intl-tel-input 24.8.1 → 25.0.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/vue/README.md CHANGED
@@ -34,7 +34,7 @@ See the [Validation demo](https://github.com/jackocnr/intl-tel-input/blob/master
34
34
  "vue:demo": "vite --config vue/demo/[demo variant]/vite.config.js"
35
35
  ```
36
36
 
37
- 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.8.1/build/js/utils.js"`.
37
+ 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@25.0.0/build/js/utils.js"`.
38
38
 
39
39
  ## Props
40
40
  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 D, useModel as x, ref as v, onMounted as E, watch as M, onUnmounted as O, withDirectives as F, openBlock as B, createElementBlock as V, mergeProps as z, vModelText as R } from "vue";
1
+ import { mergeModels as D, useModel as x, ref as v, onMounted as E, watch as M, onUnmounted as F, withDirectives as B, openBlock as O, createElementBlock as V, mergeProps as z, vModelText as R } from "vue";
2
2
  const N = [
3
3
  [
4
4
  "af",
@@ -1607,8 +1607,8 @@ const T = {
1607
1607
  i18n: {},
1608
1608
  //* Initial country.
1609
1609
  initialCountry: "",
1610
- //* Specify the path to the libphonenumber script to enable validation/formatting.
1611
- loadUtilsOnInit: "",
1610
+ //* A function to load the utils script.
1611
+ loadUtils: null,
1612
1612
  //* National vs international formatting for numbers e.g. placeholders and displaying existing numbers.
1613
1613
  nationalMode: !0,
1614
1614
  //* Display only these countries.
@@ -1629,10 +1629,8 @@ const T = {
1629
1629
  navigator.userAgent
1630
1630
  ) || window.innerWidth <= 500
1631
1631
  ) : !1,
1632
- //* Deprecated! Use `loadUtilsOnInit` instead.
1633
- utilsScript: "",
1634
1632
  //* The number type to enforce during validation.
1635
- validationNumberType: "MOBILE"
1633
+ validationNumberTypes: ["MOBILE"]
1636
1634
  }, K = [
1637
1635
  "800",
1638
1636
  "822",
@@ -1938,12 +1936,12 @@ class G {
1938
1936
  }
1939
1937
  //* Init many requests: utils script / geo ip lookup.
1940
1938
  _initRequests() {
1941
- let { loadUtilsOnInit: t, utilsScript: e, initialCountry: i, geoIpLookup: s } = this.options;
1942
- !t && e && (console.warn("intl-tel-input: The `utilsScript` option is deprecated and will be removed in a future release! Please use the `loadUtilsOnInit` option instead."), t = e), t && !l.utils ? (this._handlePageLoad = () => {
1943
- var o;
1944
- window.removeEventListener("load", this._handlePageLoad), (o = l.loadUtils(t)) == null || o.catch(() => {
1939
+ let { loadUtils: t, initialCountry: e, geoIpLookup: i } = this.options;
1940
+ t && !l.utils ? (this._handlePageLoad = () => {
1941
+ var n;
1942
+ window.removeEventListener("load", this._handlePageLoad), (n = l.attachUtils(t)) == null || n.catch(() => {
1945
1943
  });
1946
- }, l.documentReady() ? this._handlePageLoad() : window.addEventListener("load", this._handlePageLoad)) : this.resolveUtilsScriptPromise(), i === "auto" && s && !this.selectedCountryData.iso2 ? this._loadAutoCountry() : this.resolveAutoCountryPromise();
1944
+ }, l.documentReady() ? this._handlePageLoad() : window.addEventListener("load", this._handlePageLoad)) : this.resolveUtilsScriptPromise(), e === "auto" && i && !this.selectedCountryData.iso2 ? this._loadAutoCountry() : this.resolveAutoCountryPromise();
1947
1945
  }
1948
1946
  //* Perform the geo ip lookup.
1949
1947
  _loadAutoCountry() {
@@ -2190,7 +2188,7 @@ class G {
2190
2188
  }
2191
2189
  //* Update the maximum valid number length for the currently selected country.
2192
2190
  _updateMaxLength() {
2193
- const { strictMode: t, placeholderNumberType: e, validationNumberType: i } = this.options, { iso2: s } = this.selectedCountryData;
2191
+ const { strictMode: t, placeholderNumberType: e, validationNumberTypes: i } = this.options, { iso2: s } = this.selectedCountryData;
2194
2192
  if (t && l.utils)
2195
2193
  if (s) {
2196
2194
  const n = l.utils.numberType[e];
@@ -2420,7 +2418,7 @@ class G {
2420
2418
  return this._utilsIsPossibleNumber(t);
2421
2419
  }
2422
2420
  _utilsIsPossibleNumber(t) {
2423
- return l.utils ? l.utils.isPossibleNumber(t, this.selectedCountryData.iso2, this.options.validationNumberType) : null;
2421
+ return l.utils ? l.utils.isPossibleNumber(t, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
2424
2422
  }
2425
2423
  //* Validate the input val (precise)
2426
2424
  isValidNumberPrecise() {
@@ -2434,7 +2432,7 @@ class G {
2434
2432
  return this._utilsIsValidNumber(t);
2435
2433
  }
2436
2434
  _utilsIsValidNumber(t) {
2437
- return l.utils ? l.utils.isValidNumber(t, this.selectedCountryData.iso2) : null;
2435
+ return l.utils ? l.utils.isValidNumber(t, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
2438
2436
  }
2439
2437
  //* Update the selected country, and update the input val accordingly.
2440
2438
  setCountry(t) {
@@ -2457,24 +2455,18 @@ class G {
2457
2455
  const W = (u) => {
2458
2456
  if (!l.utils && !l.startedLoadingUtilsScript) {
2459
2457
  let t;
2460
- if (typeof u == "string")
2461
- t = import(
2462
- /* webpackIgnore: true */
2463
- /* @vite-ignore */
2464
- u
2465
- );
2466
- else if (typeof u == "function")
2458
+ if (typeof u == "function")
2467
2459
  try {
2468
2460
  t = Promise.resolve(u());
2469
2461
  } catch (e) {
2470
2462
  return Promise.reject(e);
2471
2463
  }
2472
2464
  else
2473
- return Promise.reject(new TypeError(`The argument passed to loadUtils must be a URL string or a function that returns a promise for the utilities module, not ${typeof u}`));
2465
+ return Promise.reject(new TypeError(`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof u}`));
2474
2466
  return l.startedLoadingUtilsScript = !0, t.then((e) => {
2475
2467
  const i = e == null ? void 0 : e.default;
2476
2468
  if (!i || typeof i != "object")
2477
- throw typeof u == "string" ? new TypeError(`The module loaded from ${u} did not set utils as its default export.`) : new TypeError("The loader function passed to loadUtils did not resolve to a module object with utils as its default export.");
2469
+ throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
2478
2470
  return l.utils = i, _("handleUtils"), !0;
2479
2471
  }).catch((e) => {
2480
2472
  throw _("rejectUtilsScriptPromise", e), e;
@@ -2499,10 +2491,10 @@ const W = (u) => {
2499
2491
  },
2500
2492
  //* A map from instance ID to instance object.
2501
2493
  instances: {},
2502
- loadUtils: W,
2494
+ attachUtils: W,
2503
2495
  startedLoadingUtilsScript: !1,
2504
2496
  startedLoadingAutoCountry: !1,
2505
- version: "24.8.1"
2497
+ version: "25.0.0"
2506
2498
  }
2507
2499
  ), J = {
2508
2500
  __name: "IntlTelInput",
@@ -2558,10 +2550,10 @@ const W = (u) => {
2558
2550
  var m;
2559
2551
  return (m = a.value) == null ? void 0 : m.setDisabled(h);
2560
2552
  }
2561
- ), O(() => {
2553
+ ), F(() => {
2562
2554
  var h;
2563
2555
  return (h = a.value) == null ? void 0 : h.destroy();
2564
- }), t({ instance: a, input: o }), (h, m) => F((B(), V("input", z({
2556
+ }), t({ instance: a, input: o }), (h, m) => B((O(), V("input", z({
2565
2557
  ref_key: "input",
2566
2558
  ref: o,
2567
2559
  "onUpdate:modelValue": m[0] || (m[0] = (f) => i.value = f),