@toolbox-web/grid 1.9.1 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.js +1082 -975
- package/all.js.map +1 -1
- package/index.js +350 -324
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +40 -1
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +11 -0
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/types.d.ts +0 -64
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +9 -0
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts +3 -0
- package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts.map +1 -1
- package/lib/plugins/column-virtualization/index.js +90 -57
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +9 -0
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +69 -0
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/editors.d.ts.map +1 -1
- package/lib/plugins/editing/index.d.ts +1 -1
- package/lib/plugins/editing/index.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +435 -293
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/editing/types.d.ts +117 -1
- package/lib/plugins/editing/types.d.ts.map +1 -1
- package/lib/plugins/export/index.js +38 -29
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +14 -5
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +9 -0
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +63 -54
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +25 -16
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +13 -4
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +13 -4
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +16 -7
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +13 -4
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/index.js +9 -0
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +13 -4
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/index.js +42 -33
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js +9 -0
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +9 -0
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +29 -20
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +20 -11
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +15 -6
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +9 -0
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/public.d.ts +1 -1
- package/public.d.ts.map +1 -1
- package/umd/grid.all.umd.js +20 -20
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +14 -14
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/column-virtualization.umd.js +1 -1
- package/umd/plugins/column-virtualization.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
|
@@ -1,5 +1,113 @@
|
|
|
1
1
|
import { ColumnConfig } from '../../core/types';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Event detail for cell value commit.
|
|
4
|
+
*
|
|
5
|
+
* Fired immediately when a cell value is committed. The event is cancelable -
|
|
6
|
+
* call `preventDefault()` to reject the change.
|
|
7
|
+
*
|
|
8
|
+
* Use `setInvalid()` to mark the cell as invalid without canceling the commit.
|
|
9
|
+
* Invalid cells can be styled via `cellClass` and will be highlighted.
|
|
10
|
+
*
|
|
11
|
+
* @category Events
|
|
12
|
+
*/
|
|
13
|
+
export interface CellCommitDetail<TRow = unknown> {
|
|
14
|
+
/** The row object (not yet mutated if event is cancelable). */
|
|
15
|
+
row: TRow;
|
|
16
|
+
/** Stable row identifier (from getRowId). */
|
|
17
|
+
rowId: string;
|
|
18
|
+
/** Field name whose value changed. */
|
|
19
|
+
field: string;
|
|
20
|
+
/** Previous value before change. */
|
|
21
|
+
oldValue: unknown;
|
|
22
|
+
/** New value to be stored. */
|
|
23
|
+
value: unknown;
|
|
24
|
+
/** Index of the row in current data set. */
|
|
25
|
+
rowIndex: number;
|
|
26
|
+
/** All rows that have at least one committed change (snapshot list). */
|
|
27
|
+
changedRows: TRow[];
|
|
28
|
+
/** IDs of changed rows. */
|
|
29
|
+
changedRowIds: string[];
|
|
30
|
+
/** True if this row just entered the changed set. */
|
|
31
|
+
firstTimeForRow: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Update other fields in this row.
|
|
34
|
+
* Convenience wrapper for grid.updateRow(rowId, changes, 'cascade').
|
|
35
|
+
* Useful for cascade updates (e.g., calculating totals).
|
|
36
|
+
*/
|
|
37
|
+
updateRow: (changes: Partial<TRow>) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Mark this cell as invalid with an optional validation message.
|
|
40
|
+
* The cell remains editable but will be marked with `data-invalid` attribute.
|
|
41
|
+
* Use `cellClass` to apply custom styling to invalid cells.
|
|
42
|
+
*
|
|
43
|
+
* Call with no message to mark as invalid, or pass a message for tooltips/display.
|
|
44
|
+
* Call `clearInvalid()` on the plugin to remove the invalid state.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* grid.addEventListener('cell-commit', (e) => {
|
|
49
|
+
* if (e.detail.field === 'email' && !isValidEmail(e.detail.value)) {
|
|
50
|
+
* e.detail.setInvalid('Please enter a valid email address');
|
|
51
|
+
* }
|
|
52
|
+
* });
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
setInvalid: (message?: string) => void;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Detail payload for a committed row edit (may or may not include changes).
|
|
59
|
+
*
|
|
60
|
+
* Fired when a row editing session ends (focus leaves the row). The event is
|
|
61
|
+
* cancelable - call `preventDefault()` to revert the entire row to its state
|
|
62
|
+
* before editing began.
|
|
63
|
+
*
|
|
64
|
+
* Use this for row-level validation: if any cells are invalid, reject the
|
|
65
|
+
* entire row edit and force the user to correct the values.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* grid.addEventListener('row-commit', (e) => {
|
|
70
|
+
* const editingPlugin = grid.getPlugin(EditingPlugin);
|
|
71
|
+
* if (editingPlugin?.hasInvalidCells(e.detail.rowId)) {
|
|
72
|
+
* e.preventDefault(); // Revert row to original values
|
|
73
|
+
* alert('Please fix validation errors before leaving the row');
|
|
74
|
+
* }
|
|
75
|
+
* });
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* @category Events
|
|
79
|
+
*/
|
|
80
|
+
export interface RowCommitDetail<TRow = unknown> {
|
|
81
|
+
/** Row index that lost edit focus. */
|
|
82
|
+
rowIndex: number;
|
|
83
|
+
/** Stable row identifier (from getRowId). */
|
|
84
|
+
rowId: string;
|
|
85
|
+
/** Row object reference (current state after edits). */
|
|
86
|
+
row: TRow;
|
|
87
|
+
/** Snapshot of the row before edits (for comparison). */
|
|
88
|
+
oldValue: TRow | undefined;
|
|
89
|
+
/** Current row value after edits (same as `row`). */
|
|
90
|
+
newValue: TRow;
|
|
91
|
+
/** Whether any cell changes were actually committed in this row during the session. */
|
|
92
|
+
changed: boolean;
|
|
93
|
+
/** Current changed row collection. */
|
|
94
|
+
changedRows: TRow[];
|
|
95
|
+
/** IDs of changed rows. */
|
|
96
|
+
changedRowIds: string[];
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Emitted when the changed rows tracking set is cleared programmatically.
|
|
100
|
+
*
|
|
101
|
+
* Fired when `resetChangedRows()` is called.
|
|
102
|
+
*
|
|
103
|
+
* @category Events
|
|
104
|
+
*/
|
|
105
|
+
export interface ChangedRowsResetDetail<TRow = unknown> {
|
|
106
|
+
/** New (empty) changed rows array after reset. */
|
|
107
|
+
rows: TRow[];
|
|
108
|
+
/** IDs of changed rows (likely empty). */
|
|
109
|
+
ids: string[];
|
|
110
|
+
}
|
|
3
111
|
/**
|
|
4
112
|
* When EditingPlugin is imported, these properties become available on column config.
|
|
5
113
|
* This augments the core BaseColumnConfig interface.
|
|
@@ -90,6 +198,14 @@ declare module '../../core/types' {
|
|
|
90
198
|
*/
|
|
91
199
|
editOn?: 'click' | 'dblclick' | 'manual' | false;
|
|
92
200
|
}
|
|
201
|
+
interface DataGridEventMap<TRow = unknown> {
|
|
202
|
+
/** Fired when a cell value is committed (cancelable). */
|
|
203
|
+
'cell-commit': CellCommitDetail<TRow>;
|
|
204
|
+
/** Fired when a row editing session ends. */
|
|
205
|
+
'row-commit': RowCommitDetail<TRow>;
|
|
206
|
+
/** Fired when changed rows tracking is reset. */
|
|
207
|
+
'changed-rows-reset': ChangedRowsResetDetail<TRow>;
|
|
208
|
+
}
|
|
93
209
|
}
|
|
94
210
|
/**
|
|
95
211
|
* Configuration options for EditingPlugin.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/editing/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","source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CAAC;CACtB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,2CAA2C;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,gBAAgB,GAAG,kBAAkB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const m = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>',
|
|
1
|
+
const m = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>', w = {
|
|
2
2
|
expand: "▶",
|
|
3
3
|
collapse: "▼",
|
|
4
4
|
sortAsc: "▲",
|
|
@@ -11,7 +11,7 @@ const m = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentCo
|
|
|
11
11
|
filterActive: m,
|
|
12
12
|
print: "🖨️"
|
|
13
13
|
};
|
|
14
|
-
class
|
|
14
|
+
class x {
|
|
15
15
|
/**
|
|
16
16
|
* Plugin dependencies - declare other plugins this one requires.
|
|
17
17
|
*
|
|
@@ -208,10 +208,19 @@ class C {
|
|
|
208
208
|
}
|
|
209
209
|
/**
|
|
210
210
|
* Request a re-render of the grid.
|
|
211
|
+
* Uses ROWS phase - does NOT trigger processColumns hooks.
|
|
211
212
|
*/
|
|
212
213
|
requestRender() {
|
|
213
214
|
this.grid?.requestRender?.();
|
|
214
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Request a columns re-render of the grid.
|
|
218
|
+
* Uses COLUMNS phase - triggers processColumns hooks.
|
|
219
|
+
* Use this when your plugin needs to reprocess column configuration.
|
|
220
|
+
*/
|
|
221
|
+
requestColumnsRender() {
|
|
222
|
+
this.grid?.requestColumnsRender?.();
|
|
223
|
+
}
|
|
215
224
|
/**
|
|
216
225
|
* Request a re-render and restore focus styling afterward.
|
|
217
226
|
* Use this when a plugin action (like expand/collapse) triggers a render
|
|
@@ -292,7 +301,7 @@ class C {
|
|
|
292
301
|
*/
|
|
293
302
|
get gridIcons() {
|
|
294
303
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
295
|
-
return { ...
|
|
304
|
+
return { ...w, ...e };
|
|
296
305
|
}
|
|
297
306
|
// #region Animation Helpers
|
|
298
307
|
/**
|
|
@@ -378,22 +387,22 @@ function b(o, e = !0) {
|
|
|
378
387
|
}
|
|
379
388
|
function E(o, e, t, n = {}) {
|
|
380
389
|
const c = n.delimiter ?? ",", l = n.newline ?? `
|
|
381
|
-
`,
|
|
390
|
+
`, r = [], i = n.bom ? "\uFEFF" : "";
|
|
382
391
|
if (t.includeHeaders !== !1) {
|
|
383
392
|
const s = e.map((a) => {
|
|
384
393
|
const d = a.header || a.field, u = t.processHeader ? t.processHeader(d, a.field) : d;
|
|
385
394
|
return b(u);
|
|
386
395
|
});
|
|
387
|
-
|
|
396
|
+
r.push(s.join(c));
|
|
388
397
|
}
|
|
389
398
|
for (const s of o) {
|
|
390
399
|
const a = e.map((d) => {
|
|
391
400
|
let u = s[d.field];
|
|
392
401
|
return t.processCell && (u = t.processCell(u, d.field, s)), b(u);
|
|
393
402
|
});
|
|
394
|
-
|
|
403
|
+
r.push(a.join(c));
|
|
395
404
|
}
|
|
396
|
-
return
|
|
405
|
+
return i + r.join(l);
|
|
397
406
|
}
|
|
398
407
|
function h(o, e) {
|
|
399
408
|
const t = URL.createObjectURL(o), n = document.createElement("a");
|
|
@@ -403,7 +412,7 @@ function S(o, e) {
|
|
|
403
412
|
const t = new Blob([o], { type: "text/csv;charset=utf-8;" });
|
|
404
413
|
h(t, e);
|
|
405
414
|
}
|
|
406
|
-
function
|
|
415
|
+
function C(o) {
|
|
407
416
|
return o.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
408
417
|
}
|
|
409
418
|
function v(o, e, t) {
|
|
@@ -417,8 +426,8 @@ function v(o, e, t) {
|
|
|
417
426
|
n += `
|
|
418
427
|
<Row>`;
|
|
419
428
|
for (const c of e) {
|
|
420
|
-
const l = c.header || c.field,
|
|
421
|
-
n += `<Cell><Data ss:Type="String">${
|
|
429
|
+
const l = c.header || c.field, r = t.processHeader ? t.processHeader(l, c.field) : l;
|
|
430
|
+
n += `<Cell><Data ss:Type="String">${C(r)}</Data></Cell>`;
|
|
422
431
|
}
|
|
423
432
|
n += "</Row>";
|
|
424
433
|
}
|
|
@@ -426,10 +435,10 @@ function v(o, e, t) {
|
|
|
426
435
|
n += `
|
|
427
436
|
<Row>`;
|
|
428
437
|
for (const l of e) {
|
|
429
|
-
let
|
|
430
|
-
t.processCell && (
|
|
431
|
-
let
|
|
432
|
-
|
|
438
|
+
let r = c[l.field];
|
|
439
|
+
t.processCell && (r = t.processCell(r, l.field, c));
|
|
440
|
+
let i = "String", s = "";
|
|
441
|
+
r == null ? s = "" : typeof r == "number" && !isNaN(r) ? (i = "Number", s = String(r)) : r instanceof Date ? (i = "DateTime", s = r.toISOString()) : s = C(String(r)), n += `<Cell><Data ss:Type="${i}">${s}</Data></Cell>`;
|
|
433
442
|
}
|
|
434
443
|
n += "</Row>";
|
|
435
444
|
}
|
|
@@ -444,7 +453,7 @@ function y(o, e) {
|
|
|
444
453
|
});
|
|
445
454
|
h(n, t);
|
|
446
455
|
}
|
|
447
|
-
class
|
|
456
|
+
class R extends x {
|
|
448
457
|
/** @internal */
|
|
449
458
|
name = "export";
|
|
450
459
|
/** @internal */
|
|
@@ -476,27 +485,27 @@ class I extends C {
|
|
|
476
485
|
const s = new Set(t.columns);
|
|
477
486
|
l = l.filter((a) => s.has(a.field));
|
|
478
487
|
}
|
|
479
|
-
let
|
|
488
|
+
let r = [...this.rows];
|
|
480
489
|
if (n.onlySelected) {
|
|
481
490
|
const s = this.getSelectionState();
|
|
482
|
-
s?.selected?.size && (
|
|
491
|
+
s?.selected?.size && (r = [...s.selected].sort((d, u) => d - u).map((d) => this.rows[d]).filter(Boolean));
|
|
483
492
|
}
|
|
484
|
-
t?.rowIndices && (
|
|
485
|
-
let
|
|
493
|
+
t?.rowIndices && (r = t.rowIndices.map((s) => this.rows[s]).filter(Boolean)), this.isExportingFlag = !0;
|
|
494
|
+
let i = c.fileName;
|
|
486
495
|
try {
|
|
487
496
|
switch (e) {
|
|
488
497
|
case "csv": {
|
|
489
|
-
const s = E(
|
|
490
|
-
|
|
498
|
+
const s = E(r, l, c, { bom: !0 });
|
|
499
|
+
i = i.endsWith(".csv") ? i : `${i}.csv`, S(s, i);
|
|
491
500
|
break;
|
|
492
501
|
}
|
|
493
502
|
case "excel": {
|
|
494
|
-
const s = v(
|
|
495
|
-
|
|
503
|
+
const s = v(r, l, c);
|
|
504
|
+
i = i.endsWith(".xls") ? i : `${i}.xls`, y(s, i);
|
|
496
505
|
break;
|
|
497
506
|
}
|
|
498
507
|
case "json": {
|
|
499
|
-
const s =
|
|
508
|
+
const s = r.map((u) => {
|
|
500
509
|
const p = {};
|
|
501
510
|
for (const f of l) {
|
|
502
511
|
let g = u[f.field];
|
|
@@ -504,16 +513,16 @@ class I extends C {
|
|
|
504
513
|
}
|
|
505
514
|
return p;
|
|
506
515
|
}), a = JSON.stringify(s, null, 2);
|
|
507
|
-
|
|
516
|
+
i = i.endsWith(".json") ? i : `${i}.json`;
|
|
508
517
|
const d = new Blob([a], { type: "application/json" });
|
|
509
|
-
h(d,
|
|
518
|
+
h(d, i);
|
|
510
519
|
break;
|
|
511
520
|
}
|
|
512
521
|
}
|
|
513
522
|
this.lastExportInfo = { format: e, timestamp: /* @__PURE__ */ new Date() }, this.emit("export-complete", {
|
|
514
523
|
format: e,
|
|
515
|
-
fileName:
|
|
516
|
-
rowCount:
|
|
524
|
+
fileName: i,
|
|
525
|
+
rowCount: r.length,
|
|
517
526
|
columnCount: l.length
|
|
518
527
|
});
|
|
519
528
|
} finally {
|
|
@@ -567,6 +576,6 @@ class I extends C {
|
|
|
567
576
|
// #endregion
|
|
568
577
|
}
|
|
569
578
|
export {
|
|
570
|
-
|
|
579
|
+
R as ExportPlugin
|
|
571
580
|
};
|
|
572
581
|
//# sourceMappingURL=index.js.map
|