@toolbox-web/grid 1.4.0 → 1.6.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.js +859 -671
- package/all.js.map +1 -1
- package/index.js +513 -495
- package/index.js.map +1 -1
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/internal/rows.d.ts +8 -0
- package/lib/core/internal/rows.d.ts.map +1 -1
- package/lib/core/types.d.ts +82 -17
- package/lib/core/types.d.ts.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/editing/index.js.map +1 -1
- package/lib/plugins/editing/types.d.ts +68 -0
- package/lib/plugins/editing/types.d.ts.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.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +18 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts.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 +313 -183
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/filtering/types.d.ts +81 -2
- package/lib/plugins/filtering/types.d.ts.map +1 -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 +199 -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.map +1 -1
- 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 +1 -1
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts +5 -0
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +90 -77
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/selection/types.d.ts +45 -0
- package/lib/plugins/selection/types.d.ts.map +1 -1
- package/lib/plugins/server-side/index.js.map +1 -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.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.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +27 -24
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +10 -10
- 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 +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/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,11 +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
12
|
print: "🖨️"
|
|
13
13
|
};
|
|
14
|
-
class
|
|
14
|
+
class C {
|
|
15
15
|
/**
|
|
16
16
|
* Plugin dependencies - declare other plugins this one requires.
|
|
17
17
|
*
|
|
@@ -311,14 +311,14 @@ class x {
|
|
|
311
311
|
}
|
|
312
312
|
// #endregion
|
|
313
313
|
}
|
|
314
|
-
const
|
|
314
|
+
const E = "__tbw_expander";
|
|
315
315
|
function A(n) {
|
|
316
|
-
return n.field ===
|
|
316
|
+
return n.field === E;
|
|
317
317
|
}
|
|
318
|
-
const
|
|
318
|
+
const y = {
|
|
319
319
|
sum: (n, e) => n.reduce((t, r) => t + (Number(r[e]) || 0), 0),
|
|
320
320
|
avg: (n, e) => {
|
|
321
|
-
const t = n.reduce((r,
|
|
321
|
+
const t = n.reduce((r, s) => r + (Number(s[e]) || 0), 0);
|
|
322
322
|
return n.length ? t / n.length : 0;
|
|
323
323
|
},
|
|
324
324
|
count: (n) => n.length,
|
|
@@ -326,106 +326,138 @@ const _ = {
|
|
|
326
326
|
max: (n, e) => Math.max(...n.map((t) => Number(t[e]) || -1 / 0)),
|
|
327
327
|
first: (n, e) => n[0]?.[e],
|
|
328
328
|
last: (n, e) => n[n.length - 1]?.[e]
|
|
329
|
-
},
|
|
329
|
+
}, b = /* @__PURE__ */ new Map(), m = {
|
|
330
330
|
/**
|
|
331
331
|
* Register a custom aggregator function.
|
|
332
332
|
*/
|
|
333
333
|
register(n, e) {
|
|
334
|
-
|
|
334
|
+
b.set(n, e);
|
|
335
335
|
},
|
|
336
336
|
/**
|
|
337
337
|
* Unregister a custom aggregator function.
|
|
338
338
|
*/
|
|
339
339
|
unregister(n) {
|
|
340
|
-
|
|
340
|
+
b.delete(n);
|
|
341
341
|
},
|
|
342
342
|
/**
|
|
343
343
|
* Get an aggregator function by reference.
|
|
344
344
|
*/
|
|
345
345
|
get(n) {
|
|
346
346
|
if (n !== void 0)
|
|
347
|
-
return typeof n == "function" ? n :
|
|
347
|
+
return typeof n == "function" ? n : b.get(n) ?? y[n];
|
|
348
348
|
},
|
|
349
349
|
/**
|
|
350
350
|
* Run an aggregator on a set of rows.
|
|
351
351
|
*/
|
|
352
352
|
run(n, e, t, r) {
|
|
353
|
-
const
|
|
354
|
-
return
|
|
353
|
+
const s = this.get(n);
|
|
354
|
+
return s ? s(e, t, r) : void 0;
|
|
355
355
|
},
|
|
356
356
|
/**
|
|
357
357
|
* Check if an aggregator exists.
|
|
358
358
|
*/
|
|
359
359
|
has(n) {
|
|
360
|
-
return
|
|
360
|
+
return b.has(n) || n in y;
|
|
361
361
|
},
|
|
362
362
|
/**
|
|
363
363
|
* List all available aggregator names.
|
|
364
364
|
*/
|
|
365
365
|
list() {
|
|
366
|
-
return [...Object.keys(
|
|
366
|
+
return [...Object.keys(y), ...b.keys()];
|
|
367
367
|
}
|
|
368
368
|
};
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
const
|
|
373
|
-
|
|
374
|
-
function
|
|
375
|
-
const
|
|
376
|
-
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")
|
|
377
377
|
return [];
|
|
378
|
-
const
|
|
379
|
-
if (n.forEach((
|
|
380
|
-
let
|
|
381
|
-
|
|
382
|
-
let
|
|
383
|
-
|
|
384
|
-
const
|
|
385
|
-
let
|
|
386
|
-
|
|
387
|
-
}),
|
|
388
|
-
}),
|
|
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)
|
|
389
389
|
return [];
|
|
390
|
-
const
|
|
391
|
-
if (
|
|
392
|
-
|
|
390
|
+
const g = /* @__PURE__ */ new Set([...t, ...r ?? []]), i = [], l = (d) => {
|
|
391
|
+
if (d === o) {
|
|
392
|
+
d.children.forEach((a) => l(a));
|
|
393
393
|
return;
|
|
394
394
|
}
|
|
395
|
-
const
|
|
396
|
-
|
|
395
|
+
const u = g.has(d.key);
|
|
396
|
+
i.push({
|
|
397
397
|
kind: "group",
|
|
398
|
-
key:
|
|
399
|
-
value:
|
|
400
|
-
depth:
|
|
401
|
-
rows:
|
|
402
|
-
expanded:
|
|
403
|
-
}),
|
|
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) })));
|
|
404
404
|
};
|
|
405
|
-
return
|
|
405
|
+
return l(o), i;
|
|
406
406
|
}
|
|
407
|
-
function
|
|
407
|
+
function S(n, e) {
|
|
408
408
|
const t = new Set(n);
|
|
409
409
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
410
410
|
}
|
|
411
|
-
function
|
|
411
|
+
function K(n) {
|
|
412
412
|
const e = /* @__PURE__ */ new Set();
|
|
413
413
|
for (const t of n)
|
|
414
414
|
t.kind === "group" && e.add(t.key);
|
|
415
415
|
return e;
|
|
416
416
|
}
|
|
417
|
-
function
|
|
417
|
+
function k() {
|
|
418
418
|
return /* @__PURE__ */ new Set();
|
|
419
419
|
}
|
|
420
|
-
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) {
|
|
421
435
|
return n.kind !== "group" ? 0 : n.rows.length;
|
|
422
436
|
}
|
|
423
|
-
const
|
|
424
|
-
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
|
+
};
|
|
425
457
|
/** @internal */
|
|
426
458
|
name = "groupingRows";
|
|
427
459
|
/** @internal */
|
|
428
|
-
styles =
|
|
460
|
+
styles = N;
|
|
429
461
|
/** @internal */
|
|
430
462
|
get defaultConfig() {
|
|
431
463
|
return {
|
|
@@ -433,7 +465,8 @@ class I extends x {
|
|
|
433
465
|
showRowCount: !0,
|
|
434
466
|
indentWidth: 20,
|
|
435
467
|
aggregators: {},
|
|
436
|
-
animation: "slide"
|
|
468
|
+
animation: "slide",
|
|
469
|
+
accordion: !1
|
|
437
470
|
};
|
|
438
471
|
}
|
|
439
472
|
// #region Internal State
|
|
@@ -442,6 +475,8 @@ class I extends x {
|
|
|
442
475
|
isActive = !1;
|
|
443
476
|
previousVisibleKeys = /* @__PURE__ */ new Set();
|
|
444
477
|
keysToAnimate = /* @__PURE__ */ new Set();
|
|
478
|
+
/** Track if initial defaultExpanded has been applied */
|
|
479
|
+
hasAppliedDefaultExpanded = !1;
|
|
445
480
|
// #endregion
|
|
446
481
|
// #region Animation
|
|
447
482
|
/**
|
|
@@ -455,7 +490,7 @@ class I extends x {
|
|
|
455
490
|
// #region Lifecycle
|
|
456
491
|
/** @internal */
|
|
457
492
|
detach() {
|
|
458
|
-
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;
|
|
459
494
|
}
|
|
460
495
|
// #endregion
|
|
461
496
|
// #region Hooks
|
|
@@ -471,29 +506,41 @@ class I extends x {
|
|
|
471
506
|
const t = this.config;
|
|
472
507
|
if (typeof t.groupOn != "function")
|
|
473
508
|
return this.isActive = !1, this.flattenedRows = [], [...e];
|
|
474
|
-
const r =
|
|
509
|
+
const r = v({
|
|
475
510
|
rows: [...e],
|
|
476
511
|
config: t,
|
|
477
|
-
expanded:
|
|
512
|
+
expanded: /* @__PURE__ */ new Set()
|
|
513
|
+
// Empty to get all root groups
|
|
478
514
|
});
|
|
479
515
|
if (r.length === 0)
|
|
480
516
|
return this.isActive = !1, this.flattenedRows = [], [...e];
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
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);
|
|
487
534
|
}
|
|
488
|
-
}), this.previousVisibleKeys =
|
|
535
|
+
}), this.previousVisibleKeys = g, o.map((i) => i.kind === "group" ? {
|
|
489
536
|
__isGroupRow: !0,
|
|
490
|
-
__groupKey:
|
|
491
|
-
__groupValue:
|
|
492
|
-
__groupDepth:
|
|
493
|
-
__groupRows:
|
|
494
|
-
__groupExpanded:
|
|
495
|
-
__groupRowCount:
|
|
496
|
-
} :
|
|
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);
|
|
497
544
|
}
|
|
498
545
|
/** @internal */
|
|
499
546
|
onCellClick(e) {
|
|
@@ -515,25 +562,25 @@ class I extends x {
|
|
|
515
562
|
renderRow(e, t, r) {
|
|
516
563
|
if (!e?.__isGroupRow)
|
|
517
564
|
return !1;
|
|
518
|
-
const
|
|
519
|
-
if (
|
|
520
|
-
const
|
|
565
|
+
const s = this.config;
|
|
566
|
+
if (s.groupRowRenderer) {
|
|
567
|
+
const i = () => {
|
|
521
568
|
this.toggle(e.__groupKey);
|
|
522
|
-
},
|
|
569
|
+
}, l = s.groupRowRenderer({
|
|
523
570
|
key: e.__groupKey,
|
|
524
571
|
value: e.__groupValue,
|
|
525
572
|
depth: e.__groupDepth,
|
|
526
573
|
rows: e.__groupRows,
|
|
527
574
|
expanded: e.__groupExpanded,
|
|
528
|
-
toggleExpand:
|
|
575
|
+
toggleExpand: i
|
|
529
576
|
});
|
|
530
|
-
if (
|
|
531
|
-
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;
|
|
532
579
|
}
|
|
533
|
-
const
|
|
580
|
+
const o = () => {
|
|
534
581
|
this.toggle(e.__groupKey);
|
|
535
582
|
};
|
|
536
|
-
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;
|
|
537
584
|
}
|
|
538
585
|
/** @internal */
|
|
539
586
|
afterRender() {
|
|
@@ -542,9 +589,9 @@ class I extends x {
|
|
|
542
589
|
const t = this.gridElement?.querySelector(".rows");
|
|
543
590
|
if (!t) return;
|
|
544
591
|
const r = e === "fade" ? "tbw-group-fade-in" : "tbw-group-slide-in";
|
|
545
|
-
for (const
|
|
546
|
-
const
|
|
547
|
-
|
|
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 }));
|
|
548
595
|
}
|
|
549
596
|
this.keysToAnimate.clear();
|
|
550
597
|
}
|
|
@@ -555,58 +602,73 @@ class I extends x {
|
|
|
555
602
|
*/
|
|
556
603
|
createToggleButton(e, t) {
|
|
557
604
|
const r = document.createElement("button");
|
|
558
|
-
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", (
|
|
559
|
-
|
|
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();
|
|
560
607
|
}), r;
|
|
561
608
|
}
|
|
562
609
|
/**
|
|
563
610
|
* Get the formatted label text for a group.
|
|
564
611
|
*/
|
|
565
612
|
getGroupLabelText(e, t, r) {
|
|
566
|
-
const
|
|
567
|
-
return
|
|
613
|
+
const s = this.config;
|
|
614
|
+
return s.formatLabel ? s.formatLabel(e, t, r) : String(e);
|
|
568
615
|
}
|
|
569
616
|
renderFullWidthGroupRow(e, t, r) {
|
|
570
|
-
const
|
|
571
|
-
|
|
572
|
-
const
|
|
573
|
-
if (
|
|
574
|
-
const
|
|
575
|
-
|
|
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);
|
|
576
623
|
}
|
|
577
|
-
|
|
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);
|
|
578
640
|
}
|
|
579
641
|
renderPerColumnGroupRow(e, t, r) {
|
|
580
|
-
const
|
|
581
|
-
|
|
582
|
-
let
|
|
583
|
-
|
|
584
|
-
const
|
|
585
|
-
if (
|
|
586
|
-
|
|
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);
|
|
587
649
|
return;
|
|
588
650
|
}
|
|
589
|
-
if (
|
|
590
|
-
const
|
|
591
|
-
if (
|
|
592
|
-
const
|
|
593
|
-
|
|
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) : "";
|
|
594
656
|
} else
|
|
595
|
-
|
|
657
|
+
p.textContent = "";
|
|
596
658
|
} else {
|
|
597
|
-
|
|
598
|
-
const
|
|
599
|
-
if (
|
|
600
|
-
const
|
|
601
|
-
|
|
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);
|
|
602
664
|
} else
|
|
603
|
-
|
|
604
|
-
if (
|
|
605
|
-
const
|
|
606
|
-
|
|
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);
|
|
607
669
|
}
|
|
608
670
|
}
|
|
609
|
-
t.appendChild(
|
|
671
|
+
t.appendChild(p);
|
|
610
672
|
});
|
|
611
673
|
}
|
|
612
674
|
// #endregion
|
|
@@ -615,26 +677,38 @@ class I extends x {
|
|
|
615
677
|
* Expand all groups.
|
|
616
678
|
*/
|
|
617
679
|
expandAll() {
|
|
618
|
-
this.expandedKeys =
|
|
680
|
+
this.expandedKeys = K(this.flattenedRows), this.requestRender();
|
|
619
681
|
}
|
|
620
682
|
/**
|
|
621
683
|
* Collapse all groups.
|
|
622
684
|
*/
|
|
623
685
|
collapseAll() {
|
|
624
|
-
this.expandedKeys =
|
|
686
|
+
this.expandedKeys = k(), this.requestRender();
|
|
625
687
|
}
|
|
626
688
|
/**
|
|
627
689
|
* Toggle expansion of a specific group.
|
|
690
|
+
* In accordion mode, expanding a group will collapse all sibling groups.
|
|
628
691
|
* @param key - The group key to toggle
|
|
629
692
|
*/
|
|
630
693
|
toggle(e) {
|
|
631
|
-
this.expandedKeys =
|
|
632
|
-
|
|
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);
|
|
633
707
|
this.emit("group-toggle", {
|
|
634
708
|
key: e,
|
|
635
709
|
expanded: this.expandedKeys.has(e),
|
|
636
|
-
value:
|
|
637
|
-
depth:
|
|
710
|
+
value: s?.value,
|
|
711
|
+
depth: s?.depth ?? 0
|
|
638
712
|
}), this.requestRender();
|
|
639
713
|
}
|
|
640
714
|
/**
|
|
@@ -720,6 +794,6 @@ class I extends x {
|
|
|
720
794
|
// #endregion
|
|
721
795
|
}
|
|
722
796
|
export {
|
|
723
|
-
|
|
797
|
+
D as GroupingRowsPlugin
|
|
724
798
|
};
|
|
725
799
|
//# sourceMappingURL=index.js.map
|