@toolbox-web/grid 0.2.5 → 0.2.7

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