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