@toolbox-web/grid 1.6.2 → 1.8.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 (114) hide show
  1. package/README.md +51 -15
  2. package/all.js +267 -158
  3. package/all.js.map +1 -1
  4. package/index.js +866 -722
  5. package/index.js.map +1 -1
  6. package/lib/core/grid.d.ts +68 -1
  7. package/lib/core/grid.d.ts.map +1 -1
  8. package/lib/core/internal/header.d.ts.map +1 -1
  9. package/lib/core/plugin/base-plugin.d.ts +182 -1
  10. package/lib/core/plugin/base-plugin.d.ts.map +1 -1
  11. package/lib/core/plugin/index.d.ts +1 -1
  12. package/lib/core/plugin/index.d.ts.map +1 -1
  13. package/lib/core/plugin/plugin-manager.d.ts +56 -1
  14. package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
  15. package/lib/core/plugin/types.d.ts +36 -0
  16. package/lib/core/plugin/types.d.ts.map +1 -1
  17. package/lib/core/types.d.ts +1349 -31
  18. package/lib/core/types.d.ts.map +1 -1
  19. package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
  20. package/lib/plugins/clipboard/index.js +140 -87
  21. package/lib/plugins/clipboard/index.js.map +1 -1
  22. package/lib/plugins/column-virtualization/index.js +64 -7
  23. package/lib/plugins/column-virtualization/index.js.map +1 -1
  24. package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
  25. package/lib/plugins/context-menu/index.js +123 -65
  26. package/lib/plugins/context-menu/index.js.map +1 -1
  27. package/lib/plugins/editing/EditingPlugin.d.ts +6 -1
  28. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
  29. package/lib/plugins/editing/index.js +95 -13
  30. package/lib/plugins/editing/index.js.map +1 -1
  31. package/lib/plugins/export/index.js +91 -34
  32. package/lib/plugins/export/index.js.map +1 -1
  33. package/lib/plugins/filtering/FilteringPlugin.d.ts +6 -1
  34. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  35. package/lib/plugins/filtering/index.js +192 -123
  36. package/lib/plugins/filtering/index.js.map +1 -1
  37. package/lib/plugins/grouping-columns/index.js +57 -0
  38. package/lib/plugins/grouping-columns/index.js.map +1 -1
  39. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +7 -2
  40. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
  41. package/lib/plugins/grouping-rows/index.js +142 -60
  42. package/lib/plugins/grouping-rows/index.js.map +1 -1
  43. package/lib/plugins/master-detail/index.js +69 -12
  44. package/lib/plugins/master-detail/index.js.map +1 -1
  45. package/lib/plugins/multi-sort/index.js +70 -13
  46. package/lib/plugins/multi-sort/index.js.map +1 -1
  47. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +3 -3
  48. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
  49. package/lib/plugins/pinned-columns/index.js +106 -36
  50. package/lib/plugins/pinned-columns/index.js.map +1 -1
  51. package/lib/plugins/pinned-rows/index.js +57 -0
  52. package/lib/plugins/pinned-rows/index.js.map +1 -1
  53. package/lib/plugins/pivot/index.js +57 -0
  54. package/lib/plugins/pivot/index.js.map +1 -1
  55. package/lib/plugins/print/PrintPlugin.d.ts.map +1 -1
  56. package/lib/plugins/print/index.js +58 -1
  57. package/lib/plugins/print/index.js.map +1 -1
  58. package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
  59. package/lib/plugins/reorder/column-drag.d.ts +2 -2
  60. package/lib/plugins/reorder/index.js +68 -17
  61. package/lib/plugins/reorder/index.js.map +1 -1
  62. package/lib/plugins/responsive/ResponsivePlugin.d.ts +6 -1
  63. package/lib/plugins/responsive/ResponsivePlugin.d.ts.map +1 -1
  64. package/lib/plugins/responsive/index.js +125 -54
  65. package/lib/plugins/responsive/index.js.map +1 -1
  66. package/lib/plugins/row-reorder/index.js +169 -112
  67. package/lib/plugins/row-reorder/index.js.map +1 -1
  68. package/lib/plugins/selection/SelectionPlugin.d.ts +14 -2
  69. package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
  70. package/lib/plugins/selection/index.js +84 -7
  71. package/lib/plugins/selection/index.js.map +1 -1
  72. package/lib/plugins/server-side/index.js +79 -22
  73. package/lib/plugins/server-side/index.js.map +1 -1
  74. package/lib/plugins/tree/TreePlugin.d.ts +7 -1
  75. package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
  76. package/lib/plugins/tree/index.js +140 -58
  77. package/lib/plugins/tree/index.js.map +1 -1
  78. package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +6 -1
  79. package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
  80. package/lib/plugins/undo-redo/index.js +79 -10
  81. package/lib/plugins/undo-redo/index.js.map +1 -1
  82. package/lib/plugins/visibility/index.js +57 -0
  83. package/lib/plugins/visibility/index.js.map +1 -1
  84. package/package.json +1 -1
  85. package/public.d.ts +80 -2
  86. package/public.d.ts.map +1 -1
  87. package/umd/grid.all.umd.js +25 -25
  88. package/umd/grid.all.umd.js.map +1 -1
  89. package/umd/grid.umd.js +15 -15
  90. package/umd/grid.umd.js.map +1 -1
  91. package/umd/plugins/clipboard.umd.js +5 -5
  92. package/umd/plugins/clipboard.umd.js.map +1 -1
  93. package/umd/plugins/context-menu.umd.js +1 -1
  94. package/umd/plugins/context-menu.umd.js.map +1 -1
  95. package/umd/plugins/editing.umd.js +1 -1
  96. package/umd/plugins/editing.umd.js.map +1 -1
  97. package/umd/plugins/filtering.umd.js +1 -1
  98. package/umd/plugins/filtering.umd.js.map +1 -1
  99. package/umd/plugins/grouping-rows.umd.js +2 -2
  100. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  101. package/umd/plugins/pinned-columns.umd.js +1 -1
  102. package/umd/plugins/pinned-columns.umd.js.map +1 -1
  103. package/umd/plugins/print.umd.js +1 -1
  104. package/umd/plugins/print.umd.js.map +1 -1
  105. package/umd/plugins/reorder.umd.js +1 -1
  106. package/umd/plugins/reorder.umd.js.map +1 -1
  107. package/umd/plugins/responsive.umd.js +1 -1
  108. package/umd/plugins/responsive.umd.js.map +1 -1
  109. package/umd/plugins/selection.umd.js +2 -2
  110. package/umd/plugins/selection.umd.js.map +1 -1
  111. package/umd/plugins/tree.umd.js +1 -1
  112. package/umd/plugins/tree.umd.js.map +1 -1
  113. package/umd/plugins/undo-redo.umd.js +1 -1
  114. package/umd/plugins/undo-redo.umd.js.map +1 -1
@@ -1,4 +1,4 @@
1
- import { BaseGridPlugin, CellClickEvent, HeaderClickEvent } from '../../core/plugin/base-plugin';
1
+ import { BaseGridPlugin, CellClickEvent, HeaderClickEvent, PluginManifest, PluginQuery } from '../../core/plugin/base-plugin';
2
2
  import { ColumnConfig } from '../../core/types';
3
3
  import { FlattenedTreeRow, TreeConfig, TreeRow } from './types';
4
4
  /**
@@ -87,6 +87,7 @@ import { FlattenedTreeRow, TreeConfig, TreeRow } from './types';
87
87
  * @internal Extends BaseGridPlugin
88
88
  */
89
89
  export declare class TreePlugin extends BaseGridPlugin<TreeConfig> {
90
+ static readonly manifest: PluginManifest;
90
91
  /** @internal */
91
92
  readonly name = "tree";
92
93
  /** @internal */
@@ -102,6 +103,11 @@ export declare class TreePlugin extends BaseGridPlugin<TreeConfig> {
102
103
  private sortState;
103
104
  /** @internal */
104
105
  detach(): void;
106
+ /**
107
+ * Handle plugin queries.
108
+ * @internal
109
+ */
110
+ handleQuery(query: PluginQuery): unknown;
105
111
  /**
106
112
  * Get expand/collapse animation style from plugin config.
107
113
  * Uses base class isAnimationEnabled to respect grid-level settings.
@@ -1 +1 @@
1
- {"version":3,"file":"TreePlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/tree/TreePlugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACjG,OAAO,KAAK,EAAE,YAAY,EAAsB,MAAM,kBAAkB,CAAC;AAIzE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AM,EAAE;IAI3B,gBAAgB,IAAI,gBAAgB,EAAE;IAItC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAI7C,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;CAM/B"}
@@ -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>', v = {
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>', S = {
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 A {
14
+ class E {
15
15
  /**
16
16
  * Plugin dependencies - declare other plugins this one requires.
17
17
  *
@@ -149,6 +149,63 @@ class A {
149
149
  const n = new CustomEvent(e, { detail: t, bubbles: !0, cancelable: !0 });
150
150
  return this.grid?.dispatchEvent?.(n), n.defaultPrevented;
151
151
  }
152
+ // =========================================================================
153
+ // Event Bus - Plugin-to-Plugin Communication
154
+ // =========================================================================
155
+ /**
156
+ * Subscribe to an event from another plugin.
157
+ * The subscription is automatically cleaned up when this plugin is detached.
158
+ *
159
+ * @category Plugin Development
160
+ * @param eventType - The event type to listen for (e.g., 'filter-change')
161
+ * @param callback - The callback to invoke when the event is emitted
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * // In attach() or other initialization
166
+ * this.on('filter-change', (detail) => {
167
+ * console.log('Filter changed:', detail);
168
+ * });
169
+ * ```
170
+ */
171
+ on(e, t) {
172
+ this.grid?._pluginManager?.subscribe(this, e, t);
173
+ }
174
+ /**
175
+ * Unsubscribe from a plugin event.
176
+ *
177
+ * @category Plugin Development
178
+ * @param eventType - The event type to stop listening for
179
+ *
180
+ * @example
181
+ * ```typescript
182
+ * this.off('filter-change');
183
+ * ```
184
+ */
185
+ off(e) {
186
+ this.grid?._pluginManager?.unsubscribe(this, e);
187
+ }
188
+ /**
189
+ * Emit an event to other plugins via the Event Bus.
190
+ * This is for inter-plugin communication only; it does NOT dispatch DOM events.
191
+ * Use `emit()` to dispatch DOM events that external consumers can listen to.
192
+ *
193
+ * @category Plugin Development
194
+ * @param eventType - The event type to emit (should be declared in manifest.events)
195
+ * @param detail - The event payload
196
+ *
197
+ * @example
198
+ * ```typescript
199
+ * // Emit to other plugins (not DOM)
200
+ * this.emitPluginEvent('filter-change', { field: 'name', value: 'Alice' });
201
+ *
202
+ * // For DOM events that consumers can addEventListener to:
203
+ * this.emit('filter-change', { field: 'name', value: 'Alice' });
204
+ * ```
205
+ */
206
+ emitPluginEvent(e, t) {
207
+ this.grid?._pluginManager?.emitPluginEvent(e, t);
208
+ }
152
209
  /**
153
210
  * Request a re-render of the grid.
154
211
  */
@@ -235,7 +292,7 @@ class A {
235
292
  */
236
293
  get gridIcons() {
237
294
  const e = this.grid?.gridConfig?.icons ?? {};
238
- return { ...v, ...e };
295
+ return { ...S, ...e };
239
296
  }
240
297
  // #region Animation Helpers
241
298
  /**
@@ -311,7 +368,7 @@ class A {
311
368
  }
312
369
  // #endregion
313
370
  }
314
- function R(o, e, t) {
371
+ function v(o, e, t) {
315
372
  return o.id !== void 0 ? String(o.id) : t ? `${t}-${e}` : String(e);
316
373
  }
317
374
  function y(o, e) {
@@ -319,9 +376,9 @@ function y(o, e) {
319
376
  return t.has(e) ? t.delete(e) : t.add(e), t;
320
377
  }
321
378
  function w(o, e, t = null, n = 0) {
322
- const i = e.childrenField ?? "children", s = /* @__PURE__ */ new Set();
323
- for (let r = 0; r < o.length; r++) {
324
- const l = o[r], a = R(l, r, t), d = l[i];
379
+ const r = e.childrenField ?? "children", s = /* @__PURE__ */ new Set();
380
+ for (let i = 0; i < o.length; i++) {
381
+ const l = o[i], a = v(l, i, t), d = l[r];
325
382
  if (Array.isArray(d) && d.length > 0) {
326
383
  s.add(a);
327
384
  const h = w(d, e, a, n + 1);
@@ -330,18 +387,18 @@ function w(o, e, t = null, n = 0) {
330
387
  }
331
388
  return s;
332
389
  }
333
- function E() {
390
+ function A() {
334
391
  return /* @__PURE__ */ new Set();
335
392
  }
336
- function _(o, e, t, n = null, i = 0) {
393
+ function K(o, e, t, n = null, r = 0) {
337
394
  const s = t.childrenField ?? "children";
338
- for (let r = 0; r < o.length; r++) {
339
- const l = o[r], a = R(l, r, n);
395
+ for (let i = 0; i < o.length; i++) {
396
+ const l = o[i], a = v(l, i, n);
340
397
  if (a === e)
341
398
  return [a];
342
399
  const d = l[s];
343
400
  if (Array.isArray(d) && d.length > 0) {
344
- const h = _(d, e, t, a, i + 1);
401
+ const h = K(d, e, t, a, r + 1);
345
402
  if (h)
346
403
  return [a, ...h];
347
404
  }
@@ -349,11 +406,11 @@ function _(o, e, t, n = null, i = 0) {
349
406
  return null;
350
407
  }
351
408
  function C(o, e, t, n) {
352
- const i = _(o, e, t);
353
- if (!i) return n;
409
+ const r = K(o, e, t);
410
+ if (!r) return n;
354
411
  const s = new Set(n);
355
- for (let r = 0; r < i.length - 1; r++)
356
- s.add(i[r]);
412
+ for (let i = 0; i < r.length - 1; i++)
413
+ s.add(r[i]);
357
414
  return s;
358
415
  }
359
416
  function x(o, e = "children") {
@@ -372,14 +429,28 @@ function k(o) {
372
429
  for (const t of o)
373
430
  if (!(!t || typeof t != "object"))
374
431
  for (const n of e) {
375
- const i = t[n];
376
- if (Array.isArray(i) && i.length > 0)
432
+ const r = t[n];
433
+ if (Array.isArray(r) && r.length > 0)
377
434
  return n;
378
435
  }
379
436
  return null;
380
437
  }
381
438
  const T = "@layer tbw-plugins{tbw-grid .cell[data-field=__tbw_expander]{border-right:none!important;padding:0;display:flex;align-items:center;justify-content:flex-start}tbw-grid .header-row .cell[data-field=__tbw_expander]{display:none}tbw-grid .header-row .cell[data-field=__tbw_expander]+.cell{grid-column:1 / 3}tbw-grid .tree-cell-wrapper{display:inline-flex;align-items:center;padding-left:calc(var(--tbw-tree-depth, 0) * var(--tbw-tree-indent-width, var(--tbw-tree-toggle-size, 1.25em)))}tbw-grid .tree-expander{display:flex;align-items:center;justify-content:flex-start;width:100%;height:100%;box-sizing:border-box}tbw-grid .tree-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-tree-toggle-size, 1.25em);height:var(--tbw-tree-toggle-size, 1.25em);flex-shrink:0}tbw-grid .tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}tbw-grid .tree-spacer{width:var(--tbw-tree-toggle-size, 1.25em);display:inline-block;flex-shrink:0}tbw-grid .data-grid-row.tbw-tree-slide-in{animation:tbw-tree-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}tbw-grid .data-grid-row.tbw-tree-fade-in{animation:tbw-tree-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-tree-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}@keyframes tbw-tree-fade-in{0%{opacity:0}to{opacity:1}}}";
382
- class F extends A {
439
+ class F extends E {
440
+ static manifest = {
441
+ events: [
442
+ {
443
+ type: "tree-state-change",
444
+ description: "Emitted when tree expansion state changes (toggle, expand all, collapse all)"
445
+ }
446
+ ],
447
+ queries: [
448
+ {
449
+ type: "canMoveRow",
450
+ description: "Returns false for rows with children (parent nodes cannot be reordered)"
451
+ }
452
+ ]
453
+ };
383
454
  /** @internal */
384
455
  name = "tree";
385
456
  /** @internal */
@@ -407,6 +478,17 @@ class F extends A {
407
478
  detach() {
408
479
  this.expandedKeys.clear(), this.initialExpansionDone = !1, this.flattenedRows = [], this.rowKeyMap.clear(), this.previousVisibleKeys.clear(), this.keysToAnimate.clear(), this.sortState = null;
409
480
  }
481
+ /**
482
+ * Handle plugin queries.
483
+ * @internal
484
+ */
485
+ handleQuery(e) {
486
+ if (e.type === "canMoveRow") {
487
+ const t = e.context;
488
+ if (t && t[this.config.childrenField ?? "children"]?.length > 0)
489
+ return !1;
490
+ }
491
+ }
410
492
  // #endregion
411
493
  // #region Animation
412
494
  /**
@@ -430,26 +512,26 @@ class F extends A {
430
512
  const t = this.config.childrenField ?? "children", n = e;
431
513
  if (!x(n, t))
432
514
  return this.flattenedRows = [], this.rowKeyMap.clear(), this.previousVisibleKeys.clear(), [...e];
433
- let i = this.withStableKeys(n);
434
- this.sortState && (i = this.sortTree(i, this.sortState.field, this.sortState.direction)), this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = w(i, this.config), this.initialExpansionDone = !0), this.flattenedRows = this.flattenTree(i, this.expandedKeys), this.rowKeyMap.clear(), this.keysToAnimate.clear();
515
+ let r = this.withStableKeys(n);
516
+ this.sortState && (r = this.sortTree(r, this.sortState.field, this.sortState.direction)), this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = w(r, this.config), this.initialExpansionDone = !0), this.flattenedRows = this.flattenTree(r, this.expandedKeys), this.rowKeyMap.clear(), this.keysToAnimate.clear();
435
517
  const s = /* @__PURE__ */ new Set();
436
- for (const r of this.flattenedRows)
437
- this.rowKeyMap.set(r.key, r), s.add(r.key), !this.previousVisibleKeys.has(r.key) && r.depth > 0 && this.keysToAnimate.add(r.key);
438
- return this.previousVisibleKeys = s, this.flattenedRows.map((r) => ({
439
- ...r.data,
440
- __treeKey: r.key,
441
- __treeDepth: r.depth,
442
- __treeHasChildren: r.hasChildren,
443
- __treeExpanded: r.isExpanded
518
+ for (const i of this.flattenedRows)
519
+ this.rowKeyMap.set(i.key, i), s.add(i.key), !this.previousVisibleKeys.has(i.key) && i.depth > 0 && this.keysToAnimate.add(i.key);
520
+ return this.previousVisibleKeys = s, this.flattenedRows.map((i) => ({
521
+ ...i.data,
522
+ __treeKey: i.key,
523
+ __treeDepth: i.depth,
524
+ __treeHasChildren: i.hasChildren,
525
+ __treeExpanded: i.isExpanded
444
526
  }));
445
527
  }
446
528
  /** Assign stable keys to rows (preserves key across sort operations) */
447
529
  withStableKeys(e, t = null) {
448
530
  const n = this.config.childrenField ?? "children";
449
- return e.map((i, s) => {
450
- const r = i.__stableKey, l = i.id !== void 0 ? String(i.id) : r ?? (t ? `${t}-${s}` : String(s)), a = i[n], d = Array.isArray(a) && a.length > 0;
531
+ return e.map((r, s) => {
532
+ const i = r.__stableKey, l = r.id !== void 0 ? String(r.id) : i ?? (t ? `${t}-${s}` : String(s)), a = r[n], d = Array.isArray(a) && a.length > 0;
451
533
  return {
452
- ...i,
534
+ ...r,
453
535
  __stableKey: l,
454
536
  ...d ? { [n]: this.withStableKeys(a, l) } : {}
455
537
  };
@@ -457,12 +539,12 @@ class F extends A {
457
539
  }
458
540
  /** Flatten tree using stable keys */
459
541
  flattenTree(e, t, n = 0) {
460
- const i = this.config.childrenField ?? "children", s = [];
461
- for (const r of e) {
462
- const a = r.__stableKey ?? String(r.id ?? "?"), d = r[i], h = Array.isArray(d) && d.length > 0, u = t.has(a);
542
+ const r = this.config.childrenField ?? "children", s = [];
543
+ for (const i of e) {
544
+ const a = i.__stableKey ?? String(i.id ?? "?"), d = i[r], h = Array.isArray(d) && d.length > 0, u = t.has(a);
463
545
  s.push({
464
546
  key: a,
465
- data: r,
547
+ data: i,
466
548
  depth: n,
467
549
  hasChildren: h,
468
550
  isExpanded: u,
@@ -473,13 +555,13 @@ class F extends A {
473
555
  }
474
556
  /** Sort tree recursively, keeping children with parents */
475
557
  sortTree(e, t, n) {
476
- const i = this.config.childrenField ?? "children";
477
- return [...e].sort((r, l) => {
478
- const a = r[t], d = l[t];
558
+ const r = this.config.childrenField ?? "children";
559
+ return [...e].sort((i, l) => {
560
+ const a = i[t], d = l[t];
479
561
  return a == null && d == null ? 0 : a == null ? -1 : d == null ? 1 : a > d ? n : a < d ? -n : 0;
480
- }).map((r) => {
481
- const l = r[i];
482
- return Array.isArray(l) && l.length > 0 ? { ...r, [i]: this.sortTree(l, t, n) } : r;
562
+ }).map((i) => {
563
+ const l = i[r];
564
+ return Array.isArray(l) && l.length > 0 ? { ...i, [r]: this.sortTree(l, t, n) } : i;
483
565
  });
484
566
  }
485
567
  /** @internal */
@@ -487,19 +569,19 @@ class F extends A {
487
569
  if (this.flattenedRows.length === 0) return [...e];
488
570
  const t = [...e];
489
571
  if (t.length === 0) return t;
490
- const n = t[0], i = n.viewRenderer, s = () => this.config, r = this.setIcon.bind(this), l = this.resolveIcon.bind(this), a = (d) => {
491
- const { row: h, value: u } = d, { showExpandIcons: K = !0, indentWidth: b } = s(), g = h, S = g.__treeDepth ?? 0, f = document.createElement("span");
492
- if (f.className = "tree-cell-wrapper", f.style.setProperty("--tbw-tree-depth", String(S)), b !== void 0 && f.style.setProperty("--tbw-tree-indent-width", `${b}px`), K)
572
+ const n = t[0], r = n.viewRenderer, s = () => this.config, i = this.setIcon.bind(this), l = this.resolveIcon.bind(this), a = (d) => {
573
+ const { row: h, value: u } = d, { showExpandIcons: R = !0, indentWidth: b } = s(), g = h, _ = g.__treeDepth ?? 0, f = document.createElement("span");
574
+ if (f.className = "tree-cell-wrapper", f.style.setProperty("--tbw-tree-depth", String(_)), b !== void 0 && f.style.setProperty("--tbw-tree-indent-width", `${b}px`), R)
493
575
  if (g.__treeHasChildren) {
494
576
  const c = document.createElement("span");
495
- c.className = `tree-toggle${g.__treeExpanded ? " expanded" : ""}`, r(c, l(g.__treeExpanded ? "collapse" : "expand")), c.setAttribute("data-tree-key", String(g.__treeKey ?? "")), f.appendChild(c);
577
+ c.className = `tree-toggle${g.__treeExpanded ? " expanded" : ""}`, i(c, l(g.__treeExpanded ? "collapse" : "expand")), c.setAttribute("data-tree-key", String(g.__treeKey ?? "")), f.appendChild(c);
496
578
  } else {
497
579
  const c = document.createElement("span");
498
580
  c.className = "tree-spacer", f.appendChild(c);
499
581
  }
500
582
  const p = document.createElement("span");
501
- if (p.className = "tree-content", i) {
502
- const c = i(d);
583
+ if (p.className = "tree-content", r) {
584
+ const c = r(d);
503
585
  c instanceof Node ? p.appendChild(c) : typeof c == "string" && (p.innerHTML = c);
504
586
  } else
505
587
  p.textContent = u != null ? String(u) : "";
@@ -515,12 +597,12 @@ class F extends A {
515
597
  if (!t?.classList.contains("tree-toggle")) return !1;
516
598
  const n = t.getAttribute("data-tree-key");
517
599
  if (!n) return !1;
518
- const i = this.rowKeyMap.get(n);
519
- return i ? (this.expandedKeys = y(this.expandedKeys, n), this.emit("tree-expand", {
600
+ const r = this.rowKeyMap.get(n);
601
+ return r ? (this.expandedKeys = y(this.expandedKeys, n), this.emit("tree-expand", {
520
602
  key: n,
521
- row: i.data,
603
+ row: r.data,
522
604
  expanded: this.expandedKeys.has(n),
523
- depth: i.depth
605
+ depth: r.depth
524
606
  }), this.requestRender(), !0) : !1;
525
607
  }
526
608
  /** @internal */
@@ -550,9 +632,9 @@ class F extends A {
550
632
  const t = this.gridElement?.querySelector(".rows");
551
633
  if (!t) return;
552
634
  const n = e === "fade" ? "tbw-tree-fade-in" : "tbw-tree-slide-in";
553
- for (const i of t.querySelectorAll(".data-grid-row")) {
554
- const s = i.querySelector(".cell[data-row]"), r = s ? parseInt(s.getAttribute("data-row") ?? "-1", 10) : -1, l = this.flattenedRows[r]?.key;
555
- l && this.keysToAnimate.has(l) && (i.classList.add(n), i.addEventListener("animationend", () => i.classList.remove(n), { once: !0 }));
635
+ for (const r of t.querySelectorAll(".data-grid-row")) {
636
+ const s = r.querySelector(".cell[data-row]"), i = s ? parseInt(s.getAttribute("data-row") ?? "-1", 10) : -1, l = this.flattenedRows[i]?.key;
637
+ l && this.keysToAnimate.has(l) && (r.classList.add(n), r.addEventListener("animationend", () => r.classList.remove(n), { once: !0 }));
556
638
  }
557
639
  this.keysToAnimate.clear();
558
640
  }
@@ -565,13 +647,13 @@ class F extends A {
565
647
  this.expandedKeys.delete(e), this.requestRender();
566
648
  }
567
649
  toggle(e) {
568
- this.expandedKeys = y(this.expandedKeys, e), this.requestRender();
650
+ this.expandedKeys = y(this.expandedKeys, e), this.emitPluginEvent("tree-state-change", { expandedKeys: [...this.expandedKeys] }), this.requestRender();
569
651
  }
570
652
  expandAll() {
571
- this.expandedKeys = w(this.rows, this.config), this.requestRender();
653
+ this.expandedKeys = w(this.rows, this.config), this.emitPluginEvent("tree-state-change", { expandedKeys: [...this.expandedKeys] }), this.requestRender();
572
654
  }
573
655
  collapseAll() {
574
- this.expandedKeys = E(), this.requestRender();
656
+ this.expandedKeys = A(), this.emitPluginEvent("tree-state-change", { expandedKeys: [...this.expandedKeys] }), this.requestRender();
575
657
  }
576
658
  isExpanded(e) {
577
659
  return this.expandedKeys.has(e);