{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "picker-vue",
  "title": "Picker (Vue)",
  "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/vue@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-command-vue"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/vue/picker.ts",
      "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 { createParts } from \"@ui-sdk/vue/primitive\";\nimport { type Component, defineComponent, Fragment, h, type PropType, type SlotsType, type VNode } from \"vue\";\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\";\n\n// `@ui-sdk/vue`'s `createParts` hands the primitive an emitter for every callback, whether or not anything listens, so\n// `onAction`, whose presence offers `run`, is declared a function prop instead, which `@action` binds.\nconst primitive = Object.defineProperty(\n  Object.assign((options: never) => pickerPrimitive(options), pickerPrimitive, {\n    options: { ...pickerPrimitive.options, onAction: \"action\" },\n  }),\n  \"name\",\n  { value: pickerPrimitive.name },\n) as typeof pickerPrimitive;\n\nconst parts = createParts(primitive, {\n  root: \"div\",\n  trigger: \"button\",\n  content: \"div\",\n  viewport: \"div\",\n  command: \"div\",\n  item: \"span\",\n  note: \"p\",\n});\n\n/** An item, whose `icon` is an image URL or a node such as an inline `svg`. */\nexport type PickerChoice = Omit<NonNullable<PickerOptions[\"items\"]>[number], \"icon\" | \"items\"> & {\n  icon?: string | VNode;\n  items?: PickerChoice[];\n};\n\n/** A footer action, whose `icon` is an image URL or a node. */\nexport type PickerFooterAction = Omit<NonNullable<PickerOptions[\"actions\"]>[number], \"icon\"> & {\n  icon?: string | VNode;\n};\n\nconst iconOf = (icon: unknown) =>\n  typeof icon === \"string\" ? h(\"img\", { src: icon, alt: \"\" }) : (icon as VNode | undefined);\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 * 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, each part named `<name><Part>` in Vue's tools.\n * `Default` renders the trigger and the popover. `icon` draws a row's icon (an image URL or a node by default;\n * `null` draws none), and `trailing` what follows its `meta`.\n */\nexport function pickerParts<P extends PickerParts>(\n  parts: P,\n  name: string,\n  {\n    icon = (row: PickerRow) => iconOf(row.icon),\n    trailing,\n  }: { icon?: (row: PickerRow) => unknown; trailing?: (row: PickerRow) => unknown } = {},\n) {\n  const Part = parts as unknown as Record<keyof PickerParts, Component>;\n\n  const Trigger = defineComponent({\n    name: `${name}Trigger`,\n    inheritAttrs: false,\n    setup(_, { attrs, slots }) {\n      return () =>\n        h(Part.Trigger, attrs, {\n          ...slots,\n          default:\n            slots.default ??\n            (({ state }: { state: PickerTriggerState }) => [\n              state.icon !== undefined ? h(\"span\", { \"data-picker-icon\": \"\" }, [iconOf(state.icon)]) : null,\n              h(\"span\", { \"data-picker-text\": \"\" }, state.text),\n              h(\"span\", { \"data-picker-chevron\": \"\" }),\n            ]),\n        });\n    },\n  });\n\n  const List = defineComponent({\n    name: `${name}List`,\n    inheritAttrs: false,\n    /** What sits in the list, from the rows: every page by default. */\n    slots: Object as SlotsType<{ default?: { state: PickerCommandState } }>,\n    setup(_, { attrs, slots }) {\n      return () =>\n        h(Part.Command, attrs, {\n          ...slots,\n          default: ({ state }: { state: PickerCommandState }) =>\n            h(KindCommand, state.props, () => [\n              h(KindCommandInput, {\n                \"aria-label\": state.label,\n                placeholder: state.placeholder,\n                \"data-agent-hidden\": \"\",\n              }),\n              state.statusText !== undefined ? h(KindCommandStatus, null, () => state.statusText) : null,\n              h(KindCommandEmpty, null, () => state.emptyText),\n              h(KindCommandList, null, () => (slots.default ? slots.default({ state }) : defaultRows(state))),\n            ]),\n        });\n    },\n  });\n\n  const defaultRows = ({ pages }: PickerCommandState) =>\n    pages.map(({ page, sections }) =>\n      h(KindCommandPage, { key: page ?? \"\", value: page }, () =>\n        sections.map((section, index) =>\n          h(SectionRows, {\n            key: section.footer ? \"\\u0000footer\" : (section.label ?? \"\"),\n            section,\n            separated: section.footer && index > 0,\n          }),\n        ),\n      ),\n    );\n\n  const SectionRows = defineComponent({\n    name: `${name}SectionRows`,\n    props: {\n      section: { type: Object as PropType<PickerSection>, required: true },\n      /** Whether a separator comes before it, as before the footer. */\n      separated: Boolean,\n    },\n    /** Renders each row: a `PickerRowItem` by default. */\n    slots: Object as SlotsType<{ default?: { row: PickerRow } }>,\n    setup(props, { slots }) {\n      return () => [\n        props.separated ? h(KindCommandSeparator) : null,\n        h(KindCommandGroup, null, () => [\n          props.section.label ? h(KindCommandGroupLabel, null, () => props.section.label) : null,\n          ...props.section.rows.map((row) =>\n            // Keyed by its label too: a footer row's label can hold the search.\n            h(Fragment, { key: `${row.option.value}\\u0000${row.option.label}` }, [\n              slots.default ? slots.default({ row }) : h(RowItem, { row }),\n            ]),\n          ),\n        ]),\n      ];\n    },\n  });\n\n  const RowItem = defineComponent({\n    name: `${name}RowItem`,\n    inheritAttrs: false,\n    props: { row: { type: Object as PropType<PickerRow>, required: true } },\n    /** The row's content: a `PickerItem` by default. */\n    slots: Object as SlotsType<{ default?: Record<string, never> }>,\n    setup(props, { attrs, slots }) {\n      return () =>\n        h(\n          KindCommandItem,\n          { ...attrs, ...props.row.option },\n          { default: slots.default ?? (() => h(Item, { value: props.row.option.value })) },\n        );\n    },\n  });\n\n  const iconOfRow = (row: PickerRow) => {\n    const drawn = row.icon === undefined ? null : icon(row);\n    return drawn == null ? null : h(KindCommandItemIcon, null, () => drawn);\n  };\n\n  const Item = defineComponent({\n    name: `${name}Item`,\n    inheritAttrs: false,\n    setup(_, { attrs, slots }) {\n      return () =>\n        h(Part.Item, attrs, {\n          ...slots,\n          default:\n            slots.default ??\n            (({ state: { row, description } }: { state: PickerItemState }) => [\n              iconOfRow(row),\n              h(\"span\", { \"data-picker-item-text\": \"\" }, [\n                h(KindCommandItemText, null, () => row.label),\n                description.length\n                  ? h(\n                      \"span\",\n                      { \"data-picker-description\": \"\" },\n                      description.map((segment) => (segment.match ? h(\"mark\", segment.text) : segment.text)),\n                    )\n                  : null,\n              ]),\n              row.meta\n                ? h(\n                    \"span\",\n                    { \"data-picker-meta\": \"\", \"aria-hidden\": row.metaLabel ? \"true\" : undefined },\n                    row.meta,\n                  )\n                : null,\n              row.meta && row.metaLabel ? h(\"span\", { \"data-picker-meta-label\": \"\" }, row.metaLabel) : null,\n              trailing?.(row),\n              h(\"span\", { \"data-picker-mark\": \"\" }),\n            ]),\n        });\n    },\n  });\n\n  /** A line under the list, like what a model's cost means. Rendered only with one. */\n  const Note = defineComponent({\n    name: `${name}Note`,\n    inheritAttrs: false,\n    setup(_, { attrs, slots }) {\n      return () =>\n        h(Part.Note, attrs, {\n          ...slots,\n          default: slots.default ?? (({ state }: { state: { note: string } }) => state.note),\n        });\n    },\n  });\n\n  const Content = defineComponent({\n    name: `${name}Content`,\n    inheritAttrs: false,\n    setup(_, { attrs, slots }) {\n      return () =>\n        h(\n          Part.Content,\n          { initialFocus: \"input\", sideOffset: 6, align: \"start\", ...attrs },\n          {\n            default: slots.default ?? (() => [h(List), h(Note)]),\n            // A sheet sits in a full-screen viewport, which renders only while the content presents as one.\n            render: (scope: {\n              props: Record<string, unknown>;\n              state: { presentation: string };\n              children: Component;\n            }) => {\n              const element = slots.render ? slots.render(scope) : h(\"div\", scope.props, [h(scope.children)]);\n              return [scope.state.presentation === \"sheet\" ? h(Part.Viewport, null, () => element) : element];\n            },\n          },\n        );\n    },\n  });\n\n  const Default = () => [h(Trigger), h(Content)];\n\n  return {\n    Trigger: Trigger as unknown as P[\"Trigger\"],\n    Content: Content as unknown as P[\"Content\"],\n    List,\n    SectionRows,\n    RowItem,\n    Item: Item as unknown as P[\"Item\"],\n    Note: Note as unknown as P[\"Note\"],\n    Default,\n  };\n}\n\nconst picker = pickerParts(parts, \"Picker\");\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. A default slot replaces the trigger and the list.\n */\nexport const Picker = defineComponent({\n  name: \"Picker\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () => h(parts.Root, attrs, { ...slots, default: slots.default ?? picker.Default });\n  },\n}) as unknown as typeof parts.Root;\n\n/** Opens the list. Shows the chosen item's icon and label, or the `label` while none is chosen, unless you pass a slot. */\nexport const PickerTrigger = picker.Trigger;\n/** The popover: the search field and the list, unless you pass a slot. 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 a slot. */\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 a slot. */\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/vue/picker.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
