intl-tel-input 27.3.0 → 27.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/angular/dist/IntlTelInput.js +114 -80
- package/angular/dist/IntlTelInputWithUtils.js +114 -80
- package/dist/js/data.d.ts +1 -4
- package/dist/js/data.js +2 -8
- package/dist/js/data.min.js +2 -2
- package/dist/js/data.mjs +1 -7
- package/dist/js/intlTelInput.d.ts +1 -4
- package/dist/js/intlTelInput.js +115 -81
- package/dist/js/intlTelInput.min.js +3 -3
- package/dist/js/intlTelInput.mjs +114 -80
- package/dist/js/intlTelInputWithUtils.js +115 -81
- package/dist/js/intlTelInputWithUtils.min.js +8 -8
- package/dist/js/intlTelInputWithUtils.mjs +114 -80
- package/package.json +1 -1
- package/react/dist/IntlTelInput.js +114 -80
- package/react/dist/IntlTelInputWithUtils.js +114 -80
- package/vue/dist/{IntlTelInput-jw1tkqdD.js → IntlTelInput-DWpqqgvZ.js} +405 -378
- package/vue/dist/IntlTelInput.js +1 -1
- package/vue/dist/IntlTelInputWithUtils.js +1 -1
|
@@ -1180,10 +1180,7 @@ for (let e of d) f.push({
|
|
|
1180
1180
|
dialCode: e[1],
|
|
1181
1181
|
priority: e[2] || 0,
|
|
1182
1182
|
areaCodes: e[3] || null,
|
|
1183
|
-
nationalPrefix: e[4] || null
|
|
1184
|
-
normalisedName: "",
|
|
1185
|
-
initials: "",
|
|
1186
|
-
dialCodePlus: ""
|
|
1183
|
+
nationalPrefix: e[4] || null
|
|
1187
1184
|
});
|
|
1188
1185
|
var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
1189
1186
|
OPEN_COUNTRY_DROPDOWN: "open:countrydropdown",
|
|
@@ -1484,30 +1481,69 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
1484
1481
|
}, se = () => `
|
|
1485
1482
|
<svg class="iti__country-check-svg" width="14" height="14" viewBox="0 0 16 16" fill="currentColor" focusable="false" ${j.HIDDEN}="true">
|
|
1486
1483
|
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0m-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z"/>
|
|
1487
|
-
</svg>`, K = () => "\n <svg width=\"256\" height=\"256\" viewBox=\"0 0 512 512\" class=\"iti__globe-svg\">\n <path d=\"M508 213a240 240 0 0 0-449-87l-2 5-2 5c-8 14-13 30-17 46a65 65 0 0 1 56 4c16-10 35-19 56-27l9-3c-6 23-10 48-10 74h-16l4 6c3 4 5 8 6 13h6c0 22 3 44 8 65l2 10-25-10-4 5 12 18 9 3 6 2 8 3 9 26 1 2 16-7h1l-5-13-1-2c24 6 49 9 75 10v26l11 10 7 7v-30l1-13c22 0 44-3 65-8l10-2-21 48-1 1a317 317 0 0 1-14 23l-21 5h-2c6 16 7 33 1 50a240 240 0 0 0 211-265m-401-56-11 6c19-44 54-79 98-98-11 20-21 44-29 69-21 6-40 15-58 23m154 182v4c-29-1-57-6-81-13-7-25-12-52-13-81h94zm0-109h-94c1-29 6-56 13-81 24-7 52-12 81-13zm0-112c-22 1-44 4-65 8l-10 2 12-30 9-17 1-2a332 332 0 0 1 13-23c13-4 26-6 40-7zm187 69 6 4c4 12 6 25 6 38v1h-68c-1-26-4-51-10-74l48 20 1 1 14 8zm-14-44 10 20c-20-11-43-21-68-29-8-25-18-49-29-69 37 16 67 44 87 78M279 49h1c13 1 27 3 39 7l14 23 1 2a343 343 0 0 1 12 26l2 5 6 16c-23-6-48-9-74-10h-1zm0 87h1c29 1 56 6 81 13 7 24 12 51 12 80v1h-94zm2 207h-2v-94h95c-1 29-6 56-13 81-24 7-51 12-80 13m86 60-20 10c11-20 21-43 29-68 25-8 48-18 68-29-16 37-43 67-77 87m87-115-7 5-16 9-2 1a337 337 0 0 1-47 21c6-24 9-49 10-75h68c0 13-2 27-6 39\"/>\n <path d=\"m261 428-2-2-22-21a40 40 0 0 0-32-11h-1a37 37 0 0 0-18 8l-1 1-4 2-2 2-5 4c-9-3-36-31-47-44s-32-45-34-55l3-2a151 151 0 0 0 11-9v-1a39 39 0 0 0 5-48l-3-3-11-19-3-4-5-7h-1l-3-3-4-3-5-2a35 35 0 0 0-16-3h-5c-4 1-14 5-24 11l-4 2-4 3-4 2c-9 8-17 17-18 27a380 380 0 0 0 212 259h3c12 0 25-10 36-21l10-12 6-11a39 39 0 0 0-8-40\"/>\n </svg>", ce = (e
|
|
1488
|
-
let
|
|
1489
|
-
for (let
|
|
1490
|
-
|
|
1484
|
+
</svg>`, K = () => "\n <svg width=\"256\" height=\"256\" viewBox=\"0 0 512 512\" class=\"iti__globe-svg\">\n <path d=\"M508 213a240 240 0 0 0-449-87l-2 5-2 5c-8 14-13 30-17 46a65 65 0 0 1 56 4c16-10 35-19 56-27l9-3c-6 23-10 48-10 74h-16l4 6c3 4 5 8 6 13h6c0 22 3 44 8 65l2 10-25-10-4 5 12 18 9 3 6 2 8 3 9 26 1 2 16-7h1l-5-13-1-2c24 6 49 9 75 10v26l11 10 7 7v-30l1-13c22 0 44-3 65-8l10-2-21 48-1 1a317 317 0 0 1-14 23l-21 5h-2c6 16 7 33 1 50a240 240 0 0 0 211-265m-401-56-11 6c19-44 54-79 98-98-11 20-21 44-29 69-21 6-40 15-58 23m154 182v4c-29-1-57-6-81-13-7-25-12-52-13-81h94zm0-109h-94c1-29 6-56 13-81 24-7 52-12 81-13zm0-112c-22 1-44 4-65 8l-10 2 12-30 9-17 1-2a332 332 0 0 1 13-23c13-4 26-6 40-7zm187 69 6 4c4 12 6 25 6 38v1h-68c-1-26-4-51-10-74l48 20 1 1 14 8zm-14-44 10 20c-20-11-43-21-68-29-8-25-18-49-29-69 37 16 67 44 87 78M279 49h1c13 1 27 3 39 7l14 23 1 2a343 343 0 0 1 12 26l2 5 6 16c-23-6-48-9-74-10h-1zm0 87h1c29 1 56 6 81 13 7 24 12 51 12 80v1h-94zm2 207h-2v-94h95c-1 29-6 56-13 81-24 7-51 12-80 13m86 60-20 10c11-20 21-43 29-68 25-8 48-18 68-29-16 37-43 67-77 87m87-115-7 5-16 9-2 1a337 337 0 0 1-47 21c6-24 9-49 10-75h68c0 13-2 27-6 39\"/>\n <path d=\"m261 428-2-2-22-21a40 40 0 0 0-32-11h-1a37 37 0 0 0-18 8l-1 1-4 2-2 2-5 4c-9-3-36-31-47-44s-32-45-34-55l3-2a151 151 0 0 0 11-9v-1a39 39 0 0 0 5-48l-3-3-11-19-3-4-5-7h-1l-3-3-4-3-5-2a35 35 0 0 0-16-3h-5c-4 1-14 5-24 11l-4 2-4 3-4 2c-9 8-17 17-18 27a380 380 0 0 0 212 259h3c12 0 25-10 36-21l10-12 6-11a39 39 0 0 0-8-40\"/>\n </svg>", ce = (e) => {
|
|
1485
|
+
let t = /* @__PURE__ */ new Map();
|
|
1486
|
+
for (let n of e) {
|
|
1487
|
+
let e = U(n.name), r = e.split(/[^a-z]/).map((e) => e[0]).join("");
|
|
1488
|
+
t.set(n.iso2, {
|
|
1489
|
+
normalisedName: e,
|
|
1490
|
+
initials: r,
|
|
1491
|
+
dialCodePlus: `+${n.dialCode}`
|
|
1492
|
+
});
|
|
1493
|
+
}
|
|
1494
|
+
return t;
|
|
1495
|
+
}, le = (e, t, n) => {
|
|
1496
|
+
let r = U(n), i = [], a = [], o = [], s = [], c = [], l = [];
|
|
1497
|
+
for (let n of e) {
|
|
1498
|
+
let e = t.get(n.iso2);
|
|
1499
|
+
n.iso2 === r ? i.push(n) : e.normalisedName.startsWith(r) ? a.push(n) : e.normalisedName.includes(r) ? o.push(n) : r === n.dialCode || r === e.dialCodePlus ? s.push(n) : e.dialCodePlus.includes(r) ? c.push(n) : e.initials.includes(r) && l.push(n);
|
|
1500
|
+
}
|
|
1501
|
+
let u = (e, t) => e.priority - t.priority;
|
|
1491
1502
|
return [
|
|
1492
|
-
...r,
|
|
1493
1503
|
...i,
|
|
1494
1504
|
...a,
|
|
1495
|
-
...o
|
|
1496
|
-
...s.sort(
|
|
1497
|
-
...c
|
|
1505
|
+
...o,
|
|
1506
|
+
...s.sort(u),
|
|
1507
|
+
...c.sort(u),
|
|
1508
|
+
...l
|
|
1498
1509
|
];
|
|
1499
|
-
},
|
|
1500
|
-
let
|
|
1501
|
-
for (let
|
|
1510
|
+
}, ue = (e, t, n) => {
|
|
1511
|
+
let r = U(n);
|
|
1512
|
+
for (let n of e) {
|
|
1513
|
+
let { normalisedName: e } = t.get(n.iso2);
|
|
1514
|
+
if (e.startsWith(r)) return n;
|
|
1515
|
+
}
|
|
1502
1516
|
return null;
|
|
1503
1517
|
}, q = class e {
|
|
1518
|
+
#e;
|
|
1519
|
+
static toAscii(e) {
|
|
1520
|
+
return e ? e.replace(/[٠-٩]/g, (e) => String.fromCharCode(48 + (e.charCodeAt(0) - 1632))).replace(/[۰-۹]/g, (e) => String.fromCharCode(48 + (e.charCodeAt(0) - 1776))) : "";
|
|
1521
|
+
}
|
|
1522
|
+
constructor(e) {
|
|
1523
|
+
e && this.#t(e);
|
|
1524
|
+
}
|
|
1525
|
+
#t(e) {
|
|
1526
|
+
/[٠-٩]/.test(e) ? this.#e = "arabic-indic" : /[۰-۹]/.test(e) ? this.#e = "persian" : this.#e = "ascii";
|
|
1527
|
+
}
|
|
1528
|
+
denormalise(e) {
|
|
1529
|
+
if (!this.#e || this.#e === "ascii") return e;
|
|
1530
|
+
let t = this.#e === "arabic-indic" ? 1632 : 1776;
|
|
1531
|
+
return e.replace(/[0-9]/g, (e) => String.fromCharCode(t + Number(e)));
|
|
1532
|
+
}
|
|
1533
|
+
normalise(t) {
|
|
1534
|
+
return t ? (this.#t(t), this.#e === "ascii" ? t : e.toAscii(t)) : "";
|
|
1535
|
+
}
|
|
1536
|
+
isAscii() {
|
|
1537
|
+
return !this.#e || this.#e === "ascii";
|
|
1538
|
+
}
|
|
1539
|
+
}, J = class e {
|
|
1504
1540
|
#e;
|
|
1505
1541
|
#t;
|
|
1506
1542
|
#n;
|
|
1507
1543
|
#r = "";
|
|
1508
1544
|
#i;
|
|
1509
|
-
#a
|
|
1510
|
-
#o;
|
|
1545
|
+
#a;
|
|
1546
|
+
#o = null;
|
|
1511
1547
|
#s;
|
|
1512
1548
|
#c;
|
|
1513
1549
|
#l;
|
|
@@ -1523,10 +1559,11 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
1523
1559
|
#y;
|
|
1524
1560
|
#b;
|
|
1525
1561
|
#x;
|
|
1526
|
-
#S
|
|
1562
|
+
#S;
|
|
1527
1563
|
#C = null;
|
|
1528
|
-
#w =
|
|
1529
|
-
#T =
|
|
1564
|
+
#w = null;
|
|
1565
|
+
#T = /* @__PURE__ */ new Map();
|
|
1566
|
+
#E = null;
|
|
1530
1567
|
telInputEl;
|
|
1531
1568
|
hadInitialPlaceholder;
|
|
1532
1569
|
constructor(e, t, n) {
|
|
@@ -1539,12 +1576,12 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
1539
1576
|
throw TypeError(`The first argument must be an HTMLInputElement, not ${t}`);
|
|
1540
1577
|
}
|
|
1541
1578
|
}
|
|
1542
|
-
buildMarkup(e) {
|
|
1543
|
-
this.#i = e, this.telInputEl.classList.add("iti__tel-input"), this.telInputEl.hasAttribute("type") || this.telInputEl.setAttribute("type", "tel"), this.telInputEl.hasAttribute("autocomplete") || this.telInputEl.setAttribute("autocomplete", "tel"), this.telInputEl.hasAttribute("inputmode") || this.telInputEl.setAttribute("inputmode", "tel");
|
|
1544
|
-
let
|
|
1545
|
-
this.#
|
|
1579
|
+
buildMarkup(e, t) {
|
|
1580
|
+
this.#i = e, this.#a = t, this.telInputEl.classList.add("iti__tel-input"), this.telInputEl.hasAttribute("type") || this.telInputEl.setAttribute("type", "tel"), this.telInputEl.hasAttribute("autocomplete") || this.telInputEl.setAttribute("autocomplete", "tel"), this.telInputEl.hasAttribute("inputmode") || this.telInputEl.setAttribute("inputmode", "tel");
|
|
1581
|
+
let n = this.#D();
|
|
1582
|
+
this.#O(n), n.appendChild(this.telInputEl), this.#j(), this.#M(n), this.ensureDropdownWidthSet();
|
|
1546
1583
|
}
|
|
1547
|
-
#
|
|
1584
|
+
#D() {
|
|
1548
1585
|
let { allowDropdown: e, showFlags: t, containerClass: n, useFullscreenPopup: r } = this.#e, i = G("div", { class: W({
|
|
1549
1586
|
iti: !0,
|
|
1550
1587
|
"iti--allow-dropdown": e,
|
|
@@ -1554,55 +1591,55 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
1554
1591
|
}) });
|
|
1555
1592
|
return this.#n && i.setAttribute("dir", "ltr"), this.telInputEl.before(i), i;
|
|
1556
1593
|
}
|
|
1557
|
-
#
|
|
1594
|
+
#O(e) {
|
|
1558
1595
|
let { allowDropdown: t, separateDialCode: n, showFlags: r } = this.#e;
|
|
1559
1596
|
if (!t && !r && !n) return;
|
|
1560
|
-
this.#
|
|
1597
|
+
this.#c = G("div", { class: `iti__country-container ${_.V_HIDE}` }, e), t ? (this.#l = G("button", {
|
|
1561
1598
|
type: "button",
|
|
1562
1599
|
class: "iti__selected-country",
|
|
1563
1600
|
[j.EXPANDED]: "false",
|
|
1564
1601
|
[j.LABEL]: this.#e.i18n.noCountrySelected,
|
|
1565
1602
|
[j.HASPOPUP]: "dialog",
|
|
1566
1603
|
[j.CONTROLS]: `iti-${this.#t}__dropdown-content`
|
|
1567
|
-
}, this.#
|
|
1568
|
-
let i = G("div", { class: "iti__selected-country-primary" }, this.#
|
|
1569
|
-
this.#
|
|
1604
|
+
}, this.#c), this.telInputEl.disabled && this.#l.setAttribute("disabled", "true")) : this.#l = G("div", { class: "iti__selected-country" }, this.#c);
|
|
1605
|
+
let i = G("div", { class: "iti__selected-country-primary" }, this.#l);
|
|
1606
|
+
this.#u = G("div", { class: _.FLAG }, i), t && (this.#f = G("div", {
|
|
1570
1607
|
class: "iti__arrow",
|
|
1571
1608
|
[j.HIDDEN]: "true"
|
|
1572
|
-
}, i)), n && (this.#
|
|
1609
|
+
}, i)), n && (this.#d = G("div", { class: "iti__selected-dial-code" }, this.#l)), t && this.#k();
|
|
1573
1610
|
}
|
|
1574
1611
|
ensureDropdownWidthSet() {
|
|
1575
1612
|
let { fixDropdownWidth: e, allowDropdown: t } = this.#e;
|
|
1576
|
-
if (!t || !e || this.#
|
|
1613
|
+
if (!t || !e || this.#p.style.width) return;
|
|
1577
1614
|
let n = this.telInputEl.offsetWidth;
|
|
1578
|
-
n > 0 && (this.#
|
|
1615
|
+
n > 0 && (this.#p.style.width = `${n}px`);
|
|
1579
1616
|
}
|
|
1580
|
-
#
|
|
1617
|
+
#k() {
|
|
1581
1618
|
let { fixDropdownWidth: e, useFullscreenPopup: t, countrySearch: n, i18n: r, dropdownContainer: i, containerClass: a } = this.#e, o = e ? "" : "iti--flexible-dropdown-width";
|
|
1582
|
-
this.#
|
|
1619
|
+
this.#p = G("div", {
|
|
1583
1620
|
id: `iti-${this.#t}__dropdown-content`,
|
|
1584
1621
|
class: `iti__dropdown-content ${_.HIDE} ${o}`,
|
|
1585
1622
|
role: "dialog",
|
|
1586
1623
|
[j.MODAL]: "true"
|
|
1587
|
-
}), this.#n && this.#
|
|
1624
|
+
}), this.#n && this.#p.setAttribute("dir", "rtl"), n && this.#A(), this.#_ = G("ul", {
|
|
1588
1625
|
class: "iti__country-list",
|
|
1589
1626
|
id: `iti-${this.#t}__country-listbox`,
|
|
1590
1627
|
role: "listbox",
|
|
1591
1628
|
[j.LABEL]: r.countryListAriaLabel
|
|
1592
|
-
}, this.#
|
|
1629
|
+
}, this.#p), this.#N(), n && this.#R(), t || (this.#s = this.#L(), n && (this.#p.style.height = `${this.#s}px`)), i ? (this.#S = G("div", { class: W({
|
|
1593
1630
|
iti: !0,
|
|
1594
1631
|
"iti--container": !0,
|
|
1595
1632
|
"iti--fullscreen-popup": t,
|
|
1596
1633
|
"iti--inline-dropdown": !t,
|
|
1597
1634
|
[a]: !!a
|
|
1598
|
-
}) }), this.#
|
|
1635
|
+
}) }), this.#S.appendChild(this.#p)) : this.#c.appendChild(this.#p);
|
|
1599
1636
|
}
|
|
1600
|
-
#
|
|
1601
|
-
let { i18n: e, searchInputClass: t } = this.#e, n = G("div", { class: "iti__search-input-wrapper" }, this.#
|
|
1602
|
-
this.#
|
|
1637
|
+
#A() {
|
|
1638
|
+
let { i18n: e, searchInputClass: t } = this.#e, n = G("div", { class: "iti__search-input-wrapper" }, this.#p);
|
|
1639
|
+
this.#m = G("span", {
|
|
1603
1640
|
class: "iti__search-icon",
|
|
1604
1641
|
[j.HIDDEN]: "true"
|
|
1605
|
-
}, n), this.#
|
|
1642
|
+
}, n), this.#m.innerHTML = ae(), this.#h = G("input", {
|
|
1606
1643
|
id: `iti-${this.#t}__search-input`,
|
|
1607
1644
|
type: "search",
|
|
1608
1645
|
class: `iti__search-input ${t}`,
|
|
@@ -1613,39 +1650,39 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
1613
1650
|
[j.CONTROLS]: `iti-${this.#t}__country-listbox`,
|
|
1614
1651
|
[j.AUTOCOMPLETE]: "list",
|
|
1615
1652
|
autocomplete: "off"
|
|
1616
|
-
}, n), this.#
|
|
1653
|
+
}, n), this.#g = G("button", {
|
|
1617
1654
|
type: "button",
|
|
1618
1655
|
class: `iti__search-clear ${_.HIDE}`,
|
|
1619
1656
|
[j.LABEL]: e.clearSearchAriaLabel,
|
|
1620
1657
|
tabindex: "-1"
|
|
1621
|
-
}, n), this.#
|
|
1658
|
+
}, n), this.#g.innerHTML = oe(this.#t), this.#x = G("span", { class: "iti__a11y-text" }, this.#p), this.#b = G("div", {
|
|
1622
1659
|
class: `iti__no-results ${_.HIDE}`,
|
|
1623
1660
|
[j.HIDDEN]: "true"
|
|
1624
|
-
}, this.#
|
|
1661
|
+
}, this.#p), this.#b.textContent = e.searchEmptyState ?? null;
|
|
1625
1662
|
}
|
|
1626
|
-
#
|
|
1627
|
-
this.#
|
|
1663
|
+
#j() {
|
|
1664
|
+
this.#c && (this.#P(), this.#c.classList.remove(_.V_HIDE));
|
|
1628
1665
|
}
|
|
1629
|
-
#
|
|
1666
|
+
#M(e) {
|
|
1630
1667
|
let { hiddenInput: t } = this.#e;
|
|
1631
1668
|
if (!t) return;
|
|
1632
1669
|
let n = t(this.telInputEl.getAttribute("name") || "");
|
|
1633
1670
|
if (n.phone) {
|
|
1634
1671
|
let t = this.telInputEl.form?.querySelector(`input[name="${n.phone}"]`);
|
|
1635
|
-
t ? this.#
|
|
1672
|
+
t ? this.#v = t : (this.#v = G("input", {
|
|
1636
1673
|
type: "hidden",
|
|
1637
1674
|
name: n.phone
|
|
1638
|
-
}), e.appendChild(this.#
|
|
1675
|
+
}), e.appendChild(this.#v));
|
|
1639
1676
|
}
|
|
1640
1677
|
if (n.country) {
|
|
1641
1678
|
let t = this.telInputEl.form?.querySelector(`input[name="${n.country}"]`);
|
|
1642
|
-
t ? this.#
|
|
1679
|
+
t ? this.#y = t : (this.#y = G("input", {
|
|
1643
1680
|
type: "hidden",
|
|
1644
1681
|
name: n.country
|
|
1645
|
-
}), e.appendChild(this.#
|
|
1682
|
+
}), e.appendChild(this.#y));
|
|
1646
1683
|
}
|
|
1647
1684
|
}
|
|
1648
|
-
#
|
|
1685
|
+
#N() {
|
|
1649
1686
|
let e = document.createDocumentFragment();
|
|
1650
1687
|
for (let t = 0; t < this.#i.length; t++) {
|
|
1651
1688
|
let n = this.#i[t], r = W({ [_.COUNTRY_ITEM]: !0 }), i = G("li", {
|
|
@@ -1655,21 +1692,21 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
1655
1692
|
role: "option",
|
|
1656
1693
|
[j.SELECTED]: "false"
|
|
1657
1694
|
});
|
|
1658
|
-
i.dataset[A.DIAL_CODE] = n.dialCode, i.dataset[A.ISO2] = n.iso2, this.#
|
|
1695
|
+
i.dataset[A.DIAL_CODE] = n.dialCode, i.dataset[A.ISO2] = n.iso2, this.#T.set(n.iso2, i), this.#e.showFlags && G("div", { class: `${_.FLAG} iti__${n.iso2}` }, i);
|
|
1659
1696
|
let a = G("span", { class: "iti__country-name" }, i);
|
|
1660
1697
|
a.textContent = `${n.name} `;
|
|
1661
1698
|
let o = G("span", { class: "iti__dial-code" }, a);
|
|
1662
1699
|
this.#n && o.setAttribute("dir", "ltr"), o.textContent = `(+${n.dialCode})`, e.appendChild(i);
|
|
1663
1700
|
}
|
|
1664
|
-
this.#
|
|
1701
|
+
this.#_.appendChild(e);
|
|
1665
1702
|
}
|
|
1666
|
-
#
|
|
1667
|
-
if (this.#
|
|
1668
|
-
let e = this.#e.separateDialCode ? C.FALLBACK_SELECTED_WITH_DIAL_WIDTH : C.FALLBACK_SELECTED_NO_DIAL_WIDTH, t = (this.#
|
|
1703
|
+
#P() {
|
|
1704
|
+
if (this.#l) {
|
|
1705
|
+
let e = this.#e.separateDialCode ? C.FALLBACK_SELECTED_WITH_DIAL_WIDTH : C.FALLBACK_SELECTED_NO_DIAL_WIDTH, t = (this.#l.offsetWidth || this.#I() || e) + C.INPUT_PADDING_EXTRA_LEFT;
|
|
1669
1706
|
this.telInputEl.style.paddingLeft = `${t}px`;
|
|
1670
1707
|
}
|
|
1671
1708
|
}
|
|
1672
|
-
static #
|
|
1709
|
+
static #F() {
|
|
1673
1710
|
let e;
|
|
1674
1711
|
try {
|
|
1675
1712
|
e = window.top.document.body;
|
|
@@ -1678,74 +1715,79 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
1678
1715
|
}
|
|
1679
1716
|
return e;
|
|
1680
1717
|
}
|
|
1681
|
-
#
|
|
1718
|
+
#I() {
|
|
1682
1719
|
if (!this.telInputEl.parentNode) return 0;
|
|
1683
|
-
let t = e.#
|
|
1720
|
+
let t = e.#F(), n = this.telInputEl.parentNode.cloneNode(!1);
|
|
1684
1721
|
n.style.visibility = "hidden", t.appendChild(n);
|
|
1685
|
-
let r = this.#
|
|
1722
|
+
let r = this.#c.cloneNode();
|
|
1686
1723
|
n.appendChild(r);
|
|
1687
|
-
let i = this.#
|
|
1724
|
+
let i = this.#l.cloneNode(!0);
|
|
1688
1725
|
r.appendChild(i);
|
|
1689
1726
|
let a = i.offsetWidth;
|
|
1690
1727
|
return t.removeChild(n), a;
|
|
1691
1728
|
}
|
|
1692
|
-
#
|
|
1693
|
-
let t = e.#
|
|
1694
|
-
this.#
|
|
1729
|
+
#L() {
|
|
1730
|
+
let t = e.#F();
|
|
1731
|
+
this.#p.classList.remove(_.HIDE);
|
|
1695
1732
|
let n = G("div", { class: "iti iti--inline-dropdown" });
|
|
1696
|
-
n.appendChild(this.#
|
|
1697
|
-
let r = this.#
|
|
1698
|
-
return t.removeChild(n), n.style.visibility = "", this.#
|
|
1733
|
+
n.appendChild(this.#p), n.style.visibility = "hidden", t.appendChild(n);
|
|
1734
|
+
let r = this.#p.offsetHeight;
|
|
1735
|
+
return t.removeChild(n), n.style.visibility = "", this.#p.classList.add(_.HIDE), r > 0 ? r : C.FALLBACK_DROPDOWN_HEIGHT;
|
|
1699
1736
|
}
|
|
1700
|
-
#
|
|
1701
|
-
let { i18n: e } = this.#e, t = this.#
|
|
1702
|
-
this.#
|
|
1737
|
+
#R() {
|
|
1738
|
+
let { i18n: e } = this.#e, t = this.#_.childElementCount;
|
|
1739
|
+
this.#x.textContent = e.searchSummaryAria(t);
|
|
1703
1740
|
}
|
|
1704
|
-
#
|
|
1741
|
+
#z(e) {
|
|
1705
1742
|
let t;
|
|
1706
|
-
|
|
1743
|
+
if (e === "") t = this.#i;
|
|
1744
|
+
else {
|
|
1745
|
+
let n = q.toAscii(e);
|
|
1746
|
+
t = le(this.#i, this.#a, n);
|
|
1747
|
+
}
|
|
1748
|
+
this.#ee(t);
|
|
1707
1749
|
}
|
|
1708
1750
|
prefillSearchWithPlus() {
|
|
1709
|
-
this.#
|
|
1710
|
-
}
|
|
1711
|
-
#z() {
|
|
1712
|
-
let e = this.#m.value.trim();
|
|
1713
|
-
this.#R(e), this.#m.value ? this.#h.classList.remove(_.HIDE) : this.#h.classList.add(_.HIDE);
|
|
1751
|
+
this.#h.value = "+", this.#h.focus(), this.#z("");
|
|
1714
1752
|
}
|
|
1715
1753
|
#B() {
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
}, x.SEARCH_DEBOUNCE_MS);
|
|
1754
|
+
let e = this.#h.value.trim();
|
|
1755
|
+
this.#z(e), this.#h.value ? this.#g.classList.remove(_.HIDE) : this.#g.classList.add(_.HIDE);
|
|
1719
1756
|
}
|
|
1720
1757
|
#V() {
|
|
1721
|
-
this.#
|
|
1758
|
+
this.#o && clearTimeout(this.#o), this.#o = setTimeout(() => {
|
|
1759
|
+
this.#B(), this.#o = null;
|
|
1760
|
+
}, x.SEARCH_DEBOUNCE_MS);
|
|
1722
1761
|
}
|
|
1723
|
-
#H(
|
|
1724
|
-
|
|
1762
|
+
#H() {
|
|
1763
|
+
this.#h.value = "", this.#h.focus(), this.#B();
|
|
1764
|
+
}
|
|
1765
|
+
#U(e) {
|
|
1766
|
+
let t = this.#_, n = t.getBoundingClientRect(), r = e.getBoundingClientRect(), i = r.top - n.top + t.scrollTop;
|
|
1725
1767
|
r.top < n.top ? t.scrollTop = i : r.bottom > n.bottom && (t.scrollTop = i - n.height + r.height);
|
|
1726
1768
|
}
|
|
1727
|
-
#
|
|
1728
|
-
if (this.#
|
|
1769
|
+
#W(e, t = !0) {
|
|
1770
|
+
if (this.#w?.classList.remove(_.HIGHLIGHT), e) {
|
|
1729
1771
|
if (e.classList.add(_.HIGHLIGHT), this.#e.countrySearch) {
|
|
1730
1772
|
let t = e.getAttribute("id") || "";
|
|
1731
|
-
this.#
|
|
1773
|
+
this.#h.setAttribute(j.ACTIVE_DESCENDANT, t);
|
|
1732
1774
|
}
|
|
1733
|
-
t && this.#
|
|
1734
|
-
} else this.#
|
|
1775
|
+
t && this.#U(e), this.#w = e;
|
|
1776
|
+
} else this.#w = null;
|
|
1735
1777
|
}
|
|
1736
1778
|
bindHiddenInputSubmitListener(e, t, n) {
|
|
1737
1779
|
let r = this.telInputEl.form;
|
|
1738
|
-
!r || !this.#
|
|
1739
|
-
this.#
|
|
1780
|
+
!r || !this.#v && !this.#y || r.addEventListener("submit", () => {
|
|
1781
|
+
this.#v && (this.#v.value = t()), this.#y && (this.#y.value = n());
|
|
1740
1782
|
}, { signal: e });
|
|
1741
1783
|
}
|
|
1742
1784
|
bindAllInitialDropdownListeners(e, t, n) {
|
|
1743
1785
|
let r = this.telInputEl.closest("label");
|
|
1744
1786
|
r && r.addEventListener("click", (e) => {
|
|
1745
1787
|
this.isDropdownOpen() ? e.preventDefault() : this.telInputEl.focus();
|
|
1746
|
-
}, { signal: e }), this.#
|
|
1788
|
+
}, { signal: e }), this.#l.addEventListener("click", () => {
|
|
1747
1789
|
!this.isDropdownOpen() && !this.telInputEl.disabled && !this.telInputEl.readOnly && t();
|
|
1748
|
-
}, { signal: e }), this.#
|
|
1790
|
+
}, { signal: e }), this.#c.addEventListener("keydown", (e) => {
|
|
1749
1791
|
let r = [
|
|
1750
1792
|
v.ARROW_UP,
|
|
1751
1793
|
v.ARROW_DOWN,
|
|
@@ -1757,41 +1799,41 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
1757
1799
|
}
|
|
1758
1800
|
openDropdown(e, t) {
|
|
1759
1801
|
let { countrySearch: n, dropdownAlwaysOpen: r, dropdownContainer: i } = this.#e;
|
|
1760
|
-
if (this.#
|
|
1802
|
+
if (this.#E = new AbortController(), this.ensureDropdownWidthSet(), i) this.#ne();
|
|
1761
1803
|
else {
|
|
1762
|
-
let e = this.#
|
|
1763
|
-
e ? this.#
|
|
1804
|
+
let e = this.#te(), t = this.telInputEl.offsetHeight + C.DROPDOWN_MARGIN;
|
|
1805
|
+
e ? this.#p.style.top = `${t}px` : this.#p.style.bottom = `${t}px`;
|
|
1764
1806
|
}
|
|
1765
|
-
this.#
|
|
1766
|
-
let a = this.#
|
|
1767
|
-
a && this.#
|
|
1768
|
-
this.#
|
|
1769
|
-
}, { signal: this.#
|
|
1807
|
+
this.#p.classList.remove(_.HIDE), this.#l.setAttribute(j.EXPANDED, "true");
|
|
1808
|
+
let a = this.#C ?? this.#_.firstElementChild;
|
|
1809
|
+
a && this.#W(a), n && !r && this.#h.focus(), this.#e.useFullscreenPopup && this.#S && window.visualViewport && window.visualViewport.addEventListener("resize", () => {
|
|
1810
|
+
this.#re(), this.#w && this.#U(this.#w);
|
|
1811
|
+
}, { signal: this.#E.signal }), this.#f.classList.add(_.ARROW_UP), this.#G(e, t);
|
|
1770
1812
|
}
|
|
1771
|
-
#
|
|
1772
|
-
let n = this.#
|
|
1773
|
-
this.#
|
|
1813
|
+
#G(e, t) {
|
|
1814
|
+
let n = this.#E.signal;
|
|
1815
|
+
this.#K(n), this.#q(n, e), this.#e.dropdownAlwaysOpen || this.#J(n, t), this.#Y(n, e, t), this.#e.countrySearch && this.#X(n), !this.#e.useFullscreenPopup && this.#e.dropdownContainer && window.addEventListener("scroll", t, { signal: n });
|
|
1774
1816
|
}
|
|
1775
|
-
#
|
|
1776
|
-
this.#
|
|
1817
|
+
#K(e) {
|
|
1818
|
+
this.#_.addEventListener("mouseover", (e) => {
|
|
1777
1819
|
let t = e.target?.closest(`.${_.COUNTRY_ITEM}`);
|
|
1778
|
-
t && this.#
|
|
1820
|
+
t && this.#W(t, !1);
|
|
1779
1821
|
}, { signal: e });
|
|
1780
1822
|
}
|
|
1781
|
-
#
|
|
1782
|
-
this.#
|
|
1823
|
+
#q(e, t) {
|
|
1824
|
+
this.#_.addEventListener("click", (e) => {
|
|
1783
1825
|
let n = e.target?.closest(`.${_.COUNTRY_ITEM}`);
|
|
1784
1826
|
n && t(n);
|
|
1785
1827
|
}, { signal: e });
|
|
1786
1828
|
}
|
|
1787
|
-
#
|
|
1829
|
+
#J(e, t) {
|
|
1788
1830
|
setTimeout(() => {
|
|
1789
1831
|
document.documentElement.addEventListener("click", (e) => {
|
|
1790
|
-
this.#
|
|
1832
|
+
this.#p.contains(e.target) || t();
|
|
1791
1833
|
}, { signal: e });
|
|
1792
1834
|
}, 0);
|
|
1793
1835
|
}
|
|
1794
|
-
#
|
|
1836
|
+
#Y(e, t, n) {
|
|
1795
1837
|
let r = "", i = null;
|
|
1796
1838
|
document.addEventListener("keydown", (e) => {
|
|
1797
1839
|
[
|
|
@@ -1799,110 +1841,110 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
1799
1841
|
v.ARROW_DOWN,
|
|
1800
1842
|
v.ENTER,
|
|
1801
1843
|
v.ESC
|
|
1802
|
-
].includes(e.key) && (e.preventDefault(), e.stopPropagation(), e.key === v.ARROW_UP || e.key === v.ARROW_DOWN ? this.#
|
|
1844
|
+
].includes(e.key) && (e.preventDefault(), e.stopPropagation(), e.key === v.ARROW_UP || e.key === v.ARROW_DOWN ? this.#Q(e.key) : e.key === v.ENTER && !e.isComposing ? t(this.#w) : e.key === v.ESC && (n(), this.#l.focus())), !this.#e.countrySearch && e.target !== this.telInputEl && b.HIDDEN_SEARCH_CHAR.test(e.key) && (e.stopPropagation(), i && clearTimeout(i), r += e.key.toLowerCase(), this.#Z(r), i = setTimeout(() => {
|
|
1803
1845
|
r = "";
|
|
1804
1846
|
}, x.HIDDEN_SEARCH_RESET_MS));
|
|
1805
1847
|
}, { signal: e });
|
|
1806
1848
|
}
|
|
1807
|
-
#Y(e) {
|
|
1808
|
-
this.#m.addEventListener("input", () => this.#B(), { signal: e }), this.#h.addEventListener("click", () => this.#V(), { signal: e });
|
|
1809
|
-
}
|
|
1810
1849
|
#X(e) {
|
|
1811
|
-
|
|
1812
|
-
if (t) {
|
|
1813
|
-
let e = this.#w.get(t.iso2);
|
|
1814
|
-
this.#U(e);
|
|
1815
|
-
}
|
|
1850
|
+
this.#h.addEventListener("input", () => this.#V(), { signal: e }), this.#g.addEventListener("click", () => this.#H(), { signal: e });
|
|
1816
1851
|
}
|
|
1817
1852
|
#Z(e) {
|
|
1818
|
-
let t =
|
|
1819
|
-
|
|
1853
|
+
let t = ue(this.#i, this.#a, e);
|
|
1854
|
+
if (t) {
|
|
1855
|
+
let e = this.#T.get(t.iso2);
|
|
1856
|
+
this.#W(e);
|
|
1857
|
+
}
|
|
1820
1858
|
}
|
|
1821
1859
|
#Q(e) {
|
|
1822
|
-
|
|
1823
|
-
|
|
1860
|
+
let t = e === v.ARROW_UP ? this.#w?.previousElementSibling : this.#w?.nextElementSibling;
|
|
1861
|
+
!t && this.#_.childElementCount > 1 && (t = e === v.ARROW_UP ? this.#_.lastElementChild : this.#_.firstElementChild), t && this.#W(t);
|
|
1862
|
+
}
|
|
1863
|
+
#$(e) {
|
|
1864
|
+
if (this.#C && this.#C.dataset[A.ISO2] !== e && (this.#C.setAttribute(j.SELECTED, "false"), this.#C.querySelector(".iti__country-check")?.remove(), this.#C = null), e && !this.#C) {
|
|
1865
|
+
let t = this.#_.querySelector(`[data-country-code="${e}"]`);
|
|
1824
1866
|
if (t) {
|
|
1825
1867
|
t.setAttribute(j.SELECTED, "true");
|
|
1826
1868
|
let e = G("span", {
|
|
1827
1869
|
class: "iti__country-check",
|
|
1828
1870
|
[j.HIDDEN]: "true"
|
|
1829
1871
|
}, t);
|
|
1830
|
-
e.innerHTML = se(), this.#
|
|
1872
|
+
e.innerHTML = se(), this.#C = t, this.#e.dropdownAlwaysOpen && this.#W(t);
|
|
1831
1873
|
}
|
|
1832
1874
|
}
|
|
1833
1875
|
}
|
|
1834
|
-
|
|
1835
|
-
this.#
|
|
1876
|
+
#ee(e) {
|
|
1877
|
+
this.#_.replaceChildren();
|
|
1836
1878
|
let t = !0;
|
|
1837
1879
|
for (let n of e) {
|
|
1838
|
-
let e = this.#
|
|
1839
|
-
e && (this.#
|
|
1880
|
+
let e = this.#T.get(n.iso2);
|
|
1881
|
+
e && (this.#_.appendChild(e), t &&= (this.#W(e, !1), !1));
|
|
1840
1882
|
}
|
|
1841
|
-
t ? (this.#
|
|
1883
|
+
t ? (this.#W(null), this.#b && this.#b.classList.remove(_.HIDE)) : this.#b && this.#b.classList.add(_.HIDE), this.#_.scrollTop = 0, this.#R();
|
|
1842
1884
|
}
|
|
1843
1885
|
closeDropdown() {
|
|
1844
1886
|
let { countrySearch: e, dropdownContainer: t } = this.#e;
|
|
1845
|
-
this.#
|
|
1887
|
+
this.#E.abort(), this.#E = null, this.#p.classList.add(_.HIDE), this.#l.setAttribute(j.EXPANDED, "false"), e && (this.#h.removeAttribute(j.ACTIVE_DESCENDANT), this.#h.value = "", this.#B(), this.#w &&= (this.#w.classList.remove(_.HIGHLIGHT), null)), this.#f.classList.remove(_.ARROW_UP), t ? (this.#S.remove(), this.#S.style.top = "", this.#S.style.bottom = "", this.#S.style.paddingLeft = "", this.#S.style.paddingRight = "") : (this.#p.style.top = "", this.#p.style.bottom = "");
|
|
1846
1888
|
}
|
|
1847
|
-
#
|
|
1889
|
+
#te() {
|
|
1848
1890
|
if (this.#e.dropdownAlwaysOpen) return !0;
|
|
1849
1891
|
let e = this.telInputEl.getBoundingClientRect(), t = e.top, n = window.innerHeight - e.bottom;
|
|
1850
|
-
return n >= this.#
|
|
1892
|
+
return n >= this.#s || n >= t;
|
|
1851
1893
|
}
|
|
1852
|
-
#
|
|
1894
|
+
#ne() {
|
|
1853
1895
|
let { dropdownContainer: e, useFullscreenPopup: t } = this.#e;
|
|
1854
1896
|
if (t) {
|
|
1855
1897
|
if (window.innerWidth >= C.NARROW_VIEWPORT_WIDTH) {
|
|
1856
1898
|
let e = this.telInputEl.getBoundingClientRect();
|
|
1857
|
-
this.#
|
|
1899
|
+
this.#S.style.paddingLeft = `${e.left}px`, this.#S.style.paddingRight = `${window.innerWidth - e.right}px`;
|
|
1858
1900
|
}
|
|
1859
1901
|
} else {
|
|
1860
1902
|
let e = this.telInputEl.getBoundingClientRect();
|
|
1861
|
-
this.#
|
|
1903
|
+
this.#S.style.left = `${e.left}px`, this.#te() ? this.#S.style.top = `${e.bottom + C.DROPDOWN_MARGIN}px` : (this.#S.style.top = "unset", this.#S.style.bottom = `${window.innerHeight - e.top + C.DROPDOWN_MARGIN}px`);
|
|
1862
1904
|
}
|
|
1863
|
-
e.appendChild(this.#
|
|
1905
|
+
e.appendChild(this.#S);
|
|
1864
1906
|
}
|
|
1865
|
-
#
|
|
1907
|
+
#re() {
|
|
1866
1908
|
let e = window.visualViewport;
|
|
1867
|
-
if (!e || !this.#
|
|
1909
|
+
if (!e || !this.#S) return;
|
|
1868
1910
|
let t = window.innerHeight - e.height;
|
|
1869
|
-
this.#
|
|
1911
|
+
this.#S.style.bottom = `${t}px`;
|
|
1870
1912
|
}
|
|
1871
1913
|
isDropdownOpen() {
|
|
1872
|
-
return !this.#
|
|
1914
|
+
return !this.#p.classList.contains(_.HIDE);
|
|
1873
1915
|
}
|
|
1874
1916
|
setLoading(e) {
|
|
1875
|
-
this.#
|
|
1917
|
+
this.#u.classList.toggle(_.LOADING, e);
|
|
1876
1918
|
}
|
|
1877
1919
|
isLoading() {
|
|
1878
|
-
return this.#
|
|
1920
|
+
return this.#u.classList.contains(_.LOADING);
|
|
1879
1921
|
}
|
|
1880
1922
|
setDisabled(e) {
|
|
1881
|
-
this.telInputEl.disabled = e, this.#
|
|
1923
|
+
this.telInputEl.disabled = e, this.#l && (e ? this.#l.setAttribute("disabled", "true") : this.#l.removeAttribute("disabled"));
|
|
1882
1924
|
}
|
|
1883
1925
|
setReadonly(e) {
|
|
1884
|
-
this.telInputEl.readOnly = e, this.#
|
|
1926
|
+
this.telInputEl.readOnly = e, this.#l && (e ? this.#l.setAttribute("disabled", "true") : this.#l.removeAttribute("disabled"));
|
|
1885
1927
|
}
|
|
1886
1928
|
setCountry(e) {
|
|
1887
1929
|
let { allowDropdown: t, showFlags: n, separateDialCode: r, i18n: i } = this.#e, a = e?.name, o = e?.dialCode, s = e?.iso2 ?? "";
|
|
1888
|
-
if (t && this
|
|
1930
|
+
if (t && this.#$(s), this.#l) {
|
|
1889
1931
|
let e = s && n ? `${_.FLAG} iti__${s}` : `${_.FLAG} ${_.GLOBE}`, t, r, c;
|
|
1890
|
-
s ? (r = a, t = i.selectedCountryAriaLabel.replace("${countryName}", a).replace("${dialCode}", `+${o}`), c = n ? "" : K()) : (r = i.noCountrySelected, t = i.noCountrySelected, c = K()), this.#
|
|
1932
|
+
s ? (r = a, t = i.selectedCountryAriaLabel.replace("${countryName}", a).replace("${dialCode}", `+${o}`), c = n ? "" : K()) : (r = i.noCountrySelected, t = i.noCountrySelected, c = K()), this.#u.className = e, this.#l.setAttribute("title", r), this.#l.setAttribute(j.LABEL, t), this.#u.innerHTML = c;
|
|
1891
1933
|
}
|
|
1892
1934
|
if (r) {
|
|
1893
1935
|
let e = o ? `+${o}` : "";
|
|
1894
|
-
this.#
|
|
1936
|
+
this.#d.textContent = e, this.#P();
|
|
1895
1937
|
}
|
|
1896
1938
|
}
|
|
1897
1939
|
destroy() {
|
|
1898
1940
|
this.telInputEl.iti = void 0, delete this.telInputEl.dataset[A.INSTANCE_ID], this.telInputEl.style.paddingLeft = this.#r;
|
|
1899
1941
|
let e = this.telInputEl.parentNode;
|
|
1900
|
-
e && (e.before(this.telInputEl), e.remove()), this.#
|
|
1942
|
+
e && (e.before(this.telInputEl), e.remove()), this.#T.clear();
|
|
1901
1943
|
}
|
|
1902
|
-
},
|
|
1944
|
+
}, de = (e) => {
|
|
1903
1945
|
let { onlyCountries: t, excludeCountries: n } = e;
|
|
1904
1946
|
return t?.length ? h.filter((e) => t.includes(e.iso2)) : n?.length ? h.filter((e) => !n.includes(e.iso2)) : [...h];
|
|
1905
|
-
},
|
|
1947
|
+
}, fe = (e, t) => {
|
|
1906
1948
|
let { countryNameLocale: n, i18n: r } = t, i;
|
|
1907
1949
|
try {
|
|
1908
1950
|
i = typeof Intl < "u" && typeof Intl.DisplayNames == "function" ? new Intl.DisplayNames(n, { type: "region" }) : null;
|
|
@@ -1910,7 +1952,7 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
1910
1952
|
console.error(e), i = null;
|
|
1911
1953
|
}
|
|
1912
1954
|
for (let t of e) t.name = r[t.iso2] || i?.of(t.iso2.toUpperCase()) || "";
|
|
1913
|
-
},
|
|
1955
|
+
}, pe = (e) => {
|
|
1914
1956
|
let t = /* @__PURE__ */ new Set(), n = 0, r = {}, i = (e, t) => {
|
|
1915
1957
|
if (!e || !t) return;
|
|
1916
1958
|
t.length > n && (n = t.length), Object.hasOwn(r, t) || (r[t] = []);
|
|
@@ -1939,7 +1981,7 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
1939
1981
|
dialCodeMaxLength: n,
|
|
1940
1982
|
dialCodeToIso2Map: r
|
|
1941
1983
|
};
|
|
1942
|
-
},
|
|
1984
|
+
}, me = (e, t) => {
|
|
1943
1985
|
let { countryOrder: n } = t;
|
|
1944
1986
|
e.sort((e, t) => {
|
|
1945
1987
|
if (n) {
|
|
@@ -1948,8 +1990,6 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
1948
1990
|
}
|
|
1949
1991
|
return e.name.localeCompare(t.name);
|
|
1950
1992
|
});
|
|
1951
|
-
}, me = (e) => {
|
|
1952
|
-
for (let t of e) t.normalisedName = U(t.name), t.initials = t.normalisedName.split(/[^a-z]/).map((e) => e[0]).join(""), t.dialCodePlus = `+${t.dialCode}`;
|
|
1953
1993
|
}, he = /* @__PURE__ */ new Set([
|
|
1954
1994
|
"800",
|
|
1955
1995
|
"808",
|
|
@@ -1959,17 +1999,17 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
1959
1999
|
"883",
|
|
1960
2000
|
"888",
|
|
1961
2001
|
"979"
|
|
1962
|
-
]),
|
|
2002
|
+
]), Y = (e) => {
|
|
1963
2003
|
let t = H(e).slice(0, 3);
|
|
1964
2004
|
return e.startsWith("+") && he.has(t);
|
|
1965
|
-
},
|
|
2005
|
+
}, ge = (e, t, n, r) => {
|
|
1966
2006
|
if (!n || !t) return e;
|
|
1967
2007
|
let i = `+${r.dialCode}`, a = e[i.length] === " " || e[i.length] === "-" ? i.length + 1 : i.length;
|
|
1968
2008
|
return e.substring(a);
|
|
1969
|
-
},
|
|
2009
|
+
}, _e = (e, t, n, r, i) => {
|
|
1970
2010
|
let a = n ? n.formatNumberAsYouType(e, r?.iso2) : e, o = r?.dialCode;
|
|
1971
2011
|
return i && t.charAt(0) !== "+" && a.includes(`+${o}`) ? (a.split(`+${o}`)[1] || "").trim() : a;
|
|
1972
|
-
},
|
|
2012
|
+
}, ve = (e, t, n, r) => {
|
|
1973
2013
|
if (n === 0 && !r) return 0;
|
|
1974
2014
|
let i = 0;
|
|
1975
2015
|
for (let n = 0; n < t.length; n++) {
|
|
@@ -1977,7 +2017,7 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
1977
2017
|
if (r && i === e + 1) return n;
|
|
1978
2018
|
}
|
|
1979
2019
|
return t.length;
|
|
1980
|
-
},
|
|
2020
|
+
}, ye = /* @__PURE__ */ new Set([
|
|
1981
2021
|
"800",
|
|
1982
2022
|
"822",
|
|
1983
2023
|
"833",
|
|
@@ -1995,35 +2035,13 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
1995
2035
|
"887",
|
|
1996
2036
|
"888",
|
|
1997
2037
|
"889"
|
|
1998
|
-
]),
|
|
2038
|
+
]), be = (e) => {
|
|
1999
2039
|
let t = H(e);
|
|
2000
2040
|
if (t.startsWith(w.NANP) && t.length >= 4) {
|
|
2001
2041
|
let e = t.substring(1, 4);
|
|
2002
|
-
return
|
|
2042
|
+
return ye.has(e);
|
|
2003
2043
|
}
|
|
2004
2044
|
return !1;
|
|
2005
|
-
}, be = class {
|
|
2006
|
-
#e;
|
|
2007
|
-
constructor(e) {
|
|
2008
|
-
e && this.#t(e);
|
|
2009
|
-
}
|
|
2010
|
-
#t(e) {
|
|
2011
|
-
/[\u0660-\u0669]/.test(e) ? this.#e = "arabic-indic" : /[\u06F0-\u06F9]/.test(e) ? this.#e = "persian" : this.#e = "ascii";
|
|
2012
|
-
}
|
|
2013
|
-
denormalise(e) {
|
|
2014
|
-
if (!this.#e || this.#e === "ascii") return e;
|
|
2015
|
-
let t = this.#e === "arabic-indic" ? 1632 : 1776;
|
|
2016
|
-
return e.replace(/[0-9]/g, (e) => String.fromCharCode(t + Number(e)));
|
|
2017
|
-
}
|
|
2018
|
-
normalise(e) {
|
|
2019
|
-
if (!e) return "";
|
|
2020
|
-
if (this.#t(e), this.#e === "ascii") return e;
|
|
2021
|
-
let t = this.#e === "arabic-indic" ? 1632 : 1776, n = this.#e === "arabic-indic" ? /[\u0660-\u0669]/g : /[\u06F0-\u06F9]/g;
|
|
2022
|
-
return e.replace(n, (e) => String.fromCharCode(48 + (e.charCodeAt(0) - t)));
|
|
2023
|
-
}
|
|
2024
|
-
isAscii() {
|
|
2025
|
-
return !this.#e || this.#e === "ascii";
|
|
2026
|
-
}
|
|
2027
2045
|
}, xe = 0, X = (e) => {
|
|
2028
2046
|
if (!Q.utils) throw Error(`intlTelInput.utils is required for ${e}(). See: https://intl-tel-input.com/docs/utils`);
|
|
2029
2047
|
}, Se = () => {
|
|
@@ -2046,61 +2064,62 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
2046
2064
|
#a;
|
|
2047
2065
|
#o;
|
|
2048
2066
|
#s;
|
|
2049
|
-
#c
|
|
2067
|
+
#c;
|
|
2050
2068
|
#l = null;
|
|
2051
|
-
#u;
|
|
2052
|
-
#d
|
|
2053
|
-
#f;
|
|
2069
|
+
#u = null;
|
|
2070
|
+
#d;
|
|
2071
|
+
#f = !0;
|
|
2054
2072
|
#p;
|
|
2055
|
-
#m
|
|
2056
|
-
#h;
|
|
2073
|
+
#m;
|
|
2074
|
+
#h = !1;
|
|
2057
2075
|
#g;
|
|
2076
|
+
#_;
|
|
2058
2077
|
constructor(e, t = {}) {
|
|
2059
|
-
this.id = xe++,
|
|
2078
|
+
this.id = xe++, J.validateInput(e);
|
|
2060
2079
|
let n = ne(t);
|
|
2061
2080
|
this.#t = {
|
|
2062
2081
|
...F,
|
|
2063
2082
|
...n
|
|
2064
|
-
}, re(this.#t), ie(this.#t), this.#e = new
|
|
2065
|
-
let { dialCodes: r, dialCodeMaxLength: i, dialCodeToIso2Map: a } =
|
|
2066
|
-
this.#o = r, this.#i = i, this.#a = a, this.#s = new Map(this.#r.map((e) => [e.iso2, e])), this.#
|
|
2083
|
+
}, re(this.#t), ie(this.#t), this.#e = new J(e, this.#t, this.id), this.#n = typeof navigator < "u" && /Android/i.test(navigator.userAgent), this.#m = new q(e.value), this.promise = this.#b(this.#t), this.#r = de(this.#t);
|
|
2084
|
+
let { dialCodes: r, dialCodeMaxLength: i, dialCodeToIso2Map: a } = pe(this.#r);
|
|
2085
|
+
this.#o = r, this.#i = i, this.#a = a, this.#s = new Map(this.#r.map((e) => [e.iso2, e])), this.#x();
|
|
2067
2086
|
}
|
|
2068
|
-
#
|
|
2087
|
+
#v() {
|
|
2069
2088
|
let e = this.#e.telInputEl.value.trim();
|
|
2070
|
-
return this.#
|
|
2071
|
-
}
|
|
2072
|
-
#v(e) {
|
|
2073
|
-
this.#e.telInputEl.value = this.#p.denormalise(e);
|
|
2089
|
+
return this.#m.normalise(e);
|
|
2074
2090
|
}
|
|
2075
2091
|
#y(e) {
|
|
2076
|
-
|
|
2077
|
-
return i && (this.#h = Se()), a && (this.#g = Se()), Promise.all([this.#h?.promise, this.#g?.promise]).then(() => {});
|
|
2092
|
+
this.#e.telInputEl.value = this.#m.denormalise(e);
|
|
2078
2093
|
}
|
|
2079
|
-
#b() {
|
|
2080
|
-
|
|
2094
|
+
#b(e) {
|
|
2095
|
+
let { initialCountry: t, geoIpLookup: n, loadUtils: r } = e, i = t === O.AUTO && !!n, a = !!r && !Q.utils;
|
|
2096
|
+
return i && (this.#g = Se()), a && (this.#_ = Se()), Promise.all([this.#g?.promise, this.#_?.promise]).then(() => {});
|
|
2081
2097
|
}
|
|
2082
2098
|
#x() {
|
|
2083
|
-
|
|
2099
|
+
this.#p = new AbortController(), this.#S(), this.#e.buildMarkup(this.#r, this.#c), this.#C(), this.#w(), this.#T(), this.#t.dropdownAlwaysOpen && this.#U();
|
|
2084
2100
|
}
|
|
2085
|
-
#S(
|
|
2086
|
-
|
|
2087
|
-
a ? o ? f ? this.#J(u) : d || this.#J(E.ISO2) : (f && this.#J(u), this.#W(i)) : f ? this.#J(u) : d || this.#J(""), i && this.#U(i);
|
|
2101
|
+
#S() {
|
|
2102
|
+
fe(this.#r, this.#t), me(this.#r, this.#t), this.#c = ce(this.#r);
|
|
2088
2103
|
}
|
|
2089
|
-
#C() {
|
|
2090
|
-
this.#
|
|
2104
|
+
#C(e = !1) {
|
|
2105
|
+
let t = this.#e.telInputEl.getAttribute("value"), n = this.#m.normalise(t ?? ""), r = this.#v(), i = n && n.startsWith("+") && (!r || !r.startsWith("+")) ? n : r, a = this.#te(i), o = be(i), { initialCountry: s, geoIpLookup: c } = this.#t, l = s === O.AUTO && c, u = l && Q.autoCountry ? Q.autoCountry : s, d = l && !e && !Q.autoCountry, f = m(u);
|
|
2106
|
+
a ? o ? f ? this.#Y(u) : d || this.#Y(E.ISO2) : (f && this.#Y(u), this.#G(i)) : f ? this.#Y(u) : d || this.#Y(""), i && this.#W(i);
|
|
2091
2107
|
}
|
|
2092
2108
|
#w() {
|
|
2093
|
-
|
|
2109
|
+
this.#k(), this.#t.allowDropdown && this.#e.bindAllInitialDropdownListeners(this.#p.signal, () => this.#U(), () => this.#$()), this.#e.bindHiddenInputSubmitListener(this.#p.signal, () => this.getNumber(), () => this.#l?.iso2 || "");
|
|
2110
|
+
}
|
|
2111
|
+
#T() {
|
|
2112
|
+
if (this.#_) {
|
|
2094
2113
|
let { loadUtils: e } = this.#t, t = () => {
|
|
2095
2114
|
Q.attachUtils(e)?.catch(() => {});
|
|
2096
2115
|
};
|
|
2097
|
-
Q.documentReady() ? t() : window.addEventListener("load", t, { signal: this.#
|
|
2116
|
+
Q.documentReady() ? t() : window.addEventListener("load", t, { signal: this.#p.signal });
|
|
2098
2117
|
}
|
|
2099
|
-
this.#
|
|
2118
|
+
this.#g && (this.#l ? this.#g.resolve() : this.#E());
|
|
2100
2119
|
}
|
|
2101
|
-
#
|
|
2120
|
+
#E() {
|
|
2102
2121
|
if (Q.autoCountry) {
|
|
2103
|
-
this.#
|
|
2122
|
+
this.#se();
|
|
2104
2123
|
return;
|
|
2105
2124
|
}
|
|
2106
2125
|
this.#e.setLoading(!0), !Q.startedLoadingAutoCountry && (Q.startedLoadingAutoCountry = !0, typeof this.#t.geoIpLookup == "function" && this.#t.geoIpLookup((t = "") => {
|
|
@@ -2110,99 +2129,107 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
2110
2129
|
e.forEachInstance("handleAutoCountryFailure");
|
|
2111
2130
|
}));
|
|
2112
2131
|
}
|
|
2113
|
-
#
|
|
2114
|
-
this.#
|
|
2132
|
+
#D() {
|
|
2133
|
+
this.#U(), this.#e.prefillSearchWithPlus();
|
|
2115
2134
|
}
|
|
2116
|
-
#
|
|
2135
|
+
#O(e) {
|
|
2117
2136
|
let t = this.#e.telInputEl.selectionStart || 0, n = e.substring(0, t - 1), r = e.substring(t);
|
|
2118
|
-
return this.#
|
|
2137
|
+
return this.#y(n + r), t - 1;
|
|
2119
2138
|
}
|
|
2120
|
-
#
|
|
2121
|
-
this.#
|
|
2139
|
+
#k() {
|
|
2140
|
+
this.#P(), this.#I(), this.#R();
|
|
2122
2141
|
}
|
|
2123
|
-
#
|
|
2124
|
-
this.#
|
|
2142
|
+
#A(e) {
|
|
2143
|
+
this.#O(e), this.#D();
|
|
2125
2144
|
}
|
|
2126
|
-
#
|
|
2127
|
-
let n = this.#
|
|
2128
|
-
this.#e.telInputEl.setSelectionRange(n, n), this.#
|
|
2145
|
+
#j(e, t) {
|
|
2146
|
+
let n = this.#O(e);
|
|
2147
|
+
this.#e.telInputEl.setSelectionRange(n, n), this.#V(), this.#H(g.STRICT_REJECT, {
|
|
2129
2148
|
source: "key",
|
|
2130
2149
|
rejectedInput: t,
|
|
2131
2150
|
reason: "invalid"
|
|
2132
2151
|
});
|
|
2133
2152
|
}
|
|
2134
|
-
#
|
|
2135
|
-
let n = this.#e.telInputEl.selectionStart || 0, r = e.substring(0, n).replace(b.NON_PLUS_NUMERIC_GLOBAL, "").length, i =
|
|
2136
|
-
this.#
|
|
2153
|
+
#M(e, t) {
|
|
2154
|
+
let n = this.#e.telInputEl.selectionStart || 0, r = e.substring(0, n).replace(b.NON_PLUS_NUMERIC_GLOBAL, "").length, i = _e(this.#re(), e, Q.utils, this.#l, this.#t.separateDialCode), a = ve(r, i, n, t);
|
|
2155
|
+
this.#y(i), this.#e.telInputEl.setSelectionRange(a, a);
|
|
2137
2156
|
}
|
|
2138
|
-
#
|
|
2139
|
-
if (e.startsWith("+") && this.#
|
|
2140
|
-
let t =
|
|
2141
|
-
this.#
|
|
2157
|
+
#N(e) {
|
|
2158
|
+
if (e.startsWith("+") && this.#l && this.#te(e)) {
|
|
2159
|
+
let t = ge(e, !0, !0, this.#l);
|
|
2160
|
+
this.#y(t);
|
|
2142
2161
|
}
|
|
2143
2162
|
}
|
|
2144
|
-
#
|
|
2145
|
-
this.#
|
|
2163
|
+
#P() {
|
|
2164
|
+
this.#h = b.ALPHA_UNICODE.test(this.#v()), this.#e.telInputEl.addEventListener("input", this.#F, { signal: this.#p.signal });
|
|
2146
2165
|
}
|
|
2147
|
-
#
|
|
2166
|
+
#F = (e) => {
|
|
2148
2167
|
let { strictMode: t, formatAsYouType: n, separateDialCode: r, allowDropdown: i, countrySearch: a } = this.#t, o = e?.detail;
|
|
2149
2168
|
if (o?.isCountryChange) return;
|
|
2150
|
-
let s = this.#
|
|
2169
|
+
let s = this.#v();
|
|
2151
2170
|
if (this.#n && e?.data === "+" && r && i && a) {
|
|
2152
|
-
this.#
|
|
2171
|
+
this.#A(s);
|
|
2153
2172
|
return;
|
|
2154
2173
|
}
|
|
2155
2174
|
if (this.#n && t && (e?.data === " " || e?.data === "-" || e?.data === ".")) {
|
|
2156
|
-
this.#
|
|
2175
|
+
this.#j(s, e.data);
|
|
2157
2176
|
return;
|
|
2158
2177
|
}
|
|
2159
|
-
this.#
|
|
2178
|
+
this.#G(s) && this.#oe();
|
|
2160
2179
|
let c = e?.data && b.NON_PLUS_NUMERIC.test(e.data), l = e?.inputType === y.PASTE && s;
|
|
2161
|
-
c || l && !t ? this.#
|
|
2180
|
+
c || l && !t ? this.#h = !0 : b.NON_PLUS_NUMERIC.test(s) || (this.#h = !1), n && !this.#h && !o?.isSetNumber && this.#m.isAscii() && this.#M(s, e?.inputType === y.DELETE_FORWARD), r && this.#N(s);
|
|
2162
2181
|
};
|
|
2163
|
-
#
|
|
2182
|
+
#I() {
|
|
2164
2183
|
let { strictMode: e, separateDialCode: t } = this.#t;
|
|
2165
|
-
!e && !t || this.#e.telInputEl.addEventListener("keydown", this.#
|
|
2184
|
+
!e && !t || this.#e.telInputEl.addEventListener("keydown", this.#L, { signal: this.#p.signal });
|
|
2166
2185
|
}
|
|
2167
|
-
#
|
|
2186
|
+
#L = (e) => {
|
|
2168
2187
|
let { strictMode: t, separateDialCode: n, allowDropdown: r, countrySearch: i } = this.#t;
|
|
2169
2188
|
if (!e.key || e.key.length !== 1 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
2170
2189
|
if (n && r && i && e.key === "+") {
|
|
2171
|
-
e.preventDefault(), this.#
|
|
2190
|
+
e.preventDefault(), this.#D();
|
|
2172
2191
|
return;
|
|
2173
2192
|
}
|
|
2174
2193
|
if (!t) return;
|
|
2175
|
-
let a = this.#
|
|
2176
|
-
Q.utils && this.#
|
|
2177
|
-
let y = this.#
|
|
2178
|
-
(!l || v && !y && !o) && (this.#
|
|
2194
|
+
let a = this.#v(), o = !a.startsWith("+") && this.#e.telInputEl.selectionStart === 0 && e.key === "+", s = this.#m.normalise(e.key), c = /^[0-9]$/.test(s), l = n ? c : o || c, u = this.#e.telInputEl, d = u.selectionStart, f = u.selectionEnd, p = a.slice(0, d ?? void 0), m = a.slice(f ?? void 0), h = p + s + m, _ = this.#ne(h), v = !1;
|
|
2195
|
+
Q.utils && this.#u && (v = Q.utils.getCoreNumber(_, this.#l?.iso2).length > this.#u);
|
|
2196
|
+
let y = this.#q(_) !== null;
|
|
2197
|
+
(!l || v && !y && !o) && (this.#V(), this.#H(g.STRICT_REJECT, {
|
|
2179
2198
|
source: "key",
|
|
2180
2199
|
rejectedInput: e.key,
|
|
2181
2200
|
reason: l ? "max-length" : "invalid"
|
|
2182
2201
|
}), e.preventDefault());
|
|
2183
2202
|
};
|
|
2184
|
-
#
|
|
2185
|
-
this.#t.strictMode && this.#e.telInputEl.addEventListener("paste", this.#
|
|
2203
|
+
#R() {
|
|
2204
|
+
this.#t.strictMode && this.#e.telInputEl.addEventListener("paste", this.#z, { signal: this.#p.signal });
|
|
2186
2205
|
}
|
|
2187
|
-
#
|
|
2206
|
+
#z = (e) => {
|
|
2188
2207
|
e.preventDefault();
|
|
2189
|
-
let t = this.#e.telInputEl, n = t.selectionStart, r = t.selectionEnd, i = this.#
|
|
2208
|
+
let t = this.#e.telInputEl, n = t.selectionStart, r = t.selectionEnd, i = this.#v(), a = i.slice(0, n ?? void 0), o = i.slice(r ?? void 0), s = this.#l?.iso2, c = e.clipboardData.getData("text"), l = this.#m.normalise(c), u = n === 0 && r > 0, d = !i.startsWith("+") || u, f = l.replace(b.NON_PLUS_NUMERIC_GLOBAL, ""), p = f.startsWith("+"), m = f.replace(/\+/g, ""), h = p && d ? `+${m}` : m, _ = a + h + o, v = h === l ? null : "invalid";
|
|
2209
|
+
if (_.length > 30) {
|
|
2210
|
+
this.#V(), this.#H(g.STRICT_REJECT, {
|
|
2211
|
+
source: "paste",
|
|
2212
|
+
rejectedInput: c,
|
|
2213
|
+
reason: "max-length"
|
|
2214
|
+
});
|
|
2215
|
+
return;
|
|
2216
|
+
}
|
|
2190
2217
|
if (_.length > 5 && Q.utils) {
|
|
2191
2218
|
let e = Q.utils.getCoreNumber(_, s);
|
|
2192
2219
|
for (; e.length === 0 && _.length > 0;) _ = _.slice(0, -1), e = Q.utils.getCoreNumber(_, s);
|
|
2193
2220
|
if (!e) {
|
|
2194
|
-
this.#
|
|
2221
|
+
this.#V(), this.#H(g.STRICT_REJECT, {
|
|
2195
2222
|
source: "paste",
|
|
2196
2223
|
rejectedInput: c,
|
|
2197
2224
|
reason: "max-length"
|
|
2198
2225
|
});
|
|
2199
2226
|
return;
|
|
2200
2227
|
}
|
|
2201
|
-
if (this.#
|
|
2202
|
-
let t = e.length - this.#
|
|
2228
|
+
if (this.#u && e.length > this.#u) if (t.selectionEnd === i.length) {
|
|
2229
|
+
let t = e.length - this.#u;
|
|
2203
2230
|
_ = _.slice(0, _.length - t), v = "max-length";
|
|
2204
2231
|
} else {
|
|
2205
|
-
this.#
|
|
2232
|
+
this.#V(), this.#H(g.STRICT_REJECT, {
|
|
2206
2233
|
source: "paste",
|
|
2207
2234
|
rejectedInput: c,
|
|
2208
2235
|
reason: "max-length"
|
|
@@ -2210,24 +2237,24 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
2210
2237
|
return;
|
|
2211
2238
|
}
|
|
2212
2239
|
}
|
|
2213
|
-
this.#
|
|
2240
|
+
this.#y(_);
|
|
2214
2241
|
let y = n + h.length;
|
|
2215
|
-
t.setSelectionRange(y, y), t.dispatchEvent(new InputEvent("input", { bubbles: !0 })), v && (l.length > 0 && h.length === 0 && this.#
|
|
2242
|
+
t.setSelectionRange(y, y), t.dispatchEvent(new InputEvent("input", { bubbles: !0 })), v && (l.length > 0 && h.length === 0 && this.#V(), this.#H(g.STRICT_REJECT, {
|
|
2216
2243
|
source: "paste",
|
|
2217
2244
|
rejectedInput: c,
|
|
2218
2245
|
reason: v
|
|
2219
2246
|
}));
|
|
2220
2247
|
};
|
|
2221
|
-
#
|
|
2248
|
+
#B(e) {
|
|
2222
2249
|
let t = Number(this.#e.telInputEl.getAttribute("maxlength"));
|
|
2223
2250
|
return t && e.length > t ? e.substring(0, t) : e;
|
|
2224
2251
|
}
|
|
2225
|
-
#
|
|
2252
|
+
#V() {
|
|
2226
2253
|
if (!this.#t.strictRejectAnimation) return;
|
|
2227
2254
|
let e = this.#e.telInputEl.parentElement;
|
|
2228
2255
|
e && (e.classList.remove("iti__strict-reject-animation"), e.offsetWidth, e.classList.add("iti__strict-reject-animation"));
|
|
2229
2256
|
}
|
|
2230
|
-
#
|
|
2257
|
+
#H(e, t = {}) {
|
|
2231
2258
|
let n = new CustomEvent(e, {
|
|
2232
2259
|
bubbles: !0,
|
|
2233
2260
|
cancelable: !0,
|
|
@@ -2235,43 +2262,43 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
2235
2262
|
});
|
|
2236
2263
|
this.#e.telInputEl.dispatchEvent(n);
|
|
2237
2264
|
}
|
|
2238
|
-
#
|
|
2239
|
-
this.#e.openDropdown((e) => this.#
|
|
2265
|
+
#U() {
|
|
2266
|
+
this.#e.openDropdown((e) => this.#Q(e), () => this.#$()), this.#H(g.OPEN_COUNTRY_DROPDOWN);
|
|
2240
2267
|
}
|
|
2241
|
-
#
|
|
2268
|
+
#W(e) {
|
|
2242
2269
|
let { formatOnDisplay: t, nationalMode: n, separateDialCode: r } = this.#t, i = e;
|
|
2243
|
-
if (t && Q.utils && this.#
|
|
2244
|
-
let t =
|
|
2245
|
-
i = Q.utils.formatNumber(i, this.#
|
|
2270
|
+
if (t && Q.utils && this.#l) {
|
|
2271
|
+
let t = Y(e), a = n && !t || !i.startsWith("+") && !r, { NATIONAL: o, INTERNATIONAL: s } = Q.utils.numberFormat, c = a ? o : s;
|
|
2272
|
+
i = Q.utils.formatNumber(i, this.#l?.iso2, c);
|
|
2246
2273
|
}
|
|
2247
|
-
i = this.#
|
|
2248
|
-
}
|
|
2249
|
-
#W(e) {
|
|
2250
|
-
let t = this.#K(e);
|
|
2251
|
-
return t === null ? !1 : this.#J(t);
|
|
2274
|
+
i = this.#ie(i), this.#y(i);
|
|
2252
2275
|
}
|
|
2253
2276
|
#G(e) {
|
|
2254
|
-
let t = this.#
|
|
2255
|
-
return
|
|
2277
|
+
let t = this.#q(e);
|
|
2278
|
+
return t === null ? !1 : this.#Y(t);
|
|
2256
2279
|
}
|
|
2257
2280
|
#K(e) {
|
|
2258
|
-
let t =
|
|
2259
|
-
n
|
|
2260
|
-
|
|
2281
|
+
let t = this.#l?.dialCode, n = this.#l?.nationalPrefix;
|
|
2282
|
+
return e.startsWith("+") || !t ? e : `+${t}${n && e.startsWith(n) && !this.#t.separateDialCode ? e.substring(1) : e}`;
|
|
2283
|
+
}
|
|
2284
|
+
#q(e) {
|
|
2285
|
+
let t = e.indexOf("+"), n = t > 0 ? e.substring(t) : e, r = this.#l?.iso2;
|
|
2286
|
+
n = this.#K(n);
|
|
2287
|
+
let i = this.#te(n, !0), a = H(n);
|
|
2261
2288
|
if (i) {
|
|
2262
2289
|
let e = H(i), t = this.#a[e];
|
|
2263
|
-
return t.length === 1 ? t[0] === r ? null : t[0] : this.#
|
|
2290
|
+
return t.length === 1 ? t[0] === r ? null : t[0] : this.#J(t, e, a);
|
|
2264
2291
|
} else if (n.startsWith("+") && a.length) {
|
|
2265
|
-
let e = this.#
|
|
2292
|
+
let e = this.#l?.dialCode || "";
|
|
2266
2293
|
return e && e.startsWith(a) ? null : "";
|
|
2267
|
-
} else if ((!n || n === "+") && !r && this.#
|
|
2294
|
+
} else if ((!n || n === "+") && !r && this.#d) return this.#d;
|
|
2268
2295
|
return null;
|
|
2269
2296
|
}
|
|
2270
|
-
#
|
|
2271
|
-
let r = this.#
|
|
2272
|
-
if (!r && this.#
|
|
2273
|
-
if (i === w.NANP &&
|
|
2274
|
-
let a = this.#
|
|
2297
|
+
#J(e, t, n) {
|
|
2298
|
+
let r = this.#l?.iso2, i = this.#l?.dialCode;
|
|
2299
|
+
if (!r && this.#d && e.includes(this.#d)) return this.#d;
|
|
2300
|
+
if (i === w.NANP && be(n)) return null;
|
|
2301
|
+
let a = this.#l?.areaCodes, o = this.#l?.priority;
|
|
2275
2302
|
if (a) {
|
|
2276
2303
|
let e = a.map((e) => `${i}${e}`);
|
|
2277
2304
|
for (let t of e) if (n.startsWith(t)) return null;
|
|
@@ -2279,50 +2306,50 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
2279
2306
|
let s = a && o !== 0 && n.length > t.length, c = r && e.includes(r) && !s, l = r === e[0];
|
|
2280
2307
|
return !c && !l ? e[0] : null;
|
|
2281
2308
|
}
|
|
2282
|
-
#
|
|
2283
|
-
let t = this.#
|
|
2284
|
-
return this.#
|
|
2309
|
+
#Y(e) {
|
|
2310
|
+
let t = this.#l?.iso2 || "";
|
|
2311
|
+
return this.#l = e ? this.#s.get(e) : null, this.#l && (this.#d = this.#l.iso2), this.#e.setCountry(this.#l), this.#Z(), this.#X(), t !== e;
|
|
2285
2312
|
}
|
|
2286
|
-
#
|
|
2313
|
+
#X() {
|
|
2287
2314
|
let { strictMode: e, placeholderNumberType: t, allowedNumberTypes: n } = this.#t;
|
|
2288
2315
|
if (!e || !Q.utils) return;
|
|
2289
|
-
let r = this.#
|
|
2316
|
+
let r = this.#l?.iso2;
|
|
2290
2317
|
if (!r) {
|
|
2291
|
-
this.#
|
|
2318
|
+
this.#u = null;
|
|
2292
2319
|
return;
|
|
2293
2320
|
}
|
|
2294
2321
|
let i = Q.utils.numberType[t], a = Q.utils.getExampleNumber(r, !1, i, !0), o = a;
|
|
2295
2322
|
for (; Q.utils.isPossibleNumber(a, r, n);) o = a, a += "0";
|
|
2296
2323
|
let s = Q.utils.getCoreNumber(o, r);
|
|
2297
|
-
this.#
|
|
2324
|
+
this.#u = s.length, r === "by" && (this.#u = s.length + 1);
|
|
2298
2325
|
}
|
|
2299
|
-
#
|
|
2326
|
+
#Z() {
|
|
2300
2327
|
let { autoPlaceholder: e, placeholderNumberType: t, nationalMode: n, customPlaceholder: r } = this.#t, i = e === D.AGGRESSIVE || !this.#e.hadInitialPlaceholder && e === D.POLITE;
|
|
2301
2328
|
if (!Q.utils || !i) return;
|
|
2302
|
-
let a = Q.utils.numberType[t], o = this.#
|
|
2303
|
-
o = this.#
|
|
2329
|
+
let a = Q.utils.numberType[t], o = this.#l ? Q.utils.getExampleNumber(this.#l.iso2, n, a) : "";
|
|
2330
|
+
o = this.#ie(o), typeof r == "function" && (o = r(o, this.#l)), this.#e.telInputEl.setAttribute("placeholder", o);
|
|
2304
2331
|
}
|
|
2305
|
-
#
|
|
2332
|
+
#Q(e) {
|
|
2306
2333
|
if (!e) return;
|
|
2307
|
-
let t = e.dataset[A.ISO2], n = this.#
|
|
2308
|
-
this
|
|
2334
|
+
let t = e.dataset[A.ISO2], n = this.#Y(t);
|
|
2335
|
+
this.#$();
|
|
2309
2336
|
let r = e.dataset[A.DIAL_CODE];
|
|
2310
|
-
if (this
|
|
2311
|
-
let e = this.#
|
|
2312
|
-
this.#
|
|
2337
|
+
if (this.#ee(r), this.#t.formatOnDisplay) {
|
|
2338
|
+
let e = this.#v();
|
|
2339
|
+
this.#W(e);
|
|
2313
2340
|
}
|
|
2314
|
-
this.#e.telInputEl.focus(), n && (this.#
|
|
2315
|
-
}
|
|
2316
|
-
#Q(e) {
|
|
2317
|
-
!this.#e.isDropdownOpen() || this.#t.dropdownAlwaysOpen && !e || (this.#e.closeDropdown(), this.#V(g.CLOSE_COUNTRY_DROPDOWN));
|
|
2341
|
+
this.#e.telInputEl.focus(), n && (this.#oe(), this.#H(g.INPUT, { isCountryChange: !0 }));
|
|
2318
2342
|
}
|
|
2319
2343
|
#$(e) {
|
|
2320
|
-
|
|
2344
|
+
!this.#e.isDropdownOpen() || this.#t.dropdownAlwaysOpen && !e || (this.#e.closeDropdown(), this.#H(g.CLOSE_COUNTRY_DROPDOWN));
|
|
2345
|
+
}
|
|
2346
|
+
#ee(e) {
|
|
2347
|
+
let t = this.#v();
|
|
2321
2348
|
if (!t.startsWith("+")) return;
|
|
2322
|
-
let n = `+${e}`, r = this.#
|
|
2323
|
-
i = r ? t.replace(r, n) : n, this.#
|
|
2349
|
+
let n = `+${e}`, r = this.#te(t), i;
|
|
2350
|
+
i = r ? t.replace(r, n) : n, this.#y(i);
|
|
2324
2351
|
}
|
|
2325
|
-
#
|
|
2352
|
+
#te(e, t) {
|
|
2326
2353
|
if (!e.startsWith("+")) return "";
|
|
2327
2354
|
let n = "", r = "", i = !1;
|
|
2328
2355
|
for (let a = 0; a < e.length; a++) {
|
|
@@ -2337,20 +2364,20 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
2337
2364
|
}
|
|
2338
2365
|
return n;
|
|
2339
2366
|
}
|
|
2340
|
-
#
|
|
2341
|
-
let t = this.#
|
|
2367
|
+
#ne(e) {
|
|
2368
|
+
let t = this.#l?.dialCode, n = H(e);
|
|
2342
2369
|
return (this.#t.separateDialCode && !e.startsWith("+") && t && n ? `+${t}` : "") + e;
|
|
2343
2370
|
}
|
|
2344
|
-
#
|
|
2345
|
-
let e = this.#
|
|
2346
|
-
return this.#
|
|
2371
|
+
#re() {
|
|
2372
|
+
let e = this.#v();
|
|
2373
|
+
return this.#ne(e);
|
|
2347
2374
|
}
|
|
2348
|
-
#
|
|
2349
|
-
let t =
|
|
2350
|
-
return this.#
|
|
2375
|
+
#ie(e) {
|
|
2376
|
+
let t = ge(e, !!this.#te(e), this.#t.separateDialCode, this.#l);
|
|
2377
|
+
return this.#B(t);
|
|
2351
2378
|
}
|
|
2352
|
-
#
|
|
2353
|
-
let e = this.#
|
|
2379
|
+
#ae() {
|
|
2380
|
+
let e = this.#l;
|
|
2354
2381
|
if (!e) return null;
|
|
2355
2382
|
let { iso2: t, dialCode: n, name: r } = e;
|
|
2356
2383
|
return {
|
|
@@ -2359,76 +2386,76 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
2359
2386
|
name: r
|
|
2360
2387
|
};
|
|
2361
2388
|
}
|
|
2362
|
-
#ae() {
|
|
2363
|
-
let e = this.#ie();
|
|
2364
|
-
this.#V(g.COUNTRY_CHANGE, e);
|
|
2365
|
-
}
|
|
2366
2389
|
#oe() {
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2390
|
+
let e = this.#ae();
|
|
2391
|
+
this.#H(g.COUNTRY_CHANGE, e);
|
|
2392
|
+
}
|
|
2393
|
+
#se() {
|
|
2394
|
+
if (!(!this.#g || !Q.autoCountry)) {
|
|
2395
|
+
if (!this.#f) {
|
|
2396
|
+
this.#g.resolve();
|
|
2370
2397
|
return;
|
|
2371
2398
|
}
|
|
2372
|
-
this.#e.isLoading() ? this.setCountry(Q.autoCountry) : this.#
|
|
2399
|
+
this.#e.isLoading() ? this.setCountry(Q.autoCountry) : this.#d = Q.autoCountry, this.#e.setLoading(!1), this.#g.resolve();
|
|
2373
2400
|
}
|
|
2374
2401
|
}
|
|
2375
|
-
#
|
|
2376
|
-
if (!this.#
|
|
2377
|
-
this.#
|
|
2402
|
+
#ce() {
|
|
2403
|
+
if (!this.#f) {
|
|
2404
|
+
this.#g?.reject();
|
|
2378
2405
|
return;
|
|
2379
2406
|
}
|
|
2380
|
-
this.#
|
|
2407
|
+
this.#C(!0), this.#e.setLoading(!1), this.#g?.reject();
|
|
2381
2408
|
}
|
|
2382
|
-
#
|
|
2383
|
-
if (!this.#
|
|
2384
|
-
this.#
|
|
2409
|
+
#le() {
|
|
2410
|
+
if (!this.#f) {
|
|
2411
|
+
this.#_?.resolve();
|
|
2385
2412
|
return;
|
|
2386
2413
|
}
|
|
2387
2414
|
if (!Q.utils) {
|
|
2388
|
-
this.#
|
|
2415
|
+
this.#_?.resolve();
|
|
2389
2416
|
return;
|
|
2390
2417
|
}
|
|
2391
|
-
let e = this.#
|
|
2392
|
-
e && this.#
|
|
2418
|
+
let e = this.#v();
|
|
2419
|
+
e && this.#W(e), this.#l && (this.#Z(), this.#X()), this.#_?.resolve();
|
|
2393
2420
|
}
|
|
2394
|
-
#
|
|
2395
|
-
if (!this.#
|
|
2396
|
-
this.#
|
|
2421
|
+
#ue(e) {
|
|
2422
|
+
if (!this.#f) {
|
|
2423
|
+
this.#_?.reject(e);
|
|
2397
2424
|
return;
|
|
2398
2425
|
}
|
|
2399
|
-
this.#
|
|
2426
|
+
this.#_?.reject(e);
|
|
2400
2427
|
}
|
|
2401
2428
|
destroy() {
|
|
2402
|
-
this.#
|
|
2429
|
+
this.#f && (this.#f = !1, this.#t.allowDropdown && this.#$(!0), this.#p.abort(), this.#e.destroy(), Q.instances.delete(String(this.id)));
|
|
2403
2430
|
}
|
|
2404
2431
|
isActive() {
|
|
2405
|
-
return this.#
|
|
2432
|
+
return this.#f;
|
|
2406
2433
|
}
|
|
2407
2434
|
getExtension() {
|
|
2408
|
-
return this.#
|
|
2435
|
+
return this.#f ? (X("getExtension"), Q.utils.getExtension(this.#re(), this.#l?.iso2)) : "";
|
|
2409
2436
|
}
|
|
2410
2437
|
getNumber(e) {
|
|
2411
|
-
if (!this.#
|
|
2438
|
+
if (!this.#f) return "";
|
|
2412
2439
|
X("getNumber");
|
|
2413
|
-
let t = this.#
|
|
2414
|
-
return this.#
|
|
2440
|
+
let t = this.#l?.iso2, n = this.#re(), r = Q.utils.formatNumber(n, t, e);
|
|
2441
|
+
return this.#m.denormalise(r);
|
|
2415
2442
|
}
|
|
2416
2443
|
getNumberType() {
|
|
2417
|
-
return this.#
|
|
2444
|
+
return this.#f ? (X("getNumberType"), Q.utils.getNumberType(this.#re(), this.#l?.iso2)) : S.UNKNOWN_NUMBER_TYPE;
|
|
2418
2445
|
}
|
|
2419
2446
|
getSelectedCountryData() {
|
|
2420
|
-
return this.#
|
|
2447
|
+
return this.#ae();
|
|
2421
2448
|
}
|
|
2422
2449
|
getValidationError() {
|
|
2423
|
-
if (!this.#
|
|
2450
|
+
if (!this.#f) return S.UNKNOWN_VALIDATION_ERROR;
|
|
2424
2451
|
X("getValidationError");
|
|
2425
|
-
let e = this.#
|
|
2426
|
-
return Q.utils.getValidationError(this.#
|
|
2452
|
+
let e = this.#l?.iso2;
|
|
2453
|
+
return Q.utils.getValidationError(this.#re(), e);
|
|
2427
2454
|
}
|
|
2428
2455
|
isValidNumber() {
|
|
2429
|
-
if (!this.#
|
|
2456
|
+
if (!this.#f) return null;
|
|
2430
2457
|
X("isValidNumber");
|
|
2431
|
-
let e = this.#
|
|
2458
|
+
let e = this.#l?.dialCode, t = this.#l?.iso2, n = this.#re(), r = Q.utils.getCoreNumber(n, t);
|
|
2432
2459
|
if (r) {
|
|
2433
2460
|
if (e === T.DIAL_CODE && r[0] === T.MOBILE_PREFIX && r.length !== T.MOBILE_CORE_LENGTH) return !1;
|
|
2434
2461
|
if (!b.ALPHA_UNICODE.test(n) && e) {
|
|
@@ -2436,57 +2463,57 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
2436
2463
|
if (r.length > t) return !1;
|
|
2437
2464
|
}
|
|
2438
2465
|
}
|
|
2439
|
-
return this.#
|
|
2466
|
+
return this.#de("possible");
|
|
2440
2467
|
}
|
|
2441
2468
|
isValidNumberPrecise() {
|
|
2442
|
-
return this.#
|
|
2469
|
+
return this.#f ? (X("isValidNumberPrecise"), this.#de("precise")) : null;
|
|
2443
2470
|
}
|
|
2444
|
-
#
|
|
2445
|
-
let { allowNumberExtensions: t, allowPhonewords: n, allowedNumberTypes: r } = this.#t, i = this.#
|
|
2446
|
-
return !this.#
|
|
2471
|
+
#de(e) {
|
|
2472
|
+
let { allowNumberExtensions: t, allowPhonewords: n, allowedNumberTypes: r } = this.#t, i = this.#l?.iso2, a = this.#re();
|
|
2473
|
+
return !this.#l && !Y(a) || !(e === "precise" ? Q.utils.isValidNumber : Q.utils.isPossibleNumber)(a, i, r) ? !1 : b.ALPHA_UNICODE.test(a) ? Q.utils.getExtension(a, i) ? t : n : !0;
|
|
2447
2474
|
}
|
|
2448
2475
|
setCountry(e) {
|
|
2449
|
-
if (!this.#
|
|
2476
|
+
if (!this.#f) return;
|
|
2450
2477
|
let t = e?.toLowerCase();
|
|
2451
2478
|
if (!m(t)) throw Error(`Invalid iso2 code: '${t}'`);
|
|
2452
|
-
let n = this.#
|
|
2479
|
+
let n = this.#l?.iso2;
|
|
2453
2480
|
if (e && t !== n || !e && n) {
|
|
2454
|
-
if (this.#
|
|
2455
|
-
let e = this.#
|
|
2456
|
-
this.#
|
|
2481
|
+
if (this.#Y(t), this.#ee(this.#l?.dialCode || ""), this.#t.formatOnDisplay) {
|
|
2482
|
+
let e = this.#v();
|
|
2483
|
+
this.#W(e);
|
|
2457
2484
|
}
|
|
2458
|
-
this.#
|
|
2485
|
+
this.#oe(), this.#H(g.INPUT, { isCountryChange: !0 });
|
|
2459
2486
|
}
|
|
2460
2487
|
}
|
|
2461
2488
|
setNumber(e) {
|
|
2462
|
-
if (!this.#
|
|
2463
|
-
let t = this.#
|
|
2464
|
-
this.#
|
|
2489
|
+
if (!this.#f) return;
|
|
2490
|
+
let t = this.#m.normalise(e), n = this.#G(t);
|
|
2491
|
+
this.#W(t), n && this.#oe(), this.#H(g.INPUT, { isSetNumber: !0 });
|
|
2465
2492
|
}
|
|
2466
2493
|
setPlaceholderNumberType(e) {
|
|
2467
|
-
this.#
|
|
2494
|
+
this.#f && (this.#t.placeholderNumberType = e, this.#Z());
|
|
2468
2495
|
}
|
|
2469
2496
|
setDisabled(e) {
|
|
2470
|
-
this.#
|
|
2497
|
+
this.#f && this.#e.setDisabled(e);
|
|
2471
2498
|
}
|
|
2472
2499
|
setReadonly(e) {
|
|
2473
|
-
this.#
|
|
2500
|
+
this.#f && this.#e.setReadonly(e);
|
|
2474
2501
|
}
|
|
2475
2502
|
static forEachInstance(t, ...n) {
|
|
2476
2503
|
let r = [...Q.instances.values()], i = n[0];
|
|
2477
2504
|
r.forEach((n) => {
|
|
2478
2505
|
if (n instanceof e) switch (t) {
|
|
2479
2506
|
case "handleUtilsLoaded":
|
|
2480
|
-
n.#
|
|
2507
|
+
n.#le();
|
|
2481
2508
|
break;
|
|
2482
2509
|
case "handleUtilsFailure":
|
|
2483
|
-
n.#
|
|
2510
|
+
n.#ue(i);
|
|
2484
2511
|
break;
|
|
2485
2512
|
case "handleAutoCountryLoaded":
|
|
2486
|
-
n.#
|
|
2513
|
+
n.#se();
|
|
2487
2514
|
break;
|
|
2488
2515
|
case "handleAutoCountryFailure":
|
|
2489
|
-
n.#
|
|
2516
|
+
n.#ce();
|
|
2490
2517
|
break;
|
|
2491
2518
|
}
|
|
2492
2519
|
});
|
|
@@ -2524,7 +2551,7 @@ var p = new Set(f.map((e) => e.iso2)), m = (e) => p.has(e), h = f, g = {
|
|
|
2524
2551
|
},
|
|
2525
2552
|
startedLoadingUtils: !1,
|
|
2526
2553
|
startedLoadingAutoCountry: !1,
|
|
2527
|
-
version: "27.3.
|
|
2554
|
+
version: "27.3.1"
|
|
2528
2555
|
}), $ = Q, Ce = /* @__PURE__ */ n({
|
|
2529
2556
|
inheritAttrs: !1,
|
|
2530
2557
|
__name: "IntlTelInput",
|