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.
@@ -1,6 +1,6 @@
1
- import { defineComponent as ce, mergeModels as K, shallowRef as R, useModel as pe, watch as w, nextTick as H, reactive as fe, computed as k, onMounted as me, resolveDirective as he, openBlock as m, createElementBlock as h, normalizeClass as C, withDirectives as z, withKeys as D, createElementVNode as x, unref as U, createCommentVNode as S, toDisplayString as P, renderSlot as F, withModifiers as ye, vModelText as be, Fragment as ge, renderList as Ce, vModelDynamic as ve } from "vue";
2
- import { parsePhoneNumberFromString as L } from "libphonenumber-js";
3
- const we = [
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
- ], Oe = we.map(([o, r, u, d = 0, s = null]) => ({
1310
- name: o,
1311
- iso2: r.toUpperCase(),
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 Se() {
1317
- return fetch("https://ip2c.org/s").then((o) => o.text()).then((o) => {
1318
- const r = (o || "").toString();
1319
- if (!r || r[0] !== "1")
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 r.substr(2, 2);
1321
+ return i.substr(2, 2);
1322
1322
  });
1323
1323
  }
1324
- function ke(o, r) {
1325
- if (o.setSelectionRange)
1326
- o.focus(), o.setSelectionRange(r, r);
1327
- else if ("createTextRange" in o && typeof o.createTextRange == "function") {
1328
- const u = o.createTextRange();
1329
- u.collapse(!0), u.moveEnd("character", r), u.moveStart("character", r), u.select();
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 De = [
1332
+ const Ne = [
1333
1333
  {
1334
1334
  name: "allCountries",
1335
1335
  type: Array,
1336
- default: Oe,
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
- ], $ = [...De].reduce((o, r) => {
1592
- if (r.name.includes(".")) {
1593
- const [u, d] = r.name.split(".");
1594
- o[u] ? Object.assign(o[u], { [d]: r.default }) : Object.assign(o, { [u]: { [d]: r.default } });
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(o, { [r.name]: r.default });
1597
- return o;
1598
- }, {}), j = {
1599
- options: { ...$ }
1603
+ Object.assign(t, { [i.name]: i.default });
1604
+ return t;
1605
+ }, {}), G = {
1606
+ options: { ..._ }
1600
1607
  };
1601
- function p(o) {
1602
- const r = j.options[o];
1603
- return typeof r > "u" ? j.options[o] : r;
1608
+ function c(t) {
1609
+ const i = G.options[t];
1610
+ return typeof i > "u" ? G.options[t] : i;
1604
1611
  }
1605
- function I(o) {
1606
- return o == null ? void 0 : o.toLowerCase();
1612
+ function B(t) {
1613
+ return t == null ? void 0 : t.toLowerCase();
1607
1614
  }
1608
- function B(o) {
1609
- return o == null ? void 0 : o.toUpperCase();
1615
+ function M(t) {
1616
+ return t == null ? void 0 : t.toUpperCase();
1610
1617
  }
1611
- const xe = {
1612
- beforeMount(o, r, u) {
1613
- if (typeof r.value != "function") {
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 ${r.expression} is not a function, but has to be`;
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
- o.clickOutsideEvent = function(d) {
1635
+ t.clickOutsideEvent = function(d) {
1619
1636
  const s = d.composedPath ? d.composedPath() : d.path;
1620
- o === d.target || o.contains(d.target) || s.includes(o) || r.value(d, o);
1621
- }, document.body.addEventListener("click", o.clickOutsideEvent);
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(o) {
1624
- document.body.removeEventListener("click", o.clickOutsideEvent);
1640
+ unmounted(t) {
1641
+ document.body.removeEventListener("click", t.clickOutsideEvent);
1625
1642
  }
1626
- }, Ie = ["aria-label", "aria-expanded", "tabindex"], Be = { class: "vti__selection" }, Me = {
1643
+ }, Re = ["aria-label", "aria-expanded", "tabindex"], Ve = { class: "vti__selection" }, ze = {
1627
1644
  key: 1,
1628
1645
  class: "vti__country-code"
1629
- }, Te = { class: "vti__dropdown-arrow" }, Ne = {
1646
+ }, Ae = { class: "vti__dropdown-arrow" }, Fe = {
1630
1647
  key: 0,
1631
1648
  class: "vti__search_box_container"
1632
- }, Pe = ["placeholder"], Ee = ["onClick", "onMousemove", "aria-selected"], Ae = { key: 1 }, Re = ["type", "autocomplete", "autofocus", "disabled", "id", "maxlength", "name", "placeholder", "readonly", "required", "tabindex", "value", "aria-describedby"], ze = /* @__PURE__ */ ce({
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: xe
1652
+ clickOutside: Ee
1636
1653
  },
1637
1654
  __name: "vue-tel-input",
1638
- props: /* @__PURE__ */ K({
1655
+ props: /* @__PURE__ */ $({
1639
1656
  allCountries: {
1640
1657
  type: Array,
1641
- default: () => p("allCountries")
1658
+ default: () => c("allCountries")
1642
1659
  },
1643
1660
  autoFormat: {
1644
1661
  type: Boolean,
1645
- default: () => p("autoFormat")
1662
+ default: () => c("autoFormat")
1646
1663
  },
1647
1664
  customValidate: {
1648
1665
  type: [Boolean, RegExp],
1649
- default: () => p("customValidate")
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: () => p("defaultCountry")
1672
+ default: () => c("defaultCountry")
1656
1673
  },
1657
1674
  disabled: {
1658
1675
  type: Boolean,
1659
- default: () => p("disabled")
1676
+ default: () => c("disabled")
1660
1677
  },
1661
1678
  autoDefaultCountry: {
1662
1679
  type: Boolean,
1663
- default: () => p("autoDefaultCountry")
1680
+ default: () => c("autoDefaultCountry")
1664
1681
  },
1665
1682
  dropdownOptions: {
1666
1683
  type: Object,
1667
- default: () => p("dropdownOptions")
1684
+ default: () => c("dropdownOptions")
1668
1685
  },
1669
1686
  ignoredCountries: {
1670
1687
  type: Array,
1671
- default: () => p("ignoredCountries")
1688
+ default: () => c("ignoredCountries")
1672
1689
  },
1673
1690
  inputOptions: {
1674
1691
  type: Object,
1675
- default: () => p("inputOptions")
1692
+ default: () => c("inputOptions")
1676
1693
  },
1677
1694
  invalidMsg: {
1678
1695
  type: String,
1679
- default: () => p("invalidMsg")
1696
+ default: () => c("invalidMsg")
1680
1697
  },
1681
1698
  mode: {
1682
1699
  type: String,
1683
- default: () => p("mode")
1700
+ default: () => c("mode")
1684
1701
  },
1685
1702
  onlyCountries: {
1686
1703
  type: Array,
1687
- default: () => p("onlyCountries")
1704
+ default: () => c("onlyCountries")
1688
1705
  },
1689
1706
  preferredCountries: {
1690
1707
  type: Array,
1691
- default: () => p("preferredCountries")
1708
+ default: () => c("preferredCountries")
1692
1709
  },
1693
1710
  validCharactersOnly: {
1694
1711
  type: Boolean,
1695
- default: () => p("validCharactersOnly")
1712
+ default: () => c("validCharactersOnly")
1696
1713
  },
1697
1714
  styleClasses: {
1698
1715
  type: [String, Array, Object],
1699
- default: () => p("styleClasses")
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__ */ K([
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(o, { expose: r, emit: u }) {
1717
- const d = R(), s = R(), b = R(), f = u, a = o, O = pe(o, "modelValue");
1718
- w(O, (e, t) => {
1719
- ee() ? n.phone = e ?? "" : H(() => {
1720
- n.phone = t ?? "", V();
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 = fe({
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
- w(() => n.open, (e) => {
1736
- e ? (ue(), f("open")) : f("close");
1756
+ O(() => n.open, (e) => {
1757
+ e ? (he(), f("open")) : f("close");
1737
1758
  });
1738
- const M = k(() => a.onlyCountries.length ? a.allCountries.filter(({ iso2: e }) => a.onlyCountries.some((t) => B(t) === e)) : a.ignoredCountries.length ? a.allCountries.filter(
1739
- ({ iso2: e }) => !a.ignoredCountries.includes(B(e)) && !a.ignoredCountries.includes(I(e))
1740
- ) : a.allCountries), E = k(() => T(n.activeCountryCode));
1741
- w(E, (e, t) => {
1742
- if (!e && (t != null && t.iso2)) {
1743
- n.activeCountryCode = t.iso2;
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 Q = k(() => {
1749
- var t;
1750
- const e = I(a.mode);
1751
- return e === "auto" ? (t = n.phone) != null && t.startsWith("+") ? "international" : "national" : ["national", "international", "e.164", "rfc3966", "idd"].includes(e) ? e : (console.error('Invalid value of prop "mode"'), "international");
1752
- }), g = k(() => {
1753
- const t = [...Z(a.preferredCountries).map((c) => ({ ...c, preferred: !0 })), ...M.value];
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 t;
1756
- const i = n.searchQuery.toLowerCase().replace(/[~`!@#$%^&*()+={}\[\];:\'\"<>.,\/\\\?-_]/g, "");
1757
- return t.filter(
1758
- (c) => new RegExp(i, "i").test(c.name) || new RegExp(i, "i").test(c.iso2) || new RegExp(i, "i").test(c.dialCode)
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
- }), y = k(() => {
1781
+ }), m = x(() => {
1761
1782
  var l;
1762
- const e = n.phone.startsWith("+") ? L(n.phone) : L(n.phone, n.activeCountryCode), t = {
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 t.valid && (t.formatted = e == null ? void 0 : e.format(B(Q.value))), e != null && e.country && (a.ignoredCountries.length || a.onlyCountries.length) && !T(e.country) && (t.valid = !1, t.possible = !1, e.country = null), e ? {
1771
- ...t,
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
- } : t;
1795
+ } : o;
1774
1796
  });
1775
- w(() => y.value.countryCode, (e) => {
1797
+ O(() => m.value.countryCode, (e) => {
1776
1798
  e && (n.activeCountryCode = e);
1777
- }), w(() => y.value.valid, () => {
1778
- f("validate", y.value);
1779
- }), w(() => y.value.formatted, (e) => {
1780
- !a.autoFormat || a.customValidate || (N(e), H(() => {
1781
- e && !O.value && (n.phone = 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
- }), w(() => a.inputOptions.placeholder, W), me(() => {
1784
- O.value && (n.phone = O.value.trim()), X(), J().then(() => {
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", y.value);
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 W() {
1815
+ function X() {
1792
1816
  n.parsedPlaceholder = a.inputOptions.placeholder;
1793
1817
  }
1794
- function J() {
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
- v(a.defaultCountry), e();
1827
+ w(a.defaultCountry), e();
1804
1828
  return;
1805
1829
  }
1806
1830
  if (typeof a.defaultCountry == "number") {
1807
- const i = _(a.defaultCountry);
1808
- if (i) {
1809
- v(i.iso2), e();
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 t = a.preferredCountries[0] || M.value[0];
1815
- a.autoDefaultCountry ? Se().then((i) => {
1816
- v(i || n.activeCountryCode);
1817
- }).catch((i) => {
1818
- console.warn(i), v(t);
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
- }) : (v(t), e());
1845
+ }) : (w(o), e());
1822
1846
  });
1823
1847
  }
1824
- function Z(e = []) {
1825
- return e.map(T).filter(Boolean);
1848
+ function ne(e = []) {
1849
+ return e.map(P).filter(Boolean);
1826
1850
  }
1827
- function T(e = "") {
1828
- return M.value.find((t) => t.iso2 === B(e));
1851
+ function P(e = "") {
1852
+ return N.value.find((o) => o.iso2 === M(e));
1829
1853
  }
1830
- function _(e) {
1831
- return M.value.find((t) => Number(t.dialCode) === e);
1854
+ function te(e) {
1855
+ return N.value.find((o) => Number(o.dialCode) === e);
1832
1856
  }
1833
- function Y(e, t) {
1834
- const l = n.selectedIndex === e, i = e === a.preferredCountries.length - 1, c = a.preferredCountries.some((A) => B(A) === t);
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": i,
1838
- preferred: c
1861
+ "last-preferred": r,
1862
+ preferred: p
1839
1863
  };
1840
1864
  }
1841
- function v(e) {
1842
- var l, i, c;
1843
- let t = e;
1844
- if (typeof t == "string" && (t = T(t)), !!t) {
1845
- if (((l = n.phone) == null ? void 0 : l[0]) === "+" && t.iso2 && y.value.nationalNumber) {
1846
- n.activeCountryCode = t.iso2, n.phone = ((i = L(
1847
- y.value.nationalNumber,
1848
- t.iso2
1849
- )) == null ? void 0 : i.formatInternational()) ?? "";
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 ((c = a.inputOptions) != null && c.showDialCode && t) {
1853
- n.phone = `+${t.dialCode}`, n.activeCountryCode = t.iso2;
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 = t.iso2, N(n.phone);
1880
+ n.activeCountryCode = o.iso2, E(n.phone);
1857
1881
  }
1858
1882
  }
1859
- function X() {
1883
+ function ae() {
1860
1884
  const e = n.phone;
1861
1885
  if (a.validCharactersOnly) {
1862
- const t = n.phone.match(/[()\-+0-9\s]*/g);
1863
- n.phone = t.join("");
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 t = n.phone.match(a.customValidate);
1867
- n.phone = t.join("");
1890
+ const o = n.phone.match(a.customValidate);
1891
+ n.phone = o.join("");
1868
1892
  }
1869
- e !== n.phone && N(n.phone);
1893
+ e !== n.phone && E(n.phone);
1870
1894
  }
1871
- function ee() {
1872
- return a.validCharactersOnly && !/^[()\-+0-9\s]*$/.test(n.phone) ? !1 : a.customValidate ? ne() : !0;
1895
+ function ie() {
1896
+ return a.validCharactersOnly && !/^[()\-+0-9\s]*$/.test(n.phone) ? !1 : a.customValidate ? re() : !0;
1873
1897
  }
1874
- function ne() {
1898
+ function re() {
1875
1899
  return a.customValidate instanceof RegExp ? a.customValidate.test(n.phone) : !1;
1876
1900
  }
1877
- function V() {
1901
+ function K() {
1878
1902
  var e;
1879
- (e = b.value) == null || e.setCustomValidity(y.value.valid ? "" : a.invalidMsg), N(n.phone);
1903
+ (e = b.value) == null || e.setCustomValidity(m.value.valid ? "" : a.invalidMsg), E(n.phone);
1880
1904
  }
1881
- function N(e) {
1882
- O.value = e, f("on-input", e, y.value, b.value);
1905
+ function E(e) {
1906
+ S.value = e, f("on-input", e, m.value, b.value);
1883
1907
  }
1884
- function te(e) {
1908
+ function se(e) {
1885
1909
  f("blur", e);
1886
1910
  }
1887
- function oe(e) {
1888
- ke(b.value, n.phone.length), f("focus", e);
1911
+ function le(e) {
1912
+ Te(b.value, n.phone.length), f("focus", e);
1889
1913
  }
1890
- function ae(e) {
1914
+ function de(e) {
1891
1915
  f("enter", e);
1892
1916
  }
1893
- function ie(e) {
1917
+ function ue(e) {
1894
1918
  f("space", e);
1895
1919
  }
1896
- function re() {
1920
+ function ce() {
1897
1921
  var e;
1898
1922
  (e = b.value) == null || e.focus();
1899
1923
  }
1900
- function se() {
1924
+ function pe() {
1901
1925
  var e;
1902
1926
  (e = b.value) == null || e.blur();
1903
1927
  }
1904
- function G() {
1928
+ function H() {
1905
1929
  a.disabled || a.dropdownOptions.disabled || (n.searchQuery = "", n.open = !n.open);
1906
1930
  }
1907
- function le() {
1931
+ function fe() {
1908
1932
  n.open = !1;
1909
1933
  }
1910
- function de(e) {
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 t = s.value.children[n.selectedIndex];
1914
- t.focus(), t.offsetTop + t.clientHeight > s.value.scrollTop + s.value.clientHeight && (s.value.scrollTop = t.offsetTop - s.value.clientHeight + t.clientHeight);
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 t = s.value.children[n.selectedIndex];
1918
- t.focus(), t.offsetTop < s.value.scrollTop && (s.value.scrollTop = t.offsetTop);
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 && v(g.value[n.selectedIndex]), n.open = !n.open;
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 t = g.value.slice(a.preferredCountries.length).findIndex((l) => I(l.name).startsWith(n.typeToFindInput));
1926
- if (t >= 0) {
1927
- n.selectedIndex = a.preferredCountries.length + t;
1928
- const l = s.value.children[n.selectedIndex], i = l.offsetTop < s.value.scrollTop, c = l.offsetTop + l.clientHeight > s.value.scrollTop + s.value.clientHeight;
1929
- (i || c) && (s.value.scrollTop = l.offsetTop - s.value.clientHeight / 2);
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 q() {
1957
+ function U() {
1934
1958
  n.selectedIndex = g.value.map((e) => e.iso2).indexOf(n.activeCountryCode), n.open = !1;
1935
1959
  }
1936
- function ue() {
1960
+ function he() {
1937
1961
  window.innerHeight - d.value.getBoundingClientRect().bottom > 200 ? n.dropdownOpenDirection = "below" : n.dropdownOpenDirection = "above";
1938
1962
  }
1939
- return r({
1940
- focus: re,
1941
- blur: se
1942
- }), (e, t) => {
1943
- const l = he("click-outside");
1944
- return m(), h("div", {
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: C(["vue-tel-input", o.styleClasses, { disabled: o.disabled }])
1971
+ class: v(["vue-tel-input", t.styleClasses, { disabled: t.disabled }])
1948
1972
  }, [
1949
- z((m(), h("div", {
1950
- "aria-label": o.dropdownOptions.ariaLabel,
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: C(["vti__dropdown", { open: n.open, disabled: o.dropdownOptions.disabled }]),
1955
- tabindex: o.dropdownOptions.tabindex,
1978
+ class: v(["vti__dropdown", { open: n.open, disabled: t.dropdownOptions.disabled }]),
1979
+ tabindex: t.dropdownOptions.tabindex,
1956
1980
  onKeydown: [
1957
- de,
1958
- D(G, ["space"]),
1959
- D(q, ["esc"]),
1960
- D(q, ["tab"])
1981
+ me,
1982
+ D(H, ["space"]),
1983
+ D(U, ["esc"]),
1984
+ D(U, ["tab"])
1961
1985
  ],
1962
- onClick: G
1986
+ onClick: H
1963
1987
  }, [
1964
- x("span", Be, [
1965
- o.dropdownOptions.showFlags ? (m(), h("span", {
1988
+ I("span", Ve, [
1989
+ t.dropdownOptions.showFlags ? (h(), y("span", {
1966
1990
  key: 0,
1967
- class: C(["vti__flag", U(I)(n.activeCountryCode)])
1968
- }, null, 2)) : S("", !0),
1969
- o.dropdownOptions.showDialCodeInSelection ? (m(), h("span", Me, " +" + P(E.value && E.value.dialCode), 1)) : S("", !0),
1970
- F(e.$slots, "arrow-icon", {
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
- x("span", Te, P(n.open ? "▲" : "▼"), 1)
1997
+ I("span", Ae, R(n.open ? "▲" : "▼"), 1)
1974
1998
  ])
1975
1999
  ]),
1976
- n.open ? (m(), h("ul", {
2000
+ n.open ? (h(), y("ul", {
1977
2001
  key: 0,
1978
2002
  ref_key: "refList",
1979
2003
  ref: s,
1980
- class: C(["vti__dropdown-list", n.dropdownOpenDirection]),
2004
+ class: v(["vti__dropdown-list", n.dropdownOpenDirection]),
1981
2005
  role: "listbox"
1982
2006
  }, [
1983
- o.dropdownOptions.showSearchBox ? (m(), h("div", Ne, [
1984
- F(e.$slots, "search-icon"),
1985
- z(x("input", {
1986
- class: C(["vti__input", "vti__search_box"]),
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: o.dropdownOptions.searchBoxPlaceholder || (g.value.length ? g.value[0].name : ""),
2012
+ placeholder: t.dropdownOptions.searchBoxPlaceholder || (g.value.length ? g.value[0].name : ""),
1989
2013
  type: "text",
1990
- "onUpdate:modelValue": t[0] || (t[0] = (i) => n.searchQuery = i),
1991
- onClick: t[1] || (t[1] = ye(() => {
2014
+ "onUpdate:modelValue": o[0] || (o[0] = (r) => n.searchQuery = r),
2015
+ onClick: o[1] || (o[1] = Oe(() => {
1992
2016
  }, ["stop"]))
1993
- }, null, 8, Pe), [
1994
- [be, n.searchQuery]
2017
+ }, null, 8, Le), [
2018
+ [Se, n.searchQuery]
1995
2019
  ])
1996
- ])) : S("", !0),
1997
- (m(!0), h(ge, null, Ce(g.value, (i, c) => (m(), h("li", {
2020
+ ])) : k("", !0),
2021
+ (h(!0), y(ke, null, xe(g.value, (r, p) => (h(), y("li", {
1998
2022
  role: "option",
1999
- class: C(["vti__dropdown-item", Y(c, i.iso2)]),
2000
- key: i.iso2 + (i.preferred ? "-preferred" : ""),
2023
+ class: v(["vti__dropdown-item", oe(p, r.iso2)]),
2024
+ key: r.iso2 + (r.preferred ? "-preferred" : ""),
2001
2025
  tabindex: "-1",
2002
- onClick: (A) => v(i),
2003
- onMousemove: (A) => n.selectedIndex = c,
2004
- "aria-selected": n.activeCountryCode === i.iso2 && !i.preferred
2026
+ onClick: (A) => w(r),
2027
+ onMousemove: (A) => n.selectedIndex = p,
2028
+ "aria-selected": n.activeCountryCode === r.iso2 && !r.preferred
2005
2029
  }, [
2006
- o.dropdownOptions.showFlags ? (m(), h("span", {
2030
+ t.dropdownOptions.showFlags ? (h(), y("span", {
2007
2031
  key: 0,
2008
- class: C(["vti__flag", U(I)(i.iso2)])
2009
- }, null, 2)) : S("", !0),
2010
- x("strong", null, P(i.name), 1),
2011
- o.dropdownOptions.showDialCodeInList ? (m(), h("span", Ae, " +" + P(i.dialCode), 1)) : S("", !0)
2012
- ], 42, Ee))), 128))
2013
- ], 2)) : S("", !0)
2014
- ], 42, Ie)), [
2015
- [l, le]
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
- z(x("input", {
2018
- "onUpdate:modelValue": t[2] || (t[2] = (i) => n.phone = i),
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: o.inputOptions.type,
2022
- autocomplete: o.inputOptions.autocomplete,
2023
- autofocus: o.inputOptions.autofocus,
2024
- class: C(["vti__input", "vti__phone", o.inputOptions.styleClasses]),
2025
- disabled: o.disabled,
2026
- id: o.inputOptions.id,
2027
- maxlength: o.inputOptions.maxlength,
2028
- name: o.inputOptions.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: o.inputOptions.readonly,
2031
- required: o.inputOptions.required,
2032
- tabindex: o.inputOptions.tabindex,
2033
- value: O.value,
2034
- "aria-describedby": o.inputOptions["aria-describedby"],
2035
- onBlur: te,
2036
- onFocus: oe,
2037
- onInput: V,
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(ae, ["enter"]),
2040
- D(ie, ["space"])
2063
+ D(de, ["enter"]),
2064
+ D(ue, ["space"])
2041
2065
  ]
2042
- }, null, 42, Re), [
2043
- [ve, n.phone]
2066
+ }, null, 42, qe), [
2067
+ [De, n.phone]
2044
2068
  ]),
2045
- F(e.$slots, "icon-right")
2069
+ j(e.$slots, "icon-right")
2046
2070
  ], 2);
2047
2071
  };
2048
2072
  }
2049
- }), je = {
2050
- install(o, r = {}) {
2073
+ }), $e = {
2074
+ install(t, i = {}) {
2051
2075
  const {
2052
2076
  dropdownOptions: u,
2053
2077
  inputOptions: d,
2054
2078
  ...s
2055
- } = r, {
2079
+ } = i, {
2056
2080
  dropdownOptions: b,
2057
2081
  inputOptions: f,
2058
2082
  ...a
2059
- } = $;
2060
- j.options = {
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
- }, o.component("vue-tel-input", ze);
2095
+ }, t.component("vue-tel-input", Ke);
2072
2096
  }
2073
2097
  };
2074
2098
  export {
2075
- ze as VueTelInput,
2076
- je as default
2099
+ Ke as VueTelInput,
2100
+ $e as default
2077
2101
  };