{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "input",
  "title": "Input",
  "description": "Single-line and multi-line text fields, plus Field and Label for a label, helper text and a validation message.",
  "registryDependencies": [
    "https://www.gliakit.com/r/tokens.json"
  ],
  "files": [
    {
      "path": "src/components/ui/input.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\n/** What a Field tells the control inside it: the id its label points at, the note that describes it, and whether it's in error. */\ntype FieldInfo = { id: string; labelId?: string; describedBy?: string; invalid: boolean };\nconst FieldContext = React.createContext<FieldInfo | null>(null);\n\ntype ControlProps = { id?: string; \"aria-describedby\"?: string; \"aria-invalid\"?: React.AriaAttributes[\"aria-invalid\"] };\n\n/**\n * A control's props with what its Field adds: the label's id (so the label\n * names it), the helper or error as its description, and aria-invalid on an\n * error. The control's own props win. Outside a Field, nothing changes.\n */\nfunction useFieldControl<P extends ControlProps>(props: P): P {\n  const field = React.useContext(FieldContext);\n  if (!field) return props;\n  const describedBy = [props[\"aria-describedby\"], field.describedBy].filter(Boolean).join(\" \") || undefined;\n  return { ...props, id: props.id ?? field.id, \"aria-describedby\": describedBy, \"aria-invalid\": props[\"aria-invalid\"] ?? (field.invalid || undefined) };\n}\n\nfunction Input({ className, type, ...rest }: React.ComponentProps<\"input\">) {\n  const props = useFieldControl(rest);\n  return (\n    <input\n      type={type}\n      data-slot=\"input\"\n      className={cn(\n        \"flex h-control w-full min-w-0 rounded-md border border-input bg-card px-3 py-1 text-sm text-foreground shadow-xs transition-colors outline-none\",\n        \"placeholder:text-muted-foreground\",\n        \"focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40\",\n        \"aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/25\",\n        \"disabled:pointer-events-none disabled:opacity-50\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\n/** Multi-line input — same field styling as Input. */\nfunction Textarea({ className, ...rest }: React.ComponentProps<\"textarea\">) {\n  const props = useFieldControl(rest);\n  return (\n    <textarea\n      data-slot=\"textarea\"\n      className={cn(\n        \"flex min-h-20 w-full min-w-0 resize-y rounded-md border border-input bg-card px-3 py-2 text-sm text-foreground shadow-xs transition-colors outline-none\",\n        \"placeholder:text-muted-foreground\",\n        \"focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/40\",\n        \"aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/25\",\n        \"disabled:pointer-events-none disabled:opacity-50\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\nfunction Label({ className, ...props }: React.ComponentProps<\"label\">) {\n  return (\n    <label\n      data-slot=\"label\"\n      className={cn(\n        \"text-[13px] font-medium text-secondary-foreground\",\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\n/**\n * A labelled control with an optional helper or error. The label, the\n * control and the note are a grid, so a theme can move the label beside\n * the control, onto its top border or inside it (data-field on <html>).\n */\nfunction Field({\n  label,\n  htmlFor,\n  required,\n  helper,\n  error,\n  children,\n  className,\n}: {\n  label?: string;\n  /** The control's id, so the label focuses it. */\n  htmlFor?: string;\n  required?: boolean;\n  helper?: string;\n  /** Validation message — replaces the helper and reads in destructive. */\n  error?: string;\n  children: React.ReactNode;\n  className?: string;\n}) {\n  const noteId = React.useId();\n  const autoId = React.useId();\n  const id = htmlFor ?? autoId;\n  const note = error ?? helper;\n  const labelId = `${autoId}-label`;\n  const info = React.useMemo<FieldInfo>(\n    () => ({ id, labelId: label ? labelId : undefined, describedBy: note ? noteId : undefined, invalid: Boolean(error) }),\n    [id, label, labelId, note, noteId, error],\n  );\n  // content-start: stretched to a taller neighbour's height (two fields in a row, one with a note), the\n  // extra space goes below the rows instead of being shared out between them, which pushed the control down.\n  return (\n    <div data-slot=\"field\" className={cn(\"grid min-w-0 content-start gap-1.5\", className)}>\n      {label && (\n        <Label data-slot=\"field-label\" id={labelId} htmlFor={id}>\n          {label}\n          {required && (\n            <span aria-hidden=\"true\" className=\"ml-0.5 text-destructive\">\n              *\n            </span>\n          )}\n        </Label>\n      )}\n      <div data-slot=\"field-control\" className=\"relative min-w-0\">\n        <FieldContext.Provider value={info}>{children}</FieldContext.Provider>\n      </div>\n      {/* Linked to the control (aria-describedby); an error that appears is announced. */}\n      <p id={noteId} data-slot=\"field-note\" aria-live=\"polite\" className={cn(\"text-xs empty:hidden\", error ? \"text-destructive\" : \"text-muted-foreground\")}>\n        {note}\n      </p>\n    </div>\n  );\n}\n\n/** The Field around a control, if any: for controls that name themselves from its label (a trigger showing a value). */\nconst useField = () => React.useContext(FieldContext);\n\nexport { Input, Textarea, Label, Field, useFieldControl, useField };\n",
      "type": "registry:ui"
    }
  ],
  "categories": [
    "forms"
  ],
  "type": "registry:ui"
}
