@finofo/react-international-phone
Version:
☎️ International phone input component for React
35 lines (34 loc) • 1.16 kB
TypeScript
interface ApplyMaskArgs {
value: string;
mask: string;
maskSymbol: string;
/**
* Apply mask starting from provided char index
* @example
* value: "+12345678"
* mask: "(....)"
* offset === 2 -> "+1(2345)"
* offset === 5 -> "+1234(5678)"
*/
offset?: number;
/**
* @description Removes all non-maskSymbol chars from the result's ending if the value is shorter than the mask
* @example
* value: "1234"
* mask: "(....) ...."
* if true -> "(1234"
* if false -> "(1234) "
*/
trimNonMaskCharsLeftover?: boolean;
/**
* @description Allow input to exceed the mask length. When set to true, formatting mask will apply to the part that fits, and overflow digits will be appended at the end.
* @example
* value: "12345678"
* mask: "(....)"
* if true -> "(1234)5678" (formatted part + overflow)
* if false -> "(1234" (formatted but truncated)
*/
allowMaskOverflow?: boolean;
}
export declare const applyMask: ({ value, mask, maskSymbol, offset, trimNonMaskCharsLeftover, allowMaskOverflow, }: ApplyMaskArgs) => string;
export {};