{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "tax-id-input",
  "type": "registry:ui",
  "title": "TaxIdInput",
  "description": "فیلد فارسی",
  "dependencies": [
    "@kashi-ui/persian@^2.26.0"
  ],
  "registryDependencies": [
    "https://kashi.sepantapouya.com/r/cx.json",
    "https://kashi.sepantapouya.com/r/input.json",
    "https://kashi.sepantapouya.com/r/kashi-provider.json"
  ],
  "files": [
    {
      "path": "registry/kashi/TaxIdInput.tsx",
      "type": "registry:ui",
      "target": "components/kashi/TaxIdInput.tsx",
      "content": "\"use client\";\n\nimport { forwardRef, useState, type ReactNode } from \"react\";\nimport { isValidTaxId, normalizeTaxId } from \"@kashi-ui/persian\";\nimport { Input, type InputProps } from \"./Input\";\nimport { useMessages } from \"./KashiProvider\";\nimport { faInvalid } from \"@kashi-ui/persian\";\n\ntype Base = Omit<InputProps, \"value\" | \"defaultValue\" | \"onChange\" | \"type\" | \"inputMode\">;\n\nexport interface TaxIdInputProps extends Base {\n  /** مقدار یکدست‌شده: ارقام لاتین و حروف بزرگ */\n  value?: string;\n  defaultValue?: string;\n  onValueChange?: (value: string, valid: boolean) => void;\n  invalidMessage?: ReactNode;\n}\n\n/**\n * شمارهٔ منحصربه‌فرد مالیاتی فاکتور (سامانهٔ مودیان): ۲۲ نویسه.\n * ارقام فارسی لاتین می‌شوند، حروف بزرگ و فاصله و خط تیره حذف؛ فقط شکل بررسی می‌شود.\n */\nexport const TaxIdInput = forwardRef<HTMLInputElement, TaxIdInputProps>(function TaxIdInput(\n  { value, defaultValue = \"\", onValueChange, invalidMessage, error, name, onBlur, placeholder, ...rest },\n  ref,\n) {\n  const M = useMessages({ invalid: faInvalid });\n  invalidMessage ??= M.invalid.taxId;\n  const [inner, setInner] = useState(() => normalizeTaxId(defaultValue).slice(0, 22));\n  const [touched, setTouched] = useState(false);\n  const raw = value !== undefined ? normalizeTaxId(value).slice(0, 22) : inner;\n  const showInvalid = raw.length > 0 && (touched || raw.length === 22) && !isValidTaxId(raw);\n  return (\n    <>\n      <Input\n        ref={ref}\n        type=\"text\"\n        variant=\"code\"\n        dir=\"ltr\"\n        placeholder={placeholder ?? \"A1B2C3…\"}\n        value={raw}\n        onChange={(e) => {\n          const next = normalizeTaxId(e.target.value).slice(0, 22);\n          if (value === undefined) setInner(next);\n          onValueChange?.(next, isValidTaxId(next));\n        }}\n        onBlur={(e) => {\n          setTouched(true);\n          onBlur?.(e);\n        }}\n        error={error ?? (showInvalid ? invalidMessage : undefined)}\n        {...rest}\n      />\n      {name && <input type=\"hidden\" name={name} value={raw} />}\n    </>\n  );\n});\n"
    }
  ]
}