{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "input",
  "type": "registry:ui",
  "title": "Input",
  "description": "Input, Textarea and Field: text controls and the wrapper that owns the label, hint and error and wires them with aria.",
  "dependencies": [],
  "registryDependencies": [
    "https://ui.klarhimmel.com/r/button.json",
    "https://ui.klarhimmel.com/r/editing.json",
    "https://ui.klarhimmel.com/r/theme.json",
    "https://ui.klarhimmel.com/r/utils.json"
  ],
  "files": [
    {
      "path": "src/ui/input.tsx",
      "type": "registry:file",
      "target": "components/klarhimmel/ui/input.tsx",
      "content": "import { forwardRef, useContext, useId, type InputHTMLAttributes, type ReactNode, type TextareaHTMLAttributes } from 'react';\nimport { cn } from '../lib/utils';\nimport { EditingContext } from '../editing';\nimport { nameEmptied } from './button';\n\n// Never under 16 px: iPhone Safari zooms into a smaller field on tap (a style with a 15 px body would do it to every form).\nconst field =\n  'w-full rounded-kh border border-kh-line-strong bg-kh-surface px-3 text-[length:max(16px,var(--kh-text-body))] text-kh-ink shadow-kh-1 transition-[border-color] duration-(--kh-dur) ' +\n  'placeholder:text-kh-muted hover:border-kh-muted focus-visible:outline-2 focus-visible:outline-offset-0 focus-visible:outline-(--kh-focus) ' +\n  'disabled:cursor-not-allowed disabled:bg-kh-surface-2 disabled:text-kh-muted aria-[invalid=true]:border-kh-danger';\n\nexport const Input = forwardRef<HTMLInputElement, InputHTMLAttributes<HTMLInputElement>>(function Input({ className, ...rest }, ref) {\n  return <input ref={ref} className={cn(field, 'min-h-11', className)} {...rest} />;\n});\n\nexport const Textarea = forwardRef<HTMLTextAreaElement, TextareaHTMLAttributes<HTMLTextAreaElement>>(function Textarea({ className, rows = 5, ...rest }, ref) {\n  return <textarea ref={ref} rows={rows} className={cn(field, 'resize-y py-2.5 leading-normal', className)} {...rest} />;\n});\n\n/** Label + control + hint/error, ids wired for assistive tech. */\nexport function Field({\n  label,\n  hint,\n  error,\n  labelHidden,\n  children,\n  className,\n}: {\n  label: ReactNode;\n  /** The label is read by assistive tech but not drawn: for a field whose context already says what it is. */\n  labelHidden?: boolean;\n  hint?: ReactNode;\n  error?: ReactNode;\n  children: (p: { id: string; 'aria-describedby'?: string; 'aria-invalid'?: true }) => ReactNode;\n  className?: string;\n}) {\n  const id = useId();\n  const editing = !!useContext(EditingContext);\n  const desc = error || hint ? `${id}-d` : undefined;\n  if (!editing && nameEmptied(label)) return null; // an emptied label: the field is not drawn\n  return (\n    <div className={cn('flex flex-col gap-1.5', className)}>\n      <label htmlFor={id} className={labelHidden ? 'sr-only' : 'text-kh-small font-medium text-kh-ink'}>\n        {label}\n      </label>\n      {children({ id, 'aria-describedby': desc, 'aria-invalid': error ? true : undefined })}\n      {(error || hint) && (\n        <p id={desc} className={cn('text-kh-small', error ? 'text-kh-danger' : 'text-kh-muted')}>\n          {error || hint}\n        </p>\n      )}\n    </div>\n  );\n}\n"
    }
  ]
}
