{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "native-select",
  "title": "NativeSelect",
  "description": "A labeled native `<select>` on the Field contract: pass `label`, `options` (or `<option>` children) and `error`.",
  "registryDependencies": [
    "@ouro/field",
    "@ouro/lib-env",
    "@ouro/lib-use-dev-messages",
    "@ouro/lib-use-field"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/select/native-select.tsx",
      "content": "\"use client\";\n\nimport type { JSX, ReactNode, Ref, SelectHTMLAttributes } from \"react\";\nimport { Field } from \"@/registry/ouro/components/ouro/field/field\";\nimport { FieldControl, type FieldControlProps } from \"@/registry/ouro/components/ouro/field/field-parts\";\nimport { contractWarnings } from \"@/registry/ouro/components/ouro/field/field-styles\";\nimport { FieldOwnerContext, type ReadonlyErrorMessages } from \"@/registry/ouro/lib/ouro/use-field\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\n\n/** One choice: the `value` it submits and the `label` it shows. */\nexport interface NativeSelectOption {\n  /** What the form submits. */\n  value: string;\n  /** What the picker shows. */\n  label: string;\n  /** The option shows but cannot be chosen. */\n  disabled?: boolean | undefined;\n}\n\n/** A labeled group of options, an `<optgroup>`. */\nexport interface NativeSelectOptionGroup {\n  /** The group's heading. */\n  label: string;\n  /** The options in the group. */\n  options: NativeSelectOption[];\n}\n\n/** The props NativeSelect adds to the `<select>` attributes it passes through. */\nexport interface NativeSelectOwnProps {\n  /**\n   * What the select is for, shown above it and read as its name. Required: every control\n   * needs a name. To hide it visually, keep it and add `hideLabel`.\n   * @claim \"Required: every control needs a name\" registry/ouro/components/ouro/select/native-select.test-d.ts verify:fileLine(registry/ouro/components/ouro/select/native-select.test-d.ts, /expectTypeOf<\\{\\sname:\\s\"country\"\\s\\}>\\(\\)\\.not\\.toExtend<NativeSelectProps>/)\n   */\n  label: string;\n  /** Hides the label visually; screen readers still read it as the select's name. */\n  hideLabel?: boolean | undefined;\n  /** Supporting text under the label, read after the label through `aria-describedby`. */\n  description?: ReactNode | undefined;\n  /**\n   * What is wrong, from your server action or client check. The message (or several, as a\n   * list) shows under the select, which gets `aria-invalid`. A message is text or a React node (one with a link); an empty string or array means valid.\n   */\n  error?: ReadonlyErrorMessages | undefined;\n  /** A choice is required: the form will not submit without one, and the label gets a marker. */\n  required?: boolean | undefined;\n  /** Disables the select and fades it. */\n  disabled?: boolean | undefined;\n  /** The form field name the value submits under. */\n  name?: string | undefined;\n  /**\n   * An empty first option shown, muted, while nothing is chosen: `\"Choose a country\"`. With\n   * `required` it cannot be chosen back, so the browser asks for a real choice.\n   */\n  placeholder?: string | undefined;\n  /**\n   * The choices: `[{ value: \"nz\", label: \"New Zealand\" }]`, and groups as\n   * `{ label: \"Oceania\", options: [...] }`. Or pass `<option>` children.\n   */\n  options?: ReadonlyArray<NativeSelectOption | NativeSelectOptionGroup> | undefined;\n  /** `<option>` and `<optgroup>` elements, when you do not pass `options`. */\n  children?: ReactNode;\n  /**\n   * Layout only: margins, width, grid placement (`mt-4`, `col-span-2`). Appearance classes\n   * warn in development; style fields in your theme.\n   */\n  className?: string | undefined;\n  /** The select element. */\n  ref?: Ref<HTMLSelectElement> | undefined;\n\n  /**\n   * Not supported by NativeSelect. A native multiple select is hard to use; use `<Select multiple>`.\n   *\n   * @claim \"Not supported by NativeSelect\" registry/ouro/components/ouro/select/native-select.test-d.ts verify:fileLine(registry/ouro/components/ouro/select/native-select.test-d.ts, /expectTypeOf<\\{\\slabel:\\s\"Tags\";\\smultiple:\\strue\\s\\}>\\(\\)\\.not\\.toExtend<NativeSelectProps>/)\n   */\n  multiple?: { 'Use <Select multiple>': never };\n  /** Not a prop. For several values use `<Select multiple>`. */\n  isMulti?: { 'Use <Select multiple>': never };\n  /** Not a prop. Ouro UI uses `error`: `<NativeSelect error=\"Required.\">`. */\n  errorMessage?: { 'Use <NativeSelect error=\"Required.\">': never };\n  /** Not a prop. Ouro UI uses `description`: `<NativeSelect description=\"...\">`. */\n  helperText?: { 'Use <NativeSelect description=\"...\">': never };\n  /** Not a prop. `error` marks the select invalid: `<NativeSelect error=\"What is wrong\">`. */\n  isInvalid?: { 'Use <NativeSelect error=\"What is wrong\">': never };\n  /** Not a prop. `error` marks the select invalid: `<NativeSelect error=\"What is wrong\">`. */\n  invalid?: { 'Use <NativeSelect error=\"What is wrong\">': never };\n  /** Not a prop. Ouro UI uses `required`: `<NativeSelect required>`. */\n  isRequired?: { 'Use <NativeSelect required>': never };\n  /** Not a prop. Ouro UI uses `disabled`: `<NativeSelect disabled>`. */\n  isDisabled?: { 'Use <NativeSelect disabled>': never };\n}\n\n/**\n * Props for {@link NativeSelect}: its own props and the `<select>` attributes it passes\n * through, including `onChange` (the event) and `onValueChange` (the value).\n */\nexport type NativeSelectProps = Omit<SelectHTMLAttributes<HTMLSelectElement>, keyof NativeSelectOwnProps | \"onChange\"> &\n  Pick<FieldControlProps, \"onValueChange\"> & {\n    /** Called with the change event when the user picks an option. `onValueChange` gets the value. */\n    onChange?: SelectHTMLAttributes<HTMLSelectElement>[\"onChange\"] | undefined;\n  } & NativeSelectOwnProps;\n\n/** Field's messages and root name NativeSelect. */\nconst owner = { name: \"NativeSelect\", data: \"native-select\" };\n\n/**\n * The select: Field's control look (44px tall with a 16px font on phones, so iOS does not\n * zoom; 36px and 14px from `sm` with a fine pointer), with room for the chevron at the end.\n * The placeholder option shows muted while it is chosen.\n * @claim \"The select: Field's control look (44px\" registry/ouro/components/ouro/select/select.test.tsx verify:testExists(registry/ouro/components/ouro/select/select.test.tsx::Select > is 36px tall with a fine pointer from sm up, with 32px options)\n * @claim \"The select: Field's control look (44px\" registry/ouro/components/ouro/select/native-select.test.tsx verify:testExists(registry/ouro/components/ouro/select/native-select.test.tsx::NativeSelect > is 36px tall with a fine pointer from sm up)\n * @claim \"The select: Field's control look (44px\" registry/ouro/components/ouro/select/select.touch.test.tsx verify:testExists(registry/ouro/components/ouro/select/select.touch.test.tsx::keeps 44px controls and 16px text on a landscape phone, where the list opens by the trigger)\n */\nconst selectClass =\n  \"m-0 box-border block w-full min-w-0 h-(--ouro-control-h) ps-3 pe-9 py-0 appearance-none \" +\n  \"[--ouro-control-h:calc(var(--spacing)*11)] sm:pointer-fine:[--ouro-control-h:calc(var(--spacing)*9)] \" +\n  \"rounded-ouro-md border border-solid border-input bg-transparent text-base text-foreground sm:pointer-fine:text-sm \" +\n  \"font-[inherit] cursor-pointer [-webkit-tap-highlight-color:transparent] \" +\n  \"outline-ring outline-offset-2 focus-visible:outline-2 focus-visible:outline-solid \" +\n  \"transition-[border-color] duration-(--ouro-duration-fast) ease-[ease] \" +\n  \"pointer-fine:hover:not-disabled:border-ring/60 aria-invalid:border-destructive disabled:cursor-not-allowed disabled:opacity-50 \" +\n  \"dark:bg-input/30 [&:has(option[value='']:checked)]:text-muted-foreground [&_option]:bg-popover [&_option]:text-popover-foreground dark:scheme-dark\";\n\n/** The chevron at the end of the box, drawn in the muted text color; presses go to the select. */\nfunction ChevronIcon(): JSX.Element {\n  return (\n    <svg\n      aria-hidden=\"true\"\n      viewBox=\"0 0 16 16\"\n      fill=\"none\"\n      stroke=\"currentColor\"\n      strokeWidth=\"1.5\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n      className=\"pointer-events-none absolute end-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground\"\n    >\n      <path d=\"M4.5 6.5L8 10l3.5-3.5\" />\n    </svg>\n  );\n}\n\n/**\n * A labeled native `<select>` on the Field contract: pass `label`, `options` (or `<option>`\n * children) and `error`. Phones open the operating system's own picker (a wheel on iOS, a\n * list on Android), which is quick for long plain-text lists such as countries, and works\n * before JavaScript loads.\n *\n * Use `Select` instead for a styled list (icons, groups with headings, several values with\n * `multiple`), and `RadioGroup` for two to five choices that should all show.\n *\n * @group Forms\n * @see https://ui.ouroboros.bot/docs/native-select\n *\n * @example\n * <NativeSelect\n *   label=\"Country\"\n *   name=\"country\"\n *   autoComplete=\"country\"\n *   placeholder=\"Choose a country\"\n *   options={[{ value: \"nz\", label: \"New Zealand\" }, { value: \"za\", label: \"South Africa\" }]}\n *   error={errors?.country}\n * />\n */\nexport function NativeSelect(props: NativeSelectProps): JSX.Element {\n  const {\n    label,\n    hideLabel,\n    description,\n    error,\n    required,\n    disabled,\n    name,\n    placeholder,\n    options,\n    children,\n    className,\n    ref,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    multiple,\n    isMulti,\n    errorMessage,\n    helperText,\n    isInvalid,\n    invalid,\n    isRequired,\n    isDisabled,\n    ...rest\n  } = props;\n\n  const hasChildren = children !== undefined && children !== null && children !== false;\n  useDevWarnings(\n    \"NativeSelect\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          multiple !== undefined && [\n            \"multiple is not supported; a native multiple select is hard to use\",\n            `<Select label=\"${label}\" multiple options={options} />`,\n          ],\n          isMulti !== undefined && [\"isMulti is not a prop\", `<Select label=\"${label}\" multiple options={options} />`],\n          ...contractWarnings(\"NativeSelect\", { errorMessage, helperText, isInvalid, invalid, isRequired, isDisabled }),\n          options !== undefined &&\n            hasChildren && [\"options and children are both set, so the children are ignored\", `<NativeSelect label=\"${label}\" options={options} />`],\n          options === undefined &&\n            !hasChildren && [\n              \"there are no options to choose from\",\n              `<NativeSelect label=\"${label}\" options={[{ value: \"nz\", label: \"New Zealand\" }]} />`,\n            ],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n\n  // A placeholder is chosen at first unless the app chose a value.\n  const start = placeholder !== undefined && rest.value === undefined && rest.defaultValue === undefined ? { defaultValue: \"\" } : {};\n\n  return (\n    <FieldOwnerContext.Provider value={owner}>\n      <Field\n        label={label}\n        hideLabel={hideLabel}\n        description={description}\n        error={error}\n        required={required}\n        disabled={disabled}\n        name={name}\n        className={className}\n      >\n        <div className=\"relative\">\n          <FieldControl\n            {...(rest as Omit<FieldControlProps, \"className\">)}\n            {...start}\n            ref={ref as Ref<HTMLInputElement> | undefined}\n            render={(controlProps) => (\n              <select {...(controlProps as SelectHTMLAttributes<HTMLSelectElement>)} data-ouro-control=\"native-select\" data-ouro-part=\"select\" className={selectClass}>\n                {placeholder !== undefined && (\n                  <option value=\"\" disabled={required}>\n                    {placeholder}\n                  </option>\n                )}\n                {options\n                  ? options.map((entry) =>\n                      \"options\" in entry ? (\n                        <optgroup key={`group:${entry.label}`} label={entry.label}>\n                          {entry.options.map((option) => (\n                            <option key={option.value} value={option.value} disabled={option.disabled}>\n                              {option.label}\n                            </option>\n                          ))}\n                        </optgroup>\n                      ) : (\n                        <option key={entry.value} value={entry.value} disabled={entry.disabled}>\n                          {entry.label}\n                        </option>\n                      ),\n                    )\n                  : children}\n              </select>\n            )}\n          />\n          <ChevronIcon />\n        </div>\n      </Field>\n    </FieldOwnerContext.Provider>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/select/native-select.tsx"
    }
  ],
  "docs": "A labeled native `<select>` on the Field contract: pass `label`, `options` (or `<option>` children) and `error`. Import: import { NativeSelect } from \"@/components/ouro/select/native-select\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: field, the helpers they import in lib/ouro. Needs ouro-base in your stylesheet: add that item once per app, from the same place as this one, if you have not. Docs: https://ui.ouroboros.bot/docs/native-select.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}