@wizishop/angular-components 14.4.2 → 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.
@@ -773,7 +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.regex = new RegExp(/^\d+[.,]?\d{0,2}$/g); // user can put . or , char.
776
+ this.decimalSeparator = ['.', ',']; // user can put . or , char.
777
777
  // input also cannot start from , or .
778
778
  this.specialKeys = ['Backspace', 'Tab', 'End', 'Home', '-', 'ArrowLeft', 'ArrowRight', 'Del', 'Delete'];
779
779
  }
@@ -784,19 +784,22 @@ class TwoDigitDecimalNumberDirective {
784
784
  const current = this.el.nativeElement.value;
785
785
  const position = this.el.nativeElement.selectionStart;
786
786
  const next = [current.slice(0, position), event.key == 'Decimal' ? '.' : event.key, current.slice(position)].join('');
787
- if (next && !String(next).match(this.regex)) {
787
+ const regex = new RegExp(`^\\d+[${this.decimalSeparator.join('')}]?\\d{0,2}$`, 'g');
788
+ if (next && !regex.test(next)) {
788
789
  event.preventDefault();
789
790
  }
790
791
  }
791
792
  }
792
793
  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 });
794
+ 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
795
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.7", ngImport: i0, type: TwoDigitDecimalNumberDirective, decorators: [{
795
796
  type: Directive,
796
797
  args: [{
797
798
  selector: '[wacTwoDigitDecimalNumber]',
798
799
  }]
799
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { onKeyDown: [{
800
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { decimalSeparator: [{
801
+ type: Input
802
+ }], onKeyDown: [{
800
803
  type: HostListener,
801
804
  args: ['keydown', ['$event']]
802
805
  }] } });