shark-ng-table 7.0.0 → 8.0.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 (57) hide show
  1. package/README.md +66 -52
  2. package/fesm2022/shark-ng-table.mjs +2191 -1833
  3. package/fesm2022/shark-ng-table.mjs.map +1 -1
  4. package/package.json +43 -31
  5. package/shark-ng-table.css +19 -1
  6. package/shark-ng-table.min.css +2 -4
  7. package/types/shark-ng-table.d.ts +913 -0
  8. package/app/table/child.component.d.ts +0 -34
  9. package/app/table/column-change-event.d.ts +0 -5
  10. package/app/table/column.d.ts +0 -64
  11. package/app/table/current.data.event.d.ts +0 -5
  12. package/app/table/dynamic/dynamic.contents.d.ts +0 -20
  13. package/app/table/dynamic/dynamic.contents.directive.d.ts +0 -8
  14. package/app/table/header-button.component.d.ts +0 -16
  15. package/app/table/index.d.ts +0 -15
  16. package/app/table/localfilter.pipe.d.ts +0 -11
  17. package/app/table/notifier/aria-notifier.component.d.ts +0 -14
  18. package/app/table/notifier/notifier.service.d.ts +0 -7
  19. package/app/table/page.change.event.d.ts +0 -27
  20. package/app/table/page.d.ts +0 -20
  21. package/app/table/sort.type.d.ts +0 -30
  22. package/app/table/table.body.component.d.ts +0 -67
  23. package/app/table/table.cell.component.d.ts +0 -20
  24. package/app/table/table.component.d.ts +0 -202
  25. package/app/table/table.footer.component.d.ts +0 -49
  26. package/app/table/table.header.component.d.ts +0 -39
  27. package/app/table/table.info.header.component.d.ts +0 -28
  28. package/app/table/table.module.d.ts +0 -21
  29. package/app/table/table.pagination.component.d.ts +0 -21
  30. package/app/table/table.utils.d.ts +0 -13
  31. package/esm2022/app/table/child.component.mjs +0 -76
  32. package/esm2022/app/table/column-change-event.mjs +0 -5
  33. package/esm2022/app/table/column.mjs +0 -2
  34. package/esm2022/app/table/current.data.event.mjs +0 -5
  35. package/esm2022/app/table/dynamic/dynamic.contents.directive.mjs +0 -17
  36. package/esm2022/app/table/dynamic/dynamic.contents.mjs +0 -2
  37. package/esm2022/app/table/header-button.component.mjs +0 -52
  38. package/esm2022/app/table/index.mjs +0 -11
  39. package/esm2022/app/table/localfilter.pipe.mjs +0 -24
  40. package/esm2022/app/table/notifier/aria-notifier.component.mjs +0 -44
  41. package/esm2022/app/table/notifier/notifier.service.mjs +0 -13
  42. package/esm2022/app/table/page.change.event.mjs +0 -2
  43. package/esm2022/app/table/page.mjs +0 -2
  44. package/esm2022/app/table/sort.type.mjs +0 -32
  45. package/esm2022/app/table/table.body.component.mjs +0 -181
  46. package/esm2022/app/table/table.cell.component.mjs +0 -75
  47. package/esm2022/app/table/table.component.mjs +0 -773
  48. package/esm2022/app/table/table.footer.component.mjs +0 -176
  49. package/esm2022/app/table/table.header.component.mjs +0 -204
  50. package/esm2022/app/table/table.info.header.component.mjs +0 -142
  51. package/esm2022/app/table/table.module.mjs +0 -73
  52. package/esm2022/app/table/table.pagination.component.mjs +0 -134
  53. package/esm2022/app/table/table.utils.mjs +0 -72
  54. package/esm2022/public_api.mjs +0 -2
  55. package/esm2022/shark-ng-table.mjs +0 -5
  56. package/index.d.ts +0 -5
  57. package/public_api.d.ts +0 -1
@@ -1,373 +1,448 @@
1
- import * as i0 from '@angular/core';
2
- import { Directive, Injectable, Component, Input, ViewChild, EventEmitter, Output, Inject, Pipe, ContentChild, NgModule } from '@angular/core';
3
- import * as i1 from '@angular/common';
4
- import { DOCUMENT, CommonModule } from '@angular/common';
5
- import * as i1$1 from '@angular/router';
6
- import { RouterModule } from '@angular/router';
7
- import * as i2 from '@angular/forms';
8
- import { FormsModule } from '@angular/forms';
9
- import { Subject, Observable } from 'rxjs';
10
- import { v4 } from 'uuid';
11
-
12
- class SharkDynamicContentsDirective {
13
- viewContainerRef;
14
- constructor(viewContainerRef) {
15
- this.viewContainerRef = viewContainerRef;
16
- }
17
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkDynamicContentsDirective, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive });
18
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: SharkDynamicContentsDirective, selector: "[sharkDynamicContents]", ngImport: i0 });
19
- }
20
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkDynamicContentsDirective, decorators: [{
21
- type: Directive,
22
- args: [{
23
- selector: '[sharkDynamicContents]'
24
- }]
25
- }], ctorParameters: function () { return [{ type: i0.ViewContainerRef }]; } });
26
-
27
- class SharkTableUtils {
28
- exportRow(row, columns, rendered) {
29
- let newRow = {};
30
- columns.filter(col => col.displayed).forEach(col => {
31
- newRow[col.property] = this.retrieveCell(row, col, rendered);
32
- });
33
- return newRow;
34
- }
35
- retrieveCell(row, column, rendered = true) {
36
- const cell = this.findValue(row, column.property);
37
- if (column.pipe && rendered) {
38
- return this.applyPipe(column.pipe, cell, column.pipeArgs, column.pipeConstructorArgs);
39
- }
40
- return cell;
41
- }
42
- applyPipe(pipe, cell, pipeArgs = [], pipeConstructorArgs = []) {
43
- const pipeInstance = new pipe(...pipeConstructorArgs);
44
- return pipeInstance.transform(cell, ...pipeArgs);
45
- }
46
- filter(items, cols, columnFiltering, filterText) {
47
- return items.filter((row) => {
48
- let found = false;
49
- if (columnFiltering && this.hasFilter(cols)) {
50
- let rowFound = false;
51
- // Not using forEach here because we needed to break when a false match occurs during column filtering
52
- for (const col of cols) {
53
- const value = this.retrieveCell(row, col) + '';
54
- const search = col.filter ? col.filter : '';
55
- if (search.length > 0) {
56
- if (value && (value.toLowerCase().indexOf(search.toLowerCase()) !== -1)) {
57
- rowFound = true;
58
- }
59
- else {
60
- rowFound = false;
61
- break;
62
- }
63
- }
64
- }
65
- found = rowFound;
66
- }
67
- else if (columnFiltering && !this.hasFilter(cols)) {
68
- return true;
69
- }
70
- else if (filterText) {
71
- cols.forEach((col) => {
72
- const value = this.retrieveCell(row, col) + '';
73
- if (filterText && value && (value.toLowerCase().indexOf(filterText.toLowerCase()) !== -1)) {
74
- found = true;
75
- }
76
- });
77
- }
78
- return found;
79
- });
80
- }
81
- findValue(input, key) {
82
- const arr = key.split('.');
83
- while (arr.length && (input = input[arr.shift()])) { }
84
- ;
85
- return input;
86
- }
87
- hasFilter(cols) {
88
- return cols.filter((col) => col.filter && col.filter.length > 0).length > 0;
89
- }
90
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableUtils, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
91
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableUtils });
92
- }
93
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableUtils, decorators: [{
94
- type: Injectable
95
- }] });
96
-
97
- /**
98
- * This Component is used to render your custom child row component.
99
- */
100
- class SharkChildComponent {
101
- tableUtils;
102
- componentFactoryResolver;
103
- changeDetectorRef;
104
- /**
105
- * Your custom component which extends {@link SharkDynamicContents} that will be used
106
- * to render each child row. Your custom component needs to be registerd in your NgModule
107
- * as an `entryComponent` and in the `declarations` section.
108
- */
109
- component;
110
- /**
111
- * The entire row, you can display anything from this row in your child component.
112
- */
113
- row;
114
- rowIndex;
115
- openChildren;
116
- childContentsDirective;
117
- childOpen;
118
- componentRef;
119
- constructor(tableUtils, componentFactoryResolver, changeDetectorRef) {
120
- this.tableUtils = tableUtils;
121
- this.componentFactoryResolver = componentFactoryResolver;
122
- this.changeDetectorRef = changeDetectorRef;
123
- }
124
- ngAfterViewInit() {
125
- this.loadComponent();
126
- }
127
- ngOnChanges(changes) {
128
- if (changes.hasOwnProperty('openChildren') && !changes['openChildren'].isFirstChange()) {
129
- this.childOpen = changes['openChildren'].currentValue.indexOf(this.rowIndex) > -1;
130
- this.componentRef.instance.childOpen(this.childOpen);
131
- }
132
- }
133
- loadComponent() {
134
- const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.component);
135
- const viewContainerRef = this.childContentsDirective.viewContainerRef;
136
- viewContainerRef.clear();
137
- this.componentRef = viewContainerRef.createComponent(componentFactory);
138
- this.componentRef.instance.data = this.row;
139
- // without this, everything went boom
140
- this.changeDetectorRef.detectChanges();
141
- }
142
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkChildComponent, deps: [{ token: SharkTableUtils }, { token: i0.ComponentFactoryResolver }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
143
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: SharkChildComponent, selector: "shark-child", inputs: { component: "component", row: "row", rowIndex: "rowIndex", openChildren: "openChildren" }, viewQueries: [{ propertyName: "childContentsDirective", first: true, predicate: SharkDynamicContentsDirective, descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: `
144
- <ng-template sharkDynamicContents></ng-template>
145
- `, isInline: true, dependencies: [{ kind: "directive", type: SharkDynamicContentsDirective, selector: "[sharkDynamicContents]" }] });
146
- }
147
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkChildComponent, decorators: [{
148
- type: Component,
149
- args: [{
150
- selector: 'shark-child',
151
- template: `
152
- <ng-template sharkDynamicContents></ng-template>
153
- `
154
- }]
155
- }], ctorParameters: function () { return [{ type: SharkTableUtils }, { type: i0.ComponentFactoryResolver }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { component: [{
156
- type: Input
157
- }], row: [{
158
- type: Input
159
- }], rowIndex: [{
160
- type: Input
161
- }], openChildren: [{
162
- type: Input
163
- }], childContentsDirective: [{
164
- type: ViewChild,
165
- args: [SharkDynamicContentsDirective, { static: true }]
166
- }] } });
167
-
168
- class SharkColumnChangeEvent {
169
- columns;
170
- currentSortString;
171
- }
172
-
173
- /**
174
- * Enumeration of the 3 different Sort types
175
- */
1
+ import * as i0 from "@angular/core";
2
+ import { ChangeDetectorRef, Component, ContentChild, DOCUMENT, ElementRef, EventEmitter, Injectable, Injector, Input, NgModule, Output, ViewChild, ViewContainerRef, afterNextRender, inject } from "@angular/core";
3
+ import { LocationStrategy, NgClass, NgStyle, NgTemplateOutlet } from "@angular/common";
4
+ import { Subject, isObservable } from "rxjs";
5
+ import * as i1 from "@angular/forms";
6
+ import { FormsModule } from "@angular/forms";
7
+ import { Router } from "@angular/router";
8
+ var SharkChildComponent = class SharkChildComponent {
9
+ component;
10
+ row;
11
+ rowIndex;
12
+ openChildren = [];
13
+ dynamicHost;
14
+ childOpen = false;
15
+ componentRef;
16
+ ngOnChanges(changes) {
17
+ if (changes["component"] || changes["row"]) this.loadComponent();
18
+ const openChange = changes["openChildren"];
19
+ if (openChange && !openChange.isFirstChange()) {
20
+ const open = (openChange.currentValue ?? []).includes(this.rowIndex);
21
+ if (open !== this.childOpen) {
22
+ this.childOpen = open;
23
+ this.componentRef?.instance.childOpen?.(open);
24
+ this.componentRef?.injector.get(ChangeDetectorRef).detectChanges();
25
+ }
26
+ }
27
+ }
28
+ ngOnDestroy() {
29
+ this.componentRef?.destroy();
30
+ }
31
+ loadComponent() {
32
+ if (!this.component) return;
33
+ if (this.componentRef?.componentType !== this.component) {
34
+ this.dynamicHost.clear();
35
+ this.componentRef = this.dynamicHost.createComponent(this.component);
36
+ }
37
+ this.componentRef.instance.data = this.row;
38
+ this.componentRef.injector.get(ChangeDetectorRef).detectChanges();
39
+ }
40
+ static ɵfac = i0.ɵɵngDeclareFactory({
41
+ minVersion: "12.0.0",
42
+ version: "22.2.6",
43
+ ngImport: i0,
44
+ type: SharkChildComponent,
45
+ deps: [],
46
+ target: i0.ɵɵFactoryTarget.Component
47
+ });
48
+ static ɵcmp = i0.ɵɵngDeclareComponent({
49
+ minVersion: "14.0.0",
50
+ version: "22.2.6",
51
+ type: SharkChildComponent,
52
+ isStandalone: true,
53
+ selector: "shark-child",
54
+ inputs: {
55
+ component: "component",
56
+ row: "row",
57
+ rowIndex: "rowIndex",
58
+ openChildren: "openChildren"
59
+ },
60
+ viewQueries: [{
61
+ propertyName: "dynamicHost",
62
+ first: true,
63
+ predicate: ["dynamicHost"],
64
+ descendants: true,
65
+ read: ViewContainerRef,
66
+ static: true
67
+ }],
68
+ usesOnChanges: true,
69
+ ngImport: i0,
70
+ template: `<ng-container #dynamicHost></ng-container>`,
71
+ isInline: true
72
+ });
73
+ };
74
+ i0.ɵɵngDeclareClassMetadata({
75
+ minVersion: "12.0.0",
76
+ version: "22.2.6",
77
+ ngImport: i0,
78
+ type: SharkChildComponent,
79
+ decorators: [{
80
+ type: Component,
81
+ args: [{
82
+ selector: "shark-child",
83
+ template: `<ng-container #dynamicHost></ng-container>`
84
+ }]
85
+ }],
86
+ propDecorators: {
87
+ component: [{ type: Input }],
88
+ row: [{ type: Input }],
89
+ rowIndex: [{ type: Input }],
90
+ openChildren: [{ type: Input }],
91
+ dynamicHost: [{
92
+ type: ViewChild,
93
+ args: ["dynamicHost", {
94
+ read: ViewContainerRef,
95
+ static: true
96
+ }]
97
+ }]
98
+ }
99
+ });
100
+ var SharkColumnChangeEvent = class {
101
+ columns;
102
+ currentSortString;
103
+ };
176
104
  var SharkSortType;
177
- (function (SharkSortType) {
178
- /**
179
- * No sorting applied, defaults to ASC.
180
- */
181
- SharkSortType[SharkSortType["NONE"] = 0] = "NONE";
182
- /**
183
- * Sort ascending (1, 2, 3)
184
- */
185
- SharkSortType[SharkSortType["ASC"] = 1] = "ASC";
186
- /**
187
- * Sort descending (3, 2, 1)
188
- */
189
- SharkSortType[SharkSortType["DESC"] = 2] = "DESC";
105
+ (function(SharkSortType) {
106
+ SharkSortType[SharkSortType["NONE"] = 0] = "NONE";
107
+ SharkSortType[SharkSortType["ASC"] = 1] = "ASC";
108
+ SharkSortType[SharkSortType["DESC"] = 2] = "DESC";
190
109
  })(SharkSortType || (SharkSortType = {}));
191
- /**
192
- * Placeholder for a column sort
193
- */
194
- class SharkCurrentSort {
195
- /**
196
- * Column property
197
- */
198
- property;
199
- /**
200
- * Sort type
201
- */
202
- sortType;
203
- }
204
-
205
- class SharkTablePaginationComponent {
206
- elementRef;
207
- pageCount = [];
208
- first = false;
209
- last = false;
210
- previous = false;
211
- next = false;
212
- displayedPages = [];
213
- page;
214
- tableId;
215
- paginationChange = new EventEmitter();
216
- lastButton;
217
- constructor(elementRef) {
218
- this.elementRef = elementRef;
219
- }
220
- ngOnChanges(changes) {
221
- if (changes.hasOwnProperty('page') && this.page) {
222
- this.pageCount = Array.from(Array(this.page.totalPages), (x, i) => i);
223
- this.first = this.page.number === 0;
224
- this.last = this.page.number === this.pageCount.length - 1;
225
- this.previous = !this.first;
226
- this.next = !this.last;
227
- if (this.pageCount.length > 3) {
228
- if (this.first) {
229
- this.displayedPages = [0, 1, 2];
230
- }
231
- else if (this.last) {
232
- this.displayedPages = [this.page.number - 2, this.page.number - 1, this.page.number];
110
+ var SharkCurrentSort = class {
111
+ property;
112
+ sortType;
113
+ };
114
+ var SharkTablePaginationComponent = class SharkTablePaginationComponent {
115
+ elementRef = inject(ElementRef);
116
+ injector = inject(Injector);
117
+ pageCount = [];
118
+ first = false;
119
+ last = false;
120
+ previous = false;
121
+ next = false;
122
+ displayedPages = [];
123
+ currentPage = 0;
124
+ page;
125
+ tableId;
126
+ paginationChange = new EventEmitter();
127
+ ngOnChanges(changes) {
128
+ if (changes["page"] && this.page) {
129
+ const totalPages = Number(this.page.totalPages);
130
+ const pages = Number.isFinite(totalPages) && totalPages > 0 ? Math.floor(totalPages) : 0;
131
+ this.pageCount = Array.from({ length: pages }, (_x, i) => i);
132
+ this.currentPage = this.page.number ?? 0;
133
+ this.first = this.currentPage === 0;
134
+ this.last = this.currentPage >= this.pageCount.length - 1;
135
+ this.previous = !this.first;
136
+ this.next = !this.last;
137
+ if (this.pageCount.length > 3) {
138
+ if (this.first) this.displayedPages = [
139
+ 0,
140
+ 1,
141
+ 2
142
+ ];
143
+ else if (this.last) this.displayedPages = [
144
+ this.currentPage - 2,
145
+ this.currentPage - 1,
146
+ this.currentPage
147
+ ];
148
+ else this.displayedPages = [
149
+ this.currentPage - 1,
150
+ this.currentPage,
151
+ this.currentPage + 1
152
+ ];
153
+ } else this.displayedPages = this.pageCount;
154
+ }
155
+ }
156
+ changePage(pageNo) {
157
+ const host = this.elementRef.nativeElement;
158
+ const focusWasInside = host.contains(host.ownerDocument.activeElement);
159
+ this.paginationChange.emit(pageNo);
160
+ if (focusWasInside) afterNextRender(() => {
161
+ const active = host.ownerDocument.activeElement;
162
+ if (!active || active === host.ownerDocument.body || !host.contains(active)) host.ownerDocument.getElementById("active-button-" + this.tableId)?.focus();
163
+ }, { injector: this.injector });
164
+ }
165
+ static ɵfac = i0.ɵɵngDeclareFactory({
166
+ minVersion: "12.0.0",
167
+ version: "22.2.6",
168
+ ngImport: i0,
169
+ type: SharkTablePaginationComponent,
170
+ deps: [],
171
+ target: i0.ɵɵFactoryTarget.Component
172
+ });
173
+ static ɵcmp = i0.ɵɵngDeclareComponent({
174
+ minVersion: "17.0.0",
175
+ version: "22.2.6",
176
+ type: SharkTablePaginationComponent,
177
+ isStandalone: true,
178
+ selector: "shark-table-pagination",
179
+ inputs: {
180
+ page: "page",
181
+ tableId: "tableId"
182
+ },
183
+ outputs: { paginationChange: "paginationChange" },
184
+ usesOnChanges: true,
185
+ ngImport: i0,
186
+ template: `
187
+ @if (pageCount.length > 1) {
188
+ <div class="pagination-wrapper">
189
+ <div class="pagination">
190
+ @if (!first) {
191
+ <button (click)="changePage(0)" type="button" class="fa fa-angle-double-left first-page-button">
192
+ <span class="screen-reader-button-label">First Page</span>
193
+ </button>
233
194
  }
234
- else {
235
- this.displayedPages = [this.page.number - 1, this.page.number, this.page.number + 1];
195
+ @if (previous) {
196
+ <button (click)="changePage(currentPage - 1)" type="button" class="fa fa-angle-left previous-page-button">
197
+ <span class="screen-reader-button-label">Previous Page</span>
198
+ </button>
236
199
  }
237
- }
238
- else {
239
- this.displayedPages = this.pageCount;
240
- }
241
- // fix focus when a button disappears
242
- if (this.lastButton) {
243
- setTimeout(() => {
244
- if (!this.elementRef.nativeElement.ownerDocument.getElementById(this.lastButton)) {
245
- const activeButton = this.elementRef.nativeElement.ownerDocument.getElementById('active-button');
246
- if (activeButton) {
247
- activeButton.focus();
248
- }
249
- }
250
- this.lastButton = undefined;
251
- }, 100);
252
- }
253
- }
254
- }
255
- changePage(pageNo) {
256
- this.lastButton = this.elementRef.nativeElement.ownerDocument.activeElement.id;
257
- this.paginationChange.emit(pageNo);
258
- }
259
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTablePaginationComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
260
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: SharkTablePaginationComponent, selector: "shark-table-pagination", inputs: { page: "page", tableId: "tableId" }, outputs: { paginationChange: "paginationChange" }, usesOnChanges: true, ngImport: i0, template: `
261
- <div class="pagination-wrapper" *ngIf="pageCount.length > 1">
262
- <div class="pagination">
263
- <button *ngIf="!first" (click)="changePage(0)" type="button" class="fa fa-angle-double-left first-page-button">
264
- <span class="screen-reader-button-label">First Page</span>
265
- </button>
266
- <button *ngIf="previous" (click)="changePage(page.number - 1)" type="button" class="fa fa-angle-left previous-page-button">
267
- <span class="screen-reader-button-label">Previous Page</span>
268
- </button>
269
200
 
270
- <ng-container *ngFor="let num of displayedPages">
271
- <button
272
- [attr.id]="num === page.number ? ('active-button-' + tableId) : null"
273
- [ngClass]="{'active': num === page.number, 'inactive': num!== page.number }"
274
- [attr.aria-current]="num === page.number ? 'true' : null"
275
- [attr.aria-disabled]="num === page.number ? 'true' : null"
276
- (click)="changePage(num)" type="button">
277
- <span class="screen-reader-button-label">Page</span>
278
- {{ num + 1 }}
279
- </button>
280
- </ng-container>
201
+ @for (num of displayedPages; track num) {
202
+ <button
203
+ [attr.id]="num === currentPage ? ('active-button-' + tableId) : null"
204
+ [ngClass]="{'active': num === currentPage, 'inactive': num !== currentPage }"
205
+ [attr.aria-current]="num === currentPage ? 'true' : null"
206
+ [attr.aria-disabled]="num === currentPage ? 'true' : null"
207
+ (click)="changePage(num)" type="button">
208
+ <span class="screen-reader-button-label">Page</span>
209
+ {{ num + 1 }}
210
+ </button>
211
+ }
281
212
 
282
- <button *ngIf="next" (click)="changePage(page.number + 1)" type="button" class="fa fa-angle-right next-page-button">
283
- <span class="screen-reader-button-label">Next Page</span>
284
- </button>
285
- <button *ngIf="!last" (click)="changePage(pageCount.length - 1)" type="button" class="fa fa-angle-double-right last-page-button">
286
- <span class="screen-reader-button-label">Last Page</span>
287
- </button>
288
- </div>
289
- </div>
290
- `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
291
- }
292
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTablePaginationComponent, decorators: [{
293
- type: Component,
294
- args: [{
295
- selector: 'shark-table-pagination',
296
- template: `
297
- <div class="pagination-wrapper" *ngIf="pageCount.length > 1">
298
- <div class="pagination">
299
- <button *ngIf="!first" (click)="changePage(0)" type="button" class="fa fa-angle-double-left first-page-button">
300
- <span class="screen-reader-button-label">First Page</span>
301
- </button>
302
- <button *ngIf="previous" (click)="changePage(page.number - 1)" type="button" class="fa fa-angle-left previous-page-button">
303
- <span class="screen-reader-button-label">Previous Page</span>
304
- </button>
213
+ @if (next) {
214
+ <button (click)="changePage(currentPage + 1)" type="button" class="fa fa-angle-right next-page-button">
215
+ <span class="screen-reader-button-label">Next Page</span>
216
+ </button>
217
+ }
218
+ @if (!last) {
219
+ <button (click)="changePage(pageCount.length - 1)" type="button" class="fa fa-angle-double-right last-page-button">
220
+ <span class="screen-reader-button-label">Last Page</span>
221
+ </button>
222
+ }
223
+ </div>
224
+ </div>
225
+ }
226
+ `,
227
+ isInline: true,
228
+ dependencies: [{
229
+ kind: "directive",
230
+ type: NgClass,
231
+ selector: "[ngClass]",
232
+ inputs: ["class", "ngClass"]
233
+ }]
234
+ });
235
+ };
236
+ i0.ɵɵngDeclareClassMetadata({
237
+ minVersion: "12.0.0",
238
+ version: "22.2.6",
239
+ ngImport: i0,
240
+ type: SharkTablePaginationComponent,
241
+ decorators: [{
242
+ type: Component,
243
+ args: [{
244
+ selector: "shark-table-pagination",
245
+ imports: [NgClass],
246
+ template: `
247
+ @if (pageCount.length > 1) {
248
+ <div class="pagination-wrapper">
249
+ <div class="pagination">
250
+ @if (!first) {
251
+ <button (click)="changePage(0)" type="button" class="fa fa-angle-double-left first-page-button">
252
+ <span class="screen-reader-button-label">First Page</span>
253
+ </button>
254
+ }
255
+ @if (previous) {
256
+ <button (click)="changePage(currentPage - 1)" type="button" class="fa fa-angle-left previous-page-button">
257
+ <span class="screen-reader-button-label">Previous Page</span>
258
+ </button>
259
+ }
305
260
 
306
- <ng-container *ngFor="let num of displayedPages">
307
- <button
308
- [attr.id]="num === page.number ? ('active-button-' + tableId) : null"
309
- [ngClass]="{'active': num === page.number, 'inactive': num!== page.number }"
310
- [attr.aria-current]="num === page.number ? 'true' : null"
311
- [attr.aria-disabled]="num === page.number ? 'true' : null"
312
- (click)="changePage(num)" type="button">
313
- <span class="screen-reader-button-label">Page</span>
314
- {{ num + 1 }}
315
- </button>
316
- </ng-container>
261
+ @for (num of displayedPages; track num) {
262
+ <button
263
+ [attr.id]="num === currentPage ? ('active-button-' + tableId) : null"
264
+ [ngClass]="{'active': num === currentPage, 'inactive': num !== currentPage }"
265
+ [attr.aria-current]="num === currentPage ? 'true' : null"
266
+ [attr.aria-disabled]="num === currentPage ? 'true' : null"
267
+ (click)="changePage(num)" type="button">
268
+ <span class="screen-reader-button-label">Page</span>
269
+ {{ num + 1 }}
270
+ </button>
271
+ }
317
272
 
318
- <button *ngIf="next" (click)="changePage(page.number + 1)" type="button" class="fa fa-angle-right next-page-button">
319
- <span class="screen-reader-button-label">Next Page</span>
320
- </button>
321
- <button *ngIf="!last" (click)="changePage(pageCount.length - 1)" type="button" class="fa fa-angle-double-right last-page-button">
322
- <span class="screen-reader-button-label">Last Page</span>
323
- </button>
324
- </div>
325
- </div>
273
+ @if (next) {
274
+ <button (click)="changePage(currentPage + 1)" type="button" class="fa fa-angle-right next-page-button">
275
+ <span class="screen-reader-button-label">Next Page</span>
276
+ </button>
277
+ }
278
+ @if (!last) {
279
+ <button (click)="changePage(pageCount.length - 1)" type="button" class="fa fa-angle-double-right last-page-button">
280
+ <span class="screen-reader-button-label">Last Page</span>
281
+ </button>
282
+ }
283
+ </div>
284
+ </div>
285
+ }
326
286
  `
327
- }]
328
- }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { page: [{
329
- type: Input
330
- }], tableId: [{
331
- type: Input
332
- }], paginationChange: [{
333
- type: Output
334
- }] } });
335
-
336
- class SharkTableHeaderButtonComponent {
337
- column;
338
- sortChange = new EventEmitter();
339
- ariaButtonLabel = 'Change Sorting';
340
- changeSort() {
341
- this.sortChange.emit({
342
- property: this.column.property,
343
- sortType: this.column.sortType
344
- });
345
- }
346
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableHeaderButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
347
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: SharkTableHeaderButtonComponent, selector: "shark-table-header-button", inputs: { column: "column" }, outputs: { sortChange: "sortChange" }, ngImport: i0, template: `
348
- <span class="header-text pointer" (click)="changeSort()" (keyup.enter)="changeSort()">{{ column.header }}</span>
349
- <button class="sort-button" [name]="column.header" (click)="changeSort()" type="button" aria-label="Change Sorting">
350
- <i class="sorting fas fa-fw" [ngClass]="{
351
- 'unsorted': !column.sortType || column.sortType === 0,
352
- 'fa-sort': !column.sortType || column.sortType === 0,
287
+ }]
288
+ }],
289
+ propDecorators: {
290
+ page: [{ type: Input }],
291
+ tableId: [{ type: Input }],
292
+ paginationChange: [{ type: Output }]
293
+ }
294
+ });
295
+ var SharkTableUtils = class SharkTableUtils {
296
+ exportRow(row, columns, rendered) {
297
+ const newRow = {};
298
+ columns.filter((col) => col.displayed).forEach((col) => {
299
+ newRow[col.property] = this.retrieveCell(row, col, rendered);
300
+ });
301
+ return newRow;
302
+ }
303
+ retrieveCell(row, column, rendered = true) {
304
+ const cell = this.findValue(row, column.property);
305
+ if (column.pipe && rendered) return this.applyPipe(column.pipe, cell, column.pipeArgs, column.pipeConstructorArgs);
306
+ return cell;
307
+ }
308
+ applyPipe(pipe, cell, pipeArgs = [], pipeConstructorArgs = []) {
309
+ return new pipe(...pipeConstructorArgs).transform(cell, ...pipeArgs);
310
+ }
311
+ filter(items, cols, columnFiltering, filterText) {
312
+ const useColumnFilters = columnFiltering && this.hasFilter(cols);
313
+ const globalFilter = (filterText ?? "").toLowerCase();
314
+ if (!useColumnFilters && (columnFiltering || globalFilter.length === 0)) return items.slice();
315
+ return items.filter((row) => {
316
+ if (useColumnFilters) return cols.every((col) => {
317
+ const search = (col.filter ?? "").toLowerCase();
318
+ return search.length === 0 || this.cellText(row, col).includes(search);
319
+ });
320
+ return cols.some((col) => this.cellText(row, col).includes(globalFilter));
321
+ });
322
+ }
323
+ findValue(input, key) {
324
+ return key.split(".").reduce((value, part) => value == null ? void 0 : value[part], input);
325
+ }
326
+ hasFilter(cols) {
327
+ return !!cols && cols.some((col) => !!col.filter && col.filter.length > 0);
328
+ }
329
+ compare(a, b) {
330
+ const aEmpty = a == null || a === "";
331
+ const bEmpty = b == null || b === "";
332
+ if (aEmpty || bEmpty) return aEmpty && bEmpty ? 0 : aEmpty ? 1 : -1;
333
+ const aNum = this.toNumber(a);
334
+ const bNum = this.toNumber(b);
335
+ if (aNum !== void 0 && bNum !== void 0) return aNum === bNum ? 0 : aNum < bNum ? -1 : 1;
336
+ const aStr = String(a);
337
+ const bStr = String(b);
338
+ return aStr < bStr ? -1 : aStr > bStr ? 1 : 0;
339
+ }
340
+ toNumber(value) {
341
+ if (typeof value === "number") return Number.isNaN(value) ? void 0 : value;
342
+ if (value instanceof Date) return value.getTime();
343
+ if (typeof value === "string" && value.trim() !== "") {
344
+ const num = Number(value);
345
+ return Number.isFinite(num) ? num : void 0;
346
+ }
347
+ }
348
+ cellText(row, col) {
349
+ const value = this.retrieveCell(row, col);
350
+ return value == null ? "" : String(value).toLowerCase();
351
+ }
352
+ static ɵfac = i0.ɵɵngDeclareFactory({
353
+ minVersion: "12.0.0",
354
+ version: "22.2.6",
355
+ ngImport: i0,
356
+ type: SharkTableUtils,
357
+ deps: [],
358
+ target: i0.ɵɵFactoryTarget.Injectable
359
+ });
360
+ static ɵprov = i0.ɵɵngDeclareInjectable({
361
+ minVersion: "12.0.0",
362
+ version: "22.2.6",
363
+ ngImport: i0,
364
+ type: SharkTableUtils,
365
+ providedIn: "root"
366
+ });
367
+ };
368
+ i0.ɵɵngDeclareClassMetadata({
369
+ minVersion: "12.0.0",
370
+ version: "22.2.6",
371
+ ngImport: i0,
372
+ type: SharkTableUtils,
373
+ decorators: [{
374
+ type: Injectable,
375
+ args: [{ providedIn: "root" }]
376
+ }]
377
+ });
378
+ var SharkTableHeaderButtonComponent = class SharkTableHeaderButtonComponent {
379
+ column;
380
+ sortChange = new EventEmitter();
381
+ changeSort() {
382
+ this.sortChange.emit({
383
+ property: this.column.property,
384
+ sortType: this.column.sortType
385
+ });
386
+ }
387
+ static ɵfac = i0.ɵɵngDeclareFactory({
388
+ minVersion: "12.0.0",
389
+ version: "22.2.6",
390
+ ngImport: i0,
391
+ type: SharkTableHeaderButtonComponent,
392
+ deps: [],
393
+ target: i0.ɵɵFactoryTarget.Component
394
+ });
395
+ static ɵcmp = i0.ɵɵngDeclareComponent({
396
+ minVersion: "14.0.0",
397
+ version: "22.2.6",
398
+ type: SharkTableHeaderButtonComponent,
399
+ isStandalone: true,
400
+ selector: "shark-table-header-button",
401
+ inputs: { column: "column" },
402
+ outputs: { sortChange: "sortChange" },
403
+ ngImport: i0,
404
+ template: `
405
+ <!-- Mouse convenience only: keyboard and screen reader users use the sort button below, so this is not a second tab stop. -->
406
+ <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->
407
+ <span class="header-text pointer" (click)="changeSort()">{{ column.header }}</span>
408
+ <button class="sort-button" [name]="column.header" (click)="changeSort()" type="button" [attr.aria-label]="'Change sorting for ' + column.header">
409
+ <i class="sorting fas fa-fw" aria-hidden="true" [ngClass]="{
410
+ 'unsorted': !column.sortType,
411
+ 'fa-sort': !column.sortType,
353
412
  'asc': column.sortType === 1,
354
413
  'fa-sort-up': column.sortType === 1,
355
414
  'desc': column.sortType === 2,
356
415
  'fa-sort-down': column.sortType === 2
357
416
  }"></i>
358
417
  </button>
359
- `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
360
- }
361
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableHeaderButtonComponent, decorators: [{
362
- type: Component,
363
- args: [{
364
- selector: 'shark-table-header-button',
365
- template: `
366
- <span class="header-text pointer" (click)="changeSort()" (keyup.enter)="changeSort()">{{ column.header }}</span>
367
- <button class="sort-button" [name]="column.header" (click)="changeSort()" type="button" aria-label="Change Sorting">
368
- <i class="sorting fas fa-fw" [ngClass]="{
369
- 'unsorted': !column.sortType || column.sortType === 0,
370
- 'fa-sort': !column.sortType || column.sortType === 0,
418
+ `,
419
+ isInline: true,
420
+ dependencies: [{
421
+ kind: "directive",
422
+ type: NgClass,
423
+ selector: "[ngClass]",
424
+ inputs: ["class", "ngClass"]
425
+ }]
426
+ });
427
+ };
428
+ i0.ɵɵngDeclareClassMetadata({
429
+ minVersion: "12.0.0",
430
+ version: "22.2.6",
431
+ ngImport: i0,
432
+ type: SharkTableHeaderButtonComponent,
433
+ decorators: [{
434
+ type: Component,
435
+ args: [{
436
+ selector: "shark-table-header-button",
437
+ imports: [NgClass],
438
+ template: `
439
+ <!-- Mouse convenience only: keyboard and screen reader users use the sort button below, so this is not a second tab stop. -->
440
+ <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events, @angular-eslint/template/interactive-supports-focus -->
441
+ <span class="header-text pointer" (click)="changeSort()">{{ column.header }}</span>
442
+ <button class="sort-button" [name]="column.header" (click)="changeSort()" type="button" [attr.aria-label]="'Change sorting for ' + column.header">
443
+ <i class="sorting fas fa-fw" aria-hidden="true" [ngClass]="{
444
+ 'unsorted': !column.sortType,
445
+ 'fa-sort': !column.sortType,
371
446
  'asc': column.sortType === 1,
372
447
  'fa-sort-up': column.sortType === 1,
373
448
  'desc': column.sortType === 2,
@@ -375,1351 +450,1565 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
375
450
  }"></i>
376
451
  </button>
377
452
  `
378
- }]
379
- }], propDecorators: { column: [{
380
- type: Input
381
- }], sortChange: [{
382
- type: Output
383
- }] } });
384
-
385
- class SharkTableHeaderComponent {
386
- document;
387
- tableId;
388
- sortable;
389
- allColumns;
390
- currentColumns;
391
- columnOrdering;
392
- childRows;
393
- page;
394
- filterable;
395
- columnFiltering;
396
- filter;
397
- showFilterPlaceholders;
398
- notifierService;
399
- localPagingSize;
400
- sortChange = new EventEmitter();
401
- filterChange = new EventEmitter();
402
- columnChange = new EventEmitter();
403
- constructor(document) {
404
- this.document = document;
405
- }
406
- dispatchSortChangeEvent(event) {
407
- this.sortChange.emit(event);
408
- }
409
- fireFilterChange() {
410
- this.filterChange.emit({
411
- columns: this.allColumns,
412
- filter: this.filter,
413
- localPagingSize: this.localPagingSize
414
- });
415
- }
416
- moveColumnForward(index, column) {
417
- this.move(index, 1, column);
418
- this.notifierService.postMessage('column moved right');
419
- const newIndex = this.currentColumns.indexOf(column);
420
- setTimeout(() => {
421
- if (newIndex === this.currentColumns.length - 1) {
422
- this.focusButton(column, 'left');
423
- }
424
- else {
425
- this.focusButton(column, 'right');
453
+ }]
454
+ }],
455
+ propDecorators: {
456
+ column: [{ type: Input }],
457
+ sortChange: [{ type: Output }]
458
+ }
459
+ });
460
+ var SharkTableHeaderComponent = class SharkTableHeaderComponent {
461
+ document = inject(DOCUMENT);
462
+ injector = inject(Injector);
463
+ tableId;
464
+ sortable;
465
+ allColumns = [];
466
+ currentColumns = [];
467
+ columnOrdering;
468
+ childRows;
469
+ page;
470
+ filterable;
471
+ columnFiltering;
472
+ filter;
473
+ showFilterPlaceholders;
474
+ notifierService;
475
+ localPagingSize;
476
+ sortChange = new EventEmitter();
477
+ filterChange = new EventEmitter();
478
+ columnChange = new EventEmitter();
479
+ ariaSort(column) {
480
+ if (!this.sortable || column.unsortable) return null;
481
+ return !column.sortType ? "none" : column.sortType === 1 ? "ascending" : "descending";
482
+ }
483
+ orderButtonId(column, dir) {
484
+ return "order-" + this.tableId + "-" + column.property + "-" + dir;
485
+ }
486
+ dispatchSortChangeEvent(event) {
487
+ this.sortChange.emit(event);
488
+ }
489
+ fireFilterChange() {
490
+ this.filterChange.emit({
491
+ columns: this.allColumns,
492
+ filter: this.filter,
493
+ localPagingSize: this.localPagingSize
494
+ });
495
+ }
496
+ moveColumnForward(index, column) {
497
+ this.move(index, 1, column);
498
+ this.notifierService.postMessage("column moved right");
499
+ this.restoreFocus(column, "right");
500
+ }
501
+ moveColumnBackward(index, column) {
502
+ this.move(index, -1, column);
503
+ this.notifierService.postMessage("column moved left");
504
+ this.restoreFocus(column, "left");
505
+ }
506
+ restoreFocus(column, dir) {
507
+ afterNextRender(() => {
508
+ (this.document.getElementById(this.orderButtonId(column, dir)) ?? this.document.getElementById(this.orderButtonId(column, dir === "left" ? "right" : "left")))?.focus();
509
+ }, { injector: this.injector });
510
+ }
511
+ move(index, offset, column) {
512
+ const newIndex = index + offset;
513
+ if (newIndex > -1 && newIndex < this.currentColumns.length) {
514
+ const allStartIndex = this.allColumns.indexOf(column);
515
+ let start = allStartIndex;
516
+ let adjust;
517
+ if (offset < 0) {
518
+ adjust = -1;
519
+ while (start >= 0) {
520
+ start--;
521
+ const col = this.allColumns[start];
522
+ if (col && !col.displayed) --adjust;
523
+ else break;
524
+ }
525
+ } else {
526
+ adjust = 1;
527
+ while (start <= this.allColumns.length) {
528
+ start++;
529
+ const col = this.allColumns[start];
530
+ if (col && !col.displayed) ++adjust;
531
+ else break;
532
+ }
533
+ }
534
+ const removedElementAll = this.allColumns.splice(allStartIndex, 1)[0];
535
+ this.allColumns.splice(allStartIndex + adjust, 0, removedElementAll);
536
+ this.columnChange.emit(this.allColumns);
537
+ }
538
+ }
539
+ static ɵfac = i0.ɵɵngDeclareFactory({
540
+ minVersion: "12.0.0",
541
+ version: "22.2.6",
542
+ ngImport: i0,
543
+ type: SharkTableHeaderComponent,
544
+ deps: [],
545
+ target: i0.ɵɵFactoryTarget.Component
546
+ });
547
+ static ɵcmp = i0.ɵɵngDeclareComponent({
548
+ minVersion: "17.0.0",
549
+ version: "22.2.6",
550
+ type: SharkTableHeaderComponent,
551
+ isStandalone: true,
552
+ selector: "[shark-table-header]",
553
+ inputs: {
554
+ tableId: "tableId",
555
+ sortable: "sortable",
556
+ allColumns: "allColumns",
557
+ currentColumns: "currentColumns",
558
+ columnOrdering: "columnOrdering",
559
+ childRows: "childRows",
560
+ page: "page",
561
+ filterable: "filterable",
562
+ columnFiltering: "columnFiltering",
563
+ filter: "filter",
564
+ showFilterPlaceholders: "showFilterPlaceholders",
565
+ notifierService: "notifierService",
566
+ localPagingSize: "localPagingSize"
567
+ },
568
+ outputs: {
569
+ sortChange: "sortChange",
570
+ filterChange: "filterChange",
571
+ columnChange: "columnChange"
572
+ },
573
+ ngImport: i0,
574
+ template: `
575
+ @if (currentColumns.length > 0) {
576
+ <tr class="header-row header-border">
577
+ @if (childRows) {
578
+ <th class="childHeader child-spacer">
579
+ <span class="screen-reader">Details</span>
580
+ </th>
426
581
  }
427
- }, 100);
428
- }
429
- moveColumnBackward(index, column) {
430
- this.move(index, -1, column);
431
- this.notifierService.postMessage('column moved left');
432
- const newIndex = this.currentColumns.indexOf(column);
433
- setTimeout(() => {
434
- if (newIndex === 0) {
435
- this.focusButton(column, 'right');
436
- }
437
- else {
438
- this.focusButton(column, 'left');
582
+ @for (column of currentColumns; track column; let i = $index, f = $first, l = $last) {
583
+ <th class="header-buttons" [ngClass]="{'right': column.alignRight }"
584
+ [attr.id]="'column' + tableId + '-' + i + '-' + column.property"
585
+ [attr.aria-sort]="ariaSort(column)">
586
+ @if (columnOrdering && !f && !column.disableOrdering) {
587
+ <button (click)="moveColumnBackward(i, column)" type="button" class="ordering-button fa fa-angle-left" [id]="orderButtonId(column, 'left')">
588
+ <span class="screen-reader-button-label">{{ 'Move the ' + column.header + ' column left' }}</span>
589
+ </button>
590
+ }
591
+ @if (sortable && !column.unsortable) {
592
+ <shark-table-header-button [column]="column" (sortChange)="dispatchSortChangeEvent($event)"></shark-table-header-button>
593
+ } @else {
594
+ {{ column.header }}
595
+ }
596
+ @if (columnOrdering && !l && !column.disableOrdering) {
597
+ <button (click)="moveColumnForward(i, column)" type="button" class="ordering-button fa fa-angle-right" [id]="orderButtonId(column, 'right')">
598
+ <span class="screen-reader-button-label">{{ 'Move the ' + column.header + ' column right' }}</span>
599
+ </button>
600
+ }
601
+ @if (columnFiltering && filterable && !column.hideHeaderFilter) {
602
+ <div>
603
+ <label [for]="'column-filter-' + tableId + '-' + i" class="screen-reader">{{ column.header }} filter</label>
604
+ <input type="text" name="column{{i}}" [id]="'column-filter-' + tableId + '-' + i" [(ngModel)]="column.filter" (ngModelChange)="fireFilterChange()" [attr.placeholder]="showFilterPlaceholders ? (column.header + ' filter') : null" />
605
+ </div>
606
+ }
607
+ </th>
439
608
  }
440
- }, 100);
441
- }
442
- focusButton(column, dir) {
443
- const button = document.getElementById(column.property + '-' + dir);
444
- if (button) {
445
- button.focus();
609
+ </tr>
446
610
  }
447
- }
448
- move(index, offset, column) {
449
- const newIndex = index + offset;
450
- if (newIndex > -1 && newIndex < this.currentColumns.length) {
451
- const allStartIndex = this.allColumns.indexOf(column);
452
- let start = allStartIndex;
453
- let adjust = 0;
454
- if (offset < 0) {
455
- // if going backwards, look backwards for hidden
456
- adjust = -1;
457
- while (start >= 0) {
458
- start--;
459
- const col = this.allColumns[start];
460
- if (col && !col.displayed) {
461
- --adjust;
462
- }
463
- else {
464
- break;
465
- }
466
- }
611
+ `,
612
+ isInline: true,
613
+ dependencies: [
614
+ {
615
+ kind: "directive",
616
+ type: NgClass,
617
+ selector: "[ngClass]",
618
+ inputs: ["class", "ngClass"]
619
+ },
620
+ {
621
+ kind: "ngmodule",
622
+ type: FormsModule
623
+ },
624
+ {
625
+ kind: "directive",
626
+ type: i1.DefaultValueAccessor,
627
+ selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]"
628
+ },
629
+ {
630
+ kind: "directive",
631
+ type: i1.NgControlStatus,
632
+ selector: "[formControlName],[ngModel],[formControl]"
633
+ },
634
+ {
635
+ kind: "directive",
636
+ type: i1.NgModel,
637
+ selector: "[ngModel]:not([formControlName]):not([formControl])",
638
+ inputs: [
639
+ "name",
640
+ "disabled",
641
+ "ngModel",
642
+ "ngModelOptions"
643
+ ],
644
+ outputs: ["ngModelChange"],
645
+ exportAs: ["ngModel"]
646
+ },
647
+ {
648
+ kind: "component",
649
+ type: SharkTableHeaderButtonComponent,
650
+ selector: "shark-table-header-button",
651
+ inputs: ["column"],
652
+ outputs: ["sortChange"]
653
+ }
654
+ ]
655
+ });
656
+ };
657
+ i0.ɵɵngDeclareClassMetadata({
658
+ minVersion: "12.0.0",
659
+ version: "22.2.6",
660
+ ngImport: i0,
661
+ type: SharkTableHeaderComponent,
662
+ decorators: [{
663
+ type: Component,
664
+ args: [{
665
+ selector: "[shark-table-header]",
666
+ imports: [
667
+ NgClass,
668
+ FormsModule,
669
+ SharkTableHeaderButtonComponent
670
+ ],
671
+ template: `
672
+ @if (currentColumns.length > 0) {
673
+ <tr class="header-row header-border">
674
+ @if (childRows) {
675
+ <th class="childHeader child-spacer">
676
+ <span class="screen-reader">Details</span>
677
+ </th>
467
678
  }
468
- else {
469
- // else look forwards for hidden
470
- adjust = 1;
471
- while (start <= this.allColumns.length) {
472
- start++;
473
- const col = this.allColumns[start];
474
- if (col && !col.displayed) {
475
- ++adjust;
476
- }
477
- else {
478
- break;
479
- }
480
- }
679
+ @for (column of currentColumns; track column; let i = $index, f = $first, l = $last) {
680
+ <th class="header-buttons" [ngClass]="{'right': column.alignRight }"
681
+ [attr.id]="'column' + tableId + '-' + i + '-' + column.property"
682
+ [attr.aria-sort]="ariaSort(column)">
683
+ @if (columnOrdering && !f && !column.disableOrdering) {
684
+ <button (click)="moveColumnBackward(i, column)" type="button" class="ordering-button fa fa-angle-left" [id]="orderButtonId(column, 'left')">
685
+ <span class="screen-reader-button-label">{{ 'Move the ' + column.header + ' column left' }}</span>
686
+ </button>
687
+ }
688
+ @if (sortable && !column.unsortable) {
689
+ <shark-table-header-button [column]="column" (sortChange)="dispatchSortChangeEvent($event)"></shark-table-header-button>
690
+ } @else {
691
+ {{ column.header }}
692
+ }
693
+ @if (columnOrdering && !l && !column.disableOrdering) {
694
+ <button (click)="moveColumnForward(i, column)" type="button" class="ordering-button fa fa-angle-right" [id]="orderButtonId(column, 'right')">
695
+ <span class="screen-reader-button-label">{{ 'Move the ' + column.header + ' column right' }}</span>
696
+ </button>
697
+ }
698
+ @if (columnFiltering && filterable && !column.hideHeaderFilter) {
699
+ <div>
700
+ <label [for]="'column-filter-' + tableId + '-' + i" class="screen-reader">{{ column.header }} filter</label>
701
+ <input type="text" name="column{{i}}" [id]="'column-filter-' + tableId + '-' + i" [(ngModel)]="column.filter" (ngModelChange)="fireFilterChange()" [attr.placeholder]="showFilterPlaceholders ? (column.header + ' filter') : null" />
702
+ </div>
703
+ }
704
+ </th>
481
705
  }
482
- const removedElementAll = this.allColumns.splice(allStartIndex, 1)[0];
483
- this.allColumns.splice(allStartIndex + adjust, 0, removedElementAll);
484
- this.columnChange.emit(this.allColumns);
706
+ </tr>
485
707
  }
486
- }
487
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableHeaderComponent, deps: [{ token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Component });
488
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: SharkTableHeaderComponent, selector: "[shark-table-header]", inputs: { tableId: "tableId", sortable: "sortable", allColumns: "allColumns", currentColumns: "currentColumns", columnOrdering: "columnOrdering", childRows: "childRows", page: "page", filterable: "filterable", columnFiltering: "columnFiltering", filter: "filter", showFilterPlaceholders: "showFilterPlaceholders", notifierService: "notifierService", localPagingSize: "localPagingSize" }, outputs: { sortChange: "sortChange", filterChange: "filterChange", columnChange: "columnChange" }, ngImport: i0, template: `
489
- <tr class="header-row header-border" *ngIf="currentColumns.length > 0">
490
- <th *ngIf="childRows" class="childHeader child-spacer">
491
- <span class="screen-reader">Details</span>
492
- </th>
493
- <th class="header-buttons" [ngClass]="{'right': column.alignRight }"
494
- *ngFor="let column of currentColumns; let i = index; let f = first; let l = last;"
495
- [attr.id]="'column' + tableId + '-' + i + '-' + column.property"
496
- [attr.aria-sort]="(!sortable || column.unsortable) ? null : (!column.sortType || column.sortType === 0) ? 'none' : column.sortType === 1 ? 'ascending' : 'descending'">
497
- <button *ngIf="columnOrdering && !f && !column.disableOrdering" (click)="moveColumnBackward(i, column)" type="button" class="ordering-button fa fa-angle-left" [id]="'order-' + tableId + '-' + column.property + '-left'">
498
- <span class="screen-reader-button-label">{{ 'Move the ' + column.header + ' column left' }}</span>
499
- </button>
500
- <shark-table-header-button *ngIf="sortable && !column.unsortable" [column]="column" (sortChange)="dispatchSortChangeEvent($event)"></shark-table-header-button>
501
- <ng-container *ngIf="!sortable || column.unsortable">
502
- {{ column.header }}
503
- </ng-container>
504
- <button *ngIf="columnOrdering && !l && !column.disableOrdering" (click)="moveColumnForward(i, column)" type="button" class="ordering-button fa fa-angle-right" [id]="'order-' + tableId + '-' + column.property + '-right'">
505
- <span class="screen-reader-button-label">{{ 'Move the ' + column.header + ' column right' }}</span>
506
- </button>
507
- <div *ngIf="columnFiltering && filterable && !column.hideHeaderFilter">
508
- <label [for]="'column-filter-' + tableId + '-' + i" class="screen-reader">{{ column.header }} filter</label>
509
- <input type="text" name="column{{i}}" [id]="'column-filter-' + tableId + '-' + i" [(ngModel)]="column.filter" (ngModelChange)="fireFilterChange()" [attr.placeholder]="showFilterPlaceholders ? (column.header + ' filter') : null" />
510
- </div>
511
- </th>
512
- </tr>
513
- `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: SharkTableHeaderButtonComponent, selector: "shark-table-header-button", inputs: ["column"], outputs: ["sortChange"] }] });
514
- }
515
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableHeaderComponent, decorators: [{
516
- type: Component,
517
- args: [{
518
- selector: '[shark-table-header]',
519
- template: `
520
- <tr class="header-row header-border" *ngIf="currentColumns.length > 0">
521
- <th *ngIf="childRows" class="childHeader child-spacer">
522
- <span class="screen-reader">Details</span>
523
- </th>
524
- <th class="header-buttons" [ngClass]="{'right': column.alignRight }"
525
- *ngFor="let column of currentColumns; let i = index; let f = first; let l = last;"
526
- [attr.id]="'column' + tableId + '-' + i + '-' + column.property"
527
- [attr.aria-sort]="(!sortable || column.unsortable) ? null : (!column.sortType || column.sortType === 0) ? 'none' : column.sortType === 1 ? 'ascending' : 'descending'">
528
- <button *ngIf="columnOrdering && !f && !column.disableOrdering" (click)="moveColumnBackward(i, column)" type="button" class="ordering-button fa fa-angle-left" [id]="'order-' + tableId + '-' + column.property + '-left'">
529
- <span class="screen-reader-button-label">{{ 'Move the ' + column.header + ' column left' }}</span>
530
- </button>
531
- <shark-table-header-button *ngIf="sortable && !column.unsortable" [column]="column" (sortChange)="dispatchSortChangeEvent($event)"></shark-table-header-button>
532
- <ng-container *ngIf="!sortable || column.unsortable">
533
- {{ column.header }}
534
- </ng-container>
535
- <button *ngIf="columnOrdering && !l && !column.disableOrdering" (click)="moveColumnForward(i, column)" type="button" class="ordering-button fa fa-angle-right" [id]="'order-' + tableId + '-' + column.property + '-right'">
536
- <span class="screen-reader-button-label">{{ 'Move the ' + column.header + ' column right' }}</span>
537
- </button>
538
- <div *ngIf="columnFiltering && filterable && !column.hideHeaderFilter">
539
- <label [for]="'column-filter-' + tableId + '-' + i" class="screen-reader">{{ column.header }} filter</label>
540
- <input type="text" name="column{{i}}" [id]="'column-filter-' + tableId + '-' + i" [(ngModel)]="column.filter" (ngModelChange)="fireFilterChange()" [attr.placeholder]="showFilterPlaceholders ? (column.header + ' filter') : null" />
541
- </div>
542
- </th>
543
- </tr>
544
708
  `
545
- }]
546
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
547
- type: Inject,
548
- args: [DOCUMENT]
549
- }] }]; }, propDecorators: { tableId: [{
550
- type: Input
551
- }], sortable: [{
552
- type: Input
553
- }], allColumns: [{
554
- type: Input
555
- }], currentColumns: [{
556
- type: Input
557
- }], columnOrdering: [{
558
- type: Input
559
- }], childRows: [{
560
- type: Input
561
- }], page: [{
562
- type: Input
563
- }], filterable: [{
564
- type: Input
565
- }], columnFiltering: [{
566
- type: Input
567
- }], filter: [{
568
- type: Input
569
- }], showFilterPlaceholders: [{
570
- type: Input
571
- }], notifierService: [{
572
- type: Input
573
- }], localPagingSize: [{
574
- type: Input
575
- }], sortChange: [{
576
- type: Output
577
- }], filterChange: [{
578
- type: Output
579
- }], columnChange: [{
580
- type: Output
581
- }] } });
582
-
583
- class SharkTableFooterComponent {
584
- tableUtils;
585
- start = 0;
586
- end = 0;
587
- total = 0;
588
- filtered = false;
589
- currentPageInfo = '';
590
- paginationComponent;
591
- leftSideFooterTemplate;
592
- rightSideFooterTemplate;
593
- notifierService;
594
- localPaging;
595
- localPagingSize;
596
- localPagingOptions;
597
- showLocalPagingOptions;
598
- /**
599
- * The current {@link Page}
600
- */
601
- page;
602
- /**
603
- * The current {@link SharkColumn}[]
604
- */
605
- currentColumns;
606
- /**
607
- * The current {@link SharkColumn}[]
608
- */
609
- allColumns;
610
- /**
611
- * The current filter string
612
- */
613
- filter;
614
- tableId;
615
- filterChange = new EventEmitter();
616
- paginationChange = new EventEmitter();
617
- constructor(tableUtils) {
618
- this.tableUtils = tableUtils;
619
- }
620
- ngOnChanges(changes) {
621
- this.total = this.page.totalElements;
622
- const size = this.page.size ? this.page.size : this.page.numberOfElements;
623
- let newStart = this.page.number * size + 1;
624
- if (newStart > this.total) {
625
- this.start = 0;
626
- }
627
- else {
628
- this.start = newStart;
629
- }
630
- let newEnd = this.page.number * size + this.page.numberOfElements;
631
- if (newEnd > this.total) {
632
- this.end = this.total;
633
- }
634
- else {
635
- this.end = newEnd;
636
- }
637
- const wasFiltered = this.filtered;
638
- this.filtered = (this.filter && this.filter.length > 0) || this.tableUtils.hasFilter(this.currentColumns);
639
- this.currentPageInfo = this.start + ' - ' + this.end + ' of ' + this.total + (this.filtered ? ' (filtered)' : '');
640
- const currentPageInfoAria = this.start + ' to ' + this.end + ' of ' + this.total + (this.filtered ? ' (filtered)' : '');
641
- if (changes.hasOwnProperty('page') && !changes['page'].isFirstChange()) {
642
- const pageChange = changes['page'];
643
- if (pageChange.previousValue.number !== pageChange.currentValue.number) {
644
- this.notifierService.postMessage('Page changed to ' + (pageChange.currentValue.number + 1) + ' showing ' + currentPageInfoAria);
645
- }
646
- else if (this.filtered || wasFiltered) {
647
- this.notifierService.postMessage('Filtering changed, showing ' + currentPageInfoAria);
648
- }
649
- }
650
- if (changes.hasOwnProperty('filter')) {
651
- const filterChange = changes['filter'];
652
- if (filterChange.previousValue !== filterChange.currentValue) {
653
- this.notifierService.postMessage('Filtering changed, showing ' + currentPageInfoAria);
654
- }
655
- }
656
- }
657
- firePageSizeChange() {
658
- this.filterChange.emit({
659
- columns: this.allColumns,
660
- filter: this.filter,
661
- localPagingSize: this.localPagingSize
662
- });
663
- this.notifierService.postMessage('Page size changed to ' + this.localPagingSize + ', page changed to ' + (this.page.number + 1));
664
- }
665
- changePage(pageNo) {
666
- this.paginationChange.emit(pageNo);
667
- }
668
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableFooterComponent, deps: [{ token: SharkTableUtils }], target: i0.ɵɵFactoryTarget.Component });
669
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: SharkTableFooterComponent, selector: "shark-table-footer", inputs: { leftSideFooterTemplate: "leftSideFooterTemplate", rightSideFooterTemplate: "rightSideFooterTemplate", notifierService: "notifierService", localPaging: "localPaging", localPagingSize: "localPagingSize", localPagingOptions: "localPagingOptions", showLocalPagingOptions: "showLocalPagingOptions", page: "page", currentColumns: "currentColumns", allColumns: "allColumns", filter: "filter", tableId: "tableId" }, outputs: { filterChange: "filterChange", paginationChange: "paginationChange" }, viewQueries: [{ propertyName: "paginationComponent", first: true, predicate: SharkTablePaginationComponent, descendants: true }], usesOnChanges: true, ngImport: i0, template: `
670
- <div class="info-footer">
671
- <div class="page-size-controls" *ngIf="localPaging && showLocalPagingOptions && currentColumns.length > 0">
672
- <label for="local-paging-size-{{ tableId }}" class="local-paging-options">
673
- Rows per page:
674
- </label>
675
- <select [(ngModel)]="localPagingSize" (change)="firePageSizeChange()" name="localPagingSize" class="local-paging-size" id="local-paging-size-{{ tableId }}">
676
- <option *ngFor="let option of localPagingOptions" [value]="option" [attr.selected]="option === localPagingSize ? 'selected' : null">{{ option }}</option>
677
- </select>
678
- <span>{{ currentPageInfo }}</span>
679
- </div>
680
- <div *ngIf="leftSideFooterTemplate" class="left-side-template">
681
- <ng-container *ngTemplateOutlet="leftSideFooterTemplate"></ng-container>
682
- </div>
683
- <div class="flex-spacer"></div>
684
- <div *ngIf="rightSideFooterTemplate" class="right-side-template">
685
- <ng-container *ngTemplateOutlet="rightSideFooterTemplate"></ng-container>
686
- </div>
687
- <div>
688
- <shark-table-pagination *ngIf="currentColumns.length > 0" [page]="page" [tableId]="tableId" (paginationChange)="changePage($event)"></shark-table-pagination>
689
- </div>
690
- </div>`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: SharkTablePaginationComponent, selector: "shark-table-pagination", inputs: ["page", "tableId"], outputs: ["paginationChange"] }] });
691
- }
692
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableFooterComponent, decorators: [{
693
- type: Component,
694
- args: [{
695
- selector: 'shark-table-footer',
696
- template: `
697
- <div class="info-footer">
698
- <div class="page-size-controls" *ngIf="localPaging && showLocalPagingOptions && currentColumns.length > 0">
699
- <label for="local-paging-size-{{ tableId }}" class="local-paging-options">
700
- Rows per page:
701
- </label>
702
- <select [(ngModel)]="localPagingSize" (change)="firePageSizeChange()" name="localPagingSize" class="local-paging-size" id="local-paging-size-{{ tableId }}">
703
- <option *ngFor="let option of localPagingOptions" [value]="option" [attr.selected]="option === localPagingSize ? 'selected' : null">{{ option }}</option>
704
- </select>
705
- <span>{{ currentPageInfo }}</span>
706
- </div>
707
- <div *ngIf="leftSideFooterTemplate" class="left-side-template">
708
- <ng-container *ngTemplateOutlet="leftSideFooterTemplate"></ng-container>
709
- </div>
710
- <div class="flex-spacer"></div>
711
- <div *ngIf="rightSideFooterTemplate" class="right-side-template">
712
- <ng-container *ngTemplateOutlet="rightSideFooterTemplate"></ng-container>
713
- </div>
714
- <div>
715
- <shark-table-pagination *ngIf="currentColumns.length > 0" [page]="page" [tableId]="tableId" (paginationChange)="changePage($event)"></shark-table-pagination>
716
- </div>
717
- </div>`
718
- }]
719
- }], ctorParameters: function () { return [{ type: SharkTableUtils }]; }, propDecorators: { paginationComponent: [{
720
- type: ViewChild,
721
- args: [SharkTablePaginationComponent, { static: false }]
722
- }], leftSideFooterTemplate: [{
723
- type: Input
724
- }], rightSideFooterTemplate: [{
725
- type: Input
726
- }], notifierService: [{
727
- type: Input
728
- }], localPaging: [{
729
- type: Input
730
- }], localPagingSize: [{
731
- type: Input
732
- }], localPagingOptions: [{
733
- type: Input
734
- }], showLocalPagingOptions: [{
735
- type: Input
736
- }], page: [{
737
- type: Input
738
- }], currentColumns: [{
739
- type: Input
740
- }], allColumns: [{
741
- type: Input
742
- }], filter: [{
743
- type: Input
744
- }], tableId: [{
745
- type: Input
746
- }], filterChange: [{
747
- type: Output
748
- }], paginationChange: [{
749
- type: Output
750
- }] } });
751
-
752
- class SharkTableInfoHeaderComponent {
753
- leftSideHeaderTemplate;
754
- rightSideHeaderTemplate;
755
- filterInput;
756
- columns;
757
- allColumns;
758
- columnPicker;
759
- serverSideData;
760
- filterable;
761
- columnFiltering;
762
- filter;
763
- showFilterPlaceholders;
764
- localPagingSize;
765
- notifierService;
766
- tableId;
767
- filterChange = new EventEmitter();
768
- columnChange = new EventEmitter();
769
- showDropDown = false;
770
- fireFilterChange() {
771
- this.filterChange.emit({
772
- columns: this.allColumns,
773
- filter: this.filter,
774
- localPagingSize: this.localPagingSize
775
- });
776
- }
777
- fireColumnChange() {
778
- this.columnChange.emit(this.allColumns);
779
- }
780
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableInfoHeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
781
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: SharkTableInfoHeaderComponent, selector: "shark-table-info-header", inputs: { leftSideHeaderTemplate: "leftSideHeaderTemplate", rightSideHeaderTemplate: "rightSideHeaderTemplate", columns: "columns", allColumns: "allColumns", columnPicker: "columnPicker", serverSideData: "serverSideData", filterable: "filterable", columnFiltering: "columnFiltering", filter: "filter", showFilterPlaceholders: "showFilterPlaceholders", localPagingSize: "localPagingSize", notifierService: "notifierService", tableId: "tableId" }, outputs: { filterChange: "filterChange", columnChange: "columnChange" }, viewQueries: [{ propertyName: "filterInput", first: true, predicate: ["filterInput"], descendants: true }], ngImport: i0, template: `
782
- <div class="info-header">
783
- <div class="controls header-buttons">
784
- <button *ngIf="columnPicker" class="toggle-dropdown" type="button" (click)="showDropDown = !showDropDown" [attr.aria-expanded]="showDropDown" [attr.aria-controls]="'column-picker-dropdown-' + tableId">
785
- <span>Choose Columns<i class="fa fa-fw fa-angle-down"></i></span>
786
- </button>
787
- <button class="server-refresh fa fa-sync" *ngIf="serverSideData" (click)="fireFilterChange()" type="button">
788
- <span class="screen-reader-button-label">Refresh Server Data</span>
789
- </button>
790
- <div *ngIf="leftSideHeaderTemplate" class="left-side-template">
791
- <ng-container *ngTemplateOutlet="leftSideHeaderTemplate"></ng-container>
792
- </div>
793
- <div class="flex-spacer"></div>
794
- <div *ngIf="rightSideHeaderTemplate" class="right-side-template">
795
- <ng-container *ngTemplateOutlet="rightSideHeaderTemplate"></ng-container>
796
- </div>
797
- <span class="filter-box" *ngIf="filterable && !columnFiltering && columns.length > 0">
798
- <label for="filter" class="screen-reader">Filter Results (all column search)</label>
799
- <input #filterInput type="text" name="filter" id="filter-{{ tableId }}" [(ngModel)]="filter" (ngModelChange)="fireFilterChange()" [attr.placeholder]="showFilterPlaceholders ? 'Filter Results' : null" />
800
- </span>
801
- </div>
802
- <div *ngIf="columnPicker" [id]="'column-picker-dropdown-' + tableId" class="dropdown" [attr.aria-hidden]="!showDropDown" role="region" tabindex="-1" [hidden]="!showDropDown" [ngStyle]="{'display': !showDropDown ? 'none' : 'block'}">
803
- <fieldset>
804
- <legend class="screen-reader">Columns to display</legend>
805
- <div class="column-wrapper">
806
- <label *ngFor="let column of allColumns">
807
- <input type="checkbox" [(ngModel)]="column.displayed" (ngModelChange)="fireColumnChange()" />
808
- {{ column.header }}
809
- </label>
810
- </div>
811
- </fieldset>
812
- </div>
813
- </div>
814
- `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
815
- }
816
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableInfoHeaderComponent, decorators: [{
817
- type: Component,
818
- args: [{
819
- selector: 'shark-table-info-header',
820
- template: `
821
- <div class="info-header">
822
- <div class="controls header-buttons">
823
- <button *ngIf="columnPicker" class="toggle-dropdown" type="button" (click)="showDropDown = !showDropDown" [attr.aria-expanded]="showDropDown" [attr.aria-controls]="'column-picker-dropdown-' + tableId">
824
- <span>Choose Columns<i class="fa fa-fw fa-angle-down"></i></span>
825
- </button>
826
- <button class="server-refresh fa fa-sync" *ngIf="serverSideData" (click)="fireFilterChange()" type="button">
827
- <span class="screen-reader-button-label">Refresh Server Data</span>
828
- </button>
829
- <div *ngIf="leftSideHeaderTemplate" class="left-side-template">
830
- <ng-container *ngTemplateOutlet="leftSideHeaderTemplate"></ng-container>
831
- </div>
832
- <div class="flex-spacer"></div>
833
- <div *ngIf="rightSideHeaderTemplate" class="right-side-template">
834
- <ng-container *ngTemplateOutlet="rightSideHeaderTemplate"></ng-container>
835
- </div>
836
- <span class="filter-box" *ngIf="filterable && !columnFiltering && columns.length > 0">
837
- <label for="filter" class="screen-reader">Filter Results (all column search)</label>
838
- <input #filterInput type="text" name="filter" id="filter-{{ tableId }}" [(ngModel)]="filter" (ngModelChange)="fireFilterChange()" [attr.placeholder]="showFilterPlaceholders ? 'Filter Results' : null" />
839
- </span>
840
- </div>
841
- <div *ngIf="columnPicker" [id]="'column-picker-dropdown-' + tableId" class="dropdown" [attr.aria-hidden]="!showDropDown" role="region" tabindex="-1" [hidden]="!showDropDown" [ngStyle]="{'display': !showDropDown ? 'none' : 'block'}">
842
- <fieldset>
843
- <legend class="screen-reader">Columns to display</legend>
844
- <div class="column-wrapper">
845
- <label *ngFor="let column of allColumns">
846
- <input type="checkbox" [(ngModel)]="column.displayed" (ngModelChange)="fireColumnChange()" />
847
- {{ column.header }}
848
- </label>
849
- </div>
850
- </fieldset>
851
- </div>
852
- </div>
853
- `
854
- }]
855
- }], propDecorators: { leftSideHeaderTemplate: [{
856
- type: Input
857
- }], rightSideHeaderTemplate: [{
858
- type: Input
859
- }], filterInput: [{
860
- type: ViewChild,
861
- args: ['filterInput', { static: false }]
862
- }], columns: [{
863
- type: Input
864
- }], allColumns: [{
865
- type: Input
866
- }], columnPicker: [{
867
- type: Input
868
- }], serverSideData: [{
869
- type: Input
870
- }], filterable: [{
871
- type: Input
872
- }], columnFiltering: [{
873
- type: Input
874
- }], filter: [{
875
- type: Input
876
- }], showFilterPlaceholders: [{
877
- type: Input
878
- }], localPagingSize: [{
879
- type: Input
880
- }], notifierService: [{
881
- type: Input
882
- }], tableId: [{
883
- type: Input
884
- }], filterChange: [{
885
- type: Output
886
- }], columnChange: [{
887
- type: Output
888
- }] } });
889
-
890
- class NotifierService {
891
- messageObservable;
892
- messageSubject;
893
- constructor() {
894
- this.messageSubject = new Subject();
895
- this.messageObservable = this.messageSubject.asObservable();
896
- }
897
- postMessage(message) {
898
- this.messageSubject.next(message);
899
- }
900
- }
901
-
902
- class AriaNotifierComponent {
903
- status;
904
- tableId;
905
- notifierService;
906
- notifierSubscription;
907
- ngOnChanges(changes) {
908
- if (changes.hasOwnProperty('notifierService')) {
909
- if (!this.notifierSubscription) {
910
- this.subscribeToNotifier();
911
- }
912
- else {
913
- this.notifierSubscription.unsubscribe();
914
- this.subscribeToNotifier();
915
- }
916
- }
917
- }
918
- ngOnDestroy() {
919
- if (this.notifierSubscription) {
920
- this.notifierSubscription.unsubscribe();
921
- }
922
- }
923
- subscribeToNotifier() {
924
- this.notifierSubscription = this.notifierService.messageObservable.subscribe((message) => {
925
- this.status = message;
926
- setTimeout(() => this.status = '', 1000);
927
- });
928
- }
929
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AriaNotifierComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
930
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: AriaNotifierComponent, selector: "shark-table-aria-notifier", inputs: { tableId: "tableId", notifierService: "notifierService" }, usesOnChanges: true, ngImport: i0, template: `<div id="shark-table-aria-notifier-{{ tableId }}" class="notification-area screen-reader" aria-atomic="true" aria-live="polite">{{ status }}</div>`, isInline: true });
931
- }
932
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AriaNotifierComponent, decorators: [{
933
- type: Component,
934
- args: [{
935
- selector: 'shark-table-aria-notifier',
936
- template: `<div id="shark-table-aria-notifier-{{ tableId }}" class="notification-area screen-reader" aria-atomic="true" aria-live="polite">{{ status }}</div>`
937
- }]
938
- }], propDecorators: { tableId: [{
939
- type: Input
940
- }], notifierService: [{
941
- type: Input
942
- }] } });
943
-
944
- class SharkTableCellComponent {
945
- tableUtils;
946
- componentFactoryResolver;
947
- cdr;
948
- column;
949
- row;
950
- tableCellContentsDirective;
951
- noComponentContents;
952
- constructor(tableUtils, componentFactoryResolver, cdr) {
953
- this.tableUtils = tableUtils;
954
- this.componentFactoryResolver = componentFactoryResolver;
955
- this.cdr = cdr;
956
- }
957
- ngAfterViewInit() {
958
- this.loadComponent();
959
- }
960
- retrieveCell(row, column) {
961
- return this.tableUtils.retrieveCell(row, column);
962
- }
963
- loadComponent() {
964
- if (this.column.component) {
965
- const contents = this.retrieveCell(this.row, this.column);
966
- const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.column.component);
967
- const viewContainerRef = this.tableCellContentsDirective.viewContainerRef;
968
- viewContainerRef.clear();
969
- const componentRef = viewContainerRef.createComponent(componentFactory);
970
- componentRef.instance.data = contents;
971
- componentRef.instance.row = this.row;
972
- }
973
- else {
974
- this.noComponentContents = this.retrieveCell(this.row, this.column);
975
- }
976
- // without this, everything went boom
977
- this.cdr.detectChanges();
978
- }
979
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableCellComponent, deps: [{ token: SharkTableUtils }, { token: i0.ComponentFactoryResolver }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
980
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: SharkTableCellComponent, selector: "shark-table-cell", inputs: { column: "column", row: "row" }, viewQueries: [{ propertyName: "tableCellContentsDirective", first: true, predicate: SharkDynamicContentsDirective, descendants: true }], ngImport: i0, template: `
981
- <ng-container *ngIf="column.component">
982
- <ng-template sharkDynamicContents></ng-template>
983
- </ng-container>
984
-
985
- <ng-container *ngIf="noComponentContents">
986
- {{ noComponentContents }}
987
- </ng-container>
988
- `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: SharkDynamicContentsDirective, selector: "[sharkDynamicContents]" }] });
989
- }
990
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableCellComponent, decorators: [{
991
- type: Component,
992
- args: [{
993
- selector: 'shark-table-cell',
994
- template: `
995
- <ng-container *ngIf="column.component">
996
- <ng-template sharkDynamicContents></ng-template>
997
- </ng-container>
998
-
999
- <ng-container *ngIf="noComponentContents">
1000
- {{ noComponentContents }}
1001
- </ng-container>
1002
- `
1003
- }]
1004
- }], ctorParameters: function () { return [{ type: SharkTableUtils }, { type: i0.ComponentFactoryResolver }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { column: [{
1005
- type: Input
1006
- }], row: [{
1007
- type: Input
1008
- }], tableCellContentsDirective: [{
1009
- type: ViewChild,
1010
- args: [SharkDynamicContentsDirective, { static: false }]
1011
- }] } });
1012
-
1013
- class LocalFilterPipe {
1014
- tableUtils;
1015
- constructor(tableUtils) {
1016
- this.tableUtils = tableUtils;
1017
- }
1018
- transform(items, cols, localFilter, localPaging, columnFiltering, filterText) {
1019
- if (localFilter && (columnFiltering && this.tableUtils.hasFilter(cols) || (filterText && filterText.length > 0))) {
1020
- return this.tableUtils.filter(items, cols, columnFiltering, filterText);
1021
- }
1022
- return items;
1023
- }
1024
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: LocalFilterPipe, deps: [{ token: SharkTableUtils }], target: i0.ɵɵFactoryTarget.Pipe });
1025
- static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: LocalFilterPipe, name: "localfilter" });
1026
- }
1027
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: LocalFilterPipe, decorators: [{
1028
- type: Pipe,
1029
- args: [{
1030
- name: 'localfilter'
1031
- }]
1032
- }], ctorParameters: function () { return [{ type: SharkTableUtils }]; } });
1033
-
1034
- /**
1035
- * This component controls each row in the table.
1036
- */
1037
- class SharkTableBodyComponent {
1038
- router;
1039
- tableUtils;
1040
- currentColumns;
1041
- columns;
1042
- localFilter;
1043
- localPaging;
1044
- columnFiltering;
1045
- filter;
1046
- rowStylingFunction;
1047
- cellStylingFunction;
1048
- childRows;
1049
- childComponent;
1050
- linkTarget;
1051
- linkKey;
1052
- tableEmptyMessage;
1053
- page;
1054
- openChildren = [];
1055
- constructor(router, tableUtils) {
1056
- this.router = router;
1057
- this.tableUtils = tableUtils;
1058
- }
1059
- ngOnChanges(changes) {
1060
- if (changes.hasOwnProperty('page') && !changes['page'].isFirstChange()) {
1061
- this.openChildren = [];
1062
- }
1063
- }
1064
- addStyleToCell(row, column) {
1065
- if (this.cellStylingFunction) {
1066
- const cellData = this.tableUtils.retrieveCell(row, column);
1067
- return this.cellStylingFunction(row, column, cellData);
1068
- }
1069
- return null;
1070
- }
1071
- childOpen(index) {
1072
- return this.openChildren.indexOf(index) > -1;
1073
- }
1074
- /**
1075
- * Toggle the show/hide status of the child row
1076
- */
1077
- toggleChild(index) {
1078
- if (this.openChildren.indexOf(index) > -1) {
1079
- this.openChildren.splice(this.openChildren.indexOf(index), 1);
1080
- }
1081
- else {
1082
- this.openChildren.push(index);
1083
- }
1084
- this.openChildren = this.openChildren.slice(0);
1085
- }
1086
- /**
1087
- * If provided, navigate to link for this row using the router.
1088
- */
1089
- rowClick(row) {
1090
- if (this.linkTarget && this.linkKey) {
1091
- this.router.navigate([this.linkTarget, this.tableUtils.findValue(row, this.linkKey)]);
1092
- }
1093
- }
1094
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableBodyComponent, deps: [{ token: i1$1.Router }, { token: SharkTableUtils }], target: i0.ɵɵFactoryTarget.Component });
1095
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: SharkTableBodyComponent, selector: "[shark-table-body]", inputs: { currentColumns: "currentColumns", columns: "columns", localFilter: "localFilter", localPaging: "localPaging", columnFiltering: "columnFiltering", filter: "filter", rowStylingFunction: "rowStylingFunction", cellStylingFunction: "cellStylingFunction", childRows: "childRows", childComponent: "childComponent", linkTarget: "linkTarget", linkKey: "linkKey", tableEmptyMessage: "tableEmptyMessage", page: "page" }, usesOnChanges: true, ngImport: i0, template: `
1096
- <ng-container *ngIf="page.content && currentColumns.length > 0">
1097
- <ng-container *ngFor="let row of (page.content | localfilter:currentColumns:localFilter:localPaging:columnFiltering:filter); let e = even; let o = odd; let i = index;">
709
+ }]
710
+ }],
711
+ propDecorators: {
712
+ tableId: [{ type: Input }],
713
+ sortable: [{ type: Input }],
714
+ allColumns: [{ type: Input }],
715
+ currentColumns: [{ type: Input }],
716
+ columnOrdering: [{ type: Input }],
717
+ childRows: [{ type: Input }],
718
+ page: [{ type: Input }],
719
+ filterable: [{ type: Input }],
720
+ columnFiltering: [{ type: Input }],
721
+ filter: [{ type: Input }],
722
+ showFilterPlaceholders: [{ type: Input }],
723
+ notifierService: [{ type: Input }],
724
+ localPagingSize: [{ type: Input }],
725
+ sortChange: [{ type: Output }],
726
+ filterChange: [{ type: Output }],
727
+ columnChange: [{ type: Output }]
728
+ }
729
+ });
730
+ var SharkTableCellComponent = class SharkTableCellComponent {
731
+ tableUtils = inject(SharkTableUtils);
732
+ column;
733
+ row;
734
+ dynamicHost;
735
+ contents;
736
+ componentRef;
737
+ ngOnChanges() {
738
+ this.contents = this.tableUtils.retrieveCell(this.row, this.column);
739
+ if (this.column.component) {
740
+ if (this.componentRef?.componentType !== this.column.component) {
741
+ this.dynamicHost.clear();
742
+ this.componentRef = this.dynamicHost.createComponent(this.column.component);
743
+ }
744
+ this.componentRef.instance.data = this.contents;
745
+ this.componentRef.instance.row = this.row;
746
+ this.componentRef.injector.get(ChangeDetectorRef).detectChanges();
747
+ } else if (this.componentRef) {
748
+ this.dynamicHost.clear();
749
+ this.componentRef = void 0;
750
+ }
751
+ }
752
+ ngOnDestroy() {
753
+ this.componentRef?.destroy();
754
+ }
755
+ static ɵfac = i0.ɵɵngDeclareFactory({
756
+ minVersion: "12.0.0",
757
+ version: "22.2.6",
758
+ ngImport: i0,
759
+ type: SharkTableCellComponent,
760
+ deps: [],
761
+ target: i0.ɵɵFactoryTarget.Component
762
+ });
763
+ static ɵcmp = i0.ɵɵngDeclareComponent({
764
+ minVersion: "17.0.0",
765
+ version: "22.2.6",
766
+ type: SharkTableCellComponent,
767
+ isStandalone: true,
768
+ selector: "shark-table-cell",
769
+ inputs: {
770
+ column: "column",
771
+ row: "row"
772
+ },
773
+ viewQueries: [{
774
+ propertyName: "dynamicHost",
775
+ first: true,
776
+ predicate: ["dynamicHost"],
777
+ descendants: true,
778
+ read: ViewContainerRef,
779
+ static: true
780
+ }],
781
+ usesOnChanges: true,
782
+ ngImport: i0,
783
+ template: `<ng-container #dynamicHost></ng-container>@if (!column.component) { {{ contents ?? '' }} }`,
784
+ isInline: true
785
+ });
786
+ };
787
+ i0.ɵɵngDeclareClassMetadata({
788
+ minVersion: "12.0.0",
789
+ version: "22.2.6",
790
+ ngImport: i0,
791
+ type: SharkTableCellComponent,
792
+ decorators: [{
793
+ type: Component,
794
+ args: [{
795
+ selector: "shark-table-cell",
796
+ template: `<ng-container #dynamicHost></ng-container>@if (!column.component) { {{ contents ?? '' }} }`
797
+ }]
798
+ }],
799
+ propDecorators: {
800
+ column: [{ type: Input }],
801
+ row: [{ type: Input }],
802
+ dynamicHost: [{
803
+ type: ViewChild,
804
+ args: ["dynamicHost", {
805
+ read: ViewContainerRef,
806
+ static: true
807
+ }]
808
+ }]
809
+ }
810
+ });
811
+ const INTERACTIVE_SELECTOR = "a, button, input, select, textarea, label, [role=\"button\"], [contenteditable=\"true\"]";
812
+ var SharkTableBodyComponent = class SharkTableBodyComponent {
813
+ router = inject(Router);
814
+ locationStrategy = inject(LocationStrategy);
815
+ tableUtils = inject(SharkTableUtils);
816
+ currentColumns = [];
817
+ columns = [];
818
+ rowStylingFunction;
819
+ cellStylingFunction;
820
+ childRows;
821
+ childComponent;
822
+ linkTarget;
823
+ linkKey;
824
+ tableEmptyMessage;
825
+ page;
826
+ openChildren = [];
827
+ get isLinked() {
828
+ return !!this.linkTarget && !!this.linkKey;
829
+ }
830
+ ngOnChanges(changes) {
831
+ if (changes["page"] && !changes["page"].isFirstChange()) this.openChildren = [];
832
+ }
833
+ addStyleToCell(row, column) {
834
+ if (this.cellStylingFunction) {
835
+ const cellData = this.tableUtils.retrieveCell(row, column);
836
+ return this.cellStylingFunction(row, column, cellData);
837
+ }
838
+ return null;
839
+ }
840
+ childOpen(index) {
841
+ return this.openChildren.includes(index);
842
+ }
843
+ toggleChild(index) {
844
+ this.openChildren = this.childOpen(index) ? this.openChildren.filter((open) => open !== index) : [...this.openChildren, index];
845
+ }
846
+ rowClick(row, event) {
847
+ if (!this.isLinked || this.isFromInteractiveElement(event)) return;
848
+ const mouseEvent = event;
849
+ if (mouseEvent && (mouseEvent.ctrlKey || mouseEvent.metaKey || mouseEvent.shiftKey)) {
850
+ this.openInNewTab(row);
851
+ return;
852
+ }
853
+ const commands = this.linkCommands(row);
854
+ if (commands) this.router.navigate(commands);
855
+ }
856
+ rowAuxClick(row, event) {
857
+ if (event.button === 1 && this.isLinked && !this.isFromInteractiveElement(event)) {
858
+ event.preventDefault();
859
+ this.openInNewTab(row);
860
+ }
861
+ }
862
+ preventMiddleClickScroll(event) {
863
+ if (event.button === 1 && this.isLinked && !this.isFromInteractiveElement(event)) event.preventDefault();
864
+ }
865
+ openInNewTab(row) {
866
+ const commands = this.linkCommands(row);
867
+ if (!commands) return;
868
+ const url = this.router.serializeUrl(this.router.createUrlTree(commands));
869
+ window.open(this.locationStrategy.prepareExternalUrl(url), "_blank", "noopener");
870
+ }
871
+ linkCommands(row) {
872
+ const key = this.tableUtils.findValue(row, this.linkKey ?? "");
873
+ return key == null || key === "" || !this.linkTarget ? null : [this.linkTarget, key];
874
+ }
875
+ isFromInteractiveElement(event) {
876
+ const target = event?.target;
877
+ const row = event?.currentTarget;
878
+ const interactive = target?.closest?.(INTERACTIVE_SELECTOR);
879
+ return !!interactive && interactive !== row && !!row?.contains(interactive);
880
+ }
881
+ static ɵfac = i0.ɵɵngDeclareFactory({
882
+ minVersion: "12.0.0",
883
+ version: "22.2.6",
884
+ ngImport: i0,
885
+ type: SharkTableBodyComponent,
886
+ deps: [],
887
+ target: i0.ɵɵFactoryTarget.Component
888
+ });
889
+ static ɵcmp = i0.ɵɵngDeclareComponent({
890
+ minVersion: "17.0.0",
891
+ version: "22.2.6",
892
+ type: SharkTableBodyComponent,
893
+ isStandalone: true,
894
+ selector: "[shark-table-body]",
895
+ inputs: {
896
+ currentColumns: "currentColumns",
897
+ columns: "columns",
898
+ rowStylingFunction: "rowStylingFunction",
899
+ cellStylingFunction: "cellStylingFunction",
900
+ childRows: "childRows",
901
+ childComponent: "childComponent",
902
+ linkTarget: "linkTarget",
903
+ linkKey: "linkKey",
904
+ tableEmptyMessage: "tableEmptyMessage",
905
+ page: "page"
906
+ },
907
+ usesOnChanges: true,
908
+ ngImport: i0,
909
+ template: `
910
+ @if (currentColumns.length === 0) {
911
+ <tr><td [attr.colspan]="childRows ? columns.length + 1 : columns.length">There are no columns selected</td></tr>
912
+ } @else if (!page.content || page.content.length === 0) {
913
+ <tr><td [attr.colspan]="childRows ? currentColumns.length + 1 : currentColumns.length">{{ tableEmptyMessage }}</td></tr>
914
+ } @else {
915
+ @for (row of page.content; track $index; let e = $even, o = $odd, i = $index) {
1098
916
  <tr class="data-row"
1099
- [ngClass]="{ odd: o, even: e, rowLink: linkTarget, rowOpen: childOpen(i) }"
1100
- [ngStyle]="rowStylingFunction(row)"
1101
- (click)="rowClick(row)" (keyup.enter)="rowClick(row)"
1102
- [attr.tabindex]="linkTarget ? 0 : null"
917
+ [ngClass]="{ odd: o, even: e, rowLink: isLinked, rowOpen: childOpen(i) }"
918
+ [ngStyle]="rowStylingFunction?.(row)"
919
+ (click)="rowClick(row, $event)"
920
+ (auxclick)="rowAuxClick(row, $event)"
921
+ (mousedown)="preventMiddleClickScroll($event)"
922
+ (keydown.enter)="rowClick(row, $event)"
923
+ [attr.tabindex]="isLinked ? 0 : null"
1103
924
  >
1104
- <td class="header-buttons" *ngIf="childRows">
1105
- <button class="black-arrow fa fa-fw"
1106
- [attr.aria-expanded]="childOpen(i)"
1107
- [ngClass]="{ 'open': childOpen(i), 'closed': !childOpen(i), 'fa-caret-down': childOpen(i), 'fa-caret-right': !childOpen(i) }"
1108
- (click)="toggleChild(i)" type="button" aria-label="Details Row"
1109
- >
1110
- </button>
1111
- </td>
1112
- <ng-container *ngFor="let column of currentColumns">
925
+ @if (childRows) {
926
+ <td class="header-buttons">
927
+ <button class="black-arrow fa fa-fw"
928
+ [attr.aria-expanded]="childOpen(i)"
929
+ [ngClass]="{ 'open': childOpen(i), 'closed': !childOpen(i), 'fa-caret-down': childOpen(i), 'fa-caret-right': !childOpen(i) }"
930
+ (click)="toggleChild(i)" type="button" aria-label="Details Row"
931
+ >
932
+ </button>
933
+ </td>
934
+ }
935
+ @for (column of currentColumns; track column) {
1113
936
  <td [ngClass]="{'right': column.alignRight }" [ngStyle]="addStyleToCell(row, column)">
1114
937
  <shark-table-cell [column]="column" [row]="row"></shark-table-cell>
1115
938
  </td>
1116
- </ng-container>
1117
- </tr>
1118
- <tr *ngIf="childRows" class="data-row child-row" [ngClass]="{ odd: o, even: e, rowOpen: childOpen(i) }" [hidden]="!childOpen(i)">
1119
- <td></td>
1120
- <td [attr.colspan]="currentColumns.length">
1121
- <shark-child [component]="childComponent" [row]="row" [rowIndex]="i" [openChildren]="openChildren"></shark-child>
1122
- </td>
939
+ }
1123
940
  </tr>
1124
- </ng-container>
1125
- </ng-container>
1126
- <ng-container *ngIf="currentColumns.length === 0">
941
+ @if (childRows) {
942
+ <tr class="data-row child-row" [ngClass]="{ odd: o, even: e, rowOpen: childOpen(i) }" [hidden]="!childOpen(i)">
943
+ <td></td>
944
+ <td [attr.colspan]="currentColumns.length">
945
+ <shark-child [component]="childComponent" [row]="row" [rowIndex]="i" [openChildren]="openChildren"></shark-child>
946
+ </td>
947
+ </tr>
948
+ }
949
+ }
950
+ }
951
+ `,
952
+ isInline: true,
953
+ dependencies: [
954
+ {
955
+ kind: "directive",
956
+ type: NgClass,
957
+ selector: "[ngClass]",
958
+ inputs: ["class", "ngClass"]
959
+ },
960
+ {
961
+ kind: "directive",
962
+ type: NgStyle,
963
+ selector: "[ngStyle]",
964
+ inputs: ["ngStyle"]
965
+ },
966
+ {
967
+ kind: "component",
968
+ type: SharkTableCellComponent,
969
+ selector: "shark-table-cell",
970
+ inputs: ["column", "row"]
971
+ },
972
+ {
973
+ kind: "component",
974
+ type: SharkChildComponent,
975
+ selector: "shark-child",
976
+ inputs: [
977
+ "component",
978
+ "row",
979
+ "rowIndex",
980
+ "openChildren"
981
+ ]
982
+ }
983
+ ]
984
+ });
985
+ };
986
+ i0.ɵɵngDeclareClassMetadata({
987
+ minVersion: "12.0.0",
988
+ version: "22.2.6",
989
+ ngImport: i0,
990
+ type: SharkTableBodyComponent,
991
+ decorators: [{
992
+ type: Component,
993
+ args: [{
994
+ selector: "[shark-table-body]",
995
+ imports: [
996
+ NgClass,
997
+ NgStyle,
998
+ SharkTableCellComponent,
999
+ SharkChildComponent
1000
+ ],
1001
+ template: `
1002
+ @if (currentColumns.length === 0) {
1127
1003
  <tr><td [attr.colspan]="childRows ? columns.length + 1 : columns.length">There are no columns selected</td></tr>
1128
- </ng-container>
1129
- <ng-container *ngIf="(!page.content || page.content.length == 0) && currentColumns.length > 0">
1004
+ } @else if (!page.content || page.content.length === 0) {
1130
1005
  <tr><td [attr.colspan]="childRows ? currentColumns.length + 1 : currentColumns.length">{{ tableEmptyMessage }}</td></tr>
1131
- </ng-container>
1132
- `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "component", type: SharkChildComponent, selector: "shark-child", inputs: ["component", "row", "rowIndex", "openChildren"] }, { kind: "component", type: SharkTableCellComponent, selector: "shark-table-cell", inputs: ["column", "row"] }, { kind: "pipe", type: LocalFilterPipe, name: "localfilter" }] });
1133
- }
1134
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableBodyComponent, decorators: [{
1135
- type: Component,
1136
- args: [{
1137
- selector: '[shark-table-body]',
1138
- template: `
1139
- <ng-container *ngIf="page.content && currentColumns.length > 0">
1140
- <ng-container *ngFor="let row of (page.content | localfilter:currentColumns:localFilter:localPaging:columnFiltering:filter); let e = even; let o = odd; let i = index;">
1006
+ } @else {
1007
+ @for (row of page.content; track $index; let e = $even, o = $odd, i = $index) {
1141
1008
  <tr class="data-row"
1142
- [ngClass]="{ odd: o, even: e, rowLink: linkTarget, rowOpen: childOpen(i) }"
1143
- [ngStyle]="rowStylingFunction(row)"
1144
- (click)="rowClick(row)" (keyup.enter)="rowClick(row)"
1145
- [attr.tabindex]="linkTarget ? 0 : null"
1009
+ [ngClass]="{ odd: o, even: e, rowLink: isLinked, rowOpen: childOpen(i) }"
1010
+ [ngStyle]="rowStylingFunction?.(row)"
1011
+ (click)="rowClick(row, $event)"
1012
+ (auxclick)="rowAuxClick(row, $event)"
1013
+ (mousedown)="preventMiddleClickScroll($event)"
1014
+ (keydown.enter)="rowClick(row, $event)"
1015
+ [attr.tabindex]="isLinked ? 0 : null"
1146
1016
  >
1147
- <td class="header-buttons" *ngIf="childRows">
1148
- <button class="black-arrow fa fa-fw"
1149
- [attr.aria-expanded]="childOpen(i)"
1150
- [ngClass]="{ 'open': childOpen(i), 'closed': !childOpen(i), 'fa-caret-down': childOpen(i), 'fa-caret-right': !childOpen(i) }"
1151
- (click)="toggleChild(i)" type="button" aria-label="Details Row"
1152
- >
1153
- </button>
1154
- </td>
1155
- <ng-container *ngFor="let column of currentColumns">
1017
+ @if (childRows) {
1018
+ <td class="header-buttons">
1019
+ <button class="black-arrow fa fa-fw"
1020
+ [attr.aria-expanded]="childOpen(i)"
1021
+ [ngClass]="{ 'open': childOpen(i), 'closed': !childOpen(i), 'fa-caret-down': childOpen(i), 'fa-caret-right': !childOpen(i) }"
1022
+ (click)="toggleChild(i)" type="button" aria-label="Details Row"
1023
+ >
1024
+ </button>
1025
+ </td>
1026
+ }
1027
+ @for (column of currentColumns; track column) {
1156
1028
  <td [ngClass]="{'right': column.alignRight }" [ngStyle]="addStyleToCell(row, column)">
1157
1029
  <shark-table-cell [column]="column" [row]="row"></shark-table-cell>
1158
1030
  </td>
1159
- </ng-container>
1160
- </tr>
1161
- <tr *ngIf="childRows" class="data-row child-row" [ngClass]="{ odd: o, even: e, rowOpen: childOpen(i) }" [hidden]="!childOpen(i)">
1162
- <td></td>
1163
- <td [attr.colspan]="currentColumns.length">
1164
- <shark-child [component]="childComponent" [row]="row" [rowIndex]="i" [openChildren]="openChildren"></shark-child>
1165
- </td>
1166
- </tr>
1167
- </ng-container>
1168
- </ng-container>
1169
- <ng-container *ngIf="currentColumns.length === 0">
1170
- <tr><td [attr.colspan]="childRows ? columns.length + 1 : columns.length">There are no columns selected</td></tr>
1171
- </ng-container>
1172
- <ng-container *ngIf="(!page.content || page.content.length == 0) && currentColumns.length > 0">
1173
- <tr><td [attr.colspan]="childRows ? currentColumns.length + 1 : currentColumns.length">{{ tableEmptyMessage }}</td></tr>
1174
- </ng-container>
1175
- `
1176
- }]
1177
- }], ctorParameters: function () { return [{ type: i1$1.Router }, { type: SharkTableUtils }]; }, propDecorators: { currentColumns: [{
1178
- type: Input
1179
- }], columns: [{
1180
- type: Input
1181
- }], localFilter: [{
1182
- type: Input
1183
- }], localPaging: [{
1184
- type: Input
1185
- }], columnFiltering: [{
1186
- type: Input
1187
- }], filter: [{
1188
- type: Input
1189
- }], rowStylingFunction: [{
1190
- type: Input
1191
- }], cellStylingFunction: [{
1192
- type: Input
1193
- }], childRows: [{
1194
- type: Input
1195
- }], childComponent: [{
1196
- type: Input
1197
- }], linkTarget: [{
1198
- type: Input
1199
- }], linkKey: [{
1200
- type: Input
1201
- }], tableEmptyMessage: [{
1202
- type: Input
1203
- }], page: [{
1204
- type: Input
1205
- }] } });
1206
-
1207
- class SharkTableComponent {
1208
- router;
1209
- tableUtils;
1210
- headerInfoComponent;
1211
- headerComponent;
1212
- footerComponent;
1213
- headerLeftTemplate;
1214
- headerRightTemplate;
1215
- footerLeftTemplate;
1216
- footerRightTemplate;
1217
- notifierService = new NotifierService();
1218
- /**
1219
- * An ID for this table, defaults to `uuid.substring(0, 5)`
1220
- */
1221
- tableId = v4().substring(0, 5);
1222
- /**
1223
- * The raw table data
1224
- */
1225
- data;
1226
- /**
1227
- * The table column definitions
1228
- */
1229
- columns;
1230
- currentColumns = [];
1231
- /**
1232
- * The <caption> text for this table
1233
- */
1234
- caption = 'A Data Table';
1235
- /**
1236
- * Whether or not the table <caption> should be hidden (screen-reader) only.
1237
- */
1238
- hideCaption = false;
1239
- /**
1240
- * Allow users to turn columns on and off
1241
- */
1242
- columnPicker = false;
1243
- /**
1244
- * Allow users to reorder columns with header buttons
1245
- */
1246
- columnOrdering = false;
1247
- /**
1248
- * The destination page for the call to `router.navigate` when the row is clicked.
1249
- */
1250
- linkTarget;
1251
- /**
1252
- * The property name from the data object to pass to `router.navigate` when the rows is clicked.
1253
- */
1254
- linkKey;
1255
- /**
1256
- * Enables the sorting headers
1257
- */
1258
- sortable = true;
1259
- /**
1260
- * Enables the global filter text box
1261
- */
1262
- filterable = true;
1263
- /**
1264
- * Enables column specific filter boxes
1265
- */
1266
- columnFiltering = false;
1267
- /**
1268
- * Enables client-side filtering as opposed to just emitting a `SharkPageChangeEvent`
1269
- */
1270
- localFilter = true;
1271
- /**
1272
- * Enables the placeholder text for the filter boxes
1273
- */
1274
- showFilterPlaceholders = true;
1275
- /**
1276
- * Enables client-side pagination as opposed to just emitting a `SharkPageChangeEvent`
1277
- */
1278
- localPaging = true;
1279
- /**
1280
- * The size of each page
1281
- */
1282
- localPagingSize = 10;
1283
- /**
1284
- * The supported page sizes
1285
- */
1286
- localPagingOptions = [10, 20, 100];
1287
- /**
1288
- * Enables the drop down for changing the page size
1289
- */
1290
- showLocalPagingOptions = true;
1291
- /**
1292
- * Shows a button that when clicked, emits a `SharkPageChangeEvent`
1293
- */
1294
- serverSideData = false;
1295
- /**
1296
- * The initial sortString
1297
- */
1298
- initialSort;
1299
- cellStylingFunction;
1300
- /**
1301
- * Enables children rows
1302
- */
1303
- childRows = false;
1304
- /**
1305
- * Your custom component which extends {@link SharkDynamicContents} that will be used
1306
- * to render each child row. Your custom component needs to be registered in your NgModule
1307
- * as an `entryComponent` and in the `declarations` section.
1308
- *
1309
- * The easiest way to specify this component in your HTML template is to create an instance variable
1310
- * and assign it, eg:
1311
- *
1312
- * ```typescript
1313
- * @Component({
1314
- * template: `
1315
- * <shark-table
1316
- * [data]="testData"
1317
- * [columns]="tableColumns"
1318
- * [childRows]="true"
1319
- * [childComponent]="childComponent"
1320
- * >
1321
- * </shark-table>
1322
- * `
1323
- * })
1324
- * export class MyComponent {
1325
- * childComponent = MyChildComponent
1326
- * }
1327
- *
1328
- * ```
1329
- */
1330
- childComponent;
1331
- /**
1332
- * {@link SharkPageChangeEvent} events are emitted from here
1333
- */
1334
- pageChange = new EventEmitter();
1335
- /**
1336
- * The column metadata is emitted from here whenever it changes
1337
- */
1338
- columnChange = new EventEmitter();
1339
- /**
1340
- * Disable the column change event, if needed, for performance reasons
1341
- */
1342
- disableColumnChangeEvent = false;
1343
- /**
1344
- * The current filter value
1345
- */
1346
- filter;
1347
- /**
1348
- * Show the footer with 'Showing x through y of z rows`
1349
- */
1350
- footer = true;
1351
- /**
1352
- * Message to show when the table is empty
1353
- */
1354
- tableEmptyMessage = 'This table contains no rows';
1355
- page;
1356
- dataSubscription;
1357
- localSubscription;
1358
- rowStylingFunction = row => ({});
1359
- constructor(router, tableUtils) {
1360
- this.router = router;
1361
- this.tableUtils = tableUtils;
1362
- }
1363
- ngOnInit() {
1364
- this.updatePage();
1365
- }
1366
- ngOnChanges(changes) {
1367
- const dataChange = changes['data'];
1368
- const columnChange = changes['columns'];
1369
- if (columnChange && columnChange.isFirstChange()) {
1370
- this.columns = columnChange.currentValue;
1371
- this.columns.forEach((column) => {
1372
- if (!column.hasOwnProperty('displayed')) {
1373
- column.displayed = true;
1374
1031
  }
1375
- });
1376
- this.updateCurrentColumns(this.columns, false);
1377
- }
1378
- if (dataChange && !dataChange.isFirstChange()) {
1379
- this.updatePage();
1380
- }
1381
- else if (columnChange && !columnChange.isFirstChange()) {
1382
- this.updateCurrentColumns(columnChange.currentValue);
1383
- }
1384
- }
1385
- ngOnDestroy() {
1386
- if (this.dataSubscription) {
1387
- this.dataSubscription.unsubscribe();
1388
- }
1389
- if (this.localSubscription) {
1390
- this.localSubscription.unsubscribe();
1391
- }
1392
- }
1393
- updateCurrentColumns(newColumns, emitPageEvent = true) {
1394
- this.currentColumns = newColumns.filter((value) => value.displayed);
1395
- this.columns = newColumns;
1396
- if (emitPageEvent) {
1397
- this.emitCurrent();
1398
- }
1399
- this.publishColumnChangeEvent();
1400
- }
1401
- /**
1402
- * Emits a {@link SharkPageChangeEvent} with the current information. This event should be consumed by the host
1403
- * component and sent to a REST endpoint to update the data.
1404
- */
1405
- emitCurrent() {
1406
- this.pageChange.emit({
1407
- pageNo: this.page.number,
1408
- columns: this.currentColumns,
1409
- sortString: this.generateSortString(),
1410
- sorts: this.generateSortArray(),
1411
- filter: this.filter
1412
- });
1413
- }
1414
- headerChange(event) {
1415
- this.columns = event.columns;
1416
- this.currentColumns = this.columns.filter((value) => value.displayed);
1417
- this.filter = event.filter;
1418
- this.localPagingSize = event.localPagingSize;
1419
- this.emitCurrent();
1420
- }
1421
- changePage(pageNo) {
1422
- this.pageChange.emit({
1423
- pageNo: pageNo,
1424
- columns: this.currentColumns,
1425
- sortString: this.generateSortString(),
1426
- sorts: this.generateSortArray(),
1427
- filter: this.filter
1428
- });
1429
- }
1430
- changeSort(columnProperty, sortType) {
1431
- if (this.sortable) {
1432
- this.currentColumns.forEach((column) => {
1433
- if (column.property === columnProperty) {
1434
- // State Machine
1435
- // ASC -> DESC -> NONE -> ASC
1436
- switch (sortType) {
1437
- case SharkSortType.ASC: {
1438
- // -> DESC
1439
- column.sortType = SharkSortType.DESC;
1440
- break;
1441
- }
1442
- case SharkSortType.DESC: {
1443
- // -> NONE
1444
- column.sortType = SharkSortType.NONE;
1445
- break;
1446
- }
1447
- case SharkSortType.NONE:
1448
- default: {
1449
- // -> ASC
1450
- column.sortType = SharkSortType.ASC;
1451
- break;
1452
- }
1453
- }
1454
- this.notifierService.postMessage((column.sortType === SharkSortType.DESC ? 'sorted descending' : column.sortType === SharkSortType.ASC ? 'sorted ascending' : 'unsorted'));
1455
- }
1456
- });
1457
- const sorts = this.generateSortArray();
1458
- if (!this.serverSideData) {
1459
- // sort internally
1460
- this.sort(this.page.content, sorts);
1032
+ </tr>
1033
+ @if (childRows) {
1034
+ <tr class="data-row child-row" [ngClass]="{ odd: o, even: e, rowOpen: childOpen(i) }" [hidden]="!childOpen(i)">
1035
+ <td></td>
1036
+ <td [attr.colspan]="currentColumns.length">
1037
+ <shark-child [component]="childComponent" [row]="row" [rowIndex]="i" [openChildren]="openChildren"></shark-child>
1038
+ </td>
1039
+ </tr>
1461
1040
  }
1462
- this.pageChange.emit({
1463
- pageNo: this.page.number,
1464
- columns: this.currentColumns,
1465
- sortString: this.generateSortString(),
1466
- sorts: sorts,
1467
- filter: this.filter
1468
- });
1469
- this.publishColumnChangeEvent();
1470
- }
1471
- }
1472
- /**
1473
- * Currently only works if your input is an any[], returns the current "view" into the table with filtering/column selection
1474
- *
1475
- * @param rendered If you would like inline pipes to be applied to the exported data
1476
- */
1477
- exportCurrentData(rendered = true) {
1478
- let currentData;
1479
- if (this.localFilter && (this.columnFiltering && this.tableUtils.hasFilter(this.currentColumns) || (this.filter && this.filter.length > 0))) {
1480
- currentData = this.tableUtils.filter(this.data, this.currentColumns, this.columnFiltering, this.filter);
1481
- this.sort(currentData, this.generateSortArray());
1482
- }
1483
- else {
1484
- currentData = this.data;
1485
- }
1486
- if (this.currentColumns.length === 0) {
1487
- return {
1488
- data: [],
1489
- columns: []
1490
- };
1491
- }
1492
- return {
1493
- data: currentData.map(row => this.tableUtils.exportRow(row, this.currentColumns, rendered)),
1494
- columns: this.currentColumns
1495
- };
1496
- }
1497
- publishColumnChangeEvent() {
1498
- if (!this.disableColumnChangeEvent) {
1499
- this.columnChange.emit({
1500
- columns: this.columns,
1501
- currentSortString: this.generateSortString()
1502
- });
1041
+ }
1503
1042
  }
1043
+ `
1044
+ }]
1045
+ }],
1046
+ propDecorators: {
1047
+ currentColumns: [{ type: Input }],
1048
+ columns: [{ type: Input }],
1049
+ rowStylingFunction: [{ type: Input }],
1050
+ cellStylingFunction: [{ type: Input }],
1051
+ childRows: [{ type: Input }],
1052
+ childComponent: [{ type: Input }],
1053
+ linkTarget: [{ type: Input }],
1054
+ linkKey: [{ type: Input }],
1055
+ tableEmptyMessage: [{ type: Input }],
1056
+ page: [{ type: Input }]
1057
+ }
1058
+ });
1059
+ var SharkTableFooterComponent = class SharkTableFooterComponent {
1060
+ tableUtils = inject(SharkTableUtils);
1061
+ start = 0;
1062
+ end = 0;
1063
+ total = 0;
1064
+ filtered = false;
1065
+ currentPageInfo = "";
1066
+ paginationComponent;
1067
+ leftSideFooterTemplate;
1068
+ rightSideFooterTemplate;
1069
+ notifierService;
1070
+ localPaging;
1071
+ localPagingSize;
1072
+ localPagingOptions = [];
1073
+ showLocalPagingOptions;
1074
+ page;
1075
+ currentColumns = [];
1076
+ allColumns = [];
1077
+ filter;
1078
+ tableId;
1079
+ filterChange = new EventEmitter();
1080
+ paginationChange = new EventEmitter();
1081
+ ngOnChanges(changes) {
1082
+ if (!this.page) return;
1083
+ const pageNumber = this.page.number ?? 0;
1084
+ const numberOfElements = this.page.numberOfElements ?? this.page.content?.length ?? 0;
1085
+ const size = this.page.size || numberOfElements;
1086
+ this.total = this.page.totalElements ?? numberOfElements;
1087
+ const newStart = pageNumber * size + 1;
1088
+ this.start = this.total === 0 || newStart > this.total ? 0 : newStart;
1089
+ const newEnd = pageNumber * size + numberOfElements;
1090
+ this.end = Math.min(newEnd, this.total);
1091
+ const wasFiltered = this.filtered;
1092
+ this.filtered = !!this.filter && this.filter.length > 0 || this.tableUtils.hasFilter(this.currentColumns);
1093
+ this.currentPageInfo = this.start + " - " + this.end + " of " + this.total + (this.filtered ? " (filtered)" : "");
1094
+ const currentPageInfoAria = this.start + " to " + this.end + " of " + this.total + (this.filtered ? " (filtered)" : "");
1095
+ const pageChange = changes["page"];
1096
+ const filterChange = changes["filter"];
1097
+ if (pageChange && !pageChange.isFirstChange()) {
1098
+ if (pageChange.previousValue?.number !== pageChange.currentValue?.number) this.notifierService.postMessage("Page changed to " + (pageNumber + 1) + " showing " + currentPageInfoAria);
1099
+ else if (this.filtered || wasFiltered) this.notifierService.postMessage("Filtering changed, showing " + currentPageInfoAria);
1100
+ } else if (filterChange && !filterChange.isFirstChange() && filterChange.previousValue !== filterChange.currentValue) this.notifierService.postMessage("Filtering changed, showing " + currentPageInfoAria);
1101
+ }
1102
+ firePageSizeChange() {
1103
+ this.filterChange.emit({
1104
+ columns: this.allColumns,
1105
+ filter: this.filter,
1106
+ localPagingSize: Number(this.localPagingSize)
1107
+ });
1108
+ this.notifierService.postMessage("Page size changed to " + this.localPagingSize);
1109
+ }
1110
+ changePage(pageNo) {
1111
+ this.paginationChange.emit(pageNo);
1112
+ }
1113
+ static ɵfac = i0.ɵɵngDeclareFactory({
1114
+ minVersion: "12.0.0",
1115
+ version: "22.2.6",
1116
+ ngImport: i0,
1117
+ type: SharkTableFooterComponent,
1118
+ deps: [],
1119
+ target: i0.ɵɵFactoryTarget.Component
1120
+ });
1121
+ static ɵcmp = i0.ɵɵngDeclareComponent({
1122
+ minVersion: "17.0.0",
1123
+ version: "22.2.6",
1124
+ type: SharkTableFooterComponent,
1125
+ isStandalone: true,
1126
+ selector: "shark-table-footer",
1127
+ inputs: {
1128
+ leftSideFooterTemplate: "leftSideFooterTemplate",
1129
+ rightSideFooterTemplate: "rightSideFooterTemplate",
1130
+ notifierService: "notifierService",
1131
+ localPaging: "localPaging",
1132
+ localPagingSize: "localPagingSize",
1133
+ localPagingOptions: "localPagingOptions",
1134
+ showLocalPagingOptions: "showLocalPagingOptions",
1135
+ page: "page",
1136
+ currentColumns: "currentColumns",
1137
+ allColumns: "allColumns",
1138
+ filter: "filter",
1139
+ tableId: "tableId"
1140
+ },
1141
+ outputs: {
1142
+ filterChange: "filterChange",
1143
+ paginationChange: "paginationChange"
1144
+ },
1145
+ viewQueries: [{
1146
+ propertyName: "paginationComponent",
1147
+ first: true,
1148
+ predicate: SharkTablePaginationComponent,
1149
+ descendants: true
1150
+ }],
1151
+ usesOnChanges: true,
1152
+ ngImport: i0,
1153
+ template: `
1154
+ <div class="info-footer">
1155
+ @if (localPaging && showLocalPagingOptions && currentColumns.length > 0) {
1156
+ <div class="page-size-controls">
1157
+ <label for="local-paging-size-{{ tableId }}" class="local-paging-options">
1158
+ Rows per page:
1159
+ </label>
1160
+ <select [(ngModel)]="localPagingSize" (ngModelChange)="firePageSizeChange()" name="localPagingSize" class="local-paging-size" id="local-paging-size-{{ tableId }}">
1161
+ @for (option of localPagingOptions; track option) {
1162
+ <option [ngValue]="option">{{ option }}</option>
1163
+ }
1164
+ </select>
1165
+ <span>{{ currentPageInfo }}</span>
1166
+ </div>
1504
1167
  }
1505
- generateSortString() {
1506
- let sortString = '';
1507
- this.currentColumns.forEach((column) => {
1508
- switch (column.sortType) {
1509
- case SharkSortType.ASC: {
1510
- sortString += '' + column.property + ';';
1511
- break;
1512
- }
1513
- case SharkSortType.DESC: {
1514
- sortString += '-' + column.property + ';';
1515
- break;
1516
- }
1517
- case SharkSortType.NONE: {
1518
- break;
1519
- }
1520
- }
1521
- });
1522
- return sortString;
1168
+ @if (leftSideFooterTemplate) {
1169
+ <div class="left-side-template">
1170
+ <ng-container *ngTemplateOutlet="leftSideFooterTemplate"></ng-container>
1171
+ </div>
1523
1172
  }
1524
- generateSortArray() {
1525
- const currentSorts = [];
1526
- this.currentColumns.forEach((column) => {
1527
- switch (column.sortType) {
1528
- case SharkSortType.ASC:
1529
- case SharkSortType.DESC: {
1530
- currentSorts.push({ property: column.property, sortType: column.sortType });
1531
- break;
1532
- }
1533
- }
1534
- });
1535
- return currentSorts;
1173
+ <div class="flex-spacer"></div>
1174
+ @if (rightSideFooterTemplate) {
1175
+ <div class="right-side-template">
1176
+ <ng-container *ngTemplateOutlet="rightSideFooterTemplate"></ng-container>
1177
+ </div>
1536
1178
  }
1537
- sort(content, sorts) {
1538
- const columnCache = {};
1539
- this.columns.forEach(column => columnCache[column.property] = column);
1540
- content.sort((a, b) => {
1541
- let result = 0;
1542
- sorts.forEach((sort) => {
1543
- if (result === 0) {
1544
- const aVal = this.tableUtils.findValue(a, sort.property);
1545
- const bVal = this.tableUtils.findValue(b, sort.property);
1546
- const sortFunction = columnCache[sort.property].ascendingSortFunction;
1547
- if (!!sortFunction) {
1548
- result = sortFunction(aVal, bVal);
1549
- }
1550
- else if (!isNaN(Number(aVal)) && !isNaN(Number(bVal))) {
1551
- result = aVal - bVal;
1552
- }
1553
- else {
1554
- result = (aVal < bVal) ? -1 : (aVal > bVal) ? 1 : 0;
1555
- }
1556
- result *= (sort.sortType === SharkSortType.DESC) ? -1 : 1;
1557
- }
1558
- });
1559
- return result;
1560
- });
1179
+ <div>
1180
+ @if (currentColumns.length > 0) {
1181
+ <shark-table-pagination [page]="page" [tableId]="tableId" (paginationChange)="changePage($event)"></shark-table-pagination>
1182
+ }
1183
+ </div>
1184
+ </div>`,
1185
+ isInline: true,
1186
+ dependencies: [
1187
+ {
1188
+ kind: "ngmodule",
1189
+ type: FormsModule
1190
+ },
1191
+ {
1192
+ kind: "directive",
1193
+ type: i1.NgSelectOption,
1194
+ selector: "option",
1195
+ inputs: ["ngValue", "value"]
1196
+ },
1197
+ {
1198
+ kind: "directive",
1199
+ type: i1.ɵNgSelectMultipleOption,
1200
+ selector: "option",
1201
+ inputs: ["ngValue", "value"]
1202
+ },
1203
+ {
1204
+ kind: "directive",
1205
+ type: i1.SelectControlValueAccessor,
1206
+ selector: "select:not([multiple]):not([ngNoCva])[formControlName],select:not([multiple]):not([ngNoCva])[formControl],select:not([multiple]):not([ngNoCva])[ngModel]",
1207
+ inputs: ["compareWith"]
1208
+ },
1209
+ {
1210
+ kind: "directive",
1211
+ type: i1.NgControlStatus,
1212
+ selector: "[formControlName],[ngModel],[formControl]"
1213
+ },
1214
+ {
1215
+ kind: "directive",
1216
+ type: i1.NgModel,
1217
+ selector: "[ngModel]:not([formControlName]):not([formControl])",
1218
+ inputs: [
1219
+ "name",
1220
+ "disabled",
1221
+ "ngModel",
1222
+ "ngModelOptions"
1223
+ ],
1224
+ outputs: ["ngModelChange"],
1225
+ exportAs: ["ngModel"]
1226
+ },
1227
+ {
1228
+ kind: "directive",
1229
+ type: NgTemplateOutlet,
1230
+ selector: "[ngTemplateOutlet]",
1231
+ inputs: [
1232
+ "ngTemplateOutletContext",
1233
+ "ngTemplateOutlet",
1234
+ "ngTemplateOutletInjector"
1235
+ ]
1236
+ },
1237
+ {
1238
+ kind: "component",
1239
+ type: SharkTablePaginationComponent,
1240
+ selector: "shark-table-pagination",
1241
+ inputs: ["page", "tableId"],
1242
+ outputs: ["paginationChange"]
1243
+ }
1244
+ ]
1245
+ });
1246
+ };
1247
+ i0.ɵɵngDeclareClassMetadata({
1248
+ minVersion: "12.0.0",
1249
+ version: "22.2.6",
1250
+ ngImport: i0,
1251
+ type: SharkTableFooterComponent,
1252
+ decorators: [{
1253
+ type: Component,
1254
+ args: [{
1255
+ selector: "shark-table-footer",
1256
+ imports: [
1257
+ FormsModule,
1258
+ NgTemplateOutlet,
1259
+ SharkTablePaginationComponent
1260
+ ],
1261
+ template: `
1262
+ <div class="info-footer">
1263
+ @if (localPaging && showLocalPagingOptions && currentColumns.length > 0) {
1264
+ <div class="page-size-controls">
1265
+ <label for="local-paging-size-{{ tableId }}" class="local-paging-options">
1266
+ Rows per page:
1267
+ </label>
1268
+ <select [(ngModel)]="localPagingSize" (ngModelChange)="firePageSizeChange()" name="localPagingSize" class="local-paging-size" id="local-paging-size-{{ tableId }}">
1269
+ @for (option of localPagingOptions; track option) {
1270
+ <option [ngValue]="option">{{ option }}</option>
1271
+ }
1272
+ </select>
1273
+ <span>{{ currentPageInfo }}</span>
1274
+ </div>
1561
1275
  }
1562
- updatePage() {
1563
- if (this.data) {
1564
- if (this.data.constructor === Array) {
1565
- this.setupPageArray();
1566
- }
1567
- else if (this.data.constructor === Observable) {
1568
- this.setupPageSubscription();
1569
- }
1570
- else {
1571
- this.page = this.data;
1572
- if (!this.page.number) {
1573
- this.page.number = 0;
1574
- }
1575
- }
1576
- this.setupInitialSort();
1577
- }
1276
+ @if (leftSideFooterTemplate) {
1277
+ <div class="left-side-template">
1278
+ <ng-container *ngTemplateOutlet="leftSideFooterTemplate"></ng-container>
1279
+ </div>
1578
1280
  }
1579
- createLocalPage(data) {
1580
- const total = (data ? data : this.data).length;
1581
- return {
1582
- number: 0,
1583
- totalPages: 1,
1584
- totalElements: total,
1585
- first: true,
1586
- last: true,
1587
- numberOfElements: total,
1588
- content: data ? data : this.data
1589
- };
1281
+ <div class="flex-spacer"></div>
1282
+ @if (rightSideFooterTemplate) {
1283
+ <div class="right-side-template">
1284
+ <ng-container *ngTemplateOutlet="rightSideFooterTemplate"></ng-container>
1285
+ </div>
1590
1286
  }
1591
- setupPageArray() {
1592
- if (this.localPaging) {
1593
- const total = this.data.length;
1594
- const pageCount = Math.ceil(total / this.localPagingSize);
1595
- this.page = {
1596
- number: 0,
1597
- totalPages: pageCount,
1598
- totalElements: total,
1599
- first: true,
1600
- last: false,
1601
- numberOfElements: this.localPagingSize,
1602
- content: this.data.slice(0, this.localPagingSize)
1603
- };
1604
- if (this.localSubscription) {
1605
- this.localSubscription.unsubscribe();
1606
- }
1607
- this.localSubscription = this.pageChange.subscribe((event) => this.calculateLocalPage(event));
1287
+ <div>
1288
+ @if (currentColumns.length > 0) {
1289
+ <shark-table-pagination [page]="page" [tableId]="tableId" (paginationChange)="changePage($event)"></shark-table-pagination>
1290
+ }
1291
+ </div>
1292
+ </div>`
1293
+ }]
1294
+ }],
1295
+ propDecorators: {
1296
+ paginationComponent: [{
1297
+ type: ViewChild,
1298
+ args: [SharkTablePaginationComponent]
1299
+ }],
1300
+ leftSideFooterTemplate: [{ type: Input }],
1301
+ rightSideFooterTemplate: [{ type: Input }],
1302
+ notifierService: [{ type: Input }],
1303
+ localPaging: [{ type: Input }],
1304
+ localPagingSize: [{ type: Input }],
1305
+ localPagingOptions: [{ type: Input }],
1306
+ showLocalPagingOptions: [{ type: Input }],
1307
+ page: [{ type: Input }],
1308
+ currentColumns: [{ type: Input }],
1309
+ allColumns: [{ type: Input }],
1310
+ filter: [{ type: Input }],
1311
+ tableId: [{ type: Input }],
1312
+ filterChange: [{ type: Output }],
1313
+ paginationChange: [{ type: Output }]
1314
+ }
1315
+ });
1316
+ var SharkTableInfoHeaderComponent = class SharkTableInfoHeaderComponent {
1317
+ leftSideHeaderTemplate;
1318
+ rightSideHeaderTemplate;
1319
+ filterInput;
1320
+ columns = [];
1321
+ allColumns = [];
1322
+ columnPicker;
1323
+ serverSideData;
1324
+ filterable;
1325
+ columnFiltering;
1326
+ filter;
1327
+ showFilterPlaceholders;
1328
+ localPagingSize;
1329
+ notifierService;
1330
+ tableId;
1331
+ filterChange = new EventEmitter();
1332
+ columnChange = new EventEmitter();
1333
+ showDropDown = false;
1334
+ fireFilterChange() {
1335
+ this.filterChange.emit({
1336
+ columns: this.allColumns,
1337
+ filter: this.filter,
1338
+ localPagingSize: this.localPagingSize
1339
+ });
1340
+ }
1341
+ fireColumnChange() {
1342
+ this.columnChange.emit(this.allColumns);
1343
+ }
1344
+ static ɵfac = i0.ɵɵngDeclareFactory({
1345
+ minVersion: "12.0.0",
1346
+ version: "22.2.6",
1347
+ ngImport: i0,
1348
+ type: SharkTableInfoHeaderComponent,
1349
+ deps: [],
1350
+ target: i0.ɵɵFactoryTarget.Component
1351
+ });
1352
+ static ɵcmp = i0.ɵɵngDeclareComponent({
1353
+ minVersion: "17.0.0",
1354
+ version: "22.2.6",
1355
+ type: SharkTableInfoHeaderComponent,
1356
+ isStandalone: true,
1357
+ selector: "shark-table-info-header",
1358
+ inputs: {
1359
+ leftSideHeaderTemplate: "leftSideHeaderTemplate",
1360
+ rightSideHeaderTemplate: "rightSideHeaderTemplate",
1361
+ columns: "columns",
1362
+ allColumns: "allColumns",
1363
+ columnPicker: "columnPicker",
1364
+ serverSideData: "serverSideData",
1365
+ filterable: "filterable",
1366
+ columnFiltering: "columnFiltering",
1367
+ filter: "filter",
1368
+ showFilterPlaceholders: "showFilterPlaceholders",
1369
+ localPagingSize: "localPagingSize",
1370
+ notifierService: "notifierService",
1371
+ tableId: "tableId"
1372
+ },
1373
+ outputs: {
1374
+ filterChange: "filterChange",
1375
+ columnChange: "columnChange"
1376
+ },
1377
+ viewQueries: [{
1378
+ propertyName: "filterInput",
1379
+ first: true,
1380
+ predicate: ["filterInput"],
1381
+ descendants: true
1382
+ }],
1383
+ ngImport: i0,
1384
+ template: `
1385
+ <div class="info-header">
1386
+ <div class="controls header-buttons">
1387
+ @if (columnPicker) {
1388
+ <button class="toggle-dropdown" type="button" (click)="showDropDown = !showDropDown" [attr.aria-expanded]="showDropDown" [attr.aria-controls]="'column-picker-dropdown-' + tableId">
1389
+ <span>Choose Columns<i class="fa fa-fw fa-angle-down" aria-hidden="true"></i></span>
1390
+ </button>
1608
1391
  }
1609
- else if (this.localFilter) {
1610
- this.page = this.createLocalPage();
1611
- if (this.localSubscription) {
1612
- this.localSubscription.unsubscribe();
1613
- }
1614
- this.localSubscription = this.pageChange.subscribe((event) => this.calculateLocalPageNoPagination(event));
1392
+ @if (serverSideData) {
1393
+ <button class="server-refresh fa fa-sync" (click)="fireFilterChange()" type="button">
1394
+ <span class="screen-reader-button-label">Refresh Server Data</span>
1395
+ </button>
1615
1396
  }
1616
- else {
1617
- this.page = this.createLocalPage();
1397
+ @if (leftSideHeaderTemplate) {
1398
+ <div class="left-side-template">
1399
+ <ng-container *ngTemplateOutlet="leftSideHeaderTemplate"></ng-container>
1400
+ </div>
1618
1401
  }
1619
- }
1620
- calculateLocalPageNoPagination(event) {
1621
- if (((event.filter && event.filter.length > 0)) || this.tableUtils.hasFilter(event.columns)) {
1622
- const filteredContent = this.tableUtils.filter(this.data, this.currentColumns, this.columnFiltering, event.filter);
1623
- this.page = {
1624
- number: 0,
1625
- totalPages: 1,
1626
- totalElements: filteredContent.length,
1627
- first: true,
1628
- last: false,
1629
- numberOfElements: filteredContent.length,
1630
- content: filteredContent
1631
- };
1402
+ <div class="flex-spacer"></div>
1403
+ @if (rightSideHeaderTemplate) {
1404
+ <div class="right-side-template">
1405
+ <ng-container *ngTemplateOutlet="rightSideHeaderTemplate"></ng-container>
1406
+ </div>
1632
1407
  }
1633
- else {
1634
- this.page = this.createLocalPage();
1408
+ @if (filterable && !columnFiltering && columns.length > 0) {
1409
+ <span class="filter-box">
1410
+ <label [for]="'filter-' + tableId" class="screen-reader">Filter Results (all column search)</label>
1411
+ <input #filterInput type="text" name="filter" [id]="'filter-' + tableId" [(ngModel)]="filter" (ngModelChange)="fireFilterChange()" [attr.placeholder]="showFilterPlaceholders ? 'Filter Results' : null" />
1412
+ </span>
1635
1413
  }
1636
- }
1637
- calculateLocalPage(event) {
1638
- let content;
1639
- if (this.localFilter && ((event.filter && event.filter.length > 0)) || this.tableUtils.hasFilter(event.columns)) {
1640
- content = this.tableUtils.filter(this.data, this.currentColumns, this.columnFiltering, event.filter);
1414
+ </div>
1415
+ @if (columnPicker) {
1416
+ <div [id]="'column-picker-dropdown-' + tableId" class="dropdown" role="region" aria-label="Column picker" tabindex="-1" [hidden]="!showDropDown" [style.display]="showDropDown ? 'block' : 'none'">
1417
+ <fieldset>
1418
+ <legend class="screen-reader">Columns to display</legend>
1419
+ <div class="column-wrapper">
1420
+ @for (column of allColumns; track column) {
1421
+ <label>
1422
+ <input type="checkbox" [(ngModel)]="column.displayed" (ngModelChange)="fireColumnChange()" />
1423
+ {{ column.header }}
1424
+ </label>
1425
+ }
1426
+ </div>
1427
+ </fieldset>
1428
+ </div>
1429
+ }
1430
+ </div>
1431
+ `,
1432
+ isInline: true,
1433
+ dependencies: [
1434
+ {
1435
+ kind: "ngmodule",
1436
+ type: FormsModule
1437
+ },
1438
+ {
1439
+ kind: "directive",
1440
+ type: i1.DefaultValueAccessor,
1441
+ selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]"
1442
+ },
1443
+ {
1444
+ kind: "directive",
1445
+ type: i1.CheckboxControlValueAccessor,
1446
+ selector: "input[type=checkbox]:not([ngNoCva])[formControlName],input[type=checkbox]:not([ngNoCva])[formControl],input[type=checkbox]:not([ngNoCva])[ngModel]"
1447
+ },
1448
+ {
1449
+ kind: "directive",
1450
+ type: i1.NgControlStatus,
1451
+ selector: "[formControlName],[ngModel],[formControl]"
1452
+ },
1453
+ {
1454
+ kind: "directive",
1455
+ type: i1.NgModel,
1456
+ selector: "[ngModel]:not([formControlName]):not([formControl])",
1457
+ inputs: [
1458
+ "name",
1459
+ "disabled",
1460
+ "ngModel",
1461
+ "ngModelOptions"
1462
+ ],
1463
+ outputs: ["ngModelChange"],
1464
+ exportAs: ["ngModel"]
1465
+ },
1466
+ {
1467
+ kind: "directive",
1468
+ type: NgTemplateOutlet,
1469
+ selector: "[ngTemplateOutlet]",
1470
+ inputs: [
1471
+ "ngTemplateOutletContext",
1472
+ "ngTemplateOutlet",
1473
+ "ngTemplateOutletInjector"
1474
+ ]
1475
+ }
1476
+ ]
1477
+ });
1478
+ };
1479
+ i0.ɵɵngDeclareClassMetadata({
1480
+ minVersion: "12.0.0",
1481
+ version: "22.2.6",
1482
+ ngImport: i0,
1483
+ type: SharkTableInfoHeaderComponent,
1484
+ decorators: [{
1485
+ type: Component,
1486
+ args: [{
1487
+ selector: "shark-table-info-header",
1488
+ imports: [FormsModule, NgTemplateOutlet],
1489
+ template: `
1490
+ <div class="info-header">
1491
+ <div class="controls header-buttons">
1492
+ @if (columnPicker) {
1493
+ <button class="toggle-dropdown" type="button" (click)="showDropDown = !showDropDown" [attr.aria-expanded]="showDropDown" [attr.aria-controls]="'column-picker-dropdown-' + tableId">
1494
+ <span>Choose Columns<i class="fa fa-fw fa-angle-down" aria-hidden="true"></i></span>
1495
+ </button>
1641
1496
  }
1642
- else {
1643
- content = this.data;
1497
+ @if (serverSideData) {
1498
+ <button class="server-refresh fa fa-sync" (click)="fireFilterChange()" type="button">
1499
+ <span class="screen-reader-button-label">Refresh Server Data</span>
1500
+ </button>
1644
1501
  }
1645
- this.sort(content, this.generateSortArray());
1646
- const total = content.length;
1647
- // IntelliJ claims this * 1 call is useless, but we need to make sure it's a number
1648
- const pageSize = (this.localPagingSize > content.length ? content.length : this.localPagingSize) * 1;
1649
- const pageCount = total === 0 ? 0 : Math.ceil(total / pageSize);
1650
- const pageNo = event.pageNo > pageCount || content.length <= pageSize ? 0 : event.pageNo;
1651
- const sliceRange = pageSize * pageNo + pageSize;
1652
- const displayedContent = content.slice((pageSize * pageNo), sliceRange);
1653
- this.page = {
1654
- number: pageNo,
1655
- totalPages: pageCount,
1656
- totalElements: total,
1657
- first: pageNo === 0,
1658
- last: pageNo === pageCount,
1659
- numberOfElements: pageSize,
1660
- content: displayedContent
1661
- };
1662
- }
1663
- setupPageSubscription() {
1664
- // Fix potential memory leak, by unsubscribing to previous subscription if exists
1665
- if (this.dataSubscription) {
1666
- this.dataSubscription.unsubscribe();
1502
+ @if (leftSideHeaderTemplate) {
1503
+ <div class="left-side-template">
1504
+ <ng-container *ngTemplateOutlet="leftSideHeaderTemplate"></ng-container>
1505
+ </div>
1667
1506
  }
1668
- this.dataSubscription = this.data.subscribe((data) => {
1669
- if (data.constructor === Array) {
1670
- this.page = this.createLocalPage(data);
1671
- }
1672
- else {
1673
- this.page = data;
1674
- }
1675
- });
1676
- }
1677
- setupInitialSort() {
1678
- if (this.initialSort) {
1679
- const sorts = this.initialSort.split(';');
1680
- sorts.forEach((sort) => {
1681
- this.columns.forEach((column) => {
1682
- let type = SharkSortType.NONE;
1683
- let property = sort;
1684
- if (sort.startsWith('-')) {
1685
- type = SharkSortType.DESC;
1686
- property = property.substr(1);
1687
- }
1688
- else {
1689
- type = SharkSortType.ASC;
1690
- }
1691
- if (property === column.property) {
1692
- column.sortType = type;
1693
- }
1694
- });
1695
- });
1696
- this.changeSort('', undefined);
1507
+ <div class="flex-spacer"></div>
1508
+ @if (rightSideHeaderTemplate) {
1509
+ <div class="right-side-template">
1510
+ <ng-container *ngTemplateOutlet="rightSideHeaderTemplate"></ng-container>
1511
+ </div>
1697
1512
  }
1698
- if (this.page.sorts && this.page.sorts.length > 0) {
1699
- this.columns.forEach((column) => {
1700
- this.page.sorts.forEach((sort) => {
1701
- if (column.property === sort.property) {
1702
- column.sortType = SharkSortType.NONE;
1703
- if (sort.ascending) {
1704
- column.sortType = SharkSortType.ASC;
1705
- }
1706
- else if (sort.descending) {
1707
- column.sortType = SharkSortType.DESC;
1708
- }
1709
- }
1710
- });
1711
- });
1712
- if (!this.serverSideData) {
1713
- this.changeSort('', undefined);
1714
- }
1513
+ @if (filterable && !columnFiltering && columns.length > 0) {
1514
+ <span class="filter-box">
1515
+ <label [for]="'filter-' + tableId" class="screen-reader">Filter Results (all column search)</label>
1516
+ <input #filterInput type="text" name="filter" [id]="'filter-' + tableId" [(ngModel)]="filter" (ngModelChange)="fireFilterChange()" [attr.placeholder]="showFilterPlaceholders ? 'Filter Results' : null" />
1517
+ </span>
1715
1518
  }
1716
- }
1717
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableComponent, deps: [{ token: i1$1.Router }, { token: SharkTableUtils }], target: i0.ɵɵFactoryTarget.Component });
1718
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: SharkTableComponent, selector: "shark-table", inputs: { tableId: "tableId", data: "data", columns: "columns", caption: "caption", hideCaption: "hideCaption", columnPicker: "columnPicker", columnOrdering: "columnOrdering", linkTarget: "linkTarget", linkKey: "linkKey", sortable: "sortable", filterable: "filterable", columnFiltering: "columnFiltering", localFilter: "localFilter", showFilterPlaceholders: "showFilterPlaceholders", localPaging: "localPaging", localPagingSize: "localPagingSize", localPagingOptions: "localPagingOptions", showLocalPagingOptions: "showLocalPagingOptions", serverSideData: "serverSideData", initialSort: "initialSort", cellStylingFunction: "cellStylingFunction", childRows: "childRows", childComponent: "childComponent", disableColumnChangeEvent: "disableColumnChangeEvent", filter: "filter", footer: "footer", tableEmptyMessage: "tableEmptyMessage", rowStylingFunction: "rowStylingFunction" }, outputs: { pageChange: "pageChange", columnChange: "columnChange" }, queries: [{ propertyName: "headerLeftTemplate", first: true, predicate: ["headerLeft"], descendants: true }, { propertyName: "headerRightTemplate", first: true, predicate: ["headerRight"], descendants: true }, { propertyName: "footerLeftTemplate", first: true, predicate: ["footerLeft"], descendants: true }, { propertyName: "footerRightTemplate", first: true, predicate: ["footerRight"], descendants: true }], viewQueries: [{ propertyName: "headerInfoComponent", first: true, predicate: SharkTableInfoHeaderComponent, descendants: true }, { propertyName: "headerComponent", first: true, predicate: SharkTableHeaderComponent, descendants: true }, { propertyName: "footerComponent", first: true, predicate: SharkTableFooterComponent, descendants: true }], usesOnChanges: true, ngImport: i0, template: `
1519
+ </div>
1520
+ @if (columnPicker) {
1521
+ <div [id]="'column-picker-dropdown-' + tableId" class="dropdown" role="region" aria-label="Column picker" tabindex="-1" [hidden]="!showDropDown" [style.display]="showDropDown ? 'block' : 'none'">
1522
+ <fieldset>
1523
+ <legend class="screen-reader">Columns to display</legend>
1524
+ <div class="column-wrapper">
1525
+ @for (column of allColumns; track column) {
1526
+ <label>
1527
+ <input type="checkbox" [(ngModel)]="column.displayed" (ngModelChange)="fireColumnChange()" />
1528
+ {{ column.header }}
1529
+ </label>
1530
+ }
1531
+ </div>
1532
+ </fieldset>
1533
+ </div>
1534
+ }
1535
+ </div>
1536
+ `
1537
+ }]
1538
+ }],
1539
+ propDecorators: {
1540
+ leftSideHeaderTemplate: [{ type: Input }],
1541
+ rightSideHeaderTemplate: [{ type: Input }],
1542
+ filterInput: [{
1543
+ type: ViewChild,
1544
+ args: ["filterInput"]
1545
+ }],
1546
+ columns: [{ type: Input }],
1547
+ allColumns: [{ type: Input }],
1548
+ columnPicker: [{ type: Input }],
1549
+ serverSideData: [{ type: Input }],
1550
+ filterable: [{ type: Input }],
1551
+ columnFiltering: [{ type: Input }],
1552
+ filter: [{ type: Input }],
1553
+ showFilterPlaceholders: [{ type: Input }],
1554
+ localPagingSize: [{ type: Input }],
1555
+ notifierService: [{ type: Input }],
1556
+ tableId: [{ type: Input }],
1557
+ filterChange: [{ type: Output }],
1558
+ columnChange: [{ type: Output }]
1559
+ }
1560
+ });
1561
+ var NotifierService = class {
1562
+ messageObservable;
1563
+ messageSubject;
1564
+ constructor() {
1565
+ this.messageSubject = new Subject();
1566
+ this.messageObservable = this.messageSubject.asObservable();
1567
+ }
1568
+ postMessage(message) {
1569
+ this.messageSubject.next(message);
1570
+ }
1571
+ };
1572
+ var AriaNotifierComponent = class AriaNotifierComponent {
1573
+ cdr = inject(ChangeDetectorRef);
1574
+ status = "";
1575
+ tableId;
1576
+ notifierService;
1577
+ notifierSubscription;
1578
+ clearTimer;
1579
+ ngOnChanges(changes) {
1580
+ if (changes["notifierService"]) {
1581
+ this.notifierSubscription?.unsubscribe();
1582
+ this.notifierSubscription = this.notifierService?.messageObservable.subscribe((message) => {
1583
+ this.status = message;
1584
+ this.cdr.markForCheck();
1585
+ clearTimeout(this.clearTimer);
1586
+ this.clearTimer = setTimeout(() => {
1587
+ this.status = "";
1588
+ this.cdr.markForCheck();
1589
+ }, 1e3);
1590
+ });
1591
+ }
1592
+ }
1593
+ ngOnDestroy() {
1594
+ this.notifierSubscription?.unsubscribe();
1595
+ clearTimeout(this.clearTimer);
1596
+ }
1597
+ static ɵfac = i0.ɵɵngDeclareFactory({
1598
+ minVersion: "12.0.0",
1599
+ version: "22.2.6",
1600
+ ngImport: i0,
1601
+ type: AriaNotifierComponent,
1602
+ deps: [],
1603
+ target: i0.ɵɵFactoryTarget.Component
1604
+ });
1605
+ static ɵcmp = i0.ɵɵngDeclareComponent({
1606
+ minVersion: "14.0.0",
1607
+ version: "22.2.6",
1608
+ type: AriaNotifierComponent,
1609
+ isStandalone: true,
1610
+ selector: "shark-table-aria-notifier",
1611
+ inputs: {
1612
+ tableId: "tableId",
1613
+ notifierService: "notifierService"
1614
+ },
1615
+ usesOnChanges: true,
1616
+ ngImport: i0,
1617
+ template: `<div id="shark-table-aria-notifier-{{ tableId }}" class="notification-area screen-reader" aria-atomic="true" aria-live="polite">{{ status }}</div>`,
1618
+ isInline: true
1619
+ });
1620
+ };
1621
+ i0.ɵɵngDeclareClassMetadata({
1622
+ minVersion: "12.0.0",
1623
+ version: "22.2.6",
1624
+ ngImport: i0,
1625
+ type: AriaNotifierComponent,
1626
+ decorators: [{
1627
+ type: Component,
1628
+ args: [{
1629
+ selector: "shark-table-aria-notifier",
1630
+ template: `<div id="shark-table-aria-notifier-{{ tableId }}" class="notification-area screen-reader" aria-atomic="true" aria-live="polite">{{ status }}</div>`
1631
+ }]
1632
+ }],
1633
+ propDecorators: {
1634
+ tableId: [{ type: Input }],
1635
+ notifierService: [{ type: Input }]
1636
+ }
1637
+ });
1638
+ let nextTableId = 0;
1639
+ var SharkTableComponent = class SharkTableComponent {
1640
+ tableUtils = inject(SharkTableUtils);
1641
+ cdr = inject(ChangeDetectorRef);
1642
+ headerInfoComponent;
1643
+ headerComponent;
1644
+ footerComponent;
1645
+ headerLeftTemplate;
1646
+ headerRightTemplate;
1647
+ footerLeftTemplate;
1648
+ footerRightTemplate;
1649
+ notifierService = new NotifierService();
1650
+ tableId = `st${++nextTableId}`;
1651
+ data;
1652
+ columns = [];
1653
+ currentColumns = [];
1654
+ caption = "A Data Table";
1655
+ hideCaption = false;
1656
+ columnPicker = false;
1657
+ columnOrdering = false;
1658
+ linkTarget;
1659
+ linkKey;
1660
+ sortable = true;
1661
+ filterable = true;
1662
+ columnFiltering = false;
1663
+ localFilter = true;
1664
+ showFilterPlaceholders = true;
1665
+ localPaging = true;
1666
+ localPagingSize = 10;
1667
+ localPagingOptions = [
1668
+ 10,
1669
+ 20,
1670
+ 100
1671
+ ];
1672
+ showLocalPagingOptions = true;
1673
+ serverSideData = false;
1674
+ initialSort;
1675
+ cellStylingFunction;
1676
+ childRows = false;
1677
+ childComponent;
1678
+ pageChange = new EventEmitter();
1679
+ columnChange = new EventEmitter();
1680
+ disableColumnChangeEvent = false;
1681
+ filter;
1682
+ footer = true;
1683
+ tableEmptyMessage = "This table contains no rows";
1684
+ rowStylingFunction = () => ({});
1685
+ page;
1686
+ localRows;
1687
+ sourcePage;
1688
+ initialSortApplied = false;
1689
+ dataSubscription;
1690
+ ngOnInit() {
1691
+ this.updatePage();
1692
+ }
1693
+ ngOnChanges(changes) {
1694
+ const columnChange = changes["columns"];
1695
+ if (columnChange) {
1696
+ const columns = columnChange.currentValue ?? [];
1697
+ this.updateCurrentColumns(columns, !columnChange.isFirstChange());
1698
+ }
1699
+ const dataChange = changes["data"];
1700
+ if (dataChange && !dataChange.isFirstChange()) this.updatePage();
1701
+ else if (this.page && [
1702
+ "filter",
1703
+ "localPaging",
1704
+ "localPagingSize",
1705
+ "localFilter",
1706
+ "columnFiltering"
1707
+ ].some((key) => changes[key] && !changes[key].isFirstChange())) this.recalculate();
1708
+ }
1709
+ ngOnDestroy() {
1710
+ this.dataSubscription?.unsubscribe();
1711
+ }
1712
+ updateCurrentColumns(newColumns, emitPageEvent = true) {
1713
+ newColumns.forEach((column) => {
1714
+ if (column.displayed === void 0) column.displayed = true;
1715
+ });
1716
+ this.columns = newColumns;
1717
+ this.currentColumns = newColumns.filter((value) => value.displayed);
1718
+ if (emitPageEvent && this.page) {
1719
+ this.emitCurrent();
1720
+ this.recalculate();
1721
+ }
1722
+ this.publishColumnChangeEvent();
1723
+ }
1724
+ emitCurrent() {
1725
+ this.emitPageChange(this.page?.number ?? 0);
1726
+ }
1727
+ headerChange(event) {
1728
+ this.columns = event.columns;
1729
+ this.currentColumns = this.columns.filter((value) => value.displayed);
1730
+ this.filter = event.filter;
1731
+ this.localPagingSize = Number(event.localPagingSize);
1732
+ this.emitCurrent();
1733
+ this.recalculate();
1734
+ }
1735
+ changePage(pageNo) {
1736
+ this.emitPageChange(pageNo);
1737
+ this.recalculate(pageNo);
1738
+ }
1739
+ changeSort(columnProperty, sortType) {
1740
+ if (this.sortable) {
1741
+ this.currentColumns.forEach((column) => {
1742
+ if (column.property === columnProperty) {
1743
+ switch (sortType) {
1744
+ case SharkSortType.ASC:
1745
+ column.sortType = SharkSortType.DESC;
1746
+ break;
1747
+ case SharkSortType.DESC:
1748
+ column.sortType = SharkSortType.NONE;
1749
+ break;
1750
+ case SharkSortType.NONE:
1751
+ default: column.sortType = SharkSortType.ASC;
1752
+ }
1753
+ this.notifierService.postMessage(column.sortType === SharkSortType.DESC ? "sorted descending" : column.sortType === SharkSortType.ASC ? "sorted ascending" : "unsorted");
1754
+ }
1755
+ });
1756
+ this.emitCurrent();
1757
+ this.recalculate();
1758
+ this.publishColumnChangeEvent();
1759
+ }
1760
+ }
1761
+ exportCurrentData(rendered = true) {
1762
+ if (this.currentColumns.length === 0) return {
1763
+ data: [],
1764
+ columns: []
1765
+ };
1766
+ return {
1767
+ data: (this.localRows ? this.filterAndSort(this.localRows) : this.page?.content ?? []).map((row) => this.tableUtils.exportRow(row, this.currentColumns, rendered)),
1768
+ columns: this.currentColumns
1769
+ };
1770
+ }
1771
+ emitPageChange(pageNo) {
1772
+ this.pageChange.emit({
1773
+ pageNo,
1774
+ columns: this.currentColumns,
1775
+ sortString: this.generateSortString(),
1776
+ sorts: this.generateSortArray(),
1777
+ filter: this.filter
1778
+ });
1779
+ }
1780
+ publishColumnChangeEvent() {
1781
+ if (!this.disableColumnChangeEvent) this.columnChange.emit({
1782
+ columns: this.columns,
1783
+ currentSortString: this.generateSortString()
1784
+ });
1785
+ }
1786
+ generateSortString() {
1787
+ return this.generateSortArray().map((sort) => (sort.sortType === SharkSortType.DESC ? "-" : "") + sort.property + ";").join("");
1788
+ }
1789
+ generateSortArray() {
1790
+ return this.currentColumns.filter((column) => column.sortType === SharkSortType.ASC || column.sortType === SharkSortType.DESC).map((column) => ({
1791
+ property: column.property,
1792
+ sortType: column.sortType
1793
+ }));
1794
+ }
1795
+ isFiltering() {
1796
+ return !!this.filter && this.filter.length > 0 || this.columnFiltering && this.tableUtils.hasFilter(this.currentColumns);
1797
+ }
1798
+ filterAndSort(rows, sort = true) {
1799
+ const result = this.localFilter && this.isFiltering() ? this.tableUtils.filter(rows, this.currentColumns, this.columnFiltering, this.filter) : rows.slice();
1800
+ if (sort) this.sort(result, this.generateSortArray());
1801
+ return result;
1802
+ }
1803
+ sort(content, sorts) {
1804
+ if (sorts.length === 0) return;
1805
+ const columnCache = /* @__PURE__ */ new Map();
1806
+ this.columns.forEach((column) => columnCache.set(column.property, column));
1807
+ content.sort((a, b) => {
1808
+ for (const sort of sorts) {
1809
+ const aVal = this.tableUtils.findValue(a, sort.property);
1810
+ const bVal = this.tableUtils.findValue(b, sort.property);
1811
+ const sortFunction = columnCache.get(sort.property)?.ascendingSortFunction;
1812
+ const result = sortFunction ? sortFunction(aVal, bVal) : this.tableUtils.compare(aVal, bVal);
1813
+ if (result !== 0) return sort.sortType === SharkSortType.DESC ? -result : result;
1814
+ }
1815
+ return 0;
1816
+ });
1817
+ }
1818
+ updatePage() {
1819
+ this.dataSubscription?.unsubscribe();
1820
+ this.dataSubscription = void 0;
1821
+ const data = this.data;
1822
+ if (data == null) return;
1823
+ if (isObservable(data)) this.dataSubscription = data.subscribe((value) => {
1824
+ this.applyData(value);
1825
+ this.cdr.markForCheck();
1826
+ });
1827
+ else this.applyData(data);
1828
+ }
1829
+ applyData(value) {
1830
+ if (value == null) return;
1831
+ if (Array.isArray(value)) {
1832
+ this.localRows = value;
1833
+ this.sourcePage = void 0;
1834
+ } else {
1835
+ this.localRows = void 0;
1836
+ this.sourcePage = value;
1837
+ }
1838
+ const sortsChanged = this.applyInitialSorts();
1839
+ this.recalculate(this.sourcePage ? this.sourcePage.number ?? 0 : 0);
1840
+ if (sortsChanged) {
1841
+ this.emitCurrent();
1842
+ this.publishColumnChangeEvent();
1843
+ }
1844
+ }
1845
+ applyInitialSorts() {
1846
+ let changed = false;
1847
+ if (!this.initialSortApplied) {
1848
+ this.initialSortApplied = true;
1849
+ if (this.initialSort) {
1850
+ this.initialSort.split(";").filter((sort) => sort.length > 0).forEach((sort) => {
1851
+ const descending = sort.startsWith("-");
1852
+ const property = descending ? sort.substring(1) : sort;
1853
+ const column = this.columns.find((col) => col.property === property);
1854
+ if (column) column.sortType = descending ? SharkSortType.DESC : SharkSortType.ASC;
1855
+ });
1856
+ changed = true;
1857
+ }
1858
+ }
1859
+ const pageSorts = this.sourcePage?.sorts;
1860
+ if (pageSorts && pageSorts.length > 0) {
1861
+ this.columns.forEach((column) => {
1862
+ pageSorts.forEach((sort) => {
1863
+ if (column.property === sort.property) column.sortType = sort.ascending ? SharkSortType.ASC : sort.descending ? SharkSortType.DESC : SharkSortType.NONE;
1864
+ });
1865
+ });
1866
+ changed = changed || !this.serverSideData;
1867
+ }
1868
+ return changed;
1869
+ }
1870
+ recalculate(pageNo = this.page?.number ?? 0) {
1871
+ if (this.localRows) this.page = this.localPaging ? this.buildLocalPage(this.filterAndSort(this.localRows), pageNo) : this.buildSinglePage(this.filterAndSort(this.localRows));
1872
+ else if (this.sourcePage) {
1873
+ const content = this.filterAndSort(this.sourcePage.content ?? [], !this.serverSideData);
1874
+ this.page = {
1875
+ ...this.sourcePage,
1876
+ number: this.sourcePage.number ?? 0,
1877
+ content
1878
+ };
1879
+ }
1880
+ }
1881
+ buildSinglePage(content) {
1882
+ return {
1883
+ number: 0,
1884
+ size: content.length,
1885
+ totalPages: 1,
1886
+ totalElements: content.length,
1887
+ first: true,
1888
+ last: true,
1889
+ numberOfElements: content.length,
1890
+ content
1891
+ };
1892
+ }
1893
+ buildLocalPage(rows, requestedPage) {
1894
+ const pageSize = Math.max(1, Math.floor(Number(this.localPagingSize)) || 10);
1895
+ const total = rows.length;
1896
+ const totalPages = Math.ceil(total / pageSize);
1897
+ const pageNo = Math.min(Math.max(0, Math.floor(Number(requestedPage)) || 0), Math.max(totalPages - 1, 0));
1898
+ const content = rows.slice(pageNo * pageSize, pageNo * pageSize + pageSize);
1899
+ return {
1900
+ number: pageNo,
1901
+ size: pageSize,
1902
+ totalPages,
1903
+ totalElements: total,
1904
+ first: pageNo === 0,
1905
+ last: pageNo >= totalPages - 1,
1906
+ numberOfElements: content.length,
1907
+ content
1908
+ };
1909
+ }
1910
+ static ɵfac = i0.ɵɵngDeclareFactory({
1911
+ minVersion: "12.0.0",
1912
+ version: "22.2.6",
1913
+ ngImport: i0,
1914
+ type: SharkTableComponent,
1915
+ deps: [],
1916
+ target: i0.ɵɵFactoryTarget.Component
1917
+ });
1918
+ static ɵcmp = i0.ɵɵngDeclareComponent({
1919
+ minVersion: "17.0.0",
1920
+ version: "22.2.6",
1921
+ type: SharkTableComponent,
1922
+ isStandalone: true,
1923
+ selector: "shark-table",
1924
+ inputs: {
1925
+ tableId: "tableId",
1926
+ data: "data",
1927
+ columns: "columns",
1928
+ caption: "caption",
1929
+ hideCaption: "hideCaption",
1930
+ columnPicker: "columnPicker",
1931
+ columnOrdering: "columnOrdering",
1932
+ linkTarget: "linkTarget",
1933
+ linkKey: "linkKey",
1934
+ sortable: "sortable",
1935
+ filterable: "filterable",
1936
+ columnFiltering: "columnFiltering",
1937
+ localFilter: "localFilter",
1938
+ showFilterPlaceholders: "showFilterPlaceholders",
1939
+ localPaging: "localPaging",
1940
+ localPagingSize: "localPagingSize",
1941
+ localPagingOptions: "localPagingOptions",
1942
+ showLocalPagingOptions: "showLocalPagingOptions",
1943
+ serverSideData: "serverSideData",
1944
+ initialSort: "initialSort",
1945
+ cellStylingFunction: "cellStylingFunction",
1946
+ childRows: "childRows",
1947
+ childComponent: "childComponent",
1948
+ disableColumnChangeEvent: "disableColumnChangeEvent",
1949
+ filter: "filter",
1950
+ footer: "footer",
1951
+ tableEmptyMessage: "tableEmptyMessage",
1952
+ rowStylingFunction: "rowStylingFunction"
1953
+ },
1954
+ outputs: {
1955
+ pageChange: "pageChange",
1956
+ columnChange: "columnChange"
1957
+ },
1958
+ queries: [
1959
+ {
1960
+ propertyName: "headerLeftTemplate",
1961
+ first: true,
1962
+ predicate: ["headerLeft"],
1963
+ descendants: true
1964
+ },
1965
+ {
1966
+ propertyName: "headerRightTemplate",
1967
+ first: true,
1968
+ predicate: ["headerRight"],
1969
+ descendants: true
1970
+ },
1971
+ {
1972
+ propertyName: "footerLeftTemplate",
1973
+ first: true,
1974
+ predicate: ["footerLeft"],
1975
+ descendants: true
1976
+ },
1977
+ {
1978
+ propertyName: "footerRightTemplate",
1979
+ first: true,
1980
+ predicate: ["footerRight"],
1981
+ descendants: true
1982
+ }
1983
+ ],
1984
+ viewQueries: [
1985
+ {
1986
+ propertyName: "headerInfoComponent",
1987
+ first: true,
1988
+ predicate: SharkTableInfoHeaderComponent,
1989
+ descendants: true
1990
+ },
1991
+ {
1992
+ propertyName: "headerComponent",
1993
+ first: true,
1994
+ predicate: SharkTableHeaderComponent,
1995
+ descendants: true
1996
+ },
1997
+ {
1998
+ propertyName: "footerComponent",
1999
+ first: true,
2000
+ predicate: SharkTableFooterComponent,
2001
+ descendants: true
2002
+ }
2003
+ ],
2004
+ usesOnChanges: true,
2005
+ ngImport: i0,
2006
+ template: `
1719
2007
  <div class="shark-table" id="shark-table-{{ tableId }}">
1720
- <ng-container *ngIf="page">
2008
+ @if (page) {
1721
2009
  <shark-table-aria-notifier [notifierService]="notifierService" [tableId]="tableId"></shark-table-aria-notifier>
1722
- <shark-table-info-header *ngIf="(serverSideData || (filterable && !columnFiltering) || columnPicker || headerLeftTemplate || headerRightTemplate)"
2010
+ @if (serverSideData || (filterable && !columnFiltering) || columnPicker || headerLeftTemplate || headerRightTemplate) {
2011
+ <shark-table-info-header
1723
2012
  [serverSideData]="serverSideData"
1724
2013
  [filterable]="filterable"
1725
2014
  [columnFiltering]="columnFiltering"
@@ -1735,7 +2024,8 @@ class SharkTableComponent {
1735
2024
  [rightSideHeaderTemplate]="headerRightTemplate"
1736
2025
  (filterChange)="headerChange($event)"
1737
2026
  (columnChange)="updateCurrentColumns($event)"
1738
- ></shark-table-info-header>
2027
+ ></shark-table-info-header>
2028
+ }
1739
2029
  <div class="table-wrapper">
1740
2030
  <table>
1741
2031
  <caption [ngClass]="{'screen-reader': hideCaption}">{{ caption }}</caption>
@@ -1760,10 +2050,6 @@ class SharkTableComponent {
1760
2050
  <tbody shark-table-body
1761
2051
  [currentColumns]="currentColumns"
1762
2052
  [columns]="columns"
1763
- [localFilter]="localFilter"
1764
- [localPaging]="localPaging"
1765
- [columnFiltering]="columnFiltering"
1766
- [filter]="filter"
1767
2053
  [childRows]="childRows"
1768
2054
  [childComponent]="childComponent"
1769
2055
  [linkTarget]="linkTarget" [linkKey]="linkKey"
@@ -1774,7 +2060,8 @@ class SharkTableComponent {
1774
2060
  ></tbody>
1775
2061
  </table>
1776
2062
  </div>
1777
- <shark-table-footer *ngIf="footer && currentColumns.length > 0"
2063
+ @if (footer && currentColumns.length > 0) {
2064
+ <shark-table-footer
1778
2065
  [page]="page"
1779
2066
  [currentColumns]="currentColumns"
1780
2067
  [allColumns]="columns"
@@ -1789,20 +2076,134 @@ class SharkTableComponent {
1789
2076
  [rightSideFooterTemplate]="footerRightTemplate"
1790
2077
  (filterChange)="headerChange($event)"
1791
2078
  (paginationChange)="changePage($event)"
1792
- ></shark-table-footer>
1793
- </ng-container>
2079
+ ></shark-table-footer>
2080
+ }
2081
+ }
1794
2082
  </div>
1795
- `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: AriaNotifierComponent, selector: "shark-table-aria-notifier", inputs: ["tableId", "notifierService"] }, { kind: "component", type: SharkTableHeaderComponent, selector: "[shark-table-header]", inputs: ["tableId", "sortable", "allColumns", "currentColumns", "columnOrdering", "childRows", "page", "filterable", "columnFiltering", "filter", "showFilterPlaceholders", "notifierService", "localPagingSize"], outputs: ["sortChange", "filterChange", "columnChange"] }, { kind: "component", type: SharkTableInfoHeaderComponent, selector: "shark-table-info-header", inputs: ["leftSideHeaderTemplate", "rightSideHeaderTemplate", "columns", "allColumns", "columnPicker", "serverSideData", "filterable", "columnFiltering", "filter", "showFilterPlaceholders", "localPagingSize", "notifierService", "tableId"], outputs: ["filterChange", "columnChange"] }, { kind: "component", type: SharkTableFooterComponent, selector: "shark-table-footer", inputs: ["leftSideFooterTemplate", "rightSideFooterTemplate", "notifierService", "localPaging", "localPagingSize", "localPagingOptions", "showLocalPagingOptions", "page", "currentColumns", "allColumns", "filter", "tableId"], outputs: ["filterChange", "paginationChange"] }, { kind: "component", type: SharkTableBodyComponent, selector: "[shark-table-body]", inputs: ["currentColumns", "columns", "localFilter", "localPaging", "columnFiltering", "filter", "rowStylingFunction", "cellStylingFunction", "childRows", "childComponent", "linkTarget", "linkKey", "tableEmptyMessage", "page"] }] });
1796
- }
1797
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableComponent, decorators: [{
1798
- type: Component,
1799
- args: [{
1800
- selector: 'shark-table',
1801
- template: `
2083
+ `,
2084
+ isInline: true,
2085
+ dependencies: [
2086
+ {
2087
+ kind: "directive",
2088
+ type: NgClass,
2089
+ selector: "[ngClass]",
2090
+ inputs: ["class", "ngClass"]
2091
+ },
2092
+ {
2093
+ kind: "component",
2094
+ type: AriaNotifierComponent,
2095
+ selector: "shark-table-aria-notifier",
2096
+ inputs: ["tableId", "notifierService"]
2097
+ },
2098
+ {
2099
+ kind: "component",
2100
+ type: SharkTableInfoHeaderComponent,
2101
+ selector: "shark-table-info-header",
2102
+ inputs: [
2103
+ "leftSideHeaderTemplate",
2104
+ "rightSideHeaderTemplate",
2105
+ "columns",
2106
+ "allColumns",
2107
+ "columnPicker",
2108
+ "serverSideData",
2109
+ "filterable",
2110
+ "columnFiltering",
2111
+ "filter",
2112
+ "showFilterPlaceholders",
2113
+ "localPagingSize",
2114
+ "notifierService",
2115
+ "tableId"
2116
+ ],
2117
+ outputs: ["filterChange", "columnChange"]
2118
+ },
2119
+ {
2120
+ kind: "component",
2121
+ type: SharkTableHeaderComponent,
2122
+ selector: "[shark-table-header]",
2123
+ inputs: [
2124
+ "tableId",
2125
+ "sortable",
2126
+ "allColumns",
2127
+ "currentColumns",
2128
+ "columnOrdering",
2129
+ "childRows",
2130
+ "page",
2131
+ "filterable",
2132
+ "columnFiltering",
2133
+ "filter",
2134
+ "showFilterPlaceholders",
2135
+ "notifierService",
2136
+ "localPagingSize"
2137
+ ],
2138
+ outputs: [
2139
+ "sortChange",
2140
+ "filterChange",
2141
+ "columnChange"
2142
+ ]
2143
+ },
2144
+ {
2145
+ kind: "component",
2146
+ type: SharkTableBodyComponent,
2147
+ selector: "[shark-table-body]",
2148
+ inputs: [
2149
+ "currentColumns",
2150
+ "columns",
2151
+ "rowStylingFunction",
2152
+ "cellStylingFunction",
2153
+ "childRows",
2154
+ "childComponent",
2155
+ "linkTarget",
2156
+ "linkKey",
2157
+ "tableEmptyMessage",
2158
+ "page"
2159
+ ]
2160
+ },
2161
+ {
2162
+ kind: "component",
2163
+ type: SharkTableFooterComponent,
2164
+ selector: "shark-table-footer",
2165
+ inputs: [
2166
+ "leftSideFooterTemplate",
2167
+ "rightSideFooterTemplate",
2168
+ "notifierService",
2169
+ "localPaging",
2170
+ "localPagingSize",
2171
+ "localPagingOptions",
2172
+ "showLocalPagingOptions",
2173
+ "page",
2174
+ "currentColumns",
2175
+ "allColumns",
2176
+ "filter",
2177
+ "tableId"
2178
+ ],
2179
+ outputs: ["filterChange", "paginationChange"]
2180
+ }
2181
+ ]
2182
+ });
2183
+ };
2184
+ i0.ɵɵngDeclareClassMetadata({
2185
+ minVersion: "12.0.0",
2186
+ version: "22.2.6",
2187
+ ngImport: i0,
2188
+ type: SharkTableComponent,
2189
+ decorators: [{
2190
+ type: Component,
2191
+ args: [{
2192
+ selector: "shark-table",
2193
+ imports: [
2194
+ NgClass,
2195
+ AriaNotifierComponent,
2196
+ SharkTableInfoHeaderComponent,
2197
+ SharkTableHeaderComponent,
2198
+ SharkTableBodyComponent,
2199
+ SharkTableFooterComponent
2200
+ ],
2201
+ template: `
1802
2202
  <div class="shark-table" id="shark-table-{{ tableId }}">
1803
- <ng-container *ngIf="page">
2203
+ @if (page) {
1804
2204
  <shark-table-aria-notifier [notifierService]="notifierService" [tableId]="tableId"></shark-table-aria-notifier>
1805
- <shark-table-info-header *ngIf="(serverSideData || (filterable && !columnFiltering) || columnPicker || headerLeftTemplate || headerRightTemplate)"
2205
+ @if (serverSideData || (filterable && !columnFiltering) || columnPicker || headerLeftTemplate || headerRightTemplate) {
2206
+ <shark-table-info-header
1806
2207
  [serverSideData]="serverSideData"
1807
2208
  [filterable]="filterable"
1808
2209
  [columnFiltering]="columnFiltering"
@@ -1818,7 +2219,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1818
2219
  [rightSideHeaderTemplate]="headerRightTemplate"
1819
2220
  (filterChange)="headerChange($event)"
1820
2221
  (columnChange)="updateCurrentColumns($event)"
1821
- ></shark-table-info-header>
2222
+ ></shark-table-info-header>
2223
+ }
1822
2224
  <div class="table-wrapper">
1823
2225
  <table>
1824
2226
  <caption [ngClass]="{'screen-reader': hideCaption}">{{ caption }}</caption>
@@ -1843,10 +2245,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1843
2245
  <tbody shark-table-body
1844
2246
  [currentColumns]="currentColumns"
1845
2247
  [columns]="columns"
1846
- [localFilter]="localFilter"
1847
- [localPaging]="localPaging"
1848
- [columnFiltering]="columnFiltering"
1849
- [filter]="filter"
1850
2248
  [childRows]="childRows"
1851
2249
  [childComponent]="childComponent"
1852
2250
  [linkTarget]="linkTarget" [linkKey]="linkKey"
@@ -1857,7 +2255,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1857
2255
  ></tbody>
1858
2256
  </table>
1859
2257
  </div>
1860
- <shark-table-footer *ngIf="footer && currentColumns.length > 0"
2258
+ @if (footer && currentColumns.length > 0) {
2259
+ <shark-table-footer
1861
2260
  [page]="page"
1862
2261
  [currentColumns]="currentColumns"
1863
2262
  [allColumns]="columns"
@@ -1872,157 +2271,116 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
1872
2271
  [rightSideFooterTemplate]="footerRightTemplate"
1873
2272
  (filterChange)="headerChange($event)"
1874
2273
  (paginationChange)="changePage($event)"
1875
- ></shark-table-footer>
1876
- </ng-container>
2274
+ ></shark-table-footer>
2275
+ }
2276
+ }
1877
2277
  </div>
1878
2278
  `
1879
- }]
1880
- }], ctorParameters: function () { return [{ type: i1$1.Router }, { type: SharkTableUtils }]; }, propDecorators: { headerInfoComponent: [{
1881
- type: ViewChild,
1882
- args: [SharkTableInfoHeaderComponent, { static: false }]
1883
- }], headerComponent: [{
1884
- type: ViewChild,
1885
- args: [SharkTableHeaderComponent, { static: false }]
1886
- }], footerComponent: [{
1887
- type: ViewChild,
1888
- args: [SharkTableFooterComponent, { static: false }]
1889
- }], headerLeftTemplate: [{
1890
- type: ContentChild,
1891
- args: ['headerLeft', { static: false }]
1892
- }], headerRightTemplate: [{
1893
- type: ContentChild,
1894
- args: ['headerRight', { static: false }]
1895
- }], footerLeftTemplate: [{
1896
- type: ContentChild,
1897
- args: ['footerLeft', { static: false }]
1898
- }], footerRightTemplate: [{
1899
- type: ContentChild,
1900
- args: ['footerRight', { static: false }]
1901
- }], tableId: [{
1902
- type: Input
1903
- }], data: [{
1904
- type: Input
1905
- }], columns: [{
1906
- type: Input
1907
- }], caption: [{
1908
- type: Input
1909
- }], hideCaption: [{
1910
- type: Input
1911
- }], columnPicker: [{
1912
- type: Input
1913
- }], columnOrdering: [{
1914
- type: Input
1915
- }], linkTarget: [{
1916
- type: Input
1917
- }], linkKey: [{
1918
- type: Input
1919
- }], sortable: [{
1920
- type: Input
1921
- }], filterable: [{
1922
- type: Input
1923
- }], columnFiltering: [{
1924
- type: Input
1925
- }], localFilter: [{
1926
- type: Input
1927
- }], showFilterPlaceholders: [{
1928
- type: Input
1929
- }], localPaging: [{
1930
- type: Input
1931
- }], localPagingSize: [{
1932
- type: Input
1933
- }], localPagingOptions: [{
1934
- type: Input
1935
- }], showLocalPagingOptions: [{
1936
- type: Input
1937
- }], serverSideData: [{
1938
- type: Input
1939
- }], initialSort: [{
1940
- type: Input
1941
- }], cellStylingFunction: [{
1942
- type: Input
1943
- }], childRows: [{
1944
- type: Input
1945
- }], childComponent: [{
1946
- type: Input
1947
- }], pageChange: [{
1948
- type: Output
1949
- }], columnChange: [{
1950
- type: Output
1951
- }], disableColumnChangeEvent: [{
1952
- type: Input
1953
- }], filter: [{
1954
- type: Input
1955
- }], footer: [{
1956
- type: Input
1957
- }], tableEmptyMessage: [{
1958
- type: Input
1959
- }], rowStylingFunction: [{
1960
- type: Input
1961
- }] } });
1962
-
1963
- class SharkTableModule {
1964
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1965
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.2.12", ngImport: i0, type: SharkTableModule, declarations: [AriaNotifierComponent,
1966
- SharkTableComponent,
1967
- SharkChildComponent,
1968
- SharkDynamicContentsDirective,
1969
- SharkTableCellComponent,
1970
- SharkTableHeaderComponent,
1971
- SharkTableHeaderButtonComponent,
1972
- SharkTableInfoHeaderComponent,
1973
- SharkTableFooterComponent,
1974
- SharkTablePaginationComponent,
1975
- SharkTableBodyComponent,
1976
- LocalFilterPipe], imports: [CommonModule,
1977
- FormsModule,
1978
- RouterModule], exports: [SharkTableComponent,
1979
- SharkTablePaginationComponent] });
1980
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableModule, providers: [
1981
- SharkTableUtils
1982
- ], imports: [CommonModule,
1983
- FormsModule,
1984
- RouterModule] });
1985
- }
1986
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SharkTableModule, decorators: [{
1987
- type: NgModule,
1988
- args: [{
1989
- imports: [
1990
- CommonModule,
1991
- FormsModule,
1992
- RouterModule
1993
- ],
1994
- declarations: [
1995
- AriaNotifierComponent,
1996
- SharkTableComponent,
1997
- SharkChildComponent,
1998
- SharkDynamicContentsDirective,
1999
- SharkTableCellComponent,
2000
- SharkTableHeaderComponent,
2001
- SharkTableHeaderButtonComponent,
2002
- SharkTableInfoHeaderComponent,
2003
- SharkTableFooterComponent,
2004
- SharkTablePaginationComponent,
2005
- SharkTableBodyComponent,
2006
- LocalFilterPipe
2007
- ],
2008
- exports: [
2009
- SharkTableComponent,
2010
- SharkTablePaginationComponent
2011
- ],
2012
- providers: [
2013
- SharkTableUtils
2014
- ]
2015
- }]
2016
- }] });
2017
-
2018
- class SharkTableCurrentDataEvent {
2019
- data;
2020
- columns;
2021
- }
2022
-
2023
- /**
2024
- * Generated bundle index. Do not edit.
2025
- */
2026
-
2279
+ }]
2280
+ }],
2281
+ propDecorators: {
2282
+ headerInfoComponent: [{
2283
+ type: ViewChild,
2284
+ args: [SharkTableInfoHeaderComponent]
2285
+ }],
2286
+ headerComponent: [{
2287
+ type: ViewChild,
2288
+ args: [SharkTableHeaderComponent]
2289
+ }],
2290
+ footerComponent: [{
2291
+ type: ViewChild,
2292
+ args: [SharkTableFooterComponent]
2293
+ }],
2294
+ headerLeftTemplate: [{
2295
+ type: ContentChild,
2296
+ args: ["headerLeft"]
2297
+ }],
2298
+ headerRightTemplate: [{
2299
+ type: ContentChild,
2300
+ args: ["headerRight"]
2301
+ }],
2302
+ footerLeftTemplate: [{
2303
+ type: ContentChild,
2304
+ args: ["footerLeft"]
2305
+ }],
2306
+ footerRightTemplate: [{
2307
+ type: ContentChild,
2308
+ args: ["footerRight"]
2309
+ }],
2310
+ tableId: [{ type: Input }],
2311
+ data: [{ type: Input }],
2312
+ columns: [{ type: Input }],
2313
+ caption: [{ type: Input }],
2314
+ hideCaption: [{ type: Input }],
2315
+ columnPicker: [{ type: Input }],
2316
+ columnOrdering: [{ type: Input }],
2317
+ linkTarget: [{ type: Input }],
2318
+ linkKey: [{ type: Input }],
2319
+ sortable: [{ type: Input }],
2320
+ filterable: [{ type: Input }],
2321
+ columnFiltering: [{ type: Input }],
2322
+ localFilter: [{ type: Input }],
2323
+ showFilterPlaceholders: [{ type: Input }],
2324
+ localPaging: [{ type: Input }],
2325
+ localPagingSize: [{ type: Input }],
2326
+ localPagingOptions: [{ type: Input }],
2327
+ showLocalPagingOptions: [{ type: Input }],
2328
+ serverSideData: [{ type: Input }],
2329
+ initialSort: [{ type: Input }],
2330
+ cellStylingFunction: [{ type: Input }],
2331
+ childRows: [{ type: Input }],
2332
+ childComponent: [{ type: Input }],
2333
+ pageChange: [{ type: Output }],
2334
+ columnChange: [{ type: Output }],
2335
+ disableColumnChangeEvent: [{ type: Input }],
2336
+ filter: [{ type: Input }],
2337
+ footer: [{ type: Input }],
2338
+ tableEmptyMessage: [{ type: Input }],
2339
+ rowStylingFunction: [{ type: Input }]
2340
+ }
2341
+ });
2342
+ var SharkTableModule = class SharkTableModule {
2343
+ static ɵfac = i0.ɵɵngDeclareFactory({
2344
+ minVersion: "12.0.0",
2345
+ version: "22.2.6",
2346
+ ngImport: i0,
2347
+ type: SharkTableModule,
2348
+ deps: [],
2349
+ target: i0.ɵɵFactoryTarget.NgModule
2350
+ });
2351
+ static ɵmod = i0.ɵɵngDeclareNgModule({
2352
+ minVersion: "14.0.0",
2353
+ version: "22.2.6",
2354
+ ngImport: i0,
2355
+ type: SharkTableModule,
2356
+ imports: [SharkTableComponent, SharkTablePaginationComponent],
2357
+ exports: [SharkTableComponent, SharkTablePaginationComponent]
2358
+ });
2359
+ static ɵinj = i0.ɵɵngDeclareInjector({
2360
+ minVersion: "12.0.0",
2361
+ version: "22.2.6",
2362
+ ngImport: i0,
2363
+ type: SharkTableModule,
2364
+ imports: [SharkTableComponent]
2365
+ });
2366
+ };
2367
+ i0.ɵɵngDeclareClassMetadata({
2368
+ minVersion: "12.0.0",
2369
+ version: "22.2.6",
2370
+ ngImport: i0,
2371
+ type: SharkTableModule,
2372
+ decorators: [{
2373
+ type: NgModule,
2374
+ args: [{
2375
+ imports: [SharkTableComponent, SharkTablePaginationComponent],
2376
+ exports: [SharkTableComponent, SharkTablePaginationComponent]
2377
+ }]
2378
+ }]
2379
+ });
2380
+ var SharkTableCurrentDataEvent = class {
2381
+ data;
2382
+ columns;
2383
+ };
2027
2384
  export { SharkChildComponent, SharkColumnChangeEvent, SharkCurrentSort, SharkSortType, SharkTableCellComponent, SharkTableComponent, SharkTableCurrentDataEvent, SharkTableModule, SharkTablePaginationComponent, SharkTableUtils };
2028
- //# sourceMappingURL=shark-ng-table.mjs.map
2385
+
2386
+ //# sourceMappingURL=shark-ng-table.mjs.map