intl-tel-input 25.7.0 → 25.8.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/README.md +11 -11
- package/angular/README.md +1 -1
- package/angular/build/IntlTelInput.js +90 -40
- package/angular/build/IntlTelInputWithUtils.js +90 -40
- package/angular/build/types/intl-tel-input/i18n/types.d.ts +1 -0
- package/angular/build/types/intl-tel-input.d.ts +10 -1
- package/build/css/intlTelInput.css +70 -6
- package/build/css/intlTelInput.min.css +1 -1
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/i18n/en/interface.js +1 -0
- package/build/js/intlTelInput.d.ts +11 -1
- package/build/js/intlTelInput.js +107 -41
- package/build/js/intlTelInput.min.js +13 -2
- package/build/js/intlTelInputWithUtils.js +107 -41
- package/build/js/intlTelInputWithUtils.min.js +13 -2
- package/package.json +7 -12
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +106 -40
- package/react/build/IntlTelInput.d.ts +11 -1
- package/react/build/IntlTelInput.js +106 -40
- package/react/build/IntlTelInputWithUtils.cjs +106 -40
- package/react/build/IntlTelInputWithUtils.js +106 -40
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +201 -134
- package/vue/build/IntlTelInputWithUtils.mjs +737 -670
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "intl-tel-input",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.8.1",
|
|
4
4
|
"description": "A JavaScript plugin for entering and validating international telephone numbers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"international",
|
|
@@ -45,9 +45,8 @@
|
|
|
45
45
|
"esbuild": "^0.25.0",
|
|
46
46
|
"eslint": "^8.57.0",
|
|
47
47
|
"eslint-import-resolver-typescript": "^3.6.1",
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"eslint-plugin-jest": "^28.5.0",
|
|
48
|
+
"eslint-plugin-import": "^2.29.1",
|
|
49
|
+
"eslint-plugin-jest": "^28.5.0",
|
|
51
50
|
"eslint-plugin-react": "^7.34.1",
|
|
52
51
|
"eslint-plugin-react-hooks": "^4.6.2",
|
|
53
52
|
"flag-icons": "^7.2.3",
|
|
@@ -57,13 +56,11 @@
|
|
|
57
56
|
"grunt-bump": "^0.8.0",
|
|
58
57
|
"grunt-cli": "^1.2.0",
|
|
59
58
|
"grunt-contrib-connect": "^5.0.0",
|
|
60
|
-
|
|
61
|
-
"grunt-contrib-jasmine": "^4.0.0",
|
|
59
|
+
"grunt-contrib-cssmin": "^5.0.0",
|
|
62
60
|
"grunt-contrib-watch": "^1.1.0",
|
|
63
61
|
"grunt-replace": "^2.0.2",
|
|
64
62
|
"grunt-sass": "^3.0.0",
|
|
65
|
-
|
|
66
|
-
"jasmine-jquery": "^2.1.1",
|
|
63
|
+
"grunt-shell": "^4.0.0",
|
|
67
64
|
"jest": "^29.7.0",
|
|
68
65
|
"jest-environment-jsdom": "^29.7.0",
|
|
69
66
|
"jquery": "^3.1.1",
|
|
@@ -98,8 +95,7 @@
|
|
|
98
95
|
},
|
|
99
96
|
"homepage": "https://intl-tel-input.com",
|
|
100
97
|
"scripts": {
|
|
101
|
-
"test": "
|
|
102
|
-
"jest": "jest",
|
|
98
|
+
"test": "jest",
|
|
103
99
|
"lint:js": "eslint .",
|
|
104
100
|
"lint:spelling": "cspell --dot --gitignore --no-progress '**'",
|
|
105
101
|
"watch": "grunt watch",
|
|
@@ -114,8 +110,7 @@
|
|
|
114
110
|
"build:react": "grunt react",
|
|
115
111
|
"build:vue": "grunt vue",
|
|
116
112
|
"build:angular": "grunt angular",
|
|
117
|
-
|
|
118
|
-
"server": "grunt jasmine:interactive"
|
|
113
|
+
"vue:demo": "vite --config vue/demo/validation/vite.config.js"
|
|
119
114
|
},
|
|
120
115
|
"style": "build/css/intlTelInput.css",
|
|
121
116
|
"main": "./build/js/intlTelInput.js",
|
package/react/README.md
CHANGED
|
@@ -28,7 +28,7 @@ import "intl-tel-input/styles";
|
|
|
28
28
|
|
|
29
29
|
See the [Validation demo](https://github.com/jackocnr/intl-tel-input/blob/master/react/demo/validation/ValidationApp.tsx) for a more fleshed-out example of how to handle validation.
|
|
30
30
|
|
|
31
|
-
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/reactWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/react"` 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.
|
|
31
|
+
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/reactWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/react"` 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.8.1/build/js/utils.js"`.
|
|
32
32
|
|
|
33
33
|
## Props
|
|
34
34
|
Here's a list of all of the current props you can pass to the IntlTelInput React component.
|
|
@@ -1628,6 +1628,7 @@ var interfaceTranslations = {
|
|
|
1628
1628
|
noCountrySelected: "No country selected",
|
|
1629
1629
|
countryListAriaLabel: "List of countries",
|
|
1630
1630
|
searchPlaceholder: "Search",
|
|
1631
|
+
clearSearchAriaLabel: "Clear search",
|
|
1631
1632
|
zeroSearchResults: "No results found",
|
|
1632
1633
|
oneSearchResult: "1 result found",
|
|
1633
1634
|
multipleSearchResults: "${count} results found",
|
|
@@ -1756,8 +1757,8 @@ var translateCursorPosition = (relevantChars, formattedValue, prevCaretPos, isDe
|
|
|
1756
1757
|
}
|
|
1757
1758
|
return formattedValue.length;
|
|
1758
1759
|
};
|
|
1759
|
-
var createEl = (
|
|
1760
|
-
const el = document.createElement(
|
|
1760
|
+
var createEl = (tagName, attrs, container) => {
|
|
1761
|
+
const el = document.createElement(tagName);
|
|
1761
1762
|
if (attrs) {
|
|
1762
1763
|
Object.entries(attrs).forEach(([key, value]) => el.setAttribute(key, value));
|
|
1763
1764
|
}
|
|
@@ -1770,7 +1771,14 @@ var forEachInstance = (method, ...args) => {
|
|
|
1770
1771
|
const { instances } = intlTelInput;
|
|
1771
1772
|
Object.values(instances).forEach((instance) => instance[method](...args));
|
|
1772
1773
|
};
|
|
1773
|
-
var Iti = class {
|
|
1774
|
+
var Iti = class _Iti {
|
|
1775
|
+
/**
|
|
1776
|
+
* Build a space-delimited class string from an object map of className -> truthy/falsey.
|
|
1777
|
+
* Only keys with truthy values are included.
|
|
1778
|
+
*/
|
|
1779
|
+
static _buildClassNames(flags) {
|
|
1780
|
+
return Object.keys(flags).filter((k) => Boolean(flags[k])).join(" ");
|
|
1781
|
+
}
|
|
1774
1782
|
constructor(input, customOptions = {}) {
|
|
1775
1783
|
this.id = id++;
|
|
1776
1784
|
this.telInput = input;
|
|
@@ -1955,20 +1963,14 @@ var Iti = class {
|
|
|
1955
1963
|
countrySearch,
|
|
1956
1964
|
i18n
|
|
1957
1965
|
} = this.options;
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
}
|
|
1965
|
-
|
|
1966
|
-
parentClass += ` ${containerClass}`;
|
|
1967
|
-
}
|
|
1968
|
-
if (!useFullscreenPopup) {
|
|
1969
|
-
parentClass += " iti--inline-dropdown";
|
|
1970
|
-
}
|
|
1971
|
-
const wrapper = createEl("div", { class: parentClass });
|
|
1966
|
+
const parentClasses = _Iti._buildClassNames({
|
|
1967
|
+
"iti": true,
|
|
1968
|
+
"iti--allow-dropdown": allowDropdown,
|
|
1969
|
+
"iti--show-flags": showFlags,
|
|
1970
|
+
"iti--inline-dropdown": !useFullscreenPopup,
|
|
1971
|
+
[containerClass]: Boolean(containerClass)
|
|
1972
|
+
});
|
|
1973
|
+
const wrapper = createEl("div", { class: parentClasses });
|
|
1972
1974
|
this.telInput.parentNode?.insertBefore(wrapper, this.telInput);
|
|
1973
1975
|
if (allowDropdown || showFlags || separateDialCode) {
|
|
1974
1976
|
this.countryContainer = createEl(
|
|
@@ -1989,9 +1991,8 @@ var Iti = class {
|
|
|
1989
1991
|
class: "iti__selected-country",
|
|
1990
1992
|
"aria-expanded": "false",
|
|
1991
1993
|
"aria-label": this.options.i18n.selectedCountryAriaLabel,
|
|
1992
|
-
"aria-haspopup": "
|
|
1993
|
-
"aria-controls": `iti-${this.id}__dropdown-content
|
|
1994
|
-
"role": "combobox"
|
|
1994
|
+
"aria-haspopup": "dialog",
|
|
1995
|
+
"aria-controls": `iti-${this.id}__dropdown-content`
|
|
1995
1996
|
},
|
|
1996
1997
|
this.countryContainer
|
|
1997
1998
|
);
|
|
@@ -2030,15 +2031,38 @@ var Iti = class {
|
|
|
2030
2031
|
const extraClasses = fixDropdownWidth ? "" : "iti--flexible-dropdown-width";
|
|
2031
2032
|
this.dropdownContent = createEl("div", {
|
|
2032
2033
|
id: `iti-${this.id}__dropdown-content`,
|
|
2033
|
-
class: `iti__dropdown-content iti__hide ${extraClasses}
|
|
2034
|
+
class: `iti__dropdown-content iti__hide ${extraClasses}`,
|
|
2035
|
+
role: "dialog",
|
|
2036
|
+
"aria-modal": "true"
|
|
2034
2037
|
});
|
|
2035
2038
|
if (countrySearch) {
|
|
2039
|
+
const searchWrapper = createEl(
|
|
2040
|
+
"div",
|
|
2041
|
+
{ class: "iti__search-input-wrapper" },
|
|
2042
|
+
this.dropdownContent
|
|
2043
|
+
);
|
|
2044
|
+
this.searchIcon = createEl(
|
|
2045
|
+
"span",
|
|
2046
|
+
{
|
|
2047
|
+
class: "iti__search-icon",
|
|
2048
|
+
"aria-hidden": "true"
|
|
2049
|
+
},
|
|
2050
|
+
searchWrapper
|
|
2051
|
+
);
|
|
2052
|
+
this.searchIcon.innerHTML = `
|
|
2053
|
+
<svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" aria-hidden="true">
|
|
2054
|
+
<circle cx="11" cy="11" r="7" />
|
|
2055
|
+
<line x1="21" y1="21" x2="16.65" y2="16.65" />
|
|
2056
|
+
</svg>`;
|
|
2036
2057
|
this.searchInput = createEl(
|
|
2037
2058
|
"input",
|
|
2038
2059
|
{
|
|
2039
|
-
|
|
2060
|
+
id: `iti-${this.id}__search-input`,
|
|
2061
|
+
// Chrome says inputs need either a name or an id
|
|
2062
|
+
type: "search",
|
|
2040
2063
|
class: "iti__search-input",
|
|
2041
2064
|
placeholder: i18n.searchPlaceholder,
|
|
2065
|
+
// 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
|
|
2042
2066
|
role: "combobox",
|
|
2043
2067
|
"aria-expanded": "true",
|
|
2044
2068
|
"aria-label": i18n.searchPlaceholder,
|
|
@@ -2046,13 +2070,42 @@ var Iti = class {
|
|
|
2046
2070
|
"aria-autocomplete": "list",
|
|
2047
2071
|
"autocomplete": "off"
|
|
2048
2072
|
},
|
|
2049
|
-
|
|
2073
|
+
searchWrapper
|
|
2074
|
+
);
|
|
2075
|
+
this.searchClearButton = createEl(
|
|
2076
|
+
"button",
|
|
2077
|
+
{
|
|
2078
|
+
type: "button",
|
|
2079
|
+
class: "iti__search-clear iti__hide",
|
|
2080
|
+
"aria-label": i18n.clearSearchAriaLabel,
|
|
2081
|
+
tabindex: "-1"
|
|
2082
|
+
},
|
|
2083
|
+
searchWrapper
|
|
2050
2084
|
);
|
|
2085
|
+
const maskId = `iti-${this.id}-clear-mask`;
|
|
2086
|
+
this.searchClearButton.innerHTML = `
|
|
2087
|
+
<svg class="iti__search-clear-svg" width="12" height="12" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
2088
|
+
<mask id="${maskId}" maskUnits="userSpaceOnUse">
|
|
2089
|
+
<rect width="16" height="16" fill="white" />
|
|
2090
|
+
<path d="M5.2 5.2 L10.8 10.8 M10.8 5.2 L5.2 10.8" stroke="black" stroke-linecap="round" class="iti__search-clear-x" />
|
|
2091
|
+
</mask>
|
|
2092
|
+
<circle cx="8" cy="8" r="8" class="iti__search-clear-bg" mask="url(#${maskId})" />
|
|
2093
|
+
</svg>`;
|
|
2051
2094
|
this.searchResultsA11yText = createEl(
|
|
2052
2095
|
"span",
|
|
2053
2096
|
{ class: "iti__a11y-text" },
|
|
2054
2097
|
this.dropdownContent
|
|
2055
2098
|
);
|
|
2099
|
+
this.searchNoResults = createEl(
|
|
2100
|
+
"div",
|
|
2101
|
+
{
|
|
2102
|
+
class: "iti__no-results iti__hide",
|
|
2103
|
+
"aria-hidden": "true"
|
|
2104
|
+
// all a11y messaging happens in this.searchResultsA11yText
|
|
2105
|
+
},
|
|
2106
|
+
this.dropdownContent
|
|
2107
|
+
);
|
|
2108
|
+
this.searchNoResults.textContent = i18n.zeroSearchResults;
|
|
2056
2109
|
}
|
|
2057
2110
|
this.countryList = createEl(
|
|
2058
2111
|
"ul",
|
|
@@ -2066,18 +2119,16 @@ var Iti = class {
|
|
|
2066
2119
|
);
|
|
2067
2120
|
this._appendListItems();
|
|
2068
2121
|
if (countrySearch) {
|
|
2069
|
-
this.
|
|
2122
|
+
this._updateSearchResultsA11yText();
|
|
2070
2123
|
}
|
|
2071
2124
|
if (dropdownContainer) {
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
}
|
|
2079
|
-
dropdownClasses += " iti--inline-dropdown";
|
|
2080
|
-
}
|
|
2125
|
+
const dropdownClasses = _Iti._buildClassNames({
|
|
2126
|
+
"iti": true,
|
|
2127
|
+
"iti--container": true,
|
|
2128
|
+
"iti--fullscreen-popup": useFullscreenPopup,
|
|
2129
|
+
"iti--inline-dropdown": !useFullscreenPopup,
|
|
2130
|
+
[containerClass]: Boolean(containerClass)
|
|
2131
|
+
});
|
|
2081
2132
|
this.dropdown = createEl("div", { class: dropdownClasses });
|
|
2082
2133
|
this.dropdown.appendChild(this.dropdownContent);
|
|
2083
2134
|
} else {
|
|
@@ -2475,6 +2526,11 @@ var Iti = class {
|
|
|
2475
2526
|
} else {
|
|
2476
2527
|
this._filterCountries("", true);
|
|
2477
2528
|
}
|
|
2529
|
+
if (this.searchInput.value) {
|
|
2530
|
+
this.searchClearButton.classList.remove("iti__hide");
|
|
2531
|
+
} else {
|
|
2532
|
+
this.searchClearButton.classList.add("iti__hide");
|
|
2533
|
+
}
|
|
2478
2534
|
};
|
|
2479
2535
|
let keyupTimer = null;
|
|
2480
2536
|
this._handleSearchChange = () => {
|
|
@@ -2487,6 +2543,13 @@ var Iti = class {
|
|
|
2487
2543
|
}, 100);
|
|
2488
2544
|
};
|
|
2489
2545
|
this.searchInput.addEventListener("input", this._handleSearchChange);
|
|
2546
|
+
this._handleSearchClear = (e) => {
|
|
2547
|
+
e.stopPropagation();
|
|
2548
|
+
this.searchInput.value = "";
|
|
2549
|
+
this.searchInput.focus();
|
|
2550
|
+
doFilter();
|
|
2551
|
+
};
|
|
2552
|
+
this.searchClearButton.addEventListener("click", this._handleSearchClear);
|
|
2490
2553
|
this.searchInput.addEventListener("click", (e) => e.stopPropagation());
|
|
2491
2554
|
}
|
|
2492
2555
|
}
|
|
@@ -2551,12 +2614,17 @@ var Iti = class {
|
|
|
2551
2614
|
}
|
|
2552
2615
|
if (noCountriesAddedYet) {
|
|
2553
2616
|
this._highlightListItem(null, false);
|
|
2617
|
+
if (this.searchNoResults) {
|
|
2618
|
+
this.searchNoResults.classList.remove("iti__hide");
|
|
2619
|
+
}
|
|
2620
|
+
} else if (this.searchNoResults) {
|
|
2621
|
+
this.searchNoResults.classList.add("iti__hide");
|
|
2554
2622
|
}
|
|
2555
2623
|
this.countryList.scrollTop = 0;
|
|
2556
|
-
this.
|
|
2624
|
+
this._updateSearchResultsA11yText();
|
|
2557
2625
|
}
|
|
2558
2626
|
//* Update search results text (for a11y).
|
|
2559
|
-
|
|
2627
|
+
_updateSearchResultsA11yText() {
|
|
2560
2628
|
const { i18n } = this.options;
|
|
2561
2629
|
const count = this.countryList.childElementCount;
|
|
2562
2630
|
let searchText;
|
|
@@ -2671,9 +2739,8 @@ var Iti = class {
|
|
|
2671
2739
|
if (this.highlightedItem) {
|
|
2672
2740
|
this.highlightedItem.classList.add("iti__highlight");
|
|
2673
2741
|
this.highlightedItem.setAttribute("aria-selected", "true");
|
|
2674
|
-
const activeDescendant = this.highlightedItem.getAttribute("id") || "";
|
|
2675
|
-
this.selectedCountry.setAttribute("aria-activedescendant", activeDescendant);
|
|
2676
2742
|
if (this.options.countrySearch) {
|
|
2743
|
+
const activeDescendant = this.highlightedItem.getAttribute("id") || "";
|
|
2677
2744
|
this.searchInput.setAttribute("aria-activedescendant", activeDescendant);
|
|
2678
2745
|
}
|
|
2679
2746
|
}
|
|
@@ -2837,7 +2904,6 @@ var Iti = class {
|
|
|
2837
2904
|
_closeDropdown() {
|
|
2838
2905
|
this.dropdownContent.classList.add("iti__hide");
|
|
2839
2906
|
this.selectedCountry.setAttribute("aria-expanded", "false");
|
|
2840
|
-
this.selectedCountry.removeAttribute("aria-activedescendant");
|
|
2841
2907
|
if (this.highlightedItem) {
|
|
2842
2908
|
this.highlightedItem.setAttribute("aria-selected", "false");
|
|
2843
2909
|
}
|
|
@@ -2845,9 +2911,9 @@ var Iti = class {
|
|
|
2845
2911
|
this.searchInput.removeAttribute("aria-activedescendant");
|
|
2846
2912
|
}
|
|
2847
2913
|
this.dropdownArrow.classList.remove("iti__arrow--up");
|
|
2848
|
-
document.removeEventListener("keydown", this._handleKeydownOnDropdown);
|
|
2849
2914
|
if (this.options.countrySearch) {
|
|
2850
2915
|
this.searchInput.removeEventListener("input", this._handleSearchChange);
|
|
2916
|
+
this.searchClearButton.removeEventListener("click", this._handleSearchClear);
|
|
2851
2917
|
}
|
|
2852
2918
|
document.documentElement.removeEventListener(
|
|
2853
2919
|
"click",
|
|
@@ -3205,7 +3271,7 @@ var intlTelInput = Object.assign(
|
|
|
3205
3271
|
attachUtils,
|
|
3206
3272
|
startedLoadingUtilsScript: false,
|
|
3207
3273
|
startedLoadingAutoCountry: false,
|
|
3208
|
-
version: "25.
|
|
3274
|
+
version: "25.8.1"
|
|
3209
3275
|
}
|
|
3210
3276
|
);
|
|
3211
3277
|
var intl_tel_input_default = intlTelInput;
|
|
@@ -264,6 +264,7 @@ declare module "intl-tel-input/i18n/types" {
|
|
|
264
264
|
ax?: string;
|
|
265
265
|
selectedCountryAriaLabel?: string;
|
|
266
266
|
searchPlaceholder?: string;
|
|
267
|
+
clearSearchAriaLabel?: string;
|
|
267
268
|
countryListAriaLabel?: string;
|
|
268
269
|
oneSearchResult?: string;
|
|
269
270
|
multipleSearchResults?: string;
|
|
@@ -397,6 +398,9 @@ declare module "intl-tel-input" {
|
|
|
397
398
|
private dropdownArrow;
|
|
398
399
|
private dropdownContent;
|
|
399
400
|
private searchInput;
|
|
401
|
+
private searchIcon;
|
|
402
|
+
private searchClearButton;
|
|
403
|
+
private searchNoResults;
|
|
400
404
|
private searchResultsA11yText;
|
|
401
405
|
private countryList;
|
|
402
406
|
private dropdown;
|
|
@@ -418,11 +422,17 @@ declare module "intl-tel-input" {
|
|
|
418
422
|
private _handleClickOffToClose;
|
|
419
423
|
private _handleKeydownOnDropdown;
|
|
420
424
|
private _handleSearchChange;
|
|
425
|
+
private _handleSearchClear;
|
|
421
426
|
private _handlePageLoad;
|
|
422
427
|
private resolveAutoCountryPromise;
|
|
423
428
|
private rejectAutoCountryPromise;
|
|
424
429
|
private resolveUtilsScriptPromise;
|
|
425
430
|
private rejectUtilsScriptPromise;
|
|
431
|
+
/**
|
|
432
|
+
* Build a space-delimited class string from an object map of className -> truthy/falsey.
|
|
433
|
+
* Only keys with truthy values are included.
|
|
434
|
+
*/
|
|
435
|
+
private static _buildClassNames;
|
|
426
436
|
constructor(input: HTMLInputElement, customOptions?: SomeOptions);
|
|
427
437
|
_init(): void;
|
|
428
438
|
private _processCountryData;
|
|
@@ -449,7 +459,7 @@ declare module "intl-tel-input" {
|
|
|
449
459
|
private _bindDropdownListeners;
|
|
450
460
|
private _searchForCountry;
|
|
451
461
|
private _filterCountries;
|
|
452
|
-
private
|
|
462
|
+
private _updateSearchResultsA11yText;
|
|
453
463
|
private _handleUpDownKey;
|
|
454
464
|
private _handleEnterKey;
|
|
455
465
|
private _updateValFromNumber;
|
|
@@ -1592,6 +1592,7 @@ var interfaceTranslations = {
|
|
|
1592
1592
|
noCountrySelected: "No country selected",
|
|
1593
1593
|
countryListAriaLabel: "List of countries",
|
|
1594
1594
|
searchPlaceholder: "Search",
|
|
1595
|
+
clearSearchAriaLabel: "Clear search",
|
|
1595
1596
|
zeroSearchResults: "No results found",
|
|
1596
1597
|
oneSearchResult: "1 result found",
|
|
1597
1598
|
multipleSearchResults: "${count} results found",
|
|
@@ -1720,8 +1721,8 @@ var translateCursorPosition = (relevantChars, formattedValue, prevCaretPos, isDe
|
|
|
1720
1721
|
}
|
|
1721
1722
|
return formattedValue.length;
|
|
1722
1723
|
};
|
|
1723
|
-
var createEl = (
|
|
1724
|
-
const el = document.createElement(
|
|
1724
|
+
var createEl = (tagName, attrs, container) => {
|
|
1725
|
+
const el = document.createElement(tagName);
|
|
1725
1726
|
if (attrs) {
|
|
1726
1727
|
Object.entries(attrs).forEach(([key, value]) => el.setAttribute(key, value));
|
|
1727
1728
|
}
|
|
@@ -1734,7 +1735,14 @@ var forEachInstance = (method, ...args) => {
|
|
|
1734
1735
|
const { instances } = intlTelInput;
|
|
1735
1736
|
Object.values(instances).forEach((instance) => instance[method](...args));
|
|
1736
1737
|
};
|
|
1737
|
-
var Iti = class {
|
|
1738
|
+
var Iti = class _Iti {
|
|
1739
|
+
/**
|
|
1740
|
+
* Build a space-delimited class string from an object map of className -> truthy/falsey.
|
|
1741
|
+
* Only keys with truthy values are included.
|
|
1742
|
+
*/
|
|
1743
|
+
static _buildClassNames(flags) {
|
|
1744
|
+
return Object.keys(flags).filter((k) => Boolean(flags[k])).join(" ");
|
|
1745
|
+
}
|
|
1738
1746
|
constructor(input, customOptions = {}) {
|
|
1739
1747
|
this.id = id++;
|
|
1740
1748
|
this.telInput = input;
|
|
@@ -1919,20 +1927,14 @@ var Iti = class {
|
|
|
1919
1927
|
countrySearch,
|
|
1920
1928
|
i18n
|
|
1921
1929
|
} = this.options;
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
}
|
|
1929
|
-
|
|
1930
|
-
parentClass += ` ${containerClass}`;
|
|
1931
|
-
}
|
|
1932
|
-
if (!useFullscreenPopup) {
|
|
1933
|
-
parentClass += " iti--inline-dropdown";
|
|
1934
|
-
}
|
|
1935
|
-
const wrapper = createEl("div", { class: parentClass });
|
|
1930
|
+
const parentClasses = _Iti._buildClassNames({
|
|
1931
|
+
"iti": true,
|
|
1932
|
+
"iti--allow-dropdown": allowDropdown,
|
|
1933
|
+
"iti--show-flags": showFlags,
|
|
1934
|
+
"iti--inline-dropdown": !useFullscreenPopup,
|
|
1935
|
+
[containerClass]: Boolean(containerClass)
|
|
1936
|
+
});
|
|
1937
|
+
const wrapper = createEl("div", { class: parentClasses });
|
|
1936
1938
|
this.telInput.parentNode?.insertBefore(wrapper, this.telInput);
|
|
1937
1939
|
if (allowDropdown || showFlags || separateDialCode) {
|
|
1938
1940
|
this.countryContainer = createEl(
|
|
@@ -1953,9 +1955,8 @@ var Iti = class {
|
|
|
1953
1955
|
class: "iti__selected-country",
|
|
1954
1956
|
"aria-expanded": "false",
|
|
1955
1957
|
"aria-label": this.options.i18n.selectedCountryAriaLabel,
|
|
1956
|
-
"aria-haspopup": "
|
|
1957
|
-
"aria-controls": `iti-${this.id}__dropdown-content
|
|
1958
|
-
"role": "combobox"
|
|
1958
|
+
"aria-haspopup": "dialog",
|
|
1959
|
+
"aria-controls": `iti-${this.id}__dropdown-content`
|
|
1959
1960
|
},
|
|
1960
1961
|
this.countryContainer
|
|
1961
1962
|
);
|
|
@@ -1994,15 +1995,38 @@ var Iti = class {
|
|
|
1994
1995
|
const extraClasses = fixDropdownWidth ? "" : "iti--flexible-dropdown-width";
|
|
1995
1996
|
this.dropdownContent = createEl("div", {
|
|
1996
1997
|
id: `iti-${this.id}__dropdown-content`,
|
|
1997
|
-
class: `iti__dropdown-content iti__hide ${extraClasses}
|
|
1998
|
+
class: `iti__dropdown-content iti__hide ${extraClasses}`,
|
|
1999
|
+
role: "dialog",
|
|
2000
|
+
"aria-modal": "true"
|
|
1998
2001
|
});
|
|
1999
2002
|
if (countrySearch) {
|
|
2003
|
+
const searchWrapper = createEl(
|
|
2004
|
+
"div",
|
|
2005
|
+
{ class: "iti__search-input-wrapper" },
|
|
2006
|
+
this.dropdownContent
|
|
2007
|
+
);
|
|
2008
|
+
this.searchIcon = createEl(
|
|
2009
|
+
"span",
|
|
2010
|
+
{
|
|
2011
|
+
class: "iti__search-icon",
|
|
2012
|
+
"aria-hidden": "true"
|
|
2013
|
+
},
|
|
2014
|
+
searchWrapper
|
|
2015
|
+
);
|
|
2016
|
+
this.searchIcon.innerHTML = `
|
|
2017
|
+
<svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" aria-hidden="true">
|
|
2018
|
+
<circle cx="11" cy="11" r="7" />
|
|
2019
|
+
<line x1="21" y1="21" x2="16.65" y2="16.65" />
|
|
2020
|
+
</svg>`;
|
|
2000
2021
|
this.searchInput = createEl(
|
|
2001
2022
|
"input",
|
|
2002
2023
|
{
|
|
2003
|
-
|
|
2024
|
+
id: `iti-${this.id}__search-input`,
|
|
2025
|
+
// Chrome says inputs need either a name or an id
|
|
2026
|
+
type: "search",
|
|
2004
2027
|
class: "iti__search-input",
|
|
2005
2028
|
placeholder: i18n.searchPlaceholder,
|
|
2029
|
+
// 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
|
|
2006
2030
|
role: "combobox",
|
|
2007
2031
|
"aria-expanded": "true",
|
|
2008
2032
|
"aria-label": i18n.searchPlaceholder,
|
|
@@ -2010,13 +2034,42 @@ var Iti = class {
|
|
|
2010
2034
|
"aria-autocomplete": "list",
|
|
2011
2035
|
"autocomplete": "off"
|
|
2012
2036
|
},
|
|
2013
|
-
|
|
2037
|
+
searchWrapper
|
|
2038
|
+
);
|
|
2039
|
+
this.searchClearButton = createEl(
|
|
2040
|
+
"button",
|
|
2041
|
+
{
|
|
2042
|
+
type: "button",
|
|
2043
|
+
class: "iti__search-clear iti__hide",
|
|
2044
|
+
"aria-label": i18n.clearSearchAriaLabel,
|
|
2045
|
+
tabindex: "-1"
|
|
2046
|
+
},
|
|
2047
|
+
searchWrapper
|
|
2014
2048
|
);
|
|
2049
|
+
const maskId = `iti-${this.id}-clear-mask`;
|
|
2050
|
+
this.searchClearButton.innerHTML = `
|
|
2051
|
+
<svg class="iti__search-clear-svg" width="12" height="12" viewBox="0 0 16 16" aria-hidden="true" focusable="false">
|
|
2052
|
+
<mask id="${maskId}" maskUnits="userSpaceOnUse">
|
|
2053
|
+
<rect width="16" height="16" fill="white" />
|
|
2054
|
+
<path d="M5.2 5.2 L10.8 10.8 M10.8 5.2 L5.2 10.8" stroke="black" stroke-linecap="round" class="iti__search-clear-x" />
|
|
2055
|
+
</mask>
|
|
2056
|
+
<circle cx="8" cy="8" r="8" class="iti__search-clear-bg" mask="url(#${maskId})" />
|
|
2057
|
+
</svg>`;
|
|
2015
2058
|
this.searchResultsA11yText = createEl(
|
|
2016
2059
|
"span",
|
|
2017
2060
|
{ class: "iti__a11y-text" },
|
|
2018
2061
|
this.dropdownContent
|
|
2019
2062
|
);
|
|
2063
|
+
this.searchNoResults = createEl(
|
|
2064
|
+
"div",
|
|
2065
|
+
{
|
|
2066
|
+
class: "iti__no-results iti__hide",
|
|
2067
|
+
"aria-hidden": "true"
|
|
2068
|
+
// all a11y messaging happens in this.searchResultsA11yText
|
|
2069
|
+
},
|
|
2070
|
+
this.dropdownContent
|
|
2071
|
+
);
|
|
2072
|
+
this.searchNoResults.textContent = i18n.zeroSearchResults;
|
|
2020
2073
|
}
|
|
2021
2074
|
this.countryList = createEl(
|
|
2022
2075
|
"ul",
|
|
@@ -2030,18 +2083,16 @@ var Iti = class {
|
|
|
2030
2083
|
);
|
|
2031
2084
|
this._appendListItems();
|
|
2032
2085
|
if (countrySearch) {
|
|
2033
|
-
this.
|
|
2086
|
+
this._updateSearchResultsA11yText();
|
|
2034
2087
|
}
|
|
2035
2088
|
if (dropdownContainer) {
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
}
|
|
2043
|
-
dropdownClasses += " iti--inline-dropdown";
|
|
2044
|
-
}
|
|
2089
|
+
const dropdownClasses = _Iti._buildClassNames({
|
|
2090
|
+
"iti": true,
|
|
2091
|
+
"iti--container": true,
|
|
2092
|
+
"iti--fullscreen-popup": useFullscreenPopup,
|
|
2093
|
+
"iti--inline-dropdown": !useFullscreenPopup,
|
|
2094
|
+
[containerClass]: Boolean(containerClass)
|
|
2095
|
+
});
|
|
2045
2096
|
this.dropdown = createEl("div", { class: dropdownClasses });
|
|
2046
2097
|
this.dropdown.appendChild(this.dropdownContent);
|
|
2047
2098
|
} else {
|
|
@@ -2439,6 +2490,11 @@ var Iti = class {
|
|
|
2439
2490
|
} else {
|
|
2440
2491
|
this._filterCountries("", true);
|
|
2441
2492
|
}
|
|
2493
|
+
if (this.searchInput.value) {
|
|
2494
|
+
this.searchClearButton.classList.remove("iti__hide");
|
|
2495
|
+
} else {
|
|
2496
|
+
this.searchClearButton.classList.add("iti__hide");
|
|
2497
|
+
}
|
|
2442
2498
|
};
|
|
2443
2499
|
let keyupTimer = null;
|
|
2444
2500
|
this._handleSearchChange = () => {
|
|
@@ -2451,6 +2507,13 @@ var Iti = class {
|
|
|
2451
2507
|
}, 100);
|
|
2452
2508
|
};
|
|
2453
2509
|
this.searchInput.addEventListener("input", this._handleSearchChange);
|
|
2510
|
+
this._handleSearchClear = (e) => {
|
|
2511
|
+
e.stopPropagation();
|
|
2512
|
+
this.searchInput.value = "";
|
|
2513
|
+
this.searchInput.focus();
|
|
2514
|
+
doFilter();
|
|
2515
|
+
};
|
|
2516
|
+
this.searchClearButton.addEventListener("click", this._handleSearchClear);
|
|
2454
2517
|
this.searchInput.addEventListener("click", (e) => e.stopPropagation());
|
|
2455
2518
|
}
|
|
2456
2519
|
}
|
|
@@ -2515,12 +2578,17 @@ var Iti = class {
|
|
|
2515
2578
|
}
|
|
2516
2579
|
if (noCountriesAddedYet) {
|
|
2517
2580
|
this._highlightListItem(null, false);
|
|
2581
|
+
if (this.searchNoResults) {
|
|
2582
|
+
this.searchNoResults.classList.remove("iti__hide");
|
|
2583
|
+
}
|
|
2584
|
+
} else if (this.searchNoResults) {
|
|
2585
|
+
this.searchNoResults.classList.add("iti__hide");
|
|
2518
2586
|
}
|
|
2519
2587
|
this.countryList.scrollTop = 0;
|
|
2520
|
-
this.
|
|
2588
|
+
this._updateSearchResultsA11yText();
|
|
2521
2589
|
}
|
|
2522
2590
|
//* Update search results text (for a11y).
|
|
2523
|
-
|
|
2591
|
+
_updateSearchResultsA11yText() {
|
|
2524
2592
|
const { i18n } = this.options;
|
|
2525
2593
|
const count = this.countryList.childElementCount;
|
|
2526
2594
|
let searchText;
|
|
@@ -2635,9 +2703,8 @@ var Iti = class {
|
|
|
2635
2703
|
if (this.highlightedItem) {
|
|
2636
2704
|
this.highlightedItem.classList.add("iti__highlight");
|
|
2637
2705
|
this.highlightedItem.setAttribute("aria-selected", "true");
|
|
2638
|
-
const activeDescendant = this.highlightedItem.getAttribute("id") || "";
|
|
2639
|
-
this.selectedCountry.setAttribute("aria-activedescendant", activeDescendant);
|
|
2640
2706
|
if (this.options.countrySearch) {
|
|
2707
|
+
const activeDescendant = this.highlightedItem.getAttribute("id") || "";
|
|
2641
2708
|
this.searchInput.setAttribute("aria-activedescendant", activeDescendant);
|
|
2642
2709
|
}
|
|
2643
2710
|
}
|
|
@@ -2801,7 +2868,6 @@ var Iti = class {
|
|
|
2801
2868
|
_closeDropdown() {
|
|
2802
2869
|
this.dropdownContent.classList.add("iti__hide");
|
|
2803
2870
|
this.selectedCountry.setAttribute("aria-expanded", "false");
|
|
2804
|
-
this.selectedCountry.removeAttribute("aria-activedescendant");
|
|
2805
2871
|
if (this.highlightedItem) {
|
|
2806
2872
|
this.highlightedItem.setAttribute("aria-selected", "false");
|
|
2807
2873
|
}
|
|
@@ -2809,9 +2875,9 @@ var Iti = class {
|
|
|
2809
2875
|
this.searchInput.removeAttribute("aria-activedescendant");
|
|
2810
2876
|
}
|
|
2811
2877
|
this.dropdownArrow.classList.remove("iti__arrow--up");
|
|
2812
|
-
document.removeEventListener("keydown", this._handleKeydownOnDropdown);
|
|
2813
2878
|
if (this.options.countrySearch) {
|
|
2814
2879
|
this.searchInput.removeEventListener("input", this._handleSearchChange);
|
|
2880
|
+
this.searchClearButton.removeEventListener("click", this._handleSearchClear);
|
|
2815
2881
|
}
|
|
2816
2882
|
document.documentElement.removeEventListener(
|
|
2817
2883
|
"click",
|
|
@@ -3169,7 +3235,7 @@ var intlTelInput = Object.assign(
|
|
|
3169
3235
|
attachUtils,
|
|
3170
3236
|
startedLoadingUtilsScript: false,
|
|
3171
3237
|
startedLoadingAutoCountry: false,
|
|
3172
|
-
version: "25.
|
|
3238
|
+
version: "25.8.1"
|
|
3173
3239
|
}
|
|
3174
3240
|
);
|
|
3175
3241
|
var intl_tel_input_default = intlTelInput;
|