intl-tel-input 25.12.5 → 25.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/angular/README.md +1 -1
- package/angular/build/IntlTelInput.js +106 -47
- package/angular/build/IntlTelInputWithUtils.js +216 -191
- package/angular/build/types/intl-tel-input.d.ts +6 -0
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput.d.ts +6 -0
- package/build/js/intlTelInput.js +108 -52
- package/build/js/intlTelInput.min.js +4 -4
- package/build/js/intlTelInputWithUtils.js +218 -196
- package/build/js/intlTelInputWithUtils.min.js +6 -6
- package/build/js/utils.js +40 -39
- package/package.json +1 -1
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +107 -51
- package/react/build/IntlTelInput.d.ts +6 -0
- package/react/build/IntlTelInput.js +107 -51
- package/react/build/IntlTelInputWithUtils.cjs +217 -195
- package/react/build/IntlTelInputWithUtils.js +217 -195
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +325 -285
- package/vue/build/IntlTelInputWithUtils.mjs +680 -674
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { mergeModels as
|
|
2
|
-
const
|
|
1
|
+
import { mergeModels as W, useModel as Q, ref as O, onMounted as J, watch as Z, onUnmounted as tt, withDirectives as et, createElementBlock as it, openBlock as st, mergeProps as nt, vModelText as ot } from "vue";
|
|
2
|
+
const rt = [
|
|
3
3
|
[
|
|
4
4
|
"af",
|
|
5
5
|
// Afghanistan
|
|
@@ -1676,18 +1676,18 @@ const st = [
|
|
|
1676
1676
|
null,
|
|
1677
1677
|
"0"
|
|
1678
1678
|
]
|
|
1679
|
-
],
|
|
1680
|
-
for (const
|
|
1681
|
-
|
|
1679
|
+
], A = [];
|
|
1680
|
+
for (const r of rt)
|
|
1681
|
+
A.push({
|
|
1682
1682
|
name: "",
|
|
1683
1683
|
// populated in the plugin
|
|
1684
|
-
iso2:
|
|
1685
|
-
dialCode:
|
|
1686
|
-
priority:
|
|
1687
|
-
areaCodes:
|
|
1684
|
+
iso2: r[0],
|
|
1685
|
+
dialCode: r[1],
|
|
1686
|
+
priority: r[2] || 0,
|
|
1687
|
+
areaCodes: r[3] || null,
|
|
1688
1688
|
nodeById: {},
|
|
1689
1689
|
// populated by the plugin
|
|
1690
|
-
nationalPrefix:
|
|
1690
|
+
nationalPrefix: r[4] || null,
|
|
1691
1691
|
normalisedName: "",
|
|
1692
1692
|
// populated in the plugin
|
|
1693
1693
|
initials: "",
|
|
@@ -1695,7 +1695,7 @@ for (const l of st)
|
|
|
1695
1695
|
dialCodePlus: ""
|
|
1696
1696
|
// populated in the plugin
|
|
1697
1697
|
});
|
|
1698
|
-
const
|
|
1698
|
+
const lt = {
|
|
1699
1699
|
ad: "Andorra",
|
|
1700
1700
|
ae: "United Arab Emirates",
|
|
1701
1701
|
af: "Afghanistan",
|
|
@@ -1938,7 +1938,7 @@ const nt = {
|
|
|
1938
1938
|
za: "South Africa",
|
|
1939
1939
|
zm: "Zambia",
|
|
1940
1940
|
zw: "Zimbabwe"
|
|
1941
|
-
},
|
|
1941
|
+
}, at = {
|
|
1942
1942
|
selectedCountryAriaLabel: "Change country, selected ${countryName} (${dialCode})",
|
|
1943
1943
|
noCountrySelected: "Select country",
|
|
1944
1944
|
countryListAriaLabel: "List of countries",
|
|
@@ -1950,7 +1950,7 @@ const nt = {
|
|
|
1950
1950
|
// additional countries (not supported by country-list library)
|
|
1951
1951
|
ac: "Ascension Island",
|
|
1952
1952
|
xk: "Kosovo"
|
|
1953
|
-
},
|
|
1953
|
+
}, j = { ...lt, ...at }, S = {
|
|
1954
1954
|
OPEN_COUNTRY_DROPDOWN: "open:countrydropdown",
|
|
1955
1955
|
CLOSE_COUNTRY_DROPDOWN: "close:countrydropdown",
|
|
1956
1956
|
COUNTRY_CHANGE: "countrychange",
|
|
@@ -1964,17 +1964,17 @@ const nt = {
|
|
|
1964
1964
|
FLAG: "iti__flag",
|
|
1965
1965
|
COUNTRY_ITEM: "iti__country",
|
|
1966
1966
|
HIGHLIGHT: "iti__highlight"
|
|
1967
|
-
},
|
|
1967
|
+
}, _ = {
|
|
1968
1968
|
ARROW_UP: "ArrowUp",
|
|
1969
1969
|
ARROW_DOWN: "ArrowDown",
|
|
1970
1970
|
SPACE: " ",
|
|
1971
1971
|
ENTER: "Enter",
|
|
1972
1972
|
ESC: "Escape",
|
|
1973
1973
|
TAB: "Tab"
|
|
1974
|
-
},
|
|
1974
|
+
}, F = {
|
|
1975
1975
|
PASTE: "insertFromPaste",
|
|
1976
1976
|
DELETE_FWD: "deleteContentForward"
|
|
1977
|
-
},
|
|
1977
|
+
}, L = {
|
|
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]/,
|
|
@@ -1983,39 +1983,39 @@ const nt = {
|
|
|
1983
1983
|
// chars that are NOT + or digit (global)
|
|
1984
1984
|
HIDDEN_SEARCH_CHAR: /^[a-zA-ZÀ-ÿа-яА-Я ]$/
|
|
1985
1985
|
// single acceptable hidden-search char
|
|
1986
|
-
},
|
|
1986
|
+
}, ut = {
|
|
1987
1987
|
HIDDEN_SEARCH_RESET_MS: 1e3
|
|
1988
|
-
},
|
|
1988
|
+
}, $ = {
|
|
1989
1989
|
UNKNOWN_NUMBER_TYPE: -99,
|
|
1990
1990
|
UNKNOWN_VALIDATION_ERROR: -99
|
|
1991
|
-
},
|
|
1991
|
+
}, R = {
|
|
1992
1992
|
SANE_SELECTED_WITH_DIAL_WIDTH: 78,
|
|
1993
1993
|
// px width fallback when separateDialCode enabled
|
|
1994
1994
|
SANE_SELECTED_NO_DIAL_WIDTH: 42,
|
|
1995
1995
|
// px width fallback when no separate dial code
|
|
1996
1996
|
INPUT_PADDING_EXTRA_LEFT: 6
|
|
1997
1997
|
// px gap between selected country container and input text
|
|
1998
|
-
},
|
|
1998
|
+
}, K = {
|
|
1999
1999
|
NANP: "1"
|
|
2000
2000
|
// North American Numbering Plan
|
|
2001
|
-
},
|
|
2001
|
+
}, k = {
|
|
2002
2002
|
DIAL_CODE: "44",
|
|
2003
2003
|
// +44 United Kingdom
|
|
2004
2004
|
MOBILE_PREFIX: "7",
|
|
2005
2005
|
// UK mobile numbers start with 7 after national trunk (0) or core section
|
|
2006
2006
|
MOBILE_CORE_LENGTH: 10
|
|
2007
2007
|
// core number length (excluding dial code / national prefix) for mobiles
|
|
2008
|
-
},
|
|
2008
|
+
}, dt = {
|
|
2009
2009
|
ISO2: "us"
|
|
2010
|
-
},
|
|
2010
|
+
}, H = {
|
|
2011
2011
|
AGGRESSIVE: "aggressive",
|
|
2012
2012
|
POLITE: "polite"
|
|
2013
|
-
},
|
|
2013
|
+
}, M = {
|
|
2014
2014
|
AUTO: "auto"
|
|
2015
|
-
},
|
|
2015
|
+
}, G = {
|
|
2016
2016
|
COUNTRY_CODE: "countryCode",
|
|
2017
2017
|
DIAL_CODE: "dialCode"
|
|
2018
|
-
},
|
|
2018
|
+
}, p = {
|
|
2019
2019
|
EXPANDED: "aria-expanded",
|
|
2020
2020
|
LABEL: "aria-label",
|
|
2021
2021
|
SELECTED: "aria-selected",
|
|
@@ -2025,21 +2025,21 @@ const nt = {
|
|
|
2025
2025
|
HIDDEN: "aria-hidden",
|
|
2026
2026
|
AUTOCOMPLETE: "aria-autocomplete",
|
|
2027
2027
|
MODAL: "aria-modal"
|
|
2028
|
-
},
|
|
2028
|
+
}, x = (r) => typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia(r).matches, ct = () => {
|
|
2029
2029
|
if (typeof navigator < "u" && typeof window < "u") {
|
|
2030
|
-
const
|
|
2030
|
+
const r = /Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
2031
2031
|
navigator.userAgent
|
|
2032
|
-
), t =
|
|
2033
|
-
return
|
|
2032
|
+
), t = x("(max-width: 500px)"), e = x("(max-height: 600px)"), i = x("(pointer: coarse)");
|
|
2033
|
+
return r || t || i && e;
|
|
2034
2034
|
}
|
|
2035
2035
|
return !1;
|
|
2036
|
-
},
|
|
2036
|
+
}, Y = {
|
|
2037
2037
|
// Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
|
|
2038
2038
|
allowPhonewords: !1,
|
|
2039
2039
|
//* Whether or not to allow the dropdown.
|
|
2040
2040
|
allowDropdown: !0,
|
|
2041
2041
|
//* Add a placeholder in the input with an example number for the selected country.
|
|
2042
|
-
autoPlaceholder:
|
|
2042
|
+
autoPlaceholder: H.POLITE,
|
|
2043
2043
|
//* Modify the parentClass.
|
|
2044
2044
|
containerClass: "",
|
|
2045
2045
|
//* The order of the countries in the dropdown. Defaults to alphabetical.
|
|
@@ -2081,43 +2081,43 @@ const nt = {
|
|
|
2081
2081
|
//* Only allow certain chars e.g. a plus followed by numeric digits, and cap at max valid length.
|
|
2082
2082
|
strictMode: !1,
|
|
2083
2083
|
//* Use full screen popup instead of dropdown for country list.
|
|
2084
|
-
useFullscreenPopup:
|
|
2084
|
+
useFullscreenPopup: ct(),
|
|
2085
2085
|
//* The number type to enforce during validation.
|
|
2086
2086
|
validationNumberTypes: ["MOBILE"]
|
|
2087
|
-
},
|
|
2088
|
-
|
|
2089
|
-
}, v = (
|
|
2090
|
-
const e =
|
|
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) ?
|
|
2087
|
+
}, ht = (r, t) => {
|
|
2088
|
+
r.useFullscreenPopup && (r.fixDropdownWidth = !1), r.onlyCountries.length === 1 && (r.initialCountry = r.onlyCountries[0]), r.separateDialCode && (r.nationalMode = !1), r.allowDropdown && !r.showFlags && !r.separateDialCode && (r.nationalMode = !1), r.useFullscreenPopup && !r.dropdownContainer && (r.dropdownContainer = document.body), r.i18n = { ...t, ...r.i18n };
|
|
2089
|
+
}, v = (r) => r.replace(/\D/g, ""), q = (r = "") => r.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), pt = (r, t) => {
|
|
2090
|
+
const e = q(t), i = [], s = [], o = [], n = [], l = [], a = [];
|
|
2091
|
+
for (const c of r)
|
|
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) ? l.push(c) : c.initials.includes(e) && a.push(c);
|
|
2093
2093
|
const d = (c, f) => c.priority - f.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
|
+
...l.sort(d),
|
|
2100
2100
|
...a.sort(d)
|
|
2101
2101
|
];
|
|
2102
|
-
},
|
|
2102
|
+
}, Ct = (r, t) => {
|
|
2103
2103
|
const e = t.toLowerCase();
|
|
2104
|
-
for (const i of
|
|
2104
|
+
for (const i of r)
|
|
2105
2105
|
if (i.name.toLowerCase().startsWith(e))
|
|
2106
2106
|
return i;
|
|
2107
2107
|
return null;
|
|
2108
|
-
},
|
|
2109
|
-
const i = document.createElement(
|
|
2108
|
+
}, U = (r) => Object.keys(r).filter((t) => !!r[t]).join(" "), m = (r, t, e) => {
|
|
2109
|
+
const i = document.createElement(r);
|
|
2110
2110
|
return t && Object.entries(t).forEach(
|
|
2111
2111
|
([s, o]) => i.setAttribute(s, o)
|
|
2112
2112
|
), e && e.appendChild(i), i;
|
|
2113
|
-
},
|
|
2114
|
-
<svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" ${
|
|
2113
|
+
}, mt = () => `
|
|
2114
|
+
<svg class="iti__search-icon-svg" width="14" height="14" viewBox="0 0 24 24" focusable="false" ${p.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>`,
|
|
2118
|
-
const t = `iti-${
|
|
2117
|
+
</svg>`, ft = (r) => {
|
|
2118
|
+
const t = `iti-${r}-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" ${p.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" />
|
|
@@ -2125,7 +2125,7 @@ const nt = {
|
|
|
2125
2125
|
<circle cx="8" cy="8" r="8" class="iti__search-clear-bg" mask="url(#${t})" />
|
|
2126
2126
|
</svg>`;
|
|
2127
2127
|
};
|
|
2128
|
-
class
|
|
2128
|
+
class yt {
|
|
2129
2129
|
constructor(t, e, i) {
|
|
2130
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);
|
|
2131
2131
|
}
|
|
@@ -2140,7 +2140,7 @@ class Ct {
|
|
|
2140
2140
|
this.telInput.classList.add("iti__tel-input"), !this.telInput.hasAttribute("autocomplete") && !((t = this.telInput.form) != null && t.hasAttribute("autocomplete")) && this.telInput.setAttribute("autocomplete", "off");
|
|
2141
2141
|
}
|
|
2142
2142
|
_createWrapperAndInsert() {
|
|
2143
|
-
const { allowDropdown: t, showFlags: e, containerClass: i, useFullscreenPopup: s } = this.options, o =
|
|
2143
|
+
const { allowDropdown: t, showFlags: e, containerClass: i, useFullscreenPopup: s } = this.options, o = U({
|
|
2144
2144
|
iti: !0,
|
|
2145
2145
|
"iti--allow-dropdown": t,
|
|
2146
2146
|
"iti--show-flags": e,
|
|
@@ -2162,10 +2162,10 @@ class Ct {
|
|
|
2162
2162
|
{
|
|
2163
2163
|
type: "button",
|
|
2164
2164
|
class: "iti__selected-country",
|
|
2165
|
-
[
|
|
2166
|
-
[
|
|
2167
|
-
[
|
|
2168
|
-
[
|
|
2165
|
+
[p.EXPANDED]: "false",
|
|
2166
|
+
[p.LABEL]: this.options.i18n.noCountrySelected,
|
|
2167
|
+
[p.HASPOPUP]: "dialog",
|
|
2168
|
+
[p.CONTROLS]: `iti-${this.id}__dropdown-content`
|
|
2169
2169
|
},
|
|
2170
2170
|
this.countryContainer
|
|
2171
2171
|
), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry = m(
|
|
@@ -2184,7 +2184,7 @@ class Ct {
|
|
|
2184
2184
|
o
|
|
2185
2185
|
), e && (this.dropdownArrow = m(
|
|
2186
2186
|
"div",
|
|
2187
|
-
{ class: "iti__arrow", [
|
|
2187
|
+
{ class: "iti__arrow", [p.HIDDEN]: "true" },
|
|
2188
2188
|
o
|
|
2189
2189
|
)), i && (this.selectedDialCode = m(
|
|
2190
2190
|
"div",
|
|
@@ -2201,23 +2201,23 @@ class Ct {
|
|
|
2201
2201
|
i18n: s,
|
|
2202
2202
|
dropdownContainer: o,
|
|
2203
2203
|
containerClass: n
|
|
2204
|
-
} = this.options,
|
|
2204
|
+
} = this.options, l = t ? "" : "iti--flexible-dropdown-width";
|
|
2205
2205
|
if (this.dropdownContent = m("div", {
|
|
2206
2206
|
id: `iti-${this.id}__dropdown-content`,
|
|
2207
|
-
class: `iti__dropdown-content ${h.HIDE} ${
|
|
2207
|
+
class: `iti__dropdown-content ${h.HIDE} ${l}`,
|
|
2208
2208
|
role: "dialog",
|
|
2209
|
-
[
|
|
2209
|
+
[p.MODAL]: "true"
|
|
2210
2210
|
}), this.isRTL && this.dropdownContent.setAttribute("dir", "rtl"), i && this._buildSearchUI(), this.countryList = m(
|
|
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
|
+
[p.LABEL]: s.countryListAriaLabel
|
|
2217
2217
|
},
|
|
2218
2218
|
this.dropdownContent
|
|
2219
2219
|
), this._appendListItems(), i && this.updateSearchResultsA11yText(), o) {
|
|
2220
|
-
const a =
|
|
2220
|
+
const a = U({
|
|
2221
2221
|
iti: !0,
|
|
2222
2222
|
"iti--container": !0,
|
|
2223
2223
|
"iti--fullscreen-popup": e,
|
|
@@ -2238,10 +2238,10 @@ class Ct {
|
|
|
2238
2238
|
"span",
|
|
2239
2239
|
{
|
|
2240
2240
|
class: "iti__search-icon",
|
|
2241
|
-
[
|
|
2241
|
+
[p.HIDDEN]: "true"
|
|
2242
2242
|
},
|
|
2243
2243
|
e
|
|
2244
|
-
), this.searchIcon.innerHTML =
|
|
2244
|
+
), this.searchIcon.innerHTML = mt(), this.searchInput = m(
|
|
2245
2245
|
"input",
|
|
2246
2246
|
{
|
|
2247
2247
|
id: `iti-${this.id}__search-input`,
|
|
@@ -2251,10 +2251,10 @@ class Ct {
|
|
|
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
|
+
[p.EXPANDED]: "true",
|
|
2255
|
+
[p.LABEL]: t.searchPlaceholder,
|
|
2256
|
+
[p.CONTROLS]: `iti-${this.id}__country-listbox`,
|
|
2257
|
+
[p.AUTOCOMPLETE]: "list",
|
|
2258
2258
|
autocomplete: "off"
|
|
2259
2259
|
},
|
|
2260
2260
|
e
|
|
@@ -2263,11 +2263,11 @@ class Ct {
|
|
|
2263
2263
|
{
|
|
2264
2264
|
type: "button",
|
|
2265
2265
|
class: `iti__search-clear ${h.HIDE}`,
|
|
2266
|
-
[
|
|
2266
|
+
[p.LABEL]: t.clearSearchAriaLabel,
|
|
2267
2267
|
tabindex: "-1"
|
|
2268
2268
|
},
|
|
2269
2269
|
e
|
|
2270
|
-
), this.searchClearButton.innerHTML =
|
|
2270
|
+
), this.searchClearButton.innerHTML = ft(this.id), this.searchResultsA11yText = m(
|
|
2271
2271
|
"span",
|
|
2272
2272
|
{ class: "iti__a11y-text" },
|
|
2273
2273
|
this.dropdownContent
|
|
@@ -2275,7 +2275,7 @@ class Ct {
|
|
|
2275
2275
|
"div",
|
|
2276
2276
|
{
|
|
2277
2277
|
class: `iti__no-results ${h.HIDE}`,
|
|
2278
|
-
[
|
|
2278
|
+
[p.HIDDEN]: "true"
|
|
2279
2279
|
// all a11y messaging happens in this.searchResultsA11yText
|
|
2280
2280
|
},
|
|
2281
2281
|
this.dropdownContent
|
|
@@ -2290,19 +2290,19 @@ class Ct {
|
|
|
2290
2290
|
if (e) {
|
|
2291
2291
|
const o = this.telInput.getAttribute("name") || "", n = e(o);
|
|
2292
2292
|
if (n.phone) {
|
|
2293
|
-
const
|
|
2293
|
+
const l = (i = this.telInput.form) == null ? void 0 : i.querySelector(
|
|
2294
2294
|
`input[name="${n.phone}"]`
|
|
2295
2295
|
);
|
|
2296
|
-
|
|
2296
|
+
l ? this.hiddenInput = l : (this.hiddenInput = m("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 l = (s = this.telInput.form) == null ? void 0 : s.querySelector(
|
|
2303
2303
|
`input[name="${n.country}"]`
|
|
2304
2304
|
);
|
|
2305
|
-
|
|
2305
|
+
l ? this.hiddenInputCountry = l : (this.hiddenInputCountry = m("input", {
|
|
2306
2306
|
type: "hidden",
|
|
2307
2307
|
name: n.country
|
|
2308
2308
|
}), t.appendChild(this.hiddenInputCountry));
|
|
@@ -2313,7 +2313,7 @@ class Ct {
|
|
|
2313
2313
|
_appendListItems() {
|
|
2314
2314
|
const t = document.createDocumentFragment();
|
|
2315
2315
|
for (let e = 0; e < this.countries.length; e++) {
|
|
2316
|
-
const i = this.countries[e], s =
|
|
2316
|
+
const i = this.countries[e], s = U({
|
|
2317
2317
|
[h.COUNTRY_ITEM]: !0,
|
|
2318
2318
|
[h.HIGHLIGHT]: e === 0
|
|
2319
2319
|
}), o = m("li", {
|
|
@@ -2321,20 +2321,20 @@ class Ct {
|
|
|
2321
2321
|
class: s,
|
|
2322
2322
|
tabindex: "-1",
|
|
2323
2323
|
role: "option",
|
|
2324
|
-
[
|
|
2324
|
+
[p.SELECTED]: "false"
|
|
2325
2325
|
});
|
|
2326
2326
|
o.dataset.dialCode = i.dialCode, o.dataset.countryCode = i.iso2, i.nodeById[this.id] = o, this.options.showFlags && m("div", { class: `${h.FLAG} iti__${i.iso2}` }, o);
|
|
2327
2327
|
const n = m("span", { class: "iti__country-name" }, o);
|
|
2328
2328
|
n.textContent = i.name;
|
|
2329
|
-
const
|
|
2330
|
-
this.isRTL &&
|
|
2329
|
+
const l = m("span", { class: "iti__dial-code" }, o);
|
|
2330
|
+
this.isRTL && l.setAttribute("dir", "ltr"), l.textContent = `+${i.dialCode}`, t.appendChild(o);
|
|
2331
2331
|
}
|
|
2332
2332
|
this.countryList.appendChild(t);
|
|
2333
2333
|
}
|
|
2334
2334
|
//* Update the input padding to make space for the selected country/dial code.
|
|
2335
2335
|
updateInputPadding() {
|
|
2336
2336
|
if (this.selectedCountry) {
|
|
2337
|
-
const t = this.options.separateDialCode ?
|
|
2337
|
+
const t = this.options.separateDialCode ? R.SANE_SELECTED_WITH_DIAL_WIDTH : R.SANE_SELECTED_NO_DIAL_WIDTH, i = (this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth() || t) + R.INPUT_PADDING_EXTRA_LEFT;
|
|
2338
2338
|
this.telInput.style.paddingLeft = `${i}px`;
|
|
2339
2339
|
}
|
|
2340
2340
|
}
|
|
@@ -2376,20 +2376,20 @@ class Ct {
|
|
|
2376
2376
|
}
|
|
2377
2377
|
//* Check if an element is visible within it's container, else scroll until it is.
|
|
2378
2378
|
scrollTo(t) {
|
|
2379
|
-
const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, o = e.getBoundingClientRect().top + i, n = o + s,
|
|
2379
|
+
const e = this.countryList, i = document.documentElement.scrollTop, s = e.offsetHeight, o = e.getBoundingClientRect().top + i, n = o + s, l = t.offsetHeight, a = t.getBoundingClientRect().top + i, d = a + l, c = a - o + e.scrollTop;
|
|
2380
2380
|
if (a < o)
|
|
2381
2381
|
e.scrollTop = c;
|
|
2382
2382
|
else if (d > n) {
|
|
2383
|
-
const f = s -
|
|
2383
|
+
const f = s - l;
|
|
2384
2384
|
e.scrollTop = c - f;
|
|
2385
2385
|
}
|
|
2386
2386
|
}
|
|
2387
2387
|
//* Remove highlighting from other list items and highlight the given item.
|
|
2388
2388
|
highlightListItem(t, e) {
|
|
2389
2389
|
const i = this.highlightedItem;
|
|
2390
|
-
if (i && (i.classList.remove(h.HIGHLIGHT), i.setAttribute(
|
|
2390
|
+
if (i && (i.classList.remove(h.HIGHLIGHT), i.setAttribute(p.SELECTED, "false")), this.highlightedItem = t, this.highlightedItem && (this.highlightedItem.classList.add(h.HIGHLIGHT), this.highlightedItem.setAttribute(p.SELECTED, "true"), this.options.countrySearch)) {
|
|
2391
2391
|
const s = this.highlightedItem.getAttribute("id") || "";
|
|
2392
|
-
this.searchInput.setAttribute(
|
|
2392
|
+
this.searchInput.setAttribute(p.ACTIVE_DESCENDANT, s);
|
|
2393
2393
|
}
|
|
2394
2394
|
e && this.highlightedItem.focus();
|
|
2395
2395
|
}
|
|
@@ -2412,46 +2412,46 @@ class Ct {
|
|
|
2412
2412
|
this.countries = null;
|
|
2413
2413
|
}
|
|
2414
2414
|
}
|
|
2415
|
-
const
|
|
2416
|
-
const { onlyCountries: t, excludeCountries: e } =
|
|
2415
|
+
const gt = (r) => {
|
|
2416
|
+
const { onlyCountries: t, excludeCountries: e } = r;
|
|
2417
2417
|
if (t.length) {
|
|
2418
2418
|
const i = t.map(
|
|
2419
2419
|
(s) => s.toLowerCase()
|
|
2420
2420
|
);
|
|
2421
|
-
return
|
|
2421
|
+
return A.filter(
|
|
2422
2422
|
(s) => i.includes(s.iso2)
|
|
2423
2423
|
);
|
|
2424
2424
|
} else if (e.length) {
|
|
2425
2425
|
const i = e.map(
|
|
2426
2426
|
(s) => s.toLowerCase()
|
|
2427
2427
|
);
|
|
2428
|
-
return
|
|
2428
|
+
return A.filter(
|
|
2429
2429
|
(s) => !i.includes(s.iso2)
|
|
2430
2430
|
);
|
|
2431
2431
|
}
|
|
2432
|
-
return
|
|
2433
|
-
},
|
|
2434
|
-
for (const e of
|
|
2432
|
+
return A;
|
|
2433
|
+
}, _t = (r, t) => {
|
|
2434
|
+
for (const e of r) {
|
|
2435
2435
|
const i = e.iso2.toLowerCase();
|
|
2436
2436
|
t.i18n[i] && (e.name = t.i18n[i]);
|
|
2437
2437
|
}
|
|
2438
|
-
},
|
|
2438
|
+
}, bt = (r, t) => {
|
|
2439
2439
|
const e = /* @__PURE__ */ new Set();
|
|
2440
2440
|
let i = 0;
|
|
2441
|
-
const s = {}, o = (n,
|
|
2442
|
-
if (!n || !
|
|
2441
|
+
const s = {}, o = (n, l, a) => {
|
|
2442
|
+
if (!n || !l)
|
|
2443
2443
|
return;
|
|
2444
|
-
|
|
2445
|
-
const d = s[
|
|
2444
|
+
l.length > i && (i = l.length), s.hasOwnProperty(l) || (s[l] = []);
|
|
2445
|
+
const d = s[l];
|
|
2446
2446
|
if (d.includes(n))
|
|
2447
2447
|
return;
|
|
2448
2448
|
const c = a !== void 0 ? a : d.length;
|
|
2449
2449
|
d[c] = n;
|
|
2450
2450
|
};
|
|
2451
|
-
for (const n of
|
|
2451
|
+
for (const n of r) {
|
|
2452
2452
|
e.has(n.dialCode) || e.add(n.dialCode);
|
|
2453
|
-
for (let
|
|
2454
|
-
const a = n.dialCode.substring(0,
|
|
2453
|
+
for (let l = 1; l < n.dialCode.length; l++) {
|
|
2454
|
+
const a = n.dialCode.substring(0, l);
|
|
2455
2455
|
o(n.iso2, a);
|
|
2456
2456
|
}
|
|
2457
2457
|
o(n.iso2, n.dialCode, n.priority);
|
|
@@ -2459,56 +2459,56 @@ const mt = (l) => {
|
|
|
2459
2459
|
(t.onlyCountries.length || t.excludeCountries.length) && e.forEach((n) => {
|
|
2460
2460
|
s[n] = s[n].filter(Boolean);
|
|
2461
2461
|
});
|
|
2462
|
-
for (const n of
|
|
2462
|
+
for (const n of r)
|
|
2463
2463
|
if (n.areaCodes) {
|
|
2464
|
-
const
|
|
2464
|
+
const l = s[n.dialCode][0];
|
|
2465
2465
|
for (const a of n.areaCodes) {
|
|
2466
2466
|
for (let d = 1; d < a.length; d++) {
|
|
2467
2467
|
const c = a.substring(0, d), f = n.dialCode + c;
|
|
2468
|
-
o(
|
|
2468
|
+
o(l, f), o(n.iso2, f);
|
|
2469
2469
|
}
|
|
2470
2470
|
o(n.iso2, n.dialCode + a);
|
|
2471
2471
|
}
|
|
2472
2472
|
}
|
|
2473
2473
|
return { dialCodes: e, dialCodeMaxLen: i, dialCodeToIso2Map: s };
|
|
2474
|
-
},
|
|
2474
|
+
}, It = (r, t) => {
|
|
2475
2475
|
t.countryOrder && (t.countryOrder = t.countryOrder.map(
|
|
2476
2476
|
(e) => e.toLowerCase()
|
|
2477
|
-
)),
|
|
2477
|
+
)), r.sort((e, i) => {
|
|
2478
2478
|
const { countryOrder: s } = t;
|
|
2479
2479
|
if (s) {
|
|
2480
|
-
const o = s.indexOf(e.iso2), n = s.indexOf(i.iso2),
|
|
2481
|
-
if (
|
|
2482
|
-
return
|
|
2480
|
+
const o = s.indexOf(e.iso2), n = s.indexOf(i.iso2), l = o > -1, a = n > -1;
|
|
2481
|
+
if (l || a)
|
|
2482
|
+
return l && a ? o - n : l ? -1 : 1;
|
|
2483
2483
|
}
|
|
2484
2484
|
return e.name.localeCompare(i.name);
|
|
2485
2485
|
});
|
|
2486
|
-
},
|
|
2487
|
-
for (const t of
|
|
2488
|
-
t.normalisedName =
|
|
2489
|
-
},
|
|
2490
|
-
let s =
|
|
2486
|
+
}, Nt = (r) => {
|
|
2487
|
+
for (const t of r)
|
|
2488
|
+
t.normalisedName = q(t.name), t.initials = t.normalisedName.split(/[^a-z]/).map((e) => e[0]).join(""), t.dialCodePlus = `+${t.dialCode}`;
|
|
2489
|
+
}, wt = (r, t, e, i) => {
|
|
2490
|
+
let s = r;
|
|
2491
2491
|
if (e && t) {
|
|
2492
2492
|
t = `+${i.dialCode}`;
|
|
2493
2493
|
const o = s[t.length] === " " || s[t.length] === "-" ? t.length + 1 : t.length;
|
|
2494
2494
|
s = s.substring(o);
|
|
2495
2495
|
}
|
|
2496
2496
|
return s;
|
|
2497
|
-
},
|
|
2498
|
-
const o = e ? e.formatNumberAsYouType(
|
|
2497
|
+
}, Dt = (r, t, e, i, s) => {
|
|
2498
|
+
const o = e ? e.formatNumberAsYouType(r, i.iso2) : r, { dialCode: n } = i;
|
|
2499
2499
|
return s && t.charAt(0) !== "+" && o.includes(`+${n}`) ? (o.split(`+${n}`)[1] || "").trim() : o;
|
|
2500
|
-
},
|
|
2500
|
+
}, Et = (r, t, e, i) => {
|
|
2501
2501
|
if (e === 0 && !i)
|
|
2502
2502
|
return 0;
|
|
2503
2503
|
let s = 0;
|
|
2504
2504
|
for (let o = 0; o < t.length; o++) {
|
|
2505
|
-
if (/[+0-9]/.test(t[o]) && s++, s ===
|
|
2505
|
+
if (/[+0-9]/.test(t[o]) && s++, s === r && !i)
|
|
2506
2506
|
return o + 1;
|
|
2507
|
-
if (i && s ===
|
|
2507
|
+
if (i && s === r + 1)
|
|
2508
2508
|
return o;
|
|
2509
2509
|
}
|
|
2510
2510
|
return t.length;
|
|
2511
|
-
},
|
|
2511
|
+
}, Lt = [
|
|
2512
2512
|
"800",
|
|
2513
2513
|
"822",
|
|
2514
2514
|
"833",
|
|
@@ -2526,22 +2526,22 @@ const mt = (l) => {
|
|
|
2526
2526
|
"887",
|
|
2527
2527
|
"888",
|
|
2528
2528
|
"889"
|
|
2529
|
-
],
|
|
2530
|
-
const t = v(
|
|
2531
|
-
if (t.startsWith(
|
|
2529
|
+
], z = (r) => {
|
|
2530
|
+
const t = v(r);
|
|
2531
|
+
if (t.startsWith(K.NANP) && t.length >= 4) {
|
|
2532
2532
|
const e = t.substring(1, 4);
|
|
2533
|
-
return
|
|
2533
|
+
return Lt.includes(e);
|
|
2534
2534
|
}
|
|
2535
2535
|
return !1;
|
|
2536
2536
|
};
|
|
2537
|
-
for (const
|
|
2538
|
-
|
|
2539
|
-
let
|
|
2540
|
-
const
|
|
2541
|
-
class
|
|
2537
|
+
for (const r of A)
|
|
2538
|
+
r.name = j[r.iso2];
|
|
2539
|
+
let At = 0;
|
|
2540
|
+
const Tt = new Set(A.map((r) => r.iso2)), B = (r) => Tt.has(r);
|
|
2541
|
+
class V {
|
|
2542
2542
|
constructor(t, e = {}) {
|
|
2543
|
-
this.id =
|
|
2544
|
-
const { dialCodes: i, dialCodeMaxLen: s, dialCodeToIso2Map: o } =
|
|
2543
|
+
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
|
+
const { dialCodes: i, dialCodeMaxLen: s, dialCodeToIso2Map: o } = bt(
|
|
2545
2545
|
this.countries,
|
|
2546
2546
|
this.options
|
|
2547
2547
|
);
|
|
@@ -2550,6 +2550,31 @@ class U {
|
|
|
2550
2550
|
static _getIsAndroid() {
|
|
2551
2551
|
return typeof navigator < "u" ? /Android/i.test(navigator.userAgent) : !1;
|
|
2552
2552
|
}
|
|
2553
|
+
_updateNumeralSet(t) {
|
|
2554
|
+
/[\u0660-\u0669]/.test(t) ? this.userNumeralSet = "arabic-indic" : /[\u06F0-\u06F9]/.test(t) ? this.userNumeralSet = "persian" : this.userNumeralSet = "ascii";
|
|
2555
|
+
}
|
|
2556
|
+
_mapAsciiToUserNumerals(t) {
|
|
2557
|
+
if (this.userNumeralSet || this._updateNumeralSet(this.ui.telInput.value), this.userNumeralSet === "ascii")
|
|
2558
|
+
return t;
|
|
2559
|
+
const e = this.userNumeralSet === "arabic-indic" ? 1632 : 1776;
|
|
2560
|
+
return t.replace(/[0-9]/g, (i) => String.fromCharCode(e + Number(i)));
|
|
2561
|
+
}
|
|
2562
|
+
// Normalize Eastern Arabic (U+0660-0669) and Persian/Extended Arabic-Indic (U+06F0-06F9) numerals to ASCII 0-9
|
|
2563
|
+
_normaliseNumerals(t) {
|
|
2564
|
+
if (!t)
|
|
2565
|
+
return "";
|
|
2566
|
+
if (this._updateNumeralSet(t), this.userNumeralSet === "ascii")
|
|
2567
|
+
return t;
|
|
2568
|
+
const e = this.userNumeralSet === "arabic-indic" ? 1632 : 1776, i = this.userNumeralSet === "arabic-indic" ? /[\u0660-\u0669]/g : /[\u06F0-\u06F9]/g;
|
|
2569
|
+
return t.replace(i, (s) => String.fromCharCode(48 + (s.charCodeAt(0) - e)));
|
|
2570
|
+
}
|
|
2571
|
+
_getTelInputValue() {
|
|
2572
|
+
const t = this.ui.telInput.value.trim();
|
|
2573
|
+
return this._normaliseNumerals(t);
|
|
2574
|
+
}
|
|
2575
|
+
_setTelInputValue(t) {
|
|
2576
|
+
this.ui.telInput.value = this._mapAsciiToUserNumerals(t);
|
|
2577
|
+
}
|
|
2553
2578
|
_createInitPromises() {
|
|
2554
2579
|
const t = new Promise((i, s) => {
|
|
2555
2580
|
this.resolveAutoCountryPromise = i, this.rejectAutoCountryPromise = s;
|
|
@@ -2567,20 +2592,20 @@ class U {
|
|
|
2567
2592
|
//********************
|
|
2568
2593
|
//* Prepare all of the country data, including onlyCountries, excludeCountries, countryOrder options.
|
|
2569
2594
|
_processCountryData() {
|
|
2570
|
-
|
|
2595
|
+
_t(this.countries, this.options), It(this.countries, this.options), Nt(this.countries);
|
|
2571
2596
|
}
|
|
2572
2597
|
//* Set the initial state of the input value and the selected country by:
|
|
2573
2598
|
//* 1. Extracting a dial code from the given number
|
|
2574
2599
|
//* 2. Using explicit initialCountry
|
|
2575
2600
|
_setInitialState(t = !1) {
|
|
2576
|
-
const e = this.ui.telInput.getAttribute("value"), i = this.
|
|
2577
|
-
if (
|
|
2578
|
-
this._updateCountryFromNumber(
|
|
2579
|
-
else if (!
|
|
2580
|
-
const
|
|
2581
|
-
|
|
2601
|
+
const e = this.ui.telInput.getAttribute("value"), i = this._normaliseNumerals(e), s = this._getTelInputValue(), n = i && i.startsWith("+") && (!s || !s.startsWith("+")) ? i : s, l = this._getDialCode(n), a = z(n), { initialCountry: d, geoIpLookup: c } = this.options, f = d === M.AUTO && c;
|
|
2602
|
+
if (l && !a)
|
|
2603
|
+
this._updateCountryFromNumber(n);
|
|
2604
|
+
else if (!f || t) {
|
|
2605
|
+
const b = d ? d.toLowerCase() : "";
|
|
2606
|
+
B(b) ? this._setCountry(b) : l && a ? this._setCountry(dt.ISO2) : this._setCountry("");
|
|
2582
2607
|
}
|
|
2583
|
-
|
|
2608
|
+
n && this._updateValFromNumber(n);
|
|
2584
2609
|
}
|
|
2585
2610
|
//* Initialise the main event listeners: input keyup, and click selected country.
|
|
2586
2611
|
_initListeners() {
|
|
@@ -2617,7 +2642,7 @@ class U {
|
|
|
2617
2642
|
const o = (n) => {
|
|
2618
2643
|
this.ui.dropdownContent.classList.contains(
|
|
2619
2644
|
h.HIDE
|
|
2620
|
-
) && [
|
|
2645
|
+
) && [_.ARROW_UP, _.ARROW_DOWN, _.SPACE, _.ENTER].includes(n.key) && (n.preventDefault(), n.stopPropagation(), this._openDropdown()), n.key === _.TAB && this._closeDropdown();
|
|
2621
2646
|
};
|
|
2622
2647
|
this.ui.countryContainer.addEventListener(
|
|
2623
2648
|
"keydown",
|
|
@@ -2646,17 +2671,17 @@ class U {
|
|
|
2646
2671
|
}
|
|
2647
2672
|
} else
|
|
2648
2673
|
this.resolveUtilsScriptPromise();
|
|
2649
|
-
e ===
|
|
2674
|
+
e === M.AUTO && i && !this.selectedCountryData.iso2 ? this._loadAutoCountry() : this.resolveAutoCountryPromise();
|
|
2650
2675
|
}
|
|
2651
2676
|
//* Perform the geo ip lookup.
|
|
2652
2677
|
_loadAutoCountry() {
|
|
2653
2678
|
u.autoCountry ? this.handleAutoCountry() : u.startedLoadingAutoCountry || (u.startedLoadingAutoCountry = !0, typeof this.options.geoIpLookup == "function" && this.options.geoIpLookup(
|
|
2654
2679
|
(t = "") => {
|
|
2655
2680
|
const e = t.toLowerCase();
|
|
2656
|
-
|
|
2681
|
+
B(e) ? (u.autoCountry = e, setTimeout(() => T("handleAutoCountry"))) : (this._setInitialState(!0), T("rejectAutoCountryPromise"));
|
|
2657
2682
|
},
|
|
2658
2683
|
() => {
|
|
2659
|
-
this._setInitialState(!0),
|
|
2684
|
+
this._setInitialState(!0), T("rejectAutoCountryPromise");
|
|
2660
2685
|
}
|
|
2661
2686
|
));
|
|
2662
2687
|
}
|
|
@@ -2676,45 +2701,43 @@ class U {
|
|
|
2676
2701
|
countrySearch: o
|
|
2677
2702
|
} = this.options;
|
|
2678
2703
|
let n = !1;
|
|
2679
|
-
|
|
2680
|
-
const
|
|
2704
|
+
L.ALPHA_UNICODE.test(this._getTelInputValue()) && (n = !0);
|
|
2705
|
+
const l = (a) => {
|
|
2706
|
+
const d = this._getTelInputValue();
|
|
2681
2707
|
if (this.isAndroid && (a == null ? void 0 : a.data) === "+" && i && s && o) {
|
|
2682
|
-
const
|
|
2683
|
-
|
|
2684
|
-
b - 1
|
|
2685
|
-
), y = this.ui.telInput.value.substring(b);
|
|
2686
|
-
this.ui.telInput.value = p + y, this._openDropdownWithPlus();
|
|
2708
|
+
const y = this.ui.telInput.selectionStart || 0, I = d.substring(0, y - 1), N = d.substring(y);
|
|
2709
|
+
this._setTelInputValue(I + N), this._openDropdownWithPlus();
|
|
2687
2710
|
return;
|
|
2688
2711
|
}
|
|
2689
|
-
this._updateCountryFromNumber(
|
|
2690
|
-
const
|
|
2691
|
-
|
|
2692
|
-
const
|
|
2693
|
-
if (e && !n && !
|
|
2694
|
-
const
|
|
2712
|
+
this._updateCountryFromNumber(d) && this._triggerCountryChange();
|
|
2713
|
+
const c = (a == null ? void 0 : a.data) && L.NON_PLUS_NUMERIC.test(a.data), f = (a == null ? void 0 : a.inputType) === F.PASTE && d;
|
|
2714
|
+
c || f && !t ? n = !0 : L.NON_PLUS_NUMERIC.test(d) || (n = !1);
|
|
2715
|
+
const b = (a == null ? void 0 : a.detail) && a.detail.isSetNumber, C = this.userNumeralSet === "ascii";
|
|
2716
|
+
if (e && !n && !b && C) {
|
|
2717
|
+
const y = this.ui.telInput.selectionStart || 0, N = d.substring(
|
|
2695
2718
|
0,
|
|
2696
|
-
|
|
2719
|
+
y
|
|
2697
2720
|
).replace(
|
|
2698
|
-
|
|
2721
|
+
L.NON_PLUS_NUMERIC_GLOBAL,
|
|
2699
2722
|
""
|
|
2700
|
-
).length,
|
|
2701
|
-
|
|
2702
|
-
|
|
2723
|
+
).length, D = (a == null ? void 0 : a.inputType) === F.DELETE_FWD, g = this._getFullNumber(), E = Dt(
|
|
2724
|
+
g,
|
|
2725
|
+
d,
|
|
2703
2726
|
u.utils,
|
|
2704
2727
|
this.selectedCountryData,
|
|
2705
2728
|
this.options.separateDialCode
|
|
2706
|
-
),
|
|
2729
|
+
), w = Et(
|
|
2730
|
+
N,
|
|
2731
|
+
E,
|
|
2707
2732
|
y,
|
|
2708
|
-
|
|
2709
|
-
b,
|
|
2710
|
-
w
|
|
2733
|
+
D
|
|
2711
2734
|
);
|
|
2712
|
-
this.
|
|
2735
|
+
this._setTelInputValue(E), this.ui.telInput.setSelectionRange(w, w);
|
|
2713
2736
|
}
|
|
2714
2737
|
};
|
|
2715
2738
|
this.ui.telInput.addEventListener(
|
|
2716
2739
|
"input",
|
|
2717
|
-
|
|
2740
|
+
l,
|
|
2718
2741
|
{
|
|
2719
2742
|
signal: this.abortController.signal
|
|
2720
2743
|
}
|
|
@@ -2730,11 +2753,11 @@ class U {
|
|
|
2730
2753
|
return;
|
|
2731
2754
|
}
|
|
2732
2755
|
if (t) {
|
|
2733
|
-
const
|
|
2734
|
-
|
|
2756
|
+
const l = this._getTelInputValue(), d = !l.startsWith("+") && this.ui.telInput.selectionStart === 0 && n.key === "+", c = this._normaliseNumerals(n.key), f = /^[0-9]$/.test(c), b = e ? f : d || f, C = this.ui.telInput, y = C.selectionStart, I = C.selectionEnd, N = l.slice(0, y), D = l.slice(I), g = N + n.key + D, E = this._getFullNumber(g), w = u.utils.getCoreNumber(
|
|
2757
|
+
E,
|
|
2735
2758
|
this.selectedCountryData.iso2
|
|
2736
|
-
),
|
|
2737
|
-
(!
|
|
2759
|
+
), P = this.maxCoreNumberLength && w.length > this.maxCoreNumberLength, X = this._getNewCountryFromNumber(E) !== null;
|
|
2760
|
+
(!b || P && !X && !d) && n.preventDefault();
|
|
2738
2761
|
}
|
|
2739
2762
|
}
|
|
2740
2763
|
};
|
|
@@ -2747,21 +2770,24 @@ class U {
|
|
|
2747
2770
|
if (this.options.strictMode) {
|
|
2748
2771
|
const t = (e) => {
|
|
2749
2772
|
e.preventDefault();
|
|
2750
|
-
const i = this.ui.telInput, s = i.selectionStart, o = i.selectionEnd, n =
|
|
2751
|
-
let
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
if (i.selectionEnd === i.value.length) {
|
|
2758
|
-
const K = _.length - this.maxCoreNumberLength;
|
|
2759
|
-
I = I.slice(0, I.length - K);
|
|
2760
|
-
} else
|
|
2773
|
+
const i = this.ui.telInput, s = i.selectionStart, o = i.selectionEnd, n = this._getTelInputValue(), l = n.slice(0, s), a = n.slice(o), d = this.selectedCountryData.iso2, c = e.clipboardData.getData("text"), f = this._normaliseNumerals(c), b = s === 0 && o > 0, C = !n.startsWith("+") || b, y = f.replace(L.NON_PLUS_NUMERIC_GLOBAL, ""), I = y.startsWith("+"), N = y.replace(/\+/g, ""), D = I && C ? `+${N}` : N;
|
|
2774
|
+
let g = l + D + a;
|
|
2775
|
+
if (g.length > 5) {
|
|
2776
|
+
let w = u.utils.getCoreNumber(g, d);
|
|
2777
|
+
for (; w.length === 0 && g.length > 0; )
|
|
2778
|
+
g = g.slice(0, -1), w = u.utils.getCoreNumber(g, d);
|
|
2779
|
+
if (!w)
|
|
2761
2780
|
return;
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2781
|
+
if (this.maxCoreNumberLength && w.length > this.maxCoreNumberLength)
|
|
2782
|
+
if (i.selectionEnd === n.length) {
|
|
2783
|
+
const P = w.length - this.maxCoreNumberLength;
|
|
2784
|
+
g = g.slice(0, g.length - P);
|
|
2785
|
+
} else
|
|
2786
|
+
return;
|
|
2787
|
+
}
|
|
2788
|
+
this._setTelInputValue(g);
|
|
2789
|
+
const E = s + D.length;
|
|
2790
|
+
i.setSelectionRange(E, E), i.dispatchEvent(new InputEvent("input", { bubbles: !0 }));
|
|
2765
2791
|
};
|
|
2766
2792
|
this.ui.telInput.addEventListener("paste", t, {
|
|
2767
2793
|
signal: this.abortController.signal
|
|
@@ -2785,11 +2811,11 @@ class U {
|
|
|
2785
2811
|
//* Open the dropdown.
|
|
2786
2812
|
_openDropdown() {
|
|
2787
2813
|
const { fixDropdownWidth: t, countrySearch: e } = this.options;
|
|
2788
|
-
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(
|
|
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(p.EXPANDED, "true"), this._setDropdownPosition(), e) {
|
|
2789
2815
|
const i = this.ui.countryList.firstElementChild;
|
|
2790
2816
|
i && (this.ui.highlightListItem(i, !1), this.ui.countryList.scrollTop = 0), this.ui.searchInput.focus();
|
|
2791
2817
|
}
|
|
2792
|
-
this._bindDropdownListeners(), this.ui.dropdownArrow.classList.add(h.ARROW_UP), this._trigger(
|
|
2818
|
+
this._bindDropdownListeners(), this.ui.dropdownArrow.classList.add(h.ARROW_UP), this._trigger(S.OPEN_COUNTRY_DROPDOWN);
|
|
2793
2819
|
}
|
|
2794
2820
|
//* Set the dropdown position
|
|
2795
2821
|
_setDropdownPosition() {
|
|
@@ -2864,13 +2890,13 @@ class U {
|
|
|
2864
2890
|
let e = "", i = null;
|
|
2865
2891
|
const s = (o) => {
|
|
2866
2892
|
[
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
].includes(o.key) && (o.preventDefault(), o.stopPropagation(), o.key ===
|
|
2893
|
+
_.ARROW_UP,
|
|
2894
|
+
_.ARROW_DOWN,
|
|
2895
|
+
_.ENTER,
|
|
2896
|
+
_.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 && L.HIDDEN_SEARCH_CHAR.test(o.key) && (o.stopPropagation(), i && clearTimeout(i), e += o.key.toLowerCase(), this._searchForCountry(e), i = setTimeout(() => {
|
|
2872
2898
|
e = "";
|
|
2873
|
-
},
|
|
2899
|
+
}, ut.HIDDEN_SEARCH_RESET_MS));
|
|
2874
2900
|
};
|
|
2875
2901
|
document.addEventListener("keydown", s, { signal: t });
|
|
2876
2902
|
}
|
|
@@ -2898,7 +2924,7 @@ class U {
|
|
|
2898
2924
|
}
|
|
2899
2925
|
//* Hidden search (countrySearch disabled): Find the first list item whose name starts with the query string.
|
|
2900
2926
|
_searchForCountry(t) {
|
|
2901
|
-
const e =
|
|
2927
|
+
const e = Ct(this.countries, t);
|
|
2902
2928
|
if (e) {
|
|
2903
2929
|
const i = e.nodeById[this.id];
|
|
2904
2930
|
this.ui.highlightListItem(i, !1), this.ui.scrollTo(i);
|
|
@@ -2907,13 +2933,13 @@ class U {
|
|
|
2907
2933
|
//* Country search: Filter the countries according to the search query.
|
|
2908
2934
|
_filterCountriesByQuery(t) {
|
|
2909
2935
|
let e;
|
|
2910
|
-
t === "" ? e = this.countries : e =
|
|
2936
|
+
t === "" ? e = this.countries : e = pt(this.countries, t), this.ui.filterCountries(e);
|
|
2911
2937
|
}
|
|
2912
2938
|
//* Highlight the next/prev item in the list (and ensure it is visible).
|
|
2913
2939
|
_handleUpDownKey(t) {
|
|
2914
2940
|
var i, s;
|
|
2915
|
-
let e = t ===
|
|
2916
|
-
!e && this.ui.countryList.childElementCount > 1 && (e = t ===
|
|
2941
|
+
let e = t === _.ARROW_UP ? (i = this.ui.highlightedItem) == null ? void 0 : i.previousElementSibling : (s = this.ui.highlightedItem) == null ? void 0 : s.nextElementSibling;
|
|
2942
|
+
!e && this.ui.countryList.childElementCount > 1 && (e = t === _.ARROW_UP ? this.ui.countryList.lastElementChild : this.ui.countryList.firstElementChild), e && (this.ui.scrollTo(e), this.ui.highlightListItem(e, !1));
|
|
2917
2943
|
}
|
|
2918
2944
|
//* Select the currently highlighted item.
|
|
2919
2945
|
_handleEnterKey() {
|
|
@@ -2931,7 +2957,7 @@ class U {
|
|
|
2931
2957
|
n
|
|
2932
2958
|
);
|
|
2933
2959
|
}
|
|
2934
|
-
e = this._beforeSetNumber(e), this.
|
|
2960
|
+
e = this._beforeSetNumber(e), this._setTelInputValue(e);
|
|
2935
2961
|
}
|
|
2936
2962
|
//* Check if need to select a new country based on the given number
|
|
2937
2963
|
//* Note: called from _setInitialState, keyup handler, setNumber.
|
|
@@ -2955,30 +2981,30 @@ class U {
|
|
|
2955
2981
|
let i = e ? t.substring(e) : t;
|
|
2956
2982
|
const s = this.selectedCountryData.iso2, o = this.selectedCountryData.dialCode;
|
|
2957
2983
|
i = this._ensureHasDialCode(i);
|
|
2958
|
-
const n = this._getDialCode(i, !0),
|
|
2984
|
+
const n = this._getDialCode(i, !0), l = v(i);
|
|
2959
2985
|
if (n) {
|
|
2960
2986
|
const a = v(n), d = this.dialCodeToIso2Map[a];
|
|
2961
2987
|
if (d.length === 1)
|
|
2962
2988
|
return d[0] === s ? null : d[0];
|
|
2963
2989
|
if (!s && this.defaultCountry && d.includes(this.defaultCountry))
|
|
2964
2990
|
return this.defaultCountry;
|
|
2965
|
-
if (o ===
|
|
2991
|
+
if (o === K.NANP && z(l))
|
|
2966
2992
|
return null;
|
|
2967
2993
|
const { areaCodes: f, priority: b } = this.selectedCountryData;
|
|
2968
2994
|
if (f) {
|
|
2969
|
-
const
|
|
2970
|
-
(
|
|
2995
|
+
const D = f.map(
|
|
2996
|
+
(g) => `${o}${g}`
|
|
2971
2997
|
);
|
|
2972
|
-
for (const
|
|
2973
|
-
if (
|
|
2998
|
+
for (const g of D)
|
|
2999
|
+
if (l.startsWith(g))
|
|
2974
3000
|
return null;
|
|
2975
3001
|
}
|
|
2976
|
-
const y = f && !(b === 0) &&
|
|
2977
|
-
if (!
|
|
3002
|
+
const y = f && !(b === 0) && l.length > a.length, I = s && d.includes(s) && !y, N = s === d[0];
|
|
3003
|
+
if (!I && !N)
|
|
2978
3004
|
return d[0];
|
|
2979
|
-
} else if (i.startsWith("+") &&
|
|
3005
|
+
} else if (i.startsWith("+") && l.length) {
|
|
2980
3006
|
const a = this.selectedCountryData.dialCode || "";
|
|
2981
|
-
return a && a.startsWith(
|
|
3007
|
+
return a && a.startsWith(l) ? null : "";
|
|
2982
3008
|
} else if ((!i || i === "+") && !s)
|
|
2983
3009
|
return this.defaultCountry;
|
|
2984
3010
|
return null;
|
|
@@ -2989,13 +3015,13 @@ class U {
|
|
|
2989
3015
|
const { separateDialCode: e, showFlags: i, i18n: s } = this.options, o = this.selectedCountryData.iso2 || "";
|
|
2990
3016
|
if (this.selectedCountryData = t ? this.countryByIso2.get(t) : {}, this.selectedCountryData.iso2 && (this.defaultCountry = this.selectedCountryData.iso2), this.ui.selectedCountry) {
|
|
2991
3017
|
const n = t && i ? `${h.FLAG} iti__${t}` : `${h.FLAG} ${h.GLOBE}`;
|
|
2992
|
-
let
|
|
3018
|
+
let l, a;
|
|
2993
3019
|
if (t) {
|
|
2994
3020
|
const { name: d, dialCode: c } = this.selectedCountryData;
|
|
2995
|
-
a = d,
|
|
3021
|
+
a = d, l = s.selectedCountryAriaLabel.replace("${countryName}", d).replace("${dialCode}", `+${c}`);
|
|
2996
3022
|
} else
|
|
2997
|
-
a = s.noCountrySelected,
|
|
2998
|
-
this.ui.selectedCountryInner.className = n, this.ui.selectedCountry.setAttribute("title", a), this.ui.selectedCountry.setAttribute(
|
|
3023
|
+
a = s.noCountrySelected, l = s.noCountrySelected;
|
|
3024
|
+
this.ui.selectedCountryInner.className = n, this.ui.selectedCountry.setAttribute("title", a), this.ui.selectedCountry.setAttribute(p.LABEL, l);
|
|
2999
3025
|
}
|
|
3000
3026
|
if (e) {
|
|
3001
3027
|
const n = this.selectedCountryData.dialCode ? `+${this.selectedCountryData.dialCode}` : "";
|
|
@@ -3014,14 +3040,14 @@ class U {
|
|
|
3014
3040
|
!1,
|
|
3015
3041
|
o,
|
|
3016
3042
|
!0
|
|
3017
|
-
),
|
|
3043
|
+
), l = n;
|
|
3018
3044
|
for (; u.utils.isPossibleNumber(
|
|
3019
3045
|
n,
|
|
3020
3046
|
s,
|
|
3021
3047
|
i
|
|
3022
3048
|
); )
|
|
3023
|
-
|
|
3024
|
-
const a = u.utils.getCoreNumber(
|
|
3049
|
+
l = n, n += "0";
|
|
3050
|
+
const a = u.utils.getCoreNumber(l, s);
|
|
3025
3051
|
this.maxCoreNumberLength = a.length, s === "by" && (this.maxCoreNumberLength = a.length + 1);
|
|
3026
3052
|
} else
|
|
3027
3053
|
this.maxCoreNumberLength = null;
|
|
@@ -3033,36 +3059,40 @@ class U {
|
|
|
3033
3059
|
placeholderNumberType: e,
|
|
3034
3060
|
nationalMode: i,
|
|
3035
3061
|
customPlaceholder: s
|
|
3036
|
-
} = this.options, o = t ===
|
|
3062
|
+
} = this.options, o = t === H.AGGRESSIVE || !this.ui.hadInitialPlaceholder && t === H.POLITE;
|
|
3037
3063
|
if (u.utils && o) {
|
|
3038
3064
|
const n = u.utils.numberType[e];
|
|
3039
|
-
let
|
|
3065
|
+
let l = this.selectedCountryData.iso2 ? u.utils.getExampleNumber(
|
|
3040
3066
|
this.selectedCountryData.iso2,
|
|
3041
3067
|
i,
|
|
3042
3068
|
n
|
|
3043
3069
|
) : "";
|
|
3044
|
-
|
|
3070
|
+
l = this._beforeSetNumber(l), typeof s == "function" && (l = s(l, this.selectedCountryData)), this.ui.telInput.setAttribute("placeholder", l);
|
|
3045
3071
|
}
|
|
3046
3072
|
}
|
|
3047
3073
|
//* Called when the user selects a list item from the dropdown.
|
|
3048
3074
|
_selectListItem(t) {
|
|
3049
|
-
const e = t.dataset[
|
|
3075
|
+
const e = t.dataset[G.COUNTRY_CODE], i = this._setCountry(e);
|
|
3050
3076
|
this._closeDropdown();
|
|
3051
|
-
const s = t.dataset[
|
|
3052
|
-
this._updateDialCode(s), this.options.formatOnDisplay
|
|
3077
|
+
const s = t.dataset[G.DIAL_CODE];
|
|
3078
|
+
if (this._updateDialCode(s), this.options.formatOnDisplay) {
|
|
3079
|
+
const o = this._getTelInputValue();
|
|
3080
|
+
this._updateValFromNumber(o);
|
|
3081
|
+
}
|
|
3082
|
+
this.ui.telInput.focus(), i && this._triggerCountryChange();
|
|
3053
3083
|
}
|
|
3054
3084
|
//* Close the dropdown and unbind any listeners.
|
|
3055
3085
|
_closeDropdown() {
|
|
3056
|
-
this.ui.dropdownContent.classList.contains(h.HIDE) || (this.ui.dropdownContent.classList.add(h.HIDE), this.ui.selectedCountry.setAttribute(
|
|
3086
|
+
this.ui.dropdownContent.classList.contains(h.HIDE) || (this.ui.dropdownContent.classList.add(h.HIDE), this.ui.selectedCountry.setAttribute(p.EXPANDED, "false"), this.ui.highlightedItem && this.ui.highlightedItem.setAttribute(p.SELECTED, "false"), this.options.countrySearch && this.ui.searchInput.removeAttribute(p.ACTIVE_DESCENDANT), this.ui.dropdownArrow.classList.remove(h.ARROW_UP), this.dropdownAbortController.abort(), this.dropdownAbortController = null, this.options.dropdownContainer && this.ui.dropdown.remove(), this._trigger(S.CLOSE_COUNTRY_DROPDOWN));
|
|
3057
3087
|
}
|
|
3058
3088
|
//* Replace any existing dial code with the new one
|
|
3059
3089
|
//* Note: called from _selectListItem and setCountry
|
|
3060
3090
|
_updateDialCode(t) {
|
|
3061
|
-
const e = this.
|
|
3091
|
+
const e = this._getTelInputValue(), i = `+${t}`;
|
|
3062
3092
|
let s;
|
|
3063
3093
|
if (e.startsWith("+")) {
|
|
3064
3094
|
const o = this._getDialCode(e);
|
|
3065
|
-
o ? s = e.replace(o, i) : s = i, this.
|
|
3095
|
+
o ? s = e.replace(o, i) : s = i, this._setTelInputValue(s);
|
|
3066
3096
|
}
|
|
3067
3097
|
}
|
|
3068
3098
|
//* Try and extract a valid international dial code from a full telephone number.
|
|
@@ -3072,9 +3102,9 @@ class U {
|
|
|
3072
3102
|
if (t.startsWith("+")) {
|
|
3073
3103
|
let s = "", o = !1;
|
|
3074
3104
|
for (let n = 0; n < t.length; n++) {
|
|
3075
|
-
const
|
|
3076
|
-
if (/[0-9]/.test(
|
|
3077
|
-
if (s +=
|
|
3105
|
+
const l = t.charAt(n);
|
|
3106
|
+
if (/[0-9]/.test(l)) {
|
|
3107
|
+
if (s += l, !!!this.dialCodeToIso2Map[s])
|
|
3078
3108
|
break;
|
|
3079
3109
|
if (this.dialCodes.has(s)) {
|
|
3080
3110
|
if (i = t.substring(0, n + 1), o = !0, !e)
|
|
@@ -3089,14 +3119,14 @@ class U {
|
|
|
3089
3119
|
}
|
|
3090
3120
|
//* Get the input val, adding the dial code if separateDialCode is enabled.
|
|
3091
3121
|
_getFullNumber(t) {
|
|
3092
|
-
const e = t
|
|
3122
|
+
const e = t ? this._normaliseNumerals(t) : this._getTelInputValue(), { dialCode: i } = this.selectedCountryData;
|
|
3093
3123
|
let s;
|
|
3094
3124
|
const o = v(e);
|
|
3095
3125
|
return this.options.separateDialCode && !e.startsWith("+") && i && o ? s = `+${i}` : s = "", s + e;
|
|
3096
3126
|
}
|
|
3097
3127
|
//* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute
|
|
3098
3128
|
_beforeSetNumber(t) {
|
|
3099
|
-
const e = this._getDialCode(t), i =
|
|
3129
|
+
const e = this._getDialCode(t), i = wt(
|
|
3100
3130
|
t,
|
|
3101
3131
|
e,
|
|
3102
3132
|
this.options.separateDialCode,
|
|
@@ -3106,18 +3136,22 @@ class U {
|
|
|
3106
3136
|
}
|
|
3107
3137
|
//* Trigger the 'countrychange' event.
|
|
3108
3138
|
_triggerCountryChange() {
|
|
3109
|
-
this._trigger(
|
|
3139
|
+
this._trigger(S.COUNTRY_CHANGE);
|
|
3110
3140
|
}
|
|
3111
3141
|
//**************************
|
|
3112
3142
|
//* SECRET PUBLIC METHODS
|
|
3113
3143
|
//**************************
|
|
3114
3144
|
//* This is called when the geoip call returns.
|
|
3115
3145
|
handleAutoCountry() {
|
|
3116
|
-
this.options.initialCountry ===
|
|
3146
|
+
this.options.initialCountry === M.AUTO && u.autoCountry && (this.defaultCountry = u.autoCountry, this.selectedCountryData.iso2 || this.ui.selectedCountryInner.classList.contains(h.GLOBE) || this.setCountry(this.defaultCountry), this.resolveAutoCountryPromise());
|
|
3117
3147
|
}
|
|
3118
3148
|
//* This is called when the utils request completes.
|
|
3119
3149
|
handleUtils() {
|
|
3120
|
-
u.utils
|
|
3150
|
+
if (u.utils) {
|
|
3151
|
+
const t = this._getTelInputValue();
|
|
3152
|
+
t && this._updateValFromNumber(t), this.selectedCountryData.iso2 && (this._updatePlaceholder(), this._updateMaxLength());
|
|
3153
|
+
}
|
|
3154
|
+
this.resolveUtilsScriptPromise();
|
|
3121
3155
|
}
|
|
3122
3156
|
//********************
|
|
3123
3157
|
//* PUBLIC METHODS
|
|
@@ -3136,12 +3170,12 @@ class U {
|
|
|
3136
3170
|
//* Format the number to the given format.
|
|
3137
3171
|
getNumber(t) {
|
|
3138
3172
|
if (u.utils) {
|
|
3139
|
-
const { iso2: e } = this.selectedCountryData
|
|
3140
|
-
|
|
3141
|
-
this._getFullNumber(),
|
|
3173
|
+
const { iso2: e } = this.selectedCountryData, i = this._getFullNumber(), s = u.utils.formatNumber(
|
|
3174
|
+
i,
|
|
3142
3175
|
e,
|
|
3143
3176
|
t
|
|
3144
3177
|
);
|
|
3178
|
+
return this._mapAsciiToUserNumerals(s);
|
|
3145
3179
|
}
|
|
3146
3180
|
return "";
|
|
3147
3181
|
}
|
|
@@ -3150,7 +3184,7 @@ class U {
|
|
|
3150
3184
|
return u.utils ? u.utils.getNumberType(
|
|
3151
3185
|
this._getFullNumber(),
|
|
3152
3186
|
this.selectedCountryData.iso2
|
|
3153
|
-
) :
|
|
3187
|
+
) : $.UNKNOWN_NUMBER_TYPE;
|
|
3154
3188
|
}
|
|
3155
3189
|
//* Get the country data for the currently selected country.
|
|
3156
3190
|
getSelectedCountryData() {
|
|
@@ -3162,14 +3196,14 @@ class U {
|
|
|
3162
3196
|
const { iso2: t } = this.selectedCountryData;
|
|
3163
3197
|
return u.utils.getValidationError(this._getFullNumber(), t);
|
|
3164
3198
|
}
|
|
3165
|
-
return
|
|
3199
|
+
return $.UNKNOWN_VALIDATION_ERROR;
|
|
3166
3200
|
}
|
|
3167
3201
|
//* Validate the input val using number length only
|
|
3168
3202
|
isValidNumber() {
|
|
3169
3203
|
const { dialCode: t, iso2: e } = this.selectedCountryData;
|
|
3170
|
-
if (t ===
|
|
3204
|
+
if (t === k.DIAL_CODE && u.utils) {
|
|
3171
3205
|
const i = this._getFullNumber(), s = u.utils.getCoreNumber(i, e);
|
|
3172
|
-
if (s[0] ===
|
|
3206
|
+
if (s[0] === k.MOBILE_PREFIX && s.length !== k.MOBILE_CORE_LENGTH)
|
|
3173
3207
|
return !1;
|
|
3174
3208
|
}
|
|
3175
3209
|
return this._validateNumber(!1);
|
|
@@ -3191,10 +3225,10 @@ class U {
|
|
|
3191
3225
|
return null;
|
|
3192
3226
|
if (!this.selectedCountryData.iso2)
|
|
3193
3227
|
return !1;
|
|
3194
|
-
const e = (n) => t ? this._utilsIsValidNumber(n) : this._utilsIsPossibleNumber(n), i = this._getFullNumber(), s = i.search(
|
|
3228
|
+
const e = (n) => t ? this._utilsIsValidNumber(n) : this._utilsIsPossibleNumber(n), i = this._getFullNumber(), s = i.search(L.ALPHA_UNICODE);
|
|
3195
3229
|
if (s > -1 && !this.options.allowPhonewords) {
|
|
3196
|
-
const n = i.substring(0, s),
|
|
3197
|
-
return
|
|
3230
|
+
const n = i.substring(0, s), l = e(n), a = e(i);
|
|
3231
|
+
return l && a;
|
|
3198
3232
|
}
|
|
3199
3233
|
return e(i);
|
|
3200
3234
|
}
|
|
@@ -3208,15 +3242,21 @@ class U {
|
|
|
3208
3242
|
//* Update the selected country, and update the input val accordingly.
|
|
3209
3243
|
setCountry(t) {
|
|
3210
3244
|
const e = t == null ? void 0 : t.toLowerCase();
|
|
3211
|
-
if (!
|
|
3245
|
+
if (!B(e))
|
|
3212
3246
|
throw new Error(`Invalid country code: '${e}'`);
|
|
3213
3247
|
const i = this.selectedCountryData.iso2;
|
|
3214
|
-
(t && e !== i || !t && i)
|
|
3248
|
+
if (t && e !== i || !t && i) {
|
|
3249
|
+
if (this._setCountry(e), this._updateDialCode(this.selectedCountryData.dialCode), this.options.formatOnDisplay) {
|
|
3250
|
+
const o = this._getTelInputValue();
|
|
3251
|
+
this._updateValFromNumber(o);
|
|
3252
|
+
}
|
|
3253
|
+
this._triggerCountryChange();
|
|
3254
|
+
}
|
|
3215
3255
|
}
|
|
3216
3256
|
//* Set the input value and update the country.
|
|
3217
3257
|
setNumber(t) {
|
|
3218
|
-
const e = this.
|
|
3219
|
-
this._updateValFromNumber(
|
|
3258
|
+
const e = this._normaliseNumerals(t), i = this._updateCountryFromNumber(e);
|
|
3259
|
+
this._updateValFromNumber(e), i && this._triggerCountryChange(), this._trigger(S.INPUT, { isSetNumber: !0 });
|
|
3220
3260
|
}
|
|
3221
3261
|
//* Set the placeholder number typ
|
|
3222
3262
|
setPlaceholderNumberType(t) {
|
|
@@ -3226,19 +3266,19 @@ class U {
|
|
|
3226
3266
|
this.ui.telInput.disabled = t, t ? this.ui.selectedCountry.setAttribute("disabled", "true") : this.ui.selectedCountry.removeAttribute("disabled");
|
|
3227
3267
|
}
|
|
3228
3268
|
}
|
|
3229
|
-
const
|
|
3269
|
+
const St = (r) => {
|
|
3230
3270
|
if (!u.utils && !u.startedLoadingUtilsScript) {
|
|
3231
3271
|
let t;
|
|
3232
|
-
if (typeof
|
|
3272
|
+
if (typeof r == "function")
|
|
3233
3273
|
try {
|
|
3234
|
-
t = Promise.resolve(
|
|
3274
|
+
t = Promise.resolve(r());
|
|
3235
3275
|
} catch (e) {
|
|
3236
3276
|
return Promise.reject(e);
|
|
3237
3277
|
}
|
|
3238
3278
|
else
|
|
3239
3279
|
return Promise.reject(
|
|
3240
3280
|
new TypeError(
|
|
3241
|
-
`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof
|
|
3281
|
+
`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof r}`
|
|
3242
3282
|
)
|
|
3243
3283
|
);
|
|
3244
3284
|
return u.startedLoadingUtilsScript = !0, t.then((e) => {
|
|
@@ -3247,43 +3287,43 @@ const Lt = (l) => {
|
|
|
3247
3287
|
throw new TypeError(
|
|
3248
3288
|
"The loader function passed to attachUtils did not resolve to a module object with utils as its default export."
|
|
3249
3289
|
);
|
|
3250
|
-
return u.utils = i,
|
|
3290
|
+
return u.utils = i, T("handleUtils"), !0;
|
|
3251
3291
|
}).catch((e) => {
|
|
3252
|
-
throw
|
|
3292
|
+
throw T("rejectUtilsScriptPromise", e), e;
|
|
3253
3293
|
});
|
|
3254
3294
|
}
|
|
3255
3295
|
return null;
|
|
3256
|
-
},
|
|
3296
|
+
}, T = (r, ...t) => {
|
|
3257
3297
|
Object.values(u.instances).forEach((e) => {
|
|
3258
|
-
const i = e[
|
|
3298
|
+
const i = e[r];
|
|
3259
3299
|
typeof i == "function" && i.apply(e, t);
|
|
3260
3300
|
});
|
|
3261
3301
|
}, u = Object.assign(
|
|
3262
|
-
(
|
|
3263
|
-
const e = new
|
|
3264
|
-
return u.instances[e.id] = e,
|
|
3302
|
+
(r, t) => {
|
|
3303
|
+
const e = new V(r, t);
|
|
3304
|
+
return u.instances[e.id] = e, r.iti = e, e;
|
|
3265
3305
|
},
|
|
3266
3306
|
{
|
|
3267
|
-
defaults:
|
|
3307
|
+
defaults: Y,
|
|
3268
3308
|
//* Using a static var like this allows us to mock it in the tests.
|
|
3269
3309
|
documentReady: () => document.readyState === "complete",
|
|
3270
3310
|
//* Get the country data object.
|
|
3271
|
-
getCountryData: () =>
|
|
3311
|
+
getCountryData: () => A,
|
|
3272
3312
|
//* A getter for the plugin instance.
|
|
3273
|
-
getInstance: (
|
|
3274
|
-
const t =
|
|
3313
|
+
getInstance: (r) => {
|
|
3314
|
+
const t = r.dataset.intlTelInputId;
|
|
3275
3315
|
return t ? u.instances[t] : null;
|
|
3276
3316
|
},
|
|
3277
3317
|
//* A map from instance ID to instance object.
|
|
3278
3318
|
instances: {},
|
|
3279
|
-
attachUtils:
|
|
3319
|
+
attachUtils: St,
|
|
3280
3320
|
startedLoadingUtilsScript: !1,
|
|
3281
3321
|
startedLoadingAutoCountry: !1,
|
|
3282
|
-
version: "25.
|
|
3322
|
+
version: "25.13.0"
|
|
3283
3323
|
}
|
|
3284
|
-
),
|
|
3324
|
+
), Ot = {
|
|
3285
3325
|
__name: "IntlTelInput",
|
|
3286
|
-
props: /* @__PURE__ */
|
|
3326
|
+
props: /* @__PURE__ */ W({
|
|
3287
3327
|
disabled: {
|
|
3288
3328
|
type: Boolean,
|
|
3289
3329
|
default: !1
|
|
@@ -3307,47 +3347,47 @@ const Lt = (l) => {
|
|
|
3307
3347
|
},
|
|
3308
3348
|
modelModifiers: {}
|
|
3309
3349
|
}),
|
|
3310
|
-
emits: /* @__PURE__ */
|
|
3350
|
+
emits: /* @__PURE__ */ W([
|
|
3311
3351
|
"changeNumber",
|
|
3312
3352
|
"changeCountry",
|
|
3313
3353
|
"changeValidity",
|
|
3314
3354
|
"changeErrorCode"
|
|
3315
3355
|
], ["update:modelValue"]),
|
|
3316
|
-
setup(
|
|
3317
|
-
const i =
|
|
3318
|
-
let
|
|
3319
|
-
a.value !==
|
|
3356
|
+
setup(r, { expose: t, emit: e }) {
|
|
3357
|
+
const i = Q(r, "modelValue"), s = r, o = e, n = O(), l = O(), a = O(!1), d = () => l.value ? s.options.strictMode ? l.value.isValidNumberPrecise() : l.value.isValidNumber() : null, c = () => {
|
|
3358
|
+
let C = d();
|
|
3359
|
+
a.value !== C && (a.value = C, o("changeValidity", !!C), o(
|
|
3320
3360
|
"changeErrorCode",
|
|
3321
|
-
|
|
3361
|
+
C ? null : l.value.getValidationError()
|
|
3322
3362
|
));
|
|
3323
3363
|
}, f = () => {
|
|
3324
|
-
var
|
|
3325
|
-
o("changeNumber", ((
|
|
3364
|
+
var C;
|
|
3365
|
+
o("changeNumber", ((C = l.value) == null ? void 0 : C.getNumber()) ?? ""), c();
|
|
3326
3366
|
}, b = () => {
|
|
3327
|
-
var
|
|
3328
|
-
o("changeCountry", ((
|
|
3367
|
+
var C;
|
|
3368
|
+
o("changeCountry", ((C = l.value) == null ? void 0 : C.getSelectedCountryData().iso2) ?? ""), f(), c();
|
|
3329
3369
|
};
|
|
3330
|
-
return
|
|
3331
|
-
n.value && (
|
|
3332
|
-
}),
|
|
3370
|
+
return J(() => {
|
|
3371
|
+
n.value && (l.value = u(n.value, s.options), s.value && l.value.setNumber(s.value), s.disabled && l.value.setDisabled(s.disabled), a.value = d());
|
|
3372
|
+
}), Z(
|
|
3333
3373
|
() => s.disabled,
|
|
3334
|
-
(
|
|
3374
|
+
(C) => {
|
|
3335
3375
|
var y;
|
|
3336
|
-
return (y =
|
|
3376
|
+
return (y = l.value) == null ? void 0 : y.setDisabled(C);
|
|
3337
3377
|
}
|
|
3338
|
-
),
|
|
3339
|
-
var
|
|
3340
|
-
return (
|
|
3341
|
-
}), t({ instance:
|
|
3378
|
+
), tt(() => {
|
|
3379
|
+
var C;
|
|
3380
|
+
return (C = l.value) == null ? void 0 : C.destroy();
|
|
3381
|
+
}), t({ instance: l, input: n }), (C, y) => et((st(), it("input", nt({
|
|
3342
3382
|
ref_key: "input",
|
|
3343
3383
|
ref: n,
|
|
3344
|
-
"onUpdate:modelValue": y[0] || (y[0] = (
|
|
3384
|
+
"onUpdate:modelValue": y[0] || (y[0] = (I) => i.value = I),
|
|
3345
3385
|
type: "tel",
|
|
3346
3386
|
onCountrychange: b,
|
|
3347
3387
|
onInput: f
|
|
3348
|
-
},
|
|
3388
|
+
}, r.inputProps), null, 16)), [
|
|
3349
3389
|
[
|
|
3350
|
-
|
|
3390
|
+
ot,
|
|
3351
3391
|
i.value,
|
|
3352
3392
|
void 0,
|
|
3353
3393
|
{ lazy: !0 }
|
|
@@ -3356,5 +3396,5 @@ const Lt = (l) => {
|
|
|
3356
3396
|
}
|
|
3357
3397
|
};
|
|
3358
3398
|
export {
|
|
3359
|
-
|
|
3399
|
+
Ot as default
|
|
3360
3400
|
};
|