diff --git a/components/ui/phone-input.tsx b/components/ui/phone-input.tsx index 05aa88f..b92ddf2 100644 --- a/components/ui/phone-input.tsx +++ b/components/ui/phone-input.tsx @@ -26,8 +26,8 @@ import { ScrollArea } from "@/components/ui/scroll-area"; import { cn } from "@/lib/utils"; type PhoneInputProps = Omit< - React.InputHTMLAttributes, - "onChange" | "value" + React.ComponentProps<"input">, + "onChange" | "value" | "ref" > & Omit, "onChange"> & { onChange?: (value: RPNInput.Value) => void; diff --git a/content/snippets/phone-input.mdx b/content/snippets/phone-input.mdx index 83ba8c9..3746110 100644 --- a/content/snippets/phone-input.mdx +++ b/content/snippets/phone-input.mdx @@ -32,8 +32,8 @@ import { cn } from "@/lib/utils"; import { ScrollArea } from "./scroll-area"; type PhoneInputProps = Omit< - React.InputHTMLAttributes, - "onChange" | "value" + React.ComponentProps<"input">, + "onChange" | "value" | "ref" > & Omit, "onChange"> & { onChange?: (value: RPNInput.Value) => void; @@ -59,7 +59,7 @@ const PhoneInput: React.ForwardRefExoticComponent = * * @param {E164Number | undefined} value - The entered value */ - onChange={(value) => onChange?.(value || "")} + onChange={(value) => onChange?.(value || ("" as RPNInput.Value))} {...props} /> ); @@ -78,41 +78,37 @@ const InputComponent = React.forwardRef( ); InputComponent.displayName = "InputComponent"; -type CountrySelectOption = { label: string; value: RPNInput.Country }; +type CountryEntry = { label: string; value: RPNInput.Country | undefined }; type CountrySelectProps = { disabled?: boolean; value: RPNInput.Country; - onChange: (value: RPNInput.Country) => void; - options: CountrySelectOption[]; + options: CountryEntry[]; + onChange: (country: RPNInput.Country) => void; }; const CountrySelect = ({ disabled, - value, + value: selectedCountry, + options: countryList, onChange, - options, }: CountrySelectProps) => { - const handleSelect = React.useCallback( - (country: RPNInput.Country) => { - onChange(country); - }, - [onChange], - ); - return (