@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.
- package/all.d.ts +19 -19
- package/all.d.ts.map +1 -1
- package/all.js +1798 -1201
- package/all.js.map +1 -1
- package/index.js +2215 -2026
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +22 -12
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/columns.d.ts +0 -9
- package/lib/core/internal/columns.d.ts.map +1 -1
- package/lib/core/internal/config-manager.d.ts +236 -0
- package/lib/core/internal/config-manager.d.ts.map +1 -0
- package/lib/core/internal/editing.d.ts +3 -3
- package/lib/core/internal/editing.d.ts.map +1 -1
- package/lib/core/internal/event-delegation.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/internal/keyboard.d.ts.map +1 -1
- package/lib/core/internal/render-scheduler.d.ts +123 -0
- package/lib/core/internal/render-scheduler.d.ts.map +1 -0
- package/lib/core/internal/rows.d.ts +8 -3
- package/lib/core/internal/rows.d.ts.map +1 -1
- package/lib/core/internal/sanitize.d.ts +2 -2
- package/lib/core/internal/sanitize.d.ts.map +1 -1
- package/lib/core/internal/shell.d.ts +40 -2
- package/lib/core/internal/shell.d.ts.map +1 -1
- package/lib/core/internal/validate-config.d.ts +25 -0
- package/lib/core/internal/validate-config.d.ts.map +1 -0
- package/lib/core/plugin/base-plugin.d.ts +118 -0
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/plugin/index.d.ts +1 -0
- package/lib/core/plugin/index.d.ts.map +1 -1
- package/lib/core/plugin/plugin-manager.d.ts +13 -2
- package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/core/plugin/types.d.ts +17 -3
- package/lib/core/plugin/types.d.ts.map +1 -1
- package/lib/core/types.d.ts +112 -12
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts +7 -1
- package/lib/plugins/clipboard/ClipboardPlugin.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +78 -22
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +72 -21
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +53 -2
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +117 -0
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -0
- package/lib/{core/internal → plugins/editing}/editors.d.ts +1 -1
- package/lib/plugins/editing/editors.d.ts.map +1 -0
- package/lib/plugins/editing/index.d.ts +8 -0
- package/lib/plugins/editing/index.d.ts.map +1 -0
- package/lib/plugins/editing/index.js +721 -0
- package/lib/plugins/editing/index.js.map +1 -0
- package/lib/plugins/editing/types.d.ts +45 -0
- package/lib/plugins/editing/types.d.ts.map +1 -0
- package/lib/plugins/export/ExportPlugin.d.ts.map +1 -1
- package/lib/plugins/export/index.js +68 -17
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +103 -50
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/grouping-columns.d.ts +4 -4
- package/lib/plugins/grouping-columns/grouping-columns.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/index.js +80 -29
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/grouping-rows.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +62 -11
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +2 -2
- package/lib/plugins/master-detail/MasterDetailPlugin.d.ts.map +1 -1
- package/lib/plugins/master-detail/index.js +156 -102
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/master-detail/types.d.ts +12 -2
- package/lib/plugins/master-detail/types.d.ts.map +1 -1
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
- package/lib/plugins/multi-sort/index.js +75 -22
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +57 -6
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/index.js +61 -9
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +58 -7
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
- package/lib/plugins/reorder/index.js +75 -19
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +57 -6
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +60 -9
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/TreePlugin.d.ts +3 -3
- package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
- package/lib/plugins/tree/index.js +181 -126
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/tree/tree-data.d.ts +6 -6
- package/lib/plugins/tree/tree-data.d.ts.map +1 -1
- package/lib/plugins/tree/tree-detect.d.ts +5 -9
- package/lib/plugins/tree/tree-detect.d.ts.map +1 -1
- package/lib/plugins/tree/types.d.ts +16 -4
- package/lib/plugins/tree/types.d.ts.map +1 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts +7 -1
- package/lib/plugins/undo-redo/UndoRedoPlugin.d.ts.map +1 -1
- package/lib/plugins/undo-redo/index.js +65 -6
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/VisibilityPlugin.d.ts +7 -1
- package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
- package/lib/plugins/visibility/index.js +61 -2
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/public.d.ts +104 -13
- package/public.d.ts.map +1 -1
- package/umd/grid.all.umd.js +37 -19
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +25 -7
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/clipboard.umd.js +2 -2
- package/umd/plugins/clipboard.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +2 -0
- package/umd/plugins/editing.umd.js.map +1 -0
- package/umd/plugins/export.umd.js +2 -2
- package/umd/plugins/export.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/reorder.umd.js +1 -1
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/undo-redo.umd.js +1 -1
- package/umd/plugins/undo-redo.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
- package/lib/core/internal/column-state.d.ts +0 -124
- package/lib/core/internal/column-state.d.ts.map +0 -1
- package/lib/core/internal/editors.d.ts.map +0 -1
- package/lib/core/internal/grid-internals.d.ts +0 -83
- 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
|
|
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) =>
|
|
249
|
+
return t.some((r) => b(s, e, r));
|
|
199
250
|
}
|
|
200
|
-
function
|
|
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
|
|
261
|
+
for (const r of p(t))
|
|
211
262
|
e.set(`${r.row},${r.col}`, r);
|
|
212
263
|
return [...e.values()];
|
|
213
264
|
}
|