intl-tel-input 21.1.4 → 21.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -6
- package/build/js/data.js +498 -243
- package/build/js/data.min.js +2 -2
- package/build/js/i18n/ar/countries.mjs +251 -0
- package/build/js/i18n/ar/index.mjs +4 -0
- package/build/js/i18n/ar/interface.mjs +10 -0
- package/build/js/i18n/bg/countries.mjs +251 -0
- package/build/js/i18n/bg/index.mjs +4 -0
- package/build/js/i18n/bg/interface.mjs +10 -0
- package/build/js/i18n/bn/countries.mjs +251 -0
- package/build/js/i18n/bn/index.mjs +4 -0
- package/build/js/i18n/bn/interface.mjs +10 -0
- package/build/js/i18n/de/countries.mjs +251 -0
- package/build/js/i18n/de/index.mjs +4 -0
- package/build/js/i18n/de/interface.mjs +10 -0
- package/build/js/i18n/el/countries.mjs +251 -0
- package/build/js/i18n/el/index.mjs +4 -0
- package/build/js/i18n/el/interface.mjs +10 -0
- package/build/js/i18n/en/countries.mjs +251 -0
- package/build/js/i18n/en/index.mjs +4 -0
- package/build/js/i18n/en/interface.mjs +10 -0
- package/build/js/i18n/es/countries.mjs +251 -0
- package/build/js/i18n/es/index.mjs +4 -0
- package/build/js/i18n/es/interface.mjs +10 -0
- package/build/js/i18n/fr/countries.mjs +251 -0
- package/build/js/i18n/fr/index.mjs +4 -0
- package/build/js/i18n/fr/interface.mjs +10 -0
- package/build/js/i18n/hi/countries.mjs +251 -0
- package/build/js/i18n/hi/index.mjs +4 -0
- package/build/js/i18n/hi/interface.mjs +10 -0
- package/build/js/i18n/hu/countries.mjs +251 -0
- package/build/js/i18n/hu/index.mjs +4 -0
- package/build/js/i18n/hu/interface.mjs +10 -0
- package/build/js/i18n/id/countries.mjs +251 -0
- package/build/js/i18n/id/index.mjs +4 -0
- package/build/js/i18n/id/interface.mjs +10 -0
- package/build/js/i18n/index.mjs +22 -0
- package/build/js/i18n/ja/countries.mjs +251 -0
- package/build/js/i18n/ja/index.mjs +4 -0
- package/build/js/i18n/ja/interface.mjs +10 -0
- package/build/js/i18n/ko/countries.mjs +251 -0
- package/build/js/i18n/ko/index.mjs +4 -0
- package/build/js/i18n/ko/interface.mjs +10 -0
- package/build/js/i18n/mr/countries.mjs +251 -0
- package/build/js/i18n/mr/index.mjs +4 -0
- package/build/js/i18n/mr/interface.mjs +10 -0
- package/build/js/i18n/nl/countries.mjs +251 -0
- package/build/js/i18n/nl/index.mjs +4 -0
- package/build/js/i18n/nl/interface.mjs +10 -0
- package/build/js/i18n/pt/countries.mjs +251 -0
- package/build/js/i18n/pt/index.mjs +4 -0
- package/build/js/i18n/pt/interface.mjs +10 -0
- package/build/js/i18n/ro/countries.mjs +251 -0
- package/build/js/i18n/ro/index.mjs +4 -0
- package/build/js/i18n/ro/interface.mjs +10 -0
- package/build/js/i18n/ru/countries.mjs +251 -0
- package/build/js/i18n/ru/index.mjs +4 -0
- package/build/js/i18n/ru/interface.mjs +10 -0
- package/build/js/i18n/te/countries.mjs +251 -0
- package/build/js/i18n/te/index.mjs +4 -0
- package/build/js/i18n/te/interface.mjs +10 -0
- package/build/js/i18n/th/countries.mjs +251 -0
- package/build/js/i18n/th/index.mjs +4 -0
- package/build/js/i18n/th/interface.mjs +10 -0
- package/build/js/i18n/tr/countries.mjs +251 -0
- package/build/js/i18n/tr/index.mjs +4 -0
- package/build/js/i18n/tr/interface.mjs +10 -0
- package/build/js/i18n/ur/countries.mjs +251 -0
- package/build/js/i18n/ur/index.mjs +4 -0
- package/build/js/i18n/ur/interface.mjs +10 -0
- package/build/js/intlTelInput.d.ts +268 -0
- package/build/js/intlTelInput.js +517 -252
- package/build/js/intlTelInput.min.js +2 -2
- package/package.json +4 -1
- package/react/build/IntlTelInput.cjs +1 -1
- package/react/build/IntlTelInput.d.ts +268 -0
- package/react/build/IntlTelInput.js +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# International Telephone Input [](https://app.travis-ci.com/jackocnr/intl-tel-input) <img src="https://img.shields.io/github/package-json/v/jackocnr/intl-tel-input.svg" alt="version"/> <img src="https://img.shields.io/npm/dm/intl-tel-input.svg" alt="downloads"/>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<img src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/react.png" alt="React logo" width="16px" /> NEWS: we now have our own <a href="https://intl-tel-input.com/examples/react-component.html">React component</a>! Play with it on <a href="https://intl-tel-input.com/storybook/">Storybook</a>.
|
|
4
4
|
|
|
5
|
-
<img src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/typescript.png" alt="Typescript logo" width="
|
|
5
|
+
<img src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/typescript.png" alt="Typescript logo" width="16px" /> NEWS: we now have our own Typescript type definitions (for both [the JavaScript plugin](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/intlTelInput.d.ts) and [the React component](https://github.com/jackocnr/intl-tel-input/blob/master/react/build/IntlTelInput.d.ts)), so no need to use `@types/intl-tel-input` any more!
|
|
6
|
+
|
|
7
|
+
🗣️ NEWS: we now provide [translation files](https://github.com/jackocnr/intl-tel-input/tree/master/build/js/i18n) for several common languages! [See them in action](https://intl-tel-input.com/examples/localise-countries.html).
|
|
6
8
|
|
|
7
9
|
International Telephone Input is a JavaScript plugin for entering and validating international telephone numbers. It takes a regular input field, adds a searchable country dropdown, auto-detects the user's country, displays a relevant placeholder number, formats the number as you type, and provides comprehensive validation methods.
|
|
8
10
|
|
|
@@ -53,6 +55,7 @@ By default, on mobile devices we show a fullscreen popup instead of the inline d
|
|
|
53
55
|
* Typescript type definitions provided
|
|
54
56
|
* Easily customise styles by overriding the provided CSS variables
|
|
55
57
|
* React component included
|
|
58
|
+
* Translations for all country names (etc) provided in many different languages
|
|
56
59
|
|
|
57
60
|
## Browser Compatibility
|
|
58
61
|
| Chrome | Firefox | Safari | Edge |
|
|
@@ -64,16 +67,16 @@ _Note: We have now dropped support for all versions of Internet Explorer because
|
|
|
64
67
|
## Getting Started (Using a CDN)
|
|
65
68
|
1. Add the CSS
|
|
66
69
|
```html
|
|
67
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@21.1
|
|
70
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@21.2.1/build/css/intlTelInput.css">
|
|
68
71
|
```
|
|
69
72
|
|
|
70
73
|
2. Add the plugin script and initialise it on your input element
|
|
71
74
|
```html
|
|
72
|
-
<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@21.1
|
|
75
|
+
<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@21.2.1/build/js/intlTelInput.min.js"></script>
|
|
73
76
|
<script>
|
|
74
77
|
const input = document.querySelector("#phone");
|
|
75
78
|
window.intlTelInput(input, {
|
|
76
|
-
utilsScript: "https://cdn.jsdelivr.net/npm/intl-tel-input@21.1
|
|
79
|
+
utilsScript: "https://cdn.jsdelivr.net/npm/intl-tel-input@21.2.1/build/js/utils.js",
|
|
77
80
|
});
|
|
78
81
|
</script>
|
|
79
82
|
```
|
|
@@ -139,6 +142,8 @@ You can always get the full international number (including country code) using
|
|
|
139
142
|
|
|
140
143
|
If you know the user's country, you can set it with `initialCountry` (e.g. `"us"` for the United States), and if you don't, we recommend setting `initialCountry` to `"auto"` (along with the `geoIpLookup` option) to determine the user's country based on their IP address.
|
|
141
144
|
|
|
145
|
+
If you know the user's language, you can utilise the included translations to localise the country names (etc) - [see example](https://intl-tel-input.com/examples/localise-countries.html).
|
|
146
|
+
|
|
142
147
|
## Initialisation Options
|
|
143
148
|
When you initialise the plugin, the first argument is the input element, and the second is an object containing any initialisation options you want, which are detailed below. Note: any options that take country codes should be [ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) codes.
|
|
144
149
|
|
|
@@ -234,9 +239,16 @@ Which will generate the following (hidden) elements, which will be automatically
|
|
|
234
239
|
|
|
235
240
|
**i18n**
|
|
236
241
|
Type: `Object` Default: `{}`
|
|
237
|
-
Allow localisation/customisation of country names and other plugin text.
|
|
242
|
+
Allow localisation/customisation of country names and other plugin text. There are two options: either import one of the [provided translation modules](https://github.com/jackocnr/intl-tel-input/tree/master/build/js/i18n) (see option 1 below), or define your own custom translations (see option 2 below). If defining your own, you will need to specify all country names (over 200 at last count - [see full list](https://github.com/jackocnr/intl-tel-input/blob/master/src/js/intl-tel-input/data.ts)) using their 2-character iso2 name, as well as the 7 interface keys listed below. [See example](https://intl-tel-input.com/examples/localise-countries.html).
|
|
238
243
|
|
|
239
244
|
```js
|
|
245
|
+
// OPTION 1: import one of the provided translation modules
|
|
246
|
+
import fr from "intl-tel-input/i18n/fr";
|
|
247
|
+
|
|
248
|
+
intlTelInput(input, { i18n: fr });
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
// OPTION 2: define your own custom translations
|
|
240
252
|
intlTelInput(input, {
|
|
241
253
|
i18n: {
|
|
242
254
|
// Country names (see full list here: https://github.com/jackocnr/intl-tel-input/blob/master/src/js/data.js)
|