intl-tel-input 25.13.0 → 25.13.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 +5 -5
- package/angular/README.md +1 -1
- package/angular/build/IntlTelInput.js +34 -25
- package/angular/build/IntlTelInputWithUtils.js +34 -25
- package/angular/build/types/modules/core/ui.d.ts +3 -1
- package/angular/build/types/modules/data/country-data.d.ts +1 -1
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput.d.ts +4 -2
- package/build/js/intlTelInput.js +37 -27
- package/build/js/intlTelInput.min.js +3 -3
- package/build/js/intlTelInputWithUtils.js +37 -27
- package/build/js/intlTelInputWithUtils.min.js +3 -3
- package/package.json +1 -1
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +36 -26
- package/react/build/IntlTelInput.d.ts +4 -2
- package/react/build/IntlTelInput.js +36 -26
- package/react/build/IntlTelInputWithUtils.cjs +36 -26
- package/react/build/IntlTelInputWithUtils.js +36 -26
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +223 -225
- package/vue/build/IntlTelInputWithUtils.mjs +147 -149
|
@@ -2236,6 +2236,7 @@ var buildClearIcon = (id2) => {
|
|
|
2236
2236
|
var UI = class {
|
|
2237
2237
|
constructor(input, options, id2) {
|
|
2238
2238
|
this.highlightedItem = null;
|
|
2239
|
+
this.selectedItem = null;
|
|
2239
2240
|
input.dataset.intlTelInputId = id2.toString();
|
|
2240
2241
|
this.telInput = input;
|
|
2241
2242
|
this.options = options;
|
|
@@ -2497,8 +2498,7 @@ var UI = class {
|
|
|
2497
2498
|
for (let i = 0; i < this.countries.length; i++) {
|
|
2498
2499
|
const c = this.countries[i];
|
|
2499
2500
|
const liClass = buildClassNames({
|
|
2500
|
-
[CLASSES.COUNTRY_ITEM]: true
|
|
2501
|
-
[CLASSES.HIGHLIGHT]: i === 0
|
|
2501
|
+
[CLASSES.COUNTRY_ITEM]: true
|
|
2502
2502
|
});
|
|
2503
2503
|
const listItem = createEl("li", {
|
|
2504
2504
|
id: `iti-${this.id}__item-${c.iso2}`,
|
|
@@ -2601,17 +2601,15 @@ var UI = class {
|
|
|
2601
2601
|
container.scrollTop = newScrollTop - heightDifference;
|
|
2602
2602
|
}
|
|
2603
2603
|
}
|
|
2604
|
-
//* Remove highlighting from
|
|
2604
|
+
//* Remove highlighting from the previous list item and highlight the new one.
|
|
2605
2605
|
highlightListItem(listItem, shouldFocus) {
|
|
2606
2606
|
const prevItem = this.highlightedItem;
|
|
2607
2607
|
if (prevItem) {
|
|
2608
2608
|
prevItem.classList.remove(CLASSES.HIGHLIGHT);
|
|
2609
|
-
prevItem.setAttribute(ARIA.SELECTED, "false");
|
|
2610
2609
|
}
|
|
2611
2610
|
this.highlightedItem = listItem;
|
|
2612
2611
|
if (this.highlightedItem) {
|
|
2613
2612
|
this.highlightedItem.classList.add(CLASSES.HIGHLIGHT);
|
|
2614
|
-
this.highlightedItem.setAttribute(ARIA.SELECTED, "true");
|
|
2615
2613
|
if (this.options.countrySearch) {
|
|
2616
2614
|
const activeDescendant = this.highlightedItem.getAttribute("id") || "";
|
|
2617
2615
|
this.searchInput.setAttribute(ARIA.ACTIVE_DESCENDANT, activeDescendant);
|
|
@@ -2621,6 +2619,21 @@ var UI = class {
|
|
|
2621
2619
|
this.highlightedItem.focus();
|
|
2622
2620
|
}
|
|
2623
2621
|
}
|
|
2622
|
+
updateSelectedItem(iso2) {
|
|
2623
|
+
if (this.selectedItem && this.selectedItem.dataset.countryCode !== iso2) {
|
|
2624
|
+
this.selectedItem.setAttribute(ARIA.SELECTED, "false");
|
|
2625
|
+
this.selectedItem = null;
|
|
2626
|
+
}
|
|
2627
|
+
if (iso2 && !this.selectedItem) {
|
|
2628
|
+
const newListItem = this.countryList.querySelector(
|
|
2629
|
+
`[data-country-code="${iso2}"]`
|
|
2630
|
+
);
|
|
2631
|
+
if (newListItem) {
|
|
2632
|
+
newListItem.setAttribute(ARIA.SELECTED, "true");
|
|
2633
|
+
this.selectedItem = newListItem;
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
}
|
|
2624
2637
|
//* Country search: Filter the country list to the given array of countries.
|
|
2625
2638
|
filterCountries(matchedCountries) {
|
|
2626
2639
|
this.countryList.innerHTML = "";
|
|
@@ -2672,6 +2685,7 @@ var UI = class {
|
|
|
2672
2685
|
this.hiddenInput = null;
|
|
2673
2686
|
this.hiddenInputCountry = null;
|
|
2674
2687
|
this.highlightedItem = null;
|
|
2688
|
+
this.selectedItem = null;
|
|
2675
2689
|
for (const c of this.countries) {
|
|
2676
2690
|
delete c.nodeById[this.id];
|
|
2677
2691
|
}
|
|
@@ -2707,11 +2721,11 @@ var translateCountryNames = (countries, options) => {
|
|
|
2707
2721
|
}
|
|
2708
2722
|
}
|
|
2709
2723
|
};
|
|
2710
|
-
var processDialCodes = (countries
|
|
2724
|
+
var processDialCodes = (countries) => {
|
|
2711
2725
|
const dialCodes = /* @__PURE__ */ new Set();
|
|
2712
2726
|
let dialCodeMaxLen = 0;
|
|
2713
2727
|
const dialCodeToIso2Map = {};
|
|
2714
|
-
const _addToDialCodeMap = (iso2, dialCode
|
|
2728
|
+
const _addToDialCodeMap = (iso2, dialCode) => {
|
|
2715
2729
|
if (!iso2 || !dialCode) {
|
|
2716
2730
|
return;
|
|
2717
2731
|
}
|
|
@@ -2725,10 +2739,10 @@ var processDialCodes = (countries, options) => {
|
|
|
2725
2739
|
if (iso2List.includes(iso2)) {
|
|
2726
2740
|
return;
|
|
2727
2741
|
}
|
|
2728
|
-
|
|
2729
|
-
iso2List[index] = iso2;
|
|
2742
|
+
iso2List.push(iso2);
|
|
2730
2743
|
};
|
|
2731
|
-
|
|
2744
|
+
const countriesSortedByPriority = [...countries].sort((a, b) => a.priority - b.priority);
|
|
2745
|
+
for (const c of countriesSortedByPriority) {
|
|
2732
2746
|
if (!dialCodes.has(c.dialCode)) {
|
|
2733
2747
|
dialCodes.add(c.dialCode);
|
|
2734
2748
|
}
|
|
@@ -2736,14 +2750,7 @@ var processDialCodes = (countries, options) => {
|
|
|
2736
2750
|
const partialDialCode = c.dialCode.substring(0, k);
|
|
2737
2751
|
_addToDialCodeMap(c.iso2, partialDialCode);
|
|
2738
2752
|
}
|
|
2739
|
-
_addToDialCodeMap(c.iso2, c.dialCode
|
|
2740
|
-
}
|
|
2741
|
-
if (options.onlyCountries.length || options.excludeCountries.length) {
|
|
2742
|
-
dialCodes.forEach((dialCode) => {
|
|
2743
|
-
dialCodeToIso2Map[dialCode] = dialCodeToIso2Map[dialCode].filter(Boolean);
|
|
2744
|
-
});
|
|
2745
|
-
}
|
|
2746
|
-
for (const c of countries) {
|
|
2753
|
+
_addToDialCodeMap(c.iso2, c.dialCode);
|
|
2747
2754
|
if (c.areaCodes) {
|
|
2748
2755
|
const rootIso2Code = dialCodeToIso2Map[c.dialCode][0];
|
|
2749
2756
|
for (const areaCode of c.areaCodes) {
|
|
@@ -2878,8 +2885,7 @@ var Iti = class _Iti {
|
|
|
2878
2885
|
this.promise = this._createInitPromises();
|
|
2879
2886
|
this.countries = processAllCountries(this.options);
|
|
2880
2887
|
const { dialCodes, dialCodeMaxLen, dialCodeToIso2Map } = processDialCodes(
|
|
2881
|
-
this.countries
|
|
2882
|
-
this.options
|
|
2888
|
+
this.countries
|
|
2883
2889
|
);
|
|
2884
2890
|
this.dialCodes = dialCodes;
|
|
2885
2891
|
this.dialCodeMaxLen = dialCodeMaxLen;
|
|
@@ -3608,11 +3614,14 @@ var Iti = class _Iti {
|
|
|
3608
3614
|
}
|
|
3609
3615
|
return null;
|
|
3610
3616
|
}
|
|
3611
|
-
//* Update the selected country, dial code (if separateDialCode), placeholder, title, and
|
|
3617
|
+
//* Update the selected country, dial code (if separateDialCode), placeholder, title, and selected list item.
|
|
3612
3618
|
//* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
|
|
3613
3619
|
_setCountry(iso2) {
|
|
3614
|
-
const { separateDialCode, showFlags, i18n } = this.options;
|
|
3620
|
+
const { separateDialCode, showFlags, i18n, allowDropdown } = this.options;
|
|
3615
3621
|
const prevIso2 = this.selectedCountryData.iso2 || "";
|
|
3622
|
+
if (allowDropdown) {
|
|
3623
|
+
this.ui.updateSelectedItem(iso2);
|
|
3624
|
+
}
|
|
3616
3625
|
this.selectedCountryData = iso2 ? this.countryByIso2.get(iso2) : {};
|
|
3617
3626
|
if (this.selectedCountryData.iso2) {
|
|
3618
3627
|
this.defaultCountry = this.selectedCountryData.iso2;
|
|
@@ -3719,11 +3728,12 @@ var Iti = class _Iti {
|
|
|
3719
3728
|
}
|
|
3720
3729
|
this.ui.dropdownContent.classList.add(CLASSES.HIDE);
|
|
3721
3730
|
this.ui.selectedCountry.setAttribute(ARIA.EXPANDED, "false");
|
|
3722
|
-
if (this.ui.highlightedItem) {
|
|
3723
|
-
this.ui.highlightedItem.setAttribute(ARIA.SELECTED, "false");
|
|
3724
|
-
}
|
|
3725
3731
|
if (this.options.countrySearch) {
|
|
3726
3732
|
this.ui.searchInput.removeAttribute(ARIA.ACTIVE_DESCENDANT);
|
|
3733
|
+
if (this.ui.highlightedItem) {
|
|
3734
|
+
this.ui.highlightedItem.classList.remove(CLASSES.HIGHLIGHT);
|
|
3735
|
+
this.ui.highlightedItem = null;
|
|
3736
|
+
}
|
|
3727
3737
|
}
|
|
3728
3738
|
this.ui.dropdownArrow.classList.remove(CLASSES.ARROW_UP);
|
|
3729
3739
|
this.dropdownAbortController.abort();
|
|
@@ -4060,7 +4070,7 @@ var intlTelInput = Object.assign(
|
|
|
4060
4070
|
attachUtils,
|
|
4061
4071
|
startedLoadingUtilsScript: false,
|
|
4062
4072
|
startedLoadingAutoCountry: false,
|
|
4063
|
-
version: "25.13.
|
|
4073
|
+
version: "25.13.2"
|
|
4064
4074
|
}
|
|
4065
4075
|
);
|
|
4066
4076
|
var intl_tel_input_default = intlTelInput;
|
package/vue/README.md
CHANGED
|
@@ -34,7 +34,7 @@ See the [Validation demo](https://github.com/jackocnr/intl-tel-input/blob/master
|
|
|
34
34
|
"vue:demo": "vite --config vue/demo/[demo variant]/vite.config.js"
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
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/vueWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/vue"` 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.13.
|
|
37
|
+
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/vueWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/vue"` 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.13.2/build/js/utils.js"`.
|
|
38
38
|
|
|
39
39
|
## Props
|
|
40
40
|
Here's a list of all of the current props you can pass to the IntlTelInput Vue component.
|