@toolbox-web/grid 0.0.7 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +1 -1
  2. package/all.d.ts +156 -95
  3. package/all.js +1561 -1502
  4. package/all.js.map +1 -1
  5. package/custom-elements.json +89 -7
  6. package/index.d.ts +68 -23
  7. package/index.js +1617 -1388
  8. package/index.js.map +1 -1
  9. package/lib/plugins/clipboard/index.js +48 -49
  10. package/lib/plugins/clipboard/index.js.map +1 -1
  11. package/lib/plugins/column-virtualization/index.js +6 -6
  12. package/lib/plugins/column-virtualization/index.js.map +1 -1
  13. package/lib/plugins/context-menu/index.js +64 -109
  14. package/lib/plugins/context-menu/index.js.map +1 -1
  15. package/lib/plugins/export/index.js +7 -7
  16. package/lib/plugins/export/index.js.map +1 -1
  17. package/lib/plugins/filtering/index.js +5 -38
  18. package/lib/plugins/filtering/index.js.map +1 -1
  19. package/lib/plugins/grouping-columns/index.js +4 -32
  20. package/lib/plugins/grouping-columns/index.js.map +1 -1
  21. package/lib/plugins/grouping-rows/index.js +8 -45
  22. package/lib/plugins/grouping-rows/index.js.map +1 -1
  23. package/lib/plugins/master-detail/index.js +7 -31
  24. package/lib/plugins/master-detail/index.js.map +1 -1
  25. package/lib/plugins/multi-sort/index.js +19 -42
  26. package/lib/plugins/multi-sort/index.js.map +1 -1
  27. package/lib/plugins/pinned-columns/index.js +5 -6
  28. package/lib/plugins/pinned-columns/index.js.map +1 -1
  29. package/lib/plugins/pinned-rows/index.js +14 -88
  30. package/lib/plugins/pinned-rows/index.js.map +1 -1
  31. package/lib/plugins/pivot/index.js +673 -145
  32. package/lib/plugins/pivot/index.js.map +1 -1
  33. package/lib/plugins/reorder/index.js +22 -51
  34. package/lib/plugins/reorder/index.js.map +1 -1
  35. package/lib/plugins/selection/index.js +76 -83
  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 +6 -14
  40. package/lib/plugins/tree/index.js.map +1 -1
  41. package/lib/plugins/undo-redo/index.js +2 -3
  42. package/lib/plugins/undo-redo/index.js.map +1 -1
  43. package/lib/plugins/visibility/index.js +13 -105
  44. package/lib/plugins/visibility/index.js.map +1 -1
  45. package/package.json +1 -1
  46. package/themes/dg-theme-bootstrap.css +73 -0
  47. package/themes/dg-theme-material.css +71 -0
  48. package/umd/grid.all.umd.js +43 -469
  49. package/umd/grid.all.umd.js.map +1 -1
  50. package/umd/grid.umd.js +35 -66
  51. package/umd/grid.umd.js.map +1 -1
  52. package/umd/plugins/clipboard.umd.js +4 -4
  53. package/umd/plugins/clipboard.umd.js.map +1 -1
  54. package/umd/plugins/column-virtualization.umd.js +1 -1
  55. package/umd/plugins/column-virtualization.umd.js.map +1 -1
  56. package/umd/plugins/context-menu.umd.js +1 -52
  57. package/umd/plugins/context-menu.umd.js.map +1 -1
  58. package/umd/plugins/export.umd.js +1 -1
  59. package/umd/plugins/export.umd.js.map +1 -1
  60. package/umd/plugins/filtering.umd.js +2 -34
  61. package/umd/plugins/filtering.umd.js.map +1 -1
  62. package/umd/plugins/grouping-columns.umd.js +1 -28
  63. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  64. package/umd/plugins/grouping-rows.umd.js +1 -39
  65. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  66. package/umd/plugins/master-detail.umd.js +1 -26
  67. package/umd/plugins/master-detail.umd.js.map +1 -1
  68. package/umd/plugins/multi-sort.umd.js +1 -25
  69. package/umd/plugins/multi-sort.umd.js.map +1 -1
  70. package/umd/plugins/pinned-columns.umd.js +1 -1
  71. package/umd/plugins/pinned-columns.umd.js.map +1 -1
  72. package/umd/plugins/pinned-rows.umd.js +1 -72
  73. package/umd/plugins/pinned-rows.umd.js.map +1 -1
  74. package/umd/plugins/pivot.umd.js +1 -7
  75. package/umd/plugins/pivot.umd.js.map +1 -1
  76. package/umd/plugins/reorder.umd.js +1 -30
  77. package/umd/plugins/reorder.umd.js.map +1 -1
  78. package/umd/plugins/selection.umd.js +1 -33
  79. package/umd/plugins/selection.umd.js.map +1 -1
  80. package/umd/plugins/server-side.umd.js +1 -1
  81. package/umd/plugins/server-side.umd.js.map +1 -1
  82. package/umd/plugins/tree.umd.js +1 -10
  83. package/umd/plugins/tree.umd.js.map +1 -1
  84. package/umd/plugins/undo-redo.umd.js +1 -1
  85. package/umd/plugins/undo-redo.umd.js.map +1 -1
  86. package/umd/plugins/visibility.umd.js +1 -93
  87. package/umd/plugins/visibility.umd.js.map +1 -1
package/all.js CHANGED
@@ -1,71 +1,70 @@
1
- import { BaseGridPlugin as y, DEFAULT_GRID_ICONS as xe, runAggregator as X, getAggregator as ve } from "./index.js";
2
- import { DGEvents as Pt, DataGridElement as Bt, FitModeEnum as Ht, GridCSSVars as Ot, GridClasses as Wt, GridDataAttrs as Vt, DataGridElement as Kt, GridSelectors as Gt, PluginEvents as zt, PluginManager as $t, SelectionPlugin as jt, TreePlugin as Ut, aggregatorRegistry as Yt, listAggregators as Xt, registerAggregator as Jt, unregisterAggregator as Qt } from "./index.js";
3
- function ye(i, e, t, n) {
4
- if (n.processCell)
5
- return n.processCell(i, e, t);
6
- if (i == null) return "";
7
- if (i instanceof Date) return i.toISOString();
8
- if (typeof i == "object") return JSON.stringify(i);
9
- const o = String(i), r = n.delimiter ?? " ", s = n.newline ?? `
1
+ import { BaseGridPlugin as C, DEFAULT_GRID_ICONS as _e, runAggregator as te, getAggregator as Ie, getValueAggregator as Te } from "./index.js";
2
+ import { DGEvents as uo, DataGridElement as ho, FitModeEnum as po, GridCSSVars as go, GridClasses as fo, GridDataAttrs as mo, DataGridElement as bo, GridSelectors as wo, PluginEvents as vo, PluginManager as xo, SelectionPlugin as Co, TreePlugin as yo, aggregatorRegistry as Ro, listAggregators as So, registerAggregator as Eo, runValueAggregator as ko, unregisterAggregator as Ao } from "./index.js";
3
+ function Fe(s, e, t, o) {
4
+ if (o.processCell)
5
+ return o.processCell(s, e, t);
6
+ if (s == null) return "";
7
+ if (s instanceof Date) return s.toISOString();
8
+ if (typeof s == "object") return JSON.stringify(s);
9
+ const n = String(s), i = o.delimiter ?? " ", r = o.newline ?? `
10
10
  `;
11
- return n.quoteStrings || o.includes(r) || o.includes(s) || o.includes('"') ? `"${o.replace(/"/g, '""')}"` : o;
11
+ return o.quoteStrings || n.includes(i) || n.includes(r) || n.includes('"') ? `"${n.replace(/"/g, '""')}"` : n;
12
12
  }
13
- function F(i) {
14
- const { rows: e, columns: t, selectedIndices: n, config: o } = i, r = o.delimiter ?? " ", s = o.newline ?? `
13
+ function H(s) {
14
+ const { rows: e, columns: t, selectedIndices: o, config: n } = s, i = n.delimiter ?? " ", r = n.newline ?? `
15
15
  `, l = t.filter((u) => !u.hidden && !u.field.startsWith("__")), a = [];
16
- if (o.includeHeaders) {
16
+ if (n.includeHeaders) {
17
17
  const u = l.map((h) => {
18
- const f = h.header || h.field;
19
- return f.includes(r) || f.includes(s) || f.includes('"') ? `"${f.replace(/"/g, '""')}"` : f;
18
+ const p = h.header || h.field;
19
+ return p.includes(i) || p.includes(r) || p.includes('"') ? `"${p.replace(/"/g, '""')}"` : p;
20
20
  });
21
- a.push(u.join(r));
21
+ a.push(u.join(i));
22
22
  }
23
- const c = [...n instanceof Set ? [...n] : n].sort((u, h) => u - h);
23
+ const c = [...o instanceof Set ? [...o] : o].sort((u, h) => u - h);
24
24
  for (const u of c) {
25
25
  const h = e[u];
26
26
  if (!h) continue;
27
- const f = l.map(
28
- (g) => ye(h[g.field], g.field, h, o)
27
+ const p = l.map(
28
+ (g) => Fe(h[g.field], g.field, h, n)
29
29
  );
30
- a.push(f.join(r));
30
+ a.push(p.join(i));
31
31
  }
32
- return a.join(s);
32
+ return a.join(r);
33
33
  }
34
- async function N(i) {
34
+ async function G(s) {
35
35
  try {
36
- return await navigator.clipboard.writeText(i), !0;
36
+ return await navigator.clipboard.writeText(s), !0;
37
37
  } catch {
38
38
  const e = document.createElement("textarea");
39
- e.value = i, e.style.position = "fixed", e.style.opacity = "0", e.style.pointerEvents = "none", document.body.appendChild(e), e.select();
39
+ e.value = s, e.style.position = "fixed", e.style.opacity = "0", e.style.pointerEvents = "none", document.body.appendChild(e), e.select();
40
40
  const t = document.execCommand("copy");
41
41
  return document.body.removeChild(e), t;
42
42
  }
43
43
  }
44
- function J(i, e) {
45
- const t = e.delimiter ?? " ", n = e.newline ?? `
46
- `, o = i.replace(/\r\n/g, `
44
+ function oe(s, e) {
45
+ const t = e.delimiter ?? " ", o = e.newline ?? `
46
+ `, n = s.replace(/\r\n/g, `
47
47
  `).replace(/\r/g, `
48
- `), r = [];
49
- let s = [], l = "", a = !1;
50
- for (let d = 0; d < o.length; d++) {
51
- const c = o[d];
52
- c === '"' && !a ? a = !0 : c === '"' && a ? o[d + 1] === '"' ? (l += '"', d++) : a = !1 : c === t && !a ? (s.push(l), l = "") : c === n && !a ? (s.push(l), l = "", (s.length > 1 || s.some((u) => u.trim() !== "")) && r.push(s), s = []) : l += c;
48
+ `), i = [];
49
+ let r = [], l = "", a = !1;
50
+ for (let d = 0; d < n.length; d++) {
51
+ const c = n[d];
52
+ c === '"' && !a ? a = !0 : c === '"' && a ? n[d + 1] === '"' ? (l += '"', d++) : a = !1 : c === t && !a ? (r.push(l), l = "") : c === o && !a ? (r.push(l), l = "", (r.length > 1 || r.some((u) => u.trim() !== "")) && i.push(r), r = []) : l += c;
53
53
  }
54
- return s.push(l), (s.length > 1 || s.some((d) => d.trim() !== "")) && r.push(s), r;
54
+ return r.push(l), (r.length > 1 || r.some((d) => d.trim() !== "")) && i.push(r), i;
55
55
  }
56
- async function Q() {
56
+ async function ne() {
57
57
  try {
58
58
  return await navigator.clipboard.readText();
59
59
  } catch {
60
60
  return "";
61
61
  }
62
62
  }
63
- class yt extends y {
63
+ class Yt extends C {
64
64
  name = "clipboard";
65
65
  version = "1.0.0";
66
66
  get defaultConfig() {
67
67
  return {
68
- enabled: !0,
69
68
  includeHeaders: !1,
70
69
  delimiter: " ",
71
70
  newline: `
@@ -82,26 +81,25 @@ class yt extends y {
82
81
  }
83
82
  // ===== Event Handlers =====
84
83
  onKeyDown(e) {
85
- if (this.config.enabled === !1) return !1;
86
- const t = (e.ctrlKey || e.metaKey) && e.key === "c", n = (e.ctrlKey || e.metaKey) && e.key === "v";
87
- return t ? (this.#e(e.target), !0) : n ? (this.#n(), !0) : !1;
84
+ const t = (e.ctrlKey || e.metaKey) && e.key === "c", o = (e.ctrlKey || e.metaKey) && e.key === "v";
85
+ return t ? (this.#e(e.target), !0) : o ? (this.#o(), !0) : !1;
88
86
  }
89
87
  // ===== Private Methods =====
90
88
  /**
91
89
  * Handle copy operation
92
90
  */
93
91
  #e(e) {
94
- const t = this.#t(), n = t?.getSelectedRows() ?? [], o = n.length > 0, r = t?.getRanges() ?? [], s = r.length > 0, l = t?.getSelectedCell() != null;
92
+ const t = this.#t(), o = t?.getSelectedRows() ?? [], n = o.length > 0, i = t?.getRanges() ?? [], r = i.length > 0, l = t?.getSelectedCell() != null;
95
93
  let a, d, c;
96
- if (o && t)
97
- a = F({
94
+ if (n && t)
95
+ a = H({
98
96
  rows: this.rows,
99
97
  columns: [...this.columns],
100
- selectedIndices: n,
98
+ selectedIndices: o,
101
99
  config: this.config
102
- }), d = n.length, c = this.columns.filter((u) => !u.hidden && !u.field.startsWith("__")).length;
103
- else if (s && t) {
104
- const u = r[r.length - 1], h = this.#r({
100
+ }), d = o.length, c = this.columns.filter((u) => !u.hidden && !u.field.startsWith("__")).length;
101
+ else if (r && t) {
102
+ const u = i[i.length - 1], h = this.#i({
105
103
  startRow: u.from.row,
106
104
  startCol: u.from.col,
107
105
  endRow: u.to.row,
@@ -109,25 +107,25 @@ class yt extends y {
109
107
  });
110
108
  a = h.text, d = h.rowCount, c = h.columnCount;
111
109
  } else if (l && t) {
112
- const u = t.getSelectedCell(), h = this.#o(u.row, u.col);
110
+ const u = t.getSelectedCell(), h = this.#n(u.row, u.col);
113
111
  if (!h) return;
114
112
  a = h.text, d = 1, c = 1;
115
113
  } else {
116
- const u = this.#i(e);
114
+ const u = this.#r(e);
117
115
  if (!u) return;
118
116
  a = u.text, d = 1, c = 1;
119
117
  }
120
- N(a).then(() => {
118
+ G(a).then(() => {
121
119
  this.lastCopied = { text: a, timestamp: Date.now() }, this.emit("copy", { text: a, rowCount: d, columnCount: c });
122
120
  });
123
121
  }
124
122
  /**
125
123
  * Handle paste operation
126
124
  */
127
- #n() {
128
- Q().then((e) => {
125
+ #o() {
126
+ ne().then((e) => {
129
127
  if (!e) return;
130
- const t = J(e, this.config);
128
+ const t = oe(e, this.config);
131
129
  this.emit("paste", { rows: t, text: e });
132
130
  });
133
131
  }
@@ -148,42 +146,42 @@ class yt extends y {
148
146
  /**
149
147
  * Build text for a single cell by row/col index.
150
148
  */
151
- #o(e, t) {
152
- const n = this.rows[e];
153
- if (!n) return null;
154
- const o = this.columns[t];
149
+ #n(e, t) {
150
+ const o = this.rows[e];
155
151
  if (!o) return null;
156
- const r = n[o.field], s = o.header || o.field;
152
+ const n = this.columns[t];
153
+ if (!n) return null;
154
+ const i = o[n.field], r = n.header || n.field;
157
155
  let l;
158
156
  if (this.config.includeHeaders) {
159
- const a = r == null ? "" : String(r);
160
- l = `${s}: ${a}`;
157
+ const a = i == null ? "" : String(i);
158
+ l = `${r}: ${a}`;
161
159
  } else
162
- l = r == null ? "" : String(r);
160
+ l = i == null ? "" : String(i);
163
161
  return { text: l };
164
162
  }
165
163
  /**
166
164
  * Build text for a rectangular range of cells.
167
165
  */
168
- #r(e) {
169
- const { startRow: t, startCol: n, endRow: o, endCol: r } = e, s = Math.min(t, o), l = Math.max(t, o), a = Math.min(n, r), d = Math.max(n, r), c = this.config.delimiter ?? " ", u = this.config.newline ?? `
170
- `, h = [], f = this.columns.slice(a, d + 1);
166
+ #i(e) {
167
+ const { startRow: t, startCol: o, endRow: n, endCol: i } = e, r = Math.min(t, n), l = Math.max(t, n), a = Math.min(o, i), d = Math.max(o, i), c = this.config.delimiter ?? " ", u = this.config.newline ?? `
168
+ `, h = [], p = this.columns.slice(a, d + 1);
171
169
  if (this.config.includeHeaders) {
172
- const g = f.map((m) => m.header || m.field);
170
+ const g = p.map((m) => m.header || m.field);
173
171
  h.push(g.join(c));
174
172
  }
175
- for (let g = s; g <= l; g++) {
173
+ for (let g = r; g <= l; g++) {
176
174
  const m = this.rows[g];
177
175
  if (!m) continue;
178
- const b = f.map((S) => {
179
- const R = m[S.field];
180
- return R == null ? "" : R instanceof Date ? R.toISOString() : String(R);
176
+ const b = p.map((R) => {
177
+ const k = m[R.field];
178
+ return k == null ? "" : k instanceof Date ? k.toISOString() : String(k);
181
179
  });
182
180
  h.push(b.join(c));
183
181
  }
184
182
  return {
185
183
  text: h.join(u),
186
- rowCount: l - s + 1,
184
+ rowCount: l - r + 1,
187
185
  columnCount: d - a + 1
188
186
  };
189
187
  }
@@ -191,25 +189,25 @@ class yt extends y {
191
189
  * Build text for a single focused cell from DOM.
192
190
  * Used when selection plugin is not available or no rows are selected.
193
191
  */
194
- #i(e) {
192
+ #r(e) {
195
193
  const t = e.closest("[data-field-cache]");
196
194
  if (!t) return null;
197
- const n = t.dataset.fieldCache;
198
- if (!n) return null;
199
- const o = t.dataset.row;
195
+ const o = t.dataset.fieldCache;
200
196
  if (!o) return null;
201
- const r = parseInt(o, 10);
202
- if (isNaN(r)) return null;
203
- const s = this.rows[r];
204
- if (!s) return null;
205
- const l = s[n], d = this.columns.find((u) => u.field === n)?.header || n;
197
+ const n = t.dataset.row;
198
+ if (!n) return null;
199
+ const i = parseInt(n, 10);
200
+ if (isNaN(i)) return null;
201
+ const r = this.rows[i];
202
+ if (!r) return null;
203
+ const l = r[o], d = this.columns.find((u) => u.field === o)?.header || o;
206
204
  let c;
207
205
  if (this.config.includeHeaders) {
208
206
  const u = l == null ? "" : String(l);
209
207
  c = `${d}: ${u}`;
210
208
  } else
211
209
  c = l == null ? "" : String(l);
212
- return { text: c, field: n, value: l };
210
+ return { text: c, field: o, value: l };
213
211
  }
214
212
  // ===== Public API =====
215
213
  /**
@@ -217,13 +215,13 @@ class yt extends y {
217
215
  * @returns The copied text
218
216
  */
219
217
  async copy() {
220
- const t = this.#t()?.getSelectedRows() ?? [], n = F({
218
+ const t = this.#t()?.getSelectedRows() ?? [], o = H({
221
219
  rows: this.rows,
222
220
  columns: [...this.columns],
223
221
  selectedIndices: t,
224
222
  config: this.config
225
223
  });
226
- return await N(n), this.lastCopied = { text: n, timestamp: Date.now() }, n;
224
+ return await G(o), this.lastCopied = { text: o, timestamp: Date.now() }, o;
227
225
  }
228
226
  /**
229
227
  * Copy specific rows by index to clipboard.
@@ -231,21 +229,21 @@ class yt extends y {
231
229
  * @returns The copied text
232
230
  */
233
231
  async copyRows(e) {
234
- const t = F({
232
+ const t = H({
235
233
  rows: this.rows,
236
234
  columns: [...this.columns],
237
235
  selectedIndices: e,
238
236
  config: this.config
239
237
  });
240
- return await N(t), this.lastCopied = { text: t, timestamp: Date.now() }, t;
238
+ return await G(t), this.lastCopied = { text: t, timestamp: Date.now() }, t;
241
239
  }
242
240
  /**
243
241
  * Read and parse clipboard content.
244
242
  * @returns Parsed 2D array of cell values, or null if clipboard is empty
245
243
  */
246
244
  async paste() {
247
- const e = await Q();
248
- return e ? J(e, this.config) : null;
245
+ const e = await ne();
246
+ return e ? oe(e, this.config) : null;
249
247
  }
250
248
  /**
251
249
  * Get the last copied text and timestamp.
@@ -255,66 +253,65 @@ class yt extends y {
255
253
  return this.lastCopied;
256
254
  }
257
255
  }
258
- const Z = 100;
259
- function G(i) {
260
- if (i == null)
261
- return Z;
262
- if (typeof i == "number")
263
- return i;
264
- const e = parseFloat(i);
265
- return isNaN(e) ? Z : e;
256
+ const ie = 100;
257
+ function Y(s) {
258
+ if (s == null)
259
+ return ie;
260
+ if (typeof s == "number")
261
+ return s;
262
+ const e = parseFloat(s);
263
+ return isNaN(e) ? ie : e;
266
264
  }
267
- function ee(i) {
268
- return i.map((e) => G(e.width));
265
+ function re(s) {
266
+ return s.map((e) => Y(e.width));
269
267
  }
270
- function te(i) {
268
+ function se(s) {
271
269
  const e = [];
272
270
  let t = 0;
273
- for (const n of i)
274
- e.push(t), t += G(n.width);
271
+ for (const o of s)
272
+ e.push(t), t += Y(o.width);
275
273
  return e;
276
274
  }
277
- function ne(i) {
278
- return i.reduce((e, t) => e + G(t.width), 0);
275
+ function le(s) {
276
+ return s.reduce((e, t) => e + Y(t.width), 0);
279
277
  }
280
- function Ce(i, e, t, n, o) {
281
- const r = t.length;
282
- if (r === 0)
278
+ function Le(s, e, t, o, n) {
279
+ const i = t.length;
280
+ if (i === 0)
283
281
  return { startCol: 0, endCol: 0, visibleColumns: [] };
284
- let s = Se(i, t, n);
285
- s = Math.max(0, s - o);
286
- const l = i + e;
287
- let a = s;
288
- for (let c = s; c < r; c++) {
282
+ let r = Ne(s, t, o);
283
+ r = Math.max(0, r - n);
284
+ const l = s + e;
285
+ let a = r;
286
+ for (let c = r; c < i; c++) {
289
287
  if (t[c] >= l) {
290
288
  a = c - 1;
291
289
  break;
292
290
  }
293
291
  a = c;
294
292
  }
295
- a = Math.min(r - 1, a + o);
293
+ a = Math.min(i - 1, a + n);
296
294
  const d = [];
297
- for (let c = s; c <= a; c++)
295
+ for (let c = r; c <= a; c++)
298
296
  d.push(c);
299
- return { startCol: s, endCol: a, visibleColumns: d };
297
+ return { startCol: r, endCol: a, visibleColumns: d };
300
298
  }
301
- function Se(i, e, t) {
302
- let n = 0, o = e.length - 1;
303
- for (; n < o; ) {
304
- const r = Math.floor((n + o) / 2);
305
- e[r] + t[r] <= i ? n = r + 1 : o = r;
299
+ function Ne(s, e, t) {
300
+ let o = 0, n = e.length - 1;
301
+ for (; o < n; ) {
302
+ const i = Math.floor((o + n) / 2);
303
+ e[i] + t[i] <= s ? o = i + 1 : n = i;
306
304
  }
307
- return n;
305
+ return o;
308
306
  }
309
- function Re(i, e, t) {
310
- return t ? i > e : !1;
307
+ function Me(s, e, t) {
308
+ return t ? s > e : !1;
311
309
  }
312
- class Ct extends y {
310
+ class Zt extends C {
313
311
  name = "columnVirtualization";
314
312
  version = "1.0.0";
315
313
  get defaultConfig() {
316
314
  return {
317
- enabled: !0,
318
315
  autoEnable: !0,
319
316
  threshold: 30,
320
317
  overscan: 3
@@ -332,35 +329,35 @@ class Ct extends y {
332
329
  attach(e) {
333
330
  super.attach(e);
334
331
  const t = this.columns;
335
- this.columnWidths = ee(t), this.columnOffsets = te(t), this.totalWidth = ne(t), this.endCol = t.length - 1;
332
+ this.columnWidths = re(t), this.columnOffsets = se(t), this.totalWidth = le(t), this.endCol = t.length - 1;
336
333
  }
337
334
  detach() {
338
335
  this.columnWidths = [], this.columnOffsets = [], this.isVirtualized = !1, this.startCol = 0, this.endCol = 0, this.scrollLeft = 0, this.totalWidth = 0;
339
336
  }
340
337
  // ===== Hooks =====
341
338
  processColumns(e) {
342
- const t = this.config.enabled && Re(e.length, this.config.threshold ?? 30, this.config.autoEnable ?? !0);
343
- if (this.isVirtualized = t ?? !1, this.columnWidths = ee(e), this.columnOffsets = te(e), this.totalWidth = ne(e), !t)
339
+ const t = Me(e.length, this.config.threshold ?? 30, this.config.autoEnable ?? !0);
340
+ if (this.isVirtualized = t ?? !1, this.columnWidths = re(e), this.columnOffsets = se(e), this.totalWidth = le(e), !t)
344
341
  return this.startCol = 0, this.endCol = e.length - 1, [...e];
345
- const n = this.grid.clientWidth || 800, o = Ce(
342
+ const o = this.grid.clientWidth || 800, n = Le(
346
343
  this.scrollLeft,
347
- n,
344
+ o,
348
345
  this.columnOffsets,
349
346
  this.columnWidths,
350
347
  this.config.overscan ?? 3
351
348
  );
352
- return this.startCol = o.startCol, this.endCol = o.endCol, o.visibleColumns.map((r) => e[r]);
349
+ return this.startCol = n.startCol, this.endCol = n.endCol, n.visibleColumns.map((i) => e[i]);
353
350
  }
354
351
  afterRender() {
355
352
  if (!this.isVirtualized) return;
356
353
  const e = this.shadowRoot;
357
354
  if (!e) return;
358
- const t = this.columnOffsets[this.startCol] ?? 0, n = e.querySelector(".header-row"), o = e.querySelectorAll(".data-grid-row");
359
- n && (n.style.paddingLeft = `${t}px`), o.forEach((s) => {
360
- s.style.paddingLeft = `${t}px`;
355
+ const t = this.columnOffsets[this.startCol] ?? 0, o = e.querySelector(".header-row"), n = e.querySelectorAll(".data-grid-row");
356
+ o && (o.style.paddingLeft = `${t}px`), n.forEach((r) => {
357
+ r.style.paddingLeft = `${t}px`;
361
358
  });
362
- const r = e.querySelector(".rows-viewport .rows");
363
- r && (r.style.width = `${this.totalWidth}px`);
359
+ const i = e.querySelector(".rows-viewport .rows");
360
+ i && (i.style.width = `${this.totalWidth}px`);
364
361
  }
365
362
  onScroll(e) {
366
363
  !this.isVirtualized || Math.abs(e.scrollLeft - this.scrollLeft) < 1 || (this.scrollLeft = e.scrollLeft, this.requestRender());
@@ -383,8 +380,8 @@ class Ct extends y {
383
380
  * @param columnIndex - Index of the column to scroll to
384
381
  */
385
382
  scrollToColumn(e) {
386
- const t = this.columnOffsets[e] ?? 0, n = this.grid;
387
- n.scrollLeft = t;
383
+ const t = this.columnOffsets[e] ?? 0, o = this.grid;
384
+ o.scrollLeft = t;
388
385
  }
389
386
  /**
390
387
  * Get the left offset for a specific column.
@@ -400,132 +397,81 @@ class Ct extends y {
400
397
  return this.totalWidth;
401
398
  }
402
399
  }
403
- function V(i, e) {
404
- return (typeof i == "function" ? i(e) : i).filter((n) => !(n.hidden === !0 || typeof n.hidden == "function" && n.hidden(e)));
400
+ const Pe = ".tbw-context-menu{position:fixed;background:light-dark(#f5f5f5,#2a2a2a);color:light-dark(#222,#eee);border:1px solid light-dark(#d0d0d4,#454545);border-radius:4px;box-shadow:0 2px 10px #00000026;min-width:160px;padding:4px 0;z-index:10000;font-size:13px;font-family:system-ui,sans-serif}.tbw-context-menu-item{display:flex;align-items:center;padding:6px 12px;cursor:pointer;gap:8px}.tbw-context-menu-item:hover:not(.disabled){background:light-dark(#e8e8e8,#3a3a3a)}.tbw-context-menu-item.disabled{opacity:.5;cursor:default}.tbw-context-menu-item.danger{color:light-dark(#c00,#f66)}.tbw-context-menu-icon{width:16px;text-align:center}.tbw-context-menu-label{flex:1}.tbw-context-menu-shortcut{color:light-dark(#888,#888);font-size:11px}.tbw-context-menu-arrow{font-size:10px;color:light-dark(#888,#888)}.tbw-context-menu-separator{height:1px;background:light-dark(#d0d0d4,#454545);margin:4px 0}";
401
+ function j(s, e) {
402
+ return (typeof s == "function" ? s(e) : s).filter((o) => !(o.hidden === !0 || typeof o.hidden == "function" && o.hidden(e)));
405
403
  }
406
- function ke(i, e) {
407
- return i.disabled === !0 ? !0 : typeof i.disabled == "function" ? i.disabled(e) : !1;
404
+ function De(s, e) {
405
+ return s.disabled === !0 ? !0 : typeof s.disabled == "function" ? s.disabled(e) : !1;
408
406
  }
409
- function K(i, e, t, n = xe.submenuArrow) {
410
- const o = document.createElement("div");
411
- o.className = "tbw-context-menu", o.setAttribute("role", "menu");
412
- for (const r of i) {
413
- if (r.separator) {
407
+ function U(s, e, t, o = _e.submenuArrow) {
408
+ const n = document.createElement("div");
409
+ n.className = "tbw-context-menu", n.setAttribute("role", "menu");
410
+ for (const i of s) {
411
+ if (i.separator) {
414
412
  const d = document.createElement("div");
415
- d.className = "tbw-context-menu-separator", d.setAttribute("role", "separator"), o.appendChild(d);
413
+ d.className = "tbw-context-menu-separator", d.setAttribute("role", "separator"), n.appendChild(d);
416
414
  continue;
417
415
  }
418
- const s = document.createElement("div");
419
- s.className = "tbw-context-menu-item", r.cssClass && s.classList.add(r.cssClass), s.setAttribute("role", "menuitem"), s.setAttribute("data-id", r.id);
420
- const l = ke(r, e);
421
- if (l && (s.classList.add("disabled"), s.setAttribute("aria-disabled", "true")), r.icon) {
416
+ const r = document.createElement("div");
417
+ r.className = "tbw-context-menu-item", i.cssClass && r.classList.add(i.cssClass), r.setAttribute("role", "menuitem"), r.setAttribute("data-id", i.id);
418
+ const l = De(i, e);
419
+ if (l && (r.classList.add("disabled"), r.setAttribute("aria-disabled", "true")), i.icon) {
422
420
  const d = document.createElement("span");
423
- d.className = "tbw-context-menu-icon", d.innerHTML = r.icon, s.appendChild(d);
421
+ d.className = "tbw-context-menu-icon", d.innerHTML = i.icon, r.appendChild(d);
424
422
  }
425
423
  const a = document.createElement("span");
426
- if (a.className = "tbw-context-menu-label", a.textContent = r.name, s.appendChild(a), r.shortcut) {
424
+ if (a.className = "tbw-context-menu-label", a.textContent = i.name, r.appendChild(a), i.shortcut) {
427
425
  const d = document.createElement("span");
428
- d.className = "tbw-context-menu-shortcut", d.textContent = r.shortcut, s.appendChild(d);
426
+ d.className = "tbw-context-menu-shortcut", d.textContent = i.shortcut, r.appendChild(d);
429
427
  }
430
- if (r.subMenu?.length) {
428
+ if (i.subMenu?.length) {
431
429
  const d = document.createElement("span");
432
- d.className = "tbw-context-menu-arrow", typeof n == "string" ? d.innerHTML = n : n instanceof HTMLElement && d.appendChild(n.cloneNode(!0)), s.appendChild(d), s.addEventListener("mouseenter", () => {
433
- if (s.querySelector(".tbw-context-menu") || !r.subMenu) return;
434
- const u = V(r.subMenu, e), h = K(u, e, t, n);
435
- h.classList.add("tbw-context-submenu"), h.style.position = "absolute", h.style.left = "100%", h.style.top = "0", s.style.position = "relative", s.appendChild(h);
436
- }), s.addEventListener("mouseleave", () => {
437
- const c = s.querySelector(".tbw-context-menu");
430
+ d.className = "tbw-context-menu-arrow", typeof o == "string" ? d.innerHTML = o : o instanceof HTMLElement && d.appendChild(o.cloneNode(!0)), r.appendChild(d), r.addEventListener("mouseenter", () => {
431
+ if (r.querySelector(".tbw-context-menu") || !i.subMenu) return;
432
+ const u = j(i.subMenu, e), h = U(u, e, t, o);
433
+ h.classList.add("tbw-context-submenu"), h.style.position = "absolute", h.style.left = "100%", h.style.top = "0", r.style.position = "relative", r.appendChild(h);
434
+ }), r.addEventListener("mouseleave", () => {
435
+ const c = r.querySelector(".tbw-context-menu");
438
436
  c && c.remove();
439
437
  });
440
438
  }
441
- !l && r.action && !r.subMenu && s.addEventListener("click", (d) => {
442
- d.stopPropagation(), t(r);
443
- }), o.appendChild(s);
439
+ !l && i.action && !i.subMenu && r.addEventListener("click", (d) => {
440
+ d.stopPropagation(), t(i);
441
+ }), n.appendChild(r);
444
442
  }
445
- return o;
443
+ return n;
444
+ }
445
+ function ae(s, e, t) {
446
+ s.style.position = "fixed", s.style.left = `${e}px`, s.style.top = `${t}px`, s.style.visibility = "hidden", s.style.zIndex = "10000";
447
+ const o = s.getBoundingClientRect(), n = window.innerWidth, i = window.innerHeight;
448
+ let r = e, l = t;
449
+ e + o.width > n && (r = e - o.width), t + o.height > i && (l = t - o.height), r = Math.max(0, r), l = Math.max(0, l), s.style.left = `${r}px`, s.style.top = `${l}px`, s.style.visibility = "visible";
446
450
  }
447
- function oe(i, e, t) {
448
- i.style.position = "fixed", i.style.left = `${e}px`, i.style.top = `${t}px`, i.style.visibility = "hidden", i.style.zIndex = "10000";
449
- const n = i.getBoundingClientRect(), o = window.innerWidth, r = window.innerHeight;
450
- let s = e, l = t;
451
- e + n.width > o && (s = e - n.width), t + n.height > r && (l = t - n.height), s = Math.max(0, s), l = Math.max(0, l), i.style.left = `${s}px`, i.style.top = `${l}px`, i.style.visibility = "visible";
452
- }
453
- let D = null, P = null, A = null;
454
- const Ee = `
455
- .tbw-context-menu {
456
- position: fixed;
457
- background: light-dark(#f5f5f5, #2a2a2a);
458
- color: light-dark(#222, #eee);
459
- border: 1px solid light-dark(#d0d0d4, #454545);
460
- border-radius: 4px;
461
- box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
462
- min-width: 160px;
463
- padding: 4px 0;
464
- z-index: 10000;
465
- font-size: 13px;
466
- font-family: system-ui, sans-serif;
467
- }
468
- .tbw-context-menu-item {
469
- display: flex;
470
- align-items: center;
471
- padding: 6px 12px;
472
- cursor: pointer;
473
- gap: 8px;
474
- }
475
- .tbw-context-menu-item:hover:not(.disabled) {
476
- background: light-dark(#e8e8e8, #3a3a3a);
477
- }
478
- .tbw-context-menu-item.disabled {
479
- opacity: 0.5;
480
- cursor: default;
481
- }
482
- .tbw-context-menu-item.danger {
483
- color: light-dark(#c00, #f66);
484
- }
485
- .tbw-context-menu-icon {
486
- width: 16px;
487
- text-align: center;
488
- }
489
- .tbw-context-menu-label {
490
- flex: 1;
491
- }
492
- .tbw-context-menu-shortcut {
493
- color: light-dark(#888, #888);
494
- font-size: 11px;
495
- }
496
- .tbw-context-menu-arrow {
497
- font-size: 10px;
498
- color: light-dark(#888, #888);
499
- }
500
- .tbw-context-menu-separator {
501
- height: 1px;
502
- background: light-dark(#d0d0d4, #454545);
503
- margin: 4px 0;
504
- }
505
- `, B = [
451
+ let _ = null, I = null, E = null, O = 0;
452
+ const B = [
506
453
  {
507
454
  id: "copy",
508
455
  name: "Copy",
509
456
  shortcut: "Ctrl+C",
510
- action: (i) => {
511
- i.grid?.plugins?.clipboard?.copy?.();
457
+ action: (s) => {
458
+ s.grid?.plugins?.clipboard?.copy?.();
512
459
  }
513
460
  },
514
461
  { separator: !0, id: "sep1", name: "" },
515
462
  {
516
463
  id: "export-csv",
517
464
  name: "Export CSV",
518
- action: (i) => {
519
- i.grid?.plugins?.export?.exportCsv?.();
465
+ action: (s) => {
466
+ s.grid?.plugins?.export?.exportCsv?.();
520
467
  }
521
468
  }
522
469
  ];
523
- class St extends y {
470
+ class Xt extends C {
524
471
  name = "contextMenu";
525
472
  version = "1.0.0";
526
473
  get defaultConfig() {
527
474
  return {
528
- enabled: !0,
529
475
  items: B
530
476
  };
531
477
  }
@@ -536,42 +482,47 @@ class St extends y {
536
482
  menuElement = null;
537
483
  // ===== Lifecycle =====
538
484
  attach(e) {
539
- super.attach(e), this.installGlobalHandlers();
485
+ super.attach(e), this.installGlobalHandlers(), O++;
540
486
  }
541
487
  detach() {
542
- this.menuElement && (this.menuElement.remove(), this.menuElement = null), this.isOpen = !1, this.params = null;
488
+ this.menuElement && (this.menuElement.remove(), this.menuElement = null), this.isOpen = !1, this.params = null, this.uninstallGlobalHandlers();
543
489
  }
544
490
  // ===== Private Methods =====
545
491
  installGlobalHandlers() {
546
- !A && typeof document < "u" && (A = document.createElement("style"), A.id = "tbw-context-menu-styles", A.textContent = Ee, document.head.appendChild(A)), D || (D = () => {
492
+ !E && typeof document < "u" && (E = document.createElement("style"), E.id = "tbw-context-menu-styles", E.textContent = Pe, document.head.appendChild(E)), _ || (_ = () => {
547
493
  document.querySelectorAll(".tbw-context-menu").forEach((t) => t.remove());
548
- }, document.addEventListener("click", D)), P || (P = (e) => {
549
- e.key === "Escape" && document.querySelectorAll(".tbw-context-menu").forEach((n) => n.remove());
550
- }, document.addEventListener("keydown", P));
494
+ }, document.addEventListener("click", _)), I || (I = (e) => {
495
+ e.key === "Escape" && document.querySelectorAll(".tbw-context-menu").forEach((o) => o.remove());
496
+ }, document.addEventListener("keydown", I));
497
+ }
498
+ /**
499
+ * Clean up global handlers when the last instance detaches.
500
+ * Uses reference counting to ensure handlers persist while any grid uses the plugin.
501
+ */
502
+ uninstallGlobalHandlers() {
503
+ O--, !(O > 0) && (_ && (document.removeEventListener("click", _), _ = null), I && (document.removeEventListener("keydown", I), I = null), E && (E.remove(), E = null));
551
504
  }
552
505
  // ===== Hooks =====
553
506
  afterRender() {
554
- if (!this.config.enabled) return;
555
507
  const e = this.shadowRoot;
556
508
  if (!e) return;
557
509
  const t = e.children[0];
558
- t && t.getAttribute("data-context-menu-bound") !== "true" && (t.setAttribute("data-context-menu-bound", "true"), t.addEventListener("contextmenu", (n) => {
559
- if (!this.config.enabled) return;
560
- const o = n;
561
- o.preventDefault();
562
- const r = o.target, s = r.closest("[data-row][data-col]"), l = r.closest(".header-cell");
510
+ t && t.getAttribute("data-context-menu-bound") !== "true" && (t.setAttribute("data-context-menu-bound", "true"), t.addEventListener("contextmenu", (o) => {
511
+ const n = o;
512
+ n.preventDefault();
513
+ const i = n.target, r = i.closest("[data-row][data-col]"), l = i.closest(".header-cell");
563
514
  let a;
564
- if (s) {
565
- const c = parseInt(s.getAttribute("data-row") ?? "-1", 10), u = parseInt(s.getAttribute("data-col") ?? "-1", 10), h = this.columns[u], f = this.rows[c];
515
+ if (r) {
516
+ const c = parseInt(r.getAttribute("data-row") ?? "-1", 10), u = parseInt(r.getAttribute("data-col") ?? "-1", 10), h = this.columns[u], p = this.rows[c];
566
517
  a = {
567
- row: f,
518
+ row: p,
568
519
  rowIndex: c,
569
520
  column: h,
570
521
  columnIndex: u,
571
522
  field: h?.field ?? "",
572
- value: f?.[h?.field] ?? null,
523
+ value: p?.[h?.field] ?? null,
573
524
  isHeader: !1,
574
- event: o
525
+ event: n
575
526
  };
576
527
  } else if (l) {
577
528
  const c = parseInt(l.getAttribute("data-col") ?? "-1", 10), u = this.columns[c];
@@ -583,20 +534,20 @@ class St extends y {
583
534
  field: u?.field ?? "",
584
535
  value: null,
585
536
  isHeader: !0,
586
- event: o
537
+ event: n
587
538
  };
588
539
  } else
589
540
  return;
590
- this.params = a, this.position = { x: o.clientX, y: o.clientY };
591
- const d = V(this.config.items ?? B, a);
592
- d.length && (this.menuElement && this.menuElement.remove(), this.menuElement = K(
541
+ this.params = a, this.position = { x: n.clientX, y: n.clientY };
542
+ const d = j(this.config.items ?? B, a);
543
+ d.length && (this.menuElement && this.menuElement.remove(), this.menuElement = U(
593
544
  d,
594
545
  a,
595
546
  (c) => {
596
547
  c.action && c.action(a), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
597
548
  },
598
549
  this.gridIcons.submenuArrow
599
- ), document.body.appendChild(this.menuElement), oe(this.menuElement, o.clientX, o.clientY), this.isOpen = !0, this.emit("context-menu-open", { params: a, items: d }));
550
+ ), document.body.appendChild(this.menuElement), ae(this.menuElement, n.clientX, n.clientY), this.isOpen = !0, this.emit("context-menu-open", { params: a, items: d }));
600
551
  }));
601
552
  }
602
553
  // ===== Public API =====
@@ -606,25 +557,25 @@ class St extends y {
606
557
  * @param y - Y coordinate
607
558
  * @param params - Partial context menu parameters
608
559
  */
609
- showMenu(e, t, n) {
610
- const o = {
611
- row: n.row ?? null,
612
- rowIndex: n.rowIndex ?? -1,
613
- column: n.column ?? null,
614
- columnIndex: n.columnIndex ?? -1,
615
- field: n.field ?? "",
616
- value: n.value ?? null,
617
- isHeader: n.isHeader ?? !1,
618
- event: n.event ?? new MouseEvent("contextmenu")
619
- }, r = V(this.config.items ?? B, o);
620
- this.menuElement && this.menuElement.remove(), this.menuElement = K(
621
- r,
622
- o,
623
- (s) => {
624
- s.action && s.action(o), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
560
+ showMenu(e, t, o) {
561
+ const n = {
562
+ row: o.row ?? null,
563
+ rowIndex: o.rowIndex ?? -1,
564
+ column: o.column ?? null,
565
+ columnIndex: o.columnIndex ?? -1,
566
+ field: o.field ?? "",
567
+ value: o.value ?? null,
568
+ isHeader: o.isHeader ?? !1,
569
+ event: o.event ?? new MouseEvent("contextmenu")
570
+ }, i = j(this.config.items ?? B, n);
571
+ this.menuElement && this.menuElement.remove(), this.menuElement = U(
572
+ i,
573
+ n,
574
+ (r) => {
575
+ r.action && r.action(n), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
625
576
  },
626
577
  this.gridIcons.submenuArrow
627
- ), document.body.appendChild(this.menuElement), oe(this.menuElement, e, t), this.isOpen = !0;
578
+ ), document.body.appendChild(this.menuElement), ae(this.menuElement, e, t), this.isOpen = !0;
628
579
  }
629
580
  /**
630
581
  * Hide the context menu.
@@ -641,88 +592,87 @@ class St extends y {
641
592
  }
642
593
  // Styles are injected globally via installGlobalHandlers() since menu renders in document.body
643
594
  }
644
- function re(i, e = !0) {
645
- if (i == null) return "";
646
- if (i instanceof Date) return i.toISOString();
647
- if (typeof i == "object") return JSON.stringify(i);
648
- const t = String(i);
595
+ function de(s, e = !0) {
596
+ if (s == null) return "";
597
+ if (s instanceof Date) return s.toISOString();
598
+ if (typeof s == "object") return JSON.stringify(s);
599
+ const t = String(s);
649
600
  return e && (t.includes(",") || t.includes('"') || t.includes(`
650
601
  `) || t.includes("\r")) ? `"${t.replace(/"/g, '""')}"` : t;
651
602
  }
652
- function Ae(i, e, t, n = {}) {
653
- const o = n.delimiter ?? ",", r = n.newline ?? `
654
- `, s = [], l = n.bom ? "\uFEFF" : "";
603
+ function qe(s, e, t, o = {}) {
604
+ const n = o.delimiter ?? ",", i = o.newline ?? `
605
+ `, r = [], l = o.bom ? "\uFEFF" : "";
655
606
  if (t.includeHeaders !== !1) {
656
607
  const a = e.map((d) => {
657
608
  const c = d.header || d.field, u = t.processHeader ? t.processHeader(c, d.field) : c;
658
- return re(u);
609
+ return de(u);
659
610
  });
660
- s.push(a.join(o));
611
+ r.push(a.join(n));
661
612
  }
662
- for (const a of i) {
613
+ for (const a of s) {
663
614
  const d = e.map((c) => {
664
615
  let u = a[c.field];
665
- return t.processCell && (u = t.processCell(u, c.field, a)), re(u);
616
+ return t.processCell && (u = t.processCell(u, c.field, a)), de(u);
666
617
  });
667
- s.push(d.join(o));
618
+ r.push(d.join(n));
668
619
  }
669
- return l + s.join(r);
620
+ return l + r.join(i);
670
621
  }
671
- function z(i, e) {
672
- const t = URL.createObjectURL(i), n = document.createElement("a");
673
- n.href = t, n.download = e, n.style.display = "none", document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(t);
622
+ function Z(s, e) {
623
+ const t = URL.createObjectURL(s), o = document.createElement("a");
624
+ o.href = t, o.download = e, o.style.display = "none", document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(t);
674
625
  }
675
- function Ie(i, e) {
676
- const t = new Blob([i], { type: "text/csv;charset=utf-8;" });
677
- z(t, e);
626
+ function He(s, e) {
627
+ const t = new Blob([s], { type: "text/csv;charset=utf-8;" });
628
+ Z(t, e);
678
629
  }
679
- function ie(i) {
680
- return i.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
630
+ function ce(s) {
631
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
681
632
  }
682
- function _e(i, e, t) {
683
- let n = `<?xml version="1.0" encoding="UTF-8"?>
633
+ function Ge(s, e, t) {
634
+ let o = `<?xml version="1.0" encoding="UTF-8"?>
684
635
  <?mso-application progid="Excel.Sheet"?>
685
636
  <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
686
637
  xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
687
638
  <Worksheet ss:Name="Sheet1">
688
639
  <Table>`;
689
640
  if (t.includeHeaders !== !1) {
690
- n += `
641
+ o += `
691
642
  <Row>`;
692
- for (const o of e) {
693
- const r = o.header || o.field, s = t.processHeader ? t.processHeader(r, o.field) : r;
694
- n += `<Cell><Data ss:Type="String">${ie(s)}</Data></Cell>`;
643
+ for (const n of e) {
644
+ const i = n.header || n.field, r = t.processHeader ? t.processHeader(i, n.field) : i;
645
+ o += `<Cell><Data ss:Type="String">${ce(r)}</Data></Cell>`;
695
646
  }
696
- n += "</Row>";
647
+ o += "</Row>";
697
648
  }
698
- for (const o of i) {
699
- n += `
649
+ for (const n of s) {
650
+ o += `
700
651
  <Row>`;
701
- for (const r of e) {
702
- let s = o[r.field];
703
- t.processCell && (s = t.processCell(s, r.field, o));
652
+ for (const i of e) {
653
+ let r = n[i.field];
654
+ t.processCell && (r = t.processCell(r, i.field, n));
704
655
  let l = "String", a = "";
705
- s == null ? a = "" : typeof s == "number" && !isNaN(s) ? (l = "Number", a = String(s)) : s instanceof Date ? (l = "DateTime", a = s.toISOString()) : a = ie(String(s)), n += `<Cell><Data ss:Type="${l}">${a}</Data></Cell>`;
656
+ r == null ? a = "" : typeof r == "number" && !isNaN(r) ? (l = "Number", a = String(r)) : r instanceof Date ? (l = "DateTime", a = r.toISOString()) : a = ce(String(r)), o += `<Cell><Data ss:Type="${l}">${a}</Data></Cell>`;
706
657
  }
707
- n += "</Row>";
658
+ o += "</Row>";
708
659
  }
709
- return n += `
660
+ return o += `
710
661
  </Table>
711
662
  </Worksheet>
712
- </Workbook>`, n;
663
+ </Workbook>`, o;
713
664
  }
714
- function Te(i, e) {
715
- const t = e.endsWith(".xls") ? e : `${e}.xls`, n = new Blob([i], {
665
+ function Oe(s, e) {
666
+ const t = e.endsWith(".xls") ? e : `${e}.xls`, o = new Blob([s], {
716
667
  type: "application/vnd.ms-excel;charset=utf-8;"
717
668
  });
718
- z(n, t);
669
+ Z(o, t);
719
670
  }
720
- class Rt extends y {
671
+ class Jt extends C {
721
672
  name = "export";
722
673
  version = "1.0.0";
723
674
  get defaultConfig() {
724
675
  return {
725
- enabled: !0,
726
676
  fileName: "export",
727
677
  includeHeaders: !0,
728
678
  onlyVisible: !0,
@@ -734,59 +684,59 @@ class Rt extends y {
734
684
  lastExportInfo = null;
735
685
  // ===== Private Methods =====
736
686
  performExport(e, t) {
737
- const n = this.config, o = {
687
+ const o = this.config, n = {
738
688
  format: e,
739
- fileName: t?.fileName ?? n.fileName ?? "export",
740
- includeHeaders: t?.includeHeaders ?? n.includeHeaders,
689
+ fileName: t?.fileName ?? o.fileName ?? "export",
690
+ includeHeaders: t?.includeHeaders ?? o.includeHeaders,
741
691
  processCell: t?.processCell,
742
692
  processHeader: t?.processHeader,
743
693
  columns: t?.columns,
744
694
  rowIndices: t?.rowIndices
745
695
  };
746
- let r = [...this.columns];
747
- if (n.onlyVisible && (r = r.filter((a) => !a.hidden && !a.field.startsWith("__"))), t?.columns) {
696
+ let i = [...this.columns];
697
+ if (o.onlyVisible && (i = i.filter((a) => !a.hidden && !a.field.startsWith("__"))), t?.columns) {
748
698
  const a = new Set(t.columns);
749
- r = r.filter((d) => a.has(d.field));
699
+ i = i.filter((d) => a.has(d.field));
750
700
  }
751
- let s = [...this.rows];
752
- if (n.onlySelected) {
701
+ let r = [...this.rows];
702
+ if (o.onlySelected) {
753
703
  const a = this.getSelectionState();
754
- a?.selected?.size && (s = [...a.selected].sort((c, u) => c - u).map((c) => this.rows[c]).filter(Boolean));
704
+ a?.selected?.size && (r = [...a.selected].sort((c, u) => c - u).map((c) => this.rows[c]).filter(Boolean));
755
705
  }
756
- t?.rowIndices && (s = t.rowIndices.map((a) => this.rows[a]).filter(Boolean)), this.isExportingFlag = !0;
757
- let l = o.fileName;
706
+ t?.rowIndices && (r = t.rowIndices.map((a) => this.rows[a]).filter(Boolean)), this.isExportingFlag = !0;
707
+ let l = n.fileName;
758
708
  try {
759
709
  switch (e) {
760
710
  case "csv": {
761
- const a = Ae(s, r, o, { bom: !0 });
762
- l = l.endsWith(".csv") ? l : `${l}.csv`, Ie(a, l);
711
+ const a = qe(r, i, n, { bom: !0 });
712
+ l = l.endsWith(".csv") ? l : `${l}.csv`, He(a, l);
763
713
  break;
764
714
  }
765
715
  case "excel": {
766
- const a = _e(s, r, o);
767
- l = l.endsWith(".xls") ? l : `${l}.xls`, Te(a, l);
716
+ const a = Ge(r, i, n);
717
+ l = l.endsWith(".xls") ? l : `${l}.xls`, Oe(a, l);
768
718
  break;
769
719
  }
770
720
  case "json": {
771
- const a = s.map((u) => {
721
+ const a = r.map((u) => {
772
722
  const h = {};
773
- for (const f of r) {
774
- let g = u[f.field];
775
- o.processCell && (g = o.processCell(g, f.field, u)), h[f.field] = g;
723
+ for (const p of i) {
724
+ let g = u[p.field];
725
+ n.processCell && (g = n.processCell(g, p.field, u)), h[p.field] = g;
776
726
  }
777
727
  return h;
778
728
  }), d = JSON.stringify(a, null, 2);
779
729
  l = l.endsWith(".json") ? l : `${l}.json`;
780
730
  const c = new Blob([d], { type: "application/json" });
781
- z(c, l);
731
+ Z(c, l);
782
732
  break;
783
733
  }
784
734
  }
785
735
  this.lastExportInfo = { format: e, timestamp: /* @__PURE__ */ new Date() }, this.emit("export-complete", {
786
736
  format: e,
787
737
  fileName: l,
788
- rowCount: s.length,
789
- columnCount: r.length
738
+ rowCount: r.length,
739
+ columnCount: i.length
790
740
  });
791
741
  } finally {
792
742
  this.isExportingFlag = !1;
@@ -836,69 +786,69 @@ class Rt extends y {
836
786
  return this.lastExportInfo;
837
787
  }
838
788
  }
839
- function Le(i) {
840
- const { totalRows: e, viewportHeight: t, scrollTop: n, rowHeight: o, overscan: r } = i, s = Math.ceil(t / o);
841
- let l = Math.floor(n / o) - r;
789
+ function Be(s) {
790
+ const { totalRows: e, viewportHeight: t, scrollTop: o, rowHeight: n, overscan: i } = s, r = Math.ceil(t / n);
791
+ let l = Math.floor(o / n) - i;
842
792
  l < 0 && (l = 0);
843
- let a = l + s + r * 2;
844
- return a > e && (a = e), a === e && l > 0 && (l = Math.max(0, a - s - r * 2)), {
793
+ let a = l + r + i * 2;
794
+ return a > e && (a = e), a === e && l > 0 && (l = Math.max(0, a - r - i * 2)), {
845
795
  start: l,
846
796
  end: a,
847
- offsetY: l * o,
848
- totalHeight: e * o
797
+ offsetY: l * n,
798
+ totalHeight: e * n
849
799
  };
850
800
  }
851
- function Me(i, e) {
852
- return i <= e;
801
+ function Ve(s, e) {
802
+ return s <= e;
853
803
  }
854
- function qe(i, e, t = !1) {
855
- const n = i[e.field];
804
+ function Ke(s, e, t = !1) {
805
+ const o = s[e.field];
856
806
  if (e.operator === "blank")
857
- return n == null || n === "";
807
+ return o == null || o === "";
858
808
  if (e.operator === "notBlank")
859
- return n != null && n !== "";
860
- if (n == null) return !1;
861
- const o = String(n), r = t ? o : o.toLowerCase(), s = t ? String(e.value) : String(e.value).toLowerCase();
809
+ return o != null && o !== "";
810
+ if (o == null) return !1;
811
+ const n = String(o), i = t ? n : n.toLowerCase(), r = t ? String(e.value) : String(e.value).toLowerCase();
862
812
  switch (e.operator) {
863
813
  // Text operators
864
814
  case "contains":
865
- return r.includes(s);
815
+ return i.includes(r);
866
816
  case "notContains":
867
- return !r.includes(s);
817
+ return !i.includes(r);
868
818
  case "equals":
869
- return r === s;
819
+ return i === r;
870
820
  case "notEquals":
871
- return r !== s;
821
+ return i !== r;
872
822
  case "startsWith":
873
- return r.startsWith(s);
823
+ return i.startsWith(r);
874
824
  case "endsWith":
875
- return r.endsWith(s);
825
+ return i.endsWith(r);
876
826
  // Number/Date operators (use raw numeric values)
877
827
  case "lessThan":
878
- return Number(n) < Number(e.value);
828
+ return Number(o) < Number(e.value);
879
829
  case "lessThanOrEqual":
880
- return Number(n) <= Number(e.value);
830
+ return Number(o) <= Number(e.value);
881
831
  case "greaterThan":
882
- return Number(n) > Number(e.value);
832
+ return Number(o) > Number(e.value);
883
833
  case "greaterThanOrEqual":
884
- return Number(n) >= Number(e.value);
834
+ return Number(o) >= Number(e.value);
885
835
  case "between":
886
- return Number(n) >= Number(e.value) && Number(n) <= Number(e.valueTo);
836
+ return Number(o) >= Number(e.value) && Number(o) <= Number(e.valueTo);
887
837
  // Set operators
888
838
  case "in":
889
- return Array.isArray(e.value) && e.value.includes(n);
839
+ return Array.isArray(e.value) && e.value.includes(o);
890
840
  case "notIn":
891
- return Array.isArray(e.value) && !e.value.includes(n);
841
+ return Array.isArray(e.value) && !e.value.includes(o);
892
842
  default:
893
843
  return !0;
894
844
  }
895
845
  }
896
- function Fe(i, e, t = !1) {
897
- return e.length ? i.filter((n) => e.every((o) => qe(n, o, t))) : i;
846
+ function ze(s, e, t = !1) {
847
+ return e.length ? s.filter((o) => e.every((n) => Ke(o, n, t))) : s;
898
848
  }
899
- function Ne(i) {
849
+ function We(s) {
900
850
  return JSON.stringify(
901
- i.map((e) => ({
851
+ s.map((e) => ({
902
852
  field: e.field,
903
853
  operator: e.operator,
904
854
  value: e.value,
@@ -906,15 +856,15 @@ function Ne(i) {
906
856
  }))
907
857
  );
908
858
  }
909
- function se(i, e) {
859
+ function ue(s, e) {
910
860
  const t = /* @__PURE__ */ new Set();
911
- for (const n of i) {
912
- const o = n[e];
913
- o != null && t.add(o);
861
+ for (const o of s) {
862
+ const n = o[e];
863
+ n != null && t.add(n);
914
864
  }
915
- return [...t].sort((n, o) => typeof n == "number" && typeof o == "number" ? n - o : String(n).localeCompare(String(o)));
865
+ return [...t].sort((o, n) => typeof o == "number" && typeof n == "number" ? o - n : String(o).localeCompare(String(n)));
916
866
  }
917
- const De = `
867
+ const $e = '.header-cell.filtered:before{content:"";position:absolute;top:4px;right:4px;width:6px;height:6px;background:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));border-radius:50%}.tbw-filter-btn{display:inline-flex;align-items:center;justify-content:center;background:transparent;border:none;cursor:pointer;padding:2px;margin-left:4px;opacity:.4;transition:opacity .15s;color:inherit;vertical-align:middle}.tbw-filter-btn:hover,.tbw-filter-btn.active{opacity:1}.tbw-filter-btn.active{color:var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6))}', je = `
918
868
  .tbw-filter-panel {
919
869
  position: fixed;
920
870
  background: var(--tbw-filter-panel-bg, var(--tbw-color-panel-bg, light-dark(#eeeeee, #222222)));
@@ -1056,12 +1006,11 @@ const De = `
1056
1006
  background: var(--tbw-filter-hover, var(--tbw-color-row-hover, light-dark(#f0f6ff, #1c1c1c)));
1057
1007
  }
1058
1008
  `;
1059
- class E extends y {
1009
+ class A extends C {
1060
1010
  name = "filtering";
1061
1011
  version = "1.0.0";
1062
1012
  get defaultConfig() {
1063
1013
  return {
1064
- enabled: !0,
1065
1014
  debounceMs: 300,
1066
1015
  caseSensitive: !1,
1067
1016
  trimInput: !0,
@@ -1095,27 +1044,26 @@ class E extends y {
1095
1044
  processRows(e) {
1096
1045
  const t = [...this.filters.values()];
1097
1046
  if (!t.length) return [...e];
1098
- const n = Ne(t);
1099
- if (this.cacheKey === n && this.cachedResult)
1047
+ const o = We(t);
1048
+ if (this.cacheKey === o && this.cachedResult)
1100
1049
  return this.cachedResult;
1101
- const o = Fe([...e], t, this.config.caseSensitive);
1102
- return this.cachedResult = o, this.cacheKey = n, o;
1050
+ const n = ze([...e], t, this.config.caseSensitive);
1051
+ return this.cachedResult = n, this.cacheKey = o, n;
1103
1052
  }
1104
1053
  afterRender() {
1105
- if (!this.config.enabled) return;
1106
1054
  const e = this.shadowRoot;
1107
1055
  if (!e) return;
1108
- e.querySelectorAll('[part~="header-cell"]').forEach((n) => {
1109
- const o = n.getAttribute("data-col");
1110
- if (o === null) return;
1111
- const r = this.columns[parseInt(o, 10)];
1112
- if (!r || r.filterable === !1 || n.querySelector(".tbw-filter-btn")) return;
1113
- const s = r.field;
1114
- if (!s) return;
1056
+ e.querySelectorAll('[part~="header-cell"]').forEach((o) => {
1057
+ const n = o.getAttribute("data-col");
1058
+ if (n === null) return;
1059
+ const i = this.columns[parseInt(n, 10)];
1060
+ if (!i || i.filterable === !1 || o.querySelector(".tbw-filter-btn")) return;
1061
+ const r = i.field;
1062
+ if (!r) return;
1115
1063
  const l = document.createElement("button");
1116
- l.className = "tbw-filter-btn", l.setAttribute("aria-label", `Filter ${r.header ?? s}`), l.innerHTML = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>', this.filters.has(s) && (l.classList.add("active"), n.classList.add("filtered")), l.addEventListener("click", (a) => {
1117
- a.stopPropagation(), this.toggleFilterPanel(s, r, l);
1118
- }), n.appendChild(l);
1064
+ l.className = "tbw-filter-btn", l.setAttribute("aria-label", `Filter ${i.header ?? r}`), l.innerHTML = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>', this.filters.has(r) && (l.classList.add("active"), o.classList.add("filtered")), l.addEventListener("click", (a) => {
1065
+ a.stopPropagation(), this.toggleFilterPanel(r, i, l);
1066
+ }), o.appendChild(l);
1119
1067
  });
1120
1068
  }
1121
1069
  // ===== Public API =====
@@ -1201,7 +1149,7 @@ class E extends y {
1201
1149
  * Uses sourceRows to include all values regardless of current filter.
1202
1150
  */
1203
1151
  getUniqueValues(e) {
1204
- return se(this.sourceRows, e);
1152
+ return ue(this.sourceRows, e);
1205
1153
  }
1206
1154
  // ===== Private Methods =====
1207
1155
  /**
@@ -1214,27 +1162,27 @@ class E extends y {
1214
1162
  return;
1215
1163
  }
1216
1164
  const e = document.createElement("style");
1217
- e.id = "tbw-filter-panel-styles", e.textContent = De, document.head.appendChild(e), this.globalStylesInjected = !0;
1165
+ e.id = "tbw-filter-panel-styles", e.textContent = je, document.head.appendChild(e), this.globalStylesInjected = !0;
1218
1166
  }
1219
1167
  /**
1220
1168
  * Toggle the filter panel for a field
1221
1169
  */
1222
- toggleFilterPanel(e, t, n) {
1170
+ toggleFilterPanel(e, t, o) {
1223
1171
  if (this.openPanelField === e) {
1224
1172
  this.closeFilterPanel();
1225
1173
  return;
1226
1174
  }
1227
1175
  this.closeFilterPanel();
1228
- const o = document.createElement("div");
1229
- o.className = "tbw-filter-panel", this.panelElement = o, this.openPanelField = e;
1230
- const r = se(this.sourceRows, e);
1231
- let s = this.excludedValues.get(e);
1232
- s || (s = /* @__PURE__ */ new Set(), this.excludedValues.set(e, s));
1176
+ const n = document.createElement("div");
1177
+ n.className = "tbw-filter-panel", this.panelElement = n, this.openPanelField = e;
1178
+ const i = ue(this.sourceRows, e);
1179
+ let r = this.excludedValues.get(e);
1180
+ r || (r = /* @__PURE__ */ new Set(), this.excludedValues.set(e, r));
1233
1181
  const l = this.searchText.get(e) ?? "", a = {
1234
1182
  field: e,
1235
1183
  column: t,
1236
- uniqueValues: r,
1237
- excludedValues: s,
1184
+ uniqueValues: i,
1185
+ excludedValues: r,
1238
1186
  searchText: l,
1239
1187
  applySetFilter: (c) => {
1240
1188
  this.applySetFilter(e, c), this.closeFilterPanel();
@@ -1248,11 +1196,11 @@ class E extends y {
1248
1196
  closePanel: () => this.closeFilterPanel()
1249
1197
  };
1250
1198
  let d = !1;
1251
- this.config.filterPanelRenderer && (this.config.filterPanelRenderer(o, a), d = o.children.length > 0), d || this.renderDefaultFilterPanel(o, a, r, s), document.body.appendChild(o), this.positionPanel(o, n), this.panelAbortController = new AbortController(), setTimeout(() => {
1199
+ this.config.filterPanelRenderer && (this.config.filterPanelRenderer(n, a), d = n.children.length > 0), d || this.renderDefaultFilterPanel(n, a, i, r), document.body.appendChild(n), this.positionPanel(n, o), this.panelAbortController = new AbortController(), setTimeout(() => {
1252
1200
  document.addEventListener(
1253
1201
  "click",
1254
1202
  (c) => {
1255
- !o.contains(c.target) && c.target !== n && this.closeFilterPanel();
1203
+ !n.contains(c.target) && c.target !== o && this.closeFilterPanel();
1256
1204
  },
1257
1205
  { signal: this.panelAbortController?.signal }
1258
1206
  );
@@ -1268,20 +1216,20 @@ class E extends y {
1268
1216
  * Position the panel below the button
1269
1217
  */
1270
1218
  positionPanel(e, t) {
1271
- const n = t.getBoundingClientRect();
1272
- e.style.position = "fixed", e.style.top = `${n.bottom + 4}px`, e.style.left = `${n.left}px`, requestAnimationFrame(() => {
1273
- const o = e.getBoundingClientRect();
1274
- o.right > window.innerWidth - 8 && (e.style.left = `${window.innerWidth - o.width - 8}px`), o.bottom > window.innerHeight - 8 && (e.style.top = `${n.top - o.height - 4}px`);
1219
+ const o = t.getBoundingClientRect();
1220
+ e.style.position = "fixed", e.style.top = `${o.bottom + 4}px`, e.style.left = `${o.left}px`, requestAnimationFrame(() => {
1221
+ const n = e.getBoundingClientRect();
1222
+ n.right > window.innerWidth - 8 && (e.style.left = `${window.innerWidth - n.width - 8}px`), n.bottom > window.innerHeight - 8 && (e.style.top = `${o.top - n.height - 4}px`);
1275
1223
  });
1276
1224
  }
1277
1225
  /**
1278
1226
  * Render the default filter panel content
1279
1227
  */
1280
- renderDefaultFilterPanel(e, t, n, o) {
1281
- const { field: r } = t, s = document.createElement("div");
1282
- s.className = "tbw-filter-search";
1228
+ renderDefaultFilterPanel(e, t, o, n) {
1229
+ const { field: i } = t, r = document.createElement("div");
1230
+ r.className = "tbw-filter-search";
1283
1231
  const l = document.createElement("input");
1284
- l.type = "text", l.placeholder = "Search...", l.className = "tbw-filter-search-input", l.value = this.searchText.get(r) ?? "", s.appendChild(l), e.appendChild(s);
1232
+ l.type = "text", l.placeholder = "Search...", l.className = "tbw-filter-search-input", l.value = this.searchText.get(i) ?? "", r.appendChild(l), e.appendChild(r);
1285
1233
  const a = document.createElement("div");
1286
1234
  a.className = "tbw-filter-actions";
1287
1235
  const d = document.createElement("label");
@@ -1291,99 +1239,99 @@ class E extends y {
1291
1239
  const u = document.createElement("span");
1292
1240
  u.textContent = "Select All", d.appendChild(c), d.appendChild(u), a.appendChild(d);
1293
1241
  const h = () => {
1294
- const p = [...b.values()], v = p.every((x) => x), C = p.every((x) => !x);
1295
- c.checked = v, c.indeterminate = !v && !C;
1242
+ const f = [...b.values()], x = f.every((v) => v), y = f.every((v) => !v);
1243
+ c.checked = x, c.indeterminate = !x && !y;
1296
1244
  };
1297
1245
  c.addEventListener("change", () => {
1298
- const p = c.checked;
1299
- for (const v of b.keys())
1300
- b.set(v, p);
1246
+ const f = c.checked;
1247
+ for (const x of b.keys())
1248
+ b.set(x, f);
1301
1249
  h(), q();
1302
1250
  }), e.appendChild(a);
1303
- const f = document.createElement("div");
1304
- f.className = "tbw-filter-values";
1251
+ const p = document.createElement("div");
1252
+ p.className = "tbw-filter-values";
1305
1253
  const g = document.createElement("div");
1306
- g.className = "tbw-filter-values-spacer", f.appendChild(g);
1254
+ g.className = "tbw-filter-values-spacer", p.appendChild(g);
1307
1255
  const m = document.createElement("div");
1308
- m.className = "tbw-filter-values-content", f.appendChild(m);
1256
+ m.className = "tbw-filter-values-content", p.appendChild(m);
1309
1257
  const b = /* @__PURE__ */ new Map();
1310
- n.forEach((p) => {
1311
- const v = p == null ? "__null__" : String(p);
1312
- b.set(v, !o.has(p));
1258
+ o.forEach((f) => {
1259
+ const x = f == null ? "__null__" : String(f);
1260
+ b.set(x, !n.has(f));
1313
1261
  }), h();
1314
- let S = [];
1315
- const R = (p, v) => {
1316
- const C = p == null ? "(Blank)" : String(p), x = p == null ? "__null__" : String(p), w = document.createElement("label");
1317
- w.className = "tbw-filter-value-item", w.style.position = "absolute", w.style.top = `${v * E.LIST_ITEM_HEIGHT}px`, w.style.left = "0", w.style.right = "0", w.style.height = `${E.LIST_ITEM_HEIGHT}px`, w.style.boxSizing = "border-box";
1318
- const k = document.createElement("input");
1319
- k.type = "checkbox", k.className = "tbw-filter-checkbox", k.checked = b.get(x) ?? !0, k.dataset.value = x, k.addEventListener("change", () => {
1320
- b.set(x, k.checked), h();
1262
+ let R = [];
1263
+ const k = (f, x) => {
1264
+ const y = f == null ? "(Blank)" : String(f), v = f == null ? "__null__" : String(f), w = document.createElement("label");
1265
+ w.className = "tbw-filter-value-item", w.style.position = "absolute", w.style.top = `${x * A.LIST_ITEM_HEIGHT}px`, w.style.left = "0", w.style.right = "0", w.style.height = `${A.LIST_ITEM_HEIGHT}px`, w.style.boxSizing = "border-box";
1266
+ const S = document.createElement("input");
1267
+ S.type = "checkbox", S.className = "tbw-filter-checkbox", S.checked = b.get(v) ?? !0, S.dataset.value = v, S.addEventListener("change", () => {
1268
+ b.set(v, S.checked), h();
1321
1269
  });
1322
- const Y = document.createElement("span");
1323
- return Y.textContent = C, w.appendChild(k), w.appendChild(Y), w;
1270
+ const ee = document.createElement("span");
1271
+ return ee.textContent = y, w.appendChild(S), w.appendChild(ee), w;
1324
1272
  }, q = () => {
1325
- const p = S.length, v = f.clientHeight, C = f.scrollTop;
1326
- if (g.style.height = `${p * E.LIST_ITEM_HEIGHT}px`, Me(p, E.LIST_BYPASS_THRESHOLD / 3)) {
1327
- m.innerHTML = "", m.style.transform = "translateY(0px)", S.forEach((w, k) => {
1328
- m.appendChild(R(w, k));
1273
+ const f = R.length, x = p.clientHeight, y = p.scrollTop;
1274
+ if (g.style.height = `${f * A.LIST_ITEM_HEIGHT}px`, Ve(f, A.LIST_BYPASS_THRESHOLD / 3)) {
1275
+ m.innerHTML = "", m.style.transform = "translateY(0px)", R.forEach((w, S) => {
1276
+ m.appendChild(k(w, S));
1329
1277
  });
1330
1278
  return;
1331
1279
  }
1332
- const x = Le({
1333
- totalRows: p,
1334
- viewportHeight: v,
1335
- scrollTop: C,
1336
- rowHeight: E.LIST_ITEM_HEIGHT,
1337
- overscan: E.LIST_OVERSCAN
1280
+ const v = Be({
1281
+ totalRows: f,
1282
+ viewportHeight: x,
1283
+ scrollTop: y,
1284
+ rowHeight: A.LIST_ITEM_HEIGHT,
1285
+ overscan: A.LIST_OVERSCAN
1338
1286
  });
1339
- m.style.transform = `translateY(${x.offsetY}px)`, m.innerHTML = "";
1340
- for (let w = x.start; w < x.end; w++)
1341
- m.appendChild(R(S[w], w - x.start));
1342
- }, j = (p) => {
1343
- const v = p.toLowerCase();
1344
- if (S = n.filter((C) => {
1345
- const x = C == null ? "(Blank)" : String(C);
1346
- return !p || x.toLowerCase().includes(v);
1347
- }), S.length === 0) {
1287
+ m.style.transform = `translateY(${v.offsetY}px)`, m.innerHTML = "";
1288
+ for (let w = v.start; w < v.end; w++)
1289
+ m.appendChild(k(R[w], w - v.start));
1290
+ }, J = (f) => {
1291
+ const x = f.toLowerCase();
1292
+ if (R = o.filter((y) => {
1293
+ const v = y == null ? "(Blank)" : String(y);
1294
+ return !f || v.toLowerCase().includes(x);
1295
+ }), R.length === 0) {
1348
1296
  g.style.height = "0px", m.innerHTML = "";
1349
- const C = document.createElement("div");
1350
- C.className = "tbw-filter-no-match", C.textContent = "No matching values", m.appendChild(C);
1297
+ const y = document.createElement("div");
1298
+ y.className = "tbw-filter-no-match", y.textContent = "No matching values", m.appendChild(y);
1351
1299
  return;
1352
1300
  }
1353
1301
  q();
1354
1302
  };
1355
- f.addEventListener(
1303
+ p.addEventListener(
1356
1304
  "scroll",
1357
1305
  () => {
1358
- S.length > 0 && q();
1306
+ R.length > 0 && q();
1359
1307
  },
1360
1308
  { passive: !0 }
1361
- ), j(l.value), e.appendChild(f);
1362
- let U;
1309
+ ), J(l.value), e.appendChild(p);
1310
+ let Q;
1363
1311
  l.addEventListener("input", () => {
1364
- clearTimeout(U), U = setTimeout(() => {
1365
- this.searchText.set(r, l.value), j(l.value);
1312
+ clearTimeout(Q), Q = setTimeout(() => {
1313
+ this.searchText.set(i, l.value), J(l.value);
1366
1314
  }, this.config.debounceMs ?? 150);
1367
1315
  });
1368
- const _ = document.createElement("div");
1369
- _.className = "tbw-filter-buttons";
1370
- const T = document.createElement("button");
1371
- T.className = "tbw-filter-apply-btn", T.textContent = "Apply", T.addEventListener("click", () => {
1372
- const p = [];
1373
- for (const [v, C] of b)
1374
- if (!C)
1375
- if (v === "__null__")
1376
- p.push(null);
1316
+ const N = document.createElement("div");
1317
+ N.className = "tbw-filter-buttons";
1318
+ const M = document.createElement("button");
1319
+ M.className = "tbw-filter-apply-btn", M.textContent = "Apply", M.addEventListener("click", () => {
1320
+ const f = [];
1321
+ for (const [x, y] of b)
1322
+ if (!y)
1323
+ if (x === "__null__")
1324
+ f.push(null);
1377
1325
  else {
1378
- const x = n.find((w) => String(w) === v);
1379
- p.push(x !== void 0 ? x : v);
1326
+ const v = o.find((w) => String(w) === x);
1327
+ f.push(v !== void 0 ? v : x);
1380
1328
  }
1381
- t.applySetFilter(p);
1382
- }), _.appendChild(T);
1383
- const L = document.createElement("button");
1384
- L.className = "tbw-filter-clear-btn", L.textContent = "Clear Filter", L.addEventListener("click", () => {
1329
+ t.applySetFilter(f);
1330
+ }), N.appendChild(M);
1331
+ const P = document.createElement("button");
1332
+ P.className = "tbw-filter-clear-btn", P.textContent = "Clear Filter", P.addEventListener("click", () => {
1385
1333
  t.clearFilter();
1386
- }), _.appendChild(L), e.appendChild(_);
1334
+ }), N.appendChild(P), e.appendChild(N);
1387
1335
  }
1388
1336
  /**
1389
1337
  * Apply a set filter (exclude values)
@@ -1402,13 +1350,13 @@ class E extends y {
1402
1350
  /**
1403
1351
  * Apply a text filter
1404
1352
  */
1405
- applyTextFilter(e, t, n, o) {
1353
+ applyTextFilter(e, t, o, n) {
1406
1354
  this.filters.set(e, {
1407
1355
  field: e,
1408
1356
  type: "text",
1409
1357
  operator: t,
1410
- value: n,
1411
- valueTo: o
1358
+ value: o,
1359
+ valueTo: n
1412
1360
  }), this.cachedResult = null, this.cacheKey = null, this.emit("filter-change", {
1413
1361
  filters: [...this.filters.values()],
1414
1362
  filteredRowCount: 0
@@ -1438,75 +1386,43 @@ class E extends y {
1438
1386
  this.filters.delete(e);
1439
1387
  return;
1440
1388
  }
1441
- const n = {
1389
+ const o = {
1442
1390
  field: e,
1443
1391
  type: t.filter.type,
1444
1392
  operator: t.filter.operator,
1445
1393
  value: t.filter.value,
1446
1394
  valueTo: t.filter.valueTo
1447
1395
  };
1448
- this.filters.set(e, n), this.cachedResult = null, this.cacheKey = null;
1396
+ this.filters.set(e, o), this.cachedResult = null, this.cacheKey = null;
1449
1397
  }
1450
1398
  // ===== Styles =====
1451
- styles = `
1452
- .header-cell.filtered::before {
1453
- content: '';
1454
- position: absolute;
1455
- top: 4px;
1456
- right: 4px;
1457
- width: 6px;
1458
- height: 6px;
1459
- background: var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));
1460
- border-radius: 50%;
1461
- }
1462
- .tbw-filter-btn {
1463
- display: inline-flex;
1464
- align-items: center;
1465
- justify-content: center;
1466
- background: transparent;
1467
- border: none;
1468
- cursor: pointer;
1469
- padding: 2px;
1470
- margin-left: 4px;
1471
- opacity: 0.4;
1472
- transition: opacity 0.15s;
1473
- color: inherit;
1474
- vertical-align: middle;
1475
- }
1476
- .tbw-filter-btn:hover,
1477
- .tbw-filter-btn.active {
1478
- opacity: 1;
1479
- }
1480
- .tbw-filter-btn.active {
1481
- color: var(--tbw-filter-accent, var(--tbw-color-accent, #3b82f6));
1482
- }
1483
- `;
1399
+ styles = $e;
1484
1400
  }
1485
- function Pe(i) {
1486
- if (!i.length) return [];
1487
- const e = /* @__PURE__ */ new Map(), t = [], n = (s, l) => {
1401
+ function Ue(s) {
1402
+ if (!s.length) return [];
1403
+ const e = /* @__PURE__ */ new Map(), t = [], o = (r, l) => {
1488
1404
  if (!l.length) return;
1489
1405
  const a = t[t.length - 1];
1490
- if (a && a.implicit && a.firstIndex + a.columns.length === s) {
1406
+ if (a && a.implicit && a.firstIndex + a.columns.length === r) {
1491
1407
  a.columns.push(...l);
1492
1408
  return;
1493
1409
  }
1494
1410
  t.push({
1495
- id: "__implicit__" + s,
1411
+ id: "__implicit__" + r,
1496
1412
  label: void 0,
1497
1413
  columns: l,
1498
- firstIndex: s,
1414
+ firstIndex: r,
1499
1415
  implicit: !0
1500
1416
  });
1501
1417
  };
1502
- let o = [], r = 0;
1503
- return i.forEach((s, l) => {
1504
- const a = s.group;
1418
+ let n = [], i = 0;
1419
+ return s.forEach((r, l) => {
1420
+ const a = r.group;
1505
1421
  if (!a) {
1506
- o.length === 0 && (r = l), o.push(s);
1422
+ n.length === 0 && (i = l), n.push(r);
1507
1423
  return;
1508
1424
  }
1509
- o.length && (n(r, o.slice()), o = []);
1425
+ n.length && (o(i, n.slice()), n = []);
1510
1426
  const d = typeof a == "string" ? a : a.id;
1511
1427
  let c = e.get(d);
1512
1428
  c || (c = {
@@ -1514,44 +1430,44 @@ function Pe(i) {
1514
1430
  label: typeof a == "string" ? void 0 : a.label,
1515
1431
  columns: [],
1516
1432
  firstIndex: l
1517
- }, e.set(d, c), t.push(c)), c.columns.push(s);
1518
- }), o.length && n(r, o), t.length === 1 && t[0].implicit && t[0].columns.length === i.length ? [] : t;
1433
+ }, e.set(d, c), t.push(c)), c.columns.push(r);
1434
+ }), n.length && o(i, n), t.length === 1 && t[0].implicit && t[0].columns.length === s.length ? [] : t;
1519
1435
  }
1520
- function Be(i, e, t) {
1521
- if (!e.length || !i) return;
1522
- const n = /* @__PURE__ */ new Map();
1523
- for (const r of e)
1524
- for (const s of r.columns)
1525
- s?.field && n.set(s.field, r.id);
1526
- const o = Array.from(i.querySelectorAll(".cell[data-field]"));
1527
- o.forEach((r) => {
1528
- const s = r.getAttribute("data-field") || "", l = n.get(s);
1529
- l && (r.classList.add("grouped"), r.getAttribute("data-group") || r.setAttribute("data-group", l));
1436
+ function Ye(s, e, t) {
1437
+ if (!e.length || !s) return;
1438
+ const o = /* @__PURE__ */ new Map();
1439
+ for (const i of e)
1440
+ for (const r of i.columns)
1441
+ r?.field && o.set(r.field, i.id);
1442
+ const n = Array.from(s.querySelectorAll(".cell[data-field]"));
1443
+ n.forEach((i) => {
1444
+ const r = i.getAttribute("data-field") || "", l = o.get(r);
1445
+ l && (i.classList.add("grouped"), i.getAttribute("data-group") || i.setAttribute("data-group", l));
1530
1446
  });
1531
- for (const r of e) {
1532
- const s = r.columns[r.columns.length - 1], l = o.find((a) => a.getAttribute("data-field") === s.field);
1447
+ for (const i of e) {
1448
+ const r = i.columns[i.columns.length - 1], l = n.find((a) => a.getAttribute("data-field") === r.field);
1533
1449
  l && l.classList.add("group-end");
1534
1450
  }
1535
1451
  }
1536
- function He(i, e) {
1537
- if (i.length === 0) return null;
1452
+ function Ze(s, e) {
1453
+ if (s.length === 0) return null;
1538
1454
  const t = document.createElement("div");
1539
1455
  t.className = "header-group-row", t.setAttribute("role", "row");
1540
- for (const n of i) {
1541
- const o = n.firstIndex != null ? n.firstIndex : e.findIndex((a) => n.columns.includes(a)), r = String(n.id).startsWith("__implicit__"), s = r ? "" : n.label || n.id, l = document.createElement("div");
1542
- l.className = "cell header-group-cell", r && l.classList.add("implicit-group"), l.setAttribute("data-group", String(n.id)), l.style.gridColumn = `${o + 1} / span ${n.columns.length}`, l.textContent = s, t.appendChild(l);
1456
+ for (const o of s) {
1457
+ const n = o.firstIndex != null ? o.firstIndex : e.findIndex((a) => o.columns.includes(a)), i = String(o.id).startsWith("__implicit__"), r = i ? "" : o.label || o.id, l = document.createElement("div");
1458
+ l.className = "cell header-group-cell", i && l.classList.add("implicit-group"), l.setAttribute("data-group", String(o.id)), l.style.gridColumn = `${n + 1} / span ${o.columns.length}`, l.textContent = r, t.appendChild(l);
1543
1459
  }
1544
1460
  return t;
1545
1461
  }
1546
- function Oe(i) {
1547
- return i.some((e) => e.group != null);
1462
+ function Xe(s) {
1463
+ return s.some((e) => e.group != null);
1548
1464
  }
1549
- class kt extends y {
1465
+ const Je = ".header-group-row{display:grid;grid-auto-flow:column;background:var(--tbw-grouping-columns-header-bg, var(--tbw-color-header-bg));border-bottom:1px solid var(--tbw-grouping-columns-border, var(--tbw-color-border))}.header-group-cell{display:flex;align-items:center;justify-content:center;padding:4px 8px;font-weight:600;font-size:.9em;text-transform:uppercase;letter-spacing:.5px;border-right:1px solid var(--tbw-grouping-columns-border, var(--tbw-color-border))}.header-group-cell:last-child{border-right:none}.header-row .cell.grouped{border-top:none}.header-row .cell.group-end{border-right:2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong))}";
1466
+ class Qt extends C {
1550
1467
  name = "groupingColumns";
1551
1468
  version = "1.0.0";
1552
1469
  get defaultConfig() {
1553
1470
  return {
1554
- enabled: !0,
1555
1471
  showGroupBorders: !0
1556
1472
  };
1557
1473
  }
@@ -1567,33 +1483,31 @@ class kt extends y {
1567
1483
  * Auto-detect column groups from column configuration.
1568
1484
  */
1569
1485
  static detect(e, t) {
1570
- const n = t?.columns;
1571
- return Array.isArray(n) ? Oe(n) : !1;
1486
+ const o = t?.columns;
1487
+ return Array.isArray(o) ? Xe(o) : !1;
1572
1488
  }
1573
1489
  // ===== Hooks =====
1574
1490
  processColumns(e) {
1575
- if (!this.config.enabled)
1576
- return this.isActive = !1, this.groups = [], [...e];
1577
- const t = Pe(e);
1491
+ const t = Ue(e);
1578
1492
  return t.length === 0 ? (this.isActive = !1, this.groups = [], [...e]) : (this.isActive = !0, this.groups = t, [...e]);
1579
1493
  }
1580
1494
  afterRender() {
1581
1495
  if (!this.isActive || this.groups.length === 0) {
1582
- const s = this.shadowRoot?.querySelector(".header")?.querySelector(".header-group-row");
1583
- s && s.remove();
1496
+ const r = this.shadowRoot?.querySelector(".header")?.querySelector(".header-group-row");
1497
+ r && r.remove();
1584
1498
  return;
1585
1499
  }
1586
1500
  const e = this.shadowRoot?.querySelector(".header");
1587
1501
  if (!e) return;
1588
1502
  const t = e.querySelector(".header-group-row");
1589
1503
  t && t.remove();
1590
- const n = He(this.groups, this.columns);
1591
- if (n) {
1592
- const r = e.querySelector(".header-row");
1593
- r ? e.insertBefore(n, r) : e.appendChild(n);
1504
+ const o = Ze(this.groups, this.columns);
1505
+ if (o) {
1506
+ const i = e.querySelector(".header-row");
1507
+ i ? e.insertBefore(o, i) : e.appendChild(o);
1594
1508
  }
1595
- const o = e.querySelector(".header-row");
1596
- o && Be(o, this.groups, this.columns);
1509
+ const n = e.querySelector(".header-row");
1510
+ n && Ye(n, this.groups, this.columns);
1597
1511
  }
1598
1512
  // ===== Public API =====
1599
1513
  /**
@@ -1616,7 +1530,7 @@ class kt extends y {
1616
1530
  * @returns Array of columns in the group
1617
1531
  */
1618
1532
  getGroupColumns(e) {
1619
- const t = this.groups.find((n) => n.id === e);
1533
+ const t = this.groups.find((o) => o.id === e);
1620
1534
  return t ? t.columns : [];
1621
1535
  }
1622
1536
  /**
@@ -1626,90 +1540,63 @@ class kt extends y {
1626
1540
  this.requestRender();
1627
1541
  }
1628
1542
  // ===== Styles =====
1629
- styles = `
1630
- .header-group-row {
1631
- display: grid;
1632
- grid-auto-flow: column;
1633
- background: var(--tbw-grouping-columns-header-bg, var(--tbw-color-header-bg));
1634
- border-bottom: 1px solid var(--tbw-grouping-columns-border, var(--tbw-color-border));
1635
- }
1636
- .header-group-cell {
1637
- display: flex;
1638
- align-items: center;
1639
- justify-content: center;
1640
- padding: 4px 8px;
1641
- font-weight: 600;
1642
- font-size: 0.9em;
1643
- text-transform: uppercase;
1644
- letter-spacing: 0.5px;
1645
- border-right: 1px solid var(--tbw-grouping-columns-border, var(--tbw-color-border));
1646
- }
1647
- .header-group-cell:last-child {
1648
- border-right: none;
1649
- }
1650
- .header-row .cell.grouped {
1651
- border-top: none;
1652
- }
1653
- .header-row .cell.group-end {
1654
- border-right: 2px solid var(--tbw-grouping-columns-separator, var(--tbw-color-border-strong));
1655
- }
1656
- `;
1543
+ styles = Je;
1657
1544
  }
1658
- function We({ rows: i, config: e, expanded: t }) {
1659
- const n = e.groupOn;
1660
- if (!e.enabled || typeof n != "function")
1545
+ function Qe({ rows: s, config: e, expanded: t }) {
1546
+ const o = e.groupOn;
1547
+ if (typeof o != "function")
1661
1548
  return [];
1662
- const o = { key: "__root__", value: null, depth: -1, rows: [], children: /* @__PURE__ */ new Map() };
1663
- if (i.forEach((l) => {
1664
- let a = n(l);
1549
+ const n = { key: "__root__", value: null, depth: -1, rows: [], children: /* @__PURE__ */ new Map() };
1550
+ if (s.forEach((l) => {
1551
+ let a = o(l);
1665
1552
  a == null || a === !1 ? a = ["__ungrouped__"] : Array.isArray(a) || (a = [a]);
1666
- let d = o;
1553
+ let d = n;
1667
1554
  a.forEach((c, u) => {
1668
- const h = c == null ? "∅" : String(c), f = d.key === "__root__" ? h : d.key + "||" + h;
1555
+ const h = c == null ? "∅" : String(c), p = d.key === "__root__" ? h : d.key + "||" + h;
1669
1556
  let g = d.children.get(h);
1670
- g || (g = { key: f, value: c, depth: u, rows: [], children: /* @__PURE__ */ new Map(), parent: d }, d.children.set(h, g)), d = g;
1557
+ g || (g = { key: p, value: c, depth: u, rows: [], children: /* @__PURE__ */ new Map(), parent: d }, d.children.set(h, g)), d = g;
1671
1558
  }), d.rows.push(l);
1672
- }), o.children.size === 1 && o.children.has("__ungrouped__") && o.children.get("__ungrouped__").rows.length === i.length)
1559
+ }), n.children.size === 1 && n.children.has("__ungrouped__") && n.children.get("__ungrouped__").rows.length === s.length)
1673
1560
  return [];
1674
- const r = [], s = (l) => {
1675
- if (l === o) {
1676
- l.children.forEach((d) => s(d));
1561
+ const i = [], r = (l) => {
1562
+ if (l === n) {
1563
+ l.children.forEach((d) => r(d));
1677
1564
  return;
1678
1565
  }
1679
1566
  const a = t.has(l.key);
1680
- r.push({
1567
+ i.push({
1681
1568
  kind: "group",
1682
1569
  key: l.key,
1683
1570
  value: l.value,
1684
1571
  depth: l.depth,
1685
1572
  rows: l.rows,
1686
1573
  expanded: a
1687
- }), a && (l.children.size ? l.children.forEach((d) => s(d)) : l.rows.forEach((d) => r.push({ kind: "data", row: d, rowIndex: i.indexOf(d) })));
1574
+ }), a && (l.children.size ? l.children.forEach((d) => r(d)) : l.rows.forEach((d) => i.push({ kind: "data", row: d, rowIndex: s.indexOf(d) })));
1688
1575
  };
1689
- return s(o), r;
1576
+ return r(n), i;
1690
1577
  }
1691
- function Ve(i, e) {
1692
- const t = new Set(i);
1578
+ function et(s, e) {
1579
+ const t = new Set(s);
1693
1580
  return t.has(e) ? t.delete(e) : t.add(e), t;
1694
1581
  }
1695
- function Ke(i) {
1582
+ function tt(s) {
1696
1583
  const e = /* @__PURE__ */ new Set();
1697
- for (const t of i)
1584
+ for (const t of s)
1698
1585
  t.kind === "group" && e.add(t.key);
1699
1586
  return e;
1700
1587
  }
1701
- function Ge() {
1588
+ function ot() {
1702
1589
  return /* @__PURE__ */ new Set();
1703
1590
  }
1704
- function ze(i) {
1705
- return i.kind !== "group" ? 0 : i.rows.length;
1591
+ function nt(s) {
1592
+ return s.kind !== "group" ? 0 : s.rows.length;
1706
1593
  }
1707
- class Et extends y {
1594
+ const it = '.group-row{background:var(--tbw-grouping-rows-bg, var(--tbw-color-panel-bg));font-weight:500}.group-row:hover{background:var(--tbw-grouping-rows-bg-hover, var(--tbw-color-row-hover))}.group-toggle{cursor:pointer;user-select:none;display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;margin-right:4px;font-size:10px}.group-toggle:hover{background:var(--tbw-grouping-rows-toggle-hover, var(--tbw-color-row-hover));border-radius:2px}.group-label{display:inline-flex;align-items:center;gap:8px}.group-count{color:var(--tbw-grouping-rows-count-color, var(--tbw-color-fg-muted));font-size:.85em;font-weight:400}[data-group-depth="0"] .group-label{padding-left:0}[data-group-depth="1"] .group-label{padding-left:20px}[data-group-depth="2"] .group-label{padding-left:40px}[data-group-depth="3"] .group-label{padding-left:60px}[data-group-depth="4"] .group-label{padding-left:80px}';
1595
+ class eo extends C {
1708
1596
  name = "groupingRows";
1709
1597
  version = "1.0.0";
1710
1598
  get defaultConfig() {
1711
1599
  return {
1712
- enabled: !0,
1713
1600
  defaultExpanded: !1,
1714
1601
  showRowCount: !0,
1715
1602
  indentWidth: 20,
@@ -1734,22 +1621,22 @@ class Et extends y {
1734
1621
  }
1735
1622
  processRows(e) {
1736
1623
  const t = this.config;
1737
- if (!t.enabled || typeof t.groupOn != "function")
1624
+ if (typeof t.groupOn != "function")
1738
1625
  return this.isActive = !1, this.flattenedRows = [], [...e];
1739
- const n = We({
1626
+ const o = Qe({
1740
1627
  rows: e,
1741
1628
  config: t,
1742
1629
  expanded: this.expandedKeys
1743
1630
  });
1744
- return n.length === 0 ? (this.isActive = !1, this.flattenedRows = [], [...e]) : (this.isActive = !0, this.flattenedRows = n, n.map((o) => o.kind === "group" ? {
1631
+ return o.length === 0 ? (this.isActive = !1, this.flattenedRows = [], [...e]) : (this.isActive = !0, this.flattenedRows = o, o.map((n) => n.kind === "group" ? {
1745
1632
  __isGroupRow: !0,
1746
- __groupKey: o.key,
1747
- __groupValue: o.value,
1748
- __groupDepth: o.depth,
1749
- __groupRows: o.rows,
1750
- __groupExpanded: o.expanded,
1751
- __groupRowCount: ze(o)
1752
- } : o.row));
1633
+ __groupKey: n.key,
1634
+ __groupValue: n.value,
1635
+ __groupDepth: n.depth,
1636
+ __groupRows: n.rows,
1637
+ __groupExpanded: n.expanded,
1638
+ __groupRowCount: nt(n)
1639
+ } : n.row));
1753
1640
  }
1754
1641
  onCellClick(e) {
1755
1642
  const t = e.row;
@@ -1759,14 +1646,14 @@ class Et extends y {
1759
1646
  /**
1760
1647
  * Render a row. Returns true if we handled the row (group row), false otherwise.
1761
1648
  */
1762
- renderRow(e, t, n) {
1649
+ renderRow(e, t, o) {
1763
1650
  if (!e?.__isGroupRow)
1764
1651
  return !1;
1765
- const o = this.config;
1766
- if (o.groupRowRenderer) {
1652
+ const n = this.config;
1653
+ if (n.groupRowRenderer) {
1767
1654
  const l = () => {
1768
1655
  this.toggle(e.__groupKey);
1769
- }, a = o.groupRowRenderer({
1656
+ }, a = n.groupRowRenderer({
1770
1657
  key: e.__groupKey,
1771
1658
  value: e.__groupValue,
1772
1659
  depth: e.__groupDepth,
@@ -1777,55 +1664,55 @@ class Et extends y {
1777
1664
  if (a)
1778
1665
  return t.className = "group-row", t.__isCustomRow = !0, t.setAttribute("data-group-depth", String(e.__groupDepth)), typeof a == "string" ? t.innerHTML = a : (t.innerHTML = "", t.appendChild(a)), !0;
1779
1666
  }
1780
- const r = () => {
1667
+ const i = () => {
1781
1668
  this.toggle(e.__groupKey);
1782
1669
  };
1783
- return t.className = "group-row", t.__isCustomRow = !0, t.setAttribute("data-group-depth", String(e.__groupDepth)), t.setAttribute("role", "row"), t.setAttribute("aria-expanded", String(e.__groupExpanded)), t.style.paddingLeft = `${(e.__groupDepth || 0) * (o.indentWidth ?? 20)}px`, t.innerHTML = "", o.fullWidth !== !1 ? this.renderFullWidthGroupRow(e, t, r) : this.renderPerColumnGroupRow(e, t, r), !0;
1670
+ return t.className = "group-row", t.__isCustomRow = !0, t.setAttribute("data-group-depth", String(e.__groupDepth)), t.setAttribute("role", "row"), t.setAttribute("aria-expanded", String(e.__groupExpanded)), t.style.paddingLeft = `${(e.__groupDepth || 0) * (n.indentWidth ?? 20)}px`, t.innerHTML = "", n.fullWidth !== !1 ? this.renderFullWidthGroupRow(e, t, i) : this.renderPerColumnGroupRow(e, t, i), !0;
1784
1671
  }
1785
1672
  afterRender() {
1786
1673
  }
1787
1674
  // ===== Private Rendering Helpers =====
1788
- renderFullWidthGroupRow(e, t, n) {
1789
- const o = this.config, r = document.createElement("div");
1790
- r.className = "cell group-full", r.style.gridColumn = "1 / -1", r.setAttribute("role", "gridcell");
1791
- const s = document.createElement("button");
1792
- s.type = "button", s.className = "group-toggle", s.setAttribute("aria-label", e.__groupExpanded ? "Collapse group" : "Expand group"), this.setIcon(s, this.resolveIcon(e.__groupExpanded ? "collapse" : "expand")), s.addEventListener("click", (d) => {
1793
- d.stopPropagation(), n();
1794
- }), r.appendChild(s);
1675
+ renderFullWidthGroupRow(e, t, o) {
1676
+ const n = this.config, i = document.createElement("div");
1677
+ i.className = "cell group-full", i.style.gridColumn = "1 / -1", i.setAttribute("role", "gridcell");
1678
+ const r = document.createElement("button");
1679
+ r.type = "button", r.className = "group-toggle", r.setAttribute("aria-label", e.__groupExpanded ? "Collapse group" : "Expand group"), this.setIcon(r, this.resolveIcon(e.__groupExpanded ? "collapse" : "expand")), r.addEventListener("click", (d) => {
1680
+ d.stopPropagation(), o();
1681
+ }), i.appendChild(r);
1795
1682
  const l = document.createElement("span");
1796
1683
  l.className = "group-label";
1797
- const a = o.formatLabel ? o.formatLabel(e.__groupValue, e.__groupDepth || 0, e.__groupKey) : String(e.__groupValue);
1798
- if (l.textContent = a, r.appendChild(l), o.showRowCount !== !1) {
1684
+ const a = n.formatLabel ? n.formatLabel(e.__groupValue, e.__groupDepth || 0, e.__groupKey) : String(e.__groupValue);
1685
+ if (l.textContent = a, i.appendChild(l), n.showRowCount !== !1) {
1799
1686
  const d = document.createElement("span");
1800
- d.className = "group-count", d.textContent = `(${e.__groupRowCount ?? e.__groupRows?.length ?? 0})`, r.appendChild(d);
1687
+ d.className = "group-count", d.textContent = `(${e.__groupRowCount ?? e.__groupRows?.length ?? 0})`, i.appendChild(d);
1801
1688
  }
1802
- t.appendChild(r);
1689
+ t.appendChild(i);
1803
1690
  }
1804
- renderPerColumnGroupRow(e, t, n) {
1805
- const o = this.config, r = o.aggregators ?? {}, s = this.columns, l = e.__groupRows ?? [], d = this.shadowRoot?.querySelector(".body")?.style.gridTemplateColumns || "";
1806
- d && (t.style.display = "grid", t.style.gridTemplateColumns = d), s.forEach((c, u) => {
1691
+ renderPerColumnGroupRow(e, t, o) {
1692
+ const n = this.config, i = n.aggregators ?? {}, r = this.columns, l = e.__groupRows ?? [], d = this.shadowRoot?.querySelector(".body")?.style.gridTemplateColumns || "";
1693
+ d && (t.style.display = "grid", t.style.gridTemplateColumns = d), r.forEach((c, u) => {
1807
1694
  const h = document.createElement("div");
1808
1695
  if (h.className = "cell group-cell", h.setAttribute("data-col", String(u)), h.setAttribute("role", "gridcell"), u === 0) {
1809
- const f = document.createElement("button");
1810
- f.type = "button", f.className = "group-toggle", f.setAttribute("aria-label", e.__groupExpanded ? "Collapse group" : "Expand group"), this.setIcon(f, this.resolveIcon(e.__groupExpanded ? "collapse" : "expand")), f.addEventListener("click", (b) => {
1811
- b.stopPropagation(), n();
1812
- }), h.appendChild(f);
1813
- const g = document.createElement("span"), m = r[c.field];
1696
+ const p = document.createElement("button");
1697
+ p.type = "button", p.className = "group-toggle", p.setAttribute("aria-label", e.__groupExpanded ? "Collapse group" : "Expand group"), this.setIcon(p, this.resolveIcon(e.__groupExpanded ? "collapse" : "expand")), p.addEventListener("click", (b) => {
1698
+ b.stopPropagation(), o();
1699
+ }), h.appendChild(p);
1700
+ const g = document.createElement("span"), m = i[c.field];
1814
1701
  if (m) {
1815
- const b = X(m, l, c.field, c);
1702
+ const b = te(m, l, c.field, c);
1816
1703
  g.textContent = b != null ? String(b) : String(e.__groupValue);
1817
1704
  } else {
1818
- const b = o.formatLabel ? o.formatLabel(e.__groupValue, e.__groupDepth || 0, e.__groupKey) : String(e.__groupValue);
1705
+ const b = n.formatLabel ? n.formatLabel(e.__groupValue, e.__groupDepth || 0, e.__groupKey) : String(e.__groupValue);
1819
1706
  g.textContent = b;
1820
1707
  }
1821
- if (h.appendChild(g), o.showRowCount !== !1) {
1708
+ if (h.appendChild(g), n.showRowCount !== !1) {
1822
1709
  const b = document.createElement("span");
1823
1710
  b.className = "group-count", b.textContent = ` (${l.length})`, h.appendChild(b);
1824
1711
  }
1825
1712
  } else {
1826
- const f = r[c.field];
1827
- if (f) {
1828
- const g = X(f, l, c.field, c);
1713
+ const p = i[c.field];
1714
+ if (p) {
1715
+ const g = te(p, l, c.field, c);
1829
1716
  h.textContent = g != null ? String(g) : "";
1830
1717
  } else
1831
1718
  h.textContent = "";
@@ -1838,21 +1725,21 @@ class Et extends y {
1838
1725
  * Expand all groups.
1839
1726
  */
1840
1727
  expandAll() {
1841
- this.expandedKeys = Ke(this.flattenedRows), this.requestRender();
1728
+ this.expandedKeys = tt(this.flattenedRows), this.requestRender();
1842
1729
  }
1843
1730
  /**
1844
1731
  * Collapse all groups.
1845
1732
  */
1846
1733
  collapseAll() {
1847
- this.expandedKeys = Ge(), this.requestRender();
1734
+ this.expandedKeys = ot(), this.requestRender();
1848
1735
  }
1849
1736
  /**
1850
1737
  * Toggle expansion of a specific group.
1851
1738
  * @param key - The group key to toggle
1852
1739
  */
1853
1740
  toggle(e) {
1854
- this.expandedKeys = Ve(this.expandedKeys, e);
1855
- const t = this.flattenedRows.find((n) => n.kind === "group" && n.key === e);
1741
+ this.expandedKeys = et(this.expandedKeys, e);
1742
+ const t = this.flattenedRows.find((o) => o.kind === "group" && o.key === e);
1856
1743
  this.emit("group-toggle", {
1857
1744
  key: e,
1858
1745
  expanded: this.expandedKeys.has(e),
@@ -1941,75 +1828,37 @@ class Et extends y {
1941
1828
  this.config.groupOn = e, this.requestRender();
1942
1829
  }
1943
1830
  // ===== Styles =====
1944
- styles = `
1945
- .group-row {
1946
- background: var(--tbw-grouping-rows-bg, var(--tbw-color-panel-bg));
1947
- font-weight: 500;
1948
- }
1949
- .group-row:hover {
1950
- background: var(--tbw-grouping-rows-bg-hover, var(--tbw-color-row-hover));
1951
- }
1952
- .group-toggle {
1953
- cursor: pointer;
1954
- user-select: none;
1955
- display: inline-flex;
1956
- align-items: center;
1957
- justify-content: center;
1958
- width: 20px;
1959
- height: 20px;
1960
- margin-right: 4px;
1961
- font-size: 10px;
1962
- }
1963
- .group-toggle:hover {
1964
- background: var(--tbw-grouping-rows-toggle-hover, var(--tbw-color-row-hover));
1965
- border-radius: 2px;
1966
- }
1967
- .group-label {
1968
- display: inline-flex;
1969
- align-items: center;
1970
- gap: 8px;
1971
- }
1972
- .group-count {
1973
- color: var(--tbw-grouping-rows-count-color, var(--tbw-color-fg-muted));
1974
- font-size: 0.85em;
1975
- font-weight: normal;
1976
- }
1977
- [data-group-depth="0"] .group-label { padding-left: 0; }
1978
- [data-group-depth="1"] .group-label { padding-left: 20px; }
1979
- [data-group-depth="2"] .group-label { padding-left: 40px; }
1980
- [data-group-depth="3"] .group-label { padding-left: 60px; }
1981
- [data-group-depth="4"] .group-label { padding-left: 80px; }
1982
- `;
1983
- }
1984
- function H(i, e) {
1985
- const t = new Set(i);
1831
+ styles = it;
1832
+ }
1833
+ function V(s, e) {
1834
+ const t = new Set(s);
1986
1835
  return t.has(e) ? t.delete(e) : t.add(e), t;
1987
1836
  }
1988
- function $e(i, e) {
1989
- const t = new Set(i);
1837
+ function rt(s, e) {
1838
+ const t = new Set(s);
1990
1839
  return t.add(e), t;
1991
1840
  }
1992
- function je(i, e) {
1993
- const t = new Set(i);
1841
+ function st(s, e) {
1842
+ const t = new Set(s);
1994
1843
  return t.delete(e), t;
1995
1844
  }
1996
- function Ue(i, e) {
1997
- return i.has(e);
1998
- }
1999
- function Ye(i, e, t, n) {
2000
- const o = document.createElement("div");
2001
- o.className = "master-detail-row", o.setAttribute("data-detail-for", String(e)), o.setAttribute("role", "row");
2002
- const r = document.createElement("div");
2003
- r.className = "master-detail-cell", r.setAttribute("role", "cell"), r.style.gridColumn = `1 / ${n + 1}`;
2004
- const s = t(i, e);
2005
- return typeof s == "string" ? r.innerHTML = s : s instanceof HTMLElement && r.appendChild(s), o.appendChild(r), o;
1845
+ function lt(s, e) {
1846
+ return s.has(e);
2006
1847
  }
2007
- class At extends y {
1848
+ function at(s, e, t, o) {
1849
+ const n = document.createElement("div");
1850
+ n.className = "master-detail-row", n.setAttribute("data-detail-for", String(e)), n.setAttribute("role", "row");
1851
+ const i = document.createElement("div");
1852
+ i.className = "master-detail-cell", i.setAttribute("role", "cell"), i.style.gridColumn = `1 / ${o + 1}`;
1853
+ const r = t(s, e);
1854
+ return typeof r == "string" ? i.innerHTML = r : r instanceof HTMLElement && i.appendChild(r), n.appendChild(i), n;
1855
+ }
1856
+ const dt = ".master-detail-cell-wrapper{display:flex;align-items:center;gap:4px}.master-detail-toggle{cursor:pointer;font-size:10px;opacity:.7;user-select:none}.master-detail-toggle:hover{opacity:1}.master-detail-row{grid-column:1 / -1;display:grid;background:var(--tbw-master-detail-bg, var(--tbw-color-row-alt));border-bottom:1px solid var(--tbw-master-detail-border, var(--tbw-color-border))}.master-detail-cell{padding:16px;overflow:auto}";
1857
+ class to extends C {
2008
1858
  name = "masterDetail";
2009
1859
  version = "1.0.0";
2010
1860
  get defaultConfig() {
2011
1861
  return {
2012
- enabled: !0,
2013
1862
  detailHeight: "auto",
2014
1863
  expandOnRowClick: !1,
2015
1864
  collapseOnClickOutside: !1,
@@ -2029,37 +1878,37 @@ class At extends y {
2029
1878
  return [...e];
2030
1879
  const t = [...e];
2031
1880
  if (t.length > 0) {
2032
- const n = { ...t[0] }, o = n.viewRenderer;
2033
- if (o?.__masterDetailWrapped)
1881
+ const o = { ...t[0] }, n = o.viewRenderer;
1882
+ if (n?.__masterDetailWrapped)
2034
1883
  return t;
2035
- const r = (s) => {
2036
- const { value: l, row: a } = s, d = this.expandedRows.has(a), c = document.createElement("span");
1884
+ const i = (r) => {
1885
+ const { value: l, row: a } = r, d = this.expandedRows.has(a), c = document.createElement("span");
2037
1886
  c.className = "master-detail-cell-wrapper";
2038
1887
  const u = document.createElement("span");
2039
- u.className = "master-detail-toggle", this.setIcon(u, this.resolveIcon(d ? "collapse" : "expand")), u.setAttribute("aria-expanded", String(d)), u.setAttribute("aria-label", d ? "Collapse details" : "Expand details"), u.addEventListener("click", (f) => {
2040
- f.stopPropagation();
1888
+ u.className = "master-detail-toggle", this.setIcon(u, this.resolveIcon(d ? "collapse" : "expand")), u.setAttribute("role", "button"), u.setAttribute("tabindex", "0"), u.setAttribute("aria-expanded", String(d)), u.setAttribute("aria-label", d ? "Collapse details" : "Expand details"), u.addEventListener("click", (p) => {
1889
+ p.stopPropagation();
2041
1890
  const g = this.rows.indexOf(a);
2042
- this.expandedRows = H(this.expandedRows, a), this.emit("detail-expand", {
1891
+ this.expandedRows = V(this.expandedRows, a), this.emit("detail-expand", {
2043
1892
  rowIndex: g,
2044
1893
  row: a,
2045
1894
  expanded: this.expandedRows.has(a)
2046
1895
  }), this.requestRender();
2047
1896
  }), c.appendChild(u);
2048
1897
  const h = document.createElement("span");
2049
- if (o) {
2050
- const f = o(s);
2051
- f instanceof Node ? h.appendChild(f) : h.textContent = String(f ?? l ?? "");
1898
+ if (n) {
1899
+ const p = n(r);
1900
+ p instanceof Node ? h.appendChild(p) : h.textContent = String(p ?? l ?? "");
2052
1901
  } else
2053
1902
  h.textContent = String(l ?? "");
2054
1903
  return c.appendChild(h), c;
2055
1904
  };
2056
- r.__masterDetailWrapped = !0, n.viewRenderer = r, t[0] = n;
1905
+ i.__masterDetailWrapped = !0, o.viewRenderer = i, t[0] = o;
2057
1906
  }
2058
1907
  return t;
2059
1908
  }
2060
1909
  onRowClick(e) {
2061
1910
  if (!(!this.config.expandOnRowClick || !this.config.detailRenderer))
2062
- return this.expandedRows = H(this.expandedRows, e.row), this.emit("detail-expand", {
1911
+ return this.expandedRows = V(this.expandedRows, e.row), this.emit("detail-expand", {
2063
1912
  rowIndex: e.rowIndex,
2064
1913
  row: e.row,
2065
1914
  expanded: this.expandedRows.has(e.row)
@@ -2086,25 +1935,25 @@ class At extends y {
2086
1935
  if (!this.config.detailRenderer) return;
2087
1936
  const e = this.shadowRoot?.querySelector(".rows");
2088
1937
  if (!e) return;
2089
- const t = /* @__PURE__ */ new Map(), n = e.querySelectorAll(".data-grid-row"), o = this.columns.length;
2090
- for (const s of n) {
2091
- const l = s.querySelector(".cell[data-row]"), a = l ? parseInt(l.getAttribute("data-row") ?? "-1", 10) : -1;
2092
- a >= 0 && t.set(a, s);
2093
- }
2094
- const r = e.querySelectorAll(".master-detail-row");
2095
- for (const s of r) {
2096
- const l = parseInt(s.getAttribute("data-detail-for") ?? "-1", 10), a = l >= 0 ? this.rows[l] : void 0, d = a && this.expandedRows.has(a), c = t.has(l);
2097
- (!d || !c) && (s.remove(), a && this.detailElements.delete(a));
2098
- }
2099
- for (const [s, l] of t) {
2100
- const a = this.rows[s];
1938
+ const t = /* @__PURE__ */ new Map(), o = e.querySelectorAll(".data-grid-row"), n = this.columns.length;
1939
+ for (const r of o) {
1940
+ const l = r.querySelector(".cell[data-row]"), a = l ? parseInt(l.getAttribute("data-row") ?? "-1", 10) : -1;
1941
+ a >= 0 && t.set(a, r);
1942
+ }
1943
+ const i = e.querySelectorAll(".master-detail-row");
1944
+ for (const r of i) {
1945
+ const l = parseInt(r.getAttribute("data-detail-for") ?? "-1", 10), a = l >= 0 ? this.rows[l] : void 0, d = a && this.expandedRows.has(a), c = t.has(l);
1946
+ (!d || !c) && (r.remove(), a && this.detailElements.delete(a));
1947
+ }
1948
+ for (const [r, l] of t) {
1949
+ const a = this.rows[r];
2101
1950
  if (!a || !this.expandedRows.has(a)) continue;
2102
1951
  const d = this.detailElements.get(a);
2103
1952
  if (d) {
2104
1953
  d.previousElementSibling !== l && l.after(d);
2105
1954
  continue;
2106
1955
  }
2107
- const c = Ye(a, s, this.config.detailRenderer, o);
1956
+ const c = at(a, r, this.config.detailRenderer, n);
2108
1957
  typeof this.config.detailHeight == "number" && (c.style.height = `${this.config.detailHeight}px`), l.after(c), this.detailElements.set(a, c);
2109
1958
  }
2110
1959
  }
@@ -2115,12 +1964,12 @@ class At extends y {
2115
1964
  getExtraHeight() {
2116
1965
  let e = 0;
2117
1966
  for (const t of this.expandedRows) {
2118
- const n = this.detailElements.get(t);
2119
- if (n)
2120
- e += n.offsetHeight;
1967
+ const o = this.detailElements.get(t);
1968
+ if (o)
1969
+ e += o.offsetHeight;
2121
1970
  else {
2122
- const o = this.config?.detailHeight;
2123
- e += typeof o == "number" ? o : 150;
1971
+ const n = this.config?.detailHeight;
1972
+ e += typeof n == "number" ? n : 150;
2124
1973
  }
2125
1974
  }
2126
1975
  return e;
@@ -2131,15 +1980,15 @@ class At extends y {
2131
1980
  */
2132
1981
  getExtraHeightBefore(e) {
2133
1982
  let t = 0;
2134
- for (const n of this.expandedRows) {
2135
- const o = this.rows.indexOf(n);
2136
- if (o >= 0 && o < e) {
2137
- const r = this.detailElements.get(n);
2138
- if (r)
2139
- t += r.offsetHeight;
1983
+ for (const o of this.expandedRows) {
1984
+ const n = this.rows.indexOf(o);
1985
+ if (n >= 0 && n < e) {
1986
+ const i = this.detailElements.get(o);
1987
+ if (i)
1988
+ t += i.offsetHeight;
2140
1989
  else {
2141
- const s = this.config?.detailHeight;
2142
- t += typeof s == "number" ? s : 150;
1990
+ const r = this.config?.detailHeight;
1991
+ t += typeof r == "number" ? r : 150;
2143
1992
  }
2144
1993
  }
2145
1994
  }
@@ -2149,20 +1998,20 @@ class At extends y {
2149
1998
  * Adjust the virtualization start index to keep expanded row visible while its detail is visible.
2150
1999
  * This ensures the detail scrolls smoothly out of view instead of disappearing abruptly.
2151
2000
  */
2152
- adjustVirtualStart(e, t, n) {
2001
+ adjustVirtualStart(e, t, o) {
2153
2002
  if (this.expandedRows.size === 0) return e;
2154
- const o = [];
2003
+ const n = [];
2155
2004
  for (const l of this.expandedRows) {
2156
2005
  const a = this.rows.indexOf(l);
2157
- a >= 0 && o.push({ index: a, row: l });
2006
+ a >= 0 && n.push({ index: a, row: l });
2158
2007
  }
2159
- o.sort((l, a) => l.index - a.index);
2160
- let r = e, s = 0;
2161
- for (const { index: l, row: a } of o) {
2162
- const d = l * n + s, u = this.detailElements.get(a)?.offsetHeight ?? (typeof this.config?.detailHeight == "number" ? this.config.detailHeight : 150), h = d + n + u;
2163
- s += u, !(l >= e) && h > t && l < r && (r = l);
2008
+ n.sort((l, a) => l.index - a.index);
2009
+ let i = e, r = 0;
2010
+ for (const { index: l, row: a } of n) {
2011
+ const d = l * o + r, u = this.detailElements.get(a)?.offsetHeight ?? (typeof this.config?.detailHeight == "number" ? this.config.detailHeight : 150), h = d + o + u;
2012
+ r += u, !(l >= e) && h > t && l < i && (i = l);
2164
2013
  }
2165
- return r;
2014
+ return i;
2166
2015
  }
2167
2016
  // ===== Public API =====
2168
2017
  /**
@@ -2171,7 +2020,7 @@ class At extends y {
2171
2020
  */
2172
2021
  expand(e) {
2173
2022
  const t = this.rows[e];
2174
- t && (this.expandedRows = $e(this.expandedRows, t), this.requestRender());
2023
+ t && (this.expandedRows = rt(this.expandedRows, t), this.requestRender());
2175
2024
  }
2176
2025
  /**
2177
2026
  * Collapse the detail row at the given index.
@@ -2179,7 +2028,7 @@ class At extends y {
2179
2028
  */
2180
2029
  collapse(e) {
2181
2030
  const t = this.rows[e];
2182
- t && (this.expandedRows = je(this.expandedRows, t), this.requestRender());
2031
+ t && (this.expandedRows = st(this.expandedRows, t), this.requestRender());
2183
2032
  }
2184
2033
  /**
2185
2034
  * Toggle the detail row at the given index.
@@ -2187,7 +2036,7 @@ class At extends y {
2187
2036
  */
2188
2037
  toggle(e) {
2189
2038
  const t = this.rows[e];
2190
- t && (this.expandedRows = H(this.expandedRows, t), this.requestRender());
2039
+ t && (this.expandedRows = V(this.expandedRows, t), this.requestRender());
2191
2040
  }
2192
2041
  /**
2193
2042
  * Check if the detail row at the given index is expanded.
@@ -2196,7 +2045,7 @@ class At extends y {
2196
2045
  */
2197
2046
  isExpanded(e) {
2198
2047
  const t = this.rows[e];
2199
- return t ? Ue(this.expandedRows, t) : !1;
2048
+ return t ? lt(this.expandedRows, t) : !1;
2200
2049
  }
2201
2050
  /**
2202
2051
  * Expand all detail rows.
@@ -2219,8 +2068,8 @@ class At extends y {
2219
2068
  getExpandedRows() {
2220
2069
  const e = [];
2221
2070
  for (const t of this.expandedRows) {
2222
- const n = this.rows.indexOf(t);
2223
- n >= 0 && e.push(n);
2071
+ const o = this.rows.indexOf(t);
2072
+ o >= 0 && e.push(o);
2224
2073
  }
2225
2074
  return e;
2226
2075
  }
@@ -2234,63 +2083,38 @@ class At extends y {
2234
2083
  return t ? this.detailElements.get(t) : void 0;
2235
2084
  }
2236
2085
  // ===== Styles =====
2237
- styles = `
2238
- .master-detail-cell-wrapper {
2239
- display: flex;
2240
- align-items: center;
2241
- gap: 4px;
2242
- }
2243
- .master-detail-toggle {
2244
- cursor: pointer;
2245
- font-size: 10px;
2246
- opacity: 0.7;
2247
- user-select: none;
2248
- }
2249
- .master-detail-toggle:hover {
2250
- opacity: 1;
2251
- }
2252
- .master-detail-row {
2253
- grid-column: 1 / -1;
2254
- display: grid;
2255
- background: var(--tbw-master-detail-bg, var(--tbw-color-row-alt));
2256
- border-bottom: 1px solid var(--tbw-master-detail-border, var(--tbw-color-border));
2257
- }
2258
- .master-detail-cell {
2259
- padding: 16px;
2260
- overflow: auto;
2261
- }
2262
- `;
2086
+ styles = dt;
2263
2087
  }
2264
- function Xe(i, e, t) {
2265
- return e.length ? [...i].sort((n, o) => {
2266
- for (const r of e) {
2267
- const l = t.find((u) => u.field === r.field)?.sortComparator ?? Je, a = n[r.field], d = o[r.field], c = l(a, d, n, o);
2088
+ function ct(s, e, t) {
2089
+ return e.length ? [...s].sort((o, n) => {
2090
+ for (const i of e) {
2091
+ const l = t.find((u) => u.field === i.field)?.sortComparator ?? ut, a = o[i.field], d = n[i.field], c = l(a, d, o, n);
2268
2092
  if (c !== 0)
2269
- return r.direction === "asc" ? c : -c;
2093
+ return i.direction === "asc" ? c : -c;
2270
2094
  }
2271
2095
  return 0;
2272
- }) : [...i];
2096
+ }) : [...s];
2273
2097
  }
2274
- function Je(i, e) {
2275
- return i == null && e == null ? 0 : i == null ? 1 : e == null ? -1 : typeof i == "number" && typeof e == "number" ? i - e : i instanceof Date && e instanceof Date ? i.getTime() - e.getTime() : typeof i == "boolean" && typeof e == "boolean" ? i === e ? 0 : i ? -1 : 1 : String(i).localeCompare(String(e));
2098
+ function ut(s, e) {
2099
+ return s == null && e == null ? 0 : s == null ? 1 : e == null ? -1 : typeof s == "number" && typeof e == "number" ? s - e : s instanceof Date && e instanceof Date ? s.getTime() - e.getTime() : typeof s == "boolean" && typeof e == "boolean" ? s === e ? 0 : s ? -1 : 1 : String(s).localeCompare(String(e));
2276
2100
  }
2277
- function Qe(i, e, t, n) {
2278
- const o = i.find((r) => r.field === e);
2279
- return t ? o ? o.direction === "asc" ? i.map((r) => r.field === e ? { ...r, direction: "desc" } : r) : i.filter((r) => r.field !== e) : i.length < n ? [...i, { field: e, direction: "asc" }] : i : o?.direction === "asc" ? [{ field: e, direction: "desc" }] : o?.direction === "desc" ? [] : [{ field: e, direction: "asc" }];
2101
+ function ht(s, e, t, o) {
2102
+ const n = s.find((i) => i.field === e);
2103
+ return t ? n ? n.direction === "asc" ? s.map((i) => i.field === e ? { ...i, direction: "desc" } : i) : s.filter((i) => i.field !== e) : s.length < o ? [...s, { field: e, direction: "asc" }] : s : n?.direction === "asc" ? [{ field: e, direction: "desc" }] : n?.direction === "desc" ? [] : [{ field: e, direction: "asc" }];
2280
2104
  }
2281
- function le(i, e) {
2282
- const t = i.findIndex((n) => n.field === e);
2105
+ function he(s, e) {
2106
+ const t = s.findIndex((o) => o.field === e);
2283
2107
  return t >= 0 ? t + 1 : void 0;
2284
2108
  }
2285
- function ae(i, e) {
2286
- return i.find((t) => t.field === e)?.direction;
2109
+ function pe(s, e) {
2110
+ return s.find((t) => t.field === e)?.direction;
2287
2111
  }
2288
- class It extends y {
2112
+ const pt = '.header-cell[data-sort=asc]:after{content:"↑";margin-left:4px;opacity:.8}.header-cell[data-sort=desc]:after{content:"↓";margin-left:4px;opacity:.8}.sort-index{font-size:10px;background:var(--tbw-multi-sort-badge-bg, var(--tbw-color-panel-bg));color:var(--tbw-multi-sort-badge-color, var(--tbw-color-fg));border-radius:50%;width:14px;height:14px;display:inline-flex;align-items:center;justify-content:center;margin-left:2px;font-weight:600}';
2113
+ class oo extends C {
2289
2114
  name = "multiSort";
2290
2115
  version = "1.0.0";
2291
2116
  get defaultConfig() {
2292
2117
  return {
2293
- enabled: !0,
2294
2118
  maxSortColumns: 3,
2295
2119
  showSortIndex: !0
2296
2120
  };
@@ -2303,30 +2127,30 @@ class It extends y {
2303
2127
  }
2304
2128
  // ===== Hooks =====
2305
2129
  processRows(e) {
2306
- return this.sortModel.length === 0 ? [...e] : Xe([...e], this.sortModel, [...this.columns]);
2130
+ return this.sortModel.length === 0 ? [...e] : ct([...e], this.sortModel, [...this.columns]);
2307
2131
  }
2308
2132
  onHeaderClick(e) {
2309
- if (!this.columns.find((r) => r.field === e.field)?.sortable) return !1;
2310
- const n = e.originalEvent.shiftKey, o = this.config.maxSortColumns ?? 3;
2311
- return this.sortModel = Qe(this.sortModel, e.field, n, o), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), !0;
2133
+ if (!this.columns.find((i) => i.field === e.field)?.sortable) return !1;
2134
+ const o = e.originalEvent.shiftKey, n = this.config.maxSortColumns ?? 3;
2135
+ return this.sortModel = ht(this.sortModel, e.field, o, n), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), !0;
2312
2136
  }
2313
2137
  afterRender() {
2314
2138
  const e = this.shadowRoot;
2315
2139
  if (!e) return;
2316
2140
  const t = this.config.showSortIndex !== !1;
2317
- e.querySelectorAll(".header-row .cell[data-field]").forEach((o) => {
2318
- const r = o.getAttribute("data-field");
2319
- if (!r) return;
2320
- const s = le(this.sortModel, r), l = ae(this.sortModel, r);
2321
- if (o.querySelector(".sort-index")?.remove(), l) {
2322
- o.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), o.setAttribute("data-sort", l);
2141
+ e.querySelectorAll(".header-row .cell[data-field]").forEach((n) => {
2142
+ const i = n.getAttribute("data-field");
2143
+ if (!i) return;
2144
+ const r = he(this.sortModel, i), l = pe(this.sortModel, i);
2145
+ if (n.querySelector(".sort-index")?.remove(), l) {
2146
+ n.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), n.setAttribute("data-sort", l);
2323
2147
  const c = document.createElement("span");
2324
- if (c.className = "sort-indicator", c.style.marginLeft = "4px", c.style.opacity = "0.8", this.setIcon(c, this.resolveIcon(l === "asc" ? "sortAsc" : "sortDesc")), o.appendChild(c), t && this.sortModel.length > 1 && s !== void 0) {
2148
+ if (c.className = "sort-indicator", c.style.marginLeft = "4px", c.style.opacity = "0.8", this.setIcon(c, this.resolveIcon(l === "asc" ? "sortAsc" : "sortDesc")), n.appendChild(c), t && this.sortModel.length > 1 && r !== void 0) {
2325
2149
  const u = document.createElement("span");
2326
- u.className = "sort-index", u.textContent = String(s), o.appendChild(u);
2150
+ u.className = "sort-index", u.textContent = String(r), n.appendChild(u);
2327
2151
  }
2328
2152
  } else
2329
- o.removeAttribute("data-sort");
2153
+ n.removeAttribute("data-sort");
2330
2154
  });
2331
2155
  }
2332
2156
  // ===== Public API =====
@@ -2356,7 +2180,7 @@ class It extends y {
2356
2180
  * @returns 1-based index or undefined if not sorted
2357
2181
  */
2358
2182
  getSortIndex(e) {
2359
- return le(this.sortModel, e);
2183
+ return he(this.sortModel, e);
2360
2184
  }
2361
2185
  /**
2362
2186
  * Get the sort direction for a specific field.
@@ -2364,14 +2188,14 @@ class It extends y {
2364
2188
  * @returns Sort direction or undefined if not sorted
2365
2189
  */
2366
2190
  getSortDirection(e) {
2367
- return ae(this.sortModel, e);
2191
+ return pe(this.sortModel, e);
2368
2192
  }
2369
2193
  // ===== Column State Hooks =====
2370
2194
  /**
2371
2195
  * Return sort state for a column if it's in the sort model.
2372
2196
  */
2373
2197
  getColumnState(e) {
2374
- const t = this.sortModel.findIndex((o) => o.field === e);
2198
+ const t = this.sortModel.findIndex((n) => n.field === e);
2375
2199
  return t === -1 ? void 0 : {
2376
2200
  sort: {
2377
2201
  direction: this.sortModel[t].direction,
@@ -2385,91 +2209,65 @@ class It extends y {
2385
2209
  */
2386
2210
  applyColumnState(e, t) {
2387
2211
  if (!t.sort) {
2388
- this.sortModel = this.sortModel.filter((r) => r.field !== e);
2212
+ this.sortModel = this.sortModel.filter((i) => i.field !== e);
2389
2213
  return;
2390
2214
  }
2391
- const n = this.sortModel.findIndex((r) => r.field === e), o = {
2215
+ const o = this.sortModel.findIndex((i) => i.field === e), n = {
2392
2216
  field: e,
2393
2217
  direction: t.sort.direction
2394
2218
  };
2395
- n !== -1 ? this.sortModel[n] = o : this.sortModel.splice(t.sort.priority, 0, o);
2219
+ o !== -1 ? this.sortModel[o] = n : this.sortModel.splice(t.sort.priority, 0, n);
2396
2220
  }
2397
2221
  // ===== Styles =====
2398
- styles = `
2399
- .header-cell[data-sort="asc"]::after {
2400
- content: '↑';
2401
- margin-left: 4px;
2402
- opacity: 0.8;
2403
- }
2404
- .header-cell[data-sort="desc"]::after {
2405
- content: '↓';
2406
- margin-left: 4px;
2407
- opacity: 0.8;
2408
- }
2409
- .sort-index {
2410
- font-size: 10px;
2411
- background: var(--tbw-multi-sort-badge-bg, var(--tbw-color-panel-bg));
2412
- color: var(--tbw-multi-sort-badge-color, var(--tbw-color-fg));
2413
- border-radius: 50%;
2414
- width: 14px;
2415
- height: 14px;
2416
- display: inline-flex;
2417
- align-items: center;
2418
- justify-content: center;
2419
- margin-left: 2px;
2420
- font-weight: 600;
2421
- }
2422
- `;
2222
+ styles = pt;
2423
2223
  }
2424
- function Ze(i) {
2425
- return i.filter((e) => e.sticky === "left");
2224
+ function gt(s) {
2225
+ return s.filter((e) => e.sticky === "left");
2426
2226
  }
2427
- function et(i) {
2428
- return i.filter((e) => e.sticky === "right");
2227
+ function ft(s) {
2228
+ return s.filter((e) => e.sticky === "right");
2429
2229
  }
2430
- function O(i) {
2431
- return i.some((e) => e.sticky === "left" || e.sticky === "right");
2230
+ function K(s) {
2231
+ return s.some((e) => e.sticky === "left" || e.sticky === "right");
2432
2232
  }
2433
- function de(i, e) {
2434
- const t = i.shadowRoot;
2233
+ function ge(s, e) {
2234
+ const t = s.shadowRoot;
2435
2235
  if (!t) return;
2436
- const n = Array.from(t.querySelectorAll(".header-row .cell"));
2437
- if (!n.length) return;
2438
- const o = /* @__PURE__ */ new Map();
2236
+ const o = Array.from(t.querySelectorAll(".header-row .cell"));
2237
+ if (!o.length) return;
2238
+ const n = /* @__PURE__ */ new Map();
2439
2239
  e.forEach((l, a) => {
2440
- l.field && o.set(l.field, a);
2240
+ l.field && n.set(l.field, a);
2441
2241
  });
2442
- let r = 0;
2242
+ let i = 0;
2443
2243
  for (const l of e)
2444
2244
  if (l.sticky === "left") {
2445
- const a = o.get(l.field), d = n.find((c) => c.getAttribute("data-field") === l.field);
2446
- d && (d.classList.add("sticky-left"), d.style.left = r + "px", a !== void 0 && t.querySelectorAll(`.data-grid-row .cell[data-col="${a}"]`).forEach((c) => {
2447
- c.classList.add("sticky-left"), c.style.left = r + "px";
2448
- }), r += d.offsetWidth);
2245
+ const a = n.get(l.field), d = o.find((c) => c.getAttribute("data-field") === l.field);
2246
+ d && (d.classList.add("sticky-left"), d.style.left = i + "px", a !== void 0 && t.querySelectorAll(`.data-grid-row .cell[data-col="${a}"]`).forEach((c) => {
2247
+ c.classList.add("sticky-left"), c.style.left = i + "px";
2248
+ }), i += d.offsetWidth);
2449
2249
  }
2450
- let s = 0;
2250
+ let r = 0;
2451
2251
  for (const l of [...e].reverse())
2452
2252
  if (l.sticky === "right") {
2453
- const a = o.get(l.field), d = n.find((c) => c.getAttribute("data-field") === l.field);
2454
- d && (d.classList.add("sticky-right"), d.style.right = s + "px", a !== void 0 && t.querySelectorAll(`.data-grid-row .cell[data-col="${a}"]`).forEach((c) => {
2455
- c.classList.add("sticky-right"), c.style.right = s + "px";
2456
- }), s += d.offsetWidth);
2253
+ const a = n.get(l.field), d = o.find((c) => c.getAttribute("data-field") === l.field);
2254
+ d && (d.classList.add("sticky-right"), d.style.right = r + "px", a !== void 0 && t.querySelectorAll(`.data-grid-row .cell[data-col="${a}"]`).forEach((c) => {
2255
+ c.classList.add("sticky-right"), c.style.right = r + "px";
2256
+ }), r += d.offsetWidth);
2457
2257
  }
2458
2258
  }
2459
- function ce(i) {
2460
- const e = i.shadowRoot;
2259
+ function fe(s) {
2260
+ const e = s.shadowRoot;
2461
2261
  if (!e) return;
2462
- e.querySelectorAll(".sticky-left, .sticky-right").forEach((n) => {
2463
- n.classList.remove("sticky-left", "sticky-right"), n.style.left = "", n.style.right = "";
2262
+ e.querySelectorAll(".sticky-left, .sticky-right").forEach((o) => {
2263
+ o.classList.remove("sticky-left", "sticky-right"), o.style.left = "", o.style.right = "";
2464
2264
  });
2465
2265
  }
2466
- class _t extends y {
2266
+ class no extends C {
2467
2267
  name = "pinnedColumns";
2468
2268
  version = "1.0.0";
2469
2269
  get defaultConfig() {
2470
- return {
2471
- enabled: !0
2472
- };
2270
+ return {};
2473
2271
  }
2474
2272
  // ===== Internal State =====
2475
2273
  isApplied = !1;
@@ -2484,23 +2282,23 @@ class _t extends y {
2484
2282
  * Auto-detect sticky columns from column configuration.
2485
2283
  */
2486
2284
  static detect(e, t) {
2487
- const n = t?.columns;
2488
- return Array.isArray(n) ? O(n) : !1;
2285
+ const o = t?.columns;
2286
+ return Array.isArray(o) ? K(o) : !1;
2489
2287
  }
2490
2288
  // ===== Hooks =====
2491
2289
  processColumns(e) {
2492
- return this.config.enabled ? (this.isApplied = O([...e]), [...e]) : (this.isApplied = !1, [...e]);
2290
+ return this.isApplied = K([...e]), [...e];
2493
2291
  }
2494
2292
  afterRender() {
2495
- if (!this.config.enabled || !this.isApplied)
2293
+ if (!this.isApplied)
2496
2294
  return;
2497
2295
  const e = this.grid, t = [...this.columns];
2498
- if (!O(t)) {
2499
- ce(e), this.isApplied = !1;
2296
+ if (!K(t)) {
2297
+ fe(e), this.isApplied = !1;
2500
2298
  return;
2501
2299
  }
2502
2300
  queueMicrotask(() => {
2503
- de(e, t);
2301
+ ge(e, t);
2504
2302
  });
2505
2303
  }
2506
2304
  // ===== Public API =====
@@ -2509,117 +2307,117 @@ class _t extends y {
2509
2307
  */
2510
2308
  refreshStickyOffsets() {
2511
2309
  const e = [...this.columns];
2512
- de(this.grid, e);
2310
+ ge(this.grid, e);
2513
2311
  }
2514
2312
  /**
2515
2313
  * Get columns pinned to the left.
2516
2314
  */
2517
2315
  getLeftPinnedColumns() {
2518
2316
  const e = [...this.columns];
2519
- return Ze(e);
2317
+ return gt(e);
2520
2318
  }
2521
2319
  /**
2522
2320
  * Get columns pinned to the right.
2523
2321
  */
2524
2322
  getRightPinnedColumns() {
2525
2323
  const e = [...this.columns];
2526
- return et(e);
2324
+ return ft(e);
2527
2325
  }
2528
2326
  /**
2529
2327
  * Clear all sticky positioning.
2530
2328
  */
2531
2329
  clearStickyPositions() {
2532
- ce(this.grid);
2330
+ fe(this.grid);
2533
2331
  }
2534
2332
  }
2535
- function W(i, e) {
2333
+ function z(s, e) {
2536
2334
  const t = document.createElement("div");
2537
- t.className = "tbw-pinned-rows", t.setAttribute("role", "status"), t.setAttribute("aria-live", "polite");
2538
- const n = document.createElement("div");
2539
- n.className = "tbw-pinned-rows-left";
2335
+ t.className = "tbw-pinned-rows", t.setAttribute("role", "presentation"), t.setAttribute("aria-live", "polite");
2540
2336
  const o = document.createElement("div");
2541
- o.className = "tbw-pinned-rows-center";
2542
- const r = document.createElement("div");
2543
- if (r.className = "tbw-pinned-rows-right", i.showRowCount !== !1) {
2544
- const s = document.createElement("span");
2545
- s.className = "tbw-status-panel tbw-status-panel-row-count", s.textContent = `Total: ${e.totalRows} rows`, n.appendChild(s);
2546
- }
2547
- if (i.showFilteredCount && e.filteredRows !== e.totalRows) {
2548
- const s = document.createElement("span");
2549
- s.className = "tbw-status-panel tbw-status-panel-filtered-count", s.textContent = `Filtered: ${e.filteredRows}`, n.appendChild(s);
2550
- }
2551
- if (i.showSelectedCount && e.selectedRows > 0) {
2552
- const s = document.createElement("span");
2553
- s.className = "tbw-status-panel tbw-status-panel-selected-count", s.textContent = `Selected: ${e.selectedRows}`, r.appendChild(s);
2554
- }
2555
- if (i.customPanels)
2556
- for (const s of i.customPanels) {
2557
- const l = tt(s, e);
2558
- switch (s.position) {
2337
+ o.className = "tbw-pinned-rows-left";
2338
+ const n = document.createElement("div");
2339
+ n.className = "tbw-pinned-rows-center";
2340
+ const i = document.createElement("div");
2341
+ if (i.className = "tbw-pinned-rows-right", s.showRowCount !== !1) {
2342
+ const r = document.createElement("span");
2343
+ r.className = "tbw-status-panel tbw-status-panel-row-count", r.textContent = `Total: ${e.totalRows} rows`, o.appendChild(r);
2344
+ }
2345
+ if (s.showFilteredCount && e.filteredRows !== e.totalRows) {
2346
+ const r = document.createElement("span");
2347
+ r.className = "tbw-status-panel tbw-status-panel-filtered-count", r.textContent = `Filtered: ${e.filteredRows}`, o.appendChild(r);
2348
+ }
2349
+ if (s.showSelectedCount && e.selectedRows > 0) {
2350
+ const r = document.createElement("span");
2351
+ r.className = "tbw-status-panel tbw-status-panel-selected-count", r.textContent = `Selected: ${e.selectedRows}`, i.appendChild(r);
2352
+ }
2353
+ if (s.customPanels)
2354
+ for (const r of s.customPanels) {
2355
+ const l = mt(r, e);
2356
+ switch (r.position) {
2559
2357
  case "left":
2560
- n.appendChild(l);
2358
+ o.appendChild(l);
2561
2359
  break;
2562
2360
  case "center":
2563
- o.appendChild(l);
2361
+ n.appendChild(l);
2564
2362
  break;
2565
2363
  case "right":
2566
- r.appendChild(l);
2364
+ i.appendChild(l);
2567
2365
  break;
2568
2366
  }
2569
2367
  }
2570
- return t.appendChild(n), t.appendChild(o), t.appendChild(r), t;
2368
+ return t.appendChild(o), t.appendChild(n), t.appendChild(i), t;
2571
2369
  }
2572
- function ue(i) {
2370
+ function me(s) {
2573
2371
  const e = document.createElement("div");
2574
- return e.className = `tbw-aggregation-rows tbw-aggregation-rows-${i}`, e.setAttribute("role", "rowgroup"), e;
2575
- }
2576
- function he(i, e, t, n) {
2577
- i.innerHTML = "";
2578
- for (const o of e) {
2579
- const r = document.createElement("div");
2580
- if (r.className = "tbw-aggregation-row", r.setAttribute("role", "row"), o.id && r.setAttribute("data-aggregation-id", o.id), o.fullWidth) {
2581
- const s = document.createElement("div");
2582
- s.className = "tbw-aggregation-cell tbw-aggregation-cell-full", s.style.gridColumn = "1 / -1", s.textContent = o.label || "", r.appendChild(s);
2372
+ return e.className = `tbw-aggregation-rows tbw-aggregation-rows-${s}`, e.setAttribute("role", "presentation"), e;
2373
+ }
2374
+ function be(s, e, t, o) {
2375
+ s.innerHTML = "";
2376
+ for (const n of e) {
2377
+ const i = document.createElement("div");
2378
+ if (i.className = "tbw-aggregation-row", i.setAttribute("role", "presentation"), n.id && i.setAttribute("data-aggregation-id", n.id), n.fullWidth) {
2379
+ const r = document.createElement("div");
2380
+ r.className = "tbw-aggregation-cell tbw-aggregation-cell-full", r.style.gridColumn = "1 / -1", r.textContent = n.label || "", i.appendChild(r);
2583
2381
  } else
2584
- for (const s of t) {
2382
+ for (const r of t) {
2585
2383
  const l = document.createElement("div");
2586
- l.className = "tbw-aggregation-cell", l.setAttribute("data-field", s.field);
2384
+ l.className = "tbw-aggregation-cell", l.setAttribute("data-field", r.field);
2587
2385
  let a;
2588
- const d = o.aggregators?.[s.field];
2386
+ const d = n.aggregators?.[r.field];
2589
2387
  if (d) {
2590
- const c = ve(d);
2591
- c && (a = c(n, s.field, s));
2592
- } else if (o.cells && Object.prototype.hasOwnProperty.call(o.cells, s.field)) {
2593
- const c = o.cells[s.field];
2594
- typeof c == "function" ? a = c(n, s.field, s) : a = c;
2388
+ const c = Ie(d);
2389
+ c && (a = c(o, r.field, r));
2390
+ } else if (n.cells && Object.prototype.hasOwnProperty.call(n.cells, r.field)) {
2391
+ const c = n.cells[r.field];
2392
+ typeof c == "function" ? a = c(o, r.field, r) : a = c;
2595
2393
  }
2596
- l.textContent = a != null ? String(a) : "", r.appendChild(l);
2394
+ l.textContent = a != null ? String(a) : "", i.appendChild(l);
2597
2395
  }
2598
- i.appendChild(r);
2396
+ s.appendChild(i);
2599
2397
  }
2600
2398
  }
2601
- function tt(i, e) {
2399
+ function mt(s, e) {
2602
2400
  const t = document.createElement("div");
2603
- t.className = "tbw-status-panel tbw-status-panel-custom", t.id = `status-panel-${i.id}`;
2604
- const n = i.render(e);
2605
- return typeof n == "string" ? t.innerHTML = n : t.appendChild(n), t;
2401
+ t.className = "tbw-status-panel tbw-status-panel-custom", t.id = `status-panel-${s.id}`;
2402
+ const o = s.render(e);
2403
+ return typeof o == "string" ? t.innerHTML = o : t.appendChild(o), t;
2606
2404
  }
2607
- function fe(i, e, t, n, o) {
2405
+ function we(s, e, t, o, n) {
2608
2406
  return {
2609
- totalRows: i.length,
2610
- filteredRows: o?.cachedResult?.length ?? i.length,
2611
- selectedRows: n?.selected?.size ?? 0,
2407
+ totalRows: s.length,
2408
+ filteredRows: n?.cachedResult?.length ?? s.length,
2409
+ selectedRows: o?.selected?.size ?? 0,
2612
2410
  columns: e,
2613
- rows: i,
2411
+ rows: s,
2614
2412
  grid: t
2615
2413
  };
2616
2414
  }
2617
- class Tt extends y {
2415
+ const bt = ".tbw-footer{position:sticky;bottom:0;z-index:var(--tbw-z-layer-pinned-rows, 20);background:var(--tbw-color-panel-bg)}.tbw-pinned-rows{display:flex;align-items:center;justify-content:space-between;padding:8px 12px;background:var(--tbw-pinned-rows-bg, var(--tbw-color-panel-bg));border-top:1px solid var(--tbw-pinned-rows-border, var(--tbw-color-border));font-size:12px;color:var(--tbw-pinned-rows-color, var(--tbw-color-fg-muted));min-height:32px;box-sizing:border-box;min-width:fit-content}.tbw-pinned-rows-left,.tbw-pinned-rows-center,.tbw-pinned-rows-right{display:flex;align-items:center;gap:16px}.tbw-pinned-rows-left{justify-content:flex-start}.tbw-pinned-rows-center{justify-content:center;flex:1}.tbw-pinned-rows-right{justify-content:flex-end}.tbw-status-panel{white-space:nowrap}.tbw-aggregation-rows{min-width:fit-content;background:var(--tbw-aggregation-bg, var(--tbw-color-header-bg))}.tbw-aggregation-rows-top{border-bottom:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-rows-bottom{border-top:1px solid var(--tbw-aggregation-border, var(--tbw-color-border))}.tbw-aggregation-row{display:grid;grid-template-columns:var(--tbw-column-template);font-weight:var(--tbw-aggregation-font-weight, 600)}.tbw-aggregation-cell{padding:var(--tbw-cell-padding, 2px 8px);min-height:var(--tbw-row-height, 28px);display:flex;align-items:center;border-right:1px solid var(--tbw-color-border-cell)}.tbw-aggregation-cell:last-child{border-right:0}.tbw-aggregation-cell-full{grid-column:1 / -1;border-right:0}";
2416
+ class io extends C {
2618
2417
  name = "pinnedRows";
2619
2418
  version = "1.0.0";
2620
2419
  get defaultConfig() {
2621
2420
  return {
2622
- enabled: !0,
2623
2421
  position: "bottom",
2624
2422
  showRowCount: !0,
2625
2423
  showSelectedCount: !0,
@@ -2637,49 +2435,45 @@ class Tt extends y {
2637
2435
  }
2638
2436
  // ===== Hooks =====
2639
2437
  afterRender() {
2640
- if (!this.config.enabled) {
2641
- this.cleanup();
2642
- return;
2643
- }
2644
2438
  const e = this.shadowRoot;
2645
2439
  if (!e) return;
2646
2440
  const t = e.querySelector(".tbw-scroll-area") ?? e.querySelector(".tbw-grid-content") ?? e.children[0];
2647
2441
  if (!t) return;
2648
- const n = this.getSelectionState(), o = this.getFilterState(), r = fe(
2442
+ const o = this.getSelectionState(), n = this.getFilterState(), i = we(
2649
2443
  this.rows,
2650
2444
  this.columns,
2651
2445
  this.grid,
2652
- n,
2653
- o
2654
- ), s = this.config.aggregationRows || [], l = s.filter((h) => h.position === "top"), a = s.filter((h) => h.position !== "top");
2446
+ o,
2447
+ n
2448
+ ), r = this.config.aggregationRows || [], l = r.filter((h) => h.position === "top"), a = r.filter((h) => h.position !== "top");
2655
2449
  if (l.length > 0) {
2656
2450
  if (!this.topAggregationContainer) {
2657
- this.topAggregationContainer = ue("top");
2451
+ this.topAggregationContainer = me("top");
2658
2452
  const h = e.querySelector(".header");
2659
2453
  h && h.nextSibling ? t.insertBefore(this.topAggregationContainer, h.nextSibling) : t.appendChild(this.topAggregationContainer);
2660
2454
  }
2661
- he(
2455
+ be(
2662
2456
  this.topAggregationContainer,
2663
2457
  l,
2664
2458
  this.visibleColumns,
2665
2459
  this.rows
2666
2460
  );
2667
2461
  } else this.topAggregationContainer && (this.topAggregationContainer.remove(), this.topAggregationContainer = null);
2668
- const d = this.config.showRowCount !== !1 || this.config.showSelectedCount && r.selectedRows > 0 || this.config.showFilteredCount && r.filteredRows !== r.totalRows || this.config.customPanels && this.config.customPanels.length > 0, c = d && this.config.position !== "top", u = a.length > 0 || c;
2462
+ const d = this.config.showRowCount !== !1 || this.config.showSelectedCount && i.selectedRows > 0 || this.config.showFilteredCount && i.filteredRows !== i.totalRows || this.config.customPanels && this.config.customPanels.length > 0, c = d && this.config.position !== "top", u = a.length > 0 || c;
2669
2463
  if (d && this.config.position === "top")
2670
2464
  if (!this.infoBarElement)
2671
- this.infoBarElement = W(this.config, r), t.insertBefore(this.infoBarElement, t.firstChild);
2465
+ this.infoBarElement = z(this.config, i), t.insertBefore(this.infoBarElement, t.firstChild);
2672
2466
  else {
2673
- const h = W(this.config, r);
2467
+ const h = z(this.config, i);
2674
2468
  this.infoBarElement.replaceWith(h), this.infoBarElement = h;
2675
2469
  }
2676
2470
  else this.config.position === "top" && this.infoBarElement && (this.infoBarElement.remove(), this.infoBarElement = null);
2677
- u ? (this.footerWrapper || (this.footerWrapper = document.createElement("div"), this.footerWrapper.className = "tbw-footer", t.appendChild(this.footerWrapper)), this.footerWrapper.innerHTML = "", a.length > 0 && (this.bottomAggregationContainer || (this.bottomAggregationContainer = ue("bottom")), this.footerWrapper.appendChild(this.bottomAggregationContainer), he(
2471
+ u ? (this.footerWrapper || (this.footerWrapper = document.createElement("div"), this.footerWrapper.className = "tbw-footer", t.appendChild(this.footerWrapper)), this.footerWrapper.innerHTML = "", a.length > 0 && (this.bottomAggregationContainer || (this.bottomAggregationContainer = me("bottom")), this.footerWrapper.appendChild(this.bottomAggregationContainer), be(
2678
2472
  this.bottomAggregationContainer,
2679
2473
  a,
2680
2474
  this.visibleColumns,
2681
2475
  this.rows
2682
- )), c && (this.infoBarElement = W(this.config, r), this.footerWrapper.appendChild(this.infoBarElement))) : this.cleanupFooter();
2476
+ )), c && (this.infoBarElement = z(this.config, i), this.footerWrapper.appendChild(this.infoBarElement))) : this.cleanupFooter();
2683
2477
  }
2684
2478
  // ===== Private Methods =====
2685
2479
  cleanup() {
@@ -2715,7 +2509,7 @@ class Tt extends y {
2715
2509
  */
2716
2510
  getContext() {
2717
2511
  const e = this.getSelectionState(), t = this.getFilterState();
2718
- return fe(
2512
+ return we(
2719
2513
  this.rows,
2720
2514
  this.columns,
2721
2515
  this.grid,
@@ -2752,223 +2546,490 @@ class Tt extends y {
2752
2546
  this.config.aggregationRows && (this.config.aggregationRows = this.config.aggregationRows.filter((t) => t.id !== e), this.requestRender());
2753
2547
  }
2754
2548
  // ===== Styles =====
2755
- styles = `
2756
- .tbw-footer {
2757
- position: sticky;
2758
- bottom: 0;
2759
- z-index: var(--tbw-z-layer-pinned-rows, 20);
2760
- background: var(--tbw-color-panel-bg);
2761
- }
2762
-
2763
- .tbw-pinned-rows {
2764
- display: flex;
2765
- align-items: center;
2766
- justify-content: space-between;
2767
- padding: 8px 12px;
2768
- background: var(--tbw-pinned-rows-bg, var(--tbw-color-panel-bg));
2769
- border-top: 1px solid var(--tbw-pinned-rows-border, var(--tbw-color-border));
2770
- font-size: 12px;
2771
- color: var(--tbw-pinned-rows-color, var(--tbw-color-fg-muted));
2772
- min-height: 32px;
2773
- box-sizing: border-box;
2774
- min-width: fit-content;
2775
- }
2776
- .tbw-pinned-rows-left,
2777
- .tbw-pinned-rows-center,
2778
- .tbw-pinned-rows-right {
2779
- display: flex;
2780
- align-items: center;
2781
- gap: 16px;
2782
- }
2783
- .tbw-pinned-rows-left {
2784
- justify-content: flex-start;
2785
- }
2786
- .tbw-pinned-rows-center {
2787
- justify-content: center;
2788
- flex: 1;
2789
- }
2790
- .tbw-pinned-rows-right {
2791
- justify-content: flex-end;
2792
- }
2793
- .tbw-status-panel {
2794
- white-space: nowrap;
2795
- }
2796
-
2797
- .tbw-aggregation-rows {
2798
- min-width: fit-content;
2799
- background: var(--tbw-aggregation-bg, var(--tbw-color-header-bg));
2800
- }
2801
- .tbw-aggregation-rows-top {
2802
- border-bottom: 1px solid var(--tbw-aggregation-border, var(--tbw-color-border));
2803
- }
2804
- .tbw-aggregation-rows-bottom {
2805
- border-top: 1px solid var(--tbw-aggregation-border, var(--tbw-color-border));
2806
- }
2807
- .tbw-aggregation-row {
2808
- display: grid;
2809
- grid-template-columns: var(--tbw-column-template);
2810
- font-weight: var(--tbw-aggregation-font-weight, 600);
2811
- }
2812
- .tbw-aggregation-cell {
2813
- padding: var(--tbw-cell-padding, 2px 8px);
2814
- min-height: var(--tbw-row-height, 28px);
2815
- display: flex;
2816
- align-items: center;
2817
- border-right: 1px solid var(--tbw-color-border-cell);
2818
- }
2819
- .tbw-aggregation-cell:last-child {
2820
- border-right: 0;
2821
- }
2822
- .tbw-aggregation-cell-full {
2823
- grid-column: 1 / -1;
2824
- border-right: 0;
2825
- }
2826
- `;
2549
+ styles = bt;
2827
2550
  }
2828
- function nt(i) {
2551
+ const wt = Te;
2552
+ function vt(s) {
2829
2553
  const e = [];
2830
- 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;
2831
- }
2832
- function ot(i) {
2833
- switch (i) {
2834
- case "sum":
2835
- return (e) => e.reduce((t, n) => t + n, 0);
2836
- case "avg":
2837
- return (e) => e.length ? e.reduce((t, n) => t + n, 0) / e.length : 0;
2838
- case "count":
2839
- return (e) => e.length;
2840
- case "min":
2841
- return (e) => e.length ? Math.min(...e) : 0;
2842
- case "max":
2843
- return (e) => e.length ? Math.max(...e) : 0;
2844
- case "first":
2845
- return (e) => e[0] ?? 0;
2846
- case "last":
2847
- return (e) => e[e.length - 1] ?? 0;
2848
- default:
2849
- return (e) => e.reduce((t, n) => t + n, 0);
2850
- }
2851
- }
2852
- function $(i, e) {
2853
- return [...i, e].join("|");
2854
- }
2855
- function rt(i, e) {
2856
- const t = e.rowGroupFields ?? [], n = e.columnGroupFields ?? [], o = e.valueFields ?? [], r = it(i, n), s = st(i, t), l = lt(s, n, r, o, 0), a = at(l, r, o), d = Object.values(a).reduce((c, u) => c + u, 0);
2554
+ return !s.rowGroupFields?.length && !s.columnGroupFields?.length && e.push("At least one row or column group field is required"), s.valueFields?.length || e.push("At least one value field is required"), e;
2555
+ }
2556
+ function X(s, e) {
2557
+ return [...s, e].join("|");
2558
+ }
2559
+ function xt(s, e) {
2560
+ const t = e.rowGroupFields ?? [], o = e.columnGroupFields ?? [], n = e.valueFields ?? [], i = Ct(s, o), r = Ae(
2561
+ s,
2562
+ t,
2563
+ o,
2564
+ i,
2565
+ n,
2566
+ 0,
2567
+ // starting depth
2568
+ ""
2569
+ // parent key prefix
2570
+ ), l = Rt(r, i, n), a = Object.values(l).reduce((d, c) => d + c, 0);
2857
2571
  return {
2858
- rows: l,
2859
- columnKeys: r,
2860
- totals: a,
2861
- grandTotal: d
2572
+ rows: r,
2573
+ columnKeys: i,
2574
+ totals: l,
2575
+ grandTotal: a
2862
2576
  };
2863
2577
  }
2864
- function it(i, e) {
2578
+ function Ct(s, e) {
2865
2579
  if (e.length === 0) return ["value"];
2866
2580
  const t = /* @__PURE__ */ new Set();
2867
- for (const n of i) {
2868
- const o = e.map((r) => String(n[r] ?? "")).join("|");
2869
- t.add(o);
2581
+ for (const o of s) {
2582
+ const n = e.map((i) => String(o[i] ?? "")).join("|");
2583
+ t.add(n);
2870
2584
  }
2871
2585
  return [...t].sort();
2872
2586
  }
2873
- function st(i, e) {
2587
+ function yt(s, e) {
2874
2588
  const t = /* @__PURE__ */ new Map();
2875
- for (const n of i) {
2876
- const o = e.map((s) => String(n[s] ?? "")).join("|");
2877
- t.has(o) || t.set(o, []);
2878
- const r = t.get(o);
2879
- r && r.push(n);
2589
+ for (const o of s) {
2590
+ const n = String(o[e] ?? ""), i = t.get(n);
2591
+ i ? i.push(o) : t.set(n, [o]);
2880
2592
  }
2881
2593
  return t;
2882
2594
  }
2883
- function lt(i, e, t, n, o) {
2884
- const r = [];
2885
- for (const [s, l] of i) {
2886
- const a = {};
2887
- let d = 0;
2888
- for (const c of t)
2889
- for (const u of n) {
2890
- const f = (e.length > 0 ? l.filter((S) => e.map((R) => String(S[R] ?? "")).join("|") === c) : l).map((S) => Number(S[u.field]) || 0), g = ot(u.aggFunc), m = f.length > 0 ? g(f) : null, b = $([c], u.field);
2891
- a[b] = m, m !== null && (d += m);
2892
- }
2893
- r.push({
2894
- rowKey: s,
2895
- rowLabel: s || "(blank)",
2896
- depth: o,
2897
- values: a,
2898
- total: d,
2899
- isGroup: !1
2595
+ function Ae(s, e, t, o, n, i, r) {
2596
+ const l = [];
2597
+ if (e.length === 0) {
2598
+ const h = ve(s, t, o, n), p = xe(h);
2599
+ return l.push({
2600
+ rowKey: r || "all",
2601
+ rowLabel: r || "All",
2602
+ depth: i,
2603
+ values: h,
2604
+ total: p,
2605
+ isGroup: !1,
2606
+ rowCount: s.length
2607
+ }), l;
2608
+ }
2609
+ const a = e[0], d = e.slice(1), c = d.length > 0, u = yt(s, a);
2610
+ for (const [h, p] of u) {
2611
+ const g = r ? `${r}|${h}` : h, m = ve(p, t, o, n), b = xe(m);
2612
+ let R;
2613
+ c && (R = Ae(
2614
+ p,
2615
+ d,
2616
+ t,
2617
+ o,
2618
+ n,
2619
+ i + 1,
2620
+ g
2621
+ )), l.push({
2622
+ rowKey: g,
2623
+ rowLabel: h || "(blank)",
2624
+ depth: i,
2625
+ values: m,
2626
+ total: b,
2627
+ isGroup: c,
2628
+ children: R,
2629
+ rowCount: p.length
2900
2630
  });
2901
2631
  }
2902
- return r;
2632
+ return l;
2903
2633
  }
2904
- function at(i, e, t) {
2634
+ function ve(s, e, t, o) {
2905
2635
  const n = {};
2906
- for (const o of e)
2907
- for (const r of t) {
2908
- const s = $([o], r.field);
2909
- n[s] = i.reduce((l, a) => l + (a.values[s] ?? 0), 0);
2636
+ for (const i of t)
2637
+ for (const r of o) {
2638
+ const a = (e.length > 0 ? s.filter((h) => e.map((p) => String(h[p] ?? "")).join("|") === i) : s).map((h) => Number(h[r.field]) || 0), d = wt(r.aggFunc), c = a.length > 0 ? d(a) : null, u = X([i], r.field);
2639
+ n[u] = c;
2910
2640
  }
2911
2641
  return n;
2912
2642
  }
2913
- function dt(i) {
2643
+ function xe(s) {
2644
+ let e = 0;
2645
+ for (const t of Object.values(s))
2646
+ e += t ?? 0;
2647
+ return e;
2648
+ }
2649
+ function Rt(s, e, t) {
2650
+ const o = {};
2651
+ function n(i) {
2652
+ for (const r of i)
2653
+ if (!r.isGroup || !r.children?.length)
2654
+ for (const l of e)
2655
+ for (const a of t) {
2656
+ const d = X([l], a.field);
2657
+ o[d] = (o[d] ?? 0) + (r.values[d] ?? 0);
2658
+ }
2659
+ else r.children && n(r.children);
2660
+ }
2661
+ return n(s), o;
2662
+ }
2663
+ function St(s, e, t = !0) {
2664
+ const o = [];
2665
+ function n(i) {
2666
+ o.push(i);
2667
+ const r = e ? e.has(i.rowKey) : t;
2668
+ if (i.children && r)
2669
+ for (const l of i.children)
2670
+ n(l);
2671
+ }
2672
+ for (const i of s)
2673
+ n(i);
2674
+ return o;
2675
+ }
2676
+ function W(s) {
2914
2677
  const e = [];
2915
- function t(n) {
2916
- if (e.push(n), n.children)
2917
- for (const o of n.children)
2918
- t(o);
2678
+ function t(o) {
2679
+ if (o.isGroup && e.push(o.rowKey), o.children)
2680
+ for (const n of o.children)
2681
+ t(n);
2919
2682
  }
2920
- for (const n of i)
2921
- t(n);
2683
+ for (const o of s)
2684
+ t(o);
2922
2685
  return e;
2923
2686
  }
2924
- class Lt extends y {
2687
+ const Et = ["sum", "avg", "count", "min", "max", "first", "last"];
2688
+ function kt(s, e, t, o) {
2689
+ const n = new AbortController(), i = { config: e, callbacks: o, signal: n.signal }, r = document.createElement("div");
2690
+ return r.className = "tbw-pivot-panel", r.appendChild(T("Options", () => Ft(t, i))), r.appendChild(T("Row Groups", () => Ce("rowGroups", i))), r.appendChild(T("Column Groups", () => Ce("columnGroups", i))), r.appendChild(T("Values", () => _t(i))), r.appendChild(T("Available Fields", () => Tt(i))), s.appendChild(r), () => {
2691
+ n.abort(), r.remove();
2692
+ };
2693
+ }
2694
+ function T(s, e) {
2695
+ const t = document.createElement("div");
2696
+ t.className = "tbw-pivot-section";
2697
+ const o = document.createElement("div");
2698
+ o.className = "tbw-pivot-section-header", o.textContent = s;
2699
+ const n = document.createElement("div");
2700
+ return n.className = "tbw-pivot-section-content", n.appendChild(e()), t.appendChild(o), t.appendChild(n), t;
2701
+ }
2702
+ function Ce(s, e) {
2703
+ const { config: t, callbacks: o, signal: n } = e, i = document.createElement("div");
2704
+ i.className = "tbw-pivot-drop-zone", i.setAttribute("data-zone", s);
2705
+ const r = s === "rowGroups" ? t.rowGroupFields ?? [] : t.columnGroupFields ?? [];
2706
+ if (r.length === 0) {
2707
+ const l = document.createElement("div");
2708
+ l.className = "tbw-pivot-placeholder", l.textContent = "Drag fields here or click to add", i.appendChild(l);
2709
+ } else
2710
+ for (const l of r)
2711
+ i.appendChild(At(l, s, e));
2712
+ return i.addEventListener(
2713
+ "dragover",
2714
+ (l) => {
2715
+ l.preventDefault(), i.classList.add("drag-over");
2716
+ },
2717
+ { signal: n }
2718
+ ), i.addEventListener(
2719
+ "dragleave",
2720
+ () => {
2721
+ i.classList.remove("drag-over");
2722
+ },
2723
+ { signal: n }
2724
+ ), i.addEventListener(
2725
+ "drop",
2726
+ (l) => {
2727
+ l.preventDefault(), i.classList.remove("drag-over");
2728
+ const a = l.dataTransfer?.getData("text/plain");
2729
+ a && o.onAddFieldToZone(a, s);
2730
+ },
2731
+ { signal: n }
2732
+ ), i;
2733
+ }
2734
+ function At(s, e, t) {
2735
+ const { callbacks: o, signal: n } = t, i = document.createElement("div");
2736
+ i.className = "tbw-pivot-field-chip", i.draggable = !0;
2737
+ const r = o.getAvailableFields().find((d) => d.field === s), l = document.createElement("span");
2738
+ l.className = "tbw-pivot-chip-label", l.textContent = r?.header ?? s;
2739
+ const a = document.createElement("button");
2740
+ return a.className = "tbw-pivot-chip-remove", a.innerHTML = "×", a.title = "Remove field", a.addEventListener(
2741
+ "click",
2742
+ (d) => {
2743
+ d.stopPropagation(), o.onRemoveFieldFromZone(s, e);
2744
+ },
2745
+ { signal: n }
2746
+ ), i.appendChild(l), i.appendChild(a), i.addEventListener(
2747
+ "dragstart",
2748
+ (d) => {
2749
+ d.dataTransfer?.setData("text/plain", s), d.dataTransfer?.setData("source-zone", e), i.classList.add("dragging");
2750
+ },
2751
+ { signal: n }
2752
+ ), i.addEventListener(
2753
+ "dragend",
2754
+ () => {
2755
+ i.classList.remove("dragging");
2756
+ },
2757
+ { signal: n }
2758
+ ), i;
2759
+ }
2760
+ function _t(s) {
2761
+ const { config: e, callbacks: t, signal: o } = s, n = document.createElement("div");
2762
+ n.className = "tbw-pivot-drop-zone tbw-pivot-values-zone", n.setAttribute("data-zone", "values");
2763
+ const i = e.valueFields ?? [];
2764
+ if (i.length === 0) {
2765
+ const r = document.createElement("div");
2766
+ r.className = "tbw-pivot-placeholder", r.textContent = "Drag numeric fields here for aggregation", n.appendChild(r);
2767
+ } else
2768
+ for (const r of i)
2769
+ n.appendChild(It(r, s));
2770
+ return n.addEventListener(
2771
+ "dragover",
2772
+ (r) => {
2773
+ r.preventDefault(), n.classList.add("drag-over");
2774
+ },
2775
+ { signal: o }
2776
+ ), n.addEventListener(
2777
+ "dragleave",
2778
+ () => {
2779
+ n.classList.remove("drag-over");
2780
+ },
2781
+ { signal: o }
2782
+ ), n.addEventListener(
2783
+ "drop",
2784
+ (r) => {
2785
+ r.preventDefault(), n.classList.remove("drag-over");
2786
+ const l = r.dataTransfer?.getData("text/plain");
2787
+ l && t.onAddValueField(l, "sum");
2788
+ },
2789
+ { signal: o }
2790
+ ), n;
2791
+ }
2792
+ function It(s, e) {
2793
+ const { callbacks: t, signal: o } = e, n = document.createElement("div");
2794
+ n.className = "tbw-pivot-field-chip tbw-pivot-value-chip";
2795
+ const i = t.getAvailableFields().find((c) => c.field === s.field), r = document.createElement("div");
2796
+ r.className = "tbw-pivot-value-label-wrapper";
2797
+ const l = document.createElement("span");
2798
+ l.className = "tbw-pivot-chip-label", l.textContent = i?.header ?? s.field;
2799
+ const a = document.createElement("select");
2800
+ a.className = "tbw-pivot-agg-select", a.title = "Aggregation function";
2801
+ for (const c of Et) {
2802
+ const u = document.createElement("option");
2803
+ u.value = c, u.textContent = c.toUpperCase(), u.selected = c === s.aggFunc, a.appendChild(u);
2804
+ }
2805
+ a.addEventListener(
2806
+ "change",
2807
+ () => {
2808
+ t.onUpdateValueAggFunc(s.field, a.value);
2809
+ },
2810
+ { signal: o }
2811
+ );
2812
+ const d = document.createElement("button");
2813
+ return d.className = "tbw-pivot-chip-remove", d.innerHTML = "×", d.title = "Remove value field", d.addEventListener(
2814
+ "click",
2815
+ (c) => {
2816
+ c.stopPropagation(), t.onRemoveValueField(s.field);
2817
+ },
2818
+ { signal: o }
2819
+ ), r.appendChild(l), r.appendChild(a), n.appendChild(r), n.appendChild(d), n;
2820
+ }
2821
+ function Tt(s) {
2822
+ const { config: e, callbacks: t, signal: o } = s, n = document.createElement("div");
2823
+ n.className = "tbw-pivot-available-fields";
2824
+ const i = t.getAvailableFields(), r = /* @__PURE__ */ new Set([
2825
+ ...e.rowGroupFields ?? [],
2826
+ ...e.columnGroupFields ?? [],
2827
+ ...e.valueFields?.map((a) => a.field) ?? []
2828
+ ]), l = i.filter((a) => !r.has(a.field));
2829
+ if (l.length === 0) {
2830
+ const a = document.createElement("div");
2831
+ a.className = "tbw-pivot-placeholder", a.textContent = "All fields are in use", n.appendChild(a);
2832
+ } else
2833
+ for (const a of l) {
2834
+ const d = document.createElement("div");
2835
+ d.className = "tbw-pivot-field-chip available", d.textContent = a.header, d.draggable = !0, d.title = `Drag to add "${a.field}" to a zone`, d.addEventListener(
2836
+ "dragstart",
2837
+ (c) => {
2838
+ c.dataTransfer?.setData("text/plain", a.field), d.classList.add("dragging");
2839
+ },
2840
+ { signal: o }
2841
+ ), d.addEventListener(
2842
+ "dragend",
2843
+ () => {
2844
+ d.classList.remove("dragging");
2845
+ },
2846
+ { signal: o }
2847
+ ), n.appendChild(d);
2848
+ }
2849
+ return n;
2850
+ }
2851
+ function Ft(s, e) {
2852
+ const { config: t, callbacks: o, signal: n } = e, i = document.createElement("div");
2853
+ return i.className = "tbw-pivot-options", i.appendChild(
2854
+ $(
2855
+ "Enable Pivot View",
2856
+ s,
2857
+ (r) => {
2858
+ o.onTogglePivot(r);
2859
+ },
2860
+ n
2861
+ )
2862
+ ), i.appendChild(
2863
+ $(
2864
+ "Show Row Totals",
2865
+ t.showTotals ?? !0,
2866
+ (r) => {
2867
+ o.onOptionChange("showTotals", r);
2868
+ },
2869
+ n
2870
+ )
2871
+ ), i.appendChild(
2872
+ $(
2873
+ "Show Grand Total",
2874
+ t.showGrandTotal ?? !0,
2875
+ (r) => {
2876
+ o.onOptionChange("showGrandTotal", r);
2877
+ },
2878
+ n
2879
+ )
2880
+ ), i;
2881
+ }
2882
+ function $(s, e, t, o) {
2883
+ const n = document.createElement("label");
2884
+ n.className = "tbw-pivot-checkbox";
2885
+ const i = document.createElement("input");
2886
+ i.type = "checkbox", i.checked = e, i.addEventListener("change", () => t(i.checked), { signal: o });
2887
+ const r = document.createElement("span");
2888
+ return r.textContent = s, n.appendChild(i), n.appendChild(r), n;
2889
+ }
2890
+ function Lt(s, e, t) {
2891
+ return e.className = "pivot-group-row", e.setAttribute("data-pivot-depth", String(s.__pivotDepth ?? 0)), e.setAttribute("role", "row"), e.innerHTML = "", t.columns.forEach((o, n) => {
2892
+ const i = document.createElement("div");
2893
+ if (i.className = "cell", i.setAttribute("data-col", String(n)), i.setAttribute("role", "gridcell"), n === 0) {
2894
+ const r = Number(s.__pivotIndent) || 0;
2895
+ i.style.paddingLeft = `${r}px`;
2896
+ const l = String(s.__pivotRowKey), a = document.createElement("button");
2897
+ a.type = "button", a.className = "pivot-toggle", a.setAttribute("aria-label", s.__pivotExpanded ? "Collapse group" : "Expand group"), t.setIcon(a, t.resolveIcon(s.__pivotExpanded ? "collapse" : "expand")), a.addEventListener("click", (u) => {
2898
+ u.stopPropagation(), t.onToggle(l);
2899
+ }), i.appendChild(a);
2900
+ const d = document.createElement("span");
2901
+ d.className = "pivot-label", d.textContent = String(s.__pivotLabel ?? ""), i.appendChild(d);
2902
+ const c = document.createElement("span");
2903
+ c.className = "pivot-count", c.textContent = ` (${Number(s.__pivotRowCount) || 0})`, i.appendChild(c);
2904
+ } else {
2905
+ const r = s[o.field];
2906
+ i.textContent = r != null ? String(r) : "";
2907
+ }
2908
+ e.appendChild(i);
2909
+ }), !0;
2910
+ }
2911
+ function Nt(s, e, t) {
2912
+ return e.className = "pivot-leaf-row", e.setAttribute("data-pivot-depth", String(s.__pivotDepth ?? 0)), e.innerHTML = "", t.forEach((o, n) => {
2913
+ const i = document.createElement("div");
2914
+ if (i.className = "cell", i.setAttribute("data-col", String(n)), i.setAttribute("role", "gridcell"), n === 0) {
2915
+ const r = Number(s.__pivotIndent) || 0;
2916
+ i.style.paddingLeft = `${r + 20}px`;
2917
+ const l = document.createElement("span");
2918
+ l.className = "pivot-label", l.textContent = String(s.__pivotLabel ?? ""), i.appendChild(l);
2919
+ } else {
2920
+ const r = s[o.field];
2921
+ i.textContent = r != null ? String(r) : "";
2922
+ }
2923
+ e.appendChild(i);
2924
+ }), !0;
2925
+ }
2926
+ function Mt(s, e, t) {
2927
+ return e.className = "pivot-grand-total-row", e.setAttribute("role", "presentation"), e.innerHTML = "", t.forEach((o, n) => {
2928
+ const i = document.createElement("div");
2929
+ if (i.className = "cell", i.setAttribute("data-col", String(n)), n === 0) {
2930
+ const r = document.createElement("span");
2931
+ r.className = "pivot-label", r.textContent = "Grand Total", i.appendChild(r);
2932
+ } else {
2933
+ const r = s[o.field];
2934
+ i.textContent = r != null ? String(r) : "";
2935
+ }
2936
+ e.appendChild(i);
2937
+ }), !0;
2938
+ }
2939
+ const Pt = '.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}';
2940
+ class F extends C {
2925
2941
  name = "pivot";
2926
2942
  version = "1.0.0";
2943
+ /** Tool panel ID for shell integration */
2944
+ static PANEL_ID = "pivot";
2927
2945
  get defaultConfig() {
2928
2946
  return {
2929
- enabled: !0,
2947
+ active: !0,
2930
2948
  showTotals: !0,
2931
2949
  showGrandTotal: !0
2932
2950
  };
2933
2951
  }
2934
2952
  // ===== Internal State =====
2935
2953
  isActive = !1;
2954
+ hasInitialized = !1;
2936
2955
  pivotResult = null;
2937
- columnHeaders = [];
2938
- rowHeaders = [];
2956
+ fieldHeaderMap = /* @__PURE__ */ new Map();
2957
+ expandedKeys = /* @__PURE__ */ new Set();
2958
+ defaultExpanded = !0;
2959
+ originalColumns = [];
2960
+ panelContainer = null;
2961
+ grandTotalFooter = null;
2962
+ /**
2963
+ * Check if the plugin has valid pivot configuration (at least value fields).
2964
+ */
2965
+ hasValidPivotConfig() {
2966
+ return (this.config.valueFields?.length ?? 0) > 0;
2967
+ }
2939
2968
  // ===== Lifecycle =====
2940
2969
  detach() {
2941
- this.isActive = !1, this.pivotResult = null, this.columnHeaders = [], this.rowHeaders = [];
2970
+ this.isActive = !1, this.hasInitialized = !1, this.pivotResult = null, this.fieldHeaderMap.clear(), this.originalColumns = [], this.panelContainer = null, this.cleanupGrandTotalFooter();
2971
+ }
2972
+ // ===== Shell Integration =====
2973
+ getToolPanel() {
2974
+ return {
2975
+ id: F.PANEL_ID,
2976
+ title: "Pivot",
2977
+ icon: "⊞",
2978
+ tooltip: "Configure pivot table",
2979
+ order: 90,
2980
+ render: (e) => this.renderPanel(e)
2981
+ };
2942
2982
  }
2943
2983
  // ===== Hooks =====
2944
2984
  processRows(e) {
2945
- if (!this.config.enabled || !this.isActive)
2985
+ if (!this.hasInitialized && this.config.active !== !1 && this.hasValidPivotConfig() && (this.hasInitialized = !0, this.isActive = !0), !this.isActive)
2946
2986
  return [...e];
2947
- const t = nt(this.config);
2948
- return t.length > 0 ? (this.warn(`Config errors: ${t.join(", ")}`), [...e]) : (this.pivotResult = rt(e, this.config), dt(this.pivotResult.rows).map((n) => ({
2949
- __pivotRowKey: n.rowKey,
2950
- __pivotLabel: n.rowLabel,
2951
- __pivotDepth: n.depth,
2952
- __pivotIsGroup: n.isGroup,
2953
- __pivotTotal: n.total,
2954
- ...n.values
2955
- })));
2987
+ const t = vt(this.config);
2988
+ if (t.length > 0)
2989
+ return this.warn(`Config errors: ${t.join(", ")}`), [...e];
2990
+ if (this.buildFieldHeaderMap(), this.defaultExpanded = this.config.defaultExpanded ?? !0, this.expandedKeys.size === 0 && this.defaultExpanded && this.pivotResult) {
2991
+ const i = W(this.pivotResult.rows);
2992
+ for (const r of i)
2993
+ this.expandedKeys.add(r);
2994
+ }
2995
+ if (this.pivotResult = xt(e, this.config), this.expandedKeys.size === 0 && this.defaultExpanded) {
2996
+ const i = W(this.pivotResult.rows);
2997
+ for (const r of i)
2998
+ this.expandedKeys.add(r);
2999
+ }
3000
+ const o = this.config.indentWidth ?? 20;
3001
+ return St(
3002
+ this.pivotResult.rows,
3003
+ this.expandedKeys,
3004
+ this.defaultExpanded
3005
+ ).map((i) => ({
3006
+ __pivotRowKey: i.rowKey,
3007
+ __pivotLabel: i.rowLabel,
3008
+ __pivotDepth: i.depth,
3009
+ __pivotIsGroup: i.isGroup,
3010
+ __pivotHasChildren: !!i.children?.length,
3011
+ __pivotExpanded: this.expandedKeys.has(i.rowKey),
3012
+ __pivotRowCount: i.rowCount ?? 0,
3013
+ __pivotIndent: i.depth * o,
3014
+ __pivotTotal: i.total,
3015
+ ...i.values
3016
+ }));
2956
3017
  }
2957
3018
  processColumns(e) {
2958
- if (!this.config.enabled || !this.isActive || !this.pivotResult)
3019
+ if (!this.isActive || !this.pivotResult)
2959
3020
  return [...e];
2960
- const t = [];
3021
+ const t = [], o = (this.config.rowGroupFields ?? []).map((n) => this.fieldHeaderMap.get(n) ?? n).join(" / ");
2961
3022
  t.push({
2962
3023
  field: "__pivotLabel",
2963
- header: this.config.rowGroupFields?.join(" / ") ?? "Group",
3024
+ header: o || "Group",
2964
3025
  width: 200
2965
3026
  });
2966
3027
  for (const n of this.pivotResult.columnKeys)
2967
- for (const o of this.config.valueFields ?? []) {
2968
- const r = $([n], o.field);
3028
+ for (const i of this.config.valueFields ?? []) {
3029
+ const r = X([n], i.field), l = i.header || this.fieldHeaderMap.get(i.field) || i.field;
2969
3030
  t.push({
2970
3031
  field: r,
2971
- header: `${n} - ${o.header || o.field} (${o.aggFunc})`,
3032
+ header: `${n} - ${l} (${i.aggFunc})`,
2972
3033
  width: 120,
2973
3034
  type: "number"
2974
3035
  });
@@ -2980,85 +3041,207 @@ class Lt extends y {
2980
3041
  type: "number"
2981
3042
  }), t;
2982
3043
  }
2983
- // ===== Public API =====
3044
+ renderRow(e, t) {
3045
+ const o = e;
3046
+ return o.__pivotRowKey && o.__pivotHasChildren ? Lt(o, t, {
3047
+ columns: this.gridColumns,
3048
+ onToggle: (n) => this.toggle(n),
3049
+ resolveIcon: (n) => this.resolveIcon(n),
3050
+ setIcon: (n, i) => this.setIcon(n, i)
3051
+ }) : o.__pivotRowKey !== void 0 && this.isActive ? Nt(o, t, this.gridColumns) : (this.cleanupPivotStyling(t), !1);
3052
+ }
2984
3053
  /**
2985
- * Enable pivot mode.
3054
+ * Remove pivot-specific classes, attributes, and inline styles from a row element.
3055
+ * Called when pivot mode is disabled to clean up reused DOM elements.
3056
+ * Clears innerHTML so the grid's default renderer can rebuild the row.
2986
3057
  */
2987
- enablePivot() {
2988
- this.isActive = !0, this.requestRender();
3058
+ cleanupPivotStyling(e) {
3059
+ (e.classList.contains("pivot-group-row") || e.classList.contains("pivot-leaf-row") || e.classList.contains("pivot-grand-total-row")) && (e.classList.remove("pivot-group-row", "pivot-leaf-row", "pivot-grand-total-row"), e.classList.add("data-grid-row"), e.removeAttribute("data-pivot-depth"), e.innerHTML = "");
3060
+ }
3061
+ afterRender() {
3062
+ this.isActive && this.config.showGrandTotal && this.pivotResult ? this.renderGrandTotalFooter() : this.cleanupGrandTotalFooter();
2989
3063
  }
2990
3064
  /**
2991
- * Disable pivot mode and return to normal grid view.
3065
+ * Render the grand total row as a sticky footer pinned to the bottom.
2992
3066
  */
2993
- disablePivot() {
2994
- this.isActive = !1, this.pivotResult = null, this.requestRender();
3067
+ renderGrandTotalFooter() {
3068
+ if (!this.pivotResult) return;
3069
+ const e = this.shadowRoot;
3070
+ if (!e) return;
3071
+ const t = e.querySelector(".tbw-scroll-area") ?? e.querySelector(".tbw-grid-content") ?? e.children[0];
3072
+ if (!t) return;
3073
+ this.grandTotalFooter || (this.grandTotalFooter = document.createElement("div"), this.grandTotalFooter.className = "pivot-grand-total-footer", t.appendChild(this.grandTotalFooter));
3074
+ const o = {
3075
+ __pivotRowKey: "__grandTotal",
3076
+ __pivotLabel: "Grand Total",
3077
+ __pivotIsGrandTotal: !0,
3078
+ __pivotTotal: this.pivotResult.grandTotal,
3079
+ ...this.pivotResult.totals
3080
+ };
3081
+ Mt(o, this.grandTotalFooter, this.gridColumns);
2995
3082
  }
2996
3083
  /**
2997
- * Check if pivot mode is currently active.
3084
+ * Remove the grand total footer element.
2998
3085
  */
3086
+ cleanupGrandTotalFooter() {
3087
+ this.grandTotalFooter && (this.grandTotalFooter.remove(), this.grandTotalFooter = null);
3088
+ }
3089
+ // ===== Expand/Collapse API =====
3090
+ toggle(e) {
3091
+ this.expandedKeys.has(e) ? this.expandedKeys.delete(e) : this.expandedKeys.add(e), this.requestRender();
3092
+ }
3093
+ expand(e) {
3094
+ this.expandedKeys.add(e), this.requestRender();
3095
+ }
3096
+ collapse(e) {
3097
+ this.expandedKeys.delete(e), this.requestRender();
3098
+ }
3099
+ expandAll() {
3100
+ if (this.pivotResult) {
3101
+ const e = W(this.pivotResult.rows);
3102
+ for (const t of e)
3103
+ this.expandedKeys.add(t);
3104
+ this.requestRender();
3105
+ }
3106
+ }
3107
+ collapseAll() {
3108
+ this.expandedKeys.clear(), this.requestRender();
3109
+ }
3110
+ isExpanded(e) {
3111
+ return this.expandedKeys.has(e);
3112
+ }
3113
+ // ===== Public API =====
3114
+ enablePivot() {
3115
+ this.originalColumns.length === 0 && this.captureOriginalColumns(), this.isActive = !0, this.requestRender();
3116
+ }
3117
+ disablePivot() {
3118
+ this.isActive = !1, this.pivotResult = null, this.requestRender();
3119
+ }
2999
3120
  isPivotActive() {
3000
3121
  return this.isActive;
3001
3122
  }
3002
- /**
3003
- * Get the current pivot result.
3004
- */
3005
3123
  getPivotResult() {
3006
3124
  return this.pivotResult;
3007
3125
  }
3008
- /**
3009
- * Set the row group fields for pivoting.
3010
- * @param fields - Array of field names to group rows by
3011
- */
3012
3126
  setRowGroupFields(e) {
3013
3127
  this.config.rowGroupFields = e, this.requestRender();
3014
3128
  }
3015
- /**
3016
- * Set the column group fields for pivoting.
3017
- * @param fields - Array of field names to create columns from
3018
- */
3019
3129
  setColumnGroupFields(e) {
3020
3130
  this.config.columnGroupFields = e, this.requestRender();
3021
3131
  }
3022
- /**
3023
- * Set the value fields with aggregation functions.
3024
- * @param fields - Array of value field configurations
3025
- */
3026
3132
  setValueFields(e) {
3027
3133
  this.config.valueFields = e, this.requestRender();
3028
3134
  }
3029
- /**
3030
- * Refresh the pivot by clearing cached results.
3031
- */
3032
3135
  refresh() {
3033
3136
  this.pivotResult = null, this.requestRender();
3034
3137
  }
3138
+ // ===== Tool Panel API =====
3139
+ showPanel() {
3140
+ this.grid.openToolPanel(F.PANEL_ID);
3141
+ }
3142
+ hidePanel() {
3143
+ this.grid.closeToolPanel();
3144
+ }
3145
+ togglePanel() {
3146
+ this.grid.toggleToolPanel(F.PANEL_ID);
3147
+ }
3148
+ isPanelVisible() {
3149
+ return this.grid.activeToolPanel === F.PANEL_ID;
3150
+ }
3151
+ // ===== Private Helpers =====
3152
+ get gridColumns() {
3153
+ return this.grid.columns ?? [];
3154
+ }
3155
+ buildFieldHeaderMap() {
3156
+ const e = this.getAvailableFields();
3157
+ this.fieldHeaderMap.clear();
3158
+ for (const t of e)
3159
+ this.fieldHeaderMap.set(t.field, t.header);
3160
+ }
3161
+ getAvailableFields() {
3162
+ return this.originalColumns.length > 0 ? this.originalColumns : this.captureOriginalColumns();
3163
+ }
3164
+ captureOriginalColumns() {
3165
+ const e = this.grid;
3166
+ try {
3167
+ const t = e.getAllColumns?.() ?? e.columns ?? [];
3168
+ return this.originalColumns = t.filter((o) => !o.field.startsWith("__pivot")).map((o) => ({
3169
+ field: o.field,
3170
+ header: o.header ?? o.field
3171
+ })), this.originalColumns;
3172
+ } catch {
3173
+ return [];
3174
+ }
3175
+ }
3176
+ renderPanel(e) {
3177
+ this.panelContainer = e, this.originalColumns.length === 0 && this.captureOriginalColumns();
3178
+ const t = {
3179
+ onTogglePivot: (o) => {
3180
+ o ? this.enablePivot() : this.disablePivot(), this.refreshPanel();
3181
+ },
3182
+ onAddFieldToZone: (o, n) => this.addFieldToZone(o, n),
3183
+ onRemoveFieldFromZone: (o, n) => this.removeFieldFromZone(o, n),
3184
+ onAddValueField: (o, n) => this.addValueField(o, n),
3185
+ onRemoveValueField: (o) => this.removeValueField(o),
3186
+ onUpdateValueAggFunc: (o, n) => this.updateValueAggFunc(o, n),
3187
+ onOptionChange: (o, n) => {
3188
+ this.config[o] = n, this.isActive && this.refresh();
3189
+ },
3190
+ getAvailableFields: () => this.getAvailableFields()
3191
+ };
3192
+ return kt(e, this.config, this.isActive, t);
3193
+ }
3194
+ refreshPanel() {
3195
+ this.panelContainer && (this.panelContainer.innerHTML = "", this.renderPanel(this.panelContainer));
3196
+ }
3197
+ addFieldToZone(e, t) {
3198
+ if (t === "rowGroups") {
3199
+ const o = this.config.rowGroupFields ?? [];
3200
+ o.includes(e) || (this.config.rowGroupFields = [...o, e]);
3201
+ } else {
3202
+ const o = this.config.columnGroupFields ?? [];
3203
+ o.includes(e) || (this.config.columnGroupFields = [...o, e]);
3204
+ }
3205
+ this.removeFromOtherZones(e, t), this.isActive && this.refresh(), this.refreshPanel();
3206
+ }
3207
+ removeFieldFromZone(e, t) {
3208
+ 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();
3209
+ }
3210
+ removeFromOtherZones(e, t) {
3211
+ 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));
3212
+ }
3213
+ addValueField(e, t) {
3214
+ const o = this.config.valueFields ?? [];
3215
+ o.some((n) => n.field === e) || (this.config.valueFields = [...o, { field: e, aggFunc: t }]), this.removeFromOtherZones(e, "values"), this.isActive && this.refresh(), this.refreshPanel();
3216
+ }
3217
+ removeValueField(e) {
3218
+ this.config.valueFields = (this.config.valueFields ?? []).filter((t) => t.field !== e), this.isActive && this.refresh(), this.refreshPanel();
3219
+ }
3220
+ updateValueAggFunc(e, t) {
3221
+ const o = this.config.valueFields ?? [], n = o.findIndex((i) => i.field === e);
3222
+ n >= 0 && (o[n] = { ...o[n], aggFunc: t }, this.config.valueFields = [...o]), this.isActive && this.refresh();
3223
+ }
3035
3224
  // ===== Styles =====
3036
- styles = `
3037
- [data-pivot-depth="1"] { padding-left: 20px; }
3038
- [data-pivot-depth="2"] { padding-left: 40px; }
3039
- [data-pivot-depth="3"] { padding-left: 60px; }
3040
- .pivot-group-row { font-weight: bold; background: var(--tbw-pivot-group-bg, var(--tbw-color-panel-bg)); }
3041
- .pivot-total-row { font-weight: bold; border-top: 2px solid var(--tbw-pivot-border, var(--tbw-color-border-strong)); }
3042
- `;
3043
- }
3044
- function ct(i) {
3045
- const e = i.sticky;
3225
+ styles = Pt;
3226
+ }
3227
+ function Dt(s) {
3228
+ const e = s.sticky;
3046
3229
  if (e === "left" || e === "right")
3047
3230
  return !1;
3048
- const t = i.meta ?? {}, n = t.sticky;
3049
- return n === "left" || n === "right" ? !1 : t.lockPosition !== !0 && t.suppressMovable !== !0;
3231
+ const t = s.meta ?? {}, o = t.sticky;
3232
+ return o === "left" || o === "right" ? !1 : t.lockPosition !== !0 && t.suppressMovable !== !0;
3050
3233
  }
3051
- function ge(i, e, t) {
3052
- if (e === t || e < 0 || e >= i.length || t < 0 || t > i.length) return i;
3053
- const n = [...i], [o] = n.splice(e, 1);
3054
- return n.splice(t, 0, o), n;
3234
+ function ye(s, e, t) {
3235
+ if (e === t || e < 0 || e >= s.length || t < 0 || t > s.length) return s;
3236
+ const o = [...s], [n] = o.splice(e, 1);
3237
+ return o.splice(t, 0, n), o;
3055
3238
  }
3056
- class Mt extends y {
3239
+ const qt = '.header-row>.cell[draggable=true]{cursor:grab;position:relative}.header-row>.cell.dragging{opacity:.5;cursor:grabbing}.header-row>.cell.drop-before:before{content:"";position:absolute;left:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}.header-row>.cell.drop-after:after{content:"";position:absolute;right:0;top:0;bottom:0;width:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent));z-index:1}';
3240
+ class ro extends C {
3057
3241
  name = "reorder";
3058
3242
  version = "1.0.0";
3059
3243
  get defaultConfig() {
3060
3244
  return {
3061
- enabled: !0,
3062
3245
  animation: !0,
3063
3246
  animationDuration: 200
3064
3247
  };
@@ -3073,8 +3256,8 @@ class Mt extends y {
3073
3256
  super.attach(e), e.addEventListener(
3074
3257
  "column-reorder-request",
3075
3258
  (t) => {
3076
- const n = t.detail;
3077
- n?.field && typeof n.toIndex == "number" && this.moveColumn(n.field, n.toIndex);
3259
+ const o = t.detail;
3260
+ o?.field && typeof o.toIndex == "number" && this.moveColumn(o.field, o.toIndex);
3078
3261
  },
3079
3262
  { signal: this.disconnectSignal }
3080
3263
  );
@@ -3085,42 +3268,41 @@ class Mt extends y {
3085
3268
  // ===== Hooks =====
3086
3269
  // Note: No processColumns hook needed - we directly update the grid's column order
3087
3270
  afterRender() {
3088
- if (!this.config.enabled) return;
3089
3271
  const e = this.shadowRoot;
3090
3272
  if (!e) return;
3091
- e.querySelectorAll(".header-row > .cell").forEach((n) => {
3092
- const o = n, r = o.getAttribute("data-field");
3093
- if (!r) return;
3094
- const s = this.columns.find((l) => l.field === r);
3095
- if (!s || !ct(s)) {
3096
- o.draggable = !1;
3273
+ e.querySelectorAll(".header-row > .cell").forEach((o) => {
3274
+ const n = o, i = n.getAttribute("data-field");
3275
+ if (!i) return;
3276
+ const r = this.columns.find((l) => l.field === i);
3277
+ if (!r || !Dt(r)) {
3278
+ n.draggable = !1;
3097
3279
  return;
3098
3280
  }
3099
- o.draggable = !0, !o.getAttribute("data-dragstart-bound") && (o.setAttribute("data-dragstart-bound", "true"), o.addEventListener("dragstart", (l) => {
3100
- const d = this.getColumnOrder().indexOf(r);
3101
- this.isDragging = !0, this.draggedField = r, this.draggedIndex = d, l.dataTransfer && (l.dataTransfer.effectAllowed = "move", l.dataTransfer.setData("text/plain", r)), o.classList.add("dragging");
3102
- }), o.addEventListener("dragend", () => {
3281
+ n.draggable = !0, !n.getAttribute("data-dragstart-bound") && (n.setAttribute("data-dragstart-bound", "true"), n.addEventListener("dragstart", (l) => {
3282
+ const d = this.getColumnOrder().indexOf(i);
3283
+ this.isDragging = !0, this.draggedField = i, this.draggedIndex = d, l.dataTransfer && (l.dataTransfer.effectAllowed = "move", l.dataTransfer.setData("text/plain", i)), n.classList.add("dragging");
3284
+ }), n.addEventListener("dragend", () => {
3103
3285
  this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, e.querySelectorAll(".header-row > .cell").forEach((l) => {
3104
3286
  l.classList.remove("dragging", "drop-target", "drop-before", "drop-after");
3105
3287
  });
3106
- }), o.addEventListener("dragover", (l) => {
3107
- if (l.preventDefault(), !this.isDragging || this.draggedField === r) return;
3108
- const a = o.getBoundingClientRect(), d = a.left + a.width / 2, u = this.getColumnOrder().indexOf(r);
3109
- this.dropIndex = l.clientX < d ? u : u + 1, o.classList.add("drop-target"), o.classList.toggle("drop-before", l.clientX < d), o.classList.toggle("drop-after", l.clientX >= d);
3110
- }), o.addEventListener("dragleave", () => {
3111
- o.classList.remove("drop-target", "drop-before", "drop-after");
3112
- }), o.addEventListener("drop", (l) => {
3288
+ }), n.addEventListener("dragover", (l) => {
3289
+ if (l.preventDefault(), !this.isDragging || this.draggedField === i) return;
3290
+ const a = n.getBoundingClientRect(), d = a.left + a.width / 2, u = this.getColumnOrder().indexOf(i);
3291
+ this.dropIndex = l.clientX < d ? u : u + 1, n.classList.add("drop-target"), n.classList.toggle("drop-before", l.clientX < d), n.classList.toggle("drop-after", l.clientX >= d);
3292
+ }), n.addEventListener("dragleave", () => {
3293
+ n.classList.remove("drop-target", "drop-before", "drop-after");
3294
+ }), n.addEventListener("drop", (l) => {
3113
3295
  l.preventDefault();
3114
3296
  const a = this.draggedField, d = this.draggedIndex, c = this.dropIndex;
3115
3297
  if (!this.isDragging || a === null || d === null || c === null)
3116
3298
  return;
3117
- const u = c > d ? c - 1 : c, h = this.getColumnOrder(), f = ge(h, d, u), g = {
3299
+ const u = c > d ? c - 1 : c, h = this.getColumnOrder(), p = ye(h, d, u), g = {
3118
3300
  field: a,
3119
3301
  fromIndex: d,
3120
3302
  toIndex: u,
3121
- columnOrder: f
3303
+ columnOrder: p
3122
3304
  };
3123
- this.grid.setColumnOrder(f), this.emit("column-move", g), this.grid.requestStateChange?.();
3305
+ this.grid.setColumnOrder(p), this.emit("column-move", g), this.grid.requestStateChange?.();
3124
3306
  }));
3125
3307
  });
3126
3308
  }
@@ -3138,14 +3320,14 @@ class Mt extends y {
3138
3320
  * @param toIndex - The target index
3139
3321
  */
3140
3322
  moveColumn(e, t) {
3141
- const n = this.getColumnOrder(), o = n.indexOf(e);
3142
- if (o === -1) return;
3143
- const r = ge(n, o, t);
3144
- this.grid.setColumnOrder(r), this.emit("column-move", {
3323
+ const o = this.getColumnOrder(), n = o.indexOf(e);
3324
+ if (n === -1) return;
3325
+ const i = ye(o, n, t);
3326
+ this.grid.setColumnOrder(i), this.emit("column-move", {
3145
3327
  field: e,
3146
- fromIndex: o,
3328
+ fromIndex: n,
3147
3329
  toIndex: t,
3148
- columnOrder: r
3330
+ columnOrder: i
3149
3331
  }), this.grid.requestStateChange?.();
3150
3332
  }
3151
3333
  /**
@@ -3163,74 +3345,44 @@ class Mt extends y {
3163
3345
  this.grid.setColumnOrder(e), this.grid.requestStateChange?.();
3164
3346
  }
3165
3347
  // ===== Styles =====
3166
- styles = `
3167
- .header-row > .cell[draggable="true"] {
3168
- cursor: grab;
3169
- position: relative;
3170
- }
3171
- .header-row > .cell.dragging {
3172
- opacity: 0.5;
3173
- cursor: grabbing;
3174
- }
3175
- .header-row > .cell.drop-before::before {
3176
- content: '';
3177
- position: absolute;
3178
- left: 0;
3179
- top: 0;
3180
- bottom: 0;
3181
- width: 2px;
3182
- background: var(--tbw-reorder-indicator, var(--tbw-color-accent));
3183
- z-index: 1;
3184
- }
3185
- .header-row > .cell.drop-after::after {
3186
- content: '';
3187
- position: absolute;
3188
- right: 0;
3189
- top: 0;
3190
- bottom: 0;
3191
- width: 2px;
3192
- background: var(--tbw-reorder-indicator, var(--tbw-color-accent));
3193
- z-index: 1;
3194
- }
3195
- `;
3348
+ styles = qt;
3196
3349
  }
3197
- function M(i, e) {
3198
- return Math.floor(i / e);
3350
+ function D(s, e) {
3351
+ return Math.floor(s / e);
3199
3352
  }
3200
- function ut(i, e) {
3353
+ function Ht(s, e) {
3201
3354
  return {
3202
- start: i * e,
3203
- end: (i + 1) * e
3355
+ start: s * e,
3356
+ end: (s + 1) * e
3204
3357
  };
3205
3358
  }
3206
- function ht(i, e, t) {
3207
- const n = M(i, t), o = M(e - 1, t), r = [];
3208
- for (let s = n; s <= o; s++)
3209
- r.push(s);
3210
- return r;
3211
- }
3212
- async function pe(i, e, t, n) {
3213
- const o = ut(e, t);
3214
- return i.getRows({
3215
- startRow: o.start,
3216
- endRow: o.end,
3217
- sortModel: n.sortModel,
3218
- filterModel: n.filterModel
3359
+ function Gt(s, e, t) {
3360
+ const o = D(s, t), n = D(e - 1, t), i = [];
3361
+ for (let r = o; r <= n; r++)
3362
+ i.push(r);
3363
+ return i;
3364
+ }
3365
+ async function Re(s, e, t, o) {
3366
+ const n = Ht(e, t);
3367
+ return s.getRows({
3368
+ startRow: n.start,
3369
+ endRow: n.end,
3370
+ sortModel: o.sortModel,
3371
+ filterModel: o.filterModel
3219
3372
  });
3220
3373
  }
3221
- function ft(i, e, t) {
3222
- const n = M(i, e), o = t.get(n);
3223
- if (!o) return;
3224
- const r = i % e;
3225
- return o[r];
3374
+ function Ot(s, e, t) {
3375
+ const o = D(s, e), n = t.get(o);
3376
+ if (!n) return;
3377
+ const i = s % e;
3378
+ return n[i];
3226
3379
  }
3227
- const gt = 100;
3228
- class qt extends y {
3380
+ const Bt = 100;
3381
+ class so extends C {
3229
3382
  name = "serverSide";
3230
3383
  version = "1.0.0";
3231
3384
  get defaultConfig() {
3232
3385
  return {
3233
- enabled: !0,
3234
3386
  pageSize: 100,
3235
3387
  cacheBlockSize: 100,
3236
3388
  maxConcurrentRequests: 2
@@ -3253,15 +3405,15 @@ class qt extends y {
3253
3405
  */
3254
3406
  loadRequiredBlocks() {
3255
3407
  if (!this.dataSource) return;
3256
- const e = this.grid, t = this.config.cacheBlockSize ?? 100, n = { startRow: e.virtualization.start, endRow: e.virtualization.end }, o = ht(n.startRow, n.endRow, t);
3257
- for (const r of o)
3258
- if (!(this.loadedBlocks.has(r) || this.loadingBlocks.has(r))) {
3408
+ const e = this.grid, t = this.config.cacheBlockSize ?? 100, o = { startRow: e.virtualization.start, endRow: e.virtualization.end }, n = Gt(o.startRow, o.endRow, t);
3409
+ for (const i of n)
3410
+ if (!(this.loadedBlocks.has(i) || this.loadingBlocks.has(i))) {
3259
3411
  if (this.loadingBlocks.size >= (this.config.maxConcurrentRequests ?? 2))
3260
3412
  break;
3261
- this.loadingBlocks.add(r), pe(this.dataSource, r, t, {}).then((s) => {
3262
- this.loadedBlocks.set(r, s.rows), this.totalRowCount = s.totalRowCount, this.loadingBlocks.delete(r), this.requestRender(), this.loadRequiredBlocks();
3413
+ this.loadingBlocks.add(i), Re(this.dataSource, i, t, {}).then((r) => {
3414
+ this.loadedBlocks.set(i, r.rows), this.totalRowCount = r.totalRowCount, this.loadingBlocks.delete(i), this.requestRender(), this.loadRequiredBlocks();
3263
3415
  }).catch(() => {
3264
- this.loadingBlocks.delete(r);
3416
+ this.loadingBlocks.delete(i);
3265
3417
  });
3266
3418
  }
3267
3419
  }
@@ -3269,16 +3421,16 @@ class qt extends y {
3269
3421
  processRows(e) {
3270
3422
  if (!this.dataSource) return [...e];
3271
3423
  const t = [];
3272
- for (let n = 0; n < this.totalRowCount; n++) {
3273
- const o = ft(n, this.config.cacheBlockSize ?? 100, this.loadedBlocks);
3274
- t.push(o ?? { __loading: !0, __index: n });
3424
+ for (let o = 0; o < this.totalRowCount; o++) {
3425
+ const n = Ot(o, this.config.cacheBlockSize ?? 100, this.loadedBlocks);
3426
+ t.push(n ?? { __loading: !0, __index: o });
3275
3427
  }
3276
3428
  return t;
3277
3429
  }
3278
3430
  onScroll(e) {
3279
3431
  this.dataSource && (this.loadRequiredBlocks(), this.scrollDebounceTimer && clearTimeout(this.scrollDebounceTimer), this.scrollDebounceTimer = setTimeout(() => {
3280
3432
  this.loadRequiredBlocks();
3281
- }, gt));
3433
+ }, Bt));
3282
3434
  }
3283
3435
  // ===== Public API =====
3284
3436
  /**
@@ -3288,8 +3440,8 @@ class qt extends y {
3288
3440
  setDataSource(e) {
3289
3441
  this.dataSource = e, this.loadedBlocks.clear(), this.loadingBlocks.clear();
3290
3442
  const t = this.config.cacheBlockSize ?? 100;
3291
- pe(e, 0, t, {}).then((n) => {
3292
- this.loadedBlocks.set(0, n.rows), this.totalRowCount = n.totalRowCount, this.requestRender();
3443
+ Re(e, 0, t, {}).then((o) => {
3444
+ this.loadedBlocks.set(0, o.rows), this.totalRowCount = o.totalRowCount, this.requestRender();
3293
3445
  });
3294
3446
  }
3295
3447
  /**
@@ -3315,8 +3467,8 @@ class qt extends y {
3315
3467
  * @param rowIndex - Row index to check
3316
3468
  */
3317
3469
  isRowLoaded(e) {
3318
- const t = this.config.cacheBlockSize ?? 100, n = M(e, t);
3319
- return this.loadedBlocks.has(n);
3470
+ const t = this.config.cacheBlockSize ?? 100, o = D(e, t);
3471
+ return this.loadedBlocks.has(o);
3320
3472
  }
3321
3473
  /**
3322
3474
  * Get the number of loaded cache blocks.
@@ -3325,65 +3477,64 @@ class qt extends y {
3325
3477
  return this.loadedBlocks.size;
3326
3478
  }
3327
3479
  }
3328
- function pt(i, e, t) {
3329
- const n = [...i.undoStack, e];
3330
- for (; n.length > t; )
3331
- n.shift();
3480
+ function Vt(s, e, t) {
3481
+ const o = [...s.undoStack, e];
3482
+ for (; o.length > t; )
3483
+ o.shift();
3332
3484
  return {
3333
- undoStack: n,
3485
+ undoStack: o,
3334
3486
  redoStack: []
3335
3487
  // Clear redo on new action
3336
3488
  };
3337
3489
  }
3338
- function me(i) {
3339
- if (i.undoStack.length === 0)
3340
- return { newState: i, action: null };
3341
- const e = [...i.undoStack], t = e.pop();
3490
+ function Se(s) {
3491
+ if (s.undoStack.length === 0)
3492
+ return { newState: s, action: null };
3493
+ const e = [...s.undoStack], t = e.pop();
3342
3494
  return t ? {
3343
3495
  newState: {
3344
3496
  undoStack: e,
3345
- redoStack: [...i.redoStack, t]
3497
+ redoStack: [...s.redoStack, t]
3346
3498
  },
3347
3499
  action: t
3348
- } : { newState: i, action: null };
3500
+ } : { newState: s, action: null };
3349
3501
  }
3350
- function be(i) {
3351
- if (i.redoStack.length === 0)
3352
- return { newState: i, action: null };
3353
- const e = [...i.redoStack], t = e.pop();
3502
+ function Ee(s) {
3503
+ if (s.redoStack.length === 0)
3504
+ return { newState: s, action: null };
3505
+ const e = [...s.redoStack], t = e.pop();
3354
3506
  return t ? {
3355
3507
  newState: {
3356
- undoStack: [...i.undoStack, t],
3508
+ undoStack: [...s.undoStack, t],
3357
3509
  redoStack: e
3358
3510
  },
3359
3511
  action: t
3360
- } : { newState: i, action: null };
3512
+ } : { newState: s, action: null };
3361
3513
  }
3362
- function mt(i) {
3363
- return i.undoStack.length > 0;
3514
+ function Kt(s) {
3515
+ return s.undoStack.length > 0;
3364
3516
  }
3365
- function bt(i) {
3366
- return i.redoStack.length > 0;
3517
+ function zt(s) {
3518
+ return s.redoStack.length > 0;
3367
3519
  }
3368
- function wt() {
3520
+ function Wt() {
3369
3521
  return { undoStack: [], redoStack: [] };
3370
3522
  }
3371
- function xt(i, e, t, n) {
3523
+ function $t(s, e, t, o) {
3372
3524
  return {
3373
3525
  type: "cell-edit",
3374
- rowIndex: i,
3526
+ rowIndex: s,
3375
3527
  field: e,
3376
3528
  oldValue: t,
3377
- newValue: n,
3529
+ newValue: o,
3378
3530
  timestamp: Date.now()
3379
3531
  };
3380
3532
  }
3381
- class Ft extends y {
3533
+ class lo extends C {
3382
3534
  name = "undoRedo";
3383
3535
  version = "1.0.0";
3384
3536
  get defaultConfig() {
3385
3537
  return {
3386
- enabled: !0,
3387
3538
  maxHistorySize: 100
3388
3539
  };
3389
3540
  }
@@ -3402,25 +3553,24 @@ class Ft extends y {
3402
3553
  * - Ctrl+Y / Cmd+Y / Ctrl+Shift+Z / Cmd+Shift+Z: Redo
3403
3554
  */
3404
3555
  onKeyDown(e) {
3405
- if (!this.config.enabled) return !1;
3406
- const t = (e.ctrlKey || e.metaKey) && e.key === "z" && !e.shiftKey, n = (e.ctrlKey || e.metaKey) && (e.key === "y" || e.key === "z" && e.shiftKey);
3556
+ const t = (e.ctrlKey || e.metaKey) && e.key === "z" && !e.shiftKey, o = (e.ctrlKey || e.metaKey) && (e.key === "y" || e.key === "z" && e.shiftKey);
3407
3557
  if (t) {
3408
- const o = me({ undoStack: this.undoStack, redoStack: this.redoStack });
3409
- if (o.action) {
3410
- const r = this.rows;
3411
- r[o.action.rowIndex] && (r[o.action.rowIndex][o.action.field] = o.action.oldValue), this.undoStack = o.newState.undoStack, this.redoStack = o.newState.redoStack, this.emit("undo", {
3412
- action: o.action,
3558
+ const n = Se({ undoStack: this.undoStack, redoStack: this.redoStack });
3559
+ if (n.action) {
3560
+ const i = this.rows;
3561
+ i[n.action.rowIndex] && (i[n.action.rowIndex][n.action.field] = n.action.oldValue), this.undoStack = n.newState.undoStack, this.redoStack = n.newState.redoStack, this.emit("undo", {
3562
+ action: n.action,
3413
3563
  type: "undo"
3414
3564
  }), this.requestRender();
3415
3565
  }
3416
3566
  return !0;
3417
3567
  }
3418
- if (n) {
3419
- const o = be({ undoStack: this.undoStack, redoStack: this.redoStack });
3420
- if (o.action) {
3421
- const r = this.rows;
3422
- r[o.action.rowIndex] && (r[o.action.rowIndex][o.action.field] = o.action.newValue), this.undoStack = o.newState.undoStack, this.redoStack = o.newState.redoStack, this.emit("redo", {
3423
- action: o.action,
3568
+ if (o) {
3569
+ const n = Ee({ undoStack: this.undoStack, redoStack: this.redoStack });
3570
+ if (n.action) {
3571
+ const i = this.rows;
3572
+ i[n.action.rowIndex] && (i[n.action.rowIndex][n.action.field] = n.action.newValue), this.undoStack = n.newState.undoStack, this.redoStack = n.newState.redoStack, this.emit("redo", {
3573
+ action: n.action,
3424
3574
  type: "redo"
3425
3575
  }), this.requestRender();
3426
3576
  }
@@ -3438,13 +3588,13 @@ class Ft extends y {
3438
3588
  * @param oldValue - The value before the edit
3439
3589
  * @param newValue - The value after the edit
3440
3590
  */
3441
- recordEdit(e, t, n, o) {
3442
- const r = xt(e, t, n, o), s = pt(
3591
+ recordEdit(e, t, o, n) {
3592
+ const i = $t(e, t, o, n), r = Vt(
3443
3593
  { undoStack: this.undoStack, redoStack: this.redoStack },
3444
- r,
3594
+ i,
3445
3595
  this.config.maxHistorySize ?? 100
3446
3596
  );
3447
- this.undoStack = s.undoStack, this.redoStack = s.redoStack;
3597
+ this.undoStack = r.undoStack, this.redoStack = r.redoStack;
3448
3598
  }
3449
3599
  /**
3450
3600
  * Programmatically undo the last action.
@@ -3452,7 +3602,7 @@ class Ft extends y {
3452
3602
  * @returns The undone action, or null if nothing to undo
3453
3603
  */
3454
3604
  undo() {
3455
- const e = me({ undoStack: this.undoStack, redoStack: this.redoStack });
3605
+ const e = Se({ undoStack: this.undoStack, redoStack: this.redoStack });
3456
3606
  if (e.action) {
3457
3607
  const t = this.rows;
3458
3608
  t[e.action.rowIndex] && (t[e.action.rowIndex][e.action.field] = e.action.oldValue), this.undoStack = e.newState.undoStack, this.redoStack = e.newState.redoStack, this.requestRender();
@@ -3465,7 +3615,7 @@ class Ft extends y {
3465
3615
  * @returns The redone action, or null if nothing to redo
3466
3616
  */
3467
3617
  redo() {
3468
- const e = be({ undoStack: this.undoStack, redoStack: this.redoStack });
3618
+ const e = Ee({ undoStack: this.undoStack, redoStack: this.redoStack });
3469
3619
  if (e.action) {
3470
3620
  const t = this.rows;
3471
3621
  t[e.action.rowIndex] && (t[e.action.rowIndex][e.action.field] = e.action.newValue), this.undoStack = e.newState.undoStack, this.redoStack = e.newState.redoStack, this.requestRender();
@@ -3476,19 +3626,19 @@ class Ft extends y {
3476
3626
  * Check if there are any actions that can be undone.
3477
3627
  */
3478
3628
  canUndo() {
3479
- return mt({ undoStack: this.undoStack, redoStack: this.redoStack });
3629
+ return Kt({ undoStack: this.undoStack, redoStack: this.redoStack });
3480
3630
  }
3481
3631
  /**
3482
3632
  * Check if there are any actions that can be redone.
3483
3633
  */
3484
3634
  canRedo() {
3485
- return bt({ undoStack: this.undoStack, redoStack: this.redoStack });
3635
+ return zt({ undoStack: this.undoStack, redoStack: this.redoStack });
3486
3636
  }
3487
3637
  /**
3488
3638
  * Clear all undo/redo history.
3489
3639
  */
3490
3640
  clearHistory() {
3491
- const e = wt();
3641
+ const e = Wt();
3492
3642
  this.undoStack = e.undoStack, this.redoStack = e.redoStack;
3493
3643
  }
3494
3644
  /**
@@ -3504,18 +3654,18 @@ class Ft extends y {
3504
3654
  return [...this.redoStack];
3505
3655
  }
3506
3656
  }
3507
- function we(i) {
3508
- const e = i.meta ?? {};
3657
+ const jt = '.tbw-visibility-content{display:flex;flex-direction:column;height:100%}.tbw-visibility-list{flex:1;overflow-y:auto;padding:8px}.tbw-visibility-row{display:flex;align-items:center;gap:8px;padding:6px 4px;cursor:pointer;font-size:13px;border-radius:var(--tbw-border-radius, 4px);position:relative}.tbw-visibility-row:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}.tbw-visibility-row input[type=checkbox]{cursor:pointer}.tbw-visibility-row.locked span{color:var(--tbw-color-fg-muted, #888)}.tbw-visibility-handle{cursor:grab;color:var(--tbw-color-fg-muted, #888);font-size:10px;letter-spacing:-2px;user-select:none;flex-shrink:0}.tbw-visibility-row.reorderable:hover .tbw-visibility-handle{color:var(--tbw-color-fg, #1f2937)}.tbw-visibility-label{display:flex;align-items:center;gap:8px;flex:1;cursor:pointer}.tbw-visibility-row.dragging{opacity:.5;cursor:grabbing}.tbw-visibility-row.drop-before:before{content:"";position:absolute;left:0;right:0;top:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-row.drop-after:after{content:"";position:absolute;left:0;right:0;bottom:0;height:2px;background:var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6))}.tbw-visibility-show-all{margin:8px;padding:8px 12px;border:1px solid var(--tbw-visibility-border, var(--tbw-color-border, #e5e7eb));border-radius:var(--tbw-border-radius, 4px);background:var(--tbw-visibility-btn-bg, var(--tbw-color-header-bg, #f9fafb));color:var(--tbw-color-fg, #1f2937);cursor:pointer;font-size:13px}.tbw-visibility-show-all:hover{background:var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6))}';
3658
+ function ke(s) {
3659
+ const e = s.meta ?? {};
3509
3660
  return e.lockPosition !== !0 && e.suppressMovable !== !0;
3510
3661
  }
3511
- class I extends y {
3662
+ class L extends C {
3512
3663
  name = "visibility";
3513
3664
  version = "1.0.0";
3514
3665
  /** Tool panel ID for shell integration */
3515
3666
  static PANEL_ID = "columns";
3516
3667
  get defaultConfig() {
3517
3668
  return {
3518
- enabled: !0,
3519
3669
  allowHideAll: !1
3520
3670
  };
3521
3671
  }
@@ -3535,23 +3685,22 @@ class I extends y {
3535
3685
  * Register the column visibility tool panel with the shell.
3536
3686
  */
3537
3687
  getToolPanel() {
3538
- if (this.config.enabled)
3539
- return {
3540
- id: I.PANEL_ID,
3541
- title: "Columns",
3542
- icon: "",
3543
- tooltip: "Column visibility",
3544
- order: 100,
3545
- // High order so it appears last
3546
- render: (e) => this.renderPanelContent(e)
3547
- };
3688
+ return {
3689
+ id: L.PANEL_ID,
3690
+ title: "Columns",
3691
+ icon: "",
3692
+ tooltip: "Column visibility",
3693
+ order: 100,
3694
+ // High order so it appears last
3695
+ render: (e) => this.renderPanelContent(e)
3696
+ };
3548
3697
  }
3549
3698
  // ===== Public API =====
3550
3699
  /**
3551
3700
  * Show the visibility sidebar panel.
3552
3701
  */
3553
3702
  show() {
3554
- this.grid.openToolPanel(I.PANEL_ID);
3703
+ this.grid.openToolPanel(L.PANEL_ID);
3555
3704
  }
3556
3705
  /**
3557
3706
  * Hide the visibility sidebar panel.
@@ -3563,7 +3712,7 @@ class I extends y {
3563
3712
  * Toggle the visibility sidebar panel.
3564
3713
  */
3565
3714
  toggle() {
3566
- this.grid.toggleToolPanel(I.PANEL_ID);
3715
+ this.grid.toggleToolPanel(L.PANEL_ID);
3567
3716
  }
3568
3717
  /**
3569
3718
  * Check if a specific column is visible.
@@ -3641,7 +3790,7 @@ class I extends y {
3641
3790
  * @returns True if the panel is open
3642
3791
  */
3643
3792
  isPanelVisible() {
3644
- return this.grid.activeToolPanel === I.PANEL_ID;
3793
+ return this.grid.activeToolPanel === L.PANEL_ID;
3645
3794
  }
3646
3795
  // ===== Private Methods =====
3647
3796
  /**
@@ -3649,15 +3798,15 @@ class I extends y {
3649
3798
  * Returns a cleanup function.
3650
3799
  */
3651
3800
  renderPanelContent(e) {
3652
- const t = this.grid, n = document.createElement("div");
3653
- n.className = "tbw-visibility-content";
3654
- const o = document.createElement("div");
3655
- o.className = "tbw-visibility-list", n.appendChild(o);
3656
- const r = document.createElement("button");
3657
- return r.className = "tbw-visibility-show-all", r.textContent = "Show All", r.addEventListener("click", () => {
3658
- t.showAllColumns(), this.rebuildToggles(o);
3659
- }), n.appendChild(r), this.columnListElement = o, this.rebuildToggles(o), e.appendChild(n), () => {
3660
- this.columnListElement = null, n.remove();
3801
+ const t = this.grid, o = document.createElement("div");
3802
+ o.className = "tbw-visibility-content";
3803
+ const n = document.createElement("div");
3804
+ n.className = "tbw-visibility-list", o.appendChild(n);
3805
+ const i = document.createElement("button");
3806
+ return i.className = "tbw-visibility-show-all", i.textContent = "Show All", i.addEventListener("click", () => {
3807
+ t.showAllColumns(), this.rebuildToggles(n);
3808
+ }), o.appendChild(i), this.columnListElement = n, this.rebuildToggles(n), e.appendChild(o), () => {
3809
+ this.columnListElement = null, o.remove();
3661
3810
  };
3662
3811
  }
3663
3812
  /**
@@ -3672,20 +3821,20 @@ class I extends y {
3672
3821
  * When a reorder plugin is present, adds drag handles for reordering.
3673
3822
  */
3674
3823
  rebuildToggles(e) {
3675
- const t = this.grid, n = this.hasReorderPlugin();
3824
+ const t = this.grid, o = this.hasReorderPlugin();
3676
3825
  e.innerHTML = "";
3677
- const o = t.getAllColumns();
3678
- for (let r = 0; r < o.length; r++) {
3679
- const s = o[r], l = s.header || s.field, a = document.createElement("div");
3680
- a.className = s.lockVisible ? "tbw-visibility-row locked" : "tbw-visibility-row", a.setAttribute("data-field", s.field), a.setAttribute("data-index", String(r)), n && we(s) && (a.draggable = !0, a.classList.add("reorderable"), this.setupDragListeners(a, s.field, r, e));
3826
+ const n = t.getAllColumns();
3827
+ for (let i = 0; i < n.length; i++) {
3828
+ const r = n[i], l = r.header || r.field, a = document.createElement("div");
3829
+ a.className = r.lockVisible ? "tbw-visibility-row locked" : "tbw-visibility-row", a.setAttribute("data-field", r.field), a.setAttribute("data-index", String(i)), o && ke(r) && (a.draggable = !0, a.classList.add("reorderable"), this.setupDragListeners(a, r.field, i, e));
3681
3830
  const d = document.createElement("label");
3682
3831
  d.className = "tbw-visibility-label";
3683
3832
  const c = document.createElement("input");
3684
- c.type = "checkbox", c.checked = s.visible, c.disabled = s.lockVisible ?? !1, c.addEventListener("change", () => {
3685
- t.toggleColumnVisibility(s.field), setTimeout(() => this.rebuildToggles(e), 0);
3833
+ c.type = "checkbox", c.checked = r.visible, c.disabled = r.lockVisible ?? !1, c.addEventListener("change", () => {
3834
+ t.toggleColumnVisibility(r.field), setTimeout(() => this.rebuildToggles(e), 0);
3686
3835
  });
3687
3836
  const u = document.createElement("span");
3688
- if (u.textContent = l, d.appendChild(c), d.appendChild(u), n && we(s)) {
3837
+ if (u.textContent = l, d.appendChild(c), d.appendChild(u), o && ke(r)) {
3689
3838
  const h = document.createElement("span");
3690
3839
  h.className = "tbw-visibility-handle", this.setIcon(h, this.resolveIcon("dragHandle")), h.title = "Drag to reorder", a.appendChild(h);
3691
3840
  }
@@ -3696,170 +3845,80 @@ class I extends y {
3696
3845
  * Set up drag-and-drop event listeners for a row.
3697
3846
  * On drop, emits a 'column-reorder-request' event for other plugins to handle.
3698
3847
  */
3699
- setupDragListeners(e, t, n, o) {
3700
- e.addEventListener("dragstart", (r) => {
3701
- this.isDragging = !0, this.draggedField = t, this.draggedIndex = n, r.dataTransfer && (r.dataTransfer.effectAllowed = "move", r.dataTransfer.setData("text/plain", t)), e.classList.add("dragging");
3848
+ setupDragListeners(e, t, o, n) {
3849
+ e.addEventListener("dragstart", (i) => {
3850
+ this.isDragging = !0, this.draggedField = t, this.draggedIndex = o, i.dataTransfer && (i.dataTransfer.effectAllowed = "move", i.dataTransfer.setData("text/plain", t)), e.classList.add("dragging");
3702
3851
  }), e.addEventListener("dragend", () => {
3703
- this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, o.querySelectorAll(".tbw-visibility-row").forEach((r) => {
3704
- r.classList.remove("dragging", "drop-target", "drop-before", "drop-after");
3852
+ this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, n.querySelectorAll(".tbw-visibility-row").forEach((i) => {
3853
+ i.classList.remove("dragging", "drop-target", "drop-before", "drop-after");
3705
3854
  });
3706
- }), e.addEventListener("dragover", (r) => {
3707
- if (r.preventDefault(), !this.isDragging || this.draggedField === t) return;
3708
- const s = e.getBoundingClientRect(), l = s.top + s.height / 2;
3709
- this.dropIndex = r.clientY < l ? n : n + 1, o.querySelectorAll(".tbw-visibility-row").forEach((a) => {
3855
+ }), e.addEventListener("dragover", (i) => {
3856
+ if (i.preventDefault(), !this.isDragging || this.draggedField === t) return;
3857
+ const r = e.getBoundingClientRect(), l = r.top + r.height / 2;
3858
+ this.dropIndex = i.clientY < l ? o : o + 1, n.querySelectorAll(".tbw-visibility-row").forEach((a) => {
3710
3859
  a !== e && a.classList.remove("drop-target", "drop-before", "drop-after");
3711
- }), e.classList.add("drop-target"), e.classList.toggle("drop-before", r.clientY < l), e.classList.toggle("drop-after", r.clientY >= l);
3860
+ }), e.classList.add("drop-target"), e.classList.toggle("drop-before", i.clientY < l), e.classList.toggle("drop-after", i.clientY >= l);
3712
3861
  }), e.addEventListener("dragleave", () => {
3713
3862
  e.classList.remove("drop-target", "drop-before", "drop-after");
3714
- }), e.addEventListener("drop", (r) => {
3715
- r.preventDefault();
3716
- const s = this.draggedField, l = this.draggedIndex, a = this.dropIndex;
3717
- if (!this.isDragging || s === null || l === null || a === null)
3863
+ }), e.addEventListener("drop", (i) => {
3864
+ i.preventDefault();
3865
+ const r = this.draggedField, l = this.draggedIndex, a = this.dropIndex;
3866
+ if (!this.isDragging || r === null || l === null || a === null)
3718
3867
  return;
3719
3868
  const d = a > l ? a - 1 : a;
3720
3869
  if (d !== l) {
3721
3870
  const c = {
3722
- field: s,
3871
+ field: r,
3723
3872
  fromIndex: l,
3724
3873
  toIndex: d
3725
3874
  };
3726
3875
  this.emit("column-reorder-request", c), setTimeout(() => {
3727
- this.rebuildToggles(o);
3876
+ this.rebuildToggles(n);
3728
3877
  }, 0);
3729
3878
  }
3730
3879
  });
3731
3880
  }
3732
3881
  // ===== Styles =====
3733
- styles = `
3734
- .tbw-visibility-content {
3735
- display: flex;
3736
- flex-direction: column;
3737
- height: 100%;
3738
- }
3739
-
3740
- .tbw-visibility-list {
3741
- flex: 1;
3742
- overflow-y: auto;
3743
- padding: 8px;
3744
- }
3745
-
3746
- .tbw-visibility-row {
3747
- display: flex;
3748
- align-items: center;
3749
- gap: 8px;
3750
- padding: 6px 4px;
3751
- cursor: pointer;
3752
- font-size: 13px;
3753
- border-radius: var(--tbw-border-radius, 4px);
3754
- position: relative;
3755
- }
3756
- .tbw-visibility-row:hover {
3757
- background: var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6));
3758
- }
3759
- .tbw-visibility-row input[type="checkbox"] {
3760
- cursor: pointer;
3761
- }
3762
- .tbw-visibility-row.locked span {
3763
- color: var(--tbw-color-fg-muted, #888);
3764
- }
3765
-
3766
- /* Drag handle */
3767
- .tbw-visibility-handle {
3768
- cursor: grab;
3769
- color: var(--tbw-color-fg-muted, #888);
3770
- font-size: 10px;
3771
- letter-spacing: -2px;
3772
- user-select: none;
3773
- flex-shrink: 0;
3774
- }
3775
- .tbw-visibility-row.reorderable:hover .tbw-visibility-handle {
3776
- color: var(--tbw-color-fg, #1f2937);
3777
- }
3778
-
3779
- /* Label wrapper for checkbox and text */
3780
- .tbw-visibility-label {
3781
- display: flex;
3782
- align-items: center;
3783
- gap: 8px;
3784
- flex: 1;
3785
- cursor: pointer;
3786
- }
3787
-
3788
- /* Drag states */
3789
- .tbw-visibility-row.dragging {
3790
- opacity: 0.5;
3791
- cursor: grabbing;
3792
- }
3793
- .tbw-visibility-row.drop-before::before {
3794
- content: '';
3795
- position: absolute;
3796
- left: 0;
3797
- right: 0;
3798
- top: 0;
3799
- height: 2px;
3800
- background: var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6));
3801
- }
3802
- .tbw-visibility-row.drop-after::after {
3803
- content: '';
3804
- position: absolute;
3805
- left: 0;
3806
- right: 0;
3807
- bottom: 0;
3808
- height: 2px;
3809
- background: var(--tbw-reorder-indicator, var(--tbw-color-accent, #3b82f6));
3810
- }
3811
-
3812
- .tbw-visibility-show-all {
3813
- margin: 8px;
3814
- padding: 8px 12px;
3815
- border: 1px solid var(--tbw-visibility-border, var(--tbw-color-border, #e5e7eb));
3816
- border-radius: var(--tbw-border-radius, 4px);
3817
- background: var(--tbw-visibility-btn-bg, var(--tbw-color-header-bg, #f9fafb));
3818
- color: var(--tbw-color-fg, #1f2937);
3819
- cursor: pointer;
3820
- font-size: 13px;
3821
- }
3822
- .tbw-visibility-show-all:hover {
3823
- background: var(--tbw-visibility-hover, var(--tbw-color-row-hover, #f3f4f6));
3824
- }
3825
- `;
3882
+ styles = jt;
3826
3883
  }
3827
3884
  export {
3828
- y as BaseGridPlugin,
3829
- yt as ClipboardPlugin,
3830
- Ct as ColumnVirtualizationPlugin,
3831
- St as ContextMenuPlugin,
3832
- xe as DEFAULT_GRID_ICONS,
3833
- Pt as DGEvents,
3834
- Bt as DataGridElement,
3835
- Rt as ExportPlugin,
3836
- E as FilteringPlugin,
3837
- Ht as FitModeEnum,
3838
- Ot as GridCSSVars,
3839
- Wt as GridClasses,
3840
- Vt as GridDataAttrs,
3841
- Kt as GridElement,
3842
- Gt as GridSelectors,
3843
- kt as GroupingColumnsPlugin,
3844
- Et as GroupingRowsPlugin,
3845
- At as MasterDetailPlugin,
3846
- It as MultiSortPlugin,
3847
- _t as PinnedColumnsPlugin,
3848
- Tt as PinnedRowsPlugin,
3849
- Lt as PivotPlugin,
3850
- zt as PluginEvents,
3851
- $t as PluginManager,
3852
- Mt as ReorderPlugin,
3853
- jt as SelectionPlugin,
3854
- qt as ServerSidePlugin,
3855
- Ut as TreePlugin,
3856
- Ft as UndoRedoPlugin,
3857
- I as VisibilityPlugin,
3858
- Yt as aggregatorRegistry,
3859
- ve as getAggregator,
3860
- Xt as listAggregators,
3861
- Jt as registerAggregator,
3862
- X as runAggregator,
3863
- Qt as unregisterAggregator
3885
+ C as BaseGridPlugin,
3886
+ Yt as ClipboardPlugin,
3887
+ Zt as ColumnVirtualizationPlugin,
3888
+ Xt as ContextMenuPlugin,
3889
+ _e as DEFAULT_GRID_ICONS,
3890
+ uo as DGEvents,
3891
+ ho as DataGridElement,
3892
+ Jt as ExportPlugin,
3893
+ A as FilteringPlugin,
3894
+ po as FitModeEnum,
3895
+ go as GridCSSVars,
3896
+ fo as GridClasses,
3897
+ mo as GridDataAttrs,
3898
+ bo as GridElement,
3899
+ wo as GridSelectors,
3900
+ Qt as GroupingColumnsPlugin,
3901
+ eo as GroupingRowsPlugin,
3902
+ to as MasterDetailPlugin,
3903
+ oo as MultiSortPlugin,
3904
+ no as PinnedColumnsPlugin,
3905
+ io as PinnedRowsPlugin,
3906
+ F as PivotPlugin,
3907
+ vo as PluginEvents,
3908
+ xo as PluginManager,
3909
+ ro as ReorderPlugin,
3910
+ Co as SelectionPlugin,
3911
+ so as ServerSidePlugin,
3912
+ yo as TreePlugin,
3913
+ lo as UndoRedoPlugin,
3914
+ L as VisibilityPlugin,
3915
+ Ro as aggregatorRegistry,
3916
+ Ie as getAggregator,
3917
+ Te as getValueAggregator,
3918
+ So as listAggregators,
3919
+ Eo as registerAggregator,
3920
+ te as runAggregator,
3921
+ ko as runValueAggregator,
3922
+ Ao as unregisterAggregator
3864
3923
  };
3865
3924
  //# sourceMappingURL=all.js.map