@rxap/material-table-system 14.2.2 → 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.
Files changed (26) hide show
  1. package/_theming.scss +235 -0
  2. package/esm2020/index.mjs +3 -1
  3. package/esm2020/lib/select-row/select-row.service.mjs +2 -2
  4. package/esm2020/lib/select-row/selection-model.mjs +218 -0
  5. package/esm2020/lib/table-row-actions/decorators.mjs +6 -2
  6. package/esm2020/lib/table-row-actions/row-action-check.pipe.mjs +43 -0
  7. package/esm2020/lib/table-row-actions/table-row-action.directive.mjs +1 -1
  8. package/esm2020/lib/table-row-actions/table-row-action.method.mjs +12 -2
  9. package/esm2020/lib/table-row-actions/table-row-actions.module.mjs +8 -3
  10. package/esm2020/lib/table-row-actions/table-row-header-action.directive.mjs +1 -1
  11. package/esm2020/lib/table-row-actions/types.mjs +2 -0
  12. package/fesm2015/rxap-material-table-system.mjs +280 -6
  13. package/fesm2015/rxap-material-table-system.mjs.map +1 -1
  14. package/fesm2020/rxap-material-table-system.mjs +278 -6
  15. package/fesm2020/rxap-material-table-system.mjs.map +1 -1
  16. package/index.d.ts +2 -0
  17. package/lib/select-row/select-row.service.d.ts +1 -1
  18. package/lib/select-row/selection-model.d.ts +118 -0
  19. package/lib/table-row-actions/decorators.d.ts +3 -1
  20. package/lib/table-row-actions/row-action-check.pipe.d.ts +10 -0
  21. package/lib/table-row-actions/table-row-action.directive.d.ts +1 -1
  22. package/lib/table-row-actions/table-row-action.method.d.ts +3 -7
  23. package/lib/table-row-actions/table-row-actions.module.d.ts +8 -7
  24. package/lib/table-row-actions/table-row-header-action.directive.d.ts +1 -1
  25. package/lib/table-row-actions/types.d.ts +8 -0
  26. package/package.json +2 -3
@@ -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';
@@ -280,6 +279,223 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImpor
280
279
 
281
280
  const RXAP_MATERIAL_TABLE_SYSTEM_SELECT_ROW_OPTIONS = new InjectionToken('rxap-material/table-system/select-row/options');
282
281
 
282
+ /**
283
+ * @license
284
+ * Copyright Google LLC All Rights Reserved.
285
+ *
286
+ * Use of this source code is governed by an MIT-style license that can be
287
+ * found in the LICENSE file at https://angular.io/license
288
+ */
289
+ /**
290
+ * Class to be used to power selecting one or more options from a list.
291
+ */
292
+ class SelectionModel {
293
+ constructor(_multiple = false, initiallySelectedValues, _emitChanges = true, compareWith) {
294
+ this._multiple = _multiple;
295
+ this._emitChanges = _emitChanges;
296
+ this.compareWith = compareWith;
297
+ /** Currently-selected values. */
298
+ this._selection = new Set();
299
+ /** Keeps track of the deselected options that haven't been emitted by the change event. */
300
+ this._deselectedToEmit = [];
301
+ /** Keeps track of the selected options that haven't been emitted by the change event. */
302
+ this._selectedToEmit = [];
303
+ /** Cache for the array value of the selected items. */
304
+ this._selected = null;
305
+ /** Event emitted when the value has changed. */
306
+ this.changed = new Subject();
307
+ if (initiallySelectedValues && initiallySelectedValues.length) {
308
+ if (_multiple) {
309
+ initiallySelectedValues.forEach(value => this._markSelected(value));
310
+ }
311
+ else {
312
+ this._markSelected(initiallySelectedValues[0]);
313
+ }
314
+ // Clear the array in order to avoid firing the change event for preselected values.
315
+ this._selectedToEmit.length = 0;
316
+ }
317
+ }
318
+ /** Selected values. */
319
+ get selected() {
320
+ if (!this._selected) {
321
+ this._selected = Array.from(this._selection.values());
322
+ }
323
+ return this._selected;
324
+ }
325
+ /**
326
+ * Selects a value or an array of values.
327
+ * @param values The values to select
328
+ * @return Whether the selection changed as a result of this call
329
+ * @breaking-change 16.0.0 make return type boolean
330
+ */
331
+ select(...values) {
332
+ this._verifyValueAssignment(values);
333
+ values.forEach(value => this._markSelected(value));
334
+ const changed = this._hasQueuedChanges();
335
+ this._emitChangeEvent();
336
+ return changed;
337
+ }
338
+ /**
339
+ * Deselects a value or an array of values.
340
+ * @param values The values to deselect
341
+ * @return Whether the selection changed as a result of this call
342
+ * @breaking-change 16.0.0 make return type boolean
343
+ */
344
+ deselect(...values) {
345
+ this._verifyValueAssignment(values);
346
+ values.forEach(value => this._unmarkSelected(value));
347
+ const changed = this._hasQueuedChanges();
348
+ this._emitChangeEvent();
349
+ return changed;
350
+ }
351
+ /**
352
+ * Sets the selected values
353
+ * @param values The new selected values
354
+ * @return Whether the selection changed as a result of this call
355
+ * @breaking-change 16.0.0 make return type boolean
356
+ */
357
+ setSelection(...values) {
358
+ this._verifyValueAssignment(values);
359
+ const oldValues = this.selected;
360
+ const newSelectedSet = new Set(values);
361
+ values.forEach(value => this._markSelected(value));
362
+ oldValues
363
+ .filter(value => !newSelectedSet.has(value))
364
+ .forEach(value => this._unmarkSelected(value));
365
+ const changed = this._hasQueuedChanges();
366
+ this._emitChangeEvent();
367
+ return changed;
368
+ }
369
+ /**
370
+ * Toggles a value between selected and deselected.
371
+ * @param value The value to toggle
372
+ * @return Whether the selection changed as a result of this call
373
+ * @breaking-change 16.0.0 make return type boolean
374
+ */
375
+ toggle(value) {
376
+ return this.isSelected(value) ? this.deselect(value) : this.select(value);
377
+ }
378
+ /**
379
+ * Clears all of the selected values.
380
+ * @param flushEvent Whether to flush the changes in an event.
381
+ * If false, the changes to the selection will be flushed along with the next event.
382
+ * @return Whether the selection changed as a result of this call
383
+ * @breaking-change 16.0.0 make return type boolean
384
+ */
385
+ clear(flushEvent = true) {
386
+ this._unmarkAll();
387
+ const changed = this._hasQueuedChanges();
388
+ if (flushEvent) {
389
+ this._emitChangeEvent();
390
+ }
391
+ return changed;
392
+ }
393
+ /**
394
+ * Determines whether a value is selected.
395
+ */
396
+ isSelected(value) {
397
+ if (this.compareWith) {
398
+ for (const otherValue of this._selection) {
399
+ if (this.compareWith(otherValue, value)) {
400
+ return true;
401
+ }
402
+ }
403
+ return false;
404
+ }
405
+ return this._selection.has(value);
406
+ }
407
+ /**
408
+ * Determines whether the model does not have a value.
409
+ */
410
+ isEmpty() {
411
+ return this._selection.size === 0;
412
+ }
413
+ /**
414
+ * Determines whether the model has a value.
415
+ */
416
+ hasValue() {
417
+ return !this.isEmpty();
418
+ }
419
+ /**
420
+ * Sorts the selected values based on a predicate function.
421
+ */
422
+ sort(predicate) {
423
+ if (this._multiple && this.selected) {
424
+ this._selected.sort(predicate);
425
+ }
426
+ }
427
+ /**
428
+ * Gets whether multiple values can be selected.
429
+ */
430
+ isMultipleSelection() {
431
+ return this._multiple;
432
+ }
433
+ /** Emits a change event and clears the records of selected and deselected values. */
434
+ _emitChangeEvent() {
435
+ // Clear the selected values so they can be re-cached.
436
+ this._selected = null;
437
+ if (this._selectedToEmit.length || this._deselectedToEmit.length) {
438
+ this.changed.next({
439
+ source: this,
440
+ added: this._selectedToEmit,
441
+ removed: this._deselectedToEmit,
442
+ });
443
+ this._deselectedToEmit = [];
444
+ this._selectedToEmit = [];
445
+ }
446
+ }
447
+ /** Selects a value. */
448
+ _markSelected(value) {
449
+ if (!this.isSelected(value)) {
450
+ if (!this._multiple) {
451
+ this._unmarkAll();
452
+ }
453
+ if (!this.isSelected(value)) {
454
+ this._selection.add(value);
455
+ }
456
+ if (this._emitChanges) {
457
+ this._selectedToEmit.push(value);
458
+ }
459
+ }
460
+ }
461
+ /** Deselects a value. */
462
+ _unmarkSelected(value) {
463
+ if (this.isSelected(value)) {
464
+ this._selection.delete(value);
465
+ if (this._emitChanges) {
466
+ this._deselectedToEmit.push(value);
467
+ }
468
+ }
469
+ }
470
+ /** Clears out the selected values. */
471
+ _unmarkAll() {
472
+ if (!this.isEmpty()) {
473
+ this._selection.forEach(value => this._unmarkSelected(value));
474
+ }
475
+ }
476
+ /**
477
+ * Verifies the value assignment and throws an error if the specified value array is
478
+ * including multiple values while the selection model is not supporting multiple values.
479
+ */
480
+ _verifyValueAssignment(values) {
481
+ if (values.length > 1 && !this._multiple && (typeof ngDevMode === 'undefined' || ngDevMode)) {
482
+ throw getMultipleValuesInSingleSelectionError();
483
+ }
484
+ }
485
+ /** Whether there are queued up change to be emitted. */
486
+ _hasQueuedChanges() {
487
+ return !!(this._deselectedToEmit.length || this._selectedToEmit.length);
488
+ }
489
+ }
490
+ /**
491
+ * Returns an error that reports that multiple values are passed into a selection model
492
+ * with a single value.
493
+ * @docs-private
494
+ */
495
+ function getMultipleValuesInSingleSelectionError() {
496
+ return Error('Cannot pass multiple values into SelectionModel with single-value mode.');
497
+ }
498
+
283
499
  class SelectRowService {
284
500
  constructor(options = null) {
285
501
  this.selectionModel = new SelectionModel(true);
@@ -1700,9 +1916,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImpor
1700
1916
  }] });
1701
1917
 
1702
1918
  const RXAP_TABLE_ACTION_METHOD_TYPE_METADATA = 'rxap-table-action-method-type-metadata';
1703
- function TableActionMethod(type) {
1919
+ const RXAP_TABLE_ACTION_METHOD_CHECK_FUNCTION_METADATA = 'rxap-table-action-method-check-function-metadata';
1920
+ function TableActionMethod(type, checkFunction) {
1704
1921
  return function (target) {
1705
1922
  setMetadata(RXAP_TABLE_ACTION_METHOD_TYPE_METADATA, type, target);
1923
+ if (checkFunction) {
1924
+ setMetadata(RXAP_TABLE_ACTION_METHOD_CHECK_FUNCTION_METADATA, checkFunction, target);
1925
+ }
1706
1926
  };
1707
1927
  }
1708
1928
 
@@ -1743,6 +1963,16 @@ function IsTableRowActionTypeMethod(type) {
1743
1963
  return (getMetadata(RXAP_TABLE_ACTION_METHOD_TYPE_METADATA, method.constructor) === type);
1744
1964
  };
1745
1965
  }
1966
+ function HasTableRowActionCheckFunction(method) {
1967
+ return hasMetadata(RXAP_TABLE_ACTION_METHOD_CHECK_FUNCTION_METADATA, method.constructor);
1968
+ }
1969
+ function GetTableRowActionCheckFunction(method) {
1970
+ const checkFunction = getMetadata(RXAP_TABLE_ACTION_METHOD_CHECK_FUNCTION_METADATA, method.constructor);
1971
+ if (!checkFunction) {
1972
+ throw new Error(`Extracted check function from '${method.constructor.name}' is empty`);
1973
+ }
1974
+ return checkFunction;
1975
+ }
1746
1976
 
1747
1977
  const RXAP_TABLE_ROW_ACTION_METHOD = new InjectionToken('rxap-table-row-action-method');
1748
1978
 
@@ -1999,14 +2229,54 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImpor
1999
2229
  args: ['rxapTableRowHeaderAction']
2000
2230
  }] } });
2001
2231
 
2232
+ class RowActionCheckPipe {
2233
+ constructor(tableRowActionMethodList) {
2234
+ this.actionMethodList = coerceArray(tableRowActionMethodList);
2235
+ }
2236
+ transform(value, type) {
2237
+ if (!type) {
2238
+ throw new Error(`The provided type is empty '${type}'`);
2239
+ }
2240
+ const actionMethodList = this.actionMethodList.filter(IsTableRowActionTypeMethod(type));
2241
+ if (actionMethodList.length > 1) {
2242
+ throw new Error(`Multiple (${actionMethodList.length}) action method with the same type '${type}' found`);
2243
+ }
2244
+ if (actionMethodList.length === 0) {
2245
+ throw new Error(`Could not find a action method with the type '${type}'`);
2246
+ }
2247
+ const actionMethod = actionMethodList[0];
2248
+ if (HasTableRowActionCheckFunction(actionMethod)) {
2249
+ const checkFunction = GetTableRowActionCheckFunction(actionMethod);
2250
+ const input = coerceArray(value);
2251
+ return input.length !== 0 && input.every(checkFunction);
2252
+ }
2253
+ return true;
2254
+ }
2255
+ }
2256
+ 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 });
2257
+ RowActionCheckPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.2.2", ngImport: i0, type: RowActionCheckPipe, name: "rxapRowActionCheck" });
2258
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: RowActionCheckPipe, decorators: [{
2259
+ type: Pipe,
2260
+ args: [{
2261
+ name: 'rxapRowActionCheck',
2262
+ }]
2263
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
2264
+ type: Optional
2265
+ }, {
2266
+ type: Inject,
2267
+ args: [RXAP_TABLE_ROW_ACTION_METHOD]
2268
+ }] }]; } });
2269
+
2002
2270
  class TableRowActionsModule {
2003
2271
  }
2004
2272
  TableRowActionsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.2", ngImport: i0, type: TableRowActionsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2005
2273
  TableRowActionsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.2", ngImport: i0, type: TableRowActionsModule, declarations: [TableRowActionDirective,
2006
2274
  TableRowActionExecutingDirective,
2007
- TableRowHeaderActionDirective], exports: [TableRowActionDirective,
2275
+ TableRowHeaderActionDirective,
2276
+ RowActionCheckPipe], exports: [TableRowActionDirective,
2008
2277
  TableRowHeaderActionDirective,
2009
2278
  TableRowActionExecutingDirective,
2279
+ RowActionCheckPipe,
2010
2280
  MatTooltipModule,
2011
2281
  MatButtonModule,
2012
2282
  ConfirmComponentModule,
@@ -2025,12 +2295,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImpor
2025
2295
  declarations: [
2026
2296
  TableRowActionDirective,
2027
2297
  TableRowActionExecutingDirective,
2028
- TableRowHeaderActionDirective
2298
+ TableRowHeaderActionDirective,
2299
+ RowActionCheckPipe
2029
2300
  ],
2030
2301
  exports: [
2031
2302
  TableRowActionDirective,
2032
2303
  TableRowHeaderActionDirective,
2033
2304
  TableRowActionExecutingDirective,
2305
+ RowActionCheckPipe,
2034
2306
  MatTooltipModule,
2035
2307
  MatButtonModule,
2036
2308
  ConfirmComponentModule,
@@ -2048,5 +2320,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.2", ngImpor
2048
2320
  * Generated bundle index. Do not edit.
2049
2321
  */
2050
2322
 
2051
- 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 };
2323
+ 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 };
2052
2324
  //# sourceMappingURL=rxap-material-table-system.mjs.map