@rxap/material-table-system 16.0.1-dev.6 → 16.1.0-dev.1

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.
@@ -1,8 +1,8 @@
1
1
  import * as i0 from '@angular/core';
2
- import { InjectionToken, Injectable, Optional, Inject, Component, ChangeDetectionStrategy, Directive, Input, isDevMode, Renderer2, ElementRef, ChangeDetectorRef, ViewContainerRef, INJECTOR, ContentChild, HostListener, Pipe, NgModule, forwardRef, ContentChildren, HostBinding, TemplateRef } from '@angular/core';
2
+ import { InjectionToken, Injectable, Optional, Inject, Component, ChangeDetectionStrategy, isDevMode, Directive, Input, Renderer2, ElementRef, ChangeDetectorRef, ViewContainerRef, INJECTOR, ContentChild, HostListener, Pipe, NgModule, forwardRef, ContentChildren, HostBinding, TemplateRef } from '@angular/core';
3
3
  import { RXAP_WINDOW_REF } from '@rxap/window-system';
4
- import { map, tap, filter, debounceTime, delay, startWith, distinctUntilChanged } from 'rxjs/operators';
5
- import { Subject, ReplaySubject, Subscription, isObservable, EMPTY, BehaviorSubject } from 'rxjs';
4
+ import { map, tap, startWith, debounceTime, distinctUntilChanged, filter } from 'rxjs/operators';
5
+ import { Subject, ReplaySubject, Subscription, isObservable, BehaviorSubject, EMPTY } from 'rxjs';
6
6
  import { AsyncPipe, CommonModule, NgFor, NgClass, NgIf, NgSwitch, NgSwitchCase, NgSwitchDefault, DatePipe } from '@angular/common';
7
7
  import * as i4 from '@angular/material/button';
8
8
  import { MatButtonModule, MatIconButton, MatButton, MatMiniFabButton } from '@angular/material/button';
@@ -27,9 +27,10 @@ import { setMetadata, getMetadata, hasMetadata } from '@rxap/reflect-metadata';
27
27
  import * as i2$2 from '@angular/material/icon';
28
28
  import { MatIconModule } from '@angular/material/icon';
29
29
  import { MatProgressBarModule } from '@angular/material/progress-bar';
30
+ import * as i1$4 from '@angular/forms';
31
+ import { ControlContainer, NgModel } from '@angular/forms';
30
32
  import { FormDirective } from '@rxap/forms';
31
- import { ControlContainer } from '@angular/forms';
32
- import * as i1$5 from '@angular/material/paginator';
33
+ import * as i1$6 from '@angular/material/paginator';
33
34
  import * as i1$3 from '@angular/material/slide-toggle';
34
35
  import { MatSlideToggleModule } from '@angular/material/slide-toggle';
35
36
  import { StopPropagationDirective, BackgroundSizeOptions, BackgroundRepeatOptions, BackgroundPositionOptions, BackgroundImageDirective } from '@rxap/directives';
@@ -38,7 +39,7 @@ import { MatCheckboxModule } from '@angular/material/checkbox';
38
39
  import * as i2$1 from '@angular/material/menu';
39
40
  import { MatMenuModule } from '@angular/material/menu';
40
41
  import * as i1$2 from '@angular/router';
41
- import * as i1$4 from '@angular/cdk/portal';
42
+ import * as i1$5 from '@angular/cdk/portal';
42
43
  import { TemplatePortal, PortalModule } from '@angular/cdk/portal';
43
44
  import { trigger, state, style, transition, animate, sequence } from '@angular/animations';
44
45
  import { IconDirective } from '@rxap/material-directives/icon';
@@ -317,6 +318,7 @@ class TableFilterService {
317
318
  constructor() {
318
319
  this.change = new ReplaySubject(1);
319
320
  this.current = {};
321
+ this.reset$ = new Subject();
320
322
  /**
321
323
  * a flag to indicate whether any value was already send to the change subject
322
324
  * true - a value was send
@@ -326,6 +328,9 @@ class TableFilterService {
326
328
  this._init = false;
327
329
  this._subscription = this.change.subscribe(current => this.current = current);
328
330
  }
331
+ reset() {
332
+ this.reset$.next();
333
+ }
329
334
  setMap(map) {
330
335
  const current = this.current;
331
336
  const copy = clone(this.current);
@@ -397,6 +402,7 @@ class TableDataSourceDirective {
397
402
  this._tableFilter = _tableFilter;
398
403
  this.loading$ = new ToggleSubject(true);
399
404
  this.hasError$ = new ToggleSubject();
405
+ this.error$ = new Subject();
400
406
  this._subscription = new Subscription();
401
407
  this.adapterFactory = null;
402
408
  this.matTable.trackBy = this.trackBy;
@@ -438,6 +444,7 @@ class TableDataSourceDirective {
438
444
  }
439
445
  this._subscription.add(this.dataSource.loading$.pipe(tap(loading => this.loading$.next(!!loading))).subscribe());
440
446
  this._subscription.add(this.dataSource.hasError$.pipe(tap(hasError => this.hasError$.next(!!hasError))).subscribe());
447
+ this._subscription.add(this.dataSource.error$.pipe(tap(error => this.error$.next(error))).subscribe());
441
448
  // create the id property for the mat table component.
442
449
  // the instance of the mat table component is used as viewer object
443
450
  // with the set of the id property it is possible to use the same data source
@@ -447,17 +454,15 @@ class TableDataSourceDirective {
447
454
  Reflect.set(this.matTable, 'id', this.id);
448
455
  this.matTable.dataSource = pipeDataSource(this.dataSource, tap(rowList => {
449
456
  if (rowList.some((element) => !element.__metadata__)) {
450
- console.debug('Ensure to use the NormalizeTableRow function to normalize the table row!');
457
+ if (isDevMode()) {
458
+ console.debug('Ensure to use the NormalizeTableRow function to normalize the table row!');
459
+ }
451
460
  rowList.forEach((element) => {
452
- element.__metadata__ ??= { loading$: new ToggleSubject() };
461
+ element.__metadata__ ??= {};
453
462
  element.__metadata__.loading$ ??= new ToggleSubject();
454
463
  });
455
464
  }
456
465
  }));
457
- // TODO : remove hack to trigger change detection after data source refresh (machine-definition -> physical unit)
458
- this._subscription.add(this.loading$
459
- .pipe(filter((loading) => !loading), debounceTime(2000), tap(() => this.cdr.detectChanges()), tap(() => this.cdr.markForCheck()), delay(500), tap(() => this.cdr.detectChanges()), tap(() => this.cdr.markForCheck()), delay(500), tap(() => this.cdr.detectChanges()), tap(() => this.cdr.markForCheck()), delay(500), tap(() => this.cdr.detectChanges()), tap(() => this.cdr.markForCheck()), delay(500), tap(() => this.cdr.detectChanges()), tap(() => this.cdr.markForCheck()), delay(500), tap(() => this.cdr.detectChanges()), tap(() => this.cdr.markForCheck()), delay(500))
460
- .subscribe());
461
466
  }
462
467
  ngOnDestroy() {
463
468
  this._subscription?.unsubscribe();
@@ -468,6 +473,10 @@ class TableDataSourceDirective {
468
473
  retry() {
469
474
  this.dataSource?.retry();
470
475
  }
476
+ reset() {
477
+ this.tableFilter?.reset();
478
+ this.dataSource?.retry();
479
+ }
471
480
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TableDataSourceDirective, deps: [{ token: CdkTable }, { token: i0.ChangeDetectorRef }, { token: RXAP_TABLE_METHOD, optional: true }, { token: TABLE_DATA_SOURCE, optional: true }, { token: TABLE_REMOTE_METHOD_ADAPTER_FACTORY, optional: true }, { token: MatSort, optional: true }, { token: TableFilterService, optional: true }, { token: RXAP_TABLE_FILTER, optional: true }], target: i0.ɵɵFactoryTarget.Directive }); }
472
481
  static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: TableDataSourceDirective, isStandalone: true, selector: "table[mat-table][rxapTableDataSource],mat-table[rxapTableDataSource]", inputs: { setDataSource: ["rxapTableDataSource", "setDataSource"], paginator: "paginator", id: "id", parameters: "parameters", dataSource: "dataSource" }, exportAs: ["rxapTableDataSource"], ngImport: i0 }); }
473
482
  }
@@ -1268,9 +1277,11 @@ class FilterHeaderRowDirective extends FormDirective {
1268
1277
  }
1269
1278
  ngOnInit() {
1270
1279
  super.ngOnInit();
1271
- this._subscription = this.form.value$
1280
+ this._subscription = new Subscription();
1281
+ this._subscription.add(this.tableFilter.reset$.subscribe(() => this.form.reset()));
1282
+ this._subscription.add(this.form.value$
1272
1283
  .pipe(debounceTime(1000), distinctUntilChanged((a, b) => equals(a, b)), tap(values => this.tableFilter.setMap(values)))
1273
- .subscribe();
1284
+ .subscribe());
1274
1285
  }
1275
1286
  ngOnDestroy() {
1276
1287
  super.ngOnDestroy();
@@ -1622,6 +1633,69 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1622
1633
  }]
1623
1634
  }] });
1624
1635
 
1636
+ // TODO : move to rxap packages
1637
+ class TableColumnFilterService {
1638
+ constructor() {
1639
+ this.change = new BehaviorSubject({});
1640
+ }
1641
+ get current() {
1642
+ return clone(this.change.value);
1643
+ }
1644
+ setFilter(column, value) {
1645
+ const next = this.current;
1646
+ if (value) {
1647
+ next[column] = value;
1648
+ }
1649
+ else if (next[column]) {
1650
+ delete next[column];
1651
+ }
1652
+ this.change.next(next);
1653
+ }
1654
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TableColumnFilterService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1655
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TableColumnFilterService }); }
1656
+ }
1657
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TableColumnFilterService, decorators: [{
1658
+ type: Injectable
1659
+ }] });
1660
+
1661
+ // TODO : move to rxap packages
1662
+ class TableColumnFilterInputDirective {
1663
+ constructor(ngModel, tableColumnFilterService) {
1664
+ this.ngModel = ngModel;
1665
+ this.tableColumnFilterService = tableColumnFilterService;
1666
+ }
1667
+ ngOnDestroy() {
1668
+ this._subscription?.unsubscribe();
1669
+ }
1670
+ ngAfterViewInit() {
1671
+ if (!this.ngModel.valueChanges) {
1672
+ throw new Error('Could not access the ngModel value change');
1673
+ }
1674
+ this._subscription = this.ngModel.valueChanges.pipe(debounceTime(500), tap((value) => {
1675
+ this.tableColumnFilterService.setFilter(this.column, value);
1676
+ }))
1677
+ .subscribe();
1678
+ }
1679
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TableColumnFilterInputDirective, deps: [{ token: NgModel }, { token: RXAP_TABLE_FILTER }], target: i0.ɵɵFactoryTarget.Directive }); }
1680
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: TableColumnFilterInputDirective, isStandalone: true, selector: "input[ngModel][rxapTableColumnFilterInput]", inputs: { column: "column" }, ngImport: i0 }); }
1681
+ }
1682
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: TableColumnFilterInputDirective, decorators: [{
1683
+ type: Directive,
1684
+ args: [{
1685
+ selector: 'input[ngModel][rxapTableColumnFilterInput]',
1686
+ standalone: true,
1687
+ }]
1688
+ }], ctorParameters: function () { return [{ type: i1$4.NgModel, decorators: [{
1689
+ type: Inject,
1690
+ args: [NgModel]
1691
+ }] }, { type: TableColumnFilterService, decorators: [{
1692
+ type: Inject,
1693
+ args: [RXAP_TABLE_FILTER]
1694
+ }] }]; }, propDecorators: { column: [{
1695
+ type: Input,
1696
+ args: [{ required: true }]
1697
+ }] } });
1698
+
1625
1699
  class CheckboxHeaderCellComponent {
1626
1700
  constructor(cdkTable, selectRow) {
1627
1701
  this.cdkTable = cdkTable;
@@ -1813,7 +1887,7 @@ class ExpandRowContainerComponent {
1813
1887
  }
1814
1888
  }
1815
1889
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ExpandRowContainerComponent, deps: [{ token: ViewContainerRef }, { token: ExpandRowService }], target: i0.ɵɵFactoryTarget.Component }); }
1816
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ExpandRowContainerComponent, isStandalone: true, selector: "td[rxap-expand-row]", inputs: { element: "element" }, queries: [{ propertyName: "expandCellContent", first: true, predicate: ExpandRowContentDirective, descendants: true }], ngImport: i0, template: "<div [@detailExpand]=\"(expandCell.isExpanded$(element) | async) ? 'expanded' : 'collapsed'\" class=\"element-detail\">\n <ng-content></ng-content>\n <ng-template [cdkPortalOutlet]=\"portal\"></ng-template>\n</div>\n", styles: [".element-detail{overflow:hidden;display:flex}\n"], dependencies: [{ kind: "ngmodule", type: PortalModule }, { kind: "directive", type: i1$4.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }, { kind: "pipe", type: AsyncPipe, name: "async" }], animations: [
1890
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: ExpandRowContainerComponent, isStandalone: true, selector: "td[rxap-expand-row]", inputs: { element: "element" }, queries: [{ propertyName: "expandCellContent", first: true, predicate: ExpandRowContentDirective, descendants: true }], ngImport: i0, template: "<div [@detailExpand]=\"(expandCell.isExpanded$(element) | async) ? 'expanded' : 'collapsed'\" class=\"element-detail\">\n <ng-content></ng-content>\n <ng-template [cdkPortalOutlet]=\"portal\"></ng-template>\n</div>\n", styles: [".element-detail{overflow:hidden;display:flex}\n"], dependencies: [{ kind: "ngmodule", type: PortalModule }, { kind: "directive", type: i1$5.CdkPortalOutlet, selector: "[cdkPortalOutlet]", inputs: ["cdkPortalOutlet"], outputs: ["attached"], exportAs: ["cdkPortalOutlet"] }, { kind: "pipe", type: AsyncPipe, name: "async" }], animations: [
1817
1891
  trigger('detailExpand', [
1818
1892
  state('collapsed', style({
1819
1893
  height: '0px',
@@ -2166,7 +2240,7 @@ class PersistentPaginatorDirective {
2166
2240
  }
2167
2241
  return null;
2168
2242
  }
2169
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PersistentPaginatorDirective, deps: [{ token: i1$5.MatPaginator }], target: i0.ɵɵFactoryTarget.Directive }); }
2243
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PersistentPaginatorDirective, deps: [{ token: i1$6.MatPaginator }], target: i0.ɵɵFactoryTarget.Directive }); }
2170
2244
  static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: PersistentPaginatorDirective, isStandalone: true, selector: "mat-paginator[rxapPersistent]", inputs: { id: "id" }, ngImport: i0 }); }
2171
2245
  }
2172
2246
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: PersistentPaginatorDirective, decorators: [{
@@ -2175,7 +2249,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
2175
2249
  selector: 'mat-paginator[rxapPersistent]',
2176
2250
  standalone: true,
2177
2251
  }]
2178
- }], ctorParameters: function () { return [{ type: i1$5.MatPaginator }]; }, propDecorators: { id: [{
2252
+ }], ctorParameters: function () { return [{ type: i1$6.MatPaginator }]; }, propDecorators: { id: [{
2179
2253
  type: Input
2180
2254
  }] } });
2181
2255
 
@@ -2225,5 +2299,5 @@ function NormalizeTableRow(row, rowIdOrMapper) {
2225
2299
  * Generated bundle index. Do not edit.
2226
2300
  */
2227
2301
 
2228
- export { AbstractTableRowAction, BooleanCellComponent, CheckboxCellComponent, CheckboxHeaderCellComponent, CopyToClipboardCellComponent, DateCellComponent, ExpandControlsCellComponent, ExpandRowContainerComponent, ExpandRowContentDirective, ExpandRowDirective, ExpandRowModule, ExpandRowService, FilterHeaderRowDirective, GetTableHeaderButtonMetadata, GetTableRowActionCheckFunction, GetTableRowActionMetadata, HasTableRowActionCheckFunction, HasTableRowActionMetadata, IconCellComponent, ImageCellComponent, IsTableRowActionTypeMethod, IsTableRowActionTypeSwitchMethod, LinkCellComponent, NormalizeTableRow, OptionsCellComponent, PersistentPaginatorDirective, RXAP_MATERIAL_TABLE_SYSTEM_SELECT_ROW_OPTIONS, RXAP_TABLE_ACTION_METHOD_CHECK_FUNCTION_METADATA, RXAP_TABLE_ACTION_METHOD_METADATA, RXAP_TABLE_ACTION_METHOD_TYPE_METADATA, RXAP_TABLE_FILTER, RXAP_TABLE_FILTER_FORM_DEFINITION, RXAP_TABLE_HEADER_BUTTON_METHOD_METADATA, RXAP_TABLE_ROW_ACTION_METHOD, RowActionCheckPipe, RowAnimation, SelectRowModule, SelectRowService, SelectedRowsDirective, SelectionModel, TABLE_CREATE_REMOTE_METHOD, TABLE_DATA_SOURCE, TABLE_HEADER_BUTTON_METHOD, TABLE_REMOTE_METHOD, TABLE_REMOTE_METHOD_ADAPTER_FACTORY, TableActionMethod, TableColumnMenuComponent, TableColumnMenuModule, TableColumnOptionComponent, TableCreateButtonDirective, TableDataSourceDirective, TableFilterModule, TableFilterService, TableHeaderButtonActionStatus, TableHeaderButtonDirective, TableHeaderButtonMethod, TableRowActionDirective, TableRowActionExecutingDirective, TableRowActionStatus, TableRowActionsModule, TableRowHeaderActionDirective, TableSelectControlsComponent, TableShowArchivedSlideComponent, ToFilterColumnNamesPipe, TreeControlCellComponent, getMultipleValuesInSingleSelectionError };
2302
+ export { AbstractTableRowAction, BooleanCellComponent, CheckboxCellComponent, CheckboxHeaderCellComponent, CopyToClipboardCellComponent, DateCellComponent, ExpandControlsCellComponent, ExpandRowContainerComponent, ExpandRowContentDirective, ExpandRowDirective, ExpandRowModule, ExpandRowService, FilterHeaderRowDirective, GetTableHeaderButtonMetadata, GetTableRowActionCheckFunction, GetTableRowActionMetadata, HasTableRowActionCheckFunction, HasTableRowActionMetadata, IconCellComponent, ImageCellComponent, IsTableRowActionTypeMethod, IsTableRowActionTypeSwitchMethod, LinkCellComponent, NormalizeTableRow, OptionsCellComponent, PersistentPaginatorDirective, RXAP_MATERIAL_TABLE_SYSTEM_SELECT_ROW_OPTIONS, RXAP_TABLE_ACTION_METHOD_CHECK_FUNCTION_METADATA, RXAP_TABLE_ACTION_METHOD_METADATA, RXAP_TABLE_ACTION_METHOD_TYPE_METADATA, RXAP_TABLE_FILTER, RXAP_TABLE_FILTER_FORM_DEFINITION, RXAP_TABLE_HEADER_BUTTON_METHOD_METADATA, RXAP_TABLE_ROW_ACTION_METHOD, RowActionCheckPipe, RowAnimation, SelectRowModule, SelectRowService, SelectedRowsDirective, SelectionModel, TABLE_CREATE_REMOTE_METHOD, TABLE_DATA_SOURCE, TABLE_HEADER_BUTTON_METHOD, TABLE_REMOTE_METHOD, TABLE_REMOTE_METHOD_ADAPTER_FACTORY, TableActionMethod, TableColumnFilterInputDirective, TableColumnFilterService, TableColumnMenuComponent, TableColumnMenuModule, TableColumnOptionComponent, TableCreateButtonDirective, TableDataSourceDirective, TableFilterModule, TableFilterService, TableHeaderButtonActionStatus, TableHeaderButtonDirective, TableHeaderButtonMethod, TableRowActionDirective, TableRowActionExecutingDirective, TableRowActionStatus, TableRowActionsModule, TableRowHeaderActionDirective, TableSelectControlsComponent, TableShowArchivedSlideComponent, ToFilterColumnNamesPipe, TreeControlCellComponent, getMultipleValuesInSingleSelectionError };
2229
2303
  //# sourceMappingURL=rxap-material-table-system.mjs.map