intl-tel-input 26.0.0-beta.1 → 26.0.2
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 +29 -26
- package/angular/README.md +1 -1
- package/angular/build/IntlTelInput.js +16 -6
- package/angular/build/IntlTelInputWithUtils.js +140 -191
- package/angular/build/types/intl-tel-input/i18n/index.d.ts +1 -0
- package/angular/build/types/intl-tel-input/i18n/zh-hk/index.d.ts +3 -0
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/i18n/ar/countries.js +245 -0
- package/build/js/i18n/ar/index.js +1 -0
- package/build/js/i18n/ar/interface.js +23 -0
- package/build/js/i18n/bg/countries.js +245 -0
- package/build/js/i18n/bg/index.js +1 -0
- package/build/js/i18n/bg/interface.js +13 -0
- package/build/js/i18n/bn/countries.js +245 -0
- package/build/js/i18n/bn/index.js +1 -0
- package/build/js/i18n/bn/interface.js +13 -0
- package/build/js/i18n/bs/countries.js +245 -0
- package/build/js/i18n/bs/index.js +1 -0
- package/build/js/i18n/bs/interface.js +20 -0
- package/build/js/i18n/ca/countries.js +245 -0
- package/build/js/i18n/ca/index.js +1 -0
- package/build/js/i18n/ca/interface.js +13 -0
- package/build/js/i18n/cs/countries.js +245 -0
- package/build/js/i18n/cs/index.js +1 -0
- package/build/js/i18n/cs/interface.js +20 -0
- package/build/js/i18n/da/countries.js +245 -0
- package/build/js/i18n/da/index.js +1 -0
- package/build/js/i18n/da/interface.js +13 -0
- package/build/js/i18n/de/countries.js +245 -0
- package/build/js/i18n/de/index.js +1 -0
- package/build/js/i18n/de/interface.js +13 -0
- package/build/js/i18n/ee/countries.js +245 -0
- package/build/js/i18n/ee/index.js +1 -0
- package/build/js/i18n/ee/interface.js +13 -0
- package/build/js/i18n/el/countries.js +245 -0
- package/build/js/i18n/el/index.js +1 -0
- package/build/js/i18n/el/interface.js +13 -0
- package/build/js/i18n/en/countries.js +245 -0
- package/build/js/i18n/en/interface.js +14 -0
- package/build/js/i18n/es/countries.js +245 -0
- package/build/js/i18n/es/index.js +1 -0
- package/build/js/i18n/es/interface.js +13 -0
- package/build/js/i18n/fa/countries.js +245 -0
- package/build/js/i18n/fa/index.js +1 -0
- package/build/js/i18n/fa/interface.js +13 -0
- package/build/js/i18n/fi/countries.js +245 -0
- package/build/js/i18n/fi/index.js +1 -0
- package/build/js/i18n/fi/interface.js +13 -0
- package/build/js/i18n/fr/countries.js +245 -0
- package/build/js/i18n/fr/index.js +1 -0
- package/build/js/i18n/fr/interface.js +13 -0
- package/build/js/i18n/hi/countries.js +245 -0
- package/build/js/i18n/hi/index.js +1 -0
- package/build/js/i18n/hi/interface.js +13 -0
- package/build/js/i18n/hr/countries.js +245 -0
- package/build/js/i18n/hr/index.js +1 -0
- package/build/js/i18n/hr/interface.js +20 -0
- package/build/js/i18n/hu/countries.js +245 -0
- package/build/js/i18n/hu/index.js +1 -0
- package/build/js/i18n/hu/interface.js +13 -0
- package/build/js/i18n/id/countries.js +245 -0
- package/build/js/i18n/id/index.js +1 -0
- package/build/js/i18n/id/interface.js +13 -0
- package/build/js/i18n/index.js +1 -0
- package/build/js/i18n/it/countries.js +245 -0
- package/build/js/i18n/it/index.js +1 -0
- package/build/js/i18n/it/interface.js +13 -0
- package/build/js/i18n/ja/countries.js +245 -0
- package/build/js/i18n/ja/index.js +1 -0
- package/build/js/i18n/ja/interface.js +13 -0
- package/build/js/i18n/ko/countries.js +245 -0
- package/build/js/i18n/ko/index.js +1 -0
- package/build/js/i18n/ko/interface.js +13 -0
- package/build/js/i18n/lt/countries.js +245 -0
- package/build/js/i18n/lt/interface.js +26 -0
- package/build/js/i18n/mr/countries.js +245 -0
- package/build/js/i18n/mr/index.js +1 -0
- package/build/js/i18n/mr/interface.js +13 -0
- package/build/js/i18n/nl/countries.js +245 -0
- package/build/js/i18n/nl/index.js +1 -0
- package/build/js/i18n/nl/interface.js +13 -0
- package/build/js/i18n/no/countries.js +245 -0
- package/build/js/i18n/no/index.js +1 -0
- package/build/js/i18n/no/interface.js +13 -0
- package/build/js/i18n/pl/countries.js +245 -0
- package/build/js/i18n/pl/index.js +1 -0
- package/build/js/i18n/pl/interface.js +19 -0
- package/build/js/i18n/pt/countries.js +245 -0
- package/build/js/i18n/pt/index.js +1 -0
- package/build/js/i18n/pt/interface.js +13 -0
- package/build/js/i18n/ro/countries.js +245 -0
- package/build/js/i18n/ro/index.js +1 -0
- package/build/js/i18n/ro/interface.js +18 -0
- package/build/js/i18n/ru/countries.js +245 -0
- package/build/js/i18n/ru/index.js +1 -0
- package/build/js/i18n/ru/interface.js +20 -0
- package/build/js/i18n/sk/countries.js +245 -0
- package/build/js/i18n/sk/index.js +1 -0
- package/build/js/i18n/sk/interface.js +20 -0
- package/build/js/i18n/sl/countries.js +245 -0
- package/build/js/i18n/sl/interface.js +25 -0
- package/build/js/i18n/sq/countries.js +245 -0
- package/build/js/i18n/sq/interface.js +14 -0
- package/build/js/i18n/sr/countries.js +245 -0
- package/build/js/i18n/sr/interface.js +21 -0
- package/build/js/i18n/sv/countries.js +245 -0
- package/build/js/i18n/sv/index.js +1 -0
- package/build/js/i18n/sv/interface.js +13 -0
- package/build/js/i18n/te/countries.js +245 -0
- package/build/js/i18n/te/index.js +1 -0
- package/build/js/i18n/te/interface.js +13 -0
- package/build/js/i18n/th/countries.js +245 -0
- package/build/js/i18n/th/index.js +1 -0
- package/build/js/i18n/th/interface.js +13 -0
- package/build/js/i18n/tr/countries.js +245 -0
- package/build/js/i18n/tr/index.js +1 -0
- package/build/js/i18n/tr/interface.js +13 -0
- package/build/js/i18n/uk/countries.js +245 -0
- package/build/js/i18n/uk/index.js +1 -0
- package/build/js/i18n/uk/interface.js +20 -0
- package/build/js/i18n/ur/countries.js +245 -0
- package/build/js/i18n/ur/index.js +1 -0
- package/build/js/i18n/ur/interface.js +13 -0
- package/build/js/i18n/uz/countries.js +245 -0
- package/build/js/i18n/uz/index.js +1 -0
- package/build/js/i18n/uz/interface.js +13 -0
- package/build/js/i18n/vi/countries.js +245 -0
- package/build/js/i18n/vi/index.js +1 -0
- package/build/js/i18n/vi/interface.js +13 -0
- package/build/js/i18n/zh/countries.js +245 -0
- package/build/js/i18n/zh/index.js +1 -0
- package/build/js/i18n/zh/interface.js +13 -0
- package/build/js/i18n/zh-hk/countries.js +245 -0
- package/build/js/i18n/zh-hk/index.js +18 -0
- package/build/js/i18n/zh-hk/interface.js +14 -0
- package/build/js/intlTelInput.d.ts +6 -0
- package/build/js/intlTelInput.js +17 -7
- package/build/js/intlTelInput.min.js +3 -3
- package/build/js/intlTelInputWithUtils.js +141 -192
- package/build/js/intlTelInputWithUtils.min.js +3 -3
- package/build/js/utils.js +53 -54
- package/package.json +2 -2
- package/react/README.md +4 -2
- package/react/build/IntlTelInput.cjs +16 -6
- package/react/build/IntlTelInput.d.ts +6 -0
- package/react/build/IntlTelInput.js +16 -6
- package/react/build/IntlTelInputWithUtils.cjs +140 -191
- package/react/build/IntlTelInputWithUtils.js +140 -191
- package/svelte/README.md +7 -9
- package/svelte/build/IntlTelInput.mjs +1446 -1440
- package/svelte/build/IntlTelInputWithUtils.mjs +1795 -1850
- package/vue/README.md +12 -10
- package/vue/build/IntlTelInput.vue.d.ts +2 -0
- package/vue/build/IntlTelInputWithUtils.vue.d.ts +2 -0
- package/vue/build/exports/IntlTelInput.mjs +17 -16
- package/vue/build/exports/IntlTelInputWithUtils.mjs +176 -236
- package/vue/build/intl-tel-input/i18n/index.d.ts +1 -0
- package/vue/build/intl-tel-input/i18n/zh-hk/index.d.ts +3 -0
- package/vue/build/{intl-tel-input-f0-6rrpA.mjs → intl-tel-input-DYFK-Vt4.mjs} +12 -6
package/README.md
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# International Telephone Input [](https://github.com/jackocnr/intl-tel-input/actions/workflows/ci.yml) <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
|
+
🗣️ NEWS: [v26.0.1](https://github.com/jackocnr/intl-tel-input/releases/tag/v26.0.1) released, with support for:
|
|
4
|
+
- Autocomplete
|
|
5
|
+
- TypeScript types for the Vue component
|
|
6
|
+
- Country names now generated with `Intl.DisplayNames` (reduced bundle size)
|
|
7
|
+
- A more easily customisable globe icon SVG
|
|
8
|
+
- Modernised CSS
|
|
9
|
+
- More control over number extensions
|
|
4
10
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
<img src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/angular.png" alt="Angular logo" width="16" /> NEWS: we now have our own <a href="https://github.com/jackocnr/intl-tel-input/tree/master/angular">Angular component</a>!
|
|
8
|
-
|
|
9
|
-
🗣️ NEWS: we now provide [translations](#translations) in over 40 languages! [See them in action](https://intl-tel-input.com/storybook/?path=/docs/intltelinput--i18n).
|
|
10
|
-
|
|
11
|
-
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. React, Vue and Angular components are also included.
|
|
11
|
+
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. [React](https://github.com/jackocnr/intl-tel-input/blob/master/react/README.md), [Vue](https://github.com/jackocnr/intl-tel-input/blob/master/vue/README.md), [Angular](https://github.com/jackocnr/intl-tel-input/blob/master/angular/README.md) and [Svelte (beta)](https://github.com/jackocnr/intl-tel-input/blob/master/svelte/README.md) components are also included.
|
|
12
12
|
|
|
13
13
|
<picture>
|
|
14
14
|
<source media="(prefers-color-scheme: dark)" srcset="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/vanilla-dark.png">
|
|
@@ -25,7 +25,7 @@ Use [Twilio's API to build phone verification, SMS 2FA, appointment reminders, m
|
|
|
25
25
|
|
|
26
26
|
## Table of Contents
|
|
27
27
|
|
|
28
|
-
- [React, Vue and
|
|
28
|
+
- [React, Vue, Angular and Svelte Components](#react-vue-angular-and-svelte-components)
|
|
29
29
|
- [Demo and Examples](#demo-and-examples)
|
|
30
30
|
- [Mobile](#mobile)
|
|
31
31
|
- [Features](#features)
|
|
@@ -44,11 +44,13 @@ Use [Twilio's API to build phone verification, SMS 2FA, appointment reminders, m
|
|
|
44
44
|
- [Contributing](#contributing)
|
|
45
45
|
- [Attributions](#attributions)
|
|
46
46
|
|
|
47
|
-
## React, Vue and
|
|
48
|
-
We now provide React, Vue and
|
|
47
|
+
## React, Vue, Angular and Svelte Components
|
|
48
|
+
We now provide React, Vue, Angular and Svelte (beta) components alongside the regular JavaScript plugin. This readme is for the JavaScript plugin. View the [React Component](https://github.com/jackocnr/intl-tel-input/blob/master/react/README.md), the [Vue Component](https://github.com/jackocnr/intl-tel-input/blob/master/vue/README.md) the [Angular Component](https://github.com/jackocnr/intl-tel-input/blob/master/angular/README.md), or the [Svelte component (beta)](https://github.com/jackocnr/intl-tel-input/blob/master/svelte/README.md).
|
|
49
49
|
|
|
50
50
|
## Demo and Examples
|
|
51
|
-
|
|
51
|
+
View the [live demo](https://intl-tel-input.com) for examples of how to use the various options, along with the relevant code snippets. Or play with the options yourself on [Storybook](https://intl-tel-input.com/storybook/?path=/docs/intltelinput--vanilla).
|
|
52
|
+
|
|
53
|
+
Alternatively, download and build the project yourself in 3 simple steps. You just need to initialise the submodules with `git submodule update --init --recursive`, then run `npm install`, and then `npm run build`. You should now be able to open the included demo.html in your browser and have a working plugin!
|
|
52
54
|
|
|
53
55
|
## Mobile
|
|
54
56
|
By default, on mobile devices, we show a fullscreen popup instead of the inline dropdown to make better use of the limited screen space. This is similar to how a native `<select>` element works. You can control this behaviour with the `useFullscreenPopup` option. The popup can be closed by either selecting a country from the list or by tapping on the grey area on the sides. [See example](https://intl-tel-input.com/storybook/?path=/docs/intltelinput--usefullscreenpopup) (using the React component).
|
|
@@ -67,8 +69,8 @@ By default, on mobile devices, we show a fullscreen popup instead of the inline
|
|
|
67
69
|
* Accessibility provided via ARIA tags
|
|
68
70
|
* Typescript type definitions included
|
|
69
71
|
* Easily customise styles by overriding CSS variables, e.g. support dark mode
|
|
70
|
-
* React, Vue, and
|
|
71
|
-
* Translations
|
|
72
|
+
* React, Vue, Angular and Svelte components also included
|
|
73
|
+
* Translations provided in over 40 languages, as well as support for RTL layout and alternative numeral sets
|
|
72
74
|
* Lots of initialisation options for customisation, as well as instance methods/events for interaction
|
|
73
75
|
|
|
74
76
|
## Browser Compatibility
|
|
@@ -81,16 +83,16 @@ _Note: We have now dropped support for all versions of Internet Explorer because
|
|
|
81
83
|
## Getting Started (Using a CDN)
|
|
82
84
|
1. Add the CSS
|
|
83
85
|
```html
|
|
84
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@
|
|
86
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@26.0.2/build/css/intlTelInput.css">
|
|
85
87
|
```
|
|
86
88
|
|
|
87
89
|
2. Add the plugin script and initialise it on your input element
|
|
88
90
|
```html
|
|
89
|
-
<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@
|
|
91
|
+
<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@26.0.2/build/js/intlTelInput.min.js"></script>
|
|
90
92
|
<script>
|
|
91
93
|
const input = document.querySelector("#phone");
|
|
92
94
|
window.intlTelInput(input, {
|
|
93
|
-
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@
|
|
95
|
+
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@26.0.2/build/js/utils.js"),
|
|
94
96
|
});
|
|
95
97
|
</script>
|
|
96
98
|
```
|
|
@@ -187,7 +189,7 @@ The locale to pass to `Intl.DisplayNames` to generate the country names.
|
|
|
187
189
|
|
|
188
190
|
**countryOrder**
|
|
189
191
|
Type: `Array` Default: `null`
|
|
190
|
-
Specify the ordering for the country list with an array of iso2 country codes. Any omitted countries will appear after those specified, in alphabetical order, e.g. setting `countryOrder` to `["jp", "kr"]` will result in the list: Japan, South Korea, Afghanistan, Albania, Algeria etc
|
|
192
|
+
Specify the ordering for the country list with an array of iso2 country codes. Any omitted countries will appear after those specified, in alphabetical order, e.g. setting `countryOrder` to `["jp", "kr"]` will result in the list: Japan, South Korea, Afghanistan, Albania, Algeria, etc. _Note: this replaces the legacy `preferredCountries` option (now removed)._
|
|
191
193
|
|
|
192
194
|
**countrySearch**
|
|
193
195
|
Type: `Boolean` Default: `true`
|
|
@@ -217,7 +219,7 @@ Fix the dropdown width to the input width (rather than being as wide as the long
|
|
|
217
219
|
|
|
218
220
|
**formatAsYouType**
|
|
219
221
|
Type: `Boolean` Default: `true`
|
|
220
|
-
Automatically format the number as the user types. This feature will be disabled if the user types their own formatting characters. Requires the [utils script to be loaded](#loading-the-utilities-script).
|
|
222
|
+
Automatically format the number as the user types. This feature will be disabled if the user types their own formatting characters. Requires the [utils script to be loaded](#loading-the-utilities-script). _Note: previously named `autoFormat`._
|
|
221
223
|
|
|
222
224
|
**formatOnDisplay**
|
|
223
225
|
Type: `Boolean` Default: `true`
|
|
@@ -265,9 +267,9 @@ This will generate the following (hidden) elements, which will be automatically
|
|
|
265
267
|
|
|
266
268
|
**i18n**
|
|
267
269
|
Type: `Object` Default: `{}`
|
|
268
|
-
Allows you to specify translation strings for the user interface text (e.g. the placeholder text for the country search input)
|
|
270
|
+
Allows you to specify translation strings for the user interface text (e.g. the placeholder text for the country search input). Country names are now automatically generated with `Intl.DisplayNames` (see `countryNameLocale` option), but they can also be overridden with this option, using the iso2 code as the key name (see example below).
|
|
269
271
|
|
|
270
|
-
If we don't currently support a language you need, it's easy to [contribute this](https://github.com/jackocnr/intl-tel-input/blob/master/.github/CONTRIBUTING.md#adding-a-new-translation) yourself - you only need to provide a handful of UI translation strings.
|
|
272
|
+
The easiest way to handle translations is to import one of the [provided translation modules](https://github.com/jackocnr/intl-tel-input/tree/master/src/js/intl-tel-input/i18n) and set the `i18n` initialisation option to that value (see option 1 below). You can also override one or more individual keys this way. Alternatively, you can provide your own custom translations (see option 2 below). If providing your own, please see the required UI strings listed below. [See example](https://intl-tel-input.com/examples/localise-countries.html). If we don't currently support a language you need, it's easy to [contribute this](https://github.com/jackocnr/intl-tel-input/blob/master/.github/CONTRIBUTING.md#adding-a-new-translation) yourself - you only need to provide a handful of UI translation strings. _Note: previously named `localizedCountries`._
|
|
271
273
|
|
|
272
274
|
Option 1: import one of the provided translation modules
|
|
273
275
|
```js
|
|
@@ -282,6 +284,8 @@ intlTelInput(input, {
|
|
|
282
284
|
i18n: {
|
|
283
285
|
...fr,
|
|
284
286
|
searchPlaceholder: "Recherche de pays",
|
|
287
|
+
// or override a specific country name
|
|
288
|
+
us: "United States",
|
|
285
289
|
},
|
|
286
290
|
});
|
|
287
291
|
```
|
|
@@ -320,12 +324,12 @@ Set the initial country selection by specifying its country code, e.g. `"us"` fo
|
|
|
320
324
|
Type: `() => Promise<module>` Default: `null`
|
|
321
325
|
This is one way to lazy load the included utils.js (to enable formatting/validation, etc) - see [Loading The Utilities Script](#loading-the-utilities-script) for more options.
|
|
322
326
|
|
|
323
|
-
The `loadUtils` option takes a function that returns a Promise resolving to the utils module
|
|
327
|
+
The `loadUtils` option takes a function that returns a Promise resolving to the utils module. You can `import` the utils module in different ways (examples below): (A) from a CDN, (B) from your own hosted version of [utils.js](https://cdn.jsdelivr.net/npm/intl-tel-input@26.0.2/build/js/utils.js), or (C) if you use a bundler like Webpack, Vite or Parcel, you can import it directly from the package. _Note: this replaces the `utilsScript` option (now removed)._
|
|
324
328
|
|
|
325
329
|
```js
|
|
326
330
|
// (A) import utils module from a CDN
|
|
327
331
|
intlTelInput(htmlInputElement, {
|
|
328
|
-
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@
|
|
332
|
+
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@26.0.2/build/js/utils.js"),
|
|
329
333
|
});
|
|
330
334
|
|
|
331
335
|
// (B) import utils module from your own hosted version of utils.js
|
|
@@ -361,8 +365,7 @@ Set this to false to hide the flags, e.g. for political reasons. Instead, it wil
|
|
|
361
365
|
|
|
362
366
|
**separateDialCode**
|
|
363
367
|
Type: `Boolean` Default: `false`
|
|
364
|
-
Display the selected country's international dial code next to the input, so it looks like it's part of the typed number. Since the user cannot edit the displayed dial code, they may try to type a new one - in this case, to avoid having two dial codes next to each other, we automatically open the country dropdown and put the
|
|
365
|
-
__Note: if the user enters their number with autofill or by copying and pasting it, and their number includes the international dial code, then this will be shown twice__
|
|
368
|
+
Display the selected country's international dial code next to the input, so it looks like it's part of the typed number. Since the user cannot edit the displayed dial code, they may try to type a new one - in this case, to avoid having two dial codes next to each other, we automatically open the country dropdown and put the newly typed dial code in the search input instead. So if they type +54, then Argentina will be highlighted in the dropdown, and they can simply press Enter to select it, updating the displayed dial code (this feature requires `allowDropdown` and `countrySearch` to be enabled). Play with this option on [Storybook](https://intl-tel-input.com/storybook/?path=/docs/intltelinput--separatedialcode) (using the React component). _Note: previously named `showSelectedDialCode`._
|
|
366
369
|
|
|
367
370
|
<img src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/separate-dial-code4.png" width="267" height="51" alt="Separate Dial Code">
|
|
368
371
|
|
|
@@ -447,7 +450,7 @@ if (error === intlTelInput.utils.validationError.TOO_SHORT) {
|
|
|
447
450
|
|
|
448
451
|
**isValidNumber**
|
|
449
452
|
(Note: only returns `true` for valid <ins>mobile numbers</ins> by default - see `allowedNumberTypes`)
|
|
450
|
-
Check if the current number is valid based on its length - [see example](https://intl-tel-input.com/examples/validation-practical.html), which should be sufficient for most use cases. See `isValidNumberPrecise` (DANGEROUS) for more precise validation, but the advantage of `isValidNumber` is that it is much more future-proof, as while countries around the world regularly update their number rules, they rarely change their number lengths. If this method returns `false`, you can use `getValidationError` to get more information. Requires the [utils script to be loaded](#loading-the-utilities-script).
|
|
453
|
+
Check if the current number is valid based on its length - [see example](https://intl-tel-input.com/examples/validation-practical.html), which should be sufficient for most use cases. See `isValidNumberPrecise` (DANGEROUS) for more precise validation, but the advantage of `isValidNumber` is that it is much more future-proof, as while countries around the world regularly update their number rules, they rarely change their number lengths. If this method returns `false`, you can use `getValidationError` to get more information. Requires the [utils script to be loaded](#loading-the-utilities-script). _Note: previously named `isPossibleNumber`._
|
|
451
454
|
```js
|
|
452
455
|
const isValid = iti.isValidNumber();
|
|
453
456
|
```
|
package/angular/README.md
CHANGED
|
@@ -54,7 +54,7 @@ import "intl-tel-input/styles";
|
|
|
54
54
|
|
|
55
55
|
See the [validation demo](https://github.com/jackocnr/intl-tel-input/blob/master/angular/demo/validation/validation.component.ts) for a more fleshed-out example of how to handle validation, or check out the [form demo](https://github.com/jackocnr/intl-tel-input/blob/master/angular/demo/form/form.component.ts) for an alternative approach using `ReactiveFormsModule`.
|
|
56
56
|
|
|
57
|
-
A note on the utils script (~260KB): if you're lazy loading the IntlTelInput chunk (and so less worried about filesize) then you can just `import { IntlTelInputComponent } from "intl-tel-input/angularWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/angular"` import, then you should couple this with the `loadUtils` initialisation option - you will need to host the [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) file, and then set the `loadUtils` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@
|
|
57
|
+
A note on the utils script (~260KB): if you're lazy loading the IntlTelInput chunk (and so less worried about filesize) then you can just `import { IntlTelInputComponent } from "intl-tel-input/angularWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/angular"` import, then you should couple this with the `loadUtils` initialisation option - you will need to host the [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) file, and then set the `loadUtils` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@26.0.2/build/js/utils.js"`.
|
|
58
58
|
|
|
59
59
|
## Props
|
|
60
60
|
|
|
@@ -2375,12 +2375,22 @@ var processAllCountries = (options) => {
|
|
|
2375
2375
|
};
|
|
2376
2376
|
var generateCountryNames = (countries, options) => {
|
|
2377
2377
|
const { countryNameLocale, i18n } = options;
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2378
|
+
let displayNames;
|
|
2379
|
+
try {
|
|
2380
|
+
const hasDisplayNames = typeof Intl !== "undefined" && typeof Intl.DisplayNames === "function";
|
|
2381
|
+
if (hasDisplayNames) {
|
|
2382
|
+
displayNames = new Intl.DisplayNames(countryNameLocale, {
|
|
2383
|
+
type: "region"
|
|
2384
|
+
});
|
|
2385
|
+
} else {
|
|
2386
|
+
displayNames = null;
|
|
2387
|
+
}
|
|
2388
|
+
} catch (e) {
|
|
2389
|
+
console.error(e);
|
|
2390
|
+
displayNames = null;
|
|
2391
|
+
}
|
|
2382
2392
|
for (const c of countries) {
|
|
2383
|
-
c.name = i18n[c.iso2] || (displayNames === null || displayNames === void 0 ? void 0 : displayNames.of(c.iso2.toUpperCase()));
|
|
2393
|
+
c.name = i18n[c.iso2] || (displayNames === null || displayNames === void 0 ? void 0 : displayNames.of(c.iso2.toUpperCase())) || "";
|
|
2384
2394
|
}
|
|
2385
2395
|
};
|
|
2386
2396
|
var processDialCodes = (countries) => {
|
|
@@ -3629,7 +3639,7 @@ var intlTelInput = Object.assign((input, options) => {
|
|
|
3629
3639
|
attachUtils,
|
|
3630
3640
|
startedLoadingUtilsScript: false,
|
|
3631
3641
|
startedLoadingAutoCountry: false,
|
|
3632
|
-
version: "26.0.
|
|
3642
|
+
version: "26.0.2"
|
|
3633
3643
|
});
|
|
3634
3644
|
var intl_tel_input_default = intlTelInput;
|
|
3635
3645
|
|