intl-tel-input 23.0.10 → 23.0.12
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 +34 -24
- 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 +33 -14
- package/build/js/intlTelInput.min.js +2 -2
- package/build/js/intlTelInputWithUtils.js +262 -189
- package/build/js/intlTelInputWithUtils.min.js +2 -2
- package/build/js/utils.js +36 -37
- package/package.json +1 -1
- package/react/README.md +9 -4
- package/react/build/IntlTelInput.cjs +32 -13
- package/react/build/IntlTelInput.d.ts +1 -0
- package/react/build/IntlTelInput.js +32 -13
- package/react/build/IntlTelInputWithUtils.cjs +261 -188
- package/react/build/IntlTelInputWithUtils.js +261 -188
|
@@ -1478,6 +1478,7 @@ var Iti = class {
|
|
|
1478
1478
|
options;
|
|
1479
1479
|
hadInitialPlaceholder;
|
|
1480
1480
|
isRTL;
|
|
1481
|
+
isAndroid;
|
|
1481
1482
|
selectedCountryData;
|
|
1482
1483
|
countries;
|
|
1483
1484
|
dialCodeMaxLen;
|
|
@@ -1536,6 +1537,7 @@ var Iti = class {
|
|
|
1536
1537
|
if (this.options.useFullscreenPopup && !this.options.dropdownContainer) {
|
|
1537
1538
|
this.options.dropdownContainer = document.body;
|
|
1538
1539
|
}
|
|
1540
|
+
this.isAndroid = typeof navigator !== "undefined" ? /Android/i.test(navigator.userAgent) : false;
|
|
1539
1541
|
this.isRTL = !!this.telInput.closest("[dir=rtl]");
|
|
1540
1542
|
this.options.i18n = { ...en_default, ...this.options.i18n };
|
|
1541
1543
|
const autoCountryPromise = new Promise((resolve, reject) => {
|
|
@@ -1853,10 +1855,11 @@ var Iti = class {
|
|
|
1853
1855
|
const val = useAttribute ? attributeValue : inputValue;
|
|
1854
1856
|
const dialCode = this._getDialCode(val);
|
|
1855
1857
|
const isRegionlessNanpNumber = isRegionlessNanp(val);
|
|
1856
|
-
const { initialCountry } = this.options;
|
|
1858
|
+
const { initialCountry, geoIpLookup } = this.options;
|
|
1859
|
+
const isAutoCountry = initialCountry === "auto" && geoIpLookup;
|
|
1857
1860
|
if (dialCode && !isRegionlessNanpNumber) {
|
|
1858
1861
|
this._updateCountryFromNumber(val);
|
|
1859
|
-
} else if (
|
|
1862
|
+
} else if (!isAutoCountry || overrideAutoCountry) {
|
|
1860
1863
|
const lowerInitialCountry = initialCountry ? initialCountry.toLowerCase() : "";
|
|
1861
1864
|
const isValidInitialCountry = lowerInitialCountry && this._getCountryData(lowerInitialCountry, true);
|
|
1862
1865
|
if (isValidInitialCountry) {
|
|
@@ -1935,18 +1938,20 @@ var Iti = class {
|
|
|
1935
1938
|
}
|
|
1936
1939
|
//* Init many requests: utils script / geo ip lookup.
|
|
1937
1940
|
_initRequests() {
|
|
1938
|
-
|
|
1941
|
+
const { utilsScript, initialCountry, geoIpLookup } = this.options;
|
|
1942
|
+
if (utilsScript && !intlTelInput.utils) {
|
|
1939
1943
|
if (intlTelInput.documentReady()) {
|
|
1940
|
-
intlTelInput.loadUtils(
|
|
1944
|
+
intlTelInput.loadUtils(utilsScript);
|
|
1941
1945
|
} else {
|
|
1942
1946
|
window.addEventListener("load", () => {
|
|
1943
|
-
intlTelInput.loadUtils(
|
|
1947
|
+
intlTelInput.loadUtils(utilsScript);
|
|
1944
1948
|
});
|
|
1945
1949
|
}
|
|
1946
1950
|
} else {
|
|
1947
1951
|
this.resolveUtilsScriptPromise();
|
|
1948
1952
|
}
|
|
1949
|
-
|
|
1953
|
+
const isAutoCountry = initialCountry === "auto" && geoIpLookup;
|
|
1954
|
+
if (isAutoCountry && !this.selectedCountryData.iso2) {
|
|
1950
1955
|
this._loadAutoCountry();
|
|
1951
1956
|
} else {
|
|
1952
1957
|
this.resolveAutoCountryPromise();
|
|
@@ -1983,7 +1988,20 @@ var Iti = class {
|
|
|
1983
1988
|
_initTelInputListeners() {
|
|
1984
1989
|
const { strictMode, formatAsYouType, separateDialCode, formatOnDisplay } = this.options;
|
|
1985
1990
|
let userOverrideFormatting = false;
|
|
1991
|
+
const openDropdownWithPlus = () => {
|
|
1992
|
+
this._openDropdown();
|
|
1993
|
+
this.searchInput.value = "+";
|
|
1994
|
+
this._filterCountries("", true);
|
|
1995
|
+
};
|
|
1986
1996
|
this._handleInputEvent = (e) => {
|
|
1997
|
+
if (this.isAndroid && e?.data === "+" && separateDialCode) {
|
|
1998
|
+
const currentCaretPos = this.telInput.selectionStart || 0;
|
|
1999
|
+
const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos - 1);
|
|
2000
|
+
const valueAfterCaret = this.telInput.value.substring(currentCaretPos);
|
|
2001
|
+
this.telInput.value = valueBeforeCaret + valueAfterCaret;
|
|
2002
|
+
openDropdownWithPlus();
|
|
2003
|
+
return;
|
|
2004
|
+
}
|
|
1987
2005
|
if (this._updateCountryFromNumber(this.telInput.value)) {
|
|
1988
2006
|
this._triggerCountryChange();
|
|
1989
2007
|
}
|
|
@@ -2012,9 +2030,7 @@ var Iti = class {
|
|
|
2012
2030
|
if (e.key && e.key.length === 1 && !e.altKey && !e.ctrlKey && !e.metaKey) {
|
|
2013
2031
|
if (separateDialCode && e.key === "+") {
|
|
2014
2032
|
e.preventDefault();
|
|
2015
|
-
|
|
2016
|
-
this.searchInput.value = "+";
|
|
2017
|
-
this._filterCountries("", true);
|
|
2033
|
+
openDropdownWithPlus();
|
|
2018
2034
|
return;
|
|
2019
2035
|
}
|
|
2020
2036
|
if (strictMode) {
|
|
@@ -2566,7 +2582,8 @@ var Iti = class {
|
|
|
2566
2582
|
handleAutoCountry() {
|
|
2567
2583
|
if (this.options.initialCountry === "auto" && intlTelInput.autoCountry) {
|
|
2568
2584
|
this.defaultCountry = intlTelInput.autoCountry;
|
|
2569
|
-
|
|
2585
|
+
const hasSelectedCountryOrGlobe = this.selectedCountryData.iso2 || this.selectedCountryInner.classList.contains("iti__globe");
|
|
2586
|
+
if (!hasSelectedCountryOrGlobe) {
|
|
2570
2587
|
this.setCountry(this.defaultCountry);
|
|
2571
2588
|
}
|
|
2572
2589
|
this.resolveAutoCountryPromise();
|
|
@@ -2681,8 +2698,10 @@ var Iti = class {
|
|
|
2681
2698
|
}
|
|
2682
2699
|
//* Update the selected country, and update the input val accordingly.
|
|
2683
2700
|
setCountry(iso2) {
|
|
2684
|
-
const iso2Lower = iso2
|
|
2685
|
-
|
|
2701
|
+
const iso2Lower = iso2?.toLowerCase();
|
|
2702
|
+
const currentCountry = this.selectedCountryData.iso2;
|
|
2703
|
+
const isCountryChange = iso2 && iso2Lower !== currentCountry || !iso2 && currentCountry;
|
|
2704
|
+
if (isCountryChange) {
|
|
2686
2705
|
this._setCountry(iso2Lower);
|
|
2687
2706
|
this._updateDialCode(this.selectedCountryData.dialCode);
|
|
2688
2707
|
this._triggerCountryChange();
|
|
@@ -2744,7 +2763,7 @@ var intlTelInput = Object.assign(
|
|
|
2744
2763
|
//* A map from instance ID to instance object.
|
|
2745
2764
|
instances: {},
|
|
2746
2765
|
loadUtils,
|
|
2747
|
-
version: "23.0.
|
|
2766
|
+
version: "23.0.12"
|
|
2748
2767
|
}
|
|
2749
2768
|
);
|
|
2750
2769
|
var intl_tel_input_default = intlTelInput;
|