Vue-phone-number-input is a Vue 2 component designed to provide a comprehensive international phone number input field. It leverages the robust `libphonenumber-js` library for accurate parsing, formatting, and validation of phone numbers. While the current stable version is 1.12.13, the package is explicitly marked as unmaintained by its author. It offers features such as country code selection, automatic number formatting while typing, validator state indication, locale detection, and accessibility improvements. However, for ongoing support, compatibility with newer Vue versions, and continued development, developers are strongly advised to migrate to the `MazPhoneNumberInput` component, which is available within the `maz-ui` library (v2.x for Vue 2 projects and v3.x for Vue 3 projects), as this standalone package receives no further updates.
npm install vue-phone-number-inputVerified import paths — ran on the pinned version, not inferred.
Demonstrates global registration and basic usage of the `VuePhoneNumberInput` component within a Vue 2 application, including v-model binding, setting a default country, preferred countries, and handling the `update` event to access parsed phone number details.
Migrate to `MazPhoneNumberInput` from the `maz-ui` library. Use `maz-ui` v2.x for Vue 2 projects or `maz-ui` v3.x for Vue 3 projects.
If working with Vue 3, use `MazPhoneNumberInput` from `maz-ui` v3.x which provides a compatible version of the component. Avoid trying to adapt this Vue 2 package to Vue 3.
Regularly monitor `libphonenumber-js` for updates. If using this unmaintained component, you may need to manually update `libphonenumber-js` and verify compatibility, or preferably, migrate to `maz-ui` which actively manages its dependencies.
Use CSS preprocessors with scoping features (e.g., Sass, Less) to override conflicting styles, or increase CSS specificity in your custom stylesheets. Consider encapsulating the component within a shadow DOM if deeper isolation is required, though this adds complexity.
This component is incompatible with Vue 3. Migrate to `MazPhoneNumberInput` from `maz-ui` v3.x.
Ensure `Vue` is imported and globally available (e.g., `import Vue from 'vue';`) and use `Vue.component('VuePhoneNumberInput', VuePhoneNumberInput);` without `.default` for ESM imports. If using UMD, refer to the documentation for correct `window.VuePhoneNumberInput.default` usage.Ensure `v-model` is bound to a string variable (e.g., `v-model="userPhoneNumber"`). The component emits a detailed object on the `@update` event, which should be handled separately if you need the full data.
Verify that the country code (e.g., 'US', 'FR', 'DE') is a valid ISO 3166-1 alpha-2 code and is recognized by `libphonenumber-js`. Refer to a list of standard country codes.