intl-tel-input 25.8.6 → 25.10.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 +10 -6
- package/angular/README.md +1 -1
- package/angular/build/IntlTelInput.js +30 -12
- package/angular/build/IntlTelInputWithUtils.js +30 -12
- package/angular/build/types/intl-tel-input.d.ts +1 -0
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput.d.ts +1 -0
- package/build/js/intlTelInput.js +27 -13
- package/build/js/intlTelInput.min.js +4 -4
- package/build/js/intlTelInputWithUtils.js +27 -13
- package/build/js/intlTelInputWithUtils.min.js +3 -3
- package/package.json +10 -10
- package/react/README.md +1 -1
- package/react/build/IntlTelInput.cjs +26 -12
- package/react/build/IntlTelInput.d.ts +1 -0
- package/react/build/IntlTelInput.js +26 -12
- package/react/build/IntlTelInputWithUtils.cjs +26 -12
- package/react/build/IntlTelInputWithUtils.js +26 -12
- package/vue/README.md +1 -1
- package/vue/build/IntlTelInput.mjs +72 -63
- package/vue/build/IntlTelInputWithUtils.mjs +209 -200
- package/angular/build/types/countryDataManager.d.ts +0 -25
- package/angular/build/types/dropdown.d.ts +0 -56
- package/angular/build/types/types.d.ts +0 -53
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# International Telephone Input <img src="https://img.shields.io/github/package-json/v/jackocnr/intl-tel-input.svg" alt="version"/> <img src="https://img.shields.io/npm/dm/intl-tel-input.svg" alt="downloads"/>
|
|
1
|
+
# International Telephone Input [](https://app.travis-ci.com/jackocnr/intl-tel-input) <img src="https://img.shields.io/github/package-json/v/jackocnr/intl-tel-input.svg" alt="version"/> <img src="https://img.shields.io/npm/dm/intl-tel-input.svg" alt="downloads"/>
|
|
2
2
|
|
|
3
3
|
<img src="https://raw.github.com/jackocnr/intl-tel-input/master/screenshots/vue-icon.png" alt="Vue logo" width="16px" /> NEWS: we now have our own <a href="https://github.com/jackocnr/intl-tel-input/tree/master/vue">Vue component</a>!
|
|
4
4
|
|
|
@@ -77,16 +77,16 @@ _Note: We have now dropped support for all versions of Internet Explorer because
|
|
|
77
77
|
## Getting Started (Using a CDN)
|
|
78
78
|
1. Add the CSS
|
|
79
79
|
```html
|
|
80
|
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@25.
|
|
80
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/intl-tel-input@25.10.1/build/css/intlTelInput.css">
|
|
81
81
|
```
|
|
82
82
|
|
|
83
83
|
2. Add the plugin script and initialise it on your input element
|
|
84
84
|
```html
|
|
85
|
-
<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@25.
|
|
85
|
+
<script src="https://cdn.jsdelivr.net/npm/intl-tel-input@25.10.1/build/js/intlTelInput.min.js"></script>
|
|
86
86
|
<script>
|
|
87
87
|
const input = document.querySelector("#phone");
|
|
88
88
|
window.intlTelInput(input, {
|
|
89
|
-
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.
|
|
89
|
+
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.10.1/build/js/utils.js"),
|
|
90
90
|
});
|
|
91
91
|
</script>
|
|
92
92
|
```
|
|
@@ -163,6 +163,10 @@ When you initialise the plugin, the first argument is the input element, and the
|
|
|
163
163
|
Type: `Boolean` Default: `true`
|
|
164
164
|
Whether or not to allow the dropdown. If disabled, there is no dropdown arrow, and the selected country is not clickable. Also, if showFlags is enabled we display the selected flag on the right instead because it is just a marker of state. Note that if `separateDialCode` is enabled, `allowDropdown` is forced to `true` as the dropdown is required when the user types "+" in this case. Play with this option on [Storybook](https://intl-tel-input.com/storybook/?path=/docs/intltelinput--allowdropdown) (using the React component).
|
|
165
165
|
|
|
166
|
+
**allowPhonewords**
|
|
167
|
+
Type: `Boolean` Default: `false`
|
|
168
|
+
Whether or not the validation methods return `true` for numbers containing phonewords e.g. "+1 702 FLOWERS".
|
|
169
|
+
|
|
166
170
|
**autoPlaceholder**
|
|
167
171
|
Type: `String` Default: `"polite"`
|
|
168
172
|
Set the input's placeholder to an example number for the selected country, and update it if the country changes. You can specify the number type using the `placeholderNumberType` option. By default, it is set to `"polite"`, which means it will only set the placeholder if the input doesn't already have one. You can also set it to `"aggressive"`, which will replace any existing placeholder, or `"off"`. Requires the [utils script to be loaded](#loading-the-utilities-script).
|
|
@@ -322,7 +326,7 @@ The `loadUtils` option takes a function which returns a Promise which resolves t
|
|
|
322
326
|
```js
|
|
323
327
|
// (A) import utils module from a CDN
|
|
324
328
|
intlTelInput(htmlInputElement, {
|
|
325
|
-
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.
|
|
329
|
+
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.10.1/build/js/utils.js"),
|
|
326
330
|
});
|
|
327
331
|
|
|
328
332
|
// (B) import utils module from your own hosted version of utils.js
|
|
@@ -606,7 +610,7 @@ The `loadUtils` option takes a function which returns a Promise which resolves t
|
|
|
606
610
|
```js
|
|
607
611
|
// (A) import utils module from a CDN
|
|
608
612
|
intlTelInput(htmlInputElement, {
|
|
609
|
-
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.
|
|
613
|
+
loadUtils: () => import("https://cdn.jsdelivr.net/npm/intl-tel-input@25.10.1/build/js/utils.js"),
|
|
610
614
|
});
|
|
611
615
|
|
|
612
616
|
// (B) import utils module from your own hosted version of utils.js
|
package/angular/README.md
CHANGED
|
@@ -29,7 +29,7 @@ import "intl-tel-input/styles";
|
|
|
29
29
|
|
|
30
30
|
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.
|
|
31
31
|
|
|
32
|
-
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/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.
|
|
32
|
+
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/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.10.1/build/js/utils.js"`.
|
|
33
33
|
|
|
34
34
|
## Props
|
|
35
35
|
Here's a list of all of the current props you can pass to the IntlTelInput Angular component.
|
|
@@ -1625,6 +1625,8 @@ var computeDefaultUseFullscreenPopup = () => {
|
|
|
1625
1625
|
return false;
|
|
1626
1626
|
};
|
|
1627
1627
|
var defaults = {
|
|
1628
|
+
// Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
|
|
1629
|
+
allowPhonewords: false,
|
|
1628
1630
|
//* Whether or not to allow the dropdown.
|
|
1629
1631
|
allowDropdown: true,
|
|
1630
1632
|
//* Add a placeholder in the input with an example number for the selected country.
|
|
@@ -1919,7 +1921,12 @@ var Iti = class _Iti {
|
|
|
1919
1921
|
const wrapper = createEl("div", { class: parentClasses });
|
|
1920
1922
|
(_a = this.telInput.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(wrapper, this.telInput);
|
|
1921
1923
|
if (allowDropdown || showFlags || separateDialCode) {
|
|
1922
|
-
this.countryContainer = createEl(
|
|
1924
|
+
this.countryContainer = createEl(
|
|
1925
|
+
"div",
|
|
1926
|
+
// visibly hidden until we measure it's width to set the input padding correctly
|
|
1927
|
+
{ class: "iti__country-container iti__v-hide" },
|
|
1928
|
+
wrapper
|
|
1929
|
+
);
|
|
1923
1930
|
if (this.showSelectedCountryOnLeft) {
|
|
1924
1931
|
this.countryContainer.style.left = "0px";
|
|
1925
1932
|
} else {
|
|
@@ -2030,7 +2037,10 @@ var Iti = class _Iti {
|
|
|
2030
2037
|
}
|
|
2031
2038
|
}
|
|
2032
2039
|
wrapper.appendChild(this.telInput);
|
|
2033
|
-
this.
|
|
2040
|
+
if (this.countryContainer) {
|
|
2041
|
+
this._updateInputPadding();
|
|
2042
|
+
this.countryContainer.classList.remove("iti__v-hide");
|
|
2043
|
+
}
|
|
2034
2044
|
if (hiddenInput) {
|
|
2035
2045
|
const telInputName = this.telInput.getAttribute("name") || "";
|
|
2036
2046
|
const names = hiddenInput(telInputName);
|
|
@@ -2672,7 +2682,8 @@ var Iti = class _Iti {
|
|
|
2672
2682
|
//* Update the input padding to make space for the selected country/dial code.
|
|
2673
2683
|
_updateInputPadding() {
|
|
2674
2684
|
if (this.selectedCountry) {
|
|
2675
|
-
const
|
|
2685
|
+
const saneDefaultWidth = this.options.separateDialCode ? 78 : 42;
|
|
2686
|
+
const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth() || saneDefaultWidth;
|
|
2676
2687
|
const inputPadding = selectedCountryWidth + 6;
|
|
2677
2688
|
if (this.showSelectedCountryOnLeft) {
|
|
2678
2689
|
this.telInput.style.paddingLeft = `${inputPadding}px`;
|
|
@@ -2704,21 +2715,27 @@ var Iti = class _Iti {
|
|
|
2704
2715
|
}
|
|
2705
2716
|
}
|
|
2706
2717
|
}
|
|
2707
|
-
//* When
|
|
2708
|
-
//*
|
|
2709
|
-
//*
|
|
2710
|
-
//*
|
|
2718
|
+
//* When input is in a hidden container during init, we cannot calculate the selected country width.
|
|
2719
|
+
//* Fix: clone the markup, make it invisible, add it to the end of the DOM, and then measure it's width.
|
|
2720
|
+
//* To get the right styling to apply, all we need is a shallow clone of the container,
|
|
2721
|
+
//* and then to inject a deep clone of the selectedCountry element.
|
|
2711
2722
|
_getHiddenSelectedCountryWidth() {
|
|
2712
2723
|
if (this.telInput.parentNode) {
|
|
2724
|
+
let body;
|
|
2725
|
+
try {
|
|
2726
|
+
body = window.top.document.body;
|
|
2727
|
+
} catch (e) {
|
|
2728
|
+
body = document.body;
|
|
2729
|
+
}
|
|
2713
2730
|
const containerClone = this.telInput.parentNode.cloneNode(false);
|
|
2714
2731
|
containerClone.style.visibility = "hidden";
|
|
2715
|
-
|
|
2732
|
+
body.appendChild(containerClone);
|
|
2716
2733
|
const countryContainerClone = this.countryContainer.cloneNode();
|
|
2717
2734
|
containerClone.appendChild(countryContainerClone);
|
|
2718
2735
|
const selectedCountryClone = this.selectedCountry.cloneNode(true);
|
|
2719
2736
|
countryContainerClone.appendChild(selectedCountryClone);
|
|
2720
2737
|
const width = selectedCountryClone.offsetWidth;
|
|
2721
|
-
|
|
2738
|
+
body.removeChild(containerClone);
|
|
2722
2739
|
return width;
|
|
2723
2740
|
}
|
|
2724
2741
|
return 0;
|
|
@@ -2999,10 +3016,11 @@ var Iti = class _Iti {
|
|
|
2999
3016
|
if (!this.selectedCountryData.iso2) {
|
|
3000
3017
|
return false;
|
|
3001
3018
|
}
|
|
3019
|
+
const testValidity = (s) => precise ? this._utilsIsValidNumber(s) : this._utilsIsPossibleNumber(s);
|
|
3002
3020
|
const val = this._getFullNumber();
|
|
3003
3021
|
const alphaCharPosition = val.search(/\p{L}/u);
|
|
3004
|
-
const
|
|
3005
|
-
if (
|
|
3022
|
+
const hasAlphaChar = alphaCharPosition > -1;
|
|
3023
|
+
if (hasAlphaChar && !this.options.allowPhonewords) {
|
|
3006
3024
|
const beforeAlphaChar = val.substring(0, alphaCharPosition);
|
|
3007
3025
|
const beforeAlphaIsValid = testValidity(beforeAlphaChar);
|
|
3008
3026
|
const isValid = testValidity(val);
|
|
@@ -3101,7 +3119,7 @@ var intlTelInput = Object.assign((input, options) => {
|
|
|
3101
3119
|
attachUtils,
|
|
3102
3120
|
startedLoadingUtilsScript: false,
|
|
3103
3121
|
startedLoadingAutoCountry: false,
|
|
3104
|
-
version: "25.
|
|
3122
|
+
version: "25.10.1"
|
|
3105
3123
|
});
|
|
3106
3124
|
var intl_tel_input_default = intlTelInput;
|
|
3107
3125
|
|
|
@@ -1625,6 +1625,8 @@ var computeDefaultUseFullscreenPopup = () => {
|
|
|
1625
1625
|
return false;
|
|
1626
1626
|
};
|
|
1627
1627
|
var defaults = {
|
|
1628
|
+
// Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
|
|
1629
|
+
allowPhonewords: false,
|
|
1628
1630
|
//* Whether or not to allow the dropdown.
|
|
1629
1631
|
allowDropdown: true,
|
|
1630
1632
|
//* Add a placeholder in the input with an example number for the selected country.
|
|
@@ -1919,7 +1921,12 @@ var Iti = class _Iti {
|
|
|
1919
1921
|
const wrapper = createEl("div", { class: parentClasses });
|
|
1920
1922
|
(_a = this.telInput.parentNode) === null || _a === void 0 ? void 0 : _a.insertBefore(wrapper, this.telInput);
|
|
1921
1923
|
if (allowDropdown || showFlags || separateDialCode) {
|
|
1922
|
-
this.countryContainer = createEl(
|
|
1924
|
+
this.countryContainer = createEl(
|
|
1925
|
+
"div",
|
|
1926
|
+
// visibly hidden until we measure it's width to set the input padding correctly
|
|
1927
|
+
{ class: "iti__country-container iti__v-hide" },
|
|
1928
|
+
wrapper
|
|
1929
|
+
);
|
|
1923
1930
|
if (this.showSelectedCountryOnLeft) {
|
|
1924
1931
|
this.countryContainer.style.left = "0px";
|
|
1925
1932
|
} else {
|
|
@@ -2030,7 +2037,10 @@ var Iti = class _Iti {
|
|
|
2030
2037
|
}
|
|
2031
2038
|
}
|
|
2032
2039
|
wrapper.appendChild(this.telInput);
|
|
2033
|
-
this.
|
|
2040
|
+
if (this.countryContainer) {
|
|
2041
|
+
this._updateInputPadding();
|
|
2042
|
+
this.countryContainer.classList.remove("iti__v-hide");
|
|
2043
|
+
}
|
|
2034
2044
|
if (hiddenInput) {
|
|
2035
2045
|
const telInputName = this.telInput.getAttribute("name") || "";
|
|
2036
2046
|
const names = hiddenInput(telInputName);
|
|
@@ -2672,7 +2682,8 @@ var Iti = class _Iti {
|
|
|
2672
2682
|
//* Update the input padding to make space for the selected country/dial code.
|
|
2673
2683
|
_updateInputPadding() {
|
|
2674
2684
|
if (this.selectedCountry) {
|
|
2675
|
-
const
|
|
2685
|
+
const saneDefaultWidth = this.options.separateDialCode ? 78 : 42;
|
|
2686
|
+
const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth() || saneDefaultWidth;
|
|
2676
2687
|
const inputPadding = selectedCountryWidth + 6;
|
|
2677
2688
|
if (this.showSelectedCountryOnLeft) {
|
|
2678
2689
|
this.telInput.style.paddingLeft = `${inputPadding}px`;
|
|
@@ -2704,21 +2715,27 @@ var Iti = class _Iti {
|
|
|
2704
2715
|
}
|
|
2705
2716
|
}
|
|
2706
2717
|
}
|
|
2707
|
-
//* When
|
|
2708
|
-
//*
|
|
2709
|
-
//*
|
|
2710
|
-
//*
|
|
2718
|
+
//* When input is in a hidden container during init, we cannot calculate the selected country width.
|
|
2719
|
+
//* Fix: clone the markup, make it invisible, add it to the end of the DOM, and then measure it's width.
|
|
2720
|
+
//* To get the right styling to apply, all we need is a shallow clone of the container,
|
|
2721
|
+
//* and then to inject a deep clone of the selectedCountry element.
|
|
2711
2722
|
_getHiddenSelectedCountryWidth() {
|
|
2712
2723
|
if (this.telInput.parentNode) {
|
|
2724
|
+
let body;
|
|
2725
|
+
try {
|
|
2726
|
+
body = window.top.document.body;
|
|
2727
|
+
} catch (e) {
|
|
2728
|
+
body = document.body;
|
|
2729
|
+
}
|
|
2713
2730
|
const containerClone = this.telInput.parentNode.cloneNode(false);
|
|
2714
2731
|
containerClone.style.visibility = "hidden";
|
|
2715
|
-
|
|
2732
|
+
body.appendChild(containerClone);
|
|
2716
2733
|
const countryContainerClone = this.countryContainer.cloneNode();
|
|
2717
2734
|
containerClone.appendChild(countryContainerClone);
|
|
2718
2735
|
const selectedCountryClone = this.selectedCountry.cloneNode(true);
|
|
2719
2736
|
countryContainerClone.appendChild(selectedCountryClone);
|
|
2720
2737
|
const width = selectedCountryClone.offsetWidth;
|
|
2721
|
-
|
|
2738
|
+
body.removeChild(containerClone);
|
|
2722
2739
|
return width;
|
|
2723
2740
|
}
|
|
2724
2741
|
return 0;
|
|
@@ -2999,10 +3016,11 @@ var Iti = class _Iti {
|
|
|
2999
3016
|
if (!this.selectedCountryData.iso2) {
|
|
3000
3017
|
return false;
|
|
3001
3018
|
}
|
|
3019
|
+
const testValidity = (s) => precise ? this._utilsIsValidNumber(s) : this._utilsIsPossibleNumber(s);
|
|
3002
3020
|
const val = this._getFullNumber();
|
|
3003
3021
|
const alphaCharPosition = val.search(/\p{L}/u);
|
|
3004
|
-
const
|
|
3005
|
-
if (
|
|
3022
|
+
const hasAlphaChar = alphaCharPosition > -1;
|
|
3023
|
+
if (hasAlphaChar && !this.options.allowPhonewords) {
|
|
3006
3024
|
const beforeAlphaChar = val.substring(0, alphaCharPosition);
|
|
3007
3025
|
const beforeAlphaIsValid = testValidity(beforeAlphaChar);
|
|
3008
3026
|
const isValid = testValidity(val);
|
|
@@ -3101,7 +3119,7 @@ var intlTelInput = Object.assign((input, options) => {
|
|
|
3101
3119
|
attachUtils,
|
|
3102
3120
|
startedLoadingUtilsScript: false,
|
|
3103
3121
|
startedLoadingAutoCountry: false,
|
|
3104
|
-
version: "25.
|
|
3122
|
+
version: "25.10.1"
|
|
3105
3123
|
});
|
|
3106
3124
|
var intl_tel_input_default = intlTelInput;
|
|
3107
3125
|
|
package/build/js/data.js
CHANGED
package/build/js/data.min.js
CHANGED
package/build/js/intlTelInput.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* International Telephone Input v25.
|
|
2
|
+
* International Telephone Input v25.10.1
|
|
3
3
|
* https://github.com/jackocnr/intl-tel-input.git
|
|
4
4
|
* Licensed under the MIT license
|
|
5
5
|
*/
|
|
@@ -1666,6 +1666,8 @@ var factoryOutput = (() => {
|
|
|
1666
1666
|
return false;
|
|
1667
1667
|
};
|
|
1668
1668
|
var defaults = {
|
|
1669
|
+
// Allow alphanumeric "phonewords" (e.g. +1 800 FLOWERS) as valid numbers
|
|
1670
|
+
allowPhonewords: false,
|
|
1669
1671
|
//* Whether or not to allow the dropdown.
|
|
1670
1672
|
allowDropdown: true,
|
|
1671
1673
|
//* Add a placeholder in the input with an example number for the selected country.
|
|
@@ -1980,7 +1982,8 @@ var factoryOutput = (() => {
|
|
|
1980
1982
|
if (allowDropdown || showFlags || separateDialCode) {
|
|
1981
1983
|
this.countryContainer = createEl(
|
|
1982
1984
|
"div",
|
|
1983
|
-
|
|
1985
|
+
// visibly hidden until we measure it's width to set the input padding correctly
|
|
1986
|
+
{ class: "iti__country-container iti__v-hide" },
|
|
1984
1987
|
wrapper
|
|
1985
1988
|
);
|
|
1986
1989
|
if (this.showSelectedCountryOnLeft) {
|
|
@@ -2145,7 +2148,10 @@ var factoryOutput = (() => {
|
|
|
2145
2148
|
}
|
|
2146
2149
|
}
|
|
2147
2150
|
wrapper.appendChild(this.telInput);
|
|
2148
|
-
this.
|
|
2151
|
+
if (this.countryContainer) {
|
|
2152
|
+
this._updateInputPadding();
|
|
2153
|
+
this.countryContainer.classList.remove("iti__v-hide");
|
|
2154
|
+
}
|
|
2149
2155
|
if (hiddenInput) {
|
|
2150
2156
|
const telInputName = this.telInput.getAttribute("name") || "";
|
|
2151
2157
|
const names = hiddenInput(telInputName);
|
|
@@ -2805,7 +2811,8 @@ var factoryOutput = (() => {
|
|
|
2805
2811
|
//* Update the input padding to make space for the selected country/dial code.
|
|
2806
2812
|
_updateInputPadding() {
|
|
2807
2813
|
if (this.selectedCountry) {
|
|
2808
|
-
const
|
|
2814
|
+
const saneDefaultWidth = this.options.separateDialCode ? 78 : 42;
|
|
2815
|
+
const selectedCountryWidth = this.selectedCountry.offsetWidth || this._getHiddenSelectedCountryWidth() || saneDefaultWidth;
|
|
2809
2816
|
const inputPadding = selectedCountryWidth + 6;
|
|
2810
2817
|
if (this.showSelectedCountryOnLeft) {
|
|
2811
2818
|
this.telInput.style.paddingLeft = `${inputPadding}px`;
|
|
@@ -2842,21 +2849,27 @@ var factoryOutput = (() => {
|
|
|
2842
2849
|
}
|
|
2843
2850
|
}
|
|
2844
2851
|
}
|
|
2845
|
-
//* When
|
|
2846
|
-
//*
|
|
2847
|
-
//*
|
|
2848
|
-
//*
|
|
2852
|
+
//* When input is in a hidden container during init, we cannot calculate the selected country width.
|
|
2853
|
+
//* Fix: clone the markup, make it invisible, add it to the end of the DOM, and then measure it's width.
|
|
2854
|
+
//* To get the right styling to apply, all we need is a shallow clone of the container,
|
|
2855
|
+
//* and then to inject a deep clone of the selectedCountry element.
|
|
2849
2856
|
_getHiddenSelectedCountryWidth() {
|
|
2850
2857
|
if (this.telInput.parentNode) {
|
|
2858
|
+
let body;
|
|
2859
|
+
try {
|
|
2860
|
+
body = window.top.document.body;
|
|
2861
|
+
} catch (e) {
|
|
2862
|
+
body = document.body;
|
|
2863
|
+
}
|
|
2851
2864
|
const containerClone = this.telInput.parentNode.cloneNode(false);
|
|
2852
2865
|
containerClone.style.visibility = "hidden";
|
|
2853
|
-
|
|
2866
|
+
body.appendChild(containerClone);
|
|
2854
2867
|
const countryContainerClone = this.countryContainer.cloneNode();
|
|
2855
2868
|
containerClone.appendChild(countryContainerClone);
|
|
2856
2869
|
const selectedCountryClone = this.selectedCountry.cloneNode(true);
|
|
2857
2870
|
countryContainerClone.appendChild(selectedCountryClone);
|
|
2858
2871
|
const width = selectedCountryClone.offsetWidth;
|
|
2859
|
-
|
|
2872
|
+
body.removeChild(containerClone);
|
|
2860
2873
|
return width;
|
|
2861
2874
|
}
|
|
2862
2875
|
return 0;
|
|
@@ -3169,10 +3182,11 @@ var factoryOutput = (() => {
|
|
|
3169
3182
|
if (!this.selectedCountryData.iso2) {
|
|
3170
3183
|
return false;
|
|
3171
3184
|
}
|
|
3185
|
+
const testValidity = (s) => precise ? this._utilsIsValidNumber(s) : this._utilsIsPossibleNumber(s);
|
|
3172
3186
|
const val = this._getFullNumber();
|
|
3173
3187
|
const alphaCharPosition = val.search(/\p{L}/u);
|
|
3174
|
-
const
|
|
3175
|
-
if (
|
|
3188
|
+
const hasAlphaChar = alphaCharPosition > -1;
|
|
3189
|
+
if (hasAlphaChar && !this.options.allowPhonewords) {
|
|
3176
3190
|
const beforeAlphaChar = val.substring(0, alphaCharPosition);
|
|
3177
3191
|
const beforeAlphaIsValid = testValidity(beforeAlphaChar);
|
|
3178
3192
|
const isValid = testValidity(val);
|
|
@@ -3273,7 +3287,7 @@ var factoryOutput = (() => {
|
|
|
3273
3287
|
attachUtils,
|
|
3274
3288
|
startedLoadingUtilsScript: false,
|
|
3275
3289
|
startedLoadingAutoCountry: false,
|
|
3276
|
-
version: "25.
|
|
3290
|
+
version: "25.10.1"
|
|
3277
3291
|
}
|
|
3278
3292
|
);
|
|
3279
3293
|
var intl_tel_input_default = intlTelInput;
|