feat: login form as a client component, theme toggle
This commit is contained in:
15
components/PhoneInput/utils/getFormat.ts
Normal file
15
components/PhoneInput/utils/getFormat.ts
Normal file
@ -0,0 +1,15 @@
|
||||
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 };
|
||||
}
|
||||
Reference in New Issue
Block a user