@toolbox-web/grid 0.0.4 → 0.0.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/README.md +24 -0
- package/all.d.ts +1709 -135
- package/all.js +745 -645
- package/all.js.map +1 -1
- package/index.d.ts +161 -1
- package/index.js +1050 -913
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js +110 -52
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +78 -20
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +163 -95
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js +93 -35
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +188 -133
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +69 -11
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +111 -55
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +196 -51
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +104 -46
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +74 -16
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +65 -7
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +117 -59
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +103 -45
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +139 -81
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +96 -38
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +108 -47
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +70 -12
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +82 -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 +15 -15
- 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/filtering.umd.js +3 -3
- package/umd/plugins/filtering.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/reorder.umd.js +1 -1
- package/umd/plugins/reorder.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,33 +1,33 @@
|
|
|
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 "";
|
|
7
7
|
if (i instanceof Date) return i.toISOString();
|
|
8
8
|
if (typeof i == "object") return JSON.stringify(i);
|
|
9
|
-
const
|
|
9
|
+
const o = String(i), r = n.delimiter ?? " ", s = n.newline ?? `
|
|
10
10
|
`;
|
|
11
|
-
return n.quoteStrings ||
|
|
11
|
+
return n.quoteStrings || o.includes(r) || o.includes(s) || o.includes('"') ? `"${o.replace(/"/g, '""')}"` : o;
|
|
12
12
|
}
|
|
13
13
|
function F(i) {
|
|
14
|
-
const { rows: e, columns: t, selectedIndices: n, config:
|
|
14
|
+
const { rows: e, columns: t, selectedIndices: n, config: o } = i, r = o.delimiter ?? " ", s = o.newline ?? `
|
|
15
15
|
`, l = t.filter((u) => !u.hidden && !u.field.startsWith("__")), a = [];
|
|
16
|
-
if (
|
|
16
|
+
if (o.includeHeaders) {
|
|
17
17
|
const u = l.map((h) => {
|
|
18
18
|
const f = h.header || h.field;
|
|
19
|
-
return f.includes(
|
|
19
|
+
return f.includes(r) || f.includes(s) || f.includes('"') ? `"${f.replace(/"/g, '""')}"` : f;
|
|
20
20
|
});
|
|
21
|
-
a.push(u.join(
|
|
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
|
-
a.push(f.join(
|
|
30
|
+
a.push(f.join(r));
|
|
31
31
|
}
|
|
32
32
|
return a.join(s);
|
|
33
33
|
}
|
|
@@ -43,15 +43,15 @@ async function N(i) {
|
|
|
43
43
|
}
|
|
44
44
|
function J(i, e) {
|
|
45
45
|
const t = e.delimiter ?? " ", n = e.newline ?? `
|
|
46
|
-
`,
|
|
46
|
+
`, o = i.replace(/\r\n/g, `
|
|
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,41 +84,41 @@ 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,
|
|
96
|
-
if (
|
|
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
|
+
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
|
-
const u =
|
|
104
|
+
const u = r[r.length - 1], h = this.#r({
|
|
105
105
|
startRow: u.from.row,
|
|
106
106
|
startCol: u.from.col,
|
|
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
|
-
const u = t.getSelectedCell(), h = this.#
|
|
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) {
|
|
@@ -148,29 +148,29 @@ class vt extends y {
|
|
|
148
148
|
/**
|
|
149
149
|
* Build text for a single cell by row/col index.
|
|
150
150
|
*/
|
|
151
|
-
#
|
|
151
|
+
#o(e, t) {
|
|
152
152
|
const n = this.rows[e];
|
|
153
153
|
if (!n) return null;
|
|
154
|
-
const
|
|
155
|
-
if (!
|
|
156
|
-
const
|
|
154
|
+
const o = this.columns[t];
|
|
155
|
+
if (!o) return null;
|
|
156
|
+
const r = n[o.field], s = o.header || o.field;
|
|
157
157
|
let l;
|
|
158
158
|
if (this.config.includeHeaders) {
|
|
159
|
-
const a =
|
|
159
|
+
const a = r == null ? "" : String(r);
|
|
160
160
|
l = `${s}: ${a}`;
|
|
161
161
|
} else
|
|
162
|
-
l =
|
|
162
|
+
l = r == null ? "" : String(r);
|
|
163
163
|
return { text: l };
|
|
164
164
|
}
|
|
165
165
|
/**
|
|
166
166
|
* Build text for a rectangular range of cells.
|
|
167
167
|
*/
|
|
168
|
-
#
|
|
169
|
-
const { startRow: t, startCol: n, endRow:
|
|
170
|
-
`, h = [], f = this.columns.slice(a,
|
|
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), 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
|
/**
|
|
@@ -196,20 +196,20 @@ class vt extends y {
|
|
|
196
196
|
if (!t) return null;
|
|
197
197
|
const n = t.dataset.fieldCache;
|
|
198
198
|
if (!n) return null;
|
|
199
|
-
const
|
|
200
|
-
if (!
|
|
201
|
-
const
|
|
202
|
-
if (isNaN(
|
|
203
|
-
const s = this.rows[
|
|
199
|
+
const o = t.dataset.row;
|
|
200
|
+
if (!o) return null;
|
|
201
|
+
const r = parseInt(o, 10);
|
|
202
|
+
if (isNaN(r)) return null;
|
|
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,39 +277,39 @@ function te(i) {
|
|
|
277
277
|
function ne(i) {
|
|
278
278
|
return i.reduce((e, t) => e + G(t.width), 0);
|
|
279
279
|
}
|
|
280
|
-
function
|
|
281
|
-
const
|
|
282
|
-
if (
|
|
280
|
+
function Ce(i, e, t, n, o) {
|
|
281
|
+
const r = t.length;
|
|
282
|
+
if (r === 0)
|
|
283
283
|
return { startCol: 0, endCol: 0, visibleColumns: [] };
|
|
284
|
-
let s =
|
|
285
|
-
s = Math.max(0, s -
|
|
284
|
+
let s = Se(i, t, n);
|
|
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
|
-
a = Math.min(
|
|
296
|
-
const
|
|
297
|
-
for (let
|
|
298
|
-
|
|
299
|
-
return { startCol: s, endCol: a, visibleColumns:
|
|
295
|
+
a = Math.min(r - 1, a + o);
|
|
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
|
|
302
|
-
let n = 0,
|
|
303
|
-
for (; n <
|
|
304
|
-
const
|
|
305
|
-
e[
|
|
301
|
+
function Se(i, e, t) {
|
|
302
|
+
let n = 0, o = e.length - 1;
|
|
303
|
+
for (; n < o; ) {
|
|
304
|
+
const r = Math.floor((n + o) / 2);
|
|
305
|
+
e[r] + t[r] <= i ? n = r + 1 : o = r;
|
|
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,28 +339,28 @@ 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,
|
|
345
|
+
const n = this.grid.clientWidth || 800, o = Ce(
|
|
346
346
|
this.scrollLeft,
|
|
347
347
|
n,
|
|
348
348
|
this.columnOffsets,
|
|
349
349
|
this.columnWidths,
|
|
350
350
|
this.config.overscan ?? 3
|
|
351
351
|
);
|
|
352
|
-
return this.startCol =
|
|
352
|
+
return this.startCol = o.startCol, this.endCol = o.endCol, o.visibleColumns.map((r) => e[r]);
|
|
353
353
|
}
|
|
354
354
|
afterRender() {
|
|
355
355
|
if (!this.isVirtualized) return;
|
|
356
356
|
const e = this.shadowRoot;
|
|
357
357
|
if (!e) return;
|
|
358
|
-
const t = this.columnOffsets[this.startCol] ?? 0, n = e.querySelector(".header-row"),
|
|
359
|
-
n && (n.style.paddingLeft = `${t}px`),
|
|
358
|
+
const t = this.columnOffsets[this.startCol] ?? 0, n = e.querySelector(".header-row"), o = e.querySelectorAll(".data-grid-row");
|
|
359
|
+
n && (n.style.paddingLeft = `${t}px`), o.forEach((s) => {
|
|
360
360
|
s.style.paddingLeft = `${t}px`;
|
|
361
361
|
});
|
|
362
|
-
const
|
|
363
|
-
|
|
362
|
+
const r = e.querySelector(".rows-viewport .rows");
|
|
363
|
+
r && (r.style.width = `${this.totalWidth}px`);
|
|
364
364
|
}
|
|
365
365
|
onScroll(e) {
|
|
366
366
|
!this.isVirtualized || Math.abs(e.scrollLeft - this.scrollLeft) < 1 || (this.scrollLeft = e.scrollLeft, this.requestRender());
|
|
@@ -400,58 +400,58 @@ 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
|
-
|
|
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
412
|
for (const r of i) {
|
|
413
413
|
if (r.separator) {
|
|
414
|
-
const
|
|
415
|
-
|
|
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
|
-
|
|
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
424
|
}
|
|
425
|
-
const
|
|
426
|
-
if (
|
|
427
|
-
const
|
|
428
|
-
|
|
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
429
|
}
|
|
430
430
|
if (r.subMenu?.length) {
|
|
431
|
-
const
|
|
432
|
-
|
|
433
|
-
if (
|
|
434
|
-
const
|
|
435
|
-
|
|
436
|
-
}),
|
|
437
|
-
const c =
|
|
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
|
-
function
|
|
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";
|
|
449
|
-
const n = i.getBoundingClientRect(),
|
|
449
|
+
const n = i.getBoundingClientRect(), o = window.innerWidth, r = window.innerHeight;
|
|
450
450
|
let s = e, l = t;
|
|
451
|
-
e + n.width >
|
|
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() {
|
|
@@ -557,41 +557,46 @@ class Ct extends y {
|
|
|
557
557
|
const t = e.children[0];
|
|
558
558
|
t && t.getAttribute("data-context-menu-bound") !== "true" && (t.setAttribute("data-context-menu-bound", "true"), t.addEventListener("contextmenu", (n) => {
|
|
559
559
|
if (!this.config.enabled) return;
|
|
560
|
-
const
|
|
561
|
-
|
|
562
|
-
const
|
|
560
|
+
const o = n;
|
|
561
|
+
o.preventDefault();
|
|
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 ?? "",
|
|
572
572
|
value: f?.[h?.field] ?? null,
|
|
573
573
|
isHeader: !1,
|
|
574
|
-
event:
|
|
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,
|
|
586
|
-
event:
|
|
586
|
+
event: o
|
|
587
587
|
};
|
|
588
588
|
} else
|
|
589
589
|
return;
|
|
590
|
-
this.params = a, this.position = { x:
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
d
|
|
594
|
-
|
|
590
|
+
this.params = a, this.position = { x: o.clientX, y: o.clientY };
|
|
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 =====
|
|
@@ -602,7 +607,7 @@ class Ct extends y {
|
|
|
602
607
|
* @param params - Partial context menu parameters
|
|
603
608
|
*/
|
|
604
609
|
showMenu(e, t, n) {
|
|
605
|
-
const
|
|
610
|
+
const o = {
|
|
606
611
|
row: n.row ?? null,
|
|
607
612
|
rowIndex: n.rowIndex ?? -1,
|
|
608
613
|
column: n.column ?? null,
|
|
@@ -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
|
-
},
|
|
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.
|
|
@@ -631,7 +641,7 @@ class Ct extends y {
|
|
|
631
641
|
}
|
|
632
642
|
// Styles are injected globally via installGlobalHandlers() since menu renders in document.body
|
|
633
643
|
}
|
|
634
|
-
function
|
|
644
|
+
function re(i, e = !0) {
|
|
635
645
|
if (i == null) return "";
|
|
636
646
|
if (i instanceof Date) return i.toISOString();
|
|
637
647
|
if (typeof i == "object") return JSON.stringify(i);
|
|
@@ -639,30 +649,30 @@ function oe(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
|
|
643
|
-
const
|
|
652
|
+
function Ae(i, e, t, n = {}) {
|
|
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
|
|
648
|
-
return
|
|
656
|
+
const a = e.map((d) => {
|
|
657
|
+
const c = d.header || d.field, u = t.processHeader ? t.processHeader(c, d.field) : c;
|
|
658
|
+
return re(u);
|
|
649
659
|
});
|
|
650
|
-
s.push(a.join(
|
|
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
|
-
return l + s.join(
|
|
669
|
+
return l + s.join(r);
|
|
660
670
|
}
|
|
661
671
|
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
|
}
|
|
@@ -679,18 +689,18 @@ function _e(i, e, t) {
|
|
|
679
689
|
if (t.includeHeaders !== !1) {
|
|
680
690
|
n += `
|
|
681
691
|
<Row>`;
|
|
682
|
-
for (const
|
|
683
|
-
const
|
|
692
|
+
for (const o of e) {
|
|
693
|
+
const r = o.header || o.field, s = t.processHeader ? t.processHeader(r, o.field) : r;
|
|
684
694
|
n += `<Cell><Data ss:Type="String">${ie(s)}</Data></Cell>`;
|
|
685
695
|
}
|
|
686
696
|
n += "</Row>";
|
|
687
697
|
}
|
|
688
|
-
for (const
|
|
698
|
+
for (const o of i) {
|
|
689
699
|
n += `
|
|
690
700
|
<Row>`;
|
|
691
|
-
for (const
|
|
692
|
-
let s = r
|
|
693
|
-
t.processCell && (s = t.processCell(s,
|
|
701
|
+
for (const r of e) {
|
|
702
|
+
let s = o[r.field];
|
|
703
|
+
t.processCell && (s = t.processCell(s, r.field, o));
|
|
694
704
|
let l = "String", a = "";
|
|
695
705
|
s == null ? a = "" : typeof s == "number" && !isNaN(s) ? (l = "Number", a = String(s)) : s instanceof Date ? (l = "DateTime", a = s.toISOString()) : a = ie(String(s)), n += `<Cell><Data ss:Type="${l}">${a}</Data></Cell>`;
|
|
696
706
|
}
|
|
@@ -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() {
|
|
@@ -724,7 +734,7 @@ class St extends y {
|
|
|
724
734
|
lastExportInfo = null;
|
|
725
735
|
// ===== Private Methods =====
|
|
726
736
|
performExport(e, t) {
|
|
727
|
-
const n = this.config,
|
|
737
|
+
const n = this.config, o = {
|
|
728
738
|
format: e,
|
|
729
739
|
fileName: t?.fileName ?? n.fileName ?? "export",
|
|
730
740
|
includeHeaders: t?.includeHeaders ?? n.includeHeaders,
|
|
@@ -733,42 +743,42 @@ class St extends y {
|
|
|
733
743
|
columns: t?.columns,
|
|
734
744
|
rowIndices: t?.rowIndices
|
|
735
745
|
};
|
|
736
|
-
let
|
|
737
|
-
if (n.onlyVisible && (
|
|
746
|
+
let r = [...this.columns];
|
|
747
|
+
if (n.onlyVisible && (r = r.filter((a) => !a.hidden && !a.field.startsWith("__"))), t?.columns) {
|
|
738
748
|
const a = new Set(t.columns);
|
|
739
|
-
|
|
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
|
-
let l =
|
|
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
|
-
const a = _e(s,
|
|
757
|
-
l = l.endsWith(".xls") ? l : `${l}.xls`,
|
|
766
|
+
const a = _e(s, r, o);
|
|
767
|
+
l = l.endsWith(".xls") ? l : `${l}.xls`, Te(a, l);
|
|
758
768
|
break;
|
|
759
769
|
}
|
|
760
770
|
case "json": {
|
|
761
771
|
const a = s.map((u) => {
|
|
762
772
|
const h = {};
|
|
763
|
-
for (const f of
|
|
773
|
+
for (const f of r) {
|
|
764
774
|
let g = u[f.field];
|
|
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
|
}
|
|
@@ -776,7 +786,7 @@ class St extends y {
|
|
|
776
786
|
format: e,
|
|
777
787
|
fileName: l,
|
|
778
788
|
rowCount: s.length,
|
|
779
|
-
columnCount:
|
|
789
|
+
columnCount: r.length
|
|
780
790
|
});
|
|
781
791
|
} finally {
|
|
782
792
|
this.isExportingFlag = !1;
|
|
@@ -826,43 +836,43 @@ class St extends y {
|
|
|
826
836
|
return this.lastExportInfo;
|
|
827
837
|
}
|
|
828
838
|
}
|
|
829
|
-
function
|
|
830
|
-
const { totalRows: e, viewportHeight: t, scrollTop: n, rowHeight:
|
|
831
|
-
let l = Math.floor(n /
|
|
839
|
+
function Le(i) {
|
|
840
|
+
const { totalRows: e, viewportHeight: t, scrollTop: n, rowHeight: o, overscan: r } = i, s = Math.ceil(t / o);
|
|
841
|
+
let l = Math.floor(n / o) - r;
|
|
832
842
|
l < 0 && (l = 0);
|
|
833
|
-
let a = l + s +
|
|
834
|
-
return a > e && (a = e), a === e && l > 0 && (l = Math.max(0, a - s -
|
|
843
|
+
let a = l + s + r * 2;
|
|
844
|
+
return a > e && (a = e), a === e && l > 0 && (l = Math.max(0, a - s - r * 2)), {
|
|
835
845
|
start: l,
|
|
836
846
|
end: a,
|
|
837
|
-
offsetY: l *
|
|
838
|
-
totalHeight: e *
|
|
847
|
+
offsetY: l * o,
|
|
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 === "";
|
|
848
858
|
if (e.operator === "notBlank")
|
|
849
859
|
return n != null && n !== "";
|
|
850
860
|
if (n == null) return !1;
|
|
851
|
-
const
|
|
861
|
+
const o = String(n), r = t ? o : o.toLowerCase(), s = t ? String(e.value) : String(e.value).toLowerCase();
|
|
852
862
|
switch (e.operator) {
|
|
853
863
|
// Text operators
|
|
854
864
|
case "contains":
|
|
855
|
-
return
|
|
865
|
+
return r.includes(s);
|
|
856
866
|
case "notContains":
|
|
857
|
-
return !
|
|
867
|
+
return !r.includes(s);
|
|
858
868
|
case "equals":
|
|
859
|
-
return
|
|
869
|
+
return r === s;
|
|
860
870
|
case "notEquals":
|
|
861
|
-
return
|
|
871
|
+
return r !== s;
|
|
862
872
|
case "startsWith":
|
|
863
|
-
return
|
|
873
|
+
return r.startsWith(s);
|
|
864
874
|
case "endsWith":
|
|
865
|
-
return
|
|
875
|
+
return r.endsWith(s);
|
|
866
876
|
// Number/Date operators (use raw numeric values)
|
|
867
877
|
case "lessThan":
|
|
868
878
|
return Number(n) < Number(e.value);
|
|
@@ -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((
|
|
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,
|
|
@@ -899,12 +909,12 @@ function Fe(i) {
|
|
|
899
909
|
function se(i, e) {
|
|
900
910
|
const t = /* @__PURE__ */ new Set();
|
|
901
911
|
for (const n of i) {
|
|
902
|
-
const
|
|
903
|
-
|
|
912
|
+
const o = n[e];
|
|
913
|
+
o != null && t.add(o);
|
|
904
914
|
}
|
|
905
|
-
return [...t].sort((n,
|
|
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)));
|
|
@@ -1066,7 +1076,8 @@ class E extends y {
|
|
|
1066
1076
|
panelElement = null;
|
|
1067
1077
|
searchText = /* @__PURE__ */ new Map();
|
|
1068
1078
|
excludedValues = /* @__PURE__ */ new Map();
|
|
1069
|
-
|
|
1079
|
+
panelAbortController = null;
|
|
1080
|
+
// For panel-scoped listeners
|
|
1070
1081
|
globalStylesInjected = !1;
|
|
1071
1082
|
// Virtualization constants for filter value list
|
|
1072
1083
|
static LIST_ITEM_HEIGHT = 28;
|
|
@@ -1078,32 +1089,32 @@ class E extends y {
|
|
|
1078
1089
|
super.attach(e), this.injectGlobalStyles();
|
|
1079
1090
|
}
|
|
1080
1091
|
detach() {
|
|
1081
|
-
this.filters.clear(), this.cachedResult = null, this.cacheKey = null, this.openPanelField = null, this.panelElement && (this.panelElement.remove(), this.panelElement = null), this.searchText.clear(), this.excludedValues.clear(), this.
|
|
1092
|
+
this.filters.clear(), this.cachedResult = null, this.cacheKey = null, this.openPanelField = null, this.panelElement && (this.panelElement.remove(), this.panelElement = null), this.searchText.clear(), this.excludedValues.clear(), this.panelAbortController?.abort(), this.panelAbortController = null;
|
|
1082
1093
|
}
|
|
1083
1094
|
// ===== Hooks =====
|
|
1084
1095
|
processRows(e) {
|
|
1085
1096
|
const t = [...this.filters.values()];
|
|
1086
1097
|
if (!t.length) return [...e];
|
|
1087
|
-
const n =
|
|
1098
|
+
const n = Ne(t);
|
|
1088
1099
|
if (this.cacheKey === n && this.cachedResult)
|
|
1089
1100
|
return this.cachedResult;
|
|
1090
|
-
const
|
|
1091
|
-
return this.cachedResult =
|
|
1101
|
+
const o = Fe([...e], t, this.config.caseSensitive);
|
|
1102
|
+
return this.cachedResult = o, this.cacheKey = n, o;
|
|
1092
1103
|
}
|
|
1093
1104
|
afterRender() {
|
|
1094
1105
|
if (!this.config.enabled) return;
|
|
1095
1106
|
const e = this.shadowRoot;
|
|
1096
1107
|
if (!e) return;
|
|
1097
1108
|
e.querySelectorAll('[part~="header-cell"]').forEach((n) => {
|
|
1098
|
-
const
|
|
1099
|
-
if (
|
|
1100
|
-
const
|
|
1101
|
-
if (!
|
|
1102
|
-
const s =
|
|
1109
|
+
const o = n.getAttribute("data-col");
|
|
1110
|
+
if (o === null) return;
|
|
1111
|
+
const r = this.columns[parseInt(o, 10)];
|
|
1112
|
+
if (!r || r.filterable === !1 || n.querySelector(".tbw-filter-btn")) return;
|
|
1113
|
+
const s = r.field;
|
|
1103
1114
|
if (!s) return;
|
|
1104
1115
|
const l = document.createElement("button");
|
|
1105
|
-
l.className = "tbw-filter-btn", l.setAttribute("aria-label", `Filter ${
|
|
1106
|
-
a.stopPropagation(), this.toggleFilterPanel(s,
|
|
1116
|
+
l.className = "tbw-filter-btn", l.setAttribute("aria-label", `Filter ${r.header ?? s}`), 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(s) && (l.classList.add("active"), n.classList.add("filtered")), l.addEventListener("click", (a) => {
|
|
1117
|
+
a.stopPropagation(), this.toggleFilterPanel(s, r, l);
|
|
1107
1118
|
}), n.appendChild(l);
|
|
1108
1119
|
});
|
|
1109
1120
|
}
|
|
@@ -1203,7 +1214,7 @@ class E extends y {
|
|
|
1203
1214
|
return;
|
|
1204
1215
|
}
|
|
1205
1216
|
const e = document.createElement("style");
|
|
1206
|
-
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;
|
|
1207
1218
|
}
|
|
1208
1219
|
/**
|
|
1209
1220
|
* Toggle the filter panel for a field
|
|
@@ -1214,48 +1225,44 @@ class E extends y {
|
|
|
1214
1225
|
return;
|
|
1215
1226
|
}
|
|
1216
1227
|
this.closeFilterPanel();
|
|
1217
|
-
const
|
|
1218
|
-
|
|
1219
|
-
const
|
|
1228
|
+
const o = document.createElement("div");
|
|
1229
|
+
o.className = "tbw-filter-panel", this.panelElement = o, this.openPanelField = e;
|
|
1230
|
+
const r = se(this.sourceRows, e);
|
|
1220
1231
|
let s = this.excludedValues.get(e);
|
|
1221
1232
|
s || (s = /* @__PURE__ */ new Set(), this.excludedValues.set(e, s));
|
|
1222
1233
|
const l = this.searchText.get(e) ?? "", a = {
|
|
1223
1234
|
field: e,
|
|
1224
1235
|
column: t,
|
|
1225
|
-
uniqueValues:
|
|
1236
|
+
uniqueValues: r,
|
|
1226
1237
|
excludedValues: s,
|
|
1227
1238
|
searchText: l,
|
|
1228
|
-
applySetFilter: (
|
|
1229
|
-
this.applySetFilter(e,
|
|
1239
|
+
applySetFilter: (c) => {
|
|
1240
|
+
this.applySetFilter(e, c), this.closeFilterPanel();
|
|
1230
1241
|
},
|
|
1231
|
-
applyTextFilter: (u, h
|
|
1232
|
-
this.applyTextFilter(e, u, h
|
|
1242
|
+
applyTextFilter: (c, u, h) => {
|
|
1243
|
+
this.applyTextFilter(e, c, u, h), this.closeFilterPanel();
|
|
1233
1244
|
},
|
|
1234
1245
|
clearFilter: () => {
|
|
1235
1246
|
this.clearFieldFilter(e), this.closeFilterPanel();
|
|
1236
1247
|
},
|
|
1237
1248
|
closePanel: () => this.closeFilterPanel()
|
|
1238
1249
|
};
|
|
1239
|
-
let
|
|
1240
|
-
this.config.filterPanelRenderer && (this.config.filterPanelRenderer(
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
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(() => {
|
|
1252
|
+
document.addEventListener(
|
|
1253
|
+
"click",
|
|
1254
|
+
(c) => {
|
|
1255
|
+
!o.contains(c.target) && c.target !== n && this.closeFilterPanel();
|
|
1256
|
+
},
|
|
1257
|
+
{ signal: this.panelAbortController?.signal }
|
|
1258
|
+
);
|
|
1246
1259
|
}, 0);
|
|
1247
1260
|
}
|
|
1248
1261
|
/**
|
|
1249
1262
|
* Close the filter panel
|
|
1250
1263
|
*/
|
|
1251
1264
|
closeFilterPanel() {
|
|
1252
|
-
this.panelElement && (this.panelElement.remove(), this.panelElement = null), this.openPanelField = null, this.
|
|
1253
|
-
}
|
|
1254
|
-
/**
|
|
1255
|
-
* Remove the document click handler
|
|
1256
|
-
*/
|
|
1257
|
-
removeDocumentClickHandler() {
|
|
1258
|
-
this.documentClickHandler && (document.removeEventListener("click", this.documentClickHandler), this.documentClickHandler = null);
|
|
1265
|
+
this.panelElement && (this.panelElement.remove(), this.panelElement = null), this.openPanelField = null, this.panelAbortController?.abort(), this.panelAbortController = null;
|
|
1259
1266
|
}
|
|
1260
1267
|
/**
|
|
1261
1268
|
* Position the panel below the button
|
|
@@ -1263,32 +1270,32 @@ class E extends y {
|
|
|
1263
1270
|
positionPanel(e, t) {
|
|
1264
1271
|
const n = t.getBoundingClientRect();
|
|
1265
1272
|
e.style.position = "fixed", e.style.top = `${n.bottom + 4}px`, e.style.left = `${n.left}px`, requestAnimationFrame(() => {
|
|
1266
|
-
const
|
|
1267
|
-
|
|
1273
|
+
const o = e.getBoundingClientRect();
|
|
1274
|
+
o.right > window.innerWidth - 8 && (e.style.left = `${window.innerWidth - o.width - 8}px`), o.bottom > window.innerHeight - 8 && (e.style.top = `${n.top - o.height - 4}px`);
|
|
1268
1275
|
});
|
|
1269
1276
|
}
|
|
1270
1277
|
/**
|
|
1271
1278
|
* Render the default filter panel content
|
|
1272
1279
|
*/
|
|
1273
|
-
renderDefaultFilterPanel(e, t, n,
|
|
1274
|
-
const { field:
|
|
1280
|
+
renderDefaultFilterPanel(e, t, n, o) {
|
|
1281
|
+
const { field: r } = t, s = document.createElement("div");
|
|
1275
1282
|
s.className = "tbw-filter-search";
|
|
1276
1283
|
const l = document.createElement("input");
|
|
1277
|
-
l.type = "text", l.placeholder = "Search...", l.className = "tbw-filter-search-input", l.value = this.searchText.get(
|
|
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);
|
|
1278
1285
|
const a = document.createElement("div");
|
|
1279
1286
|
a.className = "tbw-filter-actions";
|
|
1280
|
-
const
|
|
1281
|
-
|
|
1282
|
-
const
|
|
1283
|
-
|
|
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";
|
|
1284
1291
|
const u = document.createElement("span");
|
|
1285
|
-
u.textContent = "Select All",
|
|
1292
|
+
u.textContent = "Select All", d.appendChild(c), d.appendChild(u), a.appendChild(d);
|
|
1286
1293
|
const h = () => {
|
|
1287
1294
|
const p = [...b.values()], v = p.every((x) => x), C = p.every((x) => !x);
|
|
1288
|
-
|
|
1295
|
+
c.checked = v, c.indeterminate = !v && !C;
|
|
1289
1296
|
};
|
|
1290
|
-
|
|
1291
|
-
const p =
|
|
1297
|
+
c.addEventListener("change", () => {
|
|
1298
|
+
const p = c.checked;
|
|
1292
1299
|
for (const v of b.keys())
|
|
1293
1300
|
b.set(v, p);
|
|
1294
1301
|
h(), q();
|
|
@@ -1302,7 +1309,7 @@ class E extends y {
|
|
|
1302
1309
|
const b = /* @__PURE__ */ new Map();
|
|
1303
1310
|
n.forEach((p) => {
|
|
1304
1311
|
const v = p == null ? "__null__" : String(p);
|
|
1305
|
-
b.set(v, !
|
|
1312
|
+
b.set(v, !o.has(p));
|
|
1306
1313
|
}), h();
|
|
1307
1314
|
let S = [];
|
|
1308
1315
|
const R = (p, v) => {
|
|
@@ -1316,13 +1323,13 @@ class E extends y {
|
|
|
1316
1323
|
return Y.textContent = C, w.appendChild(k), w.appendChild(Y), w;
|
|
1317
1324
|
}, q = () => {
|
|
1318
1325
|
const p = S.length, v = f.clientHeight, C = f.scrollTop;
|
|
1319
|
-
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)) {
|
|
1320
1327
|
m.innerHTML = "", m.style.transform = "translateY(0px)", S.forEach((w, k) => {
|
|
1321
1328
|
m.appendChild(R(w, k));
|
|
1322
1329
|
});
|
|
1323
1330
|
return;
|
|
1324
1331
|
}
|
|
1325
|
-
const x =
|
|
1332
|
+
const x = Le({
|
|
1326
1333
|
totalRows: p,
|
|
1327
1334
|
viewportHeight: v,
|
|
1328
1335
|
scrollTop: C,
|
|
@@ -1355,11 +1362,11 @@ class E extends y {
|
|
|
1355
1362
|
let U;
|
|
1356
1363
|
l.addEventListener("input", () => {
|
|
1357
1364
|
clearTimeout(U), U = setTimeout(() => {
|
|
1358
|
-
this.searchText.set(
|
|
1365
|
+
this.searchText.set(r, l.value), j(l.value);
|
|
1359
1366
|
}, this.config.debounceMs ?? 150);
|
|
1360
1367
|
});
|
|
1361
|
-
const
|
|
1362
|
-
|
|
1368
|
+
const _ = document.createElement("div");
|
|
1369
|
+
_.className = "tbw-filter-buttons";
|
|
1363
1370
|
const T = document.createElement("button");
|
|
1364
1371
|
T.className = "tbw-filter-apply-btn", T.textContent = "Apply", T.addEventListener("click", () => {
|
|
1365
1372
|
const p = [];
|
|
@@ -1372,11 +1379,11 @@ class E extends y {
|
|
|
1372
1379
|
p.push(x !== void 0 ? x : v);
|
|
1373
1380
|
}
|
|
1374
1381
|
t.applySetFilter(p);
|
|
1375
|
-
}),
|
|
1382
|
+
}), _.appendChild(T);
|
|
1376
1383
|
const L = document.createElement("button");
|
|
1377
1384
|
L.className = "tbw-filter-clear-btn", L.textContent = "Clear Filter", L.addEventListener("click", () => {
|
|
1378
1385
|
t.clearFilter();
|
|
1379
|
-
}),
|
|
1386
|
+
}), _.appendChild(L), e.appendChild(_);
|
|
1380
1387
|
}
|
|
1381
1388
|
/**
|
|
1382
1389
|
* Apply a set filter (exclude values)
|
|
@@ -1395,13 +1402,13 @@ class E extends y {
|
|
|
1395
1402
|
/**
|
|
1396
1403
|
* Apply a text filter
|
|
1397
1404
|
*/
|
|
1398
|
-
applyTextFilter(e, t, n,
|
|
1405
|
+
applyTextFilter(e, t, n, o) {
|
|
1399
1406
|
this.filters.set(e, {
|
|
1400
1407
|
field: e,
|
|
1401
1408
|
type: "text",
|
|
1402
1409
|
operator: t,
|
|
1403
1410
|
value: n,
|
|
1404
|
-
valueTo:
|
|
1411
|
+
valueTo: o
|
|
1405
1412
|
}), this.cachedResult = null, this.cacheKey = null, this.emit("filter-change", {
|
|
1406
1413
|
filters: [...this.filters.values()],
|
|
1407
1414
|
filteredRowCount: 0
|
|
@@ -1492,54 +1499,54 @@ function Pe(i) {
|
|
|
1492
1499
|
implicit: !0
|
|
1493
1500
|
});
|
|
1494
1501
|
};
|
|
1495
|
-
let
|
|
1502
|
+
let o = [], r = 0;
|
|
1496
1503
|
return i.forEach((s, l) => {
|
|
1497
1504
|
const a = s.group;
|
|
1498
1505
|
if (!a) {
|
|
1499
|
-
|
|
1506
|
+
o.length === 0 && (r = l), o.push(s);
|
|
1500
1507
|
return;
|
|
1501
1508
|
}
|
|
1502
|
-
|
|
1503
|
-
const
|
|
1504
|
-
let
|
|
1505
|
-
|
|
1506
|
-
id:
|
|
1509
|
+
o.length && (n(r, o.slice()), o = []);
|
|
1510
|
+
const d = typeof a == "string" ? a : a.id;
|
|
1511
|
+
let c = e.get(d);
|
|
1512
|
+
c || (c = {
|
|
1513
|
+
id: d,
|
|
1507
1514
|
label: typeof a == "string" ? void 0 : a.label,
|
|
1508
1515
|
columns: [],
|
|
1509
1516
|
firstIndex: l
|
|
1510
|
-
}, e.set(
|
|
1511
|
-
}),
|
|
1517
|
+
}, e.set(d, c), t.push(c)), c.columns.push(s);
|
|
1518
|
+
}), o.length && n(r, o), t.length === 1 && t[0].implicit && t[0].columns.length === i.length ? [] : t;
|
|
1512
1519
|
}
|
|
1513
|
-
function
|
|
1520
|
+
function Be(i, e, t) {
|
|
1514
1521
|
if (!e.length || !i) return;
|
|
1515
1522
|
const n = /* @__PURE__ */ new Map();
|
|
1516
|
-
for (const
|
|
1517
|
-
for (const s of
|
|
1518
|
-
s?.field && n.set(s.field,
|
|
1519
|
-
const
|
|
1520
|
-
|
|
1521
|
-
const s =
|
|
1522
|
-
l && (
|
|
1523
|
+
for (const r of e)
|
|
1524
|
+
for (const s of r.columns)
|
|
1525
|
+
s?.field && n.set(s.field, r.id);
|
|
1526
|
+
const o = Array.from(i.querySelectorAll(".cell[data-field]"));
|
|
1527
|
+
o.forEach((r) => {
|
|
1528
|
+
const s = r.getAttribute("data-field") || "", l = n.get(s);
|
|
1529
|
+
l && (r.classList.add("grouped"), r.getAttribute("data-group") || r.setAttribute("data-group", l));
|
|
1523
1530
|
});
|
|
1524
|
-
for (const
|
|
1525
|
-
const s =
|
|
1531
|
+
for (const r of e) {
|
|
1532
|
+
const s = r.columns[r.columns.length - 1], l = o.find((a) => a.getAttribute("data-field") === s.field);
|
|
1526
1533
|
l && l.classList.add("group-end");
|
|
1527
1534
|
}
|
|
1528
1535
|
}
|
|
1529
|
-
function
|
|
1536
|
+
function He(i, e) {
|
|
1530
1537
|
if (i.length === 0) return null;
|
|
1531
1538
|
const t = document.createElement("div");
|
|
1532
1539
|
t.className = "header-group-row", t.setAttribute("role", "row");
|
|
1533
1540
|
for (const n of i) {
|
|
1534
|
-
const
|
|
1535
|
-
l.className = "cell header-group-cell",
|
|
1541
|
+
const o = n.firstIndex != null ? n.firstIndex : e.findIndex((a) => n.columns.includes(a)), r = String(n.id).startsWith("__implicit__"), s = r ? "" : n.label || n.id, l = document.createElement("div");
|
|
1542
|
+
l.className = "cell header-group-cell", r && l.classList.add("implicit-group"), l.setAttribute("data-group", String(n.id)), l.style.gridColumn = `${o + 1} / span ${n.columns.length}`, l.textContent = s, t.appendChild(l);
|
|
1536
1543
|
}
|
|
1537
1544
|
return t;
|
|
1538
1545
|
}
|
|
1539
|
-
function
|
|
1546
|
+
function Oe(i) {
|
|
1540
1547
|
return i.some((e) => e.group != null);
|
|
1541
1548
|
}
|
|
1542
|
-
class
|
|
1549
|
+
class kt extends y {
|
|
1543
1550
|
name = "groupingColumns";
|
|
1544
1551
|
version = "1.0.0";
|
|
1545
1552
|
get defaultConfig() {
|
|
@@ -1561,7 +1568,7 @@ class Rt extends y {
|
|
|
1561
1568
|
*/
|
|
1562
1569
|
static detect(e, t) {
|
|
1563
1570
|
const n = t?.columns;
|
|
1564
|
-
return Array.isArray(n) ?
|
|
1571
|
+
return Array.isArray(n) ? Oe(n) : !1;
|
|
1565
1572
|
}
|
|
1566
1573
|
// ===== Hooks =====
|
|
1567
1574
|
processColumns(e) {
|
|
@@ -1580,13 +1587,13 @@ class Rt extends y {
|
|
|
1580
1587
|
if (!e) return;
|
|
1581
1588
|
const t = e.querySelector(".header-group-row");
|
|
1582
1589
|
t && t.remove();
|
|
1583
|
-
const n =
|
|
1590
|
+
const n = He(this.groups, this.columns);
|
|
1584
1591
|
if (n) {
|
|
1585
|
-
const
|
|
1586
|
-
|
|
1592
|
+
const r = e.querySelector(".header-row");
|
|
1593
|
+
r ? e.insertBefore(n, r) : e.appendChild(n);
|
|
1587
1594
|
}
|
|
1588
|
-
const
|
|
1589
|
-
|
|
1595
|
+
const o = e.querySelector(".header-row");
|
|
1596
|
+
o && Be(o, this.groups, this.columns);
|
|
1590
1597
|
}
|
|
1591
1598
|
// ===== Public API =====
|
|
1592
1599
|
/**
|
|
@@ -1648,40 +1655,40 @@ class Rt extends y {
|
|
|
1648
1655
|
}
|
|
1649
1656
|
`;
|
|
1650
1657
|
}
|
|
1651
|
-
function
|
|
1658
|
+
function We({ rows: i, config: e, expanded: t }) {
|
|
1652
1659
|
const n = e.groupOn;
|
|
1653
1660
|
if (!e.enabled || typeof n != "function")
|
|
1654
1661
|
return [];
|
|
1655
|
-
const
|
|
1662
|
+
const o = { key: "__root__", value: null, depth: -1, rows: [], children: /* @__PURE__ */ new Map() };
|
|
1656
1663
|
if (i.forEach((l) => {
|
|
1657
1664
|
let a = n(l);
|
|
1658
1665
|
a == null || a === !1 ? a = ["__ungrouped__"] : Array.isArray(a) || (a = [a]);
|
|
1659
|
-
let
|
|
1660
|
-
a.forEach((
|
|
1661
|
-
const h =
|
|
1662
|
-
let g =
|
|
1663
|
-
g || (g = { key: f, value:
|
|
1664
|
-
}),
|
|
1665
|
-
}),
|
|
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);
|
|
1672
|
+
}), o.children.size === 1 && o.children.has("__ungrouped__") && o.children.get("__ungrouped__").rows.length === i.length)
|
|
1666
1673
|
return [];
|
|
1667
|
-
const
|
|
1668
|
-
if (l ===
|
|
1669
|
-
l.children.forEach((
|
|
1674
|
+
const r = [], s = (l) => {
|
|
1675
|
+
if (l === o) {
|
|
1676
|
+
l.children.forEach((d) => s(d));
|
|
1670
1677
|
return;
|
|
1671
1678
|
}
|
|
1672
1679
|
const a = t.has(l.key);
|
|
1673
|
-
|
|
1680
|
+
r.push({
|
|
1674
1681
|
kind: "group",
|
|
1675
1682
|
key: l.key,
|
|
1676
1683
|
value: l.value,
|
|
1677
1684
|
depth: l.depth,
|
|
1678
1685
|
rows: l.rows,
|
|
1679
1686
|
expanded: a
|
|
1680
|
-
}), 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) })));
|
|
1681
1688
|
};
|
|
1682
|
-
return s(
|
|
1689
|
+
return s(o), r;
|
|
1683
1690
|
}
|
|
1684
|
-
function
|
|
1691
|
+
function Ve(i, e) {
|
|
1685
1692
|
const t = new Set(i);
|
|
1686
1693
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
1687
1694
|
}
|
|
@@ -1691,13 +1698,13 @@ function Ke(i) {
|
|
|
1691
1698
|
t.kind === "group" && e.add(t.key);
|
|
1692
1699
|
return e;
|
|
1693
1700
|
}
|
|
1694
|
-
function
|
|
1701
|
+
function Ge() {
|
|
1695
1702
|
return /* @__PURE__ */ new Set();
|
|
1696
1703
|
}
|
|
1697
|
-
function
|
|
1704
|
+
function ze(i) {
|
|
1698
1705
|
return i.kind !== "group" ? 0 : i.rows.length;
|
|
1699
1706
|
}
|
|
1700
|
-
class
|
|
1707
|
+
class Et extends y {
|
|
1701
1708
|
name = "groupingRows";
|
|
1702
1709
|
version = "1.0.0";
|
|
1703
1710
|
get defaultConfig() {
|
|
@@ -1729,20 +1736,20 @@ class kt extends y {
|
|
|
1729
1736
|
const t = this.config;
|
|
1730
1737
|
if (!t.enabled || typeof t.groupOn != "function")
|
|
1731
1738
|
return this.isActive = !1, this.flattenedRows = [], [...e];
|
|
1732
|
-
const n =
|
|
1739
|
+
const n = We({
|
|
1733
1740
|
rows: e,
|
|
1734
1741
|
config: t,
|
|
1735
1742
|
expanded: this.expandedKeys
|
|
1736
1743
|
});
|
|
1737
|
-
return n.length === 0 ? (this.isActive = !1, this.flattenedRows = [], [...e]) : (this.isActive = !0, this.flattenedRows = n, n.map((
|
|
1744
|
+
return n.length === 0 ? (this.isActive = !1, this.flattenedRows = [], [...e]) : (this.isActive = !0, this.flattenedRows = n, n.map((o) => o.kind === "group" ? {
|
|
1738
1745
|
__isGroupRow: !0,
|
|
1739
|
-
__groupKey:
|
|
1740
|
-
__groupValue:
|
|
1741
|
-
__groupDepth:
|
|
1742
|
-
__groupRows:
|
|
1743
|
-
__groupExpanded:
|
|
1744
|
-
__groupRowCount:
|
|
1745
|
-
} :
|
|
1746
|
+
__groupKey: o.key,
|
|
1747
|
+
__groupValue: o.value,
|
|
1748
|
+
__groupDepth: o.depth,
|
|
1749
|
+
__groupRows: o.rows,
|
|
1750
|
+
__groupExpanded: o.expanded,
|
|
1751
|
+
__groupRowCount: ze(o)
|
|
1752
|
+
} : o.row));
|
|
1746
1753
|
}
|
|
1747
1754
|
onCellClick(e) {
|
|
1748
1755
|
const t = e.row;
|
|
@@ -1755,11 +1762,11 @@ class kt extends y {
|
|
|
1755
1762
|
renderRow(e, t, n) {
|
|
1756
1763
|
if (!e?.__isGroupRow)
|
|
1757
1764
|
return !1;
|
|
1758
|
-
const
|
|
1759
|
-
if (
|
|
1765
|
+
const o = this.config;
|
|
1766
|
+
if (o.groupRowRenderer) {
|
|
1760
1767
|
const l = () => {
|
|
1761
1768
|
this.toggle(e.__groupKey);
|
|
1762
|
-
}, a =
|
|
1769
|
+
}, a = o.groupRowRenderer({
|
|
1763
1770
|
key: e.__groupKey,
|
|
1764
1771
|
value: e.__groupValue,
|
|
1765
1772
|
depth: e.__groupDepth,
|
|
@@ -1770,57 +1777,55 @@ class kt extends y {
|
|
|
1770
1777
|
if (a)
|
|
1771
1778
|
return t.className = "group-row", t.__isCustomRow = !0, t.setAttribute("data-group-depth", String(e.__groupDepth)), typeof a == "string" ? t.innerHTML = a : (t.innerHTML = "", t.appendChild(a)), !0;
|
|
1772
1779
|
}
|
|
1773
|
-
const
|
|
1780
|
+
const r = () => {
|
|
1774
1781
|
this.toggle(e.__groupKey);
|
|
1775
1782
|
};
|
|
1776
|
-
return t.className = "group-row", t.__isCustomRow = !0, t.setAttribute("data-group-depth", String(e.__groupDepth)), t.setAttribute("role", "row"), t.setAttribute("aria-expanded", String(e.__groupExpanded)), t.style.paddingLeft = `${(e.__groupDepth || 0) * (
|
|
1783
|
+
return t.className = "group-row", t.__isCustomRow = !0, t.setAttribute("data-group-depth", String(e.__groupDepth)), t.setAttribute("role", "row"), t.setAttribute("aria-expanded", String(e.__groupExpanded)), t.style.paddingLeft = `${(e.__groupDepth || 0) * (o.indentWidth ?? 20)}px`, t.innerHTML = "", o.fullWidth !== !1 ? this.renderFullWidthGroupRow(e, t, r) : this.renderPerColumnGroupRow(e, t, r), !0;
|
|
1777
1784
|
}
|
|
1778
1785
|
afterRender() {
|
|
1779
1786
|
}
|
|
1780
1787
|
// ===== Private Rendering Helpers =====
|
|
1781
1788
|
renderFullWidthGroupRow(e, t, n) {
|
|
1782
|
-
const
|
|
1783
|
-
|
|
1789
|
+
const o = this.config, r = document.createElement("div");
|
|
1790
|
+
r.className = "cell group-full", r.style.gridColumn = "1 / -1", r.setAttribute("role", "gridcell");
|
|
1784
1791
|
const s = document.createElement("button");
|
|
1785
|
-
s.type = "button", s.className = "group-toggle", s.setAttribute("aria-label", e.__groupExpanded ? "Collapse group" : "Expand group"), s.
|
|
1786
|
-
|
|
1787
|
-
}),
|
|
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();
|
|
1794
|
+
}), r.appendChild(s);
|
|
1788
1795
|
const l = document.createElement("span");
|
|
1789
1796
|
l.className = "group-label";
|
|
1790
|
-
const a =
|
|
1791
|
-
if (l.textContent = a,
|
|
1792
|
-
const
|
|
1793
|
-
|
|
1797
|
+
const a = o.formatLabel ? o.formatLabel(e.__groupValue, e.__groupDepth || 0, e.__groupKey) : String(e.__groupValue);
|
|
1798
|
+
if (l.textContent = a, r.appendChild(l), o.showRowCount !== !1) {
|
|
1799
|
+
const d = document.createElement("span");
|
|
1800
|
+
d.className = "group-count", d.textContent = `(${e.__groupRowCount ?? e.__groupRows?.length ?? 0})`, r.appendChild(d);
|
|
1794
1801
|
}
|
|
1795
|
-
t.appendChild(
|
|
1802
|
+
t.appendChild(r);
|
|
1796
1803
|
}
|
|
1797
1804
|
renderPerColumnGroupRow(e, t, n) {
|
|
1798
|
-
const
|
|
1799
|
-
|
|
1800
|
-
const c = this.shadowRoot?.querySelector(".body")?.style.gridTemplateColumns || "";
|
|
1801
|
-
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) => {
|
|
1802
1807
|
const h = document.createElement("div");
|
|
1803
1808
|
if (h.className = "cell group-cell", h.setAttribute("data-col", String(u)), h.setAttribute("role", "gridcell"), u === 0) {
|
|
1804
1809
|
const f = document.createElement("button");
|
|
1805
|
-
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) => {
|
|
1806
1811
|
b.stopPropagation(), n();
|
|
1807
1812
|
}), h.appendChild(f);
|
|
1808
|
-
const g = document.createElement("span"), m =
|
|
1813
|
+
const g = document.createElement("span"), m = r[c.field];
|
|
1809
1814
|
if (m) {
|
|
1810
|
-
const b = X(m, l,
|
|
1815
|
+
const b = X(m, l, c.field, c);
|
|
1811
1816
|
g.textContent = b != null ? String(b) : String(e.__groupValue);
|
|
1812
1817
|
} else {
|
|
1813
|
-
const b =
|
|
1818
|
+
const b = o.formatLabel ? o.formatLabel(e.__groupValue, e.__groupDepth || 0, e.__groupKey) : String(e.__groupValue);
|
|
1814
1819
|
g.textContent = b;
|
|
1815
1820
|
}
|
|
1816
|
-
if (h.appendChild(g),
|
|
1821
|
+
if (h.appendChild(g), o.showRowCount !== !1) {
|
|
1817
1822
|
const b = document.createElement("span");
|
|
1818
1823
|
b.className = "group-count", b.textContent = ` (${l.length})`, h.appendChild(b);
|
|
1819
1824
|
}
|
|
1820
1825
|
} else {
|
|
1821
|
-
const f =
|
|
1826
|
+
const f = r[c.field];
|
|
1822
1827
|
if (f) {
|
|
1823
|
-
const g = X(f, l,
|
|
1828
|
+
const g = X(f, l, c.field, c);
|
|
1824
1829
|
h.textContent = g != null ? String(g) : "";
|
|
1825
1830
|
} else
|
|
1826
1831
|
h.textContent = "";
|
|
@@ -1839,14 +1844,14 @@ class kt extends y {
|
|
|
1839
1844
|
* Collapse all groups.
|
|
1840
1845
|
*/
|
|
1841
1846
|
collapseAll() {
|
|
1842
|
-
this.expandedKeys =
|
|
1847
|
+
this.expandedKeys = Ge(), this.requestRender();
|
|
1843
1848
|
}
|
|
1844
1849
|
/**
|
|
1845
1850
|
* Toggle expansion of a specific group.
|
|
1846
1851
|
* @param key - The group key to toggle
|
|
1847
1852
|
*/
|
|
1848
1853
|
toggle(e) {
|
|
1849
|
-
this.expandedKeys =
|
|
1854
|
+
this.expandedKeys = Ve(this.expandedKeys, e);
|
|
1850
1855
|
const t = this.flattenedRows.find((n) => n.kind === "group" && n.key === e);
|
|
1851
1856
|
this.emit("group-toggle", {
|
|
1852
1857
|
key: e,
|
|
@@ -1980,26 +1985,26 @@ function H(i, e) {
|
|
|
1980
1985
|
const t = new Set(i);
|
|
1981
1986
|
return t.has(e) ? t.delete(e) : t.add(e), t;
|
|
1982
1987
|
}
|
|
1983
|
-
function
|
|
1988
|
+
function $e(i, e) {
|
|
1984
1989
|
const t = new Set(i);
|
|
1985
1990
|
return t.add(e), t;
|
|
1986
1991
|
}
|
|
1987
|
-
function
|
|
1992
|
+
function je(i, e) {
|
|
1988
1993
|
const t = new Set(i);
|
|
1989
1994
|
return t.delete(e), t;
|
|
1990
1995
|
}
|
|
1991
|
-
function
|
|
1996
|
+
function Ue(i, e) {
|
|
1992
1997
|
return i.has(e);
|
|
1993
1998
|
}
|
|
1994
|
-
function
|
|
1995
|
-
const r = document.createElement("div");
|
|
1996
|
-
r.className = "master-detail-row", r.setAttribute("data-detail-for", String(e)), r.setAttribute("role", "row");
|
|
1999
|
+
function Ye(i, e, t, n) {
|
|
1997
2000
|
const o = document.createElement("div");
|
|
1998
|
-
o.className = "master-detail-
|
|
2001
|
+
o.className = "master-detail-row", o.setAttribute("data-detail-for", String(e)), o.setAttribute("role", "row");
|
|
2002
|
+
const r = document.createElement("div");
|
|
2003
|
+
r.className = "master-detail-cell", r.setAttribute("role", "cell"), r.style.gridColumn = `1 / ${n + 1}`;
|
|
1999
2004
|
const s = t(i, e);
|
|
2000
|
-
return typeof s == "string" ?
|
|
2005
|
+
return typeof s == "string" ? r.innerHTML = s : s instanceof HTMLElement && r.appendChild(s), o.appendChild(r), o;
|
|
2001
2006
|
}
|
|
2002
|
-
class
|
|
2007
|
+
class At extends y {
|
|
2003
2008
|
name = "masterDetail";
|
|
2004
2009
|
version = "1.0.0";
|
|
2005
2010
|
get defaultConfig() {
|
|
@@ -2024,28 +2029,31 @@ class Et extends y {
|
|
|
2024
2029
|
return [...e];
|
|
2025
2030
|
const t = [...e];
|
|
2026
2031
|
if (t.length > 0) {
|
|
2027
|
-
const n = { ...t[0] },
|
|
2028
|
-
|
|
2029
|
-
|
|
2032
|
+
const n = { ...t[0] }, o = n.viewRenderer;
|
|
2033
|
+
if (o?.__masterDetailWrapped)
|
|
2034
|
+
return t;
|
|
2035
|
+
const r = (s) => {
|
|
2036
|
+
const { value: l, row: a } = s, d = this.expandedRows.has(a), c = document.createElement("span");
|
|
2030
2037
|
c.className = "master-detail-cell-wrapper";
|
|
2031
|
-
const d = document.createElement("span");
|
|
2032
|
-
d.className = "master-detail-toggle", d.textContent = a ? "▼" : "▶", d.setAttribute("aria-expanded", String(a)), d.setAttribute("aria-label", a ? "Collapse details" : "Expand details"), d.addEventListener("click", (h) => {
|
|
2033
|
-
h.stopPropagation();
|
|
2034
|
-
const f = this.rows.indexOf(l);
|
|
2035
|
-
this.expandedRows = H(this.expandedRows, l), this.emit("detail-expand", {
|
|
2036
|
-
rowIndex: f,
|
|
2037
|
-
row: l,
|
|
2038
|
-
expanded: this.expandedRows.has(l)
|
|
2039
|
-
}), this.requestRender();
|
|
2040
|
-
}), c.appendChild(d);
|
|
2041
2038
|
const u = document.createElement("span");
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
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) => {
|
|
2040
|
+
f.stopPropagation();
|
|
2041
|
+
const g = this.rows.indexOf(a);
|
|
2042
|
+
this.expandedRows = H(this.expandedRows, a), this.emit("detail-expand", {
|
|
2043
|
+
rowIndex: g,
|
|
2044
|
+
row: a,
|
|
2045
|
+
expanded: this.expandedRows.has(a)
|
|
2046
|
+
}), this.requestRender();
|
|
2047
|
+
}), c.appendChild(u);
|
|
2048
|
+
const h = document.createElement("span");
|
|
2049
|
+
if (o) {
|
|
2050
|
+
const f = o(s);
|
|
2051
|
+
f instanceof Node ? h.appendChild(f) : h.textContent = String(f ?? l ?? "");
|
|
2045
2052
|
} else
|
|
2046
|
-
|
|
2047
|
-
return c.appendChild(
|
|
2048
|
-
}
|
|
2053
|
+
h.textContent = String(l ?? "");
|
|
2054
|
+
return c.appendChild(h), c;
|
|
2055
|
+
};
|
|
2056
|
+
r.__masterDetailWrapped = !0, n.viewRenderer = r, t[0] = n;
|
|
2049
2057
|
}
|
|
2050
2058
|
return t;
|
|
2051
2059
|
}
|
|
@@ -2057,20 +2065,104 @@ class Et extends y {
|
|
|
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);
|
|
2109
|
+
}
|
|
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
|
+
}
|
|
2073
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;
|
|
2074
2166
|
}
|
|
2075
2167
|
// ===== Public API =====
|
|
2076
2168
|
/**
|
|
@@ -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.
|
|
@@ -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,22 +2261,22 @@ class Et extends y {
|
|
|
2169
2261
|
}
|
|
2170
2262
|
`;
|
|
2171
2263
|
}
|
|
2172
|
-
function
|
|
2173
|
-
return e.length ? [...i].sort((n,
|
|
2174
|
-
for (const
|
|
2175
|
-
const l = t.find((u) => u.field ===
|
|
2176
|
-
if (
|
|
2177
|
-
return
|
|
2264
|
+
function Xe(i, e, t) {
|
|
2265
|
+
return e.length ? [...i].sort((n, o) => {
|
|
2266
|
+
for (const r of e) {
|
|
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
|
|
2186
|
-
const
|
|
2187
|
-
return t ?
|
|
2277
|
+
function Qe(i, e, t, n) {
|
|
2278
|
+
const o = i.find((r) => r.field === e);
|
|
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
|
}
|
|
2189
2281
|
function le(i, e) {
|
|
2190
2282
|
const t = i.findIndex((n) => n.field === e);
|
|
@@ -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,30 +2303,30 @@ 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
|
-
if (!this.columns.find((
|
|
2218
|
-
const n = e.originalEvent.shiftKey,
|
|
2219
|
-
return this.sortModel =
|
|
2309
|
+
if (!this.columns.find((r) => r.field === e.field)?.sortable) return !1;
|
|
2310
|
+
const n = e.originalEvent.shiftKey, o = this.config.maxSortColumns ?? 3;
|
|
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;
|
|
2223
2315
|
if (!e) return;
|
|
2224
2316
|
const t = this.config.showSortIndex !== !1;
|
|
2225
|
-
e.querySelectorAll(".header-row .cell[data-field]").forEach((
|
|
2226
|
-
const
|
|
2227
|
-
if (!
|
|
2228
|
-
const s = le(this.sortModel,
|
|
2229
|
-
if (
|
|
2230
|
-
|
|
2231
|
-
const
|
|
2232
|
-
if (
|
|
2317
|
+
e.querySelectorAll(".header-row .cell[data-field]").forEach((o) => {
|
|
2318
|
+
const r = o.getAttribute("data-field");
|
|
2319
|
+
if (!r) return;
|
|
2320
|
+
const s = le(this.sortModel, r), l = ae(this.sortModel, r);
|
|
2321
|
+
if (o.querySelector(".sort-index")?.remove(), l) {
|
|
2322
|
+
o.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), o.setAttribute("data-sort", l);
|
|
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
|
-
u.className = "sort-index", u.textContent = String(s),
|
|
2326
|
+
u.className = "sort-index", u.textContent = String(s), o.appendChild(u);
|
|
2235
2327
|
}
|
|
2236
2328
|
} else
|
|
2237
|
-
|
|
2329
|
+
o.removeAttribute("data-sort");
|
|
2238
2330
|
});
|
|
2239
2331
|
}
|
|
2240
2332
|
// ===== Public API =====
|
|
@@ -2279,7 +2371,7 @@ class At extends y {
|
|
|
2279
2371
|
* Return sort state for a column if it's in the sort model.
|
|
2280
2372
|
*/
|
|
2281
2373
|
getColumnState(e) {
|
|
2282
|
-
const t = this.sortModel.findIndex((
|
|
2374
|
+
const t = this.sortModel.findIndex((o) => o.field === e);
|
|
2283
2375
|
return t === -1 ? void 0 : {
|
|
2284
2376
|
sort: {
|
|
2285
2377
|
direction: this.sortModel[t].direction,
|
|
@@ -2293,14 +2385,14 @@ class At extends y {
|
|
|
2293
2385
|
*/
|
|
2294
2386
|
applyColumnState(e, t) {
|
|
2295
2387
|
if (!t.sort) {
|
|
2296
|
-
this.sortModel = this.sortModel.filter((
|
|
2388
|
+
this.sortModel = this.sortModel.filter((r) => r.field !== e);
|
|
2297
2389
|
return;
|
|
2298
2390
|
}
|
|
2299
|
-
const n = this.sortModel.findIndex((
|
|
2391
|
+
const n = this.sortModel.findIndex((r) => r.field === e), o = {
|
|
2300
2392
|
field: e,
|
|
2301
2393
|
direction: t.sort.direction
|
|
2302
2394
|
};
|
|
2303
|
-
n !== -1 ? this.sortModel[n] =
|
|
2395
|
+
n !== -1 ? this.sortModel[n] = o : this.sortModel.splice(t.sort.priority, 0, o);
|
|
2304
2396
|
}
|
|
2305
2397
|
// ===== Styles =====
|
|
2306
2398
|
styles = `
|
|
@@ -2329,10 +2421,10 @@ 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
2430
|
function O(i) {
|
|
@@ -2343,25 +2435,25 @@ function de(i, e) {
|
|
|
2343
2435
|
if (!t) return;
|
|
2344
2436
|
const n = Array.from(t.querySelectorAll(".header-row .cell"));
|
|
2345
2437
|
if (!n.length) return;
|
|
2346
|
-
const
|
|
2438
|
+
const o = /* @__PURE__ */ new Map();
|
|
2347
2439
|
e.forEach((l, a) => {
|
|
2348
|
-
l.field &&
|
|
2440
|
+
l.field && o.set(l.field, a);
|
|
2349
2441
|
});
|
|
2350
|
-
let
|
|
2442
|
+
let r = 0;
|
|
2351
2443
|
for (const l of e)
|
|
2352
2444
|
if (l.sticky === "left") {
|
|
2353
|
-
const a =
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
}),
|
|
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 =
|
|
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) {
|
|
@@ -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.
|
|
@@ -2445,10 +2537,10 @@ function W(i, e) {
|
|
|
2445
2537
|
t.className = "tbw-pinned-rows", t.setAttribute("role", "status"), t.setAttribute("aria-live", "polite");
|
|
2446
2538
|
const n = document.createElement("div");
|
|
2447
2539
|
n.className = "tbw-pinned-rows-left";
|
|
2448
|
-
const r = document.createElement("div");
|
|
2449
|
-
r.className = "tbw-pinned-rows-center";
|
|
2450
2540
|
const o = document.createElement("div");
|
|
2451
|
-
|
|
2541
|
+
o.className = "tbw-pinned-rows-center";
|
|
2542
|
+
const r = document.createElement("div");
|
|
2543
|
+
if (r.className = "tbw-pinned-rows-right", i.showRowCount !== !1) {
|
|
2452
2544
|
const s = document.createElement("span");
|
|
2453
2545
|
s.className = "tbw-status-panel tbw-status-panel-row-count", s.textContent = `Total: ${e.totalRows} rows`, n.appendChild(s);
|
|
2454
2546
|
}
|
|
@@ -2458,24 +2550,24 @@ function W(i, e) {
|
|
|
2458
2550
|
}
|
|
2459
2551
|
if (i.showSelectedCount && e.selectedRows > 0) {
|
|
2460
2552
|
const s = document.createElement("span");
|
|
2461
|
-
s.className = "tbw-status-panel tbw-status-panel-selected-count", s.textContent = `Selected: ${e.selectedRows}`,
|
|
2553
|
+
s.className = "tbw-status-panel tbw-status-panel-selected-count", s.textContent = `Selected: ${e.selectedRows}`, r.appendChild(s);
|
|
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);
|
|
2469
2561
|
break;
|
|
2470
2562
|
case "center":
|
|
2471
|
-
|
|
2563
|
+
o.appendChild(l);
|
|
2472
2564
|
break;
|
|
2473
2565
|
case "right":
|
|
2474
|
-
|
|
2566
|
+
r.appendChild(l);
|
|
2475
2567
|
break;
|
|
2476
2568
|
}
|
|
2477
2569
|
}
|
|
2478
|
-
return t.appendChild(n), t.appendChild(
|
|
2570
|
+
return t.appendChild(n), t.appendChild(o), t.appendChild(r), t;
|
|
2479
2571
|
}
|
|
2480
2572
|
function ue(i) {
|
|
2481
2573
|
const e = document.createElement("div");
|
|
@@ -2483,46 +2575,46 @@ function ue(i) {
|
|
|
2483
2575
|
}
|
|
2484
2576
|
function he(i, e, t, n) {
|
|
2485
2577
|
i.innerHTML = "";
|
|
2486
|
-
for (const
|
|
2487
|
-
const
|
|
2488
|
-
if (
|
|
2578
|
+
for (const o of e) {
|
|
2579
|
+
const r = document.createElement("div");
|
|
2580
|
+
if (r.className = "tbw-aggregation-row", r.setAttribute("role", "row"), o.id && r.setAttribute("data-aggregation-id", o.id), o.fullWidth) {
|
|
2489
2581
|
const s = document.createElement("div");
|
|
2490
|
-
s.className = "tbw-aggregation-cell tbw-aggregation-cell-full", s.style.gridColumn = "1 / -1", s.textContent =
|
|
2582
|
+
s.className = "tbw-aggregation-cell tbw-aggregation-cell-full", s.style.gridColumn = "1 / -1", s.textContent = o.label || "", r.appendChild(s);
|
|
2491
2583
|
} else
|
|
2492
2584
|
for (const s of t) {
|
|
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
|
-
|
|
2500
|
-
} else if (
|
|
2501
|
-
const
|
|
2502
|
-
typeof
|
|
2588
|
+
const d = o.aggregators?.[s.field];
|
|
2589
|
+
if (d) {
|
|
2590
|
+
const c = ve(d);
|
|
2591
|
+
c && (a = c(n, s.field, s));
|
|
2592
|
+
} else if (o.cells && Object.prototype.hasOwnProperty.call(o.cells, s.field)) {
|
|
2593
|
+
const c = o.cells[s.field];
|
|
2594
|
+
typeof c == "function" ? a = c(n, s.field, s) : a = c;
|
|
2503
2595
|
}
|
|
2504
|
-
l.textContent = a != null ? String(a) : "",
|
|
2596
|
+
l.textContent = a != null ? String(a) : "", r.appendChild(l);
|
|
2505
2597
|
}
|
|
2506
|
-
i.appendChild(
|
|
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);
|
|
2513
2605
|
return typeof n == "string" ? t.innerHTML = n : t.appendChild(n), t;
|
|
2514
2606
|
}
|
|
2515
|
-
function fe(i, e, t, n,
|
|
2607
|
+
function fe(i, e, t, n, o) {
|
|
2516
2608
|
return {
|
|
2517
2609
|
totalRows: i.length,
|
|
2518
|
-
filteredRows:
|
|
2610
|
+
filteredRows: o?.cachedResult?.length ?? i.length,
|
|
2519
2611
|
selectedRows: n?.selected?.size ?? 0,
|
|
2520
2612
|
columns: e,
|
|
2521
2613
|
rows: i,
|
|
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() {
|
|
@@ -2553,12 +2645,12 @@ class It extends y {
|
|
|
2553
2645
|
if (!e) return;
|
|
2554
2646
|
const t = e.querySelector(".tbw-scroll-area") ?? e.querySelector(".tbw-grid-content") ?? e.children[0];
|
|
2555
2647
|
if (!t) return;
|
|
2556
|
-
const n = this.getSelectionState(),
|
|
2648
|
+
const n = this.getSelectionState(), o = this.getFilterState(), r = fe(
|
|
2557
2649
|
this.rows,
|
|
2558
2650
|
this.columns,
|
|
2559
2651
|
this.grid,
|
|
2560
2652
|
n,
|
|
2561
|
-
|
|
2653
|
+
o
|
|
2562
2654
|
), s = this.config.aggregationRows || [], l = s.filter((h) => h.position === "top"), a = s.filter((h) => h.position !== "top");
|
|
2563
2655
|
if (l.length > 0) {
|
|
2564
2656
|
if (!this.topAggregationContainer) {
|
|
@@ -2573,12 +2665,12 @@ 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
|
-
this.infoBarElement = W(this.config,
|
|
2671
|
+
this.infoBarElement = W(this.config, r), t.insertBefore(this.infoBarElement, t.firstChild);
|
|
2580
2672
|
else {
|
|
2581
|
-
const h = W(this.config,
|
|
2673
|
+
const h = W(this.config, r);
|
|
2582
2674
|
this.infoBarElement.replaceWith(h), this.infoBarElement = h;
|
|
2583
2675
|
}
|
|
2584
2676
|
else this.config.position === "top" && this.infoBarElement && (this.infoBarElement.remove(), this.infoBarElement = null);
|
|
@@ -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);
|
|
@@ -2761,75 +2853,75 @@ function $(i, e) {
|
|
|
2761
2853
|
return [...i, e].join("|");
|
|
2762
2854
|
}
|
|
2763
2855
|
function rt(i, e) {
|
|
2764
|
-
const t = e.rowGroupFields ?? [], n = e.columnGroupFields ?? [],
|
|
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
|
-
columnKeys:
|
|
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) {
|
|
2776
|
-
const
|
|
2777
|
-
t.add(
|
|
2868
|
+
const o = e.map((r) => String(n[r] ?? "")).join("|");
|
|
2869
|
+
t.add(o);
|
|
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
|
-
const
|
|
2785
|
-
t.has(
|
|
2786
|
-
const
|
|
2787
|
-
|
|
2876
|
+
const o = e.map((s) => String(n[s] ?? "")).join("|");
|
|
2877
|
+
t.has(o) || t.set(o, []);
|
|
2878
|
+
const r = t.get(o);
|
|
2879
|
+
r && r.push(n);
|
|
2788
2880
|
}
|
|
2789
2881
|
return t;
|
|
2790
2882
|
}
|
|
2791
|
-
function
|
|
2792
|
-
const
|
|
2883
|
+
function lt(i, e, t, n, o) {
|
|
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
|
-
depth:
|
|
2896
|
+
depth: o,
|
|
2805
2897
|
values: a,
|
|
2806
|
-
total:
|
|
2898
|
+
total: d,
|
|
2807
2899
|
isGroup: !1
|
|
2808
2900
|
});
|
|
2809
2901
|
}
|
|
2810
|
-
return
|
|
2902
|
+
return r;
|
|
2811
2903
|
}
|
|
2812
|
-
function
|
|
2904
|
+
function at(i, e, t) {
|
|
2813
2905
|
const n = {};
|
|
2814
|
-
for (const
|
|
2815
|
-
for (const
|
|
2816
|
-
const s = $([
|
|
2906
|
+
for (const o of e)
|
|
2907
|
+
for (const r of t) {
|
|
2908
|
+
const s = $([o], r.field);
|
|
2817
2909
|
n[s] = i.reduce((l, a) => l + (a.values[s] ?? 0), 0);
|
|
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)
|
|
2825
|
-
for (const
|
|
2826
|
-
t(
|
|
2917
|
+
for (const o of n.children)
|
|
2918
|
+
t(o);
|
|
2827
2919
|
}
|
|
2828
2920
|
for (const n of 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 = rt(e, this.config),
|
|
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,
|
|
@@ -2872,11 +2964,11 @@ class Tt extends y {
|
|
|
2872
2964
|
width: 200
|
|
2873
2965
|
});
|
|
2874
2966
|
for (const n of this.pivotResult.columnKeys)
|
|
2875
|
-
for (const
|
|
2876
|
-
const
|
|
2967
|
+
for (const o of this.config.valueFields ?? []) {
|
|
2968
|
+
const r = $([n], o.field);
|
|
2877
2969
|
t.push({
|
|
2878
|
-
field:
|
|
2879
|
-
header: `${n} - ${
|
|
2970
|
+
field: r,
|
|
2971
|
+
header: `${n} - ${o.header || o.field} (${o.aggFunc})`,
|
|
2880
2972
|
width: 120,
|
|
2881
2973
|
type: "number"
|
|
2882
2974
|
});
|
|
@@ -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;
|
|
@@ -2958,10 +3050,10 @@ function dt(i) {
|
|
|
2958
3050
|
}
|
|
2959
3051
|
function ge(i, e, t) {
|
|
2960
3052
|
if (e === t || e < 0 || e >= i.length || t < 0 || t > i.length) return i;
|
|
2961
|
-
const n = [...i], [
|
|
2962
|
-
return n.splice(t, 0,
|
|
3053
|
+
const n = [...i], [o] = n.splice(e, 1);
|
|
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() {
|
|
@@ -2976,19 +3068,19 @@ class Lt extends y {
|
|
|
2976
3068
|
draggedField = null;
|
|
2977
3069
|
draggedIndex = null;
|
|
2978
3070
|
dropIndex = null;
|
|
2979
|
-
boundReorderRequestHandler = null;
|
|
2980
3071
|
// ===== Lifecycle =====
|
|
2981
3072
|
attach(e) {
|
|
2982
|
-
super.attach(e),
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
3073
|
+
super.attach(e), e.addEventListener(
|
|
3074
|
+
"column-reorder-request",
|
|
3075
|
+
(t) => {
|
|
3076
|
+
const n = t.detail;
|
|
3077
|
+
n?.field && typeof n.toIndex == "number" && this.moveColumn(n.field, n.toIndex);
|
|
3078
|
+
},
|
|
3079
|
+
{ signal: this.disconnectSignal }
|
|
3080
|
+
);
|
|
2986
3081
|
}
|
|
2987
3082
|
detach() {
|
|
2988
|
-
this.
|
|
2989
|
-
"column-reorder-request",
|
|
2990
|
-
this.boundReorderRequestHandler
|
|
2991
|
-
), this.boundReorderRequestHandler = null), this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null;
|
|
3083
|
+
this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null;
|
|
2992
3084
|
}
|
|
2993
3085
|
// ===== Hooks =====
|
|
2994
3086
|
// Note: No processColumns hook needed - we directly update the grid's column order
|
|
@@ -2997,34 +3089,34 @@ class Lt extends y {
|
|
|
2997
3089
|
const e = this.shadowRoot;
|
|
2998
3090
|
if (!e) return;
|
|
2999
3091
|
e.querySelectorAll(".header-row > .cell").forEach((n) => {
|
|
3000
|
-
const
|
|
3001
|
-
if (!
|
|
3002
|
-
const s = this.columns.find((l) => l.field ===
|
|
3003
|
-
if (!s || !
|
|
3004
|
-
|
|
3092
|
+
const o = n, r = o.getAttribute("data-field");
|
|
3093
|
+
if (!r) return;
|
|
3094
|
+
const s = this.columns.find((l) => l.field === r);
|
|
3095
|
+
if (!s || !ct(s)) {
|
|
3096
|
+
o.draggable = !1;
|
|
3005
3097
|
return;
|
|
3006
3098
|
}
|
|
3007
|
-
|
|
3008
|
-
const
|
|
3009
|
-
this.isDragging = !0, this.draggedField =
|
|
3010
|
-
}),
|
|
3099
|
+
o.draggable = !0, !o.getAttribute("data-dragstart-bound") && (o.setAttribute("data-dragstart-bound", "true"), o.addEventListener("dragstart", (l) => {
|
|
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");
|
|
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
|
-
}),
|
|
3015
|
-
if (l.preventDefault(), !this.isDragging || this.draggedField ===
|
|
3016
|
-
const a =
|
|
3017
|
-
this.dropIndex = l.clientX <
|
|
3018
|
-
}),
|
|
3019
|
-
|
|
3020
|
-
}),
|
|
3106
|
+
}), o.addEventListener("dragover", (l) => {
|
|
3107
|
+
if (l.preventDefault(), !this.isDragging || this.draggedField === r) return;
|
|
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);
|
|
3110
|
+
}), o.addEventListener("dragleave", () => {
|
|
3111
|
+
o.classList.remove("drop-target", "drop-before", "drop-after");
|
|
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
|
};
|
|
@@ -3046,14 +3138,14 @@ class Lt extends y {
|
|
|
3046
3138
|
* @param toIndex - The target index
|
|
3047
3139
|
*/
|
|
3048
3140
|
moveColumn(e, t) {
|
|
3049
|
-
const n = this.getColumnOrder(),
|
|
3050
|
-
if (
|
|
3051
|
-
const
|
|
3052
|
-
this.grid.setColumnOrder(
|
|
3141
|
+
const n = this.getColumnOrder(), o = n.indexOf(e);
|
|
3142
|
+
if (o === -1) return;
|
|
3143
|
+
const r = ge(n, o, t);
|
|
3144
|
+
this.grid.setColumnOrder(r), this.emit("column-move", {
|
|
3053
3145
|
field: e,
|
|
3054
|
-
fromIndex:
|
|
3146
|
+
fromIndex: o,
|
|
3055
3147
|
toIndex: t,
|
|
3056
|
-
columnOrder:
|
|
3148
|
+
columnOrder: r
|
|
3057
3149
|
}), this.grid.requestStateChange?.();
|
|
3058
3150
|
}
|
|
3059
3151
|
/**
|
|
@@ -3105,35 +3197,35 @@ 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
|
|
3115
|
-
const n = M(i, t),
|
|
3116
|
-
for (let s = n; s <=
|
|
3117
|
-
|
|
3118
|
-
return
|
|
3206
|
+
function ht(i, e, t) {
|
|
3207
|
+
const n = M(i, t), o = M(e - 1, t), r = [];
|
|
3208
|
+
for (let s = n; s <= o; s++)
|
|
3209
|
+
r.push(s);
|
|
3210
|
+
return r;
|
|
3119
3211
|
}
|
|
3120
3212
|
async function pe(i, e, t, n) {
|
|
3121
|
-
const
|
|
3213
|
+
const o = ut(e, t);
|
|
3122
3214
|
return i.getRows({
|
|
3123
|
-
startRow:
|
|
3124
|
-
endRow:
|
|
3215
|
+
startRow: o.start,
|
|
3216
|
+
endRow: o.end,
|
|
3125
3217
|
sortModel: n.sortModel,
|
|
3126
3218
|
filterModel: n.filterModel
|
|
3127
3219
|
});
|
|
3128
3220
|
}
|
|
3129
|
-
function
|
|
3130
|
-
const n = M(i, e),
|
|
3131
|
-
if (!
|
|
3132
|
-
const
|
|
3133
|
-
return r
|
|
3221
|
+
function ft(i, e, t) {
|
|
3222
|
+
const n = M(i, e), o = t.get(n);
|
|
3223
|
+
if (!o) return;
|
|
3224
|
+
const r = i % e;
|
|
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,15 +3253,15 @@ 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 },
|
|
3165
|
-
for (const
|
|
3166
|
-
if (!(this.loadedBlocks.has(
|
|
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);
|
|
3257
|
+
for (const r of o)
|
|
3258
|
+
if (!(this.loadedBlocks.has(r) || this.loadingBlocks.has(r))) {
|
|
3167
3259
|
if (this.loadingBlocks.size >= (this.config.maxConcurrentRequests ?? 2))
|
|
3168
3260
|
break;
|
|
3169
|
-
this.loadingBlocks.add(
|
|
3170
|
-
this.loadedBlocks.set(
|
|
3261
|
+
this.loadingBlocks.add(r), pe(this.dataSource, r, t, {}).then((s) => {
|
|
3262
|
+
this.loadedBlocks.set(r, s.rows), this.totalRowCount = s.totalRowCount, this.loadingBlocks.delete(r), this.requestRender(), this.loadRequiredBlocks();
|
|
3171
3263
|
}).catch(() => {
|
|
3172
|
-
this.loadingBlocks.delete(
|
|
3264
|
+
this.loadingBlocks.delete(r);
|
|
3173
3265
|
});
|
|
3174
3266
|
}
|
|
3175
3267
|
}
|
|
@@ -3178,15 +3270,15 @@ 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
|
|
3182
|
-
t.push(
|
|
3273
|
+
const o = ft(n, this.config.cacheBlockSize ?? 100, this.loadedBlocks);
|
|
3274
|
+
t.push(o ?? { __loading: !0, __index: n });
|
|
3183
3275
|
}
|
|
3184
3276
|
return t;
|
|
3185
3277
|
}
|
|
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() {
|
|
@@ -3313,22 +3405,22 @@ class qt extends y {
|
|
|
3313
3405
|
if (!this.config.enabled) return !1;
|
|
3314
3406
|
const t = (e.ctrlKey || e.metaKey) && e.key === "z" && !e.shiftKey, n = (e.ctrlKey || e.metaKey) && (e.key === "y" || e.key === "z" && e.shiftKey);
|
|
3315
3407
|
if (t) {
|
|
3316
|
-
const
|
|
3317
|
-
if (
|
|
3318
|
-
const
|
|
3319
|
-
o
|
|
3320
|
-
action:
|
|
3408
|
+
const o = me({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
3409
|
+
if (o.action) {
|
|
3410
|
+
const r = this.rows;
|
|
3411
|
+
r[o.action.rowIndex] && (r[o.action.rowIndex][o.action.field] = o.action.oldValue), this.undoStack = o.newState.undoStack, this.redoStack = o.newState.redoStack, this.emit("undo", {
|
|
3412
|
+
action: o.action,
|
|
3321
3413
|
type: "undo"
|
|
3322
3414
|
}), this.requestRender();
|
|
3323
3415
|
}
|
|
3324
3416
|
return !0;
|
|
3325
3417
|
}
|
|
3326
3418
|
if (n) {
|
|
3327
|
-
const
|
|
3328
|
-
if (
|
|
3329
|
-
const
|
|
3330
|
-
o
|
|
3331
|
-
action:
|
|
3419
|
+
const o = be({ undoStack: this.undoStack, redoStack: this.redoStack });
|
|
3420
|
+
if (o.action) {
|
|
3421
|
+
const r = this.rows;
|
|
3422
|
+
r[o.action.rowIndex] && (r[o.action.rowIndex][o.action.field] = o.action.newValue), this.undoStack = o.newState.undoStack, this.redoStack = o.newState.redoStack, this.emit("redo", {
|
|
3423
|
+
action: o.action,
|
|
3332
3424
|
type: "redo"
|
|
3333
3425
|
}), this.requestRender();
|
|
3334
3426
|
}
|
|
@@ -3346,10 +3438,10 @@ class qt extends y {
|
|
|
3346
3438
|
* @param oldValue - The value before the edit
|
|
3347
3439
|
* @param newValue - The value after the edit
|
|
3348
3440
|
*/
|
|
3349
|
-
recordEdit(e, t, n,
|
|
3350
|
-
const
|
|
3441
|
+
recordEdit(e, t, n, o) {
|
|
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
|
|
3354
3446
|
);
|
|
3355
3447
|
this.undoStack = s.undoStack, this.redoStack = s.redoStack;
|
|
@@ -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
|
/**
|
|
@@ -3559,12 +3651,12 @@ class _ extends y {
|
|
|
3559
3651
|
renderPanelContent(e) {
|
|
3560
3652
|
const t = this.grid, n = document.createElement("div");
|
|
3561
3653
|
n.className = "tbw-visibility-content";
|
|
3562
|
-
const
|
|
3563
|
-
|
|
3564
|
-
const
|
|
3565
|
-
return
|
|
3566
|
-
t.showAllColumns(), this.rebuildToggles(
|
|
3567
|
-
}), n.appendChild(
|
|
3654
|
+
const o = document.createElement("div");
|
|
3655
|
+
o.className = "tbw-visibility-list", n.appendChild(o);
|
|
3656
|
+
const r = document.createElement("button");
|
|
3657
|
+
return r.className = "tbw-visibility-show-all", r.textContent = "Show All", r.addEventListener("click", () => {
|
|
3658
|
+
t.showAllColumns(), this.rebuildToggles(o);
|
|
3659
|
+
}), n.appendChild(r), this.columnListElement = o, this.rebuildToggles(o), e.appendChild(n), () => {
|
|
3568
3660
|
this.columnListElement = null, n.remove();
|
|
3569
3661
|
};
|
|
3570
3662
|
}
|
|
@@ -3582,57 +3674,57 @@ class _ extends y {
|
|
|
3582
3674
|
rebuildToggles(e) {
|
|
3583
3675
|
const t = this.grid, n = this.hasReorderPlugin();
|
|
3584
3676
|
e.innerHTML = "";
|
|
3585
|
-
const
|
|
3586
|
-
for (let
|
|
3587
|
-
const s = r
|
|
3588
|
-
a.className = s.lockVisible ? "tbw-visibility-row locked" : "tbw-visibility-row", a.setAttribute("data-field", s.field), a.setAttribute("data-index", String(
|
|
3589
|
-
const
|
|
3590
|
-
|
|
3591
|
-
const
|
|
3592
|
-
|
|
3677
|
+
const o = t.getAllColumns();
|
|
3678
|
+
for (let r = 0; r < o.length; r++) {
|
|
3679
|
+
const s = o[r], l = s.header || s.field, a = document.createElement("div");
|
|
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));
|
|
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
|
/**
|
|
3604
3696
|
* Set up drag-and-drop event listeners for a row.
|
|
3605
3697
|
* On drop, emits a 'column-reorder-request' event for other plugins to handle.
|
|
3606
3698
|
*/
|
|
3607
|
-
setupDragListeners(e, t, n,
|
|
3608
|
-
e.addEventListener("dragstart", (
|
|
3609
|
-
this.isDragging = !0, this.draggedField = t, this.draggedIndex = n,
|
|
3699
|
+
setupDragListeners(e, t, n, o) {
|
|
3700
|
+
e.addEventListener("dragstart", (r) => {
|
|
3701
|
+
this.isDragging = !0, this.draggedField = t, this.draggedIndex = n, r.dataTransfer && (r.dataTransfer.effectAllowed = "move", r.dataTransfer.setData("text/plain", t)), e.classList.add("dragging");
|
|
3610
3702
|
}), e.addEventListener("dragend", () => {
|
|
3611
|
-
this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null,
|
|
3612
|
-
|
|
3703
|
+
this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, o.querySelectorAll(".tbw-visibility-row").forEach((r) => {
|
|
3704
|
+
r.classList.remove("dragging", "drop-target", "drop-before", "drop-after");
|
|
3613
3705
|
});
|
|
3614
|
-
}), e.addEventListener("dragover", (
|
|
3615
|
-
if (
|
|
3706
|
+
}), e.addEventListener("dragover", (r) => {
|
|
3707
|
+
if (r.preventDefault(), !this.isDragging || this.draggedField === t) return;
|
|
3616
3708
|
const s = e.getBoundingClientRect(), l = s.top + s.height / 2;
|
|
3617
|
-
this.dropIndex =
|
|
3709
|
+
this.dropIndex = r.clientY < l ? n : n + 1, o.querySelectorAll(".tbw-visibility-row").forEach((a) => {
|
|
3618
3710
|
a !== e && a.classList.remove("drop-target", "drop-before", "drop-after");
|
|
3619
|
-
}), e.classList.add("drop-target"), e.classList.toggle("drop-before",
|
|
3711
|
+
}), e.classList.add("drop-target"), e.classList.toggle("drop-before", r.clientY < l), e.classList.toggle("drop-after", r.clientY >= l);
|
|
3620
3712
|
}), e.addEventListener("dragleave", () => {
|
|
3621
3713
|
e.classList.remove("drop-target", "drop-before", "drop-after");
|
|
3622
|
-
}), e.addEventListener("drop", (
|
|
3623
|
-
|
|
3714
|
+
}), e.addEventListener("drop", (r) => {
|
|
3715
|
+
r.preventDefault();
|
|
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",
|
|
3635
|
-
this.rebuildToggles(
|
|
3726
|
+
this.emit("column-reorder-request", c), setTimeout(() => {
|
|
3727
|
+
this.rebuildToggles(o);
|
|
3636
3728
|
}, 0);
|
|
3637
3729
|
}
|
|
3638
3730
|
});
|
|
@@ -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
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3837
|
+
Ht as FitModeEnum,
|
|
3838
|
+
Ot as GridCSSVars,
|
|
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
|