{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "text-field",
  "title": "TextField",
  "description": "A labeled one-line text input on the Field contract: pass `label`, and `error` from your server action or client check.",
  "registryDependencies": [
    "@ouro/button",
    "@ouro/field",
    "@ouro/lib-cn",
    "@ouro/lib-env",
    "@ouro/lib-refs",
    "@ouro/lib-use-dev-messages",
    "@ouro/lib-use-field"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/text-field/text-field-styles.ts",
      "content": "export {\n  adornmentClass,\n  controlSizeWarning,\n  controlVariantWarning,\n  endSlotClass,\n  groupBaseClass,\n  groupClass,\n  groupSizes,\n  groupVariants,\n  inputClass,\n  nativeClearClass,\n  textFieldTypes,\n  typeDefaults,\n  typeWarning,\n};\nexport type { TextFieldType };\n\n// Class strings, value lists and dev-message helpers for TextField, apart from the component\n// so its file exports only components (React Fast Refresh). Class strings are literal so the\n// app's Tailwind finds them when it compiles.\n\n/**\n * The types TextField supports. `number` is not one: NumberField parses and steps numbers.\n *\n * @internal\n * @claim \"The types TextField supports\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.test.tsx::TextField types > renders a text input and lists the types for any other type)\n * @claim \"The types TextField supports\" registry/ouro/components/ouro/text-field/text-field-styles.ts verify:fileLine(registry/ouro/components/ouro/text-field/text-field-styles.ts, /const\\stextFieldTypes\\s=\\s\\[\"text\",\\s\"email\",\\s\"password\",\\s\"tel\",\\s\"url\",\\s\"search\",\\s\"date\",\\s\"time\"\\]/)\n */\nconst textFieldTypes = [\"text\", \"email\", \"password\", \"tel\", \"url\", \"search\", \"date\", \"time\"] as const;\n\n/**\n * A type TextField supports.\n *\n * @internal\n * @claim \"A type TextField supports\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.test.tsx::TextField types > renders a text input and lists the types for any other type)\n * @claim \"A type TextField supports\" registry/ouro/components/ouro/text-field/text-field-styles.ts verify:fileLine(registry/ouro/components/ouro/text-field/text-field-styles.ts, /const\\stextFieldTypes\\s=/)\n */\ntype TextFieldType = (typeof textFieldTypes)[number];\n\n/** The attributes a type sets unless the app passes its own. */\ninterface TypeDefaults {\n  inputMode?: \"text\" | \"email\" | \"tel\" | \"url\" | \"search\" | \"decimal\";\n  autoComplete: string;\n  autoCapitalize?: \"none\";\n  spellCheck?: false;\n  enterKeyHint?: \"search\";\n}\n\n/**\n * Each type's keyboard (`inputMode`) and autofill (`autoComplete`) defaults. A password\n * autofills the saved one; pass `autoComplete=\"new-password\"` on sign-up. Date and time open\n * the OS picker, so they set no keyboard.\n *\n * @internal\n * @claim \"Each type's keyboard (`inputMode`) and autofill\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.test.tsx::TextField > lets the app's inputMode and autoComplete win over the type's defaults)\n * @claim \"Each type's keyboard (`inputMode`) and autofill\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.test.tsx::TextField types > turns off capitalization and spell check for email and url)\n * @claim \"Date and time open the OS\" registry/ouro/components/ouro/text-field/text-field-styles.ts verify:fileLine(registry/ouro/components/ouro/text-field/text-field-styles.ts, /^\\s+date:\\s\\{\\sautoComplete:\\s\"off\"\\s\\},/)\n */\nconst typeDefaults: Readonly<Record<TextFieldType, TypeDefaults>> = {\n  text: { inputMode: \"text\", autoComplete: \"on\" },\n  email: { inputMode: \"email\", autoComplete: \"email\", autoCapitalize: \"none\", spellCheck: false },\n  password: { inputMode: \"text\", autoComplete: \"current-password\" },\n  tel: { inputMode: \"tel\", autoComplete: \"tel\" },\n  url: { inputMode: \"url\", autoComplete: \"url\", autoCapitalize: \"none\", spellCheck: false },\n  search: { inputMode: \"search\", autoComplete: \"off\", enterKeyHint: \"search\" },\n  date: { autoComplete: \"off\" },\n  time: { autoComplete: \"off\" },\n};\n\n/**\n * The box around the input and its adornments, whatever its variant and size: the focus\n * outline is on the box while the input has keyboard focus. Its height is one unprefixed\n * class that reads a variable the size sets.\n *\n * @internal\n */\nconst groupBaseClass =\n  \"relative m-0 box-border flex w-full min-w-0 items-center gap-2 h-(--ouro-control-h) py-0 cursor-text \" +\n  \"rounded-ouro-md text-foreground \" +\n  \"outline-ring outline-offset-2 has-[input:focus-visible]:outline-2 has-[input:focus-visible]:outline-solid \" +\n  \"has-[input:disabled]:cursor-not-allowed has-[input:disabled]:opacity-50\";\n\n/**\n * The box's frame. `outline` is Field's control look. `plain` draws no border, background or\n * side padding, for a field inside a frame the app draws; it keeps the corner radius, which\n * only the focus outline shows.\n *\n * @internal\n * @claim \"`plain` draws no border, background or\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.test.tsx::TextField variant and size > draws no frame of its own with variant plain, and still outlines on keyboard focus)\n */\nconst groupVariants = {\n  outline:\n    \"isolate px-3 border border-solid border-(--ouro-bd) bg-(--ouro-bg) \" +\n    \"[--ouro-bg:transparent] dark:[--ouro-bg:color-mix(in_oklab,var(--input)_30%,transparent)] [--ouro-bd:var(--input)] \" +\n    \"has-[input[aria-invalid=true]]:[--ouro-bd:var(--destructive)] [--ouro-sq-w:1px] \" +\n    \"[--ouro-sq-r:calc(var(--radius)*var(--ouro-radius-scale,1)*0.8)] \" +\n    \"transition-[border-color] duration-(--ouro-duration-fast) ease-[ease] \",\n  plain: \"px-0 border-0 bg-transparent\",\n} as const;\n\n/**\n * The box's height and font size. `md` is 44px tall with a 16px font on phones, stepping down\n * from `sm` with a fine pointer. `lg` is 56px tall, 48px from `sm` with a fine pointer, with\n * a 20px font and 20px icons at every width.\n *\n * @internal\n * @claim \"`md` is 44px tall with a\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.test.tsx::TextField looks > uses a 16px font on phones, so iOS does not zoom on focus, and a 44px box)\n * @claim \"`lg` is 56px tall, 48px from\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.test.tsx::TextField variant and size > sets 20px text in a taller box with size lg, at phone and desktop widths)\n */\nconst groupSizes = {\n  md: \"[--ouro-control-h:calc(var(--spacing)*11)] sm:pointer-fine:[--ouro-control-h:calc(var(--spacing)*9)] text-base sm:pointer-fine:text-sm\",\n  lg:\n    \"[--ouro-control-h:calc(var(--spacing)*14)] sm:pointer-fine:[--ouro-control-h:calc(var(--spacing)*12)] text-xl \" +\n    \"[&_[data-ouro-adornment]_svg]:size-5\",\n} as const;\n\n/**\n * The outlined box at the medium size, for the controls that share TextField's box (Combobox,\n * DatePicker).\n *\n * @internal\n */\nconst groupClass = `${groupBaseClass} ${groupVariants.outline} ${groupSizes.md}`;\n\n/**\n * The input inside the box: borderless, filling it, in the box's font size. Date and time\n * values start at the inline start, as text does (iOS centers them).\n *\n * @internal\n */\nconst inputClass =\n  \"m-0 box-border block h-full min-w-0 flex-1 self-stretch border-0 bg-transparent p-0 \" +\n  \"text-[length:inherit] text-inherit font-[inherit] outline-none placeholder:text-muted-foreground \" +\n  \"disabled:cursor-not-allowed [&::-webkit-date-and-time-value]:text-start\";\n\n/**\n * The browser's own clear button on a search input, hidden when TextField draws its own.\n *\n * @internal\n */\nconst nativeClearClass = \"[&::-webkit-search-cancel-button]:appearance-none\";\n\n/**\n * Text or an icon before or after the input, in the muted foreground.\n *\n * @internal\n */\nconst adornmentClass = \"flex shrink-0 items-center whitespace-nowrap text-muted-foreground select-none [&_svg]:size-4 [&_svg]:shrink-0\";\n\n/**\n * The trailing buttons (clear, show password) sit close to the box's end edge. On a coarse\n * pointer they sit 12px apart, so their 44px touch areas do not overlap. A plain box has no\n * padding to pull them into, so TextField sets `me-0` there.\n *\n * @internal\n * @claim \"On a coarse pointer they sit\" registry/ouro/components/ouro/text-field/text-field.touch.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.touch.test.tsx::gives the toggle a 44px hit area, though it is smaller than the box)\n * @claim \"On a coarse pointer they sit\" registry/ouro/components/ouro/text-field/text-field.touch.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.touch.test.tsx::keeps the clear button's and the toggle's touch areas apart)\n * @claim \"A plain box has no padding\" registry/ouro/components/ouro/text-field/text-field.tsx verify:fileLine(registry/ouro/components/ouro/text-field/text-field.tsx, /variant\\s===\\s\"plain\"\\s&&\\s\"me-0\"/)\n */\nconst endSlotClass = \"-me-2 flex shrink-0 items-center gap-1 pointer-coarse:gap-3\";\n\n/** Types that are another component's job, with why and the fix. */\nconst otherComponents: Readonly<Record<string, (label: string) => readonly [string, string]>> = {\n  number: (label) => [\"NumberField parses, steps and formats numbers\", `<NumberField label=\"${label}\" />, or <TextField inputMode=\"numeric\"> for digit codes`],\n  \"datetime-local\": (label) => [\n    \"has no date-and-time field; DatePicker picks the date and a time TextField the time\",\n    `<DatePicker label=\"${label}\" name=\"date\" /> and <TextField label=\"Time\" type=\"time\" name=\"time\" />`,\n  ],\n  month: (label) => [\"DatePicker picks dates from a calendar\", `<DatePicker label=\"${label}\" />, or <TextField type=\"date\"> for the OS picker`],\n  week: (label) => [\"DatePicker picks dates from a calendar\", `<DatePicker label=\"${label}\" />, or <TextField type=\"date\"> for the OS picker`],\n  file: (label) => [\"FileField picks and lists files\", `<FileField label=\"${label}\" name=\"file\" />`],\n};\n\n/**\n * The dev message for a type TextField does not support: the component that does the job when\n * there is one (NumberField, DatePicker, FileField), else the list of types. Development only.\n *\n * @internal\n * @claim \"The dev message for a type\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.test.tsx::TextField types > renders a text input with a decimal keyboard and points to NumberField for type=number)\n * @claim \"The dev message for a type\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.test.tsx::TextField types > renders a text input and lists the types for any other type)\n */\nfunction typeWarning(type: string, label: string): readonly [string, string] {\n  if (Object.hasOwn(otherComponents, type)) {\n    const [why, fix] = otherComponents[type]!(label);\n    return [`type=\"${type}\" is not a TextField type; ${why}`, fix];\n  }\n  return [`type=\"${type}\" is not a TextField type; use ${textFieldTypes.map((name) => `\"${name}\"`).join(\", \")}`, '<TextField type=\"text\">'];\n}\n\n/** Names other libraries give a control without a frame. */\nconst plainNames: readonly string[] = [\"ghost\", \"unstyled\", \"borderless\", \"bare\", \"none\", \"flushed\", \"transparent\"];\n\n/**\n * The dev message for a variant that is not one of a text control's. Development only.\n *\n * @internal\n */\nfunction controlVariantWarning(component: string, variant: string): readonly [string, string] {\n  return [`variant=\"${variant}\" is not a variant; use \"outline\" or \"plain\"`, `<${component} variant=\"${plainNames.includes(variant) ? \"plain\" : \"outline\"}\">`];\n}\n\n/**\n * The dev message for a size that is not one of a text control's. A number is the native\n * `size` attribute (a width in characters), which the prop replaces. Development only.\n *\n * @internal\n */\nfunction controlSizeWarning(component: string, size: unknown): readonly [string, string] {\n  if (typeof size === \"number\") {\n    return [`size={${size}} is not a size; a width in characters is not supported, so set the width with className`, `<${component} className=\"w-40\">`];\n  }\n  return [`size=\"${String(size)}\" is not a size; use \"md\" or \"lg\"`, `<${component} size=\"md\">`];\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/text-field/text-field-styles.ts"
    },
    {
      "path": "registry/ouro/components/ouro/text-field/text-field.tsx",
      "content": "\"use client\";\n\nimport { useEffect, useId, useLayoutEffect, useRef, useState } from \"react\";\nimport { flushSync } from \"react-dom\";\nimport type { JSX, MouseEvent, ReactNode, Ref } from \"react\";\nimport { Button } from \"@/registry/ouro/components/ouro/button/button\";\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 { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { useMergedRef } from \"@/registry/ouro/lib/ouro/refs\";\nimport { FieldOwnerContext, type ReadonlyErrorMessages } from \"@/registry/ouro/lib/ouro/use-field\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\nimport {\n  adornmentClass,\n  controlSizeWarning,\n  controlVariantWarning,\n  endSlotClass,\n  groupBaseClass,\n  groupSizes,\n  groupVariants,\n  inputClass,\n  nativeClearClass,\n  textFieldTypes,\n  typeDefaults,\n  typeWarning,\n  type TextFieldType,\n} from \"@/registry/ouro/components/ouro/text-field/text-field-styles\";\n\n/** The props TextField adds to the input attributes it passes through. */\nexport interface TextFieldOwnProps {\n  /**\n   * What the field 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`. A placeholder is not a label.\n   * @claim \"Required: every control needs a name\" registry/ouro/components/ouro/text-field/text-field.test-d.ts verify:fileLine(registry/ouro/components/ouro/text-field/text-field.test-d.ts, /expectTypeOf<\\{\\stype:\\s\"email\"\\s\\}>\\(\\)\\.not\\.toExtend<TextFieldProps>/)\n   */\n  label: string;\n  /** Hides the label visually; screen readers still read it as the field'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 field, 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  /** The field must be filled: it gets `required` and `aria-required`, and the label a marker. */\n  required?: boolean | undefined;\n  /** Disables the field, its buttons included, and fades it. */\n  disabled?: boolean | undefined;\n  /** The form field name the value submits under. */\n  name?: string | undefined;\n  /**\n   * What kind of text it holds. Each type sets the phone keyboard (`inputMode`) and autofill\n   * (`autoComplete`) for you; pass either to override. `password` adds a show/hide button;\n   * `date` and `time` open the OS picker. Other kinds of value have their own component:\n   * `NumberField` for numbers (`inputMode=\"numeric\"` here for digit codes), `DatePicker` for a\n   * date picked from a calendar, `DatePicker` beside a `type=\"time\"` TextField for a date and\n   * time (there is no `datetime-local`), and `FileField` for files. Any other string is a type\n   * error whose message names them.\n   * @default \"text\"\n   * @claim \"Each type sets the phone keyboard\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.test.tsx::TextField > lets the app's inputMode and autoComplete win over the type's defaults)\n   * @claim \"Each type sets the phone keyboard\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.test.tsx::TextField types > turns off capitalization and spell check for email and url)\n   * @claim \"Other kinds of value have their\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.test.tsx::TextField types > renders a text input with a decimal keyboard and points to NumberField for type=number)\n   * @claim \"Other kinds of value have their\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:fileLine(registry/ouro/components/ouro/text-field/text-field.test.tsx, /\\[\"datetime-local\",\\s\"has\\sno\\sdate-and-time\\sfield/)\n   */\n  type?:\n    | \"text\"\n    | \"email\"\n    | \"password\"\n    | \"tel\"\n    | \"url\"\n    | \"search\"\n    | \"date\"\n    | \"time\"\n    | (string & { 'number is <NumberField> (digit codes: inputMode=\"numeric\"); a calendar or datetime-local is <DatePicker>; file is <FileField>': never })\n    | undefined;\n  /**\n   * The frame. `outline` draws the bordered box. `plain` draws no border, background or side\n   * padding, for a field inside a frame your app draws (a search row with its own rules and\n   * a button beside the input); it keeps the focus outline, and the error message still shows\n   * under it, but with no border to turn red, color your own frame for an invalid field.\n   * Any other string is a type error whose message names the fix. @default \"outline\"\n   * @claim \"`plain` draws no border, background or\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.test.tsx::TextField variant and size > draws no frame of its own with variant plain, and still outlines on keyboard focus)\n   * @claim \"`plain` draws no border, background or\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.test.tsx::TextField variant and size > keeps a plain field's buttons inside its box)\n   */\n  variant?: \"outline\" | \"plain\" | (string & { 'default is \"outline\"; ghost, unstyled and borderless are \"plain\"': never }) | undefined;\n  /**\n   * Control size. `md` is 44px tall with 16px text on phones and steps down to desktop\n   * density from the `sm` breakpoint (640px). `lg` is 56px tall (48px on desktop) with 20px\n   * text at every width, for a page's main search. The font family is inherited, so set a\n   * display font on a parent. It replaces the input's own `size` attribute (a width in\n   * characters); set the width with `className`. @default \"md\"\n   * @claim \"`md` is 44px tall with 16px\" registry/ouro/components/ouro/text-field/text-field.touch.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.touch.test.tsx::keeps 16px text and a 44px box on a landscape phone, past the sm breakpoint)\n   * @claim \"`lg` is 56px tall (48px on\" registry/ouro/components/ouro/text-field/text-area.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-area.test.tsx::TextArea variant and size > sets 20px text on 28px lines with size lg, at phone and desktop widths)\n   * @claim \"`md` is 44px tall with 16px\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.test.tsx::TextField looks > uses a 16px font on phones, so iOS does not zoom on focus, and a 44px box)\n   * @claim \"`lg` is 56px tall (48px on\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.test.tsx::TextField variant and size > sets 20px text in a taller box with size lg, at phone and desktop widths)\n   */\n  size?: \"md\" | \"lg\" | (string & { 'default is \"md\"; \"lg\" is 20px text. For a width, use className=\"w-40\"': never }) | undefined;\n  /**\n   * Text or an icon inside the box, before the input: `\"$\"`, `<SearchIcon />`. Text is also\n   * read as part of the field's description. Replaces shadcn's InputGroup.\n   */\n  startAdornment?: ReactNode | undefined;\n  /** Text or an icon inside the box, after the input: `\"kg\"`, `<CheckIcon />`. Text is also read as part of the description. */\n  endAdornment?: ReactNode | undefined;\n  /**\n   * An example of what to type, shown while the field is empty: `\"you@example.com\"`. It is\n   * not a label; pass `label`, which stays visible.\n   */\n  placeholder?: string | undefined;\n  /** Adds a button that empties the field and puts focus back in it. It shows while there is text. */\n  clearable?: boolean | undefined;\n  /**\n   * The name of the clear button that `clearable` adds, as visually hidden text. Translate it with your app.\n   * @default \"Clear\"\n   */\n  clearLabel?: string | undefined;\n  /**\n   * The name of a password field's show/hide button, as visually hidden text and not an\n   * `aria-label`, so a test's `getByLabel(\"Password\")` finds the input alone; find the button\n   * with `getByRole(\"button\", { name: \"Show password\" })`. It stays the same while the password\n   * shows; the button's pressed state (`aria-pressed`) says whether it does. Translate it with your app.\n   * @default \"Show password\"\n   */\n  showPasswordLabel?: 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 input element. */\n  ref?: Ref<HTMLInputElement> | undefined;\n\n  /** Not a prop. Ouro UI uses `error`: `<TextField error=\"Required.\">`. */\n  errorMessage?: { 'Use <TextField error=\"Required.\">': never };\n  /** Not a prop. Ouro UI uses `description`: `<TextField description=\"We never share it.\">`. */\n  helperText?: { 'Use <TextField description=\"...\">': never };\n  /** Not a prop. `error` marks the field invalid: `<TextField error=\"What is wrong\">`. */\n  isInvalid?: { 'Use <TextField error=\"What is wrong\">': never };\n  /** Not a prop. `error` marks the field invalid: `<TextField error=\"What is wrong\">`. */\n  invalid?: { 'Use <TextField error=\"What is wrong\">': never };\n  /** Not a prop. Ouro UI uses `required`: `<TextField required>`. */\n  isRequired?: { 'Use <TextField required>': never };\n  /** Not a prop. Ouro UI uses `disabled`: `<TextField disabled>`. */\n  isDisabled?: { 'Use <TextField disabled>': never };\n  /** Not a prop. Ouro UI uses `startAdornment`: `<TextField startAdornment={<SearchIcon />}>`. */\n  startIcon?: { 'Use <TextField startAdornment={<SearchIcon />}>': never };\n  /** Not a prop. Ouro UI uses `startAdornment`: `<TextField startAdornment={<SearchIcon />}>`. */\n  leftIcon?: { 'Use <TextField startAdornment={<SearchIcon />}>': never };\n  /** Not a prop. Ouro UI uses `endAdornment`: `<TextField endAdornment={<CheckIcon />}>`. */\n  endIcon?: { 'Use <TextField endAdornment={<CheckIcon />}>': never };\n  /** Not a prop. Ouro UI uses `endAdornment`: `<TextField endAdornment={<CheckIcon />}>`. */\n  rightIcon?: { 'Use <TextField endAdornment={<CheckIcon />}>': never };\n  /** Not a prop. Ouro UI uses `startAdornment`: `<TextField startAdornment=\"$\">`. */\n  prefix?: { 'Use <TextField startAdornment=\"$\">': never };\n  /** Not a prop. Ouro UI uses `endAdornment`: `<TextField endAdornment=\"kg\">`. */\n  suffix?: { 'Use <TextField endAdornment=\"kg\">': never };\n  /** Not a prop. Ouro UI uses `clearable`: `<TextField clearable>`. */\n  isClearable?: { 'Use <TextField clearable>': never };\n  /** Not a prop. TextField is one line; use `TextArea` for several: `<TextArea label=\"Notes\" autoGrow />`. */\n  multiline?: { 'Use <TextArea label=\"Notes\" autoGrow />': never };\n}\n\n/** Props for {@link TextField}: its own props and the input attributes it passes through. */\nexport type TextFieldProps = Omit<FieldControlProps, keyof TextFieldOwnProps | \"render\"> & TextFieldOwnProps;\n\n/** Field's messages and root name TextField. */\nconst owner = { name: \"TextField\", data: \"text-field\" };\n\nconst preventFocusMove = (event: MouseEvent) => event.preventDefault();\n\n/** An adornment that is text, and so part of the field's description. */\nconst isText = (node: ReactNode): node is string | number => typeof node === \"string\" || typeof node === \"number\";\n\n/** The value prop as text, to know whether there is something to clear. */\nconst textOf = (value: unknown): string => (value === undefined || value === null ? \"\" : String(value));\n\n/**\n * Icons drawn in the text color at 16px, like the other Ouro icons.\n *\n * @claim \"Icons drawn in the text color\" registry/ouro/components/ouro/text-field/text-field.tsx verify:fileLine(registry/ouro/components/ouro/text-field/text-field.tsx, /viewBox=\"0\\s0\\s16\\s16\"/)\n * @claim \"Icons drawn in the text color\" registry/ouro/components/ouro/text-field/text-field.tsx verify:fileLine(registry/ouro/components/ouro/text-field/text-field.tsx, /stroke=\"currentColor\"/)\n */\nfunction Icon({ children }: { children: ReactNode }): 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=\"size-4\"\n    >\n      {children}\n    </svg>\n  );\n}\n\n/**\n * A labeled one-line text input on the Field contract: pass `label`, and `error` from your\n * server action or client check. The `type` sets the phone keyboard and autofill, `password`\n * gets a show/hide button that keeps focus in the input, `clearable` adds a clear button, and\n * `startAdornment`/`endAdornment` put text or icons inside the box.\n *\n * Use `TextArea` instead for several lines, `NumberField` for numbers, `DatePicker` for a date picked from a calendar, `FileField` for files, and `Field` with\n * `FieldControl` when the control is not a text input.\n *\n * Not here, because each has its own component:\n *\n * - Numbers: `NumberField` parses, steps and formats them. A digit code (a PIN, a postcode) stays a TextField with `inputMode=\"numeric\"`, or is an `OtpField`.\n *\n * - A date picked from a calendar: `DatePicker`. `type=\"date\"` here opens the OS picker.\n *\n * - A date and time together: there is no `datetime-local`. Use a `DatePicker` and a `type=\"time\"` TextField side by side, and join the two values on the server.\n *\n * - Files: `FileField`.\n *\n * - Several lines: `TextArea`.\n *\n * `variant=\"plain\"` draws no frame, and `size=\"lg\"` sets 20px text: together they put the\n * field inside a row your app frames, such as a page's main search between two rules.\n *\n * @group Forms\n * @see https://ui.ouroboros.bot/docs/text-field\n *\n * @example\n * <TextField label=\"Email\" type=\"email\" name=\"email\" required error={errors?.email} />\n * <TextField label=\"Password\" type=\"password\" name=\"password\" autoComplete=\"new-password\" />\n * <TextField label=\"Search recipes\" hideLabel type=\"search\" clearable startAdornment={<SearchIcon />} />\n * <TextField label=\"Price\" startAdornment=\"$\" endAdornment=\"per jar\" />\n *\n * @example\n * // A hero search: the row draws the rules, the field has no frame and large text.\n * <form action=\"/recipes\" className=\"flex items-center gap-3 border-y border-border font-serif\">\n *   <SearchIcon aria-hidden=\"true\" className=\"size-5 shrink-0\" />\n *   <TextField label=\"Search recipes\" hideLabel type=\"search\" name=\"q\" placeholder=\"tomato, beans, lemon\" variant=\"plain\" size=\"lg\" className=\"flex-1\" />\n *   <Button type=\"submit\">Search</Button>\n * </form>\n * @claim \"` sets 20px text: together they put the\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.test.tsx::TextField variant and size > sits inside the app's own bordered row: the row draws the one frame)\n * @claim \"` sets 20px text: together they put the\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.test.tsx::TextField variant and size > sets 20px text in a taller box with size lg, at phone and desktop widths)\n * @claim \"Not here, because each has its\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:testExists(registry/ouro/components/ouro/text-field/text-field.test.tsx::TextField types > renders a text input and lists the types for any other type)\n * @claim \"A date and time together: there\" registry/ouro/components/ouro/text-field/text-field.test.tsx verify:fileLine(registry/ouro/components/ouro/text-field/text-field.test.tsx, /\\[\"datetime-local\",\\s\"has\\sno\\sdate-and-time\\sfield/)\n */\nexport function TextField(props: TextFieldProps): JSX.Element {\n  const {\n    label,\n    hideLabel,\n    description,\n    error,\n    required,\n    disabled,\n    name,\n    type: typeProp = \"text\",\n    variant: variantProp = \"outline\",\n    size: sizeProp = \"md\",\n    startAdornment,\n    endAdornment,\n    clearable,\n    clearLabel = \"Clear\",\n    showPasswordLabel = \"Show password\",\n    className,\n    ref,\n    value,\n    defaultValue,\n    onChange,\n    readOnly,\n    inputMode,\n    autoComplete,\n    \"aria-describedby\": describedByProp,\n    // Guard props (hint types), dropped here so they never reach the DOM.\n    errorMessage,\n    helperText,\n    isInvalid,\n    invalid,\n    isRequired,\n    isDisabled,\n    startIcon,\n    leftIcon,\n    endIcon,\n    rightIcon,\n    prefix,\n    suffix,\n    isClearable,\n    multiline,\n    ...rest\n  } = props;\n  // A type that is not one of TextField's (a type error) warns and renders the default.\n  const type: TextFieldType = textFieldTypes.includes(typeProp as TextFieldType) ? (typeProp as TextFieldType) : \"text\";\n  const variant = Object.hasOwn(groupVariants, variantProp) ? (variantProp as keyof typeof groupVariants) : \"outline\";\n  const size = Object.hasOwn(groupSizes, sizeProp) ? (sizeProp as keyof typeof groupSizes) : \"md\";\n  // A number that fell back to text still gets a number keyboard.\n  const defaults = typeProp === \"number\" ? { ...typeDefaults.text, inputMode: \"decimal\" as const } : typeDefaults[type];\n  const id = useId();\n  const startId = `${id}-start`;\n  const endId = `${id}-end`;\n  const inputRef = useRef<HTMLInputElement | null>(null);\n\n  useDevWarnings(\n    \"TextField\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          type !== typeProp && typeWarning(String(typeProp), label),\n          variant !== variantProp && controlVariantWarning(\"TextField\", String(variantProp)),\n          size !== sizeProp && controlSizeWarning(\"TextField\", sizeProp),\n          ...contractWarnings(\"TextField\", { errorMessage, helperText, isInvalid, invalid, isRequired, isDisabled }),\n          startIcon !== undefined && [\"startIcon is not a prop\", \"<TextField startAdornment={<SearchIcon />}>\"],\n          leftIcon !== undefined && [\"leftIcon is not a prop\", \"<TextField startAdornment={<SearchIcon />}>\"],\n          endIcon !== undefined && [\"endIcon is not a prop\", \"<TextField endAdornment={<CheckIcon />}>\"],\n          rightIcon !== undefined && [\"rightIcon is not a prop\", \"<TextField endAdornment={<CheckIcon />}>\"],\n          prefix !== undefined && [\"prefix is not a prop\", `<TextField startAdornment=\"${String(prefix)}\">`],\n          suffix !== undefined && [\"suffix is not a prop\", `<TextField endAdornment=\"${String(suffix)}\">`],\n          isClearable !== undefined && [\"isClearable is not a prop\", \"<TextField clearable>\"],\n          multiline !== undefined && [\"multiline is not a prop; TextField is one line\", '<TextArea label=\"Notes\" autoGrow />'],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n\n  // Whether there is text to clear: the value when controlled, else what the user typed.\n  const [typed, setTyped] = useState(() => textOf(defaultValue) !== \"\");\n  const filled = value === undefined ? typed : textOf(value) !== \"\";\n  const handleChange: NonNullable<FieldControlProps[\"onChange\"]> = (event) => {\n    setTyped(event.currentTarget.value !== \"\");\n    onChange?.(event);\n  };\n  // A form reset puts back the default value after the reset event, so read it a task later.\n  useEffect(() => {\n    const form = inputRef.current!.form;\n    if (!clearable || !form) return;\n    const onReset = () => setTimeout(() => setTyped(inputRef.current?.value !== \"\"));\n    form.addEventListener(\"reset\", onReset);\n    return () => form.removeEventListener(\"reset\", onReset);\n  }, [clearable]);\n\n  const clear = () => {\n    const input = inputRef.current!;\n    // Set the value the way typing does, so React's onChange and Base UI's onValueChange fire\n    // for a controlled field and an uncontrolled one alike.\n    Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, \"value\")!.set!.call(input, \"\");\n    input.dispatchEvent(new Event(\"input\", { bubbles: true }));\n    input.focus();\n  };\n\n  // Showing the password changes the input's type, which resets the cursor in some browsers:\n  // remember the selection while the input has focus, and put it back after the change.\n  const [revealed, setRevealed] = useState(false);\n  const selection = useRef<[number | null, number | null] | null>(null);\n  const toggle = () => {\n    const input = inputRef.current!;\n    if (input.ownerDocument.activeElement === input) selection.current = [input.selectionStart, input.selectionEnd];\n    setRevealed((shown) => !shown);\n  };\n  // A password submitted while it shows would reach password managers as text, so hide it\n  // when the form submits (before the app's own submit handler runs).\n  const password = type === \"password\";\n  useEffect(() => {\n    const form = inputRef.current!.form;\n    if (!password || !form) return;\n    const onSubmit = () => flushSync(() => setRevealed(false));\n    form.addEventListener(\"submit\", onSubmit);\n    return () => form.removeEventListener(\"submit\", onSubmit);\n  }, [password]);\n  useLayoutEffect(() => {\n    const saved = selection.current;\n    if (!saved) return;\n    selection.current = null;\n    const input = inputRef.current!;\n    // Chrome rebuilds the input's editor on the next layout after a type change, which moves\n    // the cursor to the start: lay out first, then set the selection.\n    void input.offsetWidth;\n    input.setSelectionRange(saved[0], saved[1]);\n  }, [revealed]);\n\n  // Pressing the box outside the input (its padding, a text adornment) focuses the input, as\n  // pressing a plain input's padding does. Buttons and links inside keep their own focus.\n  const focusInput = (event: MouseEvent<HTMLDivElement>) => {\n    const target = event.target as HTMLElement;\n    // Only controls inside the box count: a dialog around the field has a tabindex too.\n    const control = target.closest(\"button, a, input, select, textarea, [tabindex]\");\n    if (target === inputRef.current || (control && event.currentTarget.contains(control))) return;\n    event.preventDefault();\n    inputRef.current!.focus();\n  };\n\n  const setRef = useMergedRef(ref, inputRef);\n\n  const hasStart = startAdornment !== undefined && startAdornment !== null && startAdornment !== false;\n  const hasEnd = endAdornment !== undefined && endAdornment !== null && endAdornment !== false;\n  const describedBy =\n    [isText(startAdornment) && startId, isText(endAdornment) && endId, describedByProp].filter(Boolean).join(\" \") || undefined;\n  const showClear = clearable && filled && !disabled && !readOnly;\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\n          data-ouro-input-group=\"\"\n          data-variant={variant}\n          data-size={size}\n          data-ouro-squircle={variant === \"outline\" ? \"\" : undefined}\n          className={cn(groupBaseClass, groupVariants[variant], groupSizes[size])}\n          onMouseDown={focusInput}\n        >\n          {variant === \"outline\" && <span data-ouro-surface=\"\" aria-hidden=\"true\" style={{ zIndex: -1 }} />}\n          {hasStart && (\n            <span id={startId} data-ouro-adornment=\"start\" className={adornmentClass}>\n              {startAdornment}\n            </span>\n          )}\n          <FieldControl\n            {...rest}\n            ref={setRef}\n            value={value}\n            defaultValue={defaultValue}\n            onChange={handleChange}\n            readOnly={readOnly}\n            type={password && revealed ? \"text\" : type}\n            inputMode={inputMode ?? defaults.inputMode}\n            autoComplete={autoComplete ?? defaults.autoComplete}\n            autoCapitalize={rest.autoCapitalize ?? defaults.autoCapitalize}\n            spellCheck={rest.spellCheck ?? defaults.spellCheck}\n            enterKeyHint={rest.enterKeyHint ?? defaults.enterKeyHint}\n            aria-describedby={describedBy}\n            render={(controlProps) => (\n              <input {...controlProps} data-ouro-control=\"text-field\" data-ouro-part=\"input\" className={cn(inputClass, clearable && type === \"search\" && nativeClearClass)} />\n            )}\n          />\n          {/* The buttons are named by visually hidden text, not `aria-label`: an aria-label is\n              label text, so a label lookup for the field (\"Password\") would also find a button\n              whose label contains it (\"Show password\"). */}\n          {(showClear || password) && (\n            <span className={cn(endSlotClass, variant === \"plain\" && \"me-0\")}>\n              {showClear && (\n                <Button\n                  variant=\"plain\"\n                  tone=\"secondary\"\n                  size=\"sm\"\n                  data-ouro-clear=\"\"\n                  data-ouro-control=\"text-field\"\n                  data-ouro-part=\"clear\"\n                  className=\"aspect-square px-0\"\n                  onMouseDown={preventFocusMove}\n                  onClick={clear}\n                >\n                  <Icon>\n                    <path d=\"M4.5 4.5l7 7M11.5 4.5l-7 7\" />\n                  </Icon>\n                  <span className=\"sr-only\">{clearLabel}</span>\n                </Button>\n              )}\n              {password && (\n                <Button\n                  variant=\"plain\"\n                  tone=\"secondary\"\n                  size=\"sm\"\n                  data-ouro-show-password=\"\"\n                  data-ouro-control=\"text-field\"\n                  data-ouro-part=\"show-password\"\n                  aria-pressed={revealed}\n                  disabled={disabled}\n                  className=\"aspect-square px-0\"\n                  onMouseDown={preventFocusMove}\n                  onClick={toggle}\n                >\n                  <Icon>\n                    <path d=\"M1.5 8s2.4-4.5 6.5-4.5S14.5 8 14.5 8s-2.4 4.5-6.5 4.5S1.5 8 1.5 8z\" />\n                    <circle cx=\"8\" cy=\"8\" r=\"2\" />\n                    {revealed && <path d=\"M2.5 2.5l11 11\" />}\n                  </Icon>\n                  <span className=\"sr-only\">{showPasswordLabel}</span>\n                </Button>\n              )}\n            </span>\n          )}\n          {hasEnd && (\n            <span id={endId} data-ouro-adornment=\"end\" className={adornmentClass}>\n              {endAdornment}\n            </span>\n          )}\n        </div>\n      </Field>\n    </FieldOwnerContext.Provider>\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/text-field/text-field.tsx"
    }
  ],
  "docs": "A labeled one-line text input on the Field contract: pass `label`, and `error` from your server action or client check. Import: import { TextField } from \"@/components/ouro/text-field/text-field\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: button, 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/text-field.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}