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/README.md +57 -48
- 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 +17 -33
- package/build/js/intlTelInput.min.js +2 -2
- package/build/js/intlTelInputWithUtils.js +448 -404
- package/build/js/intlTelInputWithUtils.min.js +2 -2
- package/build/js/utils.js +90 -91
- package/package.json +1 -1
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +16 -32
- package/react/build/IntlTelInput.d.ts +6 -8
- package/react/build/IntlTelInput.js +16 -32
- package/react/build/IntlTelInputWithUtils.cjs +447 -403
- package/react/build/IntlTelInputWithUtils.js +447 -403
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +19 -27
- package/vue/build/IntlTelInputWithUtils.mjs +770 -724
package/package.json
CHANGED
package/react/README.md
CHANGED
|
@@ -28,7 +28,7 @@ import "intl-tel-input/styles";
|
|
|
28
28
|
|
|
29
29
|
See the [Validation demo](https://github.com/jackocnr/intl-tel-input/blob/master/react/demo/validation/ValidationApp.tsx) for a more fleshed-out example of how to handle validation.
|
|
30
30
|
|
|
31
|
-
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/reactWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/react"` 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@
|
|
31
|
+
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/reactWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/react"` 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"`.
|
|
32
32
|
|
|
33
33
|
## Props
|
|
34
34
|
Here's a list of all of the current props you can pass to the IntlTelInput React component.
|
|
@@ -1659,8 +1659,8 @@ var defaults = {
|
|
|
1659
1659
|
i18n: {},
|
|
1660
1660
|
//* Initial country.
|
|
1661
1661
|
initialCountry: "",
|
|
1662
|
-
//*
|
|
1663
|
-
|
|
1662
|
+
//* A function to load the utils script.
|
|
1663
|
+
loadUtils: null,
|
|
1664
1664
|
//* National vs international formatting for numbers e.g. placeholders and displaying existing numbers.
|
|
1665
1665
|
nationalMode: true,
|
|
1666
1666
|
//* Display only these countries.
|
|
@@ -1681,10 +1681,8 @@ var defaults = {
|
|
|
1681
1681
|
navigator.userAgent
|
|
1682
1682
|
) || window.innerWidth <= 500
|
|
1683
1683
|
) : false,
|
|
1684
|
-
//* Deprecated! Use `loadUtilsOnInit` instead.
|
|
1685
|
-
utilsScript: "",
|
|
1686
1684
|
//* The number type to enforce during validation.
|
|
1687
|
-
|
|
1685
|
+
validationNumberTypes: ["MOBILE"]
|
|
1688
1686
|
};
|
|
1689
1687
|
var regionlessNanpNumbers = [
|
|
1690
1688
|
"800",
|
|
@@ -2193,15 +2191,11 @@ var Iti = class {
|
|
|
2193
2191
|
}
|
|
2194
2192
|
//* Init many requests: utils script / geo ip lookup.
|
|
2195
2193
|
_initRequests() {
|
|
2196
|
-
let {
|
|
2197
|
-
if (
|
|
2198
|
-
console.warn("intl-tel-input: The `utilsScript` option is deprecated and will be removed in a future release! Please use the `loadUtilsOnInit` option instead.");
|
|
2199
|
-
loadUtilsOnInit = utilsScript;
|
|
2200
|
-
}
|
|
2201
|
-
if (loadUtilsOnInit && !intlTelInput.utils) {
|
|
2194
|
+
let { loadUtils, initialCountry, geoIpLookup } = this.options;
|
|
2195
|
+
if (loadUtils && !intlTelInput.utils) {
|
|
2202
2196
|
this._handlePageLoad = () => {
|
|
2203
2197
|
window.removeEventListener("load", this._handlePageLoad);
|
|
2204
|
-
intlTelInput.loadUtils
|
|
2198
|
+
intlTelInput.attachUtils(loadUtils)?.catch(() => {
|
|
2205
2199
|
});
|
|
2206
2200
|
};
|
|
2207
2201
|
if (intlTelInput.documentReady()) {
|
|
@@ -2665,7 +2659,7 @@ var Iti = class {
|
|
|
2665
2659
|
}
|
|
2666
2660
|
//* Update the maximum valid number length for the currently selected country.
|
|
2667
2661
|
_updateMaxLength() {
|
|
2668
|
-
const { strictMode, placeholderNumberType,
|
|
2662
|
+
const { strictMode, placeholderNumberType, validationNumberTypes } = this.options;
|
|
2669
2663
|
const { iso2 } = this.selectedCountryData;
|
|
2670
2664
|
if (strictMode && intlTelInput.utils) {
|
|
2671
2665
|
if (iso2) {
|
|
@@ -2677,7 +2671,7 @@ var Iti = class {
|
|
|
2677
2671
|
true
|
|
2678
2672
|
);
|
|
2679
2673
|
let validNumber = exampleNumber;
|
|
2680
|
-
while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2,
|
|
2674
|
+
while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2, validationNumberTypes)) {
|
|
2681
2675
|
validNumber = exampleNumber;
|
|
2682
2676
|
exampleNumber += "0";
|
|
2683
2677
|
}
|
|
@@ -3029,7 +3023,7 @@ var Iti = class {
|
|
|
3029
3023
|
return this._utilsIsPossibleNumber(val);
|
|
3030
3024
|
}
|
|
3031
3025
|
_utilsIsPossibleNumber(val) {
|
|
3032
|
-
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.
|
|
3026
|
+
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
3033
3027
|
}
|
|
3034
3028
|
//* Validate the input val (precise)
|
|
3035
3029
|
isValidNumberPrecise() {
|
|
@@ -3047,7 +3041,7 @@ var Iti = class {
|
|
|
3047
3041
|
return this._utilsIsValidNumber(val);
|
|
3048
3042
|
}
|
|
3049
3043
|
_utilsIsValidNumber(val) {
|
|
3050
|
-
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2) : null;
|
|
3044
|
+
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
3051
3045
|
}
|
|
3052
3046
|
//* Update the selected country, and update the input val accordingly.
|
|
3053
3047
|
setCountry(iso2) {
|
|
@@ -3083,33 +3077,23 @@ var Iti = class {
|
|
|
3083
3077
|
}
|
|
3084
3078
|
}
|
|
3085
3079
|
};
|
|
3086
|
-
var
|
|
3080
|
+
var attachUtils = (source) => {
|
|
3087
3081
|
if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
|
|
3088
3082
|
let loadCall;
|
|
3089
|
-
if (typeof source === "
|
|
3090
|
-
loadCall = import(
|
|
3091
|
-
/* webpackIgnore: true */
|
|
3092
|
-
/* @vite-ignore */
|
|
3093
|
-
source
|
|
3094
|
-
);
|
|
3095
|
-
} else if (typeof source === "function") {
|
|
3083
|
+
if (typeof source === "function") {
|
|
3096
3084
|
try {
|
|
3097
3085
|
loadCall = Promise.resolve(source());
|
|
3098
3086
|
} catch (error) {
|
|
3099
3087
|
return Promise.reject(error);
|
|
3100
3088
|
}
|
|
3101
3089
|
} else {
|
|
3102
|
-
return Promise.reject(new TypeError(`The argument passed to
|
|
3090
|
+
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}`));
|
|
3103
3091
|
}
|
|
3104
3092
|
intlTelInput.startedLoadingUtilsScript = true;
|
|
3105
3093
|
return loadCall.then((module2) => {
|
|
3106
3094
|
const utils = module2?.default;
|
|
3107
3095
|
if (!utils || typeof utils !== "object") {
|
|
3108
|
-
|
|
3109
|
-
throw new TypeError(`The module loaded from ${source} did not set utils as its default export.`);
|
|
3110
|
-
} else {
|
|
3111
|
-
throw new TypeError("The loader function passed to loadUtils did not resolve to a module object with utils as its default export.");
|
|
3112
|
-
}
|
|
3096
|
+
throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
|
|
3113
3097
|
}
|
|
3114
3098
|
intlTelInput.utils = utils;
|
|
3115
3099
|
forEachInstance("handleUtils");
|
|
@@ -3142,10 +3126,10 @@ var intlTelInput = Object.assign(
|
|
|
3142
3126
|
},
|
|
3143
3127
|
//* A map from instance ID to instance object.
|
|
3144
3128
|
instances: {},
|
|
3145
|
-
|
|
3129
|
+
attachUtils,
|
|
3146
3130
|
startedLoadingUtilsScript: false,
|
|
3147
3131
|
startedLoadingAutoCountry: false,
|
|
3148
|
-
version: "
|
|
3132
|
+
version: "25.0.0"
|
|
3149
3133
|
}
|
|
3150
3134
|
);
|
|
3151
3135
|
var intl_tel_input_default = intlTelInput;
|
|
@@ -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 {
|
|
@@ -1623,8 +1623,8 @@ var defaults = {
|
|
|
1623
1623
|
i18n: {},
|
|
1624
1624
|
//* Initial country.
|
|
1625
1625
|
initialCountry: "",
|
|
1626
|
-
//*
|
|
1627
|
-
|
|
1626
|
+
//* A function to load the utils script.
|
|
1627
|
+
loadUtils: null,
|
|
1628
1628
|
//* National vs international formatting for numbers e.g. placeholders and displaying existing numbers.
|
|
1629
1629
|
nationalMode: true,
|
|
1630
1630
|
//* Display only these countries.
|
|
@@ -1645,10 +1645,8 @@ var defaults = {
|
|
|
1645
1645
|
navigator.userAgent
|
|
1646
1646
|
) || window.innerWidth <= 500
|
|
1647
1647
|
) : false,
|
|
1648
|
-
//* Deprecated! Use `loadUtilsOnInit` instead.
|
|
1649
|
-
utilsScript: "",
|
|
1650
1648
|
//* The number type to enforce during validation.
|
|
1651
|
-
|
|
1649
|
+
validationNumberTypes: ["MOBILE"]
|
|
1652
1650
|
};
|
|
1653
1651
|
var regionlessNanpNumbers = [
|
|
1654
1652
|
"800",
|
|
@@ -2157,15 +2155,11 @@ var Iti = class {
|
|
|
2157
2155
|
}
|
|
2158
2156
|
//* Init many requests: utils script / geo ip lookup.
|
|
2159
2157
|
_initRequests() {
|
|
2160
|
-
let {
|
|
2161
|
-
if (
|
|
2162
|
-
console.warn("intl-tel-input: The `utilsScript` option is deprecated and will be removed in a future release! Please use the `loadUtilsOnInit` option instead.");
|
|
2163
|
-
loadUtilsOnInit = utilsScript;
|
|
2164
|
-
}
|
|
2165
|
-
if (loadUtilsOnInit && !intlTelInput.utils) {
|
|
2158
|
+
let { loadUtils, initialCountry, geoIpLookup } = this.options;
|
|
2159
|
+
if (loadUtils && !intlTelInput.utils) {
|
|
2166
2160
|
this._handlePageLoad = () => {
|
|
2167
2161
|
window.removeEventListener("load", this._handlePageLoad);
|
|
2168
|
-
intlTelInput.loadUtils
|
|
2162
|
+
intlTelInput.attachUtils(loadUtils)?.catch(() => {
|
|
2169
2163
|
});
|
|
2170
2164
|
};
|
|
2171
2165
|
if (intlTelInput.documentReady()) {
|
|
@@ -2629,7 +2623,7 @@ var Iti = class {
|
|
|
2629
2623
|
}
|
|
2630
2624
|
//* Update the maximum valid number length for the currently selected country.
|
|
2631
2625
|
_updateMaxLength() {
|
|
2632
|
-
const { strictMode, placeholderNumberType,
|
|
2626
|
+
const { strictMode, placeholderNumberType, validationNumberTypes } = this.options;
|
|
2633
2627
|
const { iso2 } = this.selectedCountryData;
|
|
2634
2628
|
if (strictMode && intlTelInput.utils) {
|
|
2635
2629
|
if (iso2) {
|
|
@@ -2641,7 +2635,7 @@ var Iti = class {
|
|
|
2641
2635
|
true
|
|
2642
2636
|
);
|
|
2643
2637
|
let validNumber = exampleNumber;
|
|
2644
|
-
while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2,
|
|
2638
|
+
while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2, validationNumberTypes)) {
|
|
2645
2639
|
validNumber = exampleNumber;
|
|
2646
2640
|
exampleNumber += "0";
|
|
2647
2641
|
}
|
|
@@ -2993,7 +2987,7 @@ var Iti = class {
|
|
|
2993
2987
|
return this._utilsIsPossibleNumber(val);
|
|
2994
2988
|
}
|
|
2995
2989
|
_utilsIsPossibleNumber(val) {
|
|
2996
|
-
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.
|
|
2990
|
+
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
2997
2991
|
}
|
|
2998
2992
|
//* Validate the input val (precise)
|
|
2999
2993
|
isValidNumberPrecise() {
|
|
@@ -3011,7 +3005,7 @@ var Iti = class {
|
|
|
3011
3005
|
return this._utilsIsValidNumber(val);
|
|
3012
3006
|
}
|
|
3013
3007
|
_utilsIsValidNumber(val) {
|
|
3014
|
-
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2) : null;
|
|
3008
|
+
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
3015
3009
|
}
|
|
3016
3010
|
//* Update the selected country, and update the input val accordingly.
|
|
3017
3011
|
setCountry(iso2) {
|
|
@@ -3047,33 +3041,23 @@ var Iti = class {
|
|
|
3047
3041
|
}
|
|
3048
3042
|
}
|
|
3049
3043
|
};
|
|
3050
|
-
var
|
|
3044
|
+
var attachUtils = (source) => {
|
|
3051
3045
|
if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
|
|
3052
3046
|
let loadCall;
|
|
3053
|
-
if (typeof source === "
|
|
3054
|
-
loadCall = import(
|
|
3055
|
-
/* webpackIgnore: true */
|
|
3056
|
-
/* @vite-ignore */
|
|
3057
|
-
source
|
|
3058
|
-
);
|
|
3059
|
-
} else if (typeof source === "function") {
|
|
3047
|
+
if (typeof source === "function") {
|
|
3060
3048
|
try {
|
|
3061
3049
|
loadCall = Promise.resolve(source());
|
|
3062
3050
|
} catch (error) {
|
|
3063
3051
|
return Promise.reject(error);
|
|
3064
3052
|
}
|
|
3065
3053
|
} else {
|
|
3066
|
-
return Promise.reject(new TypeError(`The argument passed to
|
|
3054
|
+
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}`));
|
|
3067
3055
|
}
|
|
3068
3056
|
intlTelInput.startedLoadingUtilsScript = true;
|
|
3069
3057
|
return loadCall.then((module) => {
|
|
3070
3058
|
const utils = module?.default;
|
|
3071
3059
|
if (!utils || typeof utils !== "object") {
|
|
3072
|
-
|
|
3073
|
-
throw new TypeError(`The module loaded from ${source} did not set utils as its default export.`);
|
|
3074
|
-
} else {
|
|
3075
|
-
throw new TypeError("The loader function passed to loadUtils did not resolve to a module object with utils as its default export.");
|
|
3076
|
-
}
|
|
3060
|
+
throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
|
|
3077
3061
|
}
|
|
3078
3062
|
intlTelInput.utils = utils;
|
|
3079
3063
|
forEachInstance("handleUtils");
|
|
@@ -3106,10 +3090,10 @@ var intlTelInput = Object.assign(
|
|
|
3106
3090
|
},
|
|
3107
3091
|
//* A map from instance ID to instance object.
|
|
3108
3092
|
instances: {},
|
|
3109
|
-
|
|
3093
|
+
attachUtils,
|
|
3110
3094
|
startedLoadingUtilsScript: false,
|
|
3111
3095
|
startedLoadingAutoCountry: false,
|
|
3112
|
-
version: "
|
|
3096
|
+
version: "25.0.0"
|
|
3113
3097
|
}
|
|
3114
3098
|
);
|
|
3115
3099
|
var intl_tel_input_default = intlTelInput;
|