@toolbox-web/grid 0.0.4 → 0.0.5

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 (55) hide show
  1. package/all.d.ts +29 -6
  2. package/all.js +421 -421
  3. package/all.js.map +1 -1
  4. package/index.d.ts +28 -0
  5. package/index.js +774 -726
  6. package/index.js.map +1 -1
  7. package/lib/plugins/clipboard/index.js +55 -35
  8. package/lib/plugins/clipboard/index.js.map +1 -1
  9. package/lib/plugins/column-virtualization/index.js +49 -29
  10. package/lib/plugins/column-virtualization/index.js.map +1 -1
  11. package/lib/plugins/context-menu/index.js +35 -15
  12. package/lib/plugins/context-menu/index.js.map +1 -1
  13. package/lib/plugins/export/index.js +52 -32
  14. package/lib/plugins/export/index.js.map +1 -1
  15. package/lib/plugins/filtering/index.js +116 -99
  16. package/lib/plugins/filtering/index.js.map +1 -1
  17. package/lib/plugins/grouping-columns/index.js +42 -22
  18. package/lib/plugins/grouping-columns/index.js.map +1 -1
  19. package/lib/plugins/grouping-rows/index.js +20 -0
  20. package/lib/plugins/grouping-rows/index.js.map +1 -1
  21. package/lib/plugins/master-detail/index.js +50 -27
  22. package/lib/plugins/master-detail/index.js.map +1 -1
  23. package/lib/plugins/multi-sort/index.js +25 -5
  24. package/lib/plugins/multi-sort/index.js.map +1 -1
  25. package/lib/plugins/pinned-columns/index.js +20 -0
  26. package/lib/plugins/pinned-columns/index.js.map +1 -1
  27. package/lib/plugins/pinned-rows/index.js +20 -0
  28. package/lib/plugins/pinned-rows/index.js.map +1 -1
  29. package/lib/plugins/pivot/index.js +20 -0
  30. package/lib/plugins/pivot/index.js.map +1 -1
  31. package/lib/plugins/reorder/index.js +48 -28
  32. package/lib/plugins/reorder/index.js.map +1 -1
  33. package/lib/plugins/selection/index.js +51 -31
  34. package/lib/plugins/selection/index.js.map +1 -1
  35. package/lib/plugins/server-side/index.js +20 -0
  36. package/lib/plugins/server-side/index.js.map +1 -1
  37. package/lib/plugins/tree/index.js +76 -53
  38. package/lib/plugins/tree/index.js.map +1 -1
  39. package/lib/plugins/undo-redo/index.js +20 -0
  40. package/lib/plugins/undo-redo/index.js.map +1 -1
  41. package/lib/plugins/visibility/index.js +20 -0
  42. package/lib/plugins/visibility/index.js.map +1 -1
  43. package/package.json +1 -1
  44. package/umd/grid.all.umd.js +25 -25
  45. package/umd/grid.all.umd.js.map +1 -1
  46. package/umd/grid.umd.js +12 -12
  47. package/umd/grid.umd.js.map +1 -1
  48. package/umd/plugins/filtering.umd.js +3 -3
  49. package/umd/plugins/filtering.umd.js.map +1 -1
  50. package/umd/plugins/master-detail.umd.js +2 -2
  51. package/umd/plugins/master-detail.umd.js.map +1 -1
  52. package/umd/plugins/reorder.umd.js +1 -1
  53. package/umd/plugins/reorder.umd.js.map +1 -1
  54. package/umd/plugins/tree.umd.js +2 -2
  55. package/umd/plugins/tree.umd.js.map +1 -1
package/all.js CHANGED
@@ -1,33 +1,33 @@
1
1
  import { BaseGridPlugin as y, runAggregator as X, getAggregator as xe } from "./index.js";
2
- import { DGEvents as Pt, DataGridElement as Dt, FitModeEnum as Bt, GridCSSVars as Ht, GridClasses as Ot, GridDataAttrs as Wt, DataGridElement as Kt, GridSelectors as Vt, PluginEvents as Gt, SelectionPlugin as zt, TreePlugin as $t } from "./index.js";
2
+ import { DGEvents as Pt, DataGridElement as Dt, FitModeEnum as Bt, GridCSSVars as Ot, GridClasses as Ht, GridDataAttrs as Wt, DataGridElement as Kt, GridSelectors as Vt, PluginEvents as Gt, SelectionPlugin as zt, TreePlugin as $t } from "./index.js";
3
3
  function ve(i, e, t, n) {
4
4
  if (n.processCell)
5
5
  return n.processCell(i, e, t);
6
6
  if (i == null) return "";
7
7
  if (i instanceof Date) return i.toISOString();
8
8
  if (typeof i == "object") return JSON.stringify(i);
9
- const r = String(i), o = n.delimiter ?? " ", s = n.newline ?? `
9
+ const o = String(i), r = n.delimiter ?? " ", s = n.newline ?? `
10
10
  `;
11
- return n.quoteStrings || r.includes(o) || r.includes(s) || r.includes('"') ? `"${r.replace(/"/g, '""')}"` : r;
11
+ return n.quoteStrings || o.includes(r) || o.includes(s) || o.includes('"') ? `"${o.replace(/"/g, '""')}"` : o;
12
12
  }
13
13
  function F(i) {
14
- const { rows: e, columns: t, selectedIndices: n, config: r } = i, o = r.delimiter ?? " ", s = r.newline ?? `
14
+ const { rows: e, columns: t, selectedIndices: n, config: o } = i, r = o.delimiter ?? " ", s = o.newline ?? `
15
15
  `, l = t.filter((u) => !u.hidden && !u.field.startsWith("__")), a = [];
16
- if (r.includeHeaders) {
16
+ if (o.includeHeaders) {
17
17
  const u = l.map((h) => {
18
18
  const f = h.header || h.field;
19
- return f.includes(o) || f.includes(s) || f.includes('"') ? `"${f.replace(/"/g, '""')}"` : f;
19
+ return f.includes(r) || f.includes(s) || f.includes('"') ? `"${f.replace(/"/g, '""')}"` : f;
20
20
  });
21
- a.push(u.join(o));
21
+ a.push(u.join(r));
22
22
  }
23
23
  const d = [...n instanceof Set ? [...n] : n].sort((u, h) => u - h);
24
24
  for (const u of d) {
25
25
  const h = e[u];
26
26
  if (!h) continue;
27
27
  const f = l.map(
28
- (g) => ve(h[g.field], g.field, h, r)
28
+ (g) => ve(h[g.field], g.field, h, o)
29
29
  );
30
- a.push(f.join(o));
30
+ a.push(f.join(r));
31
31
  }
32
32
  return a.join(s);
33
33
  }
@@ -43,15 +43,15 @@ async function N(i) {
43
43
  }
44
44
  function J(i, e) {
45
45
  const t = e.delimiter ?? " ", n = e.newline ?? `
46
- `, r = i.replace(/\r\n/g, `
46
+ `, o = i.replace(/\r\n/g, `
47
47
  `).replace(/\r/g, `
48
- `), o = [];
48
+ `), r = [];
49
49
  let s = [], l = "", a = !1;
50
- for (let c = 0; c < r.length; c++) {
51
- const d = r[c];
52
- d === '"' && !a ? a = !0 : d === '"' && a ? r[c + 1] === '"' ? (l += '"', c++) : a = !1 : d === t && !a ? (s.push(l), l = "") : d === n && !a ? (s.push(l), l = "", (s.length > 1 || s.some((u) => u.trim() !== "")) && o.push(s), s = []) : l += d;
50
+ for (let c = 0; c < o.length; c++) {
51
+ const d = o[c];
52
+ d === '"' && !a ? a = !0 : d === '"' && a ? o[c + 1] === '"' ? (l += '"', c++) : a = !1 : d === t && !a ? (s.push(l), l = "") : d === n && !a ? (s.push(l), l = "", (s.length > 1 || s.some((u) => u.trim() !== "")) && r.push(s), s = []) : l += d;
53
53
  }
54
- return s.push(l), (s.length > 1 || s.some((c) => c.trim() !== "")) && o.push(s), o;
54
+ return s.push(l), (s.length > 1 || s.some((c) => c.trim() !== "")) && r.push(s), r;
55
55
  }
56
56
  async function Q() {
57
57
  try {
@@ -91,9 +91,9 @@ class vt extends y {
91
91
  * Handle copy operation
92
92
  */
93
93
  #t(e) {
94
- const t = this.#e(), n = t?.getSelectedRows() ?? [], r = n.length > 0, o = t?.getRanges() ?? [], s = o.length > 0, l = t?.getSelectedCell() != null;
94
+ const t = this.#e(), n = t?.getSelectedRows() ?? [], o = n.length > 0, r = t?.getRanges() ?? [], s = r.length > 0, l = t?.getSelectedCell() != null;
95
95
  let a, c, d;
96
- if (r && t)
96
+ if (o && t)
97
97
  a = F({
98
98
  rows: this.rows,
99
99
  columns: [...this.columns],
@@ -101,7 +101,7 @@ class vt extends y {
101
101
  config: this.config
102
102
  }), c = n.length, d = this.columns.filter((u) => !u.hidden && !u.field.startsWith("__")).length;
103
103
  else if (s && t) {
104
- const u = o[o.length - 1], h = this.#o({
104
+ const u = r[r.length - 1], h = this.#r({
105
105
  startRow: u.from.row,
106
106
  startCol: u.from.col,
107
107
  endRow: u.to.row,
@@ -109,7 +109,7 @@ class vt extends y {
109
109
  });
110
110
  a = h.text, c = h.rowCount, d = h.columnCount;
111
111
  } else if (l && t) {
112
- const u = t.getSelectedCell(), h = this.#r(u.row, u.col);
112
+ const u = t.getSelectedCell(), h = this.#o(u.row, u.col);
113
113
  if (!h) return;
114
114
  a = h.text, c = 1, d = 1;
115
115
  } else {
@@ -148,25 +148,25 @@ class vt extends y {
148
148
  /**
149
149
  * Build text for a single cell by row/col index.
150
150
  */
151
- #r(e, t) {
151
+ #o(e, t) {
152
152
  const n = this.rows[e];
153
153
  if (!n) return null;
154
- const r = this.columns[t];
155
- if (!r) return null;
156
- const o = n[r.field], s = r.header || r.field;
154
+ const o = this.columns[t];
155
+ if (!o) return null;
156
+ const r = n[o.field], s = o.header || o.field;
157
157
  let l;
158
158
  if (this.config.includeHeaders) {
159
- const a = o == null ? "" : String(o);
159
+ const a = r == null ? "" : String(r);
160
160
  l = `${s}: ${a}`;
161
161
  } else
162
- l = o == null ? "" : String(o);
162
+ l = r == null ? "" : String(r);
163
163
  return { text: l };
164
164
  }
165
165
  /**
166
166
  * Build text for a rectangular range of cells.
167
167
  */
168
- #o(e) {
169
- const { startRow: t, startCol: n, endRow: r, endCol: o } = e, s = Math.min(t, r), l = Math.max(t, r), a = Math.min(n, o), c = Math.max(n, o), d = this.config.delimiter ?? " ", u = this.config.newline ?? `
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), c = Math.max(n, r), d = this.config.delimiter ?? " ", u = this.config.newline ?? `
170
170
  `, h = [], f = this.columns.slice(a, c + 1);
171
171
  if (this.config.includeHeaders) {
172
172
  const g = f.map((m) => m.header || m.field);
@@ -196,11 +196,11 @@ class vt extends y {
196
196
  if (!t) return null;
197
197
  const n = t.dataset.fieldCache;
198
198
  if (!n) return null;
199
- const r = t.dataset.row;
200
- if (!r) return null;
201
- const o = parseInt(r, 10);
202
- if (isNaN(o)) return null;
203
- const s = this.rows[o];
199
+ const o = t.dataset.row;
200
+ if (!o) return null;
201
+ const r = parseInt(o, 10);
202
+ if (isNaN(r)) return null;
203
+ const s = this.rows[r];
204
204
  if (!s) return null;
205
205
  const l = s[n], c = this.columns.find((u) => u.field === n)?.header || n;
206
206
  let d;
@@ -277,32 +277,32 @@ function te(i) {
277
277
  function ne(i) {
278
278
  return i.reduce((e, t) => e + G(t.width), 0);
279
279
  }
280
- function ye(i, e, t, n, r) {
281
- const o = t.length;
282
- if (o === 0)
280
+ function ye(i, e, t, n, o) {
281
+ const r = t.length;
282
+ if (r === 0)
283
283
  return { startCol: 0, endCol: 0, visibleColumns: [] };
284
284
  let s = Ce(i, t, n);
285
- s = Math.max(0, s - r);
285
+ s = Math.max(0, s - o);
286
286
  const l = i + e;
287
287
  let a = s;
288
- for (let d = s; d < o; d++) {
288
+ for (let d = s; d < r; d++) {
289
289
  if (t[d] >= l) {
290
290
  a = d - 1;
291
291
  break;
292
292
  }
293
293
  a = d;
294
294
  }
295
- a = Math.min(o - 1, a + r);
295
+ a = Math.min(r - 1, a + o);
296
296
  const c = [];
297
297
  for (let d = s; d <= a; d++)
298
298
  c.push(d);
299
299
  return { startCol: s, endCol: a, visibleColumns: c };
300
300
  }
301
301
  function Ce(i, e, t) {
302
- let n = 0, r = e.length - 1;
303
- for (; n < r; ) {
304
- const o = Math.floor((n + r) / 2);
305
- e[o] + t[o] <= i ? n = o + 1 : r = o;
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;
306
306
  }
307
307
  return n;
308
308
  }
@@ -342,25 +342,25 @@ class yt extends y {
342
342
  const t = this.config.enabled && Se(e.length, this.config.threshold ?? 30, this.config.autoEnable ?? !0);
343
343
  if (this.isVirtualized = t ?? !1, this.columnWidths = ee(e), this.columnOffsets = te(e), this.totalWidth = ne(e), !t)
344
344
  return this.startCol = 0, this.endCol = e.length - 1, [...e];
345
- const n = this.grid.clientWidth || 800, r = ye(
345
+ const n = this.grid.clientWidth || 800, o = ye(
346
346
  this.scrollLeft,
347
347
  n,
348
348
  this.columnOffsets,
349
349
  this.columnWidths,
350
350
  this.config.overscan ?? 3
351
351
  );
352
- return this.startCol = r.startCol, this.endCol = r.endCol, r.visibleColumns.map((o) => e[o]);
352
+ return this.startCol = o.startCol, this.endCol = o.endCol, o.visibleColumns.map((r) => e[r]);
353
353
  }
354
354
  afterRender() {
355
355
  if (!this.isVirtualized) return;
356
356
  const e = this.shadowRoot;
357
357
  if (!e) return;
358
- const t = this.columnOffsets[this.startCol] ?? 0, n = e.querySelector(".header-row"), r = e.querySelectorAll(".data-grid-row");
359
- n && (n.style.paddingLeft = `${t}px`), r.forEach((s) => {
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
360
  s.style.paddingLeft = `${t}px`;
361
361
  });
362
- const o = e.querySelector(".rows-viewport .rows");
363
- o && (o.style.width = `${this.totalWidth}px`);
362
+ const r = e.querySelector(".rows-viewport .rows");
363
+ r && (r.style.width = `${this.totalWidth}px`);
364
364
  }
365
365
  onScroll(e) {
366
366
  !this.isVirtualized || Math.abs(e.scrollLeft - this.scrollLeft) < 1 || (this.scrollLeft = e.scrollLeft, this.requestRender());
@@ -409,46 +409,46 @@ function Re(i, e) {
409
409
  function V(i, e, t) {
410
410
  const n = document.createElement("div");
411
411
  n.className = "tbw-context-menu", n.setAttribute("role", "menu");
412
- for (const r of i) {
413
- if (r.separator) {
412
+ for (const o of i) {
413
+ if (o.separator) {
414
414
  const a = document.createElement("div");
415
415
  a.className = "tbw-context-menu-separator", a.setAttribute("role", "separator"), n.appendChild(a);
416
416
  continue;
417
417
  }
418
- const o = document.createElement("div");
419
- o.className = "tbw-context-menu-item", r.cssClass && o.classList.add(r.cssClass), o.setAttribute("role", "menuitem"), o.setAttribute("data-id", r.id);
420
- const s = Re(r, e);
421
- if (s && (o.classList.add("disabled"), o.setAttribute("aria-disabled", "true")), r.icon) {
418
+ const r = document.createElement("div");
419
+ r.className = "tbw-context-menu-item", o.cssClass && r.classList.add(o.cssClass), r.setAttribute("role", "menuitem"), r.setAttribute("data-id", o.id);
420
+ const s = Re(o, e);
421
+ if (s && (r.classList.add("disabled"), r.setAttribute("aria-disabled", "true")), o.icon) {
422
422
  const a = document.createElement("span");
423
- a.className = "tbw-context-menu-icon", a.innerHTML = r.icon, o.appendChild(a);
423
+ a.className = "tbw-context-menu-icon", a.innerHTML = o.icon, r.appendChild(a);
424
424
  }
425
425
  const l = document.createElement("span");
426
- if (l.className = "tbw-context-menu-label", l.textContent = r.name, o.appendChild(l), r.shortcut) {
426
+ if (l.className = "tbw-context-menu-label", l.textContent = o.name, r.appendChild(l), o.shortcut) {
427
427
  const a = document.createElement("span");
428
- a.className = "tbw-context-menu-shortcut", a.textContent = r.shortcut, o.appendChild(a);
428
+ a.className = "tbw-context-menu-shortcut", a.textContent = o.shortcut, r.appendChild(a);
429
429
  }
430
- if (r.subMenu?.length) {
430
+ if (o.subMenu?.length) {
431
431
  const a = document.createElement("span");
432
- a.className = "tbw-context-menu-arrow", a.textContent = "▶", o.appendChild(a), o.addEventListener("mouseenter", () => {
433
- if (o.querySelector(".tbw-context-menu") || !r.subMenu) return;
434
- const d = K(r.subMenu, e), u = V(d, e, t);
435
- u.classList.add("tbw-context-submenu"), u.style.position = "absolute", u.style.left = "100%", u.style.top = "0", o.style.position = "relative", o.appendChild(u);
436
- }), o.addEventListener("mouseleave", () => {
437
- const c = o.querySelector(".tbw-context-menu");
432
+ a.className = "tbw-context-menu-arrow", a.textContent = "▶", r.appendChild(a), r.addEventListener("mouseenter", () => {
433
+ if (r.querySelector(".tbw-context-menu") || !o.subMenu) return;
434
+ const d = K(o.subMenu, e), u = V(d, e, t);
435
+ u.classList.add("tbw-context-submenu"), u.style.position = "absolute", u.style.left = "100%", u.style.top = "0", r.style.position = "relative", r.appendChild(u);
436
+ }), r.addEventListener("mouseleave", () => {
437
+ const c = r.querySelector(".tbw-context-menu");
438
438
  c && c.remove();
439
439
  });
440
440
  }
441
- !s && r.action && !r.subMenu && o.addEventListener("click", (a) => {
442
- a.stopPropagation(), t(r);
443
- }), n.appendChild(o);
441
+ !s && o.action && !o.subMenu && r.addEventListener("click", (a) => {
442
+ a.stopPropagation(), t(o);
443
+ }), n.appendChild(r);
444
444
  }
445
445
  return n;
446
446
  }
447
- function re(i, e, t) {
447
+ function oe(i, e, t) {
448
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(), r = window.innerWidth, o = window.innerHeight;
449
+ const n = i.getBoundingClientRect(), o = window.innerWidth, r = window.innerHeight;
450
450
  let s = e, l = t;
451
- e + n.width > r && (s = e - n.width), t + n.height > o && (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";
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
452
  }
453
453
  let P = null, D = null, A = null;
454
454
  const ke = `
@@ -557,9 +557,9 @@ class Ct extends y {
557
557
  const t = e.children[0];
558
558
  t && t.getAttribute("data-context-menu-bound") !== "true" && (t.setAttribute("data-context-menu-bound", "true"), t.addEventListener("contextmenu", (n) => {
559
559
  if (!this.config.enabled) return;
560
- const r = n;
561
- r.preventDefault();
562
- const o = r.target, s = o.closest("[data-row][data-col]"), l = o.closest(".header-cell");
560
+ const o = n;
561
+ o.preventDefault();
562
+ const r = o.target, s = r.closest("[data-row][data-col]"), l = r.closest(".header-cell");
563
563
  let a;
564
564
  if (s) {
565
565
  const d = parseInt(s.getAttribute("data-row") ?? "-1", 10), u = parseInt(s.getAttribute("data-col") ?? "-1", 10), h = this.columns[u], f = this.rows[d];
@@ -571,7 +571,7 @@ class Ct extends y {
571
571
  field: h?.field ?? "",
572
572
  value: f?.[h?.field] ?? null,
573
573
  isHeader: !1,
574
- event: r
574
+ event: o
575
575
  };
576
576
  } else if (l) {
577
577
  const d = parseInt(l.getAttribute("data-col") ?? "-1", 10), u = this.columns[d];
@@ -583,15 +583,15 @@ class Ct extends y {
583
583
  field: u?.field ?? "",
584
584
  value: null,
585
585
  isHeader: !0,
586
- event: r
586
+ event: o
587
587
  };
588
588
  } else
589
589
  return;
590
- this.params = a, this.position = { x: r.clientX, y: r.clientY };
590
+ this.params = a, this.position = { x: o.clientX, y: o.clientY };
591
591
  const c = K(this.config.items ?? B, a);
592
592
  c.length && (this.menuElement && this.menuElement.remove(), this.menuElement = V(c, a, (d) => {
593
593
  d.action && d.action(a), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
594
- }), document.body.appendChild(this.menuElement), re(this.menuElement, r.clientX, r.clientY), this.isOpen = !0, this.emit("context-menu-open", { params: a, items: c }));
594
+ }), document.body.appendChild(this.menuElement), oe(this.menuElement, o.clientX, o.clientY), this.isOpen = !0, this.emit("context-menu-open", { params: a, items: c }));
595
595
  }));
596
596
  }
597
597
  // ===== Public API =====
@@ -602,7 +602,7 @@ class Ct extends y {
602
602
  * @param params - Partial context menu parameters
603
603
  */
604
604
  showMenu(e, t, n) {
605
- const r = {
605
+ const o = {
606
606
  row: n.row ?? null,
607
607
  rowIndex: n.rowIndex ?? -1,
608
608
  column: n.column ?? null,
@@ -611,10 +611,10 @@ class Ct extends y {
611
611
  value: n.value ?? null,
612
612
  isHeader: n.isHeader ?? !1,
613
613
  event: n.event ?? new MouseEvent("contextmenu")
614
- }, o = K(this.config.items ?? B, r);
615
- this.menuElement && this.menuElement.remove(), this.menuElement = V(o, r, (s) => {
616
- s.action && s.action(r), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
617
- }), document.body.appendChild(this.menuElement), re(this.menuElement, e, t), this.isOpen = !0;
614
+ }, r = K(this.config.items ?? B, o);
615
+ this.menuElement && this.menuElement.remove(), this.menuElement = V(r, o, (s) => {
616
+ s.action && s.action(o), this.menuElement?.remove(), this.menuElement = null, this.isOpen = !1;
617
+ }), document.body.appendChild(this.menuElement), oe(this.menuElement, e, t), this.isOpen = !0;
618
618
  }
619
619
  /**
620
620
  * Hide the context menu.
@@ -631,7 +631,7 @@ class Ct extends y {
631
631
  }
632
632
  // Styles are injected globally via installGlobalHandlers() since menu renders in document.body
633
633
  }
634
- function oe(i, e = !0) {
634
+ function re(i, e = !0) {
635
635
  if (i == null) return "";
636
636
  if (i instanceof Date) return i.toISOString();
637
637
  if (typeof i == "object") return JSON.stringify(i);
@@ -640,23 +640,23 @@ function oe(i, e = !0) {
640
640
  `) || t.includes("\r")) ? `"${t.replace(/"/g, '""')}"` : t;
641
641
  }
642
642
  function Ee(i, e, t, n = {}) {
643
- const r = n.delimiter ?? ",", o = n.newline ?? `
643
+ const o = n.delimiter ?? ",", r = n.newline ?? `
644
644
  `, s = [], l = n.bom ? "\uFEFF" : "";
645
645
  if (t.includeHeaders !== !1) {
646
646
  const a = e.map((c) => {
647
647
  const d = c.header || c.field, u = t.processHeader ? t.processHeader(d, c.field) : d;
648
- return oe(u);
648
+ return re(u);
649
649
  });
650
- s.push(a.join(r));
650
+ s.push(a.join(o));
651
651
  }
652
652
  for (const a of i) {
653
653
  const c = e.map((d) => {
654
654
  let u = a[d.field];
655
- return t.processCell && (u = t.processCell(u, d.field, a)), oe(u);
655
+ return t.processCell && (u = t.processCell(u, d.field, a)), re(u);
656
656
  });
657
- s.push(c.join(r));
657
+ s.push(c.join(o));
658
658
  }
659
- return l + s.join(o);
659
+ return l + s.join(r);
660
660
  }
661
661
  function z(i, e) {
662
662
  const t = URL.createObjectURL(i), n = document.createElement("a");
@@ -679,18 +679,18 @@ function _e(i, e, t) {
679
679
  if (t.includeHeaders !== !1) {
680
680
  n += `
681
681
  <Row>`;
682
- for (const r of e) {
683
- const o = r.header || r.field, s = t.processHeader ? t.processHeader(o, r.field) : o;
682
+ for (const o of e) {
683
+ const r = o.header || o.field, s = t.processHeader ? t.processHeader(r, o.field) : r;
684
684
  n += `<Cell><Data ss:Type="String">${ie(s)}</Data></Cell>`;
685
685
  }
686
686
  n += "</Row>";
687
687
  }
688
- for (const r of i) {
688
+ for (const o of i) {
689
689
  n += `
690
690
  <Row>`;
691
- for (const o of e) {
692
- let s = r[o.field];
693
- t.processCell && (s = t.processCell(s, o.field, r));
691
+ for (const r of e) {
692
+ let s = o[r.field];
693
+ t.processCell && (s = t.processCell(s, r.field, o));
694
694
  let l = "String", a = "";
695
695
  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>`;
696
696
  }
@@ -724,7 +724,7 @@ class St extends y {
724
724
  lastExportInfo = null;
725
725
  // ===== Private Methods =====
726
726
  performExport(e, t) {
727
- const n = this.config, r = {
727
+ const n = this.config, o = {
728
728
  format: e,
729
729
  fileName: t?.fileName ?? n.fileName ?? "export",
730
730
  includeHeaders: t?.includeHeaders ?? n.includeHeaders,
@@ -733,10 +733,10 @@ class St extends y {
733
733
  columns: t?.columns,
734
734
  rowIndices: t?.rowIndices
735
735
  };
736
- let o = [...this.columns];
737
- if (n.onlyVisible && (o = o.filter((a) => !a.hidden && !a.field.startsWith("__"))), t?.columns) {
736
+ let r = [...this.columns];
737
+ if (n.onlyVisible && (r = r.filter((a) => !a.hidden && !a.field.startsWith("__"))), t?.columns) {
738
738
  const a = new Set(t.columns);
739
- o = o.filter((c) => a.has(c.field));
739
+ r = r.filter((c) => a.has(c.field));
740
740
  }
741
741
  let s = [...this.rows];
742
742
  if (n.onlySelected) {
@@ -744,25 +744,25 @@ class St extends y {
744
744
  a?.selected?.size && (s = [...a.selected].sort((d, u) => d - u).map((d) => this.rows[d]).filter(Boolean));
745
745
  }
746
746
  t?.rowIndices && (s = t.rowIndices.map((a) => this.rows[a]).filter(Boolean)), this.isExportingFlag = !0;
747
- let l = r.fileName;
747
+ let l = o.fileName;
748
748
  try {
749
749
  switch (e) {
750
750
  case "csv": {
751
- const a = Ee(s, o, r, { bom: !0 });
751
+ const a = Ee(s, r, o, { bom: !0 });
752
752
  l = l.endsWith(".csv") ? l : `${l}.csv`, Ae(a, l);
753
753
  break;
754
754
  }
755
755
  case "excel": {
756
- const a = _e(s, o, r);
756
+ const a = _e(s, r, o);
757
757
  l = l.endsWith(".xls") ? l : `${l}.xls`, Ie(a, l);
758
758
  break;
759
759
  }
760
760
  case "json": {
761
761
  const a = s.map((u) => {
762
762
  const h = {};
763
- for (const f of o) {
763
+ for (const f of r) {
764
764
  let g = u[f.field];
765
- r.processCell && (g = r.processCell(g, f.field, u)), h[f.field] = g;
765
+ o.processCell && (g = o.processCell(g, f.field, u)), h[f.field] = g;
766
766
  }
767
767
  return h;
768
768
  }), c = JSON.stringify(a, null, 2);
@@ -776,7 +776,7 @@ class St extends y {
776
776
  format: e,
777
777
  fileName: l,
778
778
  rowCount: s.length,
779
- columnCount: o.length
779
+ columnCount: r.length
780
780
  });
781
781
  } finally {
782
782
  this.isExportingFlag = !1;
@@ -827,15 +827,15 @@ class St extends y {
827
827
  }
828
828
  }
829
829
  function Te(i) {
830
- const { totalRows: e, viewportHeight: t, scrollTop: n, rowHeight: r, overscan: o } = i, s = Math.ceil(t / r);
831
- let l = Math.floor(n / r) - o;
830
+ const { totalRows: e, viewportHeight: t, scrollTop: n, rowHeight: o, overscan: r } = i, s = Math.ceil(t / o);
831
+ let l = Math.floor(n / o) - r;
832
832
  l < 0 && (l = 0);
833
- let a = l + s + o * 2;
834
- return a > e && (a = e), a === e && l > 0 && (l = Math.max(0, a - s - o * 2)), {
833
+ let a = l + s + r * 2;
834
+ return a > e && (a = e), a === e && l > 0 && (l = Math.max(0, a - s - r * 2)), {
835
835
  start: l,
836
836
  end: a,
837
- offsetY: l * r,
838
- totalHeight: e * r
837
+ offsetY: l * o,
838
+ totalHeight: e * o
839
839
  };
840
840
  }
841
841
  function Le(i, e) {
@@ -848,21 +848,21 @@ function Me(i, e, t = !1) {
848
848
  if (e.operator === "notBlank")
849
849
  return n != null && n !== "";
850
850
  if (n == null) return !1;
851
- const r = String(n), o = t ? r : r.toLowerCase(), s = t ? String(e.value) : String(e.value).toLowerCase();
851
+ const o = String(n), r = t ? o : o.toLowerCase(), s = t ? String(e.value) : String(e.value).toLowerCase();
852
852
  switch (e.operator) {
853
853
  // Text operators
854
854
  case "contains":
855
- return o.includes(s);
855
+ return r.includes(s);
856
856
  case "notContains":
857
- return !o.includes(s);
857
+ return !r.includes(s);
858
858
  case "equals":
859
- return o === s;
859
+ return r === s;
860
860
  case "notEquals":
861
- return o !== s;
861
+ return r !== s;
862
862
  case "startsWith":
863
- return o.startsWith(s);
863
+ return r.startsWith(s);
864
864
  case "endsWith":
865
- return o.endsWith(s);
865
+ return r.endsWith(s);
866
866
  // Number/Date operators (use raw numeric values)
867
867
  case "lessThan":
868
868
  return Number(n) < Number(e.value);
@@ -884,7 +884,7 @@ function Me(i, e, t = !1) {
884
884
  }
885
885
  }
886
886
  function qe(i, e, t = !1) {
887
- return e.length ? i.filter((n) => e.every((r) => Me(n, r, t))) : i;
887
+ return e.length ? i.filter((n) => e.every((o) => Me(n, o, t))) : i;
888
888
  }
889
889
  function Fe(i) {
890
890
  return JSON.stringify(
@@ -899,10 +899,10 @@ function Fe(i) {
899
899
  function se(i, e) {
900
900
  const t = /* @__PURE__ */ new Set();
901
901
  for (const n of i) {
902
- const r = n[e];
903
- r != null && t.add(r);
902
+ const o = n[e];
903
+ o != null && t.add(o);
904
904
  }
905
- return [...t].sort((n, r) => typeof n == "number" && typeof r == "number" ? n - r : String(n).localeCompare(String(r)));
905
+ return [...t].sort((n, o) => typeof n == "number" && typeof o == "number" ? n - o : String(n).localeCompare(String(o)));
906
906
  }
907
907
  const Ne = `
908
908
  .tbw-filter-panel {
@@ -1066,7 +1066,8 @@ class E extends y {
1066
1066
  panelElement = null;
1067
1067
  searchText = /* @__PURE__ */ new Map();
1068
1068
  excludedValues = /* @__PURE__ */ new Map();
1069
- documentClickHandler = null;
1069
+ panelAbortController = null;
1070
+ // For panel-scoped listeners
1070
1071
  globalStylesInjected = !1;
1071
1072
  // Virtualization constants for filter value list
1072
1073
  static LIST_ITEM_HEIGHT = 28;
@@ -1078,7 +1079,7 @@ class E extends y {
1078
1079
  super.attach(e), this.injectGlobalStyles();
1079
1080
  }
1080
1081
  detach() {
1081
- this.filters.clear(), this.cachedResult = null, this.cacheKey = null, this.openPanelField = null, this.panelElement && (this.panelElement.remove(), this.panelElement = null), this.searchText.clear(), this.excludedValues.clear(), this.removeDocumentClickHandler();
1082
+ this.filters.clear(), this.cachedResult = null, this.cacheKey = null, this.openPanelField = null, this.panelElement && (this.panelElement.remove(), this.panelElement = null), this.searchText.clear(), this.excludedValues.clear(), this.panelAbortController?.abort(), this.panelAbortController = null;
1082
1083
  }
1083
1084
  // ===== Hooks =====
1084
1085
  processRows(e) {
@@ -1087,23 +1088,23 @@ class E extends y {
1087
1088
  const n = Fe(t);
1088
1089
  if (this.cacheKey === n && this.cachedResult)
1089
1090
  return this.cachedResult;
1090
- const r = qe([...e], t, this.config.caseSensitive);
1091
- return this.cachedResult = r, this.cacheKey = n, r;
1091
+ const o = qe([...e], t, this.config.caseSensitive);
1092
+ return this.cachedResult = o, this.cacheKey = n, o;
1092
1093
  }
1093
1094
  afterRender() {
1094
1095
  if (!this.config.enabled) return;
1095
1096
  const e = this.shadowRoot;
1096
1097
  if (!e) return;
1097
1098
  e.querySelectorAll('[part~="header-cell"]').forEach((n) => {
1098
- const r = n.getAttribute("data-col");
1099
- if (r === null) return;
1100
- const o = this.columns[parseInt(r, 10)];
1101
- if (!o || o.filterable === !1 || n.querySelector(".tbw-filter-btn")) return;
1102
- const s = o.field;
1099
+ const o = n.getAttribute("data-col");
1100
+ if (o === null) return;
1101
+ const r = this.columns[parseInt(o, 10)];
1102
+ if (!r || r.filterable === !1 || n.querySelector(".tbw-filter-btn")) return;
1103
+ const s = r.field;
1103
1104
  if (!s) return;
1104
1105
  const l = document.createElement("button");
1105
- l.className = "tbw-filter-btn", l.setAttribute("aria-label", `Filter ${o.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) => {
1106
- a.stopPropagation(), this.toggleFilterPanel(s, o, l);
1106
+ 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) => {
1107
+ a.stopPropagation(), this.toggleFilterPanel(s, r, l);
1107
1108
  }), n.appendChild(l);
1108
1109
  });
1109
1110
  }
@@ -1214,22 +1215,22 @@ class E extends y {
1214
1215
  return;
1215
1216
  }
1216
1217
  this.closeFilterPanel();
1217
- const r = document.createElement("div");
1218
- r.className = "tbw-filter-panel", this.panelElement = r, this.openPanelField = e;
1219
- const o = se(this.sourceRows, e);
1218
+ const o = document.createElement("div");
1219
+ o.className = "tbw-filter-panel", this.panelElement = o, this.openPanelField = e;
1220
+ const r = se(this.sourceRows, e);
1220
1221
  let s = this.excludedValues.get(e);
1221
1222
  s || (s = /* @__PURE__ */ new Set(), this.excludedValues.set(e, s));
1222
1223
  const l = this.searchText.get(e) ?? "", a = {
1223
1224
  field: e,
1224
1225
  column: t,
1225
- uniqueValues: o,
1226
+ uniqueValues: r,
1226
1227
  excludedValues: s,
1227
1228
  searchText: l,
1228
- applySetFilter: (u) => {
1229
- this.applySetFilter(e, u), this.closeFilterPanel();
1229
+ applySetFilter: (d) => {
1230
+ this.applySetFilter(e, d), this.closeFilterPanel();
1230
1231
  },
1231
- applyTextFilter: (u, h, f) => {
1232
- this.applyTextFilter(e, u, h, f), this.closeFilterPanel();
1232
+ applyTextFilter: (d, u, h) => {
1233
+ this.applyTextFilter(e, d, u, h), this.closeFilterPanel();
1233
1234
  },
1234
1235
  clearFilter: () => {
1235
1236
  this.clearFieldFilter(e), this.closeFilterPanel();
@@ -1237,25 +1238,21 @@ class E extends y {
1237
1238
  closePanel: () => this.closeFilterPanel()
1238
1239
  };
1239
1240
  let c = !1;
1240
- this.config.filterPanelRenderer && (this.config.filterPanelRenderer(r, a), c = r.children.length > 0), c || this.renderDefaultFilterPanel(r, a, o, s), document.body.appendChild(r), this.positionPanel(r, n);
1241
- const d = (u) => {
1242
- !r.contains(u.target) && u.target !== n && this.closeFilterPanel();
1243
- };
1244
- this.documentClickHandler = d, setTimeout(() => {
1245
- document.addEventListener("click", d);
1241
+ this.config.filterPanelRenderer && (this.config.filterPanelRenderer(o, a), c = o.children.length > 0), c || this.renderDefaultFilterPanel(o, a, r, s), document.body.appendChild(o), this.positionPanel(o, n), this.panelAbortController = new AbortController(), setTimeout(() => {
1242
+ document.addEventListener(
1243
+ "click",
1244
+ (d) => {
1245
+ !o.contains(d.target) && d.target !== n && this.closeFilterPanel();
1246
+ },
1247
+ { signal: this.panelAbortController?.signal }
1248
+ );
1246
1249
  }, 0);
1247
1250
  }
1248
1251
  /**
1249
1252
  * Close the filter panel
1250
1253
  */
1251
1254
  closeFilterPanel() {
1252
- this.panelElement && (this.panelElement.remove(), this.panelElement = null), this.openPanelField = null, this.removeDocumentClickHandler();
1253
- }
1254
- /**
1255
- * Remove the document click handler
1256
- */
1257
- removeDocumentClickHandler() {
1258
- this.documentClickHandler && (document.removeEventListener("click", this.documentClickHandler), this.documentClickHandler = null);
1255
+ this.panelElement && (this.panelElement.remove(), this.panelElement = null), this.openPanelField = null, this.panelAbortController?.abort(), this.panelAbortController = null;
1259
1256
  }
1260
1257
  /**
1261
1258
  * Position the panel below the button
@@ -1263,18 +1260,18 @@ class E extends y {
1263
1260
  positionPanel(e, t) {
1264
1261
  const n = t.getBoundingClientRect();
1265
1262
  e.style.position = "fixed", e.style.top = `${n.bottom + 4}px`, e.style.left = `${n.left}px`, requestAnimationFrame(() => {
1266
- const r = e.getBoundingClientRect();
1267
- r.right > window.innerWidth - 8 && (e.style.left = `${window.innerWidth - r.width - 8}px`), r.bottom > window.innerHeight - 8 && (e.style.top = `${n.top - r.height - 4}px`);
1263
+ const o = e.getBoundingClientRect();
1264
+ 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`);
1268
1265
  });
1269
1266
  }
1270
1267
  /**
1271
1268
  * Render the default filter panel content
1272
1269
  */
1273
- renderDefaultFilterPanel(e, t, n, r) {
1274
- const { field: o } = t, s = document.createElement("div");
1270
+ renderDefaultFilterPanel(e, t, n, o) {
1271
+ const { field: r } = t, s = document.createElement("div");
1275
1272
  s.className = "tbw-filter-search";
1276
1273
  const l = document.createElement("input");
1277
- l.type = "text", l.placeholder = "Search...", l.className = "tbw-filter-search-input", l.value = this.searchText.get(o) ?? "", s.appendChild(l), e.appendChild(s);
1274
+ l.type = "text", l.placeholder = "Search...", l.className = "tbw-filter-search-input", l.value = this.searchText.get(r) ?? "", s.appendChild(l), e.appendChild(s);
1278
1275
  const a = document.createElement("div");
1279
1276
  a.className = "tbw-filter-actions";
1280
1277
  const c = document.createElement("label");
@@ -1302,7 +1299,7 @@ class E extends y {
1302
1299
  const b = /* @__PURE__ */ new Map();
1303
1300
  n.forEach((p) => {
1304
1301
  const v = p == null ? "__null__" : String(p);
1305
- b.set(v, !r.has(p));
1302
+ b.set(v, !o.has(p));
1306
1303
  }), h();
1307
1304
  let S = [];
1308
1305
  const R = (p, v) => {
@@ -1355,7 +1352,7 @@ class E extends y {
1355
1352
  let U;
1356
1353
  l.addEventListener("input", () => {
1357
1354
  clearTimeout(U), U = setTimeout(() => {
1358
- this.searchText.set(o, l.value), j(l.value);
1355
+ this.searchText.set(r, l.value), j(l.value);
1359
1356
  }, this.config.debounceMs ?? 150);
1360
1357
  });
1361
1358
  const I = document.createElement("div");
@@ -1395,13 +1392,13 @@ class E extends y {
1395
1392
  /**
1396
1393
  * Apply a text filter
1397
1394
  */
1398
- applyTextFilter(e, t, n, r) {
1395
+ applyTextFilter(e, t, n, o) {
1399
1396
  this.filters.set(e, {
1400
1397
  field: e,
1401
1398
  type: "text",
1402
1399
  operator: t,
1403
1400
  value: n,
1404
- valueTo: r
1401
+ valueTo: o
1405
1402
  }), this.cachedResult = null, this.cacheKey = null, this.emit("filter-change", {
1406
1403
  filters: [...this.filters.values()],
1407
1404
  filteredRowCount: 0
@@ -1492,14 +1489,14 @@ function Pe(i) {
1492
1489
  implicit: !0
1493
1490
  });
1494
1491
  };
1495
- let r = [], o = 0;
1492
+ let o = [], r = 0;
1496
1493
  return i.forEach((s, l) => {
1497
1494
  const a = s.group;
1498
1495
  if (!a) {
1499
- r.length === 0 && (o = l), r.push(s);
1496
+ o.length === 0 && (r = l), o.push(s);
1500
1497
  return;
1501
1498
  }
1502
- r.length && (n(o, r.slice()), r = []);
1499
+ o.length && (n(r, o.slice()), o = []);
1503
1500
  const c = typeof a == "string" ? a : a.id;
1504
1501
  let d = e.get(c);
1505
1502
  d || (d = {
@@ -1508,21 +1505,21 @@ function Pe(i) {
1508
1505
  columns: [],
1509
1506
  firstIndex: l
1510
1507
  }, e.set(c, d), t.push(d)), d.columns.push(s);
1511
- }), r.length && n(o, r), t.length === 1 && t[0].implicit && t[0].columns.length === i.length ? [] : t;
1508
+ }), o.length && n(r, o), t.length === 1 && t[0].implicit && t[0].columns.length === i.length ? [] : t;
1512
1509
  }
1513
1510
  function De(i, e, t) {
1514
1511
  if (!e.length || !i) return;
1515
1512
  const n = /* @__PURE__ */ new Map();
1516
- for (const o of e)
1517
- for (const s of o.columns)
1518
- s?.field && n.set(s.field, o.id);
1519
- const r = Array.from(i.querySelectorAll(".cell[data-field]"));
1520
- r.forEach((o) => {
1521
- const s = o.getAttribute("data-field") || "", l = n.get(s);
1522
- l && (o.classList.add("grouped"), o.getAttribute("data-group") || o.setAttribute("data-group", l));
1513
+ for (const r of e)
1514
+ for (const s of r.columns)
1515
+ s?.field && n.set(s.field, r.id);
1516
+ const o = Array.from(i.querySelectorAll(".cell[data-field]"));
1517
+ o.forEach((r) => {
1518
+ const s = r.getAttribute("data-field") || "", l = n.get(s);
1519
+ l && (r.classList.add("grouped"), r.getAttribute("data-group") || r.setAttribute("data-group", l));
1523
1520
  });
1524
- for (const o of e) {
1525
- const s = o.columns[o.columns.length - 1], l = r.find((a) => a.getAttribute("data-field") === s.field);
1521
+ for (const r of e) {
1522
+ const s = r.columns[r.columns.length - 1], l = o.find((a) => a.getAttribute("data-field") === s.field);
1526
1523
  l && l.classList.add("group-end");
1527
1524
  }
1528
1525
  }
@@ -1531,12 +1528,12 @@ function Be(i, e) {
1531
1528
  const t = document.createElement("div");
1532
1529
  t.className = "header-group-row", t.setAttribute("role", "row");
1533
1530
  for (const n of i) {
1534
- const r = n.firstIndex != null ? n.firstIndex : e.findIndex((a) => n.columns.includes(a)), o = String(n.id).startsWith("__implicit__"), s = o ? "" : n.label || n.id, l = document.createElement("div");
1535
- l.className = "cell header-group-cell", o && l.classList.add("implicit-group"), l.setAttribute("data-group", String(n.id)), l.style.gridColumn = `${r + 1} / span ${n.columns.length}`, l.textContent = s, t.appendChild(l);
1531
+ 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");
1532
+ 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);
1536
1533
  }
1537
1534
  return t;
1538
1535
  }
1539
- function He(i) {
1536
+ function Oe(i) {
1540
1537
  return i.some((e) => e.group != null);
1541
1538
  }
1542
1539
  class Rt extends y {
@@ -1561,7 +1558,7 @@ class Rt extends y {
1561
1558
  */
1562
1559
  static detect(e, t) {
1563
1560
  const n = t?.columns;
1564
- return Array.isArray(n) ? He(n) : !1;
1561
+ return Array.isArray(n) ? Oe(n) : !1;
1565
1562
  }
1566
1563
  // ===== Hooks =====
1567
1564
  processColumns(e) {
@@ -1582,11 +1579,11 @@ class Rt extends y {
1582
1579
  t && t.remove();
1583
1580
  const n = Be(this.groups, this.columns);
1584
1581
  if (n) {
1585
- const o = e.querySelector(".header-row");
1586
- o ? e.insertBefore(n, o) : e.appendChild(n);
1582
+ const r = e.querySelector(".header-row");
1583
+ r ? e.insertBefore(n, r) : e.appendChild(n);
1587
1584
  }
1588
- const r = e.querySelector(".header-row");
1589
- r && De(r, this.groups, this.columns);
1585
+ const o = e.querySelector(".header-row");
1586
+ o && De(o, this.groups, this.columns);
1590
1587
  }
1591
1588
  // ===== Public API =====
1592
1589
  /**
@@ -1648,38 +1645,38 @@ class Rt extends y {
1648
1645
  }
1649
1646
  `;
1650
1647
  }
1651
- function Oe({ rows: i, config: e, expanded: t }) {
1648
+ function He({ rows: i, config: e, expanded: t }) {
1652
1649
  const n = e.groupOn;
1653
1650
  if (!e.enabled || typeof n != "function")
1654
1651
  return [];
1655
- const r = { key: "__root__", value: null, depth: -1, rows: [], children: /* @__PURE__ */ new Map() };
1652
+ const o = { key: "__root__", value: null, depth: -1, rows: [], children: /* @__PURE__ */ new Map() };
1656
1653
  if (i.forEach((l) => {
1657
1654
  let a = n(l);
1658
1655
  a == null || a === !1 ? a = ["__ungrouped__"] : Array.isArray(a) || (a = [a]);
1659
- let c = r;
1656
+ let c = o;
1660
1657
  a.forEach((d, u) => {
1661
1658
  const h = d == null ? "∅" : String(d), f = c.key === "__root__" ? h : c.key + "||" + h;
1662
1659
  let g = c.children.get(h);
1663
1660
  g || (g = { key: f, value: d, depth: u, rows: [], children: /* @__PURE__ */ new Map(), parent: c }, c.children.set(h, g)), c = g;
1664
1661
  }), c.rows.push(l);
1665
- }), r.children.size === 1 && r.children.has("__ungrouped__") && r.children.get("__ungrouped__").rows.length === i.length)
1662
+ }), o.children.size === 1 && o.children.has("__ungrouped__") && o.children.get("__ungrouped__").rows.length === i.length)
1666
1663
  return [];
1667
- const o = [], s = (l) => {
1668
- if (l === r) {
1664
+ const r = [], s = (l) => {
1665
+ if (l === o) {
1669
1666
  l.children.forEach((c) => s(c));
1670
1667
  return;
1671
1668
  }
1672
1669
  const a = t.has(l.key);
1673
- o.push({
1670
+ r.push({
1674
1671
  kind: "group",
1675
1672
  key: l.key,
1676
1673
  value: l.value,
1677
1674
  depth: l.depth,
1678
1675
  rows: l.rows,
1679
1676
  expanded: a
1680
- }), a && (l.children.size ? l.children.forEach((c) => s(c)) : l.rows.forEach((c) => o.push({ kind: "data", row: c, rowIndex: i.indexOf(c) })));
1677
+ }), a && (l.children.size ? l.children.forEach((c) => s(c)) : l.rows.forEach((c) => r.push({ kind: "data", row: c, rowIndex: i.indexOf(c) })));
1681
1678
  };
1682
- return s(r), o;
1679
+ return s(o), r;
1683
1680
  }
1684
1681
  function We(i, e) {
1685
1682
  const t = new Set(i);
@@ -1729,20 +1726,20 @@ class kt extends y {
1729
1726
  const t = this.config;
1730
1727
  if (!t.enabled || typeof t.groupOn != "function")
1731
1728
  return this.isActive = !1, this.flattenedRows = [], [...e];
1732
- const n = Oe({
1729
+ const n = He({
1733
1730
  rows: e,
1734
1731
  config: t,
1735
1732
  expanded: this.expandedKeys
1736
1733
  });
1737
- return n.length === 0 ? (this.isActive = !1, this.flattenedRows = [], [...e]) : (this.isActive = !0, this.flattenedRows = n, n.map((r) => r.kind === "group" ? {
1734
+ return n.length === 0 ? (this.isActive = !1, this.flattenedRows = [], [...e]) : (this.isActive = !0, this.flattenedRows = n, n.map((o) => o.kind === "group" ? {
1738
1735
  __isGroupRow: !0,
1739
- __groupKey: r.key,
1740
- __groupValue: r.value,
1741
- __groupDepth: r.depth,
1742
- __groupRows: r.rows,
1743
- __groupExpanded: r.expanded,
1744
- __groupRowCount: Ge(r)
1745
- } : r.row));
1736
+ __groupKey: o.key,
1737
+ __groupValue: o.value,
1738
+ __groupDepth: o.depth,
1739
+ __groupRows: o.rows,
1740
+ __groupExpanded: o.expanded,
1741
+ __groupRowCount: Ge(o)
1742
+ } : o.row));
1746
1743
  }
1747
1744
  onCellClick(e) {
1748
1745
  const t = e.row;
@@ -1755,11 +1752,11 @@ class kt extends y {
1755
1752
  renderRow(e, t, n) {
1756
1753
  if (!e?.__isGroupRow)
1757
1754
  return !1;
1758
- const r = this.config;
1759
- if (r.groupRowRenderer) {
1755
+ const o = this.config;
1756
+ if (o.groupRowRenderer) {
1760
1757
  const l = () => {
1761
1758
  this.toggle(e.__groupKey);
1762
- }, a = r.groupRowRenderer({
1759
+ }, a = o.groupRowRenderer({
1763
1760
  key: e.__groupKey,
1764
1761
  value: e.__groupValue,
1765
1762
  depth: e.__groupDepth,
@@ -1770,32 +1767,32 @@ class kt extends y {
1770
1767
  if (a)
1771
1768
  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;
1772
1769
  }
1773
- const o = () => {
1770
+ const r = () => {
1774
1771
  this.toggle(e.__groupKey);
1775
1772
  };
1776
- 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) * (r.indentWidth ?? 20)}px`, t.innerHTML = "", r.fullWidth !== !1 ? this.renderFullWidthGroupRow(e, t, o) : this.renderPerColumnGroupRow(e, t, o), !0;
1773
+ 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;
1777
1774
  }
1778
1775
  afterRender() {
1779
1776
  }
1780
1777
  // ===== Private Rendering Helpers =====
1781
1778
  renderFullWidthGroupRow(e, t, n) {
1782
- const r = this.config, o = document.createElement("div");
1783
- o.className = "cell group-full", o.style.gridColumn = "1 / -1", o.setAttribute("role", "gridcell");
1779
+ const o = this.config, r = document.createElement("div");
1780
+ r.className = "cell group-full", r.style.gridColumn = "1 / -1", r.setAttribute("role", "gridcell");
1784
1781
  const s = document.createElement("button");
1785
1782
  s.type = "button", s.className = "group-toggle", s.setAttribute("aria-label", e.__groupExpanded ? "Collapse group" : "Expand group"), s.textContent = e.__groupExpanded ? "▾" : "▸", s.addEventListener("click", (c) => {
1786
1783
  c.stopPropagation(), n();
1787
- }), o.appendChild(s);
1784
+ }), r.appendChild(s);
1788
1785
  const l = document.createElement("span");
1789
1786
  l.className = "group-label";
1790
- const a = r.formatLabel ? r.formatLabel(e.__groupValue, e.__groupDepth || 0, e.__groupKey) : String(e.__groupValue);
1791
- if (l.textContent = a, o.appendChild(l), r.showRowCount !== !1) {
1787
+ const a = o.formatLabel ? o.formatLabel(e.__groupValue, e.__groupDepth || 0, e.__groupKey) : String(e.__groupValue);
1788
+ if (l.textContent = a, r.appendChild(l), o.showRowCount !== !1) {
1792
1789
  const c = document.createElement("span");
1793
- c.className = "group-count", c.textContent = `(${e.__groupRowCount ?? e.__groupRows?.length ?? 0})`, o.appendChild(c);
1790
+ c.className = "group-count", c.textContent = `(${e.__groupRowCount ?? e.__groupRows?.length ?? 0})`, r.appendChild(c);
1794
1791
  }
1795
- t.appendChild(o);
1792
+ t.appendChild(r);
1796
1793
  }
1797
1794
  renderPerColumnGroupRow(e, t, n) {
1798
- const r = this.config, o = r.aggregators ?? {}, s = this.columns, l = e.__groupRows ?? [];
1795
+ const o = this.config, r = o.aggregators ?? {}, s = this.columns, l = e.__groupRows ?? [];
1799
1796
  this.grid;
1800
1797
  const c = this.shadowRoot?.querySelector(".body")?.style.gridTemplateColumns || "";
1801
1798
  c && (t.style.display = "grid", t.style.gridTemplateColumns = c), s.forEach((d, u) => {
@@ -1805,20 +1802,20 @@ class kt extends y {
1805
1802
  f.type = "button", f.className = "group-toggle", f.textContent = e.__groupExpanded ? "▾" : "▸", f.addEventListener("click", (b) => {
1806
1803
  b.stopPropagation(), n();
1807
1804
  }), h.appendChild(f);
1808
- const g = document.createElement("span"), m = o[d.field];
1805
+ const g = document.createElement("span"), m = r[d.field];
1809
1806
  if (m) {
1810
1807
  const b = X(m, l, d.field, d);
1811
1808
  g.textContent = b != null ? String(b) : String(e.__groupValue);
1812
1809
  } else {
1813
- const b = r.formatLabel ? r.formatLabel(e.__groupValue, e.__groupDepth || 0, e.__groupKey) : String(e.__groupValue);
1810
+ const b = o.formatLabel ? o.formatLabel(e.__groupValue, e.__groupDepth || 0, e.__groupKey) : String(e.__groupValue);
1814
1811
  g.textContent = b;
1815
1812
  }
1816
- if (h.appendChild(g), r.showRowCount !== !1) {
1813
+ if (h.appendChild(g), o.showRowCount !== !1) {
1817
1814
  const b = document.createElement("span");
1818
1815
  b.className = "group-count", b.textContent = ` (${l.length})`, h.appendChild(b);
1819
1816
  }
1820
1817
  } else {
1821
- const f = o[d.field];
1818
+ const f = r[d.field];
1822
1819
  if (f) {
1823
1820
  const g = X(f, l, d.field, d);
1824
1821
  h.textContent = g != null ? String(g) : "";
@@ -1976,7 +1973,7 @@ class kt extends y {
1976
1973
  [data-group-depth="4"] .group-label { padding-left: 80px; }
1977
1974
  `;
1978
1975
  }
1979
- function H(i, e) {
1976
+ function O(i, e) {
1980
1977
  const t = new Set(i);
1981
1978
  return t.has(e) ? t.delete(e) : t.add(e), t;
1982
1979
  }
@@ -1992,12 +1989,12 @@ function je(i, e) {
1992
1989
  return i.has(e);
1993
1990
  }
1994
1991
  function Ue(i, e, t, n) {
1995
- const r = document.createElement("div");
1996
- r.className = "master-detail-row", r.setAttribute("data-detail-for", String(e)), r.setAttribute("role", "row");
1997
1992
  const o = document.createElement("div");
1998
- o.className = "master-detail-cell", o.setAttribute("role", "cell"), o.style.gridColumn = `1 / ${n + 1}`;
1993
+ o.className = "master-detail-row", o.setAttribute("data-detail-for", String(e)), o.setAttribute("role", "row");
1994
+ const r = document.createElement("div");
1995
+ r.className = "master-detail-cell", r.setAttribute("role", "cell"), r.style.gridColumn = `1 / ${n + 1}`;
1999
1996
  const s = t(i, e);
2000
- return typeof s == "string" ? o.innerHTML = s : s instanceof HTMLElement && o.appendChild(s), r.appendChild(o), r;
1997
+ return typeof s == "string" ? r.innerHTML = s : s instanceof HTMLElement && r.appendChild(s), o.appendChild(r), o;
2001
1998
  }
2002
1999
  class Et extends y {
2003
2000
  name = "masterDetail";
@@ -2024,34 +2021,37 @@ class Et extends y {
2024
2021
  return [...e];
2025
2022
  const t = [...e];
2026
2023
  if (t.length > 0) {
2027
- const n = { ...t[0] }, r = n.viewRenderer;
2028
- n.viewRenderer = (o) => {
2029
- const { value: s, row: l } = o, a = this.expandedRows.has(l), c = document.createElement("span");
2030
- c.className = "master-detail-cell-wrapper";
2031
- const d = document.createElement("span");
2032
- d.className = "master-detail-toggle", d.textContent = a ? "▼" : "▶", d.setAttribute("aria-expanded", String(a)), d.setAttribute("aria-label", a ? "Collapse details" : "Expand details"), d.addEventListener("click", (h) => {
2033
- h.stopPropagation();
2034
- const f = this.rows.indexOf(l);
2035
- this.expandedRows = H(this.expandedRows, l), this.emit("detail-expand", {
2036
- rowIndex: f,
2037
- row: l,
2038
- expanded: this.expandedRows.has(l)
2039
- }), this.requestRender();
2040
- }), c.appendChild(d);
2024
+ const n = { ...t[0] }, o = n.viewRenderer;
2025
+ if (o?.__masterDetailWrapped)
2026
+ return t;
2027
+ const r = (s) => {
2028
+ const { value: l, row: a } = s, c = this.expandedRows.has(a), d = document.createElement("span");
2029
+ d.className = "master-detail-cell-wrapper";
2041
2030
  const u = document.createElement("span");
2042
- if (r) {
2043
- const h = r(o);
2044
- h instanceof Node ? u.appendChild(h) : u.textContent = String(h ?? s ?? "");
2031
+ u.className = "master-detail-toggle", u.textContent = c ? "▼" : "▶", u.setAttribute("aria-expanded", String(c)), u.setAttribute("aria-label", c ? "Collapse details" : "Expand details"), u.addEventListener("click", (f) => {
2032
+ f.stopPropagation();
2033
+ const g = this.rows.indexOf(a);
2034
+ this.expandedRows = O(this.expandedRows, a), this.emit("detail-expand", {
2035
+ rowIndex: g,
2036
+ row: a,
2037
+ expanded: this.expandedRows.has(a)
2038
+ }), this.requestRender();
2039
+ }), d.appendChild(u);
2040
+ const h = document.createElement("span");
2041
+ if (o) {
2042
+ const f = o(s);
2043
+ f instanceof Node ? h.appendChild(f) : h.textContent = String(f ?? l ?? "");
2045
2044
  } else
2046
- u.textContent = String(s ?? "");
2047
- return c.appendChild(u), c;
2048
- }, t[0] = n;
2045
+ h.textContent = String(l ?? "");
2046
+ return d.appendChild(h), d;
2047
+ };
2048
+ r.__masterDetailWrapped = !0, n.viewRenderer = r, t[0] = n;
2049
2049
  }
2050
2050
  return t;
2051
2051
  }
2052
2052
  onRowClick(e) {
2053
2053
  if (!(!this.config.expandOnRowClick || !this.config.detailRenderer))
2054
- return this.expandedRows = H(this.expandedRows, e.row), this.emit("detail-expand", {
2054
+ return this.expandedRows = O(this.expandedRows, e.row), this.emit("detail-expand", {
2055
2055
  rowIndex: e.rowIndex,
2056
2056
  row: e.row,
2057
2057
  expanded: this.expandedRows.has(e.row)
@@ -2061,15 +2061,15 @@ class Et extends y {
2061
2061
  if (!this.config.detailRenderer) return;
2062
2062
  const e = this.shadowRoot?.querySelector(".rows");
2063
2063
  if (!e) return;
2064
- e.querySelectorAll(".master-detail-row").forEach((r) => r.remove()), this.detailElements.clear();
2064
+ e.querySelectorAll(".master-detail-row").forEach((o) => o.remove()), this.detailElements.clear();
2065
2065
  const t = e.querySelectorAll(".data-grid-row"), n = this.columns.length;
2066
- for (const r of t) {
2067
- const o = r.querySelector(".cell[data-row]"), s = o ? parseInt(o.getAttribute("data-row") ?? "-1", 10) : -1;
2066
+ for (const o of t) {
2067
+ const r = o.querySelector(".cell[data-row]"), s = r ? parseInt(r.getAttribute("data-row") ?? "-1", 10) : -1;
2068
2068
  if (s < 0) continue;
2069
2069
  const l = this.rows[s];
2070
2070
  if (!l || !this.expandedRows.has(l)) continue;
2071
2071
  const a = Ue(l, s, this.config.detailRenderer, n);
2072
- typeof this.config.detailHeight == "number" && (a.style.height = `${this.config.detailHeight}px`), r.appendChild(a), this.detailElements.set(l, a);
2072
+ typeof this.config.detailHeight == "number" && (a.style.height = `${this.config.detailHeight}px`), o.appendChild(a), this.detailElements.set(l, a);
2073
2073
  }
2074
2074
  }
2075
2075
  // ===== Public API =====
@@ -2095,7 +2095,7 @@ class Et extends y {
2095
2095
  */
2096
2096
  toggle(e) {
2097
2097
  const t = this.rows[e];
2098
- t && (this.expandedRows = H(this.expandedRows, t), this.requestRender());
2098
+ t && (this.expandedRows = O(this.expandedRows, t), this.requestRender());
2099
2099
  }
2100
2100
  /**
2101
2101
  * Check if the detail row at the given index is expanded.
@@ -2170,11 +2170,11 @@ class Et extends y {
2170
2170
  `;
2171
2171
  }
2172
2172
  function Ye(i, e, t) {
2173
- return e.length ? [...i].sort((n, r) => {
2174
- for (const o of e) {
2175
- const l = t.find((u) => u.field === o.field)?.sortComparator ?? Xe, a = n[o.field], c = r[o.field], d = l(a, c, n, r);
2173
+ return e.length ? [...i].sort((n, o) => {
2174
+ for (const r of e) {
2175
+ const l = t.find((u) => u.field === r.field)?.sortComparator ?? Xe, a = n[r.field], c = o[r.field], d = l(a, c, n, o);
2176
2176
  if (d !== 0)
2177
- return o.direction === "asc" ? d : -d;
2177
+ return r.direction === "asc" ? d : -d;
2178
2178
  }
2179
2179
  return 0;
2180
2180
  }) : [...i];
@@ -2183,8 +2183,8 @@ function Xe(i, e) {
2183
2183
  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));
2184
2184
  }
2185
2185
  function Je(i, e, t, n) {
2186
- const r = i.find((o) => o.field === e);
2187
- return t ? r ? r.direction === "asc" ? i.map((o) => o.field === e ? { ...o, direction: "desc" } : o) : i.filter((o) => o.field !== e) : i.length < n ? [...i, { field: e, direction: "asc" }] : i : r?.direction === "asc" ? [{ field: e, direction: "desc" }] : r?.direction === "desc" ? [] : [{ field: e, direction: "asc" }];
2186
+ const o = i.find((r) => r.field === e);
2187
+ 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" }];
2188
2188
  }
2189
2189
  function le(i, e) {
2190
2190
  const t = i.findIndex((n) => n.field === e);
@@ -2214,27 +2214,27 @@ class At extends y {
2214
2214
  return this.sortModel.length === 0 ? [...e] : Ye([...e], this.sortModel, [...this.columns]);
2215
2215
  }
2216
2216
  onHeaderClick(e) {
2217
- if (!this.columns.find((o) => o.field === e.field)?.sortable) return !1;
2218
- const n = e.originalEvent.shiftKey, r = this.config.maxSortColumns ?? 3;
2219
- return this.sortModel = Je(this.sortModel, e.field, n, r), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), !0;
2217
+ if (!this.columns.find((r) => r.field === e.field)?.sortable) return !1;
2218
+ const n = e.originalEvent.shiftKey, o = this.config.maxSortColumns ?? 3;
2219
+ return this.sortModel = Je(this.sortModel, e.field, n, o), this.emit("sort-change", { sortModel: [...this.sortModel] }), this.requestRender(), !0;
2220
2220
  }
2221
2221
  afterRender() {
2222
2222
  const e = this.shadowRoot;
2223
2223
  if (!e) return;
2224
2224
  const t = this.config.showSortIndex !== !1;
2225
- e.querySelectorAll(".header-row .cell[data-field]").forEach((r) => {
2226
- const o = r.getAttribute("data-field");
2227
- if (!o) return;
2228
- const s = le(this.sortModel, o), l = ae(this.sortModel, o);
2229
- if (r.querySelector(".sort-index")?.remove(), l) {
2230
- r.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), r.setAttribute("data-sort", l);
2225
+ e.querySelectorAll(".header-row .cell[data-field]").forEach((o) => {
2226
+ const r = o.getAttribute("data-field");
2227
+ if (!r) return;
2228
+ const s = le(this.sortModel, r), l = ae(this.sortModel, r);
2229
+ if (o.querySelector(".sort-index")?.remove(), l) {
2230
+ o.querySelector('[part~="sort-indicator"], .sort-indicator')?.remove(), o.setAttribute("data-sort", l);
2231
2231
  const d = document.createElement("span");
2232
- if (d.className = "sort-indicator", d.style.marginLeft = "4px", d.style.opacity = "0.8", d.textContent = l === "asc" ? "▲" : "▼", r.appendChild(d), t && this.sortModel.length > 1 && s !== void 0) {
2232
+ if (d.className = "sort-indicator", d.style.marginLeft = "4px", d.style.opacity = "0.8", d.textContent = l === "asc" ? "▲" : "▼", o.appendChild(d), t && this.sortModel.length > 1 && s !== void 0) {
2233
2233
  const u = document.createElement("span");
2234
- u.className = "sort-index", u.textContent = String(s), r.appendChild(u);
2234
+ u.className = "sort-index", u.textContent = String(s), o.appendChild(u);
2235
2235
  }
2236
2236
  } else
2237
- r.removeAttribute("data-sort");
2237
+ o.removeAttribute("data-sort");
2238
2238
  });
2239
2239
  }
2240
2240
  // ===== Public API =====
@@ -2279,7 +2279,7 @@ class At extends y {
2279
2279
  * Return sort state for a column if it's in the sort model.
2280
2280
  */
2281
2281
  getColumnState(e) {
2282
- const t = this.sortModel.findIndex((r) => r.field === e);
2282
+ const t = this.sortModel.findIndex((o) => o.field === e);
2283
2283
  return t === -1 ? void 0 : {
2284
2284
  sort: {
2285
2285
  direction: this.sortModel[t].direction,
@@ -2293,14 +2293,14 @@ class At extends y {
2293
2293
  */
2294
2294
  applyColumnState(e, t) {
2295
2295
  if (!t.sort) {
2296
- this.sortModel = this.sortModel.filter((o) => o.field !== e);
2296
+ this.sortModel = this.sortModel.filter((r) => r.field !== e);
2297
2297
  return;
2298
2298
  }
2299
- const n = this.sortModel.findIndex((o) => o.field === e), r = {
2299
+ const n = this.sortModel.findIndex((r) => r.field === e), o = {
2300
2300
  field: e,
2301
2301
  direction: t.sort.direction
2302
2302
  };
2303
- n !== -1 ? this.sortModel[n] = r : this.sortModel.splice(t.sort.priority, 0, r);
2303
+ n !== -1 ? this.sortModel[n] = o : this.sortModel.splice(t.sort.priority, 0, o);
2304
2304
  }
2305
2305
  // ===== Styles =====
2306
2306
  styles = `
@@ -2335,7 +2335,7 @@ function Qe(i) {
2335
2335
  function Ze(i) {
2336
2336
  return i.filter((e) => e.sticky === "right");
2337
2337
  }
2338
- function O(i) {
2338
+ function H(i) {
2339
2339
  return i.some((e) => e.sticky === "left" || e.sticky === "right");
2340
2340
  }
2341
2341
  function de(i, e) {
@@ -2343,22 +2343,22 @@ function de(i, e) {
2343
2343
  if (!t) return;
2344
2344
  const n = Array.from(t.querySelectorAll(".header-row .cell"));
2345
2345
  if (!n.length) return;
2346
- const r = /* @__PURE__ */ new Map();
2346
+ const o = /* @__PURE__ */ new Map();
2347
2347
  e.forEach((l, a) => {
2348
- l.field && r.set(l.field, a);
2348
+ l.field && o.set(l.field, a);
2349
2349
  });
2350
- let o = 0;
2350
+ let r = 0;
2351
2351
  for (const l of e)
2352
2352
  if (l.sticky === "left") {
2353
- const a = r.get(l.field), c = n.find((d) => d.getAttribute("data-field") === l.field);
2354
- c && (c.classList.add("sticky-left"), c.style.left = o + "px", a !== void 0 && t.querySelectorAll(`.data-grid-row .cell[data-col="${a}"]`).forEach((d) => {
2355
- d.classList.add("sticky-left"), d.style.left = o + "px";
2356
- }), o += c.offsetWidth);
2353
+ const a = o.get(l.field), c = n.find((d) => d.getAttribute("data-field") === l.field);
2354
+ c && (c.classList.add("sticky-left"), c.style.left = r + "px", a !== void 0 && t.querySelectorAll(`.data-grid-row .cell[data-col="${a}"]`).forEach((d) => {
2355
+ d.classList.add("sticky-left"), d.style.left = r + "px";
2356
+ }), r += c.offsetWidth);
2357
2357
  }
2358
2358
  let s = 0;
2359
2359
  for (const l of [...e].reverse())
2360
2360
  if (l.sticky === "right") {
2361
- const a = r.get(l.field), c = n.find((d) => d.getAttribute("data-field") === l.field);
2361
+ const a = o.get(l.field), c = n.find((d) => d.getAttribute("data-field") === l.field);
2362
2362
  c && (c.classList.add("sticky-right"), c.style.right = s + "px", a !== void 0 && t.querySelectorAll(`.data-grid-row .cell[data-col="${a}"]`).forEach((d) => {
2363
2363
  d.classList.add("sticky-right"), d.style.right = s + "px";
2364
2364
  }), s += c.offsetWidth);
@@ -2393,17 +2393,17 @@ class _t extends y {
2393
2393
  */
2394
2394
  static detect(e, t) {
2395
2395
  const n = t?.columns;
2396
- return Array.isArray(n) ? O(n) : !1;
2396
+ return Array.isArray(n) ? H(n) : !1;
2397
2397
  }
2398
2398
  // ===== Hooks =====
2399
2399
  processColumns(e) {
2400
- return this.config.enabled ? (this.isApplied = O([...e]), [...e]) : (this.isApplied = !1, [...e]);
2400
+ return this.config.enabled ? (this.isApplied = H([...e]), [...e]) : (this.isApplied = !1, [...e]);
2401
2401
  }
2402
2402
  afterRender() {
2403
2403
  if (!this.config.enabled || !this.isApplied)
2404
2404
  return;
2405
2405
  const e = this.grid, t = [...this.columns];
2406
- if (!O(t)) {
2406
+ if (!H(t)) {
2407
2407
  ce(e), this.isApplied = !1;
2408
2408
  return;
2409
2409
  }
@@ -2445,10 +2445,10 @@ function W(i, e) {
2445
2445
  t.className = "tbw-pinned-rows", t.setAttribute("role", "status"), t.setAttribute("aria-live", "polite");
2446
2446
  const n = document.createElement("div");
2447
2447
  n.className = "tbw-pinned-rows-left";
2448
- const r = document.createElement("div");
2449
- r.className = "tbw-pinned-rows-center";
2450
2448
  const o = document.createElement("div");
2451
- if (o.className = "tbw-pinned-rows-right", i.showRowCount !== !1) {
2449
+ o.className = "tbw-pinned-rows-center";
2450
+ const r = document.createElement("div");
2451
+ if (r.className = "tbw-pinned-rows-right", i.showRowCount !== !1) {
2452
2452
  const s = document.createElement("span");
2453
2453
  s.className = "tbw-status-panel tbw-status-panel-row-count", s.textContent = `Total: ${e.totalRows} rows`, n.appendChild(s);
2454
2454
  }
@@ -2458,7 +2458,7 @@ function W(i, e) {
2458
2458
  }
2459
2459
  if (i.showSelectedCount && e.selectedRows > 0) {
2460
2460
  const s = document.createElement("span");
2461
- s.className = "tbw-status-panel tbw-status-panel-selected-count", s.textContent = `Selected: ${e.selectedRows}`, o.appendChild(s);
2461
+ s.className = "tbw-status-panel tbw-status-panel-selected-count", s.textContent = `Selected: ${e.selectedRows}`, r.appendChild(s);
2462
2462
  }
2463
2463
  if (i.customPanels)
2464
2464
  for (const s of i.customPanels) {
@@ -2468,14 +2468,14 @@ function W(i, e) {
2468
2468
  n.appendChild(l);
2469
2469
  break;
2470
2470
  case "center":
2471
- r.appendChild(l);
2471
+ o.appendChild(l);
2472
2472
  break;
2473
2473
  case "right":
2474
- o.appendChild(l);
2474
+ r.appendChild(l);
2475
2475
  break;
2476
2476
  }
2477
2477
  }
2478
- return t.appendChild(n), t.appendChild(r), t.appendChild(o), t;
2478
+ return t.appendChild(n), t.appendChild(o), t.appendChild(r), t;
2479
2479
  }
2480
2480
  function ue(i) {
2481
2481
  const e = document.createElement("div");
@@ -2483,27 +2483,27 @@ function ue(i) {
2483
2483
  }
2484
2484
  function he(i, e, t, n) {
2485
2485
  i.innerHTML = "";
2486
- for (const r of e) {
2487
- const o = document.createElement("div");
2488
- if (o.className = "tbw-aggregation-row", o.setAttribute("role", "row"), r.id && o.setAttribute("data-aggregation-id", r.id), r.fullWidth) {
2486
+ for (const o of e) {
2487
+ const r = document.createElement("div");
2488
+ if (r.className = "tbw-aggregation-row", r.setAttribute("role", "row"), o.id && r.setAttribute("data-aggregation-id", o.id), o.fullWidth) {
2489
2489
  const s = document.createElement("div");
2490
- s.className = "tbw-aggregation-cell tbw-aggregation-cell-full", s.style.gridColumn = "1 / -1", s.textContent = r.label || "", o.appendChild(s);
2490
+ s.className = "tbw-aggregation-cell tbw-aggregation-cell-full", s.style.gridColumn = "1 / -1", s.textContent = o.label || "", r.appendChild(s);
2491
2491
  } else
2492
2492
  for (const s of t) {
2493
2493
  const l = document.createElement("div");
2494
2494
  l.className = "tbw-aggregation-cell", l.setAttribute("data-field", s.field);
2495
2495
  let a;
2496
- const c = r.aggregators?.[s.field];
2496
+ const c = o.aggregators?.[s.field];
2497
2497
  if (c) {
2498
2498
  const d = xe(c);
2499
2499
  d && (a = d(n, s.field, s));
2500
- } else if (r.cells && Object.prototype.hasOwnProperty.call(r.cells, s.field)) {
2501
- const d = r.cells[s.field];
2500
+ } else if (o.cells && Object.prototype.hasOwnProperty.call(o.cells, s.field)) {
2501
+ const d = o.cells[s.field];
2502
2502
  typeof d == "function" ? a = d(n, s.field, s) : a = d;
2503
2503
  }
2504
- l.textContent = a != null ? String(a) : "", o.appendChild(l);
2504
+ l.textContent = a != null ? String(a) : "", r.appendChild(l);
2505
2505
  }
2506
- i.appendChild(o);
2506
+ i.appendChild(r);
2507
2507
  }
2508
2508
  }
2509
2509
  function et(i, e) {
@@ -2512,10 +2512,10 @@ function et(i, e) {
2512
2512
  const n = i.render(e);
2513
2513
  return typeof n == "string" ? t.innerHTML = n : t.appendChild(n), t;
2514
2514
  }
2515
- function fe(i, e, t, n, r) {
2515
+ function fe(i, e, t, n, o) {
2516
2516
  return {
2517
2517
  totalRows: i.length,
2518
- filteredRows: r?.cachedResult?.length ?? i.length,
2518
+ filteredRows: o?.cachedResult?.length ?? i.length,
2519
2519
  selectedRows: n?.selected?.size ?? 0,
2520
2520
  columns: e,
2521
2521
  rows: i,
@@ -2553,12 +2553,12 @@ class It extends y {
2553
2553
  if (!e) return;
2554
2554
  const t = e.querySelector(".tbw-scroll-area") ?? e.querySelector(".tbw-grid-content") ?? e.children[0];
2555
2555
  if (!t) return;
2556
- const n = this.getSelectionState(), r = this.getFilterState(), o = fe(
2556
+ const n = this.getSelectionState(), o = this.getFilterState(), r = fe(
2557
2557
  this.rows,
2558
2558
  this.columns,
2559
2559
  this.grid,
2560
2560
  n,
2561
- r
2561
+ o
2562
2562
  ), s = this.config.aggregationRows || [], l = s.filter((h) => h.position === "top"), a = s.filter((h) => h.position !== "top");
2563
2563
  if (l.length > 0) {
2564
2564
  if (!this.topAggregationContainer) {
@@ -2573,12 +2573,12 @@ class It extends y {
2573
2573
  this.rows
2574
2574
  );
2575
2575
  } else this.topAggregationContainer && (this.topAggregationContainer.remove(), this.topAggregationContainer = null);
2576
- const c = this.config.showRowCount !== !1 || this.config.showSelectedCount && o.selectedRows > 0 || this.config.showFilteredCount && o.filteredRows !== o.totalRows || this.config.customPanels && this.config.customPanels.length > 0, d = c && this.config.position !== "top", u = a.length > 0 || d;
2576
+ const c = 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, d = c && this.config.position !== "top", u = a.length > 0 || d;
2577
2577
  if (c && this.config.position === "top")
2578
2578
  if (!this.infoBarElement)
2579
- this.infoBarElement = W(this.config, o), t.insertBefore(this.infoBarElement, t.firstChild);
2579
+ this.infoBarElement = W(this.config, r), t.insertBefore(this.infoBarElement, t.firstChild);
2580
2580
  else {
2581
- const h = W(this.config, o);
2581
+ const h = W(this.config, r);
2582
2582
  this.infoBarElement.replaceWith(h), this.infoBarElement = h;
2583
2583
  }
2584
2584
  else this.config.position === "top" && this.infoBarElement && (this.infoBarElement.remove(), this.infoBarElement = null);
@@ -2587,7 +2587,7 @@ class It extends y {
2587
2587
  a,
2588
2588
  this.visibleColumns,
2589
2589
  this.rows
2590
- )), d && (this.infoBarElement = W(this.config, o), this.footerWrapper.appendChild(this.infoBarElement))) : this.cleanupFooter();
2590
+ )), d && (this.infoBarElement = W(this.config, r), this.footerWrapper.appendChild(this.infoBarElement))) : this.cleanupFooter();
2591
2591
  }
2592
2592
  // ===== Private Methods =====
2593
2593
  cleanup() {
@@ -2760,36 +2760,36 @@ function nt(i) {
2760
2760
  function $(i, e) {
2761
2761
  return [...i, e].join("|");
2762
2762
  }
2763
- function rt(i, e) {
2764
- const t = e.rowGroupFields ?? [], n = e.columnGroupFields ?? [], r = e.valueFields ?? [], o = ot(i, n), s = it(i, t), l = st(s, n, o, r, 0), a = lt(l, o, r), c = Object.values(a).reduce((d, u) => d + u, 0);
2763
+ function ot(i, e) {
2764
+ const t = e.rowGroupFields ?? [], n = e.columnGroupFields ?? [], o = e.valueFields ?? [], r = rt(i, n), s = it(i, t), l = st(s, n, r, o, 0), a = lt(l, r, o), c = Object.values(a).reduce((d, u) => d + u, 0);
2765
2765
  return {
2766
2766
  rows: l,
2767
- columnKeys: o,
2767
+ columnKeys: r,
2768
2768
  totals: a,
2769
2769
  grandTotal: c
2770
2770
  };
2771
2771
  }
2772
- function ot(i, e) {
2772
+ function rt(i, e) {
2773
2773
  if (e.length === 0) return ["value"];
2774
2774
  const t = /* @__PURE__ */ new Set();
2775
2775
  for (const n of i) {
2776
- const r = e.map((o) => String(n[o] ?? "")).join("|");
2777
- t.add(r);
2776
+ const o = e.map((r) => String(n[r] ?? "")).join("|");
2777
+ t.add(o);
2778
2778
  }
2779
2779
  return [...t].sort();
2780
2780
  }
2781
2781
  function it(i, e) {
2782
2782
  const t = /* @__PURE__ */ new Map();
2783
2783
  for (const n of i) {
2784
- const r = e.map((s) => String(n[s] ?? "")).join("|");
2785
- t.has(r) || t.set(r, []);
2786
- const o = t.get(r);
2787
- o && o.push(n);
2784
+ const o = e.map((s) => String(n[s] ?? "")).join("|");
2785
+ t.has(o) || t.set(o, []);
2786
+ const r = t.get(o);
2787
+ r && r.push(n);
2788
2788
  }
2789
2789
  return t;
2790
2790
  }
2791
- function st(i, e, t, n, r) {
2792
- const o = [];
2791
+ function st(i, e, t, n, o) {
2792
+ const r = [];
2793
2793
  for (const [s, l] of i) {
2794
2794
  const a = {};
2795
2795
  let c = 0;
@@ -2798,22 +2798,22 @@ function st(i, e, t, n, r) {
2798
2798
  const f = (e.length > 0 ? l.filter((S) => e.map((R) => String(S[R] ?? "")).join("|") === d) : l).map((S) => Number(S[u.field]) || 0), g = nt(u.aggFunc), m = f.length > 0 ? g(f) : null, b = $([d], u.field);
2799
2799
  a[b] = m, m !== null && (c += m);
2800
2800
  }
2801
- o.push({
2801
+ r.push({
2802
2802
  rowKey: s,
2803
2803
  rowLabel: s || "(blank)",
2804
- depth: r,
2804
+ depth: o,
2805
2805
  values: a,
2806
2806
  total: c,
2807
2807
  isGroup: !1
2808
2808
  });
2809
2809
  }
2810
- return o;
2810
+ return r;
2811
2811
  }
2812
2812
  function lt(i, e, t) {
2813
2813
  const n = {};
2814
- for (const r of e)
2815
- for (const o of t) {
2816
- const s = $([r], o.field);
2814
+ for (const o of e)
2815
+ for (const r of t) {
2816
+ const s = $([o], r.field);
2817
2817
  n[s] = i.reduce((l, a) => l + (a.values[s] ?? 0), 0);
2818
2818
  }
2819
2819
  return n;
@@ -2822,8 +2822,8 @@ function at(i) {
2822
2822
  const e = [];
2823
2823
  function t(n) {
2824
2824
  if (e.push(n), n.children)
2825
- for (const r of n.children)
2826
- t(r);
2825
+ for (const o of n.children)
2826
+ t(o);
2827
2827
  }
2828
2828
  for (const n of i)
2829
2829
  t(n);
@@ -2853,7 +2853,7 @@ class Tt extends y {
2853
2853
  if (!this.config.enabled || !this.isActive)
2854
2854
  return [...e];
2855
2855
  const t = tt(this.config);
2856
- return t.length > 0 ? (this.warn(`Config errors: ${t.join(", ")}`), [...e]) : (this.pivotResult = rt(e, this.config), at(this.pivotResult.rows).map((n) => ({
2856
+ return t.length > 0 ? (this.warn(`Config errors: ${t.join(", ")}`), [...e]) : (this.pivotResult = ot(e, this.config), at(this.pivotResult.rows).map((n) => ({
2857
2857
  __pivotRowKey: n.rowKey,
2858
2858
  __pivotLabel: n.rowLabel,
2859
2859
  __pivotDepth: n.depth,
@@ -2872,11 +2872,11 @@ class Tt extends y {
2872
2872
  width: 200
2873
2873
  });
2874
2874
  for (const n of this.pivotResult.columnKeys)
2875
- for (const r of this.config.valueFields ?? []) {
2876
- const o = $([n], r.field);
2875
+ for (const o of this.config.valueFields ?? []) {
2876
+ const r = $([n], o.field);
2877
2877
  t.push({
2878
- field: o,
2879
- header: `${n} - ${r.header || r.field} (${r.aggFunc})`,
2878
+ field: r,
2879
+ header: `${n} - ${o.header || o.field} (${o.aggFunc})`,
2880
2880
  width: 120,
2881
2881
  type: "number"
2882
2882
  });
@@ -2958,8 +2958,8 @@ function dt(i) {
2958
2958
  }
2959
2959
  function ge(i, e, t) {
2960
2960
  if (e === t || e < 0 || e >= i.length || t < 0 || t > i.length) return i;
2961
- const n = [...i], [r] = n.splice(e, 1);
2962
- return n.splice(t, 0, r), n;
2961
+ const n = [...i], [o] = n.splice(e, 1);
2962
+ return n.splice(t, 0, o), n;
2963
2963
  }
2964
2964
  class Lt extends y {
2965
2965
  name = "reorder";
@@ -2976,19 +2976,19 @@ class Lt extends y {
2976
2976
  draggedField = null;
2977
2977
  draggedIndex = null;
2978
2978
  dropIndex = null;
2979
- boundReorderRequestHandler = null;
2980
2979
  // ===== Lifecycle =====
2981
2980
  attach(e) {
2982
- super.attach(e), this.boundReorderRequestHandler = (t) => {
2983
- const n = t.detail;
2984
- n?.field && typeof n.toIndex == "number" && this.moveColumn(n.field, n.toIndex);
2985
- }, e.addEventListener("column-reorder-request", this.boundReorderRequestHandler);
2981
+ super.attach(e), e.addEventListener(
2982
+ "column-reorder-request",
2983
+ (t) => {
2984
+ const n = t.detail;
2985
+ n?.field && typeof n.toIndex == "number" && this.moveColumn(n.field, n.toIndex);
2986
+ },
2987
+ { signal: this.disconnectSignal }
2988
+ );
2986
2989
  }
2987
2990
  detach() {
2988
- this.boundReorderRequestHandler && this.grid && (this.grid.removeEventListener(
2989
- "column-reorder-request",
2990
- this.boundReorderRequestHandler
2991
- ), this.boundReorderRequestHandler = null), this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null;
2991
+ this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null;
2992
2992
  }
2993
2993
  // ===== Hooks =====
2994
2994
  // Note: No processColumns hook needed - we directly update the grid's column order
@@ -2997,27 +2997,27 @@ class Lt extends y {
2997
2997
  const e = this.shadowRoot;
2998
2998
  if (!e) return;
2999
2999
  e.querySelectorAll(".header-row > .cell").forEach((n) => {
3000
- const r = n, o = r.getAttribute("data-field");
3001
- if (!o) return;
3002
- const s = this.columns.find((l) => l.field === o);
3000
+ const o = n, r = o.getAttribute("data-field");
3001
+ if (!r) return;
3002
+ const s = this.columns.find((l) => l.field === r);
3003
3003
  if (!s || !dt(s)) {
3004
- r.draggable = !1;
3004
+ o.draggable = !1;
3005
3005
  return;
3006
3006
  }
3007
- r.draggable = !0, !r.getAttribute("data-dragstart-bound") && (r.setAttribute("data-dragstart-bound", "true"), r.addEventListener("dragstart", (l) => {
3008
- const c = this.getColumnOrder().indexOf(o);
3009
- this.isDragging = !0, this.draggedField = o, this.draggedIndex = c, l.dataTransfer && (l.dataTransfer.effectAllowed = "move", l.dataTransfer.setData("text/plain", o)), r.classList.add("dragging");
3010
- }), r.addEventListener("dragend", () => {
3007
+ o.draggable = !0, !o.getAttribute("data-dragstart-bound") && (o.setAttribute("data-dragstart-bound", "true"), o.addEventListener("dragstart", (l) => {
3008
+ const c = this.getColumnOrder().indexOf(r);
3009
+ this.isDragging = !0, this.draggedField = r, this.draggedIndex = c, l.dataTransfer && (l.dataTransfer.effectAllowed = "move", l.dataTransfer.setData("text/plain", r)), o.classList.add("dragging");
3010
+ }), o.addEventListener("dragend", () => {
3011
3011
  this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, e.querySelectorAll(".header-row > .cell").forEach((l) => {
3012
3012
  l.classList.remove("dragging", "drop-target", "drop-before", "drop-after");
3013
3013
  });
3014
- }), r.addEventListener("dragover", (l) => {
3015
- if (l.preventDefault(), !this.isDragging || this.draggedField === o) return;
3016
- const a = r.getBoundingClientRect(), c = a.left + a.width / 2, u = this.getColumnOrder().indexOf(o);
3017
- this.dropIndex = l.clientX < c ? u : u + 1, r.classList.add("drop-target"), r.classList.toggle("drop-before", l.clientX < c), r.classList.toggle("drop-after", l.clientX >= c);
3018
- }), r.addEventListener("dragleave", () => {
3019
- r.classList.remove("drop-target", "drop-before", "drop-after");
3020
- }), r.addEventListener("drop", (l) => {
3014
+ }), o.addEventListener("dragover", (l) => {
3015
+ if (l.preventDefault(), !this.isDragging || this.draggedField === r) return;
3016
+ const a = o.getBoundingClientRect(), c = a.left + a.width / 2, u = this.getColumnOrder().indexOf(r);
3017
+ this.dropIndex = l.clientX < c ? u : u + 1, o.classList.add("drop-target"), o.classList.toggle("drop-before", l.clientX < c), o.classList.toggle("drop-after", l.clientX >= c);
3018
+ }), o.addEventListener("dragleave", () => {
3019
+ o.classList.remove("drop-target", "drop-before", "drop-after");
3020
+ }), o.addEventListener("drop", (l) => {
3021
3021
  l.preventDefault();
3022
3022
  const a = this.draggedField, c = this.draggedIndex, d = this.dropIndex;
3023
3023
  if (!this.isDragging || a === null || c === null || d === null)
@@ -3046,14 +3046,14 @@ class Lt extends y {
3046
3046
  * @param toIndex - The target index
3047
3047
  */
3048
3048
  moveColumn(e, t) {
3049
- const n = this.getColumnOrder(), r = n.indexOf(e);
3050
- if (r === -1) return;
3051
- const o = ge(n, r, t);
3052
- this.grid.setColumnOrder(o), this.emit("column-move", {
3049
+ const n = this.getColumnOrder(), o = n.indexOf(e);
3050
+ if (o === -1) return;
3051
+ const r = ge(n, o, t);
3052
+ this.grid.setColumnOrder(r), this.emit("column-move", {
3053
3053
  field: e,
3054
- fromIndex: r,
3054
+ fromIndex: o,
3055
3055
  toIndex: t,
3056
- columnOrder: o
3056
+ columnOrder: r
3057
3057
  }), this.grid.requestStateChange?.();
3058
3058
  }
3059
3059
  /**
@@ -3112,25 +3112,25 @@ function ct(i, e) {
3112
3112
  };
3113
3113
  }
3114
3114
  function ut(i, e, t) {
3115
- const n = M(i, t), r = M(e - 1, t), o = [];
3116
- for (let s = n; s <= r; s++)
3117
- o.push(s);
3118
- return o;
3115
+ const n = M(i, t), o = M(e - 1, t), r = [];
3116
+ for (let s = n; s <= o; s++)
3117
+ r.push(s);
3118
+ return r;
3119
3119
  }
3120
3120
  async function pe(i, e, t, n) {
3121
- const r = ct(e, t);
3121
+ const o = ct(e, t);
3122
3122
  return i.getRows({
3123
- startRow: r.start,
3124
- endRow: r.end,
3123
+ startRow: o.start,
3124
+ endRow: o.end,
3125
3125
  sortModel: n.sortModel,
3126
3126
  filterModel: n.filterModel
3127
3127
  });
3128
3128
  }
3129
3129
  function ht(i, e, t) {
3130
- const n = M(i, e), r = t.get(n);
3131
- if (!r) return;
3132
- const o = i % e;
3133
- return r[o];
3130
+ const n = M(i, e), o = t.get(n);
3131
+ if (!o) return;
3132
+ const r = i % e;
3133
+ return o[r];
3134
3134
  }
3135
3135
  const ft = 100;
3136
3136
  class Mt extends y {
@@ -3161,15 +3161,15 @@ class Mt extends y {
3161
3161
  */
3162
3162
  loadRequiredBlocks() {
3163
3163
  if (!this.dataSource) return;
3164
- const e = this.grid, t = this.config.cacheBlockSize ?? 100, n = { startRow: e.virtualization.start, endRow: e.virtualization.end }, r = ut(n.startRow, n.endRow, t);
3165
- for (const o of r)
3166
- if (!(this.loadedBlocks.has(o) || this.loadingBlocks.has(o))) {
3164
+ const e = this.grid, t = this.config.cacheBlockSize ?? 100, n = { startRow: e.virtualization.start, endRow: e.virtualization.end }, o = ut(n.startRow, n.endRow, t);
3165
+ for (const r of o)
3166
+ if (!(this.loadedBlocks.has(r) || this.loadingBlocks.has(r))) {
3167
3167
  if (this.loadingBlocks.size >= (this.config.maxConcurrentRequests ?? 2))
3168
3168
  break;
3169
- this.loadingBlocks.add(o), pe(this.dataSource, o, t, {}).then((s) => {
3170
- this.loadedBlocks.set(o, s.rows), this.totalRowCount = s.totalRowCount, this.loadingBlocks.delete(o), this.requestRender(), this.loadRequiredBlocks();
3169
+ this.loadingBlocks.add(r), pe(this.dataSource, r, t, {}).then((s) => {
3170
+ this.loadedBlocks.set(r, s.rows), this.totalRowCount = s.totalRowCount, this.loadingBlocks.delete(r), this.requestRender(), this.loadRequiredBlocks();
3171
3171
  }).catch(() => {
3172
- this.loadingBlocks.delete(o);
3172
+ this.loadingBlocks.delete(r);
3173
3173
  });
3174
3174
  }
3175
3175
  }
@@ -3178,8 +3178,8 @@ class Mt extends y {
3178
3178
  if (!this.dataSource) return [...e];
3179
3179
  const t = [];
3180
3180
  for (let n = 0; n < this.totalRowCount; n++) {
3181
- const r = ht(n, this.config.cacheBlockSize ?? 100, this.loadedBlocks);
3182
- t.push(r ?? { __loading: !0, __index: n });
3181
+ const o = ht(n, this.config.cacheBlockSize ?? 100, this.loadedBlocks);
3182
+ t.push(o ?? { __loading: !0, __index: n });
3183
3183
  }
3184
3184
  return t;
3185
3185
  }
@@ -3313,22 +3313,22 @@ class qt extends y {
3313
3313
  if (!this.config.enabled) return !1;
3314
3314
  const t = (e.ctrlKey || e.metaKey) && e.key === "z" && !e.shiftKey, n = (e.ctrlKey || e.metaKey) && (e.key === "y" || e.key === "z" && e.shiftKey);
3315
3315
  if (t) {
3316
- const r = me({ undoStack: this.undoStack, redoStack: this.redoStack });
3317
- if (r.action) {
3318
- const o = this.rows;
3319
- o[r.action.rowIndex] && (o[r.action.rowIndex][r.action.field] = r.action.oldValue), this.undoStack = r.newState.undoStack, this.redoStack = r.newState.redoStack, this.emit("undo", {
3320
- action: r.action,
3316
+ const o = me({ undoStack: this.undoStack, redoStack: this.redoStack });
3317
+ if (o.action) {
3318
+ const r = this.rows;
3319
+ 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", {
3320
+ action: o.action,
3321
3321
  type: "undo"
3322
3322
  }), this.requestRender();
3323
3323
  }
3324
3324
  return !0;
3325
3325
  }
3326
3326
  if (n) {
3327
- const r = be({ undoStack: this.undoStack, redoStack: this.redoStack });
3328
- if (r.action) {
3329
- const o = this.rows;
3330
- o[r.action.rowIndex] && (o[r.action.rowIndex][r.action.field] = r.action.newValue), this.undoStack = r.newState.undoStack, this.redoStack = r.newState.redoStack, this.emit("redo", {
3331
- action: r.action,
3327
+ const o = be({ undoStack: this.undoStack, redoStack: this.redoStack });
3328
+ if (o.action) {
3329
+ const r = this.rows;
3330
+ 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", {
3331
+ action: o.action,
3332
3332
  type: "redo"
3333
3333
  }), this.requestRender();
3334
3334
  }
@@ -3346,10 +3346,10 @@ class qt extends y {
3346
3346
  * @param oldValue - The value before the edit
3347
3347
  * @param newValue - The value after the edit
3348
3348
  */
3349
- recordEdit(e, t, n, r) {
3350
- const o = wt(e, t, n, r), s = gt(
3349
+ recordEdit(e, t, n, o) {
3350
+ const r = wt(e, t, n, o), s = gt(
3351
3351
  { undoStack: this.undoStack, redoStack: this.redoStack },
3352
- o,
3352
+ r,
3353
3353
  this.config.maxHistorySize ?? 100
3354
3354
  );
3355
3355
  this.undoStack = s.undoStack, this.redoStack = s.redoStack;
@@ -3559,12 +3559,12 @@ class _ extends y {
3559
3559
  renderPanelContent(e) {
3560
3560
  const t = this.grid, n = document.createElement("div");
3561
3561
  n.className = "tbw-visibility-content";
3562
- const r = document.createElement("div");
3563
- r.className = "tbw-visibility-list", n.appendChild(r);
3564
- const o = document.createElement("button");
3565
- return o.className = "tbw-visibility-show-all", o.textContent = "Show All", o.addEventListener("click", () => {
3566
- t.showAllColumns(), this.rebuildToggles(r);
3567
- }), n.appendChild(o), this.columnListElement = r, this.rebuildToggles(r), e.appendChild(n), () => {
3562
+ const o = document.createElement("div");
3563
+ o.className = "tbw-visibility-list", n.appendChild(o);
3564
+ const r = document.createElement("button");
3565
+ return r.className = "tbw-visibility-show-all", r.textContent = "Show All", r.addEventListener("click", () => {
3566
+ t.showAllColumns(), this.rebuildToggles(o);
3567
+ }), n.appendChild(r), this.columnListElement = o, this.rebuildToggles(o), e.appendChild(n), () => {
3568
3568
  this.columnListElement = null, n.remove();
3569
3569
  };
3570
3570
  }
@@ -3582,10 +3582,10 @@ class _ extends y {
3582
3582
  rebuildToggles(e) {
3583
3583
  const t = this.grid, n = this.hasReorderPlugin();
3584
3584
  e.innerHTML = "";
3585
- const r = t.getAllColumns();
3586
- for (let o = 0; o < r.length; o++) {
3587
- const s = r[o], l = s.header || s.field, a = document.createElement("div");
3588
- a.className = s.lockVisible ? "tbw-visibility-row locked" : "tbw-visibility-row", a.setAttribute("data-field", s.field), a.setAttribute("data-index", String(o)), n && we(s) && (a.draggable = !0, a.classList.add("reorderable"), this.setupDragListeners(a, s.field, o, e));
3585
+ const o = t.getAllColumns();
3586
+ for (let r = 0; r < o.length; r++) {
3587
+ const s = o[r], l = s.header || s.field, a = document.createElement("div");
3588
+ 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));
3589
3589
  const c = document.createElement("label");
3590
3590
  c.className = "tbw-visibility-label";
3591
3591
  const d = document.createElement("input");
@@ -3604,23 +3604,23 @@ class _ extends y {
3604
3604
  * Set up drag-and-drop event listeners for a row.
3605
3605
  * On drop, emits a 'column-reorder-request' event for other plugins to handle.
3606
3606
  */
3607
- setupDragListeners(e, t, n, r) {
3608
- e.addEventListener("dragstart", (o) => {
3609
- this.isDragging = !0, this.draggedField = t, this.draggedIndex = n, o.dataTransfer && (o.dataTransfer.effectAllowed = "move", o.dataTransfer.setData("text/plain", t)), e.classList.add("dragging");
3607
+ setupDragListeners(e, t, n, o) {
3608
+ e.addEventListener("dragstart", (r) => {
3609
+ 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");
3610
3610
  }), e.addEventListener("dragend", () => {
3611
- this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, r.querySelectorAll(".tbw-visibility-row").forEach((o) => {
3612
- o.classList.remove("dragging", "drop-target", "drop-before", "drop-after");
3611
+ this.isDragging = !1, this.draggedField = null, this.draggedIndex = null, this.dropIndex = null, o.querySelectorAll(".tbw-visibility-row").forEach((r) => {
3612
+ r.classList.remove("dragging", "drop-target", "drop-before", "drop-after");
3613
3613
  });
3614
- }), e.addEventListener("dragover", (o) => {
3615
- if (o.preventDefault(), !this.isDragging || this.draggedField === t) return;
3614
+ }), e.addEventListener("dragover", (r) => {
3615
+ if (r.preventDefault(), !this.isDragging || this.draggedField === t) return;
3616
3616
  const s = e.getBoundingClientRect(), l = s.top + s.height / 2;
3617
- this.dropIndex = o.clientY < l ? n : n + 1, r.querySelectorAll(".tbw-visibility-row").forEach((a) => {
3617
+ this.dropIndex = r.clientY < l ? n : n + 1, o.querySelectorAll(".tbw-visibility-row").forEach((a) => {
3618
3618
  a !== e && a.classList.remove("drop-target", "drop-before", "drop-after");
3619
- }), e.classList.add("drop-target"), e.classList.toggle("drop-before", o.clientY < l), e.classList.toggle("drop-after", o.clientY >= l);
3619
+ }), e.classList.add("drop-target"), e.classList.toggle("drop-before", r.clientY < l), e.classList.toggle("drop-after", r.clientY >= l);
3620
3620
  }), e.addEventListener("dragleave", () => {
3621
3621
  e.classList.remove("drop-target", "drop-before", "drop-after");
3622
- }), e.addEventListener("drop", (o) => {
3623
- o.preventDefault();
3622
+ }), e.addEventListener("drop", (r) => {
3623
+ r.preventDefault();
3624
3624
  const s = this.draggedField, l = this.draggedIndex, a = this.dropIndex;
3625
3625
  if (!this.isDragging || s === null || l === null || a === null)
3626
3626
  return;
@@ -3632,7 +3632,7 @@ class _ extends y {
3632
3632
  toIndex: c
3633
3633
  };
3634
3634
  this.emit("column-reorder-request", d), setTimeout(() => {
3635
- this.rebuildToggles(r);
3635
+ this.rebuildToggles(o);
3636
3636
  }, 0);
3637
3637
  }
3638
3638
  });
@@ -3742,8 +3742,8 @@ export {
3742
3742
  St as ExportPlugin,
3743
3743
  E as FilteringPlugin,
3744
3744
  Bt as FitModeEnum,
3745
- Ht as GridCSSVars,
3746
- Ot as GridClasses,
3745
+ Ot as GridCSSVars,
3746
+ Ht as GridClasses,
3747
3747
  Wt as GridDataAttrs,
3748
3748
  Kt as GridElement,
3749
3749
  Vt as GridSelectors,