intl-tel-input 25.12.5 → 25.13.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 +5 -5
- package/angular/README.md +1 -1
- package/angular/build/IntlTelInput.js +106 -47
- package/angular/build/IntlTelInputWithUtils.js +216 -191
- package/angular/build/types/intl-tel-input.d.ts +6 -0
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput.d.ts +6 -0
- package/build/js/intlTelInput.js +108 -52
- package/build/js/intlTelInput.min.js +4 -4
- package/build/js/intlTelInputWithUtils.js +218 -196
- package/build/js/intlTelInputWithUtils.min.js +6 -6
- package/build/js/utils.js +40 -39
- package/package.json +1 -1
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +107 -51
- package/react/build/IntlTelInput.d.ts +6 -0
- package/react/build/IntlTelInput.js +107 -51
- package/react/build/IntlTelInputWithUtils.cjs +217 -195
- package/react/build/IntlTelInputWithUtils.js +217 -195
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +325 -285
- package/vue/build/IntlTelInputWithUtils.mjs +680 -674
|
@@ -21,12 +21,18 @@ export declare class Iti {
|
|
|
21
21
|
private defaultCountry;
|
|
22
22
|
private abortController;
|
|
23
23
|
private dropdownAbortController;
|
|
24
|
+
private userNumeralSet;
|
|
24
25
|
private resolveAutoCountryPromise;
|
|
25
26
|
private rejectAutoCountryPromise;
|
|
26
27
|
private resolveUtilsScriptPromise;
|
|
27
28
|
private rejectUtilsScriptPromise;
|
|
28
29
|
constructor(input: HTMLInputElement, customOptions?: SomeOptions);
|
|
29
30
|
private static _getIsAndroid;
|
|
31
|
+
private _updateNumeralSet;
|
|
32
|
+
private _mapAsciiToUserNumerals;
|
|
33
|
+
private _normaliseNumerals;
|
|
34
|
+
private _getTelInputValue;
|
|
35
|
+
private _setTelInputValue;
|
|
30
36
|
private _createInitPromises;
|
|
31
37
|
_init(): void;
|
|
32
38
|
private _processCountryData;
|
package/build/js/data.js
CHANGED
package/build/js/data.min.js
CHANGED
|
@@ -368,12 +368,18 @@ declare module "intl-tel-input" {
|
|
|
368
368
|
private defaultCountry;
|
|
369
369
|
private abortController;
|
|
370
370
|
private dropdownAbortController;
|
|
371
|
+
private userNumeralSet;
|
|
371
372
|
private resolveAutoCountryPromise;
|
|
372
373
|
private rejectAutoCountryPromise;
|
|
373
374
|
private resolveUtilsScriptPromise;
|
|
374
375
|
private rejectUtilsScriptPromise;
|
|
375
376
|
constructor(input: HTMLInputElement, customOptions?: SomeOptions);
|
|
376
377
|
private static _getIsAndroid;
|
|
378
|
+
private _updateNumeralSet;
|
|
379
|
+
private _mapAsciiToUserNumerals;
|
|
380
|
+
private _normaliseNumerals;
|
|
381
|
+
private _getTelInputValue;
|
|
382
|
+
private _setTelInputValue;
|
|
377
383
|
private _createInitPromises;
|
|
378
384
|
_init(): void;
|
|
379
385
|
private _processCountryData;
|
package/build/js/intlTelInput.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* International Telephone Input v25.
|
|
2
|
+
* International Telephone Input v25.13.0
|
|
3
3
|
* https://github.com/jackocnr/intl-tel-input.git
|
|
4
4
|
* Licensed under the MIT license
|
|
5
5
|
*/
|
|
@@ -2931,6 +2931,45 @@ var factoryOutput = (() => {
|
|
|
2931
2931
|
static _getIsAndroid() {
|
|
2932
2932
|
return typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false;
|
|
2933
2933
|
}
|
|
2934
|
+
_updateNumeralSet(str) {
|
|
2935
|
+
if (/[\u0660-\u0669]/.test(str)) {
|
|
2936
|
+
this.userNumeralSet = "arabic-indic";
|
|
2937
|
+
} else if (/[\u06F0-\u06F9]/.test(str)) {
|
|
2938
|
+
this.userNumeralSet = "persian";
|
|
2939
|
+
} else {
|
|
2940
|
+
this.userNumeralSet = "ascii";
|
|
2941
|
+
}
|
|
2942
|
+
}
|
|
2943
|
+
_mapAsciiToUserNumerals(str) {
|
|
2944
|
+
if (!this.userNumeralSet) {
|
|
2945
|
+
this._updateNumeralSet(this.ui.telInput.value);
|
|
2946
|
+
}
|
|
2947
|
+
if (this.userNumeralSet === "ascii") {
|
|
2948
|
+
return str;
|
|
2949
|
+
}
|
|
2950
|
+
const base = this.userNumeralSet === "arabic-indic" ? 1632 : 1776;
|
|
2951
|
+
return str.replace(/[0-9]/g, (d) => String.fromCharCode(base + Number(d)));
|
|
2952
|
+
}
|
|
2953
|
+
// Normalize Eastern Arabic (U+0660-0669) and Persian/Extended Arabic-Indic (U+06F0-06F9) numerals to ASCII 0-9
|
|
2954
|
+
_normaliseNumerals(str) {
|
|
2955
|
+
if (!str) {
|
|
2956
|
+
return "";
|
|
2957
|
+
}
|
|
2958
|
+
this._updateNumeralSet(str);
|
|
2959
|
+
if (this.userNumeralSet === "ascii") {
|
|
2960
|
+
return str;
|
|
2961
|
+
}
|
|
2962
|
+
const base = this.userNumeralSet === "arabic-indic" ? 1632 : 1776;
|
|
2963
|
+
const regex = this.userNumeralSet === "arabic-indic" ? /[\u0660-\u0669]/g : /[\u06F0-\u06F9]/g;
|
|
2964
|
+
return str.replace(regex, (ch) => String.fromCharCode(48 + (ch.charCodeAt(0) - base)));
|
|
2965
|
+
}
|
|
2966
|
+
_getTelInputValue() {
|
|
2967
|
+
const inputValue = this.ui.telInput.value.trim();
|
|
2968
|
+
return this._normaliseNumerals(inputValue);
|
|
2969
|
+
}
|
|
2970
|
+
_setTelInputValue(asciiValue) {
|
|
2971
|
+
this.ui.telInput.value = this._mapAsciiToUserNumerals(asciiValue);
|
|
2972
|
+
}
|
|
2934
2973
|
_createInitPromises() {
|
|
2935
2974
|
const autoCountryPromise = new Promise((resolve, reject) => {
|
|
2936
2975
|
this.resolveAutoCountryPromise = resolve;
|
|
@@ -2965,8 +3004,9 @@ var factoryOutput = (() => {
|
|
|
2965
3004
|
//* 1. Extracting a dial code from the given number
|
|
2966
3005
|
//* 2. Using explicit initialCountry
|
|
2967
3006
|
_setInitialState(overrideAutoCountry = false) {
|
|
2968
|
-
const
|
|
2969
|
-
const
|
|
3007
|
+
const attributeValueRaw = this.ui.telInput.getAttribute("value");
|
|
3008
|
+
const attributeValue = this._normaliseNumerals(attributeValueRaw);
|
|
3009
|
+
const inputValue = this._getTelInputValue();
|
|
2970
3010
|
const useAttribute = attributeValue && attributeValue.startsWith("+") && (!inputValue || !inputValue.startsWith("+"));
|
|
2971
3011
|
const val = useAttribute ? attributeValue : inputValue;
|
|
2972
3012
|
const dialCode = this._getDialCode(val);
|
|
@@ -3137,35 +3177,34 @@ var factoryOutput = (() => {
|
|
|
3137
3177
|
countrySearch
|
|
3138
3178
|
} = this.options;
|
|
3139
3179
|
let userOverrideFormatting = false;
|
|
3140
|
-
if (REGEX.ALPHA_UNICODE.test(this.
|
|
3180
|
+
if (REGEX.ALPHA_UNICODE.test(this._getTelInputValue())) {
|
|
3141
3181
|
userOverrideFormatting = true;
|
|
3142
3182
|
}
|
|
3143
3183
|
const handleInputEvent = (e) => {
|
|
3184
|
+
const inputValue = this._getTelInputValue();
|
|
3144
3185
|
if (this.isAndroid && e?.data === "+" && separateDialCode && allowDropdown && countrySearch) {
|
|
3145
3186
|
const currentCaretPos = this.ui.telInput.selectionStart || 0;
|
|
3146
|
-
const valueBeforeCaret =
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
);
|
|
3150
|
-
const valueAfterCaret = this.ui.telInput.value.substring(currentCaretPos);
|
|
3151
|
-
this.ui.telInput.value = valueBeforeCaret + valueAfterCaret;
|
|
3187
|
+
const valueBeforeCaret = inputValue.substring(0, currentCaretPos - 1);
|
|
3188
|
+
const valueAfterCaret = inputValue.substring(currentCaretPos);
|
|
3189
|
+
this._setTelInputValue(valueBeforeCaret + valueAfterCaret);
|
|
3152
3190
|
this._openDropdownWithPlus();
|
|
3153
3191
|
return;
|
|
3154
3192
|
}
|
|
3155
|
-
if (this._updateCountryFromNumber(
|
|
3193
|
+
if (this._updateCountryFromNumber(inputValue)) {
|
|
3156
3194
|
this._triggerCountryChange();
|
|
3157
3195
|
}
|
|
3158
3196
|
const isFormattingChar = e?.data && REGEX.NON_PLUS_NUMERIC.test(e.data);
|
|
3159
|
-
const isPaste = e?.inputType === INPUT_TYPES.PASTE &&
|
|
3197
|
+
const isPaste = e?.inputType === INPUT_TYPES.PASTE && inputValue;
|
|
3160
3198
|
if (isFormattingChar || isPaste && !strictMode) {
|
|
3161
3199
|
userOverrideFormatting = true;
|
|
3162
|
-
} else if (!REGEX.NON_PLUS_NUMERIC.test(
|
|
3200
|
+
} else if (!REGEX.NON_PLUS_NUMERIC.test(inputValue)) {
|
|
3163
3201
|
userOverrideFormatting = false;
|
|
3164
3202
|
}
|
|
3165
3203
|
const isSetNumber = e?.detail && e.detail["isSetNumber"];
|
|
3166
|
-
|
|
3204
|
+
const isAscii = this.userNumeralSet === "ascii";
|
|
3205
|
+
if (formatAsYouType && !userOverrideFormatting && !isSetNumber && isAscii) {
|
|
3167
3206
|
const currentCaretPos = this.ui.telInput.selectionStart || 0;
|
|
3168
|
-
const valueBeforeCaret =
|
|
3207
|
+
const valueBeforeCaret = inputValue.substring(
|
|
3169
3208
|
0,
|
|
3170
3209
|
currentCaretPos
|
|
3171
3210
|
);
|
|
@@ -3177,7 +3216,7 @@ var factoryOutput = (() => {
|
|
|
3177
3216
|
const fullNumber = this._getFullNumber();
|
|
3178
3217
|
const formattedValue = formatNumberAsYouType(
|
|
3179
3218
|
fullNumber,
|
|
3180
|
-
|
|
3219
|
+
inputValue,
|
|
3181
3220
|
intlTelInput.utils,
|
|
3182
3221
|
this.selectedCountryData,
|
|
3183
3222
|
this.options.separateDialCode
|
|
@@ -3188,7 +3227,7 @@ var factoryOutput = (() => {
|
|
|
3188
3227
|
currentCaretPos,
|
|
3189
3228
|
isDeleteForwards
|
|
3190
3229
|
);
|
|
3191
|
-
this.
|
|
3230
|
+
this._setTelInputValue(formattedValue);
|
|
3192
3231
|
this.ui.telInput.setSelectionRange(newCaretPos, newCaretPos);
|
|
3193
3232
|
}
|
|
3194
3233
|
};
|
|
@@ -3211,12 +3250,18 @@ var factoryOutput = (() => {
|
|
|
3211
3250
|
return;
|
|
3212
3251
|
}
|
|
3213
3252
|
if (strictMode) {
|
|
3214
|
-
const
|
|
3215
|
-
const alreadyHasPlus =
|
|
3253
|
+
const inputValue = this._getTelInputValue();
|
|
3254
|
+
const alreadyHasPlus = inputValue.startsWith("+");
|
|
3216
3255
|
const isInitialPlus = !alreadyHasPlus && this.ui.telInput.selectionStart === 0 && e.key === "+";
|
|
3217
|
-
const
|
|
3256
|
+
const normalisedKey = this._normaliseNumerals(e.key);
|
|
3257
|
+
const isNumeric = /^[0-9]$/.test(normalisedKey);
|
|
3218
3258
|
const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric;
|
|
3219
|
-
const
|
|
3259
|
+
const input = this.ui.telInput;
|
|
3260
|
+
const selStart = input.selectionStart;
|
|
3261
|
+
const selEnd = input.selectionEnd;
|
|
3262
|
+
const before = inputValue.slice(0, selStart);
|
|
3263
|
+
const after = inputValue.slice(selEnd);
|
|
3264
|
+
const newValue = before + e.key + after;
|
|
3220
3265
|
const newFullNumber = this._getFullNumber(newValue);
|
|
3221
3266
|
const coreNumber = intlTelInput.utils.getCoreNumber(
|
|
3222
3267
|
newFullNumber,
|
|
@@ -3243,34 +3288,38 @@ var factoryOutput = (() => {
|
|
|
3243
3288
|
const input = this.ui.telInput;
|
|
3244
3289
|
const selStart = input.selectionStart;
|
|
3245
3290
|
const selEnd = input.selectionEnd;
|
|
3246
|
-
const
|
|
3247
|
-
const
|
|
3291
|
+
const inputValue = this._getTelInputValue();
|
|
3292
|
+
const before = inputValue.slice(0, selStart);
|
|
3293
|
+
const after = inputValue.slice(selEnd);
|
|
3248
3294
|
const iso2 = this.selectedCountryData.iso2;
|
|
3249
|
-
const
|
|
3295
|
+
const pastedRaw = e.clipboardData.getData("text");
|
|
3296
|
+
const pasted = this._normaliseNumerals(pastedRaw);
|
|
3250
3297
|
const initialCharSelected = selStart === 0 && selEnd > 0;
|
|
3251
|
-
const allowLeadingPlus = !
|
|
3298
|
+
const allowLeadingPlus = !inputValue.startsWith("+") || initialCharSelected;
|
|
3252
3299
|
const allowedChars = pasted.replace(REGEX.NON_PLUS_NUMERIC_GLOBAL, "");
|
|
3253
3300
|
const hasLeadingPlus = allowedChars.startsWith("+");
|
|
3254
3301
|
const numerics = allowedChars.replace(/\+/g, "");
|
|
3255
3302
|
const sanitised = hasLeadingPlus && allowLeadingPlus ? `+${numerics}` : numerics;
|
|
3256
3303
|
let newVal = before + sanitised + after;
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
}
|
|
3265
|
-
if (this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength) {
|
|
3266
|
-
if (input.selectionEnd === input.value.length) {
|
|
3267
|
-
const trimLength = coreNumber.length - this.maxCoreNumberLength;
|
|
3268
|
-
newVal = newVal.slice(0, newVal.length - trimLength);
|
|
3269
|
-
} else {
|
|
3304
|
+
if (newVal.length > 5) {
|
|
3305
|
+
let coreNumber = intlTelInput.utils.getCoreNumber(newVal, iso2);
|
|
3306
|
+
while (coreNumber.length === 0 && newVal.length > 0) {
|
|
3307
|
+
newVal = newVal.slice(0, -1);
|
|
3308
|
+
coreNumber = intlTelInput.utils.getCoreNumber(newVal, iso2);
|
|
3309
|
+
}
|
|
3310
|
+
if (!coreNumber) {
|
|
3270
3311
|
return;
|
|
3271
3312
|
}
|
|
3313
|
+
if (this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength) {
|
|
3314
|
+
if (input.selectionEnd === inputValue.length) {
|
|
3315
|
+
const trimLength = coreNumber.length - this.maxCoreNumberLength;
|
|
3316
|
+
newVal = newVal.slice(0, newVal.length - trimLength);
|
|
3317
|
+
} else {
|
|
3318
|
+
return;
|
|
3319
|
+
}
|
|
3320
|
+
}
|
|
3272
3321
|
}
|
|
3273
|
-
|
|
3322
|
+
this._setTelInputValue(newVal);
|
|
3274
3323
|
const caretPos = selStart + sanitised.length;
|
|
3275
3324
|
input.setSelectionRange(caretPos, caretPos);
|
|
3276
3325
|
input.dispatchEvent(new InputEvent("input", { bubbles: true }));
|
|
@@ -3421,6 +3470,7 @@ var factoryOutput = (() => {
|
|
|
3421
3470
|
this._handleEnterKey();
|
|
3422
3471
|
} else if (e.key === KEYS.ESC) {
|
|
3423
3472
|
this._closeDropdown();
|
|
3473
|
+
this.ui.selectedCountry.focus();
|
|
3424
3474
|
}
|
|
3425
3475
|
}
|
|
3426
3476
|
if (!this.options.countrySearch && REGEX.HIDDEN_SEARCH_CHAR.test(e.key)) {
|
|
@@ -3521,7 +3571,7 @@ var factoryOutput = (() => {
|
|
|
3521
3571
|
);
|
|
3522
3572
|
}
|
|
3523
3573
|
number = this._beforeSetNumber(number);
|
|
3524
|
-
this.
|
|
3574
|
+
this._setTelInputValue(number);
|
|
3525
3575
|
}
|
|
3526
3576
|
//* Check if need to select a new country based on the given number
|
|
3527
3577
|
//* Note: called from _setInitialState, keyup handler, setNumber.
|
|
@@ -3695,7 +3745,8 @@ var factoryOutput = (() => {
|
|
|
3695
3745
|
const dialCode = listItem.dataset[DATA_KEYS.DIAL_CODE];
|
|
3696
3746
|
this._updateDialCode(dialCode);
|
|
3697
3747
|
if (this.options.formatOnDisplay) {
|
|
3698
|
-
this.
|
|
3748
|
+
const inputValue = this._getTelInputValue();
|
|
3749
|
+
this._updateValFromNumber(inputValue);
|
|
3699
3750
|
}
|
|
3700
3751
|
this.ui.telInput.focus();
|
|
3701
3752
|
if (countryChanged) {
|
|
@@ -3726,7 +3777,7 @@ var factoryOutput = (() => {
|
|
|
3726
3777
|
//* Replace any existing dial code with the new one
|
|
3727
3778
|
//* Note: called from _selectListItem and setCountry
|
|
3728
3779
|
_updateDialCode(newDialCodeBare) {
|
|
3729
|
-
const inputVal = this.
|
|
3780
|
+
const inputVal = this._getTelInputValue();
|
|
3730
3781
|
const newDialCode = `+${newDialCodeBare}`;
|
|
3731
3782
|
let newNumber;
|
|
3732
3783
|
if (inputVal.startsWith("+")) {
|
|
@@ -3736,7 +3787,7 @@ var factoryOutput = (() => {
|
|
|
3736
3787
|
} else {
|
|
3737
3788
|
newNumber = newDialCode;
|
|
3738
3789
|
}
|
|
3739
|
-
this.
|
|
3790
|
+
this._setTelInputValue(newNumber);
|
|
3740
3791
|
}
|
|
3741
3792
|
}
|
|
3742
3793
|
//* Try and extract a valid international dial code from a full telephone number.
|
|
@@ -3773,7 +3824,7 @@ var factoryOutput = (() => {
|
|
|
3773
3824
|
}
|
|
3774
3825
|
//* Get the input val, adding the dial code if separateDialCode is enabled.
|
|
3775
3826
|
_getFullNumber(overrideVal) {
|
|
3776
|
-
const val = overrideVal
|
|
3827
|
+
const val = overrideVal ? this._normaliseNumerals(overrideVal) : this._getTelInputValue();
|
|
3777
3828
|
const { dialCode } = this.selectedCountryData;
|
|
3778
3829
|
let prefix;
|
|
3779
3830
|
const numericVal = getNumeric(val);
|
|
@@ -3816,8 +3867,9 @@ var factoryOutput = (() => {
|
|
|
3816
3867
|
//* This is called when the utils request completes.
|
|
3817
3868
|
handleUtils() {
|
|
3818
3869
|
if (intlTelInput.utils) {
|
|
3819
|
-
|
|
3820
|
-
|
|
3870
|
+
const inputValue = this._getTelInputValue();
|
|
3871
|
+
if (inputValue) {
|
|
3872
|
+
this._updateValFromNumber(inputValue);
|
|
3821
3873
|
}
|
|
3822
3874
|
if (this.selectedCountryData.iso2) {
|
|
3823
3875
|
this._updatePlaceholder();
|
|
@@ -3860,11 +3912,13 @@ var factoryOutput = (() => {
|
|
|
3860
3912
|
getNumber(format) {
|
|
3861
3913
|
if (intlTelInput.utils) {
|
|
3862
3914
|
const { iso2 } = this.selectedCountryData;
|
|
3863
|
-
|
|
3864
|
-
|
|
3915
|
+
const fullNumber = this._getFullNumber();
|
|
3916
|
+
const formattedNumber = intlTelInput.utils.formatNumber(
|
|
3917
|
+
fullNumber,
|
|
3865
3918
|
iso2,
|
|
3866
3919
|
format
|
|
3867
3920
|
);
|
|
3921
|
+
return this._mapAsciiToUserNumerals(formattedNumber);
|
|
3868
3922
|
}
|
|
3869
3923
|
return "";
|
|
3870
3924
|
}
|
|
@@ -3952,15 +4006,17 @@ var factoryOutput = (() => {
|
|
|
3952
4006
|
this._setCountry(iso2Lower);
|
|
3953
4007
|
this._updateDialCode(this.selectedCountryData.dialCode);
|
|
3954
4008
|
if (this.options.formatOnDisplay) {
|
|
3955
|
-
this.
|
|
4009
|
+
const inputValue = this._getTelInputValue();
|
|
4010
|
+
this._updateValFromNumber(inputValue);
|
|
3956
4011
|
}
|
|
3957
4012
|
this._triggerCountryChange();
|
|
3958
4013
|
}
|
|
3959
4014
|
}
|
|
3960
4015
|
//* Set the input value and update the country.
|
|
3961
4016
|
setNumber(number) {
|
|
3962
|
-
const
|
|
3963
|
-
this.
|
|
4017
|
+
const normalisedNumber = this._normaliseNumerals(number);
|
|
4018
|
+
const countryChanged = this._updateCountryFromNumber(normalisedNumber);
|
|
4019
|
+
this._updateValFromNumber(normalisedNumber);
|
|
3964
4020
|
if (countryChanged) {
|
|
3965
4021
|
this._triggerCountryChange();
|
|
3966
4022
|
}
|
|
@@ -4045,7 +4101,7 @@ var factoryOutput = (() => {
|
|
|
4045
4101
|
attachUtils,
|
|
4046
4102
|
startedLoadingUtilsScript: false,
|
|
4047
4103
|
startedLoadingAutoCountry: false,
|
|
4048
|
-
version: "25.
|
|
4104
|
+
version: "25.13.0"
|
|
4049
4105
|
}
|
|
4050
4106
|
);
|
|
4051
4107
|
var intl_tel_input_default = intlTelInput;
|