@angular-generic-table/core 5.0.0-rc.10 → 5.0.0-rc.13
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.
- package/esm2020/lib/core.component.mjs +98 -30
- package/esm2020/lib/core.module.mjs +24 -7
- package/esm2020/lib/core.service.mjs +5 -5
- package/esm2020/lib/enums/order.enum.mjs +1 -1
- package/esm2020/lib/gt-delta/gt-delta.component.mjs +104 -0
- package/esm2020/lib/models/gt-pagination.mjs +2 -0
- package/esm2020/lib/models/table-column.interface.mjs +1 -1
- package/esm2020/lib/models/table-config.interface.mjs +1 -1
- package/esm2020/lib/models/table-events.interface.mjs +2 -0
- package/esm2020/lib/pagination/pagination.component.mjs +47 -12
- package/esm2020/lib/pagination/pagination.module.mjs +5 -5
- package/esm2020/lib/pipes/capital-case.pipe.mjs +3 -3
- package/esm2020/lib/pipes/dash-case.pipe.mjs +5 -5
- package/esm2020/lib/pipes/dynamic.pipe.mjs +3 -3
- package/esm2020/lib/pipes/highlight.pipe.mjs +6 -6
- package/esm2020/lib/pipes/sort-class.pipe.mjs +12 -6
- package/esm2020/lib/utilities/utilities.mjs +20 -6
- package/esm2020/public-api.mjs +3 -1
- package/fesm2015/angular-generic-table-core.mjs +331 -88
- package/fesm2015/angular-generic-table-core.mjs.map +1 -1
- package/fesm2020/angular-generic-table-core.mjs +328 -88
- package/fesm2020/angular-generic-table-core.mjs.map +1 -1
- package/{angular-generic-table-core.d.ts → index.d.ts} +0 -0
- package/lib/core.component.d.ts +18 -6
- package/lib/core.module.d.ts +3 -2
- package/lib/gt-delta/gt-delta.component.d.ts +20 -0
- package/lib/models/gt-pagination.d.ts +10 -0
- package/lib/models/table-column.interface.d.ts +4 -0
- package/lib/models/table-config.interface.d.ts +6 -0
- package/lib/models/table-events.interface.d.ts +11 -0
- package/lib/pagination/pagination.component.d.ts +11 -1
- package/lib/pipes/capital-case.pipe.d.ts +1 -1
- package/lib/pipes/dash-case.pipe.d.ts +1 -1
- package/lib/pipes/dynamic.pipe.d.ts +1 -1
- package/lib/pipes/highlight.pipe.d.ts +1 -1
- package/lib/pipes/sort-class.pipe.d.ts +2 -2
- package/package.json +5 -5
- package/public-api.d.ts +2 -0
- package/scss/index.scss +170 -13
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, Pipe, Injector, Component, ChangeDetectionStrategy, Input, NgModule } from '@angular/core';
|
|
2
|
+
import { Injectable, Pipe, Injector, EventEmitter, Component, ChangeDetectionStrategy, Input, Output, NgModule } from '@angular/core';
|
|
3
3
|
import { ReplaySubject, Subject, isObservable, of, combineLatest, EMPTY, BehaviorSubject } from 'rxjs';
|
|
4
|
-
import { startWith, map, switchMap,
|
|
4
|
+
import { debounceTime, distinctUntilChanged, tap, shareReplay, startWith, map, switchMap, withLatestFrom, take, pluck } from 'rxjs/operators';
|
|
5
5
|
import * as i1 from '@angular/common';
|
|
6
6
|
import { CommonModule } from '@angular/common';
|
|
7
7
|
|
|
8
8
|
class CoreService {
|
|
9
9
|
constructor() { }
|
|
10
10
|
}
|
|
11
|
-
CoreService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
12
|
-
CoreService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
13
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
11
|
+
CoreService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: CoreService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
12
|
+
CoreService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: CoreService, providedIn: 'root' });
|
|
13
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: CoreService, decorators: [{
|
|
14
14
|
type: Injectable,
|
|
15
15
|
args: [{
|
|
16
|
-
providedIn: 'root'
|
|
16
|
+
providedIn: 'root',
|
|
17
17
|
}]
|
|
18
18
|
}], ctorParameters: function () { return []; } });
|
|
19
19
|
|
|
@@ -51,11 +51,25 @@ search = (text, caseSensitive, data, config) => {
|
|
|
51
51
|
if (config.columns) {
|
|
52
52
|
const searchColumns = Object.keys(config.columns).filter(
|
|
53
53
|
// @ts-ignore
|
|
54
|
-
(key) =>
|
|
55
|
-
|
|
56
|
-
.
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
(key) => config.columns &&
|
|
55
|
+
!config.columns[key]?.hidden &&
|
|
56
|
+
config.columns[key]?.search !== false);
|
|
57
|
+
const FILTERED = [];
|
|
58
|
+
for (let i = 0; i < data.length; i++) {
|
|
59
|
+
const row = data[i];
|
|
60
|
+
const match = Object.entries(row)
|
|
61
|
+
.filter(([key, value]) => searchColumns.indexOf(key) !== -1)
|
|
62
|
+
.reduce((acc, [key, value], index) => {
|
|
63
|
+
return (acc +
|
|
64
|
+
(index === 0 ? '' : ' ? ') +
|
|
65
|
+
(caseSensitive ? value + '' : (value + '').toLowerCase()));
|
|
66
|
+
}, '')
|
|
67
|
+
.indexOf(text) !== -1;
|
|
68
|
+
if (match) {
|
|
69
|
+
FILTERED[FILTERED.length] = row;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return FILTERED;
|
|
59
73
|
}
|
|
60
74
|
else {
|
|
61
75
|
return data;
|
|
@@ -63,13 +77,19 @@ search = (text, caseSensitive, data, config) => {
|
|
|
63
77
|
};
|
|
64
78
|
|
|
65
79
|
class SortClassPipe {
|
|
66
|
-
transform(selection, property) {
|
|
67
|
-
return selection?.sortBy === property
|
|
80
|
+
transform(selection, property, aria = false) {
|
|
81
|
+
return selection?.sortBy === property
|
|
82
|
+
? !aria
|
|
83
|
+
? 'gt-sort-' + selection.sortByOrder
|
|
84
|
+
: selection.sortByOrder + 'ending'
|
|
85
|
+
: !aria
|
|
86
|
+
? ''
|
|
87
|
+
: null;
|
|
68
88
|
}
|
|
69
89
|
}
|
|
70
|
-
SortClassPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
71
|
-
SortClassPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "
|
|
72
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
90
|
+
SortClassPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: SortClassPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
91
|
+
SortClassPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.1.1", ngImport: i0, type: SortClassPipe, name: "sortClass" });
|
|
92
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: SortClassPipe, decorators: [{
|
|
73
93
|
type: Pipe,
|
|
74
94
|
args: [{
|
|
75
95
|
name: 'sortClass',
|
|
@@ -81,26 +101,12 @@ class DashCasePipe {
|
|
|
81
101
|
return dashed(s);
|
|
82
102
|
}
|
|
83
103
|
}
|
|
84
|
-
DashCasePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
85
|
-
DashCasePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "
|
|
86
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
104
|
+
DashCasePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: DashCasePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
105
|
+
DashCasePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.1.1", ngImport: i0, type: DashCasePipe, name: "dashCase" });
|
|
106
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: DashCasePipe, decorators: [{
|
|
87
107
|
type: Pipe,
|
|
88
108
|
args: [{
|
|
89
|
-
name: 'dashCase'
|
|
90
|
-
}]
|
|
91
|
-
}] });
|
|
92
|
-
|
|
93
|
-
class CapitalCasePipe {
|
|
94
|
-
transform(s) {
|
|
95
|
-
return capitalize(s);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
CapitalCasePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: CapitalCasePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
99
|
-
CapitalCasePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: CapitalCasePipe, name: "capitalCase" });
|
|
100
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: CapitalCasePipe, decorators: [{
|
|
101
|
-
type: Pipe,
|
|
102
|
-
args: [{
|
|
103
|
-
name: 'capitalCase',
|
|
109
|
+
name: 'dashCase',
|
|
104
110
|
}]
|
|
105
111
|
}] });
|
|
106
112
|
|
|
@@ -118,7 +124,7 @@ class HighlightPipe {
|
|
|
118
124
|
searchTerm
|
|
119
125
|
.toLowerCase()
|
|
120
126
|
.match(/".*?"|[^ ]+/g) // extract words
|
|
121
|
-
.map(needle => needle.replace(/"(.*?)"/, '$1') // strip away '"'
|
|
127
|
+
.map((needle) => needle.replace(/"(.*?)"/, '$1') // strip away '"'
|
|
122
128
|
)
|
|
123
129
|
.join('|') + // combine words
|
|
124
130
|
')', 'ig');
|
|
@@ -141,12 +147,26 @@ class HighlightPipe {
|
|
|
141
147
|
return highlightedText;
|
|
142
148
|
}
|
|
143
149
|
}
|
|
144
|
-
HighlightPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
145
|
-
HighlightPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "
|
|
146
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
150
|
+
HighlightPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: HighlightPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
151
|
+
HighlightPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.1.1", ngImport: i0, type: HighlightPipe, name: "highlight" });
|
|
152
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: HighlightPipe, decorators: [{
|
|
153
|
+
type: Pipe,
|
|
154
|
+
args: [{
|
|
155
|
+
name: 'highlight',
|
|
156
|
+
}]
|
|
157
|
+
}] });
|
|
158
|
+
|
|
159
|
+
class CapitalCasePipe {
|
|
160
|
+
transform(s) {
|
|
161
|
+
return capitalize(s);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
CapitalCasePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: CapitalCasePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
|
|
165
|
+
CapitalCasePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.1.1", ngImport: i0, type: CapitalCasePipe, name: "capitalCase" });
|
|
166
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: CapitalCasePipe, decorators: [{
|
|
147
167
|
type: Pipe,
|
|
148
168
|
args: [{
|
|
149
|
-
name: '
|
|
169
|
+
name: 'capitalCase',
|
|
150
170
|
}]
|
|
151
171
|
}] });
|
|
152
172
|
|
|
@@ -164,9 +184,9 @@ class DynamicPipe {
|
|
|
164
184
|
return pipe.transform(value, ...(pipeArgs || []));
|
|
165
185
|
}
|
|
166
186
|
}
|
|
167
|
-
DynamicPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
168
|
-
DynamicPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "
|
|
169
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
187
|
+
DynamicPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: DynamicPipe, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Pipe });
|
|
188
|
+
DynamicPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "14.1.1", ngImport: i0, type: DynamicPipe, name: "dynamicPipe" });
|
|
189
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: DynamicPipe, decorators: [{
|
|
170
190
|
type: Pipe,
|
|
171
191
|
args: [{
|
|
172
192
|
name: 'dynamicPipe',
|
|
@@ -175,6 +195,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImpor
|
|
|
175
195
|
|
|
176
196
|
class CoreComponent {
|
|
177
197
|
constructor() {
|
|
198
|
+
this.rowClick = new EventEmitter();
|
|
199
|
+
this._rowHover$ = new ReplaySubject(1);
|
|
200
|
+
this.rowHover = new EventEmitter();
|
|
201
|
+
this.rowHover$ = this._rowHover$.asObservable().pipe(debounceTime(50), distinctUntilChanged((p, q) => p.index === q.index), tap((event) => this.rowHover.emit(event)), shareReplay(1));
|
|
178
202
|
this._loading$ = new ReplaySubject(1);
|
|
179
203
|
this.sortBy$ = new Subject();
|
|
180
204
|
// tslint:disable-next-line:variable-name
|
|
@@ -183,16 +207,42 @@ class CoreComponent {
|
|
|
183
207
|
// tslint:disable-next-line:variable-name
|
|
184
208
|
this._tableConfig$ = new ReplaySubject(1);
|
|
185
209
|
this.tableConfig$ = this._tableConfig$.pipe(map((value) => (isObservable(value) ? value : of(value))), switchMap((obs) => obs), shareReplay(1));
|
|
186
|
-
// tslint:disable-next-line:variable-name
|
|
187
210
|
this._data$ = new ReplaySubject(1);
|
|
188
|
-
this.data$ = this._data$.pipe(map((value) => (isObservable(value) ? value : of(value))), switchMap((obs) => combineLatest([obs
|
|
211
|
+
this.data$ = this._data$.pipe(map((value) => (isObservable(value) ? value : of(value))), switchMap((obs) => combineLatest([obs])), withLatestFrom(this.tableConfig$), map(([[data], config]) => {
|
|
212
|
+
// if columns or rows contains config for mapTo...
|
|
213
|
+
if ((config.columns &&
|
|
214
|
+
!!Object.values(config.columns).find((column) => !!column.mapTo)) ||
|
|
215
|
+
(config.rows &&
|
|
216
|
+
!!Object.values(config.rows).find((column) => !!column.mapTo))) {
|
|
217
|
+
// ...map data to new keys on row...
|
|
218
|
+
const newData = [];
|
|
219
|
+
for (let i = 0; i < data.length; i++) {
|
|
220
|
+
const row = data[i];
|
|
221
|
+
const newKeys = Object.entries(config.columns || config.rows || [])
|
|
222
|
+
.filter(([key, value]) => !!value.mapTo) // add keys for columns with mapTo config...
|
|
223
|
+
.reduce((previousValue, [key, value]) => ({
|
|
224
|
+
...previousValue,
|
|
225
|
+
[key]: this.nestedValue(row, value.mapTo.path, value.mapTo?.missingValue),
|
|
226
|
+
}), {});
|
|
227
|
+
newData[i] = { ...row, ...newKeys };
|
|
228
|
+
}
|
|
229
|
+
data = newData;
|
|
230
|
+
}
|
|
231
|
+
return { data, config };
|
|
232
|
+
}), switchMap((obs) => combineLatest([
|
|
233
|
+
of(obs),
|
|
234
|
+
this.sortBy$.pipe(startWith(EMPTY)),
|
|
235
|
+
this.searchBy$,
|
|
236
|
+
])), map(([table, sortBy, searchBy]) => {
|
|
189
237
|
// create a new array reference and sort new array (prevent mutating existing state)
|
|
190
|
-
data = [...data];
|
|
238
|
+
table.data = [...table.data];
|
|
191
239
|
return !sortBy
|
|
192
240
|
? searchBy
|
|
193
|
-
? search(searchBy, false, data, config)
|
|
194
|
-
: data
|
|
195
|
-
: (searchBy
|
|
241
|
+
? search(searchBy, false, table.data, table.config)
|
|
242
|
+
: table.data
|
|
243
|
+
: (searchBy
|
|
244
|
+
? search(searchBy, false, table.data, table.config)
|
|
245
|
+
: table.data)?.sort((a, b) => {
|
|
196
246
|
// TODO: improve logic
|
|
197
247
|
const typed = sortBy;
|
|
198
248
|
return a[typed.sortBy] > b[typed.sortBy]
|
|
@@ -206,11 +256,18 @@ class CoreComponent {
|
|
|
206
256
|
: 0;
|
|
207
257
|
});
|
|
208
258
|
}), shareReplay(1));
|
|
209
|
-
this.table$ = combineLatest([
|
|
259
|
+
this.table$ = combineLatest([
|
|
260
|
+
this.data$,
|
|
261
|
+
this.tableConfig$,
|
|
262
|
+
]).pipe(map(([sorted, config]) => {
|
|
210
263
|
// if pagination is disabled...
|
|
211
264
|
if (!config.pagination || config.pagination.length === 0) {
|
|
212
265
|
// ...return unaltered array
|
|
213
|
-
return {
|
|
266
|
+
return {
|
|
267
|
+
data: [sorted],
|
|
268
|
+
config,
|
|
269
|
+
info: { records: sorted.length, pageTotal: 1 },
|
|
270
|
+
};
|
|
214
271
|
}
|
|
215
272
|
// return record set
|
|
216
273
|
return {
|
|
@@ -225,7 +282,8 @@ class CoreComponent {
|
|
|
225
282
|
this._currentPage$ = new BehaviorSubject(0);
|
|
226
283
|
this.currentPage$ = combineLatest([this._currentPage$, this.table$]).pipe(map(([page, table]) => {
|
|
227
284
|
// determine last page
|
|
228
|
-
const lastPage = Math.ceil(table.info.records /
|
|
285
|
+
const lastPage = Math.ceil(table.info.records /
|
|
286
|
+
(table.config?.pagination?.length || table.info.records)) - 1;
|
|
229
287
|
// determine max/min position
|
|
230
288
|
return +page < 0 ? 0 : +page > lastPage ? lastPage : +page;
|
|
231
289
|
}), shareReplay(1));
|
|
@@ -236,26 +294,47 @@ class CoreComponent {
|
|
|
236
294
|
return (a.value.order || 0) - (b.value.order || 0);
|
|
237
295
|
};
|
|
238
296
|
}
|
|
239
|
-
set loading(
|
|
240
|
-
this._loading$.next(
|
|
297
|
+
set loading(isLoading) {
|
|
298
|
+
this._loading$.next(isLoading);
|
|
299
|
+
}
|
|
300
|
+
set page(page) {
|
|
301
|
+
this._currentPage$.next(page);
|
|
241
302
|
}
|
|
242
|
-
set
|
|
243
|
-
this.
|
|
303
|
+
set search(string) {
|
|
304
|
+
this._searchBy$.next(string);
|
|
244
305
|
}
|
|
245
|
-
set
|
|
246
|
-
this.
|
|
306
|
+
set config(config) {
|
|
307
|
+
this._tableConfig$.next(config);
|
|
247
308
|
}
|
|
248
|
-
set
|
|
249
|
-
this.
|
|
309
|
+
set data(data) {
|
|
310
|
+
this._data$.next(data);
|
|
250
311
|
}
|
|
251
|
-
|
|
252
|
-
this.
|
|
312
|
+
_rowClick(row, index, event) {
|
|
313
|
+
this.rowClick.emit({ row, index, event });
|
|
314
|
+
}
|
|
315
|
+
hoverRow(arg) {
|
|
316
|
+
if (typeof arg === 'number') {
|
|
317
|
+
this.data$
|
|
318
|
+
.pipe(map((data) => data[arg]), take(1))
|
|
319
|
+
.subscribe((row) => this._hoverRow(row, arg));
|
|
320
|
+
}
|
|
321
|
+
else if (typeof arg === 'string') {
|
|
322
|
+
// TODO: implement hover by id
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
this._hoverRow(null, null);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
_hoverRow(row, index, event) {
|
|
329
|
+
this._rowHover$.next({ row, index, event });
|
|
253
330
|
}
|
|
254
331
|
get loading$() {
|
|
255
332
|
return this._loading$.pipe(startWith(false), map((value) => (isObservable(value) ? value : of(value))), switchMap((obs) => obs), shareReplay(1));
|
|
256
333
|
}
|
|
257
334
|
sort(property) {
|
|
258
|
-
const newSortOrder = this._sortBy?.sortBy !== property ||
|
|
335
|
+
const newSortOrder = this._sortBy?.sortBy !== property ||
|
|
336
|
+
this._sortBy?.sortByOrder === Order.DESC ||
|
|
337
|
+
!this._sortBy.sortByOrder
|
|
259
338
|
? Order.ASC
|
|
260
339
|
: Order.DESC;
|
|
261
340
|
const newSortBy = {
|
|
@@ -265,12 +344,17 @@ class CoreComponent {
|
|
|
265
344
|
this.sortBy$.next(newSortBy);
|
|
266
345
|
this._sortBy = newSortBy;
|
|
267
346
|
}
|
|
347
|
+
nestedValue(object, mapTo, missingValue = null) {
|
|
348
|
+
const levels = mapTo.split('.');
|
|
349
|
+
return levels.reduce((previousValue, currentValue, index) => previousValue[currentValue] ||
|
|
350
|
+
(index === levels.length - 1 ? missingValue : {}), object);
|
|
351
|
+
}
|
|
268
352
|
}
|
|
269
|
-
CoreComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
270
|
-
CoreComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.3", type: CoreComponent, selector: "angular-generic-table", inputs: { loading: "loading", page: "page", search: "search", config: "config", data: "data" }, ngImport: i0, template: "<table [ngClass]=\"(tableConfig$ | async)?.class || 'table'\" [class.table-mobile]=\"(tableConfig$ | async)?.mobileLayout\">\n <thead>\n <tr *ngIf=\"{\n config:(tableConfig$ | async)!,\n loading: loading$ | async\n } as table\">\n <ng-container *ngFor=\"let column of table?.config?.columns | keyvalue: columnOrder\">\n <th\n *ngIf=\"!column.value?.hidden\"\n ngClass=\"{{ column.value?.sortable ? 'sort ' : '' }} {{ sortBy$ | async | sortClass: column.key }} {{\n (column.key | dashCase) + '-column'\n }} {{column.value.class}}\"\n [class.disabled]=\"table.loading\"\n (click)=\"table.loading || !column.value?.sortable || sort(column.key)\"\n >\n <span *ngIf=\"column.value?.header !== false\">{{ column.value?.header || column.key | capitalCase }}</span>\n </th>\n </ng-container>\n <ng-container *ngIf=\"((table?.config?.rows | keyvalue: columnOrder)||[])[0] as headerRow\">\n <th class=\"row-header\"\n ngClass=\"{{ headerRow.value?.sortable ? 'sort ' : '' }} {{ sortBy$ | async | sortClass: headerRow.key }} {{\n (headerRow.key | dashCase) + '-column'\n }}\"\n (click)=\"table.loading || !headerRow.value?.sortable || sort(headerRow.key)\">\n <ng-container *ngIf=\"headerRow?.value?.header !== false\">{{headerRow?.value?.header || headerRow.key | capitalCase }}</ng-container>\n </th>\n <th *ngFor=\"let column of ((table$ | async)?.data || [])[0]\" ngClass=\"{{headerRow.value?.class}}\">\n <ng-container [ngTemplateOutlet]=\"(table.config?.rows || {})[headerRow.key].templateRef ? templateRef : (table.config?.rows || {})[headerRow.key].transform ? transformData:\n rawData\" [ngTemplateOutletContext]=\"{row: column, column: headerRow, transform: (table.config?.rows || {})[headerRow.key].transform, templateRef: (table.config?.rows || {})[headerRow.key].templateRef, index: 0}\">\n </ng-container>\n </th>\n </ng-container>\n </tr>\n </thead>\n <tbody *ngIf=\"loading$ | async; else tableContent\">\n <tr>\n <td class=\"p-0\" [colSpan]=\"colspan$ | async\">\n <ng-content select=\".table-loading\"></ng-content>\n </td>\n </tr>\n </tbody>\n</table>\n<ng-template #tableContent>\n <ng-container\n *ngIf=\"(table$ | async)! as table\"\n >\n <tbody *ngIf=\"(table!.data![0] || table!.data!).length > 0; else noData\">\n <ng-container *ngIf=\"table.config.columns\">\n <tr *ngFor=\"let row of table!.data![(currentPage$ | async) || 0]; let i = index\" [attr.id]=\"'tableRow_' + i\">\n <ng-container *ngFor=\"let column of table.config?.columns | keyvalue: columnOrder\">\n <td *ngIf=\"!column.value?.hidden\" ngClass=\"{{(column.key | dashCase) + '-column'}} {{column.value?.class}}\">\n <span *ngIf=\"column.value?.mobileHeader && table.config?.mobileLayout\" class=\"mobile-header\">{{ column.value?.mobileHeader !== true ? column.value?.mobileHeader : column.value?.header || column.key | capitalCase }}</span>\n <ng-container [ngTemplateOutlet]=\"(searchBy$ | async) && !(table.config?.columns || {})[column.key].templateRef ? highlighted:\n (table.config?.columns || {})[column.key].templateRef ? templateRef : (table.config?.columns || {})[column.key].transform ? transformData:\n rawData\" [ngTemplateOutletContext]=\"{row: row, column: column, search: (searchBy$ | async), transform: (table.config?.columns || {})[column.key].transform, templateRef: (table.config?.columns || {})[column.key].templateRef, index: i}\"></ng-container></td>\n </ng-container>\n </tr>\n </ng-container>\n <ng-container *ngIf=\"table.config.rows\">\n <ng-container *ngFor=\"let row of table?.config?.rows | keyvalue: columnOrder | slice:1; let i = index\">\n <tr *ngIf=\"!row.value?.hidden\" [attr.id]=\"'tableRow_' + i\" ngClass=\"{{(row.key | dashCase) + '-row'}}\">\n <th class=\"row-header\">\n <span *ngIf=\"row.value.mobileHeader\" class=\"mobile-header\">{{ row.value?.mobileHeader !== true ? row.value?.mobileHeader : row.value?.header || row.key | capitalCase }}</span>\n {{row.value?.header || row.key | capitalCase}}\n </th>\n <td *ngFor=\"let column of (table?.data || [])[0]\" ngClass=\"{{row.value?.class}}\">\n <ng-container [ngTemplateOutlet]=\"(table.config?.rows || {})[row.key].templateRef ? templateRef : (table.config?.rows || {})[row.key].transform ? transformData:\n rawData\" [ngTemplateOutletContext]=\"{row: column, column: row, transform: (table.config?.rows || {})[row.key].transform, templateRef: (table.config?.rows || {})[row.key].templateRef, index: i}\">\n </ng-container>\n </td>\n </tr>\n </ng-container>\n </ng-container>\n </tbody>\n </ng-container>\n</ng-template>\n<ng-template #noData>\n <tbody>\n <tr>\n <td class=\"p-0\" [colSpan]=\"colspan$ | async\">\n <ng-content select=\".table-no-data\"></ng-content>\n </td>\n </tr>\n </tbody>\n</ng-template>\n<ng-template #highlighted let-row=\"row\" let-column=\"column\" let-search=\"search\">\n <div [innerHTML]=\"(row[column.key] | highlight: search)\"></div>\n</ng-template>\n<ng-template #rawData let-row=\"row\" let-column=\"column\">\n {{row[column.key]}}\n</ng-template>\n<ng-template #transformData let-row=\"row\" let-column=\"column\" let-transform=\"transform\">\n {{row[column.key] | dynamicPipe:transform.pipe:transform?.args}}\n</ng-template>\n<ng-template #templateRef let-row=\"row\" let-column=\"column\" let-index=\"index\" let-templateRef=\"templateRef\">\n <ng-container [ngTemplateOutlet]=\"templateRef\" [ngTemplateOutletContext]=\"{row: row, col: column, index: index}\"></ng-container>\n</ng-template>\n", directives: [{ type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], pipes: { "async": i1.AsyncPipe, "keyvalue": i1.KeyValuePipe, "sortClass": SortClassPipe, "dashCase": DashCasePipe, "capitalCase": CapitalCasePipe, "slice": i1.SlicePipe, "highlight": HighlightPipe, "dynamicPipe": DynamicPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
271
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
353
|
+
CoreComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: CoreComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
354
|
+
CoreComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.1", type: CoreComponent, selector: "angular-generic-table", inputs: { loading: "loading", page: "page", search: "search", config: "config", data: "data" }, outputs: { rowClick: "rowClick", rowHover: "rowHover" }, ngImport: i0, template: "<table\n [ngClass]=\"(tableConfig$ | async)?.class || 'table'\"\n [class.table-mobile]=\"(tableConfig$ | async)?.mobileLayout\"\n [class.table-horizontal]=\"(tableConfig$ | async)?.rows\"\n [class.table-loading]=\"loading$ | async\"\n [class.gt-sticky-row-header]=\"\n (tableConfig$ | async)?.stickyHeaders?.row && (tableConfig$ | async)?.rows\n \"\n [class.gt-sticky-column-header]=\"\n (tableConfig$ | async)?.stickyHeaders?.column\n \"\n [attr.aria-busy]=\"(loading$ | async) === true ? true : null\"\n>\n <thead>\n <tr\n *ngIf=\"{\n config: (tableConfig$ | async)!,\n isLoading: loading$ | async\n } as table\"\n >\n <ng-container\n *ngFor=\"let column of table?.config?.columns | keyvalue: columnOrder\"\n >\n <th\n *ngIf=\"!column.value?.hidden\"\n ngClass=\"{{ (column.key | dashCase) + '-column' }} {{\n column.value.class\n }}\"\n [class.disabled]=\"table.isLoading\"\n [attr.aria-sort]=\"sortBy$ | async | sortClass: column.key:true\"\n [class.gt-sortable]=\"true\"\n scope=\"col\"\n >\n <button\n *ngIf=\"column.value?.sortable\"\n class=\"gt-sort\"\n (click)=\"\n table.isLoading || !column.value?.sortable || sort(column.key)\n \"\n >\n <span *ngIf=\"column.value?.header !== false\">{{\n column.value?.header || column.key | capitalCase\n }}</span>\n </button>\n <span\n *ngIf=\"!column.value?.sortable && column.value?.header !== false\"\n >{{ column.value?.header || column.key | capitalCase }}</span\n >\n </th>\n </ng-container>\n <ng-container\n *ngIf=\"\n ((table?.config?.rows | keyvalue: columnOrder) || [])[0] as headerRow\n \"\n >\n <th\n class=\"row-header\"\n [attr.aria-sort]=\"sortBy$ | async | sortClass: headerRow.key:true\"\n ngClass=\"{{ headerRow.value?.sortable ? 'sort ' : '' }} {{\n sortBy$ | async | sortClass: headerRow.key\n }} {{ (headerRow.key | dashCase) + '-column' }}\"\n (click)=\"\n table.isLoading || !headerRow.value?.sortable || sort(headerRow.key)\n \"\n scope=\"col\"\n >\n <ng-container *ngIf=\"headerRow?.value?.header !== false\">{{\n headerRow?.value?.header || headerRow.key | capitalCase\n }}</ng-container>\n </th>\n <th\n *ngFor=\"let column of ((table$ | async)?.data || [])[0]\"\n ngClass=\"{{ headerRow.value?.class }}\"\n >\n <ng-container\n [ngTemplateOutlet]=\"\n (table.config?.rows || {})[headerRow.key].templateRef\n ? templateRef\n : (table.config?.rows || {})[headerRow.key].transform\n ? transformData\n : rawData\n \"\n [ngTemplateOutletContext]=\"{\n row: column,\n column: headerRow,\n transform: (table.config?.rows || {})[headerRow.key].transform,\n templateRef: (table.config?.rows || {})[headerRow.key]\n .templateRef,\n index: 0\n }\"\n >\n </ng-container>\n </th>\n </ng-container>\n </tr>\n </thead>\n <tbody *ngIf=\"loading$ | async; else tableContent\">\n <tr>\n <td class=\"p-0\" [colSpan]=\"colspan$ | async\">\n <ng-content select=\".table-loading\"></ng-content>\n </td>\n </tr>\n </tbody>\n</table>\n<ng-template #tableContent>\n <ng-container *ngIf=\"(table$ | async)! as table\">\n <tbody *ngIf=\"(table!.data![0] || table!.data!).length > 0; else noData\">\n <ng-container *ngIf=\"table.config.columns\">\n <tr\n *ngFor=\"\n let row of table!.data![(currentPage$ | async) || 0];\n let i = index\n \"\n [attr.id]=\"'tableRow_' + i\"\n (click)=\"table?.config?.rowClick && _rowClick(row, i, $event)\"\n (mouseover)=\"table?.config?.rowHover && _hoverRow(row, i, $event)\"\n (mouseout)=\"table?.config?.rowHover && _hoverRow(null, null, $event)\"\n [class.gt-hover]=\"(rowHover$ | async)?.index === i\"\n >\n <ng-container\n *ngFor=\"let column of table.config?.columns | keyvalue: columnOrder\"\n >\n <td\n *ngIf=\"!column.value?.hidden\"\n ngClass=\"{{ (column.key | dashCase) + '-column' }} {{\n column.value?.class\n }}\"\n [attr.data-label]=\"\n table.config?.mobileLayout && column.value?.mobileHeader\n ? column.value?.mobileHeader !== true\n ? column.value?.mobileHeader\n : (column.value?.header || column.key | capitalCase)\n : null\n \"\n >\n <ng-container\n [ngTemplateOutlet]=\"\n (searchBy$ | async) &&\n !(table.config?.columns || {})[column.key].templateRef\n ? highlighted\n : (table.config?.columns || {})[column.key].templateRef\n ? templateRef\n : (table.config?.columns || {})[column.key].transform\n ? transformData\n : rawData\n \"\n [ngTemplateOutletContext]=\"{\n row: row,\n column: column,\n search: (searchBy$ | async),\n transform: (table.config?.columns || {})[column.key]\n .transform,\n templateRef: (table.config?.columns || {})[column.key]\n .templateRef,\n index: i,\n data: table.data[(currentPage$ | async) || 0]\n }\"\n ></ng-container>\n </td>\n </ng-container>\n </tr>\n </ng-container>\n <ng-container *ngIf=\"table.config.rows\">\n <ng-container\n *ngFor=\"\n let row of table?.config?.rows | keyvalue: columnOrder | slice: 1;\n let i = index\n \"\n >\n <tr\n *ngIf=\"!row.value?.hidden\"\n [attr.id]=\"'tableRow_' + i\"\n ngClass=\"{{ (row.key | dashCase) + '-row' }}\"\n (click)=\"table?.config?.rowClick && _rowClick(row, i, $event)\"\n (mouseover)=\"table?.config?.rowHover && _hoverRow(row, i, $event)\"\n (mouseout)=\"\n table?.config?.rowHover && _hoverRow(null, null, $event)\n \"\n [class.gt-hover]=\"(rowHover$ | async)?.index === i\"\n >\n <th class=\"row-header\" scope=\"row\">\n {{ row.value?.header || row.key | capitalCase }}\n </th>\n <td\n *ngFor=\"let column of (table?.data || [])[0]; let y = index\"\n ngClass=\"{{ row.value?.class }}\"\n >\n <ng-container\n [ngTemplateOutlet]=\"\n (table.config?.rows || {})[row.key].templateRef\n ? templateRef\n : (table.config?.rows || {})[row.key].transform\n ? transformData\n : rawData\n \"\n [ngTemplateOutletContext]=\"{\n row: column,\n column: row,\n transform: (table.config?.rows || {})[row.key].transform,\n templateRef: (table.config?.rows || {})[row.key].templateRef,\n index: table.config?.rows ? y : i,\n data: table.data[(currentPage$ | async) || 0]\n }\"\n >\n </ng-container>\n </td>\n </tr>\n </ng-container>\n </ng-container>\n </tbody>\n </ng-container>\n</ng-template>\n<ng-template #noData>\n <tbody>\n <tr>\n <td class=\"p-0\" [colSpan]=\"colspan$ | async\">\n <ng-content select=\".table-no-data\"></ng-content>\n </td>\n </tr>\n </tbody>\n</ng-template>\n<ng-template #highlighted let-row=\"row\" let-column=\"column\" let-search=\"search\">\n <div [innerHTML]=\"row[column.key] | highlight: search\"></div>\n</ng-template>\n<ng-template #rawData let-row=\"row\" let-column=\"column\">\n {{ row[column.key] }}\n</ng-template>\n<ng-template\n #transformData\n let-row=\"row\"\n let-column=\"column\"\n let-transform=\"transform\"\n let-data=\"data\"\n>\n {{ row[column.key] | dynamicPipe: transform.pipe:transform?.args }}\n</ng-template>\n<ng-template\n #templateRef\n let-row=\"row\"\n let-column=\"column\"\n let-index=\"index\"\n let-templateRef=\"templateRef\"\n let-data=\"data\"\n>\n <ng-container\n [ngTemplateOutlet]=\"templateRef\"\n [ngTemplateOutletContext]=\"{\n row: row,\n col: column,\n index: index,\n data: data\n }\"\n ></ng-container>\n</ng-template>\n", 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.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "pipe", type: i1.SlicePipe, name: "slice" }, { kind: "pipe", type: i1.KeyValuePipe, name: "keyvalue" }, { kind: "pipe", type: SortClassPipe, name: "sortClass" }, { kind: "pipe", type: DashCasePipe, name: "dashCase" }, { kind: "pipe", type: HighlightPipe, name: "highlight" }, { kind: "pipe", type: CapitalCasePipe, name: "capitalCase" }, { kind: "pipe", type: DynamicPipe, name: "dynamicPipe" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
355
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: CoreComponent, decorators: [{
|
|
272
356
|
type: Component,
|
|
273
|
-
args: [{ selector: 'angular-generic-table',
|
|
357
|
+
args: [{ selector: 'angular-generic-table', changeDetection: ChangeDetectionStrategy.OnPush, template: "<table\n [ngClass]=\"(tableConfig$ | async)?.class || 'table'\"\n [class.table-mobile]=\"(tableConfig$ | async)?.mobileLayout\"\n [class.table-horizontal]=\"(tableConfig$ | async)?.rows\"\n [class.table-loading]=\"loading$ | async\"\n [class.gt-sticky-row-header]=\"\n (tableConfig$ | async)?.stickyHeaders?.row && (tableConfig$ | async)?.rows\n \"\n [class.gt-sticky-column-header]=\"\n (tableConfig$ | async)?.stickyHeaders?.column\n \"\n [attr.aria-busy]=\"(loading$ | async) === true ? true : null\"\n>\n <thead>\n <tr\n *ngIf=\"{\n config: (tableConfig$ | async)!,\n isLoading: loading$ | async\n } as table\"\n >\n <ng-container\n *ngFor=\"let column of table?.config?.columns | keyvalue: columnOrder\"\n >\n <th\n *ngIf=\"!column.value?.hidden\"\n ngClass=\"{{ (column.key | dashCase) + '-column' }} {{\n column.value.class\n }}\"\n [class.disabled]=\"table.isLoading\"\n [attr.aria-sort]=\"sortBy$ | async | sortClass: column.key:true\"\n [class.gt-sortable]=\"true\"\n scope=\"col\"\n >\n <button\n *ngIf=\"column.value?.sortable\"\n class=\"gt-sort\"\n (click)=\"\n table.isLoading || !column.value?.sortable || sort(column.key)\n \"\n >\n <span *ngIf=\"column.value?.header !== false\">{{\n column.value?.header || column.key | capitalCase\n }}</span>\n </button>\n <span\n *ngIf=\"!column.value?.sortable && column.value?.header !== false\"\n >{{ column.value?.header || column.key | capitalCase }}</span\n >\n </th>\n </ng-container>\n <ng-container\n *ngIf=\"\n ((table?.config?.rows | keyvalue: columnOrder) || [])[0] as headerRow\n \"\n >\n <th\n class=\"row-header\"\n [attr.aria-sort]=\"sortBy$ | async | sortClass: headerRow.key:true\"\n ngClass=\"{{ headerRow.value?.sortable ? 'sort ' : '' }} {{\n sortBy$ | async | sortClass: headerRow.key\n }} {{ (headerRow.key | dashCase) + '-column' }}\"\n (click)=\"\n table.isLoading || !headerRow.value?.sortable || sort(headerRow.key)\n \"\n scope=\"col\"\n >\n <ng-container *ngIf=\"headerRow?.value?.header !== false\">{{\n headerRow?.value?.header || headerRow.key | capitalCase\n }}</ng-container>\n </th>\n <th\n *ngFor=\"let column of ((table$ | async)?.data || [])[0]\"\n ngClass=\"{{ headerRow.value?.class }}\"\n >\n <ng-container\n [ngTemplateOutlet]=\"\n (table.config?.rows || {})[headerRow.key].templateRef\n ? templateRef\n : (table.config?.rows || {})[headerRow.key].transform\n ? transformData\n : rawData\n \"\n [ngTemplateOutletContext]=\"{\n row: column,\n column: headerRow,\n transform: (table.config?.rows || {})[headerRow.key].transform,\n templateRef: (table.config?.rows || {})[headerRow.key]\n .templateRef,\n index: 0\n }\"\n >\n </ng-container>\n </th>\n </ng-container>\n </tr>\n </thead>\n <tbody *ngIf=\"loading$ | async; else tableContent\">\n <tr>\n <td class=\"p-0\" [colSpan]=\"colspan$ | async\">\n <ng-content select=\".table-loading\"></ng-content>\n </td>\n </tr>\n </tbody>\n</table>\n<ng-template #tableContent>\n <ng-container *ngIf=\"(table$ | async)! as table\">\n <tbody *ngIf=\"(table!.data![0] || table!.data!).length > 0; else noData\">\n <ng-container *ngIf=\"table.config.columns\">\n <tr\n *ngFor=\"\n let row of table!.data![(currentPage$ | async) || 0];\n let i = index\n \"\n [attr.id]=\"'tableRow_' + i\"\n (click)=\"table?.config?.rowClick && _rowClick(row, i, $event)\"\n (mouseover)=\"table?.config?.rowHover && _hoverRow(row, i, $event)\"\n (mouseout)=\"table?.config?.rowHover && _hoverRow(null, null, $event)\"\n [class.gt-hover]=\"(rowHover$ | async)?.index === i\"\n >\n <ng-container\n *ngFor=\"let column of table.config?.columns | keyvalue: columnOrder\"\n >\n <td\n *ngIf=\"!column.value?.hidden\"\n ngClass=\"{{ (column.key | dashCase) + '-column' }} {{\n column.value?.class\n }}\"\n [attr.data-label]=\"\n table.config?.mobileLayout && column.value?.mobileHeader\n ? column.value?.mobileHeader !== true\n ? column.value?.mobileHeader\n : (column.value?.header || column.key | capitalCase)\n : null\n \"\n >\n <ng-container\n [ngTemplateOutlet]=\"\n (searchBy$ | async) &&\n !(table.config?.columns || {})[column.key].templateRef\n ? highlighted\n : (table.config?.columns || {})[column.key].templateRef\n ? templateRef\n : (table.config?.columns || {})[column.key].transform\n ? transformData\n : rawData\n \"\n [ngTemplateOutletContext]=\"{\n row: row,\n column: column,\n search: (searchBy$ | async),\n transform: (table.config?.columns || {})[column.key]\n .transform,\n templateRef: (table.config?.columns || {})[column.key]\n .templateRef,\n index: i,\n data: table.data[(currentPage$ | async) || 0]\n }\"\n ></ng-container>\n </td>\n </ng-container>\n </tr>\n </ng-container>\n <ng-container *ngIf=\"table.config.rows\">\n <ng-container\n *ngFor=\"\n let row of table?.config?.rows | keyvalue: columnOrder | slice: 1;\n let i = index\n \"\n >\n <tr\n *ngIf=\"!row.value?.hidden\"\n [attr.id]=\"'tableRow_' + i\"\n ngClass=\"{{ (row.key | dashCase) + '-row' }}\"\n (click)=\"table?.config?.rowClick && _rowClick(row, i, $event)\"\n (mouseover)=\"table?.config?.rowHover && _hoverRow(row, i, $event)\"\n (mouseout)=\"\n table?.config?.rowHover && _hoverRow(null, null, $event)\n \"\n [class.gt-hover]=\"(rowHover$ | async)?.index === i\"\n >\n <th class=\"row-header\" scope=\"row\">\n {{ row.value?.header || row.key | capitalCase }}\n </th>\n <td\n *ngFor=\"let column of (table?.data || [])[0]; let y = index\"\n ngClass=\"{{ row.value?.class }}\"\n >\n <ng-container\n [ngTemplateOutlet]=\"\n (table.config?.rows || {})[row.key].templateRef\n ? templateRef\n : (table.config?.rows || {})[row.key].transform\n ? transformData\n : rawData\n \"\n [ngTemplateOutletContext]=\"{\n row: column,\n column: row,\n transform: (table.config?.rows || {})[row.key].transform,\n templateRef: (table.config?.rows || {})[row.key].templateRef,\n index: table.config?.rows ? y : i,\n data: table.data[(currentPage$ | async) || 0]\n }\"\n >\n </ng-container>\n </td>\n </tr>\n </ng-container>\n </ng-container>\n </tbody>\n </ng-container>\n</ng-template>\n<ng-template #noData>\n <tbody>\n <tr>\n <td class=\"p-0\" [colSpan]=\"colspan$ | async\">\n <ng-content select=\".table-no-data\"></ng-content>\n </td>\n </tr>\n </tbody>\n</ng-template>\n<ng-template #highlighted let-row=\"row\" let-column=\"column\" let-search=\"search\">\n <div [innerHTML]=\"row[column.key] | highlight: search\"></div>\n</ng-template>\n<ng-template #rawData let-row=\"row\" let-column=\"column\">\n {{ row[column.key] }}\n</ng-template>\n<ng-template\n #transformData\n let-row=\"row\"\n let-column=\"column\"\n let-transform=\"transform\"\n let-data=\"data\"\n>\n {{ row[column.key] | dynamicPipe: transform.pipe:transform?.args }}\n</ng-template>\n<ng-template\n #templateRef\n let-row=\"row\"\n let-column=\"column\"\n let-index=\"index\"\n let-templateRef=\"templateRef\"\n let-data=\"data\"\n>\n <ng-container\n [ngTemplateOutlet]=\"templateRef\"\n [ngTemplateOutletContext]=\"{\n row: row,\n col: column,\n index: index,\n data: data\n }\"\n ></ng-container>\n</ng-template>\n" }]
|
|
274
358
|
}], propDecorators: { loading: [{
|
|
275
359
|
type: Input
|
|
276
360
|
}], page: [{
|
|
@@ -281,27 +365,176 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImpor
|
|
|
281
365
|
type: Input
|
|
282
366
|
}], data: [{
|
|
283
367
|
type: Input
|
|
368
|
+
}], rowClick: [{
|
|
369
|
+
type: Output
|
|
370
|
+
}], rowHover: [{
|
|
371
|
+
type: Output
|
|
372
|
+
}] } });
|
|
373
|
+
|
|
374
|
+
class GtDeltaComponent {
|
|
375
|
+
constructor() {
|
|
376
|
+
this.Math = Math;
|
|
377
|
+
this.Number = Number;
|
|
378
|
+
this.data = [];
|
|
379
|
+
this.index = 0;
|
|
380
|
+
this.classes = {
|
|
381
|
+
span: 'gt-delta',
|
|
382
|
+
positive: 'text-success',
|
|
383
|
+
negative: 'text-danger',
|
|
384
|
+
};
|
|
385
|
+
this.key = 'value';
|
|
386
|
+
this.notApplicableValue = 'n/a';
|
|
387
|
+
this.initialValue = '-';
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
GtDeltaComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: GtDeltaComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
391
|
+
GtDeltaComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.1", type: GtDeltaComponent, selector: "gt-delta", inputs: { data: "data", index: "index", baseIndex: "baseIndex", classes: "classes", key: "key", notApplicableValue: "notApplicableValue", initialValue: "initialValue" }, ngImport: i0, template: `<span
|
|
392
|
+
*ngIf="{
|
|
393
|
+
value:
|
|
394
|
+
index === 0
|
|
395
|
+
? initialValue
|
|
396
|
+
: ((baseIndex === undefined
|
|
397
|
+
? data[index - 1][key]
|
|
398
|
+
: data[baseIndex][key]) -
|
|
399
|
+
data[index][key]) /
|
|
400
|
+
-Math.abs(
|
|
401
|
+
baseIndex === undefined
|
|
402
|
+
? data[index - 1][key]
|
|
403
|
+
: data[baseIndex][key]
|
|
404
|
+
)
|
|
405
|
+
} as delta"
|
|
406
|
+
[class]="[
|
|
407
|
+
classes.span,
|
|
408
|
+
!delta.value || !Number.isFinite(delta.value)
|
|
409
|
+
? null
|
|
410
|
+
: delta.value > 0
|
|
411
|
+
? classes.positive
|
|
412
|
+
: classes.negative
|
|
413
|
+
]"
|
|
414
|
+
[class.gt-delta-positive]="delta.value > 0 && Number.isFinite(delta.value)"
|
|
415
|
+
[class.gt-delta-negative]="delta.value < 0"
|
|
416
|
+
>{{
|
|
417
|
+
Number.isFinite(delta.value)
|
|
418
|
+
? (delta.value | percent)
|
|
419
|
+
: delta.value === initialValue
|
|
420
|
+
? initialValue
|
|
421
|
+
: notApplicableValue
|
|
422
|
+
}}</span
|
|
423
|
+
>`, isInline: true, styles: [":host{display:inline-block}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i1.PercentPipe, name: "percent" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
424
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: GtDeltaComponent, decorators: [{
|
|
425
|
+
type: Component,
|
|
426
|
+
args: [{ selector: 'gt-delta', template: `<span
|
|
427
|
+
*ngIf="{
|
|
428
|
+
value:
|
|
429
|
+
index === 0
|
|
430
|
+
? initialValue
|
|
431
|
+
: ((baseIndex === undefined
|
|
432
|
+
? data[index - 1][key]
|
|
433
|
+
: data[baseIndex][key]) -
|
|
434
|
+
data[index][key]) /
|
|
435
|
+
-Math.abs(
|
|
436
|
+
baseIndex === undefined
|
|
437
|
+
? data[index - 1][key]
|
|
438
|
+
: data[baseIndex][key]
|
|
439
|
+
)
|
|
440
|
+
} as delta"
|
|
441
|
+
[class]="[
|
|
442
|
+
classes.span,
|
|
443
|
+
!delta.value || !Number.isFinite(delta.value)
|
|
444
|
+
? null
|
|
445
|
+
: delta.value > 0
|
|
446
|
+
? classes.positive
|
|
447
|
+
: classes.negative
|
|
448
|
+
]"
|
|
449
|
+
[class.gt-delta-positive]="delta.value > 0 && Number.isFinite(delta.value)"
|
|
450
|
+
[class.gt-delta-negative]="delta.value < 0"
|
|
451
|
+
>{{
|
|
452
|
+
Number.isFinite(delta.value)
|
|
453
|
+
? (delta.value | percent)
|
|
454
|
+
: delta.value === initialValue
|
|
455
|
+
? initialValue
|
|
456
|
+
: notApplicableValue
|
|
457
|
+
}}</span
|
|
458
|
+
>`, changeDetection: ChangeDetectionStrategy.OnPush, styles: [":host{display:inline-block}\n"] }]
|
|
459
|
+
}], ctorParameters: function () { return []; }, propDecorators: { data: [{
|
|
460
|
+
type: Input
|
|
461
|
+
}], index: [{
|
|
462
|
+
type: Input
|
|
463
|
+
}], baseIndex: [{
|
|
464
|
+
type: Input
|
|
465
|
+
}], classes: [{
|
|
466
|
+
type: Input
|
|
467
|
+
}], key: [{
|
|
468
|
+
type: Input
|
|
469
|
+
}], notApplicableValue: [{
|
|
470
|
+
type: Input
|
|
471
|
+
}], initialValue: [{
|
|
472
|
+
type: Input
|
|
284
473
|
}] } });
|
|
285
474
|
|
|
286
475
|
class GenericTableCoreModule {
|
|
287
476
|
}
|
|
288
|
-
GenericTableCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
289
|
-
GenericTableCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "
|
|
290
|
-
|
|
291
|
-
|
|
477
|
+
GenericTableCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: GenericTableCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
478
|
+
GenericTableCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.1", ngImport: i0, type: GenericTableCoreModule, declarations: [CoreComponent,
|
|
479
|
+
SortClassPipe,
|
|
480
|
+
DashCasePipe,
|
|
481
|
+
HighlightPipe,
|
|
482
|
+
CapitalCasePipe,
|
|
483
|
+
CapitalCasePipe,
|
|
484
|
+
DynamicPipe,
|
|
485
|
+
GtDeltaComponent], imports: [CommonModule], exports: [CoreComponent, GtDeltaComponent] });
|
|
486
|
+
GenericTableCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: GenericTableCoreModule, imports: [CommonModule] });
|
|
487
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: GenericTableCoreModule, decorators: [{
|
|
292
488
|
type: NgModule,
|
|
293
489
|
args: [{
|
|
294
|
-
declarations: [
|
|
490
|
+
declarations: [
|
|
491
|
+
CoreComponent,
|
|
492
|
+
SortClassPipe,
|
|
493
|
+
DashCasePipe,
|
|
494
|
+
HighlightPipe,
|
|
495
|
+
CapitalCasePipe,
|
|
496
|
+
CapitalCasePipe,
|
|
497
|
+
DynamicPipe,
|
|
498
|
+
GtDeltaComponent,
|
|
499
|
+
],
|
|
295
500
|
imports: [CommonModule],
|
|
296
|
-
exports: [CoreComponent],
|
|
501
|
+
exports: [CoreComponent, GtDeltaComponent],
|
|
297
502
|
}]
|
|
298
503
|
}] });
|
|
299
504
|
|
|
300
505
|
class PaginationComponent {
|
|
301
506
|
constructor() {
|
|
302
507
|
this.table$ = new ReplaySubject(1);
|
|
508
|
+
this._ariaLabels = {
|
|
509
|
+
nav: 'Table pagination',
|
|
510
|
+
button: 'Go to page ',
|
|
511
|
+
};
|
|
512
|
+
this._classes = {
|
|
513
|
+
ul: 'pagination',
|
|
514
|
+
li: 'page-item',
|
|
515
|
+
button: 'page-link',
|
|
516
|
+
};
|
|
517
|
+
this._paginationLength = 5;
|
|
303
518
|
this.pagination$ = this.table$.pipe(switchMap((core) => combineLatest([core?.table$.pipe(pluck('info')), core?.currentPage$])), map(([info, currentPage]) => this.generateList(info.pageTotal, currentPage)));
|
|
304
519
|
}
|
|
520
|
+
get paginationLength() {
|
|
521
|
+
return this._paginationLength;
|
|
522
|
+
}
|
|
523
|
+
set paginationLength(value) {
|
|
524
|
+
this._paginationLength = +value;
|
|
525
|
+
}
|
|
526
|
+
get classes() {
|
|
527
|
+
return this._classes;
|
|
528
|
+
}
|
|
529
|
+
set classes(value) {
|
|
530
|
+
this._classes = value;
|
|
531
|
+
}
|
|
532
|
+
get ariaLabels() {
|
|
533
|
+
return this._ariaLabels;
|
|
534
|
+
}
|
|
535
|
+
set ariaLabels(value) {
|
|
536
|
+
this._ariaLabels = value;
|
|
537
|
+
}
|
|
305
538
|
get table() {
|
|
306
539
|
return this._table;
|
|
307
540
|
}
|
|
@@ -310,14 +543,13 @@ class PaginationComponent {
|
|
|
310
543
|
this.table$.next(value);
|
|
311
544
|
}
|
|
312
545
|
generateList(pages, currentPosition) {
|
|
313
|
-
const
|
|
314
|
-
const
|
|
315
|
-
const length = pages < paginationLength ? pages : paginationLength;
|
|
546
|
+
const middle = Math.floor(this.paginationLength / 2);
|
|
547
|
+
const length = pages < this.paginationLength ? pages : this.paginationLength;
|
|
316
548
|
return Array.from({ length }, (_, i) => {
|
|
317
549
|
if (i === 0) {
|
|
318
550
|
return 1;
|
|
319
551
|
}
|
|
320
|
-
else if (pages < paginationLength) {
|
|
552
|
+
else if (pages < this.paginationLength) {
|
|
321
553
|
return i + 1;
|
|
322
554
|
}
|
|
323
555
|
else if (i + 1 === length) {
|
|
@@ -326,10 +558,12 @@ class PaginationComponent {
|
|
|
326
558
|
else if (currentPosition > middle && currentPosition < pages - middle) {
|
|
327
559
|
return i + currentPosition - (middle - 1);
|
|
328
560
|
}
|
|
329
|
-
else if (currentPosition > middle &&
|
|
561
|
+
else if (currentPosition > middle &&
|
|
562
|
+
currentPosition < pages - (middle - 1)) {
|
|
330
563
|
return i + currentPosition - middle;
|
|
331
564
|
}
|
|
332
|
-
else if (currentPosition > middle &&
|
|
565
|
+
else if (currentPosition > middle &&
|
|
566
|
+
currentPosition === pages - (middle - 1)) {
|
|
333
567
|
return i + currentPosition - (middle + 1);
|
|
334
568
|
}
|
|
335
569
|
else if (currentPosition > middle && currentPosition === pages - 1) {
|
|
@@ -346,21 +580,27 @@ class PaginationComponent {
|
|
|
346
580
|
}
|
|
347
581
|
}
|
|
348
582
|
}
|
|
349
|
-
PaginationComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
350
|
-
PaginationComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "
|
|
351
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
583
|
+
PaginationComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: PaginationComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
584
|
+
PaginationComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.1", type: PaginationComponent, selector: "angular-generic-table-pagination", inputs: { paginationLength: "paginationLength", classes: "classes", ariaLabels: "ariaLabels", table: "table" }, ngImport: i0, template: "<ng-container\n *ngIf=\"{\n links: pagination$ | async,\n currentPosition: table?.currentPage$ | async\n } as pagination\"\n>\n <nav\n *ngIf=\"pagination.links && pagination.links.length > 1\"\n role=\"navigation\"\n [attr.aria-label]=\"ariaLabels?.nav\"\n class=\"gt-pagination\"\n [class]=\"classes?.nav\"\n >\n <ul [class]=\"classes?.ul\">\n <ng-container\n *ngFor=\"\n let position of pagination!.links;\n let i = index;\n let last = last\n \"\n >\n <li\n [class]=\"classes?.li\"\n [class.active]=\"position === (pagination!.currentPosition || 0) + 1\"\n >\n <button\n [class]=\"classes?.button\"\n [attr.aria-label]=\"ariaLabels.button + position\"\n (click)=\"goto(position)\"\n >\n {{ position }}\n </button>\n </li>\n <li\n [class]=\"classes?.li\"\n class=\"gt-ellipsis\"\n *ngIf=\"position + 1 !== pagination!.links![i + 1] && !last\"\n >\n <button [class]=\"classes?.button\" disabled tabindex=\"-1\"></button>\n </li>\n </ng-container>\n </ul>\n </nav>\n</ng-container>\n", 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: "pipe", type: i1.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
585
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: PaginationComponent, decorators: [{
|
|
352
586
|
type: Component,
|
|
353
|
-
args: [{ selector: 'angular-generic-table-pagination', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container
|
|
354
|
-
}], propDecorators: {
|
|
587
|
+
args: [{ selector: 'angular-generic-table-pagination', changeDetection: ChangeDetectionStrategy.OnPush, template: "<ng-container\n *ngIf=\"{\n links: pagination$ | async,\n currentPosition: table?.currentPage$ | async\n } as pagination\"\n>\n <nav\n *ngIf=\"pagination.links && pagination.links.length > 1\"\n role=\"navigation\"\n [attr.aria-label]=\"ariaLabels?.nav\"\n class=\"gt-pagination\"\n [class]=\"classes?.nav\"\n >\n <ul [class]=\"classes?.ul\">\n <ng-container\n *ngFor=\"\n let position of pagination!.links;\n let i = index;\n let last = last\n \"\n >\n <li\n [class]=\"classes?.li\"\n [class.active]=\"position === (pagination!.currentPosition || 0) + 1\"\n >\n <button\n [class]=\"classes?.button\"\n [attr.aria-label]=\"ariaLabels.button + position\"\n (click)=\"goto(position)\"\n >\n {{ position }}\n </button>\n </li>\n <li\n [class]=\"classes?.li\"\n class=\"gt-ellipsis\"\n *ngIf=\"position + 1 !== pagination!.links![i + 1] && !last\"\n >\n <button [class]=\"classes?.button\" disabled tabindex=\"-1\"></button>\n </li>\n </ng-container>\n </ul>\n </nav>\n</ng-container>\n" }]
|
|
588
|
+
}], propDecorators: { paginationLength: [{
|
|
589
|
+
type: Input
|
|
590
|
+
}], classes: [{
|
|
591
|
+
type: Input
|
|
592
|
+
}], ariaLabels: [{
|
|
593
|
+
type: Input
|
|
594
|
+
}], table: [{
|
|
355
595
|
type: Input
|
|
356
596
|
}] } });
|
|
357
597
|
|
|
358
598
|
class GenericTablePaginationModule {
|
|
359
599
|
}
|
|
360
|
-
GenericTablePaginationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
361
|
-
GenericTablePaginationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "
|
|
362
|
-
GenericTablePaginationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
363
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
600
|
+
GenericTablePaginationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: GenericTablePaginationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
601
|
+
GenericTablePaginationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.1.1", ngImport: i0, type: GenericTablePaginationModule, declarations: [PaginationComponent], imports: [CommonModule], exports: [PaginationComponent] });
|
|
602
|
+
GenericTablePaginationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: GenericTablePaginationModule, imports: [CommonModule] });
|
|
603
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.1", ngImport: i0, type: GenericTablePaginationModule, decorators: [{
|
|
364
604
|
type: NgModule,
|
|
365
605
|
args: [{
|
|
366
606
|
declarations: [PaginationComponent],
|
|
@@ -377,5 +617,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImpor
|
|
|
377
617
|
* Generated bundle index. Do not edit.
|
|
378
618
|
*/
|
|
379
619
|
|
|
380
|
-
export { CoreComponent, CoreService, GenericTableCoreModule, GenericTablePaginationModule, PaginationComponent };
|
|
620
|
+
export { CoreComponent, CoreService, GenericTableCoreModule, GenericTablePaginationModule, GtDeltaComponent, PaginationComponent };
|
|
381
621
|
//# sourceMappingURL=angular-generic-table-core.mjs.map
|