@toolbox-web/grid 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/all.d.ts +61 -23
  2. package/all.js +841 -809
  3. package/all.js.map +1 -1
  4. package/index.d.ts +17 -5
  5. package/index.js +316 -247
  6. package/index.js.map +1 -1
  7. package/lib/plugins/clipboard/index.js +1 -1
  8. package/lib/plugins/clipboard/index.js.map +1 -1
  9. package/lib/plugins/column-virtualization/index.js +1 -1
  10. package/lib/plugins/column-virtualization/index.js.map +1 -1
  11. package/lib/plugins/context-menu/index.js +1 -1
  12. package/lib/plugins/context-menu/index.js.map +1 -1
  13. package/lib/plugins/export/index.js +1 -1
  14. package/lib/plugins/export/index.js.map +1 -1
  15. package/lib/plugins/filtering/index.js +1 -1
  16. package/lib/plugins/filtering/index.js.map +1 -1
  17. package/lib/plugins/grouping-columns/index.js +46 -45
  18. package/lib/plugins/grouping-columns/index.js.map +1 -1
  19. package/lib/plugins/grouping-rows/index.js +1 -1
  20. package/lib/plugins/grouping-rows/index.js.map +1 -1
  21. package/lib/plugins/master-detail/index.js +1 -1
  22. package/lib/plugins/master-detail/index.js.map +1 -1
  23. package/lib/plugins/multi-sort/index.js +1 -1
  24. package/lib/plugins/multi-sort/index.js.map +1 -1
  25. package/lib/plugins/pinned-columns/index.js +1 -1
  26. package/lib/plugins/pinned-columns/index.js.map +1 -1
  27. package/lib/plugins/pinned-rows/index.js +55 -47
  28. package/lib/plugins/pinned-rows/index.js.map +1 -1
  29. package/lib/plugins/pivot/index.js +243 -241
  30. package/lib/plugins/pivot/index.js.map +1 -1
  31. package/lib/plugins/reorder/index.js +87 -67
  32. package/lib/plugins/reorder/index.js.map +1 -1
  33. package/lib/plugins/selection/index.js +28 -27
  34. package/lib/plugins/selection/index.js.map +1 -1
  35. package/lib/plugins/server-side/index.js +2 -2
  36. package/lib/plugins/server-side/index.js.map +1 -1
  37. package/lib/plugins/tree/index.js +70 -70
  38. package/lib/plugins/tree/index.js.map +1 -1
  39. package/lib/plugins/undo-redo/index.js +1 -1
  40. package/lib/plugins/undo-redo/index.js.map +1 -1
  41. package/lib/plugins/visibility/index.js +1 -1
  42. package/lib/plugins/visibility/index.js.map +1 -1
  43. package/package.json +1 -1
  44. package/themes/dg-theme-bootstrap.css +0 -2
  45. package/themes/dg-theme-contrast.css +0 -1
  46. package/themes/dg-theme-large.css +0 -1
  47. package/themes/dg-theme-material.css +0 -2
  48. package/themes/dg-theme-standard.css +0 -1
  49. package/themes/dg-theme-vibrant.css +0 -1
  50. package/umd/grid.all.umd.js +13 -13
  51. package/umd/grid.all.umd.js.map +1 -1
  52. package/umd/grid.umd.js +7 -7
  53. package/umd/grid.umd.js.map +1 -1
  54. package/umd/plugins/grouping-columns.umd.js +1 -1
  55. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  56. package/umd/plugins/pinned-rows.umd.js +1 -1
  57. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  58. package/umd/plugins/pivot.umd.js +1 -1
  59. package/umd/plugins/pivot.umd.js.map +1 -1
  60. package/umd/plugins/reorder.umd.js +1 -1
  61. package/umd/plugins/reorder.umd.js.map +1 -1
  62. package/umd/plugins/selection.umd.js +1 -1
  63. package/umd/plugins/selection.umd.js.map +1 -1
  64. package/umd/plugins/server-side.umd.js +1 -1
  65. package/umd/plugins/server-side.umd.js.map +1 -1
  66. package/umd/plugins/tree.umd.js +1 -1
  67. package/umd/plugins/tree.umd.js.map +1 -1
@@ -59,8 +59,8 @@ class N {
59
59
  /**
60
60
  * Emit a custom event from the grid.
61
61
  */
62
- emit(e, i) {
63
- this.grid?.dispatchEvent?.(new CustomEvent(e, { detail: i, bubbles: !0 }));
62
+ emit(e, o) {
63
+ this.grid?.dispatchEvent?.(new CustomEvent(e, { detail: o, bubbles: !0 }));
64
64
  }
65
65
  /**
66
66
  * Request a re-render of the grid.
@@ -99,7 +99,7 @@ class N {
99
99
  * Use this for rendering that needs to match the grid template.
100
100
  */
101
101
  get visibleColumns() {
102
- return this.grid?.visibleColumns ?? [];
102
+ return this.grid?._visibleColumns ?? [];
103
103
  }
104
104
  /**
105
105
  * Get the shadow root of the grid.
@@ -143,8 +143,8 @@ class N {
143
143
  * @param pluginOverride - Optional plugin-level override
144
144
  * @returns The resolved icon value
145
145
  */
146
- resolveIcon(e, i) {
147
- return i !== void 0 ? i : this.gridIcons[e];
146
+ resolveIcon(e, o) {
147
+ return o !== void 0 ? o : this.gridIcons[e];
148
148
  }
149
149
  /**
150
150
  * Set an icon value on an element.
@@ -153,8 +153,8 @@ class N {
153
153
  * @param element - The element to set the icon on
154
154
  * @param icon - The icon value (string or HTMLElement)
155
155
  */
156
- setIcon(e, i) {
157
- typeof i == "string" ? e.innerHTML = i : i instanceof HTMLElement && (e.innerHTML = "", e.appendChild(i.cloneNode(!0)));
156
+ setIcon(e, o) {
157
+ typeof o == "string" ? e.innerHTML = o : o instanceof HTMLElement && (e.innerHTML = "", e.appendChild(o.cloneNode(!0)));
158
158
  }
159
159
  /**
160
160
  * Log a warning message.
@@ -165,14 +165,14 @@ class N {
165
165
  // #endregion
166
166
  }
167
167
  const m = {
168
- sum: (t, e) => t.reduce((i, o) => i + (Number(o[e]) || 0), 0),
168
+ sum: (t, e) => t.reduce((o, i) => o + (Number(i[e]) || 0), 0),
169
169
  avg: (t, e) => {
170
- const i = t.reduce((o, r) => o + (Number(r[e]) || 0), 0);
171
- return t.length ? i / t.length : 0;
170
+ const o = t.reduce((i, r) => i + (Number(r[e]) || 0), 0);
171
+ return t.length ? o / t.length : 0;
172
172
  },
173
173
  count: (t) => t.length,
174
- min: (t, e) => Math.min(...t.map((i) => Number(i[e]) || 1 / 0)),
175
- max: (t, e) => Math.max(...t.map((i) => Number(i[e]) || -1 / 0)),
174
+ min: (t, e) => Math.min(...t.map((o) => Number(o[e]) || 1 / 0)),
175
+ max: (t, e) => Math.max(...t.map((o) => Number(o[e]) || -1 / 0)),
176
176
  first: (t, e) => t[0]?.[e],
177
177
  last: (t, e) => t[t.length - 1]?.[e]
178
178
  }, v = /* @__PURE__ */ new Map(), h = {
@@ -198,9 +198,9 @@ const m = {
198
198
  /**
199
199
  * Run an aggregator on a set of rows.
200
200
  */
201
- run(t, e, i, o) {
201
+ run(t, e, o, i) {
202
202
  const r = this.get(t);
203
- return r ? r(e, i, o) : void 0;
203
+ return r ? r(e, o, i) : void 0;
204
204
  },
205
205
  /**
206
206
  * Check if an aggregator exists.
@@ -215,8 +215,8 @@ const m = {
215
215
  return [...Object.keys(m), ...v.keys()];
216
216
  }
217
217
  }, A = {
218
- sum: (t) => t.reduce((e, i) => e + i, 0),
219
- avg: (t) => t.length ? t.reduce((e, i) => e + i, 0) / t.length : 0,
218
+ sum: (t) => t.reduce((e, o) => e + o, 0),
219
+ avg: (t) => t.length ? t.reduce((e, o) => e + o, 0) / t.length : 0,
220
220
  count: (t) => t.length,
221
221
  min: (t) => t.length ? Math.min(...t) : 0,
222
222
  max: (t) => t.length ? Math.max(...t) : 0,
@@ -240,68 +240,68 @@ function C(t, e) {
240
240
  return [...t, e].join("|");
241
241
  }
242
242
  function S(t, e) {
243
- const i = e.rowGroupFields ?? [], o = e.columnGroupFields ?? [], r = e.valueFields ?? [], n = V(t, o), a = L(
243
+ const o = e.rowGroupFields ?? [], i = e.columnGroupFields ?? [], r = e.valueFields ?? [], n = V(t, i), s = L(
244
244
  t,
245
- i,
246
245
  o,
246
+ i,
247
247
  n,
248
248
  r,
249
249
  0,
250
250
  // starting depth
251
251
  ""
252
252
  // parent key prefix
253
- ), s = H(a, n, r), l = Object.values(s).reduce((d, c) => d + c, 0);
253
+ ), a = H(s, n, r), l = Object.values(a).reduce((d, c) => d + c, 0);
254
254
  return {
255
- rows: a,
255
+ rows: s,
256
256
  columnKeys: n,
257
- totals: s,
257
+ totals: a,
258
258
  grandTotal: l
259
259
  };
260
260
  }
261
261
  function V(t, e) {
262
262
  if (e.length === 0) return ["value"];
263
- const i = /* @__PURE__ */ new Set();
264
- for (const o of t) {
265
- const r = e.map((n) => String(o[n] ?? "")).join("|");
266
- i.add(r);
263
+ const o = /* @__PURE__ */ new Set();
264
+ for (const i of t) {
265
+ const r = e.map((n) => String(i[n] ?? "")).join("|");
266
+ o.add(r);
267
267
  }
268
- return [...i].sort();
268
+ return [...o].sort();
269
269
  }
270
270
  function M(t, e) {
271
- const i = /* @__PURE__ */ new Map();
272
- for (const o of t) {
273
- const r = String(o[e] ?? ""), n = i.get(r);
274
- n ? n.push(o) : i.set(r, [o]);
271
+ const o = /* @__PURE__ */ new Map();
272
+ for (const i of t) {
273
+ const r = String(i[e] ?? ""), n = o.get(r);
274
+ n ? n.push(i) : o.set(r, [i]);
275
275
  }
276
- return i;
276
+ return o;
277
277
  }
278
- function L(t, e, i, o, r, n, a) {
279
- const s = [];
278
+ function L(t, e, o, i, r, n, s) {
279
+ const a = [];
280
280
  if (e.length === 0) {
281
- const u = _(t, i, o, r), g = G(u);
282
- return s.push({
283
- rowKey: a || "all",
284
- rowLabel: a || "All",
281
+ const u = T(t, o, i, r), g = _(u);
282
+ return a.push({
283
+ rowKey: s || "all",
284
+ rowLabel: s || "All",
285
285
  depth: n,
286
286
  values: u,
287
287
  total: g,
288
288
  isGroup: !1,
289
289
  rowCount: t.length
290
- }), s;
290
+ }), a;
291
291
  }
292
292
  const l = e[0], d = e.slice(1), c = d.length > 0, p = M(t, l);
293
293
  for (const [u, g] of p) {
294
- const F = a ? `${a}|${u}` : u, y = _(g, i, o, r), E = G(y);
294
+ const F = s ? `${s}|${u}` : u, y = T(g, o, i, r), E = _(y);
295
295
  let R;
296
296
  c && (R = L(
297
297
  g,
298
298
  d,
299
- i,
300
299
  o,
300
+ i,
301
301
  r,
302
302
  n + 1,
303
303
  F
304
- )), s.push({
304
+ )), a.push({
305
305
  rowKey: F,
306
306
  rowLabel: u || "(blank)",
307
307
  depth: n,
@@ -312,90 +312,90 @@ function L(t, e, i, o, r, n, a) {
312
312
  rowCount: g.length
313
313
  });
314
314
  }
315
- return s;
315
+ return a;
316
316
  }
317
- function _(t, e, i, o) {
317
+ function T(t, e, o, i) {
318
318
  const r = {};
319
- for (const n of i)
320
- for (const a of o) {
321
- 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);
319
+ for (const n of o)
320
+ for (const s of i) {
321
+ const l = (e.length > 0 ? t.filter((u) => e.map((g) => String(u[g] ?? "")).join("|") === n) : t).map((u) => Number(u[s.field]) || 0), d = K(s.aggFunc), c = l.length > 0 ? d(l) : null, p = C([n], s.field);
322
322
  r[p] = c;
323
323
  }
324
324
  return r;
325
325
  }
326
- function G(t) {
326
+ function _(t) {
327
327
  let e = 0;
328
- for (const i of Object.values(t))
329
- e += i ?? 0;
328
+ for (const o of Object.values(t))
329
+ e += o ?? 0;
330
330
  return e;
331
331
  }
332
- function H(t, e, i) {
333
- const o = {};
332
+ function H(t, e, o) {
333
+ const i = {};
334
334
  function r(n) {
335
- for (const a of n)
336
- if (!a.isGroup || !a.children?.length)
337
- for (const s of e)
338
- for (const l of i) {
339
- const d = C([s], l.field);
340
- o[d] = (o[d] ?? 0) + (a.values[d] ?? 0);
335
+ for (const s of n)
336
+ if (!s.isGroup || !s.children?.length)
337
+ for (const a of e)
338
+ for (const l of o) {
339
+ const d = C([a], l.field);
340
+ i[d] = (i[d] ?? 0) + (s.values[d] ?? 0);
341
341
  }
342
- else a.children && r(a.children);
342
+ else s.children && r(s.children);
343
343
  }
344
- return r(t), o;
344
+ return r(t), i;
345
345
  }
346
- function D(t, e, i = !0) {
347
- const o = [];
346
+ function D(t, e, o = !0) {
347
+ const i = [];
348
348
  function r(n) {
349
- o.push(n);
350
- const a = e ? e.has(n.rowKey) : i;
351
- if (n.children && a)
352
- for (const s of n.children)
353
- r(s);
349
+ i.push(n);
350
+ const s = e ? e.has(n.rowKey) : o;
351
+ if (n.children && s)
352
+ for (const a of n.children)
353
+ r(a);
354
354
  }
355
355
  for (const n of t)
356
356
  r(n);
357
- return o;
357
+ return i;
358
358
  }
359
359
  function w(t) {
360
360
  const e = [];
361
- function i(o) {
362
- if (o.isGroup && e.push(o.rowKey), o.children)
363
- for (const r of o.children)
364
- i(r);
361
+ function o(i) {
362
+ if (i.isGroup && e.push(i.rowKey), i.children)
363
+ for (const r of i.children)
364
+ o(r);
365
365
  }
366
- for (const o of t)
367
- i(o);
366
+ for (const i of t)
367
+ o(i);
368
368
  return e;
369
369
  }
370
370
  const z = ["sum", "avg", "count", "min", "max", "first", "last"];
371
- function q(t, e, i, o) {
372
- const r = new AbortController(), n = { config: e, callbacks: o, signal: r.signal }, a = document.createElement("div");
373
- 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), () => {
374
- r.abort(), a.remove();
371
+ function q(t, e, o, i) {
372
+ const r = new AbortController(), n = { config: e, callbacks: i, signal: r.signal }, s = document.createElement("div");
373
+ return s.className = "tbw-pivot-panel", s.appendChild(f("Options", () => U(o, n))), s.appendChild(f("Row Groups", () => G("rowGroups", n))), s.appendChild(f("Column Groups", () => G("columnGroups", n))), s.appendChild(f("Values", () => Z(n))), s.appendChild(f("Available Fields", () => j(n))), t.appendChild(s), () => {
374
+ r.abort(), s.remove();
375
375
  };
376
376
  }
377
377
  function f(t, e) {
378
- const i = document.createElement("div");
379
- i.className = "tbw-pivot-section";
380
378
  const o = document.createElement("div");
381
- o.className = "tbw-pivot-section-header", o.textContent = t;
379
+ o.className = "tbw-pivot-section";
380
+ const i = document.createElement("div");
381
+ i.className = "tbw-pivot-section-header", i.textContent = t;
382
382
  const r = document.createElement("div");
383
- return r.className = "tbw-pivot-section-content", r.appendChild(e()), i.appendChild(o), i.appendChild(r), i;
383
+ return r.className = "tbw-pivot-section-content", r.appendChild(e()), o.appendChild(i), o.appendChild(r), o;
384
384
  }
385
- function T(t, e) {
386
- const { config: i, callbacks: o, signal: r } = e, n = document.createElement("div");
385
+ function G(t, e) {
386
+ const { config: o, callbacks: i, signal: r } = e, n = document.createElement("div");
387
387
  n.className = "tbw-pivot-drop-zone", n.setAttribute("data-zone", t);
388
- const a = t === "rowGroups" ? i.rowGroupFields ?? [] : i.columnGroupFields ?? [];
389
- if (a.length === 0) {
390
- const s = document.createElement("div");
391
- s.className = "tbw-pivot-placeholder", s.textContent = "Drag fields here or click to add", n.appendChild(s);
388
+ const s = t === "rowGroups" ? o.rowGroupFields ?? [] : o.columnGroupFields ?? [];
389
+ if (s.length === 0) {
390
+ const a = document.createElement("div");
391
+ a.className = "tbw-pivot-placeholder", a.textContent = "Drag fields here or click to add", n.appendChild(a);
392
392
  } else
393
- for (const s of a)
394
- n.appendChild(O(s, t, e));
393
+ for (const a of s)
394
+ n.appendChild(O(a, t, e));
395
395
  return n.addEventListener(
396
396
  "dragover",
397
- (s) => {
398
- s.preventDefault(), n.classList.add("drag-over");
397
+ (a) => {
398
+ a.preventDefault(), n.classList.add("drag-over");
399
399
  },
400
400
  { signal: r }
401
401
  ), n.addEventListener(
@@ -406,27 +406,27 @@ function T(t, e) {
406
406
  { signal: r }
407
407
  ), n.addEventListener(
408
408
  "drop",
409
- (s) => {
410
- s.preventDefault(), n.classList.remove("drag-over");
411
- const l = s.dataTransfer?.getData("text/plain");
412
- l && o.onAddFieldToZone(l, t);
409
+ (a) => {
410
+ a.preventDefault(), n.classList.remove("drag-over");
411
+ const l = a.dataTransfer?.getData("text/plain");
412
+ l && i.onAddFieldToZone(l, t);
413
413
  },
414
414
  { signal: r }
415
415
  ), n;
416
416
  }
417
- function O(t, e, i) {
418
- const { callbacks: o, signal: r } = i, n = document.createElement("div");
417
+ function O(t, e, o) {
418
+ const { callbacks: i, signal: r } = o, n = document.createElement("div");
419
419
  n.className = "tbw-pivot-field-chip", n.draggable = !0;
420
- const a = o.getAvailableFields().find((d) => d.field === t), s = document.createElement("span");
421
- s.className = "tbw-pivot-chip-label", s.textContent = a?.header ?? t;
420
+ const s = i.getAvailableFields().find((d) => d.field === t), a = document.createElement("span");
421
+ a.className = "tbw-pivot-chip-label", a.textContent = s?.header ?? t;
422
422
  const l = document.createElement("button");
423
423
  return l.className = "tbw-pivot-chip-remove", l.innerHTML = "×", l.title = "Remove field", l.addEventListener(
424
424
  "click",
425
425
  (d) => {
426
- d.stopPropagation(), o.onRemoveFieldFromZone(t, e);
426
+ d.stopPropagation(), i.onRemoveFieldFromZone(t, e);
427
427
  },
428
428
  { signal: r }
429
- ), n.appendChild(s), n.appendChild(l), n.addEventListener(
429
+ ), n.appendChild(a), n.appendChild(l), n.addEventListener(
430
430
  "dragstart",
431
431
  (d) => {
432
432
  d.dataTransfer?.setData("text/plain", t), d.dataTransfer?.setData("source-zone", e), n.classList.add("dragging");
@@ -441,44 +441,44 @@ function O(t, e, i) {
441
441
  ), n;
442
442
  }
443
443
  function Z(t) {
444
- const { config: e, callbacks: i, signal: o } = t, r = document.createElement("div");
444
+ const { config: e, callbacks: o, signal: i } = t, r = document.createElement("div");
445
445
  r.className = "tbw-pivot-drop-zone tbw-pivot-values-zone", r.setAttribute("data-zone", "values");
446
446
  const n = e.valueFields ?? [];
447
447
  if (n.length === 0) {
448
- const a = document.createElement("div");
449
- a.className = "tbw-pivot-placeholder", a.textContent = "Drag numeric fields here for aggregation", r.appendChild(a);
448
+ const s = document.createElement("div");
449
+ s.className = "tbw-pivot-placeholder", s.textContent = "Drag numeric fields here for aggregation", r.appendChild(s);
450
450
  } else
451
- for (const a of n)
452
- r.appendChild($(a, t));
451
+ for (const s of n)
452
+ r.appendChild($(s, t));
453
453
  return r.addEventListener(
454
454
  "dragover",
455
- (a) => {
456
- a.preventDefault(), r.classList.add("drag-over");
455
+ (s) => {
456
+ s.preventDefault(), r.classList.add("drag-over");
457
457
  },
458
- { signal: o }
458
+ { signal: i }
459
459
  ), r.addEventListener(
460
460
  "dragleave",
461
461
  () => {
462
462
  r.classList.remove("drag-over");
463
463
  },
464
- { signal: o }
464
+ { signal: i }
465
465
  ), r.addEventListener(
466
466
  "drop",
467
- (a) => {
468
- a.preventDefault(), r.classList.remove("drag-over");
469
- const s = a.dataTransfer?.getData("text/plain");
470
- s && i.onAddValueField(s, "sum");
467
+ (s) => {
468
+ s.preventDefault(), r.classList.remove("drag-over");
469
+ const a = s.dataTransfer?.getData("text/plain");
470
+ a && o.onAddValueField(a, "sum");
471
471
  },
472
- { signal: o }
472
+ { signal: i }
473
473
  ), r;
474
474
  }
475
475
  function $(t, e) {
476
- const { callbacks: i, signal: o } = e, r = document.createElement("div");
476
+ const { callbacks: o, signal: i } = e, r = document.createElement("div");
477
477
  r.className = "tbw-pivot-field-chip tbw-pivot-value-chip";
478
- const n = i.getAvailableFields().find((c) => c.field === t.field), a = document.createElement("div");
479
- a.className = "tbw-pivot-value-label-wrapper";
480
- const s = document.createElement("span");
481
- s.className = "tbw-pivot-chip-label", s.textContent = n?.header ?? t.field;
478
+ const n = o.getAvailableFields().find((c) => c.field === t.field), s = document.createElement("div");
479
+ s.className = "tbw-pivot-value-label-wrapper";
480
+ const a = document.createElement("span");
481
+ a.className = "tbw-pivot-chip-label", a.textContent = n?.header ?? t.field;
482
482
  const l = document.createElement("select");
483
483
  l.className = "tbw-pivot-agg-select", l.title = "Aggregation function";
484
484
  for (const c of z) {
@@ -488,133 +488,133 @@ function $(t, e) {
488
488
  l.addEventListener(
489
489
  "change",
490
490
  () => {
491
- i.onUpdateValueAggFunc(t.field, l.value);
491
+ o.onUpdateValueAggFunc(t.field, l.value);
492
492
  },
493
- { signal: o }
493
+ { signal: i }
494
494
  );
495
495
  const d = document.createElement("button");
496
496
  return d.className = "tbw-pivot-chip-remove", d.innerHTML = "×", d.title = "Remove value field", d.addEventListener(
497
497
  "click",
498
498
  (c) => {
499
- c.stopPropagation(), i.onRemoveValueField(t.field);
499
+ c.stopPropagation(), o.onRemoveValueField(t.field);
500
500
  },
501
- { signal: o }
502
- ), a.appendChild(s), a.appendChild(l), r.appendChild(a), r.appendChild(d), r;
501
+ { signal: i }
502
+ ), s.appendChild(a), s.appendChild(l), r.appendChild(s), r.appendChild(d), r;
503
503
  }
504
504
  function j(t) {
505
- const { config: e, callbacks: i, signal: o } = t, r = document.createElement("div");
505
+ const { config: e, callbacks: o, signal: i } = t, r = document.createElement("div");
506
506
  r.className = "tbw-pivot-available-fields";
507
- const n = i.getAvailableFields(), a = /* @__PURE__ */ new Set([
507
+ const n = o.getAvailableFields(), s = /* @__PURE__ */ new Set([
508
508
  ...e.rowGroupFields ?? [],
509
509
  ...e.columnGroupFields ?? [],
510
510
  ...e.valueFields?.map((l) => l.field) ?? []
511
- ]), s = n.filter((l) => !a.has(l.field));
512
- if (s.length === 0) {
511
+ ]), a = n.filter((l) => !s.has(l.field));
512
+ if (a.length === 0) {
513
513
  const l = document.createElement("div");
514
514
  l.className = "tbw-pivot-placeholder", l.textContent = "All fields are in use", r.appendChild(l);
515
515
  } else
516
- for (const l of s) {
516
+ for (const l of a) {
517
517
  const d = document.createElement("div");
518
518
  d.className = "tbw-pivot-field-chip available", d.textContent = l.header, d.draggable = !0, d.title = `Drag to add "${l.field}" to a zone`, d.addEventListener(
519
519
  "dragstart",
520
520
  (c) => {
521
521
  c.dataTransfer?.setData("text/plain", l.field), d.classList.add("dragging");
522
522
  },
523
- { signal: o }
523
+ { signal: i }
524
524
  ), d.addEventListener(
525
525
  "dragend",
526
526
  () => {
527
527
  d.classList.remove("dragging");
528
528
  },
529
- { signal: o }
529
+ { signal: i }
530
530
  ), r.appendChild(d);
531
531
  }
532
532
  return r;
533
533
  }
534
534
  function U(t, e) {
535
- const { config: i, callbacks: o, signal: r } = e, n = document.createElement("div");
535
+ const { config: o, callbacks: i, signal: r } = e, n = document.createElement("div");
536
536
  return n.className = "tbw-pivot-options", n.appendChild(
537
537
  x(
538
538
  "Enable Pivot View",
539
539
  t,
540
- (a) => {
541
- o.onTogglePivot(a);
540
+ (s) => {
541
+ i.onTogglePivot(s);
542
542
  },
543
543
  r
544
544
  )
545
545
  ), n.appendChild(
546
546
  x(
547
547
  "Show Row Totals",
548
- i.showTotals ?? !0,
549
- (a) => {
550
- o.onOptionChange("showTotals", a);
548
+ o.showTotals ?? !0,
549
+ (s) => {
550
+ i.onOptionChange("showTotals", s);
551
551
  },
552
552
  r
553
553
  )
554
554
  ), n.appendChild(
555
555
  x(
556
556
  "Show Grand Total",
557
- i.showGrandTotal ?? !0,
558
- (a) => {
559
- o.onOptionChange("showGrandTotal", a);
557
+ o.showGrandTotal ?? !0,
558
+ (s) => {
559
+ i.onOptionChange("showGrandTotal", s);
560
560
  },
561
561
  r
562
562
  )
563
563
  ), n;
564
564
  }
565
- function x(t, e, i, o) {
565
+ function x(t, e, o, i) {
566
566
  const r = document.createElement("label");
567
567
  r.className = "tbw-pivot-checkbox";
568
568
  const n = document.createElement("input");
569
- n.type = "checkbox", n.checked = e, n.addEventListener("change", () => i(n.checked), { signal: o });
570
- const a = document.createElement("span");
571
- return a.textContent = t, r.appendChild(n), r.appendChild(a), r;
569
+ n.type = "checkbox", n.checked = e, n.addEventListener("change", () => o(n.checked), { signal: i });
570
+ const s = document.createElement("span");
571
+ return s.textContent = t, r.appendChild(n), r.appendChild(s), r;
572
572
  }
573
- function B(t, e, i) {
574
- 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) => {
573
+ function B(t, e, o) {
574
+ return e.className = "pivot-group-row", e.setAttribute("data-pivot-depth", String(t.__pivotDepth ?? 0)), e.setAttribute("role", "row"), e.innerHTML = "", o.columns.forEach((i, r) => {
575
575
  const n = document.createElement("div");
576
576
  if (n.className = "cell", n.setAttribute("data-col", String(r)), n.setAttribute("role", "gridcell"), r === 0) {
577
- const a = Number(t.__pivotIndent) || 0;
578
- n.style.paddingLeft = `${a}px`;
579
- const s = String(t.__pivotRowKey), l = document.createElement("button");
580
- 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) => {
581
- p.stopPropagation(), i.onToggle(s);
577
+ const s = Number(t.__pivotIndent) || 0;
578
+ n.style.paddingLeft = `${s}px`;
579
+ const a = String(t.__pivotRowKey), l = document.createElement("button");
580
+ l.type = "button", l.className = "pivot-toggle", l.setAttribute("aria-label", t.__pivotExpanded ? "Collapse group" : "Expand group"), o.setIcon(l, o.resolveIcon(t.__pivotExpanded ? "collapse" : "expand")), l.addEventListener("click", (p) => {
581
+ p.stopPropagation(), o.onToggle(a);
582
582
  }), n.appendChild(l);
583
583
  const d = document.createElement("span");
584
584
  d.className = "pivot-label", d.textContent = String(t.__pivotLabel ?? ""), n.appendChild(d);
585
585
  const c = document.createElement("span");
586
586
  c.className = "pivot-count", c.textContent = ` (${Number(t.__pivotRowCount) || 0})`, n.appendChild(c);
587
587
  } else {
588
- const a = t[o.field];
589
- n.textContent = a != null ? String(a) : "";
588
+ const s = t[i.field];
589
+ n.textContent = s != null ? String(s) : "";
590
590
  }
591
591
  e.appendChild(n);
592
592
  }), !0;
593
593
  }
594
- function W(t, e, i) {
595
- return e.className = "pivot-leaf-row", e.setAttribute("data-pivot-depth", String(t.__pivotDepth ?? 0)), e.innerHTML = "", i.forEach((o, r) => {
594
+ function W(t, e, o) {
595
+ return e.className = "pivot-leaf-row", e.setAttribute("data-pivot-depth", String(t.__pivotDepth ?? 0)), e.innerHTML = "", o.forEach((i, r) => {
596
596
  const n = document.createElement("div");
597
597
  if (n.className = "cell", n.setAttribute("data-col", String(r)), n.setAttribute("role", "gridcell"), r === 0) {
598
- const a = Number(t.__pivotIndent) || 0;
599
- n.style.paddingLeft = `${a + 20}px`;
600
- const s = document.createElement("span");
601
- s.className = "pivot-label", s.textContent = String(t.__pivotLabel ?? ""), n.appendChild(s);
598
+ const s = Number(t.__pivotIndent) || 0;
599
+ n.style.paddingLeft = `${s + 20}px`;
600
+ const a = document.createElement("span");
601
+ a.className = "pivot-label", a.textContent = String(t.__pivotLabel ?? ""), n.appendChild(a);
602
602
  } else {
603
- const a = t[o.field];
604
- n.textContent = a != null ? String(a) : "";
603
+ const s = t[i.field];
604
+ n.textContent = s != null ? String(s) : "";
605
605
  }
606
606
  e.appendChild(n);
607
607
  }), !0;
608
608
  }
609
- function J(t, e, i) {
610
- return e.className = "pivot-grand-total-row", e.setAttribute("role", "presentation"), e.innerHTML = "", i.forEach((o, r) => {
609
+ function J(t, e, o) {
610
+ return e.className = "pivot-grand-total-row", e.setAttribute("role", "presentation"), e.innerHTML = "", o.forEach((i, r) => {
611
611
  const n = document.createElement("div");
612
612
  if (n.className = "cell", n.setAttribute("data-col", String(r)), r === 0) {
613
- const a = document.createElement("span");
614
- a.className = "pivot-label", a.textContent = "Grand Total", n.appendChild(a);
613
+ const s = document.createElement("span");
614
+ s.className = "pivot-label", s.textContent = "Grand Total", n.appendChild(s);
615
615
  } else {
616
- const a = t[o.field];
617
- n.textContent = a != null ? String(a) : "";
616
+ const s = t[i.field];
617
+ n.textContent = s != null ? String(s) : "";
618
618
  }
619
619
  e.appendChild(n);
620
620
  }), !0;
@@ -629,7 +629,8 @@ class b extends N {
629
629
  return {
630
630
  active: !0,
631
631
  showTotals: !0,
632
- showGrandTotal: !0
632
+ showGrandTotal: !0,
633
+ showToolPanel: !0
633
634
  };
634
635
  }
635
636
  // #region Internal State
@@ -656,34 +657,35 @@ class b extends N {
656
657
  // #endregion
657
658
  // #region Shell Integration
658
659
  getToolPanel() {
659
- return {
660
- id: b.PANEL_ID,
661
- title: "Pivot",
662
- icon: "",
663
- tooltip: "Configure pivot table",
664
- order: 90,
665
- render: (e) => this.renderPanel(e)
666
- };
660
+ if ((this.config?.showToolPanel ?? this.userConfig?.showToolPanel ?? !0) !== !1)
661
+ return {
662
+ id: b.PANEL_ID,
663
+ title: "Pivot",
664
+ icon: "",
665
+ tooltip: "Configure pivot table",
666
+ order: 90,
667
+ render: (o) => this.renderPanel(o)
668
+ };
667
669
  }
668
670
  // #endregion
669
671
  // #region Hooks
670
672
  processRows(e) {
671
673
  if (!this.hasInitialized && this.config.active !== !1 && this.hasValidPivotConfig() && (this.hasInitialized = !0, this.isActive = !0), !this.isActive)
672
674
  return [...e];
673
- const i = I(this.config);
674
- if (i.length > 0)
675
- return this.warn(`Config errors: ${i.join(", ")}`), [...e];
675
+ const o = I(this.config);
676
+ if (o.length > 0)
677
+ return this.warn(`Config errors: ${o.join(", ")}`), [...e];
676
678
  if (this.buildFieldHeaderMap(), this.defaultExpanded = this.config.defaultExpanded ?? !0, this.expandedKeys.size === 0 && this.defaultExpanded && this.pivotResult) {
677
679
  const n = w(this.pivotResult.rows);
678
- for (const a of n)
679
- this.expandedKeys.add(a);
680
+ for (const s of n)
681
+ this.expandedKeys.add(s);
680
682
  }
681
683
  if (this.pivotResult = S(e, this.config), this.expandedKeys.size === 0 && this.defaultExpanded) {
682
684
  const n = w(this.pivotResult.rows);
683
- for (const a of n)
684
- this.expandedKeys.add(a);
685
+ for (const s of n)
686
+ this.expandedKeys.add(s);
685
687
  }
686
- const o = this.config.indentWidth ?? 20;
688
+ const i = this.config.indentWidth ?? 20;
687
689
  return D(
688
690
  this.pivotResult.rows,
689
691
  this.expandedKeys,
@@ -696,7 +698,7 @@ class b extends N {
696
698
  __pivotHasChildren: !!n.children?.length,
697
699
  __pivotExpanded: this.expandedKeys.has(n.rowKey),
698
700
  __pivotRowCount: n.rowCount ?? 0,
699
- __pivotIndent: n.depth * o,
701
+ __pivotIndent: n.depth * i,
700
702
  __pivotTotal: n.total,
701
703
  ...n.values
702
704
  }));
@@ -704,37 +706,37 @@ class b extends N {
704
706
  processColumns(e) {
705
707
  if (!this.isActive || !this.pivotResult)
706
708
  return [...e];
707
- const i = [], o = (this.config.rowGroupFields ?? []).map((r) => this.fieldHeaderMap.get(r) ?? r).join(" / ");
708
- i.push({
709
+ const o = [], i = (this.config.rowGroupFields ?? []).map((r) => this.fieldHeaderMap.get(r) ?? r).join(" / ");
710
+ o.push({
709
711
  field: "__pivotLabel",
710
- header: o || "Group",
712
+ header: i || "Group",
711
713
  width: 200
712
714
  });
713
715
  for (const r of this.pivotResult.columnKeys)
714
716
  for (const n of this.config.valueFields ?? []) {
715
- const a = C([r], n.field), s = n.header || this.fieldHeaderMap.get(n.field) || n.field;
716
- i.push({
717
- field: a,
718
- header: `${r} - ${s} (${n.aggFunc})`,
717
+ const s = C([r], n.field), a = n.header || this.fieldHeaderMap.get(n.field) || n.field;
718
+ o.push({
719
+ field: s,
720
+ header: `${r} - ${a} (${n.aggFunc})`,
719
721
  width: 120,
720
722
  type: "number"
721
723
  });
722
724
  }
723
- return this.config.showTotals && i.push({
725
+ return this.config.showTotals && o.push({
724
726
  field: "__pivotTotal",
725
727
  header: "Total",
726
728
  width: 100,
727
729
  type: "number"
728
- }), i;
730
+ }), o;
729
731
  }
730
- renderRow(e, i) {
731
- const o = e;
732
- return o.__pivotRowKey && o.__pivotHasChildren ? B(o, i, {
732
+ renderRow(e, o) {
733
+ const i = e;
734
+ return i.__pivotRowKey && i.__pivotHasChildren ? B(i, o, {
733
735
  columns: this.gridColumns,
734
736
  onToggle: (r) => this.toggle(r),
735
737
  resolveIcon: (r) => this.resolveIcon(r),
736
738
  setIcon: (r, n) => this.setIcon(r, n)
737
- }) : o.__pivotRowKey !== void 0 && this.isActive ? W(o, i, this.gridColumns) : (this.cleanupPivotStyling(i), !1);
739
+ }) : i.__pivotRowKey !== void 0 && this.isActive ? W(i, o, this.gridColumns) : (this.cleanupPivotStyling(o), !1);
738
740
  }
739
741
  /**
740
742
  * Remove pivot-specific classes, attributes, and inline styles from a row element.
@@ -754,17 +756,17 @@ class b extends N {
754
756
  if (!this.pivotResult) return;
755
757
  const e = this.shadowRoot;
756
758
  if (!e) return;
757
- const i = e.querySelector(".tbw-scroll-area") ?? e.querySelector(".tbw-grid-content") ?? e.children[0];
758
- if (!i) return;
759
- this.grandTotalFooter || (this.grandTotalFooter = document.createElement("div"), this.grandTotalFooter.className = "pivot-grand-total-footer", i.appendChild(this.grandTotalFooter));
760
- const o = {
759
+ const o = e.querySelector(".tbw-scroll-area") ?? e.querySelector(".tbw-grid-content") ?? e.children[0];
760
+ if (!o) return;
761
+ this.grandTotalFooter || (this.grandTotalFooter = document.createElement("div"), this.grandTotalFooter.className = "pivot-grand-total-footer", o.appendChild(this.grandTotalFooter));
762
+ const i = {
761
763
  __pivotRowKey: "__grandTotal",
762
764
  __pivotLabel: "Grand Total",
763
765
  __pivotIsGrandTotal: !0,
764
766
  __pivotTotal: this.pivotResult.grandTotal,
765
767
  ...this.pivotResult.totals
766
768
  };
767
- J(o, this.grandTotalFooter, this.gridColumns);
769
+ J(i, this.grandTotalFooter, this.gridColumns);
768
770
  }
769
771
  /**
770
772
  * Remove the grand total footer element.
@@ -786,8 +788,8 @@ class b extends N {
786
788
  expandAll() {
787
789
  if (this.pivotResult) {
788
790
  const e = w(this.pivotResult.rows);
789
- for (const i of e)
790
- this.expandedKeys.add(i);
791
+ for (const o of e)
792
+ this.expandedKeys.add(o);
791
793
  this.requestRender();
792
794
  }
793
795
  }
@@ -845,8 +847,8 @@ class b extends N {
845
847
  buildFieldHeaderMap() {
846
848
  const e = this.getAvailableFields();
847
849
  this.fieldHeaderMap.clear();
848
- for (const i of e)
849
- this.fieldHeaderMap.set(i.field, i.header);
850
+ for (const o of e)
851
+ this.fieldHeaderMap.set(o.field, o.header);
850
852
  }
851
853
  getAvailableFields() {
852
854
  return this.originalColumns.length > 0 ? this.originalColumns : this.captureOriginalColumns();
@@ -854,10 +856,10 @@ class b extends N {
854
856
  captureOriginalColumns() {
855
857
  const e = this.grid;
856
858
  try {
857
- const i = e.getAllColumns?.() ?? e.columns ?? [];
858
- return this.originalColumns = i.filter((o) => !o.field.startsWith("__pivot")).map((o) => ({
859
- field: o.field,
860
- header: o.header ?? o.field
859
+ const o = e.getAllColumns?.() ?? e.columns ?? [];
860
+ return this.originalColumns = o.filter((i) => !i.field.startsWith("__pivot")).map((i) => ({
861
+ field: i.field,
862
+ header: i.header ?? i.field
861
863
  })), this.originalColumns;
862
864
  } catch {
863
865
  return [];
@@ -865,51 +867,51 @@ class b extends N {
865
867
  }
866
868
  renderPanel(e) {
867
869
  this.panelContainer = e, this.originalColumns.length === 0 && this.captureOriginalColumns();
868
- const i = {
869
- onTogglePivot: (o) => {
870
- o ? this.enablePivot() : this.disablePivot(), this.refreshPanel();
870
+ const o = {
871
+ onTogglePivot: (i) => {
872
+ i ? this.enablePivot() : this.disablePivot(), this.refreshPanel();
871
873
  },
872
- onAddFieldToZone: (o, r) => this.addFieldToZone(o, r),
873
- onRemoveFieldFromZone: (o, r) => this.removeFieldFromZone(o, r),
874
- onAddValueField: (o, r) => this.addValueField(o, r),
875
- onRemoveValueField: (o) => this.removeValueField(o),
876
- onUpdateValueAggFunc: (o, r) => this.updateValueAggFunc(o, r),
877
- onOptionChange: (o, r) => {
878
- this.config[o] = r, this.isActive && this.refresh();
874
+ onAddFieldToZone: (i, r) => this.addFieldToZone(i, r),
875
+ onRemoveFieldFromZone: (i, r) => this.removeFieldFromZone(i, r),
876
+ onAddValueField: (i, r) => this.addValueField(i, r),
877
+ onRemoveValueField: (i) => this.removeValueField(i),
878
+ onUpdateValueAggFunc: (i, r) => this.updateValueAggFunc(i, r),
879
+ onOptionChange: (i, r) => {
880
+ this.config[i] = r, this.isActive && this.refresh();
879
881
  },
880
882
  getAvailableFields: () => this.getAvailableFields()
881
883
  };
882
- return q(e, this.config, this.isActive, i);
884
+ return q(e, this.config, this.isActive, o);
883
885
  }
884
886
  refreshPanel() {
885
887
  this.panelContainer && (this.panelContainer.innerHTML = "", this.renderPanel(this.panelContainer));
886
888
  }
887
- addFieldToZone(e, i) {
888
- if (i === "rowGroups") {
889
- const o = this.config.rowGroupFields ?? [];
890
- o.includes(e) || (this.config.rowGroupFields = [...o, e]);
889
+ addFieldToZone(e, o) {
890
+ if (o === "rowGroups") {
891
+ const i = this.config.rowGroupFields ?? [];
892
+ i.includes(e) || (this.config.rowGroupFields = [...i, e]);
891
893
  } else {
892
- const o = this.config.columnGroupFields ?? [];
893
- o.includes(e) || (this.config.columnGroupFields = [...o, e]);
894
+ const i = this.config.columnGroupFields ?? [];
895
+ i.includes(e) || (this.config.columnGroupFields = [...i, e]);
894
896
  }
895
- this.removeFromOtherZones(e, i), this.isActive && this.refresh(), this.refreshPanel();
897
+ this.removeFromOtherZones(e, o), this.isActive && this.refresh(), this.refreshPanel();
896
898
  }
897
- removeFieldFromZone(e, i) {
898
- i === "rowGroups" ? this.config.rowGroupFields = (this.config.rowGroupFields ?? []).filter((o) => o !== e) : this.config.columnGroupFields = (this.config.columnGroupFields ?? []).filter((o) => o !== e), this.isActive && this.refresh(), this.refreshPanel();
899
+ removeFieldFromZone(e, o) {
900
+ o === "rowGroups" ? this.config.rowGroupFields = (this.config.rowGroupFields ?? []).filter((i) => i !== e) : this.config.columnGroupFields = (this.config.columnGroupFields ?? []).filter((i) => i !== e), this.isActive && this.refresh(), this.refreshPanel();
899
901
  }
900
- removeFromOtherZones(e, i) {
901
- i !== "rowGroups" && (this.config.rowGroupFields = (this.config.rowGroupFields ?? []).filter((o) => o !== e)), i !== "columnGroups" && (this.config.columnGroupFields = (this.config.columnGroupFields ?? []).filter((o) => o !== e)), i !== "values" && (this.config.valueFields = (this.config.valueFields ?? []).filter((o) => o.field !== e));
902
+ removeFromOtherZones(e, o) {
903
+ o !== "rowGroups" && (this.config.rowGroupFields = (this.config.rowGroupFields ?? []).filter((i) => i !== e)), o !== "columnGroups" && (this.config.columnGroupFields = (this.config.columnGroupFields ?? []).filter((i) => i !== e)), o !== "values" && (this.config.valueFields = (this.config.valueFields ?? []).filter((i) => i.field !== e));
902
904
  }
903
- addValueField(e, i) {
904
- const o = this.config.valueFields ?? [];
905
- o.some((r) => r.field === e) || (this.config.valueFields = [...o, { field: e, aggFunc: i }]), this.removeFromOtherZones(e, "values"), this.isActive && this.refresh(), this.refreshPanel();
905
+ addValueField(e, o) {
906
+ const i = this.config.valueFields ?? [];
907
+ i.some((r) => r.field === e) || (this.config.valueFields = [...i, { field: e, aggFunc: o }]), this.removeFromOtherZones(e, "values"), this.isActive && this.refresh(), this.refreshPanel();
906
908
  }
907
909
  removeValueField(e) {
908
- this.config.valueFields = (this.config.valueFields ?? []).filter((i) => i.field !== e), this.isActive && this.refresh(), this.refreshPanel();
910
+ this.config.valueFields = (this.config.valueFields ?? []).filter((o) => o.field !== e), this.isActive && this.refresh(), this.refreshPanel();
909
911
  }
910
- updateValueAggFunc(e, i) {
911
- const o = this.config.valueFields ?? [], r = o.findIndex((n) => n.field === e);
912
- r >= 0 && (o[r] = { ...o[r], aggFunc: i }, this.config.valueFields = [...o]), this.isActive && this.refresh();
912
+ updateValueAggFunc(e, o) {
913
+ const i = this.config.valueFields ?? [], r = i.findIndex((n) => n.field === e);
914
+ r >= 0 && (i[r] = { ...i[r], aggFunc: o }, this.config.valueFields = [...i]), this.isActive && this.refresh();
913
915
  }
914
916
  // #endregion
915
917
  // #region Styles