intl-tel-input 24.5.2 → 24.6.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 +51 -12
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput.d.ts +10 -4
- package/build/js/intlTelInput.js +59 -24
- package/build/js/intlTelInput.min.js +2 -2
- package/build/js/intlTelInputWithUtils.js +56 -25
- package/build/js/intlTelInputWithUtils.min.js +2 -2
- package/package.json +6 -8
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +58 -23
- package/react/build/IntlTelInput.d.ts +10 -4
- package/react/build/IntlTelInput.js +58 -23
- package/react/build/IntlTelInputWithUtils.cjs +55 -24
- package/react/build/IntlTelInputWithUtils.js +55 -24
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +64 -40
- package/vue/build/IntlTelInputWithUtils.mjs +448 -428
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mergeModels as D, useModel as x, ref as v, onMounted as E, watch as M, onUnmounted as
|
|
1
|
+
import { mergeModels as D, useModel as x, ref as v, onMounted as E, watch as M, onUnmounted as O, withDirectives as F, openBlock as B, createElementBlock as V, mergeProps as z, vModelText as R } from "vue";
|
|
2
2
|
const N = [
|
|
3
3
|
[
|
|
4
4
|
"af",
|
|
@@ -1318,7 +1318,7 @@ for (let u = 0; u < N.length; u++) {
|
|
|
1318
1318
|
nodeById: {}
|
|
1319
1319
|
};
|
|
1320
1320
|
}
|
|
1321
|
-
const
|
|
1321
|
+
const j = {
|
|
1322
1322
|
ad: "Andorra",
|
|
1323
1323
|
ae: "United Arab Emirates",
|
|
1324
1324
|
af: "Afghanistan",
|
|
@@ -1561,7 +1561,7 @@ const $ = {
|
|
|
1561
1561
|
za: "South Africa",
|
|
1562
1562
|
zm: "Zambia",
|
|
1563
1563
|
zw: "Zimbabwe"
|
|
1564
|
-
},
|
|
1564
|
+
}, $ = {
|
|
1565
1565
|
selectedCountryAriaLabel: "Selected country",
|
|
1566
1566
|
noCountrySelected: "No country selected",
|
|
1567
1567
|
countryListAriaLabel: "List of countries",
|
|
@@ -1572,10 +1572,10 @@ const $ = {
|
|
|
1572
1572
|
// additional countries (not supported by country-list library)
|
|
1573
1573
|
ac: "Ascension Island",
|
|
1574
1574
|
xk: "Kosovo"
|
|
1575
|
-
}, k = {
|
|
1575
|
+
}, k = { ...j, ...$ };
|
|
1576
1576
|
for (let u = 0; u < b.length; u++)
|
|
1577
1577
|
b[u].name = k[b[u].iso2];
|
|
1578
|
-
let
|
|
1578
|
+
let U = 0;
|
|
1579
1579
|
const T = {
|
|
1580
1580
|
//* Whether or not to allow the dropdown.
|
|
1581
1581
|
allowDropdown: !0,
|
|
@@ -1607,6 +1607,8 @@ const T = {
|
|
|
1607
1607
|
i18n: {},
|
|
1608
1608
|
//* Initial country.
|
|
1609
1609
|
initialCountry: "",
|
|
1610
|
+
//* Specify the path to the libphonenumber script to enable validation/formatting.
|
|
1611
|
+
loadUtilsOnInit: "",
|
|
1610
1612
|
//* National vs international formatting for numbers e.g. placeholders and displaying existing numbers.
|
|
1611
1613
|
nationalMode: !0,
|
|
1612
1614
|
//* Display only these countries.
|
|
@@ -1627,11 +1629,11 @@ const T = {
|
|
|
1627
1629
|
navigator.userAgent
|
|
1628
1630
|
) || window.innerWidth <= 500
|
|
1629
1631
|
) : !1,
|
|
1630
|
-
//*
|
|
1632
|
+
//* Deprecated! Use `loadUtilsOnInit` instead.
|
|
1631
1633
|
utilsScript: "",
|
|
1632
1634
|
//* The number type to enforce during validation.
|
|
1633
1635
|
validationNumberType: "MOBILE"
|
|
1634
|
-
},
|
|
1636
|
+
}, K = [
|
|
1635
1637
|
"800",
|
|
1636
1638
|
"822",
|
|
1637
1639
|
"833",
|
|
@@ -1649,11 +1651,11 @@ const T = {
|
|
|
1649
1651
|
"887",
|
|
1650
1652
|
"888",
|
|
1651
1653
|
"889"
|
|
1652
|
-
],
|
|
1653
|
-
const t =
|
|
1654
|
+
], I = (u) => u.replace(/\D/g, ""), A = (u = "") => u.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), S = (u) => {
|
|
1655
|
+
const t = I(u);
|
|
1654
1656
|
if (t.charAt(0) === "1") {
|
|
1655
1657
|
const e = t.substr(1, 3);
|
|
1656
|
-
return
|
|
1658
|
+
return K.indexOf(e) !== -1;
|
|
1657
1659
|
}
|
|
1658
1660
|
return !1;
|
|
1659
1661
|
}, H = (u, t, e, i) => {
|
|
@@ -1670,13 +1672,13 @@ const T = {
|
|
|
1670
1672
|
}, y = (u, t, e) => {
|
|
1671
1673
|
const i = document.createElement(u);
|
|
1672
1674
|
return t && Object.entries(t).forEach(([s, n]) => i.setAttribute(s, n)), e && e.appendChild(i), i;
|
|
1673
|
-
}, _ = (u) => {
|
|
1674
|
-
const { instances:
|
|
1675
|
-
Object.values(
|
|
1675
|
+
}, _ = (u, ...t) => {
|
|
1676
|
+
const { instances: e } = l;
|
|
1677
|
+
Object.values(e).forEach((i) => i[u](...t));
|
|
1676
1678
|
};
|
|
1677
1679
|
class G {
|
|
1678
1680
|
constructor(t, e = {}) {
|
|
1679
|
-
this.id =
|
|
1681
|
+
this.id = U++, this.telInput = t, this.highlightedItem = null, this.options = Object.assign({}, T, e), this.hadInitialPlaceholder = !!t.getAttribute("placeholder");
|
|
1680
1682
|
}
|
|
1681
1683
|
//* Can't be private as it's called from intlTelInput convenience wrapper.
|
|
1682
1684
|
_init() {
|
|
@@ -1936,10 +1938,12 @@ class G {
|
|
|
1936
1938
|
}
|
|
1937
1939
|
//* Init many requests: utils script / geo ip lookup.
|
|
1938
1940
|
_initRequests() {
|
|
1939
|
-
|
|
1940
|
-
t &&
|
|
1941
|
-
|
|
1942
|
-
|
|
1941
|
+
let { loadUtilsOnInit: t, utilsScript: e, initialCountry: i, geoIpLookup: s } = this.options;
|
|
1942
|
+
!t && e && (console.warn("intl-tel-input: The `utilsScript` option is deprecated and will be removed in a future release! Please use the `loadUtilsOnInit` option instead."), t = e), t && !l.utils ? (this._handlePageLoad = () => {
|
|
1943
|
+
var o;
|
|
1944
|
+
window.removeEventListener("load", this._handlePageLoad), (o = l.loadUtils(t)) == null || o.catch(() => {
|
|
1945
|
+
});
|
|
1946
|
+
}, l.documentReady() ? this._handlePageLoad() : window.addEventListener("load", this._handlePageLoad)) : this.resolveUtilsScriptPromise(), i === "auto" && s && !this.selectedCountryData.iso2 ? this._loadAutoCountry() : this.resolveAutoCountryPromise();
|
|
1943
1947
|
}
|
|
1944
1948
|
//* Perform the geo ip lookup.
|
|
1945
1949
|
_loadAutoCountry() {
|
|
@@ -1971,8 +1975,8 @@ class G {
|
|
|
1971
1975
|
p || c && !t ? a = !0 : /[^+0-9]/.test(this.telInput.value) || (a = !1);
|
|
1972
1976
|
const d = (r == null ? void 0 : r.detail) && r.detail.isSetNumber && !s;
|
|
1973
1977
|
if (e && !a && !d) {
|
|
1974
|
-
const C = this.telInput.selectionStart || 0, m = this.telInput.value.substring(0, C).replace(/[^+0-9]/g, "").length, f = (r == null ? void 0 : r.inputType) === "deleteContentForward", g = this._formatNumberAsYouType(),
|
|
1975
|
-
this.telInput.value = g, this.telInput.setSelectionRange(
|
|
1978
|
+
const C = this.telInput.selectionStart || 0, m = this.telInput.value.substring(0, C).replace(/[^+0-9]/g, "").length, f = (r == null ? void 0 : r.inputType) === "deleteContentForward", g = this._formatNumberAsYouType(), w = H(m, g, C, f);
|
|
1979
|
+
this.telInput.value = g, this.telInput.setSelectionRange(w, w);
|
|
1976
1980
|
}
|
|
1977
1981
|
}, this.telInput.addEventListener("input", this._handleInputEvent), (t || i) && (this._handleKeydownEvent = (r) => {
|
|
1978
1982
|
if (r.key && r.key.length === 1 && !r.altKey && !r.ctrlKey && !r.metaKey) {
|
|
@@ -1981,13 +1985,13 @@ class G {
|
|
|
1981
1985
|
return;
|
|
1982
1986
|
}
|
|
1983
1987
|
if (t) {
|
|
1984
|
-
const p = this.telInput.value, c = p.charAt(0) === "+", d = !c && this.telInput.selectionStart === 0 && r.key === "+", C = /^[0-9]$/.test(r.key), h = i ? C : d || C, m = p.slice(0, this.telInput.selectionStart) + r.key + p.slice(this.telInput.selectionEnd), f = this._getFullNumber(m), g = l.utils.getCoreNumber(f, this.selectedCountryData.iso2),
|
|
1988
|
+
const p = this.telInput.value, c = p.charAt(0) === "+", d = !c && this.telInput.selectionStart === 0 && r.key === "+", C = /^[0-9]$/.test(r.key), h = i ? C : d || C, m = p.slice(0, this.telInput.selectionStart) + r.key + p.slice(this.telInput.selectionEnd), f = this._getFullNumber(m), g = l.utils.getCoreNumber(f, this.selectedCountryData.iso2), w = this.maxCoreNumberLength && g.length > this.maxCoreNumberLength;
|
|
1985
1989
|
let L = !1;
|
|
1986
1990
|
if (c) {
|
|
1987
1991
|
const P = this.selectedCountryData.iso2;
|
|
1988
1992
|
L = this._getCountryFromNumber(f) !== P;
|
|
1989
1993
|
}
|
|
1990
|
-
(!h ||
|
|
1994
|
+
(!h || w && !L && !d) && r.preventDefault();
|
|
1991
1995
|
}
|
|
1992
1996
|
}
|
|
1993
1997
|
}, this.telInput.addEventListener("keydown", this._handleKeydownEvent));
|
|
@@ -2127,9 +2131,9 @@ class G {
|
|
|
2127
2131
|
let i = e ? t.substring(e) : t;
|
|
2128
2132
|
const s = this.selectedCountryData.dialCode;
|
|
2129
2133
|
i && s === "1" && i.charAt(0) !== "+" && (i.charAt(0) !== "1" && (i = `1${i}`), i = `+${i}`), this.options.separateDialCode && s && i.charAt(0) !== "+" && (i = `+${s}${i}`);
|
|
2130
|
-
const o = this._getDialCode(i, !0), a =
|
|
2134
|
+
const o = this._getDialCode(i, !0), a = I(i);
|
|
2131
2135
|
if (o) {
|
|
2132
|
-
const r = this.dialCodeToIso2Map[
|
|
2136
|
+
const r = this.dialCodeToIso2Map[I(o)], p = r.indexOf(this.selectedCountryData.iso2) !== -1 && a.length <= o.length - 1;
|
|
2133
2137
|
if (!(s === "1" && S(a)) && !p) {
|
|
2134
2138
|
for (let d = 0; d < r.length; d++)
|
|
2135
2139
|
if (r[d])
|
|
@@ -2259,7 +2263,7 @@ class G {
|
|
|
2259
2263
|
), this.countryList.removeEventListener(
|
|
2260
2264
|
"mouseover",
|
|
2261
2265
|
this._handleMouseoverCountryList
|
|
2262
|
-
), this.countryList.removeEventListener("click", this._handleClickCountryList), this.options.dropdownContainer && (this.options.useFullscreenPopup || window.removeEventListener("scroll", this._handleWindowScroll), this.dropdown.parentNode && this.dropdown.parentNode.removeChild(this.dropdown)), this._trigger("close:countrydropdown");
|
|
2266
|
+
), this.countryList.removeEventListener("click", this._handleClickCountryList), this.options.dropdownContainer && (this.options.useFullscreenPopup || window.removeEventListener("scroll", this._handleWindowScroll), this.dropdown.parentNode && this.dropdown.parentNode.removeChild(this.dropdown)), this._handlePageLoad && window.removeEventListener("load", this._handlePageLoad), this._trigger("close:countrydropdown");
|
|
2263
2267
|
}
|
|
2264
2268
|
//* Check if an element is visible within it's container, else scroll until it is.
|
|
2265
2269
|
_scrollTo(t) {
|
|
@@ -2307,7 +2311,7 @@ class G {
|
|
|
2307
2311
|
_getFullNumber(t) {
|
|
2308
2312
|
const e = t || this.telInput.value.trim(), { dialCode: i } = this.selectedCountryData;
|
|
2309
2313
|
let s;
|
|
2310
|
-
const n =
|
|
2314
|
+
const n = I(e);
|
|
2311
2315
|
return this.options.separateDialCode && e.charAt(0) !== "+" && i && n ? s = `+${i}` : s = "", s + e;
|
|
2312
2316
|
}
|
|
2313
2317
|
//* Remove the dial code if separateDialCode is enabled also cap the length if the input has a maxlength attribute
|
|
@@ -2450,17 +2454,35 @@ class G {
|
|
|
2450
2454
|
this.telInput.disabled = t, t ? this.selectedCountry.setAttribute("disabled", "true") : this.selectedCountry.removeAttribute("disabled");
|
|
2451
2455
|
}
|
|
2452
2456
|
}
|
|
2453
|
-
const W = (u) =>
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2457
|
+
const W = (u) => {
|
|
2458
|
+
if (!l.utils && !l.startedLoadingUtilsScript) {
|
|
2459
|
+
let t;
|
|
2460
|
+
if (typeof u == "string")
|
|
2461
|
+
t = import(
|
|
2462
|
+
/* webpackIgnore: true */
|
|
2463
|
+
/* @vite-ignore */
|
|
2464
|
+
u
|
|
2465
|
+
);
|
|
2466
|
+
else if (typeof u == "function")
|
|
2467
|
+
try {
|
|
2468
|
+
if (t = u(), !(t instanceof Promise))
|
|
2469
|
+
throw new TypeError(`The function passed to loadUtils must return a promise for the utilities module, not ${typeof t}`);
|
|
2470
|
+
} catch (e) {
|
|
2471
|
+
return Promise.reject(e);
|
|
2472
|
+
}
|
|
2473
|
+
else
|
|
2474
|
+
return Promise.reject(new TypeError(`The argument passed to loadUtils must be a URL string or a function that returns a promise for the utilities module, not ${typeof u}`));
|
|
2475
|
+
return l.startedLoadingUtilsScript = !0, t.then((e) => {
|
|
2476
|
+
const i = e == null ? void 0 : e.default;
|
|
2477
|
+
if (!i || typeof i != "object")
|
|
2478
|
+
throw typeof u == "string" ? new TypeError(`The module loaded from ${u} did not set utils as its default export.`) : new TypeError("The loader function passed to loadUtils did not resolve to a module object with utils as its default export.");
|
|
2479
|
+
return l.utils = i, _("handleUtils"), !0;
|
|
2480
|
+
}).catch((e) => {
|
|
2481
|
+
throw _("rejectUtilsScriptPromise", e), e;
|
|
2482
|
+
});
|
|
2483
|
+
}
|
|
2484
|
+
return null;
|
|
2485
|
+
}, l = Object.assign(
|
|
2464
2486
|
(u, t) => {
|
|
2465
2487
|
const e = new G(u, t);
|
|
2466
2488
|
return e._init(), u.setAttribute("data-intl-tel-input-id", e.id.toString()), l.instances[e.id] = e, e;
|
|
@@ -2479,7 +2501,9 @@ const W = (u) => !l.utils && !l.startedLoadingUtilsScript ? (l.startedLoadingUti
|
|
|
2479
2501
|
//* A map from instance ID to instance object.
|
|
2480
2502
|
instances: {},
|
|
2481
2503
|
loadUtils: W,
|
|
2482
|
-
|
|
2504
|
+
startedLoadingUtilsScript: !1,
|
|
2505
|
+
startedLoadingAutoCountry: !1,
|
|
2506
|
+
version: "24.6.0"
|
|
2483
2507
|
}
|
|
2484
2508
|
), J = {
|
|
2485
2509
|
__name: "IntlTelInput",
|
|
@@ -2535,10 +2559,10 @@ const W = (u) => !l.utils && !l.startedLoadingUtilsScript ? (l.startedLoadingUti
|
|
|
2535
2559
|
var m;
|
|
2536
2560
|
return (m = a.value) == null ? void 0 : m.setDisabled(h);
|
|
2537
2561
|
}
|
|
2538
|
-
),
|
|
2562
|
+
), O(() => {
|
|
2539
2563
|
var h;
|
|
2540
2564
|
return (h = a.value) == null ? void 0 : h.destroy();
|
|
2541
|
-
}), t({ instance: a, input: o }), (h, m) =>
|
|
2565
|
+
}), t({ instance: a, input: o }), (h, m) => F((B(), V("input", z({
|
|
2542
2566
|
ref_key: "input",
|
|
2543
2567
|
ref: o,
|
|
2544
2568
|
"onUpdate:modelValue": m[0] || (m[0] = (f) => i.value = f),
|