{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "suggestion-vue",
  "title": "Suggestion (Vue)",
  "description": "A row of prompts a person can send in one press, which scrolls sideways when they don't fit.",
  "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-carousel-vue"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/vue/suggestion.ts",
      "content": "import {\n  type SuggestionItemState,\n  type SuggestionRootState,\n  suggestionPrimitive,\n} from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/vue/primitive\";\nimport { type Component, defineComponent, h } from \"vue\";\nimport {\n  KindCarousel,\n  KindCarouselContent,\n  KindCarouselItem,\n  KindCarouselNext,\n  KindCarouselPrevious,\n  KindCarouselViewport,\n} from \"./internal/carousel\";\n\n// `@ui-sdk/vue`'s `createParts` hands the primitive an emitter for every callback, whether or not anything listens, so\n// `onPick`, whose presence makes the chips pickable, is declared a function prop instead, which `@pick` binds.\nconst primitive = Object.defineProperty(\n  Object.assign((options: never) => suggestionPrimitive(options), suggestionPrimitive, {\n    options: { ...suggestionPrimitive.options, onPick: \"action\" },\n  }),\n  \"name\",\n  { value: suggestionPrimitive.name },\n) as typeof suggestionPrimitive;\n\nconst parts = createParts(primitive, { root: \"div\", item: \"button\" });\n\n// Lucide \"chevron-left\" and \"chevron-right\", see THIRD_PARTY_NOTICES.md.\nconst chevron = (d: string) => () =>\n  h(\n    \"svg\",\n    {\n      viewBox: \"0 0 24 24\",\n      fill: \"none\",\n      stroke: \"currentColor\",\n      \"stroke-width\": \"2\",\n      \"aria-hidden\": \"true\",\n    },\n    [h(\"path\", { d, \"stroke-linecap\": \"round\", \"stroke-linejoin\": \"round\" })],\n  );\nconst chevronLeft = chevron(\"m15 18-6-6 6-6\");\nconst chevronRight = chevron(\"m9 18 6-6-6-6\");\n\n/**\n * A row of prompts a person can send in one press. It scrolls sideways when the prompts don't fit, with Previous and\n * Next beside it, or wraps onto more lines with `layout=\"wrap\"`. Anything in its default slot replaces the row and its\n * buttons: `SuggestionItem`s inside the Carousel, or `SuggestionChip`s when it wraps.\n */\nexport const Suggestion = defineComponent({\n  name: \"Suggestion\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Root, attrs, {\n        ...slots,\n        default: ({ state }: { state: SuggestionRootState }) =>\n          state.layout === \"wrap\"\n            ? (slots.default?.() ??\n              state.suggestions.map((suggestion) =>\n                h(SuggestionChip, { key: suggestion.id, value: suggestion.id }),\n              ))\n            : h(KindCarousel, { \"aria-label\": state.label, slidesPerPage: \"auto\", dragFree: true }, () =>\n                slots.default\n                  ? slots.default()\n                  : [\n                      h(SuggestionViewport, null, () =>\n                        state.suggestions.map((suggestion) =>\n                          h(SuggestionItem, { key: suggestion.id, value: suggestion.id }),\n                        ),\n                      ),\n                      h(SuggestionControls),\n                    ],\n              ),\n      });\n  },\n}) as unknown as typeof parts.Root;\n\n/** The row that scrolls, holding the suggestions. */\nexport const SuggestionViewport = defineComponent({\n  name: \"SuggestionViewport\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(KindCarouselViewport, attrs, {\n        ...slots,\n        default: () => h(KindCarouselContent, null, () => slots.default?.()),\n      });\n  },\n}) as unknown as typeof KindCarouselViewport;\n\n/** A suggestion's button, whose `value` is its `id`. Reads its label and description unless you fill its slot. */\nexport const SuggestionChip = defineComponent({\n  name: \"SuggestionChip\",\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 }: { state: SuggestionItemState }) => [\n            h(\"span\", { \"data-suggestion-label\": \"\" }, state.label),\n            ...(state.description !== undefined\n              ? [\" \", h(\"span\", { \"data-suggestion-description\": \"\" }, state.description)]\n              : []),\n          ]),\n      });\n  },\n}) as unknown as typeof parts.Item;\n\n/** A suggestion in the Carousel: a `SuggestionChip` in its slide. */\nexport const SuggestionItem = defineComponent({\n  name: \"SuggestionItem\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () => h(KindCarouselItem, null, () => h(SuggestionChip as Component, attrs, slots));\n  },\n}) as unknown as typeof parts.Item;\n\n/** Holds Previous and Next, unless you fill its slot, and hides them while every suggestion fits. */\nexport const SuggestionControls = defineComponent({\n  name: \"SuggestionControls\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(\n        \"div\",\n        { \"data-suggestion-controls\": \"\", ...attrs },\n        slots.default?.() ?? [h(SuggestionPrevious), h(SuggestionNext)],\n      );\n  },\n});\n\n// Previous and Next are hidden from agents, which takes the Carousel out of their snapshot: an agent picks any\n// suggestion by its id with the Suggestion's own `pick`, wherever it has scrolled.\n\n/** Scrolls back to earlier suggestions. Put it in `SuggestionControls` to hide it while every suggestion fits. */\nexport const SuggestionPrevious = defineComponent({\n  name: \"SuggestionPrevious\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(\n        KindCarouselPrevious,\n        { \"aria-label\": \"Previous suggestions\", \"data-agent-hidden\": \"\", ...attrs },\n        { ...slots, default: slots.default ?? chevronLeft },\n      );\n  },\n}) as unknown as typeof KindCarouselPrevious;\n\n/** Scrolls on to later suggestions. Put it in `SuggestionControls` to hide it while every suggestion fits. */\nexport const SuggestionNext = defineComponent({\n  name: \"SuggestionNext\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(\n        KindCarouselNext,\n        { \"aria-label\": \"Next suggestions\", \"data-agent-hidden\": \"\", ...attrs },\n        { ...slots, default: slots.default ?? chevronRight },\n      );\n  },\n}) as unknown as typeof KindCarouselNext;\n",
      "type": "registry:ui",
      "target": "@ui/vue/suggestion.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
