intl-tel-input 29.1.3 → 29.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/dist/js/data.js +1 -1
- package/dist/js/data.min.js +1 -1
- package/dist/js/intlTelInput.d.ts +75 -0
- package/dist/js/intlTelInput.js +162 -52
- package/dist/js/intlTelInput.min.js +2 -2
- package/dist/js/intlTelInput.mjs +161 -51
- package/dist/js/intlTelInputWithUtils.js +162 -52
- package/dist/js/intlTelInputWithUtils.min.js +2 -2
- package/dist/js/intlTelInputWithUtils.mjs +161 -51
- package/package.json +1 -1
package/dist/js/data.js
CHANGED
package/dist/js/data.min.js
CHANGED
|
@@ -1616,6 +1616,29 @@ export type UiTranslations = {
|
|
|
1616
1616
|
searchSummaryAria?: (count: number) => string;
|
|
1617
1617
|
countryNames?: Partial<Record<Iso2, string>>;
|
|
1618
1618
|
};
|
|
1619
|
+
declare const ITI_SLOTS: readonly [
|
|
1620
|
+
"container",
|
|
1621
|
+
"input",
|
|
1622
|
+
"countryContainer",
|
|
1623
|
+
"selectedCountry",
|
|
1624
|
+
"selectedCountryPrimary",
|
|
1625
|
+
"selectedFlag",
|
|
1626
|
+
"arrow",
|
|
1627
|
+
"selectedDialCode",
|
|
1628
|
+
"countrySelector",
|
|
1629
|
+
"countrySelectorContainer",
|
|
1630
|
+
"searchWrapper",
|
|
1631
|
+
"searchIcon",
|
|
1632
|
+
"searchInput",
|
|
1633
|
+
"searchClear",
|
|
1634
|
+
"countryList",
|
|
1635
|
+
"countryListItem",
|
|
1636
|
+
"countryListItemFlag",
|
|
1637
|
+
"countryName",
|
|
1638
|
+
"dialCode",
|
|
1639
|
+
"countryCheck",
|
|
1640
|
+
"noResults"
|
|
1641
|
+
];
|
|
1619
1642
|
export declare const PLACEHOLDER_POLICY: {
|
|
1620
1643
|
readonly AGGRESSIVE: "AGGRESSIVE";
|
|
1621
1644
|
readonly POLITE: "POLITE";
|
|
@@ -1709,11 +1732,63 @@ export type NumberType = ArrayValues<typeof NUMBER_TYPES>;
|
|
|
1709
1732
|
export type ValidationError = ArrayValues<typeof VALIDATION_ERRORS>;
|
|
1710
1733
|
export type ValueOf<T> = T[keyof T];
|
|
1711
1734
|
export type CountrySelectorMode = ArrayValues<typeof COUNTRY_SELECTOR_MODES>;
|
|
1735
|
+
export type ItiSlot = ArrayValues<typeof ITI_SLOTS>;
|
|
1736
|
+
export interface ItiClassNames {
|
|
1737
|
+
/** The injected `<div class="iti">` wrapping the input and the selected country. */
|
|
1738
|
+
container?: string;
|
|
1739
|
+
/** The `<input>` itself. */
|
|
1740
|
+
input?: string;
|
|
1741
|
+
/** The `<div>` wrapping the selected country, which overlays the left of the input. */
|
|
1742
|
+
countryContainer?: string;
|
|
1743
|
+
/** The selected country `<button>` (or `<div>` when the country selector is disabled). */
|
|
1744
|
+
selectedCountry?: string;
|
|
1745
|
+
/** The `<div>` inside the selected country that gets the hover highlight. */
|
|
1746
|
+
selectedCountryPrimary?: string;
|
|
1747
|
+
/** The selected country's flag (or globe icon) `<div>`. */
|
|
1748
|
+
selectedFlag?: string;
|
|
1749
|
+
/** The dropdown arrow `<div>`. */
|
|
1750
|
+
arrow?: string;
|
|
1751
|
+
/** The selected country's dial code `<div>`. Requires `separateDialCode`. */
|
|
1752
|
+
selectedDialCode?: string;
|
|
1753
|
+
/** The country selector `<div>` i.e. the dropdown or the fullscreen popup. */
|
|
1754
|
+
countrySelector?: string;
|
|
1755
|
+
/**
|
|
1756
|
+
* The `<div>` wrapping the country selector when it is rendered outside the
|
|
1757
|
+
* main container — i.e. the fullscreen popup, or when `dropdownParent` is set.
|
|
1758
|
+
* This element only handles positioning, so it is mainly useful for getting a
|
|
1759
|
+
* scoping class (e.g. a theme class) onto a country selector that would
|
|
1760
|
+
* otherwise escape it. Does not exist for a normal inline dropdown.
|
|
1761
|
+
*/
|
|
1762
|
+
countrySelectorContainer?: string;
|
|
1763
|
+
/** The `<div>` wrapping the country search input and its icons. Requires `countrySearch`. */
|
|
1764
|
+
searchWrapper?: string;
|
|
1765
|
+
/** The search (magnifying glass) icon `<span>`. Requires `countrySearch`. */
|
|
1766
|
+
searchIcon?: string;
|
|
1767
|
+
/** The country search `<input>`. Requires `countrySearch`. */
|
|
1768
|
+
searchInput?: string;
|
|
1769
|
+
/** The clear-search `<button>`. Requires `countrySearch`. */
|
|
1770
|
+
searchClear?: string;
|
|
1771
|
+
/** The country list `<ul>`. */
|
|
1772
|
+
countryList?: string;
|
|
1773
|
+
/** Every country `<li>` in the country list. */
|
|
1774
|
+
countryListItem?: string;
|
|
1775
|
+
/** The flag `<div>` inside every country `<li>`. Requires `showFlags`. */
|
|
1776
|
+
countryListItemFlag?: string;
|
|
1777
|
+
/** The country name `<span>` inside every country `<li>`. */
|
|
1778
|
+
countryName?: string;
|
|
1779
|
+
/** The dial code `<span>` inside every country name. */
|
|
1780
|
+
dialCode?: string;
|
|
1781
|
+
/** The check icon `<span>` added to the currently selected country `<li>`. */
|
|
1782
|
+
countryCheck?: string;
|
|
1783
|
+
/** The "no results" message `<div>`. Requires `countrySearch`. */
|
|
1784
|
+
noResults?: string;
|
|
1785
|
+
}
|
|
1712
1786
|
export interface AllOptions {
|
|
1713
1787
|
countrySelectorMode: CountrySelectorMode;
|
|
1714
1788
|
allowedNumberTypes: NumberType[] | null;
|
|
1715
1789
|
allowNumberExtensions: boolean;
|
|
1716
1790
|
allowPhonewords: boolean;
|
|
1791
|
+
classNames: ItiClassNames;
|
|
1717
1792
|
containerClass: string;
|
|
1718
1793
|
countryNameLocale: string;
|
|
1719
1794
|
countryNameOverrides: Partial<Record<Iso2, string>>;
|
package/dist/js/intlTelInput.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* International Telephone Input v29.1
|
|
2
|
+
* International Telephone Input v29.2.1
|
|
3
3
|
* git+https://github.com/jackocnr/intl-tel-input.git
|
|
4
4
|
* Licensed under the MIT license
|
|
5
5
|
*/
|
|
@@ -1798,6 +1798,29 @@ var _factory = (() => {
|
|
|
1798
1798
|
// used for synthetic input trigger
|
|
1799
1799
|
STRICT_REJECT: "strict:reject"
|
|
1800
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
|
+
];
|
|
1801
1824
|
var CLASSES = {
|
|
1802
1825
|
HIDE: "iti__hide",
|
|
1803
1826
|
V_HIDE: "iti__v-hide",
|
|
@@ -1855,6 +1878,7 @@ var _factory = (() => {
|
|
|
1855
1878
|
NANP: "1"
|
|
1856
1879
|
// North American Numbering Plan
|
|
1857
1880
|
};
|
|
1881
|
+
var E164_MAX_DIGITS = 15;
|
|
1858
1882
|
var UK = {
|
|
1859
1883
|
ISO2: "gb",
|
|
1860
1884
|
DIAL_CODE: "44",
|
|
@@ -1974,6 +1998,8 @@ var _factory = (() => {
|
|
|
1974
1998
|
allowNumberExtensions: false,
|
|
1975
1999
|
// Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
|
|
1976
2000
|
allowPhonewords: false,
|
|
2001
|
+
//* Add custom classes to the elements we generate, keyed by slot name e.g. { selectedCountry: "rounded-l-lg" }.
|
|
2002
|
+
classNames: {},
|
|
1977
2003
|
//* Add a custom class to the (injected) container element.
|
|
1978
2004
|
containerClass: "",
|
|
1979
2005
|
//* Locale for localising country names via Intl.DisplayNames.
|
|
@@ -2036,6 +2062,7 @@ var _factory = (() => {
|
|
|
2036
2062
|
return v.nodeType === 1 && typeof v.tagName === "string" && typeof v.appendChild === "function";
|
|
2037
2063
|
};
|
|
2038
2064
|
var placeholderPolicySet = new Set(Object.values(PLACEHOLDER_POLICY));
|
|
2065
|
+
var slotSet = new Set(ITI_SLOTS);
|
|
2039
2066
|
var warn = (message) => {
|
|
2040
2067
|
console.warn(`[intl-tel-input] ${message}`);
|
|
2041
2068
|
};
|
|
@@ -2136,6 +2163,26 @@ var _factory = (() => {
|
|
|
2136
2163
|
}
|
|
2137
2164
|
validatedOptions[key] = value;
|
|
2138
2165
|
break;
|
|
2166
|
+
case "classNames": {
|
|
2167
|
+
if (!isPlainObject(value)) {
|
|
2168
|
+
warnOption("classNames", "an object", value);
|
|
2169
|
+
break;
|
|
2170
|
+
}
|
|
2171
|
+
const validSlots = {};
|
|
2172
|
+
for (const [slot, slotValue] of Object.entries(value)) {
|
|
2173
|
+
if (!slotSet.has(slot)) {
|
|
2174
|
+
warn(
|
|
2175
|
+
`Unknown slot '${slot}' in 'classNames'. Valid slots: ${ITI_SLOTS.join(", ")}. Skipping.`
|
|
2176
|
+
);
|
|
2177
|
+
} else if (typeof slotValue !== "string") {
|
|
2178
|
+
warnOption(`classNames.${slot}`, "a string", slotValue);
|
|
2179
|
+
} else {
|
|
2180
|
+
validSlots[slot] = slotValue.trim().replace(/\s+/g, " ");
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
validatedOptions[key] = validSlots;
|
|
2184
|
+
break;
|
|
2185
|
+
}
|
|
2139
2186
|
case "countryOrder": {
|
|
2140
2187
|
if (value === null) {
|
|
2141
2188
|
validatedOptions[key] = value;
|
|
@@ -2548,11 +2595,18 @@ var _factory = (() => {
|
|
|
2548
2595
|
);
|
|
2549
2596
|
}
|
|
2550
2597
|
}
|
|
2598
|
+
//* Append any consumer-supplied classes (via the classNames option) for the given slot to our own classes for that element.
|
|
2599
|
+
#withSlotClass(slot, ourClasses) {
|
|
2600
|
+
const custom = this.#options.classNames[slot];
|
|
2601
|
+
return custom ? `${ourClasses} ${custom}` : ourClasses;
|
|
2602
|
+
}
|
|
2551
2603
|
//* Generate all of the markup for the core library: the selected country overlay, and the country selector.
|
|
2552
2604
|
buildMarkup(countries, searchTokens) {
|
|
2553
2605
|
this.#countries = countries;
|
|
2554
2606
|
this.#searchTokens = searchTokens;
|
|
2555
|
-
this.telInputEl.classList.add(
|
|
2607
|
+
this.telInputEl.classList.add(
|
|
2608
|
+
...this.#withSlotClass("input", "iti__tel-input").split(" ")
|
|
2609
|
+
);
|
|
2556
2610
|
if (!this.telInputEl.hasAttribute("type")) {
|
|
2557
2611
|
this.telInputEl.setAttribute("type", "tel");
|
|
2558
2612
|
}
|
|
@@ -2580,7 +2634,9 @@ var _factory = (() => {
|
|
|
2580
2634
|
"iti--inline-country-selector": countrySelectorMode !== COUNTRY_SELECTOR_MODE.FULLSCREEN,
|
|
2581
2635
|
[containerClass]: Boolean(containerClass)
|
|
2582
2636
|
});
|
|
2583
|
-
const wrapper = createEl("div", {
|
|
2637
|
+
const wrapper = createEl("div", {
|
|
2638
|
+
class: this.#withSlotClass("container", parentClasses)
|
|
2639
|
+
});
|
|
2584
2640
|
if (this.#isRTL) {
|
|
2585
2641
|
wrapper.setAttribute("dir", "ltr");
|
|
2586
2642
|
}
|
|
@@ -2596,7 +2652,12 @@ var _factory = (() => {
|
|
|
2596
2652
|
this.#countryContainerEl = createEl(
|
|
2597
2653
|
"div",
|
|
2598
2654
|
// visibly hidden until we measure its width to set the input padding correctly
|
|
2599
|
-
{
|
|
2655
|
+
{
|
|
2656
|
+
class: this.#withSlotClass(
|
|
2657
|
+
"countryContainer",
|
|
2658
|
+
`iti__country-container ${CLASSES.V_HIDE}`
|
|
2659
|
+
)
|
|
2660
|
+
},
|
|
2600
2661
|
wrapper
|
|
2601
2662
|
);
|
|
2602
2663
|
if (enableCountrySelector) {
|
|
@@ -2604,7 +2665,7 @@ var _factory = (() => {
|
|
|
2604
2665
|
"button",
|
|
2605
2666
|
{
|
|
2606
2667
|
type: "button",
|
|
2607
|
-
class: "iti__selected-country",
|
|
2668
|
+
class: this.#withSlotClass("selectedCountry", "iti__selected-country"),
|
|
2608
2669
|
[ARIA.EXPANDED]: "false",
|
|
2609
2670
|
[ARIA.LABEL]: this.#options.uiTranslations.noCountrySelected,
|
|
2610
2671
|
[ARIA.HASPOPUP]: "dialog",
|
|
@@ -2618,31 +2679,44 @@ var _factory = (() => {
|
|
|
2618
2679
|
} else {
|
|
2619
2680
|
this.#selectedCountryEl = createEl(
|
|
2620
2681
|
"div",
|
|
2621
|
-
{ class: "iti__selected-country" },
|
|
2682
|
+
{ class: this.#withSlotClass("selectedCountry", "iti__selected-country") },
|
|
2622
2683
|
this.#countryContainerEl
|
|
2623
2684
|
);
|
|
2624
2685
|
}
|
|
2625
2686
|
const selectedCountryPrimary = createEl(
|
|
2626
2687
|
"div",
|
|
2627
|
-
{
|
|
2688
|
+
{
|
|
2689
|
+
class: this.#withSlotClass(
|
|
2690
|
+
"selectedCountryPrimary",
|
|
2691
|
+
"iti__selected-country-primary"
|
|
2692
|
+
)
|
|
2693
|
+
},
|
|
2628
2694
|
this.#selectedCountryEl
|
|
2629
2695
|
);
|
|
2630
2696
|
this.#selectedFlagEl = createEl(
|
|
2631
2697
|
"div",
|
|
2632
|
-
{ class: CLASSES.FLAG },
|
|
2698
|
+
{ class: this.#withSlotClass("selectedFlag", CLASSES.FLAG) },
|
|
2633
2699
|
selectedCountryPrimary
|
|
2634
2700
|
);
|
|
2635
2701
|
if (enableCountrySelector) {
|
|
2636
2702
|
this.#arrowEl = createEl(
|
|
2637
2703
|
"div",
|
|
2638
|
-
{
|
|
2704
|
+
{
|
|
2705
|
+
class: this.#withSlotClass("arrow", "iti__arrow"),
|
|
2706
|
+
[ARIA.HIDDEN]: "true"
|
|
2707
|
+
},
|
|
2639
2708
|
selectedCountryPrimary
|
|
2640
2709
|
);
|
|
2641
2710
|
}
|
|
2642
2711
|
if (separateDialCode) {
|
|
2643
2712
|
this.#selectedDialCodeEl = createEl(
|
|
2644
2713
|
"div",
|
|
2645
|
-
{
|
|
2714
|
+
{
|
|
2715
|
+
class: this.#withSlotClass(
|
|
2716
|
+
"selectedDialCode",
|
|
2717
|
+
"iti__selected-dial-code"
|
|
2718
|
+
)
|
|
2719
|
+
},
|
|
2646
2720
|
this.#selectedCountryEl
|
|
2647
2721
|
);
|
|
2648
2722
|
}
|
|
@@ -2673,7 +2747,10 @@ var _factory = (() => {
|
|
|
2673
2747
|
const extraClasses = matchDropdownWidth ? "" : "iti--flexible-dropdown-width";
|
|
2674
2748
|
this.#countrySelectorEl = createEl("div", {
|
|
2675
2749
|
id: `iti-${this.#id}__country-selector`,
|
|
2676
|
-
class:
|
|
2750
|
+
class: this.#withSlotClass(
|
|
2751
|
+
"countrySelector",
|
|
2752
|
+
`iti__country-selector ${CLASSES.HIDE} ${extraClasses}`
|
|
2753
|
+
),
|
|
2677
2754
|
role: "dialog",
|
|
2678
2755
|
[ARIA.MODAL]: "true"
|
|
2679
2756
|
});
|
|
@@ -2686,7 +2763,7 @@ var _factory = (() => {
|
|
|
2686
2763
|
this.#countryListEl = createEl(
|
|
2687
2764
|
"ul",
|
|
2688
2765
|
{
|
|
2689
|
-
class: "iti__country-list",
|
|
2766
|
+
class: this.#withSlotClass("countryList", "iti__country-list"),
|
|
2690
2767
|
id: `iti-${this.#id}__country-listbox`,
|
|
2691
2768
|
role: "listbox",
|
|
2692
2769
|
[ARIA.LABEL]: uiTranslations.countryListAriaLabel
|
|
@@ -2705,7 +2782,9 @@ var _factory = (() => {
|
|
|
2705
2782
|
"iti--inline-country-selector": !isFullscreen,
|
|
2706
2783
|
[containerClass]: Boolean(containerClass)
|
|
2707
2784
|
});
|
|
2708
|
-
this.#detachedCountrySelectorEl = createEl("div", {
|
|
2785
|
+
this.#detachedCountrySelectorEl = createEl("div", {
|
|
2786
|
+
class: this.#withSlotClass("countrySelectorContainer", wrapperClasses)
|
|
2787
|
+
});
|
|
2709
2788
|
this.#detachedCountrySelectorEl.appendChild(this.#countrySelectorEl);
|
|
2710
2789
|
} else {
|
|
2711
2790
|
this.#countryContainerEl.appendChild(this.#countrySelectorEl);
|
|
@@ -2726,13 +2805,13 @@ var _factory = (() => {
|
|
|
2726
2805
|
const { uiTranslations, searchInputClass } = this.#options;
|
|
2727
2806
|
const searchWrapper = createEl(
|
|
2728
2807
|
"div",
|
|
2729
|
-
{ class: "iti__search-input-wrapper" },
|
|
2808
|
+
{ class: this.#withSlotClass("searchWrapper", "iti__search-input-wrapper") },
|
|
2730
2809
|
this.#countrySelectorEl
|
|
2731
2810
|
);
|
|
2732
2811
|
this.#searchIconEl = createEl(
|
|
2733
2812
|
"span",
|
|
2734
2813
|
{
|
|
2735
|
-
class: "iti__search-icon",
|
|
2814
|
+
class: this.#withSlotClass("searchIcon", "iti__search-icon"),
|
|
2736
2815
|
[ARIA.HIDDEN]: "true"
|
|
2737
2816
|
},
|
|
2738
2817
|
searchWrapper
|
|
@@ -2744,7 +2823,10 @@ var _factory = (() => {
|
|
|
2744
2823
|
id: `iti-${this.#id}__search-input`,
|
|
2745
2824
|
// Chrome says inputs need either a name or an id
|
|
2746
2825
|
type: "search",
|
|
2747
|
-
class:
|
|
2826
|
+
class: this.#withSlotClass(
|
|
2827
|
+
"searchInput",
|
|
2828
|
+
`iti__search-input ${searchInputClass}`
|
|
2829
|
+
),
|
|
2748
2830
|
placeholder: uiTranslations.searchPlaceholder,
|
|
2749
2831
|
// 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
|
|
2750
2832
|
role: "combobox",
|
|
@@ -2760,7 +2842,10 @@ var _factory = (() => {
|
|
|
2760
2842
|
"button",
|
|
2761
2843
|
{
|
|
2762
2844
|
type: "button",
|
|
2763
|
-
class:
|
|
2845
|
+
class: this.#withSlotClass(
|
|
2846
|
+
"searchClear",
|
|
2847
|
+
`iti__search-clear ${CLASSES.HIDE}`
|
|
2848
|
+
),
|
|
2764
2849
|
[ARIA.LABEL]: uiTranslations.clearSearchAriaLabel,
|
|
2765
2850
|
tabindex: "-1"
|
|
2766
2851
|
},
|
|
@@ -2775,7 +2860,7 @@ var _factory = (() => {
|
|
|
2775
2860
|
this.#noResultsMessageEl = createEl(
|
|
2776
2861
|
"div",
|
|
2777
2862
|
{
|
|
2778
|
-
class: `iti__no-results ${CLASSES.HIDE}
|
|
2863
|
+
class: this.#withSlotClass("noResults", `iti__no-results ${CLASSES.HIDE}`),
|
|
2779
2864
|
[ARIA.HIDDEN]: "true"
|
|
2780
2865
|
// all a11y messaging happens in this.#searchResultsLiveRegionEl
|
|
2781
2866
|
},
|
|
@@ -2829,11 +2914,9 @@ var _factory = (() => {
|
|
|
2829
2914
|
//* For each country: add a country list item <li> to the countryList <ul> container.
|
|
2830
2915
|
#appendListItems() {
|
|
2831
2916
|
const frag = document.createDocumentFragment();
|
|
2917
|
+
const liClass = this.#withSlotClass("countryListItem", CLASSES.COUNTRY_ITEM);
|
|
2832
2918
|
for (let i = 0; i < this.#countries.length; i++) {
|
|
2833
2919
|
const c = this.#countries[i];
|
|
2834
|
-
const liClass = buildClassNames({
|
|
2835
|
-
[CLASSES.COUNTRY_ITEM]: true
|
|
2836
|
-
});
|
|
2837
2920
|
const listItem = createEl("li", {
|
|
2838
2921
|
id: `iti-${this.#id}__item-${c.iso2}`,
|
|
2839
2922
|
class: liClass,
|
|
@@ -2845,11 +2928,28 @@ var _factory = (() => {
|
|
|
2845
2928
|
listItem.dataset[DATA_KEYS.ISO2] = c.iso2;
|
|
2846
2929
|
this.#listItemByIso2.set(c.iso2, listItem);
|
|
2847
2930
|
if (this.#options.showFlags) {
|
|
2848
|
-
createEl(
|
|
2931
|
+
createEl(
|
|
2932
|
+
"div",
|
|
2933
|
+
{
|
|
2934
|
+
class: this.#withSlotClass(
|
|
2935
|
+
"countryListItemFlag",
|
|
2936
|
+
`${CLASSES.FLAG} iti__${c.iso2}`
|
|
2937
|
+
)
|
|
2938
|
+
},
|
|
2939
|
+
listItem
|
|
2940
|
+
);
|
|
2849
2941
|
}
|
|
2850
|
-
const nameEl = createEl(
|
|
2942
|
+
const nameEl = createEl(
|
|
2943
|
+
"span",
|
|
2944
|
+
{ class: this.#withSlotClass("countryName", "iti__country-name") },
|
|
2945
|
+
listItem
|
|
2946
|
+
);
|
|
2851
2947
|
nameEl.textContent = `${c.name} `;
|
|
2852
|
-
const dialEl = createEl(
|
|
2948
|
+
const dialEl = createEl(
|
|
2949
|
+
"span",
|
|
2950
|
+
{ class: this.#withSlotClass("dialCode", "iti__dial-code") },
|
|
2951
|
+
nameEl
|
|
2952
|
+
);
|
|
2853
2953
|
if (this.#isRTL) {
|
|
2854
2954
|
dialEl.setAttribute("dir", "ltr");
|
|
2855
2955
|
}
|
|
@@ -3296,7 +3396,10 @@ var _factory = (() => {
|
|
|
3296
3396
|
newListItem.setAttribute(ARIA.SELECTED, "true");
|
|
3297
3397
|
const checkIcon = createEl(
|
|
3298
3398
|
"span",
|
|
3299
|
-
{
|
|
3399
|
+
{
|
|
3400
|
+
class: this.#withSlotClass("countryCheck", "iti__country-check"),
|
|
3401
|
+
[ARIA.HIDDEN]: "true"
|
|
3402
|
+
},
|
|
3300
3403
|
newListItem
|
|
3301
3404
|
);
|
|
3302
3405
|
checkIcon.appendChild(buildCheckIcon());
|
|
@@ -3483,7 +3586,10 @@ var _factory = (() => {
|
|
|
3483
3586
|
this.#updateSelectedListItem(iso2);
|
|
3484
3587
|
}
|
|
3485
3588
|
if (this.#selectedCountryEl) {
|
|
3486
|
-
const flagClass =
|
|
3589
|
+
const flagClass = this.#withSlotClass(
|
|
3590
|
+
"selectedFlag",
|
|
3591
|
+
iso2 && showFlags ? `${CLASSES.FLAG} iti__${iso2}` : `${CLASSES.FLAG} ${CLASSES.GLOBE}`
|
|
3592
|
+
);
|
|
3487
3593
|
let ariaLabel, title;
|
|
3488
3594
|
let flagContent = null;
|
|
3489
3595
|
if (iso2) {
|
|
@@ -4113,8 +4219,8 @@ var _factory = (() => {
|
|
|
4113
4219
|
const after = inputValue.slice(selEnd ?? void 0);
|
|
4114
4220
|
const newValue = before + normalisedKey + after;
|
|
4115
4221
|
const newFullNumber = this.#buildFullNumber(newValue);
|
|
4116
|
-
let hasExceededMaxLength =
|
|
4117
|
-
if (intlTelInput.utils && this.#maxCoreNumberLength) {
|
|
4222
|
+
let hasExceededMaxLength = getNumeric(newFullNumber).length > E164_MAX_DIGITS;
|
|
4223
|
+
if (!hasExceededMaxLength && intlTelInput.utils && this.#maxCoreNumberLength) {
|
|
4118
4224
|
const coreNumber = intlTelInput.utils.getCoreNumber(
|
|
4119
4225
|
newFullNumber,
|
|
4120
4226
|
this.#selectedCountry?.iso2
|
|
@@ -4179,44 +4285,35 @@ var _factory = (() => {
|
|
|
4179
4285
|
let newValue = before + sanitised + after;
|
|
4180
4286
|
let rejectReason = sanitised !== pasted ? "invalid" : null;
|
|
4181
4287
|
if (newValue.length > 30) {
|
|
4182
|
-
this.#
|
|
4183
|
-
this.#dispatchEvent(EVENTS.STRICT_REJECT, {
|
|
4184
|
-
source: "paste",
|
|
4185
|
-
rejectedInput: pastedRaw,
|
|
4186
|
-
reason: "max-length"
|
|
4187
|
-
});
|
|
4188
|
-
this.#restoreValueBeforeStrictPaste(pasteSnapshot);
|
|
4288
|
+
this.#rejectStrictPasteAsTooLong(pasteSnapshot);
|
|
4189
4289
|
return true;
|
|
4190
4290
|
}
|
|
4191
|
-
|
|
4291
|
+
const excessDigits = getNumeric(this.#buildFullNumber(newValue)).length - E164_MAX_DIGITS;
|
|
4292
|
+
if (excessDigits > 0) {
|
|
4293
|
+
if (selEnd !== originalValue.length) {
|
|
4294
|
+
this.#rejectStrictPasteAsTooLong(pasteSnapshot);
|
|
4295
|
+
return true;
|
|
4296
|
+
}
|
|
4297
|
+
newValue = newValue.slice(0, newValue.length - excessDigits);
|
|
4298
|
+
rejectReason = "max-length";
|
|
4299
|
+
}
|
|
4300
|
+
if (this.#maxCoreNumberLength && newValue.length > 5 && intlTelInput.utils) {
|
|
4192
4301
|
let coreNumber = intlTelInput.utils.getCoreNumber(newValue, iso2);
|
|
4193
4302
|
while (coreNumber.length === 0 && newValue.length > 0) {
|
|
4194
4303
|
newValue = newValue.slice(0, -1);
|
|
4195
4304
|
coreNumber = intlTelInput.utils.getCoreNumber(newValue, iso2);
|
|
4196
4305
|
}
|
|
4197
4306
|
if (!coreNumber) {
|
|
4198
|
-
this.#
|
|
4199
|
-
this.#dispatchEvent(EVENTS.STRICT_REJECT, {
|
|
4200
|
-
source: "paste",
|
|
4201
|
-
rejectedInput: pastedRaw,
|
|
4202
|
-
reason: "max-length"
|
|
4203
|
-
});
|
|
4204
|
-
this.#restoreValueBeforeStrictPaste(pasteSnapshot);
|
|
4307
|
+
this.#rejectStrictPasteAsTooLong(pasteSnapshot);
|
|
4205
4308
|
return true;
|
|
4206
4309
|
}
|
|
4207
|
-
if (
|
|
4310
|
+
if (coreNumber.length > this.#maxCoreNumberLength) {
|
|
4208
4311
|
if (selEnd === originalValue.length) {
|
|
4209
4312
|
const trimLength = coreNumber.length - this.#maxCoreNumberLength;
|
|
4210
4313
|
newValue = newValue.slice(0, newValue.length - trimLength);
|
|
4211
4314
|
rejectReason = "max-length";
|
|
4212
4315
|
} else {
|
|
4213
|
-
this.#
|
|
4214
|
-
this.#dispatchEvent(EVENTS.STRICT_REJECT, {
|
|
4215
|
-
source: "paste",
|
|
4216
|
-
rejectedInput: pastedRaw,
|
|
4217
|
-
reason: "max-length"
|
|
4218
|
-
});
|
|
4219
|
-
this.#restoreValueBeforeStrictPaste(pasteSnapshot);
|
|
4316
|
+
this.#rejectStrictPasteAsTooLong(pasteSnapshot);
|
|
4220
4317
|
return true;
|
|
4221
4318
|
}
|
|
4222
4319
|
}
|
|
@@ -4236,6 +4333,16 @@ var _factory = (() => {
|
|
|
4236
4333
|
}
|
|
4237
4334
|
return false;
|
|
4238
4335
|
}
|
|
4336
|
+
// Reject a paste entirely because it would exceed the max length, restoring the previous value.
|
|
4337
|
+
#rejectStrictPasteAsTooLong(pasteSnapshot) {
|
|
4338
|
+
this.#ui.playStrictRejectAnimation();
|
|
4339
|
+
this.#dispatchEvent(EVENTS.STRICT_REJECT, {
|
|
4340
|
+
source: "paste",
|
|
4341
|
+
rejectedInput: pasteSnapshot.pastedRaw,
|
|
4342
|
+
reason: "max-length"
|
|
4343
|
+
});
|
|
4344
|
+
this.#restoreValueBeforeStrictPaste(pasteSnapshot);
|
|
4345
|
+
}
|
|
4239
4346
|
#restoreValueBeforeStrictPaste(pasteSnapshot) {
|
|
4240
4347
|
this.#setTelInputValue(pasteSnapshot.value);
|
|
4241
4348
|
this.#ui.telInputEl.setSelectionRange(
|
|
@@ -4344,6 +4451,9 @@ var _factory = (() => {
|
|
|
4344
4451
|
if (currentDial && currentDial.startsWith(numeric)) {
|
|
4345
4452
|
return null;
|
|
4346
4453
|
}
|
|
4454
|
+
if (!selectedIso2) {
|
|
4455
|
+
return null;
|
|
4456
|
+
}
|
|
4347
4457
|
return "";
|
|
4348
4458
|
} else if ((!number || number === "+") && !selectedIso2 && this.#fallbackCountryIso2) {
|
|
4349
4459
|
return this.#fallbackCountryIso2;
|
|
@@ -4880,7 +4990,7 @@ var _factory = (() => {
|
|
|
4880
4990
|
attachUtils,
|
|
4881
4991
|
startedLoadingUtils: false,
|
|
4882
4992
|
startedLoadingAutoCountry: false,
|
|
4883
|
-
version: "29.1
|
|
4993
|
+
version: "29.2.1",
|
|
4884
4994
|
NUMBER_FORMAT,
|
|
4885
4995
|
NUMBER_TYPE,
|
|
4886
4996
|
VALIDATION_ERROR,
|