@wizishop/angular-components 14.4.3 → 14.4.4
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/esm2020/lib/directives/keyboard-events/two-digital-decimal-number.directive.mjs +4 -5
- package/fesm2015/wizishop-angular-components.mjs +3 -4
- package/fesm2015/wizishop-angular-components.mjs.map +1 -1
- package/fesm2020/wizishop-angular-components.mjs +3 -4
- package/fesm2020/wizishop-angular-components.mjs.map +1 -1
- package/lib/directives/keyboard-events/two-digital-decimal-number.directive.d.ts +0 -1
- package/package.json +1 -1
- package/wizishop-angular-components-14.4.4.tgz +0 -0
- package/wizishop-angular-components-14.4.3.tgz +0 -0
|
@@ -773,8 +773,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.7", ngImpor
|
|
|
773
773
|
class TwoDigitDecimalNumberDirective {
|
|
774
774
|
constructor(el) {
|
|
775
775
|
this.el = el;
|
|
776
|
-
this.decimalSeparator = ['.', ','];
|
|
777
|
-
this.regex = new RegExp(/^\d+[.,]?\d{0,2}$/g); // user can put . or , char.
|
|
776
|
+
this.decimalSeparator = ['.', ',']; // user can put . or , char.
|
|
778
777
|
// input also cannot start from , or .
|
|
779
778
|
this.specialKeys = ['Backspace', 'Tab', 'End', 'Home', '-', 'ArrowLeft', 'ArrowRight', 'Del', 'Delete'];
|
|
780
779
|
}
|
|
@@ -785,8 +784,8 @@ class TwoDigitDecimalNumberDirective {
|
|
|
785
784
|
const current = this.el.nativeElement.value;
|
|
786
785
|
const position = this.el.nativeElement.selectionStart;
|
|
787
786
|
const next = [current.slice(0, position), event.key == 'Decimal' ? '.' : event.key, current.slice(position)].join('');
|
|
788
|
-
const regex = new RegExp(
|
|
789
|
-
if (next && !
|
|
787
|
+
const regex = new RegExp(`^\\d+[${this.decimalSeparator.join('')}]?\\d{0,2}$`, 'g');
|
|
788
|
+
if (next && !regex.test(next)) {
|
|
790
789
|
event.preventDefault();
|
|
791
790
|
}
|
|
792
791
|
}
|