@toolbox-web/grid 0.0.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 +3518 -0
- package/all.js +3762 -0
- package/all.js.map +1 -0
- package/index.d.ts +2367 -0
- package/index.js +3105 -0
- package/index.js.map +1 -0
- package/lib/plugins/clipboard/index.js +365 -0
- package/lib/plugins/clipboard/index.js.map +1 -0
- package/lib/plugins/column-virtualization/index.js +255 -0
- package/lib/plugins/column-virtualization/index.js.map +1 -0
- package/lib/plugins/context-menu/index.js +341 -0
- package/lib/plugins/context-menu/index.js.map +1 -0
- package/lib/plugins/export/index.js +305 -0
- package/lib/plugins/export/index.js.map +1 -0
- package/lib/plugins/filtering/index.js +759 -0
- package/lib/plugins/filtering/index.js.map +1 -0
- package/lib/plugins/grouping-columns/index.js +283 -0
- package/lib/plugins/grouping-columns/index.js.map +1 -0
- package/lib/plugins/grouping-rows/index.js +494 -0
- package/lib/plugins/grouping-rows/index.js.map +1 -0
- package/lib/plugins/master-detail/index.js +303 -0
- package/lib/plugins/master-detail/index.js.map +1 -0
- package/lib/plugins/multi-sort/index.js +270 -0
- package/lib/plugins/multi-sort/index.js.map +1 -0
- package/lib/plugins/pinned-columns/index.js +221 -0
- package/lib/plugins/pinned-columns/index.js.map +1 -0
- package/lib/plugins/pinned-rows/index.js +459 -0
- package/lib/plugins/pinned-rows/index.js.map +1 -0
- package/lib/plugins/pivot/index.js +326 -0
- package/lib/plugins/pivot/index.js.map +1 -0
- package/lib/plugins/reorder/index.js +260 -0
- package/lib/plugins/reorder/index.js.map +1 -0
- package/lib/plugins/selection/index.js +426 -0
- package/lib/plugins/selection/index.js.map +1 -0
- package/lib/plugins/server-side/index.js +241 -0
- package/lib/plugins/server-side/index.js.map +1 -0
- package/lib/plugins/tree/index.js +383 -0
- package/lib/plugins/tree/index.js.map +1 -0
- package/lib/plugins/undo-redo/index.js +289 -0
- package/lib/plugins/undo-redo/index.js.map +1 -0
- package/lib/plugins/visibility/index.js +430 -0
- package/lib/plugins/visibility/index.js.map +1 -0
- package/package.json +53 -0
- package/themes/dg-theme-contrast.css +43 -0
- package/themes/dg-theme-large.css +54 -0
- package/themes/dg-theme-standard.css +19 -0
- package/themes/dg-theme-vibrant.css +16 -0
- package/umd/grid.all.umd.js +660 -0
- package/umd/grid.all.umd.js.map +1 -0
- package/umd/grid.umd.js +105 -0
- package/umd/grid.umd.js.map +1 -0
- package/umd/plugins/clipboard.umd.js +9 -0
- package/umd/plugins/clipboard.umd.js.map +1 -0
- package/umd/plugins/column-virtualization.umd.js +2 -0
- package/umd/plugins/column-virtualization.umd.js.map +1 -0
- package/umd/plugins/context-menu.umd.js +53 -0
- package/umd/plugins/context-menu.umd.js.map +1 -0
- package/umd/plugins/export.umd.js +14 -0
- package/umd/plugins/export.umd.js.map +1 -0
- package/umd/plugins/filtering.umd.js +175 -0
- package/umd/plugins/filtering.umd.js.map +1 -0
- package/umd/plugins/grouping-columns.umd.js +29 -0
- package/umd/plugins/grouping-columns.umd.js.map +1 -0
- package/umd/plugins/grouping-rows.umd.js +40 -0
- package/umd/plugins/grouping-rows.umd.js.map +1 -0
- package/umd/plugins/master-detail.umd.js +27 -0
- package/umd/plugins/master-detail.umd.js.map +1 -0
- package/umd/plugins/multi-sort.umd.js +26 -0
- package/umd/plugins/multi-sort.umd.js.map +1 -0
- package/umd/plugins/pinned-columns.umd.js +2 -0
- package/umd/plugins/pinned-columns.umd.js.map +1 -0
- package/umd/plugins/pinned-rows.umd.js +73 -0
- package/umd/plugins/pinned-rows.umd.js.map +1 -0
- package/umd/plugins/pivot.umd.js +8 -0
- package/umd/plugins/pivot.umd.js.map +1 -0
- package/umd/plugins/reorder.umd.js +31 -0
- package/umd/plugins/reorder.umd.js.map +1 -0
- package/umd/plugins/selection.umd.js +34 -0
- package/umd/plugins/selection.umd.js.map +1 -0
- package/umd/plugins/server-side.umd.js +2 -0
- package/umd/plugins/server-side.umd.js.map +1 -0
- package/umd/plugins/tree.umd.js +11 -0
- package/umd/plugins/tree.umd.js.map +1 -0
- package/umd/plugins/undo-redo.umd.js +2 -0
- package/umd/plugins/undo-redo.umd.js.map +1 -0
- package/umd/plugins/visibility.umd.js +94 -0
- package/umd/plugins/visibility.umd.js.map +1 -0
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
class C {
|
|
2
|
+
/** Plugin version - override in subclass if needed */
|
|
3
|
+
version = "1.0.0";
|
|
4
|
+
/** CSS styles to inject into the grid's shadow DOM */
|
|
5
|
+
styles;
|
|
6
|
+
/** Custom cell renderers keyed by type name */
|
|
7
|
+
cellRenderers;
|
|
8
|
+
/** Custom header renderers keyed by type name */
|
|
9
|
+
headerRenderers;
|
|
10
|
+
/** Custom cell editors keyed by type name */
|
|
11
|
+
cellEditors;
|
|
12
|
+
/** The grid instance this plugin is attached to */
|
|
13
|
+
grid;
|
|
14
|
+
/** Plugin configuration - merged with defaults in attach() */
|
|
15
|
+
config;
|
|
16
|
+
/** User-provided configuration from constructor */
|
|
17
|
+
userConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Default configuration - subclasses should override this getter.
|
|
20
|
+
* Note: This must be a getter (not property initializer) for proper inheritance
|
|
21
|
+
* since property initializers run after parent constructor.
|
|
22
|
+
*/
|
|
23
|
+
get defaultConfig() {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
constructor(e = {}) {
|
|
27
|
+
this.userConfig = e;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Called when the plugin is attached to a grid.
|
|
31
|
+
* Override to set up event listeners, initialize state, etc.
|
|
32
|
+
*/
|
|
33
|
+
attach(e) {
|
|
34
|
+
this.grid = e, this.config = { ...this.defaultConfig, ...this.userConfig };
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Called when the plugin is detached from a grid.
|
|
38
|
+
* Override to clean up event listeners, timers, etc.
|
|
39
|
+
*/
|
|
40
|
+
detach() {
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get another plugin instance from the same grid.
|
|
44
|
+
* Use for inter-plugin communication.
|
|
45
|
+
*/
|
|
46
|
+
getPlugin(e) {
|
|
47
|
+
return this.grid?.getPlugin(e);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Emit a custom event from the grid.
|
|
51
|
+
*/
|
|
52
|
+
emit(e, t) {
|
|
53
|
+
this.grid?.dispatchEvent?.(new CustomEvent(e, { detail: t, bubbles: !0 }));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Request a re-render of the grid.
|
|
57
|
+
*/
|
|
58
|
+
requestRender() {
|
|
59
|
+
this.grid?.requestRender?.();
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Request a lightweight style update without rebuilding DOM.
|
|
63
|
+
* Use this instead of requestRender() when only CSS classes need updating.
|
|
64
|
+
*/
|
|
65
|
+
requestAfterRender() {
|
|
66
|
+
this.grid?.requestAfterRender?.();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get the current rows from the grid.
|
|
70
|
+
*/
|
|
71
|
+
get rows() {
|
|
72
|
+
return this.grid?.rows ?? [];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get the original unfiltered/unprocessed rows from the grid.
|
|
76
|
+
* Use this when you need all source data regardless of active filters.
|
|
77
|
+
*/
|
|
78
|
+
get sourceRows() {
|
|
79
|
+
return this.grid?.sourceRows ?? [];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get the current columns from the grid.
|
|
83
|
+
*/
|
|
84
|
+
get columns() {
|
|
85
|
+
return this.grid?.columns ?? [];
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Get only visible columns from the grid (excludes hidden).
|
|
89
|
+
* Use this for rendering that needs to match the grid template.
|
|
90
|
+
*/
|
|
91
|
+
get visibleColumns() {
|
|
92
|
+
return this.grid?.visibleColumns ?? [];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get the shadow root of the grid.
|
|
96
|
+
*/
|
|
97
|
+
get shadowRoot() {
|
|
98
|
+
return this.grid?.shadowRoot ?? null;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Log a warning message.
|
|
102
|
+
*/
|
|
103
|
+
warn(e) {
|
|
104
|
+
console.warn(`[tbw-grid:${this.name}] ${e}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function w(r, e, t) {
|
|
108
|
+
return r.id !== void 0 ? String(r.id) : t ? `${t}-${e}` : String(e);
|
|
109
|
+
}
|
|
110
|
+
function K(r, e, t, n = null, s = 0) {
|
|
111
|
+
const o = e.childrenField ?? "children", i = [];
|
|
112
|
+
for (let c = 0; c < r.length; c++) {
|
|
113
|
+
const a = r[c], d = w(a, c, n), h = a[o], f = Array.isArray(h) && h.length > 0, g = t.has(d);
|
|
114
|
+
if (i.push({
|
|
115
|
+
key: d,
|
|
116
|
+
data: a,
|
|
117
|
+
depth: s,
|
|
118
|
+
hasChildren: f,
|
|
119
|
+
isExpanded: g,
|
|
120
|
+
parentKey: n
|
|
121
|
+
}), f && g) {
|
|
122
|
+
const y = K(h, e, t, d, s + 1);
|
|
123
|
+
i.push(...y);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return i;
|
|
127
|
+
}
|
|
128
|
+
function R(r, e) {
|
|
129
|
+
const t = new Set(r);
|
|
130
|
+
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
131
|
+
}
|
|
132
|
+
function x(r, e, t = null, n = 0) {
|
|
133
|
+
const s = e.childrenField ?? "children", o = /* @__PURE__ */ new Set();
|
|
134
|
+
for (let i = 0; i < r.length; i++) {
|
|
135
|
+
const c = r[i], a = w(c, i, t), d = c[s];
|
|
136
|
+
if (Array.isArray(d) && d.length > 0) {
|
|
137
|
+
o.add(a);
|
|
138
|
+
const h = x(d, e, a, n + 1);
|
|
139
|
+
for (const f of h) o.add(f);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return o;
|
|
143
|
+
}
|
|
144
|
+
function E() {
|
|
145
|
+
return /* @__PURE__ */ new Set();
|
|
146
|
+
}
|
|
147
|
+
function m(r, e, t, n = null, s = 0) {
|
|
148
|
+
const o = t.childrenField ?? "children";
|
|
149
|
+
for (let i = 0; i < r.length; i++) {
|
|
150
|
+
const c = r[i], a = w(c, i, n);
|
|
151
|
+
if (a === e)
|
|
152
|
+
return [a];
|
|
153
|
+
const d = c[o];
|
|
154
|
+
if (Array.isArray(d) && d.length > 0) {
|
|
155
|
+
const h = m(d, e, t, a, s + 1);
|
|
156
|
+
if (h)
|
|
157
|
+
return [a, ...h];
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
function _(r, e, t, n) {
|
|
163
|
+
const s = m(r, e, t);
|
|
164
|
+
if (!s) return n;
|
|
165
|
+
const o = new Set(n);
|
|
166
|
+
for (let i = 0; i < s.length - 1; i++)
|
|
167
|
+
o.add(s[i]);
|
|
168
|
+
return o;
|
|
169
|
+
}
|
|
170
|
+
function A(r, e = "children") {
|
|
171
|
+
if (!Array.isArray(r) || r.length === 0) return !1;
|
|
172
|
+
for (const t of r)
|
|
173
|
+
if (t && Array.isArray(t[e]) && t[e].length > 0)
|
|
174
|
+
return !0;
|
|
175
|
+
return !1;
|
|
176
|
+
}
|
|
177
|
+
function b(r) {
|
|
178
|
+
if (!Array.isArray(r) || r.length === 0) return null;
|
|
179
|
+
const e = ["children", "items", "nodes", "subRows", "nested"];
|
|
180
|
+
for (const t of r)
|
|
181
|
+
if (!(!t || typeof t != "object")) {
|
|
182
|
+
for (const n of e)
|
|
183
|
+
if (Array.isArray(t[n]) && t[n].length > 0)
|
|
184
|
+
return n;
|
|
185
|
+
}
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
function v(r, e = "children", t = 0) {
|
|
189
|
+
if (!Array.isArray(r) || r.length === 0) return t;
|
|
190
|
+
let n = t;
|
|
191
|
+
for (const s of r) {
|
|
192
|
+
if (!s) continue;
|
|
193
|
+
const o = s[e];
|
|
194
|
+
if (Array.isArray(o) && o.length > 0) {
|
|
195
|
+
const i = v(o, e, t + 1);
|
|
196
|
+
i > n && (n = i);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return n;
|
|
200
|
+
}
|
|
201
|
+
function q(r, e = "children") {
|
|
202
|
+
if (!Array.isArray(r)) return 0;
|
|
203
|
+
let t = 0;
|
|
204
|
+
for (const n of r) {
|
|
205
|
+
if (!n) continue;
|
|
206
|
+
t++;
|
|
207
|
+
const s = n[e];
|
|
208
|
+
Array.isArray(s) && (t += q(s, e));
|
|
209
|
+
}
|
|
210
|
+
return t;
|
|
211
|
+
}
|
|
212
|
+
class F extends C {
|
|
213
|
+
name = "tree";
|
|
214
|
+
version = "1.0.0";
|
|
215
|
+
get defaultConfig() {
|
|
216
|
+
return {
|
|
217
|
+
enabled: !0,
|
|
218
|
+
childrenField: "children",
|
|
219
|
+
autoDetect: !0,
|
|
220
|
+
defaultExpanded: !1,
|
|
221
|
+
indentWidth: 20,
|
|
222
|
+
showExpandIcons: !0
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
// ===== Internal State =====
|
|
226
|
+
/** Set of expanded row keys */
|
|
227
|
+
expandedKeys = /* @__PURE__ */ new Set();
|
|
228
|
+
/** Whether initial expansion (based on defaultExpanded config) has been applied */
|
|
229
|
+
initialExpansionDone = !1;
|
|
230
|
+
/** Flattened tree rows for rendering */
|
|
231
|
+
flattenedRows = [];
|
|
232
|
+
/** Map from key to flattened row for quick lookup */
|
|
233
|
+
rowKeyMap = /* @__PURE__ */ new Map();
|
|
234
|
+
// ===== Lifecycle =====
|
|
235
|
+
detach() {
|
|
236
|
+
this.expandedKeys.clear(), this.initialExpansionDone = !1, this.flattenedRows = [], this.rowKeyMap.clear();
|
|
237
|
+
}
|
|
238
|
+
// ===== Auto-Detection =====
|
|
239
|
+
/**
|
|
240
|
+
* Detects if tree functionality should be enabled based on data structure.
|
|
241
|
+
* Called by the grid during plugin initialization.
|
|
242
|
+
*/
|
|
243
|
+
detect(e) {
|
|
244
|
+
if (!this.config.autoDetect) return !1;
|
|
245
|
+
const t = this.config.childrenField ?? b(e) ?? "children";
|
|
246
|
+
return A(e, t);
|
|
247
|
+
}
|
|
248
|
+
// ===== Data Processing =====
|
|
249
|
+
processRows(e) {
|
|
250
|
+
const t = this.config.childrenField ?? "children";
|
|
251
|
+
if (!A(e, t))
|
|
252
|
+
return this.flattenedRows = [], this.rowKeyMap.clear(), [...e];
|
|
253
|
+
this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = x(e, this.config), this.initialExpansionDone = !0), this.flattenedRows = K(e, this.config, this.expandedKeys), this.rowKeyMap.clear();
|
|
254
|
+
for (const n of this.flattenedRows)
|
|
255
|
+
this.rowKeyMap.set(n.key, n);
|
|
256
|
+
return this.flattenedRows.map((n) => ({
|
|
257
|
+
...n.data,
|
|
258
|
+
__treeKey: n.key,
|
|
259
|
+
__treeDepth: n.depth,
|
|
260
|
+
__treeHasChildren: n.hasChildren,
|
|
261
|
+
__treeExpanded: n.isExpanded
|
|
262
|
+
}));
|
|
263
|
+
}
|
|
264
|
+
processColumns(e) {
|
|
265
|
+
if (this.flattenedRows.length === 0) return [...e];
|
|
266
|
+
const t = this.config.indentWidth ?? 20, n = this.config.showExpandIcons ?? !0, s = [...e];
|
|
267
|
+
if (s.length > 0) {
|
|
268
|
+
const o = { ...s[0] }, i = o.viewRenderer;
|
|
269
|
+
o.viewRenderer = (c) => {
|
|
270
|
+
const { value: a, row: d, column: h } = c, f = d.__treeDepth ?? 0, g = d.__treeHasChildren ?? !1, y = d.__treeExpanded ?? !1, u = document.createElement("span");
|
|
271
|
+
if (u.style.display = "flex", u.style.alignItems = "center", u.style.paddingLeft = `${f * t}px`, g && n) {
|
|
272
|
+
const l = document.createElement("span");
|
|
273
|
+
l.className = "tree-toggle", l.textContent = y ? "▼" : "▶", l.style.cursor = "pointer", l.style.marginRight = "4px", l.style.fontSize = "10px", l.setAttribute("data-tree-key", d.__treeKey), u.appendChild(l);
|
|
274
|
+
} else if (n) {
|
|
275
|
+
const l = document.createElement("span");
|
|
276
|
+
l.style.width = "14px", l.style.display = "inline-block", u.appendChild(l);
|
|
277
|
+
}
|
|
278
|
+
const p = document.createElement("span");
|
|
279
|
+
if (i) {
|
|
280
|
+
const l = i(c);
|
|
281
|
+
l instanceof Node ? p.appendChild(l) : p.textContent = String(l ?? a ?? "");
|
|
282
|
+
} else
|
|
283
|
+
p.textContent = String(a ?? "");
|
|
284
|
+
return u.appendChild(p), u;
|
|
285
|
+
}, s[0] = o;
|
|
286
|
+
}
|
|
287
|
+
return s;
|
|
288
|
+
}
|
|
289
|
+
// ===== Event Handlers =====
|
|
290
|
+
onCellClick(e) {
|
|
291
|
+
const t = e.originalEvent?.target;
|
|
292
|
+
if (!t?.classList.contains("tree-toggle")) return !1;
|
|
293
|
+
const n = t.getAttribute("data-tree-key");
|
|
294
|
+
if (!n) return !1;
|
|
295
|
+
const s = this.rowKeyMap.get(n);
|
|
296
|
+
return s ? (this.expandedKeys = R(this.expandedKeys, n), this.emit("tree-expand", {
|
|
297
|
+
key: n,
|
|
298
|
+
row: s.data,
|
|
299
|
+
expanded: this.expandedKeys.has(n),
|
|
300
|
+
depth: s.depth
|
|
301
|
+
}), this.requestRender(), !0) : !1;
|
|
302
|
+
}
|
|
303
|
+
// ===== Public API =====
|
|
304
|
+
/**
|
|
305
|
+
* Expand a specific node by key.
|
|
306
|
+
*/
|
|
307
|
+
expand(e) {
|
|
308
|
+
this.expandedKeys.add(e), this.requestRender();
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Collapse a specific node by key.
|
|
312
|
+
*/
|
|
313
|
+
collapse(e) {
|
|
314
|
+
this.expandedKeys.delete(e), this.requestRender();
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Toggle the expansion state of a node.
|
|
318
|
+
*/
|
|
319
|
+
toggle(e) {
|
|
320
|
+
this.expandedKeys = R(this.expandedKeys, e), this.requestRender();
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Expand all nodes in the tree.
|
|
324
|
+
*/
|
|
325
|
+
expandAll() {
|
|
326
|
+
this.expandedKeys = x(this.rows, this.config), this.requestRender();
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Collapse all nodes in the tree.
|
|
330
|
+
*/
|
|
331
|
+
collapseAll() {
|
|
332
|
+
this.expandedKeys = E(), this.requestRender();
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Check if a node is currently expanded.
|
|
336
|
+
*/
|
|
337
|
+
isExpanded(e) {
|
|
338
|
+
return this.expandedKeys.has(e);
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Get all currently expanded keys.
|
|
342
|
+
*/
|
|
343
|
+
getExpandedKeys() {
|
|
344
|
+
return [...this.expandedKeys];
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Get the flattened tree rows with metadata.
|
|
348
|
+
*/
|
|
349
|
+
getFlattenedRows() {
|
|
350
|
+
return [...this.flattenedRows];
|
|
351
|
+
}
|
|
352
|
+
/**
|
|
353
|
+
* Get a row's original data by its key.
|
|
354
|
+
*/
|
|
355
|
+
getRowByKey(e) {
|
|
356
|
+
return this.rowKeyMap.get(e)?.data;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Expand all ancestors of a node to make it visible.
|
|
360
|
+
*/
|
|
361
|
+
expandToKey(e) {
|
|
362
|
+
this.expandedKeys = _(this.rows, e, this.config, this.expandedKeys), this.requestRender();
|
|
363
|
+
}
|
|
364
|
+
// ===== Styles =====
|
|
365
|
+
styles = `
|
|
366
|
+
.tree-toggle {
|
|
367
|
+
cursor: pointer;
|
|
368
|
+
user-select: none;
|
|
369
|
+
transition: transform 0.2s;
|
|
370
|
+
}
|
|
371
|
+
.tree-toggle:hover {
|
|
372
|
+
color: var(--tbw-tree-accent, var(--tbw-color-accent));
|
|
373
|
+
}
|
|
374
|
+
`;
|
|
375
|
+
}
|
|
376
|
+
export {
|
|
377
|
+
F as TreePlugin,
|
|
378
|
+
q as countNodes,
|
|
379
|
+
A as detectTreeStructure,
|
|
380
|
+
v as getMaxDepth,
|
|
381
|
+
b as inferChildrenField
|
|
382
|
+
};
|
|
383
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../../../libs/grid/src/lib/core/plugin/base-plugin.ts","../../../../../../libs/grid/src/lib/plugins/tree/tree-data.ts","../../../../../../libs/grid/src/lib/plugins/tree/tree-detect.ts","../../../../../../libs/grid/src/lib/plugins/tree/TreePlugin.ts"],"sourcesContent":["/**\r\n * Base Grid Plugin Class\r\n *\r\n * All plugins extend this abstract class.\r\n * Plugins are instantiated per-grid and manage their own state.\r\n */\r\n\r\nimport type { ColumnConfig, ColumnState, HeaderContentDefinition, ToolPanelDefinition } from '../types';\r\n\r\n// Forward declare to avoid circular imports\r\nexport interface GridElement {\r\n shadowRoot: ShadowRoot | null;\r\n rows: any[];\r\n columns: ColumnConfig[];\r\n gridConfig: any;\r\n requestRender(): void;\r\n requestAfterRender(): void;\r\n forceLayout(): Promise<void>;\r\n getPlugin<T extends BaseGridPlugin>(PluginClass: new (...args: any[]) => T): T | undefined;\r\n getPluginByName(name: string): BaseGridPlugin | undefined;\r\n dispatchEvent(event: Event): boolean;\r\n}\r\n\r\n/**\r\n * Keyboard modifier flags\r\n */\r\nexport interface KeyboardModifiers {\r\n ctrl?: boolean;\r\n shift?: boolean;\r\n alt?: boolean;\r\n meta?: boolean;\r\n}\r\n\r\n/**\r\n * Cell coordinates\r\n */\r\nexport interface CellCoords {\r\n row: number;\r\n col: number;\r\n}\r\n\r\n/**\r\n * Cell click event\r\n */\r\nexport interface CellClickEvent {\r\n rowIndex: number;\r\n colIndex: number;\r\n field: string;\r\n value: any;\r\n row: any;\r\n cellEl: HTMLElement;\r\n originalEvent: MouseEvent;\r\n}\r\n\r\n/**\r\n * Row click event\r\n */\r\nexport interface RowClickEvent {\r\n rowIndex: number;\r\n row: any;\r\n rowEl: HTMLElement;\r\n originalEvent: MouseEvent;\r\n}\r\n\r\n/**\r\n * Header click event\r\n */\r\nexport interface HeaderClickEvent {\r\n colIndex: number;\r\n field: string;\r\n column: ColumnConfig;\r\n headerEl: HTMLElement;\r\n originalEvent: MouseEvent;\r\n}\r\n\r\n/**\r\n * Scroll event\r\n */\r\nexport interface ScrollEvent {\r\n scrollTop: number;\r\n scrollLeft: number;\r\n scrollHeight: number;\r\n scrollWidth: number;\r\n clientHeight: number;\r\n clientWidth: number;\r\n originalEvent?: Event;\r\n}\r\n\r\n/**\r\n * Cell mouse event (for drag operations, selection, etc.)\r\n */\r\nexport interface CellMouseEvent {\r\n /** Event type: mousedown, mousemove, or mouseup */\r\n type: 'mousedown' | 'mousemove' | 'mouseup';\r\n /** Row index, undefined if not over a data cell */\r\n rowIndex?: number;\r\n /** Column index, undefined if not over a cell */\r\n colIndex?: number;\r\n /** Field name, undefined if not over a cell */\r\n field?: string;\r\n /** Cell value, undefined if not over a data cell */\r\n value?: unknown;\r\n /** Row data object, undefined if not over a data row */\r\n row?: unknown;\r\n /** Column configuration, undefined if not over a column */\r\n column?: ColumnConfig;\r\n /** The cell element, undefined if not over a cell */\r\n cellElement?: HTMLElement;\r\n /** The row element, undefined if not over a row */\r\n rowElement?: HTMLElement;\r\n /** Whether the event is over a header cell */\r\n isHeader: boolean;\r\n /** Cell coordinates if over a valid data cell */\r\n cell?: CellCoords;\r\n /** The original mouse event */\r\n originalEvent: MouseEvent;\r\n}\r\n\r\n/**\r\n * Context menu parameters\r\n */\r\nexport interface ContextMenuParams {\r\n x: number;\r\n y: number;\r\n rowIndex?: number;\r\n colIndex?: number;\r\n field?: string;\r\n value?: any;\r\n row?: any;\r\n column?: ColumnConfig;\r\n isHeader?: boolean;\r\n}\r\n\r\n/**\r\n * Context menu item\r\n */\r\nexport interface ContextMenuItem {\r\n id: string;\r\n label: string;\r\n icon?: string;\r\n disabled?: boolean;\r\n separator?: boolean;\r\n children?: ContextMenuItem[];\r\n action?: (params: ContextMenuParams) => void;\r\n}\r\n\r\n/**\r\n * Cell render context for plugin cell renderers.\r\n * Provides full context including position and editing state.\r\n *\r\n * Note: This differs from the core `CellRenderContext` in types.ts which is\r\n * simpler and used for column view renderers. This version provides additional\r\n * context needed by plugins that register custom cell renderers.\r\n */\r\nexport interface PluginCellRenderContext {\r\n /** The cell value */\r\n value: any;\r\n /** The field/column key */\r\n field: string;\r\n /** The row data object */\r\n row: any;\r\n /** Row index in the data array */\r\n rowIndex: number;\r\n /** Column index */\r\n colIndex: number;\r\n /** Column configuration */\r\n column: ColumnConfig;\r\n /** Whether the cell is currently in edit mode */\r\n isEditing: boolean;\r\n}\r\n\r\n/**\r\n * Header render context for plugin header renderers.\r\n */\r\nexport interface PluginHeaderRenderContext {\r\n /** Column configuration */\r\n column: ColumnConfig;\r\n /** Column index */\r\n colIndex: number;\r\n}\r\n\r\n/**\r\n * Cell renderer function type for plugins.\r\n */\r\nexport type CellRenderer = (ctx: PluginCellRenderContext) => string | HTMLElement;\r\n\r\n/**\r\n * Header renderer function type for plugins.\r\n */\r\nexport type HeaderRenderer = (ctx: PluginHeaderRenderContext) => string | HTMLElement;\r\n\r\n/**\r\n * Cell editor interface for plugins.\r\n */\r\nexport interface CellEditor {\r\n create(ctx: PluginCellRenderContext, commitFn: (value: any) => void, cancelFn: () => void): HTMLElement;\r\n getValue?(element: HTMLElement): any;\r\n focus?(element: HTMLElement): void;\r\n}\r\n\r\n/**\r\n * Abstract base class for all grid plugins.\r\n *\r\n * @template TConfig - Configuration type for the plugin\r\n */\r\nexport abstract class BaseGridPlugin<TConfig = unknown> {\r\n /** Unique plugin identifier (derived from class name by default) */\r\n abstract readonly name: string;\r\n\r\n /** Plugin version - override in subclass if needed */\r\n readonly version: string = '1.0.0';\r\n\r\n /** CSS styles to inject into the grid's shadow DOM */\r\n readonly styles?: string;\r\n\r\n /** Custom cell renderers keyed by type name */\r\n readonly cellRenderers?: Record<string, CellRenderer>;\r\n\r\n /** Custom header renderers keyed by type name */\r\n readonly headerRenderers?: Record<string, HeaderRenderer>;\r\n\r\n /** Custom cell editors keyed by type name */\r\n readonly cellEditors?: Record<string, CellEditor>;\r\n\r\n /** The grid instance this plugin is attached to */\r\n protected grid!: GridElement;\r\n\r\n /** Plugin configuration - merged with defaults in attach() */\r\n protected config!: TConfig;\r\n\r\n /** User-provided configuration from constructor */\r\n private readonly userConfig: Partial<TConfig>;\r\n\r\n /**\r\n * Default configuration - subclasses should override this getter.\r\n * Note: This must be a getter (not property initializer) for proper inheritance\r\n * since property initializers run after parent constructor.\r\n */\r\n protected get defaultConfig(): Partial<TConfig> {\r\n return {};\r\n }\r\n\r\n constructor(config: Partial<TConfig> = {}) {\r\n this.userConfig = config;\r\n }\r\n\r\n /**\r\n * Called when the plugin is attached to a grid.\r\n * Override to set up event listeners, initialize state, etc.\r\n */\r\n attach(grid: GridElement): void {\r\n this.grid = grid;\r\n // Merge config here (after subclass construction is complete)\r\n this.config = { ...this.defaultConfig, ...this.userConfig } as TConfig;\r\n }\r\n\r\n /**\r\n * Called when the plugin is detached from a grid.\r\n * Override to clean up event listeners, timers, etc.\r\n */\r\n detach(): void {\r\n // Override in subclass\r\n }\r\n\r\n /**\r\n * Get another plugin instance from the same grid.\r\n * Use for inter-plugin communication.\r\n */\r\n protected getPlugin<T extends BaseGridPlugin>(PluginClass: new (...args: any[]) => T): T | undefined {\r\n return this.grid?.getPlugin(PluginClass);\r\n }\r\n\r\n /**\r\n * Emit a custom event from the grid.\r\n */\r\n protected emit<T>(eventName: string, detail: T): void {\r\n this.grid?.dispatchEvent?.(new CustomEvent(eventName, { detail, bubbles: true }));\r\n }\r\n\r\n /**\r\n * Request a re-render of the grid.\r\n */\r\n protected requestRender(): void {\r\n this.grid?.requestRender?.();\r\n }\r\n\r\n /**\r\n * Request a lightweight style update without rebuilding DOM.\r\n * Use this instead of requestRender() when only CSS classes need updating.\r\n */\r\n protected requestAfterRender(): void {\r\n this.grid?.requestAfterRender?.();\r\n }\r\n\r\n /**\r\n * Get the current rows from the grid.\r\n */\r\n protected get rows(): any[] {\r\n return this.grid?.rows ?? [];\r\n }\r\n\r\n /**\r\n * Get the original unfiltered/unprocessed rows from the grid.\r\n * Use this when you need all source data regardless of active filters.\r\n */\r\n protected get sourceRows(): any[] {\r\n return (this.grid as any)?.sourceRows ?? [];\r\n }\r\n\r\n /**\r\n * Get the current columns from the grid.\r\n */\r\n protected get columns(): ColumnConfig[] {\r\n return this.grid?.columns ?? [];\r\n }\r\n\r\n /**\r\n * Get only visible columns from the grid (excludes hidden).\r\n * Use this for rendering that needs to match the grid template.\r\n */\r\n protected get visibleColumns(): ColumnConfig[] {\r\n return (this.grid as any)?.visibleColumns ?? [];\r\n }\r\n\r\n /**\r\n * Get the shadow root of the grid.\r\n */\r\n protected get shadowRoot(): ShadowRoot | null {\r\n return this.grid?.shadowRoot ?? null;\r\n }\r\n\r\n /**\r\n * Log a warning message.\r\n */\r\n protected warn(message: string): void {\r\n console.warn(`[tbw-grid:${this.name}] ${message}`);\r\n }\r\n\r\n // ===== Lifecycle Hooks (override as needed) =====\r\n\r\n /**\r\n * Transform rows before rendering.\r\n * Called during each render cycle before rows are rendered to the DOM.\r\n * Use this to filter, sort, or add computed properties to rows.\r\n *\r\n * @param rows - The current rows array (readonly to encourage returning a new array)\r\n * @returns The modified rows array to render\r\n *\r\n * @example\r\n * ```ts\r\n * processRows(rows: readonly any[]): any[] {\r\n * // Filter out hidden rows\r\n * return rows.filter(row => !row._hidden);\r\n * }\r\n * ```\r\n *\r\n * @example\r\n * ```ts\r\n * processRows(rows: readonly any[]): any[] {\r\n * // Add computed properties\r\n * return rows.map(row => ({\r\n * ...row,\r\n * _fullName: `${row.firstName} ${row.lastName}`\r\n * }));\r\n * }\r\n * ```\r\n */\r\n processRows?(rows: readonly any[]): any[];\r\n\r\n /**\r\n * Transform columns before rendering.\r\n * Called during each render cycle before column headers and cells are rendered.\r\n * Use this to add, remove, or modify column definitions.\r\n *\r\n * @param columns - The current columns array (readonly to encourage returning a new array)\r\n * @returns The modified columns array to render\r\n *\r\n * @example\r\n * ```ts\r\n * processColumns(columns: readonly ColumnConfig[]): ColumnConfig[] {\r\n * // Add a selection checkbox column\r\n * return [\r\n * { field: '_select', header: '', width: 40 },\r\n * ...columns\r\n * ];\r\n * }\r\n * ```\r\n */\r\n processColumns?(columns: readonly ColumnConfig[]): ColumnConfig[];\r\n\r\n /**\r\n * Called before each render cycle begins.\r\n * Use this to prepare state or cache values needed during rendering.\r\n *\r\n * @example\r\n * ```ts\r\n * beforeRender(): void {\r\n * this.visibleRowCount = this.calculateVisibleRows();\r\n * }\r\n * ```\r\n */\r\n beforeRender?(): void;\r\n\r\n /**\r\n * Called after each render cycle completes.\r\n * Use this for DOM manipulation, adding event listeners to rendered elements,\r\n * or applying visual effects like selection highlights.\r\n *\r\n * @example\r\n * ```ts\r\n * afterRender(): void {\r\n * // Apply selection styling to rendered rows\r\n * const rows = this.shadowRoot?.querySelectorAll('.data-row');\r\n * rows?.forEach((row, i) => {\r\n * row.classList.toggle('selected', this.selectedRows.has(i));\r\n * });\r\n * }\r\n * ```\r\n */\r\n afterRender?(): void;\r\n\r\n /**\r\n * Render a custom row, bypassing the default row rendering.\r\n * Use this for special row types like group headers, detail rows, or footers.\r\n *\r\n * @param row - The row data object\r\n * @param rowEl - The row DOM element to render into\r\n * @param rowIndex - The index of the row in the data array\r\n * @returns `true` if the plugin handled rendering (prevents default), `false`/`void` for default rendering\r\n *\r\n * @example\r\n * ```ts\r\n * renderRow(row: any, rowEl: HTMLElement, rowIndex: number): boolean | void {\r\n * if (row._isGroupHeader) {\r\n * rowEl.innerHTML = `<div class=\"group-header\">${row._groupLabel}</div>`;\r\n * return true; // Handled - skip default rendering\r\n * }\r\n * // Return void to let default rendering proceed\r\n * }\r\n * ```\r\n */\r\n renderRow?(row: any, rowEl: HTMLElement, rowIndex: number): boolean | void;\r\n\r\n // ===== Interaction Hooks (override as needed) =====\r\n\r\n /**\r\n * Handle keyboard events on the grid.\r\n * Called when a key is pressed while the grid or a cell has focus.\r\n *\r\n * @param event - The native KeyboardEvent\r\n * @returns `true` to prevent default behavior and stop propagation, `false`/`void` to allow default\r\n *\r\n * @example\r\n * ```ts\r\n * onKeyDown(event: KeyboardEvent): boolean | void {\r\n * // Handle Ctrl+A for select all\r\n * if (event.ctrlKey && event.key === 'a') {\r\n * this.selectAllRows();\r\n * return true; // Prevent default browser select-all\r\n * }\r\n * }\r\n * ```\r\n */\r\n onKeyDown?(event: KeyboardEvent): boolean | void;\r\n\r\n /**\r\n * Handle cell click events.\r\n * Called when a data cell is clicked (not headers).\r\n *\r\n * @param event - Cell click event with row/column context\r\n * @returns `true` to prevent default behavior and stop propagation, `false`/`void` to allow default\r\n *\r\n * @example\r\n * ```ts\r\n * onCellClick(event: CellClickEvent): boolean | void {\r\n * if (event.field === '_select') {\r\n * this.toggleRowSelection(event.rowIndex);\r\n * return true; // Handled\r\n * }\r\n * }\r\n * ```\r\n */\r\n onCellClick?(event: CellClickEvent): boolean | void;\r\n\r\n /**\r\n * Handle row click events.\r\n * Called when any part of a data row is clicked.\r\n * Note: This is called in addition to onCellClick, not instead of.\r\n *\r\n * @param event - Row click event with row context\r\n * @returns `true` to prevent default behavior and stop propagation, `false`/`void` to allow default\r\n *\r\n * @example\r\n * ```ts\r\n * onRowClick(event: RowClickEvent): boolean | void {\r\n * if (this.config.mode === 'row') {\r\n * this.selectRow(event.rowIndex, event.originalEvent);\r\n * return true;\r\n * }\r\n * }\r\n * ```\r\n */\r\n onRowClick?(event: RowClickEvent): boolean | void;\r\n\r\n /**\r\n * Handle header click events.\r\n * Called when a column header is clicked. Commonly used for sorting.\r\n *\r\n * @param event - Header click event with column context\r\n * @returns `true` to prevent default behavior and stop propagation, `false`/`void` to allow default\r\n *\r\n * @example\r\n * ```ts\r\n * onHeaderClick(event: HeaderClickEvent): boolean | void {\r\n * if (event.column.sortable !== false) {\r\n * this.toggleSort(event.field);\r\n * return true;\r\n * }\r\n * }\r\n * ```\r\n */\r\n onHeaderClick?(event: HeaderClickEvent): boolean | void;\r\n\r\n /**\r\n * Handle scroll events on the grid viewport.\r\n * Called during scrolling. Note: This may be called frequently; debounce if needed.\r\n *\r\n * @param event - Scroll event with scroll position and viewport dimensions\r\n *\r\n * @example\r\n * ```ts\r\n * onScroll(event: ScrollEvent): void {\r\n * // Update sticky column positions\r\n * this.updateStickyPositions(event.scrollLeft);\r\n * }\r\n * ```\r\n */\r\n onScroll?(event: ScrollEvent): void;\r\n\r\n /**\r\n * Handle cell mousedown events.\r\n * Used for initiating drag operations like range selection or column resize.\r\n *\r\n * @param event - Mouse event with cell context\r\n * @returns `true` to indicate drag started (prevents text selection), `false`/`void` otherwise\r\n *\r\n * @example\r\n * ```ts\r\n * onCellMouseDown(event: CellMouseEvent): boolean | void {\r\n * if (event.rowIndex !== undefined && this.config.mode === 'range') {\r\n * this.startDragSelection(event.rowIndex, event.colIndex);\r\n * return true; // Prevent text selection\r\n * }\r\n * }\r\n * ```\r\n */\r\n onCellMouseDown?(event: CellMouseEvent): boolean | void;\r\n\r\n /**\r\n * Handle cell mousemove events during drag operations.\r\n * Only called when a drag is in progress (after mousedown returned true).\r\n *\r\n * @param event - Mouse event with current cell context\r\n * @returns `true` to continue handling the drag, `false`/`void` otherwise\r\n *\r\n * @example\r\n * ```ts\r\n * onCellMouseMove(event: CellMouseEvent): boolean | void {\r\n * if (this.isDragging && event.rowIndex !== undefined) {\r\n * this.extendSelection(event.rowIndex, event.colIndex);\r\n * return true;\r\n * }\r\n * }\r\n * ```\r\n */\r\n onCellMouseMove?(event: CellMouseEvent): boolean | void;\r\n\r\n /**\r\n * Handle cell mouseup events to end drag operations.\r\n *\r\n * @param event - Mouse event with final cell context\r\n * @returns `true` if drag was finalized, `false`/`void` otherwise\r\n *\r\n * @example\r\n * ```ts\r\n * onCellMouseUp(event: CellMouseEvent): boolean | void {\r\n * if (this.isDragging) {\r\n * this.finalizeDragSelection();\r\n * this.isDragging = false;\r\n * return true;\r\n * }\r\n * }\r\n * ```\r\n */\r\n onCellMouseUp?(event: CellMouseEvent): boolean | void;\r\n\r\n /**\r\n * Provide context menu items when right-clicking on the grid.\r\n * Multiple plugins can contribute items; they are merged into a single menu.\r\n *\r\n * @param params - Context about where the menu was triggered (row, column, etc.)\r\n * @returns Array of menu items to display\r\n *\r\n * @example\r\n * ```ts\r\n * getContextMenuItems(params: ContextMenuParams): ContextMenuItem[] {\r\n * if (params.isHeader) {\r\n * return [\r\n * { id: 'sort-asc', label: 'Sort Ascending', action: () => this.sortAsc(params.field) },\r\n * { id: 'sort-desc', label: 'Sort Descending', action: () => this.sortDesc(params.field) },\r\n * ];\r\n * }\r\n * return [\r\n * { id: 'copy', label: 'Copy Cell', action: () => this.copyCell(params) },\r\n * ];\r\n * }\r\n * ```\r\n */\r\n getContextMenuItems?(params: ContextMenuParams): ContextMenuItem[];\r\n\r\n // ===== Column State Hooks (override as needed) =====\r\n\r\n /**\r\n * Contribute plugin-specific state for a column.\r\n * Called by the grid when collecting column state for serialization.\r\n * Plugins can add their own properties to the column state.\r\n *\r\n * @param field - The field name of the column\r\n * @returns Partial column state with plugin-specific properties, or undefined if no state to contribute\r\n *\r\n * @example\r\n * ```ts\r\n * getColumnState(field: string): Partial<ColumnState> | undefined {\r\n * const filterModel = this.filterModels.get(field);\r\n * if (filterModel) {\r\n * // Uses module augmentation to add filter property to ColumnState\r\n * return { filter: filterModel } as Partial<ColumnState>;\r\n * }\r\n * return undefined;\r\n * }\r\n * ```\r\n */\r\n getColumnState?(field: string): Partial<ColumnState> | undefined;\r\n\r\n /**\r\n * Apply plugin-specific state to a column.\r\n * Called by the grid when restoring column state from serialized data.\r\n * Plugins should restore their internal state based on the provided state.\r\n *\r\n * @param field - The field name of the column\r\n * @param state - The column state to apply (may contain plugin-specific properties)\r\n *\r\n * @example\r\n * ```ts\r\n * applyColumnState(field: string, state: ColumnState): void {\r\n * // Check for filter property added via module augmentation\r\n * const filter = (state as any).filter;\r\n * if (filter) {\r\n * this.filterModels.set(field, filter);\r\n * this.applyFilter();\r\n * }\r\n * }\r\n * ```\r\n */\r\n applyColumnState?(field: string, state: ColumnState): void;\r\n\r\n // ===== Shell Integration Hooks (override as needed) =====\r\n\r\n /**\r\n * Register a tool panel for this plugin.\r\n * Return undefined if plugin has no tool panel.\r\n * The shell will create a toolbar toggle button and render the panel content\r\n * when the user opens the panel.\r\n *\r\n * @returns Tool panel definition, or undefined if plugin has no panel\r\n *\r\n * @example\r\n * ```ts\r\n * getToolPanel(): ToolPanelDefinition | undefined {\r\n * return {\r\n * id: 'columns',\r\n * title: 'Columns',\r\n * icon: '☰',\r\n * tooltip: 'Show/hide columns',\r\n * order: 10,\r\n * render: (container) => {\r\n * this.renderColumnList(container);\r\n * return () => this.cleanup();\r\n * },\r\n * };\r\n * }\r\n * ```\r\n */\r\n getToolPanel?(): ToolPanelDefinition | undefined;\r\n\r\n /**\r\n * Register content for the shell header center section.\r\n * Return undefined if plugin has no header content.\r\n * Examples: search input, selection summary, status indicators.\r\n *\r\n * @returns Header content definition, or undefined if plugin has no header content\r\n *\r\n * @example\r\n * ```ts\r\n * getHeaderContent(): HeaderContentDefinition | undefined {\r\n * return {\r\n * id: 'quick-filter',\r\n * order: 10,\r\n * render: (container) => {\r\n * const input = document.createElement('input');\r\n * input.type = 'text';\r\n * input.placeholder = 'Search...';\r\n * input.addEventListener('input', this.handleInput);\r\n * container.appendChild(input);\r\n * return () => input.removeEventListener('input', this.handleInput);\r\n * },\r\n * };\r\n * }\r\n * ```\r\n */\r\n getHeaderContent?(): HeaderContentDefinition | undefined;\r\n}\r\n","/**\n * Core Tree Data Logic\n *\n * Pure functions for tree flattening, expansion, and traversal.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n// The tree plugin intentionally uses `any` for maximum flexibility with user-defined row types.\n\nimport type { FlattenedTreeRow, TreeConfig } from './types';\n\n/**\n * Generates a unique key for a row.\n * Uses row.id if available, otherwise generates from path.\n */\nexport function generateRowKey(row: any, index: number, parentKey: string | null): string {\n if (row.id !== undefined) return String(row.id);\n return parentKey ? `${parentKey}-${index}` : String(index);\n}\n\n/**\n * Flattens a hierarchical tree into a flat array of rows with metadata.\n * Only includes children of expanded nodes.\n */\nexport function flattenTree(\n rows: any[],\n config: TreeConfig,\n expandedKeys: Set<string>,\n parentKey: string | null = null,\n depth = 0\n): FlattenedTreeRow[] {\n const childrenField = config.childrenField ?? 'children';\n const result: FlattenedTreeRow[] = [];\n\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i];\n const key = generateRowKey(row, i, parentKey);\n const children = row[childrenField];\n const hasChildren = Array.isArray(children) && children.length > 0;\n const isExpanded = expandedKeys.has(key);\n\n result.push({\n key,\n data: row,\n depth,\n hasChildren,\n isExpanded,\n parentKey,\n });\n\n // Recursively add children if expanded\n if (hasChildren && isExpanded) {\n const childRows = flattenTree(children, config, expandedKeys, key, depth + 1);\n result.push(...childRows);\n }\n }\n\n return result;\n}\n\n/**\n * Toggles the expansion state of a row.\n * Returns a new Set with the toggled state.\n */\nexport function toggleExpand(expandedKeys: Set<string>, key: string): Set<string> {\n const newExpanded = new Set(expandedKeys);\n if (newExpanded.has(key)) {\n newExpanded.delete(key);\n } else {\n newExpanded.add(key);\n }\n return newExpanded;\n}\n\n/**\n * Expands all nodes in the tree.\n * Returns a Set of all parent row keys.\n */\nexport function expandAll(rows: any[], config: TreeConfig, parentKey: string | null = null, depth = 0): Set<string> {\n const childrenField = config.childrenField ?? 'children';\n const keys = new Set<string>();\n\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i];\n const key = generateRowKey(row, i, parentKey);\n const children = row[childrenField];\n\n if (Array.isArray(children) && children.length > 0) {\n keys.add(key);\n const childKeys = expandAll(children, config, key, depth + 1);\n for (const k of childKeys) keys.add(k);\n }\n }\n\n return keys;\n}\n\n/**\n * Collapses all nodes.\n * Returns an empty Set.\n */\nexport function collapseAll(): Set<string> {\n return new Set();\n}\n\n/**\n * Gets all descendants of a node from the flattened row list.\n * Useful for operations that need to affect an entire subtree.\n */\nexport function getDescendants(flattenedRows: FlattenedTreeRow[], parentKey: string): FlattenedTreeRow[] {\n const descendants: FlattenedTreeRow[] = [];\n let collecting = false;\n let parentDepth = -1;\n\n for (const row of flattenedRows) {\n if (row.key === parentKey) {\n collecting = true;\n parentDepth = row.depth;\n continue;\n }\n\n if (collecting) {\n if (row.depth > parentDepth) {\n descendants.push(row);\n } else {\n break; // No longer a descendant\n }\n }\n }\n\n return descendants;\n}\n\n/**\n * Finds the path from root to a specific row key.\n * Returns an array of keys from root to the target (inclusive).\n */\nexport function getPathToKey(\n rows: any[],\n targetKey: string,\n config: TreeConfig,\n parentKey: string | null = null,\n depth = 0\n): string[] | null {\n const childrenField = config.childrenField ?? 'children';\n\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i];\n const key = generateRowKey(row, i, parentKey);\n\n if (key === targetKey) {\n return [key];\n }\n\n const children = row[childrenField];\n if (Array.isArray(children) && children.length > 0) {\n const childPath = getPathToKey(children, targetKey, config, key, depth + 1);\n if (childPath) {\n return [key, ...childPath];\n }\n }\n }\n\n return null;\n}\n\n/**\n * Expands all ancestors of a specific row to make it visible.\n * Returns a new Set with the required keys added.\n */\nexport function expandToKey(\n rows: any[],\n targetKey: string,\n config: TreeConfig,\n existingExpanded: Set<string>\n): Set<string> {\n const path = getPathToKey(rows, targetKey, config);\n if (!path) return existingExpanded;\n\n const newExpanded = new Set(existingExpanded);\n // Add all keys except the last one (the target itself)\n for (let i = 0; i < path.length - 1; i++) {\n newExpanded.add(path[i]);\n }\n return newExpanded;\n}\n","/**\n * Tree Structure Auto-Detection\n *\n * Utilities for detecting hierarchical tree data structures.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n// The tree plugin intentionally uses `any` for maximum flexibility with user-defined row types.\n\n/**\n * Detects if the data has a tree structure by checking for children arrays.\n */\nexport function detectTreeStructure(rows: any[], childrenField = 'children'): boolean {\n if (!Array.isArray(rows) || rows.length === 0) return false;\n\n // Check if any row has a non-empty children array\n for (const row of rows) {\n if (row && Array.isArray(row[childrenField]) && row[childrenField].length > 0) {\n return true;\n }\n }\n\n return false;\n}\n\n/**\n * Attempts to infer the children field name from common patterns.\n * Returns the first field that contains an array with items.\n */\nexport function inferChildrenField(rows: any[]): string | null {\n if (!Array.isArray(rows) || rows.length === 0) return null;\n\n const commonArrayFields = ['children', 'items', 'nodes', 'subRows', 'nested'];\n\n for (const row of rows) {\n if (!row || typeof row !== 'object') continue;\n\n for (const field of commonArrayFields) {\n if (Array.isArray(row[field]) && row[field].length > 0) {\n return field;\n }\n }\n }\n\n return null;\n}\n\n/**\n * Calculates the maximum depth of the tree.\n * Useful for layout calculations and virtualization.\n */\nexport function getMaxDepth(rows: any[], childrenField = 'children', currentDepth = 0): number {\n if (!Array.isArray(rows) || rows.length === 0) return currentDepth;\n\n let maxDepth = currentDepth;\n\n for (const row of rows) {\n if (!row) continue;\n const children = row[childrenField];\n if (Array.isArray(children) && children.length > 0) {\n const childDepth = getMaxDepth(children, childrenField, currentDepth + 1);\n if (childDepth > maxDepth) {\n maxDepth = childDepth;\n }\n }\n }\n\n return maxDepth;\n}\n\n/**\n * Counts total nodes in the tree (including all descendants).\n */\nexport function countNodes(rows: any[], childrenField = 'children'): number {\n if (!Array.isArray(rows)) return 0;\n\n let count = 0;\n for (const row of rows) {\n if (!row) continue;\n count++;\n const children = row[childrenField];\n if (Array.isArray(children)) {\n count += countNodes(children, childrenField);\n }\n }\n\n return count;\n}\n","/**\n * Tree Data Plugin (Class-based)\n *\n * Enables hierarchical tree data with expand/collapse and auto-detection.\n */\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n// The tree plugin intentionally uses `any` for maximum flexibility with user-defined row types.\n\nimport { BaseGridPlugin, CellClickEvent } from '../../core/plugin/base-plugin';\nimport type { ColumnConfig } from '../../core/types';\nimport { collapseAll, expandAll, expandToKey, flattenTree, toggleExpand } from './tree-data';\nimport { detectTreeStructure, inferChildrenField } from './tree-detect';\nimport type { FlattenedTreeRow, TreeConfig, TreeExpandDetail } from './types';\n\n/**\n * Tree Data Plugin for tbw-grid\n *\n * Provides hierarchical tree data display with expand/collapse functionality.\n *\n * @example\n * ```ts\n * new TreePlugin({ defaultExpanded: true, indentWidth: 24 })\n * ```\n */\nexport class TreePlugin extends BaseGridPlugin<TreeConfig> {\n readonly name = 'tree';\n override readonly version = '1.0.0';\n\n protected override get defaultConfig(): Partial<TreeConfig> {\n return {\n enabled: true,\n childrenField: 'children',\n autoDetect: true,\n defaultExpanded: false,\n indentWidth: 20,\n showExpandIcons: true,\n };\n }\n\n // ===== Internal State =====\n\n /** Set of expanded row keys */\n private expandedKeys = new Set<string>();\n\n /** Whether initial expansion (based on defaultExpanded config) has been applied */\n private initialExpansionDone = false;\n\n /** Flattened tree rows for rendering */\n private flattenedRows: FlattenedTreeRow[] = [];\n\n /** Map from key to flattened row for quick lookup */\n private rowKeyMap = new Map<string, FlattenedTreeRow>();\n\n // ===== Lifecycle =====\n\n override detach(): void {\n this.expandedKeys.clear();\n this.initialExpansionDone = false;\n this.flattenedRows = [];\n this.rowKeyMap.clear();\n }\n\n // ===== Auto-Detection =====\n\n /**\n * Detects if tree functionality should be enabled based on data structure.\n * Called by the grid during plugin initialization.\n */\n detect(rows: readonly unknown[]): boolean {\n if (!this.config.autoDetect) return false;\n const childrenField = this.config.childrenField ?? inferChildrenField(rows as any[]) ?? 'children';\n return detectTreeStructure(rows as any[], childrenField);\n }\n\n // ===== Data Processing =====\n\n override processRows(rows: readonly unknown[]): any[] {\n const childrenField = this.config.childrenField ?? 'children';\n\n // Check if data is actually a tree\n if (!detectTreeStructure(rows as any[], childrenField)) {\n this.flattenedRows = [];\n this.rowKeyMap.clear();\n return [...rows];\n }\n\n // Initialize expansion state if needed (only once per grid lifecycle)\n if (this.config.defaultExpanded && !this.initialExpansionDone) {\n this.expandedKeys = expandAll(rows as any[], this.config);\n this.initialExpansionDone = true;\n }\n\n // Flatten tree\n this.flattenedRows = flattenTree(rows as any[], this.config, this.expandedKeys);\n\n // Build key map\n this.rowKeyMap.clear();\n for (const flatRow of this.flattenedRows) {\n this.rowKeyMap.set(flatRow.key, flatRow);\n }\n\n // Return flattened data for rendering with tree metadata\n return this.flattenedRows.map((fr) => ({\n ...fr.data,\n __treeKey: fr.key,\n __treeDepth: fr.depth,\n __treeHasChildren: fr.hasChildren,\n __treeExpanded: fr.isExpanded,\n }));\n }\n\n override processColumns(columns: readonly ColumnConfig[]): ColumnConfig[] {\n if (this.flattenedRows.length === 0) return [...columns];\n\n const indentWidth = this.config.indentWidth ?? 20;\n const showExpandIcons = this.config.showExpandIcons ?? true;\n\n // Wrap first column's renderer to add tree indentation\n const cols = [...columns] as ColumnConfig[];\n if (cols.length > 0) {\n const firstCol = { ...cols[0] };\n const originalRenderer = firstCol.viewRenderer;\n\n firstCol.viewRenderer = (renderCtx) => {\n const { value, row, column: colConfig } = renderCtx;\n const depth = row.__treeDepth ?? 0;\n const hasChildren = row.__treeHasChildren ?? false;\n const isExpanded = row.__treeExpanded ?? false;\n\n const container = document.createElement('span');\n container.style.display = 'flex';\n container.style.alignItems = 'center';\n container.style.paddingLeft = `${depth * indentWidth}px`;\n\n // Expand/collapse icon\n if (hasChildren && showExpandIcons) {\n const icon = document.createElement('span');\n icon.className = 'tree-toggle';\n icon.textContent = isExpanded ? '▼' : '▶';\n icon.style.cursor = 'pointer';\n icon.style.marginRight = '4px';\n icon.style.fontSize = '10px';\n icon.setAttribute('data-tree-key', row.__treeKey);\n container.appendChild(icon);\n } else if (showExpandIcons) {\n // Spacer for alignment\n const spacer = document.createElement('span');\n spacer.style.width = '14px';\n spacer.style.display = 'inline-block';\n container.appendChild(spacer);\n }\n\n // Cell content\n const content = document.createElement('span');\n if (originalRenderer) {\n const rendered = originalRenderer(renderCtx);\n if (rendered instanceof Node) {\n content.appendChild(rendered);\n } else {\n content.textContent = String(rendered ?? value ?? '');\n }\n } else {\n content.textContent = String(value ?? '');\n }\n container.appendChild(content);\n\n return container;\n };\n\n cols[0] = firstCol;\n }\n\n return cols;\n }\n\n // ===== Event Handlers =====\n\n override onCellClick(event: CellClickEvent): boolean {\n const target = event.originalEvent?.target as HTMLElement;\n if (!target?.classList.contains('tree-toggle')) return false;\n\n const key = target.getAttribute('data-tree-key');\n if (!key) return false;\n\n const flatRow = this.rowKeyMap.get(key);\n if (!flatRow) return false;\n\n this.expandedKeys = toggleExpand(this.expandedKeys, key);\n\n this.emit<TreeExpandDetail>('tree-expand', {\n key,\n row: flatRow.data,\n expanded: this.expandedKeys.has(key),\n depth: flatRow.depth,\n });\n\n this.requestRender();\n return true;\n }\n\n // ===== Public API =====\n\n /**\n * Expand a specific node by key.\n */\n expand(key: string): void {\n this.expandedKeys.add(key);\n this.requestRender();\n }\n\n /**\n * Collapse a specific node by key.\n */\n collapse(key: string): void {\n this.expandedKeys.delete(key);\n this.requestRender();\n }\n\n /**\n * Toggle the expansion state of a node.\n */\n toggle(key: string): void {\n this.expandedKeys = toggleExpand(this.expandedKeys, key);\n this.requestRender();\n }\n\n /**\n * Expand all nodes in the tree.\n */\n expandAll(): void {\n this.expandedKeys = expandAll(this.rows as any[], this.config);\n this.requestRender();\n }\n\n /**\n * Collapse all nodes in the tree.\n */\n collapseAll(): void {\n this.expandedKeys = collapseAll();\n this.requestRender();\n }\n\n /**\n * Check if a node is currently expanded.\n */\n isExpanded(key: string): boolean {\n return this.expandedKeys.has(key);\n }\n\n /**\n * Get all currently expanded keys.\n */\n getExpandedKeys(): string[] {\n return [...this.expandedKeys];\n }\n\n /**\n * Get the flattened tree rows with metadata.\n */\n getFlattenedRows(): FlattenedTreeRow[] {\n return [...this.flattenedRows];\n }\n\n /**\n * Get a row's original data by its key.\n */\n getRowByKey(key: string): any | undefined {\n return this.rowKeyMap.get(key)?.data;\n }\n\n /**\n * Expand all ancestors of a node to make it visible.\n */\n expandToKey(key: string): void {\n this.expandedKeys = expandToKey(this.rows as any[], key, this.config, this.expandedKeys);\n this.requestRender();\n }\n\n // ===== Styles =====\n\n override readonly styles = `\n .tree-toggle {\n cursor: pointer;\n user-select: none;\n transition: transform 0.2s;\n }\n .tree-toggle:hover {\n color: var(--tbw-tree-accent, var(--tbw-color-accent));\n }\n `;\n}\n"],"names":["BaseGridPlugin","config","grid","PluginClass","eventName","detail","message","generateRowKey","row","index","parentKey","flattenTree","rows","expandedKeys","depth","childrenField","result","i","key","children","hasChildren","isExpanded","childRows","toggleExpand","newExpanded","expandAll","keys","childKeys","k","collapseAll","getPathToKey","targetKey","childPath","expandToKey","existingExpanded","path","detectTreeStructure","inferChildrenField","commonArrayFields","field","getMaxDepth","currentDepth","maxDepth","childDepth","countNodes","count","TreePlugin","flatRow","fr","columns","indentWidth","showExpandIcons","cols","firstCol","originalRenderer","renderCtx","value","colConfig","container","icon","spacer","content","rendered","event","target"],"mappings":"AA6MO,MAAeA,EAAkC;AAAA;AAAA,EAK7C,UAAkB;AAAA;AAAA,EAGlB;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGC;AAAA;AAAA,EAGA;AAAA;AAAA,EAGO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOjB,IAAc,gBAAkC;AAC9C,WAAO,CAAA;AAAA,EACT;AAAA,EAEA,YAAYC,IAA2B,IAAI;AACzC,SAAK,aAAaA;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAOC,GAAyB;AAC9B,SAAK,OAAOA,GAEZ,KAAK,SAAS,EAAE,GAAG,KAAK,eAAe,GAAG,KAAK,WAAA;AAAA,EACjD;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,SAAe;AAAA,EAEf;AAAA;AAAA;AAAA;AAAA;AAAA,EAMU,UAAoCC,GAAuD;AACnG,WAAO,KAAK,MAAM,U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