{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "comp-35",
  "type": "registry:component",
  "title": "Comp 35",
  "description": "Comp 35",
  "files": [
    {
      "path": "registry/ui-basic/comp-35.tsx",
      "content": "\"use client\";\r\n\r\nimport { useId } from \"react\";\r\n\r\nimport { Input } from \"@/components/ui/input\";\r\nimport { Label } from \"@/components/ui/label\";\r\n\r\nimport { useCharacterLimit } from \"../utilities/useCharacterLimit\";\r\n\r\nexport default function Component() {\r\n\tconst id = useId();\r\n\tconst maxLength = 8;\r\n\tconst {\r\n\t\tvalue,\r\n\t\tcharacterCount,\r\n\t\thandleChange,\r\n\t\tmaxLength: limit,\r\n\t} = useCharacterLimit({ maxLength });\r\n\r\n\treturn (\r\n\t\t<div className=\"not-first:*:mt-2\">\r\n\t\t\t<Label htmlFor={id}>Input with characters left</Label>\r\n\t\t\t<Input\r\n\t\t\t\tid={id}\r\n\t\t\t\ttype=\"text\"\r\n\t\t\t\tvalue={value}\r\n\t\t\t\tmaxLength={maxLength}\r\n\t\t\t\tonChange={handleChange}\r\n\t\t\t\taria-describedby={`${id}-description`}\r\n\t\t\t/>\r\n\t\t\t<p\r\n\t\t\t\tid={`${id}-description`}\r\n\t\t\t\tclassName=\"text-muted-foreground mt-2 text-xs\"\r\n\t\t\t\trole=\"status\"\r\n\t\t\t\taria-live=\"polite\"\r\n\t\t\t>\r\n\t\t\t\t<span className=\"tabular-nums\">{limit - characterCount}</span>{\" \"}\r\n\t\t\t\tcharacters left\r\n\t\t\t</p>\r\n\t\t</div>\r\n\t);\r\n}\r\n",
      "type": "registry:ui"
    },
    {
      "path": "components/ui/input.tsx",
      "content": "// SHADCN UI GENERATED CODE\n\nimport React from \"react\";\n\nimport { cn } from \"@/registry/utilities/cn\";\n\nexport interface InputProps\n\textends React.InputHTMLAttributes<HTMLInputElement> {}\n\nconst Input = React.forwardRef<HTMLInputElement, InputProps>(\n\t({ className, type, ...props }, ref) => {\n\t\treturn (\n\t\t\t<input\n\t\t\t\ttype={type}\n\t\t\t\tclassName={cn(\n\t\t\t\t\t\"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50\",\n\t\t\t\t\tclassName\n\t\t\t\t)}\n\t\t\t\tref={ref}\n\t\t\t\t{...props}\n\t\t\t/>\n\t\t);\n\t}\n);\nInput.displayName = \"Input\";\n\nexport { Input };\n",
      "type": "registry:ui"
    },
    {
      "path": "registry/utilities/cn.ts",
      "content": "import { ClassValue, clsx } from \"clsx\";\r\nimport { twMerge } from \"tailwind-merge\";\r\n\r\nexport function cn(...inputs: ClassValue[]) {\r\n\treturn twMerge(clsx(inputs));\r\n}\r\n",
      "type": "registry:ui"
    },
    {
      "path": "components/ui/label.tsx",
      "content": "\"use client\";\n\nimport React from \"react\";\n\nimport { cn } from \"@/registry/utilities/cn\";\nimport * as LabelPrimitive from \"@radix-ui/react-label\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\n\nconst labelVariants = cva(\n\t\"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70\"\n);\n\nconst Label = React.forwardRef<\n\tReact.ElementRef<typeof LabelPrimitive.Root>,\n\tReact.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &\n\t\tVariantProps<typeof labelVariants>\n>(({ className, ...props }, ref) => (\n\t<LabelPrimitive.Root\n\t\tref={ref}\n\t\tclassName={cn(labelVariants(), className)}\n\t\t{...props}\n\t/>\n));\nLabel.displayName = LabelPrimitive.Root.displayName;\n\nexport { Label };\n",
      "type": "registry:ui"
    },
    {
      "path": "registry/utilities/useCharacterLimit.ts",
      "content": "\"use client\"\r\n\r\nimport { ChangeEvent, useState } from \"react\"\r\n\r\ntype UseCharacterLimitProps = {\r\n    maxLength: number\r\n    initialValue?: string\r\n}\r\n\r\nexport function useCharacterLimit({\r\n    maxLength,\r\n    initialValue = \"\",\r\n}: UseCharacterLimitProps) {\r\n    const [value, setValue] = useState(initialValue)\r\n    const [characterCount, setCharacterCount] = useState(initialValue.length)\r\n\r\n    const handleChange = (\r\n        e: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>\r\n    ) => {\r\n        const newValue = e.target.value\r\n        if (newValue.length <= maxLength) {\r\n            setValue(newValue)\r\n            setCharacterCount(newValue.length)\r\n        }\r\n    }\r\n\r\n    return {\r\n        value,\r\n        characterCount,\r\n        handleChange,\r\n        maxLength,\r\n    }\r\n}",
      "type": "registry:ui"
    }
  ]
}