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
|
@@ -1677,17 +1677,17 @@ const rt = [
|
|
|
1677
1677
|
"0"
|
|
1678
1678
|
]
|
|
1679
1679
|
], A = [];
|
|
1680
|
-
for (const
|
|
1680
|
+
for (const l of rt)
|
|
1681
1681
|
A.push({
|
|
1682
1682
|
name: "",
|
|
1683
1683
|
// populated in the plugin
|
|
1684
|
-
iso2:
|
|
1685
|
-
dialCode:
|
|
1686
|
-
priority:
|
|
1687
|
-
areaCodes:
|
|
1684
|
+
iso2: l[0],
|
|
1685
|
+
dialCode: l[1],
|
|
1686
|
+
priority: l[2] || 0,
|
|
1687
|
+
areaCodes: l[3] || null,
|
|
1688
1688
|
nodeById: {},
|
|
1689
1689
|
// populated by the plugin
|
|
1690
|
-
nationalPrefix:
|
|
1690
|
+
nationalPrefix: l[4] || null,
|
|
1691
1691
|
normalisedName: "",
|
|
1692
1692
|
// populated in the plugin
|
|
1693
1693
|
initials: "",
|
|
@@ -1950,7 +1950,7 @@ const lt = {
|
|
|
1950
1950
|
// additional countries (not supported by country-list library)
|
|
1951
1951
|
ac: "Ascension Island",
|
|
1952
1952
|
xk: "Kosovo"
|
|
1953
|
-
}, j = { ...lt, ...at },
|
|
1953
|
+
}, j = { ...lt, ...at }, T = {
|
|
1954
1954
|
OPEN_COUNTRY_DROPDOWN: "open:countrydropdown",
|
|
1955
1955
|
CLOSE_COUNTRY_DROPDOWN: "close:countrydropdown",
|
|
1956
1956
|
COUNTRY_CHANGE: "countrychange",
|
|
@@ -1974,7 +1974,7 @@ const lt = {
|
|
|
1974
1974
|
}, F = {
|
|
1975
1975
|
PASTE: "insertFromPaste",
|
|
1976
1976
|
DELETE_FWD: "deleteContentForward"
|
|
1977
|
-
},
|
|
1977
|
+
}, E = {
|
|
1978
1978
|
ALPHA_UNICODE: new RegExp("\\p{L}", "u"),
|
|
1979
1979
|
// any kind of letter from any language
|
|
1980
1980
|
NON_PLUS_NUMERIC: /[^+0-9]/,
|
|
@@ -2015,7 +2015,7 @@ const lt = {
|
|
|
2015
2015
|
}, G = {
|
|
2016
2016
|
COUNTRY_CODE: "countryCode",
|
|
2017
2017
|
DIAL_CODE: "dialCode"
|
|
2018
|
-
},
|
|
2018
|
+
}, m = {
|
|
2019
2019
|
EXPANDED: "aria-expanded",
|
|
2020
2020
|
LABEL: "aria-label",
|
|
2021
2021
|
SELECTED: "aria-selected",
|
|
@@ -2025,12 +2025,12 @@ const lt = {
|
|
|
2025
2025
|
HIDDEN: "aria-hidden",
|
|
2026
2026
|
AUTOCOMPLETE: "aria-autocomplete",
|
|
2027
2027
|
MODAL: "aria-modal"
|
|
2028
|
-
}, x = (
|
|
2028
|
+
}, x = (l) => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(l).matches, ct = () => {
|
|
2029
2029
|
if (typeof navigator < "u" && typeof window < "u") {
|
|
2030
|
-
const
|
|
2030
|
+
const l = /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
2031
2031
|
navigator.userAgent
|
|
2032
2032
|
), t = x("(max-width: 500px)"), e = x("(max-height: 600px)"), i = x("(pointer: coarse)");
|
|
2033
|
-
return
|
|
2033
|
+
return l || t || i && e;
|
|
2034
2034
|
}
|
|
2035
2035
|
return !1;
|
|
2036
2036
|
}, Y = {
|
|
@@ -2084,40 +2084,40 @@ const lt = {
|
|
|
2084
2084
|
useFullscreenPopup: ct(),
|
|
2085
2085
|
//* The number type to enforce during validation.
|
|
2086
2086
|
validationNumberTypes: ["MOBILE"]
|
|
2087
|
-
}, ht = (
|
|
2088
|
-
|
|
2089
|
-
}, v = (
|
|
2090
|
-
const e = q(t), i = [], s = [], o = [], n = [],
|
|
2091
|
-
for (const c of
|
|
2092
|
-
c.iso2 === e ? i.push(c) : c.normalisedName.startsWith(e) ? s.push(c) : c.normalisedName.includes(e) ? o.push(c) : e === c.dialCode || e === c.dialCodePlus ? n.push(c) : c.dialCodePlus.includes(e) ?
|
|
2093
|
-
const d = (c,
|
|
2087
|
+
}, ht = (l, t) => {
|
|
2088
|
+
l.useFullscreenPopup && (l.fixDropdownWidth = !1), l.onlyCountries.length === 1 && (l.initialCountry = l.onlyCountries[0]), l.separateDialCode && (l.nationalMode = !1), l.allowDropdown && !l.showFlags && !l.separateDialCode && (l.nationalMode = !1), l.useFullscreenPopup && !l.dropdownContainer && (l.dropdownContainer = document.body), l.i18n = { ...t, ...l.i18n };
|
|
2089
|
+
}, v = (l) => l.replace(/\D/g, ""), q = (l = "") => l.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), pt = (l, t) => {
|
|
2090
|
+
const e = q(t), i = [], s = [], o = [], n = [], r = [], a = [];
|
|
2091
|
+
for (const c of l)
|
|
2092
|
+
c.iso2 === e ? i.push(c) : c.normalisedName.startsWith(e) ? s.push(c) : c.normalisedName.includes(e) ? o.push(c) : e === c.dialCode || e === c.dialCodePlus ? n.push(c) : c.dialCodePlus.includes(e) ? r.push(c) : c.initials.includes(e) && a.push(c);
|
|
2093
|
+
const d = (c, p) => c.priority - p.priority;
|
|
2094
2094
|
return [
|
|
2095
2095
|
...i.sort(d),
|
|
2096
2096
|
...s.sort(d),
|
|
2097
2097
|
...o.sort(d),
|
|
2098
2098
|
...n.sort(d),
|
|
2099
|
-
...
|
|
2099
|
+
...r.sort(d),
|
|
2100
2100
|
...a.sort(d)
|
|
2101
2101
|
];
|
|
2102
|
-
}, Ct = (
|
|
2102
|
+
}, Ct = (l, t) => {
|
|
2103
2103
|
const e = t.toLowerCase();
|
|
2104
|
-
for (const i of
|
|
2104
|
+
for (const i of l)
|
|
2105
2105
|
if (i.name.toLowerCase().startsWith(e))
|
|
2106
2106
|
return i;
|
|
2107
2107
|
return null;
|
|
2108
|
-
}, U = (
|
|
2109
|
-
const i = document.createElement(
|
|
2108
|
+
}, U = (l) => Object.keys(l).filter((t) => !!l[t]).join(" "), f = (l, t, e) => {
|
|
2109
|
+
const i = document.createElement(l);
|
|
2110
2110
|
return t && Object.entries(t).forEach(
|
|
2111
2111
|
([s, o]) => i.setAttribute(s, o)
|
|
2112
2112
|
), e && e.appendChild(i), i;
|
|
2113
2113
|
}, mt = () => `
|
|
2114
|
-
<svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" ${
|
|
2114
|
+
<svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" ${m.HIDDEN}="true">
|
|
2115
2115
|
<circle cx="11" cy="11" r="7" />
|
|
2116
2116
|
<line x1="21" y1="21" x2="16.65" y2="16.65" />
|
|
2117
|
-
</svg>`, ft = (
|
|
2118
|
-
const t = `iti-${
|
|
2117
|
+
</svg>`, ft = (l) => {
|
|
2118
|
+
const t = `iti-${l}-clear-mask`;
|
|
2119
2119
|
return `
|
|
2120
|
-
<svg class="iti__search-clear-svg" width="12" height="12" viewBox="0 0 16 16" ${
|
|
2120
|
+
<svg class="iti__search-clear-svg" width="12" height="12" viewBox="0 0 16 16" ${m.HIDDEN}="true" focusable="false">
|
|
2121
2121
|
<mask id="${t}" maskUnits="userSpaceOnUse">
|
|
2122
2122
|
<rect width="16" height="16" fill="white" />
|
|
2123
2123
|
<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" />
|
|
@@ -2127,7 +2127,7 @@ const lt = {
|
|
|
2127
2127
|
};
|
|
2128
2128
|
class yt {
|
|
2129
2129
|
constructor(t, e, i) {
|
|
2130
|
-
this.highlightedItem = null, t.dataset.intlTelInputId = i.toString(), this.telInput = t, this.options = e, this.id = i, this.hadInitialPlaceholder = !!t.getAttribute("placeholder"), this.isRTL = !!this.telInput.closest("[dir=rtl]"), this.options.separateDialCode && (this.originalPaddingLeft = this.telInput.style.paddingLeft);
|
|
2130
|
+
this.highlightedItem = null, this.selectedItem = null, t.dataset.intlTelInputId = i.toString(), this.telInput = t, this.options = e, this.id = i, this.hadInitialPlaceholder = !!t.getAttribute("placeholder"), this.isRTL = !!this.telInput.closest("[dir=rtl]"), this.options.separateDialCode && (this.originalPaddingLeft = this.telInput.style.paddingLeft);
|
|
2131
2131
|
}
|
|
2132
2132
|
//* Generate all of the markup for the plugin: the selected country overlay, and the dropdown.
|
|
2133
2133
|
generateMarkup(t) {
|
|
@@ -2146,47 +2146,47 @@ class yt {
|
|
|
2146
2146
|
"iti--show-flags": e,
|
|
2147
2147
|
"iti--inline-dropdown": !s,
|
|
2148
2148
|
[i]: !!i
|
|
2149
|
-
}), n =
|
|
2149
|
+
}), n = f("div", { class: o });
|
|
2150
2150
|
return this.isRTL && n.setAttribute("dir", "ltr"), this.telInput.before(n), n;
|
|
2151
2151
|
}
|
|
2152
2152
|
_maybeBuildCountryContainer(t) {
|
|
2153
2153
|
const { allowDropdown: e, separateDialCode: i, showFlags: s } = this.options;
|
|
2154
2154
|
if (e || s || i) {
|
|
2155
|
-
this.countryContainer =
|
|
2155
|
+
this.countryContainer = f(
|
|
2156
2156
|
"div",
|
|
2157
2157
|
// visibly hidden until we measure it's width to set the input padding correctly
|
|
2158
2158
|
{ class: `iti__country-container ${h.V_HIDE}` },
|
|
2159
2159
|
t
|
|
2160
|
-
), e ? (this.selectedCountry =
|
|
2160
|
+
), e ? (this.selectedCountry = f(
|
|
2161
2161
|
"button",
|
|
2162
2162
|
{
|
|
2163
2163
|
type: "button",
|
|
2164
2164
|
class: "iti__selected-country",
|
|
2165
|
-
[
|
|
2166
|
-
[
|
|
2167
|
-
[
|
|
2168
|
-
[
|
|
2165
|
+
[m.EXPANDED]: "false",
|
|
2166
|
+
[m.LABEL]: this.options.i18n.noCountrySelected,
|
|
2167
|
+
[m.HASPOPUP]: "dialog",
|
|
2168
|
+
[m.CONTROLS]: `iti-${this.id}__dropdown-content`
|
|
2169
2169
|
},
|
|
2170
2170
|
this.countryContainer
|
|
2171
|
-
), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry =
|
|
2171
|
+
), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry = f(
|
|
2172
2172
|
"div",
|
|
2173
2173
|
{ class: "iti__selected-country" },
|
|
2174
2174
|
this.countryContainer
|
|
2175
2175
|
);
|
|
2176
|
-
const o =
|
|
2176
|
+
const o = f(
|
|
2177
2177
|
"div",
|
|
2178
2178
|
{ class: "iti__selected-country-primary" },
|
|
2179
2179
|
this.selectedCountry
|
|
2180
2180
|
);
|
|
2181
|
-
this.selectedCountryInner =
|
|
2181
|
+
this.selectedCountryInner = f(
|
|
2182
2182
|
"div",
|
|
2183
2183
|
{ class: h.FLAG },
|
|
2184
2184
|
o
|
|
2185
|
-
), e && (this.dropdownArrow =
|
|
2185
|
+
), e && (this.dropdownArrow = f(
|
|
2186
2186
|
"div",
|
|
2187
|
-
{ class: "iti__arrow", [
|
|
2187
|
+
{ class: "iti__arrow", [m.HIDDEN]: "true" },
|
|
2188
2188
|
o
|
|
2189
|
-
)), i && (this.selectedDialCode =
|
|
2189
|
+
)), i && (this.selectedDialCode = f(
|
|
2190
2190
|
"div",
|
|
2191
2191
|
{ class: "iti__selected-dial-code" },
|
|
2192
2192
|
this.selectedCountry
|
|
@@ -2201,19 +2201,19 @@ class yt {
|
|
|
2201
2201
|
i18n: s,
|
|
2202
2202
|
dropdownContainer: o,
|
|
2203
2203
|
containerClass: n
|
|
2204
|
-
} = this.options,
|
|
2205
|
-
if (this.dropdownContent =
|
|
2204
|
+
} = this.options, r = t ? "" : "iti--flexible-dropdown-width";
|
|
2205
|
+
if (this.dropdownContent = f("div", {
|
|
2206
2206
|
id: `iti-${this.id}__dropdown-content`,
|
|
2207
|
-
class: `iti__dropdown-content ${h.HIDE} ${
|
|
2207
|
+
class: `iti__dropdown-content ${h.HIDE} ${r}`,
|
|
2208
2208
|
role: "dialog",
|
|
2209
|
-
[
|
|
2210
|
-
}), this.isRTL && this.dropdownContent.setAttribute("dir", "rtl"), i && this._buildSearchUI(), this.countryList =
|
|
2209
|
+
[m.MODAL]: "true"
|
|
2210
|
+
}), this.isRTL && this.dropdownContent.setAttribute("dir", "rtl"), i && this._buildSearchUI(), this.countryList = f(
|
|
2211
2211
|
"ul",
|
|
2212
2212
|
{
|
|
2213
2213
|
class: "iti__country-list",
|
|
2214
2214
|
id: `iti-${this.id}__country-listbox`,
|
|
2215
2215
|
role: "listbox",
|
|
2216
|
-
[
|
|
2216
|
+
[m.LABEL]: s.countryListAriaLabel
|
|
2217
2217
|
},
|
|
2218
2218
|
this.dropdownContent
|
|
2219
2219
|
), this._appendListItems(), i && this.updateSearchResultsA11yText(), o) {
|
|
@@ -2224,24 +2224,24 @@ class yt {
|
|
|
2224
2224
|
"iti--inline-dropdown": !e,
|
|
2225
2225
|
[n]: !!n
|
|
2226
2226
|
});
|
|
2227
|
-
this.dropdown =
|
|
2227
|
+
this.dropdown = f("div", { class: a }), this.dropdown.appendChild(this.dropdownContent);
|
|
2228
2228
|
} else
|
|
2229
2229
|
this.countryContainer.appendChild(this.dropdownContent);
|
|
2230
2230
|
}
|
|
2231
2231
|
_buildSearchUI() {
|
|
2232
|
-
const { i18n: t } = this.options, e =
|
|
2232
|
+
const { i18n: t } = this.options, e = f(
|
|
2233
2233
|
"div",
|
|
2234
2234
|
{ class: "iti__search-input-wrapper" },
|
|
2235
2235
|
this.dropdownContent
|
|
2236
2236
|
);
|
|
2237
|
-
this.searchIcon =
|
|
2237
|
+
this.searchIcon = f(
|
|
2238
2238
|
"span",
|
|
2239
2239
|
{
|
|
2240
2240
|
class: "iti__search-icon",
|
|
2241
|
-
[
|
|
2241
|
+
[m.HIDDEN]: "true"
|
|
2242
2242
|
},
|
|
2243
2243
|
e
|
|
2244
|
-
), this.searchIcon.innerHTML = mt(), this.searchInput =
|
|
2244
|
+
), this.searchIcon.innerHTML = mt(), this.searchInput = f(
|
|
2245
2245
|
"input",
|
|
2246
2246
|
{
|
|
2247
2247
|
id: `iti-${this.id}__search-input`,
|
|
@@ -2251,31 +2251,31 @@ class yt {
|
|
|
2251
2251
|
placeholder: t.searchPlaceholder,
|
|
2252
2252
|
// 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
|
|
2253
2253
|
role: "combobox",
|
|
2254
|
-
[
|
|
2255
|
-
[
|
|
2256
|
-
[
|
|
2257
|
-
[
|
|
2254
|
+
[m.EXPANDED]: "true",
|
|
2255
|
+
[m.LABEL]: t.searchPlaceholder,
|
|
2256
|
+
[m.CONTROLS]: `iti-${this.id}__country-listbox`,
|
|
2257
|
+
[m.AUTOCOMPLETE]: "list",
|
|
2258
2258
|
autocomplete: "off"
|
|
2259
2259
|
},
|
|
2260
2260
|
e
|
|
2261
|
-
), this.searchClearButton =
|
|
2261
|
+
), this.searchClearButton = f(
|
|
2262
2262
|
"button",
|
|
2263
2263
|
{
|
|
2264
2264
|
type: "button",
|
|
2265
2265
|
class: `iti__search-clear ${h.HIDE}`,
|
|
2266
|
-
[
|
|
2266
|
+
[m.LABEL]: t.clearSearchAriaLabel,
|
|
2267
2267
|
tabindex: "-1"
|
|
2268
2268
|
},
|
|
2269
2269
|
e
|
|
2270
|
-
), this.searchClearButton.innerHTML = ft(this.id), this.searchResultsA11yText =
|
|
2270
|
+
), this.searchClearButton.innerHTML = ft(this.id), this.searchResultsA11yText = f(
|
|
2271
2271
|
"span",
|
|
2272
2272
|
{ class: "iti__a11y-text" },
|
|
2273
2273
|
this.dropdownContent
|
|
2274
|
-
), this.searchNoResults =
|
|
2274
|
+
), this.searchNoResults = f(
|
|
2275
2275
|
"div",
|
|
2276
2276
|
{
|
|
2277
2277
|
class: `iti__no-results ${h.HIDE}`,
|
|
2278
|
-
[
|
|
2278
|
+
[m.HIDDEN]: "true"
|
|
2279
2279
|
// all a11y messaging happens in this.searchResultsA11yText
|
|
2280
2280
|
},
|
|
2281
2281
|
this.dropdownContent
|
|
@@ -2290,19 +2290,19 @@ class yt {
|
|
|
2290
2290
|
if (e) {
|
|
2291
2291
|
const o = this.telInput.getAttribute("name") || "", n = e(o);
|
|
2292
2292
|
if (n.phone) {
|
|
2293
|
-
const
|
|
2293
|
+
const r = (i = this.telInput.form) == null ? void 0 : i.querySelector(
|
|
2294
2294
|
`input[name="${n.phone}"]`
|
|
2295
2295
|
);
|
|
2296
|
-
|
|
2296
|
+
r ? this.hiddenInput = r : (this.hiddenInput = f("input", {
|
|
2297
2297
|
type: "hidden",
|
|
2298
2298
|
name: n.phone
|
|
2299
2299
|
}), t.appendChild(this.hiddenInput));
|
|
2300
2300
|
}
|
|
2301
2301
|
if (n.country) {
|
|
2302
|
-
const
|
|
2302
|
+
const r = (s = this.telInput.form) == null ? void 0 : s.querySelector(
|
|
2303
2303
|
`input[name="${n.country}"]`
|
|
2304
2304
|
);
|
|
2305
|
-
|
|
2305
|
+
r ? this.hiddenInputCountry = r : (this.hiddenInputCountry = f("input", {
|
|
2306
2306
|
type: "hidden",
|
|
2307
2307
|
name: n.country
|
|
2308
2308
|
}), t.appendChild(this.hiddenInputCountry));
|
|
@@ -2314,20 +2314,19 @@ class yt {
|
|
|
2314
2314
|
const t = document.createDocumentFragment();
|
|
2315
2315
|
for (let e = 0; e < this.countries.length; e++) {
|
|
2316
2316
|
const i = this.countries[e], s = U({
|
|
2317
|
-
[h.COUNTRY_ITEM]: !0
|
|
2318
|
-
|
|
2319
|
-
}), o = m("li", {
|
|
2317
|
+
[h.COUNTRY_ITEM]: !0
|
|
2318
|
+
}), o = f("li", {
|
|
2320
2319
|
id: `iti-${this.id}__item-${i.iso2}`,
|
|
2321
2320
|
class: s,
|
|
2322
2321
|
tabindex: "-1",
|
|
2323
2322
|
role: "option",
|
|
2324
|
-
[
|
|
2323
|
+
[m.SELECTED]: "false"
|
|
2325
2324
|
});
|
|
2326
|
-
o.dataset.dialCode = i.dialCode, o.dataset.countryCode = i.iso2, i.nodeById[this.id] = o, this.options.showFlags &&
|
|
2327
|
-
const n =
|
|
2325
|
+
o.dataset.dialCode = i.dialCode, o.dataset.countryCode = i.iso2, i.nodeById[this.id] = o, this.options.showFlags && f("div", { class: `${h.FLAG} iti__${i.iso2}` }, o);
|
|
2326
|
+
const n = f("span", { class: "iti__country-name" }, o);
|
|
2328
2327
|
n.textContent = i.name;
|
|
2329
|
-
const
|
|
2330
|
-
this.isRTL &&
|
|
2328
|
+
const r = f("span", { class: "iti__dial-code" }, o);
|
|
2329
|
+
this.isRTL && r.setAttribute("dir", "ltr"), r.textContent = `+${i.dialCode}`, t.appendChild(o);
|
|
2331
2330
|
}
|
|
2332
2331
|
this.countryList.appendChild(t);
|
|
2333
2332
|
}
|
|
@@ -2376,23 +2375,31 @@ class yt {
|
|
|
2376
2375
|
}
|
|
2377
2376
|
//* Check if an element is visible within it's container, else scroll until it is.
|
|
2378
2377
|
scrollTo(t) {
|
|
2379
|
-
const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, o = e.getBoundingClientRect().top + i, n = o + s,
|
|
2378
|
+
const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, o = e.getBoundingClientRect().top + i, n = o + s, r = t.offsetHeight, a = t.getBoundingClientRect().top + i, d = a + r, c = a - o + e.scrollTop;
|
|
2380
2379
|
if (a < o)
|
|
2381
2380
|
e.scrollTop = c;
|
|
2382
2381
|
else if (d > n) {
|
|
2383
|
-
const
|
|
2384
|
-
e.scrollTop = c -
|
|
2382
|
+
const p = s - r;
|
|
2383
|
+
e.scrollTop = c - p;
|
|
2385
2384
|
}
|
|
2386
2385
|
}
|
|
2387
|
-
//* Remove highlighting from
|
|
2386
|
+
//* Remove highlighting from the previous list item and highlight the new one.
|
|
2388
2387
|
highlightListItem(t, e) {
|
|
2389
2388
|
const i = this.highlightedItem;
|
|
2390
|
-
if (i &&
|
|
2389
|
+
if (i && i.classList.remove(h.HIGHLIGHT), this.highlightedItem = t, this.highlightedItem && (this.highlightedItem.classList.add(h.HIGHLIGHT), this.options.countrySearch)) {
|
|
2391
2390
|
const s = this.highlightedItem.getAttribute("id") || "";
|
|
2392
|
-
this.searchInput.setAttribute(
|
|
2391
|
+
this.searchInput.setAttribute(m.ACTIVE_DESCENDANT, s);
|
|
2393
2392
|
}
|
|
2394
2393
|
e && this.highlightedItem.focus();
|
|
2395
2394
|
}
|
|
2395
|
+
updateSelectedItem(t) {
|
|
2396
|
+
if (this.selectedItem && this.selectedItem.dataset.countryCode !== t && (this.selectedItem.setAttribute(m.SELECTED, "false"), this.selectedItem = null), t && !this.selectedItem) {
|
|
2397
|
+
const e = this.countryList.querySelector(
|
|
2398
|
+
`[data-country-code="${t}"]`
|
|
2399
|
+
);
|
|
2400
|
+
e && (e.setAttribute(m.SELECTED, "true"), this.selectedItem = e);
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2396
2403
|
//* Country search: Filter the country list to the given array of countries.
|
|
2397
2404
|
filterCountries(t) {
|
|
2398
2405
|
this.countryList.innerHTML = "";
|
|
@@ -2406,14 +2413,14 @@ class yt {
|
|
|
2406
2413
|
destroy() {
|
|
2407
2414
|
this.telInput.iti = void 0, delete this.telInput.dataset.intlTelInputId, this.options.separateDialCode && (this.telInput.style.paddingLeft = this.originalPaddingLeft);
|
|
2408
2415
|
const t = this.telInput.parentNode;
|
|
2409
|
-
t.before(this.telInput), t.remove(), this.telInput = null, this.countryContainer = null, this.selectedCountry = null, this.selectedCountryInner = null, this.selectedDialCode = null, this.dropdownArrow = null, this.dropdownContent = null, this.searchInput = null, this.searchIcon = null, this.searchClearButton = null, this.searchNoResults = null, this.searchResultsA11yText = null, this.countryList = null, this.dropdown = null, this.hiddenInput = null, this.hiddenInputCountry = null, this.highlightedItem = null;
|
|
2416
|
+
t.before(this.telInput), t.remove(), this.telInput = null, this.countryContainer = null, this.selectedCountry = null, this.selectedCountryInner = null, this.selectedDialCode = null, this.dropdownArrow = null, this.dropdownContent = null, this.searchInput = null, this.searchIcon = null, this.searchClearButton = null, this.searchNoResults = null, this.searchResultsA11yText = null, this.countryList = null, this.dropdown = null, this.hiddenInput = null, this.hiddenInputCountry = null, this.highlightedItem = null, this.selectedItem = null;
|
|
2410
2417
|
for (const e of this.countries)
|
|
2411
2418
|
delete e.nodeById[this.id];
|
|
2412
2419
|
this.countries = null;
|
|
2413
2420
|
}
|
|
2414
2421
|
}
|
|
2415
|
-
const gt = (
|
|
2416
|
-
const { onlyCountries: t, excludeCountries: e } =
|
|
2422
|
+
const gt = (l) => {
|
|
2423
|
+
const { onlyCountries: t, excludeCountries: e } = l;
|
|
2417
2424
|
if (t.length) {
|
|
2418
2425
|
const i = t.map(
|
|
2419
2426
|
(s) => s.toLowerCase()
|
|
@@ -2430,85 +2437,77 @@ const gt = (r) => {
|
|
|
2430
2437
|
);
|
|
2431
2438
|
}
|
|
2432
2439
|
return A;
|
|
2433
|
-
}, _t = (
|
|
2434
|
-
for (const e of
|
|
2440
|
+
}, _t = (l, t) => {
|
|
2441
|
+
for (const e of l) {
|
|
2435
2442
|
const i = e.iso2.toLowerCase();
|
|
2436
2443
|
t.i18n[i] && (e.name = t.i18n[i]);
|
|
2437
2444
|
}
|
|
2438
|
-
}, bt = (
|
|
2439
|
-
const
|
|
2440
|
-
let
|
|
2441
|
-
const
|
|
2442
|
-
if (!n || !
|
|
2443
|
-
return;
|
|
2444
|
-
l.length > i && (i = l.length), s.hasOwnProperty(l) || (s[l] = []);
|
|
2445
|
-
const d = s[l];
|
|
2446
|
-
if (d.includes(n))
|
|
2445
|
+
}, bt = (l) => {
|
|
2446
|
+
const t = /* @__PURE__ */ new Set();
|
|
2447
|
+
let e = 0;
|
|
2448
|
+
const i = {}, s = (n, r) => {
|
|
2449
|
+
if (!n || !r)
|
|
2447
2450
|
return;
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2451
|
+
r.length > e && (e = r.length), i.hasOwnProperty(r) || (i[r] = []);
|
|
2452
|
+
const a = i[r];
|
|
2453
|
+
a.includes(n) || a.push(n);
|
|
2454
|
+
}, o = [...l].sort((n, r) => n.priority - r.priority);
|
|
2455
|
+
for (const n of o) {
|
|
2456
|
+
t.has(n.dialCode) || t.add(n.dialCode);
|
|
2457
|
+
for (let r = 1; r < n.dialCode.length; r++) {
|
|
2458
|
+
const a = n.dialCode.substring(0, r);
|
|
2459
|
+
s(n.iso2, a);
|
|
2456
2460
|
}
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
(t.onlyCountries.length || t.excludeCountries.length) && e.forEach((n) => {
|
|
2460
|
-
s[n] = s[n].filter(Boolean);
|
|
2461
|
-
});
|
|
2462
|
-
for (const n of r)
|
|
2463
|
-
if (n.areaCodes) {
|
|
2464
|
-
const l = s[n.dialCode][0];
|
|
2461
|
+
if (s(n.iso2, n.dialCode), n.areaCodes) {
|
|
2462
|
+
const r = i[n.dialCode][0];
|
|
2465
2463
|
for (const a of n.areaCodes) {
|
|
2466
2464
|
for (let d = 1; d < a.length; d++) {
|
|
2467
|
-
const c = a.substring(0, d),
|
|
2468
|
-
|
|
2465
|
+
const c = a.substring(0, d), p = n.dialCode + c;
|
|
2466
|
+
s(r, p), s(n.iso2, p);
|
|
2469
2467
|
}
|
|
2470
|
-
|
|
2468
|
+
s(n.iso2, n.dialCode + a);
|
|
2471
2469
|
}
|
|
2472
2470
|
}
|
|
2473
|
-
|
|
2474
|
-
|
|
2471
|
+
}
|
|
2472
|
+
return { dialCodes: t, dialCodeMaxLen: e, dialCodeToIso2Map: i };
|
|
2473
|
+
}, It = (l, t) => {
|
|
2475
2474
|
t.countryOrder && (t.countryOrder = t.countryOrder.map(
|
|
2476
2475
|
(e) => e.toLowerCase()
|
|
2477
|
-
)),
|
|
2476
|
+
)), l.sort((e, i) => {
|
|
2478
2477
|
const { countryOrder: s } = t;
|
|
2479
2478
|
if (s) {
|
|
2480
|
-
const o = s.indexOf(e.iso2), n = s.indexOf(i.iso2),
|
|
2481
|
-
if (
|
|
2482
|
-
return
|
|
2479
|
+
const o = s.indexOf(e.iso2), n = s.indexOf(i.iso2), r = o > -1, a = n > -1;
|
|
2480
|
+
if (r || a)
|
|
2481
|
+
return r && a ? o - n : r ? -1 : 1;
|
|
2483
2482
|
}
|
|
2484
2483
|
return e.name.localeCompare(i.name);
|
|
2485
2484
|
});
|
|
2486
|
-
}, Nt = (
|
|
2487
|
-
for (const t of
|
|
2485
|
+
}, Nt = (l) => {
|
|
2486
|
+
for (const t of l)
|
|
2488
2487
|
t.normalisedName = q(t.name), t.initials = t.normalisedName.split(/[^a-z]/).map((e) => e[0]).join(""), t.dialCodePlus = `+${t.dialCode}`;
|
|
2489
|
-
}, wt = (
|
|
2490
|
-
let s =
|
|
2488
|
+
}, wt = (l, t, e, i) => {
|
|
2489
|
+
let s = l;
|
|
2491
2490
|
if (e && t) {
|
|
2492
2491
|
t = `+${i.dialCode}`;
|
|
2493
2492
|
const o = s[t.length] === " " || s[t.length] === "-" ? t.length + 1 : t.length;
|
|
2494
2493
|
s = s.substring(o);
|
|
2495
2494
|
}
|
|
2496
2495
|
return s;
|
|
2497
|
-
}, Dt = (
|
|
2498
|
-
const o = e ? e.formatNumberAsYouType(
|
|
2496
|
+
}, Dt = (l, t, e, i, s) => {
|
|
2497
|
+
const o = e ? e.formatNumberAsYouType(l, i.iso2) : l, { dialCode: n } = i;
|
|
2499
2498
|
return s && t.charAt(0) !== "+" && o.includes(`+${n}`) ? (o.split(`+${n}`)[1] || "").trim() : o;
|
|
2500
|
-
},
|
|
2499
|
+
}, Lt = (l, t, e, i) => {
|
|
2501
2500
|
if (e === 0 && !i)
|
|
2502
2501
|
return 0;
|
|
2503
2502
|
let s = 0;
|
|
2504
2503
|
for (let o = 0; o < t.length; o++) {
|
|
2505
|
-
if (/[+0-9]/.test(t[o]) && s++, s ===
|
|
2504
|
+
if (/[+0-9]/.test(t[o]) && s++, s === l && !i)
|
|
2506
2505
|
return o + 1;
|
|
2507
|
-
if (i && s ===
|
|
2506
|
+
if (i && s === l + 1)
|
|
2508
2507
|
return o;
|
|
2509
2508
|
}
|
|
2510
2509
|
return t.length;
|
|
2511
|
-
},
|
|
2510
|
+
}, Et = [
|
|
2512
2511
|
"800",
|
|
2513
2512
|
"822",
|
|
2514
2513
|
"833",
|
|
@@ -2526,24 +2525,23 @@ const gt = (r) => {
|
|
|
2526
2525
|
"887",
|
|
2527
2526
|
"888",
|
|
2528
2527
|
"889"
|
|
2529
|
-
], z = (
|
|
2530
|
-
const t = v(
|
|
2528
|
+
], z = (l) => {
|
|
2529
|
+
const t = v(l);
|
|
2531
2530
|
if (t.startsWith(K.NANP) && t.length >= 4) {
|
|
2532
2531
|
const e = t.substring(1, 4);
|
|
2533
|
-
return
|
|
2532
|
+
return Et.includes(e);
|
|
2534
2533
|
}
|
|
2535
2534
|
return !1;
|
|
2536
2535
|
};
|
|
2537
|
-
for (const
|
|
2538
|
-
|
|
2536
|
+
for (const l of A)
|
|
2537
|
+
l.name = j[l.iso2];
|
|
2539
2538
|
let At = 0;
|
|
2540
|
-
const
|
|
2539
|
+
const St = new Set(A.map((l) => l.iso2)), B = (l) => St.has(l);
|
|
2541
2540
|
class V {
|
|
2542
2541
|
constructor(t, e = {}) {
|
|
2543
2542
|
this.id = At++, this.options = { ...Y, ...e }, ht(this.options, j), this.ui = new yt(t, this.options, this.id), this.isAndroid = V._getIsAndroid(), this.promise = this._createInitPromises(), this.countries = gt(this.options);
|
|
2544
2543
|
const { dialCodes: i, dialCodeMaxLen: s, dialCodeToIso2Map: o } = bt(
|
|
2545
|
-
this.countries
|
|
2546
|
-
this.options
|
|
2544
|
+
this.countries
|
|
2547
2545
|
);
|
|
2548
2546
|
this.dialCodes = i, this.dialCodeMaxLen = s, this.dialCodeToIso2Map = o, this.countryByIso2 = new Map(this.countries.map((n) => [n.iso2, n])), this._init();
|
|
2549
2547
|
}
|
|
@@ -2598,12 +2596,12 @@ class V {
|
|
|
2598
2596
|
//* 1. Extracting a dial code from the given number
|
|
2599
2597
|
//* 2. Using explicit initialCountry
|
|
2600
2598
|
_setInitialState(t = !1) {
|
|
2601
|
-
const e = this.ui.telInput.getAttribute("value"), i = this._normaliseNumerals(e), s = this._getTelInputValue(), n = i && i.startsWith("+") && (!s || !s.startsWith("+")) ? i : s,
|
|
2602
|
-
if (
|
|
2599
|
+
const e = this.ui.telInput.getAttribute("value"), i = this._normaliseNumerals(e), s = this._getTelInputValue(), n = i && i.startsWith("+") && (!s || !s.startsWith("+")) ? i : s, r = this._getDialCode(n), a = z(n), { initialCountry: d, geoIpLookup: c } = this.options, p = d === M.AUTO && c;
|
|
2600
|
+
if (r && !a)
|
|
2603
2601
|
this._updateCountryFromNumber(n);
|
|
2604
|
-
else if (!
|
|
2602
|
+
else if (!p || t) {
|
|
2605
2603
|
const b = d ? d.toLowerCase() : "";
|
|
2606
|
-
B(b) ? this._setCountry(b) :
|
|
2604
|
+
B(b) ? this._setCountry(b) : r && a ? this._setCountry(dt.ISO2) : this._setCountry("");
|
|
2607
2605
|
}
|
|
2608
2606
|
n && this._updateValFromNumber(n);
|
|
2609
2607
|
}
|
|
@@ -2678,10 +2676,10 @@ class V {
|
|
|
2678
2676
|
u.autoCountry ? this.handleAutoCountry() : u.startedLoadingAutoCountry || (u.startedLoadingAutoCountry = !0, typeof this.options.geoIpLookup == "function" && this.options.geoIpLookup(
|
|
2679
2677
|
(t = "") => {
|
|
2680
2678
|
const e = t.toLowerCase();
|
|
2681
|
-
B(e) ? (u.autoCountry = e, setTimeout(() =>
|
|
2679
|
+
B(e) ? (u.autoCountry = e, setTimeout(() => S("handleAutoCountry"))) : (this._setInitialState(!0), S("rejectAutoCountryPromise"));
|
|
2682
2680
|
},
|
|
2683
2681
|
() => {
|
|
2684
|
-
this._setInitialState(!0),
|
|
2682
|
+
this._setInitialState(!0), S("rejectAutoCountryPromise");
|
|
2685
2683
|
}
|
|
2686
2684
|
));
|
|
2687
2685
|
}
|
|
@@ -2701,8 +2699,8 @@ class V {
|
|
|
2701
2699
|
countrySearch: o
|
|
2702
2700
|
} = this.options;
|
|
2703
2701
|
let n = !1;
|
|
2704
|
-
|
|
2705
|
-
const
|
|
2702
|
+
E.ALPHA_UNICODE.test(this._getTelInputValue()) && (n = !0);
|
|
2703
|
+
const r = (a) => {
|
|
2706
2704
|
const d = this._getTelInputValue();
|
|
2707
2705
|
if (this.isAndroid && (a == null ? void 0 : a.data) === "+" && i && s && o) {
|
|
2708
2706
|
const y = this.ui.telInput.selectionStart || 0, I = d.substring(0, y - 1), N = d.substring(y);
|
|
@@ -2710,34 +2708,34 @@ class V {
|
|
|
2710
2708
|
return;
|
|
2711
2709
|
}
|
|
2712
2710
|
this._updateCountryFromNumber(d) && this._triggerCountryChange();
|
|
2713
|
-
const c = (a == null ? void 0 : a.data) &&
|
|
2714
|
-
c ||
|
|
2711
|
+
const c = (a == null ? void 0 : a.data) && E.NON_PLUS_NUMERIC.test(a.data), p = (a == null ? void 0 : a.inputType) === F.PASTE && d;
|
|
2712
|
+
c || p && !t ? n = !0 : E.NON_PLUS_NUMERIC.test(d) || (n = !1);
|
|
2715
2713
|
const b = (a == null ? void 0 : a.detail) && a.detail.isSetNumber, C = this.userNumeralSet === "ascii";
|
|
2716
2714
|
if (e && !n && !b && C) {
|
|
2717
2715
|
const y = this.ui.telInput.selectionStart || 0, N = d.substring(
|
|
2718
2716
|
0,
|
|
2719
2717
|
y
|
|
2720
2718
|
).replace(
|
|
2721
|
-
|
|
2719
|
+
E.NON_PLUS_NUMERIC_GLOBAL,
|
|
2722
2720
|
""
|
|
2723
|
-
).length, D = (a == null ? void 0 : a.inputType) === F.DELETE_FWD, g = this._getFullNumber(),
|
|
2721
|
+
).length, D = (a == null ? void 0 : a.inputType) === F.DELETE_FWD, g = this._getFullNumber(), L = Dt(
|
|
2724
2722
|
g,
|
|
2725
2723
|
d,
|
|
2726
2724
|
u.utils,
|
|
2727
2725
|
this.selectedCountryData,
|
|
2728
2726
|
this.options.separateDialCode
|
|
2729
|
-
), w =
|
|
2727
|
+
), w = Lt(
|
|
2730
2728
|
N,
|
|
2731
|
-
|
|
2729
|
+
L,
|
|
2732
2730
|
y,
|
|
2733
2731
|
D
|
|
2734
2732
|
);
|
|
2735
|
-
this._setTelInputValue(
|
|
2733
|
+
this._setTelInputValue(L), this.ui.telInput.setSelectionRange(w, w);
|
|
2736
2734
|
}
|
|
2737
2735
|
};
|
|
2738
2736
|
this.ui.telInput.addEventListener(
|
|
2739
2737
|
"input",
|
|
2740
|
-
|
|
2738
|
+
r,
|
|
2741
2739
|
{
|
|
2742
2740
|
signal: this.abortController.signal
|
|
2743
2741
|
}
|
|
@@ -2753,10 +2751,10 @@ class V {
|
|
|
2753
2751
|
return;
|
|
2754
2752
|
}
|
|
2755
2753
|
if (t) {
|
|
2756
|
-
const
|
|
2757
|
-
|
|
2754
|
+
const r = this._getTelInputValue(), d = !r.startsWith("+") && this.ui.telInput.selectionStart === 0 && n.key === "+", c = this._normaliseNumerals(n.key), p = /^[0-9]$/.test(c), b = e ? p : d || p, C = this.ui.telInput, y = C.selectionStart, I = C.selectionEnd, N = r.slice(0, y), D = r.slice(I), g = N + n.key + D, L = this._getFullNumber(g), w = u.utils.getCoreNumber(
|
|
2755
|
+
L,
|
|
2758
2756
|
this.selectedCountryData.iso2
|
|
2759
|
-
), P = this.maxCoreNumberLength && w.length > this.maxCoreNumberLength, X = this._getNewCountryFromNumber(
|
|
2757
|
+
), P = this.maxCoreNumberLength && w.length > this.maxCoreNumberLength, X = this._getNewCountryFromNumber(L) !== null;
|
|
2760
2758
|
(!b || P && !X && !d) && n.preventDefault();
|
|
2761
2759
|
}
|
|
2762
2760
|
}
|
|
@@ -2770,8 +2768,8 @@ class V {
|
|
|
2770
2768
|
if (this.options.strictMode) {
|
|
2771
2769
|
const t = (e) => {
|
|
2772
2770
|
e.preventDefault();
|
|
2773
|
-
const i = this.ui.telInput, s = i.selectionStart, o = i.selectionEnd, n = this._getTelInputValue(),
|
|
2774
|
-
let g =
|
|
2771
|
+
const i = this.ui.telInput, s = i.selectionStart, o = i.selectionEnd, n = this._getTelInputValue(), r = n.slice(0, s), a = n.slice(o), d = this.selectedCountryData.iso2, c = e.clipboardData.getData("text"), p = this._normaliseNumerals(c), b = s === 0 && o > 0, C = !n.startsWith("+") || b, y = p.replace(E.NON_PLUS_NUMERIC_GLOBAL, ""), I = y.startsWith("+"), N = y.replace(/\+/g, ""), D = I && C ? `+${N}` : N;
|
|
2772
|
+
let g = r + D + a;
|
|
2775
2773
|
if (g.length > 5) {
|
|
2776
2774
|
let w = u.utils.getCoreNumber(g, d);
|
|
2777
2775
|
for (; w.length === 0 && g.length > 0; )
|
|
@@ -2786,8 +2784,8 @@ class V {
|
|
|
2786
2784
|
return;
|
|
2787
2785
|
}
|
|
2788
2786
|
this._setTelInputValue(g);
|
|
2789
|
-
const
|
|
2790
|
-
i.setSelectionRange(
|
|
2787
|
+
const L = s + D.length;
|
|
2788
|
+
i.setSelectionRange(L, L), i.dispatchEvent(new InputEvent("input", { bubbles: !0 }));
|
|
2791
2789
|
};
|
|
2792
2790
|
this.ui.telInput.addEventListener("paste", t, {
|
|
2793
2791
|
signal: this.abortController.signal
|
|
@@ -2811,11 +2809,11 @@ class V {
|
|
|
2811
2809
|
//* Open the dropdown.
|
|
2812
2810
|
_openDropdown() {
|
|
2813
2811
|
const { fixDropdownWidth: t, countrySearch: e } = this.options;
|
|
2814
|
-
if (this.dropdownAbortController = new AbortController(), t && (this.ui.dropdownContent.style.width = `${this.ui.telInput.offsetWidth}px`), this.ui.dropdownContent.classList.remove(h.HIDE), this.ui.selectedCountry.setAttribute(
|
|
2812
|
+
if (this.dropdownAbortController = new AbortController(), t && (this.ui.dropdownContent.style.width = `${this.ui.telInput.offsetWidth}px`), this.ui.dropdownContent.classList.remove(h.HIDE), this.ui.selectedCountry.setAttribute(m.EXPANDED, "true"), this._setDropdownPosition(), e) {
|
|
2815
2813
|
const i = this.ui.countryList.firstElementChild;
|
|
2816
2814
|
i && (this.ui.highlightListItem(i, !1), this.ui.countryList.scrollTop = 0), this.ui.searchInput.focus();
|
|
2817
2815
|
}
|
|
2818
|
-
this._bindDropdownListeners(), this.ui.dropdownArrow.classList.add(h.ARROW_UP), this._trigger(
|
|
2816
|
+
this._bindDropdownListeners(), this.ui.dropdownArrow.classList.add(h.ARROW_UP), this._trigger(T.OPEN_COUNTRY_DROPDOWN);
|
|
2819
2817
|
}
|
|
2820
2818
|
//* Set the dropdown position
|
|
2821
2819
|
_setDropdownPosition() {
|
|
@@ -2894,7 +2892,7 @@ class V {
|
|
|
2894
2892
|
_.ARROW_DOWN,
|
|
2895
2893
|
_.ENTER,
|
|
2896
2894
|
_.ESC
|
|
2897
|
-
].includes(o.key) && (o.preventDefault(), o.stopPropagation(), o.key === _.ARROW_UP || o.key === _.ARROW_DOWN ? this._handleUpDownKey(o.key) : o.key === _.ENTER ? this._handleEnterKey() : o.key === _.ESC && (this._closeDropdown(), this.ui.selectedCountry.focus())), !this.options.countrySearch &&
|
|
2895
|
+
].includes(o.key) && (o.preventDefault(), o.stopPropagation(), o.key === _.ARROW_UP || o.key === _.ARROW_DOWN ? this._handleUpDownKey(o.key) : o.key === _.ENTER ? this._handleEnterKey() : o.key === _.ESC && (this._closeDropdown(), this.ui.selectedCountry.focus())), !this.options.countrySearch && E.HIDDEN_SEARCH_CHAR.test(o.key) && (o.stopPropagation(), i && clearTimeout(i), e += o.key.toLowerCase(), this._searchForCountry(e), i = setTimeout(() => {
|
|
2898
2896
|
e = "";
|
|
2899
2897
|
}, ut.HIDDEN_SEARCH_RESET_MS));
|
|
2900
2898
|
};
|
|
@@ -2981,53 +2979,53 @@ class V {
|
|
|
2981
2979
|
let i = e ? t.substring(e) : t;
|
|
2982
2980
|
const s = this.selectedCountryData.iso2, o = this.selectedCountryData.dialCode;
|
|
2983
2981
|
i = this._ensureHasDialCode(i);
|
|
2984
|
-
const n = this._getDialCode(i, !0),
|
|
2982
|
+
const n = this._getDialCode(i, !0), r = v(i);
|
|
2985
2983
|
if (n) {
|
|
2986
2984
|
const a = v(n), d = this.dialCodeToIso2Map[a];
|
|
2987
2985
|
if (d.length === 1)
|
|
2988
2986
|
return d[0] === s ? null : d[0];
|
|
2989
2987
|
if (!s && this.defaultCountry && d.includes(this.defaultCountry))
|
|
2990
2988
|
return this.defaultCountry;
|
|
2991
|
-
if (o === K.NANP && z(
|
|
2989
|
+
if (o === K.NANP && z(r))
|
|
2992
2990
|
return null;
|
|
2993
|
-
const { areaCodes:
|
|
2994
|
-
if (
|
|
2995
|
-
const D =
|
|
2991
|
+
const { areaCodes: p, priority: b } = this.selectedCountryData;
|
|
2992
|
+
if (p) {
|
|
2993
|
+
const D = p.map(
|
|
2996
2994
|
(g) => `${o}${g}`
|
|
2997
2995
|
);
|
|
2998
2996
|
for (const g of D)
|
|
2999
|
-
if (
|
|
2997
|
+
if (r.startsWith(g))
|
|
3000
2998
|
return null;
|
|
3001
2999
|
}
|
|
3002
|
-
const y =
|
|
3000
|
+
const y = p && !(b === 0) && r.length > a.length, I = s && d.includes(s) && !y, N = s === d[0];
|
|
3003
3001
|
if (!I && !N)
|
|
3004
3002
|
return d[0];
|
|
3005
|
-
} else if (i.startsWith("+") &&
|
|
3003
|
+
} else if (i.startsWith("+") && r.length) {
|
|
3006
3004
|
const a = this.selectedCountryData.dialCode || "";
|
|
3007
|
-
return a && a.startsWith(
|
|
3005
|
+
return a && a.startsWith(r) ? null : "";
|
|
3008
3006
|
} else if ((!i || i === "+") && !s)
|
|
3009
3007
|
return this.defaultCountry;
|
|
3010
3008
|
return null;
|
|
3011
3009
|
}
|
|
3012
|
-
//* Update the selected country, dial code (if separateDialCode), placeholder, title, and
|
|
3010
|
+
//* Update the selected country, dial code (if separateDialCode), placeholder, title, and selected list item.
|
|
3013
3011
|
//* Note: called from _setInitialState, _updateCountryFromNumber, _selectListItem, setCountry.
|
|
3014
3012
|
_setCountry(t) {
|
|
3015
|
-
const { separateDialCode: e, showFlags: i, i18n: s } = this.options,
|
|
3016
|
-
if (this.selectedCountryData = t ? this.countryByIso2.get(t) : {}, this.selectedCountryData.iso2 && (this.defaultCountry = this.selectedCountryData.iso2), this.ui.selectedCountry) {
|
|
3017
|
-
const
|
|
3018
|
-
let
|
|
3013
|
+
const { separateDialCode: e, showFlags: i, i18n: s, allowDropdown: o } = this.options, n = this.selectedCountryData.iso2 || "";
|
|
3014
|
+
if (o && this.ui.updateSelectedItem(t), this.selectedCountryData = t ? this.countryByIso2.get(t) : {}, this.selectedCountryData.iso2 && (this.defaultCountry = this.selectedCountryData.iso2), this.ui.selectedCountry) {
|
|
3015
|
+
const r = t && i ? `${h.FLAG} iti__${t}` : `${h.FLAG} ${h.GLOBE}`;
|
|
3016
|
+
let a, d;
|
|
3019
3017
|
if (t) {
|
|
3020
|
-
const { name:
|
|
3021
|
-
|
|
3018
|
+
const { name: c, dialCode: p } = this.selectedCountryData;
|
|
3019
|
+
d = c, a = s.selectedCountryAriaLabel.replace("${countryName}", c).replace("${dialCode}", `+${p}`);
|
|
3022
3020
|
} else
|
|
3023
|
-
|
|
3024
|
-
this.ui.selectedCountryInner.className =
|
|
3021
|
+
d = s.noCountrySelected, a = s.noCountrySelected;
|
|
3022
|
+
this.ui.selectedCountryInner.className = r, this.ui.selectedCountry.setAttribute("title", d), this.ui.selectedCountry.setAttribute(m.LABEL, a);
|
|
3025
3023
|
}
|
|
3026
3024
|
if (e) {
|
|
3027
|
-
const
|
|
3028
|
-
this.ui.selectedDialCode.textContent =
|
|
3025
|
+
const r = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
|
|
3026
|
+
this.ui.selectedDialCode.textContent = r, this.ui.updateInputPadding();
|
|
3029
3027
|
}
|
|
3030
|
-
return this._updatePlaceholder(), this._updateMaxLength(),
|
|
3028
|
+
return this._updatePlaceholder(), this._updateMaxLength(), n !== t;
|
|
3031
3029
|
}
|
|
3032
3030
|
//* Update the maximum valid number length for the currently selected country.
|
|
3033
3031
|
_updateMaxLength() {
|
|
@@ -3040,14 +3038,14 @@ class V {
|
|
|
3040
3038
|
!1,
|
|
3041
3039
|
o,
|
|
3042
3040
|
!0
|
|
3043
|
-
),
|
|
3041
|
+
), r = n;
|
|
3044
3042
|
for (; u.utils.isPossibleNumber(
|
|
3045
3043
|
n,
|
|
3046
3044
|
s,
|
|
3047
3045
|
i
|
|
3048
3046
|
); )
|
|
3049
|
-
|
|
3050
|
-
const a = u.utils.getCoreNumber(
|
|
3047
|
+
r = n, n += "0";
|
|
3048
|
+
const a = u.utils.getCoreNumber(r, s);
|
|
3051
3049
|
this.maxCoreNumberLength = a.length, s === "by" && (this.maxCoreNumberLength = a.length + 1);
|
|
3052
3050
|
} else
|
|
3053
3051
|
this.maxCoreNumberLength = null;
|
|
@@ -3062,12 +3060,12 @@ class V {
|
|
|
3062
3060
|
} = this.options, o = t === H.AGGRESSIVE || !this.ui.hadInitialPlaceholder && t === H.POLITE;
|
|
3063
3061
|
if (u.utils && o) {
|
|
3064
3062
|
const n = u.utils.numberType[e];
|
|
3065
|
-
let
|
|
3063
|
+
let r = this.selectedCountryData.iso2 ? u.utils.getExampleNumber(
|
|
3066
3064
|
this.selectedCountryData.iso2,
|
|
3067
3065
|
i,
|
|
3068
3066
|
n
|
|
3069
3067
|
) : "";
|
|
3070
|
-
|
|
3068
|
+
r = this._beforeSetNumber(r), typeof s == "function" && (r = s(r, this.selectedCountryData)), this.ui.telInput.setAttribute("placeholder", r);
|
|
3071
3069
|
}
|
|
3072
3070
|
}
|
|
3073
3071
|
//* Called when the user selects a list item from the dropdown.
|
|
@@ -3083,7 +3081,7 @@ class V {
|
|
|
3083
3081
|
}
|
|
3084
3082
|
//* Close the dropdown and unbind any listeners.
|
|
3085
3083
|
_closeDropdown() {
|
|
3086
|
-
this.ui.dropdownContent.classList.contains(h.HIDE) || (this.ui.dropdownContent.classList.add(h.HIDE), this.ui.selectedCountry.setAttribute(
|
|
3084
|
+
this.ui.dropdownContent.classList.contains(h.HIDE) || (this.ui.dropdownContent.classList.add(h.HIDE), this.ui.selectedCountry.setAttribute(m.EXPANDED, "false"), this.options.countrySearch && (this.ui.searchInput.removeAttribute(m.ACTIVE_DESCENDANT), this.ui.highlightedItem && (this.ui.highlightedItem.classList.remove(h.HIGHLIGHT), this.ui.highlightedItem = null)), this.ui.dropdownArrow.classList.remove(h.ARROW_UP), this.dropdownAbortController.abort(), this.dropdownAbortController = null, this.options.dropdownContainer && this.ui.dropdown.remove(), this._trigger(T.CLOSE_COUNTRY_DROPDOWN));
|
|
3087
3085
|
}
|
|
3088
3086
|
//* Replace any existing dial code with the new one
|
|
3089
3087
|
//* Note: called from _selectListItem and setCountry
|
|
@@ -3102,9 +3100,9 @@ class V {
|
|
|
3102
3100
|
if (t.startsWith("+")) {
|
|
3103
3101
|
let s = "", o = !1;
|
|
3104
3102
|
for (let n = 0; n < t.length; n++) {
|
|
3105
|
-
const
|
|
3106
|
-
if (/[0-9]/.test(
|
|
3107
|
-
if (s +=
|
|
3103
|
+
const r = t.charAt(n);
|
|
3104
|
+
if (/[0-9]/.test(r)) {
|
|
3105
|
+
if (s += r, !!!this.dialCodeToIso2Map[s])
|
|
3108
3106
|
break;
|
|
3109
3107
|
if (this.dialCodes.has(s)) {
|
|
3110
3108
|
if (i = t.substring(0, n + 1), o = !0, !e)
|
|
@@ -3136,7 +3134,7 @@ class V {
|
|
|
3136
3134
|
}
|
|
3137
3135
|
//* Trigger the 'countrychange' event.
|
|
3138
3136
|
_triggerCountryChange() {
|
|
3139
|
-
this._trigger(
|
|
3137
|
+
this._trigger(T.COUNTRY_CHANGE);
|
|
3140
3138
|
}
|
|
3141
3139
|
//**************************
|
|
3142
3140
|
//* SECRET PUBLIC METHODS
|
|
@@ -3225,10 +3223,10 @@ class V {
|
|
|
3225
3223
|
return null;
|
|
3226
3224
|
if (!this.selectedCountryData.iso2)
|
|
3227
3225
|
return !1;
|
|
3228
|
-
const e = (n) => t ? this._utilsIsValidNumber(n) : this._utilsIsPossibleNumber(n), i = this._getFullNumber(), s = i.search(
|
|
3226
|
+
const e = (n) => t ? this._utilsIsValidNumber(n) : this._utilsIsPossibleNumber(n), i = this._getFullNumber(), s = i.search(E.ALPHA_UNICODE);
|
|
3229
3227
|
if (s > -1 && !this.options.allowPhonewords) {
|
|
3230
|
-
const n = i.substring(0, s),
|
|
3231
|
-
return
|
|
3228
|
+
const n = i.substring(0, s), r = e(n), a = e(i);
|
|
3229
|
+
return r && a;
|
|
3232
3230
|
}
|
|
3233
3231
|
return e(i);
|
|
3234
3232
|
}
|
|
@@ -3256,7 +3254,7 @@ class V {
|
|
|
3256
3254
|
//* Set the input value and update the country.
|
|
3257
3255
|
setNumber(t) {
|
|
3258
3256
|
const e = this._normaliseNumerals(t), i = this._updateCountryFromNumber(e);
|
|
3259
|
-
this._updateValFromNumber(e), i && this._triggerCountryChange(), this._trigger(
|
|
3257
|
+
this._updateValFromNumber(e), i && this._triggerCountryChange(), this._trigger(T.INPUT, { isSetNumber: !0 });
|
|
3260
3258
|
}
|
|
3261
3259
|
//* Set the placeholder number typ
|
|
3262
3260
|
setPlaceholderNumberType(t) {
|
|
@@ -3266,19 +3264,19 @@ class V {
|
|
|
3266
3264
|
this.ui.telInput.disabled = t, t ? this.ui.selectedCountry.setAttribute("disabled", "true") : this.ui.selectedCountry.removeAttribute("disabled");
|
|
3267
3265
|
}
|
|
3268
3266
|
}
|
|
3269
|
-
const
|
|
3267
|
+
const Tt = (l) => {
|
|
3270
3268
|
if (!u.utils && !u.startedLoadingUtilsScript) {
|
|
3271
3269
|
let t;
|
|
3272
|
-
if (typeof
|
|
3270
|
+
if (typeof l == "function")
|
|
3273
3271
|
try {
|
|
3274
|
-
t = Promise.resolve(
|
|
3272
|
+
t = Promise.resolve(l());
|
|
3275
3273
|
} catch (e) {
|
|
3276
3274
|
return Promise.reject(e);
|
|
3277
3275
|
}
|
|
3278
3276
|
else
|
|
3279
3277
|
return Promise.reject(
|
|
3280
3278
|
new TypeError(
|
|
3281
|
-
`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof
|
|
3279
|
+
`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof l}`
|
|
3282
3280
|
)
|
|
3283
3281
|
);
|
|
3284
3282
|
return u.startedLoadingUtilsScript = !0, t.then((e) => {
|
|
@@ -3287,21 +3285,21 @@ const St = (r) => {
|
|
|
3287
3285
|
throw new TypeError(
|
|
3288
3286
|
"The loader function passed to attachUtils did not resolve to a module object with utils as its default export."
|
|
3289
3287
|
);
|
|
3290
|
-
return u.utils = i,
|
|
3288
|
+
return u.utils = i, S("handleUtils"), !0;
|
|
3291
3289
|
}).catch((e) => {
|
|
3292
|
-
throw
|
|
3290
|
+
throw S("rejectUtilsScriptPromise", e), e;
|
|
3293
3291
|
});
|
|
3294
3292
|
}
|
|
3295
3293
|
return null;
|
|
3296
|
-
},
|
|
3294
|
+
}, S = (l, ...t) => {
|
|
3297
3295
|
Object.values(u.instances).forEach((e) => {
|
|
3298
|
-
const i = e[
|
|
3296
|
+
const i = e[l];
|
|
3299
3297
|
typeof i == "function" && i.apply(e, t);
|
|
3300
3298
|
});
|
|
3301
3299
|
}, u = Object.assign(
|
|
3302
|
-
(
|
|
3303
|
-
const e = new V(
|
|
3304
|
-
return u.instances[e.id] = e,
|
|
3300
|
+
(l, t) => {
|
|
3301
|
+
const e = new V(l, t);
|
|
3302
|
+
return u.instances[e.id] = e, l.iti = e, e;
|
|
3305
3303
|
},
|
|
3306
3304
|
{
|
|
3307
3305
|
defaults: Y,
|
|
@@ -3310,16 +3308,16 @@ const St = (r) => {
|
|
|
3310
3308
|
//* Get the country data object.
|
|
3311
3309
|
getCountryData: () => A,
|
|
3312
3310
|
//* A getter for the plugin instance.
|
|
3313
|
-
getInstance: (
|
|
3314
|
-
const t =
|
|
3311
|
+
getInstance: (l) => {
|
|
3312
|
+
const t = l.dataset.intlTelInputId;
|
|
3315
3313
|
return t ? u.instances[t] : null;
|
|
3316
3314
|
},
|
|
3317
3315
|
//* A map from instance ID to instance object.
|
|
3318
3316
|
instances: {},
|
|
3319
|
-
attachUtils:
|
|
3317
|
+
attachUtils: Tt,
|
|
3320
3318
|
startedLoadingUtilsScript: !1,
|
|
3321
3319
|
startedLoadingAutoCountry: !1,
|
|
3322
|
-
version: "25.13.
|
|
3320
|
+
version: "25.13.2"
|
|
3323
3321
|
}
|
|
3324
3322
|
), Ot = {
|
|
3325
3323
|
__name: "IntlTelInput",
|
|
@@ -3353,39 +3351,39 @@ const St = (r) => {
|
|
|
3353
3351
|
"changeValidity",
|
|
3354
3352
|
"changeErrorCode"
|
|
3355
3353
|
], ["update:modelValue"]),
|
|
3356
|
-
setup(
|
|
3357
|
-
const i = Q(
|
|
3354
|
+
setup(l, { expose: t, emit: e }) {
|
|
3355
|
+
const i = Q(l, "modelValue"), s = l, o = e, n = O(), r = O(), a = O(!1), d = () => r.value ? s.options.strictMode ? r.value.isValidNumberPrecise() : r.value.isValidNumber() : null, c = () => {
|
|
3358
3356
|
let C = d();
|
|
3359
3357
|
a.value !== C && (a.value = C, o("changeValidity", !!C), o(
|
|
3360
3358
|
"changeErrorCode",
|
|
3361
|
-
C ? null :
|
|
3359
|
+
C ? null : r.value.getValidationError()
|
|
3362
3360
|
));
|
|
3363
|
-
},
|
|
3361
|
+
}, p = () => {
|
|
3364
3362
|
var C;
|
|
3365
|
-
o("changeNumber", ((C =
|
|
3363
|
+
o("changeNumber", ((C = r.value) == null ? void 0 : C.getNumber()) ?? ""), c();
|
|
3366
3364
|
}, b = () => {
|
|
3367
3365
|
var C;
|
|
3368
|
-
o("changeCountry", ((C =
|
|
3366
|
+
o("changeCountry", ((C = r.value) == null ? void 0 : C.getSelectedCountryData().iso2) ?? ""), p(), c();
|
|
3369
3367
|
};
|
|
3370
3368
|
return J(() => {
|
|
3371
|
-
n.value && (
|
|
3369
|
+
n.value && (r.value = u(n.value, s.options), s.value && r.value.setNumber(s.value), s.disabled && r.value.setDisabled(s.disabled), a.value = d());
|
|
3372
3370
|
}), Z(
|
|
3373
3371
|
() => s.disabled,
|
|
3374
3372
|
(C) => {
|
|
3375
3373
|
var y;
|
|
3376
|
-
return (y =
|
|
3374
|
+
return (y = r.value) == null ? void 0 : y.setDisabled(C);
|
|
3377
3375
|
}
|
|
3378
3376
|
), tt(() => {
|
|
3379
3377
|
var C;
|
|
3380
|
-
return (C =
|
|
3381
|
-
}), t({ instance:
|
|
3378
|
+
return (C = r.value) == null ? void 0 : C.destroy();
|
|
3379
|
+
}), t({ instance: r, input: n }), (C, y) => et((st(), it("input", nt({
|
|
3382
3380
|
ref_key: "input",
|
|
3383
3381
|
ref: n,
|
|
3384
3382
|
"onUpdate:modelValue": y[0] || (y[0] = (I) => i.value = I),
|
|
3385
3383
|
type: "tel",
|
|
3386
3384
|
onCountrychange: b,
|
|
3387
|
-
onInput:
|
|
3388
|
-
},
|
|
3385
|
+
onInput: p
|
|
3386
|
+
}, l.inputProps), null, 16)), [
|
|
3389
3387
|
[
|
|
3390
3388
|
ot,
|
|
3391
3389
|
i.value,
|