{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "selection-solid",
  "title": "Selection (Solid)",
  "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/solid@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-toolbar-solid"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/solid/selection.tsx",
      "content": "import { selectionPrimitive } from \"@kind-ui/agent-ui/core\";\nimport type { ComponentProps, JSX } from \"@solidjs/web\";\nimport { createParts } from \"@ui-sdk/solid/primitive\";\nimport { For, omit } from \"solid-js\";\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?: JSX.Element;\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(props: SelectionProps) {\n  return (\n    <parts.Root {...omit(props, \"children\")}>\n      <SelectionContent>{props.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(props: SelectionToolbarProps) {\n  return (\n    <parts.Toolbar {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <KindToolbar aria-label={state.label}>\n            <For each={state.actions} keyed={(action) => action.id}>\n              {(action) => <SelectionItem value={action().id} />}\n            </For>\n          </KindToolbar>\n        ))}\n    </parts.Toolbar>\n  );\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(props: SelectionItemProps) {\n  return (\n    <parts.Item {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <KindToolbarButton disabled={!state.canRun} title={state.description}>\n            {state.label}\n          </KindToolbarButton>\n        ))}\n    </parts.Item>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@ui/solid/selection.tsx"
    }
  ],
  "meta": {
    "layer": "solid"
  },
  "type": "registry:ui"
}
