vue-tel-input 9.5.0 → 9.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/dist/index-z9l8C72U.js +4338 -0
- package/dist/vue-tel-input.js +291 -260
- package/dist/vue-tel-input.umd.cjs +18 -2
- package/package.json +1 -1
package/dist/vue-tel-input.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { parsePhoneNumberFromString as
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as ye, mergeModels as $, shallowRef as F, ref as be, useModel as ge, watch as O, nextTick as W, reactive as ve, computed as x, onMounted as Ce, resolveDirective as we, openBlock as h, createElementBlock as y, normalizeClass as v, withDirectives as L, withKeys as D, createElementVNode as I, unref as Q, createCommentVNode as k, toDisplayString as R, renderSlot as j, withModifiers as Oe, vModelText as Se, Fragment as ke, renderList as xe, vModelDynamic as De } from "vue";
|
|
2
|
+
import { parsePhoneNumberFromString as T } from "libphonenumber-js";
|
|
3
|
+
const Ie = [
|
|
4
4
|
[
|
|
5
5
|
"Afghanistan (افغانستان)",
|
|
6
6
|
"af",
|
|
@@ -1306,34 +1306,34 @@ const we = [
|
|
|
1306
1306
|
1,
|
|
1307
1307
|
["18"]
|
|
1308
1308
|
]
|
|
1309
|
-
],
|
|
1310
|
-
name:
|
|
1311
|
-
iso2:
|
|
1309
|
+
], Be = Ie.map(([t, i, u, d = 0, s = null]) => ({
|
|
1310
|
+
name: t,
|
|
1311
|
+
iso2: i.toUpperCase(),
|
|
1312
1312
|
dialCode: u,
|
|
1313
1313
|
priority: d,
|
|
1314
1314
|
areaCodes: s
|
|
1315
1315
|
}));
|
|
1316
|
-
function
|
|
1317
|
-
return fetch("https://ip2c.org/s").then((
|
|
1318
|
-
const
|
|
1319
|
-
if (!
|
|
1316
|
+
function Me() {
|
|
1317
|
+
return fetch("https://ip2c.org/s").then((t) => t.text()).then((t) => {
|
|
1318
|
+
const i = (t || "").toString();
|
|
1319
|
+
if (!i || i[0] !== "1")
|
|
1320
1320
|
throw new Error("unable to fetch the country");
|
|
1321
|
-
return
|
|
1321
|
+
return i.substr(2, 2);
|
|
1322
1322
|
});
|
|
1323
1323
|
}
|
|
1324
|
-
function
|
|
1325
|
-
if (
|
|
1326
|
-
|
|
1327
|
-
else if ("createTextRange" in
|
|
1328
|
-
const u =
|
|
1329
|
-
u.collapse(!0), u.moveEnd("character",
|
|
1324
|
+
function Te(t, i) {
|
|
1325
|
+
if (t.setSelectionRange)
|
|
1326
|
+
t.focus(), t.setSelectionRange(i, i);
|
|
1327
|
+
else if ("createTextRange" in t && typeof t.createTextRange == "function") {
|
|
1328
|
+
const u = t.createTextRange();
|
|
1329
|
+
u.collapse(!0), u.moveEnd("character", i), u.moveStart("character", i), u.select();
|
|
1330
1330
|
}
|
|
1331
1331
|
}
|
|
1332
|
-
const
|
|
1332
|
+
const Ne = [
|
|
1333
1333
|
{
|
|
1334
1334
|
name: "allCountries",
|
|
1335
1335
|
type: Array,
|
|
1336
|
-
default:
|
|
1336
|
+
default: Be,
|
|
1337
1337
|
description: "All countries that are used in <code>libphonenumber-js</code>, can be overridden by this prop",
|
|
1338
1338
|
inDemo: !1
|
|
1339
1339
|
},
|
|
@@ -1378,6 +1378,13 @@ const xe = [
|
|
|
1378
1378
|
description: "Options for dropdown, see below",
|
|
1379
1379
|
inDemo: !1
|
|
1380
1380
|
},
|
|
1381
|
+
{
|
|
1382
|
+
name: "dropdownOptions.ariaLabel",
|
|
1383
|
+
default: "Country Code Selector",
|
|
1384
|
+
type: String,
|
|
1385
|
+
description: "Aria label for the country code selector dropdown",
|
|
1386
|
+
inDemo: !1
|
|
1387
|
+
},
|
|
1381
1388
|
{
|
|
1382
1389
|
name: "dropdownOptions.disabled",
|
|
1383
1390
|
default: !1,
|
|
@@ -1580,122 +1587,143 @@ const xe = [
|
|
|
1580
1587
|
type: Boolean,
|
|
1581
1588
|
description: "Only allow valid characters in a phone number (will also verify in <code>mounted</code>, so phone number with invalid characters will be shown as an empty string)",
|
|
1582
1589
|
inDemo: !1
|
|
1590
|
+
},
|
|
1591
|
+
{
|
|
1592
|
+
name: "strictValidation",
|
|
1593
|
+
default: !1,
|
|
1594
|
+
type: Boolean,
|
|
1595
|
+
description: "Use strict phone number validation with full metadata (libphonenumber-js/max). When false (default), uses minimal metadata for smaller bundle size. When true, validates phone number patterns more precisely but increases bundle size by ~145KB.",
|
|
1596
|
+
inDemo: !1
|
|
1583
1597
|
}
|
|
1584
|
-
],
|
|
1585
|
-
if (
|
|
1586
|
-
const [u, d] =
|
|
1587
|
-
|
|
1598
|
+
], _ = [...Ne].reduce((t, i) => {
|
|
1599
|
+
if (i.name.includes(".")) {
|
|
1600
|
+
const [u, d] = i.name.split(".");
|
|
1601
|
+
t[u] ? Object.assign(t[u], { [d]: i.default }) : Object.assign(t, { [u]: { [d]: i.default } });
|
|
1588
1602
|
} else
|
|
1589
|
-
Object.assign(
|
|
1590
|
-
return
|
|
1591
|
-
}, {}),
|
|
1592
|
-
options: {
|
|
1603
|
+
Object.assign(t, { [i.name]: i.default });
|
|
1604
|
+
return t;
|
|
1605
|
+
}, {}), G = {
|
|
1606
|
+
options: { ..._ }
|
|
1593
1607
|
};
|
|
1594
|
-
function
|
|
1595
|
-
const
|
|
1596
|
-
return typeof
|
|
1608
|
+
function c(t) {
|
|
1609
|
+
const i = G.options[t];
|
|
1610
|
+
return typeof i > "u" ? G.options[t] : i;
|
|
1611
|
+
}
|
|
1612
|
+
function B(t) {
|
|
1613
|
+
return t == null ? void 0 : t.toLowerCase();
|
|
1614
|
+
}
|
|
1615
|
+
function M(t) {
|
|
1616
|
+
return t == null ? void 0 : t.toUpperCase();
|
|
1617
|
+
}
|
|
1618
|
+
let C = null, V = null;
|
|
1619
|
+
async function Pe() {
|
|
1620
|
+
return C || V || (V = import("./index-z9l8C72U.js").then((t) => (C = t.parsePhoneNumberFromString, C)), V);
|
|
1597
1621
|
}
|
|
1598
|
-
function
|
|
1599
|
-
return
|
|
1622
|
+
function J(t, i, u = !1) {
|
|
1623
|
+
return u ? C ? i ? C(t, i) : C(t) : i ? T(t, i) : T(t) : i ? T(t, i) : T(t);
|
|
1600
1624
|
}
|
|
1601
|
-
function
|
|
1602
|
-
return
|
|
1625
|
+
function Z() {
|
|
1626
|
+
return C !== null;
|
|
1603
1627
|
}
|
|
1604
|
-
const
|
|
1605
|
-
beforeMount(
|
|
1606
|
-
if (typeof
|
|
1628
|
+
const Ee = {
|
|
1629
|
+
beforeMount(t, i, u) {
|
|
1630
|
+
if (typeof i.value != "function") {
|
|
1607
1631
|
const d = u.context.name;
|
|
1608
|
-
let s = `[Vue-click-outside:] provided expression ${
|
|
1632
|
+
let s = `[Vue-click-outside:] provided expression ${i.expression} is not a function, but has to be`;
|
|
1609
1633
|
d && (s += `Found in component ${d}`), console.warn(s);
|
|
1610
1634
|
}
|
|
1611
|
-
|
|
1635
|
+
t.clickOutsideEvent = function(d) {
|
|
1612
1636
|
const s = d.composedPath ? d.composedPath() : d.path;
|
|
1613
|
-
|
|
1614
|
-
}, document.body.addEventListener("click",
|
|
1637
|
+
t === d.target || t.contains(d.target) || s.includes(t) || i.value(d, t);
|
|
1638
|
+
}, document.body.addEventListener("click", t.clickOutsideEvent);
|
|
1615
1639
|
},
|
|
1616
|
-
unmounted(
|
|
1617
|
-
document.body.removeEventListener("click",
|
|
1640
|
+
unmounted(t) {
|
|
1641
|
+
document.body.removeEventListener("click", t.clickOutsideEvent);
|
|
1618
1642
|
}
|
|
1619
|
-
},
|
|
1643
|
+
}, Re = ["aria-label", "aria-expanded", "tabindex"], Ve = { class: "vti__selection" }, ze = {
|
|
1620
1644
|
key: 1,
|
|
1621
1645
|
class: "vti__country-code"
|
|
1622
|
-
},
|
|
1646
|
+
}, Ae = { class: "vti__dropdown-arrow" }, Fe = {
|
|
1623
1647
|
key: 0,
|
|
1624
1648
|
class: "vti__search_box_container"
|
|
1625
|
-
},
|
|
1649
|
+
}, Le = ["placeholder"], je = ["onClick", "onMousemove", "aria-selected"], Ge = { key: 1 }, qe = ["type", "autocomplete", "autofocus", "disabled", "id", "maxlength", "name", "placeholder", "readonly", "required", "tabindex", "value", "aria-describedby"], Ke = /* @__PURE__ */ ye({
|
|
1626
1650
|
name: "VueTelInput",
|
|
1627
1651
|
directives: {
|
|
1628
|
-
clickOutside:
|
|
1652
|
+
clickOutside: Ee
|
|
1629
1653
|
},
|
|
1630
1654
|
__name: "vue-tel-input",
|
|
1631
|
-
props: /* @__PURE__ */
|
|
1655
|
+
props: /* @__PURE__ */ $({
|
|
1632
1656
|
allCountries: {
|
|
1633
1657
|
type: Array,
|
|
1634
|
-
default: () =>
|
|
1658
|
+
default: () => c("allCountries")
|
|
1635
1659
|
},
|
|
1636
1660
|
autoFormat: {
|
|
1637
1661
|
type: Boolean,
|
|
1638
|
-
default: () =>
|
|
1662
|
+
default: () => c("autoFormat")
|
|
1639
1663
|
},
|
|
1640
1664
|
customValidate: {
|
|
1641
1665
|
type: [Boolean, RegExp],
|
|
1642
|
-
default: () =>
|
|
1666
|
+
default: () => c("customValidate")
|
|
1643
1667
|
},
|
|
1644
1668
|
defaultCountry: {
|
|
1645
1669
|
// Default country code, ie: 'AU'
|
|
1646
1670
|
// Will override the current country of user
|
|
1647
1671
|
type: [String, Number],
|
|
1648
|
-
default: () =>
|
|
1672
|
+
default: () => c("defaultCountry")
|
|
1649
1673
|
},
|
|
1650
1674
|
disabled: {
|
|
1651
1675
|
type: Boolean,
|
|
1652
|
-
default: () =>
|
|
1676
|
+
default: () => c("disabled")
|
|
1653
1677
|
},
|
|
1654
1678
|
autoDefaultCountry: {
|
|
1655
1679
|
type: Boolean,
|
|
1656
|
-
default: () =>
|
|
1680
|
+
default: () => c("autoDefaultCountry")
|
|
1657
1681
|
},
|
|
1658
1682
|
dropdownOptions: {
|
|
1659
1683
|
type: Object,
|
|
1660
|
-
default: () =>
|
|
1684
|
+
default: () => c("dropdownOptions")
|
|
1661
1685
|
},
|
|
1662
1686
|
ignoredCountries: {
|
|
1663
1687
|
type: Array,
|
|
1664
|
-
default: () =>
|
|
1688
|
+
default: () => c("ignoredCountries")
|
|
1665
1689
|
},
|
|
1666
1690
|
inputOptions: {
|
|
1667
1691
|
type: Object,
|
|
1668
|
-
default: () =>
|
|
1692
|
+
default: () => c("inputOptions")
|
|
1669
1693
|
},
|
|
1670
1694
|
invalidMsg: {
|
|
1671
1695
|
type: String,
|
|
1672
|
-
default: () =>
|
|
1696
|
+
default: () => c("invalidMsg")
|
|
1673
1697
|
},
|
|
1674
1698
|
mode: {
|
|
1675
1699
|
type: String,
|
|
1676
|
-
default: () =>
|
|
1700
|
+
default: () => c("mode")
|
|
1677
1701
|
},
|
|
1678
1702
|
onlyCountries: {
|
|
1679
1703
|
type: Array,
|
|
1680
|
-
default: () =>
|
|
1704
|
+
default: () => c("onlyCountries")
|
|
1681
1705
|
},
|
|
1682
1706
|
preferredCountries: {
|
|
1683
1707
|
type: Array,
|
|
1684
|
-
default: () =>
|
|
1708
|
+
default: () => c("preferredCountries")
|
|
1685
1709
|
},
|
|
1686
1710
|
validCharactersOnly: {
|
|
1687
1711
|
type: Boolean,
|
|
1688
|
-
default: () =>
|
|
1712
|
+
default: () => c("validCharactersOnly")
|
|
1689
1713
|
},
|
|
1690
1714
|
styleClasses: {
|
|
1691
1715
|
type: [String, Array, Object],
|
|
1692
|
-
default: () =>
|
|
1716
|
+
default: () => c("styleClasses")
|
|
1717
|
+
},
|
|
1718
|
+
strictValidation: {
|
|
1719
|
+
type: Boolean,
|
|
1720
|
+
default: () => c("strictValidation")
|
|
1693
1721
|
}
|
|
1694
1722
|
}, {
|
|
1695
1723
|
modelValue: { type: String },
|
|
1696
1724
|
modelModifiers: {}
|
|
1697
1725
|
}),
|
|
1698
|
-
emits: /* @__PURE__ */
|
|
1726
|
+
emits: /* @__PURE__ */ $([
|
|
1699
1727
|
"blur",
|
|
1700
1728
|
"close",
|
|
1701
1729
|
"country-changed",
|
|
@@ -1706,14 +1734,14 @@ const De = {
|
|
|
1706
1734
|
"space",
|
|
1707
1735
|
"validate"
|
|
1708
1736
|
], ["update:modelValue"]),
|
|
1709
|
-
setup(
|
|
1710
|
-
const d =
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
n.phone =
|
|
1737
|
+
setup(t, { expose: i, emit: u }) {
|
|
1738
|
+
const d = F(), s = F(), b = F(), f = u, a = t, q = be(Z()), S = ge(t, "modelValue");
|
|
1739
|
+
O(S, (e, o) => {
|
|
1740
|
+
ie() ? n.phone = e ?? "" : W(() => {
|
|
1741
|
+
n.phone = o ?? "", K();
|
|
1714
1742
|
});
|
|
1715
1743
|
});
|
|
1716
|
-
const n =
|
|
1744
|
+
const n = ve({
|
|
1717
1745
|
phone: "",
|
|
1718
1746
|
activeCountryCode: void 0,
|
|
1719
1747
|
open: !1,
|
|
@@ -1725,34 +1753,35 @@ const De = {
|
|
|
1725
1753
|
parsedPlaceholder: a.inputOptions.placeholder,
|
|
1726
1754
|
searchQuery: ""
|
|
1727
1755
|
});
|
|
1728
|
-
|
|
1729
|
-
e ? (
|
|
1756
|
+
O(() => n.open, (e) => {
|
|
1757
|
+
e ? (he(), f("open")) : f("close");
|
|
1730
1758
|
});
|
|
1731
|
-
const
|
|
1732
|
-
({ iso2: e }) => !a.ignoredCountries.includes(
|
|
1733
|
-
) : a.allCountries),
|
|
1734
|
-
|
|
1735
|
-
if (!e && (
|
|
1736
|
-
n.activeCountryCode =
|
|
1759
|
+
const N = x(() => a.onlyCountries.length ? a.allCountries.filter(({ iso2: e }) => a.onlyCountries.some((o) => M(o) === e)) : a.ignoredCountries.length ? a.allCountries.filter(
|
|
1760
|
+
({ iso2: e }) => !a.ignoredCountries.includes(M(e)) && !a.ignoredCountries.includes(B(e))
|
|
1761
|
+
) : a.allCountries), z = x(() => P(n.activeCountryCode));
|
|
1762
|
+
O(z, (e, o) => {
|
|
1763
|
+
if (!e && (o != null && o.iso2)) {
|
|
1764
|
+
n.activeCountryCode = o.iso2;
|
|
1737
1765
|
return;
|
|
1738
1766
|
}
|
|
1739
1767
|
e != null && e.iso2 && f("country-changed", e);
|
|
1740
1768
|
});
|
|
1741
|
-
const
|
|
1742
|
-
var
|
|
1743
|
-
const e =
|
|
1744
|
-
return e === "auto" ? (
|
|
1745
|
-
}),
|
|
1746
|
-
const
|
|
1769
|
+
const Y = x(() => {
|
|
1770
|
+
var o;
|
|
1771
|
+
const e = B(a.mode);
|
|
1772
|
+
return e === "auto" ? (o = n.phone) != null && o.startsWith("+") ? "international" : "national" : ["national", "international", "e.164", "rfc3966", "idd"].includes(e) ? e : (console.error('Invalid value of prop "mode"'), "international");
|
|
1773
|
+
}), g = x(() => {
|
|
1774
|
+
const o = [...ne(a.preferredCountries).map((p) => ({ ...p, preferred: !0 })), ...N.value];
|
|
1747
1775
|
if (!a.dropdownOptions.showSearchBox)
|
|
1748
|
-
return
|
|
1749
|
-
const
|
|
1750
|
-
return
|
|
1751
|
-
(
|
|
1776
|
+
return o;
|
|
1777
|
+
const r = n.searchQuery.toLowerCase().replace(/[~`!@#$%^&*()+={}\[\];:\'\"<>.,\/\\\?-_]/g, "");
|
|
1778
|
+
return o.filter(
|
|
1779
|
+
(p) => new RegExp(r, "i").test(p.name) || new RegExp(r, "i").test(p.iso2) || new RegExp(r, "i").test(p.dialCode)
|
|
1752
1780
|
);
|
|
1753
|
-
}),
|
|
1781
|
+
}), m = x(() => {
|
|
1754
1782
|
var l;
|
|
1755
|
-
|
|
1783
|
+
q.value;
|
|
1784
|
+
const e = n.phone.startsWith("+") ? J(n.phone, void 0, a.strictValidation) : J(n.phone, n.activeCountryCode, a.strictValidation), o = {
|
|
1756
1785
|
country: e == null ? void 0 : e.country,
|
|
1757
1786
|
countryCode: e == null ? void 0 : e.country,
|
|
1758
1787
|
formatted: n.phone,
|
|
@@ -1760,31 +1789,33 @@ const De = {
|
|
|
1760
1789
|
possible: (l = e == null ? void 0 : e.isPossible) == null ? void 0 : l.call(e),
|
|
1761
1790
|
nationalNumber: e == null ? void 0 : e.nationalNumber
|
|
1762
1791
|
};
|
|
1763
|
-
return
|
|
1764
|
-
...
|
|
1792
|
+
return o.valid && (o.formatted = e == null ? void 0 : e.format(M(Y.value))), e != null && e.country && (a.ignoredCountries.length || a.onlyCountries.length) && !P(e.country) && (o.valid = !1, o.possible = !1, e.country = null), e ? {
|
|
1793
|
+
...o,
|
|
1765
1794
|
...e
|
|
1766
|
-
} :
|
|
1795
|
+
} : o;
|
|
1767
1796
|
});
|
|
1768
|
-
|
|
1797
|
+
O(() => m.value.countryCode, (e) => {
|
|
1769
1798
|
e && (n.activeCountryCode = e);
|
|
1770
|
-
}),
|
|
1771
|
-
f("validate",
|
|
1772
|
-
}),
|
|
1773
|
-
!a.autoFormat || a.customValidate || (
|
|
1774
|
-
e && !
|
|
1799
|
+
}), O(() => m.value.valid, () => {
|
|
1800
|
+
f("validate", m.value);
|
|
1801
|
+
}), O(() => m.value.formatted, (e) => {
|
|
1802
|
+
!a.autoFormat || a.customValidate || (E(e), W(() => {
|
|
1803
|
+
e && !S.value && (n.phone = e);
|
|
1775
1804
|
}));
|
|
1776
|
-
}),
|
|
1777
|
-
|
|
1805
|
+
}), O(() => a.inputOptions.placeholder, X), Ce(() => {
|
|
1806
|
+
a.strictValidation && !Z() && Pe().then(() => {
|
|
1807
|
+
q.value = !0, f("validate", m.value);
|
|
1808
|
+
}), S.value && (n.phone = S.value.trim()), ae(), ee().then(() => {
|
|
1778
1809
|
var e;
|
|
1779
|
-
!n.phone && ((e = a.inputOptions) != null && e.showDialCode) && n.activeCountryCode && (n.phone = `+${n.activeCountryCode}`), f("validate",
|
|
1810
|
+
!n.phone && ((e = a.inputOptions) != null && e.showDialCode) && n.activeCountryCode && (n.phone = `+${n.activeCountryCode}`), f("validate", m.value);
|
|
1780
1811
|
}).catch(console.error).then(() => {
|
|
1781
1812
|
n.finishMounted = !0;
|
|
1782
1813
|
});
|
|
1783
1814
|
});
|
|
1784
|
-
function
|
|
1815
|
+
function X() {
|
|
1785
1816
|
n.parsedPlaceholder = a.inputOptions.placeholder;
|
|
1786
1817
|
}
|
|
1787
|
-
function
|
|
1818
|
+
function ee() {
|
|
1788
1819
|
return new Promise((e) => {
|
|
1789
1820
|
var l;
|
|
1790
1821
|
if (((l = n.phone) == null ? void 0 : l[0]) === "+") {
|
|
@@ -1793,278 +1824,278 @@ const De = {
|
|
|
1793
1824
|
}
|
|
1794
1825
|
if (a.defaultCountry) {
|
|
1795
1826
|
if (typeof a.defaultCountry == "string") {
|
|
1796
|
-
|
|
1827
|
+
w(a.defaultCountry), e();
|
|
1797
1828
|
return;
|
|
1798
1829
|
}
|
|
1799
1830
|
if (typeof a.defaultCountry == "number") {
|
|
1800
|
-
const
|
|
1801
|
-
if (
|
|
1802
|
-
|
|
1831
|
+
const r = te(a.defaultCountry);
|
|
1832
|
+
if (r) {
|
|
1833
|
+
w(r.iso2), e();
|
|
1803
1834
|
return;
|
|
1804
1835
|
}
|
|
1805
1836
|
}
|
|
1806
1837
|
}
|
|
1807
|
-
const
|
|
1808
|
-
a.autoDefaultCountry ?
|
|
1809
|
-
|
|
1810
|
-
}).catch((
|
|
1811
|
-
console.warn(
|
|
1838
|
+
const o = a.preferredCountries[0] || N.value[0];
|
|
1839
|
+
a.autoDefaultCountry ? Me().then((r) => {
|
|
1840
|
+
w(r || n.activeCountryCode);
|
|
1841
|
+
}).catch((r) => {
|
|
1842
|
+
console.warn(r), w(o);
|
|
1812
1843
|
}).then(() => {
|
|
1813
1844
|
e();
|
|
1814
|
-
}) : (
|
|
1845
|
+
}) : (w(o), e());
|
|
1815
1846
|
});
|
|
1816
1847
|
}
|
|
1817
|
-
function
|
|
1818
|
-
return e.map(
|
|
1848
|
+
function ne(e = []) {
|
|
1849
|
+
return e.map(P).filter(Boolean);
|
|
1819
1850
|
}
|
|
1820
|
-
function
|
|
1821
|
-
return
|
|
1851
|
+
function P(e = "") {
|
|
1852
|
+
return N.value.find((o) => o.iso2 === M(e));
|
|
1822
1853
|
}
|
|
1823
|
-
function
|
|
1824
|
-
return
|
|
1854
|
+
function te(e) {
|
|
1855
|
+
return N.value.find((o) => Number(o.dialCode) === e);
|
|
1825
1856
|
}
|
|
1826
|
-
function
|
|
1827
|
-
const l = n.selectedIndex === e,
|
|
1857
|
+
function oe(e, o) {
|
|
1858
|
+
const l = n.selectedIndex === e, r = e === a.preferredCountries.length - 1, p = a.preferredCountries.some((A) => M(A) === o);
|
|
1828
1859
|
return {
|
|
1829
1860
|
highlighted: l,
|
|
1830
|
-
"last-preferred":
|
|
1831
|
-
preferred:
|
|
1861
|
+
"last-preferred": r,
|
|
1862
|
+
preferred: p
|
|
1832
1863
|
};
|
|
1833
1864
|
}
|
|
1834
|
-
function
|
|
1835
|
-
var l,
|
|
1836
|
-
let
|
|
1837
|
-
if (typeof
|
|
1838
|
-
if (((l = n.phone) == null ? void 0 : l[0]) === "+" &&
|
|
1839
|
-
n.activeCountryCode =
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
)) == null ? void 0 :
|
|
1865
|
+
function w(e) {
|
|
1866
|
+
var l, r, p;
|
|
1867
|
+
let o = e;
|
|
1868
|
+
if (typeof o == "string" && (o = P(o)), !!o) {
|
|
1869
|
+
if (((l = n.phone) == null ? void 0 : l[0]) === "+" && o.iso2 && m.value.nationalNumber) {
|
|
1870
|
+
n.activeCountryCode = o.iso2, n.phone = ((r = T(
|
|
1871
|
+
m.value.nationalNumber,
|
|
1872
|
+
o.iso2
|
|
1873
|
+
)) == null ? void 0 : r.formatInternational()) ?? "";
|
|
1843
1874
|
return;
|
|
1844
1875
|
}
|
|
1845
|
-
if ((
|
|
1846
|
-
n.phone = `+${
|
|
1876
|
+
if ((p = a.inputOptions) != null && p.showDialCode && o) {
|
|
1877
|
+
n.phone = `+${o.dialCode}`, n.activeCountryCode = o.iso2;
|
|
1847
1878
|
return;
|
|
1848
1879
|
}
|
|
1849
|
-
n.activeCountryCode =
|
|
1880
|
+
n.activeCountryCode = o.iso2, E(n.phone);
|
|
1850
1881
|
}
|
|
1851
1882
|
}
|
|
1852
|
-
function
|
|
1883
|
+
function ae() {
|
|
1853
1884
|
const e = n.phone;
|
|
1854
1885
|
if (a.validCharactersOnly) {
|
|
1855
|
-
const
|
|
1856
|
-
n.phone =
|
|
1886
|
+
const o = n.phone.match(/[()\-+0-9\s]*/g);
|
|
1887
|
+
n.phone = o.join("");
|
|
1857
1888
|
}
|
|
1858
1889
|
if (a.customValidate && a.customValidate instanceof RegExp) {
|
|
1859
|
-
const
|
|
1860
|
-
n.phone =
|
|
1890
|
+
const o = n.phone.match(a.customValidate);
|
|
1891
|
+
n.phone = o.join("");
|
|
1861
1892
|
}
|
|
1862
|
-
e !== n.phone &&
|
|
1893
|
+
e !== n.phone && E(n.phone);
|
|
1863
1894
|
}
|
|
1864
|
-
function
|
|
1865
|
-
return a.validCharactersOnly && !/^[()\-+0-9\s]*$/.test(n.phone) ? !1 : a.customValidate ?
|
|
1895
|
+
function ie() {
|
|
1896
|
+
return a.validCharactersOnly && !/^[()\-+0-9\s]*$/.test(n.phone) ? !1 : a.customValidate ? re() : !0;
|
|
1866
1897
|
}
|
|
1867
|
-
function
|
|
1898
|
+
function re() {
|
|
1868
1899
|
return a.customValidate instanceof RegExp ? a.customValidate.test(n.phone) : !1;
|
|
1869
1900
|
}
|
|
1870
|
-
function
|
|
1901
|
+
function K() {
|
|
1871
1902
|
var e;
|
|
1872
|
-
(e =
|
|
1903
|
+
(e = b.value) == null || e.setCustomValidity(m.value.valid ? "" : a.invalidMsg), E(n.phone);
|
|
1873
1904
|
}
|
|
1874
|
-
function
|
|
1875
|
-
|
|
1905
|
+
function E(e) {
|
|
1906
|
+
S.value = e, f("on-input", e, m.value, b.value);
|
|
1876
1907
|
}
|
|
1877
|
-
function
|
|
1908
|
+
function se(e) {
|
|
1878
1909
|
f("blur", e);
|
|
1879
1910
|
}
|
|
1880
|
-
function
|
|
1881
|
-
|
|
1911
|
+
function le(e) {
|
|
1912
|
+
Te(b.value, n.phone.length), f("focus", e);
|
|
1882
1913
|
}
|
|
1883
|
-
function
|
|
1914
|
+
function de(e) {
|
|
1884
1915
|
f("enter", e);
|
|
1885
1916
|
}
|
|
1886
|
-
function
|
|
1917
|
+
function ue(e) {
|
|
1887
1918
|
f("space", e);
|
|
1888
1919
|
}
|
|
1889
|
-
function
|
|
1920
|
+
function ce() {
|
|
1890
1921
|
var e;
|
|
1891
|
-
(e =
|
|
1922
|
+
(e = b.value) == null || e.focus();
|
|
1892
1923
|
}
|
|
1893
|
-
function
|
|
1924
|
+
function pe() {
|
|
1894
1925
|
var e;
|
|
1895
|
-
(e =
|
|
1926
|
+
(e = b.value) == null || e.blur();
|
|
1896
1927
|
}
|
|
1897
|
-
function
|
|
1928
|
+
function H() {
|
|
1898
1929
|
a.disabled || a.dropdownOptions.disabled || (n.searchQuery = "", n.open = !n.open);
|
|
1899
1930
|
}
|
|
1900
|
-
function
|
|
1931
|
+
function fe() {
|
|
1901
1932
|
n.open = !1;
|
|
1902
1933
|
}
|
|
1903
|
-
function
|
|
1934
|
+
function me(e) {
|
|
1904
1935
|
if (e.keyCode === 40) {
|
|
1905
|
-
e.preventDefault(), n.open = !0, n.selectedIndex === null ? n.selectedIndex = 0 : n.selectedIndex = Math.min(
|
|
1906
|
-
const
|
|
1907
|
-
|
|
1936
|
+
e.preventDefault(), n.open = !0, n.selectedIndex === null ? n.selectedIndex = 0 : n.selectedIndex = Math.min(g.value.length - 1, n.selectedIndex + 1);
|
|
1937
|
+
const o = s.value.children[n.selectedIndex];
|
|
1938
|
+
o.focus(), o.offsetTop + o.clientHeight > s.value.scrollTop + s.value.clientHeight && (s.value.scrollTop = o.offsetTop - s.value.clientHeight + o.clientHeight);
|
|
1908
1939
|
} else if (e.keyCode === 38) {
|
|
1909
|
-
e.preventDefault(), n.open = !0, n.selectedIndex === null ? n.selectedIndex =
|
|
1910
|
-
const
|
|
1911
|
-
|
|
1940
|
+
e.preventDefault(), n.open = !0, n.selectedIndex === null ? n.selectedIndex = g.value.length - 1 : n.selectedIndex = Math.max(0, n.selectedIndex - 1);
|
|
1941
|
+
const o = s.value.children[n.selectedIndex];
|
|
1942
|
+
o.focus(), o.offsetTop < s.value.scrollTop && (s.value.scrollTop = o.offsetTop);
|
|
1912
1943
|
} else if (e.keyCode === 13)
|
|
1913
|
-
n.selectedIndex !== null &&
|
|
1944
|
+
n.selectedIndex !== null && w(g.value[n.selectedIndex]), n.open = !n.open;
|
|
1914
1945
|
else if (n.open) {
|
|
1915
1946
|
n.typeToFindInput += e.key, clearTimeout(n.typeToFindTimer), n.typeToFindTimer = setTimeout(() => {
|
|
1916
1947
|
n.typeToFindInput = "";
|
|
1917
1948
|
}, 700);
|
|
1918
|
-
const
|
|
1919
|
-
if (
|
|
1920
|
-
n.selectedIndex = a.preferredCountries.length +
|
|
1921
|
-
const l = s.value.children[n.selectedIndex],
|
|
1922
|
-
(
|
|
1949
|
+
const o = g.value.slice(a.preferredCountries.length).findIndex((l) => B(l.name).startsWith(n.typeToFindInput));
|
|
1950
|
+
if (o >= 0) {
|
|
1951
|
+
n.selectedIndex = a.preferredCountries.length + o;
|
|
1952
|
+
const l = s.value.children[n.selectedIndex], r = l.offsetTop < s.value.scrollTop, p = l.offsetTop + l.clientHeight > s.value.scrollTop + s.value.clientHeight;
|
|
1953
|
+
(r || p) && (s.value.scrollTop = l.offsetTop - s.value.clientHeight / 2);
|
|
1923
1954
|
}
|
|
1924
1955
|
}
|
|
1925
1956
|
}
|
|
1926
|
-
function
|
|
1927
|
-
n.selectedIndex =
|
|
1957
|
+
function U() {
|
|
1958
|
+
n.selectedIndex = g.value.map((e) => e.iso2).indexOf(n.activeCountryCode), n.open = !1;
|
|
1928
1959
|
}
|
|
1929
|
-
function
|
|
1960
|
+
function he() {
|
|
1930
1961
|
window.innerHeight - d.value.getBoundingClientRect().bottom > 200 ? n.dropdownOpenDirection = "below" : n.dropdownOpenDirection = "above";
|
|
1931
1962
|
}
|
|
1932
|
-
return
|
|
1933
|
-
focus:
|
|
1934
|
-
blur:
|
|
1935
|
-
}), (e,
|
|
1936
|
-
const l =
|
|
1937
|
-
return
|
|
1963
|
+
return i({
|
|
1964
|
+
focus: ce,
|
|
1965
|
+
blur: pe
|
|
1966
|
+
}), (e, o) => {
|
|
1967
|
+
const l = we("click-outside");
|
|
1968
|
+
return h(), y("div", {
|
|
1938
1969
|
ref_key: "refRoot",
|
|
1939
1970
|
ref: d,
|
|
1940
|
-
class:
|
|
1971
|
+
class: v(["vue-tel-input", t.styleClasses, { disabled: t.disabled }])
|
|
1941
1972
|
}, [
|
|
1942
|
-
|
|
1943
|
-
"aria-label":
|
|
1973
|
+
L((h(), y("div", {
|
|
1974
|
+
"aria-label": t.dropdownOptions.ariaLabel,
|
|
1944
1975
|
"aria-haspopup": "listbox",
|
|
1945
1976
|
"aria-expanded": n.open,
|
|
1946
1977
|
role: "button",
|
|
1947
|
-
class:
|
|
1948
|
-
tabindex:
|
|
1978
|
+
class: v(["vti__dropdown", { open: n.open, disabled: t.dropdownOptions.disabled }]),
|
|
1979
|
+
tabindex: t.dropdownOptions.tabindex,
|
|
1949
1980
|
onKeydown: [
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1981
|
+
me,
|
|
1982
|
+
D(H, ["space"]),
|
|
1983
|
+
D(U, ["esc"]),
|
|
1984
|
+
D(U, ["tab"])
|
|
1954
1985
|
],
|
|
1955
|
-
onClick:
|
|
1986
|
+
onClick: H
|
|
1956
1987
|
}, [
|
|
1957
|
-
|
|
1958
|
-
|
|
1988
|
+
I("span", Ve, [
|
|
1989
|
+
t.dropdownOptions.showFlags ? (h(), y("span", {
|
|
1959
1990
|
key: 0,
|
|
1960
|
-
class:
|
|
1961
|
-
}, null, 2)) :
|
|
1962
|
-
|
|
1963
|
-
|
|
1991
|
+
class: v(["vti__flag", Q(B)(n.activeCountryCode)])
|
|
1992
|
+
}, null, 2)) : k("", !0),
|
|
1993
|
+
t.dropdownOptions.showDialCodeInSelection ? (h(), y("span", ze, " +" + R(z.value && z.value.dialCode), 1)) : k("", !0),
|
|
1994
|
+
j(e.$slots, "arrow-icon", {
|
|
1964
1995
|
open: n.open
|
|
1965
1996
|
}, () => [
|
|
1966
|
-
|
|
1997
|
+
I("span", Ae, R(n.open ? "▲" : "▼"), 1)
|
|
1967
1998
|
])
|
|
1968
1999
|
]),
|
|
1969
|
-
n.open ? (
|
|
2000
|
+
n.open ? (h(), y("ul", {
|
|
1970
2001
|
key: 0,
|
|
1971
2002
|
ref_key: "refList",
|
|
1972
2003
|
ref: s,
|
|
1973
|
-
class:
|
|
2004
|
+
class: v(["vti__dropdown-list", n.dropdownOpenDirection]),
|
|
1974
2005
|
role: "listbox"
|
|
1975
2006
|
}, [
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
class:
|
|
2007
|
+
t.dropdownOptions.showSearchBox ? (h(), y("div", Fe, [
|
|
2008
|
+
j(e.$slots, "search-icon"),
|
|
2009
|
+
L(I("input", {
|
|
2010
|
+
class: v(["vti__input", "vti__search_box"]),
|
|
1980
2011
|
"aria-label": "Search by country name or country code",
|
|
1981
|
-
placeholder:
|
|
2012
|
+
placeholder: t.dropdownOptions.searchBoxPlaceholder || (g.value.length ? g.value[0].name : ""),
|
|
1982
2013
|
type: "text",
|
|
1983
|
-
"onUpdate:modelValue":
|
|
1984
|
-
onClick:
|
|
2014
|
+
"onUpdate:modelValue": o[0] || (o[0] = (r) => n.searchQuery = r),
|
|
2015
|
+
onClick: o[1] || (o[1] = Oe(() => {
|
|
1985
2016
|
}, ["stop"]))
|
|
1986
|
-
}, null, 8,
|
|
1987
|
-
[
|
|
2017
|
+
}, null, 8, Le), [
|
|
2018
|
+
[Se, n.searchQuery]
|
|
1988
2019
|
])
|
|
1989
|
-
])) :
|
|
1990
|
-
(
|
|
2020
|
+
])) : k("", !0),
|
|
2021
|
+
(h(!0), y(ke, null, xe(g.value, (r, p) => (h(), y("li", {
|
|
1991
2022
|
role: "option",
|
|
1992
|
-
class:
|
|
1993
|
-
key:
|
|
2023
|
+
class: v(["vti__dropdown-item", oe(p, r.iso2)]),
|
|
2024
|
+
key: r.iso2 + (r.preferred ? "-preferred" : ""),
|
|
1994
2025
|
tabindex: "-1",
|
|
1995
|
-
onClick: (A) =>
|
|
1996
|
-
onMousemove: (A) => n.selectedIndex =
|
|
1997
|
-
"aria-selected": n.activeCountryCode ===
|
|
2026
|
+
onClick: (A) => w(r),
|
|
2027
|
+
onMousemove: (A) => n.selectedIndex = p,
|
|
2028
|
+
"aria-selected": n.activeCountryCode === r.iso2 && !r.preferred
|
|
1998
2029
|
}, [
|
|
1999
|
-
|
|
2030
|
+
t.dropdownOptions.showFlags ? (h(), y("span", {
|
|
2000
2031
|
key: 0,
|
|
2001
|
-
class:
|
|
2002
|
-
}, null, 2)) :
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
], 42,
|
|
2006
|
-
], 2)) :
|
|
2007
|
-
], 42,
|
|
2008
|
-
[l,
|
|
2032
|
+
class: v(["vti__flag", Q(B)(r.iso2)])
|
|
2033
|
+
}, null, 2)) : k("", !0),
|
|
2034
|
+
I("strong", null, R(r.name), 1),
|
|
2035
|
+
t.dropdownOptions.showDialCodeInList ? (h(), y("span", Ge, " +" + R(r.dialCode), 1)) : k("", !0)
|
|
2036
|
+
], 42, je))), 128))
|
|
2037
|
+
], 2)) : k("", !0)
|
|
2038
|
+
], 42, Re)), [
|
|
2039
|
+
[l, fe]
|
|
2009
2040
|
]),
|
|
2010
|
-
|
|
2011
|
-
"onUpdate:modelValue":
|
|
2041
|
+
L(I("input", {
|
|
2042
|
+
"onUpdate:modelValue": o[2] || (o[2] = (r) => n.phone = r),
|
|
2012
2043
|
ref_key: "refInput",
|
|
2013
|
-
ref:
|
|
2014
|
-
type:
|
|
2015
|
-
autocomplete:
|
|
2016
|
-
autofocus:
|
|
2017
|
-
class:
|
|
2018
|
-
disabled:
|
|
2019
|
-
id:
|
|
2020
|
-
maxlength:
|
|
2021
|
-
name:
|
|
2044
|
+
ref: b,
|
|
2045
|
+
type: t.inputOptions.type,
|
|
2046
|
+
autocomplete: t.inputOptions.autocomplete,
|
|
2047
|
+
autofocus: t.inputOptions.autofocus,
|
|
2048
|
+
class: v(["vti__input", "vti__phone", t.inputOptions.styleClasses]),
|
|
2049
|
+
disabled: t.disabled,
|
|
2050
|
+
id: t.inputOptions.id,
|
|
2051
|
+
maxlength: t.inputOptions.maxlength,
|
|
2052
|
+
name: t.inputOptions.name,
|
|
2022
2053
|
placeholder: n.parsedPlaceholder,
|
|
2023
|
-
readonly:
|
|
2024
|
-
required:
|
|
2025
|
-
tabindex:
|
|
2026
|
-
value:
|
|
2027
|
-
"aria-describedby":
|
|
2028
|
-
onBlur:
|
|
2029
|
-
onFocus:
|
|
2030
|
-
onInput:
|
|
2054
|
+
readonly: t.inputOptions.readonly,
|
|
2055
|
+
required: t.inputOptions.required,
|
|
2056
|
+
tabindex: t.inputOptions.tabindex,
|
|
2057
|
+
value: S.value,
|
|
2058
|
+
"aria-describedby": t.inputOptions["aria-describedby"],
|
|
2059
|
+
onBlur: se,
|
|
2060
|
+
onFocus: le,
|
|
2061
|
+
onInput: K,
|
|
2031
2062
|
onKeyup: [
|
|
2032
|
-
|
|
2033
|
-
|
|
2063
|
+
D(de, ["enter"]),
|
|
2064
|
+
D(ue, ["space"])
|
|
2034
2065
|
]
|
|
2035
|
-
}, null, 42,
|
|
2036
|
-
[
|
|
2066
|
+
}, null, 42, qe), [
|
|
2067
|
+
[De, n.phone]
|
|
2037
2068
|
]),
|
|
2038
|
-
|
|
2069
|
+
j(e.$slots, "icon-right")
|
|
2039
2070
|
], 2);
|
|
2040
2071
|
};
|
|
2041
2072
|
}
|
|
2042
|
-
}),
|
|
2043
|
-
install(
|
|
2073
|
+
}), $e = {
|
|
2074
|
+
install(t, i = {}) {
|
|
2044
2075
|
const {
|
|
2045
2076
|
dropdownOptions: u,
|
|
2046
2077
|
inputOptions: d,
|
|
2047
2078
|
...s
|
|
2048
|
-
} =
|
|
2049
|
-
dropdownOptions:
|
|
2079
|
+
} = i, {
|
|
2080
|
+
dropdownOptions: b,
|
|
2050
2081
|
inputOptions: f,
|
|
2051
2082
|
...a
|
|
2052
|
-
} =
|
|
2053
|
-
|
|
2083
|
+
} = _;
|
|
2084
|
+
G.options = {
|
|
2054
2085
|
inputOptions: {
|
|
2055
2086
|
...f,
|
|
2056
2087
|
...d
|
|
2057
2088
|
},
|
|
2058
2089
|
dropdownOptions: {
|
|
2059
|
-
...
|
|
2090
|
+
...b,
|
|
2060
2091
|
...u
|
|
2061
2092
|
},
|
|
2062
2093
|
...a,
|
|
2063
2094
|
...s
|
|
2064
|
-
},
|
|
2095
|
+
}, t.component("vue-tel-input", Ke);
|
|
2065
2096
|
}
|
|
2066
2097
|
};
|
|
2067
2098
|
export {
|
|
2068
|
-
|
|
2069
|
-
|
|
2099
|
+
Ke as VueTelInput,
|
|
2100
|
+
$e as default
|
|
2070
2101
|
};
|