@toolbox-web/grid 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -0
- package/all.d.ts +1680 -129
- package/all.js +440 -340
- package/all.js.map +1 -1
- package/custom-elements.json +1852 -0
- package/index.d.ts +133 -1
- package/index.js +726 -637
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js +62 -24
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +82 -44
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +141 -93
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js +47 -9
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +89 -51
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +71 -33
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +91 -55
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +176 -54
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +83 -45
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +54 -16
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +45 -7
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +97 -59
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +71 -33
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +132 -94
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +76 -38
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +76 -38
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +50 -12
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +62 -24
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +31 -31
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +14 -14
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js +2 -2
- package/umd/plugins/context-menu.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +2 -2
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +2 -2
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +2 -2
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
package/all.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseGridPlugin as y, runAggregator as X, getAggregator as
|
|
2
|
-
import { DGEvents as Pt, DataGridElement as
|
|
3
|
-
function
|
|
1
|
+
import { BaseGridPlugin as y, DEFAULT_GRID_ICONS as xe, runAggregator as X, getAggregator as ve } from "./index.js";
|
|
2
|
+
import { DGEvents as Pt, DataGridElement as Bt, FitModeEnum as Ht, GridCSSVars as Ot, GridClasses as Wt, GridDataAttrs as Vt, DataGridElement as Kt, GridSelectors as Gt, PluginEvents as zt, PluginManager as $t, SelectionPlugin as jt, TreePlugin as Ut, aggregatorRegistry as Yt, listAggregators as Xt, registerAggregator as Jt, unregisterAggregator as Qt } from "./index.js";
|
|
3
|
+
function ye(i, e, t, n) {
|
|
4
4
|
if (n.processCell)
|
|
5
5
|
return n.processCell(i, e, t);
|
|
6
6
|
if (i == null) return "";
|
|
@@ -20,12 +20,12 @@ function F(i) {
|
|
|
20
20
|
});
|
|
21
21
|
a.push(u.join(r));
|
|
22
22
|
}
|
|
23
|
-
const
|
|
24
|
-
for (const u of
|
|
23
|
+
const c = [...n instanceof Set ? [...n] : n].sort((u, h) => u - h);
|
|
24
|
+
for (const u of c) {
|
|
25
25
|
const h = e[u];
|
|
26
26
|
if (!h) continue;
|
|
27
27
|
const f = l.map(
|
|
28
|
-
(g) =>
|
|
28
|
+
(g) => ye(h[g.field], g.field, h, o)
|
|
29
29
|
);
|
|
30
30
|
a.push(f.join(r));
|
|
31
31
|
}
|
|
@@ -47,11 +47,11 @@ function J(i, e) {
|
|
|
47
47
|
`).replace(/\r/g, `
|
|
48
48
|
`), r = [];
|
|
49
49
|
let s = [], l = "", a = !1;
|
|
50
|
-
for (let
|
|
51
|
-
const
|
|
52
|
-
|
|
50
|
+
for (let d = 0; d < o.length; d++) {
|
|
51
|
+
const c = o[d];
|
|
52
|
+
c === '"' && !a ? a = !0 : c === '"' && a ? o[d + 1] === '"' ? (l += '"', d++) : a = !1 : c === t && !a ? (s.push(l), l = "") : c === n && !a ? (s.push(l), l = "", (s.length > 1 || s.some((u) => u.trim() !== "")) && r.push(s), s = []) : l += c;
|
|
53
53
|
}
|
|
54
|
-
return s.push(l), (s.length > 1 || s.some((
|
|
54
|
+
return s.push(l), (s.length > 1 || s.some((d) => d.trim() !== "")) && r.push(s), r;
|
|
55
55
|
}
|
|
56
56
|
async function Q() {
|
|
57
57
|
try {
|
|
@@ -60,7 +60,7 @@ async function Q() {
|
|
|
60
60
|
return "";
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
class
|
|
63
|
+
class yt extends y {
|
|
64
64
|
name = "clipboard";
|
|
65
65
|
version = "1.0.0";
|
|
66
66
|
get defaultConfig() {
|
|
@@ -84,22 +84,22 @@ class vt extends y {
|
|
|
84
84
|
onKeyDown(e) {
|
|
85
85
|
if (this.config.enabled === !1) return !1;
|
|
86
86
|
const t = (e.ctrlKey || e.metaKey) && e.key === "c", n = (e.ctrlKey || e.metaKey) && e.key === "v";
|
|
87
|
-
return t ? (this.#
|
|
87
|
+
return t ? (this.#e(e.target), !0) : n ? (this.#n(), !0) : !1;
|
|
88
88
|
}
|
|
89
89
|
// ===== Private Methods =====
|
|
90
90
|
/**
|
|
91
91
|
* Handle copy operation
|
|
92
92
|
*/
|
|
93
|
-
#
|
|
94
|
-
const t = this.#
|
|
95
|
-
let a,
|
|
93
|
+
#e(e) {
|
|
94
|
+
const t = this.#t(), n = t?.getSelectedRows() ?? [], o = n.length > 0, r = t?.getRanges() ?? [], s = r.length > 0, l = t?.getSelectedCell() != null;
|
|
95
|
+
let a, d, c;
|
|
96
96
|
if (o && t)
|
|
97
97
|
a = F({
|
|
98
98
|
rows: this.rows,
|
|
99
99
|
columns: [...this.columns],
|
|
100
100
|
selectedIndices: n,
|
|
101
101
|
config: this.config
|
|
102
|
-
}),
|
|
102
|
+
}), d = n.length, c = this.columns.filter((u) => !u.hidden && !u.field.startsWith("__")).length;
|
|
103
103
|
else if (s && t) {
|
|
104
104
|
const u = r[r.length - 1], h = this.#r({
|
|
105
105
|
startRow: u.from.row,
|
|
@@ -107,18 +107,18 @@ class vt extends y {
|
|
|
107
107
|
endRow: u.to.row,
|
|
108
108
|
endCol: u.to.col
|
|
109
109
|
});
|
|
110
|
-
a = h.text,
|
|
110
|
+
a = h.text, d = h.rowCount, c = h.columnCount;
|
|
111
111
|
} else if (l && t) {
|
|
112
112
|
const u = t.getSelectedCell(), h = this.#o(u.row, u.col);
|
|
113
113
|
if (!h) return;
|
|
114
|
-
a = h.text,
|
|
114
|
+
a = h.text, d = 1, c = 1;
|
|
115
115
|
} else {
|
|
116
116
|
const u = this.#i(e);
|
|
117
117
|
if (!u) return;
|
|
118
|
-
a = u.text,
|
|
118
|
+
a = u.text, d = 1, c = 1;
|
|
119
119
|
}
|
|
120
120
|
N(a).then(() => {
|
|
121
|
-
this.lastCopied = { text: a, timestamp: Date.now() }, this.emit("copy", { text: a, rowCount:
|
|
121
|
+
this.lastCopied = { text: a, timestamp: Date.now() }, this.emit("copy", { text: a, rowCount: d, columnCount: c });
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
@@ -134,7 +134,7 @@ class vt extends y {
|
|
|
134
134
|
/**
|
|
135
135
|
* Get the selection plugin instance if available.
|
|
136
136
|
*/
|
|
137
|
-
#
|
|
137
|
+
#t() {
|
|
138
138
|
try {
|
|
139
139
|
const e = this.grid;
|
|
140
140
|
if (e?._plugins) {
|
|
@@ -166,11 +166,11 @@ class vt extends y {
|
|
|
166
166
|
* Build text for a rectangular range of cells.
|
|
167
167
|
*/
|
|
168
168
|
#r(e) {
|
|
169
|
-
const { startRow: t, startCol: n, endRow: o, endCol: r } = e, s = Math.min(t, o), l = Math.max(t, o), a = Math.min(n, r),
|
|
170
|
-
`, h = [], f = this.columns.slice(a,
|
|
169
|
+
const { startRow: t, startCol: n, endRow: o, endCol: r } = e, s = Math.min(t, o), l = Math.max(t, o), a = Math.min(n, r), d = Math.max(n, r), c = this.config.delimiter ?? " ", u = this.config.newline ?? `
|
|
170
|
+
`, h = [], f = this.columns.slice(a, d + 1);
|
|
171
171
|
if (this.config.includeHeaders) {
|
|
172
172
|
const g = f.map((m) => m.header || m.field);
|
|
173
|
-
h.push(g.join(
|
|
173
|
+
h.push(g.join(c));
|
|
174
174
|
}
|
|
175
175
|
for (let g = s; g <= l; g++) {
|
|
176
176
|
const m = this.rows[g];
|
|
@@ -179,12 +179,12 @@ class vt extends y {
|
|
|
179
179
|
const R = m[S.field];
|
|
180
180
|
return R == null ? "" : R instanceof Date ? R.toISOString() : String(R);
|
|
181
181
|
});
|
|
182
|
-
h.push(b.join(
|
|
182
|
+
h.push(b.join(c));
|
|
183
183
|
}
|
|
184
184
|
return {
|
|
185
185
|
text: h.join(u),
|
|
186
186
|
rowCount: l - s + 1,
|
|
187
|
-
columnCount:
|
|
187
|
+
columnCount: d - a + 1
|
|
188
188
|
};
|
|
189
189
|
}
|
|
190
190
|
/**
|
|
@@ -202,14 +202,14 @@ class vt extends y {
|
|
|
202
202
|
if (isNaN(r)) return null;
|
|
203
203
|
const s = this.rows[r];
|
|
204
204
|
if (!s) return null;
|
|
205
|
-
const l = s[n],
|
|
206
|
-
let
|
|
205
|
+
const l = s[n], d = this.columns.find((u) => u.field === n)?.header || n;
|
|
206
|
+
let c;
|
|
207
207
|
if (this.config.includeHeaders) {
|
|
208
208
|
const u = l == null ? "" : String(l);
|
|
209
|
-
|
|
209
|
+
c = `${d}: ${u}`;
|
|
210
210
|
} else
|
|
211
|
-
|
|
212
|
-
return { text:
|
|
211
|
+
c = l == null ? "" : String(l);
|
|
212
|
+
return { text: c, field: n, value: l };
|
|
213
213
|
}
|
|
214
214
|
// ===== Public API =====
|
|
215
215
|
/**
|
|
@@ -217,7 +217,7 @@ class vt extends y {
|
|
|
217
217
|
* @returns The copied text
|
|
218
218
|
*/
|
|
219
219
|
async copy() {
|
|
220
|
-
const t = this.#
|
|
220
|
+
const t = this.#t()?.getSelectedRows() ?? [], n = F({
|
|
221
221
|
rows: this.rows,
|
|
222
222
|
columns: [...this.columns],
|
|
223
223
|
selectedIndices: t,
|
|
@@ -277,28 +277,28 @@ function te(i) {
|
|
|
277
277
|
function ne(i) {
|
|
278
278
|
return i.reduce((e, t) => e + G(t.width), 0);
|
|
279
279
|
}
|
|
280
|
-
function
|
|
280
|
+
function Ce(i, e, t, n, o) {
|
|
281
281
|
const r = t.length;
|
|
282
282
|
if (r === 0)
|
|
283
283
|
return { startCol: 0, endCol: 0, visibleColumns: [] };
|
|
284
|
-
let s =
|
|
284
|
+
let s = Se(i, t, n);
|
|
285
285
|
s = Math.max(0, s - o);
|
|
286
286
|
const l = i + e;
|
|
287
287
|
let a = s;
|
|
288
|
-
for (let
|
|
289
|
-
if (t[
|
|
290
|
-
a =
|
|
288
|
+
for (let c = s; c < r; c++) {
|
|
289
|
+
if (t[c] >= l) {
|
|
290
|
+
a = c - 1;
|
|
291
291
|
break;
|
|
292
292
|
}
|
|
293
|
-
a =
|
|
293
|
+
a = c;
|
|
294
294
|
}
|
|
295
295
|
a = Math.min(r - 1, a + o);
|
|
296
|
-
const
|
|
297
|
-
for (let
|
|
298
|
-
|
|
299
|
-
return { startCol: s, endCol: a, visibleColumns:
|
|
296
|
+
const d = [];
|
|
297
|
+
for (let c = s; c <= a; c++)
|
|
298
|
+
d.push(c);
|
|
299
|
+
return { startCol: s, endCol: a, visibleColumns: d };
|
|
300
300
|
}
|
|
301
|
-
function
|
|
301
|
+
function Se(i, e, t) {
|
|
302
302
|
let n = 0, o = e.length - 1;
|
|
303
303
|
for (; n < o; ) {
|
|
304
304
|
const r = Math.floor((n + o) / 2);
|
|
@@ -306,10 +306,10 @@ function Ce(i, e, t) {
|
|
|
306
306
|
}
|
|
307
307
|
return n;
|
|
308
308
|
}
|
|
309
|
-
function
|
|
309
|
+
function Re(i, e, t) {
|
|
310
310
|
return t ? i > e : !1;
|
|
311
311
|
}
|
|
312
|
-
class
|
|
312
|
+
class Ct extends y {
|
|
313
313
|
name = "columnVirtualization";
|
|
314
314
|
version = "1.0.0";
|
|
315
315
|
get defaultConfig() {
|
|
@@ -339,10 +339,10 @@ class yt extends y {
|
|
|
339
339
|
}
|
|
340
340
|
// ===== Hooks =====
|
|
341
341
|
processColumns(e) {
|
|
342
|
-
const t = this.config.enabled &&
|
|
342
|
+
const t = this.config.enabled && Re(e.length, this.config.threshold ?? 30, this.config.autoEnable ?? !0);
|
|
343
343
|
if (this.isVirtualized = t ?? !1, this.columnWidths = ee(e), this.columnOffsets = te(e), this.totalWidth = ne(e), !t)
|
|
344
344
|
return this.startCol = 0, this.endCol = e.length - 1, [...e];
|
|
345
|
-
const n = this.grid.clientWidth || 800, o =
|
|
345
|
+
const n = this.grid.clientWidth || 800, o = Ce(
|
|
346
346
|
this.scrollLeft,
|
|
347
347
|
n,
|
|
348
348
|
this.columnOffsets,
|
|
@@ -400,49 +400,49 @@ class yt extends y {
|
|
|
400
400
|
return this.totalWidth;
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
|
-
function
|
|
403
|
+
function V(i, e) {
|
|
404
404
|
return (typeof i == "function" ? i(e) : i).filter((n) => !(n.hidden === !0 || typeof n.hidden == "function" && n.hidden(e)));
|
|
405
405
|
}
|
|
406
|
-
function
|
|
406
|
+
function ke(i, e) {
|
|
407
407
|
return i.disabled === !0 ? !0 : typeof i.disabled == "function" ? i.disabled(e) : !1;
|
|
408
408
|
}
|
|
409
|
-
function
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
for (const
|
|
413
|
-
if (
|
|
414
|
-
const
|
|
415
|
-
|
|
409
|
+
function K(i, e, t, n = xe.submenuArrow) {
|
|
410
|
+
const o = document.createElement("div");
|
|
411
|
+
o.className = "tbw-context-menu", o.setAttribute("role", "menu");
|
|
412
|
+
for (const r of i) {
|
|
413
|
+
if (r.separator) {
|
|
414
|
+
const d = document.createElement("div");
|
|
415
|
+
d.className = "tbw-context-menu-separator", d.setAttribute("role", "separator"), o.appendChild(d);
|
|
416
416
|
continue;
|
|
417
417
|
}
|
|
418
|
-
const
|
|
419
|
-
|
|
420
|
-
const
|
|
421
|
-
if (
|
|
422
|
-
const
|
|
423
|
-
|
|
424
|
-
}
|
|
425
|
-
const
|
|
426
|
-
if (
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
}
|
|
430
|
-
if (
|
|
431
|
-
const
|
|
432
|
-
|
|
433
|
-
if (
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
}),
|
|
437
|
-
const c =
|
|
418
|
+
const s = document.createElement("div");
|
|
419
|
+
s.className = "tbw-context-menu-item", r.cssClass && s.classList.add(r.cssClass), s.setAttribute("role", "menuitem"), s.setAttribute("data-id", r.id);
|
|
420
|
+
const l = ke(r, e);
|
|
421
|
+
if (l && (s.classList.add("disabled"), s.setAttribute("aria-disabled", "true")), r.icon) {
|
|
422
|
+
const d = document.createElement("span");
|
|
423
|
+
d.className = "tbw-context-menu-icon", d.innerHTML = r.icon, s.appendChild(d);
|
|
424
|
+
}
|
|
425
|
+
const a = document.createElement("span");
|
|
426
|
+
if (a.className = "tbw-context-menu-label", a.textContent = r.name, s.appendChild(a), r.shortcut) {
|
|
427
|
+
const d = document.createElement("span");
|
|
428
|
+
d.className = "tbw-context-menu-shortcut", d.textContent = r.shortcut, s.appendChild(d);
|
|
429
|
+
}
|
|
430
|
+
if (r.subMenu?.length) {
|
|
431
|
+
const d = document.createElement("span");
|
|
432
|
+
d.className = "tbw-context-menu-arrow", typeof n == "string" ? d.innerHTML = n : n instanceof HTMLElement && d.appendChild(n.cloneNode(!0)), s.appendChild(d), s.addEventListener("mouseenter", () => {
|
|
433
|
+
if (s.querySelector(".tbw-context-menu") || !r.subMenu) return;
|
|
434
|
+
const u = V(r.subMenu, e), h = K(u, e, t, n);
|
|
435
|
+
h.classList.add("tbw-context-submenu"), h.style.position = "absolute", h.style.left = "100%", h.style.top = "0", s.style.position = "relative", s.appendChild(h);
|
|
436
|
+
}), s.addEventListener("mouseleave", () => {
|
|
437
|
+
const c = s.querySelector(".tbw-context-menu");
|
|
438
438
|
c && c.remove();
|
|
439
439
|
});
|
|
440
440
|
}
|
|
441
|
-
!
|
|
442
|
-
|
|
443
|
-
}),
|
|
441
|
+
!l && r.action && !r.subMenu && s.addEventListener("click", (d) => {
|
|
442
|
+
d.stopPropagation(), t(r);
|
|
443
|
+
}), o.appendChild(s);
|
|
444
444
|
}
|
|
445
|
-
return
|
|
445
|
+
return o;
|
|
446
446
|
}
|
|
447
447
|
function oe(i, e, t) {
|
|
448
448
|
i.style.position = "fixed", i.style.left = `${e}px`, i.style.top = `${t}px`, i.style.visibility = "hidden", i.style.zIndex = "10000";
|
|
@@ -450,8 +450,8 @@ function oe(i, e, t) {
|
|
|
450
450
|
let s = e, l = t;
|
|
451
451
|
e + n.width > o && (s = e - n.width), t + n.height > r && (l = t - n.height), s = Math.max(0, s), l = Math.max(0, l), i.style.left = `${s}px`, i.style.top = `${l}px`, i.style.visibility = "visible";
|
|
452
452
|
}
|
|
453
|
-
let
|
|
454
|
-
const
|
|
453
|
+
let D = null, P = null, A = null;
|
|
454
|
+
const Ee = `
|
|
455
455
|
.tbw-context-menu {
|
|
456
456
|
position: fixed;
|
|
457
457
|
background: light-dark(#f5f5f5, #2a2a2a);
|
|
@@ -520,7 +520,7 @@ const ke = `
|
|
|
520
520
|
}
|
|
521
521
|
}
|
|
522
522
|
];
|
|
523
|
-
class
|
|
523
|
+
class St extends y {
|
|
524
524
|
name = "contextMenu";
|
|
525
525
|
version = "1.0.0";
|
|
526
526
|
get defaultConfig() {
|
|
@@ -543,11 +543,11 @@ class Ct extends y {
|
|
|
543
543
|
}
|
|
544
544
|
// ===== Private Methods =====
|
|
545
545
|
installGlobalHandlers() {
|
|
546
|
-
!A && typeof document < "u" && (A = document.createElement("style"), A.id = "tbw-context-menu-styles", A.textContent =
|
|
546
|
+
!A && typeof document < "u" && (A = document.createElement("style"), A.id = "tbw-context-menu-styles", A.textContent = Ee, document.head.appendChild(A)), D || (D = () => {
|
|
547
547
|
document.querySelectorAll(".tbw-context-menu").forEach((t) => t.remove());
|
|
548
|
-
}, document.addEventListener("click",
|
|
548
|
+
}, document.addEventListener("click", D)), P || (P = (e) => {
|
|
549
549
|
e.key === "Escape" && document.querySelectorAll(".tbw-context-menu").forEach((n) => n.remove());
|
|
550
|
-
}, document.addEventListener("keydown",
|
|
550
|
+
}, document.addEventListener("keydown", P));
|
|
551
551
|
}
|
|
552
552
|
// ===== Hooks =====
|
|
553
553
|
afterRender() {
|
|
@@ -562,10 +562,10 @@ class Ct extends y {
|
|
|
562
562
|
const r = o.target, s = r.closest("[data-row][data-col]"), l = r.closest(".header-cell");
|
|
563
563
|
let a;
|
|
564
564
|
if (s) {
|
|
565
|
-
const
|
|
565
|
+
const c = parseInt(s.getAttribute("data-row") ?? "-1", 10), u = parseInt(s.getAttribute("data-col") ?? "-1", 10), h = this.columns[u], f = this.rows[c];
|
|
566
566
|
a = {
|
|
567
567
|
row: f,
|
|
568
|
-
rowIndex:
|
|
568
|
+
rowIndex: c,
|
|
569
569
|
column: h,
|
|
570
570
|
columnIndex: u,
|
|
571
571
|
field: h?.field ?? "",
|
|
@@ -574,12 +574,12 @@ class Ct extends y {
|
|
|
574
574
|
event: o
|
|
575
575
|
};
|
|
576
576
|
} else if (l) {
|
|
577
|
-
const
|
|
577
|
+
const c = parseInt(l.getAttribute("data-col") ?? "-1", 10), u = this.columns[c];
|
|
578
578
|
a = {
|
|
579
579
|
row: null,
|
|
580
580
|
rowIndex: -1,
|
|
581
581
|
column: u,
|
|
582
|
-
columnIndex:
|
|
582
|
+
columnIndex: c,
|
|
583
583
|
field: u?.field ?? "",
|
|
584
584
|
value: null,
|
|
585
585
|
isHeader: !0,
|
|
@@ -588,10 +588,15 @@ class Ct extends y {
|
|
|
588
588
|
} else
|
|
589
589
|
return;
|
|
590
590
|
this.params = a, this.position = { x: o.clientX, y: o.clientY };
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
d
|
|
594
|
-
|
|
591
|
+
const d = V(this.config.items ?? B, a);
|
|
592
|
+
d.length && (this.menuElement && this.menuElement.remove(), this.menuElement = K(
|
|
593
|
+
d,
|
|
594
|
+
a,
|
|
595
|
+
(c) => {
|
|
596
|
+
c.action && c.action(a), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
|
|
597
|
+
},
|
|
598
|
+
this.gridIcons.submenuArrow
|
|
599
|
+
), document.body.appendChild(this.menuElement), oe(this.menuElement, o.clientX, o.clientY), this.isOpen = !0, this.emit("context-menu-open", { params: a, items: d }));
|
|
595
600
|
}));
|
|
596
601
|
}
|
|
597
602
|
// ===== Public API =====
|
|
@@ -611,10 +616,15 @@ class Ct extends y {
|
|
|
611
616
|
value: n.value ?? null,
|
|
612
617
|
isHeader: n.isHeader ?? !1,
|
|
613
618
|
event: n.event ?? new MouseEvent("contextmenu")
|
|
614
|
-
}, r =
|
|
615
|
-
this.menuElement && this.menuElement.remove(), this.menuElement =
|
|
616
|
-
|
|
617
|
-
|
|
619
|
+
}, r = V(this.config.items ?? B, o);
|
|
620
|
+
this.menuElement && this.menuElement.remove(), this.menuElement = K(
|
|
621
|
+
r,
|
|
622
|
+
o,
|
|
623
|
+
(s) => {
|
|
624
|
+
s.action && s.action(o), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
|
|
625
|
+
},
|
|
626
|
+
this.gridIcons.submenuArrow
|
|
627
|
+
), document.body.appendChild(this.menuElement), oe(this.menuElement, e, t), this.isOpen = !0;
|
|
618
628
|
}
|
|
619
629
|
/**
|
|
620
630
|
* Hide the context menu.
|
|
@@ -639,22 +649,22 @@ function re(i, e = !0) {
|
|
|
639
649
|
return e && (t.includes(",") || t.includes('"') || t.includes(`
|
|
640
650
|
`) || t.includes("\r")) ? `"${t.replace(/"/g, '""')}"` : t;
|
|
641
651
|
}
|
|
642
|
-
function
|
|
652
|
+
function Ae(i, e, t, n = {}) {
|
|
643
653
|
const o = n.delimiter ?? ",", r = n.newline ?? `
|
|
644
654
|
`, s = [], l = n.bom ? "\uFEFF" : "";
|
|
645
655
|
if (t.includeHeaders !== !1) {
|
|
646
|
-
const a = e.map((
|
|
647
|
-
const
|
|
656
|
+
const a = e.map((d) => {
|
|
657
|
+
const c = d.header || d.field, u = t.processHeader ? t.processHeader(c, d.field) : c;
|
|
648
658
|
return re(u);
|
|
649
659
|
});
|
|
650
660
|
s.push(a.join(o));
|
|
651
661
|
}
|
|
652
662
|
for (const a of i) {
|
|
653
|
-
const
|
|
654
|
-
let u = a[
|
|
655
|
-
return t.processCell && (u = t.processCell(u,
|
|
663
|
+
const d = e.map((c) => {
|
|
664
|
+
let u = a[c.field];
|
|
665
|
+
return t.processCell && (u = t.processCell(u, c.field, a)), re(u);
|
|
656
666
|
});
|
|
657
|
-
s.push(
|
|
667
|
+
s.push(d.join(o));
|
|
658
668
|
}
|
|
659
669
|
return l + s.join(r);
|
|
660
670
|
}
|
|
@@ -662,7 +672,7 @@ function z(i, e) {
|
|
|
662
672
|
const t = URL.createObjectURL(i), n = document.createElement("a");
|
|
663
673
|
n.href = t, n.download = e, n.style.display = "none", document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(t);
|
|
664
674
|
}
|
|
665
|
-
function
|
|
675
|
+
function Ie(i, e) {
|
|
666
676
|
const t = new Blob([i], { type: "text/csv;charset=utf-8;" });
|
|
667
677
|
z(t, e);
|
|
668
678
|
}
|
|
@@ -701,13 +711,13 @@ function _e(i, e, t) {
|
|
|
701
711
|
</Worksheet>
|
|
702
712
|
</Workbook>`, n;
|
|
703
713
|
}
|
|
704
|
-
function
|
|
714
|
+
function Te(i, e) {
|
|
705
715
|
const t = e.endsWith(".xls") ? e : `${e}.xls`, n = new Blob([i], {
|
|
706
716
|
type: "application/vnd.ms-excel;charset=utf-8;"
|
|
707
717
|
});
|
|
708
718
|
z(n, t);
|
|
709
719
|
}
|
|
710
|
-
class
|
|
720
|
+
class Rt extends y {
|
|
711
721
|
name = "export";
|
|
712
722
|
version = "1.0.0";
|
|
713
723
|
get defaultConfig() {
|
|
@@ -736,25 +746,25 @@ class St extends y {
|
|
|
736
746
|
let r = [...this.columns];
|
|
737
747
|
if (n.onlyVisible && (r = r.filter((a) => !a.hidden && !a.field.startsWith("__"))), t?.columns) {
|
|
738
748
|
const a = new Set(t.columns);
|
|
739
|
-
r = r.filter((
|
|
749
|
+
r = r.filter((d) => a.has(d.field));
|
|
740
750
|
}
|
|
741
751
|
let s = [...this.rows];
|
|
742
752
|
if (n.onlySelected) {
|
|
743
753
|
const a = this.getSelectionState();
|
|
744
|
-
a?.selected?.size && (s = [...a.selected].sort((
|
|
754
|
+
a?.selected?.size && (s = [...a.selected].sort((c, u) => c - u).map((c) => this.rows[c]).filter(Boolean));
|
|
745
755
|
}
|
|
746
756
|
t?.rowIndices && (s = t.rowIndices.map((a) => this.rows[a]).filter(Boolean)), this.isExportingFlag = !0;
|
|
747
757
|
let l = o.fileName;
|
|
748
758
|
try {
|
|
749
759
|
switch (e) {
|
|
750
760
|
case "csv": {
|
|
751
|
-
const a =
|
|
752
|
-
l = l.endsWith(".csv") ? l : `${l}.csv`,
|
|
761
|
+
const a = Ae(s, r, o, { bom: !0 });
|
|
762
|
+
l = l.endsWith(".csv") ? l : `${l}.csv`, Ie(a, l);
|
|
753
763
|
break;
|
|
754
764
|
}
|
|
755
765
|
case "excel": {
|
|
756
766
|
const a = _e(s, r, o);
|
|
757
|
-
l = l.endsWith(".xls") ? l : `${l}.xls`,
|
|
767
|
+
l = l.endsWith(".xls") ? l : `${l}.xls`, Te(a, l);
|
|
758
768
|
break;
|
|
759
769
|
}
|
|
760
770
|
case "json": {
|
|
@@ -765,10 +775,10 @@ class St extends y {
|
|
|
765
775
|
o.processCell && (g = o.processCell(g, f.field, u)), h[f.field] = g;
|
|
766
776
|
}
|
|
767
777
|
return h;
|
|
768
|
-
}),
|
|
778
|
+
}), d = JSON.stringify(a, null, 2);
|
|
769
779
|
l = l.endsWith(".json") ? l : `${l}.json`;
|
|
770
|
-
const
|
|
771
|
-
z(
|
|
780
|
+
const c = new Blob([d], { type: "application/json" });
|
|
781
|
+
z(c, l);
|
|
772
782
|
break;
|
|
773
783
|
}
|
|
774
784
|
}
|
|
@@ -826,7 +836,7 @@ class St extends y {
|
|
|
826
836
|
return this.lastExportInfo;
|
|
827
837
|
}
|
|
828
838
|
}
|
|
829
|
-
function
|
|
839
|
+
function Le(i) {
|
|
830
840
|
const { totalRows: e, viewportHeight: t, scrollTop: n, rowHeight: o, overscan: r } = i, s = Math.ceil(t / o);
|
|
831
841
|
let l = Math.floor(n / o) - r;
|
|
832
842
|
l < 0 && (l = 0);
|
|
@@ -838,10 +848,10 @@ function Te(i) {
|
|
|
838
848
|
totalHeight: e * o
|
|
839
849
|
};
|
|
840
850
|
}
|
|
841
|
-
function
|
|
851
|
+
function Me(i, e) {
|
|
842
852
|
return i <= e;
|
|
843
853
|
}
|
|
844
|
-
function
|
|
854
|
+
function qe(i, e, t = !1) {
|
|
845
855
|
const n = i[e.field];
|
|
846
856
|
if (e.operator === "blank")
|
|
847
857
|
return n == null || n === "";
|
|
@@ -883,10 +893,10 @@ function Me(i, e, t = !1) {
|
|
|
883
893
|
return !0;
|
|
884
894
|
}
|
|
885
895
|
}
|
|
886
|
-
function
|
|
887
|
-
return e.length ? i.filter((n) => e.every((o) =>
|
|
896
|
+
function Fe(i, e, t = !1) {
|
|
897
|
+
return e.length ? i.filter((n) => e.every((o) => qe(n, o, t))) : i;
|
|
888
898
|
}
|
|
889
|
-
function
|
|
899
|
+
function Ne(i) {
|
|
890
900
|
return JSON.stringify(
|
|
891
901
|
i.map((e) => ({
|
|
892
902
|
field: e.field,
|
|
@@ -904,7 +914,7 @@ function se(i, e) {
|
|
|
904
914
|
}
|
|
905
915
|
return [...t].sort((n, o) => typeof n == "number" && typeof o == "number" ? n - o : String(n).localeCompare(String(o)));
|
|
906
916
|
}
|
|
907
|
-
const
|
|
917
|
+
const De = `
|
|
908
918
|
.tbw-filter-panel {
|
|
909
919
|
position: fixed;
|
|
910
920
|
background: var(--tbw-filter-panel-bg, var(--tbw-color-panel-bg, light-dark(#eeeeee, #222222)));
|
|
@@ -1085,10 +1095,10 @@ class E extends y {
|
|
|
1085
1095
|
processRows(e) {
|
|
1086
1096
|
const t = [...this.filters.values()];
|
|
1087
1097
|
if (!t.length) return [...e];
|
|
1088
|
-
const n =
|
|
1098
|
+
const n = Ne(t);
|
|
1089
1099
|
if (this.cacheKey === n && this.cachedResult)
|
|
1090
1100
|
return this.cachedResult;
|
|
1091
|
-
const o =
|
|
1101
|
+
const o = Fe([...e], t, this.config.caseSensitive);
|
|
1092
1102
|
return this.cachedResult = o, this.cacheKey = n, o;
|
|
1093
1103
|
}
|
|
1094
1104
|
afterRender() {
|
|
@@ -1204,7 +1214,7 @@ class E extends y {
|
|
|
1204
1214
|
return;
|
|
1205
1215
|
}
|
|
1206
1216
|
const e = document.createElement("style");
|
|
1207
|
-
e.id = "tbw-filter-panel-styles", e.textContent =
|
|
1217
|
+
e.id = "tbw-filter-panel-styles", e.textContent = De, document.head.appendChild(e), this.globalStylesInjected = !0;
|
|
1208
1218
|
}
|
|
1209
1219
|
/**
|
|
1210
1220
|
* Toggle the filter panel for a field
|
|
@@ -1226,23 +1236,23 @@ class E extends y {
|
|
|
1226
1236
|
uniqueValues: r,
|
|
1227
1237
|
excludedValues: s,
|
|
1228
1238
|
searchText: l,
|
|
1229
|
-
applySetFilter: (
|
|
1230
|
-
this.applySetFilter(e,
|
|
1239
|
+
applySetFilter: (c) => {
|
|
1240
|
+
this.applySetFilter(e, c), this.closeFilterPanel();
|
|
1231
1241
|
},
|
|
1232
|
-
applyTextFilter: (
|
|
1233
|
-
this.applyTextFilter(e,
|
|
1242
|
+
applyTextFilter: (c, u, h) => {
|
|
1243
|
+
this.applyTextFilter(e, c, u, h), this.closeFilterPanel();
|
|
1234
1244
|
},
|
|
1235
1245
|
clearFilter: () => {
|
|
1236
1246
|
this.clearFieldFilter(e), this.closeFilterPanel();
|
|
1237
1247
|
},
|
|
1238
1248
|
closePanel: () => this.closeFilterPanel()
|
|
1239
1249
|
};
|
|
1240
|
-
let
|
|
1241
|
-
this.config.filterPanelRenderer && (this.config.filterPanelRenderer(o, a),
|
|
1250
|
+
let d = !1;
|
|
1251
|
+
this.config.filterPanelRenderer && (this.config.filterPanelRenderer(o, a), d = o.children.length > 0), d || this.renderDefaultFilterPanel(o, a, r, s), document.body.appendChild(o), this.positionPanel(o, n), this.panelAbortController = new AbortController(), setTimeout(() => {
|
|
1242
1252
|
document.addEventListener(
|
|
1243
1253
|
"click",
|
|
1244
|
-
(
|
|
1245
|
-
!o.contains(
|
|
1254
|
+
(c) => {
|
|
1255
|
+
!o.contains(c.target) && c.target !== n && this.closeFilterPanel();
|
|
1246
1256
|
},
|
|
1247
1257
|
{ signal: this.panelAbortController?.signal }
|
|
1248
1258
|
);
|
|
@@ -1274,18 +1284,18 @@ class E extends y {
|
|
|
1274
1284
|
l.type = "text", l.placeholder = "Search...", l.className = "tbw-filter-search-input", l.value = this.searchText.get(r) ?? "", s.appendChild(l), e.appendChild(s);
|
|
1275
1285
|
const a = document.createElement("div");
|
|
1276
1286
|
a.className = "tbw-filter-actions";
|
|
1277
|
-
const
|
|
1278
|
-
|
|
1279
|
-
const
|
|
1280
|
-
|
|
1287
|
+
const d = document.createElement("label");
|
|
1288
|
+
d.className = "tbw-filter-value-item", d.style.padding = "0", d.style.margin = "0";
|
|
1289
|
+
const c = document.createElement("input");
|
|
1290
|
+
c.type = "checkbox", c.className = "tbw-filter-checkbox";
|
|
1281
1291
|
const u = document.createElement("span");
|
|
1282
|
-
u.textContent = "Select All",
|
|
1292
|
+
u.textContent = "Select All", d.appendChild(c), d.appendChild(u), a.appendChild(d);
|
|
1283
1293
|
const h = () => {
|
|
1284
1294
|
const p = [...b.values()], v = p.every((x) => x), C = p.every((x) => !x);
|
|
1285
|
-
|
|
1295
|
+
c.checked = v, c.indeterminate = !v && !C;
|
|
1286
1296
|
};
|
|
1287
|
-
|
|
1288
|
-
const p =
|
|
1297
|
+
c.addEventListener("change", () => {
|
|
1298
|
+
const p = c.checked;
|
|
1289
1299
|
for (const v of b.keys())
|
|
1290
1300
|
b.set(v, p);
|
|
1291
1301
|
h(), q();
|
|
@@ -1313,13 +1323,13 @@ class E extends y {
|
|
|
1313
1323
|
return Y.textContent = C, w.appendChild(k), w.appendChild(Y), w;
|
|
1314
1324
|
}, q = () => {
|
|
1315
1325
|
const p = S.length, v = f.clientHeight, C = f.scrollTop;
|
|
1316
|
-
if (g.style.height = `${p * E.LIST_ITEM_HEIGHT}px`,
|
|
1326
|
+
if (g.style.height = `${p * E.LIST_ITEM_HEIGHT}px`, Me(p, E.LIST_BYPASS_THRESHOLD / 3)) {
|
|
1317
1327
|
m.innerHTML = "", m.style.transform = "translateY(0px)", S.forEach((w, k) => {
|
|
1318
1328
|
m.appendChild(R(w, k));
|
|
1319
1329
|
});
|
|
1320
1330
|
return;
|
|
1321
1331
|
}
|
|
1322
|
-
const x =
|
|
1332
|
+
const x = Le({
|
|
1323
1333
|
totalRows: p,
|
|
1324
1334
|
viewportHeight: v,
|
|
1325
1335
|
scrollTop: C,
|
|
@@ -1355,8 +1365,8 @@ class E extends y {
|
|
|
1355
1365
|
this.searchText.set(r, l.value), j(l.value);
|
|
1356
1366
|
}, this.config.debounceMs ?? 150);
|
|
1357
1367
|
});
|
|
1358
|
-
const
|
|
1359
|
-
|
|
1368
|
+
const _ = document.createElement("div");
|
|
1369
|
+
_.className = "tbw-filter-buttons";
|
|
1360
1370
|
const T = document.createElement("button");
|
|
1361
1371
|
T.className = "tbw-filter-apply-btn", T.textContent = "Apply", T.addEventListener("click", () => {
|
|
1362
1372
|
const p = [];
|
|
@@ -1369,11 +1379,11 @@ class E extends y {
|
|
|
1369
1379
|
p.push(x !== void 0 ? x : v);
|
|
1370
1380
|
}
|
|
1371
1381
|
t.applySetFilter(p);
|
|
1372
|
-
}),
|
|
1382
|
+
}), _.appendChild(T);
|
|
1373
1383
|
const L = document.createElement("button");
|
|
1374
1384
|
L.className = "tbw-filter-clear-btn", L.textContent = "Clear Filter", L.addEventListener("click", () => {
|
|
1375
1385
|
t.clearFilter();
|
|
1376
|
-
}),
|
|
1386
|
+
}), _.appendChild(L), e.appendChild(_);
|
|
1377
1387
|
}
|
|
1378
1388
|
/**
|
|
1379
1389
|
* Apply a set filter (exclude values)
|
|
@@ -1497,17 +1507,17 @@ function Pe(i) {
|
|
|
1497
1507
|
return;
|
|
1498
1508
|
}
|
|
1499
1509
|
o.length && (n(r, o.slice()), o = []);
|
|
1500
|
-
const
|
|
1501
|
-
let
|
|
1502
|
-
|
|
1503
|
-
id:
|
|
1510
|
+
const d = typeof a == "string" ? a : a.id;
|
|
1511
|
+
let c = e.get(d);
|
|
1512
|
+
c || (c = {
|
|
1513
|
+
id: d,
|
|
1504
1514
|
label: typeof a == "string" ? void 0 : a.label,
|
|
1505
1515
|
columns: [],
|
|
1506
1516
|
firstIndex: l
|
|
1507
|
-
}, e.set(
|
|
1517
|
+
}, e.set(d, c), t.push(c)), c.columns.push(s);
|
|
1508
1518
|
}), o.length && n(r, o), t.length === 1 && t[0].implicit && t[0].columns.length === i.length ? [] : t;
|
|
1509
1519
|
}
|
|
1510
|
-
function
|
|
1520
|
+
function Be(i, e, t) {
|
|
1511
1521
|
if (!e.length || !i) return;
|
|
1512
1522
|
const n = /* @__PURE__ */ new Map();
|
|
1513
1523
|
for (const r of e)
|
|
@@ -1523,7 +1533,7 @@ function De(i, e, t) {
|
|
|
1523
1533
|
l && l.classList.add("group-end");
|
|
1524
1534
|
}
|
|
1525
1535
|
}
|
|
1526
|
-
function
|
|
1536
|
+
function He(i, e) {
|
|
1527
1537
|
if (i.length === 0) return null;
|
|
1528
1538
|
const t = document.createElement("div");
|
|
1529
1539
|
t.className = "header-group-row", t.setAttribute("role", "row");
|
|
@@ -1536,7 +1546,7 @@ function Be(i, e) {
|
|
|
1536
1546
|
function Oe(i) {
|
|
1537
1547
|
return i.some((e) => e.group != null);
|
|
1538
1548
|
}
|
|
1539
|
-
class
|
|
1549
|
+
class kt extends y {
|
|
1540
1550
|
name = "groupingColumns";
|
|
1541
1551
|
version = "1.0.0";
|
|
1542
1552
|
get defaultConfig() {
|
|
@@ -1577,13 +1587,13 @@ class Rt extends y {
|
|
|
1577
1587
|
if (!e) return;
|
|
1578
1588
|
const t = e.querySelector(".header-group-row");
|
|
1579
1589
|
t && t.remove();
|
|
1580
|
-
const n =
|
|
1590
|
+
const n = He(this.groups, this.columns);
|
|
1581
1591
|
if (n) {
|
|
1582
1592
|
const r = e.querySelector(".header-row");
|
|
1583
1593
|
r ? e.insertBefore(n, r) : e.appendChild(n);
|
|
1584
1594
|
}
|
|
1585
1595
|
const o = e.querySelector(".header-row");
|
|
1586
|
-
o &&
|
|
1596
|
+
o && Be(o, this.groups, this.columns);
|
|
1587
1597
|
}
|
|
1588
1598
|
// ===== Public API =====
|
|
1589
1599
|
/**
|
|
@@ -1645,7 +1655,7 @@ class Rt extends y {
|
|
|
1645
1655
|
}
|
|
1646
1656
|
`;
|
|
1647
1657
|
}
|
|
1648
|
-
function
|
|
1658
|
+
function We({ rows: i, config: e, expanded: t }) {
|
|
1649
1659
|
const n = e.groupOn;
|
|
1650
1660
|
if (!e.enabled || typeof n != "function")
|
|
1651
1661
|
return [];
|
|
@@ -1653,17 +1663,17 @@ function He({ rows: i, config: e, expanded: t }) {
|
|
|
1653
1663
|
if (i.forEach((l) => {
|
|
1654
1664
|
let a = n(l);
|
|
1655
1665
|
a == null || a === !1 ? a = ["__ungrouped__"] : Array.isArray(a) || (a = [a]);
|
|
1656
|
-
let
|
|
1657
|
-
a.forEach((
|
|
1658
|
-
const h =
|
|
1659
|
-
let g =
|
|
1660
|
-
g || (g = { key: f, value:
|
|
1661
|
-
}),
|
|
1666
|
+
let d = o;
|
|
1667
|
+
a.forEach((c, u) => {
|
|
1668
|
+
const h = c == null ? "∅" : String(c), f = d.key === "__root__" ? h : d.key + "||" + h;
|
|
1669
|
+
let g = d.children.get(h);
|
|
1670
|
+
g || (g = { key: f, value: c, depth: u, rows: [], children: /* @__PURE__ */ new Map(), parent: d }, d.children.set(h, g)), d = g;
|
|
1671
|
+
}), d.rows.push(l);
|
|
1662
1672
|
}), o.children.size === 1 && o.children.has("__ungrouped__") && o.children.get("__ungrouped__").rows.length === i.length)
|
|
1663
1673
|
return [];
|
|
1664
1674
|
const r = [], s = (l) => {
|
|
1665
1675
|
if (l === o) {
|
|
1666
|
-
l.children.forEach((
|
|
1676
|
+
l.children.forEach((d) => s(d));
|
|
1667
1677
|
return;
|
|
1668
1678
|
}
|
|
1669
1679
|
const a = t.has(l.key);
|
|
@@ -1674,11 +1684,11 @@ function He({ rows: i, config: e, expanded: t }) {
|
|
|
1674
1684
|
depth: l.depth,
|
|
1675
1685
|
rows: l.rows,
|
|
1676
1686
|
expanded: a
|
|
1677
|
-
}), a && (l.children.size ? l.children.forEach((
|
|
1687
|
+
}), a && (l.children.size ? l.children.forEach((d) => s(d)) : l.rows.forEach((d) => r.push({ kind: "data", row: d, rowIndex: i.indexOf(d) })));
|
|
1678
1688
|
};
|
|
1679
1689
|
return s(o), r;
|
|
1680
1690
|
}
|
|
1681
|
-
function
|
|
1691
|
+
function Ve(i, e) {
|
|
1682
1692
|
const t = new Set(i);
|
|
1683
1693
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
1684
1694
|
}
|
|
@@ -1688,13 +1698,13 @@ function Ke(i) {
|
|
|
1688
1698
|
t.kind === "group" && e.add(t.key);
|
|
1689
1699
|
return e;
|
|
1690
1700
|
}
|
|
1691
|
-
function
|
|
1701
|
+
function Ge() {
|
|
1692
1702
|
return /* @__PURE__ */ new Set();
|
|
1693
1703
|
}
|
|
1694
|
-
function
|
|
1704
|
+
function ze(i) {
|
|
1695
1705
|
return i.kind !== "group" ? 0 : i.rows.length;
|
|
1696
1706
|
}
|
|
1697
|
-
class
|
|
1707
|
+
class Et extends y {
|
|
1698
1708
|
name = "groupingRows";
|
|
1699
1709
|
version = "1.0.0";
|
|
1700
1710
|
get defaultConfig() {
|
|
@@ -1726,7 +1736,7 @@ class kt extends y {
|
|
|
1726
1736
|
const t = this.config;
|
|
1727
1737
|
if (!t.enabled || typeof t.groupOn != "function")
|
|
1728
1738
|
return this.isActive = !1, this.flattenedRows = [], [...e];
|
|
1729
|
-
const n =
|
|
1739
|
+
const n = We({
|
|
1730
1740
|
rows: e,
|
|
1731
1741
|
config: t,
|
|
1732
1742
|
expanded: this.expandedKeys
|
|
@@ -1738,7 +1748,7 @@ class kt extends y {
|
|
|
1738
1748
|
__groupDepth: o.depth,
|
|
1739
1749
|
__groupRows: o.rows,
|
|
1740
1750
|
__groupExpanded: o.expanded,
|
|
1741
|
-
__groupRowCount:
|
|
1751
|
+
__groupRowCount: ze(o)
|
|
1742
1752
|
} : o.row));
|
|
1743
1753
|
}
|
|
1744
1754
|
onCellClick(e) {
|
|
@@ -1779,32 +1789,30 @@ class kt extends y {
|
|
|
1779
1789
|
const o = this.config, r = document.createElement("div");
|
|
1780
1790
|
r.className = "cell group-full", r.style.gridColumn = "1 / -1", r.setAttribute("role", "gridcell");
|
|
1781
1791
|
const s = document.createElement("button");
|
|
1782
|
-
s.type = "button", s.className = "group-toggle", s.setAttribute("aria-label", e.__groupExpanded ? "Collapse group" : "Expand group"), s.
|
|
1783
|
-
|
|
1792
|
+
s.type = "button", s.className = "group-toggle", s.setAttribute("aria-label", e.__groupExpanded ? "Collapse group" : "Expand group"), this.setIcon(s, this.resolveIcon(e.__groupExpanded ? "collapse" : "expand")), s.addEventListener("click", (d) => {
|
|
1793
|
+
d.stopPropagation(), n();
|
|
1784
1794
|
}), r.appendChild(s);
|
|
1785
1795
|
const l = document.createElement("span");
|
|
1786
1796
|
l.className = "group-label";
|
|
1787
1797
|
const a = o.formatLabel ? o.formatLabel(e.__groupValue, e.__groupDepth || 0, e.__groupKey) : String(e.__groupValue);
|
|
1788
1798
|
if (l.textContent = a, r.appendChild(l), o.showRowCount !== !1) {
|
|
1789
|
-
const
|
|
1790
|
-
|
|
1799
|
+
const d = document.createElement("span");
|
|
1800
|
+
d.className = "group-count", d.textContent = `(${e.__groupRowCount ?? e.__groupRows?.length ?? 0})`, r.appendChild(d);
|
|
1791
1801
|
}
|
|
1792
1802
|
t.appendChild(r);
|
|
1793
1803
|
}
|
|
1794
1804
|
renderPerColumnGroupRow(e, t, n) {
|
|
1795
|
-
const o = this.config, r = o.aggregators ?? {}, s = this.columns, l = e.__groupRows ?? [];
|
|
1796
|
-
|
|
1797
|
-
const c = this.shadowRoot?.querySelector(".body")?.style.gridTemplateColumns || "";
|
|
1798
|
-
c && (t.style.display = "grid", t.style.gridTemplateColumns = c), s.forEach((d, u) => {
|
|
1805
|
+
const o = this.config, r = o.aggregators ?? {}, s = this.columns, l = e.__groupRows ?? [], d = this.shadowRoot?.querySelector(".body")?.style.gridTemplateColumns || "";
|
|
1806
|
+
d && (t.style.display = "grid", t.style.gridTemplateColumns = d), s.forEach((c, u) => {
|
|
1799
1807
|
const h = document.createElement("div");
|
|
1800
1808
|
if (h.className = "cell group-cell", h.setAttribute("data-col", String(u)), h.setAttribute("role", "gridcell"), u === 0) {
|
|
1801
1809
|
const f = document.createElement("button");
|
|
1802
|
-
f.type = "button", f.className = "group-toggle", f.
|
|
1810
|
+
f.type = "button", f.className = "group-toggle", f.setAttribute("aria-label", e.__groupExpanded ? "Collapse group" : "Expand group"), this.setIcon(f, this.resolveIcon(e.__groupExpanded ? "collapse" : "expand")), f.addEventListener("click", (b) => {
|
|
1803
1811
|
b.stopPropagation(), n();
|
|
1804
1812
|
}), h.appendChild(f);
|
|
1805
|
-
const g = document.createElement("span"), m = r[
|
|
1813
|
+
const g = document.createElement("span"), m = r[c.field];
|
|
1806
1814
|
if (m) {
|
|
1807
|
-
const b = X(m, l,
|
|
1815
|
+
const b = X(m, l, c.field, c);
|
|
1808
1816
|
g.textContent = b != null ? String(b) : String(e.__groupValue);
|
|
1809
1817
|
} else {
|
|
1810
1818
|
const b = o.formatLabel ? o.formatLabel(e.__groupValue, e.__groupDepth || 0, e.__groupKey) : String(e.__groupValue);
|
|
@@ -1815,9 +1823,9 @@ class kt extends y {
|
|
|
1815
1823
|
b.className = "group-count", b.textContent = ` (${l.length})`, h.appendChild(b);
|
|
1816
1824
|
}
|
|
1817
1825
|
} else {
|
|
1818
|
-
const f = r[
|
|
1826
|
+
const f = r[c.field];
|
|
1819
1827
|
if (f) {
|
|
1820
|
-
const g = X(f, l,
|
|
1828
|
+
const g = X(f, l, c.field, c);
|
|
1821
1829
|
h.textContent = g != null ? String(g) : "";
|
|
1822
1830
|
} else
|
|
1823
1831
|
h.textContent = "";
|
|
@@ -1836,14 +1844,14 @@ class kt extends y {
|
|
|
1836
1844
|
* Collapse all groups.
|
|
1837
1845
|
*/
|
|
1838
1846
|
collapseAll() {
|
|
1839
|
-
this.expandedKeys =
|
|
1847
|
+
this.expandedKeys = Ge(), this.requestRender();
|
|
1840
1848
|
}
|
|
1841
1849
|
/**
|
|
1842
1850
|
* Toggle expansion of a specific group.
|
|
1843
1851
|
* @param key - The group key to toggle
|
|
1844
1852
|
*/
|
|
1845
1853
|
toggle(e) {
|
|
1846
|
-
this.expandedKeys =
|
|
1854
|
+
this.expandedKeys = Ve(this.expandedKeys, e);
|
|
1847
1855
|
const t = this.flattenedRows.find((n) => n.kind === "group" && n.key === e);
|
|
1848
1856
|
this.emit("group-toggle", {
|
|
1849
1857
|
key: e,
|
|
@@ -1973,22 +1981,22 @@ class kt extends y {
|
|
|
1973
1981
|
[data-group-depth="4"] .group-label { padding-left: 80px; }
|
|
1974
1982
|
`;
|
|
1975
1983
|
}
|
|
1976
|
-
function
|
|
1984
|
+
function H(i, e) {
|
|
1977
1985
|
const t = new Set(i);
|
|
1978
1986
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
1979
1987
|
}
|
|
1980
|
-
function
|
|
1988
|
+
function $e(i, e) {
|
|
1981
1989
|
const t = new Set(i);
|
|
1982
1990
|
return t.add(e), t;
|
|
1983
1991
|
}
|
|
1984
|
-
function
|
|
1992
|
+
function je(i, e) {
|
|
1985
1993
|
const t = new Set(i);
|
|
1986
1994
|
return t.delete(e), t;
|
|
1987
1995
|
}
|
|
1988
|
-
function
|
|
1996
|
+
function Ue(i, e) {
|
|
1989
1997
|
return i.has(e);
|
|
1990
1998
|
}
|
|
1991
|
-
function
|
|
1999
|
+
function Ye(i, e, t, n) {
|
|
1992
2000
|
const o = document.createElement("div");
|
|
1993
2001
|
o.className = "master-detail-row", o.setAttribute("data-detail-for", String(e)), o.setAttribute("role", "row");
|
|
1994
2002
|
const r = document.createElement("div");
|
|
@@ -1996,7 +2004,7 @@ function Ue(i, e, t, n) {
|
|
|
1996
2004
|
const s = t(i, e);
|
|
1997
2005
|
return typeof s == "string" ? r.innerHTML = s : s instanceof HTMLElement && r.appendChild(s), o.appendChild(r), o;
|
|
1998
2006
|
}
|
|
1999
|
-
class
|
|
2007
|
+
class At extends y {
|
|
2000
2008
|
name = "masterDetail";
|
|
2001
2009
|
version = "1.0.0";
|
|
2002
2010
|
get defaultConfig() {
|
|
@@ -2025,25 +2033,25 @@ class Et extends y {
|
|
|
2025
2033
|
if (o?.__masterDetailWrapped)
|
|
2026
2034
|
return t;
|
|
2027
2035
|
const r = (s) => {
|
|
2028
|
-
const { value: l, row: a } = s,
|
|
2029
|
-
|
|
2036
|
+
const { value: l, row: a } = s, d = this.expandedRows.has(a), c = document.createElement("span");
|
|
2037
|
+
c.className = "master-detail-cell-wrapper";
|
|
2030
2038
|
const u = document.createElement("span");
|
|
2031
|
-
u.className = "master-detail-toggle", u.
|
|
2039
|
+
u.className = "master-detail-toggle", this.setIcon(u, this.resolveIcon(d ? "collapse" : "expand")), u.setAttribute("aria-expanded", String(d)), u.setAttribute("aria-label", d ? "Collapse details" : "Expand details"), u.addEventListener("click", (f) => {
|
|
2032
2040
|
f.stopPropagation();
|
|
2033
2041
|
const g = this.rows.indexOf(a);
|
|
2034
|
-
this.expandedRows =
|
|
2042
|
+
this.expandedRows = H(this.expandedRows, a), this.emit("detail-expand", {
|
|
2035
2043
|
rowIndex: g,
|
|
2036
2044
|
row: a,
|
|
2037
2045
|
expanded: this.expandedRows.has(a)
|
|
2038
2046
|
}), this.requestRender();
|
|
2039
|
-
}),
|
|
2047
|
+
}), c.appendChild(u);
|
|
2040
2048
|
const h = document.createElement("span");
|
|
2041
2049
|
if (o) {
|
|
2042
2050
|
const f = o(s);
|
|
2043
2051
|
f instanceof Node ? h.appendChild(f) : h.textContent = String(f ?? l ?? "");
|
|
2044
2052
|
} else
|
|
2045
2053
|
h.textContent = String(l ?? "");
|
|
2046
|
-
return
|
|
2054
|
+
return c.appendChild(h), c;
|
|
2047
2055
|
};
|
|
2048
2056
|
r.__masterDetailWrapped = !0, n.viewRenderer = r, t[0] = n;
|
|
2049
2057
|
}
|
|
@@ -2051,27 +2059,111 @@ class Et extends y {
|
|
|
2051
2059
|
}
|
|
2052
2060
|
onRowClick(e) {
|
|
2053
2061
|
if (!(!this.config.expandOnRowClick || !this.config.detailRenderer))
|
|
2054
|
-
return this.expandedRows =
|
|
2062
|
+
return this.expandedRows = H(this.expandedRows, e.row), this.emit("detail-expand", {
|
|
2055
2063
|
rowIndex: e.rowIndex,
|
|
2056
2064
|
row: e.row,
|
|
2057
2065
|
expanded: this.expandedRows.has(e.row)
|
|
2058
2066
|
}), this.requestRender(), !1;
|
|
2059
2067
|
}
|
|
2068
|
+
onCellClick() {
|
|
2069
|
+
this.expandedRows.size > 0 && queueMicrotask(() => this.#e());
|
|
2070
|
+
}
|
|
2060
2071
|
afterRender() {
|
|
2072
|
+
this.#e();
|
|
2073
|
+
}
|
|
2074
|
+
/**
|
|
2075
|
+
* Called on scroll to sync detail elements with visible rows.
|
|
2076
|
+
* Removes details for rows that scrolled out of view and reattaches for visible rows.
|
|
2077
|
+
*/
|
|
2078
|
+
onScrollRender() {
|
|
2079
|
+
!this.config.detailRenderer || this.expandedRows.size === 0 || this.#e();
|
|
2080
|
+
}
|
|
2081
|
+
/**
|
|
2082
|
+
* Full sync of detail rows - cleans up stale elements and creates new ones.
|
|
2083
|
+
* Detail rows are inserted as siblings AFTER their master row to survive row rebuilds.
|
|
2084
|
+
*/
|
|
2085
|
+
#e() {
|
|
2061
2086
|
if (!this.config.detailRenderer) return;
|
|
2062
2087
|
const e = this.shadowRoot?.querySelector(".rows");
|
|
2063
2088
|
if (!e) return;
|
|
2064
|
-
e.querySelectorAll(".
|
|
2065
|
-
const
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
const
|
|
2072
|
-
|
|
2089
|
+
const t = /* @__PURE__ */ new Map(), n = e.querySelectorAll(".data-grid-row"), o = this.columns.length;
|
|
2090
|
+
for (const s of n) {
|
|
2091
|
+
const l = s.querySelector(".cell[data-row]"), a = l ? parseInt(l.getAttribute("data-row") ?? "-1", 10) : -1;
|
|
2092
|
+
a >= 0 && t.set(a, s);
|
|
2093
|
+
}
|
|
2094
|
+
const r = e.querySelectorAll(".master-detail-row");
|
|
2095
|
+
for (const s of r) {
|
|
2096
|
+
const l = parseInt(s.getAttribute("data-detail-for") ?? "-1", 10), a = l >= 0 ? this.rows[l] : void 0, d = a && this.expandedRows.has(a), c = t.has(l);
|
|
2097
|
+
(!d || !c) && (s.remove(), a && this.detailElements.delete(a));
|
|
2098
|
+
}
|
|
2099
|
+
for (const [s, l] of t) {
|
|
2100
|
+
const a = this.rows[s];
|
|
2101
|
+
if (!a || !this.expandedRows.has(a)) continue;
|
|
2102
|
+
const d = this.detailElements.get(a);
|
|
2103
|
+
if (d) {
|
|
2104
|
+
d.previousElementSibling !== l && l.after(d);
|
|
2105
|
+
continue;
|
|
2106
|
+
}
|
|
2107
|
+
const c = Ye(a, s, this.config.detailRenderer, o);
|
|
2108
|
+
typeof this.config.detailHeight == "number" && (c.style.height = `${this.config.detailHeight}px`), l.after(c), this.detailElements.set(a, c);
|
|
2073
2109
|
}
|
|
2074
2110
|
}
|
|
2111
|
+
/**
|
|
2112
|
+
* Return total extra height from all expanded detail rows.
|
|
2113
|
+
* Used by grid virtualization to adjust scrollbar height.
|
|
2114
|
+
*/
|
|
2115
|
+
getExtraHeight() {
|
|
2116
|
+
let e = 0;
|
|
2117
|
+
for (const t of this.expandedRows) {
|
|
2118
|
+
const n = this.detailElements.get(t);
|
|
2119
|
+
if (n)
|
|
2120
|
+
e += n.offsetHeight;
|
|
2121
|
+
else {
|
|
2122
|
+
const o = this.config?.detailHeight;
|
|
2123
|
+
e += typeof o == "number" ? o : 150;
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
return e;
|
|
2127
|
+
}
|
|
2128
|
+
/**
|
|
2129
|
+
* Return extra height that appears before a given row index.
|
|
2130
|
+
* This is the sum of heights of all expanded details whose parent row is before the given index.
|
|
2131
|
+
*/
|
|
2132
|
+
getExtraHeightBefore(e) {
|
|
2133
|
+
let t = 0;
|
|
2134
|
+
for (const n of this.expandedRows) {
|
|
2135
|
+
const o = this.rows.indexOf(n);
|
|
2136
|
+
if (o >= 0 && o < e) {
|
|
2137
|
+
const r = this.detailElements.get(n);
|
|
2138
|
+
if (r)
|
|
2139
|
+
t += r.offsetHeight;
|
|
2140
|
+
else {
|
|
2141
|
+
const s = this.config?.detailHeight;
|
|
2142
|
+
t += typeof s == "number" ? s : 150;
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
return t;
|
|
2147
|
+
}
|
|
2148
|
+
/**
|
|
2149
|
+
* Adjust the virtualization start index to keep expanded row visible while its detail is visible.
|
|
2150
|
+
* This ensures the detail scrolls smoothly out of view instead of disappearing abruptly.
|
|
2151
|
+
*/
|
|
2152
|
+
adjustVirtualStart(e, t, n) {
|
|
2153
|
+
if (this.expandedRows.size === 0) return e;
|
|
2154
|
+
const o = [];
|
|
2155
|
+
for (const l of this.expandedRows) {
|
|
2156
|
+
const a = this.rows.indexOf(l);
|
|
2157
|
+
a >= 0 && o.push({ index: a, row: l });
|
|
2158
|
+
}
|
|
2159
|
+
o.sort((l, a) => l.index - a.index);
|
|
2160
|
+
let r = e, s = 0;
|
|
2161
|
+
for (const { index: l, row: a } of o) {
|
|
2162
|
+
const d = l * n + s, u = this.detailElements.get(a)?.offsetHeight ?? (typeof this.config?.detailHeight == "number" ? this.config.detailHeight : 150), h = d + n + u;
|
|
2163
|
+
s += u, !(l >= e) && h > t && l < r && (r = l);
|
|
2164
|
+
}
|
|
2165
|
+
return r;
|
|
2166
|
+
}
|
|
2075
2167
|
// ===== Public API =====
|
|
2076
2168
|
/**
|
|
2077
2169
|
* Expand the detail row at the given index.
|
|
@@ -2079,7 +2171,7 @@ class Et extends y {
|
|
|
2079
2171
|
*/
|
|
2080
2172
|
expand(e) {
|
|
2081
2173
|
const t = this.rows[e];
|
|
2082
|
-
t && (this.expandedRows =
|
|
2174
|
+
t && (this.expandedRows = $e(this.expandedRows, t), this.requestRender());
|
|
2083
2175
|
}
|
|
2084
2176
|
/**
|
|
2085
2177
|
* Collapse the detail row at the given index.
|
|
@@ -2087,7 +2179,7 @@ class Et extends y {
|
|
|
2087
2179
|
*/
|
|
2088
2180
|
collapse(e) {
|
|
2089
2181
|
const t = this.rows[e];
|
|
2090
|
-
t && (this.expandedRows =
|
|
2182
|
+
t && (this.expandedRows = je(this.expandedRows, t), this.requestRender());
|
|
2091
2183
|
}
|
|
2092
2184
|
/**
|
|
2093
2185
|
* Toggle the detail row at the given index.
|
|
@@ -2095,7 +2187,7 @@ class Et extends y {
|
|
|
2095
2187
|
*/
|
|
2096
2188
|
toggle(e) {
|
|
2097
2189
|
const t = this.rows[e];
|
|
2098
|
-
t && (this.expandedRows =
|
|
2190
|
+
t && (this.expandedRows = H(this.expandedRows, t), this.requestRender());
|
|
2099
2191
|
}
|
|
2100
2192
|
/**
|
|
2101
2193
|
* Check if the detail row at the given index is expanded.
|
|
@@ -2104,7 +2196,7 @@ class Et extends y {
|
|
|
2104
2196
|
*/
|
|
2105
2197
|
isExpanded(e) {
|
|
2106
2198
|
const t = this.rows[e];
|
|
2107
|
-
return t ?
|
|
2199
|
+
return t ? Ue(this.expandedRows, t) : !1;
|
|
2108
2200
|
}
|
|
2109
2201
|
/**
|
|
2110
2202
|
* Expand all detail rows.
|
|
@@ -2169,20 +2261,20 @@ class Et extends y {
|
|
|
2169
2261
|
}
|
|
2170
2262
|
`;
|
|
2171
2263
|
}
|
|
2172
|
-
function
|
|
2264
|
+
function Xe(i, e, t) {
|
|
2173
2265
|
return e.length ? [...i].sort((n, o) => {
|
|
2174
2266
|
for (const r of e) {
|
|
2175
|
-
const l = t.find((u) => u.field === r.field)?.sortComparator ??
|
|
2176
|
-
if (
|
|
2177
|
-
return r.direction === "asc" ?
|
|
2267
|
+
const l = t.find((u) => u.field === r.field)?.sortComparator ?? Je, a = n[r.field], d = o[r.field], c = l(a, d, n, o);
|
|
2268
|
+
if (c !== 0)
|
|
2269
|
+
return r.direction === "asc" ? c : -c;
|
|
2178
2270
|
}
|
|
2179
2271
|
return 0;
|
|
2180
2272
|
}) : [...i];
|
|
2181
2273
|
}
|
|
2182
|
-
function
|
|
2274
|
+
function Je(i, e) {
|
|
2183
2275
|
return i == null && e == null ? 0 : i == null ? 1 : e == null ? -1 : typeof i == "number" && typeof e == "number" ? i - e : i instanceof Date && e instanceof Date ? i.getTime() - e.getTime() : typeof i == "boolean" && typeof e == "boolean" ? i === e ? 0 : i ? -1 : 1 : String(i).localeCompare(String(e));
|
|
2184
2276
|
}
|
|
2185
|
-
function
|
|
2277
|
+
function Qe(i, e, t, n) {
|
|
2186
2278
|
const o = i.find((r) => r.field === e);
|
|
2187
2279
|
return t ? o ? o.direction === "asc" ? i.map((r) => r.field === e ? { ...r, direction: "desc" } : r) : i.filter((r) => r.field !== e) : i.length < n ? [...i, { field: e, direction: "asc" }] : i : o?.direction === "asc" ? [{ field: e, direction: "desc" }] : o?.direction === "desc" ? [] : [{ field: e, direction: "asc" }];
|
|
2188
2280
|
}
|
|
@@ -2193,7 +2285,7 @@ function le(i, e) {
|
|
|
2193
2285
|
function ae(i, e) {
|
|
2194
2286
|
return i.find((t) => t.field === e)?.direction;
|
|
2195
2287
|
}
|
|
2196
|
-
class
|
|
2288
|
+
class It extends y {
|
|
2197
2289
|
name = "multiSort";
|
|
2198
2290
|
version = "1.0.0";
|
|
2199
2291
|
get defaultConfig() {
|
|
@@ -2211,12 +2303,12 @@ class At extends y {
|
|
|
2211
2303
|
}
|
|
2212
2304
|
// ===== Hooks =====
|
|
2213
2305
|
processRows(e) {
|
|
2214
|
-
return this.sortModel.length === 0 ? [...e] :
|
|
2306
|
+
return this.sortModel.length === 0 ? [...e] : Xe([...e], this.sortModel, [...this.columns]);
|
|
2215
2307
|
}
|
|
2216
2308
|
onHeaderClick(e) {
|
|
2217
2309
|
if (!this.columns.find((r) => r.field === e.field)?.sortable) return !1;
|
|
2218
2310
|
const n = e.originalEvent.shiftKey, o = this.config.maxSortColumns ?? 3;
|
|
2219
|
-
return this.sortModel =
|
|
2311
|
+
return this.sortModel = Qe(this.sortModel, e.field, n, o), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), !0;
|
|
2220
2312
|
}
|
|
2221
2313
|
afterRender() {
|
|
2222
2314
|
const e = this.shadowRoot;
|
|
@@ -2228,8 +2320,8 @@ class At extends y {
|
|
|
2228
2320
|
const s = le(this.sortModel, r), l = ae(this.sortModel, r);
|
|
2229
2321
|
if (o.querySelector(".sort-index")?.remove(), l) {
|
|
2230
2322
|
o.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), o.setAttribute("data-sort", l);
|
|
2231
|
-
const
|
|
2232
|
-
if (
|
|
2323
|
+
const c = document.createElement("span");
|
|
2324
|
+
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 && s !== void 0) {
|
|
2233
2325
|
const u = document.createElement("span");
|
|
2234
2326
|
u.className = "sort-index", u.textContent = String(s), o.appendChild(u);
|
|
2235
2327
|
}
|
|
@@ -2329,13 +2421,13 @@ class At extends y {
|
|
|
2329
2421
|
}
|
|
2330
2422
|
`;
|
|
2331
2423
|
}
|
|
2332
|
-
function
|
|
2424
|
+
function Ze(i) {
|
|
2333
2425
|
return i.filter((e) => e.sticky === "left");
|
|
2334
2426
|
}
|
|
2335
|
-
function
|
|
2427
|
+
function et(i) {
|
|
2336
2428
|
return i.filter((e) => e.sticky === "right");
|
|
2337
2429
|
}
|
|
2338
|
-
function
|
|
2430
|
+
function O(i) {
|
|
2339
2431
|
return i.some((e) => e.sticky === "left" || e.sticky === "right");
|
|
2340
2432
|
}
|
|
2341
2433
|
function de(i, e) {
|
|
@@ -2350,18 +2442,18 @@ function de(i, e) {
|
|
|
2350
2442
|
let r = 0;
|
|
2351
2443
|
for (const l of e)
|
|
2352
2444
|
if (l.sticky === "left") {
|
|
2353
|
-
const a = o.get(l.field),
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
}), r +=
|
|
2445
|
+
const a = o.get(l.field), d = n.find((c) => c.getAttribute("data-field") === l.field);
|
|
2446
|
+
d && (d.classList.add("sticky-left"), d.style.left = r + "px", a !== void 0 && t.querySelectorAll(`.data-grid-row .cell[data-col="${a}"]`).forEach((c) => {
|
|
2447
|
+
c.classList.add("sticky-left"), c.style.left = r + "px";
|
|
2448
|
+
}), r += d.offsetWidth);
|
|
2357
2449
|
}
|
|
2358
2450
|
let s = 0;
|
|
2359
2451
|
for (const l of [...e].reverse())
|
|
2360
2452
|
if (l.sticky === "right") {
|
|
2361
|
-
const a = o.get(l.field),
|
|
2362
|
-
|
|
2363
|
-
|
|
2364
|
-
}), s +=
|
|
2453
|
+
const a = o.get(l.field), d = n.find((c) => c.getAttribute("data-field") === l.field);
|
|
2454
|
+
d && (d.classList.add("sticky-right"), d.style.right = s + "px", a !== void 0 && t.querySelectorAll(`.data-grid-row .cell[data-col="${a}"]`).forEach((c) => {
|
|
2455
|
+
c.classList.add("sticky-right"), c.style.right = s + "px";
|
|
2456
|
+
}), s += d.offsetWidth);
|
|
2365
2457
|
}
|
|
2366
2458
|
}
|
|
2367
2459
|
function ce(i) {
|
|
@@ -2393,17 +2485,17 @@ class _t extends y {
|
|
|
2393
2485
|
*/
|
|
2394
2486
|
static detect(e, t) {
|
|
2395
2487
|
const n = t?.columns;
|
|
2396
|
-
return Array.isArray(n) ?
|
|
2488
|
+
return Array.isArray(n) ? O(n) : !1;
|
|
2397
2489
|
}
|
|
2398
2490
|
// ===== Hooks =====
|
|
2399
2491
|
processColumns(e) {
|
|
2400
|
-
return this.config.enabled ? (this.isApplied =
|
|
2492
|
+
return this.config.enabled ? (this.isApplied = O([...e]), [...e]) : (this.isApplied = !1, [...e]);
|
|
2401
2493
|
}
|
|
2402
2494
|
afterRender() {
|
|
2403
2495
|
if (!this.config.enabled || !this.isApplied)
|
|
2404
2496
|
return;
|
|
2405
2497
|
const e = this.grid, t = [...this.columns];
|
|
2406
|
-
if (!
|
|
2498
|
+
if (!O(t)) {
|
|
2407
2499
|
ce(e), this.isApplied = !1;
|
|
2408
2500
|
return;
|
|
2409
2501
|
}
|
|
@@ -2424,14 +2516,14 @@ class _t extends y {
|
|
|
2424
2516
|
*/
|
|
2425
2517
|
getLeftPinnedColumns() {
|
|
2426
2518
|
const e = [...this.columns];
|
|
2427
|
-
return
|
|
2519
|
+
return Ze(e);
|
|
2428
2520
|
}
|
|
2429
2521
|
/**
|
|
2430
2522
|
* Get columns pinned to the right.
|
|
2431
2523
|
*/
|
|
2432
2524
|
getRightPinnedColumns() {
|
|
2433
2525
|
const e = [...this.columns];
|
|
2434
|
-
return
|
|
2526
|
+
return et(e);
|
|
2435
2527
|
}
|
|
2436
2528
|
/**
|
|
2437
2529
|
* Clear all sticky positioning.
|
|
@@ -2462,7 +2554,7 @@ function W(i, e) {
|
|
|
2462
2554
|
}
|
|
2463
2555
|
if (i.customPanels)
|
|
2464
2556
|
for (const s of i.customPanels) {
|
|
2465
|
-
const l =
|
|
2557
|
+
const l = tt(s, e);
|
|
2466
2558
|
switch (s.position) {
|
|
2467
2559
|
case "left":
|
|
2468
2560
|
n.appendChild(l);
|
|
@@ -2493,20 +2585,20 @@ function he(i, e, t, n) {
|
|
|
2493
2585
|
const l = document.createElement("div");
|
|
2494
2586
|
l.className = "tbw-aggregation-cell", l.setAttribute("data-field", s.field);
|
|
2495
2587
|
let a;
|
|
2496
|
-
const
|
|
2497
|
-
if (
|
|
2498
|
-
const
|
|
2499
|
-
|
|
2588
|
+
const d = o.aggregators?.[s.field];
|
|
2589
|
+
if (d) {
|
|
2590
|
+
const c = ve(d);
|
|
2591
|
+
c && (a = c(n, s.field, s));
|
|
2500
2592
|
} else if (o.cells && Object.prototype.hasOwnProperty.call(o.cells, s.field)) {
|
|
2501
|
-
const
|
|
2502
|
-
typeof
|
|
2593
|
+
const c = o.cells[s.field];
|
|
2594
|
+
typeof c == "function" ? a = c(n, s.field, s) : a = c;
|
|
2503
2595
|
}
|
|
2504
2596
|
l.textContent = a != null ? String(a) : "", r.appendChild(l);
|
|
2505
2597
|
}
|
|
2506
2598
|
i.appendChild(r);
|
|
2507
2599
|
}
|
|
2508
2600
|
}
|
|
2509
|
-
function
|
|
2601
|
+
function tt(i, e) {
|
|
2510
2602
|
const t = document.createElement("div");
|
|
2511
2603
|
t.className = "tbw-status-panel tbw-status-panel-custom", t.id = `status-panel-${i.id}`;
|
|
2512
2604
|
const n = i.render(e);
|
|
@@ -2522,7 +2614,7 @@ function fe(i, e, t, n, o) {
|
|
|
2522
2614
|
grid: t
|
|
2523
2615
|
};
|
|
2524
2616
|
}
|
|
2525
|
-
class
|
|
2617
|
+
class Tt extends y {
|
|
2526
2618
|
name = "pinnedRows";
|
|
2527
2619
|
version = "1.0.0";
|
|
2528
2620
|
get defaultConfig() {
|
|
@@ -2573,8 +2665,8 @@ class It extends y {
|
|
|
2573
2665
|
this.rows
|
|
2574
2666
|
);
|
|
2575
2667
|
} else this.topAggregationContainer && (this.topAggregationContainer.remove(), this.topAggregationContainer = null);
|
|
2576
|
-
const
|
|
2577
|
-
if (
|
|
2668
|
+
const d = this.config.showRowCount !== !1 || this.config.showSelectedCount && r.selectedRows > 0 || this.config.showFilteredCount && r.filteredRows !== r.totalRows || this.config.customPanels && this.config.customPanels.length > 0, c = d && this.config.position !== "top", u = a.length > 0 || c;
|
|
2669
|
+
if (d && this.config.position === "top")
|
|
2578
2670
|
if (!this.infoBarElement)
|
|
2579
2671
|
this.infoBarElement = W(this.config, r), t.insertBefore(this.infoBarElement, t.firstChild);
|
|
2580
2672
|
else {
|
|
@@ -2587,7 +2679,7 @@ class It extends y {
|
|
|
2587
2679
|
a,
|
|
2588
2680
|
this.visibleColumns,
|
|
2589
2681
|
this.rows
|
|
2590
|
-
)),
|
|
2682
|
+
)), c && (this.infoBarElement = W(this.config, r), this.footerWrapper.appendChild(this.infoBarElement))) : this.cleanupFooter();
|
|
2591
2683
|
}
|
|
2592
2684
|
// ===== Private Methods =====
|
|
2593
2685
|
cleanup() {
|
|
@@ -2733,11 +2825,11 @@ class It extends y {
|
|
|
2733
2825
|
}
|
|
2734
2826
|
`;
|
|
2735
2827
|
}
|
|
2736
|
-
function
|
|
2828
|
+
function nt(i) {
|
|
2737
2829
|
const e = [];
|
|
2738
2830
|
return !i.rowGroupFields?.length && !i.columnGroupFields?.length && e.push("At least one row or column group field is required"), i.valueFields?.length || e.push("At least one value field is required"), e;
|
|
2739
2831
|
}
|
|
2740
|
-
function
|
|
2832
|
+
function ot(i) {
|
|
2741
2833
|
switch (i) {
|
|
2742
2834
|
case "sum":
|
|
2743
2835
|
return (e) => e.reduce((t, n) => t + n, 0);
|
|
@@ -2760,16 +2852,16 @@ function nt(i) {
|
|
|
2760
2852
|
function $(i, e) {
|
|
2761
2853
|
return [...i, e].join("|");
|
|
2762
2854
|
}
|
|
2763
|
-
function
|
|
2764
|
-
const t = e.rowGroupFields ?? [], n = e.columnGroupFields ?? [], o = e.valueFields ?? [], r =
|
|
2855
|
+
function rt(i, e) {
|
|
2856
|
+
const t = e.rowGroupFields ?? [], n = e.columnGroupFields ?? [], o = e.valueFields ?? [], r = it(i, n), s = st(i, t), l = lt(s, n, r, o, 0), a = at(l, r, o), d = Object.values(a).reduce((c, u) => c + u, 0);
|
|
2765
2857
|
return {
|
|
2766
2858
|
rows: l,
|
|
2767
2859
|
columnKeys: r,
|
|
2768
2860
|
totals: a,
|
|
2769
|
-
grandTotal:
|
|
2861
|
+
grandTotal: d
|
|
2770
2862
|
};
|
|
2771
2863
|
}
|
|
2772
|
-
function
|
|
2864
|
+
function it(i, e) {
|
|
2773
2865
|
if (e.length === 0) return ["value"];
|
|
2774
2866
|
const t = /* @__PURE__ */ new Set();
|
|
2775
2867
|
for (const n of i) {
|
|
@@ -2778,7 +2870,7 @@ function rt(i, e) {
|
|
|
2778
2870
|
}
|
|
2779
2871
|
return [...t].sort();
|
|
2780
2872
|
}
|
|
2781
|
-
function
|
|
2873
|
+
function st(i, e) {
|
|
2782
2874
|
const t = /* @__PURE__ */ new Map();
|
|
2783
2875
|
for (const n of i) {
|
|
2784
2876
|
const o = e.map((s) => String(n[s] ?? "")).join("|");
|
|
@@ -2788,28 +2880,28 @@ function it(i, e) {
|
|
|
2788
2880
|
}
|
|
2789
2881
|
return t;
|
|
2790
2882
|
}
|
|
2791
|
-
function
|
|
2883
|
+
function lt(i, e, t, n, o) {
|
|
2792
2884
|
const r = [];
|
|
2793
2885
|
for (const [s, l] of i) {
|
|
2794
2886
|
const a = {};
|
|
2795
|
-
let
|
|
2796
|
-
for (const
|
|
2887
|
+
let d = 0;
|
|
2888
|
+
for (const c of t)
|
|
2797
2889
|
for (const u of n) {
|
|
2798
|
-
const f = (e.length > 0 ? l.filter((S) => e.map((R) => String(S[R] ?? "")).join("|") ===
|
|
2799
|
-
a[b] = m, m !== null && (
|
|
2890
|
+
const f = (e.length > 0 ? l.filter((S) => e.map((R) => String(S[R] ?? "")).join("|") === c) : l).map((S) => Number(S[u.field]) || 0), g = ot(u.aggFunc), m = f.length > 0 ? g(f) : null, b = $([c], u.field);
|
|
2891
|
+
a[b] = m, m !== null && (d += m);
|
|
2800
2892
|
}
|
|
2801
2893
|
r.push({
|
|
2802
2894
|
rowKey: s,
|
|
2803
2895
|
rowLabel: s || "(blank)",
|
|
2804
2896
|
depth: o,
|
|
2805
2897
|
values: a,
|
|
2806
|
-
total:
|
|
2898
|
+
total: d,
|
|
2807
2899
|
isGroup: !1
|
|
2808
2900
|
});
|
|
2809
2901
|
}
|
|
2810
2902
|
return r;
|
|
2811
2903
|
}
|
|
2812
|
-
function
|
|
2904
|
+
function at(i, e, t) {
|
|
2813
2905
|
const n = {};
|
|
2814
2906
|
for (const o of e)
|
|
2815
2907
|
for (const r of t) {
|
|
@@ -2818,7 +2910,7 @@ function lt(i, e, t) {
|
|
|
2818
2910
|
}
|
|
2819
2911
|
return n;
|
|
2820
2912
|
}
|
|
2821
|
-
function
|
|
2913
|
+
function dt(i) {
|
|
2822
2914
|
const e = [];
|
|
2823
2915
|
function t(n) {
|
|
2824
2916
|
if (e.push(n), n.children)
|
|
@@ -2829,7 +2921,7 @@ function at(i) {
|
|
|
2829
2921
|
t(n);
|
|
2830
2922
|
return e;
|
|
2831
2923
|
}
|
|
2832
|
-
class
|
|
2924
|
+
class Lt extends y {
|
|
2833
2925
|
name = "pivot";
|
|
2834
2926
|
version = "1.0.0";
|
|
2835
2927
|
get defaultConfig() {
|
|
@@ -2852,8 +2944,8 @@ class Tt extends y {
|
|
|
2852
2944
|
processRows(e) {
|
|
2853
2945
|
if (!this.config.enabled || !this.isActive)
|
|
2854
2946
|
return [...e];
|
|
2855
|
-
const t =
|
|
2856
|
-
return t.length > 0 ? (this.warn(`Config errors: ${t.join(", ")}`), [...e]) : (this.pivotResult =
|
|
2947
|
+
const t = nt(this.config);
|
|
2948
|
+
return t.length > 0 ? (this.warn(`Config errors: ${t.join(", ")}`), [...e]) : (this.pivotResult = rt(e, this.config), dt(this.pivotResult.rows).map((n) => ({
|
|
2857
2949
|
__pivotRowKey: n.rowKey,
|
|
2858
2950
|
__pivotLabel: n.rowLabel,
|
|
2859
2951
|
__pivotDepth: n.depth,
|
|
@@ -2949,7 +3041,7 @@ class Tt extends y {
|
|
|
2949
3041
|
.pivot-total-row { font-weight: bold; border-top: 2px solid var(--tbw-pivot-border, var(--tbw-color-border-strong)); }
|
|
2950
3042
|
`;
|
|
2951
3043
|
}
|
|
2952
|
-
function
|
|
3044
|
+
function ct(i) {
|
|
2953
3045
|
const e = i.sticky;
|
|
2954
3046
|
if (e === "left" || e === "right")
|
|
2955
3047
|
return !1;
|
|
@@ -2961,7 +3053,7 @@ function ge(i, e, t) {
|
|
|
2961
3053
|
const n = [...i], [o] = n.splice(e, 1);
|
|
2962
3054
|
return n.splice(t, 0, o), n;
|
|
2963
3055
|
}
|
|
2964
|
-
class
|
|
3056
|
+
class Mt extends y {
|
|
2965
3057
|
name = "reorder";
|
|
2966
3058
|
version = "1.0.0";
|
|
2967
3059
|
get defaultConfig() {
|
|
@@ -3000,31 +3092,31 @@ class Lt extends y {
|
|
|
3000
3092
|
const o = n, r = o.getAttribute("data-field");
|
|
3001
3093
|
if (!r) return;
|
|
3002
3094
|
const s = this.columns.find((l) => l.field === r);
|
|
3003
|
-
if (!s || !
|
|
3095
|
+
if (!s || !ct(s)) {
|
|
3004
3096
|
o.draggable = !1;
|
|
3005
3097
|
return;
|
|
3006
3098
|
}
|
|
3007
3099
|
o.draggable = !0, !o.getAttribute("data-dragstart-bound") && (o.setAttribute("data-dragstart-bound", "true"), o.addEventListener("dragstart", (l) => {
|
|
3008
|
-
const
|
|
3009
|
-
this.isDragging = !0, this.draggedField = r, this.draggedIndex =
|
|
3100
|
+
const d = this.getColumnOrder().indexOf(r);
|
|
3101
|
+
this.isDragging = !0, this.draggedField = r, this.draggedIndex = d, l.dataTransfer && (l.dataTransfer.effectAllowed = "move", l.dataTransfer.setData("text/plain", r)), o.classList.add("dragging");
|
|
3010
3102
|
}), o.addEventListener("dragend", () => {
|
|
3011
3103
|
this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, e.querySelectorAll(".header-row > .cell").forEach((l) => {
|
|
3012
3104
|
l.classList.remove("dragging", "drop-target", "drop-before", "drop-after");
|
|
3013
3105
|
});
|
|
3014
3106
|
}), o.addEventListener("dragover", (l) => {
|
|
3015
3107
|
if (l.preventDefault(), !this.isDragging || this.draggedField === r) return;
|
|
3016
|
-
const a = o.getBoundingClientRect(),
|
|
3017
|
-
this.dropIndex = l.clientX <
|
|
3108
|
+
const a = o.getBoundingClientRect(), d = a.left + a.width / 2, u = this.getColumnOrder().indexOf(r);
|
|
3109
|
+
this.dropIndex = l.clientX < d ? u : u + 1, o.classList.add("drop-target"), o.classList.toggle("drop-before", l.clientX < d), o.classList.toggle("drop-after", l.clientX >= d);
|
|
3018
3110
|
}), o.addEventListener("dragleave", () => {
|
|
3019
3111
|
o.classList.remove("drop-target", "drop-before", "drop-after");
|
|
3020
3112
|
}), o.addEventListener("drop", (l) => {
|
|
3021
3113
|
l.preventDefault();
|
|
3022
|
-
const a = this.draggedField,
|
|
3023
|
-
if (!this.isDragging || a === null ||
|
|
3114
|
+
const a = this.draggedField, d = this.draggedIndex, c = this.dropIndex;
|
|
3115
|
+
if (!this.isDragging || a === null || d === null || c === null)
|
|
3024
3116
|
return;
|
|
3025
|
-
const u =
|
|
3117
|
+
const u = c > d ? c - 1 : c, h = this.getColumnOrder(), f = ge(h, d, u), g = {
|
|
3026
3118
|
field: a,
|
|
3027
|
-
fromIndex:
|
|
3119
|
+
fromIndex: d,
|
|
3028
3120
|
toIndex: u,
|
|
3029
3121
|
columnOrder: f
|
|
3030
3122
|
};
|
|
@@ -3105,20 +3197,20 @@ class Lt extends y {
|
|
|
3105
3197
|
function M(i, e) {
|
|
3106
3198
|
return Math.floor(i / e);
|
|
3107
3199
|
}
|
|
3108
|
-
function
|
|
3200
|
+
function ut(i, e) {
|
|
3109
3201
|
return {
|
|
3110
3202
|
start: i * e,
|
|
3111
3203
|
end: (i + 1) * e
|
|
3112
3204
|
};
|
|
3113
3205
|
}
|
|
3114
|
-
function
|
|
3206
|
+
function ht(i, e, t) {
|
|
3115
3207
|
const n = M(i, t), o = M(e - 1, t), r = [];
|
|
3116
3208
|
for (let s = n; s <= o; s++)
|
|
3117
3209
|
r.push(s);
|
|
3118
3210
|
return r;
|
|
3119
3211
|
}
|
|
3120
3212
|
async function pe(i, e, t, n) {
|
|
3121
|
-
const o =
|
|
3213
|
+
const o = ut(e, t);
|
|
3122
3214
|
return i.getRows({
|
|
3123
3215
|
startRow: o.start,
|
|
3124
3216
|
endRow: o.end,
|
|
@@ -3126,14 +3218,14 @@ async function pe(i, e, t, n) {
|
|
|
3126
3218
|
filterModel: n.filterModel
|
|
3127
3219
|
});
|
|
3128
3220
|
}
|
|
3129
|
-
function
|
|
3221
|
+
function ft(i, e, t) {
|
|
3130
3222
|
const n = M(i, e), o = t.get(n);
|
|
3131
3223
|
if (!o) return;
|
|
3132
3224
|
const r = i % e;
|
|
3133
3225
|
return o[r];
|
|
3134
3226
|
}
|
|
3135
|
-
const
|
|
3136
|
-
class
|
|
3227
|
+
const gt = 100;
|
|
3228
|
+
class qt extends y {
|
|
3137
3229
|
name = "serverSide";
|
|
3138
3230
|
version = "1.0.0";
|
|
3139
3231
|
get defaultConfig() {
|
|
@@ -3161,7 +3253,7 @@ class Mt extends y {
|
|
|
3161
3253
|
*/
|
|
3162
3254
|
loadRequiredBlocks() {
|
|
3163
3255
|
if (!this.dataSource) return;
|
|
3164
|
-
const e = this.grid, t = this.config.cacheBlockSize ?? 100, n = { startRow: e.virtualization.start, endRow: e.virtualization.end }, o =
|
|
3256
|
+
const e = this.grid, t = this.config.cacheBlockSize ?? 100, n = { startRow: e.virtualization.start, endRow: e.virtualization.end }, o = ht(n.startRow, n.endRow, t);
|
|
3165
3257
|
for (const r of o)
|
|
3166
3258
|
if (!(this.loadedBlocks.has(r) || this.loadingBlocks.has(r))) {
|
|
3167
3259
|
if (this.loadingBlocks.size >= (this.config.maxConcurrentRequests ?? 2))
|
|
@@ -3178,7 +3270,7 @@ class Mt extends y {
|
|
|
3178
3270
|
if (!this.dataSource) return [...e];
|
|
3179
3271
|
const t = [];
|
|
3180
3272
|
for (let n = 0; n < this.totalRowCount; n++) {
|
|
3181
|
-
const o =
|
|
3273
|
+
const o = ft(n, this.config.cacheBlockSize ?? 100, this.loadedBlocks);
|
|
3182
3274
|
t.push(o ?? { __loading: !0, __index: n });
|
|
3183
3275
|
}
|
|
3184
3276
|
return t;
|
|
@@ -3186,7 +3278,7 @@ class Mt extends y {
|
|
|
3186
3278
|
onScroll(e) {
|
|
3187
3279
|
this.dataSource && (this.loadRequiredBlocks(), this.scrollDebounceTimer && clearTimeout(this.scrollDebounceTimer), this.scrollDebounceTimer = setTimeout(() => {
|
|
3188
3280
|
this.loadRequiredBlocks();
|
|
3189
|
-
},
|
|
3281
|
+
}, gt));
|
|
3190
3282
|
}
|
|
3191
3283
|
// ===== Public API =====
|
|
3192
3284
|
/**
|
|
@@ -3233,7 +3325,7 @@ class Mt extends y {
|
|
|
3233
3325
|
return this.loadedBlocks.size;
|
|
3234
3326
|
}
|
|
3235
3327
|
}
|
|
3236
|
-
function
|
|
3328
|
+
function pt(i, e, t) {
|
|
3237
3329
|
const n = [...i.undoStack, e];
|
|
3238
3330
|
for (; n.length > t; )
|
|
3239
3331
|
n.shift();
|
|
@@ -3267,16 +3359,16 @@ function be(i) {
|
|
|
3267
3359
|
action: t
|
|
3268
3360
|
} : { newState: i, action: null };
|
|
3269
3361
|
}
|
|
3270
|
-
function
|
|
3362
|
+
function mt(i) {
|
|
3271
3363
|
return i.undoStack.length > 0;
|
|
3272
3364
|
}
|
|
3273
|
-
function
|
|
3365
|
+
function bt(i) {
|
|
3274
3366
|
return i.redoStack.length > 0;
|
|
3275
3367
|
}
|
|
3276
|
-
function
|
|
3368
|
+
function wt() {
|
|
3277
3369
|
return { undoStack: [], redoStack: [] };
|
|
3278
3370
|
}
|
|
3279
|
-
function
|
|
3371
|
+
function xt(i, e, t, n) {
|
|
3280
3372
|
return {
|
|
3281
3373
|
type: "cell-edit",
|
|
3282
3374
|
rowIndex: i,
|
|
@@ -3286,7 +3378,7 @@ function wt(i, e, t, n) {
|
|
|
3286
3378
|
timestamp: Date.now()
|
|
3287
3379
|
};
|
|
3288
3380
|
}
|
|
3289
|
-
class
|
|
3381
|
+
class Ft extends y {
|
|
3290
3382
|
name = "undoRedo";
|
|
3291
3383
|
version = "1.0.0";
|
|
3292
3384
|
get defaultConfig() {
|
|
@@ -3347,7 +3439,7 @@ class qt extends y {
|
|
|
3347
3439
|
* @param newValue - The value after the edit
|
|
3348
3440
|
*/
|
|
3349
3441
|
recordEdit(e, t, n, o) {
|
|
3350
|
-
const r =
|
|
3442
|
+
const r = xt(e, t, n, o), s = pt(
|
|
3351
3443
|
{ undoStack: this.undoStack, redoStack: this.redoStack },
|
|
3352
3444
|
r,
|
|
3353
3445
|
this.config.maxHistorySize ?? 100
|
|
@@ -3384,19 +3476,19 @@ class qt extends y {
|
|
|
3384
3476
|
* Check if there are any actions that can be undone.
|
|
3385
3477
|
*/
|
|
3386
3478
|
canUndo() {
|
|
3387
|
-
return
|
|
3479
|
+
return mt({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
3388
3480
|
}
|
|
3389
3481
|
/**
|
|
3390
3482
|
* Check if there are any actions that can be redone.
|
|
3391
3483
|
*/
|
|
3392
3484
|
canRedo() {
|
|
3393
|
-
return
|
|
3485
|
+
return bt({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
3394
3486
|
}
|
|
3395
3487
|
/**
|
|
3396
3488
|
* Clear all undo/redo history.
|
|
3397
3489
|
*/
|
|
3398
3490
|
clearHistory() {
|
|
3399
|
-
const e =
|
|
3491
|
+
const e = wt();
|
|
3400
3492
|
this.undoStack = e.undoStack, this.redoStack = e.redoStack;
|
|
3401
3493
|
}
|
|
3402
3494
|
/**
|
|
@@ -3416,7 +3508,7 @@ function we(i) {
|
|
|
3416
3508
|
const e = i.meta ?? {};
|
|
3417
3509
|
return e.lockPosition !== !0 && e.suppressMovable !== !0;
|
|
3418
3510
|
}
|
|
3419
|
-
class
|
|
3511
|
+
class I extends y {
|
|
3420
3512
|
name = "visibility";
|
|
3421
3513
|
version = "1.0.0";
|
|
3422
3514
|
/** Tool panel ID for shell integration */
|
|
@@ -3445,7 +3537,7 @@ class _ extends y {
|
|
|
3445
3537
|
getToolPanel() {
|
|
3446
3538
|
if (this.config.enabled)
|
|
3447
3539
|
return {
|
|
3448
|
-
id:
|
|
3540
|
+
id: I.PANEL_ID,
|
|
3449
3541
|
title: "Columns",
|
|
3450
3542
|
icon: "☰",
|
|
3451
3543
|
tooltip: "Column visibility",
|
|
@@ -3459,7 +3551,7 @@ class _ extends y {
|
|
|
3459
3551
|
* Show the visibility sidebar panel.
|
|
3460
3552
|
*/
|
|
3461
3553
|
show() {
|
|
3462
|
-
this.grid.openToolPanel(
|
|
3554
|
+
this.grid.openToolPanel(I.PANEL_ID);
|
|
3463
3555
|
}
|
|
3464
3556
|
/**
|
|
3465
3557
|
* Hide the visibility sidebar panel.
|
|
@@ -3471,7 +3563,7 @@ class _ extends y {
|
|
|
3471
3563
|
* Toggle the visibility sidebar panel.
|
|
3472
3564
|
*/
|
|
3473
3565
|
toggle() {
|
|
3474
|
-
this.grid.toggleToolPanel(
|
|
3566
|
+
this.grid.toggleToolPanel(I.PANEL_ID);
|
|
3475
3567
|
}
|
|
3476
3568
|
/**
|
|
3477
3569
|
* Check if a specific column is visible.
|
|
@@ -3549,7 +3641,7 @@ class _ extends y {
|
|
|
3549
3641
|
* @returns True if the panel is open
|
|
3550
3642
|
*/
|
|
3551
3643
|
isPanelVisible() {
|
|
3552
|
-
return this.grid.activeToolPanel ===
|
|
3644
|
+
return this.grid.activeToolPanel === I.PANEL_ID;
|
|
3553
3645
|
}
|
|
3554
3646
|
// ===== Private Methods =====
|
|
3555
3647
|
/**
|
|
@@ -3586,18 +3678,18 @@ class _ extends y {
|
|
|
3586
3678
|
for (let r = 0; r < o.length; r++) {
|
|
3587
3679
|
const s = o[r], l = s.header || s.field, a = document.createElement("div");
|
|
3588
3680
|
a.className = s.lockVisible ? "tbw-visibility-row locked" : "tbw-visibility-row", a.setAttribute("data-field", s.field), a.setAttribute("data-index", String(r)), n && we(s) && (a.draggable = !0, a.classList.add("reorderable"), this.setupDragListeners(a, s.field, r, e));
|
|
3589
|
-
const
|
|
3590
|
-
|
|
3591
|
-
const
|
|
3592
|
-
|
|
3681
|
+
const d = document.createElement("label");
|
|
3682
|
+
d.className = "tbw-visibility-label";
|
|
3683
|
+
const c = document.createElement("input");
|
|
3684
|
+
c.type = "checkbox", c.checked = s.visible, c.disabled = s.lockVisible ?? !1, c.addEventListener("change", () => {
|
|
3593
3685
|
t.toggleColumnVisibility(s.field), setTimeout(() => this.rebuildToggles(e), 0);
|
|
3594
3686
|
});
|
|
3595
3687
|
const u = document.createElement("span");
|
|
3596
|
-
if (u.textContent = l,
|
|
3688
|
+
if (u.textContent = l, d.appendChild(c), d.appendChild(u), n && we(s)) {
|
|
3597
3689
|
const h = document.createElement("span");
|
|
3598
|
-
h.className = "tbw-visibility-handle", h.
|
|
3690
|
+
h.className = "tbw-visibility-handle", this.setIcon(h, this.resolveIcon("dragHandle")), h.title = "Drag to reorder", a.appendChild(h);
|
|
3599
3691
|
}
|
|
3600
|
-
a.appendChild(
|
|
3692
|
+
a.appendChild(d), e.appendChild(a);
|
|
3601
3693
|
}
|
|
3602
3694
|
}
|
|
3603
3695
|
/**
|
|
@@ -3624,14 +3716,14 @@ class _ extends y {
|
|
|
3624
3716
|
const s = this.draggedField, l = this.draggedIndex, a = this.dropIndex;
|
|
3625
3717
|
if (!this.isDragging || s === null || l === null || a === null)
|
|
3626
3718
|
return;
|
|
3627
|
-
const
|
|
3628
|
-
if (
|
|
3629
|
-
const
|
|
3719
|
+
const d = a > l ? a - 1 : a;
|
|
3720
|
+
if (d !== l) {
|
|
3721
|
+
const c = {
|
|
3630
3722
|
field: s,
|
|
3631
3723
|
fromIndex: l,
|
|
3632
|
-
toIndex:
|
|
3724
|
+
toIndex: d
|
|
3633
3725
|
};
|
|
3634
|
-
this.emit("column-reorder-request",
|
|
3726
|
+
this.emit("column-reorder-request", c), setTimeout(() => {
|
|
3635
3727
|
this.rebuildToggles(o);
|
|
3636
3728
|
}, 0);
|
|
3637
3729
|
}
|
|
@@ -3734,32 +3826,40 @@ class _ extends y {
|
|
|
3734
3826
|
}
|
|
3735
3827
|
export {
|
|
3736
3828
|
y as BaseGridPlugin,
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3829
|
+
yt as ClipboardPlugin,
|
|
3830
|
+
Ct as ColumnVirtualizationPlugin,
|
|
3831
|
+
St as ContextMenuPlugin,
|
|
3832
|
+
xe as DEFAULT_GRID_ICONS,
|
|
3740
3833
|
Pt as DGEvents,
|
|
3741
|
-
|
|
3742
|
-
|
|
3834
|
+
Bt as DataGridElement,
|
|
3835
|
+
Rt as ExportPlugin,
|
|
3743
3836
|
E as FilteringPlugin,
|
|
3744
|
-
|
|
3837
|
+
Ht as FitModeEnum,
|
|
3745
3838
|
Ot as GridCSSVars,
|
|
3746
|
-
|
|
3747
|
-
|
|
3839
|
+
Wt as GridClasses,
|
|
3840
|
+
Vt as GridDataAttrs,
|
|
3748
3841
|
Kt as GridElement,
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3842
|
+
Gt as GridSelectors,
|
|
3843
|
+
kt as GroupingColumnsPlugin,
|
|
3844
|
+
Et as GroupingRowsPlugin,
|
|
3845
|
+
At as MasterDetailPlugin,
|
|
3846
|
+
It as MultiSortPlugin,
|
|
3754
3847
|
_t as PinnedColumnsPlugin,
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3848
|
+
Tt as PinnedRowsPlugin,
|
|
3849
|
+
Lt as PivotPlugin,
|
|
3850
|
+
zt as PluginEvents,
|
|
3851
|
+
$t as PluginManager,
|
|
3852
|
+
Mt as ReorderPlugin,
|
|
3853
|
+
jt as SelectionPlugin,
|
|
3854
|
+
qt as ServerSidePlugin,
|
|
3855
|
+
Ut as TreePlugin,
|
|
3856
|
+
Ft as UndoRedoPlugin,
|
|
3857
|
+
I as VisibilityPlugin,
|
|
3858
|
+
Yt as aggregatorRegistry,
|
|
3859
|
+
ve as getAggregator,
|
|
3860
|
+
Xt as listAggregators,
|
|
3861
|
+
Jt as registerAggregator,
|
|
3862
|
+
X as runAggregator,
|
|
3863
|
+
Qt as unregisterAggregator
|
|
3764
3864
|
};
|
|
3765
3865
|
//# sourceMappingURL=all.js.map
|