@toolbox-web/grid 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/all.d.ts +486 -80
- package/all.js +1364 -1029
- package/all.js.map +1 -1
- package/index-DG2CZ_Zo.js +3229 -0
- package/index-DG2CZ_Zo.js.map +1 -0
- package/index.d.ts +222 -11
- package/index.js +25 -3143
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +1 -1
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js +184 -149
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js +46 -45
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js +117 -83
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +140 -82
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +18 -18
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +55 -47
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +385 -351
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js +278 -85
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +28 -27
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +2 -2
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js +181 -170
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +22 -22
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +12 -12
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/pivot.umd.js +1 -1
- package/umd/plugins/pivot.umd.js.map +1 -1
- package/umd/plugins/reorder.umd.js +1 -1
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/server-side.umd.js +1 -1
- package/umd/plugins/server-side.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const E = {
|
|
2
2
|
expand: "▶",
|
|
3
3
|
collapse: "▼",
|
|
4
4
|
sortAsc: "▲",
|
|
@@ -8,7 +8,7 @@ const P = {
|
|
|
8
8
|
dragHandle: "⋮⋮",
|
|
9
9
|
toolPanel: "☰"
|
|
10
10
|
};
|
|
11
|
-
class
|
|
11
|
+
class P {
|
|
12
12
|
/** Plugin version - override in subclass if needed */
|
|
13
13
|
version = "1.0.0";
|
|
14
14
|
/** CSS styles to inject into the grid's shadow DOM */
|
|
@@ -59,8 +59,8 @@ class N {
|
|
|
59
59
|
/**
|
|
60
60
|
* Emit a custom event from the grid.
|
|
61
61
|
*/
|
|
62
|
-
emit(e,
|
|
63
|
-
this.grid?.dispatchEvent?.(new CustomEvent(e, { detail:
|
|
62
|
+
emit(e, t) {
|
|
63
|
+
this.grid?.dispatchEvent?.(new CustomEvent(e, { detail: t, bubbles: !0 }));
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
66
|
* Request a re-render of the grid.
|
|
@@ -99,7 +99,7 @@ class N {
|
|
|
99
99
|
* Use this for rendering that needs to match the grid template.
|
|
100
100
|
*/
|
|
101
101
|
get visibleColumns() {
|
|
102
|
-
return this.grid?.
|
|
102
|
+
return this.grid?._visibleColumns ?? [];
|
|
103
103
|
}
|
|
104
104
|
/**
|
|
105
105
|
* Get the shadow root of the grid.
|
|
@@ -133,7 +133,7 @@ class N {
|
|
|
133
133
|
*/
|
|
134
134
|
get gridIcons() {
|
|
135
135
|
const e = this.grid?.gridConfig?.icons ?? {};
|
|
136
|
-
return { ...
|
|
136
|
+
return { ...E, ...e };
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* Resolve an icon value to string or HTMLElement.
|
|
@@ -143,8 +143,8 @@ class N {
|
|
|
143
143
|
* @param pluginOverride - Optional plugin-level override
|
|
144
144
|
* @returns The resolved icon value
|
|
145
145
|
*/
|
|
146
|
-
resolveIcon(e,
|
|
147
|
-
return
|
|
146
|
+
resolveIcon(e, t) {
|
|
147
|
+
return t !== void 0 ? t : this.gridIcons[e];
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
150
|
* Set an icon value on an element.
|
|
@@ -153,8 +153,8 @@ class N {
|
|
|
153
153
|
* @param element - The element to set the icon on
|
|
154
154
|
* @param icon - The icon value (string or HTMLElement)
|
|
155
155
|
*/
|
|
156
|
-
setIcon(e,
|
|
157
|
-
typeof
|
|
156
|
+
setIcon(e, t) {
|
|
157
|
+
typeof t == "string" ? e.innerHTML = t : t instanceof HTMLElement && (e.innerHTML = "", e.appendChild(t.cloneNode(!0)));
|
|
158
158
|
}
|
|
159
159
|
/**
|
|
160
160
|
* Log a warning message.
|
|
@@ -165,48 +165,48 @@ class N {
|
|
|
165
165
|
// #endregion
|
|
166
166
|
}
|
|
167
167
|
const m = {
|
|
168
|
-
sum: (
|
|
169
|
-
avg: (
|
|
170
|
-
const
|
|
171
|
-
return
|
|
168
|
+
sum: (i, e) => i.reduce((t, o) => t + (Number(o[e]) || 0), 0),
|
|
169
|
+
avg: (i, e) => {
|
|
170
|
+
const t = i.reduce((o, n) => o + (Number(n[e]) || 0), 0);
|
|
171
|
+
return i.length ? t / i.length : 0;
|
|
172
172
|
},
|
|
173
|
-
count: (
|
|
174
|
-
min: (
|
|
175
|
-
max: (
|
|
176
|
-
first: (
|
|
177
|
-
last: (
|
|
173
|
+
count: (i) => i.length,
|
|
174
|
+
min: (i, e) => Math.min(...i.map((t) => Number(t[e]) || 1 / 0)),
|
|
175
|
+
max: (i, e) => Math.max(...i.map((t) => Number(t[e]) || -1 / 0)),
|
|
176
|
+
first: (i, e) => i[0]?.[e],
|
|
177
|
+
last: (i, e) => i[i.length - 1]?.[e]
|
|
178
178
|
}, v = /* @__PURE__ */ new Map(), h = {
|
|
179
179
|
/**
|
|
180
180
|
* Register a custom aggregator function.
|
|
181
181
|
*/
|
|
182
|
-
register(
|
|
183
|
-
v.set(
|
|
182
|
+
register(i, e) {
|
|
183
|
+
v.set(i, e);
|
|
184
184
|
},
|
|
185
185
|
/**
|
|
186
186
|
* Unregister a custom aggregator function.
|
|
187
187
|
*/
|
|
188
|
-
unregister(
|
|
189
|
-
v.delete(
|
|
188
|
+
unregister(i) {
|
|
189
|
+
v.delete(i);
|
|
190
190
|
},
|
|
191
191
|
/**
|
|
192
192
|
* Get an aggregator function by reference.
|
|
193
193
|
*/
|
|
194
|
-
get(
|
|
195
|
-
if (
|
|
196
|
-
return typeof
|
|
194
|
+
get(i) {
|
|
195
|
+
if (i !== void 0)
|
|
196
|
+
return typeof i == "function" ? i : v.get(i) ?? m[i];
|
|
197
197
|
},
|
|
198
198
|
/**
|
|
199
199
|
* Run an aggregator on a set of rows.
|
|
200
200
|
*/
|
|
201
|
-
run(
|
|
202
|
-
const
|
|
203
|
-
return
|
|
201
|
+
run(i, e, t, o) {
|
|
202
|
+
const n = this.get(i);
|
|
203
|
+
return n ? n(e, t, o) : void 0;
|
|
204
204
|
},
|
|
205
205
|
/**
|
|
206
206
|
* Check if an aggregator exists.
|
|
207
207
|
*/
|
|
208
|
-
has(
|
|
209
|
-
return v.has(
|
|
208
|
+
has(i) {
|
|
209
|
+
return v.has(i) || i in m;
|
|
210
210
|
},
|
|
211
211
|
/**
|
|
212
212
|
* List all available aggregator names.
|
|
@@ -215,280 +215,280 @@ const m = {
|
|
|
215
215
|
return [...Object.keys(m), ...v.keys()];
|
|
216
216
|
}
|
|
217
217
|
}, A = {
|
|
218
|
-
sum: (
|
|
219
|
-
avg: (
|
|
220
|
-
count: (
|
|
221
|
-
min: (
|
|
222
|
-
max: (
|
|
223
|
-
first: (
|
|
224
|
-
last: (
|
|
218
|
+
sum: (i) => i.reduce((e, t) => e + t, 0),
|
|
219
|
+
avg: (i) => i.length ? i.reduce((e, t) => e + t, 0) / i.length : 0,
|
|
220
|
+
count: (i) => i.length,
|
|
221
|
+
min: (i) => i.length ? Math.min(...i) : 0,
|
|
222
|
+
max: (i) => i.length ? Math.max(...i) : 0,
|
|
223
|
+
first: (i) => i[0] ?? 0,
|
|
224
|
+
last: (i) => i[i.length - 1] ?? 0
|
|
225
225
|
};
|
|
226
|
-
function
|
|
227
|
-
return A[
|
|
226
|
+
function N(i) {
|
|
227
|
+
return A[i] ?? A.sum;
|
|
228
228
|
}
|
|
229
229
|
h.register.bind(h);
|
|
230
230
|
h.unregister.bind(h);
|
|
231
231
|
h.get.bind(h);
|
|
232
232
|
h.run.bind(h);
|
|
233
233
|
h.list.bind(h);
|
|
234
|
-
const K =
|
|
235
|
-
function
|
|
234
|
+
const K = N;
|
|
235
|
+
function S(i) {
|
|
236
236
|
const e = [];
|
|
237
|
-
return !
|
|
237
|
+
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;
|
|
238
238
|
}
|
|
239
|
-
function C(
|
|
240
|
-
return [...
|
|
239
|
+
function C(i, e) {
|
|
240
|
+
return [...i, e].join("|");
|
|
241
241
|
}
|
|
242
|
-
function
|
|
243
|
-
const
|
|
244
|
-
t,
|
|
242
|
+
function I(i, e) {
|
|
243
|
+
const t = e.rowGroupFields ?? [], o = e.columnGroupFields ?? [], n = e.valueFields ?? [], r = V(i, o), s = L(
|
|
245
244
|
i,
|
|
245
|
+
t,
|
|
246
246
|
o,
|
|
247
|
-
n,
|
|
248
247
|
r,
|
|
248
|
+
n,
|
|
249
249
|
0,
|
|
250
250
|
// starting depth
|
|
251
251
|
""
|
|
252
252
|
// parent key prefix
|
|
253
|
-
),
|
|
253
|
+
), a = D(s, r, n), l = Object.values(a).reduce((d, c) => d + c, 0);
|
|
254
254
|
return {
|
|
255
|
-
rows:
|
|
256
|
-
columnKeys:
|
|
257
|
-
totals:
|
|
255
|
+
rows: s,
|
|
256
|
+
columnKeys: r,
|
|
257
|
+
totals: a,
|
|
258
258
|
grandTotal: l
|
|
259
259
|
};
|
|
260
260
|
}
|
|
261
|
-
function V(
|
|
261
|
+
function V(i, e) {
|
|
262
262
|
if (e.length === 0) return ["value"];
|
|
263
|
-
const
|
|
264
|
-
for (const o of
|
|
265
|
-
const
|
|
266
|
-
|
|
263
|
+
const t = /* @__PURE__ */ new Set();
|
|
264
|
+
for (const o of i) {
|
|
265
|
+
const n = e.map((r) => String(o[r] ?? "")).join("|");
|
|
266
|
+
t.add(n);
|
|
267
267
|
}
|
|
268
|
-
return [...
|
|
268
|
+
return [...t].sort();
|
|
269
269
|
}
|
|
270
|
-
function M(
|
|
271
|
-
const
|
|
272
|
-
for (const o of
|
|
273
|
-
const
|
|
274
|
-
|
|
270
|
+
function M(i, e) {
|
|
271
|
+
const t = /* @__PURE__ */ new Map();
|
|
272
|
+
for (const o of i) {
|
|
273
|
+
const n = String(o[e] ?? ""), r = t.get(n);
|
|
274
|
+
r ? r.push(o) : t.set(n, [o]);
|
|
275
275
|
}
|
|
276
|
-
return
|
|
276
|
+
return t;
|
|
277
277
|
}
|
|
278
|
-
function L(
|
|
279
|
-
const
|
|
278
|
+
function L(i, e, t, o, n, r, s) {
|
|
279
|
+
const a = [];
|
|
280
280
|
if (e.length === 0) {
|
|
281
|
-
const u =
|
|
282
|
-
return
|
|
283
|
-
rowKey:
|
|
284
|
-
rowLabel:
|
|
285
|
-
depth:
|
|
281
|
+
const u = T(i, t, o, n), g = _(u);
|
|
282
|
+
return a.push({
|
|
283
|
+
rowKey: s || "all",
|
|
284
|
+
rowLabel: s || "All",
|
|
285
|
+
depth: r,
|
|
286
286
|
values: u,
|
|
287
287
|
total: g,
|
|
288
288
|
isGroup: !1,
|
|
289
|
-
rowCount:
|
|
290
|
-
}),
|
|
289
|
+
rowCount: i.length
|
|
290
|
+
}), a;
|
|
291
291
|
}
|
|
292
|
-
const l = e[0], d = e.slice(1), c = d.length > 0, p = M(
|
|
292
|
+
const l = e[0], d = e.slice(1), c = d.length > 0, p = M(i, l);
|
|
293
293
|
for (const [u, g] of p) {
|
|
294
|
-
const
|
|
294
|
+
const y = s ? `${s}|${u}` : u, F = T(g, t, o, n), k = _(F);
|
|
295
295
|
let R;
|
|
296
296
|
c && (R = L(
|
|
297
297
|
g,
|
|
298
298
|
d,
|
|
299
|
-
|
|
299
|
+
t,
|
|
300
300
|
o,
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
)),
|
|
305
|
-
rowKey:
|
|
301
|
+
n,
|
|
302
|
+
r + 1,
|
|
303
|
+
y
|
|
304
|
+
)), a.push({
|
|
305
|
+
rowKey: y,
|
|
306
306
|
rowLabel: u || "(blank)",
|
|
307
|
-
depth:
|
|
308
|
-
values:
|
|
309
|
-
total:
|
|
307
|
+
depth: r,
|
|
308
|
+
values: F,
|
|
309
|
+
total: k,
|
|
310
310
|
isGroup: c,
|
|
311
311
|
children: R,
|
|
312
312
|
rowCount: g.length
|
|
313
313
|
});
|
|
314
314
|
}
|
|
315
|
-
return
|
|
315
|
+
return a;
|
|
316
316
|
}
|
|
317
|
-
function
|
|
318
|
-
const
|
|
319
|
-
for (const
|
|
320
|
-
for (const
|
|
321
|
-
const l = (e.length > 0 ?
|
|
322
|
-
|
|
317
|
+
function T(i, e, t, o) {
|
|
318
|
+
const n = {};
|
|
319
|
+
for (const r of t)
|
|
320
|
+
for (const s of o) {
|
|
321
|
+
const l = (e.length > 0 ? i.filter((u) => e.map((g) => String(u[g] ?? "")).join("|") === r) : i).map((u) => Number(u[s.field]) || 0), d = K(s.aggFunc), c = l.length > 0 ? d(l) : null, p = C([r], s.field);
|
|
322
|
+
n[p] = c;
|
|
323
323
|
}
|
|
324
|
-
return
|
|
324
|
+
return n;
|
|
325
325
|
}
|
|
326
|
-
function
|
|
326
|
+
function _(i) {
|
|
327
327
|
let e = 0;
|
|
328
|
-
for (const
|
|
329
|
-
e +=
|
|
328
|
+
for (const t of Object.values(i))
|
|
329
|
+
e += t ?? 0;
|
|
330
330
|
return e;
|
|
331
331
|
}
|
|
332
|
-
function
|
|
332
|
+
function D(i, e, t) {
|
|
333
333
|
const o = {};
|
|
334
|
-
function r
|
|
335
|
-
for (const
|
|
336
|
-
if (!
|
|
337
|
-
for (const
|
|
338
|
-
for (const l of
|
|
339
|
-
const d = C([
|
|
340
|
-
o[d] = (o[d] ?? 0) + (
|
|
334
|
+
function n(r) {
|
|
335
|
+
for (const s of r)
|
|
336
|
+
if (!s.isGroup || !s.children?.length)
|
|
337
|
+
for (const a of e)
|
|
338
|
+
for (const l of t) {
|
|
339
|
+
const d = C([a], l.field);
|
|
340
|
+
o[d] = (o[d] ?? 0) + (s.values[d] ?? 0);
|
|
341
341
|
}
|
|
342
|
-
else
|
|
342
|
+
else s.children && n(s.children);
|
|
343
343
|
}
|
|
344
|
-
return
|
|
344
|
+
return n(i), o;
|
|
345
345
|
}
|
|
346
|
-
function
|
|
346
|
+
function H(i, e, t = !0) {
|
|
347
347
|
const o = [];
|
|
348
|
-
function r
|
|
349
|
-
o.push(
|
|
350
|
-
const
|
|
351
|
-
if (
|
|
352
|
-
for (const
|
|
353
|
-
|
|
354
|
-
}
|
|
355
|
-
for (const
|
|
356
|
-
r
|
|
348
|
+
function n(r) {
|
|
349
|
+
o.push(r);
|
|
350
|
+
const s = e ? e.has(r.rowKey) : t;
|
|
351
|
+
if (r.children && s)
|
|
352
|
+
for (const a of r.children)
|
|
353
|
+
n(a);
|
|
354
|
+
}
|
|
355
|
+
for (const r of i)
|
|
356
|
+
n(r);
|
|
357
357
|
return o;
|
|
358
358
|
}
|
|
359
|
-
function w(
|
|
359
|
+
function w(i) {
|
|
360
360
|
const e = [];
|
|
361
|
-
function
|
|
361
|
+
function t(o) {
|
|
362
362
|
if (o.isGroup && e.push(o.rowKey), o.children)
|
|
363
|
-
for (const
|
|
364
|
-
|
|
363
|
+
for (const n of o.children)
|
|
364
|
+
t(n);
|
|
365
365
|
}
|
|
366
|
-
for (const o of
|
|
367
|
-
|
|
366
|
+
for (const o of i)
|
|
367
|
+
t(o);
|
|
368
368
|
return e;
|
|
369
369
|
}
|
|
370
|
-
const
|
|
371
|
-
function
|
|
372
|
-
const
|
|
373
|
-
return
|
|
374
|
-
|
|
370
|
+
const q = ["sum", "avg", "count", "min", "max", "first", "last"];
|
|
371
|
+
function z(i, e, t, o) {
|
|
372
|
+
const n = new AbortController(), r = { config: e, callbacks: o, signal: n.signal }, s = document.createElement("div");
|
|
373
|
+
return s.className = "tbw-pivot-panel", s.appendChild(f("Options", () => U(t, r))), s.appendChild(f("Row Groups", () => G("rowGroups", r))), s.appendChild(f("Column Groups", () => G("columnGroups", r))), s.appendChild(f("Values", () => Z(r))), s.appendChild(f("Available Fields", () => j(r))), i.appendChild(s), () => {
|
|
374
|
+
n.abort(), s.remove();
|
|
375
375
|
};
|
|
376
376
|
}
|
|
377
|
-
function f(
|
|
378
|
-
const
|
|
379
|
-
|
|
377
|
+
function f(i, e) {
|
|
378
|
+
const t = document.createElement("div");
|
|
379
|
+
t.className = "tbw-pivot-section";
|
|
380
380
|
const o = document.createElement("div");
|
|
381
|
-
o.className = "tbw-pivot-section-header", o.textContent =
|
|
382
|
-
const
|
|
383
|
-
return
|
|
381
|
+
o.className = "tbw-pivot-section-header", o.textContent = i;
|
|
382
|
+
const n = document.createElement("div");
|
|
383
|
+
return n.className = "tbw-pivot-section-content", n.appendChild(e()), t.appendChild(o), t.appendChild(n), t;
|
|
384
384
|
}
|
|
385
|
-
function
|
|
386
|
-
const { config:
|
|
387
|
-
|
|
388
|
-
const
|
|
389
|
-
if (
|
|
390
|
-
const
|
|
391
|
-
|
|
385
|
+
function G(i, e) {
|
|
386
|
+
const { config: t, callbacks: o, signal: n } = e, r = document.createElement("div");
|
|
387
|
+
r.className = "tbw-pivot-drop-zone", r.setAttribute("data-zone", i);
|
|
388
|
+
const s = i === "rowGroups" ? t.rowGroupFields ?? [] : t.columnGroupFields ?? [];
|
|
389
|
+
if (s.length === 0) {
|
|
390
|
+
const a = document.createElement("div");
|
|
391
|
+
a.className = "tbw-pivot-placeholder", a.textContent = "Drag fields here or click to add", r.appendChild(a);
|
|
392
392
|
} else
|
|
393
|
-
for (const
|
|
394
|
-
|
|
395
|
-
return
|
|
393
|
+
for (const a of s)
|
|
394
|
+
r.appendChild(O(a, i, e));
|
|
395
|
+
return r.addEventListener(
|
|
396
396
|
"dragover",
|
|
397
|
-
(
|
|
398
|
-
|
|
397
|
+
(a) => {
|
|
398
|
+
a.preventDefault(), r.classList.add("drag-over");
|
|
399
399
|
},
|
|
400
|
-
{ signal:
|
|
401
|
-
),
|
|
400
|
+
{ signal: n }
|
|
401
|
+
), r.addEventListener(
|
|
402
402
|
"dragleave",
|
|
403
403
|
() => {
|
|
404
|
-
|
|
404
|
+
r.classList.remove("drag-over");
|
|
405
405
|
},
|
|
406
|
-
{ signal:
|
|
407
|
-
),
|
|
406
|
+
{ signal: n }
|
|
407
|
+
), r.addEventListener(
|
|
408
408
|
"drop",
|
|
409
|
-
(
|
|
410
|
-
|
|
411
|
-
const l =
|
|
412
|
-
l && o.onAddFieldToZone(l,
|
|
409
|
+
(a) => {
|
|
410
|
+
a.preventDefault(), r.classList.remove("drag-over");
|
|
411
|
+
const l = a.dataTransfer?.getData("text/plain");
|
|
412
|
+
l && o.onAddFieldToZone(l, i);
|
|
413
413
|
},
|
|
414
|
-
{ signal:
|
|
415
|
-
),
|
|
414
|
+
{ signal: n }
|
|
415
|
+
), r;
|
|
416
416
|
}
|
|
417
|
-
function O(
|
|
418
|
-
const { callbacks: o, signal:
|
|
419
|
-
|
|
420
|
-
const
|
|
421
|
-
|
|
417
|
+
function O(i, e, t) {
|
|
418
|
+
const { callbacks: o, signal: n } = t, r = document.createElement("div");
|
|
419
|
+
r.className = "tbw-pivot-field-chip", r.draggable = !0;
|
|
420
|
+
const s = o.getAvailableFields().find((d) => d.field === i), a = document.createElement("span");
|
|
421
|
+
a.className = "tbw-pivot-chip-label", a.textContent = s?.header ?? i;
|
|
422
422
|
const l = document.createElement("button");
|
|
423
423
|
return l.className = "tbw-pivot-chip-remove", l.innerHTML = "×", l.title = "Remove field", l.addEventListener(
|
|
424
424
|
"click",
|
|
425
425
|
(d) => {
|
|
426
|
-
d.stopPropagation(), o.onRemoveFieldFromZone(
|
|
426
|
+
d.stopPropagation(), o.onRemoveFieldFromZone(i, e);
|
|
427
427
|
},
|
|
428
|
-
{ signal:
|
|
429
|
-
),
|
|
428
|
+
{ signal: n }
|
|
429
|
+
), r.appendChild(a), r.appendChild(l), r.addEventListener(
|
|
430
430
|
"dragstart",
|
|
431
431
|
(d) => {
|
|
432
|
-
d.dataTransfer?.setData("text/plain",
|
|
432
|
+
d.dataTransfer?.setData("text/plain", i), d.dataTransfer?.setData("source-zone", e), r.classList.add("dragging");
|
|
433
433
|
},
|
|
434
|
-
{ signal:
|
|
435
|
-
),
|
|
434
|
+
{ signal: n }
|
|
435
|
+
), r.addEventListener(
|
|
436
436
|
"dragend",
|
|
437
437
|
() => {
|
|
438
|
-
|
|
438
|
+
r.classList.remove("dragging");
|
|
439
439
|
},
|
|
440
|
-
{ signal:
|
|
441
|
-
),
|
|
440
|
+
{ signal: n }
|
|
441
|
+
), r;
|
|
442
442
|
}
|
|
443
|
-
function Z(
|
|
444
|
-
const { config: e, callbacks:
|
|
445
|
-
|
|
446
|
-
const
|
|
447
|
-
if (
|
|
448
|
-
const
|
|
449
|
-
|
|
443
|
+
function Z(i) {
|
|
444
|
+
const { config: e, callbacks: t, signal: o } = i, n = document.createElement("div");
|
|
445
|
+
n.className = "tbw-pivot-drop-zone tbw-pivot-values-zone", n.setAttribute("data-zone", "values");
|
|
446
|
+
const r = e.valueFields ?? [];
|
|
447
|
+
if (r.length === 0) {
|
|
448
|
+
const s = document.createElement("div");
|
|
449
|
+
s.className = "tbw-pivot-placeholder", s.textContent = "Drag numeric fields here for aggregation", n.appendChild(s);
|
|
450
450
|
} else
|
|
451
|
-
for (const
|
|
452
|
-
|
|
453
|
-
return
|
|
451
|
+
for (const s of r)
|
|
452
|
+
n.appendChild($(s, i));
|
|
453
|
+
return n.addEventListener(
|
|
454
454
|
"dragover",
|
|
455
|
-
(
|
|
456
|
-
|
|
455
|
+
(s) => {
|
|
456
|
+
s.preventDefault(), n.classList.add("drag-over");
|
|
457
457
|
},
|
|
458
458
|
{ signal: o }
|
|
459
|
-
),
|
|
459
|
+
), n.addEventListener(
|
|
460
460
|
"dragleave",
|
|
461
461
|
() => {
|
|
462
|
-
|
|
462
|
+
n.classList.remove("drag-over");
|
|
463
463
|
},
|
|
464
464
|
{ signal: o }
|
|
465
|
-
),
|
|
465
|
+
), n.addEventListener(
|
|
466
466
|
"drop",
|
|
467
|
-
(
|
|
468
|
-
|
|
469
|
-
const
|
|
470
|
-
|
|
467
|
+
(s) => {
|
|
468
|
+
s.preventDefault(), n.classList.remove("drag-over");
|
|
469
|
+
const a = s.dataTransfer?.getData("text/plain");
|
|
470
|
+
a && t.onAddValueField(a, "sum");
|
|
471
471
|
},
|
|
472
472
|
{ signal: o }
|
|
473
|
-
),
|
|
473
|
+
), n;
|
|
474
474
|
}
|
|
475
|
-
function $(
|
|
476
|
-
const { callbacks:
|
|
477
|
-
|
|
478
|
-
const
|
|
479
|
-
|
|
480
|
-
const
|
|
481
|
-
|
|
475
|
+
function $(i, e) {
|
|
476
|
+
const { callbacks: t, signal: o } = e, n = document.createElement("div");
|
|
477
|
+
n.className = "tbw-pivot-field-chip tbw-pivot-value-chip";
|
|
478
|
+
const r = t.getAvailableFields().find((c) => c.field === i.field), s = document.createElement("div");
|
|
479
|
+
s.className = "tbw-pivot-value-label-wrapper";
|
|
480
|
+
const a = document.createElement("span");
|
|
481
|
+
a.className = "tbw-pivot-chip-label", a.textContent = r?.header ?? i.field;
|
|
482
482
|
const l = document.createElement("select");
|
|
483
483
|
l.className = "tbw-pivot-agg-select", l.title = "Aggregation function";
|
|
484
|
-
for (const c of
|
|
484
|
+
for (const c of q) {
|
|
485
485
|
const p = document.createElement("option");
|
|
486
|
-
p.value = c, p.textContent = c.toUpperCase(), p.selected = c ===
|
|
486
|
+
p.value = c, p.textContent = c.toUpperCase(), p.selected = c === i.aggFunc, l.appendChild(p);
|
|
487
487
|
}
|
|
488
488
|
l.addEventListener(
|
|
489
489
|
"change",
|
|
490
490
|
() => {
|
|
491
|
-
|
|
491
|
+
t.onUpdateValueAggFunc(i.field, l.value);
|
|
492
492
|
},
|
|
493
493
|
{ signal: o }
|
|
494
494
|
);
|
|
@@ -496,24 +496,24 @@ function $(t, e) {
|
|
|
496
496
|
return d.className = "tbw-pivot-chip-remove", d.innerHTML = "×", d.title = "Remove value field", d.addEventListener(
|
|
497
497
|
"click",
|
|
498
498
|
(c) => {
|
|
499
|
-
c.stopPropagation(),
|
|
499
|
+
c.stopPropagation(), t.onRemoveValueField(i.field);
|
|
500
500
|
},
|
|
501
501
|
{ signal: o }
|
|
502
|
-
),
|
|
502
|
+
), s.appendChild(a), s.appendChild(l), n.appendChild(s), n.appendChild(d), n;
|
|
503
503
|
}
|
|
504
|
-
function j(
|
|
505
|
-
const { config: e, callbacks:
|
|
506
|
-
|
|
507
|
-
const
|
|
504
|
+
function j(i) {
|
|
505
|
+
const { config: e, callbacks: t, signal: o } = i, n = document.createElement("div");
|
|
506
|
+
n.className = "tbw-pivot-available-fields";
|
|
507
|
+
const r = t.getAvailableFields(), s = /* @__PURE__ */ new Set([
|
|
508
508
|
...e.rowGroupFields ?? [],
|
|
509
509
|
...e.columnGroupFields ?? [],
|
|
510
510
|
...e.valueFields?.map((l) => l.field) ?? []
|
|
511
|
-
]),
|
|
512
|
-
if (
|
|
511
|
+
]), a = r.filter((l) => !s.has(l.field));
|
|
512
|
+
if (a.length === 0) {
|
|
513
513
|
const l = document.createElement("div");
|
|
514
|
-
l.className = "tbw-pivot-placeholder", l.textContent = "All fields are in use",
|
|
514
|
+
l.className = "tbw-pivot-placeholder", l.textContent = "All fields are in use", n.appendChild(l);
|
|
515
515
|
} else
|
|
516
|
-
for (const l of
|
|
516
|
+
for (const l of a) {
|
|
517
517
|
const d = document.createElement("div");
|
|
518
518
|
d.className = "tbw-pivot-field-chip available", d.textContent = l.header, d.draggable = !0, d.title = `Drag to add "${l.field}" to a zone`, d.addEventListener(
|
|
519
519
|
"dragstart",
|
|
@@ -527,100 +527,100 @@ function j(t) {
|
|
|
527
527
|
d.classList.remove("dragging");
|
|
528
528
|
},
|
|
529
529
|
{ signal: o }
|
|
530
|
-
),
|
|
530
|
+
), n.appendChild(d);
|
|
531
531
|
}
|
|
532
|
-
return
|
|
532
|
+
return n;
|
|
533
533
|
}
|
|
534
|
-
function U(
|
|
535
|
-
const { config:
|
|
536
|
-
return
|
|
534
|
+
function U(i, e) {
|
|
535
|
+
const { config: t, callbacks: o, signal: n } = e, r = document.createElement("div");
|
|
536
|
+
return r.className = "tbw-pivot-options", r.appendChild(
|
|
537
537
|
x(
|
|
538
538
|
"Enable Pivot View",
|
|
539
|
-
|
|
540
|
-
(
|
|
541
|
-
o.onTogglePivot(
|
|
539
|
+
i,
|
|
540
|
+
(s) => {
|
|
541
|
+
o.onTogglePivot(s);
|
|
542
542
|
},
|
|
543
|
-
|
|
543
|
+
n
|
|
544
544
|
)
|
|
545
|
-
),
|
|
545
|
+
), r.appendChild(
|
|
546
546
|
x(
|
|
547
547
|
"Show Row Totals",
|
|
548
|
-
|
|
549
|
-
(
|
|
550
|
-
o.onOptionChange("showTotals",
|
|
548
|
+
t.showTotals ?? !0,
|
|
549
|
+
(s) => {
|
|
550
|
+
o.onOptionChange("showTotals", s);
|
|
551
551
|
},
|
|
552
|
-
|
|
552
|
+
n
|
|
553
553
|
)
|
|
554
|
-
),
|
|
554
|
+
), r.appendChild(
|
|
555
555
|
x(
|
|
556
556
|
"Show Grand Total",
|
|
557
|
-
|
|
558
|
-
(
|
|
559
|
-
o.onOptionChange("showGrandTotal",
|
|
557
|
+
t.showGrandTotal ?? !0,
|
|
558
|
+
(s) => {
|
|
559
|
+
o.onOptionChange("showGrandTotal", s);
|
|
560
560
|
},
|
|
561
|
-
|
|
561
|
+
n
|
|
562
562
|
)
|
|
563
|
-
),
|
|
563
|
+
), r;
|
|
564
564
|
}
|
|
565
|
-
function x(
|
|
566
|
-
const
|
|
567
|
-
|
|
568
|
-
const
|
|
569
|
-
|
|
570
|
-
const
|
|
571
|
-
return
|
|
565
|
+
function x(i, e, t, o) {
|
|
566
|
+
const n = document.createElement("label");
|
|
567
|
+
n.className = "tbw-pivot-checkbox";
|
|
568
|
+
const r = document.createElement("input");
|
|
569
|
+
r.type = "checkbox", r.checked = e, r.addEventListener("change", () => t(r.checked), { signal: o });
|
|
570
|
+
const s = document.createElement("span");
|
|
571
|
+
return s.textContent = i, n.appendChild(r), n.appendChild(s), n;
|
|
572
572
|
}
|
|
573
|
-
function B(
|
|
574
|
-
return e.className = "pivot-group-row", e.setAttribute("data-pivot-depth", String(
|
|
575
|
-
const
|
|
576
|
-
if (
|
|
577
|
-
const
|
|
578
|
-
|
|
579
|
-
const
|
|
580
|
-
l.type = "button", l.className = "pivot-toggle", l.setAttribute("aria-label",
|
|
581
|
-
p.stopPropagation(),
|
|
582
|
-
}),
|
|
573
|
+
function B(i, e, t) {
|
|
574
|
+
return e.className = "pivot-group-row", e.setAttribute("data-pivot-depth", String(i.__pivotDepth ?? 0)), e.setAttribute("data-pivot-key", String(i.__pivotRowKey ?? "")), e.setAttribute("role", "row"), e.innerHTML = "", t.columns.forEach((o, n) => {
|
|
575
|
+
const r = document.createElement("div");
|
|
576
|
+
if (r.className = "cell", r.setAttribute("data-col", String(n)), r.setAttribute("role", "gridcell"), n === 0) {
|
|
577
|
+
const s = Number(i.__pivotIndent) || 0;
|
|
578
|
+
r.style.paddingLeft = `${s}px`;
|
|
579
|
+
const a = String(i.__pivotRowKey), l = document.createElement("button");
|
|
580
|
+
l.type = "button", l.className = "pivot-toggle", l.setAttribute("aria-label", i.__pivotExpanded ? "Collapse group" : "Expand group"), t.setIcon(l, t.resolveIcon(i.__pivotExpanded ? "collapse" : "expand")), l.addEventListener("click", (p) => {
|
|
581
|
+
p.stopPropagation(), t.onToggle(a);
|
|
582
|
+
}), r.appendChild(l);
|
|
583
583
|
const d = document.createElement("span");
|
|
584
|
-
d.className = "pivot-label", d.textContent = String(
|
|
584
|
+
d.className = "pivot-label", d.textContent = String(i.__pivotLabel ?? ""), r.appendChild(d);
|
|
585
585
|
const c = document.createElement("span");
|
|
586
|
-
c.className = "pivot-count", c.textContent = ` (${Number(
|
|
586
|
+
c.className = "pivot-count", c.textContent = ` (${Number(i.__pivotRowCount) || 0})`, r.appendChild(c);
|
|
587
587
|
} else {
|
|
588
|
-
const
|
|
589
|
-
|
|
588
|
+
const s = i[o.field];
|
|
589
|
+
r.textContent = s != null ? String(s) : "";
|
|
590
590
|
}
|
|
591
|
-
e.appendChild(
|
|
591
|
+
e.appendChild(r);
|
|
592
592
|
}), !0;
|
|
593
593
|
}
|
|
594
|
-
function W(
|
|
595
|
-
return e.className = "pivot-leaf-row", e.setAttribute("data-pivot-depth", String(
|
|
596
|
-
const
|
|
597
|
-
if (
|
|
598
|
-
const
|
|
599
|
-
|
|
600
|
-
const
|
|
601
|
-
|
|
594
|
+
function W(i, e, t) {
|
|
595
|
+
return e.className = "pivot-leaf-row", e.setAttribute("data-pivot-depth", String(i.__pivotDepth ?? 0)), e.setAttribute("data-pivot-key", String(i.__pivotRowKey ?? "")), e.innerHTML = "", t.forEach((o, n) => {
|
|
596
|
+
const r = document.createElement("div");
|
|
597
|
+
if (r.className = "cell", r.setAttribute("data-col", String(n)), r.setAttribute("role", "gridcell"), n === 0) {
|
|
598
|
+
const s = Number(i.__pivotIndent) || 0;
|
|
599
|
+
r.style.paddingLeft = `${s + 20}px`;
|
|
600
|
+
const a = document.createElement("span");
|
|
601
|
+
a.className = "pivot-label", a.textContent = String(i.__pivotLabel ?? ""), r.appendChild(a);
|
|
602
602
|
} else {
|
|
603
|
-
const
|
|
604
|
-
|
|
603
|
+
const s = i[o.field];
|
|
604
|
+
r.textContent = s != null ? String(s) : "";
|
|
605
605
|
}
|
|
606
|
-
e.appendChild(
|
|
606
|
+
e.appendChild(r);
|
|
607
607
|
}), !0;
|
|
608
608
|
}
|
|
609
|
-
function J(
|
|
610
|
-
return e.className = "pivot-grand-total-row", e.setAttribute("role", "presentation"), e.innerHTML = "",
|
|
611
|
-
const
|
|
612
|
-
if (
|
|
613
|
-
const
|
|
614
|
-
|
|
609
|
+
function J(i, e, t) {
|
|
610
|
+
return e.className = "pivot-grand-total-row", e.setAttribute("role", "presentation"), e.innerHTML = "", t.forEach((o, n) => {
|
|
611
|
+
const r = document.createElement("div");
|
|
612
|
+
if (r.className = "cell", r.setAttribute("data-col", String(n)), n === 0) {
|
|
613
|
+
const s = document.createElement("span");
|
|
614
|
+
s.className = "pivot-label", s.textContent = "Grand Total", r.appendChild(s);
|
|
615
615
|
} else {
|
|
616
|
-
const
|
|
617
|
-
|
|
616
|
+
const s = i[o.field];
|
|
617
|
+
r.textContent = s != null ? String(s) : "";
|
|
618
618
|
}
|
|
619
|
-
e.appendChild(
|
|
619
|
+
e.appendChild(r);
|
|
620
620
|
}), !0;
|
|
621
621
|
}
|
|
622
|
-
const Q = '.pivot-group-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:600;background:var(--tbw-pivot-group-bg, var(--tbw-color-row-alt));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-group-row:hover{background:var(--tbw-pivot-group-hover, var(--tbw-color-row-hover))}.pivot-leaf-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-pivot-leaf-bg, var(--tbw-color-bg));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-grand-total-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:700;background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-height:var(--tbw-row-height);border-top:2px solid var(--tbw-color-border-strong)}.pivot-grand-total-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-grand-total-row>.cell:last-child{border-right:0}.pivot-grand-total-footer{position:sticky;bottom:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-width:fit-content}.pivot-group-row>.cell,.pivot-leaf-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-group-row>.cell:last-child,.pivot-leaf-row>.cell:last-child{border-right:0}.pivot-toggle{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;margin-right:6px;border:none;background:transparent;cursor:pointer;
|
|
623
|
-
class b extends
|
|
622
|
+
const Q = '.pivot-group-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:600;background:var(--tbw-pivot-group-bg, var(--tbw-color-row-alt));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-group-row:hover{background:var(--tbw-pivot-group-hover, var(--tbw-color-row-hover))}.pivot-leaf-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-pivot-leaf-bg, var(--tbw-color-bg));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-grand-total-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:700;background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-height:var(--tbw-row-height);border-top:2px solid var(--tbw-color-border-strong)}.pivot-grand-total-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-grand-total-row>.cell:last-child{border-right:0}.pivot-grand-total-footer{position:sticky;bottom:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-width:fit-content}.pivot-group-row>.cell,.pivot-leaf-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-group-row>.cell:last-child,.pivot-leaf-row>.cell:last-child{border-right:0}.pivot-toggle{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;margin-right:6px;border:none;background:transparent;cursor:pointer;color:var(--tbw-pivot-toggle-color, var(--tbw-color-fg-muted));border-radius:var(--tbw-border-radius);transition:background .15s,color .15s}.pivot-toggle:hover{background:var(--tbw-pivot-toggle-hover-bg, var(--tbw-color-row-hover));color:var(--tbw-pivot-toggle-hover-color, var(--tbw-color-fg))}.pivot-toggle:focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}.pivot-label{font-weight:inherit}.pivot-count{color:var(--tbw-pivot-count-color, var(--tbw-color-fg-muted));font-size:.9em;font-weight:400}.pivot-total-row{font-weight:700;border-top:2px solid var(--tbw-pivot-border, var(--tbw-color-border-strong))}[data-pivot-depth="1"]{--tbw-pivot-depth: 1}[data-pivot-depth="2"]{--tbw-pivot-depth: 2}[data-pivot-depth="3"]{--tbw-pivot-depth: 3}[data-pivot-depth="4"]{--tbw-pivot-depth: 4}.tbw-pivot-panel{display:flex;flex-direction:column;gap:12px;padding:12px;height:100%;overflow-y:auto;font-size:13px}.tbw-pivot-section{border:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-section-bg, var(--tbw-color-bg))}.tbw-pivot-section-header{padding:8px 12px;font-weight:600;background:var(--tbw-pivot-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius) var(--tbw-border-radius) 0 0}.tbw-pivot-section-content{padding:8px}.tbw-pivot-toggle-wrapper{display:flex;align-items:center}.tbw-pivot-toggle-label{display:flex;align-items:center;gap:8px;cursor:pointer}.tbw-pivot-toggle-label input{width:16px;height:16px;cursor:pointer}.tbw-pivot-drop-zone{min-height:60px;padding:8px;border:2px dashed var(--tbw-pivot-drop-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-drop-bg, var(--tbw-color-row-alt));display:flex;flex-wrap:wrap;gap:6px;align-content:flex-start;transition:all .15s ease}.tbw-pivot-drop-zone.drag-over{border-color:var(--tbw-color-accent);background:var(--tbw-pivot-drop-active, var(--tbw-focus-background))}.tbw-pivot-placeholder{color:var(--tbw-color-fg-muted);font-style:italic;padding:8px;text-align:center;width:100%}.tbw-pivot-field-chip{display:inline-flex;align-items:center;gap:6px;padding:4px 8px;background:var(--tbw-pivot-chip-bg, var(--tbw-color-header-bg));border:1px solid var(--tbw-pivot-chip-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);cursor:grab;font-size:12px;transition:all .15s ease}.tbw-pivot-field-chip:hover{background:var(--tbw-pivot-chip-hover, var(--tbw-color-row-hover));border-color:var(--tbw-color-accent)}.tbw-pivot-field-chip.available{background:var(--tbw-color-bg)}.tbw-pivot-field-chip.dragging{opacity:.5;cursor:grabbing}.tbw-pivot-chip-label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:120px}.tbw-pivot-chip-remove{display:flex;align-items:center;justify-content:center;width:16px;height:16px;padding:0;border:none;background:transparent;color:var(--tbw-color-fg-muted);font-size:14px;font-weight:700;cursor:pointer;border-radius:50%;transition:all .15s ease}.tbw-pivot-chip-remove:hover{background:var(--tbw-pivot-chip-remove-hover-bg, var(--tbw-color-accent));color:var(--tbw-pivot-chip-remove-hover-fg, var(--tbw-color-accent-fg))}.tbw-pivot-value-chip{padding:4px 8px}.tbw-pivot-value-label-wrapper{display:flex;align-items:center;gap:8px;flex:1;min-width:0}.tbw-pivot-agg-select{padding:2px 4px;font-size:11px;border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);cursor:pointer}.tbw-pivot-available-fields{display:flex;flex-wrap:wrap;gap:6px;min-height:40px}.tbw-pivot-options{display:flex;flex-direction:column;gap:8px}.tbw-pivot-checkbox{display:flex;align-items:center;gap:8px;cursor:pointer}.tbw-pivot-checkbox input{width:14px;height:14px;cursor:pointer}.pivot-group-row.tbw-pivot-slide-in,.pivot-leaf-row.tbw-pivot-slide-in{animation:tbw-pivot-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-pivot-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}.pivot-group-row.tbw-pivot-fade-in,.pivot-leaf-row.tbw-pivot-fade-in{animation:tbw-pivot-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-pivot-fade-in{0%{opacity:0}to{opacity:1}}';
|
|
623
|
+
class b extends P {
|
|
624
624
|
name = "pivot";
|
|
625
625
|
version = "1.0.0";
|
|
626
626
|
/** Tool panel ID for shell integration */
|
|
@@ -629,7 +629,9 @@ class b extends N {
|
|
|
629
629
|
return {
|
|
630
630
|
active: !0,
|
|
631
631
|
showTotals: !0,
|
|
632
|
-
showGrandTotal: !0
|
|
632
|
+
showGrandTotal: !0,
|
|
633
|
+
showToolPanel: !0,
|
|
634
|
+
animation: "slide"
|
|
633
635
|
};
|
|
634
636
|
}
|
|
635
637
|
// #region Internal State
|
|
@@ -642,99 +644,121 @@ class b extends N {
|
|
|
642
644
|
originalColumns = [];
|
|
643
645
|
panelContainer = null;
|
|
644
646
|
grandTotalFooter = null;
|
|
647
|
+
previousVisibleKeys = /* @__PURE__ */ new Set();
|
|
648
|
+
keysToAnimate = /* @__PURE__ */ new Set();
|
|
645
649
|
/**
|
|
646
650
|
* Check if the plugin has valid pivot configuration (at least value fields).
|
|
647
651
|
*/
|
|
648
652
|
hasValidPivotConfig() {
|
|
649
653
|
return (this.config.valueFields?.length ?? 0) > 0;
|
|
650
654
|
}
|
|
655
|
+
/**
|
|
656
|
+
* Get animation style respecting grid-level animation mode.
|
|
657
|
+
*/
|
|
658
|
+
get animationStyle() {
|
|
659
|
+
const t = this.grid.effectiveConfig?.animation?.mode ?? "reduced-motion";
|
|
660
|
+
if (t === !1 || t === "off") return !1;
|
|
661
|
+
if (t !== !0 && t !== "on") {
|
|
662
|
+
const o = this.shadowRoot?.host;
|
|
663
|
+
if (o && getComputedStyle(o).getPropertyValue("--tbw-animation-enabled").trim() === "0")
|
|
664
|
+
return !1;
|
|
665
|
+
}
|
|
666
|
+
return this.config.animation ?? "slide";
|
|
667
|
+
}
|
|
651
668
|
// #endregion
|
|
652
669
|
// #region Lifecycle
|
|
653
670
|
detach() {
|
|
654
|
-
this.isActive = !1, this.hasInitialized = !1, this.pivotResult = null, this.fieldHeaderMap.clear(), this.originalColumns = [], this.panelContainer = null, this.cleanupGrandTotalFooter();
|
|
671
|
+
this.isActive = !1, this.hasInitialized = !1, this.pivotResult = null, this.fieldHeaderMap.clear(), this.originalColumns = [], this.panelContainer = null, this.cleanupGrandTotalFooter(), this.previousVisibleKeys.clear(), this.keysToAnimate.clear();
|
|
655
672
|
}
|
|
656
673
|
// #endregion
|
|
657
674
|
// #region Shell Integration
|
|
658
675
|
getToolPanel() {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
676
|
+
if ((this.config?.showToolPanel ?? this.userConfig?.showToolPanel ?? !0) !== !1)
|
|
677
|
+
return {
|
|
678
|
+
id: b.PANEL_ID,
|
|
679
|
+
title: "Pivot",
|
|
680
|
+
icon: "⊞",
|
|
681
|
+
tooltip: "Configure pivot table",
|
|
682
|
+
order: 90,
|
|
683
|
+
render: (t) => this.renderPanel(t)
|
|
684
|
+
};
|
|
667
685
|
}
|
|
668
686
|
// #endregion
|
|
669
687
|
// #region Hooks
|
|
670
688
|
processRows(e) {
|
|
671
689
|
if (!this.hasInitialized && this.config.active !== !1 && this.hasValidPivotConfig() && (this.hasInitialized = !0, this.isActive = !0), !this.isActive)
|
|
672
690
|
return [...e];
|
|
673
|
-
const
|
|
674
|
-
if (
|
|
675
|
-
return this.warn(`Config errors: ${
|
|
691
|
+
const t = S(this.config);
|
|
692
|
+
if (t.length > 0)
|
|
693
|
+
return this.warn(`Config errors: ${t.join(", ")}`), [...e];
|
|
676
694
|
if (this.buildFieldHeaderMap(), this.defaultExpanded = this.config.defaultExpanded ?? !0, this.expandedKeys.size === 0 && this.defaultExpanded && this.pivotResult) {
|
|
677
|
-
const
|
|
678
|
-
for (const a of
|
|
695
|
+
const s = w(this.pivotResult.rows);
|
|
696
|
+
for (const a of s)
|
|
679
697
|
this.expandedKeys.add(a);
|
|
680
698
|
}
|
|
681
|
-
if (this.pivotResult =
|
|
682
|
-
const
|
|
683
|
-
for (const a of
|
|
699
|
+
if (this.pivotResult = I(e, this.config), this.expandedKeys.size === 0 && this.defaultExpanded) {
|
|
700
|
+
const s = w(this.pivotResult.rows);
|
|
701
|
+
for (const a of s)
|
|
684
702
|
this.expandedKeys.add(a);
|
|
685
703
|
}
|
|
686
|
-
const o = this.config.indentWidth ?? 20
|
|
687
|
-
return D(
|
|
704
|
+
const o = this.config.indentWidth ?? 20, n = H(
|
|
688
705
|
this.pivotResult.rows,
|
|
689
706
|
this.expandedKeys,
|
|
690
707
|
this.defaultExpanded
|
|
691
|
-
).map((
|
|
692
|
-
__pivotRowKey:
|
|
693
|
-
__pivotLabel:
|
|
694
|
-
__pivotDepth:
|
|
695
|
-
__pivotIsGroup:
|
|
696
|
-
__pivotHasChildren: !!
|
|
697
|
-
__pivotExpanded: this.expandedKeys.has(
|
|
698
|
-
__pivotRowCount:
|
|
699
|
-
__pivotIndent:
|
|
700
|
-
__pivotTotal:
|
|
701
|
-
...
|
|
708
|
+
).map((s) => ({
|
|
709
|
+
__pivotRowKey: s.rowKey,
|
|
710
|
+
__pivotLabel: s.rowLabel,
|
|
711
|
+
__pivotDepth: s.depth,
|
|
712
|
+
__pivotIsGroup: s.isGroup,
|
|
713
|
+
__pivotHasChildren: !!s.children?.length,
|
|
714
|
+
__pivotExpanded: this.expandedKeys.has(s.rowKey),
|
|
715
|
+
__pivotRowCount: s.rowCount ?? 0,
|
|
716
|
+
__pivotIndent: s.depth * o,
|
|
717
|
+
__pivotTotal: s.total,
|
|
718
|
+
...s.values
|
|
702
719
|
}));
|
|
720
|
+
this.keysToAnimate.clear();
|
|
721
|
+
const r = /* @__PURE__ */ new Set();
|
|
722
|
+
for (const s of n) {
|
|
723
|
+
const a = s.__pivotRowKey;
|
|
724
|
+
r.add(a), !this.previousVisibleKeys.has(a) && s.__pivotDepth > 0 && this.keysToAnimate.add(a);
|
|
725
|
+
}
|
|
726
|
+
return this.previousVisibleKeys = r, n;
|
|
703
727
|
}
|
|
704
728
|
processColumns(e) {
|
|
705
729
|
if (!this.isActive || !this.pivotResult)
|
|
706
730
|
return [...e];
|
|
707
|
-
const
|
|
708
|
-
|
|
731
|
+
const t = [], o = (this.config.rowGroupFields ?? []).map((n) => this.fieldHeaderMap.get(n) ?? n).join(" / ");
|
|
732
|
+
t.push({
|
|
709
733
|
field: "__pivotLabel",
|
|
710
734
|
header: o || "Group",
|
|
711
735
|
width: 200
|
|
712
736
|
});
|
|
713
|
-
for (const
|
|
714
|
-
for (const
|
|
715
|
-
const
|
|
716
|
-
|
|
717
|
-
field:
|
|
718
|
-
header: `${
|
|
737
|
+
for (const n of this.pivotResult.columnKeys)
|
|
738
|
+
for (const r of this.config.valueFields ?? []) {
|
|
739
|
+
const s = C([n], r.field), a = r.header || this.fieldHeaderMap.get(r.field) || r.field;
|
|
740
|
+
t.push({
|
|
741
|
+
field: s,
|
|
742
|
+
header: `${n} - ${a} (${r.aggFunc})`,
|
|
719
743
|
width: 120,
|
|
720
744
|
type: "number"
|
|
721
745
|
});
|
|
722
746
|
}
|
|
723
|
-
return this.config.showTotals &&
|
|
747
|
+
return this.config.showTotals && t.push({
|
|
724
748
|
field: "__pivotTotal",
|
|
725
749
|
header: "Total",
|
|
726
750
|
width: 100,
|
|
727
751
|
type: "number"
|
|
728
|
-
}),
|
|
752
|
+
}), t;
|
|
729
753
|
}
|
|
730
|
-
renderRow(e,
|
|
754
|
+
renderRow(e, t) {
|
|
731
755
|
const o = e;
|
|
732
|
-
return o.__pivotRowKey && o.__pivotHasChildren ? B(o,
|
|
756
|
+
return o.__pivotRowKey && o.__pivotHasChildren ? B(o, t, {
|
|
733
757
|
columns: this.gridColumns,
|
|
734
|
-
onToggle: (
|
|
735
|
-
resolveIcon: (
|
|
736
|
-
setIcon: (
|
|
737
|
-
}) : o.__pivotRowKey !== void 0 && this.isActive ? W(o,
|
|
758
|
+
onToggle: (n) => this.toggle(n),
|
|
759
|
+
resolveIcon: (n) => this.resolveIcon(n),
|
|
760
|
+
setIcon: (n, r) => this.setIcon(n, r)
|
|
761
|
+
}) : o.__pivotRowKey !== void 0 && this.isActive ? W(o, t, this.gridColumns) : (this.cleanupPivotStyling(t), !1);
|
|
738
762
|
}
|
|
739
763
|
/**
|
|
740
764
|
* Remove pivot-specific classes, attributes, and inline styles from a row element.
|
|
@@ -746,6 +770,16 @@ class b extends N {
|
|
|
746
770
|
}
|
|
747
771
|
afterRender() {
|
|
748
772
|
this.isActive && this.config.showGrandTotal && this.pivotResult ? this.renderGrandTotalFooter() : this.cleanupGrandTotalFooter();
|
|
773
|
+
const e = this.animationStyle;
|
|
774
|
+
if (e === !1 || this.keysToAnimate.size === 0) return;
|
|
775
|
+
const t = this.shadowRoot?.querySelector(".rows");
|
|
776
|
+
if (!t) return;
|
|
777
|
+
const o = e === "fade" ? "tbw-pivot-fade-in" : "tbw-pivot-slide-in";
|
|
778
|
+
for (const n of t.querySelectorAll(".pivot-group-row, .pivot-leaf-row")) {
|
|
779
|
+
const r = n.dataset.pivotKey;
|
|
780
|
+
r && this.keysToAnimate.has(r) && (n.classList.add(o), n.addEventListener("animationend", () => n.classList.remove(o), { once: !0 }));
|
|
781
|
+
}
|
|
782
|
+
this.keysToAnimate.clear();
|
|
749
783
|
}
|
|
750
784
|
/**
|
|
751
785
|
* Render the grand total row as a sticky footer pinned to the bottom.
|
|
@@ -754,9 +788,9 @@ class b extends N {
|
|
|
754
788
|
if (!this.pivotResult) return;
|
|
755
789
|
const e = this.shadowRoot;
|
|
756
790
|
if (!e) return;
|
|
757
|
-
const
|
|
758
|
-
if (!
|
|
759
|
-
this.grandTotalFooter || (this.grandTotalFooter = document.createElement("div"), this.grandTotalFooter.className = "pivot-grand-total-footer",
|
|
791
|
+
const t = e.querySelector(".tbw-scroll-area") ?? e.querySelector(".tbw-grid-content") ?? e.children[0];
|
|
792
|
+
if (!t) return;
|
|
793
|
+
this.grandTotalFooter || (this.grandTotalFooter = document.createElement("div"), this.grandTotalFooter.className = "pivot-grand-total-footer", t.appendChild(this.grandTotalFooter));
|
|
760
794
|
const o = {
|
|
761
795
|
__pivotRowKey: "__grandTotal",
|
|
762
796
|
__pivotLabel: "Grand Total",
|
|
@@ -786,8 +820,8 @@ class b extends N {
|
|
|
786
820
|
expandAll() {
|
|
787
821
|
if (this.pivotResult) {
|
|
788
822
|
const e = w(this.pivotResult.rows);
|
|
789
|
-
for (const
|
|
790
|
-
this.expandedKeys.add(
|
|
823
|
+
for (const t of e)
|
|
824
|
+
this.expandedKeys.add(t);
|
|
791
825
|
this.requestRender();
|
|
792
826
|
}
|
|
793
827
|
}
|
|
@@ -845,8 +879,8 @@ class b extends N {
|
|
|
845
879
|
buildFieldHeaderMap() {
|
|
846
880
|
const e = this.getAvailableFields();
|
|
847
881
|
this.fieldHeaderMap.clear();
|
|
848
|
-
for (const
|
|
849
|
-
this.fieldHeaderMap.set(
|
|
882
|
+
for (const t of e)
|
|
883
|
+
this.fieldHeaderMap.set(t.field, t.header);
|
|
850
884
|
}
|
|
851
885
|
getAvailableFields() {
|
|
852
886
|
return this.originalColumns.length > 0 ? this.originalColumns : this.captureOriginalColumns();
|
|
@@ -854,8 +888,8 @@ class b extends N {
|
|
|
854
888
|
captureOriginalColumns() {
|
|
855
889
|
const e = this.grid;
|
|
856
890
|
try {
|
|
857
|
-
const
|
|
858
|
-
return this.originalColumns =
|
|
891
|
+
const t = e.getAllColumns?.() ?? e.columns ?? [];
|
|
892
|
+
return this.originalColumns = t.filter((o) => !o.field.startsWith("__pivot")).map((o) => ({
|
|
859
893
|
field: o.field,
|
|
860
894
|
header: o.header ?? o.field
|
|
861
895
|
})), this.originalColumns;
|
|
@@ -865,51 +899,51 @@ class b extends N {
|
|
|
865
899
|
}
|
|
866
900
|
renderPanel(e) {
|
|
867
901
|
this.panelContainer = e, this.originalColumns.length === 0 && this.captureOriginalColumns();
|
|
868
|
-
const
|
|
902
|
+
const t = {
|
|
869
903
|
onTogglePivot: (o) => {
|
|
870
904
|
o ? this.enablePivot() : this.disablePivot(), this.refreshPanel();
|
|
871
905
|
},
|
|
872
|
-
onAddFieldToZone: (o,
|
|
873
|
-
onRemoveFieldFromZone: (o,
|
|
874
|
-
onAddValueField: (o,
|
|
906
|
+
onAddFieldToZone: (o, n) => this.addFieldToZone(o, n),
|
|
907
|
+
onRemoveFieldFromZone: (o, n) => this.removeFieldFromZone(o, n),
|
|
908
|
+
onAddValueField: (o, n) => this.addValueField(o, n),
|
|
875
909
|
onRemoveValueField: (o) => this.removeValueField(o),
|
|
876
|
-
onUpdateValueAggFunc: (o,
|
|
877
|
-
onOptionChange: (o,
|
|
878
|
-
this.config[o] =
|
|
910
|
+
onUpdateValueAggFunc: (o, n) => this.updateValueAggFunc(o, n),
|
|
911
|
+
onOptionChange: (o, n) => {
|
|
912
|
+
this.config[o] = n, this.isActive && this.refresh();
|
|
879
913
|
},
|
|
880
914
|
getAvailableFields: () => this.getAvailableFields()
|
|
881
915
|
};
|
|
882
|
-
return
|
|
916
|
+
return z(e, this.config, this.isActive, t);
|
|
883
917
|
}
|
|
884
918
|
refreshPanel() {
|
|
885
919
|
this.panelContainer && (this.panelContainer.innerHTML = "", this.renderPanel(this.panelContainer));
|
|
886
920
|
}
|
|
887
|
-
addFieldToZone(e,
|
|
888
|
-
if (
|
|
921
|
+
addFieldToZone(e, t) {
|
|
922
|
+
if (t === "rowGroups") {
|
|
889
923
|
const o = this.config.rowGroupFields ?? [];
|
|
890
924
|
o.includes(e) || (this.config.rowGroupFields = [...o, e]);
|
|
891
925
|
} else {
|
|
892
926
|
const o = this.config.columnGroupFields ?? [];
|
|
893
927
|
o.includes(e) || (this.config.columnGroupFields = [...o, e]);
|
|
894
928
|
}
|
|
895
|
-
this.removeFromOtherZones(e,
|
|
929
|
+
this.removeFromOtherZones(e, t), this.isActive && this.refresh(), this.refreshPanel();
|
|
896
930
|
}
|
|
897
|
-
removeFieldFromZone(e,
|
|
898
|
-
|
|
931
|
+
removeFieldFromZone(e, t) {
|
|
932
|
+
t === "rowGroups" ? this.config.rowGroupFields = (this.config.rowGroupFields ?? []).filter((o) => o !== e) : this.config.columnGroupFields = (this.config.columnGroupFields ?? []).filter((o) => o !== e), this.isActive && this.refresh(), this.refreshPanel();
|
|
899
933
|
}
|
|
900
|
-
removeFromOtherZones(e,
|
|
901
|
-
|
|
934
|
+
removeFromOtherZones(e, t) {
|
|
935
|
+
t !== "rowGroups" && (this.config.rowGroupFields = (this.config.rowGroupFields ?? []).filter((o) => o !== e)), t !== "columnGroups" && (this.config.columnGroupFields = (this.config.columnGroupFields ?? []).filter((o) => o !== e)), t !== "values" && (this.config.valueFields = (this.config.valueFields ?? []).filter((o) => o.field !== e));
|
|
902
936
|
}
|
|
903
|
-
addValueField(e,
|
|
937
|
+
addValueField(e, t) {
|
|
904
938
|
const o = this.config.valueFields ?? [];
|
|
905
|
-
o.some((
|
|
939
|
+
o.some((n) => n.field === e) || (this.config.valueFields = [...o, { field: e, aggFunc: t }]), this.removeFromOtherZones(e, "values"), this.isActive && this.refresh(), this.refreshPanel();
|
|
906
940
|
}
|
|
907
941
|
removeValueField(e) {
|
|
908
|
-
this.config.valueFields = (this.config.valueFields ?? []).filter((
|
|
942
|
+
this.config.valueFields = (this.config.valueFields ?? []).filter((t) => t.field !== e), this.isActive && this.refresh(), this.refreshPanel();
|
|
909
943
|
}
|
|
910
|
-
updateValueAggFunc(e,
|
|
911
|
-
const o = this.config.valueFields ?? [],
|
|
912
|
-
|
|
944
|
+
updateValueAggFunc(e, t) {
|
|
945
|
+
const o = this.config.valueFields ?? [], n = o.findIndex((r) => r.field === e);
|
|
946
|
+
n >= 0 && (o[n] = { ...o[n], aggFunc: t }, this.config.valueFields = [...o]), this.isActive && this.refresh();
|
|
913
947
|
}
|
|
914
948
|
// #endregion
|
|
915
949
|
// #region Styles
|