import { CountryCode as CountryCode$1 } from 'libphonenumber-js/min'; export { CountryCode } from 'libphonenumber-js/min'; import { CountryCode } from 'libphonenumber-js'; /** * Configuration options for MaskDial */ interface MaskDialOptions { /** ISO 3166-1 alpha-2 country code (e.g., 'US', 'GB', 'IN') */ country?: CountryCode; /** Fallback country when auto-detection fails */ defaultCountry?: CountryCode; /** Show international format with country code prefix */ international?: boolean; /** Placeholder character for unfilled digits (default: none) */ placeholder?: string; /** Called after each format operation */ onFormat?: (data: FormatData) => void; /** Called when validation state changes */ onValidate?: (isValid: boolean, isPossible: boolean) => void; /** Called when detected country changes */ onCountryChange?: (country: CountryCode | undefined) => void; } /** * Data returned after formatting a phone number */ interface FormatData { /** Formatted display value */ formatted: string; /** E.164 format (e.g., +12025551234) */ e164: string | undefined; /** National format without country code */ national: string; /** Raw digits only */ digits: string; /** Detected or specified country ISO code */ country: CountryCode | undefined; /** Is the number valid for the detected country */ isValid: boolean; /** Is the number possibly valid (less strict) */ isPossible: boolean; /** Format template (e.g., "(xxx) xxx-xxxx") */ template: string | undefined; /** Country calling code (e.g., "1" for US) */ countryCallingCode: string | undefined; } /** * Public interface for MaskDial instances */ interface MaskDialInstance { /** Get current formatted value */ getValue(): string; /** Get E.164 format (+12025551234) */ getE164(): string | undefined; /** Get national format (e.g., (202) 555-1234) */ getNational(): string; /** Get international format (e.g., +1 202 555 1234) */ getInternational(): string; /** Get raw digits only */ getDigits(): string; /** Check if number is valid */ isValid(): boolean; /** Check if number is possibly valid (less strict) */ isPossible(): boolean; /** Get detected or specified country */ getCountry(): CountryCode | undefined; /** Get country calling code */ getCountryCallingCode(): string | undefined; /** Change the country */ setCountry(country: CountryCode): void; /** Get current options */ getOptions(): MaskDialOptions; /** Update options */ setOptions(options: Partial): void; /** Remove event listeners and cleanup */ destroy(): void; } /** * Result from core formatting operation */ interface FormatResult { formatted: string; e164: string | undefined; national: string; international: string; digits: string; country: CountryCode | undefined; countryCallingCode: string | undefined; isValid: boolean; isPossible: boolean; template: string | undefined; } declare global { interface JQuery { maskDial(options?: MaskDialOptions): JQuery; maskDial(method: 'instance'): MaskDialJQueryInstance | undefined; maskDial(method: 'destroy'): JQuery; maskDial(method: 'getValue'): string; maskDial(method: 'getE164'): string | undefined; maskDial(method: 'getNational'): string; maskDial(method: 'getInternational'): string; maskDial(method: 'getDigits'): string; maskDial(method: 'isValid'): boolean; maskDial(method: 'isPossible'): boolean; maskDial(method: 'getCountry'): CountryCode$1 | undefined; maskDial(method: 'setCountry', country: CountryCode$1): JQuery; maskDial(method: 'setOptions', options: Partial): JQuery; maskDial(methodOrOptions?: string | MaskDialOptions, ...args: unknown[]): any; } } /** * jQuery event names */ declare const JQUERY_EVENTS: { readonly FORMAT: "maskdial:format"; readonly VALIDATE: "maskdial:validate"; readonly COUNTRY_CHANGE: "maskdial:countrychange"; }; /** * jQuery MaskDial instance */ declare class MaskDialJQueryInstance implements MaskDialInstance { private $element; private element; private core; private isComposing; constructor($element: JQuery, options?: MaskDialOptions); /** * Attach jQuery event listeners */ private attachListeners; /** * Handle input event */ private handleInput; /** * Handle focus event */ private handleFocus; /** * Handle blur event */ private handleBlur; /** * Handle paste event */ private handlePaste; /** * Handle keydown event */ private handleKeydown; /** * Handle composition start */ private handleCompositionStart; /** * Handle composition end */ private handleCompositionEnd; /** * Format value and update input */ private formatValue; getValue(): string; getE164(): string | undefined; getNational(): string; getInternational(): string; getDigits(): string; isValid(): boolean; isPossible(): boolean; getCountry(): CountryCode$1 | undefined; getCountryCallingCode(): string | undefined; setCountry(country: CountryCode$1): void; getOptions(): MaskDialOptions; setOptions(options: Partial): void; destroy(): void; } /** * Initialize jQuery plugin */ declare function initJQueryPlugin(jQuery: JQueryStatic): void; /** * Core formatting engine - framework agnostic * Handles all phone number formatting logic without DOM dependencies */ declare class MaskDialCore { private options; private formatter; private lastFormatResult; private lastValidState; private lastCountry; constructor(options?: MaskDialOptions); /** * Normalize options with defaults */ private normalizeOptions; /** * Process input and return formatted result with cursor position */ processInput(newValue: string, oldValue?: string, oldCursorPosition?: number): { formatted: string; cursorPosition: number; data: FormatData; }; /** * Trigger appropriate callbacks based on state changes */ private triggerCallbacks; /** * Format a value without cursor calculation (for programmatic use) */ format(value: string): FormatData; /** * Get current formatted value */ getValue(): string; /** * Get E.164 format */ getE164(): string | undefined; /** * Get national format */ getNational(): string; /** * Get international format */ getInternational(): string; /** * Get raw digits */ getDigits(): string; /** * Check if current value is valid */ isValid(): boolean; /** * Check if current value is possibly valid */ isPossible(): boolean; /** * Get current country */ getCountry(): CountryCode$1 | undefined; /** * Get country calling code */ getCountryCallingCode(): string | undefined; /** * Set the country */ setCountry(country: CountryCode$1): void; /** * Get current options */ getOptions(): MaskDialOptions; /** * Update options */ setOptions(options: Partial): void; /** * Reset internal state */ reset(): void; } /** * Phone number formatter using libphonenumber-js * Provides caching for O(1) formatter instance retrieval */ declare class PhoneFormatter { private formatterCache; /** * Get or create a cached AsYouType formatter for the given country */ private getFormatter; /** * Format a phone number string */ format(input: string, country?: CountryCode$1): FormatResult; /** * Extract only digits from a string */ extractDigits(input: string): string; /** * Clear formatter cache */ clearCache(): void; } declare const phoneFormatter: PhoneFormatter; /** * Validation result with detailed information */ interface ValidationResult { isValid: boolean; isPossible: boolean; error?: string; } /** * Validate a phone number for a specific country */ declare function validatePhoneNumber(phoneNumber: string, country?: CountryCode$1): ValidationResult; /** * Get E.164 format if the number is valid */ declare function getE164(phoneNumber: string, country?: CountryCode$1): string | undefined; /** * Get national format */ declare function getNationalFormat(phoneNumber: string, country?: CountryCode$1): string; /** * Get international format */ declare function getInternationalFormat(phoneNumber: string, country?: CountryCode$1): string; /** * Detect the country from a phone number */ declare function detectCountry(phoneNumber: string): CountryCode$1 | undefined; /** * Check if a phone number looks like it could be international * (starts with + or 00) */ declare function isInternationalFormat(phoneNumber: string): boolean; export { type FormatData, type FormatResult, JQUERY_EVENTS, MaskDialCore, type MaskDialInstance, MaskDialJQueryInstance, type MaskDialOptions, PhoneFormatter, detectCountry, getE164, getInternationalFormat, getNationalFormat, initJQueryPlugin, isInternationalFormat, phoneFormatter, validatePhoneNumber };