@rxap/material-table-system 13.0.2 → 13.1.0

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.
@@ -5,7 +5,7 @@ import * as i1 from '@angular/cdk/portal';
5
5
  import { TemplatePortal, PortalModule } from '@angular/cdk/portal';
6
6
  import { Required, clone, DeleteEmptyProperties, equals, coerceBoolean, coerceArray } from '@rxap/utilities';
7
7
  import { trigger, state, style, transition, animate, sequence } from '@angular/animations';
8
- import { BehaviorSubject, EMPTY, ReplaySubject, Subscription, Subject, isObservable, of } from 'rxjs';
8
+ import { BehaviorSubject, Subject, EMPTY, ReplaySubject, Subscription, isObservable, of } from 'rxjs';
9
9
  import { map, filter, tap, distinctUntilChanged, debounceTime, delay, startWith } from 'rxjs/operators';
10
10
  import * as i2 from '@angular/common';
11
11
  import { CommonModule } from '@angular/common';
@@ -13,7 +13,6 @@ import * as i2$1 from '@angular/material/button';
13
13
  import { MatButtonModule, MatButton } from '@angular/material/button';
14
14
  import * as i1$1 from '@angular/material/icon';
15
15
  import { MatIconModule } from '@angular/material/icon';
16
- import { SelectionModel } from '@angular/cdk/collections';
17
16
  import * as i1$2 from '@angular/material/checkbox';
18
17
  import { MatCheckboxModule } from '@angular/material/checkbox';
19
18
  import * as i4 from '@angular/cdk/table';
@@ -294,13 +293,227 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImpor
294
293
 
295
294
  const RXAP_MATERIAL_TABLE_SYSTEM_SELECT_ROW_OPTIONS = new InjectionToken('rxap-material/table-system/select-row/options');
296
295
 
296
+ /**
297
+ * @license
298
+ * Copyright Google LLC All Rights Reserved.
299
+ *
300
+ * Use of this source code is governed by an MIT-style license that can be
301
+ * found in the LICENSE file at https://angular.io/license
302
+ */
303
+ /**
304
+ * Class to be used to power selecting one or more options from a list.
305
+ */
306
+ class SelectionModel {
307
+ constructor(_multiple = false, initiallySelectedValues, _emitChanges = true, compareWith) {
308
+ this._multiple = _multiple;
309
+ this._emitChanges = _emitChanges;
310
+ this.compareWith = compareWith;
311
+ /** Currently-selected values. */
312
+ this._selection = new Set();
313
+ /** Keeps track of the deselected options that haven't been emitted by the change event. */
314
+ this._deselectedToEmit = [];
315
+ /** Keeps track of the selected options that haven't been emitted by the change event. */
316
+ this._selectedToEmit = [];
317
+ /** Cache for the array value of the selected items. */
318
+ this._selected = null;
319
+ /** Event emitted when the value has changed. */
320
+ this.changed = new Subject();
321
+ if (initiallySelectedValues && initiallySelectedValues.length) {
322
+ if (_multiple) {
323
+ initiallySelectedValues.forEach(value => this._markSelected(value));
324
+ }
325
+ else {
326
+ this._markSelected(initiallySelectedValues[0]);
327
+ }
328
+ // Clear the array in order to avoid firing the change event for preselected values.
329
+ this._selectedToEmit.length = 0;
330
+ }
331
+ }
332
+ /** Selected values. */
333
+ get selected() {
334
+ if (!this._selected) {
335
+ this._selected = Array.from(this._selection.values());
336
+ }
337
+ return this._selected;
338
+ }
339
+ /**
340
+ * Selects a value or an array of values.
341
+ * @param values The values to select
342
+ * @return Whether the selection changed as a result of this call
343
+ * @breaking-change 16.0.0 make return type boolean
344
+ */
345
+ select(...values) {
346
+ this._verifyValueAssignment(values);
347
+ values.forEach(value => this._markSelected(value));
348
+ const changed = this._hasQueuedChanges();
349
+ this._emitChangeEvent();
350
+ return changed;
351
+ }
352
+ /**
353
+ * Deselects a value or an array of values.
354
+ * @param values The values to deselect
355
+ * @return Whether the selection changed as a result of this call
356
+ * @breaking-change 16.0.0 make return type boolean
357
+ */
358
+ deselect(...values) {
359
+ this._verifyValueAssignment(values);
360
+ values.forEach(value => this._unmarkSelected(value));
361
+ const changed = this._hasQueuedChanges();
362
+ this._emitChangeEvent();
363
+ return changed;
364
+ }
365
+ /**
366
+ * Sets the selected values
367
+ * @param values The new selected values
368
+ * @return Whether the selection changed as a result of this call
369
+ * @breaking-change 16.0.0 make return type boolean
370
+ */
371
+ setSelection(...values) {
372
+ this._verifyValueAssignment(values);
373
+ const oldValues = this.selected;
374
+ const newSelectedSet = new Set(values);
375
+ values.forEach(value => this._markSelected(value));
376
+ oldValues
377
+ .filter(value => !newSelectedSet.has(value))
378
+ .forEach(value => this._unmarkSelected(value));
379
+ const changed = this._hasQueuedChanges();
380
+ this._emitChangeEvent();
381
+ return changed;
382
+ }
383
+ /**
384
+ * Toggles a value between selected and deselected.
385
+ * @param value The value to toggle
386
+ * @return Whether the selection changed as a result of this call
387
+ * @breaking-change 16.0.0 make return type boolean
388
+ */
389
+ toggle(value) {
390
+ return this.isSelected(value) ? this.deselect(value) : this.select(value);
391
+ }
392
+ /**
393
+ * Clears all of the selected values.
394
+ * @param flushEvent Whether to flush the changes in an event.
395
+ * If false, the changes to the selection will be flushed along with the next event.
396
+ * @return Whether the selection changed as a result of this call
397
+ * @breaking-change 16.0.0 make return type boolean
398
+ */
399
+ clear(flushEvent = true) {
400
+ this._unmarkAll();
401
+ const changed = this._hasQueuedChanges();
402
+ if (flushEvent) {
403
+ this._emitChangeEvent();
404
+ }
405
+ return changed;
406
+ }
407
+ /**
408
+ * Determines whether a value is selected.
409
+ */
410
+ isSelected(value) {
411
+ if (this.compareWith) {
412
+ for (const otherValue of this._selection) {
413
+ if (this.compareWith(otherValue, value)) {
414
+ return true;
415
+ }
416
+ }
417
+ return false;
418
+ }
419
+ return this._selection.has(value);
420
+ }
421
+ /**
422
+ * Determines whether the model does not have a value.
423
+ */
424
+ isEmpty() {
425
+ return this._selection.size === 0;
426
+ }
427
+ /**
428
+ * Determines whether the model has a value.
429
+ */
430
+ hasValue() {
431
+ return !this.isEmpty();
432
+ }
433
+ /**
434
+ * Sorts the selected values based on a predicate function.
435
+ */
436
+ sort(predicate) {
437
+ if (this._multiple && this.selected) {
438
+ this._selected.sort(predicate);
439
+ }
440
+ }
441
+ /**
442
+ * Gets whether multiple values can be selected.
443
+ */
444
+ isMultipleSelection() {
445
+ return this._multiple;
446
+ }
447
+ /** Emits a change event and clears the records of selected and deselected values. */
448
+ _emitChangeEvent() {
449
+ // Clear the selected values so they can be re-cached.
450
+ this._selected = null;
451
+ if (this._selectedToEmit.length || this._deselectedToEmit.length) {
452
+ this.changed.next({
453
+ source: this,
454
+ added: this._selectedToEmit,
455
+ removed: this._deselectedToEmit,
456
+ });
457
+ this._deselectedToEmit = [];
458
+ this._selectedToEmit = [];
459
+ }
460
+ }
461
+ /** Selects a value. */
462
+ _markSelected(value) {
463
+ if (!this.isSelected(value)) {
464
+ if (!this._multiple) {
465
+ this._unmarkAll();
466
+ }
467
+ if (!this.isSelected(value)) {
468
+ this._selection.add(value);
469
+ }
470
+ if (this._emitChanges) {
471
+ this._selectedToEmit.push(value);
472
+ }
473
+ }
474
+ }
475
+ /** Deselects a value. */
476
+ _unmarkSelected(value) {
477
+ if (this.isSelected(value)) {
478
+ this._selection.delete(value);
479
+ if (this._emitChanges) {
480
+ this._deselectedToEmit.push(value);
481
+ }
482
+ }
483
+ }
484
+ /** Clears out the selected values. */
485
+ _unmarkAll() {
486
+ if (!this.isEmpty()) {
487
+ this._selection.forEach(value => this._unmarkSelected(value));
488
+ }
489
+ }
490
+ /**
491
+ * Verifies the value assignment and throws an error if the specified value array is
492
+ * including multiple values while the selection model is not supporting multiple values.
493
+ */
494
+ _verifyValueAssignment(values) {
495
+ if (values.length > 1 && !this._multiple && (typeof ngDevMode === 'undefined' || ngDevMode)) {
496
+ throw getMultipleValuesInSingleSelectionError();
497
+ }
498
+ }
499
+ /** Whether there are queued up change to be emitted. */
500
+ _hasQueuedChanges() {
501
+ return !!(this._deselectedToEmit.length || this._selectedToEmit.length);
502
+ }
503
+ }
504
+ /**
505
+ * Returns an error that reports that multiple values are passed into a selection model
506
+ * with a single value.
507
+ * @docs-private
508
+ */
509
+ function getMultipleValuesInSingleSelectionError() {
510
+ return Error('Cannot pass multiple values into SelectionModel with single-value mode.');
511
+ }
512
+
297
513
  class SelectRowService {
298
514
  constructor(options = null) {
299
515
  this.selectionModel = new SelectionModel(true);
300
- this.selectionModel = new SelectionModel(options === null || options === void 0 ? void 0 : options.multiple);
301
- if (options === null || options === void 0 ? void 0 : options.selected) {
302
- this.selectionModel.select(...options === null || options === void 0 ? void 0 : options.selected);
303
- }
516
+ this.selectionModel = new SelectionModel(options === null || options === void 0 ? void 0 : options.multiple, options === null || options === void 0 ? void 0 : options.selected, options === null || options === void 0 ? void 0 : options.emitChanges, options === null || options === void 0 ? void 0 : options.compareWith);
304
517
  this.selectedRows$ = this.selectionModel.changed.pipe(map(() => this.selectionModel.selected));
305
518
  }
306
519
  get selectedRows() {
@@ -1029,10 +1242,10 @@ class TableShowArchivedSlideComponent {
1029
1242
  }
1030
1243
  }
1031
1244
  TableShowArchivedSlideComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: TableShowArchivedSlideComponent, deps: [{ token: TableFilterService }, { token: TableColumnMenuComponent }], target: i0.ɵɵFactoryTarget.Component });
1032
- TableShowArchivedSlideComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.3", type: TableShowArchivedSlideComponent, selector: "mfd-table-show-archived-slide", host: { classAttribute: "mfd-table-show-archived-slide" }, ngImport: i0, template: "<div rxapStopPropagation>\n <mat-slide-toggle (change)=\"onChange($event)\" i18n=\"@@rxap.material.table-system.table-column-menu.table-show-archived-slide\">\n Show archived documents\n </mat-slide-toggle>\n</div>\n", styles: [""], components: [{ type: i3$1.MatSlideToggle, selector: "mat-slide-toggle", inputs: ["disabled", "disableRipple", "color", "tabIndex", "name", "id", "labelPosition", "aria-label", "aria-labelledby", "aria-describedby", "required", "checked"], outputs: ["change", "toggleChange"], exportAs: ["matSlideToggle"] }], directives: [{ type: i6.StopPropagationDirective, selector: "[rxapStopPropagation]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1245
+ TableShowArchivedSlideComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.3", type: TableShowArchivedSlideComponent, selector: "mfd-table-show-archived-slide", host: { classAttribute: "mfd-table-show-archived-slide" }, ngImport: i0, template: "<div rxapStopPropagation>\n <mat-slide-toggle (change)=\"onChange($event)\">\n <ng-container i18n>Show archived documents</ng-container>\n </mat-slide-toggle>\n</div>\n", styles: [""], components: [{ type: i3$1.MatSlideToggle, selector: "mat-slide-toggle", inputs: ["disabled", "disableRipple", "color", "tabIndex", "name", "id", "labelPosition", "aria-label", "aria-labelledby", "aria-describedby", "required", "checked"], outputs: ["change", "toggleChange"], exportAs: ["matSlideToggle"] }], directives: [{ type: i6.StopPropagationDirective, selector: "[rxapStopPropagation]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1033
1246
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: TableShowArchivedSlideComponent, decorators: [{
1034
1247
  type: Component,
1035
- args: [{ selector: 'mfd-table-show-archived-slide', changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'mfd-table-show-archived-slide' }, template: "<div rxapStopPropagation>\n <mat-slide-toggle (change)=\"onChange($event)\" i18n=\"@@rxap.material.table-system.table-column-menu.table-show-archived-slide\">\n Show archived documents\n </mat-slide-toggle>\n</div>\n", styles: [""] }]
1248
+ args: [{ selector: 'mfd-table-show-archived-slide', changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'mfd-table-show-archived-slide' }, template: "<div rxapStopPropagation>\n <mat-slide-toggle (change)=\"onChange($event)\">\n <ng-container i18n>Show archived documents</ng-container>\n </mat-slide-toggle>\n</div>\n", styles: [""] }]
1036
1249
  }], ctorParameters: function () { return [{ type: TableFilterService }, { type: TableColumnMenuComponent }]; } });
1037
1250
 
1038
1251
  class TableShowArchivedSlideComponentModule {
@@ -1438,10 +1651,10 @@ class TableSelectControlsComponent {
1438
1651
  }
1439
1652
  }
1440
1653
  TableSelectControlsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: TableSelectControlsComponent, deps: [{ token: SelectRowService }, { token: RXAP_WINDOW_REF }], target: i0.ɵɵFactoryTarget.Component });
1441
- TableSelectControlsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.3", type: TableSelectControlsComponent, selector: "mfd-table-select-controls", host: { classAttribute: "mfd-table-select-controls" }, ngImport: i0, template: "<div fxLayout=\"row\" fxLayoutGap=\"16px\">\n <button fxFlex=\"nogrow\" mat-stroked-button (click)=\"cancel()\" type=\"button\"\n i18n=\"@@rxap-material.table-system.table-select-controls.cancel\">Cancel\n </button>\n <button fxFlex=\"nogrow\" mat-raised-button (click)=\"select()\" type=\"button\" [disabled]=\"hasNotSelected$ | async\"\n i18n=\"@@rxap-material.table-system.table-select-controls.select\">Select\n </button>\n</div>\n", styles: [""], components: [{ type: i2$1.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i4$1.DefaultLayoutDirective, selector: " [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md], [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md], [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm], [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { type: i4$1.DefaultLayoutGapDirective, selector: " [fxLayoutGap], [fxLayoutGap.xs], [fxLayoutGap.sm], [fxLayoutGap.md], [fxLayoutGap.lg], [fxLayoutGap.xl], [fxLayoutGap.lt-sm], [fxLayoutGap.lt-md], [fxLayoutGap.lt-lg], [fxLayoutGap.lt-xl], [fxLayoutGap.gt-xs], [fxLayoutGap.gt-sm], [fxLayoutGap.gt-md], [fxLayoutGap.gt-lg]", inputs: ["fxLayoutGap", "fxLayoutGap.xs", "fxLayoutGap.sm", "fxLayoutGap.md", "fxLayoutGap.lg", "fxLayoutGap.xl", "fxLayoutGap.lt-sm", "fxLayoutGap.lt-md", "fxLayoutGap.lt-lg", "fxLayoutGap.lt-xl", "fxLayoutGap.gt-xs", "fxLayoutGap.gt-sm", "fxLayoutGap.gt-md", "fxLayoutGap.gt-lg"] }, { type: i4$1.DefaultFlexDirective, selector: " [fxFlex], [fxFlex.xs], [fxFlex.sm], [fxFlex.md], [fxFlex.lg], [fxFlex.xl], [fxFlex.lt-sm], [fxFlex.lt-md], [fxFlex.lt-lg], [fxFlex.lt-xl], [fxFlex.gt-xs], [fxFlex.gt-sm], [fxFlex.gt-md], [fxFlex.gt-lg]", inputs: ["fxFlex", "fxFlex.xs", "fxFlex.sm", "fxFlex.md", "fxFlex.lg", "fxFlex.xl", "fxFlex.lt-sm", "fxFlex.lt-md", "fxFlex.lt-lg", "fxFlex.lt-xl", "fxFlex.gt-xs", "fxFlex.gt-sm", "fxFlex.gt-md", "fxFlex.gt-lg"] }], pipes: { "async": i2.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
1654
+ TableSelectControlsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.3", type: TableSelectControlsComponent, selector: "mfd-table-select-controls", host: { classAttribute: "mfd-table-select-controls" }, ngImport: i0, template: "<div fxLayout=\"row\" fxLayoutGap=\"16px\">\n <button fxFlex=\"nogrow\" mat-stroked-button (click)=\"cancel()\" type=\"button\">\n <ng-container i18n>Cancel</ng-container>\n </button>\n <button fxFlex=\"nogrow\" mat-raised-button (click)=\"select()\" type=\"button\" [disabled]=\"hasNotSelected$ | async\">\n <ng-container i18n>Select</ng-container>\n </button>\n</div>\n", styles: [""], components: [{ type: i2$1.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i4$1.DefaultLayoutDirective, selector: " [fxLayout], [fxLayout.xs], [fxLayout.sm], [fxLayout.md], [fxLayout.lg], [fxLayout.xl], [fxLayout.lt-sm], [fxLayout.lt-md], [fxLayout.lt-lg], [fxLayout.lt-xl], [fxLayout.gt-xs], [fxLayout.gt-sm], [fxLayout.gt-md], [fxLayout.gt-lg]", inputs: ["fxLayout", "fxLayout.xs", "fxLayout.sm", "fxLayout.md", "fxLayout.lg", "fxLayout.xl", "fxLayout.lt-sm", "fxLayout.lt-md", "fxLayout.lt-lg", "fxLayout.lt-xl", "fxLayout.gt-xs", "fxLayout.gt-sm", "fxLayout.gt-md", "fxLayout.gt-lg"] }, { type: i4$1.DefaultLayoutGapDirective, selector: " [fxLayoutGap], [fxLayoutGap.xs], [fxLayoutGap.sm], [fxLayoutGap.md], [fxLayoutGap.lg], [fxLayoutGap.xl], [fxLayoutGap.lt-sm], [fxLayoutGap.lt-md], [fxLayoutGap.lt-lg], [fxLayoutGap.lt-xl], [fxLayoutGap.gt-xs], [fxLayoutGap.gt-sm], [fxLayoutGap.gt-md], [fxLayoutGap.gt-lg]", inputs: ["fxLayoutGap", "fxLayoutGap.xs", "fxLayoutGap.sm", "fxLayoutGap.md", "fxLayoutGap.lg", "fxLayoutGap.xl", "fxLayoutGap.lt-sm", "fxLayoutGap.lt-md", "fxLayoutGap.lt-lg", "fxLayoutGap.lt-xl", "fxLayoutGap.gt-xs", "fxLayoutGap.gt-sm", "fxLayoutGap.gt-md", "fxLayoutGap.gt-lg"] }, { type: i4$1.DefaultFlexDirective, selector: " [fxFlex], [fxFlex.xs], [fxFlex.sm], [fxFlex.md], [fxFlex.lg], [fxFlex.xl], [fxFlex.lt-sm], [fxFlex.lt-md], [fxFlex.lt-lg], [fxFlex.lt-xl], [fxFlex.gt-xs], [fxFlex.gt-sm], [fxFlex.gt-md], [fxFlex.gt-lg]", inputs: ["fxFlex", "fxFlex.xs", "fxFlex.sm", "fxFlex.md", "fxFlex.lg", "fxFlex.xl", "fxFlex.lt-sm", "fxFlex.lt-md", "fxFlex.lt-lg", "fxFlex.lt-xl", "fxFlex.gt-xs", "fxFlex.gt-sm", "fxFlex.gt-md", "fxFlex.gt-lg"] }], pipes: { "async": i2.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
1442
1655
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: TableSelectControlsComponent, decorators: [{
1443
1656
  type: Component,
1444
- args: [{ selector: 'mfd-table-select-controls', changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'mfd-table-select-controls' }, template: "<div fxLayout=\"row\" fxLayoutGap=\"16px\">\n <button fxFlex=\"nogrow\" mat-stroked-button (click)=\"cancel()\" type=\"button\"\n i18n=\"@@rxap-material.table-system.table-select-controls.cancel\">Cancel\n </button>\n <button fxFlex=\"nogrow\" mat-raised-button (click)=\"select()\" type=\"button\" [disabled]=\"hasNotSelected$ | async\"\n i18n=\"@@rxap-material.table-system.table-select-controls.select\">Select\n </button>\n</div>\n", styles: [""] }]
1657
+ args: [{ selector: 'mfd-table-select-controls', changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'mfd-table-select-controls' }, template: "<div fxLayout=\"row\" fxLayoutGap=\"16px\">\n <button fxFlex=\"nogrow\" mat-stroked-button (click)=\"cancel()\" type=\"button\">\n <ng-container i18n>Cancel</ng-container>\n </button>\n <button fxFlex=\"nogrow\" mat-raised-button (click)=\"select()\" type=\"button\" [disabled]=\"hasNotSelected$ | async\">\n <ng-container i18n>Select</ng-container>\n </button>\n</div>\n", styles: [""] }]
1445
1658
  }], ctorParameters: function () {
1446
1659
  return [{ type: SelectRowService }, { type: undefined, decorators: [{
1447
1660
  type: Inject,