@toolbox-web/grid 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +43 -0
  2. package/all.d.ts +1680 -129
  3. package/all.js +440 -340
  4. package/all.js.map +1 -1
  5. package/custom-elements.json +1852 -0
  6. package/index.d.ts +133 -1
  7. package/index.js +726 -637
  8. package/index.js.map +1 -1
  9. package/lib/plugins/clipboard/index.js +62 -24
  10. package/lib/plugins/clipboard/index.js.map +1 -1
  11. package/lib/plugins/column-virtualization/index.js +82 -44
  12. package/lib/plugins/column-virtualization/index.js.map +1 -1
  13. package/lib/plugins/context-menu/index.js +141 -93
  14. package/lib/plugins/context-menu/index.js.map +1 -1
  15. package/lib/plugins/export/index.js +47 -9
  16. package/lib/plugins/export/index.js.map +1 -1
  17. package/lib/plugins/filtering/index.js +89 -51
  18. package/lib/plugins/filtering/index.js.map +1 -1
  19. package/lib/plugins/grouping-columns/index.js +71 -33
  20. package/lib/plugins/grouping-columns/index.js.map +1 -1
  21. package/lib/plugins/grouping-rows/index.js +91 -55
  22. package/lib/plugins/grouping-rows/index.js.map +1 -1
  23. package/lib/plugins/master-detail/index.js +176 -54
  24. package/lib/plugins/master-detail/index.js.map +1 -1
  25. package/lib/plugins/multi-sort/index.js +83 -45
  26. package/lib/plugins/multi-sort/index.js.map +1 -1
  27. package/lib/plugins/pinned-columns/index.js +54 -16
  28. package/lib/plugins/pinned-columns/index.js.map +1 -1
  29. package/lib/plugins/pinned-rows/index.js +45 -7
  30. package/lib/plugins/pinned-rows/index.js.map +1 -1
  31. package/lib/plugins/pivot/index.js +97 -59
  32. package/lib/plugins/pivot/index.js.map +1 -1
  33. package/lib/plugins/reorder/index.js +71 -33
  34. package/lib/plugins/reorder/index.js.map +1 -1
  35. package/lib/plugins/selection/index.js +132 -94
  36. package/lib/plugins/selection/index.js.map +1 -1
  37. package/lib/plugins/server-side/index.js +76 -38
  38. package/lib/plugins/server-side/index.js.map +1 -1
  39. package/lib/plugins/tree/index.js +76 -38
  40. package/lib/plugins/tree/index.js.map +1 -1
  41. package/lib/plugins/undo-redo/index.js +50 -12
  42. package/lib/plugins/undo-redo/index.js.map +1 -1
  43. package/lib/plugins/visibility/index.js +62 -24
  44. package/lib/plugins/visibility/index.js.map +1 -1
  45. package/package.json +1 -1
  46. package/umd/grid.all.umd.js +31 -31
  47. package/umd/grid.all.umd.js.map +1 -1
  48. package/umd/grid.umd.js +14 -14
  49. package/umd/grid.umd.js.map +1 -1
  50. package/umd/plugins/context-menu.umd.js +2 -2
  51. package/umd/plugins/context-menu.umd.js.map +1 -1
  52. package/umd/plugins/grouping-rows.umd.js +2 -2
  53. package/umd/plugins/grouping-rows.umd.js.map +1 -1
  54. package/umd/plugins/master-detail.umd.js +2 -2
  55. package/umd/plugins/master-detail.umd.js.map +1 -1
  56. package/umd/plugins/multi-sort.umd.js +1 -1
  57. package/umd/plugins/multi-sort.umd.js.map +1 -1
  58. package/umd/plugins/tree.umd.js +2 -2
  59. package/umd/plugins/tree.umd.js.map +1 -1
  60. package/umd/plugins/visibility.umd.js +1 -1
  61. package/umd/plugins/visibility.umd.js.map +1 -1
package/index.js CHANGED
@@ -10,51 +10,51 @@ function ae(o, e) {
10
10
  const t = o._columns, n = be(o);
11
11
  return {
12
12
  columns: t.map((i, s) => {
13
- const l = {
13
+ const r = {
14
14
  field: i.field,
15
15
  order: s,
16
16
  visible: !0
17
17
  // If it's in _columns, it's visible (hidden columns are filtered out)
18
- }, r = i;
19
- r.__renderedWidth !== void 0 ? l.width = r.__renderedWidth : i.width !== void 0 && (l.width = typeof i.width == "string" ? parseFloat(i.width) : i.width);
20
- const a = n.get(i.field);
21
- a && (l.sort = a);
18
+ }, a = i;
19
+ a.__renderedWidth !== void 0 ? r.width = a.__renderedWidth : i.width !== void 0 && (r.width = typeof i.width == "string" ? parseFloat(i.width) : i.width);
20
+ const l = n.get(i.field);
21
+ l && (r.sort = l);
22
22
  for (const f of e)
23
23
  if (f.getColumnState) {
24
24
  const p = f.getColumnState(i.field);
25
- p && Object.assign(l, p);
25
+ p && Object.assign(r, p);
26
26
  }
27
- return l;
27
+ return r;
28
28
  })
29
29
  };
30
30
  }
31
- function ge(o, e, t, n) {
31
+ function me(o, e, t, n) {
32
32
  if (!e.columns || e.columns.length === 0) return;
33
- const i = new Map(e.columns.map((r) => [r.field, r])), s = t.map((r) => {
34
- const a = i.get(r.field);
35
- if (!a) return r;
36
- const f = { ...r };
37
- return a.width !== void 0 && (f.width = a.width, f.__renderedWidth = a.width), a.visible !== void 0 && (f.hidden = !a.visible), f;
33
+ const i = new Map(e.columns.map((a) => [a.field, a])), s = t.map((a) => {
34
+ const l = i.get(a.field);
35
+ if (!l) return a;
36
+ const f = { ...a };
37
+ return l.width !== void 0 && (f.width = l.width, f.__renderedWidth = l.width), l.visible !== void 0 && (f.hidden = !l.visible), f;
38
38
  });
39
- s.sort((r, a) => {
40
- const f = i.get(r.field)?.order ?? 1 / 0, p = i.get(a.field)?.order ?? 1 / 0;
39
+ s.sort((a, l) => {
40
+ const f = i.get(a.field)?.order ?? 1 / 0, p = i.get(l.field)?.order ?? 1 / 0;
41
41
  return f - p;
42
42
  }), o._columns = s;
43
- const l = e.columns.filter((r) => r.sort !== void 0).sort((r, a) => (r.sort?.priority ?? 0) - (a.sort?.priority ?? 0));
44
- if (l.length > 0) {
45
- const r = l[0];
46
- r.sort && (o.sortState = {
47
- field: r.field,
48
- direction: r.sort.direction === "asc" ? 1 : -1
43
+ const r = e.columns.filter((a) => a.sort !== void 0).sort((a, l) => (a.sort?.priority ?? 0) - (l.sort?.priority ?? 0));
44
+ if (r.length > 0) {
45
+ const a = r[0];
46
+ a.sort && (o.sortState = {
47
+ field: a.field,
48
+ direction: a.sort.direction === "asc" ? 1 : -1
49
49
  });
50
50
  } else
51
51
  o.sortState = null;
52
- for (const r of n)
53
- if (r.applyColumnState)
54
- for (const a of e.columns)
55
- r.applyColumnState(a.field, a);
52
+ for (const a of n)
53
+ if (a.applyColumnState)
54
+ for (const l of e.columns)
55
+ a.applyColumnState(l.field, l);
56
56
  }
57
- function me(o, e, t) {
57
+ function ve(o, e, t) {
58
58
  let n = null;
59
59
  return () => {
60
60
  n !== null && clearTimeout(n), n = setTimeout(() => {
@@ -67,26 +67,34 @@ function me(o, e, t) {
67
67
  const M = {
68
68
  STRETCH: "stretch",
69
69
  FIXED: "fixed"
70
+ }, ce = {
71
+ expand: "▶",
72
+ collapse: "▼",
73
+ sortAsc: "▲",
74
+ sortDesc: "▼",
75
+ sortNone: "⇅",
76
+ submenuArrow: "▶",
77
+ dragHandle: "⋮⋮"
70
78
  };
71
- function ve(o) {
79
+ function Ce(o) {
72
80
  return o == null ? "string" : typeof o == "number" ? "number" : typeof o == "boolean" ? "boolean" : o instanceof Date || typeof o == "string" && /\d{4}-\d{2}-\d{2}/.test(o) && !isNaN(Date.parse(o)) ? "date" : "string";
73
81
  }
74
- function ce(o, e) {
82
+ function de(o, e) {
75
83
  if (e && e.length) {
76
84
  const s = {};
77
- return e.forEach((l) => {
78
- l.type && (s[l.field] = l.type);
85
+ return e.forEach((r) => {
86
+ r.type && (s[r.field] = r.type);
79
87
  }), { columns: e, typeMap: s };
80
88
  }
81
89
  const t = o[0] || {}, n = Object.keys(t).map((s) => {
82
- const l = t[s], r = ve(l);
83
- return { field: s, header: s.charAt(0).toUpperCase() + s.slice(1), type: r };
90
+ const r = t[s], a = Ce(r);
91
+ return { field: s, header: s.charAt(0).toUpperCase() + s.slice(1), type: a };
84
92
  }), i = {};
85
93
  return n.forEach((s) => {
86
94
  i[s.field] = s.type || "string";
87
95
  }), { columns: n, typeMap: i };
88
96
  }
89
- const Ce = /{{\s*([^}]+)\s*}}/g, A = "__DG_EMPTY__", ye = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, Ee = /__(proto|defineGetter|defineSetter)|constructor|window|globalThis|global|process|Function|import|eval|Reflect|Proxy|Error|arguments|document|location|cookie|localStorage|sessionStorage|indexedDB|fetch|XMLHttpRequest|WebSocket|Worker|SharedWorker|ServiceWorker|opener|parent|top|frames|self|this\b/, Re = /* @__PURE__ */ new Set([
97
+ const Ee = /{{\s*([^}]+)\s*}}/g, A = "__DG_EMPTY__", ye = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, Re = /__(proto|defineGetter|defineSetter)|constructor|window|globalThis|global|process|Function|import|eval|Reflect|Proxy|Error|arguments|document|location|cookie|localStorage|sessionStorage|indexedDB|fetch|XMLHttpRequest|WebSocket|Worker|SharedWorker|ServiceWorker|opener|parent|top|frames|self|this\b/, _e = /* @__PURE__ */ new Set([
90
98
  "script",
91
99
  "iframe",
92
100
  "object",
@@ -111,63 +119,63 @@ const Ce = /{{\s*([^}]+)\s*}}/g, A = "__DG_EMPTY__", ye = /^[\w$. '?+\-*/%:()!<>
111
119
  "plaintext",
112
120
  "xmp",
113
121
  "listing"
114
- ]), U = /^on\w+$/i, _e = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "srcdoc", "xlink:href", "poster", "srcset"]), Ae = /^\s*(javascript|vbscript|data|blob):/i;
122
+ ]), U = /^on\w+$/i, Ae = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "srcdoc", "xlink:href", "poster", "srcset"]), Se = /^\s*(javascript|vbscript|data|blob):/i;
115
123
  function z(o) {
116
124
  if (!o || typeof o != "string") return "";
117
125
  if (o.indexOf("<") === -1) return o;
118
126
  const e = document.createElement("template");
119
- return e.innerHTML = o, Se(e.content), e.innerHTML;
127
+ return e.innerHTML = o, xe(e.content), e.innerHTML;
120
128
  }
121
- function Se(o) {
129
+ function xe(o) {
122
130
  const e = [], t = o.querySelectorAll("*");
123
131
  for (const n of t) {
124
132
  const i = n.tagName.toLowerCase();
125
- if (Re.has(i)) {
133
+ if (_e.has(i)) {
126
134
  e.push(n);
127
135
  continue;
128
136
  }
129
137
  if ((i === "svg" || n.namespaceURI === "http://www.w3.org/2000/svg") && Array.from(n.attributes).some(
130
- (r) => U.test(r.name) || r.name === "href" || r.name === "xlink:href"
138
+ (a) => U.test(a.name) || a.name === "href" || a.name === "xlink:href"
131
139
  )) {
132
140
  e.push(n);
133
141
  continue;
134
142
  }
135
143
  const s = [];
136
- for (const l of n.attributes) {
137
- const r = l.name.toLowerCase();
138
- if (U.test(r)) {
139
- s.push(l.name);
144
+ for (const r of n.attributes) {
145
+ const a = r.name.toLowerCase();
146
+ if (U.test(a)) {
147
+ s.push(r.name);
140
148
  continue;
141
149
  }
142
- if (_e.has(r) && Ae.test(l.value)) {
143
- s.push(l.name);
150
+ if (Ae.has(a) && Se.test(r.value)) {
151
+ s.push(r.name);
144
152
  continue;
145
153
  }
146
- if (r === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(l.value)) {
147
- s.push(l.name);
154
+ if (a === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(r.value)) {
155
+ s.push(r.name);
148
156
  continue;
149
157
  }
150
158
  }
151
- s.forEach((l) => n.removeAttribute(l));
159
+ s.forEach((r) => n.removeAttribute(r));
152
160
  }
153
161
  e.forEach((n) => n.remove());
154
162
  }
155
- function de(o, e) {
163
+ function he(o, e) {
156
164
  if (!o || o.indexOf("{{") === -1) return o;
157
- const t = [], n = o.replace(Ce, (r, a) => {
158
- const f = xe(a, e);
159
- return t.push({ expr: a.trim(), result: f }), f;
160
- }), i = Te(n), s = t.length && t.every((r) => r.result === "" || r.result === A);
165
+ const t = [], n = o.replace(Ee, (a, l) => {
166
+ const f = Te(l, e);
167
+ return t.push({ expr: l.trim(), result: f }), f;
168
+ }), i = Le(n), s = t.length && t.every((a) => a.result === "" || a.result === A);
161
169
  return /Reflect\.|\bProxy\b|ownKeys\(/.test(o) || s ? "" : i;
162
170
  }
163
- function xe(o, e) {
171
+ function Te(o, e) {
164
172
  if (o = (o || "").trim(), !o || /\b(Reflect|Proxy|ownKeys)\b/.test(o)) return A;
165
173
  if (o === "value") return e.value == null ? A : String(e.value);
166
174
  if (o.startsWith("row.") && !/[()?]/.test(o) && !o.includes(":")) {
167
175
  const n = o.slice(4), i = e.row ? e.row[n] : void 0;
168
176
  return i == null ? A : String(i);
169
177
  }
170
- if (o.length > 80 || !ye.test(o) || Ee.test(o)) return A;
178
+ if (o.length > 80 || !ye.test(o) || Re.test(o)) return A;
171
179
  const t = o.match(/\./g);
172
180
  if (t && t.length > 1) return A;
173
181
  try {
@@ -177,10 +185,10 @@ function xe(o, e) {
177
185
  return A;
178
186
  }
179
187
  }
180
- function Te(o) {
188
+ function Le(o) {
181
189
  return o && o.replace(new RegExp(A, "g"), "").replace(/Reflect\.[^<>{}\s]+/g, "").replace(/\bProxy\b/g, "").replace(/ownKeys\([^)]*\)/g, "");
182
190
  }
183
- function Le(o) {
191
+ function ke(o) {
184
192
  if (/Reflect|Proxy|ownKeys/.test(o.textContent || "")) {
185
193
  if (Array.from(o.childNodes).forEach((e) => {
186
194
  e.nodeType === Node.TEXT_NODE && /Reflect|Proxy|ownKeys/.test(e.textContent || "") && (e.textContent = "");
@@ -193,25 +201,25 @@ function Le(o) {
193
201
  }
194
202
  }
195
203
  function X(o) {
196
- const e = /Reflect\.|\bProxy\b|ownKeys\(/.test(o), t = (n) => e ? "" : de(o, n);
204
+ const e = /Reflect\.|\bProxy\b|ownKeys\(/.test(o), t = (n) => e ? "" : he(o, n);
197
205
  return t.__blocked = e, t;
198
206
  }
199
- function ke(o) {
207
+ function Pe(o) {
200
208
  return Array.from(o.querySelectorAll("tbw-grid-column")).map((t) => {
201
209
  const n = t.getAttribute("field") || "";
202
210
  if (!n) return null;
203
- const i = t.getAttribute("type") || void 0, l = i && (/* @__PURE__ */ new Set(["number", "string", "date", "boolean", "select", "typeahead"])).has(i) ? i : void 0, r = t.getAttribute("header") || void 0, a = t.hasAttribute("sortable"), f = t.hasAttribute("editable"), p = { field: n, type: l, header: r, sortable: a, editable: f };
211
+ const i = t.getAttribute("type") || void 0, r = i && (/* @__PURE__ */ new Set(["number", "string", "date", "boolean", "select", "typeahead"])).has(i) ? i : void 0, a = t.getAttribute("header") || void 0, l = t.hasAttribute("sortable"), f = t.hasAttribute("editable"), p = { field: n, type: r, header: a, sortable: l, editable: f };
204
212
  t.hasAttribute("resizable") && (p.resizable = !0), t.hasAttribute("sizable") && (p.resizable = !0);
205
- const w = t.getAttribute("options");
206
- w && (p.options = w.split(",").map((d) => {
207
- const [g, m] = d.includes(":") ? d.split(":") : [d.trim(), d.trim()];
208
- return { value: g.trim(), label: m?.trim() || g.trim() };
213
+ const g = t.getAttribute("options");
214
+ g && (p.options = g.split(",").map((d) => {
215
+ const [b, m] = d.includes(":") ? d.split(":") : [d.trim(), d.trim()];
216
+ return { value: b.trim(), label: m?.trim() || b.trim() };
209
217
  }));
210
- const u = t.querySelector("tbw-grid-column-view"), c = t.querySelector("tbw-grid-column-editor"), h = t.querySelector("tbw-grid-column-header");
211
- return u && (p.__viewTemplate = u), c && (p.__editorTemplate = c), h && (p.__headerTemplate = h), p;
218
+ const h = t.querySelector("tbw-grid-column-view"), c = t.querySelector("tbw-grid-column-editor"), u = t.querySelector("tbw-grid-column-header");
219
+ return h && (p.__viewTemplate = h), c && (p.__editorTemplate = c), u && (p.__headerTemplate = u), p;
212
220
  }).filter((t) => !!t);
213
221
  }
214
- function Pe(o, e) {
222
+ function Me(o, e) {
215
223
  if ((!o || !o.length) && (!e || !e.length)) return [];
216
224
  if (!o || !o.length) return e || [];
217
225
  if (!e || !e.length) return o;
@@ -220,8 +228,8 @@ function Pe(o, e) {
220
228
  const n = o.map((i) => {
221
229
  const s = t[i.field];
222
230
  if (!s) return i;
223
- const l = { ...i };
224
- return s.header && !l.header && (l.header = s.header), s.type && !l.type && (l.type = s.type), l.sortable = i.sortable || s.sortable, (i.resizable === !0 || s.resizable === !0) && (l.resizable = !0), l.editable = i.editable || s.editable, s.__viewTemplate && (l.__viewTemplate = s.__viewTemplate), s.__editorTemplate && (l.__editorTemplate = s.__editorTemplate), s.__headerTemplate && (l.__headerTemplate = s.__headerTemplate), delete t[i.field], l;
231
+ const r = { ...i };
232
+ return s.header && !r.header && (r.header = s.header), s.type && !r.type && (r.type = s.type), r.sortable = i.sortable || s.sortable, (i.resizable === !0 || s.resizable === !0) && (r.resizable = !0), r.editable = i.editable || s.editable, s.__viewTemplate && (r.__viewTemplate = s.__viewTemplate), s.__editorTemplate && (r.__editorTemplate = s.__editorTemplate), s.__headerTemplate && (r.__headerTemplate = s.__headerTemplate), delete t[i.field], r;
225
233
  });
226
234
  return Object.keys(t).forEach((i) => n.push(t[i])), n;
227
235
  }
@@ -233,15 +241,15 @@ function B(o, e) {
233
241
  const t = o.getAttribute("part");
234
242
  t ? t.split(/\s+/).includes(e) || o.setAttribute("part", t + " " + e) : o.setAttribute("part", e);
235
243
  }
236
- function Me(o) {
244
+ function He(o) {
237
245
  o.__lightDomColumnsCache || (o.__originalColumnNodes = Array.from(
238
246
  o.querySelectorAll("tbw-grid-column")
239
- ), o.__lightDomColumnsCache = o.__originalColumnNodes.length ? ke(o) : []);
240
- const e = o.__lightDomColumnsCache, t = Pe(o._columns, e);
247
+ ), o.__lightDomColumnsCache = o.__originalColumnNodes.length ? Pe(o) : []);
248
+ const e = o.__lightDomColumnsCache, t = Me(o._columns, e);
241
249
  t.forEach((i) => {
242
250
  i.__viewTemplate && !i.__compiledView && (i.__compiledView = X(i.__viewTemplate.innerHTML)), i.__editorTemplate && !i.__compiledEditor && (i.__compiledEditor = X(i.__editorTemplate.innerHTML));
243
251
  });
244
- const { columns: n } = ce(o._rows, t);
252
+ const { columns: n } = de(o._rows, t);
245
253
  o._columns = n;
246
254
  }
247
255
  function Oe(o) {
@@ -252,19 +260,19 @@ function Oe(o) {
252
260
  let n = !1;
253
261
  o.visibleColumns.forEach((i, s) => {
254
262
  if (i.width) return;
255
- const l = t[s];
256
- let r = l ? l.scrollWidth : 0;
257
- for (const a of o.rowPool) {
258
- const f = a.children[s];
263
+ const r = t[s];
264
+ let a = r ? r.scrollWidth : 0;
265
+ for (const l of o.rowPool) {
266
+ const f = l.children[s];
259
267
  if (f) {
260
268
  const p = f.scrollWidth;
261
- p > r && (r = p);
269
+ p > a && (a = p);
262
270
  }
263
271
  }
264
- r > 0 && (i.width = r + 2, i.__autoSized = !0, n = !0);
265
- }), n && he(o), o.__didInitialAutoSize = !0;
272
+ a > 0 && (i.width = a + 2, i.__autoSized = !0, n = !0);
273
+ }), n && ue(o), o.__didInitialAutoSize = !0;
266
274
  }
267
- function he(o) {
275
+ function ue(o) {
268
276
  (o.effectiveConfig?.fitMode || o.fitMode || M.STRETCH) === M.STRETCH ? o.gridTemplate = o.visibleColumns.map((t) => {
269
277
  if (t.width) return `${t.width}px`;
270
278
  const n = t.minWidth;
@@ -297,14 +305,14 @@ function De(o) {
297
305
  return (e) => {
298
306
  const t = document.createElement("select");
299
307
  e.column.multi && (t.multiple = !0), (typeof e.column.options == "function" ? e.column.options() : e.column.options || []).forEach((s) => {
300
- const l = document.createElement("option");
301
- l.value = String(s.value), l.textContent = s.label, (e.column.multi && Array.isArray(e.value) && e.value.includes(s.value) || !e.column.multi && e.value === s.value) && (l.selected = !0), t.appendChild(l);
308
+ const r = document.createElement("option");
309
+ r.value = String(s.value), r.textContent = s.label, (e.column.multi && Array.isArray(e.value) && e.value.includes(s.value) || !e.column.multi && e.value === s.value) && (r.selected = !0), t.appendChild(r);
302
310
  });
303
311
  const i = () => {
304
312
  if (e.column.multi) {
305
313
  const s = [];
306
- Array.from(t.selectedOptions).forEach((l) => {
307
- s.push(l.value);
314
+ Array.from(t.selectedOptions).forEach((r) => {
315
+ s.push(r.value);
308
316
  }), e.commit(s);
309
317
  } else
310
318
  e.commit(t.value);
@@ -322,18 +330,18 @@ function De(o) {
322
330
  };
323
331
  }
324
332
  }
325
- function He(o, e) {
333
+ function ze(o, e) {
326
334
  if (o.dispatchKeyDown?.(e))
327
335
  return;
328
- const t = o._rows.length - 1, n = o.visibleColumns.length - 1, i = o.activeEditRows !== void 0 && o.activeEditRows !== -1, l = o.visibleColumns[o.focusCol]?.type, r = e.composedPath ? e.composedPath() : [], a = r && r.length ? r[0] : e.target, f = (p) => {
336
+ const t = o._rows.length - 1, n = o.visibleColumns.length - 1, i = o.activeEditRows !== void 0 && o.activeEditRows !== -1, r = o.visibleColumns[o.focusCol]?.type, a = e.composedPath ? e.composedPath() : [], l = a && a.length ? a[0] : e.target, f = (p) => {
329
337
  if (!p) return !1;
330
- const w = p.tagName;
331
- return !!(w === "INPUT" || w === "SELECT" || w === "TEXTAREA" || p.isContentEditable);
338
+ const g = p.tagName;
339
+ return !!(g === "INPUT" || g === "SELECT" || g === "TEXTAREA" || p.isContentEditable);
332
340
  };
333
- if (!(f(a) && (e.key === "Home" || e.key === "End")) && !(f(a) && (e.key === "ArrowUp" || e.key === "ArrowDown") && a.tagName === "INPUT" && a.type === "number") && !(i && (l === "select" || l === "typeahead") && (e.key === "ArrowDown" || e.key === "ArrowUp"))) {
341
+ if (!(f(l) && (e.key === "Home" || e.key === "End")) && !(f(l) && (e.key === "ArrowUp" || e.key === "ArrowDown") && l.tagName === "INPUT" && l.type === "number") && !(i && (r === "select" || r === "typeahead") && (e.key === "ArrowDown" || e.key === "ArrowUp"))) {
334
342
  switch (e.key) {
335
343
  case "Tab": {
336
- e.preventDefault(), !e.shiftKey ? o.focusCol < n ? o.focusCol += 1 : (typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow < t && (o.focusRow += 1, o.focusCol = 0)) : o.focusCol > 0 ? o.focusCol -= 1 : o.focusRow > 0 && (typeof o.commitActiveRowEdit == "function" && o.activeEditRows === o.focusRow && o.commitActiveRowEdit(), o.focusRow -= 1, o.focusCol = n), O(o);
344
+ e.preventDefault(), !e.shiftKey ? o.focusCol < n ? o.focusCol += 1 : (typeof o.commitActiveRowEdit == "function" && o.commitActiveRowEdit(), o.focusRow < t && (o.focusRow += 1, o.focusCol = 0)) : o.focusCol > 0 ? o.focusCol -= 1 : o.focusRow > 0 && (typeof o.commitActiveRowEdit == "function" && o.activeEditRows === o.focusRow && o.commitActiveRowEdit(), o.focusRow -= 1, o.focusCol = n), H(o);
337
345
  return;
338
346
  }
339
347
  case "ArrowDown":
@@ -363,17 +371,17 @@ function He(o, e) {
363
371
  case "Enter":
364
372
  return typeof o.beginBulkEdit == "function" ? o.beginBulkEdit(o.focusRow) : o.dispatchEvent(
365
373
  new CustomEvent("activate-cell", { detail: { row: o.focusRow, col: o.focusCol } })
366
- ), O(o);
374
+ ), H(o);
367
375
  default:
368
376
  return;
369
377
  }
370
- O(o);
378
+ H(o);
371
379
  }
372
380
  }
373
- function O(o) {
381
+ function H(o) {
374
382
  if (o.virtualization?.enabled) {
375
- const { rowHeight: i } = o.virtualization, s = o, l = o.focusRow * i;
376
- l < s.scrollTop ? s.scrollTop = l : l + i > s.scrollTop + s.clientHeight && (s.scrollTop = l - s.clientHeight + i);
383
+ const { rowHeight: i } = o.virtualization, s = o, r = o.focusRow * i;
384
+ r < s.scrollTop ? s.scrollTop = r : r + i > s.scrollTop + s.clientHeight && (s.scrollTop = r - s.clientHeight + i);
377
385
  }
378
386
  o.refreshVirtualWindow(!1), Array.from(o.bodyEl.querySelectorAll(".cell-focus")).forEach((i) => i.classList.remove("cell-focus")), Array.from(o.bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((i) => {
379
387
  i.setAttribute("aria-selected", "false");
@@ -383,12 +391,12 @@ function O(o) {
383
391
  const s = o.bodyEl.querySelectorAll(".data-grid-row")[e - t]?.children[o.focusCol];
384
392
  if (s) {
385
393
  if (s.classList.add("cell-focus"), s.setAttribute("aria-selected", "true"), o.activeEditRows !== void 0 && o.activeEditRows !== -1 && s.classList.contains("editing")) {
386
- const l = s.querySelector(
394
+ const r = s.querySelector(
387
395
  'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])'
388
396
  );
389
- if (l && document.activeElement !== l)
397
+ if (r && document.activeElement !== r)
390
398
  try {
391
- l.focus();
399
+ r.focus();
392
400
  } catch {
393
401
  }
394
402
  } else if (!s.contains(document.activeElement)) {
@@ -401,96 +409,96 @@ function O(o) {
401
409
  }
402
410
  }
403
411
  }
404
- const ze = "__cellDisplayCache", Ne = "__cellCacheEpoch";
412
+ const Ne = "__cellDisplayCache", Ie = "__cellCacheEpoch";
405
413
  function j(o) {
406
- o[ze] = void 0, o[Ne] = void 0, o.__hasSpecialColumns = void 0;
414
+ o[Ne] = void 0, o[Ie] = void 0, o.__hasSpecialColumns = void 0;
407
415
  }
408
416
  function qe(o, e, t, n, i) {
409
- const s = Math.max(0, t - e), l = o.bodyEl, r = o.visibleColumns, a = r.length;
417
+ const s = Math.max(0, t - e), r = o.bodyEl, a = o.visibleColumns, l = a.length;
410
418
  let f = o.__cachedHeaderRowCount;
411
419
  for (f === void 0 && (f = o.shadowRoot?.querySelector(".header-group-row") ? 2 : 1, o.__cachedHeaderRowCount = f); o.rowPool.length < s; ) {
412
- const w = document.createElement("div");
413
- w.className = "data-grid-row", w.setAttribute("role", "row"), w.addEventListener("click", (u) => Z(o, u, w, !1)), w.addEventListener("dblclick", (u) => Z(o, u, w, !0)), o.rowPool.push(w);
420
+ const g = document.createElement("div");
421
+ g.className = "data-grid-row", g.setAttribute("role", "row"), g.addEventListener("click", (h) => Z(o, h, g, !1)), g.addEventListener("dblclick", (h) => Z(o, h, g, !0)), o.rowPool.push(g);
414
422
  }
415
423
  if (o.rowPool.length > s) {
416
- for (let w = s; w < o.rowPool.length; w++) {
417
- const u = o.rowPool[w];
418
- u.parentNode === l && u.remove();
424
+ for (let g = s; g < o.rowPool.length; g++) {
425
+ const h = o.rowPool[g];
426
+ h.parentNode === r && h.remove();
419
427
  }
420
428
  o.rowPool.length = s;
421
429
  }
422
430
  const p = i && o.__hasRenderRowPlugins !== !1;
423
- for (let w = 0; w < s; w++) {
424
- const u = e + w, c = o._rows[u], h = o.rowPool[w];
425
- if (h.setAttribute("aria-rowindex", String(u + f + 1)), p && i(c, h, u)) {
426
- h.__epoch = n, h.__rowDataRef = c, h.parentNode !== l && l.appendChild(h);
431
+ for (let g = 0; g < s; g++) {
432
+ const h = e + g, c = o._rows[h], u = o.rowPool[g];
433
+ if (u.setAttribute("aria-rowindex", String(h + f + 1)), p && i(c, u, h)) {
434
+ u.__epoch = n, u.__rowDataRef = c, u.parentNode !== r && r.appendChild(u);
427
435
  continue;
428
436
  }
429
- const d = h.__epoch, g = h.__rowDataRef, m = h.children.length, R = d === n && m === a, E = g !== c;
437
+ const d = u.__epoch, b = u.__rowDataRef, m = u.children.length, R = d === n && m === l, E = b !== c;
430
438
  let _ = !1;
431
439
  if (R && E) {
432
- for (let S = 0; S < a; S++)
433
- if (r[S].externalView && !h.querySelector(`.cell[data-col="${S}"] [data-external-view]`)) {
440
+ for (let S = 0; S < l; S++)
441
+ if (a[S].externalView && !u.querySelector(`.cell[data-col="${S}"] [data-external-view]`)) {
434
442
  _ = !0;
435
443
  break;
436
444
  }
437
445
  }
438
- !R || _ ? (h.__isCustomRow && (h.className = "data-grid-row", h.setAttribute("role", "row"), h.__isCustomRow = !1), F(o, h, c, u), h.__epoch = n, h.__rowDataRef = c) : E ? (Y(o, h, c, u), h.__rowDataRef = c) : Y(o, h, c, u);
439
- const b = o._changedRowIndices.has(u), v = h.classList.contains("changed");
440
- b !== v && h.classList.toggle("changed", b), h.parentNode !== l && l.appendChild(h);
446
+ !R || _ ? (u.__isCustomRow && (u.className = "data-grid-row", u.setAttribute("role", "row"), u.__isCustomRow = !1), F(o, u, c, h), u.__epoch = n, u.__rowDataRef = c) : E ? (Y(o, u, c, h), u.__rowDataRef = c) : Y(o, u, c, h);
447
+ const w = o._changedRowIndices.has(h), v = u.classList.contains("changed");
448
+ w !== v && u.classList.toggle("changed", w), u.parentNode !== r && r.appendChild(u);
441
449
  }
442
450
  }
443
451
  function Y(o, e, t, n) {
444
- const i = e.children, s = o.visibleColumns, l = s.length, r = i.length, a = l < r ? l : r, f = o.focusRow, p = o.focusCol;
445
- let w = o.__hasSpecialColumns;
446
- if (w === void 0) {
447
- w = !1;
448
- for (let c = 0; c < l; c++) {
449
- const h = s[c];
450
- if (h.__viewTemplate || h.__compiledView || h.viewRenderer || h.externalView || h.format || h.type === "date" || h.type === "boolean") {
451
- w = !0;
452
+ const i = e.children, s = o.visibleColumns, r = s.length, a = i.length, l = r < a ? r : a, f = o.focusRow, p = o.focusCol;
453
+ let g = o.__hasSpecialColumns;
454
+ if (g === void 0) {
455
+ g = !1;
456
+ for (let c = 0; c < r; c++) {
457
+ const u = s[c];
458
+ if (u.__viewTemplate || u.__compiledView || u.viewRenderer || u.externalView || u.format || u.type === "date" || u.type === "boolean") {
459
+ g = !0;
452
460
  break;
453
461
  }
454
462
  }
455
- o.__hasSpecialColumns = w;
463
+ o.__hasSpecialColumns = g;
456
464
  }
457
- const u = String(n);
458
- if (!w) {
459
- for (let c = 0; c < a; c++) {
460
- const h = i[c], d = t[s[c].field];
461
- h.textContent = d == null ? "" : String(d), h.getAttribute("data-row") !== u && h.setAttribute("data-row", u);
462
- const g = f === n && p === c, m = h.classList.contains("cell-focus");
463
- g !== m && (h.classList.toggle("cell-focus", g), h.setAttribute("aria-selected", String(g)));
465
+ const h = String(n);
466
+ if (!g) {
467
+ for (let c = 0; c < l; c++) {
468
+ const u = i[c], d = t[s[c].field];
469
+ u.textContent = d == null ? "" : String(d), u.getAttribute("data-row") !== h && u.setAttribute("data-row", h);
470
+ const b = f === n && p === c, m = u.classList.contains("cell-focus");
471
+ b !== m && (u.classList.toggle("cell-focus", b), u.setAttribute("aria-selected", String(b)));
464
472
  }
465
473
  return;
466
474
  }
467
- for (let c = 0; c < a; c++)
475
+ for (let c = 0; c < l; c++)
468
476
  if (s[c].externalView && !i[c].querySelector("[data-external-view]")) {
469
477
  F(o, e, t, n);
470
478
  return;
471
479
  }
472
- for (let c = 0; c < a; c++) {
473
- const h = s[c], d = i[c];
474
- d.getAttribute("data-row") !== u && d.setAttribute("data-row", u);
475
- const g = f === n && p === c, m = d.classList.contains("cell-focus");
476
- if (g !== m && (d.classList.toggle("cell-focus", g), d.setAttribute("aria-selected", String(g))), d.classList.contains("editing")) continue;
477
- if (h.viewRenderer) {
478
- const E = t[h.field], _ = h.viewRenderer({ row: t, value: E, field: h.field, column: h });
480
+ for (let c = 0; c < l; c++) {
481
+ const u = s[c], d = i[c];
482
+ d.getAttribute("data-row") !== h && d.setAttribute("data-row", h);
483
+ const b = f === n && p === c, m = d.classList.contains("cell-focus");
484
+ if (b !== m && (d.classList.toggle("cell-focus", b), d.setAttribute("aria-selected", String(b))), d.classList.contains("editing")) continue;
485
+ if (u.viewRenderer) {
486
+ const E = t[u.field], _ = u.viewRenderer({ row: t, value: E, field: u.field, column: u });
479
487
  typeof _ == "string" ? d.innerHTML = z(_) : _ ? (d.innerHTML = "", d.appendChild(_)) : d.textContent = E == null ? "" : String(E);
480
488
  continue;
481
489
  }
482
- if (h.__viewTemplate || h.__compiledView || h.externalView)
490
+ if (u.__viewTemplate || u.__compiledView || u.externalView)
483
491
  continue;
484
- const C = t[h.field];
492
+ const C = t[u.field];
485
493
  let R;
486
- if (h.format)
494
+ if (u.format)
487
495
  try {
488
- const E = h.format(C, t);
496
+ const E = u.format(C, t);
489
497
  R = E == null ? "" : String(E);
490
498
  } catch {
491
499
  R = C == null ? "" : String(C);
492
500
  }
493
- else if (h.type === "date")
501
+ else if (u.type === "date")
494
502
  if (C == null || C === "")
495
503
  R = "";
496
504
  else if (C instanceof Date)
@@ -499,37 +507,37 @@ function Y(o, e, t, n) {
499
507
  const E = new Date(C);
500
508
  R = isNaN(E.getTime()) ? "" : E.toLocaleDateString();
501
509
  }
502
- else h.type === "boolean" ? (R = C ? "🗹" : "☐", d.setAttribute("aria-checked", String(!!C))) : R = C == null ? "" : String(C);
510
+ else u.type === "boolean" ? (R = C ? "🗹" : "☐", d.setAttribute("aria-checked", String(!!C))) : R = C == null ? "" : String(C);
503
511
  d.textContent = R;
504
512
  }
505
513
  }
506
514
  function F(o, e, t, n) {
507
515
  e.innerHTML = "";
508
- const i = o.visibleColumns, s = i.length, l = o.focusRow, r = o.focusCol, a = o.effectiveConfig?.editOn || o.editOn, f = o, p = document.createDocumentFragment();
509
- for (let w = 0; w < s; w++) {
510
- const u = i[w], c = document.createElement("div");
511
- c.className = "cell", B(c, "cell"), u.type !== "boolean" && c.setAttribute("role", "gridcell"), c.setAttribute("data-col", String(w)), c.setAttribute("data-row", String(n)), c.setAttribute("aria-colindex", String(w + 1)), u.type && c.setAttribute("data-type", u.type);
512
- const h = u.sticky;
513
- h === "left" ? c.classList.add("sticky-left") : h === "right" && c.classList.add("sticky-right");
514
- let d = t[u.field];
515
- const g = u.format;
516
- if (g)
516
+ const i = o.visibleColumns, s = i.length, r = o.focusRow, a = o.focusCol, l = o.effectiveConfig?.editOn || o.editOn, f = o, p = document.createDocumentFragment();
517
+ for (let g = 0; g < s; g++) {
518
+ const h = i[g], c = document.createElement("div");
519
+ c.className = "cell", B(c, "cell"), h.type !== "boolean" && c.setAttribute("role", "gridcell"), c.setAttribute("data-col", String(g)), c.setAttribute("data-row", String(n)), c.setAttribute("aria-colindex", String(g + 1)), h.type && c.setAttribute("data-type", h.type);
520
+ const u = h.sticky;
521
+ u === "left" ? c.classList.add("sticky-left") : u === "right" && c.classList.add("sticky-right");
522
+ let d = t[h.field];
523
+ const b = h.format;
524
+ if (b)
517
525
  try {
518
- d = g(d, t);
526
+ d = b(d, t);
519
527
  } catch {
520
528
  }
521
- const m = u.__compiledView, C = u.__viewTemplate, R = u.viewRenderer, E = u.externalView;
529
+ const m = h.__compiledView, C = h.__viewTemplate, R = h.viewRenderer, E = h.externalView;
522
530
  let _ = !1;
523
531
  if (R) {
524
- const b = R({ row: t, value: d, field: u.field, column: u });
525
- typeof b == "string" ? (c.innerHTML = z(b), _ = !0) : b ? c.appendChild(b) : c.textContent = d == null ? "" : String(d);
532
+ const w = R({ row: t, value: d, field: h.field, column: h });
533
+ typeof w == "string" ? (c.innerHTML = z(w), _ = !0) : w ? c.appendChild(w) : c.textContent = d == null ? "" : String(d);
526
534
  } else if (E) {
527
- const b = E, v = document.createElement("div");
528
- v.setAttribute("data-external-view", ""), v.setAttribute("data-field", u.field), c.appendChild(v);
529
- const S = { row: t, value: d, field: u.field, column: u };
530
- if (b.mount)
535
+ const w = E, v = document.createElement("div");
536
+ v.setAttribute("data-external-view", ""), v.setAttribute("data-field", h.field), c.appendChild(v);
537
+ const S = { row: t, value: d, field: h.field, column: h };
538
+ if (w.mount)
531
539
  try {
532
- b.mount({ placeholder: v, context: S, spec: b });
540
+ w.mount({ placeholder: v, context: S, spec: w });
533
541
  } catch {
534
542
  }
535
543
  else
@@ -539,7 +547,7 @@ function F(o, e, t, n) {
539
547
  new CustomEvent("mount-external-view", {
540
548
  bubbles: !0,
541
549
  composed: !0,
542
- detail: { placeholder: v, spec: b, context: S }
550
+ detail: { placeholder: v, spec: w, context: S }
543
551
  })
544
552
  );
545
553
  } catch {
@@ -547,50 +555,50 @@ function F(o, e, t, n) {
547
555
  });
548
556
  v.setAttribute("data-mounted", "");
549
557
  } else if (m) {
550
- const b = m({ row: t, value: d, field: u.field, column: u }), v = m.__blocked;
551
- c.innerHTML = v ? "" : z(b), _ = !0, v && (c.textContent = "", c.setAttribute("data-blocked-template", ""));
558
+ const w = m({ row: t, value: d, field: h.field, column: h }), v = m.__blocked;
559
+ c.innerHTML = v ? "" : z(w), _ = !0, v && (c.textContent = "", c.setAttribute("data-blocked-template", ""));
552
560
  } else if (C) {
553
- const b = C.innerHTML;
554
- /Reflect\.|\bProxy\b|ownKeys\(/.test(b) ? (c.textContent = "", c.setAttribute("data-blocked-template", "")) : (c.innerHTML = z(de(b, { row: t, value: d })), _ = !0);
555
- } else if (u.type === "date")
561
+ const w = C.innerHTML;
562
+ /Reflect\.|\bProxy\b|ownKeys\(/.test(w) ? (c.textContent = "", c.setAttribute("data-blocked-template", "")) : (c.innerHTML = z(he(w, { row: t, value: d })), _ = !0);
563
+ } else if (h.type === "date")
556
564
  if (d == null || d === "")
557
565
  c.textContent = "";
558
566
  else {
559
- let b = null;
560
- if (d instanceof Date) b = d;
567
+ let w = null;
568
+ if (d instanceof Date) w = d;
561
569
  else if (typeof d == "number" || typeof d == "string") {
562
570
  const v = new Date(d);
563
- isNaN(v.getTime()) || (b = v);
571
+ isNaN(v.getTime()) || (w = v);
564
572
  }
565
- c.textContent = b ? b.toLocaleDateString() : "";
573
+ c.textContent = w ? w.toLocaleDateString() : "";
566
574
  }
567
- else if (u.type === "boolean") {
568
- const b = !!d;
569
- c.innerHTML = b ? "&#x1F5F9;" : "&#9744;", c.setAttribute("role", "checkbox"), c.setAttribute("aria-checked", String(b)), c.setAttribute("aria-label", String(b));
575
+ else if (h.type === "boolean") {
576
+ const w = !!d;
577
+ c.innerHTML = w ? "&#x1F5F9;" : "&#9744;", c.setAttribute("role", "checkbox"), c.setAttribute("aria-checked", String(w)), c.setAttribute("aria-label", String(w));
570
578
  } else
571
579
  c.textContent = d == null ? "" : String(d);
572
580
  if (_) {
573
- Le(c);
574
- const b = c.textContent || "";
575
- /Proxy|Reflect\.ownKeys/.test(b) && (c.textContent = b.replace(/Proxy|Reflect\.ownKeys/g, "").trim(), /Proxy|Reflect\.ownKeys/.test(c.textContent || "") && (c.textContent = ""));
576
- }
577
- c.hasAttribute("data-blocked-template") && (c.textContent || "").trim().length && (c.textContent = ""), u.editable ? (c.tabIndex = 0, c.addEventListener("mousedown", () => {
578
- o.focusRow = n, o.focusCol = w, O(o);
579
- }), a === "click" ? c.addEventListener("click", (b) => {
580
- c.classList.contains("editing") || (b.stopPropagation(), o.focusRow = n, o.focusCol = w, L(o, t, n, u, c));
581
- }) : c.addEventListener("dblclick", (b) => {
582
- b.stopPropagation(), T(o, n, t);
581
+ ke(c);
582
+ const w = c.textContent || "";
583
+ /Proxy|Reflect\.ownKeys/.test(w) && (c.textContent = w.replace(/Proxy|Reflect\.ownKeys/g, "").trim(), /Proxy|Reflect\.ownKeys/.test(c.textContent || "") && (c.textContent = ""));
584
+ }
585
+ c.hasAttribute("data-blocked-template") && (c.textContent || "").trim().length && (c.textContent = ""), h.editable ? (c.tabIndex = 0, c.addEventListener("mousedown", () => {
586
+ o.focusRow = n, o.focusCol = g, H(o);
587
+ }), l === "click" ? c.addEventListener("click", (w) => {
588
+ c.classList.contains("editing") || (w.stopPropagation(), o.focusRow = n, o.focusCol = g, L(o, t, n, h, c));
589
+ }) : c.addEventListener("dblclick", (w) => {
590
+ w.stopPropagation(), T(o, n, t);
583
591
  const v = o.findRenderedRowElement?.(n);
584
592
  if (v) {
585
593
  const S = v.children;
586
594
  for (let k = 0; k < S.length; k++) {
587
- const D = o.visibleColumns[k];
588
- D && D.editable && L(o, t, n, D, S[k]);
595
+ const O = o.visibleColumns[k];
596
+ O && O.editable && L(o, t, n, O, S[k]);
589
597
  }
590
598
  }
591
- }), c.addEventListener("keydown", (b) => {
592
- if ((u.type === "select" || u.type === "typeahead") && !c.classList.contains("editing") && b.key === "Enter") {
593
- b.preventDefault(), o.activeEditRows !== n && T(o, n, t), L(o, t, n, u, c), setTimeout(() => {
599
+ }), c.addEventListener("keydown", (w) => {
600
+ if ((h.type === "select" || h.type === "typeahead") && !c.classList.contains("editing") && w.key === "Enter") {
601
+ w.preventDefault(), o.activeEditRows !== n && T(o, n, t), L(o, t, n, h, c), setTimeout(() => {
594
602
  const v = c.querySelector("select");
595
603
  try {
596
604
  v?.showPicker?.();
@@ -600,27 +608,27 @@ function F(o, e, t, n) {
600
608
  }, 0);
601
609
  return;
602
610
  }
603
- if (u.type === "boolean" && b.key === " " && !c.classList.contains("editing")) {
604
- b.preventDefault(), o.activeEditRows !== n && T(o, n, t);
605
- const v = !t[u.field];
606
- $(o, n, u, v, t), c.innerHTML = v ? "&#x1F5F9;" : "&#9744;", c.setAttribute("aria-label", String(!!v));
611
+ if (h.type === "boolean" && w.key === " " && !c.classList.contains("editing")) {
612
+ w.preventDefault(), o.activeEditRows !== n && T(o, n, t);
613
+ const v = !t[h.field];
614
+ $(o, n, h, v, t), c.innerHTML = v ? "&#x1F5F9;" : "&#9744;", c.setAttribute("aria-label", String(!!v));
607
615
  return;
608
616
  }
609
- if (b.key === "Enter" && !c.classList.contains("editing")) {
610
- b.preventDefault(), o.focusRow = n, o.focusCol = w, typeof o.beginBulkEdit == "function" ? o.beginBulkEdit(n) : L(o, t, n, u, c);
617
+ if (w.key === "Enter" && !c.classList.contains("editing")) {
618
+ w.preventDefault(), o.focusRow = n, o.focusCol = g, typeof o.beginBulkEdit == "function" ? o.beginBulkEdit(n) : L(o, t, n, h, c);
611
619
  return;
612
620
  }
613
- if (b.key === "F2" && !c.classList.contains("editing")) {
614
- b.preventDefault(), L(o, t, n, u, c);
621
+ if (w.key === "F2" && !c.classList.contains("editing")) {
622
+ w.preventDefault(), L(o, t, n, h, c);
615
623
  return;
616
624
  }
617
- })) : u.type === "boolean" && (c.hasAttribute("tabindex") || (c.tabIndex = 0), c.addEventListener("keydown", (b) => {
618
- if (b.key === " ") {
619
- b.preventDefault();
620
- const v = !t[u.field];
621
- o.activeEditRows !== n && T(o, n, t), $(o, n, u, v, t), c.innerHTML = v ? "&#x1F5F9;" : "&#9744;", c.setAttribute("role", "checkbox"), c.setAttribute("aria-checked", String(!!v)), c.setAttribute("aria-label", String(!!v));
625
+ })) : h.type === "boolean" && (c.hasAttribute("tabindex") || (c.tabIndex = 0), c.addEventListener("keydown", (w) => {
626
+ if (w.key === " ") {
627
+ w.preventDefault();
628
+ const v = !t[h.field];
629
+ o.activeEditRows !== n && T(o, n, t), $(o, n, h, v, t), c.innerHTML = v ? "&#x1F5F9;" : "&#9744;", c.setAttribute("role", "checkbox"), c.setAttribute("aria-checked", String(!!v)), c.setAttribute("aria-label", String(!!v));
622
630
  }
623
- })), l === n && r === w ? c.setAttribute("aria-selected", "true") : c.setAttribute("aria-selected", "false"), p.appendChild(c);
631
+ })), r === n && a === g ? c.setAttribute("aria-selected", "true") : c.setAttribute("aria-selected", "false"), p.appendChild(c);
624
632
  }
625
633
  e.appendChild(p);
626
634
  }
@@ -630,15 +638,15 @@ function Z(o, e, t, n) {
630
638
  if (!i) return;
631
639
  const s = Number(i.getAttribute("data-row"));
632
640
  if (isNaN(s)) return;
633
- const l = o._rows[s];
634
- if (!l) return;
635
- const r = e.target?.closest(".cell[data-col]");
636
- if (r) {
637
- const f = Number(r.getAttribute("data-col"));
641
+ const r = o._rows[s];
642
+ if (!r) return;
643
+ const a = e.target?.closest(".cell[data-col]");
644
+ if (a) {
645
+ const f = Number(a.getAttribute("data-col"));
638
646
  if (!isNaN(f)) {
639
- if (o.dispatchCellClick?.(e, s, f, r))
647
+ if (o.dispatchCellClick?.(e, s, f, a))
640
648
  return;
641
- o.focusRow = s, o.focusCol = f, O(o);
649
+ o.focusRow = s, o.focusCol = f, H(o);
642
650
  }
643
651
  }
644
652
  if (t.querySelector(".cell.editing")) {
@@ -646,13 +654,13 @@ function Z(o, e, t, n) {
646
654
  if (!n) return;
647
655
  f.forEach((p) => p.classList.remove("editing"));
648
656
  }
649
- const a = o.effectiveConfig?.editOn || o.editOn || "doubleClick";
650
- if (a === "click" || a === "doubleClick" && n) T(o, s, l);
657
+ const l = o.effectiveConfig?.editOn || o.editOn || "doubleClick";
658
+ if (l === "click" || l === "doubleClick" && n) T(o, s, r);
651
659
  else return;
652
660
  Array.from(t.children).forEach((f, p) => {
653
- const w = o.visibleColumns[p];
654
- w && w.editable && L(o, l, s, w, f);
655
- }), r && queueMicrotask(() => {
661
+ const g = o.visibleColumns[p];
662
+ g && g.editable && L(o, r, s, g, f);
663
+ }), a && queueMicrotask(() => {
656
664
  const f = t.querySelector(`.cell[data-col="${o.focusCol}"]`);
657
665
  if (f?.classList.contains("editing")) {
658
666
  const p = f.querySelector(
@@ -668,19 +676,19 @@ function Z(o, e, t, n) {
668
676
  function T(o, e, t) {
669
677
  o.activeEditRows !== e && (o.rowEditSnapshots.set(e, { ...t }), o.activeEditRows = e);
670
678
  }
671
- function Ie(o, e, t) {
679
+ function Be(o, e, t) {
672
680
  if (o.activeEditRows !== e) return;
673
681
  const n = o.rowEditSnapshots.get(e), i = o._rows[e];
674
682
  if (t && n && i)
675
- Object.keys(n).forEach((l) => i[l] = n[l]), o._changedRowIndices.delete(e);
683
+ Object.keys(n).forEach((r) => i[r] = n[r]), o._changedRowIndices.delete(e);
676
684
  else if (!t) {
677
- const l = o._changedRowIndices.has(e);
685
+ const r = o._changedRowIndices.has(e);
678
686
  o.dispatchEvent(
679
687
  new CustomEvent("row-commit", {
680
688
  detail: {
681
689
  rowIndex: e,
682
690
  row: i,
683
- changed: l,
691
+ changed: r,
684
692
  changedRows: o.changedRows,
685
693
  changedRowIndices: o.changedRowIndices
686
694
  }
@@ -692,12 +700,12 @@ function Ie(o, e, t) {
692
700
  s && (F(o, s, o._rows[e], e), o._changedRowIndices.has(e) ? s.classList.add("changed") : s.classList.remove("changed")), t && queueMicrotask(() => {
693
701
  try {
694
702
  o.focus();
695
- const l = o.focusRow, r = o.focusCol, a = o.findRenderedRowElement?.(l);
696
- if (a) {
703
+ const r = o.focusRow, a = o.focusCol, l = o.findRenderedRowElement?.(r);
704
+ if (l) {
697
705
  Array.from(o.bodyEl.querySelectorAll(".cell-focus")).forEach(
698
706
  (p) => p.classList.remove("cell-focus")
699
707
  );
700
- const f = a.querySelector(`.cell[data-row="${l}"][data-col="${r}"]`);
708
+ const f = l.querySelector(`.cell[data-row="${r}"][data-col="${a}"]`);
701
709
  f && f.classList.add("cell-focus");
702
710
  }
703
711
  } catch {
@@ -708,10 +716,10 @@ function $(o, e, t, n, i) {
708
716
  const s = t.field;
709
717
  if (i[s] === n) return;
710
718
  i[s] = n;
711
- const r = !o._changedRowIndices.has(e);
719
+ const a = !o._changedRowIndices.has(e);
712
720
  o._changedRowIndices.add(e);
713
- const a = o.findRenderedRowElement?.(e);
714
- a && a.classList.add("changed"), o.dispatchEvent(
721
+ const l = o.findRenderedRowElement?.(e);
722
+ l && l.classList.add("changed"), o.dispatchEvent(
715
723
  new CustomEvent("cell-commit", {
716
724
  detail: {
717
725
  row: i,
@@ -720,7 +728,7 @@ function $(o, e, t, n, i) {
720
728
  rowIndex: e,
721
729
  changedRows: o.changedRows,
722
730
  changedRowIndices: o.changedRowIndices,
723
- firstTimeForRow: r
731
+ firstTimeForRow: a
724
732
  }
725
733
  })
726
734
  );
@@ -729,59 +737,59 @@ function L(o, e, t, n, i) {
729
737
  if (!n.editable || (o.activeEditRows !== t && T(o, t, e), i.classList.contains("editing"))) return;
730
738
  const s = e[n.field];
731
739
  i.classList.add("editing");
732
- const l = (u) => {
733
- $(o, t, n, u, e);
734
- }, r = () => {
740
+ const r = (h) => {
741
+ $(o, t, n, h, e);
742
+ }, a = () => {
735
743
  e[n.field] = s;
736
- const u = i.querySelector("input,textarea,select");
737
- u && (typeof HTMLInputElement < "u" && u instanceof HTMLInputElement && u.type === "checkbox" ? u.checked = !!s : "value" in u && (u.value = s ?? ""));
738
- }, a = document.createElement("div");
739
- a.style.display = "contents", i.innerHTML = "", i.appendChild(a);
740
- const f = n.__editorTemplate, p = n.editor || (f ? "template" : De(n)), w = s;
744
+ const h = i.querySelector("input,textarea,select");
745
+ h && (typeof HTMLInputElement < "u" && h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked = !!s : "value" in h && (h.value = s ?? ""));
746
+ }, l = document.createElement("div");
747
+ l.style.display = "contents", i.innerHTML = "", i.appendChild(l);
748
+ const f = n.__editorTemplate, p = n.editor || (f ? "template" : De(n)), g = s;
741
749
  if (p === "template" && f) {
742
- const u = f.cloneNode(!0), c = n.__compiledEditor;
743
- c ? u.innerHTML = c({ row: e, value: s, field: n.field, column: n }) : u.querySelectorAll("*").forEach((d) => {
744
- d.childNodes.length === 1 && d.firstChild?.nodeType === Node.TEXT_NODE && (d.textContent = d.textContent?.replace(/{{\s*value\s*}}/g, s == null ? "" : String(s)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (g, m) => {
750
+ const h = f.cloneNode(!0), c = n.__compiledEditor;
751
+ c ? h.innerHTML = c({ row: e, value: s, field: n.field, column: n }) : h.querySelectorAll("*").forEach((d) => {
752
+ d.childNodes.length === 1 && d.firstChild?.nodeType === Node.TEXT_NODE && (d.textContent = d.textContent?.replace(/{{\s*value\s*}}/g, s == null ? "" : String(s)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (b, m) => {
745
753
  const C = e[m];
746
754
  return C == null ? "" : String(C);
747
755
  }) || "");
748
756
  });
749
- const h = u.querySelector("input,textarea,select");
750
- if (h) {
757
+ const u = h.querySelector("input,textarea,select");
758
+ if (u) {
751
759
  const d = typeof HTMLInputElement < "u";
752
- d && h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked = !!s : "value" in h && (h.value = s ?? ""), h.addEventListener("blur", () => {
753
- const g = d && h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked : h.value;
754
- l(g);
755
- }), h.addEventListener("keydown", (g) => {
756
- if (g.key === "Enter") {
757
- const m = d && h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked : h.value;
758
- l(m);
760
+ d && u instanceof HTMLInputElement && u.type === "checkbox" ? u.checked = !!s : "value" in u && (u.value = s ?? ""), u.addEventListener("blur", () => {
761
+ const b = d && u instanceof HTMLInputElement && u.type === "checkbox" ? u.checked : u.value;
762
+ r(b);
763
+ }), u.addEventListener("keydown", (b) => {
764
+ if (b.key === "Enter") {
765
+ const m = d && u instanceof HTMLInputElement && u.type === "checkbox" ? u.checked : u.value;
766
+ r(m);
759
767
  }
760
- g.key === "Escape" && r();
761
- }), d && h instanceof HTMLInputElement && h.type === "checkbox" && h.addEventListener("change", () => {
762
- const g = h.checked;
763
- l(g);
764
- }), setTimeout(() => h.focus(), 0);
768
+ b.key === "Escape" && a();
769
+ }), d && u instanceof HTMLInputElement && u.type === "checkbox" && u.addEventListener("change", () => {
770
+ const b = u.checked;
771
+ r(b);
772
+ }), setTimeout(() => u.focus(), 0);
765
773
  }
766
- a.appendChild(u);
774
+ l.appendChild(h);
767
775
  } else if (typeof p == "string") {
768
- const u = document.createElement(p);
769
- u.value = w, u.addEventListener("change", () => l(u.value)), a.appendChild(u);
776
+ const h = document.createElement(p);
777
+ h.value = g, h.addEventListener("change", () => r(h.value)), l.appendChild(h);
770
778
  } else if (typeof p == "function") {
771
- const u = p({ row: e, value: w, field: n.field, column: n, commit: l, cancel: r });
772
- typeof u == "string" ? a.innerHTML = u : a.appendChild(u);
779
+ const h = p({ row: e, value: g, field: n.field, column: n, commit: r, cancel: a });
780
+ typeof h == "string" ? l.innerHTML = h : l.appendChild(h);
773
781
  } else if (p && typeof p == "object") {
774
- const u = document.createElement("div");
775
- u.setAttribute("data-external-editor", ""), u.setAttribute("data-field", n.field), a.appendChild(u);
776
- const c = { row: e, value: w, field: n.field, column: n, commit: l, cancel: r };
782
+ const h = document.createElement("div");
783
+ h.setAttribute("data-external-editor", ""), h.setAttribute("data-field", n.field), l.appendChild(h);
784
+ const c = { row: e, value: g, field: n.field, column: n, commit: r, cancel: a };
777
785
  if (p.mount)
778
786
  try {
779
- p.mount({ placeholder: u, context: c, spec: p });
787
+ p.mount({ placeholder: h, context: c, spec: p });
780
788
  } catch {
781
789
  }
782
790
  else
783
791
  o.dispatchEvent(
784
- new CustomEvent("mount-external-editor", { detail: { placeholder: u, spec: p, context: c } })
792
+ new CustomEvent("mount-external-editor", { detail: { placeholder: h, spec: p, context: c } })
785
793
  );
786
794
  }
787
795
  }
@@ -799,6 +807,9 @@ function Q(o, e, t) {
799
807
  new CustomEvent("sort-change", { detail: { field: e.field, direction: t } })
800
808
  ), o.requestStateChange?.();
801
809
  }
810
+ function $e(o, e) {
811
+ typeof e == "string" ? o.textContent = e : e instanceof HTMLElement && (o.innerHTML = "", o.appendChild(e.cloneNode(!0)));
812
+ }
802
813
  function V(o) {
803
814
  o.headerRowEl = o.findHeaderRow();
804
815
  const e = o.headerRowEl;
@@ -806,31 +817,31 @@ function V(o) {
806
817
  const i = document.createElement("div");
807
818
  i.className = "cell", B(i, "header-cell"), i.setAttribute("role", "columnheader"), i.setAttribute("aria-colindex", String(n + 1)), i.setAttribute("data-field", t.field), i.setAttribute("data-col", String(n)), t.sticky === "left" ? i.classList.add("sticky-left") : t.sticky === "right" && i.classList.add("sticky-right");
808
819
  const s = t.__headerTemplate;
809
- if (s) Array.from(s.childNodes).forEach((l) => i.appendChild(l.cloneNode(!0)));
820
+ if (s) Array.from(s.childNodes).forEach((r) => i.appendChild(r.cloneNode(!0)));
810
821
  else {
811
- const l = t.header || t.field, r = document.createElement("span");
812
- r.textContent = l, i.appendChild(r);
822
+ const r = t.header || t.field, a = document.createElement("span");
823
+ a.textContent = r, i.appendChild(a);
813
824
  }
814
825
  if (t.sortable) {
815
826
  i.classList.add("sortable"), i.tabIndex = 0;
816
- const l = document.createElement("span");
817
- B(l, "sort-indicator"), l.style.opacity = "0.6";
818
- const r = o.sortState?.field === t.field ? o.sortState.direction : 0;
819
- l.textContent = r === 1 ? "▲" : r === -1 ? "▼" : "⇅", i.appendChild(l), i.setAttribute("aria-sort", r === 0 ? "none" : r === 1 ? "ascending" : "descending"), i.addEventListener("click", (a) => {
820
- o.resizeController?.isResizing || o.dispatchHeaderClick?.(a, n, i) || J(o, t);
821
- }), i.addEventListener("keydown", (a) => {
822
- if (a.key === "Enter" || a.key === " ") {
823
- if (a.preventDefault(), o.dispatchHeaderClick?.(a, n, i)) return;
827
+ const r = document.createElement("span");
828
+ B(r, "sort-indicator"), r.style.opacity = "0.6";
829
+ const a = o.sortState?.field === t.field ? o.sortState.direction : 0, l = { ...ce, ...o.icons }, f = a === 1 ? l.sortAsc : a === -1 ? l.sortDesc : l.sortNone;
830
+ $e(r, f), i.appendChild(r), i.setAttribute("aria-sort", a === 0 ? "none" : a === 1 ? "ascending" : "descending"), i.addEventListener("click", (p) => {
831
+ o.resizeController?.isResizing || o.dispatchHeaderClick?.(p, n, i) || J(o, t);
832
+ }), i.addEventListener("keydown", (p) => {
833
+ if (p.key === "Enter" || p.key === " ") {
834
+ if (p.preventDefault(), o.dispatchHeaderClick?.(p, n, i)) return;
824
835
  J(o, t);
825
836
  }
826
837
  });
827
838
  }
828
839
  if (t.resizable) {
829
840
  t.sticky || (i.style.position = "relative");
830
- const l = document.createElement("div");
831
- l.className = "resize-handle", l.setAttribute("aria-hidden", "true"), l.addEventListener("mousedown", (r) => {
832
- r.stopPropagation(), r.preventDefault(), o.resizeController.start(r, n, i);
833
- }), i.appendChild(l);
841
+ const r = document.createElement("div");
842
+ r.className = "resize-handle", r.setAttribute("aria-hidden", "true"), r.addEventListener("mousedown", (a) => {
843
+ a.stopPropagation(), a.preventDefault(), o.resizeController.start(a, n, i);
844
+ }), i.appendChild(r);
834
845
  }
835
846
  e.appendChild(i);
836
847
  });
@@ -845,39 +856,39 @@ function V(o) {
845
856
  t.getAttribute("aria-sort") || t.setAttribute("aria-sort", "none");
846
857
  });
847
858
  }
848
- function Be(o) {
859
+ function Ke(o) {
849
860
  let e = null, t = null, n = null, i = null;
850
- const s = (a) => {
861
+ const s = (l) => {
851
862
  if (!e) return;
852
- const f = a.clientX - e.startX, p = Math.max(40, e.startWidth + f), w = o.visibleColumns[e.colIndex];
853
- w.width = p, w.__userResized = !0, w.__renderedWidth = p, t == null && (t = requestAnimationFrame(() => {
863
+ const f = l.clientX - e.startX, p = Math.max(40, e.startWidth + f), g = o.visibleColumns[e.colIndex];
864
+ g.width = p, g.__userResized = !0, g.__renderedWidth = p, t == null && (t = requestAnimationFrame(() => {
854
865
  t = null, o.updateTemplate?.();
855
866
  })), o.dispatchEvent(
856
- new CustomEvent("column-resize", { detail: { field: w.field, width: p } })
867
+ new CustomEvent("column-resize", { detail: { field: g.field, width: p } })
857
868
  );
858
869
  };
859
- let l = !1;
860
- const r = () => {
861
- const a = e !== null;
862
- a && (l = !0, requestAnimationFrame(() => {
863
- l = !1;
864
- })), window.removeEventListener("mousemove", s), window.removeEventListener("mouseup", r), n !== null && (document.documentElement.style.cursor = n, n = null), i !== null && (document.body.style.userSelect = i, i = null), e = null, a && o.requestStateChange && o.requestStateChange();
870
+ let r = !1;
871
+ const a = () => {
872
+ const l = e !== null;
873
+ l && (r = !0, requestAnimationFrame(() => {
874
+ r = !1;
875
+ })), window.removeEventListener("mousemove", s), window.removeEventListener("mouseup", a), n !== null && (document.documentElement.style.cursor = n, n = null), i !== null && (document.body.style.userSelect = i, i = null), e = null, l && o.requestStateChange && o.requestStateChange();
865
876
  };
866
877
  return {
867
878
  get isResizing() {
868
- return e !== null || l;
879
+ return e !== null || r;
869
880
  },
870
- start(a, f, p) {
871
- a.preventDefault();
872
- const w = p.getBoundingClientRect();
873
- e = { startX: a.clientX, colIndex: f, startWidth: w.width }, window.addEventListener("mousemove", s), window.addEventListener("mouseup", r), n === null && (n = document.documentElement.style.cursor), document.documentElement.style.cursor = "e-resize", i === null && (i = document.body.style.userSelect), document.body.style.userSelect = "none";
881
+ start(l, f, p) {
882
+ l.preventDefault();
883
+ const g = p.getBoundingClientRect();
884
+ e = { startX: l.clientX, colIndex: f, startWidth: g.width }, window.addEventListener("mousemove", s), window.addEventListener("mouseup", a), n === null && (n = document.documentElement.style.cursor), document.documentElement.style.cursor = "e-resize", i === null && (i = document.body.style.userSelect), document.body.style.userSelect = "none";
874
885
  },
875
886
  dispose() {
876
- r();
887
+ a();
877
888
  }
878
889
  };
879
890
  }
880
- function $e() {
891
+ function We() {
881
892
  return {
882
893
  toolPanels: /* @__PURE__ */ new Map(),
883
894
  headerContents: /* @__PURE__ */ new Map(),
@@ -890,24 +901,24 @@ function $e() {
890
901
  toolbarButtonCleanups: /* @__PURE__ */ new Map()
891
902
  };
892
903
  }
893
- function Ke(o, e) {
904
+ function Fe(o, e) {
894
905
  return !!(o?.header?.title || o?.header?.toolbarButtons?.length || e.toolPanels.size > 0 || e.headerContents.size > 0 || e.toolbarButtons.size > 0 || e.lightDomButtons.length > 0 || e.lightDomHeaderContent.length > 0);
895
906
  }
896
- function We(o, e) {
897
- const t = o?.header?.title ?? "", n = !!t, i = o?.header?.toolbarButtons ?? [], s = i.length > 0, l = e.toolbarButtons.size > 0, r = e.lightDomButtons.length > 0, a = e.toolPanels.size > 0, p = (s || l || r) && a, w = [...i].sort((d, g) => (d.order ?? 100) - (g.order ?? 100)), u = [...e.toolbarButtons.values()].sort((d, g) => (d.order ?? 100) - (g.order ?? 100)), c = [...e.toolPanels.values()].sort((d, g) => (d.order ?? 100) - (g.order ?? 100));
898
- let h = "";
899
- for (const d of w)
900
- d.icon && d.action && (h += `<button class="tbw-toolbar-btn" data-btn="${d.id}" title="${d.label}" aria-label="${d.label}"${d.disabled ? " disabled" : ""}>${d.icon}</button>`);
901
- for (const d of u)
902
- d.icon && d.action && (h += `<button class="tbw-toolbar-btn" data-btn="${d.id}" title="${d.label}" aria-label="${d.label}"${d.disabled ? " disabled" : ""}>${d.icon}</button>`);
903
- for (const d of w)
904
- (d.element || d.render) && (h += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${d.id}"></div>`);
905
- for (const d of u)
906
- (d.element || d.render) && (h += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${d.id}"></div>`);
907
- r && (h += '<slot name="toolbar"></slot>'), p && (h += '<div class="tbw-toolbar-separator"></div>');
907
+ function Ve(o, e) {
908
+ const t = o?.header?.title ?? "", n = !!t, i = o?.header?.toolbarButtons ?? [], s = i.length > 0, r = e.toolbarButtons.size > 0, a = e.lightDomButtons.length > 0, l = e.toolPanels.size > 0, p = (s || r || a) && l, g = [...i].sort((d, b) => (d.order ?? 100) - (b.order ?? 100)), h = [...e.toolbarButtons.values()].sort((d, b) => (d.order ?? 100) - (b.order ?? 100)), c = [...e.toolPanels.values()].sort((d, b) => (d.order ?? 100) - (b.order ?? 100));
909
+ let u = "";
910
+ for (const d of g)
911
+ d.icon && d.action && (u += `<button class="tbw-toolbar-btn" data-btn="${d.id}" title="${d.label}" aria-label="${d.label}"${d.disabled ? " disabled" : ""}>${d.icon}</button>`);
912
+ for (const d of h)
913
+ d.icon && d.action && (u += `<button class="tbw-toolbar-btn" data-btn="${d.id}" title="${d.label}" aria-label="${d.label}"${d.disabled ? " disabled" : ""}>${d.icon}</button>`);
914
+ for (const d of g)
915
+ (d.element || d.render) && (u += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${d.id}"></div>`);
916
+ for (const d of h)
917
+ (d.element || d.render) && (u += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${d.id}"></div>`);
918
+ a && (u += '<slot name="toolbar"></slot>'), p && (u += '<div class="tbw-toolbar-separator"></div>');
908
919
  for (const d of c) {
909
- const g = e.activePanel === d.id;
910
- h += `<button class="tbw-toolbar-btn${g ? " active" : ""}" data-panel="${d.id}" title="${d.tooltip ?? d.title}" aria-label="${d.tooltip ?? d.title}" aria-pressed="${g}" aria-controls="tbw-panel-${d.id}">${d.icon}</button>`;
920
+ const b = e.activePanel === d.id;
921
+ u += `<button class="tbw-toolbar-btn${b ? " active" : ""}" data-panel="${d.id}" title="${d.tooltip ?? d.title}" aria-label="${d.tooltip ?? d.title}" aria-pressed="${b}" aria-controls="tbw-panel-${d.id}">${d.icon}</button>`;
911
922
  }
912
923
  return `
913
924
  <div class="tbw-shell-header" part="shell-header" role="banner">
@@ -916,16 +927,16 @@ function We(o, e) {
916
927
  <slot name="header-content"></slot>
917
928
  </div>
918
929
  <div class="tbw-shell-toolbar" part="shell-toolbar" role="toolbar" aria-label="Grid tools">
919
- ${h}
930
+ ${u}
920
931
  </div>
921
932
  </div>
922
933
  `;
923
934
  }
924
- function Fe(o, e, t) {
925
- const n = o?.toolPanel?.position ?? "right", i = e.toolPanels.size > 0, s = e.activePanel !== null, l = e.activePanel ? e.toolPanels.get(e.activePanel) : null, r = i ? `
926
- <aside class="tbw-tool-panel${s ? " open" : ""}" part="tool-panel" data-position="${n}" role="complementary" aria-label="${l?.title ?? "Tool panel"}" id="tbw-panel-${e.activePanel ?? "closed"}">
935
+ function Ge(o, e, t) {
936
+ const n = o?.toolPanel?.position ?? "right", i = e.toolPanels.size > 0, s = e.activePanel !== null, r = e.activePanel ? e.toolPanels.get(e.activePanel) : null, a = i ? `
937
+ <aside class="tbw-tool-panel${s ? " open" : ""}" part="tool-panel" data-position="${n}" role="complementary" aria-label="${r?.title ?? "Tool panel"}" id="tbw-panel-${e.activePanel ?? "closed"}">
927
938
  <div class="tbw-tool-panel-header">
928
- <span class="tbw-tool-panel-title">${l?.title ?? ""}</span>
939
+ <span class="tbw-tool-panel-title">${r?.title ?? ""}</span>
929
940
  <button class="tbw-tool-panel-close" aria-label="Close panel">✕</button>
930
941
  </div>
931
942
  <div class="tbw-tool-panel-content" role="region"></div>
@@ -933,7 +944,7 @@ function Fe(o, e, t) {
933
944
  ` : "";
934
945
  return n === "left" ? `
935
946
  <div class="tbw-shell-body">
936
- ${r}
947
+ ${a}
937
948
  <div class="tbw-grid-content">
938
949
  ${t}
939
950
  </div>
@@ -943,7 +954,7 @@ function Fe(o, e, t) {
943
954
  <div class="tbw-grid-content">
944
955
  ${t}
945
956
  </div>
946
- ${r}
957
+ ${a}
947
958
  </div>
948
959
  `;
949
960
  }
@@ -952,27 +963,27 @@ function ee(o, e) {
952
963
  if (!t) return;
953
964
  t.style.display = "none";
954
965
  const n = t.querySelectorAll("tbw-grid-header-content");
955
- e.lightDomHeaderContent = Array.from(n), e.lightDomHeaderContent.forEach((s, l) => {
966
+ e.lightDomHeaderContent = Array.from(n), e.lightDomHeaderContent.forEach((s, r) => {
956
967
  s.setAttribute("slot", "header-content");
957
968
  });
958
969
  const i = t.querySelectorAll("tbw-grid-tool-button");
959
- e.lightDomButtons = Array.from(i), e.lightDomButtons.sort((s, l) => {
960
- const r = parseInt(s.getAttribute("order") ?? "100", 10), a = parseInt(l.getAttribute("order") ?? "100", 10);
961
- return r - a;
970
+ e.lightDomButtons = Array.from(i), e.lightDomButtons.sort((s, r) => {
971
+ const a = parseInt(s.getAttribute("order") ?? "100", 10), l = parseInt(r.getAttribute("order") ?? "100", 10);
972
+ return a - l;
962
973
  }), e.lightDomButtons.forEach((s) => {
963
974
  s.setAttribute("slot", "toolbar");
964
975
  });
965
976
  }
966
- function Ve(o, e, t, n) {
977
+ function Ue(o, e, t, n) {
967
978
  const i = o.querySelector(".tbw-shell-toolbar");
968
- i && i.addEventListener("click", (l) => {
969
- const r = l.target, a = r.closest("[data-panel]");
970
- if (a) {
971
- const p = a.getAttribute("data-panel");
979
+ i && i.addEventListener("click", (r) => {
980
+ const a = r.target, l = a.closest("[data-panel]");
981
+ if (l) {
982
+ const p = l.getAttribute("data-panel");
972
983
  p && n.onPanelToggle(p);
973
984
  return;
974
985
  }
975
- const f = r.closest("[data-btn]");
986
+ const f = a.closest("[data-btn]");
976
987
  if (f) {
977
988
  const p = f.getAttribute("data-btn");
978
989
  p && n.onToolbarButtonClick(p);
@@ -983,34 +994,34 @@ function Ve(o, e, t, n) {
983
994
  n.onPanelClose();
984
995
  });
985
996
  }
986
- function Ge(o, e, t) {
997
+ function Xe(o, e, t) {
987
998
  const n = [...e?.header?.toolbarButtons ?? [], ...t.toolbarButtons.values()];
988
999
  for (const i of n) {
989
1000
  const s = o.querySelector(`[data-btn-slot="${i.id}"]`);
990
1001
  if (!s) continue;
991
- const l = t.toolbarButtonCleanups.get(i.id);
992
- if (l && (l(), t.toolbarButtonCleanups.delete(i.id)), i.element)
1002
+ const r = t.toolbarButtonCleanups.get(i.id);
1003
+ if (r && (r(), t.toolbarButtonCleanups.delete(i.id)), i.element)
993
1004
  s.appendChild(i.element);
994
1005
  else if (i.render) {
995
- const r = i.render(s);
996
- r && t.toolbarButtonCleanups.set(i.id, r);
1006
+ const a = i.render(s);
1007
+ a && t.toolbarButtonCleanups.set(i.id, a);
997
1008
  }
998
1009
  }
999
1010
  }
1000
1011
  function te(o, e) {
1001
1012
  const t = o.querySelector(".tbw-shell-content");
1002
1013
  if (!t) return;
1003
- const n = [...e.headerContents.values()].sort((s, l) => (s.order ?? 100) - (l.order ?? 100)), i = t.querySelector('slot[name="header-content"]');
1014
+ const n = [...e.headerContents.values()].sort((s, r) => (s.order ?? 100) - (r.order ?? 100)), i = t.querySelector('slot[name="header-content"]');
1004
1015
  for (const s of n) {
1005
- const l = e.headerContentCleanups.get(s.id);
1006
- l && (l(), e.headerContentCleanups.delete(s.id));
1007
- let r = t.querySelector(`[data-header-content="${s.id}"]`);
1008
- r || (r = document.createElement("div"), r.setAttribute("data-header-content", s.id), i ? t.insertBefore(r, i) : t.appendChild(r));
1009
- const a = s.render(r);
1010
- a && e.headerContentCleanups.set(s.id, a);
1016
+ const r = e.headerContentCleanups.get(s.id);
1017
+ r && (r(), e.headerContentCleanups.delete(s.id));
1018
+ let a = t.querySelector(`[data-header-content="${s.id}"]`);
1019
+ a || (a = document.createElement("div"), a.setAttribute("data-header-content", s.id), i ? t.insertBefore(a, i) : t.appendChild(a));
1020
+ const l = s.render(a);
1021
+ l && e.headerContentCleanups.set(s.id, l);
1011
1022
  }
1012
1023
  }
1013
- function Ue(o, e) {
1024
+ function je(o, e) {
1014
1025
  if (!e.activePanel) return;
1015
1026
  const t = e.toolPanels.get(e.activePanel);
1016
1027
  if (!t) return;
@@ -1035,7 +1046,7 @@ function ne(o, e) {
1035
1046
  s && (s.textContent = i?.title ?? ""), t.setAttribute("aria-label", `${i?.title ?? "Tool"} panel`), t.id = `tbw-panel-${e.activePanel}`;
1036
1047
  }
1037
1048
  }
1038
- function Xe(o, e) {
1049
+ function Ye(o, e) {
1039
1050
  const t = [];
1040
1051
  for (const n of o?.header?.toolbarButtons ?? [])
1041
1052
  t.push({
@@ -1070,7 +1081,7 @@ function Xe(o, e) {
1070
1081
  });
1071
1082
  return t;
1072
1083
  }
1073
- function je(o) {
1084
+ function Ze(o) {
1074
1085
  for (const e of o.headerContentCleanups.values())
1075
1086
  e();
1076
1087
  o.headerContentCleanups.clear(), o.activePanelCleanup && (o.activePanelCleanup(), o.activePanelCleanup = null);
@@ -1078,7 +1089,7 @@ function je(o) {
1078
1089
  e();
1079
1090
  o.toolbarButtonCleanups.clear(), o.activePanel && o.toolPanels.get(o.activePanel)?.onClose?.(), o.toolPanels.clear(), o.headerContents.clear(), o.toolbarButtons.clear(), o.lightDomButtons = [], o.lightDomHeaderContent = [], o.activePanel = null;
1080
1091
  }
1081
- class Ye {
1092
+ class Je {
1082
1093
  constructor(e) {
1083
1094
  this.grid = e;
1084
1095
  }
@@ -1212,6 +1223,39 @@ class Ye {
1212
1223
  for (const e of this.plugins)
1213
1224
  e.onScrollRender?.();
1214
1225
  }
1226
+ /**
1227
+ * Get total extra height contributed by plugins (e.g., expanded detail rows).
1228
+ * Used to adjust scrollbar height calculations.
1229
+ */
1230
+ getExtraHeight() {
1231
+ let e = 0;
1232
+ for (const t of this.plugins)
1233
+ typeof t.getExtraHeight == "function" && (e += t.getExtraHeight());
1234
+ return e;
1235
+ }
1236
+ /**
1237
+ * Get extra height from plugins that appears before a given row index.
1238
+ * Used by virtualization to correctly position the scroll window.
1239
+ */
1240
+ getExtraHeightBefore(e) {
1241
+ let t = 0;
1242
+ for (const n of this.plugins)
1243
+ typeof n.getExtraHeightBefore == "function" && (t += n.getExtraHeightBefore(e));
1244
+ return t;
1245
+ }
1246
+ /**
1247
+ * Adjust the virtualization start index based on plugin needs.
1248
+ * Returns the minimum start index from all plugins.
1249
+ */
1250
+ adjustVirtualStart(e, t, n) {
1251
+ let i = e;
1252
+ for (const s of this.plugins)
1253
+ if (typeof s.adjustVirtualStart == "function") {
1254
+ const r = s.adjustVirtualStart(e, t, n);
1255
+ r < i && (i = r);
1256
+ }
1257
+ return i;
1258
+ }
1215
1259
  /**
1216
1260
  * Execute renderRow hook on all plugins.
1217
1261
  * Returns true if any plugin handled the row.
@@ -1336,47 +1380,48 @@ class Ye {
1336
1380
  return e.sort((t, n) => (t.content.order ?? 0) - (n.content.order ?? 0));
1337
1381
  }
1338
1382
  }
1339
- class q extends HTMLElement {
1383
+ class I extends HTMLElement {
1340
1384
  // TODO: Rename to 'data-grid' when migration is complete
1341
1385
  static tagName = "tbw-grid";
1342
1386
  #o;
1343
1387
  #i = !1;
1344
1388
  // ---------------- Ready Promise ----------------
1345
- #H;
1346
1389
  #z;
1390
+ #N;
1347
1391
  // ================== INPUT PROPERTIES ==================
1348
1392
  // These backing fields store raw user input. They are merged into
1349
1393
  // #effectiveConfig by #mergeEffectiveConfig(). Never read directly
1350
1394
  // for rendering logic - always use effectiveConfig or derived state.
1351
- #l = [];
1352
- #r;
1353
- #p;
1395
+ #r = [];
1396
+ #l;
1354
1397
  #g;
1355
- #m;
1398
+ #v;
1399
+ #C;
1356
1400
  // ================== SINGLE SOURCE OF TRUTH ==================
1357
1401
  // All input sources converge here. This is the canonical config
1358
1402
  // that all rendering and logic should read from.
1359
1403
  #n = {};
1360
1404
  #f = !1;
1361
- #T = 0;
1362
- #v = null;
1363
- #C = !1;
1405
+ #p = 0;
1406
+ #E = null;
1407
+ #y = !1;
1364
1408
  // Cached flag for plugin scroll handlers
1365
- #L;
1409
+ #k;
1366
1410
  // Cached hook to avoid closures
1367
- #y = !1;
1368
- #E = null;
1369
- #R = null;
1411
+ #R = !1;
1370
1412
  #_ = null;
1371
1413
  #A = null;
1414
+ #S = null;
1415
+ #x = null;
1372
1416
  #a;
1417
+ #w;
1373
1418
  // ---------------- Plugin System ----------------
1374
1419
  #t;
1375
1420
  // ---------------- Column State ----------------
1376
- #k;
1421
+ #P;
1377
1422
  #h;
1378
1423
  // ---------------- Shell State ----------------
1379
- #e = $e();
1424
+ #e = We();
1380
1425
  #c = !1;
1381
1426
  // ================== DERIVED STATE ==================
1382
1427
  // _rows: result of applying plugin processRows hooks
@@ -1437,43 +1482,43 @@ class q extends HTMLElement {
1437
1482
  return this._rows;
1438
1483
  }
1439
1484
  set rows(e) {
1440
- const t = this.#l;
1441
- this.#l = e, t !== e && this.#Y();
1485
+ const t = this.#r;
1486
+ this.#r = e, t !== e && this.#Z();
1442
1487
  }
1443
1488
  /**
1444
1489
  * Get the original unfiltered/unprocessed rows.
1445
1490
  * Use this when you need access to all source data regardless of active filters.
1446
1491
  */
1447
1492
  get sourceRows() {
1448
- return this.#l;
1493
+ return this.#r;
1449
1494
  }
1450
1495
  get columns() {
1451
1496
  return [...this._columns];
1452
1497
  }
1453
1498
  set columns(e) {
1454
- const t = this.#r;
1455
- this.#r = e, t !== e && this.#Z();
1499
+ const t = this.#l;
1500
+ this.#l = e, t !== e && this.#J();
1456
1501
  }
1457
1502
  get gridConfig() {
1458
1503
  return this.#n;
1459
1504
  }
1460
1505
  set gridConfig(e) {
1461
- const t = this.#p;
1462
- this.#p = e, t !== e && this.#J();
1506
+ const t = this.#g;
1507
+ this.#g = e, t !== e && this.#Q();
1463
1508
  }
1464
1509
  get fitMode() {
1465
1510
  return this.#n.fitMode ?? "stretch";
1466
1511
  }
1467
1512
  set fitMode(e) {
1468
- const t = this.#g;
1469
- this.#g = e, t !== e && this.#X();
1513
+ const t = this.#v;
1514
+ this.#v = e, t !== e && this.#j();
1470
1515
  }
1471
1516
  get editOn() {
1472
1517
  return this.#n.editOn;
1473
1518
  }
1474
1519
  set editOn(e) {
1475
- const t = this.#m;
1476
- this.#m = e, t !== e && this.#j();
1520
+ const t = this.#C;
1521
+ this.#C = e, t !== e && this.#Y();
1477
1522
  }
1478
1523
  // Effective config accessor for internal modules and plugins
1479
1524
  // Returns the merged config (single source of truth) before plugin processing
@@ -1492,9 +1537,9 @@ class q extends HTMLElement {
1492
1537
  return this.#a || (this.#a = new AbortController()), this.#a.signal;
1493
1538
  }
1494
1539
  constructor() {
1495
- super(), this.#o = this.attachShadow({ mode: "open" }), this.#F(), this.#H = new Promise((e) => this.#z = e);
1540
+ super(), this.#o = this.attachShadow({ mode: "open" }), this.#V(), this.#z = new Promise((e) => this.#N = e);
1496
1541
  }
1497
- #F() {
1542
+ #V() {
1498
1543
  const e = new CSSStyleSheet();
1499
1544
  e.replaceSync(we), this.#o.adoptedStyleSheets = [e];
1500
1545
  }
@@ -1519,7 +1564,7 @@ class q extends HTMLElement {
1519
1564
  * Note: This does NOT reset plugin state - just re-processes rows/columns and renders.
1520
1565
  */
1521
1566
  requestRender() {
1522
- this.#x(), this.#P(), this.#S(), this.updateTemplate(), this.refreshVirtualWindow(!0);
1567
+ this.#L(), this.#M(), this.#T(), this.updateTemplate(), this.refreshVirtualWindow(!0);
1523
1568
  }
1524
1569
  /**
1525
1570
  * Request a lightweight style update without rebuilding DOM.
@@ -1527,14 +1572,14 @@ class q extends HTMLElement {
1527
1572
  * This runs all plugin afterRender hooks without rebuilding row/column DOM.
1528
1573
  */
1529
1574
  requestAfterRender() {
1530
- this.#w();
1575
+ this.#b();
1531
1576
  }
1532
1577
  /**
1533
1578
  * Initialize plugin system with instances from config.
1534
1579
  * Plugins are class instances passed in gridConfig.plugins[].
1535
1580
  */
1536
- #N() {
1537
- this.#t = new Ye(this);
1581
+ #I() {
1582
+ this.#t = new Je(this);
1538
1583
  const e = this.#n?.plugins, t = Array.isArray(e) ? e : [];
1539
1584
  this.#t.attachAll(t);
1540
1585
  }
@@ -1553,20 +1598,20 @@ class q extends HTMLElement {
1553
1598
  * Update plugins when grid config changes.
1554
1599
  * With class-based plugins, we need to detach old and attach new.
1555
1600
  */
1556
- #I() {
1557
- this.#t && this.#t.detachAll(), this.#N(), this.#q(), this.#C = this.#t?.getAll().some((e) => e.onScroll) ?? !1;
1601
+ #B() {
1602
+ this.#t && this.#t.detachAll(), this.#I(), this.#q(), this.#y = this.#t?.getAll().some((e) => e.onScroll) ?? !1;
1558
1603
  }
1559
1604
  /**
1560
1605
  * Clean up plugin states when grid disconnects.
1561
1606
  */
1562
- #V() {
1607
+ #G() {
1563
1608
  this.#t?.detachAll();
1564
1609
  }
1565
1610
  /**
1566
1611
  * Collect tool panels and header content from all plugins.
1567
1612
  * Called after plugins are attached but before render.
1568
1613
  */
1569
- #G() {
1614
+ #U() {
1570
1615
  if (!this.#t) return;
1571
1616
  const e = this.#t.getToolPanels();
1572
1617
  for (const { panel: n } of e)
@@ -1577,85 +1622,89 @@ class q extends HTMLElement {
1577
1622
  }
1578
1623
  // ---------------- Lifecycle ----------------
1579
1624
  connectedCallback() {
1580
- this.hasAttribute("tabindex") || (this.tabIndex = 0), this._rows = Array.isArray(this.#l) ? [...this.#l] : [], this.#a?.abort(), this.#a = new AbortController(), this.#u(), this.#N(), this.#G(), this.#i || (this.#W(), this.#q(), this.#i = !0), this.#B();
1625
+ this.hasAttribute("tabindex") || (this.tabIndex = 0), this._rows = Array.isArray(this.#r) ? [...this.#r] : [], this.#a?.abort(), this.#a = new AbortController(), this.#u(), this.#I(), this.#U(), this.#i || (this.#F(), this.#q(), this.#i = !0), this.#$();
1581
1626
  }
1582
1627
  disconnectedCallback() {
1583
- this.#V(), je(this.#e), this.#c = !1, this.#a && (this.#a.abort(), this.#a = void 0), this.resizeController && this.resizeController.dispose(), this.#f = !1;
1628
+ this.#G(), Ze(this.#e), this.#c = !1, this.#a && (this.#a.abort(), this.#a = void 0), this.resizeController && this.resizeController.dispose(), this.#w && (this.#w.disconnect(), this.#w = void 0), this.#f = !1;
1584
1629
  }
1585
- #B() {
1630
+ #$() {
1586
1631
  const t = this.#o.querySelector(".tbw-grid-content") ?? this.#o.querySelector(".tbw-grid-root");
1587
1632
  if (this.headerRowEl = t?.querySelector(".header-row"), this.virtualization.totalHeightEl = t?.querySelector(".faux-vscroll-spacer"), this.virtualization.viewportEl = t?.querySelector(".rows-viewport"), this.bodyEl = t?.querySelector(".rows"), this.#c) {
1588
- te(this.#o, this.#e), Ge(this.#o, this.#n?.shell, this.#e);
1589
- const l = this.#n?.shell?.toolPanel?.defaultOpen;
1590
- l && this.#e.toolPanels.has(l) && this.openToolPanel(l);
1633
+ te(this.#o, this.#e), Xe(this.#o, this.#n?.shell, this.#e);
1634
+ const r = this.#n?.shell?.toolPanel?.defaultOpen;
1635
+ r && this.#e.toolPanels.has(r) && this.openToolPanel(r);
1591
1636
  }
1592
1637
  this.setAttribute("data-upgraded", ""), this.hasAttribute("role") || this.setAttribute("role", "grid"), this.#f = !0;
1593
1638
  const n = this.disconnectSignal;
1594
- this.#d(), this.addEventListener("keydown", (l) => He(this, l), { signal: n }), document.addEventListener(
1639
+ this.#d(), this.addEventListener("keydown", (r) => ze(this, r), { signal: n }), document.addEventListener(
1595
1640
  "keydown",
1596
- (l) => {
1597
- l.key === "Escape" && this.activeEditRows !== -1 && this.#O(this.activeEditRows, !0);
1641
+ (r) => {
1642
+ r.key === "Escape" && this.activeEditRows !== -1 && this.#O(this.activeEditRows, !0);
1598
1643
  },
1599
1644
  { capture: !0, signal: n }
1600
1645
  ), document.addEventListener(
1601
1646
  "mousedown",
1602
- (l) => {
1647
+ (r) => {
1603
1648
  if (this.activeEditRows === -1) return;
1604
- const r = this.findRenderedRowElement(this.activeEditRows);
1605
- !r || (l.composedPath && l.composedPath() || []).includes(r) || this.#O(this.activeEditRows, !1);
1649
+ const a = this.findRenderedRowElement(this.activeEditRows);
1650
+ !a || (r.composedPath && r.composedPath() || []).includes(a) || this.#O(this.activeEditRows, !1);
1606
1651
  },
1607
1652
  { signal: n }
1608
1653
  );
1609
1654
  const i = t?.querySelector(".faux-vscroll"), s = t?.querySelector(".rows");
1610
- if (this.virtualization.container = i ?? this, this.#C = this.#t?.getAll().some((l) => l.onScroll) ?? !1, i && s) {
1655
+ if (this.virtualization.container = i ?? this, this.#y = this.#t?.getAll().some((r) => r.onScroll) ?? !1, i && s) {
1611
1656
  i.addEventListener(
1612
1657
  "scroll",
1613
1658
  () => {
1614
- if (!this.virtualization.enabled && !this.#C) return;
1615
- const a = i.scrollTop, f = this.virtualization.rowHeight, p = -(a % f);
1616
- s.style.transform = `translateY(${p}px)`, this.#v = a, this.#T || (this.#T = requestAnimationFrame(() => {
1617
- this.#T = 0, this.#v !== null && (this.#oe(this.#v), this.#v = null);
1659
+ if (!this.virtualization.enabled && !this.#y) return;
1660
+ const l = i.scrollTop, f = this.virtualization.rowHeight, p = Math.floor(l / f), g = p - p % 2, h = -(l - g * f);
1661
+ s.style.transform = `translateY(${h}px)`, this.#E = l, this.#p || (this.#p = requestAnimationFrame(() => {
1662
+ this.#p = 0, this.#E !== null && (this.#ne(this.#E), this.#E = null);
1618
1663
  }));
1619
1664
  },
1620
1665
  { passive: !0, signal: n }
1621
1666
  );
1622
- const l = this.#o.querySelector(".tbw-grid-content"), r = this.#o.querySelector(".tbw-scroll-area");
1623
- l && (l.addEventListener(
1667
+ const r = this.#o.querySelector(".tbw-grid-content"), a = this.#o.querySelector(".tbw-scroll-area");
1668
+ r && (r.addEventListener(
1624
1669
  "wheel",
1625
- (a) => {
1626
- a.preventDefault(), a.shiftKey || Math.abs(a.deltaX) > Math.abs(a.deltaY) ? r && (r.scrollLeft += a.shiftKey ? a.deltaY : a.deltaX) : i.scrollTop += a.deltaY;
1670
+ (l) => {
1671
+ l.preventDefault(), l.shiftKey || Math.abs(l.deltaX) > Math.abs(l.deltaY) ? a && (a.scrollLeft += l.shiftKey ? l.deltaY : l.deltaX) : i.scrollTop += l.deltaY;
1627
1672
  },
1628
1673
  { passive: !1, signal: n }
1629
- ), l.addEventListener(
1674
+ ), r.addEventListener(
1630
1675
  "touchstart",
1631
- (a) => {
1632
- a.touches.length === 1 && (this.#E = a.touches[0].clientY, this.#R = a.touches[0].clientX, this.#_ = i.scrollTop, this.#A = r?.scrollLeft ?? 0);
1676
+ (l) => {
1677
+ l.touches.length === 1 && (this.#_ = l.touches[0].clientY, this.#A = l.touches[0].clientX, this.#S = i.scrollTop, this.#x = a?.scrollLeft ?? 0);
1633
1678
  },
1634
1679
  { passive: !0, signal: n }
1635
- ), l.addEventListener(
1680
+ ), r.addEventListener(
1636
1681
  "touchmove",
1637
- (a) => {
1638
- if (a.touches.length === 1 && this.#E !== null && this.#R !== null && this.#_ !== null && this.#A !== null) {
1639
- const f = this.#E - a.touches[0].clientY, p = this.#R - a.touches[0].clientX;
1640
- i.scrollTop = this.#_ + f, r && (r.scrollLeft = this.#A + p), a.preventDefault();
1682
+ (l) => {
1683
+ if (l.touches.length === 1 && this.#_ !== null && this.#A !== null && this.#S !== null && this.#x !== null) {
1684
+ const f = this.#_ - l.touches[0].clientY, p = this.#A - l.touches[0].clientX;
1685
+ i.scrollTop = this.#S + f, a && (a.scrollLeft = this.#x + p), l.preventDefault();
1641
1686
  }
1642
1687
  },
1643
1688
  { passive: !1, signal: n }
1644
- ), l.addEventListener(
1689
+ ), r.addEventListener(
1645
1690
  "touchend",
1646
1691
  () => {
1647
- this.#E = null, this.#R = null, this.#_ = null, this.#A = null;
1692
+ this.#_ = null, this.#A = null, this.#S = null, this.#x = null;
1648
1693
  },
1649
1694
  { passive: !0, signal: n }
1650
1695
  ));
1651
1696
  }
1652
- this.resizeController = Be(this), this.#o.addEventListener("mousedown", (l) => this.#ne(l), { signal: n }), document.addEventListener("mousemove", (l) => this.#ie(l), { signal: n }), document.addEventListener("mouseup", (l) => this.#se(l), { signal: n }), this.virtualization.enabled && requestAnimationFrame(() => this.refreshVirtualWindow(!0)), requestAnimationFrame(() => {
1653
- const l = this.bodyEl.querySelector(".data-grid-row");
1654
- if (l) {
1655
- const r = l.getBoundingClientRect().height;
1656
- r && Math.abs(r - this.virtualization.rowHeight) > 0.1 && (this.virtualization.rowHeight = r, this.refreshVirtualWindow(!0));
1697
+ this.resizeController = Ke(this), this.#o.addEventListener("mousedown", (r) => this.#ie(r), { signal: n }), document.addEventListener("mousemove", (r) => this.#se(r), { signal: n }), document.addEventListener("mouseup", (r) => this.#re(r), { signal: n }), this.virtualization.enabled && requestAnimationFrame(() => this.refreshVirtualWindow(!0)), requestAnimationFrame(() => {
1698
+ const r = this.bodyEl.querySelector(".data-grid-row");
1699
+ if (r) {
1700
+ const a = r.getBoundingClientRect().height;
1701
+ a && Math.abs(a - this.virtualization.rowHeight) > 0.1 && (this.virtualization.rowHeight = a, this.refreshVirtualWindow(!0));
1657
1702
  }
1658
- }), queueMicrotask(() => this.#U()), requestAnimationFrame(() => requestAnimationFrame(() => this.#z?.()));
1703
+ }), this.virtualization.viewportEl && (this.#w = new ResizeObserver(() => {
1704
+ this.#p || (this.#p = requestAnimationFrame(() => {
1705
+ this.#p = 0, this.refreshVirtualWindow(!0);
1706
+ }));
1707
+ }), this.#w.observe(this.virtualization.viewportEl)), queueMicrotask(() => this.#X()), requestAnimationFrame(() => requestAnimationFrame(() => this.#N?.()));
1659
1708
  }
1660
1709
  // ---------------- Event Emitters ----------------
1661
1710
  #s(e, t) {
@@ -1677,67 +1726,67 @@ class q extends HTMLElement {
1677
1726
  this.#s("activate-cell", e);
1678
1727
  }
1679
1728
  /** Update ARIA selection attributes on rendered rows/cells */
1680
- #U() {
1729
+ #X() {
1681
1730
  this.bodyEl?.querySelectorAll(".data-grid-row")?.forEach((t, n) => {
1682
1731
  const i = n === this.focusRow;
1683
- t.setAttribute("aria-selected", String(i)), t.querySelectorAll(".cell").forEach((s, l) => {
1684
- s.setAttribute("aria-selected", String(i && l === this.focusCol));
1732
+ t.setAttribute("aria-selected", String(i)), t.querySelectorAll(".cell").forEach((s, r) => {
1733
+ s.setAttribute("aria-selected", String(i && r === this.focusCol));
1685
1734
  });
1686
1735
  });
1687
1736
  }
1688
1737
  // ---------------- Watch Handlers ----------------
1689
- #X() {
1738
+ #j() {
1690
1739
  if (!this.#f) return;
1691
- this.#u(), this.#n.fitMode === "fixed" ? (this.__didInitialAutoSize = !1, this.#$()) : (this._columns.forEach((t) => {
1740
+ this.#u(), this.#n.fitMode === "fixed" ? (this.__didInitialAutoSize = !1, this.#K()) : (this._columns.forEach((t) => {
1692
1741
  !t.__userResized && t.__autoSized && delete t.width;
1693
1742
  }), this.updateTemplate());
1694
1743
  }
1695
- #j() {
1696
- this.#f && (this.#u(), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.refreshVirtualWindow(!0));
1697
- }
1698
1744
  #Y() {
1699
- this._rows = Array.isArray(this.#l) ? [...this.#l] : [], this.#x(), !this.#r || Array.isArray(this.#r) && this.#r.length === 0 ? this.#d() : this.refreshVirtualWindow(!0);
1745
+ this.#f && (this.#u(), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.refreshVirtualWindow(!0));
1700
1746
  }
1701
1747
  #Z() {
1702
- j(this), this.#f && (this.#u(), this.#d());
1748
+ this._rows = Array.isArray(this.#r) ? [...this.#r] : [], this.#L(), !this.#l || Array.isArray(this.#l) && this.#l.length === 0 ? this.#d() : this.refreshVirtualWindow(!0);
1703
1749
  }
1704
1750
  #J() {
1705
- this.#f && (this.#u(), this.#I(), this.#x(), this.#P(), this.#S(), this.updateTemplate(), this.refreshVirtualWindow(!0));
1751
+ j(this), this.#f && (this.#u(), this.#d());
1706
1752
  }
1707
- // ---------------- Helper Wrappers ----------------
1708
1753
  #Q() {
1709
- Me(this);
1754
+ this.#f && (this.#u(), this.#B(), this.#L(), this.#M(), this.#T(), this.updateTemplate(), this.refreshVirtualWindow(!0));
1755
+ }
1756
+ // ---------------- Helper Wrappers ----------------
1757
+ #ee() {
1758
+ He(this);
1710
1759
  }
1711
- #S() {
1760
+ #T() {
1712
1761
  V(this);
1713
1762
  }
1714
1763
  updateTemplate() {
1715
- he(this);
1764
+ ue(this);
1716
1765
  }
1717
- #$() {
1766
+ #K() {
1718
1767
  Oe(this);
1719
1768
  }
1720
- #P() {
1769
+ #M() {
1721
1770
  if (this.#t) {
1722
1771
  const e = this._columns.filter((n) => !n.hidden), t = this.#t.processColumns([...e]);
1723
1772
  if (t !== e) {
1724
- const n = new Map(t.map((s, l) => [s.field, { col: s, order: l }])), i = this._columns.map((s) => {
1773
+ const n = new Map(t.map((s, r) => [s.field, { col: s, order: r }])), i = this._columns.map((s) => {
1725
1774
  if (s.hidden) return s;
1726
- const l = n.get(s.field);
1727
- return l ? l.col : s;
1775
+ const r = n.get(s.field);
1776
+ return r ? r.col : s;
1728
1777
  });
1729
1778
  this._columns = i;
1730
1779
  }
1731
1780
  }
1732
1781
  }
1733
1782
  /** Execute all plugin afterRender hooks */
1734
- #w() {
1783
+ #b() {
1735
1784
  this.#t?.afterRender();
1736
1785
  }
1737
1786
  /** Recompute row model via plugin hooks (grouping, tree, filtering, etc.). */
1738
- #x() {
1787
+ #L() {
1739
1788
  j(this);
1740
- const e = Array.isArray(this.#l) ? [...this.#l] : [], t = this.#t?.processRows(e) ?? e;
1789
+ const e = Array.isArray(this.#r) ? [...this.#r] : [], t = this.#t?.processRows(e) ?? e;
1741
1790
  this._rows = t;
1742
1791
  }
1743
1792
  /**
@@ -1759,7 +1808,7 @@ class q extends HTMLElement {
1759
1808
  * - Plugins receive config via their attach() method
1760
1809
  */
1761
1810
  #u() {
1762
- const e = this.#p ? { ...this.#p } : {};
1811
+ const e = this.#g ? { ...this.#g } : {};
1763
1812
  let t = Array.isArray(e.columns) ? [...e.columns] : [];
1764
1813
  const n = (this.__lightDomColumnsCache || []).map((i) => ({
1765
1814
  ...i
@@ -1767,39 +1816,39 @@ class q extends HTMLElement {
1767
1816
  if (n.length) {
1768
1817
  const i = {};
1769
1818
  t.forEach((s) => i[s.field] = s), n.forEach((s) => {
1770
- const l = i[s.field];
1771
- l ? (s.header && !l.header && (l.header = s.header), s.type && !l.type && (l.type = s.type), l.sortable = l.sortable || s.sortable, s.resizable && (l.resizable = !0), s.editable && (l.editable = !0)) : (t.push(s), i[s.field] = s);
1819
+ const r = i[s.field];
1820
+ r ? (s.header && !r.header && (r.header = s.header), s.type && !r.type && (r.type = s.type), r.sortable = r.sortable || s.sortable, s.resizable && (r.resizable = !0), s.editable && (r.editable = !0)) : (t.push(s), i[s.field] = s);
1772
1821
  });
1773
1822
  }
1774
- if (this.#r && this.#r.length && (t = [...this.#r]), (!t || t.length === 0) && this._rows.length && (t = ce(this._rows).columns), t.length) {
1775
- t.forEach((l) => {
1776
- l.sortable === void 0 && (l.sortable = !0), l.resizable === void 0 && (l.resizable = !0);
1823
+ if (this.#l && this.#l.length && (t = [...this.#l]), (!t || t.length === 0) && this._rows.length && (t = de(this._rows).columns), t.length) {
1824
+ t.forEach((r) => {
1825
+ r.sortable === void 0 && (r.sortable = !0), r.resizable === void 0 && (r.resizable = !0);
1777
1826
  });
1778
1827
  const i = this.#n.columns;
1779
- i?.some((l) => l.__compiledView || l.__compiledEditor) ? e.columns = i : e.columns = t;
1828
+ i?.some((r) => r.__compiledView || r.__compiledEditor) ? e.columns = i : e.columns = t;
1780
1829
  } else {
1781
1830
  const i = this.#n.columns;
1782
1831
  i?.some((s) => s.__compiledView || s.__compiledEditor) && (e.columns = i);
1783
1832
  }
1784
- this.#g && (e.fitMode = this.#g), e.fitMode || (e.fitMode = "stretch"), this.#m && (e.editOn = this.#m), e.columnState && !this.#h && (this.#h = e.columnState), this.#n = e, e.fitMode === "fixed" && this._columns.forEach((i) => {
1833
+ this.#v && (e.fitMode = this.#v), e.fitMode || (e.fitMode = "stretch"), this.#C && (e.editOn = this.#C), e.columnState && !this.#h && (this.#h = e.columnState), this.#n = e, e.fitMode === "fixed" && this._columns.forEach((i) => {
1785
1834
  i.width == null && (i.width = 80);
1786
1835
  });
1787
1836
  }
1788
1837
  // ---------------- Delegate Wrappers ----------------
1789
- #M(e, t, n = this.__rowRenderEpoch) {
1790
- this.#L || (this.#L = (i, s, l) => this.#t?.renderRow(i, s, l) ?? !1), qe(this, e, t, n, this.#L);
1838
+ #H(e, t, n = this.__rowRenderEpoch) {
1839
+ this.#k || (this.#k = (i, s, r) => this.#t?.renderRow(i, s, r) ?? !1), qe(this, e, t, n, this.#k);
1791
1840
  }
1792
- #ee(e, t) {
1841
+ #te(e, t) {
1793
1842
  T(this, e, t);
1794
1843
  }
1795
1844
  #O(e, t) {
1796
- Ie(this, e, t);
1845
+ Be(this, e, t);
1797
1846
  }
1798
1847
  // ---------------- Core Helpers ----------------
1799
1848
  #d() {
1800
1849
  if (!this.isConnected || !this.headerRowEl || !this.bodyEl)
1801
1850
  return;
1802
- const e = this.#p?.columns || this.#r || [];
1851
+ const e = this.#g?.columns || this.#l || [];
1803
1852
  if (e.length) {
1804
1853
  const n = new Map(this._columns.filter((s) => s.hidden).map((s) => [s.field, !0])), i = e.map((s) => ({
1805
1854
  ...s,
@@ -1807,26 +1856,26 @@ class q extends HTMLElement {
1807
1856
  }));
1808
1857
  this._columns = i;
1809
1858
  }
1810
- if (this.#Q(), this.#u(), this.#I(), this.#x(), this.#P(), this.#h) {
1859
+ if (this.#ee(), this.#u(), this.#B(), this.#L(), this.#M(), this.#h) {
1811
1860
  const n = this.#h;
1812
- this.#h = void 0, this.#K(n);
1861
+ this.#h = void 0, this.#W(n);
1813
1862
  }
1814
- this.#S(), this.updateTemplate(), this.refreshVirtualWindow(!0), this.#n.fitMode === "fixed" && !this.__didInitialAutoSize && requestAnimationFrame(() => this.#$()), this.bodyEl && (this.bodyEl.style.display = "", this.bodyEl.style.gridTemplateColumns = ""), queueMicrotask(() => this.#w());
1863
+ this.#T(), this.updateTemplate(), this.refreshVirtualWindow(!0), this.#n.fitMode === "fixed" && !this.__didInitialAutoSize && requestAnimationFrame(() => this.#K()), this.bodyEl && (this.bodyEl.style.display = "", this.bodyEl.style.gridTemplateColumns = ""), queueMicrotask(() => this.#b());
1815
1864
  }
1816
1865
  /** Internal method to apply column state without triggering setup loop */
1817
- #K(e) {
1866
+ #W(e) {
1818
1867
  const t = this.#n.columns ?? [], n = this.#t?.getAll() ?? [];
1819
- ge(this, e, t, n);
1868
+ me(this, e, t, n);
1820
1869
  for (const i of e.columns) {
1821
- const s = t.find((l) => l.field === i.field);
1870
+ const s = t.find((r) => r.field === i.field);
1822
1871
  s && (s.hidden = !i.visible);
1823
1872
  }
1824
1873
  }
1825
- #te() {
1874
+ #oe() {
1826
1875
  return this._rows.length <= this.virtualization.bypassThreshold;
1827
1876
  }
1828
- #oe(e) {
1829
- if (this.refreshVirtualWindow(!1), this.#t?.onScrollRender(), this.#C) {
1877
+ #ne(e) {
1878
+ if (this.refreshVirtualWindow(!1), this.#t?.onScrollRender(), this.#y) {
1830
1879
  const t = this.virtualization.container, n = {
1831
1880
  scrollTop: e,
1832
1881
  scrollLeft: t?.scrollLeft ?? 0,
@@ -1853,18 +1902,18 @@ class q extends HTMLElement {
1853
1902
  * Returns true if any plugin handled the event.
1854
1903
  */
1855
1904
  dispatchCellClick(e, t, n, i) {
1856
- const s = this._rows[t], l = this._columns[n];
1857
- if (!s || !l) return !1;
1858
- const r = {
1905
+ const s = this._rows[t], r = this._columns[n];
1906
+ if (!s || !r) return !1;
1907
+ const a = {
1859
1908
  row: s,
1860
1909
  rowIndex: t,
1861
1910
  colIndex: n,
1862
- field: l.field,
1863
- value: s[l.field],
1911
+ field: r.field,
1912
+ value: s[r.field],
1864
1913
  cellEl: i,
1865
1914
  originalEvent: e
1866
1915
  };
1867
- return this.#t?.onCellClick(r) ?? !1;
1916
+ return this.#t?.onCellClick(a) ?? !1;
1868
1917
  }
1869
1918
  /**
1870
1919
  * Dispatch a header click event to the plugin system.
@@ -1897,48 +1946,48 @@ class q extends HTMLElement {
1897
1946
  let n = null;
1898
1947
  const i = e.composedPath?.();
1899
1948
  if (i && i.length > 0 ? n = i[0] : n = e.target, n && !this.#o.contains(n)) {
1900
- const h = this.#o.elementFromPoint(e.clientX, e.clientY);
1901
- h && (n = h);
1949
+ const u = this.#o.elementFromPoint(e.clientX, e.clientY);
1950
+ u && (n = u);
1902
1951
  }
1903
- const s = n?.closest?.("[data-col]"), l = n?.closest?.(".data-grid-row"), r = n?.closest?.(".header-row");
1904
- let a, f, p, w, u, c;
1905
- return s && (a = parseInt(s.getAttribute("data-row") ?? "-1", 10), f = parseInt(s.getAttribute("data-col") ?? "-1", 10), a >= 0 && f >= 0 && (p = this._rows[a], c = this._columns[f], w = c?.field, u = p && w ? p[w] : void 0)), {
1952
+ const s = n?.closest?.("[data-col]"), r = n?.closest?.(".data-grid-row"), a = n?.closest?.(".header-row");
1953
+ let l, f, p, g, h, c;
1954
+ return s && (l = parseInt(s.getAttribute("data-row") ?? "-1", 10), f = parseInt(s.getAttribute("data-col") ?? "-1", 10), l >= 0 && f >= 0 && (p = this._rows[l], c = this._columns[f], g = c?.field, h = p && g ? p[g] : void 0)), {
1906
1955
  type: t,
1907
1956
  row: p,
1908
- rowIndex: a !== void 0 && a >= 0 ? a : void 0,
1957
+ rowIndex: l !== void 0 && l >= 0 ? l : void 0,
1909
1958
  colIndex: f !== void 0 && f >= 0 ? f : void 0,
1910
- field: w,
1911
- value: u,
1959
+ field: g,
1960
+ value: h,
1912
1961
  column: c,
1913
1962
  originalEvent: e,
1914
1963
  cellElement: s ?? void 0,
1915
- rowElement: l ?? void 0,
1916
- isHeader: !!r,
1917
- cell: a !== void 0 && f !== void 0 && a >= 0 && f >= 0 ? { row: a, col: f } : void 0
1964
+ rowElement: r ?? void 0,
1965
+ isHeader: !!a,
1966
+ cell: l !== void 0 && f !== void 0 && l >= 0 && f >= 0 ? { row: l, col: f } : void 0
1918
1967
  };
1919
1968
  }
1920
1969
  /**
1921
1970
  * Handle mousedown events and dispatch to plugin system.
1922
1971
  */
1923
- #ne(e) {
1972
+ #ie(e) {
1924
1973
  const t = this.#D(e, "mousedown");
1925
- (this.#t?.onCellMouseDown(t) ?? !1) && (this.#y = !0);
1974
+ (this.#t?.onCellMouseDown(t) ?? !1) && (this.#R = !0);
1926
1975
  }
1927
1976
  /**
1928
1977
  * Handle mousemove events (only when dragging).
1929
1978
  */
1930
- #ie(e) {
1931
- if (!this.#y) return;
1979
+ #se(e) {
1980
+ if (!this.#R) return;
1932
1981
  const t = this.#D(e, "mousemove");
1933
1982
  this.#t?.onCellMouseMove(t);
1934
1983
  }
1935
1984
  /**
1936
1985
  * Handle mouseup events.
1937
1986
  */
1938
- #se(e) {
1939
- if (!this.#y) return;
1987
+ #re(e) {
1988
+ if (!this.#R) return;
1940
1989
  const t = this.#D(e, "mouseup");
1941
- this.#t?.onCellMouseUp(t), this.#y = !1;
1990
+ this.#t?.onCellMouseUp(t), this.#R = !1;
1942
1991
  }
1943
1992
  // API consumed by internal utils (rows.ts)
1944
1993
  get changedRows() {
@@ -1951,13 +2000,13 @@ class q extends HTMLElement {
1951
2000
  this._changedRowIndices.clear(), e || this.#s("changed-rows-reset", { rows: this.changedRows, indices: this.changedRowIndices }), this.rowPool.forEach((t) => t.classList.remove("changed"));
1952
2001
  }
1953
2002
  async beginBulkEdit(e) {
1954
- this.#ee(e, this._rows[e]);
2003
+ this.#te(e, this._rows[e]);
1955
2004
  }
1956
2005
  async commitActiveRowEdit() {
1957
2006
  this.activeEditRows !== -1 && this.#O(this.activeEditRows, !1);
1958
2007
  }
1959
2008
  async ready() {
1960
- return this.#H;
2009
+ return this.#z;
1961
2010
  }
1962
2011
  async forceLayout() {
1963
2012
  this.#d(), await new Promise((e) => requestAnimationFrame(() => requestAnimationFrame(e)));
@@ -1974,14 +2023,14 @@ class q extends HTMLElement {
1974
2023
  * @returns True if visibility was changed, false if column not found or locked
1975
2024
  */
1976
2025
  setColumnVisible(e, t) {
1977
- const n = this.#n.columns, i = n?.find((r) => r.field === e);
1978
- if (!i || !t && i.lockVisible || !t && (n ?? []).filter((a) => !a.hidden && a.field !== e).length === 0)
2026
+ const n = this.#n.columns, i = n?.find((a) => a.field === e);
2027
+ if (!i || !t && i.lockVisible || !t && (n ?? []).filter((l) => !l.hidden && l.field !== e).length === 0)
1979
2028
  return !1;
1980
- const s = !!i.hidden, l = !t;
1981
- return s !== l ? (i.hidden = l, this.#s("column-visibility", {
2029
+ const s = !!i.hidden, r = !t;
2030
+ return s !== r ? (i.hidden = r, this.#s("column-visibility", {
1982
2031
  field: e,
1983
2032
  visible: t,
1984
- visibleColumns: (n ?? []).filter((r) => !r.hidden).map((r) => r.field)
2033
+ visibleColumns: (n ?? []).filter((a) => !a.hidden).map((a) => a.field)
1985
2034
  }), this.rowPool.length = 0, this.bodyEl && (this.bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.#d(), this.requestStateChange(), !0) : !1;
1986
2035
  }
1987
2036
  /**
@@ -2041,7 +2090,7 @@ class q extends HTMLElement {
2041
2090
  }
2042
2091
  for (const i of t.values())
2043
2092
  n.push(i);
2044
- this._columns = n, this.#S(), this.updateTemplate(), this.refreshVirtualWindow(!0);
2093
+ this._columns = n, this.#T(), this.updateTemplate(), this.refreshVirtualWindow(!0);
2045
2094
  }
2046
2095
  /**
2047
2096
  * Get the current column order as an array of field names.
@@ -2078,7 +2127,7 @@ class q extends HTMLElement {
2078
2127
  #le(e) {
2079
2128
  (this.#n.columns ?? []).forEach((n) => {
2080
2129
  n.hidden = !1;
2081
- }), this.#K(e), this.#d();
2130
+ }), this.#W(e), this.#d();
2082
2131
  }
2083
2132
  /**
2084
2133
  * Request a state change event to be emitted.
@@ -2087,11 +2136,11 @@ class q extends HTMLElement {
2087
2136
  * The event is debounced to avoid excessive events during drag operations.
2088
2137
  */
2089
2138
  requestStateChange() {
2090
- this.#k || (this.#k = me(
2139
+ this.#P || (this.#P = ve(
2091
2140
  this,
2092
2141
  () => this.#t?.getAll() ?? [],
2093
2142
  (e) => this.#s("column-state-change", e)
2094
- )), this.#k();
2143
+ )), this.#P();
2095
2144
  }
2096
2145
  /**
2097
2146
  * Reset column state to initial configuration.
@@ -2128,7 +2177,7 @@ class q extends HTMLElement {
2128
2177
  console.warn(`[tbw-grid] Tool panel "${e}" not found`);
2129
2178
  return;
2130
2179
  }
2131
- this.#e.activePanel && this.#e.activePanel !== e && this.closeToolPanel(), this.#e.activePanel = e, oe(this.#o, this.#e), ne(this.#o, this.#e), Ue(this.#o, this.#e), this.#s("tool-panel-open", { id: e });
2180
+ this.#e.activePanel && this.#e.activePanel !== e && this.closeToolPanel(), this.#e.activePanel = e, oe(this.#o, this.#e), ne(this.#o, this.#e), je(this.#o, this.#e), this.#s("tool-panel-open", { id: e });
2132
2181
  }
2133
2182
  /**
2134
2183
  * Close the currently open tool panel.
@@ -2158,13 +2207,13 @@ class q extends HTMLElement {
2158
2207
  console.warn(`[tbw-grid] Tool panel "${e.id}" already registered`);
2159
2208
  return;
2160
2209
  }
2161
- this.#e.toolPanels.set(e.id, e), this.#c && this.#b();
2210
+ this.#e.toolPanels.set(e.id, e), this.#c && this.#m();
2162
2211
  }
2163
2212
  /**
2164
2213
  * Unregister a custom tool panel.
2165
2214
  */
2166
2215
  unregisterToolPanel(e) {
2167
- this.#e.activePanel === e && this.closeToolPanel(), this.#e.toolPanels.delete(e), this.#c && this.#b();
2216
+ this.#e.activePanel === e && this.closeToolPanel(), this.#e.toolPanels.delete(e), this.#c && this.#m();
2168
2217
  }
2169
2218
  /**
2170
2219
  * Get registered header content definitions.
@@ -2193,7 +2242,7 @@ class q extends HTMLElement {
2193
2242
  * Get all registered toolbar buttons.
2194
2243
  */
2195
2244
  getToolbarButtons() {
2196
- return Xe(this.#n?.shell, this.#e);
2245
+ return Ye(this.#n?.shell, this.#e);
2197
2246
  }
2198
2247
  /**
2199
2248
  * Register a custom toolbar button programmatically.
@@ -2203,14 +2252,14 @@ class q extends HTMLElement {
2203
2252
  console.warn(`[tbw-grid] Toolbar button "${e.id}" already registered`);
2204
2253
  return;
2205
2254
  }
2206
- this.#e.toolbarButtons.set(e.id, e), this.#c && this.#b();
2255
+ this.#e.toolbarButtons.set(e.id, e), this.#c && this.#m();
2207
2256
  }
2208
2257
  /**
2209
2258
  * Unregister a custom toolbar button.
2210
2259
  */
2211
2260
  unregisterToolbarButton(e) {
2212
2261
  const t = this.#e.toolbarButtonCleanups.get(e);
2213
- t && (t(), this.#e.toolbarButtonCleanups.delete(e)), this.#e.toolbarButtons.delete(e), this.#c && this.#b();
2262
+ t && (t(), this.#e.toolbarButtonCleanups.delete(e)), this.#e.toolbarButtons.delete(e), this.#c && this.#m();
2214
2263
  }
2215
2264
  /**
2216
2265
  * Enable/disable a toolbar button by ID.
@@ -2226,13 +2275,13 @@ class q extends HTMLElement {
2226
2275
  * Call this after dynamically modifying <tbw-grid-header> children.
2227
2276
  */
2228
2277
  refreshShellHeader() {
2229
- this.#b();
2278
+ this.#m();
2230
2279
  }
2231
2280
  /**
2232
2281
  * Internal shell header refresh.
2233
2282
  */
2234
- #b() {
2235
- ee(this, this.#e), this.#W(), this.#B();
2283
+ #m() {
2284
+ ee(this, this.#e), this.#F(), this.#$();
2236
2285
  }
2237
2286
  // ---------------- Virtual Window ----------------
2238
2287
  /**
@@ -2243,26 +2292,36 @@ class q extends HTMLElement {
2243
2292
  if (!this.bodyEl) return;
2244
2293
  const t = this._rows.length;
2245
2294
  if (!this.virtualization.enabled) {
2246
- this.#M(0, t), this.#w();
2295
+ this.#H(0, t), this.#b();
2247
2296
  return;
2248
2297
  }
2249
- if (this.#te()) {
2250
- this.virtualization.start = 0, this.virtualization.end = t, this.bodyEl.style.transform = "translateY(0px)", this.#M(0, t, this.__rowRenderEpoch), this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${t * this.virtualization.rowHeight}px`), this.setAttribute("aria-rowcount", String(t)), this.setAttribute("aria-colcount", String(this.visibleColumns.length)), this.#w();
2298
+ if (this.#oe()) {
2299
+ this.virtualization.start = 0, this.virtualization.end = t, this.bodyEl.style.transform = "translateY(0px)", this.#H(0, t, this.__rowRenderEpoch), this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${t * this.virtualization.rowHeight}px`), this.setAttribute("aria-rowcount", String(t)), this.setAttribute("aria-colcount", String(this.visibleColumns.length)), this.#b();
2251
2300
  return;
2252
2301
  }
2253
- const n = this.virtualization.container ?? this, s = (this.virtualization.viewportEl ?? n).clientHeight, l = this.virtualization.rowHeight, r = n.scrollTop;
2254
- let a = Math.floor(r / l);
2255
- a < 0 && (a = 0);
2256
- const f = Math.ceil(s / l) + 2;
2257
- let p = a + f;
2258
- p > t && (p = t), this.virtualization.start = a, this.virtualization.end = p, this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${t * l}px`);
2259
- const w = -(r % l);
2260
- this.bodyEl.style.transform = `translateY(${w}px)`, this.#M(a, p, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch), this.setAttribute("aria-rowcount", String(t)), this.setAttribute("aria-colcount", String(this.visibleColumns.length)), e && this.#w();
2302
+ const n = this.virtualization.container ?? this, s = (this.virtualization.viewportEl ?? n).clientHeight, r = this.virtualization.rowHeight, a = n.scrollTop;
2303
+ let l = Math.floor(a / r), f = 0;
2304
+ const p = 10;
2305
+ for (; f < p; ) {
2306
+ const R = this.#t?.getExtraHeightBefore?.(l) ?? 0, E = Math.floor((a - R) / r);
2307
+ if (E >= l || E < 0) break;
2308
+ l = E, f++;
2309
+ }
2310
+ l = l - l % 2, l < 0 && (l = 0);
2311
+ const g = this.#t?.adjustVirtualStart(l, a, r);
2312
+ g !== void 0 && g < l && (l = g, l = l - l % 2, l < 0 && (l = 0));
2313
+ const h = Math.ceil(s / r) + 3;
2314
+ let c = l + h;
2315
+ c > t && (c = t), this.virtualization.start = l, this.virtualization.end = c;
2316
+ const d = this.#o.querySelector(".tbw-footer")?.offsetHeight ?? 0, b = this.#t?.getExtraHeight() ?? 0;
2317
+ this.virtualization.totalHeightEl && (this.virtualization.totalHeightEl.style.height = `${t * r + r + d + b}px`);
2318
+ const m = this.#t?.getExtraHeightBefore?.(l) ?? 0, C = -(a - l * r - m);
2319
+ this.bodyEl.style.transform = `translateY(${C}px)`, this.#H(l, c, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch), this.setAttribute("aria-rowcount", String(t)), this.setAttribute("aria-colcount", String(this.visibleColumns.length)), e && this.#b();
2261
2320
  }
2262
2321
  // ---------------- Render ----------------
2263
- #W() {
2322
+ #F() {
2264
2323
  ee(this, this.#e);
2265
- const e = this.#n?.shell, t = Ke(e, this.#e), n = `
2324
+ const e = this.#n?.shell, t = Fe(e, this.#e), n = `
2266
2325
  <div class="tbw-scroll-area">
2267
2326
  <div class="rows-body-wrapper">
2268
2327
  <div class="rows-body">
@@ -2282,13 +2341,13 @@ class q extends HTMLElement {
2282
2341
  </div>
2283
2342
  `;
2284
2343
  if (t) {
2285
- const i = We(e, this.#e), s = Fe(e, this.#e, n);
2344
+ const i = Ve(e, this.#e), s = Ge(e, this.#e, n);
2286
2345
  this.#o.innerHTML = `
2287
2346
  <div class="tbw-grid-root has-shell">
2288
2347
  ${i}
2289
2348
  ${s}
2290
2349
  </div>
2291
- `, this.#re(), this.#c = !0;
2350
+ `, this.#ae(), this.#c = !0;
2292
2351
  } else
2293
2352
  this.#o.innerHTML = `
2294
2353
  <div class="tbw-grid-root">
@@ -2301,17 +2360,17 @@ class q extends HTMLElement {
2301
2360
  /**
2302
2361
  * Set up shell event listeners after render.
2303
2362
  */
2304
- #re() {
2305
- Ve(this.#o, this.#n?.shell, this.#e, {
2363
+ #ae() {
2364
+ Ue(this.#o, this.#n?.shell, this.#e, {
2306
2365
  onPanelToggle: (e) => this.toggleToolPanel(e),
2307
2366
  onPanelClose: () => this.closeToolPanel(),
2308
- onToolbarButtonClick: (e) => this.#ae(e)
2367
+ onToolbarButtonClick: (e) => this.#ce(e)
2309
2368
  });
2310
2369
  }
2311
2370
  /**
2312
2371
  * Handle toolbar button click (for config buttons with action).
2313
2372
  */
2314
- #ae(e) {
2373
+ #ce(e) {
2315
2374
  const n = (this.#n?.shell?.header?.toolbarButtons ?? []).find((s) => s.id === e);
2316
2375
  if (n?.action) {
2317
2376
  n.action();
@@ -2321,8 +2380,8 @@ class q extends HTMLElement {
2321
2380
  i?.action && i.action();
2322
2381
  }
2323
2382
  }
2324
- customElements.get(q.tagName) || customElements.define(q.tagName, q);
2325
- class ue {
2383
+ customElements.get(I.tagName) || customElements.define(I.tagName, I);
2384
+ class fe {
2326
2385
  /** Plugin version - override in subclass if needed */
2327
2386
  version = "1.0.0";
2328
2387
  /** CSS styles to inject into the grid's shadow DOM */
@@ -2441,6 +2500,35 @@ class ue {
2441
2500
  get disconnectSignal() {
2442
2501
  return this.grid?.disconnectSignal;
2443
2502
  }
2503
+ /**
2504
+ * Get the grid-level icons configuration.
2505
+ * Returns merged icons (user config + defaults).
2506
+ */
2507
+ get gridIcons() {
2508
+ const e = this.grid?.gridConfig?.icons ?? {};
2509
+ return { ...ce, ...e };
2510
+ }
2511
+ /**
2512
+ * Resolve an icon value to string or HTMLElement.
2513
+ * Checks plugin config first, then grid-level icons, then defaults.
2514
+ *
2515
+ * @param iconKey - The icon key in GridIcons (e.g., 'expand', 'collapse')
2516
+ * @param pluginOverride - Optional plugin-level override
2517
+ * @returns The resolved icon value
2518
+ */
2519
+ resolveIcon(e, t) {
2520
+ return t !== void 0 ? t : this.gridIcons[e];
2521
+ }
2522
+ /**
2523
+ * Set an icon value on an element.
2524
+ * Handles both string (text/HTML) and HTMLElement values.
2525
+ *
2526
+ * @param element - The element to set the icon on
2527
+ * @param icon - The icon value (string or HTMLElement)
2528
+ */
2529
+ setIcon(e, t) {
2530
+ typeof t == "string" ? e.innerHTML = t : t instanceof HTMLElement && (e.innerHTML = "", e.appendChild(t.cloneNode(!0)));
2531
+ }
2444
2532
  /**
2445
2533
  * Log a warning message.
2446
2534
  */
@@ -2456,7 +2544,7 @@ function N(o) {
2456
2544
  endCol: Math.max(o.startCol, o.endCol)
2457
2545
  };
2458
2546
  }
2459
- function Ze(o) {
2547
+ function Qe(o) {
2460
2548
  const e = N(o);
2461
2549
  return {
2462
2550
  from: { row: e.startRow, col: e.startCol },
@@ -2464,26 +2552,26 @@ function Ze(o) {
2464
2552
  };
2465
2553
  }
2466
2554
  function K(o) {
2467
- return o.map(Ze);
2555
+ return o.map(Qe);
2468
2556
  }
2469
- function Je(o, e, t) {
2557
+ function et(o, e, t) {
2470
2558
  const n = N(t);
2471
2559
  return o >= n.startRow && o <= n.endRow && e >= n.startCol && e <= n.endCol;
2472
2560
  }
2473
2561
  function ie(o, e, t) {
2474
- return t.some((n) => Je(o, e, n));
2562
+ return t.some((n) => et(o, e, n));
2475
2563
  }
2476
- function Qe(o) {
2564
+ function tt(o) {
2477
2565
  const e = [], t = N(o);
2478
2566
  for (let n = t.startRow; n <= t.endRow; n++)
2479
2567
  for (let i = t.startCol; i <= t.endCol; i++)
2480
2568
  e.push({ row: n, col: i });
2481
2569
  return e;
2482
2570
  }
2483
- function et(o) {
2571
+ function ot(o) {
2484
2572
  const e = /* @__PURE__ */ new Map();
2485
2573
  for (const t of o)
2486
- for (const n of Qe(t))
2574
+ for (const n of tt(t))
2487
2575
  e.set(`${n.row},${n.col}`, n);
2488
2576
  return [...e.values()];
2489
2577
  }
@@ -2495,7 +2583,7 @@ function se(o, e) {
2495
2583
  endCol: e.col
2496
2584
  };
2497
2585
  }
2498
- function tt(o, e, t) {
2586
+ function nt(o, e, t) {
2499
2587
  if (o === "cell" && e.selectedCell)
2500
2588
  return {
2501
2589
  mode: o,
@@ -2515,7 +2603,7 @@ function tt(o, e, t) {
2515
2603
  }
2516
2604
  return o === "range" && e.ranges.length > 0 ? { mode: o, ranges: K(e.ranges) } : { mode: o, ranges: [] };
2517
2605
  }
2518
- class st extends ue {
2606
+ class lt extends fe {
2519
2607
  name = "selection";
2520
2608
  version = "1.0.0";
2521
2609
  get defaultConfig() {
@@ -2547,26 +2635,26 @@ class st extends ue {
2547
2635
  if (s === "row")
2548
2636
  return this.selected.clear(), this.selected.add(t), this.lastSelected = t, this.emit("selection-change", this.#i()), this.requestAfterRender(), !1;
2549
2637
  if (s === "range") {
2550
- const l = i.shiftKey, r = i.ctrlKey || i.metaKey;
2551
- if (l && this.cellAnchor) {
2552
- const a = se(this.cellAnchor, { row: t, col: n });
2553
- r ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = a : this.ranges.push(a) : this.ranges = [a], this.activeRange = a;
2554
- } else if (r) {
2555
- const a = {
2638
+ const r = i.shiftKey, a = i.ctrlKey || i.metaKey;
2639
+ if (r && this.cellAnchor) {
2640
+ const l = se(this.cellAnchor, { row: t, col: n });
2641
+ a ? this.ranges.length > 0 ? this.ranges[this.ranges.length - 1] = l : this.ranges.push(l) : this.ranges = [l], this.activeRange = l;
2642
+ } else if (a) {
2643
+ const l = {
2556
2644
  startRow: t,
2557
2645
  startCol: n,
2558
2646
  endRow: t,
2559
2647
  endCol: n
2560
2648
  };
2561
- this.ranges.push(a), this.activeRange = a, this.cellAnchor = { row: t, col: n };
2649
+ this.ranges.push(l), this.activeRange = l, this.cellAnchor = { row: t, col: n };
2562
2650
  } else {
2563
- const a = {
2651
+ const l = {
2564
2652
  startRow: t,
2565
2653
  startCol: n,
2566
2654
  endRow: t,
2567
2655
  endCol: n
2568
2656
  };
2569
- this.ranges = [a], this.activeRange = a, this.cellAnchor = { row: t, col: n };
2657
+ this.ranges = [l], this.activeRange = l, this.cellAnchor = { row: t, col: n };
2570
2658
  }
2571
2659
  return this.emit("selection-change", this.#i()), this.requestAfterRender(), !1;
2572
2660
  }
@@ -2628,13 +2716,13 @@ class st extends ue {
2628
2716
  if (i.forEach((s) => {
2629
2717
  s.classList.remove("selected", "row-focus");
2630
2718
  }), t === "row" && i.forEach((s) => {
2631
- const l = s.querySelector(".cell[data-row]"), r = parseInt(l?.getAttribute("data-row") ?? "-1", 10);
2632
- r >= 0 && this.selected.has(r) && (s.classList.add("selected", "row-focus"), s.querySelectorAll(".cell-focus").forEach((a) => a.classList.remove("cell-focus")));
2719
+ const r = s.querySelector(".cell[data-row]"), a = parseInt(r?.getAttribute("data-row") ?? "-1", 10);
2720
+ a >= 0 && this.selected.has(a) && (s.classList.add("selected", "row-focus"), s.querySelectorAll(".cell-focus").forEach((l) => l.classList.remove("cell-focus")));
2633
2721
  }), t === "range" && this.ranges.length > 0) {
2634
2722
  const s = this.activeRange ? N(this.activeRange) : null;
2635
- e.querySelectorAll(".cell[data-row][data-col]").forEach((r) => {
2636
- const a = parseInt(r.getAttribute("data-row") ?? "-1", 10), f = parseInt(r.getAttribute("data-col") ?? "-1", 10);
2637
- a >= 0 && f >= 0 && ie(a, f, this.ranges) && (r.classList.add("selected"), r.classList.remove("cell-focus"), s && (a === s.startRow && r.classList.add("top"), a === s.endRow && r.classList.add("bottom"), f === s.startCol && r.classList.add("first"), f === s.endCol && r.classList.add("last")));
2723
+ e.querySelectorAll(".cell[data-row][data-col]").forEach((a) => {
2724
+ const l = parseInt(a.getAttribute("data-row") ?? "-1", 10), f = parseInt(a.getAttribute("data-col") ?? "-1", 10);
2725
+ l >= 0 && f >= 0 && ie(l, f, this.ranges) && (a.classList.add("selected"), a.classList.remove("cell-focus"), s && (l === s.startRow && a.classList.add("top"), l === s.endRow && a.classList.add("bottom"), f === s.startCol && a.classList.add("first"), f === s.endCol && a.classList.add("last")));
2638
2726
  });
2639
2727
  }
2640
2728
  t === "cell" && this.selectedCell && e.querySelectorAll(".cell-focus").forEach((s) => s.classList.remove("cell-focus"));
@@ -2675,7 +2763,7 @@ class st extends ue {
2675
2763
  * Get all selected cells across all ranges.
2676
2764
  */
2677
2765
  getSelectedCells() {
2678
- return et(this.ranges);
2766
+ return ot(this.ranges);
2679
2767
  }
2680
2768
  /**
2681
2769
  * Check if a specific cell is in range selection.
@@ -2705,7 +2793,7 @@ class st extends ue {
2705
2793
  }
2706
2794
  // ===== Private Helpers =====
2707
2795
  #i() {
2708
- return tt(
2796
+ return nt(
2709
2797
  this.config.mode,
2710
2798
  {
2711
2799
  selectedCell: this.selectedCell,
@@ -2753,74 +2841,74 @@ class st extends ue {
2753
2841
  function G(o, e, t) {
2754
2842
  return o.id !== void 0 ? String(o.id) : t ? `${t}-${e}` : String(e);
2755
2843
  }
2756
- function fe(o, e, t, n = null, i = 0) {
2757
- const s = e.childrenField ?? "children", l = [];
2758
- for (let r = 0; r < o.length; r++) {
2759
- const a = o[r], f = G(a, r, n), p = a[s], w = Array.isArray(p) && p.length > 0, u = t.has(f);
2760
- if (l.push({
2844
+ function pe(o, e, t, n = null, i = 0) {
2845
+ const s = e.childrenField ?? "children", r = [];
2846
+ for (let a = 0; a < o.length; a++) {
2847
+ const l = o[a], f = G(l, a, n), p = l[s], g = Array.isArray(p) && p.length > 0, h = t.has(f);
2848
+ if (r.push({
2761
2849
  key: f,
2762
- data: a,
2850
+ data: l,
2763
2851
  depth: i,
2764
- hasChildren: w,
2765
- isExpanded: u,
2852
+ hasChildren: g,
2853
+ isExpanded: h,
2766
2854
  parentKey: n
2767
- }), w && u) {
2768
- const c = fe(p, e, t, f, i + 1);
2769
- l.push(...c);
2855
+ }), g && h) {
2856
+ const c = pe(p, e, t, f, i + 1);
2857
+ r.push(...c);
2770
2858
  }
2771
2859
  }
2772
- return l;
2860
+ return r;
2773
2861
  }
2774
- function le(o, e) {
2862
+ function re(o, e) {
2775
2863
  const t = new Set(o);
2776
2864
  return t.has(e) ? t.delete(e) : t.add(e), t;
2777
2865
  }
2778
2866
  function W(o, e, t = null, n = 0) {
2779
2867
  const i = e.childrenField ?? "children", s = /* @__PURE__ */ new Set();
2780
- for (let l = 0; l < o.length; l++) {
2781
- const r = o[l], a = G(r, l, t), f = r[i];
2868
+ for (let r = 0; r < o.length; r++) {
2869
+ const a = o[r], l = G(a, r, t), f = a[i];
2782
2870
  if (Array.isArray(f) && f.length > 0) {
2783
- s.add(a);
2784
- const p = W(f, e, a, n + 1);
2785
- for (const w of p) s.add(w);
2871
+ s.add(l);
2872
+ const p = W(f, e, l, n + 1);
2873
+ for (const g of p) s.add(g);
2786
2874
  }
2787
2875
  }
2788
2876
  return s;
2789
2877
  }
2790
- function ot() {
2878
+ function it() {
2791
2879
  return /* @__PURE__ */ new Set();
2792
2880
  }
2793
- function pe(o, e, t, n = null, i = 0) {
2881
+ function ge(o, e, t, n = null, i = 0) {
2794
2882
  const s = t.childrenField ?? "children";
2795
- for (let l = 0; l < o.length; l++) {
2796
- const r = o[l], a = G(r, l, n);
2797
- if (a === e)
2798
- return [a];
2799
- const f = r[s];
2883
+ for (let r = 0; r < o.length; r++) {
2884
+ const a = o[r], l = G(a, r, n);
2885
+ if (l === e)
2886
+ return [l];
2887
+ const f = a[s];
2800
2888
  if (Array.isArray(f) && f.length > 0) {
2801
- const p = pe(f, e, t, a, i + 1);
2889
+ const p = ge(f, e, t, l, i + 1);
2802
2890
  if (p)
2803
- return [a, ...p];
2891
+ return [l, ...p];
2804
2892
  }
2805
2893
  }
2806
2894
  return null;
2807
2895
  }
2808
- function nt(o, e, t, n) {
2809
- const i = pe(o, e, t);
2896
+ function st(o, e, t, n) {
2897
+ const i = ge(o, e, t);
2810
2898
  if (!i) return n;
2811
2899
  const s = new Set(n);
2812
- for (let l = 0; l < i.length - 1; l++)
2813
- s.add(i[l]);
2900
+ for (let r = 0; r < i.length - 1; r++)
2901
+ s.add(i[r]);
2814
2902
  return s;
2815
2903
  }
2816
- function re(o, e = "children") {
2904
+ function le(o, e = "children") {
2817
2905
  if (!Array.isArray(o) || o.length === 0) return !1;
2818
2906
  for (const t of o)
2819
2907
  if (t && Array.isArray(t[e]) && t[e].length > 0)
2820
2908
  return !0;
2821
2909
  return !1;
2822
2910
  }
2823
- function it(o) {
2911
+ function rt(o) {
2824
2912
  if (!Array.isArray(o) || o.length === 0) return null;
2825
2913
  const e = ["children", "items", "nodes", "subRows", "nested"];
2826
2914
  for (const t of o)
@@ -2831,7 +2919,7 @@ function it(o) {
2831
2919
  }
2832
2920
  return null;
2833
2921
  }
2834
- class lt extends ue {
2922
+ class at extends fe {
2835
2923
  name = "tree";
2836
2924
  version = "1.0.0";
2837
2925
  get defaultConfig() {
@@ -2864,15 +2952,15 @@ class lt extends ue {
2864
2952
  */
2865
2953
  detect(e) {
2866
2954
  if (!this.config.autoDetect) return !1;
2867
- const t = this.config.childrenField ?? it(e) ?? "children";
2868
- return re(e, t);
2955
+ const t = this.config.childrenField ?? rt(e) ?? "children";
2956
+ return le(e, t);
2869
2957
  }
2870
2958
  // ===== Data Processing =====
2871
2959
  processRows(e) {
2872
2960
  const t = this.config.childrenField ?? "children";
2873
- if (!re(e, t))
2961
+ if (!le(e, t))
2874
2962
  return this.flattenedRows = [], this.rowKeyMap.clear(), [...e];
2875
- this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = W(e, this.config), this.initialExpansionDone = !0), this.flattenedRows = fe(e, this.config, this.expandedKeys), this.rowKeyMap.clear();
2963
+ this.config.defaultExpanded && !this.initialExpansionDone && (this.expandedKeys = W(e, this.config), this.initialExpansionDone = !0), this.flattenedRows = pe(e, this.config, this.expandedKeys), this.rowKeyMap.clear();
2876
2964
  for (const n of this.flattenedRows)
2877
2965
  this.rowKeyMap.set(n.key, n);
2878
2966
  return this.flattenedRows.map((n) => ({
@@ -2887,27 +2975,27 @@ class lt extends ue {
2887
2975
  if (this.flattenedRows.length === 0) return [...e];
2888
2976
  const t = this.config.indentWidth ?? 20, n = this.config.showExpandIcons ?? !0, i = [...e];
2889
2977
  if (i.length > 0) {
2890
- const s = { ...i[0] }, l = s.viewRenderer;
2891
- if (l?.__treeWrapped)
2978
+ const s = { ...i[0] }, r = s.viewRenderer;
2979
+ if (r?.__treeWrapped)
2892
2980
  return i;
2893
- const r = (a) => {
2894
- const { value: f, row: p, column: w } = a, u = p.__treeDepth ?? 0, c = p.__treeHasChildren ?? !1, h = p.__treeExpanded ?? !1, d = document.createElement("span");
2895
- if (d.style.display = "flex", d.style.alignItems = "center", d.style.paddingLeft = `${u * t}px`, c && n) {
2981
+ const a = (l) => {
2982
+ const { value: f, row: p, column: g } = l, h = p.__treeDepth ?? 0, c = p.__treeHasChildren ?? !1, u = p.__treeExpanded ?? !1, d = document.createElement("span");
2983
+ if (d.style.display = "flex", d.style.alignItems = "center", d.style.paddingLeft = `${h * t}px`, c && n) {
2896
2984
  const m = document.createElement("span");
2897
- m.className = "tree-toggle", m.textContent = h ? "" : "", m.style.cursor = "pointer", m.style.marginRight = "4px", m.style.fontSize = "10px", m.setAttribute("data-tree-key", p.__treeKey), d.appendChild(m);
2985
+ m.className = "tree-toggle", this.setIcon(m, this.resolveIcon(u ? "collapse" : "expand")), m.style.cursor = "pointer", m.style.marginRight = "4px", m.style.fontSize = "10px", m.setAttribute("data-tree-key", p.__treeKey), d.appendChild(m);
2898
2986
  } else if (n) {
2899
2987
  const m = document.createElement("span");
2900
2988
  m.style.width = "14px", m.style.display = "inline-block", d.appendChild(m);
2901
2989
  }
2902
- const g = document.createElement("span");
2903
- if (l) {
2904
- const m = l(a);
2905
- m instanceof Node ? g.appendChild(m) : g.textContent = String(m ?? f ?? "");
2990
+ const b = document.createElement("span");
2991
+ if (r) {
2992
+ const m = r(l);
2993
+ m instanceof Node ? b.appendChild(m) : b.textContent = String(m ?? f ?? "");
2906
2994
  } else
2907
- g.textContent = String(f ?? "");
2908
- return d.appendChild(g), d;
2995
+ b.textContent = String(f ?? "");
2996
+ return d.appendChild(b), d;
2909
2997
  };
2910
- r.__treeWrapped = !0, s.viewRenderer = r, i[0] = s;
2998
+ a.__treeWrapped = !0, s.viewRenderer = a, i[0] = s;
2911
2999
  }
2912
3000
  return i;
2913
3001
  }
@@ -2918,7 +3006,7 @@ class lt extends ue {
2918
3006
  const n = t.getAttribute("data-tree-key");
2919
3007
  if (!n) return !1;
2920
3008
  const i = this.rowKeyMap.get(n);
2921
- return i ? (this.expandedKeys = le(this.expandedKeys, n), this.emit("tree-expand", {
3009
+ return i ? (this.expandedKeys = re(this.expandedKeys, n), this.emit("tree-expand", {
2922
3010
  key: n,
2923
3011
  row: i.data,
2924
3012
  expanded: this.expandedKeys.has(n),
@@ -2942,7 +3030,7 @@ class lt extends ue {
2942
3030
  * Toggle the expansion state of a node.
2943
3031
  */
2944
3032
  toggle(e) {
2945
- this.expandedKeys = le(this.expandedKeys, e), this.requestRender();
3033
+ this.expandedKeys = re(this.expandedKeys, e), this.requestRender();
2946
3034
  }
2947
3035
  /**
2948
3036
  * Expand all nodes in the tree.
@@ -2954,7 +3042,7 @@ class lt extends ue {
2954
3042
  * Collapse all nodes in the tree.
2955
3043
  */
2956
3044
  collapseAll() {
2957
- this.expandedKeys = ot(), this.requestRender();
3045
+ this.expandedKeys = it(), this.requestRender();
2958
3046
  }
2959
3047
  /**
2960
3048
  * Check if a node is currently expanded.
@@ -2984,7 +3072,7 @@ class lt extends ue {
2984
3072
  * Expand all ancestors of a node to make it visible.
2985
3073
  */
2986
3074
  expandToKey(e) {
2987
- this.expandedKeys = nt(this.rows, e, this.config, this.expandedKeys), this.requestRender();
3075
+ this.expandedKeys = st(this.rows, e, this.config, this.expandedKeys), this.requestRender();
2988
3076
  }
2989
3077
  // ===== Styles =====
2990
3078
  styles = `
@@ -3043,14 +3131,14 @@ const y = {
3043
3131
  // Selection
3044
3132
  RANGE_SELECTION: "range-selection",
3045
3133
  SELECTION_OVERLAY: "selection-overlay"
3046
- }, H = {
3134
+ }, D = {
3047
3135
  ROW_INDEX: "data-row-index",
3048
3136
  COL_INDEX: "data-col-index",
3049
3137
  FIELD: "data-field",
3050
3138
  GROUP_KEY: "data-group-key",
3051
3139
  TREE_LEVEL: "data-tree-level",
3052
3140
  STICKY: "data-sticky"
3053
- }, rt = {
3141
+ }, ct = {
3054
3142
  ROOT: `.${y.ROOT}`,
3055
3143
  HEADER: `.${y.HEADER}`,
3056
3144
  HEADER_ROW: `.${y.HEADER_ROW}`,
@@ -3061,13 +3149,13 @@ const y = {
3061
3149
  DATA_CELL: `.${y.DATA_CELL}`,
3062
3150
  GROUP_ROW: `.${y.GROUP_ROW}`,
3063
3151
  // By data attribute
3064
- ROW_BY_INDEX: (o) => `.${y.DATA_ROW}[${H.ROW_INDEX}="${o}"]`,
3065
- CELL_BY_FIELD: (o) => `.${y.DATA_CELL}[${H.FIELD}="${o}"]`,
3066
- CELL_AT: (o, e) => `.${y.DATA_ROW}[${H.ROW_INDEX}="${o}"] .${y.DATA_CELL}[${H.COL_INDEX}="${e}"]`,
3152
+ ROW_BY_INDEX: (o) => `.${y.DATA_ROW}[${D.ROW_INDEX}="${o}"]`,
3153
+ CELL_BY_FIELD: (o) => `.${y.DATA_CELL}[${D.FIELD}="${o}"]`,
3154
+ CELL_AT: (o, e) => `.${y.DATA_ROW}[${D.ROW_INDEX}="${o}"] .${y.DATA_CELL}[${D.COL_INDEX}="${e}"]`,
3067
3155
  // State selectors
3068
3156
  SELECTED_ROWS: `.${y.DATA_ROW}.${y.SELECTED}`,
3069
3157
  EDITING_CELL: `.${y.DATA_CELL}.${y.EDITING}`
3070
- }, at = {
3158
+ }, dt = {
3071
3159
  // Colors
3072
3160
  COLOR_BG: "--tbw-color-bg",
3073
3161
  COLOR_FG: "--tbw-color-fg",
@@ -3089,7 +3177,7 @@ const y = {
3089
3177
  // Borders
3090
3178
  BORDER_RADIUS: "--tbw-border-radius",
3091
3179
  FOCUS_OUTLINE: "--tbw-focus-outline"
3092
- }, ct = {
3180
+ }, ht = {
3093
3181
  CELL_COMMIT: "cell-commit",
3094
3182
  ROW_COMMIT: "row-commit",
3095
3183
  CHANGED_ROWS_RESET: "changed-rows-reset",
@@ -3100,7 +3188,7 @@ const y = {
3100
3188
  ACTIVATE_CELL: "activate-cell",
3101
3189
  GROUP_TOGGLE: "group-toggle",
3102
3190
  COLUMN_STATE_CHANGE: "column-state-change"
3103
- }, dt = {
3191
+ }, ut = {
3104
3192
  // Selection plugin
3105
3193
  SELECTION_CHANGE: "selection-change",
3106
3194
  // Tree plugin
@@ -3131,7 +3219,7 @@ const y = {
3131
3219
  DETAIL_EXPAND: "detail-expand",
3132
3220
  // Grouping rows plugin
3133
3221
  GROUP_EXPAND: "group-expand"
3134
- }, I = {
3222
+ }, q = {
3135
3223
  sum: (o, e) => o.reduce((t, n) => t + (Number(n[e]) || 0), 0),
3136
3224
  avg: (o, e) => {
3137
3225
  const t = o.reduce((n, i) => n + (Number(i[e]) || 0), 0);
@@ -3160,7 +3248,7 @@ const y = {
3160
3248
  */
3161
3249
  get(o) {
3162
3250
  if (o !== void 0)
3163
- return typeof o == "function" ? o : P.get(o) ?? I[o];
3251
+ return typeof o == "function" ? o : P.get(o) ?? q[o];
3164
3252
  },
3165
3253
  /**
3166
3254
  * Run an aggregator on a set of rows.
@@ -3173,34 +3261,35 @@ const y = {
3173
3261
  * Check if an aggregator exists.
3174
3262
  */
3175
3263
  has(o) {
3176
- return P.has(o) || o in I;
3264
+ return P.has(o) || o in q;
3177
3265
  },
3178
3266
  /**
3179
3267
  * List all available aggregator names.
3180
3268
  */
3181
3269
  list() {
3182
- return [...Object.keys(I), ...P.keys()];
3270
+ return [...Object.keys(q), ...P.keys()];
3183
3271
  }
3184
- }, ht = x.register.bind(x), ut = x.unregister.bind(x), ft = x.get.bind(x), pt = x.run.bind(x), wt = x.list.bind(x);
3272
+ }, ft = x.register.bind(x), pt = x.unregister.bind(x), gt = x.get.bind(x), wt = x.run.bind(x), bt = x.list.bind(x);
3185
3273
  export {
3186
- ue as BaseGridPlugin,
3187
- ct as DGEvents,
3188
- q as DataGridElement,
3274
+ fe as BaseGridPlugin,
3275
+ ce as DEFAULT_GRID_ICONS,
3276
+ ht as DGEvents,
3277
+ I as DataGridElement,
3189
3278
  M as FitModeEnum,
3190
- at as GridCSSVars,
3279
+ dt as GridCSSVars,
3191
3280
  y as GridClasses,
3192
- H as GridDataAttrs,
3193
- q as GridElement,
3194
- rt as GridSelectors,
3195
- dt as PluginEvents,
3196
- Ye as PluginManager,
3197
- st as SelectionPlugin,
3198
- lt as TreePlugin,
3281
+ D as GridDataAttrs,
3282
+ I as GridElement,
3283
+ ct as GridSelectors,
3284
+ ut as PluginEvents,
3285
+ Je as PluginManager,
3286
+ lt as SelectionPlugin,
3287
+ at as TreePlugin,
3199
3288
  x as aggregatorRegistry,
3200
- ft as getAggregator,
3201
- wt as listAggregators,
3202
- ht as registerAggregator,
3203
- pt as runAggregator,
3204
- ut as unregisterAggregator
3289
+ gt as getAggregator,
3290
+ bt as listAggregators,
3291
+ ft as registerAggregator,
3292
+ wt as runAggregator,
3293
+ pt as unregisterAggregator
3205
3294
  };
3206
3295
  //# sourceMappingURL=index.js.map