vue-tel-input 9.5.1 → 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 +276 -252
- package/dist/vue-tel-input.umd.cjs +18 -2
- package/package.json +2 -2
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
|
},
|
|
@@ -1587,122 +1587,143 @@ const De = [
|
|
|
1587
1587
|
type: Boolean,
|
|
1588
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)",
|
|
1589
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
|
|
1590
1597
|
}
|
|
1591
|
-
],
|
|
1592
|
-
if (
|
|
1593
|
-
const [u, d] =
|
|
1594
|
-
|
|
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 } });
|
|
1595
1602
|
} else
|
|
1596
|
-
Object.assign(
|
|
1597
|
-
return
|
|
1598
|
-
}, {}),
|
|
1599
|
-
options: {
|
|
1603
|
+
Object.assign(t, { [i.name]: i.default });
|
|
1604
|
+
return t;
|
|
1605
|
+
}, {}), G = {
|
|
1606
|
+
options: { ..._ }
|
|
1600
1607
|
};
|
|
1601
|
-
function
|
|
1602
|
-
const
|
|
1603
|
-
return typeof
|
|
1608
|
+
function c(t) {
|
|
1609
|
+
const i = G.options[t];
|
|
1610
|
+
return typeof i > "u" ? G.options[t] : i;
|
|
1604
1611
|
}
|
|
1605
|
-
function
|
|
1606
|
-
return
|
|
1612
|
+
function B(t) {
|
|
1613
|
+
return t == null ? void 0 : t.toLowerCase();
|
|
1607
1614
|
}
|
|
1608
|
-
function
|
|
1609
|
-
return
|
|
1615
|
+
function M(t) {
|
|
1616
|
+
return t == null ? void 0 : t.toUpperCase();
|
|
1610
1617
|
}
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
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);
|
|
1621
|
+
}
|
|
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);
|
|
1624
|
+
}
|
|
1625
|
+
function Z() {
|
|
1626
|
+
return C !== null;
|
|
1627
|
+
}
|
|
1628
|
+
const Ee = {
|
|
1629
|
+
beforeMount(t, i, u) {
|
|
1630
|
+
if (typeof i.value != "function") {
|
|
1614
1631
|
const d = u.context.name;
|
|
1615
|
-
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`;
|
|
1616
1633
|
d && (s += `Found in component ${d}`), console.warn(s);
|
|
1617
1634
|
}
|
|
1618
|
-
|
|
1635
|
+
t.clickOutsideEvent = function(d) {
|
|
1619
1636
|
const s = d.composedPath ? d.composedPath() : d.path;
|
|
1620
|
-
|
|
1621
|
-
}, 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);
|
|
1622
1639
|
},
|
|
1623
|
-
unmounted(
|
|
1624
|
-
document.body.removeEventListener("click",
|
|
1640
|
+
unmounted(t) {
|
|
1641
|
+
document.body.removeEventListener("click", t.clickOutsideEvent);
|
|
1625
1642
|
}
|
|
1626
|
-
},
|
|
1643
|
+
}, Re = ["aria-label", "aria-expanded", "tabindex"], Ve = { class: "vti__selection" }, ze = {
|
|
1627
1644
|
key: 1,
|
|
1628
1645
|
class: "vti__country-code"
|
|
1629
|
-
},
|
|
1646
|
+
}, Ae = { class: "vti__dropdown-arrow" }, Fe = {
|
|
1630
1647
|
key: 0,
|
|
1631
1648
|
class: "vti__search_box_container"
|
|
1632
|
-
},
|
|
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({
|
|
1633
1650
|
name: "VueTelInput",
|
|
1634
1651
|
directives: {
|
|
1635
|
-
clickOutside:
|
|
1652
|
+
clickOutside: Ee
|
|
1636
1653
|
},
|
|
1637
1654
|
__name: "vue-tel-input",
|
|
1638
|
-
props: /* @__PURE__ */
|
|
1655
|
+
props: /* @__PURE__ */ $({
|
|
1639
1656
|
allCountries: {
|
|
1640
1657
|
type: Array,
|
|
1641
|
-
default: () =>
|
|
1658
|
+
default: () => c("allCountries")
|
|
1642
1659
|
},
|
|
1643
1660
|
autoFormat: {
|
|
1644
1661
|
type: Boolean,
|
|
1645
|
-
default: () =>
|
|
1662
|
+
default: () => c("autoFormat")
|
|
1646
1663
|
},
|
|
1647
1664
|
customValidate: {
|
|
1648
1665
|
type: [Boolean, RegExp],
|
|
1649
|
-
default: () =>
|
|
1666
|
+
default: () => c("customValidate")
|
|
1650
1667
|
},
|
|
1651
1668
|
defaultCountry: {
|
|
1652
1669
|
// Default country code, ie: 'AU'
|
|
1653
1670
|
// Will override the current country of user
|
|
1654
1671
|
type: [String, Number],
|
|
1655
|
-
default: () =>
|
|
1672
|
+
default: () => c("defaultCountry")
|
|
1656
1673
|
},
|
|
1657
1674
|
disabled: {
|
|
1658
1675
|
type: Boolean,
|
|
1659
|
-
default: () =>
|
|
1676
|
+
default: () => c("disabled")
|
|
1660
1677
|
},
|
|
1661
1678
|
autoDefaultCountry: {
|
|
1662
1679
|
type: Boolean,
|
|
1663
|
-
default: () =>
|
|
1680
|
+
default: () => c("autoDefaultCountry")
|
|
1664
1681
|
},
|
|
1665
1682
|
dropdownOptions: {
|
|
1666
1683
|
type: Object,
|
|
1667
|
-
default: () =>
|
|
1684
|
+
default: () => c("dropdownOptions")
|
|
1668
1685
|
},
|
|
1669
1686
|
ignoredCountries: {
|
|
1670
1687
|
type: Array,
|
|
1671
|
-
default: () =>
|
|
1688
|
+
default: () => c("ignoredCountries")
|
|
1672
1689
|
},
|
|
1673
1690
|
inputOptions: {
|
|
1674
1691
|
type: Object,
|
|
1675
|
-
default: () =>
|
|
1692
|
+
default: () => c("inputOptions")
|
|
1676
1693
|
},
|
|
1677
1694
|
invalidMsg: {
|
|
1678
1695
|
type: String,
|
|
1679
|
-
default: () =>
|
|
1696
|
+
default: () => c("invalidMsg")
|
|
1680
1697
|
},
|
|
1681
1698
|
mode: {
|
|
1682
1699
|
type: String,
|
|
1683
|
-
default: () =>
|
|
1700
|
+
default: () => c("mode")
|
|
1684
1701
|
},
|
|
1685
1702
|
onlyCountries: {
|
|
1686
1703
|
type: Array,
|
|
1687
|
-
default: () =>
|
|
1704
|
+
default: () => c("onlyCountries")
|
|
1688
1705
|
},
|
|
1689
1706
|
preferredCountries: {
|
|
1690
1707
|
type: Array,
|
|
1691
|
-
default: () =>
|
|
1708
|
+
default: () => c("preferredCountries")
|
|
1692
1709
|
},
|
|
1693
1710
|
validCharactersOnly: {
|
|
1694
1711
|
type: Boolean,
|
|
1695
|
-
default: () =>
|
|
1712
|
+
default: () => c("validCharactersOnly")
|
|
1696
1713
|
},
|
|
1697
1714
|
styleClasses: {
|
|
1698
1715
|
type: [String, Array, Object],
|
|
1699
|
-
default: () =>
|
|
1716
|
+
default: () => c("styleClasses")
|
|
1717
|
+
},
|
|
1718
|
+
strictValidation: {
|
|
1719
|
+
type: Boolean,
|
|
1720
|
+
default: () => c("strictValidation")
|
|
1700
1721
|
}
|
|
1701
1722
|
}, {
|
|
1702
1723
|
modelValue: { type: String },
|
|
1703
1724
|
modelModifiers: {}
|
|
1704
1725
|
}),
|
|
1705
|
-
emits: /* @__PURE__ */
|
|
1726
|
+
emits: /* @__PURE__ */ $([
|
|
1706
1727
|
"blur",
|
|
1707
1728
|
"close",
|
|
1708
1729
|
"country-changed",
|
|
@@ -1713,14 +1734,14 @@ const xe = {
|
|
|
1713
1734
|
"space",
|
|
1714
1735
|
"validate"
|
|
1715
1736
|
], ["update:modelValue"]),
|
|
1716
|
-
setup(
|
|
1717
|
-
const d =
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
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();
|
|
1721
1742
|
});
|
|
1722
1743
|
});
|
|
1723
|
-
const n =
|
|
1744
|
+
const n = ve({
|
|
1724
1745
|
phone: "",
|
|
1725
1746
|
activeCountryCode: void 0,
|
|
1726
1747
|
open: !1,
|
|
@@ -1732,34 +1753,35 @@ const xe = {
|
|
|
1732
1753
|
parsedPlaceholder: a.inputOptions.placeholder,
|
|
1733
1754
|
searchQuery: ""
|
|
1734
1755
|
});
|
|
1735
|
-
|
|
1736
|
-
e ? (
|
|
1756
|
+
O(() => n.open, (e) => {
|
|
1757
|
+
e ? (he(), f("open")) : f("close");
|
|
1737
1758
|
});
|
|
1738
|
-
const
|
|
1739
|
-
({ iso2: e }) => !a.ignoredCountries.includes(
|
|
1740
|
-
) : a.allCountries),
|
|
1741
|
-
|
|
1742
|
-
if (!e && (
|
|
1743
|
-
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;
|
|
1744
1765
|
return;
|
|
1745
1766
|
}
|
|
1746
1767
|
e != null && e.iso2 && f("country-changed", e);
|
|
1747
1768
|
});
|
|
1748
|
-
const
|
|
1749
|
-
var
|
|
1750
|
-
const e =
|
|
1751
|
-
return e === "auto" ? (
|
|
1752
|
-
}), g =
|
|
1753
|
-
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];
|
|
1754
1775
|
if (!a.dropdownOptions.showSearchBox)
|
|
1755
|
-
return
|
|
1756
|
-
const
|
|
1757
|
-
return
|
|
1758
|
-
(
|
|
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)
|
|
1759
1780
|
);
|
|
1760
|
-
}),
|
|
1781
|
+
}), m = x(() => {
|
|
1761
1782
|
var l;
|
|
1762
|
-
|
|
1783
|
+
q.value;
|
|
1784
|
+
const e = n.phone.startsWith("+") ? J(n.phone, void 0, a.strictValidation) : J(n.phone, n.activeCountryCode, a.strictValidation), o = {
|
|
1763
1785
|
country: e == null ? void 0 : e.country,
|
|
1764
1786
|
countryCode: e == null ? void 0 : e.country,
|
|
1765
1787
|
formatted: n.phone,
|
|
@@ -1767,31 +1789,33 @@ const xe = {
|
|
|
1767
1789
|
possible: (l = e == null ? void 0 : e.isPossible) == null ? void 0 : l.call(e),
|
|
1768
1790
|
nationalNumber: e == null ? void 0 : e.nationalNumber
|
|
1769
1791
|
};
|
|
1770
|
-
return
|
|
1771
|
-
...
|
|
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,
|
|
1772
1794
|
...e
|
|
1773
|
-
} :
|
|
1795
|
+
} : o;
|
|
1774
1796
|
});
|
|
1775
|
-
|
|
1797
|
+
O(() => m.value.countryCode, (e) => {
|
|
1776
1798
|
e && (n.activeCountryCode = e);
|
|
1777
|
-
}),
|
|
1778
|
-
f("validate",
|
|
1779
|
-
}),
|
|
1780
|
-
!a.autoFormat || a.customValidate || (
|
|
1781
|
-
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);
|
|
1782
1804
|
}));
|
|
1783
|
-
}),
|
|
1784
|
-
|
|
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(() => {
|
|
1785
1809
|
var e;
|
|
1786
|
-
!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);
|
|
1787
1811
|
}).catch(console.error).then(() => {
|
|
1788
1812
|
n.finishMounted = !0;
|
|
1789
1813
|
});
|
|
1790
1814
|
});
|
|
1791
|
-
function
|
|
1815
|
+
function X() {
|
|
1792
1816
|
n.parsedPlaceholder = a.inputOptions.placeholder;
|
|
1793
1817
|
}
|
|
1794
|
-
function
|
|
1818
|
+
function ee() {
|
|
1795
1819
|
return new Promise((e) => {
|
|
1796
1820
|
var l;
|
|
1797
1821
|
if (((l = n.phone) == null ? void 0 : l[0]) === "+") {
|
|
@@ -1800,264 +1824,264 @@ const xe = {
|
|
|
1800
1824
|
}
|
|
1801
1825
|
if (a.defaultCountry) {
|
|
1802
1826
|
if (typeof a.defaultCountry == "string") {
|
|
1803
|
-
|
|
1827
|
+
w(a.defaultCountry), e();
|
|
1804
1828
|
return;
|
|
1805
1829
|
}
|
|
1806
1830
|
if (typeof a.defaultCountry == "number") {
|
|
1807
|
-
const
|
|
1808
|
-
if (
|
|
1809
|
-
|
|
1831
|
+
const r = te(a.defaultCountry);
|
|
1832
|
+
if (r) {
|
|
1833
|
+
w(r.iso2), e();
|
|
1810
1834
|
return;
|
|
1811
1835
|
}
|
|
1812
1836
|
}
|
|
1813
1837
|
}
|
|
1814
|
-
const
|
|
1815
|
-
a.autoDefaultCountry ?
|
|
1816
|
-
|
|
1817
|
-
}).catch((
|
|
1818
|
-
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);
|
|
1819
1843
|
}).then(() => {
|
|
1820
1844
|
e();
|
|
1821
|
-
}) : (
|
|
1845
|
+
}) : (w(o), e());
|
|
1822
1846
|
});
|
|
1823
1847
|
}
|
|
1824
|
-
function
|
|
1825
|
-
return e.map(
|
|
1848
|
+
function ne(e = []) {
|
|
1849
|
+
return e.map(P).filter(Boolean);
|
|
1826
1850
|
}
|
|
1827
|
-
function
|
|
1828
|
-
return
|
|
1851
|
+
function P(e = "") {
|
|
1852
|
+
return N.value.find((o) => o.iso2 === M(e));
|
|
1829
1853
|
}
|
|
1830
|
-
function
|
|
1831
|
-
return
|
|
1854
|
+
function te(e) {
|
|
1855
|
+
return N.value.find((o) => Number(o.dialCode) === e);
|
|
1832
1856
|
}
|
|
1833
|
-
function
|
|
1834
|
-
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);
|
|
1835
1859
|
return {
|
|
1836
1860
|
highlighted: l,
|
|
1837
|
-
"last-preferred":
|
|
1838
|
-
preferred:
|
|
1861
|
+
"last-preferred": r,
|
|
1862
|
+
preferred: p
|
|
1839
1863
|
};
|
|
1840
1864
|
}
|
|
1841
|
-
function
|
|
1842
|
-
var l,
|
|
1843
|
-
let
|
|
1844
|
-
if (typeof
|
|
1845
|
-
if (((l = n.phone) == null ? void 0 : l[0]) === "+" &&
|
|
1846
|
-
n.activeCountryCode =
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
)) == 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()) ?? "";
|
|
1850
1874
|
return;
|
|
1851
1875
|
}
|
|
1852
|
-
if ((
|
|
1853
|
-
n.phone = `+${
|
|
1876
|
+
if ((p = a.inputOptions) != null && p.showDialCode && o) {
|
|
1877
|
+
n.phone = `+${o.dialCode}`, n.activeCountryCode = o.iso2;
|
|
1854
1878
|
return;
|
|
1855
1879
|
}
|
|
1856
|
-
n.activeCountryCode =
|
|
1880
|
+
n.activeCountryCode = o.iso2, E(n.phone);
|
|
1857
1881
|
}
|
|
1858
1882
|
}
|
|
1859
|
-
function
|
|
1883
|
+
function ae() {
|
|
1860
1884
|
const e = n.phone;
|
|
1861
1885
|
if (a.validCharactersOnly) {
|
|
1862
|
-
const
|
|
1863
|
-
n.phone =
|
|
1886
|
+
const o = n.phone.match(/[()\-+0-9\s]*/g);
|
|
1887
|
+
n.phone = o.join("");
|
|
1864
1888
|
}
|
|
1865
1889
|
if (a.customValidate && a.customValidate instanceof RegExp) {
|
|
1866
|
-
const
|
|
1867
|
-
n.phone =
|
|
1890
|
+
const o = n.phone.match(a.customValidate);
|
|
1891
|
+
n.phone = o.join("");
|
|
1868
1892
|
}
|
|
1869
|
-
e !== n.phone &&
|
|
1893
|
+
e !== n.phone && E(n.phone);
|
|
1870
1894
|
}
|
|
1871
|
-
function
|
|
1872
|
-
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;
|
|
1873
1897
|
}
|
|
1874
|
-
function
|
|
1898
|
+
function re() {
|
|
1875
1899
|
return a.customValidate instanceof RegExp ? a.customValidate.test(n.phone) : !1;
|
|
1876
1900
|
}
|
|
1877
|
-
function
|
|
1901
|
+
function K() {
|
|
1878
1902
|
var e;
|
|
1879
|
-
(e = b.value) == null || e.setCustomValidity(
|
|
1903
|
+
(e = b.value) == null || e.setCustomValidity(m.value.valid ? "" : a.invalidMsg), E(n.phone);
|
|
1880
1904
|
}
|
|
1881
|
-
function
|
|
1882
|
-
|
|
1905
|
+
function E(e) {
|
|
1906
|
+
S.value = e, f("on-input", e, m.value, b.value);
|
|
1883
1907
|
}
|
|
1884
|
-
function
|
|
1908
|
+
function se(e) {
|
|
1885
1909
|
f("blur", e);
|
|
1886
1910
|
}
|
|
1887
|
-
function
|
|
1888
|
-
|
|
1911
|
+
function le(e) {
|
|
1912
|
+
Te(b.value, n.phone.length), f("focus", e);
|
|
1889
1913
|
}
|
|
1890
|
-
function
|
|
1914
|
+
function de(e) {
|
|
1891
1915
|
f("enter", e);
|
|
1892
1916
|
}
|
|
1893
|
-
function
|
|
1917
|
+
function ue(e) {
|
|
1894
1918
|
f("space", e);
|
|
1895
1919
|
}
|
|
1896
|
-
function
|
|
1920
|
+
function ce() {
|
|
1897
1921
|
var e;
|
|
1898
1922
|
(e = b.value) == null || e.focus();
|
|
1899
1923
|
}
|
|
1900
|
-
function
|
|
1924
|
+
function pe() {
|
|
1901
1925
|
var e;
|
|
1902
1926
|
(e = b.value) == null || e.blur();
|
|
1903
1927
|
}
|
|
1904
|
-
function
|
|
1928
|
+
function H() {
|
|
1905
1929
|
a.disabled || a.dropdownOptions.disabled || (n.searchQuery = "", n.open = !n.open);
|
|
1906
1930
|
}
|
|
1907
|
-
function
|
|
1931
|
+
function fe() {
|
|
1908
1932
|
n.open = !1;
|
|
1909
1933
|
}
|
|
1910
|
-
function
|
|
1934
|
+
function me(e) {
|
|
1911
1935
|
if (e.keyCode === 40) {
|
|
1912
1936
|
e.preventDefault(), n.open = !0, n.selectedIndex === null ? n.selectedIndex = 0 : n.selectedIndex = Math.min(g.value.length - 1, n.selectedIndex + 1);
|
|
1913
|
-
const
|
|
1914
|
-
|
|
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);
|
|
1915
1939
|
} else if (e.keyCode === 38) {
|
|
1916
1940
|
e.preventDefault(), n.open = !0, n.selectedIndex === null ? n.selectedIndex = g.value.length - 1 : n.selectedIndex = Math.max(0, n.selectedIndex - 1);
|
|
1917
|
-
const
|
|
1918
|
-
|
|
1941
|
+
const o = s.value.children[n.selectedIndex];
|
|
1942
|
+
o.focus(), o.offsetTop < s.value.scrollTop && (s.value.scrollTop = o.offsetTop);
|
|
1919
1943
|
} else if (e.keyCode === 13)
|
|
1920
|
-
n.selectedIndex !== null &&
|
|
1944
|
+
n.selectedIndex !== null && w(g.value[n.selectedIndex]), n.open = !n.open;
|
|
1921
1945
|
else if (n.open) {
|
|
1922
1946
|
n.typeToFindInput += e.key, clearTimeout(n.typeToFindTimer), n.typeToFindTimer = setTimeout(() => {
|
|
1923
1947
|
n.typeToFindInput = "";
|
|
1924
1948
|
}, 700);
|
|
1925
|
-
const
|
|
1926
|
-
if (
|
|
1927
|
-
n.selectedIndex = a.preferredCountries.length +
|
|
1928
|
-
const l = s.value.children[n.selectedIndex],
|
|
1929
|
-
(
|
|
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);
|
|
1930
1954
|
}
|
|
1931
1955
|
}
|
|
1932
1956
|
}
|
|
1933
|
-
function
|
|
1957
|
+
function U() {
|
|
1934
1958
|
n.selectedIndex = g.value.map((e) => e.iso2).indexOf(n.activeCountryCode), n.open = !1;
|
|
1935
1959
|
}
|
|
1936
|
-
function
|
|
1960
|
+
function he() {
|
|
1937
1961
|
window.innerHeight - d.value.getBoundingClientRect().bottom > 200 ? n.dropdownOpenDirection = "below" : n.dropdownOpenDirection = "above";
|
|
1938
1962
|
}
|
|
1939
|
-
return
|
|
1940
|
-
focus:
|
|
1941
|
-
blur:
|
|
1942
|
-
}), (e,
|
|
1943
|
-
const l =
|
|
1944
|
-
return
|
|
1963
|
+
return i({
|
|
1964
|
+
focus: ce,
|
|
1965
|
+
blur: pe
|
|
1966
|
+
}), (e, o) => {
|
|
1967
|
+
const l = we("click-outside");
|
|
1968
|
+
return h(), y("div", {
|
|
1945
1969
|
ref_key: "refRoot",
|
|
1946
1970
|
ref: d,
|
|
1947
|
-
class:
|
|
1971
|
+
class: v(["vue-tel-input", t.styleClasses, { disabled: t.disabled }])
|
|
1948
1972
|
}, [
|
|
1949
|
-
|
|
1950
|
-
"aria-label":
|
|
1973
|
+
L((h(), y("div", {
|
|
1974
|
+
"aria-label": t.dropdownOptions.ariaLabel,
|
|
1951
1975
|
"aria-haspopup": "listbox",
|
|
1952
1976
|
"aria-expanded": n.open,
|
|
1953
1977
|
role: "button",
|
|
1954
|
-
class:
|
|
1955
|
-
tabindex:
|
|
1978
|
+
class: v(["vti__dropdown", { open: n.open, disabled: t.dropdownOptions.disabled }]),
|
|
1979
|
+
tabindex: t.dropdownOptions.tabindex,
|
|
1956
1980
|
onKeydown: [
|
|
1957
|
-
|
|
1958
|
-
D(
|
|
1959
|
-
D(
|
|
1960
|
-
D(
|
|
1981
|
+
me,
|
|
1982
|
+
D(H, ["space"]),
|
|
1983
|
+
D(U, ["esc"]),
|
|
1984
|
+
D(U, ["tab"])
|
|
1961
1985
|
],
|
|
1962
|
-
onClick:
|
|
1986
|
+
onClick: H
|
|
1963
1987
|
}, [
|
|
1964
|
-
|
|
1965
|
-
|
|
1988
|
+
I("span", Ve, [
|
|
1989
|
+
t.dropdownOptions.showFlags ? (h(), y("span", {
|
|
1966
1990
|
key: 0,
|
|
1967
|
-
class:
|
|
1968
|
-
}, null, 2)) :
|
|
1969
|
-
|
|
1970
|
-
|
|
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", {
|
|
1971
1995
|
open: n.open
|
|
1972
1996
|
}, () => [
|
|
1973
|
-
|
|
1997
|
+
I("span", Ae, R(n.open ? "▲" : "▼"), 1)
|
|
1974
1998
|
])
|
|
1975
1999
|
]),
|
|
1976
|
-
n.open ? (
|
|
2000
|
+
n.open ? (h(), y("ul", {
|
|
1977
2001
|
key: 0,
|
|
1978
2002
|
ref_key: "refList",
|
|
1979
2003
|
ref: s,
|
|
1980
|
-
class:
|
|
2004
|
+
class: v(["vti__dropdown-list", n.dropdownOpenDirection]),
|
|
1981
2005
|
role: "listbox"
|
|
1982
2006
|
}, [
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
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"]),
|
|
1987
2011
|
"aria-label": "Search by country name or country code",
|
|
1988
|
-
placeholder:
|
|
2012
|
+
placeholder: t.dropdownOptions.searchBoxPlaceholder || (g.value.length ? g.value[0].name : ""),
|
|
1989
2013
|
type: "text",
|
|
1990
|
-
"onUpdate:modelValue":
|
|
1991
|
-
onClick:
|
|
2014
|
+
"onUpdate:modelValue": o[0] || (o[0] = (r) => n.searchQuery = r),
|
|
2015
|
+
onClick: o[1] || (o[1] = Oe(() => {
|
|
1992
2016
|
}, ["stop"]))
|
|
1993
|
-
}, null, 8,
|
|
1994
|
-
[
|
|
2017
|
+
}, null, 8, Le), [
|
|
2018
|
+
[Se, n.searchQuery]
|
|
1995
2019
|
])
|
|
1996
|
-
])) :
|
|
1997
|
-
(
|
|
2020
|
+
])) : k("", !0),
|
|
2021
|
+
(h(!0), y(ke, null, xe(g.value, (r, p) => (h(), y("li", {
|
|
1998
2022
|
role: "option",
|
|
1999
|
-
class:
|
|
2000
|
-
key:
|
|
2023
|
+
class: v(["vti__dropdown-item", oe(p, r.iso2)]),
|
|
2024
|
+
key: r.iso2 + (r.preferred ? "-preferred" : ""),
|
|
2001
2025
|
tabindex: "-1",
|
|
2002
|
-
onClick: (A) =>
|
|
2003
|
-
onMousemove: (A) => n.selectedIndex =
|
|
2004
|
-
"aria-selected": n.activeCountryCode ===
|
|
2026
|
+
onClick: (A) => w(r),
|
|
2027
|
+
onMousemove: (A) => n.selectedIndex = p,
|
|
2028
|
+
"aria-selected": n.activeCountryCode === r.iso2 && !r.preferred
|
|
2005
2029
|
}, [
|
|
2006
|
-
|
|
2030
|
+
t.dropdownOptions.showFlags ? (h(), y("span", {
|
|
2007
2031
|
key: 0,
|
|
2008
|
-
class:
|
|
2009
|
-
}, null, 2)) :
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
], 42,
|
|
2013
|
-
], 2)) :
|
|
2014
|
-
], 42,
|
|
2015
|
-
[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]
|
|
2016
2040
|
]),
|
|
2017
|
-
|
|
2018
|
-
"onUpdate:modelValue":
|
|
2041
|
+
L(I("input", {
|
|
2042
|
+
"onUpdate:modelValue": o[2] || (o[2] = (r) => n.phone = r),
|
|
2019
2043
|
ref_key: "refInput",
|
|
2020
2044
|
ref: b,
|
|
2021
|
-
type:
|
|
2022
|
-
autocomplete:
|
|
2023
|
-
autofocus:
|
|
2024
|
-
class:
|
|
2025
|
-
disabled:
|
|
2026
|
-
id:
|
|
2027
|
-
maxlength:
|
|
2028
|
-
name:
|
|
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,
|
|
2029
2053
|
placeholder: n.parsedPlaceholder,
|
|
2030
|
-
readonly:
|
|
2031
|
-
required:
|
|
2032
|
-
tabindex:
|
|
2033
|
-
value:
|
|
2034
|
-
"aria-describedby":
|
|
2035
|
-
onBlur:
|
|
2036
|
-
onFocus:
|
|
2037
|
-
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,
|
|
2038
2062
|
onKeyup: [
|
|
2039
|
-
D(
|
|
2040
|
-
D(
|
|
2063
|
+
D(de, ["enter"]),
|
|
2064
|
+
D(ue, ["space"])
|
|
2041
2065
|
]
|
|
2042
|
-
}, null, 42,
|
|
2043
|
-
[
|
|
2066
|
+
}, null, 42, qe), [
|
|
2067
|
+
[De, n.phone]
|
|
2044
2068
|
]),
|
|
2045
|
-
|
|
2069
|
+
j(e.$slots, "icon-right")
|
|
2046
2070
|
], 2);
|
|
2047
2071
|
};
|
|
2048
2072
|
}
|
|
2049
|
-
}),
|
|
2050
|
-
install(
|
|
2073
|
+
}), $e = {
|
|
2074
|
+
install(t, i = {}) {
|
|
2051
2075
|
const {
|
|
2052
2076
|
dropdownOptions: u,
|
|
2053
2077
|
inputOptions: d,
|
|
2054
2078
|
...s
|
|
2055
|
-
} =
|
|
2079
|
+
} = i, {
|
|
2056
2080
|
dropdownOptions: b,
|
|
2057
2081
|
inputOptions: f,
|
|
2058
2082
|
...a
|
|
2059
|
-
} =
|
|
2060
|
-
|
|
2083
|
+
} = _;
|
|
2084
|
+
G.options = {
|
|
2061
2085
|
inputOptions: {
|
|
2062
2086
|
...f,
|
|
2063
2087
|
...d
|
|
@@ -2068,10 +2092,10 @@ const xe = {
|
|
|
2068
2092
|
},
|
|
2069
2093
|
...a,
|
|
2070
2094
|
...s
|
|
2071
|
-
},
|
|
2095
|
+
}, t.component("vue-tel-input", Ke);
|
|
2072
2096
|
}
|
|
2073
2097
|
};
|
|
2074
2098
|
export {
|
|
2075
|
-
|
|
2076
|
-
|
|
2099
|
+
Ke as VueTelInput,
|
|
2100
|
+
$e as default
|
|
2077
2101
|
};
|