@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
package/all.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { BaseGridPlugin as R, DEFAULT_GRID_ICONS as
|
|
2
|
-
import { DEFAULT_ANIMATION_CONFIG as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
return s.field ===
|
|
1
|
+
import { BaseGridPlugin as R, DEFAULT_GRID_ICONS as Je, a as Qe, runAggregator as j, e as et, s as tt, PLUGIN_QUERIES as We, getAggregator as ge, getValueAggregator as it, b as _, c as fe, g as nt } from "./index.js";
|
|
2
|
+
import { DEFAULT_ANIMATION_CONFIG as Rn, DGEvents as En, DataGridElement as Sn, FitModeEnum as kn, GridCSSVars as An, GridClasses as _n, GridDataAttrs as Ln, DataGridElement as Tn, GridSelectors as In, PluginEvents as Pn, PluginManager as Dn, RenderPhase as Fn, builtInSort as Mn, createGrid as qn, defaultComparator as Kn, queryGrid as Nn } from "./index.js";
|
|
3
|
+
const $e = "__tbw_expander", rt = 32;
|
|
4
|
+
function ae(s) {
|
|
5
|
+
return s.field === $e;
|
|
6
6
|
}
|
|
7
7
|
function I(s) {
|
|
8
8
|
return s.meta?.utility === !0;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return s.find(
|
|
10
|
+
function ot(s) {
|
|
11
|
+
return s.find(ae);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function st(s) {
|
|
14
14
|
return {
|
|
15
|
-
field:
|
|
15
|
+
field: $e,
|
|
16
16
|
header: "",
|
|
17
|
-
width:
|
|
17
|
+
width: rt,
|
|
18
18
|
resizable: !1,
|
|
19
19
|
sortable: !1,
|
|
20
20
|
filterable: !1,
|
|
@@ -27,7 +27,7 @@ function nt(s) {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
async function
|
|
30
|
+
async function U(s) {
|
|
31
31
|
try {
|
|
32
32
|
return await navigator.clipboard.writeText(s), !0;
|
|
33
33
|
} catch {
|
|
@@ -37,7 +37,7 @@ async function W(s) {
|
|
|
37
37
|
return document.body.removeChild(e), t;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function pe(s, e) {
|
|
41
41
|
const t = e.delimiter ?? " ", i = e.newline ?? `
|
|
42
42
|
`, n = s.replace(/\r\n/g, `
|
|
43
43
|
`).replace(/\r/g, `
|
|
@@ -49,14 +49,14 @@ function fe(s, e) {
|
|
|
49
49
|
}
|
|
50
50
|
return o.push(a), (o.length > 1 || o.some((d) => d.trim() !== "")) && r.push(o), r;
|
|
51
51
|
}
|
|
52
|
-
async function
|
|
52
|
+
async function at() {
|
|
53
53
|
try {
|
|
54
54
|
return await navigator.clipboard.readText();
|
|
55
55
|
} catch {
|
|
56
56
|
return "";
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function lt(s, e) {
|
|
60
60
|
const { rows: t, target: i, fields: n } = s;
|
|
61
61
|
if (!i) return;
|
|
62
62
|
const r = e.rows, o = e.effectiveConfig.columns ?? [], a = o.map((u) => u.field), l = /* @__PURE__ */ new Map();
|
|
@@ -65,23 +65,23 @@ function ot(s, e) {
|
|
|
65
65
|
});
|
|
66
66
|
const d = [...r], c = i.bounds ? i.bounds.endRow : 1 / 0;
|
|
67
67
|
t.forEach((u, h) => {
|
|
68
|
-
const
|
|
69
|
-
if (!(
|
|
68
|
+
const g = i.row + h;
|
|
69
|
+
if (!(g > c)) {
|
|
70
70
|
if (i.bounds) {
|
|
71
|
-
if (
|
|
71
|
+
if (g >= d.length)
|
|
72
72
|
return;
|
|
73
|
-
} else for (;
|
|
74
|
-
const
|
|
75
|
-
a.forEach((p) =>
|
|
73
|
+
} else for (; g >= d.length; ) {
|
|
74
|
+
const f = {};
|
|
75
|
+
a.forEach((p) => f[p] = ""), d.push(f);
|
|
76
76
|
}
|
|
77
|
-
d[
|
|
77
|
+
d[g] = { ...d[g] }, u.forEach((f, p) => {
|
|
78
78
|
const m = n[p];
|
|
79
|
-
m && l.get(m) && (d[
|
|
79
|
+
m && l.get(m) && (d[g][m] = f);
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
}), e.rows = d;
|
|
83
83
|
}
|
|
84
|
-
class
|
|
84
|
+
class nn extends R {
|
|
85
85
|
static dependencies = [
|
|
86
86
|
{ name: "selection", required: !1, reason: "Enables copy/paste of selected cells instead of entire grid" }
|
|
87
87
|
];
|
|
@@ -110,7 +110,7 @@ class Ui extends R {
|
|
|
110
110
|
return (e.ctrlKey || e.metaKey) && e.key === "c" ? (this.#e(e.target), !0) : !1;
|
|
111
111
|
}
|
|
112
112
|
#e(e) {
|
|
113
|
-
const t = this.#
|
|
113
|
+
const t = this.#n(), i = t?.getSelection(), n = this.columns.length - 1, r = this.rows.length - 1;
|
|
114
114
|
let o;
|
|
115
115
|
if (i && i.ranges.length > 0) {
|
|
116
116
|
const { mode: l, ranges: d } = i, c = d[d.length - 1];
|
|
@@ -128,12 +128,12 @@ class Ui extends R {
|
|
|
128
128
|
} else if (!t)
|
|
129
129
|
o = { startRow: 0, startCol: 0, endRow: r, endCol: n };
|
|
130
130
|
else {
|
|
131
|
-
const l = this.#
|
|
131
|
+
const l = this.#r(e);
|
|
132
132
|
if (!l) return;
|
|
133
133
|
o = { startRow: l.row, startCol: l.col, endRow: l.row, endCol: l.col };
|
|
134
134
|
}
|
|
135
|
-
const a = this.#
|
|
136
|
-
|
|
135
|
+
const a = this.#i(o);
|
|
136
|
+
U(a.text).then(() => {
|
|
137
137
|
this.lastCopied = { text: a.text, timestamp: Date.now() }, this.emit("copy", {
|
|
138
138
|
text: a.text,
|
|
139
139
|
rowCount: a.rowCount,
|
|
@@ -145,21 +145,21 @@ class Ui extends R {
|
|
|
145
145
|
const t = e.clipboardData?.getData("text/plain");
|
|
146
146
|
if (!t) return;
|
|
147
147
|
e.preventDefault();
|
|
148
|
-
const i =
|
|
148
|
+
const i = pe(t, this.config), r = this.#n()?.getSelection(), o = r?.ranges?.[0], a = o?.from.row ?? 0, l = o?.from.col ?? 0, c = o && (r?.mode === "range" || r?.mode === "row") && (o.from.row !== o.to.row || o.from.col !== o.to.col) ? { endRow: o.to.row, endCol: o.to.col } : null, u = c?.endCol ?? this.columns.length - 1, h = this.columns[l], g = h ? { row: a, col: l, field: h.field, bounds: c } : null, f = [], p = i[0]?.length ?? 0;
|
|
149
149
|
for (let w = 0; w < p && l + w <= u; w++) {
|
|
150
150
|
const b = this.columns[l + w];
|
|
151
|
-
b && !b.hidden &&
|
|
151
|
+
b && !b.hidden && f.push(b.field);
|
|
152
152
|
}
|
|
153
|
-
const m = { rows: i, text: t, target:
|
|
153
|
+
const m = { rows: i, text: t, target: g, fields: f };
|
|
154
154
|
this.emit("paste", m), this.#o(m);
|
|
155
155
|
}
|
|
156
156
|
#o(e) {
|
|
157
157
|
if (!this.grid) return;
|
|
158
158
|
const { pasteHandler: t } = this.config;
|
|
159
159
|
if (t === null) return;
|
|
160
|
-
(t ??
|
|
160
|
+
(t ?? lt)(e, this.grid);
|
|
161
161
|
}
|
|
162
|
-
#
|
|
162
|
+
#n() {
|
|
163
163
|
try {
|
|
164
164
|
const e = this.grid?.getPluginByName("selection");
|
|
165
165
|
if (e)
|
|
@@ -167,17 +167,17 @@ class Ui extends R {
|
|
|
167
167
|
} catch {
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
#
|
|
170
|
+
#i(e) {
|
|
171
171
|
const { startRow: t, startCol: i, endRow: n, endCol: r } = e, o = Math.min(t, n), a = Math.max(t, n), l = Math.min(i, r), d = Math.max(i, r), c = this.config.delimiter ?? " ", u = this.config.newline ?? `
|
|
172
|
-
`, h = [],
|
|
172
|
+
`, h = [], g = this.columns.slice(l, d + 1).filter((f) => !I(f));
|
|
173
173
|
if (this.config.includeHeaders) {
|
|
174
|
-
const
|
|
175
|
-
h.push(
|
|
174
|
+
const f = g.map((p) => p.header || p.field);
|
|
175
|
+
h.push(f.join(c));
|
|
176
176
|
}
|
|
177
|
-
for (let
|
|
178
|
-
const p = this.rows[
|
|
177
|
+
for (let f = o; f <= a; f++) {
|
|
178
|
+
const p = this.rows[f];
|
|
179
179
|
if (!p) continue;
|
|
180
|
-
const m =
|
|
180
|
+
const m = g.map((w) => {
|
|
181
181
|
const b = p[w.field];
|
|
182
182
|
return b == null ? "" : b instanceof Date ? b.toISOString() : String(b);
|
|
183
183
|
});
|
|
@@ -189,7 +189,7 @@ class Ui extends R {
|
|
|
189
189
|
columnCount: d - l + 1
|
|
190
190
|
};
|
|
191
191
|
}
|
|
192
|
-
#
|
|
192
|
+
#r(e) {
|
|
193
193
|
const t = e.closest("[data-field-cache]");
|
|
194
194
|
if (!t) return null;
|
|
195
195
|
const i = t.dataset.fieldCache, n = t.dataset.row;
|
|
@@ -200,7 +200,7 @@ class Ui extends R {
|
|
|
200
200
|
return o === -1 ? null : { row: r, col: o };
|
|
201
201
|
}
|
|
202
202
|
async copy() {
|
|
203
|
-
const t = this.#
|
|
203
|
+
const t = this.#n()?.getSelection(), i = this.columns.length - 1;
|
|
204
204
|
let n = { startRow: 0, startCol: 0, endRow: this.rows.length - 1, endCol: i };
|
|
205
205
|
if (t && t.ranges.length > 0) {
|
|
206
206
|
const o = t.ranges[t.ranges.length - 1];
|
|
@@ -211,8 +211,8 @@ class Ui extends R {
|
|
|
211
211
|
endCol: o.to.col
|
|
212
212
|
};
|
|
213
213
|
}
|
|
214
|
-
const r = this.#
|
|
215
|
-
return await
|
|
214
|
+
const r = this.#i(n);
|
|
215
|
+
return await U(r.text), this.lastCopied = { text: r.text, timestamp: Date.now() }, r.text;
|
|
216
216
|
}
|
|
217
217
|
async copyRows(e) {
|
|
218
218
|
if (e.length === 0) return "";
|
|
@@ -221,44 +221,44 @@ class Ui extends R {
|
|
|
221
221
|
startCol: 0,
|
|
222
222
|
endRow: t[t.length - 1],
|
|
223
223
|
endCol: i
|
|
224
|
-
}, r = this.#
|
|
225
|
-
return await
|
|
224
|
+
}, r = this.#i(n);
|
|
225
|
+
return await U(r.text), this.lastCopied = { text: r.text, timestamp: Date.now() }, r.text;
|
|
226
226
|
}
|
|
227
227
|
async paste() {
|
|
228
|
-
const e = await
|
|
229
|
-
return e ?
|
|
228
|
+
const e = await at();
|
|
229
|
+
return e ? pe(e, this.config) : null;
|
|
230
230
|
}
|
|
231
231
|
getLastCopied() {
|
|
232
232
|
return this.lastCopied;
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
|
-
const
|
|
236
|
-
function
|
|
235
|
+
const me = 100;
|
|
236
|
+
function le(s) {
|
|
237
237
|
if (s == null)
|
|
238
|
-
return
|
|
238
|
+
return me;
|
|
239
239
|
if (typeof s == "number")
|
|
240
240
|
return s;
|
|
241
241
|
const e = parseFloat(s);
|
|
242
|
-
return isNaN(e) ?
|
|
242
|
+
return isNaN(e) ? me : e;
|
|
243
243
|
}
|
|
244
|
-
function
|
|
245
|
-
return s.map((e) =>
|
|
244
|
+
function we(s) {
|
|
245
|
+
return s.map((e) => le(e.width));
|
|
246
246
|
}
|
|
247
|
-
function
|
|
247
|
+
function be(s) {
|
|
248
248
|
const e = [];
|
|
249
249
|
let t = 0;
|
|
250
250
|
for (const i of s)
|
|
251
|
-
e.push(t), t +=
|
|
251
|
+
e.push(t), t += le(i.width);
|
|
252
252
|
return e;
|
|
253
253
|
}
|
|
254
|
-
function
|
|
255
|
-
return s.reduce((e, t) => e +
|
|
254
|
+
function ve(s) {
|
|
255
|
+
return s.reduce((e, t) => e + le(t.width), 0);
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function dt(s, e, t, i, n) {
|
|
258
258
|
const r = t.length;
|
|
259
259
|
if (r === 0)
|
|
260
260
|
return { startCol: 0, endCol: 0, visibleColumns: [] };
|
|
261
|
-
let o =
|
|
261
|
+
let o = ct(s, t, i);
|
|
262
262
|
o = Math.max(0, o - n);
|
|
263
263
|
const a = s + e;
|
|
264
264
|
let l = o;
|
|
@@ -275,7 +275,7 @@ function st(s, e, t, i, n) {
|
|
|
275
275
|
d.push(c);
|
|
276
276
|
return { startCol: o, endCol: l, visibleColumns: d };
|
|
277
277
|
}
|
|
278
|
-
function
|
|
278
|
+
function ct(s, e, t) {
|
|
279
279
|
let i = 0, n = e.length - 1;
|
|
280
280
|
for (; i < n; ) {
|
|
281
281
|
const r = Math.floor((i + n) / 2);
|
|
@@ -283,10 +283,10 @@ function at(s, e, t) {
|
|
|
283
283
|
}
|
|
284
284
|
return i;
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function ut(s, e, t) {
|
|
287
287
|
return t ? s > e : !1;
|
|
288
288
|
}
|
|
289
|
-
class
|
|
289
|
+
class rn extends R {
|
|
290
290
|
name = "columnVirtualization";
|
|
291
291
|
get defaultConfig() {
|
|
292
292
|
return {
|
|
@@ -305,16 +305,16 @@ class Yi extends R {
|
|
|
305
305
|
attach(e) {
|
|
306
306
|
super.attach(e);
|
|
307
307
|
const t = this.columns;
|
|
308
|
-
this.columnWidths =
|
|
308
|
+
this.columnWidths = we(t), this.columnOffsets = be(t), this.totalWidth = ve(t), this.endCol = t.length - 1;
|
|
309
309
|
}
|
|
310
310
|
detach() {
|
|
311
311
|
this.columnWidths = [], this.columnOffsets = [], this.isVirtualized = !1, this.startCol = 0, this.endCol = 0, this.scrollLeft = 0, this.totalWidth = 0;
|
|
312
312
|
}
|
|
313
313
|
processColumns(e) {
|
|
314
|
-
const t =
|
|
315
|
-
if (this.isVirtualized = t ?? !1, this.columnWidths =
|
|
314
|
+
const t = ut(e.length, this.config.threshold ?? 30, this.config.autoEnable ?? !0);
|
|
315
|
+
if (this.isVirtualized = t ?? !1, this.columnWidths = we(e), this.columnOffsets = be(e), this.totalWidth = ve(e), !t)
|
|
316
316
|
return this.startCol = 0, this.endCol = e.length - 1, [...e];
|
|
317
|
-
const i = this.grid.clientWidth || 800, n =
|
|
317
|
+
const i = this.grid.clientWidth || 800, n = dt(
|
|
318
318
|
this.scrollLeft,
|
|
319
319
|
i,
|
|
320
320
|
this.columnOffsets,
|
|
@@ -354,14 +354,14 @@ class Yi extends R {
|
|
|
354
354
|
return this.totalWidth;
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
|
-
const
|
|
358
|
-
function
|
|
357
|
+
const Y = "@layer tbw-plugins{.tbw-context-menu{position:fixed;background:var(--tbw-context-menu-bg, var(--tbw-color-panel-bg, light-dark(#f5f5f5, #2a2a2a)));color:var(--tbw-context-menu-fg, var(--tbw-color-fg, light-dark(#222, #eee)));border:1px solid var(--tbw-context-menu-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-border-radius, .25rem);box-shadow:0 2px 10px var(--tbw-color-shadow, rgba(0, 0, 0, .15));min-width:var(--tbw-menu-min-width, 10rem);padding:var(--tbw-spacing-xs, .25rem) 0;z-index:10000;font-size:var(--tbw-font-size-sm, .8125rem);font-family:var(--tbw-font-family, system-ui, sans-serif)}.tbw-context-menu-item{display:flex;align-items:center;padding:var(--tbw-menu-item-padding, .375rem .75rem);cursor:pointer;gap:var(--tbw-menu-item-gap, .5rem)}.tbw-context-menu-item:hover:not(.disabled){background:var(--tbw-context-menu-hover, var(--tbw-color-row-hover, light-dark(#e8e8e8, #3a3a3a)))}.tbw-context-menu-item.disabled{opacity:.5;cursor:default}.tbw-context-menu-item.danger{color:light-dark(#c00,#f66)}.tbw-context-menu-icon{width:var(--tbw-icon-size, 1rem);text-align:center}.tbw-context-menu-label{flex:1}.tbw-context-menu-shortcut{color:var(--tbw-color-fg-muted, light-dark(#888, #888));font-size:var(--tbw-font-size-xs, .6875rem)}.tbw-context-menu-arrow{font-size:var(--tbw-font-size-2xs, .625rem);color:var(--tbw-color-fg-muted, light-dark(#888, #888))}.tbw-context-menu-separator{height:1px;background:var(--tbw-context-menu-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));margin:var(--tbw-spacing-xs, .25rem) 0}}";
|
|
358
|
+
function re(s, e) {
|
|
359
359
|
return (typeof s == "function" ? s(e) : s).filter((i) => !(i.hidden === !0 || typeof i.hidden == "function" && i.hidden(e)));
|
|
360
360
|
}
|
|
361
|
-
function
|
|
361
|
+
function ht(s, e) {
|
|
362
362
|
return s.disabled === !0 ? !0 : typeof s.disabled == "function" ? s.disabled(e) : !1;
|
|
363
363
|
}
|
|
364
|
-
function
|
|
364
|
+
function oe(s, e, t, i = Je.submenuArrow) {
|
|
365
365
|
const n = document.createElement("div");
|
|
366
366
|
n.className = "tbw-context-menu", n.setAttribute("role", "menu");
|
|
367
367
|
for (const r of s) {
|
|
@@ -372,7 +372,7 @@ function ie(s, e, t, i = Ye.submenuArrow) {
|
|
|
372
372
|
}
|
|
373
373
|
const o = document.createElement("div");
|
|
374
374
|
o.className = "tbw-context-menu-item", r.cssClass && o.classList.add(r.cssClass), o.setAttribute("role", "menuitem"), o.setAttribute("data-id", r.id);
|
|
375
|
-
const a =
|
|
375
|
+
const a = ht(r, e);
|
|
376
376
|
if (a && (o.classList.add("disabled"), o.setAttribute("aria-disabled", "true")), r.icon) {
|
|
377
377
|
const d = document.createElement("span");
|
|
378
378
|
d.className = "tbw-context-menu-icon", d.innerHTML = r.icon, o.appendChild(d);
|
|
@@ -386,7 +386,7 @@ function ie(s, e, t, i = Ye.submenuArrow) {
|
|
|
386
386
|
const d = document.createElement("span");
|
|
387
387
|
d.className = "tbw-context-menu-arrow", typeof i == "string" ? d.innerHTML = i : i instanceof HTMLElement && d.appendChild(i.cloneNode(!0)), o.appendChild(d), o.addEventListener("mouseenter", () => {
|
|
388
388
|
if (o.querySelector(".tbw-context-menu") || !r.subMenu) return;
|
|
389
|
-
const u =
|
|
389
|
+
const u = re(r.subMenu, e), h = oe(u, e, t, i);
|
|
390
390
|
h.classList.add("tbw-context-submenu"), h.style.position = "absolute", h.style.left = "100%", h.style.top = "0", o.style.position = "relative", o.appendChild(h);
|
|
391
391
|
}), o.addEventListener("mouseleave", () => {
|
|
392
392
|
const c = o.querySelector(".tbw-context-menu");
|
|
@@ -399,14 +399,14 @@ function ie(s, e, t, i = Ye.submenuArrow) {
|
|
|
399
399
|
}
|
|
400
400
|
return n;
|
|
401
401
|
}
|
|
402
|
-
function
|
|
402
|
+
function ye(s, e, t) {
|
|
403
403
|
s.style.position = "fixed", s.style.left = `${e}px`, s.style.top = `${t}px`, s.style.visibility = "hidden", s.style.zIndex = "10000";
|
|
404
404
|
const i = s.getBoundingClientRect(), n = window.innerWidth, r = window.innerHeight;
|
|
405
405
|
let o = e, a = t;
|
|
406
406
|
e + i.width > n && (o = e - i.width), t + i.height > r && (a = t - i.height), o = Math.max(0, o), a = Math.max(0, a), s.style.left = `${o}px`, s.style.top = `${a}px`, s.style.visibility = "visible";
|
|
407
407
|
}
|
|
408
|
-
let
|
|
409
|
-
const
|
|
408
|
+
let P = null, D = null, L = null, X = 0;
|
|
409
|
+
const Z = [
|
|
410
410
|
{
|
|
411
411
|
id: "copy",
|
|
412
412
|
name: "Copy",
|
|
@@ -424,11 +424,11 @@ const U = [
|
|
|
424
424
|
}
|
|
425
425
|
}
|
|
426
426
|
];
|
|
427
|
-
class
|
|
427
|
+
class on extends R {
|
|
428
428
|
name = "contextMenu";
|
|
429
429
|
get defaultConfig() {
|
|
430
430
|
return {
|
|
431
|
-
items:
|
|
431
|
+
items: Z
|
|
432
432
|
};
|
|
433
433
|
}
|
|
434
434
|
isOpen = !1;
|
|
@@ -436,20 +436,20 @@ class Xi extends R {
|
|
|
436
436
|
params = null;
|
|
437
437
|
menuElement = null;
|
|
438
438
|
attach(e) {
|
|
439
|
-
super.attach(e), this.installGlobalHandlers(),
|
|
439
|
+
super.attach(e), this.installGlobalHandlers(), X++;
|
|
440
440
|
}
|
|
441
441
|
detach() {
|
|
442
442
|
this.menuElement && (this.menuElement.remove(), this.menuElement = null), this.isOpen = !1, this.params = null, this.uninstallGlobalHandlers();
|
|
443
443
|
}
|
|
444
444
|
installGlobalHandlers() {
|
|
445
|
-
!L && typeof document < "u" && typeof
|
|
445
|
+
!L && typeof document < "u" && typeof Y == "string" && Y && (L = document.createElement("style"), L.id = "tbw-context-menu-styles", L.textContent = Y, document.head.appendChild(L)), P || (P = () => {
|
|
446
446
|
document.querySelectorAll(".tbw-context-menu").forEach((t) => t.remove());
|
|
447
|
-
}, document.addEventListener("click",
|
|
447
|
+
}, document.addEventListener("click", P)), D || (D = (e) => {
|
|
448
448
|
e.key === "Escape" && document.querySelectorAll(".tbw-context-menu").forEach((i) => i.remove());
|
|
449
449
|
}, document.addEventListener("keydown", D));
|
|
450
450
|
}
|
|
451
451
|
uninstallGlobalHandlers() {
|
|
452
|
-
|
|
452
|
+
X--, !(X > 0) && (P && (document.removeEventListener("click", P), P = null), D && (document.removeEventListener("keydown", D), D = null), L && (L.remove(), L = null));
|
|
453
453
|
}
|
|
454
454
|
afterRender() {
|
|
455
455
|
const e = this.gridElement;
|
|
@@ -461,14 +461,14 @@ class Xi extends R {
|
|
|
461
461
|
const r = n.target, o = r.closest("[data-row][data-col]"), a = r.closest(".header-cell");
|
|
462
462
|
let l;
|
|
463
463
|
if (o) {
|
|
464
|
-
const c = parseInt(o.getAttribute("data-row") ?? "-1", 10), u = parseInt(o.getAttribute("data-col") ?? "-1", 10), h = this.columns[u],
|
|
464
|
+
const c = parseInt(o.getAttribute("data-row") ?? "-1", 10), u = parseInt(o.getAttribute("data-col") ?? "-1", 10), h = this.columns[u], g = this.rows[c];
|
|
465
465
|
l = {
|
|
466
|
-
row:
|
|
466
|
+
row: g,
|
|
467
467
|
rowIndex: c,
|
|
468
468
|
column: h,
|
|
469
469
|
columnIndex: u,
|
|
470
470
|
field: h?.field ?? "",
|
|
471
|
-
value:
|
|
471
|
+
value: g?.[h?.field] ?? null,
|
|
472
472
|
isHeader: !1,
|
|
473
473
|
event: n
|
|
474
474
|
};
|
|
@@ -487,15 +487,15 @@ class Xi extends R {
|
|
|
487
487
|
} else
|
|
488
488
|
return;
|
|
489
489
|
this.params = l, this.position = { x: n.clientX, y: n.clientY };
|
|
490
|
-
const d =
|
|
491
|
-
d.length && (this.menuElement && this.menuElement.remove(), this.menuElement =
|
|
490
|
+
const d = re(this.config.items ?? Z, l);
|
|
491
|
+
d.length && (this.menuElement && this.menuElement.remove(), this.menuElement = oe(
|
|
492
492
|
d,
|
|
493
493
|
l,
|
|
494
494
|
(c) => {
|
|
495
495
|
c.action && c.action(l), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
|
|
496
496
|
},
|
|
497
497
|
this.gridIcons.submenuArrow
|
|
498
|
-
), document.body.appendChild(this.menuElement),
|
|
498
|
+
), document.body.appendChild(this.menuElement), ye(this.menuElement, n.clientX, n.clientY), this.isOpen = !0, this.emit("context-menu-open", { params: l, items: d }));
|
|
499
499
|
}));
|
|
500
500
|
}
|
|
501
501
|
showMenu(e, t, i) {
|
|
@@ -508,15 +508,15 @@ class Xi extends R {
|
|
|
508
508
|
value: i.value ?? null,
|
|
509
509
|
isHeader: i.isHeader ?? !1,
|
|
510
510
|
event: i.event ?? new MouseEvent("contextmenu")
|
|
511
|
-
}, r =
|
|
512
|
-
this.menuElement && this.menuElement.remove(), this.menuElement =
|
|
511
|
+
}, r = re(this.config.items ?? Z, n);
|
|
512
|
+
this.menuElement && this.menuElement.remove(), this.menuElement = oe(
|
|
513
513
|
r,
|
|
514
514
|
n,
|
|
515
515
|
(o) => {
|
|
516
516
|
o.action && o.action(n), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
|
|
517
517
|
},
|
|
518
518
|
this.gridIcons.submenuArrow
|
|
519
|
-
), document.body.appendChild(this.menuElement),
|
|
519
|
+
), document.body.appendChild(this.menuElement), ye(this.menuElement, e, t), this.isOpen = !0;
|
|
520
520
|
}
|
|
521
521
|
hideMenu() {
|
|
522
522
|
this.menuElement && (this.menuElement.remove(), this.menuElement = null, this.isOpen = !1);
|
|
@@ -525,12 +525,12 @@ class Xi extends R {
|
|
|
525
525
|
return this.isOpen;
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
|
-
const
|
|
529
|
-
function
|
|
528
|
+
const gt = "@layer tbw-plugins{tbw-grid{--tbw-editing-bg: var(--tbw-color-selection);--tbw-editing-row-bg: var(--tbw-editing-bg);--tbw-editing-border: var(--tbw-border-input, 1px solid var(--tbw-color-border-strong));--tbw-padding-editing-input: var(--tbw-cell-padding-input, 2px 6px);--tbw-font-size-editor: inherit;--tbw-editing-row-outline-color: var(--tbw-color-accent);--tbw-editing-row-outline-width: 1px;.data-grid-row:has(.editing){background:var(--tbw-editing-row-bg);outline:var(--tbw-editing-row-outline-width) solid var(--tbw-editing-row-outline-color);outline-offset:calc(-1 * var(--tbw-editing-row-outline-width))}.data-grid-row>.cell.editing{overflow:hidden;padding:0;display:flex;min-height:calc(var(--tbw-row-height) + 2px);align-items:center;justify-content:center}.data-grid-row>.cell.editing input:not([type=checkbox]),.data-grid-row>.cell.editing select,.data-grid-row>.cell.editing textarea{width:100%;height:100%;flex:1 1 auto;min-width:0;border:var(--tbw-editing-border);padding:var(--tbw-padding-editing-input);font-size:var(--tbw-font-size-editor)}.tbw-editor-host{display:contents}}}";
|
|
529
|
+
function ft(s) {
|
|
530
530
|
const e = s.options;
|
|
531
531
|
return e ? typeof e == "function" ? e() : e : [];
|
|
532
532
|
}
|
|
533
|
-
function
|
|
533
|
+
function pt(s) {
|
|
534
534
|
return (e) => {
|
|
535
535
|
const t = s.editorParams, i = document.createElement("input");
|
|
536
536
|
i.type = "number", i.value = e.value != null ? String(e.value) : "", t?.min !== void 0 && (i.min = String(t.min)), t?.max !== void 0 && (i.max = String(t.max)), t?.step !== void 0 && (i.step = String(t.step)), t?.placeholder && (i.placeholder = t.placeholder);
|
|
@@ -540,13 +540,13 @@ function ht(s) {
|
|
|
540
540
|
}), i;
|
|
541
541
|
};
|
|
542
542
|
}
|
|
543
|
-
function
|
|
543
|
+
function mt() {
|
|
544
544
|
return (s) => {
|
|
545
545
|
const e = document.createElement("input");
|
|
546
546
|
return e.type = "checkbox", e.checked = !!s.value, e.addEventListener("change", () => s.commit(e.checked)), e;
|
|
547
547
|
};
|
|
548
548
|
}
|
|
549
|
-
function
|
|
549
|
+
function wt(s) {
|
|
550
550
|
return (e) => {
|
|
551
551
|
const t = s.editorParams, i = document.createElement("input");
|
|
552
552
|
return i.type = "date", e.value instanceof Date && (i.valueAsDate = e.value), t?.min && (i.min = t.min), t?.max && (i.max = t.max), t?.placeholder && (i.placeholder = t.placeholder), i.addEventListener("change", () => e.commit(i.valueAsDate)), i.addEventListener("keydown", (n) => {
|
|
@@ -554,14 +554,14 @@ function gt(s) {
|
|
|
554
554
|
}), i;
|
|
555
555
|
};
|
|
556
556
|
}
|
|
557
|
-
function
|
|
557
|
+
function bt(s) {
|
|
558
558
|
return (e) => {
|
|
559
559
|
const t = s.editorParams, i = document.createElement("select");
|
|
560
560
|
if (s.multi && (i.multiple = !0), t?.includeEmpty) {
|
|
561
561
|
const o = document.createElement("option");
|
|
562
562
|
o.value = "", o.textContent = t.emptyLabel ?? "", i.appendChild(o);
|
|
563
563
|
}
|
|
564
|
-
|
|
564
|
+
ft(s).forEach((o) => {
|
|
565
565
|
const a = document.createElement("option");
|
|
566
566
|
a.value = String(o.value), a.textContent = o.label, (s.multi && Array.isArray(e.value) && e.value.includes(o.value) || !s.multi && e.value === o.value) && (a.selected = !0), i.appendChild(a);
|
|
567
567
|
});
|
|
@@ -577,7 +577,7 @@ function pt(s) {
|
|
|
577
577
|
}), i;
|
|
578
578
|
};
|
|
579
579
|
}
|
|
580
|
-
function
|
|
580
|
+
function vt(s) {
|
|
581
581
|
return (e) => {
|
|
582
582
|
const t = s.editorParams, i = document.createElement("input");
|
|
583
583
|
return i.type = "text", i.value = e.value != null ? String(e.value) : "", t?.maxLength !== void 0 && (i.maxLength = t.maxLength), t?.pattern && (i.pattern = t.pattern), t?.placeholder && (i.placeholder = t.placeholder), i.addEventListener("blur", () => e.commit(i.value)), i.addEventListener("keydown", (n) => {
|
|
@@ -585,22 +585,22 @@ function mt(s) {
|
|
|
585
585
|
}), i;
|
|
586
586
|
};
|
|
587
587
|
}
|
|
588
|
-
function
|
|
588
|
+
function yt(s) {
|
|
589
589
|
switch (s.type) {
|
|
590
590
|
case "number":
|
|
591
|
-
return
|
|
591
|
+
return pt(s);
|
|
592
592
|
case "boolean":
|
|
593
|
-
return
|
|
593
|
+
return mt();
|
|
594
594
|
case "date":
|
|
595
|
-
return
|
|
595
|
+
return wt(s);
|
|
596
596
|
case "select":
|
|
597
|
-
return
|
|
597
|
+
return bt(s);
|
|
598
598
|
default:
|
|
599
|
-
return
|
|
599
|
+
return vt(s);
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
|
-
const
|
|
603
|
-
function
|
|
602
|
+
const J = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';
|
|
603
|
+
function xt(s, e) {
|
|
604
604
|
if (e.editor) return e.editor;
|
|
605
605
|
if (e.__editorTemplate) return "template";
|
|
606
606
|
if (!e.type) return;
|
|
@@ -614,28 +614,28 @@ function bt(s, e) {
|
|
|
614
614
|
return r.editor;
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
|
-
function
|
|
617
|
+
function N(s) {
|
|
618
618
|
return !(typeof s != "string" || s === "__proto__" || s === "constructor" || s === "prototype");
|
|
619
619
|
}
|
|
620
|
-
function
|
|
620
|
+
function Ct(s) {
|
|
621
621
|
const e = (s.__editingCellCount ?? 0) + 1;
|
|
622
622
|
s.__editingCellCount = e, s.setAttribute("data-has-editing", "");
|
|
623
623
|
}
|
|
624
|
-
function
|
|
624
|
+
function Rt(s) {
|
|
625
625
|
s.__editingCellCount = 0, s.removeAttribute("data-has-editing");
|
|
626
626
|
}
|
|
627
|
-
function
|
|
627
|
+
function z(s, e) {
|
|
628
628
|
return s instanceof HTMLInputElement ? s.type === "checkbox" ? s.checked : s.type === "number" ? s.value === "" ? null : Number(s.value) : s.type === "date" ? s.valueAsDate : s.value : e?.type === "number" && s.value !== "" ? Number(s.value) : s.value;
|
|
629
629
|
}
|
|
630
|
-
function
|
|
630
|
+
function xe(s) {
|
|
631
631
|
}
|
|
632
|
-
function
|
|
632
|
+
function Et(s, e, t) {
|
|
633
633
|
const i = s.querySelector("input,textarea,select");
|
|
634
634
|
i && (i.addEventListener("blur", () => {
|
|
635
|
-
t(
|
|
636
|
-
}), i instanceof HTMLInputElement && i.type === "checkbox" ? i.addEventListener("change", () => t(i.checked)) : i instanceof HTMLSelectElement && i.addEventListener("change", () => t(
|
|
635
|
+
t(z(i, e));
|
|
636
|
+
}), i instanceof HTMLInputElement && i.type === "checkbox" ? i.addEventListener("change", () => t(i.checked)) : i instanceof HTMLSelectElement && i.addEventListener("change", () => t(z(i, e))));
|
|
637
637
|
}
|
|
638
|
-
class
|
|
638
|
+
class sn extends R {
|
|
639
639
|
static manifest = {
|
|
640
640
|
ownedProperties: [
|
|
641
641
|
{
|
|
@@ -657,7 +657,7 @@ class Zi extends R {
|
|
|
657
657
|
]
|
|
658
658
|
};
|
|
659
659
|
name = "editing";
|
|
660
|
-
styles =
|
|
660
|
+
styles = gt;
|
|
661
661
|
get defaultConfig() {
|
|
662
662
|
return {
|
|
663
663
|
editOn: "click"
|
|
@@ -666,9 +666,9 @@ class Zi extends R {
|
|
|
666
666
|
#e = -1;
|
|
667
667
|
#t = -1;
|
|
668
668
|
#o = /* @__PURE__ */ new Map();
|
|
669
|
-
#i = /* @__PURE__ */ new Set();
|
|
670
669
|
#n = /* @__PURE__ */ new Set();
|
|
671
|
-
#
|
|
670
|
+
#i = /* @__PURE__ */ new Set();
|
|
671
|
+
#r = !1;
|
|
672
672
|
attach(e) {
|
|
673
673
|
super.attach(e);
|
|
674
674
|
const t = this.disconnectSignal, i = e;
|
|
@@ -683,7 +683,7 @@ class Zi extends R {
|
|
|
683
683
|
}, document.addEventListener(
|
|
684
684
|
"keydown",
|
|
685
685
|
(n) => {
|
|
686
|
-
n.key === "Escape" && this.#e !== -1 && this.#
|
|
686
|
+
n.key === "Escape" && this.#e !== -1 && this.#s(this.#e, !0);
|
|
687
687
|
},
|
|
688
688
|
{ capture: !0, signal: t }
|
|
689
689
|
), document.addEventListener(
|
|
@@ -691,13 +691,15 @@ class Zi extends R {
|
|
|
691
691
|
(n) => {
|
|
692
692
|
if (this.#e === -1) return;
|
|
693
693
|
const r = i.findRenderedRowElement?.(this.#e);
|
|
694
|
-
!r || (n.composedPath && n.composedPath() || []).includes(r) ||
|
|
694
|
+
!r || (n.composedPath && n.composedPath() || []).includes(r) || queueMicrotask(() => {
|
|
695
|
+
this.#e !== -1 && this.#s(this.#e, !1);
|
|
696
|
+
});
|
|
695
697
|
},
|
|
696
698
|
{ signal: t }
|
|
697
699
|
);
|
|
698
700
|
}
|
|
699
701
|
detach() {
|
|
700
|
-
this.#e = -1, this.#t = -1, this.#o.clear(), this.#
|
|
702
|
+
this.#e = -1, this.#t = -1, this.#o.clear(), this.#n.clear(), this.#i.clear(), super.detach();
|
|
701
703
|
}
|
|
702
704
|
onCellClick(e) {
|
|
703
705
|
const t = this.grid, i = this.config.editOn ?? t.effectiveConfig?.editOn;
|
|
@@ -710,16 +712,16 @@ class Zi extends R {
|
|
|
710
712
|
onKeyDown(e) {
|
|
711
713
|
const t = this.grid;
|
|
712
714
|
if (e.key === "Escape" && this.#e !== -1)
|
|
713
|
-
return this.#
|
|
715
|
+
return this.#s(this.#e, !0), !0;
|
|
714
716
|
if (e.key === " " || e.key === "Spacebar") {
|
|
715
717
|
const i = t._focusRow, n = t._focusCol;
|
|
716
718
|
if (i >= 0 && n >= 0) {
|
|
717
719
|
const r = t._visibleColumns[n], o = t._rows[i];
|
|
718
720
|
if (r?.editable && r.type === "boolean" && o) {
|
|
719
721
|
const a = r.field;
|
|
720
|
-
if (
|
|
722
|
+
if (N(a)) {
|
|
721
723
|
const d = !o[a];
|
|
722
|
-
return this.#
|
|
724
|
+
return this.#h(i, r, d, o), e.preventDefault(), this.requestRender(), !0;
|
|
723
725
|
}
|
|
724
726
|
}
|
|
725
727
|
}
|
|
@@ -747,12 +749,12 @@ class Zi extends R {
|
|
|
747
749
|
}
|
|
748
750
|
});
|
|
749
751
|
this.gridElement.dispatchEvent(h);
|
|
750
|
-
const
|
|
752
|
+
const g = new CustomEvent("activate-cell", {
|
|
751
753
|
cancelable: !0,
|
|
752
754
|
bubbles: !0,
|
|
753
755
|
detail: { row: n, col: r }
|
|
754
756
|
});
|
|
755
|
-
return this.gridElement.dispatchEvent(
|
|
757
|
+
return this.gridElement.dispatchEvent(g), h.defaultPrevented || g.defaultPrevented ? (e.preventDefault(), !0) : (this.beginBulkEdit(n), !0);
|
|
756
758
|
}
|
|
757
759
|
return !1;
|
|
758
760
|
}
|
|
@@ -775,8 +777,8 @@ class Zi extends R {
|
|
|
775
777
|
}
|
|
776
778
|
afterRender() {
|
|
777
779
|
const e = this.grid;
|
|
778
|
-
if (this.#
|
|
779
|
-
for (const t of this.#
|
|
780
|
+
if (this.#r && (this.#r = !1, this.#g(e)), this.#i.size !== 0)
|
|
781
|
+
for (const t of this.#i) {
|
|
780
782
|
const [i, n] = t.split(":"), r = parseInt(i, 10), o = parseInt(n, 10), a = e.findRenderedRowElement?.(r);
|
|
781
783
|
if (!a) continue;
|
|
782
784
|
const l = a.querySelector(`.cell[data-col="${o}"]`);
|
|
@@ -790,14 +792,14 @@ class Zi extends R {
|
|
|
790
792
|
}
|
|
791
793
|
get changedRows() {
|
|
792
794
|
const e = [];
|
|
793
|
-
for (const t of this.#
|
|
795
|
+
for (const t of this.#n) {
|
|
794
796
|
const i = this.grid.getRow(t);
|
|
795
797
|
i && e.push(i);
|
|
796
798
|
}
|
|
797
799
|
return e;
|
|
798
800
|
}
|
|
799
801
|
get changedRowIds() {
|
|
800
|
-
return Array.from(this.#
|
|
802
|
+
return Array.from(this.#n);
|
|
801
803
|
}
|
|
802
804
|
get activeEditRow() {
|
|
803
805
|
return this.#e;
|
|
@@ -809,30 +811,30 @@ class Zi extends R {
|
|
|
809
811
|
return this.#e === e;
|
|
810
812
|
}
|
|
811
813
|
isCellEditing(e, t) {
|
|
812
|
-
return this.#
|
|
814
|
+
return this.#i.has(`${e}:${t}`);
|
|
813
815
|
}
|
|
814
816
|
isRowChanged(e) {
|
|
815
817
|
const t = this.grid, i = t._rows[e];
|
|
816
818
|
if (!i) return !1;
|
|
817
819
|
try {
|
|
818
820
|
const n = t.getRowId?.(i);
|
|
819
|
-
return n ? this.#
|
|
821
|
+
return n ? this.#n.has(n) : !1;
|
|
820
822
|
} catch {
|
|
821
823
|
return !1;
|
|
822
824
|
}
|
|
823
825
|
}
|
|
824
826
|
isRowChangedById(e) {
|
|
825
|
-
return this.#
|
|
827
|
+
return this.#n.has(e);
|
|
826
828
|
}
|
|
827
829
|
resetChangedRows(e) {
|
|
828
830
|
const t = this.changedRows, i = this.changedRowIds;
|
|
829
|
-
this.#
|
|
831
|
+
this.#n.clear(), this.#a(), e || this.emit("changed-rows-reset", { rows: t, ids: i }), this.grid._rowPool?.forEach((r) => r.classList.remove("changed"));
|
|
830
832
|
}
|
|
831
833
|
beginCellEdit(e, t) {
|
|
832
834
|
const i = this.grid, n = i._visibleColumns.findIndex((l) => l.field === t);
|
|
833
835
|
if (n === -1 || !i._visibleColumns[n]?.editable) return;
|
|
834
836
|
const a = i.findRenderedRowElement?.(e)?.querySelector(`.cell[data-col="${n}"]`);
|
|
835
|
-
a && this.#
|
|
837
|
+
a && this.#d(e, n, a);
|
|
836
838
|
}
|
|
837
839
|
beginBulkEdit(e) {
|
|
838
840
|
const t = this.grid;
|
|
@@ -840,7 +842,7 @@ class Zi extends R {
|
|
|
840
842
|
const r = t.findRenderedRowElement?.(e);
|
|
841
843
|
if (!r) return;
|
|
842
844
|
const o = t._rows[e];
|
|
843
|
-
this.#
|
|
845
|
+
this.#c(e, o), Array.from(r.children).forEach((a, l) => {
|
|
844
846
|
const d = t._visibleColumns[l];
|
|
845
847
|
if (d?.editable) {
|
|
846
848
|
const c = a;
|
|
@@ -849,7 +851,7 @@ class Zi extends R {
|
|
|
849
851
|
}), setTimeout(() => {
|
|
850
852
|
let a = r.querySelector(`.cell[data-col="${t._focusCol}"]`);
|
|
851
853
|
if (a?.classList.contains("editing") || (a = r.querySelector(".cell.editing")), a?.classList.contains("editing")) {
|
|
852
|
-
const l = a.querySelector(
|
|
854
|
+
const l = a.querySelector(J);
|
|
853
855
|
try {
|
|
854
856
|
l?.focus({ preventScroll: !0 });
|
|
855
857
|
} catch {
|
|
@@ -858,23 +860,23 @@ class Zi extends R {
|
|
|
858
860
|
}, 0);
|
|
859
861
|
}
|
|
860
862
|
commitActiveRowEdit() {
|
|
861
|
-
this.#e !== -1 && this.#
|
|
863
|
+
this.#e !== -1 && this.#s(this.#e, !1);
|
|
862
864
|
}
|
|
863
865
|
cancelActiveRowEdit() {
|
|
864
|
-
this.#e !== -1 && this.#
|
|
866
|
+
this.#e !== -1 && this.#s(this.#e, !0);
|
|
865
867
|
}
|
|
866
|
-
#
|
|
868
|
+
#d(e, t, i) {
|
|
867
869
|
const n = this.grid, r = n._rows[e], o = n._visibleColumns[t];
|
|
868
|
-
!r || !o?.editable || i.classList.contains("editing") || (this.#e !== e && this.#
|
|
870
|
+
!r || !o?.editable || i.classList.contains("editing") || (this.#e !== e && this.#c(e, r), this.#t = t, this.#p(r, e, o, t, i, !1));
|
|
869
871
|
}
|
|
870
|
-
#
|
|
872
|
+
#a() {
|
|
871
873
|
const e = this.grid;
|
|
872
874
|
e._activeEditRows = this.#e, e._rowEditSnapshots = this.#o;
|
|
873
875
|
}
|
|
874
|
-
#
|
|
875
|
-
this.#e !== e && (this.#o.set(e, { ...t }), this.#e = e, this.#
|
|
876
|
+
#c(e, t) {
|
|
877
|
+
this.#e !== e && (this.#o.set(e, { ...t }), this.#e = e, this.#a());
|
|
876
878
|
}
|
|
877
|
-
#
|
|
879
|
+
#s(e, t) {
|
|
878
880
|
if (this.#e !== e) return;
|
|
879
881
|
const i = this.grid, n = this.#o.get(e), r = i._rows[e], o = i.findRenderedRowElement?.(e);
|
|
880
882
|
let a;
|
|
@@ -890,15 +892,15 @@ class Zi extends R {
|
|
|
890
892
|
if (!u) return;
|
|
891
893
|
const h = d.querySelector("input,textarea,select");
|
|
892
894
|
if (h) {
|
|
893
|
-
const
|
|
894
|
-
r[u.field] !==
|
|
895
|
+
const g = z(h, u);
|
|
896
|
+
r[u.field] !== g && this.#h(e, u, g, r);
|
|
895
897
|
}
|
|
896
898
|
}), t && n && r)
|
|
897
899
|
Object.keys(n).forEach((l) => {
|
|
898
900
|
r[l] = n[l];
|
|
899
|
-
}), a && this.#
|
|
901
|
+
}), a && this.#n.delete(a);
|
|
900
902
|
else if (!t && r) {
|
|
901
|
-
const l = a ? this.#
|
|
903
|
+
const l = a ? this.#n.has(a) : !1;
|
|
902
904
|
this.emit("row-commit", {
|
|
903
905
|
rowIndex: e,
|
|
904
906
|
rowId: a ?? "",
|
|
@@ -908,16 +910,16 @@ class Zi extends R {
|
|
|
908
910
|
changedRowIds: this.changedRowIds
|
|
909
911
|
}), l && this.isAnimationEnabled && i.animateRow?.(e, "change");
|
|
910
912
|
}
|
|
911
|
-
this.#o.delete(e), this.#e = -1, this.#t = -1, this.#
|
|
912
|
-
for (const l of this.#
|
|
913
|
-
l.startsWith(`${e}:`) && this.#
|
|
913
|
+
this.#o.delete(e), this.#e = -1, this.#t = -1, this.#a();
|
|
914
|
+
for (const l of this.#i)
|
|
915
|
+
l.startsWith(`${e}:`) && this.#i.delete(l);
|
|
914
916
|
o && (o.querySelectorAll(".cell.editing").forEach((l) => {
|
|
915
|
-
l.classList.remove("editing"),
|
|
916
|
-
}), this.requestRender()), this.#
|
|
917
|
+
l.classList.remove("editing"), Rt(l.parentElement);
|
|
918
|
+
}), this.requestRender()), this.#r = !0, o || (this.#g(i), this.#r = !1);
|
|
917
919
|
}
|
|
918
|
-
#
|
|
920
|
+
#h(e, t, i, n) {
|
|
919
921
|
const r = t.field;
|
|
920
|
-
if (!
|
|
922
|
+
if (!N(r)) return;
|
|
921
923
|
const o = n[r];
|
|
922
924
|
if (o === i) return;
|
|
923
925
|
const a = this.grid;
|
|
@@ -926,7 +928,7 @@ class Zi extends R {
|
|
|
926
928
|
l = this.grid.getRowId(n);
|
|
927
929
|
} catch {
|
|
928
930
|
}
|
|
929
|
-
const d = l ? !this.#
|
|
931
|
+
const d = l ? !this.#n.has(l) : !0, c = l ? (g) => this.grid.updateRow(l, g, "cascade") : xe;
|
|
930
932
|
if (this.emitCancelable("cell-commit", {
|
|
931
933
|
row: n,
|
|
932
934
|
rowId: l ?? "",
|
|
@@ -939,9 +941,9 @@ class Zi extends R {
|
|
|
939
941
|
firstTimeForRow: d,
|
|
940
942
|
updateRow: c
|
|
941
943
|
})) return;
|
|
942
|
-
n[r] = i, l && this.#
|
|
944
|
+
n[r] = i, l && this.#n.add(l), this.#a();
|
|
943
945
|
const h = a.findRenderedRowElement?.(e);
|
|
944
|
-
h && (h.classList.add("changed"),
|
|
946
|
+
h && (h.classList.add("changed"), Qe(h, "change"));
|
|
945
947
|
}
|
|
946
948
|
#p(e, t, i, n, r, o) {
|
|
947
949
|
if (!i.editable || r.classList.contains("editing")) return;
|
|
@@ -950,26 +952,26 @@ class Zi extends R {
|
|
|
950
952
|
a = this.grid.getRowId(e);
|
|
951
953
|
} catch {
|
|
952
954
|
}
|
|
953
|
-
const l = a ? (v) => this.grid.updateRow(a, v, "cascade") :
|
|
954
|
-
r.classList.add("editing"), this.#
|
|
955
|
+
const l = a ? (v) => this.grid.updateRow(a, v, "cascade") : xe, d = N(i.field) ? e[i.field] : void 0;
|
|
956
|
+
r.classList.add("editing"), this.#i.add(`${t}:${n}`);
|
|
955
957
|
const c = r.parentElement;
|
|
956
|
-
c &&
|
|
958
|
+
c && Ct(c);
|
|
957
959
|
let u = !1;
|
|
958
960
|
const h = (v) => {
|
|
959
|
-
u || this.#e === -1 || this.#
|
|
960
|
-
},
|
|
961
|
-
u = !0,
|
|
962
|
-
},
|
|
963
|
-
|
|
964
|
-
v.key === "Enter" && (v.stopPropagation(), v.preventDefault(), u = !0, this.#
|
|
961
|
+
u || this.#e === -1 || this.#h(t, i, v, e);
|
|
962
|
+
}, g = () => {
|
|
963
|
+
u = !0, N(i.field) && (e[i.field] = d);
|
|
964
|
+
}, f = document.createElement("div");
|
|
965
|
+
f.className = "tbw-editor-host", r.innerHTML = "", r.appendChild(f), f.addEventListener("keydown", (v) => {
|
|
966
|
+
v.key === "Enter" && (v.stopPropagation(), v.preventDefault(), u = !0, this.#s(t, !1)), v.key === "Escape" && (v.stopPropagation(), v.preventDefault(), g(), this.#s(t, !0));
|
|
965
967
|
});
|
|
966
|
-
const p = i, m = p.__editorTemplate, w =
|
|
968
|
+
const p = i, m = p.__editorTemplate, w = xt(this.grid, p) ?? yt(i), b = d;
|
|
967
969
|
if (w === "template" && m)
|
|
968
|
-
this.#
|
|
970
|
+
this.#l(f, p, e, d, h, g, o, t);
|
|
969
971
|
else if (typeof w == "string") {
|
|
970
972
|
const v = document.createElement(w);
|
|
971
|
-
v.value = b, v.addEventListener("change", () => h(v.value)),
|
|
972
|
-
|
|
973
|
+
v.value = b, v.addEventListener("change", () => h(v.value)), f.appendChild(v), o || queueMicrotask(() => {
|
|
974
|
+
f.querySelector(J)?.focus({ preventScroll: !0 });
|
|
973
975
|
});
|
|
974
976
|
} else if (typeof w == "function") {
|
|
975
977
|
const v = {
|
|
@@ -979,15 +981,15 @@ class Zi extends R {
|
|
|
979
981
|
field: i.field,
|
|
980
982
|
column: i,
|
|
981
983
|
commit: h,
|
|
982
|
-
cancel:
|
|
984
|
+
cancel: g,
|
|
983
985
|
updateRow: l
|
|
984
986
|
}, S = w(v);
|
|
985
|
-
typeof S == "string" ? (
|
|
986
|
-
|
|
987
|
+
typeof S == "string" ? (f.innerHTML = S, Et(f, i, h)) : S instanceof Node && f.appendChild(S), o || queueMicrotask(() => {
|
|
988
|
+
f.querySelector(J)?.focus({ preventScroll: !0 });
|
|
987
989
|
});
|
|
988
990
|
} else if (w && typeof w == "object") {
|
|
989
991
|
const v = document.createElement("div");
|
|
990
|
-
v.setAttribute("data-external-editor", ""), v.setAttribute("data-field", i.field),
|
|
992
|
+
v.setAttribute("data-external-editor", ""), v.setAttribute("data-field", i.field), f.appendChild(v);
|
|
991
993
|
const S = {
|
|
992
994
|
row: e,
|
|
993
995
|
rowId: a ?? "",
|
|
@@ -995,14 +997,14 @@ class Zi extends R {
|
|
|
995
997
|
field: i.field,
|
|
996
998
|
column: i,
|
|
997
999
|
commit: h,
|
|
998
|
-
cancel:
|
|
1000
|
+
cancel: g,
|
|
999
1001
|
updateRow: l
|
|
1000
1002
|
};
|
|
1001
1003
|
if (w.mount)
|
|
1002
1004
|
try {
|
|
1003
1005
|
w.mount({ placeholder: v, context: S, spec: w });
|
|
1004
|
-
} catch (
|
|
1005
|
-
console.warn(`[tbw-grid] External editor mount error for column '${i.field}':`,
|
|
1006
|
+
} catch (K) {
|
|
1007
|
+
console.warn(`[tbw-grid] External editor mount error for column '${i.field}':`, K);
|
|
1006
1008
|
}
|
|
1007
1009
|
else
|
|
1008
1010
|
this.grid.dispatchEvent(
|
|
@@ -1010,7 +1012,7 @@ class Zi extends R {
|
|
|
1010
1012
|
);
|
|
1011
1013
|
}
|
|
1012
1014
|
}
|
|
1013
|
-
#
|
|
1015
|
+
#l(e, t, i, n, r, o, a, l) {
|
|
1014
1016
|
const d = t.__editorTemplate;
|
|
1015
1017
|
if (!d) return;
|
|
1016
1018
|
const c = d.cloneNode(!0), u = t.__compiledEditor;
|
|
@@ -1021,9 +1023,9 @@ class Zi extends R {
|
|
|
1021
1023
|
column: t,
|
|
1022
1024
|
commit: r,
|
|
1023
1025
|
cancel: o
|
|
1024
|
-
}) : c.querySelectorAll("*").forEach((
|
|
1025
|
-
|
|
1026
|
-
if (!
|
|
1026
|
+
}) : c.querySelectorAll("*").forEach((g) => {
|
|
1027
|
+
g.childNodes.length === 1 && g.firstChild?.nodeType === Node.TEXT_NODE && (g.textContent = g.textContent?.replace(/{{\s*value\s*}}/g, n == null ? "" : String(n)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (f, p) => {
|
|
1028
|
+
if (!N(p)) return "";
|
|
1027
1029
|
const m = i[p];
|
|
1028
1030
|
return m == null ? "" : String(m);
|
|
1029
1031
|
}) || "");
|
|
@@ -1033,17 +1035,17 @@ class Zi extends R {
|
|
|
1033
1035
|
);
|
|
1034
1036
|
if (h) {
|
|
1035
1037
|
h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked = !!n : h.value = String(n ?? "");
|
|
1036
|
-
let
|
|
1038
|
+
let g = !1;
|
|
1037
1039
|
h.addEventListener("blur", () => {
|
|
1038
|
-
|
|
1039
|
-
}), h.addEventListener("keydown", (
|
|
1040
|
-
const p =
|
|
1041
|
-
p.key === "Enter" && (p.stopPropagation(), p.preventDefault(),
|
|
1040
|
+
g || r(z(h, t));
|
|
1041
|
+
}), h.addEventListener("keydown", (f) => {
|
|
1042
|
+
const p = f;
|
|
1043
|
+
p.key === "Enter" && (p.stopPropagation(), p.preventDefault(), g = !0, r(z(h, t)), this.#s(l, !1)), p.key === "Escape" && (p.stopPropagation(), p.preventDefault(), o(), this.#s(l, !0));
|
|
1042
1044
|
}), h instanceof HTMLInputElement && h.type === "checkbox" && h.addEventListener("change", () => r(h.checked)), a || setTimeout(() => h.focus({ preventScroll: !0 }), 0);
|
|
1043
1045
|
}
|
|
1044
1046
|
e.appendChild(c);
|
|
1045
1047
|
}
|
|
1046
|
-
#
|
|
1048
|
+
#g(e) {
|
|
1047
1049
|
queueMicrotask(() => {
|
|
1048
1050
|
try {
|
|
1049
1051
|
const t = e._focusRow, i = e._focusCol, n = e.findRenderedRowElement?.(t);
|
|
@@ -1059,7 +1061,7 @@ class Zi extends R {
|
|
|
1059
1061
|
});
|
|
1060
1062
|
}
|
|
1061
1063
|
}
|
|
1062
|
-
function
|
|
1064
|
+
function Ce(s, e = !0) {
|
|
1063
1065
|
if (s == null) return "";
|
|
1064
1066
|
if (s instanceof Date) return s.toISOString();
|
|
1065
1067
|
if (typeof s == "object") return JSON.stringify(s);
|
|
@@ -1067,37 +1069,37 @@ function ye(s, e = !0) {
|
|
|
1067
1069
|
return e && (t.includes(",") || t.includes('"') || t.includes(`
|
|
1068
1070
|
`) || t.includes("\r")) ? `"${t.replace(/"/g, '""')}"` : t;
|
|
1069
1071
|
}
|
|
1070
|
-
function
|
|
1072
|
+
function St(s, e, t, i = {}) {
|
|
1071
1073
|
const n = i.delimiter ?? ",", r = i.newline ?? `
|
|
1072
1074
|
`, o = [], a = i.bom ? "\uFEFF" : "";
|
|
1073
1075
|
if (t.includeHeaders !== !1) {
|
|
1074
1076
|
const l = e.map((d) => {
|
|
1075
1077
|
const c = d.header || d.field, u = t.processHeader ? t.processHeader(c, d.field) : c;
|
|
1076
|
-
return
|
|
1078
|
+
return Ce(u);
|
|
1077
1079
|
});
|
|
1078
1080
|
o.push(l.join(n));
|
|
1079
1081
|
}
|
|
1080
1082
|
for (const l of s) {
|
|
1081
1083
|
const d = e.map((c) => {
|
|
1082
1084
|
let u = l[c.field];
|
|
1083
|
-
return t.processCell && (u = t.processCell(u, c.field, l)),
|
|
1085
|
+
return t.processCell && (u = t.processCell(u, c.field, l)), Ce(u);
|
|
1084
1086
|
});
|
|
1085
1087
|
o.push(d.join(n));
|
|
1086
1088
|
}
|
|
1087
1089
|
return a + o.join(r);
|
|
1088
1090
|
}
|
|
1089
|
-
function
|
|
1091
|
+
function de(s, e) {
|
|
1090
1092
|
const t = URL.createObjectURL(s), i = document.createElement("a");
|
|
1091
1093
|
i.href = t, i.download = e, i.style.display = "none", document.body.appendChild(i), i.click(), document.body.removeChild(i), URL.revokeObjectURL(t);
|
|
1092
1094
|
}
|
|
1093
|
-
function
|
|
1095
|
+
function kt(s, e) {
|
|
1094
1096
|
const t = new Blob([s], { type: "text/csv;charset=utf-8;" });
|
|
1095
|
-
|
|
1097
|
+
de(t, e);
|
|
1096
1098
|
}
|
|
1097
|
-
function
|
|
1099
|
+
function Re(s) {
|
|
1098
1100
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1099
1101
|
}
|
|
1100
|
-
function
|
|
1102
|
+
function At(s, e, t) {
|
|
1101
1103
|
let i = `<?xml version="1.0" encoding="UTF-8"?>
|
|
1102
1104
|
<?mso-application progid="Excel.Sheet"?>
|
|
1103
1105
|
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
|
|
@@ -1109,7 +1111,7 @@ function Et(s, e, t) {
|
|
|
1109
1111
|
<Row>`;
|
|
1110
1112
|
for (const n of e) {
|
|
1111
1113
|
const r = n.header || n.field, o = t.processHeader ? t.processHeader(r, n.field) : r;
|
|
1112
|
-
i += `<Cell><Data ss:Type="String">${
|
|
1114
|
+
i += `<Cell><Data ss:Type="String">${Re(o)}</Data></Cell>`;
|
|
1113
1115
|
}
|
|
1114
1116
|
i += "</Row>";
|
|
1115
1117
|
}
|
|
@@ -1120,7 +1122,7 @@ function Et(s, e, t) {
|
|
|
1120
1122
|
let o = n[r.field];
|
|
1121
1123
|
t.processCell && (o = t.processCell(o, r.field, n));
|
|
1122
1124
|
let a = "String", l = "";
|
|
1123
|
-
o == null ? l = "" : typeof o == "number" && !isNaN(o) ? (a = "Number", l = String(o)) : o instanceof Date ? (a = "DateTime", l = o.toISOString()) : l =
|
|
1125
|
+
o == null ? l = "" : typeof o == "number" && !isNaN(o) ? (a = "Number", l = String(o)) : o instanceof Date ? (a = "DateTime", l = o.toISOString()) : l = Re(String(o)), i += `<Cell><Data ss:Type="${a}">${l}</Data></Cell>`;
|
|
1124
1126
|
}
|
|
1125
1127
|
i += "</Row>";
|
|
1126
1128
|
}
|
|
@@ -1129,13 +1131,13 @@ function Et(s, e, t) {
|
|
|
1129
1131
|
</Worksheet>
|
|
1130
1132
|
</Workbook>`, i;
|
|
1131
1133
|
}
|
|
1132
|
-
function
|
|
1134
|
+
function _t(s, e) {
|
|
1133
1135
|
const t = e.endsWith(".xls") ? e : `${e}.xls`, i = new Blob([s], {
|
|
1134
1136
|
type: "application/vnd.ms-excel;charset=utf-8;"
|
|
1135
1137
|
});
|
|
1136
|
-
|
|
1138
|
+
de(i, t);
|
|
1137
1139
|
}
|
|
1138
|
-
class
|
|
1140
|
+
class an extends R {
|
|
1139
1141
|
name = "export";
|
|
1140
1142
|
get defaultConfig() {
|
|
1141
1143
|
return {
|
|
@@ -1172,27 +1174,27 @@ class Ji extends R {
|
|
|
1172
1174
|
try {
|
|
1173
1175
|
switch (e) {
|
|
1174
1176
|
case "csv": {
|
|
1175
|
-
const l =
|
|
1176
|
-
a = a.endsWith(".csv") ? a : `${a}.csv`,
|
|
1177
|
+
const l = St(o, r, n, { bom: !0 });
|
|
1178
|
+
a = a.endsWith(".csv") ? a : `${a}.csv`, kt(l, a);
|
|
1177
1179
|
break;
|
|
1178
1180
|
}
|
|
1179
1181
|
case "excel": {
|
|
1180
|
-
const l =
|
|
1181
|
-
a = a.endsWith(".xls") ? a : `${a}.xls`,
|
|
1182
|
+
const l = At(o, r, n);
|
|
1183
|
+
a = a.endsWith(".xls") ? a : `${a}.xls`, _t(l, a);
|
|
1182
1184
|
break;
|
|
1183
1185
|
}
|
|
1184
1186
|
case "json": {
|
|
1185
1187
|
const l = o.map((u) => {
|
|
1186
1188
|
const h = {};
|
|
1187
|
-
for (const
|
|
1188
|
-
let
|
|
1189
|
-
n.processCell && (
|
|
1189
|
+
for (const g of r) {
|
|
1190
|
+
let f = u[g.field];
|
|
1191
|
+
n.processCell && (f = n.processCell(f, g.field, u)), h[g.field] = f;
|
|
1190
1192
|
}
|
|
1191
1193
|
return h;
|
|
1192
1194
|
}), d = JSON.stringify(l, null, 2);
|
|
1193
1195
|
a = a.endsWith(".json") ? a : `${a}.json`;
|
|
1194
1196
|
const c = new Blob([d], { type: "application/json" });
|
|
1195
|
-
|
|
1197
|
+
de(c, a);
|
|
1196
1198
|
break;
|
|
1197
1199
|
}
|
|
1198
1200
|
}
|
|
@@ -1229,7 +1231,7 @@ class Ji extends R {
|
|
|
1229
1231
|
return this.lastExportInfo;
|
|
1230
1232
|
}
|
|
1231
1233
|
}
|
|
1232
|
-
function
|
|
1234
|
+
function Lt(s) {
|
|
1233
1235
|
const { totalRows: e, viewportHeight: t, scrollTop: i, rowHeight: n, overscan: r } = s, o = Math.ceil(t / n);
|
|
1234
1236
|
let a = Math.floor(i / n) - r;
|
|
1235
1237
|
a < 0 && (a = 0);
|
|
@@ -1241,10 +1243,10 @@ function kt(s) {
|
|
|
1241
1243
|
totalHeight: e * n
|
|
1242
1244
|
};
|
|
1243
1245
|
}
|
|
1244
|
-
function
|
|
1246
|
+
function Tt(s, e) {
|
|
1245
1247
|
return s <= e;
|
|
1246
1248
|
}
|
|
1247
|
-
function
|
|
1249
|
+
function It(s, e, t = !1) {
|
|
1248
1250
|
const i = s[e.field];
|
|
1249
1251
|
if (e.operator === "blank")
|
|
1250
1252
|
return i == null || i === "";
|
|
@@ -1283,10 +1285,10 @@ function _t(s, e, t = !1) {
|
|
|
1283
1285
|
return !0;
|
|
1284
1286
|
}
|
|
1285
1287
|
}
|
|
1286
|
-
function
|
|
1287
|
-
return e.length ? s.filter((i) => e.every((n) =>
|
|
1288
|
+
function Pt(s, e, t = !1) {
|
|
1289
|
+
return e.length ? s.filter((i) => e.every((n) => It(i, n, t))) : s;
|
|
1288
1290
|
}
|
|
1289
|
-
function
|
|
1291
|
+
function Dt(s) {
|
|
1290
1292
|
return JSON.stringify(
|
|
1291
1293
|
s.map((e) => ({
|
|
1292
1294
|
field: e.field,
|
|
@@ -1296,7 +1298,7 @@ function Tt(s) {
|
|
|
1296
1298
|
}))
|
|
1297
1299
|
);
|
|
1298
1300
|
}
|
|
1299
|
-
function
|
|
1301
|
+
function Ee(s, e) {
|
|
1300
1302
|
const t = /* @__PURE__ */ new Set();
|
|
1301
1303
|
for (const i of s) {
|
|
1302
1304
|
const n = i[e];
|
|
@@ -1304,10 +1306,10 @@ function xe(s, e) {
|
|
|
1304
1306
|
}
|
|
1305
1307
|
return [...t].sort((i, n) => typeof i == "number" && typeof n == "number" ? i - n : String(i).localeCompare(String(n)));
|
|
1306
1308
|
}
|
|
1307
|
-
const
|
|
1309
|
+
const Ft = '@layer tbw-plugins{tbw-grid{.tbw-quick-filter-input{flex:1;max-width:300px;height:var(--tbw-input-height, 1.75rem);padding:var(--tbw-input-padding, 0 .5rem);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);color:var(--tbw-color-fg);font-size:var(--tbw-font-size-sm, .8125rem);&:focus{outline:none;border-color:var(--tbw-color-accent)}}.header-cell.filtered:before{content:"";position:absolute;top:var(--tbw-spacing-xs, .25rem);right:var(--tbw-spacing-xs, .25rem);width:var(--tbw-indicator-size, .375rem);height:var(--tbw-indicator-size, .375rem);background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border-radius:50%}.tbw-filter-btn{display:var(--tbw-filter-btn-display, inline-flex);visibility:var(--tbw-filter-btn-visibility, visible);align-items:center;justify-content:center;background:transparent;border:none;cursor:pointer;padding:2px;margin-left:var(--tbw-spacing-xs, .25rem);opacity:.4;transition:opacity .15s,visibility 0s,display 0s allow-discrete;color:inherit;vertical-align:middle;transition-behavior:allow-discrete;&:hover,&.active{opacity:1;visibility:visible;display:inline-flex}&.active{color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}}.header-row .cell:hover .tbw-filter-btn,.header-row .cell.filtered .tbw-filter-btn{display:inline-flex;visibility:visible}}}', Mt = "@layer tbw-plugins{.tbw-filter-panel{position:fixed;background:var(--tbw-filter-panel-bg, var(--tbw-color-panel-bg, light-dark(#eeeeee, #222222)));color:var(--tbw-filter-panel-fg, var(--tbw-color-fg, light-dark(#222222, #eeeeee)));border:1px solid var(--tbw-filter-panel-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-panel-radius, var(--tbw-border-radius, .25rem));box-shadow:0 4px 16px var(--tbw-filter-panel-shadow, var(--tbw-color-shadow, light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .3))));padding:var(--tbw-panel-padding, var(--tbw-spacing-lg, .75rem));z-index:10000;min-width:200px;max-width:280px;max-height:350px;display:flex;flex-direction:column;font-family:var(--tbw-font-family, system-ui, sans-serif);font-size:var(--tbw-font-size, .8125rem);transform-origin:top center}.tbw-filter-panel.tbw-filter-panel-above{transform-origin:bottom center}.tbw-filter-panel.tbw-filter-panel-animated{animation:tbw-filter-panel-enter var(--tbw-animation-duration, .15s) var(--tbw-animation-easing, ease-out)}.tbw-filter-panel.tbw-filter-panel-above.tbw-filter-panel-animated{animation:tbw-filter-panel-enter-above var(--tbw-animation-duration, .15s) var(--tbw-animation-easing, ease-out)}@keyframes tbw-filter-panel-enter{0%{opacity:0;transform:scaleY(.3) translateY(-10px)}to{opacity:1;transform:scaleY(1) translateY(0)}}@keyframes tbw-filter-panel-enter-above{0%{opacity:0;transform:scaleY(.3) translateY(10px)}to{opacity:1;transform:scaleY(1) translateY(0)}}@supports (anchor-name: --test){.tbw-filter-panel{position-anchor:--tbw-filter-anchor;top:anchor(bottom);left:anchor(left);margin-top:4px;position-try-fallbacks:flip-inline,flip-block,flip-block flip-inline}}.tbw-filter-search{margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-filter-search-input{width:100%;padding:var(--tbw-filter-search-padding, var(--tbw-spacing-sm, .375rem) var(--tbw-spacing-md, .5rem));background:var(--tbw-filter-input-bg, var(--tbw-color-bg, transparent));color:inherit;border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-filter-input-radius, var(--tbw-border-radius, .25rem));font-size:inherit;box-sizing:border-box}.tbw-filter-search-input:focus{outline:none;border-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));box-shadow:0 0 0 2px rgba(from var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6)) r g b / 15%)}.tbw-filter-actions{display:flex;padding:var(--tbw-button-padding-sm, .25rem .125rem);margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border-bottom:1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)))}.tbw-filter-action-btn{background:transparent;border:none;color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));cursor:pointer;font-size:var(--tbw-font-size-xs, .75rem);padding:2px 0}.tbw-filter-action-btn:hover{text-decoration:underline}.tbw-filter-values{flex:1;overflow-y:auto;margin-bottom:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));max-height:180px;position:relative}.tbw-filter-values-spacer{width:1px}.tbw-filter-values-content{position:absolute;top:0;left:0;right:0}.tbw-filter-value-item{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding:var(--tbw-button-padding-sm, .25rem .125rem);cursor:pointer;border-radius:3px;min-height:var(--tbw-filter-item-height, 28px)}.tbw-filter-value-item:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}.tbw-filter-checkbox{margin:0;cursor:pointer;accent-color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}.tbw-filter-no-match{color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem)) 0;text-align:center;font-style:italic}.tbw-filter-buttons{display:flex;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding-top:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border-top:1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)))}.tbw-filter-apply-btn{flex:1;padding:var(--tbw-filter-btn-padding, var(--tbw-button-padding, .375rem .75rem));background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));color:var(--tbw-filter-accent-fg, var(--tbw-color-accent-fg, light-dark(#ffffff, #000000)));border:none;border-radius:var(--tbw-border-radius, .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);font-weight:var(--tbw-filter-btn-font-weight, 500);min-height:var(--tbw-filter-btn-min-height, auto)}.tbw-filter-apply-btn:hover{filter:brightness(.9)}.tbw-filter-clear-btn{flex:1;padding:var(--tbw-filter-btn-padding, var(--tbw-button-padding, .375rem .75rem));background:transparent;color:var(--tbw-filter-muted, var(--tbw-color-fg-muted, light-dark(#555555, #aaaaaa)));border:1px solid var(--tbw-filter-input-border, var(--tbw-color-border, light-dark(#d0d0d4, #454545)));border-radius:var(--tbw-border-radius, .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);font-weight:var(--tbw-filter-btn-font-weight, 500);min-height:var(--tbw-filter-btn-min-height, auto)}.tbw-filter-clear-btn:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}}";
|
|
1308
1310
|
class T extends R {
|
|
1309
1311
|
name = "filtering";
|
|
1310
|
-
styles =
|
|
1312
|
+
styles = Ft;
|
|
1311
1313
|
get defaultConfig() {
|
|
1312
1314
|
return {
|
|
1313
1315
|
debounceMs: 300,
|
|
@@ -1354,10 +1356,10 @@ class T extends R {
|
|
|
1354
1356
|
if (!t.length) return [...e];
|
|
1355
1357
|
if (this.config.filterHandler)
|
|
1356
1358
|
return this.cachedResult ? this.cachedResult : [...e];
|
|
1357
|
-
const i =
|
|
1359
|
+
const i = Dt(t);
|
|
1358
1360
|
if (this.cacheKey === i && this.cachedResult)
|
|
1359
1361
|
return this.cachedResult;
|
|
1360
|
-
const n =
|
|
1362
|
+
const n = Pt([...e], t, this.config.caseSensitive);
|
|
1361
1363
|
return this.cachedResult = n, this.cacheKey = i, n;
|
|
1362
1364
|
}
|
|
1363
1365
|
afterRender() {
|
|
@@ -1435,7 +1437,7 @@ class T extends R {
|
|
|
1435
1437
|
return this.getFilters();
|
|
1436
1438
|
}
|
|
1437
1439
|
getUniqueValues(e) {
|
|
1438
|
-
return
|
|
1440
|
+
return Ee(this.sourceRows, e);
|
|
1439
1441
|
}
|
|
1440
1442
|
copyGridThemeContext(e) {
|
|
1441
1443
|
const t = this.gridElement;
|
|
@@ -1452,7 +1454,7 @@ class T extends R {
|
|
|
1452
1454
|
return;
|
|
1453
1455
|
}
|
|
1454
1456
|
const e = document.createElement("style");
|
|
1455
|
-
e.id = "tbw-filter-panel-styles", e.textContent =
|
|
1457
|
+
e.id = "tbw-filter-panel-styles", e.textContent = Mt, document.head.appendChild(e), this.globalStylesInjected = !0;
|
|
1456
1458
|
}
|
|
1457
1459
|
toggleFilterPanel(e, t, i) {
|
|
1458
1460
|
if (this.openPanelField === e) {
|
|
@@ -1467,7 +1469,7 @@ class T extends R {
|
|
|
1467
1469
|
});
|
|
1468
1470
|
return;
|
|
1469
1471
|
}
|
|
1470
|
-
const r =
|
|
1472
|
+
const r = Ee(this.sourceRows, e);
|
|
1471
1473
|
this.renderPanelContent(e, t, n, r), document.body.appendChild(n), this.positionPanel(n, i), this.setupPanelCloseHandler(n, i);
|
|
1472
1474
|
}
|
|
1473
1475
|
renderPanelContent(e, t, i, n) {
|
|
@@ -1540,100 +1542,100 @@ class T extends R {
|
|
|
1540
1542
|
u.type = "checkbox", u.className = "tbw-filter-checkbox";
|
|
1541
1543
|
const h = document.createElement("span");
|
|
1542
1544
|
h.textContent = "Select All", c.appendChild(u), c.appendChild(h), d.appendChild(c);
|
|
1543
|
-
const
|
|
1544
|
-
const y = [...w.values()], E = y.every((
|
|
1545
|
+
const g = () => {
|
|
1546
|
+
const y = [...w.values()], E = y.every((x) => x), A = y.every((x) => !x);
|
|
1545
1547
|
u.checked = E, u.indeterminate = !E && !A;
|
|
1546
1548
|
};
|
|
1547
1549
|
u.addEventListener("change", () => {
|
|
1548
1550
|
const y = u.checked;
|
|
1549
1551
|
for (const E of w.keys())
|
|
1550
1552
|
w.set(E, y);
|
|
1551
|
-
|
|
1553
|
+
g(), S();
|
|
1552
1554
|
}), e.appendChild(d);
|
|
1553
|
-
const
|
|
1554
|
-
|
|
1555
|
+
const f = document.createElement("div");
|
|
1556
|
+
f.className = "tbw-filter-values";
|
|
1555
1557
|
const p = document.createElement("div");
|
|
1556
|
-
p.className = "tbw-filter-values-spacer",
|
|
1558
|
+
p.className = "tbw-filter-values-spacer", f.appendChild(p);
|
|
1557
1559
|
const m = document.createElement("div");
|
|
1558
|
-
m.className = "tbw-filter-values-content",
|
|
1560
|
+
m.className = "tbw-filter-values-content", f.appendChild(m);
|
|
1559
1561
|
const w = /* @__PURE__ */ new Map();
|
|
1560
1562
|
i.forEach((y) => {
|
|
1561
1563
|
const E = y == null ? "__null__" : String(y);
|
|
1562
1564
|
w.set(E, !n.has(y));
|
|
1563
|
-
}),
|
|
1565
|
+
}), g();
|
|
1564
1566
|
let b = [];
|
|
1565
1567
|
const v = (y, E) => {
|
|
1566
|
-
const A = y == null ? "(Blank)" : String(y),
|
|
1567
|
-
|
|
1568
|
+
const A = y == null ? "(Blank)" : String(y), x = y == null ? "__null__" : String(y), C = document.createElement("label");
|
|
1569
|
+
C.className = "tbw-filter-value-item", C.style.position = "absolute", C.style.top = `${E * o}px`, C.style.left = "0", C.style.right = "0", C.style.height = `${o}px`, C.style.boxSizing = "border-box";
|
|
1568
1570
|
const k = document.createElement("input");
|
|
1569
|
-
k.type = "checkbox", k.className = "tbw-filter-checkbox", k.checked = w.get(
|
|
1570
|
-
w.set(
|
|
1571
|
+
k.type = "checkbox", k.className = "tbw-filter-checkbox", k.checked = w.get(x) ?? !0, k.dataset.value = x, k.addEventListener("change", () => {
|
|
1572
|
+
w.set(x, k.checked), g();
|
|
1571
1573
|
});
|
|
1572
|
-
const
|
|
1573
|
-
return
|
|
1574
|
+
const he = document.createElement("span");
|
|
1575
|
+
return he.textContent = A, C.appendChild(k), C.appendChild(he), C;
|
|
1574
1576
|
}, S = () => {
|
|
1575
|
-
const y = b.length, E =
|
|
1576
|
-
if (p.style.height = `${y * o}px`,
|
|
1577
|
-
m.innerHTML = "", m.style.transform = "translateY(0px)", b.forEach((
|
|
1578
|
-
m.appendChild(v(
|
|
1577
|
+
const y = b.length, E = f.clientHeight, A = f.scrollTop;
|
|
1578
|
+
if (p.style.height = `${y * o}px`, Tt(y, T.LIST_BYPASS_THRESHOLD / 3)) {
|
|
1579
|
+
m.innerHTML = "", m.style.transform = "translateY(0px)", b.forEach((C, k) => {
|
|
1580
|
+
m.appendChild(v(C, k));
|
|
1579
1581
|
});
|
|
1580
1582
|
return;
|
|
1581
1583
|
}
|
|
1582
|
-
const
|
|
1584
|
+
const x = Lt({
|
|
1583
1585
|
totalRows: y,
|
|
1584
1586
|
viewportHeight: E,
|
|
1585
1587
|
scrollTop: A,
|
|
1586
1588
|
rowHeight: o,
|
|
1587
1589
|
overscan: T.LIST_OVERSCAN
|
|
1588
1590
|
});
|
|
1589
|
-
m.style.transform = `translateY(${
|
|
1590
|
-
for (let
|
|
1591
|
-
m.appendChild(v(b[
|
|
1592
|
-
},
|
|
1591
|
+
m.style.transform = `translateY(${x.offsetY}px)`, m.innerHTML = "";
|
|
1592
|
+
for (let C = x.start; C < x.end; C++)
|
|
1593
|
+
m.appendChild(v(b[C], C - x.start));
|
|
1594
|
+
}, K = (y) => {
|
|
1593
1595
|
const E = this.config.caseSensitive ?? !1, A = E ? y : y.toLowerCase();
|
|
1594
|
-
if (b = i.filter((
|
|
1595
|
-
const
|
|
1596
|
+
if (b = i.filter((x) => {
|
|
1597
|
+
const C = x == null ? "(Blank)" : String(x), k = E ? C : C.toLowerCase();
|
|
1596
1598
|
return !y || k.includes(A);
|
|
1597
1599
|
}), b.length === 0) {
|
|
1598
1600
|
p.style.height = "0px", m.innerHTML = "";
|
|
1599
|
-
const
|
|
1600
|
-
|
|
1601
|
+
const x = document.createElement("div");
|
|
1602
|
+
x.className = "tbw-filter-no-match", x.textContent = "No matching values", m.appendChild(x);
|
|
1601
1603
|
return;
|
|
1602
1604
|
}
|
|
1603
1605
|
S();
|
|
1604
1606
|
};
|
|
1605
|
-
|
|
1607
|
+
f.addEventListener(
|
|
1606
1608
|
"scroll",
|
|
1607
1609
|
() => {
|
|
1608
1610
|
b.length > 0 && S();
|
|
1609
1611
|
},
|
|
1610
1612
|
{ passive: !0 }
|
|
1611
|
-
),
|
|
1612
|
-
let
|
|
1613
|
+
), K(l.value), e.appendChild(f);
|
|
1614
|
+
let ue;
|
|
1613
1615
|
l.addEventListener("input", () => {
|
|
1614
|
-
clearTimeout(
|
|
1615
|
-
this.searchText.set(r, l.value),
|
|
1616
|
+
clearTimeout(ue), ue = setTimeout(() => {
|
|
1617
|
+
this.searchText.set(r, l.value), K(l.value);
|
|
1616
1618
|
}, this.config.debounceMs ?? 150);
|
|
1617
1619
|
});
|
|
1618
|
-
const
|
|
1619
|
-
|
|
1620
|
-
const
|
|
1621
|
-
|
|
1620
|
+
const G = document.createElement("div");
|
|
1621
|
+
G.className = "tbw-filter-buttons";
|
|
1622
|
+
const O = document.createElement("button");
|
|
1623
|
+
O.className = "tbw-filter-apply-btn", O.textContent = "Apply", O.addEventListener("click", () => {
|
|
1622
1624
|
const y = [];
|
|
1623
1625
|
for (const [E, A] of w)
|
|
1624
1626
|
if (!A)
|
|
1625
1627
|
if (E === "__null__")
|
|
1626
1628
|
y.push(null);
|
|
1627
1629
|
else {
|
|
1628
|
-
const
|
|
1629
|
-
y.push(
|
|
1630
|
+
const x = i.find((C) => String(C) === E);
|
|
1631
|
+
y.push(x !== void 0 ? x : E);
|
|
1630
1632
|
}
|
|
1631
1633
|
t.applySetFilter(y);
|
|
1632
|
-
}),
|
|
1633
|
-
const
|
|
1634
|
-
|
|
1634
|
+
}), G.appendChild(O);
|
|
1635
|
+
const B = document.createElement("button");
|
|
1636
|
+
B.className = "tbw-filter-clear-btn", B.textContent = "Clear Filter", B.addEventListener("click", () => {
|
|
1635
1637
|
t.clearFilter();
|
|
1636
|
-
}),
|
|
1638
|
+
}), G.appendChild(B), e.appendChild(G);
|
|
1637
1639
|
}
|
|
1638
1640
|
applySetFilter(e, t) {
|
|
1639
1641
|
this.excludedValues.set(e, new Set(t)), t.length === 0 ? this.filters.delete(e) : this.filters.set(e, {
|
|
@@ -1699,7 +1701,7 @@ class T extends R {
|
|
|
1699
1701
|
this.filters.set(e, i), this.cachedResult = null, this.cacheKey = null;
|
|
1700
1702
|
}
|
|
1701
1703
|
}
|
|
1702
|
-
function
|
|
1704
|
+
function Se(s) {
|
|
1703
1705
|
if (!s.length) return [];
|
|
1704
1706
|
const e = /* @__PURE__ */ new Map(), t = [], i = (o, a) => {
|
|
1705
1707
|
if (!a.length) return;
|
|
@@ -1734,7 +1736,7 @@ function Re(s) {
|
|
|
1734
1736
|
}, e.set(d, c), t.push(c)), c.columns.push(o);
|
|
1735
1737
|
}), n.length && i(r, n), t.length === 1 && t[0].implicit && t[0].columns.length === s.length ? [] : t;
|
|
1736
1738
|
}
|
|
1737
|
-
function
|
|
1739
|
+
function qt(s, e, t) {
|
|
1738
1740
|
if (!e.length || !s) return;
|
|
1739
1741
|
const i = /* @__PURE__ */ new Map();
|
|
1740
1742
|
for (const r of e)
|
|
@@ -1750,7 +1752,7 @@ function Dt(s, e, t) {
|
|
|
1750
1752
|
a && a.classList.add("group-end");
|
|
1751
1753
|
}
|
|
1752
1754
|
}
|
|
1753
|
-
function
|
|
1755
|
+
function Kt(s, e) {
|
|
1754
1756
|
if (s.length === 0) return null;
|
|
1755
1757
|
const t = document.createElement("div");
|
|
1756
1758
|
t.className = "header-group-row", t.setAttribute("role", "row");
|
|
@@ -1762,11 +1764,11 @@ function Pt(s, e) {
|
|
|
1762
1764
|
}
|
|
1763
1765
|
return t;
|
|
1764
1766
|
}
|
|
1765
|
-
function
|
|
1767
|
+
function Nt(s) {
|
|
1766
1768
|
return s.some((e) => e.group != null);
|
|
1767
1769
|
}
|
|
1768
|
-
const
|
|
1769
|
-
class
|
|
1770
|
+
const Ht = "@layer tbw-plugins{.header-group-row{display:grid;grid-auto-flow:column;background:var(--tbw-grouping-columns-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-grouping-columns-border, var(--tbw-color-border))}.header-group-cell{display:flex;align-items:center;justify-content:center;padding:var(--tbw-button-padding-sm, .25rem .5rem);font-weight:600;font-size:var(--tbw-font-size-sm, .9em);text-transform:uppercase;letter-spacing:.5px;border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong, var(--tbw-color-border)))}.header-group-cell:last-child{border-right:none}.header-row .cell.grouped{border-top:none}.header-row .cell.group-end{border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong, var(--tbw-color-border)))}.header-row .cell.group-end:last-child{border-right:none}.rows .cell.group-end{border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong, var(--tbw-color-border)))}.rows .cell.group-end:last-child{border-right:none}.header-group-row.no-borders{border-bottom:none}.header-group-row.no-borders .header-group-cell{border-right:none}.header-row.no-group-borders .cell.group-end{border-right:1px solid var(--tbw-color-border)}}";
|
|
1771
|
+
class ln extends R {
|
|
1770
1772
|
static manifest = {
|
|
1771
1773
|
ownedProperties: [
|
|
1772
1774
|
{
|
|
@@ -1783,7 +1785,7 @@ class Qi extends R {
|
|
|
1783
1785
|
]
|
|
1784
1786
|
};
|
|
1785
1787
|
name = "groupingColumns";
|
|
1786
|
-
styles =
|
|
1788
|
+
styles = Ht;
|
|
1787
1789
|
get defaultConfig() {
|
|
1788
1790
|
return {
|
|
1789
1791
|
showGroupBorders: !0
|
|
@@ -1798,7 +1800,7 @@ class Qi extends R {
|
|
|
1798
1800
|
if (t?.columnGroups && Array.isArray(t.columnGroups) && t.columnGroups.length > 0)
|
|
1799
1801
|
return !0;
|
|
1800
1802
|
const i = t?.columns;
|
|
1801
|
-
return Array.isArray(i) ?
|
|
1803
|
+
return Array.isArray(i) ? Nt(i) : !1;
|
|
1802
1804
|
}
|
|
1803
1805
|
processColumns(e) {
|
|
1804
1806
|
const t = this.grid?.gridConfig?.columnGroups;
|
|
@@ -1814,7 +1816,7 @@ class Qi extends R {
|
|
|
1814
1816
|
});
|
|
1815
1817
|
} else
|
|
1816
1818
|
i = [...e];
|
|
1817
|
-
const n =
|
|
1819
|
+
const n = Se(i);
|
|
1818
1820
|
return n.length === 0 ? (this.isActive = !1, this.groups = [], i) : (this.isActive = !0, this.groups = n, i);
|
|
1819
1821
|
}
|
|
1820
1822
|
afterRender() {
|
|
@@ -1827,16 +1829,16 @@ class Qi extends R {
|
|
|
1827
1829
|
if (!e) return;
|
|
1828
1830
|
const t = e.querySelector(".header-group-row");
|
|
1829
1831
|
t && t.remove();
|
|
1830
|
-
const i = this.columns, n =
|
|
1832
|
+
const i = this.columns, n = Se(i);
|
|
1831
1833
|
if (n.length === 0) return;
|
|
1832
|
-
const r =
|
|
1834
|
+
const r = Kt(n, i);
|
|
1833
1835
|
if (r) {
|
|
1834
1836
|
r.classList.toggle("no-borders", !this.config.showGroupBorders);
|
|
1835
1837
|
const a = e.querySelector(".header-row");
|
|
1836
1838
|
a ? e.insertBefore(r, a) : e.appendChild(r);
|
|
1837
1839
|
}
|
|
1838
1840
|
const o = e.querySelector(".header-row");
|
|
1839
|
-
o && (o.classList.toggle("no-group-borders", !this.config.showGroupBorders),
|
|
1841
|
+
o && (o.classList.toggle("no-group-borders", !this.config.showGroupBorders), qt(o, n)), this.#e(n);
|
|
1840
1842
|
}
|
|
1841
1843
|
#e(e) {
|
|
1842
1844
|
if (!this.config.showGroupBorders) return;
|
|
@@ -1867,66 +1869,94 @@ class Qi extends R {
|
|
|
1867
1869
|
this.requestRender();
|
|
1868
1870
|
}
|
|
1869
1871
|
}
|
|
1870
|
-
function
|
|
1871
|
-
const
|
|
1872
|
-
if (typeof
|
|
1872
|
+
function ke({ rows: s, config: e, expanded: t, initialExpanded: i }) {
|
|
1873
|
+
const n = e.groupOn;
|
|
1874
|
+
if (typeof n != "function")
|
|
1873
1875
|
return [];
|
|
1874
|
-
const
|
|
1875
|
-
if (s.forEach((
|
|
1876
|
-
let
|
|
1877
|
-
|
|
1878
|
-
let
|
|
1879
|
-
|
|
1880
|
-
const
|
|
1881
|
-
let
|
|
1882
|
-
|
|
1883
|
-
}),
|
|
1884
|
-
}),
|
|
1876
|
+
const r = { key: "__root__", value: null, depth: -1, rows: [], children: /* @__PURE__ */ new Map() };
|
|
1877
|
+
if (s.forEach((d) => {
|
|
1878
|
+
let c = n(d);
|
|
1879
|
+
c == null || c === !1 ? c = ["__ungrouped__"] : Array.isArray(c) || (c = [c]);
|
|
1880
|
+
let u = r;
|
|
1881
|
+
c.forEach((h, g) => {
|
|
1882
|
+
const f = h == null ? "∅" : String(h), p = u.key === "__root__" ? f : u.key + "||" + f;
|
|
1883
|
+
let m = u.children.get(f);
|
|
1884
|
+
m || (m = { key: p, value: h, depth: g, rows: [], children: /* @__PURE__ */ new Map(), parent: u }, u.children.set(f, m)), u = m;
|
|
1885
|
+
}), u.rows.push(d);
|
|
1886
|
+
}), r.children.size === 1 && r.children.has("__ungrouped__") && r.children.get("__ungrouped__").rows.length === s.length)
|
|
1885
1887
|
return [];
|
|
1886
|
-
const
|
|
1887
|
-
if (
|
|
1888
|
-
|
|
1888
|
+
const o = /* @__PURE__ */ new Set([...t, ...i ?? []]), a = [], l = (d) => {
|
|
1889
|
+
if (d === r) {
|
|
1890
|
+
d.children.forEach((u) => l(u));
|
|
1889
1891
|
return;
|
|
1890
1892
|
}
|
|
1891
|
-
const
|
|
1892
|
-
|
|
1893
|
+
const c = o.has(d.key);
|
|
1894
|
+
a.push({
|
|
1893
1895
|
kind: "group",
|
|
1894
|
-
key:
|
|
1895
|
-
value:
|
|
1896
|
-
depth:
|
|
1897
|
-
rows:
|
|
1898
|
-
expanded:
|
|
1899
|
-
}),
|
|
1896
|
+
key: d.key,
|
|
1897
|
+
value: d.value,
|
|
1898
|
+
depth: d.depth,
|
|
1899
|
+
rows: d.rows,
|
|
1900
|
+
expanded: c
|
|
1901
|
+
}), c && (d.children.size ? d.children.forEach((u) => l(u)) : d.rows.forEach((u) => a.push({ kind: "data", row: u, rowIndex: s.indexOf(u) })));
|
|
1900
1902
|
};
|
|
1901
|
-
return
|
|
1903
|
+
return l(r), a;
|
|
1902
1904
|
}
|
|
1903
|
-
function
|
|
1905
|
+
function zt(s, e) {
|
|
1904
1906
|
const t = new Set(s);
|
|
1905
1907
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
1906
1908
|
}
|
|
1907
|
-
function
|
|
1909
|
+
function Gt(s) {
|
|
1908
1910
|
const e = /* @__PURE__ */ new Set();
|
|
1909
1911
|
for (const t of s)
|
|
1910
1912
|
t.kind === "group" && e.add(t.key);
|
|
1911
1913
|
return e;
|
|
1912
1914
|
}
|
|
1913
|
-
function
|
|
1915
|
+
function Ot() {
|
|
1914
1916
|
return /* @__PURE__ */ new Set();
|
|
1915
1917
|
}
|
|
1916
|
-
function
|
|
1918
|
+
function Bt(s, e) {
|
|
1919
|
+
if (s === !0)
|
|
1920
|
+
return new Set(e);
|
|
1921
|
+
if (s === !1 || s == null)
|
|
1922
|
+
return /* @__PURE__ */ new Set();
|
|
1923
|
+
if (typeof s == "number") {
|
|
1924
|
+
const t = e[s];
|
|
1925
|
+
return t ? /* @__PURE__ */ new Set([t]) : /* @__PURE__ */ new Set();
|
|
1926
|
+
}
|
|
1927
|
+
return typeof s == "string" ? /* @__PURE__ */ new Set([s]) : Array.isArray(s) ? new Set(s) : /* @__PURE__ */ new Set();
|
|
1928
|
+
}
|
|
1929
|
+
function Vt(s) {
|
|
1930
|
+
return s.filter((e) => e.kind === "group").map((e) => e.key);
|
|
1931
|
+
}
|
|
1932
|
+
function Wt(s) {
|
|
1917
1933
|
return s.kind !== "group" ? 0 : s.rows.length;
|
|
1918
1934
|
}
|
|
1919
|
-
const
|
|
1920
|
-
class
|
|
1935
|
+
const $t = "@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;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}}}";
|
|
1936
|
+
class dn extends R {
|
|
1937
|
+
static manifest = {
|
|
1938
|
+
configRules: [
|
|
1939
|
+
{
|
|
1940
|
+
id: "groupingRows/accordion-defaultExpanded",
|
|
1941
|
+
severity: "warn",
|
|
1942
|
+
message: `"accordion: true" and "defaultExpanded" (non-false) are used together.
|
|
1943
|
+
→ In accordion mode, only one group can be open at a time.
|
|
1944
|
+
→ Using defaultExpanded with multiple groups will collapse to one on first toggle.
|
|
1945
|
+
→ Consider using "defaultExpanded: false" or a single group key/index with accordion mode.`,
|
|
1946
|
+
check: (e) => e.accordion === !0 && e.defaultExpanded !== !1 && e.defaultExpanded !== void 0 && typeof e.defaultExpanded != "number" && typeof e.defaultExpanded != "string" && (e.defaultExpanded === !0 || Array.isArray(e.defaultExpanded) && e.defaultExpanded.length > 1)
|
|
1947
|
+
}
|
|
1948
|
+
]
|
|
1949
|
+
};
|
|
1921
1950
|
name = "groupingRows";
|
|
1922
|
-
styles =
|
|
1951
|
+
styles = $t;
|
|
1923
1952
|
get defaultConfig() {
|
|
1924
1953
|
return {
|
|
1925
1954
|
defaultExpanded: !1,
|
|
1926
1955
|
showRowCount: !0,
|
|
1927
1956
|
indentWidth: 20,
|
|
1928
1957
|
aggregators: {},
|
|
1929
|
-
animation: "slide"
|
|
1958
|
+
animation: "slide",
|
|
1959
|
+
accordion: !1
|
|
1930
1960
|
};
|
|
1931
1961
|
}
|
|
1932
1962
|
expandedKeys = /* @__PURE__ */ new Set();
|
|
@@ -1934,11 +1964,12 @@ class en extends R {
|
|
|
1934
1964
|
isActive = !1;
|
|
1935
1965
|
previousVisibleKeys = /* @__PURE__ */ new Set();
|
|
1936
1966
|
keysToAnimate = /* @__PURE__ */ new Set();
|
|
1967
|
+
hasAppliedDefaultExpanded = !1;
|
|
1937
1968
|
get animationStyle() {
|
|
1938
1969
|
return this.isAnimationEnabled ? this.config.animation ?? "slide" : !1;
|
|
1939
1970
|
}
|
|
1940
1971
|
detach() {
|
|
1941
|
-
this.expandedKeys.clear(), this.flattenedRows = [], this.isActive = !1, this.previousVisibleKeys.clear(), this.keysToAnimate.clear();
|
|
1972
|
+
this.expandedKeys.clear(), this.flattenedRows = [], this.isActive = !1, this.previousVisibleKeys.clear(), this.keysToAnimate.clear(), this.hasAppliedDefaultExpanded = !1;
|
|
1942
1973
|
}
|
|
1943
1974
|
static detect(e, t) {
|
|
1944
1975
|
return typeof t?.groupOn == "function" || typeof t?.enableRowGrouping == "boolean";
|
|
@@ -1947,29 +1978,40 @@ class en extends R {
|
|
|
1947
1978
|
const t = this.config;
|
|
1948
1979
|
if (typeof t.groupOn != "function")
|
|
1949
1980
|
return this.isActive = !1, this.flattenedRows = [], [...e];
|
|
1950
|
-
const i =
|
|
1981
|
+
const i = ke({
|
|
1951
1982
|
rows: [...e],
|
|
1952
1983
|
config: t,
|
|
1953
|
-
expanded:
|
|
1984
|
+
expanded: /* @__PURE__ */ new Set()
|
|
1954
1985
|
});
|
|
1955
1986
|
if (i.length === 0)
|
|
1956
1987
|
return this.isActive = !1, this.flattenedRows = [], [...e];
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1988
|
+
let n;
|
|
1989
|
+
if (!this.hasAppliedDefaultExpanded && this.expandedKeys.size === 0 && t.defaultExpanded !== !1) {
|
|
1990
|
+
const a = Vt(i);
|
|
1991
|
+
n = Bt(t.defaultExpanded ?? !1, a), n.size > 0 && (this.expandedKeys = new Set(n), this.hasAppliedDefaultExpanded = !0);
|
|
1992
|
+
}
|
|
1993
|
+
const r = ke({
|
|
1994
|
+
rows: [...e],
|
|
1995
|
+
config: t,
|
|
1996
|
+
expanded: this.expandedKeys,
|
|
1997
|
+
initialExpanded: n
|
|
1998
|
+
});
|
|
1999
|
+
this.isActive = !0, this.flattenedRows = r, this.keysToAnimate.clear();
|
|
2000
|
+
const o = /* @__PURE__ */ new Set();
|
|
2001
|
+
return r.forEach((a, l) => {
|
|
2002
|
+
if (a.kind === "data") {
|
|
2003
|
+
const d = `data-${l}`;
|
|
2004
|
+
o.add(d), this.previousVisibleKeys.has(d) || this.keysToAnimate.add(d);
|
|
1963
2005
|
}
|
|
1964
|
-
}), this.previousVisibleKeys =
|
|
2006
|
+
}), this.previousVisibleKeys = o, r.map((a) => a.kind === "group" ? {
|
|
1965
2007
|
__isGroupRow: !0,
|
|
1966
|
-
__groupKey:
|
|
1967
|
-
__groupValue:
|
|
1968
|
-
__groupDepth:
|
|
1969
|
-
__groupRows:
|
|
1970
|
-
__groupExpanded:
|
|
1971
|
-
__groupRowCount:
|
|
1972
|
-
} :
|
|
2008
|
+
__groupKey: a.key,
|
|
2009
|
+
__groupValue: a.value,
|
|
2010
|
+
__groupDepth: a.depth,
|
|
2011
|
+
__groupRows: a.rows,
|
|
2012
|
+
__groupExpanded: a.expanded,
|
|
2013
|
+
__groupRowCount: Wt(a)
|
|
2014
|
+
} : a.row);
|
|
1973
2015
|
}
|
|
1974
2016
|
onCellClick(e) {
|
|
1975
2017
|
const t = e.row;
|
|
@@ -2028,62 +2070,88 @@ class en extends R {
|
|
|
2028
2070
|
return n.formatLabel ? n.formatLabel(e, t, i) : String(e);
|
|
2029
2071
|
}
|
|
2030
2072
|
renderFullWidthGroupRow(e, t, i) {
|
|
2031
|
-
const n = this.config, r = document.createElement("div");
|
|
2032
|
-
|
|
2033
|
-
const
|
|
2034
|
-
if (
|
|
2035
|
-
const
|
|
2036
|
-
|
|
2073
|
+
const n = this.config, r = n.aggregators ?? {}, o = e.__groupRows ?? [], a = document.createElement("div");
|
|
2074
|
+
a.className = "cell group-full", a.style.gridColumn = "1 / -1", a.setAttribute("role", "gridcell"), a.setAttribute("data-col", "0"), a.appendChild(this.createToggleButton(e.__groupExpanded, i));
|
|
2075
|
+
const l = document.createElement("span");
|
|
2076
|
+
if (l.className = "group-label", l.textContent = this.getGroupLabelText(e.__groupValue, e.__groupDepth || 0, e.__groupKey), a.appendChild(l), n.showRowCount !== !1) {
|
|
2077
|
+
const c = document.createElement("span");
|
|
2078
|
+
c.className = "group-count", c.textContent = `(${e.__groupRowCount ?? e.__groupRows?.length ?? 0})`, a.appendChild(c);
|
|
2037
2079
|
}
|
|
2038
|
-
|
|
2080
|
+
const d = Object.entries(r);
|
|
2081
|
+
if (d.length > 0) {
|
|
2082
|
+
const c = document.createElement("span");
|
|
2083
|
+
c.className = "group-aggregates";
|
|
2084
|
+
for (const [u, h] of d) {
|
|
2085
|
+
const g = this.columns.find((p) => p.field === u), f = j(h, o, u, g);
|
|
2086
|
+
if (f != null) {
|
|
2087
|
+
const p = document.createElement("span");
|
|
2088
|
+
p.className = "group-aggregate", p.setAttribute("data-field", u);
|
|
2089
|
+
const m = g?.header ?? u;
|
|
2090
|
+
p.textContent = `${m}: ${f}`, c.appendChild(p);
|
|
2091
|
+
}
|
|
2092
|
+
}
|
|
2093
|
+
c.children.length > 0 && a.appendChild(c);
|
|
2094
|
+
}
|
|
2095
|
+
t.appendChild(a);
|
|
2039
2096
|
}
|
|
2040
2097
|
renderPerColumnGroupRow(e, t, i) {
|
|
2041
2098
|
const n = this.config, r = n.aggregators ?? {}, o = this.columns, a = e.__groupRows ?? [], d = this.gridElement?.querySelector(".body")?.style.gridTemplateColumns || "";
|
|
2042
2099
|
d && (t.style.display = "grid", t.style.gridTemplateColumns = d);
|
|
2043
2100
|
let c = !1;
|
|
2044
2101
|
o.forEach((u, h) => {
|
|
2045
|
-
const
|
|
2046
|
-
if (
|
|
2047
|
-
|
|
2102
|
+
const g = document.createElement("div");
|
|
2103
|
+
if (g.className = "cell group-cell", g.setAttribute("data-col", String(h)), g.setAttribute("role", "gridcell"), ae(u)) {
|
|
2104
|
+
g.setAttribute("data-field", u.field), t.appendChild(g);
|
|
2048
2105
|
return;
|
|
2049
2106
|
}
|
|
2050
2107
|
if (c) {
|
|
2051
|
-
const
|
|
2052
|
-
if (
|
|
2053
|
-
const p =
|
|
2054
|
-
|
|
2108
|
+
const f = r[u.field];
|
|
2109
|
+
if (f) {
|
|
2110
|
+
const p = j(f, a, u.field, u);
|
|
2111
|
+
g.textContent = p != null ? String(p) : "";
|
|
2055
2112
|
} else
|
|
2056
|
-
|
|
2113
|
+
g.textContent = "";
|
|
2057
2114
|
} else {
|
|
2058
|
-
c = !0,
|
|
2059
|
-
const
|
|
2115
|
+
c = !0, g.appendChild(this.createToggleButton(e.__groupExpanded, i));
|
|
2116
|
+
const f = document.createElement("span"), p = r[u.field];
|
|
2060
2117
|
if (p) {
|
|
2061
|
-
const m =
|
|
2062
|
-
|
|
2118
|
+
const m = j(p, a, u.field, u);
|
|
2119
|
+
f.textContent = m != null ? String(m) : String(e.__groupValue);
|
|
2063
2120
|
} else
|
|
2064
|
-
|
|
2065
|
-
if (
|
|
2121
|
+
f.textContent = this.getGroupLabelText(e.__groupValue, e.__groupDepth || 0, e.__groupKey);
|
|
2122
|
+
if (g.appendChild(f), n.showRowCount !== !1) {
|
|
2066
2123
|
const m = document.createElement("span");
|
|
2067
|
-
m.className = "group-count", m.textContent = ` (${a.length})`,
|
|
2124
|
+
m.className = "group-count", m.textContent = ` (${a.length})`, g.appendChild(m);
|
|
2068
2125
|
}
|
|
2069
2126
|
}
|
|
2070
|
-
t.appendChild(
|
|
2127
|
+
t.appendChild(g);
|
|
2071
2128
|
});
|
|
2072
2129
|
}
|
|
2073
2130
|
expandAll() {
|
|
2074
|
-
this.expandedKeys =
|
|
2131
|
+
this.expandedKeys = Gt(this.flattenedRows), this.requestRender();
|
|
2075
2132
|
}
|
|
2076
2133
|
collapseAll() {
|
|
2077
|
-
this.expandedKeys =
|
|
2134
|
+
this.expandedKeys = Ot(), this.requestRender();
|
|
2078
2135
|
}
|
|
2079
2136
|
toggle(e) {
|
|
2080
|
-
this.expandedKeys =
|
|
2081
|
-
|
|
2137
|
+
const t = !this.expandedKeys.has(e), i = this.config, n = this.flattenedRows.find((r) => r.kind === "group" && r.key === e);
|
|
2138
|
+
if (i.accordion && t && n) {
|
|
2139
|
+
const r = /* @__PURE__ */ new Set();
|
|
2140
|
+
for (const o of this.expandedKeys)
|
|
2141
|
+
if (e.startsWith(o + "||") || o.startsWith(e + "||"))
|
|
2142
|
+
e.startsWith(o + "||") && r.add(o);
|
|
2143
|
+
else {
|
|
2144
|
+
const a = this.flattenedRows.find((l) => l.kind === "group" && l.key === o);
|
|
2145
|
+
a && a.depth !== n.depth && r.add(o);
|
|
2146
|
+
}
|
|
2147
|
+
r.add(e), this.expandedKeys = r;
|
|
2148
|
+
} else
|
|
2149
|
+
this.expandedKeys = zt(this.expandedKeys, e);
|
|
2082
2150
|
this.emit("group-toggle", {
|
|
2083
2151
|
key: e,
|
|
2084
2152
|
expanded: this.expandedKeys.has(e),
|
|
2085
|
-
value:
|
|
2086
|
-
depth:
|
|
2153
|
+
value: n?.value,
|
|
2154
|
+
depth: n?.depth ?? 0
|
|
2087
2155
|
}), this.requestRender();
|
|
2088
2156
|
}
|
|
2089
2157
|
isExpanded(e) {
|
|
@@ -2126,22 +2194,22 @@ class en extends R {
|
|
|
2126
2194
|
this.config.groupOn = e, this.requestRender();
|
|
2127
2195
|
}
|
|
2128
2196
|
}
|
|
2129
|
-
function
|
|
2197
|
+
function Ae(s, e) {
|
|
2130
2198
|
const t = new Set(s);
|
|
2131
2199
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
2132
2200
|
}
|
|
2133
|
-
function
|
|
2201
|
+
function jt(s, e) {
|
|
2134
2202
|
const t = new Set(s);
|
|
2135
2203
|
return t.add(e), t;
|
|
2136
2204
|
}
|
|
2137
|
-
function
|
|
2205
|
+
function Ut(s, e) {
|
|
2138
2206
|
const t = new Set(s);
|
|
2139
2207
|
return t.delete(e), t;
|
|
2140
2208
|
}
|
|
2141
|
-
function
|
|
2209
|
+
function Yt(s, e) {
|
|
2142
2210
|
return s.has(e);
|
|
2143
2211
|
}
|
|
2144
|
-
function
|
|
2212
|
+
function Xt(s, e, t, i) {
|
|
2145
2213
|
const n = document.createElement("div");
|
|
2146
2214
|
n.className = "master-detail-row", n.setAttribute("data-detail-for", String(e)), n.setAttribute("role", "row");
|
|
2147
2215
|
const r = document.createElement("div");
|
|
@@ -2149,10 +2217,10 @@ function $t(s, e, t, i) {
|
|
|
2149
2217
|
const o = t(s, e);
|
|
2150
2218
|
return typeof o == "string" ? r.innerHTML = o : o instanceof HTMLElement && r.appendChild(o), n.appendChild(r), n;
|
|
2151
2219
|
}
|
|
2152
|
-
const
|
|
2153
|
-
class
|
|
2220
|
+
const Zt = "@layer tbw-plugins{tbw-grid{.cell[data-field=__tbw_expander]{border-right:none!important;padding:0;display:flex;align-items:center;justify-content:center}.header-row .cell[data-field=__tbw_expander]{display:none}.header-row .cell[data-field=__tbw_expander]+.cell{grid-column:1 / 3}.master-detail-expander{display:flex;align-items:center;justify-content:center;width:100%;height:100%}.master-detail-toggle{cursor:pointer;opacity:.7;user-select:none;display:inline-flex;align-items:center;justify-content:center}.master-detail-toggle:hover{opacity:1}.master-detail-row{grid-column:1 / -1;display:grid;background:var(--tbw-master-detail-bg, var(--tbw-color-row-alt));border-bottom:1px solid var(--tbw-master-detail-border, var(--tbw-color-border));overflow:hidden}.master-detail-cell{padding:var(--tbw-detail-padding, var(--tbw-spacing-xl, 1rem));overflow:auto}.master-detail-row.tbw-expanding{animation:tbw-detail-expand var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}.master-detail-row.tbw-collapsing{animation:tbw-detail-collapse var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}}@keyframes tbw-detail-expand{0%{opacity:0;max-height:0;padding-top:0;padding-bottom:0}to{opacity:1;max-height:var(--tbw-detail-max-height, 31.25rem);padding-top:var(--tbw-detail-padding, var(--tbw-spacing-xl, 1rem));padding-bottom:var(--tbw-detail-padding, var(--tbw-spacing-xl, 1rem))}}@keyframes tbw-detail-collapse{0%{opacity:1;max-height:var(--tbw-detail-max-height, 31.25rem)}to{opacity:0;max-height:0}}}";
|
|
2221
|
+
class je extends R {
|
|
2154
2222
|
name = "masterDetail";
|
|
2155
|
-
styles =
|
|
2223
|
+
styles = Zt;
|
|
2156
2224
|
get defaultConfig() {
|
|
2157
2225
|
return {
|
|
2158
2226
|
detailHeight: "auto",
|
|
@@ -2181,8 +2249,8 @@ class Ve extends R {
|
|
|
2181
2249
|
n !== null && (d.animation = n === "false" ? !1 : n), r !== null && (d.showExpandColumn = r !== "false"), o !== null && (d.expandOnRowClick = o === "true"), a !== null && (d.collapseOnClickOutside = a === "true"), l !== null && (d.detailHeight = l === "auto" ? "auto" : parseInt(l, 10));
|
|
2182
2250
|
const c = t.innerHTML.trim();
|
|
2183
2251
|
c && !this.config.detailRenderer && (d.detailRenderer = (u, h) => {
|
|
2184
|
-
const
|
|
2185
|
-
return
|
|
2252
|
+
const g = et(c, { value: u, row: u });
|
|
2253
|
+
return tt(g);
|
|
2186
2254
|
}), Object.keys(d).length > 0 && (this.config = { ...this.config, ...d });
|
|
2187
2255
|
}
|
|
2188
2256
|
get animationStyle() {
|
|
@@ -2213,10 +2281,10 @@ class Ve extends R {
|
|
|
2213
2281
|
static DEFAULT_DETAIL_HEIGHT = 150;
|
|
2214
2282
|
getDetailHeight(e) {
|
|
2215
2283
|
const t = this.detailElements.get(e);
|
|
2216
|
-
return t ? t.offsetHeight : typeof this.config?.detailHeight == "number" ? this.config.detailHeight :
|
|
2284
|
+
return t ? t.offsetHeight : typeof this.config?.detailHeight == "number" ? this.config.detailHeight : je.DEFAULT_DETAIL_HEIGHT;
|
|
2217
2285
|
}
|
|
2218
2286
|
toggleAndEmit(e, t) {
|
|
2219
|
-
this.expandedRows =
|
|
2287
|
+
this.expandedRows = Ae(this.expandedRows, e), this.emit("detail-expand", {
|
|
2220
2288
|
rowIndex: t,
|
|
2221
2289
|
row: e,
|
|
2222
2290
|
expanded: this.expandedRows.has(e)
|
|
@@ -2229,9 +2297,9 @@ class Ve extends R {
|
|
|
2229
2297
|
if (!(this.config.showExpandColumn === !0 || this.config.showExpandColumn !== !1 && !!this.config.detailRenderer))
|
|
2230
2298
|
return [...e];
|
|
2231
2299
|
const i = [...e];
|
|
2232
|
-
if (
|
|
2300
|
+
if (ot(i))
|
|
2233
2301
|
return i;
|
|
2234
|
-
const r =
|
|
2302
|
+
const r = st(this.name);
|
|
2235
2303
|
return r.viewRenderer = (o) => {
|
|
2236
2304
|
const { row: a } = o, l = this.expandedRows.has(a), d = document.createElement("span");
|
|
2237
2305
|
d.className = "master-detail-expander expander-cell";
|
|
@@ -2251,7 +2319,7 @@ class Ve extends R {
|
|
|
2251
2319
|
onKeyDown(e) {
|
|
2252
2320
|
if (e.key !== " ") return;
|
|
2253
2321
|
const t = this.grid._focusCol, i = this.grid._focusRow, n = this.columns[t];
|
|
2254
|
-
if (!n || !
|
|
2322
|
+
if (!n || !ae(n)) return;
|
|
2255
2323
|
const r = this.rows[i];
|
|
2256
2324
|
if (r)
|
|
2257
2325
|
return e.preventDefault(), this.toggleAndEmit(r, i), this.requestRenderWithFocus(), !0;
|
|
@@ -2284,7 +2352,7 @@ class Ve extends R {
|
|
|
2284
2352
|
d.previousElementSibling !== a && a.after(d);
|
|
2285
2353
|
continue;
|
|
2286
2354
|
}
|
|
2287
|
-
const c =
|
|
2355
|
+
const c = Xt(l, o, this.config.detailRenderer, n);
|
|
2288
2356
|
typeof this.config.detailHeight == "number" && (c.style.height = `${this.config.detailHeight}px`), a.after(c), this.detailElements.set(l, c), this.animateExpand(c);
|
|
2289
2357
|
}
|
|
2290
2358
|
}
|
|
@@ -2319,19 +2387,19 @@ class Ve extends R {
|
|
|
2319
2387
|
}
|
|
2320
2388
|
expand(e) {
|
|
2321
2389
|
const t = this.rows[e];
|
|
2322
|
-
t && (this.expandedRows =
|
|
2390
|
+
t && (this.expandedRows = jt(this.expandedRows, t), this.requestRender());
|
|
2323
2391
|
}
|
|
2324
2392
|
collapse(e) {
|
|
2325
2393
|
const t = this.rows[e];
|
|
2326
|
-
t && (this.expandedRows =
|
|
2394
|
+
t && (this.expandedRows = Ut(this.expandedRows, t), this.requestRender());
|
|
2327
2395
|
}
|
|
2328
2396
|
toggle(e) {
|
|
2329
2397
|
const t = this.rows[e];
|
|
2330
|
-
t && (this.expandedRows =
|
|
2398
|
+
t && (this.expandedRows = Ae(this.expandedRows, t), this.requestRender());
|
|
2331
2399
|
}
|
|
2332
2400
|
isExpanded(e) {
|
|
2333
2401
|
const t = this.rows[e];
|
|
2334
|
-
return t ?
|
|
2402
|
+
return t ? Yt(this.expandedRows, t) : !1;
|
|
2335
2403
|
}
|
|
2336
2404
|
expandAll() {
|
|
2337
2405
|
for (const e of this.rows)
|
|
@@ -2361,34 +2429,34 @@ class Ve extends R {
|
|
|
2361
2429
|
}
|
|
2362
2430
|
}
|
|
2363
2431
|
}
|
|
2364
|
-
function
|
|
2432
|
+
function Jt(s, e, t) {
|
|
2365
2433
|
return e.length ? [...s].sort((i, n) => {
|
|
2366
2434
|
for (const r of e) {
|
|
2367
|
-
const a = t.find((u) => u.field === r.field)?.sortComparator ??
|
|
2435
|
+
const a = t.find((u) => u.field === r.field)?.sortComparator ?? Qt, l = i[r.field], d = n[r.field], c = a(l, d, i, n);
|
|
2368
2436
|
if (c !== 0)
|
|
2369
2437
|
return r.direction === "asc" ? c : -c;
|
|
2370
2438
|
}
|
|
2371
2439
|
return 0;
|
|
2372
2440
|
}) : [...s];
|
|
2373
2441
|
}
|
|
2374
|
-
function
|
|
2442
|
+
function Qt(s, e) {
|
|
2375
2443
|
return s == null && e == null ? 0 : s == null ? 1 : e == null ? -1 : typeof s == "number" && typeof e == "number" ? s - e : s instanceof Date && e instanceof Date ? s.getTime() - e.getTime() : typeof s == "boolean" && typeof e == "boolean" ? s === e ? 0 : s ? -1 : 1 : String(s).localeCompare(String(e));
|
|
2376
2444
|
}
|
|
2377
|
-
function
|
|
2445
|
+
function ei(s, e, t, i) {
|
|
2378
2446
|
const n = s.find((r) => r.field === e);
|
|
2379
2447
|
return t ? n ? n.direction === "asc" ? s.map((r) => r.field === e ? { ...r, direction: "desc" } : r) : s.filter((r) => r.field !== e) : s.length < i ? [...s, { field: e, direction: "asc" }] : s : n?.direction === "asc" ? [{ field: e, direction: "desc" }] : n?.direction === "desc" ? [] : [{ field: e, direction: "asc" }];
|
|
2380
2448
|
}
|
|
2381
|
-
function
|
|
2449
|
+
function _e(s, e) {
|
|
2382
2450
|
const t = s.findIndex((i) => i.field === e);
|
|
2383
2451
|
return t >= 0 ? t + 1 : void 0;
|
|
2384
2452
|
}
|
|
2385
|
-
function
|
|
2453
|
+
function Le(s, e) {
|
|
2386
2454
|
return s.find((t) => t.field === e)?.direction;
|
|
2387
2455
|
}
|
|
2388
|
-
const
|
|
2389
|
-
class
|
|
2456
|
+
const ti = '@layer tbw-plugins{.header-cell[data-sort=asc]:after{content:"↑";margin-left:4px;opacity:.8}.header-cell[data-sort=desc]:after{content:"↓";margin-left:4px;opacity:.8}.sort-indicator{margin-left:4px;opacity:.8}.sort-index{font-size:10px;background:var(--tbw-multi-sort-badge-bg, var(--tbw-color-panel-bg));color:var(--tbw-multi-sort-badge-color, var(--tbw-color-fg));border-radius:50%;width:14px;height:14px;display:inline-flex;align-items:center;justify-content:center;margin-left:2px;font-weight:600}}';
|
|
2457
|
+
class cn extends R {
|
|
2390
2458
|
name = "multiSort";
|
|
2391
|
-
styles =
|
|
2459
|
+
styles = ti;
|
|
2392
2460
|
get defaultConfig() {
|
|
2393
2461
|
return {
|
|
2394
2462
|
maxSortColumns: 3,
|
|
@@ -2400,12 +2468,12 @@ class tn extends R {
|
|
|
2400
2468
|
this.sortModel = [];
|
|
2401
2469
|
}
|
|
2402
2470
|
processRows(e) {
|
|
2403
|
-
return this.sortModel.length === 0 ? [...e] :
|
|
2471
|
+
return this.sortModel.length === 0 ? [...e] : Jt([...e], this.sortModel, [...this.columns]);
|
|
2404
2472
|
}
|
|
2405
2473
|
onHeaderClick(e) {
|
|
2406
2474
|
if (!this.columns.find((r) => r.field === e.field)?.sortable) return !1;
|
|
2407
2475
|
const i = e.originalEvent.shiftKey, n = this.config.maxSortColumns ?? 3;
|
|
2408
|
-
return this.sortModel =
|
|
2476
|
+
return this.sortModel = ei(this.sortModel, e.field, i, n), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), !0;
|
|
2409
2477
|
}
|
|
2410
2478
|
afterRender() {
|
|
2411
2479
|
const e = this.gridElement;
|
|
@@ -2414,15 +2482,15 @@ class tn extends R {
|
|
|
2414
2482
|
e.querySelectorAll(".header-row .cell[data-field]").forEach((n) => {
|
|
2415
2483
|
const r = n.getAttribute("data-field");
|
|
2416
2484
|
if (!r) return;
|
|
2417
|
-
const o =
|
|
2485
|
+
const o = _e(this.sortModel, r), a = Le(this.sortModel, r);
|
|
2418
2486
|
if (n.querySelector(".sort-index")?.remove(), a) {
|
|
2419
2487
|
n.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), n.setAttribute("data-sort", a);
|
|
2420
2488
|
const c = document.createElement("span");
|
|
2421
2489
|
c.className = "sort-indicator", this.setIcon(c, this.resolveIcon(a === "asc" ? "sortAsc" : "sortDesc"));
|
|
2422
|
-
const u = n.querySelector(".tbw-filter-btn"), h = n.querySelector(".resize-handle"),
|
|
2423
|
-
if (
|
|
2424
|
-
const
|
|
2425
|
-
|
|
2490
|
+
const u = n.querySelector(".tbw-filter-btn"), h = n.querySelector(".resize-handle"), g = u ?? h;
|
|
2491
|
+
if (g ? n.insertBefore(c, g) : n.appendChild(c), t && this.sortModel.length > 1 && o !== void 0) {
|
|
2492
|
+
const f = document.createElement("span");
|
|
2493
|
+
f.className = "sort-index", f.textContent = String(o), c.nextSibling ? n.insertBefore(f, c.nextSibling) : n.appendChild(f);
|
|
2426
2494
|
}
|
|
2427
2495
|
} else
|
|
2428
2496
|
n.removeAttribute("data-sort");
|
|
@@ -2438,10 +2506,10 @@ class tn extends R {
|
|
|
2438
2506
|
this.sortModel = [], this.emit("sort-change", { sortModel: [] }), this.requestRender();
|
|
2439
2507
|
}
|
|
2440
2508
|
getSortIndex(e) {
|
|
2441
|
-
return
|
|
2509
|
+
return _e(this.sortModel, e);
|
|
2442
2510
|
}
|
|
2443
2511
|
getSortDirection(e) {
|
|
2444
|
-
return
|
|
2512
|
+
return Le(this.sortModel, e);
|
|
2445
2513
|
}
|
|
2446
2514
|
getColumnState(e) {
|
|
2447
2515
|
const t = this.sortModel.findIndex((n) => n.field === e);
|
|
@@ -2464,16 +2532,16 @@ class tn extends R {
|
|
|
2464
2532
|
i !== -1 ? this.sortModel[i] = n : this.sortModel.splice(t.sort.priority, 0, n);
|
|
2465
2533
|
}
|
|
2466
2534
|
}
|
|
2467
|
-
function
|
|
2535
|
+
function ii(s) {
|
|
2468
2536
|
return s.filter((e) => e.sticky === "left");
|
|
2469
2537
|
}
|
|
2470
|
-
function
|
|
2538
|
+
function ni(s) {
|
|
2471
2539
|
return s.filter((e) => e.sticky === "right");
|
|
2472
2540
|
}
|
|
2473
|
-
function
|
|
2541
|
+
function Q(s) {
|
|
2474
2542
|
return s.some((e) => e.sticky === "left" || e.sticky === "right");
|
|
2475
2543
|
}
|
|
2476
|
-
function
|
|
2544
|
+
function Te(s, e) {
|
|
2477
2545
|
const t = Array.from(s.querySelectorAll(".header-row .cell"));
|
|
2478
2546
|
if (!t.length) return;
|
|
2479
2547
|
const i = /* @__PURE__ */ new Map();
|
|
@@ -2497,12 +2565,12 @@ function Ae(s, e) {
|
|
|
2497
2565
|
}), r += l.offsetWidth);
|
|
2498
2566
|
}
|
|
2499
2567
|
}
|
|
2500
|
-
function
|
|
2568
|
+
function Ie(s) {
|
|
2501
2569
|
s.querySelectorAll(".sticky-left, .sticky-right").forEach((t) => {
|
|
2502
2570
|
t.classList.remove("sticky-left", "sticky-right"), t.style.position = "", t.style.left = "", t.style.right = "";
|
|
2503
2571
|
});
|
|
2504
2572
|
}
|
|
2505
|
-
class
|
|
2573
|
+
class un extends R {
|
|
2506
2574
|
static manifest = {
|
|
2507
2575
|
ownedProperties: [
|
|
2508
2576
|
{
|
|
@@ -2525,26 +2593,26 @@ class nn extends R {
|
|
|
2525
2593
|
}
|
|
2526
2594
|
static detect(e, t) {
|
|
2527
2595
|
const i = t?.columns;
|
|
2528
|
-
return Array.isArray(i) ?
|
|
2596
|
+
return Array.isArray(i) ? Q(i) : !1;
|
|
2529
2597
|
}
|
|
2530
2598
|
processColumns(e) {
|
|
2531
|
-
return this.isApplied =
|
|
2599
|
+
return this.isApplied = Q([...e]), [...e];
|
|
2532
2600
|
}
|
|
2533
2601
|
afterRender() {
|
|
2534
2602
|
if (!this.isApplied)
|
|
2535
2603
|
return;
|
|
2536
2604
|
const e = this.grid, t = [...this.columns];
|
|
2537
|
-
if (!
|
|
2538
|
-
|
|
2605
|
+
if (!Q(t)) {
|
|
2606
|
+
Ie(e), this.isApplied = !1;
|
|
2539
2607
|
return;
|
|
2540
2608
|
}
|
|
2541
2609
|
queueMicrotask(() => {
|
|
2542
|
-
|
|
2610
|
+
Te(e, t);
|
|
2543
2611
|
});
|
|
2544
2612
|
}
|
|
2545
2613
|
onPluginQuery(e) {
|
|
2546
2614
|
switch (e.type) {
|
|
2547
|
-
case
|
|
2615
|
+
case We.CAN_MOVE_COLUMN: {
|
|
2548
2616
|
const t = e.context, i = t.sticky;
|
|
2549
2617
|
if (i === "left" || i === "right")
|
|
2550
2618
|
return !1;
|
|
@@ -2557,18 +2625,18 @@ class nn extends R {
|
|
|
2557
2625
|
}
|
|
2558
2626
|
refreshStickyOffsets() {
|
|
2559
2627
|
const e = [...this.columns];
|
|
2560
|
-
|
|
2628
|
+
Te(this.grid, e);
|
|
2561
2629
|
}
|
|
2562
2630
|
getLeftPinnedColumns() {
|
|
2563
2631
|
const e = [...this.columns];
|
|
2564
|
-
return
|
|
2632
|
+
return ii(e);
|
|
2565
2633
|
}
|
|
2566
2634
|
getRightPinnedColumns() {
|
|
2567
2635
|
const e = [...this.columns];
|
|
2568
|
-
return
|
|
2636
|
+
return ni(e);
|
|
2569
2637
|
}
|
|
2570
2638
|
clearStickyPositions() {
|
|
2571
|
-
|
|
2639
|
+
Ie(this.grid);
|
|
2572
2640
|
}
|
|
2573
2641
|
getHorizontalScrollOffsets(e, t) {
|
|
2574
2642
|
if (!this.isApplied)
|
|
@@ -2589,10 +2657,10 @@ class nn extends R {
|
|
|
2589
2657
|
return { left: i, right: n, skipScroll: r };
|
|
2590
2658
|
}
|
|
2591
2659
|
}
|
|
2592
|
-
function
|
|
2660
|
+
function ri(s) {
|
|
2593
2661
|
return typeof s == "object" && s !== null && "aggFunc" in s;
|
|
2594
2662
|
}
|
|
2595
|
-
function
|
|
2663
|
+
function ee(s, e) {
|
|
2596
2664
|
const t = document.createElement("div");
|
|
2597
2665
|
t.className = "tbw-pinned-rows", t.setAttribute("role", "presentation"), t.setAttribute("aria-live", "polite");
|
|
2598
2666
|
const i = document.createElement("div");
|
|
@@ -2614,7 +2682,7 @@ function Z(s, e) {
|
|
|
2614
2682
|
}
|
|
2615
2683
|
if (s.customPanels)
|
|
2616
2684
|
for (const o of s.customPanels) {
|
|
2617
|
-
const a =
|
|
2685
|
+
const a = oi(o, e);
|
|
2618
2686
|
switch (o.position) {
|
|
2619
2687
|
case "left":
|
|
2620
2688
|
i.appendChild(a);
|
|
@@ -2629,11 +2697,11 @@ function Z(s, e) {
|
|
|
2629
2697
|
}
|
|
2630
2698
|
return t.appendChild(i), t.appendChild(n), t.appendChild(r), t;
|
|
2631
2699
|
}
|
|
2632
|
-
function
|
|
2700
|
+
function Pe(s) {
|
|
2633
2701
|
const e = document.createElement("div");
|
|
2634
2702
|
return e.className = `tbw-aggregation-rows tbw-aggregation-rows-${s}`, e.setAttribute("role", "presentation"), e;
|
|
2635
2703
|
}
|
|
2636
|
-
function
|
|
2704
|
+
function De(s, e, t, i) {
|
|
2637
2705
|
s.innerHTML = "";
|
|
2638
2706
|
for (const n of e) {
|
|
2639
2707
|
const r = document.createElement("div");
|
|
@@ -2647,11 +2715,11 @@ function Te(s, e, t, i) {
|
|
|
2647
2715
|
let l, d;
|
|
2648
2716
|
const c = n.aggregators?.[o.field];
|
|
2649
2717
|
if (c)
|
|
2650
|
-
if (
|
|
2651
|
-
const u =
|
|
2718
|
+
if (ri(c)) {
|
|
2719
|
+
const u = ge(c.aggFunc);
|
|
2652
2720
|
u && (l = u(i, o.field, o)), d = c.formatter;
|
|
2653
2721
|
} else {
|
|
2654
|
-
const u =
|
|
2722
|
+
const u = ge(c);
|
|
2655
2723
|
u && (l = u(i, o.field, o));
|
|
2656
2724
|
}
|
|
2657
2725
|
else if (n.cells && Object.prototype.hasOwnProperty.call(n.cells, o.field)) {
|
|
@@ -2663,13 +2731,13 @@ function Te(s, e, t, i) {
|
|
|
2663
2731
|
s.appendChild(r);
|
|
2664
2732
|
}
|
|
2665
2733
|
}
|
|
2666
|
-
function
|
|
2734
|
+
function oi(s, e) {
|
|
2667
2735
|
const t = document.createElement("div");
|
|
2668
2736
|
t.className = "tbw-status-panel tbw-status-panel-custom", t.id = `status-panel-${s.id}`;
|
|
2669
2737
|
const i = s.render(e);
|
|
2670
2738
|
return typeof i == "string" ? t.innerHTML = i : t.appendChild(i), t;
|
|
2671
2739
|
}
|
|
2672
|
-
function
|
|
2740
|
+
function Fe(s, e, t, i, n) {
|
|
2673
2741
|
return {
|
|
2674
2742
|
totalRows: s.length,
|
|
2675
2743
|
filteredRows: n?.cachedResult?.length ?? s.length,
|
|
@@ -2679,10 +2747,10 @@ function Ie(s, e, t, i, n) {
|
|
|
2679
2747
|
grid: t
|
|
2680
2748
|
};
|
|
2681
2749
|
}
|
|
2682
|
-
const
|
|
2683
|
-
class
|
|
2750
|
+
const si = "@layer tbw-plugins{.tbw-footer{flex-shrink:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-color-panel-bg)}.tbw-pinned-rows{display:flex;align-items:center;justify-content:space-between;padding:var(--tbw-button-padding, var(--tbw-spacing-md, .5rem) var(--tbw-spacing-lg, .75rem));background:var(--tbw-pinned-rows-bg, var(--tbw-color-panel-bg));border-top:1px solid var(--tbw-pinned-rows-border, var(--tbw-color-border));font-size:var(--tbw-font-size-xs, .75rem);color:var(--tbw-pinned-rows-color, var(--tbw-color-fg-muted));min-height:32px;box-sizing:border-box;min-width:fit-content}.tbw-pinned-rows-left,.tbw-pinned-rows-center,.tbw-pinned-rows-right{display:flex;align-items:center;gap:var(--tbw-spacing-xl, 1rem)}.tbw-pinned-rows-left{justify-content:flex-start}.tbw-pinned-rows-center{justify-content:center;flex:1}.tbw-pinned-rows-right{justify-content:flex-end}.tbw-status-panel{white-space:nowrap}.tbw-aggregation-rows{min-width:fit-content;background:var(--tbw-aggregation-bg, var(--tbw-color-header-bg))}.tbw-aggregation-rows-top{border-bottom:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-rows-bottom{border-top:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-row{display:grid;grid-template-columns:var(--tbw-column-template);font-size:var(--tbw-aggregation-font-size, .8em);font-weight:var(--tbw-aggregation-font-weight, 600)}.tbw-aggregation-cell{padding:var(--tbw-cell-padding, .125rem .5rem);min-height:var(--tbw-row-height, 1.75rem);display:block;align-items:center;border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;text-overflow:ellipsis;white-space:var(--tbw-cell-white-space, nowrap)}.tbw-aggregation-cell:last-child{border-right:0}.tbw-aggregation-cell-full{grid-column:1 / -1;border-right:0}}";
|
|
2751
|
+
class hn extends R {
|
|
2684
2752
|
name = "pinnedRows";
|
|
2685
|
-
styles =
|
|
2753
|
+
styles = si;
|
|
2686
2754
|
get defaultConfig() {
|
|
2687
2755
|
return {
|
|
2688
2756
|
position: "bottom",
|
|
@@ -2704,7 +2772,7 @@ class rn extends R {
|
|
|
2704
2772
|
const t = e.querySelector(".tbw-scroll-area") ?? e.querySelector(".tbw-grid-content") ?? e.children[0];
|
|
2705
2773
|
if (!t) return;
|
|
2706
2774
|
this.footerWrapper && !t.contains(this.footerWrapper) && (this.footerWrapper = null, this.bottomAggregationContainer = null, this.infoBarElement = null), this.topAggregationContainer && !t.contains(this.topAggregationContainer) && (this.topAggregationContainer = null), this.infoBarElement && !t.contains(this.infoBarElement) && (this.infoBarElement = null);
|
|
2707
|
-
const i = this.getSelectionState(), n = this.getFilterState(), r =
|
|
2775
|
+
const i = this.getSelectionState(), n = this.getFilterState(), r = Fe(
|
|
2708
2776
|
this.rows,
|
|
2709
2777
|
this.columns,
|
|
2710
2778
|
this.grid,
|
|
@@ -2713,11 +2781,11 @@ class rn extends R {
|
|
|
2713
2781
|
), o = this.config.aggregationRows || [], a = o.filter((h) => h.position === "top"), l = o.filter((h) => h.position !== "top");
|
|
2714
2782
|
if (a.length > 0) {
|
|
2715
2783
|
if (!this.topAggregationContainer) {
|
|
2716
|
-
this.topAggregationContainer =
|
|
2784
|
+
this.topAggregationContainer = Pe("top");
|
|
2717
2785
|
const h = e.querySelector(".header");
|
|
2718
2786
|
h && h.nextSibling ? t.insertBefore(this.topAggregationContainer, h.nextSibling) : t.appendChild(this.topAggregationContainer);
|
|
2719
2787
|
}
|
|
2720
|
-
|
|
2788
|
+
De(
|
|
2721
2789
|
this.topAggregationContainer,
|
|
2722
2790
|
a,
|
|
2723
2791
|
this.visibleColumns,
|
|
@@ -2727,18 +2795,18 @@ class rn extends R {
|
|
|
2727
2795
|
const d = this.config.showRowCount !== !1 || this.config.showSelectedCount && r.selectedRows > 0 || this.config.showFilteredCount && r.filteredRows !== r.totalRows || this.config.customPanels && this.config.customPanels.length > 0, c = d && this.config.position !== "top", u = l.length > 0 || c;
|
|
2728
2796
|
if (d && this.config.position === "top")
|
|
2729
2797
|
if (!this.infoBarElement)
|
|
2730
|
-
this.infoBarElement =
|
|
2798
|
+
this.infoBarElement = ee(this.config, r), t.insertBefore(this.infoBarElement, t.firstChild);
|
|
2731
2799
|
else {
|
|
2732
|
-
const h =
|
|
2800
|
+
const h = ee(this.config, r);
|
|
2733
2801
|
this.infoBarElement.replaceWith(h), this.infoBarElement = h;
|
|
2734
2802
|
}
|
|
2735
2803
|
else this.config.position === "top" && this.infoBarElement && (this.infoBarElement.remove(), this.infoBarElement = null);
|
|
2736
|
-
u ? (this.footerWrapper || (this.footerWrapper = document.createElement("div"), this.footerWrapper.className = "tbw-footer", t.appendChild(this.footerWrapper)), this.footerWrapper.innerHTML = "", l.length > 0 && (this.bottomAggregationContainer || (this.bottomAggregationContainer =
|
|
2804
|
+
u ? (this.footerWrapper || (this.footerWrapper = document.createElement("div"), this.footerWrapper.className = "tbw-footer", t.appendChild(this.footerWrapper)), this.footerWrapper.innerHTML = "", l.length > 0 && (this.bottomAggregationContainer || (this.bottomAggregationContainer = Pe("bottom")), this.footerWrapper.appendChild(this.bottomAggregationContainer), De(
|
|
2737
2805
|
this.bottomAggregationContainer,
|
|
2738
2806
|
l,
|
|
2739
2807
|
this.visibleColumns,
|
|
2740
2808
|
this.rows
|
|
2741
|
-
)), c && (this.infoBarElement =
|
|
2809
|
+
)), c && (this.infoBarElement = ee(this.config, r), this.footerWrapper.appendChild(this.infoBarElement))) : this.cleanupFooter();
|
|
2742
2810
|
}
|
|
2743
2811
|
cleanup() {
|
|
2744
2812
|
this.infoBarElement && (this.infoBarElement.remove(), this.infoBarElement = null), this.topAggregationContainer && (this.topAggregationContainer.remove(), this.topAggregationContainer = null), this.bottomAggregationContainer && (this.bottomAggregationContainer.remove(), this.bottomAggregationContainer = null), this.footerWrapper && (this.footerWrapper.remove(), this.footerWrapper = null);
|
|
@@ -2765,7 +2833,7 @@ class rn extends R {
|
|
|
2765
2833
|
}
|
|
2766
2834
|
getContext() {
|
|
2767
2835
|
const e = this.getSelectionState(), t = this.getFilterState();
|
|
2768
|
-
return
|
|
2836
|
+
return Fe(
|
|
2769
2837
|
this.rows,
|
|
2770
2838
|
this.columns,
|
|
2771
2839
|
this.grid,
|
|
@@ -2786,16 +2854,16 @@ class rn extends R {
|
|
|
2786
2854
|
this.config.aggregationRows && (this.config.aggregationRows = this.config.aggregationRows.filter((t) => t.id !== e), this.requestRender());
|
|
2787
2855
|
}
|
|
2788
2856
|
}
|
|
2789
|
-
const
|
|
2790
|
-
function
|
|
2857
|
+
const ai = it;
|
|
2858
|
+
function li(s) {
|
|
2791
2859
|
const e = [];
|
|
2792
2860
|
return !s.rowGroupFields?.length && !s.columnGroupFields?.length && e.push("At least one row or column group field is required"), s.valueFields?.length || e.push("At least one value field is required"), e;
|
|
2793
2861
|
}
|
|
2794
|
-
function
|
|
2862
|
+
function ce(s, e) {
|
|
2795
2863
|
return [...s, e].join("|");
|
|
2796
2864
|
}
|
|
2797
|
-
function
|
|
2798
|
-
const t = e.rowGroupFields ?? [], i = e.columnGroupFields ?? [], n = e.valueFields ?? [], r =
|
|
2865
|
+
function di(s, e) {
|
|
2866
|
+
const t = e.rowGroupFields ?? [], i = e.columnGroupFields ?? [], n = e.valueFields ?? [], r = ci(s, i), o = Ue(
|
|
2799
2867
|
s,
|
|
2800
2868
|
t,
|
|
2801
2869
|
i,
|
|
@@ -2803,7 +2871,7 @@ function oi(s, e) {
|
|
|
2803
2871
|
n,
|
|
2804
2872
|
0,
|
|
2805
2873
|
""
|
|
2806
|
-
), a =
|
|
2874
|
+
), a = hi(o, r, n), l = Object.values(a).reduce((d, c) => d + c, 0);
|
|
2807
2875
|
return {
|
|
2808
2876
|
rows: o,
|
|
2809
2877
|
columnKeys: r,
|
|
@@ -2811,7 +2879,7 @@ function oi(s, e) {
|
|
|
2811
2879
|
grandTotal: l
|
|
2812
2880
|
};
|
|
2813
2881
|
}
|
|
2814
|
-
function
|
|
2882
|
+
function ci(s, e) {
|
|
2815
2883
|
if (e.length === 0) return ["value"];
|
|
2816
2884
|
const t = /* @__PURE__ */ new Set();
|
|
2817
2885
|
for (const i of s) {
|
|
@@ -2820,7 +2888,7 @@ function si(s, e) {
|
|
|
2820
2888
|
}
|
|
2821
2889
|
return [...t].sort();
|
|
2822
2890
|
}
|
|
2823
|
-
function
|
|
2891
|
+
function ui(s, e) {
|
|
2824
2892
|
const t = /* @__PURE__ */ new Map();
|
|
2825
2893
|
for (const i of s) {
|
|
2826
2894
|
const n = String(i[e] ?? ""), r = t.get(n);
|
|
@@ -2828,75 +2896,75 @@ function ai(s, e) {
|
|
|
2828
2896
|
}
|
|
2829
2897
|
return t;
|
|
2830
2898
|
}
|
|
2831
|
-
function
|
|
2899
|
+
function Ue(s, e, t, i, n, r, o) {
|
|
2832
2900
|
const a = [];
|
|
2833
2901
|
if (e.length === 0) {
|
|
2834
|
-
const h =
|
|
2902
|
+
const h = Me(s, t, i, n), g = qe(h);
|
|
2835
2903
|
return a.push({
|
|
2836
2904
|
rowKey: o || "all",
|
|
2837
2905
|
rowLabel: o || "All",
|
|
2838
2906
|
depth: r,
|
|
2839
2907
|
values: h,
|
|
2840
|
-
total:
|
|
2908
|
+
total: g,
|
|
2841
2909
|
isGroup: !1,
|
|
2842
2910
|
rowCount: s.length
|
|
2843
2911
|
}), a;
|
|
2844
2912
|
}
|
|
2845
|
-
const l = e[0], d = e.slice(1), c = d.length > 0, u =
|
|
2846
|
-
for (const [h,
|
|
2847
|
-
const
|
|
2913
|
+
const l = e[0], d = e.slice(1), c = d.length > 0, u = ui(s, l);
|
|
2914
|
+
for (const [h, g] of u) {
|
|
2915
|
+
const f = o ? `${o}|${h}` : h, p = Me(g, t, i, n), m = qe(p);
|
|
2848
2916
|
let w;
|
|
2849
|
-
c && (w =
|
|
2850
|
-
|
|
2917
|
+
c && (w = Ue(
|
|
2918
|
+
g,
|
|
2851
2919
|
d,
|
|
2852
2920
|
t,
|
|
2853
2921
|
i,
|
|
2854
2922
|
n,
|
|
2855
2923
|
r + 1,
|
|
2856
|
-
|
|
2924
|
+
f
|
|
2857
2925
|
)), a.push({
|
|
2858
|
-
rowKey:
|
|
2926
|
+
rowKey: f,
|
|
2859
2927
|
rowLabel: h || "(blank)",
|
|
2860
2928
|
depth: r,
|
|
2861
2929
|
values: p,
|
|
2862
2930
|
total: m,
|
|
2863
2931
|
isGroup: c,
|
|
2864
2932
|
children: w,
|
|
2865
|
-
rowCount:
|
|
2933
|
+
rowCount: g.length
|
|
2866
2934
|
});
|
|
2867
2935
|
}
|
|
2868
2936
|
return a;
|
|
2869
2937
|
}
|
|
2870
|
-
function
|
|
2938
|
+
function Me(s, e, t, i) {
|
|
2871
2939
|
const n = {};
|
|
2872
2940
|
for (const r of t)
|
|
2873
2941
|
for (const o of i) {
|
|
2874
|
-
const l = (e.length > 0 ? s.filter((h) => e.map((
|
|
2942
|
+
const l = (e.length > 0 ? s.filter((h) => e.map((g) => String(h[g] ?? "")).join("|") === r) : s).map((h) => Number(h[o.field]) || 0), d = ai(o.aggFunc), c = l.length > 0 ? d(l) : null, u = ce([r], o.field);
|
|
2875
2943
|
n[u] = c;
|
|
2876
2944
|
}
|
|
2877
2945
|
return n;
|
|
2878
2946
|
}
|
|
2879
|
-
function
|
|
2947
|
+
function qe(s) {
|
|
2880
2948
|
let e = 0;
|
|
2881
2949
|
for (const t of Object.values(s))
|
|
2882
2950
|
e += t ?? 0;
|
|
2883
2951
|
return e;
|
|
2884
2952
|
}
|
|
2885
|
-
function
|
|
2953
|
+
function hi(s, e, t) {
|
|
2886
2954
|
const i = {};
|
|
2887
2955
|
function n(r) {
|
|
2888
2956
|
for (const o of r)
|
|
2889
2957
|
if (!o.isGroup || !o.children?.length)
|
|
2890
2958
|
for (const a of e)
|
|
2891
2959
|
for (const l of t) {
|
|
2892
|
-
const d =
|
|
2960
|
+
const d = ce([a], l.field);
|
|
2893
2961
|
i[d] = (i[d] ?? 0) + (o.values[d] ?? 0);
|
|
2894
2962
|
}
|
|
2895
2963
|
else o.children && n(o.children);
|
|
2896
2964
|
}
|
|
2897
2965
|
return n(s), i;
|
|
2898
2966
|
}
|
|
2899
|
-
function
|
|
2967
|
+
function gi(s, e, t = !0) {
|
|
2900
2968
|
const i = [];
|
|
2901
2969
|
function n(r) {
|
|
2902
2970
|
i.push(r);
|
|
@@ -2909,7 +2977,7 @@ function di(s, e, t = !0) {
|
|
|
2909
2977
|
n(r);
|
|
2910
2978
|
return i;
|
|
2911
2979
|
}
|
|
2912
|
-
function
|
|
2980
|
+
function fi(s) {
|
|
2913
2981
|
const e = [];
|
|
2914
2982
|
function t(i) {
|
|
2915
2983
|
if (i.isGroup && e.push(i.rowKey), i.children)
|
|
@@ -2920,10 +2988,10 @@ function ci(s) {
|
|
|
2920
2988
|
t(i);
|
|
2921
2989
|
return e;
|
|
2922
2990
|
}
|
|
2923
|
-
const
|
|
2924
|
-
function
|
|
2991
|
+
const pi = ["sum", "avg", "count", "min", "max", "first", "last"];
|
|
2992
|
+
function mi(s, e, t, i) {
|
|
2925
2993
|
const n = new AbortController(), r = { config: e, callbacks: i, signal: n.signal }, o = document.createElement("div");
|
|
2926
|
-
return o.className = "tbw-pivot-panel", o.appendChild(H("Options", () =>
|
|
2994
|
+
return o.className = "tbw-pivot-panel", o.appendChild(H("Options", () => xi(t, r))), o.appendChild(H("Row Groups", () => Ke("rowGroups", r))), o.appendChild(H("Column Groups", () => Ke("columnGroups", r))), o.appendChild(H("Values", () => bi(r))), o.appendChild(H("Available Fields", () => yi(r))), s.appendChild(o), () => {
|
|
2927
2995
|
n.abort(), o.remove();
|
|
2928
2996
|
};
|
|
2929
2997
|
}
|
|
@@ -2935,7 +3003,7 @@ function H(s, e) {
|
|
|
2935
3003
|
const n = document.createElement("div");
|
|
2936
3004
|
return n.className = "tbw-pivot-section-content", n.appendChild(e()), t.appendChild(i), t.appendChild(n), t;
|
|
2937
3005
|
}
|
|
2938
|
-
function
|
|
3006
|
+
function Ke(s, e) {
|
|
2939
3007
|
const { config: t, callbacks: i, signal: n } = e, r = document.createElement("div");
|
|
2940
3008
|
r.className = "tbw-pivot-drop-zone", r.setAttribute("data-zone", s);
|
|
2941
3009
|
const o = s === "rowGroups" ? t.rowGroupFields ?? [] : t.columnGroupFields ?? [];
|
|
@@ -2944,7 +3012,7 @@ function Pe(s, e) {
|
|
|
2944
3012
|
a.className = "tbw-pivot-placeholder", a.textContent = "Drag fields here or click to add", r.appendChild(a);
|
|
2945
3013
|
} else
|
|
2946
3014
|
for (const a of o)
|
|
2947
|
-
r.appendChild(
|
|
3015
|
+
r.appendChild(wi(a, s, e));
|
|
2948
3016
|
return r.addEventListener(
|
|
2949
3017
|
"dragover",
|
|
2950
3018
|
(a) => {
|
|
@@ -2967,7 +3035,7 @@ function Pe(s, e) {
|
|
|
2967
3035
|
{ signal: n }
|
|
2968
3036
|
), r;
|
|
2969
3037
|
}
|
|
2970
|
-
function
|
|
3038
|
+
function wi(s, e, t) {
|
|
2971
3039
|
const { callbacks: i, signal: n } = t, r = document.createElement("div");
|
|
2972
3040
|
r.className = "tbw-pivot-field-chip", r.draggable = !0;
|
|
2973
3041
|
const o = i.getAvailableFields().find((d) => d.field === s), a = document.createElement("span");
|
|
@@ -2993,7 +3061,7 @@ function fi(s, e, t) {
|
|
|
2993
3061
|
{ signal: n }
|
|
2994
3062
|
), r;
|
|
2995
3063
|
}
|
|
2996
|
-
function
|
|
3064
|
+
function bi(s) {
|
|
2997
3065
|
const { config: e, callbacks: t, signal: i } = s, n = document.createElement("div");
|
|
2998
3066
|
n.className = "tbw-pivot-drop-zone tbw-pivot-values-zone", n.setAttribute("data-zone", "values");
|
|
2999
3067
|
const r = e.valueFields ?? [];
|
|
@@ -3002,7 +3070,7 @@ function gi(s) {
|
|
|
3002
3070
|
o.className = "tbw-pivot-placeholder", o.textContent = "Drag numeric fields here for aggregation", n.appendChild(o);
|
|
3003
3071
|
} else
|
|
3004
3072
|
for (const o of r)
|
|
3005
|
-
n.appendChild(
|
|
3073
|
+
n.appendChild(vi(o, s));
|
|
3006
3074
|
return n.addEventListener(
|
|
3007
3075
|
"dragover",
|
|
3008
3076
|
(o) => {
|
|
@@ -3025,7 +3093,7 @@ function gi(s) {
|
|
|
3025
3093
|
{ signal: i }
|
|
3026
3094
|
), n;
|
|
3027
3095
|
}
|
|
3028
|
-
function
|
|
3096
|
+
function vi(s, e) {
|
|
3029
3097
|
const { callbacks: t, signal: i } = e, n = document.createElement("div");
|
|
3030
3098
|
n.className = "tbw-pivot-field-chip tbw-pivot-value-chip";
|
|
3031
3099
|
const r = t.getAvailableFields().find((c) => c.field === s.field), o = document.createElement("div");
|
|
@@ -3034,7 +3102,7 @@ function pi(s, e) {
|
|
|
3034
3102
|
a.className = "tbw-pivot-chip-label", a.textContent = r?.header ?? s.field;
|
|
3035
3103
|
const l = document.createElement("select");
|
|
3036
3104
|
l.className = "tbw-pivot-agg-select", l.title = "Aggregation function";
|
|
3037
|
-
for (const c of
|
|
3105
|
+
for (const c of pi) {
|
|
3038
3106
|
const u = document.createElement("option");
|
|
3039
3107
|
u.value = c, u.textContent = c.toUpperCase(), u.selected = c === s.aggFunc, l.appendChild(u);
|
|
3040
3108
|
}
|
|
@@ -3054,7 +3122,7 @@ function pi(s, e) {
|
|
|
3054
3122
|
{ signal: i }
|
|
3055
3123
|
), o.appendChild(a), o.appendChild(l), n.appendChild(o), n.appendChild(d), n;
|
|
3056
3124
|
}
|
|
3057
|
-
function
|
|
3125
|
+
function yi(s) {
|
|
3058
3126
|
const { config: e, callbacks: t, signal: i } = s, n = document.createElement("div");
|
|
3059
3127
|
n.className = "tbw-pivot-available-fields";
|
|
3060
3128
|
const r = t.getAvailableFields(), o = /* @__PURE__ */ new Set([
|
|
@@ -3084,10 +3152,10 @@ function mi(s) {
|
|
|
3084
3152
|
}
|
|
3085
3153
|
return n;
|
|
3086
3154
|
}
|
|
3087
|
-
function
|
|
3155
|
+
function xi(s, e) {
|
|
3088
3156
|
const { config: t, callbacks: i, signal: n } = e, r = document.createElement("div");
|
|
3089
3157
|
return r.className = "tbw-pivot-options", r.appendChild(
|
|
3090
|
-
|
|
3158
|
+
te(
|
|
3091
3159
|
"Enable Pivot View",
|
|
3092
3160
|
s,
|
|
3093
3161
|
(o) => {
|
|
@@ -3096,7 +3164,7 @@ function wi(s, e) {
|
|
|
3096
3164
|
n
|
|
3097
3165
|
)
|
|
3098
3166
|
), r.appendChild(
|
|
3099
|
-
|
|
3167
|
+
te(
|
|
3100
3168
|
"Show Row Totals",
|
|
3101
3169
|
t.showTotals ?? !0,
|
|
3102
3170
|
(o) => {
|
|
@@ -3105,7 +3173,7 @@ function wi(s, e) {
|
|
|
3105
3173
|
n
|
|
3106
3174
|
)
|
|
3107
3175
|
), r.appendChild(
|
|
3108
|
-
|
|
3176
|
+
te(
|
|
3109
3177
|
"Show Grand Total",
|
|
3110
3178
|
t.showGrandTotal ?? !0,
|
|
3111
3179
|
(o) => {
|
|
@@ -3115,7 +3183,7 @@ function wi(s, e) {
|
|
|
3115
3183
|
)
|
|
3116
3184
|
), r;
|
|
3117
3185
|
}
|
|
3118
|
-
function
|
|
3186
|
+
function te(s, e, t, i) {
|
|
3119
3187
|
const n = document.createElement("label");
|
|
3120
3188
|
n.className = "tbw-pivot-checkbox";
|
|
3121
3189
|
const r = document.createElement("input");
|
|
@@ -3123,7 +3191,7 @@ function J(s, e, t, i) {
|
|
|
3123
3191
|
const o = document.createElement("span");
|
|
3124
3192
|
return o.textContent = s, n.appendChild(r), n.appendChild(o), n;
|
|
3125
3193
|
}
|
|
3126
|
-
function
|
|
3194
|
+
function Ci(s, e, t) {
|
|
3127
3195
|
return e.className = "data-grid-row pivot-group-row", e.setAttribute("data-pivot-depth", String(s.__pivotDepth ?? 0)), e.setAttribute("data-pivot-key", String(s.__pivotRowKey ?? "")), e.setAttribute("role", "row"), e.innerHTML = "", t.columns.forEach((i, n) => {
|
|
3128
3196
|
const r = document.createElement("div");
|
|
3129
3197
|
if (r.className = "cell", r.setAttribute("data-col", String(n)), r.setAttribute("data-row", String(t.rowIndex)), r.setAttribute("role", "gridcell"), n === 0) {
|
|
@@ -3144,7 +3212,7 @@ function bi(s, e, t) {
|
|
|
3144
3212
|
e.appendChild(r);
|
|
3145
3213
|
}), !0;
|
|
3146
3214
|
}
|
|
3147
|
-
function
|
|
3215
|
+
function Ri(s, e, t, i) {
|
|
3148
3216
|
return e.className = "data-grid-row pivot-leaf-row", e.setAttribute("data-pivot-depth", String(s.__pivotDepth ?? 0)), e.setAttribute("data-pivot-key", String(s.__pivotRowKey ?? "")), e.innerHTML = "", t.forEach((n, r) => {
|
|
3149
3217
|
const o = document.createElement("div");
|
|
3150
3218
|
if (o.className = "cell", o.setAttribute("data-col", String(r)), o.setAttribute("data-row", String(i)), o.setAttribute("role", "gridcell"), r === 0) {
|
|
@@ -3159,7 +3227,7 @@ function vi(s, e, t, i) {
|
|
|
3159
3227
|
e.appendChild(o);
|
|
3160
3228
|
}), !0;
|
|
3161
3229
|
}
|
|
3162
|
-
function
|
|
3230
|
+
function Ei(s, e, t) {
|
|
3163
3231
|
return e.className = "pivot-grand-total-row", e.setAttribute("role", "presentation"), e.innerHTML = "", t.forEach((i, n) => {
|
|
3164
3232
|
const r = document.createElement("div");
|
|
3165
3233
|
if (r.className = "cell", r.setAttribute("data-col", String(n)), n === 0) {
|
|
@@ -3172,10 +3240,10 @@ function yi(s, e, t) {
|
|
|
3172
3240
|
e.appendChild(r);
|
|
3173
3241
|
}), !0;
|
|
3174
3242
|
}
|
|
3175
|
-
const
|
|
3176
|
-
class
|
|
3243
|
+
const Si = '@layer tbw-plugins{.pivot-group-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:600;background:var(--tbw-pivot-group-bg, var(--tbw-color-row-alt));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-group-row:hover{background:var(--tbw-pivot-group-hover, var(--tbw-color-row-hover))}.pivot-leaf-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-pivot-leaf-bg, var(--tbw-color-bg));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-grand-total-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:700;background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-height:var(--tbw-row-height);border-top:2px solid var(--tbw-color-border-strong)}.pivot-grand-total-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-grand-total-row>.cell:last-child{border-right:0}.pivot-grand-total-footer{position:sticky;bottom:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-width:fit-content}.pivot-group-row>.cell,.pivot-leaf-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-group-row>.cell:last-child,.pivot-leaf-row>.cell:last-child{border-right:0}.pivot-toggle{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;margin-right:6px;border:none;background:transparent;cursor:pointer;color:var(--tbw-pivot-toggle-color, var(--tbw-color-fg-muted));border-radius:var(--tbw-border-radius);transition:background .15s,color .15s}.pivot-toggle:hover{background:var(--tbw-pivot-toggle-hover-bg, var(--tbw-color-row-hover));color:var(--tbw-pivot-toggle-hover-color, var(--tbw-color-fg))}.pivot-toggle:focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}.pivot-label{font-weight:inherit}.pivot-count{color:var(--tbw-pivot-count-color, var(--tbw-color-fg-muted));font-size:.9em;font-weight:400}.pivot-total-row{font-weight:700;border-top:2px solid var(--tbw-pivot-border, var(--tbw-color-border-strong))}[data-pivot-depth="1"]{--tbw-pivot-depth: 1}[data-pivot-depth="2"]{--tbw-pivot-depth: 2}[data-pivot-depth="3"]{--tbw-pivot-depth: 3}[data-pivot-depth="4"]{--tbw-pivot-depth: 4}.tbw-pivot-panel{display:flex;flex-direction:column;gap:var(--tbw-panel-padding, var(--tbw-spacing-lg, .75rem));padding:var(--tbw-panel-padding, var(--tbw-spacing-lg, .75rem));height:100%;overflow-y:auto;font-size:var(--tbw-font-size-sm, .8125rem)}.tbw-pivot-section{border:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-section-bg, var(--tbw-color-bg))}.tbw-pivot-section-header{padding:var(--tbw-button-padding, var(--tbw-spacing-md, .5rem) var(--tbw-spacing-lg, .75rem));font-weight:600;background:var(--tbw-pivot-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius) var(--tbw-border-radius) 0 0}.tbw-pivot-section-content{padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-pivot-toggle-wrapper{display:flex;align-items:center}.tbw-pivot-toggle-label{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));cursor:pointer}.tbw-pivot-toggle-label input{width:var(--tbw-icon-size, 1rem);height:var(--tbw-icon-size, 1rem);cursor:pointer}.tbw-pivot-drop-zone{min-height:60px;padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border:2px dashed var(--tbw-pivot-drop-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-drop-bg, var(--tbw-color-row-alt));display:flex;flex-wrap:wrap;gap:var(--tbw-spacing-sm, .375rem);align-content:flex-start;transition:all .15s ease}.tbw-pivot-drop-zone.drag-over{border-color:var(--tbw-color-accent);background:var(--tbw-pivot-drop-active, var(--tbw-focus-background))}.tbw-pivot-placeholder{color:var(--tbw-color-fg-muted);font-style:italic;padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));text-align:center;width:100%}.tbw-pivot-field-chip{display:inline-flex;align-items:center;gap:var(--tbw-spacing-sm, .375rem);padding:var(--tbw-button-padding-sm, var(--tbw-spacing-xs, .25rem) var(--tbw-spacing-md, .5rem));background:var(--tbw-pivot-chip-bg, var(--tbw-color-header-bg));border:1px solid var(--tbw-pivot-chip-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);cursor:grab;font-size:var(--tbw-font-size-xs, .75rem);transition:all .15s ease}.tbw-pivot-field-chip:hover{background:var(--tbw-pivot-chip-hover, var(--tbw-color-row-hover));border-color:var(--tbw-color-accent)}.tbw-pivot-field-chip.available{background:var(--tbw-color-bg)}.tbw-pivot-field-chip.dragging{opacity:.5;cursor:grabbing}.tbw-pivot-chip-label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:120px}.tbw-pivot-chip-remove{display:flex;align-items:center;justify-content:center;width:var(--tbw-icon-size, 1rem);height:var(--tbw-icon-size, 1rem);padding:0;border:none;background:transparent;color:var(--tbw-color-fg-muted);font-size:var(--tbw-font-size-sm, .875rem);font-weight:700;cursor:pointer;border-radius:50%;transition:all .15s ease}.tbw-pivot-chip-remove:hover{background:var(--tbw-pivot-chip-remove-hover-bg, var(--tbw-color-accent));color:var(--tbw-pivot-chip-remove-hover-fg, var(--tbw-color-accent-fg))}.tbw-pivot-value-chip{padding:var(--tbw-button-padding-sm, var(--tbw-spacing-xs, .25rem) var(--tbw-spacing-md, .5rem))}.tbw-pivot-value-label-wrapper{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));flex:1;min-width:0}.tbw-pivot-agg-select{padding:var(--tbw-spacing-xs, .125rem) var(--tbw-spacing-xs, .25rem);font-size:var(--tbw-font-size-xs, .6875rem);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);cursor:pointer}.tbw-pivot-available-fields{display:flex;flex-wrap:wrap;gap:var(--tbw-spacing-sm, .375rem);min-height:40px}.tbw-pivot-options{display:flex;flex-direction:column;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-pivot-checkbox{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));cursor:pointer}.tbw-pivot-checkbox input{width:var(--tbw-icon-size-sm, .875rem);height:var(--tbw-icon-size-sm, .875rem);cursor:pointer}.pivot-group-row.tbw-pivot-slide-in,.pivot-leaf-row.tbw-pivot-slide-in{animation:tbw-pivot-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-pivot-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}.pivot-group-row.tbw-pivot-fade-in,.pivot-leaf-row.tbw-pivot-fade-in{animation:tbw-pivot-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-pivot-fade-in{0%{opacity:0}to{opacity:1}}}';
|
|
3244
|
+
class F extends R {
|
|
3177
3245
|
name = "pivot";
|
|
3178
|
-
styles =
|
|
3246
|
+
styles = Si;
|
|
3179
3247
|
static PANEL_ID = "pivot";
|
|
3180
3248
|
get defaultConfig() {
|
|
3181
3249
|
return {
|
|
@@ -3209,7 +3277,7 @@ class P extends R {
|
|
|
3209
3277
|
getToolPanel() {
|
|
3210
3278
|
if ((this.config?.showToolPanel ?? this.userConfig?.showToolPanel ?? !0) !== !1)
|
|
3211
3279
|
return {
|
|
3212
|
-
id:
|
|
3280
|
+
id: F.PANEL_ID,
|
|
3213
3281
|
title: "Pivot",
|
|
3214
3282
|
icon: "⊞",
|
|
3215
3283
|
tooltip: "Configure pivot table",
|
|
@@ -3220,11 +3288,11 @@ class P extends R {
|
|
|
3220
3288
|
processRows(e) {
|
|
3221
3289
|
if (!this.hasInitialized && this.config.active !== !1 && this.hasValidPivotConfig() && (this.hasInitialized = !0, this.isActive = !0), !this.isActive)
|
|
3222
3290
|
return [...e];
|
|
3223
|
-
const t =
|
|
3291
|
+
const t = li(this.config);
|
|
3224
3292
|
if (t.length > 0)
|
|
3225
3293
|
return this.warn(`Config errors: ${t.join(", ")}`), [...e];
|
|
3226
|
-
this.buildFieldHeaderMap(), this.defaultExpanded = this.config.defaultExpanded ?? !0, this.expandedKeys.size === 0 && this.defaultExpanded && this.pivotResult && this.expandAllKeys(), this.pivotResult =
|
|
3227
|
-
const i = this.config.indentWidth ?? 20, n =
|
|
3294
|
+
this.buildFieldHeaderMap(), this.defaultExpanded = this.config.defaultExpanded ?? !0, this.expandedKeys.size === 0 && this.defaultExpanded && this.pivotResult && this.expandAllKeys(), this.pivotResult = di(e, this.config), this.expandedKeys.size === 0 && this.defaultExpanded && this.expandAllKeys();
|
|
3295
|
+
const i = this.config.indentWidth ?? 20, n = gi(
|
|
3228
3296
|
this.pivotResult.rows,
|
|
3229
3297
|
this.expandedKeys,
|
|
3230
3298
|
this.defaultExpanded
|
|
@@ -3259,7 +3327,7 @@ class P extends R {
|
|
|
3259
3327
|
});
|
|
3260
3328
|
for (const n of this.pivotResult.columnKeys)
|
|
3261
3329
|
for (const r of this.config.valueFields ?? []) {
|
|
3262
|
-
const o =
|
|
3330
|
+
const o = ce([n], r.field), a = r.header || this.fieldHeaderMap.get(r.field) || r.field;
|
|
3263
3331
|
t.push({
|
|
3264
3332
|
field: o,
|
|
3265
3333
|
header: `${n} - ${a} (${r.aggFunc})`,
|
|
@@ -3276,13 +3344,13 @@ class P extends R {
|
|
|
3276
3344
|
}
|
|
3277
3345
|
renderRow(e, t, i) {
|
|
3278
3346
|
const n = e;
|
|
3279
|
-
return n.__pivotRowKey && n.__pivotHasChildren ?
|
|
3347
|
+
return n.__pivotRowKey && n.__pivotHasChildren ? Ci(n, t, {
|
|
3280
3348
|
columns: this.gridColumns,
|
|
3281
3349
|
rowIndex: i,
|
|
3282
3350
|
onToggle: (r) => this.toggle(r),
|
|
3283
3351
|
resolveIcon: (r) => this.resolveIcon(r),
|
|
3284
3352
|
setIcon: (r, o) => this.setIcon(r, o)
|
|
3285
|
-
}) : n.__pivotRowKey !== void 0 && this.isActive ?
|
|
3353
|
+
}) : n.__pivotRowKey !== void 0 && this.isActive ? Ri(n, t, this.gridColumns, i) : (this.cleanupPivotStyling(t), !1);
|
|
3286
3354
|
}
|
|
3287
3355
|
cleanupPivotStyling(e) {
|
|
3288
3356
|
(e.classList.contains("pivot-group-row") || e.classList.contains("pivot-leaf-row") || e.classList.contains("pivot-grand-total-row")) && (e.classList.remove("pivot-group-row", "pivot-leaf-row", "pivot-grand-total-row"), e.classList.add("data-grid-row"), e.removeAttribute("data-pivot-depth"), e.innerHTML = "");
|
|
@@ -3320,7 +3388,7 @@ class P extends R {
|
|
|
3320
3388
|
__pivotTotal: this.pivotResult.grandTotal,
|
|
3321
3389
|
...this.pivotResult.totals
|
|
3322
3390
|
};
|
|
3323
|
-
|
|
3391
|
+
Ei(i, this.grandTotalFooter, this.gridColumns);
|
|
3324
3392
|
}
|
|
3325
3393
|
cleanupGrandTotalFooter() {
|
|
3326
3394
|
this.grandTotalFooter && (this.grandTotalFooter.remove(), this.grandTotalFooter = null);
|
|
@@ -3342,7 +3410,7 @@ class P extends R {
|
|
|
3342
3410
|
}
|
|
3343
3411
|
expandAllKeys() {
|
|
3344
3412
|
if (!this.pivotResult) return;
|
|
3345
|
-
const e =
|
|
3413
|
+
const e = fi(this.pivotResult.rows);
|
|
3346
3414
|
for (const t of e)
|
|
3347
3415
|
this.expandedKeys.add(t);
|
|
3348
3416
|
}
|
|
@@ -3374,16 +3442,16 @@ class P extends R {
|
|
|
3374
3442
|
this.pivotResult = null, this.requestRender();
|
|
3375
3443
|
}
|
|
3376
3444
|
showPanel() {
|
|
3377
|
-
this.grid.openToolPanel(), this.grid.expandedToolPanelSections.includes(
|
|
3445
|
+
this.grid.openToolPanel(), this.grid.expandedToolPanelSections.includes(F.PANEL_ID) || this.grid.toggleToolPanelSection(F.PANEL_ID);
|
|
3378
3446
|
}
|
|
3379
3447
|
hidePanel() {
|
|
3380
3448
|
this.grid.closeToolPanel();
|
|
3381
3449
|
}
|
|
3382
3450
|
togglePanel() {
|
|
3383
|
-
this.grid.isToolPanelOpen || this.grid.openToolPanel(), this.grid.toggleToolPanelSection(
|
|
3451
|
+
this.grid.isToolPanelOpen || this.grid.openToolPanel(), this.grid.toggleToolPanelSection(F.PANEL_ID);
|
|
3384
3452
|
}
|
|
3385
3453
|
isPanelVisible() {
|
|
3386
|
-
return this.grid.isToolPanelOpen && this.grid.expandedToolPanelSections.includes(
|
|
3454
|
+
return this.grid.isToolPanelOpen && this.grid.expandedToolPanelSections.includes(F.PANEL_ID);
|
|
3387
3455
|
}
|
|
3388
3456
|
get gridColumns() {
|
|
3389
3457
|
return this.grid.columns ?? [];
|
|
@@ -3427,7 +3495,7 @@ class P extends R {
|
|
|
3427
3495
|
},
|
|
3428
3496
|
getAvailableFields: () => this.getAvailableFields()
|
|
3429
3497
|
};
|
|
3430
|
-
return
|
|
3498
|
+
return mi(e, this.config, this.isActive, t);
|
|
3431
3499
|
}
|
|
3432
3500
|
refreshPanel() {
|
|
3433
3501
|
this.panelContainer && (this.panelContainer.innerHTML = "", this.renderPanel(this.panelContainer));
|
|
@@ -3460,19 +3528,266 @@ class P extends R {
|
|
|
3460
3528
|
n >= 0 && (i[n] = { ...i[n], aggFunc: t }, this.config.valueFields = [...i]), this.isActive && this.refresh();
|
|
3461
3529
|
}
|
|
3462
3530
|
}
|
|
3463
|
-
|
|
3531
|
+
const W = "tbw-print-isolation-style";
|
|
3532
|
+
function ki(s, e) {
|
|
3533
|
+
const t = document.createElement("style");
|
|
3534
|
+
return t.id = W, t.textContent = `
|
|
3535
|
+
/* Print isolation: hide everything except the target grid */
|
|
3536
|
+
@media print {
|
|
3537
|
+
/* Hide all body children by default */
|
|
3538
|
+
body > *:not(#${s}) {
|
|
3539
|
+
display: none !important;
|
|
3540
|
+
}
|
|
3541
|
+
|
|
3542
|
+
/* But show the grid and ensure it's not hidden by ancestor rules */
|
|
3543
|
+
#${s} {
|
|
3544
|
+
display: block !important;
|
|
3545
|
+
position: static !important;
|
|
3546
|
+
visibility: visible !important;
|
|
3547
|
+
opacity: 1 !important;
|
|
3548
|
+
overflow: visible !important;
|
|
3549
|
+
height: auto !important;
|
|
3550
|
+
width: 100% !important;
|
|
3551
|
+
max-height: none !important;
|
|
3552
|
+
margin: 0 !important;
|
|
3553
|
+
padding: 0 !important;
|
|
3554
|
+
transform: none !important;
|
|
3555
|
+
}
|
|
3556
|
+
|
|
3557
|
+
/* If grid is nested, we need to show its ancestors too */
|
|
3558
|
+
#${s},
|
|
3559
|
+
#${s} * {
|
|
3560
|
+
visibility: visible !important;
|
|
3561
|
+
}
|
|
3562
|
+
|
|
3563
|
+
/* Walk up the DOM and show all ancestors of the grid */
|
|
3564
|
+
body *:has(> #${s}),
|
|
3565
|
+
body *:has(#${s}) {
|
|
3566
|
+
display: block !important;
|
|
3567
|
+
visibility: visible !important;
|
|
3568
|
+
opacity: 1 !important;
|
|
3569
|
+
overflow: visible !important;
|
|
3570
|
+
height: auto !important;
|
|
3571
|
+
position: static !important;
|
|
3572
|
+
transform: none !important;
|
|
3573
|
+
background: transparent !important;
|
|
3574
|
+
border: none !important;
|
|
3575
|
+
padding: 0 !important;
|
|
3576
|
+
margin: 0 !important;
|
|
3577
|
+
}
|
|
3578
|
+
|
|
3579
|
+
/* Hide siblings of ancestors (everything that's not in the path to the grid) */
|
|
3580
|
+
body *:has(#${s}) > *:not(:has(#${s})):not(#${s}) {
|
|
3581
|
+
display: none !important;
|
|
3582
|
+
}
|
|
3583
|
+
|
|
3584
|
+
/* Page settings */
|
|
3585
|
+
@page {
|
|
3586
|
+
size: ${e};
|
|
3587
|
+
margin: 1cm;
|
|
3588
|
+
}
|
|
3589
|
+
|
|
3590
|
+
/* Ensure proper print styling */
|
|
3591
|
+
body {
|
|
3592
|
+
margin: 0 !important;
|
|
3593
|
+
padding: 0 !important;
|
|
3594
|
+
background: white !important;
|
|
3595
|
+
color-scheme: light !important;
|
|
3596
|
+
}
|
|
3597
|
+
}
|
|
3598
|
+
|
|
3599
|
+
/* Screen: also apply isolation for print preview */
|
|
3600
|
+
@media screen {
|
|
3601
|
+
/* When this stylesheet is active, we're about to print */
|
|
3602
|
+
/* No screen-specific rules needed - isolation only applies to print */
|
|
3603
|
+
}
|
|
3604
|
+
`, t;
|
|
3605
|
+
}
|
|
3606
|
+
async function Ai(s, e = {}) {
|
|
3607
|
+
const { orientation: t = "landscape" } = e, i = s.id;
|
|
3608
|
+
document.querySelectorAll(`#${CSS.escape(i)}`).length > 1 && console.warn(
|
|
3609
|
+
`[tbw-grid:print] Multiple elements found with id="${i}". Print isolation may not work correctly. Ensure each grid has a unique ID.`
|
|
3610
|
+
), document.getElementById(W)?.remove();
|
|
3611
|
+
const r = ki(i, t);
|
|
3612
|
+
return document.head.appendChild(r), new Promise((o) => {
|
|
3613
|
+
const a = () => {
|
|
3614
|
+
window.removeEventListener("afterprint", a), document.getElementById(W)?.remove(), o();
|
|
3615
|
+
};
|
|
3616
|
+
window.addEventListener("afterprint", a), window.print(), setTimeout(() => {
|
|
3617
|
+
window.removeEventListener("afterprint", a), document.getElementById(W)?.remove(), o();
|
|
3618
|
+
}, 5e3);
|
|
3619
|
+
});
|
|
3620
|
+
}
|
|
3621
|
+
const _i = ".tbw-print-header,.tbw-print-footer{display:none}@media print{tbw-grid{overflow:visible!important;height:auto!important;border:none!important;border-radius:0!important;color-scheme:light only;-webkit-print-color-adjust:exact;print-color-adjust:exact}tbw-grid .tbw-grid-content{overflow:visible!important;height:auto!important;max-height:none!important}tbw-grid .tbw-scroll-area{overflow:visible!important;height:auto!important;max-height:none!important}tbw-grid .rows-body{overflow:visible!important;height:auto!important;max-height:none!important}tbw-grid .rows-container,tbw-grid .rows-viewport,tbw-grid .rows{overflow:visible!important;height:auto!important;max-height:none!important;transform:none!important}tbw-grid .rows-viewport .rows{position:static!important}tbw-grid .resize-handle,tbw-grid [part=sort-indicator],tbw-grid .tbw-filter-btn,tbw-grid .tool-panel,tbw-grid .tool-panel-content,tbw-grid .tbw-shell-header,tbw-grid .shell-toolbar,tbw-grid .tool-panel-toggle,tbw-grid [data-print-hide],tbw-grid .expander-cell,tbw-grid .tree-toggle,tbw-grid .context-menu,tbw-grid .faux-vscroll{display:none!important}tbw-grid .tbw-print-header{display:flex;justify-content:space-between;align-items:baseline;padding:.5em 0;margin-bottom:.5em;border-bottom:2px solid var(--tbw-color-border, #333);font-family:inherit}.tbw-print-header-title{font-size:1.25em;font-weight:700}.tbw-print-header-timestamp{font-size:.875em;color:var(--tbw-color-fg-muted, #666)}tbw-grid .tbw-print-footer{display:block;margin-top:.5em;padding-top:.5em;border-top:1px solid var(--tbw-color-border, #ccc);font-size:.75em;color:var(--tbw-color-fg-muted, #666);text-align:right}tbw-grid .data-grid-row{break-inside:avoid;page-break-inside:avoid}tbw-grid .cell{border:1px solid var(--tbw-color-border, #ddd)!important}tbw-grid .header-row,tbw-grid .data-grid-row{padding-right:1px}tbw-grid .data-grid-row:hover,tbw-grid .cell:hover{background:inherit!important}@page{margin:1cm}tbw-grid.print-landscape{@page{size:landscape}}tbw-grid.print-portrait{@page{size:portrait}}}", Li = {
|
|
3622
|
+
button: !1,
|
|
3623
|
+
orientation: "landscape",
|
|
3624
|
+
warnThreshold: 500,
|
|
3625
|
+
maxRows: 0,
|
|
3626
|
+
includeTitle: !0,
|
|
3627
|
+
includeTimestamp: !0,
|
|
3628
|
+
title: "",
|
|
3629
|
+
isolate: !1
|
|
3630
|
+
};
|
|
3631
|
+
class gn extends R {
|
|
3632
|
+
name = "print";
|
|
3633
|
+
version = "1.0.0";
|
|
3634
|
+
styles = _i;
|
|
3635
|
+
#e = !1;
|
|
3636
|
+
#t = null;
|
|
3637
|
+
#o = null;
|
|
3638
|
+
#n = null;
|
|
3639
|
+
#i = null;
|
|
3640
|
+
#r = null;
|
|
3641
|
+
#d = null;
|
|
3642
|
+
get #a() {
|
|
3643
|
+
return this.grid;
|
|
3644
|
+
}
|
|
3645
|
+
isPrinting() {
|
|
3646
|
+
return this.#e;
|
|
3647
|
+
}
|
|
3648
|
+
async print(e) {
|
|
3649
|
+
if (this.#e) {
|
|
3650
|
+
console.warn("[PrintPlugin] Print already in progress");
|
|
3651
|
+
return;
|
|
3652
|
+
}
|
|
3653
|
+
const t = this.gridElement;
|
|
3654
|
+
if (!t) {
|
|
3655
|
+
console.warn("[PrintPlugin] Grid not available");
|
|
3656
|
+
return;
|
|
3657
|
+
}
|
|
3658
|
+
const i = { ...Li, ...this.config, ...e }, r = this.rows.length;
|
|
3659
|
+
let o = r, a = !1;
|
|
3660
|
+
if (i.warnThreshold > 0 && r > i.warnThreshold) {
|
|
3661
|
+
const d = i.maxRows > 0 ? `
|
|
3662
|
+
|
|
3663
|
+
Note: Output will be limited to ${i.maxRows.toLocaleString()} rows.` : "";
|
|
3664
|
+
if (!confirm(
|
|
3665
|
+
`This grid has ${r.toLocaleString()} rows. Printing large datasets may cause performance issues or browser slowdowns.${d}
|
|
3666
|
+
|
|
3667
|
+
Click OK to continue, or Cancel to abort.`
|
|
3668
|
+
))
|
|
3669
|
+
return;
|
|
3670
|
+
}
|
|
3671
|
+
i.maxRows > 0 && r > i.maxRows && (o = i.maxRows, a = !0), this.#e = !0;
|
|
3672
|
+
const l = performance.now();
|
|
3673
|
+
this.emit("print-start", {
|
|
3674
|
+
rowCount: o,
|
|
3675
|
+
limitApplied: a,
|
|
3676
|
+
originalRowCount: r
|
|
3677
|
+
});
|
|
3678
|
+
try {
|
|
3679
|
+
const d = this.#a;
|
|
3680
|
+
this.#o = {
|
|
3681
|
+
bypassThreshold: d._virtualization?.bypassThreshold ?? 24
|
|
3682
|
+
}, this.#l(), a && (this.#n = this.sourceRows, this.grid.rows = this.sourceRows.slice(0, o), await new Promise((c) => setTimeout(c, 50))), (i.includeTitle || i.includeTimestamp) && this.#c(i), await this.#s(), await new Promise((c) => requestAnimationFrame(c)), await new Promise((c) => requestAnimationFrame(c)), t.classList.add(`print-${i.orientation}`), await new Promise((c) => requestAnimationFrame(c)), await new Promise((c) => requestAnimationFrame(c)), i.isolate ? await this.#p(i) : await this.#h(), this.emit("print-complete", {
|
|
3683
|
+
success: !0,
|
|
3684
|
+
rowCount: o,
|
|
3685
|
+
duration: Math.round(performance.now() - l)
|
|
3686
|
+
});
|
|
3687
|
+
} catch (d) {
|
|
3688
|
+
console.error("[PrintPlugin] Print failed:", d), this.emit("print-complete", {
|
|
3689
|
+
success: !1,
|
|
3690
|
+
rowCount: 0,
|
|
3691
|
+
duration: Math.round(performance.now() - l)
|
|
3692
|
+
});
|
|
3693
|
+
} finally {
|
|
3694
|
+
this.#f(), this.#e = !1;
|
|
3695
|
+
}
|
|
3696
|
+
}
|
|
3697
|
+
#c(e) {
|
|
3698
|
+
const t = this.gridElement;
|
|
3699
|
+
if (t) {
|
|
3700
|
+
if (this.#i = document.createElement("div"), this.#i.className = "tbw-print-header", e.includeTitle) {
|
|
3701
|
+
const i = e.title || this.grid.effectiveConfig?.shell?.header?.title || "Grid Data", n = document.createElement("div");
|
|
3702
|
+
n.className = "tbw-print-header-title", n.textContent = i, this.#i.appendChild(n);
|
|
3703
|
+
}
|
|
3704
|
+
if (e.includeTimestamp) {
|
|
3705
|
+
const i = document.createElement("div");
|
|
3706
|
+
i.className = "tbw-print-header-timestamp", i.textContent = `Printed: ${(/* @__PURE__ */ new Date()).toLocaleString()}`, this.#i.appendChild(i);
|
|
3707
|
+
}
|
|
3708
|
+
t.insertBefore(this.#i, t.firstChild), this.#r = document.createElement("div"), this.#r.className = "tbw-print-footer", this.#r.textContent = `Page generated from ${window.location.hostname}`, t.appendChild(this.#r);
|
|
3709
|
+
}
|
|
3710
|
+
}
|
|
3711
|
+
async #s() {
|
|
3712
|
+
const e = this.#a;
|
|
3713
|
+
if (!e._virtualization) return;
|
|
3714
|
+
const t = this.rows.length;
|
|
3715
|
+
e._virtualization.bypassThreshold = t + 100, e.refreshVirtualWindow(!0), await new Promise((i) => setTimeout(i, 100));
|
|
3716
|
+
}
|
|
3717
|
+
async #h() {
|
|
3718
|
+
return new Promise((e) => {
|
|
3719
|
+
const t = () => {
|
|
3720
|
+
window.removeEventListener("afterprint", t), e();
|
|
3721
|
+
};
|
|
3722
|
+
window.addEventListener("afterprint", t), window.print(), setTimeout(() => {
|
|
3723
|
+
window.removeEventListener("afterprint", t), e();
|
|
3724
|
+
}, 1e3);
|
|
3725
|
+
});
|
|
3726
|
+
}
|
|
3727
|
+
async #p(e) {
|
|
3728
|
+
const t = this.gridElement;
|
|
3729
|
+
t && await Ai(t, {
|
|
3730
|
+
orientation: e.orientation
|
|
3731
|
+
});
|
|
3732
|
+
}
|
|
3733
|
+
#l() {
|
|
3734
|
+
const e = this.columns;
|
|
3735
|
+
if (e) {
|
|
3736
|
+
this.#t = /* @__PURE__ */ new Map();
|
|
3737
|
+
for (const t of e)
|
|
3738
|
+
t.printHidden && t.field && (this.#t.set(t.field, !t.hidden), this.grid.setColumnVisible(t.field, !1));
|
|
3739
|
+
}
|
|
3740
|
+
}
|
|
3741
|
+
#g() {
|
|
3742
|
+
if (this.#t) {
|
|
3743
|
+
for (const [e, t] of this.#t)
|
|
3744
|
+
this.grid.setColumnVisible(e, t);
|
|
3745
|
+
this.#t = null;
|
|
3746
|
+
}
|
|
3747
|
+
}
|
|
3748
|
+
#f() {
|
|
3749
|
+
const e = this.gridElement;
|
|
3750
|
+
if (!e) return;
|
|
3751
|
+
this.#g(), e.classList.remove("print-portrait", "print-landscape"), this.#d !== null && (e.style.transform = "", e.style.transformOrigin = "", e.style.width = "", this.#d = null), this.#i && (this.#i.remove(), this.#i = null), this.#r && (this.#r.remove(), this.#r = null);
|
|
3752
|
+
const t = this.#a;
|
|
3753
|
+
this.#o && t._virtualization && (t._virtualization.bypassThreshold = this.#o.bypassThreshold, t.refreshVirtualWindow(!0), this.#o = null), this.#n !== null && (this.grid.rows = this.#n, this.#n = null);
|
|
3754
|
+
}
|
|
3755
|
+
afterRender() {
|
|
3756
|
+
this.config?.button && !this.#u && (this.#m(), this.#u = !0);
|
|
3757
|
+
}
|
|
3758
|
+
#u = !1;
|
|
3759
|
+
#m() {
|
|
3760
|
+
this.#a.registerToolbarContent?.({
|
|
3761
|
+
id: "print-button",
|
|
3762
|
+
order: 900,
|
|
3763
|
+
render: (t) => {
|
|
3764
|
+
const i = document.createElement("button");
|
|
3765
|
+
i.className = "tbw-toolbar-btn tbw-print-btn", i.title = "Print grid", i.type = "button";
|
|
3766
|
+
const n = this.resolveIcon("print") || "🖨️";
|
|
3767
|
+
this.setIcon(i, n), i.addEventListener(
|
|
3768
|
+
"click",
|
|
3769
|
+
() => {
|
|
3770
|
+
this.print();
|
|
3771
|
+
},
|
|
3772
|
+
{ signal: this.disconnectSignal }
|
|
3773
|
+
), t.appendChild(i);
|
|
3774
|
+
}
|
|
3775
|
+
});
|
|
3776
|
+
}
|
|
3777
|
+
}
|
|
3778
|
+
function Ti(s) {
|
|
3464
3779
|
const e = s.meta ?? {};
|
|
3465
3780
|
return e.lockPosition !== !0 && e.suppressMovable !== !0;
|
|
3466
3781
|
}
|
|
3467
|
-
function
|
|
3782
|
+
function Ne(s, e, t) {
|
|
3468
3783
|
if (e === t || e < 0 || e >= s.length || t < 0 || t > s.length) return s;
|
|
3469
3784
|
const i = [...s], [n] = i.splice(e, 1);
|
|
3470
3785
|
return i.splice(t, 0, n), i;
|
|
3471
3786
|
}
|
|
3472
|
-
const
|
|
3473
|
-
class
|
|
3787
|
+
const Ii = '@layer tbw-plugins{.header-row>.cell[draggable=true]{cursor:grab;position:relative}.header-row>.cell.dragging{opacity:.5;cursor:grabbing}.header-row>.cell.drop-before:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.header-row>.cell.drop-after:after{content:"";position:absolute;right:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.cell.flip-animating{transition:transform var(--tbw-animation-duration, .2s) ease-out;will-change:transform;z-index:1}@keyframes reorder-fade-in{0%{opacity:0}to{opacity:1}}.cell.fade-animating{animation:reorder-fade-in var(--tbw-animation-duration, .2s) ease-out backwards}}';
|
|
3788
|
+
class fn extends R {
|
|
3474
3789
|
name = "reorder";
|
|
3475
|
-
styles =
|
|
3790
|
+
styles = Ii;
|
|
3476
3791
|
get defaultConfig() {
|
|
3477
3792
|
return {
|
|
3478
3793
|
animation: "flip"
|
|
@@ -3489,8 +3804,8 @@ class on extends R {
|
|
|
3489
3804
|
draggedIndex = null;
|
|
3490
3805
|
dropIndex = null;
|
|
3491
3806
|
canMoveColumnWithPlugins(e) {
|
|
3492
|
-
return !e || !
|
|
3493
|
-
type:
|
|
3807
|
+
return !e || !Ti(e) ? !1 : !this.grid.queryPlugins({
|
|
3808
|
+
type: We.CAN_MOVE_COLUMN,
|
|
3494
3809
|
context: e
|
|
3495
3810
|
}).includes(!1);
|
|
3496
3811
|
}
|
|
@@ -3539,13 +3854,13 @@ class on extends R {
|
|
|
3539
3854
|
const l = this.draggedField, d = this.draggedIndex, c = this.dropIndex;
|
|
3540
3855
|
if (!this.isDragging || l === null || d === null || c === null)
|
|
3541
3856
|
return;
|
|
3542
|
-
const u = c > d ? c - 1 : c, h = this.getColumnOrder(),
|
|
3857
|
+
const u = c > d ? c - 1 : c, h = this.getColumnOrder(), g = Ne(h, d, u), f = {
|
|
3543
3858
|
field: l,
|
|
3544
3859
|
fromIndex: d,
|
|
3545
3860
|
toIndex: u,
|
|
3546
|
-
columnOrder:
|
|
3861
|
+
columnOrder: g
|
|
3547
3862
|
};
|
|
3548
|
-
this.emitCancelable("column-move",
|
|
3863
|
+
this.emitCancelable("column-move", f) || this.updateColumnOrder(g);
|
|
3549
3864
|
}));
|
|
3550
3865
|
});
|
|
3551
3866
|
}
|
|
@@ -3570,7 +3885,7 @@ class on extends R {
|
|
|
3570
3885
|
moveColumn(e, t) {
|
|
3571
3886
|
const i = this.getColumnOrder(), n = i.indexOf(e);
|
|
3572
3887
|
if (n === -1) return;
|
|
3573
|
-
const r =
|
|
3888
|
+
const r = Ne(i, n, t);
|
|
3574
3889
|
this.emitCancelable("column-move", {
|
|
3575
3890
|
field: e,
|
|
3576
3891
|
fromIndex: n,
|
|
@@ -3665,11 +3980,11 @@ class on extends R {
|
|
|
3665
3980
|
this.grid.requestStateChange?.();
|
|
3666
3981
|
}
|
|
3667
3982
|
}
|
|
3668
|
-
const
|
|
3669
|
-
class
|
|
3983
|
+
const Pi = 'tbw-grid[data-responsive-animate]{.data-grid-row,.data-grid-row>.cell{transition:opacity var(--tbw-responsive-duration, .2s) ease-out,transform var(--tbw-responsive-duration, .2s) ease-out}}tbw-grid[data-responsive][data-responsive-animate]{.data-grid-row{animation:responsive-card-enter var(--tbw-responsive-duration, .2s) ease-out}}@keyframes responsive-card-enter{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}tbw-grid[data-responsive]{.header{display:none!important}.footer-row{display:none}.tbw-scroll-area{overflow-x:hidden;min-width:0!important}.rows-body-wrapper{min-width:0!important}.data-grid-row:not(.group-row){display:block!important;grid-template-columns:none!important;padding:var(--tbw-cell-padding);padding-left:var(--tbw-spacing-xl);border-bottom:1px solid var(--tbw-color-border);min-height:auto!important;height:auto!important;contain:none!important;content-visibility:visible!important;background:var(--tbw-color-bg);position:relative;&:nth-child(2n){background:var(--tbw-color-row-alt)}&:hover{background:var(--tbw-color-row-hover)}&[aria-selected=true]{background:var(--tbw-color-selection);&:before{content:"";position:absolute;left:0;top:0;bottom:0;width:4px;background:var(--tbw-color-accent)}}}.data-grid-row:not(.group-row)>.cell{display:flex!important;justify-content:space-between;align-items:center;padding:var(--tbw-spacing-xs) var(--tbw-spacing-md);width:100%!important;min-width:0!important;min-height:auto!important;height:auto!important;line-height:1.5!important;position:static!important;left:auto!important;right:auto!important;border:none!important;border-bottom:none!important;border-right:none!important;background:transparent!important;white-space:normal!important;overflow:visible!important;&:before{content:attr(data-header) ": ";font-weight:600;color:var(--tbw-color-header-fg);flex-shrink:0;margin-right:var(--tbw-spacing-md);min-width:100px}&:after{content:none}}.cell[data-utility]{display:none!important}}tbw-grid[data-responsive] .cell[data-responsive-hidden]{display:none!important}tbw-grid[data-responsive] .cell[data-responsive-value-only]{&:before{display:none!important}justify-content:flex-start!important;font-weight:500}tbw-grid:not([data-responsive]) .cell[data-responsive-hidden]{display:none!important}tbw-grid[data-responsive]{.tbw-footer,.tbw-pinned-rows,.tbw-aggregation-rows{display:none!important}.tbw-pinned-rows,.tbw-aggregation-rows,.tbw-aggregation-row{min-width:0!important}}tbw-grid[data-responsive] .data-grid-row.responsive-card{display:block!important;padding:var(--tbw-cell-padding);border-bottom:1px solid var(--tbw-color-border);>*{width:100%}.cell:before{display:none}}';
|
|
3984
|
+
class pn extends R {
|
|
3670
3985
|
name = "responsive";
|
|
3671
3986
|
version = "1.0.0";
|
|
3672
|
-
styles =
|
|
3987
|
+
styles = Pi;
|
|
3673
3988
|
static manifest = {
|
|
3674
3989
|
incompatibleWith: [
|
|
3675
3990
|
{
|
|
@@ -3681,73 +3996,73 @@ class sn extends R {
|
|
|
3681
3996
|
#e;
|
|
3682
3997
|
#t = !1;
|
|
3683
3998
|
#o;
|
|
3684
|
-
#
|
|
3685
|
-
#
|
|
3686
|
-
#
|
|
3687
|
-
#
|
|
3688
|
-
#
|
|
3689
|
-
#
|
|
3999
|
+
#n = !1;
|
|
4000
|
+
#i = 0;
|
|
4001
|
+
#r = /* @__PURE__ */ new Set();
|
|
4002
|
+
#d = /* @__PURE__ */ new Set();
|
|
4003
|
+
#a = null;
|
|
4004
|
+
#c = [];
|
|
3690
4005
|
isResponsive() {
|
|
3691
4006
|
return this.#t;
|
|
3692
4007
|
}
|
|
3693
4008
|
setResponsive(e) {
|
|
3694
|
-
e !== this.#t && (this.#t = e, this.#
|
|
4009
|
+
e !== this.#t && (this.#t = e, this.#g(), this.emit("responsive-change", {
|
|
3695
4010
|
isResponsive: e,
|
|
3696
|
-
width: this.#
|
|
4011
|
+
width: this.#i,
|
|
3697
4012
|
breakpoint: this.config.breakpoint ?? 0
|
|
3698
4013
|
}));
|
|
3699
4014
|
}
|
|
3700
4015
|
setBreakpoint(e) {
|
|
3701
|
-
this.config.breakpoint = e, this.#
|
|
4016
|
+
this.config.breakpoint = e, this.#h(this.#i);
|
|
3702
4017
|
}
|
|
3703
4018
|
setCardRenderer(e) {
|
|
3704
4019
|
this.config.cardRenderer = e, this.#t && this.requestRender();
|
|
3705
4020
|
}
|
|
3706
4021
|
getWidth() {
|
|
3707
|
-
return this.#
|
|
4022
|
+
return this.#i;
|
|
3708
4023
|
}
|
|
3709
4024
|
getActiveBreakpoint() {
|
|
3710
|
-
return this.#
|
|
4025
|
+
return this.#a;
|
|
3711
4026
|
}
|
|
3712
4027
|
attach(e) {
|
|
3713
|
-
super.attach(e), this.#
|
|
4028
|
+
super.attach(e), this.#s(this.config.hiddenColumns), this.config.breakpoints?.length && (this.#c = [...this.config.breakpoints].sort((t, i) => i.maxWidth - t.maxWidth)), this.#e = new ResizeObserver((t) => {
|
|
3714
4029
|
const i = t[0]?.contentRect.width ?? 0;
|
|
3715
|
-
this.#
|
|
3716
|
-
this.#
|
|
4030
|
+
this.#i = i, clearTimeout(this.#o), this.#o = setTimeout(() => {
|
|
4031
|
+
this.#h(i);
|
|
3717
4032
|
}, this.config.debounceMs ?? 100);
|
|
3718
4033
|
}), this.#e.observe(this.gridElement);
|
|
3719
4034
|
}
|
|
3720
|
-
#
|
|
3721
|
-
if (this.#
|
|
4035
|
+
#s(e) {
|
|
4036
|
+
if (this.#r.clear(), this.#d.clear(), !!e)
|
|
3722
4037
|
for (const t of e)
|
|
3723
|
-
typeof t == "string" ? this.#
|
|
4038
|
+
typeof t == "string" ? this.#r.add(t) : t.showValue ? this.#d.add(t.field) : this.#r.add(t.field);
|
|
3724
4039
|
}
|
|
3725
4040
|
detach() {
|
|
3726
4041
|
this.#e?.disconnect(), this.#e = void 0, clearTimeout(this.#o), this.#o = void 0, this.gridElement && this.gridElement.removeAttribute("data-responsive"), super.detach();
|
|
3727
4042
|
}
|
|
3728
4043
|
afterRender() {
|
|
3729
|
-
if (this.#R(), !(this.#
|
|
4044
|
+
if (this.#R(), !(this.#c.length > 0 ? this.#a !== null : this.#t))
|
|
3730
4045
|
return;
|
|
3731
|
-
const t = this.#
|
|
4046
|
+
const t = this.#r.size > 0, i = this.#d.size > 0;
|
|
3732
4047
|
if (!t && !i)
|
|
3733
4048
|
return;
|
|
3734
4049
|
const n = this.gridElement.querySelectorAll(".cell[data-field]");
|
|
3735
4050
|
for (const r of n) {
|
|
3736
4051
|
const o = r.getAttribute("data-field");
|
|
3737
|
-
o && (this.#
|
|
4052
|
+
o && (this.#r.has(o) ? (r.setAttribute("data-responsive-hidden", ""), r.removeAttribute("data-responsive-value-only")) : this.#d.has(o) ? (r.setAttribute("data-responsive-value-only", ""), r.removeAttribute("data-responsive-hidden")) : (r.removeAttribute("data-responsive-hidden"), r.removeAttribute("data-responsive-value-only")));
|
|
3738
4053
|
}
|
|
3739
4054
|
}
|
|
3740
|
-
#
|
|
3741
|
-
if (this.#
|
|
4055
|
+
#h(e) {
|
|
4056
|
+
if (this.#c.length > 0) {
|
|
3742
4057
|
this.#p(e);
|
|
3743
4058
|
return;
|
|
3744
4059
|
}
|
|
3745
4060
|
const t = this.config.breakpoint ?? 0;
|
|
3746
|
-
t === 0 && !this.#
|
|
4061
|
+
t === 0 && !this.#n && (this.#n = !0, console.warn(
|
|
3747
4062
|
"[tbw-grid:ResponsivePlugin] No breakpoint configured. Responsive mode is disabled. Set a breakpoint based on your grid's column count."
|
|
3748
4063
|
));
|
|
3749
4064
|
const i = t > 0 && e < t;
|
|
3750
|
-
i !== this.#t && (this.#t = i, this.#
|
|
4065
|
+
i !== this.#t && (this.#t = i, this.#g(), this.emit("responsive-change", {
|
|
3751
4066
|
isResponsive: i,
|
|
3752
4067
|
width: e,
|
|
3753
4068
|
breakpoint: t
|
|
@@ -3755,33 +4070,33 @@ class sn extends R {
|
|
|
3755
4070
|
}
|
|
3756
4071
|
#p(e) {
|
|
3757
4072
|
let t = null;
|
|
3758
|
-
for (const n of this.#
|
|
4073
|
+
for (const n of this.#c)
|
|
3759
4074
|
e <= n.maxWidth && (t = n);
|
|
3760
|
-
if (t !== this.#
|
|
3761
|
-
this.#
|
|
4075
|
+
if (t !== this.#a) {
|
|
4076
|
+
this.#a = t, t?.hiddenColumns ? this.#s(t.hiddenColumns) : this.#s(this.config.hiddenColumns);
|
|
3762
4077
|
const n = t?.cardLayout === !0;
|
|
3763
|
-
n !== this.#t && (this.#t = n, this.#
|
|
4078
|
+
n !== this.#t && (this.#t = n, this.#g()), this.emit("responsive-change", {
|
|
3764
4079
|
isResponsive: this.#t,
|
|
3765
4080
|
width: e,
|
|
3766
4081
|
breakpoint: t?.maxWidth ?? 0
|
|
3767
4082
|
}), this.requestRender();
|
|
3768
4083
|
}
|
|
3769
4084
|
}
|
|
3770
|
-
#
|
|
3771
|
-
#
|
|
4085
|
+
#l;
|
|
4086
|
+
#g() {
|
|
3772
4087
|
this.gridElement.toggleAttribute("data-responsive", this.#t);
|
|
3773
4088
|
const e = this.config.animate !== !1;
|
|
3774
4089
|
this.gridElement.toggleAttribute("data-responsive-animate", e), this.config.animationDuration && this.gridElement.style.setProperty("--tbw-responsive-duration", `${this.config.animationDuration}ms`);
|
|
3775
4090
|
const t = this.grid;
|
|
3776
4091
|
if (this.#t) {
|
|
3777
|
-
t._virtualization && (this.#
|
|
4092
|
+
t._virtualization && (this.#l = t._virtualization.rowHeight);
|
|
3778
4093
|
const i = this.gridElement.querySelector(".tbw-scroll-area");
|
|
3779
4094
|
i && (i.scrollLeft = 0);
|
|
3780
4095
|
} else {
|
|
3781
4096
|
const i = this.gridElement.querySelectorAll(".data-grid-row");
|
|
3782
4097
|
for (const n of i)
|
|
3783
4098
|
n.style.height = "", n.classList.remove("responsive-card");
|
|
3784
|
-
this.#
|
|
4099
|
+
this.#l && this.#l > 0 && t._virtualization && (t._virtualization.rowHeight = this.#l, this.#l = void 0), this.#f = void 0, this.#u = void 0, this.#m = void 0;
|
|
3785
4100
|
}
|
|
3786
4101
|
}
|
|
3787
4102
|
renderRow(e, t, i) {
|
|
@@ -3822,7 +4137,7 @@ class sn extends R {
|
|
|
3822
4137
|
return !1;
|
|
3823
4138
|
}
|
|
3824
4139
|
#f;
|
|
3825
|
-
#
|
|
4140
|
+
#u;
|
|
3826
4141
|
#m;
|
|
3827
4142
|
#v() {
|
|
3828
4143
|
if (this.#f && this.#f > 0)
|
|
@@ -3831,7 +4146,7 @@ class sn extends R {
|
|
|
3831
4146
|
return typeof e == "number" && e > 0 ? e : 80;
|
|
3832
4147
|
}
|
|
3833
4148
|
#y() {
|
|
3834
|
-
return this.#
|
|
4149
|
+
return this.#u && this.#u > 0 ? this.#u : this.#l ?? 28;
|
|
3835
4150
|
}
|
|
3836
4151
|
#w() {
|
|
3837
4152
|
for (const e of this.rows)
|
|
@@ -3839,7 +4154,7 @@ class sn extends R {
|
|
|
3839
4154
|
return !0;
|
|
3840
4155
|
return !1;
|
|
3841
4156
|
}
|
|
3842
|
-
#
|
|
4157
|
+
#x() {
|
|
3843
4158
|
let e = 0, t = 0;
|
|
3844
4159
|
for (const i of this.rows)
|
|
3845
4160
|
i.__isGroupRow ? e++ : t++;
|
|
@@ -3848,20 +4163,20 @@ class sn extends R {
|
|
|
3848
4163
|
getExtraHeight() {
|
|
3849
4164
|
if (!this.#t || !this.config.cardRenderer || !this.#w())
|
|
3850
4165
|
return 0;
|
|
3851
|
-
const e = this.#
|
|
4166
|
+
const e = this.#l ?? 28, t = this.#y(), i = this.#v(), { groupCount: n, cardCount: r } = this.#x(), o = n * Math.max(0, t - e), a = r * Math.max(0, i - e);
|
|
3852
4167
|
return o + a;
|
|
3853
4168
|
}
|
|
3854
4169
|
getExtraHeightBefore(e) {
|
|
3855
4170
|
if (!this.#t || !this.config.cardRenderer || !this.#w())
|
|
3856
4171
|
return 0;
|
|
3857
|
-
const t = this.#
|
|
4172
|
+
const t = this.#l ?? 28, i = this.#y(), n = this.#v(), r = Math.max(0, i - t), o = Math.max(0, n - t);
|
|
3858
4173
|
let a = 0, l = 0;
|
|
3859
4174
|
const d = this.rows, c = Math.min(e, d.length);
|
|
3860
4175
|
for (let u = 0; u < c; u++)
|
|
3861
4176
|
d[u].__isGroupRow ? a++ : l++;
|
|
3862
4177
|
return a * r + l * o;
|
|
3863
4178
|
}
|
|
3864
|
-
#
|
|
4179
|
+
#C() {
|
|
3865
4180
|
let e = 0;
|
|
3866
4181
|
for (const t of this.rows)
|
|
3867
4182
|
t.__isGroupRow || e++;
|
|
@@ -3872,12 +4187,12 @@ class sn extends R {
|
|
|
3872
4187
|
if (!this.#t || !this.config.cardRenderer)
|
|
3873
4188
|
return;
|
|
3874
4189
|
let e = !1;
|
|
3875
|
-
const t = this.grid, i = this.#w(), n = this.#
|
|
4190
|
+
const t = this.grid, i = this.#w(), n = this.#C();
|
|
3876
4191
|
if (n !== this.#m && (this.#m = n, e = !0), i) {
|
|
3877
4192
|
const o = this.gridElement.querySelector(".data-grid-row.group-row");
|
|
3878
4193
|
if (o) {
|
|
3879
4194
|
const a = o.getBoundingClientRect().height;
|
|
3880
|
-
a > 0 && a !== this.#
|
|
4195
|
+
a > 0 && a !== this.#u && (this.#u = a, e = !0);
|
|
3881
4196
|
}
|
|
3882
4197
|
}
|
|
3883
4198
|
const r = this.gridElement.querySelector(".data-grid-row.responsive-card");
|
|
@@ -3890,10 +4205,10 @@ class sn extends R {
|
|
|
3890
4205
|
}));
|
|
3891
4206
|
}
|
|
3892
4207
|
}
|
|
3893
|
-
const
|
|
3894
|
-
class
|
|
4208
|
+
const Di = '.dg-row-drag-handle{display:flex;align-items:center;justify-content:center;cursor:grab;user-select:none;color:var(--tbw-color-fg-muted, #999);transition:color .15s ease;font-size:14px;letter-spacing:-2px;&:hover{color:var(--tbw-color-fg, #333)}&:active{cursor:grabbing}}.data-grid-row.dragging{opacity:.6}.data-grid-row.drop-target{position:relative;&.drop-before:before{content:"";position:absolute;top:0;left:0;right:0;height:2px;background-color:var(--tbw-color-accent, #1976d2);z-index:10}&.drop-after:after{content:"";position:absolute;bottom:0;left:0;right:0;height:2px;background-color:var(--tbw-color-accent, #1976d2);z-index:10}}.data-grid-row.keyboard-moving{background-color:var(--tbw-color-bg-selected, #e3f2fd);box-shadow:0 0 0 1px var(--tbw-color-accent, #1976d2) inset}.data-grid-row.animate-flip{transition:transform var(--tbw-animation-duration, .2s) ease-out}', Fi = "__tbw_row_drag";
|
|
4209
|
+
class mn extends R {
|
|
3895
4210
|
name = "rowReorder";
|
|
3896
|
-
styles =
|
|
4211
|
+
styles = Di;
|
|
3897
4212
|
get defaultConfig() {
|
|
3898
4213
|
return {
|
|
3899
4214
|
enableKeyboard: !0,
|
|
@@ -3917,7 +4232,7 @@ class an extends R {
|
|
|
3917
4232
|
if (!this.config.showDragHandle)
|
|
3918
4233
|
return [...e];
|
|
3919
4234
|
const t = {
|
|
3920
|
-
field:
|
|
4235
|
+
field: Fi,
|
|
3921
4236
|
header: "",
|
|
3922
4237
|
width: this.config.dragHandleWidth ?? 40,
|
|
3923
4238
|
resizable: !1,
|
|
@@ -4058,7 +4373,7 @@ class an extends R {
|
|
|
4058
4373
|
this.debounceTimer && (clearTimeout(this.debounceTimer), this.debounceTimer = null);
|
|
4059
4374
|
}
|
|
4060
4375
|
}
|
|
4061
|
-
function
|
|
4376
|
+
function q(s) {
|
|
4062
4377
|
return {
|
|
4063
4378
|
startRow: Math.min(s.startRow, s.endRow),
|
|
4064
4379
|
startCol: Math.min(s.startCol, s.endCol),
|
|
@@ -4066,38 +4381,38 @@ function V(s) {
|
|
|
4066
4381
|
endCol: Math.max(s.startCol, s.endCol)
|
|
4067
4382
|
};
|
|
4068
4383
|
}
|
|
4069
|
-
function
|
|
4070
|
-
const e =
|
|
4384
|
+
function Mi(s) {
|
|
4385
|
+
const e = q(s);
|
|
4071
4386
|
return {
|
|
4072
4387
|
from: { row: e.startRow, col: e.startCol },
|
|
4073
4388
|
to: { row: e.endRow, col: e.endCol }
|
|
4074
4389
|
};
|
|
4075
4390
|
}
|
|
4076
|
-
function
|
|
4077
|
-
return s.map(
|
|
4391
|
+
function Ye(s) {
|
|
4392
|
+
return s.map(Mi);
|
|
4078
4393
|
}
|
|
4079
|
-
function
|
|
4080
|
-
const i =
|
|
4394
|
+
function qi(s, e, t) {
|
|
4395
|
+
const i = q(t);
|
|
4081
4396
|
return s >= i.startRow && s <= i.endRow && e >= i.startCol && e <= i.endCol;
|
|
4082
4397
|
}
|
|
4083
|
-
function
|
|
4084
|
-
return t.some((i) =>
|
|
4398
|
+
function He(s, e, t) {
|
|
4399
|
+
return t.some((i) => qi(s, e, i));
|
|
4085
4400
|
}
|
|
4086
|
-
function
|
|
4087
|
-
const e = [], t =
|
|
4401
|
+
function Ki(s) {
|
|
4402
|
+
const e = [], t = q(s);
|
|
4088
4403
|
for (let i = t.startRow; i <= t.endRow; i++)
|
|
4089
4404
|
for (let n = t.startCol; n <= t.endCol; n++)
|
|
4090
4405
|
e.push({ row: i, col: n });
|
|
4091
4406
|
return e;
|
|
4092
4407
|
}
|
|
4093
|
-
function
|
|
4408
|
+
function Ni(s) {
|
|
4094
4409
|
const e = /* @__PURE__ */ new Map();
|
|
4095
4410
|
for (const t of s)
|
|
4096
|
-
for (const i of
|
|
4411
|
+
for (const i of Ki(t))
|
|
4097
4412
|
e.set(`${i.row},${i.col}`, i);
|
|
4098
4413
|
return [...e.values()];
|
|
4099
4414
|
}
|
|
4100
|
-
function
|
|
4415
|
+
function ie(s, e) {
|
|
4101
4416
|
return {
|
|
4102
4417
|
startRow: s.row,
|
|
4103
4418
|
startCol: s.col,
|
|
@@ -4105,8 +4420,12 @@ function Q(s, e) {
|
|
|
4105
4420
|
endCol: e.col
|
|
4106
4421
|
};
|
|
4107
4422
|
}
|
|
4108
|
-
|
|
4109
|
-
|
|
4423
|
+
function V(s, e) {
|
|
4424
|
+
const t = q(s), i = q(e);
|
|
4425
|
+
return t.startRow === i.startRow && t.startCol === i.startCol && t.endRow === i.endRow && t.endCol === i.endCol;
|
|
4426
|
+
}
|
|
4427
|
+
const Hi = "@layer tbw-plugins{tbw-grid{&.selecting .data-grid-row>.cell{user-select:none}&[data-has-focus] .data-grid-row.row-focus{background-color:var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%))}&[data-selection-mode=row] .cell-focus{outline:none}.data-grid-row>.cell.selected{background-color:var(--tbw-range-selection-bg);&.top{border-top:2px solid var(--tbw-range-border-color)}&.bottom{border-bottom:2px solid var(--tbw-range-border-color)}&.first{border-left:2px solid var(--tbw-range-border-color)}&.last{border-right:2px solid var(--tbw-range-border-color)}}.data-grid-row[data-selectable=false]{cursor:not-allowed;opacity:.6;&.row-focus{background-color:var(--tbw-color-row-alt)}}.data-grid-row>.cell[data-selectable=false]{cursor:not-allowed;opacity:.6;&.selected{background-color:var(--tbw-color-warning-bg, rgba(255, 243, 205, .5))}}.tbw-selection-summary{font-size:var(--tbw-font-size-sm, .8125rem);color:var(--tbw-color-fg-muted);white-space:nowrap}}}";
|
|
4428
|
+
function zi(s, e, t) {
|
|
4110
4429
|
if (s === "cell" && e.selectedCell)
|
|
4111
4430
|
return {
|
|
4112
4431
|
mode: s,
|
|
@@ -4124,9 +4443,9 @@ function Fi(s, e, t) {
|
|
|
4124
4443
|
}));
|
|
4125
4444
|
return { mode: s, ranges: i };
|
|
4126
4445
|
}
|
|
4127
|
-
return s === "range" && e.ranges.length > 0 ? { mode: s, ranges:
|
|
4446
|
+
return s === "range" && e.ranges.length > 0 ? { mode: s, ranges: Ye(e.ranges) } : { mode: s, ranges: [] };
|
|
4128
4447
|
}
|
|
4129
|
-
class
|
|
4448
|
+
class wn extends R {
|
|
4130
4449
|
static manifest = {
|
|
4131
4450
|
configRules: [
|
|
4132
4451
|
{
|
|
@@ -4140,7 +4459,7 @@ class ln extends R {
|
|
|
4140
4459
|
]
|
|
4141
4460
|
};
|
|
4142
4461
|
name = "selection";
|
|
4143
|
-
styles =
|
|
4462
|
+
styles = Hi;
|
|
4144
4463
|
get defaultConfig() {
|
|
4145
4464
|
return {
|
|
4146
4465
|
mode: "cell",
|
|
@@ -4178,16 +4497,22 @@ class ln extends R {
|
|
|
4178
4497
|
if (n.type !== o)
|
|
4179
4498
|
return !1;
|
|
4180
4499
|
const a = this.columns[i], l = a && I(a);
|
|
4181
|
-
if (r === "cell")
|
|
4182
|
-
|
|
4500
|
+
if (r === "cell") {
|
|
4501
|
+
if (l || !this.isCellSelectable(t, i))
|
|
4502
|
+
return !1;
|
|
4503
|
+
const d = this.selectedCell;
|
|
4504
|
+
return d && d.row === t && d.col === i || (this.selectedCell = { row: t, col: i }, this.emit("selection-change", this.#t()), this.requestAfterRender()), !1;
|
|
4505
|
+
}
|
|
4183
4506
|
if (r === "row")
|
|
4184
|
-
return this.isRowSelectable(t) && (this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#t()), this.requestAfterRender()), !1;
|
|
4507
|
+
return !this.isRowSelectable(t) || this.selected.size === 1 && this.selected.has(t) || (this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#t()), this.requestAfterRender()), !1;
|
|
4185
4508
|
if (r === "range") {
|
|
4186
4509
|
if (l || !this.isCellSelectable(t, i))
|
|
4187
4510
|
return !1;
|
|
4188
4511
|
const d = n.shiftKey, c = n.ctrlKey || n.metaKey;
|
|
4189
4512
|
if (d && this.cellAnchor) {
|
|
4190
|
-
const u =
|
|
4513
|
+
const u = ie(this.cellAnchor, { row: t, col: i }), h = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
|
|
4514
|
+
if (h && V(h, u))
|
|
4515
|
+
return !1;
|
|
4191
4516
|
c ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = u : this.ranges.push(u) : this.ranges = [u], this.activeRange = u;
|
|
4192
4517
|
} else if (c) {
|
|
4193
4518
|
const u = {
|
|
@@ -4204,6 +4529,8 @@ class ln extends R {
|
|
|
4204
4529
|
endRow: t,
|
|
4205
4530
|
endCol: i
|
|
4206
4531
|
};
|
|
4532
|
+
if (this.ranges.length === 1 && V(this.ranges[0], u))
|
|
4533
|
+
return !1;
|
|
4207
4534
|
this.ranges = [u], this.activeRange = u, this.cellAnchor = { row: t, col: i };
|
|
4208
4535
|
}
|
|
4209
4536
|
return this.emit("selection-change", this.#t()), this.requestAfterRender(), !1;
|
|
@@ -4231,6 +4558,7 @@ class ln extends R {
|
|
|
4231
4558
|
if (t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey)) {
|
|
4232
4559
|
const r = this.rows.length, o = this.columns.length;
|
|
4233
4560
|
if (r > 0 && o > 0) {
|
|
4561
|
+
e.preventDefault(), e.stopPropagation();
|
|
4234
4562
|
const a = {
|
|
4235
4563
|
startRow: 0,
|
|
4236
4564
|
startCol: 0,
|
|
@@ -4248,26 +4576,24 @@ class ln extends R {
|
|
|
4248
4576
|
if (t && I(t) || !this.isCellSelectable(e.rowIndex, e.colIndex) || e.originalEvent.shiftKey && this.cellAnchor)
|
|
4249
4577
|
return;
|
|
4250
4578
|
this.isDragging = !0;
|
|
4251
|
-
const i = e.rowIndex, n = e.colIndex
|
|
4252
|
-
this.cellAnchor = { row: i, col: n }, e.originalEvent.ctrlKey || e.originalEvent.metaKey || (this.ranges = []);
|
|
4253
|
-
const o = {
|
|
4579
|
+
const i = e.rowIndex, n = e.colIndex, r = e.originalEvent.ctrlKey || e.originalEvent.metaKey, o = {
|
|
4254
4580
|
startRow: i,
|
|
4255
4581
|
startCol: n,
|
|
4256
4582
|
endRow: i,
|
|
4257
4583
|
endCol: n
|
|
4258
4584
|
};
|
|
4259
|
-
return this.ranges.push(o), this.activeRange = o, this.emit("selection-change", this.#t()), this.requestAfterRender(), !0;
|
|
4585
|
+
return !r && this.ranges.length === 1 && V(this.ranges[0], o) ? (this.cellAnchor = { row: i, col: n }, !0) : (this.cellAnchor = { row: i, col: n }, r || (this.ranges = []), this.ranges.push(o), this.activeRange = o, this.emit("selection-change", this.#t()), this.requestAfterRender(), !0);
|
|
4260
4586
|
}
|
|
4261
4587
|
onCellMouseMove(e) {
|
|
4262
4588
|
if (this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
|
|
4263
4589
|
let t = e.colIndex;
|
|
4264
4590
|
const i = this.columns[t];
|
|
4265
4591
|
if (i && I(i)) {
|
|
4266
|
-
const
|
|
4267
|
-
|
|
4592
|
+
const o = this.columns.findIndex((a) => !I(a));
|
|
4593
|
+
o >= 0 && (t = o);
|
|
4268
4594
|
}
|
|
4269
|
-
const n =
|
|
4270
|
-
return this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = n : this.ranges.push(n), this.activeRange = n, this.emit("selection-change", this.#t()), this.requestAfterRender(), !0;
|
|
4595
|
+
const n = ie(this.cellAnchor, { row: e.rowIndex, col: t }), r = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
|
|
4596
|
+
return r && V(r, n) || (this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = n : this.ranges.push(n), this.activeRange = n, this.emit("selection-change", this.#t()), this.requestAfterRender()), !0;
|
|
4271
4597
|
}
|
|
4272
4598
|
onCellMouseUp(e) {
|
|
4273
4599
|
if (this.config.mode === "range" && this.isDragging)
|
|
@@ -4283,25 +4609,25 @@ class ln extends R {
|
|
|
4283
4609
|
const r = e.querySelectorAll(".data-grid-row");
|
|
4284
4610
|
if (r.forEach((o) => {
|
|
4285
4611
|
o.classList.remove("selected", "row-focus"), i && o.removeAttribute("data-selectable");
|
|
4286
|
-
}), t === "row" && (
|
|
4287
|
-
const a = o.querySelector(".cell[data-row]"), l =
|
|
4612
|
+
}), t === "row" && (fe(e), r.forEach((o) => {
|
|
4613
|
+
const a = o.querySelector(".cell[data-row]"), l = nt(a);
|
|
4288
4614
|
l >= 0 && (i && !this.isRowSelectable(l) && o.setAttribute("data-selectable", "false"), this.selected.has(l) && o.classList.add("selected", "row-focus"));
|
|
4289
4615
|
})), (t === "cell" || t === "range") && i && e.querySelectorAll(".cell[data-row][data-col]").forEach((a) => {
|
|
4290
4616
|
const l = parseInt(a.getAttribute("data-row") ?? "-1", 10), d = parseInt(a.getAttribute("data-col") ?? "-1", 10);
|
|
4291
4617
|
l >= 0 && d >= 0 && (this.isCellSelectable(l, d) || a.setAttribute("data-selectable", "false"));
|
|
4292
4618
|
}), t === "range" && this.ranges.length > 0) {
|
|
4293
|
-
|
|
4294
|
-
const o = this.activeRange ?
|
|
4619
|
+
fe(e);
|
|
4620
|
+
const o = this.activeRange ? q(this.activeRange) : null, a = this.columns.findIndex((d) => !I(d));
|
|
4295
4621
|
this.columns.length - 1, e.querySelectorAll(".cell[data-row][data-col]").forEach((d) => {
|
|
4296
4622
|
const c = parseInt(d.getAttribute("data-row") ?? "-1", 10), u = parseInt(d.getAttribute("data-col") ?? "-1", 10);
|
|
4297
4623
|
if (c >= 0 && u >= 0) {
|
|
4298
4624
|
const h = this.columns[u];
|
|
4299
4625
|
if (h && I(h))
|
|
4300
4626
|
return;
|
|
4301
|
-
if (
|
|
4627
|
+
if (He(c, u, this.ranges) && (d.classList.add("selected"), o)) {
|
|
4302
4628
|
c === o.startRow && d.classList.add("top"), c === o.endRow && d.classList.add("bottom");
|
|
4303
|
-
const
|
|
4304
|
-
u ===
|
|
4629
|
+
const f = Math.max(o.startCol, a);
|
|
4630
|
+
u === f && d.classList.add("first"), u === o.endCol && d.classList.add("last");
|
|
4305
4631
|
}
|
|
4306
4632
|
}
|
|
4307
4633
|
});
|
|
@@ -4316,7 +4642,7 @@ class ln extends R {
|
|
|
4316
4642
|
this.pendingKeyboardUpdate = null;
|
|
4317
4643
|
const r = this.grid._focusRow, o = this.grid._focusCol;
|
|
4318
4644
|
if (n && this.cellAnchor) {
|
|
4319
|
-
const a =
|
|
4645
|
+
const a = ie(this.cellAnchor, { row: r, col: o });
|
|
4320
4646
|
this.ranges = [a], this.activeRange = a;
|
|
4321
4647
|
} else n || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: r, col: o });
|
|
4322
4648
|
this.emit("selection-change", this.#t());
|
|
@@ -4334,10 +4660,10 @@ class ln extends R {
|
|
|
4334
4660
|
};
|
|
4335
4661
|
}
|
|
4336
4662
|
getSelectedCells() {
|
|
4337
|
-
return
|
|
4663
|
+
return Ni(this.ranges);
|
|
4338
4664
|
}
|
|
4339
4665
|
isCellSelected(e, t) {
|
|
4340
|
-
return
|
|
4666
|
+
return He(e, t, this.ranges);
|
|
4341
4667
|
}
|
|
4342
4668
|
clearSelection() {
|
|
4343
4669
|
this.selectedCell = null, this.selected.clear(), this.anchor = null, this.ranges = [], this.activeRange = null, this.cellAnchor = null, this.emit("selection-change", { mode: this.config.mode, ranges: [] }), this.requestAfterRender();
|
|
@@ -4350,11 +4676,11 @@ class ln extends R {
|
|
|
4350
4676
|
endCol: t.to.col
|
|
4351
4677
|
})), this.activeRange = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null, this.emit("selection-change", {
|
|
4352
4678
|
mode: this.config.mode,
|
|
4353
|
-
ranges:
|
|
4679
|
+
ranges: Ye(this.ranges)
|
|
4354
4680
|
}), this.requestAfterRender();
|
|
4355
4681
|
}
|
|
4356
4682
|
#t() {
|
|
4357
|
-
return
|
|
4683
|
+
return zi(
|
|
4358
4684
|
this.config.mode,
|
|
4359
4685
|
{
|
|
4360
4686
|
selectedCell: this.selectedCell,
|
|
@@ -4365,23 +4691,23 @@ class ln extends R {
|
|
|
4365
4691
|
);
|
|
4366
4692
|
}
|
|
4367
4693
|
}
|
|
4368
|
-
function
|
|
4694
|
+
function $(s, e) {
|
|
4369
4695
|
return Math.floor(s / e);
|
|
4370
4696
|
}
|
|
4371
|
-
function
|
|
4697
|
+
function Gi(s, e) {
|
|
4372
4698
|
return {
|
|
4373
4699
|
start: s * e,
|
|
4374
4700
|
end: (s + 1) * e
|
|
4375
4701
|
};
|
|
4376
4702
|
}
|
|
4377
|
-
function
|
|
4378
|
-
const i =
|
|
4703
|
+
function Oi(s, e, t) {
|
|
4704
|
+
const i = $(s, t), n = $(e - 1, t), r = [];
|
|
4379
4705
|
for (let o = i; o <= n; o++)
|
|
4380
4706
|
r.push(o);
|
|
4381
4707
|
return r;
|
|
4382
4708
|
}
|
|
4383
|
-
async function
|
|
4384
|
-
const n =
|
|
4709
|
+
async function ze(s, e, t, i) {
|
|
4710
|
+
const n = Gi(e, t);
|
|
4385
4711
|
return s.getRows({
|
|
4386
4712
|
startRow: n.start,
|
|
4387
4713
|
endRow: n.end,
|
|
@@ -4389,14 +4715,14 @@ async function Ke(s, e, t, i) {
|
|
|
4389
4715
|
filterModel: i.filterModel
|
|
4390
4716
|
});
|
|
4391
4717
|
}
|
|
4392
|
-
function
|
|
4393
|
-
const i =
|
|
4718
|
+
function Bi(s, e, t) {
|
|
4719
|
+
const i = $(s, e), n = t.get(i);
|
|
4394
4720
|
if (!n) return;
|
|
4395
4721
|
const r = s % e;
|
|
4396
4722
|
return n[r];
|
|
4397
4723
|
}
|
|
4398
|
-
const
|
|
4399
|
-
class
|
|
4724
|
+
const Vi = 100;
|
|
4725
|
+
class bn extends R {
|
|
4400
4726
|
name = "serverSide";
|
|
4401
4727
|
get defaultConfig() {
|
|
4402
4728
|
return {
|
|
@@ -4416,12 +4742,12 @@ class dn extends R {
|
|
|
4416
4742
|
}
|
|
4417
4743
|
loadRequiredBlocks() {
|
|
4418
4744
|
if (!this.dataSource) return;
|
|
4419
|
-
const e = this.grid, t = this.config.cacheBlockSize ?? 100, i = { startRow: e._virtualization.start, endRow: e._virtualization.end }, n =
|
|
4745
|
+
const e = this.grid, t = this.config.cacheBlockSize ?? 100, i = { startRow: e._virtualization.start, endRow: e._virtualization.end }, n = Oi(i.startRow, i.endRow, t);
|
|
4420
4746
|
for (const r of n)
|
|
4421
4747
|
if (!(this.loadedBlocks.has(r) || this.loadingBlocks.has(r))) {
|
|
4422
4748
|
if (this.loadingBlocks.size >= (this.config.maxConcurrentRequests ?? 2))
|
|
4423
4749
|
break;
|
|
4424
|
-
this.loadingBlocks.add(r),
|
|
4750
|
+
this.loadingBlocks.add(r), ze(this.dataSource, r, t, {}).then((o) => {
|
|
4425
4751
|
this.loadedBlocks.set(r, o.rows), this.totalRowCount = o.totalRowCount, this.loadingBlocks.delete(r), this.requestRender(), this.loadRequiredBlocks();
|
|
4426
4752
|
}).catch(() => {
|
|
4427
4753
|
this.loadingBlocks.delete(r);
|
|
@@ -4432,7 +4758,7 @@ class dn extends R {
|
|
|
4432
4758
|
if (!this.dataSource) return [...e];
|
|
4433
4759
|
const t = [];
|
|
4434
4760
|
for (let i = 0; i < this.totalRowCount; i++) {
|
|
4435
|
-
const n =
|
|
4761
|
+
const n = Bi(i, this.config.cacheBlockSize ?? 100, this.loadedBlocks);
|
|
4436
4762
|
t.push(n ?? { __loading: !0, __index: i });
|
|
4437
4763
|
}
|
|
4438
4764
|
return t;
|
|
@@ -4440,12 +4766,12 @@ class dn extends R {
|
|
|
4440
4766
|
onScroll(e) {
|
|
4441
4767
|
this.dataSource && (this.loadRequiredBlocks(), this.scrollDebounceTimer && clearTimeout(this.scrollDebounceTimer), this.scrollDebounceTimer = setTimeout(() => {
|
|
4442
4768
|
this.loadRequiredBlocks();
|
|
4443
|
-
},
|
|
4769
|
+
}, Vi));
|
|
4444
4770
|
}
|
|
4445
4771
|
setDataSource(e) {
|
|
4446
4772
|
this.dataSource = e, this.loadedBlocks.clear(), this.loadingBlocks.clear();
|
|
4447
4773
|
const t = this.config.cacheBlockSize ?? 100;
|
|
4448
|
-
|
|
4774
|
+
ze(e, 0, t, {}).then((i) => {
|
|
4449
4775
|
this.loadedBlocks.set(0, i.rows), this.totalRowCount = i.totalRowCount, this.requestRender();
|
|
4450
4776
|
});
|
|
4451
4777
|
}
|
|
@@ -4459,59 +4785,59 @@ class dn extends R {
|
|
|
4459
4785
|
return this.totalRowCount;
|
|
4460
4786
|
}
|
|
4461
4787
|
isRowLoaded(e) {
|
|
4462
|
-
const t = this.config.cacheBlockSize ?? 100, i =
|
|
4788
|
+
const t = this.config.cacheBlockSize ?? 100, i = $(e, t);
|
|
4463
4789
|
return this.loadedBlocks.has(i);
|
|
4464
4790
|
}
|
|
4465
4791
|
getLoadedBlockCount() {
|
|
4466
4792
|
return this.loadedBlocks.size;
|
|
4467
4793
|
}
|
|
4468
4794
|
}
|
|
4469
|
-
function
|
|
4795
|
+
function Xe(s, e, t) {
|
|
4470
4796
|
return s.id !== void 0 ? String(s.id) : t ? `${t}-${e}` : String(e);
|
|
4471
4797
|
}
|
|
4472
|
-
function
|
|
4798
|
+
function ne(s, e) {
|
|
4473
4799
|
const t = new Set(s);
|
|
4474
4800
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
4475
4801
|
}
|
|
4476
|
-
function
|
|
4802
|
+
function se(s, e, t = null, i = 0) {
|
|
4477
4803
|
const n = e.childrenField ?? "children", r = /* @__PURE__ */ new Set();
|
|
4478
4804
|
for (let o = 0; o < s.length; o++) {
|
|
4479
|
-
const a = s[o], l =
|
|
4805
|
+
const a = s[o], l = Xe(a, o, t), d = a[n];
|
|
4480
4806
|
if (Array.isArray(d) && d.length > 0) {
|
|
4481
4807
|
r.add(l);
|
|
4482
|
-
const c =
|
|
4808
|
+
const c = se(d, e, l, i + 1);
|
|
4483
4809
|
for (const u of c) r.add(u);
|
|
4484
4810
|
}
|
|
4485
4811
|
}
|
|
4486
4812
|
return r;
|
|
4487
4813
|
}
|
|
4488
|
-
function
|
|
4814
|
+
function Wi() {
|
|
4489
4815
|
return /* @__PURE__ */ new Set();
|
|
4490
4816
|
}
|
|
4491
|
-
function
|
|
4817
|
+
function Ze(s, e, t, i = null, n = 0) {
|
|
4492
4818
|
const r = t.childrenField ?? "children";
|
|
4493
4819
|
for (let o = 0; o < s.length; o++) {
|
|
4494
|
-
const a = s[o], l =
|
|
4820
|
+
const a = s[o], l = Xe(a, o, i);
|
|
4495
4821
|
if (l === e)
|
|
4496
4822
|
return [l];
|
|
4497
4823
|
const d = a[r];
|
|
4498
4824
|
if (Array.isArray(d) && d.length > 0) {
|
|
4499
|
-
const c =
|
|
4825
|
+
const c = Ze(d, e, t, l, n + 1);
|
|
4500
4826
|
if (c)
|
|
4501
4827
|
return [l, ...c];
|
|
4502
4828
|
}
|
|
4503
4829
|
}
|
|
4504
4830
|
return null;
|
|
4505
4831
|
}
|
|
4506
|
-
function
|
|
4507
|
-
const n =
|
|
4832
|
+
function $i(s, e, t, i) {
|
|
4833
|
+
const n = Ze(s, e, t);
|
|
4508
4834
|
if (!n) return i;
|
|
4509
4835
|
const r = new Set(i);
|
|
4510
4836
|
for (let o = 0; o < n.length - 1; o++)
|
|
4511
4837
|
r.add(n[o]);
|
|
4512
4838
|
return r;
|
|
4513
4839
|
}
|
|
4514
|
-
function
|
|
4840
|
+
function Ge(s, e = "children") {
|
|
4515
4841
|
if (!Array.isArray(s) || s.length === 0) return !1;
|
|
4516
4842
|
for (const t of s) {
|
|
4517
4843
|
if (!t) continue;
|
|
@@ -4521,7 +4847,7 @@ function He(s, e = "children") {
|
|
|
4521
4847
|
}
|
|
4522
4848
|
return !1;
|
|
4523
4849
|
}
|
|
4524
|
-
function
|
|
4850
|
+
function ji(s) {
|
|
4525
4851
|
if (!Array.isArray(s) || s.length === 0) return null;
|
|
4526
4852
|
const e = ["children", "items", "nodes", "subRows", "nested"];
|
|
4527
4853
|
for (const t of s)
|
|
@@ -4533,10 +4859,10 @@ function Ni(s) {
|
|
|
4533
4859
|
}
|
|
4534
4860
|
return null;
|
|
4535
4861
|
}
|
|
4536
|
-
const
|
|
4537
|
-
class
|
|
4862
|
+
const Ui = "@layer tbw-plugins{tbw-grid{.cell[data-field=__tbw_expander]{border-right:none!important;padding:0;display:flex;align-items:center;justify-content:flex-start}.header-row .cell[data-field=__tbw_expander]{display:none}.header-row .cell[data-field=__tbw_expander]+.cell{grid-column:1 / 3}.tree-cell-wrapper{display:inline-flex;align-items:center;padding-left:calc(var(--tbw-tree-depth, 0) * var(--tbw-tree-indent-width, var(--tbw-tree-toggle-size, 1.25em)))}.tree-expander{display:flex;align-items:center;justify-content:flex-start;width:100%;height:100%;box-sizing:border-box}.tree-toggle{cursor:pointer;user-select:none;display:inline-flex;align-items:center;justify-content:center;width:var(--tbw-tree-toggle-size, 1.25em);height:var(--tbw-tree-toggle-size, 1.25em);flex-shrink:0}.tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}.tree-spacer{width:var(--tbw-tree-toggle-size, 1.25em);display:inline-block;flex-shrink:0}.data-grid-row.tbw-tree-slide-in{animation:tbw-tree-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}.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-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}@keyframes tbw-tree-fade-in{0%{opacity:0}to{opacity:1}}}";
|
|
4863
|
+
class vn extends R {
|
|
4538
4864
|
name = "tree";
|
|
4539
|
-
styles =
|
|
4865
|
+
styles = Ui;
|
|
4540
4866
|
get defaultConfig() {
|
|
4541
4867
|
return {
|
|
4542
4868
|
childrenField: "children",
|
|
@@ -4562,15 +4888,15 @@ class cn extends R {
|
|
|
4562
4888
|
}
|
|
4563
4889
|
detect(e) {
|
|
4564
4890
|
if (!this.config.autoDetect) return !1;
|
|
4565
|
-
const t = e, i = this.config.childrenField ??
|
|
4566
|
-
return
|
|
4891
|
+
const t = e, i = this.config.childrenField ?? ji(t) ?? "children";
|
|
4892
|
+
return Ge(t, i);
|
|
4567
4893
|
}
|
|
4568
4894
|
processRows(e) {
|
|
4569
4895
|
const t = this.config.childrenField ?? "children", i = e;
|
|
4570
|
-
if (!
|
|
4896
|
+
if (!Ge(i, t))
|
|
4571
4897
|
return this.flattenedRows = [], this.rowKeyMap.clear(), this.previousVisibleKeys.clear(), [...e];
|
|
4572
4898
|
let n = this.withStableKeys(i);
|
|
4573
|
-
this.sortState && (n = this.sortTree(n, this.sortState.field, this.sortState.direction)), this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys =
|
|
4899
|
+
this.sortState && (n = this.sortTree(n, this.sortState.field, this.sortState.direction)), this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = se(n, this.config), this.initialExpansionDone = !0), this.flattenedRows = this.flattenTree(n, this.expandedKeys), this.rowKeyMap.clear(), this.keysToAnimate.clear();
|
|
4574
4900
|
const r = /* @__PURE__ */ new Set();
|
|
4575
4901
|
for (const o of this.flattenedRows)
|
|
4576
4902
|
this.rowKeyMap.set(o.key, o), r.add(o.key), !this.previousVisibleKeys.has(o.key) && o.depth > 0 && this.keysToAnimate.add(o.key);
|
|
@@ -4623,11 +4949,11 @@ class cn extends R {
|
|
|
4623
4949
|
const t = [...e];
|
|
4624
4950
|
if (t.length === 0) return t;
|
|
4625
4951
|
const i = t[0], n = i.viewRenderer, r = () => this.config, o = this.setIcon.bind(this), a = this.resolveIcon.bind(this), l = (d) => {
|
|
4626
|
-
const { row: c, value: u } = d, { showExpandIcons: h = !0, indentWidth:
|
|
4627
|
-
if (m.className = "tree-cell-wrapper", m.style.setProperty("--tbw-tree-depth", String(p)),
|
|
4628
|
-
if (
|
|
4952
|
+
const { row: c, value: u } = d, { showExpandIcons: h = !0, indentWidth: g } = r(), f = c, p = f.__treeDepth ?? 0, m = document.createElement("span");
|
|
4953
|
+
if (m.className = "tree-cell-wrapper", m.style.setProperty("--tbw-tree-depth", String(p)), g !== void 0 && m.style.setProperty("--tbw-tree-indent-width", `${g}px`), h)
|
|
4954
|
+
if (f.__treeHasChildren) {
|
|
4629
4955
|
const b = document.createElement("span");
|
|
4630
|
-
b.className = `tree-toggle${
|
|
4956
|
+
b.className = `tree-toggle${f.__treeExpanded ? " expanded" : ""}`, o(b, a(f.__treeExpanded ? "collapse" : "expand")), b.setAttribute("data-tree-key", String(f.__treeKey ?? "")), m.appendChild(b);
|
|
4631
4957
|
} else {
|
|
4632
4958
|
const b = document.createElement("span");
|
|
4633
4959
|
b.className = "tree-spacer", m.appendChild(b);
|
|
@@ -4648,7 +4974,7 @@ class cn extends R {
|
|
|
4648
4974
|
const i = t.getAttribute("data-tree-key");
|
|
4649
4975
|
if (!i) return !1;
|
|
4650
4976
|
const n = this.rowKeyMap.get(i);
|
|
4651
|
-
return n ? (this.expandedKeys =
|
|
4977
|
+
return n ? (this.expandedKeys = ne(this.expandedKeys, i), this.emit("tree-expand", {
|
|
4652
4978
|
key: i,
|
|
4653
4979
|
row: n.data,
|
|
4654
4980
|
expanded: this.expandedKeys.has(i),
|
|
@@ -4659,7 +4985,7 @@ class cn extends R {
|
|
|
4659
4985
|
if (e.key !== " ") return;
|
|
4660
4986
|
const t = this.grid._focusRow, i = this.flattenedRows[t];
|
|
4661
4987
|
if (i?.hasChildren)
|
|
4662
|
-
return e.preventDefault(), this.expandedKeys =
|
|
4988
|
+
return e.preventDefault(), this.expandedKeys = ne(this.expandedKeys, i.key), this.emit("tree-expand", {
|
|
4663
4989
|
key: i.key,
|
|
4664
4990
|
row: i.data,
|
|
4665
4991
|
expanded: this.expandedKeys.has(i.key),
|
|
@@ -4692,13 +5018,13 @@ class cn extends R {
|
|
|
4692
5018
|
this.expandedKeys.delete(e), this.requestRender();
|
|
4693
5019
|
}
|
|
4694
5020
|
toggle(e) {
|
|
4695
|
-
this.expandedKeys =
|
|
5021
|
+
this.expandedKeys = ne(this.expandedKeys, e), this.requestRender();
|
|
4696
5022
|
}
|
|
4697
5023
|
expandAll() {
|
|
4698
|
-
this.expandedKeys =
|
|
5024
|
+
this.expandedKeys = se(this.rows, this.config), this.requestRender();
|
|
4699
5025
|
}
|
|
4700
5026
|
collapseAll() {
|
|
4701
|
-
this.expandedKeys =
|
|
5027
|
+
this.expandedKeys = Wi(), this.requestRender();
|
|
4702
5028
|
}
|
|
4703
5029
|
isExpanded(e) {
|
|
4704
5030
|
return this.expandedKeys.has(e);
|
|
@@ -4713,10 +5039,10 @@ class cn extends R {
|
|
|
4713
5039
|
return this.rowKeyMap.get(e)?.data;
|
|
4714
5040
|
}
|
|
4715
5041
|
expandToKey(e) {
|
|
4716
|
-
this.expandedKeys =
|
|
5042
|
+
this.expandedKeys = $i(this.rows, e, this.config, this.expandedKeys), this.requestRender();
|
|
4717
5043
|
}
|
|
4718
5044
|
}
|
|
4719
|
-
function
|
|
5045
|
+
function Yi(s, e, t) {
|
|
4720
5046
|
const i = [...s.undoStack, e];
|
|
4721
5047
|
for (; i.length > t; )
|
|
4722
5048
|
i.shift();
|
|
@@ -4725,7 +5051,7 @@ function Gi(s, e, t) {
|
|
|
4725
5051
|
redoStack: []
|
|
4726
5052
|
};
|
|
4727
5053
|
}
|
|
4728
|
-
function
|
|
5054
|
+
function Oe(s) {
|
|
4729
5055
|
if (s.undoStack.length === 0)
|
|
4730
5056
|
return { newState: s, action: null };
|
|
4731
5057
|
const e = [...s.undoStack], t = e.pop();
|
|
@@ -4737,7 +5063,7 @@ function Ne(s) {
|
|
|
4737
5063
|
action: t
|
|
4738
5064
|
} : { newState: s, action: null };
|
|
4739
5065
|
}
|
|
4740
|
-
function
|
|
5066
|
+
function Be(s) {
|
|
4741
5067
|
if (s.redoStack.length === 0)
|
|
4742
5068
|
return { newState: s, action: null };
|
|
4743
5069
|
const e = [...s.redoStack], t = e.pop();
|
|
@@ -4749,16 +5075,16 @@ function ze(s) {
|
|
|
4749
5075
|
action: t
|
|
4750
5076
|
} : { newState: s, action: null };
|
|
4751
5077
|
}
|
|
4752
|
-
function
|
|
5078
|
+
function Xi(s) {
|
|
4753
5079
|
return s.undoStack.length > 0;
|
|
4754
5080
|
}
|
|
4755
|
-
function
|
|
5081
|
+
function Zi(s) {
|
|
4756
5082
|
return s.redoStack.length > 0;
|
|
4757
5083
|
}
|
|
4758
|
-
function
|
|
5084
|
+
function Ji() {
|
|
4759
5085
|
return { undoStack: [], redoStack: [] };
|
|
4760
5086
|
}
|
|
4761
|
-
function
|
|
5087
|
+
function Qi(s, e, t, i) {
|
|
4762
5088
|
return {
|
|
4763
5089
|
type: "cell-edit",
|
|
4764
5090
|
rowIndex: s,
|
|
@@ -4768,7 +5094,7 @@ function Wi(s, e, t, i) {
|
|
|
4768
5094
|
timestamp: Date.now()
|
|
4769
5095
|
};
|
|
4770
5096
|
}
|
|
4771
|
-
class
|
|
5097
|
+
class yn extends R {
|
|
4772
5098
|
static dependencies = [
|
|
4773
5099
|
{ name: "editing", required: !0, reason: "UndoRedoPlugin tracks cell edit history" }
|
|
4774
5100
|
];
|
|
@@ -4786,7 +5112,7 @@ class un extends R {
|
|
|
4786
5112
|
onKeyDown(e) {
|
|
4787
5113
|
const t = (e.ctrlKey || e.metaKey) && e.key === "z" && !e.shiftKey, i = (e.ctrlKey || e.metaKey) && (e.key === "y" || e.key === "z" && e.shiftKey);
|
|
4788
5114
|
if (t) {
|
|
4789
|
-
const n =
|
|
5115
|
+
const n = Oe({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4790
5116
|
if (n.action) {
|
|
4791
5117
|
const r = this.rows;
|
|
4792
5118
|
r[n.action.rowIndex] && (r[n.action.rowIndex][n.action.field] = n.action.oldValue), this.undoStack = n.newState.undoStack, this.redoStack = n.newState.redoStack, this.emit("undo", {
|
|
@@ -4797,7 +5123,7 @@ class un extends R {
|
|
|
4797
5123
|
return !0;
|
|
4798
5124
|
}
|
|
4799
5125
|
if (i) {
|
|
4800
|
-
const n =
|
|
5126
|
+
const n = Be({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4801
5127
|
if (n.action) {
|
|
4802
5128
|
const r = this.rows;
|
|
4803
5129
|
r[n.action.rowIndex] && (r[n.action.rowIndex][n.action.field] = n.action.newValue), this.undoStack = n.newState.undoStack, this.redoStack = n.newState.redoStack, this.emit("redo", {
|
|
@@ -4810,7 +5136,7 @@ class un extends R {
|
|
|
4810
5136
|
return !1;
|
|
4811
5137
|
}
|
|
4812
5138
|
recordEdit(e, t, i, n) {
|
|
4813
|
-
const r =
|
|
5139
|
+
const r = Qi(e, t, i, n), o = Yi(
|
|
4814
5140
|
{ undoStack: this.undoStack, redoStack: this.redoStack },
|
|
4815
5141
|
r,
|
|
4816
5142
|
this.config.maxHistorySize ?? 100
|
|
@@ -4818,7 +5144,7 @@ class un extends R {
|
|
|
4818
5144
|
this.undoStack = o.undoStack, this.redoStack = o.redoStack;
|
|
4819
5145
|
}
|
|
4820
5146
|
undo() {
|
|
4821
|
-
const e =
|
|
5147
|
+
const e = Oe({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4822
5148
|
if (e.action) {
|
|
4823
5149
|
const t = this.rows;
|
|
4824
5150
|
t[e.action.rowIndex] && (t[e.action.rowIndex][e.action.field] = e.action.oldValue), this.undoStack = e.newState.undoStack, this.redoStack = e.newState.redoStack, this.requestRender();
|
|
@@ -4826,7 +5152,7 @@ class un extends R {
|
|
|
4826
5152
|
return e.action;
|
|
4827
5153
|
}
|
|
4828
5154
|
redo() {
|
|
4829
|
-
const e =
|
|
5155
|
+
const e = Be({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4830
5156
|
if (e.action) {
|
|
4831
5157
|
const t = this.rows;
|
|
4832
5158
|
t[e.action.rowIndex] && (t[e.action.rowIndex][e.action.field] = e.action.newValue), this.undoStack = e.newState.undoStack, this.redoStack = e.newState.redoStack, this.requestRender();
|
|
@@ -4834,13 +5160,13 @@ class un extends R {
|
|
|
4834
5160
|
return e.action;
|
|
4835
5161
|
}
|
|
4836
5162
|
canUndo() {
|
|
4837
|
-
return
|
|
5163
|
+
return Xi({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4838
5164
|
}
|
|
4839
5165
|
canRedo() {
|
|
4840
|
-
return
|
|
5166
|
+
return Zi({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4841
5167
|
}
|
|
4842
5168
|
clearHistory() {
|
|
4843
|
-
const e =
|
|
5169
|
+
const e = Ji();
|
|
4844
5170
|
this.undoStack = e.undoStack, this.redoStack = e.redoStack;
|
|
4845
5171
|
}
|
|
4846
5172
|
getUndoStack() {
|
|
@@ -4850,8 +5176,8 @@ class un extends R {
|
|
|
4850
5176
|
return [...this.redoStack];
|
|
4851
5177
|
}
|
|
4852
5178
|
}
|
|
4853
|
-
const
|
|
4854
|
-
function
|
|
5179
|
+
const en = '@layer tbw-plugins{.tbw-visibility-content{display:flex;flex-direction:column;height:100%}.tbw-visibility-list{flex:1;overflow-y:auto;padding:var(--tbw-panel-padding, var(--tbw-spacing-md, .5rem))}.tbw-visibility-row{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));padding:var(--tbw-menu-item-padding, .375rem .25rem);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem);border-radius:var(--tbw-border-radius, .25rem);position:relative}.tbw-visibility-row:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}.tbw-visibility-row input[type=checkbox]{cursor:pointer}.tbw-visibility-row.locked span{color:var(--tbw-color-fg-muted, #888)}.tbw-visibility-handle{cursor:grab;color:var(--tbw-color-fg-muted, #888);font-size:var(--tbw-font-size-2xs, .625rem);letter-spacing:-2px;user-select:none;flex-shrink:0}.tbw-visibility-row.reorderable:hover .tbw-visibility-handle{color:var(--tbw-color-fg, #1f2937)}.tbw-visibility-label{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));flex:1;cursor:pointer}.tbw-visibility-row.dragging{opacity:.5;cursor:grabbing}.tbw-visibility-row.drop-before:before{content:"";position:absolute;left:0;right:0;top:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-row.drop-after:after{content:"";position:absolute;left:0;right:0;bottom:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-show-all{margin:var(--tbw-panel-padding, var(--tbw-spacing-md, .5rem));padding:var(--tbw-button-padding, .5rem .75rem);border:1px solid var(--tbw-visibility-border, var(--tbw-color-border, #e5e7eb));border-radius:var(--tbw-border-radius, .25rem);background:var(--tbw-visibility-btn-bg, var(--tbw-color-header-bg, #f9fafb));color:var(--tbw-color-fg, #1f2937);cursor:pointer;font-size:var(--tbw-font-size-sm, .8125rem)}.tbw-visibility-show-all:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}}';
|
|
5180
|
+
function Ve(s) {
|
|
4855
5181
|
const e = s.meta ?? {};
|
|
4856
5182
|
return e.lockPosition !== !0 && e.suppressMovable !== !0;
|
|
4857
5183
|
}
|
|
@@ -4861,7 +5187,7 @@ class M extends R {
|
|
|
4861
5187
|
];
|
|
4862
5188
|
name = "visibility";
|
|
4863
5189
|
static PANEL_ID = "columns";
|
|
4864
|
-
styles =
|
|
5190
|
+
styles = en;
|
|
4865
5191
|
get defaultConfig() {
|
|
4866
5192
|
return {
|
|
4867
5193
|
allowHideAll: !1
|
|
@@ -4951,7 +5277,7 @@ class M extends R {
|
|
|
4951
5277
|
const i = this.grid.getAllColumns().filter((n) => !n.utility);
|
|
4952
5278
|
for (let n = 0; n < i.length; n++) {
|
|
4953
5279
|
const r = i[n], o = r.header || r.field, a = document.createElement("div");
|
|
4954
|
-
a.className = r.lockVisible ? "tbw-visibility-row locked" : "tbw-visibility-row", a.setAttribute("data-field", r.field), a.setAttribute("data-index", String(n)), t &&
|
|
5280
|
+
a.className = r.lockVisible ? "tbw-visibility-row locked" : "tbw-visibility-row", a.setAttribute("data-field", r.field), a.setAttribute("data-index", String(n)), t && Ve(r) && (a.draggable = !0, a.classList.add("reorderable"), this.setupDragListeners(a, r.field, n, e));
|
|
4955
5281
|
const l = document.createElement("label");
|
|
4956
5282
|
l.className = "tbw-visibility-label";
|
|
4957
5283
|
const d = document.createElement("input");
|
|
@@ -4959,7 +5285,7 @@ class M extends R {
|
|
|
4959
5285
|
this.grid.toggleColumnVisibility(r.field), setTimeout(() => this.rebuildToggles(e), 0);
|
|
4960
5286
|
});
|
|
4961
5287
|
const c = document.createElement("span");
|
|
4962
|
-
if (c.textContent = o, l.appendChild(d), l.appendChild(c), t &&
|
|
5288
|
+
if (c.textContent = o, l.appendChild(d), l.appendChild(c), t && Ve(r)) {
|
|
4963
5289
|
const u = document.createElement("span");
|
|
4964
5290
|
u.className = "tbw-visibility-handle", this.setIcon(u, this.resolveIcon("dragHandle")), u.title = "Drag to reorder", a.appendChild(u);
|
|
4965
5291
|
}
|
|
@@ -4986,12 +5312,12 @@ class M extends R {
|
|
|
4986
5312
|
return;
|
|
4987
5313
|
const d = l > a ? l - 1 : l;
|
|
4988
5314
|
if (d !== a) {
|
|
4989
|
-
const c = this.grid.getAllColumns(), h = c.filter((p) => !p.utility)[d]?.field,
|
|
5315
|
+
const c = this.grid.getAllColumns(), h = c.filter((p) => !p.utility)[d]?.field, g = h ? c.findIndex((p) => p.field === h) : c.length, f = {
|
|
4990
5316
|
field: o,
|
|
4991
5317
|
fromIndex: a,
|
|
4992
|
-
toIndex:
|
|
5318
|
+
toIndex: g
|
|
4993
5319
|
};
|
|
4994
|
-
this.emit("column-reorder-request",
|
|
5320
|
+
this.emit("column-reorder-request", f), setTimeout(() => {
|
|
4995
5321
|
this.rebuildToggles(n);
|
|
4996
5322
|
}, 0);
|
|
4997
5323
|
}
|
|
@@ -5000,47 +5326,49 @@ class M extends R {
|
|
|
5000
5326
|
}
|
|
5001
5327
|
export {
|
|
5002
5328
|
R as BaseGridPlugin,
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5329
|
+
nn as ClipboardPlugin,
|
|
5330
|
+
rn as ColumnVirtualizationPlugin,
|
|
5331
|
+
on as ContextMenuPlugin,
|
|
5332
|
+
Rn as DEFAULT_ANIMATION_CONFIG,
|
|
5333
|
+
Je as DEFAULT_GRID_ICONS,
|
|
5334
|
+
En as DGEvents,
|
|
5335
|
+
Sn as DataGridElement,
|
|
5336
|
+
sn as EditingPlugin,
|
|
5337
|
+
an as ExportPlugin,
|
|
5012
5338
|
T as FilteringPlugin,
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5339
|
+
kn as FitModeEnum,
|
|
5340
|
+
An as GridCSSVars,
|
|
5341
|
+
_n as GridClasses,
|
|
5342
|
+
Ln as GridDataAttrs,
|
|
5343
|
+
Tn as GridElement,
|
|
5344
|
+
In as GridSelectors,
|
|
5345
|
+
ln as GroupingColumnsPlugin,
|
|
5346
|
+
dn as GroupingRowsPlugin,
|
|
5347
|
+
je as MasterDetailPlugin,
|
|
5348
|
+
cn as MultiSortPlugin,
|
|
5349
|
+
We as PLUGIN_QUERIES,
|
|
5350
|
+
un as PinnedColumnsPlugin,
|
|
5351
|
+
hn as PinnedRowsPlugin,
|
|
5352
|
+
F as PivotPlugin,
|
|
5353
|
+
Pn as PluginEvents,
|
|
5354
|
+
Dn as PluginManager,
|
|
5355
|
+
gn as PrintPlugin,
|
|
5356
|
+
Fi as ROW_DRAG_HANDLE_FIELD,
|
|
5357
|
+
Fn as RenderPhase,
|
|
5358
|
+
fn as ReorderPlugin,
|
|
5359
|
+
pn as ResponsivePlugin,
|
|
5360
|
+
mn as RowReorderPlugin,
|
|
5361
|
+
wn as SelectionPlugin,
|
|
5362
|
+
bn as ServerSidePlugin,
|
|
5363
|
+
vn as TreePlugin,
|
|
5364
|
+
yn as UndoRedoPlugin,
|
|
5038
5365
|
M as VisibilityPlugin,
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5366
|
+
Mn as builtInSort,
|
|
5367
|
+
qn as createGrid,
|
|
5368
|
+
Kn as defaultComparator,
|
|
5369
|
+
yt as defaultEditorFor,
|
|
5370
|
+
lt as defaultPasteHandler,
|
|
5371
|
+
Ai as printGridIsolated,
|
|
5372
|
+
Nn as queryGrid
|
|
5045
5373
|
};
|
|
5046
5374
|
//# sourceMappingURL=all.js.map
|