fn
maskPhoneCountryOptions
v0.0.14A dynamic phone mask that switches format based on the typed
country dialing code. The mask is a function of state: it reads the leading
digits, resolves the country via findPhoneCountry (dialing code → area
code → priority), and applies that country's template — falling back to a
generic international template until a code is recognized. Defaults to the full
PHONE_COUNTRIES set. The unmasked value is the digit string.
Examples
ts
// Typing "+1…" formats as US, "+380…" as Ukraine, etc.
const phone = useMaskedInput({ mask: maskPhoneCountryOptions() });
// <input v-bind="phone.bind">ts
maskPhoneCountryOptions({
countries: [{ code: '34', template: '+## ### ### ###' }], // Spain only
fallback: '+#############',
});Signature
ts
export function maskPhoneCountryOptions(params: MaskPhoneCountryParams ={ ... }Parameters
| Parameter | Type | Description |
|---|---|---|
params? | MaskPhoneCountryParams | Countries and fallback template |
Returns
MaskOptionsReady-to-use mask options (a function mask)| Property | Type | Description |
|---|---|---|
mask | Mask | The mask pattern (or a function of state). |
preprocessors? | readonly MaskPreprocessor[] | Normalizers run before conforming. |
postprocessors? | readonly MaskPostprocessor[] | Finishers run after conforming. |
overwriteMode? | OverwriteMode | Insert vs overwrite behavior. |