{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "phone-input",
  "title": "Phone Input",
  "description": "International phone number input with a flag country picker that returns E.164 numbers.",
  "dependencies": [
    "react-phone-number-input@^3.4.16",
    "lucide-react"
  ],
  "registryDependencies": [
    "input"
  ],
  "files": [
    {
      "path": "components/dentil/phone-input/phone-input.tsx",
      "content": "'use client';\n\nimport { ChevronDownIcon, PhoneIcon } from 'lucide-react';\nimport * as React from 'react';\nimport * as RPNInput from 'react-phone-number-input';\nimport flags from 'react-phone-number-input/flags';\n\nimport { Input } from '@/components/ui/input';\nimport { cn } from '@/lib/utils';\n\nexport type PhoneCountry = RPNInput.Country;\n\nexport interface PhoneInputProps extends Omit<\n  React.ComponentProps<'input'>,\n  'value' | 'onChange' | 'type' | 'defaultValue' | 'ref'\n> {\n  /** E.164 number, e.g. `'+447700900123'`. */\n  value: string | null | undefined;\n  /** Called with the E.164 number, or `''` when the field is cleared. */\n  onChange: (value: string) => void;\n  /** Country preselected while the field is empty. */\n  defaultCountry?: PhoneCountry;\n  /** Only list these countries. */\n  countries?: PhoneCountry[];\n}\n\nexport function PhoneInput({\n  className,\n  defaultCountry,\n  countries,\n  disabled,\n  value,\n  onChange,\n  placeholder = 'Enter phone number',\n  ...props\n}: PhoneInputProps) {\n  return (\n    <RPNInput.default\n      containerComponentProps={{ 'data-slot': 'phone-input' }}\n      className={cn(\n        'border-input dark:bg-input/30 flex h-9 w-full rounded-md border shadow-xs transition-[color,box-shadow]',\n        'has-[input:focus-visible]:border-ring has-[input:focus-visible]:ring-ring/50 has-[input:focus-visible]:ring-[3px]',\n        'has-[[aria-invalid=true]]:border-destructive has-[[aria-invalid=true]]:ring-destructive/20 dark:has-[[aria-invalid=true]]:ring-destructive/40',\n        'has-disabled:opacity-50',\n        className\n      )}\n      dir=\"ltr\"\n      international\n      flagComponent={Flag}\n      countrySelectComponent={CountrySelect}\n      inputComponent={PhoneNumberInput}\n      countries={countries}\n      defaultCountry={defaultCountry}\n      placeholder={placeholder}\n      disabled={disabled}\n      value={value ?? undefined}\n      onChange={(next) => onChange(next ?? '')}\n      {...props}\n    />\n  );\n}\n\nfunction PhoneNumberInput({ className, ...props }: React.ComponentProps<'input'>) {\n  return (\n    <Input\n      className={cn(\n        'h-full flex-1 rounded-none border-0 bg-transparent shadow-none focus-visible:ring-0 dark:bg-transparent',\n        className\n      )}\n      {...props}\n    />\n  );\n}\n\ninterface CountrySelectProps {\n  disabled?: boolean;\n  value: PhoneCountry | undefined;\n  onChange: (value: PhoneCountry | undefined) => void;\n  options: { label: string; value: PhoneCountry | undefined }[];\n}\n\nfunction CountrySelect({ disabled, value, onChange, options }: CountrySelectProps) {\n  return (\n    <div className=\"text-muted-foreground hover:bg-accent has-focus-visible:bg-accent relative inline-flex shrink-0 items-center gap-1 rounded-l-md border-r ps-3 pe-2 transition-colors has-disabled:pointer-events-none\">\n      <Flag country={value} countryName={value ?? ''} />\n      <ChevronDownIcon className=\"size-4 opacity-50\" aria-hidden=\"true\" />\n      <select\n        disabled={disabled}\n        value={value ?? ''}\n        onChange={(e) => onChange((e.target.value || undefined) as PhoneCountry | undefined)}\n        className=\"absolute inset-0 text-sm opacity-0\"\n        aria-label=\"Country\">\n        <option value=\"\">Select a country</option>\n        {options\n          .filter((option): option is { label: string; value: PhoneCountry } => !!option.value)\n          .map((option) => (\n            <option key={option.value} value={option.value}>\n              {option.label} +{RPNInput.getCountryCallingCode(option.value)}\n            </option>\n          ))}\n      </select>\n    </div>\n  );\n}\n\nfunction Flag({ country, countryName }: { country: PhoneCountry | undefined; countryName: string }) {\n  const FlagSvg = country ? flags[country] : undefined;\n\n  return (\n    <span className=\"flex h-3.5 w-5 items-center justify-center overflow-hidden rounded-[2px]\" aria-hidden=\"true\">\n      {FlagSvg ? <FlagSvg title={countryName} /> : <PhoneIcon className=\"size-4\" />}\n    </span>\n  );\n}\n",
      "type": "registry:component",
      "target": "components/dentil/phone-input/phone-input.tsx"
    }
  ],
  "type": "registry:component"
}
