import { ChangeEventHandler, MutableRefObject } from 'react'; import { CountryCode, NationalNumber } from 'libphonenumber-js'; type PhoneNumberInputContextProps = { defaultValue?: string; defaultCountry: CountryCode; /** * Set the input's placeholder to an example number for the selected country, * and update it if the country changes. * * By default it is set to "polite", which means it will only set the * placeholder if the input doesn't already have one. You can also set it to * "aggressive", which will replace any existing placeholder, or "off" to not * show any example numbers in the placeholder. */ examplePlaceholder?: 'polite' | 'aggressive' | 'off'; /** * Examples to retrieve placeholder number from, if any. Defaults to * `resources/examples` if none provided. */ examples?: { [country in CountryCode]: NationalNumber; }; placeholder?: string; /** * Whether international phone numbers are allowed. Defaults to `true`. * If allowed, the phone number input will be prefixed with the country code, * and the selected country will be displayed in the input's left add-on, and * autoformatting will be enabled. */ allowInternational?: boolean; /** * Callback that will be called when the value in the phone number input field * changes. */ onChange: (val: string) => void; /** * Optional. Callback that will be called when the phone number input field is * blurred. */ onBlur?: () => void; }; type PhoneNumberInputContextReturn = { inputValue: string; country: CountryCode; innerInputRef: MutableRefObject; handleInputChange: ChangeEventHandler; handleInputBlur: () => void; handleCountryChange: (newCountry: CountryCode) => void; inputPlaceholder: string | undefined; isDisabled?: boolean; }; export type PhoneNumberInputProviderProps = PhoneNumberInputContextProps & { children?: React.ReactNode; }; /** * Provider component that makes context object available to any * child component that calls `usePhoneNumberInput()`. */ export declare const PhoneNumberInputProvider: ({ children, ...contextProps }: PhoneNumberInputProviderProps) => JSX.Element; /** * Hook for components nested in PhoneNumberProvider component to get the * current context object. */ export declare const usePhoneNumberInput: () => PhoneNumberInputContextReturn; export {};