@3kles/kles-material-table-v2 21.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.
|
@@ -0,0 +1,3751 @@
|
|
|
1
|
+
import * as i15 from '@angular/common';
|
|
2
|
+
import { CommonModule } from '@angular/common';
|
|
3
|
+
import * as i0 from '@angular/core';
|
|
4
|
+
import { Pipe, InjectionToken, Injectable, input, computed, HostBinding, Directive, inject, Inject, signal, DestroyRef, Component, Optional, EventEmitter, ViewChild, effect, Injector, Output, NgModule } from '@angular/core';
|
|
5
|
+
import * as i16 from '@angular/forms';
|
|
6
|
+
import { FormControl, FormGroup, FormArray, ReactiveFormsModule } from '@angular/forms';
|
|
7
|
+
import * as i2 from '@angular/material/button';
|
|
8
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
9
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
10
|
+
import * as i1 from '@angular/material/icon';
|
|
11
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
12
|
+
import { MatInputModule } from '@angular/material/input';
|
|
13
|
+
import * as i18 from '@angular/material/table';
|
|
14
|
+
import { MatTableDataSource, MatTableModule, MatTable } from '@angular/material/table';
|
|
15
|
+
import * as i19 from '@angular/cdk/table';
|
|
16
|
+
import { CdkTableModule } from '@angular/cdk/table';
|
|
17
|
+
import * as i20 from '@3kles/kles-material-dynamicforms';
|
|
18
|
+
import { componentMapper, klesFieldControlFactory, klesFieldUiFactory, GroupUiState, ArrayUiState, KlesMaterialDynamicformsModule } from '@3kles/kles-material-dynamicforms';
|
|
19
|
+
import * as i4 from '@angular/material/sort';
|
|
20
|
+
import { MatSortModule, MatSort } from '@angular/material/sort';
|
|
21
|
+
import * as i21 from '@angular/cdk/drag-drop';
|
|
22
|
+
import { DragDropModule } from '@angular/cdk/drag-drop';
|
|
23
|
+
import * as i22 from '@angular/material/progress-spinner';
|
|
24
|
+
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
25
|
+
import { Subject, BehaviorSubject, combineLatest, startWith, of, auditTime, switchMap, concat, catchError, map, filter, take, merge, debounceTime, distinctUntilChanged, scan, concatMap, shareReplay } from 'rxjs';
|
|
26
|
+
import { toObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
27
|
+
import * as _ from 'lodash';
|
|
28
|
+
import ___default from 'lodash';
|
|
29
|
+
import * as i3 from '@angular/material/tooltip';
|
|
30
|
+
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
31
|
+
import * as i2$1 from '@angular/material/paginator';
|
|
32
|
+
import { MatPaginatorModule, MatPaginator, MatPaginatorIntl } from '@angular/material/paginator';
|
|
33
|
+
import { ScrollingModule } from '@angular/cdk/scrolling';
|
|
34
|
+
|
|
35
|
+
class HeaderFieldPipe {
|
|
36
|
+
transform(col) {
|
|
37
|
+
if (!col)
|
|
38
|
+
return null;
|
|
39
|
+
return {
|
|
40
|
+
name: col.columnDef,
|
|
41
|
+
...col.headerCell.field,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: HeaderFieldPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
45
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.19", ngImport: i0, type: HeaderFieldPipe, isStandalone: true, name: "headerField" }); }
|
|
46
|
+
}
|
|
47
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: HeaderFieldPipe, decorators: [{
|
|
48
|
+
type: Pipe,
|
|
49
|
+
args: [{
|
|
50
|
+
name: 'headerField',
|
|
51
|
+
standalone: true,
|
|
52
|
+
}]
|
|
53
|
+
}] });
|
|
54
|
+
|
|
55
|
+
class CellFieldPipe {
|
|
56
|
+
transform(col) {
|
|
57
|
+
if (!col)
|
|
58
|
+
return null;
|
|
59
|
+
return { name: col.columnDef, canExpand: col.canExpand, ...col.cell.field };
|
|
60
|
+
}
|
|
61
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: CellFieldPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
62
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.19", ngImport: i0, type: CellFieldPipe, isStandalone: true, name: "cellField" }); }
|
|
63
|
+
}
|
|
64
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: CellFieldPipe, decorators: [{
|
|
65
|
+
type: Pipe,
|
|
66
|
+
args: [{
|
|
67
|
+
name: 'cellField',
|
|
68
|
+
standalone: true,
|
|
69
|
+
}]
|
|
70
|
+
}] });
|
|
71
|
+
class ExtraCellFieldPipe {
|
|
72
|
+
transform(col) {
|
|
73
|
+
if (!col)
|
|
74
|
+
return null;
|
|
75
|
+
return { name: col.columnDef, ...col.field };
|
|
76
|
+
}
|
|
77
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ExtraCellFieldPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
78
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.19", ngImport: i0, type: ExtraCellFieldPipe, isStandalone: true, name: "extraCellField" }); }
|
|
79
|
+
}
|
|
80
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ExtraCellFieldPipe, decorators: [{
|
|
81
|
+
type: Pipe,
|
|
82
|
+
args: [{
|
|
83
|
+
name: 'extraCellField',
|
|
84
|
+
standalone: true,
|
|
85
|
+
}]
|
|
86
|
+
}] });
|
|
87
|
+
|
|
88
|
+
const SELECTION_CONFIG = new InjectionToken('SELECTION_CONFIG');
|
|
89
|
+
const LOADER_CONFIG = new InjectionToken('LOADER_CONFIG');
|
|
90
|
+
const COLUMNS = new InjectionToken('COLUMNS');
|
|
91
|
+
const FOOTER = new InjectionToken('FOOTER');
|
|
92
|
+
const EXTRA_ROWS = new InjectionToken('EXTRA_ROWS');
|
|
93
|
+
const ROW_DRAG_DROP = new InjectionToken('ROW_DRAG_DROP');
|
|
94
|
+
const DRAG_DROP_CONFIG = new InjectionToken('DRAG_DROP_CONFIG');
|
|
95
|
+
// export const KLES_TABLE_SERVICE = new InjectionToken<KlesTableService>('KLES_TABLE_SERVICE');
|
|
96
|
+
const PAGINATOR_CONFIG = new InjectionToken('PAGINATOR_CONFIG');
|
|
97
|
+
const SORT_CONFIG = new InjectionToken('SORT_CONFIG');
|
|
98
|
+
const HEADER_SERVICE = new InjectionToken('HEADER_SERVICE');
|
|
99
|
+
const LOADER_SERVICE = new InjectionToken('LOADER_SERVICE');
|
|
100
|
+
const LINES_SERVICE = new InjectionToken('LINES_SERVICE');
|
|
101
|
+
const DATASOURCE_SERVICE = new InjectionToken('DATASOURCE_SERVICE');
|
|
102
|
+
const SELECTION_SERVICE = new InjectionToken('SELECTION_SERVICE');
|
|
103
|
+
const SORT_SERVICE = new InjectionToken('SORT_SERVICE');
|
|
104
|
+
const SCROLLBAR_ORCHESTRATOR_SERVICE = new InjectionToken('SCROLLBAR_ORCHESTRATOR_SERVICE');
|
|
105
|
+
const TABLE_SERVICE = new InjectionToken('TABLE_SERVICE');
|
|
106
|
+
|
|
107
|
+
class ResolveNgStylePipe {
|
|
108
|
+
transform(style, value, status, row, rowStatus) {
|
|
109
|
+
if (!style)
|
|
110
|
+
return {};
|
|
111
|
+
return typeof style === 'function' ? style(value, status, row, rowStatus) : style;
|
|
112
|
+
}
|
|
113
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ResolveNgStylePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
114
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.19", ngImport: i0, type: ResolveNgStylePipe, isStandalone: true, name: "resolveNgStyle" }); }
|
|
115
|
+
}
|
|
116
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ResolveNgStylePipe, decorators: [{
|
|
117
|
+
type: Pipe,
|
|
118
|
+
args: [{
|
|
119
|
+
name: 'resolveNgStyle',
|
|
120
|
+
standalone: true,
|
|
121
|
+
}]
|
|
122
|
+
}] });
|
|
123
|
+
|
|
124
|
+
class EventsService {
|
|
125
|
+
constructor() {
|
|
126
|
+
this.eventsSubject = new Subject();
|
|
127
|
+
this.events$ = this.eventsSubject.asObservable();
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Émet un event typé.
|
|
131
|
+
*
|
|
132
|
+
* Si l'event a un payload, TypeScript t'oblige à le fournir.
|
|
133
|
+
* Si l'event est void, TypeScript t'empêche de fournir un payload.
|
|
134
|
+
*/
|
|
135
|
+
emit(type, ...args) {
|
|
136
|
+
const payload = args[0];
|
|
137
|
+
const event = payload === undefined ? { type } : { type, payload };
|
|
138
|
+
this.eventsSubject.next(event);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Émet directement un event complet.
|
|
142
|
+
* Pratique si tu construis déjà l'objet ailleurs.
|
|
143
|
+
*/
|
|
144
|
+
emitEvent(event) {
|
|
145
|
+
this.eventsSubject.next(event);
|
|
146
|
+
}
|
|
147
|
+
complete() {
|
|
148
|
+
this.eventsSubject.complete();
|
|
149
|
+
}
|
|
150
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: EventsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
151
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: EventsService }); }
|
|
152
|
+
}
|
|
153
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: EventsService, decorators: [{
|
|
154
|
+
type: Injectable
|
|
155
|
+
}] });
|
|
156
|
+
|
|
157
|
+
class ResizableColumnDirective {
|
|
158
|
+
get appResizableColumnAttr() {
|
|
159
|
+
return this.column().columnDef;
|
|
160
|
+
}
|
|
161
|
+
constructor(el, renderer, zone, eventsService) {
|
|
162
|
+
this.el = el;
|
|
163
|
+
this.renderer = renderer;
|
|
164
|
+
this.zone = zone;
|
|
165
|
+
this.eventsService = eventsService;
|
|
166
|
+
this.column = input.required({ ...(ngDevMode ? { debugName: "column" } : /* istanbul ignore next */ {}), alias: 'appResizableColumn' });
|
|
167
|
+
this.minWidth = computed(() => {
|
|
168
|
+
return 60; //TODO trouver une solution pour ne plus avoir une valeur en dur
|
|
169
|
+
}, ...(ngDevMode ? [{ debugName: "minWidth" }] : /* istanbul ignore next */ []));
|
|
170
|
+
this.maxWidth = computed(() => {
|
|
171
|
+
return 800; //TODO trouver une solution pour ne plus avoir une valeur en dur
|
|
172
|
+
}, ...(ngDevMode ? [{ debugName: "maxWidth" }] : /* istanbul ignore next */ []));
|
|
173
|
+
this.startX = 0;
|
|
174
|
+
this.startWidth = 0;
|
|
175
|
+
this.currentWidth = 0;
|
|
176
|
+
}
|
|
177
|
+
ngOnInit() {
|
|
178
|
+
if (this.column().resizable) {
|
|
179
|
+
this.apply();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
ngOnChanges(changes) {
|
|
183
|
+
if (!changes.column.isFirstChange()) {
|
|
184
|
+
if (changes.column.previousValue.resizable !== changes.column.currentValue.resizable) {
|
|
185
|
+
if (changes.column.currentValue.resizable) {
|
|
186
|
+
this.apply();
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
this.remove();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
onDown(e) {
|
|
195
|
+
e.preventDefault();
|
|
196
|
+
this.startResize(e.clientX);
|
|
197
|
+
}
|
|
198
|
+
onTouchDown(e) {
|
|
199
|
+
if (!e.touches?.length)
|
|
200
|
+
return;
|
|
201
|
+
e.preventDefault();
|
|
202
|
+
this.startResize(e.touches[0].clientX);
|
|
203
|
+
}
|
|
204
|
+
startResize(clientX) {
|
|
205
|
+
const th = this.el.nativeElement;
|
|
206
|
+
this.startX = clientX;
|
|
207
|
+
this.startWidth = th.getBoundingClientRect().width;
|
|
208
|
+
this.currentWidth = this.startWidth;
|
|
209
|
+
this.zone.run(() => {
|
|
210
|
+
this.eventsService.emit('columnResizeStart', {
|
|
211
|
+
columnDef: this.column().columnDef,
|
|
212
|
+
width: this.startWidth,
|
|
213
|
+
previousWidth: this.startWidth,
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
this.zone.runOutsideAngular(() => {
|
|
217
|
+
const doc = th.ownerDocument;
|
|
218
|
+
const onMove = (ev) => {
|
|
219
|
+
const x = ev instanceof MouseEvent ? ev.clientX : (ev.touches?.[0]?.clientX ?? this.startX);
|
|
220
|
+
const delta = x - this.startX;
|
|
221
|
+
const next = Math.min(this.maxWidth(), Math.max(this.minWidth(), this.startWidth + delta));
|
|
222
|
+
if (next === this.currentWidth) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
const previousWidth = this.currentWidth;
|
|
226
|
+
this.currentWidth = next;
|
|
227
|
+
this.applyWidth(next);
|
|
228
|
+
this.eventsService.emit('columnResize', {
|
|
229
|
+
columnDef: this.column().columnDef,
|
|
230
|
+
width: next,
|
|
231
|
+
previousWidth,
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
const onUp = () => this.stopResize();
|
|
235
|
+
this.cleanupMove = this.renderer.listen(doc, 'mousemove', onMove);
|
|
236
|
+
this.renderer.listen(doc, 'touchmove', onMove);
|
|
237
|
+
this.cleanupUp = this.renderer.listen(doc, 'mouseup', onUp);
|
|
238
|
+
this.renderer.listen(doc, 'touchend', onUp);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
stopResize() {
|
|
242
|
+
this.cleanupMove?.();
|
|
243
|
+
this.cleanupUp?.();
|
|
244
|
+
this.cleanupMove = undefined;
|
|
245
|
+
this.cleanupUp = undefined;
|
|
246
|
+
if (this.currentWidth > 0) {
|
|
247
|
+
this.zone.run(() => {
|
|
248
|
+
this.eventsService.emit('columnResizeEnd', {
|
|
249
|
+
columnDef: this.column().columnDef,
|
|
250
|
+
width: this.currentWidth,
|
|
251
|
+
previousWidth: this.startWidth,
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
applyWidth(px) {
|
|
257
|
+
const root = this.el.nativeElement.closest('table, mat-table, cdk-table');
|
|
258
|
+
if (!root)
|
|
259
|
+
return;
|
|
260
|
+
const selectors = [`.mat-column-${this.column().columnDef}`, `.cdk-column-${this.column().columnDef}`];
|
|
261
|
+
const cells = root.querySelectorAll(selectors.join(','));
|
|
262
|
+
for (const cell of Array.from(cells)) {
|
|
263
|
+
// table natif
|
|
264
|
+
cell.style.width = `${px}px`;
|
|
265
|
+
cell.style.minWidth = `${px}px`;
|
|
266
|
+
cell.style.maxWidth = `${px}px`;
|
|
267
|
+
// mode flex
|
|
268
|
+
cell.style.flex = `0 0 ${px}px`;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
apply() {
|
|
272
|
+
this.remove();
|
|
273
|
+
this.child = this.renderer.createElement('span');
|
|
274
|
+
this.renderer.addClass(this.child, 'resize-handle');
|
|
275
|
+
this.renderer.appendChild(this.el.nativeElement, this.child);
|
|
276
|
+
this.renderer.listen(this.child, 'mousedown', (e) => this.onDown(e));
|
|
277
|
+
this.renderer.listen(this.child, 'touchstart', (e) => this.onTouchDown(e));
|
|
278
|
+
}
|
|
279
|
+
remove() {
|
|
280
|
+
if (this.child) {
|
|
281
|
+
this.renderer.removeChild(this.el.nativeElement, this.child);
|
|
282
|
+
this.child = undefined;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
ngOnDestroy() {
|
|
286
|
+
this.stopResize();
|
|
287
|
+
}
|
|
288
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ResizableColumnDirective, deps: [{ token: i0.ElementRef }, { token: i0.Renderer2 }, { token: i0.NgZone }, { token: EventsService }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
289
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.19", type: ResizableColumnDirective, isStandalone: true, selector: "th[appResizableColumn]", inputs: { column: { classPropertyName: "column", publicName: "appResizableColumn", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "attr.appResizableColumn": "this.appResizableColumnAttr" } }, usesOnChanges: true, ngImport: i0 }); }
|
|
290
|
+
}
|
|
291
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ResizableColumnDirective, decorators: [{
|
|
292
|
+
type: Directive,
|
|
293
|
+
args: [{
|
|
294
|
+
selector: 'th[appResizableColumn]',
|
|
295
|
+
standalone: true,
|
|
296
|
+
}]
|
|
297
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }, { type: i0.NgZone }, { type: EventsService }], propDecorators: { column: [{ type: i0.Input, args: [{ isSignal: true, alias: "appResizableColumn", required: true }] }], appResizableColumnAttr: [{
|
|
298
|
+
type: HostBinding,
|
|
299
|
+
args: ['attr.appResizableColumn']
|
|
300
|
+
}] } });
|
|
301
|
+
|
|
302
|
+
class FooterFieldPipe {
|
|
303
|
+
transform(col) {
|
|
304
|
+
if (!col)
|
|
305
|
+
return null;
|
|
306
|
+
return { name: col.columnDef, ...col.footerCell.field };
|
|
307
|
+
}
|
|
308
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: FooterFieldPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
309
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.19", ngImport: i0, type: FooterFieldPipe, isStandalone: true, name: "footerField" }); }
|
|
310
|
+
}
|
|
311
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: FooterFieldPipe, decorators: [{
|
|
312
|
+
type: Pipe,
|
|
313
|
+
args: [{
|
|
314
|
+
name: 'footerField',
|
|
315
|
+
standalone: true,
|
|
316
|
+
}]
|
|
317
|
+
}] });
|
|
318
|
+
|
|
319
|
+
class UiFieldPipe {
|
|
320
|
+
constructor() {
|
|
321
|
+
this.tableService = inject(TABLE_SERVICE);
|
|
322
|
+
}
|
|
323
|
+
transform(control) {
|
|
324
|
+
if (!control)
|
|
325
|
+
return undefined;
|
|
326
|
+
return this.tableService?.klesForm.uiStore.get(control);
|
|
327
|
+
}
|
|
328
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: UiFieldPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
329
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.19", ngImport: i0, type: UiFieldPipe, isStandalone: true, name: "uiField" }); }
|
|
330
|
+
}
|
|
331
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: UiFieldPipe, decorators: [{
|
|
332
|
+
type: Pipe,
|
|
333
|
+
args: [{
|
|
334
|
+
name: 'uiField',
|
|
335
|
+
standalone: true,
|
|
336
|
+
}]
|
|
337
|
+
}] });
|
|
338
|
+
|
|
339
|
+
var Span;
|
|
340
|
+
(function (Span) {
|
|
341
|
+
Span["MAX"] = "max";
|
|
342
|
+
})(Span || (Span = {}));
|
|
343
|
+
|
|
344
|
+
class SpanPipe {
|
|
345
|
+
transform(span, maxSize) {
|
|
346
|
+
if (span === Span.MAX) {
|
|
347
|
+
return maxSize;
|
|
348
|
+
}
|
|
349
|
+
return span;
|
|
350
|
+
}
|
|
351
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SpanPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
352
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.19", ngImport: i0, type: SpanPipe, isStandalone: true, name: "spanPipe" }); }
|
|
353
|
+
}
|
|
354
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SpanPipe, decorators: [{
|
|
355
|
+
type: Pipe,
|
|
356
|
+
args: [{
|
|
357
|
+
name: 'spanPipe',
|
|
358
|
+
standalone: true,
|
|
359
|
+
}]
|
|
360
|
+
}] });
|
|
361
|
+
|
|
362
|
+
class ExpandedRowStore {
|
|
363
|
+
constructor() {
|
|
364
|
+
this._expandedIds$ = new BehaviorSubject(new Set());
|
|
365
|
+
this.expandedIds$ = this._expandedIds$.asObservable();
|
|
366
|
+
}
|
|
367
|
+
reset() {
|
|
368
|
+
this._expandedIds$.next(new Set());
|
|
369
|
+
}
|
|
370
|
+
isExpanded(id) {
|
|
371
|
+
return this._expandedIds$.value.has(id);
|
|
372
|
+
}
|
|
373
|
+
get expandedIds() {
|
|
374
|
+
return this._expandedIds$.value;
|
|
375
|
+
}
|
|
376
|
+
expand(id) {
|
|
377
|
+
const next = new Set(this._expandedIds$.value);
|
|
378
|
+
next.add(id);
|
|
379
|
+
this._expandedIds$.next(next);
|
|
380
|
+
}
|
|
381
|
+
collapse(id) {
|
|
382
|
+
const next = new Set(this._expandedIds$.value);
|
|
383
|
+
next.delete(id);
|
|
384
|
+
this._expandedIds$.next(next);
|
|
385
|
+
}
|
|
386
|
+
toggle(id) {
|
|
387
|
+
const next = new Set(this._expandedIds$.value);
|
|
388
|
+
next.has(id) ? next.delete(id) : next.add(id);
|
|
389
|
+
this._expandedIds$.next(next);
|
|
390
|
+
}
|
|
391
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ExpandedRowStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
392
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ExpandedRowStore }); }
|
|
393
|
+
}
|
|
394
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ExpandedRowStore, decorators: [{
|
|
395
|
+
type: Injectable
|
|
396
|
+
}] });
|
|
397
|
+
|
|
398
|
+
class LoaderChildrensService {
|
|
399
|
+
constructor(loaderConfig) {
|
|
400
|
+
this.loaderConfig = loaderConfig;
|
|
401
|
+
this._refresh$ = new Subject();
|
|
402
|
+
}
|
|
403
|
+
load(parent, depth) {
|
|
404
|
+
const linesLoader = this.loaderConfig.lines;
|
|
405
|
+
return combineLatest([this._refresh$.pipe(startWith(void 0)), linesLoader.params?.() || of({})]).pipe(auditTime(0), switchMap(([_, params]) => {
|
|
406
|
+
return concat(of({ loading: true, total: 0, items: [] }), (linesLoader.childrens?.(params, parent, depth) ?? of({ items: [] })).pipe(catchError((err) => {
|
|
407
|
+
return of({ error: err, items: [] });
|
|
408
|
+
}), map((response) => {
|
|
409
|
+
return { ...response, loading: false, total: response?.items.length || 0 };
|
|
410
|
+
})));
|
|
411
|
+
}));
|
|
412
|
+
}
|
|
413
|
+
refresh() {
|
|
414
|
+
this._refresh$.next();
|
|
415
|
+
}
|
|
416
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LoaderChildrensService, deps: [{ token: LOADER_CONFIG }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
417
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LoaderChildrensService }); }
|
|
418
|
+
}
|
|
419
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LoaderChildrensService, decorators: [{
|
|
420
|
+
type: Injectable
|
|
421
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
422
|
+
type: Inject,
|
|
423
|
+
args: [LOADER_CONFIG]
|
|
424
|
+
}] }] });
|
|
425
|
+
|
|
426
|
+
class LoadingService {
|
|
427
|
+
constructor() {
|
|
428
|
+
this._loading = signal(false, ...(ngDevMode ? [{ debugName: "_loading" }] : /* istanbul ignore next */ []));
|
|
429
|
+
}
|
|
430
|
+
get loading() {
|
|
431
|
+
return this._loading.asReadonly();
|
|
432
|
+
}
|
|
433
|
+
start() {
|
|
434
|
+
this._loading.set(true);
|
|
435
|
+
}
|
|
436
|
+
stop() {
|
|
437
|
+
this._loading.set(false);
|
|
438
|
+
}
|
|
439
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LoadingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
440
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LoadingService }); }
|
|
441
|
+
}
|
|
442
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LoadingService, decorators: [{
|
|
443
|
+
type: Injectable
|
|
444
|
+
}] });
|
|
445
|
+
|
|
446
|
+
class ColumnsService {
|
|
447
|
+
constructor(_columns, eventsService) {
|
|
448
|
+
this._columns = _columns;
|
|
449
|
+
this.eventsService = eventsService;
|
|
450
|
+
}
|
|
451
|
+
register() {
|
|
452
|
+
this.setDisplayedColumns();
|
|
453
|
+
}
|
|
454
|
+
get columns() {
|
|
455
|
+
return this._columns.asReadonly();
|
|
456
|
+
}
|
|
457
|
+
getVisible() {
|
|
458
|
+
return this.columns()
|
|
459
|
+
.filter((column) => column.visible !== false)
|
|
460
|
+
.map((column) => column.columnDef);
|
|
461
|
+
}
|
|
462
|
+
setVisible(columnDef, visible) {
|
|
463
|
+
this.updateColumn(columnDef, { visible });
|
|
464
|
+
this.eventsService.emit('columnVisibilityChange', {
|
|
465
|
+
columnDef,
|
|
466
|
+
columns: this.getVisible(),
|
|
467
|
+
visible,
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
toggleVisible(columnDef) {
|
|
471
|
+
const visible = this._columns().find((col) => col.columnDef === columnDef)?.visible;
|
|
472
|
+
this.setVisible(columnDef, visible === undefined ? false : !visible);
|
|
473
|
+
}
|
|
474
|
+
changeWidth(columnDef, options) {
|
|
475
|
+
this.updateColumn(columnDef, {
|
|
476
|
+
...(options.width && { width: options.width }),
|
|
477
|
+
...(options.maxWidth && { maxWidth: options.maxWidth }),
|
|
478
|
+
...(options.minWidth && { minWidth: options.minWidth }),
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
setResizable(columnDef, resizable) {
|
|
482
|
+
this.updateColumn(columnDef, { resizable });
|
|
483
|
+
}
|
|
484
|
+
toggleResizable(columnDef) {
|
|
485
|
+
const resizable = this._columns().find((col) => col.columnDef === columnDef)?.resizable;
|
|
486
|
+
this.setResizable(columnDef, resizable === undefined ? true : !resizable);
|
|
487
|
+
}
|
|
488
|
+
setSticky(columnDef, options) {
|
|
489
|
+
this.updateColumn(columnDef, {
|
|
490
|
+
...(options.sticky && { sticky: options.sticky }),
|
|
491
|
+
...(options.stickyEnd && { stickyEnd: options.stickyEnd }),
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
setColumnPosition(columnDef, position) {
|
|
495
|
+
const previousIndex = this._columns().findIndex((c) => c.columnDef === columnDef);
|
|
496
|
+
this._columns.update((columns) => {
|
|
497
|
+
if (previousIndex >= 0 && position >= 0 && previousIndex != position) {
|
|
498
|
+
const currentElement = columns.at(position);
|
|
499
|
+
const [val] = columns.splice(previousIndex, 1);
|
|
500
|
+
const newCurrentElementPosition = columns.findIndex((c) => c.columnDef === currentElement?.columnDef);
|
|
501
|
+
columns.splice(newCurrentElementPosition, 0, val);
|
|
502
|
+
return [...columns];
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
return columns;
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
this.eventsService.emit('columnOrderChange', {
|
|
509
|
+
previousIndex: previousIndex,
|
|
510
|
+
columns: this.getVisible(),
|
|
511
|
+
currentIndex: position,
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
updateColumn(columnDef, config) {
|
|
515
|
+
this._columns.update((columns) => columns.map((col) => col.columnDef === columnDef
|
|
516
|
+
? {
|
|
517
|
+
...col,
|
|
518
|
+
...config,
|
|
519
|
+
cell: config.cell ? { ...col.cell, ...config.cell } : col.cell,
|
|
520
|
+
headerCell: config.headerCell ? { ...col.headerCell, ...config.headerCell } : col.headerCell,
|
|
521
|
+
footerCell: config.footerCell ? { ...col.footerCell, ...config.footerCell } : col.footerCell,
|
|
522
|
+
}
|
|
523
|
+
: col));
|
|
524
|
+
}
|
|
525
|
+
setDisplayedColumns() {
|
|
526
|
+
this.displayedColumns = computed(() => {
|
|
527
|
+
return this._columns()
|
|
528
|
+
.filter((c) => {
|
|
529
|
+
if (c.visibleWhen !== undefined) {
|
|
530
|
+
return c.visibleWhen();
|
|
531
|
+
}
|
|
532
|
+
else if (c.visible !== undefined) {
|
|
533
|
+
return c.visible !== false;
|
|
534
|
+
}
|
|
535
|
+
return true;
|
|
536
|
+
})
|
|
537
|
+
.map((c) => c.columnDef);
|
|
538
|
+
}, ...(ngDevMode ? [{ debugName: "displayedColumns" }] : /* istanbul ignore next */ []));
|
|
539
|
+
}
|
|
540
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ColumnsService, deps: [{ token: COLUMNS }, { token: EventsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
541
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ColumnsService }); }
|
|
542
|
+
}
|
|
543
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ColumnsService, decorators: [{
|
|
544
|
+
type: Injectable
|
|
545
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
546
|
+
type: Inject,
|
|
547
|
+
args: [COLUMNS]
|
|
548
|
+
}] }, { type: EventsService }] });
|
|
549
|
+
|
|
550
|
+
class RowFormFactory {
|
|
551
|
+
createControl(field, value) {
|
|
552
|
+
let control;
|
|
553
|
+
let ui;
|
|
554
|
+
if (field.type) {
|
|
555
|
+
control =
|
|
556
|
+
componentMapper.find((c) => c.type === field.type)?.factory({ ...field, value }) || klesFieldControlFactory({ ...field, value });
|
|
557
|
+
ui = componentMapper.find((c) => c.type === field.type)?.ui?.({ ...field, value }) || klesFieldUiFactory({ ...field, value });
|
|
558
|
+
}
|
|
559
|
+
else {
|
|
560
|
+
control =
|
|
561
|
+
componentMapper.find((c) => c.component === field.component)?.factory({ ...field, value }) ||
|
|
562
|
+
klesFieldControlFactory({ ...field, value });
|
|
563
|
+
ui = componentMapper.find((c) => c.component === field.component)?.ui?.({ ...field, value }) || klesFieldUiFactory({ ...field, value });
|
|
564
|
+
}
|
|
565
|
+
return { control, ui };
|
|
566
|
+
}
|
|
567
|
+
createRow(fields, record, meta = { depth: 0, parentId: null }) {
|
|
568
|
+
const data = { _id: crypto.randomUUID(), ...record };
|
|
569
|
+
const controls = {
|
|
570
|
+
_id: new FormControl(data._id, { nonNullable: true }),
|
|
571
|
+
_depth: new FormControl(meta.depth),
|
|
572
|
+
_parentId: new FormControl(meta.parentId),
|
|
573
|
+
};
|
|
574
|
+
const uis = {};
|
|
575
|
+
for (const field of fields) {
|
|
576
|
+
const { control, ui } = this.createControl(field, data?.[field.name] ?? undefined);
|
|
577
|
+
controls[field.name] = control;
|
|
578
|
+
uis[field.name] = ui;
|
|
579
|
+
}
|
|
580
|
+
return { formGroup: new FormGroup(controls), groupUi: new GroupUiState(uis) };
|
|
581
|
+
}
|
|
582
|
+
createRows(fields, records, meta = { depth: 0, parentId: null }) {
|
|
583
|
+
return records.map((r) => this.createRow(fields, r, meta));
|
|
584
|
+
}
|
|
585
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: RowFormFactory, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
586
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: RowFormFactory, providedIn: 'root' }); }
|
|
587
|
+
}
|
|
588
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: RowFormFactory, decorators: [{
|
|
589
|
+
type: Injectable,
|
|
590
|
+
args: [{ providedIn: 'root' }]
|
|
591
|
+
}] });
|
|
592
|
+
|
|
593
|
+
class KlesForm {
|
|
594
|
+
constructor(columnsService, rowFactory) {
|
|
595
|
+
this.columnsService = columnsService;
|
|
596
|
+
this.rowFactory = rowFactory;
|
|
597
|
+
this.form = new FormGroup({
|
|
598
|
+
header: new FormGroup({}),
|
|
599
|
+
rows: new FormArray([]),
|
|
600
|
+
footer: new FormGroup({}),
|
|
601
|
+
});
|
|
602
|
+
this.ui = new GroupUiState({
|
|
603
|
+
header: new GroupUiState({}),
|
|
604
|
+
rows: new ArrayUiState([]),
|
|
605
|
+
footer: new GroupUiState({}),
|
|
606
|
+
});
|
|
607
|
+
this.uiStore = new WeakMap();
|
|
608
|
+
this.rowsStructureChangedSubject = new Subject();
|
|
609
|
+
this.rowsStructureChanged$ = this.rowsStructureChangedSubject.asObservable();
|
|
610
|
+
}
|
|
611
|
+
getRows() {
|
|
612
|
+
return this.form.get('rows');
|
|
613
|
+
}
|
|
614
|
+
getUiRows() {
|
|
615
|
+
return this.ui.get('rows');
|
|
616
|
+
}
|
|
617
|
+
getUiHeader() {
|
|
618
|
+
return this.ui.get('header');
|
|
619
|
+
}
|
|
620
|
+
getUiFooter() {
|
|
621
|
+
return this.ui.get('footer');
|
|
622
|
+
}
|
|
623
|
+
getHeader() {
|
|
624
|
+
return this.form.get('header');
|
|
625
|
+
}
|
|
626
|
+
getFooter() {
|
|
627
|
+
return this.form.get('footer');
|
|
628
|
+
}
|
|
629
|
+
setRows(rows) {
|
|
630
|
+
this.getRows().clear({ emitEvent: false });
|
|
631
|
+
rows.forEach((r) => {
|
|
632
|
+
this.uiStore.set(r.formGroup, r.groupUi);
|
|
633
|
+
this.getRows().push(r.formGroup, { emitEvent: false });
|
|
634
|
+
this.getUiRows().push(r.groupUi);
|
|
635
|
+
});
|
|
636
|
+
this.notifyRowsStructureChanged();
|
|
637
|
+
}
|
|
638
|
+
insertRowAndNotify(row, index, options, notify) {
|
|
639
|
+
this.uiStore.set(row.formGroup, row.groupUi);
|
|
640
|
+
if (index !== undefined) {
|
|
641
|
+
this.getRows().insert(index, row.formGroup, options);
|
|
642
|
+
this.getUiRows().insert(index, row.groupUi);
|
|
643
|
+
}
|
|
644
|
+
else {
|
|
645
|
+
this.getRows().push(row.formGroup, options);
|
|
646
|
+
this.getUiRows().push(row.groupUi);
|
|
647
|
+
}
|
|
648
|
+
if (notify) {
|
|
649
|
+
this.notifyRowsStructureChanged();
|
|
650
|
+
}
|
|
651
|
+
return row;
|
|
652
|
+
}
|
|
653
|
+
insertRow(row, index, options) {
|
|
654
|
+
return this.insertRowAndNotify(row, index, options, true);
|
|
655
|
+
}
|
|
656
|
+
insertRows(rows, index) {
|
|
657
|
+
rows.forEach((r) => {
|
|
658
|
+
this.insertRowAndNotify(r, index);
|
|
659
|
+
});
|
|
660
|
+
this.notifyRowsStructureChanged();
|
|
661
|
+
}
|
|
662
|
+
updateRow(_id, value, options) {
|
|
663
|
+
const row = this.getRows().controls.find((c) => c.getRawValue()._id === _id);
|
|
664
|
+
if (row) {
|
|
665
|
+
const oldValue = row.getRawValue();
|
|
666
|
+
row.patchValue({ ...(value ?? {}), _id: oldValue._id }, options);
|
|
667
|
+
return row;
|
|
668
|
+
}
|
|
669
|
+
return undefined;
|
|
670
|
+
}
|
|
671
|
+
resetRow(_id, value, options) {
|
|
672
|
+
const row = this.getRows().controls.find((c) => c.getRawValue()._id === _id);
|
|
673
|
+
if (row) {
|
|
674
|
+
const oldValue = row.getRawValue();
|
|
675
|
+
row.reset({ ...(value ?? {}), _id: oldValue._id }, options);
|
|
676
|
+
}
|
|
677
|
+
}
|
|
678
|
+
deleteRowById(id, option) {
|
|
679
|
+
const index = this.getRows().controls.findIndex((c) => c.getRawValue()._id === id);
|
|
680
|
+
if (index !== -1) {
|
|
681
|
+
this.getRows().removeAt(index, option);
|
|
682
|
+
this.getUiRows().removeAt(index);
|
|
683
|
+
this.notifyRowsStructureChanged();
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
setHeaderControl(name, header, options) {
|
|
687
|
+
this.getHeader().setControl(name, header, options);
|
|
688
|
+
}
|
|
689
|
+
setFooterControl(name, footer, options) {
|
|
690
|
+
this.getFooter().setControl(name, footer, options);
|
|
691
|
+
}
|
|
692
|
+
setHeaderUi(name, header) {
|
|
693
|
+
this.getUiHeader().addUiState(name, header);
|
|
694
|
+
}
|
|
695
|
+
setFooterUi(name, footer) {
|
|
696
|
+
this.getUiFooter().addUiState(name, footer);
|
|
697
|
+
}
|
|
698
|
+
get rows() {
|
|
699
|
+
return this.getRows().controls;
|
|
700
|
+
}
|
|
701
|
+
init() {
|
|
702
|
+
this.columnsService.columns().forEach((column) => {
|
|
703
|
+
let colCellHeader = {};
|
|
704
|
+
if (column.headerCell.field) {
|
|
705
|
+
const { pipeTransform, ...tmpCell } = column.headerCell.field;
|
|
706
|
+
colCellHeader = _.cloneDeep(tmpCell);
|
|
707
|
+
colCellHeader = { pipeTransform, ...colCellHeader };
|
|
708
|
+
}
|
|
709
|
+
colCellHeader.name = column.columnDef;
|
|
710
|
+
const { control, ui } = this.rowFactory.createControl(colCellHeader, colCellHeader.value);
|
|
711
|
+
this.setHeaderControl(colCellHeader.name, control, { emitEvent: false });
|
|
712
|
+
this.setHeaderUi(colCellHeader.name, ui);
|
|
713
|
+
this.uiStore.set(control, ui);
|
|
714
|
+
});
|
|
715
|
+
this.columnsService
|
|
716
|
+
.columns()
|
|
717
|
+
.filter((column) => column.footerCell)
|
|
718
|
+
.forEach((column) => {
|
|
719
|
+
let colCellFooter = {};
|
|
720
|
+
if (column.footerCell?.field) {
|
|
721
|
+
const { pipeTransform, ...tmpCell } = column.footerCell.field;
|
|
722
|
+
colCellFooter = _.cloneDeep(tmpCell);
|
|
723
|
+
}
|
|
724
|
+
colCellFooter.name = column.columnDef;
|
|
725
|
+
const { control, ui } = this.rowFactory.createControl(colCellFooter, colCellFooter.value);
|
|
726
|
+
this.setFooterControl(colCellFooter.name, control, { emitEvent: false });
|
|
727
|
+
this.setFooterUi(colCellFooter.name, ui);
|
|
728
|
+
this.uiStore.set(control, ui);
|
|
729
|
+
});
|
|
730
|
+
}
|
|
731
|
+
notifyRowsStructureChanged() {
|
|
732
|
+
this.rowsStructureChangedSubject.next();
|
|
733
|
+
}
|
|
734
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: KlesForm, deps: [{ token: ColumnsService }, { token: RowFormFactory }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
735
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: KlesForm }); }
|
|
736
|
+
}
|
|
737
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: KlesForm, decorators: [{
|
|
738
|
+
type: Injectable
|
|
739
|
+
}], ctorParameters: () => [{ type: ColumnsService }, { type: RowFormFactory }] });
|
|
740
|
+
|
|
741
|
+
class TreeService {
|
|
742
|
+
constructor() {
|
|
743
|
+
this.loaderConfig = inject(LOADER_CONFIG);
|
|
744
|
+
this.loaderChildrensService = inject(LoaderChildrensService);
|
|
745
|
+
this.loadingService = inject(LoadingService);
|
|
746
|
+
this.fm = inject(KlesForm);
|
|
747
|
+
this.columnsService = inject(ColumnsService);
|
|
748
|
+
this.rowFactory = inject(RowFormFactory);
|
|
749
|
+
this.loading = new Set();
|
|
750
|
+
this._expandedIds$ = new BehaviorSubject(new Set());
|
|
751
|
+
this.expandedIds$ = this._expandedIds$.asObservable();
|
|
752
|
+
}
|
|
753
|
+
findParentIndex(id) {
|
|
754
|
+
return this.fm.getRows().controls.findIndex((c) => c.getRawValue()._id === id);
|
|
755
|
+
}
|
|
756
|
+
toggle(id, group, depth) {
|
|
757
|
+
const expanded = new Set(this._expandedIds$.value);
|
|
758
|
+
if (expanded.has(id)) {
|
|
759
|
+
this.fm
|
|
760
|
+
.getRows()
|
|
761
|
+
.controls.filter((control) => control.getRawValue()._parentId === id)
|
|
762
|
+
.map((control) => control.getRawValue()._id)
|
|
763
|
+
.forEach((_id) => this.fm.deleteRowById(_id));
|
|
764
|
+
expanded.delete(id);
|
|
765
|
+
this._expandedIds$.next(expanded);
|
|
766
|
+
}
|
|
767
|
+
else {
|
|
768
|
+
const index = this.findParentIndex(id);
|
|
769
|
+
this.loaderChildrensService.load(group, depth).subscribe((response) => {
|
|
770
|
+
if (response.loading) {
|
|
771
|
+
this.loading.add(id);
|
|
772
|
+
// this.loadingService.start();
|
|
773
|
+
}
|
|
774
|
+
else {
|
|
775
|
+
this.loading.delete(id);
|
|
776
|
+
// this.loadingService.stop();
|
|
777
|
+
console.log((group.getRawValue()._depth ?? 0) + 1);
|
|
778
|
+
this.fm.insertRows(this.rowFactory.createRows(this.columnsService.columns().map((col) => ({ ...col.cell.field, name: col.columnDef })), response.items, { depth: (group.getRawValue()._depth ?? 0) + 1, parentId: id }), index + 1);
|
|
779
|
+
expanded.add(id);
|
|
780
|
+
this._expandedIds$.next(expanded);
|
|
781
|
+
}
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
hasChildren(group, depth) {
|
|
786
|
+
return this.loaderConfig.lines.hasChildren?.(group, depth) ?? true;
|
|
787
|
+
}
|
|
788
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: TreeService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
789
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: TreeService }); }
|
|
790
|
+
}
|
|
791
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: TreeService, decorators: [{
|
|
792
|
+
type: Injectable
|
|
793
|
+
}] });
|
|
794
|
+
|
|
795
|
+
class KlesCellComponent {
|
|
796
|
+
constructor() {
|
|
797
|
+
this.destroyRef = inject(DestroyRef);
|
|
798
|
+
this.expandedRowStore = inject(ExpandedRowStore);
|
|
799
|
+
this.treeService = inject(TreeService);
|
|
800
|
+
this.ui = input.required(...(ngDevMode ? [{ debugName: "ui" }] : /* istanbul ignore next */ []));
|
|
801
|
+
this.group = input.required(...(ngDevMode ? [{ debugName: "group" }] : /* istanbul ignore next */ []));
|
|
802
|
+
this.column = input.required(...(ngDevMode ? [{ debugName: "column" }] : /* istanbul ignore next */ []));
|
|
803
|
+
this.expandedRow = computed(() => {
|
|
804
|
+
return (this.column().canExpand ?? false) && (this.ui().get(this.column().columnDef).value().expandedRow ?? false);
|
|
805
|
+
}, ...(ngDevMode ? [{ debugName: "expandedRow" }] : /* istanbul ignore next */ []));
|
|
806
|
+
this.expandedNode = computed(() => {
|
|
807
|
+
return (this.column().canExpandNode ?? false) && (this.ui().get(this.column().columnDef).value().expandedNode ?? false);
|
|
808
|
+
}, ...(ngDevMode ? [{ debugName: "expandedNode" }] : /* istanbul ignore next */ []));
|
|
809
|
+
this.hasChildren = computed(() => {
|
|
810
|
+
return this.treeService.hasChildren(this.group(), this.group().getRawValue()._depth);
|
|
811
|
+
}, ...(ngDevMode ? [{ debugName: "hasChildren" }] : /* istanbul ignore next */ []));
|
|
812
|
+
this.column$ = toObservable(this.column);
|
|
813
|
+
}
|
|
814
|
+
ngOnInit() {
|
|
815
|
+
this.listen();
|
|
816
|
+
}
|
|
817
|
+
stopPropagation(event) {
|
|
818
|
+
event.stopPropagation();
|
|
819
|
+
}
|
|
820
|
+
expandRow() {
|
|
821
|
+
this.expandedRowStore.toggle(this.group().getRawValue()._id);
|
|
822
|
+
}
|
|
823
|
+
expandNode() {
|
|
824
|
+
this.treeService.toggle(this.group().getRawValue()._id, this.group(), 0); //TODO depth
|
|
825
|
+
}
|
|
826
|
+
listen() {
|
|
827
|
+
this.column$
|
|
828
|
+
.pipe(filter((column) => column.canExpand ?? false), switchMap(() => {
|
|
829
|
+
return this.expandedRowStore.expandedIds$.pipe(takeUntilDestroyed(this.destroyRef), map((ids) => {
|
|
830
|
+
return ids.has(this.group().value._id);
|
|
831
|
+
}));
|
|
832
|
+
}))
|
|
833
|
+
.subscribe((expandedRow) => {
|
|
834
|
+
this.ui().get(this.column().columnDef)?.patchValue({ expandedRow });
|
|
835
|
+
});
|
|
836
|
+
this.column$
|
|
837
|
+
.pipe(filter((column) => column.canExpandNode ?? false), switchMap(() => {
|
|
838
|
+
return this.treeService.expandedIds$.pipe(takeUntilDestroyed(this.destroyRef), map((ids) => {
|
|
839
|
+
return ids.has(this.group().getRawValue()._id);
|
|
840
|
+
}));
|
|
841
|
+
}))
|
|
842
|
+
.subscribe((expandedNode) => {
|
|
843
|
+
this.ui().get(this.column().columnDef)?.patchValue({ expandedNode });
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: KlesCellComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
847
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.19", type: KlesCellComponent, isStandalone: true, selector: "kles-cell", inputs: { ui: { classPropertyName: "ui", publicName: "ui", isSignal: true, isRequired: true, transformFunction: null }, group: { classPropertyName: "group", publicName: "group", isSignal: true, isRequired: true, transformFunction: null }, column: { classPropertyName: "column", publicName: "column", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "@if (column().canExpand) {\n <button matIconButton class=\"expand-button\" (click)=\"expandRow(); stopPropagation($event)\">\n @if (this.expandedRow()) {\n <mat-icon>keyboard_arrow_down</mat-icon>\n } @else {\n <mat-icon>chevron_right</mat-icon>\n }\n </button>\n}\n@if (hasChildren() && column().canExpandNode) {\n <button matIconButton class=\"expand-button\" (click)=\"expandNode(); stopPropagation($event)\">\n @if (this.expandedNode()) {\n <mat-icon>keyboard_arrow_down</mat-icon>\n } @else {\n <mat-icon>chevron_right</mat-icon>\n }\n </button>\n}\n<div class=\"cell-field\"><ng-content></ng-content></div>\n", styles: [":host{display:flex;flex-direction:row;justify-content:inherit;gap:5px;align-items:center}.cell-field{flex-grow:1;justify-content:inherit;flex-direction:column;display:flex;text-align:center}.expand-button.mat-mdc-icon-button{--mdc-icon-button-state-layer-size: 28px;--mdc-icon-button-icon-size: 22px;width:28px;height:28px;padding:0;display:grid;place-items:center}.expand-button.mat-mdc-icon-button .mat-icon{width:22px;height:22px;font-size:22px;line-height:22px;margin:0}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i2.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }] }); }
|
|
848
|
+
}
|
|
849
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: KlesCellComponent, decorators: [{
|
|
850
|
+
type: Component,
|
|
851
|
+
args: [{ selector: 'kles-cell', standalone: true, imports: [CommonModule, MatIconModule, MatButtonModule], template: "@if (column().canExpand) {\n <button matIconButton class=\"expand-button\" (click)=\"expandRow(); stopPropagation($event)\">\n @if (this.expandedRow()) {\n <mat-icon>keyboard_arrow_down</mat-icon>\n } @else {\n <mat-icon>chevron_right</mat-icon>\n }\n </button>\n}\n@if (hasChildren() && column().canExpandNode) {\n <button matIconButton class=\"expand-button\" (click)=\"expandNode(); stopPropagation($event)\">\n @if (this.expandedNode()) {\n <mat-icon>keyboard_arrow_down</mat-icon>\n } @else {\n <mat-icon>chevron_right</mat-icon>\n }\n </button>\n}\n<div class=\"cell-field\"><ng-content></ng-content></div>\n", styles: [":host{display:flex;flex-direction:row;justify-content:inherit;gap:5px;align-items:center}.cell-field{flex-grow:1;justify-content:inherit;flex-direction:column;display:flex;text-align:center}.expand-button.mat-mdc-icon-button{--mdc-icon-button-state-layer-size: 28px;--mdc-icon-button-icon-size: 22px;width:28px;height:28px;padding:0;display:grid;place-items:center}.expand-button.mat-mdc-icon-button .mat-icon{width:22px;height:22px;font-size:22px;line-height:22px;margin:0}\n"] }]
|
|
852
|
+
}], propDecorators: { ui: [{ type: i0.Input, args: [{ isSignal: true, alias: "ui", required: true }] }], group: [{ type: i0.Input, args: [{ isSignal: true, alias: "group", required: true }] }], column: [{ type: i0.Input, args: [{ isSignal: true, alias: "column", required: true }] }] } });
|
|
853
|
+
|
|
854
|
+
class KlesHeaderComponent {
|
|
855
|
+
constructor() {
|
|
856
|
+
this.header = input.required(...(ngDevMode ? [{ debugName: "header" }] : /* istanbul ignore next */ []));
|
|
857
|
+
this.group = input.required(...(ngDevMode ? [{ debugName: "group" }] : /* istanbul ignore next */ []));
|
|
858
|
+
}
|
|
859
|
+
ngOnInit() { }
|
|
860
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: KlesHeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
861
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.19", type: KlesHeaderComponent, isStandalone: true, selector: "kles-header", inputs: { header: { classPropertyName: "header", publicName: "header", isSignal: true, isRequired: true, transformFunction: null }, group: { classPropertyName: "group", publicName: "group", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
|
|
862
|
+
<div
|
|
863
|
+
class="header"
|
|
864
|
+
mat-sort-header
|
|
865
|
+
[disabled]="!header().sortable"
|
|
866
|
+
[arrowPosition]="header().sortArrowPosition"
|
|
867
|
+
[matTooltip]="header().tooltip"
|
|
868
|
+
matTooltipPosition="above"
|
|
869
|
+
>
|
|
870
|
+
{{ header().label }}
|
|
871
|
+
</div>
|
|
872
|
+
|
|
873
|
+
<div class="filterHeader">
|
|
874
|
+
<div class="field">
|
|
875
|
+
<ng-content></ng-content>
|
|
876
|
+
</div>
|
|
877
|
+
|
|
878
|
+
@if (header().filterClearable && group().get(header().columnDef).value) {
|
|
879
|
+
<div class="icon-button">
|
|
880
|
+
<button
|
|
881
|
+
mat-icon-button
|
|
882
|
+
aria-label="Clear"
|
|
883
|
+
type="button"
|
|
884
|
+
class="icon-button-small"
|
|
885
|
+
(click)="group().controls[header().columnDef].reset()"
|
|
886
|
+
>
|
|
887
|
+
<mat-icon>close</mat-icon>
|
|
888
|
+
</button>
|
|
889
|
+
</div>
|
|
890
|
+
}
|
|
891
|
+
</div>
|
|
892
|
+
`, isInline: true, styles: [":host{padding-bottom:10px;display:flex;flex-direction:column;justify-content:inherit}.header{flex-grow:1;align-items:center;display:flex;justify-content:inherit}.filterHeader{display:flex;flex-grow:1;align-items:center;gap:2px}.field{flex-grow:1;text-align:center}.icon-button button[mat-icon-button].icon-button-small{width:24px;height:24px;line-height:24px;padding:0}.icon-button button[mat-icon-button].icon-button-small .mat-icon{font-size:18px;width:18px;height:18px;line-height:18px}.icon-button button[mat-icon-button].icon-button-small .mat-mdc-button-ripple{font-size:inherit;width:inherit;height:inherit;line-height:inherit}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i2.MatIconButton, selector: "button[mat-icon-button], a[mat-icon-button], button[matIconButton], a[matIconButton]", exportAs: ["matButton", "matAnchor"] }, { kind: "ngmodule", type: MatTooltipModule }, { kind: "directive", type: i3.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "ngmodule", type: MatSortModule }, { kind: "component", type: i4.MatSortHeader, selector: "[mat-sort-header]", inputs: ["mat-sort-header", "arrowPosition", "start", "disabled", "sortActionDescription", "disableClear"], exportAs: ["matSortHeader"] }] }); }
|
|
893
|
+
}
|
|
894
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: KlesHeaderComponent, decorators: [{
|
|
895
|
+
type: Component,
|
|
896
|
+
args: [{ selector: 'kles-header', template: `
|
|
897
|
+
<div
|
|
898
|
+
class="header"
|
|
899
|
+
mat-sort-header
|
|
900
|
+
[disabled]="!header().sortable"
|
|
901
|
+
[arrowPosition]="header().sortArrowPosition"
|
|
902
|
+
[matTooltip]="header().tooltip"
|
|
903
|
+
matTooltipPosition="above"
|
|
904
|
+
>
|
|
905
|
+
{{ header().label }}
|
|
906
|
+
</div>
|
|
907
|
+
|
|
908
|
+
<div class="filterHeader">
|
|
909
|
+
<div class="field">
|
|
910
|
+
<ng-content></ng-content>
|
|
911
|
+
</div>
|
|
912
|
+
|
|
913
|
+
@if (header().filterClearable && group().get(header().columnDef).value) {
|
|
914
|
+
<div class="icon-button">
|
|
915
|
+
<button
|
|
916
|
+
mat-icon-button
|
|
917
|
+
aria-label="Clear"
|
|
918
|
+
type="button"
|
|
919
|
+
class="icon-button-small"
|
|
920
|
+
(click)="group().controls[header().columnDef].reset()"
|
|
921
|
+
>
|
|
922
|
+
<mat-icon>close</mat-icon>
|
|
923
|
+
</button>
|
|
924
|
+
</div>
|
|
925
|
+
}
|
|
926
|
+
</div>
|
|
927
|
+
`, standalone: true, imports: [CommonModule, ReactiveFormsModule, MatIconModule, MatButtonModule, MatTooltipModule, MatSortModule], styles: [":host{padding-bottom:10px;display:flex;flex-direction:column;justify-content:inherit}.header{flex-grow:1;align-items:center;display:flex;justify-content:inherit}.filterHeader{display:flex;flex-grow:1;align-items:center;gap:2px}.field{flex-grow:1;text-align:center}.icon-button button[mat-icon-button].icon-button-small{width:24px;height:24px;line-height:24px;padding:0}.icon-button button[mat-icon-button].icon-button-small .mat-icon{font-size:18px;width:18px;height:18px;line-height:18px}.icon-button button[mat-icon-button].icon-button-small .mat-mdc-button-ripple{font-size:inherit;width:inherit;height:inherit;line-height:inherit}\n"] }]
|
|
928
|
+
}], propDecorators: { header: [{ type: i0.Input, args: [{ isSignal: true, alias: "header", required: true }] }], group: [{ type: i0.Input, args: [{ isSignal: true, alias: "group", required: true }] }] } });
|
|
929
|
+
|
|
930
|
+
class HeaderPipe {
|
|
931
|
+
transform(col) {
|
|
932
|
+
if (!col)
|
|
933
|
+
return null;
|
|
934
|
+
return {
|
|
935
|
+
columnDef: col.columnDef,
|
|
936
|
+
filterable: col.filterable,
|
|
937
|
+
sortable: col.sortable,
|
|
938
|
+
sortArrowPosition: col.sortArrowPosition,
|
|
939
|
+
...col.headerCell,
|
|
940
|
+
};
|
|
941
|
+
}
|
|
942
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: HeaderPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
|
|
943
|
+
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.19", ngImport: i0, type: HeaderPipe, isStandalone: true, name: "header" }); }
|
|
944
|
+
}
|
|
945
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: HeaderPipe, decorators: [{
|
|
946
|
+
type: Pipe,
|
|
947
|
+
args: [{
|
|
948
|
+
name: 'header',
|
|
949
|
+
standalone: true,
|
|
950
|
+
}]
|
|
951
|
+
}] });
|
|
952
|
+
|
|
953
|
+
class KlesTableConnectorService {
|
|
954
|
+
constructor() {
|
|
955
|
+
this._connected$ = new BehaviorSubject(false);
|
|
956
|
+
this.connected$ = this._connected$.asObservable();
|
|
957
|
+
}
|
|
958
|
+
connect(table) {
|
|
959
|
+
this._table = table;
|
|
960
|
+
this._connected$.next(true);
|
|
961
|
+
return () => {
|
|
962
|
+
if (this._table === table) {
|
|
963
|
+
this._table = undefined;
|
|
964
|
+
this._connected$.next(false);
|
|
965
|
+
}
|
|
966
|
+
};
|
|
967
|
+
}
|
|
968
|
+
get table() {
|
|
969
|
+
if (!this._table) {
|
|
970
|
+
throw new Error('KlesTableConnectorService: table is not connected');
|
|
971
|
+
}
|
|
972
|
+
return this._table;
|
|
973
|
+
}
|
|
974
|
+
get scrollbar() {
|
|
975
|
+
return this.table.scrollbar;
|
|
976
|
+
}
|
|
977
|
+
get column() {
|
|
978
|
+
return this.table?.column;
|
|
979
|
+
}
|
|
980
|
+
get pagination() {
|
|
981
|
+
return this.table.pagination;
|
|
982
|
+
}
|
|
983
|
+
get sort() {
|
|
984
|
+
return this.table.sort;
|
|
985
|
+
}
|
|
986
|
+
get loading() {
|
|
987
|
+
return this.table.loading;
|
|
988
|
+
}
|
|
989
|
+
get selection() {
|
|
990
|
+
return this.table.selection;
|
|
991
|
+
}
|
|
992
|
+
get footer() {
|
|
993
|
+
return this.table.footer;
|
|
994
|
+
}
|
|
995
|
+
get form() {
|
|
996
|
+
return this.table.form;
|
|
997
|
+
}
|
|
998
|
+
get ui() {
|
|
999
|
+
return this.table.ui;
|
|
1000
|
+
}
|
|
1001
|
+
get events() {
|
|
1002
|
+
return this.table.events;
|
|
1003
|
+
}
|
|
1004
|
+
refresh() {
|
|
1005
|
+
this.table?.refresh();
|
|
1006
|
+
}
|
|
1007
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: KlesTableConnectorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1008
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: KlesTableConnectorService }); }
|
|
1009
|
+
}
|
|
1010
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: KlesTableConnectorService, decorators: [{
|
|
1011
|
+
type: Injectable
|
|
1012
|
+
}], ctorParameters: () => [] });
|
|
1013
|
+
|
|
1014
|
+
class PaginatorStore {
|
|
1015
|
+
constructor(config) {
|
|
1016
|
+
this.config = config;
|
|
1017
|
+
this.s = new BehaviorSubject({ page: 0, perPage: config?.pageSize ?? 10 });
|
|
1018
|
+
this.page$ = this.s.asObservable();
|
|
1019
|
+
}
|
|
1020
|
+
setPage(v) {
|
|
1021
|
+
this.s.next(v);
|
|
1022
|
+
}
|
|
1023
|
+
snapshot() {
|
|
1024
|
+
return this.s.value;
|
|
1025
|
+
}
|
|
1026
|
+
reset() {
|
|
1027
|
+
this.s.next({ page: 0, perPage: this.config?.pageSize ?? 10 });
|
|
1028
|
+
}
|
|
1029
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: PaginatorStore, deps: [{ token: PAGINATOR_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1030
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: PaginatorStore }); }
|
|
1031
|
+
}
|
|
1032
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: PaginatorStore, decorators: [{
|
|
1033
|
+
type: Injectable
|
|
1034
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1035
|
+
type: Optional
|
|
1036
|
+
}, {
|
|
1037
|
+
type: Inject,
|
|
1038
|
+
args: [PAGINATOR_CONFIG]
|
|
1039
|
+
}] }] });
|
|
1040
|
+
|
|
1041
|
+
class PaginatorService {
|
|
1042
|
+
constructor(config, paginatorStore, datasourceService, eventsService) {
|
|
1043
|
+
this.config = config;
|
|
1044
|
+
this.paginatorStore = paginatorStore;
|
|
1045
|
+
this.datasourceService = datasourceService;
|
|
1046
|
+
this.eventsService = eventsService;
|
|
1047
|
+
this._disabled = signal(false, ...(ngDevMode ? [{ debugName: "_disabled" }] : /* istanbul ignore next */ []));
|
|
1048
|
+
this._pageChanged = new EventEmitter();
|
|
1049
|
+
this.destroyRef = inject(DestroyRef);
|
|
1050
|
+
}
|
|
1051
|
+
register(paginator) {
|
|
1052
|
+
this._paginator = paginator;
|
|
1053
|
+
this.datasourceService.datasource.paginator = this._paginator;
|
|
1054
|
+
if (this._paginator) {
|
|
1055
|
+
this._paginator.pageIndex = this.paginatorStore?.snapshot().page ?? this._paginator.pageIndex;
|
|
1056
|
+
this._paginator.pageSize = this.paginatorStore?.snapshot().perPage ?? this._paginator.pageSize;
|
|
1057
|
+
this._paginator.pageSizeOptions = this.config?.pageSizeOptions ?? [5, 10, 20, 25, 50];
|
|
1058
|
+
this._paginator.selectConfig = this.config?.selectConfig ?? {};
|
|
1059
|
+
this._paginator.showFirstLastButtons = this.config?.showFirstLastButtons ?? true;
|
|
1060
|
+
this._paginator.page.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((event) => {
|
|
1061
|
+
this.paginatorStore?.setPage({ page: event.pageIndex, perPage: event.pageSize });
|
|
1062
|
+
this._pageChanged.next(event);
|
|
1063
|
+
this.eventsService.emit('pageChange', {
|
|
1064
|
+
pageIndex: event.pageIndex,
|
|
1065
|
+
previousPageIndex: event.previousPageIndex,
|
|
1066
|
+
pageSize: event.pageSize,
|
|
1067
|
+
totalItems: event.length,
|
|
1068
|
+
sourceEvent: event,
|
|
1069
|
+
});
|
|
1070
|
+
});
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
get paginator() {
|
|
1074
|
+
return this._paginator;
|
|
1075
|
+
}
|
|
1076
|
+
pageChanged() {
|
|
1077
|
+
return this._pageChanged;
|
|
1078
|
+
}
|
|
1079
|
+
setPageIndex(index) {
|
|
1080
|
+
if (!this._paginator) {
|
|
1081
|
+
return;
|
|
1082
|
+
}
|
|
1083
|
+
this.setSizeIndex(this._paginator.pageSize, index);
|
|
1084
|
+
}
|
|
1085
|
+
setPageSize(size) {
|
|
1086
|
+
if (!this._paginator) {
|
|
1087
|
+
return;
|
|
1088
|
+
}
|
|
1089
|
+
this.setSizeIndex(size, 0);
|
|
1090
|
+
}
|
|
1091
|
+
setPageSizeOptions(option) {
|
|
1092
|
+
if (this._paginator) {
|
|
1093
|
+
this._paginator.pageSizeOptions = option;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
setlength(length) {
|
|
1097
|
+
if (this._paginator) {
|
|
1098
|
+
this._paginator.length = length;
|
|
1099
|
+
}
|
|
1100
|
+
}
|
|
1101
|
+
firstPage() {
|
|
1102
|
+
this._paginator?.firstPage();
|
|
1103
|
+
}
|
|
1104
|
+
lastPage() {
|
|
1105
|
+
this._paginator?.lastPage();
|
|
1106
|
+
}
|
|
1107
|
+
disabled() {
|
|
1108
|
+
return this._disabled.asReadonly();
|
|
1109
|
+
}
|
|
1110
|
+
disable() {
|
|
1111
|
+
this._disabled.set(true);
|
|
1112
|
+
}
|
|
1113
|
+
enable() {
|
|
1114
|
+
this._disabled.set(false);
|
|
1115
|
+
}
|
|
1116
|
+
setSizeIndex(size, index) {
|
|
1117
|
+
if (this._paginator) {
|
|
1118
|
+
const prev = this._paginator.pageIndex;
|
|
1119
|
+
this._paginator.pageSize = size;
|
|
1120
|
+
this._paginator.pageIndex = index;
|
|
1121
|
+
this._paginator.page.emit({
|
|
1122
|
+
pageIndex: this._paginator.pageIndex,
|
|
1123
|
+
pageSize: this._paginator.pageSize,
|
|
1124
|
+
length: this._paginator.length,
|
|
1125
|
+
previousPageIndex: prev,
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: PaginatorService, deps: [{ token: PAGINATOR_CONFIG, optional: true }, { token: PaginatorStore, optional: true }, { token: DATASOURCE_SERVICE }, { token: EventsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1130
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: PaginatorService }); }
|
|
1131
|
+
}
|
|
1132
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: PaginatorService, decorators: [{
|
|
1133
|
+
type: Injectable
|
|
1134
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1135
|
+
type: Optional
|
|
1136
|
+
}, {
|
|
1137
|
+
type: Inject,
|
|
1138
|
+
args: [PAGINATOR_CONFIG]
|
|
1139
|
+
}] }, { type: PaginatorStore, decorators: [{
|
|
1140
|
+
type: Optional
|
|
1141
|
+
}] }, { type: undefined, decorators: [{
|
|
1142
|
+
type: Inject,
|
|
1143
|
+
args: [DATASOURCE_SERVICE]
|
|
1144
|
+
}] }, { type: EventsService }] });
|
|
1145
|
+
|
|
1146
|
+
class ScrollbarService {
|
|
1147
|
+
constructor() {
|
|
1148
|
+
this.default = 'smooth';
|
|
1149
|
+
}
|
|
1150
|
+
register(el) {
|
|
1151
|
+
this.element = el;
|
|
1152
|
+
}
|
|
1153
|
+
unregister() {
|
|
1154
|
+
this.element = undefined;
|
|
1155
|
+
}
|
|
1156
|
+
toTop(sb) {
|
|
1157
|
+
this.element?.scrollTo({ top: 0, behavior: sb ?? this.default });
|
|
1158
|
+
}
|
|
1159
|
+
toBottom(sb) {
|
|
1160
|
+
const top = this.element.scrollHeight;
|
|
1161
|
+
this.element?.scrollTo({ top, behavior: sb ?? this.default });
|
|
1162
|
+
}
|
|
1163
|
+
toLeft(sb) {
|
|
1164
|
+
this.element?.scrollTo({ left: 0, behavior: sb ?? this.default });
|
|
1165
|
+
}
|
|
1166
|
+
toRight(sb) {
|
|
1167
|
+
const left = this.element.scrollWidth;
|
|
1168
|
+
this.element?.scrollTo({ left, behavior: sb ?? this.default });
|
|
1169
|
+
}
|
|
1170
|
+
to(top, left, sb) {
|
|
1171
|
+
this.element?.scrollTo({ top, left, behavior: sb ?? this.default });
|
|
1172
|
+
}
|
|
1173
|
+
getTop() {
|
|
1174
|
+
return this.element?.scrollTop;
|
|
1175
|
+
}
|
|
1176
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ScrollbarService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1177
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ScrollbarService }); }
|
|
1178
|
+
}
|
|
1179
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ScrollbarService, decorators: [{
|
|
1180
|
+
type: Injectable
|
|
1181
|
+
}] });
|
|
1182
|
+
|
|
1183
|
+
class FooterService {
|
|
1184
|
+
constructor(_footer) {
|
|
1185
|
+
this._footer = _footer;
|
|
1186
|
+
}
|
|
1187
|
+
get footer() {
|
|
1188
|
+
return this._footer.asReadonly();
|
|
1189
|
+
}
|
|
1190
|
+
show() {
|
|
1191
|
+
this._footer.set(true);
|
|
1192
|
+
}
|
|
1193
|
+
hide() {
|
|
1194
|
+
this._footer.set(false);
|
|
1195
|
+
}
|
|
1196
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: FooterService, deps: [{ token: FOOTER }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1197
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: FooterService }); }
|
|
1198
|
+
}
|
|
1199
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: FooterService, decorators: [{
|
|
1200
|
+
type: Injectable
|
|
1201
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1202
|
+
type: Inject,
|
|
1203
|
+
args: [FOOTER]
|
|
1204
|
+
}] }] });
|
|
1205
|
+
|
|
1206
|
+
class ExtraRowService {
|
|
1207
|
+
constructor(_extraRowsConfig, expandedRowStore) {
|
|
1208
|
+
this._extraRowsConfig = _extraRowsConfig;
|
|
1209
|
+
this.expandedRowStore = expandedRowStore;
|
|
1210
|
+
this.multiTemplateDataRows = computed(() => this._extraRowsConfig().length > 0, ...(ngDevMode ? [{ debugName: "multiTemplateDataRows" }] : /* istanbul ignore next */ []));
|
|
1211
|
+
this.rows = computed(() => this._extraRowsConfig().map((config) => ({
|
|
1212
|
+
...config,
|
|
1213
|
+
when: this.createWhen(config),
|
|
1214
|
+
displayedColumns: config.cells.map((cel) => cel.columnDef),
|
|
1215
|
+
})), ...(ngDevMode ? [{ debugName: "rows" }] : /* istanbul ignore next */ []));
|
|
1216
|
+
}
|
|
1217
|
+
extraColumns() {
|
|
1218
|
+
return this._extraRowsConfig()
|
|
1219
|
+
.flatMap((config) => config.cells)
|
|
1220
|
+
.filter(Boolean);
|
|
1221
|
+
}
|
|
1222
|
+
createWhen(config) {
|
|
1223
|
+
if (config.mode === 'expand') {
|
|
1224
|
+
return (_, row) => {
|
|
1225
|
+
return this.expandedRowStore.isExpanded(row.value._id);
|
|
1226
|
+
};
|
|
1227
|
+
}
|
|
1228
|
+
else {
|
|
1229
|
+
return config?.when;
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ExtraRowService, deps: [{ token: EXTRA_ROWS }, { token: ExpandedRowStore }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1233
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ExtraRowService }); }
|
|
1234
|
+
}
|
|
1235
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ExtraRowService, decorators: [{
|
|
1236
|
+
type: Injectable
|
|
1237
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1238
|
+
type: Inject,
|
|
1239
|
+
args: [EXTRA_ROWS]
|
|
1240
|
+
}] }, { type: ExpandedRowStore }] });
|
|
1241
|
+
|
|
1242
|
+
class RenderService {
|
|
1243
|
+
constructor() {
|
|
1244
|
+
this._render = new EventEmitter();
|
|
1245
|
+
}
|
|
1246
|
+
render() {
|
|
1247
|
+
return this._render;
|
|
1248
|
+
}
|
|
1249
|
+
forceRenderRows() {
|
|
1250
|
+
this._render.emit();
|
|
1251
|
+
}
|
|
1252
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: RenderService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1253
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: RenderService }); }
|
|
1254
|
+
}
|
|
1255
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: RenderService, decorators: [{
|
|
1256
|
+
type: Injectable
|
|
1257
|
+
}] });
|
|
1258
|
+
|
|
1259
|
+
class KlesDataSource extends MatTableDataSource {
|
|
1260
|
+
constructor() {
|
|
1261
|
+
super([]);
|
|
1262
|
+
}
|
|
1263
|
+
}
|
|
1264
|
+
class KlesLazyDataSource {
|
|
1265
|
+
constructor() {
|
|
1266
|
+
this._rows$ = new BehaviorSubject([]);
|
|
1267
|
+
this._filter = undefined;
|
|
1268
|
+
}
|
|
1269
|
+
get sort() {
|
|
1270
|
+
return this._sort;
|
|
1271
|
+
}
|
|
1272
|
+
set sort(sort) {
|
|
1273
|
+
this._sort = sort;
|
|
1274
|
+
}
|
|
1275
|
+
get paginator() {
|
|
1276
|
+
return this._paginator;
|
|
1277
|
+
}
|
|
1278
|
+
set paginator(paginator) {
|
|
1279
|
+
this._paginator = paginator;
|
|
1280
|
+
}
|
|
1281
|
+
set data(data) {
|
|
1282
|
+
this._rows$.next(data);
|
|
1283
|
+
}
|
|
1284
|
+
get filter() {
|
|
1285
|
+
return this._filter;
|
|
1286
|
+
}
|
|
1287
|
+
set filter(f) {
|
|
1288
|
+
this._filter = f;
|
|
1289
|
+
}
|
|
1290
|
+
connect() {
|
|
1291
|
+
return this._rows$;
|
|
1292
|
+
}
|
|
1293
|
+
disconnect() {
|
|
1294
|
+
this._rows$.complete();
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
class CellValueChangeService {
|
|
1299
|
+
constructor(eventsService) {
|
|
1300
|
+
this.eventsService = eventsService;
|
|
1301
|
+
this.destroyRef = inject(DestroyRef);
|
|
1302
|
+
this.subscriptions = new Map();
|
|
1303
|
+
}
|
|
1304
|
+
listen(visibleRows, visibleColumns) {
|
|
1305
|
+
const expectedKeys = new Set();
|
|
1306
|
+
visibleRows.forEach((row, rowIndex) => {
|
|
1307
|
+
visibleColumns.forEach((column) => {
|
|
1308
|
+
const columnKey = column;
|
|
1309
|
+
const control = row.get(columnKey);
|
|
1310
|
+
if (!control) {
|
|
1311
|
+
return;
|
|
1312
|
+
}
|
|
1313
|
+
const key = this.getCellKey(row, columnKey);
|
|
1314
|
+
expectedKeys.add(key);
|
|
1315
|
+
if (this.subscriptions.has(key)) {
|
|
1316
|
+
return;
|
|
1317
|
+
}
|
|
1318
|
+
const subscription = this.subscribeToCell(row, rowIndex, columnKey, control);
|
|
1319
|
+
this.subscriptions.set(key, subscription);
|
|
1320
|
+
});
|
|
1321
|
+
});
|
|
1322
|
+
this.unsubscribeInvisibleCells(expectedKeys);
|
|
1323
|
+
}
|
|
1324
|
+
getCellKey(row, columnDef) {
|
|
1325
|
+
return `${row.get('_id')?.value}:${columnDef}`;
|
|
1326
|
+
}
|
|
1327
|
+
subscribeToCell(row, rowIndex, columnDef, control) {
|
|
1328
|
+
let previousValue = control.value;
|
|
1329
|
+
return control.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((currentValue) => {
|
|
1330
|
+
this.eventsService.emit('cellValueChange', {
|
|
1331
|
+
row,
|
|
1332
|
+
rowIndex,
|
|
1333
|
+
columnDef,
|
|
1334
|
+
control,
|
|
1335
|
+
previousValue,
|
|
1336
|
+
currentValue,
|
|
1337
|
+
value: row.value,
|
|
1338
|
+
rawValue: row.getRawValue(),
|
|
1339
|
+
});
|
|
1340
|
+
previousValue = currentValue;
|
|
1341
|
+
});
|
|
1342
|
+
}
|
|
1343
|
+
unsubscribeInvisibleCells(expectedKeys) {
|
|
1344
|
+
for (const [key, subscription] of this.subscriptions.entries()) {
|
|
1345
|
+
if (!expectedKeys.has(key)) {
|
|
1346
|
+
subscription.unsubscribe();
|
|
1347
|
+
this.subscriptions.delete(key);
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: CellValueChangeService, deps: [{ token: EventsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1352
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: CellValueChangeService }); }
|
|
1353
|
+
}
|
|
1354
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: CellValueChangeService, decorators: [{
|
|
1355
|
+
type: Injectable
|
|
1356
|
+
}], ctorParameters: () => [{ type: EventsService }] });
|
|
1357
|
+
|
|
1358
|
+
class ValidationService {
|
|
1359
|
+
constructor(eventsService) {
|
|
1360
|
+
this.eventsService = eventsService;
|
|
1361
|
+
this.destroyRef = inject(DestroyRef);
|
|
1362
|
+
this.columnSubscriptions = new Map();
|
|
1363
|
+
this.rowSubscriptions = new Map();
|
|
1364
|
+
}
|
|
1365
|
+
listen(visibleRows, visibleColumns) {
|
|
1366
|
+
const expectedColumnKeys = new Set();
|
|
1367
|
+
const expectedRowKeys = new Set();
|
|
1368
|
+
visibleRows.forEach((row, rowIndex) => {
|
|
1369
|
+
const rowSubscription = this.subscribeToRow(row, rowIndex);
|
|
1370
|
+
const key = this.getRowKey(row);
|
|
1371
|
+
expectedRowKeys.add(key);
|
|
1372
|
+
this.rowSubscriptions.set(key, rowSubscription);
|
|
1373
|
+
visibleColumns.forEach((column) => {
|
|
1374
|
+
const columnKey = column;
|
|
1375
|
+
const control = row.get(columnKey);
|
|
1376
|
+
if (!control) {
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
const key = this.getCellKey(row, columnKey);
|
|
1380
|
+
expectedColumnKeys.add(key);
|
|
1381
|
+
if (this.columnSubscriptions.has(key)) {
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1384
|
+
const subscription = this.subscribeToCell(row, rowIndex, columnKey, control);
|
|
1385
|
+
this.columnSubscriptions.set(key, subscription);
|
|
1386
|
+
});
|
|
1387
|
+
});
|
|
1388
|
+
this.unsubscribe(expectedRowKeys, expectedColumnKeys);
|
|
1389
|
+
}
|
|
1390
|
+
getCellKey(row, columnDef) {
|
|
1391
|
+
return `${this.getRowKey(row)}:${columnDef}`;
|
|
1392
|
+
}
|
|
1393
|
+
getRowKey(row) {
|
|
1394
|
+
return `${row.get('_id')?.value}`;
|
|
1395
|
+
}
|
|
1396
|
+
subscribeToCell(row, rowIndex, columnDef, control) {
|
|
1397
|
+
return control.statusChanges
|
|
1398
|
+
.pipe(takeUntilDestroyed(this.destroyRef), filter((status) => status === 'INVALID'))
|
|
1399
|
+
.subscribe(() => {
|
|
1400
|
+
this.eventsService.emit('cellValidationError', {
|
|
1401
|
+
row,
|
|
1402
|
+
rowIndex,
|
|
1403
|
+
rawValue: row.getRawValue(),
|
|
1404
|
+
value: row.value,
|
|
1405
|
+
errors: control.errors,
|
|
1406
|
+
controlsErrors: { columnDef: control.errors },
|
|
1407
|
+
});
|
|
1408
|
+
});
|
|
1409
|
+
}
|
|
1410
|
+
subscribeToRow(row, rowIndex) {
|
|
1411
|
+
return row.statusChanges
|
|
1412
|
+
.pipe(takeUntilDestroyed(this.destroyRef), filter((status) => status === 'INVALID'))
|
|
1413
|
+
.subscribe(() => {
|
|
1414
|
+
this.eventsService.emit('rowValidationError', {
|
|
1415
|
+
row,
|
|
1416
|
+
rowIndex,
|
|
1417
|
+
rawValue: row.getRawValue(),
|
|
1418
|
+
value: row.value,
|
|
1419
|
+
errors: row.errors,
|
|
1420
|
+
controlsErrors: Object.keys(row.controls)
|
|
1421
|
+
.filter((key) => row.get(key)?.errors)
|
|
1422
|
+
.map((key) => ({ [key]: row.get(key)?.errors }))
|
|
1423
|
+
.reduce((a, b) => ({ ...a, ...b })),
|
|
1424
|
+
});
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
unsubscribe(expectedRowKeys, expectedColumnKeys) {
|
|
1428
|
+
for (const [key, subscription] of this.columnSubscriptions.entries()) {
|
|
1429
|
+
if (!expectedColumnKeys.has(key)) {
|
|
1430
|
+
subscription.unsubscribe();
|
|
1431
|
+
this.columnSubscriptions.delete(key);
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
for (const [key, subscription] of this.rowSubscriptions.entries()) {
|
|
1435
|
+
if (!expectedRowKeys.has(key)) {
|
|
1436
|
+
subscription.unsubscribe();
|
|
1437
|
+
this.rowSubscriptions.delete(key);
|
|
1438
|
+
}
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ValidationService, deps: [{ token: EventsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1442
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ValidationService }); }
|
|
1443
|
+
}
|
|
1444
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ValidationService, decorators: [{
|
|
1445
|
+
type: Injectable
|
|
1446
|
+
}], ctorParameters: () => [{ type: EventsService }] });
|
|
1447
|
+
|
|
1448
|
+
//TODO Abstract Datasource service
|
|
1449
|
+
class DatasourceService {
|
|
1450
|
+
constructor(fm, columnsService, cellValueChangeService, validationService) {
|
|
1451
|
+
this.fm = fm;
|
|
1452
|
+
this.columnsService = columnsService;
|
|
1453
|
+
this.cellValueChangeService = cellValueChangeService;
|
|
1454
|
+
this.validationService = validationService;
|
|
1455
|
+
this.destroyRef = inject(DestroyRef);
|
|
1456
|
+
}
|
|
1457
|
+
register() {
|
|
1458
|
+
this.createDataSource();
|
|
1459
|
+
this.listen();
|
|
1460
|
+
}
|
|
1461
|
+
get datasource() {
|
|
1462
|
+
return this._datasource;
|
|
1463
|
+
}
|
|
1464
|
+
createDataSource() {
|
|
1465
|
+
this._datasource = new KlesDataSource();
|
|
1466
|
+
}
|
|
1467
|
+
listen() {
|
|
1468
|
+
this.fm.rowsStructureChanged$.pipe(takeUntilDestroyed(this.destroyRef), startWith(void 0)).subscribe(() => {
|
|
1469
|
+
this._datasource.data = this.fm.rows;
|
|
1470
|
+
});
|
|
1471
|
+
this.datasource
|
|
1472
|
+
.connect()
|
|
1473
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
1474
|
+
.subscribe((rows) => {
|
|
1475
|
+
this.cellValueChangeService.listen(rows, this.columnsService.getVisible());
|
|
1476
|
+
this.validationService.listen(rows, this.columnsService.getVisible());
|
|
1477
|
+
});
|
|
1478
|
+
}
|
|
1479
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: DatasourceService, deps: [{ token: KlesForm }, { token: ColumnsService }, { token: CellValueChangeService }, { token: ValidationService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1480
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: DatasourceService }); }
|
|
1481
|
+
}
|
|
1482
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: DatasourceService, decorators: [{
|
|
1483
|
+
type: Injectable
|
|
1484
|
+
}], ctorParameters: () => [{ type: KlesForm }, { type: ColumnsService }, { type: CellValueChangeService }, { type: ValidationService }] });
|
|
1485
|
+
class DatasourceLazyService {
|
|
1486
|
+
constructor(fm, columnsService, cellValueChangeService, validationService) {
|
|
1487
|
+
this.fm = fm;
|
|
1488
|
+
this.columnsService = columnsService;
|
|
1489
|
+
this.cellValueChangeService = cellValueChangeService;
|
|
1490
|
+
this.validationService = validationService;
|
|
1491
|
+
this.destroyRef = inject(DestroyRef);
|
|
1492
|
+
}
|
|
1493
|
+
register() {
|
|
1494
|
+
this.createDataSource();
|
|
1495
|
+
this.listen();
|
|
1496
|
+
}
|
|
1497
|
+
get datasource() {
|
|
1498
|
+
return this._datasource;
|
|
1499
|
+
}
|
|
1500
|
+
createDataSource() {
|
|
1501
|
+
this._datasource = new KlesLazyDataSource();
|
|
1502
|
+
}
|
|
1503
|
+
listen() {
|
|
1504
|
+
this.fm.rowsStructureChanged$.pipe(takeUntilDestroyed(this.destroyRef), startWith(void 0)).subscribe(() => {
|
|
1505
|
+
this._datasource.data = this.fm.rows;
|
|
1506
|
+
});
|
|
1507
|
+
this.datasource
|
|
1508
|
+
.connect()
|
|
1509
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
1510
|
+
.subscribe((rows) => {
|
|
1511
|
+
this.cellValueChangeService.listen(rows, this.columnsService.getVisible());
|
|
1512
|
+
this.validationService.listen(rows, this.columnsService.getVisible());
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: DatasourceLazyService, deps: [{ token: KlesForm }, { token: ColumnsService }, { token: CellValueChangeService }, { token: ValidationService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1516
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: DatasourceLazyService }); }
|
|
1517
|
+
}
|
|
1518
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: DatasourceLazyService, decorators: [{
|
|
1519
|
+
type: Injectable
|
|
1520
|
+
}], ctorParameters: () => [{ type: KlesForm }, { type: ColumnsService }, { type: CellValueChangeService }, { type: ValidationService }] });
|
|
1521
|
+
|
|
1522
|
+
class FilterService {
|
|
1523
|
+
constructor(columnsService, datasourceService) {
|
|
1524
|
+
this.columnsService = columnsService;
|
|
1525
|
+
this.datasourceService = datasourceService;
|
|
1526
|
+
}
|
|
1527
|
+
register() {
|
|
1528
|
+
this.datasourceService.datasource.filterPredicate = this.createFilterPredicate();
|
|
1529
|
+
}
|
|
1530
|
+
formatData(data) {
|
|
1531
|
+
return data;
|
|
1532
|
+
}
|
|
1533
|
+
createFilterPredicate() {
|
|
1534
|
+
return (data, filter) => {
|
|
1535
|
+
let searchString = JSON.parse(filter);
|
|
1536
|
+
const filterableColumn = this.columnsService
|
|
1537
|
+
.columns()
|
|
1538
|
+
.filter((f) => f.filterable)
|
|
1539
|
+
.map((m) => m.columnDef);
|
|
1540
|
+
searchString = _.pick(searchString, filterableColumn);
|
|
1541
|
+
return Object.keys(searchString)
|
|
1542
|
+
.filter((f) => searchString[f] && filterableColumn.includes(f))
|
|
1543
|
+
.every((key) => {
|
|
1544
|
+
let keyValue = data?.controls[key]?.value;
|
|
1545
|
+
const column = this.columnsService.columns().find((col) => col.columnDef === key);
|
|
1546
|
+
if (column) {
|
|
1547
|
+
if (column.headerCell.filterPredicate) {
|
|
1548
|
+
return column.headerCell.filterPredicate(keyValue, searchString[key]) || false;
|
|
1549
|
+
}
|
|
1550
|
+
if (keyValue != null && typeof keyValue === 'object' && column.cell.field.property) {
|
|
1551
|
+
keyValue = keyValue[column.cell.field.property];
|
|
1552
|
+
}
|
|
1553
|
+
if (searchString?.[key] && typeof searchString[key] === 'object') {
|
|
1554
|
+
if (Array.isArray(searchString[key])) {
|
|
1555
|
+
if (!searchString[key].length) {
|
|
1556
|
+
return true;
|
|
1557
|
+
}
|
|
1558
|
+
const list = searchString[key]
|
|
1559
|
+
.map((m) => {
|
|
1560
|
+
const subkey = column.headerCell.field?.property ?? column.cell.field.property;
|
|
1561
|
+
if (subkey) {
|
|
1562
|
+
return m?.[subkey] ?? m;
|
|
1563
|
+
}
|
|
1564
|
+
return m;
|
|
1565
|
+
})
|
|
1566
|
+
.map((value) => {
|
|
1567
|
+
return typeof value === 'string' ? value?.trim().toLowerCase() : value;
|
|
1568
|
+
});
|
|
1569
|
+
return keyValue != undefined && list.includes(keyValue.toString().trim().toLowerCase());
|
|
1570
|
+
}
|
|
1571
|
+
else {
|
|
1572
|
+
const subKey = column.headerCell.field?.property ?? column.cell.field.property;
|
|
1573
|
+
if (subKey) {
|
|
1574
|
+
searchString[key] = searchString[key][subKey];
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
if (keyValue === null && searchString?.[key].length === 0) {
|
|
1580
|
+
return true;
|
|
1581
|
+
}
|
|
1582
|
+
else if (keyValue === null) {
|
|
1583
|
+
return false;
|
|
1584
|
+
}
|
|
1585
|
+
else if (searchString?.[key] === null) {
|
|
1586
|
+
return true;
|
|
1587
|
+
}
|
|
1588
|
+
return keyValue !== null && keyValue.toString().trim().toLowerCase().indexOf(searchString?.[key].toString().toLowerCase()) !== -1;
|
|
1589
|
+
});
|
|
1590
|
+
};
|
|
1591
|
+
}
|
|
1592
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: FilterService, deps: [{ token: ColumnsService }, { token: DATASOURCE_SERVICE }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1593
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: FilterService }); }
|
|
1594
|
+
}
|
|
1595
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: FilterService, decorators: [{
|
|
1596
|
+
type: Injectable
|
|
1597
|
+
}], ctorParameters: () => [{ type: ColumnsService }, { type: DatasourceService, decorators: [{
|
|
1598
|
+
type: Inject,
|
|
1599
|
+
args: [DATASOURCE_SERVICE]
|
|
1600
|
+
}] }] });
|
|
1601
|
+
|
|
1602
|
+
class RowService {
|
|
1603
|
+
constructor(eventsService) {
|
|
1604
|
+
this.eventsService = eventsService;
|
|
1605
|
+
}
|
|
1606
|
+
onClick(event, row, rowIndex) {
|
|
1607
|
+
this.eventsService.emit('rowClick', {
|
|
1608
|
+
row,
|
|
1609
|
+
rowIndex,
|
|
1610
|
+
value: row.value,
|
|
1611
|
+
rawValue: row.getRawValue(),
|
|
1612
|
+
event,
|
|
1613
|
+
});
|
|
1614
|
+
}
|
|
1615
|
+
onDoubleClick(event, row, rowIndex) {
|
|
1616
|
+
this.eventsService.emit('rowDoubleClick', {
|
|
1617
|
+
row,
|
|
1618
|
+
rowIndex,
|
|
1619
|
+
value: row.value,
|
|
1620
|
+
rawValue: row.getRawValue(),
|
|
1621
|
+
event,
|
|
1622
|
+
});
|
|
1623
|
+
}
|
|
1624
|
+
onContextMenu(event, row, rowIndex) {
|
|
1625
|
+
event.preventDefault();
|
|
1626
|
+
event.stopPropagation();
|
|
1627
|
+
this.eventsService.emit('rowContextMenu', {
|
|
1628
|
+
row,
|
|
1629
|
+
rowIndex,
|
|
1630
|
+
value: row.value,
|
|
1631
|
+
rawValue: row.getRawValue(),
|
|
1632
|
+
event,
|
|
1633
|
+
});
|
|
1634
|
+
}
|
|
1635
|
+
onMouseEnter(event, row, rowIndex) {
|
|
1636
|
+
this.eventsService.emit('rowMouseEnter', {
|
|
1637
|
+
row,
|
|
1638
|
+
rowIndex,
|
|
1639
|
+
value: row.value,
|
|
1640
|
+
rawValue: row.getRawValue(),
|
|
1641
|
+
event,
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
onMouseLeave(event, row, rowIndex) {
|
|
1645
|
+
this.eventsService.emit('rowMouseLeave', {
|
|
1646
|
+
row,
|
|
1647
|
+
rowIndex,
|
|
1648
|
+
value: row.value,
|
|
1649
|
+
rawValue: row.getRawValue(),
|
|
1650
|
+
event,
|
|
1651
|
+
});
|
|
1652
|
+
}
|
|
1653
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: RowService, deps: [{ token: EventsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1654
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: RowService }); }
|
|
1655
|
+
}
|
|
1656
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: RowService, decorators: [{
|
|
1657
|
+
type: Injectable
|
|
1658
|
+
}], ctorParameters: () => [{ type: EventsService }] });
|
|
1659
|
+
|
|
1660
|
+
class CellService {
|
|
1661
|
+
constructor(eventsService) {
|
|
1662
|
+
this.eventsService = eventsService;
|
|
1663
|
+
}
|
|
1664
|
+
onClick(event, row, rowIndex, columnDef) {
|
|
1665
|
+
const control = row.get(columnDef);
|
|
1666
|
+
this.eventsService.emit('cellClick', {
|
|
1667
|
+
row,
|
|
1668
|
+
rowIndex,
|
|
1669
|
+
value: control?.value,
|
|
1670
|
+
rawValue: row.getRawValue(),
|
|
1671
|
+
event,
|
|
1672
|
+
columnDef,
|
|
1673
|
+
control,
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
onDoubleClick(event, row, rowIndex, columnDef) {
|
|
1677
|
+
const control = row.get(columnDef);
|
|
1678
|
+
this.eventsService.emit('cellDoubleClick', {
|
|
1679
|
+
row,
|
|
1680
|
+
rowIndex,
|
|
1681
|
+
value: control?.value,
|
|
1682
|
+
rawValue: row.getRawValue(),
|
|
1683
|
+
event,
|
|
1684
|
+
columnDef,
|
|
1685
|
+
control,
|
|
1686
|
+
});
|
|
1687
|
+
}
|
|
1688
|
+
onContextMenu(event, row, rowIndex, columnDef) {
|
|
1689
|
+
event.preventDefault();
|
|
1690
|
+
event.stopPropagation();
|
|
1691
|
+
const control = row.get(columnDef);
|
|
1692
|
+
this.eventsService.emit('cellContextMenu', {
|
|
1693
|
+
row,
|
|
1694
|
+
rowIndex,
|
|
1695
|
+
value: control?.value,
|
|
1696
|
+
rawValue: row.getRawValue(),
|
|
1697
|
+
event,
|
|
1698
|
+
columnDef,
|
|
1699
|
+
control,
|
|
1700
|
+
});
|
|
1701
|
+
}
|
|
1702
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: CellService, deps: [{ token: EventsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1703
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: CellService }); }
|
|
1704
|
+
}
|
|
1705
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: CellService, decorators: [{
|
|
1706
|
+
type: Injectable
|
|
1707
|
+
}], ctorParameters: () => [{ type: EventsService }] });
|
|
1708
|
+
|
|
1709
|
+
class DragDropBase {
|
|
1710
|
+
constructor(config) {
|
|
1711
|
+
this.config = config;
|
|
1712
|
+
}
|
|
1713
|
+
get enable() {
|
|
1714
|
+
return this.config?.enable || false;
|
|
1715
|
+
}
|
|
1716
|
+
get autoScrollStep() {
|
|
1717
|
+
return this.config?.options?.autoScrollStep ?? true;
|
|
1718
|
+
}
|
|
1719
|
+
get connectedTo() {
|
|
1720
|
+
return this.config?.options?.connectedTo;
|
|
1721
|
+
}
|
|
1722
|
+
get sortPredicate() {
|
|
1723
|
+
return (index, item) => {
|
|
1724
|
+
return true;
|
|
1725
|
+
};
|
|
1726
|
+
}
|
|
1727
|
+
get previewComponent() {
|
|
1728
|
+
return this.config?.options?.dragPreview?.component;
|
|
1729
|
+
}
|
|
1730
|
+
get previewMatchSize() {
|
|
1731
|
+
return this.config?.options?.dragPreview?.matchSize || true;
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
class DragDropService extends DragDropBase {
|
|
1735
|
+
constructor(config, paginatorStore) {
|
|
1736
|
+
super(config);
|
|
1737
|
+
this.config = config;
|
|
1738
|
+
this.paginatorStore = paginatorStore;
|
|
1739
|
+
}
|
|
1740
|
+
listDropped(event) {
|
|
1741
|
+
if (event.previousContainer === event.container) {
|
|
1742
|
+
const faRows = event.container.data;
|
|
1743
|
+
const currentIndex = event.currentIndex + (this.paginatorStore?.snapshot().page ?? 0) * (this.paginatorStore?.snapshot().perPage ?? 0);
|
|
1744
|
+
const previousIndex = event.previousIndex + (this.paginatorStore?.snapshot().page ?? 0) * (this.paginatorStore?.snapshot().perPage ?? 0);
|
|
1745
|
+
if (previousIndex >= 0) {
|
|
1746
|
+
const ctrl = faRows.at(previousIndex);
|
|
1747
|
+
faRows.removeAt(previousIndex, { emitEvent: false });
|
|
1748
|
+
faRows.insert(currentIndex, ctrl, { emitEvent: false });
|
|
1749
|
+
faRows.updateValueAndValidity({ emitEvent: true });
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
else {
|
|
1753
|
+
//TODO
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: DragDropService, deps: [{ token: DRAG_DROP_CONFIG, optional: true }, { token: PaginatorStore, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1757
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: DragDropService }); }
|
|
1758
|
+
}
|
|
1759
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: DragDropService, decorators: [{
|
|
1760
|
+
type: Injectable
|
|
1761
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1762
|
+
type: Optional
|
|
1763
|
+
}, {
|
|
1764
|
+
type: Inject,
|
|
1765
|
+
args: [DRAG_DROP_CONFIG]
|
|
1766
|
+
}] }, { type: PaginatorStore, decorators: [{
|
|
1767
|
+
type: Optional
|
|
1768
|
+
}] }] });
|
|
1769
|
+
class DragDropLazyService extends DragDropBase {
|
|
1770
|
+
constructor(config) {
|
|
1771
|
+
super(config);
|
|
1772
|
+
this.config = config;
|
|
1773
|
+
}
|
|
1774
|
+
listDropped(event) {
|
|
1775
|
+
console.log('lazy');
|
|
1776
|
+
// TODO appeler un observable + refresh tableau
|
|
1777
|
+
}
|
|
1778
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: DragDropLazyService, deps: [{ token: DRAG_DROP_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1779
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: DragDropLazyService }); }
|
|
1780
|
+
}
|
|
1781
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: DragDropLazyService, decorators: [{
|
|
1782
|
+
type: Injectable
|
|
1783
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1784
|
+
type: Optional
|
|
1785
|
+
}, {
|
|
1786
|
+
type: Inject,
|
|
1787
|
+
args: [DRAG_DROP_CONFIG]
|
|
1788
|
+
}] }] });
|
|
1789
|
+
|
|
1790
|
+
class TableComponent {
|
|
1791
|
+
constructor(host, connectorService, loader, datasourceService, tableService, dragDropRowService, selectionService, columnsService, loadingService, paginatorService, scrollbarService, footerService, extraRowService, renderService, sortService, filterService, expandedRowStore, rowFactory, eventsService, rowService, cellService) {
|
|
1792
|
+
this.host = host;
|
|
1793
|
+
this.connectorService = connectorService;
|
|
1794
|
+
this.loader = loader;
|
|
1795
|
+
this.datasourceService = datasourceService;
|
|
1796
|
+
this.tableService = tableService;
|
|
1797
|
+
this.dragDropRowService = dragDropRowService;
|
|
1798
|
+
this.selectionService = selectionService;
|
|
1799
|
+
this.columnsService = columnsService;
|
|
1800
|
+
this.loadingService = loadingService;
|
|
1801
|
+
this.paginatorService = paginatorService;
|
|
1802
|
+
this.scrollbarService = scrollbarService;
|
|
1803
|
+
this.footerService = footerService;
|
|
1804
|
+
this.extraRowService = extraRowService;
|
|
1805
|
+
this.renderService = renderService;
|
|
1806
|
+
this.sortService = sortService;
|
|
1807
|
+
this.filterService = filterService;
|
|
1808
|
+
this.expandedRowStore = expandedRowStore;
|
|
1809
|
+
this.rowFactory = rowFactory;
|
|
1810
|
+
this.eventsService = eventsService;
|
|
1811
|
+
this.rowService = rowService;
|
|
1812
|
+
this.cellService = cellService;
|
|
1813
|
+
this.headerHeightPx = 56;
|
|
1814
|
+
this.scrollHeightPx = 0;
|
|
1815
|
+
this.footerHeightPx = 0;
|
|
1816
|
+
this.destroyRef = inject(DestroyRef);
|
|
1817
|
+
this.columns = this.columnsService.columns;
|
|
1818
|
+
this.displayedColumns = this.columnsService.displayedColumns;
|
|
1819
|
+
this.showFooter = this.footerService.footer;
|
|
1820
|
+
this.dataSource = this.datasourceService.datasource;
|
|
1821
|
+
this.multiTemplateDataRows = this.extraRowService.multiTemplateDataRows;
|
|
1822
|
+
this.extraRows = this.extraRowService.rows;
|
|
1823
|
+
this.connectorService.connect(this);
|
|
1824
|
+
this.filterService?.register();
|
|
1825
|
+
}
|
|
1826
|
+
get isLoadingClass() {
|
|
1827
|
+
return this.loadingService.loading();
|
|
1828
|
+
}
|
|
1829
|
+
get events() {
|
|
1830
|
+
return {
|
|
1831
|
+
listen: () => this.eventsService.events$,
|
|
1832
|
+
};
|
|
1833
|
+
}
|
|
1834
|
+
get form() {
|
|
1835
|
+
return {
|
|
1836
|
+
header: {
|
|
1837
|
+
clear: (value, options) => this.tableService.klesForm.getHeader().reset(value, options),
|
|
1838
|
+
get: () => this.tableService.klesForm.getHeader(),
|
|
1839
|
+
setValue: (value, options) => this.tableService.klesForm.getHeader().setValue(value, options),
|
|
1840
|
+
patchValue: (value, options) => this.tableService.klesForm.getHeader().patchValue(value, options),
|
|
1841
|
+
},
|
|
1842
|
+
footer: {
|
|
1843
|
+
clear: (value, options) => this.tableService.klesForm.getFooter().reset(value, options),
|
|
1844
|
+
get: () => this.tableService.klesForm.getFooter(),
|
|
1845
|
+
setValue: (value, options) => this.tableService.klesForm.getFooter().setValue(value, options),
|
|
1846
|
+
patchValue: (value, options) => this.tableService.klesForm.getFooter().patchValue(value, options),
|
|
1847
|
+
},
|
|
1848
|
+
rows: {
|
|
1849
|
+
list: () => this.tableService.klesForm.getRows(),
|
|
1850
|
+
get: (_id) => this.tableService.klesForm.getRows().controls.find((row) => row.value._id === _id),
|
|
1851
|
+
create: (value, index, options) => {
|
|
1852
|
+
return this.tableService.klesForm.insertRow(this.rowFactory.createRow(this.columnsService
|
|
1853
|
+
.columns()
|
|
1854
|
+
.map((col) => ({ ...col.cell.field, name: col.columnDef }))
|
|
1855
|
+
.concat(this.extraRowService.extraColumns().map((col) => ({ ...col, name: col.columnDef }))), value), index, options).formGroup;
|
|
1856
|
+
},
|
|
1857
|
+
patch: (_id, value, options) => {
|
|
1858
|
+
return this.tableService.klesForm.updateRow(_id, value, options);
|
|
1859
|
+
},
|
|
1860
|
+
remove: (_id, options) => {
|
|
1861
|
+
this.tableService.klesForm.deleteRowById(_id, options);
|
|
1862
|
+
},
|
|
1863
|
+
reset: (_id, value, options) => {
|
|
1864
|
+
this.tableService.klesForm.resetRow(_id, value, options);
|
|
1865
|
+
},
|
|
1866
|
+
},
|
|
1867
|
+
};
|
|
1868
|
+
}
|
|
1869
|
+
get scrollbar() {
|
|
1870
|
+
return {
|
|
1871
|
+
getTop: () => this.scrollbarService.getTop(),
|
|
1872
|
+
to: (top, left, sb) => this.scrollbarService.to(top, left, sb),
|
|
1873
|
+
toTop: (sb) => this.scrollbarService.toTop(sb),
|
|
1874
|
+
toLeft: (sb) => this.scrollbarService.toLeft(sb),
|
|
1875
|
+
toBottom: (sb) => this.scrollbarService.toBottom(sb),
|
|
1876
|
+
toRight: (sb) => this.scrollbarService.toRight(sb),
|
|
1877
|
+
};
|
|
1878
|
+
}
|
|
1879
|
+
get column() {
|
|
1880
|
+
return {
|
|
1881
|
+
setVisible: (columnDef, visible) => this.columnsService.setVisible(columnDef, visible),
|
|
1882
|
+
toggleVisible: (columnDef) => this.columnsService.toggleVisible(columnDef),
|
|
1883
|
+
changeWidth: (columnDef, options) => this.columnsService.changeWidth(columnDef, options),
|
|
1884
|
+
setResizable: (columnDef, resizable) => this.columnsService.setResizable(columnDef, resizable),
|
|
1885
|
+
toggleResizable: (columnDef) => this.columnsService.toggleResizable(columnDef),
|
|
1886
|
+
setSticky: (columnDef, options) => this.columnsService.setSticky(columnDef, options),
|
|
1887
|
+
columns: () => this.columnsService.columns(),
|
|
1888
|
+
setColumnPosition: (columnDef, position) => this.columnsService.setColumnPosition(columnDef, position),
|
|
1889
|
+
};
|
|
1890
|
+
}
|
|
1891
|
+
get pagination() {
|
|
1892
|
+
return {
|
|
1893
|
+
setPageIndex: (index) => this.paginatorService.setPageIndex(index),
|
|
1894
|
+
setPageSize: (size) => this.paginatorService.setPageSize(size),
|
|
1895
|
+
firstPage: () => this.paginatorService.firstPage(),
|
|
1896
|
+
lastPage: () => this.paginatorService.lastPage(),
|
|
1897
|
+
enable: () => this.paginatorService.enable(),
|
|
1898
|
+
disable: () => this.paginatorService.disable(),
|
|
1899
|
+
setPageSizeOptions: (option) => this.paginatorService.setPageSizeOptions(option),
|
|
1900
|
+
page: this.paginatorService.pageChanged(),
|
|
1901
|
+
};
|
|
1902
|
+
}
|
|
1903
|
+
get selection() {
|
|
1904
|
+
return {
|
|
1905
|
+
disable: () => this.selectionService.disable(),
|
|
1906
|
+
enable: () => this.selectionService.enable(),
|
|
1907
|
+
count: this.selectionService.count(),
|
|
1908
|
+
selectionModel: this.selectionService.selectionModel,
|
|
1909
|
+
// changed: () => {},
|
|
1910
|
+
// isEmpty: () => {},
|
|
1911
|
+
// isMultipleSelection: () => {},
|
|
1912
|
+
// selected: () => {},
|
|
1913
|
+
};
|
|
1914
|
+
}
|
|
1915
|
+
get sort() {
|
|
1916
|
+
return {
|
|
1917
|
+
setActive: (active) => this.sortService.setActive(active),
|
|
1918
|
+
setDirection: (direction) => this.sortService.setDirection(direction),
|
|
1919
|
+
sortChange: () => this.sortService.sortChange(),
|
|
1920
|
+
};
|
|
1921
|
+
}
|
|
1922
|
+
get loading() {
|
|
1923
|
+
return {
|
|
1924
|
+
start: () => this.loadingService.start(),
|
|
1925
|
+
stop: () => this.loadingService.stop(),
|
|
1926
|
+
};
|
|
1927
|
+
}
|
|
1928
|
+
get footer() {
|
|
1929
|
+
return {
|
|
1930
|
+
hide: () => this.footerService.hide(),
|
|
1931
|
+
show: () => this.footerService.show(),
|
|
1932
|
+
};
|
|
1933
|
+
}
|
|
1934
|
+
get ui() {
|
|
1935
|
+
return this.tableService.ui;
|
|
1936
|
+
}
|
|
1937
|
+
refresh() {
|
|
1938
|
+
this.loader.refresh();
|
|
1939
|
+
}
|
|
1940
|
+
ngOnInit() {
|
|
1941
|
+
this.sortService.register(this.matSort);
|
|
1942
|
+
const el = this.formElemRef.nativeElement;
|
|
1943
|
+
this.scrollbarService.register(el);
|
|
1944
|
+
this.renderService
|
|
1945
|
+
.render()
|
|
1946
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
1947
|
+
.subscribe(() => {
|
|
1948
|
+
this.table?.renderRows();
|
|
1949
|
+
});
|
|
1950
|
+
this.expandedRowStore.expandedIds$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
|
1951
|
+
this.table?.renderRows();
|
|
1952
|
+
});
|
|
1953
|
+
}
|
|
1954
|
+
ngAfterViewInit() {
|
|
1955
|
+
this.calculHeaderHeight();
|
|
1956
|
+
}
|
|
1957
|
+
ngOnDestroy() {
|
|
1958
|
+
this._cleanup?.();
|
|
1959
|
+
this.scrollbarService.unregister();
|
|
1960
|
+
}
|
|
1961
|
+
submit() {
|
|
1962
|
+
// TODO
|
|
1963
|
+
}
|
|
1964
|
+
calculHeaderHeight() {
|
|
1965
|
+
const formNativeElem = this.formElemRef?.nativeElement;
|
|
1966
|
+
const header = this.host.nativeElement.querySelector('.mat-mdc-header-row');
|
|
1967
|
+
const footer = this.host.nativeElement.querySelector('.mat-mdc-footer-row');
|
|
1968
|
+
const compute = () => {
|
|
1969
|
+
this.scrollHeightPx = Math.max(0, (formNativeElem?.offsetHeight ?? 0) - (formNativeElem?.clientHeight ?? 0));
|
|
1970
|
+
this.headerHeightPx = Math.ceil(header?.getBoundingClientRect().height ?? 0);
|
|
1971
|
+
this.footerHeightPx = Math.max(0, footer?.getBoundingClientRect().height ?? 0);
|
|
1972
|
+
};
|
|
1973
|
+
const scheduleCompute = () => {
|
|
1974
|
+
if (this.rafId) {
|
|
1975
|
+
cancelAnimationFrame(this.rafId);
|
|
1976
|
+
}
|
|
1977
|
+
this.rafId = requestAnimationFrame(() => {
|
|
1978
|
+
compute();
|
|
1979
|
+
this.rafId = requestAnimationFrame(compute);
|
|
1980
|
+
});
|
|
1981
|
+
};
|
|
1982
|
+
scheduleCompute();
|
|
1983
|
+
this.ro = new ResizeObserver(scheduleCompute);
|
|
1984
|
+
if (formNativeElem) {
|
|
1985
|
+
this.ro.observe(formNativeElem);
|
|
1986
|
+
}
|
|
1987
|
+
if (header) {
|
|
1988
|
+
this.ro.observe(header);
|
|
1989
|
+
}
|
|
1990
|
+
if (footer) {
|
|
1991
|
+
this.ro.observe(footer);
|
|
1992
|
+
}
|
|
1993
|
+
if (formNativeElem) {
|
|
1994
|
+
formNativeElem.addEventListener('scroll', scheduleCompute, { passive: true });
|
|
1995
|
+
window.addEventListener('resize', scheduleCompute, { passive: true });
|
|
1996
|
+
this._cleanup = () => {
|
|
1997
|
+
formNativeElem.removeEventListener('scroll', scheduleCompute);
|
|
1998
|
+
window.removeEventListener('resize', scheduleCompute);
|
|
1999
|
+
this.ro?.disconnect();
|
|
2000
|
+
if (this.rafId) {
|
|
2001
|
+
cancelAnimationFrame(this.rafId);
|
|
2002
|
+
}
|
|
2003
|
+
};
|
|
2004
|
+
}
|
|
2005
|
+
}
|
|
2006
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: TableComponent, deps: [{ token: i0.ElementRef }, { token: KlesTableConnectorService }, { token: LOADER_SERVICE }, { token: DATASOURCE_SERVICE }, { token: TABLE_SERVICE }, { token: ROW_DRAG_DROP }, { token: SELECTION_SERVICE }, { token: ColumnsService }, { token: LoadingService }, { token: PaginatorService }, { token: ScrollbarService }, { token: FooterService }, { token: ExtraRowService }, { token: RenderService }, { token: SORT_SERVICE }, { token: FilterService, optional: true }, { token: ExpandedRowStore }, { token: RowFormFactory }, { token: EventsService }, { token: RowService }, { token: CellService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2007
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.19", type: TableComponent, isStandalone: true, selector: "kles-table", host: { properties: { "class.loading": "this.isLoadingClass" } }, viewQueries: [{ propertyName: "table", first: true, predicate: MatTable, descendants: true }, { propertyName: "matSort", first: true, predicate: MatSort, descendants: true, static: true }, { propertyName: "formElemRef", first: true, predicate: ["form"], descendants: true, static: true }], ngImport: i0, template: "<form #form [formGroup]=\"tableService.form\" (ngSubmit)=\"submit()\">\n <!-- [fixedLayout]=\"true\" -->\n <table\n mat-table\n [dataSource]=\"dataSource\"\n matSort\n [trackBy]=\"multiTemplateDataRows() ? null : tableService.trackBy\"\n class=\"mat-elevation-z2\"\n formArrayName=\"rows\"\n cdkDropList\n [cdkDropListData]=\"tableService.form.controls.rows\"\n (cdkDropListDropped)=\"dragDropRowService.listDropped($event)\"\n [cdkDropListDisabled]=\"!dragDropRowService.enable\"\n [cdkDropListAutoScrollStep]=\"dragDropRowService.autoScrollStep\"\n [cdkDropListSortPredicate]=\"dragDropRowService.sortPredicate\"\n [cdkDropListConnectedTo]=\"dragDropRowService.connectedTo\"\n class=\"mat-elevation-z1\"\n [multiTemplateDataRows]=\"multiTemplateDataRows()\"\n >\n <colgroup>\n @for (column of columns(); track column.columnDef) {\n <col [style.width]=\"column.width ?? null\" [style.minWidth]=\"column.minWidth ?? null\" [style.maxWidth]=\"column.maxWidth ?? null\" />\n }\n </colgroup>\n\n @for (column of columns(); track column.columnDef) {\n <ng-container [cdkColumnDef]=\"column.columnDef\" [sticky]=\"column.sticky ?? false\" [stickyEnd]=\"column.stickyEnd ?? false\">\n <th\n mat-header-cell\n *matHeaderCellDef\n [appResizableColumn]=\"column\"\n [ngStyle]=\"\n column.headerCell?.style?.ngStyle\n | resolveNgStyle\n : tableService.form.get(['header', column.columnDef])?.value\n : tableService.form.get(['header', column.columnDef])?.status\n : tableService.form.controls.header.value\n : tableService.form.controls.header.status\n \"\n >\n <div class=\"cell\">\n <kles-header [header]=\"column | header\" [group]=\"tableService.form.controls.header\">\n <ng-container\n klesDynamicField\n [field]=\"column | headerField\"\n [group]=\"tableService.form.controls.header\"\n [ui]=\"tableService.ui.states.header\"\n ></ng-container>\n </kles-header>\n </div>\n </th>\n\n <td\n mat-cell\n *cdkCellDef=\"let row; let index = index; let dataIndex = dataIndex\"\n [ngStyle]=\"\n column.cell?.style?.ngStyle\n | resolveNgStyle: row.controls[column.columnDef].value : row.controls[column.columnDef].status : row.value : row.status\n \"\n (click)=\"cellService.onClick($event, row, dataIndex ?? index, column.columnDef)\"\n (dblclick)=\"cellService.onDoubleClick($event, row, dataIndex ?? index, column.columnDef)\"\n (contextmenu)=\"cellService.onContextMenu($event, row, dataIndex ?? index, column.columnDef)\"\n >\n <div class=\"cell\" [style.--align]=\"column.align\">\n <kles-cell [group]=\"row\" [ui]=\"row | uiField\" [column]=\"column\">\n <ng-container klesDynamicField [field]=\"column | cellField\" [group]=\"row\" [ui]=\"row | uiField\"></ng-container>\n </kles-cell>\n </div>\n </td>\n\n <td\n mat-footer-cell\n *matFooterCellDef\n [ngStyle]=\"\n column.footerCell?.style?.ngStyle\n | resolveNgStyle\n : tableService.form.get(['footer', column.columnDef])?.value\n : tableService.form.get(['footer', column.columnDef])?.status\n : tableService.form.controls.footer.value\n : tableService.form.controls.footer.status\n \"\n >\n @if (column.footerCell) {\n <ng-container\n klesDynamicField\n [field]=\"column | footerField\"\n [group]=\"tableService.form.controls.footer\"\n [ui]=\"tableService.ui.states.footer\"\n >\n </ng-container>\n }\n </td>\n </ng-container>\n }\n\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns(); sticky: true\"></tr>\n\n <tr\n mat-row\n *matRowDef=\"let row; let index = index; let dataIndex = dataIndex; columns: displayedColumns()\"\n cdkDrag\n [cdkDragData]=\"row\"\n (click)=\"rowService.onClick($event, row, dataIndex ?? index)\"\n (dblclick)=\"rowService.onDoubleClick($event, row, dataIndex ?? index)\"\n (contextmenu)=\"rowService.onContextMenu($event, row, dataIndex ?? index)\"\n (mouseenter)=\"rowService.onMouseEnter($event, row, dataIndex ?? index)\"\n (mouseleave)=\"rowService.onMouseLeave($event, row, dataIndex ?? index)\"\n ></tr>\n\n @if (multiTemplateDataRows()) {\n @for (extraRow of extraRows(); track extraRow) {\n @for (extraColumn of extraRow.cells; track extraColumn.columnDef) {\n <ng-container [cdkColumnDef]=\"extraColumn.columnDef\">\n <td\n mat-cell\n *cdkCellDef=\"let row\"\n [attr.colspan]=\"extraColumn.colspan | spanPipe: displayedColumns().length\"\n [attr.rowspan]=\"extraColumn.rowspan\"\n [ngStyle]=\"\n extraColumn?.style?.ngStyle\n | resolveNgStyle\n : row.controls[extraColumn.columnDef].value\n : row.controls[extraColumn.columnDef].status\n : row.value\n : row.status\n \"\n >\n <ng-container klesDynamicField [field]=\"extraColumn | extraCellField\" [group]=\"row\" [ui]=\"row | uiField\"></ng-container>\n </td>\n </ng-container>\n }\n <tr\n mat-row\n *matRowDef=\"let row; let index = index; let dataIndex = dataIndex; columns: extraRow.displayedColumns; when: extraRow.when\"\n (click)=\"rowService.onClick($event, row, dataIndex ?? index)\"\n (dblclick)=\"rowService.onDoubleClick($event, row, dataIndex ?? index)\"\n (contextmenu)=\"rowService.onContextMenu($event, row, dataIndex ?? index)\"\n (mouseenter)=\"rowService.onMouseEnter($event, row, dataIndex ?? index)\"\n (mouseleave)=\"rowService.onMouseLeave($event, row, dataIndex ?? index)\"\n ></tr>\n }\n }\n\n <tr mat-footer-row *matFooterRowDef=\"displayedColumns(); sticky: true\" [style.display]=\"showFooter() ? '' : 'none'\"></tr>\n\n <tr *matNoDataRow [attr.colspan]=\"displayedColumns().length\">\n @if (!loadingService.loading()) {\n no data TODO\n }\n </tr>\n </table>\n</form>\n\n@if (loadingService.loading()) {\n <div class=\"table-overlay\" [style.--header-h.px]=\"headerHeightPx\" [style.--scroll-h.px]=\"scrollHeightPx\" [style.--footer-h.px]=\"footerHeightPx\">\n <mat-spinner></mat-spinner>\n </div>\n}\n", styles: [":host{overflow:auto;display:flex;flex-direction:column;position:relative;height:100%;--mat-form-field-filled-container-color: transparent;--mat-form-field-hover-state-layer-opacity: 0;--mat-form-field-focus-state-layer-opacity: 0;--mat-form-field-state-layer-color: transparent}:host(.loading){min-height:350px}form{display:flex;flex-direction:column;flex-grow:1;position:relative;overflow:auto}table{width:100%;flex-grow:1}.mat-mdc-header-row{background-color:#e2e6eb}th,td{text-wrap:pretty;white-space:normal;padding-top:2px;padding-bottom:2px}td{word-break:normal}th .cell,td .cell{display:flex;flex-direction:column;justify-content:var(--align, center)}th[appResizableColumn]{position:relative}th[appResizableColumn] .resize-handle{position:absolute;top:0;right:-4px;width:8px;height:100%;cursor:col-resize;-webkit-user-select:none;user-select:none}.table-overlay{position:absolute;width:100%;left:0;right:0;top:var(--header-h, 56px);bottom:calc(var(--scroll-h, 0px) + var(--footer-h, 0px));display:grid;place-items:center;background:#8b939a26;z-index:500}:host .mat-mdc-table .mat-mdc-cell,:host .mat-mdc-table .mat-mdc-header-cell{box-shadow:inset -1px 0 #c4c6d0;border-bottom-color:#c4c6d0}:host .mat-mdc-table .mat-mdc-cell:last-child,:host .mat-mdc-table .mat-mdc-header-cell:last-child{border-right:none}:host tr.mat-mdc-footer-row td.mat-mdc-footer-cell{box-shadow:inset 0 1px #c4c6d0}:host tr.mat-mdc-row:last-of-type td.mat-mdc-cell{border-bottom:1px solid rgb(196,198,208)}:host tr.mat-mdc-footer-row{font-weight:500}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i15.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i16.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i16.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i16.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i16.FormArrayName, selector: "[formArrayName]", inputs: ["formArrayName"] }, { kind: "ngmodule", type: MatSortModule }, { kind: "directive", type: i4.MatSort, selector: "[matSort]", inputs: ["matSortActive", "matSortStart", "matSortDirection", "matSortDisableClear", "matSortDisabled"], outputs: ["matSortChange"], exportAs: ["matSort"] }, { kind: "ngmodule", type: MatTableModule }, { kind: "component", type: i18.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { kind: "directive", type: i18.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { kind: "directive", type: i18.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { kind: "directive", type: i18.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { kind: "directive", type: i18.MatFooterCellDef, selector: "[matFooterCellDef]" }, { kind: "directive", type: i18.MatFooterRowDef, selector: "[matFooterRowDef]", inputs: ["matFooterRowDef", "matFooterRowDefSticky"] }, { kind: "directive", type: i18.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { kind: "directive", type: i18.MatCell, selector: "mat-cell, td[mat-cell]" }, { kind: "directive", type: i18.MatFooterCell, selector: "mat-footer-cell, td[mat-footer-cell]" }, { kind: "component", type: i18.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { kind: "component", type: i18.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { kind: "component", type: i18.MatFooterRow, selector: "mat-footer-row, tr[mat-footer-row]", exportAs: ["matFooterRow"] }, { kind: "directive", type: i18.MatNoDataRow, selector: "ng-template[matNoDataRow]" }, { kind: "ngmodule", type: MatFormFieldModule }, { kind: "ngmodule", type: MatInputModule }, { kind: "ngmodule", type: MatIconModule }, { kind: "ngmodule", type: MatButtonModule }, { kind: "ngmodule", type: CdkTableModule }, { kind: "directive", type: i19.CdkCellDef, selector: "[cdkCellDef]" }, { kind: "directive", type: i19.CdkColumnDef, selector: "[cdkColumnDef]", inputs: ["cdkColumnDef", "sticky", "stickyEnd"] }, { kind: "ngmodule", type: KlesMaterialDynamicformsModule }, { kind: "directive", type: i20.KlesDynamicFieldDirective, selector: "[klesDynamicField]", inputs: ["field", "group", "ui", "siblingFields"] }, { kind: "ngmodule", type: DragDropModule }, { kind: "directive", type: i21.CdkDropList, selector: "[cdkDropList], cdk-drop-list", inputs: ["cdkDropListConnectedTo", "cdkDropListData", "cdkDropListOrientation", "id", "cdkDropListLockAxis", "cdkDropListDisabled", "cdkDropListSortingDisabled", "cdkDropListEnterPredicate", "cdkDropListSortPredicate", "cdkDropListAutoScrollDisabled", "cdkDropListAutoScrollStep", "cdkDropListElementContainer", "cdkDropListHasAnchor"], outputs: ["cdkDropListDropped", "cdkDropListEntered", "cdkDropListExited", "cdkDropListSorted"], exportAs: ["cdkDropList"] }, { kind: "directive", type: i21.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragData", "cdkDragLockAxis", "cdkDragRootElement", "cdkDragBoundary", "cdkDragStartDelay", "cdkDragFreeDragPosition", "cdkDragDisabled", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragPreviewContainer", "cdkDragScale"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { kind: "ngmodule", type: MatProgressSpinnerModule }, { kind: "component", type: i22.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }, { kind: "directive", type: ResizableColumnDirective, selector: "th[appResizableColumn]", inputs: ["appResizableColumn"] }, { kind: "component", type: KlesCellComponent, selector: "kles-cell", inputs: ["ui", "group", "column"] }, { kind: "component", type: KlesHeaderComponent, selector: "kles-header", inputs: ["header", "group"] }, { kind: "pipe", type: HeaderFieldPipe, name: "headerField" }, { kind: "pipe", type: CellFieldPipe, name: "cellField" }, { kind: "pipe", type: UiFieldPipe, name: "uiField" }, { kind: "pipe", type: FooterFieldPipe, name: "footerField" }, { kind: "pipe", type: SpanPipe, name: "spanPipe" }, { kind: "pipe", type: ExtraCellFieldPipe, name: "extraCellField" }, { kind: "pipe", type: ResolveNgStylePipe, name: "resolveNgStyle" }, { kind: "pipe", type: HeaderPipe, name: "header" }] }); }
|
|
2008
|
+
}
|
|
2009
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: TableComponent, decorators: [{
|
|
2010
|
+
type: Component,
|
|
2011
|
+
args: [{ selector: 'kles-table', standalone: true, imports: [
|
|
2012
|
+
CommonModule,
|
|
2013
|
+
ReactiveFormsModule,
|
|
2014
|
+
MatSortModule,
|
|
2015
|
+
MatTableModule,
|
|
2016
|
+
MatFormFieldModule,
|
|
2017
|
+
MatInputModule,
|
|
2018
|
+
MatIconModule,
|
|
2019
|
+
MatButtonModule,
|
|
2020
|
+
CdkTableModule,
|
|
2021
|
+
KlesMaterialDynamicformsModule,
|
|
2022
|
+
HeaderFieldPipe,
|
|
2023
|
+
CellFieldPipe,
|
|
2024
|
+
UiFieldPipe,
|
|
2025
|
+
FooterFieldPipe,
|
|
2026
|
+
SpanPipe,
|
|
2027
|
+
ExtraCellFieldPipe,
|
|
2028
|
+
DragDropModule,
|
|
2029
|
+
ResolveNgStylePipe,
|
|
2030
|
+
MatProgressSpinnerModule,
|
|
2031
|
+
ResizableColumnDirective,
|
|
2032
|
+
MatIconModule,
|
|
2033
|
+
KlesCellComponent,
|
|
2034
|
+
KlesHeaderComponent,
|
|
2035
|
+
HeaderPipe,
|
|
2036
|
+
], template: "<form #form [formGroup]=\"tableService.form\" (ngSubmit)=\"submit()\">\n <!-- [fixedLayout]=\"true\" -->\n <table\n mat-table\n [dataSource]=\"dataSource\"\n matSort\n [trackBy]=\"multiTemplateDataRows() ? null : tableService.trackBy\"\n class=\"mat-elevation-z2\"\n formArrayName=\"rows\"\n cdkDropList\n [cdkDropListData]=\"tableService.form.controls.rows\"\n (cdkDropListDropped)=\"dragDropRowService.listDropped($event)\"\n [cdkDropListDisabled]=\"!dragDropRowService.enable\"\n [cdkDropListAutoScrollStep]=\"dragDropRowService.autoScrollStep\"\n [cdkDropListSortPredicate]=\"dragDropRowService.sortPredicate\"\n [cdkDropListConnectedTo]=\"dragDropRowService.connectedTo\"\n class=\"mat-elevation-z1\"\n [multiTemplateDataRows]=\"multiTemplateDataRows()\"\n >\n <colgroup>\n @for (column of columns(); track column.columnDef) {\n <col [style.width]=\"column.width ?? null\" [style.minWidth]=\"column.minWidth ?? null\" [style.maxWidth]=\"column.maxWidth ?? null\" />\n }\n </colgroup>\n\n @for (column of columns(); track column.columnDef) {\n <ng-container [cdkColumnDef]=\"column.columnDef\" [sticky]=\"column.sticky ?? false\" [stickyEnd]=\"column.stickyEnd ?? false\">\n <th\n mat-header-cell\n *matHeaderCellDef\n [appResizableColumn]=\"column\"\n [ngStyle]=\"\n column.headerCell?.style?.ngStyle\n | resolveNgStyle\n : tableService.form.get(['header', column.columnDef])?.value\n : tableService.form.get(['header', column.columnDef])?.status\n : tableService.form.controls.header.value\n : tableService.form.controls.header.status\n \"\n >\n <div class=\"cell\">\n <kles-header [header]=\"column | header\" [group]=\"tableService.form.controls.header\">\n <ng-container\n klesDynamicField\n [field]=\"column | headerField\"\n [group]=\"tableService.form.controls.header\"\n [ui]=\"tableService.ui.states.header\"\n ></ng-container>\n </kles-header>\n </div>\n </th>\n\n <td\n mat-cell\n *cdkCellDef=\"let row; let index = index; let dataIndex = dataIndex\"\n [ngStyle]=\"\n column.cell?.style?.ngStyle\n | resolveNgStyle: row.controls[column.columnDef].value : row.controls[column.columnDef].status : row.value : row.status\n \"\n (click)=\"cellService.onClick($event, row, dataIndex ?? index, column.columnDef)\"\n (dblclick)=\"cellService.onDoubleClick($event, row, dataIndex ?? index, column.columnDef)\"\n (contextmenu)=\"cellService.onContextMenu($event, row, dataIndex ?? index, column.columnDef)\"\n >\n <div class=\"cell\" [style.--align]=\"column.align\">\n <kles-cell [group]=\"row\" [ui]=\"row | uiField\" [column]=\"column\">\n <ng-container klesDynamicField [field]=\"column | cellField\" [group]=\"row\" [ui]=\"row | uiField\"></ng-container>\n </kles-cell>\n </div>\n </td>\n\n <td\n mat-footer-cell\n *matFooterCellDef\n [ngStyle]=\"\n column.footerCell?.style?.ngStyle\n | resolveNgStyle\n : tableService.form.get(['footer', column.columnDef])?.value\n : tableService.form.get(['footer', column.columnDef])?.status\n : tableService.form.controls.footer.value\n : tableService.form.controls.footer.status\n \"\n >\n @if (column.footerCell) {\n <ng-container\n klesDynamicField\n [field]=\"column | footerField\"\n [group]=\"tableService.form.controls.footer\"\n [ui]=\"tableService.ui.states.footer\"\n >\n </ng-container>\n }\n </td>\n </ng-container>\n }\n\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns(); sticky: true\"></tr>\n\n <tr\n mat-row\n *matRowDef=\"let row; let index = index; let dataIndex = dataIndex; columns: displayedColumns()\"\n cdkDrag\n [cdkDragData]=\"row\"\n (click)=\"rowService.onClick($event, row, dataIndex ?? index)\"\n (dblclick)=\"rowService.onDoubleClick($event, row, dataIndex ?? index)\"\n (contextmenu)=\"rowService.onContextMenu($event, row, dataIndex ?? index)\"\n (mouseenter)=\"rowService.onMouseEnter($event, row, dataIndex ?? index)\"\n (mouseleave)=\"rowService.onMouseLeave($event, row, dataIndex ?? index)\"\n ></tr>\n\n @if (multiTemplateDataRows()) {\n @for (extraRow of extraRows(); track extraRow) {\n @for (extraColumn of extraRow.cells; track extraColumn.columnDef) {\n <ng-container [cdkColumnDef]=\"extraColumn.columnDef\">\n <td\n mat-cell\n *cdkCellDef=\"let row\"\n [attr.colspan]=\"extraColumn.colspan | spanPipe: displayedColumns().length\"\n [attr.rowspan]=\"extraColumn.rowspan\"\n [ngStyle]=\"\n extraColumn?.style?.ngStyle\n | resolveNgStyle\n : row.controls[extraColumn.columnDef].value\n : row.controls[extraColumn.columnDef].status\n : row.value\n : row.status\n \"\n >\n <ng-container klesDynamicField [field]=\"extraColumn | extraCellField\" [group]=\"row\" [ui]=\"row | uiField\"></ng-container>\n </td>\n </ng-container>\n }\n <tr\n mat-row\n *matRowDef=\"let row; let index = index; let dataIndex = dataIndex; columns: extraRow.displayedColumns; when: extraRow.when\"\n (click)=\"rowService.onClick($event, row, dataIndex ?? index)\"\n (dblclick)=\"rowService.onDoubleClick($event, row, dataIndex ?? index)\"\n (contextmenu)=\"rowService.onContextMenu($event, row, dataIndex ?? index)\"\n (mouseenter)=\"rowService.onMouseEnter($event, row, dataIndex ?? index)\"\n (mouseleave)=\"rowService.onMouseLeave($event, row, dataIndex ?? index)\"\n ></tr>\n }\n }\n\n <tr mat-footer-row *matFooterRowDef=\"displayedColumns(); sticky: true\" [style.display]=\"showFooter() ? '' : 'none'\"></tr>\n\n <tr *matNoDataRow [attr.colspan]=\"displayedColumns().length\">\n @if (!loadingService.loading()) {\n no data TODO\n }\n </tr>\n </table>\n</form>\n\n@if (loadingService.loading()) {\n <div class=\"table-overlay\" [style.--header-h.px]=\"headerHeightPx\" [style.--scroll-h.px]=\"scrollHeightPx\" [style.--footer-h.px]=\"footerHeightPx\">\n <mat-spinner></mat-spinner>\n </div>\n}\n", styles: [":host{overflow:auto;display:flex;flex-direction:column;position:relative;height:100%;--mat-form-field-filled-container-color: transparent;--mat-form-field-hover-state-layer-opacity: 0;--mat-form-field-focus-state-layer-opacity: 0;--mat-form-field-state-layer-color: transparent}:host(.loading){min-height:350px}form{display:flex;flex-direction:column;flex-grow:1;position:relative;overflow:auto}table{width:100%;flex-grow:1}.mat-mdc-header-row{background-color:#e2e6eb}th,td{text-wrap:pretty;white-space:normal;padding-top:2px;padding-bottom:2px}td{word-break:normal}th .cell,td .cell{display:flex;flex-direction:column;justify-content:var(--align, center)}th[appResizableColumn]{position:relative}th[appResizableColumn] .resize-handle{position:absolute;top:0;right:-4px;width:8px;height:100%;cursor:col-resize;-webkit-user-select:none;user-select:none}.table-overlay{position:absolute;width:100%;left:0;right:0;top:var(--header-h, 56px);bottom:calc(var(--scroll-h, 0px) + var(--footer-h, 0px));display:grid;place-items:center;background:#8b939a26;z-index:500}:host .mat-mdc-table .mat-mdc-cell,:host .mat-mdc-table .mat-mdc-header-cell{box-shadow:inset -1px 0 #c4c6d0;border-bottom-color:#c4c6d0}:host .mat-mdc-table .mat-mdc-cell:last-child,:host .mat-mdc-table .mat-mdc-header-cell:last-child{border-right:none}:host tr.mat-mdc-footer-row td.mat-mdc-footer-cell{box-shadow:inset 0 1px #c4c6d0}:host tr.mat-mdc-row:last-of-type td.mat-mdc-cell{border-bottom:1px solid rgb(196,198,208)}:host tr.mat-mdc-footer-row{font-weight:500}\n"] }]
|
|
2037
|
+
}], ctorParameters: () => [{ type: i0.ElementRef }, { type: KlesTableConnectorService }, { type: undefined, decorators: [{
|
|
2038
|
+
type: Inject,
|
|
2039
|
+
args: [LOADER_SERVICE]
|
|
2040
|
+
}] }, { type: undefined, decorators: [{
|
|
2041
|
+
type: Inject,
|
|
2042
|
+
args: [DATASOURCE_SERVICE]
|
|
2043
|
+
}] }, { type: undefined, decorators: [{
|
|
2044
|
+
type: Inject,
|
|
2045
|
+
args: [TABLE_SERVICE]
|
|
2046
|
+
}] }, { type: DragDropService, decorators: [{
|
|
2047
|
+
type: Inject,
|
|
2048
|
+
args: [ROW_DRAG_DROP]
|
|
2049
|
+
}] }, { type: undefined, decorators: [{
|
|
2050
|
+
type: Inject,
|
|
2051
|
+
args: [SELECTION_SERVICE]
|
|
2052
|
+
}] }, { type: ColumnsService }, { type: LoadingService }, { type: PaginatorService }, { type: ScrollbarService }, { type: FooterService }, { type: ExtraRowService }, { type: RenderService }, { type: undefined, decorators: [{
|
|
2053
|
+
type: Inject,
|
|
2054
|
+
args: [SORT_SERVICE]
|
|
2055
|
+
}] }, { type: FilterService, decorators: [{
|
|
2056
|
+
type: Optional
|
|
2057
|
+
}] }, { type: ExpandedRowStore }, { type: RowFormFactory }, { type: EventsService }, { type: RowService }, { type: CellService }], propDecorators: { table: [{
|
|
2058
|
+
type: ViewChild,
|
|
2059
|
+
args: [MatTable]
|
|
2060
|
+
}], matSort: [{
|
|
2061
|
+
type: ViewChild,
|
|
2062
|
+
args: [MatSort, { static: true }]
|
|
2063
|
+
}], formElemRef: [{
|
|
2064
|
+
type: ViewChild,
|
|
2065
|
+
args: ['form', { static: true }]
|
|
2066
|
+
}], isLoadingClass: [{
|
|
2067
|
+
type: HostBinding,
|
|
2068
|
+
args: ['class.loading']
|
|
2069
|
+
}] } });
|
|
2070
|
+
|
|
2071
|
+
function isDestroyable(value) {
|
|
2072
|
+
return value !== null && typeof value === 'object' &&
|
|
2073
|
+
typeof value.destroy === 'function';
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
class PaginateTableComponent {
|
|
2077
|
+
constructor(paginatorService) {
|
|
2078
|
+
this.paginatorService = paginatorService;
|
|
2079
|
+
this.disabled = paginatorService.disabled();
|
|
2080
|
+
}
|
|
2081
|
+
ngOnInit() {
|
|
2082
|
+
this.paginatorService.register(this.paginator);
|
|
2083
|
+
}
|
|
2084
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: PaginateTableComponent, deps: [{ token: PaginatorService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2085
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.19", type: PaginateTableComponent, isStandalone: true, selector: "kles-paginate-table", viewQueries: [{ propertyName: "paginator", first: true, predicate: MatPaginator, descendants: true, static: true }, { propertyName: "table", first: true, predicate: TableComponent, descendants: true, static: true }], ngImport: i0, template: "<kles-table></kles-table>\n<mat-paginator [disabled]=\"disabled()\" class=\"paginator\"></mat-paginator>\n", styles: [":host{display:flex;flex-direction:column;height:100%;overflow:auto}.paginator{padding-bottom:4px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: TableComponent, selector: "kles-table" }, { kind: "ngmodule", type: MatPaginatorModule }, { kind: "component", type: i2$1.MatPaginator, selector: "mat-paginator", inputs: ["color", "pageIndex", "length", "pageSize", "pageSizeOptions", "hidePageSize", "showFirstLastButtons", "selectConfig", "disabled"], outputs: ["page"], exportAs: ["matPaginator"] }] }); }
|
|
2086
|
+
}
|
|
2087
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: PaginateTableComponent, decorators: [{
|
|
2088
|
+
type: Component,
|
|
2089
|
+
args: [{ selector: 'kles-paginate-table', standalone: true, imports: [CommonModule, TableComponent, MatPaginatorModule], template: "<kles-table></kles-table>\n<mat-paginator [disabled]=\"disabled()\" class=\"paginator\"></mat-paginator>\n", styles: [":host{display:flex;flex-direction:column;height:100%;overflow:auto}.paginator{padding-bottom:4px}\n"] }]
|
|
2090
|
+
}], ctorParameters: () => [{ type: PaginatorService }], propDecorators: { paginator: [{
|
|
2091
|
+
type: ViewChild,
|
|
2092
|
+
args: [MatPaginator, { static: true }]
|
|
2093
|
+
}], table: [{
|
|
2094
|
+
type: ViewChild,
|
|
2095
|
+
args: [TableComponent, { static: true }]
|
|
2096
|
+
}] } });
|
|
2097
|
+
|
|
2098
|
+
class SortStore {
|
|
2099
|
+
constructor(config) {
|
|
2100
|
+
this.config = config;
|
|
2101
|
+
this.s = new BehaviorSubject(config || undefined);
|
|
2102
|
+
this.sort$ = this.s.asObservable();
|
|
2103
|
+
}
|
|
2104
|
+
setSort(v) {
|
|
2105
|
+
this.s.next(v);
|
|
2106
|
+
}
|
|
2107
|
+
snapshot() {
|
|
2108
|
+
return this.s.value;
|
|
2109
|
+
}
|
|
2110
|
+
reset() {
|
|
2111
|
+
this.s.next(this.config || undefined);
|
|
2112
|
+
}
|
|
2113
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SortStore, deps: [{ token: SORT_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2114
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SortStore }); }
|
|
2115
|
+
}
|
|
2116
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SortStore, decorators: [{
|
|
2117
|
+
type: Injectable
|
|
2118
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
2119
|
+
type: Optional
|
|
2120
|
+
}, {
|
|
2121
|
+
type: Inject,
|
|
2122
|
+
args: [SORT_CONFIG]
|
|
2123
|
+
}] }] });
|
|
2124
|
+
|
|
2125
|
+
class AbstractSortService {
|
|
2126
|
+
constructor(eventsService) {
|
|
2127
|
+
this.eventsService = eventsService;
|
|
2128
|
+
this._sortChange = new EventEmitter();
|
|
2129
|
+
this.destroyRef = inject(DestroyRef);
|
|
2130
|
+
}
|
|
2131
|
+
get sort() {
|
|
2132
|
+
return this._sort;
|
|
2133
|
+
}
|
|
2134
|
+
register(s) {
|
|
2135
|
+
this._sort = s;
|
|
2136
|
+
this._sort.sortChange.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((event) => {
|
|
2137
|
+
this._sortChange.emit(event);
|
|
2138
|
+
this.eventsService.emit('sortChange', {
|
|
2139
|
+
active: event.active,
|
|
2140
|
+
direction: event.direction,
|
|
2141
|
+
});
|
|
2142
|
+
});
|
|
2143
|
+
}
|
|
2144
|
+
setDirection(direction) {
|
|
2145
|
+
if (this._sort) {
|
|
2146
|
+
this._sort.direction = direction;
|
|
2147
|
+
this.sort.sortChange.emit({ active: this._sort.active, direction: this._sort.direction });
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
setActive(active) {
|
|
2151
|
+
if (this._sort) {
|
|
2152
|
+
this._sort.active = active;
|
|
2153
|
+
this.sort.sortChange.emit({ active: this._sort.active, direction: this._sort.direction });
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
sortChange() {
|
|
2157
|
+
return this._sortChange;
|
|
2158
|
+
}
|
|
2159
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: AbstractSortService, deps: [{ token: EventsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2160
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: AbstractSortService }); }
|
|
2161
|
+
}
|
|
2162
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: AbstractSortService, decorators: [{
|
|
2163
|
+
type: Injectable
|
|
2164
|
+
}], ctorParameters: () => [{ type: EventsService }] });
|
|
2165
|
+
class SortService extends AbstractSortService {
|
|
2166
|
+
constructor(sortStore, columnsService, datasourceService, eventsService) {
|
|
2167
|
+
super(eventsService);
|
|
2168
|
+
this.sortStore = sortStore;
|
|
2169
|
+
this.columnsService = columnsService;
|
|
2170
|
+
this.datasourceService = datasourceService;
|
|
2171
|
+
this.eventsService = eventsService;
|
|
2172
|
+
this.sortingDataAccessor = (item, property) => {
|
|
2173
|
+
if (!item.value) {
|
|
2174
|
+
return undefined;
|
|
2175
|
+
}
|
|
2176
|
+
let value = item.value?.[property];
|
|
2177
|
+
if (value) {
|
|
2178
|
+
if (typeof value === 'string') {
|
|
2179
|
+
value = value.toLowerCase();
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
|
+
return value;
|
|
2183
|
+
};
|
|
2184
|
+
}
|
|
2185
|
+
register(s) {
|
|
2186
|
+
super.register(s);
|
|
2187
|
+
this.datasourceService.datasource.sort = this._sort;
|
|
2188
|
+
if (!this._sort)
|
|
2189
|
+
return;
|
|
2190
|
+
this.datasourceService.datasource.sortingDataAccessor = this.sortingDataAccessor;
|
|
2191
|
+
this.datasourceService.datasource.sortData = this.sortDataPredicate(this.columnsService.columns());
|
|
2192
|
+
s.active = this.sortStore?.snapshot()?.active ?? s.active;
|
|
2193
|
+
s.direction = this.sortStore?.snapshot()?.direction ?? s.direction;
|
|
2194
|
+
s.sortChange.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((event) => {
|
|
2195
|
+
this.sortStore?.setSort(event);
|
|
2196
|
+
});
|
|
2197
|
+
}
|
|
2198
|
+
sortDataPredicate(columns) {
|
|
2199
|
+
return (data, sort) => {
|
|
2200
|
+
const active = sort.active;
|
|
2201
|
+
const direction = sort.direction;
|
|
2202
|
+
if (!active || direction == '') {
|
|
2203
|
+
return data;
|
|
2204
|
+
}
|
|
2205
|
+
const column = columns.find((col) => col.columnDef === active);
|
|
2206
|
+
return data.sort((a, b) => {
|
|
2207
|
+
let valueA;
|
|
2208
|
+
let valueB;
|
|
2209
|
+
if (column?.headerCell.sortPredicate) {
|
|
2210
|
+
valueA = column?.headerCell.sortPredicate(a);
|
|
2211
|
+
valueB = column?.headerCell.sortPredicate(b);
|
|
2212
|
+
}
|
|
2213
|
+
else {
|
|
2214
|
+
valueA = this.sortingDataAccessor(a, active);
|
|
2215
|
+
valueB = this.sortingDataAccessor(b, active);
|
|
2216
|
+
if (column) {
|
|
2217
|
+
const key = column.cell?.field.property;
|
|
2218
|
+
if (key) {
|
|
2219
|
+
valueA = valueA?.[key];
|
|
2220
|
+
valueB = valueB?.[key];
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
const valueAType = typeof valueA;
|
|
2225
|
+
const valueBType = typeof valueB;
|
|
2226
|
+
if (valueAType !== valueBType) {
|
|
2227
|
+
if (valueAType === 'number') {
|
|
2228
|
+
valueA += '';
|
|
2229
|
+
}
|
|
2230
|
+
if (valueBType === 'number') {
|
|
2231
|
+
valueB += '';
|
|
2232
|
+
}
|
|
2233
|
+
}
|
|
2234
|
+
let comparatorResult = 0;
|
|
2235
|
+
if (valueA != null && valueB != null) {
|
|
2236
|
+
if (valueA > valueB) {
|
|
2237
|
+
comparatorResult = 1;
|
|
2238
|
+
}
|
|
2239
|
+
else if (valueA < valueB) {
|
|
2240
|
+
comparatorResult = -1;
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
else if (valueA != null) {
|
|
2244
|
+
comparatorResult = 1;
|
|
2245
|
+
}
|
|
2246
|
+
else if (valueB != null) {
|
|
2247
|
+
comparatorResult = -1;
|
|
2248
|
+
}
|
|
2249
|
+
return comparatorResult * (direction == 'asc' ? 1 : -1);
|
|
2250
|
+
});
|
|
2251
|
+
};
|
|
2252
|
+
}
|
|
2253
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SortService, deps: [{ token: SortStore, optional: true }, { token: ColumnsService }, { token: DATASOURCE_SERVICE }, { token: EventsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2254
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SortService }); }
|
|
2255
|
+
}
|
|
2256
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SortService, decorators: [{
|
|
2257
|
+
type: Injectable
|
|
2258
|
+
}], ctorParameters: () => [{ type: SortStore, decorators: [{
|
|
2259
|
+
type: Optional
|
|
2260
|
+
}] }, { type: ColumnsService }, { type: DatasourceService, decorators: [{
|
|
2261
|
+
type: Inject,
|
|
2262
|
+
args: [DATASOURCE_SERVICE]
|
|
2263
|
+
}] }, { type: EventsService }] });
|
|
2264
|
+
class SortLazyService extends AbstractSortService {
|
|
2265
|
+
constructor(sortStore, datasourceService, eventsService) {
|
|
2266
|
+
super(eventsService);
|
|
2267
|
+
this.sortStore = sortStore;
|
|
2268
|
+
this.datasourceService = datasourceService;
|
|
2269
|
+
this.eventsService = eventsService;
|
|
2270
|
+
}
|
|
2271
|
+
register(s) {
|
|
2272
|
+
super.register(s);
|
|
2273
|
+
this.datasourceService.datasource.sort = this._sort;
|
|
2274
|
+
if (!this._sort)
|
|
2275
|
+
return;
|
|
2276
|
+
s.active = this.sortStore?.snapshot()?.active ?? s.active;
|
|
2277
|
+
s.direction = this.sortStore?.snapshot()?.direction ?? s.direction;
|
|
2278
|
+
s.sortChange.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((event) => {
|
|
2279
|
+
this.sortStore?.setSort(event);
|
|
2280
|
+
});
|
|
2281
|
+
}
|
|
2282
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SortLazyService, deps: [{ token: SortStore, optional: true }, { token: DATASOURCE_SERVICE }, { token: EventsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2283
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SortLazyService }); }
|
|
2284
|
+
}
|
|
2285
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SortLazyService, decorators: [{
|
|
2286
|
+
type: Injectable
|
|
2287
|
+
}], ctorParameters: () => [{ type: SortStore, decorators: [{
|
|
2288
|
+
type: Optional
|
|
2289
|
+
}] }, { type: DatasourceLazyService, decorators: [{
|
|
2290
|
+
type: Inject,
|
|
2291
|
+
args: [DATASOURCE_SERVICE]
|
|
2292
|
+
}] }, { type: EventsService }] });
|
|
2293
|
+
|
|
2294
|
+
class FilterStore {
|
|
2295
|
+
constructor() {
|
|
2296
|
+
this.s = new BehaviorSubject({});
|
|
2297
|
+
this.filters$ = this.s.asObservable();
|
|
2298
|
+
}
|
|
2299
|
+
setFilters(v) {
|
|
2300
|
+
this.s.next(v);
|
|
2301
|
+
}
|
|
2302
|
+
reset() {
|
|
2303
|
+
this.s.next({});
|
|
2304
|
+
}
|
|
2305
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: FilterStore, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2306
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: FilterStore }); }
|
|
2307
|
+
}
|
|
2308
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: FilterStore, decorators: [{
|
|
2309
|
+
type: Injectable
|
|
2310
|
+
}] });
|
|
2311
|
+
|
|
2312
|
+
class InfiniteScrollTableComponent {
|
|
2313
|
+
constructor() { }
|
|
2314
|
+
ngOnInit() { }
|
|
2315
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: InfiniteScrollTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
2316
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.19", type: InfiniteScrollTableComponent, isStandalone: true, selector: "kles-infinite-scroll-table", ngImport: i0, template: "<!-- <cdk-virtual-scroll-viewport itemSize=\"48\">\n <kles-table></kles-table>\n</cdk-virtual-scroll-viewport> -->\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ScrollingModule }] }); }
|
|
2317
|
+
}
|
|
2318
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: InfiniteScrollTableComponent, decorators: [{
|
|
2319
|
+
type: Component,
|
|
2320
|
+
args: [{ selector: 'kles-infinite-scroll-table', standalone: true, imports: [CommonModule, TableComponent, ScrollingModule], template: "<!-- <cdk-virtual-scroll-viewport itemSize=\"48\">\n <kles-table></kles-table>\n</cdk-virtual-scroll-viewport> -->\n" }]
|
|
2321
|
+
}], ctorParameters: () => [] });
|
|
2322
|
+
|
|
2323
|
+
class SelectionLoaderService {
|
|
2324
|
+
constructor(selectionConfig) {
|
|
2325
|
+
this.selectionConfig = selectionConfig;
|
|
2326
|
+
}
|
|
2327
|
+
get key() {
|
|
2328
|
+
return this.selectionConfig?.key || '#select';
|
|
2329
|
+
}
|
|
2330
|
+
select(row, selected, filters) {
|
|
2331
|
+
return (this.selectionConfig?.params?.() || of({})).pipe(auditTime(0), take(1), switchMap((params) => {
|
|
2332
|
+
return concat(of({ loading: true, success: false }), (this.selectionConfig?.select
|
|
2333
|
+
? this.selectionConfig?.select?.(params, row, selected, filters)
|
|
2334
|
+
: of({ selected, count: null })).pipe(map((response) => {
|
|
2335
|
+
return { ...response, loading: false, success: true };
|
|
2336
|
+
}), catchError((err) => {
|
|
2337
|
+
return of({ error: err, loading: false, success: false });
|
|
2338
|
+
})));
|
|
2339
|
+
}));
|
|
2340
|
+
}
|
|
2341
|
+
selectAll(selected, filters) {
|
|
2342
|
+
return (this.selectionConfig?.params?.() || of({})).pipe(auditTime(0), take(1), switchMap((params) => {
|
|
2343
|
+
return concat(of({ loading: true, success: false }), (this.selectionConfig?.selectAll
|
|
2344
|
+
? this.selectionConfig?.selectAll?.(params, selected, filters)
|
|
2345
|
+
: of({ selected, count: null, footer: null })).pipe(map((response) => {
|
|
2346
|
+
return { ...response, loading: false, success: true };
|
|
2347
|
+
}), catchError((err) => {
|
|
2348
|
+
return of({ error: err, loading: false, success: false });
|
|
2349
|
+
})));
|
|
2350
|
+
}));
|
|
2351
|
+
}
|
|
2352
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SelectionLoaderService, deps: [{ token: SELECTION_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2353
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SelectionLoaderService }); }
|
|
2354
|
+
}
|
|
2355
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SelectionLoaderService, decorators: [{
|
|
2356
|
+
type: Injectable
|
|
2357
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
2358
|
+
type: Optional
|
|
2359
|
+
}, {
|
|
2360
|
+
type: Inject,
|
|
2361
|
+
args: [SELECTION_CONFIG]
|
|
2362
|
+
}] }] });
|
|
2363
|
+
|
|
2364
|
+
class HeaderService {
|
|
2365
|
+
constructor(fm, filterService, filterStore, datasourceService, loader, columnsService, eventsService) {
|
|
2366
|
+
this.fm = fm;
|
|
2367
|
+
this.filterService = filterService;
|
|
2368
|
+
this.filterStore = filterStore;
|
|
2369
|
+
this.datasourceService = datasourceService;
|
|
2370
|
+
this.loader = loader;
|
|
2371
|
+
this.columnsService = columnsService;
|
|
2372
|
+
this.eventsService = eventsService;
|
|
2373
|
+
this.destroyRef = inject(DestroyRef);
|
|
2374
|
+
this.filterableColumns = this.columnsService
|
|
2375
|
+
.columns()
|
|
2376
|
+
.filter((c) => c.filterable === true)
|
|
2377
|
+
.map((c) => c.columnDef);
|
|
2378
|
+
}
|
|
2379
|
+
register() {
|
|
2380
|
+
this.load();
|
|
2381
|
+
const header = this.fm.getHeader();
|
|
2382
|
+
const filterControlChanges$ = merge(...this.filterableColumns.map((columnDef) => {
|
|
2383
|
+
const control = header.get(columnDef);
|
|
2384
|
+
if (!control) {
|
|
2385
|
+
throw new Error(`Missing header filter control: ${columnDef}`);
|
|
2386
|
+
}
|
|
2387
|
+
return control.valueChanges.pipe(debounceTime(300), distinctUntilChanged((a, b) => ___default.isEqual(a, b)), map((currentValue) => ({
|
|
2388
|
+
columnDef,
|
|
2389
|
+
currentValue,
|
|
2390
|
+
})));
|
|
2391
|
+
}));
|
|
2392
|
+
filterControlChanges$
|
|
2393
|
+
.pipe(takeUntilDestroyed(this.destroyRef), scan((state, changed) => {
|
|
2394
|
+
const previousValue = state.filters[changed.columnDef];
|
|
2395
|
+
const changedFilter = {
|
|
2396
|
+
columnDef: changed.columnDef,
|
|
2397
|
+
previousValue,
|
|
2398
|
+
currentValue: changed.currentValue,
|
|
2399
|
+
};
|
|
2400
|
+
const filters = {
|
|
2401
|
+
...state.filters,
|
|
2402
|
+
[changed.columnDef]: changed.currentValue,
|
|
2403
|
+
};
|
|
2404
|
+
return {
|
|
2405
|
+
filters,
|
|
2406
|
+
changedFilter,
|
|
2407
|
+
};
|
|
2408
|
+
}, {
|
|
2409
|
+
filters: Object.fromEntries(this.filterableColumns.map((columnDef) => [columnDef, header.get(columnDef)?.value])),
|
|
2410
|
+
changedFilter: undefined,
|
|
2411
|
+
}))
|
|
2412
|
+
.subscribe(({ filters, changedFilter }) => {
|
|
2413
|
+
if (this.filterService) {
|
|
2414
|
+
const prepared = this.filterService.formatData(filters);
|
|
2415
|
+
this.datasourceService.datasource.filter = JSON.stringify(prepared);
|
|
2416
|
+
this.filterStore?.setFilters(prepared);
|
|
2417
|
+
}
|
|
2418
|
+
else {
|
|
2419
|
+
this.filterStore?.setFilters(filters);
|
|
2420
|
+
this.datasourceService.datasource.filter = JSON.stringify(filters);
|
|
2421
|
+
}
|
|
2422
|
+
this.eventsService.emit('filterChange', {
|
|
2423
|
+
filters,
|
|
2424
|
+
changedFilter,
|
|
2425
|
+
});
|
|
2426
|
+
});
|
|
2427
|
+
}
|
|
2428
|
+
load() {
|
|
2429
|
+
this.loader
|
|
2430
|
+
.load()
|
|
2431
|
+
.pipe(takeUntilDestroyed(this.destroyRef), filter((response) => !response.loading), map((response) => response.header), filter((header) => header != undefined), distinctUntilChanged((p, c) => {
|
|
2432
|
+
return this.filterableColumns.every((col) => p?.[col] === c?.[col]);
|
|
2433
|
+
}))
|
|
2434
|
+
.subscribe((header) => {
|
|
2435
|
+
this.fm.getHeader().patchValue(header, { emitEvent: false });
|
|
2436
|
+
});
|
|
2437
|
+
}
|
|
2438
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: HeaderService, deps: [{ token: KlesForm }, { token: FilterService, optional: true }, { token: FilterStore, optional: true }, { token: DATASOURCE_SERVICE }, { token: LOADER_SERVICE }, { token: ColumnsService }, { token: EventsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2439
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: HeaderService }); }
|
|
2440
|
+
}
|
|
2441
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: HeaderService, decorators: [{
|
|
2442
|
+
type: Injectable
|
|
2443
|
+
}], ctorParameters: () => [{ type: KlesForm }, { type: FilterService, decorators: [{
|
|
2444
|
+
type: Optional
|
|
2445
|
+
}] }, { type: FilterStore, decorators: [{
|
|
2446
|
+
type: Optional
|
|
2447
|
+
}] }, { type: undefined, decorators: [{
|
|
2448
|
+
type: Inject,
|
|
2449
|
+
args: [DATASOURCE_SERVICE]
|
|
2450
|
+
}] }, { type: undefined, decorators: [{
|
|
2451
|
+
type: Inject,
|
|
2452
|
+
args: [LOADER_SERVICE]
|
|
2453
|
+
}] }, { type: ColumnsService }, { type: EventsService }] });
|
|
2454
|
+
class HeaderLazyService {
|
|
2455
|
+
constructor(fm, filterStore, loader, columnsService, eventsService) {
|
|
2456
|
+
this.fm = fm;
|
|
2457
|
+
this.filterStore = filterStore;
|
|
2458
|
+
this.loader = loader;
|
|
2459
|
+
this.columnsService = columnsService;
|
|
2460
|
+
this.eventsService = eventsService;
|
|
2461
|
+
this.destroyRef = inject(DestroyRef);
|
|
2462
|
+
this.filterableColumns = this.columnsService
|
|
2463
|
+
.columns()
|
|
2464
|
+
.filter((c) => c.filterable === true)
|
|
2465
|
+
.map((c) => c.columnDef);
|
|
2466
|
+
}
|
|
2467
|
+
register() {
|
|
2468
|
+
this.load();
|
|
2469
|
+
const header = this.fm.getHeader();
|
|
2470
|
+
const filterControlChanges$ = merge(...this.filterableColumns.map((columnDef) => {
|
|
2471
|
+
const control = header.get(columnDef);
|
|
2472
|
+
if (!control) {
|
|
2473
|
+
throw new Error(`Missing header filter control: ${columnDef}`);
|
|
2474
|
+
}
|
|
2475
|
+
return control.valueChanges.pipe(debounceTime(300), distinctUntilChanged((a, b) => ___default.isEqual(a, b)), map((currentValue) => ({
|
|
2476
|
+
columnDef,
|
|
2477
|
+
currentValue,
|
|
2478
|
+
})));
|
|
2479
|
+
}));
|
|
2480
|
+
filterControlChanges$
|
|
2481
|
+
.pipe(takeUntilDestroyed(this.destroyRef), scan((state, changed) => {
|
|
2482
|
+
const previousValue = state.filters[changed.columnDef];
|
|
2483
|
+
const changedFilter = {
|
|
2484
|
+
columnDef: changed.columnDef,
|
|
2485
|
+
previousValue,
|
|
2486
|
+
currentValue: changed.currentValue,
|
|
2487
|
+
};
|
|
2488
|
+
const filters = {
|
|
2489
|
+
...state.filters,
|
|
2490
|
+
[changed.columnDef]: changed.currentValue,
|
|
2491
|
+
};
|
|
2492
|
+
return {
|
|
2493
|
+
filters,
|
|
2494
|
+
changedFilter,
|
|
2495
|
+
};
|
|
2496
|
+
}, {
|
|
2497
|
+
filters: Object.fromEntries(this.filterableColumns.map((columnDef) => [columnDef, header.get(columnDef)?.value])),
|
|
2498
|
+
changedFilter: undefined,
|
|
2499
|
+
}))
|
|
2500
|
+
.subscribe(({ filters, changedFilter }) => {
|
|
2501
|
+
this.filterStore?.setFilters(filters);
|
|
2502
|
+
this.eventsService.emit('filterChange', {
|
|
2503
|
+
filters,
|
|
2504
|
+
changedFilter,
|
|
2505
|
+
});
|
|
2506
|
+
});
|
|
2507
|
+
}
|
|
2508
|
+
load() {
|
|
2509
|
+
this.loader
|
|
2510
|
+
.load()
|
|
2511
|
+
.pipe(takeUntilDestroyed(this.destroyRef), filter((response) => !response.loading), map((response) => response.header), filter((header) => header != undefined), distinctUntilChanged((p, c) => {
|
|
2512
|
+
return this.filterableColumns.every((col) => p?.[col] === c?.[col]);
|
|
2513
|
+
}))
|
|
2514
|
+
.subscribe((header) => {
|
|
2515
|
+
this.fm.getHeader().patchValue(header, { emitEvent: false });
|
|
2516
|
+
});
|
|
2517
|
+
}
|
|
2518
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: HeaderLazyService, deps: [{ token: KlesForm }, { token: FilterStore, optional: true }, { token: LOADER_SERVICE }, { token: ColumnsService }, { token: EventsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2519
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: HeaderLazyService }); }
|
|
2520
|
+
}
|
|
2521
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: HeaderLazyService, decorators: [{
|
|
2522
|
+
type: Injectable
|
|
2523
|
+
}], ctorParameters: () => [{ type: KlesForm }, { type: FilterStore, decorators: [{
|
|
2524
|
+
type: Optional
|
|
2525
|
+
}] }, { type: undefined, decorators: [{
|
|
2526
|
+
type: Inject,
|
|
2527
|
+
args: [LOADER_SERVICE]
|
|
2528
|
+
}] }, { type: ColumnsService }, { type: EventsService }] });
|
|
2529
|
+
|
|
2530
|
+
function getMultipleValuesInSingleSelectionError() {
|
|
2531
|
+
return Error('Cannot pass multiple values into SelectionModel with single-value mode.');
|
|
2532
|
+
}
|
|
2533
|
+
|
|
2534
|
+
var KlesSelectionModelState;
|
|
2535
|
+
(function (KlesSelectionModelState) {
|
|
2536
|
+
KlesSelectionModelState["ENABLED"] = "enabled";
|
|
2537
|
+
KlesSelectionModelState["DISABLED"] = "disabled";
|
|
2538
|
+
})(KlesSelectionModelState || (KlesSelectionModelState = {}));
|
|
2539
|
+
|
|
2540
|
+
class KlesSelectionModel {
|
|
2541
|
+
constructor(multiple = false, initialValues) {
|
|
2542
|
+
this.multiple = multiple;
|
|
2543
|
+
this._selection = new Set();
|
|
2544
|
+
this._changed = new Subject();
|
|
2545
|
+
this._stateChanged = new Subject();
|
|
2546
|
+
this._state = KlesSelectionModelState.ENABLED;
|
|
2547
|
+
this._count = signal(0, ...(ngDevMode ? [{ debugName: "_count" }] : /* istanbul ignore next */ []));
|
|
2548
|
+
initialValues?.forEach((v) => {
|
|
2549
|
+
this._selection.add(v);
|
|
2550
|
+
});
|
|
2551
|
+
}
|
|
2552
|
+
get selected() {
|
|
2553
|
+
return {
|
|
2554
|
+
items: Array.from(this._selection),
|
|
2555
|
+
count: this._selection.size,
|
|
2556
|
+
state: this._state,
|
|
2557
|
+
};
|
|
2558
|
+
}
|
|
2559
|
+
get count() {
|
|
2560
|
+
return this._count.asReadonly();
|
|
2561
|
+
}
|
|
2562
|
+
get changed() {
|
|
2563
|
+
return this._changed.asObservable();
|
|
2564
|
+
}
|
|
2565
|
+
get state() {
|
|
2566
|
+
return this._state;
|
|
2567
|
+
}
|
|
2568
|
+
get stateChanged() {
|
|
2569
|
+
return this._stateChanged.asObservable();
|
|
2570
|
+
}
|
|
2571
|
+
select(value, options) {
|
|
2572
|
+
const added = [];
|
|
2573
|
+
const removed = [];
|
|
2574
|
+
if (this._state === KlesSelectionModelState.ENABLED) {
|
|
2575
|
+
if (Array.isArray(value)) {
|
|
2576
|
+
if (value.length > 1 && !this.multiple) {
|
|
2577
|
+
throw getMultipleValuesInSingleSelectionError();
|
|
2578
|
+
}
|
|
2579
|
+
value.forEach((v) => {
|
|
2580
|
+
if (!this.isSelected(v)) {
|
|
2581
|
+
this._selection.add(v);
|
|
2582
|
+
added.push(v);
|
|
2583
|
+
}
|
|
2584
|
+
});
|
|
2585
|
+
}
|
|
2586
|
+
else {
|
|
2587
|
+
if (!this.isSelected(value)) {
|
|
2588
|
+
if (!this.multiple) {
|
|
2589
|
+
removed.push(...Array.from(this._selection));
|
|
2590
|
+
this._selection.clear();
|
|
2591
|
+
}
|
|
2592
|
+
this._selection.add(value);
|
|
2593
|
+
added.push(value);
|
|
2594
|
+
}
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
this._count.set(this._selection.size);
|
|
2598
|
+
if (options?.emitEvent ?? true) {
|
|
2599
|
+
this._changed.next({ added, removed, count: this._selection.size, state: this._state });
|
|
2600
|
+
}
|
|
2601
|
+
}
|
|
2602
|
+
deselect(value, options) {
|
|
2603
|
+
const removed = [];
|
|
2604
|
+
const added = [];
|
|
2605
|
+
if (this._state === KlesSelectionModelState.ENABLED) {
|
|
2606
|
+
if (Array.isArray(value)) {
|
|
2607
|
+
value.forEach((v) => {
|
|
2608
|
+
if (this.isSelected(v)) {
|
|
2609
|
+
this._selection.delete(v);
|
|
2610
|
+
removed.push(v);
|
|
2611
|
+
}
|
|
2612
|
+
});
|
|
2613
|
+
}
|
|
2614
|
+
else {
|
|
2615
|
+
if (this.isSelected(value)) {
|
|
2616
|
+
this._selection.delete(value);
|
|
2617
|
+
removed.push(value);
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2621
|
+
this._count.set(this._selection.size);
|
|
2622
|
+
if (options?.emitEvent ?? true) {
|
|
2623
|
+
this._changed.next({ added, removed, count: this._selection.size, state: this._state });
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
toggle(value, options) {
|
|
2627
|
+
if (this.isSelected(value)) {
|
|
2628
|
+
this.deselect(value, options);
|
|
2629
|
+
}
|
|
2630
|
+
else {
|
|
2631
|
+
this.select(value, options);
|
|
2632
|
+
}
|
|
2633
|
+
}
|
|
2634
|
+
isEmpty() {
|
|
2635
|
+
return this._selection.size === 0;
|
|
2636
|
+
}
|
|
2637
|
+
hasValue() {
|
|
2638
|
+
return this._selection.size > 0;
|
|
2639
|
+
}
|
|
2640
|
+
disable() {
|
|
2641
|
+
this._state = KlesSelectionModelState.DISABLED;
|
|
2642
|
+
this._stateChanged.next(this._state);
|
|
2643
|
+
}
|
|
2644
|
+
enable() {
|
|
2645
|
+
this._state = KlesSelectionModelState.ENABLED;
|
|
2646
|
+
this._stateChanged.next(this._state);
|
|
2647
|
+
}
|
|
2648
|
+
isSelected(value) {
|
|
2649
|
+
return this._selection.has(this.getValue(value));
|
|
2650
|
+
}
|
|
2651
|
+
isMultipleSelection() {
|
|
2652
|
+
return this.multiple || false;
|
|
2653
|
+
}
|
|
2654
|
+
getValue(value) {
|
|
2655
|
+
// si jamais je rajoute une méthode de comparaison avec _selection
|
|
2656
|
+
return value;
|
|
2657
|
+
}
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
class AbstractSelectionService {
|
|
2661
|
+
constructor(selectionConfig) {
|
|
2662
|
+
this.selectionConfig = selectionConfig;
|
|
2663
|
+
}
|
|
2664
|
+
get key() {
|
|
2665
|
+
return this.selectionConfig?.key || '#select';
|
|
2666
|
+
}
|
|
2667
|
+
get selectionMode() {
|
|
2668
|
+
return this.selectionConfig?.selectionMode || false;
|
|
2669
|
+
}
|
|
2670
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: AbstractSelectionService, deps: [{ token: SELECTION_CONFIG, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2671
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: AbstractSelectionService }); }
|
|
2672
|
+
}
|
|
2673
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: AbstractSelectionService, decorators: [{
|
|
2674
|
+
type: Injectable
|
|
2675
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
2676
|
+
type: Optional
|
|
2677
|
+
}, {
|
|
2678
|
+
type: Inject,
|
|
2679
|
+
args: [SELECTION_CONFIG]
|
|
2680
|
+
}] }] });
|
|
2681
|
+
class SelectionService extends AbstractSelectionService {
|
|
2682
|
+
constructor(selectionConfig, fm, selectionLoaderService, scrollbarService, loadingService, datasourceService, linesService) {
|
|
2683
|
+
super(selectionConfig);
|
|
2684
|
+
this.fm = fm;
|
|
2685
|
+
this.selectionLoaderService = selectionLoaderService;
|
|
2686
|
+
this.scrollbarService = scrollbarService;
|
|
2687
|
+
this.loadingService = loadingService;
|
|
2688
|
+
this.datasourceService = datasourceService;
|
|
2689
|
+
this.linesService = linesService;
|
|
2690
|
+
this.destroyRef = inject(DestroyRef);
|
|
2691
|
+
this.selectionModel = new KlesSelectionModel(selectionConfig?.selectionMode);
|
|
2692
|
+
}
|
|
2693
|
+
register() {
|
|
2694
|
+
this.listenSelection();
|
|
2695
|
+
this.setSelection();
|
|
2696
|
+
this.listenDatasource();
|
|
2697
|
+
this.listenRowSelection();
|
|
2698
|
+
this.listenHeaderSelection();
|
|
2699
|
+
}
|
|
2700
|
+
count() {
|
|
2701
|
+
return this.selectionModel.count;
|
|
2702
|
+
}
|
|
2703
|
+
disable() {
|
|
2704
|
+
this.selectionModel.disable();
|
|
2705
|
+
}
|
|
2706
|
+
enable() {
|
|
2707
|
+
this.selectionModel.enable();
|
|
2708
|
+
}
|
|
2709
|
+
setSelection() {
|
|
2710
|
+
this.linesService
|
|
2711
|
+
.loaded()
|
|
2712
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
2713
|
+
.subscribe(() => {
|
|
2714
|
+
this.fm.getRows().controls.forEach((group) => {
|
|
2715
|
+
if (group.controls[this.selectionLoaderService.key]?.value === true) {
|
|
2716
|
+
this.selectionModel.select(group, { emitEvent: false }); // event false to avoid multiple send event
|
|
2717
|
+
}
|
|
2718
|
+
else if (this.selectionConfig?.isSelected != undefined && this.selectionConfig.isSelected(group)) {
|
|
2719
|
+
this.selectionModel.select(group, { emitEvent: false }); // event false to avoid multiple send event
|
|
2720
|
+
group.controls[this.selectionLoaderService.key]?.patchValue(true, { emitEvent: false });
|
|
2721
|
+
}
|
|
2722
|
+
else {
|
|
2723
|
+
this.selectionModel.deselect(group, { emitEvent: false }); // event false to avoid multiple send event
|
|
2724
|
+
}
|
|
2725
|
+
if (this.selectionConfig?.isDisabled && this.selectionConfig.isDisabled(group)) {
|
|
2726
|
+
group.controls[this.selectionLoaderService.key]?.disable({ emitEvent: false });
|
|
2727
|
+
}
|
|
2728
|
+
});
|
|
2729
|
+
this.updateHeader();
|
|
2730
|
+
});
|
|
2731
|
+
}
|
|
2732
|
+
listenHeaderSelection() {
|
|
2733
|
+
this.fm
|
|
2734
|
+
.getHeader()
|
|
2735
|
+
.controls[this.key]?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef), switchMap((value) => {
|
|
2736
|
+
return this.selectionLoaderService.selectAll(!!value, this.fm.getHeader().getRawValue());
|
|
2737
|
+
}))
|
|
2738
|
+
.subscribe((response) => {
|
|
2739
|
+
if (response.loading) {
|
|
2740
|
+
this.scrollbarService.toTop('instant');
|
|
2741
|
+
this.loadingService.start();
|
|
2742
|
+
return;
|
|
2743
|
+
}
|
|
2744
|
+
else {
|
|
2745
|
+
this.loadingService.stop();
|
|
2746
|
+
if (response.selected) {
|
|
2747
|
+
if (this.selectionModel.isMultipleSelection()) {
|
|
2748
|
+
this.selectionModel.select(this.datasourceService.datasource.filteredData?.filter((g) => g.controls[this.selectionLoaderService.key]?.enabled) ??
|
|
2749
|
+
[]);
|
|
2750
|
+
}
|
|
2751
|
+
else {
|
|
2752
|
+
this.selectionModel.select(this.datasourceService.datasource.filteredData?.filter((g) => g.controls[this.selectionLoaderService.key]?.enabled)[0] ?? []);
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
else {
|
|
2756
|
+
this.selectionModel.deselect(this.datasourceService.datasource.filteredData?.filter((g) => g.controls[this.selectionLoaderService.key]?.enabled));
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
});
|
|
2760
|
+
}
|
|
2761
|
+
listenRowSelection() {
|
|
2762
|
+
this.datasourceService.datasource
|
|
2763
|
+
.connect()
|
|
2764
|
+
.pipe(takeUntilDestroyed(this.destroyRef), auditTime(0), switchMap((rows) => {
|
|
2765
|
+
return merge(...rows
|
|
2766
|
+
.map((row) => {
|
|
2767
|
+
return row.controls[this.selectionLoaderService.key]?.valueChanges.pipe(map((value) => {
|
|
2768
|
+
return { row, selected: !!value };
|
|
2769
|
+
}));
|
|
2770
|
+
})
|
|
2771
|
+
.filter(Boolean));
|
|
2772
|
+
}), concatMap(({ row, selected }) => {
|
|
2773
|
+
return this.selectionLoaderService.select(row, selected).pipe(map((response) => {
|
|
2774
|
+
return {
|
|
2775
|
+
row,
|
|
2776
|
+
response,
|
|
2777
|
+
};
|
|
2778
|
+
}));
|
|
2779
|
+
}))
|
|
2780
|
+
.subscribe(({ row, response }) => {
|
|
2781
|
+
if (response.loading) {
|
|
2782
|
+
//mettre la ligne avec un spinner
|
|
2783
|
+
}
|
|
2784
|
+
else {
|
|
2785
|
+
if (response.selected) {
|
|
2786
|
+
this.selectionModel.select(row);
|
|
2787
|
+
}
|
|
2788
|
+
else {
|
|
2789
|
+
this.selectionModel.deselect(row);
|
|
2790
|
+
}
|
|
2791
|
+
//enlever la ligne en spinner
|
|
2792
|
+
}
|
|
2793
|
+
});
|
|
2794
|
+
}
|
|
2795
|
+
listenSelection() {
|
|
2796
|
+
this.selectionModel.changed.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((changed) => {
|
|
2797
|
+
changed.removed?.forEach((group) => {
|
|
2798
|
+
group.controls[this.selectionLoaderService.key].patchValue(false, { emitEvent: false });
|
|
2799
|
+
});
|
|
2800
|
+
changed.added?.forEach((group) => {
|
|
2801
|
+
group.controls[this.selectionLoaderService.key].patchValue(true, { emitEvent: false });
|
|
2802
|
+
});
|
|
2803
|
+
this.fm.getRows().updateValueAndValidity({ emitEvent: false });
|
|
2804
|
+
this.updateHeader();
|
|
2805
|
+
});
|
|
2806
|
+
this.selectionModel.stateChanged.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((state) => {
|
|
2807
|
+
if (state === KlesSelectionModelState.ENABLED) {
|
|
2808
|
+
this.fm.getHeader().controls[this.key].enable({ emitEvent: false });
|
|
2809
|
+
this.fm.getRows().controls.forEach((group) => {
|
|
2810
|
+
group.controls[this.key].enable({ emitEvent: false });
|
|
2811
|
+
});
|
|
2812
|
+
}
|
|
2813
|
+
else {
|
|
2814
|
+
this.fm.getHeader().controls[this.key].disable({ emitEvent: false });
|
|
2815
|
+
this.fm.getRows().controls.forEach((group) => {
|
|
2816
|
+
group.controls[this.key].disable({ emitEvent: false });
|
|
2817
|
+
});
|
|
2818
|
+
}
|
|
2819
|
+
});
|
|
2820
|
+
}
|
|
2821
|
+
listenDatasource() {
|
|
2822
|
+
this.datasourceService.datasource
|
|
2823
|
+
.connect()
|
|
2824
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
2825
|
+
.subscribe(() => {
|
|
2826
|
+
this.updateHeader();
|
|
2827
|
+
});
|
|
2828
|
+
}
|
|
2829
|
+
updateHeader() {
|
|
2830
|
+
if (this.selectionModel.hasValue()) {
|
|
2831
|
+
if (this.datasourceService.datasource.filteredData
|
|
2832
|
+
.filter((group) => group.controls[this.selectionLoaderService.key]?.enabled)
|
|
2833
|
+
.every((group) => this.selectionModel.isSelected(group))) {
|
|
2834
|
+
this.fm.getUiHeader().get(this.selectionLoaderService.key)?.patchValue({ indeterminate: false });
|
|
2835
|
+
this.fm.getHeader().controls[this.selectionLoaderService.key]?.patchValue(true, { emitEvent: false });
|
|
2836
|
+
}
|
|
2837
|
+
else {
|
|
2838
|
+
this.fm.getUiHeader().get(this.selectionLoaderService.key)?.patchValue({ indeterminate: true });
|
|
2839
|
+
this.fm.getHeader().controls[this.selectionLoaderService.key]?.patchValue(false, { emitEvent: false });
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2842
|
+
else {
|
|
2843
|
+
this.fm.getUiHeader().get(this.selectionLoaderService.key)?.patchValue({ indeterminate: false });
|
|
2844
|
+
this.fm.getHeader().controls[this.selectionLoaderService.key]?.patchValue(false, { emitEvent: false });
|
|
2845
|
+
}
|
|
2846
|
+
}
|
|
2847
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SelectionService, deps: [{ token: SELECTION_CONFIG, optional: true }, { token: KlesForm }, { token: SelectionLoaderService }, { token: ScrollbarService }, { token: LoadingService }, { token: DATASOURCE_SERVICE }, { token: LINES_SERVICE }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2848
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SelectionService }); }
|
|
2849
|
+
}
|
|
2850
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SelectionService, decorators: [{
|
|
2851
|
+
type: Injectable
|
|
2852
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
2853
|
+
type: Optional
|
|
2854
|
+
}, {
|
|
2855
|
+
type: Inject,
|
|
2856
|
+
args: [SELECTION_CONFIG]
|
|
2857
|
+
}] }, { type: KlesForm }, { type: SelectionLoaderService }, { type: ScrollbarService }, { type: LoadingService }, { type: DatasourceService, decorators: [{
|
|
2858
|
+
type: Inject,
|
|
2859
|
+
args: [DATASOURCE_SERVICE]
|
|
2860
|
+
}] }, { type: undefined, decorators: [{
|
|
2861
|
+
type: Inject,
|
|
2862
|
+
args: [LINES_SERVICE]
|
|
2863
|
+
}] }] });
|
|
2864
|
+
class SelectionLazyService extends AbstractSelectionService {
|
|
2865
|
+
constructor(selectionConfig, fm, selectionLoaderService, scrollbarService, loadingService, datasourceService, linesService) {
|
|
2866
|
+
super(selectionConfig);
|
|
2867
|
+
this.fm = fm;
|
|
2868
|
+
this.selectionLoaderService = selectionLoaderService;
|
|
2869
|
+
this.scrollbarService = scrollbarService;
|
|
2870
|
+
this.loadingService = loadingService;
|
|
2871
|
+
this.datasourceService = datasourceService;
|
|
2872
|
+
this.linesService = linesService;
|
|
2873
|
+
this.destroyRef = inject(DestroyRef);
|
|
2874
|
+
this._count = signal(0, ...(ngDevMode ? [{ debugName: "_count" }] : /* istanbul ignore next */ []));
|
|
2875
|
+
}
|
|
2876
|
+
register() {
|
|
2877
|
+
this.setSelection();
|
|
2878
|
+
this.listenHeaderSelection();
|
|
2879
|
+
this.listenRowSelection();
|
|
2880
|
+
}
|
|
2881
|
+
count() {
|
|
2882
|
+
return this._count.asReadonly();
|
|
2883
|
+
}
|
|
2884
|
+
disable() {
|
|
2885
|
+
this.fm.getHeader().controls[this.key].disable({ emitEvent: false });
|
|
2886
|
+
}
|
|
2887
|
+
enable() {
|
|
2888
|
+
this.fm.getHeader().controls[this.key].enable({ emitEvent: false });
|
|
2889
|
+
}
|
|
2890
|
+
listenHeaderSelection() {
|
|
2891
|
+
this.fm
|
|
2892
|
+
.getHeader()
|
|
2893
|
+
.controls[this.key].valueChanges.pipe(takeUntilDestroyed(this.destroyRef), switchMap((value) => {
|
|
2894
|
+
return this.selectionLoaderService.selectAll(!!value, this.fm.getHeader().getRawValue());
|
|
2895
|
+
}))
|
|
2896
|
+
.subscribe((response) => {
|
|
2897
|
+
if (response.loading) {
|
|
2898
|
+
this.scrollbarService.toTop('instant');
|
|
2899
|
+
this.loadingService.start();
|
|
2900
|
+
return;
|
|
2901
|
+
}
|
|
2902
|
+
else {
|
|
2903
|
+
this.loadingService.stop();
|
|
2904
|
+
this._count.set(response.count ?? 0);
|
|
2905
|
+
this.fm
|
|
2906
|
+
.getRows()
|
|
2907
|
+
.controls.filter((group) => group.controls[this.key]?.enabled)
|
|
2908
|
+
.forEach((group) => {
|
|
2909
|
+
group.controls[this.selectionLoaderService.key].patchValue(response.selected, { emitEvent: false });
|
|
2910
|
+
});
|
|
2911
|
+
this.fm.getRows().updateValueAndValidity({ emitEvent: false });
|
|
2912
|
+
// if (response.footer) {
|
|
2913
|
+
// this.fm.getFooter().patchValue(response.footer, { emitEvent: false });
|
|
2914
|
+
// }
|
|
2915
|
+
}
|
|
2916
|
+
});
|
|
2917
|
+
}
|
|
2918
|
+
listenRowSelection() {
|
|
2919
|
+
this.datasourceService.datasource
|
|
2920
|
+
.connect()
|
|
2921
|
+
.pipe(takeUntilDestroyed(this.destroyRef), auditTime(0), switchMap((rows) => {
|
|
2922
|
+
return merge(...rows
|
|
2923
|
+
.map((row) => {
|
|
2924
|
+
return row.controls[this.selectionLoaderService.key]?.valueChanges.pipe(map((value) => {
|
|
2925
|
+
return { row, selected: !!value };
|
|
2926
|
+
}));
|
|
2927
|
+
})
|
|
2928
|
+
.filter(Boolean));
|
|
2929
|
+
}), concatMap(({ row, selected }) => {
|
|
2930
|
+
return this.selectionLoaderService.select(row, selected).pipe(map((response) => {
|
|
2931
|
+
return {
|
|
2932
|
+
row,
|
|
2933
|
+
response,
|
|
2934
|
+
};
|
|
2935
|
+
}));
|
|
2936
|
+
}))
|
|
2937
|
+
.subscribe(({ row, response }) => {
|
|
2938
|
+
if (response.loading) {
|
|
2939
|
+
//mettre la ligne avec un spinner
|
|
2940
|
+
}
|
|
2941
|
+
else {
|
|
2942
|
+
this.fm
|
|
2943
|
+
.getUiHeader()
|
|
2944
|
+
.get(this.selectionLoaderService.key)
|
|
2945
|
+
?.patchValue({
|
|
2946
|
+
indeterminate: response.count != undefined ? response.count > 0 && this.linesService.total() > response.count : false,
|
|
2947
|
+
});
|
|
2948
|
+
// if (footer) {
|
|
2949
|
+
// this.fm.getFooter().patchValue(footer, { emitEvent: false });
|
|
2950
|
+
// }
|
|
2951
|
+
}
|
|
2952
|
+
});
|
|
2953
|
+
}
|
|
2954
|
+
setSelection() {
|
|
2955
|
+
this.linesService
|
|
2956
|
+
.loaded()
|
|
2957
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
2958
|
+
.subscribe(() => {
|
|
2959
|
+
this.fm.getRows().controls.forEach((group) => {
|
|
2960
|
+
if (this.selectionConfig?.isSelected != undefined && this.selectionConfig.isSelected(group)) {
|
|
2961
|
+
group.controls[this.selectionLoaderService.key]?.patchValue(true, { emitEvent: false });
|
|
2962
|
+
}
|
|
2963
|
+
if (this.selectionConfig?.isDisabled && this.selectionConfig.isDisabled(group)) {
|
|
2964
|
+
group.controls[this.selectionLoaderService.key]?.disable({ emitEvent: false });
|
|
2965
|
+
}
|
|
2966
|
+
});
|
|
2967
|
+
// this.updateHeader();
|
|
2968
|
+
});
|
|
2969
|
+
}
|
|
2970
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SelectionLazyService, deps: [{ token: SELECTION_CONFIG, optional: true }, { token: KlesForm }, { token: SelectionLoaderService }, { token: ScrollbarService }, { token: LoadingService }, { token: DATASOURCE_SERVICE }, { token: LINES_SERVICE }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2971
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SelectionLazyService }); }
|
|
2972
|
+
}
|
|
2973
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: SelectionLazyService, decorators: [{
|
|
2974
|
+
type: Injectable
|
|
2975
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
2976
|
+
type: Optional
|
|
2977
|
+
}, {
|
|
2978
|
+
type: Inject,
|
|
2979
|
+
args: [SELECTION_CONFIG]
|
|
2980
|
+
}] }, { type: KlesForm }, { type: SelectionLoaderService }, { type: ScrollbarService }, { type: LoadingService }, { type: DatasourceService, decorators: [{
|
|
2981
|
+
type: Inject,
|
|
2982
|
+
args: [DATASOURCE_SERVICE]
|
|
2983
|
+
}] }, { type: undefined, decorators: [{
|
|
2984
|
+
type: Inject,
|
|
2985
|
+
args: [LINES_SERVICE]
|
|
2986
|
+
}] }] });
|
|
2987
|
+
|
|
2988
|
+
class LoaderService {
|
|
2989
|
+
constructor(loaderConfig, eventsService) {
|
|
2990
|
+
this.loaderConfig = loaderConfig;
|
|
2991
|
+
this.eventsService = eventsService;
|
|
2992
|
+
this._refresh$ = new Subject();
|
|
2993
|
+
this.init();
|
|
2994
|
+
}
|
|
2995
|
+
init() {
|
|
2996
|
+
const linesLoader = this.loaderConfig.lines;
|
|
2997
|
+
this._loader$ = combineLatest([this._refresh$.pipe(startWith(void 0)), this.loaderConfig.lines.params?.() || of({})]).pipe(auditTime(0), switchMap(([_, params]) => {
|
|
2998
|
+
return concat(of({ loading: true, total: 0, items: [] }), linesLoader.loader(params).pipe(catchError((err) => {
|
|
2999
|
+
return of({ error: err, items: [] });
|
|
3000
|
+
}), map((response) => {
|
|
3001
|
+
return { ...response, loading: false, total: response?.items.length || 0 };
|
|
3002
|
+
})));
|
|
3003
|
+
}), shareReplay({ bufferSize: 1, refCount: true }));
|
|
3004
|
+
}
|
|
3005
|
+
load() {
|
|
3006
|
+
return this._loader$;
|
|
3007
|
+
}
|
|
3008
|
+
refresh() {
|
|
3009
|
+
this._refresh$.next();
|
|
3010
|
+
this.eventsService.emit('refresh');
|
|
3011
|
+
}
|
|
3012
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LoaderService, deps: [{ token: LOADER_CONFIG }, { token: EventsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3013
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LoaderService }); }
|
|
3014
|
+
}
|
|
3015
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LoaderService, decorators: [{
|
|
3016
|
+
type: Injectable
|
|
3017
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
3018
|
+
type: Inject,
|
|
3019
|
+
args: [LOADER_CONFIG]
|
|
3020
|
+
}] }, { type: EventsService }] });
|
|
3021
|
+
class LoaderLazyService {
|
|
3022
|
+
constructor(loaderConfig, paginatorStore, sortStore, filterStore, eventsService) {
|
|
3023
|
+
this.loaderConfig = loaderConfig;
|
|
3024
|
+
this.paginatorStore = paginatorStore;
|
|
3025
|
+
this.sortStore = sortStore;
|
|
3026
|
+
this.filterStore = filterStore;
|
|
3027
|
+
this.eventsService = eventsService;
|
|
3028
|
+
this._refresh$ = new Subject();
|
|
3029
|
+
this.init();
|
|
3030
|
+
}
|
|
3031
|
+
load() {
|
|
3032
|
+
return this._loader$;
|
|
3033
|
+
}
|
|
3034
|
+
init() {
|
|
3035
|
+
const linesLoader = this.loaderConfig.lines;
|
|
3036
|
+
this._loader$ = combineLatest([
|
|
3037
|
+
this._refresh$.pipe(startWith(void 0)),
|
|
3038
|
+
this.loaderConfig.lines.params?.() || of({}),
|
|
3039
|
+
this.paginatorStore?.page$ || of(undefined),
|
|
3040
|
+
this.sortStore?.sort$ || of(undefined),
|
|
3041
|
+
this.filterStore?.filters$ || of({}),
|
|
3042
|
+
]).pipe(auditTime(0), switchMap(([_, params, pagination, sort, filters]) => {
|
|
3043
|
+
return concat(of({ loading: true, total: 0, items: [] }), linesLoader.loader(params, { filters, pagination, sort }).pipe(catchError((err) => {
|
|
3044
|
+
return of({ error: err, items: [], total: 0 });
|
|
3045
|
+
}), map((response) => {
|
|
3046
|
+
return { ...response, loading: false };
|
|
3047
|
+
})));
|
|
3048
|
+
}), shareReplay({ bufferSize: 1, refCount: true }));
|
|
3049
|
+
}
|
|
3050
|
+
refresh() {
|
|
3051
|
+
this._refresh$.next();
|
|
3052
|
+
this.eventsService.emit('refresh');
|
|
3053
|
+
}
|
|
3054
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LoaderLazyService, deps: [{ token: LOADER_CONFIG }, { token: PaginatorStore, optional: true }, { token: SortStore, optional: true }, { token: FilterStore, optional: true }, { token: EventsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3055
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LoaderLazyService }); }
|
|
3056
|
+
}
|
|
3057
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LoaderLazyService, decorators: [{
|
|
3058
|
+
type: Injectable
|
|
3059
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
3060
|
+
type: Inject,
|
|
3061
|
+
args: [LOADER_CONFIG]
|
|
3062
|
+
}] }, { type: PaginatorStore, decorators: [{
|
|
3063
|
+
type: Optional
|
|
3064
|
+
}] }, { type: SortStore, decorators: [{
|
|
3065
|
+
type: Optional
|
|
3066
|
+
}] }, { type: FilterStore, decorators: [{
|
|
3067
|
+
type: Optional
|
|
3068
|
+
}] }, { type: EventsService }] });
|
|
3069
|
+
|
|
3070
|
+
class LinesService {
|
|
3071
|
+
constructor(loader, fm, columnsService, rowFactory, extraRowService, eventsService) {
|
|
3072
|
+
this.loader = loader;
|
|
3073
|
+
this.fm = fm;
|
|
3074
|
+
this.columnsService = columnsService;
|
|
3075
|
+
this.rowFactory = rowFactory;
|
|
3076
|
+
this.extraRowService = extraRowService;
|
|
3077
|
+
this.eventsService = eventsService;
|
|
3078
|
+
this.destroyRef = inject(DestroyRef);
|
|
3079
|
+
this._loaded = new EventEmitter();
|
|
3080
|
+
}
|
|
3081
|
+
register() {
|
|
3082
|
+
this.load();
|
|
3083
|
+
}
|
|
3084
|
+
total() {
|
|
3085
|
+
return this._total ?? 0;
|
|
3086
|
+
}
|
|
3087
|
+
loaded() {
|
|
3088
|
+
return this._loaded;
|
|
3089
|
+
}
|
|
3090
|
+
load() {
|
|
3091
|
+
this.loader
|
|
3092
|
+
.load()
|
|
3093
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
3094
|
+
.subscribe((response) => {
|
|
3095
|
+
if (response.loading) {
|
|
3096
|
+
this.eventsService.emit('loadStart');
|
|
3097
|
+
}
|
|
3098
|
+
else {
|
|
3099
|
+
if (response.error) {
|
|
3100
|
+
this.eventsService.emit('loadError', {
|
|
3101
|
+
error: response.error,
|
|
3102
|
+
message: response.error?.message,
|
|
3103
|
+
});
|
|
3104
|
+
}
|
|
3105
|
+
else {
|
|
3106
|
+
this.fm.setRows(this.rowFactory.createRows(this.columnsService
|
|
3107
|
+
.columns()
|
|
3108
|
+
.map((col) => ({ ...col.cell.field, name: col.columnDef }))
|
|
3109
|
+
.concat(this.extraRowService.extraColumns().map((col) => ({ ...col, name: col.columnDef }))), response.items ?? []));
|
|
3110
|
+
this._total = response.items?.length ?? 0;
|
|
3111
|
+
this._loaded.next();
|
|
3112
|
+
this.eventsService.emit('loadSuccess', {
|
|
3113
|
+
total: this._total,
|
|
3114
|
+
values: response.items,
|
|
3115
|
+
rawValues: this.fm.getRows().getRawValue(),
|
|
3116
|
+
rows: this.fm.getRows().controls,
|
|
3117
|
+
});
|
|
3118
|
+
}
|
|
3119
|
+
}
|
|
3120
|
+
});
|
|
3121
|
+
}
|
|
3122
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LinesService, deps: [{ token: LOADER_SERVICE }, { token: KlesForm }, { token: ColumnsService }, { token: RowFormFactory }, { token: ExtraRowService }, { token: EventsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3123
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LinesService }); }
|
|
3124
|
+
}
|
|
3125
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LinesService, decorators: [{
|
|
3126
|
+
type: Injectable
|
|
3127
|
+
}], ctorParameters: () => [{ type: LoaderService, decorators: [{
|
|
3128
|
+
type: Inject,
|
|
3129
|
+
args: [LOADER_SERVICE]
|
|
3130
|
+
}] }, { type: KlesForm }, { type: ColumnsService }, { type: RowFormFactory }, { type: ExtraRowService }, { type: EventsService }] });
|
|
3131
|
+
class LinesLazyService {
|
|
3132
|
+
constructor(loader, fm, columnsService, rowFactory, extraRowService, paginatorService, eventsService) {
|
|
3133
|
+
this.loader = loader;
|
|
3134
|
+
this.fm = fm;
|
|
3135
|
+
this.columnsService = columnsService;
|
|
3136
|
+
this.rowFactory = rowFactory;
|
|
3137
|
+
this.extraRowService = extraRowService;
|
|
3138
|
+
this.paginatorService = paginatorService;
|
|
3139
|
+
this.eventsService = eventsService;
|
|
3140
|
+
this.destroyRef = inject(DestroyRef);
|
|
3141
|
+
this._refresh$ = new Subject();
|
|
3142
|
+
this._loaded = new EventEmitter();
|
|
3143
|
+
}
|
|
3144
|
+
register() {
|
|
3145
|
+
this.load();
|
|
3146
|
+
}
|
|
3147
|
+
total() {
|
|
3148
|
+
return this._total ?? 0;
|
|
3149
|
+
}
|
|
3150
|
+
loaded() {
|
|
3151
|
+
return this._loaded;
|
|
3152
|
+
}
|
|
3153
|
+
refresh() {
|
|
3154
|
+
this._refresh$.next();
|
|
3155
|
+
}
|
|
3156
|
+
load() {
|
|
3157
|
+
this.loader
|
|
3158
|
+
.load()
|
|
3159
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
3160
|
+
.subscribe((response) => {
|
|
3161
|
+
if (response.loading) {
|
|
3162
|
+
this.eventsService.emit('loadStart');
|
|
3163
|
+
}
|
|
3164
|
+
else {
|
|
3165
|
+
if (response.error) {
|
|
3166
|
+
this.eventsService.emit('loadError', {
|
|
3167
|
+
error: response.error,
|
|
3168
|
+
message: response.error?.message,
|
|
3169
|
+
});
|
|
3170
|
+
}
|
|
3171
|
+
else {
|
|
3172
|
+
this.fm.setRows(this.rowFactory.createRows(this.columnsService
|
|
3173
|
+
.columns()
|
|
3174
|
+
.map((col) => ({ ...col.cell.field, name: col.columnDef }))
|
|
3175
|
+
.concat(this.extraRowService.extraColumns().map((col) => ({ ...col, name: col.columnDef }))), response.items));
|
|
3176
|
+
this.paginatorService.setlength(response.total ?? 0);
|
|
3177
|
+
this._total = response.total ?? 0;
|
|
3178
|
+
this._loaded.next();
|
|
3179
|
+
this.eventsService.emit('loadSuccess', {
|
|
3180
|
+
total: this._total ?? 0,
|
|
3181
|
+
values: response.items,
|
|
3182
|
+
rawValues: this.fm.getRows().getRawValue(),
|
|
3183
|
+
rows: this.fm.getRows().controls,
|
|
3184
|
+
});
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3187
|
+
});
|
|
3188
|
+
}
|
|
3189
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LinesLazyService, deps: [{ token: LOADER_SERVICE }, { token: KlesForm }, { token: ColumnsService }, { token: RowFormFactory }, { token: ExtraRowService }, { token: PaginatorService }, { token: EventsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3190
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LinesLazyService }); }
|
|
3191
|
+
}
|
|
3192
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LinesLazyService, decorators: [{
|
|
3193
|
+
type: Injectable
|
|
3194
|
+
}], ctorParameters: () => [{ type: LoaderLazyService, decorators: [{
|
|
3195
|
+
type: Inject,
|
|
3196
|
+
args: [LOADER_SERVICE]
|
|
3197
|
+
}] }, { type: KlesForm }, { type: ColumnsService }, { type: RowFormFactory }, { type: ExtraRowService }, { type: PaginatorService }, { type: EventsService }] });
|
|
3198
|
+
|
|
3199
|
+
class LoadingOrchestratorService {
|
|
3200
|
+
constructor(loader, loadingService) {
|
|
3201
|
+
this.loader = loader;
|
|
3202
|
+
this.loadingService = loadingService;
|
|
3203
|
+
this.destroyRef = inject(DestroyRef);
|
|
3204
|
+
}
|
|
3205
|
+
register() {
|
|
3206
|
+
this.listen();
|
|
3207
|
+
}
|
|
3208
|
+
listen() {
|
|
3209
|
+
this.loader
|
|
3210
|
+
.load()
|
|
3211
|
+
.pipe(takeUntilDestroyed(this.destroyRef), map((response) => response.loading ?? false))
|
|
3212
|
+
.subscribe((loading) => {
|
|
3213
|
+
if (loading) {
|
|
3214
|
+
this.loadingService.start();
|
|
3215
|
+
}
|
|
3216
|
+
else {
|
|
3217
|
+
this.loadingService.stop();
|
|
3218
|
+
}
|
|
3219
|
+
});
|
|
3220
|
+
}
|
|
3221
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LoadingOrchestratorService, deps: [{ token: LOADER_SERVICE }, { token: LoadingService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3222
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LoadingOrchestratorService }); }
|
|
3223
|
+
}
|
|
3224
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: LoadingOrchestratorService, decorators: [{
|
|
3225
|
+
type: Injectable
|
|
3226
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
3227
|
+
type: Inject,
|
|
3228
|
+
args: [LOADER_SERVICE]
|
|
3229
|
+
}] }, { type: LoadingService }] });
|
|
3230
|
+
|
|
3231
|
+
class TableService {
|
|
3232
|
+
constructor(klesForm, columnsService, datasourceService, linesService, headerService, selectionService, loadingOrchestratorService, scrollbarOrchestratorService) {
|
|
3233
|
+
this.klesForm = klesForm;
|
|
3234
|
+
this.columnsService = columnsService;
|
|
3235
|
+
this.datasourceService = datasourceService;
|
|
3236
|
+
this.linesService = linesService;
|
|
3237
|
+
this.headerService = headerService;
|
|
3238
|
+
this.selectionService = selectionService;
|
|
3239
|
+
this.loadingOrchestratorService = loadingOrchestratorService;
|
|
3240
|
+
this.scrollbarOrchestratorService = scrollbarOrchestratorService;
|
|
3241
|
+
this.trackBy = (_, row) => row.get('_id')?.value ?? row;
|
|
3242
|
+
this.orchestrators();
|
|
3243
|
+
this.features();
|
|
3244
|
+
}
|
|
3245
|
+
get ui() {
|
|
3246
|
+
return this.klesForm.ui;
|
|
3247
|
+
}
|
|
3248
|
+
get form() {
|
|
3249
|
+
return this.klesForm.form;
|
|
3250
|
+
}
|
|
3251
|
+
orchestrators() {
|
|
3252
|
+
this.scrollbarOrchestratorService.register();
|
|
3253
|
+
this.loadingOrchestratorService.register();
|
|
3254
|
+
}
|
|
3255
|
+
features() {
|
|
3256
|
+
this.columnsService.register();
|
|
3257
|
+
this.klesForm.init();
|
|
3258
|
+
this.datasourceService.register();
|
|
3259
|
+
this.headerService.register();
|
|
3260
|
+
this.linesService.register();
|
|
3261
|
+
this.selectionService.register();
|
|
3262
|
+
}
|
|
3263
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: TableService, deps: [{ token: KlesForm }, { token: ColumnsService }, { token: DATASOURCE_SERVICE }, { token: LINES_SERVICE }, { token: HEADER_SERVICE }, { token: SELECTION_SERVICE }, { token: LoadingOrchestratorService }, { token: SCROLLBAR_ORCHESTRATOR_SERVICE }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3264
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: TableService }); }
|
|
3265
|
+
}
|
|
3266
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: TableService, decorators: [{
|
|
3267
|
+
type: Injectable
|
|
3268
|
+
}], ctorParameters: () => [{ type: KlesForm }, { type: ColumnsService }, { type: undefined, decorators: [{
|
|
3269
|
+
type: Inject,
|
|
3270
|
+
args: [DATASOURCE_SERVICE]
|
|
3271
|
+
}] }, { type: undefined, decorators: [{
|
|
3272
|
+
type: Inject,
|
|
3273
|
+
args: [LINES_SERVICE]
|
|
3274
|
+
}] }, { type: undefined, decorators: [{
|
|
3275
|
+
type: Inject,
|
|
3276
|
+
args: [HEADER_SERVICE]
|
|
3277
|
+
}] }, { type: undefined, decorators: [{
|
|
3278
|
+
type: Inject,
|
|
3279
|
+
args: [SELECTION_SERVICE]
|
|
3280
|
+
}] }, { type: LoadingOrchestratorService }, { type: undefined, decorators: [{
|
|
3281
|
+
type: Inject,
|
|
3282
|
+
args: [SCROLLBAR_ORCHESTRATOR_SERVICE]
|
|
3283
|
+
}] }] });
|
|
3284
|
+
|
|
3285
|
+
class ScrollbarOrchestratorService {
|
|
3286
|
+
constructor(linesService, scrollbarService, paginatorService, sortService) {
|
|
3287
|
+
this.linesService = linesService;
|
|
3288
|
+
this.scrollbarService = scrollbarService;
|
|
3289
|
+
this.paginatorService = paginatorService;
|
|
3290
|
+
this.sortService = sortService;
|
|
3291
|
+
this.destroyRef = inject(DestroyRef);
|
|
3292
|
+
}
|
|
3293
|
+
register() {
|
|
3294
|
+
this.listen();
|
|
3295
|
+
}
|
|
3296
|
+
listen() {
|
|
3297
|
+
this.linesService
|
|
3298
|
+
.loaded()
|
|
3299
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
3300
|
+
.subscribe(() => {
|
|
3301
|
+
this.scrollbarService.toTop('instant');
|
|
3302
|
+
});
|
|
3303
|
+
this.paginatorService
|
|
3304
|
+
?.pageChanged()
|
|
3305
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
3306
|
+
.subscribe(() => {
|
|
3307
|
+
this.scrollbarService.toTop('instant');
|
|
3308
|
+
});
|
|
3309
|
+
this.sortService
|
|
3310
|
+
?.sortChange()
|
|
3311
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
3312
|
+
.subscribe(() => {
|
|
3313
|
+
this.scrollbarService.toTop('instant');
|
|
3314
|
+
});
|
|
3315
|
+
}
|
|
3316
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ScrollbarOrchestratorService, deps: [{ token: LINES_SERVICE }, { token: ScrollbarService }, { token: PaginatorService, optional: true }, { token: SORT_SERVICE, optional: true }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3317
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ScrollbarOrchestratorService }); }
|
|
3318
|
+
}
|
|
3319
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ScrollbarOrchestratorService, decorators: [{
|
|
3320
|
+
type: Injectable
|
|
3321
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
3322
|
+
type: Inject,
|
|
3323
|
+
args: [LINES_SERVICE]
|
|
3324
|
+
}] }, { type: ScrollbarService }, { type: PaginatorService, decorators: [{
|
|
3325
|
+
type: Optional
|
|
3326
|
+
}] }, { type: undefined, decorators: [{
|
|
3327
|
+
type: Optional
|
|
3328
|
+
}, {
|
|
3329
|
+
type: Inject,
|
|
3330
|
+
args: [SORT_SERVICE]
|
|
3331
|
+
}] }] });
|
|
3332
|
+
class ScrollbarLazyOrchestratorService {
|
|
3333
|
+
constructor(linesService, scrollbarService) {
|
|
3334
|
+
this.linesService = linesService;
|
|
3335
|
+
this.scrollbarService = scrollbarService;
|
|
3336
|
+
this.destroyRef = inject(DestroyRef);
|
|
3337
|
+
}
|
|
3338
|
+
register() {
|
|
3339
|
+
this.listen();
|
|
3340
|
+
}
|
|
3341
|
+
listen() {
|
|
3342
|
+
this.linesService
|
|
3343
|
+
.loaded()
|
|
3344
|
+
.pipe(takeUntilDestroyed(this.destroyRef))
|
|
3345
|
+
.subscribe(() => {
|
|
3346
|
+
this.scrollbarService.toTop('instant');
|
|
3347
|
+
});
|
|
3348
|
+
}
|
|
3349
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ScrollbarLazyOrchestratorService, deps: [{ token: LINES_SERVICE }, { token: ScrollbarService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3350
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ScrollbarLazyOrchestratorService }); }
|
|
3351
|
+
}
|
|
3352
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: ScrollbarLazyOrchestratorService, decorators: [{
|
|
3353
|
+
type: Injectable
|
|
3354
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
3355
|
+
type: Inject,
|
|
3356
|
+
args: [LINES_SERVICE]
|
|
3357
|
+
}] }, { type: ScrollbarService }] });
|
|
3358
|
+
|
|
3359
|
+
// import { ScrollbarLazyOrchestratorService, ScrollbarOrchestratorService } from '../services/features/scrollbar/scrollbar-orchestrator.service';
|
|
3360
|
+
class DynamicTableLoaderDirective {
|
|
3361
|
+
constructor(viewContainerRef) {
|
|
3362
|
+
this.viewContainerRef = viewContainerRef;
|
|
3363
|
+
this.tableConfig = input.required({ ...(ngDevMode ? { debugName: "tableConfig" } : /* istanbul ignore next */ {}), transform: (v) => {
|
|
3364
|
+
v.columns = v.columns.map((col) => {
|
|
3365
|
+
if (col.headerCell.field) {
|
|
3366
|
+
col.headerCell.field.subscriptSizing = col.headerCell.field.subscriptSizing ?? 'dynamic';
|
|
3367
|
+
}
|
|
3368
|
+
return col;
|
|
3369
|
+
});
|
|
3370
|
+
return v;
|
|
3371
|
+
} });
|
|
3372
|
+
this.componentRef = null;
|
|
3373
|
+
effect(() => {
|
|
3374
|
+
if (this.tableConfig()) {
|
|
3375
|
+
this.loadComponent();
|
|
3376
|
+
}
|
|
3377
|
+
else {
|
|
3378
|
+
this.clearComponent();
|
|
3379
|
+
}
|
|
3380
|
+
});
|
|
3381
|
+
}
|
|
3382
|
+
ngOnInit() { }
|
|
3383
|
+
ngOnDestroy() {
|
|
3384
|
+
this.clearComponent();
|
|
3385
|
+
}
|
|
3386
|
+
loadComponent() {
|
|
3387
|
+
if (this.componentRef) {
|
|
3388
|
+
this.clearComponent();
|
|
3389
|
+
}
|
|
3390
|
+
this.viewContainerRef.clear();
|
|
3391
|
+
let component = TableComponent;
|
|
3392
|
+
if (this.tableConfig().paginator) {
|
|
3393
|
+
component = PaginateTableComponent;
|
|
3394
|
+
}
|
|
3395
|
+
else if (this.tableConfig().infinite) {
|
|
3396
|
+
component = InfiniteScrollTableComponent;
|
|
3397
|
+
}
|
|
3398
|
+
const injector = this.initInjector();
|
|
3399
|
+
this.componentRef = this.viewContainerRef.createComponent(component, {
|
|
3400
|
+
injector,
|
|
3401
|
+
});
|
|
3402
|
+
this.componentRef.onDestroy(() => {
|
|
3403
|
+
if (isDestroyable(injector)) {
|
|
3404
|
+
injector.destroy();
|
|
3405
|
+
}
|
|
3406
|
+
});
|
|
3407
|
+
}
|
|
3408
|
+
clearComponent() {
|
|
3409
|
+
if (this.componentRef) {
|
|
3410
|
+
this.componentRef.destroy();
|
|
3411
|
+
this.componentRef = null;
|
|
3412
|
+
}
|
|
3413
|
+
}
|
|
3414
|
+
initInjector() {
|
|
3415
|
+
const storeProviders = [SortStore, FilterStore, ...(this.tableConfig().paginator ? [PaginatorStore] : []), ExpandedRowStore];
|
|
3416
|
+
const configProviders = [
|
|
3417
|
+
{
|
|
3418
|
+
provide: COLUMNS,
|
|
3419
|
+
useValue: signal(this.tableConfig().columns || []),
|
|
3420
|
+
},
|
|
3421
|
+
{
|
|
3422
|
+
provide: EXTRA_ROWS,
|
|
3423
|
+
useValue: signal(this.tableConfig().extraRows ?? []),
|
|
3424
|
+
},
|
|
3425
|
+
{
|
|
3426
|
+
provide: FOOTER,
|
|
3427
|
+
useValue: signal(this.tableConfig().footer ?? false),
|
|
3428
|
+
},
|
|
3429
|
+
{
|
|
3430
|
+
provide: LOADER_CONFIG,
|
|
3431
|
+
useValue: {
|
|
3432
|
+
lazy: this.tableConfig().lazy,
|
|
3433
|
+
lines: this.tableConfig().lines,
|
|
3434
|
+
},
|
|
3435
|
+
},
|
|
3436
|
+
{
|
|
3437
|
+
provide: SORT_CONFIG,
|
|
3438
|
+
useValue: this.tableConfig().sortConfig,
|
|
3439
|
+
},
|
|
3440
|
+
{
|
|
3441
|
+
provide: SELECTION_CONFIG,
|
|
3442
|
+
useValue: this.tableConfig().selection,
|
|
3443
|
+
},
|
|
3444
|
+
{
|
|
3445
|
+
provide: PAGINATOR_CONFIG,
|
|
3446
|
+
useValue: {
|
|
3447
|
+
paginator: this.tableConfig().paginator || false,
|
|
3448
|
+
customMatPaginatorIntl: this.tableConfig().customMatPaginatorIntl,
|
|
3449
|
+
pageSize: this.tableConfig().pageSize,
|
|
3450
|
+
pageSizeOptions: this.tableConfig().pageSizeOptions,
|
|
3451
|
+
},
|
|
3452
|
+
},
|
|
3453
|
+
...(this.tableConfig().customMatPaginatorIntl
|
|
3454
|
+
? [
|
|
3455
|
+
{
|
|
3456
|
+
provide: MatPaginatorIntl,
|
|
3457
|
+
useClass: this.tableConfig().customMatPaginatorIntl,
|
|
3458
|
+
},
|
|
3459
|
+
]
|
|
3460
|
+
: []),
|
|
3461
|
+
];
|
|
3462
|
+
const orchestratorProviders = [
|
|
3463
|
+
LoadingOrchestratorService,
|
|
3464
|
+
...(this.tableConfig().lazy
|
|
3465
|
+
? [
|
|
3466
|
+
{
|
|
3467
|
+
provide: SCROLLBAR_ORCHESTRATOR_SERVICE,
|
|
3468
|
+
useClass: ScrollbarLazyOrchestratorService,
|
|
3469
|
+
},
|
|
3470
|
+
]
|
|
3471
|
+
: [
|
|
3472
|
+
{
|
|
3473
|
+
provide: SCROLLBAR_ORCHESTRATOR_SERVICE,
|
|
3474
|
+
useClass: ScrollbarOrchestratorService,
|
|
3475
|
+
},
|
|
3476
|
+
]),
|
|
3477
|
+
];
|
|
3478
|
+
const datasourceProvider = this.tableConfig().lazy
|
|
3479
|
+
? [
|
|
3480
|
+
{
|
|
3481
|
+
provide: DATASOURCE_SERVICE,
|
|
3482
|
+
useClass: DatasourceLazyService,
|
|
3483
|
+
},
|
|
3484
|
+
]
|
|
3485
|
+
: [
|
|
3486
|
+
{
|
|
3487
|
+
provide: DATASOURCE_SERVICE,
|
|
3488
|
+
useClass: DatasourceService,
|
|
3489
|
+
},
|
|
3490
|
+
];
|
|
3491
|
+
const featureProviders = [
|
|
3492
|
+
TreeService,
|
|
3493
|
+
RenderService,
|
|
3494
|
+
ExtraRowService,
|
|
3495
|
+
LoadingService,
|
|
3496
|
+
KlesForm,
|
|
3497
|
+
ColumnsService,
|
|
3498
|
+
FooterService,
|
|
3499
|
+
ScrollbarService,
|
|
3500
|
+
EventsService,
|
|
3501
|
+
RowService,
|
|
3502
|
+
CellService,
|
|
3503
|
+
CellValueChangeService,
|
|
3504
|
+
ValidationService,
|
|
3505
|
+
SelectionLoaderService,
|
|
3506
|
+
PaginatorService,
|
|
3507
|
+
LoaderChildrensService, //TODO
|
|
3508
|
+
{
|
|
3509
|
+
provide: TABLE_SERVICE,
|
|
3510
|
+
useClass: TableService,
|
|
3511
|
+
},
|
|
3512
|
+
...(this.tableConfig().lazy
|
|
3513
|
+
? [
|
|
3514
|
+
{
|
|
3515
|
+
provide: HEADER_SERVICE,
|
|
3516
|
+
useClass: HeaderLazyService,
|
|
3517
|
+
},
|
|
3518
|
+
{
|
|
3519
|
+
provide: LOADER_SERVICE,
|
|
3520
|
+
useClass: LoaderLazyService,
|
|
3521
|
+
},
|
|
3522
|
+
{
|
|
3523
|
+
provide: LINES_SERVICE,
|
|
3524
|
+
useClass: LinesLazyService,
|
|
3525
|
+
},
|
|
3526
|
+
{
|
|
3527
|
+
provide: SELECTION_SERVICE,
|
|
3528
|
+
useClass: SelectionLazyService,
|
|
3529
|
+
},
|
|
3530
|
+
{
|
|
3531
|
+
provide: ROW_DRAG_DROP,
|
|
3532
|
+
useFactory: () => new DragDropLazyService(this.tableConfig().dragDropRows),
|
|
3533
|
+
},
|
|
3534
|
+
{
|
|
3535
|
+
provide: SORT_SERVICE,
|
|
3536
|
+
useClass: SortLazyService,
|
|
3537
|
+
},
|
|
3538
|
+
]
|
|
3539
|
+
: [
|
|
3540
|
+
{
|
|
3541
|
+
provide: LOADER_SERVICE,
|
|
3542
|
+
useClass: LoaderService,
|
|
3543
|
+
},
|
|
3544
|
+
{
|
|
3545
|
+
provide: HEADER_SERVICE,
|
|
3546
|
+
useClass: HeaderService,
|
|
3547
|
+
},
|
|
3548
|
+
{
|
|
3549
|
+
provide: LINES_SERVICE,
|
|
3550
|
+
useClass: LinesService,
|
|
3551
|
+
},
|
|
3552
|
+
{
|
|
3553
|
+
provide: SELECTION_SERVICE,
|
|
3554
|
+
useClass: SelectionService,
|
|
3555
|
+
},
|
|
3556
|
+
FilterService,
|
|
3557
|
+
{
|
|
3558
|
+
provide: ROW_DRAG_DROP,
|
|
3559
|
+
useFactory: (paginatorstore) => new DragDropService(this.tableConfig().dragDropRows, paginatorstore),
|
|
3560
|
+
deps: [...(this.tableConfig().paginator ? [PaginatorStore] : [])],
|
|
3561
|
+
},
|
|
3562
|
+
{
|
|
3563
|
+
provide: SORT_SERVICE,
|
|
3564
|
+
useClass: SortService,
|
|
3565
|
+
},
|
|
3566
|
+
]),
|
|
3567
|
+
];
|
|
3568
|
+
const providers = [
|
|
3569
|
+
storeProviders,
|
|
3570
|
+
configProviders,
|
|
3571
|
+
datasourceProvider,
|
|
3572
|
+
featureProviders,
|
|
3573
|
+
orchestratorProviders,
|
|
3574
|
+
];
|
|
3575
|
+
return Injector.create({
|
|
3576
|
+
parent: this.viewContainerRef.injector,
|
|
3577
|
+
providers,
|
|
3578
|
+
});
|
|
3579
|
+
}
|
|
3580
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: DynamicTableLoaderDirective, deps: [{ token: i0.ViewContainerRef }], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
3581
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.2.19", type: DynamicTableLoaderDirective, isStandalone: true, selector: "[appDynamicTableLoader]", inputs: { tableConfig: { classPropertyName: "tableConfig", publicName: "tableConfig", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0 }); }
|
|
3582
|
+
}
|
|
3583
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: DynamicTableLoaderDirective, decorators: [{
|
|
3584
|
+
type: Directive,
|
|
3585
|
+
args: [{
|
|
3586
|
+
selector: '[appDynamicTableLoader]',
|
|
3587
|
+
}]
|
|
3588
|
+
}], ctorParameters: () => [{ type: i0.ViewContainerRef }], propDecorators: { tableConfig: [{ type: i0.Input, args: [{ isSignal: true, alias: "tableConfig", required: true }] }] } });
|
|
3589
|
+
|
|
3590
|
+
class KlesTableComponent {
|
|
3591
|
+
// @Output() selectionChange = new EventEmitter<KlesTableSelectionChangePayload<TValue>>();
|
|
3592
|
+
// @Output() pageChange = new EventEmitter<KlesTablePageChangePayload>();
|
|
3593
|
+
// @Output() sortChange = new EventEmitter<KlesTableSortPayload>();
|
|
3594
|
+
// @Output() filterChange = new EventEmitter<KlesTableFilterChangePayload>();
|
|
3595
|
+
// @Output() lazyQueryChange = new EventEmitter<KlesTableLazyQueryChangePayload>();
|
|
3596
|
+
// @Output() loadError = new EventEmitter<KlesTableLoadErrorPayload>();
|
|
3597
|
+
constructor(connectorService) {
|
|
3598
|
+
this.connectorService = connectorService;
|
|
3599
|
+
this.tableConfig = input.required(...(ngDevMode ? [{ debugName: "tableConfig" }] : /* istanbul ignore next */ []));
|
|
3600
|
+
this.destroyRef = inject(DestroyRef);
|
|
3601
|
+
this.tableEvent = new EventEmitter();
|
|
3602
|
+
this.rowClick = new EventEmitter();
|
|
3603
|
+
this.rowDoubleClick = new EventEmitter();
|
|
3604
|
+
this.rowContextMenu = new EventEmitter();
|
|
3605
|
+
this.cellClick = new EventEmitter();
|
|
3606
|
+
this.cellValueChange = new EventEmitter();
|
|
3607
|
+
}
|
|
3608
|
+
ngOnInit() {
|
|
3609
|
+
this.connectorService.connected$
|
|
3610
|
+
.pipe(takeUntilDestroyed(this.destroyRef), filter((connected) => connected), switchMap(() => {
|
|
3611
|
+
return this.connectorService.events.listen();
|
|
3612
|
+
}))
|
|
3613
|
+
.subscribe((event) => {
|
|
3614
|
+
this.dispatchEvent(event);
|
|
3615
|
+
});
|
|
3616
|
+
}
|
|
3617
|
+
get hostId() {
|
|
3618
|
+
return this.tableConfig()?.id ?? undefined;
|
|
3619
|
+
}
|
|
3620
|
+
refresh() {
|
|
3621
|
+
this.connectorService.refresh();
|
|
3622
|
+
}
|
|
3623
|
+
get scrollbar() {
|
|
3624
|
+
return this.connectorService.scrollbar;
|
|
3625
|
+
}
|
|
3626
|
+
get column() {
|
|
3627
|
+
return this.connectorService.column;
|
|
3628
|
+
}
|
|
3629
|
+
get pagination() {
|
|
3630
|
+
return this.connectorService.pagination;
|
|
3631
|
+
}
|
|
3632
|
+
get sort() {
|
|
3633
|
+
return this.connectorService.sort;
|
|
3634
|
+
}
|
|
3635
|
+
get loading() {
|
|
3636
|
+
return this.connectorService.loading;
|
|
3637
|
+
}
|
|
3638
|
+
get selection() {
|
|
3639
|
+
return this.connectorService.selection;
|
|
3640
|
+
}
|
|
3641
|
+
get form() {
|
|
3642
|
+
return this.connectorService.form;
|
|
3643
|
+
}
|
|
3644
|
+
get footer() {
|
|
3645
|
+
return this.connectorService.footer;
|
|
3646
|
+
}
|
|
3647
|
+
get ui() {
|
|
3648
|
+
return this.connectorService.ui;
|
|
3649
|
+
}
|
|
3650
|
+
dispatchEvent(event) {
|
|
3651
|
+
console.log('event', event);
|
|
3652
|
+
this.tableEvent.emit(event);
|
|
3653
|
+
switch (event.type) {
|
|
3654
|
+
case 'rowClick':
|
|
3655
|
+
this.rowClick.emit(event.payload);
|
|
3656
|
+
break;
|
|
3657
|
+
case 'rowDoubleClick':
|
|
3658
|
+
this.rowDoubleClick.emit(event.payload);
|
|
3659
|
+
break;
|
|
3660
|
+
case 'rowContextMenu':
|
|
3661
|
+
this.rowContextMenu.emit(event.payload);
|
|
3662
|
+
break;
|
|
3663
|
+
case 'cellClick':
|
|
3664
|
+
this.cellClick.emit(event.payload);
|
|
3665
|
+
break;
|
|
3666
|
+
case 'cellValueChange':
|
|
3667
|
+
this.cellValueChange.emit(event.payload);
|
|
3668
|
+
break;
|
|
3669
|
+
// case 'selectionChange':
|
|
3670
|
+
// this.selectionChange.emit(event.payload);
|
|
3671
|
+
// break;
|
|
3672
|
+
// case 'pageChange':
|
|
3673
|
+
// this.pageChange.emit(event.payload);
|
|
3674
|
+
// break;
|
|
3675
|
+
// case 'sortChange':
|
|
3676
|
+
// this.sortChange.emit(event.payload);
|
|
3677
|
+
// break;
|
|
3678
|
+
// case 'filterChange':
|
|
3679
|
+
// this.filterChange.emit(event.payload);
|
|
3680
|
+
// break;
|
|
3681
|
+
// case 'lazyQueryChange':
|
|
3682
|
+
// this.lazyQueryChange.emit(event.payload);
|
|
3683
|
+
// break;
|
|
3684
|
+
// case 'loadError':
|
|
3685
|
+
// this.loadError.emit(event.payload);
|
|
3686
|
+
// break;
|
|
3687
|
+
}
|
|
3688
|
+
}
|
|
3689
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: KlesTableComponent, deps: [{ token: KlesTableConnectorService }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3690
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "21.2.19", type: KlesTableComponent, isStandalone: true, selector: "kles-dynamic-table", inputs: { tableConfig: { classPropertyName: "tableConfig", publicName: "tableConfig", isSignal: true, isRequired: true, transformFunction: null } }, outputs: { tableEvent: "tableEvent", rowClick: "rowClick", rowDoubleClick: "rowDoubleClick", rowContextMenu: "rowContextMenu", cellClick: "cellClick", cellValueChange: "cellValueChange" }, host: { properties: { "attr.id": "this.hostId" } }, providers: [KlesTableConnectorService], ngImport: i0, template: "<ng-template appDynamicTableLoader [tableConfig]=\"tableConfig()\"></ng-template>\n", styles: [":host{display:flex;flex-direction:column;max-height:100%;overflow:auto}\n"], dependencies: [{ kind: "directive", type: DynamicTableLoaderDirective, selector: "[appDynamicTableLoader]", inputs: ["tableConfig"] }] }); }
|
|
3691
|
+
}
|
|
3692
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: KlesTableComponent, decorators: [{
|
|
3693
|
+
type: Component,
|
|
3694
|
+
args: [{ selector: 'kles-dynamic-table', standalone: true, imports: [DynamicTableLoaderDirective], providers: [KlesTableConnectorService], template: "<ng-template appDynamicTableLoader [tableConfig]=\"tableConfig()\"></ng-template>\n", styles: [":host{display:flex;flex-direction:column;max-height:100%;overflow:auto}\n"] }]
|
|
3695
|
+
}], ctorParameters: () => [{ type: KlesTableConnectorService }], propDecorators: { tableConfig: [{ type: i0.Input, args: [{ isSignal: true, alias: "tableConfig", required: true }] }], tableEvent: [{
|
|
3696
|
+
type: Output
|
|
3697
|
+
}], rowClick: [{
|
|
3698
|
+
type: Output
|
|
3699
|
+
}], rowDoubleClick: [{
|
|
3700
|
+
type: Output
|
|
3701
|
+
}], rowContextMenu: [{
|
|
3702
|
+
type: Output
|
|
3703
|
+
}], cellClick: [{
|
|
3704
|
+
type: Output
|
|
3705
|
+
}], cellValueChange: [{
|
|
3706
|
+
type: Output
|
|
3707
|
+
}], hostId: [{
|
|
3708
|
+
type: HostBinding,
|
|
3709
|
+
args: ['attr.id']
|
|
3710
|
+
}] } });
|
|
3711
|
+
|
|
3712
|
+
const components = [TableComponent];
|
|
3713
|
+
const directives = [];
|
|
3714
|
+
const pipes = [];
|
|
3715
|
+
class KlesMaterialTableModule {
|
|
3716
|
+
static { this.declarations = [components, directives, pipes]; }
|
|
3717
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: KlesMaterialTableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
3718
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.19", ngImport: i0, type: KlesMaterialTableModule, imports: [CommonModule, TableComponent, KlesTableComponent, KlesMaterialDynamicformsModule], exports: [KlesTableComponent] }); }
|
|
3719
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: KlesMaterialTableModule, providers: [pipes], imports: [CommonModule, components, KlesMaterialDynamicformsModule] }); }
|
|
3720
|
+
}
|
|
3721
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.19", ngImport: i0, type: KlesMaterialTableModule, decorators: [{
|
|
3722
|
+
type: NgModule,
|
|
3723
|
+
args: [{
|
|
3724
|
+
imports: [CommonModule, components, KlesTableComponent, KlesMaterialDynamicformsModule],
|
|
3725
|
+
providers: [pipes],
|
|
3726
|
+
exports: [pipes, directives, KlesTableComponent],
|
|
3727
|
+
}]
|
|
3728
|
+
}] });
|
|
3729
|
+
|
|
3730
|
+
const linesLoader = (l) => l;
|
|
3731
|
+
const linesLazyLoader = (l) => l;
|
|
3732
|
+
|
|
3733
|
+
const selectionConfig = (l) => l;
|
|
3734
|
+
|
|
3735
|
+
var AlignCell;
|
|
3736
|
+
(function (AlignCell) {
|
|
3737
|
+
AlignCell["LEFT"] = "left";
|
|
3738
|
+
AlignCell["CENTER"] = "center";
|
|
3739
|
+
AlignCell["RIGHT"] = "right";
|
|
3740
|
+
})(AlignCell || (AlignCell = {}));
|
|
3741
|
+
|
|
3742
|
+
/*
|
|
3743
|
+
* Public API Surface of kles-material-table
|
|
3744
|
+
*/
|
|
3745
|
+
|
|
3746
|
+
/**
|
|
3747
|
+
* Generated bundle index. Do not edit.
|
|
3748
|
+
*/
|
|
3749
|
+
|
|
3750
|
+
export { AlignCell, COLUMNS, DATASOURCE_SERVICE, DRAG_DROP_CONFIG, EXTRA_ROWS, FOOTER, HEADER_SERVICE, KlesMaterialTableModule, KlesTableComponent, LINES_SERVICE, LOADER_CONFIG, LOADER_SERVICE, PAGINATOR_CONFIG, ROW_DRAG_DROP, SCROLLBAR_ORCHESTRATOR_SERVICE, SELECTION_CONFIG, SELECTION_SERVICE, SORT_CONFIG, SORT_SERVICE, Span, TABLE_SERVICE, TableComponent, linesLazyLoader, linesLoader, selectionConfig };
|
|
3751
|
+
//# sourceMappingURL=3kles-kles-material-table-v2.mjs.map
|