@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';
@@ -285,13 +284,227 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImpor
285
284
 
286
285
  const RXAP_MATERIAL_TABLE_SYSTEM_SELECT_ROW_OPTIONS = new InjectionToken('rxap-material/table-system/select-row/options');
287
286
 
287
+ /**
288
+ * @license
289
+ * Copyright Google LLC All Rights Reserved.
290
+ *
291
+ * Use of this source code is governed by an MIT-style license that can be
292
+ * found in the LICENSE file at https://angular.io/license
293
+ */
294
+ /**
295
+ * Class to be used to power selecting one or more options from a list.
296
+ */
297
+ class SelectionModel {
298
+ constructor(_multiple = false, initiallySelectedValues, _emitChanges = true, compareWith) {
299
+ this._multiple = _multiple;
300
+ this._emitChanges = _emitChanges;
301
+ this.compareWith = compareWith;
302
+ /** Currently-selected values. */
303
+ this._selection = new Set();
304
+ /** Keeps track of the deselected options that haven't been emitted by the change event. */
305
+ this._deselectedToEmit = [];
306
+ /** Keeps track of the selected options that haven't been emitted by the change event. */
307
+ this._selectedToEmit = [];
308
+ /** Cache for the array value of the selected items. */
309
+ this._selected = null;
310
+ /** Event emitted when the value has changed. */
311
+ this.changed = new Subject();
312
+ if (initiallySelectedValues && initiallySelectedValues.length) {
313
+ if (_multiple) {
314
+ initiallySelectedValues.forEach(value => this._markSelected(value));
315
+ }
316
+ else {
317
+ this._markSelected(initiallySelectedValues[0]);
318
+ }
319
+ // Clear the array in order to avoid firing the change event for preselected values.
320
+ this._selectedToEmit.length = 0;
321
+ }
322
+ }
323
+ /** Selected values. */
324
+ get selected() {
325
+ if (!this._selected) {
326
+ this._selected = Array.from(this._selection.values());
327
+ }
328
+ return this._selected;
329
+ }
330
+ /**
331
+ * Selects a value or an array of values.
332
+ * @param values The values to select
333
+ * @return Whether the selection changed as a result of this call
334
+ * @breaking-change 16.0.0 make return type boolean
335
+ */
336
+ select(...values) {
337
+ this._verifyValueAssignment(values);
338
+ values.forEach(value => this._markSelected(value));
339
+ const changed = this._hasQueuedChanges();
340
+ this._emitChangeEvent();
341
+ return changed;
342
+ }
343
+ /**
344
+ * Deselects a value or an array of values.
345
+ * @param values The values to deselect
346
+ * @return Whether the selection changed as a result of this call
347
+ * @breaking-change 16.0.0 make return type boolean
348
+ */
349
+ deselect(...values) {
350
+ this._verifyValueAssignment(values);
351
+ values.forEach(value => this._unmarkSelected(value));
352
+ const changed = this._hasQueuedChanges();
353
+ this._emitChangeEvent();
354
+ return changed;
355
+ }
356
+ /**
357
+ * Sets the selected values
358
+ * @param values The new selected values
359
+ * @return Whether the selection changed as a result of this call
360
+ * @breaking-change 16.0.0 make return type boolean
361
+ */
362
+ setSelection(...values) {
363
+ this._verifyValueAssignment(values);
364
+ const oldValues = this.selected;
365
+ const newSelectedSet = new Set(values);
366
+ values.forEach(value => this._markSelected(value));
367
+ oldValues
368
+ .filter(value => !newSelectedSet.has(value))
369
+ .forEach(value => this._unmarkSelected(value));
370
+ const changed = this._hasQueuedChanges();
371
+ this._emitChangeEvent();
372
+ return changed;
373
+ }
374
+ /**
375
+ * Toggles a value between selected and deselected.
376
+ * @param value The value to toggle
377
+ * @return Whether the selection changed as a result of this call
378
+ * @breaking-change 16.0.0 make return type boolean
379
+ */
380
+ toggle(value) {
381
+ return this.isSelected(value) ? this.deselect(value) : this.select(value);
382
+ }
383
+ /**
384
+ * Clears all of the selected values.
385
+ * @param flushEvent Whether to flush the changes in an event.
386
+ * If false, the changes to the selection will be flushed along with the next event.
387
+ * @return Whether the selection changed as a result of this call
388
+ * @breaking-change 16.0.0 make return type boolean
389
+ */
390
+ clear(flushEvent = true) {
391
+ this._unmarkAll();
392
+ const changed = this._hasQueuedChanges();
393
+ if (flushEvent) {
394
+ this._emitChangeEvent();
395
+ }
396
+ return changed;
397
+ }
398
+ /**
399
+ * Determines whether a value is selected.
400
+ */
401
+ isSelected(value) {
402
+ if (this.compareWith) {
403
+ for (const otherValue of this._selection) {
404
+ if (this.compareWith(otherValue, value)) {
405
+ return true;
406
+ }
407
+ }
408
+ return false;
409
+ }
410
+ return this._selection.has(value);
411
+ }
412
+ /**
413
+ * Determines whether the model does not have a value.
414
+ */
415
+ isEmpty() {
416
+ return this._selection.size === 0;
417
+ }
418
+ /**
419
+ * Determines whether the model has a value.
420
+ */
421
+ hasValue() {
422
+ return !this.isEmpty();
423
+ }
424
+ /**
425
+ * Sorts the selected values based on a predicate function.
426
+ */
427
+ sort(predicate) {
428
+ if (this._multiple && this.selected) {
429
+ this._selected.sort(predicate);
430
+ }
431
+ }
432
+ /**
433
+ * Gets whether multiple values can be selected.
434
+ */
435
+ isMultipleSelection() {
436
+ return this._multiple;
437
+ }
438
+ /** Emits a change event and clears the records of selected and deselected values. */
439
+ _emitChangeEvent() {
440
+ // Clear the selected values so they can be re-cached.
441
+ this._selected = null;
442
+ if (this._selectedToEmit.length || this._deselectedToEmit.length) {
443
+ this.changed.next({
444
+ source: this,
445
+ added: this._selectedToEmit,
446
+ removed: this._deselectedToEmit,
447
+ });
448
+ this._deselectedToEmit = [];
449
+ this._selectedToEmit = [];
450
+ }
451
+ }
452
+ /** Selects a value. */
453
+ _markSelected(value) {
454
+ if (!this.isSelected(value)) {
455
+ if (!this._multiple) {
456
+ this._unmarkAll();
457
+ }
458
+ if (!this.isSelected(value)) {
459
+ this._selection.add(value);
460
+ }
461
+ if (this._emitChanges) {
462
+ this._selectedToEmit.push(value);
463
+ }
464
+ }
465
+ }
466
+ /** Deselects a value. */
467
+ _unmarkSelected(value) {
468
+ if (this.isSelected(value)) {
469
+ this._selection.delete(value);
470
+ if (this._emitChanges) {
471
+ this._deselectedToEmit.push(value);
472
+ }
473
+ }
474
+ }
475
+ /** Clears out the selected values. */
476
+ _unmarkAll() {
477
+ if (!this.isEmpty()) {
478
+ this._selection.forEach(value => this._unmarkSelected(value));
479
+ }
480
+ }
481
+ /**
482
+ * Verifies the value assignment and throws an error if the specified value array is
483
+ * including multiple values while the selection model is not supporting multiple values.
484
+ */
485
+ _verifyValueAssignment(values) {
486
+ if (values.length > 1 && !this._multiple && (typeof ngDevMode === 'undefined' || ngDevMode)) {
487
+ throw getMultipleValuesInSingleSelectionError();
488
+ }
489
+ }
490
+ /** Whether there are queued up change to be emitted. */
491
+ _hasQueuedChanges() {
492
+ return !!(this._deselectedToEmit.length || this._selectedToEmit.length);
493
+ }
494
+ }
495
+ /**
496
+ * Returns an error that reports that multiple values are passed into a selection model
497
+ * with a single value.
498
+ * @docs-private
499
+ */
500
+ function getMultipleValuesInSingleSelectionError() {
501
+ return Error('Cannot pass multiple values into SelectionModel with single-value mode.');
502
+ }
503
+
288
504
  class SelectRowService {
289
505
  constructor(options = null) {
290
506
  this.selectionModel = new SelectionModel(true);
291
- this.selectionModel = new SelectionModel(options?.multiple);
292
- if (options?.selected) {
293
- this.selectionModel.select(...options?.selected);
294
- }
507
+ this.selectionModel = new SelectionModel(options?.multiple, options?.selected, options?.emitChanges, options?.compareWith);
295
508
  this.selectedRows$ = this.selectionModel.changed.pipe(map(() => this.selectionModel.selected));
296
509
  }
297
510
  get selectedRows() {
@@ -1002,10 +1215,10 @@ class TableShowArchivedSlideComponent {
1002
1215
  }
1003
1216
  }
1004
1217
  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 });
1005
- 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 });
1218
+ 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 });
1006
1219
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: TableShowArchivedSlideComponent, decorators: [{
1007
1220
  type: Component,
1008
- 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: [""] }]
1221
+ 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: [""] }]
1009
1222
  }], ctorParameters: function () { return [{ type: TableFilterService }, { type: TableColumnMenuComponent }]; } });
1010
1223
 
1011
1224
  class TableShowArchivedSlideComponentModule {
@@ -1375,10 +1588,10 @@ class TableSelectControlsComponent {
1375
1588
  }
1376
1589
  }
1377
1590
  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 });
1378
- 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 });
1591
+ 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 });
1379
1592
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.3", ngImport: i0, type: TableSelectControlsComponent, decorators: [{
1380
1593
  type: Component,
1381
- 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: [""] }]
1594
+ 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: [""] }]
1382
1595
  }], ctorParameters: function () { return [{ type: SelectRowService }, { type: undefined, decorators: [{
1383
1596
  type: Inject,
1384
1597
  args: [RXAP_WINDOW_REF]