UNPKG

react-phone-number-input

Version:

Telephone number input React component

22 lines (20 loc) 492 B
import { getCountryCallingCode } from 'libphonenumber-js/core' export function getInputValuePrefix({ country, international, withCountryCallingCode, metadata }) { return country && international && !withCountryCallingCode ? `+${getCountryCallingCode(country, metadata)}` : '' } export function removeInputValuePrefix(value, prefix) { if (prefix) { value = value.slice(prefix.length) if (value[0] === ' ') { value = value.slice(1) } } return value }