{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "select",
  "title": "Select",
  "description": "A labeled list of choices on the Field contract: pass `label`, `options` (or `SelectItem` children) and `error` from your server action or client check.",
  "dependencies": [
    "@base-ui/react@^1.8.0"
  ],
  "registryDependencies": [
    "@ouro/field",
    "@ouro/lib-control-ref",
    "@ouro/lib-dev",
    "@ouro/lib-env",
    "@ouro/lib-page-scroll-hold",
    "@ouro/lib-portal-container",
    "@ouro/lib-server-element",
    "@ouro/lib-use-dev-messages",
    "@ouro/lib-use-field",
    "@ouro/lib-use-media-query"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/select/select-parts.tsx",
      "content": "\"use client\";\n\nimport { Select as BaseSelect } from \"@base-ui/react/select\";\nimport { createContext, useContext, type JSX, type ReactNode } from \"react\";\nimport { devThrow } from \"@/registry/ouro/lib/ouro/dev\";\nimport { groupLabelClass, itemClass, itemIndicatorClass } from \"@/registry/ouro/components/ouro/select/select-styles\";\n\n/** Whether a part is inside a Select's list. */\nconst SelectListContext = createContext(false);\n\n/** The JSX a part belongs in, for the dev message when it is not there. */\nconst SHAPE = '<Select label=\"Fruit\"><SelectItem value=\"apple\">Apple</SelectItem></Select>';\n\n/** Throws in development, with the JSX the part belongs in, outside a Select. */\nfunction useSelectPart(part: string): void {\n  if (!useContext(SelectListContext)) {\n    devThrow(\n      part,\n      \"must be rendered inside <Select>\",\n      process.env.NODE_ENV !== \"production\" ? SHAPE : /* istanbul ignore next @preserve -- production only */ \"\",\n    );\n  }\n}\n\n/**\n * Marks Select's list, so the parts know they are in place.\n *\n * @internal For `Select`; apps use `Select`.\n */\nexport function SelectListScope({ children }: { children: ReactNode }): JSX.Element {\n  return <SelectListContext.Provider value>{children}</SelectListContext.Provider>;\n}\n\n/** Props for {@link SelectItem}. */\nexport interface SelectItemProps {\n  /** What the form submits and `onValueChange` receives when this option is chosen. */\n  value: string;\n  /** What the list and the trigger show: text, or text with an icon. */\n  children: ReactNode;\n  /** The option shows but cannot be chosen. */\n  disabled?: boolean | undefined;\n  /**\n   * The text typing a letter matches, when `children` is not plain text:\n   * `label=\"Apple\"` for `<><AppleIcon /> Apple</>`.\n   */\n  label?: string | undefined;\n}\n\n/**\n * A check mark, drawn in the text color at 16px.\n *\n * @claim \"A check mark, drawn in the\" registry/ouro/components/ouro/select/select-parts.tsx verify:fileLine(registry/ouro/components/ouro/select/select-parts.tsx, /viewBox=\"0\\s0\\s16\\s16\"\\sfill=\"none\"\\sstroke=\"currentColor\"/)\n */\nfunction CheckIcon(): JSX.Element {\n  return (\n    <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n      <path d=\"M3 8.5l3.5 3.5L13 4.5\" />\n    </svg>\n  );\n}\n\n/**\n * Part: one option in a `Select`, for options that need more than text (an icon, a color\n * swatch). Pass `options` to `Select` instead when every option is text; it renders these\n * for you.\n *\n * @example\n * <Select label=\"Course\" name=\"course\">\n *   <SelectItem value=\"starter\">Starter</SelectItem>\n *   <SelectItem value=\"main\">Main</SelectItem>\n * </Select>\n */\nexport function SelectItem({ value, children, disabled, label }: SelectItemProps): JSX.Element {\n  useSelectPart(\"SelectItem\");\n  return (\n    <BaseSelect.Item value={value} disabled={disabled} label={label} data-ouro-control=\"select\" data-ouro-part=\"option\" className={itemClass}>\n      <BaseSelect.ItemIndicator className={itemIndicatorClass}>\n        <CheckIcon />\n      </BaseSelect.ItemIndicator>\n      <BaseSelect.ItemText className=\"col-start-2 min-w-0\">{children}</BaseSelect.ItemText>\n    </BaseSelect.Item>\n  );\n}\n\n/** Props for {@link SelectGroup}. */\nexport interface SelectGroupProps {\n  /** The group's heading, which also names the group for screen readers. */\n  label: string;\n  /** The group's `SelectItem`s. */\n  children: ReactNode;\n}\n\n/**\n * Part: a labeled group of `SelectItem`s. With `options`, pass a group as\n * `{ label: \"Fruit\", options: [...] }` instead.\n *\n * @example\n * <Select label=\"Produce\" name=\"produce\">\n *   <SelectGroup label=\"Fruit\">\n *     <SelectItem value=\"apple\">Apple</SelectItem>\n *   </SelectGroup>\n * </Select>\n */\nexport function SelectGroup({ label, children }: SelectGroupProps): JSX.Element {\n  useSelectPart(\"SelectGroup\");\n  return (\n    <BaseSelect.Group className=\"block py-0.5\">\n      <BaseSelect.GroupLabel className={groupLabelClass}>{label}</BaseSelect.GroupLabel>\n      {children}\n    </BaseSelect.Group>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/select/select-parts.tsx"
    },
    {
      "path": "registry/ouro/components/ouro/select/select-styles.ts",
      "content": "import type { FocusEvent, ReactElement, ReactNode } from \"react\";\nimport { hasLazyType, serverNodes } from \"@/registry/ouro/lib/ouro/server-element\";\n\nexport { flattenOptions, focusOptionFromPopup, groupLabelClass, itemClass, itemIndicatorClass, popupClass, positionerClass, sheetQuery, triggerClass, backdropClass, sheetTitleClass, isGroup };\nexport type { SelectOption, SelectOptionGroup, SelectOptions };\n\n// Class strings, option helpers and the sheet query for Select and its parts, apart from\n// the components so each component file exports only components (React Fast Refresh).\n// Class strings are literal so the app's Tailwind finds them when it compiles.\n\n/** One choice: the `value` it submits and the `label` it shows. */\ninterface SelectOption {\n  /** What the form submits and `onValueChange` receives. */\n  value: string;\n  /** What the list and the trigger show. */\n  label: string;\n  /** The option shows but cannot be chosen. */\n  disabled?: boolean | undefined;\n}\n\n/** A labeled group of options, shown under a heading in the list. */\ninterface SelectOptionGroup {\n  /** The group's heading. */\n  label: string;\n  /** The options in the group. */\n  options: SelectOption[];\n}\n\n/** Select's `options`: options, groups of options, or both. */\ntype SelectOptions = ReadonlyArray<SelectOption | SelectOptionGroup>;\n\n/**\n * Whether an entry in `options` is a group.\n *\n * @internal\n */\nfunction isGroup(entry: SelectOption | SelectOptionGroup): entry is SelectOptionGroup {\n  return \"options\" in entry;\n}\n\n/**\n * Moves focus from the list's own frame onto an option. Base UI queues a focus move for the frame\n * and another for an option on a keyboard open, and when the frame's lands last, focus stays on the frame, where a screen\n * reader announces nothing and arrow keys highlight an option the user cannot hear. A pointer\n * open keeps Base UI's choice, so only a keyboard focus (`:focus-visible`) is moved.\n *\n * @internal\n */\nfunction focusOptionFromPopup(event: FocusEvent<HTMLElement>): void {\n  const popup = event.currentTarget;\n  // Stryker disable next-line ConditionalExpression: Base UI highlights an option as it takes focus, so a focus that lands on an option redirects to that same option.\n  if (event.target !== popup || !popup.matches(\":focus-visible\")) return;\n  const selectors = [\"[data-highlighted]\", '[aria-selected=\"true\"]:not([data-disabled])', '[role=\"option\"]:not([data-disabled])'];\n  for (const selector of selectors) {\n    const option = popup.querySelector<HTMLElement>(selector);\n    if (option) {\n      option.focus({ preventScroll: true });\n      return;\n    }\n  }\n}\n\n/**\n * Every option, groups flattened, as `{ value, label }` for the trigger's text. Children\n * count too: each `SelectItem` element, inside fragments and `SelectGroup`s.\n *\n * @internal\n * @claim \"Every option, groups flattened, as `{\" registry/ouro/components/ouro/select/native-select.test.tsx verify:testExists(registry/ouro/components/ouro/select/native-select.test.tsx::NativeSelect > renders option groups and option children)\n * @claim \"Every option, groups flattened, as `{\" registry/ouro/components/ouro/select/select.test.tsx verify:testExists(registry/ouro/components/ouro/select/select.test.tsx::Select > renders groups from options, each named by its heading)\n * @claim \"Children count too: each `SelectItem` element\" registry/ouro/components/ouro/select/select.test.tsx verify:testExists(registry/ouro/components/ouro/select/select.test.tsx::Select > takes SelectItem and SelectGroup children, and shows a child's label in the trigger)\n */\nfunction flattenOptions(options: SelectOptions | undefined, children: ReactNode, itemType: unknown): Array<{ value: string; label: ReactNode }> {\n  const found: Array<{ value: string; label: ReactNode }> = [];\n  for (const entry of options ?? []) {\n    for (const option of isGroup(entry) ? entry.options : [entry]) found.push({ value: option.value, label: option.label });\n  }\n  const walk = (given: ReactNode): void => {\n    // Items a Server Component passed can arrive inside a lazy wrapper with no props.\n    const node = serverNodes(given);\n    if (Array.isArray(node)) return node.forEach(walk);\n    if (!node || typeof node !== \"object\" || !(\"props\" in node)) return;\n    const element = node as ReactElement<{ value?: unknown; children?: ReactNode }>;\n    // An item is a `SelectItem`. Across a Server Component boundary its type is a lazy\n    // reference, never the component itself, so there it is known by its string `value`.\n    // (That also takes a client component with a string `value` that a Server Component put\n    // around the items for an item; nothing visible across the boundary tells them apart.)\n    const isItem = element.type === itemType || (hasLazyType(element) && typeof element.props.value === \"string\");\n    if (isItem) found.push({ value: element.props.value as string, label: element.props.children });\n    else walk(element.props.children);\n  };\n  walk(children);\n  return found;\n}\n\n/**\n * Phones present the list as a bottom sheet: below the `sm` breakpoint with a coarse pointer.\n *\n * @internal\n */\nconst sheetQuery = \"(max-width: 639.98px) and (pointer: coarse)\";\n\n/**\n * The trigger: Field's control look (44px tall with a 16px font on phones, stepping down\n * from `sm` with a fine pointer), with the value at the start and a chevron at the end. Its\n * height is one unprefixed class that reads a variable, so an app's `h-*` replaces it.\n *\n * @internal\n * @claim \"The trigger: 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 * @claim \"The trigger: 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 trigger: 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 */\nconst triggerClass =\n  \"relative m-0 box-border flex w-full min-w-0 items-center justify-between gap-2 h-(--ouro-control-h) px-3 py-0 \" +\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-start text-base text-foreground sm:pointer-fine:text-sm \" +\n  \"font-[inherit] cursor-pointer select-none [-webkit-tap-highlight-color:transparent] \" +\n  \"outline-ring outline-offset-2 focus-visible:outline-2 focus-visible:outline-solid \" +\n  \"transition-[border-color,background-color] duration-(--ouro-duration-fast) ease-[ease] \" +\n  \"pointer-fine:hover:not-data-disabled:border-ring/60 not-data-disabled:active:bg-accent/60 aria-invalid:border-destructive \" +\n  \"data-disabled:cursor-not-allowed data-disabled:opacity-50 dark:bg-input/30 \" +\n  \"[&_[data-placeholder]]:text-muted-foreground [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-muted-foreground\";\n\n/**\n * The positioner. As a sheet it is pinned to the bottom edge at full width, over the place\n * Base UI computed next to the trigger.\n *\n * @internal\n */\nconst positionerClass =\n  \"outline-none \" +\n  \"data-[ouro-presentation=sheet]:fixed! data-[ouro-presentation=sheet]:inset-x-0! data-[ouro-presentation=sheet]:top-auto! \" +\n  \"data-[ouro-presentation=sheet]:bottom-0! data-[ouro-presentation=sheet]:w-auto! data-[ouro-presentation=sheet]:transform-none!\";\n\n/**\n * The list's panel: the trigger's width at least, scrolling within the space Base UI\n * measured. It scales and fades from its origin, and with reduced motion only fades. As a\n * sheet it rises from the bottom edge with rounded top corners and clears the home indicator.\n *\n * @internal\n */\nconst popupClass =\n  \"box-border flex max-h-(--available-height) min-w-(--anchor-width) flex-col overflow-hidden outline-none \" +\n  \"rounded-ouro-md border border-solid border-border bg-popover p-1 text-popover-foreground \" +\n  \"shadow-(--shadow-lg) origin-(--transform-origin) \" +\n  \"[transition:opacity_var(--ouro-duration-base)_var(--ouro-ease-out),scale_var(--ouro-duration-base)_var(--ouro-ease-out)] data-ending-style:duration-(--ouro-duration-fast) \" +\n  \"data-starting-style:opacity-0 data-starting-style:scale-95 data-ending-style:opacity-0 data-ending-style:scale-95 \" +\n  \"data-[side=none]:data-starting-style:scale-100 data-[side=none]:data-starting-style:opacity-100 \" +\n  \"motion-reduce:data-starting-style:scale-100 motion-reduce:data-ending-style:scale-100 \" +\n  \"data-[ouro-presentation=sheet]:max-h-[min(70dvh,calc(100dvh-4rem))] data-[ouro-presentation=sheet]:min-w-0 \" +\n  \"data-[ouro-presentation=sheet]:rounded-none data-[ouro-presentation=sheet]:rounded-t-ouro-xl data-[ouro-presentation=sheet]:border-x-0 \" +\n  \"data-[ouro-presentation=sheet]:border-b-0 data-[ouro-presentation=sheet]:px-2 data-[ouro-presentation=sheet]:pt-2 \" +\n  \"data-[ouro-presentation=sheet]:pb-[calc(env(safe-area-inset-bottom,0px)+0.5rem)] \" +\n  \"data-[ouro-presentation=sheet]:[transition:translate_var(--ouro-duration-sheet)_var(--ouro-ease-drawer),opacity_var(--ouro-duration-fast)_var(--ouro-ease-out)] \" +\n  \"data-[ouro-presentation=sheet]:data-starting-style:scale-100 data-[ouro-presentation=sheet]:data-ending-style:scale-100 \" +\n  \"data-[ouro-presentation=sheet]:data-starting-style:opacity-100 data-[ouro-presentation=sheet]:data-ending-style:opacity-100 \" +\n  \"data-[ouro-presentation=sheet]:data-starting-style:translate-y-full data-[ouro-presentation=sheet]:data-ending-style:translate-y-full \" +\n  \"data-[ouro-presentation=sheet]:data-ending-style:duration-(--ouro-duration-base) \" +\n  \"motion-reduce:data-[ouro-presentation=sheet]:[transition:opacity_var(--ouro-duration-base)_var(--ouro-ease-out)] \" +\n  \"motion-reduce:data-[ouro-presentation=sheet]:data-starting-style:translate-y-0 motion-reduce:data-[ouro-presentation=sheet]:data-ending-style:translate-y-0 \" +\n  \"motion-reduce:data-[ouro-presentation=sheet]:data-starting-style:opacity-0 motion-reduce:data-[ouro-presentation=sheet]:data-ending-style:opacity-0\";\n\n/**\n * The sheet's dimmed backdrop, which a tap outside the list closes. Only the sheet has one.\n *\n * @internal\n */\nconst backdropClass =\n  \"fixed inset-0 bg-(--ouro-backdrop-color) opacity-(--ouro-backdrop-max) \" +\n  \"[transition:opacity_var(--ouro-duration-base)_var(--ouro-ease-out)] data-starting-style:opacity-0 data-ending-style:opacity-0\";\n\n/**\n * The sheet's heading: the field's label, so the user sees what they are choosing.\n *\n * @internal\n */\nconst sheetTitleClass = \"m-0 shrink-0 px-3 pt-1 pb-2 text-base leading-6 font-semibold text-foreground\";\n\n/**\n * An option: 44px tall on coarse pointers, 32px with a fine one, with the check mark in\n * front. The highlighted option (pointer or arrow keys) takes the accent color.\n *\n * @internal\n * @claim \"An option: 44px tall on coarse\" 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 \"An option: 44px tall on coarse\" registry/ouro/components/ouro/select/select.touch.test.tsx verify:testExists(registry/ouro/components/ouro/select/select.touch.test.tsx::chooses an option with a tap and closes, with 44px rows)\n */\nconst itemClass =\n  \"relative box-border grid min-h-11 cursor-default grid-cols-[1rem_1fr] items-center gap-2 rounded-ouro-sm px-2 py-1.5 \" +\n  \"text-base leading-6 outline-none select-none pointer-fine:min-h-8 sm:pointer-fine:text-sm sm:pointer-fine:leading-5 \" +\n  \"scroll-my-1 [-webkit-tap-highlight-color:transparent] data-highlighted:bg-accent data-highlighted:text-accent-foreground \" +\n  // Forced colours drop the fill, so the highlight takes the system's pair.\n  \"forced-colors:data-highlighted:bg-[Highlight] forced-colors:data-highlighted:text-[HighlightText] \" +\n  \"not-data-disabled:active:bg-accent not-data-disabled:active:text-accent-foreground \" +\n  \"data-disabled:opacity-50 [&_svg]:size-4\";\n\n/**\n * The check mark in front of a chosen option.\n *\n * @internal\n */\nconst itemIndicatorClass = \"col-start-1 flex items-center justify-center\";\n\n/**\n * A group's heading.\n *\n * @internal\n */\nconst groupLabelClass = \"px-2 pt-2 pb-1 ps-8 text-xs leading-4 font-medium text-muted-foreground select-none\";\n",
      "type": "registry:ui",
      "target": "@components/ouro/select/select-styles.ts"
    },
    {
      "path": "registry/ouro/components/ouro/select/select.tsx",
      "content": "\"use client\";\n\nimport { Select as BaseSelect } from \"@base-ui/react/select\";\nimport { useMemo, type JSX, type ReactNode, type Ref } from \"react\";\nimport { Field } from \"@/registry/ouro/components/ouro/field/field\";\nimport { contractWarnings } from \"@/registry/ouro/components/ouro/field/field-styles\";\nimport { SelectGroup, SelectItem, SelectListScope } from \"@/registry/ouro/components/ouro/select/select-parts\";\nimport {\n  backdropClass,\n  flattenOptions,\n  focusOptionFromPopup,\n  isGroup,\n  popupClass,\n  positionerClass,\n  sheetQuery,\n  sheetTitleClass,\n  triggerClass,\n  type SelectOptions,\n} from \"@/registry/ouro/components/ouro/select/select-styles\";\nimport { controlRef } from \"@/registry/ouro/lib/ouro/control-ref\";\nimport { FieldOwnerContext, useField, useFormErrors, type ReadonlyErrorMessages } from \"@/registry/ouro/lib/ouro/use-field\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\nimport { useMediaQuery } from \"@/registry/ouro/lib/ouro/use-media-query\";\nimport { holdPageAtPress } from \"@/registry/ouro/lib/ouro/page-scroll-hold\";\nimport { PortalScope, usePortalContainer } from \"@/registry/ouro/lib/ouro/portal-container\";\n\nexport type { SelectOption, SelectOptionGroup, SelectOptions } from \"@/registry/ouro/components/ouro/select/select-styles\";\n\n/**\n * Props every Select takes, whether it picks one value or several.\n *\n * @claim \"Props every Select takes, whether it\" registry/ouro/components/ouro/select/select.test.tsx verify:testExists(registry/ouro/components/ouro/select/select.test.tsx::Select > picks several values with multiple, as a string array)\n * @claim \"Props every Select takes, whether it\" registry/ouro/components/ouro/select/select.test.tsx verify:testExists(registry/ouro/components/ouro/select/select.test.tsx::Select > chooses an option, shows its label and submits its value)\n */\nexport interface SelectBaseProps {\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`. On phones it also heads the list.\n   * @claim \"Required: every control needs a name\" registry/ouro/components/ouro/select/select.test-d.ts verify:fileLine(registry/ouro/components/ouro/select/select.test-d.ts, /expectTypeOf<\\{\\soptions:\\stypeof\\scourses\\s\\}>\\(\\)\\.not\\.toExtend<SelectProps>/)\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 value can be seen but not changed. */\n  readOnly?: boolean | undefined;\n  /**\n   * The form field name the value submits under. With `multiple`, each value submits under it.\n   *\n   * @claim \"With `multiple`, each value submits under\" registry/ouro/components/ouro/select/select.test.tsx verify:testExists(registry/ouro/components/ouro/select/select.test.tsx::Select > posts one entry per chosen value under its name with multiple, for formData.getAll)\n   */\n  name?: string | undefined;\n  /** Shown in the trigger while nothing is chosen: `\"Choose a course\"`. It is not a label. */\n  placeholder?: string | undefined;\n  /**\n   * The choices: `[{ value: \"main\", label: \"Main\" }]`, and groups as\n   * `{ label: \"Fruit\", options: [...] }`. Pass `SelectItem` children instead when an option\n   * needs more than text.\n   */\n  options?: SelectOptions | undefined;\n  /** `SelectItem`s and `SelectGroup`s, when you do not pass `options`. */\n  children?: ReactNode;\n  /** Autofill hint for the hidden input that submits the value, such as `\"country\"`. */\n  autoComplete?: string | undefined;\n  /** The id of a form outside which the select sits, so its value submits with that form. */\n  form?: string | undefined;\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 trigger button. */\n  ref?: Ref<HTMLButtonElement> | undefined;\n\n  /** Not a prop. Select calls `onValueChange` with the value: `<Select onValueChange={(value) => setCourse(value)}>`. */\n  onChange?: { 'Use onValueChange={(value) => ...}': never };\n  /** Not a prop. Ouro UI uses `multiple`: `<Select multiple>`. */\n  isMulti?: { 'Use <Select multiple>': never };\n  /** Not a prop. Ouro UI uses `options`: `<Select options={[{ value: \"main\", label: \"Main\" }]}>`. */\n  items?: { 'Use options={[{ value: \"main\", label: \"Main\" }]}': never };\n  /** Not a prop. Ouro UI uses `error`: `<Select error=\"Required.\">`. */\n  errorMessage?: { 'Use <Select error=\"Required.\">': never };\n  /** Not a prop. Ouro UI uses `description`: `<Select description=\"...\">`. */\n  helperText?: { 'Use <Select description=\"...\">': never };\n  /** Not a prop. `error` marks the select invalid: `<Select error=\"What is wrong\">`. */\n  isInvalid?: { 'Use <Select error=\"What is wrong\">': never };\n  /** Not a prop. `error` marks the select invalid: `<Select error=\"What is wrong\">`. */\n  invalid?: { 'Use <Select error=\"What is wrong\">': never };\n  /** Not a prop. Ouro UI uses `required`: `<Select required>`. */\n  isRequired?: { 'Use <Select required>': never };\n  /** Not a prop. Ouro UI uses `disabled`: `<Select disabled>`. */\n  isDisabled?: { 'Use <Select disabled>': never };\n}\n\n/** A Select that picks one value: a `string`, or `null` while nothing is chosen. */\nexport type SelectSingleProps = SelectBaseProps & {\n  /** Pick several values: the list stays open while the user chooses, and the value is a `string[]` instead of `string | null`. */\n  multiple?: false | undefined;\n  /**\n   * The chosen value, when you control it: a `string`, or `null` for none; with `multiple`, a `string[]`.\n   *\n   * @claim \"The chosen value, when you control\" registry/ouro/components/ouro/select/select.test-d.ts verify:fileLine(registry/ouro/components/ouro/select/select.test-d.ts, /\\{\\slabel:\\s\"Tags\";\\smultiple:\\strue;\\svalue:\\s\"quick\"\\s\\}>\\(\\)\\.not\\.toExtend<SelectProps>/)\n   */\n  value?: string | null | undefined;\n  /** The value chosen at first, when the select keeps its own state: a `string` or `null`; with `multiple`, a `string[]`. */\n  defaultValue?: string | null | undefined;\n  /**\n   * Called with the new value when the user chooses an option: a `string` or `null`; with `multiple`, every chosen value as a `string[]`.\n   *\n   * @claim \"Called with the new value when\" registry/ouro/components/ouro/select/select.test.tsx verify:testExists(registry/ouro/components/ouro/select/select.test.tsx::Select > chooses an option, shows its label and submits its value)\n   * @claim \"Called with the new value when\" registry/ouro/components/ouro/select/select.test.tsx verify:testExists(registry/ouro/components/ouro/select/select.test.tsx::Select > picks several values with multiple, as a string array)\n   */\n  onValueChange?: ((value: string | null) => void) | undefined;\n};\n\n/** A Select that picks several values, as a `string[]`. */\nexport type SelectMultipleProps = SelectBaseProps & {\n  /** Pick several values: the list stays open while the user chooses, and the value is a `string[]` instead of `string | null`. */\n  multiple: true;\n  /**\n   * The chosen value, when you control it: a `string`, or `null` for none; with `multiple`, a `string[]`.\n   *\n   * @claim \"The chosen value, when you control\" registry/ouro/components/ouro/select/select.test-d.ts verify:fileLine(registry/ouro/components/ouro/select/select.test-d.ts, /\\{\\slabel:\\s\"Tags\";\\smultiple:\\strue;\\svalue:\\s\"quick\"\\s\\}>\\(\\)\\.not\\.toExtend<SelectProps>/)\n   */\n  value?: string[] | undefined;\n  /** The value chosen at first, when the select keeps its own state: a `string` or `null`; with `multiple`, a `string[]`. */\n  defaultValue?: string[] | undefined;\n  /**\n   * Called with the new value when the user chooses an option: a `string` or `null`; with `multiple`, every chosen value as a `string[]`.\n   *\n   * @claim \"Called with the new value when\" registry/ouro/components/ouro/select/select.test.tsx verify:testExists(registry/ouro/components/ouro/select/select.test.tsx::Select > chooses an option, shows its label and submits its value)\n   * @claim \"Called with the new value when\" registry/ouro/components/ouro/select/select.test.tsx verify:testExists(registry/ouro/components/ouro/select/select.test.tsx::Select > picks several values with multiple, as a string array)\n   */\n  onValueChange?: ((value: string[]) => void) | undefined;\n};\n\n/** Props for {@link Select}: `multiple` switches the value from `string | null` to `string[]`. */\nexport type SelectProps = SelectSingleProps | SelectMultipleProps;\n\n/** Field's messages and root name Select; its label is a `<div>` that names the trigger. */\nconst owner = { name: \"Select\", data: \"select\", nativeLabel: false as const };\n/** Marks the hidden input Base UI submits the value with. */\nconst markInput = controlRef(\"select\", \"hidden-input\");\n\n/**\n * A chevron pointing up and down, drawn in the muted text color at 16px.\n *\n * @claim \"A chevron pointing up and down\" registry/ouro/components/ouro/select/select.tsx verify:fileLine(registry/ouro/components/ouro/select/select.tsx, /viewBox=\"0\\s0\\s16\\s16\"\\sfill=\"none\"\\sstroke=\"currentColor\"/)\n */\nfunction ChevronIcon(): JSX.Element {\n  return (\n    <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n      <path d=\"M5 6.5L8 3.5l3 3M5 9.5l3 3 3-3\" />\n    </svg>\n  );\n}\n\n/** The parts of Select that read the Field it sits in. */\nfunction SelectControl({\n  props,\n  items,\n}: {\n  props: SelectProps;\n  items: Array<{ value: string; label: ReactNode }>;\n}): JSX.Element {\n  const { label, required, disabled, readOnly, name, placeholder, options, children, autoComplete, form: formId, ref, multiple, value, defaultValue, onValueChange } =\n    props as SelectBaseProps & {\n      multiple?: boolean;\n      value?: string | string[] | null;\n      defaultValue?: string | string[] | null;\n      onValueChange?: (value: string | string[] | null) => void;\n    };\n  const field = useField()!;\n  const form = useFormErrors();\n  // Phones (below sm, with a coarse pointer) get the list as a bottom sheet. The list only\n  // renders open, after hydration, so the server's answer never shows.\n  const sheet = useMediaQuery(sheetQuery, false);\n  const presentation = sheet ? \"sheet\" : undefined;\n\n  // Choosing a value drops a Form error for this name, as typing does in a text field.\n  const handleValueChange = (next: string | string[] | null) => {\n    if (name !== undefined) form?.clear(name);\n    onValueChange?.(next);\n  };\n\n  const portal = usePortalContainer(\"Select\", true);\n  return (\n    <BaseSelect.Root<string, boolean>\n      items={items}\n      multiple={multiple}\n      {...(value !== undefined ? { value } : {})}\n      {...(defaultValue !== undefined ? { defaultValue } : {})}\n      onValueChange={handleValueChange}\n      name={name}\n      required={required}\n      disabled={disabled}\n      readOnly={readOnly}\n      autoComplete={autoComplete}\n      form={formId}\n      inputRef={markInput}\n    >\n      {/* A div, not a button: VoiceOver drops the end of a <button role=\"combobox\">'s value and adds a comma before\n          it (WebKit bug 285047, ourostack/ouro-ui#113), and reads a div's whole, on macOS 15 and 26. */}\n      <BaseSelect.Trigger\n        render={<div />}\n        nativeButton={false}\n        {...holdPageAtPress.listButton}\n        ref={ref}\n        data-ouro-control=\"select\"\n        data-ouro-part=\"trigger\"\n        className={triggerClass}\n        aria-labelledby={field.labelId}\n        aria-describedby={field.describedBy}\n        aria-invalid={field.invalid || undefined}\n      >\n        <BaseSelect.Value placeholder={placeholder} className=\"min-w-0 flex-1 truncate\" />\n        <ChevronIcon />\n      </BaseSelect.Trigger>\n      {/* Base UI puts the portal inside a Dialog's or Sheet's portal when the Select is in one, where\n          the dialog's layers sit at z-1000; 1000 above --ouro-layer clears them there and on the page. */}\n      <BaseSelect.Portal {...portal} data-ouro=\"select-portal\" className=\"relative isolate z-[calc(var(--ouro-layer)+1000)]\">\n        <PortalScope>\n          {sheet && <BaseSelect.Backdrop data-ouro=\"select-backdrop\" className={backdropClass} />}\n          <BaseSelect.Positioner\n            className={positionerClass}\n            sideOffset={4}\n            collisionPadding={8}\n            alignItemWithTrigger={!sheet}\n            data-ouro-presentation={presentation}\n          >\n            <BaseSelect.Popup className={popupClass} data-ouro=\"select-popup\" data-ouro-presentation={presentation} onFocus={focusOptionFromPopup}>\n              {sheet && (\n                <div aria-hidden=\"true\" className={sheetTitleClass}>\n                  {label}\n                </div>\n              )}\n              <BaseSelect.List className=\"min-h-0 flex-1 overflow-y-auto overscroll-contain\">\n                <SelectListScope>\n                  {options\n                    ? options.map((entry) =>\n                        isGroup(entry) ? (\n                          <SelectGroup key={`group:${entry.label}`} label={entry.label}>\n                            {entry.options.map((option) => (\n                              <SelectItem key={option.value} value={option.value} disabled={option.disabled}>\n                                {option.label}\n                              </SelectItem>\n                            ))}\n                          </SelectGroup>\n                        ) : (\n                          <SelectItem key={entry.value} value={entry.value} disabled={entry.disabled}>\n                            {entry.label}\n                          </SelectItem>\n                        ),\n                      )\n                    : children}\n                </SelectListScope>\n              </BaseSelect.List>\n            </BaseSelect.Popup>\n          </BaseSelect.Positioner>\n        </PortalScope>\n      </BaseSelect.Portal>\n    </BaseSelect.Root>\n  );\n}\n\n/**\n * A labeled list of choices on the Field contract: pass `label`, `options` (or `SelectItem`\n * children) and `error` from your server action or client check. With `multiple` the value\n * is a `string[]`. On a phone the list opens as a bottom sheet you scroll with your thumb;\n * elsewhere it opens next to the trigger, over the chosen option. It submits its value under\n * `name` in a plain form post. Covers Catalyst's Listbox.\n *\n * A `multiple` Select posts one entry per chosen value, all under `name`, in the order they\n * were chosen, and no entry when nothing is chosen: read them with\n * `formData.getAll(\"tags\")`, not `formData.get`. In a test, open the list and choose an\n * option with real pointer events (`userEvent.click` in Vitest browser mode, `locator.click()`\n * in Playwright): the options act on pointer events, so a synthetic `fireEvent.click`\n * chooses nothing.\n *\n * Use `NativeSelect` instead for the operating system's own picker (long lists of plain\n * text on phones, such as countries), `RadioGroup` for two to five choices that should all\n * show, and `Combobox` when the user needs to type to filter.\n *\n * @group Forms\n * @see https://ui.ouroboros.bot/docs/select\n *\n * @example\n * <Select\n *   label=\"Course\"\n *   name=\"course\"\n *   placeholder=\"Choose a course\"\n *   options={[{ value: \"starter\", label: \"Starter\" }, { value: \"main\", label: \"Main\" }]}\n *   error={errors?.course}\n * />\n * <Select label=\"Tags\" name=\"tags\" multiple defaultValue={[\"quick\"]} options={tags} />\n * @claim \"A `multiple` Select posts one entry\" registry/ouro/components/ouro/select/select.test.tsx verify:testExists(registry/ouro/components/ouro/select/select.test.tsx::Select > posts one entry per chosen value under its name with multiple, for formData.getAll)\n */\nexport function Select(props: SelectProps): JSX.Element {\n  const {\n    label,\n    hideLabel,\n    description,\n    error,\n    required,\n    disabled,\n    name,\n    options,\n    children,\n    className,\n    // Guard props (hint types), never passed on.\n    onChange,\n    isMulti,\n    items: itemsGuess,\n    errorMessage,\n    helperText,\n    isInvalid,\n    invalid,\n    isRequired,\n    isDisabled,\n  } = props;\n\n  const hasChildren = children !== undefined && children !== null && children !== false;\n  useDevWarnings(\n    \"Select\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          onChange !== undefined && [\"onChange is not a prop; Select calls onValueChange with the value\", \"<Select onValueChange={(value) => setValue(value)}>\"],\n          isMulti !== undefined && [\"isMulti is not a prop\", \"<Select multiple>\"],\n          itemsGuess !== undefined && [\"items is not a prop\", '<Select options={[{ value: \"main\", label: \"Main\" }]}>'],\n          ...contractWarnings(\"Select\", { errorMessage, helperText, isInvalid, invalid, isRequired, isDisabled }),\n          options !== undefined &&\n            hasChildren && [\"options and children are both set, so the children are ignored\", `<Select label=\"${label}\" options={options} />`],\n          options === undefined &&\n            !hasChildren && [\"there are no options to choose from\", `<Select label=\"${label}\" options={[{ value: \"main\", label: \"Main\" }]} />`],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n\n  // The trigger shows the chosen option's label, so Select needs every value's label up front.\n  const items = useMemo(() => flattenOptions(options, options ? undefined : children, SelectItem), [options, children]);\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        <SelectControl props={props} items={items} />\n      </Field>\n    </FieldOwnerContext.Provider>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/select/select.tsx"
    }
  ],
  "docs": "A labeled list of choices on the Field contract: pass `label`, `options` (or `SelectItem` children) and `error` from your server action or client check. Import: import { Select } from \"@/components/ouro/select/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/select.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}