@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.
Files changed (58) hide show
  1. package/README.md +40 -14
  2. package/all.js +25 -23
  3. package/all.js.map +1 -1
  4. package/index.js +410 -365
  5. package/index.js.map +1 -1
  6. package/lib/core/grid.d.ts +81 -12
  7. package/lib/core/grid.d.ts.map +1 -1
  8. package/lib/core/internal/event-delegation.d.ts.map +1 -1
  9. package/lib/core/internal/row-animation.d.ts +6 -6
  10. package/lib/core/internal/row-animation.d.ts.map +1 -1
  11. package/lib/core/internal/sorting.d.ts +6 -0
  12. package/lib/core/internal/sorting.d.ts.map +1 -1
  13. package/lib/core/types.d.ts +10 -6
  14. package/lib/core/types.d.ts.map +1 -1
  15. package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
  16. package/lib/plugins/clipboard/index.js +54 -54
  17. package/lib/plugins/clipboard/index.js.map +1 -1
  18. package/lib/plugins/column-virtualization/index.js.map +1 -1
  19. package/lib/plugins/context-menu/index.js.map +1 -1
  20. package/lib/plugins/editing/index.js.map +1 -1
  21. package/lib/plugins/export/index.js.map +1 -1
  22. package/lib/plugins/filtering/index.js.map +1 -1
  23. package/lib/plugins/grouping-columns/index.js.map +1 -1
  24. package/lib/plugins/grouping-rows/index.js.map +1 -1
  25. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
  26. package/lib/plugins/master-detail/index.js +1 -1
  27. package/lib/plugins/master-detail/index.js.map +1 -1
  28. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +8 -0
  29. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
  30. package/lib/plugins/multi-sort/index.js +23 -12
  31. package/lib/plugins/multi-sort/index.js.map +1 -1
  32. package/lib/plugins/pinned-columns/index.js.map +1 -1
  33. package/lib/plugins/pinned-rows/index.js.map +1 -1
  34. package/lib/plugins/pivot/index.js.map +1 -1
  35. package/lib/plugins/print/index.js.map +1 -1
  36. package/lib/plugins/reorder/index.js.map +1 -1
  37. package/lib/plugins/responsive/index.js.map +1 -1
  38. package/lib/plugins/row-reorder/index.js.map +1 -1
  39. package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
  40. package/lib/plugins/selection/index.js +93 -95
  41. package/lib/plugins/selection/index.js.map +1 -1
  42. package/lib/plugins/server-side/index.js.map +1 -1
  43. package/lib/plugins/tree/index.js.map +1 -1
  44. package/lib/plugins/undo-redo/index.js.map +1 -1
  45. package/lib/plugins/visibility/index.js.map +1 -1
  46. package/package.json +1 -1
  47. package/umd/grid.all.umd.js +20 -20
  48. package/umd/grid.all.umd.js.map +1 -1
  49. package/umd/grid.umd.js +15 -15
  50. package/umd/grid.umd.js.map +1 -1
  51. package/umd/plugins/clipboard.umd.js +4 -4
  52. package/umd/plugins/clipboard.umd.js.map +1 -1
  53. package/umd/plugins/master-detail.umd.js +1 -1
  54. package/umd/plugins/master-detail.umd.js.map +1 -1
  55. package/umd/plugins/multi-sort.umd.js +1 -1
  56. package/umd/plugins/multi-sort.umd.js.map +1 -1
  57. package/umd/plugins/selection.umd.js +1 -1
  58. package/umd/plugins/selection.umd.js.map +1 -1
@@ -93,6 +93,14 @@ export declare class MultiSortPlugin extends BaseGridPlugin<MultiSortConfig> {
93
93
  * the edited row from jumping to a new sorted position mid-edit. Row data
94
94
  * mutations are still visible because the array holds shared object refs. */
95
95
  private cachedSortResult;
96
+ /**
97
+ * Clear the core `_sortState` so that only this plugin's `processRows`
98
+ * sorting applies. `ConfigManager.applyState()` always sets the core sort
99
+ * state when restoring from storage, even when a plugin handles sorting.
100
+ * Without this, the stale core state leaks into `collectState()` and
101
+ * `reapplyCoreSort()` after the plugin clears its own model.
102
+ */
103
+ private clearCoreSortState;
96
104
  /** @internal */
97
105
  detach(): void;
98
106
  /** @internal */
@@ -1 +1 @@
1
- {"version":3,"file":"MultiSortPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/gr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AE,SAAS,EAAE,GAAG,IAAI;IAQtC;;OAEG;IACH,SAAS,IAAI,IAAI;IAQjB;;;;OAIG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI/C;;;;OAIG;IACH,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS;IAO3D;;;OAGG;IACM,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,SAAS;IAaxE;;;;OAIG;IACM,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI;CA6BnE"}
@@ -1,4 +1,4 @@
1
- const f = '<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>', S = {
1
+ const f = '<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>', b = {
2
2
  expand: "▶",
3
3
  collapse: "▼",
4
4
  sortAsc: "▲",
@@ -301,7 +301,7 @@ class C {
301
301
  */
302
302
  get gridIcons() {
303
303
  const t = this.grid?.gridConfig?.icons ?? {};
304
- return { ...S, ...t };
304
+ return { ...b, ...t };
305
305
  }
306
306
  // #region Animation Helpers
307
307
  /**
@@ -380,7 +380,7 @@ class C {
380
380
  function v(i, t, e) {
381
381
  return t.length ? [...i].sort((n, r) => {
382
382
  for (const s of t) {
383
- const d = e.find((u) => u.field === s.field)?.sortComparator ?? x, g = n[s.field], c = r[s.field], o = d(g, c, n, r);
383
+ const d = e.find((u) => u.field === s.field)?.sortComparator ?? x, h = n[s.field], c = r[s.field], o = d(h, c, n, r);
384
384
  if (o !== 0)
385
385
  return s.direction === "asc" ? o : -o;
386
386
  }
@@ -398,7 +398,7 @@ function m(i, t) {
398
398
  const e = i.findIndex((n) => n.field === t);
399
399
  return e >= 0 ? e + 1 : void 0;
400
400
  }
401
- function p(i, t) {
401
+ function S(i, t) {
402
402
  return i.find((e) => e.field === t)?.direction;
403
403
  }
404
404
  const w = '@layer tbw-plugins{.header-cell[data-sort=asc]:after{content:"↑";margin-left:var(--tbw-spacing-xs, .25em);opacity:.8}.header-cell[data-sort=desc]:after{content:"↓";margin-left:var(--tbw-spacing-xs, .25em);opacity:.8}.sort-indicator{margin-left:var(--tbw-spacing-xs, .25em);opacity:.8}.sort-index{font-size:var(--tbw-font-size-2xs, .7em);background:var(--tbw-multi-sort-badge-bg, var(--tbw-color-panel-bg));color:var(--tbw-multi-sort-badge-color, var(--tbw-color-fg));border-radius:50%;width:var(--tbw-multi-sort-badge-size, 1em);height:var(--tbw-multi-sort-badge-size, 1em);display:inline-flex;align-items:center;justify-content:center;margin-left:var(--tbw-spacing-xs, .125em);font-weight:600}}';
@@ -420,6 +420,17 @@ class y extends C {
420
420
  * the edited row from jumping to a new sorted position mid-edit. Row data
421
421
  * mutations are still visible because the array holds shared object refs. */
422
422
  cachedSortResult = null;
423
+ /**
424
+ * Clear the core `_sortState` so that only this plugin's `processRows`
425
+ * sorting applies. `ConfigManager.applyState()` always sets the core sort
426
+ * state when restoring from storage, even when a plugin handles sorting.
427
+ * Without this, the stale core state leaks into `collectState()` and
428
+ * `reapplyCoreSort()` after the plugin clears its own model.
429
+ */
430
+ clearCoreSortState() {
431
+ const t = this.gridElement;
432
+ t && (t._sortState = null);
433
+ }
423
434
  // #endregion
424
435
  // #region Lifecycle
425
436
  /** @internal */
@@ -442,7 +453,7 @@ class y extends C {
442
453
  onHeaderClick(t) {
443
454
  if (!this.columns.find((s) => s.field === t.field)?.sortable) return !1;
444
455
  const n = t.originalEvent.shiftKey, r = this.config.maxSortColumns ?? 3;
445
- return this.sortModel = M(this.sortModel, t.field, n, r), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), this.grid?.requestStateChange?.(), !0;
456
+ return this.sortModel = M(this.sortModel, t.field, n, r), this.clearCoreSortState(), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), this.grid?.requestStateChange?.(), !0;
446
457
  }
447
458
  /** @internal */
448
459
  afterRender() {
@@ -452,13 +463,13 @@ class y extends C {
452
463
  t.querySelectorAll(".header-row .cell[data-field]").forEach((r) => {
453
464
  const s = r.getAttribute("data-field");
454
465
  if (!s) return;
455
- const a = m(this.sortModel, s), d = p(this.sortModel, s);
466
+ const a = m(this.sortModel, s), d = S(this.sortModel, s);
456
467
  if (r.querySelector(".sort-index")?.remove(), d) {
457
468
  r.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), r.setAttribute("data-sort", d);
458
469
  const o = document.createElement("span");
459
470
  o.className = "sort-indicator", this.setIcon(o, this.resolveIcon(d === "asc" ? "sortAsc" : "sortDesc"));
460
- const u = r.querySelector(".tbw-filter-btn"), b = r.querySelector(".resize-handle"), h = u ?? b;
461
- if (h ? r.insertBefore(o, h) : r.appendChild(o), e && this.sortModel.length > 1 && a !== void 0) {
471
+ const u = r.querySelector(".tbw-filter-btn"), p = r.querySelector(".resize-handle"), g = u ?? p;
472
+ if (g ? r.insertBefore(o, g) : r.appendChild(o), e && this.sortModel.length > 1 && a !== void 0) {
462
473
  const l = document.createElement("span");
463
474
  l.className = "sort-index", l.textContent = String(a), o.nextSibling ? r.insertBefore(l, o.nextSibling) : r.appendChild(l);
464
475
  }
@@ -480,13 +491,13 @@ class y extends C {
480
491
  * @param model - New sort model to apply
481
492
  */
482
493
  setSortModel(t) {
483
- this.sortModel = [...t], this.emit("sort-change", { sortModel: [...t] }), this.requestRender(), this.grid?.requestStateChange?.();
494
+ this.sortModel = [...t], this.clearCoreSortState(), this.emit("sort-change", { sortModel: [...t] }), this.requestRender(), this.grid?.requestStateChange?.();
484
495
  }
485
496
  /**
486
497
  * Clear all sorting.
487
498
  */
488
499
  clearSort() {
489
- this.sortModel = [], this.emit("sort-change", { sortModel: [] }), this.requestRender(), this.grid?.requestStateChange?.();
500
+ this.sortModel = [], this.clearCoreSortState(), this.emit("sort-change", { sortModel: [] }), this.requestRender(), this.grid?.requestStateChange?.();
490
501
  }
491
502
  /**
492
503
  * Get the sort index (1-based) for a specific field.
@@ -502,7 +513,7 @@ class y extends C {
502
513
  * @returns Sort direction or undefined if not sorted
503
514
  */
504
515
  getSortDirection(t) {
505
- return p(this.sortModel, t);
516
+ return S(this.sortModel, t);
506
517
  }
507
518
  // #endregion
508
519
  // #region Column State Hooks
@@ -533,7 +544,7 @@ class y extends C {
533
544
  field: t,
534
545
  direction: e.sort.direction
535
546
  };
536
- n !== -1 ? this.sortModel[n] = r : this.sortModel.splice(e.sort.priority, 0, r);
547
+ n !== -1 ? this.sortModel[n] = r : this.sortModel.splice(e.sort.priority, 0, r), this.clearCoreSortState();
537
548
  }
538
549
  // #endregion
539
550
  }