{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "graph-node-connector",
  "title": "Graph Node Connector",
  "description": "Connector areas for the left and right edges of a graph node: rows of ports, with or without labels. A port is a circle or a diamond, outlined, dashed or solid, shows a halo on hover, and takes the node's tone or one of its own.",
  "dependencies": [
    "@base-ui/react@^1.8.0",
    "class-variance-authority@^0.7.1"
  ],
  "registryDependencies": [
    "@pipecat/graph-tone",
    "@pipecat/graph-node"
  ],
  "files": [
    {
      "path": "src/components/graph/node-connector.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\";\n\nimport {\n  type GraphTone,\n  graphToneStyle,\n} from \"@/components/pipecat/graph/tone\";\nimport { cn } from \"@/lib/utils\";\n\n/*\n * A connector area fills the `left` or `right` column of a node. Its sizes\n * come from the node's type, so connectors follow the node's size, and are\n * declared here: set any of them on the area to change it.\n */\nconst nodeConnectorsVariants = cva(\n  [\n    // Raised, so ports stay over the card when the area sits beside it.\n    \"group/node-connectors relative z-1 flex max-w-(--node-connector-max-width) min-w-0 flex-col justify-center pt-(--node-body-pt) pb-(--node-body-pb)\",\n    \"[--node-connector-height:calc(var(--node-text)*2_-_var(--spacing))] [--node-connector-port:calc(var(--node-text)_-_var(--spacing)/2)] [--node-connector-text:var(--node-text-description)]\",\n    // Labels truncate at two fifths of the size's own width, however wide a fluid node is.\n    \"[--node-connector-max-width:calc(var(--node-width)*0.4)]\",\n  ],\n  {\n    variants: {\n      side: {\n        left: \"[grid-area:left]\",\n        right: \"[grid-area:right]\",\n      },\n    },\n  },\n);\n\nexport type NodeConnectorsProps = useRender.ComponentProps<\"div\">;\n\nfunction NodeConnectors({\n  side,\n  className,\n  render,\n  ...props\n}: NodeConnectorsProps & { side: \"left\" | \"right\" }) {\n  return useRender({\n    defaultTagName: \"div\",\n    render,\n    props: mergeProps<\"div\">(\n      { className: cn(nodeConnectorsVariants({ side }), className) },\n      props,\n    ),\n    state: { slot: \"node-connectors\", side },\n  });\n}\n\n/** The connectors on the node's left edge, level with its content. */\nexport function NodeConnectorsLeft(props: NodeConnectorsProps) {\n  return <NodeConnectors side=\"left\" {...props} />;\n}\n\n/** The connectors on the node's right edge, level with its content. */\nexport function NodeConnectorsRight(props: NodeConnectorsProps) {\n  return <NodeConnectors side=\"right\" {...props} />;\n}\n\nexport interface NodeConnectorProps extends useRender.ComponentProps<\"div\"> {\n  /** The connector's own tone, for its port and label. Defaults to the node's. */\n  tone?: GraphTone;\n  /** The connector in use: its port fills and its label is tinted. */\n  active?: boolean;\n}\n\n/** One row of a connector area: a port, with or without a label. */\nexport function NodeConnector({\n  tone,\n  active = false,\n  className,\n  render,\n  ...props\n}: NodeConnectorProps) {\n  return useRender({\n    defaultTagName: \"div\",\n    render,\n    props: mergeProps<\"div\">(\n      {\n        className: cn(\n          // The port takes no room, so the gap is the label's distance from the\n          // node's edge: the node's own inline padding.\n          \"group/node-connector flex min-h-(--node-connector-height) w-full min-w-0 items-center gap-(--node-px) group-data-[side=right]/node-connectors:justify-end\",\n          className,\n        ),\n        style: graphToneStyle(tone),\n      },\n      props,\n    ),\n    state: { slot: \"node-connector\", tone, active },\n  });\n}\n\nconst nodeConnectorPortVariants = cva(\n  [\n    \"border-graph-tone bg-card order-first -mx-[calc(var(--node-connector-port)/2)] size-(--node-connector-port) shrink-0 border-2\",\n    // Rendered as a canvas's handle, it stays where the row puts it.\n    \"static transform-none\",\n    // A halo in the port's tone on hover, so it reads as something to grab.\n    \"outline-4 outline-transparent transition-[outline-color] hover:outline-graph-tone/30 forced-colors:outline-none\",\n    \"group-data-[side=right]/node-connectors:order-last\",\n    \"group-data-active/node-connector:bg-graph-tone group-data-active/node-connector:border-solid\",\n  ],\n  {\n    variants: {\n      shape: {\n        circle: \"rounded-full\",\n        diamond: \"rotate-45 rounded-[calc(var(--node-connector-port)/6)]\",\n      },\n      variant: {\n        outline: \"\",\n        dashed: \"border-dashed\",\n        solid: \"bg-graph-tone\",\n      },\n    },\n    defaultVariants: { shape: \"circle\", variant: \"outline\" },\n  },\n);\n\ntype PortVariants = VariantProps<typeof nodeConnectorPortVariants>;\n\nexport interface NodeConnectorPortProps extends useRender.ComponentProps<\"span\"> {\n  /** A diamond marks a link into or out of another graph. */\n  shape?: NonNullable<PortVariants[\"shape\"]>;\n  /** The ring alone, a dashed ring, or filled with the tone. */\n  variant?: NonNullable<PortVariants[\"variant\"]>;\n}\n\n/**\n * Where a wire ends. It sits on the outer edge of its area, centred on the\n * card's edge, wherever it comes in the markup, and takes no width.\n */\nexport function NodeConnectorPort({\n  shape = \"circle\",\n  variant = \"outline\",\n  className,\n  render,\n  ...props\n}: NodeConnectorPortProps) {\n  return useRender({\n    defaultTagName: \"span\",\n    render,\n    props: mergeProps<\"span\">(\n      {\n        className: cn(nodeConnectorPortVariants({ shape, variant }), className),\n      },\n      props,\n    ),\n    state: { slot: \"node-connector-port\", shape, variant },\n  });\n}\n\nexport type NodeConnectorLabelProps = useRender.ComponentProps<\"span\">;\n\nexport function NodeConnectorLabel({\n  className,\n  render,\n  ...props\n}: NodeConnectorLabelProps) {\n  return useRender({\n    defaultTagName: \"span\",\n    render,\n    props: mergeProps<\"span\">(\n      {\n        className: cn(\n          \"text-muted-foreground group-data-active/node-connector:bg-graph-tone-soft group-data-active/node-connector:text-graph-tone-ink -mx-1 min-w-0 truncate rounded-sm px-1 text-(length:--node-connector-text) leading-snug\",\n          className,\n        ),\n      },\n      props,\n    ),\n    state: { slot: \"node-connector-label\" },\n  });\n}\n",
      "type": "registry:component",
      "target": "components/pipecat/graph/node-connector.tsx"
    }
  ],
  "docs": "Put NodeConnectorsLeft or NodeConnectorsRight in a GraphNode, with one NodeConnector per row holding a NodeConnectorPort and an optional NodeConnectorLabel. Size connectors with the --node-connector-* variables on the area.",
  "categories": [
    "graph"
  ],
  "type": "registry:component"
}