{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "mobile-input",
  "type": "registry:ui",
  "title": "MobileInput",
  "description": "فیلد شماره موبایل: +98 و 0098 را به 09 تبدیل می‌کند، گروه‌بندی و تشخیص اپراتور",
  "dependencies": [
    "@kashi-ui/persian@^1.8.0"
  ],
  "registryDependencies": [
    "https://kashi.sepantapouya.com/r/cx.json",
    "https://kashi.sepantapouya.com/r/input.json",
    "https://kashi.sepantapouya.com/r/kashi-provider.json",
    "https://kashi.sepantapouya.com/r/use-digits-input.json",
    "https://kashi.sepantapouya.com/r/utils.json"
  ],
  "files": [
    {
      "path": "registry/kashi/MobileInput.tsx",
      "type": "registry:ui",
      "target": "components/kashi/MobileInput.tsx",
      "content": "\"use client\";\n\nimport { forwardRef, useId, useState, type ReactNode } from \"react\";\nimport { formatMobile, getMobileOperator, isValidMobile, normalizeMobile, operatorName } from \"@kashi-ui/persian\";\nimport { Input, type InputProps } from \"./Input\";\nimport { useDigitsInput } from \"./useDigitsInput\";\nimport { mergeRefs } from \"./utils\";\nimport { useKashi } from \"./KashiProvider\";\n\ntype Base = Omit<InputProps, \"value\" | \"defaultValue\" | \"onChange\" | \"type\" | \"inputMode\" | \"addonEnd\">;\n\nexport interface MobileInputProps extends Base {\n  /** مقدار کنترل‌شده، مثل \"09123456789\" یا \"+989123456789\" */\n  value?: string;\n  defaultValue?: string;\n  /** با هر تغییر: شماره به شکل ۰۹xxxxxxxxx، معتبر بودن و نام اپراتور */\n  onValueChange?: (value: string, valid: boolean, operator: string | null) => void;\n  /** @default \"fa\" */\n  digits?: \"fa\" | \"latin\";\n  /** نمایش نام اپراتور @default true */\n  showOperator?: boolean;\n  /** @default \"شماره موبایل معتبر نیست.\" */\n  invalidMessage?: ReactNode;\n}\n\n/** فیلد شماره موبایل: +98 و 0098 را به 09 تبدیل می‌کند، گروه‌بندی و تشخیص اپراتور */\nexport const MobileInput = forwardRef<HTMLInputElement, MobileInputProps>(function MobileInput(\n  { value, defaultValue, onValueChange, digits, showOperator = true, invalidMessage, error, name, id, onBlur, placeholder, ...rest },\n  ref,\n) {\n  const { messages: M, digits: D, locale } = useKashi();\n  digits ??= D;\n  invalidMessage ??= M.invalid.mobile;\n  const autoId = useId();\n  const inputId = id ?? autoId;\n  const [touched, setTouched] = useState(false);\n  const { raw, shown, inputRef, handleChange } = useDigitsInput({\n    value,\n    defaultValue,\n    maxDigits: 11,\n    normalize: normalizeMobile,\n    format: formatMobile,\n    digits,\n  });\n  const operator = showOperator ? getMobileOperator(raw) : null;\n  const showInvalid = raw.length > 0 && (touched || raw.length === 11) && !isValidMobile(raw);\n  const opId = `${inputId}-operator`;\n\n  return (\n    <>\n      <Input\n        ref={mergeRefs(ref, inputRef)}\n        id={inputId}\n        type=\"tel\"\n        inputMode=\"tel\"\n        autoComplete=\"tel-national\"\n        dir=\"ltr\"\n        placeholder={placeholder ?? (digits === \"fa\" ? \"۰۹۱۲ ۳۴۵ ۶۷۸۹\" : \"0912 345 6789\")}\n        value={shown}\n        onChange={(e) => {\n          const next = handleChange(e);\n          onValueChange?.(next, isValidMobile(next), getMobileOperator(next)?.name ?? null);\n        }}\n        onBlur={(e) => {\n          setTouched(true);\n          onBlur?.(e);\n        }}\n        addonEnd={operator ? <span className=\"k-input__meta\" id={opId}>{operatorName(operator, locale)}</span> : undefined}\n        aria-describedby={operator ? opId : undefined}\n        error={error ?? (showInvalid ? invalidMessage : undefined)}\n        {...rest}\n      />\n      {name && <input type=\"hidden\" name={name} value={raw} />}\n    </>\n  );\n});\n"
    }
  ]
}