{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "action-vue",
  "title": "Action (Vue)",
  "description": "An action run on selected text as a step, quoting the text above its streamed result.",
  "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/markdown-vue"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/vue/action.ts",
      "content": "import { type ActionState, actionPrimitive } from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/vue/primitive\";\nimport { type Component, defineComponent, h, type Slot, type VNode } from \"vue\";\nimport { Markdown } from \"./markdown\";\n\n// `$stable` tells Vue these slots never change, so a part that renders again doesn't render the parts inside it.\nconst stable = (slot: () => unknown) => ({ default: slot, $stable: true });\n\nconst parts = createParts(actionPrimitive, {\n  root: \"div\",\n  trigger: \"button\",\n  icon: \"span\",\n  title: \"span\",\n  content: \"div\",\n  quote: \"blockquote\",\n  result: \"div\",\n});\n\n// A part whose default slot falls back to content built from its state.\nfunction withDefault<C extends Component>(\n  part: C,\n  name: string,\n  fallback: (state: ActionState & { streaming: boolean }) => unknown,\n) {\n  return defineComponent({\n    name,\n    inheritAttrs: false,\n    setup(_, { attrs, slots }) {\n      const fill: Slot = ({ state }) => fallback(state) as VNode[];\n      return () => h(part, attrs, { ...slots, default: slots.default ?? fill });\n    },\n  }) as unknown as C;\n}\n\nexport const ActionTrigger = parts.Trigger;\nexport const ActionIcon = parts.Icon;\nexport const ActionContent = parts.Content;\n\n/** The `label`, else \"Action\", unless you fill the default slot. */\nexport const ActionTitle = withDefault(parts.Title, \"ActionTitle\", (state) => state.title);\n\n/** The `quote`, unless you fill the default slot. */\nexport const ActionQuote = withDefault(parts.Quote, \"ActionQuote\", (state) => state.quote);\n\n/** The `result` as markdown, streaming while the action runs, unless you fill the default slot. */\nexport const ActionResult = withDefault(parts.Result, \"ActionResult\", (state) =>\n  h(Markdown, { source: state.result, streaming: state.streaming }),\n);\n\n/**\n * An action run on selected text, as a step: its `label`, the `quote` it ran on and its `result` as streamed markdown.\n * A default slot replaces the default trigger and content.\n */\nexport const Action = withDefault(parts.Root, \"Action\", () => [\n  h(\n    ActionTrigger,\n    null,\n    stable(() => [h(ActionIcon), h(ActionTitle)]),\n  ),\n  h(\n    ActionContent,\n    null,\n    stable(() => [h(ActionQuote), h(ActionResult)]),\n  ),\n]);\n",
      "type": "registry:ui",
      "target": "@ui/vue/action.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
