@toolbox-web/grid 1.19.3 → 1.21.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/README.md +40 -14
- package/all.js +25 -23
- package/all.js.map +1 -1
- package/index.js +410 -365
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +81 -12
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/event-delegation.d.ts.map +1 -1
- package/lib/core/internal/row-animation.d.ts +6 -6
- package/lib/core/internal/row-animation.d.ts.map +1 -1
- package/lib/core/internal/sorting.d.ts +6 -0
- package/lib/core/internal/sorting.d.ts.map +1 -1
- package/lib/core/types.d.ts +10 -6
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +54 -54
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
- package/lib/plugins/master-detail/index.js +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +8 -0
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
- package/lib/plugins/multi-sort/index.js +23 -12
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +93 -95
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +20 -20
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +15 -15
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +4 -4
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -252,13 +252,20 @@ The grid supports configuration via HTML attributes with JSON-serialized values:
|
|
|
252
252
|
| `isCellLoading(rowId, field)` | `boolean` | Check if cell is loading |
|
|
253
253
|
| `clearAllLoading()` | `void` | Clear all loading states |
|
|
254
254
|
|
|
255
|
+
#### Row Mutation Methods
|
|
256
|
+
|
|
257
|
+
| Method | Returns | Description |
|
|
258
|
+
| --------------------------------- | ------------------------- | -------------------------------------------------- |
|
|
259
|
+
| `insertRow(index, row, animate?)` | `Promise<void>` | Insert a row at a visible position (auto-animates) |
|
|
260
|
+
| `removeRow(index, animate?)` | `Promise<T \| undefined>` | Remove a row at a visible position (auto-animates) |
|
|
261
|
+
|
|
255
262
|
#### Animation Methods
|
|
256
263
|
|
|
257
|
-
| Method | Returns
|
|
258
|
-
| ---------------------------- |
|
|
259
|
-
| `animateRow(index, type)` | `
|
|
260
|
-
| `animateRows(indices, type)` | `
|
|
261
|
-
| `animateRowById(id, type)` | `boolean
|
|
264
|
+
| Method | Returns | Description |
|
|
265
|
+
| ---------------------------- | ------------------ | ------------------------------------------- |
|
|
266
|
+
| `animateRow(index, type)` | `Promise<boolean>` | Animate a single row (change/insert/remove) |
|
|
267
|
+
| `animateRows(indices, type)` | `Promise<number>` | Animate multiple rows at once |
|
|
268
|
+
| `animateRowById(id, type)` | `Promise<boolean>` | Animate row by ID (resolves true if found) |
|
|
262
269
|
|
|
263
270
|
#### Plugin Methods
|
|
264
271
|
|
|
@@ -307,24 +314,43 @@ import { DGEvents } from '@toolbox-web/grid';
|
|
|
307
314
|
grid.addEventListener(DGEvents.CELL_COMMIT, handler);
|
|
308
315
|
```
|
|
309
316
|
|
|
310
|
-
###
|
|
317
|
+
### Insert & Remove Rows
|
|
311
318
|
|
|
312
|
-
|
|
319
|
+
Add or remove rows at a specific visible position without re-running the sort/filter pipeline:
|
|
313
320
|
|
|
314
321
|
```typescript
|
|
315
|
-
//
|
|
316
|
-
grid.
|
|
322
|
+
// Insert with animation (default)
|
|
323
|
+
grid.insertRow(3, newEmployee);
|
|
317
324
|
|
|
318
|
-
//
|
|
319
|
-
grid.
|
|
325
|
+
// Insert without animation
|
|
326
|
+
grid.insertRow(3, newEmployee, false);
|
|
320
327
|
|
|
321
|
-
//
|
|
322
|
-
grid.
|
|
328
|
+
// Remove with fade-out animation and await completion
|
|
329
|
+
await grid.removeRow(5);
|
|
330
|
+
|
|
331
|
+
// Remove without animation
|
|
332
|
+
const removed = await grid.removeRow(5, false);
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
Both methods update the source data automatically. The next full `grid.rows = freshData` assignment re-sorts/re-filters normally. Do **not** use them for bulk data refreshes — assign `grid.rows` directly instead.
|
|
336
|
+
|
|
337
|
+
### Row Animation API
|
|
338
|
+
|
|
339
|
+
All animation methods return **Promises** that resolve when the animation completes:
|
|
340
|
+
|
|
341
|
+
```typescript
|
|
342
|
+
// Flash highlight for updated row
|
|
343
|
+
await grid.animateRow(5, 'change');
|
|
323
344
|
|
|
324
345
|
// Animate by row ID
|
|
325
|
-
grid.animateRowById('emp-123', 'change');
|
|
346
|
+
await grid.animateRowById('emp-123', 'change');
|
|
347
|
+
|
|
348
|
+
// Animate multiple rows
|
|
349
|
+
await grid.animateRows([0, 1, 2], 'change');
|
|
326
350
|
```
|
|
327
351
|
|
|
352
|
+
> **Note:** `insertRow` and `removeRow` handle animation automatically — you only need `animateRow` directly for highlighting existing rows (e.g., after an external data update).
|
|
353
|
+
|
|
328
354
|
**Animation Types:** `'change'` | `'insert'` | `'remove'`
|
|
329
355
|
|
|
330
356
|
### Animation Configuration
|
package/all.js
CHANGED
|
@@ -111,10 +111,10 @@ class In extends F {
|
|
|
111
111
|
const t = e.clipboardData?.getData("text/plain");
|
|
112
112
|
if (!t) return;
|
|
113
113
|
e.preventDefault();
|
|
114
|
-
const i = _e(t, this.config), n = this.#s(), r = n?.ranges?.[0], o = r?.from.row ?? 0, s = r?.from.col ?? 0, d = r && (n?.mode === "range" || n?.mode === "row") && (r.from.row !== r.to.row || r.from.col !== r.to.col) ? { endRow: r.to.row, endCol: r.to.col } : null, c = d?.endCol ?? this.
|
|
114
|
+
const i = _e(t, this.config), n = this.#s(), r = n?.ranges?.[0], o = r?.from.row ?? 0, s = r?.from.col ?? 0, d = r && (n?.mode === "range" || n?.mode === "row") && (r.from.row !== r.to.row || r.from.col !== r.to.col) ? { endRow: r.to.row, endCol: r.to.col } : null, c = d?.endCol ?? this.visibleColumns.length - 1, u = this.visibleColumns[s], h = u ? { row: o, col: s, field: u.field, bounds: d } : null, f = [], g = i[0]?.length ?? 0;
|
|
115
115
|
for (let m = 0; m < g && s + m <= c; m++) {
|
|
116
|
-
const y = this.
|
|
117
|
-
y &&
|
|
116
|
+
const y = this.visibleColumns[s + m];
|
|
117
|
+
y && f.push(y.field);
|
|
118
118
|
}
|
|
119
119
|
const p = { rows: i, text: t, target: h, fields: f };
|
|
120
120
|
this.emit("paste", p), this.#o(p);
|
|
@@ -135,7 +135,7 @@ class In extends F {
|
|
|
135
135
|
i = ie(this.columns, e.columns);
|
|
136
136
|
else if (t?.ranges.length && t.mode !== "row") {
|
|
137
137
|
const r = t.ranges[t.ranges.length - 1], o = Math.min(r.from.col, r.to.col), s = Math.max(r.from.col, r.to.col);
|
|
138
|
-
i = ie(this.
|
|
138
|
+
i = ie(this.visibleColumns.slice(o, s + 1));
|
|
139
139
|
} else
|
|
140
140
|
i = ie(this.columns);
|
|
141
141
|
let n;
|
|
@@ -3182,7 +3182,7 @@ class ut extends F {
|
|
|
3182
3182
|
}
|
|
3183
3183
|
onKeyDown(e) {
|
|
3184
3184
|
if (e.key !== " ") return;
|
|
3185
|
-
const t = this.grid._focusCol, i = this.grid._focusRow, n = this.
|
|
3185
|
+
const t = this.grid._focusCol, i = this.grid._focusRow, n = this.visibleColumns[t];
|
|
3186
3186
|
if (!n || !se(n)) return;
|
|
3187
3187
|
const r = this.rows[i];
|
|
3188
3188
|
if (r)
|
|
@@ -3364,6 +3364,10 @@ class qn extends F {
|
|
|
3364
3364
|
}
|
|
3365
3365
|
sortModel = [];
|
|
3366
3366
|
cachedSortResult = null;
|
|
3367
|
+
clearCoreSortState() {
|
|
3368
|
+
const e = this.gridElement;
|
|
3369
|
+
e && (e._sortState = null);
|
|
3370
|
+
}
|
|
3367
3371
|
detach() {
|
|
3368
3372
|
this.sortModel = [], this.cachedSortResult = null;
|
|
3369
3373
|
}
|
|
@@ -3379,7 +3383,7 @@ class qn extends F {
|
|
|
3379
3383
|
onHeaderClick(e) {
|
|
3380
3384
|
if (!this.columns.find((r) => r.field === e.field)?.sortable) return !1;
|
|
3381
3385
|
const i = e.originalEvent.shiftKey, n = this.config.maxSortColumns ?? 3;
|
|
3382
|
-
return this.sortModel = Ci(this.sortModel, e.field, i, n), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), this.grid?.requestStateChange?.(), !0;
|
|
3386
|
+
return this.sortModel = Ci(this.sortModel, e.field, i, n), this.clearCoreSortState(), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), this.grid?.requestStateChange?.(), !0;
|
|
3383
3387
|
}
|
|
3384
3388
|
afterRender() {
|
|
3385
3389
|
const e = this.gridElement;
|
|
@@ -3406,10 +3410,10 @@ class qn extends F {
|
|
|
3406
3410
|
return [...this.sortModel];
|
|
3407
3411
|
}
|
|
3408
3412
|
setSortModel(e) {
|
|
3409
|
-
this.sortModel = [...e], this.emit("sort-change", { sortModel: [...e] }), this.requestRender(), this.grid?.requestStateChange?.();
|
|
3413
|
+
this.sortModel = [...e], this.clearCoreSortState(), this.emit("sort-change", { sortModel: [...e] }), this.requestRender(), this.grid?.requestStateChange?.();
|
|
3410
3414
|
}
|
|
3411
3415
|
clearSort() {
|
|
3412
|
-
this.sortModel = [], this.emit("sort-change", { sortModel: [] }), this.requestRender(), this.grid?.requestStateChange?.();
|
|
3416
|
+
this.sortModel = [], this.clearCoreSortState(), this.emit("sort-change", { sortModel: [] }), this.requestRender(), this.grid?.requestStateChange?.();
|
|
3413
3417
|
}
|
|
3414
3418
|
getSortIndex(e) {
|
|
3415
3419
|
return Be(this.sortModel, e);
|
|
@@ -3435,7 +3439,7 @@ class qn extends F {
|
|
|
3435
3439
|
field: e,
|
|
3436
3440
|
direction: t.sort.direction
|
|
3437
3441
|
};
|
|
3438
|
-
i !== -1 ? this.sortModel[i] = n : this.sortModel.splice(t.sort.priority, 0, n);
|
|
3442
|
+
i !== -1 ? this.sortModel[i] = n : this.sortModel.splice(t.sort.priority, 0, n), this.clearCoreSortState();
|
|
3439
3443
|
}
|
|
3440
3444
|
}
|
|
3441
3445
|
function O(a) {
|
|
@@ -5626,7 +5630,7 @@ class Bn extends F {
|
|
|
5626
5630
|
if (!i) return !0;
|
|
5627
5631
|
const n = this.rows[e];
|
|
5628
5632
|
if (!n) return !1;
|
|
5629
|
-
const r = t !== void 0 ? this.
|
|
5633
|
+
const r = t !== void 0 ? this.visibleColumns[t] : void 0;
|
|
5630
5634
|
return i(n, e, r, t);
|
|
5631
5635
|
}
|
|
5632
5636
|
isRowSelectable(e) {
|
|
@@ -5659,7 +5663,7 @@ class Bn extends F {
|
|
|
5659
5663
|
const { rowIndex: t, colIndex: i, originalEvent: n } = e, { mode: r, triggerOn: o = "click" } = this.config;
|
|
5660
5664
|
if (n.type !== o)
|
|
5661
5665
|
return !1;
|
|
5662
|
-
const s =
|
|
5666
|
+
const s = e.column, l = s && W(s);
|
|
5663
5667
|
if (r === "cell") {
|
|
5664
5668
|
if (l || !this.isCellSelectable(t, i))
|
|
5665
5669
|
return !1;
|
|
@@ -5752,25 +5756,23 @@ class Bn extends F {
|
|
|
5752
5756
|
return t === "range" && this.config.multiSelect !== !1 && e.key === "a" && (e.ctrlKey || e.metaKey) ? this.grid.query("isEditing").some(Boolean) ? !1 : (e.preventDefault(), e.stopPropagation(), this.selectAll(), !0) : !1;
|
|
5753
5757
|
}
|
|
5754
5758
|
onCellMouseDown(e) {
|
|
5755
|
-
if (!this.isSelectionEnabled() || this.config.mode !== "range" || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0)
|
|
5756
|
-
const t = this.columns[e.colIndex];
|
|
5757
|
-
if (t && W(t) || !this.isCellSelectable(e.rowIndex, e.colIndex) || e.originalEvent.shiftKey && this.cellAnchor)
|
|
5759
|
+
if (!this.isSelectionEnabled() || this.config.mode !== "range" || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0 || e.column && W(e.column) || !this.isCellSelectable(e.rowIndex, e.colIndex) || e.originalEvent.shiftKey && this.cellAnchor)
|
|
5758
5760
|
return;
|
|
5759
5761
|
this.isDragging = !0;
|
|
5760
|
-
const
|
|
5761
|
-
startRow:
|
|
5762
|
-
startCol:
|
|
5763
|
-
endRow:
|
|
5764
|
-
endCol:
|
|
5762
|
+
const t = e.rowIndex, i = e.colIndex, n = (e.originalEvent.ctrlKey || e.originalEvent.metaKey) && this.config.multiSelect !== !1, r = {
|
|
5763
|
+
startRow: t,
|
|
5764
|
+
startCol: i,
|
|
5765
|
+
endRow: t,
|
|
5766
|
+
endCol: i
|
|
5765
5767
|
};
|
|
5766
|
-
return !
|
|
5768
|
+
return !n && this.ranges.length === 1 && ee(this.ranges[0], r) ? (this.cellAnchor = { row: t, col: i }, !0) : (this.cellAnchor = { row: t, col: i }, n || (this.ranges = []), this.ranges.push(r), this.activeRange = r, this.emit("selection-change", this.#i()), this.requestAfterRender(), !0);
|
|
5767
5769
|
}
|
|
5768
5770
|
onCellMouseMove(e) {
|
|
5769
5771
|
if (!this.isSelectionEnabled() || this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
|
|
5770
5772
|
let t = e.colIndex;
|
|
5771
|
-
const i = this.
|
|
5773
|
+
const i = this.visibleColumns[t];
|
|
5772
5774
|
if (i && W(i)) {
|
|
5773
|
-
const o = this.
|
|
5775
|
+
const o = this.visibleColumns.findIndex((s) => !W(s));
|
|
5774
5776
|
o >= 0 && (t = o);
|
|
5775
5777
|
}
|
|
5776
5778
|
const n = ge(this.cellAnchor, { row: e.rowIndex, col: t }), r = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
|
|
@@ -5887,7 +5889,7 @@ class Bn extends F {
|
|
|
5887
5889
|
e.querySelectorAll(".cell[data-row][data-col]").forEach((d) => {
|
|
5888
5890
|
const c = parseInt(d.getAttribute("data-row") ?? "-1", 10), u = parseInt(d.getAttribute("data-col") ?? "-1", 10);
|
|
5889
5891
|
if (c >= 0 && u >= 0) {
|
|
5890
|
-
const h = this.
|
|
5892
|
+
const h = this.visibleColumns[u];
|
|
5891
5893
|
if (h && W(h))
|
|
5892
5894
|
return;
|
|
5893
5895
|
s(c, u) && (d.classList.add("selected"), s(c - 1, u) || d.classList.add("top"), s(c + 1, u) || d.classList.add("bottom"), s(c, u - 1) || d.classList.add("first"), s(c, u + 1) || d.classList.add("last"));
|