@toolbox-web/grid 0.1.0 → 0.2.1
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 +1 -1
- package/all.d.ts +13 -0
- package/all.js +1684 -1196
- package/all.js.map +1 -1
- package/index.d.ts +4 -163
- package/index.js +1278 -1702
- package/index.js.map +1 -1
- package/lib/plugins/clipboard/index.js.map +1 -1
- package/lib/plugins/column-virtualization/index.js.map +1 -1
- package/lib/plugins/context-menu/index.js +35 -78
- package/lib/plugins/context-menu/index.js.map +1 -1
- package/lib/plugins/export/index.js.map +1 -1
- package/lib/plugins/filtering/index.js.map +1 -1
- package/lib/plugins/grouping-columns/index.js.map +1 -1
- package/lib/plugins/grouping-rows/index.js.map +1 -1
- package/lib/plugins/master-detail/index.js +1 -1
- package/lib/plugins/master-detail/index.js.map +1 -1
- package/lib/plugins/multi-sort/index.js.map +1 -1
- package/lib/plugins/pinned-columns/index.js.map +1 -1
- package/lib/plugins/pinned-rows/index.js +8 -8
- package/lib/plugins/pinned-rows/index.js.map +1 -1
- package/lib/plugins/pivot/index.js +160 -160
- package/lib/plugins/pivot/index.js.map +1 -1
- package/lib/plugins/reorder/index.js.map +1 -1
- package/lib/plugins/selection/index.js +93 -72
- package/lib/plugins/selection/index.js.map +1 -1
- package/lib/plugins/server-side/index.js.map +1 -1
- package/lib/plugins/tree/index.js.map +1 -1
- package/lib/plugins/undo-redo/index.js.map +1 -1
- package/lib/plugins/visibility/index.js.map +1 -1
- package/package.json +1 -1
- package/umd/grid.all.umd.js +27 -78
- package/umd/grid.all.umd.js.map +1 -1
- package/umd/grid.umd.js +28 -28
- package/umd/grid.umd.js.map +1 -1
- package/umd/plugins/context-menu.umd.js +1 -52
- package/umd/plugins/context-menu.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/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/selection.umd.js +1 -1
- package/umd/plugins/selection.umd.js.map +1 -1
- package/custom-elements.json +0 -1934
|
@@ -166,7 +166,7 @@ class N {
|
|
|
166
166
|
const m = {
|
|
167
167
|
sum: (t, e) => t.reduce((i, o) => i + (Number(o[e]) || 0), 0),
|
|
168
168
|
avg: (t, e) => {
|
|
169
|
-
const i = t.reduce((o,
|
|
169
|
+
const i = t.reduce((o, r) => o + (Number(r[e]) || 0), 0);
|
|
170
170
|
return t.length ? i / t.length : 0;
|
|
171
171
|
},
|
|
172
172
|
count: (t) => t.length,
|
|
@@ -198,8 +198,8 @@ const m = {
|
|
|
198
198
|
* Run an aggregator on a set of rows.
|
|
199
199
|
*/
|
|
200
200
|
run(t, e, i, o) {
|
|
201
|
-
const
|
|
202
|
-
return
|
|
201
|
+
const r = this.get(t);
|
|
202
|
+
return r ? r(e, i, o) : void 0;
|
|
203
203
|
},
|
|
204
204
|
/**
|
|
205
205
|
* Check if an aggregator exists.
|
|
@@ -239,20 +239,20 @@ function C(t, e) {
|
|
|
239
239
|
return [...t, e].join("|");
|
|
240
240
|
}
|
|
241
241
|
function S(t, e) {
|
|
242
|
-
const i = e.rowGroupFields ?? [], o = e.columnGroupFields ?? [],
|
|
242
|
+
const i = e.rowGroupFields ?? [], o = e.columnGroupFields ?? [], r = e.valueFields ?? [], n = V(t, o), a = L(
|
|
243
243
|
t,
|
|
244
244
|
i,
|
|
245
245
|
o,
|
|
246
|
-
r,
|
|
247
246
|
n,
|
|
247
|
+
r,
|
|
248
248
|
0,
|
|
249
249
|
// starting depth
|
|
250
250
|
""
|
|
251
251
|
// parent key prefix
|
|
252
|
-
), s = H(a,
|
|
252
|
+
), s = H(a, n, r), l = Object.values(s).reduce((d, c) => d + c, 0);
|
|
253
253
|
return {
|
|
254
254
|
rows: a,
|
|
255
|
-
columnKeys:
|
|
255
|
+
columnKeys: n,
|
|
256
256
|
totals: s,
|
|
257
257
|
grandTotal: l
|
|
258
258
|
};
|
|
@@ -261,27 +261,27 @@ function V(t, e) {
|
|
|
261
261
|
if (e.length === 0) return ["value"];
|
|
262
262
|
const i = /* @__PURE__ */ new Set();
|
|
263
263
|
for (const o of t) {
|
|
264
|
-
const
|
|
265
|
-
i.add(
|
|
264
|
+
const r = e.map((n) => String(o[n] ?? "")).join("|");
|
|
265
|
+
i.add(r);
|
|
266
266
|
}
|
|
267
267
|
return [...i].sort();
|
|
268
268
|
}
|
|
269
269
|
function M(t, e) {
|
|
270
270
|
const i = /* @__PURE__ */ new Map();
|
|
271
271
|
for (const o of t) {
|
|
272
|
-
const
|
|
273
|
-
|
|
272
|
+
const r = String(o[e] ?? ""), n = i.get(r);
|
|
273
|
+
n ? n.push(o) : i.set(r, [o]);
|
|
274
274
|
}
|
|
275
275
|
return i;
|
|
276
276
|
}
|
|
277
|
-
function L(t, e, i, o,
|
|
277
|
+
function L(t, e, i, o, r, n, a) {
|
|
278
278
|
const s = [];
|
|
279
279
|
if (e.length === 0) {
|
|
280
|
-
const u = _(t, i, o,
|
|
280
|
+
const u = _(t, i, o, r), g = G(u);
|
|
281
281
|
return s.push({
|
|
282
282
|
rowKey: a || "all",
|
|
283
283
|
rowLabel: a || "All",
|
|
284
|
-
depth:
|
|
284
|
+
depth: n,
|
|
285
285
|
values: u,
|
|
286
286
|
total: g,
|
|
287
287
|
isGroup: !1,
|
|
@@ -290,20 +290,20 @@ function L(t, e, i, o, n, r, a) {
|
|
|
290
290
|
}
|
|
291
291
|
const l = e[0], d = e.slice(1), c = d.length > 0, p = M(t, l);
|
|
292
292
|
for (const [u, g] of p) {
|
|
293
|
-
const F = a ? `${a}|${u}` : u, y = _(g, i, o,
|
|
293
|
+
const F = a ? `${a}|${u}` : u, y = _(g, i, o, r), E = G(y);
|
|
294
294
|
let R;
|
|
295
295
|
c && (R = L(
|
|
296
296
|
g,
|
|
297
297
|
d,
|
|
298
298
|
i,
|
|
299
299
|
o,
|
|
300
|
-
|
|
301
|
-
|
|
300
|
+
r,
|
|
301
|
+
n + 1,
|
|
302
302
|
F
|
|
303
303
|
)), s.push({
|
|
304
304
|
rowKey: F,
|
|
305
305
|
rowLabel: u || "(blank)",
|
|
306
|
-
depth:
|
|
306
|
+
depth: n,
|
|
307
307
|
values: y,
|
|
308
308
|
total: E,
|
|
309
309
|
isGroup: c,
|
|
@@ -314,13 +314,13 @@ function L(t, e, i, o, n, r, a) {
|
|
|
314
314
|
return s;
|
|
315
315
|
}
|
|
316
316
|
function _(t, e, i, o) {
|
|
317
|
-
const
|
|
318
|
-
for (const
|
|
317
|
+
const r = {};
|
|
318
|
+
for (const n of i)
|
|
319
319
|
for (const a of o) {
|
|
320
|
-
const l = (e.length > 0 ? t.filter((u) => e.map((g) => String(u[g] ?? "")).join("|") ===
|
|
321
|
-
|
|
320
|
+
const l = (e.length > 0 ? t.filter((u) => e.map((g) => String(u[g] ?? "")).join("|") === n) : t).map((u) => Number(u[a.field]) || 0), d = K(a.aggFunc), c = l.length > 0 ? d(l) : null, p = C([n], a.field);
|
|
321
|
+
r[p] = c;
|
|
322
322
|
}
|
|
323
|
-
return
|
|
323
|
+
return r;
|
|
324
324
|
}
|
|
325
325
|
function G(t) {
|
|
326
326
|
let e = 0;
|
|
@@ -330,37 +330,37 @@ function G(t) {
|
|
|
330
330
|
}
|
|
331
331
|
function H(t, e, i) {
|
|
332
332
|
const o = {};
|
|
333
|
-
function n
|
|
334
|
-
for (const a of
|
|
333
|
+
function r(n) {
|
|
334
|
+
for (const a of n)
|
|
335
335
|
if (!a.isGroup || !a.children?.length)
|
|
336
336
|
for (const s of e)
|
|
337
337
|
for (const l of i) {
|
|
338
338
|
const d = C([s], l.field);
|
|
339
339
|
o[d] = (o[d] ?? 0) + (a.values[d] ?? 0);
|
|
340
340
|
}
|
|
341
|
-
else a.children &&
|
|
341
|
+
else a.children && r(a.children);
|
|
342
342
|
}
|
|
343
|
-
return
|
|
343
|
+
return r(t), o;
|
|
344
344
|
}
|
|
345
345
|
function D(t, e, i = !0) {
|
|
346
346
|
const o = [];
|
|
347
|
-
function n
|
|
348
|
-
o.push(
|
|
349
|
-
const a = e ? e.has(
|
|
350
|
-
if (
|
|
351
|
-
for (const s of
|
|
352
|
-
|
|
353
|
-
}
|
|
354
|
-
for (const
|
|
355
|
-
n
|
|
347
|
+
function r(n) {
|
|
348
|
+
o.push(n);
|
|
349
|
+
const a = e ? e.has(n.rowKey) : i;
|
|
350
|
+
if (n.children && a)
|
|
351
|
+
for (const s of n.children)
|
|
352
|
+
r(s);
|
|
353
|
+
}
|
|
354
|
+
for (const n of t)
|
|
355
|
+
r(n);
|
|
356
356
|
return o;
|
|
357
357
|
}
|
|
358
358
|
function w(t) {
|
|
359
359
|
const e = [];
|
|
360
360
|
function i(o) {
|
|
361
361
|
if (o.isGroup && e.push(o.rowKey), o.children)
|
|
362
|
-
for (const
|
|
363
|
-
i(
|
|
362
|
+
for (const r of o.children)
|
|
363
|
+
i(r);
|
|
364
364
|
}
|
|
365
365
|
for (const o of t)
|
|
366
366
|
i(o);
|
|
@@ -368,9 +368,9 @@ function w(t) {
|
|
|
368
368
|
}
|
|
369
369
|
const z = ["sum", "avg", "count", "min", "max", "first", "last"];
|
|
370
370
|
function q(t, e, i, o) {
|
|
371
|
-
const
|
|
372
|
-
return a.className = "tbw-pivot-panel", a.appendChild(f("Options", () => U(i,
|
|
373
|
-
|
|
371
|
+
const r = new AbortController(), n = { config: e, callbacks: o, signal: r.signal }, a = document.createElement("div");
|
|
372
|
+
return a.className = "tbw-pivot-panel", a.appendChild(f("Options", () => U(i, n))), a.appendChild(f("Row Groups", () => T("rowGroups", n))), a.appendChild(f("Column Groups", () => T("columnGroups", n))), a.appendChild(f("Values", () => Z(n))), a.appendChild(f("Available Fields", () => j(n))), t.appendChild(a), () => {
|
|
373
|
+
r.abort(), a.remove();
|
|
374
374
|
};
|
|
375
375
|
}
|
|
376
376
|
function f(t, e) {
|
|
@@ -378,44 +378,44 @@ function f(t, e) {
|
|
|
378
378
|
i.className = "tbw-pivot-section";
|
|
379
379
|
const o = document.createElement("div");
|
|
380
380
|
o.className = "tbw-pivot-section-header", o.textContent = t;
|
|
381
|
-
const
|
|
382
|
-
return
|
|
381
|
+
const r = document.createElement("div");
|
|
382
|
+
return r.className = "tbw-pivot-section-content", r.appendChild(e()), i.appendChild(o), i.appendChild(r), i;
|
|
383
383
|
}
|
|
384
384
|
function T(t, e) {
|
|
385
|
-
const { config: i, callbacks: o, signal:
|
|
386
|
-
|
|
385
|
+
const { config: i, callbacks: o, signal: r } = e, n = document.createElement("div");
|
|
386
|
+
n.className = "tbw-pivot-drop-zone", n.setAttribute("data-zone", t);
|
|
387
387
|
const a = t === "rowGroups" ? i.rowGroupFields ?? [] : i.columnGroupFields ?? [];
|
|
388
388
|
if (a.length === 0) {
|
|
389
389
|
const s = document.createElement("div");
|
|
390
|
-
s.className = "tbw-pivot-placeholder", s.textContent = "Drag fields here or click to add",
|
|
390
|
+
s.className = "tbw-pivot-placeholder", s.textContent = "Drag fields here or click to add", n.appendChild(s);
|
|
391
391
|
} else
|
|
392
392
|
for (const s of a)
|
|
393
|
-
|
|
394
|
-
return
|
|
393
|
+
n.appendChild(O(s, t, e));
|
|
394
|
+
return n.addEventListener(
|
|
395
395
|
"dragover",
|
|
396
396
|
(s) => {
|
|
397
|
-
s.preventDefault(),
|
|
397
|
+
s.preventDefault(), n.classList.add("drag-over");
|
|
398
398
|
},
|
|
399
|
-
{ signal:
|
|
400
|
-
),
|
|
399
|
+
{ signal: r }
|
|
400
|
+
), n.addEventListener(
|
|
401
401
|
"dragleave",
|
|
402
402
|
() => {
|
|
403
|
-
|
|
403
|
+
n.classList.remove("drag-over");
|
|
404
404
|
},
|
|
405
|
-
{ signal:
|
|
406
|
-
),
|
|
405
|
+
{ signal: r }
|
|
406
|
+
), n.addEventListener(
|
|
407
407
|
"drop",
|
|
408
408
|
(s) => {
|
|
409
|
-
s.preventDefault(),
|
|
409
|
+
s.preventDefault(), n.classList.remove("drag-over");
|
|
410
410
|
const l = s.dataTransfer?.getData("text/plain");
|
|
411
411
|
l && o.onAddFieldToZone(l, t);
|
|
412
412
|
},
|
|
413
|
-
{ signal:
|
|
414
|
-
),
|
|
413
|
+
{ signal: r }
|
|
414
|
+
), n;
|
|
415
415
|
}
|
|
416
416
|
function O(t, e, i) {
|
|
417
|
-
const { callbacks: o, signal:
|
|
418
|
-
|
|
417
|
+
const { callbacks: o, signal: r } = i, n = document.createElement("div");
|
|
418
|
+
n.className = "tbw-pivot-field-chip", n.draggable = !0;
|
|
419
419
|
const a = o.getAvailableFields().find((d) => d.field === t), s = document.createElement("span");
|
|
420
420
|
s.className = "tbw-pivot-chip-label", s.textContent = a?.header ?? t;
|
|
421
421
|
const l = document.createElement("button");
|
|
@@ -424,60 +424,60 @@ function O(t, e, i) {
|
|
|
424
424
|
(d) => {
|
|
425
425
|
d.stopPropagation(), o.onRemoveFieldFromZone(t, e);
|
|
426
426
|
},
|
|
427
|
-
{ signal:
|
|
428
|
-
),
|
|
427
|
+
{ signal: r }
|
|
428
|
+
), n.appendChild(s), n.appendChild(l), n.addEventListener(
|
|
429
429
|
"dragstart",
|
|
430
430
|
(d) => {
|
|
431
|
-
d.dataTransfer?.setData("text/plain", t), d.dataTransfer?.setData("source-zone", e),
|
|
431
|
+
d.dataTransfer?.setData("text/plain", t), d.dataTransfer?.setData("source-zone", e), n.classList.add("dragging");
|
|
432
432
|
},
|
|
433
|
-
{ signal:
|
|
434
|
-
),
|
|
433
|
+
{ signal: r }
|
|
434
|
+
), n.addEventListener(
|
|
435
435
|
"dragend",
|
|
436
436
|
() => {
|
|
437
|
-
|
|
437
|
+
n.classList.remove("dragging");
|
|
438
438
|
},
|
|
439
|
-
{ signal:
|
|
440
|
-
),
|
|
439
|
+
{ signal: r }
|
|
440
|
+
), n;
|
|
441
441
|
}
|
|
442
442
|
function Z(t) {
|
|
443
|
-
const { config: e, callbacks: i, signal: o } = t,
|
|
444
|
-
|
|
445
|
-
const
|
|
446
|
-
if (
|
|
443
|
+
const { config: e, callbacks: i, signal: o } = t, r = document.createElement("div");
|
|
444
|
+
r.className = "tbw-pivot-drop-zone tbw-pivot-values-zone", r.setAttribute("data-zone", "values");
|
|
445
|
+
const n = e.valueFields ?? [];
|
|
446
|
+
if (n.length === 0) {
|
|
447
447
|
const a = document.createElement("div");
|
|
448
|
-
a.className = "tbw-pivot-placeholder", a.textContent = "Drag numeric fields here for aggregation",
|
|
448
|
+
a.className = "tbw-pivot-placeholder", a.textContent = "Drag numeric fields here for aggregation", r.appendChild(a);
|
|
449
449
|
} else
|
|
450
|
-
for (const a of
|
|
451
|
-
|
|
452
|
-
return
|
|
450
|
+
for (const a of n)
|
|
451
|
+
r.appendChild($(a, t));
|
|
452
|
+
return r.addEventListener(
|
|
453
453
|
"dragover",
|
|
454
454
|
(a) => {
|
|
455
|
-
a.preventDefault(),
|
|
455
|
+
a.preventDefault(), r.classList.add("drag-over");
|
|
456
456
|
},
|
|
457
457
|
{ signal: o }
|
|
458
|
-
),
|
|
458
|
+
), r.addEventListener(
|
|
459
459
|
"dragleave",
|
|
460
460
|
() => {
|
|
461
|
-
|
|
461
|
+
r.classList.remove("drag-over");
|
|
462
462
|
},
|
|
463
463
|
{ signal: o }
|
|
464
|
-
),
|
|
464
|
+
), r.addEventListener(
|
|
465
465
|
"drop",
|
|
466
466
|
(a) => {
|
|
467
|
-
a.preventDefault(),
|
|
467
|
+
a.preventDefault(), r.classList.remove("drag-over");
|
|
468
468
|
const s = a.dataTransfer?.getData("text/plain");
|
|
469
469
|
s && i.onAddValueField(s, "sum");
|
|
470
470
|
},
|
|
471
471
|
{ signal: o }
|
|
472
|
-
),
|
|
472
|
+
), r;
|
|
473
473
|
}
|
|
474
474
|
function $(t, e) {
|
|
475
|
-
const { callbacks: i, signal: o } = e,
|
|
476
|
-
|
|
477
|
-
const
|
|
475
|
+
const { callbacks: i, signal: o } = e, r = document.createElement("div");
|
|
476
|
+
r.className = "tbw-pivot-field-chip tbw-pivot-value-chip";
|
|
477
|
+
const n = i.getAvailableFields().find((c) => c.field === t.field), a = document.createElement("div");
|
|
478
478
|
a.className = "tbw-pivot-value-label-wrapper";
|
|
479
479
|
const s = document.createElement("span");
|
|
480
|
-
s.className = "tbw-pivot-chip-label", s.textContent =
|
|
480
|
+
s.className = "tbw-pivot-chip-label", s.textContent = n?.header ?? t.field;
|
|
481
481
|
const l = document.createElement("select");
|
|
482
482
|
l.className = "tbw-pivot-agg-select", l.title = "Aggregation function";
|
|
483
483
|
for (const c of z) {
|
|
@@ -498,19 +498,19 @@ function $(t, e) {
|
|
|
498
498
|
c.stopPropagation(), i.onRemoveValueField(t.field);
|
|
499
499
|
},
|
|
500
500
|
{ signal: o }
|
|
501
|
-
), a.appendChild(s), a.appendChild(l),
|
|
501
|
+
), a.appendChild(s), a.appendChild(l), r.appendChild(a), r.appendChild(d), r;
|
|
502
502
|
}
|
|
503
503
|
function j(t) {
|
|
504
|
-
const { config: e, callbacks: i, signal: o } = t,
|
|
505
|
-
|
|
506
|
-
const
|
|
504
|
+
const { config: e, callbacks: i, signal: o } = t, r = document.createElement("div");
|
|
505
|
+
r.className = "tbw-pivot-available-fields";
|
|
506
|
+
const n = i.getAvailableFields(), a = /* @__PURE__ */ new Set([
|
|
507
507
|
...e.rowGroupFields ?? [],
|
|
508
508
|
...e.columnGroupFields ?? [],
|
|
509
509
|
...e.valueFields?.map((l) => l.field) ?? []
|
|
510
|
-
]), s =
|
|
510
|
+
]), s = n.filter((l) => !a.has(l.field));
|
|
511
511
|
if (s.length === 0) {
|
|
512
512
|
const l = document.createElement("div");
|
|
513
|
-
l.className = "tbw-pivot-placeholder", l.textContent = "All fields are in use",
|
|
513
|
+
l.className = "tbw-pivot-placeholder", l.textContent = "All fields are in use", r.appendChild(l);
|
|
514
514
|
} else
|
|
515
515
|
for (const l of s) {
|
|
516
516
|
const d = document.createElement("div");
|
|
@@ -526,96 +526,96 @@ function j(t) {
|
|
|
526
526
|
d.classList.remove("dragging");
|
|
527
527
|
},
|
|
528
528
|
{ signal: o }
|
|
529
|
-
),
|
|
529
|
+
), r.appendChild(d);
|
|
530
530
|
}
|
|
531
|
-
return
|
|
531
|
+
return r;
|
|
532
532
|
}
|
|
533
533
|
function U(t, e) {
|
|
534
|
-
const { config: i, callbacks: o, signal:
|
|
535
|
-
return
|
|
534
|
+
const { config: i, callbacks: o, signal: r } = e, n = document.createElement("div");
|
|
535
|
+
return n.className = "tbw-pivot-options", n.appendChild(
|
|
536
536
|
x(
|
|
537
537
|
"Enable Pivot View",
|
|
538
538
|
t,
|
|
539
539
|
(a) => {
|
|
540
540
|
o.onTogglePivot(a);
|
|
541
541
|
},
|
|
542
|
-
|
|
542
|
+
r
|
|
543
543
|
)
|
|
544
|
-
),
|
|
544
|
+
), n.appendChild(
|
|
545
545
|
x(
|
|
546
546
|
"Show Row Totals",
|
|
547
547
|
i.showTotals ?? !0,
|
|
548
548
|
(a) => {
|
|
549
549
|
o.onOptionChange("showTotals", a);
|
|
550
550
|
},
|
|
551
|
-
|
|
551
|
+
r
|
|
552
552
|
)
|
|
553
|
-
),
|
|
553
|
+
), n.appendChild(
|
|
554
554
|
x(
|
|
555
555
|
"Show Grand Total",
|
|
556
556
|
i.showGrandTotal ?? !0,
|
|
557
557
|
(a) => {
|
|
558
558
|
o.onOptionChange("showGrandTotal", a);
|
|
559
559
|
},
|
|
560
|
-
|
|
560
|
+
r
|
|
561
561
|
)
|
|
562
|
-
),
|
|
562
|
+
), n;
|
|
563
563
|
}
|
|
564
564
|
function x(t, e, i, o) {
|
|
565
|
-
const
|
|
566
|
-
|
|
567
|
-
const
|
|
568
|
-
|
|
565
|
+
const r = document.createElement("label");
|
|
566
|
+
r.className = "tbw-pivot-checkbox";
|
|
567
|
+
const n = document.createElement("input");
|
|
568
|
+
n.type = "checkbox", n.checked = e, n.addEventListener("change", () => i(n.checked), { signal: o });
|
|
569
569
|
const a = document.createElement("span");
|
|
570
|
-
return a.textContent = t,
|
|
570
|
+
return a.textContent = t, r.appendChild(n), r.appendChild(a), r;
|
|
571
571
|
}
|
|
572
572
|
function B(t, e, i) {
|
|
573
|
-
return e.className = "pivot-group-row", e.setAttribute("data-pivot-depth", String(t.__pivotDepth ?? 0)), e.setAttribute("role", "row"), e.
|
|
574
|
-
const
|
|
575
|
-
if (
|
|
573
|
+
return e.className = "pivot-group-row", e.setAttribute("data-pivot-depth", String(t.__pivotDepth ?? 0)), e.setAttribute("role", "row"), e.innerHTML = "", i.columns.forEach((o, r) => {
|
|
574
|
+
const n = document.createElement("div");
|
|
575
|
+
if (n.className = "cell", n.setAttribute("data-col", String(r)), n.setAttribute("role", "gridcell"), r === 0) {
|
|
576
576
|
const a = Number(t.__pivotIndent) || 0;
|
|
577
|
-
|
|
577
|
+
n.style.paddingLeft = `${a}px`;
|
|
578
578
|
const s = String(t.__pivotRowKey), l = document.createElement("button");
|
|
579
579
|
l.type = "button", l.className = "pivot-toggle", l.setAttribute("aria-label", t.__pivotExpanded ? "Collapse group" : "Expand group"), i.setIcon(l, i.resolveIcon(t.__pivotExpanded ? "collapse" : "expand")), l.addEventListener("click", (p) => {
|
|
580
580
|
p.stopPropagation(), i.onToggle(s);
|
|
581
|
-
}),
|
|
581
|
+
}), n.appendChild(l);
|
|
582
582
|
const d = document.createElement("span");
|
|
583
|
-
d.className = "pivot-label", d.textContent = String(t.__pivotLabel ?? ""),
|
|
583
|
+
d.className = "pivot-label", d.textContent = String(t.__pivotLabel ?? ""), n.appendChild(d);
|
|
584
584
|
const c = document.createElement("span");
|
|
585
|
-
c.className = "pivot-count", c.textContent = ` (${Number(t.__pivotRowCount) || 0})`,
|
|
585
|
+
c.className = "pivot-count", c.textContent = ` (${Number(t.__pivotRowCount) || 0})`, n.appendChild(c);
|
|
586
586
|
} else {
|
|
587
587
|
const a = t[o.field];
|
|
588
|
-
|
|
588
|
+
n.textContent = a != null ? String(a) : "";
|
|
589
589
|
}
|
|
590
|
-
e.appendChild(
|
|
590
|
+
e.appendChild(n);
|
|
591
591
|
}), !0;
|
|
592
592
|
}
|
|
593
593
|
function W(t, e, i) {
|
|
594
|
-
return e.className = "pivot-leaf-row", e.setAttribute("data-pivot-depth", String(t.__pivotDepth ?? 0)), e.innerHTML = "", i.forEach((o,
|
|
595
|
-
const
|
|
596
|
-
if (
|
|
594
|
+
return e.className = "pivot-leaf-row", e.setAttribute("data-pivot-depth", String(t.__pivotDepth ?? 0)), e.innerHTML = "", i.forEach((o, r) => {
|
|
595
|
+
const n = document.createElement("div");
|
|
596
|
+
if (n.className = "cell", n.setAttribute("data-col", String(r)), n.setAttribute("role", "gridcell"), r === 0) {
|
|
597
597
|
const a = Number(t.__pivotIndent) || 0;
|
|
598
|
-
|
|
598
|
+
n.style.paddingLeft = `${a + 20}px`;
|
|
599
599
|
const s = document.createElement("span");
|
|
600
|
-
s.className = "pivot-label", s.textContent = String(t.__pivotLabel ?? ""),
|
|
600
|
+
s.className = "pivot-label", s.textContent = String(t.__pivotLabel ?? ""), n.appendChild(s);
|
|
601
601
|
} else {
|
|
602
602
|
const a = t[o.field];
|
|
603
|
-
|
|
603
|
+
n.textContent = a != null ? String(a) : "";
|
|
604
604
|
}
|
|
605
|
-
e.appendChild(
|
|
605
|
+
e.appendChild(n);
|
|
606
606
|
}), !0;
|
|
607
607
|
}
|
|
608
608
|
function J(t, e, i) {
|
|
609
|
-
return e.className = "pivot-grand-total-row", e.setAttribute("role", "
|
|
610
|
-
const
|
|
611
|
-
if (
|
|
609
|
+
return e.className = "pivot-grand-total-row", e.setAttribute("role", "presentation"), e.innerHTML = "", i.forEach((o, r) => {
|
|
610
|
+
const n = document.createElement("div");
|
|
611
|
+
if (n.className = "cell", n.setAttribute("data-col", String(r)), r === 0) {
|
|
612
612
|
const a = document.createElement("span");
|
|
613
|
-
a.className = "pivot-label", a.textContent = "Grand Total",
|
|
613
|
+
a.className = "pivot-label", a.textContent = "Grand Total", n.appendChild(a);
|
|
614
614
|
} else {
|
|
615
615
|
const a = t[o.field];
|
|
616
|
-
|
|
616
|
+
n.textContent = a != null ? String(a) : "";
|
|
617
617
|
}
|
|
618
|
-
e.appendChild(
|
|
618
|
+
e.appendChild(n);
|
|
619
619
|
}), !0;
|
|
620
620
|
}
|
|
621
621
|
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;font-size:10px;color:var(--tbw-pivot-toggle-color, var(--tbw-color-fg-muted));border-radius:var(--tbw-border-radius);transition:background .15s,color .15s}.pivot-toggle:hover{background:var(--tbw-pivot-toggle-hover-bg, var(--tbw-color-row-hover));color:var(--tbw-pivot-toggle-hover-color, var(--tbw-color-fg))}.pivot-toggle:focus{outline:var(--tbw-focus-outline);outline-offset:var(--tbw-focus-outline-offset)}.pivot-label{font-weight:inherit}.pivot-count{color:var(--tbw-pivot-count-color, var(--tbw-color-fg-muted));font-size:.9em;font-weight:400}.pivot-total-row{font-weight:700;border-top:2px solid var(--tbw-pivot-border, var(--tbw-color-border-strong))}[data-pivot-depth="1"]{--tbw-pivot-depth: 1}[data-pivot-depth="2"]{--tbw-pivot-depth: 2}[data-pivot-depth="3"]{--tbw-pivot-depth: 3}[data-pivot-depth="4"]{--tbw-pivot-depth: 4}.tbw-pivot-panel{display:flex;flex-direction:column;gap:12px;padding:12px;height:100%;overflow-y:auto;font-size:13px}.tbw-pivot-section{border:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-section-bg, var(--tbw-color-bg))}.tbw-pivot-section-header{padding:8px 12px;font-weight:600;background:var(--tbw-pivot-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-pivot-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius) var(--tbw-border-radius) 0 0}.tbw-pivot-section-content{padding:8px}.tbw-pivot-toggle-wrapper{display:flex;align-items:center}.tbw-pivot-toggle-label{display:flex;align-items:center;gap:8px;cursor:pointer}.tbw-pivot-toggle-label input{width:16px;height:16px;cursor:pointer}.tbw-pivot-drop-zone{min-height:60px;padding:8px;border:2px dashed var(--tbw-pivot-drop-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);background:var(--tbw-pivot-drop-bg, var(--tbw-color-row-alt));display:flex;flex-wrap:wrap;gap:6px;align-content:flex-start;transition:all .15s ease}.tbw-pivot-drop-zone.drag-over{border-color:var(--tbw-color-accent);background:var(--tbw-pivot-drop-active, var(--tbw-focus-background))}.tbw-pivot-placeholder{color:var(--tbw-color-fg-muted);font-style:italic;padding:8px;text-align:center;width:100%}.tbw-pivot-field-chip{display:inline-flex;align-items:center;gap:6px;padding:4px 8px;background:var(--tbw-pivot-chip-bg, var(--tbw-color-header-bg));border:1px solid var(--tbw-pivot-chip-border, var(--tbw-color-border));border-radius:var(--tbw-border-radius);cursor:grab;font-size:12px;transition:all .15s ease}.tbw-pivot-field-chip:hover{background:var(--tbw-pivot-chip-hover, var(--tbw-color-row-hover));border-color:var(--tbw-color-accent)}.tbw-pivot-field-chip.available{background:var(--tbw-color-bg)}.tbw-pivot-field-chip.dragging{opacity:.5;cursor:grabbing}.tbw-pivot-chip-label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:120px}.tbw-pivot-chip-remove{display:flex;align-items:center;justify-content:center;width:16px;height:16px;padding:0;border:none;background:transparent;color:var(--tbw-color-fg-muted);font-size:14px;font-weight:700;cursor:pointer;border-radius:50%;transition:all .15s ease}.tbw-pivot-chip-remove:hover{background:var(--tbw-pivot-chip-remove-hover-bg, var(--tbw-color-accent));color:var(--tbw-pivot-chip-remove-hover-fg, var(--tbw-color-accent-fg))}.tbw-pivot-value-chip{padding:4px 8px}.tbw-pivot-value-label-wrapper{display:flex;align-items:center;gap:8px;flex:1;min-width:0}.tbw-pivot-agg-select{padding:2px 4px;font-size:11px;border:1px solid var(--tbw-color-border);border-radius:var(--tbw-border-radius);background:var(--tbw-color-bg);cursor:pointer}.tbw-pivot-available-fields{display:flex;flex-wrap:wrap;gap:6px;min-height:40px}.tbw-pivot-options{display:flex;flex-direction:column;gap:8px}.tbw-pivot-checkbox{display:flex;align-items:center;gap:8px;cursor:pointer}.tbw-pivot-checkbox input{width:14px;height:14px;cursor:pointer}';
|
|
@@ -670,13 +670,13 @@ class b extends N {
|
|
|
670
670
|
if (i.length > 0)
|
|
671
671
|
return this.warn(`Config errors: ${i.join(", ")}`), [...e];
|
|
672
672
|
if (this.buildFieldHeaderMap(), this.defaultExpanded = this.config.defaultExpanded ?? !0, this.expandedKeys.size === 0 && this.defaultExpanded && this.pivotResult) {
|
|
673
|
-
const
|
|
674
|
-
for (const a of
|
|
673
|
+
const n = w(this.pivotResult.rows);
|
|
674
|
+
for (const a of n)
|
|
675
675
|
this.expandedKeys.add(a);
|
|
676
676
|
}
|
|
677
677
|
if (this.pivotResult = S(e, this.config), this.expandedKeys.size === 0 && this.defaultExpanded) {
|
|
678
|
-
const
|
|
679
|
-
for (const a of
|
|
678
|
+
const n = w(this.pivotResult.rows);
|
|
679
|
+
for (const a of n)
|
|
680
680
|
this.expandedKeys.add(a);
|
|
681
681
|
}
|
|
682
682
|
const o = this.config.indentWidth ?? 20;
|
|
@@ -684,34 +684,34 @@ class b extends N {
|
|
|
684
684
|
this.pivotResult.rows,
|
|
685
685
|
this.expandedKeys,
|
|
686
686
|
this.defaultExpanded
|
|
687
|
-
).map((
|
|
688
|
-
__pivotRowKey:
|
|
689
|
-
__pivotLabel:
|
|
690
|
-
__pivotDepth:
|
|
691
|
-
__pivotIsGroup:
|
|
692
|
-
__pivotHasChildren: !!
|
|
693
|
-
__pivotExpanded: this.expandedKeys.has(
|
|
694
|
-
__pivotRowCount:
|
|
695
|
-
__pivotIndent:
|
|
696
|
-
__pivotTotal:
|
|
697
|
-
...
|
|
687
|
+
).map((n) => ({
|
|
688
|
+
__pivotRowKey: n.rowKey,
|
|
689
|
+
__pivotLabel: n.rowLabel,
|
|
690
|
+
__pivotDepth: n.depth,
|
|
691
|
+
__pivotIsGroup: n.isGroup,
|
|
692
|
+
__pivotHasChildren: !!n.children?.length,
|
|
693
|
+
__pivotExpanded: this.expandedKeys.has(n.rowKey),
|
|
694
|
+
__pivotRowCount: n.rowCount ?? 0,
|
|
695
|
+
__pivotIndent: n.depth * o,
|
|
696
|
+
__pivotTotal: n.total,
|
|
697
|
+
...n.values
|
|
698
698
|
}));
|
|
699
699
|
}
|
|
700
700
|
processColumns(e) {
|
|
701
701
|
if (!this.isActive || !this.pivotResult)
|
|
702
702
|
return [...e];
|
|
703
|
-
const i = [], o = (this.config.rowGroupFields ?? []).map((
|
|
703
|
+
const i = [], o = (this.config.rowGroupFields ?? []).map((r) => this.fieldHeaderMap.get(r) ?? r).join(" / ");
|
|
704
704
|
i.push({
|
|
705
705
|
field: "__pivotLabel",
|
|
706
706
|
header: o || "Group",
|
|
707
707
|
width: 200
|
|
708
708
|
});
|
|
709
|
-
for (const
|
|
710
|
-
for (const
|
|
711
|
-
const a = C([
|
|
709
|
+
for (const r of this.pivotResult.columnKeys)
|
|
710
|
+
for (const n of this.config.valueFields ?? []) {
|
|
711
|
+
const a = C([r], n.field), s = n.header || this.fieldHeaderMap.get(n.field) || n.field;
|
|
712
712
|
i.push({
|
|
713
713
|
field: a,
|
|
714
|
-
header: `${
|
|
714
|
+
header: `${r} - ${s} (${n.aggFunc})`,
|
|
715
715
|
width: 120,
|
|
716
716
|
type: "number"
|
|
717
717
|
});
|
|
@@ -727,9 +727,9 @@ class b extends N {
|
|
|
727
727
|
const o = e;
|
|
728
728
|
return o.__pivotRowKey && o.__pivotHasChildren ? B(o, i, {
|
|
729
729
|
columns: this.gridColumns,
|
|
730
|
-
onToggle: (
|
|
731
|
-
resolveIcon: (
|
|
732
|
-
setIcon: (
|
|
730
|
+
onToggle: (r) => this.toggle(r),
|
|
731
|
+
resolveIcon: (r) => this.resolveIcon(r),
|
|
732
|
+
setIcon: (r, n) => this.setIcon(r, n)
|
|
733
733
|
}) : o.__pivotRowKey !== void 0 && this.isActive ? W(o, i, this.gridColumns) : (this.cleanupPivotStyling(i), !1);
|
|
734
734
|
}
|
|
735
735
|
/**
|
|
@@ -861,13 +861,13 @@ class b extends N {
|
|
|
861
861
|
onTogglePivot: (o) => {
|
|
862
862
|
o ? this.enablePivot() : this.disablePivot(), this.refreshPanel();
|
|
863
863
|
},
|
|
864
|
-
onAddFieldToZone: (o,
|
|
865
|
-
onRemoveFieldFromZone: (o,
|
|
866
|
-
onAddValueField: (o,
|
|
864
|
+
onAddFieldToZone: (o, r) => this.addFieldToZone(o, r),
|
|
865
|
+
onRemoveFieldFromZone: (o, r) => this.removeFieldFromZone(o, r),
|
|
866
|
+
onAddValueField: (o, r) => this.addValueField(o, r),
|
|
867
867
|
onRemoveValueField: (o) => this.removeValueField(o),
|
|
868
|
-
onUpdateValueAggFunc: (o,
|
|
869
|
-
onOptionChange: (o,
|
|
870
|
-
this.config[o] =
|
|
868
|
+
onUpdateValueAggFunc: (o, r) => this.updateValueAggFunc(o, r),
|
|
869
|
+
onOptionChange: (o, r) => {
|
|
870
|
+
this.config[o] = r, this.isActive && this.refresh();
|
|
871
871
|
},
|
|
872
872
|
getAvailableFields: () => this.getAvailableFields()
|
|
873
873
|
};
|
|
@@ -894,14 +894,14 @@ class b extends N {
|
|
|
894
894
|
}
|
|
895
895
|
addValueField(e, i) {
|
|
896
896
|
const o = this.config.valueFields ?? [];
|
|
897
|
-
o.some((
|
|
897
|
+
o.some((r) => r.field === e) || (this.config.valueFields = [...o, { field: e, aggFunc: i }]), this.removeFromOtherZones(e, "values"), this.isActive && this.refresh(), this.refreshPanel();
|
|
898
898
|
}
|
|
899
899
|
removeValueField(e) {
|
|
900
900
|
this.config.valueFields = (this.config.valueFields ?? []).filter((i) => i.field !== e), this.isActive && this.refresh(), this.refreshPanel();
|
|
901
901
|
}
|
|
902
902
|
updateValueAggFunc(e, i) {
|
|
903
|
-
const o = this.config.valueFields ?? [],
|
|
904
|
-
|
|
903
|
+
const o = this.config.valueFields ?? [], r = o.findIndex((n) => n.field === e);
|
|
904
|
+
r >= 0 && (o[r] = { ...o[r], aggFunc: i }, this.config.valueFields = [...o]), this.isActive && this.refresh();
|
|
905
905
|
}
|
|
906
906
|
// ===== Styles =====
|
|
907
907
|
styles = Q;
|