{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "suggestion",
  "title": "Suggestion",
  "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/react@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-carousel"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/react/suggestion.tsx",
      "content": "\"use client\";\n\nimport { suggestionPrimitive } from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/react/primitive\";\nimport type { ComponentProps, ReactNode } from \"react\";\nimport {\n  KindCarousel,\n  KindCarouselContent,\n  KindCarouselItem,\n  KindCarouselNext,\n  KindCarouselPrevious,\n  KindCarouselViewport,\n} from \"./internal/carousel\";\n\nconst parts = createParts(suggestionPrimitive, { root: \"div\", item: \"button\" });\n\n// Lucide \"chevron-left\" and \"chevron-right\", see THIRD_PARTY_NOTICES.md.\nconst CHEVRON_LEFT = (\n  <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" aria-hidden=\"true\">\n    <path d=\"m15 18-6-6 6-6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n  </svg>\n);\nconst CHEVRON_RIGHT = (\n  <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" aria-hidden=\"true\">\n    <path d=\"m9 18 6-6-6-6\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n  </svg>\n);\n\nexport type SuggestionProps = Omit<ComponentProps<typeof parts.Root>, \"children\"> & {\n  children?: ReactNode;\n};\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\"`. Any `children` replace the row and its buttons:\n * `SuggestionItem`s inside the Carousel, or `SuggestionChip`s when it wraps.\n */\nexport function Suggestion({ children, ...props }: SuggestionProps) {\n  return (\n    <parts.Root {...props}>\n      {({ label, layout, suggestions }) =>\n        layout === \"wrap\" ? (\n          children !== undefined ? (\n            children\n          ) : (\n            suggestions.map((suggestion) => <SuggestionChip key={suggestion.id} value={suggestion.id} />)\n          )\n        ) : (\n          <KindCarousel aria-label={label} slidesPerPage=\"auto\" dragFree>\n            {children !== undefined ? (\n              children\n            ) : (\n              <>\n                <SuggestionViewport>\n                  {suggestions.map((suggestion) => (\n                    <SuggestionItem key={suggestion.id} value={suggestion.id} />\n                  ))}\n                </SuggestionViewport>\n                <SuggestionControls />\n              </>\n            )}\n          </KindCarousel>\n        )\n      }\n    </parts.Root>\n  );\n}\n\n/** The row that scrolls, holding the suggestions. */\nexport function SuggestionViewport({\n  children,\n  ...props\n}: Omit<ComponentProps<typeof KindCarouselViewport>, \"children\"> & { children?: ReactNode }) {\n  return (\n    <KindCarouselViewport {...props}>\n      <KindCarouselContent>{children}</KindCarouselContent>\n    </KindCarouselViewport>\n  );\n}\n\nexport type SuggestionItemProps = ComponentProps<typeof parts.Item>;\n\n/** A suggestion in the Carousel: a `SuggestionChip` in its slide. */\nexport function SuggestionItem(props: SuggestionItemProps) {\n  return (\n    <KindCarouselItem>\n      <SuggestionChip {...props} />\n    </KindCarouselItem>\n  );\n}\n\nexport type SuggestionChipProps = ComponentProps<typeof parts.Item>;\n\n/** A suggestion's button, whose `value` is its `id`. Reads its label and description unless you pass children. */\nexport function SuggestionChip({\n  children = ({ label, description }) => (\n    <>\n      <span data-suggestion-label=\"\">{label}</span>\n      {description !== undefined && (\n        <>\n          {\" \"}\n          <span data-suggestion-description=\"\">{description}</span>\n        </>\n      )}\n    </>\n  ),\n  ...props\n}: SuggestionChipProps) {\n  return <parts.Item {...props}>{children}</parts.Item>;\n}\n\n/** Holds Previous and Next, unless you pass children, and hides them while every suggestion fits. */\nexport function SuggestionControls({\n  children = (\n    <>\n      <SuggestionPrevious />\n      <SuggestionNext />\n    </>\n  ),\n  ...props\n}: ComponentProps<\"div\">) {\n  return (\n    <div data-suggestion-controls=\"\" {...props}>\n      {children}\n    </div>\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 function SuggestionPrevious({\n  children = CHEVRON_LEFT,\n  ...props\n}: ComponentProps<typeof KindCarouselPrevious>) {\n  return (\n    <KindCarouselPrevious aria-label=\"Previous suggestions\" data-agent-hidden=\"\" {...props}>\n      {children}\n    </KindCarouselPrevious>\n  );\n}\n\n/** Scrolls on to later suggestions. Put it in `SuggestionControls` to hide it while every suggestion fits. */\nexport function SuggestionNext({\n  children = CHEVRON_RIGHT,\n  ...props\n}: ComponentProps<typeof KindCarouselNext>) {\n  return (\n    <KindCarouselNext aria-label=\"Next suggestions\" data-agent-hidden=\"\" {...props}>\n      {children}\n    </KindCarouselNext>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@ui/suggestion.tsx"
    }
  ],
  "meta": {
    "layer": "react"
  },
  "type": "registry:ui"
}
