{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "native-select",
  "title": "Native select",
  "description": "The browser's own select in Kino's input box, for long lists a phone picks from with its own wheel. Its options take the page's font.",
  "dependencies": [
    "@ui-sdk/react",
    "@ui-sdk/core"
  ],
  "registryDependencies": [
    "https://kinoui.com/r/field-control.json",
    "https://kinoui.com/r/input.json",
    "https://kinoui.com/r/native-select-control.json",
    "https://kinoui.com/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/components/kino/native-select.tsx",
      "content": "'use client'\n\nimport {\n  InputInvalidIcon,\n  inputBoxClassName,\n  inputControlClassName,\n} from '@/registry/components/kino/input'\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { keptOnReset } from '@/registry/lib/field-control'\nimport {\n  type NativeSelectOptions,\n  nativeSelectControl,\n} from '@/registry/lib/native-select-control'\nimport { useFieldControl } from '@ui-sdk/react/field'\nimport { usePart, usePrimitive } from '@ui-sdk/react/primitive'\nimport { type ComponentProps, useLayoutEffect } from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * The browser's own select in Kino's box, for long lists a phone should\n * pick from with its own wheel. Its options take the page's font. It is a\n * ui-sdk primitive (`registry/lib/native-select-control`), so an agent reads\n * its value and options and picks one, and it joins its Field as ui-sdk's\n * controls do: the Field's label names it and its name goes with the form.\n */\nfunction NativeSelect({\n  className,\n  children,\n  name,\n  onValueChange,\n  ...props\n}: Omit<ComponentProps<'select'>, 'className'> & {\n  className?: string\n} & NativeSelectOptions) {\n  const field = useFieldControl()\n  const select = usePrimitive(nativeSelectControl, {\n    onValueChange: (value, details) => {\n      // A held select with no default keeps its value through a form's reset, as ui-sdk's controls do.\n      if (details.reason === 'reset' && keptOnReset(props.value, props.defaultValue))\n        details.cancel()\n      else onValueChange?.(value, details)\n    },\n  })\n  // A value set by a render, as a controlled select's is, is read after it.\n  useLayoutEffect(() => select.api.read())\n  const own = {\n    ...props,\n    // The primitive hears each pick, so a select held by `value` and `onValueChange` isn't read-only.\n    onChange: props.onChange ?? (onValueChange ? heard : undefined),\n    name: name ?? field?.name,\n    disabled: props.disabled || field?.disabled || undefined,\n    className: cn(\n      inputControlClassName,\n      // A select matches `:read-only`, which would grey its value.\n      'appearance-none pe-9 read-only:text-foreground group-has-aria-invalid/input:pe-14 [&_option]:bg-[Canvas] [&_option]:font-[inherit] [&_option]:text-[CanvasText]',\n    ),\n    children,\n  }\n  return (\n    <div data-slot='native-select' className={cn(inputBoxClassName, className)}>\n      {usePart(select, 'root', {}, field ? field.props(own) : own, 'select')}\n      <span className='pointer-events-none absolute end-(--control-padding) flex items-center gap-1.5'>\n        <InputInvalidIcon className='pe-0' />\n        <IconPlaceholder\n          lucide='ChevronDownIcon'\n          tabler='IconChevronDown'\n          hugeicons='ArrowDown01Icon'\n          phosphor='CaretDownIcon'\n          remixicon='RiArrowDownSLine'\n          aria-hidden\n        />\n      </span>\n    </div>\n  )\n}\n\nfunction heard() {}\n\nfunction NativeSelectOption(props: ComponentProps<'option'>) {\n  return <option data-slot='native-select-option' {...props} />\n}\n\nfunction NativeSelectOptGroup(props: ComponentProps<'optgroup'>) {\n  return <optgroup data-slot='native-select-optgroup' {...props} />\n}\n\nexport { NativeSelect, NativeSelectOptGroup, NativeSelectOption }\n",
      "type": "registry:component",
      "target": "@components/kino/native-select.tsx"
    }
  ],
  "type": "registry:component"
}