intl-tel-input 25.5.2 → 25.7.0
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/CHANGELOG.md +29 -1
- package/README.md +9 -9
- package/angular/README.md +1 -1
- package/angular/build/IntlTelInput.js +81 -77
- package/angular/build/IntlTelInputWithUtils.js +146 -163
- package/angular/build/types/intl-tel-input/data.d.ts +7 -2
- package/angular/build/types/intl-tel-input.d.ts +4 -1
- package/build/css/intlTelInput.min.css +1 -1
- package/build/js/data.js +6 -6
- package/build/js/data.min.js +2 -2
- package/build/js/intlTelInput.d.ts +11 -3
- package/build/js/intlTelInput.js +82 -80
- package/build/js/intlTelInput.min.js +2 -2
- package/build/js/intlTelInputWithUtils.js +146 -165
- package/build/js/intlTelInputWithUtils.min.js +2 -2
- package/build/js/utils.js +22 -21
- package/package.json +3 -1
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +81 -79
- package/react/build/IntlTelInput.d.ts +11 -3
- package/react/build/IntlTelInput.js +81 -79
- package/react/build/IntlTelInputWithUtils.cjs +145 -164
- package/react/build/IntlTelInputWithUtils.js +145 -164
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +230 -238
- package/vue/build/IntlTelInputWithUtils.mjs +813 -843
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
1
|
See the Github Releases page for changelog: https://github.com/jackocnr/intl-tel-input/releases
|
|
2
2
|
|
|
3
|
-
Or to
|
|
3
|
+
Or to view a specific version, e.g. v20.0.0, update the URL accordingly, e.g. https://github.com/jackocnr/intl-tel-input/releases/tag/v20.0.0
|
|
4
|
+
|
|
5
|
+
## Breaking changes
|
|
6
|
+
|
|
7
|
+
- v25.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v25.0.0
|
|
8
|
+
- v24.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v24.0.0
|
|
9
|
+
- v23.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v23.0.0
|
|
10
|
+
- v22.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v22.0.0
|
|
11
|
+
- v21.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v21.0.0
|
|
12
|
+
- v20.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v20.0.0
|
|
13
|
+
- v19.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v19.0.0
|
|
14
|
+
- v18.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v18.0.0
|
|
15
|
+
- v17.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v17.0.0
|
|
16
|
+
- v16.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v16.0.0
|
|
17
|
+
- v15.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v15.0.0
|
|
18
|
+
- v14.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v14.0.0
|
|
19
|
+
- v13.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v13.0.0
|
|
20
|
+
- v12.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v12.0.0
|
|
21
|
+
- v11.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v11.0.0
|
|
22
|
+
- v10.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v10.0.0
|
|
23
|
+
- v9.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v9.0.0
|
|
24
|
+
- v8.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v8.0.0
|
|
25
|
+
- v7.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v7.0.0
|
|
26
|
+
- v6.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v6.0.0
|
|
27
|
+
- v5.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v5.0.0
|
|
28
|
+
- v4.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v4.0.0
|
|
29
|
+
- v3.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v3.0.0
|
|
30
|
+
- v2.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v2.0.0
|
|
31
|
+
- v1.0.0 https://github.com/jackocnr/intl-tel-input/releases/tag/v1.0.0
|
package/README.md
CHANGED
|
@@ -77,16 +77,16 @@ _Note: We have now dropped support for all versions of Internet Explorer because
|
|
|
77
77
|
## Getting Started (Using a CDN)
|
|
78
78
|
1. Add the CSS
|
|
79
79
|
```html
|
|
80
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@25.
|
|
80
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@25.7.0/build/css/intlTelInput.css">
|
|
81
81
|
```
|
|
82
82
|
|
|
83
83
|
2. Add the plugin script and initialise it on your input element
|
|
84
84
|
```html
|
|
85
|
-
<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@25.
|
|
85
|
+
<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@25.7.0/build/js/intlTelInput.min.js"></script>
|
|
86
86
|
<script>
|
|
87
87
|
const input = document.querySelector("#phone");
|
|
88
88
|
window.intlTelInput(input, {
|
|
89
|
-
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.
|
|
89
|
+
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.7.0/build/js/utils.js"),
|
|
90
90
|
});
|
|
91
91
|
</script>
|
|
92
92
|
```
|
|
@@ -229,9 +229,9 @@ _Note that the `failure` callback must be called in the event of an error, hence
|
|
|
229
229
|
|
|
230
230
|
**hiddenInput**
|
|
231
231
|
Type: `Function` Default: `null`
|
|
232
|
-
Allows the creation of hidden input fields within a form
|
|
232
|
+
Allows the creation of hidden input fields within a form, which, on submit, get populated with the (1) full international telephone number and (2) the selected country code. It accepts a function that receives the name of the main telephone input as an argument. This function should return an object with `phone` and (optionally) `country` properties to specify the names of the hidden inputs for the phone number and country code, respectively. This is useful for non-Ajax form submissions to ensure the full international number and country code are captured, especially when `nationalMode` is enabled.
|
|
233
233
|
|
|
234
|
-
***Note**: This feature requires the input to be inside a `<form>` element, as it listens for the `submit` event on the closest form element. Also note that since this uses `getNumber` internally, firstly it requires the [utils script to be loaded](#loading-the-utilities-script), and secondly it expects a valid number and so will only work correctly if you have used `isValidNumber` to validate the number before allowing the form submit to go through.
|
|
234
|
+
***Note**: This feature requires the input to be inside a `<form>` element, as it listens for the `submit` event on the closest form element. Also note that since this uses `getNumber` internally, firstly it requires the [utils script to be loaded](#loading-the-utilities-script), and secondly, it expects a valid number and so will only work correctly if you have used `isValidNumber` to validate the number before allowing the form submit to go through.
|
|
235
235
|
|
|
236
236
|
```js
|
|
237
237
|
intlTelInput(input, {
|
|
@@ -251,7 +251,7 @@ This will generate the following (hidden) elements, which will be automatically
|
|
|
251
251
|
|
|
252
252
|
**i18n**
|
|
253
253
|
Type: `Object` Default: `{}`
|
|
254
|
-
|
|
254
|
+
Allows you to specify translation strings for the 200+ country names, as well as other user interface text (e.g. the placeholder text for the country search input). The easiest way to do this is to import one of the [provided translation modules](https://github.com/jackocnr/intl-tel-input/tree/master/build/js/i18n) and set `i18n` to that value (see option 1 below). You can also override one or more individual keys this way (see option 1 below). Alternatively, you can provide your own custom translations (see option 2 below). If providing your own, you will need to specify all the country names (which can be copied from the country-list project, e.g. here are the [country names in French](https://github.com/umpirsky/country-list/blob/master/data/fr/country.json)), as well as a few UI strings (listed below). [See example](https://intl-tel-input.com/examples/localise-countries.html).
|
|
255
255
|
|
|
256
256
|
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, as we automatically pull in the country names from the country-list project.
|
|
257
257
|
|
|
@@ -297,7 +297,7 @@ intlTelInput(input, {
|
|
|
297
297
|
oneSearchResult: "1 result found",
|
|
298
298
|
// Screen reader text for when the search produces multiple results
|
|
299
299
|
multipleSearchResults: "${count} results found",
|
|
300
|
-
// For more complex pluralisation cases e.g. Polish or Arabic, you can implement your own logic
|
|
300
|
+
// For more complex pluralisation cases, e.g. Polish or Arabic, you can implement your own logic
|
|
301
301
|
// Note that if this function is defined, the plugin will ignore the "zero", "one" and "multiple" keys listed above
|
|
302
302
|
searchResultsText(count) {
|
|
303
303
|
if (count === 0) return "No results found";
|
|
@@ -322,7 +322,7 @@ The `loadUtils` option takes a function which returns a Promise which resolves t
|
|
|
322
322
|
```js
|
|
323
323
|
// (A) import utils module from a CDN
|
|
324
324
|
intlTelInput(htmlInputElement, {
|
|
325
|
-
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.
|
|
325
|
+
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.7.0/build/js/utils.js"),
|
|
326
326
|
});
|
|
327
327
|
|
|
328
328
|
// (B) import utils module from your own hosted version of utils.js
|
|
@@ -606,7 +606,7 @@ The `loadUtils` option takes a function which returns a Promise which resolves t
|
|
|
606
606
|
```js
|
|
607
607
|
// (A) import utils module from a CDN
|
|
608
608
|
intlTelInput(htmlInputElement, {
|
|
609
|
-
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.
|
|
609
|
+
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.7.0/build/js/utils.js"),
|
|
610
610
|
});
|
|
611
611
|
|
|
612
612
|
// (B) import utils module from your own hosted version of utils.js
|
package/angular/README.md
CHANGED
|
@@ -29,7 +29,7 @@ import "intl-tel-input/styles";
|
|
|
29
29
|
|
|
30
30
|
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.
|
|
31
31
|
|
|
32
|
-
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 IntlTelInput 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@25.
|
|
32
|
+
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 IntlTelInput 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@25.7.0/build/js/utils.js"`.
|
|
33
33
|
|
|
34
34
|
## Props
|
|
35
35
|
Here's a list of all of the current props you can pass to the IntlTelInput Angular component.
|
|
@@ -1324,18 +1324,18 @@ var rawCountryData = [
|
|
|
1324
1324
|
]
|
|
1325
1325
|
];
|
|
1326
1326
|
var allCountries = [];
|
|
1327
|
-
for (
|
|
1328
|
-
|
|
1329
|
-
allCountries[i] = {
|
|
1327
|
+
for (const c of rawCountryData) {
|
|
1328
|
+
allCountries.push({
|
|
1330
1329
|
name: "",
|
|
1331
|
-
//
|
|
1330
|
+
// populated in the plugin
|
|
1332
1331
|
iso2: c[0],
|
|
1333
1332
|
dialCode: c[1],
|
|
1334
1333
|
priority: c[2] || 0,
|
|
1335
1334
|
areaCodes: c[3] || null,
|
|
1336
1335
|
nodeById: {},
|
|
1336
|
+
// populated by the plugin
|
|
1337
1337
|
nationalPrefix: c[4] || null
|
|
1338
|
-
};
|
|
1338
|
+
});
|
|
1339
1339
|
}
|
|
1340
1340
|
var data_default = allCountries;
|
|
1341
1341
|
|
|
@@ -1606,10 +1606,23 @@ var allTranslations = Object.assign(Object.assign({}, countries_default), interf
|
|
|
1606
1606
|
var en_default = allTranslations;
|
|
1607
1607
|
|
|
1608
1608
|
// angular/build/temp/intl-tel-input.js
|
|
1609
|
-
for (
|
|
1610
|
-
|
|
1609
|
+
for (const c of data_default) {
|
|
1610
|
+
c.name = en_default[c.iso2];
|
|
1611
1611
|
}
|
|
1612
1612
|
var id = 0;
|
|
1613
|
+
var mq = (q) => {
|
|
1614
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia(q).matches;
|
|
1615
|
+
};
|
|
1616
|
+
var computeDefaultUseFullscreenPopup = () => {
|
|
1617
|
+
if (typeof navigator !== "undefined" && typeof window !== "undefined") {
|
|
1618
|
+
const isMobileUserAgent = /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
|
1619
|
+
const isNarrowViewport = mq("(max-width: 500px)");
|
|
1620
|
+
const isShortViewport = mq("(max-height: 600px)");
|
|
1621
|
+
const isCoarsePointer = mq("(pointer: coarse)");
|
|
1622
|
+
return isMobileUserAgent || isNarrowViewport || isCoarsePointer && isShortViewport;
|
|
1623
|
+
}
|
|
1624
|
+
return false;
|
|
1625
|
+
};
|
|
1613
1626
|
var defaults = {
|
|
1614
1627
|
//* Whether or not to allow the dropdown.
|
|
1615
1628
|
allowDropdown: true,
|
|
@@ -1656,11 +1669,7 @@ var defaults = {
|
|
|
1656
1669
|
//* Only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length.
|
|
1657
1670
|
strictMode: false,
|
|
1658
1671
|
//* Use full screen popup instead of dropdown for country list.
|
|
1659
|
-
useFullscreenPopup:
|
|
1660
|
-
//* We cannot just test screen size as some smartphones/website meta tags will report desktop resolutions.
|
|
1661
|
-
//* Note: to target Android Mobiles (and not Tablets), we must find 'Android' and 'Mobile'
|
|
1662
|
-
/Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || window.innerWidth <= 500
|
|
1663
|
-
) : false,
|
|
1672
|
+
useFullscreenPopup: computeDefaultUseFullscreenPopup(),
|
|
1664
1673
|
//* The number type to enforce during validation.
|
|
1665
1674
|
validationNumberTypes: ["MOBILE"]
|
|
1666
1675
|
};
|
|
@@ -1688,7 +1697,7 @@ var normaliseString = (s = "") => s.normalize("NFD").replace(/[\u0300-\u036f]/g,
|
|
|
1688
1697
|
var isRegionlessNanp = (number) => {
|
|
1689
1698
|
const numeric = getNumeric(number);
|
|
1690
1699
|
if (numeric.charAt(0) === "1") {
|
|
1691
|
-
const areaCode = numeric.
|
|
1700
|
+
const areaCode = numeric.substring(1, 4);
|
|
1692
1701
|
return regionlessNanpNumbers.includes(areaCode);
|
|
1693
1702
|
}
|
|
1694
1703
|
return false;
|
|
@@ -1788,6 +1797,16 @@ var Iti = class {
|
|
|
1788
1797
|
this._processDialCodes();
|
|
1789
1798
|
this._translateCountryNames();
|
|
1790
1799
|
this._sortCountries();
|
|
1800
|
+
this.countryByIso2 = new Map(this.countries.map((c) => [c.iso2, c]));
|
|
1801
|
+
this._cacheSearchTokens();
|
|
1802
|
+
}
|
|
1803
|
+
//* Precompute and cache country search tokens to speed up filtering
|
|
1804
|
+
_cacheSearchTokens() {
|
|
1805
|
+
for (const c of this.countries) {
|
|
1806
|
+
c.normalisedName = normaliseString(c.name);
|
|
1807
|
+
c.initials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
|
|
1808
|
+
c.dialCodePlus = `+${c.dialCode}`;
|
|
1809
|
+
}
|
|
1791
1810
|
}
|
|
1792
1811
|
//* Sort countries by countryOrder option (if present), then name.
|
|
1793
1812
|
_sortCountries() {
|
|
@@ -1819,13 +1838,12 @@ var Iti = class {
|
|
|
1819
1838
|
if (!this.dialCodeToIso2Map.hasOwnProperty(dialCode)) {
|
|
1820
1839
|
this.dialCodeToIso2Map[dialCode] = [];
|
|
1821
1840
|
}
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
}
|
|
1841
|
+
const iso2List = this.dialCodeToIso2Map[dialCode];
|
|
1842
|
+
if (iso2List.includes(iso2)) {
|
|
1843
|
+
return;
|
|
1826
1844
|
}
|
|
1827
|
-
const index = priority !== void 0 ? priority :
|
|
1828
|
-
|
|
1845
|
+
const index = priority !== void 0 ? priority : iso2List.length;
|
|
1846
|
+
iso2List[index] = iso2;
|
|
1829
1847
|
}
|
|
1830
1848
|
//* Process onlyCountries or excludeCountries array if present.
|
|
1831
1849
|
_processAllCountries() {
|
|
@@ -1842,33 +1860,30 @@ var Iti = class {
|
|
|
1842
1860
|
}
|
|
1843
1861
|
//* Translate Countries by object literal provided on config.
|
|
1844
1862
|
_translateCountryNames() {
|
|
1845
|
-
for (
|
|
1846
|
-
const iso2 =
|
|
1863
|
+
for (const c of this.countries) {
|
|
1864
|
+
const iso2 = c.iso2.toLowerCase();
|
|
1847
1865
|
if (this.options.i18n.hasOwnProperty(iso2)) {
|
|
1848
|
-
|
|
1866
|
+
c.name = this.options.i18n[iso2];
|
|
1849
1867
|
}
|
|
1850
1868
|
}
|
|
1851
1869
|
}
|
|
1852
1870
|
//* Generate this.dialCodes and this.dialCodeToIso2Map.
|
|
1853
1871
|
_processDialCodes() {
|
|
1854
|
-
this.dialCodes =
|
|
1872
|
+
this.dialCodes = /* @__PURE__ */ new Set();
|
|
1855
1873
|
this.dialCodeMaxLen = 0;
|
|
1856
1874
|
this.dialCodeToIso2Map = {};
|
|
1857
|
-
for (
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
this.dialCodes[c.dialCode] = true;
|
|
1875
|
+
for (const c of this.countries) {
|
|
1876
|
+
if (!this.dialCodes.has(c.dialCode)) {
|
|
1877
|
+
this.dialCodes.add(c.dialCode);
|
|
1861
1878
|
}
|
|
1862
1879
|
this._addToDialCodeMap(c.iso2, c.dialCode, c.priority);
|
|
1863
1880
|
}
|
|
1864
|
-
for (
|
|
1865
|
-
const c = this.countries[i];
|
|
1881
|
+
for (const c of this.countries) {
|
|
1866
1882
|
if (c.areaCodes) {
|
|
1867
1883
|
const rootIso2Code = this.dialCodeToIso2Map[c.dialCode][0];
|
|
1868
|
-
for (
|
|
1869
|
-
const areaCode = c.areaCodes[j];
|
|
1884
|
+
for (const areaCode of c.areaCodes) {
|
|
1870
1885
|
for (let k = 1; k < areaCode.length; k++) {
|
|
1871
|
-
const partialAreaCode = areaCode.
|
|
1886
|
+
const partialAreaCode = areaCode.substring(0, k);
|
|
1872
1887
|
const partialDialCode = c.dialCode + partialAreaCode;
|
|
1873
1888
|
this._addToDialCodeMap(rootIso2Code, partialDialCode);
|
|
1874
1889
|
this._addToDialCodeMap(c.iso2, partialDialCode);
|
|
@@ -2246,7 +2261,7 @@ var Iti = class {
|
|
|
2246
2261
|
//* Adhere to the input's maxlength attr.
|
|
2247
2262
|
_cap(number) {
|
|
2248
2263
|
const max = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
|
|
2249
|
-
return max && number.length > max ? number.
|
|
2264
|
+
return max && number.length > max ? number.substring(0, max) : number;
|
|
2250
2265
|
}
|
|
2251
2266
|
//* Trigger a custom event on the input.
|
|
2252
2267
|
_trigger(name, detailProps = {}) {
|
|
@@ -2372,9 +2387,8 @@ var Iti = class {
|
|
|
2372
2387
|
}
|
|
2373
2388
|
//* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
|
|
2374
2389
|
_searchForCountry(query) {
|
|
2375
|
-
for (
|
|
2376
|
-
const
|
|
2377
|
-
const startsWith = c.name.substr(0, query.length).toLowerCase() === query;
|
|
2390
|
+
for (const c of this.countries) {
|
|
2391
|
+
const startsWith = c.name.substring(0, query.length).toLowerCase() === query;
|
|
2378
2392
|
if (startsWith) {
|
|
2379
2393
|
const listItem = c.nodeById[this.id];
|
|
2380
2394
|
this._highlightListItem(listItem, false);
|
|
@@ -2395,23 +2409,20 @@ var Iti = class {
|
|
|
2395
2409
|
const dialCodeMatches = [];
|
|
2396
2410
|
const dialCodeContains = [];
|
|
2397
2411
|
const initialsMatches = [];
|
|
2398
|
-
for (
|
|
2399
|
-
const c = this.countries[i];
|
|
2400
|
-
const normalisedCountryName = normaliseString(c.name);
|
|
2401
|
-
const countryInitials = c.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((word) => word[0]).join("").toLowerCase();
|
|
2412
|
+
for (const c of this.countries) {
|
|
2402
2413
|
if (isReset || queryLength === 0) {
|
|
2403
2414
|
nameContains.push(c);
|
|
2404
|
-
} else if (c.iso2
|
|
2415
|
+
} else if (c.iso2 === normalisedQuery) {
|
|
2405
2416
|
iso2Matches.push(c);
|
|
2406
|
-
} else if (
|
|
2417
|
+
} else if (c.normalisedName.startsWith(normalisedQuery)) {
|
|
2407
2418
|
nameStartWith.push(c);
|
|
2408
|
-
} else if (
|
|
2419
|
+
} else if (c.normalisedName.includes(normalisedQuery)) {
|
|
2409
2420
|
nameContains.push(c);
|
|
2410
|
-
} else if (normalisedQuery === c.dialCode || normalisedQuery ===
|
|
2421
|
+
} else if (normalisedQuery === c.dialCode || normalisedQuery === c.dialCodePlus) {
|
|
2411
2422
|
dialCodeMatches.push(c);
|
|
2412
|
-
} else if (
|
|
2423
|
+
} else if (c.dialCodePlus.includes(normalisedQuery)) {
|
|
2413
2424
|
dialCodeContains.push(c);
|
|
2414
|
-
} else if (
|
|
2425
|
+
} else if (c.initials.includes(normalisedQuery)) {
|
|
2415
2426
|
initialsMatches.push(c);
|
|
2416
2427
|
}
|
|
2417
2428
|
}
|
|
@@ -2528,9 +2539,9 @@ var Iti = class {
|
|
|
2528
2539
|
const alreadySelected = selectedIso2 && iso2Codes.includes(selectedIso2) && !hasAreaCodesButNoneMatched;
|
|
2529
2540
|
const isRegionlessNanpNumber = selectedDialCode === "1" && isRegionlessNanp(numeric);
|
|
2530
2541
|
if (!isRegionlessNanpNumber && !alreadySelected) {
|
|
2531
|
-
for (
|
|
2532
|
-
if (
|
|
2533
|
-
return
|
|
2542
|
+
for (const iso2 of iso2Codes) {
|
|
2543
|
+
if (iso2) {
|
|
2544
|
+
return iso2;
|
|
2534
2545
|
}
|
|
2535
2546
|
}
|
|
2536
2547
|
}
|
|
@@ -2563,12 +2574,11 @@ var Iti = class {
|
|
|
2563
2574
|
}
|
|
2564
2575
|
}
|
|
2565
2576
|
//* Find the country data for the given iso2 code
|
|
2566
|
-
//* the
|
|
2577
|
+
//* the allowFail option is only used during init() for the initialCountry option, and for the iso2 returned from geoIpLookup - in these 2 cases we don't want to error out
|
|
2567
2578
|
_getCountryData(iso2, allowFail) {
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
}
|
|
2579
|
+
const country = this.countryByIso2.get(iso2);
|
|
2580
|
+
if (country) {
|
|
2581
|
+
return country;
|
|
2572
2582
|
}
|
|
2573
2583
|
if (allowFail) {
|
|
2574
2584
|
return null;
|
|
@@ -2777,11 +2787,11 @@ var Iti = class {
|
|
|
2777
2787
|
numericChars += c;
|
|
2778
2788
|
if (includeAreaCode) {
|
|
2779
2789
|
if (this.dialCodeToIso2Map[numericChars]) {
|
|
2780
|
-
dialCode = number.
|
|
2790
|
+
dialCode = number.substring(0, i + 1);
|
|
2781
2791
|
}
|
|
2782
2792
|
} else {
|
|
2783
|
-
if (this.dialCodes
|
|
2784
|
-
dialCode = number.
|
|
2793
|
+
if (this.dialCodes.has(numericChars)) {
|
|
2794
|
+
dialCode = number.substring(0, i + 1);
|
|
2785
2795
|
break;
|
|
2786
2796
|
}
|
|
2787
2797
|
}
|
|
@@ -2814,7 +2824,7 @@ var Iti = class {
|
|
|
2814
2824
|
if (dialCode) {
|
|
2815
2825
|
dialCode = `+${this.selectedCountryData.dialCode}`;
|
|
2816
2826
|
const start = number[dialCode.length] === " " || number[dialCode.length] === "-" ? dialCode.length + 1 : dialCode.length;
|
|
2817
|
-
number = number.
|
|
2827
|
+
number = number.substring(start);
|
|
2818
2828
|
}
|
|
2819
2829
|
}
|
|
2820
2830
|
return this._cap(number);
|
|
@@ -2933,38 +2943,32 @@ var Iti = class {
|
|
|
2933
2943
|
}
|
|
2934
2944
|
return -99;
|
|
2935
2945
|
}
|
|
2936
|
-
//* Validate the input val
|
|
2946
|
+
//* Validate the input val (with precise=false)
|
|
2937
2947
|
isValidNumber() {
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
if (alphaCharPosition > -1) {
|
|
2944
|
-
const beforeAlphaChar = val.substring(0, alphaCharPosition);
|
|
2945
|
-
const beforeAlphaIsValid = this._utilsIsPossibleNumber(beforeAlphaChar);
|
|
2946
|
-
const isValid = this._utilsIsPossibleNumber(val);
|
|
2947
|
-
return beforeAlphaIsValid && isValid;
|
|
2948
|
-
}
|
|
2949
|
-
return this._utilsIsPossibleNumber(val);
|
|
2948
|
+
return this._validateNumber(false);
|
|
2949
|
+
}
|
|
2950
|
+
//* Validate the input val (with precise=true)
|
|
2951
|
+
isValidNumberPrecise() {
|
|
2952
|
+
return this._validateNumber(true);
|
|
2950
2953
|
}
|
|
2951
2954
|
_utilsIsPossibleNumber(val) {
|
|
2952
2955
|
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
2953
2956
|
}
|
|
2954
|
-
//*
|
|
2955
|
-
|
|
2957
|
+
//* Shared internal validation logic to handle alpha character extension rules.
|
|
2958
|
+
_validateNumber(precise) {
|
|
2956
2959
|
if (!this.selectedCountryData.iso2) {
|
|
2957
2960
|
return false;
|
|
2958
2961
|
}
|
|
2959
2962
|
const val = this._getFullNumber();
|
|
2960
2963
|
const alphaCharPosition = val.search(/\p{L}/u);
|
|
2964
|
+
const testValidity = (s) => precise ? this._utilsIsValidNumber(s) : this._utilsIsPossibleNumber(s);
|
|
2961
2965
|
if (alphaCharPosition > -1) {
|
|
2962
2966
|
const beforeAlphaChar = val.substring(0, alphaCharPosition);
|
|
2963
|
-
const beforeAlphaIsValid =
|
|
2964
|
-
const isValid =
|
|
2967
|
+
const beforeAlphaIsValid = testValidity(beforeAlphaChar);
|
|
2968
|
+
const isValid = testValidity(val);
|
|
2965
2969
|
return beforeAlphaIsValid && isValid;
|
|
2966
2970
|
}
|
|
2967
|
-
return
|
|
2971
|
+
return testValidity(val);
|
|
2968
2972
|
}
|
|
2969
2973
|
_utilsIsValidNumber(val) {
|
|
2970
2974
|
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
@@ -3054,7 +3058,7 @@ var intlTelInput = Object.assign((input, options) => {
|
|
|
3054
3058
|
attachUtils,
|
|
3055
3059
|
startedLoadingUtilsScript: false,
|
|
3056
3060
|
startedLoadingAutoCountry: false,
|
|
3057
|
-
version: "25.
|
|
3061
|
+
version: "25.7.0"
|
|
3058
3062
|
});
|
|
3059
3063
|
var intl_tel_input_default = intlTelInput;
|
|
3060
3064
|
|