{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "selection-vue",
  "title": "Selection (Vue)",
  "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/vue@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-toolbar-vue"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/vue/selection.ts",
      "content": "import {\n  type SelectionItemState,\n  type SelectionToolbarState,\n  selectionPrimitive,\n} from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/vue/primitive\";\nimport { type Component, defineComponent, h } from \"vue\";\nimport { KindToolbar, KindToolbarButton } from \"./internal/toolbar\";\n\n// `@ui-sdk/vue`'s `createParts` hands the primitive an emitter for every callback, whether or not anything listens, so\n// `onAction`, whose presence offers the actions, is declared a function prop instead, which `@action` binds.\nconst primitive = Object.defineProperty(\n  Object.assign((options: never) => selectionPrimitive(options), selectionPrimitive, {\n    options: { ...selectionPrimitive.options, onAction: \"action\" },\n  }),\n  \"name\",\n  { value: selectionPrimitive.name },\n) as typeof selectionPrimitive;\n\nconst parts = createParts(primitive, {\n  root: \"div\",\n  content: \"div\",\n  toolbar: \"div\",\n  item: \"span\",\n});\n\ntype Scope<State> = { state: State };\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\n/** An action, whose `value` is its `id`. Wrap a `KindToolbarButton`, or leave it empty for one with the action's label. */\nexport const SelectionItem = defineComponent({\n  name: \"SelectionItem\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Item as Component, attrs, {\n        ...slots,\n        default:\n          slots.default ??\n          (({ state }: Scope<SelectionItemState>) =>\n            h(KindToolbarButton, { disabled: !state.canRun, title: state.description }, () => state.label)),\n      });\n  },\n}) as unknown as typeof parts.Item;\n\n/** Shown above the selection, with one `SelectionItem` per action unless you fill its slot. */\nexport const SelectionToolbar = defineComponent({\n  name: \"SelectionToolbar\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Toolbar, attrs, {\n        ...slots,\n        default:\n          slots.default ??\n          (({ state }: Scope<SelectionToolbarState>) =>\n            h(KindToolbar, { \"aria-label\": state.label }, () =>\n              state.actions.map((action) => h(SelectionItem, { key: action.id, value: action.id })),\n            )),\n      });\n  },\n}) as unknown as typeof parts.Toolbar;\n\n/**\n * Wraps a reply so selecting text in it shows a toolbar of `actions` above the selection. Its default slot is the\n * reply.\n */\nexport const Selection = defineComponent({\n  name: \"Selection\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Root, attrs, {\n        render: slots.render,\n        default: () => [h(SelectionContent, null, () => slots.default?.()), h(SelectionToolbar)],\n      });\n  },\n}) as unknown as typeof parts.Root;\n",
      "type": "registry:ui",
      "target": "@ui/vue/selection.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
