{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "input",
  "title": "Input",
  "description": "A text input whose focus ring spreads out of its border, and which marks itself with an icon when its field is invalid.",
  "dependencies": [
    "@ui-sdk/react",
    "@ui-sdk/core"
  ],
  "registryDependencies": [
    "https://kinoui.com/r/refs.json",
    "https://kinoui.com/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/components/kino/input.tsx",
      "content": "'use client'\n\nimport { IconPlaceholder } from '@/registry/icons/icon-placeholder'\nimport { markMounted } from '@/registry/lib/refs'\nimport {\n  InputGroup as InputGroupPrimitive,\n  Input as InputPrimitive,\n} from '@ui-sdk/react/input'\nimport type { ComponentProps, PointerEvent } from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * The box every text control sits in: Input, Textarea, Input group, Number\n * input, Native select and the OTP input's slots. It reads its state from\n * the control inside it, so it works in a Field or on its own; a hidden\n * input that only holds a form's value, such as a File input's, isn't it.\n */\n// `--field-height` is the control height inside the box's 1px borders, so a field stands as tall as a Button.\nconst inputBoxClassName =\n  \"[--field-height:calc(var(--control-height)-2px)] group/input relative flex min-w-0 items-center rounded-(--control-radius) border border-input bg-transparent shadow-xs transition-[color,background-color,border-color,box-shadow] duration-(--motion-press-duration) ease-(--motion-press-fade-easing) has-focus-visible:border-ring has-focus-visible:ring-3 has-focus-visible:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:has-focus-visible:border-destructive has-aria-invalid:has-focus-visible:ring-destructive/20 forced-colors:has-aria-invalid:outline-2 forced-colors:has-aria-invalid:outline-offset-1 forced-colors:has-aria-invalid:outline-dashed has-[:is(input:not([aria-hidden=true]),textarea,select):disabled]:pointer-events-none has-[:is(input:not([aria-hidden=true]),textarea,select):disabled]:opacity-50 has-[:is(input,textarea,select)[aria-disabled=true]]:opacity-50 dark:bg-input/30 dark:has-aria-invalid:border-destructive/70 dark:has-aria-invalid:has-focus-visible:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-']):not(:is(button,[data-slot=button]):is([data-variant=default],[data-variant=destructive],[aria-pressed])_*)]:text-muted-foreground\"\n\n/**\n * The text inside a box, at the control's height. A search box hides the\n * browser's own clear button, which only some browsers draw and none lets us\n * style: a clear button is an `InputGroupButton`, as in the docs.\n */\nconst inputControlClassName =\n  '[&::-webkit-search-cancel-button]:appearance-none h-(--field-height) w-full min-w-0 flex-1 bg-transparent px-(--control-padding) text-base focus-visible:outline-hidden placeholder:text-muted-foreground read-only:text-muted-foreground md:text-sm'\n\n/**\n * A press on a box, outside its value and its buttons, puts the caret in the\n * value as the press starts, so a focused value never blurs and comes back.\n */\nfunction focusControl(event: PointerEvent<HTMLElement>) {\n  const box = event.currentTarget\n  const target = event.target as HTMLElement\n  // A popup opened from a part in the box, such as a currency picker's list,\n  // sits inside it in the page: a press there isn't on the box.\n  const inPopup = (element: Element) => {\n    const popup = element.closest('[data-presentation]')\n    return popup !== null && box.contains(popup)\n  }\n  if (target.closest('input, textarea, select, button, a, [data-slot*=scrub]')) return\n  if (inPopup(target)) return\n  // Not a part's own hidden input, such as a Combobox's or a field's form value.\n  const control = [\n    ...box.querySelectorAll<HTMLElement>(\n      ':is(input, textarea, select):not([type=hidden], [aria-hidden=true])',\n    ),\n  ].find((each) => !inPopup(each))\n  if (!control) return\n  event.preventDefault()\n  control.focus()\n}\n\n/**\n * The mark an invalid control shows, so an error isn't told by colour alone:\n * in a box whose control is invalid, or inside an invalid control, such as a\n * select's trigger.\n */\nfunction InputInvalidIcon({ className, ...props }: ComponentProps<'span'>) {\n  return (\n    <span\n      ref={markMounted}\n      data-slot='input-invalid-icon'\n      aria-hidden\n      className={cn(\n        // It scales in on `enter` and out on `exit`, and turns back from\n        // where it is; one that is invalid on page load is simply there.\n        'text-destructive hidden shrink-0 items-center pe-(--control-padding) opacity-0 transition-[opacity,scale,display] transition-discrete duration-(--motion-exit-duration) ease-(--motion-exit-easing) group-has-aria-invalid/input:flex motion-safe:group-has-aria-invalid/input:scale-100 group-has-aria-invalid/input:opacity-100 group-has-aria-invalid/input:duration-(--motion-enter-duration) group-has-aria-invalid/input:ease-(--motion-enter-easing) in-aria-invalid:flex motion-safe:in-aria-invalid:scale-100 in-aria-invalid:opacity-100 in-aria-invalid:duration-(--motion-enter-duration) in-aria-invalid:ease-(--motion-enter-easing) data-mounted:starting:opacity-0 motion-safe:scale-95 motion-safe:data-mounted:starting:scale-95',\n        className,\n      )}\n      {...props}\n    >\n      {/* Its own colour class, so the box's muted icon colour skips it. */}\n      <IconPlaceholder\n        className='text-destructive'\n        lucide='CircleXIcon'\n        tabler='IconCircleX'\n        hugeicons='CancelCircleIcon'\n        phosphor='XCircleIcon'\n        remixicon='RiCloseCircleLine'\n        aria-hidden\n      />\n    </span>\n  )\n}\n\ntype InputControlProps = Omit<ComponentProps<typeof InputPrimitive>, 'className'> & {\n  className?: string\n}\n\n/** ui-sdk's `<input>` alone, at the control's height, for a box of your own. */\nfunction InputControl({ className, ...props }: InputControlProps) {\n  return <InputPrimitive className={cn(inputControlClassName, className)} {...props} />\n}\n\n/** The box the input sits in, with its invalid mark; the props go to the input, `className` to the box. */\nfunction Input({ className, ...props }: InputControlProps) {\n  return (\n    <InputGroupPrimitive\n      onPointerDown={focusControl}\n      className={cn(inputBoxClassName, 'cursor-text', className)}\n    >\n      <InputControl {...props} />\n      <InputInvalidIcon />\n    </InputGroupPrimitive>\n  )\n}\n\n/*\n * A field's Clear button, a ghost icon Button marked `data-field-clear`: it\n * fades in on `enter` and out on `exit` where it is, and turns back from\n * where it is; a press still answers on `press`. Scoped to its attribute, so\n * it wins over the Button's own transition. With less motion it doesn't\n * scale, so only the fade and colours move.\n */\nconst fieldClearClassName =\n  'data-starting-style:opacity-0 data-ending-style:opacity-0 motion-safe:data-field-clear:[transition:opacity_var(--motion-enter-duration)_var(--motion-enter-easing),scale_var(--motion-press-duration)_var(--motion-press-easing),color_var(--motion-press-duration)_var(--motion-press-fade-easing),background-color_var(--motion-press-duration)_var(--motion-press-fade-easing),box-shadow_var(--motion-press-duration)_var(--motion-press-fade-easing)] motion-reduce:data-field-clear:[transition:opacity_var(--motion-enter-duration)_var(--motion-enter-easing),color_var(--motion-press-duration)_var(--motion-press-fade-easing),background-color_var(--motion-press-duration)_var(--motion-press-fade-easing),box-shadow_var(--motion-press-duration)_var(--motion-press-fade-easing)] data-ending-style:data-field-clear:[transition:opacity_var(--motion-exit-duration)_var(--motion-exit-easing)]'\n\n/*\n * A search pinned above a popup's rows, as one line: its icon, then the text\n * at the large control's height, with a rule under it that takes the ring's\n * colour while the text has focus. The Command and the menus' search.\n */\nconst searchLineClassName =\n  'flex shrink-0 items-center gap-2 border-b px-[calc(var(--control-padding)+0.25rem)] has-focus-visible:border-ring'\n\nconst searchLineInputClassName = cn(inputControlClassName, 'h-(--control-height-lg) px-0')\n\n/** The search line's icon. */\nconst searchLineIcon = (\n  <IconPlaceholder\n    lucide='SearchIcon'\n    tabler='IconSearch'\n    hugeicons='Search01Icon'\n    phosphor='MagnifyingGlassIcon'\n    remixicon='RiSearchLine'\n    aria-hidden\n    className='text-muted-foreground size-4 shrink-0'\n  />\n)\n\nexport {\n  fieldClearClassName,\n  focusControl,\n  Input,\n  InputControl,\n  InputInvalidIcon,\n  inputBoxClassName,\n  inputControlClassName,\n  searchLineClassName,\n  searchLineIcon,\n  searchLineInputClassName,\n}\n",
      "type": "registry:component",
      "target": "@components/kino/input.tsx"
    }
  ],
  "type": "registry:component"
}