@toolbox-web/grid 1.3.0 → 1.4.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 +997 -710
- package/all.js.map +1 -1
- package/index.js +642 -599
- 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 +151 -0
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +19 -16
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +42 -39
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +25 -22
- 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 +53 -48
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +23 -20
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +11 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +186 -150
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +21 -18
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +67 -64
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +52 -49
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +18 -15
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +25 -22
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +26 -23
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +50 -47
- 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 +25 -22
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/responsive/index.js +20 -17
- package/lib/plugins/responsive/index.js.map +1 -1
- package/lib/plugins/row-reorder/index.js +39 -36
- 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 +115 -101
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +35 -32
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +26 -23
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +23 -20
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +22 -19
- 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 +98 -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/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 Ze, a as Je, runAggregator as he, e as Qe, s as et, PLUGIN_QUERIES as Ve, getAggregator as ge, getValueAggregator as tt, b as _, c as fe, g as it } from "./index.js";
|
|
2
|
+
import { DEFAULT_ANIMATION_CONFIG as Cn, DGEvents as xn, DataGridElement as Rn, FitModeEnum as En, GridCSSVars as Sn, GridClasses as kn, GridDataAttrs as An, DataGridElement as _n, GridSelectors as Ln, PluginEvents as Tn, PluginManager as In, RenderPhase as Pn, builtInSort as Fn, createGrid as Dn, defaultComparator as Mn, queryGrid as qn } from "./index.js";
|
|
3
|
+
const We = "__tbw_expander", nt = 32;
|
|
4
|
+
function se(s) {
|
|
5
|
+
return s.field === We;
|
|
6
6
|
}
|
|
7
7
|
function I(s) {
|
|
8
8
|
return s.meta?.utility === !0;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return s.find(
|
|
10
|
+
function rt(s) {
|
|
11
|
+
return s.find(se);
|
|
12
12
|
}
|
|
13
|
-
function
|
|
13
|
+
function ot(s) {
|
|
14
14
|
return {
|
|
15
|
-
field:
|
|
15
|
+
field: We,
|
|
16
16
|
header: "",
|
|
17
|
-
width:
|
|
17
|
+
width: nt,
|
|
18
18
|
resizable: !1,
|
|
19
19
|
sortable: !1,
|
|
20
20
|
filterable: !1,
|
|
@@ -27,7 +27,7 @@ function it(s) {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
|
-
async function
|
|
30
|
+
async function j(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 he(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 st() {
|
|
53
53
|
try {
|
|
54
54
|
return await navigator.clipboard.readText();
|
|
55
55
|
} catch {
|
|
56
56
|
return "";
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
|
-
function
|
|
59
|
+
function at(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 rt(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 en 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 ji 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 ji 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
|
+
j(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 ji 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 ?? at)(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 ji 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 ji 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 ji 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 ji 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 j(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 ji 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 j(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 st();
|
|
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 ae(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) => ae(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 += ae(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 + ae(t.width), 0);
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function lt(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 = dt(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 ot(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 dt(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 st(s, e, t) {
|
|
|
283
283
|
}
|
|
284
284
|
return i;
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function ct(s, e, t) {
|
|
287
287
|
return t ? s > e : !1;
|
|
288
288
|
}
|
|
289
|
-
class
|
|
289
|
+
class tn extends R {
|
|
290
290
|
name = "columnVirtualization";
|
|
291
291
|
get defaultConfig() {
|
|
292
292
|
return {
|
|
@@ -305,16 +305,16 @@ class Ui 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 = ct(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 = lt(
|
|
318
318
|
this.scrollLeft,
|
|
319
319
|
i,
|
|
320
320
|
this.columnOffsets,
|
|
@@ -354,14 +354,14 @@ class Ui extends R {
|
|
|
354
354
|
return this.totalWidth;
|
|
355
355
|
}
|
|
356
356
|
}
|
|
357
|
-
const
|
|
358
|
-
function
|
|
357
|
+
const U = "@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 ne(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 ut(s, e) {
|
|
362
362
|
return s.disabled === !0 ? !0 : typeof s.disabled == "function" ? s.disabled(e) : !1;
|
|
363
363
|
}
|
|
364
|
-
function
|
|
364
|
+
function re(s, e, t, i = Ze.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 = Ue.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 = ut(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 = Ue.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 = ne(r.subMenu, e), h = re(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 = Ue.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, F = null, L = null, Y = 0;
|
|
409
|
+
const X = [
|
|
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 nn extends R {
|
|
428
428
|
name = "contextMenu";
|
|
429
429
|
get defaultConfig() {
|
|
430
430
|
return {
|
|
431
|
-
items:
|
|
431
|
+
items: X
|
|
432
432
|
};
|
|
433
433
|
}
|
|
434
434
|
isOpen = !1;
|
|
@@ -436,20 +436,20 @@ class Yi 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(), Y++;
|
|
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
|
-
!
|
|
445
|
+
!L && typeof document < "u" && typeof U == "string" && U && (L = document.createElement("style"), L.id = "tbw-context-menu-styles", L.textContent = U, 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)), F || (F = (e) => {
|
|
448
448
|
e.key === "Escape" && document.querySelectorAll(".tbw-context-menu").forEach((i) => i.remove());
|
|
449
449
|
}, document.addEventListener("keydown", F));
|
|
450
450
|
}
|
|
451
451
|
uninstallGlobalHandlers() {
|
|
452
|
-
|
|
452
|
+
Y--, !(Y > 0) && (P && (document.removeEventListener("click", P), P = null), F && (document.removeEventListener("keydown", F), F = null), L && (L.remove(), L = null));
|
|
453
453
|
}
|
|
454
454
|
afterRender() {
|
|
455
455
|
const e = this.gridElement;
|
|
@@ -461,14 +461,14 @@ class Yi 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 Yi 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 = ne(this.config.items ?? X, l);
|
|
491
|
+
d.length && (this.menuElement && this.menuElement.remove(), this.menuElement = re(
|
|
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 Yi 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 = ne(this.config.items ?? X, n);
|
|
512
|
+
this.menuElement && this.menuElement.remove(), this.menuElement = re(
|
|
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 Yi extends R {
|
|
|
525
525
|
return this.isOpen;
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
|
-
const
|
|
529
|
-
function
|
|
528
|
+
const ht = "@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 gt(s) {
|
|
530
530
|
const e = s.options;
|
|
531
531
|
return e ? typeof e == "function" ? e() : e : [];
|
|
532
532
|
}
|
|
533
|
-
function
|
|
533
|
+
function ft(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 ut(s) {
|
|
|
540
540
|
}), i;
|
|
541
541
|
};
|
|
542
542
|
}
|
|
543
|
-
function
|
|
543
|
+
function pt() {
|
|
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 mt(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 ft(s) {
|
|
|
554
554
|
}), i;
|
|
555
555
|
};
|
|
556
556
|
}
|
|
557
|
-
function
|
|
557
|
+
function wt(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
|
+
gt(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 gt(s) {
|
|
|
577
577
|
}), i;
|
|
578
578
|
};
|
|
579
579
|
}
|
|
580
|
-
function
|
|
580
|
+
function bt(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 pt(s) {
|
|
|
585
585
|
}), i;
|
|
586
586
|
};
|
|
587
587
|
}
|
|
588
|
-
function
|
|
588
|
+
function vt(s) {
|
|
589
589
|
switch (s.type) {
|
|
590
590
|
case "number":
|
|
591
|
-
return
|
|
591
|
+
return ft(s);
|
|
592
592
|
case "boolean":
|
|
593
|
-
return
|
|
593
|
+
return pt();
|
|
594
594
|
case "date":
|
|
595
|
-
return
|
|
595
|
+
return mt(s);
|
|
596
596
|
case "select":
|
|
597
|
-
return
|
|
597
|
+
return wt(s);
|
|
598
598
|
default:
|
|
599
|
-
return
|
|
599
|
+
return bt(s);
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
|
-
const
|
|
603
|
-
function
|
|
602
|
+
const Z = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';
|
|
603
|
+
function yt(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 wt(s, e) {
|
|
|
614
614
|
return r.editor;
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
|
-
function
|
|
617
|
+
function H(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 xt(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 Ce(s) {
|
|
631
631
|
}
|
|
632
|
-
function
|
|
632
|
+
function Rt(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 rn extends R {
|
|
639
639
|
static manifest = {
|
|
640
640
|
ownedProperties: [
|
|
641
641
|
{
|
|
@@ -657,7 +657,7 @@ class Xi extends R {
|
|
|
657
657
|
]
|
|
658
658
|
};
|
|
659
659
|
name = "editing";
|
|
660
|
-
styles =
|
|
660
|
+
styles = ht;
|
|
661
661
|
get defaultConfig() {
|
|
662
662
|
return {
|
|
663
663
|
editOn: "click"
|
|
@@ -666,9 +666,9 @@ class Xi 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 Xi 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 Xi 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 Xi 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 (H(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 Xi 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 Xi 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 Xi 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 Xi 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 Xi 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 Xi 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(Z);
|
|
853
855
|
try {
|
|
854
856
|
l?.focus({ preventScroll: !0 });
|
|
855
857
|
} catch {
|
|
@@ -858,23 +860,23 @@ class Xi 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 Xi 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 Xi 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"), xt(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 (!H(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 Xi 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") : Ce;
|
|
930
932
|
if (this.emitCancelable("cell-commit", {
|
|
931
933
|
row: n,
|
|
932
934
|
rowId: l ?? "",
|
|
@@ -939,9 +941,9 @@ class Xi 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"), Je(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 Xi 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") : Ce, d = H(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, H(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 = yt(this.grid, p) ?? vt(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(Z)?.focus({ preventScroll: !0 });
|
|
973
975
|
});
|
|
974
976
|
} else if (typeof w == "function") {
|
|
975
977
|
const v = {
|
|
@@ -979,15 +981,15 @@ class Xi 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, Rt(f, i, h)) : S instanceof Node && f.appendChild(S), o || queueMicrotask(() => {
|
|
988
|
+
f.querySelector(Z)?.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 Xi 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 (N) {
|
|
1007
|
+
console.warn(`[tbw-grid] External editor mount error for column '${i.field}':`, N);
|
|
1006
1008
|
}
|
|
1007
1009
|
else
|
|
1008
1010
|
this.grid.dispatchEvent(
|
|
@@ -1010,7 +1012,7 @@ class Xi 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 Xi 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 (!H(p)) return "";
|
|
1027
1029
|
const m = i[p];
|
|
1028
1030
|
return m == null ? "" : String(m);
|
|
1029
1031
|
}) || "");
|
|
@@ -1033,17 +1035,17 @@ class Xi 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 Xi extends R {
|
|
|
1059
1061
|
});
|
|
1060
1062
|
}
|
|
1061
1063
|
}
|
|
1062
|
-
function
|
|
1064
|
+
function xe(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 ve(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 Et(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 xe(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)), xe(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 le(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 St(s, e) {
|
|
1094
1096
|
const t = new Blob([s], { type: "text/csv;charset=utf-8;" });
|
|
1095
|
-
|
|
1097
|
+
le(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 kt(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 Rt(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 Rt(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 Rt(s, e, t) {
|
|
|
1129
1131
|
</Worksheet>
|
|
1130
1132
|
</Workbook>`, i;
|
|
1131
1133
|
}
|
|
1132
|
-
function
|
|
1134
|
+
function At(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
|
+
le(i, t);
|
|
1137
1139
|
}
|
|
1138
|
-
class
|
|
1140
|
+
class on extends R {
|
|
1139
1141
|
name = "export";
|
|
1140
1142
|
get defaultConfig() {
|
|
1141
1143
|
return {
|
|
@@ -1172,27 +1174,27 @@ class Zi 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 = Et(o, r, n, { bom: !0 });
|
|
1178
|
+
a = a.endsWith(".csv") ? a : `${a}.csv`, St(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 = kt(o, r, n);
|
|
1183
|
+
a = a.endsWith(".xls") ? a : `${a}.xls`, At(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
|
+
le(c, a);
|
|
1196
1198
|
break;
|
|
1197
1199
|
}
|
|
1198
1200
|
}
|
|
@@ -1229,7 +1231,7 @@ class Zi extends R {
|
|
|
1229
1231
|
return this.lastExportInfo;
|
|
1230
1232
|
}
|
|
1231
1233
|
}
|
|
1232
|
-
function
|
|
1234
|
+
function _t(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 St(s) {
|
|
|
1241
1243
|
totalHeight: e * n
|
|
1242
1244
|
};
|
|
1243
1245
|
}
|
|
1244
|
-
function
|
|
1246
|
+
function Lt(s, e) {
|
|
1245
1247
|
return s <= e;
|
|
1246
1248
|
}
|
|
1247
|
-
function
|
|
1249
|
+
function Tt(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 At(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 It(s, e, t = !1) {
|
|
1289
|
+
return e.length ? s.filter((i) => e.every((n) => Tt(i, n, t))) : s;
|
|
1288
1290
|
}
|
|
1289
|
-
function
|
|
1291
|
+
function Pt(s) {
|
|
1290
1292
|
return JSON.stringify(
|
|
1291
1293
|
s.map((e) => ({
|
|
1292
1294
|
field: e.field,
|
|
@@ -1296,7 +1298,7 @@ function Lt(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 Ce(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
|
|
1308
|
-
class
|
|
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}}}', Dt = "@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)))}}";
|
|
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,
|
|
@@ -1326,9 +1328,20 @@ class A extends R {
|
|
|
1326
1328
|
excludedValues = /* @__PURE__ */ new Map();
|
|
1327
1329
|
panelAbortController = null;
|
|
1328
1330
|
globalStylesInjected = !1;
|
|
1329
|
-
static
|
|
1331
|
+
static DEFAULT_LIST_ITEM_HEIGHT = 28;
|
|
1330
1332
|
static LIST_OVERSCAN = 3;
|
|
1331
1333
|
static LIST_BYPASS_THRESHOLD = 50;
|
|
1334
|
+
getListItemHeight() {
|
|
1335
|
+
if (this.panelElement) {
|
|
1336
|
+
const e = getComputedStyle(this.panelElement).getPropertyValue("--tbw-filter-item-height");
|
|
1337
|
+
if (e && e.trim()) {
|
|
1338
|
+
const t = parseFloat(e);
|
|
1339
|
+
if (!isNaN(t) && t > 0)
|
|
1340
|
+
return t;
|
|
1341
|
+
}
|
|
1342
|
+
}
|
|
1343
|
+
return T.DEFAULT_LIST_ITEM_HEIGHT;
|
|
1344
|
+
}
|
|
1332
1345
|
syncExcludedValues(e, t) {
|
|
1333
1346
|
t ? t.type === "set" && t.operator === "notIn" && Array.isArray(t.value) ? this.excludedValues.set(e, new Set(t.value)) : t.type === "set" && this.excludedValues.delete(e) : this.excludedValues.delete(e);
|
|
1334
1347
|
}
|
|
@@ -1343,10 +1356,10 @@ class A extends R {
|
|
|
1343
1356
|
if (!t.length) return [...e];
|
|
1344
1357
|
if (this.config.filterHandler)
|
|
1345
1358
|
return this.cachedResult ? this.cachedResult : [...e];
|
|
1346
|
-
const i =
|
|
1359
|
+
const i = Pt(t);
|
|
1347
1360
|
if (this.cacheKey === i && this.cachedResult)
|
|
1348
1361
|
return this.cachedResult;
|
|
1349
|
-
const n =
|
|
1362
|
+
const n = It([...e], t, this.config.caseSensitive);
|
|
1350
1363
|
return this.cachedResult = n, this.cacheKey = i, n;
|
|
1351
1364
|
}
|
|
1352
1365
|
afterRender() {
|
|
@@ -1362,14 +1375,20 @@ class A extends R {
|
|
|
1362
1375
|
const a = this.filters.has(o);
|
|
1363
1376
|
let l = i.querySelector(".tbw-filter-btn");
|
|
1364
1377
|
if (l) {
|
|
1365
|
-
l.classList.
|
|
1378
|
+
const u = l.classList.contains("active");
|
|
1379
|
+
if (l.classList.toggle("active", a), i.classList.toggle("filtered", a), u !== a) {
|
|
1380
|
+
const h = a ? "filterActive" : "filter";
|
|
1381
|
+
this.setIcon(l, this.resolveIcon(h));
|
|
1382
|
+
}
|
|
1366
1383
|
return;
|
|
1367
1384
|
}
|
|
1368
|
-
l = document.createElement("button"), l.className = "tbw-filter-btn", l.setAttribute("aria-label", `Filter ${r.header ?? o}`)
|
|
1369
|
-
|
|
1385
|
+
l = document.createElement("button"), l.className = "tbw-filter-btn", l.setAttribute("aria-label", `Filter ${r.header ?? o}`);
|
|
1386
|
+
const d = a ? "filterActive" : "filter";
|
|
1387
|
+
this.setIcon(l, this.resolveIcon(d)), a && (l.classList.add("active"), i.classList.add("filtered")), l.addEventListener("click", (u) => {
|
|
1388
|
+
u.stopPropagation(), this.toggleFilterPanel(o, r, l);
|
|
1370
1389
|
});
|
|
1371
|
-
const
|
|
1372
|
-
|
|
1390
|
+
const c = i.querySelector(".resize-handle");
|
|
1391
|
+
c ? i.insertBefore(l, c) : i.appendChild(l);
|
|
1373
1392
|
});
|
|
1374
1393
|
}
|
|
1375
1394
|
setFilter(e, t) {
|
|
@@ -1418,7 +1437,15 @@ class A extends R {
|
|
|
1418
1437
|
return this.getFilters();
|
|
1419
1438
|
}
|
|
1420
1439
|
getUniqueValues(e) {
|
|
1421
|
-
return
|
|
1440
|
+
return Ee(this.sourceRows, e);
|
|
1441
|
+
}
|
|
1442
|
+
copyGridThemeContext(e) {
|
|
1443
|
+
const t = this.gridElement;
|
|
1444
|
+
if (!t) return;
|
|
1445
|
+
for (const n of t.classList)
|
|
1446
|
+
n.startsWith("tbw-") || n === "selecting" || e.classList.add(n);
|
|
1447
|
+
const i = t.dataset.theme;
|
|
1448
|
+
i && (e.dataset.theme = i);
|
|
1422
1449
|
}
|
|
1423
1450
|
injectGlobalStyles() {
|
|
1424
1451
|
if (this.globalStylesInjected) return;
|
|
@@ -1427,7 +1454,7 @@ class A extends R {
|
|
|
1427
1454
|
return;
|
|
1428
1455
|
}
|
|
1429
1456
|
const e = document.createElement("style");
|
|
1430
|
-
e.id = "tbw-filter-panel-styles", e.textContent =
|
|
1457
|
+
e.id = "tbw-filter-panel-styles", e.textContent = Dt, document.head.appendChild(e), this.globalStylesInjected = !0;
|
|
1431
1458
|
}
|
|
1432
1459
|
toggleFilterPanel(e, t, i) {
|
|
1433
1460
|
if (this.openPanelField === e) {
|
|
@@ -1436,13 +1463,13 @@ class A extends R {
|
|
|
1436
1463
|
}
|
|
1437
1464
|
this.closeFilterPanel();
|
|
1438
1465
|
const n = document.createElement("div");
|
|
1439
|
-
if (n.className = "tbw-filter-panel", this.isAnimationEnabled && n.classList.add("tbw-filter-panel-animated"), this.panelElement = n, this.openPanelField = e, this.config.valuesHandler) {
|
|
1466
|
+
if (n.className = "tbw-filter-panel", this.copyGridThemeContext(n), this.isAnimationEnabled && n.classList.add("tbw-filter-panel-animated"), this.panelElement = n, this.openPanelField = e, this.config.valuesHandler) {
|
|
1440
1467
|
n.innerHTML = '<div class="tbw-filter-loading">Loading...</div>', document.body.appendChild(n), this.positionPanel(n, i), this.setupPanelCloseHandler(n, i), this.config.valuesHandler(e, t).then((o) => {
|
|
1441
1468
|
this.openPanelField !== e || !this.panelElement || (n.innerHTML = "", this.renderPanelContent(e, t, n, o));
|
|
1442
1469
|
});
|
|
1443
1470
|
return;
|
|
1444
1471
|
}
|
|
1445
|
-
const r =
|
|
1472
|
+
const r = Ee(this.sourceRows, e);
|
|
1446
1473
|
this.renderPanelContent(e, t, n, r), document.body.appendChild(n), this.positionPanel(n, i), this.setupPanelCloseHandler(n, i);
|
|
1447
1474
|
}
|
|
1448
1475
|
renderPanelContent(e, t, i, n) {
|
|
@@ -1485,11 +1512,11 @@ class A extends R {
|
|
|
1485
1512
|
}
|
|
1486
1513
|
static supportsAnchorPositioning = null;
|
|
1487
1514
|
static checkAnchorPositioningSupport() {
|
|
1488
|
-
return
|
|
1515
|
+
return T.supportsAnchorPositioning === null && (T.supportsAnchorPositioning = CSS.supports("anchor-name", "--test")), T.supportsAnchorPositioning;
|
|
1489
1516
|
}
|
|
1490
1517
|
positionPanel(e, t) {
|
|
1491
1518
|
const n = t.closest(".cell") ?? t;
|
|
1492
|
-
if (n.style.anchorName = "--tbw-filter-anchor", this.panelAnchorElement = n,
|
|
1519
|
+
if (n.style.anchorName = "--tbw-filter-anchor", this.panelAnchorElement = n, T.checkAnchorPositioningSupport()) {
|
|
1493
1520
|
requestAnimationFrame(() => {
|
|
1494
1521
|
const o = e.getBoundingClientRect(), a = n.getBoundingClientRect();
|
|
1495
1522
|
o.top < a.top && e.classList.add("tbw-filter-panel-above");
|
|
@@ -1503,100 +1530,100 @@ class A extends R {
|
|
|
1503
1530
|
});
|
|
1504
1531
|
}
|
|
1505
1532
|
renderDefaultFilterPanel(e, t, i, n) {
|
|
1506
|
-
const { field: r } = t, o = document.createElement("div");
|
|
1507
|
-
|
|
1508
|
-
const
|
|
1509
|
-
|
|
1510
|
-
const
|
|
1511
|
-
|
|
1512
|
-
const
|
|
1513
|
-
|
|
1514
|
-
const
|
|
1515
|
-
|
|
1516
|
-
const
|
|
1517
|
-
|
|
1518
|
-
const
|
|
1519
|
-
const y = [...
|
|
1520
|
-
|
|
1533
|
+
const { field: r } = t, o = this.getListItemHeight(), a = document.createElement("div");
|
|
1534
|
+
a.className = "tbw-filter-search";
|
|
1535
|
+
const l = document.createElement("input");
|
|
1536
|
+
l.type = "text", l.placeholder = "Search...", l.className = "tbw-filter-search-input", l.value = this.searchText.get(r) ?? "", a.appendChild(l), e.appendChild(a);
|
|
1537
|
+
const d = document.createElement("div");
|
|
1538
|
+
d.className = "tbw-filter-actions";
|
|
1539
|
+
const c = document.createElement("label");
|
|
1540
|
+
c.className = "tbw-filter-value-item", c.style.padding = "0", c.style.margin = "0";
|
|
1541
|
+
const u = document.createElement("input");
|
|
1542
|
+
u.type = "checkbox", u.className = "tbw-filter-checkbox";
|
|
1543
|
+
const h = document.createElement("span");
|
|
1544
|
+
h.textContent = "Select All", c.appendChild(u), c.appendChild(h), d.appendChild(c);
|
|
1545
|
+
const g = () => {
|
|
1546
|
+
const y = [...w.values()], E = y.every((C) => C), A = y.every((C) => !C);
|
|
1547
|
+
u.checked = E, u.indeterminate = !E && !A;
|
|
1521
1548
|
};
|
|
1522
|
-
|
|
1523
|
-
const y =
|
|
1524
|
-
for (const E of
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
}), e.appendChild(
|
|
1549
|
+
u.addEventListener("change", () => {
|
|
1550
|
+
const y = u.checked;
|
|
1551
|
+
for (const E of w.keys())
|
|
1552
|
+
w.set(E, y);
|
|
1553
|
+
g(), S();
|
|
1554
|
+
}), e.appendChild(d);
|
|
1528
1555
|
const f = document.createElement("div");
|
|
1529
1556
|
f.className = "tbw-filter-values";
|
|
1530
|
-
const g = document.createElement("div");
|
|
1531
|
-
g.className = "tbw-filter-values-spacer", f.appendChild(g);
|
|
1532
1557
|
const p = document.createElement("div");
|
|
1533
|
-
p.className = "tbw-filter-values-
|
|
1534
|
-
const m =
|
|
1558
|
+
p.className = "tbw-filter-values-spacer", f.appendChild(p);
|
|
1559
|
+
const m = document.createElement("div");
|
|
1560
|
+
m.className = "tbw-filter-values-content", f.appendChild(m);
|
|
1561
|
+
const w = /* @__PURE__ */ new Map();
|
|
1535
1562
|
i.forEach((y) => {
|
|
1536
1563
|
const E = y == null ? "__null__" : String(y);
|
|
1537
|
-
|
|
1538
|
-
}),
|
|
1539
|
-
let
|
|
1540
|
-
const
|
|
1541
|
-
const
|
|
1542
|
-
x.className = "tbw-filter-value-item", x.style.position = "absolute", x.style.top = `${E *
|
|
1564
|
+
w.set(E, !n.has(y));
|
|
1565
|
+
}), g();
|
|
1566
|
+
let b = [];
|
|
1567
|
+
const v = (y, E) => {
|
|
1568
|
+
const A = y == null ? "(Blank)" : String(y), C = y == null ? "__null__" : String(y), x = document.createElement("label");
|
|
1569
|
+
x.className = "tbw-filter-value-item", x.style.position = "absolute", x.style.top = `${E * o}px`, x.style.left = "0", x.style.right = "0", x.style.height = `${o}px`, x.style.boxSizing = "border-box";
|
|
1543
1570
|
const k = document.createElement("input");
|
|
1544
|
-
k.type = "checkbox", k.className = "tbw-filter-checkbox", k.checked =
|
|
1545
|
-
|
|
1571
|
+
k.type = "checkbox", k.className = "tbw-filter-checkbox", k.checked = w.get(C) ?? !0, k.dataset.value = C, k.addEventListener("change", () => {
|
|
1572
|
+
w.set(C, k.checked), g();
|
|
1546
1573
|
});
|
|
1547
|
-
const
|
|
1548
|
-
return
|
|
1549
|
-
},
|
|
1550
|
-
const y =
|
|
1551
|
-
if (
|
|
1552
|
-
|
|
1553
|
-
|
|
1574
|
+
const ue = document.createElement("span");
|
|
1575
|
+
return ue.textContent = A, x.appendChild(k), x.appendChild(ue), x;
|
|
1576
|
+
}, S = () => {
|
|
1577
|
+
const y = b.length, E = f.clientHeight, A = f.scrollTop;
|
|
1578
|
+
if (p.style.height = `${y * o}px`, Lt(y, T.LIST_BYPASS_THRESHOLD / 3)) {
|
|
1579
|
+
m.innerHTML = "", m.style.transform = "translateY(0px)", b.forEach((x, k) => {
|
|
1580
|
+
m.appendChild(v(x, k));
|
|
1554
1581
|
});
|
|
1555
1582
|
return;
|
|
1556
1583
|
}
|
|
1557
|
-
const C =
|
|
1584
|
+
const C = _t({
|
|
1558
1585
|
totalRows: y,
|
|
1559
1586
|
viewportHeight: E,
|
|
1560
|
-
scrollTop:
|
|
1561
|
-
rowHeight:
|
|
1562
|
-
overscan:
|
|
1587
|
+
scrollTop: A,
|
|
1588
|
+
rowHeight: o,
|
|
1589
|
+
overscan: T.LIST_OVERSCAN
|
|
1563
1590
|
});
|
|
1564
|
-
|
|
1591
|
+
m.style.transform = `translateY(${C.offsetY}px)`, m.innerHTML = "";
|
|
1565
1592
|
for (let x = C.start; x < C.end; x++)
|
|
1566
|
-
|
|
1567
|
-
},
|
|
1568
|
-
const E = this.config.caseSensitive ?? !1,
|
|
1569
|
-
if (
|
|
1593
|
+
m.appendChild(v(b[x], x - C.start));
|
|
1594
|
+
}, N = (y) => {
|
|
1595
|
+
const E = this.config.caseSensitive ?? !1, A = E ? y : y.toLowerCase();
|
|
1596
|
+
if (b = i.filter((C) => {
|
|
1570
1597
|
const x = C == null ? "(Blank)" : String(C), k = E ? x : x.toLowerCase();
|
|
1571
|
-
return !y || k.includes(
|
|
1572
|
-
}),
|
|
1573
|
-
|
|
1598
|
+
return !y || k.includes(A);
|
|
1599
|
+
}), b.length === 0) {
|
|
1600
|
+
p.style.height = "0px", m.innerHTML = "";
|
|
1574
1601
|
const C = document.createElement("div");
|
|
1575
|
-
C.className = "tbw-filter-no-match", C.textContent = "No matching values",
|
|
1602
|
+
C.className = "tbw-filter-no-match", C.textContent = "No matching values", m.appendChild(C);
|
|
1576
1603
|
return;
|
|
1577
1604
|
}
|
|
1578
|
-
|
|
1605
|
+
S();
|
|
1579
1606
|
};
|
|
1580
1607
|
f.addEventListener(
|
|
1581
1608
|
"scroll",
|
|
1582
1609
|
() => {
|
|
1583
|
-
|
|
1610
|
+
b.length > 0 && S();
|
|
1584
1611
|
},
|
|
1585
1612
|
{ passive: !0 }
|
|
1586
|
-
),
|
|
1587
|
-
let
|
|
1588
|
-
|
|
1589
|
-
clearTimeout(
|
|
1590
|
-
this.searchText.set(r,
|
|
1613
|
+
), N(l.value), e.appendChild(f);
|
|
1614
|
+
let ce;
|
|
1615
|
+
l.addEventListener("input", () => {
|
|
1616
|
+
clearTimeout(ce), ce = setTimeout(() => {
|
|
1617
|
+
this.searchText.set(r, l.value), N(l.value);
|
|
1591
1618
|
}, this.config.debounceMs ?? 150);
|
|
1592
1619
|
});
|
|
1593
|
-
const
|
|
1594
|
-
|
|
1595
|
-
const
|
|
1596
|
-
|
|
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", () => {
|
|
1597
1624
|
const y = [];
|
|
1598
|
-
for (const [E,
|
|
1599
|
-
if (!
|
|
1625
|
+
for (const [E, A] of w)
|
|
1626
|
+
if (!A)
|
|
1600
1627
|
if (E === "__null__")
|
|
1601
1628
|
y.push(null);
|
|
1602
1629
|
else {
|
|
@@ -1604,11 +1631,11 @@ class A extends R {
|
|
|
1604
1631
|
y.push(C !== void 0 ? C : E);
|
|
1605
1632
|
}
|
|
1606
1633
|
t.applySetFilter(y);
|
|
1607
|
-
}),
|
|
1608
|
-
const
|
|
1609
|
-
|
|
1634
|
+
}), G.appendChild(O);
|
|
1635
|
+
const B = document.createElement("button");
|
|
1636
|
+
B.className = "tbw-filter-clear-btn", B.textContent = "Clear Filter", B.addEventListener("click", () => {
|
|
1610
1637
|
t.clearFilter();
|
|
1611
|
-
}),
|
|
1638
|
+
}), G.appendChild(B), e.appendChild(G);
|
|
1612
1639
|
}
|
|
1613
1640
|
applySetFilter(e, t) {
|
|
1614
1641
|
this.excludedValues.set(e, new Set(t)), t.length === 0 ? this.filters.delete(e) : this.filters.set(e, {
|
|
@@ -1674,7 +1701,7 @@ class A extends R {
|
|
|
1674
1701
|
this.filters.set(e, i), this.cachedResult = null, this.cacheKey = null;
|
|
1675
1702
|
}
|
|
1676
1703
|
}
|
|
1677
|
-
function
|
|
1704
|
+
function Se(s) {
|
|
1678
1705
|
if (!s.length) return [];
|
|
1679
1706
|
const e = /* @__PURE__ */ new Map(), t = [], i = (o, a) => {
|
|
1680
1707
|
if (!a.length) return;
|
|
@@ -1709,7 +1736,7 @@ function xe(s) {
|
|
|
1709
1736
|
}, e.set(d, c), t.push(c)), c.columns.push(o);
|
|
1710
1737
|
}), n.length && i(r, n), t.length === 1 && t[0].implicit && t[0].columns.length === s.length ? [] : t;
|
|
1711
1738
|
}
|
|
1712
|
-
function
|
|
1739
|
+
function Mt(s, e, t) {
|
|
1713
1740
|
if (!e.length || !s) return;
|
|
1714
1741
|
const i = /* @__PURE__ */ new Map();
|
|
1715
1742
|
for (const r of e)
|
|
@@ -1725,7 +1752,7 @@ function Dt(s, e, t) {
|
|
|
1725
1752
|
a && a.classList.add("group-end");
|
|
1726
1753
|
}
|
|
1727
1754
|
}
|
|
1728
|
-
function
|
|
1755
|
+
function qt(s, e) {
|
|
1729
1756
|
if (s.length === 0) return null;
|
|
1730
1757
|
const t = document.createElement("div");
|
|
1731
1758
|
t.className = "header-group-row", t.setAttribute("role", "row");
|
|
@@ -1737,11 +1764,11 @@ function Ft(s, e) {
|
|
|
1737
1764
|
}
|
|
1738
1765
|
return t;
|
|
1739
1766
|
}
|
|
1740
|
-
function
|
|
1767
|
+
function Nt(s) {
|
|
1741
1768
|
return s.some((e) => e.group != null);
|
|
1742
1769
|
}
|
|
1743
|
-
const
|
|
1744
|
-
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 sn extends R {
|
|
1745
1772
|
static manifest = {
|
|
1746
1773
|
ownedProperties: [
|
|
1747
1774
|
{
|
|
@@ -1758,7 +1785,7 @@ class Ji extends R {
|
|
|
1758
1785
|
]
|
|
1759
1786
|
};
|
|
1760
1787
|
name = "groupingColumns";
|
|
1761
|
-
styles =
|
|
1788
|
+
styles = Ht;
|
|
1762
1789
|
get defaultConfig() {
|
|
1763
1790
|
return {
|
|
1764
1791
|
showGroupBorders: !0
|
|
@@ -1773,7 +1800,7 @@ class Ji extends R {
|
|
|
1773
1800
|
if (t?.columnGroups && Array.isArray(t.columnGroups) && t.columnGroups.length > 0)
|
|
1774
1801
|
return !0;
|
|
1775
1802
|
const i = t?.columns;
|
|
1776
|
-
return Array.isArray(i) ?
|
|
1803
|
+
return Array.isArray(i) ? Nt(i) : !1;
|
|
1777
1804
|
}
|
|
1778
1805
|
processColumns(e) {
|
|
1779
1806
|
const t = this.grid?.gridConfig?.columnGroups;
|
|
@@ -1789,7 +1816,7 @@ class Ji extends R {
|
|
|
1789
1816
|
});
|
|
1790
1817
|
} else
|
|
1791
1818
|
i = [...e];
|
|
1792
|
-
const n =
|
|
1819
|
+
const n = Se(i);
|
|
1793
1820
|
return n.length === 0 ? (this.isActive = !1, this.groups = [], i) : (this.isActive = !0, this.groups = n, i);
|
|
1794
1821
|
}
|
|
1795
1822
|
afterRender() {
|
|
@@ -1802,16 +1829,16 @@ class Ji extends R {
|
|
|
1802
1829
|
if (!e) return;
|
|
1803
1830
|
const t = e.querySelector(".header-group-row");
|
|
1804
1831
|
t && t.remove();
|
|
1805
|
-
const i = this.columns, n =
|
|
1832
|
+
const i = this.columns, n = Se(i);
|
|
1806
1833
|
if (n.length === 0) return;
|
|
1807
|
-
const r =
|
|
1834
|
+
const r = qt(n, i);
|
|
1808
1835
|
if (r) {
|
|
1809
1836
|
r.classList.toggle("no-borders", !this.config.showGroupBorders);
|
|
1810
1837
|
const a = e.querySelector(".header-row");
|
|
1811
1838
|
a ? e.insertBefore(r, a) : e.appendChild(r);
|
|
1812
1839
|
}
|
|
1813
1840
|
const o = e.querySelector(".header-row");
|
|
1814
|
-
o && (o.classList.toggle("no-group-borders", !this.config.showGroupBorders),
|
|
1841
|
+
o && (o.classList.toggle("no-group-borders", !this.config.showGroupBorders), Mt(o, n)), this.#e(n);
|
|
1815
1842
|
}
|
|
1816
1843
|
#e(e) {
|
|
1817
1844
|
if (!this.config.showGroupBorders) return;
|
|
@@ -1842,7 +1869,7 @@ class Ji extends R {
|
|
|
1842
1869
|
this.requestRender();
|
|
1843
1870
|
}
|
|
1844
1871
|
}
|
|
1845
|
-
function
|
|
1872
|
+
function Kt({ rows: s, config: e, expanded: t }) {
|
|
1846
1873
|
const i = e.groupOn;
|
|
1847
1874
|
if (typeof i != "function")
|
|
1848
1875
|
return [];
|
|
@@ -1852,9 +1879,9 @@ function qt({ rows: s, config: e, expanded: t }) {
|
|
|
1852
1879
|
l == null || l === !1 ? l = ["__ungrouped__"] : Array.isArray(l) || (l = [l]);
|
|
1853
1880
|
let d = n;
|
|
1854
1881
|
l.forEach((c, u) => {
|
|
1855
|
-
const h = c == null ? "∅" : String(c),
|
|
1856
|
-
let
|
|
1857
|
-
|
|
1882
|
+
const h = c == null ? "∅" : String(c), g = d.key === "__root__" ? h : d.key + "||" + h;
|
|
1883
|
+
let f = d.children.get(h);
|
|
1884
|
+
f || (f = { key: g, value: c, depth: u, rows: [], children: /* @__PURE__ */ new Map(), parent: d }, d.children.set(h, f)), d = f;
|
|
1858
1885
|
}), d.rows.push(a);
|
|
1859
1886
|
}), n.children.size === 1 && n.children.has("__ungrouped__") && n.children.get("__ungrouped__").rows.length === s.length)
|
|
1860
1887
|
return [];
|
|
@@ -1875,26 +1902,26 @@ function qt({ rows: s, config: e, expanded: t }) {
|
|
|
1875
1902
|
};
|
|
1876
1903
|
return o(n), r;
|
|
1877
1904
|
}
|
|
1878
|
-
function
|
|
1905
|
+
function zt(s, e) {
|
|
1879
1906
|
const t = new Set(s);
|
|
1880
1907
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
1881
1908
|
}
|
|
1882
|
-
function
|
|
1909
|
+
function Gt(s) {
|
|
1883
1910
|
const e = /* @__PURE__ */ new Set();
|
|
1884
1911
|
for (const t of s)
|
|
1885
1912
|
t.kind === "group" && e.add(t.key);
|
|
1886
1913
|
return e;
|
|
1887
1914
|
}
|
|
1888
|
-
function
|
|
1915
|
+
function Ot() {
|
|
1889
1916
|
return /* @__PURE__ */ new Set();
|
|
1890
1917
|
}
|
|
1891
|
-
function
|
|
1918
|
+
function Bt(s) {
|
|
1892
1919
|
return s.kind !== "group" ? 0 : s.rows.length;
|
|
1893
1920
|
}
|
|
1894
|
-
const
|
|
1895
|
-
class
|
|
1921
|
+
const Vt = "@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-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}}}";
|
|
1922
|
+
class an extends R {
|
|
1896
1923
|
name = "groupingRows";
|
|
1897
|
-
styles =
|
|
1924
|
+
styles = Vt;
|
|
1898
1925
|
get defaultConfig() {
|
|
1899
1926
|
return {
|
|
1900
1927
|
defaultExpanded: !1,
|
|
@@ -1922,7 +1949,7 @@ class Qi extends R {
|
|
|
1922
1949
|
const t = this.config;
|
|
1923
1950
|
if (typeof t.groupOn != "function")
|
|
1924
1951
|
return this.isActive = !1, this.flattenedRows = [], [...e];
|
|
1925
|
-
const i =
|
|
1952
|
+
const i = Kt({
|
|
1926
1953
|
rows: [...e],
|
|
1927
1954
|
config: t,
|
|
1928
1955
|
expanded: this.expandedKeys
|
|
@@ -1943,7 +1970,7 @@ class Qi extends R {
|
|
|
1943
1970
|
__groupDepth: r.depth,
|
|
1944
1971
|
__groupRows: r.rows,
|
|
1945
1972
|
__groupExpanded: r.expanded,
|
|
1946
|
-
__groupRowCount:
|
|
1973
|
+
__groupRowCount: Bt(r)
|
|
1947
1974
|
} : r.row);
|
|
1948
1975
|
}
|
|
1949
1976
|
onCellClick(e) {
|
|
@@ -2017,42 +2044,42 @@ class Qi extends R {
|
|
|
2017
2044
|
d && (t.style.display = "grid", t.style.gridTemplateColumns = d);
|
|
2018
2045
|
let c = !1;
|
|
2019
2046
|
o.forEach((u, h) => {
|
|
2020
|
-
const
|
|
2021
|
-
if (
|
|
2022
|
-
|
|
2047
|
+
const g = document.createElement("div");
|
|
2048
|
+
if (g.className = "cell group-cell", g.setAttribute("data-col", String(h)), g.setAttribute("role", "gridcell"), se(u)) {
|
|
2049
|
+
g.setAttribute("data-field", u.field), t.appendChild(g);
|
|
2023
2050
|
return;
|
|
2024
2051
|
}
|
|
2025
2052
|
if (c) {
|
|
2026
|
-
const
|
|
2027
|
-
if (
|
|
2028
|
-
const p =
|
|
2029
|
-
|
|
2053
|
+
const f = r[u.field];
|
|
2054
|
+
if (f) {
|
|
2055
|
+
const p = he(f, a, u.field, u);
|
|
2056
|
+
g.textContent = p != null ? String(p) : "";
|
|
2030
2057
|
} else
|
|
2031
|
-
|
|
2058
|
+
g.textContent = "";
|
|
2032
2059
|
} else {
|
|
2033
|
-
c = !0,
|
|
2034
|
-
const
|
|
2060
|
+
c = !0, g.appendChild(this.createToggleButton(e.__groupExpanded, i));
|
|
2061
|
+
const f = document.createElement("span"), p = r[u.field];
|
|
2035
2062
|
if (p) {
|
|
2036
|
-
const m =
|
|
2037
|
-
|
|
2063
|
+
const m = he(p, a, u.field, u);
|
|
2064
|
+
f.textContent = m != null ? String(m) : String(e.__groupValue);
|
|
2038
2065
|
} else
|
|
2039
|
-
|
|
2040
|
-
if (
|
|
2066
|
+
f.textContent = this.getGroupLabelText(e.__groupValue, e.__groupDepth || 0, e.__groupKey);
|
|
2067
|
+
if (g.appendChild(f), n.showRowCount !== !1) {
|
|
2041
2068
|
const m = document.createElement("span");
|
|
2042
|
-
m.className = "group-count", m.textContent = ` (${a.length})`,
|
|
2069
|
+
m.className = "group-count", m.textContent = ` (${a.length})`, g.appendChild(m);
|
|
2043
2070
|
}
|
|
2044
2071
|
}
|
|
2045
|
-
t.appendChild(
|
|
2072
|
+
t.appendChild(g);
|
|
2046
2073
|
});
|
|
2047
2074
|
}
|
|
2048
2075
|
expandAll() {
|
|
2049
|
-
this.expandedKeys =
|
|
2076
|
+
this.expandedKeys = Gt(this.flattenedRows), this.requestRender();
|
|
2050
2077
|
}
|
|
2051
2078
|
collapseAll() {
|
|
2052
|
-
this.expandedKeys =
|
|
2079
|
+
this.expandedKeys = Ot(), this.requestRender();
|
|
2053
2080
|
}
|
|
2054
2081
|
toggle(e) {
|
|
2055
|
-
this.expandedKeys =
|
|
2082
|
+
this.expandedKeys = zt(this.expandedKeys, e);
|
|
2056
2083
|
const t = this.flattenedRows.find((i) => i.kind === "group" && i.key === e);
|
|
2057
2084
|
this.emit("group-toggle", {
|
|
2058
2085
|
key: e,
|
|
@@ -2101,22 +2128,22 @@ class Qi extends R {
|
|
|
2101
2128
|
this.config.groupOn = e, this.requestRender();
|
|
2102
2129
|
}
|
|
2103
2130
|
}
|
|
2104
|
-
function
|
|
2131
|
+
function ke(s, e) {
|
|
2105
2132
|
const t = new Set(s);
|
|
2106
2133
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
2107
2134
|
}
|
|
2108
|
-
function
|
|
2135
|
+
function Wt(s, e) {
|
|
2109
2136
|
const t = new Set(s);
|
|
2110
2137
|
return t.add(e), t;
|
|
2111
2138
|
}
|
|
2112
|
-
function
|
|
2139
|
+
function $t(s, e) {
|
|
2113
2140
|
const t = new Set(s);
|
|
2114
2141
|
return t.delete(e), t;
|
|
2115
2142
|
}
|
|
2116
|
-
function
|
|
2143
|
+
function jt(s, e) {
|
|
2117
2144
|
return s.has(e);
|
|
2118
2145
|
}
|
|
2119
|
-
function
|
|
2146
|
+
function Ut(s, e, t, i) {
|
|
2120
2147
|
const n = document.createElement("div");
|
|
2121
2148
|
n.className = "master-detail-row", n.setAttribute("data-detail-for", String(e)), n.setAttribute("role", "row");
|
|
2122
2149
|
const r = document.createElement("div");
|
|
@@ -2124,10 +2151,10 @@ function Wt(s, e, t, i) {
|
|
|
2124
2151
|
const o = t(s, e);
|
|
2125
2152
|
return typeof o == "string" ? r.innerHTML = o : o instanceof HTMLElement && r.appendChild(o), n.appendChild(r), n;
|
|
2126
2153
|
}
|
|
2127
|
-
const
|
|
2128
|
-
class
|
|
2154
|
+
const Yt = "@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}}}";
|
|
2155
|
+
class $e extends R {
|
|
2129
2156
|
name = "masterDetail";
|
|
2130
|
-
styles =
|
|
2157
|
+
styles = Yt;
|
|
2131
2158
|
get defaultConfig() {
|
|
2132
2159
|
return {
|
|
2133
2160
|
detailHeight: "auto",
|
|
@@ -2156,8 +2183,8 @@ class Be extends R {
|
|
|
2156
2183
|
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));
|
|
2157
2184
|
const c = t.innerHTML.trim();
|
|
2158
2185
|
c && !this.config.detailRenderer && (d.detailRenderer = (u, h) => {
|
|
2159
|
-
const
|
|
2160
|
-
return
|
|
2186
|
+
const g = Qe(c, { value: u, row: u });
|
|
2187
|
+
return et(g);
|
|
2161
2188
|
}), Object.keys(d).length > 0 && (this.config = { ...this.config, ...d });
|
|
2162
2189
|
}
|
|
2163
2190
|
get animationStyle() {
|
|
@@ -2188,10 +2215,10 @@ class Be extends R {
|
|
|
2188
2215
|
static DEFAULT_DETAIL_HEIGHT = 150;
|
|
2189
2216
|
getDetailHeight(e) {
|
|
2190
2217
|
const t = this.detailElements.get(e);
|
|
2191
|
-
return t ? t.offsetHeight : typeof this.config?.detailHeight == "number" ? this.config.detailHeight :
|
|
2218
|
+
return t ? t.offsetHeight : typeof this.config?.detailHeight == "number" ? this.config.detailHeight : $e.DEFAULT_DETAIL_HEIGHT;
|
|
2192
2219
|
}
|
|
2193
2220
|
toggleAndEmit(e, t) {
|
|
2194
|
-
this.expandedRows =
|
|
2221
|
+
this.expandedRows = ke(this.expandedRows, e), this.emit("detail-expand", {
|
|
2195
2222
|
rowIndex: t,
|
|
2196
2223
|
row: e,
|
|
2197
2224
|
expanded: this.expandedRows.has(e)
|
|
@@ -2204,9 +2231,9 @@ class Be extends R {
|
|
|
2204
2231
|
if (!(this.config.showExpandColumn === !0 || this.config.showExpandColumn !== !1 && !!this.config.detailRenderer))
|
|
2205
2232
|
return [...e];
|
|
2206
2233
|
const i = [...e];
|
|
2207
|
-
if (
|
|
2234
|
+
if (rt(i))
|
|
2208
2235
|
return i;
|
|
2209
|
-
const r =
|
|
2236
|
+
const r = ot(this.name);
|
|
2210
2237
|
return r.viewRenderer = (o) => {
|
|
2211
2238
|
const { row: a } = o, l = this.expandedRows.has(a), d = document.createElement("span");
|
|
2212
2239
|
d.className = "master-detail-expander expander-cell";
|
|
@@ -2226,7 +2253,7 @@ class Be extends R {
|
|
|
2226
2253
|
onKeyDown(e) {
|
|
2227
2254
|
if (e.key !== " ") return;
|
|
2228
2255
|
const t = this.grid._focusCol, i = this.grid._focusRow, n = this.columns[t];
|
|
2229
|
-
if (!n || !
|
|
2256
|
+
if (!n || !se(n)) return;
|
|
2230
2257
|
const r = this.rows[i];
|
|
2231
2258
|
if (r)
|
|
2232
2259
|
return e.preventDefault(), this.toggleAndEmit(r, i), this.requestRenderWithFocus(), !0;
|
|
@@ -2259,7 +2286,7 @@ class Be extends R {
|
|
|
2259
2286
|
d.previousElementSibling !== a && a.after(d);
|
|
2260
2287
|
continue;
|
|
2261
2288
|
}
|
|
2262
|
-
const c =
|
|
2289
|
+
const c = Ut(l, o, this.config.detailRenderer, n);
|
|
2263
2290
|
typeof this.config.detailHeight == "number" && (c.style.height = `${this.config.detailHeight}px`), a.after(c), this.detailElements.set(l, c), this.animateExpand(c);
|
|
2264
2291
|
}
|
|
2265
2292
|
}
|
|
@@ -2294,19 +2321,19 @@ class Be extends R {
|
|
|
2294
2321
|
}
|
|
2295
2322
|
expand(e) {
|
|
2296
2323
|
const t = this.rows[e];
|
|
2297
|
-
t && (this.expandedRows =
|
|
2324
|
+
t && (this.expandedRows = Wt(this.expandedRows, t), this.requestRender());
|
|
2298
2325
|
}
|
|
2299
2326
|
collapse(e) {
|
|
2300
2327
|
const t = this.rows[e];
|
|
2301
|
-
t && (this.expandedRows =
|
|
2328
|
+
t && (this.expandedRows = $t(this.expandedRows, t), this.requestRender());
|
|
2302
2329
|
}
|
|
2303
2330
|
toggle(e) {
|
|
2304
2331
|
const t = this.rows[e];
|
|
2305
|
-
t && (this.expandedRows =
|
|
2332
|
+
t && (this.expandedRows = ke(this.expandedRows, t), this.requestRender());
|
|
2306
2333
|
}
|
|
2307
2334
|
isExpanded(e) {
|
|
2308
2335
|
const t = this.rows[e];
|
|
2309
|
-
return t ?
|
|
2336
|
+
return t ? jt(this.expandedRows, t) : !1;
|
|
2310
2337
|
}
|
|
2311
2338
|
expandAll() {
|
|
2312
2339
|
for (const e of this.rows)
|
|
@@ -2336,34 +2363,34 @@ class Be extends R {
|
|
|
2336
2363
|
}
|
|
2337
2364
|
}
|
|
2338
2365
|
}
|
|
2339
|
-
function
|
|
2366
|
+
function Xt(s, e, t) {
|
|
2340
2367
|
return e.length ? [...s].sort((i, n) => {
|
|
2341
2368
|
for (const r of e) {
|
|
2342
|
-
const a = t.find((u) => u.field === r.field)?.sortComparator ??
|
|
2369
|
+
const a = t.find((u) => u.field === r.field)?.sortComparator ?? Zt, l = i[r.field], d = n[r.field], c = a(l, d, i, n);
|
|
2343
2370
|
if (c !== 0)
|
|
2344
2371
|
return r.direction === "asc" ? c : -c;
|
|
2345
2372
|
}
|
|
2346
2373
|
return 0;
|
|
2347
2374
|
}) : [...s];
|
|
2348
2375
|
}
|
|
2349
|
-
function
|
|
2376
|
+
function Zt(s, e) {
|
|
2350
2377
|
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));
|
|
2351
2378
|
}
|
|
2352
|
-
function
|
|
2379
|
+
function Jt(s, e, t, i) {
|
|
2353
2380
|
const n = s.find((r) => r.field === e);
|
|
2354
2381
|
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" }];
|
|
2355
2382
|
}
|
|
2356
|
-
function
|
|
2383
|
+
function Ae(s, e) {
|
|
2357
2384
|
const t = s.findIndex((i) => i.field === e);
|
|
2358
2385
|
return t >= 0 ? t + 1 : void 0;
|
|
2359
2386
|
}
|
|
2360
|
-
function
|
|
2387
|
+
function _e(s, e) {
|
|
2361
2388
|
return s.find((t) => t.field === e)?.direction;
|
|
2362
2389
|
}
|
|
2363
|
-
const
|
|
2364
|
-
class
|
|
2390
|
+
const Qt = '@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}}';
|
|
2391
|
+
class ln extends R {
|
|
2365
2392
|
name = "multiSort";
|
|
2366
|
-
styles =
|
|
2393
|
+
styles = Qt;
|
|
2367
2394
|
get defaultConfig() {
|
|
2368
2395
|
return {
|
|
2369
2396
|
maxSortColumns: 3,
|
|
@@ -2375,12 +2402,12 @@ class en extends R {
|
|
|
2375
2402
|
this.sortModel = [];
|
|
2376
2403
|
}
|
|
2377
2404
|
processRows(e) {
|
|
2378
|
-
return this.sortModel.length === 0 ? [...e] :
|
|
2405
|
+
return this.sortModel.length === 0 ? [...e] : Xt([...e], this.sortModel, [...this.columns]);
|
|
2379
2406
|
}
|
|
2380
2407
|
onHeaderClick(e) {
|
|
2381
2408
|
if (!this.columns.find((r) => r.field === e.field)?.sortable) return !1;
|
|
2382
2409
|
const i = e.originalEvent.shiftKey, n = this.config.maxSortColumns ?? 3;
|
|
2383
|
-
return this.sortModel =
|
|
2410
|
+
return this.sortModel = Jt(this.sortModel, e.field, i, n), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), !0;
|
|
2384
2411
|
}
|
|
2385
2412
|
afterRender() {
|
|
2386
2413
|
const e = this.gridElement;
|
|
@@ -2389,15 +2416,15 @@ class en extends R {
|
|
|
2389
2416
|
e.querySelectorAll(".header-row .cell[data-field]").forEach((n) => {
|
|
2390
2417
|
const r = n.getAttribute("data-field");
|
|
2391
2418
|
if (!r) return;
|
|
2392
|
-
const o =
|
|
2419
|
+
const o = Ae(this.sortModel, r), a = _e(this.sortModel, r);
|
|
2393
2420
|
if (n.querySelector(".sort-index")?.remove(), a) {
|
|
2394
2421
|
n.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), n.setAttribute("data-sort", a);
|
|
2395
2422
|
const c = document.createElement("span");
|
|
2396
2423
|
c.className = "sort-indicator", this.setIcon(c, this.resolveIcon(a === "asc" ? "sortAsc" : "sortDesc"));
|
|
2397
|
-
const u = n.querySelector(".tbw-filter-btn"), h = n.querySelector(".resize-handle"),
|
|
2398
|
-
if (
|
|
2399
|
-
const
|
|
2400
|
-
|
|
2424
|
+
const u = n.querySelector(".tbw-filter-btn"), h = n.querySelector(".resize-handle"), g = u ?? h;
|
|
2425
|
+
if (g ? n.insertBefore(c, g) : n.appendChild(c), t && this.sortModel.length > 1 && o !== void 0) {
|
|
2426
|
+
const f = document.createElement("span");
|
|
2427
|
+
f.className = "sort-index", f.textContent = String(o), c.nextSibling ? n.insertBefore(f, c.nextSibling) : n.appendChild(f);
|
|
2401
2428
|
}
|
|
2402
2429
|
} else
|
|
2403
2430
|
n.removeAttribute("data-sort");
|
|
@@ -2413,10 +2440,10 @@ class en extends R {
|
|
|
2413
2440
|
this.sortModel = [], this.emit("sort-change", { sortModel: [] }), this.requestRender();
|
|
2414
2441
|
}
|
|
2415
2442
|
getSortIndex(e) {
|
|
2416
|
-
return
|
|
2443
|
+
return Ae(this.sortModel, e);
|
|
2417
2444
|
}
|
|
2418
2445
|
getSortDirection(e) {
|
|
2419
|
-
return
|
|
2446
|
+
return _e(this.sortModel, e);
|
|
2420
2447
|
}
|
|
2421
2448
|
getColumnState(e) {
|
|
2422
2449
|
const t = this.sortModel.findIndex((n) => n.field === e);
|
|
@@ -2439,16 +2466,16 @@ class en extends R {
|
|
|
2439
2466
|
i !== -1 ? this.sortModel[i] = n : this.sortModel.splice(t.sort.priority, 0, n);
|
|
2440
2467
|
}
|
|
2441
2468
|
}
|
|
2442
|
-
function
|
|
2469
|
+
function ei(s) {
|
|
2443
2470
|
return s.filter((e) => e.sticky === "left");
|
|
2444
2471
|
}
|
|
2445
|
-
function
|
|
2472
|
+
function ti(s) {
|
|
2446
2473
|
return s.filter((e) => e.sticky === "right");
|
|
2447
2474
|
}
|
|
2448
|
-
function
|
|
2475
|
+
function J(s) {
|
|
2449
2476
|
return s.some((e) => e.sticky === "left" || e.sticky === "right");
|
|
2450
2477
|
}
|
|
2451
|
-
function
|
|
2478
|
+
function Le(s, e) {
|
|
2452
2479
|
const t = Array.from(s.querySelectorAll(".header-row .cell"));
|
|
2453
2480
|
if (!t.length) return;
|
|
2454
2481
|
const i = /* @__PURE__ */ new Map();
|
|
@@ -2472,12 +2499,12 @@ function ke(s, e) {
|
|
|
2472
2499
|
}), r += l.offsetWidth);
|
|
2473
2500
|
}
|
|
2474
2501
|
}
|
|
2475
|
-
function
|
|
2502
|
+
function Te(s) {
|
|
2476
2503
|
s.querySelectorAll(".sticky-left, .sticky-right").forEach((t) => {
|
|
2477
2504
|
t.classList.remove("sticky-left", "sticky-right"), t.style.position = "", t.style.left = "", t.style.right = "";
|
|
2478
2505
|
});
|
|
2479
2506
|
}
|
|
2480
|
-
class
|
|
2507
|
+
class dn extends R {
|
|
2481
2508
|
static manifest = {
|
|
2482
2509
|
ownedProperties: [
|
|
2483
2510
|
{
|
|
@@ -2500,26 +2527,26 @@ class tn extends R {
|
|
|
2500
2527
|
}
|
|
2501
2528
|
static detect(e, t) {
|
|
2502
2529
|
const i = t?.columns;
|
|
2503
|
-
return Array.isArray(i) ?
|
|
2530
|
+
return Array.isArray(i) ? J(i) : !1;
|
|
2504
2531
|
}
|
|
2505
2532
|
processColumns(e) {
|
|
2506
|
-
return this.isApplied =
|
|
2533
|
+
return this.isApplied = J([...e]), [...e];
|
|
2507
2534
|
}
|
|
2508
2535
|
afterRender() {
|
|
2509
2536
|
if (!this.isApplied)
|
|
2510
2537
|
return;
|
|
2511
2538
|
const e = this.grid, t = [...this.columns];
|
|
2512
|
-
if (!
|
|
2513
|
-
|
|
2539
|
+
if (!J(t)) {
|
|
2540
|
+
Te(e), this.isApplied = !1;
|
|
2514
2541
|
return;
|
|
2515
2542
|
}
|
|
2516
2543
|
queueMicrotask(() => {
|
|
2517
|
-
|
|
2544
|
+
Le(e, t);
|
|
2518
2545
|
});
|
|
2519
2546
|
}
|
|
2520
2547
|
onPluginQuery(e) {
|
|
2521
2548
|
switch (e.type) {
|
|
2522
|
-
case
|
|
2549
|
+
case Ve.CAN_MOVE_COLUMN: {
|
|
2523
2550
|
const t = e.context, i = t.sticky;
|
|
2524
2551
|
if (i === "left" || i === "right")
|
|
2525
2552
|
return !1;
|
|
@@ -2532,18 +2559,18 @@ class tn extends R {
|
|
|
2532
2559
|
}
|
|
2533
2560
|
refreshStickyOffsets() {
|
|
2534
2561
|
const e = [...this.columns];
|
|
2535
|
-
|
|
2562
|
+
Le(this.grid, e);
|
|
2536
2563
|
}
|
|
2537
2564
|
getLeftPinnedColumns() {
|
|
2538
2565
|
const e = [...this.columns];
|
|
2539
|
-
return
|
|
2566
|
+
return ei(e);
|
|
2540
2567
|
}
|
|
2541
2568
|
getRightPinnedColumns() {
|
|
2542
2569
|
const e = [...this.columns];
|
|
2543
|
-
return
|
|
2570
|
+
return ti(e);
|
|
2544
2571
|
}
|
|
2545
2572
|
clearStickyPositions() {
|
|
2546
|
-
|
|
2573
|
+
Te(this.grid);
|
|
2547
2574
|
}
|
|
2548
2575
|
getHorizontalScrollOffsets(e, t) {
|
|
2549
2576
|
if (!this.isApplied)
|
|
@@ -2564,10 +2591,10 @@ class tn extends R {
|
|
|
2564
2591
|
return { left: i, right: n, skipScroll: r };
|
|
2565
2592
|
}
|
|
2566
2593
|
}
|
|
2567
|
-
function
|
|
2594
|
+
function ii(s) {
|
|
2568
2595
|
return typeof s == "object" && s !== null && "aggFunc" in s;
|
|
2569
2596
|
}
|
|
2570
|
-
function
|
|
2597
|
+
function Q(s, e) {
|
|
2571
2598
|
const t = document.createElement("div");
|
|
2572
2599
|
t.className = "tbw-pinned-rows", t.setAttribute("role", "presentation"), t.setAttribute("aria-live", "polite");
|
|
2573
2600
|
const i = document.createElement("div");
|
|
@@ -2589,7 +2616,7 @@ function Z(s, e) {
|
|
|
2589
2616
|
}
|
|
2590
2617
|
if (s.customPanels)
|
|
2591
2618
|
for (const o of s.customPanels) {
|
|
2592
|
-
const a =
|
|
2619
|
+
const a = ni(o, e);
|
|
2593
2620
|
switch (o.position) {
|
|
2594
2621
|
case "left":
|
|
2595
2622
|
i.appendChild(a);
|
|
@@ -2604,11 +2631,11 @@ function Z(s, e) {
|
|
|
2604
2631
|
}
|
|
2605
2632
|
return t.appendChild(i), t.appendChild(n), t.appendChild(r), t;
|
|
2606
2633
|
}
|
|
2607
|
-
function
|
|
2634
|
+
function Ie(s) {
|
|
2608
2635
|
const e = document.createElement("div");
|
|
2609
2636
|
return e.className = `tbw-aggregation-rows tbw-aggregation-rows-${s}`, e.setAttribute("role", "presentation"), e;
|
|
2610
2637
|
}
|
|
2611
|
-
function
|
|
2638
|
+
function Pe(s, e, t, i) {
|
|
2612
2639
|
s.innerHTML = "";
|
|
2613
2640
|
for (const n of e) {
|
|
2614
2641
|
const r = document.createElement("div");
|
|
@@ -2622,11 +2649,11 @@ function Le(s, e, t, i) {
|
|
|
2622
2649
|
let l, d;
|
|
2623
2650
|
const c = n.aggregators?.[o.field];
|
|
2624
2651
|
if (c)
|
|
2625
|
-
if (
|
|
2626
|
-
const u =
|
|
2652
|
+
if (ii(c)) {
|
|
2653
|
+
const u = ge(c.aggFunc);
|
|
2627
2654
|
u && (l = u(i, o.field, o)), d = c.formatter;
|
|
2628
2655
|
} else {
|
|
2629
|
-
const u =
|
|
2656
|
+
const u = ge(c);
|
|
2630
2657
|
u && (l = u(i, o.field, o));
|
|
2631
2658
|
}
|
|
2632
2659
|
else if (n.cells && Object.prototype.hasOwnProperty.call(n.cells, o.field)) {
|
|
@@ -2638,13 +2665,13 @@ function Le(s, e, t, i) {
|
|
|
2638
2665
|
s.appendChild(r);
|
|
2639
2666
|
}
|
|
2640
2667
|
}
|
|
2641
|
-
function
|
|
2668
|
+
function ni(s, e) {
|
|
2642
2669
|
const t = document.createElement("div");
|
|
2643
2670
|
t.className = "tbw-status-panel tbw-status-panel-custom", t.id = `status-panel-${s.id}`;
|
|
2644
2671
|
const i = s.render(e);
|
|
2645
2672
|
return typeof i == "string" ? t.innerHTML = i : t.appendChild(i), t;
|
|
2646
2673
|
}
|
|
2647
|
-
function
|
|
2674
|
+
function Fe(s, e, t, i, n) {
|
|
2648
2675
|
return {
|
|
2649
2676
|
totalRows: s.length,
|
|
2650
2677
|
filteredRows: n?.cachedResult?.length ?? s.length,
|
|
@@ -2654,10 +2681,10 @@ function Te(s, e, t, i, n) {
|
|
|
2654
2681
|
grid: t
|
|
2655
2682
|
};
|
|
2656
2683
|
}
|
|
2657
|
-
const
|
|
2658
|
-
class
|
|
2684
|
+
const ri = "@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:flex;align-items:center;border-right:1px solid var(--tbw-color-border-cell)}.tbw-aggregation-cell:last-child{border-right:0}.tbw-aggregation-cell-full{grid-column:1 / -1;border-right:0}}";
|
|
2685
|
+
class cn extends R {
|
|
2659
2686
|
name = "pinnedRows";
|
|
2660
|
-
styles =
|
|
2687
|
+
styles = ri;
|
|
2661
2688
|
get defaultConfig() {
|
|
2662
2689
|
return {
|
|
2663
2690
|
position: "bottom",
|
|
@@ -2679,7 +2706,7 @@ class nn extends R {
|
|
|
2679
2706
|
const t = e.querySelector(".tbw-scroll-area") ?? e.querySelector(".tbw-grid-content") ?? e.children[0];
|
|
2680
2707
|
if (!t) return;
|
|
2681
2708
|
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);
|
|
2682
|
-
const i = this.getSelectionState(), n = this.getFilterState(), r =
|
|
2709
|
+
const i = this.getSelectionState(), n = this.getFilterState(), r = Fe(
|
|
2683
2710
|
this.rows,
|
|
2684
2711
|
this.columns,
|
|
2685
2712
|
this.grid,
|
|
@@ -2688,11 +2715,11 @@ class nn extends R {
|
|
|
2688
2715
|
), o = this.config.aggregationRows || [], a = o.filter((h) => h.position === "top"), l = o.filter((h) => h.position !== "top");
|
|
2689
2716
|
if (a.length > 0) {
|
|
2690
2717
|
if (!this.topAggregationContainer) {
|
|
2691
|
-
this.topAggregationContainer =
|
|
2718
|
+
this.topAggregationContainer = Ie("top");
|
|
2692
2719
|
const h = e.querySelector(".header");
|
|
2693
2720
|
h && h.nextSibling ? t.insertBefore(this.topAggregationContainer, h.nextSibling) : t.appendChild(this.topAggregationContainer);
|
|
2694
2721
|
}
|
|
2695
|
-
|
|
2722
|
+
Pe(
|
|
2696
2723
|
this.topAggregationContainer,
|
|
2697
2724
|
a,
|
|
2698
2725
|
this.visibleColumns,
|
|
@@ -2702,18 +2729,18 @@ class nn extends R {
|
|
|
2702
2729
|
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;
|
|
2703
2730
|
if (d && this.config.position === "top")
|
|
2704
2731
|
if (!this.infoBarElement)
|
|
2705
|
-
this.infoBarElement =
|
|
2732
|
+
this.infoBarElement = Q(this.config, r), t.insertBefore(this.infoBarElement, t.firstChild);
|
|
2706
2733
|
else {
|
|
2707
|
-
const h =
|
|
2734
|
+
const h = Q(this.config, r);
|
|
2708
2735
|
this.infoBarElement.replaceWith(h), this.infoBarElement = h;
|
|
2709
2736
|
}
|
|
2710
2737
|
else this.config.position === "top" && this.infoBarElement && (this.infoBarElement.remove(), this.infoBarElement = null);
|
|
2711
|
-
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 =
|
|
2738
|
+
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 = Ie("bottom")), this.footerWrapper.appendChild(this.bottomAggregationContainer), Pe(
|
|
2712
2739
|
this.bottomAggregationContainer,
|
|
2713
2740
|
l,
|
|
2714
2741
|
this.visibleColumns,
|
|
2715
2742
|
this.rows
|
|
2716
|
-
)), c && (this.infoBarElement =
|
|
2743
|
+
)), c && (this.infoBarElement = Q(this.config, r), this.footerWrapper.appendChild(this.infoBarElement))) : this.cleanupFooter();
|
|
2717
2744
|
}
|
|
2718
2745
|
cleanup() {
|
|
2719
2746
|
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);
|
|
@@ -2740,7 +2767,7 @@ class nn extends R {
|
|
|
2740
2767
|
}
|
|
2741
2768
|
getContext() {
|
|
2742
2769
|
const e = this.getSelectionState(), t = this.getFilterState();
|
|
2743
|
-
return
|
|
2770
|
+
return Fe(
|
|
2744
2771
|
this.rows,
|
|
2745
2772
|
this.columns,
|
|
2746
2773
|
this.grid,
|
|
@@ -2761,16 +2788,16 @@ class nn extends R {
|
|
|
2761
2788
|
this.config.aggregationRows && (this.config.aggregationRows = this.config.aggregationRows.filter((t) => t.id !== e), this.requestRender());
|
|
2762
2789
|
}
|
|
2763
2790
|
}
|
|
2764
|
-
const
|
|
2765
|
-
function
|
|
2791
|
+
const oi = tt;
|
|
2792
|
+
function si(s) {
|
|
2766
2793
|
const e = [];
|
|
2767
2794
|
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;
|
|
2768
2795
|
}
|
|
2769
|
-
function
|
|
2796
|
+
function de(s, e) {
|
|
2770
2797
|
return [...s, e].join("|");
|
|
2771
2798
|
}
|
|
2772
|
-
function
|
|
2773
|
-
const t = e.rowGroupFields ?? [], i = e.columnGroupFields ?? [], n = e.valueFields ?? [], r =
|
|
2799
|
+
function ai(s, e) {
|
|
2800
|
+
const t = e.rowGroupFields ?? [], i = e.columnGroupFields ?? [], n = e.valueFields ?? [], r = li(s, i), o = je(
|
|
2774
2801
|
s,
|
|
2775
2802
|
t,
|
|
2776
2803
|
i,
|
|
@@ -2778,7 +2805,7 @@ function ri(s, e) {
|
|
|
2778
2805
|
n,
|
|
2779
2806
|
0,
|
|
2780
2807
|
""
|
|
2781
|
-
), a =
|
|
2808
|
+
), a = ci(o, r, n), l = Object.values(a).reduce((d, c) => d + c, 0);
|
|
2782
2809
|
return {
|
|
2783
2810
|
rows: o,
|
|
2784
2811
|
columnKeys: r,
|
|
@@ -2786,7 +2813,7 @@ function ri(s, e) {
|
|
|
2786
2813
|
grandTotal: l
|
|
2787
2814
|
};
|
|
2788
2815
|
}
|
|
2789
|
-
function
|
|
2816
|
+
function li(s, e) {
|
|
2790
2817
|
if (e.length === 0) return ["value"];
|
|
2791
2818
|
const t = /* @__PURE__ */ new Set();
|
|
2792
2819
|
for (const i of s) {
|
|
@@ -2795,7 +2822,7 @@ function oi(s, e) {
|
|
|
2795
2822
|
}
|
|
2796
2823
|
return [...t].sort();
|
|
2797
2824
|
}
|
|
2798
|
-
function
|
|
2825
|
+
function di(s, e) {
|
|
2799
2826
|
const t = /* @__PURE__ */ new Map();
|
|
2800
2827
|
for (const i of s) {
|
|
2801
2828
|
const n = String(i[e] ?? ""), r = t.get(n);
|
|
@@ -2803,75 +2830,75 @@ function si(s, e) {
|
|
|
2803
2830
|
}
|
|
2804
2831
|
return t;
|
|
2805
2832
|
}
|
|
2806
|
-
function
|
|
2833
|
+
function je(s, e, t, i, n, r, o) {
|
|
2807
2834
|
const a = [];
|
|
2808
2835
|
if (e.length === 0) {
|
|
2809
|
-
const h =
|
|
2836
|
+
const h = De(s, t, i, n), g = Me(h);
|
|
2810
2837
|
return a.push({
|
|
2811
2838
|
rowKey: o || "all",
|
|
2812
2839
|
rowLabel: o || "All",
|
|
2813
2840
|
depth: r,
|
|
2814
2841
|
values: h,
|
|
2815
|
-
total:
|
|
2842
|
+
total: g,
|
|
2816
2843
|
isGroup: !1,
|
|
2817
2844
|
rowCount: s.length
|
|
2818
2845
|
}), a;
|
|
2819
2846
|
}
|
|
2820
|
-
const l = e[0], d = e.slice(1), c = d.length > 0, u =
|
|
2821
|
-
for (const [h,
|
|
2822
|
-
const
|
|
2847
|
+
const l = e[0], d = e.slice(1), c = d.length > 0, u = di(s, l);
|
|
2848
|
+
for (const [h, g] of u) {
|
|
2849
|
+
const f = o ? `${o}|${h}` : h, p = De(g, t, i, n), m = Me(p);
|
|
2823
2850
|
let w;
|
|
2824
|
-
c && (w =
|
|
2825
|
-
|
|
2851
|
+
c && (w = je(
|
|
2852
|
+
g,
|
|
2826
2853
|
d,
|
|
2827
2854
|
t,
|
|
2828
2855
|
i,
|
|
2829
2856
|
n,
|
|
2830
2857
|
r + 1,
|
|
2831
|
-
|
|
2858
|
+
f
|
|
2832
2859
|
)), a.push({
|
|
2833
|
-
rowKey:
|
|
2860
|
+
rowKey: f,
|
|
2834
2861
|
rowLabel: h || "(blank)",
|
|
2835
2862
|
depth: r,
|
|
2836
2863
|
values: p,
|
|
2837
2864
|
total: m,
|
|
2838
2865
|
isGroup: c,
|
|
2839
2866
|
children: w,
|
|
2840
|
-
rowCount:
|
|
2867
|
+
rowCount: g.length
|
|
2841
2868
|
});
|
|
2842
2869
|
}
|
|
2843
2870
|
return a;
|
|
2844
2871
|
}
|
|
2845
|
-
function
|
|
2872
|
+
function De(s, e, t, i) {
|
|
2846
2873
|
const n = {};
|
|
2847
2874
|
for (const r of t)
|
|
2848
2875
|
for (const o of i) {
|
|
2849
|
-
const l = (e.length > 0 ? s.filter((h) => e.map((
|
|
2876
|
+
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 = oi(o.aggFunc), c = l.length > 0 ? d(l) : null, u = de([r], o.field);
|
|
2850
2877
|
n[u] = c;
|
|
2851
2878
|
}
|
|
2852
2879
|
return n;
|
|
2853
2880
|
}
|
|
2854
|
-
function
|
|
2881
|
+
function Me(s) {
|
|
2855
2882
|
let e = 0;
|
|
2856
2883
|
for (const t of Object.values(s))
|
|
2857
2884
|
e += t ?? 0;
|
|
2858
2885
|
return e;
|
|
2859
2886
|
}
|
|
2860
|
-
function
|
|
2887
|
+
function ci(s, e, t) {
|
|
2861
2888
|
const i = {};
|
|
2862
2889
|
function n(r) {
|
|
2863
2890
|
for (const o of r)
|
|
2864
2891
|
if (!o.isGroup || !o.children?.length)
|
|
2865
2892
|
for (const a of e)
|
|
2866
2893
|
for (const l of t) {
|
|
2867
|
-
const d =
|
|
2894
|
+
const d = de([a], l.field);
|
|
2868
2895
|
i[d] = (i[d] ?? 0) + (o.values[d] ?? 0);
|
|
2869
2896
|
}
|
|
2870
2897
|
else o.children && n(o.children);
|
|
2871
2898
|
}
|
|
2872
2899
|
return n(s), i;
|
|
2873
2900
|
}
|
|
2874
|
-
function
|
|
2901
|
+
function ui(s, e, t = !0) {
|
|
2875
2902
|
const i = [];
|
|
2876
2903
|
function n(r) {
|
|
2877
2904
|
i.push(r);
|
|
@@ -2884,7 +2911,7 @@ function li(s, e, t = !0) {
|
|
|
2884
2911
|
n(r);
|
|
2885
2912
|
return i;
|
|
2886
2913
|
}
|
|
2887
|
-
function
|
|
2914
|
+
function hi(s) {
|
|
2888
2915
|
const e = [];
|
|
2889
2916
|
function t(i) {
|
|
2890
2917
|
if (i.isGroup && e.push(i.rowKey), i.children)
|
|
@@ -2895,14 +2922,14 @@ function di(s) {
|
|
|
2895
2922
|
t(i);
|
|
2896
2923
|
return e;
|
|
2897
2924
|
}
|
|
2898
|
-
const
|
|
2899
|
-
function
|
|
2925
|
+
const gi = ["sum", "avg", "count", "min", "max", "first", "last"];
|
|
2926
|
+
function fi(s, e, t, i) {
|
|
2900
2927
|
const n = new AbortController(), r = { config: e, callbacks: i, signal: n.signal }, o = document.createElement("div");
|
|
2901
|
-
return o.className = "tbw-pivot-panel", o.appendChild(
|
|
2928
|
+
return o.className = "tbw-pivot-panel", o.appendChild(K("Options", () => vi(t, r))), o.appendChild(K("Row Groups", () => qe("rowGroups", r))), o.appendChild(K("Column Groups", () => qe("columnGroups", r))), o.appendChild(K("Values", () => mi(r))), o.appendChild(K("Available Fields", () => bi(r))), s.appendChild(o), () => {
|
|
2902
2929
|
n.abort(), o.remove();
|
|
2903
2930
|
};
|
|
2904
2931
|
}
|
|
2905
|
-
function
|
|
2932
|
+
function K(s, e) {
|
|
2906
2933
|
const t = document.createElement("div");
|
|
2907
2934
|
t.className = "tbw-pivot-section";
|
|
2908
2935
|
const i = document.createElement("div");
|
|
@@ -2910,7 +2937,7 @@ function H(s, e) {
|
|
|
2910
2937
|
const n = document.createElement("div");
|
|
2911
2938
|
return n.className = "tbw-pivot-section-content", n.appendChild(e()), t.appendChild(i), t.appendChild(n), t;
|
|
2912
2939
|
}
|
|
2913
|
-
function
|
|
2940
|
+
function qe(s, e) {
|
|
2914
2941
|
const { config: t, callbacks: i, signal: n } = e, r = document.createElement("div");
|
|
2915
2942
|
r.className = "tbw-pivot-drop-zone", r.setAttribute("data-zone", s);
|
|
2916
2943
|
const o = s === "rowGroups" ? t.rowGroupFields ?? [] : t.columnGroupFields ?? [];
|
|
@@ -2919,7 +2946,7 @@ function Fe(s, e) {
|
|
|
2919
2946
|
a.className = "tbw-pivot-placeholder", a.textContent = "Drag fields here or click to add", r.appendChild(a);
|
|
2920
2947
|
} else
|
|
2921
2948
|
for (const a of o)
|
|
2922
|
-
r.appendChild(
|
|
2949
|
+
r.appendChild(pi(a, s, e));
|
|
2923
2950
|
return r.addEventListener(
|
|
2924
2951
|
"dragover",
|
|
2925
2952
|
(a) => {
|
|
@@ -2942,7 +2969,7 @@ function Fe(s, e) {
|
|
|
2942
2969
|
{ signal: n }
|
|
2943
2970
|
), r;
|
|
2944
2971
|
}
|
|
2945
|
-
function
|
|
2972
|
+
function pi(s, e, t) {
|
|
2946
2973
|
const { callbacks: i, signal: n } = t, r = document.createElement("div");
|
|
2947
2974
|
r.className = "tbw-pivot-field-chip", r.draggable = !0;
|
|
2948
2975
|
const o = i.getAvailableFields().find((d) => d.field === s), a = document.createElement("span");
|
|
@@ -2968,7 +2995,7 @@ function hi(s, e, t) {
|
|
|
2968
2995
|
{ signal: n }
|
|
2969
2996
|
), r;
|
|
2970
2997
|
}
|
|
2971
|
-
function
|
|
2998
|
+
function mi(s) {
|
|
2972
2999
|
const { config: e, callbacks: t, signal: i } = s, n = document.createElement("div");
|
|
2973
3000
|
n.className = "tbw-pivot-drop-zone tbw-pivot-values-zone", n.setAttribute("data-zone", "values");
|
|
2974
3001
|
const r = e.valueFields ?? [];
|
|
@@ -2977,7 +3004,7 @@ function fi(s) {
|
|
|
2977
3004
|
o.className = "tbw-pivot-placeholder", o.textContent = "Drag numeric fields here for aggregation", n.appendChild(o);
|
|
2978
3005
|
} else
|
|
2979
3006
|
for (const o of r)
|
|
2980
|
-
n.appendChild(
|
|
3007
|
+
n.appendChild(wi(o, s));
|
|
2981
3008
|
return n.addEventListener(
|
|
2982
3009
|
"dragover",
|
|
2983
3010
|
(o) => {
|
|
@@ -3000,7 +3027,7 @@ function fi(s) {
|
|
|
3000
3027
|
{ signal: i }
|
|
3001
3028
|
), n;
|
|
3002
3029
|
}
|
|
3003
|
-
function
|
|
3030
|
+
function wi(s, e) {
|
|
3004
3031
|
const { callbacks: t, signal: i } = e, n = document.createElement("div");
|
|
3005
3032
|
n.className = "tbw-pivot-field-chip tbw-pivot-value-chip";
|
|
3006
3033
|
const r = t.getAvailableFields().find((c) => c.field === s.field), o = document.createElement("div");
|
|
@@ -3009,7 +3036,7 @@ function gi(s, e) {
|
|
|
3009
3036
|
a.className = "tbw-pivot-chip-label", a.textContent = r?.header ?? s.field;
|
|
3010
3037
|
const l = document.createElement("select");
|
|
3011
3038
|
l.className = "tbw-pivot-agg-select", l.title = "Aggregation function";
|
|
3012
|
-
for (const c of
|
|
3039
|
+
for (const c of gi) {
|
|
3013
3040
|
const u = document.createElement("option");
|
|
3014
3041
|
u.value = c, u.textContent = c.toUpperCase(), u.selected = c === s.aggFunc, l.appendChild(u);
|
|
3015
3042
|
}
|
|
@@ -3029,7 +3056,7 @@ function gi(s, e) {
|
|
|
3029
3056
|
{ signal: i }
|
|
3030
3057
|
), o.appendChild(a), o.appendChild(l), n.appendChild(o), n.appendChild(d), n;
|
|
3031
3058
|
}
|
|
3032
|
-
function
|
|
3059
|
+
function bi(s) {
|
|
3033
3060
|
const { config: e, callbacks: t, signal: i } = s, n = document.createElement("div");
|
|
3034
3061
|
n.className = "tbw-pivot-available-fields";
|
|
3035
3062
|
const r = t.getAvailableFields(), o = /* @__PURE__ */ new Set([
|
|
@@ -3059,10 +3086,10 @@ function pi(s) {
|
|
|
3059
3086
|
}
|
|
3060
3087
|
return n;
|
|
3061
3088
|
}
|
|
3062
|
-
function
|
|
3089
|
+
function vi(s, e) {
|
|
3063
3090
|
const { config: t, callbacks: i, signal: n } = e, r = document.createElement("div");
|
|
3064
3091
|
return r.className = "tbw-pivot-options", r.appendChild(
|
|
3065
|
-
|
|
3092
|
+
ee(
|
|
3066
3093
|
"Enable Pivot View",
|
|
3067
3094
|
s,
|
|
3068
3095
|
(o) => {
|
|
@@ -3071,7 +3098,7 @@ function mi(s, e) {
|
|
|
3071
3098
|
n
|
|
3072
3099
|
)
|
|
3073
3100
|
), r.appendChild(
|
|
3074
|
-
|
|
3101
|
+
ee(
|
|
3075
3102
|
"Show Row Totals",
|
|
3076
3103
|
t.showTotals ?? !0,
|
|
3077
3104
|
(o) => {
|
|
@@ -3080,7 +3107,7 @@ function mi(s, e) {
|
|
|
3080
3107
|
n
|
|
3081
3108
|
)
|
|
3082
3109
|
), r.appendChild(
|
|
3083
|
-
|
|
3110
|
+
ee(
|
|
3084
3111
|
"Show Grand Total",
|
|
3085
3112
|
t.showGrandTotal ?? !0,
|
|
3086
3113
|
(o) => {
|
|
@@ -3090,7 +3117,7 @@ function mi(s, e) {
|
|
|
3090
3117
|
)
|
|
3091
3118
|
), r;
|
|
3092
3119
|
}
|
|
3093
|
-
function
|
|
3120
|
+
function ee(s, e, t, i) {
|
|
3094
3121
|
const n = document.createElement("label");
|
|
3095
3122
|
n.className = "tbw-pivot-checkbox";
|
|
3096
3123
|
const r = document.createElement("input");
|
|
@@ -3098,7 +3125,7 @@ function J(s, e, t, i) {
|
|
|
3098
3125
|
const o = document.createElement("span");
|
|
3099
3126
|
return o.textContent = s, n.appendChild(r), n.appendChild(o), n;
|
|
3100
3127
|
}
|
|
3101
|
-
function
|
|
3128
|
+
function yi(s, e, t) {
|
|
3102
3129
|
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) => {
|
|
3103
3130
|
const r = document.createElement("div");
|
|
3104
3131
|
if (r.className = "cell", r.setAttribute("data-col", String(n)), r.setAttribute("data-row", String(t.rowIndex)), r.setAttribute("role", "gridcell"), n === 0) {
|
|
@@ -3119,7 +3146,7 @@ function wi(s, e, t) {
|
|
|
3119
3146
|
e.appendChild(r);
|
|
3120
3147
|
}), !0;
|
|
3121
3148
|
}
|
|
3122
|
-
function
|
|
3149
|
+
function Ci(s, e, t, i) {
|
|
3123
3150
|
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) => {
|
|
3124
3151
|
const o = document.createElement("div");
|
|
3125
3152
|
if (o.className = "cell", o.setAttribute("data-col", String(r)), o.setAttribute("data-row", String(i)), o.setAttribute("role", "gridcell"), r === 0) {
|
|
@@ -3134,7 +3161,7 @@ function bi(s, e, t, i) {
|
|
|
3134
3161
|
e.appendChild(o);
|
|
3135
3162
|
}), !0;
|
|
3136
3163
|
}
|
|
3137
|
-
function
|
|
3164
|
+
function xi(s, e, t) {
|
|
3138
3165
|
return e.className = "pivot-grand-total-row", e.setAttribute("role", "presentation"), e.innerHTML = "", t.forEach((i, n) => {
|
|
3139
3166
|
const r = document.createElement("div");
|
|
3140
3167
|
if (r.className = "cell", r.setAttribute("data-col", String(n)), n === 0) {
|
|
@@ -3147,10 +3174,10 @@ function vi(s, e, t) {
|
|
|
3147
3174
|
e.appendChild(r);
|
|
3148
3175
|
}), !0;
|
|
3149
3176
|
}
|
|
3150
|
-
const
|
|
3151
|
-
class
|
|
3177
|
+
const Ri = '@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}}}';
|
|
3178
|
+
class D extends R {
|
|
3152
3179
|
name = "pivot";
|
|
3153
|
-
styles =
|
|
3180
|
+
styles = Ri;
|
|
3154
3181
|
static PANEL_ID = "pivot";
|
|
3155
3182
|
get defaultConfig() {
|
|
3156
3183
|
return {
|
|
@@ -3184,7 +3211,7 @@ class M extends R {
|
|
|
3184
3211
|
getToolPanel() {
|
|
3185
3212
|
if ((this.config?.showToolPanel ?? this.userConfig?.showToolPanel ?? !0) !== !1)
|
|
3186
3213
|
return {
|
|
3187
|
-
id:
|
|
3214
|
+
id: D.PANEL_ID,
|
|
3188
3215
|
title: "Pivot",
|
|
3189
3216
|
icon: "⊞",
|
|
3190
3217
|
tooltip: "Configure pivot table",
|
|
@@ -3195,11 +3222,11 @@ class M extends R {
|
|
|
3195
3222
|
processRows(e) {
|
|
3196
3223
|
if (!this.hasInitialized && this.config.active !== !1 && this.hasValidPivotConfig() && (this.hasInitialized = !0, this.isActive = !0), !this.isActive)
|
|
3197
3224
|
return [...e];
|
|
3198
|
-
const t =
|
|
3225
|
+
const t = si(this.config);
|
|
3199
3226
|
if (t.length > 0)
|
|
3200
3227
|
return this.warn(`Config errors: ${t.join(", ")}`), [...e];
|
|
3201
|
-
this.buildFieldHeaderMap(), this.defaultExpanded = this.config.defaultExpanded ?? !0, this.expandedKeys.size === 0 && this.defaultExpanded && this.pivotResult && this.expandAllKeys(), this.pivotResult =
|
|
3202
|
-
const i = this.config.indentWidth ?? 20, n =
|
|
3228
|
+
this.buildFieldHeaderMap(), this.defaultExpanded = this.config.defaultExpanded ?? !0, this.expandedKeys.size === 0 && this.defaultExpanded && this.pivotResult && this.expandAllKeys(), this.pivotResult = ai(e, this.config), this.expandedKeys.size === 0 && this.defaultExpanded && this.expandAllKeys();
|
|
3229
|
+
const i = this.config.indentWidth ?? 20, n = ui(
|
|
3203
3230
|
this.pivotResult.rows,
|
|
3204
3231
|
this.expandedKeys,
|
|
3205
3232
|
this.defaultExpanded
|
|
@@ -3234,7 +3261,7 @@ class M extends R {
|
|
|
3234
3261
|
});
|
|
3235
3262
|
for (const n of this.pivotResult.columnKeys)
|
|
3236
3263
|
for (const r of this.config.valueFields ?? []) {
|
|
3237
|
-
const o =
|
|
3264
|
+
const o = de([n], r.field), a = r.header || this.fieldHeaderMap.get(r.field) || r.field;
|
|
3238
3265
|
t.push({
|
|
3239
3266
|
field: o,
|
|
3240
3267
|
header: `${n} - ${a} (${r.aggFunc})`,
|
|
@@ -3251,13 +3278,13 @@ class M extends R {
|
|
|
3251
3278
|
}
|
|
3252
3279
|
renderRow(e, t, i) {
|
|
3253
3280
|
const n = e;
|
|
3254
|
-
return n.__pivotRowKey && n.__pivotHasChildren ?
|
|
3281
|
+
return n.__pivotRowKey && n.__pivotHasChildren ? yi(n, t, {
|
|
3255
3282
|
columns: this.gridColumns,
|
|
3256
3283
|
rowIndex: i,
|
|
3257
3284
|
onToggle: (r) => this.toggle(r),
|
|
3258
3285
|
resolveIcon: (r) => this.resolveIcon(r),
|
|
3259
3286
|
setIcon: (r, o) => this.setIcon(r, o)
|
|
3260
|
-
}) : n.__pivotRowKey !== void 0 && this.isActive ?
|
|
3287
|
+
}) : n.__pivotRowKey !== void 0 && this.isActive ? Ci(n, t, this.gridColumns, i) : (this.cleanupPivotStyling(t), !1);
|
|
3261
3288
|
}
|
|
3262
3289
|
cleanupPivotStyling(e) {
|
|
3263
3290
|
(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 = "");
|
|
@@ -3295,7 +3322,7 @@ class M extends R {
|
|
|
3295
3322
|
__pivotTotal: this.pivotResult.grandTotal,
|
|
3296
3323
|
...this.pivotResult.totals
|
|
3297
3324
|
};
|
|
3298
|
-
|
|
3325
|
+
xi(i, this.grandTotalFooter, this.gridColumns);
|
|
3299
3326
|
}
|
|
3300
3327
|
cleanupGrandTotalFooter() {
|
|
3301
3328
|
this.grandTotalFooter && (this.grandTotalFooter.remove(), this.grandTotalFooter = null);
|
|
@@ -3317,7 +3344,7 @@ class M extends R {
|
|
|
3317
3344
|
}
|
|
3318
3345
|
expandAllKeys() {
|
|
3319
3346
|
if (!this.pivotResult) return;
|
|
3320
|
-
const e =
|
|
3347
|
+
const e = hi(this.pivotResult.rows);
|
|
3321
3348
|
for (const t of e)
|
|
3322
3349
|
this.expandedKeys.add(t);
|
|
3323
3350
|
}
|
|
@@ -3349,16 +3376,16 @@ class M extends R {
|
|
|
3349
3376
|
this.pivotResult = null, this.requestRender();
|
|
3350
3377
|
}
|
|
3351
3378
|
showPanel() {
|
|
3352
|
-
this.grid.openToolPanel(), this.grid.expandedToolPanelSections.includes(
|
|
3379
|
+
this.grid.openToolPanel(), this.grid.expandedToolPanelSections.includes(D.PANEL_ID) || this.grid.toggleToolPanelSection(D.PANEL_ID);
|
|
3353
3380
|
}
|
|
3354
3381
|
hidePanel() {
|
|
3355
3382
|
this.grid.closeToolPanel();
|
|
3356
3383
|
}
|
|
3357
3384
|
togglePanel() {
|
|
3358
|
-
this.grid.isToolPanelOpen || this.grid.openToolPanel(), this.grid.toggleToolPanelSection(
|
|
3385
|
+
this.grid.isToolPanelOpen || this.grid.openToolPanel(), this.grid.toggleToolPanelSection(D.PANEL_ID);
|
|
3359
3386
|
}
|
|
3360
3387
|
isPanelVisible() {
|
|
3361
|
-
return this.grid.isToolPanelOpen && this.grid.expandedToolPanelSections.includes(
|
|
3388
|
+
return this.grid.isToolPanelOpen && this.grid.expandedToolPanelSections.includes(D.PANEL_ID);
|
|
3362
3389
|
}
|
|
3363
3390
|
get gridColumns() {
|
|
3364
3391
|
return this.grid.columns ?? [];
|
|
@@ -3402,7 +3429,7 @@ class M extends R {
|
|
|
3402
3429
|
},
|
|
3403
3430
|
getAvailableFields: () => this.getAvailableFields()
|
|
3404
3431
|
};
|
|
3405
|
-
return
|
|
3432
|
+
return fi(e, this.config, this.isActive, t);
|
|
3406
3433
|
}
|
|
3407
3434
|
refreshPanel() {
|
|
3408
3435
|
this.panelContainer && (this.panelContainer.innerHTML = "", this.renderPanel(this.panelContainer));
|
|
@@ -3435,19 +3462,266 @@ class M extends R {
|
|
|
3435
3462
|
n >= 0 && (i[n] = { ...i[n], aggFunc: t }, this.config.valueFields = [...i]), this.isActive && this.refresh();
|
|
3436
3463
|
}
|
|
3437
3464
|
}
|
|
3438
|
-
|
|
3465
|
+
const W = "tbw-print-isolation-style";
|
|
3466
|
+
function Ei(s, e) {
|
|
3467
|
+
const t = document.createElement("style");
|
|
3468
|
+
return t.id = W, t.textContent = `
|
|
3469
|
+
/* Print isolation: hide everything except the target grid */
|
|
3470
|
+
@media print {
|
|
3471
|
+
/* Hide all body children by default */
|
|
3472
|
+
body > *:not(#${s}) {
|
|
3473
|
+
display: none !important;
|
|
3474
|
+
}
|
|
3475
|
+
|
|
3476
|
+
/* But show the grid and ensure it's not hidden by ancestor rules */
|
|
3477
|
+
#${s} {
|
|
3478
|
+
display: block !important;
|
|
3479
|
+
position: static !important;
|
|
3480
|
+
visibility: visible !important;
|
|
3481
|
+
opacity: 1 !important;
|
|
3482
|
+
overflow: visible !important;
|
|
3483
|
+
height: auto !important;
|
|
3484
|
+
width: 100% !important;
|
|
3485
|
+
max-height: none !important;
|
|
3486
|
+
margin: 0 !important;
|
|
3487
|
+
padding: 0 !important;
|
|
3488
|
+
transform: none !important;
|
|
3489
|
+
}
|
|
3490
|
+
|
|
3491
|
+
/* If grid is nested, we need to show its ancestors too */
|
|
3492
|
+
#${s},
|
|
3493
|
+
#${s} * {
|
|
3494
|
+
visibility: visible !important;
|
|
3495
|
+
}
|
|
3496
|
+
|
|
3497
|
+
/* Walk up the DOM and show all ancestors of the grid */
|
|
3498
|
+
body *:has(> #${s}),
|
|
3499
|
+
body *:has(#${s}) {
|
|
3500
|
+
display: block !important;
|
|
3501
|
+
visibility: visible !important;
|
|
3502
|
+
opacity: 1 !important;
|
|
3503
|
+
overflow: visible !important;
|
|
3504
|
+
height: auto !important;
|
|
3505
|
+
position: static !important;
|
|
3506
|
+
transform: none !important;
|
|
3507
|
+
background: transparent !important;
|
|
3508
|
+
border: none !important;
|
|
3509
|
+
padding: 0 !important;
|
|
3510
|
+
margin: 0 !important;
|
|
3511
|
+
}
|
|
3512
|
+
|
|
3513
|
+
/* Hide siblings of ancestors (everything that's not in the path to the grid) */
|
|
3514
|
+
body *:has(#${s}) > *:not(:has(#${s})):not(#${s}) {
|
|
3515
|
+
display: none !important;
|
|
3516
|
+
}
|
|
3517
|
+
|
|
3518
|
+
/* Page settings */
|
|
3519
|
+
@page {
|
|
3520
|
+
size: ${e};
|
|
3521
|
+
margin: 1cm;
|
|
3522
|
+
}
|
|
3523
|
+
|
|
3524
|
+
/* Ensure proper print styling */
|
|
3525
|
+
body {
|
|
3526
|
+
margin: 0 !important;
|
|
3527
|
+
padding: 0 !important;
|
|
3528
|
+
background: white !important;
|
|
3529
|
+
color-scheme: light !important;
|
|
3530
|
+
}
|
|
3531
|
+
}
|
|
3532
|
+
|
|
3533
|
+
/* Screen: also apply isolation for print preview */
|
|
3534
|
+
@media screen {
|
|
3535
|
+
/* When this stylesheet is active, we're about to print */
|
|
3536
|
+
/* No screen-specific rules needed - isolation only applies to print */
|
|
3537
|
+
}
|
|
3538
|
+
`, t;
|
|
3539
|
+
}
|
|
3540
|
+
async function Si(s, e = {}) {
|
|
3541
|
+
const { orientation: t = "landscape" } = e, i = s.id;
|
|
3542
|
+
document.querySelectorAll(`#${CSS.escape(i)}`).length > 1 && console.warn(
|
|
3543
|
+
`[tbw-grid:print] Multiple elements found with id="${i}". Print isolation may not work correctly. Ensure each grid has a unique ID.`
|
|
3544
|
+
), document.getElementById(W)?.remove();
|
|
3545
|
+
const r = Ei(i, t);
|
|
3546
|
+
return document.head.appendChild(r), new Promise((o) => {
|
|
3547
|
+
const a = () => {
|
|
3548
|
+
window.removeEventListener("afterprint", a), document.getElementById(W)?.remove(), o();
|
|
3549
|
+
};
|
|
3550
|
+
window.addEventListener("afterprint", a), window.print(), setTimeout(() => {
|
|
3551
|
+
window.removeEventListener("afterprint", a), document.getElementById(W)?.remove(), o();
|
|
3552
|
+
}, 5e3);
|
|
3553
|
+
});
|
|
3554
|
+
}
|
|
3555
|
+
const ki = ".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}}}", Ai = {
|
|
3556
|
+
button: !1,
|
|
3557
|
+
orientation: "landscape",
|
|
3558
|
+
warnThreshold: 500,
|
|
3559
|
+
maxRows: 0,
|
|
3560
|
+
includeTitle: !0,
|
|
3561
|
+
includeTimestamp: !0,
|
|
3562
|
+
title: "",
|
|
3563
|
+
isolate: !1
|
|
3564
|
+
};
|
|
3565
|
+
class un extends R {
|
|
3566
|
+
name = "print";
|
|
3567
|
+
version = "1.0.0";
|
|
3568
|
+
styles = ki;
|
|
3569
|
+
#e = !1;
|
|
3570
|
+
#t = null;
|
|
3571
|
+
#o = null;
|
|
3572
|
+
#n = null;
|
|
3573
|
+
#i = null;
|
|
3574
|
+
#r = null;
|
|
3575
|
+
#d = null;
|
|
3576
|
+
get #a() {
|
|
3577
|
+
return this.grid;
|
|
3578
|
+
}
|
|
3579
|
+
isPrinting() {
|
|
3580
|
+
return this.#e;
|
|
3581
|
+
}
|
|
3582
|
+
async print(e) {
|
|
3583
|
+
if (this.#e) {
|
|
3584
|
+
console.warn("[PrintPlugin] Print already in progress");
|
|
3585
|
+
return;
|
|
3586
|
+
}
|
|
3587
|
+
const t = this.gridElement;
|
|
3588
|
+
if (!t) {
|
|
3589
|
+
console.warn("[PrintPlugin] Grid not available");
|
|
3590
|
+
return;
|
|
3591
|
+
}
|
|
3592
|
+
const i = { ...Ai, ...this.config, ...e }, r = this.rows.length;
|
|
3593
|
+
let o = r, a = !1;
|
|
3594
|
+
if (i.warnThreshold > 0 && r > i.warnThreshold) {
|
|
3595
|
+
const d = i.maxRows > 0 ? `
|
|
3596
|
+
|
|
3597
|
+
Note: Output will be limited to ${i.maxRows.toLocaleString()} rows.` : "";
|
|
3598
|
+
if (!confirm(
|
|
3599
|
+
`This grid has ${r.toLocaleString()} rows. Printing large datasets may cause performance issues or browser slowdowns.${d}
|
|
3600
|
+
|
|
3601
|
+
Click OK to continue, or Cancel to abort.`
|
|
3602
|
+
))
|
|
3603
|
+
return;
|
|
3604
|
+
}
|
|
3605
|
+
i.maxRows > 0 && r > i.maxRows && (o = i.maxRows, a = !0), this.#e = !0;
|
|
3606
|
+
const l = performance.now();
|
|
3607
|
+
this.emit("print-start", {
|
|
3608
|
+
rowCount: o,
|
|
3609
|
+
limitApplied: a,
|
|
3610
|
+
originalRowCount: r
|
|
3611
|
+
});
|
|
3612
|
+
try {
|
|
3613
|
+
const d = this.#a;
|
|
3614
|
+
this.#o = {
|
|
3615
|
+
bypassThreshold: d._virtualization?.bypassThreshold ?? 24
|
|
3616
|
+
}, 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", {
|
|
3617
|
+
success: !0,
|
|
3618
|
+
rowCount: o,
|
|
3619
|
+
duration: Math.round(performance.now() - l)
|
|
3620
|
+
});
|
|
3621
|
+
} catch (d) {
|
|
3622
|
+
console.error("[PrintPlugin] Print failed:", d), this.emit("print-complete", {
|
|
3623
|
+
success: !1,
|
|
3624
|
+
rowCount: 0,
|
|
3625
|
+
duration: Math.round(performance.now() - l)
|
|
3626
|
+
});
|
|
3627
|
+
} finally {
|
|
3628
|
+
this.#f(), this.#e = !1;
|
|
3629
|
+
}
|
|
3630
|
+
}
|
|
3631
|
+
#c(e) {
|
|
3632
|
+
const t = this.gridElement;
|
|
3633
|
+
if (t) {
|
|
3634
|
+
if (this.#i = document.createElement("div"), this.#i.className = "tbw-print-header", e.includeTitle) {
|
|
3635
|
+
const i = e.title || this.grid.effectiveConfig?.shell?.header?.title || "Grid Data", n = document.createElement("div");
|
|
3636
|
+
n.className = "tbw-print-header-title", n.textContent = i, this.#i.appendChild(n);
|
|
3637
|
+
}
|
|
3638
|
+
if (e.includeTimestamp) {
|
|
3639
|
+
const i = document.createElement("div");
|
|
3640
|
+
i.className = "tbw-print-header-timestamp", i.textContent = `Printed: ${(/* @__PURE__ */ new Date()).toLocaleString()}`, this.#i.appendChild(i);
|
|
3641
|
+
}
|
|
3642
|
+
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);
|
|
3643
|
+
}
|
|
3644
|
+
}
|
|
3645
|
+
async #s() {
|
|
3646
|
+
const e = this.#a;
|
|
3647
|
+
if (!e._virtualization) return;
|
|
3648
|
+
const t = this.rows.length;
|
|
3649
|
+
e._virtualization.bypassThreshold = t + 100, e.refreshVirtualWindow(!0), await new Promise((i) => setTimeout(i, 100));
|
|
3650
|
+
}
|
|
3651
|
+
async #h() {
|
|
3652
|
+
return new Promise((e) => {
|
|
3653
|
+
const t = () => {
|
|
3654
|
+
window.removeEventListener("afterprint", t), e();
|
|
3655
|
+
};
|
|
3656
|
+
window.addEventListener("afterprint", t), window.print(), setTimeout(() => {
|
|
3657
|
+
window.removeEventListener("afterprint", t), e();
|
|
3658
|
+
}, 1e3);
|
|
3659
|
+
});
|
|
3660
|
+
}
|
|
3661
|
+
async #p(e) {
|
|
3662
|
+
const t = this.gridElement;
|
|
3663
|
+
t && await Si(t, {
|
|
3664
|
+
orientation: e.orientation
|
|
3665
|
+
});
|
|
3666
|
+
}
|
|
3667
|
+
#l() {
|
|
3668
|
+
const e = this.columns;
|
|
3669
|
+
if (e) {
|
|
3670
|
+
this.#t = /* @__PURE__ */ new Map();
|
|
3671
|
+
for (const t of e)
|
|
3672
|
+
t.printHidden && t.field && (this.#t.set(t.field, !t.hidden), this.grid.setColumnVisible(t.field, !1));
|
|
3673
|
+
}
|
|
3674
|
+
}
|
|
3675
|
+
#g() {
|
|
3676
|
+
if (this.#t) {
|
|
3677
|
+
for (const [e, t] of this.#t)
|
|
3678
|
+
this.grid.setColumnVisible(e, t);
|
|
3679
|
+
this.#t = null;
|
|
3680
|
+
}
|
|
3681
|
+
}
|
|
3682
|
+
#f() {
|
|
3683
|
+
const e = this.gridElement;
|
|
3684
|
+
if (!e) return;
|
|
3685
|
+
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);
|
|
3686
|
+
const t = this.#a;
|
|
3687
|
+
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);
|
|
3688
|
+
}
|
|
3689
|
+
afterRender() {
|
|
3690
|
+
this.config?.button && !this.#u && (this.#m(), this.#u = !0);
|
|
3691
|
+
}
|
|
3692
|
+
#u = !1;
|
|
3693
|
+
#m() {
|
|
3694
|
+
this.#a.registerToolbarContent?.({
|
|
3695
|
+
id: "print-button",
|
|
3696
|
+
order: 900,
|
|
3697
|
+
render: (t) => {
|
|
3698
|
+
const i = document.createElement("button");
|
|
3699
|
+
i.className = "tbw-toolbar-btn tbw-print-btn", i.title = "Print grid", i.type = "button";
|
|
3700
|
+
const n = this.resolveIcon("print") || "🖨️";
|
|
3701
|
+
this.setIcon(i, n), i.addEventListener(
|
|
3702
|
+
"click",
|
|
3703
|
+
() => {
|
|
3704
|
+
this.print();
|
|
3705
|
+
},
|
|
3706
|
+
{ signal: this.disconnectSignal }
|
|
3707
|
+
), t.appendChild(i);
|
|
3708
|
+
}
|
|
3709
|
+
});
|
|
3710
|
+
}
|
|
3711
|
+
}
|
|
3712
|
+
function _i(s) {
|
|
3439
3713
|
const e = s.meta ?? {};
|
|
3440
3714
|
return e.lockPosition !== !0 && e.suppressMovable !== !0;
|
|
3441
3715
|
}
|
|
3442
|
-
function
|
|
3716
|
+
function Ne(s, e, t) {
|
|
3443
3717
|
if (e === t || e < 0 || e >= s.length || t < 0 || t > s.length) return s;
|
|
3444
3718
|
const i = [...s], [n] = i.splice(e, 1);
|
|
3445
3719
|
return i.splice(t, 0, n), i;
|
|
3446
3720
|
}
|
|
3447
|
-
const
|
|
3448
|
-
class
|
|
3721
|
+
const Li = '@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}}';
|
|
3722
|
+
class hn extends R {
|
|
3449
3723
|
name = "reorder";
|
|
3450
|
-
styles =
|
|
3724
|
+
styles = Li;
|
|
3451
3725
|
get defaultConfig() {
|
|
3452
3726
|
return {
|
|
3453
3727
|
animation: "flip"
|
|
@@ -3464,8 +3738,8 @@ class rn extends R {
|
|
|
3464
3738
|
draggedIndex = null;
|
|
3465
3739
|
dropIndex = null;
|
|
3466
3740
|
canMoveColumnWithPlugins(e) {
|
|
3467
|
-
return !e || !
|
|
3468
|
-
type:
|
|
3741
|
+
return !e || !_i(e) ? !1 : !this.grid.queryPlugins({
|
|
3742
|
+
type: Ve.CAN_MOVE_COLUMN,
|
|
3469
3743
|
context: e
|
|
3470
3744
|
}).includes(!1);
|
|
3471
3745
|
}
|
|
@@ -3514,13 +3788,13 @@ class rn extends R {
|
|
|
3514
3788
|
const l = this.draggedField, d = this.draggedIndex, c = this.dropIndex;
|
|
3515
3789
|
if (!this.isDragging || l === null || d === null || c === null)
|
|
3516
3790
|
return;
|
|
3517
|
-
const u = c > d ? c - 1 : c, h = this.getColumnOrder(),
|
|
3791
|
+
const u = c > d ? c - 1 : c, h = this.getColumnOrder(), g = Ne(h, d, u), f = {
|
|
3518
3792
|
field: l,
|
|
3519
3793
|
fromIndex: d,
|
|
3520
3794
|
toIndex: u,
|
|
3521
|
-
columnOrder:
|
|
3795
|
+
columnOrder: g
|
|
3522
3796
|
};
|
|
3523
|
-
this.emitCancelable("column-move",
|
|
3797
|
+
this.emitCancelable("column-move", f) || this.updateColumnOrder(g);
|
|
3524
3798
|
}));
|
|
3525
3799
|
});
|
|
3526
3800
|
}
|
|
@@ -3537,7 +3811,7 @@ class rn extends R {
|
|
|
3537
3811
|
if (l < 0 || l >= o.length) return;
|
|
3538
3812
|
const d = n.find((c) => c.field === o[l]);
|
|
3539
3813
|
if (this.canMoveColumnWithPlugins(d))
|
|
3540
|
-
return this.moveColumn(r.field, l), t._focusCol = l,
|
|
3814
|
+
return this.moveColumn(r.field, l), t._focusCol = l, _(this.grid), e.preventDefault(), e.stopPropagation(), !0;
|
|
3541
3815
|
}
|
|
3542
3816
|
getColumnOrder() {
|
|
3543
3817
|
return this.grid.getColumnOrder();
|
|
@@ -3545,7 +3819,7 @@ class rn extends R {
|
|
|
3545
3819
|
moveColumn(e, t) {
|
|
3546
3820
|
const i = this.getColumnOrder(), n = i.indexOf(e);
|
|
3547
3821
|
if (n === -1) return;
|
|
3548
|
-
const r =
|
|
3822
|
+
const r = Ne(i, n, t);
|
|
3549
3823
|
this.emitCancelable("column-move", {
|
|
3550
3824
|
field: e,
|
|
3551
3825
|
fromIndex: n,
|
|
@@ -3640,11 +3914,11 @@ class rn extends R {
|
|
|
3640
3914
|
this.grid.requestStateChange?.();
|
|
3641
3915
|
}
|
|
3642
3916
|
}
|
|
3643
|
-
const
|
|
3644
|
-
class
|
|
3917
|
+
const Ti = '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}}';
|
|
3918
|
+
class gn extends R {
|
|
3645
3919
|
name = "responsive";
|
|
3646
3920
|
version = "1.0.0";
|
|
3647
|
-
styles =
|
|
3921
|
+
styles = Ti;
|
|
3648
3922
|
static manifest = {
|
|
3649
3923
|
incompatibleWith: [
|
|
3650
3924
|
{
|
|
@@ -3656,73 +3930,73 @@ class on extends R {
|
|
|
3656
3930
|
#e;
|
|
3657
3931
|
#t = !1;
|
|
3658
3932
|
#o;
|
|
3659
|
-
#
|
|
3660
|
-
#
|
|
3661
|
-
#
|
|
3662
|
-
#
|
|
3663
|
-
#
|
|
3664
|
-
#
|
|
3933
|
+
#n = !1;
|
|
3934
|
+
#i = 0;
|
|
3935
|
+
#r = /* @__PURE__ */ new Set();
|
|
3936
|
+
#d = /* @__PURE__ */ new Set();
|
|
3937
|
+
#a = null;
|
|
3938
|
+
#c = [];
|
|
3665
3939
|
isResponsive() {
|
|
3666
3940
|
return this.#t;
|
|
3667
3941
|
}
|
|
3668
3942
|
setResponsive(e) {
|
|
3669
|
-
e !== this.#t && (this.#t = e, this.#
|
|
3943
|
+
e !== this.#t && (this.#t = e, this.#g(), this.emit("responsive-change", {
|
|
3670
3944
|
isResponsive: e,
|
|
3671
|
-
width: this.#
|
|
3945
|
+
width: this.#i,
|
|
3672
3946
|
breakpoint: this.config.breakpoint ?? 0
|
|
3673
3947
|
}));
|
|
3674
3948
|
}
|
|
3675
3949
|
setBreakpoint(e) {
|
|
3676
|
-
this.config.breakpoint = e, this.#
|
|
3950
|
+
this.config.breakpoint = e, this.#h(this.#i);
|
|
3677
3951
|
}
|
|
3678
3952
|
setCardRenderer(e) {
|
|
3679
3953
|
this.config.cardRenderer = e, this.#t && this.requestRender();
|
|
3680
3954
|
}
|
|
3681
3955
|
getWidth() {
|
|
3682
|
-
return this.#
|
|
3956
|
+
return this.#i;
|
|
3683
3957
|
}
|
|
3684
3958
|
getActiveBreakpoint() {
|
|
3685
|
-
return this.#
|
|
3959
|
+
return this.#a;
|
|
3686
3960
|
}
|
|
3687
3961
|
attach(e) {
|
|
3688
|
-
super.attach(e), this.#
|
|
3962
|
+
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) => {
|
|
3689
3963
|
const i = t[0]?.contentRect.width ?? 0;
|
|
3690
|
-
this.#
|
|
3691
|
-
this.#
|
|
3964
|
+
this.#i = i, clearTimeout(this.#o), this.#o = setTimeout(() => {
|
|
3965
|
+
this.#h(i);
|
|
3692
3966
|
}, this.config.debounceMs ?? 100);
|
|
3693
3967
|
}), this.#e.observe(this.gridElement);
|
|
3694
3968
|
}
|
|
3695
|
-
#
|
|
3696
|
-
if (this.#
|
|
3969
|
+
#s(e) {
|
|
3970
|
+
if (this.#r.clear(), this.#d.clear(), !!e)
|
|
3697
3971
|
for (const t of e)
|
|
3698
|
-
typeof t == "string" ? this.#
|
|
3972
|
+
typeof t == "string" ? this.#r.add(t) : t.showValue ? this.#d.add(t.field) : this.#r.add(t.field);
|
|
3699
3973
|
}
|
|
3700
3974
|
detach() {
|
|
3701
3975
|
this.#e?.disconnect(), this.#e = void 0, clearTimeout(this.#o), this.#o = void 0, this.gridElement && this.gridElement.removeAttribute("data-responsive"), super.detach();
|
|
3702
3976
|
}
|
|
3703
3977
|
afterRender() {
|
|
3704
|
-
if (this.#R(), !(this.#
|
|
3978
|
+
if (this.#R(), !(this.#c.length > 0 ? this.#a !== null : this.#t))
|
|
3705
3979
|
return;
|
|
3706
|
-
const t = this.#
|
|
3980
|
+
const t = this.#r.size > 0, i = this.#d.size > 0;
|
|
3707
3981
|
if (!t && !i)
|
|
3708
3982
|
return;
|
|
3709
3983
|
const n = this.gridElement.querySelectorAll(".cell[data-field]");
|
|
3710
3984
|
for (const r of n) {
|
|
3711
3985
|
const o = r.getAttribute("data-field");
|
|
3712
|
-
o && (this.#
|
|
3986
|
+
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")));
|
|
3713
3987
|
}
|
|
3714
3988
|
}
|
|
3715
|
-
#
|
|
3716
|
-
if (this.#
|
|
3989
|
+
#h(e) {
|
|
3990
|
+
if (this.#c.length > 0) {
|
|
3717
3991
|
this.#p(e);
|
|
3718
3992
|
return;
|
|
3719
3993
|
}
|
|
3720
3994
|
const t = this.config.breakpoint ?? 0;
|
|
3721
|
-
t === 0 && !this.#
|
|
3995
|
+
t === 0 && !this.#n && (this.#n = !0, console.warn(
|
|
3722
3996
|
"[tbw-grid:ResponsivePlugin] No breakpoint configured. Responsive mode is disabled. Set a breakpoint based on your grid's column count."
|
|
3723
3997
|
));
|
|
3724
3998
|
const i = t > 0 && e < t;
|
|
3725
|
-
i !== this.#t && (this.#t = i, this.#
|
|
3999
|
+
i !== this.#t && (this.#t = i, this.#g(), this.emit("responsive-change", {
|
|
3726
4000
|
isResponsive: i,
|
|
3727
4001
|
width: e,
|
|
3728
4002
|
breakpoint: t
|
|
@@ -3730,33 +4004,33 @@ class on extends R {
|
|
|
3730
4004
|
}
|
|
3731
4005
|
#p(e) {
|
|
3732
4006
|
let t = null;
|
|
3733
|
-
for (const n of this.#
|
|
4007
|
+
for (const n of this.#c)
|
|
3734
4008
|
e <= n.maxWidth && (t = n);
|
|
3735
|
-
if (t !== this.#
|
|
3736
|
-
this.#
|
|
4009
|
+
if (t !== this.#a) {
|
|
4010
|
+
this.#a = t, t?.hiddenColumns ? this.#s(t.hiddenColumns) : this.#s(this.config.hiddenColumns);
|
|
3737
4011
|
const n = t?.cardLayout === !0;
|
|
3738
|
-
n !== this.#t && (this.#t = n, this.#
|
|
4012
|
+
n !== this.#t && (this.#t = n, this.#g()), this.emit("responsive-change", {
|
|
3739
4013
|
isResponsive: this.#t,
|
|
3740
4014
|
width: e,
|
|
3741
4015
|
breakpoint: t?.maxWidth ?? 0
|
|
3742
4016
|
}), this.requestRender();
|
|
3743
4017
|
}
|
|
3744
4018
|
}
|
|
3745
|
-
#
|
|
3746
|
-
#
|
|
4019
|
+
#l;
|
|
4020
|
+
#g() {
|
|
3747
4021
|
this.gridElement.toggleAttribute("data-responsive", this.#t);
|
|
3748
4022
|
const e = this.config.animate !== !1;
|
|
3749
4023
|
this.gridElement.toggleAttribute("data-responsive-animate", e), this.config.animationDuration && this.gridElement.style.setProperty("--tbw-responsive-duration", `${this.config.animationDuration}ms`);
|
|
3750
4024
|
const t = this.grid;
|
|
3751
4025
|
if (this.#t) {
|
|
3752
|
-
t._virtualization && (this.#
|
|
4026
|
+
t._virtualization && (this.#l = t._virtualization.rowHeight);
|
|
3753
4027
|
const i = this.gridElement.querySelector(".tbw-scroll-area");
|
|
3754
4028
|
i && (i.scrollLeft = 0);
|
|
3755
4029
|
} else {
|
|
3756
4030
|
const i = this.gridElement.querySelectorAll(".data-grid-row");
|
|
3757
4031
|
for (const n of i)
|
|
3758
4032
|
n.style.height = "", n.classList.remove("responsive-card");
|
|
3759
|
-
this.#
|
|
4033
|
+
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;
|
|
3760
4034
|
}
|
|
3761
4035
|
}
|
|
3762
4036
|
renderRow(e, t, i) {
|
|
@@ -3775,29 +4049,29 @@ class on extends R {
|
|
|
3775
4049
|
switch (e.key) {
|
|
3776
4050
|
case "ArrowDown":
|
|
3777
4051
|
if (this.grid._focusCol < i)
|
|
3778
|
-
return this.grid._focusCol += 1, e.preventDefault(),
|
|
4052
|
+
return this.grid._focusCol += 1, e.preventDefault(), _(this.grid), !0;
|
|
3779
4053
|
if (this.grid._focusRow < t)
|
|
3780
|
-
return this.grid._focusRow += 1, this.grid._focusCol = 0, e.preventDefault(),
|
|
4054
|
+
return this.grid._focusRow += 1, this.grid._focusCol = 0, e.preventDefault(), _(this.grid), !0;
|
|
3781
4055
|
break;
|
|
3782
4056
|
case "ArrowUp":
|
|
3783
4057
|
if (this.grid._focusCol > 0)
|
|
3784
|
-
return this.grid._focusCol -= 1, e.preventDefault(),
|
|
4058
|
+
return this.grid._focusCol -= 1, e.preventDefault(), _(this.grid), !0;
|
|
3785
4059
|
if (this.grid._focusRow > 0)
|
|
3786
|
-
return this.grid._focusRow -= 1, this.grid._focusCol = i, e.preventDefault(),
|
|
4060
|
+
return this.grid._focusRow -= 1, this.grid._focusCol = i, e.preventDefault(), _(this.grid), !0;
|
|
3787
4061
|
break;
|
|
3788
4062
|
case "ArrowRight":
|
|
3789
4063
|
if (this.grid._focusRow < t)
|
|
3790
|
-
return this.grid._focusRow += 1, e.preventDefault(),
|
|
4064
|
+
return this.grid._focusRow += 1, e.preventDefault(), _(this.grid), !0;
|
|
3791
4065
|
break;
|
|
3792
4066
|
case "ArrowLeft":
|
|
3793
4067
|
if (this.grid._focusRow > 0)
|
|
3794
|
-
return this.grid._focusRow -= 1, e.preventDefault(),
|
|
4068
|
+
return this.grid._focusRow -= 1, e.preventDefault(), _(this.grid), !0;
|
|
3795
4069
|
break;
|
|
3796
4070
|
}
|
|
3797
4071
|
return !1;
|
|
3798
4072
|
}
|
|
3799
4073
|
#f;
|
|
3800
|
-
#
|
|
4074
|
+
#u;
|
|
3801
4075
|
#m;
|
|
3802
4076
|
#v() {
|
|
3803
4077
|
if (this.#f && this.#f > 0)
|
|
@@ -3806,7 +4080,7 @@ class on extends R {
|
|
|
3806
4080
|
return typeof e == "number" && e > 0 ? e : 80;
|
|
3807
4081
|
}
|
|
3808
4082
|
#y() {
|
|
3809
|
-
return this.#
|
|
4083
|
+
return this.#u && this.#u > 0 ? this.#u : this.#l ?? 28;
|
|
3810
4084
|
}
|
|
3811
4085
|
#w() {
|
|
3812
4086
|
for (const e of this.rows)
|
|
@@ -3823,13 +4097,13 @@ class on extends R {
|
|
|
3823
4097
|
getExtraHeight() {
|
|
3824
4098
|
if (!this.#t || !this.config.cardRenderer || !this.#w())
|
|
3825
4099
|
return 0;
|
|
3826
|
-
const e = this.#
|
|
4100
|
+
const e = this.#l ?? 28, t = this.#y(), i = this.#v(), { groupCount: n, cardCount: r } = this.#C(), o = n * Math.max(0, t - e), a = r * Math.max(0, i - e);
|
|
3827
4101
|
return o + a;
|
|
3828
4102
|
}
|
|
3829
4103
|
getExtraHeightBefore(e) {
|
|
3830
4104
|
if (!this.#t || !this.config.cardRenderer || !this.#w())
|
|
3831
4105
|
return 0;
|
|
3832
|
-
const t = this.#
|
|
4106
|
+
const t = this.#l ?? 28, i = this.#y(), n = this.#v(), r = Math.max(0, i - t), o = Math.max(0, n - t);
|
|
3833
4107
|
let a = 0, l = 0;
|
|
3834
4108
|
const d = this.rows, c = Math.min(e, d.length);
|
|
3835
4109
|
for (let u = 0; u < c; u++)
|
|
@@ -3852,7 +4126,7 @@ class on extends R {
|
|
|
3852
4126
|
const o = this.gridElement.querySelector(".data-grid-row.group-row");
|
|
3853
4127
|
if (o) {
|
|
3854
4128
|
const a = o.getBoundingClientRect().height;
|
|
3855
|
-
a > 0 && a !== this.#
|
|
4129
|
+
a > 0 && a !== this.#u && (this.#u = a, e = !0);
|
|
3856
4130
|
}
|
|
3857
4131
|
}
|
|
3858
4132
|
const r = this.gridElement.querySelector(".data-grid-row.responsive-card");
|
|
@@ -3865,10 +4139,10 @@ class on extends R {
|
|
|
3865
4139
|
}));
|
|
3866
4140
|
}
|
|
3867
4141
|
}
|
|
3868
|
-
const
|
|
3869
|
-
class
|
|
4142
|
+
const Ii = '.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}', Pi = "__tbw_row_drag";
|
|
4143
|
+
class fn extends R {
|
|
3870
4144
|
name = "rowReorder";
|
|
3871
|
-
styles =
|
|
4145
|
+
styles = Ii;
|
|
3872
4146
|
get defaultConfig() {
|
|
3873
4147
|
return {
|
|
3874
4148
|
enableKeyboard: !0,
|
|
@@ -3892,7 +4166,7 @@ class sn extends R {
|
|
|
3892
4166
|
if (!this.config.showDragHandle)
|
|
3893
4167
|
return [...e];
|
|
3894
4168
|
const t = {
|
|
3895
|
-
field:
|
|
4169
|
+
field: Pi,
|
|
3896
4170
|
header: "",
|
|
3897
4171
|
width: this.config.dragHandleWidth ?? 40,
|
|
3898
4172
|
resizable: !1,
|
|
@@ -3986,7 +4260,7 @@ class sn extends R {
|
|
|
3986
4260
|
row: e
|
|
3987
4261
|
}, this.lastFocusCol = r;
|
|
3988
4262
|
const o = this.grid, a = [...o._rows ?? this.sourceRows], [l] = a.splice(t, 1);
|
|
3989
|
-
a.splice(i, 0, l), o._rows = a, o._focusRow = i, o._focusCol = r, o.refreshVirtualWindow(!0),
|
|
4263
|
+
a.splice(i, 0, l), o._rows = a, o._focusRow = i, o._focusCol = r, o.refreshVirtualWindow(!0), _(o), this.clearDebounceTimer(), this.debounceTimer = setTimeout(() => {
|
|
3990
4264
|
this.flushPendingMove();
|
|
3991
4265
|
}, this.config.debounceMs ?? 300);
|
|
3992
4266
|
}
|
|
@@ -4005,7 +4279,7 @@ class sn extends R {
|
|
|
4005
4279
|
const o = [...this.sourceRows], [a] = o.splice(t, 1);
|
|
4006
4280
|
o.splice(e, 0, a);
|
|
4007
4281
|
const l = this.grid;
|
|
4008
|
-
l._rows = o, l._focusRow = e, l._focusCol = this.lastFocusCol, l.refreshVirtualWindow(!0),
|
|
4282
|
+
l._rows = o, l._focusRow = e, l._focusCol = this.lastFocusCol, l.refreshVirtualWindow(!0), _(l);
|
|
4009
4283
|
}
|
|
4010
4284
|
}
|
|
4011
4285
|
executeMove(e, t, i, n) {
|
|
@@ -4033,7 +4307,7 @@ class sn extends R {
|
|
|
4033
4307
|
this.debounceTimer && (clearTimeout(this.debounceTimer), this.debounceTimer = null);
|
|
4034
4308
|
}
|
|
4035
4309
|
}
|
|
4036
|
-
function
|
|
4310
|
+
function q(s) {
|
|
4037
4311
|
return {
|
|
4038
4312
|
startRow: Math.min(s.startRow, s.endRow),
|
|
4039
4313
|
startCol: Math.min(s.startCol, s.endCol),
|
|
@@ -4041,38 +4315,38 @@ function V(s) {
|
|
|
4041
4315
|
endCol: Math.max(s.startCol, s.endCol)
|
|
4042
4316
|
};
|
|
4043
4317
|
}
|
|
4044
|
-
function
|
|
4045
|
-
const e =
|
|
4318
|
+
function Fi(s) {
|
|
4319
|
+
const e = q(s);
|
|
4046
4320
|
return {
|
|
4047
4321
|
from: { row: e.startRow, col: e.startCol },
|
|
4048
4322
|
to: { row: e.endRow, col: e.endCol }
|
|
4049
4323
|
};
|
|
4050
4324
|
}
|
|
4051
|
-
function
|
|
4052
|
-
return s.map(
|
|
4325
|
+
function Ue(s) {
|
|
4326
|
+
return s.map(Fi);
|
|
4053
4327
|
}
|
|
4054
|
-
function
|
|
4055
|
-
const i =
|
|
4328
|
+
function Di(s, e, t) {
|
|
4329
|
+
const i = q(t);
|
|
4056
4330
|
return s >= i.startRow && s <= i.endRow && e >= i.startCol && e <= i.endCol;
|
|
4057
4331
|
}
|
|
4058
|
-
function
|
|
4059
|
-
return t.some((i) =>
|
|
4332
|
+
function He(s, e, t) {
|
|
4333
|
+
return t.some((i) => Di(s, e, i));
|
|
4060
4334
|
}
|
|
4061
|
-
function
|
|
4062
|
-
const e = [], t =
|
|
4335
|
+
function Mi(s) {
|
|
4336
|
+
const e = [], t = q(s);
|
|
4063
4337
|
for (let i = t.startRow; i <= t.endRow; i++)
|
|
4064
4338
|
for (let n = t.startCol; n <= t.endCol; n++)
|
|
4065
4339
|
e.push({ row: i, col: n });
|
|
4066
4340
|
return e;
|
|
4067
4341
|
}
|
|
4068
|
-
function
|
|
4342
|
+
function qi(s) {
|
|
4069
4343
|
const e = /* @__PURE__ */ new Map();
|
|
4070
4344
|
for (const t of s)
|
|
4071
|
-
for (const i of
|
|
4345
|
+
for (const i of Mi(t))
|
|
4072
4346
|
e.set(`${i.row},${i.col}`, i);
|
|
4073
4347
|
return [...e.values()];
|
|
4074
4348
|
}
|
|
4075
|
-
function
|
|
4349
|
+
function te(s, e) {
|
|
4076
4350
|
return {
|
|
4077
4351
|
startRow: s.row,
|
|
4078
4352
|
startCol: s.col,
|
|
@@ -4080,8 +4354,12 @@ function Q(s, e) {
|
|
|
4080
4354
|
endCol: e.col
|
|
4081
4355
|
};
|
|
4082
4356
|
}
|
|
4083
|
-
|
|
4084
|
-
|
|
4357
|
+
function V(s, e) {
|
|
4358
|
+
const t = q(s), i = q(e);
|
|
4359
|
+
return t.startRow === i.startRow && t.startCol === i.startCol && t.endRow === i.endRow && t.endCol === i.endCol;
|
|
4360
|
+
}
|
|
4361
|
+
const Ni = "@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}}}";
|
|
4362
|
+
function Hi(s, e, t) {
|
|
4085
4363
|
if (s === "cell" && e.selectedCell)
|
|
4086
4364
|
return {
|
|
4087
4365
|
mode: s,
|
|
@@ -4099,9 +4377,9 @@ function Ii(s, e, t) {
|
|
|
4099
4377
|
}));
|
|
4100
4378
|
return { mode: s, ranges: i };
|
|
4101
4379
|
}
|
|
4102
|
-
return s === "range" && e.ranges.length > 0 ? { mode: s, ranges:
|
|
4380
|
+
return s === "range" && e.ranges.length > 0 ? { mode: s, ranges: Ue(e.ranges) } : { mode: s, ranges: [] };
|
|
4103
4381
|
}
|
|
4104
|
-
class
|
|
4382
|
+
class pn extends R {
|
|
4105
4383
|
static manifest = {
|
|
4106
4384
|
configRules: [
|
|
4107
4385
|
{
|
|
@@ -4115,7 +4393,7 @@ class an extends R {
|
|
|
4115
4393
|
]
|
|
4116
4394
|
};
|
|
4117
4395
|
name = "selection";
|
|
4118
|
-
styles =
|
|
4396
|
+
styles = Ni;
|
|
4119
4397
|
get defaultConfig() {
|
|
4120
4398
|
return {
|
|
4121
4399
|
mode: "cell",
|
|
@@ -4153,16 +4431,22 @@ class an extends R {
|
|
|
4153
4431
|
if (n.type !== o)
|
|
4154
4432
|
return !1;
|
|
4155
4433
|
const a = this.columns[i], l = a && I(a);
|
|
4156
|
-
if (r === "cell")
|
|
4157
|
-
|
|
4434
|
+
if (r === "cell") {
|
|
4435
|
+
if (l || !this.isCellSelectable(t, i))
|
|
4436
|
+
return !1;
|
|
4437
|
+
const d = this.selectedCell;
|
|
4438
|
+
return d && d.row === t && d.col === i || (this.selectedCell = { row: t, col: i }, this.emit("selection-change", this.#t()), this.requestAfterRender()), !1;
|
|
4439
|
+
}
|
|
4158
4440
|
if (r === "row")
|
|
4159
|
-
return this.isRowSelectable(t) && (this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#t()), this.requestAfterRender()), !1;
|
|
4441
|
+
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;
|
|
4160
4442
|
if (r === "range") {
|
|
4161
4443
|
if (l || !this.isCellSelectable(t, i))
|
|
4162
4444
|
return !1;
|
|
4163
4445
|
const d = n.shiftKey, c = n.ctrlKey || n.metaKey;
|
|
4164
4446
|
if (d && this.cellAnchor) {
|
|
4165
|
-
const u =
|
|
4447
|
+
const u = te(this.cellAnchor, { row: t, col: i }), h = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
|
|
4448
|
+
if (h && V(h, u))
|
|
4449
|
+
return !1;
|
|
4166
4450
|
c ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = u : this.ranges.push(u) : this.ranges = [u], this.activeRange = u;
|
|
4167
4451
|
} else if (c) {
|
|
4168
4452
|
const u = {
|
|
@@ -4179,6 +4463,8 @@ class an extends R {
|
|
|
4179
4463
|
endRow: t,
|
|
4180
4464
|
endCol: i
|
|
4181
4465
|
};
|
|
4466
|
+
if (this.ranges.length === 1 && V(this.ranges[0], u))
|
|
4467
|
+
return !1;
|
|
4182
4468
|
this.ranges = [u], this.activeRange = u, this.cellAnchor = { row: t, col: i };
|
|
4183
4469
|
}
|
|
4184
4470
|
return this.emit("selection-change", this.#t()), this.requestAfterRender(), !1;
|
|
@@ -4206,6 +4492,7 @@ class an extends R {
|
|
|
4206
4492
|
if (t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey)) {
|
|
4207
4493
|
const r = this.rows.length, o = this.columns.length;
|
|
4208
4494
|
if (r > 0 && o > 0) {
|
|
4495
|
+
e.preventDefault(), e.stopPropagation();
|
|
4209
4496
|
const a = {
|
|
4210
4497
|
startRow: 0,
|
|
4211
4498
|
startCol: 0,
|
|
@@ -4223,26 +4510,24 @@ class an extends R {
|
|
|
4223
4510
|
if (t && I(t) || !this.isCellSelectable(e.rowIndex, e.colIndex) || e.originalEvent.shiftKey && this.cellAnchor)
|
|
4224
4511
|
return;
|
|
4225
4512
|
this.isDragging = !0;
|
|
4226
|
-
const i = e.rowIndex, n = e.colIndex
|
|
4227
|
-
this.cellAnchor = { row: i, col: n }, e.originalEvent.ctrlKey || e.originalEvent.metaKey || (this.ranges = []);
|
|
4228
|
-
const o = {
|
|
4513
|
+
const i = e.rowIndex, n = e.colIndex, r = e.originalEvent.ctrlKey || e.originalEvent.metaKey, o = {
|
|
4229
4514
|
startRow: i,
|
|
4230
4515
|
startCol: n,
|
|
4231
4516
|
endRow: i,
|
|
4232
4517
|
endCol: n
|
|
4233
4518
|
};
|
|
4234
|
-
return this.ranges.push(o), this.activeRange = o, this.emit("selection-change", this.#t()), this.requestAfterRender(), !0;
|
|
4519
|
+
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);
|
|
4235
4520
|
}
|
|
4236
4521
|
onCellMouseMove(e) {
|
|
4237
4522
|
if (this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
|
|
4238
4523
|
let t = e.colIndex;
|
|
4239
4524
|
const i = this.columns[t];
|
|
4240
4525
|
if (i && I(i)) {
|
|
4241
|
-
const
|
|
4242
|
-
|
|
4526
|
+
const o = this.columns.findIndex((a) => !I(a));
|
|
4527
|
+
o >= 0 && (t = o);
|
|
4243
4528
|
}
|
|
4244
|
-
const n =
|
|
4245
|
-
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;
|
|
4529
|
+
const n = te(this.cellAnchor, { row: e.rowIndex, col: t }), r = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null;
|
|
4530
|
+
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;
|
|
4246
4531
|
}
|
|
4247
4532
|
onCellMouseUp(e) {
|
|
4248
4533
|
if (this.config.mode === "range" && this.isDragging)
|
|
@@ -4258,25 +4543,25 @@ class an extends R {
|
|
|
4258
4543
|
const r = e.querySelectorAll(".data-grid-row");
|
|
4259
4544
|
if (r.forEach((o) => {
|
|
4260
4545
|
o.classList.remove("selected", "row-focus"), i && o.removeAttribute("data-selectable");
|
|
4261
|
-
}), t === "row" && (
|
|
4262
|
-
const a = o.querySelector(".cell[data-row]"), l =
|
|
4546
|
+
}), t === "row" && (fe(e), r.forEach((o) => {
|
|
4547
|
+
const a = o.querySelector(".cell[data-row]"), l = it(a);
|
|
4263
4548
|
l >= 0 && (i && !this.isRowSelectable(l) && o.setAttribute("data-selectable", "false"), this.selected.has(l) && o.classList.add("selected", "row-focus"));
|
|
4264
4549
|
})), (t === "cell" || t === "range") && i && e.querySelectorAll(".cell[data-row][data-col]").forEach((a) => {
|
|
4265
4550
|
const l = parseInt(a.getAttribute("data-row") ?? "-1", 10), d = parseInt(a.getAttribute("data-col") ?? "-1", 10);
|
|
4266
4551
|
l >= 0 && d >= 0 && (this.isCellSelectable(l, d) || a.setAttribute("data-selectable", "false"));
|
|
4267
4552
|
}), t === "range" && this.ranges.length > 0) {
|
|
4268
|
-
|
|
4269
|
-
const o = this.activeRange ?
|
|
4553
|
+
fe(e);
|
|
4554
|
+
const o = this.activeRange ? q(this.activeRange) : null, a = this.columns.findIndex((d) => !I(d));
|
|
4270
4555
|
this.columns.length - 1, e.querySelectorAll(".cell[data-row][data-col]").forEach((d) => {
|
|
4271
4556
|
const c = parseInt(d.getAttribute("data-row") ?? "-1", 10), u = parseInt(d.getAttribute("data-col") ?? "-1", 10);
|
|
4272
4557
|
if (c >= 0 && u >= 0) {
|
|
4273
4558
|
const h = this.columns[u];
|
|
4274
4559
|
if (h && I(h))
|
|
4275
4560
|
return;
|
|
4276
|
-
if (
|
|
4561
|
+
if (He(c, u, this.ranges) && (d.classList.add("selected"), o)) {
|
|
4277
4562
|
c === o.startRow && d.classList.add("top"), c === o.endRow && d.classList.add("bottom");
|
|
4278
|
-
const
|
|
4279
|
-
u ===
|
|
4563
|
+
const f = Math.max(o.startCol, a);
|
|
4564
|
+
u === f && d.classList.add("first"), u === o.endCol && d.classList.add("last");
|
|
4280
4565
|
}
|
|
4281
4566
|
}
|
|
4282
4567
|
});
|
|
@@ -4291,7 +4576,7 @@ class an extends R {
|
|
|
4291
4576
|
this.pendingKeyboardUpdate = null;
|
|
4292
4577
|
const r = this.grid._focusRow, o = this.grid._focusCol;
|
|
4293
4578
|
if (n && this.cellAnchor) {
|
|
4294
|
-
const a =
|
|
4579
|
+
const a = te(this.cellAnchor, { row: r, col: o });
|
|
4295
4580
|
this.ranges = [a], this.activeRange = a;
|
|
4296
4581
|
} else n || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: r, col: o });
|
|
4297
4582
|
this.emit("selection-change", this.#t());
|
|
@@ -4309,10 +4594,10 @@ class an extends R {
|
|
|
4309
4594
|
};
|
|
4310
4595
|
}
|
|
4311
4596
|
getSelectedCells() {
|
|
4312
|
-
return
|
|
4597
|
+
return qi(this.ranges);
|
|
4313
4598
|
}
|
|
4314
4599
|
isCellSelected(e, t) {
|
|
4315
|
-
return
|
|
4600
|
+
return He(e, t, this.ranges);
|
|
4316
4601
|
}
|
|
4317
4602
|
clearSelection() {
|
|
4318
4603
|
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();
|
|
@@ -4325,11 +4610,11 @@ class an extends R {
|
|
|
4325
4610
|
endCol: t.to.col
|
|
4326
4611
|
})), this.activeRange = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null, this.emit("selection-change", {
|
|
4327
4612
|
mode: this.config.mode,
|
|
4328
|
-
ranges:
|
|
4613
|
+
ranges: Ue(this.ranges)
|
|
4329
4614
|
}), this.requestAfterRender();
|
|
4330
4615
|
}
|
|
4331
4616
|
#t() {
|
|
4332
|
-
return
|
|
4617
|
+
return Hi(
|
|
4333
4618
|
this.config.mode,
|
|
4334
4619
|
{
|
|
4335
4620
|
selectedCell: this.selectedCell,
|
|
@@ -4340,23 +4625,23 @@ class an extends R {
|
|
|
4340
4625
|
);
|
|
4341
4626
|
}
|
|
4342
4627
|
}
|
|
4343
|
-
function
|
|
4628
|
+
function $(s, e) {
|
|
4344
4629
|
return Math.floor(s / e);
|
|
4345
4630
|
}
|
|
4346
|
-
function
|
|
4631
|
+
function Ki(s, e) {
|
|
4347
4632
|
return {
|
|
4348
4633
|
start: s * e,
|
|
4349
4634
|
end: (s + 1) * e
|
|
4350
4635
|
};
|
|
4351
4636
|
}
|
|
4352
|
-
function
|
|
4353
|
-
const i =
|
|
4637
|
+
function zi(s, e, t) {
|
|
4638
|
+
const i = $(s, t), n = $(e - 1, t), r = [];
|
|
4354
4639
|
for (let o = i; o <= n; o++)
|
|
4355
4640
|
r.push(o);
|
|
4356
4641
|
return r;
|
|
4357
4642
|
}
|
|
4358
|
-
async function
|
|
4359
|
-
const n =
|
|
4643
|
+
async function Ke(s, e, t, i) {
|
|
4644
|
+
const n = Ki(e, t);
|
|
4360
4645
|
return s.getRows({
|
|
4361
4646
|
startRow: n.start,
|
|
4362
4647
|
endRow: n.end,
|
|
@@ -4364,14 +4649,14 @@ async function qe(s, e, t, i) {
|
|
|
4364
4649
|
filterModel: i.filterModel
|
|
4365
4650
|
});
|
|
4366
4651
|
}
|
|
4367
|
-
function
|
|
4368
|
-
const i =
|
|
4652
|
+
function Gi(s, e, t) {
|
|
4653
|
+
const i = $(s, e), n = t.get(i);
|
|
4369
4654
|
if (!n) return;
|
|
4370
4655
|
const r = s % e;
|
|
4371
4656
|
return n[r];
|
|
4372
4657
|
}
|
|
4373
|
-
const
|
|
4374
|
-
class
|
|
4658
|
+
const Oi = 100;
|
|
4659
|
+
class mn extends R {
|
|
4375
4660
|
name = "serverSide";
|
|
4376
4661
|
get defaultConfig() {
|
|
4377
4662
|
return {
|
|
@@ -4391,12 +4676,12 @@ class ln extends R {
|
|
|
4391
4676
|
}
|
|
4392
4677
|
loadRequiredBlocks() {
|
|
4393
4678
|
if (!this.dataSource) return;
|
|
4394
|
-
const e = this.grid, t = this.config.cacheBlockSize ?? 100, i = { startRow: e._virtualization.start, endRow: e._virtualization.end }, n =
|
|
4679
|
+
const e = this.grid, t = this.config.cacheBlockSize ?? 100, i = { startRow: e._virtualization.start, endRow: e._virtualization.end }, n = zi(i.startRow, i.endRow, t);
|
|
4395
4680
|
for (const r of n)
|
|
4396
4681
|
if (!(this.loadedBlocks.has(r) || this.loadingBlocks.has(r))) {
|
|
4397
4682
|
if (this.loadingBlocks.size >= (this.config.maxConcurrentRequests ?? 2))
|
|
4398
4683
|
break;
|
|
4399
|
-
this.loadingBlocks.add(r),
|
|
4684
|
+
this.loadingBlocks.add(r), Ke(this.dataSource, r, t, {}).then((o) => {
|
|
4400
4685
|
this.loadedBlocks.set(r, o.rows), this.totalRowCount = o.totalRowCount, this.loadingBlocks.delete(r), this.requestRender(), this.loadRequiredBlocks();
|
|
4401
4686
|
}).catch(() => {
|
|
4402
4687
|
this.loadingBlocks.delete(r);
|
|
@@ -4407,7 +4692,7 @@ class ln extends R {
|
|
|
4407
4692
|
if (!this.dataSource) return [...e];
|
|
4408
4693
|
const t = [];
|
|
4409
4694
|
for (let i = 0; i < this.totalRowCount; i++) {
|
|
4410
|
-
const n =
|
|
4695
|
+
const n = Gi(i, this.config.cacheBlockSize ?? 100, this.loadedBlocks);
|
|
4411
4696
|
t.push(n ?? { __loading: !0, __index: i });
|
|
4412
4697
|
}
|
|
4413
4698
|
return t;
|
|
@@ -4415,12 +4700,12 @@ class ln extends R {
|
|
|
4415
4700
|
onScroll(e) {
|
|
4416
4701
|
this.dataSource && (this.loadRequiredBlocks(), this.scrollDebounceTimer && clearTimeout(this.scrollDebounceTimer), this.scrollDebounceTimer = setTimeout(() => {
|
|
4417
4702
|
this.loadRequiredBlocks();
|
|
4418
|
-
},
|
|
4703
|
+
}, Oi));
|
|
4419
4704
|
}
|
|
4420
4705
|
setDataSource(e) {
|
|
4421
4706
|
this.dataSource = e, this.loadedBlocks.clear(), this.loadingBlocks.clear();
|
|
4422
4707
|
const t = this.config.cacheBlockSize ?? 100;
|
|
4423
|
-
|
|
4708
|
+
Ke(e, 0, t, {}).then((i) => {
|
|
4424
4709
|
this.loadedBlocks.set(0, i.rows), this.totalRowCount = i.totalRowCount, this.requestRender();
|
|
4425
4710
|
});
|
|
4426
4711
|
}
|
|
@@ -4434,59 +4719,59 @@ class ln extends R {
|
|
|
4434
4719
|
return this.totalRowCount;
|
|
4435
4720
|
}
|
|
4436
4721
|
isRowLoaded(e) {
|
|
4437
|
-
const t = this.config.cacheBlockSize ?? 100, i =
|
|
4722
|
+
const t = this.config.cacheBlockSize ?? 100, i = $(e, t);
|
|
4438
4723
|
return this.loadedBlocks.has(i);
|
|
4439
4724
|
}
|
|
4440
4725
|
getLoadedBlockCount() {
|
|
4441
4726
|
return this.loadedBlocks.size;
|
|
4442
4727
|
}
|
|
4443
4728
|
}
|
|
4444
|
-
function
|
|
4729
|
+
function Ye(s, e, t) {
|
|
4445
4730
|
return s.id !== void 0 ? String(s.id) : t ? `${t}-${e}` : String(e);
|
|
4446
4731
|
}
|
|
4447
|
-
function
|
|
4732
|
+
function ie(s, e) {
|
|
4448
4733
|
const t = new Set(s);
|
|
4449
4734
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
4450
4735
|
}
|
|
4451
|
-
function
|
|
4736
|
+
function oe(s, e, t = null, i = 0) {
|
|
4452
4737
|
const n = e.childrenField ?? "children", r = /* @__PURE__ */ new Set();
|
|
4453
4738
|
for (let o = 0; o < s.length; o++) {
|
|
4454
|
-
const a = s[o], l =
|
|
4739
|
+
const a = s[o], l = Ye(a, o, t), d = a[n];
|
|
4455
4740
|
if (Array.isArray(d) && d.length > 0) {
|
|
4456
4741
|
r.add(l);
|
|
4457
|
-
const c =
|
|
4742
|
+
const c = oe(d, e, l, i + 1);
|
|
4458
4743
|
for (const u of c) r.add(u);
|
|
4459
4744
|
}
|
|
4460
4745
|
}
|
|
4461
4746
|
return r;
|
|
4462
4747
|
}
|
|
4463
|
-
function
|
|
4748
|
+
function Bi() {
|
|
4464
4749
|
return /* @__PURE__ */ new Set();
|
|
4465
4750
|
}
|
|
4466
|
-
function
|
|
4751
|
+
function Xe(s, e, t, i = null, n = 0) {
|
|
4467
4752
|
const r = t.childrenField ?? "children";
|
|
4468
4753
|
for (let o = 0; o < s.length; o++) {
|
|
4469
|
-
const a = s[o], l =
|
|
4754
|
+
const a = s[o], l = Ye(a, o, i);
|
|
4470
4755
|
if (l === e)
|
|
4471
4756
|
return [l];
|
|
4472
4757
|
const d = a[r];
|
|
4473
4758
|
if (Array.isArray(d) && d.length > 0) {
|
|
4474
|
-
const c =
|
|
4759
|
+
const c = Xe(d, e, t, l, n + 1);
|
|
4475
4760
|
if (c)
|
|
4476
4761
|
return [l, ...c];
|
|
4477
4762
|
}
|
|
4478
4763
|
}
|
|
4479
4764
|
return null;
|
|
4480
4765
|
}
|
|
4481
|
-
function
|
|
4482
|
-
const n =
|
|
4766
|
+
function Vi(s, e, t, i) {
|
|
4767
|
+
const n = Xe(s, e, t);
|
|
4483
4768
|
if (!n) return i;
|
|
4484
4769
|
const r = new Set(i);
|
|
4485
4770
|
for (let o = 0; o < n.length - 1; o++)
|
|
4486
4771
|
r.add(n[o]);
|
|
4487
4772
|
return r;
|
|
4488
4773
|
}
|
|
4489
|
-
function
|
|
4774
|
+
function ze(s, e = "children") {
|
|
4490
4775
|
if (!Array.isArray(s) || s.length === 0) return !1;
|
|
4491
4776
|
for (const t of s) {
|
|
4492
4777
|
if (!t) continue;
|
|
@@ -4496,7 +4781,7 @@ function Ke(s, e = "children") {
|
|
|
4496
4781
|
}
|
|
4497
4782
|
return !1;
|
|
4498
4783
|
}
|
|
4499
|
-
function
|
|
4784
|
+
function Wi(s) {
|
|
4500
4785
|
if (!Array.isArray(s) || s.length === 0) return null;
|
|
4501
4786
|
const e = ["children", "items", "nodes", "subRows", "nested"];
|
|
4502
4787
|
for (const t of s)
|
|
@@ -4508,10 +4793,10 @@ function Hi(s) {
|
|
|
4508
4793
|
}
|
|
4509
4794
|
return null;
|
|
4510
4795
|
}
|
|
4511
|
-
const
|
|
4512
|
-
class
|
|
4796
|
+
const $i = "@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}}}";
|
|
4797
|
+
class wn extends R {
|
|
4513
4798
|
name = "tree";
|
|
4514
|
-
styles =
|
|
4799
|
+
styles = $i;
|
|
4515
4800
|
get defaultConfig() {
|
|
4516
4801
|
return {
|
|
4517
4802
|
childrenField: "children",
|
|
@@ -4537,15 +4822,15 @@ class dn extends R {
|
|
|
4537
4822
|
}
|
|
4538
4823
|
detect(e) {
|
|
4539
4824
|
if (!this.config.autoDetect) return !1;
|
|
4540
|
-
const t = e, i = this.config.childrenField ??
|
|
4541
|
-
return
|
|
4825
|
+
const t = e, i = this.config.childrenField ?? Wi(t) ?? "children";
|
|
4826
|
+
return ze(t, i);
|
|
4542
4827
|
}
|
|
4543
4828
|
processRows(e) {
|
|
4544
4829
|
const t = this.config.childrenField ?? "children", i = e;
|
|
4545
|
-
if (!
|
|
4830
|
+
if (!ze(i, t))
|
|
4546
4831
|
return this.flattenedRows = [], this.rowKeyMap.clear(), this.previousVisibleKeys.clear(), [...e];
|
|
4547
4832
|
let n = this.withStableKeys(i);
|
|
4548
|
-
this.sortState && (n = this.sortTree(n, this.sortState.field, this.sortState.direction)), this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys =
|
|
4833
|
+
this.sortState && (n = this.sortTree(n, this.sortState.field, this.sortState.direction)), this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = oe(n, this.config), this.initialExpansionDone = !0), this.flattenedRows = this.flattenTree(n, this.expandedKeys), this.rowKeyMap.clear(), this.keysToAnimate.clear();
|
|
4549
4834
|
const r = /* @__PURE__ */ new Set();
|
|
4550
4835
|
for (const o of this.flattenedRows)
|
|
4551
4836
|
this.rowKeyMap.set(o.key, o), r.add(o.key), !this.previousVisibleKeys.has(o.key) && o.depth > 0 && this.keysToAnimate.add(o.key);
|
|
@@ -4598,11 +4883,11 @@ class dn extends R {
|
|
|
4598
4883
|
const t = [...e];
|
|
4599
4884
|
if (t.length === 0) return t;
|
|
4600
4885
|
const i = t[0], n = i.viewRenderer, r = () => this.config, o = this.setIcon.bind(this), a = this.resolveIcon.bind(this), l = (d) => {
|
|
4601
|
-
const { row: c, value: u } = d, { showExpandIcons: h = !0, indentWidth:
|
|
4602
|
-
if (m.className = "tree-cell-wrapper", m.style.setProperty("--tbw-tree-depth", String(p)),
|
|
4603
|
-
if (
|
|
4886
|
+
const { row: c, value: u } = d, { showExpandIcons: h = !0, indentWidth: g } = r(), f = c, p = f.__treeDepth ?? 0, m = document.createElement("span");
|
|
4887
|
+
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)
|
|
4888
|
+
if (f.__treeHasChildren) {
|
|
4604
4889
|
const b = document.createElement("span");
|
|
4605
|
-
b.className = `tree-toggle${
|
|
4890
|
+
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);
|
|
4606
4891
|
} else {
|
|
4607
4892
|
const b = document.createElement("span");
|
|
4608
4893
|
b.className = "tree-spacer", m.appendChild(b);
|
|
@@ -4623,7 +4908,7 @@ class dn extends R {
|
|
|
4623
4908
|
const i = t.getAttribute("data-tree-key");
|
|
4624
4909
|
if (!i) return !1;
|
|
4625
4910
|
const n = this.rowKeyMap.get(i);
|
|
4626
|
-
return n ? (this.expandedKeys =
|
|
4911
|
+
return n ? (this.expandedKeys = ie(this.expandedKeys, i), this.emit("tree-expand", {
|
|
4627
4912
|
key: i,
|
|
4628
4913
|
row: n.data,
|
|
4629
4914
|
expanded: this.expandedKeys.has(i),
|
|
@@ -4634,7 +4919,7 @@ class dn extends R {
|
|
|
4634
4919
|
if (e.key !== " ") return;
|
|
4635
4920
|
const t = this.grid._focusRow, i = this.flattenedRows[t];
|
|
4636
4921
|
if (i?.hasChildren)
|
|
4637
|
-
return e.preventDefault(), this.expandedKeys =
|
|
4922
|
+
return e.preventDefault(), this.expandedKeys = ie(this.expandedKeys, i.key), this.emit("tree-expand", {
|
|
4638
4923
|
key: i.key,
|
|
4639
4924
|
row: i.data,
|
|
4640
4925
|
expanded: this.expandedKeys.has(i.key),
|
|
@@ -4667,13 +4952,13 @@ class dn extends R {
|
|
|
4667
4952
|
this.expandedKeys.delete(e), this.requestRender();
|
|
4668
4953
|
}
|
|
4669
4954
|
toggle(e) {
|
|
4670
|
-
this.expandedKeys =
|
|
4955
|
+
this.expandedKeys = ie(this.expandedKeys, e), this.requestRender();
|
|
4671
4956
|
}
|
|
4672
4957
|
expandAll() {
|
|
4673
|
-
this.expandedKeys =
|
|
4958
|
+
this.expandedKeys = oe(this.rows, this.config), this.requestRender();
|
|
4674
4959
|
}
|
|
4675
4960
|
collapseAll() {
|
|
4676
|
-
this.expandedKeys =
|
|
4961
|
+
this.expandedKeys = Bi(), this.requestRender();
|
|
4677
4962
|
}
|
|
4678
4963
|
isExpanded(e) {
|
|
4679
4964
|
return this.expandedKeys.has(e);
|
|
@@ -4688,10 +4973,10 @@ class dn extends R {
|
|
|
4688
4973
|
return this.rowKeyMap.get(e)?.data;
|
|
4689
4974
|
}
|
|
4690
4975
|
expandToKey(e) {
|
|
4691
|
-
this.expandedKeys =
|
|
4976
|
+
this.expandedKeys = Vi(this.rows, e, this.config, this.expandedKeys), this.requestRender();
|
|
4692
4977
|
}
|
|
4693
4978
|
}
|
|
4694
|
-
function
|
|
4979
|
+
function ji(s, e, t) {
|
|
4695
4980
|
const i = [...s.undoStack, e];
|
|
4696
4981
|
for (; i.length > t; )
|
|
4697
4982
|
i.shift();
|
|
@@ -4700,7 +4985,7 @@ function zi(s, e, t) {
|
|
|
4700
4985
|
redoStack: []
|
|
4701
4986
|
};
|
|
4702
4987
|
}
|
|
4703
|
-
function
|
|
4988
|
+
function Ge(s) {
|
|
4704
4989
|
if (s.undoStack.length === 0)
|
|
4705
4990
|
return { newState: s, action: null };
|
|
4706
4991
|
const e = [...s.undoStack], t = e.pop();
|
|
@@ -4712,7 +4997,7 @@ function He(s) {
|
|
|
4712
4997
|
action: t
|
|
4713
4998
|
} : { newState: s, action: null };
|
|
4714
4999
|
}
|
|
4715
|
-
function
|
|
5000
|
+
function Oe(s) {
|
|
4716
5001
|
if (s.redoStack.length === 0)
|
|
4717
5002
|
return { newState: s, action: null };
|
|
4718
5003
|
const e = [...s.redoStack], t = e.pop();
|
|
@@ -4724,16 +5009,16 @@ function Ne(s) {
|
|
|
4724
5009
|
action: t
|
|
4725
5010
|
} : { newState: s, action: null };
|
|
4726
5011
|
}
|
|
4727
|
-
function
|
|
5012
|
+
function Ui(s) {
|
|
4728
5013
|
return s.undoStack.length > 0;
|
|
4729
5014
|
}
|
|
4730
|
-
function
|
|
5015
|
+
function Yi(s) {
|
|
4731
5016
|
return s.redoStack.length > 0;
|
|
4732
5017
|
}
|
|
4733
|
-
function
|
|
5018
|
+
function Xi() {
|
|
4734
5019
|
return { undoStack: [], redoStack: [] };
|
|
4735
5020
|
}
|
|
4736
|
-
function
|
|
5021
|
+
function Zi(s, e, t, i) {
|
|
4737
5022
|
return {
|
|
4738
5023
|
type: "cell-edit",
|
|
4739
5024
|
rowIndex: s,
|
|
@@ -4743,7 +5028,7 @@ function Vi(s, e, t, i) {
|
|
|
4743
5028
|
timestamp: Date.now()
|
|
4744
5029
|
};
|
|
4745
5030
|
}
|
|
4746
|
-
class
|
|
5031
|
+
class bn extends R {
|
|
4747
5032
|
static dependencies = [
|
|
4748
5033
|
{ name: "editing", required: !0, reason: "UndoRedoPlugin tracks cell edit history" }
|
|
4749
5034
|
];
|
|
@@ -4761,7 +5046,7 @@ class cn extends R {
|
|
|
4761
5046
|
onKeyDown(e) {
|
|
4762
5047
|
const t = (e.ctrlKey || e.metaKey) && e.key === "z" && !e.shiftKey, i = (e.ctrlKey || e.metaKey) && (e.key === "y" || e.key === "z" && e.shiftKey);
|
|
4763
5048
|
if (t) {
|
|
4764
|
-
const n =
|
|
5049
|
+
const n = Ge({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4765
5050
|
if (n.action) {
|
|
4766
5051
|
const r = this.rows;
|
|
4767
5052
|
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", {
|
|
@@ -4772,7 +5057,7 @@ class cn extends R {
|
|
|
4772
5057
|
return !0;
|
|
4773
5058
|
}
|
|
4774
5059
|
if (i) {
|
|
4775
|
-
const n =
|
|
5060
|
+
const n = Oe({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4776
5061
|
if (n.action) {
|
|
4777
5062
|
const r = this.rows;
|
|
4778
5063
|
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", {
|
|
@@ -4785,7 +5070,7 @@ class cn extends R {
|
|
|
4785
5070
|
return !1;
|
|
4786
5071
|
}
|
|
4787
5072
|
recordEdit(e, t, i, n) {
|
|
4788
|
-
const r =
|
|
5073
|
+
const r = Zi(e, t, i, n), o = ji(
|
|
4789
5074
|
{ undoStack: this.undoStack, redoStack: this.redoStack },
|
|
4790
5075
|
r,
|
|
4791
5076
|
this.config.maxHistorySize ?? 100
|
|
@@ -4793,7 +5078,7 @@ class cn extends R {
|
|
|
4793
5078
|
this.undoStack = o.undoStack, this.redoStack = o.redoStack;
|
|
4794
5079
|
}
|
|
4795
5080
|
undo() {
|
|
4796
|
-
const e =
|
|
5081
|
+
const e = Ge({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4797
5082
|
if (e.action) {
|
|
4798
5083
|
const t = this.rows;
|
|
4799
5084
|
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();
|
|
@@ -4801,7 +5086,7 @@ class cn extends R {
|
|
|
4801
5086
|
return e.action;
|
|
4802
5087
|
}
|
|
4803
5088
|
redo() {
|
|
4804
|
-
const e =
|
|
5089
|
+
const e = Oe({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4805
5090
|
if (e.action) {
|
|
4806
5091
|
const t = this.rows;
|
|
4807
5092
|
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();
|
|
@@ -4809,13 +5094,13 @@ class cn extends R {
|
|
|
4809
5094
|
return e.action;
|
|
4810
5095
|
}
|
|
4811
5096
|
canUndo() {
|
|
4812
|
-
return
|
|
5097
|
+
return Ui({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4813
5098
|
}
|
|
4814
5099
|
canRedo() {
|
|
4815
|
-
return
|
|
5100
|
+
return Yi({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4816
5101
|
}
|
|
4817
5102
|
clearHistory() {
|
|
4818
|
-
const e =
|
|
5103
|
+
const e = Xi();
|
|
4819
5104
|
this.undoStack = e.undoStack, this.redoStack = e.redoStack;
|
|
4820
5105
|
}
|
|
4821
5106
|
getUndoStack() {
|
|
@@ -4825,18 +5110,18 @@ class cn extends R {
|
|
|
4825
5110
|
return [...this.redoStack];
|
|
4826
5111
|
}
|
|
4827
5112
|
}
|
|
4828
|
-
const
|
|
4829
|
-
function
|
|
5113
|
+
const Ji = '@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))}}';
|
|
5114
|
+
function Be(s) {
|
|
4830
5115
|
const e = s.meta ?? {};
|
|
4831
5116
|
return e.lockPosition !== !0 && e.suppressMovable !== !0;
|
|
4832
5117
|
}
|
|
4833
|
-
class
|
|
5118
|
+
class M extends R {
|
|
4834
5119
|
static dependencies = [
|
|
4835
5120
|
{ name: "reorder", required: !1, reason: "Enables drag-to-reorder columns in visibility panel" }
|
|
4836
5121
|
];
|
|
4837
5122
|
name = "visibility";
|
|
4838
5123
|
static PANEL_ID = "columns";
|
|
4839
|
-
styles =
|
|
5124
|
+
styles = Ji;
|
|
4840
5125
|
get defaultConfig() {
|
|
4841
5126
|
return {
|
|
4842
5127
|
allowHideAll: !1
|
|
@@ -4857,7 +5142,7 @@ class P extends R {
|
|
|
4857
5142
|
}
|
|
4858
5143
|
getToolPanel() {
|
|
4859
5144
|
return {
|
|
4860
|
-
id:
|
|
5145
|
+
id: M.PANEL_ID,
|
|
4861
5146
|
title: "Columns",
|
|
4862
5147
|
icon: "☰",
|
|
4863
5148
|
tooltip: "Column visibility",
|
|
@@ -4866,13 +5151,13 @@ class P extends R {
|
|
|
4866
5151
|
};
|
|
4867
5152
|
}
|
|
4868
5153
|
show() {
|
|
4869
|
-
this.grid.openToolPanel(), this.grid.expandedToolPanelSections.includes(
|
|
5154
|
+
this.grid.openToolPanel(), this.grid.expandedToolPanelSections.includes(M.PANEL_ID) || this.grid.toggleToolPanelSection(M.PANEL_ID);
|
|
4870
5155
|
}
|
|
4871
5156
|
hide() {
|
|
4872
5157
|
this.grid.closeToolPanel();
|
|
4873
5158
|
}
|
|
4874
5159
|
toggle() {
|
|
4875
|
-
this.grid.isToolPanelOpen || this.grid.openToolPanel(), this.grid.toggleToolPanelSection(
|
|
5160
|
+
this.grid.isToolPanelOpen || this.grid.openToolPanel(), this.grid.toggleToolPanelSection(M.PANEL_ID);
|
|
4876
5161
|
}
|
|
4877
5162
|
isColumnVisible(e) {
|
|
4878
5163
|
return this.grid.isColumnVisible(e);
|
|
@@ -4902,7 +5187,7 @@ class P extends R {
|
|
|
4902
5187
|
return this.grid.getAllColumns();
|
|
4903
5188
|
}
|
|
4904
5189
|
isPanelVisible() {
|
|
4905
|
-
return this.grid.isToolPanelOpen && this.grid.expandedToolPanelSections.includes(
|
|
5190
|
+
return this.grid.isToolPanelOpen && this.grid.expandedToolPanelSections.includes(M.PANEL_ID);
|
|
4906
5191
|
}
|
|
4907
5192
|
renderPanelContent(e) {
|
|
4908
5193
|
const t = document.createElement("div");
|
|
@@ -4926,7 +5211,7 @@ class P extends R {
|
|
|
4926
5211
|
const i = this.grid.getAllColumns().filter((n) => !n.utility);
|
|
4927
5212
|
for (let n = 0; n < i.length; n++) {
|
|
4928
5213
|
const r = i[n], o = r.header || r.field, a = document.createElement("div");
|
|
4929
|
-
a.className = r.lockVisible ? "tbw-visibility-row locked" : "tbw-visibility-row", a.setAttribute("data-field", r.field), a.setAttribute("data-index", String(n)), t &&
|
|
5214
|
+
a.className = r.lockVisible ? "tbw-visibility-row locked" : "tbw-visibility-row", a.setAttribute("data-field", r.field), a.setAttribute("data-index", String(n)), t && Be(r) && (a.draggable = !0, a.classList.add("reorderable"), this.setupDragListeners(a, r.field, n, e));
|
|
4930
5215
|
const l = document.createElement("label");
|
|
4931
5216
|
l.className = "tbw-visibility-label";
|
|
4932
5217
|
const d = document.createElement("input");
|
|
@@ -4934,7 +5219,7 @@ class P extends R {
|
|
|
4934
5219
|
this.grid.toggleColumnVisibility(r.field), setTimeout(() => this.rebuildToggles(e), 0);
|
|
4935
5220
|
});
|
|
4936
5221
|
const c = document.createElement("span");
|
|
4937
|
-
if (c.textContent = o, l.appendChild(d), l.appendChild(c), t &&
|
|
5222
|
+
if (c.textContent = o, l.appendChild(d), l.appendChild(c), t && Be(r)) {
|
|
4938
5223
|
const u = document.createElement("span");
|
|
4939
5224
|
u.className = "tbw-visibility-handle", this.setIcon(u, this.resolveIcon("dragHandle")), u.title = "Drag to reorder", a.appendChild(u);
|
|
4940
5225
|
}
|
|
@@ -4961,12 +5246,12 @@ class P extends R {
|
|
|
4961
5246
|
return;
|
|
4962
5247
|
const d = l > a ? l - 1 : l;
|
|
4963
5248
|
if (d !== a) {
|
|
4964
|
-
const c = this.grid.getAllColumns(), h = c.filter((p) => !p.utility)[d]?.field,
|
|
5249
|
+
const c = this.grid.getAllColumns(), h = c.filter((p) => !p.utility)[d]?.field, g = h ? c.findIndex((p) => p.field === h) : c.length, f = {
|
|
4965
5250
|
field: o,
|
|
4966
5251
|
fromIndex: a,
|
|
4967
|
-
toIndex:
|
|
5252
|
+
toIndex: g
|
|
4968
5253
|
};
|
|
4969
|
-
this.emit("column-reorder-request",
|
|
5254
|
+
this.emit("column-reorder-request", f), setTimeout(() => {
|
|
4970
5255
|
this.rebuildToggles(n);
|
|
4971
5256
|
}, 0);
|
|
4972
5257
|
}
|
|
@@ -4975,47 +5260,49 @@ class P extends R {
|
|
|
4975
5260
|
}
|
|
4976
5261
|
export {
|
|
4977
5262
|
R as BaseGridPlugin,
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5263
|
+
en as ClipboardPlugin,
|
|
5264
|
+
tn as ColumnVirtualizationPlugin,
|
|
5265
|
+
nn as ContextMenuPlugin,
|
|
5266
|
+
Cn as DEFAULT_ANIMATION_CONFIG,
|
|
5267
|
+
Ze as DEFAULT_GRID_ICONS,
|
|
5268
|
+
xn as DGEvents,
|
|
5269
|
+
Rn as DataGridElement,
|
|
5270
|
+
rn as EditingPlugin,
|
|
5271
|
+
on as ExportPlugin,
|
|
5272
|
+
T as FilteringPlugin,
|
|
5273
|
+
En as FitModeEnum,
|
|
5274
|
+
Sn as GridCSSVars,
|
|
5275
|
+
kn as GridClasses,
|
|
5276
|
+
An as GridDataAttrs,
|
|
5277
|
+
_n as GridElement,
|
|
5278
|
+
Ln as GridSelectors,
|
|
5279
|
+
sn as GroupingColumnsPlugin,
|
|
5280
|
+
an as GroupingRowsPlugin,
|
|
5281
|
+
$e as MasterDetailPlugin,
|
|
5282
|
+
ln as MultiSortPlugin,
|
|
5283
|
+
Ve as PLUGIN_QUERIES,
|
|
5284
|
+
dn as PinnedColumnsPlugin,
|
|
5285
|
+
cn as PinnedRowsPlugin,
|
|
5286
|
+
D as PivotPlugin,
|
|
5287
|
+
Tn as PluginEvents,
|
|
5288
|
+
In as PluginManager,
|
|
5289
|
+
un as PrintPlugin,
|
|
5290
|
+
Pi as ROW_DRAG_HANDLE_FIELD,
|
|
5291
|
+
Pn as RenderPhase,
|
|
5292
|
+
hn as ReorderPlugin,
|
|
5293
|
+
gn as ResponsivePlugin,
|
|
5294
|
+
fn as RowReorderPlugin,
|
|
5295
|
+
pn as SelectionPlugin,
|
|
5296
|
+
mn as ServerSidePlugin,
|
|
5297
|
+
wn as TreePlugin,
|
|
5298
|
+
bn as UndoRedoPlugin,
|
|
5299
|
+
M as VisibilityPlugin,
|
|
5300
|
+
Fn as builtInSort,
|
|
5301
|
+
Dn as createGrid,
|
|
5302
|
+
Mn as defaultComparator,
|
|
5303
|
+
vt as defaultEditorFor,
|
|
5304
|
+
at as defaultPasteHandler,
|
|
5305
|
+
Si as printGridIsolated,
|
|
5306
|
+
qn as queryGrid
|
|
5020
5307
|
};
|
|
5021
5308
|
//# sourceMappingURL=all.js.map
|