{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "graph-node-group",
  "title": "Graph Node Group",
  "description": "A group of graph nodes, as plain markup: a tinted island around them and a name tag on its top edge with a drag handle and room for controls. Four sizes, palette tones, and an empty state with an add button in the group's tone. It hugs the nodes inside it, or takes its size from a canvas.",
  "dependencies": [
    "@base-ui/react@^1.8.0",
    "class-variance-authority@^0.7.1",
    "lucide-react@^1.41.0"
  ],
  "registryDependencies": [
    "button",
    "@pipecat/graph-tone"
  ],
  "files": [
    {
      "path": "src/components/graph/node-group.tsx",
      "content": "\"use client\";\n\nimport { mergeProps } from \"@base-ui/react/merge-props\";\nimport { useRender } from \"@base-ui/react/use-render\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { PlusIcon } from \"lucide-react\";\n\nimport {\n  type GraphTone,\n  graphToneStyle,\n} from \"@/components/pipecat/graph/tone\";\nimport { Button } from \"@/components/ui/button\";\nimport { cn } from \"@/lib/utils\";\n\n/*\n * The root paints nothing: it is the box a canvas places and the scope its\n * parts read their sizes and tone from. That lets a canvas draw the island\n * under its nodes and the tag over them, each in a root of its own.\n */\nconst nodeGroupVariants = cva(\"group/node-group relative grid w-fit\", {\n  variants: {\n    size: {\n      sm: \"[--node-group-px:--spacing(4)] [--node-group-py:--spacing(4)] [--node-group-radius:calc(var(--radius)*2.2)] [--node-group-text:--spacing(3)]\",\n      md: \"[--node-group-px:--spacing(6)] [--node-group-py:--spacing(6)] [--node-group-radius:calc(var(--radius)*2.6)] [--node-group-text:--spacing(3.5)]\",\n      lg: \"[--node-group-px:--spacing(8)] [--node-group-py:--spacing(8)] [--node-group-radius:calc(var(--radius)*3)] [--node-group-text:--spacing(4)]\",\n      xl: \"[--node-group-px:--spacing(10)] [--node-group-py:--spacing(10)] [--node-group-radius:calc(var(--radius)*3.4)] [--node-group-text:--spacing(4.5)]\",\n    },\n  },\n  defaultVariants: { size: \"md\" },\n});\n\nexport type NodeGroupSize = NonNullable<\n  VariantProps<typeof nodeGroupVariants>[\"size\"]\n>;\n\nexport interface NodeGroupProps extends useRender.ComponentProps<\"div\"> {\n  /** The island's padding and radius, and the tag's type. */\n  size?: NodeGroupSize;\n  /** The palette tone of the island, the tag's dot and everything inside. */\n  tone?: GraphTone;\n  /** A group with nothing in it yet: the island is outlined, waiting for a node. */\n  empty?: boolean;\n}\n\n/**\n * A group of nodes. It hugs what is inside it, or takes a width and height\n * from a canvas that works them out.\n */\nexport function NodeGroup({\n  size = \"md\",\n  tone,\n  empty = false,\n  className,\n  render,\n  ...props\n}: NodeGroupProps) {\n  return useRender({\n    defaultTagName: \"div\",\n    render,\n    props: mergeProps<\"div\">(\n      {\n        className: cn(nodeGroupVariants({ size }), className),\n        style: graphToneStyle(tone),\n      },\n      props,\n    ),\n    state: { slot: \"node-group\", size, tone, empty },\n  });\n}\n\nexport type NodeGroupIslandProps = useRender.ComponentProps<\"div\">;\n\n/**\n * The tinted region behind a group's nodes. Put the nodes inside it, or leave\n * it bare and let the group's box size it. The top is deeper, for the tag.\n */\nexport function NodeGroupIsland({\n  className,\n  render,\n  ...props\n}: NodeGroupIslandProps) {\n  return useRender({\n    defaultTagName: \"div\",\n    render,\n    props: mergeProps<\"div\">(\n      {\n        className: cn(\n          \"bg-graph-tone-soft grid min-w-0 rounded-(--node-group-radius) px-(--node-group-px) pt-[calc(var(--node-group-py)*2)] pb-(--node-group-py)\",\n          // An outline, so an empty group is the same size as a full one, and\n          // even padding, so what it shows sits in the island's centre.\n          \"outline-graph-tone-mid group-data-empty/node-group:min-h-54 group-data-empty/node-group:min-w-72 group-data-empty/node-group:pt-(--node-group-py) group-data-empty/node-group:outline-2 group-data-empty/node-group:-outline-offset-2 group-data-empty/node-group:outline-dashed\",\n          className,\n        ),\n      },\n      props,\n    ),\n    state: { slot: \"node-group-island\" },\n  });\n}\n\nexport type NodeGroupTagProps = useRender.ComponentProps<\"div\">;\n\n/** The group's name tag. It straddles the top edge, a little in from the corner. */\nexport function NodeGroupTag({\n  className,\n  render,\n  ...props\n}: NodeGroupTagProps) {\n  return useRender({\n    defaultTagName: \"div\",\n    render,\n    props: mergeProps<\"div\">(\n      {\n        className: cn(\n          \"bg-card text-card-foreground ring-foreground/10 absolute top-0 left-[calc(var(--node-group-px)-var(--spacing)*2)] z-1 flex -translate-y-1/2 items-center gap-0.5 rounded-full p-1 text-(length:--node-group-text) leading-snug whitespace-nowrap shadow-sm ring-1\",\n          className,\n        ),\n      },\n      props,\n    ),\n    state: { slot: \"node-group-tag\" },\n  });\n}\n\nexport type NodeGroupHandleProps = useRender.ComponentProps<\"span\">;\n\n/**\n * The part of the tag a group is dragged by: a grip and its name. It only\n * looks grabbable; the dragging is the canvas's.\n */\nexport function NodeGroupHandle({\n  className,\n  render,\n  ...props\n}: NodeGroupHandleProps) {\n  return useRender({\n    defaultTagName: \"span\",\n    render,\n    props: mergeProps<\"span\">(\n      {\n        className: cn(\n          \"[&_svg]:text-muted-foreground flex cursor-grab items-center gap-1.5 rounded-full py-0.5 pr-2 pl-1 active:cursor-grabbing [&_svg]:size-[calc(var(--node-group-text)+var(--spacing)/2)] [&_svg]:shrink-0\",\n          className,\n        ),\n      },\n      props,\n    ),\n    state: { slot: \"node-group-handle\" },\n  });\n}\n\nexport type NodeGroupTitleProps = useRender.ComponentProps<\"span\">;\n\n/** The group's name, after a dot in its tone. */\nexport function NodeGroupTitle({\n  className,\n  render,\n  ...props\n}: NodeGroupTitleProps) {\n  return useRender({\n    defaultTagName: \"span\",\n    render,\n    props: mergeProps<\"span\">(\n      {\n        className: cn(\n          \"font-heading before:bg-graph-tone flex items-center gap-1.5 font-semibold before:size-[calc(var(--node-group-text)-var(--spacing))] before:shrink-0 before:rounded-full\",\n          className,\n        ),\n      },\n      props,\n    ),\n    state: { slot: \"node-group-title\" },\n  });\n}\n\nexport type NodeGroupEmptyProps = useRender.ComponentProps<\"div\">;\n\n/** What an empty group shows in the middle of its island: a button, a hint. */\nexport function NodeGroupEmpty({\n  className,\n  render,\n  ...props\n}: NodeGroupEmptyProps) {\n  return useRender({\n    defaultTagName: \"div\",\n    render,\n    props: mergeProps<\"div\">(\n      {\n        className: cn(\n          // Centred in the island however the island lays out its nodes.\n          \"text-graph-tone-ink flex flex-col items-center justify-center gap-2 place-self-center text-center text-[length:calc(var(--node-group-text)-var(--spacing)/2)] leading-snug font-medium\",\n          className,\n        ),\n      },\n      props,\n    ),\n    state: { slot: \"node-group-empty\" },\n  });\n}\n\n/** An icon-only button needs a name: one of these has to be given. */\ntype Named =\n  | { \"aria-label\": string }\n  | { \"aria-labelledby\": string }\n  | { children: React.ReactNode };\n\nexport type NodeGroupAddProps = React.ComponentProps<typeof Button> & Named;\n\n/**\n * The button an empty group starts from, in the group's tone: dashed at rest,\n * tinted under the pointer, filled while it has something open. It goes in\n * `NodeGroupEmpty`; say what it adds with `aria-label`.\n */\nexport function NodeGroupAdd({\n  className,\n  children,\n  ...props\n}: NodeGroupAddProps) {\n  return (\n    <Button\n      variant=\"outline\"\n      size=\"icon-lg\"\n      {...props}\n      data-slot=\"node-group-add\"\n      className={cn(\n        \"border-graph-tone bg-card text-graph-tone-ink size-[calc(var(--node-group-text)*4)] rounded-full border-2 border-dashed [&_svg:not([class*='size-'])]:size-[calc(var(--node-group-text)+var(--spacing)*2.5)]\",\n        \"hover:bg-graph-tone-mid/40 hover:text-graph-tone-ink hover:border-solid\",\n        \"aria-expanded:bg-graph-tone aria-expanded:text-card aria-expanded:border-solid\",\n        // The stock outline button turns grey in dark mode; this one keeps its tone.\n        \"dark:border-graph-tone dark:bg-card dark:hover:bg-graph-tone-mid/40 dark:aria-expanded:bg-graph-tone\",\n        className,\n      )}\n    >\n      {children ?? <PlusIcon aria-hidden />}\n    </Button>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/pipecat/graph/node-group.tsx"
    }
  ],
  "docs": "Compose NodeGroup > NodeGroupTag (NodeGroupHandle, NodeGroupTitle, your buttons) and NodeGroupIsland around the nodes. On a canvas, give NodeGroup a position and size and leave the island bare; put the tag in a second NodeGroup to draw it over the nodes. Size it with the --node-group-* variables.",
  "categories": [
    "graph"
  ],
  "type": "registry:component"
}