@sumaris-net/ngx-components 1.6.13 → 1.6.17

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.
@@ -7473,14 +7473,74 @@ MaterialChipsModule.decorators = [
7473
7473
  class MatBadgeIconDirective {
7474
7474
  constructor(el) {
7475
7475
  this.el = el;
7476
+ this._subscription = null;
7477
+ this._$update = new Subject();
7478
+ }
7479
+ set size(value) {
7480
+ if (this._size !== value) {
7481
+ this._size = value;
7482
+ this.updateView();
7483
+ }
7484
+ }
7485
+ get size() {
7486
+ return this._size;
7487
+ }
7488
+ set color(value) {
7489
+ if (this._color !== value) {
7490
+ this._color = value;
7491
+ this.updateView();
7492
+ }
7493
+ }
7494
+ get color() {
7495
+ return this._color;
7496
+ }
7497
+ set fill(value) {
7498
+ if (this._fill !== value) {
7499
+ this._fill = value;
7500
+ this.updateView();
7501
+ }
7502
+ }
7503
+ get fill() {
7504
+ return this._fill;
7505
+ }
7506
+ set matIcon(icon) {
7507
+ if (this._matIcon !== icon) {
7508
+ this._matIcon = icon;
7509
+ this.updateView();
7510
+ }
7511
+ }
7512
+ set ionIcon(icon) {
7513
+ if (this._ionIcon !== icon) {
7514
+ this._ionIcon = icon;
7515
+ this.updateView();
7516
+ }
7476
7517
  }
7477
7518
  ngOnInit() {
7478
- this.size = this.size || 'medium';
7479
- this.color = this.color || 'primary';
7480
- if (this.color === 'warn')
7481
- this.color = 'warning';
7519
+ // Default value
7520
+ this._size = this._size || 'medium';
7521
+ this._color = this._color || 'primary';
7522
+ if (this._color === 'warn')
7523
+ this._color = 'warning';
7524
+ this.updateView(true);
7525
+ this._subscription = this._$update
7526
+ .pipe(debounceTime(100))
7527
+ .subscribe(() => this.updateView(true));
7528
+ }
7529
+ ngOnDestroy() {
7530
+ var _a;
7531
+ (_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
7532
+ }
7533
+ updateView(immediate) {
7534
+ // Async by default
7535
+ if (!immediate) {
7536
+ this._$update.next();
7537
+ return;
7538
+ }
7539
+ const badge = this.el.nativeElement.querySelector('.mat-badge-content');
7540
+ if (!badge)
7541
+ return;
7482
7542
  let fontSize;
7483
- switch (this.size) {
7543
+ switch (this._size) {
7484
7544
  case 'large':
7485
7545
  fontSize = '24px';
7486
7546
  break;
@@ -7491,26 +7551,34 @@ class MatBadgeIconDirective {
7491
7551
  fontSize = '16px';
7492
7552
  break;
7493
7553
  }
7494
- const badge = this.el.nativeElement.querySelector('.mat-badge-content');
7495
- badge.style.display = 'flex';
7496
- badge.style.alignItems = 'center';
7497
- badge.style.justifyContent = 'center';
7554
+ let html = '';
7555
+ if (this._matIcon) {
7556
+ html = `<i class="material-icons" style="font-size: ${fontSize};">${this._matIcon}</i>`;
7557
+ }
7558
+ else if (this._ionIcon) {
7559
+ html = `<ion-icon style="font-size: ${fontSize}; pointer-events: none;" name="${this._ionIcon}"></ion-icon>`;
7560
+ }
7561
+ if (this._html !== html) {
7562
+ this._html = html;
7563
+ badge.innerHTML = html;
7564
+ }
7565
+ // Update style
7498
7566
  // fill: 'clear'
7499
- if (this.fill === 'clear') {
7500
- badge.style.color = `var(--ion-color-${this.color})`;
7567
+ if (this._fill === 'clear') {
7568
+ badge.style.color = `var(--ion-color-${this._color})`;
7501
7569
  badge.style.background = 'transparent';
7502
7570
  }
7503
7571
  // fill: 'solid' (default value)
7504
7572
  else {
7505
- badge.style.background = `var(--ion-color-${this.color})`;
7506
- badge.style.color = `var(--ion-color-${this.color}-contrast)`;
7507
- }
7508
- if (this.matIcon) {
7509
- badge.innerHTML = `<i class="material-icons" style="font-size: ${fontSize};">${this.matIcon}</i>`;
7510
- }
7511
- else if (this.ionIcon) {
7512
- badge.innerHTML = `<ion-icon style="font-size: ${fontSize}; pointer-events: none;" name="${this.ionIcon}"></ion-icon>`;
7573
+ badge.style.background = `var(--ion-color-${this._color})`;
7574
+ badge.style.color = `var(--ion-color-${this._color}-contrast)`;
7513
7575
  }
7576
+ if (badge.style.display !== 'inline-block')
7577
+ badge.style.display = 'inline-block';
7578
+ if (badge.style.alignItems !== 'center')
7579
+ badge.style.alignItems = 'center';
7580
+ if (badge.style.justifyContent !== 'center')
7581
+ badge.style.justifyContent = 'center';
7514
7582
  }
7515
7583
  }
7516
7584
  MatBadgeIconDirective.decorators = [
@@ -7527,6 +7595,9 @@ MatBadgeIconDirective.ctorParameters = () => [
7527
7595
  { type: ElementRef }
7528
7596
  ];
7529
7597
  MatBadgeIconDirective.propDecorators = {
7598
+ size: [{ type: Input, args: ['matBadgeSize',] }],
7599
+ color: [{ type: Input, args: ['matBadgeColor',] }],
7600
+ fill: [{ type: Input, args: ['matBadgeFill',] }],
7530
7601
  matIcon: [{ type: Input, args: ['matBadgeIcon',] }],
7531
7602
  ionIcon: [{ type: Input, args: ['ionBadgeIcon',] }]
7532
7603
  };
@@ -17061,11 +17132,17 @@ ChipsTestPage.ctorParameters = () => [
17061
17132
  ];
17062
17133
 
17063
17134
  class MatBadgeIconTestPage {
17135
+ constructor() {
17136
+ this.$icon = new BehaviorSubject('alert');
17137
+ this.$size = new BehaviorSubject('small');
17138
+ this.$fill = new BehaviorSubject('solid');
17139
+ this.$color = new BehaviorSubject('danger');
17140
+ }
17064
17141
  }
17065
17142
  MatBadgeIconTestPage.decorators = [
17066
17143
  { type: Component, args: [{
17067
17144
  selector: 'mat-badge-icon-test',
17068
- template: "\n<ion-header>\n <ion-toolbar color=\"primary\">\n\n <ion-buttons slot=\"start\">\n <ion-back-button></ion-back-button>\n </ion-buttons>\n\n <ion-title>matBadgeIcon directive</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content class=\"ion-padding\">\n\n <!-- small badge -->\n <p>\n <ion-text color=\"tertiary\">\n <span matBadge matIcon=\"check\"\n matBadgeSize=\"small\"\n matBadgeColor=\"accent\"\n matBadgeOverlap=\"false\">Small badge</span>\n </ion-text>\n </p>\n\n <!-- medium badge -->\n <p>\n <ion-text matBadge matBadgeIcon=\"check\"\n matBadgeSize=\"medium\"\n matBadgeColor=\"tertiary\"\n matBadgeOverlap=\"false\"\n >Medium badge</ion-text>\n </p>\n\n <!-- small badge -->\n <p>\n <ion-label matBadge matBadgeIcon=\"close\" matBadgeSize=\"large\"\n matBadgeOverlap=\"false\">Large badge</ion-label>\n </p>\n\n <!-- default size badge -->\n <p>\n <ion-label matBadge matBadgeIcon=\"check\" matBadgeColor=\"success\"\n matBadgeOverlap=\"false\">Badge (no size, no color)\n </ion-label>\n </p>\n\n <!-- ion icon -->\n <p>\n <ion-label matBadge\n ionBadgeIcon=\"checkmark\"\n matBadgeColor=\"success\"\n matBadgeOverlap=\"false\">Badge with ion-icon\n </ion-label>\n </p>\n\n <!-- ion icon clear -->\n <p>\n <ion-label matBadge\n ionBadgeIcon=\"checkmark-circle\"\n matBadgeColor=\"tertiary\"\n matBadgeFill=\"clear\"\n matBadgeOverlap=\"false\">Badge with clear icon\n </ion-label>\n </p>\n\n\n</ion-content>\n"
17145
+ template: "\n<ion-header>\n <ion-toolbar color=\"primary\">\n\n <ion-buttons slot=\"start\">\n <ion-back-button></ion-back-button>\n </ion-buttons>\n\n <ion-title>matBadgeIcon directive</ion-title>\n </ion-toolbar>\n</ion-header>\n\n<ion-content class=\"ion-padding\">\n\n <!-- small badge -->\n <p>\n <ion-text color=\"tertiary\">\n <span matBadge matIcon=\"check\"\n matBadgeSize=\"small\"\n matBadgeColor=\"accent\"\n matBadgeOverlap=\"false\">Small badge</span>\n </ion-text>\n </p>\n\n <!-- medium badge -->\n <p>\n <ion-text matBadge matBadgeIcon=\"check\"\n matBadgeSize=\"medium\"\n matBadgeColor=\"tertiary\"\n matBadgeOverlap=\"false\"\n >Medium badge</ion-text>\n </p>\n\n <!-- small badge -->\n <p>\n <ion-label matBadge matBadgeIcon=\"close\" matBadgeSize=\"large\"\n matBadgeOverlap=\"false\">Large badge</ion-label>\n </p>\n\n <!-- default size badge -->\n <p>\n <ion-label matBadge matBadgeIcon=\"check\" matBadgeColor=\"success\"\n matBadgeOverlap=\"false\">Badge (no size, no color)\n </ion-label>\n </p>\n\n <!-- ion icon -->\n <p>\n <ion-label matBadge\n ionBadgeIcon=\"checkmark\"\n matBadgeColor=\"success\"\n matBadgeOverlap=\"false\">Badge with ion-icon\n </ion-label>\n </p>\n\n <!-- ion icon clear -->\n <p>\n <ion-label matBadge\n ionBadgeIcon=\"checkmark-circle\"\n matBadgeColor=\"tertiary\"\n matBadgeFill=\"clear\"\n matBadgeOverlap=\"false\">Badge with clear icon\n </ion-label>\n </p>\n\n <ion-row class=\"ion-no-padding\">\n <ion-col>\n <mat-icon [style.color]=\"'var(--ion-color-secondary)'\"\n matBadge\n [ionBadgeIcon]=\"$icon|async\"\n [matBadgeColor]=\"$color|async\"\n [matBadgeFill]=\"$fill|async\"\n [matBadgeSize]=\"$size|async\"\n matBadgeOverlap=\"false\">\n <ion-icon slot=\"icon-only\"\n [color]=\"'secondary'\"\n name=\"navigate\"\n ></ion-icon>\n </mat-icon>\n </ion-col>\n\n <ion-col>\n <mat-form-field>\n <mat-select placeholder=\"matBadgeColor\"\n [value]=\"$color.value\"\n (selectionChange)=\"this.$color.next($event.value)\">\n <mat-option [value]=\"'primary'\">primary</mat-option>\n <mat-option [value]=\"'secondary'\">secondary</mat-option>\n <mat-option [value]=\"'tertiary'\">tertiary</mat-option>\n <mat-option [value]=\"'danger'\">danger</mat-option>\n </mat-select>\n </mat-form-field>\n </ion-col>\n\n <ion-col>\n <mat-form-field>\n <mat-select placeholder=\"ionBadgeIcon\"\n [value]=\"$icon.value\"\n (selectionChange)=\"this.$icon.next($event.value)\">\n <mat-option [value]=\"'checkmark-circle'\">checkmark-circle</mat-option>\n <mat-option [value]=\"'alert-circle'\">alert-circle</mat-option>\n <mat-option [value]=\"'alert'\">alert</mat-option>\n <mat-option [value]=\"'flag'\">flag</mat-option>\n </mat-select>\n </mat-form-field>\n </ion-col>\n\n <ion-col>\n <mat-form-field>\n <mat-select placeholder=\"matBadgeSize\"\n [value]=\"$size.value\"\n (selectionChange)=\"this.$size.next($event.value)\">\n <mat-option [value]=\"'large'\">large</mat-option>\n <mat-option [value]=\"'medium'\">medium</mat-option>\n <mat-option [value]=\"'small'\">small</mat-option>\n </mat-select>\n </mat-form-field>\n </ion-col>\n\n <ion-col>\n <mat-form-field>\n <mat-select placeholder=\"matBadgeFill\"\n [value]=\"$fill.value\"\n (selectionChange)=\"this.$fill.next($event.value)\">\n <mat-option [value]=\"'clear'\">clear</mat-option>\n <mat-option [value]=\"'solid'\">solid</mat-option>\n </mat-select>\n </mat-form-field>\n </ion-col>\n </ion-row>\n\n</ion-content>\n"
17069
17146
  },] }
17070
17147
  ];
17071
17148