ngx-core-components 0.3.6 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/charts/combo-chart/combo-chart.component.d.ts +58 -0
  2. package/charts/public-api.d.ts +3 -0
  3. package/charts/scatter-plot/scatter-plot.component.d.ts +66 -0
  4. package/fesm2022/ngx-core-components-charts.mjs +821 -1
  5. package/fesm2022/ngx-core-components-charts.mjs.map +1 -1
  6. package/fesm2022/ngx-core-components-grid.mjs +2450 -269
  7. package/fesm2022/ngx-core-components-grid.mjs.map +1 -1
  8. package/fesm2022/ngx-core-components-inputs.mjs +545 -63
  9. package/fesm2022/ngx-core-components-inputs.mjs.map +1 -1
  10. package/fesm2022/ngx-core-components-navigation.mjs +122 -1
  11. package/fesm2022/ngx-core-components-navigation.mjs.map +1 -1
  12. package/fesm2022/ngx-core-components-views.mjs +1043 -445
  13. package/fesm2022/ngx-core-components-views.mjs.map +1 -1
  14. package/fesm2022/ngx-core-components.mjs +5 -5
  15. package/fesm2022/ngx-core-components.mjs.map +1 -1
  16. package/grid/data-grid/data-grid.component.d.ts +191 -6
  17. package/grid/pivot-grid/pivot-grid.component.d.ts +32 -0
  18. package/grid/public-api.d.ts +4 -2
  19. package/inputs/date-range-picker/date-range-picker.component.d.ts +41 -5
  20. package/inputs/form-builder/form-builder.component.d.ts +36 -0
  21. package/inputs/public-api.d.ts +3 -0
  22. package/inputs/signature-pad/signature-pad.component.d.ts +24 -0
  23. package/navigation/context-menu/context-menu.component.d.ts +23 -0
  24. package/navigation/public-api.d.ts +2 -0
  25. package/package.json +1 -1
  26. package/public-api.d.ts +13 -8
  27. package/views/json-viewer/json-viewer.component.d.ts +18 -0
  28. package/views/kanban/kanban.component.d.ts +38 -18
  29. package/views/kanban/models.d.ts +21 -0
  30. package/views/org-chart/org-chart.component.d.ts +18 -0
  31. package/views/public-api.d.ts +5 -2
  32. package/views/scheduler/models.d.ts +12 -1
  33. package/views/scheduler/scheduler.component.d.ts +58 -10
@@ -1,10 +1,86 @@
1
1
  import * as i0 from '@angular/core';
2
- import { input, output, signal, effect, computed, ChangeDetectionStrategy, Component } from '@angular/core';
3
- import { NgTemplateOutlet } from '@angular/common';
2
+ import { inject, TemplateRef, Input, Directive, input, output, signal, ElementRef, DestroyRef, effect, untracked, computed, HostListener, ContentChildren, ChangeDetectionStrategy, Component } from '@angular/core';
3
+ import { NgTemplateOutlet, CommonModule } from '@angular/common';
4
4
 
5
+ class NgxGridCellTemplateDirective {
6
+ columnField;
7
+ templateRef = inject(TemplateRef);
8
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: NgxGridCellTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
9
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.20", type: NgxGridCellTemplateDirective, isStandalone: true, selector: "[ngxGridCellTemplate]", inputs: { columnField: ["ngxGridCellTemplate", "columnField"] }, ngImport: i0 });
10
+ }
11
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: NgxGridCellTemplateDirective, decorators: [{
12
+ type: Directive,
13
+ args: [{
14
+ selector: '[ngxGridCellTemplate]',
15
+ standalone: true
16
+ }]
17
+ }], propDecorators: { columnField: [{
18
+ type: Input,
19
+ args: ['ngxGridCellTemplate']
20
+ }] } });
21
+ class NgxGridEditCellTemplateDirective {
22
+ columnField;
23
+ templateRef = inject(TemplateRef);
24
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: NgxGridEditCellTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
25
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.20", type: NgxGridEditCellTemplateDirective, isStandalone: true, selector: "[ngxGridEditCellTemplate]", inputs: { columnField: ["ngxGridEditCellTemplate", "columnField"] }, ngImport: i0 });
26
+ }
27
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: NgxGridEditCellTemplateDirective, decorators: [{
28
+ type: Directive,
29
+ args: [{
30
+ selector: '[ngxGridEditCellTemplate]',
31
+ standalone: true
32
+ }]
33
+ }], propDecorators: { columnField: [{
34
+ type: Input,
35
+ args: ['ngxGridEditCellTemplate']
36
+ }] } });
37
+ class NgxGridHeaderTemplateDirective {
38
+ columnField;
39
+ templateRef = inject(TemplateRef);
40
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: NgxGridHeaderTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
41
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.20", type: NgxGridHeaderTemplateDirective, isStandalone: true, selector: "[ngxGridHeaderTemplate]", inputs: { columnField: ["ngxGridHeaderTemplate", "columnField"] }, ngImport: i0 });
42
+ }
43
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: NgxGridHeaderTemplateDirective, decorators: [{
44
+ type: Directive,
45
+ args: [{
46
+ selector: '[ngxGridHeaderTemplate]',
47
+ standalone: true
48
+ }]
49
+ }], propDecorators: { columnField: [{
50
+ type: Input,
51
+ args: ['ngxGridHeaderTemplate']
52
+ }] } });
53
+ class NgxGridFooterTemplateDirective {
54
+ columnField;
55
+ templateRef = inject(TemplateRef);
56
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: NgxGridFooterTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
57
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.20", type: NgxGridFooterTemplateDirective, isStandalone: true, selector: "[ngxGridFooterTemplate]", inputs: { columnField: ["ngxGridFooterTemplate", "columnField"] }, ngImport: i0 });
58
+ }
59
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: NgxGridFooterTemplateDirective, decorators: [{
60
+ type: Directive,
61
+ args: [{
62
+ selector: '[ngxGridFooterTemplate]',
63
+ standalone: true
64
+ }]
65
+ }], propDecorators: { columnField: [{
66
+ type: Input,
67
+ args: ['ngxGridFooterTemplate']
68
+ }] } });
5
69
  class DataGridComponent {
70
+ cellTemplates;
71
+ editCellTemplates;
72
+ headerTemplates;
73
+ footerTemplates;
6
74
  data = input([]);
7
75
  columns = input([]);
76
+ stateKey = input('');
77
+ reorderable = input(false);
78
+ multiSort = input(false);
79
+ columnReorder = output();
80
+ rowReorderable = input(false);
81
+ showGlobalSearch = input(false);
82
+ globalSearchPlaceholder = input('Search...');
83
+ rowReorder = output();
8
84
  pageSize = input(10);
9
85
  page = input(1);
10
86
  total = input(0);
@@ -20,8 +96,10 @@ class DataGridComponent {
20
96
  groupedData = input([]);
21
97
  headerTemplate = input(null);
22
98
  cellTemplate = input(null);
99
+ editCellTemplate = input(null);
23
100
  rowTemplate = input(null);
24
101
  detailRowTemplate = input(null);
102
+ footerTemplate = input(null);
25
103
  rowClick = output();
26
104
  selectionChange = output();
27
105
  sortChange = output();
@@ -30,6 +108,13 @@ class DataGridComponent {
30
108
  pageChange = output();
31
109
  dataStateChange = output();
32
110
  rowUpdate = output();
111
+ // New Enterprise Features
112
+ showColumnChooser = input(false);
113
+ cellSelection = input(false);
114
+ cellSelectionChange = output();
115
+ enableContextMenu = input(false);
116
+ keyboardNavigation = input(false);
117
+ groupAggregations = input(false);
33
118
  sortState = signal(null);
34
119
  currentPage = signal(1);
35
120
  selectedRows = signal(new Set());
@@ -37,12 +122,55 @@ class DataGridComponent {
37
122
  collapsedGroups = signal(new Set());
38
123
  editingRowKey = signal(null);
39
124
  editingDraft = signal({});
40
- filters = signal(new Map());
125
+ // Enterprise Extensions
126
+ elementRef = inject(ElementRef);
127
+ destroyRef = inject(DestroyRef);
128
+ columnWidths = signal({});
129
+ filterStates = signal(new Map());
130
+ sortStates = signal([]);
131
+ columnOrder = signal([]);
132
+ // Column Chooser state
133
+ hiddenColumns = signal(new Set());
134
+ activeColumnChooserPopover = signal(null);
135
+ // Cell Selection state
136
+ selectedCellStart = signal(null);
137
+ selectedCellEnd = signal(null);
138
+ isCellDragging = signal(false);
139
+ // Context Menu state
140
+ activeContextMenu = signal(null);
141
+ columnPinnedOverrides = signal({});
142
+ // Keyboard Navigation state
143
+ focusedCell = signal(null);
144
+ focusedCellEditActive = signal(false);
145
+ // Drag and drop state
146
+ draggingField = signal(null);
147
+ dragOverField = signal(null);
148
+ draggingRowIndex = signal(null);
149
+ dragOverRowIndex = signal(null);
150
+ // Resizing state
151
+ resizeStartWidth = 0;
152
+ resizeStartX = 0;
153
+ resizingField = null;
154
+ isInitialPageSync = true;
155
+ // Filter Popover state
156
+ activeFilterPopover = signal(null);
157
+ tempFilterValue = signal('');
158
+ tempFilterOperator = signal('contains');
159
+ tempSelectedValues = signal(new Set());
160
+ // Global search state
161
+ searchText = signal('');
41
162
  constructor() {
42
163
  effect(() => {
43
164
  const externalPage = this.page();
44
- if (externalPage > 0 && externalPage !== this.currentPage()) {
45
- this.currentPage.set(externalPage);
165
+ const current = untracked(() => this.currentPage());
166
+ if (this.isInitialPageSync) {
167
+ this.isInitialPageSync = false;
168
+ if (this.stateKey()) {
169
+ return;
170
+ }
171
+ }
172
+ if (externalPage > 0 && externalPage !== current) {
173
+ untracked(() => this.currentPage.set(externalPage));
46
174
  }
47
175
  });
48
176
  effect(() => {
@@ -51,39 +179,404 @@ class DataGridComponent {
51
179
  this.currentPage.set(max);
52
180
  }
53
181
  });
182
+ effect(() => {
183
+ const states = this.sortStates();
184
+ const current = untracked(() => this.sortState());
185
+ const first = states.length > 0 ? states[0] : null;
186
+ if (JSON.stringify(first) !== JSON.stringify(current)) {
187
+ untracked(() => this.sortState.set(first));
188
+ }
189
+ });
190
+ effect(() => {
191
+ const single = this.sortState();
192
+ const current = untracked(() => this.sortStates());
193
+ const first = current.length > 0 ? current[0] : null;
194
+ if (JSON.stringify(single) !== JSON.stringify(first)) {
195
+ untracked(() => this.sortStates.set(single ? [single] : []));
196
+ }
197
+ });
198
+ // Initialize hidden columns from definitions
199
+ effect(() => {
200
+ const cols = this.columns();
201
+ untracked(() => {
202
+ const currentHidden = this.hiddenColumns();
203
+ if (currentHidden.size === 0 && !this.stateKey()) {
204
+ const initialHidden = new Set();
205
+ cols.forEach(c => {
206
+ if (c.hidden) {
207
+ initialHidden.add(c.field);
208
+ }
209
+ });
210
+ if (initialHidden.size > 0) {
211
+ this.hiddenColumns.set(initialHidden);
212
+ }
213
+ }
214
+ });
215
+ }, { allowSignalWrites: true });
216
+ effect(() => {
217
+ const key = this.stateKey();
218
+ if (!key || typeof window === 'undefined' || typeof localStorage === 'undefined') {
219
+ return;
220
+ }
221
+ const state = {
222
+ columnWidths: this.columnWidths(),
223
+ sortState: this.sortState(),
224
+ sortStates: this.sortStates(),
225
+ columnOrder: this.columnOrder(),
226
+ currentPage: this.currentPage(),
227
+ filters: Array.from(this.filterStates().values()),
228
+ searchText: this.searchText(),
229
+ hiddenColumns: Array.from(this.hiddenColumns()),
230
+ columnPinnedOverrides: this.columnPinnedOverrides()
231
+ };
232
+ try {
233
+ localStorage.setItem(`ngx_grid_state_${key}`, JSON.stringify(state));
234
+ }
235
+ catch (e) {
236
+ console.warn('Failed to save grid state to localStorage', e);
237
+ }
238
+ });
239
+ // Window event listeners for closing popovers and copy behavior
240
+ if (typeof window !== 'undefined') {
241
+ const clickListener = () => {
242
+ this.activeFilterPopover.set(null);
243
+ this.activeColumnChooserPopover.set(null);
244
+ this.activeContextMenu.set(null);
245
+ };
246
+ const mouseUpListener = () => {
247
+ if (this.isCellDragging()) {
248
+ this.isCellDragging.set(false);
249
+ }
250
+ };
251
+ const keydownListener = (e) => {
252
+ if (e.key === 'Escape') {
253
+ this.activeFilterPopover.set(null);
254
+ this.activeColumnChooserPopover.set(null);
255
+ this.activeContextMenu.set(null);
256
+ }
257
+ if (!this.cellSelection())
258
+ return;
259
+ if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'c') {
260
+ const start = this.selectedCellStart();
261
+ const end = this.selectedCellEnd();
262
+ if (!start || !end)
263
+ return;
264
+ const text = this.getSelectedCellsText();
265
+ if (text) {
266
+ e.preventDefault();
267
+ navigator.clipboard.writeText(text).catch(err => {
268
+ console.error('Failed to copy grid cell range to clipboard', err);
269
+ });
270
+ }
271
+ }
272
+ };
273
+ window.addEventListener('click', clickListener);
274
+ window.addEventListener('mouseup', mouseUpListener);
275
+ window.addEventListener('keydown', keydownListener);
276
+ this.destroyRef.onDestroy(() => {
277
+ window.removeEventListener('click', clickListener);
278
+ window.removeEventListener('mouseup', mouseUpListener);
279
+ window.removeEventListener('keydown', keydownListener);
280
+ });
281
+ }
282
+ }
283
+ ngOnInit() {
284
+ this.loadState();
285
+ }
286
+ loadState() {
287
+ const key = this.stateKey();
288
+ if (!key || typeof window === 'undefined' || typeof localStorage === 'undefined') {
289
+ return;
290
+ }
291
+ try {
292
+ const saved = localStorage.getItem(`ngx_grid_state_${key}`);
293
+ if (saved) {
294
+ const state = JSON.parse(saved);
295
+ if (state.columnWidths) {
296
+ this.columnWidths.set(state.columnWidths);
297
+ }
298
+ if (state.columnOrder) {
299
+ this.columnOrder.set(state.columnOrder);
300
+ }
301
+ if (state.sortStates) {
302
+ this.sortStates.set(state.sortStates);
303
+ this.sortState.set(state.sortStates.length > 0 ? state.sortStates[0] : null);
304
+ }
305
+ else if (state.sortState !== undefined) {
306
+ this.sortState.set(state.sortState);
307
+ this.sortStates.set(state.sortState ? [state.sortState] : []);
308
+ }
309
+ if (state.currentPage !== undefined) {
310
+ this.currentPage.set(state.currentPage);
311
+ }
312
+ if (state.filters) {
313
+ const map = new Map();
314
+ state.filters.forEach((f) => {
315
+ map.set(f.field, f);
316
+ });
317
+ this.filterStates.set(map);
318
+ }
319
+ if (state.searchText !== undefined) {
320
+ this.searchText.set(state.searchText);
321
+ }
322
+ if (state.hiddenColumns) {
323
+ this.hiddenColumns.set(new Set(state.hiddenColumns));
324
+ }
325
+ if (state.columnPinnedOverrides) {
326
+ this.columnPinnedOverrides.set(state.columnPinnedOverrides);
327
+ }
328
+ }
329
+ }
330
+ catch (e) {
331
+ console.warn('Failed to load grid state from localStorage', e);
332
+ }
54
333
  }
334
+ orderedColumns = computed(() => {
335
+ const cols = this.columns();
336
+ const order = this.columnOrder();
337
+ const hidden = this.hiddenColumns();
338
+ const pinOverrides = this.columnPinnedOverrides();
339
+ let mapped = cols
340
+ .filter(c => !hidden.has(c.field))
341
+ .map(c => {
342
+ const pinOverride = pinOverrides[c.field];
343
+ if (pinOverride !== undefined) {
344
+ return { ...c, pinned: pinOverride === null ? undefined : pinOverride };
345
+ }
346
+ return c;
347
+ });
348
+ if (order.length > 0) {
349
+ mapped.sort((a, b) => {
350
+ const idxA = order.indexOf(a.field);
351
+ const idxB = order.indexOf(b.field);
352
+ if (idxA === -1 && idxB === -1)
353
+ return 0;
354
+ if (idxA === -1)
355
+ return 1;
356
+ if (idxB === -1)
357
+ return -1;
358
+ return idxA - idxB;
359
+ });
360
+ }
361
+ const pinnedLeft = mapped.filter(c => c.pinned === 'left');
362
+ const pinnedRight = mapped.filter(c => c.pinned === 'right');
363
+ const normal = mapped.filter(c => c.pinned !== 'left' && c.pinned !== 'right');
364
+ return [...pinnedLeft, ...normal, ...pinnedRight];
365
+ });
366
+ hasPinnedColumns = computed(() => this.orderedColumns().some(c => c.pinned === 'left' || c.pinned === 'right'));
367
+ lastPinnedColumnField = computed(() => {
368
+ const pinned = this.orderedColumns().filter(c => c.pinned === 'left');
369
+ return pinned.length > 0 ? pinned[pinned.length - 1].field : null;
370
+ });
371
+ isSelectableLastPinned = computed(() => {
372
+ const hasPinnedCols = this.orderedColumns().some(c => c.pinned === 'left');
373
+ return this.selectable() && !hasPinnedCols;
374
+ });
375
+ isDetailToggleLastPinned = computed(() => {
376
+ const hasPinnedCols = this.orderedColumns().some(c => c.pinned === 'left');
377
+ return this.showDetailToggle() && !this.selectable() && !hasPinnedCols;
378
+ });
379
+ isRowReorderableLastPinned = computed(() => {
380
+ const hasPinnedCols = this.orderedColumns().some(c => c.pinned === 'left');
381
+ return this.rowReorderable() && !this.showDetailToggle() && !this.selectable() && !hasPinnedCols;
382
+ });
383
+ firstPinnedRightColumnField = computed(() => {
384
+ const pinned = this.orderedColumns().filter(c => c.pinned === 'right');
385
+ return pinned.length > 0 ? pinned[0].field : null;
386
+ });
387
+ columnRightOffsets = computed(() => {
388
+ const offsets = {};
389
+ let currentOffset = 0;
390
+ if (this.editable()) {
391
+ offsets['__actions'] = currentOffset;
392
+ currentOffset += 120;
393
+ }
394
+ const cols = this.orderedColumns();
395
+ for (let i = cols.length - 1; i >= 0; i--) {
396
+ const col = cols[i];
397
+ if (col.pinned === 'right') {
398
+ offsets[col.field] = currentOffset;
399
+ currentOffset += this.getColumnWidth(col) ?? 120;
400
+ }
401
+ }
402
+ return offsets;
403
+ });
404
+ columnOffsets = computed(() => {
405
+ const offsets = {};
406
+ let currentOffset = 0;
407
+ if (this.rowReorderable()) {
408
+ currentOffset += 44;
409
+ }
410
+ if (this.showDetailToggle()) {
411
+ currentOffset += 44;
412
+ }
413
+ if (this.selectable()) {
414
+ currentOffset += 44;
415
+ }
416
+ const cols = this.orderedColumns();
417
+ for (const col of cols) {
418
+ if (col.pinned === 'left') {
419
+ offsets[col.field] = currentOffset;
420
+ currentOffset += this.getColumnWidth(col) ?? 120;
421
+ }
422
+ }
423
+ return offsets;
424
+ });
425
+ hasColumnCategories = computed(() => {
426
+ return this.orderedColumns().some(c => !!c.category);
427
+ });
428
+ headerRows = computed(() => {
429
+ const cols = this.orderedColumns();
430
+ const hasCat = this.hasColumnCategories();
431
+ if (!hasCat) {
432
+ return {
433
+ row1: cols.map(c => ({
434
+ title: c.title,
435
+ column: c,
436
+ colSpan: 1,
437
+ rowSpan: 1,
438
+ isCategory: false,
439
+ field: c.field,
440
+ pinned: c.pinned,
441
+ leftOffset: c.pinned === 'left' ? this.columnOffsets()[c.field] : null,
442
+ rightOffset: c.pinned === 'right' ? this.columnRightOffsets()[c.field] : null,
443
+ isPinnedLast: c.pinned === 'left' && this.lastPinnedColumnField() === c.field,
444
+ isPinnedFirst: c.pinned === 'right' && this.firstPinnedRightColumnField() === c.field
445
+ })),
446
+ row2: []
447
+ };
448
+ }
449
+ const row1 = [];
450
+ const row2 = [];
451
+ let i = 0;
452
+ while (i < cols.length) {
453
+ const col = cols[i];
454
+ if (!col.category) {
455
+ row1.push({
456
+ title: col.title,
457
+ column: col,
458
+ colSpan: 1,
459
+ rowSpan: 2,
460
+ isCategory: false,
461
+ field: col.field,
462
+ pinned: col.pinned,
463
+ leftOffset: col.pinned === 'left' ? this.columnOffsets()[col.field] : null,
464
+ rightOffset: col.pinned === 'right' ? this.columnRightOffsets()[col.field] : null,
465
+ isPinnedLast: col.pinned === 'left' && this.lastPinnedColumnField() === col.field,
466
+ isPinnedFirst: col.pinned === 'right' && this.firstPinnedRightColumnField() === col.field
467
+ });
468
+ i++;
469
+ }
470
+ else {
471
+ const cat = col.category;
472
+ const startIdx = i;
473
+ while (i < cols.length && cols[i].category === cat && cols[i].pinned === col.pinned) {
474
+ const currentCol = cols[i];
475
+ row2.push({
476
+ title: currentCol.title,
477
+ column: currentCol,
478
+ colSpan: 1,
479
+ rowSpan: 1,
480
+ isCategory: false,
481
+ field: currentCol.field,
482
+ pinned: currentCol.pinned,
483
+ leftOffset: currentCol.pinned === 'left' ? this.columnOffsets()[currentCol.field] : null,
484
+ rightOffset: currentCol.pinned === 'right' ? this.columnRightOffsets()[currentCol.field] : null,
485
+ isPinnedLast: currentCol.pinned === 'left' && this.lastPinnedColumnField() === currentCol.field,
486
+ isPinnedFirst: currentCol.pinned === 'right' && this.firstPinnedRightColumnField() === currentCol.field
487
+ });
488
+ i++;
489
+ }
490
+ const groupCount = i - startIdx;
491
+ const lastColInGroup = cols[i - 1];
492
+ row1.push({
493
+ title: cat,
494
+ colSpan: groupCount,
495
+ rowSpan: 1,
496
+ isCategory: true,
497
+ pinned: col.pinned,
498
+ leftOffset: col.pinned === 'left' ? this.columnOffsets()[col.field] : null,
499
+ rightOffset: col.pinned === 'right' ? this.columnRightOffsets()[lastColInGroup.field] : null,
500
+ isPinnedLast: col.pinned === 'left' && this.lastPinnedColumnField() === lastColInGroup.field,
501
+ isPinnedFirst: col.pinned === 'right' && this.firstPinnedRightColumnField() === col.field,
502
+ field: `__cat_${cat}_${startIdx}`
503
+ });
504
+ }
505
+ }
506
+ return { row1, row2 };
507
+ });
55
508
  hasFilterableColumns = computed(() => this.columns().some(column => column.filterable));
56
509
  isAnyServerMode = computed(() => this.sortMode() === 'server' ||
57
510
  this.filterMode() === 'server' ||
58
511
  this.groupMode() === 'server' ||
59
512
  this.pagingMode() === 'server');
60
513
  showDetailToggle = computed(() => this.detailRowTemplate() !== null);
61
- activeFilters = computed(() => Array.from(this.filters().entries()).map(([field, value]) => ({ field, value, operator: 'contains' })));
514
+ activeFilters = computed(() => Array.from(this.filterStates().values()));
62
515
  clientFilteredData = computed(() => {
63
516
  if (this.filterMode() !== 'client') {
64
517
  return this.data();
65
518
  }
66
519
  let rows = this.data();
67
520
  for (const filter of this.activeFilters()) {
68
- if (!filter.value) {
69
- continue;
521
+ if (filter.operator === 'in') {
522
+ const selected = filter.selectedValues ?? [];
523
+ if (selected.length > 0) {
524
+ rows = rows.filter(row => {
525
+ const cellVal = String(row[filter.field] ?? '');
526
+ const displayVal = cellVal === '' || cellVal == null ? '(Blank)' : cellVal;
527
+ return selected.includes(displayVal);
528
+ });
529
+ }
530
+ }
531
+ else {
532
+ if (!filter.value) {
533
+ continue;
534
+ }
535
+ const query = filter.value.toLowerCase();
536
+ const operator = filter.operator ?? 'contains';
537
+ rows = rows.filter(row => {
538
+ const cellVal = String(row[filter.field] ?? '').toLowerCase();
539
+ if (operator === 'eq')
540
+ return cellVal === query;
541
+ if (operator === 'startsWith')
542
+ return cellVal.startsWith(query);
543
+ if (operator === 'endsWith')
544
+ return cellVal.endsWith(query);
545
+ return cellVal.includes(query); // contains
546
+ });
70
547
  }
71
- const query = filter.value.toLowerCase();
72
- rows = rows.filter(row => String(row[filter.field] ?? '').toLowerCase().includes(query));
548
+ }
549
+ const searchVal = this.searchText().trim().toLowerCase();
550
+ if (searchVal) {
551
+ const cols = this.orderedColumns();
552
+ rows = rows.filter(row => {
553
+ return cols.some(col => {
554
+ const cellVal = String(row[col.field] ?? '').toLowerCase();
555
+ return cellVal.includes(searchVal);
556
+ });
557
+ });
73
558
  }
74
559
  return rows;
75
560
  });
76
561
  clientSortedData = computed(() => {
77
562
  const rows = this.clientFilteredData();
78
- if (this.sortMode() !== 'client' || !this.sortState()) {
563
+ if (this.sortMode() !== 'client') {
564
+ return rows;
565
+ }
566
+ const activeSorts = this.sortStates();
567
+ if (activeSorts.length === 0) {
79
568
  return rows;
80
569
  }
81
- const state = this.sortState();
82
570
  return [...rows].sort((left, right) => {
83
- const leftValue = left[state.field];
84
- const rightValue = right[state.field];
85
- const compared = this.compareValues(leftValue, rightValue);
86
- return state.dir === 'asc' ? compared : -compared;
571
+ for (const state of activeSorts) {
572
+ const leftValue = left[state.field];
573
+ const rightValue = right[state.field];
574
+ const compared = this.compareValues(leftValue, rightValue);
575
+ if (compared !== 0) {
576
+ return state.dir === 'asc' ? compared : -compared;
577
+ }
578
+ }
579
+ return 0;
87
580
  });
88
581
  });
89
582
  baseFlatData = computed(() => {
@@ -183,13 +676,200 @@ class DataGridComponent {
183
676
  }
184
677
  return pages;
185
678
  });
186
- renderColumnCount = computed(() => this.columns().length +
679
+ renderColumnCount = computed(() => this.orderedColumns().length +
187
680
  (this.selectable() ? 1 : 0) +
188
681
  (this.showDetailToggle() ? 1 : 0) +
682
+ (this.rowReorderable() ? 1 : 0) +
189
683
  (this.editable() ? 1 : 0));
190
684
  showPager = computed(() => this.totalItems() > 0);
685
+ renderedRowsList = computed(() => {
686
+ if (this.hasGrouping()) {
687
+ const list = [];
688
+ this.groupedRows().forEach(group => {
689
+ if (!this.isGroupCollapsed(group.key)) {
690
+ list.push(...group.items);
691
+ }
692
+ });
693
+ return list;
694
+ }
695
+ return this.flatRenderedRows();
696
+ });
697
+ isCellSelected(row, colField) {
698
+ const start = this.selectedCellStart();
699
+ const end = this.selectedCellEnd();
700
+ if (!start || !end)
701
+ return false;
702
+ const rows = this.renderedRowsList();
703
+ const cols = this.orderedColumns();
704
+ const startRowIndex = rows.indexOf(start.row);
705
+ const endRowIndex = rows.indexOf(end.row);
706
+ const rowIndex = rows.indexOf(row);
707
+ const startColIndex = cols.findIndex(c => c.field === start.colField);
708
+ const endColIndex = cols.findIndex(c => c.field === end.colField);
709
+ const colIndex = cols.findIndex(c => c.field === colField);
710
+ if (startRowIndex === -1 || endRowIndex === -1 || rowIndex === -1 ||
711
+ startColIndex === -1 || endColIndex === -1 || colIndex === -1) {
712
+ return false;
713
+ }
714
+ const minRow = Math.min(startRowIndex, endRowIndex);
715
+ const maxRow = Math.max(startRowIndex, endRowIndex);
716
+ const minCol = Math.min(startColIndex, endColIndex);
717
+ const maxCol = Math.max(startColIndex, endColIndex);
718
+ return rowIndex >= minRow && rowIndex <= maxRow && colIndex >= minCol && colIndex <= maxCol;
719
+ }
720
+ onCellContextMenu(event, row, colField) {
721
+ if (!this.enableContextMenu())
722
+ return;
723
+ event.preventDefault();
724
+ event.stopPropagation();
725
+ const gridEl = this.elementRef.nativeElement.querySelector('.ngx-data-grid');
726
+ const gridRect = gridEl.getBoundingClientRect();
727
+ const x = event.clientX - gridRect.left;
728
+ const y = event.clientY - gridRect.top;
729
+ this.activeFilterPopover.set(null);
730
+ this.activeColumnChooserPopover.set(null);
731
+ this.activeContextMenu.set({
732
+ x: Math.min(x, gridRect.width - 190),
733
+ y: y,
734
+ row,
735
+ colField
736
+ });
737
+ }
738
+ isColumnPinned(field) {
739
+ if (!field)
740
+ return false;
741
+ const pinOverride = this.columnPinnedOverrides()[field];
742
+ if (pinOverride !== undefined) {
743
+ return pinOverride === 'left';
744
+ }
745
+ const col = this.columns().find(c => c.field === field);
746
+ return col?.pinned === 'left';
747
+ }
748
+ contextMenuTogglePin(field) {
749
+ if (!field)
750
+ return;
751
+ const currentlyPinned = this.isColumnPinned(field);
752
+ const overrides = { ...this.columnPinnedOverrides() };
753
+ overrides[field] = currentlyPinned ? null : 'left';
754
+ this.columnPinnedOverrides.set(overrides);
755
+ this.activeContextMenu.set(null);
756
+ }
757
+ contextMenuHideColumn(field) {
758
+ if (field) {
759
+ this.toggleColumnVisibility(field);
760
+ }
761
+ this.activeContextMenu.set(null);
762
+ }
763
+ contextMenuClearFilters() {
764
+ this.filterStates.set(new Map());
765
+ this.currentPage.set(1);
766
+ this.filterChange.emit({ filters: [] });
767
+ this.emitDataState();
768
+ this.activeContextMenu.set(null);
769
+ }
770
+ contextMenuCopy() {
771
+ const text = this.getSelectedCellsText();
772
+ if (text) {
773
+ navigator.clipboard.writeText(text).catch(err => {
774
+ console.error('Failed to copy to clipboard', err);
775
+ });
776
+ }
777
+ this.activeContextMenu.set(null);
778
+ }
779
+ onCellMouseDown(event, row, colField) {
780
+ if (!this.cellSelection())
781
+ return;
782
+ if (event.button !== 0)
783
+ return;
784
+ const target = event.target;
785
+ if (target && (target.closest('.grid-edit-input') || target.closest('.action-btn') || target.closest('.toggle-btn') || target.closest('input[type="checkbox"]'))) {
786
+ return;
787
+ }
788
+ event.preventDefault();
789
+ this.selectedCellStart.set({ row, colField });
790
+ this.selectedCellEnd.set({ row, colField });
791
+ this.isCellDragging.set(true);
792
+ this.cellSelectionChange.emit({
793
+ start: { row, colField },
794
+ end: { row, colField }
795
+ });
796
+ }
797
+ onCellMouseEnter(row, colField) {
798
+ if (!this.cellSelection() || !this.isCellDragging())
799
+ return;
800
+ this.selectedCellEnd.set({ row, colField });
801
+ const start = this.selectedCellStart();
802
+ if (start) {
803
+ this.cellSelectionChange.emit({
804
+ start,
805
+ end: { row, colField }
806
+ });
807
+ }
808
+ }
809
+ openColumnChooser(event) {
810
+ event.stopPropagation();
811
+ if (this.activeColumnChooserPopover()) {
812
+ this.activeColumnChooserPopover.set(null);
813
+ return;
814
+ }
815
+ this.activeFilterPopover.set(null);
816
+ const buttonEl = event.currentTarget;
817
+ const gridEl = this.elementRef.nativeElement.querySelector('.ngx-data-grid');
818
+ const buttonRect = buttonEl.getBoundingClientRect();
819
+ const gridRect = gridEl.getBoundingClientRect();
820
+ const top = buttonRect.bottom - gridRect.top;
821
+ const left = buttonRect.left - gridRect.left;
822
+ this.activeColumnChooserPopover.set({
823
+ top,
824
+ left: Math.min(left, gridRect.width - 260)
825
+ });
826
+ }
827
+ toggleColumnVisibility(field) {
828
+ const hidden = new Set(this.hiddenColumns());
829
+ if (hidden.has(field)) {
830
+ hidden.delete(field);
831
+ }
832
+ else {
833
+ if (hidden.size < this.columns().length - 1) {
834
+ hidden.add(field);
835
+ }
836
+ }
837
+ this.hiddenColumns.set(hidden);
838
+ }
839
+ getSelectedCellsText() {
840
+ const start = this.selectedCellStart();
841
+ const end = this.selectedCellEnd();
842
+ if (!start || !end)
843
+ return null;
844
+ const rows = this.renderedRowsList();
845
+ const cols = this.orderedColumns();
846
+ const startRowIndex = rows.indexOf(start.row);
847
+ const endRowIndex = rows.indexOf(end.row);
848
+ const startColIndex = cols.findIndex(c => c.field === start.colField);
849
+ const endColIndex = cols.findIndex(c => c.field === end.colField);
850
+ if (startRowIndex === -1 || endRowIndex === -1 || startColIndex === -1 || endColIndex === -1) {
851
+ return null;
852
+ }
853
+ const minRow = Math.min(startRowIndex, endRowIndex);
854
+ const maxRow = Math.max(startRowIndex, endRowIndex);
855
+ const minCol = Math.min(startColIndex, endColIndex);
856
+ const maxCol = Math.max(startColIndex, endColIndex);
857
+ const selectedCols = cols.slice(minCol, maxCol + 1);
858
+ const textLines = [];
859
+ for (let r = minRow; r <= maxRow; r++) {
860
+ if (r >= 0 && r < rows.length) {
861
+ const rowData = rows[r];
862
+ const rowValues = selectedCols.map(col => {
863
+ const val = this.getCellValue(rowData, col.field);
864
+ return val !== null && val !== undefined ? String(val) : '';
865
+ });
866
+ textLines.push(rowValues.join('\t'));
867
+ }
868
+ }
869
+ return textLines.join('\n');
870
+ }
191
871
  getFilter(field) {
192
- return this.filters().get(field) ?? '';
872
+ return this.filterStates().get(field)?.value ?? '';
193
873
  }
194
874
  exportToJson() {
195
875
  const dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(this.data(), null, 2));
@@ -203,7 +883,7 @@ class DataGridComponent {
203
883
  exportToCsv() {
204
884
  if (this.data().length === 0)
205
885
  return;
206
- const cols = this.columns();
886
+ const cols = this.orderedColumns();
207
887
  const headers = cols.map(c => c.title);
208
888
  const fields = cols.map(c => c.field);
209
889
  const rows = this.data().map(row => {
@@ -225,31 +905,317 @@ class DataGridComponent {
225
905
  downloadAnchor.remove();
226
906
  }
227
907
  setFilter(field, value) {
228
- const nextFilters = new Map(this.filters());
908
+ const nextStates = new Map(this.filterStates());
229
909
  if (value) {
230
- nextFilters.set(field, value);
910
+ nextStates.set(field, { field, value, operator: 'contains' });
231
911
  }
232
912
  else {
233
- nextFilters.delete(field);
913
+ nextStates.delete(field);
234
914
  }
235
- this.filters.set(nextFilters);
915
+ this.filterStates.set(nextStates);
236
916
  this.currentPage.set(1);
237
917
  const filters = this.activeFilters();
238
918
  this.filterChange.emit({ filters });
239
919
  this.emitDataState();
240
920
  }
241
- onSort(column) {
242
- const current = this.sortState();
243
- if (current?.field === column.field) {
244
- this.sortState.set(current.dir === 'asc' ? { field: column.field, dir: 'desc' } : null);
921
+ getColumnWidth(col) {
922
+ return this.columnWidths()[col.field] ?? col.width;
923
+ }
924
+ onResizeStart(event, col) {
925
+ event.stopPropagation();
926
+ event.preventDefault();
927
+ this.resizingField = col.field;
928
+ this.resizeStartX = event.clientX;
929
+ this.resizeStartWidth = this.columnWidths()[col.field] ?? col.width ?? 120;
930
+ const onMouseMove = (moveEvent) => {
931
+ if (!this.resizingField)
932
+ return;
933
+ const deltaX = moveEvent.clientX - this.resizeStartX;
934
+ const newWidth = Math.max(50, this.resizeStartWidth + deltaX);
935
+ this.columnWidths.update(widths => ({
936
+ ...widths,
937
+ [this.resizingField]: newWidth
938
+ }));
939
+ };
940
+ const onMouseUp = () => {
941
+ this.resizingField = null;
942
+ window.removeEventListener('mousemove', onMouseMove);
943
+ window.removeEventListener('mouseup', onMouseUp);
944
+ };
945
+ window.addEventListener('mousemove', onMouseMove);
946
+ window.addEventListener('mouseup', onMouseUp);
947
+ }
948
+ openFilterPopover(event, field) {
949
+ event.stopPropagation();
950
+ if (this.activeFilterPopover()?.field === field) {
951
+ this.activeFilterPopover.set(null);
952
+ return;
953
+ }
954
+ const current = this.filterStates().get(field);
955
+ this.tempFilterValue.set(current?.value ?? '');
956
+ this.tempFilterOperator.set((current?.operator === 'in' ? 'contains' : current?.operator) ?? 'contains');
957
+ const distinct = this.getDistinctValues(field);
958
+ if (current?.selectedValues) {
959
+ this.tempSelectedValues.set(new Set(current.selectedValues));
960
+ }
961
+ else {
962
+ this.tempSelectedValues.set(new Set(distinct));
963
+ }
964
+ const buttonEl = event.currentTarget;
965
+ const gridEl = this.elementRef.nativeElement.querySelector('.ngx-data-grid');
966
+ const buttonRect = buttonEl.getBoundingClientRect();
967
+ const gridRect = gridEl.getBoundingClientRect();
968
+ const top = buttonRect.bottom - gridRect.top;
969
+ const left = buttonRect.left - gridRect.left;
970
+ this.activeFilterPopover.set({
971
+ field,
972
+ top,
973
+ left: Math.min(left, gridRect.width - 260)
974
+ });
975
+ }
976
+ getDistinctValues(field) {
977
+ const vals = new Set();
978
+ this.data().forEach(row => {
979
+ const val = row[field];
980
+ vals.add(val == null || val === '' ? '(Blank)' : String(val));
981
+ });
982
+ return Array.from(vals).sort();
983
+ }
984
+ toggleChecklistItem(val) {
985
+ const next = new Set(this.tempSelectedValues());
986
+ if (next.has(val)) {
987
+ next.delete(val);
988
+ }
989
+ else {
990
+ next.add(val);
991
+ }
992
+ this.tempSelectedValues.set(next);
993
+ }
994
+ toggleSelectAllChecklist() {
995
+ const pop = this.activeFilterPopover();
996
+ if (!pop)
997
+ return;
998
+ const distinct = this.getDistinctValues(pop.field);
999
+ if (this.tempSelectedValues().size === distinct.length) {
1000
+ this.tempSelectedValues.set(new Set());
1001
+ }
1002
+ else {
1003
+ this.tempSelectedValues.set(new Set(distinct));
1004
+ }
1005
+ }
1006
+ applyPopoverFilter() {
1007
+ const pop = this.activeFilterPopover();
1008
+ if (!pop)
1009
+ return;
1010
+ const field = pop.field;
1011
+ const distinct = this.getDistinctValues(field);
1012
+ const selected = this.tempSelectedValues();
1013
+ let filterState = null;
1014
+ if (this.tempFilterValue()) {
1015
+ filterState = {
1016
+ field,
1017
+ value: this.tempFilterValue(),
1018
+ operator: this.tempFilterOperator()
1019
+ };
1020
+ }
1021
+ else if (selected.size < distinct.length) {
1022
+ filterState = {
1023
+ field,
1024
+ value: '',
1025
+ operator: 'in',
1026
+ selectedValues: Array.from(selected)
1027
+ };
1028
+ }
1029
+ const nextStates = new Map(this.filterStates());
1030
+ if (filterState) {
1031
+ nextStates.set(field, filterState);
1032
+ }
1033
+ else {
1034
+ nextStates.delete(field);
1035
+ }
1036
+ this.filterStates.set(nextStates);
1037
+ this.currentPage.set(1);
1038
+ this.activeFilterPopover.set(null);
1039
+ this.filterChange.emit({ filters: this.activeFilters() });
1040
+ this.emitDataState();
1041
+ }
1042
+ clearPopoverFilter() {
1043
+ const pop = this.activeFilterPopover();
1044
+ if (!pop)
1045
+ return;
1046
+ const field = pop.field;
1047
+ const nextStates = new Map(this.filterStates());
1048
+ nextStates.delete(field);
1049
+ this.filterStates.set(nextStates);
1050
+ this.currentPage.set(1);
1051
+ this.activeFilterPopover.set(null);
1052
+ this.filterChange.emit({ filters: this.activeFilters() });
1053
+ this.emitDataState();
1054
+ }
1055
+ hasAggregation = computed(() => this.columns().some(col => col.aggregation));
1056
+ getAggregationValue(col) {
1057
+ const rows = this.clientFilteredData();
1058
+ if (rows.length === 0)
1059
+ return '-';
1060
+ const values = rows.map(r => {
1061
+ const val = r[col.field];
1062
+ return typeof val === 'number' ? val : Number(val);
1063
+ }).filter(v => !isNaN(v));
1064
+ if (col.aggregation === 'count') {
1065
+ return String(rows.length);
1066
+ }
1067
+ if (values.length === 0)
1068
+ return '-';
1069
+ switch (col.aggregation) {
1070
+ case 'sum': {
1071
+ const sum = values.reduce((acc, v) => acc + v, 0);
1072
+ return this.formatAggValue(sum);
1073
+ }
1074
+ case 'avg': {
1075
+ const sum = values.reduce((acc, v) => acc + v, 0);
1076
+ const avg = sum / values.length;
1077
+ return this.formatAggValue(avg);
1078
+ }
1079
+ case 'min': {
1080
+ return this.formatAggValue(Math.min(...values));
1081
+ }
1082
+ case 'max': {
1083
+ return this.formatAggValue(Math.max(...values));
1084
+ }
1085
+ default:
1086
+ return '-';
1087
+ }
1088
+ }
1089
+ formatAggValue(val) {
1090
+ return val % 1 === 0 ? String(val) : val.toFixed(2);
1091
+ }
1092
+ onSort(column, event) {
1093
+ const isMulti = this.multiSort() && event && (event.ctrlKey || event.shiftKey);
1094
+ const currentStates = [...this.sortStates()];
1095
+ const index = currentStates.findIndex(s => s.field === column.field);
1096
+ if (isMulti) {
1097
+ if (index !== -1) {
1098
+ const current = currentStates[index];
1099
+ if (current.dir === 'asc') {
1100
+ currentStates[index] = { field: column.field, dir: 'desc' };
1101
+ }
1102
+ else {
1103
+ currentStates.splice(index, 1);
1104
+ }
1105
+ }
1106
+ else {
1107
+ currentStates.push({ field: column.field, dir: 'asc' });
1108
+ }
1109
+ this.sortStates.set(currentStates);
245
1110
  }
246
1111
  else {
247
- this.sortState.set({ field: column.field, dir: 'asc' });
1112
+ if (index !== -1 && currentStates.length === 1) {
1113
+ const current = currentStates[0];
1114
+ if (current.dir === 'asc') {
1115
+ this.sortStates.set([{ field: column.field, dir: 'desc' }]);
1116
+ }
1117
+ else {
1118
+ this.sortStates.set([]);
1119
+ }
1120
+ }
1121
+ else {
1122
+ this.sortStates.set([{ field: column.field, dir: 'asc' }]);
1123
+ }
248
1124
  }
249
1125
  this.currentPage.set(1);
250
- this.sortChange.emit({ sort: this.sortState() });
1126
+ this.sortChange.emit({ sort: this.sortState(), sorts: this.sortStates() });
251
1127
  this.emitDataState();
252
1128
  }
1129
+ onDragStart(event, col) {
1130
+ if (!this.reorderable())
1131
+ return;
1132
+ this.draggingField.set(col.field);
1133
+ if (event.dataTransfer) {
1134
+ event.dataTransfer.effectAllowed = 'move';
1135
+ event.dataTransfer.setData('text/plain', col.field);
1136
+ }
1137
+ }
1138
+ onDragOver(event, col) {
1139
+ if (!this.reorderable() || this.draggingField() === col.field)
1140
+ return;
1141
+ event.preventDefault();
1142
+ this.dragOverField.set(col.field);
1143
+ }
1144
+ onDrop(event, targetCol) {
1145
+ if (!this.reorderable())
1146
+ return;
1147
+ const sourceField = this.draggingField();
1148
+ const targetField = targetCol.field;
1149
+ if (sourceField && sourceField !== targetField) {
1150
+ const currentOrder = this.columnOrder().length > 0
1151
+ ? [...this.columnOrder()]
1152
+ : this.columns().map(c => c.field);
1153
+ const sourceIndex = currentOrder.indexOf(sourceField);
1154
+ const targetIndex = currentOrder.indexOf(targetField);
1155
+ if (sourceIndex !== -1 && targetIndex !== -1) {
1156
+ currentOrder.splice(sourceIndex, 1);
1157
+ currentOrder.splice(targetIndex, 0, sourceField);
1158
+ this.columnOrder.set(currentOrder);
1159
+ this.columnReorder.emit({ columns: this.orderedColumns() });
1160
+ }
1161
+ }
1162
+ this.draggingField.set(null);
1163
+ this.dragOverField.set(null);
1164
+ }
1165
+ onDragEnd() {
1166
+ this.draggingField.set(null);
1167
+ this.dragOverField.set(null);
1168
+ }
1169
+ onRowDragStart(event, index) {
1170
+ if (!this.rowReorderable())
1171
+ return;
1172
+ this.draggingRowIndex.set(index);
1173
+ if (event.dataTransfer) {
1174
+ event.dataTransfer.effectAllowed = 'move';
1175
+ event.dataTransfer.setData('text/plain', String(index));
1176
+ }
1177
+ }
1178
+ onRowDragOver(event, index) {
1179
+ if (!this.rowReorderable() || this.draggingRowIndex() === index)
1180
+ return;
1181
+ event.preventDefault();
1182
+ this.dragOverRowIndex.set(index);
1183
+ }
1184
+ onRowDrop(event, targetIndex) {
1185
+ if (!this.rowReorderable())
1186
+ return;
1187
+ const sourceIndex = this.draggingRowIndex();
1188
+ if (sourceIndex !== null && sourceIndex !== targetIndex) {
1189
+ const rendered = this.flatRenderedRows();
1190
+ const sourceItem = rendered[sourceIndex];
1191
+ const targetItem = rendered[targetIndex];
1192
+ const currentData = [...this.data()];
1193
+ const actualSourceIdx = currentData.indexOf(sourceItem);
1194
+ const actualTargetIdx = currentData.indexOf(targetItem);
1195
+ if (actualSourceIdx !== -1 && actualTargetIdx !== -1) {
1196
+ currentData.splice(actualSourceIdx, 1);
1197
+ currentData.splice(actualTargetIdx, 0, sourceItem);
1198
+ this.rowReorder.emit({
1199
+ previousIndex: actualSourceIdx,
1200
+ currentIndex: actualTargetIdx,
1201
+ data: currentData
1202
+ });
1203
+ }
1204
+ }
1205
+ this.draggingRowIndex.set(null);
1206
+ this.dragOverRowIndex.set(null);
1207
+ }
1208
+ onRowDragEnd() {
1209
+ this.draggingRowIndex.set(null);
1210
+ this.dragOverRowIndex.set(null);
1211
+ }
1212
+ getSortIndex(col) {
1213
+ return this.sortStates().findIndex(s => s.field === col.field) + 1;
1214
+ }
1215
+ getSortDirection(col) {
1216
+ const found = this.sortStates().find(s => s.field === col.field);
1217
+ return found ? found.dir : null;
1218
+ }
253
1219
  setGroup(state) {
254
1220
  this.groupChange.emit({ group: state });
255
1221
  this.currentPage.set(1);
@@ -358,14 +1324,78 @@ class DataGridComponent {
358
1324
  return row[field] ?? '';
359
1325
  }
360
1326
  resolveHeaderTemplate(column) {
361
- return column.headerTemplate ?? this.headerTemplate();
1327
+ if (column.headerTemplate) {
1328
+ return column.headerTemplate;
1329
+ }
1330
+ const match = this.headerTemplates?.find(t => t.columnField === column.field);
1331
+ if (match) {
1332
+ return match.templateRef;
1333
+ }
1334
+ return this.headerTemplate();
362
1335
  }
363
1336
  resolveCellTemplate(column) {
364
- return column.cellTemplate ?? this.cellTemplate();
1337
+ if (column.cellTemplate) {
1338
+ return column.cellTemplate;
1339
+ }
1340
+ const match = this.cellTemplates?.find(t => t.columnField === column.field);
1341
+ if (match) {
1342
+ return match.templateRef;
1343
+ }
1344
+ return this.cellTemplate();
1345
+ }
1346
+ resolveEditCellTemplate(column) {
1347
+ if (column.editCellTemplate) {
1348
+ return column.editCellTemplate;
1349
+ }
1350
+ const match = this.editCellTemplates?.find(t => t.columnField === column.field);
1351
+ if (match) {
1352
+ return match.templateRef;
1353
+ }
1354
+ return this.editCellTemplate();
1355
+ }
1356
+ resolveFooterTemplate(column) {
1357
+ if (column.footerTemplate) {
1358
+ return column.footerTemplate;
1359
+ }
1360
+ const match = this.footerTemplates?.find(t => t.columnField === column.field);
1361
+ if (match) {
1362
+ return match.templateRef;
1363
+ }
1364
+ return this.footerTemplate();
1365
+ }
1366
+ getUpdateDraftCallback(field) {
1367
+ return (val) => this.updateDraft(field, val);
365
1368
  }
366
1369
  toStringSafe(value) {
367
1370
  return value == null ? '' : String(value);
368
1371
  }
1372
+ highlightSearchText(value) {
1373
+ const rawVal = value == null ? '' : String(value);
1374
+ const searchVal = this.searchText().trim();
1375
+ if (!searchVal || !this.showGlobalSearch()) {
1376
+ return this.escapeHtml(rawVal);
1377
+ }
1378
+ const escapedVal = this.escapeHtml(rawVal);
1379
+ const escapedSearch = this.escapeRegExp(searchVal);
1380
+ try {
1381
+ const regex = new RegExp(`(${escapedSearch})`, 'gi');
1382
+ return escapedVal.replace(regex, '<mark class="search-highlight">$1</mark>');
1383
+ }
1384
+ catch {
1385
+ return escapedVal;
1386
+ }
1387
+ }
1388
+ escapeHtml(text) {
1389
+ return text
1390
+ .replace(/&/g, '&amp;')
1391
+ .replace(/</g, '&lt;')
1392
+ .replace(/>/g, '&gt;')
1393
+ .replace(/"/g, '&quot;')
1394
+ .replace(/'/g, '&#039;');
1395
+ }
1396
+ escapeRegExp(text) {
1397
+ return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
1398
+ }
369
1399
  getKey(row, index) {
370
1400
  const source = row;
371
1401
  return String(source['id'] ?? source['key'] ?? index);
@@ -425,81 +1455,394 @@ class DataGridComponent {
425
1455
  group: overrideGroup === undefined ? this.groupBy() : overrideGroup,
426
1456
  });
427
1457
  }
428
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: DataGridComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
429
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: DataGridComponent, isStandalone: true, selector: "ngx-data-grid", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: false, transformFunction: null }, pageSize: { classPropertyName: "pageSize", publicName: "pageSize", isSignal: true, isRequired: false, transformFunction: null }, page: { classPropertyName: "page", publicName: "page", isSignal: true, isRequired: false, transformFunction: null }, total: { classPropertyName: "total", publicName: "total", isSignal: true, isRequired: false, transformFunction: null }, selectable: { classPropertyName: "selectable", publicName: "selectable", isSignal: true, isRequired: false, transformFunction: null }, striped: { classPropertyName: "striped", publicName: "striped", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, editable: { classPropertyName: "editable", publicName: "editable", isSignal: true, isRequired: false, transformFunction: null }, sortMode: { classPropertyName: "sortMode", publicName: "sortMode", isSignal: true, isRequired: false, transformFunction: null }, filterMode: { classPropertyName: "filterMode", publicName: "filterMode", isSignal: true, isRequired: false, transformFunction: null }, groupMode: { classPropertyName: "groupMode", publicName: "groupMode", isSignal: true, isRequired: false, transformFunction: null }, pagingMode: { classPropertyName: "pagingMode", publicName: "pagingMode", isSignal: true, isRequired: false, transformFunction: null }, groupBy: { classPropertyName: "groupBy", publicName: "groupBy", isSignal: true, isRequired: false, transformFunction: null }, groupedData: { classPropertyName: "groupedData", publicName: "groupedData", isSignal: true, isRequired: false, transformFunction: null }, headerTemplate: { classPropertyName: "headerTemplate", publicName: "headerTemplate", isSignal: true, isRequired: false, transformFunction: null }, cellTemplate: { classPropertyName: "cellTemplate", publicName: "cellTemplate", isSignal: true, isRequired: false, transformFunction: null }, rowTemplate: { classPropertyName: "rowTemplate", publicName: "rowTemplate", isSignal: true, isRequired: false, transformFunction: null }, detailRowTemplate: { classPropertyName: "detailRowTemplate", publicName: "detailRowTemplate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { rowClick: "rowClick", selectionChange: "selectionChange", sortChange: "sortChange", filterChange: "filterChange", groupChange: "groupChange", pageChange: "pageChange", dataStateChange: "dataStateChange", rowUpdate: "rowUpdate" }, ngImport: i0, template: `
430
- <div class="ngx-data-grid" [class.loading]="loading()">
431
-
432
- <div class="grid-toolbar">
433
- <span class="grid-toolbar-title">Data Grid</span>
434
- <div class="grid-toolbar-actions">
435
- <button class="grid-action-btn" (click)="exportToJson()" title="Export JSON">JSON</button>
436
- <button class="grid-action-btn" (click)="exportToCsv()" title="Export CSV">CSV</button>
437
- </div>
438
- </div>
439
-
440
- @if (hasFilterableColumns()) {
441
- <div class="grid-filter-bar">
442
- @for (col of columns(); track col.field) {
443
- @if (col.filterable) {
444
- <input
445
- class="grid-filter-input"
446
- [placeholder]="'Filter ' + col.title"
447
- [value]="getFilter(col.field)"
448
- (input)="setFilter(col.field, $any($event.target).value)"
449
- [style.width.px]="col.width ?? 120"
450
- />
451
- } @else {
452
- <div [style.width.px]="col.width ?? 120" class="grid-filter-spacer"></div>
1458
+ onCellClick(row, colField) {
1459
+ if (!this.keyboardNavigation())
1460
+ return;
1461
+ this.focusedCell.set({ row, colField });
1462
+ this.focusedCellEditActive.set(this.isEditing(row));
1463
+ }
1464
+ handleKeyDown(event) {
1465
+ if (!this.keyboardNavigation())
1466
+ return;
1467
+ const key = event.key;
1468
+ const focused = this.focusedCell();
1469
+ if (!focused) {
1470
+ if (key === 'ArrowDown' || key === 'ArrowUp' || key === 'ArrowLeft' || key === 'ArrowRight') {
1471
+ const rows = this.flatRenderedRows();
1472
+ const cols = this.orderedColumns();
1473
+ if (rows.length > 0 && cols.length > 0) {
1474
+ this.focusedCell.set({ row: rows[0], colField: cols[0].field });
1475
+ event.preventDefault();
1476
+ }
453
1477
  }
454
- }
455
- </div>
456
- }
457
-
458
- <div class="grid-table-wrap">
459
- <table class="grid-table" [class.striped]="striped()">
460
- <thead>
461
- <tr>
462
- @if (showDetailToggle()) {
463
- <th class="grid-th grid-th-toggle" style="width:36px"></th>
464
- }
465
- @if (selectable()) {
466
- <th class="grid-th grid-th-check" style="width:40px">
467
- <input type="checkbox" [checked]="allSelected()" [indeterminate]="someSelected() && !allSelected()" (change)="toggleAll()" />
468
- </th>
1478
+ return;
1479
+ }
1480
+ const rows = this.flatRenderedRows();
1481
+ const cols = this.orderedColumns();
1482
+ const rowIndex = rows.indexOf(focused.row);
1483
+ const colIndex = cols.findIndex(c => c.field === focused.colField);
1484
+ if (rowIndex === -1 || colIndex === -1)
1485
+ return;
1486
+ if (this.focusedCellEditActive()) {
1487
+ if (key === 'Enter') {
1488
+ this.saveEdit(focused.row, rowIndex);
1489
+ this.focusedCellEditActive.set(false);
1490
+ if (rowIndex < rows.length - 1) {
1491
+ this.focusedCell.set({ row: rows[rowIndex + 1], colField: focused.colField });
1492
+ }
1493
+ event.preventDefault();
1494
+ }
1495
+ else if (key === 'Escape') {
1496
+ this.cancelEdit();
1497
+ this.focusedCellEditActive.set(false);
1498
+ event.preventDefault();
1499
+ }
1500
+ return;
1501
+ }
1502
+ switch (key) {
1503
+ case 'ArrowUp':
1504
+ if (rowIndex > 0) {
1505
+ this.focusedCell.set({ row: rows[rowIndex - 1], colField: focused.colField });
1506
+ event.preventDefault();
1507
+ }
1508
+ break;
1509
+ case 'ArrowDown':
1510
+ if (rowIndex < rows.length - 1) {
1511
+ this.focusedCell.set({ row: rows[rowIndex + 1], colField: focused.colField });
1512
+ event.preventDefault();
1513
+ }
1514
+ break;
1515
+ case 'ArrowLeft':
1516
+ if (colIndex > 0) {
1517
+ this.focusedCell.set({ row: focused.row, colField: cols[colIndex - 1].field });
1518
+ event.preventDefault();
1519
+ }
1520
+ break;
1521
+ case 'ArrowRight':
1522
+ if (colIndex < cols.length - 1) {
1523
+ this.focusedCell.set({ row: focused.row, colField: cols[colIndex + 1].field });
1524
+ event.preventDefault();
1525
+ }
1526
+ break;
1527
+ case 'Tab':
1528
+ if (event.shiftKey) {
1529
+ if (colIndex > 0) {
1530
+ this.focusedCell.set({ row: focused.row, colField: cols[colIndex - 1].field });
1531
+ }
1532
+ else if (rowIndex > 0) {
1533
+ this.focusedCell.set({ row: rows[rowIndex - 1], colField: cols[cols.length - 1].field });
1534
+ }
1535
+ }
1536
+ else {
1537
+ if (colIndex < cols.length - 1) {
1538
+ this.focusedCell.set({ row: focused.row, colField: cols[colIndex + 1].field });
1539
+ }
1540
+ else if (rowIndex < rows.length - 1) {
1541
+ this.focusedCell.set({ row: rows[rowIndex + 1], colField: cols[0].field });
1542
+ }
1543
+ }
1544
+ event.preventDefault();
1545
+ break;
1546
+ case 'Enter': {
1547
+ const col = cols[colIndex];
1548
+ if (this.editable() && col.editable) {
1549
+ this.beginEdit(focused.row, rowIndex);
1550
+ this.focusedCellEditActive.set(true);
1551
+ setTimeout(() => {
1552
+ const inputEl = this.elementRef.nativeElement.querySelector('.grid-edit-input');
1553
+ if (inputEl)
1554
+ inputEl.focus();
1555
+ }, 0);
1556
+ event.preventDefault();
1557
+ }
1558
+ break;
1559
+ }
1560
+ case 'Escape':
1561
+ this.focusedCell.set(null);
1562
+ event.preventDefault();
1563
+ break;
1564
+ default:
1565
+ if (key.length === 1 && !event.ctrlKey && !event.altKey && !event.metaKey) {
1566
+ const currentCol = cols[colIndex];
1567
+ if (this.editable() && currentCol.editable) {
1568
+ this.beginEdit(focused.row, rowIndex);
1569
+ this.focusedCellEditActive.set(true);
1570
+ this.updateDraft(focused.colField, key);
1571
+ setTimeout(() => {
1572
+ const inputEl = this.elementRef.nativeElement.querySelector('.grid-edit-input');
1573
+ if (inputEl) {
1574
+ inputEl.focus();
1575
+ inputEl.value = key;
1576
+ }
1577
+ }, 0);
1578
+ event.preventDefault();
1579
+ }
1580
+ }
1581
+ break;
1582
+ }
1583
+ }
1584
+ getCellRowSpan(row, colField, rowIndex, groupItems) {
1585
+ const col = this.columns().find(c => c.field === colField);
1586
+ if (!col || !col.mergeRows) {
1587
+ return 1;
1588
+ }
1589
+ const items = groupItems ? groupItems : this.flatRenderedRows();
1590
+ const currentValue = this.getCellValue(row, colField);
1591
+ if (rowIndex > 0) {
1592
+ const prevValue = this.getCellValue(items[rowIndex - 1], colField);
1593
+ if (prevValue === currentValue) {
1594
+ return 0;
1595
+ }
1596
+ }
1597
+ let span = 1;
1598
+ for (let i = rowIndex + 1; i < items.length; i++) {
1599
+ if (this.getCellValue(items[i], colField) === currentValue) {
1600
+ span++;
1601
+ }
1602
+ else {
1603
+ break;
1604
+ }
1605
+ }
1606
+ return span;
1607
+ }
1608
+ isGroupAllSelected(group) {
1609
+ const rows = group.items;
1610
+ if (rows.length === 0)
1611
+ return false;
1612
+ const selected = this.selectedRows();
1613
+ return rows.every(row => selected.has(this.keyOf(row)));
1614
+ }
1615
+ toggleGroupSelection(group, event) {
1616
+ event.stopPropagation();
1617
+ const checked = event.target.checked;
1618
+ const selected = new Set(this.selectedRows());
1619
+ group.items.forEach(row => {
1620
+ const key = this.keyOf(row);
1621
+ if (checked) {
1622
+ selected.add(key);
1623
+ }
1624
+ else {
1625
+ selected.delete(key);
1626
+ }
1627
+ });
1628
+ this.selectedRows.set(selected);
1629
+ this.selectionChange.emit(this.resolveSelectedRows(selected));
1630
+ }
1631
+ getGroupAggregationValue(group, col) {
1632
+ const rows = group.items;
1633
+ if (rows.length === 0)
1634
+ return '-';
1635
+ const values = rows.map(r => {
1636
+ const val = r[col.field];
1637
+ return typeof val === 'number' ? val : Number(val);
1638
+ }).filter(v => !isNaN(v));
1639
+ if (col.aggregation === 'count') {
1640
+ return String(rows.length);
1641
+ }
1642
+ if (values.length === 0)
1643
+ return '-';
1644
+ switch (col.aggregation) {
1645
+ case 'sum': {
1646
+ const sum = values.reduce((acc, v) => acc + v, 0);
1647
+ return this.formatAggValue(sum);
1648
+ }
1649
+ case 'avg': {
1650
+ const sum = values.reduce((acc, v) => acc + v, 0);
1651
+ const avg = sum / values.length;
1652
+ return this.formatAggValue(avg);
1653
+ }
1654
+ case 'min': {
1655
+ return this.formatAggValue(Math.min(...values));
1656
+ }
1657
+ case 'max': {
1658
+ return this.formatAggValue(Math.max(...values));
1659
+ }
1660
+ default:
1661
+ return '-';
1662
+ }
1663
+ }
1664
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: DataGridComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1665
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: DataGridComponent, isStandalone: true, selector: "ngx-data-grid", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: false, transformFunction: null }, stateKey: { classPropertyName: "stateKey", publicName: "stateKey", isSignal: true, isRequired: false, transformFunction: null }, reorderable: { classPropertyName: "reorderable", publicName: "reorderable", isSignal: true, isRequired: false, transformFunction: null }, multiSort: { classPropertyName: "multiSort", publicName: "multiSort", isSignal: true, isRequired: false, transformFunction: null }, rowReorderable: { classPropertyName: "rowReorderable", publicName: "rowReorderable", isSignal: true, isRequired: false, transformFunction: null }, showGlobalSearch: { classPropertyName: "showGlobalSearch", publicName: "showGlobalSearch", isSignal: true, isRequired: false, transformFunction: null }, globalSearchPlaceholder: { classPropertyName: "globalSearchPlaceholder", publicName: "globalSearchPlaceholder", isSignal: true, isRequired: false, transformFunction: null }, pageSize: { classPropertyName: "pageSize", publicName: "pageSize", isSignal: true, isRequired: false, transformFunction: null }, page: { classPropertyName: "page", publicName: "page", isSignal: true, isRequired: false, transformFunction: null }, total: { classPropertyName: "total", publicName: "total", isSignal: true, isRequired: false, transformFunction: null }, selectable: { classPropertyName: "selectable", publicName: "selectable", isSignal: true, isRequired: false, transformFunction: null }, striped: { classPropertyName: "striped", publicName: "striped", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, editable: { classPropertyName: "editable", publicName: "editable", isSignal: true, isRequired: false, transformFunction: null }, sortMode: { classPropertyName: "sortMode", publicName: "sortMode", isSignal: true, isRequired: false, transformFunction: null }, filterMode: { classPropertyName: "filterMode", publicName: "filterMode", isSignal: true, isRequired: false, transformFunction: null }, groupMode: { classPropertyName: "groupMode", publicName: "groupMode", isSignal: true, isRequired: false, transformFunction: null }, pagingMode: { classPropertyName: "pagingMode", publicName: "pagingMode", isSignal: true, isRequired: false, transformFunction: null }, groupBy: { classPropertyName: "groupBy", publicName: "groupBy", isSignal: true, isRequired: false, transformFunction: null }, groupedData: { classPropertyName: "groupedData", publicName: "groupedData", isSignal: true, isRequired: false, transformFunction: null }, headerTemplate: { classPropertyName: "headerTemplate", publicName: "headerTemplate", isSignal: true, isRequired: false, transformFunction: null }, cellTemplate: { classPropertyName: "cellTemplate", publicName: "cellTemplate", isSignal: true, isRequired: false, transformFunction: null }, editCellTemplate: { classPropertyName: "editCellTemplate", publicName: "editCellTemplate", isSignal: true, isRequired: false, transformFunction: null }, rowTemplate: { classPropertyName: "rowTemplate", publicName: "rowTemplate", isSignal: true, isRequired: false, transformFunction: null }, detailRowTemplate: { classPropertyName: "detailRowTemplate", publicName: "detailRowTemplate", isSignal: true, isRequired: false, transformFunction: null }, footerTemplate: { classPropertyName: "footerTemplate", publicName: "footerTemplate", isSignal: true, isRequired: false, transformFunction: null }, showColumnChooser: { classPropertyName: "showColumnChooser", publicName: "showColumnChooser", isSignal: true, isRequired: false, transformFunction: null }, cellSelection: { classPropertyName: "cellSelection", publicName: "cellSelection", isSignal: true, isRequired: false, transformFunction: null }, enableContextMenu: { classPropertyName: "enableContextMenu", publicName: "enableContextMenu", isSignal: true, isRequired: false, transformFunction: null }, keyboardNavigation: { classPropertyName: "keyboardNavigation", publicName: "keyboardNavigation", isSignal: true, isRequired: false, transformFunction: null }, groupAggregations: { classPropertyName: "groupAggregations", publicName: "groupAggregations", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { columnReorder: "columnReorder", rowReorder: "rowReorder", rowClick: "rowClick", selectionChange: "selectionChange", sortChange: "sortChange", filterChange: "filterChange", groupChange: "groupChange", pageChange: "pageChange", dataStateChange: "dataStateChange", rowUpdate: "rowUpdate", cellSelectionChange: "cellSelectionChange" }, host: { listeners: { "keydown": "handleKeyDown($event)" } }, queries: [{ propertyName: "cellTemplates", predicate: NgxGridCellTemplateDirective }, { propertyName: "editCellTemplates", predicate: NgxGridEditCellTemplateDirective }, { propertyName: "headerTemplates", predicate: NgxGridHeaderTemplateDirective }, { propertyName: "footerTemplates", predicate: NgxGridFooterTemplateDirective }], ngImport: i0, template: `
1666
+ <div class="ngx-data-grid" [class.loading]="loading()">
1667
+
1668
+ <div class="grid-toolbar">
1669
+ <span class="grid-toolbar-title">Data Grid</span>
1670
+ <div class="grid-toolbar-actions">
1671
+ @if (showGlobalSearch()) {
1672
+ <div class="grid-search-wrap">
1673
+ <input
1674
+ class="grid-search-input"
1675
+ type="text"
1676
+ [placeholder]="globalSearchPlaceholder()"
1677
+ [value]="searchText()"
1678
+ (input)="searchText.set($any($event.target).value)"
1679
+ />
1680
+ @if (searchText()) {
1681
+ <button class="grid-search-clear" (click)="searchText.set('')" title="Clear search">×</button>
469
1682
  }
470
- @for (col of columns(); track col.field) {
471
- <th
472
- class="grid-th"
473
- [style.width.px]="col.width"
474
- [class.sortable]="col.sortable"
475
- [class.sort-asc]="sortState()?.field === col.field && sortState()?.dir === 'asc'"
476
- [class.sort-desc]="sortState()?.field === col.field && sortState()?.dir === 'desc'"
477
- (click)="col.sortable ? onSort(col) : null"
478
- >
479
- @if (resolveHeaderTemplate(col); as activeHeaderTemplate) {
480
- <ng-container *ngTemplateOutlet="activeHeaderTemplate; context: {
481
- $implicit: col,
482
- column: col,
483
- sort: sortState(),
484
- filters: activeFilters(),
485
- isServerMode: isAnyServerMode()
486
- }" />
487
- } @else {
488
- <span class="th-text">{{ col.title }}</span>
489
- @if (col.sortable) {
490
- <span class="sort-icon">
491
- @if (sortState()?.field === col.field) {
492
- {{ sortState()?.dir === 'asc' ? '↑' : '↓' }}
493
- } @else { ↕ }
1683
+ </div>
1684
+ }
1685
+ @if (showColumnChooser()) {
1686
+ <button class="grid-action-btn" (click)="openColumnChooser($event)" title="Choose columns">Columns</button>
1687
+ }
1688
+ <button class="grid-action-btn" (click)="exportToJson()" title="Export JSON">JSON</button>
1689
+ <button class="grid-action-btn" (click)="exportToCsv()" title="Export CSV">CSV</button>
1690
+ </div>
1691
+ </div>
1692
+
1693
+ <div class="grid-table-wrap">
1694
+ <table class="grid-table" [class.striped]="striped()">
1695
+ <colgroup>
1696
+ @if (rowReorderable()) {
1697
+ <col style="width: 44px" />
1698
+ }
1699
+ @if (showDetailToggle()) {
1700
+ <col style="width: 44px" />
1701
+ }
1702
+ @if (selectable()) {
1703
+ <col style="width: 44px" />
1704
+ }
1705
+ @for (col of orderedColumns(); track col.field) {
1706
+ <col [style.width.px]="getColumnWidth(col)" />
1707
+ }
1708
+ @if (editable()) {
1709
+ <col style="width: 120px" />
1710
+ }
1711
+ </colgroup>
1712
+ <thead>
1713
+ <ng-template #headerCellContent let-col="col">
1714
+ <div class="th-content-wrapper">
1715
+ @if (resolveHeaderTemplate(col); as activeHeaderTemplate) {
1716
+ <ng-container *ngTemplateOutlet="activeHeaderTemplate; context: {
1717
+ $implicit: col,
1718
+ column: col,
1719
+ sort: sortState(),
1720
+ filters: activeFilters(),
1721
+ isServerMode: isAnyServerMode()
1722
+ }" />
1723
+ } @else {
1724
+ <span class="th-text">{{ col.title }}</span>
1725
+ @if (col.sortable) {
1726
+ @if (getSortDirection(col); as dir) {
1727
+ <span class="sort-icon active">
1728
+ {{ dir === 'asc' ? '↑' : '↓' }}
1729
+ @if (multiSort() && sortStates().length > 1) {
1730
+ <sub class="sort-order-badge">{{ getSortIndex(col) }}</sub>
1731
+ }
494
1732
  </span>
1733
+ } @else {
1734
+ <span class="sort-icon">↕</span>
495
1735
  }
496
1736
  }
1737
+ }
1738
+ @if (col.filterable) {
1739
+ <button class="grid-filter-btn" [class.active]="filterStates().has(col.field)" (click)="openFilterPopover($event, col.field); $event.stopPropagation()" title="Filter column">
1740
+ <svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
1741
+ <polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"></polygon>
1742
+ </svg>
1743
+ </button>
1744
+ }
1745
+ </div>
1746
+ <div class="grid-resize-handle" (mousedown)="onResizeStart($event, col)" (click)="$event.stopPropagation()"></div>
1747
+ </ng-template>
1748
+
1749
+ <tr class="grid-header-row">
1750
+ @if (rowReorderable()) {
1751
+ <th class="grid-th grid-th-reorder pinned-left" [class.pinned-left-last]="isRowReorderableLastPinned()" [attr.rowspan]="hasColumnCategories() ? 2 : 1" style="width:44px; left:0px"></th>
1752
+ }
1753
+ @if (showDetailToggle()) {
1754
+ <th class="grid-th grid-th-toggle pinned-left" [class.pinned-left-last]="isDetailToggleLastPinned()" [attr.rowspan]="hasColumnCategories() ? 2 : 1" [style.left.px]="rowReorderable() ? 44 : 0" style="width:44px"></th>
1755
+ }
1756
+ @if (selectable()) {
1757
+ <th class="grid-th grid-th-check pinned-left" [class.pinned-left-last]="isSelectableLastPinned()" [attr.rowspan]="hasColumnCategories() ? 2 : 1" [style.left.px]="(rowReorderable() ? 44 : 0) + (showDetailToggle() ? 44 : 0)" style="width:44px">
1758
+ <input type="checkbox" [checked]="allSelected()" [indeterminate]="someSelected() && !allSelected()" (change)="toggleAll()" />
497
1759
  </th>
498
1760
  }
1761
+ @for (cell of headerRows().row1; track cell.field) {
1762
+ @if (cell.isCategory) {
1763
+ <th
1764
+ class="grid-th grid-category-th"
1765
+ [class.pinned-left]="cell.pinned === 'left'"
1766
+ [class.pinned-left-last]="cell.isPinnedLast"
1767
+ [class.pinned-right]="cell.pinned === 'right'"
1768
+ [class.pinned-right-first]="cell.isPinnedFirst"
1769
+ [style.left.px]="cell.pinned === 'left' ? cell.leftOffset : null"
1770
+ [style.right.px]="cell.pinned === 'right' ? cell.rightOffset : null"
1771
+ [attr.colspan]="cell.colSpan"
1772
+ [attr.rowspan]="cell.rowSpan"
1773
+ >
1774
+ <span class="category-title">{{ cell.title }}</span>
1775
+ </th>
1776
+ } @else {
1777
+ <th
1778
+ class="grid-th"
1779
+ [class.pinned-left]="cell.column.pinned === 'left'"
1780
+ [class.pinned-left-last]="cell.isPinnedLast"
1781
+ [class.pinned-right]="cell.column.pinned === 'right'"
1782
+ [class.pinned-right-first]="cell.isPinnedFirst"
1783
+ [style.left.px]="cell.column.pinned === 'left' ? cell.leftOffset : null"
1784
+ [style.right.px]="cell.column.pinned === 'right' ? cell.rightOffset : null"
1785
+ [style.width.px]="getColumnWidth(cell.column)"
1786
+ [class.sortable]="cell.column.sortable"
1787
+ [class.sort-asc]="getSortDirection(cell.column) === 'asc'"
1788
+ [class.sort-desc]="getSortDirection(cell.column) === 'desc'"
1789
+ [class.dragging]="draggingField() === cell.column.field"
1790
+ [class.drag-over]="dragOverField() === cell.column.field"
1791
+ [attr.draggable]="reorderable() ? true : null"
1792
+ (dragstart)="onDragStart($event, cell.column)"
1793
+ (dragover)="onDragOver($event, cell.column)"
1794
+ (drop)="onDrop($event, cell.column)"
1795
+ (dragend)="onDragEnd()"
1796
+ (click)="cell.column.sortable ? onSort(cell.column, $event) : null"
1797
+ [attr.colspan]="cell.colSpan"
1798
+ [attr.rowspan]="cell.rowSpan"
1799
+ >
1800
+ <ng-container *ngTemplateOutlet="headerCellContent; context: { col: cell.column }" />
1801
+ </th>
1802
+ }
1803
+ }
499
1804
  @if (editable()) {
500
- <th class="grid-th" style="width:120px">Actions</th>
1805
+ <th
1806
+ class="grid-th"
1807
+ [class.pinned-right]="firstPinnedRightColumnField() !== null"
1808
+ [class.pinned-right-first]="firstPinnedRightColumnField() === null"
1809
+ [style.right.px]="firstPinnedRightColumnField() !== null ? 0 : null"
1810
+ [attr.rowspan]="hasColumnCategories() ? 2 : 1"
1811
+ style="width:120px"
1812
+ >Actions</th>
501
1813
  }
502
1814
  </tr>
1815
+ @if (hasColumnCategories()) {
1816
+ <tr class="grid-header-row sub-header-row">
1817
+ @for (cell of headerRows().row2; track cell.field) {
1818
+ <th
1819
+ class="grid-th"
1820
+ [class.pinned-left]="cell.column.pinned === 'left'"
1821
+ [class.pinned-left-last]="cell.isPinnedLast"
1822
+ [class.pinned-right]="cell.column.pinned === 'right'"
1823
+ [class.pinned-right-first]="cell.isPinnedFirst"
1824
+ [style.left.px]="cell.column.pinned === 'left' ? cell.leftOffset : null"
1825
+ [style.right.px]="cell.column.pinned === 'right' ? cell.rightOffset : null"
1826
+ [style.width.px]="getColumnWidth(cell.column)"
1827
+ [class.sortable]="cell.column.sortable"
1828
+ [class.sort-asc]="getSortDirection(cell.column) === 'asc'"
1829
+ [class.sort-desc]="getSortDirection(cell.column) === 'desc'"
1830
+ [class.dragging]="draggingField() === cell.column.field"
1831
+ [class.drag-over]="dragOverField() === cell.column.field"
1832
+ [attr.draggable]="reorderable() ? true : null"
1833
+ (dragstart)="onDragStart($event, cell.column)"
1834
+ (dragover)="onDragOver($event, cell.column)"
1835
+ (drop)="onDrop($event, cell.column)"
1836
+ (dragend)="onDragEnd()"
1837
+ (click)="cell.column.sortable ? onSort(cell.column, $event) : null"
1838
+ [attr.colspan]="cell.colSpan"
1839
+ [attr.rowspan]="cell.rowSpan"
1840
+ >
1841
+ <ng-container *ngTemplateOutlet="headerCellContent; context: { col: cell.column }" />
1842
+ </th>
1843
+ }
1844
+ </tr>
1845
+ }
503
1846
  </thead>
504
1847
  <tbody>
505
1848
  @if (loading()) {
@@ -515,13 +1858,59 @@ class DataGridComponent {
515
1858
  } @else if (groupedRows().length > 0) {
516
1859
  @for (group of groupedRows(); track group.key) {
517
1860
  <tr class="grid-group-row" (click)="toggleGroup(group.key)">
518
- <td [attr.colspan]="renderColumnCount()">
519
- <button class="group-toggle" type="button" (click)="toggleGroup(group.key); $event.stopPropagation()">
520
- {{ isGroupCollapsed(group.key) ? '▸' : '▾' }}
521
- </button>
522
- <strong>{{ group.field }}</strong>: {{ group.value }}
523
- <span class="group-count">({{ group.count }})</span>
524
- </td>
1861
+ @if (groupAggregations()) {
1862
+ @if (rowReorderable()) {
1863
+ <td class="grid-td grid-td-reorder pinned-left" [class.pinned-left-last]="isRowReorderableLastPinned()" style="left:0px; width:44px"></td>
1864
+ }
1865
+ @if (showDetailToggle()) {
1866
+ <td class="grid-td grid-td-toggle pinned-left" [class.pinned-left-last]="isDetailToggleLastPinned()" [style.left.px]="rowReorderable() ? 44 : 0" style="width:44px"></td>
1867
+ }
1868
+ @if (selectable()) {
1869
+ <td class="grid-td grid-td-check pinned-left" [class.pinned-left-last]="isSelectableLastPinned()" [style.left.px]="(rowReorderable() ? 44 : 0) + (showDetailToggle() ? 44 : 0)" style="width:44px">
1870
+ <input type="checkbox" [checked]="isGroupAllSelected(group)" (change)="toggleGroupSelection(group, $event)" (click)="$event.stopPropagation()" />
1871
+ </td>
1872
+ }
1873
+ @for (col of orderedColumns(); track col.field; let first = $first) {
1874
+ <td
1875
+ class="grid-td"
1876
+ [class.pinned-left]="col.pinned === 'left'"
1877
+ [class.pinned-left-last]="col.pinned === 'left' && lastPinnedColumnField() === col.field"
1878
+ [class.pinned-right]="col.pinned === 'right'"
1879
+ [class.pinned-right-first]="col.pinned === 'right' && firstPinnedRightColumnField() === col.field"
1880
+ [style.left.px]="col.pinned === 'left' ? columnOffsets()[col.field] : null"
1881
+ [style.right.px]="col.pinned === 'right' ? columnRightOffsets()[col.field] : null"
1882
+ [style.text-align]="col.align ?? 'left'"
1883
+ [style.width.px]="getColumnWidth(col)"
1884
+ >
1885
+ @if (first) {
1886
+ <div style="display: flex; align-items: center; gap: 4px;">
1887
+ <button class="group-toggle" type="button" (click)="toggleGroup(group.key); $event.stopPropagation()" style="background: transparent; border: none; cursor: pointer; padding: 0 4px; font-weight: bold; color: inherit; outline: none;">
1888
+ {{ isGroupCollapsed(group.key) ? '▸' : '▾' }}
1889
+ </button>
1890
+ <strong>{{ col.category ? '' : group.field + ': ' }}</strong>{{ group.value }} <span class="group-count">({{ group.count }})</span>
1891
+ </div>
1892
+ } @else if (col.aggregation) {
1893
+ <span class="agg-label">{{ col.aggregation }}: </span>
1894
+ <strong class="agg-value">{{ getGroupAggregationValue(group, col) }}</strong>
1895
+ }
1896
+ </td>
1897
+ }
1898
+ @if (editable()) {
1899
+ <td
1900
+ [class.pinned-right]="firstPinnedRightColumnField() !== null"
1901
+ [class.pinned-right-first]="firstPinnedRightColumnField() === null"
1902
+ [style.right.px]="firstPinnedRightColumnField() !== null ? 0 : null"
1903
+ ></td>
1904
+ }
1905
+ } @else {
1906
+ <td [attr.colspan]="renderColumnCount()">
1907
+ <button class="group-toggle" type="button" (click)="toggleGroup(group.key); $event.stopPropagation()">
1908
+ {{ isGroupCollapsed(group.key) ? '▸' : '▾' }}
1909
+ </button>
1910
+ <strong>{{ group.field }}</strong>: {{ group.value }}
1911
+ <span class="group-count">({{ group.count }})</span>
1912
+ </td>
1913
+ }
525
1914
  </tr>
526
1915
 
527
1916
  @if (!isGroupCollapsed(group.key)) {
@@ -529,11 +1918,27 @@ class DataGridComponent {
529
1918
  <tr
530
1919
  class="grid-row"
531
1920
  [class.selected]="isRowSelected(row)"
1921
+ [class.dragging-row]="draggingRowIndex() === i"
1922
+ [class.drag-over-row]="dragOverRowIndex() === i"
1923
+ (dragover)="onRowDragOver($event, i)"
1924
+ (drop)="onRowDrop($event, i)"
1925
+ (dragend)="onRowDragEnd()"
532
1926
  (click)="onRowClick(row, i)"
533
1927
  (dblclick)="editable() ? beginEdit(row, i) : null"
534
1928
  >
1929
+ @if (rowReorderable()) {
1930
+ <td class="grid-td grid-td-reorder pinned-left" [class.pinned-left-last]="isRowReorderableLastPinned()" style="left:0px; text-align:center; width:44px">
1931
+ <span
1932
+ class="row-drag-handle"
1933
+ draggable="true"
1934
+ (dragstart)="onRowDragStart($event, i)"
1935
+ (dragend)="onRowDragEnd()"
1936
+ >⋮⋮</span>
1937
+ </td>
1938
+ }
1939
+
535
1940
  @if (showDetailToggle()) {
536
- <td class="grid-td grid-td-toggle">
1941
+ <td class="grid-td grid-td-toggle pinned-left" [class.pinned-left-last]="isDetailToggleLastPinned()" [style.left.px]="rowReorderable() ? 44 : 0">
537
1942
  <button class="toggle-btn" type="button" (click)="toggleDetail(row); $event.stopPropagation()">
538
1943
  {{ isExpanded(row) ? '▾' : '▸' }}
539
1944
  </button>
@@ -541,13 +1946,13 @@ class DataGridComponent {
541
1946
  }
542
1947
 
543
1948
  @if (selectable()) {
544
- <td class="grid-td grid-td-check">
1949
+ <td class="grid-td grid-td-check pinned-left" [class.pinned-left-last]="isSelectableLastPinned()" [style.left.px]="(rowReorderable() ? 44 : 0) + (showDetailToggle() ? 44 : 0)">
545
1950
  <input type="checkbox" [checked]="isRowSelected(row)" (change)="toggleRow(row)" (click)="$event.stopPropagation()" />
546
1951
  </td>
547
1952
  }
548
1953
 
549
1954
  @if (rowTemplate()) {
550
- <td class="grid-td" [attr.colspan]="columns().length + (editable() ? 1 : 0)">
1955
+ <td class="grid-td" [attr.colspan]="orderedColumns().length + (editable() ? 1 : 0)">
551
1956
  <ng-container *ngTemplateOutlet="rowTemplate(); context: {
552
1957
  $implicit: row,
553
1958
  row: row,
@@ -557,32 +1962,75 @@ class DataGridComponent {
557
1962
  }" />
558
1963
  </td>
559
1964
  } @else {
560
- @for (col of columns(); track col.field) {
561
- <td class="grid-td" [style.text-align]="col.align ?? 'left'">
562
- @if (isEditing(row) && editable() && col.editable) {
563
- <input
564
- class="grid-edit-input"
565
- [value]="toStringSafe(getDraftValue(row, col.field))"
566
- (input)="updateDraft(col.field, $any($event.target).value)"
567
- (click)="$event.stopPropagation()"
568
- />
569
- } @else if (resolveCellTemplate(col)) {
570
- <ng-container *ngTemplateOutlet="resolveCellTemplate(col)!; context: {
571
- $implicit: getCellValue(row, col.field),
572
- value: getCellValue(row, col.field),
573
- row: row,
574
- column: col,
575
- index: i,
576
- editing: isEditing(row)
577
- }" />
578
- } @else {
579
- {{ getCellValue(row, col.field) }}
580
- }
581
- </td>
1965
+ @for (col of orderedColumns(); track col.field) {
1966
+ @if (getCellRowSpan(row, col.field, i, group.items) > 0) {
1967
+ <td
1968
+ class="grid-td"
1969
+ [attr.rowspan]="getCellRowSpan(row, col.field, i, group.items)"
1970
+ [class.pinned-left]="col.pinned === 'left'"
1971
+ [class.pinned-left-last]="col.pinned === 'left' && lastPinnedColumnField() === col.field"
1972
+ [class.pinned-right]="col.pinned === 'right'"
1973
+ [class.pinned-right-first]="col.pinned === 'right' && firstPinnedRightColumnField() === col.field"
1974
+ [class.cell-focused]="focusedCell()?.row === row && focusedCell()?.colField === col.field"
1975
+ [class.cell-focused-editing]="focusedCell()?.row === row && focusedCell()?.colField === col.field && focusedCellEditActive()"
1976
+ [style.left.px]="col.pinned === 'left' ? columnOffsets()[col.field] : null"
1977
+ [style.right.px]="col.pinned === 'right' ? columnRightOffsets()[col.field] : null"
1978
+ [style.text-align]="col.align ?? 'left'"
1979
+ [style.width.px]="getColumnWidth(col)"
1980
+ [class.cell-selected]="isCellSelected(row, col.field)"
1981
+ (mousedown)="onCellMouseDown($event, row, col.field)"
1982
+ (mouseenter)="onCellMouseEnter(row, col.field)"
1983
+ (contextmenu)="onCellContextMenu($event, row, col.field)"
1984
+ (click)="onCellClick(row, col.field)"
1985
+ >
1986
+ @if (isEditing(row) && editable() && col.editable) {
1987
+ @if (resolveEditCellTemplate(col); as activeEditTemplate) {
1988
+ <ng-container *ngTemplateOutlet="activeEditTemplate; context: {
1989
+ $implicit: getDraftValue(row, col.field),
1990
+ value: getCellValue(row, col.field),
1991
+ row: row,
1992
+ column: col,
1993
+ index: i,
1994
+ editing: true,
1995
+ draftValue: getDraftValue(row, col.field),
1996
+ updateDraft: getUpdateDraftCallback(col.field)
1997
+ }" />
1998
+ } @else {
1999
+ <input
2000
+ class="grid-edit-input"
2001
+ [value]="toStringSafe(getDraftValue(row, col.field))"
2002
+ (input)="updateDraft(col.field, $any($event.target).value)"
2003
+ (click)="$event.stopPropagation()"
2004
+ />
2005
+ }
2006
+ } @else if (resolveCellTemplate(col)) {
2007
+ <ng-container *ngTemplateOutlet="resolveCellTemplate(col)!; context: {
2008
+ $implicit: getCellValue(row, col.field),
2009
+ value: getCellValue(row, col.field),
2010
+ row: row,
2011
+ column: col,
2012
+ index: i,
2013
+ editing: isEditing(row)
2014
+ }" />
2015
+ } @else {
2016
+ @if (showGlobalSearch() && searchText()) {
2017
+ <span [innerHTML]="highlightSearchText(getCellValue(row, col.field))"></span>
2018
+ } @else {
2019
+ {{ getCellValue(row, col.field) }}
2020
+ }
2021
+ }
2022
+ </td>
2023
+ }
582
2024
  }
583
2025
 
584
2026
  @if (editable()) {
585
- <td class="grid-td grid-actions">
2027
+ <td
2028
+ class="grid-td grid-actions"
2029
+ [class.pinned-right]="firstPinnedRightColumnField() !== null"
2030
+ [class.pinned-right-first]="firstPinnedRightColumnField() === null"
2031
+ [style.right.px]="firstPinnedRightColumnField() !== null ? 0 : null"
2032
+ style="width:120px"
2033
+ >
586
2034
  @if (!isEditing(row)) {
587
2035
  <button class="action-btn" type="button" (click)="beginEdit(row, i); $event.stopPropagation()">Edit</button>
588
2036
  } @else {
@@ -613,11 +2061,27 @@ class DataGridComponent {
613
2061
  <tr
614
2062
  class="grid-row"
615
2063
  [class.selected]="isRowSelected(row)"
2064
+ [class.dragging-row]="draggingRowIndex() === i"
2065
+ [class.drag-over-row]="dragOverRowIndex() === i"
2066
+ (dragover)="onRowDragOver($event, i)"
2067
+ (drop)="onRowDrop($event, i)"
2068
+ (dragend)="onRowDragEnd()"
616
2069
  (click)="onRowClick(row, i)"
617
2070
  (dblclick)="editable() ? beginEdit(row, i) : null"
618
2071
  >
2072
+ @if (rowReorderable()) {
2073
+ <td class="grid-td grid-td-reorder pinned-left" [class.pinned-left-last]="isRowReorderableLastPinned()" style="left:0px; text-align:center; width:44px">
2074
+ <span
2075
+ class="row-drag-handle"
2076
+ draggable="true"
2077
+ (dragstart)="onRowDragStart($event, i)"
2078
+ (dragend)="onRowDragEnd()"
2079
+ >⋮⋮</span>
2080
+ </td>
2081
+ }
2082
+
619
2083
  @if (showDetailToggle()) {
620
- <td class="grid-td grid-td-toggle">
2084
+ <td class="grid-td grid-td-toggle pinned-left" [class.pinned-left-last]="isDetailToggleLastPinned()" [style.left.px]="rowReorderable() ? 44 : 0">
621
2085
  <button class="toggle-btn" type="button" (click)="toggleDetail(row); $event.stopPropagation()">
622
2086
  {{ isExpanded(row) ? '▾' : '▸' }}
623
2087
  </button>
@@ -625,13 +2089,13 @@ class DataGridComponent {
625
2089
  }
626
2090
 
627
2091
  @if (selectable()) {
628
- <td class="grid-td grid-td-check">
2092
+ <td class="grid-td grid-td-check pinned-left" [class.pinned-left-last]="isSelectableLastPinned()" [style.left.px]="(rowReorderable() ? 44 : 0) + (showDetailToggle() ? 44 : 0)">
629
2093
  <input type="checkbox" [checked]="isRowSelected(row)" (change)="toggleRow(row)" (click)="$event.stopPropagation()" />
630
2094
  </td>
631
2095
  }
632
2096
 
633
2097
  @if (rowTemplate()) {
634
- <td class="grid-td" [attr.colspan]="columns().length + (editable() ? 1 : 0)">
2098
+ <td class="grid-td" [attr.colspan]="orderedColumns().length + (editable() ? 1 : 0)">
635
2099
  <ng-container *ngTemplateOutlet="rowTemplate(); context: {
636
2100
  $implicit: row,
637
2101
  row: row,
@@ -641,32 +2105,75 @@ class DataGridComponent {
641
2105
  }" />
642
2106
  </td>
643
2107
  } @else {
644
- @for (col of columns(); track col.field) {
645
- <td class="grid-td" [style.text-align]="col.align ?? 'left'">
646
- @if (isEditing(row) && editable() && col.editable) {
647
- <input
648
- class="grid-edit-input"
649
- [value]="toStringSafe(getDraftValue(row, col.field))"
650
- (input)="updateDraft(col.field, $any($event.target).value)"
651
- (click)="$event.stopPropagation()"
652
- />
653
- } @else if (resolveCellTemplate(col)) {
654
- <ng-container *ngTemplateOutlet="resolveCellTemplate(col)!; context: {
655
- $implicit: getCellValue(row, col.field),
656
- value: getCellValue(row, col.field),
657
- row: row,
658
- column: col,
659
- index: i,
660
- editing: isEditing(row)
661
- }" />
662
- } @else {
663
- {{ getCellValue(row, col.field) }}
664
- }
665
- </td>
2108
+ @for (col of orderedColumns(); track col.field) {
2109
+ @if (getCellRowSpan(row, col.field, i) > 0) {
2110
+ <td
2111
+ class="grid-td"
2112
+ [attr.rowspan]="getCellRowSpan(row, col.field, i)"
2113
+ [class.pinned-left]="col.pinned === 'left'"
2114
+ [class.pinned-left-last]="col.pinned === 'left' && lastPinnedColumnField() === col.field"
2115
+ [class.pinned-right]="col.pinned === 'right'"
2116
+ [class.pinned-right-first]="col.pinned === 'right' && firstPinnedRightColumnField() === col.field"
2117
+ [class.cell-focused]="focusedCell()?.row === row && focusedCell()?.colField === col.field"
2118
+ [class.cell-focused-editing]="focusedCell()?.row === row && focusedCell()?.colField === col.field && focusedCellEditActive()"
2119
+ [style.left.px]="col.pinned === 'left' ? columnOffsets()[col.field] : null"
2120
+ [style.right.px]="col.pinned === 'right' ? columnRightOffsets()[col.field] : null"
2121
+ [style.text-align]="col.align ?? 'left'"
2122
+ [style.width.px]="getColumnWidth(col)"
2123
+ [class.cell-selected]="isCellSelected(row, col.field)"
2124
+ (mousedown)="onCellMouseDown($event, row, col.field)"
2125
+ (mouseenter)="onCellMouseEnter(row, col.field)"
2126
+ (contextmenu)="onCellContextMenu($event, row, col.field)"
2127
+ (click)="onCellClick(row, col.field)"
2128
+ >
2129
+ @if (isEditing(row) && editable() && col.editable) {
2130
+ @if (resolveEditCellTemplate(col); as activeEditTemplate) {
2131
+ <ng-container *ngTemplateOutlet="activeEditTemplate; context: {
2132
+ $implicit: getDraftValue(row, col.field),
2133
+ value: getCellValue(row, col.field),
2134
+ row: row,
2135
+ column: col,
2136
+ index: i,
2137
+ editing: true,
2138
+ draftValue: getDraftValue(row, col.field),
2139
+ updateDraft: getUpdateDraftCallback(col.field)
2140
+ }" />
2141
+ } @else {
2142
+ <input
2143
+ class="grid-edit-input"
2144
+ [value]="toStringSafe(getDraftValue(row, col.field))"
2145
+ (input)="updateDraft(col.field, $any($event.target).value)"
2146
+ (click)="$event.stopPropagation()"
2147
+ />
2148
+ }
2149
+ } @else if (resolveCellTemplate(col)) {
2150
+ <ng-container *ngTemplateOutlet="resolveCellTemplate(col)!; context: {
2151
+ $implicit: getCellValue(row, col.field),
2152
+ value: getCellValue(row, col.field),
2153
+ row: row,
2154
+ column: col,
2155
+ index: i,
2156
+ editing: isEditing(row)
2157
+ }" />
2158
+ } @else {
2159
+ @if (showGlobalSearch() && searchText()) {
2160
+ <span [innerHTML]="highlightSearchText(getCellValue(row, col.field))"></span>
2161
+ } @else {
2162
+ {{ getCellValue(row, col.field) }}
2163
+ }
2164
+ }
2165
+ </td>
2166
+ }
666
2167
  }
667
2168
 
668
2169
  @if (editable()) {
669
- <td class="grid-td grid-actions">
2170
+ <td
2171
+ class="grid-td grid-actions"
2172
+ [class.pinned-right]="firstPinnedRightColumnField() !== null"
2173
+ [class.pinned-right-first]="firstPinnedRightColumnField() === null"
2174
+ [style.right.px]="firstPinnedRightColumnField() !== null ? 0 : null"
2175
+ style="width:120px"
2176
+ >
670
2177
  @if (!isEditing(row)) {
671
2178
  <button class="action-btn" type="button" (click)="beginEdit(row, i); $event.stopPropagation()">Edit</button>
672
2179
  } @else {
@@ -692,6 +2199,50 @@ class DataGridComponent {
692
2199
  }
693
2200
  }
694
2201
  </tbody>
2202
+ @if (hasAggregation()) {
2203
+ <tfoot>
2204
+ <tr class="grid-footer-row">
2205
+ @if (showDetailToggle()) {
2206
+ <td class="grid-td-toggle pinned-left" [class.pinned-left-last]="isDetailToggleLastPinned()" style="left:0px; width:44px"></td>
2207
+ }
2208
+ @if (selectable()) {
2209
+ <td class="grid-td-check pinned-left" [class.pinned-left-last]="isSelectableLastPinned()" [style.left.px]="showDetailToggle() ? 44 : 0" style="width:44px"></td>
2210
+ }
2211
+ @for (col of orderedColumns(); track col.field) {
2212
+ <td
2213
+ class="grid-td grid-footer-cell"
2214
+ [class.pinned-left]="col.pinned === 'left'"
2215
+ [class.pinned-left-last]="col.pinned === 'left' && lastPinnedColumnField() === col.field"
2216
+ [class.pinned-right]="col.pinned === 'right'"
2217
+ [class.pinned-right-first]="col.pinned === 'right' && firstPinnedRightColumnField() === col.field"
2218
+ [style.left.px]="col.pinned === 'left' ? columnOffsets()[col.field] : null"
2219
+ [style.right.px]="col.pinned === 'right' ? columnRightOffsets()[col.field] : null"
2220
+ [style.text-align]="col.align ?? 'left'"
2221
+ [style.width.px]="getColumnWidth(col)"
2222
+ >
2223
+ @if (resolveFooterTemplate(col); as activeFooterTemplate) {
2224
+ <ng-container *ngTemplateOutlet="activeFooterTemplate; context: {
2225
+ $implicit: col,
2226
+ column: col,
2227
+ aggregationValue: getAggregationValue(col),
2228
+ data: flatRenderedRows()
2229
+ }" />
2230
+ } @else if (col.aggregation) {
2231
+ <span class="agg-label">{{ col.aggregation }}: </span>
2232
+ <strong class="agg-value">{{ getAggregationValue(col) }}</strong>
2233
+ }
2234
+ </td>
2235
+ }
2236
+ @if (editable()) {
2237
+ <td
2238
+ [class.pinned-right]="firstPinnedRightColumnField() !== null"
2239
+ [class.pinned-right-first]="firstPinnedRightColumnField() === null"
2240
+ [style.right.px]="firstPinnedRightColumnField() !== null ? 0 : null"
2241
+ ></td>
2242
+ }
2243
+ </tr>
2244
+ </tfoot>
2245
+ }
695
2246
  </table>
696
2247
  </div>
697
2248
 
@@ -711,85 +2262,285 @@ class DataGridComponent {
711
2262
  </div>
712
2263
  </div>
713
2264
  }
2265
+
2266
+ <!-- Excel-Style Filter Popover Overlay -->
2267
+ @if (activeFilterPopover(); as pop) {
2268
+ <div class="grid-filter-popover" [style.top.px]="pop.top" [style.left.px]="pop.left" (click)="$event.stopPropagation()">
2269
+ <div class="popover-section text-filter-section">
2270
+ <label class="popover-label">Text Filter</label>
2271
+ <div class="text-filter-row">
2272
+ <select class="popover-select" [value]="tempFilterOperator()" (change)="tempFilterOperator.set($any($event.target).value)">
2273
+ <option value="contains">Contains</option>
2274
+ <option value="eq">Equals</option>
2275
+ <option value="startsWith">Starts With</option>
2276
+ <option value="endsWith">Ends With</option>
2277
+ </select>
2278
+ <input class="popover-input" type="text" [value]="tempFilterValue()" (input)="tempFilterValue.set($any($event.target).value)" placeholder="Filter value..." />
2279
+ </div>
2280
+ </div>
2281
+
2282
+ <div class="popover-section checklist-section">
2283
+ <label class="popover-label">Checklist Filter</label>
2284
+ <div class="checklist-actions">
2285
+ <label class="checklist-item select-all">
2286
+ <input type="checkbox" [checked]="tempSelectedValues().size === getDistinctValues(pop.field).length" [indeterminate]="tempSelectedValues().size > 0 && tempSelectedValues().size < getDistinctValues(pop.field).length" (change)="toggleSelectAllChecklist()" />
2287
+ <span>(Select All)</span>
2288
+ </label>
2289
+ </div>
2290
+ <div class="checklist-scroll">
2291
+ @for (val of getDistinctValues(pop.field); track val) {
2292
+ <label class="checklist-item">
2293
+ <input type="checkbox" [checked]="tempSelectedValues().has(val)" (change)="toggleChecklistItem(val)" />
2294
+ <span>{{ val }}</span>
2295
+ </label>
2296
+ }
2297
+ </div>
2298
+ </div>
2299
+
2300
+ <div class="popover-footer">
2301
+ <button class="popover-btn clear" (click)="clearPopoverFilter()">Clear</button>
2302
+ <div class="footer-actions">
2303
+ <button class="popover-btn cancel" (click)="activeFilterPopover.set(null)">Cancel</button>
2304
+ <button class="popover-btn apply" (click)="applyPopoverFilter()">Apply</button>
2305
+ </div>
2306
+ </div>
2307
+ </div>
2308
+ }
2309
+
2310
+ <!-- Column Chooser Popover Overlay -->
2311
+ @if (activeColumnChooserPopover(); as pop) {
2312
+ <div class="grid-column-chooser-popover" [style.top.px]="pop.top" [style.left.px]="pop.left" (click)="$event.stopPropagation()">
2313
+ <div class="popover-section checklist-section" style="border-top: none; padding-top: 0;">
2314
+ <label class="popover-label">Visible Columns</label>
2315
+ <div class="checklist-scroll">
2316
+ @for (col of columns(); track col.field) {
2317
+ <label class="checklist-item">
2318
+ <input type="checkbox" [checked]="!hiddenColumns().has(col.field)" (change)="toggleColumnVisibility(col.field)" />
2319
+ <span>{{ col.title }}</span>
2320
+ </label>
2321
+ }
2322
+ </div>
2323
+ </div>
2324
+ <div class="popover-footer">
2325
+ <button class="popover-btn apply" (click)="activeColumnChooserPopover.set(null)">Close</button>
2326
+ </div>
2327
+ </div>
2328
+ }
2329
+
2330
+ <!-- Custom Context Menu Overlay -->
2331
+ @if (activeContextMenu(); as menu) {
2332
+ <div class="grid-context-menu" [style.top.px]="menu.y" [style.left.px]="menu.x" (click)="$event.stopPropagation()">
2333
+ <button class="menu-item" [disabled]="!selectedCellStart()" (click)="contextMenuCopy()">
2334
+ <span class="menu-icon">📋</span> Copy Selection
2335
+ </button>
2336
+ <div class="menu-divider"></div>
2337
+ <button class="menu-item" (click)="contextMenuTogglePin(menu.colField)">
2338
+ <span class="menu-icon">📌</span> {{ isColumnPinned(menu.colField) ? 'Unpin Column' : 'Pin Column Left' }}
2339
+ </button>
2340
+ <button class="menu-item" (click)="contextMenuHideColumn(menu.colField)">
2341
+ <span class="menu-icon">👁️</span> Hide Column
2342
+ </button>
2343
+ <div class="menu-divider"></div>
2344
+ <button class="menu-item" [disabled]="filterStates().size === 0" (click)="contextMenuClearFilters()">
2345
+ <span class="menu-icon">🧹</span> Clear All Filters
2346
+ </button>
2347
+ <div class="menu-divider"></div>
2348
+ <button class="menu-item" (click)="exportToJson(); activeContextMenu.set(null)">
2349
+ <span class="menu-icon">📄</span> Export to JSON
2350
+ </button>
2351
+ <button class="menu-item" (click)="exportToCsv(); activeContextMenu.set(null)">
2352
+ <span class="menu-icon">📊</span> Export to CSV
2353
+ </button>
2354
+ </div>
2355
+ }
714
2356
  </div>
715
- `, isInline: true, styles: [":host{display:block}.ngx-data-grid{font-family:inherit;border:1px solid var(--ngx-grid-border, #e2e8f0);border-radius:var(--ngx-grid-radius, 12px);overflow:hidden;background:var(--ngx-grid-bg, #ffffff);box-shadow:0 4px 6px -1px #0000000d,0 2px 4px -2px #0000000d;transition:background-color .3s,border-color .3s,box-shadow .3s}.grid-toolbar{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;background:var(--ngx-grid-header-bg, #f8fafc);border-bottom:1px solid var(--ngx-grid-border, #e2e8f0);flex-wrap:wrap;gap:12px}.grid-toolbar-title{font-family:var(--ngx-heading-font-family, \"Outfit\", sans-serif);font-weight:700;font-size:14px;color:var(--ngx-grid-text, #0f172a)}.grid-toolbar-actions{display:flex;gap:6px}.grid-action-btn{padding:6px 14px;border:1px solid var(--ngx-grid-border, #e2e8f0);border-radius:8px;background:var(--ngx-grid-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);font-size:12px;font-weight:500;cursor:pointer;font-family:inherit;transition:all .2s cubic-bezier(.4,0,.2,1);outline:none}.grid-action-btn:hover{background:var(--ngx-grid-hover-bg, #f1f5f9);border-color:var(--ngx-input-border, #cbd5e1);transform:translateY(-.5px)}.grid-action-btn:active{transform:scale(.97)}.grid-filter-bar{display:flex;gap:8px;padding:10px 16px;background:var(--ngx-grid-header-bg, #f8fafc);border-bottom:1px solid var(--ngx-grid-border, #e2e8f0)}.grid-filter-input{padding:6px 12px;border:1px solid var(--ngx-grid-border, #cbd5e1);border-radius:8px;font-size:12px;outline:none;font-family:inherit;background:var(--ngx-input-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);transition:border-color .2s,box-shadow .2s}.grid-filter-input:focus{border-color:var(--ngx-input-focus, #4f46e5);box-shadow:0 0 0 3px var(--primary-glow, rgba(79, 70, 229, .15))}.grid-filter-spacer{flex-shrink:0}.grid-table-wrap{overflow-x:auto}.grid-table{width:100%;border-collapse:collapse;font-size:13px}.grid-th{padding:12px 16px;text-align:left;font-size:11px;font-weight:700;color:var(--ngx-grid-text-secondary, #64748b);background:var(--ngx-grid-header-bg, #f8fafc);border-bottom:2px solid var(--ngx-grid-border, #e2e8f0);white-space:nowrap;-webkit-user-select:none;user-select:none;text-transform:uppercase;letter-spacing:.05em;font-family:var(--ngx-heading-font-family, \"Outfit\", sans-serif)}.grid-th.sortable{cursor:pointer;transition:background-color .2s}.grid-th.sortable:hover{background:var(--ngx-grid-hover-bg, #f1f5f9)}.grid-th.sort-asc,.grid-th.sort-desc{color:var(--ngx-input-focus, #4f46e5)}.th-text{margin-right:4px}.sort-icon{font-size:10px;color:#cbd5e1}.sort-asc .sort-icon,.sort-desc .sort-icon{color:var(--ngx-input-focus, #4f46e5)}.grid-group-row td{background:var(--ngx-grid-header-bg, #f8fafc);border-bottom:1.5px solid var(--ngx-grid-border, #e2e8f0);color:var(--ngx-grid-text, #0f172a);font-size:12px;font-weight:600;padding:11px 16px;cursor:pointer}.group-toggle{border:none;background:transparent;margin-right:6px;cursor:pointer;color:var(--ngx-grid-text-secondary, #64748b);font-size:12px}.group-count{color:var(--ngx-grid-text-secondary, #64748b);margin-left:6px;font-weight:500}.grid-row{border-bottom:1px solid var(--ngx-grid-border, #e2e8f0);transition:background-color .15s}.grid-row:hover{background:var(--ngx-grid-hover-bg, #f1f5f9)}.grid-row.selected{background:var(--ngx-grid-selected-bg, #e0e7ff)!important}.grid-table.striped .grid-row:nth-child(2n){background:var(--ngx-grid-stripe-bg, #f8fafc)}.grid-table.striped .grid-row:nth-child(2n):hover{background:var(--ngx-grid-hover-bg, #f1f5f9)}.grid-table.striped .grid-row.selected{background:var(--ngx-grid-selected-bg, #e0e7ff)!important}.grid-td{padding:11px 16px;color:var(--ngx-grid-text, #0f172a);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;vertical-align:middle}.grid-th-check,.grid-td-check,.grid-th-toggle,.grid-td-toggle{width:44px!important;text-align:center}.toggle-btn{border:none;background:transparent;color:var(--ngx-grid-text-secondary, #64748b);cursor:pointer;font-size:13px;transition:color .15s}.toggle-btn:hover{color:var(--ngx-grid-text, #0f172a)}.grid-detail-row td{background:var(--ngx-grid-stripe-bg, #f8fafc);border-bottom:1px solid var(--ngx-grid-border, #e2e8f0)}.grid-detail-cell{padding:16px 24px;white-space:normal}.grid-edit-input{width:100%;min-width:80px;padding:6px 10px;border:1px solid var(--ngx-grid-border, #cbd5e1);border-radius:6px;font-size:12px;font-family:inherit;background:var(--ngx-input-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);box-sizing:border-box;outline:none;transition:border-color .2s,box-shadow .2s}.grid-edit-input:focus{border-color:var(--ngx-input-focus, #4f46e5);box-shadow:0 0 0 3px var(--primary-glow, rgba(79, 70, 229, .15))}.grid-actions{white-space:nowrap}.action-btn{border:1px solid var(--ngx-grid-border, #cbd5e1);background:var(--ngx-grid-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);border-radius:6px;padding:5px 10px;font-size:12px;font-weight:500;margin-right:6px;cursor:pointer;transition:all .2s;outline:none}.action-btn:hover{background:var(--ngx-grid-hover-bg, #f1f5f9);border-color:var(--ngx-input-border, #cbd5e1)}.action-btn.save{border-color:var(--ngx-btn-primary-bg, #4f46e5);background:var(--ngx-btn-primary-bg, #4f46e5);color:#fff}.action-btn.save:hover{background:var(--ngx-btn-primary-hover, #4338ca);border-color:var(--ngx-btn-primary-hover, #4338ca)}.action-btn:last-child{margin-right:0}.grid-loading-cell,.grid-empty-cell{padding:48px;text-align:center;color:var(--ngx-grid-text-secondary, #64748b);font-weight:500}.grid-spinner{width:28px;height:28px;border:3.5px solid var(--ngx-grid-border, #e2e8f0);border-top-color:var(--ngx-btn-primary-bg, #4f46e5);border-radius:50%;animation:spin .8s cubic-bezier(.4,0,.2,1) infinite;margin:0 auto}@keyframes spin{to{transform:rotate(360deg)}}.grid-pagination{display:flex;align-items:center;justify-content:space-between;padding:10px 16px;border-top:1px solid var(--ngx-grid-border, #e2e8f0);background:var(--ngx-grid-bg, #ffffff);flex-wrap:wrap;gap:8px}.page-info{font-size:12px;color:var(--ngx-grid-text-secondary, #64748b);font-weight:500}.page-btns{display:flex;gap:4px}.page-btn{min-width:32px;height:32px;padding:0 8px;font-size:12px;font-weight:500;border:1px solid var(--ngx-grid-border, #e2e8f0);background:var(--ngx-grid-bg, #ffffff);border-radius:8px;cursor:pointer;font-family:inherit;color:var(--ngx-grid-text, #0f172a);transition:all .2s;outline:none}.page-btn:hover:not(:disabled){background:var(--ngx-grid-hover-bg, #f1f5f9);border-color:var(--ngx-input-border, #cbd5e1)}.page-btn.active{background:var(--ngx-btn-primary-bg, #4f46e5);color:#fff;border-color:var(--ngx-btn-primary-bg, #4f46e5);box-shadow:0 2px 4px #4f46e533}.page-btn:disabled{opacity:.4;cursor:not-allowed}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2357
+ `, isInline: true, styles: [":host{display:block}.ngx-data-grid{position:relative;font-family:inherit;border:1px solid var(--ngx-grid-border, #e2e8f0);border-radius:var(--ngx-grid-radius, 12px);overflow:visible;background:var(--ngx-grid-bg, #ffffff);box-shadow:0 4px 6px -1px #0000000d,0 2px 4px -2px #0000000d;transition:background-color .3s,border-color .3s,box-shadow .3s}.grid-toolbar{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;background:var(--ngx-grid-header-bg, #f8fafc);border-bottom:1px solid var(--ngx-grid-border, #e2e8f0);border-radius:var(--ngx-grid-radius, 12px) var(--ngx-grid-radius, 12px) 0 0;flex-wrap:wrap;gap:12px}.grid-toolbar-title{font-family:var(--ngx-heading-font-family, \"Outfit\", sans-serif);font-weight:700;font-size:14px;color:var(--ngx-grid-text, #0f172a)}.grid-toolbar-actions{display:flex;gap:6px}.grid-action-btn{padding:6px 14px;border:1px solid var(--ngx-grid-border, #e2e8f0);border-radius:8px;background:var(--ngx-grid-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);font-size:12px;font-weight:500;cursor:pointer;font-family:inherit;transition:all .2s cubic-bezier(.4,0,.2,1);outline:none}.grid-action-btn:hover{background:var(--ngx-grid-hover-bg, #f1f5f9);border-color:var(--ngx-input-border, #cbd5e1);transform:translateY(-.5px)}.grid-action-btn:active{transform:scale(.97)}.grid-table-wrap{overflow-x:auto;overflow-y:hidden}.grid-table{width:100%;border-collapse:collapse;font-size:13px;table-layout:fixed}.grid-th{position:relative;padding:12px 16px;text-align:left;font-size:11px;font-weight:700;color:var(--ngx-grid-text-secondary, #64748b);background:var(--ngx-grid-header-bg, #f8fafc);border-bottom:2px solid var(--ngx-grid-border, #e2e8f0);white-space:nowrap;-webkit-user-select:none;user-select:none;text-transform:uppercase;letter-spacing:.05em;font-family:var(--ngx-heading-font-family, \"Outfit\", sans-serif)}.grid-category-th{text-align:center;border-bottom:1px solid var(--ngx-grid-border, #e2e8f0);border-right:1px solid var(--ngx-grid-border, #e2e8f0)}.sub-header-row .grid-th{border-bottom:2px solid var(--ngx-grid-border, #e2e8f0);border-right:1px solid var(--ngx-grid-border, #f1f5f9)}.grid-th.sortable{cursor:pointer;transition:background-color .2s}.grid-th.sortable:hover{background:var(--ngx-grid-hover-bg, #f1f5f9)}.grid-th.sort-asc,.grid-th.sort-desc{color:var(--ngx-input-focus, #4f46e5)}.th-text{margin-right:4px}.sort-icon{font-size:10px;color:#cbd5e1}.sort-asc .sort-icon,.sort-desc .sort-icon{color:var(--ngx-input-focus, #4f46e5)}.th-content-wrapper{display:flex;align-items:center;justify-content:space-between;gap:6px;width:100%}.grid-filter-btn{background:transparent;border:none;color:var(--ngx-grid-text-secondary, #64748b);cursor:pointer;padding:2px;border-radius:4px;display:flex;align-items:center;justify-content:center;transition:all .2s}.grid-filter-btn:hover{background:var(--ngx-grid-hover-bg, #e2e8f0);color:var(--ngx-grid-text, #0f172a)}.grid-filter-btn.active{color:var(--ngx-input-focus, #4f46e5);background:#4f46e51a}.grid-resize-handle{position:absolute;right:0;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background-color .2s}.grid-resize-handle:hover,.grid-resize-handle.resizing{background:var(--ngx-input-focus, #4f46e5)}.grid-filter-popover,.grid-column-chooser-popover{position:absolute;width:250px;background:var(--ngx-grid-bg, #ffffff);border:1px solid var(--ngx-grid-border, #e2e8f0);border-radius:12px;box-shadow:0 10px 25px -5px #0000001a,0 8px 10px -6px #0000001a;z-index:1000;padding:12px;box-sizing:border-box;display:flex;flex-direction:column;gap:12px;font-family:inherit}.popover-section{display:flex;flex-direction:column;gap:6px}.popover-label{font-size:11px;font-weight:700;color:var(--ngx-grid-text-secondary, #64748b);text-transform:uppercase;letter-spacing:.05em}.text-filter-row{display:flex;flex-direction:column;gap:6px}.popover-select{padding:6px;border:1px solid var(--ngx-grid-border, #cbd5e1);border-radius:6px;font-size:12px;font-family:inherit;outline:none;background:var(--ngx-input-bg, #ffffff);color:var(--ngx-grid-text, #0f172a)}.popover-input{padding:6px 10px;border:1px solid var(--ngx-grid-border, #cbd5e1);border-radius:6px;font-size:12px;font-family:inherit;outline:none;background:var(--ngx-input-bg, #ffffff);color:var(--ngx-grid-text, #0f172a)}.checklist-section{border-top:1px solid var(--ngx-grid-border, #e2e8f0);padding-top:10px}.checklist-scroll{max-height:120px;overflow-y:auto;display:flex;flex-direction:column;gap:4px;border:1px solid var(--ngx-grid-border, #e2e8f0);border-radius:6px;padding:6px}.checklist-item{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--ngx-grid-text, #0f172a);cursor:pointer;-webkit-user-select:none;user-select:none}.checklist-item input{margin:0}.popover-footer{display:flex;justify-content:space-between;align-items:center;border-top:1px solid var(--ngx-grid-border, #e2e8f0);padding-top:10px;margin-top:4px}.footer-actions{display:flex;gap:6px}.popover-btn{padding:5px 10px;font-size:11px;font-weight:600;border-radius:6px;cursor:pointer;border:1px solid var(--ngx-grid-border, #cbd5e1);background:var(--ngx-grid-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);transition:all .2s}.popover-btn:hover{background:var(--ngx-grid-hover-bg, #f1f5f9)}.popover-btn.apply{background:var(--ngx-btn-primary-bg, #4f46e5);color:#fff;border-color:var(--ngx-btn-primary-bg, #4f46e5)}.popover-btn.apply:hover{background:var(--ngx-btn-primary-hover, #4338ca);border-color:var(--ngx-btn-primary-hover, #4338ca)}.popover-btn.clear{color:#ef4444;border-color:transparent;background:transparent}.popover-btn.clear:hover{background:#fef2f2}.grid-group-row td{background:var(--ngx-grid-header-bg, #f8fafc);border-bottom:1.5px solid var(--ngx-grid-border, #e2e8f0);color:var(--ngx-grid-text, #0f172a);font-size:12px;font-weight:600;padding:11px 16px;cursor:pointer}.group-toggle{border:none;background:transparent;margin-right:6px;cursor:pointer;color:var(--ngx-grid-text-secondary, #64748b);font-size:12px}.group-count{color:var(--ngx-grid-text-secondary, #64748b);margin-left:6px;font-weight:500}.grid-row{border-bottom:1px solid var(--ngx-grid-border, #e2e8f0);transition:background-color .15s}.grid-row:hover{background:var(--ngx-grid-hover-bg, #f1f5f9)}.grid-row.selected{background:var(--ngx-grid-selected-bg, #e0e7ff)!important}.grid-table.striped .grid-row:nth-child(2n){background:var(--ngx-grid-stripe-bg, #f8fafc)}.grid-table.striped .grid-row:nth-child(2n):hover{background:var(--ngx-grid-hover-bg, #f1f5f9)}.grid-table.striped .grid-row.selected{background:var(--ngx-grid-selected-bg, #e0e7ff)!important}.grid-td{padding:11px 16px;color:var(--ngx-grid-text, #0f172a);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;vertical-align:middle;box-sizing:border-box}.grid-th-check,.grid-td-check,.grid-th-toggle,.grid-td-toggle{width:44px!important;text-align:center}.toggle-btn{border:none;background:transparent;color:var(--ngx-grid-text-secondary, #64748b);cursor:pointer;font-size:13px;transition:color .15s}.toggle-btn:hover{color:var(--ngx-grid-text, #0f172a)}.grid-detail-row td{background:var(--ngx-grid-stripe-bg, #f8fafc);border-bottom:1px solid var(--ngx-grid-border, #e2e8f0)}.grid-detail-cell{padding:16px 24px;white-space:normal}.grid-edit-input{width:100%;min-width:80px;padding:6px 10px;border:1px solid var(--ngx-grid-border, #cbd5e1);border-radius:6px;font-size:12px;font-family:inherit;background:var(--ngx-input-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);box-sizing:border-box;outline:none;transition:border-color .2s,box-shadow .2s}.grid-edit-input:focus{border-color:var(--ngx-input-focus, #4f46e5);box-shadow:0 0 0 3px var(--primary-glow, rgba(79, 70, 229, .15))}.grid-actions{white-space:nowrap}.action-btn{border:1px solid var(--ngx-grid-border, #cbd5e1);background:var(--ngx-grid-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);border-radius:6px;padding:5px 10px;font-size:12px;font-weight:500;margin-right:6px;cursor:pointer;transition:all .2s;outline:none}.action-btn:hover{background:var(--ngx-grid-hover-bg, #f1f5f9);border-color:var(--ngx-input-border, #cbd5e1)}.action-btn.save{border-color:var(--ngx-btn-primary-bg, #4f46e5);background:var(--ngx-btn-primary-bg, #4f46e5);color:#fff}.action-btn.save:hover{background:var(--ngx-btn-primary-hover, #4338ca);border-color:var(--ngx-btn-primary-hover, #4338ca)}.action-btn:last-child{margin-right:0}.grid-loading-cell,.grid-empty-cell{padding:48px;text-align:center;color:var(--ngx-grid-text-secondary, #64748b);font-weight:500}.grid-spinner{width:28px;height:28px;border:3.5px solid var(--ngx-grid-border, #e2e8f0);border-top-color:var(--ngx-btn-primary-bg, #4f46e5);border-radius:50%;animation:spin .8s cubic-bezier(.4,0,.2,1) infinite;margin:0 auto}@keyframes spin{to{transform:rotate(360deg)}}.grid-pagination{display:flex;align-items:center;justify-content:space-between;padding:10px 16px;border-top:1px solid var(--ngx-grid-border, #e2e8f0);background:var(--ngx-grid-bg, #ffffff);border-radius:0 0 var(--ngx-grid-radius, 12px) var(--ngx-grid-radius, 12px);flex-wrap:wrap;gap:8px}.page-info{font-size:12px;color:var(--ngx-grid-text-secondary, #64748b);font-weight:500}.page-btns{display:flex;gap:4px}.page-btn{min-width:32px;height:32px;padding:0 8px;font-size:12px;font-weight:500;border:1px solid var(--ngx-grid-border, #e2e8f0);background:var(--ngx-grid-bg, #ffffff);border-radius:8px;cursor:pointer;font-family:inherit;color:var(--ngx-grid-text, #0f172a);transition:all .2s;outline:none}.page-btn:hover:not(:disabled){background:var(--ngx-grid-hover-bg, #f1f5f9);border-color:var(--ngx-input-border, #cbd5e1)}.page-btn.active{background:var(--ngx-btn-primary-bg, #4f46e5);color:#fff;border-color:var(--ngx-btn-primary-bg, #4f46e5);box-shadow:0 2px 4px #4f46e533}.page-btn:disabled{opacity:.4;cursor:not-allowed}.grid-footer-row td{background:var(--ngx-grid-header-bg, #f8fafc);border-top:2px solid var(--ngx-grid-border, #e2e8f0);font-size:12px;padding:12px 16px;color:var(--ngx-grid-text, #0f172a)}.agg-label{font-size:10px;font-weight:700;color:var(--ngx-grid-text-secondary, #64748b);text-transform:uppercase;letter-spacing:.05em}.agg-value{font-weight:700;color:var(--ngx-input-focus, #4f46e5)}.pinned-left{position:sticky!important;z-index:2;background:var(--ngx-grid-bg, #ffffff)}th.pinned-left{z-index:4;background:var(--ngx-grid-header-bg, #f8fafc)}.sticky-toggle{position:sticky!important;left:0;z-index:3;background:var(--ngx-grid-bg, #ffffff)}th.sticky-toggle{z-index:5;background:var(--ngx-grid-header-bg, #f8fafc)}.sticky-check{position:sticky!important;z-index:3;background:var(--ngx-grid-bg, #ffffff)}th.sticky-check{z-index:5;background:var(--ngx-grid-header-bg, #f8fafc)}.pinned-left-last,.sticky-toggle-last,.sticky-check-last{border-right:1px solid var(--ngx-grid-border, #cbd5e1)!important;box-shadow:4px 0 8px -3px #00000026}.grid-table.striped .grid-row:nth-child(2n) .pinned-left,.grid-table.striped .grid-row:nth-child(2n) .sticky-toggle,.grid-table.striped .grid-row:nth-child(2n) .sticky-check{background:var(--ngx-grid-stripe-bg, #f8fafc)}.grid-row:hover .pinned-left,.grid-row:hover .sticky-toggle,.grid-row:hover .sticky-check{background:var(--ngx-grid-hover-bg, #f1f5f9)!important}.grid-row.selected .pinned-left,.grid-row.selected .sticky-toggle,.grid-row.selected .sticky-check{background:var(--ngx-grid-selected-bg, #e0e7ff)!important}.grid-footer-row .pinned-left,.grid-footer-row .sticky-toggle,.grid-footer-row .sticky-check{background:var(--ngx-grid-header-bg, #f8fafc)}.pinned-right{position:sticky!important;z-index:2;background:var(--ngx-grid-bg, #ffffff)}th.pinned-right{z-index:4;background:var(--ngx-grid-header-bg, #f8fafc)}.pinned-right-first{border-left:1px solid var(--ngx-grid-border, #cbd5e1)!important;box-shadow:-4px 0 8px -3px #00000026}.grid-table.striped .grid-row:nth-child(2n) .pinned-right{background:var(--ngx-grid-stripe-bg, #f8fafc)}.grid-row:hover .pinned-right{background:var(--ngx-grid-hover-bg, #f1f5f9)!important}.grid-row.selected .pinned-right{background:var(--ngx-grid-selected-bg, #e0e7ff)!important}.grid-footer-row .pinned-right{background:var(--ngx-grid-header-bg, #f8fafc)}.grid-td.cell-focused{outline:2px solid var(--ngx-input-focus, #4f46e5)!important;outline-offset:-2px;z-index:5}.grid-td.cell-focused-editing{padding:0!important}.grid-td.cell-focused-editing .grid-edit-input{width:100%;height:100%;border:none;outline:none;padding:12px 16px;box-sizing:border-box;background:var(--ngx-grid-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);font-family:inherit;font-size:inherit}.grid-th[draggable=true]{cursor:grab}.grid-th[draggable=true]:active{cursor:grabbing}.grid-th.dragging{opacity:.4;background:var(--ngx-grid-hover-bg, #f1f5f9)!important;border:1.5px dashed var(--ngx-input-border, #cbd5e1)}.grid-th.drag-over{border-left:3px solid var(--ngx-input-focus, #4f46e5)!important}.sort-icon.active{color:var(--ngx-input-focus, #4f46e5);font-weight:700}.sort-order-badge{font-size:8px;line-height:1;background:var(--ngx-input-focus, #4f46e5);color:#fff;padding:1px 3.5px;border-radius:4px;vertical-align:super;margin-left:2px}.grid-search-wrap{position:relative;display:inline-flex;align-items:center}.grid-search-input{padding:6px 30px 6px 12px;border:1px solid var(--ngx-grid-border, #cbd5e1);border-radius:8px;font-size:13px;font-family:inherit;background:var(--ngx-input-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);outline:none;transition:all .2s cubic-bezier(.4,0,.2,1);width:180px}.grid-search-input:focus{border-color:var(--ngx-input-focus, #4f46e5);box-shadow:0 0 0 3px var(--primary-glow, rgba(79, 70, 229, .15));width:220px}.grid-search-clear{position:absolute;right:8px;background:transparent;border:none;color:var(--ngx-grid-text-secondary, #94a3b8);font-size:16px;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:2px;line-height:1}.grid-search-clear:hover{color:var(--ngx-grid-text, #0f172a)}.search-highlight{background-color:#fbbf244d;color:inherit;font-weight:600;padding:1px 2px;border-radius:4px}.grid-td.cell-selected{background:var(--ngx-grid-cell-selected-bg, rgba(79, 70, 229, .12))!important;outline:1.5px solid var(--ngx-grid-cell-selected-border, #4f46e5);outline-offset:-1.5px}.row-drag-handle{cursor:grab;-webkit-user-select:none;user-select:none;color:var(--ngx-grid-text-secondary, #94a3b8);font-size:15px;font-weight:700;display:inline-block;padding:4px 8px;transition:color .15s ease}.row-drag-handle:hover{color:var(--ngx-grid-text, #0f172a)}.row-drag-handle:active{cursor:grabbing}.grid-row.dragging-row{opacity:.4;background:var(--ngx-grid-hover-bg, #f1f5f9)!important;border:1.5px dashed var(--ngx-input-border, #cbd5e1)}.grid-row.drag-over-row{border-top:2px solid var(--ngx-input-focus, #4f46e5)!important}.grid-context-menu{position:absolute;width:180px;background:var(--ngx-grid-bg, rgba(255, 255, 255, .95));backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);border:1px solid var(--ngx-grid-border, #e2e8f0);border-radius:10px;box-shadow:0 10px 25px -5px #0000001a,0 8px 10px -6px #0000001a;z-index:2000;padding:6px;box-sizing:border-box;display:flex;flex-direction:column;gap:2px;font-family:inherit}.menu-item{display:flex;align-items:center;gap:8px;padding:8px 10px;border:none;background:transparent;color:var(--ngx-grid-text, #0f172a);font-size:12px;font-weight:500;cursor:pointer;text-align:left;border-radius:6px;transition:all .15s ease;font-family:inherit;width:100%;box-sizing:border-box;outline:none}.menu-item:hover:not(:disabled){background:var(--ngx-grid-hover-bg, #f1f5f9);color:var(--ngx-btn-primary-bg, #4f46e5)}.menu-item:disabled{opacity:.4;cursor:not-allowed}.menu-icon{font-size:14px;width:16px;text-align:center}.menu-divider{height:1px;background:var(--ngx-grid-border, #e2e8f0);margin:4px 6px}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
716
2358
  }
717
2359
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: DataGridComponent, decorators: [{
718
2360
  type: Component,
719
- args: [{ selector: 'ngx-data-grid', standalone: true, imports: [NgTemplateOutlet], changeDetection: ChangeDetectionStrategy.OnPush, template: `
2361
+ args: [{ selector: 'ngx-data-grid', standalone: true, imports: [
2362
+ NgTemplateOutlet
2363
+ ], changeDetection: ChangeDetectionStrategy.OnPush, template: `
720
2364
  <div class="ngx-data-grid" [class.loading]="loading()">
721
2365
 
722
2366
  <div class="grid-toolbar">
723
2367
  <span class="grid-toolbar-title">Data Grid</span>
724
2368
  <div class="grid-toolbar-actions">
725
- <button class="grid-action-btn" (click)="exportToJson()" title="Export JSON">JSON</button>
726
- <button class="grid-action-btn" (click)="exportToCsv()" title="Export CSV">CSV</button>
727
- </div>
728
- </div>
729
-
730
- @if (hasFilterableColumns()) {
731
- <div class="grid-filter-bar">
732
- @for (col of columns(); track col.field) {
733
- @if (col.filterable) {
2369
+ @if (showGlobalSearch()) {
2370
+ <div class="grid-search-wrap">
734
2371
  <input
735
- class="grid-filter-input"
736
- [placeholder]="'Filter ' + col.title"
737
- [value]="getFilter(col.field)"
738
- (input)="setFilter(col.field, $any($event.target).value)"
739
- [style.width.px]="col.width ?? 120"
2372
+ class="grid-search-input"
2373
+ type="text"
2374
+ [placeholder]="globalSearchPlaceholder()"
2375
+ [value]="searchText()"
2376
+ (input)="searchText.set($any($event.target).value)"
740
2377
  />
741
- } @else {
742
- <div [style.width.px]="col.width ?? 120" class="grid-filter-spacer"></div>
743
- }
2378
+ @if (searchText()) {
2379
+ <button class="grid-search-clear" (click)="searchText.set('')" title="Clear search">×</button>
2380
+ }
2381
+ </div>
2382
+ }
2383
+ @if (showColumnChooser()) {
2384
+ <button class="grid-action-btn" (click)="openColumnChooser($event)" title="Choose columns">Columns</button>
744
2385
  }
2386
+ <button class="grid-action-btn" (click)="exportToJson()" title="Export JSON">JSON</button>
2387
+ <button class="grid-action-btn" (click)="exportToCsv()" title="Export CSV">CSV</button>
745
2388
  </div>
746
- }
2389
+ </div>
747
2390
 
748
2391
  <div class="grid-table-wrap">
749
2392
  <table class="grid-table" [class.striped]="striped()">
2393
+ <colgroup>
2394
+ @if (rowReorderable()) {
2395
+ <col style="width: 44px" />
2396
+ }
2397
+ @if (showDetailToggle()) {
2398
+ <col style="width: 44px" />
2399
+ }
2400
+ @if (selectable()) {
2401
+ <col style="width: 44px" />
2402
+ }
2403
+ @for (col of orderedColumns(); track col.field) {
2404
+ <col [style.width.px]="getColumnWidth(col)" />
2405
+ }
2406
+ @if (editable()) {
2407
+ <col style="width: 120px" />
2408
+ }
2409
+ </colgroup>
750
2410
  <thead>
751
- <tr>
2411
+ <ng-template #headerCellContent let-col="col">
2412
+ <div class="th-content-wrapper">
2413
+ @if (resolveHeaderTemplate(col); as activeHeaderTemplate) {
2414
+ <ng-container *ngTemplateOutlet="activeHeaderTemplate; context: {
2415
+ $implicit: col,
2416
+ column: col,
2417
+ sort: sortState(),
2418
+ filters: activeFilters(),
2419
+ isServerMode: isAnyServerMode()
2420
+ }" />
2421
+ } @else {
2422
+ <span class="th-text">{{ col.title }}</span>
2423
+ @if (col.sortable) {
2424
+ @if (getSortDirection(col); as dir) {
2425
+ <span class="sort-icon active">
2426
+ {{ dir === 'asc' ? '↑' : '↓' }}
2427
+ @if (multiSort() && sortStates().length > 1) {
2428
+ <sub class="sort-order-badge">{{ getSortIndex(col) }}</sub>
2429
+ }
2430
+ </span>
2431
+ } @else {
2432
+ <span class="sort-icon">↕</span>
2433
+ }
2434
+ }
2435
+ }
2436
+ @if (col.filterable) {
2437
+ <button class="grid-filter-btn" [class.active]="filterStates().has(col.field)" (click)="openFilterPopover($event, col.field); $event.stopPropagation()" title="Filter column">
2438
+ <svg viewBox="0 0 24 24" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
2439
+ <polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3"></polygon>
2440
+ </svg>
2441
+ </button>
2442
+ }
2443
+ </div>
2444
+ <div class="grid-resize-handle" (mousedown)="onResizeStart($event, col)" (click)="$event.stopPropagation()"></div>
2445
+ </ng-template>
2446
+
2447
+ <tr class="grid-header-row">
2448
+ @if (rowReorderable()) {
2449
+ <th class="grid-th grid-th-reorder pinned-left" [class.pinned-left-last]="isRowReorderableLastPinned()" [attr.rowspan]="hasColumnCategories() ? 2 : 1" style="width:44px; left:0px"></th>
2450
+ }
752
2451
  @if (showDetailToggle()) {
753
- <th class="grid-th grid-th-toggle" style="width:36px"></th>
2452
+ <th class="grid-th grid-th-toggle pinned-left" [class.pinned-left-last]="isDetailToggleLastPinned()" [attr.rowspan]="hasColumnCategories() ? 2 : 1" [style.left.px]="rowReorderable() ? 44 : 0" style="width:44px"></th>
754
2453
  }
755
2454
  @if (selectable()) {
756
- <th class="grid-th grid-th-check" style="width:40px">
2455
+ <th class="grid-th grid-th-check pinned-left" [class.pinned-left-last]="isSelectableLastPinned()" [attr.rowspan]="hasColumnCategories() ? 2 : 1" [style.left.px]="(rowReorderable() ? 44 : 0) + (showDetailToggle() ? 44 : 0)" style="width:44px">
757
2456
  <input type="checkbox" [checked]="allSelected()" [indeterminate]="someSelected() && !allSelected()" (change)="toggleAll()" />
758
2457
  </th>
759
2458
  }
760
- @for (col of columns(); track col.field) {
761
- <th
762
- class="grid-th"
763
- [style.width.px]="col.width"
764
- [class.sortable]="col.sortable"
765
- [class.sort-asc]="sortState()?.field === col.field && sortState()?.dir === 'asc'"
766
- [class.sort-desc]="sortState()?.field === col.field && sortState()?.dir === 'desc'"
767
- (click)="col.sortable ? onSort(col) : null"
768
- >
769
- @if (resolveHeaderTemplate(col); as activeHeaderTemplate) {
770
- <ng-container *ngTemplateOutlet="activeHeaderTemplate; context: {
771
- $implicit: col,
772
- column: col,
773
- sort: sortState(),
774
- filters: activeFilters(),
775
- isServerMode: isAnyServerMode()
776
- }" />
777
- } @else {
778
- <span class="th-text">{{ col.title }}</span>
779
- @if (col.sortable) {
780
- <span class="sort-icon">
781
- @if (sortState()?.field === col.field) {
782
- {{ sortState()?.dir === 'asc' ? '↑' : '↓' }}
783
- } @else { ↕ }
784
- </span>
785
- }
786
- }
787
- </th>
2459
+ @for (cell of headerRows().row1; track cell.field) {
2460
+ @if (cell.isCategory) {
2461
+ <th
2462
+ class="grid-th grid-category-th"
2463
+ [class.pinned-left]="cell.pinned === 'left'"
2464
+ [class.pinned-left-last]="cell.isPinnedLast"
2465
+ [class.pinned-right]="cell.pinned === 'right'"
2466
+ [class.pinned-right-first]="cell.isPinnedFirst"
2467
+ [style.left.px]="cell.pinned === 'left' ? cell.leftOffset : null"
2468
+ [style.right.px]="cell.pinned === 'right' ? cell.rightOffset : null"
2469
+ [attr.colspan]="cell.colSpan"
2470
+ [attr.rowspan]="cell.rowSpan"
2471
+ >
2472
+ <span class="category-title">{{ cell.title }}</span>
2473
+ </th>
2474
+ } @else {
2475
+ <th
2476
+ class="grid-th"
2477
+ [class.pinned-left]="cell.column.pinned === 'left'"
2478
+ [class.pinned-left-last]="cell.isPinnedLast"
2479
+ [class.pinned-right]="cell.column.pinned === 'right'"
2480
+ [class.pinned-right-first]="cell.isPinnedFirst"
2481
+ [style.left.px]="cell.column.pinned === 'left' ? cell.leftOffset : null"
2482
+ [style.right.px]="cell.column.pinned === 'right' ? cell.rightOffset : null"
2483
+ [style.width.px]="getColumnWidth(cell.column)"
2484
+ [class.sortable]="cell.column.sortable"
2485
+ [class.sort-asc]="getSortDirection(cell.column) === 'asc'"
2486
+ [class.sort-desc]="getSortDirection(cell.column) === 'desc'"
2487
+ [class.dragging]="draggingField() === cell.column.field"
2488
+ [class.drag-over]="dragOverField() === cell.column.field"
2489
+ [attr.draggable]="reorderable() ? true : null"
2490
+ (dragstart)="onDragStart($event, cell.column)"
2491
+ (dragover)="onDragOver($event, cell.column)"
2492
+ (drop)="onDrop($event, cell.column)"
2493
+ (dragend)="onDragEnd()"
2494
+ (click)="cell.column.sortable ? onSort(cell.column, $event) : null"
2495
+ [attr.colspan]="cell.colSpan"
2496
+ [attr.rowspan]="cell.rowSpan"
2497
+ >
2498
+ <ng-container *ngTemplateOutlet="headerCellContent; context: { col: cell.column }" />
2499
+ </th>
2500
+ }
788
2501
  }
789
2502
  @if (editable()) {
790
- <th class="grid-th" style="width:120px">Actions</th>
2503
+ <th
2504
+ class="grid-th"
2505
+ [class.pinned-right]="firstPinnedRightColumnField() !== null"
2506
+ [class.pinned-right-first]="firstPinnedRightColumnField() === null"
2507
+ [style.right.px]="firstPinnedRightColumnField() !== null ? 0 : null"
2508
+ [attr.rowspan]="hasColumnCategories() ? 2 : 1"
2509
+ style="width:120px"
2510
+ >Actions</th>
791
2511
  }
792
2512
  </tr>
2513
+ @if (hasColumnCategories()) {
2514
+ <tr class="grid-header-row sub-header-row">
2515
+ @for (cell of headerRows().row2; track cell.field) {
2516
+ <th
2517
+ class="grid-th"
2518
+ [class.pinned-left]="cell.column.pinned === 'left'"
2519
+ [class.pinned-left-last]="cell.isPinnedLast"
2520
+ [class.pinned-right]="cell.column.pinned === 'right'"
2521
+ [class.pinned-right-first]="cell.isPinnedFirst"
2522
+ [style.left.px]="cell.column.pinned === 'left' ? cell.leftOffset : null"
2523
+ [style.right.px]="cell.column.pinned === 'right' ? cell.rightOffset : null"
2524
+ [style.width.px]="getColumnWidth(cell.column)"
2525
+ [class.sortable]="cell.column.sortable"
2526
+ [class.sort-asc]="getSortDirection(cell.column) === 'asc'"
2527
+ [class.sort-desc]="getSortDirection(cell.column) === 'desc'"
2528
+ [class.dragging]="draggingField() === cell.column.field"
2529
+ [class.drag-over]="dragOverField() === cell.column.field"
2530
+ [attr.draggable]="reorderable() ? true : null"
2531
+ (dragstart)="onDragStart($event, cell.column)"
2532
+ (dragover)="onDragOver($event, cell.column)"
2533
+ (drop)="onDrop($event, cell.column)"
2534
+ (dragend)="onDragEnd()"
2535
+ (click)="cell.column.sortable ? onSort(cell.column, $event) : null"
2536
+ [attr.colspan]="cell.colSpan"
2537
+ [attr.rowspan]="cell.rowSpan"
2538
+ >
2539
+ <ng-container *ngTemplateOutlet="headerCellContent; context: { col: cell.column }" />
2540
+ </th>
2541
+ }
2542
+ </tr>
2543
+ }
793
2544
  </thead>
794
2545
  <tbody>
795
2546
  @if (loading()) {
@@ -805,13 +2556,59 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
805
2556
  } @else if (groupedRows().length > 0) {
806
2557
  @for (group of groupedRows(); track group.key) {
807
2558
  <tr class="grid-group-row" (click)="toggleGroup(group.key)">
808
- <td [attr.colspan]="renderColumnCount()">
809
- <button class="group-toggle" type="button" (click)="toggleGroup(group.key); $event.stopPropagation()">
810
- {{ isGroupCollapsed(group.key) ? '▸' : '▾' }}
811
- </button>
812
- <strong>{{ group.field }}</strong>: {{ group.value }}
813
- <span class="group-count">({{ group.count }})</span>
814
- </td>
2559
+ @if (groupAggregations()) {
2560
+ @if (rowReorderable()) {
2561
+ <td class="grid-td grid-td-reorder pinned-left" [class.pinned-left-last]="isRowReorderableLastPinned()" style="left:0px; width:44px"></td>
2562
+ }
2563
+ @if (showDetailToggle()) {
2564
+ <td class="grid-td grid-td-toggle pinned-left" [class.pinned-left-last]="isDetailToggleLastPinned()" [style.left.px]="rowReorderable() ? 44 : 0" style="width:44px"></td>
2565
+ }
2566
+ @if (selectable()) {
2567
+ <td class="grid-td grid-td-check pinned-left" [class.pinned-left-last]="isSelectableLastPinned()" [style.left.px]="(rowReorderable() ? 44 : 0) + (showDetailToggle() ? 44 : 0)" style="width:44px">
2568
+ <input type="checkbox" [checked]="isGroupAllSelected(group)" (change)="toggleGroupSelection(group, $event)" (click)="$event.stopPropagation()" />
2569
+ </td>
2570
+ }
2571
+ @for (col of orderedColumns(); track col.field; let first = $first) {
2572
+ <td
2573
+ class="grid-td"
2574
+ [class.pinned-left]="col.pinned === 'left'"
2575
+ [class.pinned-left-last]="col.pinned === 'left' && lastPinnedColumnField() === col.field"
2576
+ [class.pinned-right]="col.pinned === 'right'"
2577
+ [class.pinned-right-first]="col.pinned === 'right' && firstPinnedRightColumnField() === col.field"
2578
+ [style.left.px]="col.pinned === 'left' ? columnOffsets()[col.field] : null"
2579
+ [style.right.px]="col.pinned === 'right' ? columnRightOffsets()[col.field] : null"
2580
+ [style.text-align]="col.align ?? 'left'"
2581
+ [style.width.px]="getColumnWidth(col)"
2582
+ >
2583
+ @if (first) {
2584
+ <div style="display: flex; align-items: center; gap: 4px;">
2585
+ <button class="group-toggle" type="button" (click)="toggleGroup(group.key); $event.stopPropagation()" style="background: transparent; border: none; cursor: pointer; padding: 0 4px; font-weight: bold; color: inherit; outline: none;">
2586
+ {{ isGroupCollapsed(group.key) ? '▸' : '▾' }}
2587
+ </button>
2588
+ <strong>{{ col.category ? '' : group.field + ': ' }}</strong>{{ group.value }} <span class="group-count">({{ group.count }})</span>
2589
+ </div>
2590
+ } @else if (col.aggregation) {
2591
+ <span class="agg-label">{{ col.aggregation }}: </span>
2592
+ <strong class="agg-value">{{ getGroupAggregationValue(group, col) }}</strong>
2593
+ }
2594
+ </td>
2595
+ }
2596
+ @if (editable()) {
2597
+ <td
2598
+ [class.pinned-right]="firstPinnedRightColumnField() !== null"
2599
+ [class.pinned-right-first]="firstPinnedRightColumnField() === null"
2600
+ [style.right.px]="firstPinnedRightColumnField() !== null ? 0 : null"
2601
+ ></td>
2602
+ }
2603
+ } @else {
2604
+ <td [attr.colspan]="renderColumnCount()">
2605
+ <button class="group-toggle" type="button" (click)="toggleGroup(group.key); $event.stopPropagation()">
2606
+ {{ isGroupCollapsed(group.key) ? '▸' : '▾' }}
2607
+ </button>
2608
+ <strong>{{ group.field }}</strong>: {{ group.value }}
2609
+ <span class="group-count">({{ group.count }})</span>
2610
+ </td>
2611
+ }
815
2612
  </tr>
816
2613
 
817
2614
  @if (!isGroupCollapsed(group.key)) {
@@ -819,11 +2616,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
819
2616
  <tr
820
2617
  class="grid-row"
821
2618
  [class.selected]="isRowSelected(row)"
2619
+ [class.dragging-row]="draggingRowIndex() === i"
2620
+ [class.drag-over-row]="dragOverRowIndex() === i"
2621
+ (dragover)="onRowDragOver($event, i)"
2622
+ (drop)="onRowDrop($event, i)"
2623
+ (dragend)="onRowDragEnd()"
822
2624
  (click)="onRowClick(row, i)"
823
2625
  (dblclick)="editable() ? beginEdit(row, i) : null"
824
2626
  >
2627
+ @if (rowReorderable()) {
2628
+ <td class="grid-td grid-td-reorder pinned-left" [class.pinned-left-last]="isRowReorderableLastPinned()" style="left:0px; text-align:center; width:44px">
2629
+ <span
2630
+ class="row-drag-handle"
2631
+ draggable="true"
2632
+ (dragstart)="onRowDragStart($event, i)"
2633
+ (dragend)="onRowDragEnd()"
2634
+ >⋮⋮</span>
2635
+ </td>
2636
+ }
2637
+
825
2638
  @if (showDetailToggle()) {
826
- <td class="grid-td grid-td-toggle">
2639
+ <td class="grid-td grid-td-toggle pinned-left" [class.pinned-left-last]="isDetailToggleLastPinned()" [style.left.px]="rowReorderable() ? 44 : 0">
827
2640
  <button class="toggle-btn" type="button" (click)="toggleDetail(row); $event.stopPropagation()">
828
2641
  {{ isExpanded(row) ? '▾' : '▸' }}
829
2642
  </button>
@@ -831,13 +2644,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
831
2644
  }
832
2645
 
833
2646
  @if (selectable()) {
834
- <td class="grid-td grid-td-check">
2647
+ <td class="grid-td grid-td-check pinned-left" [class.pinned-left-last]="isSelectableLastPinned()" [style.left.px]="(rowReorderable() ? 44 : 0) + (showDetailToggle() ? 44 : 0)">
835
2648
  <input type="checkbox" [checked]="isRowSelected(row)" (change)="toggleRow(row)" (click)="$event.stopPropagation()" />
836
2649
  </td>
837
2650
  }
838
2651
 
839
2652
  @if (rowTemplate()) {
840
- <td class="grid-td" [attr.colspan]="columns().length + (editable() ? 1 : 0)">
2653
+ <td class="grid-td" [attr.colspan]="orderedColumns().length + (editable() ? 1 : 0)">
841
2654
  <ng-container *ngTemplateOutlet="rowTemplate(); context: {
842
2655
  $implicit: row,
843
2656
  row: row,
@@ -847,32 +2660,75 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
847
2660
  }" />
848
2661
  </td>
849
2662
  } @else {
850
- @for (col of columns(); track col.field) {
851
- <td class="grid-td" [style.text-align]="col.align ?? 'left'">
852
- @if (isEditing(row) && editable() && col.editable) {
853
- <input
854
- class="grid-edit-input"
855
- [value]="toStringSafe(getDraftValue(row, col.field))"
856
- (input)="updateDraft(col.field, $any($event.target).value)"
857
- (click)="$event.stopPropagation()"
858
- />
859
- } @else if (resolveCellTemplate(col)) {
860
- <ng-container *ngTemplateOutlet="resolveCellTemplate(col)!; context: {
861
- $implicit: getCellValue(row, col.field),
862
- value: getCellValue(row, col.field),
863
- row: row,
864
- column: col,
865
- index: i,
866
- editing: isEditing(row)
867
- }" />
868
- } @else {
869
- {{ getCellValue(row, col.field) }}
870
- }
871
- </td>
2663
+ @for (col of orderedColumns(); track col.field) {
2664
+ @if (getCellRowSpan(row, col.field, i, group.items) > 0) {
2665
+ <td
2666
+ class="grid-td"
2667
+ [attr.rowspan]="getCellRowSpan(row, col.field, i, group.items)"
2668
+ [class.pinned-left]="col.pinned === 'left'"
2669
+ [class.pinned-left-last]="col.pinned === 'left' && lastPinnedColumnField() === col.field"
2670
+ [class.pinned-right]="col.pinned === 'right'"
2671
+ [class.pinned-right-first]="col.pinned === 'right' && firstPinnedRightColumnField() === col.field"
2672
+ [class.cell-focused]="focusedCell()?.row === row && focusedCell()?.colField === col.field"
2673
+ [class.cell-focused-editing]="focusedCell()?.row === row && focusedCell()?.colField === col.field && focusedCellEditActive()"
2674
+ [style.left.px]="col.pinned === 'left' ? columnOffsets()[col.field] : null"
2675
+ [style.right.px]="col.pinned === 'right' ? columnRightOffsets()[col.field] : null"
2676
+ [style.text-align]="col.align ?? 'left'"
2677
+ [style.width.px]="getColumnWidth(col)"
2678
+ [class.cell-selected]="isCellSelected(row, col.field)"
2679
+ (mousedown)="onCellMouseDown($event, row, col.field)"
2680
+ (mouseenter)="onCellMouseEnter(row, col.field)"
2681
+ (contextmenu)="onCellContextMenu($event, row, col.field)"
2682
+ (click)="onCellClick(row, col.field)"
2683
+ >
2684
+ @if (isEditing(row) && editable() && col.editable) {
2685
+ @if (resolveEditCellTemplate(col); as activeEditTemplate) {
2686
+ <ng-container *ngTemplateOutlet="activeEditTemplate; context: {
2687
+ $implicit: getDraftValue(row, col.field),
2688
+ value: getCellValue(row, col.field),
2689
+ row: row,
2690
+ column: col,
2691
+ index: i,
2692
+ editing: true,
2693
+ draftValue: getDraftValue(row, col.field),
2694
+ updateDraft: getUpdateDraftCallback(col.field)
2695
+ }" />
2696
+ } @else {
2697
+ <input
2698
+ class="grid-edit-input"
2699
+ [value]="toStringSafe(getDraftValue(row, col.field))"
2700
+ (input)="updateDraft(col.field, $any($event.target).value)"
2701
+ (click)="$event.stopPropagation()"
2702
+ />
2703
+ }
2704
+ } @else if (resolveCellTemplate(col)) {
2705
+ <ng-container *ngTemplateOutlet="resolveCellTemplate(col)!; context: {
2706
+ $implicit: getCellValue(row, col.field),
2707
+ value: getCellValue(row, col.field),
2708
+ row: row,
2709
+ column: col,
2710
+ index: i,
2711
+ editing: isEditing(row)
2712
+ }" />
2713
+ } @else {
2714
+ @if (showGlobalSearch() && searchText()) {
2715
+ <span [innerHTML]="highlightSearchText(getCellValue(row, col.field))"></span>
2716
+ } @else {
2717
+ {{ getCellValue(row, col.field) }}
2718
+ }
2719
+ }
2720
+ </td>
2721
+ }
872
2722
  }
873
2723
 
874
2724
  @if (editable()) {
875
- <td class="grid-td grid-actions">
2725
+ <td
2726
+ class="grid-td grid-actions"
2727
+ [class.pinned-right]="firstPinnedRightColumnField() !== null"
2728
+ [class.pinned-right-first]="firstPinnedRightColumnField() === null"
2729
+ [style.right.px]="firstPinnedRightColumnField() !== null ? 0 : null"
2730
+ style="width:120px"
2731
+ >
876
2732
  @if (!isEditing(row)) {
877
2733
  <button class="action-btn" type="button" (click)="beginEdit(row, i); $event.stopPropagation()">Edit</button>
878
2734
  } @else {
@@ -903,11 +2759,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
903
2759
  <tr
904
2760
  class="grid-row"
905
2761
  [class.selected]="isRowSelected(row)"
2762
+ [class.dragging-row]="draggingRowIndex() === i"
2763
+ [class.drag-over-row]="dragOverRowIndex() === i"
2764
+ (dragover)="onRowDragOver($event, i)"
2765
+ (drop)="onRowDrop($event, i)"
2766
+ (dragend)="onRowDragEnd()"
906
2767
  (click)="onRowClick(row, i)"
907
2768
  (dblclick)="editable() ? beginEdit(row, i) : null"
908
2769
  >
2770
+ @if (rowReorderable()) {
2771
+ <td class="grid-td grid-td-reorder pinned-left" [class.pinned-left-last]="isRowReorderableLastPinned()" style="left:0px; text-align:center; width:44px">
2772
+ <span
2773
+ class="row-drag-handle"
2774
+ draggable="true"
2775
+ (dragstart)="onRowDragStart($event, i)"
2776
+ (dragend)="onRowDragEnd()"
2777
+ >⋮⋮</span>
2778
+ </td>
2779
+ }
2780
+
909
2781
  @if (showDetailToggle()) {
910
- <td class="grid-td grid-td-toggle">
2782
+ <td class="grid-td grid-td-toggle pinned-left" [class.pinned-left-last]="isDetailToggleLastPinned()" [style.left.px]="rowReorderable() ? 44 : 0">
911
2783
  <button class="toggle-btn" type="button" (click)="toggleDetail(row); $event.stopPropagation()">
912
2784
  {{ isExpanded(row) ? '▾' : '▸' }}
913
2785
  </button>
@@ -915,13 +2787,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
915
2787
  }
916
2788
 
917
2789
  @if (selectable()) {
918
- <td class="grid-td grid-td-check">
2790
+ <td class="grid-td grid-td-check pinned-left" [class.pinned-left-last]="isSelectableLastPinned()" [style.left.px]="(rowReorderable() ? 44 : 0) + (showDetailToggle() ? 44 : 0)">
919
2791
  <input type="checkbox" [checked]="isRowSelected(row)" (change)="toggleRow(row)" (click)="$event.stopPropagation()" />
920
2792
  </td>
921
2793
  }
922
2794
 
923
2795
  @if (rowTemplate()) {
924
- <td class="grid-td" [attr.colspan]="columns().length + (editable() ? 1 : 0)">
2796
+ <td class="grid-td" [attr.colspan]="orderedColumns().length + (editable() ? 1 : 0)">
925
2797
  <ng-container *ngTemplateOutlet="rowTemplate(); context: {
926
2798
  $implicit: row,
927
2799
  row: row,
@@ -931,32 +2803,75 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
931
2803
  }" />
932
2804
  </td>
933
2805
  } @else {
934
- @for (col of columns(); track col.field) {
935
- <td class="grid-td" [style.text-align]="col.align ?? 'left'">
936
- @if (isEditing(row) && editable() && col.editable) {
937
- <input
938
- class="grid-edit-input"
939
- [value]="toStringSafe(getDraftValue(row, col.field))"
940
- (input)="updateDraft(col.field, $any($event.target).value)"
941
- (click)="$event.stopPropagation()"
942
- />
943
- } @else if (resolveCellTemplate(col)) {
944
- <ng-container *ngTemplateOutlet="resolveCellTemplate(col)!; context: {
945
- $implicit: getCellValue(row, col.field),
946
- value: getCellValue(row, col.field),
947
- row: row,
948
- column: col,
949
- index: i,
950
- editing: isEditing(row)
951
- }" />
952
- } @else {
953
- {{ getCellValue(row, col.field) }}
954
- }
955
- </td>
2806
+ @for (col of orderedColumns(); track col.field) {
2807
+ @if (getCellRowSpan(row, col.field, i) > 0) {
2808
+ <td
2809
+ class="grid-td"
2810
+ [attr.rowspan]="getCellRowSpan(row, col.field, i)"
2811
+ [class.pinned-left]="col.pinned === 'left'"
2812
+ [class.pinned-left-last]="col.pinned === 'left' && lastPinnedColumnField() === col.field"
2813
+ [class.pinned-right]="col.pinned === 'right'"
2814
+ [class.pinned-right-first]="col.pinned === 'right' && firstPinnedRightColumnField() === col.field"
2815
+ [class.cell-focused]="focusedCell()?.row === row && focusedCell()?.colField === col.field"
2816
+ [class.cell-focused-editing]="focusedCell()?.row === row && focusedCell()?.colField === col.field && focusedCellEditActive()"
2817
+ [style.left.px]="col.pinned === 'left' ? columnOffsets()[col.field] : null"
2818
+ [style.right.px]="col.pinned === 'right' ? columnRightOffsets()[col.field] : null"
2819
+ [style.text-align]="col.align ?? 'left'"
2820
+ [style.width.px]="getColumnWidth(col)"
2821
+ [class.cell-selected]="isCellSelected(row, col.field)"
2822
+ (mousedown)="onCellMouseDown($event, row, col.field)"
2823
+ (mouseenter)="onCellMouseEnter(row, col.field)"
2824
+ (contextmenu)="onCellContextMenu($event, row, col.field)"
2825
+ (click)="onCellClick(row, col.field)"
2826
+ >
2827
+ @if (isEditing(row) && editable() && col.editable) {
2828
+ @if (resolveEditCellTemplate(col); as activeEditTemplate) {
2829
+ <ng-container *ngTemplateOutlet="activeEditTemplate; context: {
2830
+ $implicit: getDraftValue(row, col.field),
2831
+ value: getCellValue(row, col.field),
2832
+ row: row,
2833
+ column: col,
2834
+ index: i,
2835
+ editing: true,
2836
+ draftValue: getDraftValue(row, col.field),
2837
+ updateDraft: getUpdateDraftCallback(col.field)
2838
+ }" />
2839
+ } @else {
2840
+ <input
2841
+ class="grid-edit-input"
2842
+ [value]="toStringSafe(getDraftValue(row, col.field))"
2843
+ (input)="updateDraft(col.field, $any($event.target).value)"
2844
+ (click)="$event.stopPropagation()"
2845
+ />
2846
+ }
2847
+ } @else if (resolveCellTemplate(col)) {
2848
+ <ng-container *ngTemplateOutlet="resolveCellTemplate(col)!; context: {
2849
+ $implicit: getCellValue(row, col.field),
2850
+ value: getCellValue(row, col.field),
2851
+ row: row,
2852
+ column: col,
2853
+ index: i,
2854
+ editing: isEditing(row)
2855
+ }" />
2856
+ } @else {
2857
+ @if (showGlobalSearch() && searchText()) {
2858
+ <span [innerHTML]="highlightSearchText(getCellValue(row, col.field))"></span>
2859
+ } @else {
2860
+ {{ getCellValue(row, col.field) }}
2861
+ }
2862
+ }
2863
+ </td>
2864
+ }
956
2865
  }
957
2866
 
958
2867
  @if (editable()) {
959
- <td class="grid-td grid-actions">
2868
+ <td
2869
+ class="grid-td grid-actions"
2870
+ [class.pinned-right]="firstPinnedRightColumnField() !== null"
2871
+ [class.pinned-right-first]="firstPinnedRightColumnField() === null"
2872
+ [style.right.px]="firstPinnedRightColumnField() !== null ? 0 : null"
2873
+ style="width:120px"
2874
+ >
960
2875
  @if (!isEditing(row)) {
961
2876
  <button class="action-btn" type="button" (click)="beginEdit(row, i); $event.stopPropagation()">Edit</button>
962
2877
  } @else {
@@ -982,6 +2897,50 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
982
2897
  }
983
2898
  }
984
2899
  </tbody>
2900
+ @if (hasAggregation()) {
2901
+ <tfoot>
2902
+ <tr class="grid-footer-row">
2903
+ @if (showDetailToggle()) {
2904
+ <td class="grid-td-toggle pinned-left" [class.pinned-left-last]="isDetailToggleLastPinned()" style="left:0px; width:44px"></td>
2905
+ }
2906
+ @if (selectable()) {
2907
+ <td class="grid-td-check pinned-left" [class.pinned-left-last]="isSelectableLastPinned()" [style.left.px]="showDetailToggle() ? 44 : 0" style="width:44px"></td>
2908
+ }
2909
+ @for (col of orderedColumns(); track col.field) {
2910
+ <td
2911
+ class="grid-td grid-footer-cell"
2912
+ [class.pinned-left]="col.pinned === 'left'"
2913
+ [class.pinned-left-last]="col.pinned === 'left' && lastPinnedColumnField() === col.field"
2914
+ [class.pinned-right]="col.pinned === 'right'"
2915
+ [class.pinned-right-first]="col.pinned === 'right' && firstPinnedRightColumnField() === col.field"
2916
+ [style.left.px]="col.pinned === 'left' ? columnOffsets()[col.field] : null"
2917
+ [style.right.px]="col.pinned === 'right' ? columnRightOffsets()[col.field] : null"
2918
+ [style.text-align]="col.align ?? 'left'"
2919
+ [style.width.px]="getColumnWidth(col)"
2920
+ >
2921
+ @if (resolveFooterTemplate(col); as activeFooterTemplate) {
2922
+ <ng-container *ngTemplateOutlet="activeFooterTemplate; context: {
2923
+ $implicit: col,
2924
+ column: col,
2925
+ aggregationValue: getAggregationValue(col),
2926
+ data: flatRenderedRows()
2927
+ }" />
2928
+ } @else if (col.aggregation) {
2929
+ <span class="agg-label">{{ col.aggregation }}: </span>
2930
+ <strong class="agg-value">{{ getAggregationValue(col) }}</strong>
2931
+ }
2932
+ </td>
2933
+ }
2934
+ @if (editable()) {
2935
+ <td
2936
+ [class.pinned-right]="firstPinnedRightColumnField() !== null"
2937
+ [class.pinned-right-first]="firstPinnedRightColumnField() === null"
2938
+ [style.right.px]="firstPinnedRightColumnField() !== null ? 0 : null"
2939
+ ></td>
2940
+ }
2941
+ </tr>
2942
+ </tfoot>
2943
+ }
985
2944
  </table>
986
2945
  </div>
987
2946
 
@@ -1001,9 +2960,231 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
1001
2960
  </div>
1002
2961
  </div>
1003
2962
  }
2963
+
2964
+ <!-- Excel-Style Filter Popover Overlay -->
2965
+ @if (activeFilterPopover(); as pop) {
2966
+ <div class="grid-filter-popover" [style.top.px]="pop.top" [style.left.px]="pop.left" (click)="$event.stopPropagation()">
2967
+ <div class="popover-section text-filter-section">
2968
+ <label class="popover-label">Text Filter</label>
2969
+ <div class="text-filter-row">
2970
+ <select class="popover-select" [value]="tempFilterOperator()" (change)="tempFilterOperator.set($any($event.target).value)">
2971
+ <option value="contains">Contains</option>
2972
+ <option value="eq">Equals</option>
2973
+ <option value="startsWith">Starts With</option>
2974
+ <option value="endsWith">Ends With</option>
2975
+ </select>
2976
+ <input class="popover-input" type="text" [value]="tempFilterValue()" (input)="tempFilterValue.set($any($event.target).value)" placeholder="Filter value..." />
2977
+ </div>
2978
+ </div>
2979
+
2980
+ <div class="popover-section checklist-section">
2981
+ <label class="popover-label">Checklist Filter</label>
2982
+ <div class="checklist-actions">
2983
+ <label class="checklist-item select-all">
2984
+ <input type="checkbox" [checked]="tempSelectedValues().size === getDistinctValues(pop.field).length" [indeterminate]="tempSelectedValues().size > 0 && tempSelectedValues().size < getDistinctValues(pop.field).length" (change)="toggleSelectAllChecklist()" />
2985
+ <span>(Select All)</span>
2986
+ </label>
2987
+ </div>
2988
+ <div class="checklist-scroll">
2989
+ @for (val of getDistinctValues(pop.field); track val) {
2990
+ <label class="checklist-item">
2991
+ <input type="checkbox" [checked]="tempSelectedValues().has(val)" (change)="toggleChecklistItem(val)" />
2992
+ <span>{{ val }}</span>
2993
+ </label>
2994
+ }
2995
+ </div>
2996
+ </div>
2997
+
2998
+ <div class="popover-footer">
2999
+ <button class="popover-btn clear" (click)="clearPopoverFilter()">Clear</button>
3000
+ <div class="footer-actions">
3001
+ <button class="popover-btn cancel" (click)="activeFilterPopover.set(null)">Cancel</button>
3002
+ <button class="popover-btn apply" (click)="applyPopoverFilter()">Apply</button>
3003
+ </div>
3004
+ </div>
3005
+ </div>
3006
+ }
3007
+
3008
+ <!-- Column Chooser Popover Overlay -->
3009
+ @if (activeColumnChooserPopover(); as pop) {
3010
+ <div class="grid-column-chooser-popover" [style.top.px]="pop.top" [style.left.px]="pop.left" (click)="$event.stopPropagation()">
3011
+ <div class="popover-section checklist-section" style="border-top: none; padding-top: 0;">
3012
+ <label class="popover-label">Visible Columns</label>
3013
+ <div class="checklist-scroll">
3014
+ @for (col of columns(); track col.field) {
3015
+ <label class="checklist-item">
3016
+ <input type="checkbox" [checked]="!hiddenColumns().has(col.field)" (change)="toggleColumnVisibility(col.field)" />
3017
+ <span>{{ col.title }}</span>
3018
+ </label>
3019
+ }
3020
+ </div>
3021
+ </div>
3022
+ <div class="popover-footer">
3023
+ <button class="popover-btn apply" (click)="activeColumnChooserPopover.set(null)">Close</button>
3024
+ </div>
3025
+ </div>
3026
+ }
3027
+
3028
+ <!-- Custom Context Menu Overlay -->
3029
+ @if (activeContextMenu(); as menu) {
3030
+ <div class="grid-context-menu" [style.top.px]="menu.y" [style.left.px]="menu.x" (click)="$event.stopPropagation()">
3031
+ <button class="menu-item" [disabled]="!selectedCellStart()" (click)="contextMenuCopy()">
3032
+ <span class="menu-icon">📋</span> Copy Selection
3033
+ </button>
3034
+ <div class="menu-divider"></div>
3035
+ <button class="menu-item" (click)="contextMenuTogglePin(menu.colField)">
3036
+ <span class="menu-icon">📌</span> {{ isColumnPinned(menu.colField) ? 'Unpin Column' : 'Pin Column Left' }}
3037
+ </button>
3038
+ <button class="menu-item" (click)="contextMenuHideColumn(menu.colField)">
3039
+ <span class="menu-icon">👁️</span> Hide Column
3040
+ </button>
3041
+ <div class="menu-divider"></div>
3042
+ <button class="menu-item" [disabled]="filterStates().size === 0" (click)="contextMenuClearFilters()">
3043
+ <span class="menu-icon">🧹</span> Clear All Filters
3044
+ </button>
3045
+ <div class="menu-divider"></div>
3046
+ <button class="menu-item" (click)="exportToJson(); activeContextMenu.set(null)">
3047
+ <span class="menu-icon">📄</span> Export to JSON
3048
+ </button>
3049
+ <button class="menu-item" (click)="exportToCsv(); activeContextMenu.set(null)">
3050
+ <span class="menu-icon">📊</span> Export to CSV
3051
+ </button>
3052
+ </div>
3053
+ }
3054
+ </div>
3055
+ `, styles: [":host{display:block}.ngx-data-grid{position:relative;font-family:inherit;border:1px solid var(--ngx-grid-border, #e2e8f0);border-radius:var(--ngx-grid-radius, 12px);overflow:visible;background:var(--ngx-grid-bg, #ffffff);box-shadow:0 4px 6px -1px #0000000d,0 2px 4px -2px #0000000d;transition:background-color .3s,border-color .3s,box-shadow .3s}.grid-toolbar{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;background:var(--ngx-grid-header-bg, #f8fafc);border-bottom:1px solid var(--ngx-grid-border, #e2e8f0);border-radius:var(--ngx-grid-radius, 12px) var(--ngx-grid-radius, 12px) 0 0;flex-wrap:wrap;gap:12px}.grid-toolbar-title{font-family:var(--ngx-heading-font-family, \"Outfit\", sans-serif);font-weight:700;font-size:14px;color:var(--ngx-grid-text, #0f172a)}.grid-toolbar-actions{display:flex;gap:6px}.grid-action-btn{padding:6px 14px;border:1px solid var(--ngx-grid-border, #e2e8f0);border-radius:8px;background:var(--ngx-grid-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);font-size:12px;font-weight:500;cursor:pointer;font-family:inherit;transition:all .2s cubic-bezier(.4,0,.2,1);outline:none}.grid-action-btn:hover{background:var(--ngx-grid-hover-bg, #f1f5f9);border-color:var(--ngx-input-border, #cbd5e1);transform:translateY(-.5px)}.grid-action-btn:active{transform:scale(.97)}.grid-table-wrap{overflow-x:auto;overflow-y:hidden}.grid-table{width:100%;border-collapse:collapse;font-size:13px;table-layout:fixed}.grid-th{position:relative;padding:12px 16px;text-align:left;font-size:11px;font-weight:700;color:var(--ngx-grid-text-secondary, #64748b);background:var(--ngx-grid-header-bg, #f8fafc);border-bottom:2px solid var(--ngx-grid-border, #e2e8f0);white-space:nowrap;-webkit-user-select:none;user-select:none;text-transform:uppercase;letter-spacing:.05em;font-family:var(--ngx-heading-font-family, \"Outfit\", sans-serif)}.grid-category-th{text-align:center;border-bottom:1px solid var(--ngx-grid-border, #e2e8f0);border-right:1px solid var(--ngx-grid-border, #e2e8f0)}.sub-header-row .grid-th{border-bottom:2px solid var(--ngx-grid-border, #e2e8f0);border-right:1px solid var(--ngx-grid-border, #f1f5f9)}.grid-th.sortable{cursor:pointer;transition:background-color .2s}.grid-th.sortable:hover{background:var(--ngx-grid-hover-bg, #f1f5f9)}.grid-th.sort-asc,.grid-th.sort-desc{color:var(--ngx-input-focus, #4f46e5)}.th-text{margin-right:4px}.sort-icon{font-size:10px;color:#cbd5e1}.sort-asc .sort-icon,.sort-desc .sort-icon{color:var(--ngx-input-focus, #4f46e5)}.th-content-wrapper{display:flex;align-items:center;justify-content:space-between;gap:6px;width:100%}.grid-filter-btn{background:transparent;border:none;color:var(--ngx-grid-text-secondary, #64748b);cursor:pointer;padding:2px;border-radius:4px;display:flex;align-items:center;justify-content:center;transition:all .2s}.grid-filter-btn:hover{background:var(--ngx-grid-hover-bg, #e2e8f0);color:var(--ngx-grid-text, #0f172a)}.grid-filter-btn.active{color:var(--ngx-input-focus, #4f46e5);background:#4f46e51a}.grid-resize-handle{position:absolute;right:0;top:0;bottom:0;width:6px;cursor:col-resize;background:transparent;z-index:10;transition:background-color .2s}.grid-resize-handle:hover,.grid-resize-handle.resizing{background:var(--ngx-input-focus, #4f46e5)}.grid-filter-popover,.grid-column-chooser-popover{position:absolute;width:250px;background:var(--ngx-grid-bg, #ffffff);border:1px solid var(--ngx-grid-border, #e2e8f0);border-radius:12px;box-shadow:0 10px 25px -5px #0000001a,0 8px 10px -6px #0000001a;z-index:1000;padding:12px;box-sizing:border-box;display:flex;flex-direction:column;gap:12px;font-family:inherit}.popover-section{display:flex;flex-direction:column;gap:6px}.popover-label{font-size:11px;font-weight:700;color:var(--ngx-grid-text-secondary, #64748b);text-transform:uppercase;letter-spacing:.05em}.text-filter-row{display:flex;flex-direction:column;gap:6px}.popover-select{padding:6px;border:1px solid var(--ngx-grid-border, #cbd5e1);border-radius:6px;font-size:12px;font-family:inherit;outline:none;background:var(--ngx-input-bg, #ffffff);color:var(--ngx-grid-text, #0f172a)}.popover-input{padding:6px 10px;border:1px solid var(--ngx-grid-border, #cbd5e1);border-radius:6px;font-size:12px;font-family:inherit;outline:none;background:var(--ngx-input-bg, #ffffff);color:var(--ngx-grid-text, #0f172a)}.checklist-section{border-top:1px solid var(--ngx-grid-border, #e2e8f0);padding-top:10px}.checklist-scroll{max-height:120px;overflow-y:auto;display:flex;flex-direction:column;gap:4px;border:1px solid var(--ngx-grid-border, #e2e8f0);border-radius:6px;padding:6px}.checklist-item{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--ngx-grid-text, #0f172a);cursor:pointer;-webkit-user-select:none;user-select:none}.checklist-item input{margin:0}.popover-footer{display:flex;justify-content:space-between;align-items:center;border-top:1px solid var(--ngx-grid-border, #e2e8f0);padding-top:10px;margin-top:4px}.footer-actions{display:flex;gap:6px}.popover-btn{padding:5px 10px;font-size:11px;font-weight:600;border-radius:6px;cursor:pointer;border:1px solid var(--ngx-grid-border, #cbd5e1);background:var(--ngx-grid-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);transition:all .2s}.popover-btn:hover{background:var(--ngx-grid-hover-bg, #f1f5f9)}.popover-btn.apply{background:var(--ngx-btn-primary-bg, #4f46e5);color:#fff;border-color:var(--ngx-btn-primary-bg, #4f46e5)}.popover-btn.apply:hover{background:var(--ngx-btn-primary-hover, #4338ca);border-color:var(--ngx-btn-primary-hover, #4338ca)}.popover-btn.clear{color:#ef4444;border-color:transparent;background:transparent}.popover-btn.clear:hover{background:#fef2f2}.grid-group-row td{background:var(--ngx-grid-header-bg, #f8fafc);border-bottom:1.5px solid var(--ngx-grid-border, #e2e8f0);color:var(--ngx-grid-text, #0f172a);font-size:12px;font-weight:600;padding:11px 16px;cursor:pointer}.group-toggle{border:none;background:transparent;margin-right:6px;cursor:pointer;color:var(--ngx-grid-text-secondary, #64748b);font-size:12px}.group-count{color:var(--ngx-grid-text-secondary, #64748b);margin-left:6px;font-weight:500}.grid-row{border-bottom:1px solid var(--ngx-grid-border, #e2e8f0);transition:background-color .15s}.grid-row:hover{background:var(--ngx-grid-hover-bg, #f1f5f9)}.grid-row.selected{background:var(--ngx-grid-selected-bg, #e0e7ff)!important}.grid-table.striped .grid-row:nth-child(2n){background:var(--ngx-grid-stripe-bg, #f8fafc)}.grid-table.striped .grid-row:nth-child(2n):hover{background:var(--ngx-grid-hover-bg, #f1f5f9)}.grid-table.striped .grid-row.selected{background:var(--ngx-grid-selected-bg, #e0e7ff)!important}.grid-td{padding:11px 16px;color:var(--ngx-grid-text, #0f172a);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;vertical-align:middle;box-sizing:border-box}.grid-th-check,.grid-td-check,.grid-th-toggle,.grid-td-toggle{width:44px!important;text-align:center}.toggle-btn{border:none;background:transparent;color:var(--ngx-grid-text-secondary, #64748b);cursor:pointer;font-size:13px;transition:color .15s}.toggle-btn:hover{color:var(--ngx-grid-text, #0f172a)}.grid-detail-row td{background:var(--ngx-grid-stripe-bg, #f8fafc);border-bottom:1px solid var(--ngx-grid-border, #e2e8f0)}.grid-detail-cell{padding:16px 24px;white-space:normal}.grid-edit-input{width:100%;min-width:80px;padding:6px 10px;border:1px solid var(--ngx-grid-border, #cbd5e1);border-radius:6px;font-size:12px;font-family:inherit;background:var(--ngx-input-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);box-sizing:border-box;outline:none;transition:border-color .2s,box-shadow .2s}.grid-edit-input:focus{border-color:var(--ngx-input-focus, #4f46e5);box-shadow:0 0 0 3px var(--primary-glow, rgba(79, 70, 229, .15))}.grid-actions{white-space:nowrap}.action-btn{border:1px solid var(--ngx-grid-border, #cbd5e1);background:var(--ngx-grid-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);border-radius:6px;padding:5px 10px;font-size:12px;font-weight:500;margin-right:6px;cursor:pointer;transition:all .2s;outline:none}.action-btn:hover{background:var(--ngx-grid-hover-bg, #f1f5f9);border-color:var(--ngx-input-border, #cbd5e1)}.action-btn.save{border-color:var(--ngx-btn-primary-bg, #4f46e5);background:var(--ngx-btn-primary-bg, #4f46e5);color:#fff}.action-btn.save:hover{background:var(--ngx-btn-primary-hover, #4338ca);border-color:var(--ngx-btn-primary-hover, #4338ca)}.action-btn:last-child{margin-right:0}.grid-loading-cell,.grid-empty-cell{padding:48px;text-align:center;color:var(--ngx-grid-text-secondary, #64748b);font-weight:500}.grid-spinner{width:28px;height:28px;border:3.5px solid var(--ngx-grid-border, #e2e8f0);border-top-color:var(--ngx-btn-primary-bg, #4f46e5);border-radius:50%;animation:spin .8s cubic-bezier(.4,0,.2,1) infinite;margin:0 auto}@keyframes spin{to{transform:rotate(360deg)}}.grid-pagination{display:flex;align-items:center;justify-content:space-between;padding:10px 16px;border-top:1px solid var(--ngx-grid-border, #e2e8f0);background:var(--ngx-grid-bg, #ffffff);border-radius:0 0 var(--ngx-grid-radius, 12px) var(--ngx-grid-radius, 12px);flex-wrap:wrap;gap:8px}.page-info{font-size:12px;color:var(--ngx-grid-text-secondary, #64748b);font-weight:500}.page-btns{display:flex;gap:4px}.page-btn{min-width:32px;height:32px;padding:0 8px;font-size:12px;font-weight:500;border:1px solid var(--ngx-grid-border, #e2e8f0);background:var(--ngx-grid-bg, #ffffff);border-radius:8px;cursor:pointer;font-family:inherit;color:var(--ngx-grid-text, #0f172a);transition:all .2s;outline:none}.page-btn:hover:not(:disabled){background:var(--ngx-grid-hover-bg, #f1f5f9);border-color:var(--ngx-input-border, #cbd5e1)}.page-btn.active{background:var(--ngx-btn-primary-bg, #4f46e5);color:#fff;border-color:var(--ngx-btn-primary-bg, #4f46e5);box-shadow:0 2px 4px #4f46e533}.page-btn:disabled{opacity:.4;cursor:not-allowed}.grid-footer-row td{background:var(--ngx-grid-header-bg, #f8fafc);border-top:2px solid var(--ngx-grid-border, #e2e8f0);font-size:12px;padding:12px 16px;color:var(--ngx-grid-text, #0f172a)}.agg-label{font-size:10px;font-weight:700;color:var(--ngx-grid-text-secondary, #64748b);text-transform:uppercase;letter-spacing:.05em}.agg-value{font-weight:700;color:var(--ngx-input-focus, #4f46e5)}.pinned-left{position:sticky!important;z-index:2;background:var(--ngx-grid-bg, #ffffff)}th.pinned-left{z-index:4;background:var(--ngx-grid-header-bg, #f8fafc)}.sticky-toggle{position:sticky!important;left:0;z-index:3;background:var(--ngx-grid-bg, #ffffff)}th.sticky-toggle{z-index:5;background:var(--ngx-grid-header-bg, #f8fafc)}.sticky-check{position:sticky!important;z-index:3;background:var(--ngx-grid-bg, #ffffff)}th.sticky-check{z-index:5;background:var(--ngx-grid-header-bg, #f8fafc)}.pinned-left-last,.sticky-toggle-last,.sticky-check-last{border-right:1px solid var(--ngx-grid-border, #cbd5e1)!important;box-shadow:4px 0 8px -3px #00000026}.grid-table.striped .grid-row:nth-child(2n) .pinned-left,.grid-table.striped .grid-row:nth-child(2n) .sticky-toggle,.grid-table.striped .grid-row:nth-child(2n) .sticky-check{background:var(--ngx-grid-stripe-bg, #f8fafc)}.grid-row:hover .pinned-left,.grid-row:hover .sticky-toggle,.grid-row:hover .sticky-check{background:var(--ngx-grid-hover-bg, #f1f5f9)!important}.grid-row.selected .pinned-left,.grid-row.selected .sticky-toggle,.grid-row.selected .sticky-check{background:var(--ngx-grid-selected-bg, #e0e7ff)!important}.grid-footer-row .pinned-left,.grid-footer-row .sticky-toggle,.grid-footer-row .sticky-check{background:var(--ngx-grid-header-bg, #f8fafc)}.pinned-right{position:sticky!important;z-index:2;background:var(--ngx-grid-bg, #ffffff)}th.pinned-right{z-index:4;background:var(--ngx-grid-header-bg, #f8fafc)}.pinned-right-first{border-left:1px solid var(--ngx-grid-border, #cbd5e1)!important;box-shadow:-4px 0 8px -3px #00000026}.grid-table.striped .grid-row:nth-child(2n) .pinned-right{background:var(--ngx-grid-stripe-bg, #f8fafc)}.grid-row:hover .pinned-right{background:var(--ngx-grid-hover-bg, #f1f5f9)!important}.grid-row.selected .pinned-right{background:var(--ngx-grid-selected-bg, #e0e7ff)!important}.grid-footer-row .pinned-right{background:var(--ngx-grid-header-bg, #f8fafc)}.grid-td.cell-focused{outline:2px solid var(--ngx-input-focus, #4f46e5)!important;outline-offset:-2px;z-index:5}.grid-td.cell-focused-editing{padding:0!important}.grid-td.cell-focused-editing .grid-edit-input{width:100%;height:100%;border:none;outline:none;padding:12px 16px;box-sizing:border-box;background:var(--ngx-grid-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);font-family:inherit;font-size:inherit}.grid-th[draggable=true]{cursor:grab}.grid-th[draggable=true]:active{cursor:grabbing}.grid-th.dragging{opacity:.4;background:var(--ngx-grid-hover-bg, #f1f5f9)!important;border:1.5px dashed var(--ngx-input-border, #cbd5e1)}.grid-th.drag-over{border-left:3px solid var(--ngx-input-focus, #4f46e5)!important}.sort-icon.active{color:var(--ngx-input-focus, #4f46e5);font-weight:700}.sort-order-badge{font-size:8px;line-height:1;background:var(--ngx-input-focus, #4f46e5);color:#fff;padding:1px 3.5px;border-radius:4px;vertical-align:super;margin-left:2px}.grid-search-wrap{position:relative;display:inline-flex;align-items:center}.grid-search-input{padding:6px 30px 6px 12px;border:1px solid var(--ngx-grid-border, #cbd5e1);border-radius:8px;font-size:13px;font-family:inherit;background:var(--ngx-input-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);outline:none;transition:all .2s cubic-bezier(.4,0,.2,1);width:180px}.grid-search-input:focus{border-color:var(--ngx-input-focus, #4f46e5);box-shadow:0 0 0 3px var(--primary-glow, rgba(79, 70, 229, .15));width:220px}.grid-search-clear{position:absolute;right:8px;background:transparent;border:none;color:var(--ngx-grid-text-secondary, #94a3b8);font-size:16px;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:2px;line-height:1}.grid-search-clear:hover{color:var(--ngx-grid-text, #0f172a)}.search-highlight{background-color:#fbbf244d;color:inherit;font-weight:600;padding:1px 2px;border-radius:4px}.grid-td.cell-selected{background:var(--ngx-grid-cell-selected-bg, rgba(79, 70, 229, .12))!important;outline:1.5px solid var(--ngx-grid-cell-selected-border, #4f46e5);outline-offset:-1.5px}.row-drag-handle{cursor:grab;-webkit-user-select:none;user-select:none;color:var(--ngx-grid-text-secondary, #94a3b8);font-size:15px;font-weight:700;display:inline-block;padding:4px 8px;transition:color .15s ease}.row-drag-handle:hover{color:var(--ngx-grid-text, #0f172a)}.row-drag-handle:active{cursor:grabbing}.grid-row.dragging-row{opacity:.4;background:var(--ngx-grid-hover-bg, #f1f5f9)!important;border:1.5px dashed var(--ngx-input-border, #cbd5e1)}.grid-row.drag-over-row{border-top:2px solid var(--ngx-input-focus, #4f46e5)!important}.grid-context-menu{position:absolute;width:180px;background:var(--ngx-grid-bg, rgba(255, 255, 255, .95));backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);border:1px solid var(--ngx-grid-border, #e2e8f0);border-radius:10px;box-shadow:0 10px 25px -5px #0000001a,0 8px 10px -6px #0000001a;z-index:2000;padding:6px;box-sizing:border-box;display:flex;flex-direction:column;gap:2px;font-family:inherit}.menu-item{display:flex;align-items:center;gap:8px;padding:8px 10px;border:none;background:transparent;color:var(--ngx-grid-text, #0f172a);font-size:12px;font-weight:500;cursor:pointer;text-align:left;border-radius:6px;transition:all .15s ease;font-family:inherit;width:100%;box-sizing:border-box;outline:none}.menu-item:hover:not(:disabled){background:var(--ngx-grid-hover-bg, #f1f5f9);color:var(--ngx-btn-primary-bg, #4f46e5)}.menu-item:disabled{opacity:.4;cursor:not-allowed}.menu-icon{font-size:14px;width:16px;text-align:center}.menu-divider{height:1px;background:var(--ngx-grid-border, #e2e8f0);margin:4px 6px}\n"] }]
3056
+ }], ctorParameters: () => [], propDecorators: { cellTemplates: [{
3057
+ type: ContentChildren,
3058
+ args: [NgxGridCellTemplateDirective]
3059
+ }], editCellTemplates: [{
3060
+ type: ContentChildren,
3061
+ args: [NgxGridEditCellTemplateDirective]
3062
+ }], headerTemplates: [{
3063
+ type: ContentChildren,
3064
+ args: [NgxGridHeaderTemplateDirective]
3065
+ }], footerTemplates: [{
3066
+ type: ContentChildren,
3067
+ args: [NgxGridFooterTemplateDirective]
3068
+ }], handleKeyDown: [{
3069
+ type: HostListener,
3070
+ args: ['keydown', ['$event']]
3071
+ }] } });
3072
+
3073
+ class PivotGridComponent {
3074
+ data = input([]);
3075
+ rows = input([]);
3076
+ columns = input([]);
3077
+ values = input([{ field: 'value', aggregate: 'sum' }]);
3078
+ emptyValue = input('-');
3079
+ pivotColumns = computed(() => {
3080
+ const keys = new Map();
3081
+ for (const item of this.data()) {
3082
+ const key = this.keyFor(item, this.columns());
3083
+ keys.set(key, this.labelFor(item, this.columns()));
3084
+ }
3085
+ return Array.from(keys, ([key, label]) => ({ key, label }));
3086
+ });
3087
+ pivotRows = computed(() => {
3088
+ const rows = new Map();
3089
+ for (const item of this.data()) {
3090
+ const key = this.keyFor(item, this.rows());
3091
+ if (!rows.has(key)) {
3092
+ rows.set(key, { key, label: this.labelFor(item, this.rows()), values: item });
3093
+ }
3094
+ }
3095
+ return Array.from(rows.values());
3096
+ });
3097
+ rowHeaderLabel() {
3098
+ return this.rows().join(' / ') || 'Rows';
3099
+ }
3100
+ aggregateCell(row, column, value) {
3101
+ const items = this.data().filter(item => this.keyFor(item, this.rows()) === row.key && this.keyFor(item, this.columns()) === column.key);
3102
+ if (!items.length)
3103
+ return this.emptyValue();
3104
+ const aggregate = value.aggregate ?? 'sum';
3105
+ if (aggregate === 'count')
3106
+ return items.length;
3107
+ const numbers = items.map(item => Number(item[value.field])).filter(item => Number.isFinite(item));
3108
+ if (!numbers.length)
3109
+ return this.emptyValue();
3110
+ if (aggregate === 'avg')
3111
+ return this.round(numbers.reduce((sum, item) => sum + item, 0) / numbers.length);
3112
+ if (aggregate === 'min')
3113
+ return Math.min(...numbers);
3114
+ if (aggregate === 'max')
3115
+ return Math.max(...numbers);
3116
+ return this.round(numbers.reduce((sum, item) => sum + item, 0));
3117
+ }
3118
+ keyFor(item, fields) {
3119
+ return fields.map(field => String(item[field] ?? '')).join('||') || '__total__';
3120
+ }
3121
+ labelFor(item, fields) {
3122
+ return fields.map(field => String(item[field] ?? '')).filter(Boolean).join(' / ') || 'Total';
3123
+ }
3124
+ round(value) {
3125
+ return Math.round(value * 100) / 100;
3126
+ }
3127
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: PivotGridComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
3128
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.20", type: PivotGridComponent, isStandalone: true, selector: "ngx-pivot-grid", inputs: { data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, rows: { classPropertyName: "rows", publicName: "rows", isSignal: true, isRequired: false, transformFunction: null }, columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: false, transformFunction: null }, values: { classPropertyName: "values", publicName: "values", isSignal: true, isRequired: false, transformFunction: null }, emptyValue: { classPropertyName: "emptyValue", publicName: "emptyValue", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: `
3129
+ <div class="ngx-pivot-grid">
3130
+ <table>
3131
+ <thead>
3132
+ <tr>
3133
+ <th class="row-header">{{ rowHeaderLabel() }}</th>
3134
+ @for (column of pivotColumns(); track column.key) {
3135
+ @for (value of values(); track value.field) {
3136
+ <th>{{ column.label }}@if (values().length > 1) { <span> / {{ value.label || value.field }}</span> }</th>
3137
+ }
3138
+ }
3139
+ </tr>
3140
+ </thead>
3141
+ <tbody>
3142
+ @for (row of pivotRows(); track row.key) {
3143
+ <tr>
3144
+ <th class="row-label">{{ row.label }}</th>
3145
+ @for (column of pivotColumns(); track column.key) {
3146
+ @for (value of values(); track value.field) {
3147
+ <td>{{ aggregateCell(row, column, value) }}</td>
3148
+ }
3149
+ }
3150
+ </tr>
3151
+ }
3152
+ </tbody>
3153
+ </table>
3154
+ </div>
3155
+ `, isInline: true, styles: [":host{display:block}.ngx-pivot-grid{width:100%;overflow:auto;border:1px solid var(--border-color, #dbe3ee);border-radius:8px;background:var(--bg-secondary, #ffffff)}table{width:100%;border-collapse:collapse;min-width:520px;font-family:var(--ngx-font-family, inherit);font-size:13px;color:var(--text-primary, #0f172a)}th,td{padding:10px 12px;border-bottom:1px solid var(--border-light, #edf2f7);border-right:1px solid var(--border-light, #edf2f7);text-align:right;white-space:nowrap}thead th{position:sticky;top:0;z-index:1;background:var(--border-light, #f8fafc);color:var(--text-secondary, #475569);font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:.4px}thead th span{color:var(--text-primary, #0f172a)}.row-header,.row-label{position:sticky;left:0;z-index:2;text-align:left;background:var(--bg-secondary, #ffffff)}thead .row-header{z-index:3;background:var(--border-light, #f8fafc)}tbody tr:hover td,tbody tr:hover .row-label{background:var(--primary-glow, rgba(79, 70, 229, .04))}tr:last-child th,tr:last-child td{border-bottom:none}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }] });
3156
+ }
3157
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: PivotGridComponent, decorators: [{
3158
+ type: Component,
3159
+ args: [{ selector: 'ngx-pivot-grid', standalone: true, imports: [CommonModule], template: `
3160
+ <div class="ngx-pivot-grid">
3161
+ <table>
3162
+ <thead>
3163
+ <tr>
3164
+ <th class="row-header">{{ rowHeaderLabel() }}</th>
3165
+ @for (column of pivotColumns(); track column.key) {
3166
+ @for (value of values(); track value.field) {
3167
+ <th>{{ column.label }}@if (values().length > 1) { <span> / {{ value.label || value.field }}</span> }</th>
3168
+ }
3169
+ }
3170
+ </tr>
3171
+ </thead>
3172
+ <tbody>
3173
+ @for (row of pivotRows(); track row.key) {
3174
+ <tr>
3175
+ <th class="row-label">{{ row.label }}</th>
3176
+ @for (column of pivotColumns(); track column.key) {
3177
+ @for (value of values(); track value.field) {
3178
+ <td>{{ aggregateCell(row, column, value) }}</td>
3179
+ }
3180
+ }
3181
+ </tr>
3182
+ }
3183
+ </tbody>
3184
+ </table>
1004
3185
  </div>
1005
- `, styles: [":host{display:block}.ngx-data-grid{font-family:inherit;border:1px solid var(--ngx-grid-border, #e2e8f0);border-radius:var(--ngx-grid-radius, 12px);overflow:hidden;background:var(--ngx-grid-bg, #ffffff);box-shadow:0 4px 6px -1px #0000000d,0 2px 4px -2px #0000000d;transition:background-color .3s,border-color .3s,box-shadow .3s}.grid-toolbar{display:flex;justify-content:space-between;align-items:center;padding:12px 16px;background:var(--ngx-grid-header-bg, #f8fafc);border-bottom:1px solid var(--ngx-grid-border, #e2e8f0);flex-wrap:wrap;gap:12px}.grid-toolbar-title{font-family:var(--ngx-heading-font-family, \"Outfit\", sans-serif);font-weight:700;font-size:14px;color:var(--ngx-grid-text, #0f172a)}.grid-toolbar-actions{display:flex;gap:6px}.grid-action-btn{padding:6px 14px;border:1px solid var(--ngx-grid-border, #e2e8f0);border-radius:8px;background:var(--ngx-grid-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);font-size:12px;font-weight:500;cursor:pointer;font-family:inherit;transition:all .2s cubic-bezier(.4,0,.2,1);outline:none}.grid-action-btn:hover{background:var(--ngx-grid-hover-bg, #f1f5f9);border-color:var(--ngx-input-border, #cbd5e1);transform:translateY(-.5px)}.grid-action-btn:active{transform:scale(.97)}.grid-filter-bar{display:flex;gap:8px;padding:10px 16px;background:var(--ngx-grid-header-bg, #f8fafc);border-bottom:1px solid var(--ngx-grid-border, #e2e8f0)}.grid-filter-input{padding:6px 12px;border:1px solid var(--ngx-grid-border, #cbd5e1);border-radius:8px;font-size:12px;outline:none;font-family:inherit;background:var(--ngx-input-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);transition:border-color .2s,box-shadow .2s}.grid-filter-input:focus{border-color:var(--ngx-input-focus, #4f46e5);box-shadow:0 0 0 3px var(--primary-glow, rgba(79, 70, 229, .15))}.grid-filter-spacer{flex-shrink:0}.grid-table-wrap{overflow-x:auto}.grid-table{width:100%;border-collapse:collapse;font-size:13px}.grid-th{padding:12px 16px;text-align:left;font-size:11px;font-weight:700;color:var(--ngx-grid-text-secondary, #64748b);background:var(--ngx-grid-header-bg, #f8fafc);border-bottom:2px solid var(--ngx-grid-border, #e2e8f0);white-space:nowrap;-webkit-user-select:none;user-select:none;text-transform:uppercase;letter-spacing:.05em;font-family:var(--ngx-heading-font-family, \"Outfit\", sans-serif)}.grid-th.sortable{cursor:pointer;transition:background-color .2s}.grid-th.sortable:hover{background:var(--ngx-grid-hover-bg, #f1f5f9)}.grid-th.sort-asc,.grid-th.sort-desc{color:var(--ngx-input-focus, #4f46e5)}.th-text{margin-right:4px}.sort-icon{font-size:10px;color:#cbd5e1}.sort-asc .sort-icon,.sort-desc .sort-icon{color:var(--ngx-input-focus, #4f46e5)}.grid-group-row td{background:var(--ngx-grid-header-bg, #f8fafc);border-bottom:1.5px solid var(--ngx-grid-border, #e2e8f0);color:var(--ngx-grid-text, #0f172a);font-size:12px;font-weight:600;padding:11px 16px;cursor:pointer}.group-toggle{border:none;background:transparent;margin-right:6px;cursor:pointer;color:var(--ngx-grid-text-secondary, #64748b);font-size:12px}.group-count{color:var(--ngx-grid-text-secondary, #64748b);margin-left:6px;font-weight:500}.grid-row{border-bottom:1px solid var(--ngx-grid-border, #e2e8f0);transition:background-color .15s}.grid-row:hover{background:var(--ngx-grid-hover-bg, #f1f5f9)}.grid-row.selected{background:var(--ngx-grid-selected-bg, #e0e7ff)!important}.grid-table.striped .grid-row:nth-child(2n){background:var(--ngx-grid-stripe-bg, #f8fafc)}.grid-table.striped .grid-row:nth-child(2n):hover{background:var(--ngx-grid-hover-bg, #f1f5f9)}.grid-table.striped .grid-row.selected{background:var(--ngx-grid-selected-bg, #e0e7ff)!important}.grid-td{padding:11px 16px;color:var(--ngx-grid-text, #0f172a);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;vertical-align:middle}.grid-th-check,.grid-td-check,.grid-th-toggle,.grid-td-toggle{width:44px!important;text-align:center}.toggle-btn{border:none;background:transparent;color:var(--ngx-grid-text-secondary, #64748b);cursor:pointer;font-size:13px;transition:color .15s}.toggle-btn:hover{color:var(--ngx-grid-text, #0f172a)}.grid-detail-row td{background:var(--ngx-grid-stripe-bg, #f8fafc);border-bottom:1px solid var(--ngx-grid-border, #e2e8f0)}.grid-detail-cell{padding:16px 24px;white-space:normal}.grid-edit-input{width:100%;min-width:80px;padding:6px 10px;border:1px solid var(--ngx-grid-border, #cbd5e1);border-radius:6px;font-size:12px;font-family:inherit;background:var(--ngx-input-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);box-sizing:border-box;outline:none;transition:border-color .2s,box-shadow .2s}.grid-edit-input:focus{border-color:var(--ngx-input-focus, #4f46e5);box-shadow:0 0 0 3px var(--primary-glow, rgba(79, 70, 229, .15))}.grid-actions{white-space:nowrap}.action-btn{border:1px solid var(--ngx-grid-border, #cbd5e1);background:var(--ngx-grid-bg, #ffffff);color:var(--ngx-grid-text, #0f172a);border-radius:6px;padding:5px 10px;font-size:12px;font-weight:500;margin-right:6px;cursor:pointer;transition:all .2s;outline:none}.action-btn:hover{background:var(--ngx-grid-hover-bg, #f1f5f9);border-color:var(--ngx-input-border, #cbd5e1)}.action-btn.save{border-color:var(--ngx-btn-primary-bg, #4f46e5);background:var(--ngx-btn-primary-bg, #4f46e5);color:#fff}.action-btn.save:hover{background:var(--ngx-btn-primary-hover, #4338ca);border-color:var(--ngx-btn-primary-hover, #4338ca)}.action-btn:last-child{margin-right:0}.grid-loading-cell,.grid-empty-cell{padding:48px;text-align:center;color:var(--ngx-grid-text-secondary, #64748b);font-weight:500}.grid-spinner{width:28px;height:28px;border:3.5px solid var(--ngx-grid-border, #e2e8f0);border-top-color:var(--ngx-btn-primary-bg, #4f46e5);border-radius:50%;animation:spin .8s cubic-bezier(.4,0,.2,1) infinite;margin:0 auto}@keyframes spin{to{transform:rotate(360deg)}}.grid-pagination{display:flex;align-items:center;justify-content:space-between;padding:10px 16px;border-top:1px solid var(--ngx-grid-border, #e2e8f0);background:var(--ngx-grid-bg, #ffffff);flex-wrap:wrap;gap:8px}.page-info{font-size:12px;color:var(--ngx-grid-text-secondary, #64748b);font-weight:500}.page-btns{display:flex;gap:4px}.page-btn{min-width:32px;height:32px;padding:0 8px;font-size:12px;font-weight:500;border:1px solid var(--ngx-grid-border, #e2e8f0);background:var(--ngx-grid-bg, #ffffff);border-radius:8px;cursor:pointer;font-family:inherit;color:var(--ngx-grid-text, #0f172a);transition:all .2s;outline:none}.page-btn:hover:not(:disabled){background:var(--ngx-grid-hover-bg, #f1f5f9);border-color:var(--ngx-input-border, #cbd5e1)}.page-btn.active{background:var(--ngx-btn-primary-bg, #4f46e5);color:#fff;border-color:var(--ngx-btn-primary-bg, #4f46e5);box-shadow:0 2px 4px #4f46e533}.page-btn:disabled{opacity:.4;cursor:not-allowed}\n"] }]
1006
- }], ctorParameters: () => [] });
3186
+ `, styles: [":host{display:block}.ngx-pivot-grid{width:100%;overflow:auto;border:1px solid var(--border-color, #dbe3ee);border-radius:8px;background:var(--bg-secondary, #ffffff)}table{width:100%;border-collapse:collapse;min-width:520px;font-family:var(--ngx-font-family, inherit);font-size:13px;color:var(--text-primary, #0f172a)}th,td{padding:10px 12px;border-bottom:1px solid var(--border-light, #edf2f7);border-right:1px solid var(--border-light, #edf2f7);text-align:right;white-space:nowrap}thead th{position:sticky;top:0;z-index:1;background:var(--border-light, #f8fafc);color:var(--text-secondary, #475569);font-size:11px;font-weight:800;text-transform:uppercase;letter-spacing:.4px}thead th span{color:var(--text-primary, #0f172a)}.row-header,.row-label{position:sticky;left:0;z-index:2;text-align:left;background:var(--bg-secondary, #ffffff)}thead .row-header{z-index:3;background:var(--border-light, #f8fafc)}tbody tr:hover td,tbody tr:hover .row-label{background:var(--primary-glow, rgba(79, 70, 229, .04))}tr:last-child th,tr:last-child td{border-bottom:none}\n"] }]
3187
+ }] });
1007
3188
 
1008
3189
  /*
1009
3190
  * Public API Surface — secondary entry point: ngx-core-components/grid
@@ -1013,5 +3194,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
1013
3194
  * Generated bundle index. Do not edit.
1014
3195
  */
1015
3196
 
1016
- export { DataGridComponent };
3197
+ export { DataGridComponent, NgxGridCellTemplateDirective, NgxGridEditCellTemplateDirective, NgxGridFooterTemplateDirective, NgxGridHeaderTemplateDirective, PivotGridComponent };
1017
3198
  //# sourceMappingURL=ngx-core-components-grid.mjs.map