@toolbox-web/grid 0.4.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- package/all.js +1063 -1024
- package/all.js.map +1 -1
- package/index.js +1078 -912
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +28 -0
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/dom-builder.d.ts +2 -0
- package/lib/core/internal/dom-builder.d.ts.map +1 -1
- package/lib/core/internal/event-delegation.d.ts +21 -0
- package/lib/core/internal/event-delegation.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/internal/resize.d.ts.map +1 -1
- package/lib/core/internal/rows.d.ts +1 -1
- package/lib/core/internal/rows.d.ts.map +1 -1
- package/lib/core/internal/shell.d.ts +19 -13
- package/lib/core/internal/shell.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +13 -2
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/plugin/expander-column.d.ts.map +1 -1
- package/lib/core/plugin/plugin-manager.d.ts +6 -2
- package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/core/types.d.ts +41 -3
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +22 -11
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +59 -48
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +71 -60
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +1 -0
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +93 -80
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +29 -18
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +9 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +199 -165
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +1 -0
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/index.js +79 -49
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +98 -87
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +70 -57
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +48 -37
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-columns/index.js +71 -66
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-columns/pinned-columns.d.ts +2 -2
- package/lib/plugins/pinned-columns/pinned-columns.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/index.js +63 -52
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/PivotPlugin.d.ts.map +1 -1
- package/lib/plugins/pivot/index.js +310 -299
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
- package/lib/plugins/reorder/index.d.ts +1 -1
- package/lib/plugins/reorder/index.d.ts.map +1 -1
- package/lib/plugins/reorder/index.js +79 -68
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +115 -105
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +15 -4
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
- package/lib/plugins/tree/index.js +41 -30
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +29 -18
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
- package/lib/plugins/visibility/index.js +59 -47
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +6 -6
- package/public.d.ts +42 -0
- package/public.d.ts.map +1 -1
- package/themes/dg-theme-bootstrap.css +55 -53
- package/themes/dg-theme-contrast.css +42 -40
- package/themes/dg-theme-large.css +38 -37
- package/themes/dg-theme-material.css +54 -52
- package/themes/dg-theme-standard.css +19 -17
- package/themes/dg-theme-vibrant.css +16 -14
- package/umd/grid.all.umd.js +23 -22
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +15 -14
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/column-virtualization.umd.js +1 -1
- package/umd/plugins/column-virtualization.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js +1 -1
- package/umd/plugins/context-menu.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/pinned-columns.umd.js +1 -1
- package/umd/plugins/pinned-columns.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/pivot.umd.js +1 -1
- package/umd/plugins/pivot.umd.js.map +1 -1
- package/umd/plugins/reorder.umd.js +1 -1
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
package/all.js
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import { BaseGridPlugin as x, DEFAULT_GRID_ICONS as $e, runAggregator as
|
|
2
|
-
import { DEFAULT_ANIMATION_CONFIG as oi, DGEvents as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
return s.field ===
|
|
1
|
+
import { BaseGridPlugin as x, DEFAULT_GRID_ICONS as $e, runAggregator as ae, e as je, s as Ue, PLUGIN_QUERIES as He, getAggregator as de, getValueAggregator as Ye, a as Xe, c as ce, g as Ze } from "./index.js";
|
|
2
|
+
import { DEFAULT_ANIMATION_CONFIG as oi, DGEvents as si, DataGridElement as li, FitModeEnum as ai, GridCSSVars as di, GridClasses as ci, GridDataAttrs as ui, DataGridElement as hi, GridSelectors as fi, PluginEvents as gi, PluginManager as pi, RenderPhase as mi, builtInSort as wi, createGrid as bi, defaultComparator as vi, queryGrid as yi } from "./index.js";
|
|
3
|
+
const ze = "__tbw_expander", Je = 32;
|
|
4
|
+
function ne(s) {
|
|
5
|
+
return s.field === ze;
|
|
6
6
|
}
|
|
7
7
|
function _(s) {
|
|
8
8
|
return s.meta?.utility === !0;
|
|
9
9
|
}
|
|
10
10
|
function Qe(s) {
|
|
11
|
-
return s.find(
|
|
11
|
+
return s.find(ne);
|
|
12
12
|
}
|
|
13
13
|
function et(s) {
|
|
14
14
|
return {
|
|
15
|
-
field:
|
|
15
|
+
field: ze,
|
|
16
16
|
header: "",
|
|
17
17
|
// No header text - visually merges with next column
|
|
18
18
|
width: Je,
|
|
19
19
|
resizable: !1,
|
|
20
20
|
sortable: !1,
|
|
21
|
+
filterable: !1,
|
|
22
|
+
// No filter button for expander column
|
|
21
23
|
meta: {
|
|
22
24
|
lockPosition: !0,
|
|
23
25
|
suppressMovable: !0,
|
|
@@ -28,7 +30,7 @@ function et(s) {
|
|
|
28
30
|
}
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
|
-
async function
|
|
33
|
+
async function B(s) {
|
|
32
34
|
try {
|
|
33
35
|
return await navigator.clipboard.writeText(s), !0;
|
|
34
36
|
} catch {
|
|
@@ -42,13 +44,13 @@ function ue(s, e) {
|
|
|
42
44
|
const t = e.delimiter ?? " ", n = e.newline ?? `
|
|
43
45
|
`, i = s.replace(/\r\n/g, `
|
|
44
46
|
`).replace(/\r/g, `
|
|
45
|
-
`),
|
|
46
|
-
let
|
|
47
|
+
`), r = [];
|
|
48
|
+
let o = [], l = "", a = !1;
|
|
47
49
|
for (let d = 0; d < i.length; d++) {
|
|
48
50
|
const c = i[d];
|
|
49
|
-
c === '"' && !a ? a = !0 : c === '"' && a ? i[d + 1] === '"' ? (l += '"', d++) : a = !1 : c === t && !a ? (
|
|
51
|
+
c === '"' && !a ? a = !0 : c === '"' && a ? i[d + 1] === '"' ? (l += '"', d++) : a = !1 : c === t && !a ? (o.push(l), l = "") : c === n && !a ? (o.push(l), l = "", (o.length > 1 || o.some((u) => u.trim() !== "")) && r.push(o), o = []) : l += c;
|
|
50
52
|
}
|
|
51
|
-
return
|
|
53
|
+
return o.push(l), (o.length > 1 || o.some((d) => d.trim() !== "")) && r.push(o), r;
|
|
52
54
|
}
|
|
53
55
|
async function tt() {
|
|
54
56
|
try {
|
|
@@ -60,7 +62,7 @@ async function tt() {
|
|
|
60
62
|
function nt(s, e) {
|
|
61
63
|
const { rows: t, target: n, fields: i } = s;
|
|
62
64
|
if (!n) return;
|
|
63
|
-
const
|
|
65
|
+
const r = e.rows, l = (e.effectiveConfig.columns ?? []).map((c) => c.field), a = [...r], d = n.bounds ? n.bounds.endRow : 1 / 0;
|
|
64
66
|
t.forEach((c, u) => {
|
|
65
67
|
const h = n.row + u;
|
|
66
68
|
if (!(h > d)) {
|
|
@@ -78,7 +80,7 @@ function nt(s, e) {
|
|
|
78
80
|
}
|
|
79
81
|
}), e.rows = a;
|
|
80
82
|
}
|
|
81
|
-
class
|
|
83
|
+
class Nn extends x {
|
|
82
84
|
/**
|
|
83
85
|
* Plugin dependencies - ClipboardPlugin works best with SelectionPlugin.
|
|
84
86
|
*
|
|
@@ -130,30 +132,30 @@ class qn extends x {
|
|
|
130
132
|
* - No selection: try to get focused cell from DOM as 1x1 range
|
|
131
133
|
*/
|
|
132
134
|
#e(e) {
|
|
133
|
-
const t = this.#n(), n = t?.getSelection(), i = this.columns.length - 1,
|
|
134
|
-
let
|
|
135
|
+
const t = this.#n(), n = t?.getSelection(), i = this.columns.length - 1, r = this.rows.length - 1;
|
|
136
|
+
let o;
|
|
135
137
|
if (n && n.ranges.length > 0) {
|
|
136
138
|
const { mode: a, ranges: d } = n, c = d[d.length - 1];
|
|
137
|
-
a === "row" ?
|
|
139
|
+
a === "row" ? o = {
|
|
138
140
|
startRow: c.from.row,
|
|
139
141
|
startCol: 0,
|
|
140
142
|
endRow: c.to.row,
|
|
141
143
|
endCol: i
|
|
142
|
-
} :
|
|
144
|
+
} : o = {
|
|
143
145
|
startRow: c.from.row,
|
|
144
146
|
startCol: c.from.col,
|
|
145
147
|
endRow: c.to.row,
|
|
146
148
|
endCol: c.to.col
|
|
147
149
|
};
|
|
148
150
|
} else if (!t)
|
|
149
|
-
|
|
151
|
+
o = { startRow: 0, startCol: 0, endRow: r, endCol: i };
|
|
150
152
|
else {
|
|
151
153
|
const a = this.#s(e);
|
|
152
154
|
if (!a) return;
|
|
153
|
-
|
|
155
|
+
o = { startRow: a.row, startCol: a.col, endRow: a.row, endCol: a.col };
|
|
154
156
|
}
|
|
155
|
-
const l = this.#i(
|
|
156
|
-
|
|
157
|
+
const l = this.#i(o);
|
|
158
|
+
B(l.text).then(() => {
|
|
157
159
|
this.lastCopied = { text: l.text, timestamp: Date.now() }, this.emit("copy", {
|
|
158
160
|
text: l.text,
|
|
159
161
|
rowCount: l.rowCount,
|
|
@@ -180,13 +182,13 @@ class qn extends x {
|
|
|
180
182
|
const t = e.clipboardData?.getData("text/plain");
|
|
181
183
|
if (!t) return;
|
|
182
184
|
e.preventDefault();
|
|
183
|
-
const n = ue(t, this.config),
|
|
185
|
+
const n = ue(t, this.config), r = this.#n()?.getSelection(), o = r?.ranges?.[0], l = o?.from.row ?? 0, a = 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[a], f = h ? { row: l, col: a, field: h.field, bounds: c } : null, g = [], p = n[0]?.length ?? 0;
|
|
184
186
|
for (let m = 0; m < p && a + m <= u; m++) {
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
+
const b = this.columns[a + m];
|
|
188
|
+
b && !b.hidden && g.push(b.field);
|
|
187
189
|
}
|
|
188
|
-
const
|
|
189
|
-
this.emit("paste",
|
|
190
|
+
const w = { rows: n, text: t, target: f, fields: g };
|
|
191
|
+
this.emit("paste", w), this.#o(w);
|
|
190
192
|
}
|
|
191
193
|
/**
|
|
192
194
|
* Apply the paste handler to update grid data.
|
|
@@ -194,7 +196,7 @@ class qn extends x {
|
|
|
194
196
|
* Uses the configured `pasteHandler`, or the default handler if not specified.
|
|
195
197
|
* Set `pasteHandler: null` in config to disable auto-paste.
|
|
196
198
|
*/
|
|
197
|
-
#
|
|
199
|
+
#o(e) {
|
|
198
200
|
if (!this.grid) return;
|
|
199
201
|
const { pasteHandler: t } = this.config;
|
|
200
202
|
if (t === null) return;
|
|
@@ -216,24 +218,24 @@ class qn extends x {
|
|
|
216
218
|
* Utility columns (like expander columns) are automatically excluded.
|
|
217
219
|
*/
|
|
218
220
|
#i(e) {
|
|
219
|
-
const { startRow: t, startCol: n, endRow: i, endCol:
|
|
221
|
+
const { startRow: t, startCol: n, endRow: i, endCol: r } = e, o = Math.min(t, i), l = Math.max(t, i), a = Math.min(n, r), d = Math.max(n, r), c = this.config.delimiter ?? " ", u = this.config.newline ?? `
|
|
220
222
|
`, h = [], f = this.columns.slice(a, d + 1).filter((g) => !_(g));
|
|
221
223
|
if (this.config.includeHeaders) {
|
|
222
224
|
const g = f.map((p) => p.header || p.field);
|
|
223
225
|
h.push(g.join(c));
|
|
224
226
|
}
|
|
225
|
-
for (let g =
|
|
227
|
+
for (let g = o; g <= l; g++) {
|
|
226
228
|
const p = this.rows[g];
|
|
227
229
|
if (!p) continue;
|
|
228
|
-
const
|
|
229
|
-
const
|
|
230
|
-
return
|
|
230
|
+
const w = f.map((m) => {
|
|
231
|
+
const b = p[m.field];
|
|
232
|
+
return b == null ? "" : b instanceof Date ? b.toISOString() : String(b);
|
|
231
233
|
});
|
|
232
|
-
h.push(
|
|
234
|
+
h.push(w.join(c));
|
|
233
235
|
}
|
|
234
236
|
return {
|
|
235
237
|
text: h.join(u),
|
|
236
|
-
rowCount: l -
|
|
238
|
+
rowCount: l - o + 1,
|
|
237
239
|
columnCount: d - a + 1
|
|
238
240
|
};
|
|
239
241
|
}
|
|
@@ -246,10 +248,10 @@ class qn extends x {
|
|
|
246
248
|
if (!t) return null;
|
|
247
249
|
const n = t.dataset.fieldCache, i = t.dataset.row;
|
|
248
250
|
if (!n || !i) return null;
|
|
249
|
-
const
|
|
250
|
-
if (isNaN(
|
|
251
|
-
const
|
|
252
|
-
return
|
|
251
|
+
const r = parseInt(i, 10);
|
|
252
|
+
if (isNaN(r)) return null;
|
|
253
|
+
const o = this.columns.findIndex((l) => l.field === n);
|
|
254
|
+
return o === -1 ? null : { row: r, col: o };
|
|
253
255
|
}
|
|
254
256
|
// #endregion
|
|
255
257
|
// #region Public API
|
|
@@ -261,16 +263,16 @@ class qn extends x {
|
|
|
261
263
|
const t = this.#n()?.getSelection(), n = this.columns.length - 1;
|
|
262
264
|
let i = { startRow: 0, startCol: 0, endRow: this.rows.length - 1, endCol: n };
|
|
263
265
|
if (t && t.ranges.length > 0) {
|
|
264
|
-
const
|
|
265
|
-
t.mode === "row" ? i = { startRow:
|
|
266
|
-
startRow:
|
|
267
|
-
startCol:
|
|
268
|
-
endRow:
|
|
269
|
-
endCol:
|
|
266
|
+
const o = t.ranges[t.ranges.length - 1];
|
|
267
|
+
t.mode === "row" ? i = { startRow: o.from.row, startCol: 0, endRow: o.to.row, endCol: n } : i = {
|
|
268
|
+
startRow: o.from.row,
|
|
269
|
+
startCol: o.from.col,
|
|
270
|
+
endRow: o.to.row,
|
|
271
|
+
endCol: o.to.col
|
|
270
272
|
};
|
|
271
273
|
}
|
|
272
|
-
const
|
|
273
|
-
return await
|
|
274
|
+
const r = this.#i(i);
|
|
275
|
+
return await B(r.text), this.lastCopied = { text: r.text, timestamp: Date.now() }, r.text;
|
|
274
276
|
}
|
|
275
277
|
/**
|
|
276
278
|
* Copy specific rows by index to clipboard.
|
|
@@ -279,13 +281,13 @@ class qn extends x {
|
|
|
279
281
|
*/
|
|
280
282
|
async copyRows(e) {
|
|
281
283
|
if (e.length === 0) return "";
|
|
282
|
-
const t = [...e].sort((
|
|
284
|
+
const t = [...e].sort((o, l) => o - l), n = this.columns.length - 1, i = {
|
|
283
285
|
startRow: t[0],
|
|
284
286
|
startCol: 0,
|
|
285
287
|
endRow: t[t.length - 1],
|
|
286
288
|
endCol: n
|
|
287
|
-
},
|
|
288
|
-
return await
|
|
289
|
+
}, r = this.#i(i);
|
|
290
|
+
return await B(r.text), this.lastCopied = { text: r.text, timestamp: Date.now() }, r.text;
|
|
289
291
|
}
|
|
290
292
|
/**
|
|
291
293
|
* Read and parse clipboard content.
|
|
@@ -305,7 +307,7 @@ class qn extends x {
|
|
|
305
307
|
// #endregion
|
|
306
308
|
}
|
|
307
309
|
const he = 100;
|
|
308
|
-
function
|
|
310
|
+
function ie(s) {
|
|
309
311
|
if (s == null)
|
|
310
312
|
return he;
|
|
311
313
|
if (typeof s == "number")
|
|
@@ -314,51 +316,51 @@ function oe(s) {
|
|
|
314
316
|
return isNaN(e) ? he : e;
|
|
315
317
|
}
|
|
316
318
|
function fe(s) {
|
|
317
|
-
return s.map((e) =>
|
|
319
|
+
return s.map((e) => ie(e.width));
|
|
318
320
|
}
|
|
319
321
|
function ge(s) {
|
|
320
322
|
const e = [];
|
|
321
323
|
let t = 0;
|
|
322
324
|
for (const n of s)
|
|
323
|
-
e.push(t), t +=
|
|
325
|
+
e.push(t), t += ie(n.width);
|
|
324
326
|
return e;
|
|
325
327
|
}
|
|
326
328
|
function pe(s) {
|
|
327
|
-
return s.reduce((e, t) => e +
|
|
329
|
+
return s.reduce((e, t) => e + ie(t.width), 0);
|
|
328
330
|
}
|
|
329
331
|
function it(s, e, t, n, i) {
|
|
330
|
-
const
|
|
331
|
-
if (
|
|
332
|
+
const r = t.length;
|
|
333
|
+
if (r === 0)
|
|
332
334
|
return { startCol: 0, endCol: 0, visibleColumns: [] };
|
|
333
|
-
let
|
|
334
|
-
|
|
335
|
+
let o = rt(s, t, n);
|
|
336
|
+
o = Math.max(0, o - i);
|
|
335
337
|
const l = s + e;
|
|
336
|
-
let a =
|
|
337
|
-
for (let c =
|
|
338
|
+
let a = o;
|
|
339
|
+
for (let c = o; c < r; c++) {
|
|
338
340
|
if (t[c] >= l) {
|
|
339
341
|
a = c - 1;
|
|
340
342
|
break;
|
|
341
343
|
}
|
|
342
344
|
a = c;
|
|
343
345
|
}
|
|
344
|
-
a = Math.min(
|
|
346
|
+
a = Math.min(r - 1, a + i);
|
|
345
347
|
const d = [];
|
|
346
|
-
for (let c =
|
|
348
|
+
for (let c = o; c <= a; c++)
|
|
347
349
|
d.push(c);
|
|
348
|
-
return { startCol:
|
|
350
|
+
return { startCol: o, endCol: a, visibleColumns: d };
|
|
349
351
|
}
|
|
350
|
-
function
|
|
352
|
+
function rt(s, e, t) {
|
|
351
353
|
let n = 0, i = e.length - 1;
|
|
352
354
|
for (; n < i; ) {
|
|
353
|
-
const
|
|
354
|
-
e[
|
|
355
|
+
const r = Math.floor((n + i) / 2);
|
|
356
|
+
e[r] + t[r] <= s ? n = r + 1 : i = r;
|
|
355
357
|
}
|
|
356
358
|
return n;
|
|
357
359
|
}
|
|
358
|
-
function
|
|
360
|
+
function ot(s, e, t) {
|
|
359
361
|
return t ? s > e : !1;
|
|
360
362
|
}
|
|
361
|
-
class
|
|
363
|
+
class Hn extends x {
|
|
362
364
|
name = "columnVirtualization";
|
|
363
365
|
get defaultConfig() {
|
|
364
366
|
return {
|
|
@@ -388,7 +390,7 @@ class Nn extends x {
|
|
|
388
390
|
// #endregion
|
|
389
391
|
// #region Hooks
|
|
390
392
|
processColumns(e) {
|
|
391
|
-
const t =
|
|
393
|
+
const t = ot(e.length, this.config.threshold ?? 30, this.config.autoEnable ?? !0);
|
|
392
394
|
if (this.isVirtualized = t ?? !1, this.columnWidths = fe(e), this.columnOffsets = ge(e), this.totalWidth = pe(e), !t)
|
|
393
395
|
return this.startCol = 0, this.endCol = e.length - 1, [...e];
|
|
394
396
|
const n = this.grid.clientWidth || 800, i = it(
|
|
@@ -398,18 +400,18 @@ class Nn extends x {
|
|
|
398
400
|
this.columnWidths,
|
|
399
401
|
this.config.overscan ?? 3
|
|
400
402
|
);
|
|
401
|
-
return this.startCol = i.startCol, this.endCol = i.endCol, i.visibleColumns.map((
|
|
403
|
+
return this.startCol = i.startCol, this.endCol = i.endCol, i.visibleColumns.map((r) => e[r]);
|
|
402
404
|
}
|
|
403
405
|
afterRender() {
|
|
404
406
|
if (!this.isVirtualized) return;
|
|
405
|
-
const e = this.
|
|
407
|
+
const e = this.gridElement;
|
|
406
408
|
if (!e) return;
|
|
407
409
|
const t = this.columnOffsets[this.startCol] ?? 0, n = e.querySelector(".header-row"), i = e.querySelectorAll(".data-grid-row");
|
|
408
|
-
n && (n.style.paddingLeft = `${t}px`), i.forEach((
|
|
409
|
-
|
|
410
|
+
n && (n.style.paddingLeft = `${t}px`), i.forEach((o) => {
|
|
411
|
+
o.style.paddingLeft = `${t}px`;
|
|
410
412
|
});
|
|
411
|
-
const
|
|
412
|
-
|
|
413
|
+
const r = e.querySelector(".rows-viewport .rows");
|
|
414
|
+
r && (r.style.width = `${this.totalWidth}px`);
|
|
413
415
|
}
|
|
414
416
|
onScroll(e) {
|
|
415
417
|
!this.isVirtualized || Math.abs(e.scrollLeft - this.scrollLeft) < 1 || (this.scrollLeft = e.scrollLeft, this.requestRender());
|
|
@@ -451,59 +453,59 @@ class Nn extends x {
|
|
|
451
453
|
}
|
|
452
454
|
// #endregion
|
|
453
455
|
}
|
|
454
|
-
const
|
|
455
|
-
function
|
|
456
|
+
const V = "@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}}";
|
|
457
|
+
function Q(s, e) {
|
|
456
458
|
return (typeof s == "function" ? s(e) : s).filter((n) => !(n.hidden === !0 || typeof n.hidden == "function" && n.hidden(e)));
|
|
457
459
|
}
|
|
458
460
|
function st(s, e) {
|
|
459
461
|
return s.disabled === !0 ? !0 : typeof s.disabled == "function" ? s.disabled(e) : !1;
|
|
460
462
|
}
|
|
461
|
-
function
|
|
463
|
+
function ee(s, e, t, n = $e.submenuArrow) {
|
|
462
464
|
const i = document.createElement("div");
|
|
463
465
|
i.className = "tbw-context-menu", i.setAttribute("role", "menu");
|
|
464
|
-
for (const
|
|
465
|
-
if (
|
|
466
|
+
for (const r of s) {
|
|
467
|
+
if (r.separator) {
|
|
466
468
|
const d = document.createElement("div");
|
|
467
469
|
d.className = "tbw-context-menu-separator", d.setAttribute("role", "separator"), i.appendChild(d);
|
|
468
470
|
continue;
|
|
469
471
|
}
|
|
470
|
-
const
|
|
471
|
-
|
|
472
|
-
const l = st(
|
|
473
|
-
if (l && (
|
|
472
|
+
const o = document.createElement("div");
|
|
473
|
+
o.className = "tbw-context-menu-item", r.cssClass && o.classList.add(r.cssClass), o.setAttribute("role", "menuitem"), o.setAttribute("data-id", r.id);
|
|
474
|
+
const l = st(r, e);
|
|
475
|
+
if (l && (o.classList.add("disabled"), o.setAttribute("aria-disabled", "true")), r.icon) {
|
|
474
476
|
const d = document.createElement("span");
|
|
475
|
-
d.className = "tbw-context-menu-icon", d.innerHTML =
|
|
477
|
+
d.className = "tbw-context-menu-icon", d.innerHTML = r.icon, o.appendChild(d);
|
|
476
478
|
}
|
|
477
479
|
const a = document.createElement("span");
|
|
478
|
-
if (a.className = "tbw-context-menu-label", a.textContent =
|
|
480
|
+
if (a.className = "tbw-context-menu-label", a.textContent = r.name, o.appendChild(a), r.shortcut) {
|
|
479
481
|
const d = document.createElement("span");
|
|
480
|
-
d.className = "tbw-context-menu-shortcut", d.textContent =
|
|
482
|
+
d.className = "tbw-context-menu-shortcut", d.textContent = r.shortcut, o.appendChild(d);
|
|
481
483
|
}
|
|
482
|
-
if (
|
|
484
|
+
if (r.subMenu?.length) {
|
|
483
485
|
const d = document.createElement("span");
|
|
484
|
-
d.className = "tbw-context-menu-arrow", typeof n == "string" ? d.innerHTML = n : n instanceof HTMLElement && d.appendChild(n.cloneNode(!0)),
|
|
485
|
-
if (
|
|
486
|
-
const u =
|
|
487
|
-
h.classList.add("tbw-context-submenu"), h.style.position = "absolute", h.style.left = "100%", h.style.top = "0",
|
|
488
|
-
}),
|
|
489
|
-
const c =
|
|
486
|
+
d.className = "tbw-context-menu-arrow", typeof n == "string" ? d.innerHTML = n : n instanceof HTMLElement && d.appendChild(n.cloneNode(!0)), o.appendChild(d), o.addEventListener("mouseenter", () => {
|
|
487
|
+
if (o.querySelector(".tbw-context-menu") || !r.subMenu) return;
|
|
488
|
+
const u = Q(r.subMenu, e), h = ee(u, e, t, n);
|
|
489
|
+
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);
|
|
490
|
+
}), o.addEventListener("mouseleave", () => {
|
|
491
|
+
const c = o.querySelector(".tbw-context-menu");
|
|
490
492
|
c && c.remove();
|
|
491
493
|
});
|
|
492
494
|
}
|
|
493
|
-
!l &&
|
|
494
|
-
d.stopPropagation(), t(
|
|
495
|
-
}), i.appendChild(
|
|
495
|
+
!l && r.action && !r.subMenu && o.addEventListener("click", (d) => {
|
|
496
|
+
d.stopPropagation(), t(r);
|
|
497
|
+
}), i.appendChild(o);
|
|
496
498
|
}
|
|
497
499
|
return i;
|
|
498
500
|
}
|
|
499
501
|
function me(s, e, t) {
|
|
500
502
|
s.style.position = "fixed", s.style.left = `${e}px`, s.style.top = `${t}px`, s.style.visibility = "hidden", s.style.zIndex = "10000";
|
|
501
|
-
const n = s.getBoundingClientRect(), i = window.innerWidth,
|
|
502
|
-
let
|
|
503
|
-
e + n.width > i && (
|
|
503
|
+
const n = s.getBoundingClientRect(), i = window.innerWidth, r = window.innerHeight;
|
|
504
|
+
let o = e, l = t;
|
|
505
|
+
e + n.width > i && (o = e - n.width), t + n.height > r && (l = t - n.height), o = Math.max(0, o), l = Math.max(0, l), s.style.left = `${o}px`, s.style.top = `${l}px`, s.style.visibility = "visible";
|
|
504
506
|
}
|
|
505
|
-
let T = null, I = null,
|
|
506
|
-
const
|
|
507
|
+
let T = null, I = null, A = null, W = 0;
|
|
508
|
+
const $ = [
|
|
507
509
|
{
|
|
508
510
|
id: "copy",
|
|
509
511
|
name: "Copy",
|
|
@@ -521,11 +523,11 @@ const j = [
|
|
|
521
523
|
}
|
|
522
524
|
}
|
|
523
525
|
];
|
|
524
|
-
class
|
|
526
|
+
class zn extends x {
|
|
525
527
|
name = "contextMenu";
|
|
526
528
|
get defaultConfig() {
|
|
527
529
|
return {
|
|
528
|
-
items:
|
|
530
|
+
items: $
|
|
529
531
|
};
|
|
530
532
|
}
|
|
531
533
|
// #region Internal State
|
|
@@ -536,7 +538,7 @@ class Hn extends x {
|
|
|
536
538
|
// #endregion
|
|
537
539
|
// #region Lifecycle
|
|
538
540
|
attach(e) {
|
|
539
|
-
super.attach(e), this.installGlobalHandlers(),
|
|
541
|
+
super.attach(e), this.installGlobalHandlers(), W++;
|
|
540
542
|
}
|
|
541
543
|
detach() {
|
|
542
544
|
this.menuElement && (this.menuElement.remove(), this.menuElement = null), this.isOpen = !1, this.params = null, this.uninstallGlobalHandlers();
|
|
@@ -544,7 +546,7 @@ class Hn extends x {
|
|
|
544
546
|
// #endregion
|
|
545
547
|
// #region Private Methods
|
|
546
548
|
installGlobalHandlers() {
|
|
547
|
-
!
|
|
549
|
+
!A && typeof document < "u" && typeof V == "string" && V && (A = document.createElement("style"), A.id = "tbw-context-menu-styles", A.textContent = V, document.head.appendChild(A)), T || (T = () => {
|
|
548
550
|
document.querySelectorAll(".tbw-context-menu").forEach((t) => t.remove());
|
|
549
551
|
}, document.addEventListener("click", T)), I || (I = (e) => {
|
|
550
552
|
e.key === "Escape" && document.querySelectorAll(".tbw-context-menu").forEach((n) => n.remove());
|
|
@@ -555,21 +557,21 @@ class Hn extends x {
|
|
|
555
557
|
* Uses reference counting to ensure handlers persist while any grid uses the plugin.
|
|
556
558
|
*/
|
|
557
559
|
uninstallGlobalHandlers() {
|
|
558
|
-
|
|
560
|
+
W--, !(W > 0) && (T && (document.removeEventListener("click", T), T = null), I && (document.removeEventListener("keydown", I), I = null), A && (A.remove(), A = null));
|
|
559
561
|
}
|
|
560
562
|
// #endregion
|
|
561
563
|
// #region Hooks
|
|
562
564
|
afterRender() {
|
|
563
|
-
const e = this.
|
|
565
|
+
const e = this.gridElement;
|
|
564
566
|
if (!e) return;
|
|
565
567
|
const t = e.children[0];
|
|
566
568
|
t && t.getAttribute("data-context-menu-bound") !== "true" && (t.setAttribute("data-context-menu-bound", "true"), t.addEventListener("contextmenu", (n) => {
|
|
567
569
|
const i = n;
|
|
568
570
|
i.preventDefault();
|
|
569
|
-
const
|
|
571
|
+
const r = i.target, o = r.closest("[data-row][data-col]"), l = r.closest(".header-cell");
|
|
570
572
|
let a;
|
|
571
|
-
if (
|
|
572
|
-
const c = parseInt(
|
|
573
|
+
if (o) {
|
|
574
|
+
const c = parseInt(o.getAttribute("data-row") ?? "-1", 10), u = parseInt(o.getAttribute("data-col") ?? "-1", 10), h = this.columns[u], f = this.rows[c];
|
|
573
575
|
a = {
|
|
574
576
|
row: f,
|
|
575
577
|
rowIndex: c,
|
|
@@ -595,8 +597,8 @@ class Hn extends x {
|
|
|
595
597
|
} else
|
|
596
598
|
return;
|
|
597
599
|
this.params = a, this.position = { x: i.clientX, y: i.clientY };
|
|
598
|
-
const d =
|
|
599
|
-
d.length && (this.menuElement && this.menuElement.remove(), this.menuElement =
|
|
600
|
+
const d = Q(this.config.items ?? $, a);
|
|
601
|
+
d.length && (this.menuElement && this.menuElement.remove(), this.menuElement = ee(
|
|
600
602
|
d,
|
|
601
603
|
a,
|
|
602
604
|
(c) => {
|
|
@@ -624,12 +626,12 @@ class Hn extends x {
|
|
|
624
626
|
value: n.value ?? null,
|
|
625
627
|
isHeader: n.isHeader ?? !1,
|
|
626
628
|
event: n.event ?? new MouseEvent("contextmenu")
|
|
627
|
-
},
|
|
628
|
-
this.menuElement && this.menuElement.remove(), this.menuElement =
|
|
629
|
-
|
|
629
|
+
}, r = Q(this.config.items ?? $, i);
|
|
630
|
+
this.menuElement && this.menuElement.remove(), this.menuElement = ee(
|
|
631
|
+
r,
|
|
630
632
|
i,
|
|
631
|
-
(
|
|
632
|
-
|
|
633
|
+
(o) => {
|
|
634
|
+
o.action && o.action(i), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
|
|
633
635
|
},
|
|
634
636
|
this.gridIcons.submenuArrow
|
|
635
637
|
), document.body.appendChild(this.menuElement), me(this.menuElement, e, t), this.isOpen = !0;
|
|
@@ -650,7 +652,8 @@ class Hn extends x {
|
|
|
650
652
|
// #endregion
|
|
651
653
|
// Styles are injected globally via installGlobalHandlers() since menu renders in document.body
|
|
652
654
|
}
|
|
653
|
-
|
|
655
|
+
const lt = "@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}}}";
|
|
656
|
+
function at(s) {
|
|
654
657
|
switch (s.type) {
|
|
655
658
|
case "number":
|
|
656
659
|
return (e) => {
|
|
@@ -681,7 +684,7 @@ function lt(s) {
|
|
|
681
684
|
const a = document.createElement("option");
|
|
682
685
|
a.value = String(l.value), a.textContent = l.label, (n.multi && Array.isArray(e.value) && e.value.includes(l.value) || !n.multi && e.value === l.value) && (a.selected = !0), t.appendChild(a);
|
|
683
686
|
});
|
|
684
|
-
const
|
|
687
|
+
const o = () => {
|
|
685
688
|
if (n.multi) {
|
|
686
689
|
const l = [];
|
|
687
690
|
Array.from(t.selectedOptions).forEach((a) => {
|
|
@@ -690,7 +693,7 @@ function lt(s) {
|
|
|
690
693
|
} else
|
|
691
694
|
e.commit(t.value);
|
|
692
695
|
};
|
|
693
|
-
return t.addEventListener("change",
|
|
696
|
+
return t.addEventListener("change", o), t.addEventListener("blur", o), t.addEventListener("keydown", (l) => {
|
|
694
697
|
l.key === "Escape" && e.cancel();
|
|
695
698
|
}), t;
|
|
696
699
|
};
|
|
@@ -703,31 +706,32 @@ function lt(s) {
|
|
|
703
706
|
};
|
|
704
707
|
}
|
|
705
708
|
}
|
|
706
|
-
const
|
|
709
|
+
const j = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';
|
|
707
710
|
function P(s) {
|
|
708
711
|
return !(typeof s != "string" || s === "__proto__" || s === "constructor" || s === "prototype");
|
|
709
712
|
}
|
|
710
|
-
function
|
|
713
|
+
function Gn(s) {
|
|
711
714
|
return (s.__editingCellCount ?? 0) > 0;
|
|
712
715
|
}
|
|
713
|
-
function
|
|
716
|
+
function dt(s) {
|
|
714
717
|
const e = (s.__editingCellCount ?? 0) + 1;
|
|
715
718
|
s.__editingCellCount = e, s.setAttribute("data-has-editing", "");
|
|
716
719
|
}
|
|
717
|
-
function
|
|
720
|
+
function ct(s) {
|
|
718
721
|
s.__editingCellCount = 0, s.removeAttribute("data-has-editing");
|
|
719
722
|
}
|
|
720
723
|
function K(s, e) {
|
|
721
724
|
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;
|
|
722
725
|
}
|
|
723
|
-
function
|
|
726
|
+
function ut(s, e, t) {
|
|
724
727
|
const n = s.querySelector("input,textarea,select");
|
|
725
728
|
n && (n.addEventListener("blur", () => {
|
|
726
729
|
t(K(n, e));
|
|
727
730
|
}), n instanceof HTMLInputElement && n.type === "checkbox" ? n.addEventListener("change", () => t(n.checked)) : n instanceof HTMLSelectElement && n.addEventListener("change", () => t(K(n, e))));
|
|
728
731
|
}
|
|
729
|
-
class
|
|
732
|
+
class On extends x {
|
|
730
733
|
name = "editing";
|
|
734
|
+
styles = lt;
|
|
731
735
|
get defaultConfig() {
|
|
732
736
|
return {
|
|
733
737
|
editOn: "click"
|
|
@@ -739,7 +743,7 @@ class Gn extends x {
|
|
|
739
743
|
/** Currently active edit column index, or -1 if not editing */
|
|
740
744
|
#t = -1;
|
|
741
745
|
/** Snapshots of row data before editing started */
|
|
742
|
-
#
|
|
746
|
+
#o = /* @__PURE__ */ new Map();
|
|
743
747
|
/** Set of row indices that have been modified */
|
|
744
748
|
#n = /* @__PURE__ */ new Set();
|
|
745
749
|
/** Set of cells currently in edit mode: "rowIndex:colIndex" */
|
|
@@ -757,26 +761,26 @@ class Gn extends x {
|
|
|
757
761
|
}), Object.defineProperty(e, "changedRowIndices", {
|
|
758
762
|
get: () => this.changedRowIndices,
|
|
759
763
|
configurable: !0
|
|
760
|
-
}), e.resetChangedRows = (i) => this.resetChangedRows(i), e.beginBulkEdit = (i,
|
|
761
|
-
|
|
764
|
+
}), e.resetChangedRows = (i) => this.resetChangedRows(i), e.beginBulkEdit = (i, r) => {
|
|
765
|
+
r && this.beginCellEdit(i, r);
|
|
762
766
|
}, document.addEventListener(
|
|
763
767
|
"keydown",
|
|
764
768
|
(i) => {
|
|
765
|
-
i.key === "Escape" && this.#e !== -1 && this.#
|
|
769
|
+
i.key === "Escape" && this.#e !== -1 && this.#r(this.#e, !0);
|
|
766
770
|
},
|
|
767
771
|
{ capture: !0, signal: t }
|
|
768
772
|
), document.addEventListener(
|
|
769
773
|
"mousedown",
|
|
770
774
|
(i) => {
|
|
771
775
|
if (this.#e === -1) return;
|
|
772
|
-
const
|
|
773
|
-
!
|
|
776
|
+
const r = n.findRenderedRowElement?.(this.#e);
|
|
777
|
+
!r || (i.composedPath && i.composedPath() || []).includes(r) || this.#r(this.#e, !1);
|
|
774
778
|
},
|
|
775
779
|
{ signal: t }
|
|
776
780
|
);
|
|
777
781
|
}
|
|
778
782
|
detach() {
|
|
779
|
-
this.#e = -1, this.#t = -1, this.#
|
|
783
|
+
this.#e = -1, this.#t = -1, this.#o.clear(), this.#n.clear(), this.#i.clear(), super.detach();
|
|
780
784
|
}
|
|
781
785
|
// #endregion
|
|
782
786
|
// #region Event Handlers (event distribution)
|
|
@@ -790,8 +794,8 @@ class Gn extends x {
|
|
|
790
794
|
if (n === !1 || n === "manual" || n !== "click" && n !== "dblclick") return !1;
|
|
791
795
|
const i = e.originalEvent.type === "dblclick";
|
|
792
796
|
if (n === "click" && i || n === "dblclick" && !i) return !1;
|
|
793
|
-
const { rowIndex:
|
|
794
|
-
return t._columns?.some((l) => l.editable) ? (e.originalEvent.stopPropagation(), this.beginBulkEdit(
|
|
797
|
+
const { rowIndex: r } = e;
|
|
798
|
+
return t._columns?.some((l) => l.editable) ? (e.originalEvent.stopPropagation(), this.beginBulkEdit(r), !0) : !1;
|
|
795
799
|
}
|
|
796
800
|
/**
|
|
797
801
|
* Handle keyboard events for edit lifecycle.
|
|
@@ -799,16 +803,16 @@ class Gn extends x {
|
|
|
799
803
|
onKeyDown(e) {
|
|
800
804
|
const t = this.grid;
|
|
801
805
|
if (e.key === "Escape" && this.#e !== -1)
|
|
802
|
-
return this.#
|
|
806
|
+
return this.#r(this.#e, !0), !0;
|
|
803
807
|
if (e.key === " " || e.key === "Spacebar") {
|
|
804
808
|
const n = t._focusRow, i = t._focusCol;
|
|
805
809
|
if (n >= 0 && i >= 0) {
|
|
806
|
-
const
|
|
807
|
-
if (
|
|
808
|
-
const l =
|
|
810
|
+
const r = t._visibleColumns[i], o = t._rows[n];
|
|
811
|
+
if (r?.editable && r.type === "boolean" && o) {
|
|
812
|
+
const l = r.field;
|
|
809
813
|
if (P(l)) {
|
|
810
|
-
const d = !
|
|
811
|
-
return this.#a(n,
|
|
814
|
+
const d = !o[l];
|
|
815
|
+
return this.#a(n, r, d, o), e.preventDefault(), this.requestRender(), !0;
|
|
812
816
|
}
|
|
813
817
|
}
|
|
814
818
|
}
|
|
@@ -820,7 +824,7 @@ class Gn extends x {
|
|
|
820
824
|
const n = this.config.editOn ?? t.effectiveConfig?.editOn;
|
|
821
825
|
if (n === !1 || n === "manual") return !1;
|
|
822
826
|
const i = t._focusRow;
|
|
823
|
-
return i >= 0 && t._columns?.some((
|
|
827
|
+
return i >= 0 && t._columns?.some((o) => o.editable) ? (this.beginBulkEdit(i), !0) : !1;
|
|
824
828
|
}
|
|
825
829
|
return !1;
|
|
826
830
|
}
|
|
@@ -835,12 +839,12 @@ class Gn extends x {
|
|
|
835
839
|
const e = this.grid;
|
|
836
840
|
if (this.#s && (this.#s = !1, this.#u(e)), this.#i.size !== 0)
|
|
837
841
|
for (const t of this.#i) {
|
|
838
|
-
const [n, i] = t.split(":"),
|
|
842
|
+
const [n, i] = t.split(":"), r = parseInt(n, 10), o = parseInt(i, 10), l = e.findRenderedRowElement?.(r);
|
|
839
843
|
if (!l) continue;
|
|
840
|
-
const a = l.querySelector(`.cell[data-col="${
|
|
844
|
+
const a = l.querySelector(`.cell[data-col="${o}"]`);
|
|
841
845
|
if (!a || a.classList.contains("editing")) continue;
|
|
842
|
-
const d = e._rows[
|
|
843
|
-
d && c && this.#d(d,
|
|
846
|
+
const d = e._rows[r], c = e._visibleColumns[o];
|
|
847
|
+
d && c && this.#d(d, r, c, o, a, !0);
|
|
844
848
|
}
|
|
845
849
|
}
|
|
846
850
|
/**
|
|
@@ -899,7 +903,7 @@ class Gn extends x {
|
|
|
899
903
|
*/
|
|
900
904
|
resetChangedRows(e) {
|
|
901
905
|
const t = this.changedRows, n = this.changedRowIndices;
|
|
902
|
-
this.#n.clear(), this.#l(), e || this.emit("changed-rows-reset", { rows: t, indices: n }), this.grid._rowPool?.forEach((
|
|
906
|
+
this.#n.clear(), this.#l(), e || this.emit("changed-rows-reset", { rows: t, indices: n }), this.grid._rowPool?.forEach((r) => r.classList.remove("changed"));
|
|
903
907
|
}
|
|
904
908
|
/**
|
|
905
909
|
* Programmatically begin editing a cell.
|
|
@@ -916,19 +920,19 @@ class Gn extends x {
|
|
|
916
920
|
beginBulkEdit(e) {
|
|
917
921
|
const t = this.grid;
|
|
918
922
|
if ((this.config.editOn ?? t.effectiveConfig?.editOn) === !1 || !t._columns?.some((l) => l.editable)) return;
|
|
919
|
-
const
|
|
920
|
-
if (!
|
|
921
|
-
const
|
|
922
|
-
this.#c(e,
|
|
923
|
+
const r = t.findRenderedRowElement?.(e);
|
|
924
|
+
if (!r) return;
|
|
925
|
+
const o = t._rows[e];
|
|
926
|
+
this.#c(e, o), Array.from(r.children).forEach((l, a) => {
|
|
923
927
|
const d = t._visibleColumns[a];
|
|
924
928
|
if (d?.editable) {
|
|
925
929
|
const c = l;
|
|
926
|
-
c.classList.contains("editing") || this.#d(
|
|
930
|
+
c.classList.contains("editing") || this.#d(o, e, d, a, c, !0);
|
|
927
931
|
}
|
|
928
932
|
}), setTimeout(() => {
|
|
929
|
-
let l =
|
|
930
|
-
if (l?.classList.contains("editing") || (l =
|
|
931
|
-
const a = l.querySelector(
|
|
933
|
+
let l = r.querySelector(`.cell[data-col="${t._focusCol}"]`);
|
|
934
|
+
if (l?.classList.contains("editing") || (l = r.querySelector(".cell.editing")), l?.classList.contains("editing")) {
|
|
935
|
+
const a = l.querySelector(j);
|
|
932
936
|
try {
|
|
933
937
|
a?.focus({ preventScroll: !0 });
|
|
934
938
|
} catch {
|
|
@@ -940,13 +944,13 @@ class Gn extends x {
|
|
|
940
944
|
* Commit the currently active row edit.
|
|
941
945
|
*/
|
|
942
946
|
commitActiveRowEdit() {
|
|
943
|
-
this.#e !== -1 && this.#
|
|
947
|
+
this.#e !== -1 && this.#r(this.#e, !1);
|
|
944
948
|
}
|
|
945
949
|
/**
|
|
946
950
|
* Cancel the currently active row edit.
|
|
947
951
|
*/
|
|
948
952
|
cancelActiveRowEdit() {
|
|
949
|
-
this.#e !== -1 && this.#
|
|
953
|
+
this.#e !== -1 && this.#r(this.#e, !0);
|
|
950
954
|
}
|
|
951
955
|
// #endregion
|
|
952
956
|
// #region Internal Methods
|
|
@@ -954,29 +958,29 @@ class Gn extends x {
|
|
|
954
958
|
* Begin editing a single cell.
|
|
955
959
|
*/
|
|
956
960
|
#h(e, t, n) {
|
|
957
|
-
const i = this.grid,
|
|
958
|
-
!
|
|
961
|
+
const i = this.grid, r = i._rows[e], o = i._visibleColumns[t];
|
|
962
|
+
!r || !o?.editable || n.classList.contains("editing") || (this.#e !== e && this.#c(e, r), this.#t = t, this.#d(r, e, o, t, n, !1));
|
|
959
963
|
}
|
|
960
964
|
/**
|
|
961
965
|
* Sync the internal grid state with the plugin's editing state.
|
|
962
966
|
*/
|
|
963
967
|
#l() {
|
|
964
968
|
const e = this.grid;
|
|
965
|
-
e._activeEditRows = this.#e, e._rowEditSnapshots = this.#
|
|
969
|
+
e._activeEditRows = this.#e, e._rowEditSnapshots = this.#o, e._changedRowIndices = this.#n;
|
|
966
970
|
}
|
|
967
971
|
/**
|
|
968
972
|
* Snapshot original row data and mark as editing.
|
|
969
973
|
*/
|
|
970
974
|
#c(e, t) {
|
|
971
|
-
this.#e !== e && (this.#
|
|
975
|
+
this.#e !== e && (this.#o.set(e, { ...t }), this.#e = e, this.#l());
|
|
972
976
|
}
|
|
973
977
|
/**
|
|
974
978
|
* Exit editing for a row.
|
|
975
979
|
*/
|
|
976
|
-
#
|
|
980
|
+
#r(e, t) {
|
|
977
981
|
if (this.#e !== e) return;
|
|
978
|
-
const n = this.grid, i = this.#
|
|
979
|
-
if (!t &&
|
|
982
|
+
const n = this.grid, i = this.#o.get(e), r = n._rows[e], o = n.findRenderedRowElement?.(e);
|
|
983
|
+
if (!t && o && r && o.querySelectorAll(".cell.editing").forEach((a) => {
|
|
980
984
|
const d = Number(a.getAttribute("data-col"));
|
|
981
985
|
if (isNaN(d)) return;
|
|
982
986
|
const c = n._visibleColumns[d];
|
|
@@ -984,103 +988,103 @@ class Gn extends x {
|
|
|
984
988
|
const u = a.querySelector("input,textarea,select");
|
|
985
989
|
if (u) {
|
|
986
990
|
const h = K(u, c);
|
|
987
|
-
|
|
991
|
+
r[c.field] !== h && this.#a(e, c, h, r);
|
|
988
992
|
}
|
|
989
|
-
}), t && i &&
|
|
993
|
+
}), t && i && r)
|
|
990
994
|
Object.keys(i).forEach((l) => {
|
|
991
|
-
|
|
995
|
+
r[l] = i[l];
|
|
992
996
|
}), this.#n.delete(e);
|
|
993
997
|
else if (!t) {
|
|
994
998
|
const l = this.#n.has(e);
|
|
995
999
|
this.emit("row-commit", {
|
|
996
1000
|
rowIndex: e,
|
|
997
|
-
row:
|
|
1001
|
+
row: r,
|
|
998
1002
|
changed: l,
|
|
999
1003
|
changedRows: this.changedRows,
|
|
1000
1004
|
changedRowIndices: this.changedRowIndices
|
|
1001
1005
|
});
|
|
1002
1006
|
}
|
|
1003
|
-
this.#
|
|
1007
|
+
this.#o.delete(e), this.#e = -1, this.#t = -1, this.#l();
|
|
1004
1008
|
for (const l of this.#i)
|
|
1005
1009
|
l.startsWith(`${e}:`) && this.#i.delete(l);
|
|
1006
|
-
|
|
1007
|
-
l.classList.remove("editing"),
|
|
1008
|
-
}), this.requestRender()), this.#s = !0,
|
|
1010
|
+
o && (o.querySelectorAll(".cell.editing").forEach((l) => {
|
|
1011
|
+
l.classList.remove("editing"), ct(l.parentElement);
|
|
1012
|
+
}), this.requestRender()), this.#s = !0, o || (this.#u(n), this.#s = !1);
|
|
1009
1013
|
}
|
|
1010
1014
|
/**
|
|
1011
1015
|
* Commit a single cell value change.
|
|
1012
1016
|
*/
|
|
1013
1017
|
#a(e, t, n, i) {
|
|
1014
|
-
const
|
|
1015
|
-
if (!P(
|
|
1016
|
-
const
|
|
1017
|
-
if (
|
|
1018
|
+
const r = t.field;
|
|
1019
|
+
if (!P(r)) return;
|
|
1020
|
+
const o = i[r];
|
|
1021
|
+
if (o === n) return;
|
|
1018
1022
|
const l = !this.#n.has(e);
|
|
1019
1023
|
if (this.emitCancelable("cell-commit", {
|
|
1020
1024
|
row: i,
|
|
1021
|
-
field:
|
|
1022
|
-
oldValue:
|
|
1025
|
+
field: r,
|
|
1026
|
+
oldValue: o,
|
|
1023
1027
|
value: n,
|
|
1024
1028
|
rowIndex: e,
|
|
1025
1029
|
changedRows: this.changedRows,
|
|
1026
1030
|
changedRowIndices: this.changedRowIndices,
|
|
1027
1031
|
firstTimeForRow: l
|
|
1028
1032
|
})) return;
|
|
1029
|
-
i[
|
|
1033
|
+
i[r] = n, this.#n.add(e), this.#l();
|
|
1030
1034
|
const c = this.grid.findRenderedRowElement?.(e);
|
|
1031
1035
|
c && c.classList.add("changed");
|
|
1032
1036
|
}
|
|
1033
1037
|
/**
|
|
1034
1038
|
* Inject an editor into a cell.
|
|
1035
1039
|
*/
|
|
1036
|
-
#d(e, t, n, i,
|
|
1037
|
-
if (!n.editable ||
|
|
1040
|
+
#d(e, t, n, i, r, o) {
|
|
1041
|
+
if (!n.editable || r.classList.contains("editing")) return;
|
|
1038
1042
|
const l = P(n.field) ? e[n.field] : void 0;
|
|
1039
|
-
|
|
1040
|
-
const a =
|
|
1041
|
-
a &&
|
|
1043
|
+
r.classList.add("editing"), this.#i.add(`${t}:${i}`);
|
|
1044
|
+
const a = r.parentElement;
|
|
1045
|
+
a && dt(a);
|
|
1042
1046
|
let d = !1;
|
|
1043
1047
|
const c = (m) => {
|
|
1044
1048
|
d || this.#e === -1 || this.#a(t, n, m, e);
|
|
1045
1049
|
}, u = () => {
|
|
1046
1050
|
d = !0, P(n.field) && (e[n.field] = l);
|
|
1047
1051
|
}, h = document.createElement("div");
|
|
1048
|
-
h.className = "tbw-editor-host",
|
|
1049
|
-
m.key === "Enter" && (m.stopPropagation(), m.preventDefault(), d = !0, this.#
|
|
1052
|
+
h.className = "tbw-editor-host", r.innerHTML = "", r.appendChild(h), h.addEventListener("keydown", (m) => {
|
|
1053
|
+
m.key === "Enter" && (m.stopPropagation(), m.preventDefault(), d = !0, this.#r(t, !1)), m.key === "Escape" && (m.stopPropagation(), m.preventDefault(), u(), this.#r(t, !0));
|
|
1050
1054
|
});
|
|
1051
|
-
const f = n, g = f.__editorTemplate, p = f.editor || (g ? "template" :
|
|
1055
|
+
const f = n, g = f.__editorTemplate, p = f.editor || (g ? "template" : at(n)), w = l;
|
|
1052
1056
|
if (p === "template" && g)
|
|
1053
|
-
this.#f(h, f, e, l, c, u,
|
|
1057
|
+
this.#f(h, f, e, l, c, u, o, t);
|
|
1054
1058
|
else if (typeof p == "string") {
|
|
1055
1059
|
const m = document.createElement(p);
|
|
1056
|
-
m.value =
|
|
1057
|
-
h.querySelector(
|
|
1060
|
+
m.value = w, m.addEventListener("change", () => c(m.value)), h.appendChild(m), o || queueMicrotask(() => {
|
|
1061
|
+
h.querySelector(j)?.focus({ preventScroll: !0 });
|
|
1058
1062
|
});
|
|
1059
1063
|
} else if (typeof p == "function") {
|
|
1060
|
-
const m = { row: e, value:
|
|
1061
|
-
typeof
|
|
1062
|
-
h.querySelector(
|
|
1064
|
+
const m = { row: e, value: w, field: n.field, column: n, commit: c, cancel: u }, b = p(m);
|
|
1065
|
+
typeof b == "string" ? (h.innerHTML = b, ut(h, n, c)) : b instanceof Node && h.appendChild(b), o || queueMicrotask(() => {
|
|
1066
|
+
h.querySelector(j)?.focus({ preventScroll: !0 });
|
|
1063
1067
|
});
|
|
1064
1068
|
} else if (p && typeof p == "object") {
|
|
1065
|
-
const m = this.grid,
|
|
1066
|
-
|
|
1067
|
-
const
|
|
1069
|
+
const m = this.grid, b = document.createElement("div");
|
|
1070
|
+
b.setAttribute("data-external-editor", ""), b.setAttribute("data-field", n.field), h.appendChild(b);
|
|
1071
|
+
const L = { row: e, value: w, field: n.field, column: n, commit: c, cancel: u };
|
|
1068
1072
|
if (p.mount)
|
|
1069
1073
|
try {
|
|
1070
|
-
p.mount({ placeholder:
|
|
1074
|
+
p.mount({ placeholder: b, context: L, spec: p });
|
|
1071
1075
|
} catch (q) {
|
|
1072
1076
|
console.warn(`[tbw-grid] External editor mount error for column '${n.field}':`, q);
|
|
1073
1077
|
}
|
|
1074
1078
|
else
|
|
1075
1079
|
m.dispatchEvent(
|
|
1076
|
-
new CustomEvent("mount-external-editor", { detail: { placeholder:
|
|
1080
|
+
new CustomEvent("mount-external-editor", { detail: { placeholder: b, spec: p, context: L } })
|
|
1077
1081
|
);
|
|
1078
1082
|
}
|
|
1079
1083
|
}
|
|
1080
1084
|
/**
|
|
1081
1085
|
* Render a template-based editor.
|
|
1082
1086
|
*/
|
|
1083
|
-
#f(e, t, n, i,
|
|
1087
|
+
#f(e, t, n, i, r, o, l, a) {
|
|
1084
1088
|
const d = t.__editorTemplate;
|
|
1085
1089
|
if (!d) return;
|
|
1086
1090
|
const c = d.cloneNode(!0), u = t.__compiledEditor;
|
|
@@ -1089,13 +1093,13 @@ class Gn extends x {
|
|
|
1089
1093
|
value: i,
|
|
1090
1094
|
field: t.field,
|
|
1091
1095
|
column: t,
|
|
1092
|
-
commit:
|
|
1093
|
-
cancel:
|
|
1096
|
+
commit: r,
|
|
1097
|
+
cancel: o
|
|
1094
1098
|
}) : c.querySelectorAll("*").forEach((f) => {
|
|
1095
1099
|
f.childNodes.length === 1 && f.firstChild?.nodeType === Node.TEXT_NODE && (f.textContent = f.textContent?.replace(/{{\s*value\s*}}/g, i == null ? "" : String(i)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (g, p) => {
|
|
1096
1100
|
if (!P(p)) return "";
|
|
1097
|
-
const
|
|
1098
|
-
return
|
|
1101
|
+
const w = n[p];
|
|
1102
|
+
return w == null ? "" : String(w);
|
|
1099
1103
|
}) || "");
|
|
1100
1104
|
});
|
|
1101
1105
|
const h = c.querySelector(
|
|
@@ -1105,11 +1109,11 @@ class Gn extends x {
|
|
|
1105
1109
|
h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked = !!i : h.value = String(i ?? "");
|
|
1106
1110
|
let f = !1;
|
|
1107
1111
|
h.addEventListener("blur", () => {
|
|
1108
|
-
f ||
|
|
1112
|
+
f || r(K(h, t));
|
|
1109
1113
|
}), h.addEventListener("keydown", (g) => {
|
|
1110
1114
|
const p = g;
|
|
1111
|
-
p.key === "Enter" && (p.stopPropagation(), p.preventDefault(), f = !0,
|
|
1112
|
-
}), h instanceof HTMLInputElement && h.type === "checkbox" && h.addEventListener("change", () =>
|
|
1115
|
+
p.key === "Enter" && (p.stopPropagation(), p.preventDefault(), f = !0, r(K(h, t)), this.#r(a, !1)), p.key === "Escape" && (p.stopPropagation(), p.preventDefault(), o(), this.#r(a, !0));
|
|
1116
|
+
}), h instanceof HTMLInputElement && h.type === "checkbox" && h.addEventListener("change", () => r(h.checked)), l || setTimeout(() => h.focus({ preventScroll: !0 }), 0);
|
|
1113
1117
|
}
|
|
1114
1118
|
e.appendChild(c);
|
|
1115
1119
|
}
|
|
@@ -1122,10 +1126,10 @@ class Gn extends x {
|
|
|
1122
1126
|
const t = e._focusRow, n = e._focusCol, i = e.findRenderedRowElement?.(t);
|
|
1123
1127
|
if (i) {
|
|
1124
1128
|
Array.from(e._bodyEl.querySelectorAll(".cell-focus")).forEach(
|
|
1125
|
-
(
|
|
1129
|
+
(o) => o.classList.remove("cell-focus")
|
|
1126
1130
|
);
|
|
1127
|
-
const
|
|
1128
|
-
|
|
1131
|
+
const r = i.querySelector(`.cell[data-row="${t}"][data-col="${n}"]`);
|
|
1132
|
+
r && (r.classList.add("cell-focus"), r.setAttribute("aria-selected", "true"), r.hasAttribute("tabindex") || r.setAttribute("tabindex", "-1"), r.focus({ preventScroll: !0 }));
|
|
1129
1133
|
}
|
|
1130
1134
|
} catch {
|
|
1131
1135
|
}
|
|
@@ -1141,37 +1145,37 @@ function we(s, e = !0) {
|
|
|
1141
1145
|
return e && (t.includes(",") || t.includes('"') || t.includes(`
|
|
1142
1146
|
`) || t.includes("\r")) ? `"${t.replace(/"/g, '""')}"` : t;
|
|
1143
1147
|
}
|
|
1144
|
-
function
|
|
1145
|
-
const i = n.delimiter ?? ",",
|
|
1146
|
-
`,
|
|
1148
|
+
function ht(s, e, t, n = {}) {
|
|
1149
|
+
const i = n.delimiter ?? ",", r = n.newline ?? `
|
|
1150
|
+
`, o = [], l = n.bom ? "\uFEFF" : "";
|
|
1147
1151
|
if (t.includeHeaders !== !1) {
|
|
1148
1152
|
const a = e.map((d) => {
|
|
1149
1153
|
const c = d.header || d.field, u = t.processHeader ? t.processHeader(c, d.field) : c;
|
|
1150
1154
|
return we(u);
|
|
1151
1155
|
});
|
|
1152
|
-
|
|
1156
|
+
o.push(a.join(i));
|
|
1153
1157
|
}
|
|
1154
1158
|
for (const a of s) {
|
|
1155
1159
|
const d = e.map((c) => {
|
|
1156
1160
|
let u = a[c.field];
|
|
1157
1161
|
return t.processCell && (u = t.processCell(u, c.field, a)), we(u);
|
|
1158
1162
|
});
|
|
1159
|
-
|
|
1163
|
+
o.push(d.join(i));
|
|
1160
1164
|
}
|
|
1161
|
-
return l +
|
|
1165
|
+
return l + o.join(r);
|
|
1162
1166
|
}
|
|
1163
1167
|
function re(s, e) {
|
|
1164
1168
|
const t = URL.createObjectURL(s), n = document.createElement("a");
|
|
1165
1169
|
n.href = t, n.download = e, n.style.display = "none", document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(t);
|
|
1166
1170
|
}
|
|
1167
|
-
function
|
|
1171
|
+
function ft(s, e) {
|
|
1168
1172
|
const t = new Blob([s], { type: "text/csv;charset=utf-8;" });
|
|
1169
1173
|
re(t, e);
|
|
1170
1174
|
}
|
|
1171
1175
|
function be(s) {
|
|
1172
1176
|
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1173
1177
|
}
|
|
1174
|
-
function
|
|
1178
|
+
function gt(s, e, t) {
|
|
1175
1179
|
let n = `<?xml version="1.0" encoding="UTF-8"?>
|
|
1176
1180
|
<?mso-application progid="Excel.Sheet"?>
|
|
1177
1181
|
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
|
|
@@ -1182,19 +1186,19 @@ function ft(s, e, t) {
|
|
|
1182
1186
|
n += `
|
|
1183
1187
|
<Row>`;
|
|
1184
1188
|
for (const i of e) {
|
|
1185
|
-
const
|
|
1186
|
-
n += `<Cell><Data ss:Type="String">${be(
|
|
1189
|
+
const r = i.header || i.field, o = t.processHeader ? t.processHeader(r, i.field) : r;
|
|
1190
|
+
n += `<Cell><Data ss:Type="String">${be(o)}</Data></Cell>`;
|
|
1187
1191
|
}
|
|
1188
1192
|
n += "</Row>";
|
|
1189
1193
|
}
|
|
1190
1194
|
for (const i of s) {
|
|
1191
1195
|
n += `
|
|
1192
1196
|
<Row>`;
|
|
1193
|
-
for (const
|
|
1194
|
-
let
|
|
1195
|
-
t.processCell && (
|
|
1197
|
+
for (const r of e) {
|
|
1198
|
+
let o = i[r.field];
|
|
1199
|
+
t.processCell && (o = t.processCell(o, r.field, i));
|
|
1196
1200
|
let l = "String", a = "";
|
|
1197
|
-
|
|
1201
|
+
o == null ? a = "" : typeof o == "number" && !isNaN(o) ? (l = "Number", a = String(o)) : o instanceof Date ? (l = "DateTime", a = o.toISOString()) : a = be(String(o)), n += `<Cell><Data ss:Type="${l}">${a}</Data></Cell>`;
|
|
1198
1202
|
}
|
|
1199
1203
|
n += "</Row>";
|
|
1200
1204
|
}
|
|
@@ -1203,7 +1207,7 @@ function ft(s, e, t) {
|
|
|
1203
1207
|
</Worksheet>
|
|
1204
1208
|
</Workbook>`, n;
|
|
1205
1209
|
}
|
|
1206
|
-
function
|
|
1210
|
+
function pt(s, e) {
|
|
1207
1211
|
const t = e.endsWith(".xls") ? e : `${e}.xls`, n = new Blob([s], {
|
|
1208
1212
|
type: "application/vnd.ms-excel;charset=utf-8;"
|
|
1209
1213
|
});
|
|
@@ -1234,34 +1238,34 @@ class Bn extends x {
|
|
|
1234
1238
|
columns: t?.columns,
|
|
1235
1239
|
rowIndices: t?.rowIndices
|
|
1236
1240
|
};
|
|
1237
|
-
let
|
|
1238
|
-
if (n.onlyVisible && (
|
|
1241
|
+
let r = [...this.columns];
|
|
1242
|
+
if (n.onlyVisible && (r = r.filter((a) => !a.hidden && !a.field.startsWith("__"))), t?.columns) {
|
|
1239
1243
|
const a = new Set(t.columns);
|
|
1240
|
-
|
|
1244
|
+
r = r.filter((d) => a.has(d.field));
|
|
1241
1245
|
}
|
|
1242
|
-
let
|
|
1246
|
+
let o = [...this.rows];
|
|
1243
1247
|
if (n.onlySelected) {
|
|
1244
1248
|
const a = this.getSelectionState();
|
|
1245
|
-
a?.selected?.size && (
|
|
1249
|
+
a?.selected?.size && (o = [...a.selected].sort((c, u) => c - u).map((c) => this.rows[c]).filter(Boolean));
|
|
1246
1250
|
}
|
|
1247
|
-
t?.rowIndices && (
|
|
1251
|
+
t?.rowIndices && (o = t.rowIndices.map((a) => this.rows[a]).filter(Boolean)), this.isExportingFlag = !0;
|
|
1248
1252
|
let l = i.fileName;
|
|
1249
1253
|
try {
|
|
1250
1254
|
switch (e) {
|
|
1251
1255
|
case "csv": {
|
|
1252
|
-
const a =
|
|
1253
|
-
l = l.endsWith(".csv") ? l : `${l}.csv`,
|
|
1256
|
+
const a = ht(o, r, i, { bom: !0 });
|
|
1257
|
+
l = l.endsWith(".csv") ? l : `${l}.csv`, ft(a, l);
|
|
1254
1258
|
break;
|
|
1255
1259
|
}
|
|
1256
1260
|
case "excel": {
|
|
1257
|
-
const a =
|
|
1258
|
-
l = l.endsWith(".xls") ? l : `${l}.xls`,
|
|
1261
|
+
const a = gt(o, r, i);
|
|
1262
|
+
l = l.endsWith(".xls") ? l : `${l}.xls`, pt(a, l);
|
|
1259
1263
|
break;
|
|
1260
1264
|
}
|
|
1261
1265
|
case "json": {
|
|
1262
|
-
const a =
|
|
1266
|
+
const a = o.map((u) => {
|
|
1263
1267
|
const h = {};
|
|
1264
|
-
for (const f of
|
|
1268
|
+
for (const f of r) {
|
|
1265
1269
|
let g = u[f.field];
|
|
1266
1270
|
i.processCell && (g = i.processCell(g, f.field, u)), h[f.field] = g;
|
|
1267
1271
|
}
|
|
@@ -1276,8 +1280,8 @@ class Bn extends x {
|
|
|
1276
1280
|
this.lastExportInfo = { format: e, timestamp: /* @__PURE__ */ new Date() }, this.emit("export-complete", {
|
|
1277
1281
|
format: e,
|
|
1278
1282
|
fileName: l,
|
|
1279
|
-
rowCount:
|
|
1280
|
-
columnCount:
|
|
1283
|
+
rowCount: o.length,
|
|
1284
|
+
columnCount: r.length
|
|
1281
1285
|
});
|
|
1282
1286
|
} finally {
|
|
1283
1287
|
this.isExportingFlag = !1;
|
|
@@ -1329,43 +1333,43 @@ class Bn extends x {
|
|
|
1329
1333
|
}
|
|
1330
1334
|
// #endregion
|
|
1331
1335
|
}
|
|
1332
|
-
function
|
|
1333
|
-
const { totalRows: e, viewportHeight: t, scrollTop: n, rowHeight: i, overscan:
|
|
1334
|
-
let l = Math.floor(n / i) -
|
|
1336
|
+
function mt(s) {
|
|
1337
|
+
const { totalRows: e, viewportHeight: t, scrollTop: n, rowHeight: i, overscan: r } = s, o = Math.ceil(t / i);
|
|
1338
|
+
let l = Math.floor(n / i) - r;
|
|
1335
1339
|
l < 0 && (l = 0);
|
|
1336
|
-
let a = l +
|
|
1337
|
-
return a > e && (a = e), a === e && l > 0 && (l = Math.max(0, a -
|
|
1340
|
+
let a = l + o + r * 2;
|
|
1341
|
+
return a > e && (a = e), a === e && l > 0 && (l = Math.max(0, a - o - r * 2)), {
|
|
1338
1342
|
start: l,
|
|
1339
1343
|
end: a,
|
|
1340
1344
|
offsetY: l * i,
|
|
1341
1345
|
totalHeight: e * i
|
|
1342
1346
|
};
|
|
1343
1347
|
}
|
|
1344
|
-
function
|
|
1348
|
+
function wt(s, e) {
|
|
1345
1349
|
return s <= e;
|
|
1346
1350
|
}
|
|
1347
|
-
function
|
|
1351
|
+
function bt(s, e, t = !1) {
|
|
1348
1352
|
const n = s[e.field];
|
|
1349
1353
|
if (e.operator === "blank")
|
|
1350
1354
|
return n == null || n === "";
|
|
1351
1355
|
if (e.operator === "notBlank")
|
|
1352
1356
|
return n != null && n !== "";
|
|
1353
1357
|
if (n == null) return !1;
|
|
1354
|
-
const i = String(n),
|
|
1358
|
+
const i = String(n), r = t ? i : i.toLowerCase(), o = t ? String(e.value) : String(e.value).toLowerCase();
|
|
1355
1359
|
switch (e.operator) {
|
|
1356
1360
|
// Text operators
|
|
1357
1361
|
case "contains":
|
|
1358
|
-
return
|
|
1362
|
+
return r.includes(o);
|
|
1359
1363
|
case "notContains":
|
|
1360
|
-
return !
|
|
1364
|
+
return !r.includes(o);
|
|
1361
1365
|
case "equals":
|
|
1362
|
-
return
|
|
1366
|
+
return r === o;
|
|
1363
1367
|
case "notEquals":
|
|
1364
|
-
return
|
|
1368
|
+
return r !== o;
|
|
1365
1369
|
case "startsWith":
|
|
1366
|
-
return
|
|
1370
|
+
return r.startsWith(o);
|
|
1367
1371
|
case "endsWith":
|
|
1368
|
-
return
|
|
1372
|
+
return r.endsWith(o);
|
|
1369
1373
|
// Number/Date operators (use raw numeric values)
|
|
1370
1374
|
case "lessThan":
|
|
1371
1375
|
return Number(n) < Number(e.value);
|
|
@@ -1386,10 +1390,10 @@ function wt(s, e, t = !1) {
|
|
|
1386
1390
|
return !0;
|
|
1387
1391
|
}
|
|
1388
1392
|
}
|
|
1389
|
-
function
|
|
1390
|
-
return e.length ? s.filter((n) => e.every((i) =>
|
|
1393
|
+
function vt(s, e, t = !1) {
|
|
1394
|
+
return e.length ? s.filter((n) => e.every((i) => bt(n, i, t))) : s;
|
|
1391
1395
|
}
|
|
1392
|
-
function
|
|
1396
|
+
function yt(s) {
|
|
1393
1397
|
return JSON.stringify(
|
|
1394
1398
|
s.map((e) => ({
|
|
1395
1399
|
field: e.field,
|
|
@@ -1407,10 +1411,10 @@ function ve(s, e) {
|
|
|
1407
1411
|
}
|
|
1408
1412
|
return [...t].sort((n, i) => typeof n == "number" && typeof i == "number" ? n - i : String(n).localeCompare(String(i)));
|
|
1409
1413
|
}
|
|
1410
|
-
const
|
|
1411
|
-
class
|
|
1414
|
+
const Ct = '@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:inline-flex;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;color:inherit;vertical-align:middle;&:hover,&.active{opacity:1}&.active{color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}}}}', xt = "@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-button-padding, .375rem .625rem);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}.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-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)}.tbw-filter-apply-btn:hover{filter:brightness(.9)}.tbw-filter-clear-btn{flex:1;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)}.tbw-filter-clear-btn:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}}";
|
|
1415
|
+
class S extends x {
|
|
1412
1416
|
name = "filtering";
|
|
1413
|
-
styles =
|
|
1417
|
+
styles = Ct;
|
|
1414
1418
|
get defaultConfig() {
|
|
1415
1419
|
return {
|
|
1416
1420
|
debounceMs: 300,
|
|
@@ -1425,6 +1429,8 @@ class L extends x {
|
|
|
1425
1429
|
cacheKey = null;
|
|
1426
1430
|
openPanelField = null;
|
|
1427
1431
|
panelElement = null;
|
|
1432
|
+
panelAnchorElement = null;
|
|
1433
|
+
// For CSS anchor positioning cleanup
|
|
1428
1434
|
searchText = /* @__PURE__ */ new Map();
|
|
1429
1435
|
excludedValues = /* @__PURE__ */ new Map();
|
|
1430
1436
|
panelAbortController = null;
|
|
@@ -1456,30 +1462,30 @@ class L extends x {
|
|
|
1456
1462
|
if (!t.length) return [...e];
|
|
1457
1463
|
if (this.config.filterHandler)
|
|
1458
1464
|
return this.cachedResult ? this.cachedResult : [...e];
|
|
1459
|
-
const n =
|
|
1465
|
+
const n = yt(t);
|
|
1460
1466
|
if (this.cacheKey === n && this.cachedResult)
|
|
1461
1467
|
return this.cachedResult;
|
|
1462
|
-
const i =
|
|
1468
|
+
const i = vt([...e], t, this.config.caseSensitive);
|
|
1463
1469
|
return this.cachedResult = i, this.cacheKey = n, i;
|
|
1464
1470
|
}
|
|
1465
1471
|
afterRender() {
|
|
1466
|
-
const e = this.
|
|
1472
|
+
const e = this.gridElement;
|
|
1467
1473
|
if (!e) return;
|
|
1468
1474
|
e.querySelectorAll('[part~="header-cell"]').forEach((n) => {
|
|
1469
1475
|
const i = n.getAttribute("data-col");
|
|
1470
1476
|
if (i === null) return;
|
|
1471
|
-
const
|
|
1472
|
-
if (!
|
|
1473
|
-
const
|
|
1474
|
-
if (!
|
|
1475
|
-
const l = this.filters.has(
|
|
1477
|
+
const r = this.visibleColumns[parseInt(i, 10)];
|
|
1478
|
+
if (!r || r.filterable === !1 || _(r)) return;
|
|
1479
|
+
const o = r.field;
|
|
1480
|
+
if (!o) return;
|
|
1481
|
+
const l = this.filters.has(o);
|
|
1476
1482
|
let a = n.querySelector(".tbw-filter-btn");
|
|
1477
1483
|
if (a) {
|
|
1478
1484
|
a.classList.toggle("active", l), n.classList.toggle("filtered", l);
|
|
1479
1485
|
return;
|
|
1480
1486
|
}
|
|
1481
|
-
a = document.createElement("button"), a.className = "tbw-filter-btn", a.setAttribute("aria-label", `Filter ${
|
|
1482
|
-
c.stopPropagation(), this.toggleFilterPanel(
|
|
1487
|
+
a = document.createElement("button"), a.className = "tbw-filter-btn", a.setAttribute("aria-label", `Filter ${r.header ?? o}`), a.innerHTML = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>', l && (a.classList.add("active"), n.classList.add("filtered")), a.addEventListener("click", (c) => {
|
|
1488
|
+
c.stopPropagation(), this.toggleFilterPanel(o, r, a);
|
|
1483
1489
|
});
|
|
1484
1490
|
const d = n.querySelector(".resize-handle");
|
|
1485
1491
|
d ? n.insertBefore(a, d) : n.appendChild(a);
|
|
@@ -1595,27 +1601,27 @@ class L extends x {
|
|
|
1595
1601
|
}
|
|
1596
1602
|
this.closeFilterPanel();
|
|
1597
1603
|
const i = document.createElement("div");
|
|
1598
|
-
if (i.className = "tbw-filter-panel", this.panelElement = i, this.openPanelField = e, this.config.valuesHandler) {
|
|
1599
|
-
i.innerHTML = '<div class="tbw-filter-loading">Loading...</div>', document.body.appendChild(i), this.positionPanel(i, n), this.setupPanelCloseHandler(i, n), this.config.valuesHandler(e, t).then((
|
|
1600
|
-
this.openPanelField !== e || !this.panelElement || (i.innerHTML = "", this.renderPanelContent(e, t, i,
|
|
1604
|
+
if (i.className = "tbw-filter-panel", this.isAnimationEnabled && i.classList.add("tbw-filter-panel-animated"), this.panelElement = i, this.openPanelField = e, this.config.valuesHandler) {
|
|
1605
|
+
i.innerHTML = '<div class="tbw-filter-loading">Loading...</div>', document.body.appendChild(i), this.positionPanel(i, n), this.setupPanelCloseHandler(i, n), this.config.valuesHandler(e, t).then((o) => {
|
|
1606
|
+
this.openPanelField !== e || !this.panelElement || (i.innerHTML = "", this.renderPanelContent(e, t, i, o));
|
|
1601
1607
|
});
|
|
1602
1608
|
return;
|
|
1603
1609
|
}
|
|
1604
|
-
const
|
|
1605
|
-
this.renderPanelContent(e, t, i,
|
|
1610
|
+
const r = ve(this.sourceRows, e);
|
|
1611
|
+
this.renderPanelContent(e, t, i, r), document.body.appendChild(i), this.positionPanel(i, n), this.setupPanelCloseHandler(i, n);
|
|
1606
1612
|
}
|
|
1607
1613
|
/**
|
|
1608
1614
|
* Render filter panel content with given values
|
|
1609
1615
|
*/
|
|
1610
1616
|
renderPanelContent(e, t, n, i) {
|
|
1611
|
-
let
|
|
1612
|
-
|
|
1613
|
-
const
|
|
1617
|
+
let r = this.excludedValues.get(e);
|
|
1618
|
+
r || (r = /* @__PURE__ */ new Set(), this.excludedValues.set(e, r));
|
|
1619
|
+
const o = this.searchText.get(e) ?? "", l = {
|
|
1614
1620
|
field: e,
|
|
1615
1621
|
column: t,
|
|
1616
1622
|
uniqueValues: i,
|
|
1617
|
-
excludedValues:
|
|
1618
|
-
searchText:
|
|
1623
|
+
excludedValues: r,
|
|
1624
|
+
searchText: o,
|
|
1619
1625
|
applySetFilter: (d) => {
|
|
1620
1626
|
this.applySetFilter(e, d), this.closeFilterPanel();
|
|
1621
1627
|
},
|
|
@@ -1628,7 +1634,7 @@ class L extends x {
|
|
|
1628
1634
|
closePanel: () => this.closeFilterPanel()
|
|
1629
1635
|
};
|
|
1630
1636
|
let a = !1;
|
|
1631
|
-
this.config.filterPanelRenderer && (this.config.filterPanelRenderer(n, l), a = n.children.length > 0), a || this.renderDefaultFilterPanel(n, l, i,
|
|
1637
|
+
this.config.filterPanelRenderer && (this.config.filterPanelRenderer(n, l), a = n.children.length > 0), a || this.renderDefaultFilterPanel(n, l, i, r);
|
|
1632
1638
|
}
|
|
1633
1639
|
/**
|
|
1634
1640
|
* Setup click-outside handler to close the panel
|
|
@@ -1648,26 +1654,44 @@ class L extends x {
|
|
|
1648
1654
|
* Close the filter panel
|
|
1649
1655
|
*/
|
|
1650
1656
|
closeFilterPanel() {
|
|
1651
|
-
|
|
1657
|
+
const e = this.panelElement;
|
|
1658
|
+
e && (e.remove(), this.panelElement = null), this.panelAnchorElement && (this.panelAnchorElement.style.anchorName = "", this.panelAnchorElement = null), this.openPanelField = null, this.panelAbortController?.abort(), this.panelAbortController = null;
|
|
1652
1659
|
}
|
|
1660
|
+
/** Cache for CSS anchor positioning support check */
|
|
1661
|
+
static supportsAnchorPositioning = null;
|
|
1653
1662
|
/**
|
|
1654
|
-
*
|
|
1663
|
+
* Check if browser supports CSS Anchor Positioning
|
|
1664
|
+
*/
|
|
1665
|
+
static checkAnchorPositioningSupport() {
|
|
1666
|
+
return S.supportsAnchorPositioning === null && (S.supportsAnchorPositioning = CSS.supports("anchor-name", "--test")), S.supportsAnchorPositioning;
|
|
1667
|
+
}
|
|
1668
|
+
/**
|
|
1669
|
+
* Position the panel below the header cell
|
|
1670
|
+
* Uses CSS Anchor Positioning if supported, falls back to JS positioning
|
|
1655
1671
|
*/
|
|
1656
1672
|
positionPanel(e, t) {
|
|
1657
|
-
const
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1673
|
+
const i = t.closest(".cell") ?? t;
|
|
1674
|
+
if (i.style.anchorName = "--tbw-filter-anchor", this.panelAnchorElement = i, S.checkAnchorPositioningSupport()) {
|
|
1675
|
+
requestAnimationFrame(() => {
|
|
1676
|
+
const o = e.getBoundingClientRect(), l = i.getBoundingClientRect();
|
|
1677
|
+
o.top < l.top && e.classList.add("tbw-filter-panel-above");
|
|
1678
|
+
});
|
|
1679
|
+
return;
|
|
1680
|
+
}
|
|
1681
|
+
const r = i.getBoundingClientRect();
|
|
1682
|
+
e.style.position = "fixed", e.style.top = `${r.bottom + 4}px`, e.style.left = `${r.left}px`, requestAnimationFrame(() => {
|
|
1683
|
+
const o = e.getBoundingClientRect();
|
|
1684
|
+
o.right > window.innerWidth - 8 && (e.style.left = `${r.right - o.width}px`), o.bottom > window.innerHeight - 8 && (e.style.top = `${r.top - o.height - 4}px`, e.classList.add("tbw-filter-panel-above"));
|
|
1661
1685
|
});
|
|
1662
1686
|
}
|
|
1663
1687
|
/**
|
|
1664
1688
|
* Render the default filter panel content
|
|
1665
1689
|
*/
|
|
1666
1690
|
renderDefaultFilterPanel(e, t, n, i) {
|
|
1667
|
-
const { field:
|
|
1668
|
-
|
|
1691
|
+
const { field: r } = t, o = document.createElement("div");
|
|
1692
|
+
o.className = "tbw-filter-search";
|
|
1669
1693
|
const l = document.createElement("input");
|
|
1670
|
-
l.type = "text", l.placeholder = "Search...", l.className = "tbw-filter-search-input", l.value = this.searchText.get(
|
|
1694
|
+
l.type = "text", l.placeholder = "Search...", l.className = "tbw-filter-search-input", l.value = this.searchText.get(r) ?? "", o.appendChild(l), e.appendChild(o);
|
|
1671
1695
|
const a = document.createElement("div");
|
|
1672
1696
|
a.className = "tbw-filter-actions";
|
|
1673
1697
|
const d = document.createElement("label");
|
|
@@ -1677,14 +1701,14 @@ class L extends x {
|
|
|
1677
1701
|
const u = document.createElement("span");
|
|
1678
1702
|
u.textContent = "Select All", d.appendChild(c), d.appendChild(u), a.appendChild(d);
|
|
1679
1703
|
const h = () => {
|
|
1680
|
-
const v = [...
|
|
1681
|
-
c.checked = R, c.indeterminate = !R && !
|
|
1704
|
+
const v = [...w.values()], R = v.every((y) => y), k = v.every((y) => !y);
|
|
1705
|
+
c.checked = R, c.indeterminate = !R && !k;
|
|
1682
1706
|
};
|
|
1683
1707
|
c.addEventListener("change", () => {
|
|
1684
1708
|
const v = c.checked;
|
|
1685
|
-
for (const R of
|
|
1686
|
-
|
|
1687
|
-
h(),
|
|
1709
|
+
for (const R of w.keys())
|
|
1710
|
+
w.set(R, v);
|
|
1711
|
+
h(), L();
|
|
1688
1712
|
}), e.appendChild(a);
|
|
1689
1713
|
const f = document.createElement("div");
|
|
1690
1714
|
f.className = "tbw-filter-values";
|
|
@@ -1692,63 +1716,63 @@ class L extends x {
|
|
|
1692
1716
|
g.className = "tbw-filter-values-spacer", f.appendChild(g);
|
|
1693
1717
|
const p = document.createElement("div");
|
|
1694
1718
|
p.className = "tbw-filter-values-content", f.appendChild(p);
|
|
1695
|
-
const
|
|
1719
|
+
const w = /* @__PURE__ */ new Map();
|
|
1696
1720
|
n.forEach((v) => {
|
|
1697
1721
|
const R = v == null ? "__null__" : String(v);
|
|
1698
|
-
|
|
1722
|
+
w.set(R, !i.has(v));
|
|
1699
1723
|
}), h();
|
|
1700
1724
|
let m = [];
|
|
1701
|
-
const
|
|
1702
|
-
const
|
|
1703
|
-
|
|
1704
|
-
const
|
|
1705
|
-
|
|
1706
|
-
|
|
1725
|
+
const b = (v, R) => {
|
|
1726
|
+
const k = v == null ? "(Blank)" : String(v), y = v == null ? "__null__" : String(v), C = document.createElement("label");
|
|
1727
|
+
C.className = "tbw-filter-value-item", C.style.position = "absolute", C.style.top = `${R * S.LIST_ITEM_HEIGHT}px`, C.style.left = "0", C.style.right = "0", C.style.height = `${S.LIST_ITEM_HEIGHT}px`, C.style.boxSizing = "border-box";
|
|
1728
|
+
const E = document.createElement("input");
|
|
1729
|
+
E.type = "checkbox", E.className = "tbw-filter-checkbox", E.checked = w.get(y) ?? !0, E.dataset.value = y, E.addEventListener("change", () => {
|
|
1730
|
+
w.set(y, E.checked), h();
|
|
1707
1731
|
});
|
|
1708
|
-
const
|
|
1709
|
-
return
|
|
1710
|
-
},
|
|
1711
|
-
const v = m.length, R = f.clientHeight,
|
|
1712
|
-
if (g.style.height = `${v *
|
|
1713
|
-
p.innerHTML = "", p.style.transform = "translateY(0px)", m.forEach((
|
|
1714
|
-
p.appendChild(
|
|
1732
|
+
const le = document.createElement("span");
|
|
1733
|
+
return le.textContent = k, C.appendChild(E), C.appendChild(le), C;
|
|
1734
|
+
}, L = () => {
|
|
1735
|
+
const v = m.length, R = f.clientHeight, k = f.scrollTop;
|
|
1736
|
+
if (g.style.height = `${v * S.LIST_ITEM_HEIGHT}px`, wt(v, S.LIST_BYPASS_THRESHOLD / 3)) {
|
|
1737
|
+
p.innerHTML = "", p.style.transform = "translateY(0px)", m.forEach((C, E) => {
|
|
1738
|
+
p.appendChild(b(C, E));
|
|
1715
1739
|
});
|
|
1716
1740
|
return;
|
|
1717
1741
|
}
|
|
1718
|
-
const
|
|
1742
|
+
const y = mt({
|
|
1719
1743
|
totalRows: v,
|
|
1720
1744
|
viewportHeight: R,
|
|
1721
|
-
scrollTop:
|
|
1722
|
-
rowHeight:
|
|
1723
|
-
overscan:
|
|
1745
|
+
scrollTop: k,
|
|
1746
|
+
rowHeight: S.LIST_ITEM_HEIGHT,
|
|
1747
|
+
overscan: S.LIST_OVERSCAN
|
|
1724
1748
|
});
|
|
1725
|
-
p.style.transform = `translateY(${
|
|
1726
|
-
for (let
|
|
1727
|
-
p.appendChild(
|
|
1749
|
+
p.style.transform = `translateY(${y.offsetY}px)`, p.innerHTML = "";
|
|
1750
|
+
for (let C = y.start; C < y.end; C++)
|
|
1751
|
+
p.appendChild(b(m[C], C - y.start));
|
|
1728
1752
|
}, q = (v) => {
|
|
1729
|
-
const R = v.toLowerCase();
|
|
1730
|
-
if (m = n.filter((
|
|
1731
|
-
const C =
|
|
1732
|
-
return !v ||
|
|
1753
|
+
const R = this.config.caseSensitive ?? !1, k = R ? v : v.toLowerCase();
|
|
1754
|
+
if (m = n.filter((y) => {
|
|
1755
|
+
const C = y == null ? "(Blank)" : String(y), E = R ? C : C.toLowerCase();
|
|
1756
|
+
return !v || E.includes(k);
|
|
1733
1757
|
}), m.length === 0) {
|
|
1734
1758
|
g.style.height = "0px", p.innerHTML = "";
|
|
1735
|
-
const
|
|
1736
|
-
|
|
1759
|
+
const y = document.createElement("div");
|
|
1760
|
+
y.className = "tbw-filter-no-match", y.textContent = "No matching values", p.appendChild(y);
|
|
1737
1761
|
return;
|
|
1738
1762
|
}
|
|
1739
|
-
|
|
1763
|
+
L();
|
|
1740
1764
|
};
|
|
1741
1765
|
f.addEventListener(
|
|
1742
1766
|
"scroll",
|
|
1743
1767
|
() => {
|
|
1744
|
-
m.length > 0 &&
|
|
1768
|
+
m.length > 0 && L();
|
|
1745
1769
|
},
|
|
1746
1770
|
{ passive: !0 }
|
|
1747
1771
|
), q(l.value), e.appendChild(f);
|
|
1748
|
-
let
|
|
1772
|
+
let se;
|
|
1749
1773
|
l.addEventListener("input", () => {
|
|
1750
|
-
clearTimeout(
|
|
1751
|
-
this.searchText.set(
|
|
1774
|
+
clearTimeout(se), se = setTimeout(() => {
|
|
1775
|
+
this.searchText.set(r, l.value), q(l.value);
|
|
1752
1776
|
}, this.config.debounceMs ?? 150);
|
|
1753
1777
|
});
|
|
1754
1778
|
const N = document.createElement("div");
|
|
@@ -1756,20 +1780,20 @@ class L extends x {
|
|
|
1756
1780
|
const H = document.createElement("button");
|
|
1757
1781
|
H.className = "tbw-filter-apply-btn", H.textContent = "Apply", H.addEventListener("click", () => {
|
|
1758
1782
|
const v = [];
|
|
1759
|
-
for (const [R,
|
|
1760
|
-
if (!
|
|
1783
|
+
for (const [R, k] of w)
|
|
1784
|
+
if (!k)
|
|
1761
1785
|
if (R === "__null__")
|
|
1762
1786
|
v.push(null);
|
|
1763
1787
|
else {
|
|
1764
|
-
const
|
|
1765
|
-
v.push(
|
|
1788
|
+
const y = n.find((C) => String(C) === R);
|
|
1789
|
+
v.push(y !== void 0 ? y : R);
|
|
1766
1790
|
}
|
|
1767
1791
|
t.applySetFilter(v);
|
|
1768
1792
|
}), N.appendChild(H);
|
|
1769
|
-
const
|
|
1770
|
-
|
|
1793
|
+
const z = document.createElement("button");
|
|
1794
|
+
z.className = "tbw-filter-clear-btn", z.textContent = "Clear Filter", z.addEventListener("click", () => {
|
|
1771
1795
|
t.clearFilter();
|
|
1772
|
-
}), N.appendChild(
|
|
1796
|
+
}), N.appendChild(z), e.appendChild(N);
|
|
1773
1797
|
}
|
|
1774
1798
|
/**
|
|
1775
1799
|
* Apply a set filter (exclude values)
|
|
@@ -1803,10 +1827,10 @@ class L extends x {
|
|
|
1803
1827
|
if (this.config.filterHandler) {
|
|
1804
1828
|
const t = this.grid;
|
|
1805
1829
|
t.setAttribute("aria-busy", "true");
|
|
1806
|
-
const n = this.config.filterHandler(e, this.sourceRows), i = (
|
|
1807
|
-
t.removeAttribute("aria-busy"), this.cachedResult =
|
|
1830
|
+
const n = this.config.filterHandler(e, this.sourceRows), i = (r) => {
|
|
1831
|
+
t.removeAttribute("aria-busy"), this.cachedResult = r, this.grid.rows = r, this.emit("filter-change", {
|
|
1808
1832
|
filters: e,
|
|
1809
|
-
filteredRowCount:
|
|
1833
|
+
filteredRowCount: r.length
|
|
1810
1834
|
}), this.requestRender();
|
|
1811
1835
|
};
|
|
1812
1836
|
n && typeof n.then == "function" ? n.then(i) : i(n);
|
|
@@ -1855,29 +1879,29 @@ class L extends x {
|
|
|
1855
1879
|
}
|
|
1856
1880
|
function ye(s) {
|
|
1857
1881
|
if (!s.length) return [];
|
|
1858
|
-
const e = /* @__PURE__ */ new Map(), t = [], n = (
|
|
1882
|
+
const e = /* @__PURE__ */ new Map(), t = [], n = (o, l) => {
|
|
1859
1883
|
if (!l.length) return;
|
|
1860
1884
|
const a = t[t.length - 1];
|
|
1861
|
-
if (a && a.implicit && a.firstIndex + a.columns.length ===
|
|
1885
|
+
if (a && a.implicit && a.firstIndex + a.columns.length === o) {
|
|
1862
1886
|
a.columns.push(...l);
|
|
1863
1887
|
return;
|
|
1864
1888
|
}
|
|
1865
1889
|
t.push({
|
|
1866
|
-
id: "__implicit__" +
|
|
1890
|
+
id: "__implicit__" + o,
|
|
1867
1891
|
label: void 0,
|
|
1868
1892
|
columns: l,
|
|
1869
|
-
firstIndex:
|
|
1893
|
+
firstIndex: o,
|
|
1870
1894
|
implicit: !0
|
|
1871
1895
|
});
|
|
1872
1896
|
};
|
|
1873
|
-
let i = [],
|
|
1874
|
-
return s.forEach((
|
|
1875
|
-
const a =
|
|
1897
|
+
let i = [], r = 0;
|
|
1898
|
+
return s.forEach((o, l) => {
|
|
1899
|
+
const a = o.group;
|
|
1876
1900
|
if (!a) {
|
|
1877
|
-
i.length === 0 && (
|
|
1901
|
+
i.length === 0 && (r = l), i.push(o);
|
|
1878
1902
|
return;
|
|
1879
1903
|
}
|
|
1880
|
-
i.length && (n(
|
|
1904
|
+
i.length && (n(r, i.slice()), i = []);
|
|
1881
1905
|
const d = typeof a == "string" ? a : a.id;
|
|
1882
1906
|
let c = e.get(d);
|
|
1883
1907
|
c || (c = {
|
|
@@ -1885,44 +1909,44 @@ function ye(s) {
|
|
|
1885
1909
|
label: typeof a == "string" ? void 0 : a.label,
|
|
1886
1910
|
columns: [],
|
|
1887
1911
|
firstIndex: l
|
|
1888
|
-
}, e.set(d, c), t.push(c)), c.columns.push(
|
|
1889
|
-
}), i.length && n(
|
|
1912
|
+
}, e.set(d, c), t.push(c)), c.columns.push(o);
|
|
1913
|
+
}), i.length && n(r, i), t.length === 1 && t[0].implicit && t[0].columns.length === s.length ? [] : t;
|
|
1890
1914
|
}
|
|
1891
|
-
function
|
|
1915
|
+
function Rt(s, e, t) {
|
|
1892
1916
|
if (!e.length || !s) return;
|
|
1893
1917
|
const n = /* @__PURE__ */ new Map();
|
|
1894
|
-
for (const
|
|
1895
|
-
for (const
|
|
1896
|
-
|
|
1918
|
+
for (const r of e)
|
|
1919
|
+
for (const o of r.columns)
|
|
1920
|
+
o.field && n.set(o.field, r.id);
|
|
1897
1921
|
const i = Array.from(s.querySelectorAll(".cell[data-field]"));
|
|
1898
|
-
i.forEach((
|
|
1899
|
-
const
|
|
1900
|
-
l && (
|
|
1922
|
+
i.forEach((r) => {
|
|
1923
|
+
const o = r.getAttribute("data-field") || "", l = n.get(o);
|
|
1924
|
+
l && (r.classList.add("grouped"), r.getAttribute("data-group") || r.setAttribute("data-group", l));
|
|
1901
1925
|
});
|
|
1902
|
-
for (const
|
|
1903
|
-
const
|
|
1926
|
+
for (const r of e) {
|
|
1927
|
+
const o = r.columns[r.columns.length - 1], l = i.find((a) => a.getAttribute("data-field") === o.field);
|
|
1904
1928
|
l && l.classList.add("group-end");
|
|
1905
1929
|
}
|
|
1906
1930
|
}
|
|
1907
|
-
function
|
|
1931
|
+
function Et(s, e) {
|
|
1908
1932
|
if (s.length === 0) return null;
|
|
1909
1933
|
const t = document.createElement("div");
|
|
1910
1934
|
t.className = "header-group-row", t.setAttribute("role", "row");
|
|
1911
1935
|
for (const n of s) {
|
|
1912
|
-
const i = n.columns[0],
|
|
1913
|
-
if (
|
|
1914
|
-
const
|
|
1915
|
-
a.className = "cell header-group-cell",
|
|
1936
|
+
const i = n.columns[0], r = i ? e.findIndex((d) => d.field === i.field) : -1;
|
|
1937
|
+
if (r === -1) continue;
|
|
1938
|
+
const o = String(n.id).startsWith("__implicit__"), l = o ? "" : n.label || n.id, a = document.createElement("div");
|
|
1939
|
+
a.className = "cell header-group-cell", o && a.classList.add("implicit-group"), a.setAttribute("data-group", String(n.id)), a.style.gridColumn = `${r + 1} / span ${n.columns.length}`, a.textContent = l, t.appendChild(a);
|
|
1916
1940
|
}
|
|
1917
1941
|
return t;
|
|
1918
1942
|
}
|
|
1919
|
-
function
|
|
1943
|
+
function St(s) {
|
|
1920
1944
|
return s.some((e) => e.group != null);
|
|
1921
1945
|
}
|
|
1922
|
-
const
|
|
1946
|
+
const kt = "@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)}}";
|
|
1923
1947
|
class Vn extends x {
|
|
1924
1948
|
name = "groupingColumns";
|
|
1925
|
-
styles =
|
|
1949
|
+
styles = kt;
|
|
1926
1950
|
get defaultConfig() {
|
|
1927
1951
|
return {
|
|
1928
1952
|
showGroupBorders: !0
|
|
@@ -1946,7 +1970,7 @@ class Vn extends x {
|
|
|
1946
1970
|
if (t?.columnGroups && Array.isArray(t.columnGroups) && t.columnGroups.length > 0)
|
|
1947
1971
|
return !0;
|
|
1948
1972
|
const n = t?.columns;
|
|
1949
|
-
return Array.isArray(n) ?
|
|
1973
|
+
return Array.isArray(n) ? St(n) : !1;
|
|
1950
1974
|
}
|
|
1951
1975
|
// #endregion
|
|
1952
1976
|
// #region Hooks
|
|
@@ -1954,13 +1978,13 @@ class Vn extends x {
|
|
|
1954
1978
|
const t = this.grid?.gridConfig?.columnGroups;
|
|
1955
1979
|
let n;
|
|
1956
1980
|
if (t && Array.isArray(t) && t.length > 0) {
|
|
1957
|
-
const
|
|
1958
|
-
for (const
|
|
1959
|
-
for (const l of
|
|
1960
|
-
|
|
1961
|
-
n = e.map((
|
|
1962
|
-
const l =
|
|
1963
|
-
return l && !
|
|
1981
|
+
const r = /* @__PURE__ */ new Map();
|
|
1982
|
+
for (const o of t)
|
|
1983
|
+
for (const l of o.children)
|
|
1984
|
+
r.set(l, { id: o.id, label: o.header });
|
|
1985
|
+
n = e.map((o) => {
|
|
1986
|
+
const l = r.get(o.field);
|
|
1987
|
+
return l && !o.group ? { ...o, group: l } : o;
|
|
1964
1988
|
});
|
|
1965
1989
|
} else
|
|
1966
1990
|
n = [...e];
|
|
@@ -1969,24 +1993,43 @@ class Vn extends x {
|
|
|
1969
1993
|
}
|
|
1970
1994
|
afterRender() {
|
|
1971
1995
|
if (!this.isActive) {
|
|
1972
|
-
const a = this.
|
|
1996
|
+
const a = this.gridElement?.querySelector(".header")?.querySelector(".header-group-row");
|
|
1973
1997
|
a && a.remove();
|
|
1974
1998
|
return;
|
|
1975
1999
|
}
|
|
1976
|
-
const e = this.
|
|
2000
|
+
const e = this.gridElement?.querySelector(".header");
|
|
1977
2001
|
if (!e) return;
|
|
1978
2002
|
const t = e.querySelector(".header-group-row");
|
|
1979
2003
|
t && t.remove();
|
|
1980
2004
|
const n = this.columns, i = ye(n);
|
|
1981
2005
|
if (i.length === 0) return;
|
|
1982
|
-
const
|
|
1983
|
-
if (
|
|
1984
|
-
|
|
2006
|
+
const r = Et(i, n);
|
|
2007
|
+
if (r) {
|
|
2008
|
+
r.classList.toggle("no-borders", !this.config.showGroupBorders);
|
|
1985
2009
|
const l = e.querySelector(".header-row");
|
|
1986
|
-
l ? e.insertBefore(
|
|
2010
|
+
l ? e.insertBefore(r, l) : e.appendChild(r);
|
|
2011
|
+
}
|
|
2012
|
+
const o = e.querySelector(".header-row");
|
|
2013
|
+
o && (o.classList.toggle("no-group-borders", !this.config.showGroupBorders), Rt(o, i)), this.#e(i);
|
|
2014
|
+
}
|
|
2015
|
+
/**
|
|
2016
|
+
* Apply group-end class to all data cells in the last column of each group.
|
|
2017
|
+
* This extends the strong border separator through all data rows.
|
|
2018
|
+
*/
|
|
2019
|
+
#e(e) {
|
|
2020
|
+
if (!this.config.showGroupBorders) return;
|
|
2021
|
+
const t = this.gridElement;
|
|
2022
|
+
if (!t) return;
|
|
2023
|
+
const n = /* @__PURE__ */ new Set();
|
|
2024
|
+
for (const r of e) {
|
|
2025
|
+
const o = r.columns[r.columns.length - 1];
|
|
2026
|
+
o?.field && n.add(o.field);
|
|
2027
|
+
}
|
|
2028
|
+
const i = t.querySelectorAll(".rows .cell[data-field]");
|
|
2029
|
+
for (const r of i) {
|
|
2030
|
+
const o = r.getAttribute("data-field");
|
|
2031
|
+
o && n.has(o) ? r.classList.add("group-end") : r.classList.remove("group-end");
|
|
1987
2032
|
}
|
|
1988
|
-
const r = e.querySelector(".header-row");
|
|
1989
|
-
r && (r.classList.toggle("no-group-borders", !this.config.showGroupBorders), Ct(r, i));
|
|
1990
2033
|
}
|
|
1991
2034
|
// #endregion
|
|
1992
2035
|
// #region Public API
|
|
@@ -2021,7 +2064,7 @@ class Vn extends x {
|
|
|
2021
2064
|
}
|
|
2022
2065
|
// #endregion
|
|
2023
2066
|
}
|
|
2024
|
-
function
|
|
2067
|
+
function At({ rows: s, config: e, expanded: t }) {
|
|
2025
2068
|
const n = e.groupOn;
|
|
2026
2069
|
if (typeof n != "function")
|
|
2027
2070
|
return [];
|
|
@@ -2037,43 +2080,43 @@ function kt({ rows: s, config: e, expanded: t }) {
|
|
|
2037
2080
|
}), d.rows.push(l);
|
|
2038
2081
|
}), i.children.size === 1 && i.children.has("__ungrouped__") && i.children.get("__ungrouped__").rows.length === s.length)
|
|
2039
2082
|
return [];
|
|
2040
|
-
const
|
|
2083
|
+
const r = [], o = (l) => {
|
|
2041
2084
|
if (l === i) {
|
|
2042
|
-
l.children.forEach((d) =>
|
|
2085
|
+
l.children.forEach((d) => o(d));
|
|
2043
2086
|
return;
|
|
2044
2087
|
}
|
|
2045
2088
|
const a = t.has(l.key);
|
|
2046
|
-
|
|
2089
|
+
r.push({
|
|
2047
2090
|
kind: "group",
|
|
2048
2091
|
key: l.key,
|
|
2049
2092
|
value: l.value,
|
|
2050
2093
|
depth: l.depth,
|
|
2051
2094
|
rows: l.rows,
|
|
2052
2095
|
expanded: a
|
|
2053
|
-
}), a && (l.children.size ? l.children.forEach((d) =>
|
|
2096
|
+
}), a && (l.children.size ? l.children.forEach((d) => o(d)) : l.rows.forEach((d) => r.push({ kind: "data", row: d, rowIndex: s.indexOf(d) })));
|
|
2054
2097
|
};
|
|
2055
|
-
return
|
|
2098
|
+
return o(i), r;
|
|
2056
2099
|
}
|
|
2057
|
-
function
|
|
2100
|
+
function _t(s, e) {
|
|
2058
2101
|
const t = new Set(s);
|
|
2059
2102
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
2060
2103
|
}
|
|
2061
|
-
function
|
|
2104
|
+
function Lt(s) {
|
|
2062
2105
|
const e = /* @__PURE__ */ new Set();
|
|
2063
2106
|
for (const t of s)
|
|
2064
2107
|
t.kind === "group" && e.add(t.key);
|
|
2065
2108
|
return e;
|
|
2066
2109
|
}
|
|
2067
|
-
function
|
|
2110
|
+
function Tt() {
|
|
2068
2111
|
return /* @__PURE__ */ new Set();
|
|
2069
2112
|
}
|
|
2070
|
-
function
|
|
2113
|
+
function It(s) {
|
|
2071
2114
|
return s.kind !== "group" ? 0 : s.rows.length;
|
|
2072
2115
|
}
|
|
2073
|
-
const
|
|
2074
|
-
class
|
|
2116
|
+
const Ft = "@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}}}";
|
|
2117
|
+
class Wn extends x {
|
|
2075
2118
|
name = "groupingRows";
|
|
2076
|
-
styles =
|
|
2119
|
+
styles = Ft;
|
|
2077
2120
|
get defaultConfig() {
|
|
2078
2121
|
return {
|
|
2079
2122
|
defaultExpanded: !1,
|
|
@@ -2116,7 +2159,7 @@ class zn extends x {
|
|
|
2116
2159
|
const t = this.config;
|
|
2117
2160
|
if (typeof t.groupOn != "function")
|
|
2118
2161
|
return this.isActive = !1, this.flattenedRows = [], [...e];
|
|
2119
|
-
const n =
|
|
2162
|
+
const n = At({
|
|
2120
2163
|
rows: [...e],
|
|
2121
2164
|
config: t,
|
|
2122
2165
|
expanded: this.expandedKeys
|
|
@@ -2125,20 +2168,20 @@ class zn extends x {
|
|
|
2125
2168
|
return this.isActive = !1, this.flattenedRows = [], [...e];
|
|
2126
2169
|
this.isActive = !0, this.flattenedRows = n, this.keysToAnimate.clear();
|
|
2127
2170
|
const i = /* @__PURE__ */ new Set();
|
|
2128
|
-
return n.forEach((
|
|
2129
|
-
if (
|
|
2130
|
-
const l = `data-${
|
|
2171
|
+
return n.forEach((r, o) => {
|
|
2172
|
+
if (r.kind === "data") {
|
|
2173
|
+
const l = `data-${o}`;
|
|
2131
2174
|
i.add(l), this.previousVisibleKeys.has(l) || this.keysToAnimate.add(l);
|
|
2132
2175
|
}
|
|
2133
|
-
}), this.previousVisibleKeys = i, n.map((
|
|
2176
|
+
}), this.previousVisibleKeys = i, n.map((r) => r.kind === "group" ? {
|
|
2134
2177
|
__isGroupRow: !0,
|
|
2135
|
-
__groupKey:
|
|
2136
|
-
__groupValue:
|
|
2137
|
-
__groupDepth:
|
|
2138
|
-
__groupRows:
|
|
2139
|
-
__groupExpanded:
|
|
2140
|
-
__groupRowCount:
|
|
2141
|
-
} :
|
|
2178
|
+
__groupKey: r.key,
|
|
2179
|
+
__groupValue: r.value,
|
|
2180
|
+
__groupDepth: r.depth,
|
|
2181
|
+
__groupRows: r.rows,
|
|
2182
|
+
__groupExpanded: r.expanded,
|
|
2183
|
+
__groupRowCount: It(r)
|
|
2184
|
+
} : r.row);
|
|
2142
2185
|
}
|
|
2143
2186
|
onCellClick(e) {
|
|
2144
2187
|
const t = e.row;
|
|
@@ -2172,19 +2215,19 @@ class zn extends x {
|
|
|
2172
2215
|
if (a)
|
|
2173
2216
|
return t.className = "data-grid-row group-row", t.__isCustomRow = !0, t.setAttribute("data-group-depth", String(e.__groupDepth)), typeof a == "string" ? t.innerHTML = a : (t.innerHTML = "", t.appendChild(a)), !0;
|
|
2174
2217
|
}
|
|
2175
|
-
const
|
|
2218
|
+
const r = () => {
|
|
2176
2219
|
this.toggle(e.__groupKey);
|
|
2177
2220
|
};
|
|
2178
|
-
return t.className = "data-grid-row group-row", t.__isCustomRow = !0, t.setAttribute("data-group-depth", String(e.__groupDepth)), t.setAttribute("role", "row"), t.setAttribute("aria-expanded", String(e.__groupExpanded)), t.style.
|
|
2221
|
+
return t.className = "data-grid-row group-row", t.__isCustomRow = !0, t.setAttribute("data-group-depth", String(e.__groupDepth)), t.setAttribute("role", "row"), t.setAttribute("aria-expanded", String(e.__groupExpanded)), t.style.setProperty("--tbw-group-depth", String(e.__groupDepth || 0)), i.indentWidth !== void 0 && t.style.setProperty("--tbw-group-indent-width", `${i.indentWidth}px`), t.innerHTML = "", i.fullWidth !== !1 ? this.renderFullWidthGroupRow(e, t, r) : this.renderPerColumnGroupRow(e, t, r), !0;
|
|
2179
2222
|
}
|
|
2180
2223
|
afterRender() {
|
|
2181
2224
|
const e = this.animationStyle;
|
|
2182
2225
|
if (e === !1 || this.keysToAnimate.size === 0) return;
|
|
2183
|
-
const t = this.
|
|
2226
|
+
const t = this.gridElement?.querySelector(".rows");
|
|
2184
2227
|
if (!t) return;
|
|
2185
2228
|
const n = e === "fade" ? "tbw-group-fade-in" : "tbw-group-slide-in";
|
|
2186
2229
|
for (const i of t.querySelectorAll(".data-grid-row:not(.group-row)")) {
|
|
2187
|
-
const
|
|
2230
|
+
const r = i.querySelector(".cell[data-row]"), o = r ? parseInt(r.getAttribute("data-row") ?? "-1", 10) : -1, a = this.flattenedRows[o]?.kind === "data" ? `data-${o}` : void 0;
|
|
2188
2231
|
a && this.keysToAnimate.has(a) && (i.classList.add(n), i.addEventListener("animationend", () => i.classList.remove(n), { once: !0 }));
|
|
2189
2232
|
}
|
|
2190
2233
|
this.keysToAnimate.clear();
|
|
@@ -2208,43 +2251,43 @@ class zn extends x {
|
|
|
2208
2251
|
return i.formatLabel ? i.formatLabel(e, t, n) : String(e);
|
|
2209
2252
|
}
|
|
2210
2253
|
renderFullWidthGroupRow(e, t, n) {
|
|
2211
|
-
const i = this.config,
|
|
2212
|
-
|
|
2213
|
-
const
|
|
2214
|
-
if (
|
|
2254
|
+
const i = this.config, r = document.createElement("div");
|
|
2255
|
+
r.className = "cell group-full", r.style.gridColumn = "1 / -1", r.setAttribute("role", "gridcell"), r.setAttribute("data-col", "0"), r.appendChild(this.createToggleButton(e.__groupExpanded, n));
|
|
2256
|
+
const o = document.createElement("span");
|
|
2257
|
+
if (o.className = "group-label", o.textContent = this.getGroupLabelText(e.__groupValue, e.__groupDepth || 0, e.__groupKey), r.appendChild(o), i.showRowCount !== !1) {
|
|
2215
2258
|
const l = document.createElement("span");
|
|
2216
|
-
l.className = "group-count", l.textContent = `(${e.__groupRowCount ?? e.__groupRows?.length ?? 0})`,
|
|
2259
|
+
l.className = "group-count", l.textContent = `(${e.__groupRowCount ?? e.__groupRows?.length ?? 0})`, r.appendChild(l);
|
|
2217
2260
|
}
|
|
2218
|
-
t.appendChild(
|
|
2261
|
+
t.appendChild(r);
|
|
2219
2262
|
}
|
|
2220
2263
|
renderPerColumnGroupRow(e, t, n) {
|
|
2221
|
-
const i = this.config,
|
|
2264
|
+
const i = this.config, r = i.aggregators ?? {}, o = this.columns, l = e.__groupRows ?? [], d = this.gridElement?.querySelector(".body")?.style.gridTemplateColumns || "";
|
|
2222
2265
|
d && (t.style.display = "grid", t.style.gridTemplateColumns = d);
|
|
2223
2266
|
let c = !1;
|
|
2224
|
-
|
|
2267
|
+
o.forEach((u, h) => {
|
|
2225
2268
|
const f = document.createElement("div");
|
|
2226
|
-
if (f.className = "cell group-cell", f.setAttribute("data-col", String(h)), f.setAttribute("role", "gridcell"),
|
|
2269
|
+
if (f.className = "cell group-cell", f.setAttribute("data-col", String(h)), f.setAttribute("role", "gridcell"), ne(u)) {
|
|
2227
2270
|
f.setAttribute("data-field", u.field), t.appendChild(f);
|
|
2228
2271
|
return;
|
|
2229
2272
|
}
|
|
2230
2273
|
if (c) {
|
|
2231
|
-
const g =
|
|
2274
|
+
const g = r[u.field];
|
|
2232
2275
|
if (g) {
|
|
2233
|
-
const p =
|
|
2276
|
+
const p = ae(g, l, u.field, u);
|
|
2234
2277
|
f.textContent = p != null ? String(p) : "";
|
|
2235
2278
|
} else
|
|
2236
2279
|
f.textContent = "";
|
|
2237
2280
|
} else {
|
|
2238
2281
|
c = !0, f.appendChild(this.createToggleButton(e.__groupExpanded, n));
|
|
2239
|
-
const g = document.createElement("span"), p =
|
|
2282
|
+
const g = document.createElement("span"), p = r[u.field];
|
|
2240
2283
|
if (p) {
|
|
2241
|
-
const
|
|
2242
|
-
g.textContent =
|
|
2284
|
+
const w = ae(p, l, u.field, u);
|
|
2285
|
+
g.textContent = w != null ? String(w) : String(e.__groupValue);
|
|
2243
2286
|
} else
|
|
2244
2287
|
g.textContent = this.getGroupLabelText(e.__groupValue, e.__groupDepth || 0, e.__groupKey);
|
|
2245
2288
|
if (f.appendChild(g), i.showRowCount !== !1) {
|
|
2246
|
-
const
|
|
2247
|
-
|
|
2289
|
+
const w = document.createElement("span");
|
|
2290
|
+
w.className = "group-count", w.textContent = ` (${l.length})`, f.appendChild(w);
|
|
2248
2291
|
}
|
|
2249
2292
|
}
|
|
2250
2293
|
t.appendChild(f);
|
|
@@ -2256,20 +2299,20 @@ class zn extends x {
|
|
|
2256
2299
|
* Expand all groups.
|
|
2257
2300
|
*/
|
|
2258
2301
|
expandAll() {
|
|
2259
|
-
this.expandedKeys =
|
|
2302
|
+
this.expandedKeys = Lt(this.flattenedRows), this.requestRender();
|
|
2260
2303
|
}
|
|
2261
2304
|
/**
|
|
2262
2305
|
* Collapse all groups.
|
|
2263
2306
|
*/
|
|
2264
2307
|
collapseAll() {
|
|
2265
|
-
this.expandedKeys =
|
|
2308
|
+
this.expandedKeys = Tt(), this.requestRender();
|
|
2266
2309
|
}
|
|
2267
2310
|
/**
|
|
2268
2311
|
* Toggle expansion of a specific group.
|
|
2269
2312
|
* @param key - The group key to toggle
|
|
2270
2313
|
*/
|
|
2271
2314
|
toggle(e) {
|
|
2272
|
-
this.expandedKeys =
|
|
2315
|
+
this.expandedKeys = _t(this.expandedKeys, e);
|
|
2273
2316
|
const t = this.flattenedRows.find((n) => n.kind === "group" && n.key === e);
|
|
2274
2317
|
this.emit("group-toggle", {
|
|
2275
2318
|
key: e,
|
|
@@ -2360,33 +2403,33 @@ class zn extends x {
|
|
|
2360
2403
|
}
|
|
2361
2404
|
// #endregion
|
|
2362
2405
|
}
|
|
2363
|
-
function
|
|
2406
|
+
function Ce(s, e) {
|
|
2364
2407
|
const t = new Set(s);
|
|
2365
2408
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
2366
2409
|
}
|
|
2367
|
-
function
|
|
2410
|
+
function Mt(s, e) {
|
|
2368
2411
|
const t = new Set(s);
|
|
2369
2412
|
return t.add(e), t;
|
|
2370
2413
|
}
|
|
2371
|
-
function
|
|
2414
|
+
function Pt(s, e) {
|
|
2372
2415
|
const t = new Set(s);
|
|
2373
2416
|
return t.delete(e), t;
|
|
2374
2417
|
}
|
|
2375
|
-
function
|
|
2418
|
+
function Dt(s, e) {
|
|
2376
2419
|
return s.has(e);
|
|
2377
2420
|
}
|
|
2378
|
-
function
|
|
2421
|
+
function Kt(s, e, t, n) {
|
|
2379
2422
|
const i = document.createElement("div");
|
|
2380
2423
|
i.className = "master-detail-row", i.setAttribute("data-detail-for", String(e)), i.setAttribute("role", "row");
|
|
2381
|
-
const
|
|
2382
|
-
|
|
2383
|
-
const
|
|
2384
|
-
return typeof
|
|
2424
|
+
const r = document.createElement("div");
|
|
2425
|
+
r.className = "master-detail-cell", r.setAttribute("role", "cell"), r.style.gridColumn = `1 / ${n + 1}`;
|
|
2426
|
+
const o = t(s, e);
|
|
2427
|
+
return typeof o == "string" ? r.innerHTML = o : o instanceof HTMLElement && r.appendChild(o), i.appendChild(r), i;
|
|
2385
2428
|
}
|
|
2386
|
-
const
|
|
2429
|
+
const qt = "@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}}}";
|
|
2387
2430
|
class Ge extends x {
|
|
2388
2431
|
name = "masterDetail";
|
|
2389
|
-
styles =
|
|
2432
|
+
styles = qt;
|
|
2390
2433
|
get defaultConfig() {
|
|
2391
2434
|
return {
|
|
2392
2435
|
detailHeight: "auto",
|
|
@@ -2440,8 +2483,8 @@ class Ge extends x {
|
|
|
2440
2483
|
return;
|
|
2441
2484
|
}
|
|
2442
2485
|
}
|
|
2443
|
-
const i = t.getAttribute("animation"),
|
|
2444
|
-
i !== null && (d.animation = i === "false" ? !1 : i),
|
|
2486
|
+
const i = t.getAttribute("animation"), r = t.getAttribute("show-expand-column"), o = t.getAttribute("expand-on-row-click"), l = t.getAttribute("collapse-on-click-outside"), a = t.getAttribute("height"), d = {};
|
|
2487
|
+
i !== null && (d.animation = i === "false" ? !1 : i), r !== null && (d.showExpandColumn = r !== "false"), o !== null && (d.expandOnRowClick = o === "true"), l !== null && (d.collapseOnClickOutside = l === "true"), a !== null && (d.detailHeight = a === "auto" ? "auto" : parseInt(a, 10));
|
|
2445
2488
|
const c = t.innerHTML.trim();
|
|
2446
2489
|
c && !this.config.detailRenderer && (d.detailRenderer = (u, h) => {
|
|
2447
2490
|
const f = je(c, { value: u, row: u });
|
|
@@ -2500,7 +2543,7 @@ class Ge extends x {
|
|
|
2500
2543
|
* Toggle a row's detail and emit event.
|
|
2501
2544
|
*/
|
|
2502
2545
|
toggleAndEmit(e, t) {
|
|
2503
|
-
this.expandedRows =
|
|
2546
|
+
this.expandedRows = Ce(this.expandedRows, e), this.emit("detail-expand", {
|
|
2504
2547
|
rowIndex: t,
|
|
2505
2548
|
row: e,
|
|
2506
2549
|
expanded: this.expandedRows.has(e)
|
|
@@ -2520,8 +2563,8 @@ class Ge extends x {
|
|
|
2520
2563
|
if (Qe(t))
|
|
2521
2564
|
return t;
|
|
2522
2565
|
const i = et(this.name);
|
|
2523
|
-
return i.viewRenderer = (
|
|
2524
|
-
const { row:
|
|
2566
|
+
return i.viewRenderer = (r) => {
|
|
2567
|
+
const { row: o } = r, l = this.expandedRows.has(o), a = document.createElement("span");
|
|
2525
2568
|
a.className = "master-detail-expander expander-cell";
|
|
2526
2569
|
const d = document.createElement("span");
|
|
2527
2570
|
return d.className = `master-detail-toggle${l ? " expanded" : ""}`, this.setIcon(d, this.resolveIcon(l ? "collapse" : "expand")), d.setAttribute("role", "button"), d.setAttribute("tabindex", "0"), d.setAttribute("aria-expanded", String(l)), d.setAttribute("aria-label", l ? "Collapse details" : "Expand details"), a.appendChild(d), a;
|
|
@@ -2539,10 +2582,10 @@ class Ge extends x {
|
|
|
2539
2582
|
onKeyDown(e) {
|
|
2540
2583
|
if (e.key !== " ") return;
|
|
2541
2584
|
const t = this.grid._focusCol, n = this.grid._focusRow, i = this.columns[t];
|
|
2542
|
-
if (!i || !
|
|
2543
|
-
const
|
|
2544
|
-
if (
|
|
2545
|
-
return e.preventDefault(), this.toggleAndEmit(
|
|
2585
|
+
if (!i || !ne(i)) return;
|
|
2586
|
+
const r = this.rows[n];
|
|
2587
|
+
if (r)
|
|
2588
|
+
return e.preventDefault(), this.toggleAndEmit(r, n), this.requestRenderWithFocus(), !0;
|
|
2546
2589
|
}
|
|
2547
2590
|
afterRender() {
|
|
2548
2591
|
this.#e();
|
|
@@ -2560,27 +2603,27 @@ class Ge extends x {
|
|
|
2560
2603
|
*/
|
|
2561
2604
|
#e() {
|
|
2562
2605
|
if (!this.config.detailRenderer) return;
|
|
2563
|
-
const e = this.
|
|
2606
|
+
const e = this.gridElement?.querySelector(".rows");
|
|
2564
2607
|
if (!e) return;
|
|
2565
2608
|
const t = /* @__PURE__ */ new Map(), n = e.querySelectorAll(".data-grid-row"), i = this.columns.length;
|
|
2566
|
-
for (const
|
|
2567
|
-
const l =
|
|
2568
|
-
a >= 0 && t.set(a,
|
|
2609
|
+
for (const o of n) {
|
|
2610
|
+
const l = o.querySelector(".cell[data-row]"), a = l ? parseInt(l.getAttribute("data-row") ?? "-1", 10) : -1;
|
|
2611
|
+
a >= 0 && t.set(a, o);
|
|
2569
2612
|
}
|
|
2570
|
-
const
|
|
2571
|
-
for (const
|
|
2572
|
-
const l = parseInt(
|
|
2573
|
-
(!d || !c) && (
|
|
2613
|
+
const r = e.querySelectorAll(".master-detail-row");
|
|
2614
|
+
for (const o of r) {
|
|
2615
|
+
const l = parseInt(o.getAttribute("data-detail-for") ?? "-1", 10), a = l >= 0 ? this.rows[l] : void 0, d = a && this.expandedRows.has(a), c = t.has(l);
|
|
2616
|
+
(!d || !c) && (o.remove(), a && this.detailElements.delete(a));
|
|
2574
2617
|
}
|
|
2575
|
-
for (const [
|
|
2576
|
-
const a = this.rows[
|
|
2618
|
+
for (const [o, l] of t) {
|
|
2619
|
+
const a = this.rows[o];
|
|
2577
2620
|
if (!a || !this.expandedRows.has(a)) continue;
|
|
2578
2621
|
const d = this.detailElements.get(a);
|
|
2579
2622
|
if (d) {
|
|
2580
2623
|
d.previousElementSibling !== l && l.after(d);
|
|
2581
2624
|
continue;
|
|
2582
2625
|
}
|
|
2583
|
-
const c =
|
|
2626
|
+
const c = Kt(a, o, this.config.detailRenderer, i);
|
|
2584
2627
|
typeof this.config.detailHeight == "number" && (c.style.height = `${this.config.detailHeight}px`), l.after(c), this.detailElements.set(a, c), this.animateExpand(c);
|
|
2585
2628
|
}
|
|
2586
2629
|
}
|
|
@@ -2618,12 +2661,12 @@ class Ge extends x {
|
|
|
2618
2661
|
a >= 0 && i.push({ index: a, row: l });
|
|
2619
2662
|
}
|
|
2620
2663
|
i.sort((l, a) => l.index - a.index);
|
|
2621
|
-
let
|
|
2664
|
+
let r = e, o = 0;
|
|
2622
2665
|
for (const { index: l, row: a } of i) {
|
|
2623
|
-
const d = l * n +
|
|
2624
|
-
|
|
2666
|
+
const d = l * n + o, c = this.getDetailHeight(a), u = d + n + c;
|
|
2667
|
+
o += c, !(l >= e) && u > t && l < r && (r = l);
|
|
2625
2668
|
}
|
|
2626
|
-
return
|
|
2669
|
+
return r;
|
|
2627
2670
|
}
|
|
2628
2671
|
// #endregion
|
|
2629
2672
|
// #region Public API
|
|
@@ -2633,7 +2676,7 @@ class Ge extends x {
|
|
|
2633
2676
|
*/
|
|
2634
2677
|
expand(e) {
|
|
2635
2678
|
const t = this.rows[e];
|
|
2636
|
-
t && (this.expandedRows =
|
|
2679
|
+
t && (this.expandedRows = Mt(this.expandedRows, t), this.requestRender());
|
|
2637
2680
|
}
|
|
2638
2681
|
/**
|
|
2639
2682
|
* Collapse the detail row at the given index.
|
|
@@ -2641,7 +2684,7 @@ class Ge extends x {
|
|
|
2641
2684
|
*/
|
|
2642
2685
|
collapse(e) {
|
|
2643
2686
|
const t = this.rows[e];
|
|
2644
|
-
t && (this.expandedRows =
|
|
2687
|
+
t && (this.expandedRows = Pt(this.expandedRows, t), this.requestRender());
|
|
2645
2688
|
}
|
|
2646
2689
|
/**
|
|
2647
2690
|
* Toggle the detail row at the given index.
|
|
@@ -2649,7 +2692,7 @@ class Ge extends x {
|
|
|
2649
2692
|
*/
|
|
2650
2693
|
toggle(e) {
|
|
2651
2694
|
const t = this.rows[e];
|
|
2652
|
-
t && (this.expandedRows =
|
|
2695
|
+
t && (this.expandedRows = Ce(this.expandedRows, t), this.requestRender());
|
|
2653
2696
|
}
|
|
2654
2697
|
/**
|
|
2655
2698
|
* Check if the detail row at the given index is expanded.
|
|
@@ -2658,7 +2701,7 @@ class Ge extends x {
|
|
|
2658
2701
|
*/
|
|
2659
2702
|
isExpanded(e) {
|
|
2660
2703
|
const t = this.rows[e];
|
|
2661
|
-
return t ?
|
|
2704
|
+
return t ? Dt(this.expandedRows, t) : !1;
|
|
2662
2705
|
}
|
|
2663
2706
|
/**
|
|
2664
2707
|
* Expand all detail rows.
|
|
@@ -2711,34 +2754,34 @@ class Ge extends x {
|
|
|
2711
2754
|
}
|
|
2712
2755
|
// #endregion
|
|
2713
2756
|
}
|
|
2714
|
-
function
|
|
2757
|
+
function Nt(s, e, t) {
|
|
2715
2758
|
return e.length ? [...s].sort((n, i) => {
|
|
2716
|
-
for (const
|
|
2717
|
-
const l = t.find((u) => u.field ===
|
|
2759
|
+
for (const r of e) {
|
|
2760
|
+
const l = t.find((u) => u.field === r.field)?.sortComparator ?? Ht, a = n[r.field], d = i[r.field], c = l(a, d, n, i);
|
|
2718
2761
|
if (c !== 0)
|
|
2719
|
-
return
|
|
2762
|
+
return r.direction === "asc" ? c : -c;
|
|
2720
2763
|
}
|
|
2721
2764
|
return 0;
|
|
2722
2765
|
}) : [...s];
|
|
2723
2766
|
}
|
|
2724
|
-
function
|
|
2767
|
+
function Ht(s, e) {
|
|
2725
2768
|
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));
|
|
2726
2769
|
}
|
|
2727
|
-
function
|
|
2728
|
-
const i = s.find((
|
|
2729
|
-
return t ? i ? i.direction === "asc" ? s.map((
|
|
2770
|
+
function zt(s, e, t, n) {
|
|
2771
|
+
const i = s.find((r) => r.field === e);
|
|
2772
|
+
return t ? i ? i.direction === "asc" ? s.map((r) => r.field === e ? { ...r, direction: "desc" } : r) : s.filter((r) => r.field !== e) : s.length < n ? [...s, { field: e, direction: "asc" }] : s : i?.direction === "asc" ? [{ field: e, direction: "desc" }] : i?.direction === "desc" ? [] : [{ field: e, direction: "asc" }];
|
|
2730
2773
|
}
|
|
2731
|
-
function
|
|
2774
|
+
function xe(s, e) {
|
|
2732
2775
|
const t = s.findIndex((n) => n.field === e);
|
|
2733
2776
|
return t >= 0 ? t + 1 : void 0;
|
|
2734
2777
|
}
|
|
2735
2778
|
function Re(s, e) {
|
|
2736
2779
|
return s.find((t) => t.field === e)?.direction;
|
|
2737
2780
|
}
|
|
2738
|
-
const
|
|
2739
|
-
class
|
|
2781
|
+
const Gt = '@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}}';
|
|
2782
|
+
class $n extends x {
|
|
2740
2783
|
name = "multiSort";
|
|
2741
|
-
styles =
|
|
2784
|
+
styles = Gt;
|
|
2742
2785
|
get defaultConfig() {
|
|
2743
2786
|
return {
|
|
2744
2787
|
maxSortColumns: 3,
|
|
@@ -2755,29 +2798,29 @@ class Wn extends x {
|
|
|
2755
2798
|
// #endregion
|
|
2756
2799
|
// #region Hooks
|
|
2757
2800
|
processRows(e) {
|
|
2758
|
-
return this.sortModel.length === 0 ? [...e] :
|
|
2801
|
+
return this.sortModel.length === 0 ? [...e] : Nt([...e], this.sortModel, [...this.columns]);
|
|
2759
2802
|
}
|
|
2760
2803
|
onHeaderClick(e) {
|
|
2761
|
-
if (!this.columns.find((
|
|
2804
|
+
if (!this.columns.find((r) => r.field === e.field)?.sortable) return !1;
|
|
2762
2805
|
const n = e.originalEvent.shiftKey, i = this.config.maxSortColumns ?? 3;
|
|
2763
|
-
return this.sortModel =
|
|
2806
|
+
return this.sortModel = zt(this.sortModel, e.field, n, i), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), !0;
|
|
2764
2807
|
}
|
|
2765
2808
|
afterRender() {
|
|
2766
|
-
const e = this.
|
|
2809
|
+
const e = this.gridElement;
|
|
2767
2810
|
if (!e) return;
|
|
2768
2811
|
const t = this.config.showSortIndex !== !1;
|
|
2769
2812
|
e.querySelectorAll(".header-row .cell[data-field]").forEach((i) => {
|
|
2770
|
-
const
|
|
2771
|
-
if (!
|
|
2772
|
-
const
|
|
2813
|
+
const r = i.getAttribute("data-field");
|
|
2814
|
+
if (!r) return;
|
|
2815
|
+
const o = xe(this.sortModel, r), l = Re(this.sortModel, r);
|
|
2773
2816
|
if (i.querySelector(".sort-index")?.remove(), l) {
|
|
2774
2817
|
i.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), i.setAttribute("data-sort", l);
|
|
2775
2818
|
const c = document.createElement("span");
|
|
2776
2819
|
c.className = "sort-indicator", this.setIcon(c, this.resolveIcon(l === "asc" ? "sortAsc" : "sortDesc"));
|
|
2777
2820
|
const u = i.querySelector(".tbw-filter-btn"), h = i.querySelector(".resize-handle"), f = u ?? h;
|
|
2778
|
-
if (f ? i.insertBefore(c, f) : i.appendChild(c), t && this.sortModel.length > 1 &&
|
|
2821
|
+
if (f ? i.insertBefore(c, f) : i.appendChild(c), t && this.sortModel.length > 1 && o !== void 0) {
|
|
2779
2822
|
const g = document.createElement("span");
|
|
2780
|
-
g.className = "sort-index", g.textContent = String(
|
|
2823
|
+
g.className = "sort-index", g.textContent = String(o), c.nextSibling ? i.insertBefore(g, c.nextSibling) : i.appendChild(g);
|
|
2781
2824
|
}
|
|
2782
2825
|
} else
|
|
2783
2826
|
i.removeAttribute("data-sort");
|
|
@@ -2811,7 +2854,7 @@ class Wn extends x {
|
|
|
2811
2854
|
* @returns 1-based index or undefined if not sorted
|
|
2812
2855
|
*/
|
|
2813
2856
|
getSortIndex(e) {
|
|
2814
|
-
return
|
|
2857
|
+
return xe(this.sortModel, e);
|
|
2815
2858
|
}
|
|
2816
2859
|
/**
|
|
2817
2860
|
* Get the sort direction for a specific field.
|
|
@@ -2841,10 +2884,10 @@ class Wn extends x {
|
|
|
2841
2884
|
*/
|
|
2842
2885
|
applyColumnState(e, t) {
|
|
2843
2886
|
if (!t.sort) {
|
|
2844
|
-
this.sortModel = this.sortModel.filter((
|
|
2887
|
+
this.sortModel = this.sortModel.filter((r) => r.field !== e);
|
|
2845
2888
|
return;
|
|
2846
2889
|
}
|
|
2847
|
-
const n = this.sortModel.findIndex((
|
|
2890
|
+
const n = this.sortModel.findIndex((r) => r.field === e), i = {
|
|
2848
2891
|
field: e,
|
|
2849
2892
|
direction: t.sort.direction
|
|
2850
2893
|
};
|
|
@@ -2852,49 +2895,45 @@ class Wn extends x {
|
|
|
2852
2895
|
}
|
|
2853
2896
|
// #endregion
|
|
2854
2897
|
}
|
|
2855
|
-
function
|
|
2898
|
+
function Ot(s) {
|
|
2856
2899
|
return s.filter((e) => e.sticky === "left");
|
|
2857
2900
|
}
|
|
2858
2901
|
function Bt(s) {
|
|
2859
2902
|
return s.filter((e) => e.sticky === "right");
|
|
2860
2903
|
}
|
|
2861
|
-
function
|
|
2904
|
+
function U(s) {
|
|
2862
2905
|
return s.some((e) => e.sticky === "left" || e.sticky === "right");
|
|
2863
2906
|
}
|
|
2864
2907
|
function Ee(s, e) {
|
|
2865
|
-
const t = s.
|
|
2866
|
-
if (!t) return;
|
|
2867
|
-
const n =
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
e.forEach((l, a) => {
|
|
2871
|
-
l.field && i.set(l.field, a);
|
|
2908
|
+
const t = Array.from(s.querySelectorAll(".header-row .cell"));
|
|
2909
|
+
if (!t.length) return;
|
|
2910
|
+
const n = /* @__PURE__ */ new Map();
|
|
2911
|
+
e.forEach((o, l) => {
|
|
2912
|
+
o.field && n.set(o.field, l);
|
|
2872
2913
|
});
|
|
2873
|
-
let
|
|
2874
|
-
for (const
|
|
2875
|
-
if (
|
|
2876
|
-
const
|
|
2877
|
-
|
|
2878
|
-
|
|
2879
|
-
}),
|
|
2914
|
+
let i = 0;
|
|
2915
|
+
for (const o of e)
|
|
2916
|
+
if (o.sticky === "left") {
|
|
2917
|
+
const l = n.get(o.field), a = t.find((d) => d.getAttribute("data-field") === o.field);
|
|
2918
|
+
a && (a.classList.add("sticky-left"), a.style.position = "sticky", a.style.left = i + "px", l !== void 0 && s.querySelectorAll(`.data-grid-row .cell[data-col="${l}"]`).forEach((d) => {
|
|
2919
|
+
d.classList.add("sticky-left"), d.style.position = "sticky", d.style.left = i + "px";
|
|
2920
|
+
}), i += a.offsetWidth);
|
|
2880
2921
|
}
|
|
2881
2922
|
let r = 0;
|
|
2882
|
-
for (const
|
|
2883
|
-
if (
|
|
2884
|
-
const
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
}), r +=
|
|
2923
|
+
for (const o of [...e].reverse())
|
|
2924
|
+
if (o.sticky === "right") {
|
|
2925
|
+
const l = n.get(o.field), a = t.find((d) => d.getAttribute("data-field") === o.field);
|
|
2926
|
+
a && (a.classList.add("sticky-right"), a.style.position = "sticky", a.style.right = r + "px", l !== void 0 && s.querySelectorAll(`.data-grid-row .cell[data-col="${l}"]`).forEach((d) => {
|
|
2927
|
+
d.classList.add("sticky-right"), d.style.position = "sticky", d.style.right = r + "px";
|
|
2928
|
+
}), r += a.offsetWidth);
|
|
2888
2929
|
}
|
|
2889
2930
|
}
|
|
2890
2931
|
function Se(s) {
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
e.querySelectorAll(".sticky-left, .sticky-right").forEach((n) => {
|
|
2894
|
-
n.classList.remove("sticky-left", "sticky-right"), n.style.position = "", n.style.left = "", n.style.right = "";
|
|
2932
|
+
s.querySelectorAll(".sticky-left, .sticky-right").forEach((t) => {
|
|
2933
|
+
t.classList.remove("sticky-left", "sticky-right"), t.style.position = "", t.style.left = "", t.style.right = "";
|
|
2895
2934
|
});
|
|
2896
2935
|
}
|
|
2897
|
-
class
|
|
2936
|
+
class jn extends x {
|
|
2898
2937
|
name = "pinnedColumns";
|
|
2899
2938
|
get defaultConfig() {
|
|
2900
2939
|
return {};
|
|
@@ -2915,18 +2954,18 @@ class $n extends x {
|
|
|
2915
2954
|
*/
|
|
2916
2955
|
static detect(e, t) {
|
|
2917
2956
|
const n = t?.columns;
|
|
2918
|
-
return Array.isArray(n) ?
|
|
2957
|
+
return Array.isArray(n) ? U(n) : !1;
|
|
2919
2958
|
}
|
|
2920
2959
|
// #endregion
|
|
2921
2960
|
// #region Hooks
|
|
2922
2961
|
processColumns(e) {
|
|
2923
|
-
return this.isApplied =
|
|
2962
|
+
return this.isApplied = U([...e]), [...e];
|
|
2924
2963
|
}
|
|
2925
2964
|
afterRender() {
|
|
2926
2965
|
if (!this.isApplied)
|
|
2927
2966
|
return;
|
|
2928
2967
|
const e = this.grid, t = [...this.columns];
|
|
2929
|
-
if (!
|
|
2968
|
+
if (!U(t)) {
|
|
2930
2969
|
Se(e), this.isApplied = !1;
|
|
2931
2970
|
return;
|
|
2932
2971
|
}
|
|
@@ -2964,7 +3003,7 @@ class $n extends x {
|
|
|
2964
3003
|
*/
|
|
2965
3004
|
getLeftPinnedColumns() {
|
|
2966
3005
|
const e = [...this.columns];
|
|
2967
|
-
return
|
|
3006
|
+
return Ot(e);
|
|
2968
3007
|
}
|
|
2969
3008
|
/**
|
|
2970
3009
|
* Get columns pinned to the right.
|
|
@@ -2988,50 +3027,48 @@ class $n extends x {
|
|
|
2988
3027
|
return;
|
|
2989
3028
|
let n = 0, i = 0;
|
|
2990
3029
|
if (e) {
|
|
2991
|
-
const
|
|
2992
|
-
|
|
3030
|
+
const o = e.querySelectorAll(".sticky-left"), l = e.querySelectorAll(".sticky-right");
|
|
3031
|
+
o.forEach((a) => {
|
|
2993
3032
|
n += a.offsetWidth;
|
|
2994
3033
|
}), l.forEach((a) => {
|
|
2995
3034
|
i += a.offsetWidth;
|
|
2996
3035
|
});
|
|
2997
|
-
} else
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
d.classList.contains("sticky-left") ? n += d.offsetWidth : d.classList.contains("sticky-right") && (i += d.offsetWidth);
|
|
3036
|
+
} else
|
|
3037
|
+
this.grid.querySelectorAll(".header-row .cell").forEach((a) => {
|
|
3038
|
+
a.classList.contains("sticky-left") ? n += a.offsetWidth : a.classList.contains("sticky-right") && (i += a.offsetWidth);
|
|
3001
3039
|
});
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
return { left: n, right: i, skipScroll: o };
|
|
3040
|
+
const r = t?.classList.contains("sticky-left") || t?.classList.contains("sticky-right");
|
|
3041
|
+
return { left: n, right: i, skipScroll: r };
|
|
3005
3042
|
}
|
|
3006
3043
|
// #endregion
|
|
3007
3044
|
}
|
|
3008
3045
|
function Vt(s) {
|
|
3009
3046
|
return typeof s == "object" && s !== null && "aggFunc" in s;
|
|
3010
3047
|
}
|
|
3011
|
-
function
|
|
3048
|
+
function Y(s, e) {
|
|
3012
3049
|
const t = document.createElement("div");
|
|
3013
3050
|
t.className = "tbw-pinned-rows", t.setAttribute("role", "presentation"), t.setAttribute("aria-live", "polite");
|
|
3014
3051
|
const n = document.createElement("div");
|
|
3015
3052
|
n.className = "tbw-pinned-rows-left";
|
|
3016
3053
|
const i = document.createElement("div");
|
|
3017
3054
|
i.className = "tbw-pinned-rows-center";
|
|
3018
|
-
const
|
|
3019
|
-
if (
|
|
3020
|
-
const
|
|
3021
|
-
|
|
3055
|
+
const r = document.createElement("div");
|
|
3056
|
+
if (r.className = "tbw-pinned-rows-right", s.showRowCount !== !1) {
|
|
3057
|
+
const o = document.createElement("span");
|
|
3058
|
+
o.className = "tbw-status-panel tbw-status-panel-row-count", o.textContent = `Total: ${e.totalRows} rows`, n.appendChild(o);
|
|
3022
3059
|
}
|
|
3023
3060
|
if (s.showFilteredCount && e.filteredRows !== e.totalRows) {
|
|
3024
|
-
const
|
|
3025
|
-
|
|
3061
|
+
const o = document.createElement("span");
|
|
3062
|
+
o.className = "tbw-status-panel tbw-status-panel-filtered-count", o.textContent = `Filtered: ${e.filteredRows}`, n.appendChild(o);
|
|
3026
3063
|
}
|
|
3027
3064
|
if (s.showSelectedCount && e.selectedRows > 0) {
|
|
3028
|
-
const
|
|
3029
|
-
|
|
3065
|
+
const o = document.createElement("span");
|
|
3066
|
+
o.className = "tbw-status-panel tbw-status-panel-selected-count", o.textContent = `Selected: ${e.selectedRows}`, r.appendChild(o);
|
|
3030
3067
|
}
|
|
3031
3068
|
if (s.customPanels)
|
|
3032
|
-
for (const
|
|
3033
|
-
const l =
|
|
3034
|
-
switch (
|
|
3069
|
+
for (const o of s.customPanels) {
|
|
3070
|
+
const l = Wt(o, e);
|
|
3071
|
+
switch (o.position) {
|
|
3035
3072
|
case "left":
|
|
3036
3073
|
n.appendChild(l);
|
|
3037
3074
|
break;
|
|
@@ -3039,11 +3076,11 @@ function Z(s, e) {
|
|
|
3039
3076
|
i.appendChild(l);
|
|
3040
3077
|
break;
|
|
3041
3078
|
case "right":
|
|
3042
|
-
|
|
3079
|
+
r.appendChild(l);
|
|
3043
3080
|
break;
|
|
3044
3081
|
}
|
|
3045
3082
|
}
|
|
3046
|
-
return t.appendChild(n), t.appendChild(i), t.appendChild(
|
|
3083
|
+
return t.appendChild(n), t.appendChild(i), t.appendChild(r), t;
|
|
3047
3084
|
}
|
|
3048
3085
|
function ke(s) {
|
|
3049
3086
|
const e = document.createElement("div");
|
|
@@ -3052,34 +3089,34 @@ function ke(s) {
|
|
|
3052
3089
|
function Ae(s, e, t, n) {
|
|
3053
3090
|
s.innerHTML = "";
|
|
3054
3091
|
for (const i of e) {
|
|
3055
|
-
const
|
|
3056
|
-
if (
|
|
3057
|
-
const
|
|
3058
|
-
|
|
3092
|
+
const r = document.createElement("div");
|
|
3093
|
+
if (r.className = "tbw-aggregation-row", r.setAttribute("role", "presentation"), i.id && r.setAttribute("data-aggregation-id", i.id), i.fullWidth) {
|
|
3094
|
+
const o = document.createElement("div");
|
|
3095
|
+
o.className = "tbw-aggregation-cell tbw-aggregation-cell-full", o.style.gridColumn = "1 / -1", o.textContent = i.label || "", r.appendChild(o);
|
|
3059
3096
|
} else
|
|
3060
|
-
for (const
|
|
3097
|
+
for (const o of t) {
|
|
3061
3098
|
const l = document.createElement("div");
|
|
3062
|
-
l.className = "tbw-aggregation-cell", l.setAttribute("data-field",
|
|
3099
|
+
l.className = "tbw-aggregation-cell", l.setAttribute("data-field", o.field);
|
|
3063
3100
|
let a, d;
|
|
3064
|
-
const c = i.aggregators?.[
|
|
3101
|
+
const c = i.aggregators?.[o.field];
|
|
3065
3102
|
if (c)
|
|
3066
3103
|
if (Vt(c)) {
|
|
3067
|
-
const u =
|
|
3068
|
-
u && (a = u(n,
|
|
3104
|
+
const u = de(c.aggFunc);
|
|
3105
|
+
u && (a = u(n, o.field, o)), d = c.formatter;
|
|
3069
3106
|
} else {
|
|
3070
|
-
const u =
|
|
3071
|
-
u && (a = u(n,
|
|
3107
|
+
const u = de(c);
|
|
3108
|
+
u && (a = u(n, o.field, o));
|
|
3072
3109
|
}
|
|
3073
|
-
else if (i.cells && Object.prototype.hasOwnProperty.call(i.cells,
|
|
3074
|
-
const u = i.cells[
|
|
3075
|
-
typeof u == "function" ? a = u(n,
|
|
3110
|
+
else if (i.cells && Object.prototype.hasOwnProperty.call(i.cells, o.field)) {
|
|
3111
|
+
const u = i.cells[o.field];
|
|
3112
|
+
typeof u == "function" ? a = u(n, o.field, o) : a = u;
|
|
3076
3113
|
}
|
|
3077
|
-
a != null ? l.textContent = d ? d(a,
|
|
3114
|
+
a != null ? l.textContent = d ? d(a, o.field, o) : String(a) : l.textContent = "", r.appendChild(l);
|
|
3078
3115
|
}
|
|
3079
|
-
s.appendChild(
|
|
3116
|
+
s.appendChild(r);
|
|
3080
3117
|
}
|
|
3081
3118
|
}
|
|
3082
|
-
function
|
|
3119
|
+
function Wt(s, e) {
|
|
3083
3120
|
const t = document.createElement("div");
|
|
3084
3121
|
t.className = "tbw-status-panel tbw-status-panel-custom", t.id = `status-panel-${s.id}`;
|
|
3085
3122
|
const n = s.render(e);
|
|
@@ -3095,10 +3132,10 @@ function _e(s, e, t, n, i) {
|
|
|
3095
3132
|
grid: t
|
|
3096
3133
|
};
|
|
3097
3134
|
}
|
|
3098
|
-
const
|
|
3099
|
-
class
|
|
3135
|
+
const $t = "@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}}";
|
|
3136
|
+
class Un extends x {
|
|
3100
3137
|
name = "pinnedRows";
|
|
3101
|
-
styles =
|
|
3138
|
+
styles = $t;
|
|
3102
3139
|
get defaultConfig() {
|
|
3103
3140
|
return {
|
|
3104
3141
|
position: "bottom",
|
|
@@ -3120,18 +3157,18 @@ class jn extends x {
|
|
|
3120
3157
|
// #endregion
|
|
3121
3158
|
// #region Hooks
|
|
3122
3159
|
afterRender() {
|
|
3123
|
-
const e = this.
|
|
3160
|
+
const e = this.gridElement;
|
|
3124
3161
|
if (!e) return;
|
|
3125
3162
|
const t = e.querySelector(".tbw-scroll-area") ?? e.querySelector(".tbw-grid-content") ?? e.children[0];
|
|
3126
3163
|
if (!t) return;
|
|
3127
3164
|
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);
|
|
3128
|
-
const n = this.getSelectionState(), i = this.getFilterState(),
|
|
3165
|
+
const n = this.getSelectionState(), i = this.getFilterState(), r = _e(
|
|
3129
3166
|
this.rows,
|
|
3130
3167
|
this.columns,
|
|
3131
3168
|
this.grid,
|
|
3132
3169
|
n,
|
|
3133
3170
|
i
|
|
3134
|
-
),
|
|
3171
|
+
), o = this.config.aggregationRows || [], l = o.filter((h) => h.position === "top"), a = o.filter((h) => h.position !== "top");
|
|
3135
3172
|
if (l.length > 0) {
|
|
3136
3173
|
if (!this.topAggregationContainer) {
|
|
3137
3174
|
this.topAggregationContainer = ke("top");
|
|
@@ -3145,12 +3182,12 @@ class jn extends x {
|
|
|
3145
3182
|
this.rows
|
|
3146
3183
|
);
|
|
3147
3184
|
} else this.topAggregationContainer && (this.topAggregationContainer.remove(), this.topAggregationContainer = null);
|
|
3148
|
-
const d = this.config.showRowCount !== !1 || this.config.showSelectedCount &&
|
|
3185
|
+
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 = a.length > 0 || c;
|
|
3149
3186
|
if (d && this.config.position === "top")
|
|
3150
3187
|
if (!this.infoBarElement)
|
|
3151
|
-
this.infoBarElement =
|
|
3188
|
+
this.infoBarElement = Y(this.config, r), t.insertBefore(this.infoBarElement, t.firstChild);
|
|
3152
3189
|
else {
|
|
3153
|
-
const h =
|
|
3190
|
+
const h = Y(this.config, r);
|
|
3154
3191
|
this.infoBarElement.replaceWith(h), this.infoBarElement = h;
|
|
3155
3192
|
}
|
|
3156
3193
|
else this.config.position === "top" && this.infoBarElement && (this.infoBarElement.remove(), this.infoBarElement = null);
|
|
@@ -3159,7 +3196,7 @@ class jn extends x {
|
|
|
3159
3196
|
a,
|
|
3160
3197
|
this.visibleColumns,
|
|
3161
3198
|
this.rows
|
|
3162
|
-
)), c && (this.infoBarElement =
|
|
3199
|
+
)), c && (this.infoBarElement = Y(this.config, r), this.footerWrapper.appendChild(this.infoBarElement))) : this.cleanupFooter();
|
|
3163
3200
|
}
|
|
3164
3201
|
// #endregion
|
|
3165
3202
|
// #region Private Methods
|
|
@@ -3235,29 +3272,29 @@ class jn extends x {
|
|
|
3235
3272
|
}
|
|
3236
3273
|
// #endregion
|
|
3237
3274
|
}
|
|
3238
|
-
const
|
|
3239
|
-
function
|
|
3275
|
+
const jt = Ye;
|
|
3276
|
+
function Ut(s) {
|
|
3240
3277
|
const e = [];
|
|
3241
3278
|
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;
|
|
3242
3279
|
}
|
|
3243
|
-
function
|
|
3280
|
+
function oe(s, e) {
|
|
3244
3281
|
return [...s, e].join("|");
|
|
3245
3282
|
}
|
|
3246
|
-
function
|
|
3247
|
-
const t = e.rowGroupFields ?? [], n = e.columnGroupFields ?? [], i = e.valueFields ?? [],
|
|
3283
|
+
function Yt(s, e) {
|
|
3284
|
+
const t = e.rowGroupFields ?? [], n = e.columnGroupFields ?? [], i = e.valueFields ?? [], r = Xt(s, n), o = Oe(
|
|
3248
3285
|
s,
|
|
3249
3286
|
t,
|
|
3250
3287
|
n,
|
|
3251
|
-
|
|
3288
|
+
r,
|
|
3252
3289
|
i,
|
|
3253
3290
|
0,
|
|
3254
3291
|
// starting depth
|
|
3255
3292
|
""
|
|
3256
3293
|
// parent key prefix
|
|
3257
|
-
), l =
|
|
3294
|
+
), l = Jt(o, r, i), a = Object.values(l).reduce((d, c) => d + c, 0);
|
|
3258
3295
|
return {
|
|
3259
|
-
rows:
|
|
3260
|
-
columnKeys:
|
|
3296
|
+
rows: o,
|
|
3297
|
+
columnKeys: r,
|
|
3261
3298
|
totals: l,
|
|
3262
3299
|
grandTotal: a
|
|
3263
3300
|
};
|
|
@@ -3266,7 +3303,7 @@ function Xt(s, e) {
|
|
|
3266
3303
|
if (e.length === 0) return ["value"];
|
|
3267
3304
|
const t = /* @__PURE__ */ new Set();
|
|
3268
3305
|
for (const n of s) {
|
|
3269
|
-
const i = e.map((
|
|
3306
|
+
const i = e.map((r) => String(n[r] ?? "")).join("|");
|
|
3270
3307
|
t.add(i);
|
|
3271
3308
|
}
|
|
3272
3309
|
return [...t].sort();
|
|
@@ -3274,19 +3311,19 @@ function Xt(s, e) {
|
|
|
3274
3311
|
function Zt(s, e) {
|
|
3275
3312
|
const t = /* @__PURE__ */ new Map();
|
|
3276
3313
|
for (const n of s) {
|
|
3277
|
-
const i = String(n[e] ?? ""),
|
|
3278
|
-
|
|
3314
|
+
const i = String(n[e] ?? ""), r = t.get(i);
|
|
3315
|
+
r ? r.push(n) : t.set(i, [n]);
|
|
3279
3316
|
}
|
|
3280
3317
|
return t;
|
|
3281
3318
|
}
|
|
3282
|
-
function
|
|
3319
|
+
function Oe(s, e, t, n, i, r, o) {
|
|
3283
3320
|
const l = [];
|
|
3284
3321
|
if (e.length === 0) {
|
|
3285
3322
|
const h = Le(s, t, n, i), f = Te(h);
|
|
3286
3323
|
return l.push({
|
|
3287
|
-
rowKey:
|
|
3288
|
-
rowLabel:
|
|
3289
|
-
depth:
|
|
3324
|
+
rowKey: o || "all",
|
|
3325
|
+
rowLabel: o || "All",
|
|
3326
|
+
depth: r,
|
|
3290
3327
|
values: h,
|
|
3291
3328
|
total: f,
|
|
3292
3329
|
isGroup: !1,
|
|
@@ -3295,22 +3332,22 @@ function Be(s, e, t, n, i, o, r) {
|
|
|
3295
3332
|
}
|
|
3296
3333
|
const a = e[0], d = e.slice(1), c = d.length > 0, u = Zt(s, a);
|
|
3297
3334
|
for (const [h, f] of u) {
|
|
3298
|
-
const g =
|
|
3335
|
+
const g = o ? `${o}|${h}` : h, p = Le(f, t, n, i), w = Te(p);
|
|
3299
3336
|
let m;
|
|
3300
|
-
c && (m =
|
|
3337
|
+
c && (m = Oe(
|
|
3301
3338
|
f,
|
|
3302
3339
|
d,
|
|
3303
3340
|
t,
|
|
3304
3341
|
n,
|
|
3305
3342
|
i,
|
|
3306
|
-
|
|
3343
|
+
r + 1,
|
|
3307
3344
|
g
|
|
3308
3345
|
)), l.push({
|
|
3309
3346
|
rowKey: g,
|
|
3310
3347
|
rowLabel: h || "(blank)",
|
|
3311
|
-
depth:
|
|
3348
|
+
depth: r,
|
|
3312
3349
|
values: p,
|
|
3313
|
-
total:
|
|
3350
|
+
total: w,
|
|
3314
3351
|
isGroup: c,
|
|
3315
3352
|
children: m,
|
|
3316
3353
|
rowCount: f.length
|
|
@@ -3320,9 +3357,9 @@ function Be(s, e, t, n, i, o, r) {
|
|
|
3320
3357
|
}
|
|
3321
3358
|
function Le(s, e, t, n) {
|
|
3322
3359
|
const i = {};
|
|
3323
|
-
for (const
|
|
3324
|
-
for (const
|
|
3325
|
-
const a = (e.length > 0 ? s.filter((h) => e.map((f) => String(h[f] ?? "")).join("|") ===
|
|
3360
|
+
for (const r of t)
|
|
3361
|
+
for (const o of n) {
|
|
3362
|
+
const a = (e.length > 0 ? s.filter((h) => e.map((f) => String(h[f] ?? "")).join("|") === r) : s).map((h) => Number(h[o.field]) || 0), d = jt(o.aggFunc), c = a.length > 0 ? d(a) : null, u = oe([r], o.field);
|
|
3326
3363
|
i[u] = c;
|
|
3327
3364
|
}
|
|
3328
3365
|
return i;
|
|
@@ -3333,34 +3370,34 @@ function Te(s) {
|
|
|
3333
3370
|
e += t ?? 0;
|
|
3334
3371
|
return e;
|
|
3335
3372
|
}
|
|
3336
|
-
function
|
|
3373
|
+
function Jt(s, e, t) {
|
|
3337
3374
|
const n = {};
|
|
3338
|
-
function i(
|
|
3339
|
-
for (const
|
|
3340
|
-
if (!
|
|
3375
|
+
function i(r) {
|
|
3376
|
+
for (const o of r)
|
|
3377
|
+
if (!o.isGroup || !o.children?.length)
|
|
3341
3378
|
for (const l of e)
|
|
3342
3379
|
for (const a of t) {
|
|
3343
|
-
const d =
|
|
3344
|
-
n[d] = (n[d] ?? 0) + (
|
|
3380
|
+
const d = oe([l], a.field);
|
|
3381
|
+
n[d] = (n[d] ?? 0) + (o.values[d] ?? 0);
|
|
3345
3382
|
}
|
|
3346
|
-
else
|
|
3383
|
+
else o.children && i(o.children);
|
|
3347
3384
|
}
|
|
3348
3385
|
return i(s), n;
|
|
3349
3386
|
}
|
|
3350
|
-
function
|
|
3387
|
+
function Qt(s, e, t = !0) {
|
|
3351
3388
|
const n = [];
|
|
3352
|
-
function i(
|
|
3353
|
-
n.push(
|
|
3354
|
-
const
|
|
3355
|
-
if (
|
|
3356
|
-
for (const l of
|
|
3389
|
+
function i(r) {
|
|
3390
|
+
n.push(r);
|
|
3391
|
+
const o = e ? e.has(r.rowKey) : t;
|
|
3392
|
+
if (r.children && o)
|
|
3393
|
+
for (const l of r.children)
|
|
3357
3394
|
i(l);
|
|
3358
3395
|
}
|
|
3359
|
-
for (const
|
|
3360
|
-
i(
|
|
3396
|
+
for (const r of s)
|
|
3397
|
+
i(r);
|
|
3361
3398
|
return n;
|
|
3362
3399
|
}
|
|
3363
|
-
function
|
|
3400
|
+
function en(s) {
|
|
3364
3401
|
const e = [];
|
|
3365
3402
|
function t(n) {
|
|
3366
3403
|
if (n.isGroup && e.push(n.rowKey), n.children)
|
|
@@ -3371,11 +3408,11 @@ function Qt(s) {
|
|
|
3371
3408
|
t(n);
|
|
3372
3409
|
return e;
|
|
3373
3410
|
}
|
|
3374
|
-
const
|
|
3375
|
-
function
|
|
3376
|
-
const i = new AbortController(),
|
|
3377
|
-
return
|
|
3378
|
-
i.abort(),
|
|
3411
|
+
const tn = ["sum", "avg", "count", "min", "max", "first", "last"];
|
|
3412
|
+
function nn(s, e, t, n) {
|
|
3413
|
+
const i = new AbortController(), r = { config: e, callbacks: n, signal: i.signal }, o = document.createElement("div");
|
|
3414
|
+
return o.className = "tbw-pivot-panel", o.appendChild(D("Options", () => an(t, r))), o.appendChild(D("Row Groups", () => Ie("rowGroups", r))), o.appendChild(D("Column Groups", () => Ie("columnGroups", r))), o.appendChild(D("Values", () => on(r))), o.appendChild(D("Available Fields", () => ln(r))), s.appendChild(o), () => {
|
|
3415
|
+
i.abort(), o.remove();
|
|
3379
3416
|
};
|
|
3380
3417
|
}
|
|
3381
3418
|
function D(s, e) {
|
|
@@ -3387,42 +3424,42 @@ function D(s, e) {
|
|
|
3387
3424
|
return i.className = "tbw-pivot-section-content", i.appendChild(e()), t.appendChild(n), t.appendChild(i), t;
|
|
3388
3425
|
}
|
|
3389
3426
|
function Ie(s, e) {
|
|
3390
|
-
const { config: t, callbacks: n, signal: i } = e,
|
|
3391
|
-
|
|
3392
|
-
const
|
|
3393
|
-
if (
|
|
3427
|
+
const { config: t, callbacks: n, signal: i } = e, r = document.createElement("div");
|
|
3428
|
+
r.className = "tbw-pivot-drop-zone", r.setAttribute("data-zone", s);
|
|
3429
|
+
const o = s === "rowGroups" ? t.rowGroupFields ?? [] : t.columnGroupFields ?? [];
|
|
3430
|
+
if (o.length === 0) {
|
|
3394
3431
|
const l = document.createElement("div");
|
|
3395
|
-
l.className = "tbw-pivot-placeholder", l.textContent = "Drag fields here or click to add",
|
|
3432
|
+
l.className = "tbw-pivot-placeholder", l.textContent = "Drag fields here or click to add", r.appendChild(l);
|
|
3396
3433
|
} else
|
|
3397
|
-
for (const l of
|
|
3398
|
-
|
|
3399
|
-
return
|
|
3434
|
+
for (const l of o)
|
|
3435
|
+
r.appendChild(rn(l, s, e));
|
|
3436
|
+
return r.addEventListener(
|
|
3400
3437
|
"dragover",
|
|
3401
3438
|
(l) => {
|
|
3402
|
-
l.preventDefault(),
|
|
3439
|
+
l.preventDefault(), r.classList.add("drag-over");
|
|
3403
3440
|
},
|
|
3404
3441
|
{ signal: i }
|
|
3405
|
-
),
|
|
3442
|
+
), r.addEventListener(
|
|
3406
3443
|
"dragleave",
|
|
3407
3444
|
() => {
|
|
3408
|
-
|
|
3445
|
+
r.classList.remove("drag-over");
|
|
3409
3446
|
},
|
|
3410
3447
|
{ signal: i }
|
|
3411
|
-
),
|
|
3448
|
+
), r.addEventListener(
|
|
3412
3449
|
"drop",
|
|
3413
3450
|
(l) => {
|
|
3414
|
-
l.preventDefault(),
|
|
3451
|
+
l.preventDefault(), r.classList.remove("drag-over");
|
|
3415
3452
|
const a = l.dataTransfer?.getData("text/plain");
|
|
3416
3453
|
a && n.onAddFieldToZone(a, s);
|
|
3417
3454
|
},
|
|
3418
3455
|
{ signal: i }
|
|
3419
|
-
),
|
|
3456
|
+
), r;
|
|
3420
3457
|
}
|
|
3421
|
-
function
|
|
3422
|
-
const { callbacks: n, signal: i } = t,
|
|
3423
|
-
|
|
3424
|
-
const
|
|
3425
|
-
l.className = "tbw-pivot-chip-label", l.textContent =
|
|
3458
|
+
function rn(s, e, t) {
|
|
3459
|
+
const { callbacks: n, signal: i } = t, r = document.createElement("div");
|
|
3460
|
+
r.className = "tbw-pivot-field-chip", r.draggable = !0;
|
|
3461
|
+
const o = n.getAvailableFields().find((d) => d.field === s), l = document.createElement("span");
|
|
3462
|
+
l.className = "tbw-pivot-chip-label", l.textContent = o?.header ?? s;
|
|
3426
3463
|
const a = document.createElement("button");
|
|
3427
3464
|
return a.className = "tbw-pivot-chip-remove", a.innerHTML = "×", a.title = "Remove field", a.addEventListener(
|
|
3428
3465
|
"click",
|
|
@@ -3430,34 +3467,34 @@ function nn(s, e, t) {
|
|
|
3430
3467
|
d.stopPropagation(), n.onRemoveFieldFromZone(s, e);
|
|
3431
3468
|
},
|
|
3432
3469
|
{ signal: i }
|
|
3433
|
-
),
|
|
3470
|
+
), r.appendChild(l), r.appendChild(a), r.addEventListener(
|
|
3434
3471
|
"dragstart",
|
|
3435
3472
|
(d) => {
|
|
3436
|
-
d.dataTransfer?.setData("text/plain", s), d.dataTransfer?.setData("source-zone", e),
|
|
3473
|
+
d.dataTransfer?.setData("text/plain", s), d.dataTransfer?.setData("source-zone", e), r.classList.add("dragging");
|
|
3437
3474
|
},
|
|
3438
3475
|
{ signal: i }
|
|
3439
|
-
),
|
|
3476
|
+
), r.addEventListener(
|
|
3440
3477
|
"dragend",
|
|
3441
3478
|
() => {
|
|
3442
|
-
|
|
3479
|
+
r.classList.remove("dragging");
|
|
3443
3480
|
},
|
|
3444
3481
|
{ signal: i }
|
|
3445
|
-
),
|
|
3482
|
+
), r;
|
|
3446
3483
|
}
|
|
3447
3484
|
function on(s) {
|
|
3448
3485
|
const { config: e, callbacks: t, signal: n } = s, i = document.createElement("div");
|
|
3449
3486
|
i.className = "tbw-pivot-drop-zone tbw-pivot-values-zone", i.setAttribute("data-zone", "values");
|
|
3450
|
-
const
|
|
3451
|
-
if (
|
|
3452
|
-
const
|
|
3453
|
-
|
|
3487
|
+
const r = e.valueFields ?? [];
|
|
3488
|
+
if (r.length === 0) {
|
|
3489
|
+
const o = document.createElement("div");
|
|
3490
|
+
o.className = "tbw-pivot-placeholder", o.textContent = "Drag numeric fields here for aggregation", i.appendChild(o);
|
|
3454
3491
|
} else
|
|
3455
|
-
for (const
|
|
3456
|
-
i.appendChild(
|
|
3492
|
+
for (const o of r)
|
|
3493
|
+
i.appendChild(sn(o, s));
|
|
3457
3494
|
return i.addEventListener(
|
|
3458
3495
|
"dragover",
|
|
3459
|
-
(
|
|
3460
|
-
|
|
3496
|
+
(o) => {
|
|
3497
|
+
o.preventDefault(), i.classList.add("drag-over");
|
|
3461
3498
|
},
|
|
3462
3499
|
{ signal: n }
|
|
3463
3500
|
), i.addEventListener(
|
|
@@ -3468,24 +3505,24 @@ function on(s) {
|
|
|
3468
3505
|
{ signal: n }
|
|
3469
3506
|
), i.addEventListener(
|
|
3470
3507
|
"drop",
|
|
3471
|
-
(
|
|
3472
|
-
|
|
3473
|
-
const l =
|
|
3508
|
+
(o) => {
|
|
3509
|
+
o.preventDefault(), i.classList.remove("drag-over");
|
|
3510
|
+
const l = o.dataTransfer?.getData("text/plain");
|
|
3474
3511
|
l && t.onAddValueField(l, "sum");
|
|
3475
3512
|
},
|
|
3476
3513
|
{ signal: n }
|
|
3477
3514
|
), i;
|
|
3478
3515
|
}
|
|
3479
|
-
function
|
|
3516
|
+
function sn(s, e) {
|
|
3480
3517
|
const { callbacks: t, signal: n } = e, i = document.createElement("div");
|
|
3481
3518
|
i.className = "tbw-pivot-field-chip tbw-pivot-value-chip";
|
|
3482
|
-
const
|
|
3483
|
-
|
|
3519
|
+
const r = t.getAvailableFields().find((c) => c.field === s.field), o = document.createElement("div");
|
|
3520
|
+
o.className = "tbw-pivot-value-label-wrapper";
|
|
3484
3521
|
const l = document.createElement("span");
|
|
3485
|
-
l.className = "tbw-pivot-chip-label", l.textContent =
|
|
3522
|
+
l.className = "tbw-pivot-chip-label", l.textContent = r?.header ?? s.field;
|
|
3486
3523
|
const a = document.createElement("select");
|
|
3487
3524
|
a.className = "tbw-pivot-agg-select", a.title = "Aggregation function";
|
|
3488
|
-
for (const c of
|
|
3525
|
+
for (const c of tn) {
|
|
3489
3526
|
const u = document.createElement("option");
|
|
3490
3527
|
u.value = c, u.textContent = c.toUpperCase(), u.selected = c === s.aggFunc, a.appendChild(u);
|
|
3491
3528
|
}
|
|
@@ -3503,16 +3540,16 @@ function rn(s, e) {
|
|
|
3503
3540
|
c.stopPropagation(), t.onRemoveValueField(s.field);
|
|
3504
3541
|
},
|
|
3505
3542
|
{ signal: n }
|
|
3506
|
-
),
|
|
3543
|
+
), o.appendChild(l), o.appendChild(a), i.appendChild(o), i.appendChild(d), i;
|
|
3507
3544
|
}
|
|
3508
|
-
function
|
|
3545
|
+
function ln(s) {
|
|
3509
3546
|
const { config: e, callbacks: t, signal: n } = s, i = document.createElement("div");
|
|
3510
3547
|
i.className = "tbw-pivot-available-fields";
|
|
3511
|
-
const
|
|
3548
|
+
const r = t.getAvailableFields(), o = /* @__PURE__ */ new Set([
|
|
3512
3549
|
...e.rowGroupFields ?? [],
|
|
3513
3550
|
...e.columnGroupFields ?? [],
|
|
3514
3551
|
...e.valueFields?.map((a) => a.field) ?? []
|
|
3515
|
-
]), l =
|
|
3552
|
+
]), l = r.filter((a) => !o.has(a.field));
|
|
3516
3553
|
if (l.length === 0) {
|
|
3517
3554
|
const a = document.createElement("div");
|
|
3518
3555
|
a.className = "tbw-pivot-placeholder", a.textContent = "All fields are in use", i.appendChild(a);
|
|
@@ -3535,98 +3572,98 @@ function sn(s) {
|
|
|
3535
3572
|
}
|
|
3536
3573
|
return i;
|
|
3537
3574
|
}
|
|
3538
|
-
function
|
|
3539
|
-
const { config: t, callbacks: n, signal: i } = e,
|
|
3540
|
-
return
|
|
3541
|
-
|
|
3575
|
+
function an(s, e) {
|
|
3576
|
+
const { config: t, callbacks: n, signal: i } = e, r = document.createElement("div");
|
|
3577
|
+
return r.className = "tbw-pivot-options", r.appendChild(
|
|
3578
|
+
X(
|
|
3542
3579
|
"Enable Pivot View",
|
|
3543
3580
|
s,
|
|
3544
|
-
(
|
|
3545
|
-
n.onTogglePivot(
|
|
3581
|
+
(o) => {
|
|
3582
|
+
n.onTogglePivot(o);
|
|
3546
3583
|
},
|
|
3547
3584
|
i
|
|
3548
3585
|
)
|
|
3549
|
-
),
|
|
3550
|
-
|
|
3586
|
+
), r.appendChild(
|
|
3587
|
+
X(
|
|
3551
3588
|
"Show Row Totals",
|
|
3552
3589
|
t.showTotals ?? !0,
|
|
3553
|
-
(
|
|
3554
|
-
n.onOptionChange("showTotals",
|
|
3590
|
+
(o) => {
|
|
3591
|
+
n.onOptionChange("showTotals", o);
|
|
3555
3592
|
},
|
|
3556
3593
|
i
|
|
3557
3594
|
)
|
|
3558
|
-
),
|
|
3559
|
-
|
|
3595
|
+
), r.appendChild(
|
|
3596
|
+
X(
|
|
3560
3597
|
"Show Grand Total",
|
|
3561
3598
|
t.showGrandTotal ?? !0,
|
|
3562
|
-
(
|
|
3563
|
-
n.onOptionChange("showGrandTotal",
|
|
3599
|
+
(o) => {
|
|
3600
|
+
n.onOptionChange("showGrandTotal", o);
|
|
3564
3601
|
},
|
|
3565
3602
|
i
|
|
3566
3603
|
)
|
|
3567
|
-
),
|
|
3604
|
+
), r;
|
|
3568
3605
|
}
|
|
3569
|
-
function
|
|
3606
|
+
function X(s, e, t, n) {
|
|
3570
3607
|
const i = document.createElement("label");
|
|
3571
3608
|
i.className = "tbw-pivot-checkbox";
|
|
3572
|
-
const
|
|
3573
|
-
|
|
3574
|
-
const
|
|
3575
|
-
return
|
|
3609
|
+
const r = document.createElement("input");
|
|
3610
|
+
r.type = "checkbox", r.checked = e, r.addEventListener("change", () => t(r.checked), { signal: n });
|
|
3611
|
+
const o = document.createElement("span");
|
|
3612
|
+
return o.textContent = s, i.appendChild(r), i.appendChild(o), i;
|
|
3576
3613
|
}
|
|
3577
|
-
function
|
|
3614
|
+
function dn(s, e, t) {
|
|
3578
3615
|
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((n, i) => {
|
|
3579
|
-
const
|
|
3580
|
-
if (
|
|
3581
|
-
const
|
|
3582
|
-
|
|
3616
|
+
const r = document.createElement("div");
|
|
3617
|
+
if (r.className = "cell", r.setAttribute("data-col", String(i)), r.setAttribute("data-row", String(t.rowIndex)), r.setAttribute("role", "gridcell"), i === 0) {
|
|
3618
|
+
const o = Number(s.__pivotIndent) || 0;
|
|
3619
|
+
r.style.paddingLeft = `${o}px`;
|
|
3583
3620
|
const l = String(s.__pivotRowKey), a = document.createElement("button");
|
|
3584
3621
|
a.type = "button", a.className = "pivot-toggle", a.setAttribute("aria-label", s.__pivotExpanded ? "Collapse group" : "Expand group"), t.setIcon(a, t.resolveIcon(s.__pivotExpanded ? "collapse" : "expand")), a.addEventListener("click", (u) => {
|
|
3585
3622
|
u.stopPropagation(), t.onToggle(l);
|
|
3586
|
-
}),
|
|
3623
|
+
}), r.appendChild(a);
|
|
3587
3624
|
const d = document.createElement("span");
|
|
3588
|
-
d.className = "pivot-label", d.textContent = String(s.__pivotLabel ?? ""),
|
|
3625
|
+
d.className = "pivot-label", d.textContent = String(s.__pivotLabel ?? ""), r.appendChild(d);
|
|
3589
3626
|
const c = document.createElement("span");
|
|
3590
|
-
c.className = "pivot-count", c.textContent = ` (${Number(s.__pivotRowCount) || 0})`,
|
|
3627
|
+
c.className = "pivot-count", c.textContent = ` (${Number(s.__pivotRowCount) || 0})`, r.appendChild(c);
|
|
3591
3628
|
} else {
|
|
3592
|
-
const
|
|
3593
|
-
|
|
3629
|
+
const o = s[n.field];
|
|
3630
|
+
r.textContent = o != null ? String(o) : "";
|
|
3594
3631
|
}
|
|
3595
|
-
e.appendChild(
|
|
3632
|
+
e.appendChild(r);
|
|
3596
3633
|
}), !0;
|
|
3597
3634
|
}
|
|
3598
|
-
function
|
|
3599
|
-
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((i,
|
|
3600
|
-
const
|
|
3601
|
-
if (
|
|
3635
|
+
function cn(s, e, t, n) {
|
|
3636
|
+
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((i, r) => {
|
|
3637
|
+
const o = document.createElement("div");
|
|
3638
|
+
if (o.className = "cell", o.setAttribute("data-col", String(r)), o.setAttribute("data-row", String(n)), o.setAttribute("role", "gridcell"), r === 0) {
|
|
3602
3639
|
const l = Number(s.__pivotIndent) || 0;
|
|
3603
|
-
|
|
3640
|
+
o.style.paddingLeft = `${l + 20}px`;
|
|
3604
3641
|
const a = document.createElement("span");
|
|
3605
|
-
a.className = "pivot-label", a.textContent = String(s.__pivotLabel ?? ""),
|
|
3642
|
+
a.className = "pivot-label", a.textContent = String(s.__pivotLabel ?? ""), o.appendChild(a);
|
|
3606
3643
|
} else {
|
|
3607
3644
|
const l = s[i.field];
|
|
3608
|
-
|
|
3645
|
+
o.textContent = l != null ? String(l) : "";
|
|
3609
3646
|
}
|
|
3610
|
-
e.appendChild(
|
|
3647
|
+
e.appendChild(o);
|
|
3611
3648
|
}), !0;
|
|
3612
3649
|
}
|
|
3613
|
-
function
|
|
3650
|
+
function un(s, e, t) {
|
|
3614
3651
|
return e.className = "pivot-grand-total-row", e.setAttribute("role", "presentation"), e.innerHTML = "", t.forEach((n, i) => {
|
|
3615
|
-
const
|
|
3616
|
-
if (
|
|
3617
|
-
const
|
|
3618
|
-
|
|
3652
|
+
const r = document.createElement("div");
|
|
3653
|
+
if (r.className = "cell", r.setAttribute("data-col", String(i)), i === 0) {
|
|
3654
|
+
const o = document.createElement("span");
|
|
3655
|
+
o.className = "pivot-label", o.textContent = "Grand Total", r.appendChild(o);
|
|
3619
3656
|
} else {
|
|
3620
|
-
const
|
|
3621
|
-
|
|
3657
|
+
const o = s[n.field];
|
|
3658
|
+
r.textContent = o != null ? String(o) : "";
|
|
3622
3659
|
}
|
|
3623
|
-
e.appendChild(
|
|
3660
|
+
e.appendChild(r);
|
|
3624
3661
|
}), !0;
|
|
3625
3662
|
}
|
|
3626
|
-
const
|
|
3663
|
+
const hn = '@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}}}';
|
|
3627
3664
|
class F extends x {
|
|
3628
3665
|
name = "pivot";
|
|
3629
|
-
styles =
|
|
3666
|
+
styles = hn;
|
|
3630
3667
|
/** Tool panel ID for shell integration */
|
|
3631
3668
|
static PANEL_ID = "pivot";
|
|
3632
3669
|
get defaultConfig() {
|
|
@@ -3686,33 +3723,33 @@ class F extends x {
|
|
|
3686
3723
|
processRows(e) {
|
|
3687
3724
|
if (!this.hasInitialized && this.config.active !== !1 && this.hasValidPivotConfig() && (this.hasInitialized = !0, this.isActive = !0), !this.isActive)
|
|
3688
3725
|
return [...e];
|
|
3689
|
-
const t =
|
|
3726
|
+
const t = Ut(this.config);
|
|
3690
3727
|
if (t.length > 0)
|
|
3691
3728
|
return this.warn(`Config errors: ${t.join(", ")}`), [...e];
|
|
3692
|
-
this.buildFieldHeaderMap(), this.defaultExpanded = this.config.defaultExpanded ?? !0, this.expandedKeys.size === 0 && this.defaultExpanded && this.pivotResult && this.expandAllKeys(), this.pivotResult =
|
|
3693
|
-
const n = this.config.indentWidth ?? 20, i =
|
|
3729
|
+
this.buildFieldHeaderMap(), this.defaultExpanded = this.config.defaultExpanded ?? !0, this.expandedKeys.size === 0 && this.defaultExpanded && this.pivotResult && this.expandAllKeys(), this.pivotResult = Yt(e, this.config), this.expandedKeys.size === 0 && this.defaultExpanded && this.expandAllKeys();
|
|
3730
|
+
const n = this.config.indentWidth ?? 20, i = Qt(
|
|
3694
3731
|
this.pivotResult.rows,
|
|
3695
3732
|
this.expandedKeys,
|
|
3696
3733
|
this.defaultExpanded
|
|
3697
|
-
).map((
|
|
3698
|
-
__pivotRowKey:
|
|
3699
|
-
__pivotLabel:
|
|
3700
|
-
__pivotDepth:
|
|
3701
|
-
__pivotIsGroup:
|
|
3702
|
-
__pivotHasChildren: !!
|
|
3703
|
-
__pivotExpanded: this.expandedKeys.has(
|
|
3704
|
-
__pivotRowCount:
|
|
3705
|
-
__pivotIndent:
|
|
3706
|
-
__pivotTotal:
|
|
3707
|
-
...
|
|
3734
|
+
).map((o) => ({
|
|
3735
|
+
__pivotRowKey: o.rowKey,
|
|
3736
|
+
__pivotLabel: o.rowLabel,
|
|
3737
|
+
__pivotDepth: o.depth,
|
|
3738
|
+
__pivotIsGroup: o.isGroup,
|
|
3739
|
+
__pivotHasChildren: !!o.children?.length,
|
|
3740
|
+
__pivotExpanded: this.expandedKeys.has(o.rowKey),
|
|
3741
|
+
__pivotRowCount: o.rowCount ?? 0,
|
|
3742
|
+
__pivotIndent: o.depth * n,
|
|
3743
|
+
__pivotTotal: o.total,
|
|
3744
|
+
...o.values
|
|
3708
3745
|
}));
|
|
3709
3746
|
this.keysToAnimate.clear();
|
|
3710
|
-
const
|
|
3711
|
-
for (const
|
|
3712
|
-
const l =
|
|
3713
|
-
|
|
3747
|
+
const r = /* @__PURE__ */ new Set();
|
|
3748
|
+
for (const o of i) {
|
|
3749
|
+
const l = o.__pivotRowKey;
|
|
3750
|
+
r.add(l), !this.previousVisibleKeys.has(l) && o.__pivotDepth > 0 && this.keysToAnimate.add(l);
|
|
3714
3751
|
}
|
|
3715
|
-
return this.previousVisibleKeys =
|
|
3752
|
+
return this.previousVisibleKeys = r, i;
|
|
3716
3753
|
}
|
|
3717
3754
|
processColumns(e) {
|
|
3718
3755
|
if (!this.isActive || !this.pivotResult)
|
|
@@ -3724,11 +3761,11 @@ class F extends x {
|
|
|
3724
3761
|
width: 200
|
|
3725
3762
|
});
|
|
3726
3763
|
for (const i of this.pivotResult.columnKeys)
|
|
3727
|
-
for (const
|
|
3728
|
-
const
|
|
3764
|
+
for (const r of this.config.valueFields ?? []) {
|
|
3765
|
+
const o = oe([i], r.field), l = r.header || this.fieldHeaderMap.get(r.field) || r.field;
|
|
3729
3766
|
t.push({
|
|
3730
|
-
field:
|
|
3731
|
-
header: `${i} - ${l} (${
|
|
3767
|
+
field: o,
|
|
3768
|
+
header: `${i} - ${l} (${r.aggFunc})`,
|
|
3732
3769
|
width: 120,
|
|
3733
3770
|
type: "number"
|
|
3734
3771
|
});
|
|
@@ -3742,13 +3779,13 @@ class F extends x {
|
|
|
3742
3779
|
}
|
|
3743
3780
|
renderRow(e, t, n) {
|
|
3744
3781
|
const i = e;
|
|
3745
|
-
return i.__pivotRowKey && i.__pivotHasChildren ?
|
|
3782
|
+
return i.__pivotRowKey && i.__pivotHasChildren ? dn(i, t, {
|
|
3746
3783
|
columns: this.gridColumns,
|
|
3747
3784
|
rowIndex: n,
|
|
3748
|
-
onToggle: (
|
|
3749
|
-
resolveIcon: (
|
|
3750
|
-
setIcon: (
|
|
3751
|
-
}) : i.__pivotRowKey !== void 0 && this.isActive ?
|
|
3785
|
+
onToggle: (r) => this.toggle(r),
|
|
3786
|
+
resolveIcon: (r) => this.resolveIcon(r),
|
|
3787
|
+
setIcon: (r, o) => this.setIcon(r, o)
|
|
3788
|
+
}) : i.__pivotRowKey !== void 0 && this.isActive ? cn(i, t, this.gridColumns, n) : (this.cleanupPivotStyling(t), !1);
|
|
3752
3789
|
}
|
|
3753
3790
|
/**
|
|
3754
3791
|
* Remove pivot-specific classes, attributes, and inline styles from a row element.
|
|
@@ -3768,12 +3805,12 @@ class F extends x {
|
|
|
3768
3805
|
this.isActive && this.config.showGrandTotal && this.pivotResult ? this.renderGrandTotalFooter() : this.cleanupGrandTotalFooter();
|
|
3769
3806
|
const e = this.animationStyle;
|
|
3770
3807
|
if (e === !1 || this.keysToAnimate.size === 0) return;
|
|
3771
|
-
const t = this.
|
|
3808
|
+
const t = this.gridElement?.querySelector(".rows");
|
|
3772
3809
|
if (!t) return;
|
|
3773
3810
|
const n = e === "fade" ? "tbw-pivot-fade-in" : "tbw-pivot-slide-in";
|
|
3774
3811
|
for (const i of t.querySelectorAll(".pivot-group-row, .pivot-leaf-row")) {
|
|
3775
|
-
const
|
|
3776
|
-
|
|
3812
|
+
const r = i.dataset.pivotKey;
|
|
3813
|
+
r && this.keysToAnimate.has(r) && (i.classList.add(n), i.addEventListener("animationend", () => i.classList.remove(n), { once: !0 }));
|
|
3777
3814
|
}
|
|
3778
3815
|
this.keysToAnimate.clear();
|
|
3779
3816
|
}
|
|
@@ -3782,7 +3819,7 @@ class F extends x {
|
|
|
3782
3819
|
*/
|
|
3783
3820
|
renderGrandTotalFooter() {
|
|
3784
3821
|
if (!this.pivotResult) return;
|
|
3785
|
-
const e = this.
|
|
3822
|
+
const e = this.gridElement;
|
|
3786
3823
|
if (!e) return;
|
|
3787
3824
|
const t = e.querySelector(".tbw-scroll-area") ?? e.querySelector(".tbw-grid-content") ?? e.children[0];
|
|
3788
3825
|
if (!t) return;
|
|
@@ -3794,7 +3831,7 @@ class F extends x {
|
|
|
3794
3831
|
__pivotTotal: this.pivotResult.grandTotal,
|
|
3795
3832
|
...this.pivotResult.totals
|
|
3796
3833
|
};
|
|
3797
|
-
|
|
3834
|
+
un(n, this.grandTotalFooter, this.gridColumns);
|
|
3798
3835
|
}
|
|
3799
3836
|
/**
|
|
3800
3837
|
* Remove the grand total footer element.
|
|
@@ -3824,7 +3861,7 @@ class F extends x {
|
|
|
3824
3861
|
*/
|
|
3825
3862
|
expandAllKeys() {
|
|
3826
3863
|
if (!this.pivotResult) return;
|
|
3827
|
-
const e =
|
|
3864
|
+
const e = en(this.pivotResult.rows);
|
|
3828
3865
|
for (const t of e)
|
|
3829
3866
|
this.expandedKeys.add(t);
|
|
3830
3867
|
}
|
|
@@ -3931,7 +3968,7 @@ class F extends x {
|
|
|
3931
3968
|
},
|
|
3932
3969
|
getAvailableFields: () => this.getAvailableFields()
|
|
3933
3970
|
};
|
|
3934
|
-
return
|
|
3971
|
+
return nn(e, this.config, this.isActive, t);
|
|
3935
3972
|
}
|
|
3936
3973
|
refreshPanel() {
|
|
3937
3974
|
this.panelContainer && (this.panelContainer.innerHTML = "", this.renderPanel(this.panelContainer));
|
|
@@ -3960,12 +3997,12 @@ class F extends x {
|
|
|
3960
3997
|
this.config.valueFields = (this.config.valueFields ?? []).filter((t) => t.field !== e), this.refreshIfActive();
|
|
3961
3998
|
}
|
|
3962
3999
|
updateValueAggFunc(e, t) {
|
|
3963
|
-
const n = this.config.valueFields ?? [], i = n.findIndex((
|
|
4000
|
+
const n = this.config.valueFields ?? [], i = n.findIndex((r) => r.field === e);
|
|
3964
4001
|
i >= 0 && (n[i] = { ...n[i], aggFunc: t }, this.config.valueFields = [...n]), this.isActive && this.refresh();
|
|
3965
4002
|
}
|
|
3966
4003
|
// #endregion
|
|
3967
4004
|
}
|
|
3968
|
-
function
|
|
4005
|
+
function fn(s) {
|
|
3969
4006
|
const e = s.meta ?? {};
|
|
3970
4007
|
return e.lockPosition !== !0 && e.suppressMovable !== !0;
|
|
3971
4008
|
}
|
|
@@ -3974,10 +4011,10 @@ function Fe(s, e, t) {
|
|
|
3974
4011
|
const n = [...s], [i] = n.splice(e, 1);
|
|
3975
4012
|
return n.splice(t, 0, i), n;
|
|
3976
4013
|
}
|
|
3977
|
-
const
|
|
3978
|
-
class
|
|
4014
|
+
const gn = '@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}}';
|
|
4015
|
+
class Yn extends x {
|
|
3979
4016
|
name = "reorder";
|
|
3980
|
-
styles =
|
|
4017
|
+
styles = gn;
|
|
3981
4018
|
get defaultConfig() {
|
|
3982
4019
|
return {
|
|
3983
4020
|
animation: "flip"
|
|
@@ -4007,7 +4044,7 @@ class Un extends x {
|
|
|
4007
4044
|
* Check if a column can be moved, considering both column config and plugin queries.
|
|
4008
4045
|
*/
|
|
4009
4046
|
canMoveColumnWithPlugins(e) {
|
|
4010
|
-
return !e || !
|
|
4047
|
+
return !e || !fn(e) ? !1 : !this.grid.queryPlugins({
|
|
4011
4048
|
type: He.CAN_MOVE_COLUMN,
|
|
4012
4049
|
context: e
|
|
4013
4050
|
}).includes(!1);
|
|
@@ -4016,7 +4053,7 @@ class Un extends x {
|
|
|
4016
4053
|
* Clear all drag-related classes from header cells.
|
|
4017
4054
|
*/
|
|
4018
4055
|
clearDragClasses() {
|
|
4019
|
-
this.
|
|
4056
|
+
this.gridElement?.querySelectorAll(".header-row > .cell").forEach((e) => {
|
|
4020
4057
|
e.classList.remove("dragging", "drop-target", "drop-before", "drop-after");
|
|
4021
4058
|
});
|
|
4022
4059
|
}
|
|
@@ -4038,24 +4075,24 @@ class Un extends x {
|
|
|
4038
4075
|
// #endregion
|
|
4039
4076
|
// #region Hooks
|
|
4040
4077
|
afterRender() {
|
|
4041
|
-
const e = this.
|
|
4078
|
+
const e = this.gridElement;
|
|
4042
4079
|
if (!e) return;
|
|
4043
4080
|
e.querySelectorAll(".header-row > .cell").forEach((n) => {
|
|
4044
|
-
const i = n,
|
|
4045
|
-
if (!
|
|
4046
|
-
const
|
|
4047
|
-
if (!this.canMoveColumnWithPlugins(
|
|
4081
|
+
const i = n, r = i.getAttribute("data-field");
|
|
4082
|
+
if (!r) return;
|
|
4083
|
+
const o = this.columns.find((l) => l.field === r);
|
|
4084
|
+
if (!this.canMoveColumnWithPlugins(o)) {
|
|
4048
4085
|
i.draggable = !1;
|
|
4049
4086
|
return;
|
|
4050
4087
|
}
|
|
4051
4088
|
i.draggable = !0, !i.getAttribute("data-dragstart-bound") && (i.setAttribute("data-dragstart-bound", "true"), i.addEventListener("dragstart", (l) => {
|
|
4052
|
-
const d = this.getColumnOrder().indexOf(
|
|
4053
|
-
this.isDragging = !0, this.draggedField =
|
|
4089
|
+
const d = this.getColumnOrder().indexOf(r);
|
|
4090
|
+
this.isDragging = !0, this.draggedField = r, this.draggedIndex = d, l.dataTransfer && (l.dataTransfer.effectAllowed = "move", l.dataTransfer.setData("text/plain", r)), i.classList.add("dragging");
|
|
4054
4091
|
}), i.addEventListener("dragend", () => {
|
|
4055
4092
|
this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, this.clearDragClasses();
|
|
4056
4093
|
}), i.addEventListener("dragover", (l) => {
|
|
4057
|
-
if (l.preventDefault(), !this.isDragging || this.draggedField ===
|
|
4058
|
-
const a = i.getBoundingClientRect(), d = a.left + a.width / 2, u = this.getColumnOrder().indexOf(
|
|
4094
|
+
if (l.preventDefault(), !this.isDragging || this.draggedField === r) return;
|
|
4095
|
+
const a = i.getBoundingClientRect(), d = a.left + a.width / 2, u = this.getColumnOrder().indexOf(r);
|
|
4059
4096
|
this.dropIndex = l.clientX < d ? u : u + 1, i.classList.add("drop-target"), i.classList.toggle("drop-before", l.clientX < d), i.classList.toggle("drop-after", l.clientX >= d);
|
|
4060
4097
|
}), i.addEventListener("dragleave", () => {
|
|
4061
4098
|
i.classList.remove("drop-target", "drop-before", "drop-after");
|
|
@@ -4070,7 +4107,7 @@ class Un extends x {
|
|
|
4070
4107
|
toIndex: u,
|
|
4071
4108
|
columnOrder: f
|
|
4072
4109
|
};
|
|
4073
|
-
this.
|
|
4110
|
+
this.emitCancelable("column-move", g) || this.updateColumnOrder(f);
|
|
4074
4111
|
}));
|
|
4075
4112
|
});
|
|
4076
4113
|
}
|
|
@@ -4082,15 +4119,15 @@ class Un extends x {
|
|
|
4082
4119
|
return;
|
|
4083
4120
|
const t = this.grid, n = t._focusCol, i = t._visibleColumns;
|
|
4084
4121
|
if (n < 0 || n >= i.length) return;
|
|
4085
|
-
const
|
|
4086
|
-
if (!this.canMoveColumnWithPlugins(
|
|
4087
|
-
const
|
|
4122
|
+
const r = i[n];
|
|
4123
|
+
if (!this.canMoveColumnWithPlugins(r)) return;
|
|
4124
|
+
const o = this.getColumnOrder(), l = o.indexOf(r.field);
|
|
4088
4125
|
if (l === -1) return;
|
|
4089
4126
|
const a = e.key === "ArrowLeft" ? l - 1 : l + 1;
|
|
4090
|
-
if (a < 0 || a >=
|
|
4091
|
-
const d = i.find((c) => c.field ===
|
|
4127
|
+
if (a < 0 || a >= o.length) return;
|
|
4128
|
+
const d = i.find((c) => c.field === o[a]);
|
|
4092
4129
|
if (this.canMoveColumnWithPlugins(d))
|
|
4093
|
-
return this.moveColumn(
|
|
4130
|
+
return this.moveColumn(r.field, a), t._focusCol = a, Xe(this.grid), e.preventDefault(), e.stopPropagation(), !0;
|
|
4094
4131
|
}
|
|
4095
4132
|
// #endregion
|
|
4096
4133
|
// #region Public API
|
|
@@ -4109,13 +4146,13 @@ class Un extends x {
|
|
|
4109
4146
|
moveColumn(e, t) {
|
|
4110
4147
|
const n = this.getColumnOrder(), i = n.indexOf(e);
|
|
4111
4148
|
if (i === -1) return;
|
|
4112
|
-
const
|
|
4113
|
-
this.
|
|
4149
|
+
const r = Fe(n, i, t);
|
|
4150
|
+
this.emitCancelable("column-move", {
|
|
4114
4151
|
field: e,
|
|
4115
4152
|
fromIndex: i,
|
|
4116
4153
|
toIndex: t,
|
|
4117
|
-
columnOrder:
|
|
4118
|
-
})
|
|
4154
|
+
columnOrder: r
|
|
4155
|
+
}) || this.updateColumnOrder(r);
|
|
4119
4156
|
}
|
|
4120
4157
|
/**
|
|
4121
4158
|
* Set a specific column order.
|
|
@@ -4138,7 +4175,7 @@ class Un extends x {
|
|
|
4138
4175
|
*/
|
|
4139
4176
|
captureHeaderPositions() {
|
|
4140
4177
|
const e = /* @__PURE__ */ new Map();
|
|
4141
|
-
return this.
|
|
4178
|
+
return this.gridElement?.querySelectorAll(".header-row > .cell[data-field]").forEach((t) => {
|
|
4142
4179
|
const n = t.getAttribute("data-field");
|
|
4143
4180
|
n && e.set(n, t.getBoundingClientRect().left);
|
|
4144
4181
|
}), e;
|
|
@@ -4149,35 +4186,35 @@ class Un extends x {
|
|
|
4149
4186
|
* @param oldPositions - Header positions captured before DOM change
|
|
4150
4187
|
*/
|
|
4151
4188
|
animateFLIP(e) {
|
|
4152
|
-
const t = this.
|
|
4189
|
+
const t = this.gridElement;
|
|
4153
4190
|
if (!t || e.size === 0) return;
|
|
4154
4191
|
const n = /* @__PURE__ */ new Map();
|
|
4155
|
-
if (t.querySelectorAll(".header-row > .cell[data-field]").forEach((
|
|
4156
|
-
const l =
|
|
4192
|
+
if (t.querySelectorAll(".header-row > .cell[data-field]").forEach((o) => {
|
|
4193
|
+
const l = o.getAttribute("data-field");
|
|
4157
4194
|
if (!l) return;
|
|
4158
4195
|
const a = e.get(l);
|
|
4159
4196
|
if (a === void 0) return;
|
|
4160
|
-
const d = a -
|
|
4197
|
+
const d = a - o.getBoundingClientRect().left;
|
|
4161
4198
|
Math.abs(d) > 1 && n.set(l, d);
|
|
4162
4199
|
}), n.size === 0) return;
|
|
4163
4200
|
const i = [];
|
|
4164
|
-
if (t.querySelectorAll(".cell[data-field]").forEach((
|
|
4165
|
-
const l = n.get(
|
|
4201
|
+
if (t.querySelectorAll(".cell[data-field]").forEach((o) => {
|
|
4202
|
+
const l = n.get(o.getAttribute("data-field") ?? "");
|
|
4166
4203
|
if (l !== void 0) {
|
|
4167
|
-
const a =
|
|
4204
|
+
const a = o;
|
|
4168
4205
|
a.style.transform = `translateX(${l}px)`, i.push(a);
|
|
4169
4206
|
}
|
|
4170
4207
|
}), i.length === 0) return;
|
|
4171
|
-
|
|
4172
|
-
const
|
|
4208
|
+
this.gridElement.offsetHeight;
|
|
4209
|
+
const r = this.animationDuration;
|
|
4173
4210
|
requestAnimationFrame(() => {
|
|
4174
|
-
i.forEach((
|
|
4175
|
-
|
|
4211
|
+
i.forEach((o) => {
|
|
4212
|
+
o.classList.add("flip-animating"), o.style.transform = "";
|
|
4176
4213
|
}), setTimeout(() => {
|
|
4177
|
-
i.forEach((
|
|
4178
|
-
|
|
4214
|
+
i.forEach((o) => {
|
|
4215
|
+
o.style.transform = "", o.classList.remove("flip-animating");
|
|
4179
4216
|
});
|
|
4180
|
-
},
|
|
4217
|
+
}, r + 50);
|
|
4181
4218
|
});
|
|
4182
4219
|
}
|
|
4183
4220
|
/**
|
|
@@ -4185,7 +4222,7 @@ class Un extends x {
|
|
|
4185
4222
|
* Uses CSS keyframes - JS just toggles classes.
|
|
4186
4223
|
*/
|
|
4187
4224
|
animateFade(e) {
|
|
4188
|
-
const t = this.
|
|
4225
|
+
const t = this.gridElement;
|
|
4189
4226
|
if (!t) {
|
|
4190
4227
|
e();
|
|
4191
4228
|
return;
|
|
@@ -4201,28 +4238,28 @@ class Un extends x {
|
|
|
4201
4238
|
const c = l.getBoundingClientRect().left;
|
|
4202
4239
|
Math.abs(d - c) > 1 && i.add(a);
|
|
4203
4240
|
}), i.size === 0) return;
|
|
4204
|
-
const
|
|
4241
|
+
const r = [];
|
|
4205
4242
|
if (t.querySelectorAll(".cell[data-field]").forEach((l) => {
|
|
4206
4243
|
const a = l.getAttribute("data-field");
|
|
4207
4244
|
if (a && i.has(a)) {
|
|
4208
4245
|
const d = l;
|
|
4209
|
-
d.classList.add("fade-animating"),
|
|
4246
|
+
d.classList.add("fade-animating"), r.push(d);
|
|
4210
4247
|
}
|
|
4211
|
-
}),
|
|
4212
|
-
const
|
|
4248
|
+
}), r.length === 0) return;
|
|
4249
|
+
const o = this.animationDuration;
|
|
4213
4250
|
setTimeout(() => {
|
|
4214
|
-
|
|
4215
|
-
},
|
|
4251
|
+
r.forEach((l) => l.classList.remove("fade-animating"));
|
|
4252
|
+
}, o + 50);
|
|
4216
4253
|
}
|
|
4217
4254
|
/**
|
|
4218
4255
|
* Update column order with configured animation.
|
|
4219
4256
|
*/
|
|
4220
4257
|
updateColumnOrder(e) {
|
|
4221
4258
|
const t = this.animationType;
|
|
4222
|
-
if (t === "flip" && this.
|
|
4259
|
+
if (t === "flip" && this.gridElement) {
|
|
4223
4260
|
const n = this.captureHeaderPositions();
|
|
4224
4261
|
this.grid.setColumnOrder(e), requestAnimationFrame(() => {
|
|
4225
|
-
this.
|
|
4262
|
+
this.gridElement.offsetHeight, this.animateFLIP(n);
|
|
4226
4263
|
});
|
|
4227
4264
|
} else t === "fade" ? this.animateFade(() => this.grid.setColumnOrder(e)) : this.grid.setColumnOrder(e);
|
|
4228
4265
|
this.grid.requestStateChange?.();
|
|
@@ -4231,18 +4268,18 @@ class Un extends x {
|
|
|
4231
4268
|
}
|
|
4232
4269
|
function Xn(s, e, t, n) {
|
|
4233
4270
|
const i = new Set(s.selected);
|
|
4234
|
-
let
|
|
4271
|
+
let r = s.anchor;
|
|
4235
4272
|
if (t === "single")
|
|
4236
|
-
i.clear(), i.add(e),
|
|
4273
|
+
i.clear(), i.add(e), r = e;
|
|
4237
4274
|
else if (t === "multiple") {
|
|
4238
|
-
const
|
|
4275
|
+
const o = n.ctrlKey || n.metaKey;
|
|
4239
4276
|
if (n.shiftKey && s.anchor !== null) {
|
|
4240
4277
|
const l = Math.min(s.anchor, e), a = Math.max(s.anchor, e);
|
|
4241
4278
|
for (let d = l; d <= a; d++)
|
|
4242
4279
|
i.add(d);
|
|
4243
|
-
} else
|
|
4280
|
+
} else o ? (i.has(e) ? i.delete(e) : i.add(e), r = e) : (i.clear(), i.add(e), r = e);
|
|
4244
4281
|
}
|
|
4245
|
-
return { selected: i, lastSelected: e, anchor:
|
|
4282
|
+
return { selected: i, lastSelected: e, anchor: r };
|
|
4246
4283
|
}
|
|
4247
4284
|
function Zn(s) {
|
|
4248
4285
|
const e = /* @__PURE__ */ new Set();
|
|
@@ -4250,7 +4287,7 @@ function Zn(s) {
|
|
|
4250
4287
|
e.add(t);
|
|
4251
4288
|
return e;
|
|
4252
4289
|
}
|
|
4253
|
-
function
|
|
4290
|
+
function Jn(s, e) {
|
|
4254
4291
|
const t = [], n = [];
|
|
4255
4292
|
for (const i of e)
|
|
4256
4293
|
s.has(i) || t.push(i);
|
|
@@ -4258,7 +4295,7 @@ function Yn(s, e) {
|
|
|
4258
4295
|
e.has(i) || n.push(i);
|
|
4259
4296
|
return { added: t, removed: n };
|
|
4260
4297
|
}
|
|
4261
|
-
function
|
|
4298
|
+
function O(s) {
|
|
4262
4299
|
return {
|
|
4263
4300
|
startRow: Math.min(s.startRow, s.endRow),
|
|
4264
4301
|
startCol: Math.min(s.startCol, s.endCol),
|
|
@@ -4266,38 +4303,38 @@ function B(s) {
|
|
|
4266
4303
|
endCol: Math.max(s.startCol, s.endCol)
|
|
4267
4304
|
};
|
|
4268
4305
|
}
|
|
4269
|
-
function
|
|
4270
|
-
const e =
|
|
4306
|
+
function pn(s) {
|
|
4307
|
+
const e = O(s);
|
|
4271
4308
|
return {
|
|
4272
4309
|
from: { row: e.startRow, col: e.startCol },
|
|
4273
4310
|
to: { row: e.endRow, col: e.endCol }
|
|
4274
4311
|
};
|
|
4275
4312
|
}
|
|
4276
|
-
function
|
|
4277
|
-
return s.map(
|
|
4313
|
+
function Be(s) {
|
|
4314
|
+
return s.map(pn);
|
|
4278
4315
|
}
|
|
4279
|
-
function
|
|
4280
|
-
const n =
|
|
4316
|
+
function mn(s, e, t) {
|
|
4317
|
+
const n = O(t);
|
|
4281
4318
|
return s >= n.startRow && s <= n.endRow && e >= n.startCol && e <= n.endCol;
|
|
4282
4319
|
}
|
|
4283
4320
|
function Me(s, e, t) {
|
|
4284
|
-
return t.some((n) =>
|
|
4321
|
+
return t.some((n) => mn(s, e, n));
|
|
4285
4322
|
}
|
|
4286
|
-
function
|
|
4287
|
-
const e = [], t =
|
|
4323
|
+
function wn(s) {
|
|
4324
|
+
const e = [], t = O(s);
|
|
4288
4325
|
for (let n = t.startRow; n <= t.endRow; n++)
|
|
4289
4326
|
for (let i = t.startCol; i <= t.endCol; i++)
|
|
4290
4327
|
e.push({ row: n, col: i });
|
|
4291
4328
|
return e;
|
|
4292
4329
|
}
|
|
4293
|
-
function
|
|
4330
|
+
function bn(s) {
|
|
4294
4331
|
const e = /* @__PURE__ */ new Map();
|
|
4295
4332
|
for (const t of s)
|
|
4296
|
-
for (const n of
|
|
4333
|
+
for (const n of wn(t))
|
|
4297
4334
|
e.set(`${n.row},${n.col}`, n);
|
|
4298
4335
|
return [...e.values()];
|
|
4299
4336
|
}
|
|
4300
|
-
function
|
|
4337
|
+
function Z(s, e) {
|
|
4301
4338
|
return {
|
|
4302
4339
|
startRow: s.row,
|
|
4303
4340
|
startCol: s.col,
|
|
@@ -4305,8 +4342,8 @@ function J(s, e) {
|
|
|
4305
4342
|
endCol: e.col
|
|
4306
4343
|
};
|
|
4307
4344
|
}
|
|
4308
|
-
const
|
|
4309
|
-
function
|
|
4345
|
+
const vn = "@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)}}.tbw-selection-summary{font-size:var(--tbw-font-size-sm, .8125rem);color:var(--tbw-color-fg-muted);white-space:nowrap}}}";
|
|
4346
|
+
function yn(s, e, t) {
|
|
4310
4347
|
if (s === "cell" && e.selectedCell)
|
|
4311
4348
|
return {
|
|
4312
4349
|
mode: s,
|
|
@@ -4324,11 +4361,11 @@ function vn(s, e, t) {
|
|
|
4324
4361
|
}));
|
|
4325
4362
|
return { mode: s, ranges: n };
|
|
4326
4363
|
}
|
|
4327
|
-
return s === "range" && e.ranges.length > 0 ? { mode: s, ranges:
|
|
4364
|
+
return s === "range" && e.ranges.length > 0 ? { mode: s, ranges: Be(e.ranges) } : { mode: s, ranges: [] };
|
|
4328
4365
|
}
|
|
4329
|
-
class
|
|
4366
|
+
class Qn extends x {
|
|
4330
4367
|
name = "selection";
|
|
4331
|
-
styles =
|
|
4368
|
+
styles = vn;
|
|
4332
4369
|
get defaultConfig() {
|
|
4333
4370
|
return {
|
|
4334
4371
|
mode: "cell"
|
|
@@ -4356,17 +4393,17 @@ class Jn extends x {
|
|
|
4356
4393
|
// #endregion
|
|
4357
4394
|
// #region Event Handlers
|
|
4358
4395
|
onCellClick(e) {
|
|
4359
|
-
const { rowIndex: t, colIndex: n, originalEvent: i } = e, { mode:
|
|
4360
|
-
if (
|
|
4396
|
+
const { rowIndex: t, colIndex: n, originalEvent: i } = e, { mode: r } = this.config, o = this.columns[n], l = o && _(o);
|
|
4397
|
+
if (r === "cell")
|
|
4361
4398
|
return l || (this.selectedCell = { row: t, col: n }, this.emit("selection-change", this.#t()), this.requestAfterRender()), !1;
|
|
4362
|
-
if (
|
|
4399
|
+
if (r === "row")
|
|
4363
4400
|
return this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#t()), this.requestAfterRender(), !1;
|
|
4364
|
-
if (
|
|
4401
|
+
if (r === "range") {
|
|
4365
4402
|
if (l)
|
|
4366
4403
|
return !1;
|
|
4367
4404
|
const a = i.shiftKey, d = i.ctrlKey || i.metaKey;
|
|
4368
4405
|
if (a && this.cellAnchor) {
|
|
4369
|
-
const c =
|
|
4406
|
+
const c = Z(this.cellAnchor, { row: t, col: n });
|
|
4370
4407
|
d ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = c : this.ranges.push(c) : this.ranges = [c], this.activeRange = c;
|
|
4371
4408
|
} else if (d) {
|
|
4372
4409
|
const c = {
|
|
@@ -4402,17 +4439,17 @@ class Jn extends x {
|
|
|
4402
4439
|
this.selected.clear(), this.selected.add(this.grid._focusRow), this.lastSelected = this.grid._focusRow, this.emit("selection-change", this.#t()), this.requestAfterRender();
|
|
4403
4440
|
}), !1;
|
|
4404
4441
|
if (t === "range" && i) {
|
|
4405
|
-
const
|
|
4406
|
-
return
|
|
4442
|
+
const r = e.key === "Tab", o = e.shiftKey && !r;
|
|
4443
|
+
return o && !this.cellAnchor && (this.cellAnchor = { row: this.grid._focusRow, col: this.grid._focusCol }), this.pendingKeyboardUpdate = { shiftKey: o }, queueMicrotask(() => this.requestAfterRender()), !1;
|
|
4407
4444
|
}
|
|
4408
4445
|
if (t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey)) {
|
|
4409
|
-
const
|
|
4410
|
-
if (
|
|
4446
|
+
const r = this.rows.length, o = this.columns.length;
|
|
4447
|
+
if (r > 0 && o > 0) {
|
|
4411
4448
|
const l = {
|
|
4412
4449
|
startRow: 0,
|
|
4413
4450
|
startCol: 0,
|
|
4414
|
-
endRow:
|
|
4415
|
-
endCol:
|
|
4451
|
+
endRow: r - 1,
|
|
4452
|
+
endCol: o - 1
|
|
4416
4453
|
};
|
|
4417
4454
|
return this.ranges = [l], this.activeRange = l, this.emit("selection-change", this.#t()), this.requestAfterRender(), !0;
|
|
4418
4455
|
}
|
|
@@ -4427,23 +4464,23 @@ class Jn extends x {
|
|
|
4427
4464
|
this.isDragging = !0;
|
|
4428
4465
|
const n = e.rowIndex, i = e.colIndex;
|
|
4429
4466
|
this.cellAnchor = { row: n, col: i }, e.originalEvent.ctrlKey || e.originalEvent.metaKey || (this.ranges = []);
|
|
4430
|
-
const
|
|
4467
|
+
const o = {
|
|
4431
4468
|
startRow: n,
|
|
4432
4469
|
startCol: i,
|
|
4433
4470
|
endRow: n,
|
|
4434
4471
|
endCol: i
|
|
4435
4472
|
};
|
|
4436
|
-
return this.ranges.push(
|
|
4473
|
+
return this.ranges.push(o), this.activeRange = o, this.emit("selection-change", this.#t()), this.requestAfterRender(), !0;
|
|
4437
4474
|
}
|
|
4438
4475
|
onCellMouseMove(e) {
|
|
4439
4476
|
if (this.config.mode !== "range" || !this.isDragging || !this.cellAnchor || e.rowIndex === void 0 || e.colIndex === void 0 || e.rowIndex < 0) return;
|
|
4440
4477
|
let t = e.colIndex;
|
|
4441
4478
|
const n = this.columns[t];
|
|
4442
4479
|
if (n && _(n)) {
|
|
4443
|
-
const
|
|
4444
|
-
|
|
4480
|
+
const r = this.columns.findIndex((o) => !_(o));
|
|
4481
|
+
r >= 0 && (t = r);
|
|
4445
4482
|
}
|
|
4446
|
-
const i =
|
|
4483
|
+
const i = Z(this.cellAnchor, { row: e.rowIndex, col: t });
|
|
4447
4484
|
return this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = i : this.ranges.push(i), this.activeRange = i, this.emit("selection-change", this.#t()), this.requestAfterRender(), !0;
|
|
4448
4485
|
}
|
|
4449
4486
|
onCellMouseUp(e) {
|
|
@@ -4455,49 +4492,48 @@ class Jn extends x {
|
|
|
4455
4492
|
* Shared by afterRender and onScrollRender.
|
|
4456
4493
|
*/
|
|
4457
4494
|
#e() {
|
|
4458
|
-
const e = this.
|
|
4495
|
+
const e = this.gridElement;
|
|
4459
4496
|
if (!e) return;
|
|
4460
4497
|
const { mode: t } = this.config;
|
|
4461
|
-
e.querySelectorAll(".cell").forEach((
|
|
4462
|
-
|
|
4498
|
+
e.querySelectorAll(".cell").forEach((r) => {
|
|
4499
|
+
r.classList.remove("selected", "top", "bottom", "first", "last");
|
|
4463
4500
|
});
|
|
4464
4501
|
const i = e.querySelectorAll(".data-grid-row");
|
|
4465
|
-
if (i.forEach((
|
|
4466
|
-
|
|
4467
|
-
}), t === "row" && (
|
|
4468
|
-
const
|
|
4469
|
-
l >= 0 && this.selected.has(l) &&
|
|
4502
|
+
if (i.forEach((r) => {
|
|
4503
|
+
r.classList.remove("selected", "row-focus");
|
|
4504
|
+
}), t === "row" && (ce(e), i.forEach((r) => {
|
|
4505
|
+
const o = r.querySelector(".cell[data-row]"), l = Ze(o);
|
|
4506
|
+
l >= 0 && this.selected.has(l) && r.classList.add("selected", "row-focus");
|
|
4470
4507
|
})), t === "range" && this.ranges.length > 0) {
|
|
4471
|
-
|
|
4472
|
-
const
|
|
4508
|
+
ce(e);
|
|
4509
|
+
const r = this.activeRange ? O(this.activeRange) : null, o = this.columns.findIndex((a) => !_(a));
|
|
4473
4510
|
this.columns.length - 1, e.querySelectorAll(".cell[data-row][data-col]").forEach((a) => {
|
|
4474
4511
|
const d = parseInt(a.getAttribute("data-row") ?? "-1", 10), c = parseInt(a.getAttribute("data-col") ?? "-1", 10);
|
|
4475
4512
|
if (d >= 0 && c >= 0) {
|
|
4476
4513
|
const u = this.columns[c];
|
|
4477
4514
|
if (u && _(u))
|
|
4478
4515
|
return;
|
|
4479
|
-
if (Me(d, c, this.ranges) && (a.classList.add("selected"),
|
|
4480
|
-
d ===
|
|
4481
|
-
const f = Math.max(
|
|
4482
|
-
c === f && a.classList.add("first"), c ===
|
|
4516
|
+
if (Me(d, c, this.ranges) && (a.classList.add("selected"), r)) {
|
|
4517
|
+
d === r.startRow && a.classList.add("top"), d === r.endRow && a.classList.add("bottom");
|
|
4518
|
+
const f = Math.max(r.startCol, o);
|
|
4519
|
+
c === f && a.classList.add("first"), c === r.endCol && a.classList.add("last");
|
|
4483
4520
|
}
|
|
4484
4521
|
}
|
|
4485
4522
|
});
|
|
4486
4523
|
}
|
|
4487
|
-
t === "cell" && this.selectedCell && V(e);
|
|
4488
4524
|
}
|
|
4489
4525
|
afterRender() {
|
|
4490
|
-
const e = this.
|
|
4526
|
+
const e = this.gridElement;
|
|
4491
4527
|
if (!e) return;
|
|
4492
4528
|
const t = e.children[0], { mode: n } = this.config;
|
|
4493
4529
|
if (this.pendingKeyboardUpdate && n === "range") {
|
|
4494
4530
|
const { shiftKey: i } = this.pendingKeyboardUpdate;
|
|
4495
4531
|
this.pendingKeyboardUpdate = null;
|
|
4496
|
-
const
|
|
4532
|
+
const r = this.grid._focusRow, o = this.grid._focusCol;
|
|
4497
4533
|
if (i && this.cellAnchor) {
|
|
4498
|
-
const l =
|
|
4534
|
+
const l = Z(this.cellAnchor, { row: r, col: o });
|
|
4499
4535
|
this.ranges = [l], this.activeRange = l;
|
|
4500
|
-
} else i || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row:
|
|
4536
|
+
} else i || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: r, col: o });
|
|
4501
4537
|
this.emit("selection-change", this.#t());
|
|
4502
4538
|
}
|
|
4503
4539
|
this.grid.setAttribute("data-selection-mode", n), t && t.classList.toggle("selecting", this.isDragging), this.#e();
|
|
@@ -4560,7 +4596,7 @@ class Jn extends x {
|
|
|
4560
4596
|
* Get all selected cells across all ranges.
|
|
4561
4597
|
*/
|
|
4562
4598
|
getSelectedCells() {
|
|
4563
|
-
return
|
|
4599
|
+
return bn(this.ranges);
|
|
4564
4600
|
}
|
|
4565
4601
|
/**
|
|
4566
4602
|
* Check if a specific cell is in range selection.
|
|
@@ -4585,13 +4621,13 @@ class Jn extends x {
|
|
|
4585
4621
|
endCol: t.to.col
|
|
4586
4622
|
})), this.activeRange = this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] : null, this.emit("selection-change", {
|
|
4587
4623
|
mode: this.config.mode,
|
|
4588
|
-
ranges:
|
|
4624
|
+
ranges: Be(this.ranges)
|
|
4589
4625
|
}), this.requestAfterRender();
|
|
4590
4626
|
}
|
|
4591
4627
|
// #endregion
|
|
4592
4628
|
// #region Private Helpers
|
|
4593
4629
|
#t() {
|
|
4594
|
-
return
|
|
4630
|
+
return yn(
|
|
4595
4631
|
this.config.mode,
|
|
4596
4632
|
{
|
|
4597
4633
|
selectedCell: this.selectedCell,
|
|
@@ -4606,20 +4642,20 @@ class Jn extends x {
|
|
|
4606
4642
|
function G(s, e) {
|
|
4607
4643
|
return Math.floor(s / e);
|
|
4608
4644
|
}
|
|
4609
|
-
function
|
|
4645
|
+
function Cn(s, e) {
|
|
4610
4646
|
return {
|
|
4611
4647
|
start: s * e,
|
|
4612
4648
|
end: (s + 1) * e
|
|
4613
4649
|
};
|
|
4614
4650
|
}
|
|
4615
4651
|
function xn(s, e, t) {
|
|
4616
|
-
const n = G(s, t), i = G(e - 1, t),
|
|
4617
|
-
for (let
|
|
4618
|
-
|
|
4619
|
-
return
|
|
4652
|
+
const n = G(s, t), i = G(e - 1, t), r = [];
|
|
4653
|
+
for (let o = n; o <= i; o++)
|
|
4654
|
+
r.push(o);
|
|
4655
|
+
return r;
|
|
4620
4656
|
}
|
|
4621
4657
|
async function Pe(s, e, t, n) {
|
|
4622
|
-
const i =
|
|
4658
|
+
const i = Cn(e, t);
|
|
4623
4659
|
return s.getRows({
|
|
4624
4660
|
startRow: i.start,
|
|
4625
4661
|
endRow: i.end,
|
|
@@ -4627,14 +4663,14 @@ async function Pe(s, e, t, n) {
|
|
|
4627
4663
|
filterModel: n.filterModel
|
|
4628
4664
|
});
|
|
4629
4665
|
}
|
|
4630
|
-
function
|
|
4666
|
+
function Rn(s, e, t) {
|
|
4631
4667
|
const n = G(s, e), i = t.get(n);
|
|
4632
4668
|
if (!i) return;
|
|
4633
|
-
const
|
|
4634
|
-
return i[
|
|
4669
|
+
const r = s % e;
|
|
4670
|
+
return i[r];
|
|
4635
4671
|
}
|
|
4636
|
-
const
|
|
4637
|
-
class
|
|
4672
|
+
const En = 100;
|
|
4673
|
+
class ei extends x {
|
|
4638
4674
|
name = "serverSide";
|
|
4639
4675
|
get defaultConfig() {
|
|
4640
4676
|
return {
|
|
@@ -4663,14 +4699,14 @@ class Qn extends x {
|
|
|
4663
4699
|
loadRequiredBlocks() {
|
|
4664
4700
|
if (!this.dataSource) return;
|
|
4665
4701
|
const e = this.grid, t = this.config.cacheBlockSize ?? 100, n = { startRow: e._virtualization.start, endRow: e._virtualization.end }, i = xn(n.startRow, n.endRow, t);
|
|
4666
|
-
for (const
|
|
4667
|
-
if (!(this.loadedBlocks.has(
|
|
4702
|
+
for (const r of i)
|
|
4703
|
+
if (!(this.loadedBlocks.has(r) || this.loadingBlocks.has(r))) {
|
|
4668
4704
|
if (this.loadingBlocks.size >= (this.config.maxConcurrentRequests ?? 2))
|
|
4669
4705
|
break;
|
|
4670
|
-
this.loadingBlocks.add(
|
|
4671
|
-
this.loadedBlocks.set(
|
|
4706
|
+
this.loadingBlocks.add(r), Pe(this.dataSource, r, t, {}).then((o) => {
|
|
4707
|
+
this.loadedBlocks.set(r, o.rows), this.totalRowCount = o.totalRowCount, this.loadingBlocks.delete(r), this.requestRender(), this.loadRequiredBlocks();
|
|
4672
4708
|
}).catch(() => {
|
|
4673
|
-
this.loadingBlocks.delete(
|
|
4709
|
+
this.loadingBlocks.delete(r);
|
|
4674
4710
|
});
|
|
4675
4711
|
}
|
|
4676
4712
|
}
|
|
@@ -4680,7 +4716,7 @@ class Qn extends x {
|
|
|
4680
4716
|
if (!this.dataSource) return [...e];
|
|
4681
4717
|
const t = [];
|
|
4682
4718
|
for (let n = 0; n < this.totalRowCount; n++) {
|
|
4683
|
-
const i =
|
|
4719
|
+
const i = Rn(n, this.config.cacheBlockSize ?? 100, this.loadedBlocks);
|
|
4684
4720
|
t.push(i ?? { __loading: !0, __index: n });
|
|
4685
4721
|
}
|
|
4686
4722
|
return t;
|
|
@@ -4688,7 +4724,7 @@ class Qn extends x {
|
|
|
4688
4724
|
onScroll(e) {
|
|
4689
4725
|
this.dataSource && (this.loadRequiredBlocks(), this.scrollDebounceTimer && clearTimeout(this.scrollDebounceTimer), this.scrollDebounceTimer = setTimeout(() => {
|
|
4690
4726
|
this.loadRequiredBlocks();
|
|
4691
|
-
},
|
|
4727
|
+
}, En));
|
|
4692
4728
|
}
|
|
4693
4729
|
// #endregion
|
|
4694
4730
|
// #region Public API
|
|
@@ -4737,35 +4773,35 @@ class Qn extends x {
|
|
|
4737
4773
|
}
|
|
4738
4774
|
// #endregion
|
|
4739
4775
|
}
|
|
4740
|
-
function
|
|
4776
|
+
function Ve(s, e, t) {
|
|
4741
4777
|
return s.id !== void 0 ? String(s.id) : t ? `${t}-${e}` : String(e);
|
|
4742
4778
|
}
|
|
4743
|
-
function
|
|
4779
|
+
function J(s, e) {
|
|
4744
4780
|
const t = new Set(s);
|
|
4745
4781
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
4746
4782
|
}
|
|
4747
|
-
function
|
|
4748
|
-
const i = e.childrenField ?? "children",
|
|
4749
|
-
for (let
|
|
4750
|
-
const l = s[
|
|
4783
|
+
function te(s, e, t = null, n = 0) {
|
|
4784
|
+
const i = e.childrenField ?? "children", r = /* @__PURE__ */ new Set();
|
|
4785
|
+
for (let o = 0; o < s.length; o++) {
|
|
4786
|
+
const l = s[o], a = Ve(l, o, t), d = l[i];
|
|
4751
4787
|
if (Array.isArray(d) && d.length > 0) {
|
|
4752
|
-
|
|
4753
|
-
const c =
|
|
4754
|
-
for (const u of c)
|
|
4788
|
+
r.add(a);
|
|
4789
|
+
const c = te(d, e, a, n + 1);
|
|
4790
|
+
for (const u of c) r.add(u);
|
|
4755
4791
|
}
|
|
4756
4792
|
}
|
|
4757
|
-
return
|
|
4793
|
+
return r;
|
|
4758
4794
|
}
|
|
4759
|
-
function
|
|
4795
|
+
function Sn() {
|
|
4760
4796
|
return /* @__PURE__ */ new Set();
|
|
4761
4797
|
}
|
|
4762
4798
|
function We(s, e, t, n = null, i = 0) {
|
|
4763
|
-
const
|
|
4764
|
-
for (let
|
|
4765
|
-
const l = s[
|
|
4799
|
+
const r = t.childrenField ?? "children";
|
|
4800
|
+
for (let o = 0; o < s.length; o++) {
|
|
4801
|
+
const l = s[o], a = Ve(l, o, n);
|
|
4766
4802
|
if (a === e)
|
|
4767
4803
|
return [a];
|
|
4768
|
-
const d = l[
|
|
4804
|
+
const d = l[r];
|
|
4769
4805
|
if (Array.isArray(d) && d.length > 0) {
|
|
4770
4806
|
const c = We(d, e, t, a, i + 1);
|
|
4771
4807
|
if (c)
|
|
@@ -4774,13 +4810,13 @@ function We(s, e, t, n = null, i = 0) {
|
|
|
4774
4810
|
}
|
|
4775
4811
|
return null;
|
|
4776
4812
|
}
|
|
4777
|
-
function
|
|
4813
|
+
function kn(s, e, t, n) {
|
|
4778
4814
|
const i = We(s, e, t);
|
|
4779
4815
|
if (!i) return n;
|
|
4780
|
-
const
|
|
4781
|
-
for (let
|
|
4782
|
-
|
|
4783
|
-
return
|
|
4816
|
+
const r = new Set(n);
|
|
4817
|
+
for (let o = 0; o < i.length - 1; o++)
|
|
4818
|
+
r.add(i[o]);
|
|
4819
|
+
return r;
|
|
4784
4820
|
}
|
|
4785
4821
|
function De(s, e = "children") {
|
|
4786
4822
|
if (!Array.isArray(s) || s.length === 0) return !1;
|
|
@@ -4792,7 +4828,7 @@ function De(s, e = "children") {
|
|
|
4792
4828
|
}
|
|
4793
4829
|
return !1;
|
|
4794
4830
|
}
|
|
4795
|
-
function
|
|
4831
|
+
function An(s) {
|
|
4796
4832
|
if (!Array.isArray(s) || s.length === 0) return null;
|
|
4797
4833
|
const e = ["children", "items", "nodes", "subRows", "nested"];
|
|
4798
4834
|
for (const t of s)
|
|
@@ -4804,34 +4840,34 @@ function kn(s) {
|
|
|
4804
4840
|
}
|
|
4805
4841
|
return null;
|
|
4806
4842
|
}
|
|
4807
|
-
function
|
|
4843
|
+
function _n(s, e = "children", t = 0) {
|
|
4808
4844
|
if (!Array.isArray(s) || s.length === 0) return t;
|
|
4809
4845
|
let n = t;
|
|
4810
4846
|
for (const i of s) {
|
|
4811
4847
|
if (!i) continue;
|
|
4812
|
-
const
|
|
4813
|
-
if (Array.isArray(
|
|
4814
|
-
const
|
|
4815
|
-
|
|
4848
|
+
const r = i[e];
|
|
4849
|
+
if (Array.isArray(r) && r.length > 0) {
|
|
4850
|
+
const o = _n(r, e, t + 1);
|
|
4851
|
+
o > n && (n = o);
|
|
4816
4852
|
}
|
|
4817
4853
|
}
|
|
4818
4854
|
return n;
|
|
4819
4855
|
}
|
|
4820
|
-
function
|
|
4856
|
+
function Ln(s, e = "children") {
|
|
4821
4857
|
if (!Array.isArray(s)) return 0;
|
|
4822
4858
|
let t = 0;
|
|
4823
4859
|
for (const n of s) {
|
|
4824
4860
|
if (!n) continue;
|
|
4825
4861
|
t++;
|
|
4826
4862
|
const i = n[e];
|
|
4827
|
-
Array.isArray(i) && (t +=
|
|
4863
|
+
Array.isArray(i) && (t += Ln(i, e));
|
|
4828
4864
|
}
|
|
4829
4865
|
return t;
|
|
4830
4866
|
}
|
|
4831
|
-
const
|
|
4832
|
-
class
|
|
4867
|
+
const Tn = "@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}}}";
|
|
4868
|
+
class ti extends x {
|
|
4833
4869
|
name = "tree";
|
|
4834
|
-
styles =
|
|
4870
|
+
styles = Tn;
|
|
4835
4871
|
get defaultConfig() {
|
|
4836
4872
|
return {
|
|
4837
4873
|
childrenField: "children",
|
|
@@ -4866,7 +4902,7 @@ class ei extends x {
|
|
|
4866
4902
|
// #region Auto-Detection
|
|
4867
4903
|
detect(e) {
|
|
4868
4904
|
if (!this.config.autoDetect) return !1;
|
|
4869
|
-
const t = e, n = this.config.childrenField ??
|
|
4905
|
+
const t = e, n = this.config.childrenField ?? An(t) ?? "children";
|
|
4870
4906
|
return De(t, n);
|
|
4871
4907
|
}
|
|
4872
4908
|
// #endregion
|
|
@@ -4876,23 +4912,23 @@ class ei extends x {
|
|
|
4876
4912
|
if (!De(n, t))
|
|
4877
4913
|
return this.flattenedRows = [], this.rowKeyMap.clear(), this.previousVisibleKeys.clear(), [...e];
|
|
4878
4914
|
let i = this.withStableKeys(n);
|
|
4879
|
-
this.sortState && (i = this.sortTree(i, this.sortState.field, this.sortState.direction)), this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys =
|
|
4880
|
-
const
|
|
4881
|
-
for (const
|
|
4882
|
-
this.rowKeyMap.set(
|
|
4883
|
-
return this.previousVisibleKeys =
|
|
4884
|
-
...
|
|
4885
|
-
__treeKey:
|
|
4886
|
-
__treeDepth:
|
|
4887
|
-
__treeHasChildren:
|
|
4888
|
-
__treeExpanded:
|
|
4915
|
+
this.sortState && (i = this.sortTree(i, this.sortState.field, this.sortState.direction)), this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = te(i, this.config), this.initialExpansionDone = !0), this.flattenedRows = this.flattenTree(i, this.expandedKeys), this.rowKeyMap.clear(), this.keysToAnimate.clear();
|
|
4916
|
+
const r = /* @__PURE__ */ new Set();
|
|
4917
|
+
for (const o of this.flattenedRows)
|
|
4918
|
+
this.rowKeyMap.set(o.key, o), r.add(o.key), !this.previousVisibleKeys.has(o.key) && o.depth > 0 && this.keysToAnimate.add(o.key);
|
|
4919
|
+
return this.previousVisibleKeys = r, this.flattenedRows.map((o) => ({
|
|
4920
|
+
...o.data,
|
|
4921
|
+
__treeKey: o.key,
|
|
4922
|
+
__treeDepth: o.depth,
|
|
4923
|
+
__treeHasChildren: o.hasChildren,
|
|
4924
|
+
__treeExpanded: o.isExpanded
|
|
4889
4925
|
}));
|
|
4890
4926
|
}
|
|
4891
4927
|
/** Assign stable keys to rows (preserves key across sort operations) */
|
|
4892
4928
|
withStableKeys(e, t = null) {
|
|
4893
4929
|
const n = this.config.childrenField ?? "children";
|
|
4894
|
-
return e.map((i,
|
|
4895
|
-
const
|
|
4930
|
+
return e.map((i, r) => {
|
|
4931
|
+
const o = i.__stableKey, l = i.id !== void 0 ? String(i.id) : o ?? (t ? `${t}-${r}` : String(r)), a = i[n], d = Array.isArray(a) && a.length > 0;
|
|
4896
4932
|
return {
|
|
4897
4933
|
...i,
|
|
4898
4934
|
__stableKey: l,
|
|
@@ -4902,52 +4938,52 @@ class ei extends x {
|
|
|
4902
4938
|
}
|
|
4903
4939
|
/** Flatten tree using stable keys */
|
|
4904
4940
|
flattenTree(e, t, n = 0) {
|
|
4905
|
-
const i = this.config.childrenField ?? "children",
|
|
4906
|
-
for (const
|
|
4907
|
-
const a =
|
|
4908
|
-
|
|
4941
|
+
const i = this.config.childrenField ?? "children", r = [];
|
|
4942
|
+
for (const o of e) {
|
|
4943
|
+
const a = o.__stableKey ?? String(o.id ?? "?"), d = o[i], c = Array.isArray(d) && d.length > 0, u = t.has(a);
|
|
4944
|
+
r.push({
|
|
4909
4945
|
key: a,
|
|
4910
|
-
data:
|
|
4946
|
+
data: o,
|
|
4911
4947
|
depth: n,
|
|
4912
4948
|
hasChildren: c,
|
|
4913
4949
|
isExpanded: u,
|
|
4914
4950
|
parentKey: n > 0 && a.substring(0, a.lastIndexOf("-")) || null
|
|
4915
|
-
}), c && u &&
|
|
4951
|
+
}), c && u && r.push(...this.flattenTree(d, t, n + 1));
|
|
4916
4952
|
}
|
|
4917
|
-
return
|
|
4953
|
+
return r;
|
|
4918
4954
|
}
|
|
4919
4955
|
/** Sort tree recursively, keeping children with parents */
|
|
4920
4956
|
sortTree(e, t, n) {
|
|
4921
4957
|
const i = this.config.childrenField ?? "children";
|
|
4922
|
-
return [...e].sort((
|
|
4923
|
-
const a =
|
|
4958
|
+
return [...e].sort((o, l) => {
|
|
4959
|
+
const a = o[t], d = l[t];
|
|
4924
4960
|
return a == null && d == null ? 0 : a == null ? -1 : d == null ? 1 : a > d ? n : a < d ? -n : 0;
|
|
4925
|
-
}).map((
|
|
4926
|
-
const l =
|
|
4927
|
-
return Array.isArray(l) && l.length > 0 ? { ...
|
|
4961
|
+
}).map((o) => {
|
|
4962
|
+
const l = o[i];
|
|
4963
|
+
return Array.isArray(l) && l.length > 0 ? { ...o, [i]: this.sortTree(l, t, n) } : o;
|
|
4928
4964
|
});
|
|
4929
4965
|
}
|
|
4930
4966
|
processColumns(e) {
|
|
4931
4967
|
if (this.flattenedRows.length === 0) return [...e];
|
|
4932
4968
|
const t = [...e];
|
|
4933
4969
|
if (t.length === 0) return t;
|
|
4934
|
-
const n = t[0], i = n.viewRenderer,
|
|
4935
|
-
const { row: c, value: u } = d, {
|
|
4936
|
-
if (
|
|
4970
|
+
const n = t[0], i = n.viewRenderer, r = () => this.config, o = this.setIcon.bind(this), l = this.resolveIcon.bind(this), a = (d) => {
|
|
4971
|
+
const { row: c, value: u } = d, { showExpandIcons: h = !0, indentWidth: f } = r(), g = c, p = g.__treeDepth ?? 0, w = document.createElement("span");
|
|
4972
|
+
if (w.className = "tree-cell-wrapper", w.style.setProperty("--tbw-tree-depth", String(p)), f !== void 0 && w.style.setProperty("--tbw-tree-indent-width", `${f}px`), h)
|
|
4937
4973
|
if (g.__treeHasChildren) {
|
|
4938
|
-
const
|
|
4939
|
-
|
|
4974
|
+
const b = document.createElement("span");
|
|
4975
|
+
b.className = `tree-toggle${g.__treeExpanded ? " expanded" : ""}`, o(b, l(g.__treeExpanded ? "collapse" : "expand")), b.setAttribute("data-tree-key", String(g.__treeKey ?? "")), w.appendChild(b);
|
|
4940
4976
|
} else {
|
|
4941
|
-
const
|
|
4942
|
-
|
|
4977
|
+
const b = document.createElement("span");
|
|
4978
|
+
b.className = "tree-spacer", w.appendChild(b);
|
|
4943
4979
|
}
|
|
4944
4980
|
const m = document.createElement("span");
|
|
4945
4981
|
if (m.className = "tree-content", i) {
|
|
4946
|
-
const
|
|
4947
|
-
|
|
4982
|
+
const b = i(d);
|
|
4983
|
+
b instanceof Node ? m.appendChild(b) : typeof b == "string" && (m.innerHTML = b);
|
|
4948
4984
|
} else
|
|
4949
4985
|
m.textContent = u != null ? String(u) : "";
|
|
4950
|
-
return
|
|
4986
|
+
return w.appendChild(m), w;
|
|
4951
4987
|
};
|
|
4952
4988
|
return t[0] = { ...n, viewRenderer: a }, t;
|
|
4953
4989
|
}
|
|
@@ -4959,7 +4995,7 @@ class ei extends x {
|
|
|
4959
4995
|
const n = t.getAttribute("data-tree-key");
|
|
4960
4996
|
if (!n) return !1;
|
|
4961
4997
|
const i = this.rowKeyMap.get(n);
|
|
4962
|
-
return i ? (this.expandedKeys =
|
|
4998
|
+
return i ? (this.expandedKeys = J(this.expandedKeys, n), this.emit("tree-expand", {
|
|
4963
4999
|
key: n,
|
|
4964
5000
|
row: i.data,
|
|
4965
5001
|
expanded: this.expandedKeys.has(n),
|
|
@@ -4970,7 +5006,7 @@ class ei extends x {
|
|
|
4970
5006
|
if (e.key !== " ") return;
|
|
4971
5007
|
const t = this.grid._focusRow, n = this.flattenedRows[t];
|
|
4972
5008
|
if (n?.hasChildren)
|
|
4973
|
-
return e.preventDefault(), this.expandedKeys =
|
|
5009
|
+
return e.preventDefault(), this.expandedKeys = J(this.expandedKeys, n.key), this.emit("tree-expand", {
|
|
4974
5010
|
key: n.key,
|
|
4975
5011
|
row: n.data,
|
|
4976
5012
|
expanded: this.expandedKeys.has(n.key),
|
|
@@ -4987,11 +5023,11 @@ class ei extends x {
|
|
|
4987
5023
|
afterRender() {
|
|
4988
5024
|
const e = this.animationStyle;
|
|
4989
5025
|
if (e === !1 || this.keysToAnimate.size === 0) return;
|
|
4990
|
-
const t = this.
|
|
5026
|
+
const t = this.gridElement?.querySelector(".rows");
|
|
4991
5027
|
if (!t) return;
|
|
4992
5028
|
const n = e === "fade" ? "tbw-tree-fade-in" : "tbw-tree-slide-in";
|
|
4993
5029
|
for (const i of t.querySelectorAll(".data-grid-row")) {
|
|
4994
|
-
const
|
|
5030
|
+
const r = i.querySelector(".cell[data-row]"), o = r ? parseInt(r.getAttribute("data-row") ?? "-1", 10) : -1, l = this.flattenedRows[o]?.key;
|
|
4995
5031
|
l && this.keysToAnimate.has(l) && (i.classList.add(n), i.addEventListener("animationend", () => i.classList.remove(n), { once: !0 }));
|
|
4996
5032
|
}
|
|
4997
5033
|
this.keysToAnimate.clear();
|
|
@@ -5005,13 +5041,13 @@ class ei extends x {
|
|
|
5005
5041
|
this.expandedKeys.delete(e), this.requestRender();
|
|
5006
5042
|
}
|
|
5007
5043
|
toggle(e) {
|
|
5008
|
-
this.expandedKeys =
|
|
5044
|
+
this.expandedKeys = J(this.expandedKeys, e), this.requestRender();
|
|
5009
5045
|
}
|
|
5010
5046
|
expandAll() {
|
|
5011
|
-
this.expandedKeys =
|
|
5047
|
+
this.expandedKeys = te(this.rows, this.config), this.requestRender();
|
|
5012
5048
|
}
|
|
5013
5049
|
collapseAll() {
|
|
5014
|
-
this.expandedKeys =
|
|
5050
|
+
this.expandedKeys = Sn(), this.requestRender();
|
|
5015
5051
|
}
|
|
5016
5052
|
isExpanded(e) {
|
|
5017
5053
|
return this.expandedKeys.has(e);
|
|
@@ -5026,11 +5062,11 @@ class ei extends x {
|
|
|
5026
5062
|
return this.rowKeyMap.get(e)?.data;
|
|
5027
5063
|
}
|
|
5028
5064
|
expandToKey(e) {
|
|
5029
|
-
this.expandedKeys =
|
|
5065
|
+
this.expandedKeys = kn(this.rows, e, this.config, this.expandedKeys), this.requestRender();
|
|
5030
5066
|
}
|
|
5031
5067
|
// #endregion
|
|
5032
5068
|
}
|
|
5033
|
-
function
|
|
5069
|
+
function In(s, e, t) {
|
|
5034
5070
|
const n = [...s.undoStack, e];
|
|
5035
5071
|
for (; n.length > t; )
|
|
5036
5072
|
n.shift();
|
|
@@ -5064,16 +5100,16 @@ function qe(s) {
|
|
|
5064
5100
|
action: t
|
|
5065
5101
|
} : { newState: s, action: null };
|
|
5066
5102
|
}
|
|
5067
|
-
function
|
|
5103
|
+
function Fn(s) {
|
|
5068
5104
|
return s.undoStack.length > 0;
|
|
5069
5105
|
}
|
|
5070
|
-
function
|
|
5106
|
+
function Mn(s) {
|
|
5071
5107
|
return s.redoStack.length > 0;
|
|
5072
5108
|
}
|
|
5073
|
-
function
|
|
5109
|
+
function Pn() {
|
|
5074
5110
|
return { undoStack: [], redoStack: [] };
|
|
5075
5111
|
}
|
|
5076
|
-
function
|
|
5112
|
+
function Dn(s, e, t, n) {
|
|
5077
5113
|
return {
|
|
5078
5114
|
type: "cell-edit",
|
|
5079
5115
|
rowIndex: s,
|
|
@@ -5083,7 +5119,7 @@ function Pn(s, e, t, n) {
|
|
|
5083
5119
|
timestamp: Date.now()
|
|
5084
5120
|
};
|
|
5085
5121
|
}
|
|
5086
|
-
class
|
|
5122
|
+
class ni extends x {
|
|
5087
5123
|
/**
|
|
5088
5124
|
* Plugin dependencies - UndoRedoPlugin requires EditingPlugin to track edits.
|
|
5089
5125
|
*
|
|
@@ -5117,8 +5153,8 @@ class ti extends x {
|
|
|
5117
5153
|
if (t) {
|
|
5118
5154
|
const i = Ke({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
5119
5155
|
if (i.action) {
|
|
5120
|
-
const
|
|
5121
|
-
|
|
5156
|
+
const r = this.rows;
|
|
5157
|
+
r[i.action.rowIndex] && (r[i.action.rowIndex][i.action.field] = i.action.oldValue), this.undoStack = i.newState.undoStack, this.redoStack = i.newState.redoStack, this.emit("undo", {
|
|
5122
5158
|
action: i.action,
|
|
5123
5159
|
type: "undo"
|
|
5124
5160
|
}), this.requestRender();
|
|
@@ -5128,8 +5164,8 @@ class ti extends x {
|
|
|
5128
5164
|
if (n) {
|
|
5129
5165
|
const i = qe({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
5130
5166
|
if (i.action) {
|
|
5131
|
-
const
|
|
5132
|
-
|
|
5167
|
+
const r = this.rows;
|
|
5168
|
+
r[i.action.rowIndex] && (r[i.action.rowIndex][i.action.field] = i.action.newValue), this.undoStack = i.newState.undoStack, this.redoStack = i.newState.redoStack, this.emit("redo", {
|
|
5133
5169
|
action: i.action,
|
|
5134
5170
|
type: "redo"
|
|
5135
5171
|
}), this.requestRender();
|
|
@@ -5149,12 +5185,12 @@ class ti extends x {
|
|
|
5149
5185
|
* @param newValue - The value after the edit
|
|
5150
5186
|
*/
|
|
5151
5187
|
recordEdit(e, t, n, i) {
|
|
5152
|
-
const
|
|
5188
|
+
const r = Dn(e, t, n, i), o = In(
|
|
5153
5189
|
{ undoStack: this.undoStack, redoStack: this.redoStack },
|
|
5154
|
-
|
|
5190
|
+
r,
|
|
5155
5191
|
this.config.maxHistorySize ?? 100
|
|
5156
5192
|
);
|
|
5157
|
-
this.undoStack =
|
|
5193
|
+
this.undoStack = o.undoStack, this.redoStack = o.redoStack;
|
|
5158
5194
|
}
|
|
5159
5195
|
/**
|
|
5160
5196
|
* Programmatically undo the last action.
|
|
@@ -5186,19 +5222,19 @@ class ti extends x {
|
|
|
5186
5222
|
* Check if there are any actions that can be undone.
|
|
5187
5223
|
*/
|
|
5188
5224
|
canUndo() {
|
|
5189
|
-
return
|
|
5225
|
+
return Fn({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
5190
5226
|
}
|
|
5191
5227
|
/**
|
|
5192
5228
|
* Check if there are any actions that can be redone.
|
|
5193
5229
|
*/
|
|
5194
5230
|
canRedo() {
|
|
5195
|
-
return
|
|
5231
|
+
return Mn({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
5196
5232
|
}
|
|
5197
5233
|
/**
|
|
5198
5234
|
* Clear all undo/redo history.
|
|
5199
5235
|
*/
|
|
5200
5236
|
clearHistory() {
|
|
5201
|
-
const e =
|
|
5237
|
+
const e = Pn();
|
|
5202
5238
|
this.undoStack = e.undoStack, this.redoStack = e.redoStack;
|
|
5203
5239
|
}
|
|
5204
5240
|
/**
|
|
@@ -5215,7 +5251,7 @@ class ti extends x {
|
|
|
5215
5251
|
}
|
|
5216
5252
|
// #endregion
|
|
5217
5253
|
}
|
|
5218
|
-
const
|
|
5254
|
+
const Kn = '@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))}}';
|
|
5219
5255
|
function Ne(s) {
|
|
5220
5256
|
const e = s.meta ?? {};
|
|
5221
5257
|
return e.lockPosition !== !0 && e.suppressMovable !== !0;
|
|
@@ -5232,7 +5268,7 @@ class M extends x {
|
|
|
5232
5268
|
name = "visibility";
|
|
5233
5269
|
/** Tool panel ID for shell integration */
|
|
5234
5270
|
static PANEL_ID = "columns";
|
|
5235
|
-
styles =
|
|
5271
|
+
styles = Kn;
|
|
5236
5272
|
get defaultConfig() {
|
|
5237
5273
|
return {
|
|
5238
5274
|
allowHideAll: !1
|
|
@@ -5405,16 +5441,16 @@ class M extends x {
|
|
|
5405
5441
|
e.innerHTML = "";
|
|
5406
5442
|
const n = this.grid.getAllColumns().filter((i) => !i.utility);
|
|
5407
5443
|
for (let i = 0; i < n.length; i++) {
|
|
5408
|
-
const
|
|
5409
|
-
l.className =
|
|
5444
|
+
const r = n[i], o = r.header || r.field, l = document.createElement("div");
|
|
5445
|
+
l.className = r.lockVisible ? "tbw-visibility-row locked" : "tbw-visibility-row", l.setAttribute("data-field", r.field), l.setAttribute("data-index", String(i)), t && Ne(r) && (l.draggable = !0, l.classList.add("reorderable"), this.setupDragListeners(l, r.field, i, e));
|
|
5410
5446
|
const a = document.createElement("label");
|
|
5411
5447
|
a.className = "tbw-visibility-label";
|
|
5412
5448
|
const d = document.createElement("input");
|
|
5413
|
-
d.type = "checkbox", d.checked =
|
|
5414
|
-
this.grid.toggleColumnVisibility(
|
|
5449
|
+
d.type = "checkbox", d.checked = r.visible, d.disabled = r.lockVisible ?? !1, d.addEventListener("change", () => {
|
|
5450
|
+
this.grid.toggleColumnVisibility(r.field), setTimeout(() => this.rebuildToggles(e), 0);
|
|
5415
5451
|
});
|
|
5416
5452
|
const c = document.createElement("span");
|
|
5417
|
-
if (c.textContent =
|
|
5453
|
+
if (c.textContent = o, a.appendChild(d), a.appendChild(c), t && Ne(r)) {
|
|
5418
5454
|
const u = document.createElement("span");
|
|
5419
5455
|
u.className = "tbw-visibility-handle", this.setIcon(u, this.resolveIcon("dragHandle")), u.title = "Drag to reorder", l.appendChild(u);
|
|
5420
5456
|
}
|
|
@@ -5426,31 +5462,32 @@ class M extends x {
|
|
|
5426
5462
|
* On drop, emits a 'column-reorder-request' event for other plugins to handle.
|
|
5427
5463
|
*/
|
|
5428
5464
|
setupDragListeners(e, t, n, i) {
|
|
5429
|
-
e.addEventListener("dragstart", (
|
|
5430
|
-
this.isDragging = !0, this.draggedField = t, this.draggedIndex = n,
|
|
5465
|
+
e.addEventListener("dragstart", (r) => {
|
|
5466
|
+
this.isDragging = !0, this.draggedField = t, this.draggedIndex = n, r.dataTransfer && (r.dataTransfer.effectAllowed = "move", r.dataTransfer.setData("text/plain", t)), e.classList.add("dragging");
|
|
5431
5467
|
}), e.addEventListener("dragend", () => {
|
|
5432
5468
|
this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, this.clearDragClasses(i);
|
|
5433
|
-
}), e.addEventListener("dragover", (
|
|
5434
|
-
if (
|
|
5435
|
-
const
|
|
5436
|
-
this.dropIndex =
|
|
5469
|
+
}), e.addEventListener("dragover", (r) => {
|
|
5470
|
+
if (r.preventDefault(), !this.isDragging || this.draggedField === t) return;
|
|
5471
|
+
const o = e.getBoundingClientRect(), l = o.top + o.height / 2;
|
|
5472
|
+
this.dropIndex = r.clientY < l ? n : n + 1, i.querySelectorAll(".tbw-visibility-row").forEach((a) => {
|
|
5437
5473
|
a !== e && a.classList.remove("drop-target", "drop-before", "drop-after");
|
|
5438
|
-
}), e.classList.add("drop-target"), e.classList.toggle("drop-before",
|
|
5474
|
+
}), e.classList.add("drop-target"), e.classList.toggle("drop-before", r.clientY < l), e.classList.toggle("drop-after", r.clientY >= l);
|
|
5439
5475
|
}), e.addEventListener("dragleave", () => {
|
|
5440
5476
|
e.classList.remove("drop-target", "drop-before", "drop-after");
|
|
5441
|
-
}), e.addEventListener("drop", (
|
|
5442
|
-
|
|
5443
|
-
const
|
|
5444
|
-
if (!this.isDragging ||
|
|
5477
|
+
}), e.addEventListener("drop", (r) => {
|
|
5478
|
+
r.preventDefault();
|
|
5479
|
+
const o = this.draggedField, l = this.draggedIndex, a = this.dropIndex;
|
|
5480
|
+
if (!this.isDragging || o === null || l === null || a === null)
|
|
5445
5481
|
return;
|
|
5446
5482
|
const d = a > l ? a - 1 : a;
|
|
5447
5483
|
if (d !== l) {
|
|
5448
|
-
const c = {
|
|
5449
|
-
field:
|
|
5484
|
+
const c = this.grid.getAllColumns(), h = c.filter((p) => !p.utility)[d]?.field, f = h ? c.findIndex((p) => p.field === h) : c.length, g = {
|
|
5485
|
+
field: o,
|
|
5450
5486
|
fromIndex: l,
|
|
5451
|
-
|
|
5487
|
+
// Not used by ReorderPlugin, just for info
|
|
5488
|
+
toIndex: f
|
|
5452
5489
|
};
|
|
5453
|
-
this.emit("column-reorder-request",
|
|
5490
|
+
this.emit("column-reorder-request", g), setTimeout(() => {
|
|
5454
5491
|
this.rebuildToggles(i);
|
|
5455
5492
|
}, 0);
|
|
5456
5493
|
}
|
|
@@ -5460,52 +5497,54 @@ class M extends x {
|
|
|
5460
5497
|
}
|
|
5461
5498
|
export {
|
|
5462
5499
|
x as BaseGridPlugin,
|
|
5463
|
-
|
|
5464
|
-
|
|
5465
|
-
|
|
5500
|
+
Nn as ClipboardPlugin,
|
|
5501
|
+
Hn as ColumnVirtualizationPlugin,
|
|
5502
|
+
zn as ContextMenuPlugin,
|
|
5466
5503
|
oi as DEFAULT_ANIMATION_CONFIG,
|
|
5467
5504
|
$e as DEFAULT_GRID_ICONS,
|
|
5468
|
-
|
|
5469
|
-
|
|
5470
|
-
|
|
5505
|
+
si as DGEvents,
|
|
5506
|
+
li as DataGridElement,
|
|
5507
|
+
On as EditingPlugin,
|
|
5471
5508
|
Bn as ExportPlugin,
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
|
|
5509
|
+
j as FOCUSABLE_EDITOR_SELECTOR,
|
|
5510
|
+
S as FilteringPlugin,
|
|
5511
|
+
ai as FitModeEnum,
|
|
5512
|
+
di as GridCSSVars,
|
|
5513
|
+
ci as GridClasses,
|
|
5514
|
+
ui as GridDataAttrs,
|
|
5515
|
+
hi as GridElement,
|
|
5516
|
+
fi as GridSelectors,
|
|
5480
5517
|
Vn as GroupingColumnsPlugin,
|
|
5481
|
-
|
|
5518
|
+
Wn as GroupingRowsPlugin,
|
|
5482
5519
|
Ge as MasterDetailPlugin,
|
|
5483
|
-
|
|
5520
|
+
$n as MultiSortPlugin,
|
|
5484
5521
|
He as PLUGIN_QUERIES,
|
|
5485
|
-
|
|
5486
|
-
|
|
5522
|
+
jn as PinnedColumnsPlugin,
|
|
5523
|
+
Un as PinnedRowsPlugin,
|
|
5487
5524
|
F as PivotPlugin,
|
|
5488
|
-
|
|
5489
|
-
|
|
5490
|
-
|
|
5491
|
-
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
|
|
5495
|
-
|
|
5525
|
+
gi as PluginEvents,
|
|
5526
|
+
pi as PluginManager,
|
|
5527
|
+
mi as RenderPhase,
|
|
5528
|
+
Yn as ReorderPlugin,
|
|
5529
|
+
Qn as SelectionPlugin,
|
|
5530
|
+
ei as ServerSidePlugin,
|
|
5531
|
+
ti as TreePlugin,
|
|
5532
|
+
ni as UndoRedoPlugin,
|
|
5496
5533
|
M as VisibilityPlugin,
|
|
5497
|
-
|
|
5498
|
-
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5534
|
+
wi as builtInSort,
|
|
5535
|
+
ct as clearEditingState,
|
|
5536
|
+
Jn as computeSelectionDiff,
|
|
5537
|
+
Ln as countNodes,
|
|
5538
|
+
bi as createGrid,
|
|
5539
|
+
vi as defaultComparator,
|
|
5540
|
+
at as defaultEditorFor,
|
|
5503
5541
|
nt as defaultPasteHandler,
|
|
5504
5542
|
De as detectTreeStructure,
|
|
5505
|
-
|
|
5543
|
+
_n as getMaxDepth,
|
|
5506
5544
|
Xn as handleRowClick,
|
|
5507
|
-
|
|
5508
|
-
|
|
5545
|
+
Gn as hasEditingCells,
|
|
5546
|
+
An as inferChildrenField,
|
|
5547
|
+
yi as queryGrid,
|
|
5509
5548
|
Zn as selectAll
|
|
5510
5549
|
};
|
|
5511
5550
|
//# sourceMappingURL=all.js.map
|