{"$schema":"https:\/\/ui.particle.academy\/schema\/registry-item.json","name":"textarea","type":"registry:ui","title":"Textarea","description":"Multi-line input with validation, controlled values and optional auto-resize.","package":"react-fancy","dependencies":["tailwind-merge"],"registryDependencies":["field"],"files":[{"path":"components\/fancy\/textarea\/Textarea.tsx","content":"import { forwardRef, useEffect, useId, useRef } from \"react\";\nimport { cn } from \"..\/lib\/utils\/cn\";\nimport { Field } from \"..\/field\";\nimport { InputWrapper } from \"..\/lib\/components\/inputs\/InputWrapper\";\nimport {\n  dirtyClasses,\n  errorClasses,\n  fieldAria,\n  inputBaseClasses,\n  inputSizeClasses,\n} from \"..\/lib\/components\/inputs\/inputs.utils\";\nimport { useFieldMode } from \"..\/lib\/components\/inputs\/mode\/FieldMode.context\";\nimport { DisplayValue } from \"..\/lib\/components\/inputs\/mode\/DisplayValue\";\nimport { useInlineEdit } from \"..\/lib\/components\/inputs\/mode\/useInlineEdit\";\nimport type { TextareaProps } from \".\/Textarea.types\";\n\nexport const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(\n  (\n    {\n      size = \"md\",\n      dirty,\n      error,\n      label,\n      labelHidden,\n      description,\n      required,\n      disabled,\n      className,\n      id,\n      autoResize,\n      minRows = 3,\n      maxRows,\n      prefix,\n      suffix,\n      prefixPosition: _prefixPosition,\n      suffixPosition: _suffixPosition,\n      mode,\n      onValueChange,\n      onChange,\n      value,\n      defaultValue,\n      ...props\n    },\n    ref,\n  ) => {\n    const autoId = useId();\n    const textareaId = id ?? autoId;\n    const internalRef = useRef<HTMLTextAreaElement | null>(null);\n    const resolvedMode = useFieldMode(mode);\n    const { showControl, interactive, enterEdit, exitEdit } = useInlineEdit(resolvedMode, disabled);\n    const { errorId, descriptionId, aria } = fieldAria(textareaId, {\n      error,\n      description,\n      describedBy: props[\"aria-describedby\"],\n      invalid: props[\"aria-invalid\"],\n    });\n\n    useEffect(() => {\n      const el = internalRef.current;\n      if (!autoResize || !el) return;\n      el.style.height = \"auto\";\n      const lineHeight = parseInt(getComputedStyle(el).lineHeight) || 20;\n      const minHeight = minRows * lineHeight;\n      const maxHeight = maxRows ? maxRows * lineHeight : Infinity;\n      el.style.height = `${Math.min(Math.max(el.scrollHeight, minHeight), maxHeight)}px`;\n    }, [autoResize, minRows, maxRows, value, defaultValue]);\n\n    const textarea = !showControl ? (\n      <DisplayValue\n        size={size}\n        className=\"whitespace-pre-wrap\"\n        interactive={interactive}\n        onActivate={enterEdit}\n      >\n        {(value ?? defaultValue) as string | undefined}\n      <\/DisplayValue>\n    ) : (\n      <InputWrapper\n        prefix={prefix}\n        suffix={suffix}\n        prefixPosition=\"outside\"\n        suffixPosition=\"outside\"\n        size={size}\n      >\n        <textarea\n          data-react-fancy-textarea=\"\"\n          ref={(node) => {\n            internalRef.current = node;\n            if (typeof ref === \"function\") {\n              ref(node);\n            } else if (ref) {\n              ref.current = node;\n            }\n          }}\n          id={textareaId}\n          disabled={disabled}\n          required={required}\n          rows={autoResize ? minRows : minRows}\n          value={value}\n          defaultValue={defaultValue}\n          className={cn(\n            inputBaseClasses,\n            inputSizeClasses[size],\n            dirtyClasses(dirty),\n            errorClasses(error),\n            \"w-full resize-y\",\n            autoResize && \"resize-none overflow-hidden\",\n            className,\n          )}\n          onChange={(e) => {\n            onChange?.(e);\n            onValueChange?.(e.target.value);\n          }}\n          {...props}\n          {...aria}\n          autoFocus={interactive || props.autoFocus}\n          onBlur={(e) => {\n            props.onBlur?.(e);\n            if (interactive) exitEdit();\n          }}\n        \/>\n      <\/InputWrapper>\n    );\n\n    if (label || error || description) {\n      return (\n        <Field\n          label={label}\n          labelHidden={labelHidden}\n          description={description}\n          descriptionId={descriptionId}\n          error={error}\n          errorId={errorId}\n          required={required}\n          htmlFor={textareaId}\n          size={size}\n        >\n          {textarea}\n        <\/Field>\n      );\n    }\n\n    return textarea;\n  },\n);\n\nTextarea.displayName = \"Textarea\";\n","type":"registry:ui","target":"components\/fancy\/textarea\/Textarea.tsx"},{"path":"components\/fancy\/textarea\/Textarea.types.ts","content":"import type { TextareaHTMLAttributes } from \"react\";\nimport type { InputBaseProps, InputAffixProps } from \"..\/lib\/components\/inputs\/inputs.types\";\n\nexport interface TextareaProps\n  extends InputBaseProps,\n    InputAffixProps,\n    Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, \"size\" | \"prefix\"> {\n  autoResize?: boolean;\n  minRows?: number;\n  maxRows?: number;\n  onValueChange?: (value: string) => void;\n}\n","type":"registry:ui","target":"components\/fancy\/textarea\/Textarea.types.ts"},{"path":"components\/fancy\/textarea\/index.ts","content":"export { Textarea } from \".\/Textarea\";\nexport type { TextareaProps } from \".\/Textarea.types\";\n","type":"registry:ui","target":"components\/fancy\/textarea\/index.ts"},{"path":"components\/fancy\/lib\/utils\/cn.ts","content":"import { twMerge } from \"tailwind-merge\";\n\n\/**\n * A class value: a string, a number, a conditional map, an array of any of\n * those, or nothing. Mirrors what `clsx` accepted, because every component in\n * this package already passes these shapes.\n *\/\nexport type ClassValue =\n  | string\n  | number\n  | bigint\n  | null\n  | undefined\n  | false\n  | ClassDictionary\n  | ClassValue[];\n\ntype ClassDictionary = Record<string, unknown>;\n\n\/**\n * Flatten class values into a space-separated string.\n *\n * This was `clsx` until 2026-08-19. It is roughly twenty lines of logic, it\n * shipped as a RUNTIME dependency to every consumer of this package, and its\n * last commit was 801 days old \u2014 so it fell to the rule that third-party code\n * must be both approved and actively maintained. Owning it costs less than\n * carrying it.\n *\n * `tailwind-merge` deliberately stays: deciding which of two conflicting\n * Tailwind utilities wins requires modelling the entire utility space, which is\n * emphatically not twenty lines, and it is actively maintained.\n *\n * Falsy values are dropped \u2014 including `0` and `\"\"`, which is what `clsx` did\n * and what `tests\/cn.test.ts` pins. A truthy number is kept, because digits are\n * legal class names. `bigint` is admitted because clsx's signature did and\n * the compiler proved it reachable from two call sites here.\n *\/\nfunction flatten(value: ClassValue): string {\n  if (!value) return \"\";\n\n  if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"bigint\") {\n    return String(value);\n  }\n\n  if (Array.isArray(value)) {\n    let out = \"\";\n    for (const item of value) {\n      const part = flatten(item);\n      if (part) out = out ? `${out} ${part}` : part;\n    }\n    return out;\n  }\n\n  let out = \"\";\n  for (const key in value) {\n    if (value[key]) out = out ? `${out} ${key}` : key;\n  }\n  return out;\n}\n\nexport function cn(...inputs: ClassValue[]): string {\n  return twMerge(flatten(inputs));\n}\n","type":"registry:lib","target":"components\/fancy\/lib\/utils\/cn.ts"},{"path":"components\/fancy\/lib\/components\/inputs\/InputWrapper.tsx","content":"import type { ReactNode } from \"react\";\nimport { cn } from \"..\/..\/utils\/cn\";\nimport type { AffixPosition } from \".\/inputs.types\";\nimport type { Size } from \"..\/..\/utils\/types\";\n\ninterface InputWrapperProps {\n  children: ReactNode;\n  prefix?: ReactNode;\n  suffix?: ReactNode;\n  prefixPosition?: AffixPosition;\n  suffixPosition?: AffixPosition;\n  size?: Size;\n  \/** Extra padding className to apply to the input when affixes are \"inside\" *\/\n  insidePrefixPadding?: string;\n  insideSuffixPadding?: string;\n}\n\n\/\/ NOTE: these must be COMPLETE, static class strings. Tailwind only detects\n\/\/ utilities it can see verbatim in the source \u2014 building the arbitrary variant\n\/\/ at runtime (e.g. `[&_input]:${\"pl-9\"}`) means `[&_input]:ps-9` is never\n\/\/ emitted to CSS, so the inside affix gets no padding and overlaps the text\n\/\/ (issue #6). Keep input\/select\/textarea spelled out here.\nconst insidePaddingLeft: Record<Size, string> = {\n  xs: \"[&_input]:ps-7 [&_select]:ps-7 [&_textarea]:ps-7\",\n  sm: \"[&_input]:ps-8 [&_select]:ps-8 [&_textarea]:ps-8\",\n  md: \"[&_input]:ps-9 [&_select]:ps-9 [&_textarea]:ps-9\",\n  lg: \"[&_input]:ps-10 [&_select]:ps-10 [&_textarea]:ps-10\",\n  xl: \"[&_input]:ps-11 [&_select]:ps-11 [&_textarea]:ps-11\",\n};\n\nconst insidePaddingRight: Record<Size, string> = {\n  xs: \"[&_input]:pe-7 [&_select]:pe-7 [&_textarea]:pe-7\",\n  sm: \"[&_input]:pe-8 [&_select]:pe-8 [&_textarea]:pe-8\",\n  md: \"[&_input]:pe-9 [&_select]:pe-9 [&_textarea]:pe-9\",\n  lg: \"[&_input]:pe-10 [&_select]:pe-10 [&_textarea]:pe-10\",\n  xl: \"[&_input]:pe-11 [&_select]:pe-11 [&_textarea]:pe-11\",\n};\n\nconst affixOutsideClasses =\n  \"inline-flex items-center border border-[color:var(--fancy-border-strong,var(--color-zinc-500))] bg-zinc-50 px-3 text-sm text-[color:var(--fancy-text-muted,var(--color-zinc-500))] dark:border-[color:var(--fancy-border-strong-dark,var(--color-zinc-500))] dark:bg-zinc-800 dark:text-[color:var(--fancy-text-muted-dark,var(--color-zinc-400))]\";\n\nexport function InputWrapper({\n  children,\n  prefix,\n  suffix,\n  prefixPosition = \"inside\",\n  suffixPosition = \"inside\",\n  size = \"md\",\n}: InputWrapperProps) {\n  const hasInsidePrefix = prefix && prefixPosition === \"inside\";\n  const hasInsideSuffix = suffix && suffixPosition === \"inside\";\n  const hasOutsidePrefix = prefix && prefixPosition === \"outside\";\n  const hasOutsideSuffix = suffix && suffixPosition === \"outside\";\n  const hasOutside = hasOutsidePrefix || hasOutsideSuffix;\n\n  if (!prefix && !suffix) {\n    return <>{children}<\/>;\n  }\n\n  if (hasOutside) {\n    return (\n      <div data-react-fancy-input-wrapper=\"\" className=\"flex\">\n        {hasOutsidePrefix && (\n          <span className={cn(affixOutsideClasses, \"rounded-s-lg border-e-0\")}>\n            {prefix}\n          <\/span>\n        )}\n        <div\n          className={cn(\n            \"relative flex flex-1 items-center\",\n            hasInsidePrefix && \"relative\",\n          )}\n        >\n          {hasInsidePrefix && (\n            <span className=\"pointer-events-none absolute start-3 z-10 text-[color:var(--fancy-text-muted,var(--color-zinc-500))] dark:text-[color:var(--fancy-text-muted-dark,var(--color-zinc-400))]\">\n              {prefix}\n            <\/span>\n          )}\n          <div\n            className={cn(\n              \"w-full [&>*]:w-full\",\n              hasOutsidePrefix && !hasOutsideSuffix && \"[&_input]:rounded-s-none [&_select]:rounded-s-none [&_textarea]:rounded-s-none\",\n              !hasOutsidePrefix && hasOutsideSuffix && \"[&_input]:rounded-e-none [&_select]:rounded-e-none [&_textarea]:rounded-e-none\",\n              hasOutsidePrefix && hasOutsideSuffix && \"[&_input]:rounded-none [&_select]:rounded-none [&_textarea]:rounded-none\",\n              hasInsidePrefix && insidePaddingLeft[size],\n            )}\n          >\n            {children}\n          <\/div>\n          {hasInsideSuffix && (\n            <span className=\"pointer-events-none absolute end-3 z-10 text-[color:var(--fancy-text-muted,var(--color-zinc-500))] dark:text-[color:var(--fancy-text-muted-dark,var(--color-zinc-400))]\">\n              {suffix}\n            <\/span>\n          )}\n        <\/div>\n        {hasOutsideSuffix && (\n          <span className={cn(affixOutsideClasses, \"rounded-e-lg border-s-0\")}>\n            {suffix}\n          <\/span>\n        )}\n      <\/div>\n    );\n  }\n\n  \/\/ Both inside\n  return (\n    <div data-react-fancy-input-wrapper=\"\" className=\"relative flex items-center\">\n      {hasInsidePrefix && (\n        <span className=\"pointer-events-none absolute start-3 z-10 text-[color:var(--fancy-text-muted,var(--color-zinc-500))] dark:text-[color:var(--fancy-text-muted-dark,var(--color-zinc-400))]\">\n          {prefix}\n        <\/span>\n      )}\n      <div\n        className={cn(\n          \"w-full\",\n          hasInsidePrefix && insidePaddingLeft[size],\n          hasInsideSuffix && insidePaddingRight[size],\n        )}\n      >\n        {children}\n      <\/div>\n      {hasInsideSuffix && (\n        <span className=\"pointer-events-none absolute end-3 z-10 text-[color:var(--fancy-text-muted,var(--color-zinc-500))] dark:text-[color:var(--fancy-text-muted-dark,var(--color-zinc-400))]\">\n          {suffix}\n        <\/span>\n      )}\n    <\/div>\n  );\n}\n","type":"registry:lib","target":"components\/fancy\/lib\/components\/inputs\/InputWrapper.tsx"},{"path":"components\/fancy\/lib\/components\/inputs\/inputs.utils.ts","content":"import { createElement, Fragment, type AriaAttributes, type ReactNode } from \"react\";\nimport type { Size } from \"..\/..\/utils\/types\";\nimport type { InputOption, OptionDir } from \".\/inputs.types\";\n\nexport const inputSizeClasses: Record<Size, string> = {\n  xs: \"px-2 py-1 text-xs rounded\",\n  sm: \"px-2.5 py-1.5 text-sm rounded-md\",\n  md: \"px-3 py-2 text-sm rounded-lg\",\n  lg: \"px-4 py-2.5 text-base rounded-lg\",\n  xl: \"px-5 py-3 text-lg rounded-xl\",\n};\n\nexport const labelSizeClasses: Record<Size, string> = {\n  xs: \"text-xs\",\n  sm: \"text-xs\",\n  md: \"text-sm\",\n  lg: \"text-sm\",\n  xl: \"text-base\",\n};\n\nexport function dirtyClasses(dirty?: boolean): string {\n  return dirty ? \"border-s-[3px] border-s-amber-400\" : \"\";\n}\n\nexport function dirtyRingClasses(dirty?: boolean): string {\n  return dirty ? \"ring-2 ring-amber-400\/50\" : \"\";\n}\n\n\/**\n * Validation text: the error message and the required asterisk of Field,\n * Checkbox and Switch. Reads the `error` theme token (CC-fancy-0018, 6.19.0);\n * its defaults clear WCAG 1.4.3's 4.5:1 for small text. red-600 is 4.77:1 on\n * white; red-400 is 5.74:1 on #1e1e24, 6.13:1 on zinc-900, 5.16:1 on zinc-800.\n * The old `text-red-500` was 3.81:1 on white and 3.91:1 on zinc-800.\n *\/\nexport const ERROR_TEXT =\n  \"text-[color:var(--fancy-error,var(--color-red-600))] dark:text-[color:var(--fancy-error-dark,var(--color-red-400))]\";\n\nexport function errorClasses(error?: string): string {\n  return error ? \"border-red-500 focus:ring-red-500\" : \"\";\n}\n\n\/**\n * What a control needs to expose its error and description to assistive\n * technology (6.20.0, K1 of the full-kit benchmark). Every form control had\n * rendered its `error` as a plain paragraph: no `aria-invalid`, no\n * `aria-describedby`, nothing announced.\n *\n * `errorId` \/ `descriptionId` go to `Field` (which renders the message with\n * those ids, the error as `role=\"alert\"`); `aria` goes on the control. The\n * description is only rendered while there is no error, so the control is\n * described by whichever of the two is on screen, after any id the host passed.\n *\/\nexport function fieldAria(\n  id: string,\n  {\n    error,\n    description,\n    describedBy,\n    invalid,\n  }: {\n    error?: unknown;\n    description?: unknown;\n    \/** The host's own `aria-describedby`, kept ahead of the message id. *\/\n    describedBy?: string;\n    \/** The host's own `aria-invalid` (NumberField, PhoneInput), kept when there is no `error`. *\/\n    invalid?: unknown;\n  },\n): {\n  errorId: string;\n  descriptionId: string;\n  aria: { \"aria-invalid\": AriaAttributes[\"aria-invalid\"]; \"aria-describedby\": string | undefined };\n} {\n  const errorId = `${id}-error`;\n  const descriptionId = `${id}-description`;\n  const own = error ? errorId : description ? descriptionId : undefined;\n  const ids = [describedBy, own].filter(Boolean).join(\" \");\n  return {\n    errorId,\n    descriptionId,\n    aria: {\n      \"aria-invalid\": error ? true : (invalid as AriaAttributes[\"aria-invalid\"]),\n      \"aria-describedby\": ids || undefined,\n    },\n  };\n}\n\nexport const inputBaseClasses =\n  \"border border-[color:var(--fancy-border-strong,var(--color-zinc-500))] bg-[color:var(--fancy-input,var(--color-white))] text-[color:var(--fancy-text,var(--color-zinc-900))] placeholder:text-[color:var(--fancy-text-muted,var(--color-zinc-500))] transition-[border-color,box-shadow] duration-150 focus:outline-none focus:ring-2 focus:ring-[color:var(--fancy-focus,var(--color-blue-500))]\/40 focus:border-[color:var(--fancy-focus,var(--color-blue-500))] disabled:opacity-50 disabled:cursor-not-allowed dark:border-[color:var(--fancy-border-strong-dark,var(--color-zinc-500))] dark:bg-[color:var(--fancy-input-dark,#1e1e24)] dark:text-[color:var(--fancy-text-dark,var(--color-zinc-100))] dark:placeholder:text-[color:var(--fancy-text-muted-dark,var(--color-zinc-400))] dark:focus:border-[color:var(--fancy-focus-dark,var(--color-blue-400))] dark:focus:ring-[color:var(--fancy-focus-dark,var(--color-blue-400))]\/20\";\n\nexport function resolveOption<V = string>(\n  option: InputOption<V>,\n): Exclude<InputOption<V>, string> {\n  if (typeof option === \"string\") {\n    return { value: option as unknown as V, label: option };\n  }\n  return option;\n}\n\n\/**\n * The `lang` \/ `dir` attributes for the element holding an option's label.\n * Only the keys that are set, so an option without them renders exactly as it\n * did before 6.13.0.\n *\/\nexport function optionLangProps(option: { lang?: string; dir?: OptionDir } | null | undefined): {\n  lang?: string;\n  dir?: OptionDir;\n} {\n  const out: { lang?: string; dir?: OptionDir } = {};\n  if (option?.lang) out.lang = option.lang;\n  if (option?.dir) out.dir = option.dir;\n  return out;\n}\n\n\/**\n * An option's label as a view-mode value: wrapped in a span carrying its\n * `lang` \/ `dir` when it has them, the bare string otherwise.\n *\/\nexport function optionLabelNode(\n  option: { label: string; lang?: string; dir?: OptionDir } | null | undefined,\n  fallback?: ReactNode,\n): ReactNode {\n  if (!option) return fallback;\n  const attrs = optionLangProps(option);\n  return attrs.lang || attrs.dir ? createElement(\"span\", attrs, option.label) : option.label;\n}\n\n\/**\n * Several labels joined with \", \". Stays one plain string unless an option\n * carries `lang` \/ `dir`, so existing output does not change.\n *\/\nexport function optionLabelList(\n  options: Array<{ label: string; lang?: string; dir?: OptionDir } | string>,\n): ReactNode {\n  const tagged = options.some((o) => typeof o !== \"string\" && (o.lang || o.dir));\n  if (!tagged) return options.map((o) => (typeof o === \"string\" ? o : o.label)).join(\", \");\n  return options.map((o, i) =>\n    createElement(Fragment, { key: i }, i > 0 ? \", \" : null, typeof o === \"string\" ? o : optionLabelNode(o)),\n  );\n}\n","type":"registry:lib","target":"components\/fancy\/lib\/components\/inputs\/inputs.utils.ts"},{"path":"components\/fancy\/lib\/components\/inputs\/mode\/FieldMode.context.ts","content":"import { createContext, useContext } from \"react\";\nimport type { FieldMode } from \"..\/inputs.types\";\n\nexport interface FieldModeContextValue {\n  mode: FieldMode;\n}\n\nexport const FieldModeContext = createContext<FieldModeContextValue | null>(null);\n\n\/**\n * Resolve the effective mode for an input. Precedence: an explicit prop wins,\n * then the nearest `<Form>` \/ `<FormProvider>` context, then `\"edit\"`.\n *\n * Deliberately tolerant (returns `\"edit\"` outside any provider) \u2014 unlike a slot\n * guard \u2014 so every input works standalone with zero context and existing call\n * sites behave identically.\n *\/\nexport function useFieldMode(explicit?: FieldMode): FieldMode {\n  const ctx = useContext(FieldModeContext);\n  return explicit ?? ctx?.mode ?? \"edit\";\n}\n","type":"registry:lib","target":"components\/fancy\/lib\/components\/inputs\/mode\/FieldMode.context.ts"},{"path":"components\/fancy\/lib\/components\/inputs\/mode\/DisplayValue.tsx","content":"import type { KeyboardEvent, ReactNode } from \"react\";\nimport { cn } from \"..\/..\/..\/utils\/cn\";\nimport type { Size } from \"..\/..\/..\/utils\/types\";\nimport { inputSizeClasses } from \"..\/inputs.utils\";\n\nexport interface DisplayValueProps {\n  \/** The formatted value to show. Empty \/ null \/ undefined renders `empty`. *\/\n  children?: ReactNode;\n  size?: Size;\n  \/** Static adornment rendered before the value (mirrors an input's `leading`\/`prefix`). *\/\n  leading?: ReactNode;\n  \/** Static adornment rendered after the value (mirrors an input's `trailing`\/`suffix`). *\/\n  trailing?: ReactNode;\n  \/** Shown when the value is empty. Default `\u2014`. *\/\n  empty?: ReactNode;\n  \/** When true the value is clickable to enter edit mode (inline click-to-edit). *\/\n  interactive?: boolean;\n  \/** Called when an interactive value is activated (click \/ Enter \/ Space). *\/\n  onActivate?: () => void;\n  className?: string;\n}\n\nfunction isEmpty(value: ReactNode): boolean {\n  return value === null || value === undefined || value === \"\";\n}\n\n\/**\n * The read-only counterpart to an `<input>`. Renders a non-interactive value\n * with the same size rhythm as the editable control (reusing\n * {@link inputSizeClasses}) but without the border \/ background \/ focus ring.\n *\n * When `interactive` (inline click-to-edit), the value becomes a focusable,\n * hoverable target that calls `onActivate` on click \/ Enter \/ Space to swap in\n * the real control. Dropped into the SAME `Field` wrapper the editable control\n * uses, so label \/ description \/ error chrome stays byte-identical between the\n * display and the editor.\n *\n * Carries `data-react-fancy-display` \/ `data-mode=\"view\"` stable handles for\n * agents and tests (Human+ contract).\n *\/\nexport function DisplayValue({\n  children,\n  size = \"md\",\n  leading,\n  trailing,\n  empty = \"\u2014\",\n  interactive,\n  onActivate,\n  className,\n}: DisplayValueProps) {\n  const empties = isEmpty(children);\n\n  const onKeyDown = interactive\n    ? (e: KeyboardEvent<HTMLDivElement>) => {\n        if (e.key === \"Enter\" || e.key === \" \") {\n          e.preventDefault();\n          onActivate?.();\n        }\n      }\n    : undefined;\n\n  return (\n    <div\n      data-react-fancy-display=\"\"\n      data-mode=\"view\"\n      role={interactive ? \"button\" : undefined}\n      tabIndex={interactive ? 0 : undefined}\n      title={interactive ? \"Click to edit\" : undefined}\n      onClick={interactive ? onActivate : undefined}\n      onKeyDown={onKeyDown}\n      className={cn(\n        \"flex w-full items-center gap-2 text-[color:var(--fancy-text,var(--color-zinc-900))] dark:text-[color:var(--fancy-text-dark,var(--color-zinc-100))]\",\n        inputSizeClasses[size],\n        \/\/ Strip the editable box look \u2014 keep only the size\/padding rhythm.\n        \"border-0 bg-transparent px-0\",\n        interactive &&\n          \"-mx-2 cursor-text rounded-md px-2 outline-none transition-colors hover:bg-[color:var(--fancy-surface-muted,var(--color-zinc-100))] focus-visible:ring-2 focus-visible:ring-blue-500\/40 dark:hover:bg-[color:var(--fancy-surface-muted-dark,var(--color-zinc-800))]\",\n        empties && \"text-[color:var(--fancy-text-muted,var(--color-zinc-500))] dark:text-[color:var(--fancy-text-muted-dark,var(--color-zinc-400))]\",\n        className,\n      )}\n    >\n      {leading && <span className=\"text-[color:var(--fancy-text-muted,var(--color-zinc-500))] dark:text-[color:var(--fancy-text-muted-dark,var(--color-zinc-400))]\">{leading}<\/span>}\n      <span className=\"min-w-0 truncate\">{empties ? empty : children}<\/span>\n      {trailing && <span className=\"text-[color:var(--fancy-text-muted,var(--color-zinc-500))] dark:text-[color:var(--fancy-text-muted-dark,var(--color-zinc-400))]\">{trailing}<\/span>}\n    <\/div>\n  );\n}\n","type":"registry:lib","target":"components\/fancy\/lib\/components\/inputs\/mode\/DisplayValue.tsx"},{"path":"components\/fancy\/lib\/components\/inputs\/mode\/useInlineEdit.ts","content":"import { useCallback, useState } from \"react\";\nimport type { FieldMode } from \"..\/inputs.types\";\n\nexport interface InlineEdit {\n  \/** Render the editable control (`true`) vs. the read-only value display (`false`). *\/\n  showControl: boolean;\n  \/** Whether view mode is interactive (click-to-edit) \u2014 i.e. `view` and not disabled. *\/\n  interactive: boolean;\n  \/** Enter edit mode (no-op unless interactive). *\/\n  enterEdit: () => void;\n  \/** Leave edit mode, back to the value display. *\/\n  exitEdit: () => void;\n}\n\n\/**\n * Inline click-to-edit for `mode=\"view\"`. The bound value shows as clean static\n * text; clicking it swaps in the focused control; blur returns to the display\n * (the control's `onChange` \/ `onBlur` fire as usual, so a host can persist on\n * commit). `mode=\"edit\"` is always the control; a **disabled** view stays static\n * text (no click-to-edit).\n *\n * This is the value of \"view mode\": tidy read-only surfaces where each field\n * becomes editable only when the user reaches for it.\n *\/\nexport function useInlineEdit(mode: FieldMode, disabled?: boolean): InlineEdit {\n  const [editing, setEditing] = useState(false);\n  const interactive = mode === \"view\" && !disabled;\n  const showControl = mode !== \"view\" || (interactive && editing);\n  const enterEdit = useCallback(() => {\n    if (interactive) setEditing(true);\n  }, [interactive]);\n  const exitEdit = useCallback(() => setEditing(false), []);\n  return { showControl, interactive, enterEdit, exitEdit };\n}\n","type":"registry:lib","target":"components\/fancy\/lib\/components\/inputs\/mode\/useInlineEdit.ts"},{"path":"components\/fancy\/lib\/components\/inputs\/inputs.types.ts","content":"import type { ReactNode } from \"react\";\nimport type { Size } from \"..\/..\/utils\/types\";\n\n\/** Text direction of one option's label. *\/\nexport type OptionDir = \"ltr\" | \"rtl\" | \"auto\";\n\nexport type InputOption<V = string> =\n  | string\n  | {\n      value: V;\n      label: string;\n      disabled?: boolean;\n      description?: string;\n      \/**\n       * BCP 47 language of `label`, when it differs from the page's: a language\n       * switcher that names each language in itself (WCAG 3.1.2, language of\n       * parts). Rendered as `lang` on the element holding the label, including\n       * the selected-value display. Unset renders no attribute.\n       *\/\n      lang?: string;\n      \/**\n       * Direction of `label`: `\"rtl\"` for a right-to-left script inside a\n       * left-to-right control. `\"auto\"` is available; nothing is added when\n       * unset.\n       *\/\n      dir?: OptionDir;\n    };\n\nexport type InputOptionGroup<V = string> = {\n  label: string;\n  options: InputOption<V>[];\n};\n\n\/**\n * Edit vs. read-only display. In `\"view\"` mode an input renders the bound value\n * as static text instead of an interactive control \u2014 the React\/Inertia analog of\n * Livewire's public\/bindable properties. Declared here (rather than in `mode\/`)\n * to keep `InputBaseProps` free of an import cycle. Resolved per input via\n * {@link useFieldMode}: explicit prop \u2192 `<Form>`\/`<FormProvider>` context \u2192 `\"edit\"`.\n *\/\nexport type FieldMode = \"edit\" | \"view\";\n\nexport interface InputBaseProps {\n  size?: Size;\n  dirty?: boolean;\n  error?: string;\n  label?: string;\n  \/**\n   * Keep the label for assistive tech, but do not draw it.\n   *\n   * For a control whose options already say what it does \u2014 a filter toolbar's\n   * segmented switches, say \u2014 where a visible label is noise but an unnamed\n   * control is a bug. Without this the only choices were an unnamed control or\n   * a label the design does not have, and the silent one is the one that ships.\n   *\/\n  labelHidden?: boolean;\n  description?: string;\n  required?: boolean;\n  disabled?: boolean;\n  className?: string;\n  id?: string;\n  name?: string;\n  \/** `\"edit\"` (default) renders the control; `\"view\"` renders the value as text. Overrides the `<Form mode>` context. *\/\n  mode?: FieldMode;\n}\n\nexport type AffixPosition = \"inside\" | \"outside\";\n\nexport interface InputAffixProps {\n  prefix?: ReactNode;\n  suffix?: ReactNode;\n  prefixPosition?: AffixPosition;\n  suffixPosition?: AffixPosition;\n}\n","type":"registry:lib","target":"components\/fancy\/lib\/components\/inputs\/inputs.types.ts"},{"path":"components\/fancy\/lib\/utils\/types.ts","content":"import type { ElementType } from \"react\";\n\nexport type Size = \"xs\" | \"sm\" | \"md\" | \"lg\" | \"xl\";\n\n\/**\n * What a navigation primitive owes a router.\n *\n * Every nav surface here \u2014 `Navbar.Item`, `Sidebar.Item`, `Menu.Item`,\n * `MobileMenu.Item`, `Breadcrumbs.Item` \u2014 used to hardcode a plain `<a href>`.\n * That is a FULL PAGE LOAD in every client-routed app, and the only way around\n * it was to nest a router `<Link>` inside the item: an anchor inside an anchor,\n * which is invalid HTML and the same nested-anchor shape that already cost this\n * suite an SSR hydration bug.\n *\n * `as` is the seam {@link ButtonProps.as} already had. It is router-agnostic on\n * purpose \u2014 one prop serves Inertia, TanStack Router, React Router and Next\n * rather than a package per router:\n *\n * ```tsx\n * \/\/ href-based routers (Inertia, Next)\n * <Navbar.Item as={Link} href=\"\/dashboard\">Dashboard<\/Navbar.Item>\n *\n * \/\/ to-based routers (TanStack Router, React Router) \u2014 `to` reaches the Link\n * \/\/ through the forwarded rest props\n * <Navbar.Item as={Link} to=\"\/dashboard\">Dashboard<\/Navbar.Item>\n * ```\n *\n * Link mode engages on `href` OR `as`, because a `to`-based router never passes\n * an `href` and would otherwise silently render the non-interactive fallback.\n *\/\nexport interface NavigableProps {\n  \/** Target URL. Renders link mode with a plain `<a>` unless `as` is given. *\/\n  href?: string;\n  \/**\n   * Link-mode element override \u2014 the component to render INSTEAD of the plain\n   * `<a>`, e.g. a router's `<Link>` so navigation happens client-side. Receives\n   * `className`, the item's `data-*` handles, and every unrecognized prop, so\n   * router-specific props (`to`, `params`, `preload`, `search`) pass straight\n   * through. Ignored in button mode.\n   *\/\n  as?: ElementType;\n}\n\n\/**\n * The full Tailwind v4 named color palette \u2014 every default hue, including all\n * five gray families \u2014 plus `brand`, the host's own colour. Components that\n * accept a `color` should type it as this so the whole palette is available.\n *\n * `brand` is not a hue. It resolves through three CSS variables the host sets\n * once, rather than through a Tailwind scale:\n *\n *   `--color-brand`, `--color-brand-contrast`, `--color-brand-hover`\n *\n * Three rather than one because a generated hover assumes \"same hue, darker\",\n * and a brand palette need not work that way \u2014 navy whose hover is gold cannot\n * be derived from navy by any amount of arithmetic. The host states it.\n *\/\nexport type Color =\n  \/\/ the host's own colour, resolved from CSS variables (see styles.css)\n  | \"brand\"\n  \/\/ grays\n  | \"slate\"\n  | \"gray\"\n  | \"zinc\"\n  | \"neutral\"\n  | \"stone\"\n  \/\/ hues\n  | \"red\"\n  | \"orange\"\n  | \"amber\"\n  | \"yellow\"\n  | \"lime\"\n  | \"green\"\n  | \"emerald\"\n  | \"teal\"\n  | \"cyan\"\n  | \"sky\"\n  | \"blue\"\n  | \"indigo\"\n  | \"violet\"\n  | \"purple\"\n  | \"fuchsia\"\n  | \"pink\"\n  | \"rose\";\n\n\/** Every value of {@link Color}, for building exhaustive class maps. *\/\nexport const COLORS = [\n  \"brand\",\n  \"slate\", \"gray\", \"zinc\", \"neutral\", \"stone\",\n  \"red\", \"orange\", \"amber\", \"yellow\", \"lime\", \"green\", \"emerald\", \"teal\",\n  \"cyan\", \"sky\", \"blue\", \"indigo\", \"violet\", \"purple\", \"fuchsia\", \"pink\", \"rose\",\n] as const satisfies readonly Color[];\n\nexport type Variant = \"solid\" | \"outline\" | \"ghost\" | \"soft\";\n\n\/** Button accepts the full Tailwind v4 palette (alias of {@link Color}). *\/\nexport type ButtonColor = Color;\n\n\/**\n * @deprecated Renamed to {@link ButtonColor}. `ActionColor` remains as an alias\n * for backward compatibility and will be removed in a future major version.\n *\/\nexport type ActionColor = ButtonColor;\n\nexport type Placement =\n  | \"top\"\n  | \"bottom\"\n  | \"left\"\n  | \"right\"\n  | \"top-start\"\n  | \"top-end\"\n  | \"bottom-start\"\n  | \"bottom-end\";\n","type":"registry:lib","target":"components\/fancy\/lib\/utils\/types.ts"}]}