@wizishop/angular-components 14.4.2 → 14.4.3
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 +9 -5
- package/fesm2015/wizishop-angular-components.mjs +7 -3
- package/fesm2015/wizishop-angular-components.mjs.map +1 -1
- package/fesm2020/wizishop-angular-components.mjs +7 -3
- package/fesm2020/wizishop-angular-components.mjs.map +1 -1
- package/lib/directives/keyboard-events/two-digital-decimal-number.directive.d.ts +2 -1
- package/package.json +1 -1
- package/wizishop-angular-components-14.4.3.tgz +0 -0
- package/wizishop-angular-components-14.4.2.tgz +0 -0
|
@@ -773,6 +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 = ['.', ','];
|
|
776
777
|
this.regex = new RegExp(/^\d+[.,]?\d{0,2}$/g); // user can put . or , char.
|
|
777
778
|
// input also cannot start from , or .
|
|
778
779
|
this.specialKeys = ['Backspace', 'Tab', 'End', 'Home', '-', 'ArrowLeft', 'ArrowRight', 'Del', 'Delete'];
|
|
@@ -784,19 +785,22 @@ class TwoDigitDecimalNumberDirective {
|
|
|
784
785
|
const current = this.el.nativeElement.value;
|
|
785
786
|
const position = this.el.nativeElement.selectionStart;
|
|
786
787
|
const next = [current.slice(0, position), event.key == 'Decimal' ? '.' : event.key, current.slice(position)].join('');
|
|
787
|
-
|
|
788
|
+
const regex = new RegExp(`^\d+[${this.decimalSeparator.join('')}]?\d{0,2}$`, 'g');
|
|
789
|
+
if (next && !String(next).match(regex)) {
|
|
788
790
|
event.preventDefault();
|
|
789
791
|
}
|
|
790
792
|
}
|
|
791
793
|
}
|
|
792
794
|
TwoDigitDecimalNumberDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.7", ngImport: i0, type: TwoDigitDecimalNumberDirective, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Directive });
|
|
793
|
-
TwoDigitDecimalNumberDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.7", type: TwoDigitDecimalNumberDirective, selector: "[wacTwoDigitDecimalNumber]", host: { listeners: { "keydown": "onKeyDown($event)" } }, ngImport: i0 });
|
|
795
|
+
TwoDigitDecimalNumberDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.7", type: TwoDigitDecimalNumberDirective, selector: "[wacTwoDigitDecimalNumber]", inputs: { decimalSeparator: "decimalSeparator" }, host: { listeners: { "keydown": "onKeyDown($event)" } }, ngImport: i0 });
|
|
794
796
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.7", ngImport: i0, type: TwoDigitDecimalNumberDirective, decorators: [{
|
|
795
797
|
type: Directive,
|
|
796
798
|
args: [{
|
|
797
799
|
selector: '[wacTwoDigitDecimalNumber]',
|
|
798
800
|
}]
|
|
799
|
-
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: {
|
|
801
|
+
}], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { decimalSeparator: [{
|
|
802
|
+
type: Input
|
|
803
|
+
}], onKeyDown: [{
|
|
800
804
|
type: HostListener,
|
|
801
805
|
args: ['keydown', ['$event']]
|
|
802
806
|
}] } });
|