@toolbox-web/grid 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.d.ts +56 -23
- package/all.js +841 -809
- package/all.js.map +1 -1
- package/index.d.ts +12 -5
- package/index.js +276 -225
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +46 -45
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +1 -1
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +1 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +55 -47
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +243 -241
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +87 -67
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +28 -27
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +2 -2
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +70 -70
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +13 -13
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +7 -7
- package/umd/grid.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/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/server-side.umd.js +1 -1
- package/umd/plugins/server-side.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
package/all.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { BaseGridPlugin as
|
|
2
|
-
import { DGEvents as
|
|
3
|
-
function Be(
|
|
1
|
+
import { BaseGridPlugin as y, DEFAULT_GRID_ICONS as Ge, runAggregator as se, PLUGIN_QUERIES as Ke, getAggregator as le, getValueAggregator as Oe } from "./index.js";
|
|
2
|
+
import { DGEvents as Pn, DataGridElement as Kn, FitModeEnum as qn, GridCSSVars as Dn, GridClasses as Hn, GridDataAttrs as Gn, DataGridElement as On, GridSelectors as Bn, PluginEvents as Vn, PluginManager as zn, aggregatorRegistry as Wn, listAggregators as $n, registerAggregator as jn, runValueAggregator as Un, unregisterAggregator as Yn } from "./index.js";
|
|
3
|
+
function Be(s, e, t, n) {
|
|
4
4
|
if (n.processCell)
|
|
5
|
-
return n.processCell(
|
|
6
|
-
if (
|
|
7
|
-
if (
|
|
8
|
-
if (typeof
|
|
9
|
-
const o = String(
|
|
5
|
+
return n.processCell(s, e, t);
|
|
6
|
+
if (s == null) return "";
|
|
7
|
+
if (s instanceof Date) return s.toISOString();
|
|
8
|
+
if (typeof s == "object") return JSON.stringify(s);
|
|
9
|
+
const o = String(s), i = n.delimiter ?? " ", r = n.newline ?? `
|
|
10
10
|
`;
|
|
11
|
-
return n.quoteStrings || o.includes(i) || o.includes(
|
|
11
|
+
return n.quoteStrings || o.includes(i) || o.includes(r) || o.includes('"') ? `"${o.replace(/"/g, '""')}"` : o;
|
|
12
12
|
}
|
|
13
|
-
function H(
|
|
14
|
-
const { rows: e, columns: t, selectedIndices: n, config: o } =
|
|
13
|
+
function H(s) {
|
|
14
|
+
const { rows: e, columns: t, selectedIndices: n, config: o } = s, i = o.delimiter ?? " ", r = o.newline ?? `
|
|
15
15
|
`, l = t.filter((u) => !u.hidden && !u.field.startsWith("__")), a = [];
|
|
16
16
|
if (o.includeHeaders) {
|
|
17
17
|
const u = l.map((h) => {
|
|
18
18
|
const g = h.header || h.field;
|
|
19
|
-
return g.includes(i) || g.includes(
|
|
19
|
+
return g.includes(i) || g.includes(r) || g.includes('"') ? `"${g.replace(/"/g, '""')}"` : g;
|
|
20
20
|
});
|
|
21
21
|
a.push(u.join(i));
|
|
22
22
|
}
|
|
@@ -29,38 +29,38 @@ function H(r) {
|
|
|
29
29
|
);
|
|
30
30
|
a.push(g.join(i));
|
|
31
31
|
}
|
|
32
|
-
return a.join(
|
|
32
|
+
return a.join(r);
|
|
33
33
|
}
|
|
34
|
-
async function G(
|
|
34
|
+
async function G(s) {
|
|
35
35
|
try {
|
|
36
|
-
return await navigator.clipboard.writeText(
|
|
36
|
+
return await navigator.clipboard.writeText(s), !0;
|
|
37
37
|
} catch {
|
|
38
38
|
const e = document.createElement("textarea");
|
|
39
|
-
e.value =
|
|
39
|
+
e.value = s, e.style.position = "fixed", e.style.opacity = "0", e.style.pointerEvents = "none", document.body.appendChild(e), e.select();
|
|
40
40
|
const t = document.execCommand("copy");
|
|
41
41
|
return document.body.removeChild(e), t;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
function
|
|
44
|
+
function ae(s, e) {
|
|
45
45
|
const t = e.delimiter ?? " ", n = e.newline ?? `
|
|
46
|
-
`, o =
|
|
46
|
+
`, o = s.replace(/\r\n/g, `
|
|
47
47
|
`).replace(/\r/g, `
|
|
48
48
|
`), i = [];
|
|
49
|
-
let
|
|
49
|
+
let r = [], l = "", a = !1;
|
|
50
50
|
for (let d = 0; d < o.length; d++) {
|
|
51
51
|
const c = o[d];
|
|
52
|
-
c === '"' && !a ? a = !0 : c === '"' && a ? o[d + 1] === '"' ? (l += '"', d++) : a = !1 : c === t && !a ? (
|
|
52
|
+
c === '"' && !a ? a = !0 : c === '"' && a ? o[d + 1] === '"' ? (l += '"', d++) : a = !1 : c === t && !a ? (r.push(l), l = "") : c === n && !a ? (r.push(l), l = "", (r.length > 1 || r.some((u) => u.trim() !== "")) && i.push(r), r = []) : l += c;
|
|
53
53
|
}
|
|
54
|
-
return
|
|
54
|
+
return r.push(l), (r.length > 1 || r.some((d) => d.trim() !== "")) && i.push(r), i;
|
|
55
55
|
}
|
|
56
|
-
async function
|
|
56
|
+
async function de() {
|
|
57
57
|
try {
|
|
58
58
|
return await navigator.clipboard.readText();
|
|
59
59
|
} catch {
|
|
60
60
|
return "";
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
class
|
|
63
|
+
class bn extends y {
|
|
64
64
|
name = "clipboard";
|
|
65
65
|
version = "1.0.0";
|
|
66
66
|
get defaultConfig() {
|
|
@@ -92,7 +92,7 @@ class wn extends x {
|
|
|
92
92
|
* Handle copy operation
|
|
93
93
|
*/
|
|
94
94
|
#t(e) {
|
|
95
|
-
const t = this.#n(), n = t?.getSelectedRows() ?? [], o = n.length > 0, i = t?.getRanges() ?? [],
|
|
95
|
+
const t = this.#n(), n = t?.getSelectedRows() ?? [], o = n.length > 0, i = t?.getRanges() ?? [], r = i.length > 0, l = t?.getSelectedCell() != null;
|
|
96
96
|
let a, d, c;
|
|
97
97
|
if (o && t)
|
|
98
98
|
a = H({
|
|
@@ -101,7 +101,7 @@ class wn extends x {
|
|
|
101
101
|
selectedIndices: n,
|
|
102
102
|
config: this.config
|
|
103
103
|
}), d = n.length, c = this.columns.filter((u) => !u.hidden && !u.field.startsWith("__")).length;
|
|
104
|
-
else if (
|
|
104
|
+
else if (r && t) {
|
|
105
105
|
const u = i[i.length - 1], h = this.#i({
|
|
106
106
|
startRow: u.from.row,
|
|
107
107
|
startCol: u.from.col,
|
|
@@ -126,9 +126,9 @@ class wn extends x {
|
|
|
126
126
|
* Handle paste operation
|
|
127
127
|
*/
|
|
128
128
|
#e() {
|
|
129
|
-
|
|
129
|
+
de().then((e) => {
|
|
130
130
|
if (!e) return;
|
|
131
|
-
const t =
|
|
131
|
+
const t = ae(e, this.config);
|
|
132
132
|
this.emit("paste", { rows: t, text: e });
|
|
133
133
|
});
|
|
134
134
|
}
|
|
@@ -154,11 +154,11 @@ class wn extends x {
|
|
|
154
154
|
if (!n) return null;
|
|
155
155
|
const o = this.columns[t];
|
|
156
156
|
if (!o) return null;
|
|
157
|
-
const i = n[o.field],
|
|
157
|
+
const i = n[o.field], r = o.header || o.field;
|
|
158
158
|
let l;
|
|
159
159
|
if (this.config.includeHeaders) {
|
|
160
160
|
const a = i == null ? "" : String(i);
|
|
161
|
-
l = `${
|
|
161
|
+
l = `${r}: ${a}`;
|
|
162
162
|
} else
|
|
163
163
|
l = i == null ? "" : String(i);
|
|
164
164
|
return { text: l };
|
|
@@ -167,24 +167,24 @@ class wn extends x {
|
|
|
167
167
|
* Build text for a rectangular range of cells.
|
|
168
168
|
*/
|
|
169
169
|
#i(e) {
|
|
170
|
-
const { startRow: t, startCol: n, endRow: o, endCol: i } = e,
|
|
170
|
+
const { startRow: t, startCol: n, endRow: o, endCol: i } = e, r = Math.min(t, o), l = Math.max(t, o), a = Math.min(n, i), d = Math.max(n, i), c = this.config.delimiter ?? " ", u = this.config.newline ?? `
|
|
171
171
|
`, h = [], g = this.columns.slice(a, d + 1);
|
|
172
172
|
if (this.config.includeHeaders) {
|
|
173
|
-
const p = g.map((
|
|
173
|
+
const p = g.map((m) => m.header || m.field);
|
|
174
174
|
h.push(p.join(c));
|
|
175
175
|
}
|
|
176
|
-
for (let p =
|
|
177
|
-
const
|
|
178
|
-
if (!
|
|
179
|
-
const
|
|
180
|
-
const
|
|
181
|
-
return
|
|
176
|
+
for (let p = r; p <= l; p++) {
|
|
177
|
+
const m = this.rows[p];
|
|
178
|
+
if (!m) continue;
|
|
179
|
+
const f = g.map((b) => {
|
|
180
|
+
const E = m[b.field];
|
|
181
|
+
return E == null ? "" : E instanceof Date ? E.toISOString() : String(E);
|
|
182
182
|
});
|
|
183
|
-
h.push(
|
|
183
|
+
h.push(f.join(c));
|
|
184
184
|
}
|
|
185
185
|
return {
|
|
186
186
|
text: h.join(u),
|
|
187
|
-
rowCount: l -
|
|
187
|
+
rowCount: l - r + 1,
|
|
188
188
|
columnCount: d - a + 1
|
|
189
189
|
};
|
|
190
190
|
}
|
|
@@ -201,9 +201,9 @@ class wn extends x {
|
|
|
201
201
|
if (!o) return null;
|
|
202
202
|
const i = parseInt(o, 10);
|
|
203
203
|
if (isNaN(i)) return null;
|
|
204
|
-
const
|
|
205
|
-
if (!
|
|
206
|
-
const l =
|
|
204
|
+
const r = this.rows[i];
|
|
205
|
+
if (!r) return null;
|
|
206
|
+
const l = r[n], d = this.columns.find((u) => u.field === n)?.header || n;
|
|
207
207
|
let c;
|
|
208
208
|
if (this.config.includeHeaders) {
|
|
209
209
|
const u = l == null ? "" : String(l);
|
|
@@ -246,8 +246,8 @@ class wn extends x {
|
|
|
246
246
|
* @returns Parsed 2D array of cell values, or null if clipboard is empty
|
|
247
247
|
*/
|
|
248
248
|
async paste() {
|
|
249
|
-
const e = await
|
|
250
|
-
return e ?
|
|
249
|
+
const e = await de();
|
|
250
|
+
return e ? ae(e, this.config) : null;
|
|
251
251
|
}
|
|
252
252
|
/**
|
|
253
253
|
* Get the last copied text and timestamp.
|
|
@@ -258,37 +258,37 @@ class wn extends x {
|
|
|
258
258
|
}
|
|
259
259
|
// #endregion
|
|
260
260
|
}
|
|
261
|
-
const
|
|
262
|
-
function Q(
|
|
263
|
-
if (
|
|
264
|
-
return
|
|
265
|
-
if (typeof
|
|
266
|
-
return
|
|
267
|
-
const e = parseFloat(
|
|
268
|
-
return isNaN(e) ?
|
|
261
|
+
const ce = 100;
|
|
262
|
+
function Q(s) {
|
|
263
|
+
if (s == null)
|
|
264
|
+
return ce;
|
|
265
|
+
if (typeof s == "number")
|
|
266
|
+
return s;
|
|
267
|
+
const e = parseFloat(s);
|
|
268
|
+
return isNaN(e) ? ce : e;
|
|
269
269
|
}
|
|
270
|
-
function
|
|
271
|
-
return
|
|
270
|
+
function ue(s) {
|
|
271
|
+
return s.map((e) => Q(e.width));
|
|
272
272
|
}
|
|
273
|
-
function
|
|
273
|
+
function he(s) {
|
|
274
274
|
const e = [];
|
|
275
275
|
let t = 0;
|
|
276
|
-
for (const n of
|
|
276
|
+
for (const n of s)
|
|
277
277
|
e.push(t), t += Q(n.width);
|
|
278
278
|
return e;
|
|
279
279
|
}
|
|
280
|
-
function
|
|
281
|
-
return
|
|
280
|
+
function ge(s) {
|
|
281
|
+
return s.reduce((e, t) => e + Q(t.width), 0);
|
|
282
282
|
}
|
|
283
|
-
function Ve(
|
|
283
|
+
function Ve(s, e, t, n, o) {
|
|
284
284
|
const i = t.length;
|
|
285
285
|
if (i === 0)
|
|
286
286
|
return { startCol: 0, endCol: 0, visibleColumns: [] };
|
|
287
|
-
let
|
|
288
|
-
|
|
289
|
-
const l =
|
|
290
|
-
let a =
|
|
291
|
-
for (let c =
|
|
287
|
+
let r = ze(s, t, n);
|
|
288
|
+
r = Math.max(0, r - o);
|
|
289
|
+
const l = s + e;
|
|
290
|
+
let a = r;
|
|
291
|
+
for (let c = r; c < i; c++) {
|
|
292
292
|
if (t[c] >= l) {
|
|
293
293
|
a = c - 1;
|
|
294
294
|
break;
|
|
@@ -297,22 +297,22 @@ function Ve(r, e, t, n, o) {
|
|
|
297
297
|
}
|
|
298
298
|
a = Math.min(i - 1, a + o);
|
|
299
299
|
const d = [];
|
|
300
|
-
for (let c =
|
|
300
|
+
for (let c = r; c <= a; c++)
|
|
301
301
|
d.push(c);
|
|
302
|
-
return { startCol:
|
|
302
|
+
return { startCol: r, endCol: a, visibleColumns: d };
|
|
303
303
|
}
|
|
304
|
-
function ze(
|
|
304
|
+
function ze(s, e, t) {
|
|
305
305
|
let n = 0, o = e.length - 1;
|
|
306
306
|
for (; n < o; ) {
|
|
307
307
|
const i = Math.floor((n + o) / 2);
|
|
308
|
-
e[i] + t[i] <=
|
|
308
|
+
e[i] + t[i] <= s ? n = i + 1 : o = i;
|
|
309
309
|
}
|
|
310
310
|
return n;
|
|
311
311
|
}
|
|
312
|
-
function We(
|
|
313
|
-
return t ?
|
|
312
|
+
function We(s, e, t) {
|
|
313
|
+
return t ? s > e : !1;
|
|
314
314
|
}
|
|
315
|
-
class
|
|
315
|
+
class vn extends y {
|
|
316
316
|
name = "columnVirtualization";
|
|
317
317
|
version = "1.0.0";
|
|
318
318
|
get defaultConfig() {
|
|
@@ -335,7 +335,7 @@ class bn extends x {
|
|
|
335
335
|
attach(e) {
|
|
336
336
|
super.attach(e);
|
|
337
337
|
const t = this.columns;
|
|
338
|
-
this.columnWidths =
|
|
338
|
+
this.columnWidths = ue(t), this.columnOffsets = he(t), this.totalWidth = ge(t), this.endCol = t.length - 1;
|
|
339
339
|
}
|
|
340
340
|
detach() {
|
|
341
341
|
this.columnWidths = [], this.columnOffsets = [], this.isVirtualized = !1, this.startCol = 0, this.endCol = 0, this.scrollLeft = 0, this.totalWidth = 0;
|
|
@@ -344,7 +344,7 @@ class bn extends x {
|
|
|
344
344
|
// #region Hooks
|
|
345
345
|
processColumns(e) {
|
|
346
346
|
const t = We(e.length, this.config.threshold ?? 30, this.config.autoEnable ?? !0);
|
|
347
|
-
if (this.isVirtualized = t ?? !1, this.columnWidths =
|
|
347
|
+
if (this.isVirtualized = t ?? !1, this.columnWidths = ue(e), this.columnOffsets = he(e), this.totalWidth = ge(e), !t)
|
|
348
348
|
return this.startCol = 0, this.endCol = e.length - 1, [...e];
|
|
349
349
|
const n = this.grid.clientWidth || 800, o = Ve(
|
|
350
350
|
this.scrollLeft,
|
|
@@ -360,8 +360,8 @@ class bn extends x {
|
|
|
360
360
|
const e = this.shadowRoot;
|
|
361
361
|
if (!e) return;
|
|
362
362
|
const t = this.columnOffsets[this.startCol] ?? 0, n = e.querySelector(".header-row"), o = e.querySelectorAll(".data-grid-row");
|
|
363
|
-
n && (n.style.paddingLeft = `${t}px`), o.forEach((
|
|
364
|
-
|
|
363
|
+
n && (n.style.paddingLeft = `${t}px`), o.forEach((r) => {
|
|
364
|
+
r.style.paddingLeft = `${t}px`;
|
|
365
365
|
});
|
|
366
366
|
const i = e.querySelector(".rows-viewport .rows");
|
|
367
367
|
i && (i.style.width = `${this.totalWidth}px`);
|
|
@@ -407,76 +407,76 @@ class bn extends x {
|
|
|
407
407
|
// #endregion
|
|
408
408
|
}
|
|
409
409
|
const $e = ".tbw-context-menu{position:fixed;background:light-dark(#f5f5f5,#2a2a2a);color:light-dark(#222,#eee);border:1px solid light-dark(#d0d0d4,#454545);border-radius:4px;box-shadow:0 2px 10px #00000026;min-width:160px;padding:4px 0;z-index:10000;font-size:13px;font-family:system-ui,sans-serif}.tbw-context-menu-item{display:flex;align-items:center;padding:6px 12px;cursor:pointer;gap:8px}.tbw-context-menu-item:hover:not(.disabled){background: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:16px;text-align:center}.tbw-context-menu-label{flex:1}.tbw-context-menu-shortcut{color:light-dark(#888,#888);font-size:11px}.tbw-context-menu-arrow{font-size:10px;color:light-dark(#888,#888)}.tbw-context-menu-separator{height:1px;background:light-dark(#d0d0d4,#454545);margin:4px 0}";
|
|
410
|
-
function Y(
|
|
411
|
-
return (typeof
|
|
410
|
+
function Y(s, e) {
|
|
411
|
+
return (typeof s == "function" ? s(e) : s).filter((n) => !(n.hidden === !0 || typeof n.hidden == "function" && n.hidden(e)));
|
|
412
412
|
}
|
|
413
|
-
function je(
|
|
414
|
-
return
|
|
413
|
+
function je(s, e) {
|
|
414
|
+
return s.disabled === !0 ? !0 : typeof s.disabled == "function" ? s.disabled(e) : !1;
|
|
415
415
|
}
|
|
416
|
-
function Z(
|
|
416
|
+
function Z(s, e, t, n = Ge.submenuArrow) {
|
|
417
417
|
const o = document.createElement("div");
|
|
418
418
|
o.className = "tbw-context-menu", o.setAttribute("role", "menu");
|
|
419
|
-
for (const i of
|
|
419
|
+
for (const i of s) {
|
|
420
420
|
if (i.separator) {
|
|
421
421
|
const d = document.createElement("div");
|
|
422
422
|
d.className = "tbw-context-menu-separator", d.setAttribute("role", "separator"), o.appendChild(d);
|
|
423
423
|
continue;
|
|
424
424
|
}
|
|
425
|
-
const
|
|
426
|
-
|
|
425
|
+
const r = document.createElement("div");
|
|
426
|
+
r.className = "tbw-context-menu-item", i.cssClass && r.classList.add(i.cssClass), r.setAttribute("role", "menuitem"), r.setAttribute("data-id", i.id);
|
|
427
427
|
const l = je(i, e);
|
|
428
|
-
if (l && (
|
|
428
|
+
if (l && (r.classList.add("disabled"), r.setAttribute("aria-disabled", "true")), i.icon) {
|
|
429
429
|
const d = document.createElement("span");
|
|
430
|
-
d.className = "tbw-context-menu-icon", d.innerHTML = i.icon,
|
|
430
|
+
d.className = "tbw-context-menu-icon", d.innerHTML = i.icon, r.appendChild(d);
|
|
431
431
|
}
|
|
432
432
|
const a = document.createElement("span");
|
|
433
|
-
if (a.className = "tbw-context-menu-label", a.textContent = i.name,
|
|
433
|
+
if (a.className = "tbw-context-menu-label", a.textContent = i.name, r.appendChild(a), i.shortcut) {
|
|
434
434
|
const d = document.createElement("span");
|
|
435
|
-
d.className = "tbw-context-menu-shortcut", d.textContent = i.shortcut,
|
|
435
|
+
d.className = "tbw-context-menu-shortcut", d.textContent = i.shortcut, r.appendChild(d);
|
|
436
436
|
}
|
|
437
437
|
if (i.subMenu?.length) {
|
|
438
438
|
const d = document.createElement("span");
|
|
439
|
-
d.className = "tbw-context-menu-arrow", typeof n == "string" ? d.innerHTML = n : n instanceof HTMLElement && d.appendChild(n.cloneNode(!0)),
|
|
440
|
-
if (
|
|
439
|
+
d.className = "tbw-context-menu-arrow", typeof n == "string" ? d.innerHTML = n : n instanceof HTMLElement && d.appendChild(n.cloneNode(!0)), r.appendChild(d), r.addEventListener("mouseenter", () => {
|
|
440
|
+
if (r.querySelector(".tbw-context-menu") || !i.subMenu) return;
|
|
441
441
|
const u = Y(i.subMenu, e), h = Z(u, e, t, n);
|
|
442
|
-
h.classList.add("tbw-context-submenu"), h.style.position = "absolute", h.style.left = "100%", h.style.top = "0",
|
|
443
|
-
}),
|
|
444
|
-
const c =
|
|
442
|
+
h.classList.add("tbw-context-submenu"), h.style.position = "absolute", h.style.left = "100%", h.style.top = "0", r.style.position = "relative", r.appendChild(h);
|
|
443
|
+
}), r.addEventListener("mouseleave", () => {
|
|
444
|
+
const c = r.querySelector(".tbw-context-menu");
|
|
445
445
|
c && c.remove();
|
|
446
446
|
});
|
|
447
447
|
}
|
|
448
|
-
!l && i.action && !i.subMenu &&
|
|
448
|
+
!l && i.action && !i.subMenu && r.addEventListener("click", (d) => {
|
|
449
449
|
d.stopPropagation(), t(i);
|
|
450
|
-
}), o.appendChild(
|
|
450
|
+
}), o.appendChild(r);
|
|
451
451
|
}
|
|
452
452
|
return o;
|
|
453
453
|
}
|
|
454
|
-
function
|
|
455
|
-
|
|
456
|
-
const n =
|
|
457
|
-
let
|
|
458
|
-
e + n.width > o && (
|
|
454
|
+
function pe(s, e, t) {
|
|
455
|
+
s.style.position = "fixed", s.style.left = `${e}px`, s.style.top = `${t}px`, s.style.visibility = "hidden", s.style.zIndex = "10000";
|
|
456
|
+
const n = s.getBoundingClientRect(), o = window.innerWidth, i = window.innerHeight;
|
|
457
|
+
let r = e, l = t;
|
|
458
|
+
e + n.width > o && (r = e - n.width), t + n.height > i && (l = t - n.height), r = Math.max(0, r), l = Math.max(0, l), s.style.left = `${r}px`, s.style.top = `${l}px`, s.style.visibility = "visible";
|
|
459
459
|
}
|
|
460
|
-
let
|
|
460
|
+
let I = null, L = null, A = null, O = 0;
|
|
461
461
|
const B = [
|
|
462
462
|
{
|
|
463
463
|
id: "copy",
|
|
464
464
|
name: "Copy",
|
|
465
465
|
shortcut: "Ctrl+C",
|
|
466
|
-
action: (
|
|
467
|
-
|
|
466
|
+
action: (s) => {
|
|
467
|
+
s.grid?.plugins?.clipboard?.copy?.();
|
|
468
468
|
}
|
|
469
469
|
},
|
|
470
470
|
{ separator: !0, id: "sep1", name: "" },
|
|
471
471
|
{
|
|
472
472
|
id: "export-csv",
|
|
473
473
|
name: "Export CSV",
|
|
474
|
-
action: (
|
|
475
|
-
|
|
474
|
+
action: (s) => {
|
|
475
|
+
s.grid?.plugins?.export?.exportCsv?.();
|
|
476
476
|
}
|
|
477
477
|
}
|
|
478
478
|
];
|
|
479
|
-
class
|
|
479
|
+
class xn extends y {
|
|
480
480
|
name = "contextMenu";
|
|
481
481
|
version = "1.0.0";
|
|
482
482
|
get defaultConfig() {
|
|
@@ -500,18 +500,18 @@ class vn extends x {
|
|
|
500
500
|
// #endregion
|
|
501
501
|
// #region Private Methods
|
|
502
502
|
installGlobalHandlers() {
|
|
503
|
-
!
|
|
503
|
+
!A && typeof document < "u" && (A = document.createElement("style"), A.id = "tbw-context-menu-styles", A.textContent = $e, document.head.appendChild(A)), I || (I = () => {
|
|
504
504
|
document.querySelectorAll(".tbw-context-menu").forEach((t) => t.remove());
|
|
505
|
-
}, document.addEventListener("click",
|
|
505
|
+
}, document.addEventListener("click", I)), L || (L = (e) => {
|
|
506
506
|
e.key === "Escape" && document.querySelectorAll(".tbw-context-menu").forEach((n) => n.remove());
|
|
507
|
-
}, document.addEventListener("keydown",
|
|
507
|
+
}, document.addEventListener("keydown", L));
|
|
508
508
|
}
|
|
509
509
|
/**
|
|
510
510
|
* Clean up global handlers when the last instance detaches.
|
|
511
511
|
* Uses reference counting to ensure handlers persist while any grid uses the plugin.
|
|
512
512
|
*/
|
|
513
513
|
uninstallGlobalHandlers() {
|
|
514
|
-
O--, !(O > 0) && (
|
|
514
|
+
O--, !(O > 0) && (I && (document.removeEventListener("click", I), I = null), L && (document.removeEventListener("keydown", L), L = null), A && (A.remove(), A = null));
|
|
515
515
|
}
|
|
516
516
|
// #endregion
|
|
517
517
|
// #region Hooks
|
|
@@ -522,10 +522,10 @@ class vn extends x {
|
|
|
522
522
|
t && t.getAttribute("data-context-menu-bound") !== "true" && (t.setAttribute("data-context-menu-bound", "true"), t.addEventListener("contextmenu", (n) => {
|
|
523
523
|
const o = n;
|
|
524
524
|
o.preventDefault();
|
|
525
|
-
const i = o.target,
|
|
525
|
+
const i = o.target, r = i.closest("[data-row][data-col]"), l = i.closest(".header-cell");
|
|
526
526
|
let a;
|
|
527
|
-
if (
|
|
528
|
-
const c = parseInt(
|
|
527
|
+
if (r) {
|
|
528
|
+
const c = parseInt(r.getAttribute("data-row") ?? "-1", 10), u = parseInt(r.getAttribute("data-col") ?? "-1", 10), h = this.columns[u], g = this.rows[c];
|
|
529
529
|
a = {
|
|
530
530
|
row: g,
|
|
531
531
|
rowIndex: c,
|
|
@@ -559,7 +559,7 @@ class vn extends x {
|
|
|
559
559
|
c.action && c.action(a), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
|
|
560
560
|
},
|
|
561
561
|
this.gridIcons.submenuArrow
|
|
562
|
-
), document.body.appendChild(this.menuElement),
|
|
562
|
+
), document.body.appendChild(this.menuElement), pe(this.menuElement, o.clientX, o.clientY), this.isOpen = !0, this.emit("context-menu-open", { params: a, items: d }));
|
|
563
563
|
}));
|
|
564
564
|
}
|
|
565
565
|
// #endregion
|
|
@@ -584,11 +584,11 @@ class vn extends x {
|
|
|
584
584
|
this.menuElement && this.menuElement.remove(), this.menuElement = Z(
|
|
585
585
|
i,
|
|
586
586
|
o,
|
|
587
|
-
(
|
|
588
|
-
|
|
587
|
+
(r) => {
|
|
588
|
+
r.action && r.action(o), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
|
|
589
589
|
},
|
|
590
590
|
this.gridIcons.submenuArrow
|
|
591
|
-
), document.body.appendChild(this.menuElement),
|
|
591
|
+
), document.body.appendChild(this.menuElement), pe(this.menuElement, e, t), this.isOpen = !0;
|
|
592
592
|
}
|
|
593
593
|
/**
|
|
594
594
|
* Hide the context menu.
|
|
@@ -606,45 +606,45 @@ class vn extends x {
|
|
|
606
606
|
// #endregion
|
|
607
607
|
// Styles are injected globally via installGlobalHandlers() since menu renders in document.body
|
|
608
608
|
}
|
|
609
|
-
function
|
|
610
|
-
if (
|
|
611
|
-
if (
|
|
612
|
-
if (typeof
|
|
613
|
-
const t = String(
|
|
609
|
+
function fe(s, e = !0) {
|
|
610
|
+
if (s == null) return "";
|
|
611
|
+
if (s instanceof Date) return s.toISOString();
|
|
612
|
+
if (typeof s == "object") return JSON.stringify(s);
|
|
613
|
+
const t = String(s);
|
|
614
614
|
return e && (t.includes(",") || t.includes('"') || t.includes(`
|
|
615
615
|
`) || t.includes("\r")) ? `"${t.replace(/"/g, '""')}"` : t;
|
|
616
616
|
}
|
|
617
|
-
function Ue(
|
|
617
|
+
function Ue(s, e, t, n = {}) {
|
|
618
618
|
const o = n.delimiter ?? ",", i = n.newline ?? `
|
|
619
|
-
`,
|
|
619
|
+
`, r = [], l = n.bom ? "\uFEFF" : "";
|
|
620
620
|
if (t.includeHeaders !== !1) {
|
|
621
621
|
const a = e.map((d) => {
|
|
622
622
|
const c = d.header || d.field, u = t.processHeader ? t.processHeader(c, d.field) : c;
|
|
623
|
-
return
|
|
623
|
+
return fe(u);
|
|
624
624
|
});
|
|
625
|
-
|
|
625
|
+
r.push(a.join(o));
|
|
626
626
|
}
|
|
627
|
-
for (const a of
|
|
627
|
+
for (const a of s) {
|
|
628
628
|
const d = e.map((c) => {
|
|
629
629
|
let u = a[c.field];
|
|
630
|
-
return t.processCell && (u = t.processCell(u, c.field, a)),
|
|
630
|
+
return t.processCell && (u = t.processCell(u, c.field, a)), fe(u);
|
|
631
631
|
});
|
|
632
|
-
|
|
632
|
+
r.push(d.join(o));
|
|
633
633
|
}
|
|
634
|
-
return l +
|
|
634
|
+
return l + r.join(i);
|
|
635
635
|
}
|
|
636
|
-
function ee(
|
|
637
|
-
const t = URL.createObjectURL(
|
|
636
|
+
function ee(s, e) {
|
|
637
|
+
const t = URL.createObjectURL(s), n = document.createElement("a");
|
|
638
638
|
n.href = t, n.download = e, n.style.display = "none", document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(t);
|
|
639
639
|
}
|
|
640
|
-
function Ye(
|
|
641
|
-
const t = new Blob([
|
|
640
|
+
function Ye(s, e) {
|
|
641
|
+
const t = new Blob([s], { type: "text/csv;charset=utf-8;" });
|
|
642
642
|
ee(t, e);
|
|
643
643
|
}
|
|
644
|
-
function
|
|
645
|
-
return
|
|
644
|
+
function me(s) {
|
|
645
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
646
646
|
}
|
|
647
|
-
function Ze(
|
|
647
|
+
function Ze(s, e, t) {
|
|
648
648
|
let n = `<?xml version="1.0" encoding="UTF-8"?>
|
|
649
649
|
<?mso-application progid="Excel.Sheet"?>
|
|
650
650
|
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
|
|
@@ -655,19 +655,19 @@ function Ze(r, e, t) {
|
|
|
655
655
|
n += `
|
|
656
656
|
<Row>`;
|
|
657
657
|
for (const o of e) {
|
|
658
|
-
const i = o.header || o.field,
|
|
659
|
-
n += `<Cell><Data ss:Type="String">${
|
|
658
|
+
const i = o.header || o.field, r = t.processHeader ? t.processHeader(i, o.field) : i;
|
|
659
|
+
n += `<Cell><Data ss:Type="String">${me(r)}</Data></Cell>`;
|
|
660
660
|
}
|
|
661
661
|
n += "</Row>";
|
|
662
662
|
}
|
|
663
|
-
for (const o of
|
|
663
|
+
for (const o of s) {
|
|
664
664
|
n += `
|
|
665
665
|
<Row>`;
|
|
666
666
|
for (const i of e) {
|
|
667
|
-
let
|
|
668
|
-
t.processCell && (
|
|
667
|
+
let r = o[i.field];
|
|
668
|
+
t.processCell && (r = t.processCell(r, i.field, o));
|
|
669
669
|
let l = "String", a = "";
|
|
670
|
-
|
|
670
|
+
r == null ? a = "" : typeof r == "number" && !isNaN(r) ? (l = "Number", a = String(r)) : r instanceof Date ? (l = "DateTime", a = r.toISOString()) : a = me(String(r)), n += `<Cell><Data ss:Type="${l}">${a}</Data></Cell>`;
|
|
671
671
|
}
|
|
672
672
|
n += "</Row>";
|
|
673
673
|
}
|
|
@@ -676,13 +676,13 @@ function Ze(r, e, t) {
|
|
|
676
676
|
</Worksheet>
|
|
677
677
|
</Workbook>`, n;
|
|
678
678
|
}
|
|
679
|
-
function Xe(
|
|
680
|
-
const t = e.endsWith(".xls") ? e : `${e}.xls`, n = new Blob([
|
|
679
|
+
function Xe(s, e) {
|
|
680
|
+
const t = e.endsWith(".xls") ? e : `${e}.xls`, n = new Blob([s], {
|
|
681
681
|
type: "application/vnd.ms-excel;charset=utf-8;"
|
|
682
682
|
});
|
|
683
683
|
ee(n, t);
|
|
684
684
|
}
|
|
685
|
-
class
|
|
685
|
+
class yn extends y {
|
|
686
686
|
name = "export";
|
|
687
687
|
version = "1.0.0";
|
|
688
688
|
get defaultConfig() {
|
|
@@ -713,27 +713,27 @@ class xn extends x {
|
|
|
713
713
|
const a = new Set(t.columns);
|
|
714
714
|
i = i.filter((d) => a.has(d.field));
|
|
715
715
|
}
|
|
716
|
-
let
|
|
716
|
+
let r = [...this.rows];
|
|
717
717
|
if (n.onlySelected) {
|
|
718
718
|
const a = this.getSelectionState();
|
|
719
|
-
a?.selected?.size && (
|
|
719
|
+
a?.selected?.size && (r = [...a.selected].sort((c, u) => c - u).map((c) => this.rows[c]).filter(Boolean));
|
|
720
720
|
}
|
|
721
|
-
t?.rowIndices && (
|
|
721
|
+
t?.rowIndices && (r = t.rowIndices.map((a) => this.rows[a]).filter(Boolean)), this.isExportingFlag = !0;
|
|
722
722
|
let l = o.fileName;
|
|
723
723
|
try {
|
|
724
724
|
switch (e) {
|
|
725
725
|
case "csv": {
|
|
726
|
-
const a = Ue(
|
|
726
|
+
const a = Ue(r, i, o, { bom: !0 });
|
|
727
727
|
l = l.endsWith(".csv") ? l : `${l}.csv`, Ye(a, l);
|
|
728
728
|
break;
|
|
729
729
|
}
|
|
730
730
|
case "excel": {
|
|
731
|
-
const a = Ze(
|
|
731
|
+
const a = Ze(r, i, o);
|
|
732
732
|
l = l.endsWith(".xls") ? l : `${l}.xls`, Xe(a, l);
|
|
733
733
|
break;
|
|
734
734
|
}
|
|
735
735
|
case "json": {
|
|
736
|
-
const a =
|
|
736
|
+
const a = r.map((u) => {
|
|
737
737
|
const h = {};
|
|
738
738
|
for (const g of i) {
|
|
739
739
|
let p = u[g.field];
|
|
@@ -750,7 +750,7 @@ class xn extends x {
|
|
|
750
750
|
this.lastExportInfo = { format: e, timestamp: /* @__PURE__ */ new Date() }, this.emit("export-complete", {
|
|
751
751
|
format: e,
|
|
752
752
|
fileName: l,
|
|
753
|
-
rowCount:
|
|
753
|
+
rowCount: r.length,
|
|
754
754
|
columnCount: i.length
|
|
755
755
|
});
|
|
756
756
|
} finally {
|
|
@@ -803,43 +803,43 @@ class xn extends x {
|
|
|
803
803
|
}
|
|
804
804
|
// #endregion
|
|
805
805
|
}
|
|
806
|
-
function Je(
|
|
807
|
-
const { totalRows: e, viewportHeight: t, scrollTop: n, rowHeight: o, overscan: i } =
|
|
806
|
+
function Je(s) {
|
|
807
|
+
const { totalRows: e, viewportHeight: t, scrollTop: n, rowHeight: o, overscan: i } = s, r = Math.ceil(t / o);
|
|
808
808
|
let l = Math.floor(n / o) - i;
|
|
809
809
|
l < 0 && (l = 0);
|
|
810
|
-
let a = l +
|
|
811
|
-
return a > e && (a = e), a === e && l > 0 && (l = Math.max(0, a -
|
|
810
|
+
let a = l + r + i * 2;
|
|
811
|
+
return a > e && (a = e), a === e && l > 0 && (l = Math.max(0, a - r - i * 2)), {
|
|
812
812
|
start: l,
|
|
813
813
|
end: a,
|
|
814
814
|
offsetY: l * o,
|
|
815
815
|
totalHeight: e * o
|
|
816
816
|
};
|
|
817
817
|
}
|
|
818
|
-
function Qe(
|
|
819
|
-
return
|
|
818
|
+
function Qe(s, e) {
|
|
819
|
+
return s <= e;
|
|
820
820
|
}
|
|
821
|
-
function et(
|
|
822
|
-
const n =
|
|
821
|
+
function et(s, e, t = !1) {
|
|
822
|
+
const n = s[e.field];
|
|
823
823
|
if (e.operator === "blank")
|
|
824
824
|
return n == null || n === "";
|
|
825
825
|
if (e.operator === "notBlank")
|
|
826
826
|
return n != null && n !== "";
|
|
827
827
|
if (n == null) return !1;
|
|
828
|
-
const o = String(n), i = t ? o : o.toLowerCase(),
|
|
828
|
+
const o = String(n), i = t ? o : o.toLowerCase(), r = t ? String(e.value) : String(e.value).toLowerCase();
|
|
829
829
|
switch (e.operator) {
|
|
830
830
|
// Text operators
|
|
831
831
|
case "contains":
|
|
832
|
-
return i.includes(
|
|
832
|
+
return i.includes(r);
|
|
833
833
|
case "notContains":
|
|
834
|
-
return !i.includes(
|
|
834
|
+
return !i.includes(r);
|
|
835
835
|
case "equals":
|
|
836
|
-
return i ===
|
|
836
|
+
return i === r;
|
|
837
837
|
case "notEquals":
|
|
838
|
-
return i !==
|
|
838
|
+
return i !== r;
|
|
839
839
|
case "startsWith":
|
|
840
|
-
return i.startsWith(
|
|
840
|
+
return i.startsWith(r);
|
|
841
841
|
case "endsWith":
|
|
842
|
-
return i.endsWith(
|
|
842
|
+
return i.endsWith(r);
|
|
843
843
|
// Number/Date operators (use raw numeric values)
|
|
844
844
|
case "lessThan":
|
|
845
845
|
return Number(n) < Number(e.value);
|
|
@@ -860,12 +860,12 @@ function et(r, e, t = !1) {
|
|
|
860
860
|
return !0;
|
|
861
861
|
}
|
|
862
862
|
}
|
|
863
|
-
function tt(
|
|
864
|
-
return e.length ?
|
|
863
|
+
function tt(s, e, t = !1) {
|
|
864
|
+
return e.length ? s.filter((n) => e.every((o) => et(n, o, t))) : s;
|
|
865
865
|
}
|
|
866
|
-
function nt(
|
|
866
|
+
function nt(s) {
|
|
867
867
|
return JSON.stringify(
|
|
868
|
-
|
|
868
|
+
s.map((e) => ({
|
|
869
869
|
field: e.field,
|
|
870
870
|
operator: e.operator,
|
|
871
871
|
value: e.value,
|
|
@@ -873,16 +873,16 @@ function nt(r) {
|
|
|
873
873
|
}))
|
|
874
874
|
);
|
|
875
875
|
}
|
|
876
|
-
function
|
|
876
|
+
function we(s, e) {
|
|
877
877
|
const t = /* @__PURE__ */ new Set();
|
|
878
|
-
for (const n of
|
|
878
|
+
for (const n of s) {
|
|
879
879
|
const o = n[e];
|
|
880
880
|
o != null && t.add(o);
|
|
881
881
|
}
|
|
882
882
|
return [...t].sort((n, o) => typeof n == "number" && typeof o == "number" ? n - o : String(n).localeCompare(String(o)));
|
|
883
883
|
}
|
|
884
884
|
const ot = '.header-cell.filtered:before{content:"";position:absolute;top:4px;right:4px;width:6px;height:6px;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:4px;opacity:.4;transition:opacity .15s;color:inherit;vertical-align:middle}.tbw-filter-btn:hover,.tbw-filter-btn.active{opacity:1}.tbw-filter-btn.active{color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}', it = ".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, 4px));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:12px;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, 13px)}.tbw-filter-search{margin-bottom:8px}.tbw-filter-search-input{width:100%;padding:6px 10px;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, 4px);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:4px 2px;margin-bottom:8px;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:12px;padding:2px 0}.tbw-filter-action-btn:hover{text-decoration:underline}.tbw-filter-values{flex:1;overflow-y:auto;margin-bottom:8px;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:8px;padding:4px 2px;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:8px 0;text-align:center;font-style:italic}.tbw-filter-buttons{display:flex;gap:8px;padding-top:8px;border-top:1px solid var(--tbw-filter-divider, var(--tbw-color-border, light-dark(#d0d0d4, #454545)))}.tbw-filter-apply-btn{flex:1;padding:6px 12px;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:4px;cursor:pointer;font-size:13px}.tbw-filter-apply-btn:hover{filter:brightness(.9)}.tbw-filter-clear-btn{flex:1;padding:6px 12px;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:4px;cursor:pointer;font-size:13px}.tbw-filter-clear-btn:hover{background:var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)))}";
|
|
885
|
-
class
|
|
885
|
+
class _ extends y {
|
|
886
886
|
name = "filtering";
|
|
887
887
|
version = "1.0.0";
|
|
888
888
|
get defaultConfig() {
|
|
@@ -936,11 +936,11 @@ class A extends x {
|
|
|
936
936
|
if (o === null) return;
|
|
937
937
|
const i = this.columns[parseInt(o, 10)];
|
|
938
938
|
if (!i || i.filterable === !1 || n.querySelector(".tbw-filter-btn")) return;
|
|
939
|
-
const
|
|
940
|
-
if (!
|
|
939
|
+
const r = i.field;
|
|
940
|
+
if (!r) return;
|
|
941
941
|
const l = document.createElement("button");
|
|
942
|
-
l.className = "tbw-filter-btn", l.setAttribute("aria-label", `Filter ${i.header ??
|
|
943
|
-
a.stopPropagation(), this.toggleFilterPanel(
|
|
942
|
+
l.className = "tbw-filter-btn", l.setAttribute("aria-label", `Filter ${i.header ?? r}`), l.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>', this.filters.has(r) && (l.classList.add("active"), n.classList.add("filtered")), l.addEventListener("click", (a) => {
|
|
943
|
+
a.stopPropagation(), this.toggleFilterPanel(r, i, l);
|
|
944
944
|
}), n.appendChild(l);
|
|
945
945
|
});
|
|
946
946
|
}
|
|
@@ -1028,7 +1028,7 @@ class A extends x {
|
|
|
1028
1028
|
* Uses sourceRows to include all values regardless of current filter.
|
|
1029
1029
|
*/
|
|
1030
1030
|
getUniqueValues(e) {
|
|
1031
|
-
return
|
|
1031
|
+
return we(this.sourceRows, e);
|
|
1032
1032
|
}
|
|
1033
1033
|
// #endregion
|
|
1034
1034
|
// #region Private Methods
|
|
@@ -1055,14 +1055,14 @@ class A extends x {
|
|
|
1055
1055
|
this.closeFilterPanel();
|
|
1056
1056
|
const o = document.createElement("div");
|
|
1057
1057
|
o.className = "tbw-filter-panel", this.panelElement = o, this.openPanelField = e;
|
|
1058
|
-
const i =
|
|
1059
|
-
let
|
|
1060
|
-
|
|
1058
|
+
const i = we(this.sourceRows, e);
|
|
1059
|
+
let r = this.excludedValues.get(e);
|
|
1060
|
+
r || (r = /* @__PURE__ */ new Set(), this.excludedValues.set(e, r));
|
|
1061
1061
|
const l = this.searchText.get(e) ?? "", a = {
|
|
1062
1062
|
field: e,
|
|
1063
1063
|
column: t,
|
|
1064
1064
|
uniqueValues: i,
|
|
1065
|
-
excludedValues:
|
|
1065
|
+
excludedValues: r,
|
|
1066
1066
|
searchText: l,
|
|
1067
1067
|
applySetFilter: (c) => {
|
|
1068
1068
|
this.applySetFilter(e, c), this.closeFilterPanel();
|
|
@@ -1076,7 +1076,7 @@ class A extends x {
|
|
|
1076
1076
|
closePanel: () => this.closeFilterPanel()
|
|
1077
1077
|
};
|
|
1078
1078
|
let d = !1;
|
|
1079
|
-
this.config.filterPanelRenderer && (this.config.filterPanelRenderer(o, a), d = o.children.length > 0), d || this.renderDefaultFilterPanel(o, a, i,
|
|
1079
|
+
this.config.filterPanelRenderer && (this.config.filterPanelRenderer(o, a), d = o.children.length > 0), d || this.renderDefaultFilterPanel(o, a, i, r), document.body.appendChild(o), this.positionPanel(o, n), this.panelAbortController = new AbortController(), setTimeout(() => {
|
|
1080
1080
|
document.addEventListener(
|
|
1081
1081
|
"click",
|
|
1082
1082
|
(c) => {
|
|
@@ -1106,10 +1106,10 @@ class A extends x {
|
|
|
1106
1106
|
* Render the default filter panel content
|
|
1107
1107
|
*/
|
|
1108
1108
|
renderDefaultFilterPanel(e, t, n, o) {
|
|
1109
|
-
const { field: i } = t,
|
|
1110
|
-
|
|
1109
|
+
const { field: i } = t, r = document.createElement("div");
|
|
1110
|
+
r.className = "tbw-filter-search";
|
|
1111
1111
|
const l = document.createElement("input");
|
|
1112
|
-
l.type = "text", l.placeholder = "Search...", l.className = "tbw-filter-search-input", l.value = this.searchText.get(i) ?? "",
|
|
1112
|
+
l.type = "text", l.placeholder = "Search...", l.className = "tbw-filter-search-input", l.value = this.searchText.get(i) ?? "", r.appendChild(l), e.appendChild(r);
|
|
1113
1113
|
const a = document.createElement("div");
|
|
1114
1114
|
a.className = "tbw-filter-actions";
|
|
1115
1115
|
const d = document.createElement("label");
|
|
@@ -1119,71 +1119,71 @@ class A extends x {
|
|
|
1119
1119
|
const u = document.createElement("span");
|
|
1120
1120
|
u.textContent = "Select All", d.appendChild(c), d.appendChild(u), a.appendChild(d);
|
|
1121
1121
|
const h = () => {
|
|
1122
|
-
const
|
|
1123
|
-
c.checked =
|
|
1122
|
+
const w = [...f.values()], R = w.every((C) => C), S = w.every((C) => !C);
|
|
1123
|
+
c.checked = R, c.indeterminate = !R && !S;
|
|
1124
1124
|
};
|
|
1125
1125
|
c.addEventListener("change", () => {
|
|
1126
|
-
const
|
|
1127
|
-
for (const
|
|
1128
|
-
|
|
1129
|
-
h(),
|
|
1126
|
+
const w = c.checked;
|
|
1127
|
+
for (const R of f.keys())
|
|
1128
|
+
f.set(R, w);
|
|
1129
|
+
h(), v();
|
|
1130
1130
|
}), e.appendChild(a);
|
|
1131
1131
|
const g = document.createElement("div");
|
|
1132
1132
|
g.className = "tbw-filter-values";
|
|
1133
1133
|
const p = document.createElement("div");
|
|
1134
1134
|
p.className = "tbw-filter-values-spacer", g.appendChild(p);
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1137
|
-
const
|
|
1138
|
-
n.forEach((
|
|
1139
|
-
const
|
|
1140
|
-
|
|
1135
|
+
const m = document.createElement("div");
|
|
1136
|
+
m.className = "tbw-filter-values-content", g.appendChild(m);
|
|
1137
|
+
const f = /* @__PURE__ */ new Map();
|
|
1138
|
+
n.forEach((w) => {
|
|
1139
|
+
const R = w == null ? "__null__" : String(w);
|
|
1140
|
+
f.set(R, !o.has(w));
|
|
1141
1141
|
}), h();
|
|
1142
|
-
let
|
|
1143
|
-
const
|
|
1144
|
-
const
|
|
1145
|
-
|
|
1146
|
-
const
|
|
1147
|
-
|
|
1148
|
-
|
|
1142
|
+
let b = [];
|
|
1143
|
+
const E = (w, R) => {
|
|
1144
|
+
const S = w == null ? "(Blank)" : String(w), C = w == null ? "__null__" : String(w), x = document.createElement("label");
|
|
1145
|
+
x.className = "tbw-filter-value-item", x.style.position = "absolute", x.style.top = `${R * _.LIST_ITEM_HEIGHT}px`, x.style.left = "0", x.style.right = "0", x.style.height = `${_.LIST_ITEM_HEIGHT}px`, x.style.boxSizing = "border-box";
|
|
1146
|
+
const k = document.createElement("input");
|
|
1147
|
+
k.type = "checkbox", k.className = "tbw-filter-checkbox", k.checked = f.get(C) ?? !0, k.dataset.value = C, k.addEventListener("change", () => {
|
|
1148
|
+
f.set(C, k.checked), h();
|
|
1149
1149
|
});
|
|
1150
1150
|
const re = document.createElement("span");
|
|
1151
|
-
return re.textContent =
|
|
1152
|
-
},
|
|
1153
|
-
const
|
|
1154
|
-
if (p.style.height = `${
|
|
1155
|
-
|
|
1156
|
-
|
|
1151
|
+
return re.textContent = S, x.appendChild(k), x.appendChild(re), x;
|
|
1152
|
+
}, v = () => {
|
|
1153
|
+
const w = b.length, R = g.clientHeight, S = g.scrollTop;
|
|
1154
|
+
if (p.style.height = `${w * _.LIST_ITEM_HEIGHT}px`, Qe(w, _.LIST_BYPASS_THRESHOLD / 3)) {
|
|
1155
|
+
m.innerHTML = "", m.style.transform = "translateY(0px)", b.forEach((x, k) => {
|
|
1156
|
+
m.appendChild(E(x, k));
|
|
1157
1157
|
});
|
|
1158
1158
|
return;
|
|
1159
1159
|
}
|
|
1160
|
-
const
|
|
1161
|
-
totalRows:
|
|
1162
|
-
viewportHeight:
|
|
1163
|
-
scrollTop:
|
|
1164
|
-
rowHeight:
|
|
1165
|
-
overscan:
|
|
1160
|
+
const C = Je({
|
|
1161
|
+
totalRows: w,
|
|
1162
|
+
viewportHeight: R,
|
|
1163
|
+
scrollTop: S,
|
|
1164
|
+
rowHeight: _.LIST_ITEM_HEIGHT,
|
|
1165
|
+
overscan: _.LIST_OVERSCAN
|
|
1166
1166
|
});
|
|
1167
|
-
|
|
1168
|
-
for (let
|
|
1169
|
-
|
|
1170
|
-
}, oe = (
|
|
1171
|
-
const
|
|
1172
|
-
if (
|
|
1173
|
-
const
|
|
1174
|
-
return !
|
|
1175
|
-
}),
|
|
1176
|
-
p.style.height = "0px",
|
|
1177
|
-
const
|
|
1178
|
-
|
|
1167
|
+
m.style.transform = `translateY(${C.offsetY}px)`, m.innerHTML = "";
|
|
1168
|
+
for (let x = C.start; x < C.end; x++)
|
|
1169
|
+
m.appendChild(E(b[x], x - C.start));
|
|
1170
|
+
}, oe = (w) => {
|
|
1171
|
+
const R = w.toLowerCase();
|
|
1172
|
+
if (b = n.filter((S) => {
|
|
1173
|
+
const C = S == null ? "(Blank)" : String(S);
|
|
1174
|
+
return !w || C.toLowerCase().includes(R);
|
|
1175
|
+
}), b.length === 0) {
|
|
1176
|
+
p.style.height = "0px", m.innerHTML = "";
|
|
1177
|
+
const S = document.createElement("div");
|
|
1178
|
+
S.className = "tbw-filter-no-match", S.textContent = "No matching values", m.appendChild(S);
|
|
1179
1179
|
return;
|
|
1180
1180
|
}
|
|
1181
|
-
|
|
1181
|
+
v();
|
|
1182
1182
|
};
|
|
1183
1183
|
g.addEventListener(
|
|
1184
1184
|
"scroll",
|
|
1185
1185
|
() => {
|
|
1186
|
-
|
|
1186
|
+
b.length > 0 && v();
|
|
1187
1187
|
},
|
|
1188
1188
|
{ passive: !0 }
|
|
1189
1189
|
), oe(l.value), e.appendChild(g);
|
|
@@ -1193,25 +1193,25 @@ class A extends x {
|
|
|
1193
1193
|
this.searchText.set(i, l.value), oe(l.value);
|
|
1194
1194
|
}, this.config.debounceMs ?? 150);
|
|
1195
1195
|
});
|
|
1196
|
-
const
|
|
1197
|
-
|
|
1198
|
-
const
|
|
1199
|
-
|
|
1200
|
-
const
|
|
1201
|
-
for (const [
|
|
1202
|
-
if (!
|
|
1203
|
-
if (
|
|
1204
|
-
|
|
1196
|
+
const N = document.createElement("div");
|
|
1197
|
+
N.className = "tbw-filter-buttons";
|
|
1198
|
+
const P = document.createElement("button");
|
|
1199
|
+
P.className = "tbw-filter-apply-btn", P.textContent = "Apply", P.addEventListener("click", () => {
|
|
1200
|
+
const w = [];
|
|
1201
|
+
for (const [R, S] of f)
|
|
1202
|
+
if (!S)
|
|
1203
|
+
if (R === "__null__")
|
|
1204
|
+
w.push(null);
|
|
1205
1205
|
else {
|
|
1206
|
-
const
|
|
1207
|
-
|
|
1206
|
+
const C = n.find((x) => String(x) === R);
|
|
1207
|
+
w.push(C !== void 0 ? C : R);
|
|
1208
1208
|
}
|
|
1209
|
-
t.applySetFilter(
|
|
1210
|
-
}),
|
|
1211
|
-
const
|
|
1212
|
-
|
|
1209
|
+
t.applySetFilter(w);
|
|
1210
|
+
}), N.appendChild(P);
|
|
1211
|
+
const K = document.createElement("button");
|
|
1212
|
+
K.className = "tbw-filter-clear-btn", K.textContent = "Clear Filter", K.addEventListener("click", () => {
|
|
1213
1213
|
t.clearFilter();
|
|
1214
|
-
}),
|
|
1214
|
+
}), N.appendChild(K), e.appendChild(N);
|
|
1215
1215
|
}
|
|
1216
1216
|
/**
|
|
1217
1217
|
* Apply a set filter (exclude values)
|
|
@@ -1281,28 +1281,28 @@ class A extends x {
|
|
|
1281
1281
|
styles = ot;
|
|
1282
1282
|
// #endregion
|
|
1283
1283
|
}
|
|
1284
|
-
function rt(
|
|
1285
|
-
if (!
|
|
1286
|
-
const e = /* @__PURE__ */ new Map(), t = [], n = (
|
|
1284
|
+
function rt(s) {
|
|
1285
|
+
if (!s.length) return [];
|
|
1286
|
+
const e = /* @__PURE__ */ new Map(), t = [], n = (r, l) => {
|
|
1287
1287
|
if (!l.length) return;
|
|
1288
1288
|
const a = t[t.length - 1];
|
|
1289
|
-
if (a && a.implicit && a.firstIndex + a.columns.length ===
|
|
1289
|
+
if (a && a.implicit && a.firstIndex + a.columns.length === r) {
|
|
1290
1290
|
a.columns.push(...l);
|
|
1291
1291
|
return;
|
|
1292
1292
|
}
|
|
1293
1293
|
t.push({
|
|
1294
|
-
id: "__implicit__" +
|
|
1294
|
+
id: "__implicit__" + r,
|
|
1295
1295
|
label: void 0,
|
|
1296
1296
|
columns: l,
|
|
1297
|
-
firstIndex:
|
|
1297
|
+
firstIndex: r,
|
|
1298
1298
|
implicit: !0
|
|
1299
1299
|
});
|
|
1300
1300
|
};
|
|
1301
1301
|
let o = [], i = 0;
|
|
1302
|
-
return
|
|
1303
|
-
const a =
|
|
1302
|
+
return s.forEach((r, l) => {
|
|
1303
|
+
const a = r.group;
|
|
1304
1304
|
if (!a) {
|
|
1305
|
-
o.length === 0 && (i = l), o.push(
|
|
1305
|
+
o.length === 0 && (i = l), o.push(r);
|
|
1306
1306
|
return;
|
|
1307
1307
|
}
|
|
1308
1308
|
o.length && (n(i, o.slice()), o = []);
|
|
@@ -1313,40 +1313,40 @@ function rt(r) {
|
|
|
1313
1313
|
label: typeof a == "string" ? void 0 : a.label,
|
|
1314
1314
|
columns: [],
|
|
1315
1315
|
firstIndex: l
|
|
1316
|
-
}, e.set(d, c), t.push(c)), c.columns.push(
|
|
1317
|
-
}), o.length && n(i, o), t.length === 1 && t[0].implicit && t[0].columns.length ===
|
|
1316
|
+
}, e.set(d, c), t.push(c)), c.columns.push(r);
|
|
1317
|
+
}), o.length && n(i, o), t.length === 1 && t[0].implicit && t[0].columns.length === s.length ? [] : t;
|
|
1318
1318
|
}
|
|
1319
|
-
function st(
|
|
1320
|
-
if (!e.length || !
|
|
1319
|
+
function st(s, e, t) {
|
|
1320
|
+
if (!e.length || !s) return;
|
|
1321
1321
|
const n = /* @__PURE__ */ new Map();
|
|
1322
1322
|
for (const i of e)
|
|
1323
|
-
for (const
|
|
1324
|
-
|
|
1325
|
-
const o = Array.from(
|
|
1323
|
+
for (const r of i.columns)
|
|
1324
|
+
r?.field && n.set(r.field, i.id);
|
|
1325
|
+
const o = Array.from(s.querySelectorAll(".cell[data-field]"));
|
|
1326
1326
|
o.forEach((i) => {
|
|
1327
|
-
const
|
|
1327
|
+
const r = i.getAttribute("data-field") || "", l = n.get(r);
|
|
1328
1328
|
l && (i.classList.add("grouped"), i.getAttribute("data-group") || i.setAttribute("data-group", l));
|
|
1329
1329
|
});
|
|
1330
1330
|
for (const i of e) {
|
|
1331
|
-
const
|
|
1331
|
+
const r = i.columns[i.columns.length - 1], l = o.find((a) => a.getAttribute("data-field") === r.field);
|
|
1332
1332
|
l && l.classList.add("group-end");
|
|
1333
1333
|
}
|
|
1334
1334
|
}
|
|
1335
|
-
function lt(
|
|
1336
|
-
if (
|
|
1335
|
+
function lt(s, e) {
|
|
1336
|
+
if (s.length === 0) return null;
|
|
1337
1337
|
const t = document.createElement("div");
|
|
1338
1338
|
t.className = "header-group-row", t.setAttribute("role", "row");
|
|
1339
|
-
for (const n of
|
|
1340
|
-
const o = n.firstIndex != null ? n.firstIndex : e.findIndex((a) => n.columns.includes(a)), i = String(n.id).startsWith("__implicit__"),
|
|
1341
|
-
l.className = "cell header-group-cell", i && l.classList.add("implicit-group"), l.setAttribute("data-group", String(n.id)), l.style.gridColumn = `${o + 1} / span ${n.columns.length}`, l.textContent =
|
|
1339
|
+
for (const n of s) {
|
|
1340
|
+
const o = n.firstIndex != null ? n.firstIndex : e.findIndex((a) => n.columns.includes(a)), i = String(n.id).startsWith("__implicit__"), r = i ? "" : n.label || n.id, l = document.createElement("div");
|
|
1341
|
+
l.className = "cell header-group-cell", i && l.classList.add("implicit-group"), l.setAttribute("data-group", String(n.id)), l.style.gridColumn = `${o + 1} / span ${n.columns.length}`, l.textContent = r, t.appendChild(l);
|
|
1342
1342
|
}
|
|
1343
1343
|
return t;
|
|
1344
1344
|
}
|
|
1345
|
-
function at(
|
|
1346
|
-
return
|
|
1345
|
+
function at(s) {
|
|
1346
|
+
return s.some((e) => e.group != null);
|
|
1347
1347
|
}
|
|
1348
|
-
const dt = ".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:4px 8px;font-weight:600;font-size:.9em;text-transform:uppercase;letter-spacing:.5px;border-right:1px solid var(--tbw-grouping-columns-border, 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))}";
|
|
1349
|
-
class
|
|
1348
|
+
const dt = ".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:4px 8px;font-weight:600;font-size:.9em;text-transform:uppercase;letter-spacing:.5px;border-right:1px solid var(--tbw-grouping-columns-border, 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))}.header-row .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)}";
|
|
1349
|
+
class Cn extends y {
|
|
1350
1350
|
name = "groupingColumns";
|
|
1351
1351
|
version = "1.0.0";
|
|
1352
1352
|
get defaultConfig() {
|
|
@@ -1379,8 +1379,8 @@ class yn extends x {
|
|
|
1379
1379
|
}
|
|
1380
1380
|
afterRender() {
|
|
1381
1381
|
if (!this.isActive || this.groups.length === 0) {
|
|
1382
|
-
const
|
|
1383
|
-
|
|
1382
|
+
const r = this.shadowRoot?.querySelector(".header")?.querySelector(".header-group-row");
|
|
1383
|
+
r && r.remove();
|
|
1384
1384
|
return;
|
|
1385
1385
|
}
|
|
1386
1386
|
const e = this.shadowRoot?.querySelector(".header");
|
|
@@ -1389,11 +1389,12 @@ class yn extends x {
|
|
|
1389
1389
|
t && t.remove();
|
|
1390
1390
|
const n = lt(this.groups, this.columns);
|
|
1391
1391
|
if (n) {
|
|
1392
|
+
n.classList.toggle("no-borders", !this.config.showGroupBorders);
|
|
1392
1393
|
const i = e.querySelector(".header-row");
|
|
1393
1394
|
i ? e.insertBefore(n, i) : e.appendChild(n);
|
|
1394
1395
|
}
|
|
1395
1396
|
const o = e.querySelector(".header-row");
|
|
1396
|
-
o && st(o, this.groups, this.columns);
|
|
1397
|
+
o && (o.classList.toggle("no-group-borders", !this.config.showGroupBorders), st(o, this.groups, this.columns));
|
|
1397
1398
|
}
|
|
1398
1399
|
// #endregion
|
|
1399
1400
|
// #region Public API
|
|
@@ -1431,12 +1432,12 @@ class yn extends x {
|
|
|
1431
1432
|
styles = dt;
|
|
1432
1433
|
// #endregion
|
|
1433
1434
|
}
|
|
1434
|
-
function ct({ rows:
|
|
1435
|
+
function ct({ rows: s, config: e, expanded: t }) {
|
|
1435
1436
|
const n = e.groupOn;
|
|
1436
1437
|
if (typeof n != "function")
|
|
1437
1438
|
return [];
|
|
1438
1439
|
const o = { key: "__root__", value: null, depth: -1, rows: [], children: /* @__PURE__ */ new Map() };
|
|
1439
|
-
if (
|
|
1440
|
+
if (s.forEach((l) => {
|
|
1440
1441
|
let a = n(l);
|
|
1441
1442
|
a == null || a === !1 ? a = ["__ungrouped__"] : Array.isArray(a) || (a = [a]);
|
|
1442
1443
|
let d = o;
|
|
@@ -1445,11 +1446,11 @@ function ct({ rows: r, config: e, expanded: t }) {
|
|
|
1445
1446
|
let p = d.children.get(h);
|
|
1446
1447
|
p || (p = { key: g, value: c, depth: u, rows: [], children: /* @__PURE__ */ new Map(), parent: d }, d.children.set(h, p)), d = p;
|
|
1447
1448
|
}), d.rows.push(l);
|
|
1448
|
-
}), o.children.size === 1 && o.children.has("__ungrouped__") && o.children.get("__ungrouped__").rows.length ===
|
|
1449
|
+
}), o.children.size === 1 && o.children.has("__ungrouped__") && o.children.get("__ungrouped__").rows.length === s.length)
|
|
1449
1450
|
return [];
|
|
1450
|
-
const i = [],
|
|
1451
|
+
const i = [], r = (l) => {
|
|
1451
1452
|
if (l === o) {
|
|
1452
|
-
l.children.forEach((d) =>
|
|
1453
|
+
l.children.forEach((d) => r(d));
|
|
1453
1454
|
return;
|
|
1454
1455
|
}
|
|
1455
1456
|
const a = t.has(l.key);
|
|
@@ -1460,28 +1461,28 @@ function ct({ rows: r, config: e, expanded: t }) {
|
|
|
1460
1461
|
depth: l.depth,
|
|
1461
1462
|
rows: l.rows,
|
|
1462
1463
|
expanded: a
|
|
1463
|
-
}), a && (l.children.size ? l.children.forEach((d) =>
|
|
1464
|
+
}), a && (l.children.size ? l.children.forEach((d) => r(d)) : l.rows.forEach((d) => i.push({ kind: "data", row: d, rowIndex: s.indexOf(d) })));
|
|
1464
1465
|
};
|
|
1465
|
-
return
|
|
1466
|
+
return r(o), i;
|
|
1466
1467
|
}
|
|
1467
|
-
function ut(
|
|
1468
|
-
const t = new Set(
|
|
1468
|
+
function ut(s, e) {
|
|
1469
|
+
const t = new Set(s);
|
|
1469
1470
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
1470
1471
|
}
|
|
1471
|
-
function ht(
|
|
1472
|
+
function ht(s) {
|
|
1472
1473
|
const e = /* @__PURE__ */ new Set();
|
|
1473
|
-
for (const t of
|
|
1474
|
+
for (const t of s)
|
|
1474
1475
|
t.kind === "group" && e.add(t.key);
|
|
1475
1476
|
return e;
|
|
1476
1477
|
}
|
|
1477
1478
|
function gt() {
|
|
1478
1479
|
return /* @__PURE__ */ new Set();
|
|
1479
1480
|
}
|
|
1480
|
-
function pt(
|
|
1481
|
-
return
|
|
1481
|
+
function pt(s) {
|
|
1482
|
+
return s.kind !== "group" ? 0 : s.rows.length;
|
|
1482
1483
|
}
|
|
1483
1484
|
const ft = '.group-row{background:var(--tbw-grouping-rows-bg, var(--tbw-color-panel-bg));font-weight:500}.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:20px;height:20px;margin-right:4px;font-size:10px}.group-toggle:hover{background:var(--tbw-grouping-rows-toggle-hover, var(--tbw-color-row-hover));border-radius:2px}.group-label{display:inline-flex;align-items:center;gap:8px}.group-count{color:var(--tbw-grouping-rows-count-color, var(--tbw-color-fg-muted));font-size:.85em;font-weight:400}[data-group-depth="0"] .group-label{padding-left:0}[data-group-depth="1"] .group-label{padding-left:20px}[data-group-depth="2"] .group-label{padding-left:40px}[data-group-depth="3"] .group-label{padding-left:60px}[data-group-depth="4"] .group-label{padding-left:80px}';
|
|
1484
|
-
class
|
|
1485
|
+
class Rn extends y {
|
|
1485
1486
|
name = "groupingRows";
|
|
1486
1487
|
version = "1.0.0";
|
|
1487
1488
|
get defaultConfig() {
|
|
@@ -1567,10 +1568,10 @@ class Cn extends x {
|
|
|
1567
1568
|
renderFullWidthGroupRow(e, t, n) {
|
|
1568
1569
|
const o = this.config, i = document.createElement("div");
|
|
1569
1570
|
i.className = "cell group-full", i.style.gridColumn = "1 / -1", i.setAttribute("role", "gridcell");
|
|
1570
|
-
const
|
|
1571
|
-
|
|
1571
|
+
const r = document.createElement("button");
|
|
1572
|
+
r.type = "button", r.className = "group-toggle", r.setAttribute("aria-label", e.__groupExpanded ? "Collapse group" : "Expand group"), this.setIcon(r, this.resolveIcon(e.__groupExpanded ? "collapse" : "expand")), r.addEventListener("click", (d) => {
|
|
1572
1573
|
d.stopPropagation(), n();
|
|
1573
|
-
}), i.appendChild(
|
|
1574
|
+
}), i.appendChild(r);
|
|
1574
1575
|
const l = document.createElement("span");
|
|
1575
1576
|
l.className = "group-label";
|
|
1576
1577
|
const a = o.formatLabel ? o.formatLabel(e.__groupValue, e.__groupDepth || 0, e.__groupKey) : String(e.__groupValue);
|
|
@@ -1581,25 +1582,25 @@ class Cn extends x {
|
|
|
1581
1582
|
t.appendChild(i);
|
|
1582
1583
|
}
|
|
1583
1584
|
renderPerColumnGroupRow(e, t, n) {
|
|
1584
|
-
const o = this.config, i = o.aggregators ?? {},
|
|
1585
|
-
d && (t.style.display = "grid", t.style.gridTemplateColumns = d),
|
|
1585
|
+
const o = this.config, i = o.aggregators ?? {}, r = this.columns, l = e.__groupRows ?? [], d = this.shadowRoot?.querySelector(".body")?.style.gridTemplateColumns || "";
|
|
1586
|
+
d && (t.style.display = "grid", t.style.gridTemplateColumns = d), r.forEach((c, u) => {
|
|
1586
1587
|
const h = document.createElement("div");
|
|
1587
1588
|
if (h.className = "cell group-cell", h.setAttribute("data-col", String(u)), h.setAttribute("role", "gridcell"), u === 0) {
|
|
1588
1589
|
const g = document.createElement("button");
|
|
1589
|
-
g.type = "button", g.className = "group-toggle", g.setAttribute("aria-label", e.__groupExpanded ? "Collapse group" : "Expand group"), this.setIcon(g, this.resolveIcon(e.__groupExpanded ? "collapse" : "expand")), g.addEventListener("click", (
|
|
1590
|
-
|
|
1590
|
+
g.type = "button", g.className = "group-toggle", g.setAttribute("aria-label", e.__groupExpanded ? "Collapse group" : "Expand group"), this.setIcon(g, this.resolveIcon(e.__groupExpanded ? "collapse" : "expand")), g.addEventListener("click", (f) => {
|
|
1591
|
+
f.stopPropagation(), n();
|
|
1591
1592
|
}), h.appendChild(g);
|
|
1592
|
-
const p = document.createElement("span"),
|
|
1593
|
-
if (
|
|
1594
|
-
const
|
|
1595
|
-
p.textContent =
|
|
1593
|
+
const p = document.createElement("span"), m = i[c.field];
|
|
1594
|
+
if (m) {
|
|
1595
|
+
const f = se(m, l, c.field, c);
|
|
1596
|
+
p.textContent = f != null ? String(f) : String(e.__groupValue);
|
|
1596
1597
|
} else {
|
|
1597
|
-
const
|
|
1598
|
-
p.textContent =
|
|
1598
|
+
const f = o.formatLabel ? o.formatLabel(e.__groupValue, e.__groupDepth || 0, e.__groupKey) : String(e.__groupValue);
|
|
1599
|
+
p.textContent = f;
|
|
1599
1600
|
}
|
|
1600
1601
|
if (h.appendChild(p), o.showRowCount !== !1) {
|
|
1601
|
-
const
|
|
1602
|
-
|
|
1602
|
+
const f = document.createElement("span");
|
|
1603
|
+
f.className = "group-count", f.textContent = ` (${l.length})`, h.appendChild(f);
|
|
1603
1604
|
}
|
|
1604
1605
|
} else {
|
|
1605
1606
|
const g = i[c.field];
|
|
@@ -1725,31 +1726,31 @@ class Cn extends x {
|
|
|
1725
1726
|
styles = ft;
|
|
1726
1727
|
// #endregion
|
|
1727
1728
|
}
|
|
1728
|
-
function V(
|
|
1729
|
-
const t = new Set(
|
|
1729
|
+
function V(s, e) {
|
|
1730
|
+
const t = new Set(s);
|
|
1730
1731
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
1731
1732
|
}
|
|
1732
|
-
function mt(
|
|
1733
|
-
const t = new Set(
|
|
1733
|
+
function mt(s, e) {
|
|
1734
|
+
const t = new Set(s);
|
|
1734
1735
|
return t.add(e), t;
|
|
1735
1736
|
}
|
|
1736
|
-
function wt(
|
|
1737
|
-
const t = new Set(
|
|
1737
|
+
function wt(s, e) {
|
|
1738
|
+
const t = new Set(s);
|
|
1738
1739
|
return t.delete(e), t;
|
|
1739
1740
|
}
|
|
1740
|
-
function bt(
|
|
1741
|
-
return
|
|
1741
|
+
function bt(s, e) {
|
|
1742
|
+
return s.has(e);
|
|
1742
1743
|
}
|
|
1743
|
-
function vt(
|
|
1744
|
+
function vt(s, e, t, n) {
|
|
1744
1745
|
const o = document.createElement("div");
|
|
1745
1746
|
o.className = "master-detail-row", o.setAttribute("data-detail-for", String(e)), o.setAttribute("role", "row");
|
|
1746
1747
|
const i = document.createElement("div");
|
|
1747
1748
|
i.className = "master-detail-cell", i.setAttribute("role", "cell"), i.style.gridColumn = `1 / ${n + 1}`;
|
|
1748
|
-
const
|
|
1749
|
-
return typeof
|
|
1749
|
+
const r = t(s, e);
|
|
1750
|
+
return typeof r == "string" ? i.innerHTML = r : r instanceof HTMLElement && i.appendChild(r), o.appendChild(i), o;
|
|
1750
1751
|
}
|
|
1751
1752
|
const xt = ".master-detail-cell-wrapper{display:flex;align-items:center;gap:4px}.master-detail-toggle{cursor:pointer;font-size:10px;opacity:.7;user-select:none}.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))}.master-detail-cell{padding:16px;overflow:auto}";
|
|
1752
|
-
class
|
|
1753
|
+
class Sn extends y {
|
|
1753
1754
|
name = "masterDetail";
|
|
1754
1755
|
version = "1.0.0";
|
|
1755
1756
|
get defaultConfig() {
|
|
@@ -1778,8 +1779,8 @@ class Rn extends x {
|
|
|
1778
1779
|
const n = { ...t[0] }, o = n.viewRenderer;
|
|
1779
1780
|
if (o?.__masterDetailWrapped)
|
|
1780
1781
|
return t;
|
|
1781
|
-
const i = (
|
|
1782
|
-
const { value: l, row: a } =
|
|
1782
|
+
const i = (r) => {
|
|
1783
|
+
const { value: l, row: a } = r, d = this.expandedRows.has(a), c = document.createElement("span");
|
|
1783
1784
|
c.className = "master-detail-cell-wrapper";
|
|
1784
1785
|
const u = document.createElement("span");
|
|
1785
1786
|
u.className = "master-detail-toggle", this.setIcon(u, this.resolveIcon(d ? "collapse" : "expand")), u.setAttribute("role", "button"), u.setAttribute("tabindex", "0"), u.setAttribute("aria-expanded", String(d)), u.setAttribute("aria-label", d ? "Collapse details" : "Expand details"), u.addEventListener("click", (g) => {
|
|
@@ -1793,7 +1794,7 @@ class Rn extends x {
|
|
|
1793
1794
|
}), c.appendChild(u);
|
|
1794
1795
|
const h = document.createElement("span");
|
|
1795
1796
|
if (o) {
|
|
1796
|
-
const g = o(
|
|
1797
|
+
const g = o(r);
|
|
1797
1798
|
g instanceof Node ? h.appendChild(g) : h.textContent = String(g ?? l ?? "");
|
|
1798
1799
|
} else
|
|
1799
1800
|
h.textContent = String(l ?? "");
|
|
@@ -1833,24 +1834,24 @@ class Rn extends x {
|
|
|
1833
1834
|
const e = this.shadowRoot?.querySelector(".rows");
|
|
1834
1835
|
if (!e) return;
|
|
1835
1836
|
const t = /* @__PURE__ */ new Map(), n = e.querySelectorAll(".data-grid-row"), o = this.columns.length;
|
|
1836
|
-
for (const
|
|
1837
|
-
const l =
|
|
1838
|
-
a >= 0 && t.set(a,
|
|
1837
|
+
for (const r of n) {
|
|
1838
|
+
const l = r.querySelector(".cell[data-row]"), a = l ? parseInt(l.getAttribute("data-row") ?? "-1", 10) : -1;
|
|
1839
|
+
a >= 0 && t.set(a, r);
|
|
1839
1840
|
}
|
|
1840
1841
|
const i = e.querySelectorAll(".master-detail-row");
|
|
1841
|
-
for (const
|
|
1842
|
-
const l = parseInt(
|
|
1843
|
-
(!d || !c) && (
|
|
1842
|
+
for (const r of i) {
|
|
1843
|
+
const l = parseInt(r.getAttribute("data-detail-for") ?? "-1", 10), a = l >= 0 ? this.rows[l] : void 0, d = a && this.expandedRows.has(a), c = t.has(l);
|
|
1844
|
+
(!d || !c) && (r.remove(), a && this.detailElements.delete(a));
|
|
1844
1845
|
}
|
|
1845
|
-
for (const [
|
|
1846
|
-
const a = this.rows[
|
|
1846
|
+
for (const [r, l] of t) {
|
|
1847
|
+
const a = this.rows[r];
|
|
1847
1848
|
if (!a || !this.expandedRows.has(a)) continue;
|
|
1848
1849
|
const d = this.detailElements.get(a);
|
|
1849
1850
|
if (d) {
|
|
1850
1851
|
d.previousElementSibling !== l && l.after(d);
|
|
1851
1852
|
continue;
|
|
1852
1853
|
}
|
|
1853
|
-
const c = vt(a,
|
|
1854
|
+
const c = vt(a, r, this.config.detailRenderer, o);
|
|
1854
1855
|
typeof this.config.detailHeight == "number" && (c.style.height = `${this.config.detailHeight}px`), l.after(c), this.detailElements.set(a, c);
|
|
1855
1856
|
}
|
|
1856
1857
|
}
|
|
@@ -1884,8 +1885,8 @@ class Rn extends x {
|
|
|
1884
1885
|
if (i)
|
|
1885
1886
|
t += i.offsetHeight;
|
|
1886
1887
|
else {
|
|
1887
|
-
const
|
|
1888
|
-
t += typeof
|
|
1888
|
+
const r = this.config?.detailHeight;
|
|
1889
|
+
t += typeof r == "number" ? r : 150;
|
|
1889
1890
|
}
|
|
1890
1891
|
}
|
|
1891
1892
|
}
|
|
@@ -1903,10 +1904,10 @@ class Rn extends x {
|
|
|
1903
1904
|
a >= 0 && o.push({ index: a, row: l });
|
|
1904
1905
|
}
|
|
1905
1906
|
o.sort((l, a) => l.index - a.index);
|
|
1906
|
-
let i = e,
|
|
1907
|
+
let i = e, r = 0;
|
|
1907
1908
|
for (const { index: l, row: a } of o) {
|
|
1908
|
-
const d = l * n +
|
|
1909
|
-
|
|
1909
|
+
const d = l * n + r, u = this.detailElements.get(a)?.offsetHeight ?? (typeof this.config?.detailHeight == "number" ? this.config.detailHeight : 150), h = d + n + u;
|
|
1910
|
+
r += u, !(l >= e) && h > t && l < i && (i = l);
|
|
1910
1911
|
}
|
|
1911
1912
|
return i;
|
|
1912
1913
|
}
|
|
@@ -1985,32 +1986,32 @@ class Rn extends x {
|
|
|
1985
1986
|
styles = xt;
|
|
1986
1987
|
// #endregion
|
|
1987
1988
|
}
|
|
1988
|
-
function yt(
|
|
1989
|
-
return e.length ? [...
|
|
1989
|
+
function yt(s, e, t) {
|
|
1990
|
+
return e.length ? [...s].sort((n, o) => {
|
|
1990
1991
|
for (const i of e) {
|
|
1991
1992
|
const l = t.find((u) => u.field === i.field)?.sortComparator ?? Ct, a = n[i.field], d = o[i.field], c = l(a, d, n, o);
|
|
1992
1993
|
if (c !== 0)
|
|
1993
1994
|
return i.direction === "asc" ? c : -c;
|
|
1994
1995
|
}
|
|
1995
1996
|
return 0;
|
|
1996
|
-
}) : [...
|
|
1997
|
+
}) : [...s];
|
|
1997
1998
|
}
|
|
1998
|
-
function Ct(
|
|
1999
|
-
return
|
|
1999
|
+
function Ct(s, e) {
|
|
2000
|
+
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));
|
|
2000
2001
|
}
|
|
2001
|
-
function Rt(
|
|
2002
|
-
const o =
|
|
2003
|
-
return t ? o ? o.direction === "asc" ?
|
|
2002
|
+
function Rt(s, e, t, n) {
|
|
2003
|
+
const o = s.find((i) => i.field === e);
|
|
2004
|
+
return t ? o ? o.direction === "asc" ? s.map((i) => i.field === e ? { ...i, direction: "desc" } : i) : s.filter((i) => i.field !== e) : s.length < n ? [...s, { field: e, direction: "asc" }] : s : o?.direction === "asc" ? [{ field: e, direction: "desc" }] : o?.direction === "desc" ? [] : [{ field: e, direction: "asc" }];
|
|
2004
2005
|
}
|
|
2005
|
-
function
|
|
2006
|
-
const t =
|
|
2006
|
+
function be(s, e) {
|
|
2007
|
+
const t = s.findIndex((n) => n.field === e);
|
|
2007
2008
|
return t >= 0 ? t + 1 : void 0;
|
|
2008
2009
|
}
|
|
2009
|
-
function
|
|
2010
|
-
return
|
|
2010
|
+
function ve(s, e) {
|
|
2011
|
+
return s.find((t) => t.field === e)?.direction;
|
|
2011
2012
|
}
|
|
2012
2013
|
const St = '.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-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}';
|
|
2013
|
-
class
|
|
2014
|
+
class En extends y {
|
|
2014
2015
|
name = "multiSort";
|
|
2015
2016
|
version = "1.0.0";
|
|
2016
2017
|
get defaultConfig() {
|
|
@@ -2043,13 +2044,13 @@ class Sn extends x {
|
|
|
2043
2044
|
e.querySelectorAll(".header-row .cell[data-field]").forEach((o) => {
|
|
2044
2045
|
const i = o.getAttribute("data-field");
|
|
2045
2046
|
if (!i) return;
|
|
2046
|
-
const
|
|
2047
|
+
const r = be(this.sortModel, i), l = ve(this.sortModel, i);
|
|
2047
2048
|
if (o.querySelector(".sort-index")?.remove(), l) {
|
|
2048
2049
|
o.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), o.setAttribute("data-sort", l);
|
|
2049
2050
|
const c = document.createElement("span");
|
|
2050
|
-
if (c.className = "sort-indicator", c.style.marginLeft = "4px", c.style.opacity = "0.8", this.setIcon(c, this.resolveIcon(l === "asc" ? "sortAsc" : "sortDesc")), o.appendChild(c), t && this.sortModel.length > 1 &&
|
|
2051
|
+
if (c.className = "sort-indicator", c.style.marginLeft = "4px", c.style.opacity = "0.8", this.setIcon(c, this.resolveIcon(l === "asc" ? "sortAsc" : "sortDesc")), o.appendChild(c), t && this.sortModel.length > 1 && r !== void 0) {
|
|
2051
2052
|
const u = document.createElement("span");
|
|
2052
|
-
u.className = "sort-index", u.textContent = String(
|
|
2053
|
+
u.className = "sort-index", u.textContent = String(r), o.appendChild(u);
|
|
2053
2054
|
}
|
|
2054
2055
|
} else
|
|
2055
2056
|
o.removeAttribute("data-sort");
|
|
@@ -2083,7 +2084,7 @@ class Sn extends x {
|
|
|
2083
2084
|
* @returns 1-based index or undefined if not sorted
|
|
2084
2085
|
*/
|
|
2085
2086
|
getSortIndex(e) {
|
|
2086
|
-
return
|
|
2087
|
+
return be(this.sortModel, e);
|
|
2087
2088
|
}
|
|
2088
2089
|
/**
|
|
2089
2090
|
* Get the sort direction for a specific field.
|
|
@@ -2091,7 +2092,7 @@ class Sn extends x {
|
|
|
2091
2092
|
* @returns Sort direction or undefined if not sorted
|
|
2092
2093
|
*/
|
|
2093
2094
|
getSortDirection(e) {
|
|
2094
|
-
return
|
|
2095
|
+
return ve(this.sortModel, e);
|
|
2095
2096
|
}
|
|
2096
2097
|
// #endregion
|
|
2097
2098
|
// #region Column State Hooks
|
|
@@ -2127,17 +2128,17 @@ class Sn extends x {
|
|
|
2127
2128
|
styles = St;
|
|
2128
2129
|
// #endregion
|
|
2129
2130
|
}
|
|
2130
|
-
function Et(
|
|
2131
|
-
return
|
|
2131
|
+
function Et(s) {
|
|
2132
|
+
return s.filter((e) => e.sticky === "left");
|
|
2132
2133
|
}
|
|
2133
|
-
function kt(
|
|
2134
|
-
return
|
|
2134
|
+
function kt(s) {
|
|
2135
|
+
return s.filter((e) => e.sticky === "right");
|
|
2135
2136
|
}
|
|
2136
|
-
function z(
|
|
2137
|
-
return
|
|
2137
|
+
function z(s) {
|
|
2138
|
+
return s.some((e) => e.sticky === "left" || e.sticky === "right");
|
|
2138
2139
|
}
|
|
2139
|
-
function
|
|
2140
|
-
const t =
|
|
2140
|
+
function xe(s, e) {
|
|
2141
|
+
const t = s.shadowRoot;
|
|
2141
2142
|
if (!t) return;
|
|
2142
2143
|
const n = Array.from(t.querySelectorAll(".header-row .cell"));
|
|
2143
2144
|
if (!n.length) return;
|
|
@@ -2153,23 +2154,23 @@ function ve(r, e) {
|
|
|
2153
2154
|
c.classList.add("sticky-left"), c.style.position = "sticky", c.style.left = i + "px";
|
|
2154
2155
|
}), i += d.offsetWidth);
|
|
2155
2156
|
}
|
|
2156
|
-
let
|
|
2157
|
+
let r = 0;
|
|
2157
2158
|
for (const l of [...e].reverse())
|
|
2158
2159
|
if (l.sticky === "right") {
|
|
2159
2160
|
const a = o.get(l.field), d = n.find((c) => c.getAttribute("data-field") === l.field);
|
|
2160
|
-
d && (d.classList.add("sticky-right"), d.style.position = "sticky", d.style.right =
|
|
2161
|
-
c.classList.add("sticky-right"), c.style.position = "sticky", c.style.right =
|
|
2162
|
-
}),
|
|
2161
|
+
d && (d.classList.add("sticky-right"), d.style.position = "sticky", d.style.right = r + "px", a !== void 0 && t.querySelectorAll(`.data-grid-row .cell[data-col="${a}"]`).forEach((c) => {
|
|
2162
|
+
c.classList.add("sticky-right"), c.style.position = "sticky", c.style.right = r + "px";
|
|
2163
|
+
}), r += d.offsetWidth);
|
|
2163
2164
|
}
|
|
2164
2165
|
}
|
|
2165
|
-
function
|
|
2166
|
-
const e =
|
|
2166
|
+
function ye(s) {
|
|
2167
|
+
const e = s.shadowRoot;
|
|
2167
2168
|
if (!e) return;
|
|
2168
2169
|
e.querySelectorAll(".sticky-left, .sticky-right").forEach((n) => {
|
|
2169
2170
|
n.classList.remove("sticky-left", "sticky-right"), n.style.position = "", n.style.left = "", n.style.right = "";
|
|
2170
2171
|
});
|
|
2171
2172
|
}
|
|
2172
|
-
class
|
|
2173
|
+
class kn extends y {
|
|
2173
2174
|
name = "pinnedColumns";
|
|
2174
2175
|
version = "1.0.0";
|
|
2175
2176
|
get defaultConfig() {
|
|
@@ -2203,11 +2204,11 @@ class En extends x {
|
|
|
2203
2204
|
return;
|
|
2204
2205
|
const e = this.grid, t = [...this.columns];
|
|
2205
2206
|
if (!z(t)) {
|
|
2206
|
-
|
|
2207
|
+
ye(e), this.isApplied = !1;
|
|
2207
2208
|
return;
|
|
2208
2209
|
}
|
|
2209
2210
|
queueMicrotask(() => {
|
|
2210
|
-
|
|
2211
|
+
xe(e, t);
|
|
2211
2212
|
});
|
|
2212
2213
|
}
|
|
2213
2214
|
/**
|
|
@@ -2215,7 +2216,7 @@ class En extends x {
|
|
|
2215
2216
|
*/
|
|
2216
2217
|
onPluginQuery(e) {
|
|
2217
2218
|
switch (e.type) {
|
|
2218
|
-
case
|
|
2219
|
+
case Ke.CAN_MOVE_COLUMN: {
|
|
2219
2220
|
const t = e.context, n = t.sticky;
|
|
2220
2221
|
if (n === "left" || n === "right")
|
|
2221
2222
|
return !1;
|
|
@@ -2233,7 +2234,7 @@ class En extends x {
|
|
|
2233
2234
|
*/
|
|
2234
2235
|
refreshStickyOffsets() {
|
|
2235
2236
|
const e = [...this.columns];
|
|
2236
|
-
|
|
2237
|
+
xe(this.grid, e);
|
|
2237
2238
|
}
|
|
2238
2239
|
/**
|
|
2239
2240
|
* Get columns pinned to the left.
|
|
@@ -2253,7 +2254,7 @@ class En extends x {
|
|
|
2253
2254
|
* Clear all sticky positioning.
|
|
2254
2255
|
*/
|
|
2255
2256
|
clearStickyPositions() {
|
|
2256
|
-
|
|
2257
|
+
ye(this.grid);
|
|
2257
2258
|
}
|
|
2258
2259
|
/**
|
|
2259
2260
|
* Report horizontal scroll boundary offsets for pinned columns.
|
|
@@ -2264,8 +2265,8 @@ class En extends x {
|
|
|
2264
2265
|
return;
|
|
2265
2266
|
let n = 0, o = 0;
|
|
2266
2267
|
if (e) {
|
|
2267
|
-
const
|
|
2268
|
-
|
|
2268
|
+
const r = e.querySelectorAll(".sticky-left"), l = e.querySelectorAll(".sticky-right");
|
|
2269
|
+
r.forEach((a) => {
|
|
2269
2270
|
n += a.offsetWidth;
|
|
2270
2271
|
}), l.forEach((a) => {
|
|
2271
2272
|
o += a.offsetWidth;
|
|
@@ -2281,7 +2282,10 @@ class En extends x {
|
|
|
2281
2282
|
}
|
|
2282
2283
|
// #endregion
|
|
2283
2284
|
}
|
|
2284
|
-
function
|
|
2285
|
+
function At(s) {
|
|
2286
|
+
return typeof s == "object" && s !== null && "aggFunc" in s;
|
|
2287
|
+
}
|
|
2288
|
+
function W(s, e) {
|
|
2285
2289
|
const t = document.createElement("div");
|
|
2286
2290
|
t.className = "tbw-pinned-rows", t.setAttribute("role", "presentation"), t.setAttribute("aria-live", "polite");
|
|
2287
2291
|
const n = document.createElement("div");
|
|
@@ -2289,22 +2293,22 @@ function W(r, e) {
|
|
|
2289
2293
|
const o = document.createElement("div");
|
|
2290
2294
|
o.className = "tbw-pinned-rows-center";
|
|
2291
2295
|
const i = document.createElement("div");
|
|
2292
|
-
if (i.className = "tbw-pinned-rows-right",
|
|
2293
|
-
const
|
|
2294
|
-
|
|
2295
|
-
}
|
|
2296
|
-
if (
|
|
2297
|
-
const
|
|
2298
|
-
|
|
2299
|
-
}
|
|
2300
|
-
if (
|
|
2301
|
-
const
|
|
2302
|
-
|
|
2303
|
-
}
|
|
2304
|
-
if (
|
|
2305
|
-
for (const
|
|
2306
|
-
const l =
|
|
2307
|
-
switch (
|
|
2296
|
+
if (i.className = "tbw-pinned-rows-right", s.showRowCount !== !1) {
|
|
2297
|
+
const r = document.createElement("span");
|
|
2298
|
+
r.className = "tbw-status-panel tbw-status-panel-row-count", r.textContent = `Total: ${e.totalRows} rows`, n.appendChild(r);
|
|
2299
|
+
}
|
|
2300
|
+
if (s.showFilteredCount && e.filteredRows !== e.totalRows) {
|
|
2301
|
+
const r = document.createElement("span");
|
|
2302
|
+
r.className = "tbw-status-panel tbw-status-panel-filtered-count", r.textContent = `Filtered: ${e.filteredRows}`, n.appendChild(r);
|
|
2303
|
+
}
|
|
2304
|
+
if (s.showSelectedCount && e.selectedRows > 0) {
|
|
2305
|
+
const r = document.createElement("span");
|
|
2306
|
+
r.className = "tbw-status-panel tbw-status-panel-selected-count", r.textContent = `Selected: ${e.selectedRows}`, i.appendChild(r);
|
|
2307
|
+
}
|
|
2308
|
+
if (s.customPanels)
|
|
2309
|
+
for (const r of s.customPanels) {
|
|
2310
|
+
const l = _t(r, e);
|
|
2311
|
+
switch (r.position) {
|
|
2308
2312
|
case "left":
|
|
2309
2313
|
n.appendChild(l);
|
|
2310
2314
|
break;
|
|
@@ -2318,53 +2322,58 @@ function W(r, e) {
|
|
|
2318
2322
|
}
|
|
2319
2323
|
return t.appendChild(n), t.appendChild(o), t.appendChild(i), t;
|
|
2320
2324
|
}
|
|
2321
|
-
function
|
|
2325
|
+
function Ce(s) {
|
|
2322
2326
|
const e = document.createElement("div");
|
|
2323
|
-
return e.className = `tbw-aggregation-rows tbw-aggregation-rows-${
|
|
2327
|
+
return e.className = `tbw-aggregation-rows tbw-aggregation-rows-${s}`, e.setAttribute("role", "presentation"), e;
|
|
2324
2328
|
}
|
|
2325
|
-
function
|
|
2326
|
-
|
|
2329
|
+
function Re(s, e, t, n) {
|
|
2330
|
+
s.innerHTML = "";
|
|
2327
2331
|
for (const o of e) {
|
|
2328
2332
|
const i = document.createElement("div");
|
|
2329
2333
|
if (i.className = "tbw-aggregation-row", i.setAttribute("role", "presentation"), o.id && i.setAttribute("data-aggregation-id", o.id), o.fullWidth) {
|
|
2330
|
-
const
|
|
2331
|
-
|
|
2334
|
+
const r = document.createElement("div");
|
|
2335
|
+
r.className = "tbw-aggregation-cell tbw-aggregation-cell-full", r.style.gridColumn = "1 / -1", r.textContent = o.label || "", i.appendChild(r);
|
|
2332
2336
|
} else
|
|
2333
|
-
for (const
|
|
2337
|
+
for (const r of t) {
|
|
2334
2338
|
const l = document.createElement("div");
|
|
2335
|
-
l.className = "tbw-aggregation-cell", l.setAttribute("data-field",
|
|
2336
|
-
let a;
|
|
2337
|
-
const
|
|
2338
|
-
if (
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2339
|
+
l.className = "tbw-aggregation-cell", l.setAttribute("data-field", r.field);
|
|
2340
|
+
let a, d;
|
|
2341
|
+
const c = o.aggregators?.[r.field];
|
|
2342
|
+
if (c)
|
|
2343
|
+
if (At(c)) {
|
|
2344
|
+
const u = le(c.aggFunc);
|
|
2345
|
+
u && (a = u(n, r.field, r)), d = c.formatter;
|
|
2346
|
+
} else {
|
|
2347
|
+
const u = le(c);
|
|
2348
|
+
u && (a = u(n, r.field, r));
|
|
2349
|
+
}
|
|
2350
|
+
else if (o.cells && Object.prototype.hasOwnProperty.call(o.cells, r.field)) {
|
|
2351
|
+
const u = o.cells[r.field];
|
|
2352
|
+
typeof u == "function" ? a = u(n, r.field, r) : a = u;
|
|
2344
2353
|
}
|
|
2345
|
-
l.textContent = a
|
|
2354
|
+
a != null ? l.textContent = d ? d(a, r.field, r) : String(a) : l.textContent = "", i.appendChild(l);
|
|
2346
2355
|
}
|
|
2347
|
-
|
|
2356
|
+
s.appendChild(i);
|
|
2348
2357
|
}
|
|
2349
2358
|
}
|
|
2350
|
-
function
|
|
2359
|
+
function _t(s, e) {
|
|
2351
2360
|
const t = document.createElement("div");
|
|
2352
|
-
t.className = "tbw-status-panel tbw-status-panel-custom", t.id = `status-panel-${
|
|
2353
|
-
const n =
|
|
2361
|
+
t.className = "tbw-status-panel tbw-status-panel-custom", t.id = `status-panel-${s.id}`;
|
|
2362
|
+
const n = s.render(e);
|
|
2354
2363
|
return typeof n == "string" ? t.innerHTML = n : t.appendChild(n), t;
|
|
2355
2364
|
}
|
|
2356
|
-
function
|
|
2365
|
+
function Se(s, e, t, n, o) {
|
|
2357
2366
|
return {
|
|
2358
|
-
totalRows:
|
|
2359
|
-
filteredRows: o?.cachedResult?.length ??
|
|
2367
|
+
totalRows: s.length,
|
|
2368
|
+
filteredRows: o?.cachedResult?.length ?? s.length,
|
|
2360
2369
|
selectedRows: n?.selected?.size ?? 0,
|
|
2361
2370
|
columns: e,
|
|
2362
|
-
rows:
|
|
2371
|
+
rows: s,
|
|
2363
2372
|
grid: t
|
|
2364
2373
|
};
|
|
2365
2374
|
}
|
|
2366
|
-
const
|
|
2367
|
-
class
|
|
2375
|
+
const It = ".tbw-footer{position:sticky;bottom: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:8px 12px;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:12px;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:16px}.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, 2px 8px);min-height:var(--tbw-row-height, 28px);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}";
|
|
2376
|
+
class An extends y {
|
|
2368
2377
|
name = "pinnedRows";
|
|
2369
2378
|
version = "1.0.0";
|
|
2370
2379
|
get defaultConfig() {
|
|
@@ -2392,20 +2401,20 @@ class kn extends x {
|
|
|
2392
2401
|
if (!e) return;
|
|
2393
2402
|
const t = e.querySelector(".tbw-scroll-area") ?? e.querySelector(".tbw-grid-content") ?? e.children[0];
|
|
2394
2403
|
if (!t) return;
|
|
2395
|
-
const n = this.getSelectionState(), o = this.getFilterState(), i =
|
|
2404
|
+
const n = this.getSelectionState(), o = this.getFilterState(), i = Se(
|
|
2396
2405
|
this.rows,
|
|
2397
2406
|
this.columns,
|
|
2398
2407
|
this.grid,
|
|
2399
2408
|
n,
|
|
2400
2409
|
o
|
|
2401
|
-
),
|
|
2410
|
+
), r = this.config.aggregationRows || [], l = r.filter((h) => h.position === "top"), a = r.filter((h) => h.position !== "top");
|
|
2402
2411
|
if (l.length > 0) {
|
|
2403
2412
|
if (!this.topAggregationContainer) {
|
|
2404
|
-
this.topAggregationContainer =
|
|
2413
|
+
this.topAggregationContainer = Ce("top");
|
|
2405
2414
|
const h = e.querySelector(".header");
|
|
2406
2415
|
h && h.nextSibling ? t.insertBefore(this.topAggregationContainer, h.nextSibling) : t.appendChild(this.topAggregationContainer);
|
|
2407
2416
|
}
|
|
2408
|
-
|
|
2417
|
+
Re(
|
|
2409
2418
|
this.topAggregationContainer,
|
|
2410
2419
|
l,
|
|
2411
2420
|
this.visibleColumns,
|
|
@@ -2421,7 +2430,7 @@ class kn extends x {
|
|
|
2421
2430
|
this.infoBarElement.replaceWith(h), this.infoBarElement = h;
|
|
2422
2431
|
}
|
|
2423
2432
|
else this.config.position === "top" && this.infoBarElement && (this.infoBarElement.remove(), this.infoBarElement = null);
|
|
2424
|
-
u ? (this.footerWrapper || (this.footerWrapper = document.createElement("div"), this.footerWrapper.className = "tbw-footer", t.appendChild(this.footerWrapper)), this.footerWrapper.innerHTML = "", a.length > 0 && (this.bottomAggregationContainer || (this.bottomAggregationContainer =
|
|
2433
|
+
u ? (this.footerWrapper || (this.footerWrapper = document.createElement("div"), this.footerWrapper.className = "tbw-footer", t.appendChild(this.footerWrapper)), this.footerWrapper.innerHTML = "", a.length > 0 && (this.bottomAggregationContainer || (this.bottomAggregationContainer = Ce("bottom")), this.footerWrapper.appendChild(this.bottomAggregationContainer), Re(
|
|
2425
2434
|
this.bottomAggregationContainer,
|
|
2426
2435
|
a,
|
|
2427
2436
|
this.visibleColumns,
|
|
@@ -2464,7 +2473,7 @@ class kn extends x {
|
|
|
2464
2473
|
*/
|
|
2465
2474
|
getContext() {
|
|
2466
2475
|
const e = this.getSelectionState(), t = this.getFilterState();
|
|
2467
|
-
return
|
|
2476
|
+
return Se(
|
|
2468
2477
|
this.rows,
|
|
2469
2478
|
this.columns,
|
|
2470
2479
|
this.grid,
|
|
@@ -2502,20 +2511,20 @@ class kn extends x {
|
|
|
2502
2511
|
}
|
|
2503
2512
|
// #endregion
|
|
2504
2513
|
// #region Styles
|
|
2505
|
-
styles =
|
|
2514
|
+
styles = It;
|
|
2506
2515
|
// #endregion
|
|
2507
2516
|
}
|
|
2508
|
-
const
|
|
2509
|
-
function
|
|
2517
|
+
const Lt = Oe;
|
|
2518
|
+
function Tt(s) {
|
|
2510
2519
|
const e = [];
|
|
2511
|
-
return !
|
|
2520
|
+
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;
|
|
2512
2521
|
}
|
|
2513
|
-
function te(
|
|
2514
|
-
return [...
|
|
2522
|
+
function te(s, e) {
|
|
2523
|
+
return [...s, e].join("|");
|
|
2515
2524
|
}
|
|
2516
|
-
function Ft(
|
|
2517
|
-
const t = e.rowGroupFields ?? [], n = e.columnGroupFields ?? [], o = e.valueFields ?? [], i =
|
|
2518
|
-
|
|
2525
|
+
function Ft(s, e) {
|
|
2526
|
+
const t = e.rowGroupFields ?? [], n = e.columnGroupFields ?? [], o = e.valueFields ?? [], i = Mt(s, n), r = qe(
|
|
2527
|
+
s,
|
|
2519
2528
|
t,
|
|
2520
2529
|
n,
|
|
2521
2530
|
i,
|
|
@@ -2524,50 +2533,50 @@ function Ft(r, e) {
|
|
|
2524
2533
|
// starting depth
|
|
2525
2534
|
""
|
|
2526
2535
|
// parent key prefix
|
|
2527
|
-
), l =
|
|
2536
|
+
), l = Pt(r, i, o), a = Object.values(l).reduce((d, c) => d + c, 0);
|
|
2528
2537
|
return {
|
|
2529
|
-
rows:
|
|
2538
|
+
rows: r,
|
|
2530
2539
|
columnKeys: i,
|
|
2531
2540
|
totals: l,
|
|
2532
2541
|
grandTotal: a
|
|
2533
2542
|
};
|
|
2534
2543
|
}
|
|
2535
|
-
function
|
|
2544
|
+
function Mt(s, e) {
|
|
2536
2545
|
if (e.length === 0) return ["value"];
|
|
2537
2546
|
const t = /* @__PURE__ */ new Set();
|
|
2538
|
-
for (const n of
|
|
2547
|
+
for (const n of s) {
|
|
2539
2548
|
const o = e.map((i) => String(n[i] ?? "")).join("|");
|
|
2540
2549
|
t.add(o);
|
|
2541
2550
|
}
|
|
2542
2551
|
return [...t].sort();
|
|
2543
2552
|
}
|
|
2544
|
-
function
|
|
2553
|
+
function Nt(s, e) {
|
|
2545
2554
|
const t = /* @__PURE__ */ new Map();
|
|
2546
|
-
for (const n of
|
|
2555
|
+
for (const n of s) {
|
|
2547
2556
|
const o = String(n[e] ?? ""), i = t.get(o);
|
|
2548
2557
|
i ? i.push(n) : t.set(o, [n]);
|
|
2549
2558
|
}
|
|
2550
2559
|
return t;
|
|
2551
2560
|
}
|
|
2552
|
-
function qe(
|
|
2561
|
+
function qe(s, e, t, n, o, i, r) {
|
|
2553
2562
|
const l = [];
|
|
2554
2563
|
if (e.length === 0) {
|
|
2555
|
-
const h =
|
|
2564
|
+
const h = Ee(s, t, n, o), g = ke(h);
|
|
2556
2565
|
return l.push({
|
|
2557
|
-
rowKey:
|
|
2558
|
-
rowLabel:
|
|
2566
|
+
rowKey: r || "all",
|
|
2567
|
+
rowLabel: r || "All",
|
|
2559
2568
|
depth: i,
|
|
2560
2569
|
values: h,
|
|
2561
2570
|
total: g,
|
|
2562
2571
|
isGroup: !1,
|
|
2563
|
-
rowCount:
|
|
2572
|
+
rowCount: s.length
|
|
2564
2573
|
}), l;
|
|
2565
2574
|
}
|
|
2566
|
-
const a = e[0], d = e.slice(1), c = d.length > 0, u =
|
|
2575
|
+
const a = e[0], d = e.slice(1), c = d.length > 0, u = Nt(s, a);
|
|
2567
2576
|
for (const [h, g] of u) {
|
|
2568
|
-
const p =
|
|
2569
|
-
let
|
|
2570
|
-
c && (
|
|
2577
|
+
const p = r ? `${r}|${h}` : h, m = Ee(g, t, n, o), f = ke(m);
|
|
2578
|
+
let b;
|
|
2579
|
+
c && (b = qe(
|
|
2571
2580
|
g,
|
|
2572
2581
|
d,
|
|
2573
2582
|
t,
|
|
@@ -2579,93 +2588,93 @@ function qe(r, e, t, n, o, i, s) {
|
|
|
2579
2588
|
rowKey: p,
|
|
2580
2589
|
rowLabel: h || "(blank)",
|
|
2581
2590
|
depth: i,
|
|
2582
|
-
values:
|
|
2583
|
-
total:
|
|
2591
|
+
values: m,
|
|
2592
|
+
total: f,
|
|
2584
2593
|
isGroup: c,
|
|
2585
|
-
children:
|
|
2594
|
+
children: b,
|
|
2586
2595
|
rowCount: g.length
|
|
2587
2596
|
});
|
|
2588
2597
|
}
|
|
2589
2598
|
return l;
|
|
2590
2599
|
}
|
|
2591
|
-
function
|
|
2600
|
+
function Ee(s, e, t, n) {
|
|
2592
2601
|
const o = {};
|
|
2593
2602
|
for (const i of t)
|
|
2594
|
-
for (const
|
|
2595
|
-
const a = (e.length > 0 ?
|
|
2603
|
+
for (const r of n) {
|
|
2604
|
+
const a = (e.length > 0 ? s.filter((h) => e.map((g) => String(h[g] ?? "")).join("|") === i) : s).map((h) => Number(h[r.field]) || 0), d = Lt(r.aggFunc), c = a.length > 0 ? d(a) : null, u = te([i], r.field);
|
|
2596
2605
|
o[u] = c;
|
|
2597
2606
|
}
|
|
2598
2607
|
return o;
|
|
2599
2608
|
}
|
|
2600
|
-
function
|
|
2609
|
+
function ke(s) {
|
|
2601
2610
|
let e = 0;
|
|
2602
|
-
for (const t of Object.values(
|
|
2611
|
+
for (const t of Object.values(s))
|
|
2603
2612
|
e += t ?? 0;
|
|
2604
2613
|
return e;
|
|
2605
2614
|
}
|
|
2606
|
-
function
|
|
2615
|
+
function Pt(s, e, t) {
|
|
2607
2616
|
const n = {};
|
|
2608
2617
|
function o(i) {
|
|
2609
|
-
for (const
|
|
2610
|
-
if (!
|
|
2618
|
+
for (const r of i)
|
|
2619
|
+
if (!r.isGroup || !r.children?.length)
|
|
2611
2620
|
for (const l of e)
|
|
2612
2621
|
for (const a of t) {
|
|
2613
2622
|
const d = te([l], a.field);
|
|
2614
|
-
n[d] = (n[d] ?? 0) + (
|
|
2623
|
+
n[d] = (n[d] ?? 0) + (r.values[d] ?? 0);
|
|
2615
2624
|
}
|
|
2616
|
-
else
|
|
2625
|
+
else r.children && o(r.children);
|
|
2617
2626
|
}
|
|
2618
|
-
return o(
|
|
2627
|
+
return o(s), n;
|
|
2619
2628
|
}
|
|
2620
|
-
function
|
|
2629
|
+
function Kt(s, e, t = !0) {
|
|
2621
2630
|
const n = [];
|
|
2622
2631
|
function o(i) {
|
|
2623
2632
|
n.push(i);
|
|
2624
|
-
const
|
|
2625
|
-
if (i.children &&
|
|
2633
|
+
const r = e ? e.has(i.rowKey) : t;
|
|
2634
|
+
if (i.children && r)
|
|
2626
2635
|
for (const l of i.children)
|
|
2627
2636
|
o(l);
|
|
2628
2637
|
}
|
|
2629
|
-
for (const i of
|
|
2638
|
+
for (const i of s)
|
|
2630
2639
|
o(i);
|
|
2631
2640
|
return n;
|
|
2632
2641
|
}
|
|
2633
|
-
function $(
|
|
2642
|
+
function $(s) {
|
|
2634
2643
|
const e = [];
|
|
2635
2644
|
function t(n) {
|
|
2636
2645
|
if (n.isGroup && e.push(n.rowKey), n.children)
|
|
2637
2646
|
for (const o of n.children)
|
|
2638
2647
|
t(o);
|
|
2639
2648
|
}
|
|
2640
|
-
for (const n of
|
|
2649
|
+
for (const n of s)
|
|
2641
2650
|
t(n);
|
|
2642
2651
|
return e;
|
|
2643
2652
|
}
|
|
2644
2653
|
const qt = ["sum", "avg", "count", "min", "max", "first", "last"];
|
|
2645
|
-
function Dt(
|
|
2646
|
-
const o = new AbortController(), i = { config: e, callbacks: n, signal: o.signal },
|
|
2647
|
-
return
|
|
2648
|
-
o.abort(),
|
|
2654
|
+
function Dt(s, e, t, n) {
|
|
2655
|
+
const o = new AbortController(), i = { config: e, callbacks: n, signal: o.signal }, r = document.createElement("div");
|
|
2656
|
+
return r.className = "tbw-pivot-panel", r.appendChild(T("Options", () => Vt(t, i))), r.appendChild(T("Row Groups", () => Ae("rowGroups", i))), r.appendChild(T("Column Groups", () => Ae("columnGroups", i))), r.appendChild(T("Values", () => Gt(i))), r.appendChild(T("Available Fields", () => Bt(i))), s.appendChild(r), () => {
|
|
2657
|
+
o.abort(), r.remove();
|
|
2649
2658
|
};
|
|
2650
2659
|
}
|
|
2651
|
-
function
|
|
2660
|
+
function T(s, e) {
|
|
2652
2661
|
const t = document.createElement("div");
|
|
2653
2662
|
t.className = "tbw-pivot-section";
|
|
2654
2663
|
const n = document.createElement("div");
|
|
2655
|
-
n.className = "tbw-pivot-section-header", n.textContent =
|
|
2664
|
+
n.className = "tbw-pivot-section-header", n.textContent = s;
|
|
2656
2665
|
const o = document.createElement("div");
|
|
2657
2666
|
return o.className = "tbw-pivot-section-content", o.appendChild(e()), t.appendChild(n), t.appendChild(o), t;
|
|
2658
2667
|
}
|
|
2659
|
-
function
|
|
2668
|
+
function Ae(s, e) {
|
|
2660
2669
|
const { config: t, callbacks: n, signal: o } = e, i = document.createElement("div");
|
|
2661
|
-
i.className = "tbw-pivot-drop-zone", i.setAttribute("data-zone",
|
|
2662
|
-
const
|
|
2663
|
-
if (
|
|
2670
|
+
i.className = "tbw-pivot-drop-zone", i.setAttribute("data-zone", s);
|
|
2671
|
+
const r = s === "rowGroups" ? t.rowGroupFields ?? [] : t.columnGroupFields ?? [];
|
|
2672
|
+
if (r.length === 0) {
|
|
2664
2673
|
const l = document.createElement("div");
|
|
2665
2674
|
l.className = "tbw-pivot-placeholder", l.textContent = "Drag fields here or click to add", i.appendChild(l);
|
|
2666
2675
|
} else
|
|
2667
|
-
for (const l of
|
|
2668
|
-
i.appendChild(
|
|
2676
|
+
for (const l of r)
|
|
2677
|
+
i.appendChild(Ht(l, s, e));
|
|
2669
2678
|
return i.addEventListener(
|
|
2670
2679
|
"dragover",
|
|
2671
2680
|
(l) => {
|
|
@@ -2683,27 +2692,27 @@ function ke(r, e) {
|
|
|
2683
2692
|
(l) => {
|
|
2684
2693
|
l.preventDefault(), i.classList.remove("drag-over");
|
|
2685
2694
|
const a = l.dataTransfer?.getData("text/plain");
|
|
2686
|
-
a && n.onAddFieldToZone(a,
|
|
2695
|
+
a && n.onAddFieldToZone(a, s);
|
|
2687
2696
|
},
|
|
2688
2697
|
{ signal: o }
|
|
2689
2698
|
), i;
|
|
2690
2699
|
}
|
|
2691
|
-
function
|
|
2700
|
+
function Ht(s, e, t) {
|
|
2692
2701
|
const { callbacks: n, signal: o } = t, i = document.createElement("div");
|
|
2693
2702
|
i.className = "tbw-pivot-field-chip", i.draggable = !0;
|
|
2694
|
-
const
|
|
2695
|
-
l.className = "tbw-pivot-chip-label", l.textContent =
|
|
2703
|
+
const r = n.getAvailableFields().find((d) => d.field === s), l = document.createElement("span");
|
|
2704
|
+
l.className = "tbw-pivot-chip-label", l.textContent = r?.header ?? s;
|
|
2696
2705
|
const a = document.createElement("button");
|
|
2697
2706
|
return a.className = "tbw-pivot-chip-remove", a.innerHTML = "×", a.title = "Remove field", a.addEventListener(
|
|
2698
2707
|
"click",
|
|
2699
2708
|
(d) => {
|
|
2700
|
-
d.stopPropagation(), n.onRemoveFieldFromZone(
|
|
2709
|
+
d.stopPropagation(), n.onRemoveFieldFromZone(s, e);
|
|
2701
2710
|
},
|
|
2702
2711
|
{ signal: o }
|
|
2703
2712
|
), i.appendChild(l), i.appendChild(a), i.addEventListener(
|
|
2704
2713
|
"dragstart",
|
|
2705
2714
|
(d) => {
|
|
2706
|
-
d.dataTransfer?.setData("text/plain",
|
|
2715
|
+
d.dataTransfer?.setData("text/plain", s), d.dataTransfer?.setData("source-zone", e), i.classList.add("dragging");
|
|
2707
2716
|
},
|
|
2708
2717
|
{ signal: o }
|
|
2709
2718
|
), i.addEventListener(
|
|
@@ -2714,20 +2723,20 @@ function Kt(r, e, t) {
|
|
|
2714
2723
|
{ signal: o }
|
|
2715
2724
|
), i;
|
|
2716
2725
|
}
|
|
2717
|
-
function
|
|
2718
|
-
const { config: e, callbacks: t, signal: n } =
|
|
2726
|
+
function Gt(s) {
|
|
2727
|
+
const { config: e, callbacks: t, signal: n } = s, o = document.createElement("div");
|
|
2719
2728
|
o.className = "tbw-pivot-drop-zone tbw-pivot-values-zone", o.setAttribute("data-zone", "values");
|
|
2720
2729
|
const i = e.valueFields ?? [];
|
|
2721
2730
|
if (i.length === 0) {
|
|
2722
|
-
const
|
|
2723
|
-
|
|
2731
|
+
const r = document.createElement("div");
|
|
2732
|
+
r.className = "tbw-pivot-placeholder", r.textContent = "Drag numeric fields here for aggregation", o.appendChild(r);
|
|
2724
2733
|
} else
|
|
2725
|
-
for (const
|
|
2726
|
-
o.appendChild(
|
|
2734
|
+
for (const r of i)
|
|
2735
|
+
o.appendChild(Ot(r, s));
|
|
2727
2736
|
return o.addEventListener(
|
|
2728
2737
|
"dragover",
|
|
2729
|
-
(
|
|
2730
|
-
|
|
2738
|
+
(r) => {
|
|
2739
|
+
r.preventDefault(), o.classList.add("drag-over");
|
|
2731
2740
|
},
|
|
2732
2741
|
{ signal: n }
|
|
2733
2742
|
), o.addEventListener(
|
|
@@ -2738,31 +2747,31 @@ function Ht(r) {
|
|
|
2738
2747
|
{ signal: n }
|
|
2739
2748
|
), o.addEventListener(
|
|
2740
2749
|
"drop",
|
|
2741
|
-
(
|
|
2742
|
-
|
|
2743
|
-
const l =
|
|
2750
|
+
(r) => {
|
|
2751
|
+
r.preventDefault(), o.classList.remove("drag-over");
|
|
2752
|
+
const l = r.dataTransfer?.getData("text/plain");
|
|
2744
2753
|
l && t.onAddValueField(l, "sum");
|
|
2745
2754
|
},
|
|
2746
2755
|
{ signal: n }
|
|
2747
2756
|
), o;
|
|
2748
2757
|
}
|
|
2749
|
-
function
|
|
2758
|
+
function Ot(s, e) {
|
|
2750
2759
|
const { callbacks: t, signal: n } = e, o = document.createElement("div");
|
|
2751
2760
|
o.className = "tbw-pivot-field-chip tbw-pivot-value-chip";
|
|
2752
|
-
const i = t.getAvailableFields().find((c) => c.field ===
|
|
2753
|
-
|
|
2761
|
+
const i = t.getAvailableFields().find((c) => c.field === s.field), r = document.createElement("div");
|
|
2762
|
+
r.className = "tbw-pivot-value-label-wrapper";
|
|
2754
2763
|
const l = document.createElement("span");
|
|
2755
|
-
l.className = "tbw-pivot-chip-label", l.textContent = i?.header ??
|
|
2764
|
+
l.className = "tbw-pivot-chip-label", l.textContent = i?.header ?? s.field;
|
|
2756
2765
|
const a = document.createElement("select");
|
|
2757
2766
|
a.className = "tbw-pivot-agg-select", a.title = "Aggregation function";
|
|
2758
2767
|
for (const c of qt) {
|
|
2759
2768
|
const u = document.createElement("option");
|
|
2760
|
-
u.value = c, u.textContent = c.toUpperCase(), u.selected = c ===
|
|
2769
|
+
u.value = c, u.textContent = c.toUpperCase(), u.selected = c === s.aggFunc, a.appendChild(u);
|
|
2761
2770
|
}
|
|
2762
2771
|
a.addEventListener(
|
|
2763
2772
|
"change",
|
|
2764
2773
|
() => {
|
|
2765
|
-
t.onUpdateValueAggFunc(
|
|
2774
|
+
t.onUpdateValueAggFunc(s.field, a.value);
|
|
2766
2775
|
},
|
|
2767
2776
|
{ signal: n }
|
|
2768
2777
|
);
|
|
@@ -2770,19 +2779,19 @@ function Gt(r, e) {
|
|
|
2770
2779
|
return d.className = "tbw-pivot-chip-remove", d.innerHTML = "×", d.title = "Remove value field", d.addEventListener(
|
|
2771
2780
|
"click",
|
|
2772
2781
|
(c) => {
|
|
2773
|
-
c.stopPropagation(), t.onRemoveValueField(
|
|
2782
|
+
c.stopPropagation(), t.onRemoveValueField(s.field);
|
|
2774
2783
|
},
|
|
2775
2784
|
{ signal: n }
|
|
2776
|
-
),
|
|
2785
|
+
), r.appendChild(l), r.appendChild(a), o.appendChild(r), o.appendChild(d), o;
|
|
2777
2786
|
}
|
|
2778
|
-
function
|
|
2779
|
-
const { config: e, callbacks: t, signal: n } =
|
|
2787
|
+
function Bt(s) {
|
|
2788
|
+
const { config: e, callbacks: t, signal: n } = s, o = document.createElement("div");
|
|
2780
2789
|
o.className = "tbw-pivot-available-fields";
|
|
2781
|
-
const i = t.getAvailableFields(),
|
|
2790
|
+
const i = t.getAvailableFields(), r = /* @__PURE__ */ new Set([
|
|
2782
2791
|
...e.rowGroupFields ?? [],
|
|
2783
2792
|
...e.columnGroupFields ?? [],
|
|
2784
2793
|
...e.valueFields?.map((a) => a.field) ?? []
|
|
2785
|
-
]), l = i.filter((a) => !
|
|
2794
|
+
]), l = i.filter((a) => !r.has(a.field));
|
|
2786
2795
|
if (l.length === 0) {
|
|
2787
2796
|
const a = document.createElement("div");
|
|
2788
2797
|
a.className = "tbw-pivot-placeholder", a.textContent = "All fields are in use", o.appendChild(a);
|
|
@@ -2805,14 +2814,14 @@ function Ot(r) {
|
|
|
2805
2814
|
}
|
|
2806
2815
|
return o;
|
|
2807
2816
|
}
|
|
2808
|
-
function
|
|
2817
|
+
function Vt(s, e) {
|
|
2809
2818
|
const { config: t, callbacks: n, signal: o } = e, i = document.createElement("div");
|
|
2810
2819
|
return i.className = "tbw-pivot-options", i.appendChild(
|
|
2811
2820
|
j(
|
|
2812
2821
|
"Enable Pivot View",
|
|
2813
|
-
|
|
2814
|
-
(
|
|
2815
|
-
n.onTogglePivot(
|
|
2822
|
+
s,
|
|
2823
|
+
(r) => {
|
|
2824
|
+
n.onTogglePivot(r);
|
|
2816
2825
|
},
|
|
2817
2826
|
o
|
|
2818
2827
|
)
|
|
@@ -2820,8 +2829,8 @@ function Bt(r, e) {
|
|
|
2820
2829
|
j(
|
|
2821
2830
|
"Show Row Totals",
|
|
2822
2831
|
t.showTotals ?? !0,
|
|
2823
|
-
(
|
|
2824
|
-
n.onOptionChange("showTotals",
|
|
2832
|
+
(r) => {
|
|
2833
|
+
n.onOptionChange("showTotals", r);
|
|
2825
2834
|
},
|
|
2826
2835
|
o
|
|
2827
2836
|
)
|
|
@@ -2829,72 +2838,72 @@ function Bt(r, e) {
|
|
|
2829
2838
|
j(
|
|
2830
2839
|
"Show Grand Total",
|
|
2831
2840
|
t.showGrandTotal ?? !0,
|
|
2832
|
-
(
|
|
2833
|
-
n.onOptionChange("showGrandTotal",
|
|
2841
|
+
(r) => {
|
|
2842
|
+
n.onOptionChange("showGrandTotal", r);
|
|
2834
2843
|
},
|
|
2835
2844
|
o
|
|
2836
2845
|
)
|
|
2837
2846
|
), i;
|
|
2838
2847
|
}
|
|
2839
|
-
function j(
|
|
2848
|
+
function j(s, e, t, n) {
|
|
2840
2849
|
const o = document.createElement("label");
|
|
2841
2850
|
o.className = "tbw-pivot-checkbox";
|
|
2842
2851
|
const i = document.createElement("input");
|
|
2843
2852
|
i.type = "checkbox", i.checked = e, i.addEventListener("change", () => t(i.checked), { signal: n });
|
|
2844
|
-
const
|
|
2845
|
-
return
|
|
2853
|
+
const r = document.createElement("span");
|
|
2854
|
+
return r.textContent = s, o.appendChild(i), o.appendChild(r), o;
|
|
2846
2855
|
}
|
|
2847
|
-
function
|
|
2848
|
-
return e.className = "pivot-group-row", e.setAttribute("data-pivot-depth", String(
|
|
2856
|
+
function zt(s, e, t) {
|
|
2857
|
+
return e.className = "pivot-group-row", e.setAttribute("data-pivot-depth", String(s.__pivotDepth ?? 0)), e.setAttribute("role", "row"), e.innerHTML = "", t.columns.forEach((n, o) => {
|
|
2849
2858
|
const i = document.createElement("div");
|
|
2850
2859
|
if (i.className = "cell", i.setAttribute("data-col", String(o)), i.setAttribute("role", "gridcell"), o === 0) {
|
|
2851
|
-
const
|
|
2852
|
-
i.style.paddingLeft = `${
|
|
2853
|
-
const l = String(
|
|
2854
|
-
a.type = "button", a.className = "pivot-toggle", a.setAttribute("aria-label",
|
|
2860
|
+
const r = Number(s.__pivotIndent) || 0;
|
|
2861
|
+
i.style.paddingLeft = `${r}px`;
|
|
2862
|
+
const l = String(s.__pivotRowKey), a = document.createElement("button");
|
|
2863
|
+
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) => {
|
|
2855
2864
|
u.stopPropagation(), t.onToggle(l);
|
|
2856
2865
|
}), i.appendChild(a);
|
|
2857
2866
|
const d = document.createElement("span");
|
|
2858
|
-
d.className = "pivot-label", d.textContent = String(
|
|
2867
|
+
d.className = "pivot-label", d.textContent = String(s.__pivotLabel ?? ""), i.appendChild(d);
|
|
2859
2868
|
const c = document.createElement("span");
|
|
2860
|
-
c.className = "pivot-count", c.textContent = ` (${Number(
|
|
2869
|
+
c.className = "pivot-count", c.textContent = ` (${Number(s.__pivotRowCount) || 0})`, i.appendChild(c);
|
|
2861
2870
|
} else {
|
|
2862
|
-
const
|
|
2863
|
-
i.textContent =
|
|
2871
|
+
const r = s[n.field];
|
|
2872
|
+
i.textContent = r != null ? String(r) : "";
|
|
2864
2873
|
}
|
|
2865
2874
|
e.appendChild(i);
|
|
2866
2875
|
}), !0;
|
|
2867
2876
|
}
|
|
2868
|
-
function
|
|
2869
|
-
return e.className = "pivot-leaf-row", e.setAttribute("data-pivot-depth", String(
|
|
2877
|
+
function Wt(s, e, t) {
|
|
2878
|
+
return e.className = "pivot-leaf-row", e.setAttribute("data-pivot-depth", String(s.__pivotDepth ?? 0)), e.innerHTML = "", t.forEach((n, o) => {
|
|
2870
2879
|
const i = document.createElement("div");
|
|
2871
2880
|
if (i.className = "cell", i.setAttribute("data-col", String(o)), i.setAttribute("role", "gridcell"), o === 0) {
|
|
2872
|
-
const
|
|
2873
|
-
i.style.paddingLeft = `${
|
|
2881
|
+
const r = Number(s.__pivotIndent) || 0;
|
|
2882
|
+
i.style.paddingLeft = `${r + 20}px`;
|
|
2874
2883
|
const l = document.createElement("span");
|
|
2875
|
-
l.className = "pivot-label", l.textContent = String(
|
|
2884
|
+
l.className = "pivot-label", l.textContent = String(s.__pivotLabel ?? ""), i.appendChild(l);
|
|
2876
2885
|
} else {
|
|
2877
|
-
const
|
|
2878
|
-
i.textContent =
|
|
2886
|
+
const r = s[n.field];
|
|
2887
|
+
i.textContent = r != null ? String(r) : "";
|
|
2879
2888
|
}
|
|
2880
2889
|
e.appendChild(i);
|
|
2881
2890
|
}), !0;
|
|
2882
2891
|
}
|
|
2883
|
-
function
|
|
2892
|
+
function $t(s, e, t) {
|
|
2884
2893
|
return e.className = "pivot-grand-total-row", e.setAttribute("role", "presentation"), e.innerHTML = "", t.forEach((n, o) => {
|
|
2885
2894
|
const i = document.createElement("div");
|
|
2886
2895
|
if (i.className = "cell", i.setAttribute("data-col", String(o)), o === 0) {
|
|
2887
|
-
const
|
|
2888
|
-
|
|
2896
|
+
const r = document.createElement("span");
|
|
2897
|
+
r.className = "pivot-label", r.textContent = "Grand Total", i.appendChild(r);
|
|
2889
2898
|
} else {
|
|
2890
|
-
const
|
|
2891
|
-
i.textContent =
|
|
2899
|
+
const r = s[n.field];
|
|
2900
|
+
i.textContent = r != null ? String(r) : "";
|
|
2892
2901
|
}
|
|
2893
2902
|
e.appendChild(i);
|
|
2894
2903
|
}), !0;
|
|
2895
2904
|
}
|
|
2896
|
-
const
|
|
2897
|
-
class F extends
|
|
2905
|
+
const jt = '.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;font-size:10px;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:12px;padding:12px;height:100%;overflow-y:auto;font-size:13px}.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:8px 12px;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:8px}.tbw-pivot-toggle-wrapper{display:flex;align-items:center}.tbw-pivot-toggle-label{display:flex;align-items:center;gap:8px;cursor:pointer}.tbw-pivot-toggle-label input{width:16px;height:16px;cursor:pointer}.tbw-pivot-drop-zone{min-height:60px;padding:8px;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:6px;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:8px;text-align:center;width:100%}.tbw-pivot-field-chip{display:inline-flex;align-items:center;gap:6px;padding:4px 8px;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:12px;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:16px;height:16px;padding:0;border:none;background:transparent;color:var(--tbw-color-fg-muted);font-size:14px;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:4px 8px}.tbw-pivot-value-label-wrapper{display:flex;align-items:center;gap:8px;flex:1;min-width:0}.tbw-pivot-agg-select{padding:2px 4px;font-size:11px;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:6px;min-height:40px}.tbw-pivot-options{display:flex;flex-direction:column;gap:8px}.tbw-pivot-checkbox{display:flex;align-items:center;gap:8px;cursor:pointer}.tbw-pivot-checkbox input{width:14px;height:14px;cursor:pointer}';
|
|
2906
|
+
class F extends y {
|
|
2898
2907
|
name = "pivot";
|
|
2899
2908
|
version = "1.0.0";
|
|
2900
2909
|
/** Tool panel ID for shell integration */
|
|
@@ -2903,7 +2912,8 @@ class F extends x {
|
|
|
2903
2912
|
return {
|
|
2904
2913
|
active: !0,
|
|
2905
2914
|
showTotals: !0,
|
|
2906
|
-
showGrandTotal: !0
|
|
2915
|
+
showGrandTotal: !0,
|
|
2916
|
+
showToolPanel: !0
|
|
2907
2917
|
};
|
|
2908
2918
|
}
|
|
2909
2919
|
// #region Internal State
|
|
@@ -2930,35 +2940,36 @@ class F extends x {
|
|
|
2930
2940
|
// #endregion
|
|
2931
2941
|
// #region Shell Integration
|
|
2932
2942
|
getToolPanel() {
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2943
|
+
if ((this.config?.showToolPanel ?? this.userConfig?.showToolPanel ?? !0) !== !1)
|
|
2944
|
+
return {
|
|
2945
|
+
id: F.PANEL_ID,
|
|
2946
|
+
title: "Pivot",
|
|
2947
|
+
icon: "⊞",
|
|
2948
|
+
tooltip: "Configure pivot table",
|
|
2949
|
+
order: 90,
|
|
2950
|
+
render: (t) => this.renderPanel(t)
|
|
2951
|
+
};
|
|
2941
2952
|
}
|
|
2942
2953
|
// #endregion
|
|
2943
2954
|
// #region Hooks
|
|
2944
2955
|
processRows(e) {
|
|
2945
2956
|
if (!this.hasInitialized && this.config.active !== !1 && this.hasValidPivotConfig() && (this.hasInitialized = !0, this.isActive = !0), !this.isActive)
|
|
2946
2957
|
return [...e];
|
|
2947
|
-
const t =
|
|
2958
|
+
const t = Tt(this.config);
|
|
2948
2959
|
if (t.length > 0)
|
|
2949
2960
|
return this.warn(`Config errors: ${t.join(", ")}`), [...e];
|
|
2950
2961
|
if (this.buildFieldHeaderMap(), this.defaultExpanded = this.config.defaultExpanded ?? !0, this.expandedKeys.size === 0 && this.defaultExpanded && this.pivotResult) {
|
|
2951
2962
|
const i = $(this.pivotResult.rows);
|
|
2952
|
-
for (const
|
|
2953
|
-
this.expandedKeys.add(
|
|
2963
|
+
for (const r of i)
|
|
2964
|
+
this.expandedKeys.add(r);
|
|
2954
2965
|
}
|
|
2955
2966
|
if (this.pivotResult = Ft(e, this.config), this.expandedKeys.size === 0 && this.defaultExpanded) {
|
|
2956
2967
|
const i = $(this.pivotResult.rows);
|
|
2957
|
-
for (const
|
|
2958
|
-
this.expandedKeys.add(
|
|
2968
|
+
for (const r of i)
|
|
2969
|
+
this.expandedKeys.add(r);
|
|
2959
2970
|
}
|
|
2960
2971
|
const n = this.config.indentWidth ?? 20;
|
|
2961
|
-
return
|
|
2972
|
+
return Kt(
|
|
2962
2973
|
this.pivotResult.rows,
|
|
2963
2974
|
this.expandedKeys,
|
|
2964
2975
|
this.defaultExpanded
|
|
@@ -2986,9 +2997,9 @@ class F extends x {
|
|
|
2986
2997
|
});
|
|
2987
2998
|
for (const o of this.pivotResult.columnKeys)
|
|
2988
2999
|
for (const i of this.config.valueFields ?? []) {
|
|
2989
|
-
const
|
|
3000
|
+
const r = te([o], i.field), l = i.header || this.fieldHeaderMap.get(i.field) || i.field;
|
|
2990
3001
|
t.push({
|
|
2991
|
-
field:
|
|
3002
|
+
field: r,
|
|
2992
3003
|
header: `${o} - ${l} (${i.aggFunc})`,
|
|
2993
3004
|
width: 120,
|
|
2994
3005
|
type: "number"
|
|
@@ -3003,12 +3014,12 @@ class F extends x {
|
|
|
3003
3014
|
}
|
|
3004
3015
|
renderRow(e, t) {
|
|
3005
3016
|
const n = e;
|
|
3006
|
-
return n.__pivotRowKey && n.__pivotHasChildren ?
|
|
3017
|
+
return n.__pivotRowKey && n.__pivotHasChildren ? zt(n, t, {
|
|
3007
3018
|
columns: this.gridColumns,
|
|
3008
3019
|
onToggle: (o) => this.toggle(o),
|
|
3009
3020
|
resolveIcon: (o) => this.resolveIcon(o),
|
|
3010
3021
|
setIcon: (o, i) => this.setIcon(o, i)
|
|
3011
|
-
}) : n.__pivotRowKey !== void 0 && this.isActive ?
|
|
3022
|
+
}) : n.__pivotRowKey !== void 0 && this.isActive ? Wt(n, t, this.gridColumns) : (this.cleanupPivotStyling(t), !1);
|
|
3012
3023
|
}
|
|
3013
3024
|
/**
|
|
3014
3025
|
* Remove pivot-specific classes, attributes, and inline styles from a row element.
|
|
@@ -3038,7 +3049,7 @@ class F extends x {
|
|
|
3038
3049
|
__pivotTotal: this.pivotResult.grandTotal,
|
|
3039
3050
|
...this.pivotResult.totals
|
|
3040
3051
|
};
|
|
3041
|
-
|
|
3052
|
+
$t(n, this.grandTotalFooter, this.gridColumns);
|
|
3042
3053
|
}
|
|
3043
3054
|
/**
|
|
3044
3055
|
* Remove the grand total footer element.
|
|
@@ -3187,26 +3198,25 @@ class F extends x {
|
|
|
3187
3198
|
}
|
|
3188
3199
|
// #endregion
|
|
3189
3200
|
// #region Styles
|
|
3190
|
-
styles =
|
|
3201
|
+
styles = jt;
|
|
3191
3202
|
// #endregion
|
|
3192
3203
|
}
|
|
3193
|
-
function
|
|
3194
|
-
const e =
|
|
3204
|
+
function Ut(s) {
|
|
3205
|
+
const e = s.meta ?? {};
|
|
3195
3206
|
return e.lockPosition !== !0 && e.suppressMovable !== !0;
|
|
3196
3207
|
}
|
|
3197
|
-
function
|
|
3198
|
-
if (e === t || e < 0 || e >=
|
|
3199
|
-
const n = [...
|
|
3208
|
+
function _e(s, e, t) {
|
|
3209
|
+
if (e === t || e < 0 || e >= s.length || t < 0 || t > s.length) return s;
|
|
3210
|
+
const n = [...s], [o] = n.splice(e, 1);
|
|
3200
3211
|
return n.splice(t, 0, o), n;
|
|
3201
3212
|
}
|
|
3202
|
-
const
|
|
3203
|
-
class
|
|
3213
|
+
const Yt = '.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}';
|
|
3214
|
+
class _n extends y {
|
|
3204
3215
|
name = "reorder";
|
|
3205
3216
|
version = "1.0.0";
|
|
3206
3217
|
get defaultConfig() {
|
|
3207
3218
|
return {
|
|
3208
|
-
|
|
3209
|
-
animationDuration: 200
|
|
3219
|
+
viewTransition: !0
|
|
3210
3220
|
};
|
|
3211
3221
|
}
|
|
3212
3222
|
// #region Internal State
|
|
@@ -3231,18 +3241,17 @@ class An extends x {
|
|
|
3231
3241
|
}
|
|
3232
3242
|
// #endregion
|
|
3233
3243
|
// #region Hooks
|
|
3234
|
-
// Note: No processColumns hook needed - we directly update the grid's column order
|
|
3235
3244
|
afterRender() {
|
|
3236
3245
|
const e = this.shadowRoot;
|
|
3237
3246
|
if (!e) return;
|
|
3238
3247
|
e.querySelectorAll(".header-row > .cell").forEach((n) => {
|
|
3239
3248
|
const o = n, i = o.getAttribute("data-field");
|
|
3240
3249
|
if (!i) return;
|
|
3241
|
-
const
|
|
3242
|
-
type:
|
|
3243
|
-
context:
|
|
3250
|
+
const r = this.columns.find((c) => c.field === i), d = !this.grid.queryPlugins({
|
|
3251
|
+
type: Ke.CAN_MOVE_COLUMN,
|
|
3252
|
+
context: r
|
|
3244
3253
|
}).includes(!1);
|
|
3245
|
-
if (!
|
|
3254
|
+
if (!r || !Ut(r) || !d) {
|
|
3246
3255
|
o.draggable = !1;
|
|
3247
3256
|
return;
|
|
3248
3257
|
}
|
|
@@ -3264,13 +3273,13 @@ class An extends x {
|
|
|
3264
3273
|
const u = this.draggedField, h = this.draggedIndex, g = this.dropIndex;
|
|
3265
3274
|
if (!this.isDragging || u === null || h === null || g === null)
|
|
3266
3275
|
return;
|
|
3267
|
-
const p = g > h ? g - 1 : g,
|
|
3276
|
+
const p = g > h ? g - 1 : g, m = this.getColumnOrder(), f = _e(m, h, p), b = {
|
|
3268
3277
|
field: u,
|
|
3269
3278
|
fromIndex: h,
|
|
3270
3279
|
toIndex: p,
|
|
3271
|
-
columnOrder:
|
|
3280
|
+
columnOrder: f
|
|
3272
3281
|
};
|
|
3273
|
-
this.
|
|
3282
|
+
this.updateColumnOrder(f), this.emit("column-move", b);
|
|
3274
3283
|
}));
|
|
3275
3284
|
});
|
|
3276
3285
|
}
|
|
@@ -3291,85 +3300,107 @@ class An extends x {
|
|
|
3291
3300
|
moveColumn(e, t) {
|
|
3292
3301
|
const n = this.getColumnOrder(), o = n.indexOf(e);
|
|
3293
3302
|
if (o === -1) return;
|
|
3294
|
-
const i =
|
|
3295
|
-
this.
|
|
3303
|
+
const i = _e(n, o, t);
|
|
3304
|
+
this.updateColumnOrder(i), this.emit("column-move", {
|
|
3296
3305
|
field: e,
|
|
3297
3306
|
fromIndex: o,
|
|
3298
3307
|
toIndex: t,
|
|
3299
3308
|
columnOrder: i
|
|
3300
|
-
})
|
|
3309
|
+
});
|
|
3301
3310
|
}
|
|
3302
3311
|
/**
|
|
3303
3312
|
* Set a specific column order.
|
|
3304
3313
|
* @param order - Array of field names in desired order
|
|
3305
3314
|
*/
|
|
3306
3315
|
setColumnOrder(e) {
|
|
3307
|
-
this.
|
|
3316
|
+
this.updateColumnOrder(e);
|
|
3308
3317
|
}
|
|
3309
3318
|
/**
|
|
3310
3319
|
* Reset column order to the original configuration order.
|
|
3311
3320
|
*/
|
|
3312
3321
|
resetColumnOrder() {
|
|
3313
3322
|
const e = this.columns.map((t) => t.field);
|
|
3314
|
-
this.
|
|
3323
|
+
this.updateColumnOrder(e);
|
|
3324
|
+
}
|
|
3325
|
+
// #endregion
|
|
3326
|
+
// #region View Transition
|
|
3327
|
+
/**
|
|
3328
|
+
* Update column order with optional view transition animation.
|
|
3329
|
+
* Falls back to instant update if View Transitions API is not supported.
|
|
3330
|
+
*/
|
|
3331
|
+
updateColumnOrder(e) {
|
|
3332
|
+
const t = this.grid, n = this.shadowRoot;
|
|
3333
|
+
if (this.config.viewTransition && "startViewTransition" in document && n) {
|
|
3334
|
+
const o = n.querySelectorAll(".cell[data-field]");
|
|
3335
|
+
o.forEach((r) => {
|
|
3336
|
+
const l = r.getAttribute("data-field");
|
|
3337
|
+
l && (r.style.viewTransitionName = `col-${l}`);
|
|
3338
|
+
}), document.startViewTransition(() => t.setColumnOrder(e)).finished.finally(() => {
|
|
3339
|
+
o.forEach((r) => {
|
|
3340
|
+
r.style.viewTransitionName = "";
|
|
3341
|
+
});
|
|
3342
|
+
});
|
|
3343
|
+
} else
|
|
3344
|
+
t.setColumnOrder(e);
|
|
3345
|
+
t.requestStateChange?.();
|
|
3315
3346
|
}
|
|
3316
3347
|
// #endregion
|
|
3317
3348
|
// #region Styles
|
|
3318
|
-
styles =
|
|
3349
|
+
styles = Yt;
|
|
3319
3350
|
// #endregion
|
|
3320
3351
|
}
|
|
3321
|
-
function D(
|
|
3352
|
+
function D(s) {
|
|
3322
3353
|
return {
|
|
3323
|
-
startRow: Math.min(
|
|
3324
|
-
startCol: Math.min(
|
|
3325
|
-
endRow: Math.max(
|
|
3326
|
-
endCol: Math.max(
|
|
3354
|
+
startRow: Math.min(s.startRow, s.endRow),
|
|
3355
|
+
startCol: Math.min(s.startCol, s.endCol),
|
|
3356
|
+
endRow: Math.max(s.startRow, s.endRow),
|
|
3357
|
+
endCol: Math.max(s.startCol, s.endCol)
|
|
3327
3358
|
};
|
|
3328
3359
|
}
|
|
3329
|
-
function
|
|
3330
|
-
const e = D(
|
|
3360
|
+
function Zt(s) {
|
|
3361
|
+
const e = D(s);
|
|
3331
3362
|
return {
|
|
3332
3363
|
from: { row: e.startRow, col: e.startCol },
|
|
3333
3364
|
to: { row: e.endRow, col: e.endCol }
|
|
3334
3365
|
};
|
|
3335
3366
|
}
|
|
3336
|
-
function X(
|
|
3337
|
-
return
|
|
3367
|
+
function X(s) {
|
|
3368
|
+
return s.map(Zt);
|
|
3338
3369
|
}
|
|
3339
|
-
function
|
|
3370
|
+
function Xt(s, e, t) {
|
|
3340
3371
|
const n = D(t);
|
|
3341
|
-
return
|
|
3372
|
+
return s >= n.startRow && s <= n.endRow && e >= n.startCol && e <= n.endCol;
|
|
3342
3373
|
}
|
|
3343
|
-
function
|
|
3344
|
-
return t.some((n) =>
|
|
3374
|
+
function Ie(s, e, t) {
|
|
3375
|
+
return t.some((n) => Xt(s, e, n));
|
|
3345
3376
|
}
|
|
3346
|
-
function
|
|
3347
|
-
const e = [], t = D(
|
|
3377
|
+
function Jt(s) {
|
|
3378
|
+
const e = [], t = D(s);
|
|
3348
3379
|
for (let n = t.startRow; n <= t.endRow; n++)
|
|
3349
3380
|
for (let o = t.startCol; o <= t.endCol; o++)
|
|
3350
3381
|
e.push({ row: n, col: o });
|
|
3351
3382
|
return e;
|
|
3352
3383
|
}
|
|
3353
|
-
function
|
|
3384
|
+
function Qt(s) {
|
|
3354
3385
|
const e = /* @__PURE__ */ new Map();
|
|
3355
|
-
for (const t of
|
|
3356
|
-
for (const n of
|
|
3386
|
+
for (const t of s)
|
|
3387
|
+
for (const n of Jt(t))
|
|
3357
3388
|
e.set(`${n.row},${n.col}`, n);
|
|
3358
3389
|
return [...e.values()];
|
|
3359
3390
|
}
|
|
3360
|
-
function U(
|
|
3391
|
+
function U(s, e) {
|
|
3361
3392
|
return {
|
|
3362
|
-
startRow:
|
|
3363
|
-
startCol:
|
|
3393
|
+
startRow: s.row,
|
|
3394
|
+
startCol: s.col,
|
|
3364
3395
|
endRow: e.row,
|
|
3365
3396
|
endCol: e.col
|
|
3366
3397
|
};
|
|
3367
3398
|
}
|
|
3368
|
-
const
|
|
3369
|
-
function
|
|
3370
|
-
if (
|
|
3399
|
+
const en = ':host .selecting .data-grid-row>.cell{user-select:none}:host .data-grid-row.row-focus{background-color:var(--tbw-focus-background, rgba(from var(--tbw-color-accent) r g b / 12%))}:host([data-selection-mode="row"]) .cell-focus{outline:none}:host .data-grid-row>.cell.selected{background-color:var(--tbw-range-selection-bg)}:host .data-grid-row>.cell.selected.top{border-top:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.bottom{border-bottom:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.first{border-left:2px solid var(--tbw-range-border-color)}:host .data-grid-row>.cell.selected.last{border-right:2px solid var(--tbw-range-border-color)}';
|
|
3400
|
+
function tn(s, e, t) {
|
|
3401
|
+
if (s === "cell" && e.selectedCell)
|
|
3371
3402
|
return {
|
|
3372
|
-
mode:
|
|
3403
|
+
mode: s,
|
|
3373
3404
|
ranges: [
|
|
3374
3405
|
{
|
|
3375
3406
|
from: { row: e.selectedCell.row, col: e.selectedCell.col },
|
|
@@ -3377,16 +3408,16 @@ function en(r, e, t) {
|
|
|
3377
3408
|
}
|
|
3378
3409
|
]
|
|
3379
3410
|
};
|
|
3380
|
-
if (
|
|
3411
|
+
if (s === "row" && e.selected.size > 0) {
|
|
3381
3412
|
const n = [...e.selected].map((o) => ({
|
|
3382
3413
|
from: { row: o, col: 0 },
|
|
3383
3414
|
to: { row: o, col: t - 1 }
|
|
3384
3415
|
}));
|
|
3385
|
-
return { mode:
|
|
3416
|
+
return { mode: s, ranges: n };
|
|
3386
3417
|
}
|
|
3387
|
-
return
|
|
3418
|
+
return s === "range" && e.ranges.length > 0 ? { mode: s, ranges: X(e.ranges) } : { mode: s, ranges: [] };
|
|
3388
3419
|
}
|
|
3389
|
-
class
|
|
3420
|
+
class In extends y {
|
|
3390
3421
|
name = "selection";
|
|
3391
3422
|
version = "1.0.0";
|
|
3392
3423
|
get defaultConfig() {
|
|
@@ -3404,12 +3435,14 @@ class _n extends x {
|
|
|
3404
3435
|
activeRange = null;
|
|
3405
3436
|
cellAnchor = null;
|
|
3406
3437
|
isDragging = !1;
|
|
3438
|
+
/** Pending keyboard navigation update (processed in afterRender) */
|
|
3439
|
+
pendingKeyboardUpdate = null;
|
|
3407
3440
|
/** Cell selection state (cell mode) */
|
|
3408
3441
|
selectedCell = null;
|
|
3409
3442
|
// #endregion
|
|
3410
3443
|
// #region Lifecycle
|
|
3411
3444
|
detach() {
|
|
3412
|
-
this.selected.clear(), this.ranges = [], this.activeRange = null, this.cellAnchor = null, this.isDragging = !1, this.selectedCell = null;
|
|
3445
|
+
this.selected.clear(), this.ranges = [], this.activeRange = null, this.cellAnchor = null, this.isDragging = !1, this.selectedCell = null, this.pendingKeyboardUpdate = null;
|
|
3413
3446
|
}
|
|
3414
3447
|
// #endregion
|
|
3415
3448
|
// #region Event Handlers
|
|
@@ -3420,8 +3453,8 @@ class _n extends x {
|
|
|
3420
3453
|
if (i === "row")
|
|
3421
3454
|
return this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#e()), this.requestAfterRender(), !1;
|
|
3422
3455
|
if (i === "range") {
|
|
3423
|
-
const
|
|
3424
|
-
if (
|
|
3456
|
+
const r = o.shiftKey, l = o.ctrlKey || o.metaKey;
|
|
3457
|
+
if (r && this.cellAnchor) {
|
|
3425
3458
|
const a = U(this.cellAnchor, { row: t, col: n });
|
|
3426
3459
|
l ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = a : this.ranges.push(a) : this.ranges = [a], this.activeRange = a;
|
|
3427
3460
|
} else if (l) {
|
|
@@ -3451,33 +3484,22 @@ class _n extends x {
|
|
|
3451
3484
|
return t === "cell" ? this.selectedCell = null : t === "row" ? (this.selected.clear(), this.anchor = null) : t === "range" && (this.ranges = [], this.activeRange = null, this.cellAnchor = null), this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
|
|
3452
3485
|
if (t === "cell" && o)
|
|
3453
3486
|
return queueMicrotask(() => {
|
|
3454
|
-
this.selectedCell = { row: this.grid.
|
|
3487
|
+
this.selectedCell = { row: this.grid._focusRow, col: this.grid._focusCol }, this.emit("selection-change", this.#e()), this.requestAfterRender();
|
|
3455
3488
|
}), !1;
|
|
3456
3489
|
if (t === "row" && (e.key === "ArrowUp" || e.key === "ArrowDown"))
|
|
3457
3490
|
return queueMicrotask(() => {
|
|
3458
|
-
this.selected.clear(), this.selected.add(this.grid.
|
|
3491
|
+
this.selected.clear(), this.selected.add(this.grid._focusRow), this.lastSelected = this.grid._focusRow, this.emit("selection-change", this.#e()), this.requestAfterRender();
|
|
3459
3492
|
}), !1;
|
|
3460
|
-
if (t === "range" && o)
|
|
3461
|
-
|
|
3462
|
-
return queueMicrotask(() => {
|
|
3463
|
-
const s = this.grid.focusRow, l = this.grid.focusCol;
|
|
3464
|
-
if (i) {
|
|
3465
|
-
this.cellAnchor || (this.cellAnchor = { row: s, col: l });
|
|
3466
|
-
const a = U(this.cellAnchor, { row: s, col: l });
|
|
3467
|
-
this.ranges = [a], this.activeRange = a;
|
|
3468
|
-
} else
|
|
3469
|
-
this.ranges = [], this.activeRange = null, this.cellAnchor = { row: s, col: l };
|
|
3470
|
-
this.emit("selection-change", this.#e()), this.requestAfterRender();
|
|
3471
|
-
}), !1;
|
|
3472
|
-
}
|
|
3493
|
+
if (t === "range" && o)
|
|
3494
|
+
return e.shiftKey && !this.cellAnchor && (this.cellAnchor = { row: this.grid._focusRow, col: this.grid._focusCol }), this.pendingKeyboardUpdate = { shiftKey: e.shiftKey }, queueMicrotask(() => this.requestAfterRender()), !1;
|
|
3473
3495
|
if (t === "range" && e.key === "a" && (e.ctrlKey || e.metaKey)) {
|
|
3474
|
-
const i = this.rows.length,
|
|
3475
|
-
if (i > 0 &&
|
|
3496
|
+
const i = this.rows.length, r = this.columns.length;
|
|
3497
|
+
if (i > 0 && r > 0) {
|
|
3476
3498
|
const l = {
|
|
3477
3499
|
startRow: 0,
|
|
3478
3500
|
startCol: 0,
|
|
3479
3501
|
endRow: i - 1,
|
|
3480
|
-
endCol:
|
|
3502
|
+
endCol: r - 1
|
|
3481
3503
|
};
|
|
3482
3504
|
return this.ranges = [l], this.activeRange = l, this.emit("selection-change", this.#e()), this.requestAfterRender(), !0;
|
|
3483
3505
|
}
|
|
@@ -3522,13 +3544,13 @@ class _n extends x {
|
|
|
3522
3544
|
if (o.forEach((i) => {
|
|
3523
3545
|
i.classList.remove("selected", "row-focus");
|
|
3524
3546
|
}), t === "row" && (e.querySelectorAll(".cell-focus").forEach((i) => i.classList.remove("cell-focus")), o.forEach((i) => {
|
|
3525
|
-
const
|
|
3547
|
+
const r = i.querySelector(".cell[data-row]"), l = parseInt(r?.getAttribute("data-row") ?? "-1", 10);
|
|
3526
3548
|
l >= 0 && this.selected.has(l) && i.classList.add("selected", "row-focus");
|
|
3527
3549
|
})), t === "range" && this.ranges.length > 0) {
|
|
3528
3550
|
const i = this.activeRange ? D(this.activeRange) : null;
|
|
3529
3551
|
e.querySelectorAll(".cell[data-row][data-col]").forEach((l) => {
|
|
3530
3552
|
const a = parseInt(l.getAttribute("data-row") ?? "-1", 10), d = parseInt(l.getAttribute("data-col") ?? "-1", 10);
|
|
3531
|
-
a >= 0 && d >= 0 &&
|
|
3553
|
+
a >= 0 && d >= 0 && Ie(a, d, this.ranges) && (l.classList.add("selected"), l.classList.remove("cell-focus"), i && (a === i.startRow && l.classList.add("top"), a === i.endRow && l.classList.add("bottom"), d === i.startCol && l.classList.add("first"), d === i.endCol && l.classList.add("last")));
|
|
3532
3554
|
});
|
|
3533
3555
|
}
|
|
3534
3556
|
t === "cell" && this.selectedCell && e.querySelectorAll(".cell-focus").forEach((i) => i.classList.remove("cell-focus"));
|
|
@@ -3537,6 +3559,16 @@ class _n extends x {
|
|
|
3537
3559
|
const e = this.shadowRoot;
|
|
3538
3560
|
if (!e) return;
|
|
3539
3561
|
const t = e.children[0], { mode: n } = this.config;
|
|
3562
|
+
if (this.pendingKeyboardUpdate && n === "range") {
|
|
3563
|
+
const { shiftKey: o } = this.pendingKeyboardUpdate;
|
|
3564
|
+
this.pendingKeyboardUpdate = null;
|
|
3565
|
+
const i = this.grid._focusRow, r = this.grid._focusCol;
|
|
3566
|
+
if (o && this.cellAnchor) {
|
|
3567
|
+
const l = U(this.cellAnchor, { row: i, col: r });
|
|
3568
|
+
this.ranges = [l], this.activeRange = l;
|
|
3569
|
+
} else o || (this.ranges = [], this.activeRange = null, this.cellAnchor = { row: i, col: r });
|
|
3570
|
+
this.emit("selection-change", this.#e());
|
|
3571
|
+
}
|
|
3540
3572
|
this.grid.setAttribute("data-selection-mode", n), t && t.classList.toggle("selecting", this.isDragging), this.#t();
|
|
3541
3573
|
}
|
|
3542
3574
|
/**
|
|
@@ -3570,13 +3602,13 @@ class _n extends x {
|
|
|
3570
3602
|
* Get all selected cells across all ranges.
|
|
3571
3603
|
*/
|
|
3572
3604
|
getSelectedCells() {
|
|
3573
|
-
return
|
|
3605
|
+
return Qt(this.ranges);
|
|
3574
3606
|
}
|
|
3575
3607
|
/**
|
|
3576
3608
|
* Check if a specific cell is in range selection.
|
|
3577
3609
|
*/
|
|
3578
3610
|
isCellSelected(e, t) {
|
|
3579
|
-
return
|
|
3611
|
+
return Ie(e, t, this.ranges);
|
|
3580
3612
|
}
|
|
3581
3613
|
/**
|
|
3582
3614
|
* Clear all selection.
|
|
@@ -3601,7 +3633,7 @@ class _n extends x {
|
|
|
3601
3633
|
// #endregion
|
|
3602
3634
|
// #region Private Helpers
|
|
3603
3635
|
#e() {
|
|
3604
|
-
return
|
|
3636
|
+
return tn(
|
|
3605
3637
|
this.config.mode,
|
|
3606
3638
|
{
|
|
3607
3639
|
selectedCell: this.selectedCell,
|
|
@@ -3613,41 +3645,41 @@ class _n extends x {
|
|
|
3613
3645
|
}
|
|
3614
3646
|
// #endregion
|
|
3615
3647
|
// #region Styles
|
|
3616
|
-
styles =
|
|
3648
|
+
styles = en;
|
|
3617
3649
|
// #endregion
|
|
3618
3650
|
}
|
|
3619
|
-
function q(
|
|
3620
|
-
return Math.floor(
|
|
3651
|
+
function q(s, e) {
|
|
3652
|
+
return Math.floor(s / e);
|
|
3621
3653
|
}
|
|
3622
|
-
function
|
|
3654
|
+
function nn(s, e) {
|
|
3623
3655
|
return {
|
|
3624
|
-
start:
|
|
3625
|
-
end: (
|
|
3656
|
+
start: s * e,
|
|
3657
|
+
end: (s + 1) * e
|
|
3626
3658
|
};
|
|
3627
3659
|
}
|
|
3628
|
-
function
|
|
3629
|
-
const n = q(
|
|
3630
|
-
for (let
|
|
3631
|
-
i.push(
|
|
3660
|
+
function on(s, e, t) {
|
|
3661
|
+
const n = q(s, t), o = q(e - 1, t), i = [];
|
|
3662
|
+
for (let r = n; r <= o; r++)
|
|
3663
|
+
i.push(r);
|
|
3632
3664
|
return i;
|
|
3633
3665
|
}
|
|
3634
|
-
async function
|
|
3635
|
-
const o =
|
|
3636
|
-
return
|
|
3666
|
+
async function Le(s, e, t, n) {
|
|
3667
|
+
const o = nn(e, t);
|
|
3668
|
+
return s.getRows({
|
|
3637
3669
|
startRow: o.start,
|
|
3638
3670
|
endRow: o.end,
|
|
3639
3671
|
sortModel: n.sortModel,
|
|
3640
3672
|
filterModel: n.filterModel
|
|
3641
3673
|
});
|
|
3642
3674
|
}
|
|
3643
|
-
function
|
|
3644
|
-
const n = q(
|
|
3675
|
+
function rn(s, e, t) {
|
|
3676
|
+
const n = q(s, e), o = t.get(n);
|
|
3645
3677
|
if (!o) return;
|
|
3646
|
-
const i =
|
|
3678
|
+
const i = s % e;
|
|
3647
3679
|
return o[i];
|
|
3648
3680
|
}
|
|
3649
|
-
const
|
|
3650
|
-
class
|
|
3681
|
+
const sn = 100;
|
|
3682
|
+
class Ln extends y {
|
|
3651
3683
|
name = "serverSide";
|
|
3652
3684
|
version = "1.0.0";
|
|
3653
3685
|
get defaultConfig() {
|
|
@@ -3676,13 +3708,13 @@ class In extends x {
|
|
|
3676
3708
|
*/
|
|
3677
3709
|
loadRequiredBlocks() {
|
|
3678
3710
|
if (!this.dataSource) return;
|
|
3679
|
-
const e = this.grid, t = this.config.cacheBlockSize ?? 100, n = { startRow: e.
|
|
3711
|
+
const e = this.grid, t = this.config.cacheBlockSize ?? 100, n = { startRow: e._virtualization.start, endRow: e._virtualization.end }, o = on(n.startRow, n.endRow, t);
|
|
3680
3712
|
for (const i of o)
|
|
3681
3713
|
if (!(this.loadedBlocks.has(i) || this.loadingBlocks.has(i))) {
|
|
3682
3714
|
if (this.loadingBlocks.size >= (this.config.maxConcurrentRequests ?? 2))
|
|
3683
3715
|
break;
|
|
3684
|
-
this.loadingBlocks.add(i),
|
|
3685
|
-
this.loadedBlocks.set(i,
|
|
3716
|
+
this.loadingBlocks.add(i), Le(this.dataSource, i, t, {}).then((r) => {
|
|
3717
|
+
this.loadedBlocks.set(i, r.rows), this.totalRowCount = r.totalRowCount, this.loadingBlocks.delete(i), this.requestRender(), this.loadRequiredBlocks();
|
|
3686
3718
|
}).catch(() => {
|
|
3687
3719
|
this.loadingBlocks.delete(i);
|
|
3688
3720
|
});
|
|
@@ -3694,7 +3726,7 @@ class In extends x {
|
|
|
3694
3726
|
if (!this.dataSource) return [...e];
|
|
3695
3727
|
const t = [];
|
|
3696
3728
|
for (let n = 0; n < this.totalRowCount; n++) {
|
|
3697
|
-
const o =
|
|
3729
|
+
const o = rn(n, this.config.cacheBlockSize ?? 100, this.loadedBlocks);
|
|
3698
3730
|
t.push(o ?? { __loading: !0, __index: n });
|
|
3699
3731
|
}
|
|
3700
3732
|
return t;
|
|
@@ -3702,7 +3734,7 @@ class In extends x {
|
|
|
3702
3734
|
onScroll(e) {
|
|
3703
3735
|
this.dataSource && (this.loadRequiredBlocks(), this.scrollDebounceTimer && clearTimeout(this.scrollDebounceTimer), this.scrollDebounceTimer = setTimeout(() => {
|
|
3704
3736
|
this.loadRequiredBlocks();
|
|
3705
|
-
},
|
|
3737
|
+
}, sn));
|
|
3706
3738
|
}
|
|
3707
3739
|
// #endregion
|
|
3708
3740
|
// #region Public API
|
|
@@ -3713,7 +3745,7 @@ class In extends x {
|
|
|
3713
3745
|
setDataSource(e) {
|
|
3714
3746
|
this.dataSource = e, this.loadedBlocks.clear(), this.loadingBlocks.clear();
|
|
3715
3747
|
const t = this.config.cacheBlockSize ?? 100;
|
|
3716
|
-
|
|
3748
|
+
Le(e, 0, t, {}).then((n) => {
|
|
3717
3749
|
this.loadedBlocks.set(0, n.rows), this.totalRowCount = n.totalRowCount, this.requestRender();
|
|
3718
3750
|
});
|
|
3719
3751
|
}
|
|
@@ -3751,14 +3783,14 @@ class In extends x {
|
|
|
3751
3783
|
}
|
|
3752
3784
|
// #endregion
|
|
3753
3785
|
}
|
|
3754
|
-
function ne(
|
|
3755
|
-
return
|
|
3786
|
+
function ne(s, e, t) {
|
|
3787
|
+
return s.id !== void 0 ? String(s.id) : t ? `${t}-${e}` : String(e);
|
|
3756
3788
|
}
|
|
3757
|
-
function De(
|
|
3758
|
-
const i = e.childrenField ?? "children",
|
|
3759
|
-
for (let l = 0; l <
|
|
3760
|
-
const a =
|
|
3761
|
-
if (
|
|
3789
|
+
function De(s, e, t, n = null, o = 0) {
|
|
3790
|
+
const i = e.childrenField ?? "children", r = [];
|
|
3791
|
+
for (let l = 0; l < s.length; l++) {
|
|
3792
|
+
const a = s[l], d = ne(a, l, n), c = a[i], u = Array.isArray(c) && c.length > 0, h = t.has(d);
|
|
3793
|
+
if (r.push({
|
|
3762
3794
|
key: d,
|
|
3763
3795
|
data: a,
|
|
3764
3796
|
depth: o,
|
|
@@ -3767,19 +3799,19 @@ function De(r, e, t, n = null, o = 0) {
|
|
|
3767
3799
|
parentKey: n
|
|
3768
3800
|
}), u && h) {
|
|
3769
3801
|
const g = De(c, e, t, d, o + 1);
|
|
3770
|
-
|
|
3802
|
+
r.push(...g);
|
|
3771
3803
|
}
|
|
3772
3804
|
}
|
|
3773
|
-
return
|
|
3805
|
+
return r;
|
|
3774
3806
|
}
|
|
3775
|
-
function
|
|
3776
|
-
const t = new Set(
|
|
3807
|
+
function Te(s, e) {
|
|
3808
|
+
const t = new Set(s);
|
|
3777
3809
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
3778
3810
|
}
|
|
3779
|
-
function J(
|
|
3811
|
+
function J(s, e, t = null, n = 0) {
|
|
3780
3812
|
const o = e.childrenField ?? "children", i = /* @__PURE__ */ new Set();
|
|
3781
|
-
for (let
|
|
3782
|
-
const l = r
|
|
3813
|
+
for (let r = 0; r < s.length; r++) {
|
|
3814
|
+
const l = s[r], a = ne(l, r, t), d = l[o];
|
|
3783
3815
|
if (Array.isArray(d) && d.length > 0) {
|
|
3784
3816
|
i.add(a);
|
|
3785
3817
|
const c = J(d, e, a, n + 1);
|
|
@@ -3788,43 +3820,43 @@ function J(r, e, t = null, n = 0) {
|
|
|
3788
3820
|
}
|
|
3789
3821
|
return i;
|
|
3790
3822
|
}
|
|
3791
|
-
function
|
|
3823
|
+
function ln() {
|
|
3792
3824
|
return /* @__PURE__ */ new Set();
|
|
3793
3825
|
}
|
|
3794
|
-
function
|
|
3826
|
+
function He(s, e, t, n = null, o = 0) {
|
|
3795
3827
|
const i = t.childrenField ?? "children";
|
|
3796
|
-
for (let
|
|
3797
|
-
const l = r
|
|
3828
|
+
for (let r = 0; r < s.length; r++) {
|
|
3829
|
+
const l = s[r], a = ne(l, r, n);
|
|
3798
3830
|
if (a === e)
|
|
3799
3831
|
return [a];
|
|
3800
3832
|
const d = l[i];
|
|
3801
3833
|
if (Array.isArray(d) && d.length > 0) {
|
|
3802
|
-
const c =
|
|
3834
|
+
const c = He(d, e, t, a, o + 1);
|
|
3803
3835
|
if (c)
|
|
3804
3836
|
return [a, ...c];
|
|
3805
3837
|
}
|
|
3806
3838
|
}
|
|
3807
3839
|
return null;
|
|
3808
3840
|
}
|
|
3809
|
-
function
|
|
3810
|
-
const o =
|
|
3841
|
+
function an(s, e, t, n) {
|
|
3842
|
+
const o = He(s, e, t);
|
|
3811
3843
|
if (!o) return n;
|
|
3812
3844
|
const i = new Set(n);
|
|
3813
|
-
for (let
|
|
3814
|
-
i.add(o[
|
|
3845
|
+
for (let r = 0; r < o.length - 1; r++)
|
|
3846
|
+
i.add(o[r]);
|
|
3815
3847
|
return i;
|
|
3816
3848
|
}
|
|
3817
|
-
function Fe(
|
|
3818
|
-
if (!Array.isArray(
|
|
3819
|
-
for (const t of
|
|
3849
|
+
function Fe(s, e = "children") {
|
|
3850
|
+
if (!Array.isArray(s) || s.length === 0) return !1;
|
|
3851
|
+
for (const t of s)
|
|
3820
3852
|
if (t && Array.isArray(t[e]) && t[e].length > 0)
|
|
3821
3853
|
return !0;
|
|
3822
3854
|
return !1;
|
|
3823
3855
|
}
|
|
3824
|
-
function
|
|
3825
|
-
if (!Array.isArray(
|
|
3856
|
+
function dn(s) {
|
|
3857
|
+
if (!Array.isArray(s) || s.length === 0) return null;
|
|
3826
3858
|
const e = ["children", "items", "nodes", "subRows", "nested"];
|
|
3827
|
-
for (const t of
|
|
3859
|
+
for (const t of s)
|
|
3828
3860
|
if (!(!t || typeof t != "object")) {
|
|
3829
3861
|
for (const n of e)
|
|
3830
3862
|
if (Array.isArray(t[n]) && t[n].length > 0)
|
|
@@ -3832,8 +3864,8 @@ function an(r) {
|
|
|
3832
3864
|
}
|
|
3833
3865
|
return null;
|
|
3834
3866
|
}
|
|
3835
|
-
const
|
|
3836
|
-
class
|
|
3867
|
+
const cn = ".tree-toggle{cursor:pointer;user-select:none;transition:transform .2s}.tree-toggle:hover{color:var(--tbw-tree-accent, var(--tbw-color-accent))}";
|
|
3868
|
+
class Tn extends y {
|
|
3837
3869
|
name = "tree";
|
|
3838
3870
|
version = "1.0.0";
|
|
3839
3871
|
get defaultConfig() {
|
|
@@ -3867,7 +3899,7 @@ class Ln extends x {
|
|
|
3867
3899
|
*/
|
|
3868
3900
|
detect(e) {
|
|
3869
3901
|
if (!this.config.autoDetect) return !1;
|
|
3870
|
-
const t = this.config.childrenField ??
|
|
3902
|
+
const t = this.config.childrenField ?? dn(e) ?? "children";
|
|
3871
3903
|
return Fe(e, t);
|
|
3872
3904
|
}
|
|
3873
3905
|
// #endregion
|
|
@@ -3889,31 +3921,31 @@ class Ln extends x {
|
|
|
3889
3921
|
}
|
|
3890
3922
|
processColumns(e) {
|
|
3891
3923
|
if (this.flattenedRows.length === 0) return [...e];
|
|
3892
|
-
const t =
|
|
3893
|
-
if (
|
|
3894
|
-
const
|
|
3895
|
-
if (
|
|
3896
|
-
return
|
|
3897
|
-
const
|
|
3898
|
-
const { value:
|
|
3899
|
-
if (
|
|
3900
|
-
const
|
|
3901
|
-
|
|
3902
|
-
} else if (
|
|
3903
|
-
const
|
|
3904
|
-
|
|
3924
|
+
const t = [...e];
|
|
3925
|
+
if (t.length > 0) {
|
|
3926
|
+
const n = { ...t[0] }, o = n.viewRenderer;
|
|
3927
|
+
if (o?.__treeWrapped)
|
|
3928
|
+
return t;
|
|
3929
|
+
const i = () => this.config, r = (l) => {
|
|
3930
|
+
const { value: a, row: d, column: c } = l, u = d.__treeDepth ?? 0, h = d.__treeHasChildren ?? !1, g = d.__treeExpanded ?? !1, p = i(), m = p.indentWidth ?? 20, f = p.showExpandIcons ?? !0, b = document.createElement("span");
|
|
3931
|
+
if (b.style.display = "flex", b.style.alignItems = "center", b.style.paddingLeft = `${u * m}px`, h && f) {
|
|
3932
|
+
const v = document.createElement("span");
|
|
3933
|
+
v.className = "tree-toggle", this.setIcon(v, this.resolveIcon(g ? "collapse" : "expand")), v.style.cursor = "pointer", v.style.marginRight = "4px", v.style.fontSize = "10px", v.setAttribute("data-tree-key", d.__treeKey), b.appendChild(v);
|
|
3934
|
+
} else if (f) {
|
|
3935
|
+
const v = document.createElement("span");
|
|
3936
|
+
v.style.width = "14px", v.style.display = "inline-block", b.appendChild(v);
|
|
3905
3937
|
}
|
|
3906
|
-
const
|
|
3907
|
-
if (
|
|
3908
|
-
const
|
|
3909
|
-
|
|
3938
|
+
const E = document.createElement("span");
|
|
3939
|
+
if (o) {
|
|
3940
|
+
const v = o(l);
|
|
3941
|
+
v instanceof Node ? E.appendChild(v) : E.textContent = String(v ?? a ?? "");
|
|
3910
3942
|
} else
|
|
3911
|
-
|
|
3912
|
-
return
|
|
3943
|
+
E.textContent = String(a ?? "");
|
|
3944
|
+
return b.appendChild(E), b;
|
|
3913
3945
|
};
|
|
3914
|
-
|
|
3946
|
+
r.__treeWrapped = !0, n.viewRenderer = r, t[0] = n;
|
|
3915
3947
|
}
|
|
3916
|
-
return
|
|
3948
|
+
return t;
|
|
3917
3949
|
}
|
|
3918
3950
|
// #endregion
|
|
3919
3951
|
// #region Event Handlers
|
|
@@ -3923,7 +3955,7 @@ class Ln extends x {
|
|
|
3923
3955
|
const n = t.getAttribute("data-tree-key");
|
|
3924
3956
|
if (!n) return !1;
|
|
3925
3957
|
const o = this.rowKeyMap.get(n);
|
|
3926
|
-
return o ? (this.expandedKeys =
|
|
3958
|
+
return o ? (this.expandedKeys = Te(this.expandedKeys, n), this.emit("tree-expand", {
|
|
3927
3959
|
key: n,
|
|
3928
3960
|
row: o.data,
|
|
3929
3961
|
expanded: this.expandedKeys.has(n),
|
|
@@ -3948,7 +3980,7 @@ class Ln extends x {
|
|
|
3948
3980
|
* Toggle the expansion state of a node.
|
|
3949
3981
|
*/
|
|
3950
3982
|
toggle(e) {
|
|
3951
|
-
this.expandedKeys =
|
|
3983
|
+
this.expandedKeys = Te(this.expandedKeys, e), this.requestRender();
|
|
3952
3984
|
}
|
|
3953
3985
|
/**
|
|
3954
3986
|
* Expand all nodes in the tree.
|
|
@@ -3960,7 +3992,7 @@ class Ln extends x {
|
|
|
3960
3992
|
* Collapse all nodes in the tree.
|
|
3961
3993
|
*/
|
|
3962
3994
|
collapseAll() {
|
|
3963
|
-
this.expandedKeys =
|
|
3995
|
+
this.expandedKeys = ln(), this.requestRender();
|
|
3964
3996
|
}
|
|
3965
3997
|
/**
|
|
3966
3998
|
* Check if a node is currently expanded.
|
|
@@ -3990,15 +4022,15 @@ class Ln extends x {
|
|
|
3990
4022
|
* Expand all ancestors of a node to make it visible.
|
|
3991
4023
|
*/
|
|
3992
4024
|
expandToKey(e) {
|
|
3993
|
-
this.expandedKeys =
|
|
4025
|
+
this.expandedKeys = an(this.rows, e, this.config, this.expandedKeys), this.requestRender();
|
|
3994
4026
|
}
|
|
3995
4027
|
// #endregion
|
|
3996
4028
|
// #region Styles
|
|
3997
|
-
styles =
|
|
4029
|
+
styles = cn;
|
|
3998
4030
|
// #endregion
|
|
3999
4031
|
}
|
|
4000
|
-
function
|
|
4001
|
-
const n = [...
|
|
4032
|
+
function un(s, e, t) {
|
|
4033
|
+
const n = [...s.undoStack, e];
|
|
4002
4034
|
for (; n.length > t; )
|
|
4003
4035
|
n.shift();
|
|
4004
4036
|
return {
|
|
@@ -4007,50 +4039,50 @@ function cn(r, e, t) {
|
|
|
4007
4039
|
// Clear redo on new action
|
|
4008
4040
|
};
|
|
4009
4041
|
}
|
|
4010
|
-
function
|
|
4011
|
-
if (
|
|
4012
|
-
return { newState:
|
|
4013
|
-
const e = [...
|
|
4042
|
+
function Me(s) {
|
|
4043
|
+
if (s.undoStack.length === 0)
|
|
4044
|
+
return { newState: s, action: null };
|
|
4045
|
+
const e = [...s.undoStack], t = e.pop();
|
|
4014
4046
|
return t ? {
|
|
4015
4047
|
newState: {
|
|
4016
4048
|
undoStack: e,
|
|
4017
|
-
redoStack: [...
|
|
4049
|
+
redoStack: [...s.redoStack, t]
|
|
4018
4050
|
},
|
|
4019
4051
|
action: t
|
|
4020
|
-
} : { newState:
|
|
4052
|
+
} : { newState: s, action: null };
|
|
4021
4053
|
}
|
|
4022
|
-
function
|
|
4023
|
-
if (
|
|
4024
|
-
return { newState:
|
|
4025
|
-
const e = [...
|
|
4054
|
+
function Ne(s) {
|
|
4055
|
+
if (s.redoStack.length === 0)
|
|
4056
|
+
return { newState: s, action: null };
|
|
4057
|
+
const e = [...s.redoStack], t = e.pop();
|
|
4026
4058
|
return t ? {
|
|
4027
4059
|
newState: {
|
|
4028
|
-
undoStack: [...
|
|
4060
|
+
undoStack: [...s.undoStack, t],
|
|
4029
4061
|
redoStack: e
|
|
4030
4062
|
},
|
|
4031
4063
|
action: t
|
|
4032
|
-
} : { newState:
|
|
4064
|
+
} : { newState: s, action: null };
|
|
4033
4065
|
}
|
|
4034
|
-
function
|
|
4035
|
-
return
|
|
4066
|
+
function hn(s) {
|
|
4067
|
+
return s.undoStack.length > 0;
|
|
4036
4068
|
}
|
|
4037
|
-
function
|
|
4038
|
-
return
|
|
4069
|
+
function gn(s) {
|
|
4070
|
+
return s.redoStack.length > 0;
|
|
4039
4071
|
}
|
|
4040
|
-
function
|
|
4072
|
+
function pn() {
|
|
4041
4073
|
return { undoStack: [], redoStack: [] };
|
|
4042
4074
|
}
|
|
4043
|
-
function
|
|
4075
|
+
function fn(s, e, t, n) {
|
|
4044
4076
|
return {
|
|
4045
4077
|
type: "cell-edit",
|
|
4046
|
-
rowIndex:
|
|
4078
|
+
rowIndex: s,
|
|
4047
4079
|
field: e,
|
|
4048
4080
|
oldValue: t,
|
|
4049
4081
|
newValue: n,
|
|
4050
4082
|
timestamp: Date.now()
|
|
4051
4083
|
};
|
|
4052
4084
|
}
|
|
4053
|
-
class Fn extends
|
|
4085
|
+
class Fn extends y {
|
|
4054
4086
|
name = "undoRedo";
|
|
4055
4087
|
version = "1.0.0";
|
|
4056
4088
|
get defaultConfig() {
|
|
@@ -4075,7 +4107,7 @@ class Fn extends x {
|
|
|
4075
4107
|
onKeyDown(e) {
|
|
4076
4108
|
const t = (e.ctrlKey || e.metaKey) && e.key === "z" && !e.shiftKey, n = (e.ctrlKey || e.metaKey) && (e.key === "y" || e.key === "z" && e.shiftKey);
|
|
4077
4109
|
if (t) {
|
|
4078
|
-
const o =
|
|
4110
|
+
const o = Me({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4079
4111
|
if (o.action) {
|
|
4080
4112
|
const i = this.rows;
|
|
4081
4113
|
i[o.action.rowIndex] && (i[o.action.rowIndex][o.action.field] = o.action.oldValue), this.undoStack = o.newState.undoStack, this.redoStack = o.newState.redoStack, this.emit("undo", {
|
|
@@ -4086,7 +4118,7 @@ class Fn extends x {
|
|
|
4086
4118
|
return !0;
|
|
4087
4119
|
}
|
|
4088
4120
|
if (n) {
|
|
4089
|
-
const o =
|
|
4121
|
+
const o = Ne({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4090
4122
|
if (o.action) {
|
|
4091
4123
|
const i = this.rows;
|
|
4092
4124
|
i[o.action.rowIndex] && (i[o.action.rowIndex][o.action.field] = o.action.newValue), this.undoStack = o.newState.undoStack, this.redoStack = o.newState.redoStack, this.emit("redo", {
|
|
@@ -4109,12 +4141,12 @@ class Fn extends x {
|
|
|
4109
4141
|
* @param newValue - The value after the edit
|
|
4110
4142
|
*/
|
|
4111
4143
|
recordEdit(e, t, n, o) {
|
|
4112
|
-
const i =
|
|
4144
|
+
const i = fn(e, t, n, o), r = un(
|
|
4113
4145
|
{ undoStack: this.undoStack, redoStack: this.redoStack },
|
|
4114
4146
|
i,
|
|
4115
4147
|
this.config.maxHistorySize ?? 100
|
|
4116
4148
|
);
|
|
4117
|
-
this.undoStack =
|
|
4149
|
+
this.undoStack = r.undoStack, this.redoStack = r.redoStack;
|
|
4118
4150
|
}
|
|
4119
4151
|
/**
|
|
4120
4152
|
* Programmatically undo the last action.
|
|
@@ -4122,7 +4154,7 @@ class Fn extends x {
|
|
|
4122
4154
|
* @returns The undone action, or null if nothing to undo
|
|
4123
4155
|
*/
|
|
4124
4156
|
undo() {
|
|
4125
|
-
const e =
|
|
4157
|
+
const e = Me({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4126
4158
|
if (e.action) {
|
|
4127
4159
|
const t = this.rows;
|
|
4128
4160
|
t[e.action.rowIndex] && (t[e.action.rowIndex][e.action.field] = e.action.oldValue), this.undoStack = e.newState.undoStack, this.redoStack = e.newState.redoStack, this.requestRender();
|
|
@@ -4135,7 +4167,7 @@ class Fn extends x {
|
|
|
4135
4167
|
* @returns The redone action, or null if nothing to redo
|
|
4136
4168
|
*/
|
|
4137
4169
|
redo() {
|
|
4138
|
-
const e =
|
|
4170
|
+
const e = Ne({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4139
4171
|
if (e.action) {
|
|
4140
4172
|
const t = this.rows;
|
|
4141
4173
|
t[e.action.rowIndex] && (t[e.action.rowIndex][e.action.field] = e.action.newValue), this.undoStack = e.newState.undoStack, this.redoStack = e.newState.redoStack, this.requestRender();
|
|
@@ -4146,19 +4178,19 @@ class Fn extends x {
|
|
|
4146
4178
|
* Check if there are any actions that can be undone.
|
|
4147
4179
|
*/
|
|
4148
4180
|
canUndo() {
|
|
4149
|
-
return
|
|
4181
|
+
return hn({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4150
4182
|
}
|
|
4151
4183
|
/**
|
|
4152
4184
|
* Check if there are any actions that can be redone.
|
|
4153
4185
|
*/
|
|
4154
4186
|
canRedo() {
|
|
4155
|
-
return
|
|
4187
|
+
return gn({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
4156
4188
|
}
|
|
4157
4189
|
/**
|
|
4158
4190
|
* Clear all undo/redo history.
|
|
4159
4191
|
*/
|
|
4160
4192
|
clearHistory() {
|
|
4161
|
-
const e =
|
|
4193
|
+
const e = pn();
|
|
4162
4194
|
this.undoStack = e.undoStack, this.redoStack = e.redoStack;
|
|
4163
4195
|
}
|
|
4164
4196
|
/**
|
|
@@ -4175,12 +4207,12 @@ class Fn extends x {
|
|
|
4175
4207
|
}
|
|
4176
4208
|
// #endregion
|
|
4177
4209
|
}
|
|
4178
|
-
const
|
|
4179
|
-
function
|
|
4180
|
-
const e =
|
|
4210
|
+
const mn = '.tbw-visibility-content{display:flex;flex-direction:column;height:100%}.tbw-visibility-list{flex:1;overflow-y:auto;padding:8px}.tbw-visibility-row{display:flex;align-items:center;gap:8px;padding:6px 4px;cursor:pointer;font-size:13px;border-radius:var(--tbw-border-radius, 4px);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:10px;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:8px;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:8px;padding:8px 12px;border:1px solid var(--tbw-visibility-border, var(--tbw-color-border, #e5e7eb));border-radius:var(--tbw-border-radius, 4px);background:var(--tbw-visibility-btn-bg, var(--tbw-color-header-bg, #f9fafb));color:var(--tbw-color-fg, #1f2937);cursor:pointer;font-size:13px}.tbw-visibility-show-all:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}';
|
|
4211
|
+
function Pe(s) {
|
|
4212
|
+
const e = s.meta ?? {};
|
|
4181
4213
|
return e.lockPosition !== !0 && e.suppressMovable !== !0;
|
|
4182
4214
|
}
|
|
4183
|
-
class
|
|
4215
|
+
class M extends y {
|
|
4184
4216
|
name = "visibility";
|
|
4185
4217
|
version = "1.0.0";
|
|
4186
4218
|
/** Tool panel ID for shell integration */
|
|
@@ -4209,7 +4241,7 @@ class T extends x {
|
|
|
4209
4241
|
*/
|
|
4210
4242
|
getToolPanel() {
|
|
4211
4243
|
return {
|
|
4212
|
-
id:
|
|
4244
|
+
id: M.PANEL_ID,
|
|
4213
4245
|
title: "Columns",
|
|
4214
4246
|
icon: "☰",
|
|
4215
4247
|
tooltip: "Column visibility",
|
|
@@ -4224,7 +4256,7 @@ class T extends x {
|
|
|
4224
4256
|
* Show the visibility sidebar panel.
|
|
4225
4257
|
*/
|
|
4226
4258
|
show() {
|
|
4227
|
-
this.grid.openToolPanel(
|
|
4259
|
+
this.grid.openToolPanel(M.PANEL_ID);
|
|
4228
4260
|
}
|
|
4229
4261
|
/**
|
|
4230
4262
|
* Hide the visibility sidebar panel.
|
|
@@ -4236,7 +4268,7 @@ class T extends x {
|
|
|
4236
4268
|
* Toggle the visibility sidebar panel.
|
|
4237
4269
|
*/
|
|
4238
4270
|
toggle() {
|
|
4239
|
-
this.grid.toggleToolPanel(
|
|
4271
|
+
this.grid.toggleToolPanel(M.PANEL_ID);
|
|
4240
4272
|
}
|
|
4241
4273
|
/**
|
|
4242
4274
|
* Check if a specific column is visible.
|
|
@@ -4314,7 +4346,7 @@ class T extends x {
|
|
|
4314
4346
|
* @returns True if the panel is open
|
|
4315
4347
|
*/
|
|
4316
4348
|
isPanelVisible() {
|
|
4317
|
-
return this.grid.activeToolPanel ===
|
|
4349
|
+
return this.grid.activeToolPanel === M.PANEL_ID;
|
|
4318
4350
|
}
|
|
4319
4351
|
// #endregion
|
|
4320
4352
|
// #region Private Methods
|
|
@@ -4350,16 +4382,16 @@ class T extends x {
|
|
|
4350
4382
|
e.innerHTML = "";
|
|
4351
4383
|
const o = t.getAllColumns();
|
|
4352
4384
|
for (let i = 0; i < o.length; i++) {
|
|
4353
|
-
const
|
|
4354
|
-
a.className =
|
|
4385
|
+
const r = o[i], l = r.header || r.field, a = document.createElement("div");
|
|
4386
|
+
a.className = r.lockVisible ? "tbw-visibility-row locked" : "tbw-visibility-row", a.setAttribute("data-field", r.field), a.setAttribute("data-index", String(i)), n && Pe(r) && (a.draggable = !0, a.classList.add("reorderable"), this.setupDragListeners(a, r.field, i, e));
|
|
4355
4387
|
const d = document.createElement("label");
|
|
4356
4388
|
d.className = "tbw-visibility-label";
|
|
4357
4389
|
const c = document.createElement("input");
|
|
4358
|
-
c.type = "checkbox", c.checked =
|
|
4359
|
-
t.toggleColumnVisibility(
|
|
4390
|
+
c.type = "checkbox", c.checked = r.visible, c.disabled = r.lockVisible ?? !1, c.addEventListener("change", () => {
|
|
4391
|
+
t.toggleColumnVisibility(r.field), setTimeout(() => this.rebuildToggles(e), 0);
|
|
4360
4392
|
});
|
|
4361
4393
|
const u = document.createElement("span");
|
|
4362
|
-
if (u.textContent = l, d.appendChild(c), d.appendChild(u), n &&
|
|
4394
|
+
if (u.textContent = l, d.appendChild(c), d.appendChild(u), n && Pe(r)) {
|
|
4363
4395
|
const h = document.createElement("span");
|
|
4364
4396
|
h.className = "tbw-visibility-handle", this.setIcon(h, this.resolveIcon("dragHandle")), h.title = "Drag to reorder", a.appendChild(h);
|
|
4365
4397
|
}
|
|
@@ -4379,7 +4411,7 @@ class T extends x {
|
|
|
4379
4411
|
});
|
|
4380
4412
|
}), e.addEventListener("dragover", (i) => {
|
|
4381
4413
|
if (i.preventDefault(), !this.isDragging || this.draggedField === t) return;
|
|
4382
|
-
const
|
|
4414
|
+
const r = e.getBoundingClientRect(), l = r.top + r.height / 2;
|
|
4383
4415
|
this.dropIndex = i.clientY < l ? n : n + 1, o.querySelectorAll(".tbw-visibility-row").forEach((a) => {
|
|
4384
4416
|
a !== e && a.classList.remove("drop-target", "drop-before", "drop-after");
|
|
4385
4417
|
}), e.classList.add("drop-target"), e.classList.toggle("drop-before", i.clientY < l), e.classList.toggle("drop-after", i.clientY >= l);
|
|
@@ -4387,13 +4419,13 @@ class T extends x {
|
|
|
4387
4419
|
e.classList.remove("drop-target", "drop-before", "drop-after");
|
|
4388
4420
|
}), e.addEventListener("drop", (i) => {
|
|
4389
4421
|
i.preventDefault();
|
|
4390
|
-
const
|
|
4391
|
-
if (!this.isDragging ||
|
|
4422
|
+
const r = this.draggedField, l = this.draggedIndex, a = this.dropIndex;
|
|
4423
|
+
if (!this.isDragging || r === null || l === null || a === null)
|
|
4392
4424
|
return;
|
|
4393
4425
|
const d = a > l ? a - 1 : a;
|
|
4394
4426
|
if (d !== l) {
|
|
4395
4427
|
const c = {
|
|
4396
|
-
field:
|
|
4428
|
+
field: r,
|
|
4397
4429
|
fromIndex: l,
|
|
4398
4430
|
toIndex: d
|
|
4399
4431
|
};
|
|
@@ -4405,48 +4437,48 @@ class T extends x {
|
|
|
4405
4437
|
}
|
|
4406
4438
|
// #endregion
|
|
4407
4439
|
// #region Styles
|
|
4408
|
-
styles =
|
|
4440
|
+
styles = mn;
|
|
4409
4441
|
// #endregion
|
|
4410
4442
|
}
|
|
4411
4443
|
export {
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4444
|
+
y as BaseGridPlugin,
|
|
4445
|
+
bn as ClipboardPlugin,
|
|
4446
|
+
vn as ColumnVirtualizationPlugin,
|
|
4447
|
+
xn as ContextMenuPlugin,
|
|
4448
|
+
Ge as DEFAULT_GRID_ICONS,
|
|
4449
|
+
Pn as DGEvents,
|
|
4450
|
+
Kn as DataGridElement,
|
|
4451
|
+
yn as ExportPlugin,
|
|
4452
|
+
_ as FilteringPlugin,
|
|
4421
4453
|
qn as FitModeEnum,
|
|
4422
4454
|
Dn as GridCSSVars,
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
|
|
4428
|
-
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4455
|
+
Hn as GridClasses,
|
|
4456
|
+
Gn as GridDataAttrs,
|
|
4457
|
+
On as GridElement,
|
|
4458
|
+
Bn as GridSelectors,
|
|
4459
|
+
Cn as GroupingColumnsPlugin,
|
|
4460
|
+
Rn as GroupingRowsPlugin,
|
|
4461
|
+
Sn as MasterDetailPlugin,
|
|
4462
|
+
En as MultiSortPlugin,
|
|
4463
|
+
Ke as PLUGIN_QUERIES,
|
|
4464
|
+
kn as PinnedColumnsPlugin,
|
|
4465
|
+
An as PinnedRowsPlugin,
|
|
4434
4466
|
F as PivotPlugin,
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4467
|
+
Vn as PluginEvents,
|
|
4468
|
+
zn as PluginManager,
|
|
4469
|
+
_n as ReorderPlugin,
|
|
4470
|
+
In as SelectionPlugin,
|
|
4471
|
+
Ln as ServerSidePlugin,
|
|
4472
|
+
Tn as TreePlugin,
|
|
4441
4473
|
Fn as UndoRedoPlugin,
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4474
|
+
M as VisibilityPlugin,
|
|
4475
|
+
Wn as aggregatorRegistry,
|
|
4476
|
+
le as getAggregator,
|
|
4445
4477
|
Oe as getValueAggregator,
|
|
4446
|
-
|
|
4447
|
-
|
|
4478
|
+
$n as listAggregators,
|
|
4479
|
+
jn as registerAggregator,
|
|
4448
4480
|
se as runAggregator,
|
|
4449
|
-
|
|
4450
|
-
|
|
4481
|
+
Un as runValueAggregator,
|
|
4482
|
+
Yn as unregisterAggregator
|
|
4451
4483
|
};
|
|
4452
4484
|
//# sourceMappingURL=all.js.map
|