intl-tel-input 19.5.6 → 19.5.7
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 +13 -9
- package/build/js/data.js +1 -1
- package/build/js/data.min.js +1 -1
- package/build/js/intlTelInput-jquery.js +16 -10
- package/build/js/intlTelInput-jquery.min.js +3 -3
- package/build/js/intlTelInput.js +16 -10
- package/build/js/intlTelInput.min.js +3 -3
- package/composer.json +1 -1
- package/package.json +1 -1
- package/react/build/IntlTelInput.cjs.js +2 -2
- package/react/build/IntlTelInput.cjs.js.map +3 -3
- package/react/build/IntlTelInput.esm.js +2 -2
- package/react/build/IntlTelInput.esm.js.map +3 -3
- package/react/demo/simple-bundle.js +49 -47
- package/react/demo/validation-bundle.js +49 -47
- package/src/js/intlTelInput.js +21 -14
package/src/js/intlTelInput.js
CHANGED
|
@@ -816,7 +816,9 @@ class Iti {
|
|
|
816
816
|
}
|
|
817
817
|
|
|
818
818
|
// if user types their own formatting char (not a plus or a numeric), then set the override
|
|
819
|
-
|
|
819
|
+
const isFormattingChar = e && e.data && /[^+0-9]/.test(e.data);
|
|
820
|
+
const isPaste = e && e.inputType === "insertFromPaste" && this.telInput.value;
|
|
821
|
+
if (isFormattingChar || isPaste) {
|
|
820
822
|
userOverrideFormatting = true;
|
|
821
823
|
}
|
|
822
824
|
// if user removes all formatting chars, then reset the override
|
|
@@ -824,7 +826,8 @@ class Iti {
|
|
|
824
826
|
userOverrideFormatting = false;
|
|
825
827
|
}
|
|
826
828
|
|
|
827
|
-
|
|
829
|
+
// handle FAYT, unless userOverrideFormatting or it's a paste event
|
|
830
|
+
if (this.options.formatAsYouType && !userOverrideFormatting && e.inputType !== "insertFromPaste") {
|
|
828
831
|
// maintain caret position after reformatting
|
|
829
832
|
const currentCaretPos = this.telInput.selectionStart;
|
|
830
833
|
const valueBeforeCaret = this.telInput.value.substring(0, currentCaretPos);
|
|
@@ -1474,27 +1477,29 @@ class Iti {
|
|
|
1474
1477
|
|
|
1475
1478
|
// update the input placeholder to an example number from the currently selected country
|
|
1476
1479
|
_updatePlaceholder() {
|
|
1480
|
+
const {
|
|
1481
|
+
autoPlaceholder,
|
|
1482
|
+
placeholderNumberType,
|
|
1483
|
+
nationalMode,
|
|
1484
|
+
customPlaceholder
|
|
1485
|
+
} = this.options;
|
|
1477
1486
|
const shouldSetPlaceholder =
|
|
1478
|
-
|
|
1479
|
-
(!this.hadInitialPlaceholder &&
|
|
1480
|
-
|
|
1487
|
+
autoPlaceholder === "aggressive" ||
|
|
1488
|
+
(!this.hadInitialPlaceholder && autoPlaceholder === "polite");
|
|
1489
|
+
|
|
1481
1490
|
if (window.intlTelInputUtils && shouldSetPlaceholder) {
|
|
1482
|
-
const numberType =
|
|
1483
|
-
intlTelInputUtils.numberType[this.options.placeholderNumberType];
|
|
1491
|
+
const numberType = intlTelInputUtils.numberType[placeholderNumberType];
|
|
1484
1492
|
let placeholder = this.selectedCountryData.iso2
|
|
1485
1493
|
? intlTelInputUtils.getExampleNumber(
|
|
1486
1494
|
this.selectedCountryData.iso2,
|
|
1487
|
-
|
|
1495
|
+
nationalMode,
|
|
1488
1496
|
numberType
|
|
1489
1497
|
)
|
|
1490
1498
|
: "";
|
|
1491
1499
|
|
|
1492
1500
|
placeholder = this._beforeSetNumber(placeholder);
|
|
1493
|
-
if (typeof
|
|
1494
|
-
placeholder = this.
|
|
1495
|
-
placeholder,
|
|
1496
|
-
this.selectedCountryData
|
|
1497
|
-
);
|
|
1501
|
+
if (typeof customPlaceholder === "function") {
|
|
1502
|
+
placeholder = customPlaceholder(placeholder, this.selectedCountryData);
|
|
1498
1503
|
}
|
|
1499
1504
|
this.telInput.setAttribute("placeholder", placeholder);
|
|
1500
1505
|
}
|
|
@@ -1750,7 +1755,9 @@ class Iti {
|
|
|
1750
1755
|
if (this.telInput.value) {
|
|
1751
1756
|
this._updateValFromNumber(this.telInput.value);
|
|
1752
1757
|
}
|
|
1753
|
-
this.
|
|
1758
|
+
if (this.selectedCountryData.iso2) {
|
|
1759
|
+
this._updatePlaceholder();
|
|
1760
|
+
}
|
|
1754
1761
|
}
|
|
1755
1762
|
this.resolveUtilsScriptPromise();
|
|
1756
1763
|
}
|