@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
@@ -17,6 +17,22 @@ const R = {
17
17
  toolPanel: "☰"
18
18
  };
19
19
  class C {
20
+ /**
21
+ * Plugin dependencies - declare other plugins this one requires.
22
+ *
23
+ * Dependencies are validated when the plugin is attached.
24
+ * Required dependencies throw an error if missing.
25
+ * Optional dependencies log an info message if missing.
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * static readonly dependencies: PluginDependency[] = [
30
+ * { name: 'editing', required: true, reason: 'Tracks cell edits for undo/redo' },
31
+ * { name: 'selection', required: false, reason: 'Enables selection-based undo' },
32
+ * ];
33
+ * ```
34
+ */
35
+ static dependencies;
20
36
  /** Plugin version - override in subclass if needed */
21
37
  version = "1.0.0";
22
38
  /** CSS styles to inject into the grid's shadow DOM */
@@ -33,6 +49,12 @@ class C {
33
49
  config;
34
50
  /** User-provided configuration from constructor */
35
51
  userConfig;
52
+ /**
53
+ * Plugin-level AbortController for event listener cleanup.
54
+ * Created fresh in attach(), aborted in detach().
55
+ * This ensures event listeners are properly cleaned up when plugins are re-attached.
56
+ */
57
+ #t;
36
58
  /**
37
59
  * Default configuration - subclasses should override this getter.
38
60
  * Note: This must be a getter (not property initializer) for proper inheritance
@@ -47,19 +69,48 @@ class C {
47
69
  /**
48
70
  * Called when the plugin is attached to a grid.
49
71
  * Override to set up event listeners, initialize state, etc.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * attach(grid: GridElement): void {
76
+ * super.attach(grid);
77
+ * // Set up document-level listeners with auto-cleanup
78
+ * document.addEventListener('keydown', this.handleEscape, {
79
+ * signal: this.disconnectSignal
80
+ * });
81
+ * }
82
+ * ```
50
83
  */
51
84
  attach(e) {
52
- this.grid = e, this.config = { ...this.defaultConfig, ...this.userConfig };
85
+ this.#t?.abort(), this.#t = new AbortController(), this.grid = e, this.config = { ...this.defaultConfig, ...this.userConfig };
53
86
  }
54
87
  /**
55
88
  * Called when the plugin is detached from a grid.
56
89
  * Override to clean up event listeners, timers, etc.
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * detach(): void {
94
+ * // Clean up any state not handled by disconnectSignal
95
+ * this.selectedRows.clear();
96
+ * this.cache = null;
97
+ * }
98
+ * ```
57
99
  */
58
100
  detach() {
101
+ this.#t?.abort(), this.#t = void 0;
59
102
  }
60
103
  /**
61
104
  * Get another plugin instance from the same grid.
62
105
  * Use for inter-plugin communication.
106
+ *
107
+ * @example
108
+ * ```ts
109
+ * const selection = this.getPlugin(SelectionPlugin);
110
+ * if (selection) {
111
+ * const selectedRows = selection.getSelectedRows();
112
+ * }
113
+ * ```
63
114
  */
64
115
  getPlugin(e) {
65
116
  return this.grid?.getPlugin(e);
@@ -133,7 +184,7 @@ class C {
133
184
  * document.addEventListener('keydown', handler, { signal: this.disconnectSignal });
134
185
  */
135
186
  get disconnectSignal() {
136
- return this.grid?.disconnectSignal;
187
+ return this.#t?.signal ?? this.grid?.disconnectSignal;
137
188
  }
138
189
  /**
139
190
  * Get the grid-level icons configuration.
@@ -190,14 +241,14 @@ function m(s) {
190
241
  function u(s) {
191
242
  return s.map(m);
192
243
  }
193
- function p(s, e, t) {
244
+ function b(s, e, t) {
194
245
  const r = h(t);
195
246
  return s >= r.startRow && s <= r.endRow && e >= r.startCol && e <= r.endCol;
196
247
  }
197
248
  function f(s, e, t) {
198
- return t.some((r) => p(s, e, r));
249
+ return t.some((r) => b(s, e, r));
199
250
  }
200
- function b(s) {
251
+ function p(s) {
201
252
  const e = [], t = h(s);
202
253
  for (let r = t.startRow; r <= t.endRow; r++)
203
254
  for (let n = t.startCol; n <= t.endCol; n++)
@@ -207,7 +258,7 @@ function b(s) {
207
258
  function A(s) {
208
259
  const e = /* @__PURE__ */ new Map();
209
260
  for (const t of s)
210
- for (const r of b(t))
261
+ for (const r of p(t))
211
262
  e.set(`${r.row},${r.col}`, r);
212
263
  return [...e.values()];
213
264
  }