intl-tel-input 24.8.2 → 25.0.1
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/README.md +56 -47
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput.d.ts +6 -8
- package/build/js/intlTelInput.js +37 -43
- package/build/js/intlTelInput.min.js +2 -2
- package/build/js/intlTelInputWithUtils.js +301 -302
- package/build/js/intlTelInputWithUtils.min.js +2 -2
- package/build/js/utils.js +51 -52
- package/package.json +1 -1
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +36 -42
- package/react/build/IntlTelInput.d.ts +6 -8
- package/react/build/IntlTelInput.js +36 -42
- package/react/build/IntlTelInputWithUtils.cjs +300 -301
- package/react/build/IntlTelInputWithUtils.js +300 -301
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +64 -65
- package/vue/build/IntlTelInputWithUtils.mjs +669 -671
package/README.md
CHANGED
|
@@ -75,16 +75,16 @@ _Note: We have now dropped support for all versions of Internet Explorer because
|
|
|
75
75
|
## Getting Started (Using a CDN)
|
|
76
76
|
1. Add the CSS
|
|
77
77
|
```html
|
|
78
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@
|
|
78
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@25.0.1/build/css/intlTelInput.css">
|
|
79
79
|
```
|
|
80
80
|
|
|
81
81
|
2. Add the plugin script and initialise it on your input element
|
|
82
82
|
```html
|
|
83
|
-
<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@
|
|
83
|
+
<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@25.0.1/build/js/intlTelInput.min.js"></script>
|
|
84
84
|
<script>
|
|
85
85
|
const input = document.querySelector("#phone");
|
|
86
86
|
window.intlTelInput(input, {
|
|
87
|
-
|
|
87
|
+
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.0.1/build/js/utils.js"),
|
|
88
88
|
});
|
|
89
89
|
</script>
|
|
90
90
|
```
|
|
@@ -110,20 +110,11 @@ _Note: We have now dropped support for all versions of Internet Explorer because
|
|
|
110
110
|
|
|
111
111
|
const input = document.querySelector("#phone");
|
|
112
112
|
intlTelInput(input, {
|
|
113
|
-
|
|
113
|
+
loadUtils: () => import("intl-tel-input/utils"),
|
|
114
114
|
});
|
|
115
115
|
```
|
|
116
116
|
|
|
117
|
-
Most bundlers (such as Webpack, Vite, or Parcel) will see this and place the [utilities script](#utilities-script) in a separate bundle and load it asynchronously, only when needed. If this doesn’t work with your bundler or you want to load the utils module from some other location (such as a CDN
|
|
118
|
-
|
|
119
|
-
```js
|
|
120
|
-
import intlTelInput from 'intl-tel-input';
|
|
121
|
-
|
|
122
|
-
const input = document.querySelector("#phone");
|
|
123
|
-
intlTelInput(input, {
|
|
124
|
-
loadUtilsOnInit: `https://cdn.jsdelivr.net/npm/intl-tel-input@${intlTelInput.version}/build/js/utils.js`;
|
|
125
|
-
});
|
|
126
|
-
```
|
|
117
|
+
Most bundlers (such as Webpack, Vite, or Parcel) will see this and place the [utilities script](#utilities-script) in a separate bundle and load it asynchronously, only when needed. If this doesn’t work with your bundler or you want to load the utils module from some other location (such as a CDN or your own hosted version), you can do that as well - see other examples.
|
|
127
118
|
|
|
128
119
|
## Getting Started (Not using a bundler)
|
|
129
120
|
1. Download the [latest release](https://github.com/jackocnr/intl-tel-input/releases/latest), or better yet install it with [npm](https://www.npmjs.com/package/intl-tel-input)
|
|
@@ -149,7 +140,7 @@ intlTelInput(input, {
|
|
|
149
140
|
<script>
|
|
150
141
|
const input = document.querySelector("#phone");
|
|
151
142
|
window.intlTelInput(input, {
|
|
152
|
-
|
|
143
|
+
loadUtils: () => import("https://my-domain/path/to/utils.js"),
|
|
153
144
|
});
|
|
154
145
|
</script>
|
|
155
146
|
```
|
|
@@ -316,14 +307,33 @@ intlTelInput(input, {
|
|
|
316
307
|
Type: `String` Default: `""`
|
|
317
308
|
Set the initial country selection by specifying its country code e.g. `"us"` for the United States. (Be careful not to do this unless you are sure of the user's country, as it can lead to tricky issues if set incorrectly and the user auto-fills their national number and submits the form without checking - in certain cases, this can pass validation and you can end up storing a number with the wrong dial code). You can also set `initialCountry` to `"auto"`, which will look up the user's country based on their IP address (requires the `geoIpLookup` option - [see example](https://intl-tel-input.com/examples/lookup-country.html)). Note that however you use `initialCountry`, it will not update the country selection if the input already contains a number with an international dial code.
|
|
318
309
|
|
|
319
|
-
**
|
|
320
|
-
Type: `
|
|
310
|
+
**loadUtils**
|
|
311
|
+
Type: `() => Promise<module>` Default: `null` Example: `() => import("/path/to/utils.js")`
|
|
312
|
+
|
|
313
|
+
This is one way to lazy load the included utils.js (to enable formatting/validation etc) - see [Loading The Utilities Script](#loading-the-utilities-script) for more options.
|
|
314
|
+
|
|
315
|
+
The `loadUtils` option takes a function which returns a Promise which resolves to the utils module. You can `import` the utils module in different ways: (A) from a CDN, (B) from your own hosted version of [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js), or (C) if you use a bundler like Webpack, Vite or Parcel, you can import it directly from the package.
|
|
316
|
+
|
|
317
|
+
```js
|
|
318
|
+
// (A) import utils module from a CDN
|
|
319
|
+
intlTelInput(htmlInputElement, {
|
|
320
|
+
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.0.1/build/js/utils.js"),
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
// (B) import utils module from your own hosted version of utils.js
|
|
324
|
+
intlTelInput(htmlInputElement, {
|
|
325
|
+
loadUtils: () => import("https://my-domain.com/path/to/utils.js"),
|
|
326
|
+
});
|
|
321
327
|
|
|
322
|
-
|
|
328
|
+
// (C) if your bundler supports it, you can import utils module directly from the package
|
|
329
|
+
intlTelInput(htmlInputElement, {
|
|
330
|
+
loadUtils: () => import("intl-tel-input/utils"),
|
|
331
|
+
});
|
|
332
|
+
```
|
|
323
333
|
|
|
324
|
-
|
|
334
|
+
The module is only loaded when you initialise the plugin, and additionally, only when the page has finished loading (on the window load event) to prevent blocking (the script is ~260KB). When instantiating the plugin, a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) object is returned under the `promise` instance property, so you can do something like `iti.promise.then(callback)` to know when initialisation requests like this have finished. See [Utilities Script](#utilities-script) for more information.
|
|
325
335
|
|
|
326
|
-
|
|
336
|
+
If you want more control over when this file is lazy loaded, you can manually invoke the `attachUtils` static method whenever you like, instead of using the `loadUtils` initialisation option.
|
|
327
337
|
|
|
328
338
|
**nationalMode**
|
|
329
339
|
Type: `Boolean` Default: `true`
|
|
@@ -349,20 +359,15 @@ Display the selected country's international dial code next to the input, so it
|
|
|
349
359
|
|
|
350
360
|
**strictMode**
|
|
351
361
|
Type: `Boolean` Default: `false`
|
|
352
|
-
As the user types in the input, ignore any irrelevant characters. The user can only enter numeric characters and an optional plus at the beginning. Cap the length at the maximum valid number length (this respects `
|
|
362
|
+
As the user types in the input, ignore any irrelevant characters. The user can only enter numeric characters and an optional plus at the beginning. Cap the length at the maximum valid number length (this respects `validationNumberTypes`). Requires the [utils script to be loaded](#loading-the-utilities-script). [See example](https://intl-tel-input.com/examples/strict-mode.html).
|
|
353
363
|
|
|
354
364
|
**useFullscreenPopup**
|
|
355
365
|
Type: `Boolean` Default: `true on mobile devices, false otherwise`
|
|
356
366
|
Control when the country list appears as a fullscreen popup vs an inline dropdown. By default, it will appear as a fullscreen popup on mobile devices (based on user-agent and screen width), to make better use of the limited space (similar to how a native `<select>` works), and as an inline dropdown on larger devices/screens. Play with this option on [Storybook](https://intl-tel-input.com/storybook/?path=/docs/intltelinput--usefullscreenpopup) (using the React component).
|
|
357
367
|
|
|
358
|
-
**
|
|
359
|
-
Type: `String`
|
|
360
|
-
|
|
361
|
-
This option is deprecated and has been renamed to `loadUtilsOnInit`. Please see the deatails for that option and use it instead.
|
|
362
|
-
|
|
363
|
-
**validationNumberType**
|
|
364
|
-
Type: `String` Default: `"MOBILE"`
|
|
365
|
-
Specify [one of the keys](https://github.com/jackocnr/intl-tel-input/blob/master/src/js/utils.js#L162) from the enum `intlTelInput.utils.numberType` (e.g. `"FIXED_LINE"`) to set the number type to enforce during validation with `isValidNumber`, as well as the number length to enforce with `strictMode`. Set it to `null` to not enforce any particular type.
|
|
368
|
+
**validationNumberTypes**
|
|
369
|
+
Type: `String` Default: `["MOBILE"]`
|
|
370
|
+
Specify an array of [the keys](https://github.com/jackocnr/intl-tel-input/blob/master/src/js/utils.js#L162) from the enum `intlTelInput.utils.numberType` to set the number type(s) to enforce during validation with `isValidNumber`, as well as the number length to enforce with `strictMode`. Set it to `null` to not enforce any particular type. By default, it's set to `["MOBILE"]` so `isValidNumber` will only return `true` for mobile numbers. Alternatively, you could set it to `["TOLL_FREE", "PREMIUM_RATE"]` to get `isValidNumber` to return `true` for only those kinds of numbers.
|
|
366
371
|
|
|
367
372
|
## Instance Methods
|
|
368
373
|
In these examples, `iti` refers to the plugin instance which gets returned when you initialise the plugin e.g.
|
|
@@ -432,14 +437,14 @@ if (error === intlTelInput.utils.validationError.TOO_SHORT) {
|
|
|
432
437
|
```
|
|
433
438
|
|
|
434
439
|
**isValidNumber**
|
|
435
|
-
Check if the current number is valid based on its length - [see example](https://intl-tel-input.com/examples/validation-practical.html), which should be sufficient for most use cases. See `isValidNumberPrecise` (DANGEROUS) for more precise validation, but the advantage of `isValidNumber` is that it is much more future-proof as while countries around the world regularly update their number rules, they rarely change their number lengths. If this method returns `false`, you can use `getValidationError` to get more information. Respects the `
|
|
440
|
+
Check if the current number is valid based on its length - [see example](https://intl-tel-input.com/examples/validation-practical.html), which should be sufficient for most use cases. See `isValidNumberPrecise` (DANGEROUS) for more precise validation, but the advantage of `isValidNumber` is that it is much more future-proof as while countries around the world regularly update their number rules, they rarely change their number lengths. If this method returns `false`, you can use `getValidationError` to get more information. Respects the `validationNumberTypes` option (which is set to `["MOBILE"]` by default). Requires the [utils script to be loaded](#loading-the-utilities-script).
|
|
436
441
|
```js
|
|
437
442
|
const isValid = iti.isValidNumber();
|
|
438
443
|
```
|
|
439
444
|
Returns: `true`/`false`
|
|
440
445
|
|
|
441
446
|
**isValidNumberPrecise** ⚠️ DANGEROUS
|
|
442
|
-
Check if the current number is valid using precise matching rules for each country/area code etc - [see example](https://intl-tel-input.com/examples/validation.html). Note that these rules change each month for various countries around the world, so you need to be careful to constantly keep the plugin up-to-date (e.g. via an automated script) else <ins>you will start rejecting valid numbers</ins>. For a simpler and more future-proof form of validation, see `isValidNumber` above. If validation fails, you can use `getValidationError` to get more information. Requires the [utils script to be loaded](#loading-the-utilities-script).
|
|
447
|
+
Check if the current number is valid using precise matching rules for each country/area code etc - [see example](https://intl-tel-input.com/examples/validation.html). Note that these rules change each month for various countries around the world, so you need to be careful to constantly keep the plugin up-to-date (e.g. via an automated script) else <ins>you will start rejecting valid numbers</ins>. For a simpler and more future-proof form of validation, see `isValidNumber` above. If validation fails, you can use `getValidationError` to get more information. Respects the `validationNumberTypes` option (which is set to `["MOBILE"]` by default). Requires the [utils script to be loaded](#loading-the-utilities-script).
|
|
443
448
|
```js
|
|
444
449
|
const isValid = iti.isValidNumberPrecise();
|
|
445
450
|
```
|
|
@@ -493,18 +498,11 @@ const iti = intlTelInput.getInstance(input);
|
|
|
493
498
|
iti.isValidNumber(); // etc
|
|
494
499
|
```
|
|
495
500
|
|
|
496
|
-
**
|
|
497
|
-
An alternative to the `
|
|
501
|
+
**attachUtils**
|
|
502
|
+
An alternative to the `loadUtils` option, this method lets you manually load the utils.js script on demand, to enable formatting/validation etc. See [Loading The Utilities Script](#loading-the-utilities-script) for more information. This method should only be called once per page. A [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) object is returned so you can use `attachUtils().then(...)` to know when it's finished.
|
|
498
503
|
```js
|
|
499
|
-
|
|
500
|
-
intlTelInput.loadUtils
|
|
501
|
-
|
|
502
|
-
// Or manage load via some other method with a function:
|
|
503
|
-
intlTelInput.loadUtils(async () => {
|
|
504
|
-
// Your own loading logic here. Return a JavaScript "module" object with
|
|
505
|
-
// the utils as the default export.
|
|
506
|
-
return { default: { /* a copy of the utils module */ } }
|
|
507
|
-
});
|
|
504
|
+
const loadUtils = () => import("/build/js/utils.js");
|
|
505
|
+
intlTelInput.attachUtils(loadUtils);
|
|
508
506
|
```
|
|
509
507
|
|
|
510
508
|
## Events
|
|
@@ -592,18 +590,29 @@ The utils script provides lots of great functionality (see above section), but c
|
|
|
592
590
|
**Option 1: intlTelInputWithUtils**
|
|
593
591
|
If you're not concerned about filesize (e.g. you're lazy loading this script), the easiest thing to do is to just use the full bundle (`/build/js/intlTelInputWithUtils.js`), which comes with the utils script included. This script can be used exactly like the main intlTelInput.js - so it can either be loaded directly onto the page (which defines `window.intlTelInput` like usual), or it can be imported like so: `import intlTelInput from "intl-tel-input/intlTelInputWithUtils"`.
|
|
594
592
|
|
|
595
|
-
**Option 2:
|
|
596
|
-
If you *are* concerned about filesize, you can lazy load the utils
|
|
593
|
+
**Option 2: loadUtils**
|
|
594
|
+
If you *are* concerned about filesize, you can lazy load the utils module when the plugin initialises, using the `loadUtils` initialisation option.
|
|
597
595
|
|
|
598
|
-
|
|
596
|
+
The `loadUtils` option takes a function which returns a Promise which resolves to the utils module. You can `import` the utils module in different ways: (A) from a CDN, (B) from your own hosted version of [utils.js](https://github.com/jackocnr/intl-tel-input/blob/master/build/js/utils.js), or (C) if you use a bundler like Webpack, Vite or Parcel, you can import it directly from the package.
|
|
599
597
|
|
|
600
598
|
```js
|
|
599
|
+
// (A) import utils module from a CDN
|
|
600
|
+
intlTelInput(htmlInputElement, {
|
|
601
|
+
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.0.1/build/js/utils.js"),
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
// (B) import utils module from your own hosted version of utils.js
|
|
605
|
+
intlTelInput(htmlInputElement, {
|
|
606
|
+
loadUtils: () => import("https://my-domain.com/path/to/utils.js"),
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
// (C) if your bundler supports it, you can import utils module directly from the package
|
|
601
610
|
intlTelInput(htmlInputElement, {
|
|
602
|
-
|
|
611
|
+
loadUtils: () => import("intl-tel-input/utils"),
|
|
603
612
|
});
|
|
604
613
|
```
|
|
605
614
|
|
|
606
|
-
If you want more control over when this file is lazy loaded, you can manually invoke the `
|
|
615
|
+
If you want more control over when this file is lazy loaded, you can manually invoke the `attachUtils` static method whenever you like, instead of using the `loadUtils` initialisation option.
|
|
607
616
|
|
|
608
617
|
## Troubleshooting
|
|
609
618
|
|
package/build/js/data.js
CHANGED
package/build/js/data.min.js
CHANGED
|
@@ -299,7 +299,7 @@ declare module "intl-tel-input" {
|
|
|
299
299
|
instances: {
|
|
300
300
|
[key: string]: Iti;
|
|
301
301
|
};
|
|
302
|
-
|
|
302
|
+
attachUtils: (source: UtilsLoader) => Promise<unknown> | null;
|
|
303
303
|
startedLoadingAutoCountry: boolean;
|
|
304
304
|
startedLoadingUtilsScript: boolean;
|
|
305
305
|
version: string | undefined;
|
|
@@ -311,10 +311,10 @@ declare module "intl-tel-input" {
|
|
|
311
311
|
getCoreNumber(number: string, iso2: string | undefined): string;
|
|
312
312
|
getExampleNumber(iso2: string | undefined, nationalMode: boolean, numberType: number, useE164?: boolean): string;
|
|
313
313
|
getExtension(number: string, iso2: string | undefined): string;
|
|
314
|
-
getNumberType
|
|
314
|
+
getNumberType(number: string, iso2: string | undefined): number;
|
|
315
315
|
getValidationError(number: string, iso2: string | undefined): number;
|
|
316
|
-
isPossibleNumber(number: string, iso2: string | undefined, numberType?:
|
|
317
|
-
isValidNumber
|
|
316
|
+
isPossibleNumber(number: string, iso2: string | undefined, numberType?: NumberType[] | null): boolean;
|
|
317
|
+
isValidNumber(number: string, iso2: string | undefined, numberType?: NumberType[] | null): boolean;
|
|
318
318
|
numberFormat: {
|
|
319
319
|
NATIONAL: number;
|
|
320
320
|
INTERNATIONAL: number;
|
|
@@ -348,7 +348,7 @@ declare module "intl-tel-input" {
|
|
|
348
348
|
}) | null;
|
|
349
349
|
i18n: I18n;
|
|
350
350
|
initialCountry: string;
|
|
351
|
-
|
|
351
|
+
loadUtils: UtilsLoader;
|
|
352
352
|
nationalMode: boolean;
|
|
353
353
|
onlyCountries: string[];
|
|
354
354
|
placeholderNumberType: NumberType;
|
|
@@ -356,9 +356,7 @@ declare module "intl-tel-input" {
|
|
|
356
356
|
separateDialCode: boolean;
|
|
357
357
|
strictMode: boolean;
|
|
358
358
|
useFullscreenPopup: boolean;
|
|
359
|
-
|
|
360
|
-
utilsScript: string | UtilsLoader;
|
|
361
|
-
validationNumberType: NumberType | null;
|
|
359
|
+
validationNumberTypes: NumberType[] | null;
|
|
362
360
|
}
|
|
363
361
|
export type SomeOptions = Partial<AllOptions>;
|
|
364
362
|
export class Iti {
|
package/build/js/intlTelInput.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* International Telephone Input
|
|
2
|
+
* International Telephone Input v25.0.1
|
|
3
3
|
* https://github.com/jackocnr/intl-tel-input.git
|
|
4
4
|
* Licensed under the MIT license
|
|
5
5
|
*/
|
|
@@ -1664,8 +1664,8 @@ var factoryOutput = (() => {
|
|
|
1664
1664
|
i18n: {},
|
|
1665
1665
|
//* Initial country.
|
|
1666
1666
|
initialCountry: "",
|
|
1667
|
-
//*
|
|
1668
|
-
|
|
1667
|
+
//* A function to load the utils script.
|
|
1668
|
+
loadUtils: null,
|
|
1669
1669
|
//* National vs international formatting for numbers e.g. placeholders and displaying existing numbers.
|
|
1670
1670
|
nationalMode: true,
|
|
1671
1671
|
//* Display only these countries.
|
|
@@ -1686,10 +1686,8 @@ var factoryOutput = (() => {
|
|
|
1686
1686
|
navigator.userAgent
|
|
1687
1687
|
) || window.innerWidth <= 500
|
|
1688
1688
|
) : false,
|
|
1689
|
-
//* Deprecated! Use `loadUtilsOnInit` instead.
|
|
1690
|
-
utilsScript: "",
|
|
1691
1689
|
//* The number type to enforce during validation.
|
|
1692
|
-
|
|
1690
|
+
validationNumberTypes: ["MOBILE"]
|
|
1693
1691
|
};
|
|
1694
1692
|
var regionlessNanpNumbers = [
|
|
1695
1693
|
"800",
|
|
@@ -2062,18 +2060,28 @@ var factoryOutput = (() => {
|
|
|
2062
2060
|
const telInputName = this.telInput.getAttribute("name") || "";
|
|
2063
2061
|
const names = hiddenInput(telInputName);
|
|
2064
2062
|
if (names.phone) {
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
}
|
|
2069
|
-
|
|
2063
|
+
const existingInput = this.telInput.form?.querySelector(`input[name="${names.phone}"]`);
|
|
2064
|
+
if (existingInput) {
|
|
2065
|
+
this.hiddenInput = existingInput;
|
|
2066
|
+
} else {
|
|
2067
|
+
this.hiddenInput = createEl("input", {
|
|
2068
|
+
type: "hidden",
|
|
2069
|
+
name: names.phone
|
|
2070
|
+
});
|
|
2071
|
+
wrapper.appendChild(this.hiddenInput);
|
|
2072
|
+
}
|
|
2070
2073
|
}
|
|
2071
2074
|
if (names.country) {
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
}
|
|
2076
|
-
|
|
2075
|
+
const existingInput = this.telInput.form?.querySelector(`input[name="${names.country}"]`);
|
|
2076
|
+
if (existingInput) {
|
|
2077
|
+
this.hiddenInputCountry = existingInput;
|
|
2078
|
+
} else {
|
|
2079
|
+
this.hiddenInputCountry = createEl("input", {
|
|
2080
|
+
type: "hidden",
|
|
2081
|
+
name: names.country
|
|
2082
|
+
});
|
|
2083
|
+
wrapper.appendChild(this.hiddenInputCountry);
|
|
2084
|
+
}
|
|
2077
2085
|
}
|
|
2078
2086
|
}
|
|
2079
2087
|
}
|
|
@@ -2198,15 +2206,11 @@ var factoryOutput = (() => {
|
|
|
2198
2206
|
}
|
|
2199
2207
|
//* Init many requests: utils script / geo ip lookup.
|
|
2200
2208
|
_initRequests() {
|
|
2201
|
-
let {
|
|
2202
|
-
if (
|
|
2203
|
-
console.warn("intl-tel-input: The `utilsScript` option is deprecated and will be removed in a future release! Please use the `loadUtilsOnInit` option instead.");
|
|
2204
|
-
loadUtilsOnInit = utilsScript;
|
|
2205
|
-
}
|
|
2206
|
-
if (loadUtilsOnInit && !intlTelInput.utils) {
|
|
2209
|
+
let { loadUtils, initialCountry, geoIpLookup } = this.options;
|
|
2210
|
+
if (loadUtils && !intlTelInput.utils) {
|
|
2207
2211
|
this._handlePageLoad = () => {
|
|
2208
2212
|
window.removeEventListener("load", this._handlePageLoad);
|
|
2209
|
-
intlTelInput.loadUtils
|
|
2213
|
+
intlTelInput.attachUtils(loadUtils)?.catch(() => {
|
|
2210
2214
|
});
|
|
2211
2215
|
};
|
|
2212
2216
|
if (intlTelInput.documentReady()) {
|
|
@@ -2670,7 +2674,7 @@ var factoryOutput = (() => {
|
|
|
2670
2674
|
}
|
|
2671
2675
|
//* Update the maximum valid number length for the currently selected country.
|
|
2672
2676
|
_updateMaxLength() {
|
|
2673
|
-
const { strictMode, placeholderNumberType,
|
|
2677
|
+
const { strictMode, placeholderNumberType, validationNumberTypes } = this.options;
|
|
2674
2678
|
const { iso2 } = this.selectedCountryData;
|
|
2675
2679
|
if (strictMode && intlTelInput.utils) {
|
|
2676
2680
|
if (iso2) {
|
|
@@ -2682,7 +2686,7 @@ var factoryOutput = (() => {
|
|
|
2682
2686
|
true
|
|
2683
2687
|
);
|
|
2684
2688
|
let validNumber = exampleNumber;
|
|
2685
|
-
while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2,
|
|
2689
|
+
while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2, validationNumberTypes)) {
|
|
2686
2690
|
validNumber = exampleNumber;
|
|
2687
2691
|
exampleNumber += "0";
|
|
2688
2692
|
}
|
|
@@ -3034,7 +3038,7 @@ var factoryOutput = (() => {
|
|
|
3034
3038
|
return this._utilsIsPossibleNumber(val);
|
|
3035
3039
|
}
|
|
3036
3040
|
_utilsIsPossibleNumber(val) {
|
|
3037
|
-
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.
|
|
3041
|
+
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
3038
3042
|
}
|
|
3039
3043
|
//* Validate the input val (precise)
|
|
3040
3044
|
isValidNumberPrecise() {
|
|
@@ -3052,7 +3056,7 @@ var factoryOutput = (() => {
|
|
|
3052
3056
|
return this._utilsIsValidNumber(val);
|
|
3053
3057
|
}
|
|
3054
3058
|
_utilsIsValidNumber(val) {
|
|
3055
|
-
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2) : null;
|
|
3059
|
+
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
3056
3060
|
}
|
|
3057
3061
|
//* Update the selected country, and update the input val accordingly.
|
|
3058
3062
|
setCountry(iso2) {
|
|
@@ -3088,33 +3092,23 @@ var factoryOutput = (() => {
|
|
|
3088
3092
|
}
|
|
3089
3093
|
}
|
|
3090
3094
|
};
|
|
3091
|
-
var
|
|
3095
|
+
var attachUtils = (source) => {
|
|
3092
3096
|
if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
|
|
3093
3097
|
let loadCall;
|
|
3094
|
-
if (typeof source === "
|
|
3095
|
-
loadCall = import(
|
|
3096
|
-
/* webpackIgnore: true */
|
|
3097
|
-
/* @vite-ignore */
|
|
3098
|
-
source
|
|
3099
|
-
);
|
|
3100
|
-
} else if (typeof source === "function") {
|
|
3098
|
+
if (typeof source === "function") {
|
|
3101
3099
|
try {
|
|
3102
3100
|
loadCall = Promise.resolve(source());
|
|
3103
3101
|
} catch (error) {
|
|
3104
3102
|
return Promise.reject(error);
|
|
3105
3103
|
}
|
|
3106
3104
|
} else {
|
|
3107
|
-
return Promise.reject(new TypeError(`The argument passed to
|
|
3105
|
+
return Promise.reject(new TypeError(`The argument passed to attachUtils must be a function that returns a promise for the utilities module, not ${typeof source}`));
|
|
3108
3106
|
}
|
|
3109
3107
|
intlTelInput.startedLoadingUtilsScript = true;
|
|
3110
3108
|
return loadCall.then((module) => {
|
|
3111
3109
|
const utils = module?.default;
|
|
3112
3110
|
if (!utils || typeof utils !== "object") {
|
|
3113
|
-
|
|
3114
|
-
throw new TypeError(`The module loaded from ${source} did not set utils as its default export.`);
|
|
3115
|
-
} else {
|
|
3116
|
-
throw new TypeError("The loader function passed to loadUtils did not resolve to a module object with utils as its default export.");
|
|
3117
|
-
}
|
|
3111
|
+
throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
|
|
3118
3112
|
}
|
|
3119
3113
|
intlTelInput.utils = utils;
|
|
3120
3114
|
forEachInstance("handleUtils");
|
|
@@ -3147,10 +3141,10 @@ var factoryOutput = (() => {
|
|
|
3147
3141
|
},
|
|
3148
3142
|
//* A map from instance ID to instance object.
|
|
3149
3143
|
instances: {},
|
|
3150
|
-
|
|
3144
|
+
attachUtils,
|
|
3151
3145
|
startedLoadingUtilsScript: false,
|
|
3152
3146
|
startedLoadingAutoCountry: false,
|
|
3153
|
-
version: "
|
|
3147
|
+
version: "25.0.1"
|
|
3154
3148
|
}
|
|
3155
3149
|
);
|
|
3156
3150
|
var intl_tel_input_default = intlTelInput;
|