intl-tel-input 24.3.6 → 24.3.7

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/vue/README.md CHANGED
@@ -7,7 +7,7 @@ A Vue component wrapper for the [intl-tel-input](https://github.com/jackocnr/int
7
7
  - [Props](#props)
8
8
 
9
9
  ## Demo
10
- Try it for yourself by downloading the project and running `npm install` and then `npm run vue:demo` and then copying the given URL into your browser.
10
+ Try it for yourself by downloading the project and running `npm install` and then `npm run vue:demo` and then copy the given URL into your browser. NOTE: the component is rendering the plugin correctly, but we still need help hooking up the [validation functionality](https://github.com/jackocnr/intl-tel-input/blob/master/vue/demo/validation/App.vue)!
11
11
 
12
12
  ## Getting Started
13
13
  ```vue
@@ -27,7 +27,7 @@ Try it for yourself by downloading the project and running `npm install` and the
27
27
 
28
28
  See the [Validation demo](https://github.com/jackocnr/intl-tel-input/blob/master/vue/demo/validation/App.vue) for a more fleshed-out example of how to handle validation [COMING SOON].
29
29
 
30
- A note on the utils script (~260KB): if you're lazy loading the IntlTelInput chunk (and so less worried about filesize) then you can just import IntlTelInput from `"intl-tel-input/vueWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/vue"` import, then you should couple this with the `utilsScript` initialisation option - you will need to host the [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) file, and then set the `utilsScript` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@24.3.6/build/js/utils.js"`.
30
+ A note on the utils script (~260KB): if you're lazy loading the IntlTelInput chunk (and so less worried about filesize) then you can just import IntlTelInput from `"intl-tel-input/vueWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/vue"` import, then you should couple this with the `utilsScript` initialisation option - you will need to host the [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js) file, and then set the `utilsScript` option to that URL, or alternatively just point it to a CDN hosted version e.g. `"https://cdn.jsdelivr.net/npm/intl-tel-input@24.3.7/build/js/utils.js"`.
31
31
 
32
32
  ## Props
33
33
  Here's a list of all of the current props you can pass to the IntlTelInput Vue component.
@@ -1,4 +1,4 @@
1
- import { mergeModels as L, useModel as T, ref as w, onMounted as P, watch as x, onUnmounted as E, withDirectives as M, openBlock as B, createElementBlock as O, vModelText as V } from "vue";
1
+ import { mergeModels as L, useModel as P, ref as v, onMounted as x, watch as E, onUnmounted as M, withDirectives as B, openBlock as O, createElementBlock as V, vModelText as F } from "vue";
2
2
  const D = [
3
3
  [
4
4
  "af",
@@ -1318,7 +1318,7 @@ for (let u = 0; u < D.length; u++) {
1318
1318
  nodeById: {}
1319
1319
  };
1320
1320
  }
1321
- const F = {
1321
+ const z = {
1322
1322
  ad: "Andorra",
1323
1323
  ae: "United Arab Emirates",
1324
1324
  af: "Afghanistan",
@@ -1561,7 +1561,7 @@ const F = {
1561
1561
  za: "South Africa",
1562
1562
  zm: "Zambia",
1563
1563
  zw: "Zimbabwe"
1564
- }, z = {
1564
+ }, R = {
1565
1565
  selectedCountryAriaLabel: "Selected country",
1566
1566
  noCountrySelected: "No country selected",
1567
1567
  countryListAriaLabel: "List of countries",
@@ -1572,10 +1572,10 @@ const F = {
1572
1572
  // additional countries (not supported by country-list library)
1573
1573
  ac: "Ascension Island",
1574
1574
  xk: "Kosovo"
1575
- }, S = { ...F, ...z };
1575
+ }, S = { ...z, ...R };
1576
1576
  for (let u = 0; u < b.length; u++)
1577
1577
  b[u].name = S[b[u].iso2];
1578
- let R = 0;
1578
+ let $ = 0;
1579
1579
  const k = {
1580
1580
  //* Whether or not to allow the dropdown.
1581
1581
  allowDropdown: !0,
@@ -1631,7 +1631,7 @@ const k = {
1631
1631
  utilsScript: "",
1632
1632
  //* The number type to enforce during validation.
1633
1633
  validationNumberType: "MOBILE"
1634
- }, $ = [
1634
+ }, j = [
1635
1635
  "800",
1636
1636
  "822",
1637
1637
  "833",
@@ -1653,10 +1653,10 @@ const k = {
1653
1653
  const t = I(u);
1654
1654
  if (t.charAt(0) === "1") {
1655
1655
  const e = t.substr(1, 3);
1656
- return $.indexOf(e) !== -1;
1656
+ return j.indexOf(e) !== -1;
1657
1657
  }
1658
1658
  return !1;
1659
- }, j = (u, t, e, i) => {
1659
+ }, K = (u, t, e, i) => {
1660
1660
  if (e === 0 && !i)
1661
1661
  return 0;
1662
1662
  let s = 0;
@@ -1667,16 +1667,16 @@ const k = {
1667
1667
  return n;
1668
1668
  }
1669
1669
  return t.length;
1670
- }, m = (u, t, e) => {
1670
+ }, y = (u, t, e) => {
1671
1671
  const i = document.createElement(u);
1672
1672
  return t && Object.entries(t).forEach(([s, n]) => i.setAttribute(s, n)), e && e.appendChild(i), i;
1673
1673
  }, _ = (u) => {
1674
1674
  const { instances: t } = l;
1675
1675
  Object.values(t).forEach((e) => e[u]());
1676
1676
  };
1677
- class K {
1677
+ class U {
1678
1678
  constructor(t, e = {}) {
1679
- this.id = R++, this.telInput = t, this.highlightedItem = null, this.options = Object.assign({}, k, e), this.hadInitialPlaceholder = !!t.getAttribute("placeholder");
1679
+ this.id = $++, this.telInput = t, this.highlightedItem = null, this.options = Object.assign({}, k, e), this.hadInitialPlaceholder = !!t.getAttribute("placeholder");
1680
1680
  }
1681
1681
  //* Can't be private as it's called from intlTelInput convenience wrapper.
1682
1682
  _init() {
@@ -1785,16 +1785,13 @@ class K {
1785
1785
  } = this.options;
1786
1786
  let C = "iti";
1787
1787
  t && (C += " iti--allow-dropdown"), i && (C += " iti--show-flags"), s && (C += ` ${s}`), r || (C += " iti--inline-dropdown");
1788
- const c = m("div", { class: C });
1788
+ const c = y("div", { class: C });
1789
1789
  if ((h = this.telInput.parentNode) == null || h.insertBefore(c, this.telInput), t || i || e) {
1790
- this.countryContainer = m(
1790
+ this.countryContainer = y(
1791
1791
  "div",
1792
- {
1793
- class: "iti__country-container",
1794
- style: this.showSelectedCountryOnLeft ? "left: 0" : "right: 0"
1795
- },
1792
+ { class: "iti__country-container" },
1796
1793
  c
1797
- ), t ? (this.selectedCountry = m(
1794
+ ), this.showSelectedCountryOnLeft ? this.countryContainer.style.left = "0px" : this.countryContainer.style.right = "0px", t ? (this.selectedCountry = y(
1798
1795
  "button",
1799
1796
  {
1800
1797
  type: "button",
@@ -1806,30 +1803,30 @@ class K {
1806
1803
  role: "combobox"
1807
1804
  },
1808
1805
  this.countryContainer
1809
- ), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry = m(
1806
+ ), this.telInput.disabled && this.selectedCountry.setAttribute("disabled", "true")) : this.selectedCountry = y(
1810
1807
  "div",
1811
1808
  { class: "iti__selected-country" },
1812
1809
  this.countryContainer
1813
1810
  );
1814
- const y = m("div", { class: "iti__selected-country-primary" }, this.selectedCountry);
1815
- if (this.selectedCountryInner = m("div", { class: "iti__flag" }, y), this.selectedCountryA11yText = m(
1811
+ const m = y("div", { class: "iti__selected-country-primary" }, this.selectedCountry);
1812
+ if (this.selectedCountryInner = y("div", { class: "iti__flag" }, m), this.selectedCountryA11yText = y(
1816
1813
  "span",
1817
1814
  { class: "iti__a11y-text" },
1818
1815
  this.selectedCountryInner
1819
- ), t && (this.dropdownArrow = m(
1816
+ ), t && (this.dropdownArrow = y(
1820
1817
  "div",
1821
1818
  { class: "iti__arrow", "aria-hidden": "true" },
1822
- y
1823
- )), e && (this.selectedDialCode = m(
1819
+ m
1820
+ )), e && (this.selectedDialCode = y(
1824
1821
  "div",
1825
1822
  { class: "iti__selected-dial-code" },
1826
1823
  this.selectedCountry
1827
1824
  )), t) {
1828
1825
  const f = a ? "" : "iti--flexible-dropdown-width";
1829
- if (this.dropdownContent = m("div", {
1826
+ if (this.dropdownContent = y("div", {
1830
1827
  id: `iti-${this.id}__dropdown-content`,
1831
1828
  class: `iti__dropdown-content iti__hide ${f}`
1832
- }), p && (this.searchInput = m(
1829
+ }), p && (this.searchInput = y(
1833
1830
  "input",
1834
1831
  {
1835
1832
  type: "text",
@@ -1843,11 +1840,11 @@ class K {
1843
1840
  autocomplete: "off"
1844
1841
  },
1845
1842
  this.dropdownContent
1846
- ), this.searchResultsA11yText = m(
1843
+ ), this.searchResultsA11yText = y(
1847
1844
  "span",
1848
1845
  { class: "iti__a11y-text" },
1849
1846
  this.dropdownContent
1850
- )), this.countryList = m(
1847
+ )), this.countryList = y(
1851
1848
  "ul",
1852
1849
  {
1853
1850
  class: "iti__country-list",
@@ -1858,17 +1855,17 @@ class K {
1858
1855
  this.dropdownContent
1859
1856
  ), this._appendListItems(), p && this._updateSearchResultsText(), o) {
1860
1857
  let g = "iti iti--container";
1861
- r ? g += " iti--fullscreen-popup" : g += " iti--inline-dropdown", this.dropdown = m("div", { class: g }), this.dropdown.appendChild(this.dropdownContent);
1858
+ r ? g += " iti--fullscreen-popup" : g += " iti--inline-dropdown", this.dropdown = y("div", { class: g }), this.dropdown.appendChild(this.dropdownContent);
1862
1859
  } else
1863
1860
  this.countryContainer.appendChild(this.dropdownContent);
1864
1861
  }
1865
1862
  }
1866
1863
  if (c.appendChild(this.telInput), this._updateInputPadding(), n) {
1867
- const y = this.telInput.getAttribute("name") || "", f = n(y);
1868
- f.phone && (this.hiddenInput = m("input", {
1864
+ const m = this.telInput.getAttribute("name") || "", f = n(m);
1865
+ f.phone && (this.hiddenInput = y("input", {
1869
1866
  type: "hidden",
1870
1867
  name: f.phone
1871
- }), c.appendChild(this.hiddenInput)), f.country && (this.hiddenInputCountry = m("input", {
1868
+ }), c.appendChild(this.hiddenInput)), f.country && (this.hiddenInputCountry = y("input", {
1872
1869
  type: "hidden",
1873
1870
  name: f.country
1874
1871
  }), c.appendChild(this.hiddenInputCountry));
@@ -1877,7 +1874,7 @@ class K {
1877
1874
  //* For each country: add a country list item <li> to the countryList <ul> container.
1878
1875
  _appendListItems() {
1879
1876
  for (let t = 0; t < this.countries.length; t++) {
1880
- const e = this.countries[t], i = t === 0 ? "iti__highlight" : "", s = m(
1877
+ const e = this.countries[t], i = t === 0 ? "iti__highlight" : "", s = y(
1881
1878
  "li",
1882
1879
  {
1883
1880
  id: `iti-${this.id}__item-${e.iso2}`,
@@ -1965,8 +1962,8 @@ class K {
1965
1962
  let a = !1;
1966
1963
  new RegExp("\\p{L}", "u").test(this.telInput.value) && (a = !0), this._handleInputEvent = (r) => {
1967
1964
  if (this.isAndroid && (r == null ? void 0 : r.data) === "+" && i && n && o) {
1968
- const c = this.telInput.selectionStart || 0, h = this.telInput.value.substring(0, c - 1), y = this.telInput.value.substring(c);
1969
- this.telInput.value = h + y, this._openDropdownWithPlus();
1965
+ const c = this.telInput.selectionStart || 0, h = this.telInput.value.substring(0, c - 1), m = this.telInput.value.substring(c);
1966
+ this.telInput.value = h + m, this._openDropdownWithPlus();
1970
1967
  return;
1971
1968
  }
1972
1969
  this._updateCountryFromNumber(this.telInput.value) && this._triggerCountryChange();
@@ -1974,8 +1971,8 @@ class K {
1974
1971
  p || d && !t ? a = !0 : /[^+0-9]/.test(this.telInput.value) || (a = !1);
1975
1972
  const C = (r == null ? void 0 : r.detail) && r.detail.isSetNumber && !s;
1976
1973
  if (e && !a && !C) {
1977
- const c = this.telInput.selectionStart || 0, y = this.telInput.value.substring(0, c).replace(/[^+0-9]/g, "").length, f = (r == null ? void 0 : r.inputType) === "deleteContentForward", g = this._formatNumberAsYouType(), v = j(y, g, c, f);
1978
- this.telInput.value = g, this.telInput.setSelectionRange(v, v);
1974
+ const c = this.telInput.selectionStart || 0, m = this.telInput.value.substring(0, c).replace(/[^+0-9]/g, "").length, f = (r == null ? void 0 : r.inputType) === "deleteContentForward", g = this._formatNumberAsYouType(), w = K(m, g, c, f);
1975
+ this.telInput.value = g, this.telInput.setSelectionRange(w, w);
1979
1976
  }
1980
1977
  }, this.telInput.addEventListener("input", this._handleInputEvent), (t || i) && (this._handleKeydownEvent = (r) => {
1981
1978
  if (r.key && r.key.length === 1 && !r.altKey && !r.ctrlKey && !r.metaKey) {
@@ -1984,8 +1981,8 @@ class K {
1984
1981
  return;
1985
1982
  }
1986
1983
  if (t) {
1987
- const p = this.telInput.selectionStart === 0 && r.key === "+", d = /^[0-9]$/.test(r.key), C = i ? d : p || d, c = this._getFullNumber(), h = l.utils.getCoreNumber(c, this.selectedCountryData.iso2), y = this.maxCoreNumberLength && h.length >= this.maxCoreNumberLength, f = this.telInput.value.substring(this.telInput.selectionStart, this.telInput.selectionEnd), g = /\d/.test(f);
1988
- (!C || y && !g) && r.preventDefault();
1984
+ const p = this.telInput.selectionStart === 0 && r.key === "+", d = /^[0-9]$/.test(r.key), C = i ? d : p || d, c = this._getFullNumber(), h = l.utils.getCoreNumber(c, this.selectedCountryData.iso2), m = this.maxCoreNumberLength && h.length >= this.maxCoreNumberLength, f = this.telInput.value.substring(this.telInput.selectionStart, this.telInput.selectionEnd), g = /\d/.test(f), T = (this.telInput.selectionStart || 0) === this.telInput.value.length;
1985
+ (!C || m && !g && T) && r.preventDefault();
1989
1986
  }
1990
1987
  }
1991
1988
  }, this.telInput.addEventListener("keydown", this._handleKeydownEvent));
@@ -2442,7 +2439,7 @@ class K {
2442
2439
  this.telInput.disabled = t, t ? this.selectedCountry.setAttribute("disabled", "true") : this.selectedCountry.removeAttribute("disabled");
2443
2440
  }
2444
2441
  }
2445
- const U = (u) => !l.utils && !l.startedLoadingUtilsScript ? (l.startedLoadingUtilsScript = !0, new Promise((t, e) => {
2442
+ const H = (u) => !l.utils && !l.startedLoadingUtilsScript ? (l.startedLoadingUtilsScript = !0, new Promise((t, e) => {
2446
2443
  import(
2447
2444
  /* webpackIgnore: true */
2448
2445
  /* @vite-ignore */
@@ -2454,7 +2451,7 @@ const U = (u) => !l.utils && !l.startedLoadingUtilsScript ? (l.startedLoadingUti
2454
2451
  });
2455
2452
  })) : null, l = Object.assign(
2456
2453
  (u, t) => {
2457
- const e = new K(u, t);
2454
+ const e = new U(u, t);
2458
2455
  return e._init(), u.setAttribute("data-intl-tel-input-id", e.id.toString()), l.instances[e.id] = e, e;
2459
2456
  },
2460
2457
  {
@@ -2470,10 +2467,10 @@ const U = (u) => !l.utils && !l.startedLoadingUtilsScript ? (l.startedLoadingUti
2470
2467
  },
2471
2468
  //* A map from instance ID to instance object.
2472
2469
  instances: {},
2473
- loadUtils: U,
2474
- version: "24.3.6"
2470
+ loadUtils: H,
2471
+ version: "24.3.7"
2475
2472
  }
2476
- ), G = {
2473
+ ), W = {
2477
2474
  __name: "IntlTelInput",
2478
2475
  props: /* @__PURE__ */ L({
2479
2476
  options: {
@@ -2496,7 +2493,7 @@ const U = (u) => !l.utils && !l.startedLoadingUtilsScript ? (l.startedLoadingUti
2496
2493
  }),
2497
2494
  emits: /* @__PURE__ */ L(["changeNumber", "changeCountry", "changeValidity", "changeErrorCode"], ["update:modelValue"]),
2498
2495
  setup(u, { expose: t, emit: e }) {
2499
- const i = T(u, "modelValue"), s = u, n = e, o = w(), a = w(), r = w(!1), p = () => a.value ? s.options.strictMode ? a.value.isValidNumberPrecise() : a.value.isValidNumber() : null, d = () => {
2496
+ const i = P(u, "modelValue"), s = u, n = e, o = v(), a = v(), r = v(!1), p = () => a.value ? s.options.strictMode ? a.value.isValidNumberPrecise() : a.value.isValidNumber() : null, d = () => {
2500
2497
  let h = p();
2501
2498
  r.value !== h && (r.value = h, n("changeValidity", !!h), n("changeErrorCode", h ? null : a.value.getValidationError()));
2502
2499
  }, C = () => {
@@ -2506,29 +2503,29 @@ const U = (u) => !l.utils && !l.startedLoadingUtilsScript ? (l.startedLoadingUti
2506
2503
  var h;
2507
2504
  n("changeCountry", ((h = a.value) == null ? void 0 : h.getSelectedCountryData().iso2) ?? ""), C(), d();
2508
2505
  };
2509
- return P(() => {
2506
+ return x(() => {
2510
2507
  o.value && (a.value = l(o.value, s.options), s.value && a.value.setNumber(s.value), s.disabled && a.value.setDisabled(s.disabled));
2511
- }), x(
2508
+ }), E(
2512
2509
  () => s.disabled,
2513
2510
  (h) => {
2514
- var y;
2515
- return (y = a.value) == null ? void 0 : y.setDisabled(h);
2511
+ var m;
2512
+ return (m = a.value) == null ? void 0 : m.setDisabled(h);
2516
2513
  }
2517
- ), E(() => {
2514
+ ), M(() => {
2518
2515
  var h;
2519
2516
  return (h = a.value) == null ? void 0 : h.destroy();
2520
- }), t({ instance: a, input: o }), (h, y) => M((B(), O("input", {
2517
+ }), t({ instance: a, input: o }), (h, m) => B((O(), V("input", {
2521
2518
  ref_key: "input",
2522
2519
  ref: o,
2523
- "onUpdate:modelValue": y[0] || (y[0] = (f) => i.value = f),
2520
+ "onUpdate:modelValue": m[0] || (m[0] = (f) => i.value = f),
2524
2521
  type: "tel",
2525
2522
  onCountrychange: c,
2526
2523
  onInput: C
2527
2524
  }, null, 544)), [
2528
- [V, i.value]
2525
+ [F, i.value]
2529
2526
  ]);
2530
2527
  }
2531
2528
  };
2532
2529
  export {
2533
- G as default
2530
+ W as default
2534
2531
  };