@toolbox-web/grid 0.3.3 → 0.4.1

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 (148) hide show
  1. package/all.d.ts +19 -19
  2. package/all.d.ts.map +1 -1
  3. package/all.js +1798 -1201
  4. package/all.js.map +1 -1
  5. package/index.js +2215 -2026
  6. package/index.js.map +1 -1
  7. package/lib/core/grid.d.ts +22 -12
  8. package/lib/core/grid.d.ts.map +1 -1
  9. package/lib/core/internal/columns.d.ts +0 -9
  10. package/lib/core/internal/columns.d.ts.map +1 -1
  11. package/lib/core/internal/config-manager.d.ts +236 -0
  12. package/lib/core/internal/config-manager.d.ts.map +1 -0
  13. package/lib/core/internal/editing.d.ts +3 -3
  14. package/lib/core/internal/editing.d.ts.map +1 -1
  15. package/lib/core/internal/event-delegation.d.ts.map +1 -1
  16. package/lib/core/internal/header.d.ts.map +1 -1
  17. package/lib/core/internal/keyboard.d.ts.map +1 -1
  18. package/lib/core/internal/render-scheduler.d.ts +123 -0
  19. package/lib/core/internal/render-scheduler.d.ts.map +1 -0
  20. package/lib/core/internal/rows.d.ts +8 -3
  21. package/lib/core/internal/rows.d.ts.map +1 -1
  22. package/lib/core/internal/sanitize.d.ts +2 -2
  23. package/lib/core/internal/sanitize.d.ts.map +1 -1
  24. package/lib/core/internal/shell.d.ts +40 -2
  25. package/lib/core/internal/shell.d.ts.map +1 -1
  26. package/lib/core/internal/validate-config.d.ts +25 -0
  27. package/lib/core/internal/validate-config.d.ts.map +1 -0
  28. package/lib/core/plugin/base-plugin.d.ts +118 -0
  29. package/lib/core/plugin/base-plugin.d.ts.map +1 -1
  30. package/lib/core/plugin/index.d.ts +1 -0
  31. package/lib/core/plugin/index.d.ts.map +1 -1
  32. package/lib/core/plugin/plugin-manager.d.ts +13 -2
  33. package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
  34. package/lib/core/plugin/types.d.ts +17 -3
  35. package/lib/core/plugin/types.d.ts.map +1 -1
  36. package/lib/core/types.d.ts +112 -12
  37. package/lib/core/types.d.ts.map +1 -1
  38. package/lib/plugins/clipboard/ClipboardPlugin.d.ts +7 -1
  39. package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
  40. package/lib/plugins/clipboard/index.js +78 -22
  41. package/lib/plugins/clipboard/index.js.map +1 -1
  42. package/lib/plugins/column-virtualization/index.js +72 -21
  43. package/lib/plugins/column-virtualization/index.js.map +1 -1
  44. package/lib/plugins/context-menu/index.js +53 -2
  45. package/lib/plugins/context-menu/index.js.map +1 -1
  46. package/lib/plugins/editing/EditingPlugin.d.ts +117 -0
  47. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -0
  48. package/lib/{core/internal → plugins/editing}/editors.d.ts +1 -1
  49. package/lib/plugins/editing/editors.d.ts.map +1 -0
  50. package/lib/plugins/editing/index.d.ts +8 -0
  51. package/lib/plugins/editing/index.d.ts.map +1 -0
  52. package/lib/plugins/editing/index.js +721 -0
  53. package/lib/plugins/editing/index.js.map +1 -0
  54. package/lib/plugins/editing/types.d.ts +45 -0
  55. package/lib/plugins/editing/types.d.ts.map +1 -0
  56. package/lib/plugins/export/ExportPlugin.d.ts.map +1 -1
  57. package/lib/plugins/export/index.js +68 -17
  58. package/lib/plugins/export/index.js.map +1 -1
  59. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  60. package/lib/plugins/filtering/index.js +103 -50
  61. package/lib/plugins/filtering/index.js.map +1 -1
  62. package/lib/plugins/grouping-columns/grouping-columns.d.ts +4 -4
  63. package/lib/plugins/grouping-columns/grouping-columns.d.ts.map +1 -1
  64. package/lib/plugins/grouping-columns/index.js +80 -29
  65. package/lib/plugins/grouping-columns/index.js.map +1 -1
  66. package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
  67. package/lib/plugins/grouping-rows/grouping-rows.d.ts.map +1 -1
  68. package/lib/plugins/grouping-rows/index.js +62 -11
  69. package/lib/plugins/grouping-rows/index.js.map +1 -1
  70. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +2 -2
  71. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
  72. package/lib/plugins/master-detail/index.js +156 -102
  73. package/lib/plugins/master-detail/index.js.map +1 -1
  74. package/lib/plugins/master-detail/types.d.ts +12 -2
  75. package/lib/plugins/master-detail/types.d.ts.map +1 -1
  76. package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
  77. package/lib/plugins/multi-sort/index.js +75 -22
  78. package/lib/plugins/multi-sort/index.js.map +1 -1
  79. package/lib/plugins/pinned-columns/index.js +57 -6
  80. package/lib/plugins/pinned-columns/index.js.map +1 -1
  81. package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
  82. package/lib/plugins/pinned-rows/index.js +61 -9
  83. package/lib/plugins/pinned-rows/index.js.map +1 -1
  84. package/lib/plugins/pivot/index.js +58 -7
  85. package/lib/plugins/pivot/index.js.map +1 -1
  86. package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
  87. package/lib/plugins/reorder/index.js +75 -19
  88. package/lib/plugins/reorder/index.js.map +1 -1
  89. package/lib/plugins/selection/index.js +57 -6
  90. package/lib/plugins/selection/index.js.map +1 -1
  91. package/lib/plugins/server-side/index.js +60 -9
  92. package/lib/plugins/server-side/index.js.map +1 -1
  93. package/lib/plugins/tree/TreePlugin.d.ts +3 -3
  94. package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
  95. package/lib/plugins/tree/index.js +181 -126
  96. package/lib/plugins/tree/index.js.map +1 -1
  97. package/lib/plugins/tree/tree-data.d.ts +6 -6
  98. package/lib/plugins/tree/tree-data.d.ts.map +1 -1
  99. package/lib/plugins/tree/tree-detect.d.ts +5 -9
  100. package/lib/plugins/tree/tree-detect.d.ts.map +1 -1
  101. package/lib/plugins/tree/types.d.ts +16 -4
  102. package/lib/plugins/tree/types.d.ts.map +1 -1
  103. package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +7 -1
  104. package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
  105. package/lib/plugins/undo-redo/index.js +65 -6
  106. package/lib/plugins/undo-redo/index.js.map +1 -1
  107. package/lib/plugins/visibility/VisibilityPlugin.d.ts +7 -1
  108. package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
  109. package/lib/plugins/visibility/index.js +61 -2
  110. package/lib/plugins/visibility/index.js.map +1 -1
  111. package/package.json +1 -1
  112. package/public.d.ts +104 -13
  113. package/public.d.ts.map +1 -1
  114. package/umd/grid.all.umd.js +37 -19
  115. package/umd/grid.all.umd.js.map +1 -1
  116. package/umd/grid.umd.js +25 -7
  117. package/umd/grid.umd.js.map +1 -1
  118. package/umd/plugins/clipboard.umd.js +2 -2
  119. package/umd/plugins/clipboard.umd.js.map +1 -1
  120. package/umd/plugins/editing.umd.js +2 -0
  121. package/umd/plugins/editing.umd.js.map +1 -0
  122. package/umd/plugins/export.umd.js +2 -2
  123. package/umd/plugins/export.umd.js.map +1 -1
  124. package/umd/plugins/filtering.umd.js +1 -1
  125. package/umd/plugins/filtering.umd.js.map +1 -1
  126. package/umd/plugins/grouping-columns.umd.js +1 -1
  127. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  128. package/umd/plugins/grouping-rows.umd.js +1 -1
  129. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  130. package/umd/plugins/master-detail.umd.js +1 -1
  131. package/umd/plugins/master-detail.umd.js.map +1 -1
  132. package/umd/plugins/multi-sort.umd.js +1 -1
  133. package/umd/plugins/multi-sort.umd.js.map +1 -1
  134. package/umd/plugins/pinned-rows.umd.js +1 -1
  135. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  136. package/umd/plugins/reorder.umd.js +1 -1
  137. package/umd/plugins/reorder.umd.js.map +1 -1
  138. package/umd/plugins/tree.umd.js +1 -1
  139. package/umd/plugins/tree.umd.js.map +1 -1
  140. package/umd/plugins/undo-redo.umd.js +1 -1
  141. package/umd/plugins/undo-redo.umd.js.map +1 -1
  142. package/umd/plugins/visibility.umd.js +1 -1
  143. package/umd/plugins/visibility.umd.js.map +1 -1
  144. package/lib/core/internal/column-state.d.ts +0 -124
  145. package/lib/core/internal/column-state.d.ts.map +0 -1
  146. package/lib/core/internal/editors.d.ts.map +0 -1
  147. package/lib/core/internal/grid-internals.d.ts +0 -83
  148. 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,EAAE,MAAM,kBAAkB,CAAC;AAChE,YAAY,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAEhE,yDAAyD;AACzD,MAAM,WAAW,kBAAkB;IACjC,8DAA8D;IAC9D,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,KAAK,WAAW,GAAG,MAAM,CAAC;IACtE,6EAA6E;IAC7E,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,sEAAsE;IACtE,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,kDAAkD;IAClD,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,uBAAuB,CAAC;CACrC;AAED,yDAAyD;AACzD,MAAM,WAAW,iBAAiB;IAChC,yDAAyD;IACzD,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC1B,4CAA4C;IAC5C,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CAC1C;AAED,2CAA2C;AAC3C,MAAM,WAAW,kBAAkB;IACjC,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB;I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CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,SAAS;IAO3D;;OAEG;IACM,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,SAAS;IAaxE;;;OAGG;IACM,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI;IA8BlE,SAAkB,MAAM,SAAU;CAEnC"}
@@ -1,4 +1,4 @@
1
- const h = {
1
+ const x = {
2
2
  expand: "▶",
3
3
  collapse: "▼",
4
4
  sortAsc: "▲",
@@ -8,7 +8,23 @@ const h = {
8
8
  dragHandle: "⋮⋮",
9
9
  toolPanel: "☰"
10
10
  };
11
- class m {
11
+ class M {
12
+ /**
13
+ * Plugin dependencies - declare other plugins this one requires.
14
+ *
15
+ * Dependencies are validated when the plugin is attached.
16
+ * Required dependencies throw an error if missing.
17
+ * Optional dependencies log an info message if missing.
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * static readonly dependencies: PluginDependency[] = [
22
+ * { name: 'editing', required: true, reason: 'Tracks cell edits for undo/redo' },
23
+ * { name: 'selection', required: false, reason: 'Enables selection-based undo' },
24
+ * ];
25
+ * ```
26
+ */
27
+ static dependencies;
12
28
  /** Plugin version - override in subclass if needed */
13
29
  version = "1.0.0";
14
30
  /** CSS styles to inject into the grid's shadow DOM */
@@ -25,6 +41,12 @@ class m {
25
41
  config;
26
42
  /** User-provided configuration from constructor */
27
43
  userConfig;
44
+ /**
45
+ * Plugin-level AbortController for event listener cleanup.
46
+ * Created fresh in attach(), aborted in detach().
47
+ * This ensures event listeners are properly cleaned up when plugins are re-attached.
48
+ */
49
+ #t;
28
50
  /**
29
51
  * Default configuration - subclasses should override this getter.
30
52
  * Note: This must be a getter (not property initializer) for proper inheritance
@@ -39,19 +61,48 @@ class m {
39
61
  /**
40
62
  * Called when the plugin is attached to a grid.
41
63
  * Override to set up event listeners, initialize state, etc.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * attach(grid: GridElement): void {
68
+ * super.attach(grid);
69
+ * // Set up document-level listeners with auto-cleanup
70
+ * document.addEventListener('keydown', this.handleEscape, {
71
+ * signal: this.disconnectSignal
72
+ * });
73
+ * }
74
+ * ```
42
75
  */
43
76
  attach(t) {
44
- this.grid = t, this.config = { ...this.defaultConfig, ...this.userConfig };
77
+ this.#t?.abort(), this.#t = new AbortController(), this.grid = t, this.config = { ...this.defaultConfig, ...this.userConfig };
45
78
  }
46
79
  /**
47
80
  * Called when the plugin is detached from a grid.
48
81
  * Override to clean up event listeners, timers, etc.
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * detach(): void {
86
+ * // Clean up any state not handled by disconnectSignal
87
+ * this.selectedRows.clear();
88
+ * this.cache = null;
89
+ * }
90
+ * ```
49
91
  */
50
92
  detach() {
93
+ this.#t?.abort(), this.#t = void 0;
51
94
  }
52
95
  /**
53
96
  * Get another plugin instance from the same grid.
54
97
  * Use for inter-plugin communication.
98
+ *
99
+ * @example
100
+ * ```ts
101
+ * const selection = this.getPlugin(SelectionPlugin);
102
+ * if (selection) {
103
+ * const selectedRows = selection.getSelectedRows();
104
+ * }
105
+ * ```
55
106
  */
56
107
  getPlugin(t) {
57
108
  return this.grid?.getPlugin(t);
@@ -125,7 +176,7 @@ class m {
125
176
  * document.addEventListener('keydown', handler, { signal: this.disconnectSignal });
126
177
  */
127
178
  get disconnectSignal() {
128
- return this.grid?.disconnectSignal;
179
+ return this.#t?.signal ?? this.grid?.disconnectSignal;
129
180
  }
130
181
  /**
131
182
  * Get the grid-level icons configuration.
@@ -133,7 +184,7 @@ class m {
133
184
  */
134
185
  get gridIcons() {
135
186
  const t = this.grid?.gridConfig?.icons ?? {};
136
- return { ...h, ...t };
187
+ return { ...x, ...t };
137
188
  }
138
189
  /**
139
190
  * Resolve an icon value to string or HTMLElement.
@@ -164,32 +215,32 @@ class m {
164
215
  }
165
216
  // #endregion
166
217
  }
167
- function p(r, t, e) {
218
+ function S(r, t, e) {
168
219
  return t.length ? [...r].sort((n, o) => {
169
220
  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);
221
+ 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
222
  if (s !== 0)
172
223
  return i.direction === "asc" ? s : -s;
173
224
  }
174
225
  return 0;
175
226
  }) : [...r];
176
227
  }
177
- function x(r, t) {
228
+ function C(r, t) {
178
229
  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
230
  }
180
- function M(r, t, e, n) {
231
+ function y(r, t, e, n) {
181
232
  const o = r.find((i) => i.field === t);
182
233
  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
234
  }
184
- function f(r, t) {
235
+ function h(r, t) {
185
236
  const e = r.findIndex((n) => n.field === t);
186
237
  return e >= 0 ? e + 1 : void 0;
187
238
  }
188
- function g(r, t) {
239
+ function m(r, t) {
189
240
  return r.find((e) => e.field === t)?.direction;
190
241
  }
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 {
242
+ 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}';
243
+ class w extends M {
193
244
  name = "multiSort";
194
245
  version = "1.0.0";
195
246
  get defaultConfig() {
@@ -208,12 +259,12 @@ class S extends m {
208
259
  // #endregion
209
260
  // #region Hooks
210
261
  processRows(t) {
211
- return this.sortModel.length === 0 ? [...t] : p([...t], this.sortModel, [...this.columns]);
262
+ return this.sortModel.length === 0 ? [...t] : S([...t], this.sortModel, [...this.columns]);
212
263
  }
213
264
  onHeaderClick(t) {
214
265
  if (!this.columns.find((i) => i.field === t.field)?.sortable) return !1;
215
266
  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;
267
+ return this.sortModel = y(this.sortModel, t.field, n, o), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), !0;
217
268
  }
218
269
  afterRender() {
219
270
  const t = this.shadowRoot;
@@ -222,13 +273,15 @@ class S extends m {
222
273
  t.querySelectorAll(".header-row .cell[data-field]").forEach((o) => {
223
274
  const i = o.getAttribute("data-field");
224
275
  if (!i) return;
225
- const c = f(this.sortModel, i), d = g(this.sortModel, i);
276
+ const c = h(this.sortModel, i), d = m(this.sortModel, i);
226
277
  if (o.querySelector(".sort-index")?.remove(), d) {
227
278
  o.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), o.setAttribute("data-sort", d);
228
279
  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) {
280
+ s.className = "sort-indicator", this.setIcon(s, this.resolveIcon(d === "asc" ? "sortAsc" : "sortDesc"));
281
+ const a = o.querySelector(".tbw-filter-btn"), p = o.querySelector(".resize-handle"), g = a ?? p;
282
+ if (g ? o.insertBefore(s, g) : o.appendChild(s), e && this.sortModel.length > 1 && c !== void 0) {
230
283
  const l = document.createElement("span");
231
- l.className = "sort-index", l.textContent = String(c), o.appendChild(l);
284
+ l.className = "sort-index", l.textContent = String(c), s.nextSibling ? o.insertBefore(l, s.nextSibling) : o.appendChild(l);
232
285
  }
233
286
  } else
234
287
  o.removeAttribute("data-sort");
@@ -262,7 +315,7 @@ class S extends m {
262
315
  * @returns 1-based index or undefined if not sorted
263
316
  */
264
317
  getSortIndex(t) {
265
- return f(this.sortModel, t);
318
+ return h(this.sortModel, t);
266
319
  }
267
320
  /**
268
321
  * Get the sort direction for a specific field.
@@ -270,7 +323,7 @@ class S extends m {
270
323
  * @returns Sort direction or undefined if not sorted
271
324
  */
272
325
  getSortDirection(t) {
273
- return g(this.sortModel, t);
326
+ return m(this.sortModel, t);
274
327
  }
275
328
  // #endregion
276
329
  // #region Column State Hooks
@@ -303,10 +356,10 @@ class S extends m {
303
356
  }
304
357
  // #endregion
305
358
  // #region Styles
306
- styles = C;
359
+ styles = b;
307
360
  // #endregion
308
361
  }
309
362
  export {
310
- S as MultiSortPlugin
363
+ w as MultiSortPlugin
311
364
  };
312
365
  //# sourceMappingURL=index.js.map