@toolbox-web/grid 1.9.0 → 1.9.2
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 +712 -692
- package/all.js.map +1 -1
- package/index.js +321 -300
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +9 -0
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +11 -0
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +9 -0
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts +3 -0
- package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts.map +1 -1
- package/lib/plugins/column-virtualization/index.js +90 -57
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +9 -0
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/index.js +9 -0
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +38 -29
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +14 -5
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +9 -0
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +63 -54
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +25 -16
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +13 -4
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +13 -4
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +9 -0
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +13 -4
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/print/index.js +9 -0
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +13 -4
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/index.js +42 -33
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js +10 -1
- package/lib/plugins/row-reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +10 -1
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +29 -20
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +20 -11
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +15 -6
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +9 -0
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +14 -14
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +14 -14
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/column-virtualization.umd.js +1 -1
- package/umd/plugins/column-virtualization.umd.js.map +1 -1
- package/umd/plugins/row-reorder.umd.js +1 -1
- package/umd/plugins/row-reorder.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
|
@@ -208,10 +208,19 @@ class C {
|
|
|
208
208
|
}
|
|
209
209
|
/**
|
|
210
210
|
* Request a re-render of the grid.
|
|
211
|
+
* Uses ROWS phase - does NOT trigger processColumns hooks.
|
|
211
212
|
*/
|
|
212
213
|
requestRender() {
|
|
213
214
|
this.grid?.requestRender?.();
|
|
214
215
|
}
|
|
216
|
+
/**
|
|
217
|
+
* Request a columns re-render of the grid.
|
|
218
|
+
* Uses COLUMNS phase - triggers processColumns hooks.
|
|
219
|
+
* Use this when your plugin needs to reprocess column configuration.
|
|
220
|
+
*/
|
|
221
|
+
requestColumnsRender() {
|
|
222
|
+
this.grid?.requestColumnsRender?.();
|
|
223
|
+
}
|
|
215
224
|
/**
|
|
216
225
|
* Request a re-render and restore focus styling afterward.
|
|
217
226
|
* Use this when a plugin action (like expand/collapse) triggers a render
|
|
@@ -375,7 +384,7 @@ function A(n) {
|
|
|
375
384
|
const y = {
|
|
376
385
|
sum: (n, e) => n.reduce((t, r) => t + (Number(r[e]) || 0), 0),
|
|
377
386
|
avg: (n, e) => {
|
|
378
|
-
const t = n.reduce((r,
|
|
387
|
+
const t = n.reduce((r, s) => r + (Number(s[e]) || 0), 0);
|
|
379
388
|
return n.length ? t / n.length : 0;
|
|
380
389
|
},
|
|
381
390
|
count: (n) => n.length,
|
|
@@ -407,8 +416,8 @@ const y = {
|
|
|
407
416
|
* Run an aggregator on a set of rows.
|
|
408
417
|
*/
|
|
409
418
|
run(n, e, t, r) {
|
|
410
|
-
const
|
|
411
|
-
return
|
|
419
|
+
const s = this.get(n);
|
|
420
|
+
return s ? s(e, t, r) : void 0;
|
|
412
421
|
},
|
|
413
422
|
/**
|
|
414
423
|
* Check if an aggregator exists.
|
|
@@ -429,12 +438,12 @@ m.get.bind(m);
|
|
|
429
438
|
const _ = m.run.bind(m);
|
|
430
439
|
m.list.bind(m);
|
|
431
440
|
function v({ rows: n, config: e, expanded: t, initialExpanded: r }) {
|
|
432
|
-
const
|
|
433
|
-
if (typeof
|
|
441
|
+
const s = e.groupOn;
|
|
442
|
+
if (typeof s != "function")
|
|
434
443
|
return [];
|
|
435
444
|
const o = { key: "__root__", value: null, depth: -1, rows: [], children: /* @__PURE__ */ new Map() };
|
|
436
445
|
if (n.forEach((d) => {
|
|
437
|
-
let u =
|
|
446
|
+
let u = s(d);
|
|
438
447
|
u == null || u === !1 ? u = ["__ungrouped__"] : Array.isArray(u) || (u = [u]);
|
|
439
448
|
let a = o;
|
|
440
449
|
u.forEach((w, p) => {
|
|
@@ -444,22 +453,22 @@ function v({ rows: n, config: e, expanded: t, initialExpanded: r }) {
|
|
|
444
453
|
}), a.rows.push(d);
|
|
445
454
|
}), o.children.size === 1 && o.children.has("__ungrouped__") && o.children.get("__ungrouped__").rows.length === n.length)
|
|
446
455
|
return [];
|
|
447
|
-
const g = /* @__PURE__ */ new Set([...t, ...r ?? []]),
|
|
456
|
+
const g = /* @__PURE__ */ new Set([...t, ...r ?? []]), i = [], l = (d) => {
|
|
448
457
|
if (d === o) {
|
|
449
458
|
d.children.forEach((a) => l(a));
|
|
450
459
|
return;
|
|
451
460
|
}
|
|
452
461
|
const u = g.has(d.key);
|
|
453
|
-
|
|
462
|
+
i.push({
|
|
454
463
|
kind: "group",
|
|
455
464
|
key: d.key,
|
|
456
465
|
value: d.value,
|
|
457
466
|
depth: d.depth,
|
|
458
467
|
rows: d.rows,
|
|
459
468
|
expanded: u
|
|
460
|
-
}), u && (d.children.size ? d.children.forEach((a) => l(a)) : d.rows.forEach((a) =>
|
|
469
|
+
}), u && (d.children.size ? d.children.forEach((a) => l(a)) : d.rows.forEach((a) => i.push({ kind: "data", row: a, rowIndex: n.indexOf(a) })));
|
|
461
470
|
};
|
|
462
|
-
return l(o),
|
|
471
|
+
return l(o), i;
|
|
463
472
|
}
|
|
464
473
|
function K(n, e) {
|
|
465
474
|
const t = new Set(n);
|
|
@@ -591,33 +600,33 @@ class D extends C {
|
|
|
591
600
|
});
|
|
592
601
|
if (r.length === 0)
|
|
593
602
|
return this.isActive = !1, this.flattenedRows = [], [...e];
|
|
594
|
-
let
|
|
603
|
+
let s;
|
|
595
604
|
if (!this.hasAppliedDefaultExpanded && this.expandedKeys.size === 0 && t.defaultExpanded !== !1) {
|
|
596
|
-
const
|
|
597
|
-
|
|
605
|
+
const i = T(r);
|
|
606
|
+
s = G(t.defaultExpanded ?? !1, i), s.size > 0 && (this.expandedKeys = new Set(s), this.hasAppliedDefaultExpanded = !0);
|
|
598
607
|
}
|
|
599
608
|
const o = v({
|
|
600
609
|
rows: [...e],
|
|
601
610
|
config: t,
|
|
602
611
|
expanded: this.expandedKeys,
|
|
603
|
-
initialExpanded:
|
|
612
|
+
initialExpanded: s
|
|
604
613
|
});
|
|
605
614
|
this.isActive = !0, this.flattenedRows = o, this.keysToAnimate.clear();
|
|
606
615
|
const g = /* @__PURE__ */ new Set();
|
|
607
|
-
return o.forEach((
|
|
608
|
-
if (
|
|
616
|
+
return o.forEach((i, l) => {
|
|
617
|
+
if (i.kind === "data") {
|
|
609
618
|
const d = `data-${l}`;
|
|
610
619
|
g.add(d), this.previousVisibleKeys.has(d) || this.keysToAnimate.add(d);
|
|
611
620
|
}
|
|
612
|
-
}), this.previousVisibleKeys = g, o.map((
|
|
621
|
+
}), this.previousVisibleKeys = g, o.map((i) => i.kind === "group" ? {
|
|
613
622
|
__isGroupRow: !0,
|
|
614
|
-
__groupKey:
|
|
615
|
-
__groupValue:
|
|
616
|
-
__groupDepth:
|
|
617
|
-
__groupRows:
|
|
618
|
-
__groupExpanded:
|
|
619
|
-
__groupRowCount: I(
|
|
620
|
-
} :
|
|
623
|
+
__groupKey: i.key,
|
|
624
|
+
__groupValue: i.value,
|
|
625
|
+
__groupDepth: i.depth,
|
|
626
|
+
__groupRows: i.rows,
|
|
627
|
+
__groupExpanded: i.expanded,
|
|
628
|
+
__groupRowCount: I(i)
|
|
629
|
+
} : i.row);
|
|
621
630
|
}
|
|
622
631
|
/** @internal */
|
|
623
632
|
onCellClick(e) {
|
|
@@ -639,17 +648,17 @@ class D extends C {
|
|
|
639
648
|
renderRow(e, t, r) {
|
|
640
649
|
if (!e?.__isGroupRow)
|
|
641
650
|
return !1;
|
|
642
|
-
const
|
|
643
|
-
if (
|
|
644
|
-
const
|
|
651
|
+
const s = this.config;
|
|
652
|
+
if (s.groupRowRenderer) {
|
|
653
|
+
const i = () => {
|
|
645
654
|
this.toggle(e.__groupKey);
|
|
646
|
-
}, l =
|
|
655
|
+
}, l = s.groupRowRenderer({
|
|
647
656
|
key: e.__groupKey,
|
|
648
657
|
value: e.__groupValue,
|
|
649
658
|
depth: e.__groupDepth,
|
|
650
659
|
rows: e.__groupRows,
|
|
651
660
|
expanded: e.__groupExpanded,
|
|
652
|
-
toggleExpand:
|
|
661
|
+
toggleExpand: i
|
|
653
662
|
});
|
|
654
663
|
if (l)
|
|
655
664
|
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;
|
|
@@ -657,7 +666,7 @@ class D extends C {
|
|
|
657
666
|
const o = () => {
|
|
658
667
|
this.toggle(e.__groupKey);
|
|
659
668
|
};
|
|
660
|
-
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)),
|
|
669
|
+
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;
|
|
661
670
|
}
|
|
662
671
|
/** @internal */
|
|
663
672
|
afterRender() {
|
|
@@ -666,9 +675,9 @@ class D extends C {
|
|
|
666
675
|
const t = this.gridElement?.querySelector(".rows");
|
|
667
676
|
if (!t) return;
|
|
668
677
|
const r = e === "fade" ? "tbw-group-fade-in" : "tbw-group-slide-in";
|
|
669
|
-
for (const
|
|
670
|
-
const o =
|
|
671
|
-
l && this.keysToAnimate.has(l) && (
|
|
678
|
+
for (const s of t.querySelectorAll(".data-grid-row:not(.group-row)")) {
|
|
679
|
+
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;
|
|
680
|
+
l && this.keysToAnimate.has(l) && (s.classList.add(r), s.addEventListener("animationend", () => s.classList.remove(r), { once: !0 }));
|
|
672
681
|
}
|
|
673
682
|
this.keysToAnimate.clear();
|
|
674
683
|
}
|
|
@@ -679,24 +688,24 @@ class D extends C {
|
|
|
679
688
|
*/
|
|
680
689
|
createToggleButton(e, t) {
|
|
681
690
|
const r = document.createElement("button");
|
|
682
|
-
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", (
|
|
683
|
-
|
|
691
|
+
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) => {
|
|
692
|
+
s.stopPropagation(), t();
|
|
684
693
|
}), r;
|
|
685
694
|
}
|
|
686
695
|
/**
|
|
687
696
|
* Get the formatted label text for a group.
|
|
688
697
|
*/
|
|
689
698
|
getGroupLabelText(e, t, r) {
|
|
690
|
-
const
|
|
691
|
-
return
|
|
699
|
+
const s = this.config;
|
|
700
|
+
return s.formatLabel ? s.formatLabel(e, t, r) : String(e);
|
|
692
701
|
}
|
|
693
702
|
renderFullWidthGroupRow(e, t, r) {
|
|
694
|
-
const
|
|
695
|
-
|
|
703
|
+
const s = this.config, o = s.aggregators ?? {}, g = e.__groupRows ?? [], i = document.createElement("div");
|
|
704
|
+
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));
|
|
696
705
|
const l = document.createElement("span");
|
|
697
|
-
if (l.className = "group-label", l.textContent = this.getGroupLabelText(e.__groupValue, e.__groupDepth || 0, e.__groupKey),
|
|
706
|
+
if (l.className = "group-label", l.textContent = this.getGroupLabelText(e.__groupValue, e.__groupDepth || 0, e.__groupKey), i.appendChild(l), s.showRowCount !== !1) {
|
|
698
707
|
const u = document.createElement("span");
|
|
699
|
-
u.className = "group-count", u.textContent = `(${e.__groupRowCount ?? e.__groupRows?.length ?? 0})`,
|
|
708
|
+
u.className = "group-count", u.textContent = `(${e.__groupRowCount ?? e.__groupRows?.length ?? 0})`, i.appendChild(u);
|
|
700
709
|
}
|
|
701
710
|
const d = Object.entries(o);
|
|
702
711
|
if (d.length > 0) {
|
|
@@ -711,12 +720,12 @@ class D extends C {
|
|
|
711
720
|
h.textContent = `${f}: ${c}`, u.appendChild(h);
|
|
712
721
|
}
|
|
713
722
|
}
|
|
714
|
-
u.children.length > 0 &&
|
|
723
|
+
u.children.length > 0 && i.appendChild(u);
|
|
715
724
|
}
|
|
716
|
-
t.appendChild(
|
|
725
|
+
t.appendChild(i);
|
|
717
726
|
}
|
|
718
727
|
renderPerColumnGroupRow(e, t, r) {
|
|
719
|
-
const
|
|
728
|
+
const s = this.config, o = s.aggregators ?? {}, g = this.columns, i = e.__groupRows ?? [], d = this.gridElement?.querySelector(".body")?.style.gridTemplateColumns || "";
|
|
720
729
|
d && (t.style.display = "grid", t.style.gridTemplateColumns = d);
|
|
721
730
|
let u = !1;
|
|
722
731
|
g.forEach((a, w) => {
|
|
@@ -728,7 +737,7 @@ class D extends C {
|
|
|
728
737
|
if (u) {
|
|
729
738
|
const c = o[a.field];
|
|
730
739
|
if (c) {
|
|
731
|
-
const h = _(c,
|
|
740
|
+
const h = _(c, i, a.field, a);
|
|
732
741
|
p.textContent = h != null ? String(h) : "";
|
|
733
742
|
} else
|
|
734
743
|
p.textContent = "";
|
|
@@ -736,13 +745,13 @@ class D extends C {
|
|
|
736
745
|
u = !0, p.appendChild(this.createToggleButton(e.__groupExpanded, r));
|
|
737
746
|
const c = document.createElement("span"), h = o[a.field];
|
|
738
747
|
if (h) {
|
|
739
|
-
const f = _(h,
|
|
748
|
+
const f = _(h, i, a.field, a);
|
|
740
749
|
c.textContent = f != null ? String(f) : String(e.__groupValue);
|
|
741
750
|
} else
|
|
742
751
|
c.textContent = this.getGroupLabelText(e.__groupValue, e.__groupDepth || 0, e.__groupKey);
|
|
743
|
-
if (p.appendChild(c),
|
|
752
|
+
if (p.appendChild(c), s.showRowCount !== !1) {
|
|
744
753
|
const f = document.createElement("span");
|
|
745
|
-
f.className = "group-count", f.textContent = ` (${
|
|
754
|
+
f.className = "group-count", f.textContent = ` (${i.length})`, p.appendChild(f);
|
|
746
755
|
}
|
|
747
756
|
}
|
|
748
757
|
t.appendChild(p);
|
|
@@ -768,15 +777,15 @@ class D extends C {
|
|
|
768
777
|
* @param key - The group key to toggle
|
|
769
778
|
*/
|
|
770
779
|
toggle(e) {
|
|
771
|
-
const t = !this.expandedKeys.has(e), r = this.config,
|
|
772
|
-
if (r.accordion && t &&
|
|
780
|
+
const t = !this.expandedKeys.has(e), r = this.config, s = this.flattenedRows.find((o) => o.kind === "group" && o.key === e);
|
|
781
|
+
if (r.accordion && t && s) {
|
|
773
782
|
const o = /* @__PURE__ */ new Set();
|
|
774
783
|
for (const g of this.expandedKeys)
|
|
775
784
|
if (e.startsWith(g + "||") || g.startsWith(e + "||"))
|
|
776
785
|
e.startsWith(g + "||") && o.add(g);
|
|
777
786
|
else {
|
|
778
|
-
const
|
|
779
|
-
|
|
787
|
+
const i = this.flattenedRows.find((l) => l.kind === "group" && l.key === g);
|
|
788
|
+
i && i.depth !== s.depth && o.add(g);
|
|
780
789
|
}
|
|
781
790
|
o.add(e), this.expandedKeys = o;
|
|
782
791
|
} else
|
|
@@ -784,8 +793,8 @@ class D extends C {
|
|
|
784
793
|
this.emit("group-toggle", {
|
|
785
794
|
key: e,
|
|
786
795
|
expanded: this.expandedKeys.has(e),
|
|
787
|
-
value:
|
|
788
|
-
depth:
|
|
796
|
+
value: s?.value,
|
|
797
|
+
depth: s?.depth ?? 0
|
|
789
798
|
}), this.emitPluginEvent("grouping-state-change", {
|
|
790
799
|
expandedKeys: [...this.expandedKeys]
|
|
791
800
|
}), this.requestRender();
|