{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "react-number-input",
  "title": "React Number Input",
  "description": "Labeled React number input with an optional unit, stacked controls, bounds, and empty values.",
  "dependencies": [
    "@solar-icons/react"
  ],
  "files": [
    {
      "path": "components/input/ReactNumberInput.tsx",
      "content": "'use client';\n\nimport { useId, useState, type FocusEvent, type InputHTMLAttributes } from 'react';\nimport { AltArrowDownBoldIcon, AltArrowUpBoldIcon } from '@solar-icons/react';\n\ntype ReactNumberInputProps = Omit<\n  InputHTMLAttributes<HTMLInputElement>,\n  'type' | 'size' | 'value' | 'defaultValue' | 'onChange' | 'min' | 'max' | 'step'\n> & {\n  label: string;\n  value?: number | null;\n  defaultValue?: number | null;\n  min?: number;\n  max?: number;\n  step?: number;\n  unit?: string;\n  hint?: string;\n  error?: string;\n  // eslint-disable-next-line no-unused-vars\n  onValueChange?: (value: number | null) => void;\n};\n\nconst clamp = (value: number, min?: number, max?: number) =>\n  Math.min(max ?? Infinity, Math.max(min ?? -Infinity, value));\n\nexport default function ReactNumberInput({\n  id,\n  label,\n  value,\n  defaultValue = null,\n  min,\n  max,\n  step = 1,\n  unit,\n  hint,\n  error,\n  disabled,\n  className = '',\n  onValueChange,\n  onBlur,\n  ...props\n}: ReactNumberInputProps) {\n  const generatedId = useId();\n  const inputId = id ?? generatedId;\n  const messageId = `${inputId}-message`;\n  const [internalValue, setInternalValue] = useState(defaultValue === null ? '' : String(defaultValue));\n  const displayValue = value === undefined ? internalValue : value === null ? '' : String(value);\n  const numericValue = displayValue === '' ? null : Number(displayValue);\n\n  const commit = (next: number | null) => {\n    const normalized = next === null ? null : Number(clamp(next, min, max).toFixed(10));\n    if (value === undefined) setInternalValue(normalized === null ? '' : String(normalized));\n    onValueChange?.(normalized);\n  };\n\n  const stepValue = (direction: -1 | 1) => {\n    const start = numericValue !== null && Number.isFinite(numericValue) ? numericValue : min ?? 0;\n    commit(start + direction * step);\n  };\n\n  const handleBlur = (event: FocusEvent<HTMLInputElement>) => {\n    if (numericValue !== null && Number.isFinite(numericValue)) commit(numericValue);\n    onBlur?.(event);\n  };\n\n  return (\n    <div className={['w-full', className].filter(Boolean).join(' ')}>\n      <label htmlFor={inputId} className=\"mb-2 block text-sm font-semibold text-[color:var(--color-foreground,#030712)]\">\n        {label}\n      </label>\n      <div\n        className={[\n          'flex min-h-14 overflow-hidden rounded-[var(--radius-2xl,1rem)] border bg-[var(--color-background,#fff)] shadow-sm transition focus-within:ring-4',\n          error\n            ? 'border-red-300 focus-within:border-red-400 focus-within:ring-red-100'\n            : 'border-[color:var(--color-border,#e5e7eb)] focus-within:border-[color:var(--color-input,#9ca3af)] focus-within:ring-[var(--color-ring,#f3f4f6)]',\n          disabled ? 'bg-[var(--color-muted,#f9fafb)] opacity-60' : '',\n        ].join(' ')}\n      >\n        <input\n          {...props}\n          id={inputId}\n          type=\"number\"\n          inputMode=\"decimal\"\n          value={displayValue}\n          min={min}\n          max={max}\n          step={step}\n          disabled={disabled}\n          aria-invalid={Boolean(error)}\n          aria-describedby={hint || error ? messageId : undefined}\n          onChange={(event) => {\n            const raw = event.target.value;\n            if (value === undefined) setInternalValue(raw);\n            onValueChange?.(raw === '' || !Number.isFinite(event.target.valueAsNumber) ? null : event.target.valueAsNumber);\n          }}\n          onBlur={handleBlur}\n          className=\"min-w-0 flex-1 appearance-none bg-transparent px-4 text-base font-medium tabular-nums text-[color:var(--color-foreground,#030712)] outline-none placeholder:text-[color:var(--color-muted-foreground,#9ca3af)] [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none\"\n        />\n        {unit ? <span className=\"flex items-center px-3 text-sm font-medium text-[color:var(--color-muted-foreground,#6b7280)]\">{unit}</span> : null}\n        <span className=\"grid w-11 shrink-0 grid-rows-2 border-l border-[color:var(--color-border,#f3f4f6)]\">\n          <button\n            type=\"button\"\n            aria-label={`Increase ${label}`}\n            onClick={() => stepValue(1)}\n            disabled={disabled || (max !== undefined && numericValue !== null && numericValue >= max)}\n            className=\"grid place-items-center border-b border-[color:var(--color-border,#f3f4f6)] text-[color:var(--color-muted-foreground,#6b7280)] transition hover:bg-[var(--color-muted,#f9fafb)] hover:text-[color:var(--color-foreground,#030712)] focus:z-10 focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[color:var(--color-ring,#6b7280)] disabled:cursor-not-allowed disabled:text-[color:var(--color-muted-foreground,#d1d5db)]\"\n          >\n            <AltArrowUpBoldIcon className=\"h-4 w-4\" aria-hidden=\"true\" />\n          </button>\n          <button\n            type=\"button\"\n            aria-label={`Decrease ${label}`}\n            onClick={() => stepValue(-1)}\n            disabled={disabled || (min !== undefined && numericValue !== null && numericValue <= min)}\n            className=\"grid place-items-center text-[color:var(--color-muted-foreground,#6b7280)] transition hover:bg-[var(--color-muted,#f9fafb)] hover:text-[color:var(--color-foreground,#030712)] focus:z-10 focus:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[color:var(--color-ring,#6b7280)] disabled:cursor-not-allowed disabled:text-[color:var(--color-muted-foreground,#d1d5db)]\"\n          >\n            <AltArrowDownBoldIcon className=\"h-4 w-4\" aria-hidden=\"true\" />\n          </button>\n        </span>\n      </div>\n      {error || hint ? (\n        <p id={messageId} className={['mt-2 text-xs', error ? 'text-[color:var(--color-destructive,#dc2626)]' : 'text-[color:var(--color-muted-foreground,#6b7280)]'].join(' ')}>\n          {error || hint}\n        </p>\n      ) : null}\n    </div>\n  );\n}\n",
      "type": "registry:component",
      "target": "@components/input/ReactNumberInput.tsx"
    }
  ],
  "categories": [
    "input"
  ],
  "type": "registry:component"
}