@one-paragon/angular-utilities 2.8.2 → 2.8.4

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 (203) hide show
  1. package/karma.conf.js +43 -0
  2. package/ng-package.json +7 -0
  3. package/package.json +15 -27
  4. package/src/action-state/action-state-spinner/action-state-spinner.component.css +16 -0
  5. package/src/action-state/action-state-spinner/action-state-spinner.component.html +7 -0
  6. package/src/action-state/action-state-spinner/action-state-spinner.component.spec.ts +25 -0
  7. package/src/action-state/action-state-spinner/action-state-spinner.component.ts +26 -0
  8. package/src/action-state/action-state-ui/action-state-ui.module.ts +13 -0
  9. package/src/action-state/index.ts +8 -0
  10. package/src/action-state/ngrx-ext/ngrx-ext.module.ts +14 -0
  11. package/src/action-state/ngrx.ts +69 -0
  12. package/src/http-request-state/RequestStateFactory.ts +56 -0
  13. package/src/http-request-state/RequestStateStore.ts +360 -0
  14. package/src/http-request-state/deprecated.ts +20 -0
  15. package/src/http-request-state/directives/HttpStateDirectiveBase.ts +29 -0
  16. package/src/http-request-state/directives/http-error-state-directive.ts +21 -0
  17. package/src/http-request-state/directives/http-inProgress-state-directive.ts +19 -0
  18. package/src/http-request-state/directives/http-notStarted-state-directive.ts +19 -0
  19. package/src/http-request-state/directives/http-success-state-directive.ts +29 -0
  20. package/src/http-request-state/directives/index.ts +5 -0
  21. package/src/http-request-state/directives/request-state-directive.spec.ts +73 -0
  22. package/src/http-request-state/directives/request-state-directive.ts +78 -0
  23. package/src/http-request-state/documentation/CREATE-REQUESTOR.md +667 -0
  24. package/src/http-request-state/documentation/README.md +191 -0
  25. package/src/http-request-state/documentation/REQUEST-STATE-STORE-CONFIG.md +648 -0
  26. package/src/http-request-state/documentation/REQUESTOR.md +616 -0
  27. package/src/http-request-state/helpers.ts +30 -0
  28. package/src/http-request-state/http-state-module.ts +23 -0
  29. package/src/http-request-state/index.ts +7 -0
  30. package/src/http-request-state/models/view-context.ts +18 -0
  31. package/src/http-request-state/observable.spec.ts +43 -0
  32. package/src/http-request-state/request-state.ts +66 -0
  33. package/src/http-request-state/rxjs/getRequestorBody.ts +10 -0
  34. package/src/http-request-state/rxjs/getRequestorState.ts +8 -0
  35. package/src/http-request-state/rxjs/index.ts +4 -0
  36. package/src/http-request-state/rxjs/tapError.ts +16 -0
  37. package/src/http-request-state/rxjs/tapSuccess.ts +16 -0
  38. package/src/http-request-state/strategies.spec.ts +42 -0
  39. package/src/http-request-state/types.ts +54 -0
  40. package/src/ngrx/actionable-selector.ts +189 -0
  41. package/src/ngrx/index.ts +1 -0
  42. package/src/public-api.ts +40 -0
  43. package/src/rxjs/defaultShareReplay.ts +8 -0
  44. package/src/rxjs/index.ts +5 -0
  45. package/src/rxjs/mapError.ts +8 -0
  46. package/src/rxjs/rxjs-operators.ts +130 -0
  47. package/src/rxjs/subjectifier.ts +17 -0
  48. package/src/rxjs/subscriber.directive.ts +57 -0
  49. package/src/specs/clickSubject.spec.ts +99 -0
  50. package/src/specs/dialog.spec.ts +101 -0
  51. package/src/specs/toggleGroupDirective.spec.ts +229 -0
  52. package/src/table-builder/classes/DefaultSettings.ts +11 -0
  53. package/src/table-builder/classes/MatTableObservableDataSource.ts +23 -0
  54. package/src/table-builder/classes/TableBuilderConfig.ts +49 -0
  55. package/src/table-builder/classes/TableBuilderDataSource.ts +64 -0
  56. package/src/table-builder/classes/TableState.ts +96 -0
  57. package/src/table-builder/classes/data-store.ts +10 -0
  58. package/src/table-builder/classes/display-col.ts +5 -0
  59. package/src/table-builder/classes/filter-info.ts +129 -0
  60. package/src/table-builder/classes/table-builder-general-settings.ts +233 -0
  61. package/src/table-builder/classes/table-builder.ts +105 -0
  62. package/src/table-builder/classes/table-store.helpers.ts +109 -0
  63. package/src/table-builder/classes/table-store.ts +540 -0
  64. package/src/table-builder/components/array-column.component.ts +34 -0
  65. package/src/table-builder/components/column-builder/column-builder.component.html +109 -0
  66. package/src/table-builder/components/column-builder/column-builder.component.scss +43 -0
  67. package/src/table-builder/components/column-builder/column-builder.component.spec.ts +49 -0
  68. package/src/table-builder/components/column-builder/column-builder.component.ts +130 -0
  69. package/src/table-builder/components/column-builder/column-helpers.ts +54 -0
  70. package/src/table-builder/components/column-header-menu/column-header-menu.component.html +128 -0
  71. package/src/table-builder/components/column-header-menu/column-header-menu.component.scss +97 -0
  72. package/src/table-builder/components/column-header-menu/column-header-menu.component.ts +113 -0
  73. package/src/table-builder/components/date-filter/date-filter.component.html +39 -0
  74. package/src/table-builder/components/date-filter/date-filter.component.ts +33 -0
  75. package/src/table-builder/components/date-time-filter/date-time-filter.component.html +25 -0
  76. package/src/table-builder/components/date-time-filter/date-time-filter.component.ts +33 -0
  77. package/src/table-builder/components/filter/filter.component.html +120 -0
  78. package/src/table-builder/components/filter/filter.component.scss +60 -0
  79. package/src/table-builder/components/filter/filter.component.spec.ts +86 -0
  80. package/src/table-builder/components/filter/filter.component.ts +73 -0
  81. package/src/table-builder/components/filter/in-list/in-list-filter.component.ts +171 -0
  82. package/src/table-builder/components/gen-col-displayer/gen-col-displayer.component.html +60 -0
  83. package/src/table-builder/components/gen-col-displayer/gen-col-displayer.component.scss +57 -0
  84. package/src/table-builder/components/gen-col-displayer/gen-col-displayer.component.ts +44 -0
  85. package/src/table-builder/components/generic-table/generic-table.component.html +140 -0
  86. package/src/table-builder/components/generic-table/generic-table.component.scss +45 -0
  87. package/src/table-builder/components/generic-table/generic-table.component.ts +531 -0
  88. package/src/table-builder/components/generic-table/paginator.component.ts +125 -0
  89. package/src/table-builder/components/group-by-list/group-by-list.component.css +24 -0
  90. package/src/table-builder/components/group-by-list/group-by-list.component.html +21 -0
  91. package/src/table-builder/components/group-by-list/group-by-list.component.spec.ts +23 -0
  92. package/src/table-builder/components/group-by-list/group-by-list.component.ts +26 -0
  93. package/src/table-builder/components/in-filter/in-filter.component.css +22 -0
  94. package/src/table-builder/components/in-filter/in-filter.component.html +38 -0
  95. package/src/table-builder/components/in-filter/in-filter.component.ts +66 -0
  96. package/src/table-builder/components/index.ts +9 -0
  97. package/src/table-builder/components/initialization-component/initialization.component.html +78 -0
  98. package/src/table-builder/components/initialization-component/initialization.component.ts +28 -0
  99. package/src/table-builder/components/link-column.component.ts +42 -0
  100. package/src/table-builder/components/number-filter/number-filter.component.css +10 -0
  101. package/src/table-builder/components/number-filter/number-filter.component.html +32 -0
  102. package/src/table-builder/components/number-filter/number-filter.component.spec.ts +30 -0
  103. package/src/table-builder/components/number-filter/number-filter.component.ts +34 -0
  104. package/src/table-builder/components/profiles-menu/profiles-menu.component.html +77 -0
  105. package/src/table-builder/components/profiles-menu/profiles-menu.component.scss +126 -0
  106. package/src/table-builder/components/profiles-menu/profiles-menu.component.spec.ts +23 -0
  107. package/src/table-builder/components/profiles-menu/profiles-menu.component.ts +64 -0
  108. package/src/table-builder/components/reset-menu/reset-menu.component.css +3 -0
  109. package/src/table-builder/components/reset-menu/reset-menu.component.html +10 -0
  110. package/src/table-builder/components/reset-menu/reset-menu.component.ts +87 -0
  111. package/src/table-builder/components/scroll-strategy.ts +139 -0
  112. package/src/table-builder/components/sort-menu/sort-menu.component-store.ts +57 -0
  113. package/src/table-builder/components/sort-menu/sort-menu.component.html +115 -0
  114. package/src/table-builder/components/sort-menu/sort-menu.component.scss +119 -0
  115. package/src/table-builder/components/sort-menu/sort-menu.component.ts +88 -0
  116. package/src/table-builder/components/table-container/table-container.component.html +94 -0
  117. package/src/table-builder/components/table-container/table-container.component.scss +60 -0
  118. package/src/table-builder/components/table-container/table-container.component.ts +467 -0
  119. package/src/table-builder/components/table-container/table-container.helpers/data-state.helpers.ts +113 -0
  120. package/src/table-builder/components/table-container/table-container.helpers/filter-state.helpers.ts +125 -0
  121. package/src/table-builder/components/table-container/table-container.helpers/groupBy.helpers.ts +172 -0
  122. package/src/table-builder/components/table-container/table-container.helpers/meta-data.helpers.ts +19 -0
  123. package/src/table-builder/components/table-container/table-container.helpers/sort-state.helpers.ts +47 -0
  124. package/src/table-builder/components/table-container/tableProps.ts +21 -0
  125. package/src/table-builder/components/table-container/virtual-scroll-container.ts +216 -0
  126. package/src/table-builder/components/table-container-filter/filter-list/filter-list.component.html +42 -0
  127. package/src/table-builder/components/table-container-filter/filter-list/filter-list.component.ts +47 -0
  128. package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.css +40 -0
  129. package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.html +11 -0
  130. package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.spec.ts +85 -0
  131. package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.ts +35 -0
  132. package/src/table-builder/components/table-container-filter/table-wrapper-filter-store.ts +13 -0
  133. package/src/table-builder/components/table-header-menu/table-header-menu.component.css +21 -0
  134. package/src/table-builder/components/table-header-menu/table-header-menu.component.html +48 -0
  135. package/src/table-builder/components/table-header-menu/table-header-menu.component.ts +36 -0
  136. package/src/table-builder/directives/custom-cell-directive.ts +63 -0
  137. package/src/table-builder/directives/custom-header-directive.ts +16 -0
  138. package/src/table-builder/directives/group-row-directive.ts +91 -0
  139. package/src/table-builder/directives/index.ts +8 -0
  140. package/src/table-builder/directives/multi-sort.directive.spec.ts +124 -0
  141. package/src/table-builder/directives/multi-sort.directive.ts +58 -0
  142. package/src/table-builder/directives/resize-column.directive.ts +107 -0
  143. package/src/table-builder/directives/table-wrapper.directive.ts +13 -0
  144. package/src/table-builder/directives/tb-filter.directive.ts +376 -0
  145. package/src/table-builder/documentation/table-builder/CUSTOM-CELL.md +568 -0
  146. package/src/table-builder/documentation/table-builder/CUSTOM-GROUP-ROW.md +356 -0
  147. package/src/table-builder/documentation/table-builder/METADATA-DOCUMENTATION.md +517 -0
  148. package/src/table-builder/documentation/table-builder/STYLER-STYLE.md +228 -0
  149. package/src/table-builder/documentation/table-builder/TABLE-BUILDER-CONFIG.md +325 -0
  150. package/src/table-builder/documentation/table-builder/TABLE-BUILDER-SETTINGS.md +515 -0
  151. package/src/table-builder/documentation/table-builder/TABLE-BUILDER.md +430 -0
  152. package/src/table-builder/documentation/table-builder/TABLE-CONTAINER.md +628 -0
  153. package/src/table-builder/enums/filterTypes.ts +39 -0
  154. package/src/table-builder/functions/boolean-filter-function.ts +12 -0
  155. package/src/table-builder/functions/date-filter-function.ts +85 -0
  156. package/src/table-builder/functions/download-data.ts +11 -0
  157. package/src/table-builder/functions/null-filter-function.ts +9 -0
  158. package/src/table-builder/functions/number-filter-function.ts +47 -0
  159. package/src/table-builder/functions/sort-data-function.ts +80 -0
  160. package/src/table-builder/functions/string-filter-function.ts +59 -0
  161. package/src/table-builder/interfaces/ColumnInfo.ts +9 -0
  162. package/src/table-builder/interfaces/dictionary.ts +3 -0
  163. package/src/table-builder/interfaces/meta-data.ts +279 -0
  164. package/src/table-builder/ngrx/tableBuilderStateStore.ts +203 -0
  165. package/src/table-builder/pipes/column-total.pipe.ts +16 -0
  166. package/src/table-builder/pipes/format-filter-type.pipe.ts +12 -0
  167. package/src/table-builder/pipes/format-filter-value.pipe.ts +71 -0
  168. package/src/table-builder/pipes/key-display.ts +13 -0
  169. package/src/table-builder/services/all-values-filter-creator.service.ts +92 -0
  170. package/src/table-builder/services/export-to-csv.service.ts +117 -0
  171. package/src/table-builder/services/link-creator.service.ts +98 -0
  172. package/src/table-builder/services/table-template-service.ts +47 -0
  173. package/src/table-builder/services/transform-creator.ts +90 -0
  174. package/src/table-builder/specs/table-custom-filters.spec.ts +262 -0
  175. package/src/table-builder/styles/collapser.styles.scss +16 -0
  176. package/src/table-builder/table-builder.module.ts +42 -0
  177. package/src/table-builder/types/group-types.ts +42 -0
  178. package/src/table-builder/types/index.ts +1 -0
  179. package/src/test.ts +17 -0
  180. package/src/utilities/array-helpers.ts +13 -0
  181. package/src/utilities/directives/auto-focus.directive.ts +20 -0
  182. package/src/utilities/directives/clickEmitterDirective.ts +15 -0
  183. package/src/utilities/directives/clickSubject.ts +19 -0
  184. package/src/utilities/directives/conditional-classes.directive.ts +36 -0
  185. package/src/utilities/directives/dialog-service.ts +19 -0
  186. package/src/utilities/directives/dialog.ts +174 -0
  187. package/src/utilities/directives/mat-toggle-group-directive.ts +60 -0
  188. package/src/utilities/directives/prevent-enter.directive.ts +12 -0
  189. package/src/utilities/directives/stop-propagation.directive.ts +19 -0
  190. package/src/utilities/directives/styler.ts +45 -0
  191. package/src/utilities/directives/trim-whitespace.directive.ts +20 -0
  192. package/src/utilities/index.ts +22 -0
  193. package/src/utilities/module.ts +53 -0
  194. package/src/utilities/pipes/function.pipe.ts +21 -0
  195. package/src/utilities/pipes/phone.pipe.ts +20 -0
  196. package/src/utilities/pipes/space-case.pipes.spec.ts +47 -0
  197. package/src/utilities/pipes/space-case.pipes.ts +29 -0
  198. package/tsconfig.lib.json +20 -0
  199. package/tsconfig.lib.prod.json +10 -0
  200. package/tsconfig.spec.json +17 -0
  201. package/fesm2022/one-paragon-angular-utilities.mjs +0 -7328
  202. package/fesm2022/one-paragon-angular-utilities.mjs.map +0 -1
  203. package/types/one-paragon-angular-utilities.d.ts +0 -2197
@@ -0,0 +1,47 @@
1
+ import { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core';
2
+ import { TableStore } from '../../../classes/table-store';
3
+ import { CustomFilter, FilterInfo, isCustomFilter, isFilterInfo } from '../../../classes/filter-info';
4
+ import { WrapperFilterStore } from '../table-wrapper-filter-store';
5
+ import { MatButtonModule } from '@angular/material/button';
6
+ import { MatTooltipModule } from '@angular/material/tooltip';
7
+ import { MatIconModule } from '@angular/material/icon';
8
+ import { FilterComponent } from '../../filter/filter.component';
9
+ import { MatChipsModule } from '@angular/material/chips';
10
+ import { KeyDisplayPipe } from '../../../pipes/key-display';
11
+ import { FormatFilterTypePipe } from '../../../pipes/format-filter-type.pipe';
12
+ import { FormatFilterValuePipe } from '../../../pipes/format-filter-value.pipe';
13
+
14
+ @Component({
15
+ selector: 'lib-filter-list',
16
+ templateUrl: './filter-list.component.html',
17
+ styleUrls: ['../gen-filter-displayer/gen-filter-displayer.component.css'],
18
+ changeDetection: ChangeDetectionStrategy.OnPush,
19
+ imports: [
20
+ MatButtonModule, MatTooltipModule, MatIconModule, FilterComponent,
21
+ MatChipsModule, KeyDisplayPipe, FormatFilterTypePipe, FormatFilterValuePipe
22
+ ]
23
+ })
24
+ export class FilterChipsComponent {
25
+
26
+ tableState = inject(TableStore);
27
+ filterStore = inject(WrapperFilterStore);
28
+
29
+ $filters = computed(() =>
30
+ this.tableState.$filtersArray().filter(f => isFilterInfo(f) && !f._isExternallyManaged) as FilterInfo[]);
31
+ $certainCustomFilters = computed(() =>
32
+ this.tableState.$filtersArray().filter(f => isCustomFilter(f) && f.chipLabel) as CustomFilter[]);
33
+
34
+ deleteByIndex(index: number) {
35
+ this.filterStore.deleteByIndex(index);
36
+ }
37
+
38
+ addFilter(filter:FilterInfo<any>){
39
+ this.filterStore.addFilter(filter);
40
+ }
41
+
42
+ clearAll() {
43
+ this.filterStore.clearAll();
44
+ }
45
+
46
+ $currentFilters = this.filterStore.$filters;
47
+ }
@@ -0,0 +1,40 @@
1
+ .filter {
2
+ margin: 15px;
3
+ display: inline-block;
4
+ }
5
+ .filter-button {
6
+ font-size: 22px;
7
+ font-weight: 700;
8
+ }
9
+
10
+ .cancel-button {
11
+ margin-right: 30px;
12
+ font-weight: 700;
13
+ }
14
+ .filter-wrapper{
15
+ margin-top: 1em;
16
+ margin-bottom: 1em;
17
+ float: right;
18
+ }
19
+ .menu {
20
+ margin-bottom: 10px;
21
+ width: 109.1%;
22
+ }
23
+
24
+ .filter-labels {
25
+ font-size: 17px;
26
+ font-weight: 600;
27
+ }
28
+ .float{
29
+ position: absolute;
30
+ width: fit-content;
31
+ z-index: 101;
32
+ top: 10px;
33
+ right: 180px;
34
+ max-width: 90vw;
35
+ }
36
+ .d-w{
37
+ display: flex;
38
+ flex-direction: row;
39
+ justify-content: flex-end;
40
+ }
@@ -0,0 +1,11 @@
1
+ <button color="primary" stop-propagation class="filter-button" mat-icon-button [matMenuTriggerFor]="menu" [matTooltip]="'Add Filter'">
2
+ <mat-icon class="filter-icon" color="primary">filter_list</mat-icon>
3
+ </button>
4
+ <mat-menu #menu="matMenu">
5
+ @for (md of $filterCols(); track md.key)
6
+ {
7
+ <button mat-menu-item (click)="addFilter(md)">
8
+ <span class="filter-labels">{{md.displayName || (md.key | spaceCase)}}</span>
9
+ </button>
10
+ }
11
+ </mat-menu>
@@ -0,0 +1,85 @@
1
+ import { firstValueFrom, of } from 'rxjs';
2
+ import { map } from 'rxjs/operators';
3
+ import { TestBed, ComponentFixture, ComponentFixtureAutoDetect, tick, fakeAsync, flush } from '@angular/core/testing';
4
+ import { GenFilterDisplayerComponent } from './gen-filter-displayer.component';
5
+ import { SpaceCasePipe } from '../../../../utilities/pipes/space-case.pipes';
6
+ import { FilterComponent } from '../../filter/filter.component';
7
+ import { CommonModule } from '@angular/common';
8
+ import { FormsModule } from '@angular/forms';
9
+ import { FieldType } from '../../../interfaces/meta-data';
10
+ import { By } from '@angular/platform-browser';
11
+ import { NoopAnimationsModule } from '@angular/platform-browser/animations';
12
+ import { DateFilterComponent } from '../../date-filter/date-filter.component';
13
+ import { TableBuilderModule } from '../../../table-builder.module';
14
+ import { StoreModule } from '@ngrx/store';
15
+ import { EffectsModule } from '@ngrx/effects';
16
+ import { TableStore } from '../../../classes/table-store';
17
+ import { WrapperFilterStore } from '../table-wrapper-filter-store';
18
+
19
+
20
+ function getMetaData() {
21
+ return of([
22
+ {
23
+ key: 'name',
24
+ displayName: 'first name',
25
+ fieldType: FieldType.String,
26
+ additional: {},
27
+ order: 1
28
+ },
29
+ {
30
+ key: 'last',
31
+ displayName: 'last name',
32
+ fieldType: FieldType.String,
33
+ additional: {},
34
+ order: 2
35
+ }
36
+ ]);
37
+ }
38
+
39
+ describe('generic filter displayer', () => {
40
+ let fixture: ComponentFixture<GenFilterDisplayerComponent>;
41
+ let component: GenFilterDisplayerComponent;
42
+
43
+ const clickFilter = (idx: number) => {
44
+ const btn = fixture.debugElement.query(By.css('.filter-button')).nativeElement;
45
+
46
+ btn.click();
47
+ const menu = fixture.debugElement.queryAll(By.css('.mat-menu-item'));
48
+ menu[idx].nativeElement.click();
49
+ };
50
+ beforeEach(() => {
51
+
52
+ TestBed.configureTestingModule({
53
+ declarations: [
54
+ GenFilterDisplayerComponent,
55
+ SpaceCasePipe,
56
+ FilterComponent,
57
+ DateFilterComponent,
58
+ ],
59
+ providers: [TableStore, WrapperFilterStore,
60
+ { provide: ComponentFixtureAutoDetect, useValue: true }
61
+ ],
62
+ imports: [
63
+ NoopAnimationsModule,
64
+ CommonModule,
65
+ FormsModule,
66
+ TableBuilderModule.forRoot({ defaultTableSettings: { } }),
67
+ StoreModule.forRoot({}),
68
+ EffectsModule.forRoot([])]
69
+ })
70
+ .compileComponents();
71
+ fixture = TestBed.createComponent(GenFilterDisplayerComponent);
72
+ component = fixture.componentInstance;
73
+ });
74
+
75
+ it('should get the generic filter displayer component', () => {
76
+ expect(component).toBeDefined();
77
+ });
78
+
79
+ it('should be able to create a filter', async () => {
80
+ clickFilter(0);
81
+ const filter = await firstValueFrom(fixture.componentInstance.filterStore.state$.pipe(map(x => x.filterInfo)));
82
+ expect(filter.length).toBe(1);
83
+ });
84
+
85
+ });
@@ -0,0 +1,35 @@
1
+ import { Component, ChangeDetectionStrategy, inject, computed } from '@angular/core';
2
+ import { MetaData, FieldType } from '../../../interfaces/meta-data';
3
+ import { TableStore } from '../../../classes/table-store';
4
+ import { WrapperFilterStore } from '../table-wrapper-filter-store';
5
+ import { MatButtonModule } from '@angular/material/button';
6
+ import { MatMenuModule } from '@angular/material/menu';
7
+ import { MatTooltipModule } from '@angular/material/tooltip';
8
+ import { SpaceCasePipe, StopPropagationDirective } from '../../../../utilities';
9
+ import { MatIconModule } from '@angular/material/icon';
10
+
11
+ @Component({
12
+ selector: 'tb-filter-displayer',
13
+ templateUrl: './gen-filter-displayer.component.html',
14
+ styleUrls: ['./gen-filter-displayer.component.css'],
15
+ changeDetection: ChangeDetectionStrategy.OnPush,
16
+ imports: [
17
+ MatButtonModule, MatMenuModule, MatTooltipModule, StopPropagationDirective, MatIconModule,
18
+ SpaceCasePipe
19
+ ]
20
+ })
21
+ export class GenFilterDisplayerComponent {
22
+ protected tableState = inject(TableStore);
23
+ protected filterStore = inject(WrapperFilterStore);
24
+ $filterCols = computed(() => {
25
+ const mds = this.tableState.$metaDataArray();
26
+ return mds.filter(m => m.fieldType !== FieldType.Hidden && (m.fieldType !== FieldType.NotMapped || m.filterLogic?.filterBy) && !m.noFilter);
27
+ });
28
+
29
+ addFilter(metaData: MetaData) {
30
+ this.filterStore.addFilter({
31
+ key: metaData.key,
32
+ fieldType: metaData.filterLogic?.filterType || metaData.fieldType,
33
+ });
34
+ }
35
+ }
@@ -0,0 +1,13 @@
1
+ import { Injectable, signal } from "@angular/core";
2
+ import { PartialFilter } from "../../classes/filter-info";
3
+ @Injectable()
4
+ export class WrapperFilterStore {
5
+ $filters = signal<PartialFilter[]>([]);
6
+
7
+ clearAll = () => this.$filters.set([]);
8
+ deleteByIndex = (index: number) => this.$filters.update(filters => filters.toSpliced(index, 1))
9
+
10
+ addFilter = (filter: PartialFilter) => {
11
+ this.$filters.update(filters => [...filters, filter]);
12
+ }
13
+ }
@@ -0,0 +1,21 @@
1
+ .input {
2
+ appearance: none;
3
+ outline: none;
4
+ background: none;
5
+ box-shadow: none;
6
+ padding: 0;
7
+ margin: 0;
8
+ font: inherit;
9
+ color: inherit;
10
+ border: 1px solid black;
11
+ border-radius: 4px;
12
+ width: 50px;
13
+ padding-left: 4px;
14
+ &::placeholder{
15
+ font-size: 12px;
16
+ }
17
+ }
18
+ .height-input-wrapper{
19
+ display: flex;
20
+ gap: 4px;
21
+ }
@@ -0,0 +1,48 @@
1
+ <span [matTooltip]="!r.$set().length ? 'Nothing To Reset' : ''">
2
+ <button #d="matMenuItem" mat-menu-item [matMenuTriggerFor]="r.menu()" [disabled]="!r.$set().length">
3
+ <mat-icon color="primary">autorenew</mat-icon>
4
+ <span>Reset</span>
5
+ </button>
6
+ </span>
7
+ @if (!tableContainer.state.$tableSettings().hideExport)
8
+ {
9
+ <button mat-menu-item (click)="exportToCsv()">
10
+ <mat-icon color="primary">file_download</mat-icon>
11
+ <span>Export Table</span>
12
+ </button>
13
+ }
14
+ @if (tableContainer.$tableId(); as tableId)
15
+ {
16
+ <button stop-propagation mat-menu-item [matMenuTriggerFor]="pm.menu()">
17
+ <mat-icon color="primary">people</mat-icon>
18
+ <span>Profiles</span>
19
+ </button>
20
+ <tb-profiles-menu #pm class="profiles-menu" [tableId]="tableId" [isMatMenuChild]="true" />
21
+ }
22
+
23
+
24
+ <div mat-menu-item>
25
+ <div class="height-input-wrapper">
26
+ <span>Row Height</span>
27
+ <input #i class="input" stop-propagation type="number"
28
+ placeholder="Set Size"
29
+ [value]="$rowHeightNum()"
30
+ [min]="10"
31
+ [max]="100" (change)="updateHeight('row', i)" />
32
+ </div>
33
+ </div>
34
+ @if(!state.$tableSettings().hideHeader)
35
+ {
36
+ <div mat-menu-item>
37
+ <div class="height-input-wrapper">
38
+ <span>Header Height</span>
39
+ <input #i2 class="input" stop-propagation type="number"
40
+ placeholder="Set Size"
41
+ [value]="$headerHeightNum()"
42
+ [min]="10"
43
+ [max]="100" (change)="updateHeight('header', i2)"/>
44
+ </div>
45
+ </div>
46
+ }
47
+ <lib-reset-menu #r/>
48
+
@@ -0,0 +1,36 @@
1
+ import { Component, computed, inject, viewChild, ChangeDetectionStrategy } from '@angular/core';
2
+ import { MatIcon } from '@angular/material/icon';
3
+ import { MatMenu, MatMenuModule } from '@angular/material/menu';
4
+ import { TableContainerComponent } from '../table-container/table-container.component';
5
+ import { ExportToCsvService } from '../../services/export-to-csv.service';
6
+ import { ProfilesMenuComponent } from "../profiles-menu/profiles-menu.component";
7
+ import { ResetMenuComponent } from "../reset-menu/reset-menu.component";
8
+ import { MatTooltip } from '@angular/material/tooltip';
9
+ import { StopPropagationDirective } from '../../../utilities';
10
+
11
+ @Component({
12
+ selector: 'lib-table-header-menu',
13
+ imports: [MatMenuModule, MatIcon, ProfilesMenuComponent, ResetMenuComponent, MatTooltip, StopPropagationDirective],
14
+ templateUrl: './table-header-menu.component.html',
15
+ styleUrl: './table-header-menu.component.css',
16
+ changeDetection: ChangeDetectionStrategy.OnPush
17
+ })
18
+ export class TableHeaderMenuComponent {
19
+ menu = viewChild.required(MatMenu);
20
+ private exportToCsvService = inject(ExportToCsvService);
21
+ protected tableContainer = inject(TableContainerComponent);
22
+ state = this.tableContainer.state;
23
+ $rowHeightNum = computed(() => +(this.tableContainer.$genericTable()?.$rowHeight()?.replace('px', '') || 0) || undefined);
24
+ $headerHeightNum = computed(() => +(this.tableContainer.$genericTable()?.$headerHeight()?.replace('px', '') || 0) || undefined);
25
+ protected exportToCsv(): void {
26
+ this.exportToCsvService.exportToCsv(this.tableContainer.$data());
27
+ }
28
+
29
+ updateHeight(v: 'row' | 'header', element: HTMLInputElement){
30
+ if(+element.value < 10) element.value = '10';
31
+ if(+element.value > 100) element.value = '100';
32
+ if(v === 'row') this.state.setUserDefinedRowHeight(+element.value);
33
+ if(v === 'header') this.state.setUserDefinedHeaderHeight(+element.value);
34
+ }
35
+
36
+ }
@@ -0,0 +1,63 @@
1
+ import { Directive, TemplateRef, inject, input, computed, signal, OnInit } from '@angular/core';
2
+ import { CdkColumnDef } from '@angular/cdk/table';
3
+ import { CustomCellMeta, FieldType, SortDef } from '../interfaces/meta-data';
4
+ import { TableBuilder } from '../classes/table-builder';
5
+ import { coerceBooleanProperty } from '@angular/cdk/coercion';
6
+ import { StylerStyle } from '../../utilities/directives/styler';
7
+
8
+ interface CustomCellContext<T> {
9
+ $implicit: T,
10
+ element: T,
11
+ }
12
+ // here is how to use it
13
+ // <generic-table [report]="report">
14
+ // <p *customCell="'column1'; let element = element" [class.makeMeRed]="element?.port">If Port, i will be red</p>
15
+ // <p *customCell="'column2'">I am custom cell two </p>
16
+ // </generic-table>
17
+ @Directive({ selector: '[customCell]' })
18
+ export class CustomCellDirective<T = any> implements OnInit {
19
+ private templateRef = inject<TemplateRef<any>>(TemplateRef, { optional: true });
20
+ public columnDef = inject(CdkColumnDef, { optional: true });
21
+ $customCell = input.required<string>({ alias: 'customCell' });
22
+ $displayName = input<string | undefined>(undefined, { alias: 'customCellDisplayName' });
23
+ $preSort = input<SortDef | undefined>(undefined, { alias: 'preSort' });
24
+ $templateRef = input<TemplateRef<any> | undefined>(this.templateRef || undefined, { alias: 'templateRef' });
25
+ $customCellOrder = input<number | undefined>(undefined, { alias: 'customCellOrder' });
26
+ $customCellWidth = input<string | undefined>(undefined, { alias: 'customCellWidth' });
27
+ /**
28
+ * for type safety, this is a reference to the table builder instance.
29
+ */
30
+ $customCellTableRef = input<TableBuilder<T> | undefined>(undefined, { alias: 'customCellTableRef' });
31
+ /**
32
+ * true if column not mapped to a property in the data source. Default is false.
33
+ */
34
+ $customCellNotMapped = input(false, { alias: 'customCellNotMapped', transform: coerceBooleanProperty });
35
+ /**
36
+ * Styles to apply to the cell element
37
+ */
38
+ $customCellCellStyles = input<StylerStyle<T>>(undefined, { alias: 'customCellCellStyles' });
39
+ $metaData = computed((): CustomCellMeta | undefined => {
40
+ const c = this.$customCell();
41
+ if(!c) return;
42
+ return ({
43
+ key: this.$customCell(),
44
+ displayName: this.$displayName(),
45
+ preSort: this.$preSort(),
46
+ fieldType: this.$customCellNotMapped() ? FieldType.NotMapped : FieldType.Unknown,
47
+ order: this.$customCellOrder(),
48
+ width: this.$customCellWidth(),
49
+ customCell: true,
50
+ noExport: true,
51
+ additional: { styles: this.$customCellCellStyles() },
52
+ })
53
+ });
54
+ $inited = signal(false);
55
+
56
+ ngOnInit(){
57
+ this.$inited.set(true);
58
+ }
59
+
60
+ static ngTemplateContextGuard<T>(dir: CustomCellDirective<T>, ctx: any): ctx is CustomCellContext<T> {
61
+ return true;
62
+ }
63
+ }
@@ -0,0 +1,16 @@
1
+ import { Directive, TemplateRef, inject, input, signal, OnInit } from '@angular/core';
2
+
3
+ @Directive({ selector: '[customHeader]' })
4
+ export class CustomHeaderDirective<T = any> implements OnInit {
5
+ private templateRef = inject<TemplateRef<any>>(TemplateRef);
6
+
7
+ $customHeader = input.required<string>({ alias: 'customHeader' });
8
+
9
+ $inited = signal(false);
10
+
11
+ template = () => this.templateRef;
12
+
13
+ ngOnInit() {
14
+ this.$inited.set(true);
15
+ }
16
+ }
@@ -0,0 +1,91 @@
1
+ import { Directive, TemplateRef, inject, input, computed, signal, OnInit } from '@angular/core';
2
+ import { TableBuilder } from '../classes/table-builder';
3
+ import { Group } from '../types/group-types';
4
+ import { Path } from '../interfaces/meta-data';
5
+
6
+ interface CustomGroupRowContext<T> {
7
+ $implicit: Group<T>;
8
+ element: T;
9
+ expanded: boolean;
10
+ level: number;
11
+ key: string;
12
+ uniqueName: string;
13
+ groupHeaderDisplay: string;
14
+ length: number;
15
+ padding: number;
16
+ }
17
+
18
+ // Usage examples:
19
+ // <!-- Custom group row for all groupings -->
20
+ // <div *customGroupRow="let group">
21
+ // Custom template for: {{group.groupHeaderDisplay}} ({{group.length}} items)
22
+ // </div>
23
+ //
24
+ // <!-- Custom group row only for specific grouping key -->
25
+ // <div *customGroupRow="'category'; let group">
26
+ // Category: {{group.groupHeaderDisplay}} - {{group.length}} products
27
+ // </div>
28
+ //
29
+ // <!-- Custom group row for multiple grouping keys -->
30
+ // <div *customGroupRow="['category', 'status']; let group">
31
+ // Multi-key template: {{group.groupHeaderDisplay}} ({{group.length}} items)
32
+ // </div>
33
+ @Directive({ selector: '[customGroupRow]' })
34
+ export class CustomGroupRowDirective<T = any> implements OnInit {
35
+ private templateRef = inject<TemplateRef<any>>(TemplateRef);
36
+
37
+ /**
38
+ * Optional grouping key(s). If provided, this custom row will only apply when data is grouped by this key or keys.
39
+ * If not provided (or null), this custom row will apply to all groupings.
40
+ * Can be a single Path<T> or an array of Path<T> values.
41
+ */
42
+ $customGroupRow = input(null, { alias: 'customGroupRow', transform: (val: Path<T> | Path<T>[] | null | '') => val === '' ? null : val });
43
+
44
+ /**
45
+ * For type safety, this is a reference to the table builder instance.
46
+ */
47
+ $customGroupRowTableRef = input<TableBuilder<T> | undefined>(undefined, { alias: 'customGroupRowTableRef' });
48
+
49
+ /**
50
+ * Priority order for this custom group row. Higher numbers have higher priority.
51
+ * Useful when multiple custom group rows could apply to the same grouping.
52
+ */
53
+ $priority = input<number>(0, { alias: 'customGroupRowPriority' });
54
+
55
+ $inited = signal(false);
56
+
57
+ /**
58
+ * Gets the grouping key(s) this directive applies to, or null for all groupings
59
+ */
60
+ $groupingKey = computed(() => this.$customGroupRow());
61
+
62
+ /**
63
+ * Gets the template reference to use
64
+ */
65
+ template = () => this.templateRef;
66
+
67
+ ngOnInit() {
68
+ this.$inited.set(true);
69
+ }
70
+
71
+ /**
72
+ * Type guard for template context
73
+ */
74
+ static ngTemplateContextGuard<T>(dir: CustomGroupRowDirective<T>, ctx: any): ctx is CustomGroupRowContext<T> {
75
+ return true;
76
+ }
77
+
78
+ /**
79
+ * Checks if this directive applies to the given grouping key
80
+ */
81
+ appliesTo(groupingKey: string): boolean {
82
+ const targetKey = this.$groupingKey();
83
+ if(targetKey === null) {
84
+ return true; // Apply to all groupings
85
+ }
86
+ if(Array.isArray(targetKey)) {
87
+ return targetKey.includes(groupingKey as Path<T>);
88
+ }
89
+ return targetKey === groupingKey;
90
+ }
91
+ }
@@ -0,0 +1,8 @@
1
+ export * from './custom-cell-directive';
2
+ export * from './custom-header-directive';
3
+ export * from './group-row-directive';
4
+ export * from './multi-sort.directive';
5
+ export * from './resize-column.directive';
6
+ export * from './table-wrapper.directive';
7
+ export * from './tb-filter.directive';
8
+
@@ -0,0 +1,124 @@
1
+ import { MultiSortDirective } from './multi-sort.directive';
2
+ import { Sort, MatSortable } from '@angular/material/sort';
3
+ import { FieldType } from '../interfaces/meta-data';
4
+ import { TableBuilderConfigToken } from '../classes/TableBuilderConfig';
5
+ import { DatePipe } from '@angular/common';
6
+ import { TestBed } from '@angular/core/testing';
7
+ import { StoreModule } from '@ngrx/store';
8
+ import { storageStateReducer } from '../ngrx/reducer';
9
+ import { TableStore } from '../classes/table-store';
10
+
11
+ describe('MultiSortDirective', () => {
12
+
13
+ let directive: MultiSortDirective;
14
+ let rules: Sort[];
15
+
16
+ const data = [
17
+ {
18
+ name: 'Joe',
19
+ age: 10,
20
+ balance: 25
21
+ },
22
+ {
23
+ name: 'Jane',
24
+ age: 20,
25
+ balance: 35
26
+ }
27
+ ];
28
+ const metaData = [
29
+ {
30
+ key: 'name',
31
+ fieldType: FieldType.String,
32
+ additional: {},
33
+ order: 1
34
+ },
35
+ {
36
+ key: 'age',
37
+ fieldType: FieldType.Number,
38
+ additional: {},
39
+ order: 2
40
+ },
41
+ {
42
+ key: 'balance',
43
+ fieldType: FieldType.Number,
44
+ additional: {},
45
+ order: 3
46
+ }
47
+ ];
48
+
49
+ const initialState = { fullTableState: {
50
+ 'test-id': {
51
+ metaData,
52
+ hiddenKeys: [],
53
+ pageSize: 10,
54
+ initialized: true,
55
+ filters: [],
56
+ sorted: [],
57
+ }
58
+ } };
59
+
60
+ beforeEach(() => {
61
+ TestBed.resetTestingModule();
62
+ rules = [];
63
+ TestBed.configureTestingModule({
64
+ declarations: [],
65
+ providers: [
66
+ { provide: TableBuilderConfigToken, useValue: { defaultTableState: { } } },
67
+ DatePipe,
68
+ TableStore
69
+ ],
70
+ imports: [
71
+ StoreModule.forRoot({ 'fullTableState': storageStateReducer }),
72
+ ],
73
+ teardown: { destroyAfterEach: true }
74
+ })
75
+ .compileComponents();
76
+
77
+ const store = TestBed.inject(TableStore);
78
+ // stateManager.upda ..tableId = 'test-id';
79
+ // stateManager.initializeState();
80
+ directive = new MultiSortDirective(store);
81
+
82
+ rules = [
83
+ { active: 'a', direction: 'asc' },
84
+ { active: 'b', direction: 'asc' },
85
+ { active: 'c', direction: 'asc' },
86
+ ];
87
+
88
+ [...rules].reverse().forEach( rule => store.setSort( { key: rule.active, direction: rule.direction } ));
89
+ directive.ngOnInit();
90
+ });
91
+
92
+ describe('Initializing Rules', () => {
93
+
94
+ it('should inititialize the rules', () => {
95
+ expect(directive.rules).toEqual(rules);
96
+ });
97
+ });
98
+
99
+ describe('Updating the rules', () => {
100
+ it('should add new rule to begining of rules array', () => {
101
+ const originalLength = directive.rules.length;
102
+ const sort: MatSortable = { id: 'd', start: 'asc', disableClear: false };
103
+ directive.sort(sort);
104
+ expect(directive.rules.length).toBe(originalLength + 1, 'updated rules length should be one larger than original');
105
+ expect(directive.rules[0].active).toBe(sort.id);
106
+ });
107
+
108
+ it('should remove old rule for the column of new rule and replace it with new rule', () => {
109
+ const originalLength = directive.rules.length;
110
+ const sort: MatSortable = { id: 'a', start: 'asc', disableClear: false };
111
+ directive.sort(sort);
112
+ expect(directive.rules.length).toBe(originalLength, 'updated rules length should be same as original');
113
+ expect(directive.rules[0].direction).toBe('desc');
114
+ });
115
+
116
+ it('should remove old rule without replacing it if new rule for that column has no direction', () => {
117
+ const originalLength = directive.rules.length;
118
+ const sort: MatSortable = { id: 'a', start: 'asc', disableClear: false };
119
+ directive.sort({ ...sort });
120
+ directive.sort({ ...sort });
121
+ expect(directive.rules.length).toBe(originalLength - 1, 'updated rules length should be one smaller than original');
122
+ });
123
+ });
124
+ });