@toolbox-web/grid 0.4.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- package/all.js +1063 -1024
- package/all.js.map +1 -1
- package/index.js +1078 -912
- package/index.js.map +1 -1
- package/lib/core/grid.d.ts +28 -0
- package/lib/core/grid.d.ts.map +1 -1
- package/lib/core/internal/dom-builder.d.ts +2 -0
- package/lib/core/internal/dom-builder.d.ts.map +1 -1
- package/lib/core/internal/event-delegation.d.ts +21 -0
- package/lib/core/internal/event-delegation.d.ts.map +1 -1
- package/lib/core/internal/header.d.ts.map +1 -1
- package/lib/core/internal/resize.d.ts.map +1 -1
- package/lib/core/internal/rows.d.ts +1 -1
- package/lib/core/internal/rows.d.ts.map +1 -1
- package/lib/core/internal/shell.d.ts +19 -13
- package/lib/core/internal/shell.d.ts.map +1 -1
- package/lib/core/plugin/base-plugin.d.ts +13 -2
- package/lib/core/plugin/base-plugin.d.ts.map +1 -1
- package/lib/core/plugin/expander-column.d.ts.map +1 -1
- package/lib/core/plugin/plugin-manager.d.ts +6 -2
- package/lib/core/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/core/types.d.ts +41 -3
- package/lib/core/types.d.ts.map +1 -1
- package/lib/plugins/clipboard/index.js +22 -11
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js +59 -48
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +71 -60
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/editing/EditingPlugin.d.ts +1 -0
- package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
- package/lib/plugins/editing/index.js +93 -80
- package/lib/plugins/editing/index.js.map +1 -1
- package/lib/plugins/export/index.js +29 -18
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts +9 -1
- package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
- package/lib/plugins/filtering/index.js +199 -165
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +1 -0
- package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-columns/index.js +79 -49
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/GroupingRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/grouping-rows/index.js +98 -87
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +70 -57
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js +48 -37
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-columns/index.js +71 -66
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-columns/pinned-columns.d.ts +2 -2
- package/lib/plugins/pinned-columns/pinned-columns.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/PinnedRowsPlugin.d.ts.map +1 -1
- package/lib/plugins/pinned-rows/index.js +63 -52
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/PivotPlugin.d.ts.map +1 -1
- package/lib/plugins/pivot/index.js +310 -299
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/ReorderPlugin.d.ts.map +1 -1
- package/lib/plugins/reorder/index.d.ts +1 -1
- package/lib/plugins/reorder/index.d.ts.map +1 -1
- package/lib/plugins/reorder/index.js +79 -68
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/SelectionPlugin.d.ts.map +1 -1
- package/lib/plugins/selection/index.js +115 -105
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js +15 -4
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/TreePlugin.d.ts.map +1 -1
- package/lib/plugins/tree/index.js +41 -30
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js +29 -18
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
- package/lib/plugins/visibility/index.js +59 -47
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +6 -6
- package/public.d.ts +42 -0
- package/public.d.ts.map +1 -1
- package/themes/dg-theme-bootstrap.css +55 -53
- package/themes/dg-theme-contrast.css +42 -40
- package/themes/dg-theme-large.css +38 -37
- package/themes/dg-theme-material.css +54 -52
- package/themes/dg-theme-standard.css +19 -17
- package/themes/dg-theme-vibrant.css +16 -14
- package/umd/grid.all.umd.js +23 -22
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +15 -14
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/column-virtualization.umd.js +1 -1
- package/umd/plugins/column-virtualization.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js +1 -1
- package/umd/plugins/context-menu.umd.js.map +1 -1
- package/umd/plugins/editing.umd.js +1 -1
- package/umd/plugins/editing.umd.js.map +1 -1
- package/umd/plugins/filtering.umd.js +1 -1
- package/umd/plugins/filtering.umd.js.map +1 -1
- package/umd/plugins/grouping-columns.umd.js +1 -1
- package/umd/plugins/grouping-columns.umd.js.map +1 -1
- package/umd/plugins/grouping-rows.umd.js +1 -1
- package/umd/plugins/grouping-rows.umd.js.map +1 -1
- package/umd/plugins/master-detail.umd.js +1 -1
- package/umd/plugins/master-detail.umd.js.map +1 -1
- package/umd/plugins/multi-sort.umd.js +1 -1
- package/umd/plugins/multi-sort.umd.js.map +1 -1
- package/umd/plugins/pinned-columns.umd.js +1 -1
- package/umd/plugins/pinned-columns.umd.js.map +1 -1
- package/umd/plugins/pinned-rows.umd.js +1 -1
- package/umd/plugins/pinned-rows.umd.js.map +1 -1
- package/umd/plugins/pivot.umd.js +1 -1
- package/umd/plugins/pivot.umd.js.map +1 -1
- package/umd/plugins/reorder.umd.js +1 -1
- package/umd/plugins/reorder.umd.js.map +1 -1
- package/umd/plugins/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/umd/plugins/tree.umd.js +1 -1
- package/umd/plugins/tree.umd.js.map +1 -1
- package/umd/plugins/visibility.umd.js +1 -1
- package/umd/plugins/visibility.umd.js.map +1 -1
|
@@ -121,8 +121,8 @@ class P {
|
|
|
121
121
|
* @returns `true` if the event was cancelled (preventDefault called), `false` otherwise
|
|
122
122
|
*/
|
|
123
123
|
emitCancelable(e, t) {
|
|
124
|
-
const
|
|
125
|
-
return this.grid?.dispatchEvent?.(
|
|
124
|
+
const o = new CustomEvent(e, { detail: t, bubbles: !0, cancelable: !0 });
|
|
125
|
+
return this.grid?.dispatchEvent?.(o), o.defaultPrevented;
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
128
|
* Request a re-render of the grid.
|
|
@@ -185,10 +185,21 @@ class P {
|
|
|
185
185
|
return this.grid;
|
|
186
186
|
}
|
|
187
187
|
/**
|
|
188
|
-
* Get the
|
|
188
|
+
* Get the render root of the grid for DOM queries.
|
|
189
|
+
* @deprecated Use `gridElement` instead. This getter exists only for backward compatibility.
|
|
190
|
+
*
|
|
191
|
+
* With Shadow DOM removed, the grid element itself is the render root.
|
|
192
|
+
* All new code should use `this.gridElement` for DOM queries.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* // OLD (deprecated)
|
|
196
|
+
* const rows = this.shadowRoot?.querySelector('.rows');
|
|
197
|
+
*
|
|
198
|
+
* // NEW (preferred)
|
|
199
|
+
* const rows = this.gridElement.querySelector('.rows');
|
|
189
200
|
*/
|
|
190
201
|
get shadowRoot() {
|
|
191
|
-
return this.
|
|
202
|
+
return this.gridElement;
|
|
192
203
|
}
|
|
193
204
|
/**
|
|
194
205
|
* Get the disconnect signal for event listener cleanup.
|
|
@@ -239,7 +250,7 @@ class P {
|
|
|
239
250
|
const e = this.grid?.effectiveConfig?.animation?.mode ?? "reduced-motion";
|
|
240
251
|
if (e === !1 || e === "off") return !1;
|
|
241
252
|
if (e === !0 || e === "on") return !0;
|
|
242
|
-
const t = this.
|
|
253
|
+
const t = this.gridElement;
|
|
243
254
|
return t ? getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim() !== "0" : !0;
|
|
244
255
|
}
|
|
245
256
|
/**
|
|
@@ -255,10 +266,10 @@ class P {
|
|
|
255
266
|
* ```
|
|
256
267
|
*/
|
|
257
268
|
get animationDuration() {
|
|
258
|
-
const e = this.
|
|
269
|
+
const e = this.gridElement;
|
|
259
270
|
if (e) {
|
|
260
|
-
const t = getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),
|
|
261
|
-
if (!isNaN(
|
|
271
|
+
const t = getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(), o = parseInt(t, 10);
|
|
272
|
+
if (!isNaN(o)) return o;
|
|
262
273
|
}
|
|
263
274
|
return 200;
|
|
264
275
|
}
|
|
@@ -293,48 +304,48 @@ class P {
|
|
|
293
304
|
// #endregion
|
|
294
305
|
}
|
|
295
306
|
const m = {
|
|
296
|
-
sum: (
|
|
297
|
-
avg: (
|
|
298
|
-
const t =
|
|
299
|
-
return
|
|
307
|
+
sum: (i, e) => i.reduce((t, o) => t + (Number(o[e]) || 0), 0),
|
|
308
|
+
avg: (i, e) => {
|
|
309
|
+
const t = i.reduce((o, r) => o + (Number(r[e]) || 0), 0);
|
|
310
|
+
return i.length ? t / i.length : 0;
|
|
300
311
|
},
|
|
301
|
-
count: (
|
|
302
|
-
min: (
|
|
303
|
-
max: (
|
|
304
|
-
first: (
|
|
305
|
-
last: (
|
|
306
|
-
}, f = /* @__PURE__ */ new Map(),
|
|
312
|
+
count: (i) => i.length,
|
|
313
|
+
min: (i, e) => Math.min(...i.map((t) => Number(t[e]) || 1 / 0)),
|
|
314
|
+
max: (i, e) => Math.max(...i.map((t) => Number(t[e]) || -1 / 0)),
|
|
315
|
+
first: (i, e) => i[0]?.[e],
|
|
316
|
+
last: (i, e) => i[i.length - 1]?.[e]
|
|
317
|
+
}, f = /* @__PURE__ */ new Map(), g = {
|
|
307
318
|
/**
|
|
308
319
|
* Register a custom aggregator function.
|
|
309
320
|
*/
|
|
310
|
-
register(
|
|
311
|
-
f.set(
|
|
321
|
+
register(i, e) {
|
|
322
|
+
f.set(i, e);
|
|
312
323
|
},
|
|
313
324
|
/**
|
|
314
325
|
* Unregister a custom aggregator function.
|
|
315
326
|
*/
|
|
316
|
-
unregister(
|
|
317
|
-
f.delete(
|
|
327
|
+
unregister(i) {
|
|
328
|
+
f.delete(i);
|
|
318
329
|
},
|
|
319
330
|
/**
|
|
320
331
|
* Get an aggregator function by reference.
|
|
321
332
|
*/
|
|
322
|
-
get(
|
|
323
|
-
if (
|
|
324
|
-
return typeof
|
|
333
|
+
get(i) {
|
|
334
|
+
if (i !== void 0)
|
|
335
|
+
return typeof i == "function" ? i : f.get(i) ?? m[i];
|
|
325
336
|
},
|
|
326
337
|
/**
|
|
327
338
|
* Run an aggregator on a set of rows.
|
|
328
339
|
*/
|
|
329
|
-
run(
|
|
330
|
-
const
|
|
331
|
-
return
|
|
340
|
+
run(i, e, t, o) {
|
|
341
|
+
const r = this.get(i);
|
|
342
|
+
return r ? r(e, t, o) : void 0;
|
|
332
343
|
},
|
|
333
344
|
/**
|
|
334
345
|
* Check if an aggregator exists.
|
|
335
346
|
*/
|
|
336
|
-
has(
|
|
337
|
-
return f.has(
|
|
347
|
+
has(i) {
|
|
348
|
+
return f.has(i) || i in m;
|
|
338
349
|
},
|
|
339
350
|
/**
|
|
340
351
|
* List all available aggregator names.
|
|
@@ -343,303 +354,303 @@ const m = {
|
|
|
343
354
|
return [...Object.keys(m), ...f.keys()];
|
|
344
355
|
}
|
|
345
356
|
}, A = {
|
|
346
|
-
sum: (
|
|
347
|
-
avg: (
|
|
348
|
-
count: (
|
|
349
|
-
min: (
|
|
350
|
-
max: (
|
|
351
|
-
first: (
|
|
352
|
-
last: (
|
|
357
|
+
sum: (i) => i.reduce((e, t) => e + t, 0),
|
|
358
|
+
avg: (i) => i.length ? i.reduce((e, t) => e + t, 0) / i.length : 0,
|
|
359
|
+
count: (i) => i.length,
|
|
360
|
+
min: (i) => i.length ? Math.min(...i) : 0,
|
|
361
|
+
max: (i) => i.length ? Math.max(...i) : 0,
|
|
362
|
+
first: (i) => i[0] ?? 0,
|
|
363
|
+
last: (i) => i[i.length - 1] ?? 0
|
|
353
364
|
};
|
|
354
|
-
function k(
|
|
355
|
-
return A[
|
|
365
|
+
function k(i) {
|
|
366
|
+
return A[i] ?? A.sum;
|
|
356
367
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
368
|
+
g.register.bind(g);
|
|
369
|
+
g.unregister.bind(g);
|
|
370
|
+
g.get.bind(g);
|
|
371
|
+
g.run.bind(g);
|
|
372
|
+
g.list.bind(g);
|
|
362
373
|
const N = k;
|
|
363
|
-
function S(
|
|
374
|
+
function S(i) {
|
|
364
375
|
const e = [];
|
|
365
|
-
return !
|
|
376
|
+
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;
|
|
366
377
|
}
|
|
367
|
-
function
|
|
368
|
-
return [...
|
|
378
|
+
function C(i, e) {
|
|
379
|
+
return [...i, e].join("|");
|
|
369
380
|
}
|
|
370
|
-
function K(
|
|
371
|
-
const t = e.rowGroupFields ?? [],
|
|
372
|
-
o,
|
|
373
|
-
t,
|
|
381
|
+
function K(i, e) {
|
|
382
|
+
const t = e.rowGroupFields ?? [], o = e.columnGroupFields ?? [], r = e.valueFields ?? [], n = I(i, o), a = E(
|
|
374
383
|
i,
|
|
375
|
-
|
|
384
|
+
t,
|
|
385
|
+
o,
|
|
376
386
|
n,
|
|
387
|
+
r,
|
|
377
388
|
0,
|
|
378
389
|
// starting depth
|
|
379
390
|
""
|
|
380
391
|
// parent key prefix
|
|
381
|
-
), s =
|
|
392
|
+
), s = z(a, n, r), l = Object.values(s).reduce((d, c) => d + c, 0);
|
|
382
393
|
return {
|
|
383
394
|
rows: a,
|
|
384
|
-
columnKeys:
|
|
395
|
+
columnKeys: n,
|
|
385
396
|
totals: s,
|
|
386
397
|
grandTotal: l
|
|
387
398
|
};
|
|
388
399
|
}
|
|
389
|
-
function I(
|
|
400
|
+
function I(i, e) {
|
|
390
401
|
if (e.length === 0) return ["value"];
|
|
391
402
|
const t = /* @__PURE__ */ new Set();
|
|
392
|
-
for (const
|
|
393
|
-
const
|
|
394
|
-
t.add(
|
|
403
|
+
for (const o of i) {
|
|
404
|
+
const r = e.map((n) => String(o[n] ?? "")).join("|");
|
|
405
|
+
t.add(r);
|
|
395
406
|
}
|
|
396
407
|
return [...t].sort();
|
|
397
408
|
}
|
|
398
|
-
function V(
|
|
409
|
+
function V(i, e) {
|
|
399
410
|
const t = /* @__PURE__ */ new Map();
|
|
400
|
-
for (const
|
|
401
|
-
const
|
|
402
|
-
|
|
411
|
+
for (const o of i) {
|
|
412
|
+
const r = String(o[e] ?? ""), n = t.get(r);
|
|
413
|
+
n ? n.push(o) : t.set(r, [o]);
|
|
403
414
|
}
|
|
404
415
|
return t;
|
|
405
416
|
}
|
|
406
|
-
function
|
|
417
|
+
function E(i, e, t, o, r, n, a) {
|
|
407
418
|
const s = [];
|
|
408
419
|
if (e.length === 0) {
|
|
409
|
-
const u =
|
|
420
|
+
const u = _(i, t, o, r), h = R(u);
|
|
410
421
|
return s.push({
|
|
411
422
|
rowKey: a || "all",
|
|
412
423
|
rowLabel: a || "All",
|
|
413
|
-
depth:
|
|
424
|
+
depth: n,
|
|
414
425
|
values: u,
|
|
415
|
-
total:
|
|
426
|
+
total: h,
|
|
416
427
|
isGroup: !1,
|
|
417
|
-
rowCount:
|
|
428
|
+
rowCount: i.length
|
|
418
429
|
}), s;
|
|
419
430
|
}
|
|
420
|
-
const l = e[0], d = e.slice(1), c = d.length > 0, p = V(
|
|
421
|
-
for (const [u,
|
|
422
|
-
const
|
|
431
|
+
const l = e[0], d = e.slice(1), c = d.length > 0, p = V(i, l);
|
|
432
|
+
for (const [u, h] of p) {
|
|
433
|
+
const y = a ? `${a}|${u}` : u, x = _(h, t, o, r), G = R(x);
|
|
423
434
|
let F;
|
|
424
|
-
c && (F =
|
|
425
|
-
|
|
435
|
+
c && (F = E(
|
|
436
|
+
h,
|
|
426
437
|
d,
|
|
427
438
|
t,
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
439
|
+
o,
|
|
440
|
+
r,
|
|
441
|
+
n + 1,
|
|
442
|
+
y
|
|
432
443
|
)), s.push({
|
|
433
|
-
rowKey:
|
|
444
|
+
rowKey: y,
|
|
434
445
|
rowLabel: u || "(blank)",
|
|
435
|
-
depth:
|
|
436
|
-
values:
|
|
437
|
-
total:
|
|
446
|
+
depth: n,
|
|
447
|
+
values: x,
|
|
448
|
+
total: G,
|
|
438
449
|
isGroup: c,
|
|
439
450
|
children: F,
|
|
440
|
-
rowCount:
|
|
451
|
+
rowCount: h.length
|
|
441
452
|
});
|
|
442
453
|
}
|
|
443
454
|
return s;
|
|
444
455
|
}
|
|
445
|
-
function
|
|
446
|
-
const
|
|
447
|
-
for (const
|
|
448
|
-
for (const a of
|
|
449
|
-
const l = (e.length > 0 ?
|
|
450
|
-
|
|
456
|
+
function _(i, e, t, o) {
|
|
457
|
+
const r = {};
|
|
458
|
+
for (const n of t)
|
|
459
|
+
for (const a of o) {
|
|
460
|
+
const l = (e.length > 0 ? i.filter((u) => e.map((h) => String(u[h] ?? "")).join("|") === n) : i).map((u) => Number(u[a.field]) || 0), d = N(a.aggFunc), c = l.length > 0 ? d(l) : null, p = C([n], a.field);
|
|
461
|
+
r[p] = c;
|
|
451
462
|
}
|
|
452
|
-
return
|
|
463
|
+
return r;
|
|
453
464
|
}
|
|
454
|
-
function
|
|
465
|
+
function R(i) {
|
|
455
466
|
let e = 0;
|
|
456
|
-
for (const t of Object.values(
|
|
467
|
+
for (const t of Object.values(i))
|
|
457
468
|
e += t ?? 0;
|
|
458
469
|
return e;
|
|
459
470
|
}
|
|
460
|
-
function
|
|
461
|
-
const
|
|
462
|
-
function n
|
|
463
|
-
for (const a of
|
|
471
|
+
function z(i, e, t) {
|
|
472
|
+
const o = {};
|
|
473
|
+
function r(n) {
|
|
474
|
+
for (const a of n)
|
|
464
475
|
if (!a.isGroup || !a.children?.length)
|
|
465
476
|
for (const s of e)
|
|
466
477
|
for (const l of t) {
|
|
467
|
-
const d =
|
|
468
|
-
|
|
478
|
+
const d = C([s], l.field);
|
|
479
|
+
o[d] = (o[d] ?? 0) + (a.values[d] ?? 0);
|
|
469
480
|
}
|
|
470
|
-
else a.children &&
|
|
481
|
+
else a.children && r(a.children);
|
|
471
482
|
}
|
|
472
|
-
return
|
|
483
|
+
return r(i), o;
|
|
473
484
|
}
|
|
474
|
-
function
|
|
475
|
-
const
|
|
476
|
-
function n
|
|
477
|
-
|
|
478
|
-
const a = e ? e.has(
|
|
479
|
-
if (
|
|
480
|
-
for (const s of
|
|
481
|
-
|
|
482
|
-
}
|
|
483
|
-
for (const
|
|
484
|
-
n
|
|
485
|
-
return
|
|
485
|
+
function D(i, e, t = !0) {
|
|
486
|
+
const o = [];
|
|
487
|
+
function r(n) {
|
|
488
|
+
o.push(n);
|
|
489
|
+
const a = e ? e.has(n.rowKey) : t;
|
|
490
|
+
if (n.children && a)
|
|
491
|
+
for (const s of n.children)
|
|
492
|
+
r(s);
|
|
493
|
+
}
|
|
494
|
+
for (const n of i)
|
|
495
|
+
r(n);
|
|
496
|
+
return o;
|
|
486
497
|
}
|
|
487
|
-
function
|
|
498
|
+
function q(i) {
|
|
488
499
|
const e = [];
|
|
489
|
-
function t(
|
|
490
|
-
if (
|
|
491
|
-
for (const
|
|
492
|
-
t(
|
|
500
|
+
function t(o) {
|
|
501
|
+
if (o.isGroup && e.push(o.rowKey), o.children)
|
|
502
|
+
for (const r of o.children)
|
|
503
|
+
t(r);
|
|
493
504
|
}
|
|
494
|
-
for (const
|
|
495
|
-
t(
|
|
505
|
+
for (const o of i)
|
|
506
|
+
t(o);
|
|
496
507
|
return e;
|
|
497
508
|
}
|
|
498
|
-
const
|
|
499
|
-
function
|
|
500
|
-
const
|
|
501
|
-
return a.className = "tbw-pivot-panel", a.appendChild(b("Options", () => W(t,
|
|
502
|
-
|
|
509
|
+
const H = ["sum", "avg", "count", "min", "max", "first", "last"];
|
|
510
|
+
function M(i, e, t, o) {
|
|
511
|
+
const r = new AbortController(), n = { config: e, callbacks: o, signal: r.signal }, a = document.createElement("div");
|
|
512
|
+
return a.className = "tbw-pivot-panel", a.appendChild(b("Options", () => W(t, n))), a.appendChild(b("Row Groups", () => T("rowGroups", n))), a.appendChild(b("Column Groups", () => T("columnGroups", n))), a.appendChild(b("Values", () => Z(n))), a.appendChild(b("Available Fields", () => j(n))), i.appendChild(a), () => {
|
|
513
|
+
r.abort(), a.remove();
|
|
503
514
|
};
|
|
504
515
|
}
|
|
505
|
-
function b(
|
|
516
|
+
function b(i, e) {
|
|
506
517
|
const t = document.createElement("div");
|
|
507
518
|
t.className = "tbw-pivot-section";
|
|
508
|
-
const
|
|
509
|
-
|
|
510
|
-
const
|
|
511
|
-
return
|
|
519
|
+
const o = document.createElement("div");
|
|
520
|
+
o.className = "tbw-pivot-section-header", o.textContent = i;
|
|
521
|
+
const r = document.createElement("div");
|
|
522
|
+
return r.className = "tbw-pivot-section-content", r.appendChild(e()), t.appendChild(o), t.appendChild(r), t;
|
|
512
523
|
}
|
|
513
|
-
function T(
|
|
514
|
-
const { config: t, callbacks:
|
|
515
|
-
|
|
516
|
-
const a =
|
|
524
|
+
function T(i, e) {
|
|
525
|
+
const { config: t, callbacks: o, signal: r } = e, n = document.createElement("div");
|
|
526
|
+
n.className = "tbw-pivot-drop-zone", n.setAttribute("data-zone", i);
|
|
527
|
+
const a = i === "rowGroups" ? t.rowGroupFields ?? [] : t.columnGroupFields ?? [];
|
|
517
528
|
if (a.length === 0) {
|
|
518
529
|
const s = document.createElement("div");
|
|
519
|
-
s.className = "tbw-pivot-placeholder", s.textContent = "Drag fields here or click to add",
|
|
530
|
+
s.className = "tbw-pivot-placeholder", s.textContent = "Drag fields here or click to add", n.appendChild(s);
|
|
520
531
|
} else
|
|
521
532
|
for (const s of a)
|
|
522
|
-
|
|
523
|
-
return
|
|
533
|
+
n.appendChild(O(s, i, e));
|
|
534
|
+
return n.addEventListener(
|
|
524
535
|
"dragover",
|
|
525
536
|
(s) => {
|
|
526
|
-
s.preventDefault(),
|
|
537
|
+
s.preventDefault(), n.classList.add("drag-over");
|
|
527
538
|
},
|
|
528
|
-
{ signal:
|
|
529
|
-
),
|
|
539
|
+
{ signal: r }
|
|
540
|
+
), n.addEventListener(
|
|
530
541
|
"dragleave",
|
|
531
542
|
() => {
|
|
532
|
-
|
|
543
|
+
n.classList.remove("drag-over");
|
|
533
544
|
},
|
|
534
|
-
{ signal:
|
|
535
|
-
),
|
|
545
|
+
{ signal: r }
|
|
546
|
+
), n.addEventListener(
|
|
536
547
|
"drop",
|
|
537
548
|
(s) => {
|
|
538
|
-
s.preventDefault(),
|
|
549
|
+
s.preventDefault(), n.classList.remove("drag-over");
|
|
539
550
|
const l = s.dataTransfer?.getData("text/plain");
|
|
540
|
-
l &&
|
|
551
|
+
l && o.onAddFieldToZone(l, i);
|
|
541
552
|
},
|
|
542
|
-
{ signal:
|
|
543
|
-
),
|
|
553
|
+
{ signal: r }
|
|
554
|
+
), n;
|
|
544
555
|
}
|
|
545
|
-
function O(
|
|
546
|
-
const { callbacks:
|
|
547
|
-
|
|
548
|
-
const a =
|
|
549
|
-
s.className = "tbw-pivot-chip-label", s.textContent = a?.header ??
|
|
556
|
+
function O(i, e, t) {
|
|
557
|
+
const { callbacks: o, signal: r } = t, n = document.createElement("div");
|
|
558
|
+
n.className = "tbw-pivot-field-chip", n.draggable = !0;
|
|
559
|
+
const a = o.getAvailableFields().find((d) => d.field === i), s = document.createElement("span");
|
|
560
|
+
s.className = "tbw-pivot-chip-label", s.textContent = a?.header ?? i;
|
|
550
561
|
const l = document.createElement("button");
|
|
551
562
|
return l.className = "tbw-pivot-chip-remove", l.innerHTML = "×", l.title = "Remove field", l.addEventListener(
|
|
552
563
|
"click",
|
|
553
564
|
(d) => {
|
|
554
|
-
d.stopPropagation(),
|
|
565
|
+
d.stopPropagation(), o.onRemoveFieldFromZone(i, e);
|
|
555
566
|
},
|
|
556
|
-
{ signal:
|
|
557
|
-
),
|
|
567
|
+
{ signal: r }
|
|
568
|
+
), n.appendChild(s), n.appendChild(l), n.addEventListener(
|
|
558
569
|
"dragstart",
|
|
559
570
|
(d) => {
|
|
560
|
-
d.dataTransfer?.setData("text/plain",
|
|
571
|
+
d.dataTransfer?.setData("text/plain", i), d.dataTransfer?.setData("source-zone", e), n.classList.add("dragging");
|
|
561
572
|
},
|
|
562
|
-
{ signal:
|
|
563
|
-
),
|
|
573
|
+
{ signal: r }
|
|
574
|
+
), n.addEventListener(
|
|
564
575
|
"dragend",
|
|
565
576
|
() => {
|
|
566
|
-
|
|
577
|
+
n.classList.remove("dragging");
|
|
567
578
|
},
|
|
568
|
-
{ signal:
|
|
569
|
-
),
|
|
579
|
+
{ signal: r }
|
|
580
|
+
), n;
|
|
570
581
|
}
|
|
571
|
-
function Z(
|
|
572
|
-
const { config: e, callbacks: t, signal:
|
|
573
|
-
|
|
574
|
-
const
|
|
575
|
-
if (
|
|
582
|
+
function Z(i) {
|
|
583
|
+
const { config: e, callbacks: t, signal: o } = i, r = document.createElement("div");
|
|
584
|
+
r.className = "tbw-pivot-drop-zone tbw-pivot-values-zone", r.setAttribute("data-zone", "values");
|
|
585
|
+
const n = e.valueFields ?? [];
|
|
586
|
+
if (n.length === 0) {
|
|
576
587
|
const a = document.createElement("div");
|
|
577
|
-
a.className = "tbw-pivot-placeholder", a.textContent = "Drag numeric fields here for aggregation",
|
|
588
|
+
a.className = "tbw-pivot-placeholder", a.textContent = "Drag numeric fields here for aggregation", r.appendChild(a);
|
|
578
589
|
} else
|
|
579
|
-
for (const a of
|
|
580
|
-
|
|
581
|
-
return
|
|
590
|
+
for (const a of n)
|
|
591
|
+
r.appendChild($(a, i));
|
|
592
|
+
return r.addEventListener(
|
|
582
593
|
"dragover",
|
|
583
594
|
(a) => {
|
|
584
|
-
a.preventDefault(),
|
|
595
|
+
a.preventDefault(), r.classList.add("drag-over");
|
|
585
596
|
},
|
|
586
|
-
{ signal:
|
|
587
|
-
),
|
|
597
|
+
{ signal: o }
|
|
598
|
+
), r.addEventListener(
|
|
588
599
|
"dragleave",
|
|
589
600
|
() => {
|
|
590
|
-
|
|
601
|
+
r.classList.remove("drag-over");
|
|
591
602
|
},
|
|
592
|
-
{ signal:
|
|
593
|
-
),
|
|
603
|
+
{ signal: o }
|
|
604
|
+
), r.addEventListener(
|
|
594
605
|
"drop",
|
|
595
606
|
(a) => {
|
|
596
|
-
a.preventDefault(),
|
|
607
|
+
a.preventDefault(), r.classList.remove("drag-over");
|
|
597
608
|
const s = a.dataTransfer?.getData("text/plain");
|
|
598
609
|
s && t.onAddValueField(s, "sum");
|
|
599
610
|
},
|
|
600
|
-
{ signal:
|
|
601
|
-
),
|
|
611
|
+
{ signal: o }
|
|
612
|
+
), r;
|
|
602
613
|
}
|
|
603
|
-
function $(
|
|
604
|
-
const { callbacks: t, signal:
|
|
605
|
-
|
|
606
|
-
const
|
|
614
|
+
function $(i, e) {
|
|
615
|
+
const { callbacks: t, signal: o } = e, r = document.createElement("div");
|
|
616
|
+
r.className = "tbw-pivot-field-chip tbw-pivot-value-chip";
|
|
617
|
+
const n = t.getAvailableFields().find((c) => c.field === i.field), a = document.createElement("div");
|
|
607
618
|
a.className = "tbw-pivot-value-label-wrapper";
|
|
608
619
|
const s = document.createElement("span");
|
|
609
|
-
s.className = "tbw-pivot-chip-label", s.textContent =
|
|
620
|
+
s.className = "tbw-pivot-chip-label", s.textContent = n?.header ?? i.field;
|
|
610
621
|
const l = document.createElement("select");
|
|
611
622
|
l.className = "tbw-pivot-agg-select", l.title = "Aggregation function";
|
|
612
|
-
for (const c of
|
|
623
|
+
for (const c of H) {
|
|
613
624
|
const p = document.createElement("option");
|
|
614
|
-
p.value = c, p.textContent = c.toUpperCase(), p.selected = c ===
|
|
625
|
+
p.value = c, p.textContent = c.toUpperCase(), p.selected = c === i.aggFunc, l.appendChild(p);
|
|
615
626
|
}
|
|
616
627
|
l.addEventListener(
|
|
617
628
|
"change",
|
|
618
629
|
() => {
|
|
619
|
-
t.onUpdateValueAggFunc(
|
|
630
|
+
t.onUpdateValueAggFunc(i.field, l.value);
|
|
620
631
|
},
|
|
621
|
-
{ signal:
|
|
632
|
+
{ signal: o }
|
|
622
633
|
);
|
|
623
634
|
const d = document.createElement("button");
|
|
624
635
|
return d.className = "tbw-pivot-chip-remove", d.innerHTML = "×", d.title = "Remove value field", d.addEventListener(
|
|
625
636
|
"click",
|
|
626
637
|
(c) => {
|
|
627
|
-
c.stopPropagation(), t.onRemoveValueField(
|
|
638
|
+
c.stopPropagation(), t.onRemoveValueField(i.field);
|
|
628
639
|
},
|
|
629
|
-
{ signal:
|
|
630
|
-
), a.appendChild(s), a.appendChild(l),
|
|
640
|
+
{ signal: o }
|
|
641
|
+
), a.appendChild(s), a.appendChild(l), r.appendChild(a), r.appendChild(d), r;
|
|
631
642
|
}
|
|
632
|
-
function j(
|
|
633
|
-
const { config: e, callbacks: t, signal:
|
|
634
|
-
|
|
635
|
-
const
|
|
643
|
+
function j(i) {
|
|
644
|
+
const { config: e, callbacks: t, signal: o } = i, r = document.createElement("div");
|
|
645
|
+
r.className = "tbw-pivot-available-fields";
|
|
646
|
+
const n = t.getAvailableFields(), a = /* @__PURE__ */ new Set([
|
|
636
647
|
...e.rowGroupFields ?? [],
|
|
637
648
|
...e.columnGroupFields ?? [],
|
|
638
649
|
...e.valueFields?.map((l) => l.field) ?? []
|
|
639
|
-
]), s =
|
|
650
|
+
]), s = n.filter((l) => !a.has(l.field));
|
|
640
651
|
if (s.length === 0) {
|
|
641
652
|
const l = document.createElement("div");
|
|
642
|
-
l.className = "tbw-pivot-placeholder", l.textContent = "All fields are in use",
|
|
653
|
+
l.className = "tbw-pivot-placeholder", l.textContent = "All fields are in use", r.appendChild(l);
|
|
643
654
|
} else
|
|
644
655
|
for (const l of s) {
|
|
645
656
|
const d = document.createElement("div");
|
|
@@ -648,106 +659,106 @@ function j(o) {
|
|
|
648
659
|
(c) => {
|
|
649
660
|
c.dataTransfer?.setData("text/plain", l.field), d.classList.add("dragging");
|
|
650
661
|
},
|
|
651
|
-
{ signal:
|
|
662
|
+
{ signal: o }
|
|
652
663
|
), d.addEventListener(
|
|
653
664
|
"dragend",
|
|
654
665
|
() => {
|
|
655
666
|
d.classList.remove("dragging");
|
|
656
667
|
},
|
|
657
|
-
{ signal:
|
|
658
|
-
),
|
|
668
|
+
{ signal: o }
|
|
669
|
+
), r.appendChild(d);
|
|
659
670
|
}
|
|
660
|
-
return
|
|
671
|
+
return r;
|
|
661
672
|
}
|
|
662
|
-
function W(
|
|
663
|
-
const { config: t, callbacks:
|
|
664
|
-
return
|
|
673
|
+
function W(i, e) {
|
|
674
|
+
const { config: t, callbacks: o, signal: r } = e, n = document.createElement("div");
|
|
675
|
+
return n.className = "tbw-pivot-options", n.appendChild(
|
|
665
676
|
w(
|
|
666
677
|
"Enable Pivot View",
|
|
667
|
-
|
|
678
|
+
i,
|
|
668
679
|
(a) => {
|
|
669
|
-
|
|
680
|
+
o.onTogglePivot(a);
|
|
670
681
|
},
|
|
671
|
-
|
|
682
|
+
r
|
|
672
683
|
)
|
|
673
|
-
),
|
|
684
|
+
), n.appendChild(
|
|
674
685
|
w(
|
|
675
686
|
"Show Row Totals",
|
|
676
687
|
t.showTotals ?? !0,
|
|
677
688
|
(a) => {
|
|
678
|
-
|
|
689
|
+
o.onOptionChange("showTotals", a);
|
|
679
690
|
},
|
|
680
|
-
|
|
691
|
+
r
|
|
681
692
|
)
|
|
682
|
-
),
|
|
693
|
+
), n.appendChild(
|
|
683
694
|
w(
|
|
684
695
|
"Show Grand Total",
|
|
685
696
|
t.showGrandTotal ?? !0,
|
|
686
697
|
(a) => {
|
|
687
|
-
|
|
698
|
+
o.onOptionChange("showGrandTotal", a);
|
|
688
699
|
},
|
|
689
|
-
|
|
700
|
+
r
|
|
690
701
|
)
|
|
691
|
-
),
|
|
702
|
+
), n;
|
|
692
703
|
}
|
|
693
|
-
function w(
|
|
694
|
-
const
|
|
695
|
-
|
|
696
|
-
const
|
|
697
|
-
|
|
704
|
+
function w(i, e, t, o) {
|
|
705
|
+
const r = document.createElement("label");
|
|
706
|
+
r.className = "tbw-pivot-checkbox";
|
|
707
|
+
const n = document.createElement("input");
|
|
708
|
+
n.type = "checkbox", n.checked = e, n.addEventListener("change", () => t(n.checked), { signal: o });
|
|
698
709
|
const a = document.createElement("span");
|
|
699
|
-
return a.textContent =
|
|
710
|
+
return a.textContent = i, r.appendChild(n), r.appendChild(a), r;
|
|
700
711
|
}
|
|
701
|
-
function U(
|
|
702
|
-
return e.className = "data-grid-row pivot-group-row", e.setAttribute("data-pivot-depth", String(
|
|
703
|
-
const
|
|
704
|
-
if (
|
|
705
|
-
const a = Number(
|
|
706
|
-
|
|
707
|
-
const s = String(
|
|
708
|
-
l.type = "button", l.className = "pivot-toggle", l.setAttribute("aria-label",
|
|
712
|
+
function U(i, e, t) {
|
|
713
|
+
return e.className = "data-grid-row 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, r) => {
|
|
714
|
+
const n = document.createElement("div");
|
|
715
|
+
if (n.className = "cell", n.setAttribute("data-col", String(r)), n.setAttribute("data-row", String(t.rowIndex)), n.setAttribute("role", "gridcell"), r === 0) {
|
|
716
|
+
const a = Number(i.__pivotIndent) || 0;
|
|
717
|
+
n.style.paddingLeft = `${a}px`;
|
|
718
|
+
const s = String(i.__pivotRowKey), l = document.createElement("button");
|
|
719
|
+
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) => {
|
|
709
720
|
p.stopPropagation(), t.onToggle(s);
|
|
710
|
-
}),
|
|
721
|
+
}), n.appendChild(l);
|
|
711
722
|
const d = document.createElement("span");
|
|
712
|
-
d.className = "pivot-label", d.textContent = String(
|
|
723
|
+
d.className = "pivot-label", d.textContent = String(i.__pivotLabel ?? ""), n.appendChild(d);
|
|
713
724
|
const c = document.createElement("span");
|
|
714
|
-
c.className = "pivot-count", c.textContent = ` (${Number(
|
|
725
|
+
c.className = "pivot-count", c.textContent = ` (${Number(i.__pivotRowCount) || 0})`, n.appendChild(c);
|
|
715
726
|
} else {
|
|
716
|
-
const a = o
|
|
717
|
-
|
|
727
|
+
const a = i[o.field];
|
|
728
|
+
n.textContent = a != null ? String(a) : "";
|
|
718
729
|
}
|
|
719
|
-
e.appendChild(
|
|
730
|
+
e.appendChild(n);
|
|
720
731
|
}), !0;
|
|
721
732
|
}
|
|
722
|
-
function B(
|
|
723
|
-
return e.className = "data-grid-row pivot-leaf-row", e.setAttribute("data-pivot-depth", String(
|
|
733
|
+
function B(i, e, t, o) {
|
|
734
|
+
return e.className = "data-grid-row pivot-leaf-row", e.setAttribute("data-pivot-depth", String(i.__pivotDepth ?? 0)), e.setAttribute("data-pivot-key", String(i.__pivotRowKey ?? "")), e.innerHTML = "", t.forEach((r, n) => {
|
|
724
735
|
const a = document.createElement("div");
|
|
725
|
-
if (a.className = "cell", a.setAttribute("data-col", String(
|
|
726
|
-
const s = Number(
|
|
736
|
+
if (a.className = "cell", a.setAttribute("data-col", String(n)), a.setAttribute("data-row", String(o)), a.setAttribute("role", "gridcell"), n === 0) {
|
|
737
|
+
const s = Number(i.__pivotIndent) || 0;
|
|
727
738
|
a.style.paddingLeft = `${s + 20}px`;
|
|
728
739
|
const l = document.createElement("span");
|
|
729
|
-
l.className = "pivot-label", l.textContent = String(
|
|
740
|
+
l.className = "pivot-label", l.textContent = String(i.__pivotLabel ?? ""), a.appendChild(l);
|
|
730
741
|
} else {
|
|
731
|
-
const s =
|
|
742
|
+
const s = i[r.field];
|
|
732
743
|
a.textContent = s != null ? String(s) : "";
|
|
733
744
|
}
|
|
734
745
|
e.appendChild(a);
|
|
735
746
|
}), !0;
|
|
736
747
|
}
|
|
737
|
-
function J(
|
|
738
|
-
return e.className = "pivot-grand-total-row", e.setAttribute("role", "presentation"), e.innerHTML = "", t.forEach((
|
|
739
|
-
const
|
|
740
|
-
if (
|
|
748
|
+
function J(i, e, t) {
|
|
749
|
+
return e.className = "pivot-grand-total-row", e.setAttribute("role", "presentation"), e.innerHTML = "", t.forEach((o, r) => {
|
|
750
|
+
const n = document.createElement("div");
|
|
751
|
+
if (n.className = "cell", n.setAttribute("data-col", String(r)), r === 0) {
|
|
741
752
|
const a = document.createElement("span");
|
|
742
|
-
a.className = "pivot-label", a.textContent = "Grand Total",
|
|
753
|
+
a.className = "pivot-label", a.textContent = "Grand Total", n.appendChild(a);
|
|
743
754
|
} else {
|
|
744
|
-
const a = o
|
|
745
|
-
|
|
755
|
+
const a = i[o.field];
|
|
756
|
+
n.textContent = a != null ? String(a) : "";
|
|
746
757
|
}
|
|
747
|
-
e.appendChild(
|
|
758
|
+
e.appendChild(n);
|
|
748
759
|
}), !0;
|
|
749
760
|
}
|
|
750
|
-
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:
|
|
761
|
+
const Q = '@layer tbw-plugins{.pivot-group-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:600;background:var(--tbw-pivot-group-bg, var(--tbw-color-row-alt));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-group-row:hover{background:var(--tbw-pivot-group-hover, var(--tbw-color-row-hover))}.pivot-leaf-row{display:grid;grid-template-columns:var(--tbw-column-template);background:var(--tbw-pivot-leaf-bg, var(--tbw-color-bg));min-height:var(--tbw-row-height);border-bottom:var(--tbw-row-divider)}.pivot-grand-total-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:700;background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-height:var(--tbw-row-height);border-top:2px solid var(--tbw-color-border-strong)}.pivot-grand-total-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-grand-total-row>.cell:last-child{border-right:0}.pivot-grand-total-footer{position:sticky;bottom:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-pivot-grand-total-bg, var(--tbw-color-header-bg));min-width:fit-content}.pivot-group-row>.cell,.pivot-leaf-row>.cell{display:flex;align-items:center;padding:var(--tbw-cell-padding);border-right:1px solid var(--tbw-color-border-cell);overflow:hidden;min-width:0}.pivot-group-row>.cell:last-child,.pivot-leaf-row>.cell:last-child{border-right:0}.pivot-toggle{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;margin-right:6px;border:none;background:transparent;cursor:pointer;color:var(--tbw-pivot-toggle-color, var(--tbw-color-fg-muted));border-radius:var(--tbw-border-radius);transition:background .15s,color .15s}.pivot-toggle:hover{background:var(--tbw-pivot-toggle-hover-bg, var(--tbw-color-row-hover));color:var(--tbw-pivot-toggle-hover-color, var(--tbw-color-fg))}.pivot-toggle:focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}.pivot-label{font-weight:inherit}.pivot-count{color:var(--tbw-pivot-count-color, var(--tbw-color-fg-muted));font-size:.9em;font-weight:400}.pivot-total-row{font-weight:700;border-top:2px solid var(--tbw-pivot-border, var(--tbw-color-border-strong))}[data-pivot-depth="1"]{--tbw-pivot-depth: 1}[data-pivot-depth="2"]{--tbw-pivot-depth: 2}[data-pivot-depth="3"]{--tbw-pivot-depth: 3}[data-pivot-depth="4"]{--tbw-pivot-depth: 4}.tbw-pivot-panel{display:flex;flex-direction:column;gap:var(--tbw-panel-padding, var(--tbw-spacing-lg, .75rem));padding:var(--tbw-panel-padding, var(--tbw-spacing-lg, .75rem));height:100%;overflow-y:auto;font-size:var(--tbw-font-size-sm, .8125rem)}.tbw-pivot-section{border:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-section-bg, var(--tbw-color-bg))}.tbw-pivot-section-header{padding:var(--tbw-button-padding, var(--tbw-spacing-md, .5rem) var(--tbw-spacing-lg, .75rem));font-weight:600;background:var(--tbw-pivot-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius) var(--tbw-border-radius) 0 0}.tbw-pivot-section-content{padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-pivot-toggle-wrapper{display:flex;align-items:center}.tbw-pivot-toggle-label{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));cursor:pointer}.tbw-pivot-toggle-label input{width:var(--tbw-icon-size, 1rem);height:var(--tbw-icon-size, 1rem);cursor:pointer}.tbw-pivot-drop-zone{min-height:60px;padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));border:2px dashed var(--tbw-pivot-drop-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-drop-bg, var(--tbw-color-row-alt));display:flex;flex-wrap:wrap;gap:var(--tbw-spacing-sm, .375rem);align-content:flex-start;transition:all .15s ease}.tbw-pivot-drop-zone.drag-over{border-color:var(--tbw-color-accent);background:var(--tbw-pivot-drop-active, var(--tbw-focus-background))}.tbw-pivot-placeholder{color:var(--tbw-color-fg-muted);font-style:italic;padding:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));text-align:center;width:100%}.tbw-pivot-field-chip{display:inline-flex;align-items:center;gap:var(--tbw-spacing-sm, .375rem);padding:var(--tbw-button-padding-sm, var(--tbw-spacing-xs, .25rem) var(--tbw-spacing-md, .5rem));background:var(--tbw-pivot-chip-bg, var(--tbw-color-header-bg));border:1px solid var(--tbw-pivot-chip-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);cursor:grab;font-size:var(--tbw-font-size-xs, .75rem);transition:all .15s ease}.tbw-pivot-field-chip:hover{background:var(--tbw-pivot-chip-hover, var(--tbw-color-row-hover));border-color:var(--tbw-color-accent)}.tbw-pivot-field-chip.available{background:var(--tbw-color-bg)}.tbw-pivot-field-chip.dragging{opacity:.5;cursor:grabbing}.tbw-pivot-chip-label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:120px}.tbw-pivot-chip-remove{display:flex;align-items:center;justify-content:center;width:var(--tbw-icon-size, 1rem);height:var(--tbw-icon-size, 1rem);padding:0;border:none;background:transparent;color:var(--tbw-color-fg-muted);font-size:var(--tbw-font-size-sm, .875rem);font-weight:700;cursor:pointer;border-radius:50%;transition:all .15s ease}.tbw-pivot-chip-remove:hover{background:var(--tbw-pivot-chip-remove-hover-bg, var(--tbw-color-accent));color:var(--tbw-pivot-chip-remove-hover-fg, var(--tbw-color-accent-fg))}.tbw-pivot-value-chip{padding:var(--tbw-button-padding-sm, var(--tbw-spacing-xs, .25rem) var(--tbw-spacing-md, .5rem))}.tbw-pivot-value-label-wrapper{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));flex:1;min-width:0}.tbw-pivot-agg-select{padding:var(--tbw-spacing-xs, .125rem) var(--tbw-spacing-xs, .25rem);font-size:var(--tbw-font-size-xs, .6875rem);border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);cursor:pointer}.tbw-pivot-available-fields{display:flex;flex-wrap:wrap;gap:var(--tbw-spacing-sm, .375rem);min-height:40px}.tbw-pivot-options{display:flex;flex-direction:column;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem))}.tbw-pivot-checkbox{display:flex;align-items:center;gap:var(--tbw-panel-gap, var(--tbw-spacing-md, .5rem));cursor:pointer}.tbw-pivot-checkbox input{width:var(--tbw-icon-size-sm, .875rem);height:var(--tbw-icon-size-sm, .875rem);cursor:pointer}.pivot-group-row.tbw-pivot-slide-in,.pivot-leaf-row.tbw-pivot-slide-in{animation:tbw-pivot-slide-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-pivot-slide-in{0%{opacity:0;transform:translate(-8px)}to{opacity:1;transform:translate(0)}}.pivot-group-row.tbw-pivot-fade-in,.pivot-leaf-row.tbw-pivot-fade-in{animation:tbw-pivot-fade-in var(--tbw-animation-duration, .2s) var(--tbw-animation-easing, ease-out) forwards}@keyframes tbw-pivot-fade-in{0%{opacity:0}to{opacity:1}}}';
|
|
751
762
|
class v extends P {
|
|
752
763
|
name = "pivot";
|
|
753
764
|
styles = Q;
|
|
@@ -814,7 +825,7 @@ class v extends P {
|
|
|
814
825
|
if (t.length > 0)
|
|
815
826
|
return this.warn(`Config errors: ${t.join(", ")}`), [...e];
|
|
816
827
|
this.buildFieldHeaderMap(), this.defaultExpanded = this.config.defaultExpanded ?? !0, this.expandedKeys.size === 0 && this.defaultExpanded && this.pivotResult && this.expandAllKeys(), this.pivotResult = K(e, this.config), this.expandedKeys.size === 0 && this.defaultExpanded && this.expandAllKeys();
|
|
817
|
-
const
|
|
828
|
+
const o = this.config.indentWidth ?? 20, r = D(
|
|
818
829
|
this.pivotResult.rows,
|
|
819
830
|
this.expandedKeys,
|
|
820
831
|
this.defaultExpanded
|
|
@@ -826,33 +837,33 @@ class v extends P {
|
|
|
826
837
|
__pivotHasChildren: !!a.children?.length,
|
|
827
838
|
__pivotExpanded: this.expandedKeys.has(a.rowKey),
|
|
828
839
|
__pivotRowCount: a.rowCount ?? 0,
|
|
829
|
-
__pivotIndent: a.depth *
|
|
840
|
+
__pivotIndent: a.depth * o,
|
|
830
841
|
__pivotTotal: a.total,
|
|
831
842
|
...a.values
|
|
832
843
|
}));
|
|
833
844
|
this.keysToAnimate.clear();
|
|
834
|
-
const
|
|
835
|
-
for (const a of
|
|
845
|
+
const n = /* @__PURE__ */ new Set();
|
|
846
|
+
for (const a of r) {
|
|
836
847
|
const s = a.__pivotRowKey;
|
|
837
|
-
|
|
848
|
+
n.add(s), !this.previousVisibleKeys.has(s) && a.__pivotDepth > 0 && this.keysToAnimate.add(s);
|
|
838
849
|
}
|
|
839
|
-
return this.previousVisibleKeys =
|
|
850
|
+
return this.previousVisibleKeys = n, r;
|
|
840
851
|
}
|
|
841
852
|
processColumns(e) {
|
|
842
853
|
if (!this.isActive || !this.pivotResult)
|
|
843
854
|
return [...e];
|
|
844
|
-
const t = [],
|
|
855
|
+
const t = [], o = (this.config.rowGroupFields ?? []).map((r) => this.fieldHeaderMap.get(r) ?? r).join(" / ");
|
|
845
856
|
t.push({
|
|
846
857
|
field: "__pivotLabel",
|
|
847
|
-
header:
|
|
858
|
+
header: o || "Group",
|
|
848
859
|
width: 200
|
|
849
860
|
});
|
|
850
|
-
for (const
|
|
851
|
-
for (const
|
|
852
|
-
const a =
|
|
861
|
+
for (const r of this.pivotResult.columnKeys)
|
|
862
|
+
for (const n of this.config.valueFields ?? []) {
|
|
863
|
+
const a = C([r], n.field), s = n.header || this.fieldHeaderMap.get(n.field) || n.field;
|
|
853
864
|
t.push({
|
|
854
865
|
field: a,
|
|
855
|
-
header: `${
|
|
866
|
+
header: `${r} - ${s} (${n.aggFunc})`,
|
|
856
867
|
width: 120,
|
|
857
868
|
type: "number"
|
|
858
869
|
});
|
|
@@ -864,15 +875,15 @@ class v extends P {
|
|
|
864
875
|
type: "number"
|
|
865
876
|
}), t;
|
|
866
877
|
}
|
|
867
|
-
renderRow(e, t,
|
|
868
|
-
const
|
|
869
|
-
return
|
|
878
|
+
renderRow(e, t, o) {
|
|
879
|
+
const r = e;
|
|
880
|
+
return r.__pivotRowKey && r.__pivotHasChildren ? U(r, t, {
|
|
870
881
|
columns: this.gridColumns,
|
|
871
|
-
rowIndex:
|
|
872
|
-
onToggle: (
|
|
873
|
-
resolveIcon: (
|
|
874
|
-
setIcon: (
|
|
875
|
-
}) :
|
|
882
|
+
rowIndex: o,
|
|
883
|
+
onToggle: (n) => this.toggle(n),
|
|
884
|
+
resolveIcon: (n) => this.resolveIcon(n),
|
|
885
|
+
setIcon: (n, a) => this.setIcon(n, a)
|
|
886
|
+
}) : r.__pivotRowKey !== void 0 && this.isActive ? B(r, t, this.gridColumns, o) : (this.cleanupPivotStyling(t), !1);
|
|
876
887
|
}
|
|
877
888
|
/**
|
|
878
889
|
* Remove pivot-specific classes, attributes, and inline styles from a row element.
|
|
@@ -884,20 +895,20 @@ class v extends P {
|
|
|
884
895
|
}
|
|
885
896
|
onKeyDown(e) {
|
|
886
897
|
if (e.key !== " " || !this.isActive) return;
|
|
887
|
-
const t = this.grid._focusRow,
|
|
888
|
-
if (!(!
|
|
889
|
-
return e.preventDefault(), this.toggle(
|
|
898
|
+
const t = this.grid._focusRow, o = this.rows[t];
|
|
899
|
+
if (!(!o?.__pivotIsGroup || !o.__pivotHasChildren))
|
|
900
|
+
return e.preventDefault(), this.toggle(o.__pivotRowKey), this.requestRenderWithFocus(), !0;
|
|
890
901
|
}
|
|
891
902
|
afterRender() {
|
|
892
903
|
this.isActive && this.config.showGrandTotal && this.pivotResult ? this.renderGrandTotalFooter() : this.cleanupGrandTotalFooter();
|
|
893
904
|
const e = this.animationStyle;
|
|
894
905
|
if (e === !1 || this.keysToAnimate.size === 0) return;
|
|
895
|
-
const t = this.
|
|
906
|
+
const t = this.gridElement?.querySelector(".rows");
|
|
896
907
|
if (!t) return;
|
|
897
|
-
const
|
|
898
|
-
for (const
|
|
899
|
-
const
|
|
900
|
-
|
|
908
|
+
const o = e === "fade" ? "tbw-pivot-fade-in" : "tbw-pivot-slide-in";
|
|
909
|
+
for (const r of t.querySelectorAll(".pivot-group-row, .pivot-leaf-row")) {
|
|
910
|
+
const n = r.dataset.pivotKey;
|
|
911
|
+
n && this.keysToAnimate.has(n) && (r.classList.add(o), r.addEventListener("animationend", () => r.classList.remove(o), { once: !0 }));
|
|
901
912
|
}
|
|
902
913
|
this.keysToAnimate.clear();
|
|
903
914
|
}
|
|
@@ -906,19 +917,19 @@ class v extends P {
|
|
|
906
917
|
*/
|
|
907
918
|
renderGrandTotalFooter() {
|
|
908
919
|
if (!this.pivotResult) return;
|
|
909
|
-
const e = this.
|
|
920
|
+
const e = this.gridElement;
|
|
910
921
|
if (!e) return;
|
|
911
922
|
const t = e.querySelector(".tbw-scroll-area") ?? e.querySelector(".tbw-grid-content") ?? e.children[0];
|
|
912
923
|
if (!t) return;
|
|
913
924
|
this.grandTotalFooter || (this.grandTotalFooter = document.createElement("div"), this.grandTotalFooter.className = "pivot-grand-total-footer", t.appendChild(this.grandTotalFooter));
|
|
914
|
-
const
|
|
925
|
+
const o = {
|
|
915
926
|
__pivotRowKey: "__grandTotal",
|
|
916
927
|
__pivotLabel: "Grand Total",
|
|
917
928
|
__pivotIsGrandTotal: !0,
|
|
918
929
|
__pivotTotal: this.pivotResult.grandTotal,
|
|
919
930
|
...this.pivotResult.totals
|
|
920
931
|
};
|
|
921
|
-
J(
|
|
932
|
+
J(o, this.grandTotalFooter, this.gridColumns);
|
|
922
933
|
}
|
|
923
934
|
/**
|
|
924
935
|
* Remove the grand total footer element.
|
|
@@ -948,7 +959,7 @@ class v extends P {
|
|
|
948
959
|
*/
|
|
949
960
|
expandAllKeys() {
|
|
950
961
|
if (!this.pivotResult) return;
|
|
951
|
-
const e =
|
|
962
|
+
const e = q(this.pivotResult.rows);
|
|
952
963
|
for (const t of e)
|
|
953
964
|
this.expandedKeys.add(t);
|
|
954
965
|
}
|
|
@@ -1042,50 +1053,50 @@ class v extends P {
|
|
|
1042
1053
|
renderPanel(e) {
|
|
1043
1054
|
this.panelContainer = e, this.originalColumns.length === 0 && this.captureOriginalColumns();
|
|
1044
1055
|
const t = {
|
|
1045
|
-
onTogglePivot: (
|
|
1046
|
-
|
|
1056
|
+
onTogglePivot: (o) => {
|
|
1057
|
+
o ? this.enablePivot() : this.disablePivot(), this.refreshPanel();
|
|
1047
1058
|
},
|
|
1048
|
-
onAddFieldToZone: (
|
|
1049
|
-
onRemoveFieldFromZone: (
|
|
1050
|
-
onAddValueField: (
|
|
1051
|
-
onRemoveValueField: (
|
|
1052
|
-
onUpdateValueAggFunc: (
|
|
1053
|
-
onOptionChange: (
|
|
1054
|
-
this.config[
|
|
1059
|
+
onAddFieldToZone: (o, r) => this.addFieldToZone(o, r),
|
|
1060
|
+
onRemoveFieldFromZone: (o, r) => this.removeFieldFromZone(o, r),
|
|
1061
|
+
onAddValueField: (o, r) => this.addValueField(o, r),
|
|
1062
|
+
onRemoveValueField: (o) => this.removeValueField(o),
|
|
1063
|
+
onUpdateValueAggFunc: (o, r) => this.updateValueAggFunc(o, r),
|
|
1064
|
+
onOptionChange: (o, r) => {
|
|
1065
|
+
this.config[o] = r, this.isActive && this.refresh();
|
|
1055
1066
|
},
|
|
1056
1067
|
getAvailableFields: () => this.getAvailableFields()
|
|
1057
1068
|
};
|
|
1058
|
-
return
|
|
1069
|
+
return M(e, this.config, this.isActive, t);
|
|
1059
1070
|
}
|
|
1060
1071
|
refreshPanel() {
|
|
1061
1072
|
this.panelContainer && (this.panelContainer.innerHTML = "", this.renderPanel(this.panelContainer));
|
|
1062
1073
|
}
|
|
1063
1074
|
addFieldToZone(e, t) {
|
|
1064
1075
|
if (t === "rowGroups") {
|
|
1065
|
-
const
|
|
1066
|
-
|
|
1076
|
+
const o = this.config.rowGroupFields ?? [];
|
|
1077
|
+
o.includes(e) || (this.config.rowGroupFields = [...o, e]);
|
|
1067
1078
|
} else {
|
|
1068
|
-
const
|
|
1069
|
-
|
|
1079
|
+
const o = this.config.columnGroupFields ?? [];
|
|
1080
|
+
o.includes(e) || (this.config.columnGroupFields = [...o, e]);
|
|
1070
1081
|
}
|
|
1071
1082
|
this.removeFromOtherZones(e, t), this.refreshIfActive();
|
|
1072
1083
|
}
|
|
1073
1084
|
removeFieldFromZone(e, t) {
|
|
1074
|
-
t === "rowGroups" ? this.config.rowGroupFields = (this.config.rowGroupFields ?? []).filter((
|
|
1085
|
+
t === "rowGroups" ? this.config.rowGroupFields = (this.config.rowGroupFields ?? []).filter((o) => o !== e) : this.config.columnGroupFields = (this.config.columnGroupFields ?? []).filter((o) => o !== e), this.refreshIfActive();
|
|
1075
1086
|
}
|
|
1076
1087
|
removeFromOtherZones(e, t) {
|
|
1077
|
-
t !== "rowGroups" && (this.config.rowGroupFields = (this.config.rowGroupFields ?? []).filter((
|
|
1088
|
+
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));
|
|
1078
1089
|
}
|
|
1079
1090
|
addValueField(e, t) {
|
|
1080
|
-
const
|
|
1081
|
-
|
|
1091
|
+
const o = this.config.valueFields ?? [];
|
|
1092
|
+
o.some((r) => r.field === e) || (this.config.valueFields = [...o, { field: e, aggFunc: t }]), this.removeFromOtherZones(e, "values"), this.refreshIfActive();
|
|
1082
1093
|
}
|
|
1083
1094
|
removeValueField(e) {
|
|
1084
1095
|
this.config.valueFields = (this.config.valueFields ?? []).filter((t) => t.field !== e), this.refreshIfActive();
|
|
1085
1096
|
}
|
|
1086
1097
|
updateValueAggFunc(e, t) {
|
|
1087
|
-
const
|
|
1088
|
-
|
|
1098
|
+
const o = this.config.valueFields ?? [], r = o.findIndex((n) => n.field === e);
|
|
1099
|
+
r >= 0 && (o[r] = { ...o[r], aggFunc: t }, this.config.valueFields = [...o]), this.isActive && this.refresh();
|
|
1089
1100
|
}
|
|
1090
1101
|
// #endregion
|
|
1091
1102
|
}
|