{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "suggestion-solid",
  "title": "Suggestion (Solid)",
  "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/solid@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-carousel-solid"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/solid/suggestion.tsx",
      "content": "import { suggestionPrimitive } from \"@kind-ui/agent-ui/core\";\nimport type { ComponentProps, JSX } from \"@solidjs/web\";\nimport { createParts } from \"@ui-sdk/solid/primitive\";\nimport { For, omit, children as resolveChildren, Show } from \"solid-js\";\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 chevronLeft = () => (\n  <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\">\n    <path d=\"m15 18-6-6 6-6\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />\n  </svg>\n);\nconst chevronRight = () => (\n  <svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\">\n    <path d=\"m9 18 6-6-6-6\" stroke-linecap=\"round\" stroke-linejoin=\"round\" />\n  </svg>\n);\n\nexport type SuggestionProps = Omit<ComponentProps<typeof parts.Root>, \"children\"> & {\n  children?: JSX.Element;\n};\n\n// Resolves the caller's children once, where they're placed, so they're built inside the Carousel when there is one.\nfunction Rows(props: { children?: JSX.Element; fallback: () => JSX.Element }) {\n  const resolved = resolveChildren(() => props.children);\n  return (\n    <Show when={resolved() !== undefined} fallback={props.fallback()}>\n      {resolved()}\n    </Show>\n  );\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(props: SuggestionProps) {\n  return (\n    <parts.Root {...omit(props, \"children\")}>\n      {(state) => (\n        <Show\n          when={state.layout === \"wrap\"}\n          fallback={\n            <KindCarousel aria-label={state.label} slidesPerPage=\"auto\" dragFree>\n              <Rows\n                fallback={() => (\n                  <>\n                    <SuggestionViewport>\n                      <For each={state.suggestions} keyed={(suggestion) => suggestion.id}>\n                        {(suggestion) => <SuggestionItem value={suggestion().id} />}\n                      </For>\n                    </SuggestionViewport>\n                    <SuggestionControls />\n                  </>\n                )}\n              >\n                {props.children}\n              </Rows>\n            </KindCarousel>\n          }\n        >\n          <Rows\n            fallback={() => (\n              <For each={state.suggestions} keyed={(suggestion) => suggestion.id}>\n                {(suggestion) => <SuggestionChip value={suggestion().id} />}\n              </For>\n            )}\n          >\n            {props.children}\n          </Rows>\n        </Show>\n      )}\n    </parts.Root>\n  );\n}\n\n/** The row that scrolls, holding the suggestions. */\nexport function SuggestionViewport(\n  props: Omit<ComponentProps<typeof KindCarouselViewport>, \"children\"> & { children?: JSX.Element },\n) {\n  return (\n    <KindCarouselViewport {...omit(props, \"children\")}>\n      <KindCarouselContent>{props.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(props: SuggestionChipProps) {\n  return (\n    <parts.Item {...omit(props, \"children\")}>\n      {props.children ??\n        ((state) => (\n          <>\n            <span data-suggestion-label=\"\">{state.label}</span>\n            <Show when={state.description !== undefined}>\n              {\" \"}\n              <span data-suggestion-description=\"\">{state.description}</span>\n            </Show>\n          </>\n        ))}\n    </parts.Item>\n  );\n}\n\n/** Holds Previous and Next, unless you pass children, and hides them while every suggestion fits. */\nexport function SuggestionControls(props: ComponentProps<\"div\">) {\n  return (\n    <div data-suggestion-controls=\"\" {...omit(props, \"children\")}>\n      {props.children ?? (\n        <>\n          <SuggestionPrevious />\n          <SuggestionNext />\n        </>\n      )}\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(props: ComponentProps<typeof KindCarouselPrevious>) {\n  return (\n    <KindCarouselPrevious aria-label=\"Previous suggestions\" data-agent-hidden=\"\" {...omit(props, \"children\")}>\n      {props.children ?? chevronLeft()}\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(props: ComponentProps<typeof KindCarouselNext>) {\n  return (\n    <KindCarouselNext aria-label=\"Next suggestions\" data-agent-hidden=\"\" {...omit(props, \"children\")}>\n      {props.children ?? chevronRight()}\n    </KindCarouselNext>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@ui/solid/suggestion.tsx"
    }
  ],
  "meta": {
    "layer": "solid"
  },
  "type": "registry:ui"
}
