@rxap/material-table-system 14.2.0 → 14.4.0-dev.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/icon';
13
13
  import { MatIconModule } from '@angular/material/icon';
14
14
  import * as i3 from '@angular/material/button';
15
15
  import { MatButtonModule, MatButton } from '@angular/material/button';
16
- import { SelectionModel } from '@angular/cdk/collections';
17
16
  import * as i1$1 from '@angular/material/checkbox';
18
17
  import { MatCheckboxModule } from '@angular/material/checkbox';
19
18
  import * as i4 from '@angular/cdk/table';
@@ -289,6 +288,223 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImpor
289
288
 
290
289
  const RXAP_MATERIAL_TABLE_SYSTEM_SELECT_ROW_OPTIONS = new InjectionToken('rxap-material/table-system/select-row/options');
291
290
 
291
+ /**
292
+ * @license
293
+ * Copyright Google LLC All Rights Reserved.
294
+ *
295
+ * Use of this source code is governed by an MIT-style license that can be
296
+ * found in the LICENSE file at https://angular.io/license
297
+ */
298
+ /**
299
+ * Class to be used to power selecting one or more options from a list.
300
+ */
301
+ class SelectionModel {
302
+ constructor(_multiple = false, initiallySelectedValues, _emitChanges = true, compareWith) {
303
+ this._multiple = _multiple;
304
+ this._emitChanges = _emitChanges;
305
+ this.compareWith = compareWith;
306
+ /** Currently-selected values. */
307
+ this._selection = new Set();
308
+ /** Keeps track of the deselected options that haven't been emitted by the change event. */
309
+ this._deselectedToEmit = [];
310
+ /** Keeps track of the selected options that haven't been emitted by the change event. */
311
+ this._selectedToEmit = [];
312
+ /** Cache for the array value of the selected items. */
313
+ this._selected = null;
314
+ /** Event emitted when the value has changed. */
315
+ this.changed = new Subject();
316
+ if (initiallySelectedValues && initiallySelectedValues.length) {
317
+ if (_multiple) {
318
+ initiallySelectedValues.forEach(value => this._markSelected(value));
319
+ }
320
+ else {
321
+ this._markSelected(initiallySelectedValues[0]);
322
+ }
323
+ // Clear the array in order to avoid firing the change event for preselected values.
324
+ this._selectedToEmit.length = 0;
325
+ }
326
+ }
327
+ /** Selected values. */
328
+ get selected() {
329
+ if (!this._selected) {
330
+ this._selected = Array.from(this._selection.values());
331
+ }
332
+ return this._selected;
333
+ }
334
+ /**
335
+ * Selects a value or an array of values.
336
+ * @param values The values to select
337
+ * @return Whether the selection changed as a result of this call
338
+ * @breaking-change 16.0.0 make return type boolean
339
+ */
340
+ select(...values) {
341
+ this._verifyValueAssignment(values);
342
+ values.forEach(value => this._markSelected(value));
343
+ const changed = this._hasQueuedChanges();
344
+ this._emitChangeEvent();
345
+ return changed;
346
+ }
347
+ /**
348
+ * Deselects a value or an array of values.
349
+ * @param values The values to deselect
350
+ * @return Whether the selection changed as a result of this call
351
+ * @breaking-change 16.0.0 make return type boolean
352
+ */
353
+ deselect(...values) {
354
+ this._verifyValueAssignment(values);
355
+ values.forEach(value => this._unmarkSelected(value));
356
+ const changed = this._hasQueuedChanges();
357
+ this._emitChangeEvent();
358
+ return changed;
359
+ }
360
+ /**
361
+ * Sets the selected values
362
+ * @param values The new selected values
363
+ * @return Whether the selection changed as a result of this call
364
+ * @breaking-change 16.0.0 make return type boolean
365
+ */
366
+ setSelection(...values) {
367
+ this._verifyValueAssignment(values);
368
+ const oldValues = this.selected;
369
+ const newSelectedSet = new Set(values);
370
+ values.forEach(value => this._markSelected(value));
371
+ oldValues
372
+ .filter(value => !newSelectedSet.has(value))
373
+ .forEach(value => this._unmarkSelected(value));
374
+ const changed = this._hasQueuedChanges();
375
+ this._emitChangeEvent();
376
+ return changed;
377
+ }
378
+ /**
379
+ * Toggles a value between selected and deselected.
380
+ * @param value The value to toggle
381
+ * @return Whether the selection changed as a result of this call
382
+ * @breaking-change 16.0.0 make return type boolean
383
+ */
384
+ toggle(value) {
385
+ return this.isSelected(value) ? this.deselect(value) : this.select(value);
386
+ }
387
+ /**
388
+ * Clears all of the selected values.
389
+ * @param flushEvent Whether to flush the changes in an event.
390
+ * If false, the changes to the selection will be flushed along with the next event.
391
+ * @return Whether the selection changed as a result of this call
392
+ * @breaking-change 16.0.0 make return type boolean
393
+ */
394
+ clear(flushEvent = true) {
395
+ this._unmarkAll();
396
+ const changed = this._hasQueuedChanges();
397
+ if (flushEvent) {
398
+ this._emitChangeEvent();
399
+ }
400
+ return changed;
401
+ }
402
+ /**
403
+ * Determines whether a value is selected.
404
+ */
405
+ isSelected(value) {
406
+ if (this.compareWith) {
407
+ for (const otherValue of this._selection) {
408
+ if (this.compareWith(otherValue, value)) {
409
+ return true;
410
+ }
411
+ }
412
+ return false;
413
+ }
414
+ return this._selection.has(value);
415
+ }
416
+ /**
417
+ * Determines whether the model does not have a value.
418
+ */
419
+ isEmpty() {
420
+ return this._selection.size === 0;
421
+ }
422
+ /**
423
+ * Determines whether the model has a value.
424
+ */
425
+ hasValue() {
426
+ return !this.isEmpty();
427
+ }
428
+ /**
429
+ * Sorts the selected values based on a predicate function.
430
+ */
431
+ sort(predicate) {
432
+ if (this._multiple && this.selected) {
433
+ this._selected.sort(predicate);
434
+ }
435
+ }
436
+ /**
437
+ * Gets whether multiple values can be selected.
438
+ */
439
+ isMultipleSelection() {
440
+ return this._multiple;
441
+ }
442
+ /** Emits a change event and clears the records of selected and deselected values. */
443
+ _emitChangeEvent() {
444
+ // Clear the selected values so they can be re-cached.
445
+ this._selected = null;
446
+ if (this._selectedToEmit.length || this._deselectedToEmit.length) {
447
+ this.changed.next({
448
+ source: this,
449
+ added: this._selectedToEmit,
450
+ removed: this._deselectedToEmit,
451
+ });
452
+ this._deselectedToEmit = [];
453
+ this._selectedToEmit = [];
454
+ }
455
+ }
456
+ /** Selects a value. */
457
+ _markSelected(value) {
458
+ if (!this.isSelected(value)) {
459
+ if (!this._multiple) {
460
+ this._unmarkAll();
461
+ }
462
+ if (!this.isSelected(value)) {
463
+ this._selection.add(value);
464
+ }
465
+ if (this._emitChanges) {
466
+ this._selectedToEmit.push(value);
467
+ }
468
+ }
469
+ }
470
+ /** Deselects a value. */
471
+ _unmarkSelected(value) {
472
+ if (this.isSelected(value)) {
473
+ this._selection.delete(value);
474
+ if (this._emitChanges) {
475
+ this._deselectedToEmit.push(value);
476
+ }
477
+ }
478
+ }
479
+ /** Clears out the selected values. */
480
+ _unmarkAll() {
481
+ if (!this.isEmpty()) {
482
+ this._selection.forEach(value => this._unmarkSelected(value));
483
+ }
484
+ }
485
+ /**
486
+ * Verifies the value assignment and throws an error if the specified value array is
487
+ * including multiple values while the selection model is not supporting multiple values.
488
+ */
489
+ _verifyValueAssignment(values) {
490
+ if (values.length > 1 && !this._multiple && (typeof ngDevMode === 'undefined' || ngDevMode)) {
491
+ throw getMultipleValuesInSingleSelectionError();
492
+ }
493
+ }
494
+ /** Whether there are queued up change to be emitted. */
495
+ _hasQueuedChanges() {
496
+ return !!(this._deselectedToEmit.length || this._selectedToEmit.length);
497
+ }
498
+ }
499
+ /**
500
+ * Returns an error that reports that multiple values are passed into a selection model
501
+ * with a single value.
502
+ * @docs-private
503
+ */
504
+ function getMultipleValuesInSingleSelectionError() {
505
+ return Error('Cannot pass multiple values into SelectionModel with single-value mode.');
506
+ }
507
+
292
508
  class SelectRowService {
293
509
  constructor(options = null) {
294
510
  this.selectionModel = new SelectionModel(true);
@@ -1766,9 +1982,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImpor
1766
1982
  }] });
1767
1983
 
1768
1984
  const RXAP_TABLE_ACTION_METHOD_TYPE_METADATA = 'rxap-table-action-method-type-metadata';
1769
- function TableActionMethod(type) {
1985
+ const RXAP_TABLE_ACTION_METHOD_CHECK_FUNCTION_METADATA = 'rxap-table-action-method-check-function-metadata';
1986
+ function TableActionMethod(type, checkFunction) {
1770
1987
  return function (target) {
1771
1988
  setMetadata(RXAP_TABLE_ACTION_METHOD_TYPE_METADATA, type, target);
1989
+ if (checkFunction) {
1990
+ setMetadata(RXAP_TABLE_ACTION_METHOD_CHECK_FUNCTION_METADATA, checkFunction, target);
1991
+ }
1772
1992
  };
1773
1993
  }
1774
1994
 
@@ -1809,6 +2029,16 @@ function IsTableRowActionTypeMethod(type) {
1809
2029
  return (getMetadata(RXAP_TABLE_ACTION_METHOD_TYPE_METADATA, method.constructor) === type);
1810
2030
  };
1811
2031
  }
2032
+ function HasTableRowActionCheckFunction(method) {
2033
+ return hasMetadata(RXAP_TABLE_ACTION_METHOD_CHECK_FUNCTION_METADATA, method.constructor);
2034
+ }
2035
+ function GetTableRowActionCheckFunction(method) {
2036
+ const checkFunction = getMetadata(RXAP_TABLE_ACTION_METHOD_CHECK_FUNCTION_METADATA, method.constructor);
2037
+ if (!checkFunction) {
2038
+ throw new Error(`Extracted check function from '${method.constructor.name}' is empty`);
2039
+ }
2040
+ return checkFunction;
2041
+ }
1812
2042
 
1813
2043
  const RXAP_TABLE_ROW_ACTION_METHOD = new InjectionToken('rxap-table-row-action-method');
1814
2044
 
@@ -2074,14 +2304,56 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImpor
2074
2304
  args: ['rxapTableRowHeaderAction']
2075
2305
  }] } });
2076
2306
 
2307
+ class RowActionCheckPipe {
2308
+ constructor(tableRowActionMethodList) {
2309
+ this.actionMethodList = coerceArray(tableRowActionMethodList);
2310
+ }
2311
+ transform(value, type) {
2312
+ if (!type) {
2313
+ throw new Error(`The provided type is empty '${type}'`);
2314
+ }
2315
+ const actionMethodList = this.actionMethodList.filter(IsTableRowActionTypeMethod(type));
2316
+ if (actionMethodList.length > 1) {
2317
+ throw new Error(`Multiple (${actionMethodList.length}) action method with the same type '${type}' found`);
2318
+ }
2319
+ if (actionMethodList.length === 0) {
2320
+ throw new Error(`Could not find a action method with the type '${type}'`);
2321
+ }
2322
+ const actionMethod = actionMethodList[0];
2323
+ if (HasTableRowActionCheckFunction(actionMethod)) {
2324
+ const checkFunction = GetTableRowActionCheckFunction(actionMethod);
2325
+ const input = coerceArray(value);
2326
+ return input.length !== 0 && input.every(checkFunction);
2327
+ }
2328
+ return true;
2329
+ }
2330
+ }
2331
+ RowActionCheckPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RowActionCheckPipe, deps: [{ token: RXAP_TABLE_ROW_ACTION_METHOD, optional: true }], target: i0.ɵɵFactoryTarget.Pipe });
2332
+ RowActionCheckPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.2.2", ngImport: i0, type: RowActionCheckPipe, name: "rxapRowActionCheck" });
2333
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RowActionCheckPipe, decorators: [{
2334
+ type: Pipe,
2335
+ args: [{
2336
+ name: 'rxapRowActionCheck',
2337
+ }]
2338
+ }], ctorParameters: function () {
2339
+ return [{ type: undefined, decorators: [{
2340
+ type: Optional
2341
+ }, {
2342
+ type: Inject,
2343
+ args: [RXAP_TABLE_ROW_ACTION_METHOD]
2344
+ }] }];
2345
+ } });
2346
+
2077
2347
  class TableRowActionsModule {
2078
2348
  }
2079
2349
  TableRowActionsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: TableRowActionsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2080
2350
  TableRowActionsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.2", ngImport: i0, type: TableRowActionsModule, declarations: [TableRowActionDirective,
2081
2351
  TableRowActionExecutingDirective,
2082
- TableRowHeaderActionDirective], exports: [TableRowActionDirective,
2352
+ TableRowHeaderActionDirective,
2353
+ RowActionCheckPipe], exports: [TableRowActionDirective,
2083
2354
  TableRowHeaderActionDirective,
2084
2355
  TableRowActionExecutingDirective,
2356
+ RowActionCheckPipe,
2085
2357
  MatTooltipModule,
2086
2358
  MatButtonModule,
2087
2359
  ConfirmComponentModule,
@@ -2100,12 +2372,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImpor
2100
2372
  declarations: [
2101
2373
  TableRowActionDirective,
2102
2374
  TableRowActionExecutingDirective,
2103
- TableRowHeaderActionDirective
2375
+ TableRowHeaderActionDirective,
2376
+ RowActionCheckPipe
2104
2377
  ],
2105
2378
  exports: [
2106
2379
  TableRowActionDirective,
2107
2380
  TableRowHeaderActionDirective,
2108
2381
  TableRowActionExecutingDirective,
2382
+ RowActionCheckPipe,
2109
2383
  MatTooltipModule,
2110
2384
  MatButtonModule,
2111
2385
  ConfirmComponentModule,
@@ -2123,5 +2397,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImpor
2123
2397
  * Generated bundle index. Do not edit.
2124
2398
  */
2125
2399
 
2126
- export { BooleanCellComponent, BooleanCellComponentModule, CheckboxCellComponent, CheckboxCellComponentModule, CheckboxHeaderCellComponent, CheckboxHeaderCellComponentModule, CopyToClipboardCellComponent, CopyToClipboardCellComponentModule, DateCellComponent, DateCellComponentModule, ExpandControlsCellComponent, ExpandControlsCellComponentModule, ExpandRowContainerComponent, ExpandRowContainerComponentModule, ExpandRowContentDirective, ExpandRowDirective, ExpandRowModule, ExpandRowService, FilterHeaderRowDirective, IconCellComponent, IconCellComponentModule, ImageCellComponent, ImageCellComponentModule, IsTableRowActionTypeMethod, IsTableRowActionTypeSwitchMethod, LinkCellComponent, LinkCellComponentModule, OptionsCellComponent, OptionsCellComponentModule, PersistentPaginatorDirective, PersistentPaginatorDirectiveModule, ROW_ARCHIVE_METHOD, ROW_DELETE_METHOD, ROW_EDIT_LOADER_METHOD, ROW_EDIT_METHOD, ROW_LINK_METHOD, ROW_RESTORE_METHOD, ROW_VIEW_METHOD, RXAP_MATERIAL_TABLE_SYSTEM_SELECT_ROW_OPTIONS, RXAP_TABLE_ACTION_METHOD_TYPE_METADATA, RXAP_TABLE_FILTER, RXAP_TABLE_FILTER_FORM_DEFINITION, RXAP_TABLE_ROW_ACTION_METHOD, RowAnimation, RowControlsCellComponent, RowControlsCellComponentModule, RowControlsHeaderCellComponent, RowControlsHeaderCellComponentModule, SelectRowModule, SelectRowService, SelectedRowsDirective, TABLE_CREATE_REMOTE_METHOD, TABLE_DATA_SOURCE, TABLE_REMOTE_METHOD, TABLE_REMOTE_METHOD_ADAPTER_FACTORY, TableActionMethod, TableColumnMenuComponent, TableColumnMenuComponentModule, TableColumnOptionComponent, TableCreateButtonDirective, TableCreateButtonDirectiveModule, TableDataSourceDirective, TableDataSourceModule, TableFilterModule, TableFilterService, TableRowActionDirective, TableRowActionExecutingDirective, TableRowActionStatus, TableRowActionsModule, TableRowControlsModule, TableRowHeaderActionDirective, TableSelectControlsComponent, TableSelectControlsComponentModule, TableShowArchivedSlideComponent, TableShowArchivedSlideComponentModule, ToFilterColumnNamesPipe };
2400
+ export { BooleanCellComponent, BooleanCellComponentModule, CheckboxCellComponent, CheckboxCellComponentModule, CheckboxHeaderCellComponent, CheckboxHeaderCellComponentModule, CopyToClipboardCellComponent, CopyToClipboardCellComponentModule, DateCellComponent, DateCellComponentModule, ExpandControlsCellComponent, ExpandControlsCellComponentModule, ExpandRowContainerComponent, ExpandRowContainerComponentModule, ExpandRowContentDirective, ExpandRowDirective, ExpandRowModule, ExpandRowService, FilterHeaderRowDirective, GetTableRowActionCheckFunction, HasTableRowActionCheckFunction, IconCellComponent, IconCellComponentModule, ImageCellComponent, ImageCellComponentModule, IsTableRowActionTypeMethod, IsTableRowActionTypeSwitchMethod, LinkCellComponent, LinkCellComponentModule, OptionsCellComponent, OptionsCellComponentModule, PersistentPaginatorDirective, PersistentPaginatorDirectiveModule, ROW_ARCHIVE_METHOD, ROW_DELETE_METHOD, ROW_EDIT_LOADER_METHOD, ROW_EDIT_METHOD, ROW_LINK_METHOD, ROW_RESTORE_METHOD, ROW_VIEW_METHOD, RXAP_MATERIAL_TABLE_SYSTEM_SELECT_ROW_OPTIONS, RXAP_TABLE_ACTION_METHOD_CHECK_FUNCTION_METADATA, RXAP_TABLE_ACTION_METHOD_TYPE_METADATA, RXAP_TABLE_FILTER, RXAP_TABLE_FILTER_FORM_DEFINITION, RXAP_TABLE_ROW_ACTION_METHOD, RowActionCheckPipe, RowAnimation, RowControlsCellComponent, RowControlsCellComponentModule, RowControlsHeaderCellComponent, RowControlsHeaderCellComponentModule, SelectRowModule, SelectRowService, SelectedRowsDirective, TABLE_CREATE_REMOTE_METHOD, TABLE_DATA_SOURCE, TABLE_REMOTE_METHOD, TABLE_REMOTE_METHOD_ADAPTER_FACTORY, TableActionMethod, TableColumnMenuComponent, TableColumnMenuComponentModule, TableColumnOptionComponent, TableCreateButtonDirective, TableCreateButtonDirectiveModule, TableDataSourceDirective, TableDataSourceModule, TableFilterModule, TableFilterService, TableRowActionDirective, TableRowActionExecutingDirective, TableRowActionStatus, TableRowActionsModule, TableRowControlsModule, TableRowHeaderActionDirective, TableSelectControlsComponent, TableSelectControlsComponentModule, TableShowArchivedSlideComponent, TableShowArchivedSlideComponentModule, ToFilterColumnNamesPipe };
2127
2401
  //# sourceMappingURL=rxap-material-table-system.mjs.map