@ibragim-dev-org/ui-forge-library 1.2.1 → 1.2.2
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.
|
@@ -3014,15 +3014,15 @@ class UIInputDateDirective extends UiInputDirective {
|
|
|
3014
3014
|
const end = inputElement.selectionEnd;
|
|
3015
3015
|
const oldValue = value;
|
|
3016
3016
|
const newValue = this.maskDate(oldValue);
|
|
3017
|
-
const
|
|
3018
|
-
const
|
|
3019
|
-
const
|
|
3020
|
-
const
|
|
3021
|
-
const
|
|
3022
|
-
const
|
|
3017
|
+
const pattern = this.$dividePattern();
|
|
3018
|
+
const escapedPattern = pattern.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
3019
|
+
const patternRegex = new RegExp(escapedPattern, 'g');
|
|
3020
|
+
const oldPatternCount = (oldValue.match(patternRegex) || []).length;
|
|
3021
|
+
const newPatternCount = (newValue.match(patternRegex) || []).length;
|
|
3022
|
+
const patternAdded = newPatternCount > oldPatternCount;
|
|
3023
3023
|
super.onInput(newValue);
|
|
3024
3024
|
inputElement.value = newValue;
|
|
3025
|
-
if (
|
|
3025
|
+
if (patternAdded) {
|
|
3026
3026
|
inputElement.setSelectionRange(newValue.length, newValue.length);
|
|
3027
3027
|
}
|
|
3028
3028
|
else {
|
|
@@ -3035,15 +3035,16 @@ class UIInputDateDirective extends UiInputDirective {
|
|
|
3035
3035
|
const limit = this.$isRangeSelection() ? 16 : 8;
|
|
3036
3036
|
const limited = digits.substring(0, limit);
|
|
3037
3037
|
const formatSingle = (str) => {
|
|
3038
|
+
const pattern = this.$dividePattern();
|
|
3038
3039
|
let res = '';
|
|
3039
3040
|
if (str.length > 0) {
|
|
3040
3041
|
res += str.substring(0, 2);
|
|
3041
3042
|
}
|
|
3042
3043
|
if (str.length >= 3) {
|
|
3043
|
-
res +=
|
|
3044
|
+
res += pattern + str.substring(2, 4);
|
|
3044
3045
|
}
|
|
3045
3046
|
if (str.length >= 5) {
|
|
3046
|
-
res +=
|
|
3047
|
+
res += pattern + str.substring(4, 8);
|
|
3047
3048
|
}
|
|
3048
3049
|
return res;
|
|
3049
3050
|
};
|