@toolbox-web/grid 0.3.2 → 0.4.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 (138) hide show
  1. package/README.md +5 -4
  2. package/all.d.ts +19 -19
  3. package/all.d.ts.map +1 -1
  4. package/all.js +1775 -1202
  5. package/all.js.map +1 -1
  6. package/index.js +2143 -2015
  7. package/index.js.map +1 -1
  8. package/lib/core/grid.d.ts +22 -12
  9. package/lib/core/grid.d.ts.map +1 -1
  10. package/lib/core/internal/columns.d.ts +0 -9
  11. package/lib/core/internal/columns.d.ts.map +1 -1
  12. package/lib/core/internal/config-manager.d.ts +236 -0
  13. package/lib/core/internal/config-manager.d.ts.map +1 -0
  14. package/lib/core/internal/event-delegation.d.ts.map +1 -1
  15. package/lib/core/internal/header.d.ts.map +1 -1
  16. package/lib/core/internal/keyboard.d.ts.map +1 -1
  17. package/lib/core/internal/render-scheduler.d.ts +123 -0
  18. package/lib/core/internal/render-scheduler.d.ts.map +1 -0
  19. package/lib/core/internal/rows.d.ts +8 -3
  20. package/lib/core/internal/rows.d.ts.map +1 -1
  21. package/lib/core/internal/sanitize.d.ts +10 -2
  22. package/lib/core/internal/sanitize.d.ts.map +1 -1
  23. package/lib/core/internal/shell.d.ts +40 -2
  24. package/lib/core/internal/shell.d.ts.map +1 -1
  25. package/lib/core/internal/validate-config.d.ts +11 -0
  26. package/lib/core/internal/validate-config.d.ts.map +1 -0
  27. package/lib/core/plugin/base-plugin.d.ts +70 -0
  28. package/lib/core/plugin/base-plugin.d.ts.map +1 -1
  29. package/lib/core/plugin/plugin-manager.d.ts +13 -2
  30. package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
  31. package/lib/core/plugin/types.d.ts +17 -3
  32. package/lib/core/plugin/types.d.ts.map +1 -1
  33. package/lib/core/types.d.ts +112 -12
  34. package/lib/core/types.d.ts.map +1 -1
  35. package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
  36. package/lib/plugins/clipboard/index.js +50 -18
  37. package/lib/plugins/clipboard/index.js.map +1 -1
  38. package/lib/plugins/column-virtualization/index.js +60 -25
  39. package/lib/plugins/column-virtualization/index.js.map +1 -1
  40. package/lib/plugins/context-menu/index.js +51 -16
  41. package/lib/plugins/context-menu/index.js.map +1 -1
  42. package/lib/plugins/editing/EditingPlugin.d.ts +117 -0
  43. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -0
  44. package/lib/{core/internal → plugins/editing}/editors.d.ts +1 -1
  45. package/lib/plugins/editing/editors.d.ts.map +1 -0
  46. package/lib/plugins/editing/index.d.ts +8 -0
  47. package/lib/plugins/editing/index.d.ts.map +1 -0
  48. package/lib/plugins/editing/index.js +705 -0
  49. package/lib/plugins/editing/index.js.map +1 -0
  50. package/lib/plugins/editing/types.d.ts +45 -0
  51. package/lib/plugins/editing/types.d.ts.map +1 -0
  52. package/lib/plugins/export/ExportPlugin.d.ts.map +1 -1
  53. package/lib/plugins/export/index.js +74 -39
  54. package/lib/plugins/export/index.js.map +1 -1
  55. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  56. package/lib/plugins/filtering/index.js +87 -50
  57. package/lib/plugins/filtering/index.js.map +1 -1
  58. package/lib/plugins/grouping-columns/grouping-columns.d.ts +4 -4
  59. package/lib/plugins/grouping-columns/grouping-columns.d.ts.map +1 -1
  60. package/lib/plugins/grouping-columns/index.js +59 -24
  61. package/lib/plugins/grouping-columns/index.js.map +1 -1
  62. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
  63. package/lib/plugins/grouping-rows/grouping-rows.d.ts.map +1 -1
  64. package/lib/plugins/grouping-rows/index.js +46 -11
  65. package/lib/plugins/grouping-rows/index.js.map +1 -1
  66. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +2 -2
  67. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
  68. package/lib/plugins/master-detail/index.js +140 -102
  69. package/lib/plugins/master-detail/index.js.map +1 -1
  70. package/lib/plugins/master-detail/types.d.ts +12 -2
  71. package/lib/plugins/master-detail/types.d.ts.map +1 -1
  72. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
  73. package/lib/plugins/multi-sort/index.js +59 -22
  74. package/lib/plugins/multi-sort/index.js.map +1 -1
  75. package/lib/plugins/pinned-columns/index.js +41 -6
  76. package/lib/plugins/pinned-columns/index.js.map +1 -1
  77. package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
  78. package/lib/plugins/pinned-rows/index.js +45 -9
  79. package/lib/plugins/pinned-rows/index.js.map +1 -1
  80. package/lib/plugins/pivot/index.js +42 -7
  81. package/lib/plugins/pivot/index.js.map +1 -1
  82. package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
  83. package/lib/plugins/reorder/index.js +59 -19
  84. package/lib/plugins/reorder/index.js.map +1 -1
  85. package/lib/plugins/selection/index.js +41 -6
  86. package/lib/plugins/selection/index.js.map +1 -1
  87. package/lib/plugins/server-side/index.js +48 -13
  88. package/lib/plugins/server-side/index.js.map +1 -1
  89. package/lib/plugins/tree/TreePlugin.d.ts +3 -3
  90. package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
  91. package/lib/plugins/tree/index.js +165 -126
  92. package/lib/plugins/tree/index.js.map +1 -1
  93. package/lib/plugins/tree/tree-data.d.ts +6 -6
  94. package/lib/plugins/tree/tree-data.d.ts.map +1 -1
  95. package/lib/plugins/tree/tree-detect.d.ts +5 -9
  96. package/lib/plugins/tree/tree-detect.d.ts.map +1 -1
  97. package/lib/plugins/tree/types.d.ts +16 -4
  98. package/lib/plugins/tree/types.d.ts.map +1 -1
  99. package/lib/plugins/undo-redo/index.js +46 -11
  100. package/lib/plugins/undo-redo/index.js.map +1 -1
  101. package/lib/plugins/visibility/index.js +37 -2
  102. package/lib/plugins/visibility/index.js.map +1 -1
  103. package/package.json +1 -1
  104. package/public.d.ts +104 -13
  105. package/public.d.ts.map +1 -1
  106. package/umd/grid.all.umd.js +31 -19
  107. package/umd/grid.all.umd.js.map +1 -1
  108. package/umd/grid.umd.js +18 -6
  109. package/umd/grid.umd.js.map +1 -1
  110. package/umd/plugins/clipboard.umd.js +1 -1
  111. package/umd/plugins/clipboard.umd.js.map +1 -1
  112. package/umd/plugins/editing.umd.js +2 -0
  113. package/umd/plugins/editing.umd.js.map +1 -0
  114. package/umd/plugins/export.umd.js +2 -2
  115. package/umd/plugins/export.umd.js.map +1 -1
  116. package/umd/plugins/filtering.umd.js +1 -1
  117. package/umd/plugins/filtering.umd.js.map +1 -1
  118. package/umd/plugins/grouping-columns.umd.js +1 -1
  119. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  120. package/umd/plugins/grouping-rows.umd.js +1 -1
  121. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  122. package/umd/plugins/master-detail.umd.js +1 -1
  123. package/umd/plugins/master-detail.umd.js.map +1 -1
  124. package/umd/plugins/multi-sort.umd.js +1 -1
  125. package/umd/plugins/multi-sort.umd.js.map +1 -1
  126. package/umd/plugins/pinned-rows.umd.js +1 -1
  127. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  128. package/umd/plugins/reorder.umd.js +1 -1
  129. package/umd/plugins/reorder.umd.js.map +1 -1
  130. package/umd/plugins/tree.umd.js +1 -1
  131. package/umd/plugins/tree.umd.js.map +1 -1
  132. package/lib/core/internal/column-state.d.ts +0 -124
  133. package/lib/core/internal/column-state.d.ts.map +0 -1
  134. package/lib/core/internal/editing.d.ts +0 -76
  135. package/lib/core/internal/editing.d.ts.map +0 -1
  136. package/lib/core/internal/editors.d.ts.map +0 -1
  137. package/lib/core/internal/grid-internals.d.ts +0 -83
  138. package/lib/core/internal/grid-internals.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/master-detail/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,uBAAuB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⋮",
9
9
  toolPanel: "☰"
10
10
  };
11
- class m {
11
+ class M {
12
12
  /** Plugin version - override in subclass if needed */
13
13
  version = "1.0.0";
14
14
  /** CSS styles to inject into the grid's shadow DOM */
@@ -25,6 +25,12 @@ class m {
25
25
  config;
26
26
  /** User-provided configuration from constructor */
27
27
  userConfig;
28
+ /**
29
+ * Plugin-level AbortController for event listener cleanup.
30
+ * Created fresh in attach(), aborted in detach().
31
+ * This ensures event listeners are properly cleaned up when plugins are re-attached.
32
+ */
33
+ #t;
28
34
  /**
29
35
  * Default configuration - subclasses should override this getter.
30
36
  * Note: This must be a getter (not property initializer) for proper inheritance
@@ -39,19 +45,48 @@ class m {
39
45
  /**
40
46
  * Called when the plugin is attached to a grid.
41
47
  * Override to set up event listeners, initialize state, etc.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * attach(grid: GridElement): void {
52
+ * super.attach(grid);
53
+ * // Set up document-level listeners with auto-cleanup
54
+ * document.addEventListener('keydown', this.handleEscape, {
55
+ * signal: this.disconnectSignal
56
+ * });
57
+ * }
58
+ * ```
42
59
  */
43
60
  attach(t) {
44
- this.grid = t, this.config = { ...this.defaultConfig, ...this.userConfig };
61
+ this.#t?.abort(), this.#t = new AbortController(), this.grid = t, this.config = { ...this.defaultConfig, ...this.userConfig };
45
62
  }
46
63
  /**
47
64
  * Called when the plugin is detached from a grid.
48
65
  * Override to clean up event listeners, timers, etc.
66
+ *
67
+ * @example
68
+ * ```ts
69
+ * detach(): void {
70
+ * // Clean up any state not handled by disconnectSignal
71
+ * this.selectedRows.clear();
72
+ * this.cache = null;
73
+ * }
74
+ * ```
49
75
  */
50
76
  detach() {
77
+ this.#t?.abort(), this.#t = void 0;
51
78
  }
52
79
  /**
53
80
  * Get another plugin instance from the same grid.
54
81
  * Use for inter-plugin communication.
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * const selection = this.getPlugin(SelectionPlugin);
86
+ * if (selection) {
87
+ * const selectedRows = selection.getSelectedRows();
88
+ * }
89
+ * ```
55
90
  */
56
91
  getPlugin(t) {
57
92
  return this.grid?.getPlugin(t);
@@ -125,7 +160,7 @@ class m {
125
160
  * document.addEventListener('keydown', handler, { signal: this.disconnectSignal });
126
161
  */
127
162
  get disconnectSignal() {
128
- return this.grid?.disconnectSignal;
163
+ return this.#t?.signal ?? this.grid?.disconnectSignal;
129
164
  }
130
165
  /**
131
166
  * Get the grid-level icons configuration.
@@ -133,7 +168,7 @@ class m {
133
168
  */
134
169
  get gridIcons() {
135
170
  const t = this.grid?.gridConfig?.icons ?? {};
136
- return { ...h, ...t };
171
+ return { ...x, ...t };
137
172
  }
138
173
  /**
139
174
  * Resolve an icon value to string or HTMLElement.
@@ -164,32 +199,32 @@ class m {
164
199
  }
165
200
  // #endregion
166
201
  }
167
- function p(r, t, e) {
202
+ function S(r, t, e) {
168
203
  return t.length ? [...r].sort((n, o) => {
169
204
  for (const i of t) {
170
- const d = e.find((l) => l.field === i.field)?.sortComparator ?? x, a = n[i.field], u = o[i.field], s = d(a, u, n, o);
205
+ const d = e.find((a) => a.field === i.field)?.sortComparator ?? C, u = n[i.field], f = o[i.field], s = d(u, f, n, o);
171
206
  if (s !== 0)
172
207
  return i.direction === "asc" ? s : -s;
173
208
  }
174
209
  return 0;
175
210
  }) : [...r];
176
211
  }
177
- function x(r, t) {
212
+ function C(r, t) {
178
213
  return r == null && t == null ? 0 : r == null ? 1 : t == null ? -1 : typeof r == "number" && typeof t == "number" ? r - t : r instanceof Date && t instanceof Date ? r.getTime() - t.getTime() : typeof r == "boolean" && typeof t == "boolean" ? r === t ? 0 : r ? -1 : 1 : String(r).localeCompare(String(t));
179
214
  }
180
- function M(r, t, e, n) {
215
+ function y(r, t, e, n) {
181
216
  const o = r.find((i) => i.field === t);
182
217
  return e ? o ? o.direction === "asc" ? r.map((i) => i.field === t ? { ...i, direction: "desc" } : i) : r.filter((i) => i.field !== t) : r.length < n ? [...r, { field: t, direction: "asc" }] : r : o?.direction === "asc" ? [{ field: t, direction: "desc" }] : o?.direction === "desc" ? [] : [{ field: t, direction: "asc" }];
183
218
  }
184
- function f(r, t) {
219
+ function h(r, t) {
185
220
  const e = r.findIndex((n) => n.field === t);
186
221
  return e >= 0 ? e + 1 : void 0;
187
222
  }
188
- function g(r, t) {
223
+ function m(r, t) {
189
224
  return r.find((e) => e.field === t)?.direction;
190
225
  }
191
- const C = '.header-cell[data-sort=asc]:after{content:"↑";margin-left:4px;opacity:.8}.header-cell[data-sort=desc]:after{content:"↓";margin-left:4px;opacity:.8}.sort-indicator{margin-left:4px;opacity:.8}.sort-index{font-size:10px;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:14px;height:14px;display:inline-flex;align-items:center;justify-content:center;margin-left:2px;font-weight:600}';
192
- class S extends m {
226
+ const b = '.header-cell[data-sort=asc]:after{content:"↑";margin-left:4px;opacity:.8}.header-cell[data-sort=desc]:after{content:"↓";margin-left:4px;opacity:.8}.sort-indicator{margin-left:4px;opacity:.8}.sort-index{font-size:10px;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:14px;height:14px;display:inline-flex;align-items:center;justify-content:center;margin-left:2px;font-weight:600}';
227
+ class w extends M {
193
228
  name = "multiSort";
194
229
  version = "1.0.0";
195
230
  get defaultConfig() {
@@ -208,12 +243,12 @@ class S extends m {
208
243
  // #endregion
209
244
  // #region Hooks
210
245
  processRows(t) {
211
- return this.sortModel.length === 0 ? [...t] : p([...t], this.sortModel, [...this.columns]);
246
+ return this.sortModel.length === 0 ? [...t] : S([...t], this.sortModel, [...this.columns]);
212
247
  }
213
248
  onHeaderClick(t) {
214
249
  if (!this.columns.find((i) => i.field === t.field)?.sortable) return !1;
215
250
  const n = t.originalEvent.shiftKey, o = this.config.maxSortColumns ?? 3;
216
- return this.sortModel = M(this.sortModel, t.field, n, o), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), !0;
251
+ return this.sortModel = y(this.sortModel, t.field, n, o), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), !0;
217
252
  }
218
253
  afterRender() {
219
254
  const t = this.shadowRoot;
@@ -222,13 +257,15 @@ class S extends m {
222
257
  t.querySelectorAll(".header-row .cell[data-field]").forEach((o) => {
223
258
  const i = o.getAttribute("data-field");
224
259
  if (!i) return;
225
- const c = f(this.sortModel, i), d = g(this.sortModel, i);
260
+ const c = h(this.sortModel, i), d = m(this.sortModel, i);
226
261
  if (o.querySelector(".sort-index")?.remove(), d) {
227
262
  o.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), o.setAttribute("data-sort", d);
228
263
  const s = document.createElement("span");
229
- if (s.className = "sort-indicator", this.setIcon(s, this.resolveIcon(d === "asc" ? "sortAsc" : "sortDesc")), o.appendChild(s), e && this.sortModel.length > 1 && c !== void 0) {
264
+ s.className = "sort-indicator", this.setIcon(s, this.resolveIcon(d === "asc" ? "sortAsc" : "sortDesc"));
265
+ const a = o.querySelector(".tbw-filter-btn"), p = o.querySelector(".resize-handle"), g = a ?? p;
266
+ if (g ? o.insertBefore(s, g) : o.appendChild(s), e && this.sortModel.length > 1 && c !== void 0) {
230
267
  const l = document.createElement("span");
231
- l.className = "sort-index", l.textContent = String(c), o.appendChild(l);
268
+ l.className = "sort-index", l.textContent = String(c), s.nextSibling ? o.insertBefore(l, s.nextSibling) : o.appendChild(l);
232
269
  }
233
270
  } else
234
271
  o.removeAttribute("data-sort");
@@ -262,7 +299,7 @@ class S extends m {
262
299
  * @returns 1-based index or undefined if not sorted
263
300
  */
264
301
  getSortIndex(t) {
265
- return f(this.sortModel, t);
302
+ return h(this.sortModel, t);
266
303
  }
267
304
  /**
268
305
  * Get the sort direction for a specific field.
@@ -270,7 +307,7 @@ class S extends m {
270
307
  * @returns Sort direction or undefined if not sorted
271
308
  */
272
309
  getSortDirection(t) {
273
- return g(this.sortModel, t);
310
+ return m(this.sortModel, t);
274
311
  }
275
312
  // #endregion
276
313
  // #region Column State Hooks
@@ -303,10 +340,10 @@ class S extends m {
303
340
  }
304
341
  // #endregion
305
342
  // #region Styles
306
- styles = C;
343
+ styles = b;
307
344
  // #endregion
308
345
  }
309
346
  export {
310
- S as MultiSortPlugin
347
+ w as MultiSortPlugin
311
348
  };
312
349
  //# sourceMappingURL=index.js.map