@toolbox-web/grid 0.2.6 → 0.2.7
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 +434 -61
- package/all.js +844 -541
- package/all.js.map +1 -1
- package/index-DG2CZ_Zo.js +3229 -0
- package/index-DG2CZ_Zo.js.map +1 -0
- package/index.d.ts +210 -6
- package/index.js +25 -3194
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +183 -148
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +116 -82
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +139 -81
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +17 -17
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +369 -337
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +264 -91
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +180 -169
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +21 -21
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +12 -12
- package/umd/grid.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-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/pivot.umd.js +1 -1
- package/umd/plugins/pivot.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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const S = {
|
|
2
2
|
expand: "▶",
|
|
3
3
|
collapse: "▼",
|
|
4
4
|
sortAsc: "▲",
|
|
@@ -8,7 +8,7 @@ const v = {
|
|
|
8
8
|
dragHandle: "⋮⋮",
|
|
9
9
|
toolPanel: "☰"
|
|
10
10
|
};
|
|
11
|
-
class
|
|
11
|
+
class K {
|
|
12
12
|
/** Plugin version - override in subclass if needed */
|
|
13
13
|
version = "1.0.0";
|
|
14
14
|
/** CSS styles to inject into the grid's shadow DOM */
|
|
@@ -133,7 +133,7 @@ class b {
|
|
|
133
133
|
*/
|
|
134
134
|
get gridIcons() {
|
|
135
135
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
136
|
-
return { ...
|
|
136
|
+
return { ...S, ...e };
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* Resolve an icon value to string or HTMLElement.
|
|
@@ -164,80 +164,62 @@ class b {
|
|
|
164
164
|
}
|
|
165
165
|
// #endregion
|
|
166
166
|
}
|
|
167
|
-
function
|
|
168
|
-
return
|
|
167
|
+
function x(o, e, t) {
|
|
168
|
+
return o.id !== void 0 ? String(o.id) : t ? `${t}-${e}` : String(e);
|
|
169
169
|
}
|
|
170
|
-
function
|
|
171
|
-
const
|
|
172
|
-
for (let c = 0; c < r.length; c++) {
|
|
173
|
-
const a = r[c], d = w(a, c, n), h = a[o], f = Array.isArray(h) && h.length > 0, g = t.has(d);
|
|
174
|
-
if (i.push({
|
|
175
|
-
key: d,
|
|
176
|
-
data: a,
|
|
177
|
-
depth: s,
|
|
178
|
-
hasChildren: f,
|
|
179
|
-
isExpanded: g,
|
|
180
|
-
parentKey: n
|
|
181
|
-
}), f && g) {
|
|
182
|
-
const y = E(h, e, t, d, s + 1);
|
|
183
|
-
i.push(...y);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return i;
|
|
187
|
-
}
|
|
188
|
-
function C(r, e) {
|
|
189
|
-
const t = new Set(r);
|
|
170
|
+
function w(o, e) {
|
|
171
|
+
const t = new Set(o);
|
|
190
172
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
191
173
|
}
|
|
192
|
-
function
|
|
193
|
-
const
|
|
194
|
-
for (let
|
|
195
|
-
const
|
|
174
|
+
function p(o, e, t = null, n = 0) {
|
|
175
|
+
const r = e.childrenField ?? "children", i = /* @__PURE__ */ new Set();
|
|
176
|
+
for (let s = 0; s < o.length; s++) {
|
|
177
|
+
const a = o[s], l = x(a, s, t), d = a[r];
|
|
196
178
|
if (Array.isArray(d) && d.length > 0) {
|
|
197
|
-
|
|
198
|
-
const h =
|
|
199
|
-
for (const
|
|
179
|
+
i.add(l);
|
|
180
|
+
const h = p(d, e, l, n + 1);
|
|
181
|
+
for (const u of h) i.add(u);
|
|
200
182
|
}
|
|
201
183
|
}
|
|
202
|
-
return
|
|
184
|
+
return i;
|
|
203
185
|
}
|
|
204
|
-
function
|
|
186
|
+
function R() {
|
|
205
187
|
return /* @__PURE__ */ new Set();
|
|
206
188
|
}
|
|
207
|
-
function
|
|
208
|
-
const
|
|
209
|
-
for (let
|
|
210
|
-
const
|
|
211
|
-
if (
|
|
212
|
-
return [
|
|
213
|
-
const d =
|
|
189
|
+
function b(o, e, t, n = null, r = 0) {
|
|
190
|
+
const i = t.childrenField ?? "children";
|
|
191
|
+
for (let s = 0; s < o.length; s++) {
|
|
192
|
+
const a = o[s], l = x(a, s, n);
|
|
193
|
+
if (l === e)
|
|
194
|
+
return [l];
|
|
195
|
+
const d = a[i];
|
|
214
196
|
if (Array.isArray(d) && d.length > 0) {
|
|
215
|
-
const h =
|
|
197
|
+
const h = b(d, e, t, l, r + 1);
|
|
216
198
|
if (h)
|
|
217
|
-
return [
|
|
199
|
+
return [l, ...h];
|
|
218
200
|
}
|
|
219
201
|
}
|
|
220
202
|
return null;
|
|
221
203
|
}
|
|
222
|
-
function
|
|
223
|
-
const
|
|
224
|
-
if (!
|
|
225
|
-
const
|
|
226
|
-
for (let
|
|
227
|
-
|
|
228
|
-
return
|
|
204
|
+
function C(o, e, t, n) {
|
|
205
|
+
const r = b(o, e, t);
|
|
206
|
+
if (!r) return n;
|
|
207
|
+
const i = new Set(n);
|
|
208
|
+
for (let s = 0; s < r.length - 1; s++)
|
|
209
|
+
i.add(r[s]);
|
|
210
|
+
return i;
|
|
229
211
|
}
|
|
230
|
-
function
|
|
231
|
-
if (!Array.isArray(
|
|
232
|
-
for (const t of
|
|
212
|
+
function m(o, e = "children") {
|
|
213
|
+
if (!Array.isArray(o) || o.length === 0) return !1;
|
|
214
|
+
for (const t of o)
|
|
233
215
|
if (t && Array.isArray(t[e]) && t[e].length > 0)
|
|
234
216
|
return !0;
|
|
235
217
|
return !1;
|
|
236
218
|
}
|
|
237
|
-
function
|
|
238
|
-
if (!Array.isArray(
|
|
219
|
+
function _(o) {
|
|
220
|
+
if (!Array.isArray(o) || o.length === 0) return null;
|
|
239
221
|
const e = ["children", "items", "nodes", "subRows", "nested"];
|
|
240
|
-
for (const t of
|
|
222
|
+
for (const t of o)
|
|
241
223
|
if (!(!t || typeof t != "object")) {
|
|
242
224
|
for (const n of e)
|
|
243
225
|
if (Array.isArray(t[n]) && t[n].length > 0)
|
|
@@ -245,200 +227,229 @@ function D(r) {
|
|
|
245
227
|
}
|
|
246
228
|
return null;
|
|
247
229
|
}
|
|
248
|
-
function
|
|
249
|
-
if (!Array.isArray(
|
|
230
|
+
function v(o, e = "children", t = 0) {
|
|
231
|
+
if (!Array.isArray(o) || o.length === 0) return t;
|
|
250
232
|
let n = t;
|
|
251
|
-
for (const
|
|
252
|
-
if (!
|
|
253
|
-
const
|
|
254
|
-
if (Array.isArray(
|
|
255
|
-
const
|
|
256
|
-
|
|
233
|
+
for (const r of o) {
|
|
234
|
+
if (!r) continue;
|
|
235
|
+
const i = r[e];
|
|
236
|
+
if (Array.isArray(i) && i.length > 0) {
|
|
237
|
+
const s = v(i, e, t + 1);
|
|
238
|
+
s > n && (n = s);
|
|
257
239
|
}
|
|
258
240
|
}
|
|
259
241
|
return n;
|
|
260
242
|
}
|
|
261
|
-
function
|
|
262
|
-
if (!Array.isArray(
|
|
243
|
+
function E(o, e = "children") {
|
|
244
|
+
if (!Array.isArray(o)) return 0;
|
|
263
245
|
let t = 0;
|
|
264
|
-
for (const n of
|
|
246
|
+
for (const n of o) {
|
|
265
247
|
if (!n) continue;
|
|
266
248
|
t++;
|
|
267
|
-
const
|
|
268
|
-
Array.isArray(
|
|
249
|
+
const r = n[e];
|
|
250
|
+
Array.isArray(r) && (t += E(r, e));
|
|
269
251
|
}
|
|
270
252
|
return t;
|
|
271
253
|
}
|
|
272
|
-
const k = ".tree-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;
|
|
273
|
-
class
|
|
254
|
+
const k = ".tree-cell{display:flex;align-items:center;padding-left:calc(var(--tree-depth, 0) * var(--tbw-tree-indent, 20px))}.tree-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center;margin-right:4px}.tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}.tree-spacer{width:14px;display:inline-block}.data-grid-row.tbw-tree-slide-in{animation:tbw-tree-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-tree-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}.data-grid-row.tbw-tree-fade-in{animation:tbw-tree-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-tree-fade-in{0%{opacity:0}to{opacity:1}}";
|
|
255
|
+
class T extends K {
|
|
274
256
|
name = "tree";
|
|
275
257
|
version = "1.0.0";
|
|
258
|
+
styles = k;
|
|
276
259
|
get defaultConfig() {
|
|
277
260
|
return {
|
|
278
261
|
childrenField: "children",
|
|
279
262
|
autoDetect: !0,
|
|
280
263
|
defaultExpanded: !1,
|
|
281
264
|
indentWidth: 20,
|
|
282
|
-
showExpandIcons: !0
|
|
265
|
+
showExpandIcons: !0,
|
|
266
|
+
animation: "slide"
|
|
283
267
|
};
|
|
284
268
|
}
|
|
285
|
-
// #region
|
|
286
|
-
/** Set of expanded row keys */
|
|
269
|
+
// #region State
|
|
287
270
|
expandedKeys = /* @__PURE__ */ new Set();
|
|
288
|
-
/** Whether initial expansion (based on defaultExpanded config) has been applied */
|
|
289
271
|
initialExpansionDone = !1;
|
|
290
|
-
/** Flattened tree rows for rendering */
|
|
291
272
|
flattenedRows = [];
|
|
292
|
-
/** Map from key to flattened row for quick lookup */
|
|
293
273
|
rowKeyMap = /* @__PURE__ */ new Map();
|
|
294
|
-
|
|
295
|
-
|
|
274
|
+
previousVisibleKeys = /* @__PURE__ */ new Set();
|
|
275
|
+
keysToAnimate = /* @__PURE__ */ new Set();
|
|
276
|
+
sortState = null;
|
|
296
277
|
detach() {
|
|
297
|
-
this.expandedKeys.clear(), this.initialExpansionDone = !1, this.flattenedRows = [], this.rowKeyMap.clear();
|
|
278
|
+
this.expandedKeys.clear(), this.initialExpansionDone = !1, this.flattenedRows = [], this.rowKeyMap.clear(), this.previousVisibleKeys.clear(), this.keysToAnimate.clear(), this.sortState = null;
|
|
279
|
+
}
|
|
280
|
+
// #endregion
|
|
281
|
+
// #region Animation
|
|
282
|
+
get animationStyle() {
|
|
283
|
+
const t = this.grid.effectiveConfig?.animation?.mode ?? "reduced-motion";
|
|
284
|
+
if (t === !1 || t === "off") return !1;
|
|
285
|
+
if (t !== !0 && t !== "on") {
|
|
286
|
+
const n = this.shadowRoot?.host;
|
|
287
|
+
if (n && getComputedStyle(n).getPropertyValue("--tbw-animation-enabled").trim() === "0")
|
|
288
|
+
return !1;
|
|
289
|
+
}
|
|
290
|
+
return this.config.animation ?? "slide";
|
|
298
291
|
}
|
|
299
292
|
// #endregion
|
|
300
293
|
// #region Auto-Detection
|
|
301
|
-
/**
|
|
302
|
-
* Detects if tree functionality should be enabled based on data structure.
|
|
303
|
-
* Called by the grid during plugin initialization.
|
|
304
|
-
*/
|
|
305
294
|
detect(e) {
|
|
306
295
|
if (!this.config.autoDetect) return !1;
|
|
307
|
-
const t = this.config.childrenField ??
|
|
308
|
-
return
|
|
296
|
+
const t = this.config.childrenField ?? _(e) ?? "children";
|
|
297
|
+
return m(e, t);
|
|
309
298
|
}
|
|
310
299
|
// #endregion
|
|
311
300
|
// #region Data Processing
|
|
312
301
|
processRows(e) {
|
|
313
302
|
const t = this.config.childrenField ?? "children";
|
|
314
|
-
if (!
|
|
315
|
-
return this.flattenedRows = [], this.rowKeyMap.clear(), [...e];
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
303
|
+
if (!m(e, t))
|
|
304
|
+
return this.flattenedRows = [], this.rowKeyMap.clear(), this.previousVisibleKeys.clear(), [...e];
|
|
305
|
+
let n = this.withStableKeys(e);
|
|
306
|
+
this.sortState && (n = this.sortTree(n, this.sortState.field, this.sortState.direction)), this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = p(n, this.config), this.initialExpansionDone = !0), this.flattenedRows = this.flattenTree(n, this.expandedKeys), this.rowKeyMap.clear(), this.keysToAnimate.clear();
|
|
307
|
+
const r = /* @__PURE__ */ new Set();
|
|
308
|
+
for (const i of this.flattenedRows)
|
|
309
|
+
this.rowKeyMap.set(i.key, i), r.add(i.key), !this.previousVisibleKeys.has(i.key) && i.depth > 0 && this.keysToAnimate.add(i.key);
|
|
310
|
+
return this.previousVisibleKeys = r, this.flattenedRows.map((i) => ({
|
|
311
|
+
...i.data,
|
|
312
|
+
__treeKey: i.key,
|
|
313
|
+
__treeDepth: i.depth,
|
|
314
|
+
__treeHasChildren: i.hasChildren,
|
|
315
|
+
__treeExpanded: i.isExpanded
|
|
325
316
|
}));
|
|
326
317
|
}
|
|
318
|
+
/** Assign stable keys to rows (preserves key across sort operations) */
|
|
319
|
+
withStableKeys(e, t = null) {
|
|
320
|
+
const n = this.config.childrenField ?? "children";
|
|
321
|
+
return e.map((r, i) => {
|
|
322
|
+
const s = r.id !== void 0 ? String(r.id) : r.__stableKey ?? (t ? `${t}-${i}` : String(i)), a = r[n], l = Array.isArray(a) && a.length > 0;
|
|
323
|
+
return {
|
|
324
|
+
...r,
|
|
325
|
+
__stableKey: s,
|
|
326
|
+
...l ? { [n]: this.withStableKeys(a, s) } : {}
|
|
327
|
+
};
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
/** Flatten tree using stable keys */
|
|
331
|
+
flattenTree(e, t, n = 0) {
|
|
332
|
+
const r = this.config.childrenField ?? "children", i = [];
|
|
333
|
+
for (const s of e) {
|
|
334
|
+
const a = s.__stableKey ?? s.id ?? "?", l = s[r], d = Array.isArray(l) && l.length > 0, h = t.has(a);
|
|
335
|
+
i.push({
|
|
336
|
+
key: a,
|
|
337
|
+
data: s,
|
|
338
|
+
depth: n,
|
|
339
|
+
hasChildren: d,
|
|
340
|
+
isExpanded: h,
|
|
341
|
+
parentKey: n > 0 && a.substring(0, a.lastIndexOf("-")) || null
|
|
342
|
+
}), d && h && i.push(...this.flattenTree(l, t, n + 1));
|
|
343
|
+
}
|
|
344
|
+
return i;
|
|
345
|
+
}
|
|
346
|
+
/** Sort tree recursively, keeping children with parents */
|
|
347
|
+
sortTree(e, t, n) {
|
|
348
|
+
const r = this.config.childrenField ?? "children";
|
|
349
|
+
return [...e].sort((s, a) => {
|
|
350
|
+
const l = s[t], d = a[t];
|
|
351
|
+
return l == null && d == null ? 0 : l == null ? -1 : d == null ? 1 : l > d ? n : l < d ? -n : 0;
|
|
352
|
+
}).map((s) => {
|
|
353
|
+
const a = s[r];
|
|
354
|
+
return Array.isArray(a) && a.length > 0 ? { ...s, [r]: this.sortTree(a, t, n) } : s;
|
|
355
|
+
});
|
|
356
|
+
}
|
|
327
357
|
processColumns(e) {
|
|
328
358
|
if (this.flattenedRows.length === 0) return [...e];
|
|
329
359
|
const t = [...e];
|
|
330
|
-
if (t.length
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
i.__treeWrapped = !0, n.viewRenderer = i, t[0] = n;
|
|
352
|
-
}
|
|
353
|
-
return t;
|
|
360
|
+
if (t.length === 0) return t;
|
|
361
|
+
const n = { ...t[0] }, r = n.viewRenderer;
|
|
362
|
+
if (r?.__treeWrapped) return t;
|
|
363
|
+
const i = () => this.config, s = this.setIcon.bind(this), a = this.resolveIcon.bind(this), l = (d) => {
|
|
364
|
+
const { value: h, row: u } = d, { indentWidth: A = 20, showExpandIcons: y = !0 } = i(), f = document.createElement("span");
|
|
365
|
+
if (f.className = "tree-cell", f.style.setProperty("--tree-depth", String(u.__treeDepth ?? 0)), f.style.setProperty("--tbw-tree-indent", `${A}px`), u.__treeHasChildren && y) {
|
|
366
|
+
const c = document.createElement("span");
|
|
367
|
+
c.className = `tree-toggle${u.__treeExpanded ? " expanded" : ""}`, s(c, a(u.__treeExpanded ? "collapse" : "expand")), c.setAttribute("data-tree-key", u.__treeKey), f.appendChild(c);
|
|
368
|
+
} else if (y) {
|
|
369
|
+
const c = document.createElement("span");
|
|
370
|
+
c.className = "tree-spacer", f.appendChild(c);
|
|
371
|
+
}
|
|
372
|
+
const g = document.createElement("span");
|
|
373
|
+
if (r) {
|
|
374
|
+
const c = r(d);
|
|
375
|
+
c instanceof Node ? g.appendChild(c) : g.textContent = String(c ?? h ?? "");
|
|
376
|
+
} else
|
|
377
|
+
g.textContent = String(h ?? "");
|
|
378
|
+
return f.appendChild(g), f;
|
|
379
|
+
};
|
|
380
|
+
return l.__treeWrapped = !0, n.viewRenderer = l, t[0] = n, t;
|
|
354
381
|
}
|
|
355
382
|
// #endregion
|
|
356
383
|
// #region Event Handlers
|
|
357
384
|
onCellClick(e) {
|
|
358
385
|
const t = e.originalEvent?.target;
|
|
359
386
|
if (!t?.classList.contains("tree-toggle")) return !1;
|
|
360
|
-
const n = t.getAttribute("data-tree-key");
|
|
361
|
-
|
|
362
|
-
const s = this.rowKeyMap.get(n);
|
|
363
|
-
return s ? (this.expandedKeys = C(this.expandedKeys, n), this.emit("tree-expand", {
|
|
387
|
+
const n = t.getAttribute("data-tree-key"), r = n ? this.rowKeyMap.get(n) : null;
|
|
388
|
+
return r ? (this.expandedKeys = w(this.expandedKeys, n), this.emit("tree-expand", {
|
|
364
389
|
key: n,
|
|
365
|
-
row:
|
|
390
|
+
row: r.data,
|
|
366
391
|
expanded: this.expandedKeys.has(n),
|
|
367
|
-
depth:
|
|
392
|
+
depth: r.depth
|
|
368
393
|
}), this.requestRender(), !0) : !1;
|
|
369
394
|
}
|
|
395
|
+
onHeaderClick(e) {
|
|
396
|
+
if (this.flattenedRows.length === 0 || !e.column.sortable) return !1;
|
|
397
|
+
const { field: t } = e.column;
|
|
398
|
+
!this.sortState || this.sortState.field !== t ? this.sortState = { field: t, direction: 1 } : this.sortState.direction === 1 ? this.sortState = { field: t, direction: -1 } : this.sortState = null;
|
|
399
|
+
const n = this.grid;
|
|
400
|
+
return n._sortState !== void 0 && (n._sortState = this.sortState ? { ...this.sortState } : null), this.emit("sort-change", { field: t, direction: this.sortState?.direction ?? 0 }), this.requestRender(), !0;
|
|
401
|
+
}
|
|
402
|
+
afterRender() {
|
|
403
|
+
const e = this.animationStyle;
|
|
404
|
+
if (e === !1 || this.keysToAnimate.size === 0) return;
|
|
405
|
+
const t = this.shadowRoot?.querySelector(".rows");
|
|
406
|
+
if (!t) return;
|
|
407
|
+
const n = e === "fade" ? "tbw-tree-fade-in" : "tbw-tree-slide-in";
|
|
408
|
+
for (const r of t.querySelectorAll(".data-grid-row")) {
|
|
409
|
+
const i = r.querySelector(".cell[data-row]"), s = i ? parseInt(i.getAttribute("data-row") ?? "-1", 10) : -1, a = this.flattenedRows[s]?.key;
|
|
410
|
+
a && this.keysToAnimate.has(a) && (r.classList.add(n), r.addEventListener("animationend", () => r.classList.remove(n), { once: !0 }));
|
|
411
|
+
}
|
|
412
|
+
this.keysToAnimate.clear();
|
|
413
|
+
}
|
|
370
414
|
// #endregion
|
|
371
415
|
// #region Public API
|
|
372
|
-
/**
|
|
373
|
-
* Expand a specific node by key.
|
|
374
|
-
*/
|
|
375
416
|
expand(e) {
|
|
376
417
|
this.expandedKeys.add(e), this.requestRender();
|
|
377
418
|
}
|
|
378
|
-
/**
|
|
379
|
-
* Collapse a specific node by key.
|
|
380
|
-
*/
|
|
381
419
|
collapse(e) {
|
|
382
420
|
this.expandedKeys.delete(e), this.requestRender();
|
|
383
421
|
}
|
|
384
|
-
/**
|
|
385
|
-
* Toggle the expansion state of a node.
|
|
386
|
-
*/
|
|
387
422
|
toggle(e) {
|
|
388
|
-
this.expandedKeys =
|
|
423
|
+
this.expandedKeys = w(this.expandedKeys, e), this.requestRender();
|
|
389
424
|
}
|
|
390
|
-
/**
|
|
391
|
-
* Expand all nodes in the tree.
|
|
392
|
-
*/
|
|
393
425
|
expandAll() {
|
|
394
|
-
this.expandedKeys =
|
|
426
|
+
this.expandedKeys = p(this.rows, this.config), this.requestRender();
|
|
395
427
|
}
|
|
396
|
-
/**
|
|
397
|
-
* Collapse all nodes in the tree.
|
|
398
|
-
*/
|
|
399
428
|
collapseAll() {
|
|
400
|
-
this.expandedKeys =
|
|
429
|
+
this.expandedKeys = R(), this.requestRender();
|
|
401
430
|
}
|
|
402
|
-
/**
|
|
403
|
-
* Check if a node is currently expanded.
|
|
404
|
-
*/
|
|
405
431
|
isExpanded(e) {
|
|
406
432
|
return this.expandedKeys.has(e);
|
|
407
433
|
}
|
|
408
|
-
/**
|
|
409
|
-
* Get all currently expanded keys.
|
|
410
|
-
*/
|
|
411
434
|
getExpandedKeys() {
|
|
412
435
|
return [...this.expandedKeys];
|
|
413
436
|
}
|
|
414
|
-
/**
|
|
415
|
-
* Get the flattened tree rows with metadata.
|
|
416
|
-
*/
|
|
417
437
|
getFlattenedRows() {
|
|
418
438
|
return [...this.flattenedRows];
|
|
419
439
|
}
|
|
420
|
-
/**
|
|
421
|
-
* Get a row's original data by its key.
|
|
422
|
-
*/
|
|
423
440
|
getRowByKey(e) {
|
|
424
441
|
return this.rowKeyMap.get(e)?.data;
|
|
425
442
|
}
|
|
426
|
-
/**
|
|
427
|
-
* Expand all ancestors of a node to make it visible.
|
|
428
|
-
*/
|
|
429
443
|
expandToKey(e) {
|
|
430
|
-
this.expandedKeys =
|
|
444
|
+
this.expandedKeys = C(this.rows, e, this.config, this.expandedKeys), this.requestRender();
|
|
431
445
|
}
|
|
432
446
|
// #endregion
|
|
433
|
-
// #region Styles
|
|
434
|
-
styles = k;
|
|
435
|
-
// #endregion
|
|
436
447
|
}
|
|
437
448
|
export {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
449
|
+
T as TreePlugin,
|
|
450
|
+
E as countNodes,
|
|
451
|
+
m as detectTreeStructure,
|
|
452
|
+
v as getMaxDepth,
|
|
453
|
+
_ as inferChildrenField
|
|
443
454
|
};
|
|
444
455
|
//# sourceMappingURL=index.js.map
|