import { App, ComputedRef, Directive, MaybeRefOrGetter, ShallowRef } from "vue"; import { CountryKey, CountryKey as PCountryKey, Mask as PMask, MaskBase as PMaskBase, MaskBaseMap as PMaskBaseMap, MaskFull, MaskFull as PMaskFull, MaskFullMap as PMaskFullMap, MaskMap as PMaskMap, MaskWithFlag as PMaskWithFlag, MaskWithFlagMap as PMaskWithFlagMap } from "@desource/phone-mask"; import { FormatterHelpers } from "@desource/phone-mask/kit"; type Size = 'compact' | 'normal' | 'large'; type Theme = 'auto' | 'light' | 'dark'; type PhoneNumber = { full: string; fullFormatted: string; digits: string; }; interface UsePhoneMaskOptions { /** Controlled value — digits only, without country code */ value: MaybeRefOrGetter; /** Called when digits change */ onChange: (digits: string) => void; /** Country ISO 3166-1 alpha-2 code */ country?: MaybeRefOrGetter; /** Locale for country names (defaults to browser language) */ locale?: MaybeRefOrGetter; /** Auto-detect country via GeoIP */ detect?: MaybeRefOrGetter; /** Called on every phone number update */ onPhoneChange?: (data: PhoneNumber) => void; /** Called when country changes */ onCountryChange?: (country: MaskFull) => void; } interface UsePhoneMaskReturn { /** Bind this ref to your <input> element */ inputRef: ShallowRef; digits: ComputedRef; /** Phone formatter instance */ formatter: ComputedRef; full: ComputedRef; fullFormatted: ComputedRef; isComplete: ComputedRef; isEmpty: ComputedRef; shouldShowWarn: ComputedRef; country: ComputedRef; setCountry: (countryCode?: string | null) => boolean; clear: () => void; } interface PhoneInputProps { /** Optional id attribute applied to the underlying phone input element */ id?: string; /** Optional name attribute applied to the underlying phone input element */ name?: string; /** Whether to preselect a country by its ISO 3166-1 alpha-2 code */ country?: CountryKey; /** * Whether to auto-detect country via geo IP lookup. * Note: This requires an external geo IP service and may not work in all environments. * @default true */ detect?: boolean; /** Locale for country names (defaults to browser language) */ locale?: string; /** * Size preset for the component ("compact" | "normal" | "large"). * @default 'normal' */ size?: Size; /** * Theme preset for the component ("auto" | "light" | "dark"). * @default 'auto' */ theme?: Theme; /** * Whether the input is disabled. * @default false */ disabled?: boolean; /** * Whether the input is readonly. * @default false */ readonly?: boolean; /** * Whether to show the copy button. * @default true */ showCopy?: boolean; /** * Whether to show the clear button. * @default false */ showClear?: boolean; /** * Whether to show validation related styles (border & outline). * @default true */ withValidity?: boolean; /** * Custom search placeholder. * @default 'Search country or code...' */ searchPlaceholder?: string; /** * Custom no results text. * @default 'No countries found' */ noResultsText?: string; /** * Custom clear button label. * @default 'Clear phone number' */ clearButtonLabel?: string; /** Dropdown menu custom class */ dropdownClass?: string; /** * Whether to disable default internal styles. * @default false */ disableDefaultStyles?: boolean; } interface PhoneInputSlots { /** Slot for custom action buttons before default ones */ 'actions-before': {}; /** Slots for flag icons in the country list and country selector */ flag: { country: MaskFull; }; /** Slot for custom copy buttons */ 'copy-svg': { copied: boolean; }; /** Slot for custom clear button */ 'clear-svg': {}; } interface PhoneInputExposed { /** Focus the phone input */ focus: () => void; /** Blur the phone input */ blur: () => void; /** Clear the phone input */ clear: () => void; /** Select a country by its ISO 3166-1 alpha-2 code */ selectCountry: (country: CountryKey) => void; /** Get the full phone number with country code (e.g. +1234567890) */ getFullNumber: () => string; /** Get the full phone number formatted according to country rules (e.g. +1 234-567-890) */ getFullFormattedNumber: () => string; /** Get only the digits of the phone number without country code (e.g. 234567890) */ getDigits: () => string; /** Check if the current phone number is valid */ isValid: () => boolean; /** Check if the current phone number is complete */ isComplete: () => boolean; } /** Configuration options for the phone mask directive */ interface PMaskDirectiveOptions { /** Country ISO code (e.g., 'US', 'DE', 'GB') */ country?: string; /** Locale for country names (default: navigator.language) */ locale?: string; /** Auto-detect country from IP/locale (default: false) */ detect?: boolean; /** * Callback when formatted value changes. * Provides full number, formatted phone number, and raw digits. * @example * onChange: (phone) => { * console.log(phone.full); // +1234567890 * console.log(phone.fullFormatted); // +1 234-567-890 * console.log(phone.digits); // 234567890 * } */ onChange?: (phone: PhoneNumber) => void; /** Callback when country changes */ onCountryChange?: (country: MaskFull) => void; } /** Internal state stored on the input element of the directive */ interface PMaskDirectiveState { edited?: boolean; country: MaskFull; countryOption?: string; formatter: FormatterHelpers; digits: string; locale: string; options: PMaskDirectiveOptions; beforeInputHandler?: (e: InputEvent) => void; inputHandler?: (e: Event) => void; keydownHandler?: (e: KeyboardEvent) => void; pasteHandler?: (e: ClipboardEvent) => void; } /** Extended HTMLInputElement with directive state */ interface DirectiveHTMLInputElement extends HTMLInputElement { __phoneMaskState?: PMaskDirectiveState; } type __VLS_Props = PhoneInputProps; type __VLS_Slots = PhoneInputSlots; type __VLS_ModelProps = { modelValue?: string; }; type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps; declare const __VLS_base: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<__VLS_PublicProps>, { detect: boolean; size: string; theme: string; showCopy: boolean; showClear: boolean; withValidity: boolean; disabled: boolean; readonly: boolean; searchPlaceholder: string; noResultsText: string; clearButtonLabel: string; disableDefaultStyles: boolean; }>, PhoneInputExposed, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, { change: (value: PhoneNumber) => void; "country-change": (country: import("@desource/phone-mask").MaskFull) => void; "validation-change": (isValid: boolean) => void; focus: (event: FocusEvent) => void; blur: (event: FocusEvent) => void; copy: (value: string) => void; clear: () => void; "update:modelValue": (value: string) => void; }, string, import("vue").PublicProps, Readonly, { detect: boolean; size: string; theme: string; showCopy: boolean; showClear: boolean; withValidity: boolean; disabled: boolean; readonly: boolean; searchPlaceholder: string; noResultsText: string; clearButtonLabel: string; disableDefaultStyles: boolean; }>>> & { onChange?: ((value: PhoneNumber) => any) | undefined; onCopy?: ((value: string) => any) | undefined; "onCountry-change"?: ((country: import("@desource/phone-mask").MaskFull) => any) | undefined; "onValidation-change"?: ((isValid: boolean) => any) | undefined; onFocus?: ((event: FocusEvent) => any) | undefined; onBlur?: ((event: FocusEvent) => any) | undefined; onClear?: (() => any) | undefined; "onUpdate:modelValue"?: ((value: string) => any) | undefined; }, { detect: boolean; theme: Theme; size: Size; disabled: boolean; readonly: boolean; showCopy: boolean; showClear: boolean; withValidity: boolean; searchPlaceholder: string; noResultsText: string; clearButtonLabel: string; disableDefaultStyles: boolean; }, {}>; declare const __VLS_export: __VLS_WithSlots; declare const _default: typeof __VLS_export; type __VLS_TypePropsToOption = { [K in keyof T & string]-?: {} extends Pick ? { type: import('vue').PropType[K]>; } : { type: import('vue').PropType; required: true; }; }; type __VLS_WithDefaults = { [K in keyof P & string]: K extends keyof D ? __VLS_PrettifyLocal : P[K]; }; type __VLS_WithSlots = T & { new (): { $slots: S; }; }; type __VLS_PrettifyLocal = (T extends any ? { [K in keyof T]: T[K]; } : { [K in keyof T as K]: T[K]; }) & {}; /** * Update country and reformat existing input. * Updates formatter, placeholder, truncates digits if needed, and triggers callbacks */ declare function setCountry(el: HTMLInputElement, state: PMaskDirectiveState, newCountryCode: string, updateValue?: boolean): void; export declare const vPhoneMask: Directive; /** * Vue composable for phone number masking. * Provides low-level phone masking functionality for custom input implementations. * Works in controlled mode — caller manages value state via onChange callback. */ export declare function usePhoneMask(options: UsePhoneMaskOptions): UsePhoneMaskReturn; type TPhoneInputComponent = typeof _default; type TPhoneMaskDirective = typeof vPhoneMask; type TPhoneMaskSetCountryType = typeof setCountry; declare function install(app: App): void; declare const _default$1: { install: typeof install; }; export { type PCountryKey, type PMask, type PMaskBase, type PMaskBaseMap, type PMaskFull, type PMaskFullMap, type PMaskMap, type PhoneNumber as PMaskPhoneNumber, type PMaskWithFlag, type PMaskWithFlagMap, _default as PhoneInput, type Size as PhoneInputSize, type Theme as PhoneInputTheme, type TPhoneInputComponent, type TPhoneMaskDirective, type TPhoneMaskSetCountryType, type UsePhoneMaskOptions, type UsePhoneMaskReturn, _default$1 as default, install, setCountry as vPhoneMaskSetCountry };