ngx-core-components 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +145 -0
- package/charts/gantt-chart/gantt-chart.component.d.ts +8 -1
- package/fesm2022/ngx-core-components-charts.mjs +235 -159
- package/fesm2022/ngx-core-components-charts.mjs.map +1 -1
- package/fesm2022/ngx-core-components-grid.mjs +740 -107
- package/fesm2022/ngx-core-components-grid.mjs.map +1 -1
- package/fesm2022/ngx-core-components-inputs.mjs +203 -60
- package/fesm2022/ngx-core-components-inputs.mjs.map +1 -1
- package/fesm2022/ngx-core-components-layout.mjs +48 -13
- package/fesm2022/ngx-core-components-layout.mjs.map +1 -1
- package/fesm2022/ngx-core-components-views.mjs +87 -15
- package/fesm2022/ngx-core-components-views.mjs.map +1 -1
- package/fesm2022/ngx-core-components.mjs.map +1 -1
- package/grid/data-grid/data-grid.component.d.ts +132 -14
- package/grid/public-api.d.ts +1 -1
- package/inputs/numeric-textbox/numeric-textbox.component.d.ts +6 -2
- package/inputs/time-picker/time-picker.component.d.ts +17 -7
- package/layout/splitter/splitter.component.d.ts +9 -2
- package/package.json +1 -1
- package/public-api.d.ts +2 -2
- package/views/list-view/list-view.component.d.ts +19 -1
- package/views/public-api.d.ts +1 -1
|
@@ -1,111 +1,401 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, output, signal, computed, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
2
|
+
import { input, output, signal, effect, computed, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
3
4
|
|
|
4
5
|
class DataGridComponent {
|
|
5
6
|
data = input([]);
|
|
6
7
|
columns = input([]);
|
|
7
8
|
pageSize = input(10);
|
|
9
|
+
page = input(1);
|
|
10
|
+
total = input(0);
|
|
8
11
|
selectable = input(false);
|
|
9
12
|
striped = input(true);
|
|
10
13
|
loading = input(false);
|
|
14
|
+
editable = input(false);
|
|
15
|
+
sortMode = input('client');
|
|
16
|
+
filterMode = input('client');
|
|
17
|
+
groupMode = input('client');
|
|
18
|
+
pagingMode = input('client');
|
|
19
|
+
groupBy = input(null);
|
|
20
|
+
groupedData = input([]);
|
|
21
|
+
headerTemplate = input(null);
|
|
22
|
+
cellTemplate = input(null);
|
|
23
|
+
rowTemplate = input(null);
|
|
24
|
+
detailRowTemplate = input(null);
|
|
11
25
|
rowClick = output();
|
|
12
26
|
selectionChange = output();
|
|
13
27
|
sortChange = output();
|
|
28
|
+
filterChange = output();
|
|
29
|
+
groupChange = output();
|
|
14
30
|
pageChange = output();
|
|
31
|
+
dataStateChange = output();
|
|
32
|
+
rowUpdate = output();
|
|
15
33
|
sortState = signal(null);
|
|
16
34
|
currentPage = signal(1);
|
|
17
35
|
selectedRows = signal(new Set());
|
|
36
|
+
expandedRows = signal(new Set());
|
|
37
|
+
collapsedGroups = signal(new Set());
|
|
38
|
+
editingRowKey = signal(null);
|
|
39
|
+
editingDraft = signal({});
|
|
18
40
|
filters = signal(new Map());
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
41
|
+
constructor() {
|
|
42
|
+
effect(() => {
|
|
43
|
+
const externalPage = this.page();
|
|
44
|
+
if (externalPage > 0 && externalPage !== this.currentPage()) {
|
|
45
|
+
this.currentPage.set(externalPage);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
effect(() => {
|
|
49
|
+
const max = this.totalPages();
|
|
50
|
+
if (this.currentPage() > max) {
|
|
51
|
+
this.currentPage.set(max);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
hasFilterableColumns = computed(() => this.columns().some(column => column.filterable));
|
|
56
|
+
isAnyServerMode = computed(() => this.sortMode() === 'server' ||
|
|
57
|
+
this.filterMode() === 'server' ||
|
|
58
|
+
this.groupMode() === 'server' ||
|
|
59
|
+
this.pagingMode() === 'server');
|
|
60
|
+
showDetailToggle = computed(() => this.detailRowTemplate() !== null);
|
|
61
|
+
activeFilters = computed(() => Array.from(this.filters().entries()).map(([field, value]) => ({ field, value, operator: 'contains' })));
|
|
62
|
+
clientFilteredData = computed(() => {
|
|
63
|
+
if (this.filterMode() !== 'client') {
|
|
64
|
+
return this.data();
|
|
65
|
+
}
|
|
66
|
+
let rows = this.data();
|
|
67
|
+
for (const filter of this.activeFilters()) {
|
|
68
|
+
if (!filter.value) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const query = filter.value.toLowerCase();
|
|
72
|
+
rows = rows.filter(row => String(row[filter.field] ?? '').toLowerCase().includes(query));
|
|
73
|
+
}
|
|
74
|
+
return rows;
|
|
75
|
+
});
|
|
76
|
+
clientSortedData = computed(() => {
|
|
77
|
+
const rows = this.clientFilteredData();
|
|
78
|
+
if (this.sortMode() !== 'client' || !this.sortState()) {
|
|
79
|
+
return rows;
|
|
80
|
+
}
|
|
81
|
+
const state = this.sortState();
|
|
82
|
+
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;
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
baseFlatData = computed(() => {
|
|
90
|
+
if (this.sortMode() === 'server' || this.filterMode() === 'server') {
|
|
91
|
+
return this.data();
|
|
92
|
+
}
|
|
93
|
+
return this.clientSortedData();
|
|
94
|
+
});
|
|
95
|
+
totalItems = computed(() => {
|
|
96
|
+
if (this.pagingMode() === 'server') {
|
|
97
|
+
return this.total() > 0 ? this.total() : this.data().length;
|
|
98
|
+
}
|
|
99
|
+
return this.baseFlatData().length;
|
|
100
|
+
});
|
|
101
|
+
totalPages = computed(() => {
|
|
102
|
+
const pageSize = Math.max(1, this.pageSize());
|
|
103
|
+
return Math.max(1, Math.ceil(this.totalItems() / pageSize));
|
|
104
|
+
});
|
|
105
|
+
flatRenderedRows = computed(() => {
|
|
106
|
+
if (this.hasGrouping()) {
|
|
107
|
+
return [];
|
|
108
|
+
}
|
|
109
|
+
if (this.pagingMode() === 'server') {
|
|
110
|
+
return this.data();
|
|
111
|
+
}
|
|
112
|
+
const pageSize = Math.max(1, this.pageSize());
|
|
113
|
+
const start = (this.currentPage() - 1) * pageSize;
|
|
114
|
+
return this.baseFlatData().slice(start, start + pageSize);
|
|
115
|
+
});
|
|
116
|
+
groupedRows = computed(() => {
|
|
117
|
+
if (!this.hasGrouping()) {
|
|
118
|
+
return [];
|
|
119
|
+
}
|
|
120
|
+
if (this.groupMode() === 'server') {
|
|
121
|
+
return this.groupedData();
|
|
122
|
+
}
|
|
123
|
+
const group = this.groupBy();
|
|
124
|
+
if (!group) {
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
const source = this.pagingMode() === 'server'
|
|
128
|
+
? this.data()
|
|
129
|
+
: this.paginateRows(this.baseFlatData());
|
|
130
|
+
const map = new Map();
|
|
131
|
+
for (const row of source) {
|
|
132
|
+
const value = row[group.field];
|
|
133
|
+
const key = String(value ?? '(empty)');
|
|
134
|
+
const existing = map.get(key);
|
|
135
|
+
if (existing) {
|
|
136
|
+
existing.items.push(row);
|
|
137
|
+
existing.count += 1;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
map.set(key, { key, value, field: group.field, count: 1, items: [row] });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const groups = Array.from(map.values());
|
|
144
|
+
groups.sort((a, b) => {
|
|
145
|
+
const compared = this.compareValues(a.value, b.value);
|
|
146
|
+
return (group.dir ?? 'asc') === 'asc' ? compared : -compared;
|
|
27
147
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
148
|
+
return groups;
|
|
149
|
+
});
|
|
150
|
+
allSelected = computed(() => {
|
|
151
|
+
const rows = this.visibleSelectionRows();
|
|
152
|
+
if (rows.length === 0) {
|
|
153
|
+
return false;
|
|
154
|
+
}
|
|
155
|
+
const selected = this.selectedRows();
|
|
156
|
+
return rows.every(row => selected.has(this.keyOf(row)));
|
|
157
|
+
});
|
|
158
|
+
someSelected = computed(() => {
|
|
159
|
+
const rows = this.visibleSelectionRows();
|
|
160
|
+
const selected = this.selectedRows();
|
|
161
|
+
return rows.some(row => selected.has(this.keyOf(row)));
|
|
162
|
+
});
|
|
163
|
+
pagerRangeStart = computed(() => {
|
|
164
|
+
if (this.totalItems() === 0) {
|
|
165
|
+
return 0;
|
|
166
|
+
}
|
|
167
|
+
return (this.currentPage() - 1) * this.pageSize() + 1;
|
|
38
168
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return this.filteredData().slice((p - 1) * sz, p * sz);
|
|
169
|
+
pagerRangeEnd = computed(() => {
|
|
170
|
+
if (this.totalItems() === 0) {
|
|
171
|
+
return 0;
|
|
172
|
+
}
|
|
173
|
+
return Math.min(this.currentPage() * this.pageSize(), this.totalItems());
|
|
45
174
|
});
|
|
46
175
|
pageNumbers = computed(() => {
|
|
47
176
|
const total = this.totalPages();
|
|
48
|
-
const
|
|
177
|
+
const current = this.currentPage();
|
|
49
178
|
const pages = [];
|
|
50
|
-
|
|
51
|
-
|
|
179
|
+
const from = Math.max(1, current - 2);
|
|
180
|
+
const to = Math.min(total, current + 2);
|
|
181
|
+
for (let page = from; page <= to; page += 1) {
|
|
182
|
+
pages.push(page);
|
|
183
|
+
}
|
|
52
184
|
return pages;
|
|
53
185
|
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
this.filters
|
|
186
|
+
renderColumnCount = computed(() => this.columns().length +
|
|
187
|
+
(this.selectable() ? 1 : 0) +
|
|
188
|
+
(this.showDetailToggle() ? 1 : 0) +
|
|
189
|
+
(this.editable() ? 1 : 0));
|
|
190
|
+
showPager = computed(() => this.totalItems() > 0);
|
|
191
|
+
getFilter(field) {
|
|
192
|
+
return this.filters().get(field) ?? '';
|
|
193
|
+
}
|
|
194
|
+
setFilter(field, value) {
|
|
195
|
+
const nextFilters = new Map(this.filters());
|
|
196
|
+
if (value) {
|
|
197
|
+
nextFilters.set(field, value);
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
nextFilters.delete(field);
|
|
201
|
+
}
|
|
202
|
+
this.filters.set(nextFilters);
|
|
64
203
|
this.currentPage.set(1);
|
|
204
|
+
const filters = this.activeFilters();
|
|
205
|
+
this.filterChange.emit({ filters });
|
|
206
|
+
this.emitDataState();
|
|
65
207
|
}
|
|
66
|
-
onSort(
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
this.sortState.set(
|
|
208
|
+
onSort(column) {
|
|
209
|
+
const current = this.sortState();
|
|
210
|
+
if (current?.field === column.field) {
|
|
211
|
+
this.sortState.set(current.dir === 'asc' ? { field: column.field, dir: 'desc' } : null);
|
|
70
212
|
}
|
|
71
213
|
else {
|
|
72
|
-
this.sortState.set({ field:
|
|
214
|
+
this.sortState.set({ field: column.field, dir: 'asc' });
|
|
73
215
|
}
|
|
74
216
|
this.currentPage.set(1);
|
|
75
217
|
this.sortChange.emit({ sort: this.sortState() });
|
|
218
|
+
this.emitDataState();
|
|
219
|
+
}
|
|
220
|
+
setGroup(state) {
|
|
221
|
+
this.groupChange.emit({ group: state });
|
|
222
|
+
this.currentPage.set(1);
|
|
223
|
+
this.emitDataState(state);
|
|
224
|
+
}
|
|
225
|
+
toggleGroup(key) {
|
|
226
|
+
const next = new Set(this.collapsedGroups());
|
|
227
|
+
if (next.has(key)) {
|
|
228
|
+
next.delete(key);
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
next.add(key);
|
|
232
|
+
}
|
|
233
|
+
this.collapsedGroups.set(next);
|
|
234
|
+
}
|
|
235
|
+
isGroupCollapsed(key) {
|
|
236
|
+
return this.collapsedGroups().has(key);
|
|
237
|
+
}
|
|
238
|
+
goPage(page) {
|
|
239
|
+
const safePage = Math.max(1, Math.min(this.totalPages(), page));
|
|
240
|
+
this.currentPage.set(safePage);
|
|
241
|
+
this.pageChange.emit({ page: safePage, pageSize: this.pageSize() });
|
|
242
|
+
this.emitDataState();
|
|
76
243
|
}
|
|
77
|
-
|
|
78
|
-
this.
|
|
79
|
-
|
|
244
|
+
onRowClick(row, index) {
|
|
245
|
+
this.rowClick.emit({ row, index });
|
|
246
|
+
}
|
|
247
|
+
isRowSelected(row) {
|
|
248
|
+
return this.selectedRows().has(this.keyOf(row));
|
|
80
249
|
}
|
|
81
|
-
onRowClick(row, index) { this.rowClick.emit({ row, index }); }
|
|
82
|
-
isRowSelected(row) { return this.selectedRows().has(row); }
|
|
83
250
|
toggleRow(row) {
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
251
|
+
const key = this.keyOf(row);
|
|
252
|
+
const next = new Set(this.selectedRows());
|
|
253
|
+
if (next.has(key)) {
|
|
254
|
+
next.delete(key);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
next.add(key);
|
|
258
|
+
}
|
|
259
|
+
this.selectedRows.set(next);
|
|
260
|
+
this.selectionChange.emit(this.resolveSelectedRows(next));
|
|
88
261
|
}
|
|
89
262
|
toggleAll() {
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
this.
|
|
93
|
-
|
|
94
|
-
|
|
263
|
+
const next = new Set(this.selectedRows());
|
|
264
|
+
const rows = this.visibleSelectionRows();
|
|
265
|
+
if (this.allSelected()) {
|
|
266
|
+
for (const row of rows) {
|
|
267
|
+
next.delete(this.keyOf(row));
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
for (const row of rows) {
|
|
272
|
+
next.add(this.keyOf(row));
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
this.selectedRows.set(next);
|
|
276
|
+
this.selectionChange.emit(this.resolveSelectedRows(next));
|
|
277
|
+
}
|
|
278
|
+
toggleDetail(row) {
|
|
279
|
+
const key = this.keyOf(row);
|
|
280
|
+
const next = new Set(this.expandedRows());
|
|
281
|
+
if (next.has(key)) {
|
|
282
|
+
next.delete(key);
|
|
283
|
+
}
|
|
284
|
+
else {
|
|
285
|
+
next.add(key);
|
|
286
|
+
}
|
|
287
|
+
this.expandedRows.set(next);
|
|
288
|
+
}
|
|
289
|
+
isExpanded(row) {
|
|
290
|
+
return this.expandedRows().has(this.keyOf(row));
|
|
291
|
+
}
|
|
292
|
+
beginEdit(row, _index) {
|
|
293
|
+
if (!this.editable()) {
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
const key = this.keyOf(row);
|
|
297
|
+
this.editingRowKey.set(key);
|
|
298
|
+
this.editingDraft.set({ ...row });
|
|
299
|
+
}
|
|
300
|
+
isEditing(row) {
|
|
301
|
+
return this.editingRowKey() === this.keyOf(row);
|
|
302
|
+
}
|
|
303
|
+
updateDraft(field, value) {
|
|
304
|
+
this.editingDraft.set({ ...this.editingDraft(), [field]: value });
|
|
305
|
+
}
|
|
306
|
+
getDraftValue(row, field) {
|
|
307
|
+
if (!this.isEditing(row)) {
|
|
308
|
+
return row[field];
|
|
309
|
+
}
|
|
310
|
+
const draft = this.editingDraft();
|
|
311
|
+
return Object.prototype.hasOwnProperty.call(draft, field)
|
|
312
|
+
? draft[field]
|
|
313
|
+
: row[field];
|
|
314
|
+
}
|
|
315
|
+
saveEdit(row, index) {
|
|
316
|
+
const updated = { ...row, ...this.editingDraft() };
|
|
317
|
+
this.rowUpdate.emit({ previous: row, updated, index });
|
|
318
|
+
this.cancelEdit();
|
|
319
|
+
}
|
|
320
|
+
cancelEdit() {
|
|
321
|
+
this.editingRowKey.set(null);
|
|
322
|
+
this.editingDraft.set({});
|
|
95
323
|
}
|
|
96
324
|
getCellValue(row, field) {
|
|
97
|
-
|
|
98
|
-
|
|
325
|
+
return row[field] ?? '';
|
|
326
|
+
}
|
|
327
|
+
resolveHeaderTemplate(column) {
|
|
328
|
+
return column.headerTemplate ?? this.headerTemplate();
|
|
329
|
+
}
|
|
330
|
+
resolveCellTemplate(column) {
|
|
331
|
+
return column.cellTemplate ?? this.cellTemplate();
|
|
332
|
+
}
|
|
333
|
+
toStringSafe(value) {
|
|
334
|
+
return value == null ? '' : String(value);
|
|
335
|
+
}
|
|
336
|
+
getKey(row, index) {
|
|
337
|
+
const source = row;
|
|
338
|
+
return String(source['id'] ?? source['key'] ?? index);
|
|
339
|
+
}
|
|
340
|
+
hasGrouping() {
|
|
341
|
+
return this.groupBy() !== null;
|
|
342
|
+
}
|
|
343
|
+
paginateRows(rows) {
|
|
344
|
+
if (this.pagingMode() === 'server') {
|
|
345
|
+
return rows;
|
|
346
|
+
}
|
|
347
|
+
const pageSize = Math.max(1, this.pageSize());
|
|
348
|
+
const start = (this.currentPage() - 1) * pageSize;
|
|
349
|
+
return rows.slice(start, start + pageSize);
|
|
350
|
+
}
|
|
351
|
+
compareValues(left, right) {
|
|
352
|
+
if (left == null && right == null) {
|
|
353
|
+
return 0;
|
|
354
|
+
}
|
|
355
|
+
if (left == null) {
|
|
356
|
+
return -1;
|
|
357
|
+
}
|
|
358
|
+
if (right == null) {
|
|
359
|
+
return 1;
|
|
360
|
+
}
|
|
361
|
+
if (typeof left === 'number' && typeof right === 'number') {
|
|
362
|
+
return left - right;
|
|
363
|
+
}
|
|
364
|
+
return String(left).localeCompare(String(right), undefined, { numeric: true, sensitivity: 'base' });
|
|
365
|
+
}
|
|
366
|
+
visibleSelectionRows() {
|
|
367
|
+
if (this.groupedRows().length > 0) {
|
|
368
|
+
const rows = [];
|
|
369
|
+
for (const group of this.groupedRows()) {
|
|
370
|
+
if (!this.isGroupCollapsed(group.key)) {
|
|
371
|
+
rows.push(...group.items);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return rows;
|
|
375
|
+
}
|
|
376
|
+
return this.flatRenderedRows();
|
|
377
|
+
}
|
|
378
|
+
resolveSelectedRows(selection) {
|
|
379
|
+
const source = this.data();
|
|
380
|
+
return source.filter(row => selection.has(this.keyOf(row)));
|
|
99
381
|
}
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
return String(
|
|
382
|
+
keyOf(row) {
|
|
383
|
+
const source = row;
|
|
384
|
+
return String(source['id'] ?? source['key'] ?? JSON.stringify(row));
|
|
385
|
+
}
|
|
386
|
+
emitDataState(overrideGroup) {
|
|
387
|
+
this.dataStateChange.emit({
|
|
388
|
+
page: this.currentPage(),
|
|
389
|
+
pageSize: this.pageSize(),
|
|
390
|
+
sort: this.sortState(),
|
|
391
|
+
filters: this.activeFilters(),
|
|
392
|
+
group: overrideGroup !== undefined ? overrideGroup : this.groupBy(),
|
|
393
|
+
});
|
|
103
394
|
}
|
|
104
395
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: DataGridComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
105
|
-
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 }, 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 } }, outputs: { rowClick: "rowClick", selectionChange: "selectionChange", sortChange: "sortChange", pageChange: "pageChange" }, ngImport: i0, template: `
|
|
396
|
+
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: `
|
|
106
397
|
<div class="ngx-data-grid" [class.loading]="loading()">
|
|
107
398
|
|
|
108
|
-
<!-- Filter row (above table) if any column is filterable -->
|
|
109
399
|
@if (hasFilterableColumns()) {
|
|
110
400
|
<div class="grid-filter-bar">
|
|
111
401
|
@for (col of columns(); track col.field) {
|
|
@@ -124,11 +414,13 @@ class DataGridComponent {
|
|
|
124
414
|
</div>
|
|
125
415
|
}
|
|
126
416
|
|
|
127
|
-
<!-- Table -->
|
|
128
417
|
<div class="grid-table-wrap">
|
|
129
418
|
<table class="grid-table" [class.striped]="striped()">
|
|
130
419
|
<thead>
|
|
131
420
|
<tr>
|
|
421
|
+
@if (showDetailToggle()) {
|
|
422
|
+
<th class="grid-th grid-th-toggle" style="width:36px"></th>
|
|
423
|
+
}
|
|
132
424
|
@if (selectable()) {
|
|
133
425
|
<th class="grid-th grid-th-check" style="width:40px">
|
|
134
426
|
<input type="checkbox" [checked]="allSelected()" [indeterminate]="someSelected() && !allSelected()" (change)="toggleAll()" />
|
|
@@ -143,59 +435,229 @@ class DataGridComponent {
|
|
|
143
435
|
[class.sort-desc]="sortState()?.field === col.field && sortState()?.dir === 'desc'"
|
|
144
436
|
(click)="col.sortable ? onSort(col) : null"
|
|
145
437
|
>
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
438
|
+
@if (resolveHeaderTemplate(col); as activeHeaderTemplate) {
|
|
439
|
+
<ng-container *ngTemplateOutlet="activeHeaderTemplate; context: {
|
|
440
|
+
$implicit: col,
|
|
441
|
+
column: col,
|
|
442
|
+
sort: sortState(),
|
|
443
|
+
filters: activeFilters(),
|
|
444
|
+
isServerMode: isAnyServerMode()
|
|
445
|
+
}" />
|
|
446
|
+
} @else {
|
|
447
|
+
<span class="th-text">{{ col.title }}</span>
|
|
448
|
+
@if (col.sortable) {
|
|
449
|
+
<span class="sort-icon">
|
|
450
|
+
@if (sortState()?.field === col.field) {
|
|
451
|
+
{{ sortState()?.dir === 'asc' ? '↑' : '↓' }}
|
|
452
|
+
} @else { ↕ }
|
|
453
|
+
</span>
|
|
454
|
+
}
|
|
153
455
|
}
|
|
154
456
|
</th>
|
|
155
457
|
}
|
|
458
|
+
@if (editable()) {
|
|
459
|
+
<th class="grid-th" style="width:120px">Actions</th>
|
|
460
|
+
}
|
|
156
461
|
</tr>
|
|
157
462
|
</thead>
|
|
158
463
|
<tbody>
|
|
159
464
|
@if (loading()) {
|
|
160
465
|
<tr>
|
|
161
|
-
<td [attr.colspan]="
|
|
466
|
+
<td [attr.colspan]="renderColumnCount()" class="grid-loading-cell">
|
|
162
467
|
<div class="grid-spinner"></div>
|
|
163
468
|
</td>
|
|
164
469
|
</tr>
|
|
165
|
-
} @else if (
|
|
470
|
+
} @else if (flatRenderedRows().length === 0 && groupedRows().length === 0) {
|
|
166
471
|
<tr>
|
|
167
|
-
<td [attr.colspan]="
|
|
472
|
+
<td [attr.colspan]="renderColumnCount()" class="grid-empty-cell">No data found.</td>
|
|
168
473
|
</tr>
|
|
474
|
+
} @else if (groupedRows().length > 0) {
|
|
475
|
+
@for (group of groupedRows(); track group.key) {
|
|
476
|
+
<tr class="grid-group-row" (click)="toggleGroup(group.key)">
|
|
477
|
+
<td [attr.colspan]="renderColumnCount()">
|
|
478
|
+
<button class="group-toggle" type="button" (click)="toggleGroup(group.key); $event.stopPropagation()">
|
|
479
|
+
{{ isGroupCollapsed(group.key) ? '▸' : '▾' }}
|
|
480
|
+
</button>
|
|
481
|
+
<strong>{{ group.field }}</strong>: {{ group.value }}
|
|
482
|
+
<span class="group-count">({{ group.count }})</span>
|
|
483
|
+
</td>
|
|
484
|
+
</tr>
|
|
485
|
+
|
|
486
|
+
@if (!isGroupCollapsed(group.key)) {
|
|
487
|
+
@for (row of group.items; track getKey(row, $index); let i = $index) {
|
|
488
|
+
<tr
|
|
489
|
+
class="grid-row"
|
|
490
|
+
[class.selected]="isRowSelected(row)"
|
|
491
|
+
(click)="onRowClick(row, i)"
|
|
492
|
+
(dblclick)="editable() ? beginEdit(row, i) : null"
|
|
493
|
+
>
|
|
494
|
+
@if (showDetailToggle()) {
|
|
495
|
+
<td class="grid-td grid-td-toggle">
|
|
496
|
+
<button class="toggle-btn" type="button" (click)="toggleDetail(row); $event.stopPropagation()">
|
|
497
|
+
{{ isExpanded(row) ? '▾' : '▸' }}
|
|
498
|
+
</button>
|
|
499
|
+
</td>
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
@if (selectable()) {
|
|
503
|
+
<td class="grid-td grid-td-check">
|
|
504
|
+
<input type="checkbox" [checked]="isRowSelected(row)" (change)="toggleRow(row)" (click)="$event.stopPropagation()" />
|
|
505
|
+
</td>
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
@if (rowTemplate()) {
|
|
509
|
+
<td class="grid-td" [attr.colspan]="columns().length + (editable() ? 1 : 0)">
|
|
510
|
+
<ng-container *ngTemplateOutlet="rowTemplate(); context: {
|
|
511
|
+
$implicit: row,
|
|
512
|
+
row: row,
|
|
513
|
+
index: i,
|
|
514
|
+
editing: isEditing(row),
|
|
515
|
+
expanded: isExpanded(row)
|
|
516
|
+
}" />
|
|
517
|
+
</td>
|
|
518
|
+
} @else {
|
|
519
|
+
@for (col of columns(); track col.field) {
|
|
520
|
+
<td class="grid-td" [style.text-align]="col.align ?? 'left'">
|
|
521
|
+
@if (isEditing(row) && editable() && col.editable) {
|
|
522
|
+
<input
|
|
523
|
+
class="grid-edit-input"
|
|
524
|
+
[value]="toStringSafe(getDraftValue(row, col.field))"
|
|
525
|
+
(input)="updateDraft(col.field, $any($event.target).value)"
|
|
526
|
+
(click)="$event.stopPropagation()"
|
|
527
|
+
/>
|
|
528
|
+
} @else if (resolveCellTemplate(col)) {
|
|
529
|
+
<ng-container *ngTemplateOutlet="resolveCellTemplate(col)!; context: {
|
|
530
|
+
$implicit: getCellValue(row, col.field),
|
|
531
|
+
value: getCellValue(row, col.field),
|
|
532
|
+
row: row,
|
|
533
|
+
column: col,
|
|
534
|
+
index: i,
|
|
535
|
+
editing: isEditing(row)
|
|
536
|
+
}" />
|
|
537
|
+
} @else {
|
|
538
|
+
{{ getCellValue(row, col.field) }}
|
|
539
|
+
}
|
|
540
|
+
</td>
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
@if (editable()) {
|
|
544
|
+
<td class="grid-td grid-actions">
|
|
545
|
+
@if (!isEditing(row)) {
|
|
546
|
+
<button class="action-btn" type="button" (click)="beginEdit(row, i); $event.stopPropagation()">Edit</button>
|
|
547
|
+
} @else {
|
|
548
|
+
<button class="action-btn save" type="button" (click)="saveEdit(row, i); $event.stopPropagation()">Save</button>
|
|
549
|
+
<button class="action-btn" type="button" (click)="cancelEdit(); $event.stopPropagation()">Cancel</button>
|
|
550
|
+
}
|
|
551
|
+
</td>
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
</tr>
|
|
555
|
+
|
|
556
|
+
@if (showDetailToggle() && isExpanded(row) && detailRowTemplate()) {
|
|
557
|
+
<tr class="grid-detail-row">
|
|
558
|
+
<td [attr.colspan]="renderColumnCount()" class="grid-detail-cell">
|
|
559
|
+
<ng-container *ngTemplateOutlet="detailRowTemplate(); context: {
|
|
560
|
+
$implicit: row,
|
|
561
|
+
row: row,
|
|
562
|
+
index: i
|
|
563
|
+
}" />
|
|
564
|
+
</td>
|
|
565
|
+
</tr>
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
}
|
|
169
570
|
} @else {
|
|
170
|
-
@for (row of
|
|
571
|
+
@for (row of flatRenderedRows(); track getKey(row, $index); let i = $index) {
|
|
171
572
|
<tr
|
|
172
573
|
class="grid-row"
|
|
173
574
|
[class.selected]="isRowSelected(row)"
|
|
174
575
|
(click)="onRowClick(row, i)"
|
|
576
|
+
(dblclick)="editable() ? beginEdit(row, i) : null"
|
|
175
577
|
>
|
|
578
|
+
@if (showDetailToggle()) {
|
|
579
|
+
<td class="grid-td grid-td-toggle">
|
|
580
|
+
<button class="toggle-btn" type="button" (click)="toggleDetail(row); $event.stopPropagation()">
|
|
581
|
+
{{ isExpanded(row) ? '▾' : '▸' }}
|
|
582
|
+
</button>
|
|
583
|
+
</td>
|
|
584
|
+
}
|
|
585
|
+
|
|
176
586
|
@if (selectable()) {
|
|
177
587
|
<td class="grid-td grid-td-check">
|
|
178
588
|
<input type="checkbox" [checked]="isRowSelected(row)" (change)="toggleRow(row)" (click)="$event.stopPropagation()" />
|
|
179
589
|
</td>
|
|
180
590
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
591
|
+
|
|
592
|
+
@if (rowTemplate()) {
|
|
593
|
+
<td class="grid-td" [attr.colspan]="columns().length + (editable() ? 1 : 0)">
|
|
594
|
+
<ng-container *ngTemplateOutlet="rowTemplate(); context: {
|
|
595
|
+
$implicit: row,
|
|
596
|
+
row: row,
|
|
597
|
+
index: i,
|
|
598
|
+
editing: isEditing(row),
|
|
599
|
+
expanded: isExpanded(row)
|
|
600
|
+
}" />
|
|
184
601
|
</td>
|
|
602
|
+
} @else {
|
|
603
|
+
@for (col of columns(); track col.field) {
|
|
604
|
+
<td class="grid-td" [style.text-align]="col.align ?? 'left'">
|
|
605
|
+
@if (isEditing(row) && editable() && col.editable) {
|
|
606
|
+
<input
|
|
607
|
+
class="grid-edit-input"
|
|
608
|
+
[value]="toStringSafe(getDraftValue(row, col.field))"
|
|
609
|
+
(input)="updateDraft(col.field, $any($event.target).value)"
|
|
610
|
+
(click)="$event.stopPropagation()"
|
|
611
|
+
/>
|
|
612
|
+
} @else if (resolveCellTemplate(col)) {
|
|
613
|
+
<ng-container *ngTemplateOutlet="resolveCellTemplate(col)!; context: {
|
|
614
|
+
$implicit: getCellValue(row, col.field),
|
|
615
|
+
value: getCellValue(row, col.field),
|
|
616
|
+
row: row,
|
|
617
|
+
column: col,
|
|
618
|
+
index: i,
|
|
619
|
+
editing: isEditing(row)
|
|
620
|
+
}" />
|
|
621
|
+
} @else {
|
|
622
|
+
{{ getCellValue(row, col.field) }}
|
|
623
|
+
}
|
|
624
|
+
</td>
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
@if (editable()) {
|
|
628
|
+
<td class="grid-td grid-actions">
|
|
629
|
+
@if (!isEditing(row)) {
|
|
630
|
+
<button class="action-btn" type="button" (click)="beginEdit(row, i); $event.stopPropagation()">Edit</button>
|
|
631
|
+
} @else {
|
|
632
|
+
<button class="action-btn save" type="button" (click)="saveEdit(row, i); $event.stopPropagation()">Save</button>
|
|
633
|
+
<button class="action-btn" type="button" (click)="cancelEdit(); $event.stopPropagation()">Cancel</button>
|
|
634
|
+
}
|
|
635
|
+
</td>
|
|
636
|
+
}
|
|
185
637
|
}
|
|
186
638
|
</tr>
|
|
639
|
+
|
|
640
|
+
@if (showDetailToggle() && isExpanded(row) && detailRowTemplate()) {
|
|
641
|
+
<tr class="grid-detail-row">
|
|
642
|
+
<td [attr.colspan]="renderColumnCount()" class="grid-detail-cell">
|
|
643
|
+
<ng-container *ngTemplateOutlet="detailRowTemplate(); context: {
|
|
644
|
+
$implicit: row,
|
|
645
|
+
row: row,
|
|
646
|
+
index: i
|
|
647
|
+
}" />
|
|
648
|
+
</td>
|
|
649
|
+
</tr>
|
|
650
|
+
}
|
|
187
651
|
}
|
|
188
652
|
}
|
|
189
653
|
</tbody>
|
|
190
654
|
</table>
|
|
191
655
|
</div>
|
|
192
656
|
|
|
193
|
-
|
|
194
|
-
@if (pagedData().length > 0 || totalFiltered() > 0) {
|
|
657
|
+
@if (showPager()) {
|
|
195
658
|
<div class="grid-pagination">
|
|
196
659
|
<span class="page-info">
|
|
197
|
-
{{ (
|
|
198
|
-
of {{ totalFiltered() }}
|
|
660
|
+
{{ pagerRangeStart() }}–{{ pagerRangeEnd() }} of {{ totalItems() }}
|
|
199
661
|
</span>
|
|
200
662
|
<div class="page-btns">
|
|
201
663
|
<button class="page-btn" [disabled]="currentPage() === 1" (click)="goPage(1)">«</button>
|
|
@@ -209,14 +671,13 @@ class DataGridComponent {
|
|
|
209
671
|
</div>
|
|
210
672
|
}
|
|
211
673
|
</div>
|
|
212
|
-
`, isInline: true, styles: [":host{display:block}.ngx-data-grid{font-family:inherit;border:1px solid var(--ngx-grid-border, #dee2e6);border-radius:var(--ngx-grid-radius, 4px);overflow:hidden;background:var(--ngx-grid-bg, #fff)}.grid-filter-bar{display:flex;gap:8px;padding:8px 12px;background:var(--ngx-grid-header-bg, #f1f3f5);border-bottom:1px solid var(--ngx-grid-border, #dee2e6)}.grid-filter-input{padding:4px 8px;border:1px solid var(--ngx-grid-border, #dee2e6);border-radius:3px;font-size:12px;outline:none;font-family:inherit}.grid-filter-input:focus{border-color:#4a90d9}.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:10px 12px;text-align:left;font-size:12px;font-weight:600;color:var(--ngx-grid-text-secondary, #6c757d);background:var(--ngx-grid-header-bg, #f1f3f5);border-bottom:2px solid var(--ngx-grid-border, #dee2e6);white-space:nowrap;-webkit-user-select:none;user-select:none}.grid-th.sortable{cursor:pointer}.grid-th.sortable:hover{background:#e9ecef}.grid-th.sort-asc,.grid-th.sort-desc{color:#4a90d9}.th-text{margin-right:4px}.sort-icon{font-size:10px;color:#adb5bd}.sort-asc .sort-icon,.sort-desc .sort-icon{color:#4a90d9}.grid-row{border-bottom:1px solid var(--ngx-grid-border, #dee2e6);
|
|
674
|
+
`, isInline: true, styles: [":host{display:block}.ngx-data-grid{font-family:inherit;border:1px solid var(--ngx-grid-border, #dee2e6);border-radius:var(--ngx-grid-radius, 4px);overflow:hidden;background:var(--ngx-grid-bg, #fff)}.grid-filter-bar{display:flex;gap:8px;padding:8px 12px;background:var(--ngx-grid-header-bg, #f1f3f5);border-bottom:1px solid var(--ngx-grid-border, #dee2e6)}.grid-filter-input{padding:4px 8px;border:1px solid var(--ngx-grid-border, #dee2e6);border-radius:3px;font-size:12px;outline:none;font-family:inherit}.grid-filter-input:focus{border-color:#4a90d9}.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:10px 12px;text-align:left;font-size:12px;font-weight:600;color:var(--ngx-grid-text-secondary, #6c757d);background:var(--ngx-grid-header-bg, #f1f3f5);border-bottom:2px solid var(--ngx-grid-border, #dee2e6);white-space:nowrap;-webkit-user-select:none;user-select:none}.grid-th.sortable{cursor:pointer}.grid-th.sortable:hover{background:#e9ecef}.grid-th.sort-asc,.grid-th.sort-desc{color:#4a90d9}.th-text{margin-right:4px}.sort-icon{font-size:10px;color:#adb5bd}.sort-asc .sort-icon,.sort-desc .sort-icon{color:#4a90d9}.grid-group-row td{background:#f8f9fa;border-bottom:1px solid #e9ecef;color:#495057;font-size:12px;padding:9px 12px;cursor:pointer}.group-toggle{border:none;background:transparent;margin-right:6px;cursor:pointer;color:#6c757d}.group-count{color:#6c757d;margin-left:4px}.grid-row{border-bottom:1px solid var(--ngx-grid-border, #dee2e6);transition:background .1s}.grid-row:hover{background:var(--ngx-grid-hover-bg, #f8f9fa)}.grid-row.selected{background:var(--ngx-grid-selected-bg, #e8f0fe)}.grid-table.striped .grid-row:nth-child(2n){background:#f8f9fa}.grid-table.striped .grid-row:nth-child(2n):hover{background:var(--ngx-grid-hover-bg, #f8f9fa)}.grid-table.striped .grid-row.selected{background:var(--ngx-grid-selected-bg, #e8f0fe)!important}.grid-td{padding:9px 12px;color:var(--ngx-grid-text, #212529);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;vertical-align:middle}.grid-th-check,.grid-td-check,.grid-th-toggle,.grid-td-toggle{width:40px!important;text-align:center}.toggle-btn{border:none;background:transparent;color:#6c757d;cursor:pointer;font-size:13px}.grid-detail-row td{background:#fcfcfd;border-bottom:1px solid var(--ngx-grid-border, #dee2e6)}.grid-detail-cell{padding:12px 16px;white-space:normal}.grid-edit-input{width:100%;min-width:80px;padding:5px 8px;border:1px solid #ced4da;border-radius:4px;font-size:12px;font-family:inherit;box-sizing:border-box}.grid-actions{white-space:nowrap}.action-btn{border:1px solid #ced4da;background:#fff;color:#495057;border-radius:4px;padding:4px 8px;font-size:12px;margin-right:6px;cursor:pointer}.action-btn.save{border-color:#1a73e8;background:#1a73e8;color:#fff}.action-btn:last-child{margin-right:0}.grid-loading-cell,.grid-empty-cell{padding:32px;text-align:center;color:var(--ngx-grid-text-secondary, #6c757d)}.grid-spinner{width:24px;height:24px;border:3px solid #dee2e6;border-top-color:#4a90d9;border-radius:50%;animation:spin .7s linear infinite;margin:0 auto}@keyframes spin{to{transform:rotate(360deg)}}.grid-pagination{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;border-top:1px solid var(--ngx-grid-border, #dee2e6);background:var(--ngx-grid-bg, #fff);flex-wrap:wrap;gap:8px}.page-info{font-size:12px;color:var(--ngx-grid-text-secondary, #6c757d)}.page-btns{display:flex;gap:2px}.page-btn{min-width:28px;height:28px;padding:0 6px;font-size:13px;border:1px solid var(--ngx-grid-border, #dee2e6);background:var(--ngx-grid-bg, #fff);border-radius:3px;cursor:pointer;font-family:inherit;color:var(--ngx-grid-text, #212529);transition:background .1s}.page-btn:hover:not(:disabled){background:#f1f3f5}.page-btn.active{background:#4a90d9;color:#fff;border-color:#4a90d9}.page-btn:disabled{opacity:.4;cursor:not-allowed}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
213
675
|
}
|
|
214
676
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImport: i0, type: DataGridComponent, decorators: [{
|
|
215
677
|
type: Component,
|
|
216
|
-
args: [{ selector: 'ngx-data-grid', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
678
|
+
args: [{ selector: 'ngx-data-grid', standalone: true, imports: [NgTemplateOutlet], changeDetection: ChangeDetectionStrategy.OnPush, template: `
|
|
217
679
|
<div class="ngx-data-grid" [class.loading]="loading()">
|
|
218
680
|
|
|
219
|
-
<!-- Filter row (above table) if any column is filterable -->
|
|
220
681
|
@if (hasFilterableColumns()) {
|
|
221
682
|
<div class="grid-filter-bar">
|
|
222
683
|
@for (col of columns(); track col.field) {
|
|
@@ -235,11 +696,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
|
|
|
235
696
|
</div>
|
|
236
697
|
}
|
|
237
698
|
|
|
238
|
-
<!-- Table -->
|
|
239
699
|
<div class="grid-table-wrap">
|
|
240
700
|
<table class="grid-table" [class.striped]="striped()">
|
|
241
701
|
<thead>
|
|
242
702
|
<tr>
|
|
703
|
+
@if (showDetailToggle()) {
|
|
704
|
+
<th class="grid-th grid-th-toggle" style="width:36px"></th>
|
|
705
|
+
}
|
|
243
706
|
@if (selectable()) {
|
|
244
707
|
<th class="grid-th grid-th-check" style="width:40px">
|
|
245
708
|
<input type="checkbox" [checked]="allSelected()" [indeterminate]="someSelected() && !allSelected()" (change)="toggleAll()" />
|
|
@@ -254,59 +717,229 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
|
|
|
254
717
|
[class.sort-desc]="sortState()?.field === col.field && sortState()?.dir === 'desc'"
|
|
255
718
|
(click)="col.sortable ? onSort(col) : null"
|
|
256
719
|
>
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
720
|
+
@if (resolveHeaderTemplate(col); as activeHeaderTemplate) {
|
|
721
|
+
<ng-container *ngTemplateOutlet="activeHeaderTemplate; context: {
|
|
722
|
+
$implicit: col,
|
|
723
|
+
column: col,
|
|
724
|
+
sort: sortState(),
|
|
725
|
+
filters: activeFilters(),
|
|
726
|
+
isServerMode: isAnyServerMode()
|
|
727
|
+
}" />
|
|
728
|
+
} @else {
|
|
729
|
+
<span class="th-text">{{ col.title }}</span>
|
|
730
|
+
@if (col.sortable) {
|
|
731
|
+
<span class="sort-icon">
|
|
732
|
+
@if (sortState()?.field === col.field) {
|
|
733
|
+
{{ sortState()?.dir === 'asc' ? '↑' : '↓' }}
|
|
734
|
+
} @else { ↕ }
|
|
735
|
+
</span>
|
|
736
|
+
}
|
|
264
737
|
}
|
|
265
738
|
</th>
|
|
266
739
|
}
|
|
740
|
+
@if (editable()) {
|
|
741
|
+
<th class="grid-th" style="width:120px">Actions</th>
|
|
742
|
+
}
|
|
267
743
|
</tr>
|
|
268
744
|
</thead>
|
|
269
745
|
<tbody>
|
|
270
746
|
@if (loading()) {
|
|
271
747
|
<tr>
|
|
272
|
-
<td [attr.colspan]="
|
|
748
|
+
<td [attr.colspan]="renderColumnCount()" class="grid-loading-cell">
|
|
273
749
|
<div class="grid-spinner"></div>
|
|
274
750
|
</td>
|
|
275
751
|
</tr>
|
|
276
|
-
} @else if (
|
|
752
|
+
} @else if (flatRenderedRows().length === 0 && groupedRows().length === 0) {
|
|
277
753
|
<tr>
|
|
278
|
-
<td [attr.colspan]="
|
|
754
|
+
<td [attr.colspan]="renderColumnCount()" class="grid-empty-cell">No data found.</td>
|
|
279
755
|
</tr>
|
|
756
|
+
} @else if (groupedRows().length > 0) {
|
|
757
|
+
@for (group of groupedRows(); track group.key) {
|
|
758
|
+
<tr class="grid-group-row" (click)="toggleGroup(group.key)">
|
|
759
|
+
<td [attr.colspan]="renderColumnCount()">
|
|
760
|
+
<button class="group-toggle" type="button" (click)="toggleGroup(group.key); $event.stopPropagation()">
|
|
761
|
+
{{ isGroupCollapsed(group.key) ? '▸' : '▾' }}
|
|
762
|
+
</button>
|
|
763
|
+
<strong>{{ group.field }}</strong>: {{ group.value }}
|
|
764
|
+
<span class="group-count">({{ group.count }})</span>
|
|
765
|
+
</td>
|
|
766
|
+
</tr>
|
|
767
|
+
|
|
768
|
+
@if (!isGroupCollapsed(group.key)) {
|
|
769
|
+
@for (row of group.items; track getKey(row, $index); let i = $index) {
|
|
770
|
+
<tr
|
|
771
|
+
class="grid-row"
|
|
772
|
+
[class.selected]="isRowSelected(row)"
|
|
773
|
+
(click)="onRowClick(row, i)"
|
|
774
|
+
(dblclick)="editable() ? beginEdit(row, i) : null"
|
|
775
|
+
>
|
|
776
|
+
@if (showDetailToggle()) {
|
|
777
|
+
<td class="grid-td grid-td-toggle">
|
|
778
|
+
<button class="toggle-btn" type="button" (click)="toggleDetail(row); $event.stopPropagation()">
|
|
779
|
+
{{ isExpanded(row) ? '▾' : '▸' }}
|
|
780
|
+
</button>
|
|
781
|
+
</td>
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
@if (selectable()) {
|
|
785
|
+
<td class="grid-td grid-td-check">
|
|
786
|
+
<input type="checkbox" [checked]="isRowSelected(row)" (change)="toggleRow(row)" (click)="$event.stopPropagation()" />
|
|
787
|
+
</td>
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
@if (rowTemplate()) {
|
|
791
|
+
<td class="grid-td" [attr.colspan]="columns().length + (editable() ? 1 : 0)">
|
|
792
|
+
<ng-container *ngTemplateOutlet="rowTemplate(); context: {
|
|
793
|
+
$implicit: row,
|
|
794
|
+
row: row,
|
|
795
|
+
index: i,
|
|
796
|
+
editing: isEditing(row),
|
|
797
|
+
expanded: isExpanded(row)
|
|
798
|
+
}" />
|
|
799
|
+
</td>
|
|
800
|
+
} @else {
|
|
801
|
+
@for (col of columns(); track col.field) {
|
|
802
|
+
<td class="grid-td" [style.text-align]="col.align ?? 'left'">
|
|
803
|
+
@if (isEditing(row) && editable() && col.editable) {
|
|
804
|
+
<input
|
|
805
|
+
class="grid-edit-input"
|
|
806
|
+
[value]="toStringSafe(getDraftValue(row, col.field))"
|
|
807
|
+
(input)="updateDraft(col.field, $any($event.target).value)"
|
|
808
|
+
(click)="$event.stopPropagation()"
|
|
809
|
+
/>
|
|
810
|
+
} @else if (resolveCellTemplate(col)) {
|
|
811
|
+
<ng-container *ngTemplateOutlet="resolveCellTemplate(col)!; context: {
|
|
812
|
+
$implicit: getCellValue(row, col.field),
|
|
813
|
+
value: getCellValue(row, col.field),
|
|
814
|
+
row: row,
|
|
815
|
+
column: col,
|
|
816
|
+
index: i,
|
|
817
|
+
editing: isEditing(row)
|
|
818
|
+
}" />
|
|
819
|
+
} @else {
|
|
820
|
+
{{ getCellValue(row, col.field) }}
|
|
821
|
+
}
|
|
822
|
+
</td>
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
@if (editable()) {
|
|
826
|
+
<td class="grid-td grid-actions">
|
|
827
|
+
@if (!isEditing(row)) {
|
|
828
|
+
<button class="action-btn" type="button" (click)="beginEdit(row, i); $event.stopPropagation()">Edit</button>
|
|
829
|
+
} @else {
|
|
830
|
+
<button class="action-btn save" type="button" (click)="saveEdit(row, i); $event.stopPropagation()">Save</button>
|
|
831
|
+
<button class="action-btn" type="button" (click)="cancelEdit(); $event.stopPropagation()">Cancel</button>
|
|
832
|
+
}
|
|
833
|
+
</td>
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
</tr>
|
|
837
|
+
|
|
838
|
+
@if (showDetailToggle() && isExpanded(row) && detailRowTemplate()) {
|
|
839
|
+
<tr class="grid-detail-row">
|
|
840
|
+
<td [attr.colspan]="renderColumnCount()" class="grid-detail-cell">
|
|
841
|
+
<ng-container *ngTemplateOutlet="detailRowTemplate(); context: {
|
|
842
|
+
$implicit: row,
|
|
843
|
+
row: row,
|
|
844
|
+
index: i
|
|
845
|
+
}" />
|
|
846
|
+
</td>
|
|
847
|
+
</tr>
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
}
|
|
280
852
|
} @else {
|
|
281
|
-
@for (row of
|
|
853
|
+
@for (row of flatRenderedRows(); track getKey(row, $index); let i = $index) {
|
|
282
854
|
<tr
|
|
283
855
|
class="grid-row"
|
|
284
856
|
[class.selected]="isRowSelected(row)"
|
|
285
857
|
(click)="onRowClick(row, i)"
|
|
858
|
+
(dblclick)="editable() ? beginEdit(row, i) : null"
|
|
286
859
|
>
|
|
860
|
+
@if (showDetailToggle()) {
|
|
861
|
+
<td class="grid-td grid-td-toggle">
|
|
862
|
+
<button class="toggle-btn" type="button" (click)="toggleDetail(row); $event.stopPropagation()">
|
|
863
|
+
{{ isExpanded(row) ? '▾' : '▸' }}
|
|
864
|
+
</button>
|
|
865
|
+
</td>
|
|
866
|
+
}
|
|
867
|
+
|
|
287
868
|
@if (selectable()) {
|
|
288
869
|
<td class="grid-td grid-td-check">
|
|
289
870
|
<input type="checkbox" [checked]="isRowSelected(row)" (change)="toggleRow(row)" (click)="$event.stopPropagation()" />
|
|
290
871
|
</td>
|
|
291
872
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
873
|
+
|
|
874
|
+
@if (rowTemplate()) {
|
|
875
|
+
<td class="grid-td" [attr.colspan]="columns().length + (editable() ? 1 : 0)">
|
|
876
|
+
<ng-container *ngTemplateOutlet="rowTemplate(); context: {
|
|
877
|
+
$implicit: row,
|
|
878
|
+
row: row,
|
|
879
|
+
index: i,
|
|
880
|
+
editing: isEditing(row),
|
|
881
|
+
expanded: isExpanded(row)
|
|
882
|
+
}" />
|
|
295
883
|
</td>
|
|
884
|
+
} @else {
|
|
885
|
+
@for (col of columns(); track col.field) {
|
|
886
|
+
<td class="grid-td" [style.text-align]="col.align ?? 'left'">
|
|
887
|
+
@if (isEditing(row) && editable() && col.editable) {
|
|
888
|
+
<input
|
|
889
|
+
class="grid-edit-input"
|
|
890
|
+
[value]="toStringSafe(getDraftValue(row, col.field))"
|
|
891
|
+
(input)="updateDraft(col.field, $any($event.target).value)"
|
|
892
|
+
(click)="$event.stopPropagation()"
|
|
893
|
+
/>
|
|
894
|
+
} @else if (resolveCellTemplate(col)) {
|
|
895
|
+
<ng-container *ngTemplateOutlet="resolveCellTemplate(col)!; context: {
|
|
896
|
+
$implicit: getCellValue(row, col.field),
|
|
897
|
+
value: getCellValue(row, col.field),
|
|
898
|
+
row: row,
|
|
899
|
+
column: col,
|
|
900
|
+
index: i,
|
|
901
|
+
editing: isEditing(row)
|
|
902
|
+
}" />
|
|
903
|
+
} @else {
|
|
904
|
+
{{ getCellValue(row, col.field) }}
|
|
905
|
+
}
|
|
906
|
+
</td>
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
@if (editable()) {
|
|
910
|
+
<td class="grid-td grid-actions">
|
|
911
|
+
@if (!isEditing(row)) {
|
|
912
|
+
<button class="action-btn" type="button" (click)="beginEdit(row, i); $event.stopPropagation()">Edit</button>
|
|
913
|
+
} @else {
|
|
914
|
+
<button class="action-btn save" type="button" (click)="saveEdit(row, i); $event.stopPropagation()">Save</button>
|
|
915
|
+
<button class="action-btn" type="button" (click)="cancelEdit(); $event.stopPropagation()">Cancel</button>
|
|
916
|
+
}
|
|
917
|
+
</td>
|
|
918
|
+
}
|
|
296
919
|
}
|
|
297
920
|
</tr>
|
|
921
|
+
|
|
922
|
+
@if (showDetailToggle() && isExpanded(row) && detailRowTemplate()) {
|
|
923
|
+
<tr class="grid-detail-row">
|
|
924
|
+
<td [attr.colspan]="renderColumnCount()" class="grid-detail-cell">
|
|
925
|
+
<ng-container *ngTemplateOutlet="detailRowTemplate(); context: {
|
|
926
|
+
$implicit: row,
|
|
927
|
+
row: row,
|
|
928
|
+
index: i
|
|
929
|
+
}" />
|
|
930
|
+
</td>
|
|
931
|
+
</tr>
|
|
932
|
+
}
|
|
298
933
|
}
|
|
299
934
|
}
|
|
300
935
|
</tbody>
|
|
301
936
|
</table>
|
|
302
937
|
</div>
|
|
303
938
|
|
|
304
|
-
|
|
305
|
-
@if (pagedData().length > 0 || totalFiltered() > 0) {
|
|
939
|
+
@if (showPager()) {
|
|
306
940
|
<div class="grid-pagination">
|
|
307
941
|
<span class="page-info">
|
|
308
|
-
{{ (
|
|
309
|
-
of {{ totalFiltered() }}
|
|
942
|
+
{{ pagerRangeStart() }}–{{ pagerRangeEnd() }} of {{ totalItems() }}
|
|
310
943
|
</span>
|
|
311
944
|
<div class="page-btns">
|
|
312
945
|
<button class="page-btn" [disabled]="currentPage() === 1" (click)="goPage(1)">«</button>
|
|
@@ -320,8 +953,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.20", ngImpo
|
|
|
320
953
|
</div>
|
|
321
954
|
}
|
|
322
955
|
</div>
|
|
323
|
-
`, styles: [":host{display:block}.ngx-data-grid{font-family:inherit;border:1px solid var(--ngx-grid-border, #dee2e6);border-radius:var(--ngx-grid-radius, 4px);overflow:hidden;background:var(--ngx-grid-bg, #fff)}.grid-filter-bar{display:flex;gap:8px;padding:8px 12px;background:var(--ngx-grid-header-bg, #f1f3f5);border-bottom:1px solid var(--ngx-grid-border, #dee2e6)}.grid-filter-input{padding:4px 8px;border:1px solid var(--ngx-grid-border, #dee2e6);border-radius:3px;font-size:12px;outline:none;font-family:inherit}.grid-filter-input:focus{border-color:#4a90d9}.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:10px 12px;text-align:left;font-size:12px;font-weight:600;color:var(--ngx-grid-text-secondary, #6c757d);background:var(--ngx-grid-header-bg, #f1f3f5);border-bottom:2px solid var(--ngx-grid-border, #dee2e6);white-space:nowrap;-webkit-user-select:none;user-select:none}.grid-th.sortable{cursor:pointer}.grid-th.sortable:hover{background:#e9ecef}.grid-th.sort-asc,.grid-th.sort-desc{color:#4a90d9}.th-text{margin-right:4px}.sort-icon{font-size:10px;color:#adb5bd}.sort-asc .sort-icon,.sort-desc .sort-icon{color:#4a90d9}.grid-row{border-bottom:1px solid var(--ngx-grid-border, #dee2e6);
|
|
324
|
-
}] });
|
|
956
|
+
`, styles: [":host{display:block}.ngx-data-grid{font-family:inherit;border:1px solid var(--ngx-grid-border, #dee2e6);border-radius:var(--ngx-grid-radius, 4px);overflow:hidden;background:var(--ngx-grid-bg, #fff)}.grid-filter-bar{display:flex;gap:8px;padding:8px 12px;background:var(--ngx-grid-header-bg, #f1f3f5);border-bottom:1px solid var(--ngx-grid-border, #dee2e6)}.grid-filter-input{padding:4px 8px;border:1px solid var(--ngx-grid-border, #dee2e6);border-radius:3px;font-size:12px;outline:none;font-family:inherit}.grid-filter-input:focus{border-color:#4a90d9}.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:10px 12px;text-align:left;font-size:12px;font-weight:600;color:var(--ngx-grid-text-secondary, #6c757d);background:var(--ngx-grid-header-bg, #f1f3f5);border-bottom:2px solid var(--ngx-grid-border, #dee2e6);white-space:nowrap;-webkit-user-select:none;user-select:none}.grid-th.sortable{cursor:pointer}.grid-th.sortable:hover{background:#e9ecef}.grid-th.sort-asc,.grid-th.sort-desc{color:#4a90d9}.th-text{margin-right:4px}.sort-icon{font-size:10px;color:#adb5bd}.sort-asc .sort-icon,.sort-desc .sort-icon{color:#4a90d9}.grid-group-row td{background:#f8f9fa;border-bottom:1px solid #e9ecef;color:#495057;font-size:12px;padding:9px 12px;cursor:pointer}.group-toggle{border:none;background:transparent;margin-right:6px;cursor:pointer;color:#6c757d}.group-count{color:#6c757d;margin-left:4px}.grid-row{border-bottom:1px solid var(--ngx-grid-border, #dee2e6);transition:background .1s}.grid-row:hover{background:var(--ngx-grid-hover-bg, #f8f9fa)}.grid-row.selected{background:var(--ngx-grid-selected-bg, #e8f0fe)}.grid-table.striped .grid-row:nth-child(2n){background:#f8f9fa}.grid-table.striped .grid-row:nth-child(2n):hover{background:var(--ngx-grid-hover-bg, #f8f9fa)}.grid-table.striped .grid-row.selected{background:var(--ngx-grid-selected-bg, #e8f0fe)!important}.grid-td{padding:9px 12px;color:var(--ngx-grid-text, #212529);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;vertical-align:middle}.grid-th-check,.grid-td-check,.grid-th-toggle,.grid-td-toggle{width:40px!important;text-align:center}.toggle-btn{border:none;background:transparent;color:#6c757d;cursor:pointer;font-size:13px}.grid-detail-row td{background:#fcfcfd;border-bottom:1px solid var(--ngx-grid-border, #dee2e6)}.grid-detail-cell{padding:12px 16px;white-space:normal}.grid-edit-input{width:100%;min-width:80px;padding:5px 8px;border:1px solid #ced4da;border-radius:4px;font-size:12px;font-family:inherit;box-sizing:border-box}.grid-actions{white-space:nowrap}.action-btn{border:1px solid #ced4da;background:#fff;color:#495057;border-radius:4px;padding:4px 8px;font-size:12px;margin-right:6px;cursor:pointer}.action-btn.save{border-color:#1a73e8;background:#1a73e8;color:#fff}.action-btn:last-child{margin-right:0}.grid-loading-cell,.grid-empty-cell{padding:32px;text-align:center;color:var(--ngx-grid-text-secondary, #6c757d)}.grid-spinner{width:24px;height:24px;border:3px solid #dee2e6;border-top-color:#4a90d9;border-radius:50%;animation:spin .7s linear infinite;margin:0 auto}@keyframes spin{to{transform:rotate(360deg)}}.grid-pagination{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;border-top:1px solid var(--ngx-grid-border, #dee2e6);background:var(--ngx-grid-bg, #fff);flex-wrap:wrap;gap:8px}.page-info{font-size:12px;color:var(--ngx-grid-text-secondary, #6c757d)}.page-btns{display:flex;gap:2px}.page-btn{min-width:28px;height:28px;padding:0 6px;font-size:13px;border:1px solid var(--ngx-grid-border, #dee2e6);background:var(--ngx-grid-bg, #fff);border-radius:3px;cursor:pointer;font-family:inherit;color:var(--ngx-grid-text, #212529);transition:background .1s}.page-btn:hover:not(:disabled){background:#f1f3f5}.page-btn.active{background:#4a90d9;color:#fff;border-color:#4a90d9}.page-btn:disabled{opacity:.4;cursor:not-allowed}\n"] }]
|
|
957
|
+
}], ctorParameters: () => [] });
|
|
325
958
|
|
|
326
959
|
/*
|
|
327
960
|
* Public API Surface — secondary entry point: ngx-core-components/grid
|