{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"phone-input","type":"registry:ui","title":"Phone Input","description":"","dependencies":["react-phone-number-input"],"registryDependencies":["button","combobox","input","scroll-area"],"files":[{"path":"phone-input.tsx","type":"registry:ui","content":"\"use client\"\n\nimport type { ComponentProps } from \"react\"\nimport { createContext, useContext, useMemo, useState } from \"react\"\nimport * as BasePhoneInput from \"react-phone-number-input\"\nimport flags from \"react-phone-number-input/flags\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Button } from \"@/components/ui/button\"\nimport {\n Combobox,\n ComboboxContent,\n ComboboxEmpty,\n ComboboxInput,\n ComboboxItem,\n ComboboxList,\n ComboboxSeparator,\n ComboboxTrigger,\n ComboboxValue,\n} from \"@/components/ui/combobox\"\nimport { Input } from \"@/components/ui/input\"\nimport { ScrollArea } from \"@/components/ui/scroll-area\"\nimport { IconPlaceholder } from \"@/app/(create)/components/icon-placeholder\"\n\ntype PhoneInputSize = \"sm\" | \"default\" | \"lg\"\n\nconst PhoneInputContext = createContext<{\n variant: PhoneInputSize\n popupClassName?: string\n scrollAreaClassName?: string\n}>({\n variant: \"default\",\n popupClassName: undefined,\n scrollAreaClassName: undefined,\n})\n\ntype PhoneInputProps = Omit<\n ComponentProps<\"input\">,\n \"onChange\" | \"value\" | \"ref\"\n> &\n Omit<\n BasePhoneInput.Props,\n \"onChange\" | \"variant\" | \"popupClassName\" | \"scrollAreaClassName\"\n > & {\n onChange?: (value: BasePhoneInput.Value) => void\n variant?: PhoneInputSize\n popupClassName?: string\n scrollAreaClassName?: string\n }\n\nfunction PhoneInput({\n className,\n variant,\n popupClassName,\n scrollAreaClassName,\n onChange,\n value,\n ...props\n}: PhoneInputProps) {\n const phoneInputSize = variant || \"default\"\n return (\n \n onChange?.(value || (\"\" as BasePhoneInput.Value))}\n {...props}\n />\n \n )\n}\n\nfunction InputComponent({ className, ...props }: ComponentProps) {\n const { variant } = useContext(PhoneInputContext)\n\n return (\n \n )\n}\n\ntype CountryEntry = { label: string; value: BasePhoneInput.Country | undefined }\n\ntype CountrySelectProps = {\n disabled?: boolean\n value: BasePhoneInput.Country\n options: CountryEntry[]\n onChange: (country: BasePhoneInput.Country) => void\n}\n\nfunction CountrySelect({\n disabled,\n value: selectedCountry,\n options: countryList,\n onChange,\n}: CountrySelectProps) {\n const { variant, popupClassName } = useContext(PhoneInputContext)\n const [searchValue, setSearchValue] = useState(\"\")\n\n const filteredCountries = useMemo(() => {\n if (!searchValue) return countryList\n return countryList.filter(({ label }) =>\n label.toLowerCase().includes(searchValue.toLowerCase())\n )\n }, [countryList, searchValue])\n\n return (\n {\n if (country) {\n onChange(country)\n }\n }}\n >\n \n \n \n \n \n \n }\n />\n \n setSearchValue(e.target.value)}\n showTrigger={false}\n className=\"border-input focus-visible:border-border rounded-none border-0 px-0 py-2.5 shadow-none ring-0! outline-none! focus-visible:ring-0 focus-visible:ring-offset-0\"\n />\n \n \n No country found.\n \n \n
\n
\n \n {filteredCountries.map((item: CountryEntry) =>\n item.value ? (\n \n \n {item.label}\n \n {`+${BasePhoneInput.getCountryCallingCode(item.value)}`}\n \n \n ) : null\n )}\n \n
\n
\n
\n \n \n )\n}\n\nfunction FlagComponent({ country, countryName }: BasePhoneInput.FlagProps) {\n const Flag = flags[country]\n\n return (\n \n {Flag ? (\n \n ) : (\n \n )}\n \n )\n}\n\nexport { PhoneInput }","target":"components/neui/phone-input.tsx"}]}