intl-tel-input 25.12.6 → 25.13.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 +5 -5
- package/angular/README.md +1 -1
- package/angular/build/IntlTelInput.js +112 -61
- package/angular/build/IntlTelInputWithUtils.js +112 -61
- package/angular/build/types/intl-tel-input.d.ts +6 -0
- package/angular/build/types/modules/data/country-data.d.ts +1 -1
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput.d.ts +7 -1
- package/build/js/intlTelInput.js +114 -67
- package/build/js/intlTelInput.min.js +4 -4
- package/build/js/intlTelInputWithUtils.js +114 -67
- package/build/js/intlTelInputWithUtils.min.js +6 -6
- package/package.json +1 -1
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +113 -66
- package/react/build/IntlTelInput.d.ts +7 -1
- package/react/build/IntlTelInput.js +113 -66
- package/react/build/IntlTelInputWithUtils.cjs +113 -66
- package/react/build/IntlTelInputWithUtils.js +113 -66
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +271 -240
- package/vue/build/IntlTelInputWithUtils.mjs +583 -552
package/README.md
CHANGED
|
@@ -81,16 +81,16 @@ _Note: We have now dropped support for all versions of Internet Explorer because
|
|
|
81
81
|
## Getting Started (Using a CDN)
|
|
82
82
|
1. Add the CSS
|
|
83
83
|
```html
|
|
84
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@25.
|
|
84
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@25.13.1/build/css/intlTelInput.css">
|
|
85
85
|
```
|
|
86
86
|
|
|
87
87
|
2. Add the plugin script and initialise it on your input element
|
|
88
88
|
```html
|
|
89
|
-
<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@25.
|
|
89
|
+
<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@25.13.1/build/js/intlTelInput.min.js"></script>
|
|
90
90
|
<script>
|
|
91
91
|
const input = document.querySelector("#phone");
|
|
92
92
|
window.intlTelInput(input, {
|
|
93
|
-
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.
|
|
93
|
+
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.13.1/build/js/utils.js"),
|
|
94
94
|
});
|
|
95
95
|
</script>
|
|
96
96
|
```
|
|
@@ -328,12 +328,12 @@ Set the initial country selection by specifying its country code, e.g. `"us"` fo
|
|
|
328
328
|
Type: `() => Promise<module>` Default: `null`
|
|
329
329
|
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.
|
|
330
330
|
|
|
331
|
-
The `loadUtils` option takes a function that returns a Promise resolving to the utils module (see example code below). You can `import` the utils module in different ways: (A) from a CDN, (B) from your own hosted version of [utils.js](https://cdn.jsdelivr.net/npm/intl-tel-input@25.
|
|
331
|
+
The `loadUtils` option takes a function that returns a Promise resolving to the utils module (see example code below). You can `import` the utils module in different ways: (A) from a CDN, (B) from your own hosted version of [utils.js](https://cdn.jsdelivr.net/npm/intl-tel-input@25.13.1/build/js/utils.js), or (C) if you use a bundler like Webpack, Vite or Parcel, you can import it directly from the package.
|
|
332
332
|
|
|
333
333
|
```js
|
|
334
334
|
// (A) import utils module from a CDN
|
|
335
335
|
intlTelInput(htmlInputElement, {
|
|
336
|
-
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.
|
|
336
|
+
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.13.1/build/js/utils.js"),
|
|
337
337
|
});
|
|
338
338
|
|
|
339
339
|
// (B) import utils module from your own hosted version of utils.js
|
package/angular/README.md
CHANGED
|
@@ -54,7 +54,7 @@ import "intl-tel-input/styles";
|
|
|
54
54
|
|
|
55
55
|
See the [validation demo](https://github.com/jackocnr/intl-tel-input/blob/master/angular/demo/validation/validation.component.ts) for a more fleshed-out example of how to handle validation, or check out the [form demo](https://github.com/jackocnr/intl-tel-input/blob/master/angular/demo/form/form.component.ts) for an alternative approach using `ReactiveFormsModule`.
|
|
56
56
|
|
|
57
|
-
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 { IntlTelInputComponent } from "intl-tel-input/angularWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/angular"` import, then you should couple this with the `loadUtils` 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 `loadUtils` 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.
|
|
57
|
+
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 { IntlTelInputComponent } from "intl-tel-input/angularWithUtils"`, to include the utils script. Alternatively, if you use the main `"intl-tel-input/angular"` import, then you should couple this with the `loadUtils` 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 `loadUtils` 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.13.1/build/js/utils.js"`.
|
|
58
58
|
|
|
59
59
|
## Props
|
|
60
60
|
|
|
@@ -2627,11 +2627,11 @@ var translateCountryNames = (countries, options) => {
|
|
|
2627
2627
|
}
|
|
2628
2628
|
}
|
|
2629
2629
|
};
|
|
2630
|
-
var processDialCodes = (countries
|
|
2630
|
+
var processDialCodes = (countries) => {
|
|
2631
2631
|
const dialCodes = /* @__PURE__ */ new Set();
|
|
2632
2632
|
let dialCodeMaxLen = 0;
|
|
2633
2633
|
const dialCodeToIso2Map = {};
|
|
2634
|
-
const _addToDialCodeMap = (iso2, dialCode
|
|
2634
|
+
const _addToDialCodeMap = (iso2, dialCode) => {
|
|
2635
2635
|
if (!iso2 || !dialCode) {
|
|
2636
2636
|
return;
|
|
2637
2637
|
}
|
|
@@ -2645,10 +2645,10 @@ var processDialCodes = (countries, options) => {
|
|
|
2645
2645
|
if (iso2List.includes(iso2)) {
|
|
2646
2646
|
return;
|
|
2647
2647
|
}
|
|
2648
|
-
|
|
2649
|
-
iso2List[index] = iso2;
|
|
2648
|
+
iso2List.push(iso2);
|
|
2650
2649
|
};
|
|
2651
|
-
|
|
2650
|
+
const countriesSortedByPriority = [...countries].sort((a, b) => a.priority - b.priority);
|
|
2651
|
+
for (const c of countriesSortedByPriority) {
|
|
2652
2652
|
if (!dialCodes.has(c.dialCode)) {
|
|
2653
2653
|
dialCodes.add(c.dialCode);
|
|
2654
2654
|
}
|
|
@@ -2656,14 +2656,7 @@ var processDialCodes = (countries, options) => {
|
|
|
2656
2656
|
const partialDialCode = c.dialCode.substring(0, k);
|
|
2657
2657
|
_addToDialCodeMap(c.iso2, partialDialCode);
|
|
2658
2658
|
}
|
|
2659
|
-
_addToDialCodeMap(c.iso2, c.dialCode
|
|
2660
|
-
}
|
|
2661
|
-
if (options.onlyCountries.length || options.excludeCountries.length) {
|
|
2662
|
-
dialCodes.forEach((dialCode) => {
|
|
2663
|
-
dialCodeToIso2Map[dialCode] = dialCodeToIso2Map[dialCode].filter(Boolean);
|
|
2664
|
-
});
|
|
2665
|
-
}
|
|
2666
|
-
for (const c of countries) {
|
|
2659
|
+
_addToDialCodeMap(c.iso2, c.dialCode);
|
|
2667
2660
|
if (c.areaCodes) {
|
|
2668
2661
|
const rootIso2Code = dialCodeToIso2Map[c.dialCode][0];
|
|
2669
2662
|
for (const areaCode of c.areaCodes) {
|
|
@@ -2795,7 +2788,7 @@ var Iti = class _Iti {
|
|
|
2795
2788
|
this.isAndroid = _Iti._getIsAndroid();
|
|
2796
2789
|
this.promise = this._createInitPromises();
|
|
2797
2790
|
this.countries = processAllCountries(this.options);
|
|
2798
|
-
const { dialCodes, dialCodeMaxLen, dialCodeToIso2Map } = processDialCodes(this.countries
|
|
2791
|
+
const { dialCodes, dialCodeMaxLen, dialCodeToIso2Map } = processDialCodes(this.countries);
|
|
2799
2792
|
this.dialCodes = dialCodes;
|
|
2800
2793
|
this.dialCodeMaxLen = dialCodeMaxLen;
|
|
2801
2794
|
this.dialCodeToIso2Map = dialCodeToIso2Map;
|
|
@@ -2805,6 +2798,45 @@ var Iti = class _Iti {
|
|
|
2805
2798
|
static _getIsAndroid() {
|
|
2806
2799
|
return typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false;
|
|
2807
2800
|
}
|
|
2801
|
+
_updateNumeralSet(str) {
|
|
2802
|
+
if (/[\u0660-\u0669]/.test(str)) {
|
|
2803
|
+
this.userNumeralSet = "arabic-indic";
|
|
2804
|
+
} else if (/[\u06F0-\u06F9]/.test(str)) {
|
|
2805
|
+
this.userNumeralSet = "persian";
|
|
2806
|
+
} else {
|
|
2807
|
+
this.userNumeralSet = "ascii";
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
_mapAsciiToUserNumerals(str) {
|
|
2811
|
+
if (!this.userNumeralSet) {
|
|
2812
|
+
this._updateNumeralSet(this.ui.telInput.value);
|
|
2813
|
+
}
|
|
2814
|
+
if (this.userNumeralSet === "ascii") {
|
|
2815
|
+
return str;
|
|
2816
|
+
}
|
|
2817
|
+
const base = this.userNumeralSet === "arabic-indic" ? 1632 : 1776;
|
|
2818
|
+
return str.replace(/[0-9]/g, (d) => String.fromCharCode(base + Number(d)));
|
|
2819
|
+
}
|
|
2820
|
+
// Normalize Eastern Arabic (U+0660-0669) and Persian/Extended Arabic-Indic (U+06F0-06F9) numerals to ASCII 0-9
|
|
2821
|
+
_normaliseNumerals(str) {
|
|
2822
|
+
if (!str) {
|
|
2823
|
+
return "";
|
|
2824
|
+
}
|
|
2825
|
+
this._updateNumeralSet(str);
|
|
2826
|
+
if (this.userNumeralSet === "ascii") {
|
|
2827
|
+
return str;
|
|
2828
|
+
}
|
|
2829
|
+
const base = this.userNumeralSet === "arabic-indic" ? 1632 : 1776;
|
|
2830
|
+
const regex = this.userNumeralSet === "arabic-indic" ? /[\u0660-\u0669]/g : /[\u06F0-\u06F9]/g;
|
|
2831
|
+
return str.replace(regex, (ch) => String.fromCharCode(48 + (ch.charCodeAt(0) - base)));
|
|
2832
|
+
}
|
|
2833
|
+
_getTelInputValue() {
|
|
2834
|
+
const inputValue = this.ui.telInput.value.trim();
|
|
2835
|
+
return this._normaliseNumerals(inputValue);
|
|
2836
|
+
}
|
|
2837
|
+
_setTelInputValue(asciiValue) {
|
|
2838
|
+
this.ui.telInput.value = this._mapAsciiToUserNumerals(asciiValue);
|
|
2839
|
+
}
|
|
2808
2840
|
_createInitPromises() {
|
|
2809
2841
|
const autoCountryPromise = new Promise((resolve, reject) => {
|
|
2810
2842
|
this.resolveAutoCountryPromise = resolve;
|
|
@@ -2839,8 +2871,9 @@ var Iti = class _Iti {
|
|
|
2839
2871
|
//* 1. Extracting a dial code from the given number
|
|
2840
2872
|
//* 2. Using explicit initialCountry
|
|
2841
2873
|
_setInitialState(overrideAutoCountry = false) {
|
|
2842
|
-
const
|
|
2843
|
-
const
|
|
2874
|
+
const attributeValueRaw = this.ui.telInput.getAttribute("value");
|
|
2875
|
+
const attributeValue = this._normaliseNumerals(attributeValueRaw);
|
|
2876
|
+
const inputValue = this._getTelInputValue();
|
|
2844
2877
|
const useAttribute = attributeValue && attributeValue.startsWith("+") && (!inputValue || !inputValue.startsWith("+"));
|
|
2845
2878
|
const val = useAttribute ? attributeValue : inputValue;
|
|
2846
2879
|
const dialCode = this._getDialCode(val);
|
|
@@ -2992,38 +3025,40 @@ var Iti = class _Iti {
|
|
|
2992
3025
|
_bindInputListener() {
|
|
2993
3026
|
const { strictMode, formatAsYouType, separateDialCode, allowDropdown, countrySearch } = this.options;
|
|
2994
3027
|
let userOverrideFormatting = false;
|
|
2995
|
-
if (REGEX.ALPHA_UNICODE.test(this.
|
|
3028
|
+
if (REGEX.ALPHA_UNICODE.test(this._getTelInputValue())) {
|
|
2996
3029
|
userOverrideFormatting = true;
|
|
2997
3030
|
}
|
|
2998
3031
|
const handleInputEvent = (e) => {
|
|
3032
|
+
const inputValue = this._getTelInputValue();
|
|
2999
3033
|
if (this.isAndroid && (e === null || e === void 0 ? void 0 : e.data) === "+" && separateDialCode && allowDropdown && countrySearch) {
|
|
3000
3034
|
const currentCaretPos = this.ui.telInput.selectionStart || 0;
|
|
3001
|
-
const valueBeforeCaret =
|
|
3002
|
-
const valueAfterCaret =
|
|
3003
|
-
this.
|
|
3035
|
+
const valueBeforeCaret = inputValue.substring(0, currentCaretPos - 1);
|
|
3036
|
+
const valueAfterCaret = inputValue.substring(currentCaretPos);
|
|
3037
|
+
this._setTelInputValue(valueBeforeCaret + valueAfterCaret);
|
|
3004
3038
|
this._openDropdownWithPlus();
|
|
3005
3039
|
return;
|
|
3006
3040
|
}
|
|
3007
|
-
if (this._updateCountryFromNumber(
|
|
3041
|
+
if (this._updateCountryFromNumber(inputValue)) {
|
|
3008
3042
|
this._triggerCountryChange();
|
|
3009
3043
|
}
|
|
3010
3044
|
const isFormattingChar = (e === null || e === void 0 ? void 0 : e.data) && REGEX.NON_PLUS_NUMERIC.test(e.data);
|
|
3011
|
-
const isPaste = (e === null || e === void 0 ? void 0 : e.inputType) === INPUT_TYPES.PASTE &&
|
|
3045
|
+
const isPaste = (e === null || e === void 0 ? void 0 : e.inputType) === INPUT_TYPES.PASTE && inputValue;
|
|
3012
3046
|
if (isFormattingChar || isPaste && !strictMode) {
|
|
3013
3047
|
userOverrideFormatting = true;
|
|
3014
|
-
} else if (!REGEX.NON_PLUS_NUMERIC.test(
|
|
3048
|
+
} else if (!REGEX.NON_PLUS_NUMERIC.test(inputValue)) {
|
|
3015
3049
|
userOverrideFormatting = false;
|
|
3016
3050
|
}
|
|
3017
3051
|
const isSetNumber = (e === null || e === void 0 ? void 0 : e.detail) && e.detail["isSetNumber"];
|
|
3018
|
-
|
|
3052
|
+
const isAscii = this.userNumeralSet === "ascii";
|
|
3053
|
+
if (formatAsYouType && !userOverrideFormatting && !isSetNumber && isAscii) {
|
|
3019
3054
|
const currentCaretPos = this.ui.telInput.selectionStart || 0;
|
|
3020
|
-
const valueBeforeCaret =
|
|
3055
|
+
const valueBeforeCaret = inputValue.substring(0, currentCaretPos);
|
|
3021
3056
|
const relevantCharsBeforeCaret = valueBeforeCaret.replace(REGEX.NON_PLUS_NUMERIC_GLOBAL, "").length;
|
|
3022
3057
|
const isDeleteForwards = (e === null || e === void 0 ? void 0 : e.inputType) === INPUT_TYPES.DELETE_FWD;
|
|
3023
3058
|
const fullNumber = this._getFullNumber();
|
|
3024
|
-
const formattedValue = formatNumberAsYouType(fullNumber,
|
|
3059
|
+
const formattedValue = formatNumberAsYouType(fullNumber, inputValue, intlTelInput.utils, this.selectedCountryData, this.options.separateDialCode);
|
|
3025
3060
|
const newCaretPos = translateCursorPosition(relevantCharsBeforeCaret, formattedValue, currentCaretPos, isDeleteForwards);
|
|
3026
|
-
this.
|
|
3061
|
+
this._setTelInputValue(formattedValue);
|
|
3027
3062
|
this.ui.telInput.setSelectionRange(newCaretPos, newCaretPos);
|
|
3028
3063
|
}
|
|
3029
3064
|
};
|
|
@@ -3042,12 +3077,18 @@ var Iti = class _Iti {
|
|
|
3042
3077
|
return;
|
|
3043
3078
|
}
|
|
3044
3079
|
if (strictMode) {
|
|
3045
|
-
const
|
|
3046
|
-
const alreadyHasPlus =
|
|
3080
|
+
const inputValue = this._getTelInputValue();
|
|
3081
|
+
const alreadyHasPlus = inputValue.startsWith("+");
|
|
3047
3082
|
const isInitialPlus = !alreadyHasPlus && this.ui.telInput.selectionStart === 0 && e.key === "+";
|
|
3048
|
-
const
|
|
3083
|
+
const normalisedKey = this._normaliseNumerals(e.key);
|
|
3084
|
+
const isNumeric = /^[0-9]$/.test(normalisedKey);
|
|
3049
3085
|
const isAllowedChar = separateDialCode ? isNumeric : isInitialPlus || isNumeric;
|
|
3050
|
-
const
|
|
3086
|
+
const input = this.ui.telInput;
|
|
3087
|
+
const selStart = input.selectionStart;
|
|
3088
|
+
const selEnd = input.selectionEnd;
|
|
3089
|
+
const before = inputValue.slice(0, selStart);
|
|
3090
|
+
const after = inputValue.slice(selEnd);
|
|
3091
|
+
const newValue = before + e.key + after;
|
|
3051
3092
|
const newFullNumber = this._getFullNumber(newValue);
|
|
3052
3093
|
const coreNumber = intlTelInput.utils.getCoreNumber(newFullNumber, this.selectedCountryData.iso2);
|
|
3053
3094
|
const hasExceededMaxLength = this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength;
|
|
@@ -3071,34 +3112,38 @@ var Iti = class _Iti {
|
|
|
3071
3112
|
const input = this.ui.telInput;
|
|
3072
3113
|
const selStart = input.selectionStart;
|
|
3073
3114
|
const selEnd = input.selectionEnd;
|
|
3074
|
-
const
|
|
3075
|
-
const
|
|
3115
|
+
const inputValue = this._getTelInputValue();
|
|
3116
|
+
const before = inputValue.slice(0, selStart);
|
|
3117
|
+
const after = inputValue.slice(selEnd);
|
|
3076
3118
|
const iso2 = this.selectedCountryData.iso2;
|
|
3077
|
-
const
|
|
3119
|
+
const pastedRaw = e.clipboardData.getData("text");
|
|
3120
|
+
const pasted = this._normaliseNumerals(pastedRaw);
|
|
3078
3121
|
const initialCharSelected = selStart === 0 && selEnd > 0;
|
|
3079
|
-
const allowLeadingPlus = !
|
|
3122
|
+
const allowLeadingPlus = !inputValue.startsWith("+") || initialCharSelected;
|
|
3080
3123
|
const allowedChars = pasted.replace(REGEX.NON_PLUS_NUMERIC_GLOBAL, "");
|
|
3081
3124
|
const hasLeadingPlus = allowedChars.startsWith("+");
|
|
3082
3125
|
const numerics = allowedChars.replace(/\+/g, "");
|
|
3083
3126
|
const sanitised = hasLeadingPlus && allowLeadingPlus ? `+${numerics}` : numerics;
|
|
3084
3127
|
let newVal = before + sanitised + after;
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
}
|
|
3093
|
-
if (this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength) {
|
|
3094
|
-
if (input.selectionEnd === input.value.length) {
|
|
3095
|
-
const trimLength = coreNumber.length - this.maxCoreNumberLength;
|
|
3096
|
-
newVal = newVal.slice(0, newVal.length - trimLength);
|
|
3097
|
-
} else {
|
|
3128
|
+
if (newVal.length > 5) {
|
|
3129
|
+
let coreNumber = intlTelInput.utils.getCoreNumber(newVal, iso2);
|
|
3130
|
+
while (coreNumber.length === 0 && newVal.length > 0) {
|
|
3131
|
+
newVal = newVal.slice(0, -1);
|
|
3132
|
+
coreNumber = intlTelInput.utils.getCoreNumber(newVal, iso2);
|
|
3133
|
+
}
|
|
3134
|
+
if (!coreNumber) {
|
|
3098
3135
|
return;
|
|
3099
3136
|
}
|
|
3137
|
+
if (this.maxCoreNumberLength && coreNumber.length > this.maxCoreNumberLength) {
|
|
3138
|
+
if (input.selectionEnd === inputValue.length) {
|
|
3139
|
+
const trimLength = coreNumber.length - this.maxCoreNumberLength;
|
|
3140
|
+
newVal = newVal.slice(0, newVal.length - trimLength);
|
|
3141
|
+
} else {
|
|
3142
|
+
return;
|
|
3143
|
+
}
|
|
3144
|
+
}
|
|
3100
3145
|
}
|
|
3101
|
-
|
|
3146
|
+
this._setTelInputValue(newVal);
|
|
3102
3147
|
const caretPos = selStart + sanitised.length;
|
|
3103
3148
|
input.setSelectionRange(caretPos, caretPos);
|
|
3104
3149
|
input.dispatchEvent(new InputEvent("input", { bubbles: true }));
|
|
@@ -3335,7 +3380,7 @@ var Iti = class _Iti {
|
|
|
3335
3380
|
number = intlTelInput.utils.formatNumber(number, this.selectedCountryData.iso2, format);
|
|
3336
3381
|
}
|
|
3337
3382
|
number = this._beforeSetNumber(number);
|
|
3338
|
-
this.
|
|
3383
|
+
this._setTelInputValue(number);
|
|
3339
3384
|
}
|
|
3340
3385
|
//* Check if need to select a new country based on the given number
|
|
3341
3386
|
//* Note: called from _setInitialState, keyup handler, setNumber.
|
|
@@ -3489,7 +3534,8 @@ var Iti = class _Iti {
|
|
|
3489
3534
|
const dialCode = listItem.dataset[DATA_KEYS.DIAL_CODE];
|
|
3490
3535
|
this._updateDialCode(dialCode);
|
|
3491
3536
|
if (this.options.formatOnDisplay) {
|
|
3492
|
-
this.
|
|
3537
|
+
const inputValue = this._getTelInputValue();
|
|
3538
|
+
this._updateValFromNumber(inputValue);
|
|
3493
3539
|
}
|
|
3494
3540
|
this.ui.telInput.focus();
|
|
3495
3541
|
if (countryChanged) {
|
|
@@ -3520,7 +3566,7 @@ var Iti = class _Iti {
|
|
|
3520
3566
|
//* Replace any existing dial code with the new one
|
|
3521
3567
|
//* Note: called from _selectListItem and setCountry
|
|
3522
3568
|
_updateDialCode(newDialCodeBare) {
|
|
3523
|
-
const inputVal = this.
|
|
3569
|
+
const inputVal = this._getTelInputValue();
|
|
3524
3570
|
const newDialCode = `+${newDialCodeBare}`;
|
|
3525
3571
|
let newNumber;
|
|
3526
3572
|
if (inputVal.startsWith("+")) {
|
|
@@ -3530,7 +3576,7 @@ var Iti = class _Iti {
|
|
|
3530
3576
|
} else {
|
|
3531
3577
|
newNumber = newDialCode;
|
|
3532
3578
|
}
|
|
3533
|
-
this.
|
|
3579
|
+
this._setTelInputValue(newNumber);
|
|
3534
3580
|
}
|
|
3535
3581
|
}
|
|
3536
3582
|
//* Try and extract a valid international dial code from a full telephone number.
|
|
@@ -3567,7 +3613,7 @@ var Iti = class _Iti {
|
|
|
3567
3613
|
}
|
|
3568
3614
|
//* Get the input val, adding the dial code if separateDialCode is enabled.
|
|
3569
3615
|
_getFullNumber(overrideVal) {
|
|
3570
|
-
const val = overrideVal
|
|
3616
|
+
const val = overrideVal ? this._normaliseNumerals(overrideVal) : this._getTelInputValue();
|
|
3571
3617
|
const { dialCode } = this.selectedCountryData;
|
|
3572
3618
|
let prefix;
|
|
3573
3619
|
const numericVal = getNumeric(val);
|
|
@@ -3605,8 +3651,9 @@ var Iti = class _Iti {
|
|
|
3605
3651
|
//* This is called when the utils request completes.
|
|
3606
3652
|
handleUtils() {
|
|
3607
3653
|
if (intlTelInput.utils) {
|
|
3608
|
-
|
|
3609
|
-
|
|
3654
|
+
const inputValue = this._getTelInputValue();
|
|
3655
|
+
if (inputValue) {
|
|
3656
|
+
this._updateValFromNumber(inputValue);
|
|
3610
3657
|
}
|
|
3611
3658
|
if (this.selectedCountryData.iso2) {
|
|
3612
3659
|
this._updatePlaceholder();
|
|
@@ -3646,7 +3693,9 @@ var Iti = class _Iti {
|
|
|
3646
3693
|
getNumber(format) {
|
|
3647
3694
|
if (intlTelInput.utils) {
|
|
3648
3695
|
const { iso2 } = this.selectedCountryData;
|
|
3649
|
-
|
|
3696
|
+
const fullNumber = this._getFullNumber();
|
|
3697
|
+
const formattedNumber = intlTelInput.utils.formatNumber(fullNumber, iso2, format);
|
|
3698
|
+
return this._mapAsciiToUserNumerals(formattedNumber);
|
|
3650
3699
|
}
|
|
3651
3700
|
return "";
|
|
3652
3701
|
}
|
|
@@ -3723,15 +3772,17 @@ var Iti = class _Iti {
|
|
|
3723
3772
|
this._setCountry(iso2Lower);
|
|
3724
3773
|
this._updateDialCode(this.selectedCountryData.dialCode);
|
|
3725
3774
|
if (this.options.formatOnDisplay) {
|
|
3726
|
-
this.
|
|
3775
|
+
const inputValue = this._getTelInputValue();
|
|
3776
|
+
this._updateValFromNumber(inputValue);
|
|
3727
3777
|
}
|
|
3728
3778
|
this._triggerCountryChange();
|
|
3729
3779
|
}
|
|
3730
3780
|
}
|
|
3731
3781
|
//* Set the input value and update the country.
|
|
3732
3782
|
setNumber(number) {
|
|
3733
|
-
const
|
|
3734
|
-
this.
|
|
3783
|
+
const normalisedNumber = this._normaliseNumerals(number);
|
|
3784
|
+
const countryChanged = this._updateCountryFromNumber(normalisedNumber);
|
|
3785
|
+
this._updateValFromNumber(normalisedNumber);
|
|
3735
3786
|
if (countryChanged) {
|
|
3736
3787
|
this._triggerCountryChange();
|
|
3737
3788
|
}
|
|
@@ -3808,7 +3859,7 @@ var intlTelInput = Object.assign((input, options) => {
|
|
|
3808
3859
|
attachUtils,
|
|
3809
3860
|
startedLoadingUtilsScript: false,
|
|
3810
3861
|
startedLoadingAutoCountry: false,
|
|
3811
|
-
version: "25.
|
|
3862
|
+
version: "25.13.1"
|
|
3812
3863
|
});
|
|
3813
3864
|
var intl_tel_input_default = intlTelInput;
|
|
3814
3865
|
|