@toolbox-web/grid 1.3.1 → 1.5.0
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 +1 -0
- package/all.d.ts.map +1 -1
- package/all.js +1034 -706
- package/all.js.map +1 -1
- package/index.js +641 -600
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts +7 -0
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/types.d.ts +147 -0
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +2 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +6 -5
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +2 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +9 -6
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.d.ts +1 -1
- package/lib/plugins/export/index.d.ts.map +1 -1
- package/lib/plugins/export/index.js +2 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.d.ts +1 -1
- package/lib/plugins/filtering/index.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +60 -59
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +2 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts +12 -3
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/grouping-rows.d.ts +13 -2
- package/lib/plugins/grouping-rows/grouping-rows.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.d.ts +1 -1
- package/lib/plugins/grouping-rows/index.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +200 -125
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/grouping-rows/types.d.ts +24 -2
- package/lib/plugins/grouping-rows/types.d.ts.map +1 -1
- package/lib/plugins/master-detail/index.d.ts +1 -1
- package/lib/plugins/master-detail/index.d.ts.map +1 -1
- package/lib/plugins/master-detail/index.js +2 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +2 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +2 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +3 -2
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +2 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/PrintPlugin.d.ts +98 -0
- package/lib/plugins/print/PrintPlugin.d.ts.map +1 -0
- package/lib/plugins/print/index.d.ts +10 -0
- package/lib/plugins/print/index.d.ts.map +1 -0
- package/lib/plugins/print/index.js +626 -0
- package/lib/plugins/print/index.js.map +1 -0
- package/lib/plugins/print/print-isolated.d.ts +26 -0
- package/lib/plugins/print/print-isolated.d.ts.map +1 -0
- package/lib/plugins/print/types.d.ts +147 -0
- package/lib/plugins/print/types.d.ts.map +1 -0
- package/lib/plugins/reorder/index.js +2 -1
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/index.js +2 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js +2 -1
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +109 -97
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +2 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +2 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.d.ts +1 -1
- package/lib/plugins/undo-redo/index.d.ts.map +1 -1
- package/lib/plugins/undo-redo/index.js +2 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.d.ts +1 -1
- package/lib/plugins/visibility/index.d.ts.map +1 -1
- package/lib/plugins/visibility/index.js +2 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/public.d.ts +1 -1
- package/public.d.ts.map +1 -1
- package/umd/grid.all.umd.js +101 -24
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +11 -11
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +1 -1
- package/umd/plugins/editing.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 +4 -1
- package/umd/plugins/grouping-rows.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/print.umd.js +76 -0
- package/umd/plugins/print.umd.js.map +1 -0
- package/umd/plugins/selection.umd.js +2 -2
- package/umd/plugins/selection.umd.js.map +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const x = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>', R = {
|
|
2
2
|
expand: "▶",
|
|
3
3
|
collapse: "▼",
|
|
4
4
|
sortAsc: "▲",
|
|
@@ -7,10 +7,11 @@ const y = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentCo
|
|
|
7
7
|
submenuArrow: "▶",
|
|
8
8
|
dragHandle: "⋮⋮",
|
|
9
9
|
toolPanel: "☰",
|
|
10
|
-
filter:
|
|
11
|
-
filterActive:
|
|
10
|
+
filter: x,
|
|
11
|
+
filterActive: x,
|
|
12
|
+
print: "🖨️"
|
|
12
13
|
};
|
|
13
|
-
class
|
|
14
|
+
class C {
|
|
14
15
|
/**
|
|
15
16
|
* Plugin dependencies - declare other plugins this one requires.
|
|
16
17
|
*
|
|
@@ -310,14 +311,14 @@ class x {
|
|
|
310
311
|
}
|
|
311
312
|
// #endregion
|
|
312
313
|
}
|
|
313
|
-
const
|
|
314
|
+
const E = "__tbw_expander";
|
|
314
315
|
function A(n) {
|
|
315
|
-
return n.field ===
|
|
316
|
+
return n.field === E;
|
|
316
317
|
}
|
|
317
|
-
const
|
|
318
|
+
const y = {
|
|
318
319
|
sum: (n, e) => n.reduce((t, r) => t + (Number(r[e]) || 0), 0),
|
|
319
320
|
avg: (n, e) => {
|
|
320
|
-
const t = n.reduce((r,
|
|
321
|
+
const t = n.reduce((r, s) => r + (Number(s[e]) || 0), 0);
|
|
321
322
|
return n.length ? t / n.length : 0;
|
|
322
323
|
},
|
|
323
324
|
count: (n) => n.length,
|
|
@@ -325,106 +326,138 @@ const _ = {
|
|
|
325
326
|
max: (n, e) => Math.max(...n.map((t) => Number(t[e]) || -1 / 0)),
|
|
326
327
|
first: (n, e) => n[0]?.[e],
|
|
327
328
|
last: (n, e) => n[n.length - 1]?.[e]
|
|
328
|
-
},
|
|
329
|
+
}, b = /* @__PURE__ */ new Map(), m = {
|
|
329
330
|
/**
|
|
330
331
|
* Register a custom aggregator function.
|
|
331
332
|
*/
|
|
332
333
|
register(n, e) {
|
|
333
|
-
|
|
334
|
+
b.set(n, e);
|
|
334
335
|
},
|
|
335
336
|
/**
|
|
336
337
|
* Unregister a custom aggregator function.
|
|
337
338
|
*/
|
|
338
339
|
unregister(n) {
|
|
339
|
-
|
|
340
|
+
b.delete(n);
|
|
340
341
|
},
|
|
341
342
|
/**
|
|
342
343
|
* Get an aggregator function by reference.
|
|
343
344
|
*/
|
|
344
345
|
get(n) {
|
|
345
346
|
if (n !== void 0)
|
|
346
|
-
return typeof n == "function" ? n :
|
|
347
|
+
return typeof n == "function" ? n : b.get(n) ?? y[n];
|
|
347
348
|
},
|
|
348
349
|
/**
|
|
349
350
|
* Run an aggregator on a set of rows.
|
|
350
351
|
*/
|
|
351
352
|
run(n, e, t, r) {
|
|
352
|
-
const
|
|
353
|
-
return
|
|
353
|
+
const s = this.get(n);
|
|
354
|
+
return s ? s(e, t, r) : void 0;
|
|
354
355
|
},
|
|
355
356
|
/**
|
|
356
357
|
* Check if an aggregator exists.
|
|
357
358
|
*/
|
|
358
359
|
has(n) {
|
|
359
|
-
return
|
|
360
|
+
return b.has(n) || n in y;
|
|
360
361
|
},
|
|
361
362
|
/**
|
|
362
363
|
* List all available aggregator names.
|
|
363
364
|
*/
|
|
364
365
|
list() {
|
|
365
|
-
return [...Object.keys(
|
|
366
|
+
return [...Object.keys(y), ...b.keys()];
|
|
366
367
|
}
|
|
367
368
|
};
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
const
|
|
372
|
-
|
|
373
|
-
function
|
|
374
|
-
const
|
|
375
|
-
if (typeof
|
|
369
|
+
m.register.bind(m);
|
|
370
|
+
m.unregister.bind(m);
|
|
371
|
+
m.get.bind(m);
|
|
372
|
+
const _ = m.run.bind(m);
|
|
373
|
+
m.list.bind(m);
|
|
374
|
+
function v({ rows: n, config: e, expanded: t, initialExpanded: r }) {
|
|
375
|
+
const s = e.groupOn;
|
|
376
|
+
if (typeof s != "function")
|
|
376
377
|
return [];
|
|
377
|
-
const
|
|
378
|
-
if (n.forEach((
|
|
379
|
-
let
|
|
380
|
-
|
|
381
|
-
let
|
|
382
|
-
|
|
383
|
-
const
|
|
384
|
-
let
|
|
385
|
-
|
|
386
|
-
}),
|
|
387
|
-
}),
|
|
378
|
+
const o = { key: "__root__", value: null, depth: -1, rows: [], children: /* @__PURE__ */ new Map() };
|
|
379
|
+
if (n.forEach((d) => {
|
|
380
|
+
let u = s(d);
|
|
381
|
+
u == null || u === !1 ? u = ["__ungrouped__"] : Array.isArray(u) || (u = [u]);
|
|
382
|
+
let a = o;
|
|
383
|
+
u.forEach((w, p) => {
|
|
384
|
+
const c = w == null ? "∅" : String(w), h = a.key === "__root__" ? c : a.key + "||" + c;
|
|
385
|
+
let f = a.children.get(c);
|
|
386
|
+
f || (f = { key: h, value: w, depth: p, rows: [], children: /* @__PURE__ */ new Map(), parent: a }, a.children.set(c, f)), a = f;
|
|
387
|
+
}), a.rows.push(d);
|
|
388
|
+
}), o.children.size === 1 && o.children.has("__ungrouped__") && o.children.get("__ungrouped__").rows.length === n.length)
|
|
388
389
|
return [];
|
|
389
|
-
const
|
|
390
|
-
if (
|
|
391
|
-
|
|
390
|
+
const g = /* @__PURE__ */ new Set([...t, ...r ?? []]), i = [], l = (d) => {
|
|
391
|
+
if (d === o) {
|
|
392
|
+
d.children.forEach((a) => l(a));
|
|
392
393
|
return;
|
|
393
394
|
}
|
|
394
|
-
const
|
|
395
|
-
|
|
395
|
+
const u = g.has(d.key);
|
|
396
|
+
i.push({
|
|
396
397
|
kind: "group",
|
|
397
|
-
key:
|
|
398
|
-
value:
|
|
399
|
-
depth:
|
|
400
|
-
rows:
|
|
401
|
-
expanded:
|
|
402
|
-
}),
|
|
398
|
+
key: d.key,
|
|
399
|
+
value: d.value,
|
|
400
|
+
depth: d.depth,
|
|
401
|
+
rows: d.rows,
|
|
402
|
+
expanded: u
|
|
403
|
+
}), u && (d.children.size ? d.children.forEach((a) => l(a)) : d.rows.forEach((a) => i.push({ kind: "data", row: a, rowIndex: n.indexOf(a) })));
|
|
403
404
|
};
|
|
404
|
-
return
|
|
405
|
+
return l(o), i;
|
|
405
406
|
}
|
|
406
|
-
function
|
|
407
|
+
function S(n, e) {
|
|
407
408
|
const t = new Set(n);
|
|
408
409
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
409
410
|
}
|
|
410
|
-
function
|
|
411
|
+
function K(n) {
|
|
411
412
|
const e = /* @__PURE__ */ new Set();
|
|
412
413
|
for (const t of n)
|
|
413
414
|
t.kind === "group" && e.add(t.key);
|
|
414
415
|
return e;
|
|
415
416
|
}
|
|
416
|
-
function
|
|
417
|
+
function k() {
|
|
417
418
|
return /* @__PURE__ */ new Set();
|
|
418
419
|
}
|
|
419
|
-
function G(n) {
|
|
420
|
+
function G(n, e) {
|
|
421
|
+
if (n === !0)
|
|
422
|
+
return new Set(e);
|
|
423
|
+
if (n === !1 || n == null)
|
|
424
|
+
return /* @__PURE__ */ new Set();
|
|
425
|
+
if (typeof n == "number") {
|
|
426
|
+
const t = e[n];
|
|
427
|
+
return t ? /* @__PURE__ */ new Set([t]) : /* @__PURE__ */ new Set();
|
|
428
|
+
}
|
|
429
|
+
return typeof n == "string" ? /* @__PURE__ */ new Set([n]) : Array.isArray(n) ? new Set(n) : /* @__PURE__ */ new Set();
|
|
430
|
+
}
|
|
431
|
+
function T(n) {
|
|
432
|
+
return n.filter((e) => e.kind === "group").map((e) => e.key);
|
|
433
|
+
}
|
|
434
|
+
function I(n) {
|
|
420
435
|
return n.kind !== "group" ? 0 : n.rows.length;
|
|
421
436
|
}
|
|
422
|
-
const
|
|
423
|
-
class
|
|
437
|
+
const N = "@layer tbw-plugins{.group-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-grouping-rows-bg, var(--tbw-color-panel-bg));font-weight:500;border-bottom:var(--tbw-row-divider);min-height:var(--tbw-row-height)}.group-row .cell{display:flex;align-items:center;padding:var(--tbw-cell-padding, .125rem .5rem)}.group-row:hover{background:var(--tbw-grouping-rows-bg-hover, var(--tbw-color-row-hover))}.group-toggle{cursor:pointer;-webkit-user-select:none;user-select:none;display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-toggle-size, 1.25rem);height:var(--tbw-toggle-size, 1.25rem);margin-right:.25rem;background:none;border:0;font:inherit}.group-toggle:hover{background:var(--tbw-grouping-rows-toggle-hover, var(--tbw-color-row-hover));border-radius:var(--tbw-border-radius, .125rem)}.group-label{display:inline-flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.group-count{color:var(--tbw-grouping-rows-count-color, var(--tbw-color-fg-muted));font-size:var(--tbw-font-size-xs, .85em);font-weight:400}.group-aggregates{display:inline-flex;align-items:center;gap:var(--tbw-spacing-lg, 1rem);margin-left:var(--tbw-spacing-lg, 1rem);font-weight:400;font-size:var(--tbw-font-size-sm, .875em);color:var(--tbw-grouping-rows-aggregate-color, var(--tbw-color-fg-muted))}.group-aggregate{white-space:nowrap}.group-row{padding-left:calc(var(--tbw-group-depth, 0) * var(--tbw-group-indent-width, 1.25em))}.data-grid-row.tbw-group-slide-in{animation:tbw-group-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-group-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}.data-grid-row.tbw-group-fade-in{animation:tbw-group-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-group-fade-in{0%{opacity:0}to{opacity:1}}}";
|
|
438
|
+
class D extends C {
|
|
439
|
+
/**
|
|
440
|
+
* Plugin manifest - declares configuration validation rules.
|
|
441
|
+
* @internal
|
|
442
|
+
*/
|
|
443
|
+
static manifest = {
|
|
444
|
+
configRules: [
|
|
445
|
+
{
|
|
446
|
+
id: "groupingRows/accordion-defaultExpanded",
|
|
447
|
+
severity: "warn",
|
|
448
|
+
message: `"accordion: true" and "defaultExpanded" (non-false) are used together.
|
|
449
|
+
→ In accordion mode, only one group can be open at a time.
|
|
450
|
+
→ Using defaultExpanded with multiple groups will collapse to one on first toggle.
|
|
451
|
+
→ Consider using "defaultExpanded: false" or a single group key/index with accordion mode.`,
|
|
452
|
+
check: (e) => e.accordion === !0 && e.defaultExpanded !== !1 && e.defaultExpanded !== void 0 && typeof e.defaultExpanded != "number" && typeof e.defaultExpanded != "string" && // Warn if true or array with multiple items
|
|
453
|
+
(e.defaultExpanded === !0 || Array.isArray(e.defaultExpanded) && e.defaultExpanded.length > 1)
|
|
454
|
+
}
|
|
455
|
+
]
|
|
456
|
+
};
|
|
424
457
|
/** @internal */
|
|
425
458
|
name = "groupingRows";
|
|
426
459
|
/** @internal */
|
|
427
|
-
styles =
|
|
460
|
+
styles = N;
|
|
428
461
|
/** @internal */
|
|
429
462
|
get defaultConfig() {
|
|
430
463
|
return {
|
|
@@ -432,7 +465,8 @@ class I extends x {
|
|
|
432
465
|
showRowCount: !0,
|
|
433
466
|
indentWidth: 20,
|
|
434
467
|
aggregators: {},
|
|
435
|
-
animation: "slide"
|
|
468
|
+
animation: "slide",
|
|
469
|
+
accordion: !1
|
|
436
470
|
};
|
|
437
471
|
}
|
|
438
472
|
// #region Internal State
|
|
@@ -441,6 +475,8 @@ class I extends x {
|
|
|
441
475
|
isActive = !1;
|
|
442
476
|
previousVisibleKeys = /* @__PURE__ */ new Set();
|
|
443
477
|
keysToAnimate = /* @__PURE__ */ new Set();
|
|
478
|
+
/** Track if initial defaultExpanded has been applied */
|
|
479
|
+
hasAppliedDefaultExpanded = !1;
|
|
444
480
|
// #endregion
|
|
445
481
|
// #region Animation
|
|
446
482
|
/**
|
|
@@ -454,7 +490,7 @@ class I extends x {
|
|
|
454
490
|
// #region Lifecycle
|
|
455
491
|
/** @internal */
|
|
456
492
|
detach() {
|
|
457
|
-
this.expandedKeys.clear(), this.flattenedRows = [], this.isActive = !1, this.previousVisibleKeys.clear(), this.keysToAnimate.clear();
|
|
493
|
+
this.expandedKeys.clear(), this.flattenedRows = [], this.isActive = !1, this.previousVisibleKeys.clear(), this.keysToAnimate.clear(), this.hasAppliedDefaultExpanded = !1;
|
|
458
494
|
}
|
|
459
495
|
// #endregion
|
|
460
496
|
// #region Hooks
|
|
@@ -470,29 +506,41 @@ class I extends x {
|
|
|
470
506
|
const t = this.config;
|
|
471
507
|
if (typeof t.groupOn != "function")
|
|
472
508
|
return this.isActive = !1, this.flattenedRows = [], [...e];
|
|
473
|
-
const r =
|
|
509
|
+
const r = v({
|
|
474
510
|
rows: [...e],
|
|
475
511
|
config: t,
|
|
476
|
-
expanded:
|
|
512
|
+
expanded: /* @__PURE__ */ new Set()
|
|
513
|
+
// Empty to get all root groups
|
|
477
514
|
});
|
|
478
515
|
if (r.length === 0)
|
|
479
516
|
return this.isActive = !1, this.flattenedRows = [], [...e];
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
517
|
+
let s;
|
|
518
|
+
if (!this.hasAppliedDefaultExpanded && this.expandedKeys.size === 0 && t.defaultExpanded !== !1) {
|
|
519
|
+
const i = T(r);
|
|
520
|
+
s = G(t.defaultExpanded ?? !1, i), s.size > 0 && (this.expandedKeys = new Set(s), this.hasAppliedDefaultExpanded = !0);
|
|
521
|
+
}
|
|
522
|
+
const o = v({
|
|
523
|
+
rows: [...e],
|
|
524
|
+
config: t,
|
|
525
|
+
expanded: this.expandedKeys,
|
|
526
|
+
initialExpanded: s
|
|
527
|
+
});
|
|
528
|
+
this.isActive = !0, this.flattenedRows = o, this.keysToAnimate.clear();
|
|
529
|
+
const g = /* @__PURE__ */ new Set();
|
|
530
|
+
return o.forEach((i, l) => {
|
|
531
|
+
if (i.kind === "data") {
|
|
532
|
+
const d = `data-${l}`;
|
|
533
|
+
g.add(d), this.previousVisibleKeys.has(d) || this.keysToAnimate.add(d);
|
|
486
534
|
}
|
|
487
|
-
}), this.previousVisibleKeys =
|
|
535
|
+
}), this.previousVisibleKeys = g, o.map((i) => i.kind === "group" ? {
|
|
488
536
|
__isGroupRow: !0,
|
|
489
|
-
__groupKey:
|
|
490
|
-
__groupValue:
|
|
491
|
-
__groupDepth:
|
|
492
|
-
__groupRows:
|
|
493
|
-
__groupExpanded:
|
|
494
|
-
__groupRowCount:
|
|
495
|
-
} :
|
|
537
|
+
__groupKey: i.key,
|
|
538
|
+
__groupValue: i.value,
|
|
539
|
+
__groupDepth: i.depth,
|
|
540
|
+
__groupRows: i.rows,
|
|
541
|
+
__groupExpanded: i.expanded,
|
|
542
|
+
__groupRowCount: I(i)
|
|
543
|
+
} : i.row);
|
|
496
544
|
}
|
|
497
545
|
/** @internal */
|
|
498
546
|
onCellClick(e) {
|
|
@@ -514,25 +562,25 @@ class I extends x {
|
|
|
514
562
|
renderRow(e, t, r) {
|
|
515
563
|
if (!e?.__isGroupRow)
|
|
516
564
|
return !1;
|
|
517
|
-
const
|
|
518
|
-
if (
|
|
519
|
-
const
|
|
565
|
+
const s = this.config;
|
|
566
|
+
if (s.groupRowRenderer) {
|
|
567
|
+
const i = () => {
|
|
520
568
|
this.toggle(e.__groupKey);
|
|
521
|
-
},
|
|
569
|
+
}, l = s.groupRowRenderer({
|
|
522
570
|
key: e.__groupKey,
|
|
523
571
|
value: e.__groupValue,
|
|
524
572
|
depth: e.__groupDepth,
|
|
525
573
|
rows: e.__groupRows,
|
|
526
574
|
expanded: e.__groupExpanded,
|
|
527
|
-
toggleExpand:
|
|
575
|
+
toggleExpand: i
|
|
528
576
|
});
|
|
529
|
-
if (
|
|
530
|
-
return t.className = "data-grid-row group-row", t.__isCustomRow = !0, t.setAttribute("data-group-depth", String(e.__groupDepth)), typeof
|
|
577
|
+
if (l)
|
|
578
|
+
return t.className = "data-grid-row group-row", t.__isCustomRow = !0, t.setAttribute("data-group-depth", String(e.__groupDepth)), typeof l == "string" ? t.innerHTML = l : (t.innerHTML = "", t.appendChild(l)), !0;
|
|
531
579
|
}
|
|
532
|
-
const
|
|
580
|
+
const o = () => {
|
|
533
581
|
this.toggle(e.__groupKey);
|
|
534
582
|
};
|
|
535
|
-
return t.className = "data-grid-row group-row", t.__isCustomRow = !0, t.setAttribute("data-group-depth", String(e.__groupDepth)), t.setAttribute("role", "row"), t.setAttribute("aria-expanded", String(e.__groupExpanded)), t.style.setProperty("--tbw-group-depth", String(e.__groupDepth || 0)),
|
|
583
|
+
return t.className = "data-grid-row group-row", t.__isCustomRow = !0, t.setAttribute("data-group-depth", String(e.__groupDepth)), t.setAttribute("role", "row"), t.setAttribute("aria-expanded", String(e.__groupExpanded)), t.style.setProperty("--tbw-group-depth", String(e.__groupDepth || 0)), s.indentWidth !== void 0 && t.style.setProperty("--tbw-group-indent-width", `${s.indentWidth}px`), t.style.height = "", t.innerHTML = "", s.fullWidth !== !1 ? this.renderFullWidthGroupRow(e, t, o) : this.renderPerColumnGroupRow(e, t, o), !0;
|
|
536
584
|
}
|
|
537
585
|
/** @internal */
|
|
538
586
|
afterRender() {
|
|
@@ -541,9 +589,9 @@ class I extends x {
|
|
|
541
589
|
const t = this.gridElement?.querySelector(".rows");
|
|
542
590
|
if (!t) return;
|
|
543
591
|
const r = e === "fade" ? "tbw-group-fade-in" : "tbw-group-slide-in";
|
|
544
|
-
for (const
|
|
545
|
-
const
|
|
546
|
-
|
|
592
|
+
for (const s of t.querySelectorAll(".data-grid-row:not(.group-row)")) {
|
|
593
|
+
const o = s.querySelector(".cell[data-row]"), g = o ? parseInt(o.getAttribute("data-row") ?? "-1", 10) : -1, l = this.flattenedRows[g]?.kind === "data" ? `data-${g}` : void 0;
|
|
594
|
+
l && this.keysToAnimate.has(l) && (s.classList.add(r), s.addEventListener("animationend", () => s.classList.remove(r), { once: !0 }));
|
|
547
595
|
}
|
|
548
596
|
this.keysToAnimate.clear();
|
|
549
597
|
}
|
|
@@ -554,58 +602,73 @@ class I extends x {
|
|
|
554
602
|
*/
|
|
555
603
|
createToggleButton(e, t) {
|
|
556
604
|
const r = document.createElement("button");
|
|
557
|
-
return r.type = "button", r.className = `group-toggle${e ? " expanded" : ""}`, r.setAttribute("aria-label", e ? "Collapse group" : "Expand group"), this.setIcon(r, this.resolveIcon(e ? "collapse" : "expand")), r.addEventListener("click", (
|
|
558
|
-
|
|
605
|
+
return r.type = "button", r.className = `group-toggle${e ? " expanded" : ""}`, r.setAttribute("aria-label", e ? "Collapse group" : "Expand group"), this.setIcon(r, this.resolveIcon(e ? "collapse" : "expand")), r.addEventListener("click", (s) => {
|
|
606
|
+
s.stopPropagation(), t();
|
|
559
607
|
}), r;
|
|
560
608
|
}
|
|
561
609
|
/**
|
|
562
610
|
* Get the formatted label text for a group.
|
|
563
611
|
*/
|
|
564
612
|
getGroupLabelText(e, t, r) {
|
|
565
|
-
const
|
|
566
|
-
return
|
|
613
|
+
const s = this.config;
|
|
614
|
+
return s.formatLabel ? s.formatLabel(e, t, r) : String(e);
|
|
567
615
|
}
|
|
568
616
|
renderFullWidthGroupRow(e, t, r) {
|
|
569
|
-
const
|
|
570
|
-
|
|
571
|
-
const
|
|
572
|
-
if (
|
|
573
|
-
const
|
|
574
|
-
|
|
617
|
+
const s = this.config, o = s.aggregators ?? {}, g = e.__groupRows ?? [], i = document.createElement("div");
|
|
618
|
+
i.className = "cell group-full", i.style.gridColumn = "1 / -1", i.setAttribute("role", "gridcell"), i.setAttribute("data-col", "0"), i.appendChild(this.createToggleButton(e.__groupExpanded, r));
|
|
619
|
+
const l = document.createElement("span");
|
|
620
|
+
if (l.className = "group-label", l.textContent = this.getGroupLabelText(e.__groupValue, e.__groupDepth || 0, e.__groupKey), i.appendChild(l), s.showRowCount !== !1) {
|
|
621
|
+
const u = document.createElement("span");
|
|
622
|
+
u.className = "group-count", u.textContent = `(${e.__groupRowCount ?? e.__groupRows?.length ?? 0})`, i.appendChild(u);
|
|
575
623
|
}
|
|
576
|
-
|
|
624
|
+
const d = Object.entries(o);
|
|
625
|
+
if (d.length > 0) {
|
|
626
|
+
const u = document.createElement("span");
|
|
627
|
+
u.className = "group-aggregates";
|
|
628
|
+
for (const [a, w] of d) {
|
|
629
|
+
const p = this.columns.find((h) => h.field === a), c = _(w, g, a, p);
|
|
630
|
+
if (c != null) {
|
|
631
|
+
const h = document.createElement("span");
|
|
632
|
+
h.className = "group-aggregate", h.setAttribute("data-field", a);
|
|
633
|
+
const f = p?.header ?? a;
|
|
634
|
+
h.textContent = `${f}: ${c}`, u.appendChild(h);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
u.children.length > 0 && i.appendChild(u);
|
|
638
|
+
}
|
|
639
|
+
t.appendChild(i);
|
|
577
640
|
}
|
|
578
641
|
renderPerColumnGroupRow(e, t, r) {
|
|
579
|
-
const
|
|
580
|
-
|
|
581
|
-
let
|
|
582
|
-
|
|
583
|
-
const
|
|
584
|
-
if (
|
|
585
|
-
|
|
642
|
+
const s = this.config, o = s.aggregators ?? {}, g = this.columns, i = e.__groupRows ?? [], d = this.gridElement?.querySelector(".body")?.style.gridTemplateColumns || "";
|
|
643
|
+
d && (t.style.display = "grid", t.style.gridTemplateColumns = d);
|
|
644
|
+
let u = !1;
|
|
645
|
+
g.forEach((a, w) => {
|
|
646
|
+
const p = document.createElement("div");
|
|
647
|
+
if (p.className = "cell group-cell", p.setAttribute("data-col", String(w)), p.setAttribute("role", "gridcell"), A(a)) {
|
|
648
|
+
p.setAttribute("data-field", a.field), t.appendChild(p);
|
|
586
649
|
return;
|
|
587
650
|
}
|
|
588
|
-
if (
|
|
589
|
-
const
|
|
590
|
-
if (
|
|
591
|
-
const
|
|
592
|
-
|
|
651
|
+
if (u) {
|
|
652
|
+
const c = o[a.field];
|
|
653
|
+
if (c) {
|
|
654
|
+
const h = _(c, i, a.field, a);
|
|
655
|
+
p.textContent = h != null ? String(h) : "";
|
|
593
656
|
} else
|
|
594
|
-
|
|
657
|
+
p.textContent = "";
|
|
595
658
|
} else {
|
|
596
|
-
|
|
597
|
-
const
|
|
598
|
-
if (
|
|
599
|
-
const
|
|
600
|
-
|
|
659
|
+
u = !0, p.appendChild(this.createToggleButton(e.__groupExpanded, r));
|
|
660
|
+
const c = document.createElement("span"), h = o[a.field];
|
|
661
|
+
if (h) {
|
|
662
|
+
const f = _(h, i, a.field, a);
|
|
663
|
+
c.textContent = f != null ? String(f) : String(e.__groupValue);
|
|
601
664
|
} else
|
|
602
|
-
|
|
603
|
-
if (
|
|
604
|
-
const
|
|
605
|
-
|
|
665
|
+
c.textContent = this.getGroupLabelText(e.__groupValue, e.__groupDepth || 0, e.__groupKey);
|
|
666
|
+
if (p.appendChild(c), s.showRowCount !== !1) {
|
|
667
|
+
const f = document.createElement("span");
|
|
668
|
+
f.className = "group-count", f.textContent = ` (${i.length})`, p.appendChild(f);
|
|
606
669
|
}
|
|
607
670
|
}
|
|
608
|
-
t.appendChild(
|
|
671
|
+
t.appendChild(p);
|
|
609
672
|
});
|
|
610
673
|
}
|
|
611
674
|
// #endregion
|
|
@@ -614,26 +677,38 @@ class I extends x {
|
|
|
614
677
|
* Expand all groups.
|
|
615
678
|
*/
|
|
616
679
|
expandAll() {
|
|
617
|
-
this.expandedKeys =
|
|
680
|
+
this.expandedKeys = K(this.flattenedRows), this.requestRender();
|
|
618
681
|
}
|
|
619
682
|
/**
|
|
620
683
|
* Collapse all groups.
|
|
621
684
|
*/
|
|
622
685
|
collapseAll() {
|
|
623
|
-
this.expandedKeys =
|
|
686
|
+
this.expandedKeys = k(), this.requestRender();
|
|
624
687
|
}
|
|
625
688
|
/**
|
|
626
689
|
* Toggle expansion of a specific group.
|
|
690
|
+
* In accordion mode, expanding a group will collapse all sibling groups.
|
|
627
691
|
* @param key - The group key to toggle
|
|
628
692
|
*/
|
|
629
693
|
toggle(e) {
|
|
630
|
-
this.expandedKeys =
|
|
631
|
-
|
|
694
|
+
const t = !this.expandedKeys.has(e), r = this.config, s = this.flattenedRows.find((o) => o.kind === "group" && o.key === e);
|
|
695
|
+
if (r.accordion && t && s) {
|
|
696
|
+
const o = /* @__PURE__ */ new Set();
|
|
697
|
+
for (const g of this.expandedKeys)
|
|
698
|
+
if (e.startsWith(g + "||") || g.startsWith(e + "||"))
|
|
699
|
+
e.startsWith(g + "||") && o.add(g);
|
|
700
|
+
else {
|
|
701
|
+
const i = this.flattenedRows.find((l) => l.kind === "group" && l.key === g);
|
|
702
|
+
i && i.depth !== s.depth && o.add(g);
|
|
703
|
+
}
|
|
704
|
+
o.add(e), this.expandedKeys = o;
|
|
705
|
+
} else
|
|
706
|
+
this.expandedKeys = S(this.expandedKeys, e);
|
|
632
707
|
this.emit("group-toggle", {
|
|
633
708
|
key: e,
|
|
634
709
|
expanded: this.expandedKeys.has(e),
|
|
635
|
-
value:
|
|
636
|
-
depth:
|
|
710
|
+
value: s?.value,
|
|
711
|
+
depth: s?.depth ?? 0
|
|
637
712
|
}), this.requestRender();
|
|
638
713
|
}
|
|
639
714
|
/**
|
|
@@ -719,6 +794,6 @@ class I extends x {
|
|
|
719
794
|
// #endregion
|
|
720
795
|
}
|
|
721
796
|
export {
|
|
722
|
-
|
|
797
|
+
D as GroupingRowsPlugin
|
|
723
798
|
};
|
|
724
799
|
//# sourceMappingURL=index.js.map
|