intl-tel-input 24.5.1 → 24.5.2
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 +5 -5
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput.d.ts +0 -1
- package/build/js/intlTelInput.js +21 -24
- package/build/js/intlTelInput.min.js +2 -2
- package/build/js/intlTelInputWithUtils.js +21 -24
- package/build/js/intlTelInputWithUtils.min.js +2 -2
- package/package.json +1 -1
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +20 -23
- package/react/build/IntlTelInput.d.ts +0 -1
- package/react/build/IntlTelInput.js +20 -23
- package/react/build/IntlTelInputWithUtils.cjs +20 -23
- package/react/build/IntlTelInputWithUtils.js +20 -23
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +38 -41
- package/vue/build/IntlTelInputWithUtils.mjs +531 -534
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@24.5.
|
|
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@24.5.2/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.
|
|
@@ -2295,13 +2295,17 @@ var Iti = class {
|
|
|
2295
2295
|
const isInitialPlus = !alreadyHasPlus && this.telInput.selectionStart === 0 && e.key === "+";
|
|
2296
2296
|
const isNumeric = /^[0-9]$/.test(e.key);
|
|
2297
2297
|
const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric;
|
|
2298
|
-
const
|
|
2299
|
-
const
|
|
2300
|
-
const
|
|
2301
|
-
const
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2298
|
+
const newValue = value.slice(0, this.telInput.selectionStart) + e.key + value.slice(this.telInput.selectionEnd);
|
|
2299
|
+
const newFullNumber = this._getFullNumber(newValue);
|
|
2300
|
+
const coreNumber = intlTelInput.utils.getCoreNumber(newFullNumber, this.selectedCountryData.iso2);
|
|
2301
|
+
const hasExceededMaxLength = this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength;
|
|
2302
|
+
let isChangingDialCode = false;
|
|
2303
|
+
if (alreadyHasPlus) {
|
|
2304
|
+
const currentCountry = this.selectedCountryData.iso2;
|
|
2305
|
+
const newCountry = this._getCountryFromNumber(newFullNumber);
|
|
2306
|
+
isChangingDialCode = newCountry !== currentCountry;
|
|
2307
|
+
}
|
|
2308
|
+
if (!isAllowedChar || hasExceededMaxLength && !isChangingDialCode && !isInitialPlus) {
|
|
2305
2309
|
e.preventDefault();
|
|
2306
2310
|
}
|
|
2307
2311
|
}
|
|
@@ -2310,17 +2314,6 @@ var Iti = class {
|
|
|
2310
2314
|
this.telInput.addEventListener("keydown", this._handleKeydownEvent);
|
|
2311
2315
|
}
|
|
2312
2316
|
}
|
|
2313
|
-
_isChangingDialCode(char) {
|
|
2314
|
-
const value = this.telInput.value;
|
|
2315
|
-
if (value.charAt(0) === "+") {
|
|
2316
|
-
const currentCountry = this.selectedCountryData.iso2;
|
|
2317
|
-
const newValue = value.slice(0, this.telInput.selectionStart) + char + value.slice(this.telInput.selectionEnd);
|
|
2318
|
-
const newFullNumber = this._getFullNumber(newValue);
|
|
2319
|
-
const newCountry = this._getCountryFromNumber(newFullNumber);
|
|
2320
|
-
return newCountry !== currentCountry;
|
|
2321
|
-
}
|
|
2322
|
-
return false;
|
|
2323
|
-
}
|
|
2324
2317
|
//* Adhere to the input's maxlength attr.
|
|
2325
2318
|
_cap(number) {
|
|
2326
2319
|
const max = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
|
|
@@ -2664,22 +2657,26 @@ var Iti = class {
|
|
|
2664
2657
|
//* Update the maximum valid number length for the currently selected country.
|
|
2665
2658
|
_updateMaxLength() {
|
|
2666
2659
|
const { strictMode, placeholderNumberType, validationNumberType } = this.options;
|
|
2660
|
+
const { iso2 } = this.selectedCountryData;
|
|
2667
2661
|
if (strictMode && intlTelInput.utils) {
|
|
2668
|
-
if (
|
|
2662
|
+
if (iso2) {
|
|
2669
2663
|
const numberType = intlTelInput.utils.numberType[placeholderNumberType];
|
|
2670
2664
|
let exampleNumber = intlTelInput.utils.getExampleNumber(
|
|
2671
|
-
|
|
2665
|
+
iso2,
|
|
2672
2666
|
false,
|
|
2673
2667
|
numberType,
|
|
2674
2668
|
true
|
|
2675
2669
|
);
|
|
2676
2670
|
let validNumber = exampleNumber;
|
|
2677
|
-
while (intlTelInput.utils.isPossibleNumber(exampleNumber,
|
|
2671
|
+
while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2, validationNumberType)) {
|
|
2678
2672
|
validNumber = exampleNumber;
|
|
2679
2673
|
exampleNumber += "0";
|
|
2680
2674
|
}
|
|
2681
|
-
const coreNumber = intlTelInput.utils.getCoreNumber(validNumber,
|
|
2675
|
+
const coreNumber = intlTelInput.utils.getCoreNumber(validNumber, iso2);
|
|
2682
2676
|
this.maxCoreNumberLength = coreNumber.length;
|
|
2677
|
+
if (iso2 === "by") {
|
|
2678
|
+
this.maxCoreNumberLength = coreNumber.length + 1;
|
|
2679
|
+
}
|
|
2683
2680
|
} else {
|
|
2684
2681
|
this.maxCoreNumberLength = null;
|
|
2685
2682
|
}
|
|
@@ -3116,7 +3113,7 @@ var intlTelInput = Object.assign(
|
|
|
3116
3113
|
//* A map from instance ID to instance object.
|
|
3117
3114
|
instances: {},
|
|
3118
3115
|
loadUtils,
|
|
3119
|
-
version: "24.5.
|
|
3116
|
+
version: "24.5.2"
|
|
3120
3117
|
}
|
|
3121
3118
|
);
|
|
3122
3119
|
var intl_tel_input_default = intlTelInput;
|
|
@@ -2259,13 +2259,17 @@ var Iti = class {
|
|
|
2259
2259
|
const isInitialPlus = !alreadyHasPlus && this.telInput.selectionStart === 0 && e.key === "+";
|
|
2260
2260
|
const isNumeric = /^[0-9]$/.test(e.key);
|
|
2261
2261
|
const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric;
|
|
2262
|
-
const
|
|
2263
|
-
const
|
|
2264
|
-
const
|
|
2265
|
-
const
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2262
|
+
const newValue = value.slice(0, this.telInput.selectionStart) + e.key + value.slice(this.telInput.selectionEnd);
|
|
2263
|
+
const newFullNumber = this._getFullNumber(newValue);
|
|
2264
|
+
const coreNumber = intlTelInput.utils.getCoreNumber(newFullNumber, this.selectedCountryData.iso2);
|
|
2265
|
+
const hasExceededMaxLength = this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength;
|
|
2266
|
+
let isChangingDialCode = false;
|
|
2267
|
+
if (alreadyHasPlus) {
|
|
2268
|
+
const currentCountry = this.selectedCountryData.iso2;
|
|
2269
|
+
const newCountry = this._getCountryFromNumber(newFullNumber);
|
|
2270
|
+
isChangingDialCode = newCountry !== currentCountry;
|
|
2271
|
+
}
|
|
2272
|
+
if (!isAllowedChar || hasExceededMaxLength && !isChangingDialCode && !isInitialPlus) {
|
|
2269
2273
|
e.preventDefault();
|
|
2270
2274
|
}
|
|
2271
2275
|
}
|
|
@@ -2274,17 +2278,6 @@ var Iti = class {
|
|
|
2274
2278
|
this.telInput.addEventListener("keydown", this._handleKeydownEvent);
|
|
2275
2279
|
}
|
|
2276
2280
|
}
|
|
2277
|
-
_isChangingDialCode(char) {
|
|
2278
|
-
const value = this.telInput.value;
|
|
2279
|
-
if (value.charAt(0) === "+") {
|
|
2280
|
-
const currentCountry = this.selectedCountryData.iso2;
|
|
2281
|
-
const newValue = value.slice(0, this.telInput.selectionStart) + char + value.slice(this.telInput.selectionEnd);
|
|
2282
|
-
const newFullNumber = this._getFullNumber(newValue);
|
|
2283
|
-
const newCountry = this._getCountryFromNumber(newFullNumber);
|
|
2284
|
-
return newCountry !== currentCountry;
|
|
2285
|
-
}
|
|
2286
|
-
return false;
|
|
2287
|
-
}
|
|
2288
2281
|
//* Adhere to the input's maxlength attr.
|
|
2289
2282
|
_cap(number) {
|
|
2290
2283
|
const max = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
|
|
@@ -2628,22 +2621,26 @@ var Iti = class {
|
|
|
2628
2621
|
//* Update the maximum valid number length for the currently selected country.
|
|
2629
2622
|
_updateMaxLength() {
|
|
2630
2623
|
const { strictMode, placeholderNumberType, validationNumberType } = this.options;
|
|
2624
|
+
const { iso2 } = this.selectedCountryData;
|
|
2631
2625
|
if (strictMode && intlTelInput.utils) {
|
|
2632
|
-
if (
|
|
2626
|
+
if (iso2) {
|
|
2633
2627
|
const numberType = intlTelInput.utils.numberType[placeholderNumberType];
|
|
2634
2628
|
let exampleNumber = intlTelInput.utils.getExampleNumber(
|
|
2635
|
-
|
|
2629
|
+
iso2,
|
|
2636
2630
|
false,
|
|
2637
2631
|
numberType,
|
|
2638
2632
|
true
|
|
2639
2633
|
);
|
|
2640
2634
|
let validNumber = exampleNumber;
|
|
2641
|
-
while (intlTelInput.utils.isPossibleNumber(exampleNumber,
|
|
2635
|
+
while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2, validationNumberType)) {
|
|
2642
2636
|
validNumber = exampleNumber;
|
|
2643
2637
|
exampleNumber += "0";
|
|
2644
2638
|
}
|
|
2645
|
-
const coreNumber = intlTelInput.utils.getCoreNumber(validNumber,
|
|
2639
|
+
const coreNumber = intlTelInput.utils.getCoreNumber(validNumber, iso2);
|
|
2646
2640
|
this.maxCoreNumberLength = coreNumber.length;
|
|
2641
|
+
if (iso2 === "by") {
|
|
2642
|
+
this.maxCoreNumberLength = coreNumber.length + 1;
|
|
2643
|
+
}
|
|
2647
2644
|
} else {
|
|
2648
2645
|
this.maxCoreNumberLength = null;
|
|
2649
2646
|
}
|
|
@@ -3080,7 +3077,7 @@ var intlTelInput = Object.assign(
|
|
|
3080
3077
|
//* A map from instance ID to instance object.
|
|
3081
3078
|
instances: {},
|
|
3082
3079
|
loadUtils,
|
|
3083
|
-
version: "24.5.
|
|
3080
|
+
version: "24.5.2"
|
|
3084
3081
|
}
|
|
3085
3082
|
);
|
|
3086
3083
|
var intl_tel_input_default = intlTelInput;
|
|
@@ -2295,13 +2295,17 @@ var Iti = class {
|
|
|
2295
2295
|
const isInitialPlus = !alreadyHasPlus && this.telInput.selectionStart === 0 && e.key === "+";
|
|
2296
2296
|
const isNumeric = /^[0-9]$/.test(e.key);
|
|
2297
2297
|
const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric;
|
|
2298
|
-
const
|
|
2299
|
-
const
|
|
2300
|
-
const
|
|
2301
|
-
const
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2298
|
+
const newValue = value.slice(0, this.telInput.selectionStart) + e.key + value.slice(this.telInput.selectionEnd);
|
|
2299
|
+
const newFullNumber = this._getFullNumber(newValue);
|
|
2300
|
+
const coreNumber = intlTelInput.utils.getCoreNumber(newFullNumber, this.selectedCountryData.iso2);
|
|
2301
|
+
const hasExceededMaxLength = this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength;
|
|
2302
|
+
let isChangingDialCode = false;
|
|
2303
|
+
if (alreadyHasPlus) {
|
|
2304
|
+
const currentCountry = this.selectedCountryData.iso2;
|
|
2305
|
+
const newCountry = this._getCountryFromNumber(newFullNumber);
|
|
2306
|
+
isChangingDialCode = newCountry !== currentCountry;
|
|
2307
|
+
}
|
|
2308
|
+
if (!isAllowedChar || hasExceededMaxLength && !isChangingDialCode && !isInitialPlus) {
|
|
2305
2309
|
e.preventDefault();
|
|
2306
2310
|
}
|
|
2307
2311
|
}
|
|
@@ -2310,17 +2314,6 @@ var Iti = class {
|
|
|
2310
2314
|
this.telInput.addEventListener("keydown", this._handleKeydownEvent);
|
|
2311
2315
|
}
|
|
2312
2316
|
}
|
|
2313
|
-
_isChangingDialCode(char) {
|
|
2314
|
-
const value = this.telInput.value;
|
|
2315
|
-
if (value.charAt(0) === "+") {
|
|
2316
|
-
const currentCountry = this.selectedCountryData.iso2;
|
|
2317
|
-
const newValue = value.slice(0, this.telInput.selectionStart) + char + value.slice(this.telInput.selectionEnd);
|
|
2318
|
-
const newFullNumber = this._getFullNumber(newValue);
|
|
2319
|
-
const newCountry = this._getCountryFromNumber(newFullNumber);
|
|
2320
|
-
return newCountry !== currentCountry;
|
|
2321
|
-
}
|
|
2322
|
-
return false;
|
|
2323
|
-
}
|
|
2324
2317
|
//* Adhere to the input's maxlength attr.
|
|
2325
2318
|
_cap(number) {
|
|
2326
2319
|
const max = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
|
|
@@ -2664,22 +2657,26 @@ var Iti = class {
|
|
|
2664
2657
|
//* Update the maximum valid number length for the currently selected country.
|
|
2665
2658
|
_updateMaxLength() {
|
|
2666
2659
|
const { strictMode, placeholderNumberType, validationNumberType } = this.options;
|
|
2660
|
+
const { iso2 } = this.selectedCountryData;
|
|
2667
2661
|
if (strictMode && intlTelInput.utils) {
|
|
2668
|
-
if (
|
|
2662
|
+
if (iso2) {
|
|
2669
2663
|
const numberType = intlTelInput.utils.numberType[placeholderNumberType];
|
|
2670
2664
|
let exampleNumber = intlTelInput.utils.getExampleNumber(
|
|
2671
|
-
|
|
2665
|
+
iso2,
|
|
2672
2666
|
false,
|
|
2673
2667
|
numberType,
|
|
2674
2668
|
true
|
|
2675
2669
|
);
|
|
2676
2670
|
let validNumber = exampleNumber;
|
|
2677
|
-
while (intlTelInput.utils.isPossibleNumber(exampleNumber,
|
|
2671
|
+
while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2, validationNumberType)) {
|
|
2678
2672
|
validNumber = exampleNumber;
|
|
2679
2673
|
exampleNumber += "0";
|
|
2680
2674
|
}
|
|
2681
|
-
const coreNumber = intlTelInput.utils.getCoreNumber(validNumber,
|
|
2675
|
+
const coreNumber = intlTelInput.utils.getCoreNumber(validNumber, iso2);
|
|
2682
2676
|
this.maxCoreNumberLength = coreNumber.length;
|
|
2677
|
+
if (iso2 === "by") {
|
|
2678
|
+
this.maxCoreNumberLength = coreNumber.length + 1;
|
|
2679
|
+
}
|
|
2683
2680
|
} else {
|
|
2684
2681
|
this.maxCoreNumberLength = null;
|
|
2685
2682
|
}
|
|
@@ -3116,7 +3113,7 @@ var intlTelInput = Object.assign(
|
|
|
3116
3113
|
//* A map from instance ID to instance object.
|
|
3117
3114
|
instances: {},
|
|
3118
3115
|
loadUtils,
|
|
3119
|
-
version: "24.5.
|
|
3116
|
+
version: "24.5.2"
|
|
3120
3117
|
}
|
|
3121
3118
|
);
|
|
3122
3119
|
var intl_tel_input_default = intlTelInput;
|
|
@@ -2259,13 +2259,17 @@ var Iti = class {
|
|
|
2259
2259
|
const isInitialPlus = !alreadyHasPlus && this.telInput.selectionStart === 0 && e.key === "+";
|
|
2260
2260
|
const isNumeric = /^[0-9]$/.test(e.key);
|
|
2261
2261
|
const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric;
|
|
2262
|
-
const
|
|
2263
|
-
const
|
|
2264
|
-
const
|
|
2265
|
-
const
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2262
|
+
const newValue = value.slice(0, this.telInput.selectionStart) + e.key + value.slice(this.telInput.selectionEnd);
|
|
2263
|
+
const newFullNumber = this._getFullNumber(newValue);
|
|
2264
|
+
const coreNumber = intlTelInput.utils.getCoreNumber(newFullNumber, this.selectedCountryData.iso2);
|
|
2265
|
+
const hasExceededMaxLength = this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength;
|
|
2266
|
+
let isChangingDialCode = false;
|
|
2267
|
+
if (alreadyHasPlus) {
|
|
2268
|
+
const currentCountry = this.selectedCountryData.iso2;
|
|
2269
|
+
const newCountry = this._getCountryFromNumber(newFullNumber);
|
|
2270
|
+
isChangingDialCode = newCountry !== currentCountry;
|
|
2271
|
+
}
|
|
2272
|
+
if (!isAllowedChar || hasExceededMaxLength && !isChangingDialCode && !isInitialPlus) {
|
|
2269
2273
|
e.preventDefault();
|
|
2270
2274
|
}
|
|
2271
2275
|
}
|
|
@@ -2274,17 +2278,6 @@ var Iti = class {
|
|
|
2274
2278
|
this.telInput.addEventListener("keydown", this._handleKeydownEvent);
|
|
2275
2279
|
}
|
|
2276
2280
|
}
|
|
2277
|
-
_isChangingDialCode(char) {
|
|
2278
|
-
const value = this.telInput.value;
|
|
2279
|
-
if (value.charAt(0) === "+") {
|
|
2280
|
-
const currentCountry = this.selectedCountryData.iso2;
|
|
2281
|
-
const newValue = value.slice(0, this.telInput.selectionStart) + char + value.slice(this.telInput.selectionEnd);
|
|
2282
|
-
const newFullNumber = this._getFullNumber(newValue);
|
|
2283
|
-
const newCountry = this._getCountryFromNumber(newFullNumber);
|
|
2284
|
-
return newCountry !== currentCountry;
|
|
2285
|
-
}
|
|
2286
|
-
return false;
|
|
2287
|
-
}
|
|
2288
2281
|
//* Adhere to the input's maxlength attr.
|
|
2289
2282
|
_cap(number) {
|
|
2290
2283
|
const max = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
|
|
@@ -2628,22 +2621,26 @@ var Iti = class {
|
|
|
2628
2621
|
//* Update the maximum valid number length for the currently selected country.
|
|
2629
2622
|
_updateMaxLength() {
|
|
2630
2623
|
const { strictMode, placeholderNumberType, validationNumberType } = this.options;
|
|
2624
|
+
const { iso2 } = this.selectedCountryData;
|
|
2631
2625
|
if (strictMode && intlTelInput.utils) {
|
|
2632
|
-
if (
|
|
2626
|
+
if (iso2) {
|
|
2633
2627
|
const numberType = intlTelInput.utils.numberType[placeholderNumberType];
|
|
2634
2628
|
let exampleNumber = intlTelInput.utils.getExampleNumber(
|
|
2635
|
-
|
|
2629
|
+
iso2,
|
|
2636
2630
|
false,
|
|
2637
2631
|
numberType,
|
|
2638
2632
|
true
|
|
2639
2633
|
);
|
|
2640
2634
|
let validNumber = exampleNumber;
|
|
2641
|
-
while (intlTelInput.utils.isPossibleNumber(exampleNumber,
|
|
2635
|
+
while (intlTelInput.utils.isPossibleNumber(exampleNumber, iso2, validationNumberType)) {
|
|
2642
2636
|
validNumber = exampleNumber;
|
|
2643
2637
|
exampleNumber += "0";
|
|
2644
2638
|
}
|
|
2645
|
-
const coreNumber = intlTelInput.utils.getCoreNumber(validNumber,
|
|
2639
|
+
const coreNumber = intlTelInput.utils.getCoreNumber(validNumber, iso2);
|
|
2646
2640
|
this.maxCoreNumberLength = coreNumber.length;
|
|
2641
|
+
if (iso2 === "by") {
|
|
2642
|
+
this.maxCoreNumberLength = coreNumber.length + 1;
|
|
2643
|
+
}
|
|
2647
2644
|
} else {
|
|
2648
2645
|
this.maxCoreNumberLength = null;
|
|
2649
2646
|
}
|
|
@@ -3080,7 +3077,7 @@ var intlTelInput = Object.assign(
|
|
|
3080
3077
|
//* A map from instance ID to instance object.
|
|
3081
3078
|
instances: {},
|
|
3082
3079
|
loadUtils,
|
|
3083
|
-
version: "24.5.
|
|
3080
|
+
version: "24.5.2"
|
|
3084
3081
|
}
|
|
3085
3082
|
);
|
|
3086
3083
|
var intl_tel_input_default = intlTelInput;
|
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.5.
|
|
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.5.2/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,5 +1,5 @@
|
|
|
1
|
-
import { mergeModels as
|
|
2
|
-
const
|
|
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
|
+
const N = [
|
|
3
3
|
[
|
|
4
4
|
"af",
|
|
5
5
|
// Afghanistan
|
|
@@ -1306,8 +1306,8 @@ const D = [
|
|
|
1306
1306
|
"263"
|
|
1307
1307
|
]
|
|
1308
1308
|
], b = [];
|
|
1309
|
-
for (let u = 0; u <
|
|
1310
|
-
const t =
|
|
1309
|
+
for (let u = 0; u < N.length; u++) {
|
|
1310
|
+
const t = N[u];
|
|
1311
1311
|
b[u] = {
|
|
1312
1312
|
name: "",
|
|
1313
1313
|
// this is now populated in the plugin
|
|
@@ -1572,11 +1572,11 @@ const $ = {
|
|
|
1572
1572
|
// additional countries (not supported by country-list library)
|
|
1573
1573
|
ac: "Ascension Island",
|
|
1574
1574
|
xk: "Kosovo"
|
|
1575
|
-
},
|
|
1575
|
+
}, k = { ...$, ...j };
|
|
1576
1576
|
for (let u = 0; u < b.length; u++)
|
|
1577
|
-
b[u].name =
|
|
1577
|
+
b[u].name = k[b[u].iso2];
|
|
1578
1578
|
let K = 0;
|
|
1579
|
-
const
|
|
1579
|
+
const T = {
|
|
1580
1580
|
//* Whether or not to allow the dropdown.
|
|
1581
1581
|
allowDropdown: !0,
|
|
1582
1582
|
//* Add a placeholder in the input with an example number for the selected country.
|
|
@@ -1649,7 +1649,7 @@ const k = {
|
|
|
1649
1649
|
"887",
|
|
1650
1650
|
"888",
|
|
1651
1651
|
"889"
|
|
1652
|
-
], w = (u) => u.replace(/\D/g, ""),
|
|
1652
|
+
], w = (u) => u.replace(/\D/g, ""), A = (u = "") => u.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase(), S = (u) => {
|
|
1653
1653
|
const t = w(u);
|
|
1654
1654
|
if (t.charAt(0) === "1") {
|
|
1655
1655
|
const e = t.substr(1, 3);
|
|
@@ -1676,13 +1676,13 @@ const k = {
|
|
|
1676
1676
|
};
|
|
1677
1677
|
class G {
|
|
1678
1678
|
constructor(t, e = {}) {
|
|
1679
|
-
this.id = K++, this.telInput = t, this.highlightedItem = null, this.options = Object.assign({},
|
|
1679
|
+
this.id = K++, this.telInput = t, this.highlightedItem = null, this.options = Object.assign({}, T, 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() {
|
|
1683
1683
|
this.options.useFullscreenPopup && (this.options.fixDropdownWidth = !1), this.options.onlyCountries.length === 1 && (this.options.initialCountry = this.options.onlyCountries[0]), this.options.separateDialCode && (this.options.nationalMode = !1), this.options.allowDropdown && !this.options.showFlags && !this.options.separateDialCode && (this.options.nationalMode = !1), this.options.useFullscreenPopup && !this.options.dropdownContainer && (this.options.dropdownContainer = document.body), this.isAndroid = typeof navigator < "u" ? /Android/i.test(navigator.userAgent) : !1, this.isRTL = !!this.telInput.closest("[dir=rtl]");
|
|
1684
1684
|
const t = this.options.allowDropdown || this.options.separateDialCode;
|
|
1685
|
-
this.showSelectedCountryOnLeft = this.isRTL ? !t : t, this.options.separateDialCode && (this.isRTL ? this.originalPaddingRight = this.telInput.style.paddingRight : this.originalPaddingLeft = this.telInput.style.paddingLeft), this.options.i18n = { ...
|
|
1685
|
+
this.showSelectedCountryOnLeft = this.isRTL ? !t : t, this.options.separateDialCode && (this.isRTL ? this.originalPaddingRight = this.telInput.style.paddingRight : this.originalPaddingLeft = this.telInput.style.paddingLeft), this.options.i18n = { ...k, ...this.options.i18n };
|
|
1686
1686
|
const e = new Promise((s, n) => {
|
|
1687
1687
|
this.resolveAutoCountryPromise = s, this.rejectAutoCountryPromise = n;
|
|
1688
1688
|
}), i = new Promise((s, n) => {
|
|
@@ -1896,7 +1896,7 @@ class G {
|
|
|
1896
1896
|
//* 1. Extracting a dial code from the given number
|
|
1897
1897
|
//* 2. Using explicit initialCountry
|
|
1898
1898
|
_setInitialState(t = !1) {
|
|
1899
|
-
const e = this.telInput.getAttribute("value"), i = this.telInput.value, n = e && e.charAt(0) === "+" && (!i || i.charAt(0) !== "+") ? e : i, o = this._getDialCode(n), a =
|
|
1899
|
+
const e = this.telInput.getAttribute("value"), i = this.telInput.value, n = e && e.charAt(0) === "+" && (!i || i.charAt(0) !== "+") ? e : i, o = this._getDialCode(n), a = S(n), { initialCountry: r, geoIpLookup: p } = this.options, c = r === "auto" && p;
|
|
1900
1900
|
if (o && !a)
|
|
1901
1901
|
this._updateCountryFromNumber(n);
|
|
1902
1902
|
else if (!c || t) {
|
|
@@ -1981,20 +1981,17 @@ class G {
|
|
|
1981
1981
|
return;
|
|
1982
1982
|
}
|
|
1983
1983
|
if (t) {
|
|
1984
|
-
const p = this.telInput.value,
|
|
1985
|
-
|
|
1984
|
+
const p = this.telInput.value, c = p.charAt(0) === "+", d = !c && this.telInput.selectionStart === 0 && r.key === "+", C = /^[0-9]$/.test(r.key), h = i ? C : d || C, m = p.slice(0, this.telInput.selectionStart) + r.key + p.slice(this.telInput.selectionEnd), f = this._getFullNumber(m), g = l.utils.getCoreNumber(f, this.selectedCountryData.iso2), I = this.maxCoreNumberLength && g.length > this.maxCoreNumberLength;
|
|
1985
|
+
let L = !1;
|
|
1986
|
+
if (c) {
|
|
1987
|
+
const P = this.selectedCountryData.iso2;
|
|
1988
|
+
L = this._getCountryFromNumber(f) !== P;
|
|
1989
|
+
}
|
|
1990
|
+
(!h || I && !L && !d) && r.preventDefault();
|
|
1986
1991
|
}
|
|
1987
1992
|
}
|
|
1988
1993
|
}, this.telInput.addEventListener("keydown", this._handleKeydownEvent));
|
|
1989
1994
|
}
|
|
1990
|
-
_isChangingDialCode(t) {
|
|
1991
|
-
const e = this.telInput.value;
|
|
1992
|
-
if (e.charAt(0) === "+") {
|
|
1993
|
-
const i = this.selectedCountryData.iso2, s = e.slice(0, this.telInput.selectionStart) + t + e.slice(this.telInput.selectionEnd), n = this._getFullNumber(s);
|
|
1994
|
-
return this._getCountryFromNumber(n) !== i;
|
|
1995
|
-
}
|
|
1996
|
-
return !1;
|
|
1997
|
-
}
|
|
1998
1995
|
//* Adhere to the input's maxlength attr.
|
|
1999
1996
|
_cap(t) {
|
|
2000
1997
|
const e = parseInt(this.telInput.getAttribute("maxlength") || "", 10);
|
|
@@ -2079,9 +2076,9 @@ class G {
|
|
|
2079
2076
|
_filterCountries(t, e = !1) {
|
|
2080
2077
|
let i = !0;
|
|
2081
2078
|
this.countryList.innerHTML = "";
|
|
2082
|
-
const s =
|
|
2079
|
+
const s = A(t);
|
|
2083
2080
|
for (let n = 0; n < this.countries.length; n++) {
|
|
2084
|
-
const o = this.countries[n], a =
|
|
2081
|
+
const o = this.countries[n], a = A(o.name), r = o.name.split(/[^a-zA-ZÀ-ÿа-яА-Я]/).map((c) => c[0]).join("").toLowerCase(), p = `+${o.dialCode}`;
|
|
2085
2082
|
if (e || a.includes(s) || p.includes(s) || o.iso2.includes(s) || r.includes(s)) {
|
|
2086
2083
|
const c = o.nodeById[this.id];
|
|
2087
2084
|
c && this.countryList.appendChild(c), i && (this._highlightListItem(c, !1), i = !1);
|
|
@@ -2133,7 +2130,7 @@ class G {
|
|
|
2133
2130
|
const o = this._getDialCode(i, !0), a = w(i);
|
|
2134
2131
|
if (o) {
|
|
2135
2132
|
const r = this.dialCodeToIso2Map[w(o)], p = r.indexOf(this.selectedCountryData.iso2) !== -1 && a.length <= o.length - 1;
|
|
2136
|
-
if (!(s === "1" &&
|
|
2133
|
+
if (!(s === "1" && S(a)) && !p) {
|
|
2137
2134
|
for (let d = 0; d < r.length; d++)
|
|
2138
2135
|
if (r[d])
|
|
2139
2136
|
return r[d];
|
|
@@ -2189,20 +2186,20 @@ class G {
|
|
|
2189
2186
|
}
|
|
2190
2187
|
//* Update the maximum valid number length for the currently selected country.
|
|
2191
2188
|
_updateMaxLength() {
|
|
2192
|
-
const { strictMode: t, placeholderNumberType: e, validationNumberType: i } = this.options;
|
|
2189
|
+
const { strictMode: t, placeholderNumberType: e, validationNumberType: i } = this.options, { iso2: s } = this.selectedCountryData;
|
|
2193
2190
|
if (t && l.utils)
|
|
2194
|
-
if (
|
|
2195
|
-
const
|
|
2196
|
-
let
|
|
2197
|
-
this.selectedCountryData.iso2,
|
|
2198
|
-
!1,
|
|
2191
|
+
if (s) {
|
|
2192
|
+
const n = l.utils.numberType[e];
|
|
2193
|
+
let o = l.utils.getExampleNumber(
|
|
2199
2194
|
s,
|
|
2195
|
+
!1,
|
|
2196
|
+
n,
|
|
2200
2197
|
!0
|
|
2201
|
-
),
|
|
2202
|
-
for (; l.utils.isPossibleNumber(
|
|
2203
|
-
|
|
2204
|
-
const
|
|
2205
|
-
this.maxCoreNumberLength =
|
|
2198
|
+
), a = o;
|
|
2199
|
+
for (; l.utils.isPossibleNumber(o, s, i); )
|
|
2200
|
+
a = o, o += "0";
|
|
2201
|
+
const r = l.utils.getCoreNumber(a, s);
|
|
2202
|
+
this.maxCoreNumberLength = r.length, s === "by" && (this.maxCoreNumberLength = r.length + 1);
|
|
2206
2203
|
} else
|
|
2207
2204
|
this.maxCoreNumberLength = null;
|
|
2208
2205
|
}
|
|
@@ -2469,7 +2466,7 @@ const W = (u) => !l.utils && !l.startedLoadingUtilsScript ? (l.startedLoadingUti
|
|
|
2469
2466
|
return e._init(), u.setAttribute("data-intl-tel-input-id", e.id.toString()), l.instances[e.id] = e, e;
|
|
2470
2467
|
},
|
|
2471
2468
|
{
|
|
2472
|
-
defaults:
|
|
2469
|
+
defaults: T,
|
|
2473
2470
|
//* Using a static var like this allows us to mock it in the tests.
|
|
2474
2471
|
documentReady: () => document.readyState === "complete",
|
|
2475
2472
|
//* Get the country data object.
|
|
@@ -2482,11 +2479,11 @@ const W = (u) => !l.utils && !l.startedLoadingUtilsScript ? (l.startedLoadingUti
|
|
|
2482
2479
|
//* A map from instance ID to instance object.
|
|
2483
2480
|
instances: {},
|
|
2484
2481
|
loadUtils: W,
|
|
2485
|
-
version: "24.5.
|
|
2482
|
+
version: "24.5.2"
|
|
2486
2483
|
}
|
|
2487
|
-
),
|
|
2484
|
+
), J = {
|
|
2488
2485
|
__name: "IntlTelInput",
|
|
2489
|
-
props: /* @__PURE__ */
|
|
2486
|
+
props: /* @__PURE__ */ D({
|
|
2490
2487
|
disabled: {
|
|
2491
2488
|
type: Boolean,
|
|
2492
2489
|
default: !1
|
|
@@ -2510,7 +2507,7 @@ const W = (u) => !l.utils && !l.startedLoadingUtilsScript ? (l.startedLoadingUti
|
|
|
2510
2507
|
},
|
|
2511
2508
|
modelModifiers: {}
|
|
2512
2509
|
}),
|
|
2513
|
-
emits: /* @__PURE__ */
|
|
2510
|
+
emits: /* @__PURE__ */ D([
|
|
2514
2511
|
"changeNumber",
|
|
2515
2512
|
"changeCountry",
|
|
2516
2513
|
"changeValidity",
|
|
@@ -2554,5 +2551,5 @@ const W = (u) => !l.utils && !l.startedLoadingUtilsScript ? (l.startedLoadingUti
|
|
|
2554
2551
|
}
|
|
2555
2552
|
};
|
|
2556
2553
|
export {
|
|
2557
|
-
|
|
2554
|
+
J as default
|
|
2558
2555
|
};
|