{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "picker-svelte",
  "title": "Picker (Svelte)",
  "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/svelte@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-command-svelte"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/svelte/picker/Picker.svelte",
      "content": "<!--\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-->\n<script lang=\"ts\">\n  import type { ComponentProps, Snippet } from \"svelte\";\n  import type { PickerChoice, PickerFooterAction } from \"./index\";\n  import PickerContent from \"./PickerContent.svelte\";\n  import PickerTrigger from \"./PickerTrigger.svelte\";\n  import { parts, setPickerConfig } from \"./parts\";\n\n  type Props = ComponentProps<typeof parts.Root> & {\n    items?: PickerChoice[];\n    actions?: PickerFooterAction[];\n    children?: Snippet;\n  };\n\n  let { value = $bindable(), open = $bindable(), children, ...props }: Props = $props();\n  setPickerConfig({ parts });\n</script>\n\n<parts.Root bind:value bind:open {...props}>\n  {#if children}{@render children()}{:else}<PickerTrigger /><PickerContent />{/if}\n</parts.Root>\n",
      "type": "registry:ui",
      "target": "@ui/svelte/picker/Picker.svelte"
    },
    {
      "path": "packages/agent-ui/src/svelte/picker/PickerContent.svelte",
      "content": "<!-- The popover: the search field, the list and its note, unless you pass children. Focus moves to the search field. -->\n<script lang=\"ts\">\n  import type { ComponentProps } from \"svelte\";\n  import PickerList from \"./PickerList.svelte\";\n  import PickerNote from \"./PickerNote.svelte\";\n  import { type PickerParts, pickerConfig } from \"./parts\";\n\n  type ContentProps = ComponentProps<PickerParts[\"Content\"]>;\n  type Props = ContentProps;\n\n  let { children: content, render: own, ...props }: Props = $props();\n  const { parts } = pickerConfig();\n</script>\n\n<parts.Content initialFocus=\"input\" sideOffset={6} align=\"start\" {...props}>\n  <!-- A sheet sits in a full-screen viewport, which renders only while the content presents as one. -->\n  {#snippet render(handed: Parameters<NonNullable<ContentProps[\"render\"]>>[0])}\n    {#if handed.state.presentation === \"sheet\"}\n      <parts.Viewport>{@render element(handed)}</parts.Viewport>\n    {:else}\n      {@render element(handed)}\n    {/if}\n  {/snippet}\n  {#snippet children(state: Parameters<NonNullable<ContentProps[\"children\"]>>[0])}\n    {#if content}{@render content(state)}{:else}<PickerList /><PickerNote />{/if}\n  {/snippet}\n</parts.Content>\n\n{#snippet element(handed: Parameters<NonNullable<ContentProps[\"render\"]>>[0])}\n  {#if own}{@render own(handed)}{:else}<div {...handed.props}>{@render handed.children?.(handed.state)}</div>{/if}\n{/snippet}\n",
      "type": "registry:ui",
      "target": "@ui/svelte/picker/PickerContent.svelte"
    },
    {
      "path": "packages/agent-ui/src/svelte/picker/PickerIcon.svelte",
      "content": "<!-- An icon a host passed: an image URL, or a snippet such as an inline `svg`. -->\n<script lang=\"ts\">\n  import type { Snippet } from \"svelte\";\n\n  let { icon }: { icon: unknown } = $props();\n</script>\n\n{#if typeof icon === \"string\"}<img src={icon} alt=\"\" />{:else if typeof icon === \"function\"}{@render (icon as Snippet)()}{/if}\n",
      "type": "registry:ui",
      "target": "@ui/svelte/picker/PickerIcon.svelte"
    },
    {
      "path": "packages/agent-ui/src/svelte/picker/PickerItem.svelte",
      "content": "<!-- A row's content: its icon, marked label, description, `meta`, and its check or chevron. -->\n<script lang=\"ts\">\n  import type { PickerItemState } from \"@kind-ui/agent-ui/core\";\n  import type { ComponentProps, Snippet } from \"svelte\";\n  import { KindCommandItemIcon, KindCommandItemText } from \"../internal/command/index\";\n  import PickerIcon from \"./PickerIcon.svelte\";\n  import { type PickerParts, pickerConfig } from \"./parts\";\n\n  type Props = ComponentProps<PickerParts[\"Item\"]> & {\n    children?: Snippet<[PickerItemState]>;\n  };\n\n  let { children: content, ...props }: Props = $props();\n  const { parts, icon, trailing } = pickerConfig();\n</script>\n\n<parts.Item {...props}>\n  {#snippet children(state: PickerItemState)}\n    <!-- A row the list just dropped reads its state once more before Svelte removes it, and has none. -->\n    {#if !state.row}{:else if content}{@render content(state)}{:else}{#if state.row.icon !== undefined && icon !== null}<KindCommandItemIcon\n          >{#if icon}{@render icon(state.row)}{:else}<PickerIcon icon={state.row.icon} />{/if}</KindCommandItemIcon\n        >{/if}<span data-picker-item-text=\"\"\n        ><KindCommandItemText>{state.row.label}</KindCommandItemText\n        >{#if state.description.length}<span data-picker-description=\"\"\n            >{#each state.description as segment, index (index)}{#if segment.match}<mark>{segment.text}</mark\n                >{:else}{segment.text}{/if}{/each}</span\n          >{/if}</span\n      >{#if state.row.meta}<span data-picker-meta=\"\" aria-hidden={state.row.metaLabel ? \"true\" : undefined}\n          >{state.row.meta}</span\n        >{/if}{#if state.row.meta && state.row.metaLabel}<span data-picker-meta-label=\"\">{state.row.metaLabel}</span\n        >{/if}{@render trailing?.(\n        state.row,\n      )}<span data-picker-mark=\"\"></span>{/if}\n  {/snippet}\n</parts.Item>\n",
      "type": "registry:ui",
      "target": "@ui/svelte/picker/PickerItem.svelte"
    },
    {
      "path": "packages/agent-ui/src/svelte/picker/PickerList.svelte",
      "content": "<!-- UI SDK Command: the search field, the empty text, and every page of rows unless you pass children. -->\n<script lang=\"ts\">\n  import type { PickerCommandState } from \"@kind-ui/agent-ui/core\";\n  import type { ComponentProps, Snippet } from \"svelte\";\n  import {\n    KindCommand,\n    KindCommandEmpty,\n    KindCommandInput,\n    KindCommandList,\n    KindCommandPage,\n    KindCommandStatus,\n  } from \"../internal/command/index\";\n  import PickerSectionRows from \"./PickerSectionRows.svelte\";\n  import { type PickerParts, pickerConfig } from \"./parts\";\n\n  type Props = ComponentProps<PickerParts[\"Command\"]> & {\n    /** What sits in the list, from the rows: every page by default. */\n    children?: Snippet<[PickerCommandState]>;\n  };\n\n  let { children: rows, ...props }: Props = $props();\n  const { parts } = pickerConfig();\n</script>\n\n<parts.Command {...props}>\n  {#snippet children(state: PickerCommandState)}\n    <KindCommand {...state.props}>\n      <KindCommandInput aria-label={state.label} placeholder={state.placeholder} data-agent-hidden=\"\"\n      />{#if state.statusText !== undefined}<KindCommandStatus>{state.statusText}</KindCommandStatus>{/if}<KindCommandEmpty\n      >{state.emptyText}</KindCommandEmpty\n      ><KindCommandList>\n        {#if rows}{@render rows(state)}{:else}\n          {#each state.pages as { page, sections } (page ?? \"\")}\n            <KindCommandPage value={page}>\n              {#each sections as section, index (section.footer ? \"\\u0000footer\" : (section.label ?? \"\"))}\n                <PickerSectionRows {section} separated={section.footer && index > 0} />\n              {/each}\n            </KindCommandPage>\n          {/each}\n        {/if}\n      </KindCommandList>\n    </KindCommand>\n  {/snippet}\n</parts.Command>\n",
      "type": "registry:ui",
      "target": "@ui/svelte/picker/PickerList.svelte"
    },
    {
      "path": "packages/agent-ui/src/svelte/picker/PickerNote.svelte",
      "content": "<!-- A line under the list, like what a model's cost means, unless you pass children. Rendered only with one. -->\n<script lang=\"ts\">\n  import type { ComponentProps } from \"svelte\";\n  import { type PickerParts, pickerConfig } from \"./parts\";\n\n  let { children, ...props }: ComponentProps<PickerParts[\"Note\"]> = $props();\n  const { parts } = pickerConfig();\n</script>\n\n{#snippet note(state: { note: string })}{state.note}{/snippet}\n\n<parts.Note {...props} children={children ?? note} />\n",
      "type": "registry:ui",
      "target": "@ui/svelte/picker/PickerNote.svelte"
    },
    {
      "path": "packages/agent-ui/src/svelte/picker/PickerRowItem.svelte",
      "content": "<!-- A row: UI SDK's `CommandItem` with the row's props, holding its `PickerItem` unless you pass children. -->\n<script lang=\"ts\">\n  import type { PickerRow } from \"@kind-ui/agent-ui/core\";\n  import type { ComponentProps, Snippet } from \"svelte\";\n  import { KindCommandItem } from \"../internal/command/index\";\n  import PickerItem from \"./PickerItem.svelte\";\n\n  type Props = ComponentProps<typeof KindCommandItem> & {\n    row: PickerRow;\n    /** The row's content: a `PickerItem` by default. */\n    children?: Snippet;\n  };\n\n  let { row, children, ...props }: Props = $props();\n</script>\n\n<KindCommandItem {...props} {...row.option}>\n  {#if children}{@render children()}{:else}<PickerItem value={row.option.value} />{/if}\n</KindCommandItem>\n",
      "type": "registry:ui",
      "target": "@ui/svelte/picker/PickerRowItem.svelte"
    },
    {
      "path": "packages/agent-ui/src/svelte/picker/PickerSectionRows.svelte",
      "content": "<!-- A group of rows under its label, or the footer. -->\n<script lang=\"ts\">\n  import type { PickerRow, PickerSection } from \"@kind-ui/agent-ui/core\";\n  import type { Snippet } from \"svelte\";\n  import { KindCommandGroup, KindCommandGroupLabel, KindCommandSeparator } from \"../internal/command/index\";\n  import PickerRowItem from \"./PickerRowItem.svelte\";\n\n  let {\n    section,\n    separated = false,\n    children,\n  }: {\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?: Snippet<[PickerRow]>;\n  } = $props();\n</script>\n\n{#if separated}<KindCommandSeparator />{/if}<KindCommandGroup>\n  {#if section.label}<KindCommandGroupLabel>{section.label}</KindCommandGroupLabel>{/if}<!--\n    Keyed by its label too: a footer row's label can hold the search.\n  -->{#each section.rows as row (`${row.option.value}\\u0000${row.option.label}`)}\n    {#if children}{@render children(row)}{:else}<PickerRowItem {row} />{/if}\n  {/each}\n</KindCommandGroup>\n",
      "type": "registry:ui",
      "target": "@ui/svelte/picker/PickerSectionRows.svelte"
    },
    {
      "path": "packages/agent-ui/src/svelte/picker/PickerTrigger.svelte",
      "content": "<!-- Opens the list. Shows the chosen item's icon and label, or the `label` while none is chosen, unless you pass children. -->\n<script lang=\"ts\">\n  import type { PickerTriggerState } from \"@kind-ui/agent-ui/core\";\n  import type { ComponentProps, Snippet } from \"svelte\";\n  import PickerIcon from \"./PickerIcon.svelte\";\n  import { type PickerParts, pickerConfig } from \"./parts\";\n\n  type Props = ComponentProps<PickerParts[\"Trigger\"]> & {\n    children?: Snippet<[PickerTriggerState]>;\n  };\n\n  let { children: content, ...props }: Props = $props();\n  const { parts } = pickerConfig();\n</script>\n\n<parts.Trigger {...props}>\n  {#snippet children(state: PickerTriggerState)}\n    {#if content}{@render content(state)}{:else}\n      {#if state.icon !== undefined}<span data-picker-icon=\"\"><PickerIcon icon={state.icon} /></span>{/if}<span data-picker-text=\"\"\n      >{state.text}</span\n      ><span data-picker-chevron=\"\"></span>\n    {/if}\n  {/snippet}\n</parts.Trigger>\n",
      "type": "registry:ui",
      "target": "@ui/svelte/picker/PickerTrigger.svelte"
    },
    {
      "path": "packages/agent-ui/src/svelte/picker/index.ts",
      "content": "import type { PickerOptions } from \"@kind-ui/agent-ui/core\";\nimport type { Snippet } from \"svelte\";\n\n/** An item, whose `icon` is an image URL or a snippet such as an inline `svg`. */\nexport type PickerChoice = Omit<NonNullable<PickerOptions[\"items\"]>[number], \"icon\" | \"items\"> & {\n  icon?: string | Snippet;\n  items?: PickerChoice[];\n};\n\n/** A footer action, whose `icon` is an image URL or a snippet. */\nexport type PickerFooterAction = Omit<NonNullable<PickerOptions[\"actions\"]>[number], \"icon\"> & {\n  icon?: string | Snippet;\n};\n\nexport { default as Picker } from \"./Picker.svelte\";\nexport { default as PickerContent } from \"./PickerContent.svelte\";\nexport { default as PickerItem } from \"./PickerItem.svelte\";\nexport { default as PickerList } from \"./PickerList.svelte\";\nexport { default as PickerRowItem } from \"./PickerRowItem.svelte\";\nexport { default as PickerSectionRows } from \"./PickerSectionRows.svelte\";\nexport { default as PickerTrigger } from \"./PickerTrigger.svelte\";\nexport { type PickerConfig, type PickerParts, setPickerConfig } from \"./parts\";\n",
      "type": "registry:ui",
      "target": "@ui/svelte/picker/index.ts"
    },
    {
      "path": "packages/agent-ui/src/svelte/picker/parts.ts",
      "content": "import { type PickerRow, pickerPrimitive } from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/svelte/primitive\";\nimport { getContext, type Snippet, setContext } from \"svelte\";\n\nexport const 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/** 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\n/**\n * How a picker draws its parts, which its root hands the parts inside it. `icon` draws a row's icon (an image URL\n * or a snippet by default; `null` draws none), and `trailing` what follows its `meta`.\n */\nexport type PickerConfig = {\n  parts: PickerParts;\n  icon?: Snippet<[PickerRow]> | null;\n  trailing?: Snippet<[PickerRow]>;\n};\n\nconst key = Symbol(\"kind-picker\");\n\n/** Lets the Picker parts inside render through `config.parts`, for components that spread `pickerBase`. */\nexport const setPickerConfig = (config: PickerConfig) => setContext(key, config);\nexport const pickerConfig = () => getContext<PickerConfig>(key);\n",
      "type": "registry:ui",
      "target": "@ui/svelte/picker/parts.ts"
    }
  ],
  "meta": {
    "layer": "svelte"
  },
  "type": "registry:ui"
}
