@toolbox-web/grid 1.20.0 → 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.
Files changed (43) hide show
  1. package/README.md +40 -14
  2. package/all.js +8 -4
  3. package/all.js.map +1 -1
  4. package/index.js +271 -238
  5. package/index.js.map +1 -1
  6. package/lib/core/grid.d.ts +81 -34
  7. package/lib/core/grid.d.ts.map +1 -1
  8. package/lib/core/internal/row-animation.d.ts +6 -6
  9. package/lib/core/internal/row-animation.d.ts.map +1 -1
  10. package/lib/core/types.d.ts +10 -12
  11. package/lib/core/types.d.ts.map +1 -1
  12. package/lib/plugins/clipboard/index.js.map +1 -1
  13. package/lib/plugins/column-virtualization/index.js.map +1 -1
  14. package/lib/plugins/context-menu/index.js.map +1 -1
  15. package/lib/plugins/editing/index.js.map +1 -1
  16. package/lib/plugins/export/index.js.map +1 -1
  17. package/lib/plugins/filtering/index.js.map +1 -1
  18. package/lib/plugins/grouping-columns/index.js.map +1 -1
  19. package/lib/plugins/grouping-rows/index.js.map +1 -1
  20. package/lib/plugins/master-detail/index.js.map +1 -1
  21. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +8 -0
  22. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
  23. package/lib/plugins/multi-sort/index.js +23 -12
  24. package/lib/plugins/multi-sort/index.js.map +1 -1
  25. package/lib/plugins/pinned-columns/index.js.map +1 -1
  26. package/lib/plugins/pinned-rows/index.js.map +1 -1
  27. package/lib/plugins/pivot/index.js.map +1 -1
  28. package/lib/plugins/print/index.js.map +1 -1
  29. package/lib/plugins/reorder/index.js.map +1 -1
  30. package/lib/plugins/responsive/index.js.map +1 -1
  31. package/lib/plugins/row-reorder/index.js.map +1 -1
  32. package/lib/plugins/selection/index.js.map +1 -1
  33. package/lib/plugins/server-side/index.js.map +1 -1
  34. package/lib/plugins/tree/index.js.map +1 -1
  35. package/lib/plugins/undo-redo/index.js.map +1 -1
  36. package/lib/plugins/visibility/index.js.map +1 -1
  37. package/package.json +1 -1
  38. package/umd/grid.all.umd.js +11 -11
  39. package/umd/grid.all.umd.js.map +1 -1
  40. package/umd/grid.umd.js +12 -12
  41. package/umd/grid.umd.js.map +1 -1
  42. package/umd/plugins/multi-sort.umd.js +1 -1
  43. package/umd/plugins/multi-sort.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 | Description |
258
- | ---------------------------- | --------- | ------------------------------------------- |
259
- | `animateRow(index, type)` | `void` | Animate a single row (change/insert/remove) |
260
- | `animateRows(indices, type)` | `void` | Animate multiple rows at once |
261
- | `animateRowById(id, type)` | `boolean` | Animate row by ID (returns true if found) |
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
- ### Row Animation API
317
+ ### Insert & Remove Rows
311
318
 
312
- Trigger visual feedback when rows change:
319
+ Add or remove rows at a specific visible position without re-running the sort/filter pipeline:
313
320
 
314
321
  ```typescript
315
- // Flash highlight for updated row
316
- grid.animateRow(5, 'change');
322
+ // Insert with animation (default)
323
+ grid.insertRow(3, newEmployee);
317
324
 
318
- // Slide-in for new row
319
- grid.animateRow(0, 'insert');
325
+ // Insert without animation
326
+ grid.insertRow(3, newEmployee, false);
320
327
 
321
- // Fade-out for removed row
322
- grid.animateRow(3, 'remove');
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
@@ -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) {