{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "input",
  "title": "Input",
  "description": "A text input component.",
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "src/components/ui/input.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { XCircle } from \"phosphor-react\";\nimport { cn } from \"@/stories/lib/utils\";\n\n// Base input variants (unchanged)\nconst inputVariants = cva(\n  \"bg-background file:text-foreground placeholder:text-muted-foreground flex w-full rounded border font-medium file:border-0 file:bg-transparent file:font-medium focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 transition-colors\",\n  {\n    variants: {\n      size: {\n        xl: \"min-h-14 px-4 py-4 text-lg file:text-base\",\n        l: \"min-h-12 px-3 py-3 text-base file:text-sm\",\n        m: \"min-h-10 px-3 py-2 text-sm file:text-sm\",\n        s: \"min-h-8 px-2 py-1.5 text-sm file:text-xs\",\n      },\n      validation: {\n        none: \"border-input focus:border-secondary\",\n        error: \"border-error focus:border-destructive\",\n        success: \"border-green-500 focus:border-green-600\",\n      },\n    },\n    defaultVariants: {\n      size: \"m\",\n      validation: \"none\",\n    },\n  },\n);\n\n// Base Input Component Props (unchanged)\nexport interface BaseInputProps\n  extends\n    Omit<React.InputHTMLAttributes<HTMLInputElement>, \"size\">,\n    VariantProps<typeof inputVariants> {\n  validationMsg?: string;\n}\n\n// Base Input Component (unchanged)\nconst Input = React.forwardRef<HTMLInputElement, BaseInputProps>(\n  (\n    {\n      className,\n      type = \"text\",\n      size = \"m\",\n      validation = \"none\",\n      validationMsg,\n      ...props\n    },\n    ref,\n  ) => {\n    return (\n      <div className=\"w-full\">\n        <input\n          type={type}\n          className={cn(inputVariants({ size, validation }), className)}\n          ref={ref}\n          {...props}\n        />\n        {/* 3. Add this block to conditionally render the message */}\n        {validationMsg && validation !== \"none\" && (\n          <p\n            className={cn(\"mt-1.5 text-xs font-medium\", {\n              \"text-error\": validation === \"error\",\n              \"text-green-600\": validation === \"success\",\n            })}\n          >\n            {validationMsg}\n          </p>\n        )}\n      </div>\n    );\n  },\n);\nInput.displayName = \"Input\";\n\n// NEW: ClearableInput Component\nconst ClearableInput = React.forwardRef<HTMLInputElement, BaseInputProps>(\n  ({ value, onChange, className, ...props }, ref) => {\n    const hasValue = value && String(value).length > 0;\n\n    const handleClear = (\n      e: React.MouseEvent<HTMLButtonElement, MouseEvent>,\n    ) => {\n      e.preventDefault();\n      const input = e.currentTarget.previousSibling as HTMLInputElement;\n\n      // Create a synthetic event\n      const syntheticEvent = {\n        target: { ...input, value: \"\" },\n        currentTarget: { ...input, value: \"\" },\n      } as React.ChangeEvent<HTMLInputElement>;\n\n      // Trigger the parent's onChange\n      onChange?.(syntheticEvent);\n\n      // Focus the input after clearing\n      input.focus();\n    };\n\n    return (\n      <div className=\"relative w-full\">\n        <Input\n          ref={ref}\n          value={value}\n          onChange={onChange}\n          // Add padding on the right to make space for the icon\n          className={cn(\"pr-10\", className)}\n          {...props}\n        />\n        {/* Conditionally render the \"X\" icon */}\n        {hasValue && (\n          <button\n            type=\"button\"\n            aria-label=\"Clear input\"\n            onClick={handleClear}\n            className=\"absolute inset-y-0 right-0 flex items-center justify-center px-3 text-muted-foreground transition-colors hover:text-foreground\"\n          >\n            <XCircle className=\"h-4 w-4\" weight=\"fill\" />\n          </button>\n        )}\n      </div>\n    );\n  },\n);\nClearableInput.displayName = \"ClearableInput\";\n\nexport { Input, inputVariants, ClearableInput };\n",
      "type": "registry:ui",
      "target": "components/ui/input.tsx"
    }
  ],
  "type": "registry:ui"
}