@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.
Files changed (46) hide show
  1. package/README.md +1 -1
  2. package/all.d.ts +13 -0
  3. package/all.js +1684 -1196
  4. package/all.js.map +1 -1
  5. package/index.d.ts +4 -163
  6. package/index.js +1278 -1702
  7. package/index.js.map +1 -1
  8. package/lib/plugins/clipboard/index.js.map +1 -1
  9. package/lib/plugins/column-virtualization/index.js.map +1 -1
  10. package/lib/plugins/context-menu/index.js +35 -78
  11. package/lib/plugins/context-menu/index.js.map +1 -1
  12. package/lib/plugins/export/index.js.map +1 -1
  13. package/lib/plugins/filtering/index.js.map +1 -1
  14. package/lib/plugins/grouping-columns/index.js.map +1 -1
  15. package/lib/plugins/grouping-rows/index.js.map +1 -1
  16. package/lib/plugins/master-detail/index.js +1 -1
  17. package/lib/plugins/master-detail/index.js.map +1 -1
  18. package/lib/plugins/multi-sort/index.js.map +1 -1
  19. package/lib/plugins/pinned-columns/index.js.map +1 -1
  20. package/lib/plugins/pinned-rows/index.js +8 -8
  21. package/lib/plugins/pinned-rows/index.js.map +1 -1
  22. package/lib/plugins/pivot/index.js +160 -160
  23. package/lib/plugins/pivot/index.js.map +1 -1
  24. package/lib/plugins/reorder/index.js.map +1 -1
  25. package/lib/plugins/selection/index.js +93 -72
  26. package/lib/plugins/selection/index.js.map +1 -1
  27. package/lib/plugins/server-side/index.js.map +1 -1
  28. package/lib/plugins/tree/index.js.map +1 -1
  29. package/lib/plugins/undo-redo/index.js.map +1 -1
  30. package/lib/plugins/visibility/index.js.map +1 -1
  31. package/package.json +1 -1
  32. package/umd/grid.all.umd.js +27 -78
  33. package/umd/grid.all.umd.js.map +1 -1
  34. package/umd/grid.umd.js +28 -28
  35. package/umd/grid.umd.js.map +1 -1
  36. package/umd/plugins/context-menu.umd.js +1 -52
  37. package/umd/plugins/context-menu.umd.js.map +1 -1
  38. package/umd/plugins/master-detail.umd.js +1 -1
  39. package/umd/plugins/master-detail.umd.js.map +1 -1
  40. package/umd/plugins/pinned-rows.umd.js +1 -1
  41. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  42. package/umd/plugins/pivot.umd.js +1 -1
  43. package/umd/plugins/pivot.umd.js.map +1 -1
  44. package/umd/plugins/selection.umd.js +1 -1
  45. package/umd/plugins/selection.umd.js.map +1 -1
  46. 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, n) => o + (Number(n[e]) || 0), 0);
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 n = this.get(t);
202
- return n ? n(e, i, o) : void 0;
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 ?? [], n = e.valueFields ?? [], r = V(t, o), a = L(
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, r, n), l = Object.values(s).reduce((d, c) => d + c, 0);
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: r,
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 n = e.map((r) => String(o[r] ?? "")).join("|");
265
- i.add(n);
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 n = String(o[e] ?? ""), r = i.get(n);
273
- r ? r.push(o) : i.set(n, [o]);
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, n, r, a) {
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, n), g = G(u);
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: r,
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, n), E = G(y);
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
- n,
301
- r + 1,
300
+ r,
301
+ n + 1,
302
302
  F
303
303
  )), s.push({
304
304
  rowKey: F,
305
305
  rowLabel: u || "(blank)",
306
- depth: r,
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 n = {};
318
- for (const r of i)
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("|") === r) : t).map((u) => Number(u[a.field]) || 0), d = K(a.aggFunc), c = l.length > 0 ? d(l) : null, p = C([r], a.field);
321
- n[p] = c;
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 n;
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(r) {
334
- for (const a of r)
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 && n(a.children);
341
+ else a.children && r(a.children);
342
342
  }
343
- return n(t), o;
343
+ return r(t), o;
344
344
  }
345
345
  function D(t, e, i = !0) {
346
346
  const o = [];
347
- function n(r) {
348
- o.push(r);
349
- const a = e ? e.has(r.rowKey) : i;
350
- if (r.children && a)
351
- for (const s of r.children)
352
- n(s);
353
- }
354
- for (const r of t)
355
- n(r);
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 n of o.children)
363
- i(n);
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 n = new AbortController(), r = { config: e, callbacks: o, signal: n.signal }, a = document.createElement("div");
372
- return a.className = "tbw-pivot-panel", a.appendChild(f("Options", () => U(i, r))), a.appendChild(f("Row Groups", () => T("rowGroups", r))), a.appendChild(f("Column Groups", () => T("columnGroups", r))), a.appendChild(f("Values", () => Z(r))), a.appendChild(f("Available Fields", () => j(r))), t.appendChild(a), () => {
373
- n.abort(), a.remove();
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 n = document.createElement("div");
382
- return n.className = "tbw-pivot-section-content", n.appendChild(e()), i.appendChild(o), i.appendChild(n), i;
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: n } = e, r = document.createElement("div");
386
- r.className = "tbw-pivot-drop-zone", r.setAttribute("data-zone", t);
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", r.appendChild(s);
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
- r.appendChild(O(s, t, e));
394
- return r.addEventListener(
393
+ n.appendChild(O(s, t, e));
394
+ return n.addEventListener(
395
395
  "dragover",
396
396
  (s) => {
397
- s.preventDefault(), r.classList.add("drag-over");
397
+ s.preventDefault(), n.classList.add("drag-over");
398
398
  },
399
- { signal: n }
400
- ), r.addEventListener(
399
+ { signal: r }
400
+ ), n.addEventListener(
401
401
  "dragleave",
402
402
  () => {
403
- r.classList.remove("drag-over");
403
+ n.classList.remove("drag-over");
404
404
  },
405
- { signal: n }
406
- ), r.addEventListener(
405
+ { signal: r }
406
+ ), n.addEventListener(
407
407
  "drop",
408
408
  (s) => {
409
- s.preventDefault(), r.classList.remove("drag-over");
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: n }
414
- ), r;
413
+ { signal: r }
414
+ ), n;
415
415
  }
416
416
  function O(t, e, i) {
417
- const { callbacks: o, signal: n } = i, r = document.createElement("div");
418
- r.className = "tbw-pivot-field-chip", r.draggable = !0;
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: n }
428
- ), r.appendChild(s), r.appendChild(l), r.addEventListener(
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), r.classList.add("dragging");
431
+ d.dataTransfer?.setData("text/plain", t), d.dataTransfer?.setData("source-zone", e), n.classList.add("dragging");
432
432
  },
433
- { signal: n }
434
- ), r.addEventListener(
433
+ { signal: r }
434
+ ), n.addEventListener(
435
435
  "dragend",
436
436
  () => {
437
- r.classList.remove("dragging");
437
+ n.classList.remove("dragging");
438
438
  },
439
- { signal: n }
440
- ), r;
439
+ { signal: r }
440
+ ), n;
441
441
  }
442
442
  function Z(t) {
443
- const { config: e, callbacks: i, signal: o } = t, n = document.createElement("div");
444
- n.className = "tbw-pivot-drop-zone tbw-pivot-values-zone", n.setAttribute("data-zone", "values");
445
- const r = e.valueFields ?? [];
446
- if (r.length === 0) {
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", n.appendChild(a);
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 r)
451
- n.appendChild($(a, t));
452
- return n.addEventListener(
450
+ for (const a of n)
451
+ r.appendChild($(a, t));
452
+ return r.addEventListener(
453
453
  "dragover",
454
454
  (a) => {
455
- a.preventDefault(), n.classList.add("drag-over");
455
+ a.preventDefault(), r.classList.add("drag-over");
456
456
  },
457
457
  { signal: o }
458
- ), n.addEventListener(
458
+ ), r.addEventListener(
459
459
  "dragleave",
460
460
  () => {
461
- n.classList.remove("drag-over");
461
+ r.classList.remove("drag-over");
462
462
  },
463
463
  { signal: o }
464
- ), n.addEventListener(
464
+ ), r.addEventListener(
465
465
  "drop",
466
466
  (a) => {
467
- a.preventDefault(), n.classList.remove("drag-over");
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
- ), n;
472
+ ), r;
473
473
  }
474
474
  function $(t, e) {
475
- const { callbacks: i, signal: o } = e, n = document.createElement("div");
476
- n.className = "tbw-pivot-field-chip tbw-pivot-value-chip";
477
- const r = i.getAvailableFields().find((c) => c.field === t.field), a = document.createElement("div");
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 = r?.header ?? t.field;
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), n.appendChild(a), n.appendChild(d), n;
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, n = document.createElement("div");
505
- n.className = "tbw-pivot-available-fields";
506
- const r = i.getAvailableFields(), a = /* @__PURE__ */ new Set([
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 = r.filter((l) => !a.has(l.field));
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", n.appendChild(l);
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
- ), n.appendChild(d);
529
+ ), r.appendChild(d);
530
530
  }
531
- return n;
531
+ return r;
532
532
  }
533
533
  function U(t, e) {
534
- const { config: i, callbacks: o, signal: n } = e, r = document.createElement("div");
535
- return r.className = "tbw-pivot-options", r.appendChild(
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
- n
542
+ r
543
543
  )
544
- ), r.appendChild(
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
- n
551
+ r
552
552
  )
553
- ), r.appendChild(
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
- n
560
+ r
561
561
  )
562
- ), r;
562
+ ), n;
563
563
  }
564
564
  function x(t, e, i, o) {
565
- const n = document.createElement("label");
566
- n.className = "tbw-pivot-checkbox";
567
- const r = document.createElement("input");
568
- r.type = "checkbox", r.checked = e, r.addEventListener("change", () => i(r.checked), { signal: o });
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, n.appendChild(r), n.appendChild(a), n;
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.setAttribute("aria-expanded", String(t.__pivotExpanded)), e.innerHTML = "", i.columns.forEach((o, n) => {
574
- const r = document.createElement("div");
575
- if (r.className = "cell", r.setAttribute("data-col", String(n)), r.setAttribute("role", "gridcell"), n === 0) {
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
- r.style.paddingLeft = `${a}px`;
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
- }), r.appendChild(l);
581
+ }), n.appendChild(l);
582
582
  const d = document.createElement("span");
583
- d.className = "pivot-label", d.textContent = String(t.__pivotLabel ?? ""), r.appendChild(d);
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})`, r.appendChild(c);
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
- r.textContent = a != null ? String(a) : "";
588
+ n.textContent = a != null ? String(a) : "";
589
589
  }
590
- e.appendChild(r);
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, n) => {
595
- const r = document.createElement("div");
596
- if (r.className = "cell", r.setAttribute("data-col", String(n)), r.setAttribute("role", "gridcell"), n === 0) {
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
- r.style.paddingLeft = `${a + 20}px`;
598
+ n.style.paddingLeft = `${a + 20}px`;
599
599
  const s = document.createElement("span");
600
- s.className = "pivot-label", s.textContent = String(t.__pivotLabel ?? ""), r.appendChild(s);
600
+ s.className = "pivot-label", s.textContent = String(t.__pivotLabel ?? ""), n.appendChild(s);
601
601
  } else {
602
602
  const a = t[o.field];
603
- r.textContent = a != null ? String(a) : "";
603
+ n.textContent = a != null ? String(a) : "";
604
604
  }
605
- e.appendChild(r);
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", "row"), e.innerHTML = "", i.forEach((o, n) => {
610
- const r = document.createElement("div");
611
- if (r.className = "cell", r.setAttribute("data-col", String(n)), r.setAttribute("role", "gridcell"), n === 0) {
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", r.appendChild(a);
613
+ a.className = "pivot-label", a.textContent = "Grand Total", n.appendChild(a);
614
614
  } else {
615
615
  const a = t[o.field];
616
- r.textContent = a != null ? String(a) : "";
616
+ n.textContent = a != null ? String(a) : "";
617
617
  }
618
- e.appendChild(r);
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 r = w(this.pivotResult.rows);
674
- for (const a of r)
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 r = w(this.pivotResult.rows);
679
- for (const a of r)
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((r) => ({
688
- __pivotRowKey: r.rowKey,
689
- __pivotLabel: r.rowLabel,
690
- __pivotDepth: r.depth,
691
- __pivotIsGroup: r.isGroup,
692
- __pivotHasChildren: !!r.children?.length,
693
- __pivotExpanded: this.expandedKeys.has(r.rowKey),
694
- __pivotRowCount: r.rowCount ?? 0,
695
- __pivotIndent: r.depth * o,
696
- __pivotTotal: r.total,
697
- ...r.values
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((n) => this.fieldHeaderMap.get(n) ?? n).join(" / ");
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 n of this.pivotResult.columnKeys)
710
- for (const r of this.config.valueFields ?? []) {
711
- const a = C([n], r.field), s = r.header || this.fieldHeaderMap.get(r.field) || r.field;
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: `${n} - ${s} (${r.aggFunc})`,
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: (n) => this.toggle(n),
731
- resolveIcon: (n) => this.resolveIcon(n),
732
- setIcon: (n, r) => this.setIcon(n, r)
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, n) => this.addFieldToZone(o, n),
865
- onRemoveFieldFromZone: (o, n) => this.removeFieldFromZone(o, n),
866
- onAddValueField: (o, n) => this.addValueField(o, n),
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, n) => this.updateValueAggFunc(o, n),
869
- onOptionChange: (o, n) => {
870
- this.config[o] = n, this.isActive && this.refresh();
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((n) => n.field === e) || (this.config.valueFields = [...o, { field: e, aggFunc: i }]), this.removeFromOtherZones(e, "values"), this.isActive && this.refresh(), this.refreshPanel();
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 ?? [], n = o.findIndex((r) => r.field === e);
904
- n >= 0 && (o[n] = { ...o[n], aggFunc: i }, this.config.valueFields = [...o]), this.isActive && this.refresh();
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;