@toolbox-web/grid 1.16.1 → 1.18.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/README.md +126 -41
- package/all.js +1046 -936
- package/all.js.map +1 -1
- package/index.js +394 -369
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +13 -3
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/internal/keyboard.d.ts.map +1 -1
- package/lib/core/internal/shell.d.ts +11 -0
- package/lib/core/internal/shell.d.ts.map +1 -1
- package/lib/core/plugin/types.d.ts +1 -0
- package/lib/core/plugin/types.d.ts.map +1 -1
- package/lib/core/types.d.ts +42 -2
- 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/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +155 -145
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +31 -0
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/filter-model.d.ts +30 -3
- package/lib/plugins/filtering/filter-model.d.ts.map +1 -1
- package/lib/plugins/filtering/index.d.ts +1 -0
- package/lib/plugins/filtering/index.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +471 -361
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/filtering/types.d.ts +32 -0
- 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/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts +4 -0
- package/lib/plugins/multi-sort/MultiSortPlugin.d.ts.map +1 -1
- package/lib/plugins/multi-sort/index.js +57 -47
- 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.map +1 -1
- package/lib/plugins/print/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +81 -78
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/index.js +58 -55
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js +5 -2
- package/lib/plugins/row-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.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 +29 -29
- 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/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/multi-sort.umd.js +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
|
@@ -44,36 +44,36 @@ function H(r) {
|
|
|
44
44
|
t.push(i);
|
|
45
45
|
continue;
|
|
46
46
|
}
|
|
47
|
-
const
|
|
47
|
+
const l = [];
|
|
48
48
|
for (const s of i.attributes) {
|
|
49
49
|
const o = s.name.toLowerCase();
|
|
50
50
|
if (v.test(o)) {
|
|
51
|
-
|
|
51
|
+
l.push(s.name);
|
|
52
52
|
continue;
|
|
53
53
|
}
|
|
54
54
|
if (A.has(o) && S.test(s.value)) {
|
|
55
|
-
|
|
55
|
+
l.push(s.name);
|
|
56
56
|
continue;
|
|
57
57
|
}
|
|
58
58
|
if (o === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(s.value)) {
|
|
59
|
-
|
|
59
|
+
l.push(s.name);
|
|
60
60
|
continue;
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
|
|
63
|
+
l.forEach((s) => i.removeAttribute(s));
|
|
64
64
|
}
|
|
65
65
|
t.forEach((i) => i.remove());
|
|
66
66
|
}
|
|
67
67
|
function T(r, t) {
|
|
68
68
|
if (!r || r.indexOf("{{") === -1) return r;
|
|
69
69
|
const e = [], i = r.replace(y, (o, c) => {
|
|
70
|
-
const
|
|
71
|
-
return e.push({ expr: c.trim(), result:
|
|
72
|
-
}), n = x(i),
|
|
73
|
-
return
|
|
70
|
+
const a = L(c, t);
|
|
71
|
+
return e.push({ expr: c.trim(), result: a }), a;
|
|
72
|
+
}), n = x(i), l = e.length && e.every((o) => o.result === "" || o.result === u);
|
|
73
|
+
return w.test(r) || l ? "" : n;
|
|
74
74
|
}
|
|
75
75
|
function L(r, t) {
|
|
76
|
-
if (r = (r || "").trim(), !r ||
|
|
76
|
+
if (r = (r || "").trim(), !r || w.test(r)) return u;
|
|
77
77
|
if (r === "value") return t.value == null ? u : String(t.value);
|
|
78
78
|
if (r.startsWith("row.") && !/[()?]/.test(r) && !r.includes(":")) {
|
|
79
79
|
const i = r.slice(4), n = t.row ? t.row[i] : void 0;
|
|
@@ -83,13 +83,13 @@ function L(r, t) {
|
|
|
83
83
|
const e = r.match(/\./g);
|
|
84
84
|
if (e && e.length > 1) return u;
|
|
85
85
|
try {
|
|
86
|
-
const n = new Function("value", "row", `return (${r});`)(t.value, t.row),
|
|
87
|
-
return
|
|
86
|
+
const n = new Function("value", "row", `return (${r});`)(t.value, t.row), l = n == null ? "" : String(n);
|
|
87
|
+
return w.test(l) ? u : l || u;
|
|
88
88
|
} catch {
|
|
89
89
|
return u;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
const
|
|
92
|
+
const w = /Reflect|Proxy|ownKeys/;
|
|
93
93
|
function x(r) {
|
|
94
94
|
return r && r.replace(new RegExp(u, "g"), "").replace(/Reflect\.[^<>{}\s]+|\bProxy\b|ownKeys\([^)]*\)/g, "");
|
|
95
95
|
}
|
|
@@ -102,43 +102,46 @@ const N = document.createElement("template");
|
|
|
102
102
|
N.innerHTML = '<div class="data-grid-row" role="row" part="row"></div>';
|
|
103
103
|
function g(r, t) {
|
|
104
104
|
if (r._virtualization?.enabled) {
|
|
105
|
-
const { rowHeight: s, container: o, viewportEl: c } = r._virtualization,
|
|
106
|
-
if (
|
|
105
|
+
const { rowHeight: s, container: o, viewportEl: c } = r._virtualization, a = o, h = c?.clientHeight ?? a?.clientHeight ?? 0;
|
|
106
|
+
if (a && h > 0) {
|
|
107
107
|
const d = r._focusRow * s;
|
|
108
|
-
d <
|
|
108
|
+
d < a.scrollTop ? a.scrollTop = d : d + s > a.scrollTop + h && (a.scrollTop = d - h + s);
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
const e = r._activeEditRows !== void 0 && r._activeEditRows !== -1;
|
|
112
112
|
e || r.refreshVirtualWindow(!1), M(r._bodyEl), Array.from(r._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((s) => {
|
|
113
113
|
s.setAttribute("aria-selected", "false");
|
|
114
114
|
});
|
|
115
|
-
const i = r._focusRow, n = r._virtualization.start ?? 0,
|
|
116
|
-
if (i >= n && i <
|
|
115
|
+
const i = r._focusRow, n = r._virtualization.start ?? 0, l = r._virtualization.end ?? r._rows.length;
|
|
116
|
+
if (i >= n && i < l) {
|
|
117
117
|
const s = r._bodyEl.querySelectorAll(".data-grid-row")[i - n];
|
|
118
118
|
let o = s?.children[r._focusCol];
|
|
119
119
|
if ((!o || !o.classList?.contains("cell")) && (o = s?.querySelector(`.cell[data-col="${r._focusCol}"]`) ?? s?.querySelector(".cell[data-col]")), o) {
|
|
120
120
|
o.classList.add("cell-focus"), o.setAttribute("aria-selected", "true");
|
|
121
121
|
const c = r.querySelector(".tbw-scroll-area");
|
|
122
122
|
if (c && o && (!e || t?.forceHorizontalScroll)) {
|
|
123
|
-
const
|
|
124
|
-
if (!
|
|
125
|
-
const h = o.getBoundingClientRect(), d = c.getBoundingClientRect(), f = h.left - d.left + c.scrollLeft,
|
|
126
|
-
f < p ? c.scrollLeft = f -
|
|
123
|
+
const a = r._getHorizontalScrollOffsets?.(s ?? void 0, o) ?? { left: 0, right: 0 };
|
|
124
|
+
if (!a.skipScroll) {
|
|
125
|
+
const h = o.getBoundingClientRect(), d = c.getBoundingClientRect(), f = h.left - d.left + c.scrollLeft, m = f + h.width, p = c.scrollLeft + a.left, R = c.scrollLeft + c.clientWidth - a.right;
|
|
126
|
+
f < p ? c.scrollLeft = f - a.left : m > R && (c.scrollLeft = m - c.clientWidth + a.right);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
if (
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
129
|
+
if (e && o.classList.contains("editing")) {
|
|
130
|
+
const a = o.querySelector(D);
|
|
131
|
+
if (a && document.activeElement !== a)
|
|
132
132
|
try {
|
|
133
|
-
|
|
133
|
+
a.focus({ preventScroll: !0 });
|
|
134
134
|
} catch {
|
|
135
135
|
}
|
|
136
|
-
} else if (!o.contains(document.activeElement)) {
|
|
136
|
+
} else if (e && !o.contains(document.activeElement)) {
|
|
137
137
|
o.hasAttribute("tabindex") || o.setAttribute("tabindex", "-1");
|
|
138
138
|
try {
|
|
139
139
|
o.focus({ preventScroll: !0 });
|
|
140
140
|
} catch {
|
|
141
141
|
}
|
|
142
|
+
} else if (!e) {
|
|
143
|
+
const a = r;
|
|
144
|
+
document.activeElement !== a && a.focus({ preventScroll: !0 });
|
|
142
145
|
}
|
|
143
146
|
}
|
|
144
147
|
}
|
|
@@ -646,20 +649,20 @@ class G extends z {
|
|
|
646
649
|
const d = i.__frameworkAdapter.parseResponsiveCardElement(e);
|
|
647
650
|
d && (this.config = { ...this.config, cardRenderer: d });
|
|
648
651
|
}
|
|
649
|
-
const n = e.getAttribute("breakpoint"),
|
|
652
|
+
const n = e.getAttribute("breakpoint"), l = e.getAttribute("card-row-height"), s = e.getAttribute("hidden-columns"), o = e.getAttribute("hide-header"), c = e.getAttribute("debounce-ms"), a = {};
|
|
650
653
|
if (n !== null) {
|
|
651
654
|
const d = parseInt(n, 10);
|
|
652
|
-
isNaN(d) || (
|
|
655
|
+
isNaN(d) || (a.breakpoint = d);
|
|
653
656
|
}
|
|
654
|
-
if (
|
|
657
|
+
if (l !== null && (a.cardRowHeight = l === "auto" ? "auto" : parseInt(l, 10)), s !== null && (a.hiddenColumns = s.split(",").map((d) => d.trim()).filter((d) => d.length > 0)), o !== null && (a.hideHeader = o !== "false"), c !== null) {
|
|
655
658
|
const d = parseInt(c, 10);
|
|
656
|
-
isNaN(d) || (
|
|
659
|
+
isNaN(d) || (a.debounceMs = d);
|
|
657
660
|
}
|
|
658
661
|
const h = e.innerHTML.trim();
|
|
659
|
-
h && !this.config.cardRenderer && !i.__frameworkAdapter?.parseResponsiveCardElement && (
|
|
660
|
-
const f = T(h, { value: d, row: d }),
|
|
661
|
-
return p.className = "tbw-responsive-card-content", p.innerHTML =
|
|
662
|
-
}), Object.keys(
|
|
662
|
+
h && !this.config.cardRenderer && !i.__frameworkAdapter?.parseResponsiveCardElement && (a.cardRenderer = (d) => {
|
|
663
|
+
const f = T(h, { value: d, row: d }), m = k(f), p = document.createElement("div");
|
|
664
|
+
return p.className = "tbw-responsive-card-content", p.innerHTML = m, p;
|
|
665
|
+
}), Object.keys(a).length > 0 && (this.config = { ...this.config, ...a });
|
|
663
666
|
}
|
|
664
667
|
// #endregion
|
|
665
668
|
/**
|
|
@@ -693,9 +696,9 @@ class G extends z {
|
|
|
693
696
|
if (!e && !i)
|
|
694
697
|
return;
|
|
695
698
|
const n = this.gridElement.querySelectorAll(".cell[data-field]");
|
|
696
|
-
for (const
|
|
697
|
-
const s =
|
|
698
|
-
s && (this.#s.has(s) ? (
|
|
699
|
+
for (const l of n) {
|
|
700
|
+
const s = l.getAttribute("data-field");
|
|
701
|
+
s && (this.#s.has(s) ? (l.setAttribute("data-responsive-hidden", ""), l.removeAttribute("data-responsive-value-only")) : this.#l.has(s) ? (l.setAttribute("data-responsive-value-only", ""), l.removeAttribute("data-responsive-hidden")) : (l.removeAttribute("data-responsive-hidden"), l.removeAttribute("data-responsive-value-only")));
|
|
699
702
|
}
|
|
700
703
|
}
|
|
701
704
|
/**
|
|
@@ -775,8 +778,8 @@ class G extends z {
|
|
|
775
778
|
e.replaceChildren();
|
|
776
779
|
const n = this.config.cardRenderer(t, i);
|
|
777
780
|
e.className = "data-grid-row responsive-card";
|
|
778
|
-
const
|
|
779
|
-
return
|
|
781
|
+
const l = this.config.cardRowHeight ?? "auto";
|
|
782
|
+
return l !== "auto" ? e.style.height = `${l}px` : e.style.height = "auto", e.appendChild(n), !0;
|
|
780
783
|
}
|
|
781
784
|
/**
|
|
782
785
|
* Handle keyboard navigation in responsive mode.
|
|
@@ -851,7 +854,7 @@ class G extends z {
|
|
|
851
854
|
* Check if there are any group rows in the current dataset.
|
|
852
855
|
* Used to determine if we have mixed row heights.
|
|
853
856
|
*/
|
|
854
|
-
#
|
|
857
|
+
#m() {
|
|
855
858
|
for (const t of this.rows)
|
|
856
859
|
if (t.__isGroupRow)
|
|
857
860
|
return !0;
|
|
@@ -880,9 +883,9 @@ class G extends z {
|
|
|
880
883
|
* @deprecated Use getRowHeight() instead. This hook will be removed in v3.0.
|
|
881
884
|
*/
|
|
882
885
|
getExtraHeight() {
|
|
883
|
-
if (!this.#t || !this.config.cardRenderer || !this.#
|
|
886
|
+
if (!this.#t || !this.config.cardRenderer || !this.#m())
|
|
884
887
|
return 0;
|
|
885
|
-
const t = this.#i ?? 28, e = this.#p(), i = this.#f(), { groupCount: n, cardCount:
|
|
888
|
+
const t = this.#i ?? 28, e = this.#p(), i = this.#f(), { groupCount: n, cardCount: l } = this.#_(), s = n * Math.max(0, e - t), o = l * Math.max(0, i - t);
|
|
886
889
|
return s + o;
|
|
887
890
|
}
|
|
888
891
|
/**
|
|
@@ -894,14 +897,14 @@ class G extends z {
|
|
|
894
897
|
* @deprecated Use getRowHeight() instead. This hook will be removed in v3.0.
|
|
895
898
|
*/
|
|
896
899
|
getExtraHeightBefore(t) {
|
|
897
|
-
if (!this.#t || !this.config.cardRenderer || !this.#
|
|
900
|
+
if (!this.#t || !this.config.cardRenderer || !this.#m())
|
|
898
901
|
return 0;
|
|
899
|
-
const e = this.#i ?? 28, i = this.#p(), n = this.#f(),
|
|
902
|
+
const e = this.#i ?? 28, i = this.#p(), n = this.#f(), l = Math.max(0, i - e), s = Math.max(0, n - e);
|
|
900
903
|
let o = 0, c = 0;
|
|
901
|
-
const
|
|
904
|
+
const a = this.rows, h = Math.min(t, a.length);
|
|
902
905
|
for (let d = 0; d < h; d++)
|
|
903
|
-
|
|
904
|
-
return o *
|
|
906
|
+
a[d].__isGroupRow ? o++ : c++;
|
|
907
|
+
return o * l + c * s;
|
|
905
908
|
}
|
|
906
909
|
/**
|
|
907
910
|
* Get the height of a specific row based on its type (group row vs card row).
|
|
@@ -925,7 +928,7 @@ class G extends z {
|
|
|
925
928
|
return t;
|
|
926
929
|
}
|
|
927
930
|
/** Pending refresh scheduled via microtask */
|
|
928
|
-
#
|
|
931
|
+
#w = !1;
|
|
929
932
|
/**
|
|
930
933
|
* Measure card height from DOM after render and detect row count changes.
|
|
931
934
|
* Called in afterRender to ensure scroll calculations are accurate.
|
|
@@ -945,7 +948,7 @@ class G extends z {
|
|
|
945
948
|
if (!this.#t || !this.config.cardRenderer)
|
|
946
949
|
return;
|
|
947
950
|
let t = !1;
|
|
948
|
-
const e = this.grid, i = this.#
|
|
951
|
+
const e = this.grid, i = this.#m(), n = this.#C();
|
|
949
952
|
if (n !== this.#g && (this.#g = n, t = !0), i) {
|
|
950
953
|
const s = this.gridElement.querySelector(".data-grid-row.group-row");
|
|
951
954
|
if (s) {
|
|
@@ -953,13 +956,13 @@ class G extends z {
|
|
|
953
956
|
o > 0 && o !== this.#o && (this.#o = o, t = !0);
|
|
954
957
|
}
|
|
955
958
|
}
|
|
956
|
-
const
|
|
957
|
-
if (
|
|
958
|
-
const s =
|
|
959
|
+
const l = this.gridElement.querySelector(".data-grid-row.responsive-card");
|
|
960
|
+
if (l) {
|
|
961
|
+
const s = l.getBoundingClientRect().height;
|
|
959
962
|
s > 0 && s !== this.#r && (this.#r = s, t = !0, !i && e._virtualization && (e._virtualization.rowHeight = s));
|
|
960
963
|
}
|
|
961
|
-
t && !this.#
|
|
962
|
-
this.#
|
|
964
|
+
t && !this.#w && (this.#w = !0, queueMicrotask(() => {
|
|
965
|
+
this.#w = !1, this.grid && this.#t && this.grid.refreshVirtualWindow?.(!0, !0);
|
|
963
966
|
}));
|
|
964
967
|
}
|
|
965
968
|
}
|