import { CountryCode, getExampleNumber } from "libphonenumber-js"; import examples from "libphonenumber-js/examples.mobile.json"; import { getCountryCallingCode } from "libphonenumber-js/max"; export default function getFormat(countryCode: CountryCode) { let example = getExampleNumber( countryCode, examples )!.formatInternational(); const callingCode = getCountryCallingCode(countryCode); const callingCodeLen = callingCode.length + 1; example = example.slice(callingCodeLen); const mask = example.replace(/\d/g, "0"); return { example, mask }; }