@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.
@@ -8369,14 +8369,95 @@
8369
8369
  var MatBadgeIconDirective = /** @class */ (function () {
8370
8370
  function MatBadgeIconDirective(el) {
8371
8371
  this.el = el;
8372
+ this._subscription = null;
8373
+ this._$update = new rxjs.Subject();
8372
8374
  }
8375
+ Object.defineProperty(MatBadgeIconDirective.prototype, "size", {
8376
+ get: function () {
8377
+ return this._size;
8378
+ },
8379
+ set: function (value) {
8380
+ if (this._size !== value) {
8381
+ this._size = value;
8382
+ this.updateView();
8383
+ }
8384
+ },
8385
+ enumerable: false,
8386
+ configurable: true
8387
+ });
8388
+ Object.defineProperty(MatBadgeIconDirective.prototype, "color", {
8389
+ get: function () {
8390
+ return this._color;
8391
+ },
8392
+ set: function (value) {
8393
+ if (this._color !== value) {
8394
+ this._color = value;
8395
+ this.updateView();
8396
+ }
8397
+ },
8398
+ enumerable: false,
8399
+ configurable: true
8400
+ });
8401
+ Object.defineProperty(MatBadgeIconDirective.prototype, "fill", {
8402
+ get: function () {
8403
+ return this._fill;
8404
+ },
8405
+ set: function (value) {
8406
+ if (this._fill !== value) {
8407
+ this._fill = value;
8408
+ this.updateView();
8409
+ }
8410
+ },
8411
+ enumerable: false,
8412
+ configurable: true
8413
+ });
8414
+ Object.defineProperty(MatBadgeIconDirective.prototype, "matIcon", {
8415
+ set: function (icon) {
8416
+ if (this._matIcon !== icon) {
8417
+ this._matIcon = icon;
8418
+ this.updateView();
8419
+ }
8420
+ },
8421
+ enumerable: false,
8422
+ configurable: true
8423
+ });
8424
+ Object.defineProperty(MatBadgeIconDirective.prototype, "ionIcon", {
8425
+ set: function (icon) {
8426
+ if (this._ionIcon !== icon) {
8427
+ this._ionIcon = icon;
8428
+ this.updateView();
8429
+ }
8430
+ },
8431
+ enumerable: false,
8432
+ configurable: true
8433
+ });
8373
8434
  MatBadgeIconDirective.prototype.ngOnInit = function () {
8374
- this.size = this.size || 'medium';
8375
- this.color = this.color || 'primary';
8376
- if (this.color === 'warn')
8377
- this.color = 'warning';
8435
+ var _this = this;
8436
+ // Default value
8437
+ this._size = this._size || 'medium';
8438
+ this._color = this._color || 'primary';
8439
+ if (this._color === 'warn')
8440
+ this._color = 'warning';
8441
+ this.updateView(true);
8442
+ this._subscription = this._$update
8443
+ .pipe(operators.debounceTime(100))
8444
+ .subscribe(function () { return _this.updateView(true); });
8445
+ };
8446
+ MatBadgeIconDirective.prototype.ngOnDestroy = function () {
8447
+ var _a;
8448
+ (_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
8449
+ };
8450
+ MatBadgeIconDirective.prototype.updateView = function (immediate) {
8451
+ // Async by default
8452
+ if (!immediate) {
8453
+ this._$update.next();
8454
+ return;
8455
+ }
8456
+ var badge = this.el.nativeElement.querySelector('.mat-badge-content');
8457
+ if (!badge)
8458
+ return;
8378
8459
  var fontSize;
8379
- switch (this.size) {
8460
+ switch (this._size) {
8380
8461
  case 'large':
8381
8462
  fontSize = '24px';
8382
8463
  break;
@@ -8387,26 +8468,34 @@
8387
8468
  fontSize = '16px';
8388
8469
  break;
8389
8470
  }
8390
- var badge = this.el.nativeElement.querySelector('.mat-badge-content');
8391
- badge.style.display = 'flex';
8392
- badge.style.alignItems = 'center';
8393
- badge.style.justifyContent = 'center';
8471
+ var html = '';
8472
+ if (this._matIcon) {
8473
+ html = "<i class=\"material-icons\" style=\"font-size: " + fontSize + ";\">" + this._matIcon + "</i>";
8474
+ }
8475
+ else if (this._ionIcon) {
8476
+ html = "<ion-icon style=\"font-size: " + fontSize + "; pointer-events: none;\" name=\"" + this._ionIcon + "\"></ion-icon>";
8477
+ }
8478
+ if (this._html !== html) {
8479
+ this._html = html;
8480
+ badge.innerHTML = html;
8481
+ }
8482
+ // Update style
8394
8483
  // fill: 'clear'
8395
- if (this.fill === 'clear') {
8396
- badge.style.color = "var(--ion-color-" + this.color + ")";
8484
+ if (this._fill === 'clear') {
8485
+ badge.style.color = "var(--ion-color-" + this._color + ")";
8397
8486
  badge.style.background = 'transparent';
8398
8487
  }
8399
8488
  // fill: 'solid' (default value)
8400
8489
  else {
8401
- badge.style.background = "var(--ion-color-" + this.color + ")";
8402
- badge.style.color = "var(--ion-color-" + this.color + "-contrast)";
8403
- }
8404
- if (this.matIcon) {
8405
- badge.innerHTML = "<i class=\"material-icons\" style=\"font-size: " + fontSize + ";\">" + this.matIcon + "</i>";
8406
- }
8407
- else if (this.ionIcon) {
8408
- badge.innerHTML = "<ion-icon style=\"font-size: " + fontSize + "; pointer-events: none;\" name=\"" + this.ionIcon + "\"></ion-icon>";
8490
+ badge.style.background = "var(--ion-color-" + this._color + ")";
8491
+ badge.style.color = "var(--ion-color-" + this._color + "-contrast)";
8409
8492
  }
8493
+ if (badge.style.display !== 'inline-block')
8494
+ badge.style.display = 'inline-block';
8495
+ if (badge.style.alignItems !== 'center')
8496
+ badge.style.alignItems = 'center';
8497
+ if (badge.style.justifyContent !== 'center')
8498
+ badge.style.justifyContent = 'center';
8410
8499
  };
8411
8500
  return MatBadgeIconDirective;
8412
8501
  }());
@@ -8424,6 +8513,9 @@
8424
8513
  { type: i0.ElementRef }
8425
8514
  ]; };
8426
8515
  MatBadgeIconDirective.propDecorators = {
8516
+ size: [{ type: i0.Input, args: ['matBadgeSize',] }],
8517
+ color: [{ type: i0.Input, args: ['matBadgeColor',] }],
8518
+ fill: [{ type: i0.Input, args: ['matBadgeFill',] }],
8427
8519
  matIcon: [{ type: i0.Input, args: ['matBadgeIcon',] }],
8428
8520
  ionIcon: [{ type: i0.Input, args: ['ionBadgeIcon',] }]
8429
8521
  };
@@ -19574,13 +19666,17 @@
19574
19666
 
19575
19667
  var MatBadgeIconTestPage = /** @class */ (function () {
19576
19668
  function MatBadgeIconTestPage() {
19669
+ this.$icon = new rxjs.BehaviorSubject('alert');
19670
+ this.$size = new rxjs.BehaviorSubject('small');
19671
+ this.$fill = new rxjs.BehaviorSubject('solid');
19672
+ this.$color = new rxjs.BehaviorSubject('danger');
19577
19673
  }
19578
19674
  return MatBadgeIconTestPage;
19579
19675
  }());
19580
19676
  MatBadgeIconTestPage.decorators = [
19581
19677
  { type: i0.Component, args: [{
19582
19678
  selector: 'mat-badge-icon-test',
19583
- 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"
19679
+ 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"
19584
19680
  },] }
19585
19681
  ];
19586
19682