UNPKG

intl-tel-input

Version:

A JavaScript plugin for entering and validating international telephone numbers

66 lines (65 loc) 2.76 kB
import { Country, Iso2 } from '../../intl-tel-input/data'; import { I18n } from '../../intl-tel-input/i18n/types'; import { NUMBER_TYPE_SET, PLACEHOLDER_MODES } from '../constants'; export type UtilsLoader = () => Promise<{ default: ItiUtils; }>; export type ItiUtils = { formatNumber(number: string, iso2: string | undefined, format?: number): string; formatNumberAsYouType(number: string, iso2: string | undefined): string; getCoreNumber(number: string, iso2: string | undefined): string; getExampleNumber(iso2: string | undefined, nationalMode: boolean, numberType: number, useE164?: boolean): string; getExtension(number: string, iso2: string | undefined): string; getNumberType(number: string, iso2: string | undefined): number; getValidationError(number: string, iso2: string | undefined): number; isPossibleNumber(number: string, iso2: string | undefined, numberType?: NumberType[] | null): boolean; isValidNumber(number: string, iso2: string | undefined, numberType?: NumberType[] | null): boolean; numberFormat: { NATIONAL: number; INTERNATIONAL: number; E164: number; RFC3966: number; }; numberType: Record<string, number>; }; type SetValues<T> = T extends ReadonlySet<infer U> ? U : never; export type NumberType = SetValues<typeof NUMBER_TYPE_SET>; type ValueOf<T> = T[keyof T]; export interface AllOptions { allowDropdown: boolean; allowedNumberTypes: NumberType[] | null; allowNumberExtensions: boolean; allowPhonewords: boolean; autoPlaceholder: ValueOf<typeof PLACEHOLDER_MODES>; containerClass: string; countryNameLocale: string; countryOrder: Iso2[] | null; countrySearch: boolean; customPlaceholder: ((selectedCountryPlaceholder: string, selectedCountryData: SelectedCountryData) => string) | null; dropdownAlwaysOpen: boolean; dropdownContainer: HTMLElement | null; excludeCountries: Iso2[]; fixDropdownWidth: boolean; formatAsYouType: boolean; formatOnDisplay: boolean; geoIpLookup: ((success: (iso2: Iso2) => void, failure: () => void) => void) | null; hiddenInput: ((telInputName: string) => { phone: string; country?: string; }) | null; i18n: I18n; initialCountry: Iso2 | "auto" | ""; loadUtils: UtilsLoader | null; nationalMode: boolean; onlyCountries: Iso2[]; placeholderNumberType: NumberType; searchInputClass: string; separateDialCode: boolean; showFlags: boolean; strictMode: boolean; useFullscreenPopup: boolean; } export type SomeOptions = Partial<AllOptions>; type EmptyObject = Record<string, never>; export type SelectedCountryData = Pick<Country, "iso2" | "dialCode" | "name"> | EmptyObject; export {};