{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "name-input",
  "title": "Name Input",
  "description": "A person-name form that asks for the parts of a name in the order the reader's own locale writes them, and that does not lock out the people a First name / Last name layout excludes. Eleven languages write the family name first — Hungarian, Japanese, Khmer, Korean, Mongolian, Sinhala, Tamil, Telugu, Vietnamese, Cantonese and Chinese — so the fields swap round for a Japanese or Tamil reader and the middle name stays in the middle, exactly as CLDR's own name patterns do. The family name is optional by default, because in parts of Southern India, Malaysia and Indonesia many people have a given name only, and a form that demands a family name does not collect family names: it collects \".\" and \"Mr.\" from people escaping the form. \"I have a single name\" swaps the two fields for one, carrying across whatever was already typed. The autofill tokens are the part that looks finished and is not: HTML defines name as the *full* name, so a split field must take given-name, additional-name and family-name, and name belongs only on the single field. The Japanese phonetic fields (セイ／メイ) have no autofill token at all, so they carry autocomplete=\"off\" rather than borrowing given-name, which would make the browser fill the kanji into the furigana box. No character validation, no case normalising, no length cap — O'Brien, van der Waals, McNamara and Rose Marie are all names, and only emptiness of the required fields is checked. Reach for it wherever a form collects a person's name: sign-up and onboarding; checkout and guest checkout; KYC, AML and identity verification; bookings, reservations and ticketing; passenger, traveller and boarding details; patient intake and clinic registration; student, HR and payroll records; invoice, receipt and billing names; visa, licence and government forms; shipping and recipient details next to address-input; the name row on a profile, customer, contact or CRM record; and any admin form with a person in it. Common asks it answers: \"name input react\", \"first name last name component\", \"shadcn name input\", \"shadcn name field\", \"full name form react\", \"given name family name react\", \"surname first name order\", \"name order by locale\", \"japanese name order form\", \"family name first locale react\", \"international name form\", \"i18n name form react\", \"name form cultural order\", \"middle name field optional\", \"mononym single name form\", \"people with one name form\", \"make last name optional\", \"required last name breaks signup\", \"autocomplete given-name family-name\", \"autocomplete name vs given-name\", \"html autofill name tokens\", \"furigana input react\", \"kana name field react\", \"セイ メイ フォーム react\", \"phonetic name field autocomplete\", \"name validation regex bad idea\", \"allow apostrophe hyphen in name\", \"do not uppercase names\", \"honorific prefix field react\", \"title field mr ms dr react\", \"cldr person names order\", \"name field accessibility aria\". Controlled or uncontrolled, every field always present so a half-filled name round-trips, and the answers are exported as pure functions so a server route, a confirmation screen or a test can get the same ones without mounting anything: nameOrderFor, resolveOrder, fieldsFor, validateName, formatName, emptyName, languageOf, SURNAME_FIRST_LANGUAGES, DEFAULT_REQUIRED and FIELD_LABELS. The surname-first table is derived from CLDR by node scripts/person-name-data.mjs, which re-derives and diffs it with --check. Styled entirely with shadcn tokens (input, ring, destructive, muted-foreground, primary) so it follows light and dark mode, and it ships zero npm dependencies — no name library, no locale package, one file.",
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/ui/name-input.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\n/**\n * A person's name, in the fields and the order the reader's own locale writes them.\n *\n * The reason this is a component and not two inputs labelled First name and Last name is that\n * both halves of that layout are assumptions, and each one locks somebody out.\n *\n * The **order** is not universal. Derived from CLDR, eleven languages write the family name first\n * — Hungarian, Japanese, Khmer, Korean, Mongolian, Sinhala, Tamil, Telugu, Vietnamese, Cantonese\n * and Chinese (`SURNAME_FIRST_LANGUAGES`, produced by `node scripts/person-name-data.mjs`). The\n * design note for this component had that list as \"Japan, China, Korea, Hungary\", which is four\n * right answers and seven missing ones; a Tamil or Khmer speaker meets exactly the same reversed\n * form as a Japanese one. The list is derived rather than written down because there is no way to\n * notice the omission by reading the component, and `--check` re-derives it against upstream.\n *\n * The **split itself** does not hold either. W3C's \"Personal names around the world\" is explicit:\n * do not require a family name, because in parts of Southern India, Malaysia and Indonesia a large\n * number of people have a given name only — and when a form demands one anyway, people \"enter\n * garbage data like '.' or 'Mr.' in the family name field just to escape the form\". A required\n * family name is the same defect as a required state in `address-input`: it does not collect the\n * missing data, it corrupts the data that was there. So the family name is **optional by default**,\n * and `allowSingleName` offers the reader one field instead of two.\n *\n * The **autofill tokens** are the part that looks done and is not. HTML defines `name` as the\n * *full* name — the spec's own example is \"Sir Timothy John Berners-Lee, OM, KBE, FRS, FREng,\n * FRSA\" — so putting `autocomplete=\"name\"` on a split field asks the browser to fill the whole\n * name into the half of the form meant for one part of it. The split fields take `given-name`,\n * `additional-name` and `family-name`; `name` is used here only in single-field mode, where it is\n * the correct token rather than a near-enough one.\n *\n * The **phonetic fields** Japanese forms carry (セイ／メイ) have no token at all. Measured against\n * the HTML standard, `phonetic`, `furigana` and `kana` appear zero times in the autofill section,\n * and CLDR's person-name fields (`given`, `given2`, `surname`, `generation`, `title`) have no\n * phonetic member either. The tempting fix is the nearest token — but `autocomplete=\"given-name\"`\n * on a reading field tells the browser to fill the *written* name into it, so a reader who\n * autofills gets kanji in the furigana box and has to clear it by hand. These fields therefore\n * carry `autocomplete=\"off\"`: there is no right token, and the nearest wrong one actively breaks\n * the field.\n *\n * What it deliberately does not do:\n *\n *   - **No character validation.** Not a letters-only rule, not a two-characters-minimum, not a\n *     \"no numbers\" rule. W3C's list of what this breaks is long — apostrophes and hyphens\n *     (O'Brien, Demna-Whitfield), spaces inside one name (Rose Marie), capitals that are not the\n *     first letter (McNamara), words that are not capitalised (van der Waals) — and a name that\n *     looks wrong to a regex is usually a name. Only emptiness of required fields is checked.\n *   - **No normalising.** The value is stored exactly as typed. No trimming into state, no title\n *     casing, no uppercasing: W3C asks forms to \"preserve the case the user enters\", and a form\n *     that renders `MCNAMARA` back at someone has not tidied their name, it has misspelt it.\n *   - **No length limit.** No `maxLength` on any field, because names are longer than the form\n *     designer's own.\n *   - **No title placement engine.** `honorific` is opt-in and the prefix renders first, which is\n *     what the token means. CLDR puts the title *last* in surname-first locales, and resolving\n *     that properly is a formatting problem, not a form problem.\n *\n * ```tsx\n * const [name, setName] = React.useState(emptyName)\n *\n * <NameInput value={name} onChange={setName} locale=\"ja-JP\" phonetic />\n * ```\n *\n * Validate on submit with the same rules the fields show on blur:\n *\n * ```tsx\n * const errors = validateName(name)\n * if (Object.keys(errors).length) return setShowErrors(true)\n * ```\n */\n\n/**\n * The locale the order is resolved in before hydration. See `activeLocale` in the component.\n *\n * CLDR's `und` — the root locale, what it answers when it is given nothing — lists itself as\n * given-first, so this default is the measured one rather than an Anglocentric guess.\n */\nconst HYDRATION_LOCALE = \"en-US\"\n\n/**\n * The languages whose forms write the family name first, derived from CLDR by\n * `node scripts/person-name-data.mjs`. Run it with `--check` to diff this against upstream.\n */\nexport const SURNAME_FIRST_LANGUAGES = [\n  \"hu\",\n  \"ja\",\n  \"km\",\n  \"ko\",\n  \"mn\",\n  \"si\",\n  \"ta\",\n  \"te\",\n  \"vi\",\n  \"yue\",\n  \"zh\",\n] as const\n\n/** Which part of the name a form writes first. */\nexport type NameOrder = \"givenFirst\" | \"surnameFirst\"\n\n/** The parts of a name this component collects, named as HTML autofill names them. */\nexport type NameField =\n  | \"honorificPrefix\"\n  | \"given\"\n  | \"additional\"\n  | \"surname\"\n  | \"phoneticSurname\"\n  | \"phoneticGiven\"\n  | \"fullName\"\n\n/**\n * A whole name. Every field is always present, even the ones the current options do not render, so\n * a partly-filled name is fully representable and a controlled parent can store it without\n * dropping keystrokes.\n *\n * `singleName` is part of the value rather than component state because it is the reader's answer\n * to a question about themselves, and it decides which of the other fields is their actual name. A\n * parent that stores the name and not that flag has stored a row it cannot read back.\n */\nexport type NameValue = Record<NameField, string> & { singleName: boolean }\n\n/**\n * The language subtag of a locale, lowercased — `ja-JP` is `ja`, `zh-Hant-MO` is `zh`.\n *\n * Hand-parsed rather than passed through `Intl`: this runs on whatever a caller puts in `locale`,\n * including a malformed tag, and the fallback that matters is \"treat it as unknown and use the\n * default order\", not an exception out of a form's render.\n */\nexport function languageOf(locale: string | undefined): string {\n  const match = /^[A-Za-z]{2,3}/.exec(String(locale ?? \"\").trim())\n  return match ? match[0].toLowerCase() : \"\"\n}\n\n/**\n * Whether a locale writes the family name before the given name.\n *\n * Asked of the *reader's* locale, which is a different question from the one CLDR's per-locale\n * lists answer. Those say which order a locale uses when it *displays* a name from somewhere else,\n * and the two disagree: `en` reorders a Hungarian name to Viktor Orbán, so asking `en` about `hu`\n * returns given-first. A form is not displaying a foreign name, it is collecting the reader's own,\n * so what matters is whether a locale writes *itself* surname-first — and `hu` does. That\n * distinction is the whole derivation; see scripts/person-name-data.mjs.\n */\nexport function nameOrderFor(locale: string | undefined): NameOrder {\n  const language = languageOf(locale)\n  return (SURNAME_FIRST_LANGUAGES as readonly string[]).includes(language)\n    ? \"surnameFirst\"\n    : \"givenFirst\"\n}\n\n/**\n * The default English labels, by field.\n *\n * Exported so a caller overriding one can start from the rest. The phonetic labels read \"(phonetic)\"\n * rather than \"Furigana\" because the fields are not Japanese-only — Hong Kong and Taiwan forms ask\n * for a romanised reading in the same slot — and a Japanese form should pass `labels` with セイ and\n * メイ, which is one object rather than a locale-detection branch nobody can test.\n */\nexport const FIELD_LABELS: Record<string, string> = {\n  honorificPrefix: \"Title\",\n  given: \"Given name\",\n  additional: \"Middle name\",\n  surname: \"Family name\",\n  phoneticSurname: \"Family name (phonetic)\",\n  phoneticGiven: \"Given name (phonetic)\",\n  fullName: \"Full name\",\n  singleName: \"I have a single name\",\n}\n\n/** One rendered field: what it is, what it says, whether it may be empty, what fills it. */\nexport type NameFieldSpec = {\n  field: NameField\n  label: string\n  required: boolean\n  /** The autofill token, or `\"off\"` for the phonetic fields, which have none. */\n  autoComplete: string\n}\n\n/**\n * Which fields may not be left empty, by default.\n *\n * Only the given name in split mode, and only the full name in single-field mode — both named\n * here rather than inferred, so the list is one prop a caller can read and replace. The family\n * name is **not** in it on purpose: see the W3C finding in the component's note above. Requiring it\n * does not produce family names, it produces `.` and `Mr.`\n */\nexport const DEFAULT_REQUIRED: readonly NameField[] = [\"given\", \"fullName\"]\n\nexport type NameFieldsOptions = {\n  /** The reader's locale, which decides the order. Left out, `HYDRATION_LOCALE`. */\n  locale?: string\n  /** Pins the order, ignoring `locale`. For a form that already knows its audience. */\n  order?: NameOrder\n  /** Render a title field (`honorific-prefix`). Off by default. */\n  honorific?: boolean\n  /** Render a middle-name field (`additional-name`). Off by default. */\n  additional?: boolean\n  /** Render the phonetic reading fields. Off by default; see the note on tokens above. */\n  phonetic?: boolean\n  /** The reader said they have one name, so one field replaces the split ones. */\n  singleName?: boolean\n  /** Which fields may not be empty. Defaults to `DEFAULT_REQUIRED`. */\n  required?: readonly NameField[]\n  /** Overrides for `FIELD_LABELS`, by field name. */\n  labels?: Partial<Record<string, string>>\n  /** An autofill section prefix: `\"shipping\"`, `\"billing\"`, `\"section-<name>\"`. */\n  autoCompleteSection?: string\n}\n\n/** The autofill token each field takes, with the phonetic pair opted out rather than guessed. */\nconst AUTOCOMPLETE: Record<NameField, string> = {\n  honorificPrefix: \"honorific-prefix\",\n  given: \"given-name\",\n  additional: \"additional-name\",\n  surname: \"family-name\",\n  // No token exists, and the nearest one fills the written name into the reading field.\n  phoneticSurname: \"off\",\n  phoneticGiven: \"off\",\n  fullName: \"name\",\n}\n\n/** The order the fields are resolved in, with an explicit `order` beating the locale. */\nexport function resolveOrder(options: NameFieldsOptions = {}): NameOrder {\n  return options.order ?? nameOrderFor(options.locale ?? HYDRATION_LOCALE)\n}\n\n/**\n * The fields to render, in the order this locale writes them.\n *\n * The middle name sits between the other two in both orders, which is CLDR's own shape: the\n * given-first pattern is `{given} {given2} {surname}` and the surname-first one is\n * `{surname} {given2} {given}`. The phonetic pair follows the written fields as its own row, in\n * the same order, which is how Japanese forms lay it out — 姓 名 above セイ メイ.\n */\nexport function fieldsFor(options: NameFieldsOptions = {}): NameFieldSpec[] {\n  const { honorific = false, additional = false, phonetic = false, singleName = false } = options\n  const required = options.required ?? DEFAULT_REQUIRED\n  const labels = options.labels\n  const section = options.autoCompleteSection?.trim()\n\n  const spec = (field: NameField): NameFieldSpec => {\n    const token = AUTOCOMPLETE[field]\n    return {\n      field,\n      label: labels?.[field] ?? FIELD_LABELS[field] ?? field,\n      required: required.includes(field),\n      // `off` is not an autofill field name and does not take a section prefix — \"shipping off\" is\n      // not a thing the spec defines, and a browser reading it as an unknown token would fall back\n      // to its own guess, which is the behaviour the `off` was there to stop.\n      autoComplete: section && token !== \"off\" ? `${section} ${token}` : token,\n    }\n  }\n\n  const order = resolveOrder(options)\n  const prefix: NameField[] = honorific ? [\"honorificPrefix\"] : []\n\n  if (singleName) return [...prefix, \"fullName\" as NameField].map(spec)\n\n  const middle: NameField[] = additional ? [\"additional\"] : []\n  const written: NameField[] =\n    order === \"surnameFirst\" ? [\"surname\", ...middle, \"given\"] : [\"given\", ...middle, \"surname\"]\n  const reading: NameField[] = !phonetic\n    ? []\n    : order === \"surnameFirst\"\n      ? [\"phoneticSurname\", \"phoneticGiven\"]\n      : [\"phoneticGiven\", \"phoneticSurname\"]\n\n  return [...prefix, ...written, ...reading].map(spec)\n}\n\n/** Every field, for the helpers that have to touch all of them. */\nconst NAME_FIELDS: NameField[] = [\n  \"honorificPrefix\",\n  \"given\",\n  \"additional\",\n  \"surname\",\n  \"phoneticSurname\",\n  \"phoneticGiven\",\n  \"fullName\",\n]\n\n/** A blank name, ready to put in state. */\nexport function emptyName(): NameValue {\n  return {\n    honorificPrefix: \"\",\n    given: \"\",\n    additional: \"\",\n    surname: \"\",\n    phoneticSurname: \"\",\n    phoneticGiven: \"\",\n    fullName: \"\",\n    singleName: false,\n  }\n}\n\n/** Whether two names agree on every field, so a controlled re-render is not a change. */\nfunction sameName(a: NameValue, b: NameValue): boolean {\n  if (a.singleName !== b.singleName) return false\n  return NAME_FIELDS.every((field) => (a[field] ?? \"\") === (b[field] ?? \"\"))\n}\n\n/** Fills in whatever a caller left out, so the internal value always has every field. */\nfunction completeName(partial: Partial<NameValue> | undefined): NameValue {\n  return { ...emptyName(), ...partial } as NameValue\n}\n\nexport type NameMessages = {\n  required?: (label: string) => string\n}\n\nconst DEFAULT_MESSAGES: Required<NameMessages> = {\n  required: (label) => `${label} is required`,\n}\n\n/**\n * The problems with a name, by field, empty when there are none.\n *\n * Emptiness of the required fields, and nothing else — no character class, no minimum length, no\n * \"looks like a placeholder\" heuristic. That is not an omission to fill in later: every such rule\n * rejects a real name somewhere, and the reader whose name it rejects is the one who most needs the\n * form to work. Only the fields the current options actually render are checked, so a phonetic\n * field left over from a form that no longer asks for one is not an error.\n *\n * Exported so a submit handler runs exactly what the fields showed on blur rather than a second\n * opinion.\n */\nexport function validateName(\n  value: Partial<NameValue>,\n  options: NameFieldsOptions & { messages?: NameMessages } = {}\n): Partial<Record<NameField, string>> {\n  const name = completeName(value)\n  const messages = { ...DEFAULT_MESSAGES, ...options.messages }\n  const errors: Partial<Record<NameField, string>> = {}\n  for (const spec of fieldsFor({ ...options, singleName: options.singleName ?? name.singleName })) {\n    if (!spec.required) continue\n    if ((name[spec.field] ?? \"\").trim() === \"\") errors[spec.field] = messages.required(spec.label)\n  }\n  return errors\n}\n\n/**\n * The name as one string, assembled in the locale's order.\n *\n * For a confirmation screen, an email, a label — the places a split name has to go back together.\n * Trimming happens here and not in the stored value, which is the difference between presenting a\n * name tidily and editing what someone typed.\n */\nexport function formatName(value: Partial<NameValue>, options: NameFieldsOptions = {}): string {\n  const name = completeName(value)\n  const parts = name.singleName\n    ? [name.fullName]\n    : resolveOrder(options) === \"surnameFirst\"\n      ? [name.surname, name.additional, name.given]\n      : [name.given, name.additional, name.surname]\n  return [name.honorificPrefix, ...parts]\n    .map((part) => part.trim())\n    .filter(Boolean)\n    .join(\" \")\n}\n\n/** The runtime's own locale, or `null` where there is no `Intl` to ask. */\nfunction runtimeLocale(): string | null {\n  try {\n    return new Intl.DateTimeFormat().resolvedOptions().locale || null\n  } catch {\n    return null\n  }\n}\n\nexport interface NameInputProps {\n  /** The name, when the parent owns it. Every field should be present; missing ones read empty. */\n  value?: NameValue\n  defaultValue?: Partial<NameValue>\n  onChange?: (value: NameValue) => void\n  /** The reader's locale, which decides the order. Left out, the runtime's, resolved after mount. */\n  locale?: string\n  /** Pins the order, ignoring `locale`. */\n  order?: NameOrder\n  /** Render a title field. Off by default. */\n  honorific?: boolean\n  /** Render a middle-name field. Off by default. */\n  additional?: boolean\n  /** Render the phonetic reading fields (セイ／メイ). Off by default. */\n  phonetic?: boolean\n  /** Offer \"I have a single name\", which replaces the split fields with one. On by default. */\n  allowSingleName?: boolean\n  /** Which fields may not be empty. Defaults to `DEFAULT_REQUIRED` — the family name is not in it. */\n  required?: readonly NameField[]\n  /** Overrides for `FIELD_LABELS`, by field name. */\n  labels?: Partial<Record<string, string>>\n  messages?: NameMessages\n  /** An autofill section prefix: `\"shipping\"`, `\"billing\"`, `\"section-<name>\"`. */\n  autoCompleteSection?: string\n  /** Show every error at once, not only for fields that have been visited. For submit. */\n  showErrors?: boolean\n  /** An accessible name for the group of fields. Defaults to \"Name\". */\n  legend?: string\n  disabled?: boolean\n  /** Prefix for each input's `name`, so the name posts with a plain form. */\n  namePrefix?: string\n  id?: string\n  className?: string\n}\n\n/**\n * Renders the reader's name in their locale's own fields and order.\n *\n * The fields are a `role=\"group\"` rather than a `<fieldset>` so the component drops into a form\n * that already has one without nesting legends, and the group carries the accessible name either\n * way. Nothing here is a combobox: a name is free text, and the browser can only autofill a real\n * `<input>`.\n */\nexport const NameInput = React.forwardRef<HTMLDivElement, NameInputProps>(function NameInput(\n  {\n    value,\n    defaultValue,\n    onChange,\n    locale,\n    order,\n    honorific = false,\n    additional = false,\n    phonetic = false,\n    allowSingleName = true,\n    required,\n    labels,\n    messages,\n    autoCompleteSection,\n    showErrors = false,\n    legend,\n    disabled = false,\n    namePrefix,\n    id,\n    className,\n  },\n  forwardedRef\n) {\n  const isControlled = value !== undefined\n  const [fields, setFields] = React.useState<NameValue>(() =>\n    completeName(isControlled ? value : defaultValue)\n  )\n  const [touched, setTouched] = React.useState<Partial<Record<NameField, boolean>>>({})\n\n  const fieldsRef = React.useRef(fields)\n  fieldsRef.current = fields\n\n  // Re-seed from the prop only when it disagrees with what is on screen. A parent that rebuilds the\n  // object on every render still passes an equal name, and echoing that back would reset the field\n  // being typed in; comparing by field rather than by identity is what makes a controlled name\n  // typable at all. This registry has shipped that bug once, in date-input.\n  React.useEffect(() => {\n    if (value === undefined) return\n    const next = completeName(value)\n    if (!sameName(next, fieldsRef.current)) setFields(next)\n  }, [value])\n\n  const [mounted, setMounted] = React.useState(false)\n  React.useEffect(() => {\n    setMounted(true)\n  }, [])\n\n  // The order is resolved after mount unless the caller pinned it, because the server's locale is\n  // the server's: `Intl` on the server and `Intl` in the browser disagree, and an order that\n  // disagrees across hydration is not a cosmetic mismatch — React would keep the server's field\n  // sequence while the labels came from the client's, which is how a form ends up asking for the\n  // family name in the box that posts the given one. Until then the order is HYDRATION_LOCALE's,\n  // which is CLDR's own root default.\n  const activeLocale = locale ?? (mounted ? (runtimeLocale() ?? HYDRATION_LOCALE) : HYDRATION_LOCALE)\n\n  const reactId = React.useId()\n  const base = id ?? reactId\n  const fieldId = (field: string) => `${base}-${field}`\n  const errorId = (field: string) => `${base}-${field}-error`\n  const legendId = `${base}-legend`\n  const singleNameId = `${base}-single-name`\n\n  const options = React.useMemo<NameFieldsOptions>(\n    () => ({\n      locale: activeLocale,\n      order,\n      honorific,\n      additional,\n      phonetic,\n      singleName: fields.singleName,\n      required,\n      labels,\n      autoCompleteSection,\n    }),\n    [\n      activeLocale,\n      order,\n      honorific,\n      additional,\n      phonetic,\n      fields.singleName,\n      required,\n      labels,\n      autoCompleteSection,\n    ]\n  )\n\n  const specs = React.useMemo(() => fieldsFor(options), [options])\n  const errors = React.useMemo(\n    () => validateName(fields, { ...options, messages }),\n    [fields, options, messages]\n  )\n\n  // One commit path, and it always writes the local state — the value carries every field, so a\n  // half-filled name round-trips through a controlled parent without losing anything.\n  function commit(next: NameValue) {\n    setFields(next)\n    onChange?.(next)\n  }\n\n  function setField(field: NameField, next: string) {\n    commit({ ...fields, [field]: next })\n  }\n\n  /**\n   * Switching to one field carries the split fields into it, and switching back leaves them.\n   *\n   * Nothing is cleared either way. Someone who typed their name into two boxes, found the\n   * checkbox, and ticked it should not have to type it again — and someone who ticks it by mistake\n   * should get their two boxes back as they left them. The carry only fills an empty full-name\n   * field, so it cannot overwrite a name the reader has already corrected here.\n   */\n  function toggleSingleName(singleName: boolean) {\n    const next: NameValue = { ...fields, singleName }\n    if (singleName && next.fullName.trim() === \"\") {\n      const assembled = formatName({ ...fields, singleName: false }, { ...options, honorific: false })\n      if (assembled !== \"\") next.fullName = assembled\n    }\n    setTouched({})\n    commit(next)\n  }\n\n  return (\n    <div\n      ref={forwardedRef}\n      role=\"group\"\n      aria-labelledby={legend ? legendId : undefined}\n      aria-label={legend ? undefined : \"Name\"}\n      className={cn(\"flex flex-col gap-4\", className)}\n    >\n      {legend ? (\n        <span id={legendId} className=\"text-sm font-medium\">\n          {legend}\n        </span>\n      ) : null}\n\n      {specs.map((spec) => {\n        const message = errors[spec.field]\n        const show = Boolean(message) && (showErrors || touched[spec.field] === true)\n        return (\n          <div key={spec.field} className=\"flex flex-col gap-1.5\">\n            <label htmlFor={fieldId(spec.field)} className=\"text-sm font-medium\">\n              {spec.label}\n              {spec.required ? null : (\n                <span className=\"ml-1 font-normal text-muted-foreground\">(optional)</span>\n              )}\n            </label>\n            <input\n              id={fieldId(spec.field)}\n              name={namePrefix ? `${namePrefix}.${spec.field}` : undefined}\n              type=\"text\"\n              value={fields[spec.field] ?? \"\"}\n              disabled={disabled}\n              autoComplete={spec.autoComplete}\n              // Names are not words a dictionary has, and a red underline under every surname\n              // teaches the reader that their own name is a mistake.\n              spellCheck={false}\n              aria-required={spec.required}\n              aria-invalid={show ? true : undefined}\n              aria-describedby={show ? errorId(spec.field) : undefined}\n              onChange={(event) => setField(spec.field, event.target.value)}\n              onBlur={() => setTouched((t) => ({ ...t, [spec.field]: true }))}\n              className={cn(\n                \"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors\",\n                \"placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring\",\n                \"disabled:cursor-not-allowed disabled:opacity-50\",\n                show && \"border-destructive focus-visible:ring-destructive\"\n              )}\n            />\n            {show ? (\n              <p id={errorId(spec.field)} role=\"alert\" className=\"text-sm text-destructive\">\n                {message}\n              </p>\n            ) : null}\n          </div>\n        )\n      })}\n\n      {allowSingleName ? (\n        <div className=\"flex items-center gap-2\">\n          <input\n            id={singleNameId}\n            name={namePrefix ? `${namePrefix}.singleName` : undefined}\n            type=\"checkbox\"\n            checked={fields.singleName}\n            disabled={disabled}\n            onChange={(event) => toggleSingleName(event.target.checked)}\n            className={cn(\n              // The same checkbox column-visibility renders, so the two match wherever both appear.\n              \"size-4 shrink-0 cursor-pointer rounded border-input accent-primary\",\n              \"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n              \"disabled:cursor-not-allowed disabled:opacity-50\"\n            )}\n          />\n          <label htmlFor={singleNameId} className=\"text-sm text-muted-foreground\">\n            {labels?.singleName ?? FIELD_LABELS.singleName}\n          </label>\n        </div>\n      ) : null}\n    </div>\n  )\n})\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui",
  "docs": "Install any pulld component by name: add \"@pulld\": \"https://pulld.pages.dev/r/{name}.json\" to the registries block in components.json, then `npx shadcn add @pulld/<name>`. All 149 components: https://pulld.pages.dev/?utm_source=cli"
}
