{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "selection",
  "title": "Selection",
  "description": "A small toolbar of actions that floats above text a person selects in a reply.",
  "dependencies": [
    "@kind-ui/agent-ui@0.9.0",
    "@ui-sdk/core@0.1.0-beta.17",
    "@ui-sdk/react@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-toolbar"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/react/selection.tsx",
      "content": "\"use client\";\n\nimport { selectionPrimitive } from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/react/primitive\";\nimport type { ComponentProps, ReactNode } from \"react\";\nimport { KindToolbar, KindToolbarButton } from \"./internal/toolbar\";\n\nconst parts = createParts(selectionPrimitive, {\n  root: \"div\",\n  content: \"div\",\n  toolbar: \"div\",\n  item: \"span\",\n});\n\nexport type SelectionProps = Omit<ComponentProps<typeof parts.Root>, \"children\"> & {\n  children?: ReactNode;\n};\n\n/**\n * Wraps a reply so selecting text in it shows a toolbar of `actions` above the selection. The `children` are the reply.\n */\nexport function Selection({ children, ...props }: SelectionProps) {\n  return (\n    <parts.Root {...props}>\n      <SelectionContent>{children}</SelectionContent>\n      <SelectionToolbar />\n    </parts.Root>\n  );\n}\n\n/** The bare root, for arranging `SelectionContent` and `SelectionToolbar` yourself. */\nexport const SelectionRoot = parts.Root;\n\n/** Holds the text a person selects. Put `SelectionToolbar` right after it. */\nexport const SelectionContent = parts.Content;\n\nexport type SelectionToolbarProps = ComponentProps<typeof parts.Toolbar>;\n\n/** Shown above the selection, with one `SelectionItem` per action unless you pass children. */\nexport function SelectionToolbar({\n  children = ({ label, actions }) => (\n    <KindToolbar aria-label={label}>\n      {actions.map((action) => (\n        <SelectionItem key={action.id} value={action.id} />\n      ))}\n    </KindToolbar>\n  ),\n  ...props\n}: SelectionToolbarProps) {\n  return <parts.Toolbar {...props}>{children}</parts.Toolbar>;\n}\n\nexport type SelectionItemProps = ComponentProps<typeof parts.Item>;\n\n/** An action, whose `value` is its `id`. Wrap a `KindToolbarButton`, or leave it empty for one with the action's label. */\nexport function SelectionItem({\n  children = ({ label, description, canRun }) => (\n    <KindToolbarButton disabled={!canRun} title={description}>\n      {label}\n    </KindToolbarButton>\n  ),\n  ...props\n}: SelectionItemProps) {\n  return <parts.Item {...props}>{children}</parts.Item>;\n}\n",
      "type": "registry:ui",
      "target": "@ui/selection.tsx"
    }
  ],
  "meta": {
    "layer": "react"
  },
  "type": "registry:ui"
}
