intl-tel-input 29.1.2 → 29.2.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/dist/css/intlTelInput-no-assets.css +1 -1
- package/dist/css/intlTelInput-no-assets.min.css +1 -1
- package/dist/css/intlTelInput.css +1 -1
- package/dist/css/intlTelInput.min.css +1 -1
- package/dist/js/data.d.ts +12 -5
- package/dist/js/data.js +10 -8
- package/dist/js/data.min.js +2 -2
- package/dist/js/data.mjs +9 -7
- package/dist/js/intlTelInput.d.ts +87 -5
- package/dist/js/intlTelInput.js +141 -34
- package/dist/js/intlTelInput.min.js +2 -2
- package/dist/js/intlTelInput.mjs +140 -33
- package/dist/js/intlTelInputWithUtils.js +207 -114
- package/dist/js/intlTelInputWithUtils.min.js +2 -2
- package/dist/js/intlTelInputWithUtils.mjs +206 -113
- package/dist/js/locale.d.ts +12 -5
- package/dist/js/utils.js +22 -22
- package/package.json +5 -1
package/dist/js/intlTelInput.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* International Telephone Input v29.
|
|
2
|
+
* International Telephone Input v29.2.0
|
|
3
3
|
* git+https://github.com/jackocnr/intl-tel-input.git
|
|
4
4
|
* Licensed under the MIT license
|
|
5
5
|
*/
|
|
@@ -50,8 +50,8 @@ var _factory = (() => {
|
|
|
50
50
|
// Åland Islands (AKA Aland Islands)
|
|
51
51
|
"358",
|
|
52
52
|
1,
|
|
53
|
-
["18", "4"],
|
|
54
|
-
// (4
|
|
53
|
+
["18", "4", "50"],
|
|
54
|
+
// (4 and 50 are mobile ranges shared with FI)
|
|
55
55
|
// NOTE: https://en.wikipedia.org/wiki/Telephone%20numbers%20in%20%C3%85land says some 4XXX ranges (e.g. 4570) are specific to AX, but LPN doesn't respect this (https://libphonenumber.appspot.com/phonenumberparser?number=%2B3584570123456 says region=FI) so we won't either. Also it's too much of a maintenance burden to keep track of. Keep the 4 area code range here so that if the user selects AX and types this kind of number, we wont change the flag to FI. Whereas if they type a FI-only range then we will.
|
|
56
56
|
"0"
|
|
57
57
|
],
|
|
@@ -598,8 +598,8 @@ var _factory = (() => {
|
|
|
598
598
|
// Finland
|
|
599
599
|
"358",
|
|
600
600
|
0,
|
|
601
|
-
["4"],
|
|
602
|
-
// (mobile
|
|
601
|
+
["4", "50"],
|
|
602
|
+
// (mobile ranges shared with AX)
|
|
603
603
|
"0"
|
|
604
604
|
],
|
|
605
605
|
[
|
|
@@ -706,7 +706,8 @@ var _factory = (() => {
|
|
|
706
706
|
// Guernsey
|
|
707
707
|
"44",
|
|
708
708
|
1,
|
|
709
|
-
|
|
709
|
+
//* Only 79111 and 79117 belong to GG - the rest of 7911 is GB (e.g. 79110).
|
|
710
|
+
["1481", "7781", "7839", "79111", "79117"],
|
|
710
711
|
"0"
|
|
711
712
|
],
|
|
712
713
|
[
|
|
@@ -837,7 +838,8 @@ var _factory = (() => {
|
|
|
837
838
|
// Jersey
|
|
838
839
|
"44",
|
|
839
840
|
3,
|
|
840
|
-
|
|
841
|
+
//* Only 77003/77007/77008 belong to JE - the rest of 7700 is GB (e.g. 77001).
|
|
842
|
+
["1534", "7509", "77003", "77007", "77008", "7797", "7829", "7937"],
|
|
841
843
|
"0"
|
|
842
844
|
],
|
|
843
845
|
[
|
|
@@ -1032,7 +1034,7 @@ var _factory = (() => {
|
|
|
1032
1034
|
// Mayotte
|
|
1033
1035
|
"262",
|
|
1034
1036
|
1,
|
|
1035
|
-
["269", "639"],
|
|
1037
|
+
["2689", "269", "639", "7093"],
|
|
1036
1038
|
"0"
|
|
1037
1039
|
],
|
|
1038
1040
|
[
|
|
@@ -1796,6 +1798,29 @@ var _factory = (() => {
|
|
|
1796
1798
|
// used for synthetic input trigger
|
|
1797
1799
|
STRICT_REJECT: "strict:reject"
|
|
1798
1800
|
};
|
|
1801
|
+
var ITI_SLOTS = [
|
|
1802
|
+
"container",
|
|
1803
|
+
"input",
|
|
1804
|
+
"countryContainer",
|
|
1805
|
+
"selectedCountry",
|
|
1806
|
+
"selectedCountryPrimary",
|
|
1807
|
+
"selectedFlag",
|
|
1808
|
+
"arrow",
|
|
1809
|
+
"selectedDialCode",
|
|
1810
|
+
"countrySelector",
|
|
1811
|
+
"countrySelectorContainer",
|
|
1812
|
+
"searchWrapper",
|
|
1813
|
+
"searchIcon",
|
|
1814
|
+
"searchInput",
|
|
1815
|
+
"searchClear",
|
|
1816
|
+
"countryList",
|
|
1817
|
+
"countryListItem",
|
|
1818
|
+
"countryListItemFlag",
|
|
1819
|
+
"countryName",
|
|
1820
|
+
"dialCode",
|
|
1821
|
+
"countryCheck",
|
|
1822
|
+
"noResults"
|
|
1823
|
+
];
|
|
1799
1824
|
var CLASSES = {
|
|
1800
1825
|
HIDE: "iti__hide",
|
|
1801
1826
|
V_HIDE: "iti__v-hide",
|
|
@@ -1972,6 +1997,8 @@ var _factory = (() => {
|
|
|
1972
1997
|
allowNumberExtensions: false,
|
|
1973
1998
|
// Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
|
|
1974
1999
|
allowPhonewords: false,
|
|
2000
|
+
//* Add custom classes to the elements we generate, keyed by slot name e.g. { selectedCountry: "rounded-l-lg" }.
|
|
2001
|
+
classNames: {},
|
|
1975
2002
|
//* Add a custom class to the (injected) container element.
|
|
1976
2003
|
containerClass: "",
|
|
1977
2004
|
//* Locale for localising country names via Intl.DisplayNames.
|
|
@@ -2034,6 +2061,7 @@ var _factory = (() => {
|
|
|
2034
2061
|
return v.nodeType === 1 && typeof v.tagName === "string" && typeof v.appendChild === "function";
|
|
2035
2062
|
};
|
|
2036
2063
|
var placeholderPolicySet = new Set(Object.values(PLACEHOLDER_POLICY));
|
|
2064
|
+
var slotSet = new Set(ITI_SLOTS);
|
|
2037
2065
|
var warn = (message) => {
|
|
2038
2066
|
console.warn(`[intl-tel-input] ${message}`);
|
|
2039
2067
|
};
|
|
@@ -2134,6 +2162,26 @@ var _factory = (() => {
|
|
|
2134
2162
|
}
|
|
2135
2163
|
validatedOptions[key] = value;
|
|
2136
2164
|
break;
|
|
2165
|
+
case "classNames": {
|
|
2166
|
+
if (!isPlainObject(value)) {
|
|
2167
|
+
warnOption("classNames", "an object", value);
|
|
2168
|
+
break;
|
|
2169
|
+
}
|
|
2170
|
+
const validSlots = {};
|
|
2171
|
+
for (const [slot, slotValue] of Object.entries(value)) {
|
|
2172
|
+
if (!slotSet.has(slot)) {
|
|
2173
|
+
warn(
|
|
2174
|
+
`Unknown slot '${slot}' in 'classNames'. Valid slots: ${ITI_SLOTS.join(", ")}. Skipping.`
|
|
2175
|
+
);
|
|
2176
|
+
} else if (typeof slotValue !== "string") {
|
|
2177
|
+
warnOption(`classNames.${slot}`, "a string", slotValue);
|
|
2178
|
+
} else {
|
|
2179
|
+
validSlots[slot] = slotValue.trim().replace(/\s+/g, " ");
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
validatedOptions[key] = validSlots;
|
|
2183
|
+
break;
|
|
2184
|
+
}
|
|
2137
2185
|
case "countryOrder": {
|
|
2138
2186
|
if (value === null) {
|
|
2139
2187
|
validatedOptions[key] = value;
|
|
@@ -2546,11 +2594,18 @@ var _factory = (() => {
|
|
|
2546
2594
|
);
|
|
2547
2595
|
}
|
|
2548
2596
|
}
|
|
2597
|
+
//* Append any consumer-supplied classes (via the classNames option) for the given slot to our own classes for that element.
|
|
2598
|
+
#withSlotClass(slot, ourClasses) {
|
|
2599
|
+
const custom = this.#options.classNames[slot];
|
|
2600
|
+
return custom ? `${ourClasses} ${custom}` : ourClasses;
|
|
2601
|
+
}
|
|
2549
2602
|
//* Generate all of the markup for the core library: the selected country overlay, and the country selector.
|
|
2550
2603
|
buildMarkup(countries, searchTokens) {
|
|
2551
2604
|
this.#countries = countries;
|
|
2552
2605
|
this.#searchTokens = searchTokens;
|
|
2553
|
-
this.telInputEl.classList.add(
|
|
2606
|
+
this.telInputEl.classList.add(
|
|
2607
|
+
...this.#withSlotClass("input", "iti__tel-input").split(" ")
|
|
2608
|
+
);
|
|
2554
2609
|
if (!this.telInputEl.hasAttribute("type")) {
|
|
2555
2610
|
this.telInputEl.setAttribute("type", "tel");
|
|
2556
2611
|
}
|
|
@@ -2578,7 +2633,9 @@ var _factory = (() => {
|
|
|
2578
2633
|
"iti--inline-country-selector": countrySelectorMode !== COUNTRY_SELECTOR_MODE.FULLSCREEN,
|
|
2579
2634
|
[containerClass]: Boolean(containerClass)
|
|
2580
2635
|
});
|
|
2581
|
-
const wrapper = createEl("div", {
|
|
2636
|
+
const wrapper = createEl("div", {
|
|
2637
|
+
class: this.#withSlotClass("container", parentClasses)
|
|
2638
|
+
});
|
|
2582
2639
|
if (this.#isRTL) {
|
|
2583
2640
|
wrapper.setAttribute("dir", "ltr");
|
|
2584
2641
|
}
|
|
@@ -2594,7 +2651,12 @@ var _factory = (() => {
|
|
|
2594
2651
|
this.#countryContainerEl = createEl(
|
|
2595
2652
|
"div",
|
|
2596
2653
|
// visibly hidden until we measure its width to set the input padding correctly
|
|
2597
|
-
{
|
|
2654
|
+
{
|
|
2655
|
+
class: this.#withSlotClass(
|
|
2656
|
+
"countryContainer",
|
|
2657
|
+
`iti__country-container ${CLASSES.V_HIDE}`
|
|
2658
|
+
)
|
|
2659
|
+
},
|
|
2598
2660
|
wrapper
|
|
2599
2661
|
);
|
|
2600
2662
|
if (enableCountrySelector) {
|
|
@@ -2602,7 +2664,7 @@ var _factory = (() => {
|
|
|
2602
2664
|
"button",
|
|
2603
2665
|
{
|
|
2604
2666
|
type: "button",
|
|
2605
|
-
class: "iti__selected-country",
|
|
2667
|
+
class: this.#withSlotClass("selectedCountry", "iti__selected-country"),
|
|
2606
2668
|
[ARIA.EXPANDED]: "false",
|
|
2607
2669
|
[ARIA.LABEL]: this.#options.uiTranslations.noCountrySelected,
|
|
2608
2670
|
[ARIA.HASPOPUP]: "dialog",
|
|
@@ -2616,31 +2678,44 @@ var _factory = (() => {
|
|
|
2616
2678
|
} else {
|
|
2617
2679
|
this.#selectedCountryEl = createEl(
|
|
2618
2680
|
"div",
|
|
2619
|
-
{ class: "iti__selected-country" },
|
|
2681
|
+
{ class: this.#withSlotClass("selectedCountry", "iti__selected-country") },
|
|
2620
2682
|
this.#countryContainerEl
|
|
2621
2683
|
);
|
|
2622
2684
|
}
|
|
2623
2685
|
const selectedCountryPrimary = createEl(
|
|
2624
2686
|
"div",
|
|
2625
|
-
{
|
|
2687
|
+
{
|
|
2688
|
+
class: this.#withSlotClass(
|
|
2689
|
+
"selectedCountryPrimary",
|
|
2690
|
+
"iti__selected-country-primary"
|
|
2691
|
+
)
|
|
2692
|
+
},
|
|
2626
2693
|
this.#selectedCountryEl
|
|
2627
2694
|
);
|
|
2628
2695
|
this.#selectedFlagEl = createEl(
|
|
2629
2696
|
"div",
|
|
2630
|
-
{ class: CLASSES.FLAG },
|
|
2697
|
+
{ class: this.#withSlotClass("selectedFlag", CLASSES.FLAG) },
|
|
2631
2698
|
selectedCountryPrimary
|
|
2632
2699
|
);
|
|
2633
2700
|
if (enableCountrySelector) {
|
|
2634
2701
|
this.#arrowEl = createEl(
|
|
2635
2702
|
"div",
|
|
2636
|
-
{
|
|
2703
|
+
{
|
|
2704
|
+
class: this.#withSlotClass("arrow", "iti__arrow"),
|
|
2705
|
+
[ARIA.HIDDEN]: "true"
|
|
2706
|
+
},
|
|
2637
2707
|
selectedCountryPrimary
|
|
2638
2708
|
);
|
|
2639
2709
|
}
|
|
2640
2710
|
if (separateDialCode) {
|
|
2641
2711
|
this.#selectedDialCodeEl = createEl(
|
|
2642
2712
|
"div",
|
|
2643
|
-
{
|
|
2713
|
+
{
|
|
2714
|
+
class: this.#withSlotClass(
|
|
2715
|
+
"selectedDialCode",
|
|
2716
|
+
"iti__selected-dial-code"
|
|
2717
|
+
)
|
|
2718
|
+
},
|
|
2644
2719
|
this.#selectedCountryEl
|
|
2645
2720
|
);
|
|
2646
2721
|
}
|
|
@@ -2671,7 +2746,10 @@ var _factory = (() => {
|
|
|
2671
2746
|
const extraClasses = matchDropdownWidth ? "" : "iti--flexible-dropdown-width";
|
|
2672
2747
|
this.#countrySelectorEl = createEl("div", {
|
|
2673
2748
|
id: `iti-${this.#id}__country-selector`,
|
|
2674
|
-
class:
|
|
2749
|
+
class: this.#withSlotClass(
|
|
2750
|
+
"countrySelector",
|
|
2751
|
+
`iti__country-selector ${CLASSES.HIDE} ${extraClasses}`
|
|
2752
|
+
),
|
|
2675
2753
|
role: "dialog",
|
|
2676
2754
|
[ARIA.MODAL]: "true"
|
|
2677
2755
|
});
|
|
@@ -2684,7 +2762,7 @@ var _factory = (() => {
|
|
|
2684
2762
|
this.#countryListEl = createEl(
|
|
2685
2763
|
"ul",
|
|
2686
2764
|
{
|
|
2687
|
-
class: "iti__country-list",
|
|
2765
|
+
class: this.#withSlotClass("countryList", "iti__country-list"),
|
|
2688
2766
|
id: `iti-${this.#id}__country-listbox`,
|
|
2689
2767
|
role: "listbox",
|
|
2690
2768
|
[ARIA.LABEL]: uiTranslations.countryListAriaLabel
|
|
@@ -2703,7 +2781,9 @@ var _factory = (() => {
|
|
|
2703
2781
|
"iti--inline-country-selector": !isFullscreen,
|
|
2704
2782
|
[containerClass]: Boolean(containerClass)
|
|
2705
2783
|
});
|
|
2706
|
-
this.#detachedCountrySelectorEl = createEl("div", {
|
|
2784
|
+
this.#detachedCountrySelectorEl = createEl("div", {
|
|
2785
|
+
class: this.#withSlotClass("countrySelectorContainer", wrapperClasses)
|
|
2786
|
+
});
|
|
2707
2787
|
this.#detachedCountrySelectorEl.appendChild(this.#countrySelectorEl);
|
|
2708
2788
|
} else {
|
|
2709
2789
|
this.#countryContainerEl.appendChild(this.#countrySelectorEl);
|
|
@@ -2724,13 +2804,13 @@ var _factory = (() => {
|
|
|
2724
2804
|
const { uiTranslations, searchInputClass } = this.#options;
|
|
2725
2805
|
const searchWrapper = createEl(
|
|
2726
2806
|
"div",
|
|
2727
|
-
{ class: "iti__search-input-wrapper" },
|
|
2807
|
+
{ class: this.#withSlotClass("searchWrapper", "iti__search-input-wrapper") },
|
|
2728
2808
|
this.#countrySelectorEl
|
|
2729
2809
|
);
|
|
2730
2810
|
this.#searchIconEl = createEl(
|
|
2731
2811
|
"span",
|
|
2732
2812
|
{
|
|
2733
|
-
class: "iti__search-icon",
|
|
2813
|
+
class: this.#withSlotClass("searchIcon", "iti__search-icon"),
|
|
2734
2814
|
[ARIA.HIDDEN]: "true"
|
|
2735
2815
|
},
|
|
2736
2816
|
searchWrapper
|
|
@@ -2742,7 +2822,10 @@ var _factory = (() => {
|
|
|
2742
2822
|
id: `iti-${this.#id}__search-input`,
|
|
2743
2823
|
// Chrome says inputs need either a name or an id
|
|
2744
2824
|
type: "search",
|
|
2745
|
-
class:
|
|
2825
|
+
class: this.#withSlotClass(
|
|
2826
|
+
"searchInput",
|
|
2827
|
+
`iti__search-input ${searchInputClass}`
|
|
2828
|
+
),
|
|
2746
2829
|
placeholder: uiTranslations.searchPlaceholder,
|
|
2747
2830
|
// role=combobox + aria-autocomplete=list + aria-activedescendant allows maintaining focus on the search input while allowing users to navigate search results with up/down keyboard keys
|
|
2748
2831
|
role: "combobox",
|
|
@@ -2758,7 +2841,10 @@ var _factory = (() => {
|
|
|
2758
2841
|
"button",
|
|
2759
2842
|
{
|
|
2760
2843
|
type: "button",
|
|
2761
|
-
class:
|
|
2844
|
+
class: this.#withSlotClass(
|
|
2845
|
+
"searchClear",
|
|
2846
|
+
`iti__search-clear ${CLASSES.HIDE}`
|
|
2847
|
+
),
|
|
2762
2848
|
[ARIA.LABEL]: uiTranslations.clearSearchAriaLabel,
|
|
2763
2849
|
tabindex: "-1"
|
|
2764
2850
|
},
|
|
@@ -2773,7 +2859,7 @@ var _factory = (() => {
|
|
|
2773
2859
|
this.#noResultsMessageEl = createEl(
|
|
2774
2860
|
"div",
|
|
2775
2861
|
{
|
|
2776
|
-
class: `iti__no-results ${CLASSES.HIDE}
|
|
2862
|
+
class: this.#withSlotClass("noResults", `iti__no-results ${CLASSES.HIDE}`),
|
|
2777
2863
|
[ARIA.HIDDEN]: "true"
|
|
2778
2864
|
// all a11y messaging happens in this.#searchResultsLiveRegionEl
|
|
2779
2865
|
},
|
|
@@ -2827,11 +2913,9 @@ var _factory = (() => {
|
|
|
2827
2913
|
//* For each country: add a country list item <li> to the countryList <ul> container.
|
|
2828
2914
|
#appendListItems() {
|
|
2829
2915
|
const frag = document.createDocumentFragment();
|
|
2916
|
+
const liClass = this.#withSlotClass("countryListItem", CLASSES.COUNTRY_ITEM);
|
|
2830
2917
|
for (let i = 0; i < this.#countries.length; i++) {
|
|
2831
2918
|
const c = this.#countries[i];
|
|
2832
|
-
const liClass = buildClassNames({
|
|
2833
|
-
[CLASSES.COUNTRY_ITEM]: true
|
|
2834
|
-
});
|
|
2835
2919
|
const listItem = createEl("li", {
|
|
2836
2920
|
id: `iti-${this.#id}__item-${c.iso2}`,
|
|
2837
2921
|
class: liClass,
|
|
@@ -2843,11 +2927,28 @@ var _factory = (() => {
|
|
|
2843
2927
|
listItem.dataset[DATA_KEYS.ISO2] = c.iso2;
|
|
2844
2928
|
this.#listItemByIso2.set(c.iso2, listItem);
|
|
2845
2929
|
if (this.#options.showFlags) {
|
|
2846
|
-
createEl(
|
|
2930
|
+
createEl(
|
|
2931
|
+
"div",
|
|
2932
|
+
{
|
|
2933
|
+
class: this.#withSlotClass(
|
|
2934
|
+
"countryListItemFlag",
|
|
2935
|
+
`${CLASSES.FLAG} iti__${c.iso2}`
|
|
2936
|
+
)
|
|
2937
|
+
},
|
|
2938
|
+
listItem
|
|
2939
|
+
);
|
|
2847
2940
|
}
|
|
2848
|
-
const nameEl = createEl(
|
|
2941
|
+
const nameEl = createEl(
|
|
2942
|
+
"span",
|
|
2943
|
+
{ class: this.#withSlotClass("countryName", "iti__country-name") },
|
|
2944
|
+
listItem
|
|
2945
|
+
);
|
|
2849
2946
|
nameEl.textContent = `${c.name} `;
|
|
2850
|
-
const dialEl = createEl(
|
|
2947
|
+
const dialEl = createEl(
|
|
2948
|
+
"span",
|
|
2949
|
+
{ class: this.#withSlotClass("dialCode", "iti__dial-code") },
|
|
2950
|
+
nameEl
|
|
2951
|
+
);
|
|
2851
2952
|
if (this.#isRTL) {
|
|
2852
2953
|
dialEl.setAttribute("dir", "ltr");
|
|
2853
2954
|
}
|
|
@@ -3294,7 +3395,10 @@ var _factory = (() => {
|
|
|
3294
3395
|
newListItem.setAttribute(ARIA.SELECTED, "true");
|
|
3295
3396
|
const checkIcon = createEl(
|
|
3296
3397
|
"span",
|
|
3297
|
-
{
|
|
3398
|
+
{
|
|
3399
|
+
class: this.#withSlotClass("countryCheck", "iti__country-check"),
|
|
3400
|
+
[ARIA.HIDDEN]: "true"
|
|
3401
|
+
},
|
|
3298
3402
|
newListItem
|
|
3299
3403
|
);
|
|
3300
3404
|
checkIcon.appendChild(buildCheckIcon());
|
|
@@ -3481,7 +3585,10 @@ var _factory = (() => {
|
|
|
3481
3585
|
this.#updateSelectedListItem(iso2);
|
|
3482
3586
|
}
|
|
3483
3587
|
if (this.#selectedCountryEl) {
|
|
3484
|
-
const flagClass =
|
|
3588
|
+
const flagClass = this.#withSlotClass(
|
|
3589
|
+
"selectedFlag",
|
|
3590
|
+
iso2 && showFlags ? `${CLASSES.FLAG} iti__${iso2}` : `${CLASSES.FLAG} ${CLASSES.GLOBE}`
|
|
3591
|
+
);
|
|
3485
3592
|
let ariaLabel, title;
|
|
3486
3593
|
let flagContent = null;
|
|
3487
3594
|
if (iso2) {
|
|
@@ -4878,7 +4985,7 @@ var _factory = (() => {
|
|
|
4878
4985
|
attachUtils,
|
|
4879
4986
|
startedLoadingUtils: false,
|
|
4880
4987
|
startedLoadingAutoCountry: false,
|
|
4881
|
-
version: "29.
|
|
4988
|
+
version: "29.2.0",
|
|
4882
4989
|
NUMBER_FORMAT,
|
|
4883
4990
|
NUMBER_TYPE,
|
|
4884
4991
|
VALIDATION_ERROR,
|