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
|
@@ -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",
|
|
@@ -2021,18 +2019,28 @@ var Iti = class {
|
|
|
2021
2019
|
const telInputName = this.telInput.getAttribute("name") || "";
|
|
2022
2020
|
const names = hiddenInput(telInputName);
|
|
2023
2021
|
if (names.phone) {
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
}
|
|
2028
|
-
|
|
2022
|
+
const existingInput = this.telInput.form?.querySelector(`input[name="${names.phone}"]`);
|
|
2023
|
+
if (existingInput) {
|
|
2024
|
+
this.hiddenInput = existingInput;
|
|
2025
|
+
} else {
|
|
2026
|
+
this.hiddenInput = createEl("input", {
|
|
2027
|
+
type: "hidden",
|
|
2028
|
+
name: names.phone
|
|
2029
|
+
});
|
|
2030
|
+
wrapper.appendChild(this.hiddenInput);
|
|
2031
|
+
}
|
|
2029
2032
|
}
|
|
2030
2033
|
if (names.country) {
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
}
|
|
2035
|
-
|
|
2034
|
+
const existingInput = this.telInput.form?.querySelector(`input[name="${names.country}"]`);
|
|
2035
|
+
if (existingInput) {
|
|
2036
|
+
this.hiddenInputCountry = existingInput;
|
|
2037
|
+
} else {
|
|
2038
|
+
this.hiddenInputCountry = createEl("input", {
|
|
2039
|
+
type: "hidden",
|
|
2040
|
+
name: names.country
|
|
2041
|
+
});
|
|
2042
|
+
wrapper.appendChild(this.hiddenInputCountry);
|
|
2043
|
+
}
|
|
2036
2044
|
}
|
|
2037
2045
|
}
|
|
2038
2046
|
}
|
|
@@ -2157,15 +2165,11 @@ var Iti = class {
|
|
|
2157
2165
|
}
|
|
2158
2166
|
//* Init many requests: utils script / geo ip lookup.
|
|
2159
2167
|
_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) {
|
|
2168
|
+
let { loadUtils, initialCountry, geoIpLookup } = this.options;
|
|
2169
|
+
if (loadUtils && !intlTelInput.utils) {
|
|
2166
2170
|
this._handlePageLoad = () => {
|
|
2167
2171
|
window.removeEventListener("load", this._handlePageLoad);
|
|
2168
|
-
intlTelInput.loadUtils
|
|
2172
|
+
intlTelInput.attachUtils(loadUtils)?.catch(() => {
|
|
2169
2173
|
});
|
|
2170
2174
|
};
|
|
2171
2175
|
if (intlTelInput.documentReady()) {
|
|
@@ -2629,7 +2633,7 @@ var Iti = class {
|
|
|
2629
2633
|
}
|
|
2630
2634
|
//* Update the maximum valid number length for the currently selected country.
|
|
2631
2635
|
_updateMaxLength() {
|
|
2632
|
-
const { strictMode, placeholderNumberType,
|
|
2636
|
+
const { strictMode, placeholderNumberType, validationNumberTypes } = this.options;
|
|
2633
2637
|
const { iso2 } = this.selectedCountryData;
|
|
2634
2638
|
if (strictMode && intlTelInput.utils) {
|
|
2635
2639
|
if (iso2) {
|
|
@@ -2641,7 +2645,7 @@ var Iti = class {
|
|
|
2641
2645
|
true
|
|
2642
2646
|
);
|
|
2643
2647
|
let validNumber = exampleNumber;
|
|
2644
|
-
while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2,
|
|
2648
|
+
while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2, validationNumberTypes)) {
|
|
2645
2649
|
validNumber = exampleNumber;
|
|
2646
2650
|
exampleNumber += "0";
|
|
2647
2651
|
}
|
|
@@ -2993,7 +2997,7 @@ var Iti = class {
|
|
|
2993
2997
|
return this._utilsIsPossibleNumber(val);
|
|
2994
2998
|
}
|
|
2995
2999
|
_utilsIsPossibleNumber(val) {
|
|
2996
|
-
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.
|
|
3000
|
+
return intlTelInput.utils ? intlTelInput.utils.isPossibleNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
2997
3001
|
}
|
|
2998
3002
|
//* Validate the input val (precise)
|
|
2999
3003
|
isValidNumberPrecise() {
|
|
@@ -3011,7 +3015,7 @@ var Iti = class {
|
|
|
3011
3015
|
return this._utilsIsValidNumber(val);
|
|
3012
3016
|
}
|
|
3013
3017
|
_utilsIsValidNumber(val) {
|
|
3014
|
-
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2) : null;
|
|
3018
|
+
return intlTelInput.utils ? intlTelInput.utils.isValidNumber(val, this.selectedCountryData.iso2, this.options.validationNumberTypes) : null;
|
|
3015
3019
|
}
|
|
3016
3020
|
//* Update the selected country, and update the input val accordingly.
|
|
3017
3021
|
setCountry(iso2) {
|
|
@@ -3047,33 +3051,23 @@ var Iti = class {
|
|
|
3047
3051
|
}
|
|
3048
3052
|
}
|
|
3049
3053
|
};
|
|
3050
|
-
var
|
|
3054
|
+
var attachUtils = (source) => {
|
|
3051
3055
|
if (!intlTelInput.utils && !intlTelInput.startedLoadingUtilsScript) {
|
|
3052
3056
|
let loadCall;
|
|
3053
|
-
if (typeof source === "
|
|
3054
|
-
loadCall = import(
|
|
3055
|
-
/* webpackIgnore: true */
|
|
3056
|
-
/* @vite-ignore */
|
|
3057
|
-
source
|
|
3058
|
-
);
|
|
3059
|
-
} else if (typeof source === "function") {
|
|
3057
|
+
if (typeof source === "function") {
|
|
3060
3058
|
try {
|
|
3061
3059
|
loadCall = Promise.resolve(source());
|
|
3062
3060
|
} catch (error) {
|
|
3063
3061
|
return Promise.reject(error);
|
|
3064
3062
|
}
|
|
3065
3063
|
} else {
|
|
3066
|
-
return Promise.reject(new TypeError(`The argument passed to
|
|
3064
|
+
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
3065
|
}
|
|
3068
3066
|
intlTelInput.startedLoadingUtilsScript = true;
|
|
3069
3067
|
return loadCall.then((module) => {
|
|
3070
3068
|
const utils = module?.default;
|
|
3071
3069
|
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
|
-
}
|
|
3070
|
+
throw new TypeError("The loader function passed to attachUtils did not resolve to a module object with utils as its default export.");
|
|
3077
3071
|
}
|
|
3078
3072
|
intlTelInput.utils = utils;
|
|
3079
3073
|
forEachInstance("handleUtils");
|
|
@@ -3106,10 +3100,10 @@ var intlTelInput = Object.assign(
|
|
|
3106
3100
|
},
|
|
3107
3101
|
//* A map from instance ID to instance object.
|
|
3108
3102
|
instances: {},
|
|
3109
|
-
|
|
3103
|
+
attachUtils,
|
|
3110
3104
|
startedLoadingUtilsScript: false,
|
|
3111
3105
|
startedLoadingAutoCountry: false,
|
|
3112
|
-
version: "
|
|
3106
|
+
version: "25.0.1"
|
|
3113
3107
|
}
|
|
3114
3108
|
);
|
|
3115
3109
|
var intl_tel_input_default = intlTelInput;
|