{ "$schema": "https://ui.shadcn.com/schema/registry-item.json", "name": "input", "title": "Input", "dependencies": [ "lucide-react@1.14.0" ], "registryDependencies": [ "@birchline/tokens", "@birchline/utils" ], "files": [ { "path": "src/components/ui/input.tsx", "content": "import * as React from \"react\"\nimport { useState, useRef, useCallback } from \"react\"\nimport { X } from \"lucide-react\"\nimport { cn } from \"@/lib/utils\"\n\ninterface InputProps extends React.InputHTMLAttributes {\n wrapperClassName?: string\n}\n\nconst Input = React.forwardRef(\n ({ className, wrapperClassName, type, value: controlledValue, defaultValue, onChange, ...props }, ref) => {\n const [internalValue, setInternalValue] = useState(\n defaultValue !== undefined ? String(defaultValue) : \"\"\n )\n const inputRef = useRef(null)\n\n const isControlled = controlledValue !== undefined\n const displayValue = isControlled ? controlledValue : internalValue\n const hasValue = String(displayValue).length > 0\n\n const setRef = useCallback(\n (node: HTMLInputElement | null) => {\n inputRef.current = node\n if (typeof ref === \"function\") ref(node)\n else if (ref) (ref as React.MutableRefObject).current = node\n },\n [ref]\n )\n\n function handleChange(e: React.ChangeEvent) {\n if (!isControlled) setInternalValue(e.target.value)\n onChange?.(e)\n }\n\n function handleClear() {\n const input = inputRef.current\n if (!input) return\n const nativeInputValueSetter = Object.getOwnPropertyDescriptor(\n window.HTMLInputElement.prototype, \"value\"\n )?.set\n nativeInputValueSetter?.call(input, \"\")\n input.dispatchEvent(new Event(\"input\", { bubbles: true }))\n if (!isControlled) setInternalValue(\"\")\n input.focus()\n }\n\n return (\n
\n \n {hasValue && (\n \n \n \n )}\n
\n )\n }\n)\nInput.displayName = \"Input\"\n\nexport { Input }\n", "type": "registry:ui", "target": "components/ui/input.tsx" } ], "type": "registry:ui" }