{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "picker-solid",
  "title": "Picker (Solid)",
  "description": "A button that opens a searchable list of choices, with groups, two-line rows, pages and footer actions.",
  "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-command-solid"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/solid/picker.tsx",
      "content": "import {\n  type PickerCommandState,\n  type PickerItemState,\n  type PickerOptions,\n  type PickerRow,\n  type PickerSection,\n  type PickerTriggerState,\n  pickerPrimitive,\n} from \"@kind-ui/agent-ui/core\";\nimport type { ComponentProps, JSX } from \"@solidjs/web\";\nimport { createParts } from \"@ui-sdk/solid/primitive\";\nimport { For, omit, Show } from \"solid-js\";\nimport {\n  KindCommand,\n  KindCommandEmpty,\n  KindCommandGroup,\n  KindCommandGroupLabel,\n  KindCommandInput,\n  KindCommandItem,\n  KindCommandItemIcon,\n  KindCommandItemText,\n  KindCommandList,\n  KindCommandPage,\n  KindCommandSeparator,\n  KindCommandStatus,\n} from \"./internal/command\";\nimport { iconElement } from \"./internal/kind-class\";\n\nconst parts = createParts(pickerPrimitive, {\n  root: \"div\",\n  trigger: \"button\",\n  content: \"div\",\n  viewport: \"div\",\n  command: \"div\",\n  item: \"span\",\n  note: \"p\",\n});\n\n/**\n * An item, whose `icon` is an image URL, an element such as an inline `svg`, or a function returning one, which draws a\n * new copy wherever the icon shows: the chosen item's shows in the trigger and in its row.\n */\nexport type PickerChoice = Omit<NonNullable<PickerOptions[\"items\"]>[number], \"icon\" | \"items\"> & {\n  icon?: string | JSX.Element | (() => JSX.Element);\n  items?: PickerChoice[];\n};\n\n/** A footer action, whose `icon` is an image URL, an element, or a function returning one. */\nexport type PickerFooterAction = Omit<NonNullable<PickerOptions[\"actions\"]>[number], \"icon\"> & {\n  icon?: string | JSX.Element | (() => JSX.Element);\n};\n\nconst iconOf = (icon: unknown) => (typeof icon === \"string\" ? <img src={icon} alt=\"\" /> : iconElement(icon));\n\nexport type PickerProps = Omit<ComponentProps<typeof parts.Root>, \"children\" | \"items\" | \"actions\"> & {\n  items?: PickerChoice[];\n  actions?: PickerFooterAction[];\n  children?: JSX.Element;\n};\n\nexport type PickerTriggerProps = ComponentProps<typeof parts.Trigger>;\nexport type PickerContentProps = ComponentProps<typeof parts.Content>;\nexport type PickerListProps = Omit<ComponentProps<typeof parts.Command>, \"children\"> & {\n  /** What sits in the list, from the rows: every page by default. */\n  children?: (state: PickerCommandState) => JSX.Element;\n};\nexport type PickerSectionRowsProps = {\n  section: PickerSection;\n  /** Whether a separator comes before it, as before the footer. */\n  separated?: boolean;\n  /** Renders each row: a `PickerRowItem` by default. */\n  children?: (row: PickerRow) => JSX.Element;\n};\nexport type PickerRowItemProps = Omit<ComponentProps<typeof KindCommandItem>, keyof PickerRow[\"option\"]> & {\n  row: PickerRow;\n  /** The row's content: a `PickerItem` by default. */\n  children?: JSX.Element;\n};\nexport type PickerItemProps = ComponentProps<typeof parts.Item>;\n\n/** The parts a picker renders through: Picker's, or those of a component that spreads `pickerBase`. */\nexport type PickerParts = Pick<\n  typeof parts,\n  \"Trigger\" | \"Content\" | \"Viewport\" | \"Command\" | \"Item\" | \"Note\"\n>;\n\ntype Render = (props: Record<string, unknown>, state: { presentation?: string }) => JSX.Element;\n\n/**\n * The trigger, popover, list and rows of a picker, rendered through `parts`, for Model Selector and the other\n * components that spread `pickerBase` to share Picker's markup. `Default` is the trigger and the popover. `icon` draws a\n * row's icon (an image URL or an element by default; `null` draws none), and `trailing` what follows its `meta`.\n */\nexport function pickerParts(\n  parts: PickerParts,\n  draw: { icon?: (row: PickerRow) => JSX.Element; trailing?: (row: PickerRow) => JSX.Element } = {},\n) {\n  const icon = draw.icon ?? ((row: PickerRow) => iconOf(row.icon));\n\n  const triggerContent = (state: PickerTriggerState) => (\n    <>\n      <Show when={state.icon !== undefined}>\n        <span data-picker-icon=\"\">{iconOf(state.icon)}</span>\n      </Show>\n      <span data-picker-text=\"\">{state.text}</span>\n      <span data-picker-chevron=\"\" />\n    </>\n  );\n\n  function Trigger(props: PickerTriggerProps) {\n    return <parts.Trigger {...omit(props, \"children\")}>{props.children ?? triggerContent}</parts.Trigger>;\n  }\n\n  function Content(props: PickerContentProps) {\n    const render = (content: Record<string, unknown>, state: { presentation?: string }) => {\n      const element = () => {\n        const own = props.render as Render | undefined;\n        return own ? own(content, state) : <div {...content} />;\n      };\n      // A sheet sits in a full-screen viewport, which renders only while the content presents as one.\n      return (\n        <Show when={state.presentation === \"sheet\"} fallback={element()}>\n          <parts.Viewport>{element()}</parts.Viewport>\n        </Show>\n      );\n    };\n    return (\n      <parts.Content\n        initialFocus=\"input\"\n        sideOffset={6}\n        align=\"start\"\n        {...omit(props, \"children\", \"render\")}\n        render={render as PickerContentProps[\"render\"]}\n      >\n        {props.children ?? (\n          <>\n            <List />\n            <Note />\n          </>\n        )}\n      </parts.Content>\n    );\n  }\n\n  function List(props: PickerListProps) {\n    return (\n      <parts.Command {...omit(props, \"children\")}>\n        {(state: PickerCommandState) => (\n          <KindCommand {...state.props}>\n            <KindCommandInput aria-label={state.label} placeholder={state.placeholder} data-agent-hidden=\"\" />\n            <Show when={state.statusText !== undefined}>\n              <KindCommandStatus>{state.statusText}</KindCommandStatus>\n            </Show>\n            <KindCommandEmpty>{state.emptyText}</KindCommandEmpty>\n            <KindCommandList>{(props.children ?? defaultRows)(state)}</KindCommandList>\n          </KindCommand>\n        )}\n      </parts.Command>\n    );\n  }\n\n  const defaultRows = (state: PickerCommandState) => (\n    <For each={state.pages} keyed={(page) => page.page ?? \"\"}>\n      {(page) => (\n        <KindCommandPage value={page().page}>\n          <For\n            each={page().sections}\n            keyed={(section) => (section.footer ? \"\\u0000footer\" : (section.label ?? \"\"))}\n          >\n            {(section, index) => (\n              <SectionRows section={section()} separated={section().footer && index() > 0} />\n            )}\n          </For>\n        </KindCommandPage>\n      )}\n    </For>\n  );\n\n  function SectionRows(props: PickerSectionRowsProps) {\n    return (\n      <>\n        <Show when={props.separated}>\n          <KindCommandSeparator />\n        </Show>\n        <KindCommandGroup>\n          <Show when={props.section.label}>\n            <KindCommandGroupLabel>{props.section.label}</KindCommandGroupLabel>\n          </Show>\n          {/* Keyed by its label too: Command filters a row by the label it mounted with, and a footer row's label can\n              hold the search. */}\n          <For each={props.section.rows} keyed={(row) => `${row.option.value}\\u0000${row.option.label}`}>\n            {(row) => (props.children ? props.children(row()) : <RowItem row={row()} />)}\n          </For>\n        </KindCommandGroup>\n      </>\n    );\n  }\n\n  function RowItem(props: PickerRowItemProps) {\n    return (\n      <KindCommandItem {...omit(props, \"row\", \"children\")} {...props.row.option}>\n        {props.children ?? <Item value={props.row.option.value} />}\n      </KindCommandItem>\n    );\n  }\n\n  const itemContent = (state: PickerItemState) => (\n    <>\n      {iconOfRow(state.row)}\n      <span data-picker-item-text=\"\">\n        <KindCommandItemText>{state.row.label}</KindCommandItemText>\n        <Show when={state.description.length}>\n          <span data-picker-description=\"\">\n            <For each={state.description} keyed={false}>\n              {(segment) => (\n                <Show when={segment().match} fallback={segment().text}>\n                  <mark>{segment().text}</mark>\n                </Show>\n              )}\n            </For>\n          </span>\n        </Show>\n      </span>\n      <Show when={state.row.meta}>\n        <span data-picker-meta=\"\" aria-hidden={state.row.metaLabel ? \"true\" : undefined}>\n          {state.row.meta}\n        </span>\n        <Show when={state.row.metaLabel}>\n          <span data-picker-meta-label=\"\">{state.row.metaLabel}</span>\n        </Show>\n      </Show>\n      {draw.trailing?.(state.row)}\n      <span data-picker-mark=\"\" />\n    </>\n  );\n\n  function Item(props: PickerItemProps) {\n    return <parts.Item {...omit(props, \"children\")}>{props.children ?? itemContent}</parts.Item>;\n  }\n\n  /** A line under the list, like what a model's cost means. Rendered only with one. */\n  function Note(props: ComponentProps<typeof parts.Note>) {\n    return (\n      <parts.Note {...omit(props, \"children\")}>\n        {props.children ?? ((state: { note: string }) => state.note)}\n      </parts.Note>\n    );\n  }\n\n  const iconOfRow = (row: PickerRow) => {\n    const drawn = row.icon === undefined ? null : icon(row);\n    return drawn == null ? null : <KindCommandItemIcon>{drawn}</KindCommandItemIcon>;\n  };\n\n  const Default = () => (\n    <>\n      <Trigger />\n      <Content />\n    </>\n  );\n\n  return { Trigger, Content, List, SectionRows, RowItem, Item, Note, Default };\n}\n\nconst picker = pickerParts(parts);\n\n/**\n * A button that shows the chosen item and opens a searchable list of them, with groups, two-line rows, pages and\n * footer actions. Any `children` replace the trigger and the list.\n */\nexport function Picker(props: PickerProps) {\n  return <parts.Root {...omit(props, \"children\")}>{props.children ?? <picker.Default />}</parts.Root>;\n}\n\n/** Opens the list. Shows the chosen item's icon and label, or the `label` while none is chosen, unless you pass children. */\nexport const PickerTrigger = picker.Trigger;\n/** The popover: the search field and the list, unless you pass children. Focus moves to the search field. */\nexport const PickerContent = picker.Content;\n/** UI SDK Command: the search field, the empty text, and every page of rows unless you pass children. */\nexport const PickerList = picker.List;\n/** A group of rows under its label, or the footer. */\nexport const PickerSectionRows = picker.SectionRows;\n/** A row: UI SDK's `CommandItem` with the row's props, holding its `PickerItem` unless you pass children. */\nexport const PickerRowItem = picker.RowItem;\n/** A row's content: its icon, marked label, description, `meta`, and its check or chevron. */\nexport const PickerItem = picker.Item;\n",
      "type": "registry:ui",
      "target": "@ui/solid/picker.tsx"
    }
  ],
  "meta": {
    "layer": "solid"
  },
  "type": "registry:ui"
}
