@toolbox-web/grid 0.3.2 → 0.3.3

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.
package/index.js CHANGED
@@ -10,49 +10,49 @@ function xe(t, e) {
10
10
  const o = t._columns, n = Fe(t);
11
11
  return {
12
12
  columns: o.map((i, r) => {
13
- const s = {
13
+ const l = {
14
14
  field: i.field,
15
15
  order: r,
16
16
  visible: !0
17
17
  // If it's in _columns, it's visible (hidden columns are filtered out)
18
- }, l = i;
19
- l.__renderedWidth !== void 0 ? s.width = l.__renderedWidth : i.width !== void 0 && (s.width = typeof i.width == "string" ? parseFloat(i.width) : i.width);
18
+ }, s = i;
19
+ s.__renderedWidth !== void 0 ? l.width = s.__renderedWidth : i.width !== void 0 && (l.width = typeof i.width == "string" ? parseFloat(i.width) : i.width);
20
20
  const a = n.get(i.field);
21
- a && (s.sort = a);
21
+ a && (l.sort = a);
22
22
  for (const c of e)
23
23
  if (c.getColumnState) {
24
24
  const f = c.getColumnState(i.field);
25
- f && Object.assign(s, f);
25
+ f && Object.assign(l, f);
26
26
  }
27
- return s;
27
+ return l;
28
28
  })
29
29
  };
30
30
  }
31
31
  function Ge(t, e, o, n) {
32
32
  if (!e.columns || e.columns.length === 0) return;
33
- const i = new Map(e.columns.map((l) => [l.field, l])), r = o.map((l) => {
34
- const a = i.get(l.field);
35
- if (!a) return l;
36
- const c = { ...l };
33
+ const i = new Map(e.columns.map((s) => [s.field, s])), r = o.map((s) => {
34
+ const a = i.get(s.field);
35
+ if (!a) return s;
36
+ const c = { ...s };
37
37
  return a.width !== void 0 && (c.width = a.width, c.__renderedWidth = a.width), a.visible !== void 0 && (c.hidden = !a.visible), c;
38
38
  });
39
- r.sort((l, a) => {
40
- const c = i.get(l.field)?.order ?? 1 / 0, f = i.get(a.field)?.order ?? 1 / 0;
39
+ r.sort((s, a) => {
40
+ const c = i.get(s.field)?.order ?? 1 / 0, f = i.get(a.field)?.order ?? 1 / 0;
41
41
  return c - f;
42
42
  }), t._columns = r;
43
- const s = e.columns.filter((l) => l.sort !== void 0).sort((l, a) => (l.sort?.priority ?? 0) - (a.sort?.priority ?? 0));
44
- if (s.length > 0) {
45
- const l = s[0];
46
- l.sort && (t._sortState = {
47
- field: l.field,
48
- direction: l.sort.direction === "asc" ? 1 : -1
43
+ const l = e.columns.filter((s) => s.sort !== void 0).sort((s, a) => (s.sort?.priority ?? 0) - (a.sort?.priority ?? 0));
44
+ if (l.length > 0) {
45
+ const s = l[0];
46
+ s.sort && (t._sortState = {
47
+ field: s.field,
48
+ direction: s.sort.direction === "asc" ? 1 : -1
49
49
  });
50
50
  } else
51
51
  t._sortState = null;
52
- for (const l of n)
53
- if (l.applyColumnState)
52
+ for (const s of n)
53
+ if (s.applyColumnState)
54
54
  for (const a of e.columns)
55
- l.applyColumnState(a.field, a);
55
+ s.applyColumnState(a.field, a);
56
56
  }
57
57
  function Ue(t, e, o) {
58
58
  let n = null;
@@ -65,11 +65,11 @@ function Ue(t, e, o) {
65
65
  };
66
66
  }
67
67
  function Ae(t, e, o, n) {
68
- const i = t.effectiveConfig?.columns ?? [], r = i.find((l) => l.field === e);
68
+ const i = t.effectiveConfig?.columns ?? [], r = i.find((s) => s.field === e);
69
69
  return !r || !o && r.lockVisible || !o && i.filter((a) => !a.hidden && a.field !== e).length === 0 || !!r.hidden === !o ? !1 : (r.hidden = !o, n.emit("column-visibility", {
70
70
  field: e,
71
71
  visible: o,
72
- visibleColumns: i.filter((l) => !l.hidden).map((l) => l.field)
72
+ visibleColumns: i.filter((s) => !s.hidden).map((s) => s.field)
73
73
  }), n.clearRowPool(), n.setup(), n.requestStateChange(), !0);
74
74
  }
75
75
  function Xe(t, e, o) {
@@ -101,8 +101,8 @@ function Je(t, e, o) {
101
101
  if (!e.length) return;
102
102
  const n = new Map(t._columns.map((r) => [r.field, r])), i = [];
103
103
  for (const r of e) {
104
- const s = n.get(r);
105
- s && (i.push(s), n.delete(r));
104
+ const l = n.get(r);
105
+ l && (i.push(l), n.delete(r));
106
106
  }
107
107
  for (const r of n.values())
108
108
  i.push(r);
@@ -131,19 +131,23 @@ function et(t) {
131
131
  function Le(t, e) {
132
132
  if (e && e.length) {
133
133
  const r = {};
134
- return e.forEach((s) => {
135
- s.type && (r[s.field] = s.type);
134
+ return e.forEach((l) => {
135
+ l.type && (r[l.field] = l.type);
136
136
  }), { columns: e, typeMap: r };
137
137
  }
138
138
  const o = t[0] || {}, n = Object.keys(o).map((r) => {
139
- const s = o[r], l = et(s);
140
- return { field: r, header: r.charAt(0).toUpperCase() + r.slice(1), type: l };
139
+ const l = o[r], s = et(l);
140
+ return { field: r, header: r.charAt(0).toUpperCase() + r.slice(1), type: s };
141
141
  }), i = {};
142
142
  return n.forEach((r) => {
143
143
  i[r.field] = r.type || "string";
144
144
  }), { columns: n, typeMap: i };
145
145
  }
146
- const tt = /{{\s*([^}]+)\s*}}/g, L = "__DG_EMPTY__", ot = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, nt = /__(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/, it = /* @__PURE__ */ new Set([
146
+ const tt = /{{\s*([^}]+)\s*}}/g, L = "__DG_EMPTY__", ot = /^[\w$. '?+\-*/%:()!<>=,&|]+$/, nt = /__(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/;
147
+ function it(t) {
148
+ return !t || typeof t != "string" ? "" : t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
149
+ }
150
+ const rt = /* @__PURE__ */ new Set([
147
151
  "script",
148
152
  "iframe",
149
153
  "object",
@@ -168,56 +172,56 @@ const tt = /{{\s*([^}]+)\s*}}/g, L = "__DG_EMPTY__", ot = /^[\w$. '?+\-*/%:()!<>
168
172
  "plaintext",
169
173
  "xmp",
170
174
  "listing"
171
- ]), ue = /^on\w+$/i, rt = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "srcdoc", "xlink:href", "poster", "srcset"]), st = /^\s*(javascript|vbscript|data|blob):/i;
175
+ ]), ue = /^on\w+$/i, lt = /* @__PURE__ */ new Set(["href", "src", "action", "formaction", "data", "srcdoc", "xlink:href", "poster", "srcset"]), st = /^\s*(javascript|vbscript|data|blob):/i;
172
176
  function Q(t) {
173
177
  if (!t || typeof t != "string") return "";
174
178
  if (t.indexOf("<") === -1) return t;
175
179
  const e = document.createElement("template");
176
- return e.innerHTML = t, lt(e.content), e.innerHTML;
180
+ return e.innerHTML = t, at(e.content), e.innerHTML;
177
181
  }
178
- function lt(t) {
182
+ function at(t) {
179
183
  const e = [], o = t.querySelectorAll("*");
180
184
  for (const n of o) {
181
185
  const i = n.tagName.toLowerCase();
182
- if (it.has(i)) {
186
+ if (rt.has(i)) {
183
187
  e.push(n);
184
188
  continue;
185
189
  }
186
190
  if ((i === "svg" || n.namespaceURI === "http://www.w3.org/2000/svg") && Array.from(n.attributes).some(
187
- (l) => ue.test(l.name) || l.name === "href" || l.name === "xlink:href"
191
+ (s) => ue.test(s.name) || s.name === "href" || s.name === "xlink:href"
188
192
  )) {
189
193
  e.push(n);
190
194
  continue;
191
195
  }
192
196
  const r = [];
193
- for (const s of n.attributes) {
194
- const l = s.name.toLowerCase();
195
- if (ue.test(l)) {
196
- r.push(s.name);
197
+ for (const l of n.attributes) {
198
+ const s = l.name.toLowerCase();
199
+ if (ue.test(s)) {
200
+ r.push(l.name);
197
201
  continue;
198
202
  }
199
- if (rt.has(l) && st.test(s.value)) {
200
- r.push(s.name);
203
+ if (lt.has(s) && st.test(l.value)) {
204
+ r.push(l.name);
201
205
  continue;
202
206
  }
203
- if (l === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(s.value)) {
204
- r.push(s.name);
207
+ if (s === "style" && /expression\s*\(|javascript:|behavior\s*:/i.test(l.value)) {
208
+ r.push(l.name);
205
209
  continue;
206
210
  }
207
211
  }
208
- r.forEach((s) => n.removeAttribute(s));
212
+ r.forEach((l) => n.removeAttribute(l));
209
213
  }
210
214
  e.forEach((n) => n.remove());
211
215
  }
212
216
  function Pe(t, e) {
213
217
  if (!t || t.indexOf("{{") === -1) return t;
214
- const o = [], n = t.replace(tt, (l, a) => {
215
- const c = at(a, e);
218
+ const o = [], n = t.replace(tt, (s, a) => {
219
+ const c = ct(a, e);
216
220
  return o.push({ expr: a.trim(), result: c }), c;
217
- }), i = ct(n), r = o.length && o.every((l) => l.result === "" || l.result === L);
221
+ }), i = dt(n), r = o.length && o.every((s) => s.result === "" || s.result === L);
218
222
  return /Reflect\.|\bProxy\b|ownKeys\(/.test(t) || r ? "" : i;
219
223
  }
220
- function at(t, e) {
224
+ function ct(t, e) {
221
225
  if (t = (t || "").trim(), !t || /\b(Reflect|Proxy|ownKeys)\b/.test(t)) return L;
222
226
  if (t === "value") return e.value == null ? L : String(e.value);
223
227
  if (t.startsWith("row.") && !/[()?]/.test(t) && !t.includes(":")) {
@@ -234,10 +238,10 @@ function at(t, e) {
234
238
  return L;
235
239
  }
236
240
  }
237
- function ct(t) {
241
+ function dt(t) {
238
242
  return t && t.replace(new RegExp(L, "g"), "").replace(/Reflect\.[^<>{}\s]+/g, "").replace(/\bProxy\b/g, "").replace(/ownKeys\([^)]*\)/g, "");
239
243
  }
240
- function dt(t) {
244
+ function ut(t) {
241
245
  if (/Reflect|Proxy|ownKeys/.test(t.textContent || "")) {
242
246
  if (Array.from(t.childNodes).forEach((e) => {
243
247
  e.nodeType === Node.TEXT_NODE && /Reflect|Proxy|ownKeys/.test(e.textContent || "") && (e.textContent = "");
@@ -253,11 +257,11 @@ function he(t) {
253
257
  const e = /Reflect\.|\bProxy\b|ownKeys\(/.test(t), o = (n) => e ? "" : Pe(t, n);
254
258
  return o.__blocked = e, o;
255
259
  }
256
- function ut(t) {
260
+ function ht(t) {
257
261
  return Array.from(t.querySelectorAll("tbw-grid-column")).map((o) => {
258
262
  const n = o.getAttribute("field") || "";
259
263
  if (!n) return null;
260
- const i = o.getAttribute("type") || void 0, s = i && (/* @__PURE__ */ new Set(["number", "string", "date", "boolean", "select", "typeahead"])).has(i) ? i : void 0, l = o.getAttribute("header") || void 0, a = o.hasAttribute("sortable"), c = o.hasAttribute("editable"), f = { field: n, type: s, header: l, sortable: a, editable: c }, d = o.getAttribute("width");
264
+ const i = o.getAttribute("type") || void 0, l = i && (/* @__PURE__ */ new Set(["number", "string", "date", "boolean", "select", "typeahead"])).has(i) ? i : void 0, s = o.getAttribute("header") || void 0, a = o.hasAttribute("sortable"), c = o.hasAttribute("editable"), f = { field: n, type: l, header: s, sortable: a, editable: c }, d = o.getAttribute("width");
261
265
  if (d) {
262
266
  const C = parseFloat(d);
263
267
  !isNaN(C) && /^\d+(\.\d+)?$/.test(d.trim()) ? f.width = C : f.width = d;
@@ -290,7 +294,7 @@ function ut(t) {
290
294
  return f;
291
295
  }).filter((o) => !!o);
292
296
  }
293
- function ht(t, e) {
297
+ function ft(t, e) {
294
298
  if ((!t || !t.length) && (!e || !e.length)) return [];
295
299
  if (!t || !t.length) return e || [];
296
300
  if (!e || !e.length) return t;
@@ -299,18 +303,18 @@ function ht(t, e) {
299
303
  const r = o[i.field];
300
304
  if (r) {
301
305
  i.header && !r.header && (r.header = i.header), i.type && !r.type && (r.type = i.type), i.sortable && (r.sortable = !0), i.editable && (r.editable = !0), i.resizable && (r.resizable = !0), i.width != null && r.width == null && (r.width = i.width), i.minWidth != null && r.minWidth == null && (r.minWidth = i.minWidth), i.__viewTemplate && (r.__viewTemplate = i.__viewTemplate), i.__editorTemplate && (r.__editorTemplate = i.__editorTemplate), i.__headerTemplate && (r.__headerTemplate = i.__headerTemplate);
302
- const s = i.renderer || i.viewRenderer, l = r.renderer || r.viewRenderer;
303
- s && !l && (r.viewRenderer = s, i.renderer && (r.renderer = s)), i.editor && !r.editor && (r.editor = i.editor);
306
+ const l = i.renderer || i.viewRenderer, s = r.renderer || r.viewRenderer;
307
+ l && !s && (r.viewRenderer = l, i.renderer && (r.renderer = l)), i.editor && !r.editor && (r.editor = i.editor);
304
308
  } else
305
309
  o[i.field] = { ...i };
306
310
  });
307
311
  const n = t.map((i) => {
308
312
  const r = o[i.field];
309
313
  if (!r) return i;
310
- const s = { ...i };
311
- r.header && !s.header && (s.header = r.header), r.type && !s.type && (s.type = r.type), s.sortable = i.sortable || r.sortable, (i.resizable === !0 || r.resizable === !0) && (s.resizable = !0), s.editable = i.editable || r.editable, r.width != null && s.width == null && (s.width = r.width), r.minWidth != null && s.minWidth == null && (s.minWidth = r.minWidth), r.__viewTemplate && (s.__viewTemplate = r.__viewTemplate), r.__editorTemplate && (s.__editorTemplate = r.__editorTemplate), r.__headerTemplate && (s.__headerTemplate = r.__headerTemplate);
312
- const l = r.renderer || r.viewRenderer, a = s.renderer || s.viewRenderer;
313
- return l && !a && (s.viewRenderer = l, r.renderer && (s.renderer = l)), r.editor && !s.editor && (s.editor = r.editor), delete o[i.field], s;
314
+ const l = { ...i };
315
+ r.header && !l.header && (l.header = r.header), r.type && !l.type && (l.type = r.type), l.sortable = i.sortable || r.sortable, (i.resizable === !0 || r.resizable === !0) && (l.resizable = !0), l.editable = i.editable || r.editable, r.width != null && l.width == null && (l.width = r.width), r.minWidth != null && l.minWidth == null && (l.minWidth = r.minWidth), r.__viewTemplate && (l.__viewTemplate = r.__viewTemplate), r.__editorTemplate && (l.__editorTemplate = r.__editorTemplate), r.__headerTemplate && (l.__headerTemplate = r.__headerTemplate);
316
+ const s = r.renderer || r.viewRenderer, a = l.renderer || l.viewRenderer;
317
+ return s && !a && (l.viewRenderer = s, r.renderer && (l.renderer = s)), r.editor && !l.editor && (l.editor = r.editor), delete o[i.field], l;
314
318
  });
315
319
  return Object.keys(o).forEach((i) => n.push(o[i])), n;
316
320
  }
@@ -325,8 +329,8 @@ function fe(t, e) {
325
329
  function pe(t) {
326
330
  t.__lightDomColumnsCache || (t.__originalColumnNodes = Array.from(
327
331
  t.querySelectorAll("tbw-grid-column")
328
- ), t.__lightDomColumnsCache = t.__originalColumnNodes.length ? ut(t) : []);
329
- const e = t.__lightDomColumnsCache, o = ht(t._columns, e);
332
+ ), t.__lightDomColumnsCache = t.__originalColumnNodes.length ? ht(t) : []);
333
+ const e = t.__lightDomColumnsCache, o = ft(t._columns, e);
330
334
  o.forEach((i) => {
331
335
  i.__viewTemplate && !i.__compiledView && (i.__compiledView = he(i.__viewTemplate.innerHTML)), i.__editorTemplate && !i.__compiledEditor && (i.__compiledEditor = he(i.__editorTemplate.innerHTML));
332
336
  });
@@ -341,16 +345,16 @@ function we(t) {
341
345
  let n = !1;
342
346
  t._visibleColumns.forEach((i, r) => {
343
347
  if (i.width) return;
344
- const s = o[r];
345
- let l = s ? s.scrollWidth : 0;
348
+ const l = o[r];
349
+ let s = l ? l.scrollWidth : 0;
346
350
  for (const a of t._rowPool) {
347
351
  const c = a.children[r];
348
352
  if (c) {
349
353
  const f = c.scrollWidth;
350
- f > l && (l = f);
354
+ f > s && (s = f);
351
355
  }
352
356
  }
353
- l > 0 && (i.width = l + 2, i.__autoSized = !0, n = !0);
357
+ s > 0 && (i.width = s + 2, i.__autoSized = !0, n = !0);
354
358
  }), n && z(t), t.__didInitialAutoSize = !0;
355
359
  }
356
360
  function z(t) {
@@ -360,7 +364,7 @@ function z(t) {
360
364
  return n != null ? `minmax(${n}px, 1fr)` : "1fr";
361
365
  }).join(" ").trim() : t._gridTemplate = t._visibleColumns.map((o) => o.width ? `${o.width}px` : "max-content").join(" "), t.style.setProperty("--tbw-column-template", t._gridTemplate);
362
366
  }
363
- function ft(t) {
367
+ function pt(t) {
364
368
  switch (t.type) {
365
369
  case "number":
366
370
  return (e) => {
@@ -386,14 +390,14 @@ function ft(t) {
386
390
  return (e) => {
387
391
  const o = document.createElement("select");
388
392
  e.column.multi && (o.multiple = !0), (typeof e.column.options == "function" ? e.column.options() : e.column.options || []).forEach((r) => {
389
- const s = document.createElement("option");
390
- s.value = String(r.value), s.textContent = r.label, (e.column.multi && Array.isArray(e.value) && e.value.includes(r.value) || !e.column.multi && e.value === r.value) && (s.selected = !0), o.appendChild(s);
393
+ const l = document.createElement("option");
394
+ l.value = String(r.value), l.textContent = r.label, (e.column.multi && Array.isArray(e.value) && e.value.includes(r.value) || !e.column.multi && e.value === r.value) && (l.selected = !0), o.appendChild(l);
391
395
  });
392
396
  const i = () => {
393
397
  if (e.column.multi) {
394
398
  const r = [];
395
- Array.from(o.selectedOptions).forEach((s) => {
396
- r.push(s.value);
399
+ Array.from(o.selectedOptions).forEach((l) => {
400
+ r.push(l.value);
397
401
  }), e.commit(r);
398
402
  } else
399
403
  e.commit(o.value);
@@ -434,18 +438,18 @@ function X(t) {
434
438
  const e = t.getAttribute("data-col");
435
439
  return e ? parseInt(e, 10) : -1;
436
440
  }
437
- function se(t) {
441
+ function le(t) {
438
442
  t && t.querySelectorAll(".cell-focus").forEach((e) => e.classList.remove("cell-focus"));
439
443
  }
440
- function pt(t, e) {
444
+ function wt(t, e) {
441
445
  if (t._dispatchKeyDown?.(e))
442
446
  return;
443
- const o = t._rows.length - 1, n = t._visibleColumns.length - 1, i = t._activeEditRows !== void 0 && t._activeEditRows !== -1, s = t._visibleColumns[t._focusCol]?.type, l = e.composedPath ? e.composedPath() : [], a = l && l.length ? l[0] : e.target, c = (f) => {
447
+ const o = t._rows.length - 1, n = t._visibleColumns.length - 1, i = t._activeEditRows !== void 0 && t._activeEditRows !== -1, l = t._visibleColumns[t._focusCol]?.type, s = e.composedPath ? e.composedPath() : [], a = s && s.length ? s[0] : e.target, c = (f) => {
444
448
  if (!f) return !1;
445
449
  const d = f.tagName;
446
450
  return !!(d === "INPUT" || d === "SELECT" || d === "TEXTAREA" || f.isContentEditable);
447
451
  };
448
- if (!(c(a) && (e.key === "Home" || e.key === "End")) && !(c(a) && (e.key === "ArrowUp" || e.key === "ArrowDown") && a.tagName === "INPUT" && a.type === "number") && !(c(a) && (e.key === "ArrowLeft" || e.key === "ArrowRight")) && !(c(a) && (e.key === "Enter" || e.key === "Escape")) && !(i && (s === "select" || s === "typeahead") && (e.key === "ArrowDown" || e.key === "ArrowUp"))) {
452
+ if (!(c(a) && (e.key === "Home" || e.key === "End")) && !(c(a) && (e.key === "ArrowUp" || e.key === "ArrowDown") && a.tagName === "INPUT" && a.type === "number") && !(c(a) && (e.key === "ArrowLeft" || e.key === "ArrowRight")) && !(c(a) && (e.key === "Enter" || e.key === "Escape")) && !(i && (l === "select" || l === "typeahead") && (e.key === "ArrowDown" || e.key === "ArrowUp"))) {
449
453
  switch (e.key) {
450
454
  case "Tab": {
451
455
  e.preventDefault(), !e.shiftKey ? t._focusCol < n ? t._focusCol += 1 : (typeof t.commitActiveRowEdit == "function" && t.commitActiveRowEdit(), t._focusRow < o && (t._focusRow += 1, t._focusCol = 0)) : t._focusCol > 0 ? t._focusCol -= 1 : t._focusRow > 0 && (typeof t.commitActiveRowEdit == "function" && t._activeEditRows === t._focusRow && t.commitActiveRowEdit(), t._focusRow -= 1, t._focusCol = n), k(t);
@@ -492,45 +496,45 @@ function pt(t, e) {
492
496
  }
493
497
  function k(t, e) {
494
498
  if (t._virtualization?.enabled) {
495
- const { rowHeight: s, container: l, viewportEl: a } = t._virtualization, c = l, f = a?.clientHeight ?? c?.clientHeight ?? 0;
499
+ const { rowHeight: l, container: s, viewportEl: a } = t._virtualization, c = s, f = a?.clientHeight ?? c?.clientHeight ?? 0;
496
500
  if (c && f > 0) {
497
- const d = t._focusRow * s;
498
- d < c.scrollTop ? c.scrollTop = d : d + s > c.scrollTop + f && (c.scrollTop = d - f + s);
501
+ const d = t._focusRow * l;
502
+ d < c.scrollTop ? c.scrollTop = d : d + l > c.scrollTop + f && (c.scrollTop = d - f + l);
499
503
  }
500
504
  }
501
505
  const o = t._activeEditRows !== void 0 && t._activeEditRows !== -1;
502
- o || t.refreshVirtualWindow(!1), se(t._bodyEl), Array.from(t._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((s) => {
503
- s.setAttribute("aria-selected", "false");
506
+ o || t.refreshVirtualWindow(!1), le(t._bodyEl), Array.from(t._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((l) => {
507
+ l.setAttribute("aria-selected", "false");
504
508
  });
505
509
  const n = t._focusRow, i = t._virtualization.start ?? 0, r = t._virtualization.end ?? t._rows.length;
506
510
  if (n >= i && n < r) {
507
- const s = t._bodyEl.querySelectorAll(".data-grid-row")[n - i], l = s?.children[t._focusCol];
508
- if (l) {
509
- l.classList.add("cell-focus"), l.setAttribute("aria-selected", "true");
511
+ const l = t._bodyEl.querySelectorAll(".data-grid-row")[n - i], s = l?.children[t._focusCol];
512
+ if (s) {
513
+ s.classList.add("cell-focus"), s.setAttribute("aria-selected", "true");
510
514
  const a = t.shadowRoot?.querySelector(".tbw-scroll-area");
511
- if (a && l && !o)
515
+ if (a && s && !o)
512
516
  if (e?.forceScrollLeft)
513
517
  a.scrollLeft = 0;
514
518
  else if (e?.forceScrollRight)
515
519
  a.scrollLeft = a.scrollWidth - a.clientWidth;
516
520
  else {
517
- const c = t._getHorizontalScrollOffsets?.(s ?? void 0, l) ?? { left: 0, right: 0 };
521
+ const c = t._getHorizontalScrollOffsets?.(l ?? void 0, s) ?? { left: 0, right: 0 };
518
522
  if (!c.skipScroll) {
519
- const f = l.getBoundingClientRect(), d = a.getBoundingClientRect(), u = f.left - d.left + a.scrollLeft, w = u + f.width, h = a.scrollLeft + c.left, p = a.scrollLeft + a.clientWidth - c.right;
523
+ const f = s.getBoundingClientRect(), d = a.getBoundingClientRect(), u = f.left - d.left + a.scrollLeft, w = u + f.width, h = a.scrollLeft + c.left, p = a.scrollLeft + a.clientWidth - c.right;
520
524
  u < h ? a.scrollLeft = u - c.left : w > p && (a.scrollLeft = w - a.clientWidth + c.right);
521
525
  }
522
526
  }
523
- if (t._activeEditRows !== void 0 && t._activeEditRows !== -1 && l.classList.contains("editing")) {
524
- const c = l.querySelector(B);
527
+ if (t._activeEditRows !== void 0 && t._activeEditRows !== -1 && s.classList.contains("editing")) {
528
+ const c = s.querySelector(q);
525
529
  if (c && document.activeElement !== c)
526
530
  try {
527
531
  c.focus({ preventScroll: !0 });
528
532
  } catch {
529
533
  }
530
- } else if (!l.contains(document.activeElement)) {
531
- l.hasAttribute("tabindex") || l.setAttribute("tabindex", "-1");
534
+ } else if (!s.contains(document.activeElement)) {
535
+ s.hasAttribute("tabindex") || s.setAttribute("tabindex", "-1");
532
536
  try {
533
- l.focus({ preventScroll: !0 });
537
+ s.focus({ preventScroll: !0 });
534
538
  } catch {
535
539
  }
536
540
  }
@@ -541,27 +545,27 @@ const Oe = document.createElement("template");
541
545
  Oe.innerHTML = '<div class="cell" role="gridcell" part="cell"></div>';
542
546
  const ke = document.createElement("template");
543
547
  ke.innerHTML = '<div class="data-grid-row" role="row" part="row"></div>';
544
- function wt() {
548
+ function bt() {
545
549
  return Oe.content.firstElementChild.cloneNode(!0);
546
550
  }
547
- function bt() {
551
+ function gt() {
548
552
  return ke.content.firstElementChild.cloneNode(!0);
549
553
  }
550
- const gt = "__cellDisplayCache", mt = "__cellCacheEpoch";
554
+ const mt = "__cellDisplayCache", vt = "__cellCacheEpoch";
551
555
  function Y(t) {
552
- t[gt] = void 0, t[mt] = void 0, t.__hasSpecialColumns = void 0;
556
+ t[mt] = void 0, t[vt] = void 0, t.__hasSpecialColumns = void 0;
553
557
  }
554
- function vt(t, e, o, n, i) {
555
- const r = Math.max(0, o - e), s = t._bodyEl, l = t._visibleColumns, a = l.length;
558
+ function _t(t, e, o, n, i) {
559
+ const r = Math.max(0, o - e), l = t._bodyEl, s = t._visibleColumns, a = s.length;
556
560
  let c = t.__cachedHeaderRowCount;
557
561
  for (c === void 0 && (c = t.shadowRoot?.querySelector(".header-group-row") ? 2 : 1, t.__cachedHeaderRowCount = c); t._rowPool.length < r; ) {
558
- const d = bt();
562
+ const d = gt();
559
563
  d.addEventListener("click", (u) => be(t, u, d, !1)), d.addEventListener("dblclick", (u) => be(t, u, d, !0)), t._rowPool.push(d);
560
564
  }
561
565
  if (t._rowPool.length > r) {
562
566
  for (let d = r; d < t._rowPool.length; d++) {
563
567
  const u = t._rowPool[d];
564
- u.parentNode === s && u.remove();
568
+ u.parentNode === l && u.remove();
565
569
  }
566
570
  t._rowPool.length = r;
567
571
  }
@@ -569,14 +573,14 @@ function vt(t, e, o, n, i) {
569
573
  for (let d = 0; d < r; d++) {
570
574
  const u = e + d, w = t._rows[u], h = t._rowPool[d];
571
575
  if (h.setAttribute("aria-rowindex", String(u + c + 1)), f && i(w, h, u)) {
572
- h.__epoch = n, h.__rowDataRef = w, h.parentNode !== s && s.appendChild(h);
576
+ h.__epoch = n, h.__rowDataRef = w, h.parentNode !== l && l.appendChild(h);
573
577
  continue;
574
578
  }
575
579
  const p = h.__epoch, g = h.__rowDataRef, b = h.children.length, v = p === n && b === a, m = g !== w;
576
580
  let E = !1;
577
581
  if (v && m) {
578
582
  for (let S = 0; S < a; S++)
579
- if (l[S].externalView && !h.querySelector(`.cell[data-col="${S}"] [data-external-view]`)) {
583
+ if (s[S].externalView && !h.querySelector(`.cell[data-col="${S}"] [data-external-view]`)) {
580
584
  E = !0;
581
585
  break;
582
586
  }
@@ -618,15 +622,15 @@ function vt(t, e, o, n, i) {
618
622
  }
619
623
  }
620
624
  const x = t._changedRowIndices.has(u), K = h.classList.contains("changed");
621
- x !== K && h.classList.toggle("changed", x), h.parentNode !== s && s.appendChild(h);
625
+ x !== K && h.classList.toggle("changed", x), h.parentNode !== l && l.appendChild(h);
622
626
  }
623
627
  }
624
628
  function ne(t, e, o, n) {
625
- const i = e.children, r = t._visibleColumns, s = r.length, l = i.length, a = s < l ? s : l, c = t._focusRow, f = t._focusCol;
629
+ const i = e.children, r = t._visibleColumns, l = r.length, s = i.length, a = l < s ? l : s, c = t._focusRow, f = t._focusCol;
626
630
  let d = t.__hasSpecialColumns;
627
631
  if (d === void 0) {
628
632
  d = !1;
629
- for (let w = 0; w < s; w++) {
633
+ for (let w = 0; w < l; w++) {
630
634
  const h = r[w];
631
635
  if (h.__viewTemplate || h.__compiledView || h.renderer || h.viewRenderer || h.externalView || h.format || h.type === "date" || h.type === "boolean") {
632
636
  d = !0;
@@ -677,11 +681,11 @@ function ne(t, e, o, n) {
677
681
  }
678
682
  function $(t, e, o, n) {
679
683
  e.innerHTML = "";
680
- const i = t._visibleColumns, r = i.length, s = t._focusRow, l = t._focusCol;
684
+ const i = t._visibleColumns, r = i.length, l = t._focusRow, s = t._focusCol;
681
685
  t.effectiveConfig?.editOn || t.editOn;
682
686
  const a = t, c = document.createDocumentFragment();
683
687
  for (let f = 0; f < r; f++) {
684
- const d = i[f], u = wt();
688
+ const d = i[f], u = bt();
685
689
  u.setAttribute("aria-colindex", String(f + 1)), u.setAttribute("data-col", String(f)), u.setAttribute("data-row", String(n)), u.setAttribute("data-field", d.field), d.type, d.type && u.setAttribute("data-type", d.type);
686
690
  let w = o[d.field];
687
691
  const h = d.format;
@@ -727,11 +731,11 @@ function $(t, e, o, n) {
727
731
  } else
728
732
  d.type === "date" ? u.textContent = He(w) : d.type === "boolean" ? u.innerHTML = ae(!!w) : u.textContent = w == null ? "" : String(w);
729
733
  if (v) {
730
- dt(u);
734
+ ut(u);
731
735
  const m = u.textContent || "";
732
736
  /Proxy|Reflect\.ownKeys/.test(m) && (u.textContent = m.replace(/Proxy|Reflect\.ownKeys/g, "").trim(), /Proxy|Reflect\.ownKeys/.test(u.textContent || "") && (u.textContent = ""));
733
737
  }
734
- u.hasAttribute("data-blocked-template") && (u.textContent || "").trim().length && (u.textContent = ""), d.editable ? u.tabIndex = 0 : d.type === "boolean" && (u.hasAttribute("tabindex") || (u.tabIndex = 0)), s === n && l === f ? (u.classList.add("cell-focus"), u.setAttribute("aria-selected", "true")) : u.setAttribute("aria-selected", "false"), c.appendChild(u);
738
+ u.hasAttribute("data-blocked-template") && (u.textContent || "").trim().length && (u.textContent = ""), d.editable ? u.tabIndex = 0 : d.type === "boolean" && (u.hasAttribute("tabindex") || (u.tabIndex = 0)), l === n && s === f ? (u.classList.add("cell-focus"), u.setAttribute("aria-selected", "true")) : u.setAttribute("aria-selected", "false"), c.appendChild(u);
735
739
  }
736
740
  e.appendChild(c);
737
741
  }
@@ -739,28 +743,28 @@ function be(t, e, o, n) {
739
743
  if (e.target?.closest(".resize-handle")) return;
740
744
  const i = o.querySelector(".cell[data-row]"), r = Me(i);
741
745
  if (r < 0) return;
742
- const s = t._rows[r];
743
- if (!s || t._dispatchRowClick?.(e, r, s, o))
746
+ const l = t._rows[r];
747
+ if (!l || t._dispatchRowClick?.(e, r, l, o))
744
748
  return;
745
- const l = e.target?.closest(".cell[data-col]");
746
- if (l) {
747
- const d = Number(l.getAttribute("data-col"));
749
+ const s = e.target?.closest(".cell[data-col]");
750
+ if (s) {
751
+ const d = Number(s.getAttribute("data-col"));
748
752
  if (!isNaN(d)) {
749
- if (t._dispatchCellClick?.(e, r, d, l))
753
+ if (t._dispatchCellClick?.(e, r, d, s))
750
754
  return;
751
755
  const u = t._focusRow !== r || t._focusCol !== d;
752
- if (t._focusRow = r, t._focusCol = d, l.classList.contains("editing")) {
753
- u && (se(t.shadowRoot ?? t._bodyEl), l.classList.add("cell-focus"));
756
+ if (t._focusRow = r, t._focusCol = d, s.classList.contains("editing")) {
757
+ u && (le(t.shadowRoot ?? t._bodyEl), s.classList.add("cell-focus"));
754
758
  return;
755
759
  }
756
760
  k(t);
757
761
  }
758
762
  }
759
763
  if (t._activeEditRows === r) {
760
- l && (se(t.shadowRoot ?? t._bodyEl), l.classList.add("cell-focus"), queueMicrotask(() => {
761
- const d = Number(l.getAttribute("data-col")), u = t._visibleColumns[d];
762
- if (u && u.editable && l.classList.contains("editing")) {
763
- const w = l.querySelector(B);
764
+ s && (le(t.shadowRoot ?? t._bodyEl), s.classList.add("cell-focus"), queueMicrotask(() => {
765
+ const d = Number(s.getAttribute("data-col")), u = t._visibleColumns[d];
766
+ if (u && u.editable && s.classList.contains("editing")) {
767
+ const w = s.querySelector(q);
764
768
  try {
765
769
  w?.focus({ preventScroll: !0 });
766
770
  } catch {
@@ -784,15 +788,15 @@ function be(t, e, o, n) {
784
788
  t.beginBulkEdit(r);
785
789
  return;
786
790
  }
787
- G(t, r, s);
791
+ G(t, r, l);
788
792
  } else return;
789
793
  Array.from(o.children).forEach((d, u) => {
790
794
  const w = t._visibleColumns[u];
791
- w && w.editable && H(t, s, r, w, d, !0);
792
- }), l && queueMicrotask(() => {
795
+ w && w.editable && H(t, l, r, w, d, !0);
796
+ }), s && queueMicrotask(() => {
793
797
  const d = o.querySelector(`.cell[data-col="${t._focusCol}"]`);
794
798
  if (d?.classList.contains("editing")) {
795
- const u = d.querySelector(B);
799
+ const u = d.querySelector(q);
796
800
  try {
797
801
  u?.focus({ preventScroll: !0 });
798
802
  } catch {
@@ -800,24 +804,24 @@ function be(t, e, o, n) {
800
804
  }
801
805
  });
802
806
  }
803
- const B = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';
804
- function le(t) {
807
+ const q = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])';
808
+ function se(t) {
805
809
  return !(t === "__proto__" || t === "constructor" || t === "prototype");
806
810
  }
807
811
  function ee(t) {
808
812
  return (t.__editingCellCount ?? 0) > 0;
809
813
  }
810
- function _t(t) {
814
+ function Ct(t) {
811
815
  const e = (t.__editingCellCount ?? 0) + 1;
812
816
  t.__editingCellCount = e, t.setAttribute("data-has-editing", "");
813
817
  }
814
818
  function te(t) {
815
819
  t.__editingCellCount = 0, t.removeAttribute("data-has-editing");
816
820
  }
817
- function Ct(t, e, o, n, i) {
821
+ function Et(t, e, o, n, i) {
818
822
  const r = t.querySelector("input,textarea,select");
819
823
  if (!r) return;
820
- const s = () => {
824
+ const l = () => {
821
825
  if (r instanceof HTMLInputElement) {
822
826
  if (r.type === "checkbox") return r.checked;
823
827
  if (r.type === "number") return r.value === "" ? null : Number(r.value);
@@ -826,8 +830,8 @@ function Ct(t, e, o, n, i) {
826
830
  return e.type === "number" && r.value !== "" ? Number(r.value) : r.value;
827
831
  };
828
832
  r.addEventListener("blur", () => {
829
- o(s());
830
- }), r instanceof HTMLInputElement && r.type === "checkbox" ? r.addEventListener("change", () => o(r.checked)) : r instanceof HTMLSelectElement && r.addEventListener("change", () => o(s()));
833
+ o(l());
834
+ }), r instanceof HTMLInputElement && r.type === "checkbox" ? r.addEventListener("change", () => o(r.checked)) : r instanceof HTMLSelectElement && r.addEventListener("change", () => o(l()));
831
835
  }
832
836
  function G(t, e, o) {
833
837
  t._activeEditRows !== e && (t._rowEditSnapshots.set(e, { ...o }), t._activeEditRows = e);
@@ -835,26 +839,26 @@ function G(t, e, o) {
835
839
  function D(t, e, o) {
836
840
  if (t._activeEditRows !== e) return;
837
841
  const n = t._rowEditSnapshots.get(e), i = t._rows[e], r = t.findRenderedRowElement?.(e);
838
- if (!o && r && i && r.querySelectorAll(".cell.editing").forEach((l) => {
839
- const a = Number(l.getAttribute("data-col"));
842
+ if (!o && r && i && r.querySelectorAll(".cell.editing").forEach((s) => {
843
+ const a = Number(s.getAttribute("data-col"));
840
844
  if (isNaN(a)) return;
841
845
  const c = t._visibleColumns[a];
842
846
  if (!c) return;
843
- const f = l.querySelector("input,textarea,select");
847
+ const f = s.querySelector("input,textarea,select");
844
848
  if (f) {
845
849
  let d;
846
850
  f instanceof HTMLInputElement && f.type === "checkbox" ? d = f.checked : (d = f.value, c.type === "number" && d !== "" && (d = Number(d))), i[c.field] !== d && ce(t, e, c, d, i);
847
851
  }
848
852
  }), o && n && i)
849
- Object.keys(n).forEach((s) => i[s] = n[s]), t._changedRowIndices.delete(e), Y(t);
853
+ Object.keys(n).forEach((l) => i[l] = n[l]), t._changedRowIndices.delete(e), Y(t);
850
854
  else if (!o) {
851
- const s = t._changedRowIndices.has(e);
855
+ const l = t._changedRowIndices.has(e);
852
856
  t.dispatchEvent(
853
857
  new CustomEvent("row-commit", {
854
858
  detail: {
855
859
  rowIndex: e,
856
860
  row: i,
857
- changed: s,
861
+ changed: l,
858
862
  changedRows: t.changedRows,
859
863
  changedRowIndices: t.changedRowIndices
860
864
  }
@@ -863,12 +867,12 @@ function D(t, e, o) {
863
867
  }
864
868
  t._rowEditSnapshots.delete(e), t._activeEditRows = -1, r && ($(t, r, t._rows[e], e), t._changedRowIndices.has(e) ? r.classList.add("changed") : r.classList.remove("changed")), queueMicrotask(() => {
865
869
  try {
866
- const s = t._focusRow, l = t._focusCol, a = t.findRenderedRowElement?.(s);
870
+ const l = t._focusRow, s = t._focusCol, a = t.findRenderedRowElement?.(l);
867
871
  if (a) {
868
872
  Array.from(t._bodyEl.querySelectorAll(".cell-focus")).forEach(
869
873
  (f) => f.classList.remove("cell-focus")
870
874
  );
871
- const c = a.querySelector(`.cell[data-row="${s}"][data-col="${l}"]`);
875
+ const c = a.querySelector(`.cell[data-row="${l}"][data-col="${s}"]`);
872
876
  c && (c.classList.add("cell-focus"), c.setAttribute("aria-selected", "true"), c.hasAttribute("tabindex") || c.setAttribute("tabindex", "-1"), c.focus({ preventScroll: !0 }));
873
877
  }
874
878
  } catch {
@@ -877,9 +881,9 @@ function D(t, e, o) {
877
881
  }
878
882
  function ce(t, e, o, n, i) {
879
883
  const r = o.field;
880
- if (!le(r) || i[r] === n) return;
884
+ if (!se(r) || i[r] === n) return;
881
885
  i[r] = n;
882
- const l = !t._changedRowIndices.has(e);
886
+ const s = !t._changedRowIndices.has(e);
883
887
  t._changedRowIndices.add(e);
884
888
  const a = t.findRenderedRowElement?.(e);
885
889
  a && a.classList.add("changed"), t.dispatchEvent(
@@ -891,33 +895,33 @@ function ce(t, e, o, n, i) {
891
895
  rowIndex: e,
892
896
  changedRows: t.changedRows,
893
897
  changedRowIndices: t.changedRowIndices,
894
- firstTimeForRow: l
898
+ firstTimeForRow: s
895
899
  }
896
900
  })
897
901
  );
898
902
  }
899
903
  function H(t, e, o, n, i, r = !1) {
900
904
  if (!n.editable || (t._activeEditRows !== o && G(t, o, e), i.classList.contains("editing"))) return;
901
- const s = le(n.field) ? e[n.field] : void 0;
905
+ const l = se(n.field) ? e[n.field] : void 0;
902
906
  i.classList.add("editing");
903
- const l = i.parentElement;
904
- l && _t(l);
907
+ const s = i.parentElement;
908
+ s && Ct(s);
905
909
  let a = !1;
906
910
  const c = (p) => {
907
911
  a || t._activeEditRows === -1 || ce(t, o, n, p, e);
908
912
  }, f = () => {
909
- a = !0, e[n.field] = le(n.field) ? s : void 0;
913
+ a = !0, e[n.field] = se(n.field) ? l : void 0;
910
914
  const p = i.querySelector("input,textarea,select");
911
- p && (typeof HTMLInputElement < "u" && p instanceof HTMLInputElement && p.type === "checkbox" ? p.checked = !!s : "value" in p && (p.value = s ?? ""));
915
+ p && (typeof HTMLInputElement < "u" && p instanceof HTMLInputElement && p.type === "checkbox" ? p.checked = !!l : "value" in p && (p.value = l ?? ""));
912
916
  }, d = document.createElement("div");
913
917
  d.style.display = "contents", i.innerHTML = "", i.appendChild(d), d.addEventListener("keydown", (p) => {
914
918
  p.key === "Enter" && (p.stopPropagation(), p.preventDefault(), a = !0, D(t, o, !1)), p.key === "Escape" && (p.stopPropagation(), p.preventDefault(), f(), D(t, o, !0));
915
919
  });
916
- const u = n.__editorTemplate, w = n.editor || (u ? "template" : ft(n)), h = s;
920
+ const u = n.__editorTemplate, w = n.editor || (u ? "template" : pt(n)), h = l;
917
921
  if (w === "template" && u) {
918
922
  const p = u.cloneNode(!0), g = n.__compiledEditor;
919
- g ? p.innerHTML = g({ row: e, value: s, field: n.field, column: n }) : p.querySelectorAll("*").forEach((_) => {
920
- _.childNodes.length === 1 && _.firstChild?.nodeType === Node.TEXT_NODE && (_.textContent = _.textContent?.replace(/{{\s*value\s*}}/g, s == null ? "" : String(s)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (v, m) => {
923
+ g ? p.innerHTML = g({ row: e, value: l, field: n.field, column: n }) : p.querySelectorAll("*").forEach((_) => {
924
+ _.childNodes.length === 1 && _.firstChild?.nodeType === Node.TEXT_NODE && (_.textContent = _.textContent?.replace(/{{\s*value\s*}}/g, l == null ? "" : String(l)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (v, m) => {
921
925
  const E = e[m];
922
926
  return E == null ? "" : String(E);
923
927
  }) || "");
@@ -925,7 +929,7 @@ function H(t, e, o, n, i, r = !1) {
925
929
  const b = p.querySelector("input,textarea,select");
926
930
  if (b) {
927
931
  const _ = typeof HTMLInputElement < "u";
928
- _ && b instanceof HTMLInputElement && b.type === "checkbox" ? b.checked = !!s : "value" in b && (b.value = s ?? ""), b.addEventListener("blur", () => {
932
+ _ && b instanceof HTMLInputElement && b.type === "checkbox" ? b.checked = !!l : "value" in b && (b.value = l ?? ""), b.addEventListener("blur", () => {
929
933
  const v = _ && b instanceof HTMLInputElement && b.type === "checkbox" ? b.checked : b.value;
930
934
  c(v);
931
935
  }), b.addEventListener("keydown", (v) => {
@@ -944,12 +948,12 @@ function H(t, e, o, n, i, r = !1) {
944
948
  } else if (typeof w == "string") {
945
949
  const p = document.createElement(w);
946
950
  p.value = h, p.addEventListener("change", () => c(p.value)), d.appendChild(p), r || queueMicrotask(() => {
947
- d.querySelector(B)?.focus({ preventScroll: !0 });
951
+ d.querySelector(q)?.focus({ preventScroll: !0 });
948
952
  });
949
953
  } else if (typeof w == "function") {
950
954
  const p = w({ row: e, value: h, field: n.field, column: n, commit: c, cancel: f });
951
- typeof p == "string" ? (d.innerHTML = p, Ct(d, n, c)) : d.appendChild(p), r || queueMicrotask(() => {
952
- d.querySelector(B)?.focus({ preventScroll: !0 });
955
+ typeof p == "string" ? (d.innerHTML = p, Et(d, n, c)) : d.appendChild(p), r || queueMicrotask(() => {
956
+ d.querySelector(q)?.focus({ preventScroll: !0 });
953
957
  });
954
958
  } else if (w && typeof w == "object") {
955
959
  const p = document.createElement("div");
@@ -966,7 +970,7 @@ function H(t, e, o, n, i, r = !1) {
966
970
  );
967
971
  }
968
972
  }
969
- function Et(t, e, o) {
973
+ function yt(t, e, o) {
970
974
  t.dispatchEvent(new CustomEvent(e, { detail: o, bubbles: !0 }));
971
975
  }
972
976
  function De(t) {
@@ -975,38 +979,38 @@ function De(t) {
975
979
  function ze(t) {
976
980
  return Array.from(t._changedRowIndices);
977
981
  }
978
- function yt(t, e) {
979
- t._changedRowIndices.clear(), e || Et(t, "changed-rows-reset", {
982
+ function St(t, e) {
983
+ t._changedRowIndices.clear(), e || yt(t, "changed-rows-reset", {
980
984
  rows: De(t),
981
985
  indices: ze(t)
982
986
  }), t._rowPool.forEach((o) => o.classList.remove("changed"));
983
987
  }
984
- function St(t, e, o) {
985
- if (t.effectiveConfig?.editOn === !1 || !t._columns.some((s) => s.editable)) return;
988
+ function Rt(t, e, o) {
989
+ if (t.effectiveConfig?.editOn === !1 || !t._columns.some((l) => l.editable)) return;
986
990
  const i = t._rows[e];
987
991
  G(t, e, i);
988
992
  const r = o.findRenderedRowElement(e);
989
- r && (Array.from(r.children).forEach((s, l) => {
990
- const a = t._visibleColumns[l];
993
+ r && (Array.from(r.children).forEach((l, s) => {
994
+ const a = t._visibleColumns[s];
991
995
  if (a?.editable) {
992
- const c = s;
996
+ const c = l;
993
997
  c.classList.contains("editing") || H(t, i, e, a, c, !0);
994
998
  }
995
999
  }), setTimeout(() => {
996
- let s = r.querySelector(`.cell[data-col="${t._focusCol}"]`);
997
- if (s?.classList.contains("editing") || (s = r.querySelector(".cell.editing")), s?.classList.contains("editing")) {
998
- const l = s.querySelector(B);
1000
+ let l = r.querySelector(`.cell[data-col="${t._focusCol}"]`);
1001
+ if (l?.classList.contains("editing") || (l = r.querySelector(".cell.editing")), l?.classList.contains("editing")) {
1002
+ const s = l.querySelector(q);
999
1003
  try {
1000
- l?.focus({ preventScroll: !0 });
1004
+ s?.focus({ preventScroll: !0 });
1001
1005
  } catch {
1002
1006
  }
1003
1007
  }
1004
1008
  }, 0));
1005
1009
  }
1006
- function Rt(t) {
1010
+ function Tt(t) {
1007
1011
  t._activeEditRows !== -1 && D(t, t._activeEditRows, !1);
1008
1012
  }
1009
- function Tt(t) {
1013
+ function xt(t) {
1010
1014
  t._activeEditRows !== -1 && D(t, t._activeEditRows, !0);
1011
1015
  }
1012
1016
  function oe(t, e) {
@@ -1015,17 +1019,17 @@ function oe(t, e) {
1015
1019
  const i = t._rows[o], r = t._visibleColumns[n];
1016
1020
  return !i || !r ? null : { rowIndex: o, colIndex: n, rowData: i, col: r };
1017
1021
  }
1018
- function xt(t, e) {
1022
+ function At(t, e) {
1019
1023
  if (e.classList.contains("editing")) return;
1020
1024
  const o = oe(t, e);
1021
1025
  o && (t._focusRow = o.rowIndex, t._focusCol = o.colIndex, k(t));
1022
1026
  }
1023
- function At(t, e, o) {
1027
+ function Lt(t, e, o) {
1024
1028
  if (e.classList.contains("editing")) return;
1025
1029
  const n = oe(t, e);
1026
1030
  n && (o.stopPropagation(), t._focusRow = n.rowIndex, t._focusCol = n.colIndex, H(t, n.rowData, n.rowIndex, n.col, e));
1027
1031
  }
1028
- function Lt(t, e, o) {
1032
+ function Pt(t, e, o) {
1029
1033
  o.stopPropagation();
1030
1034
  const n = oe(t, e);
1031
1035
  if (!n) return;
@@ -1037,28 +1041,28 @@ function Lt(t, e, o) {
1037
1041
  const i = t.findRenderedRowElement?.(n.rowIndex);
1038
1042
  if (i) {
1039
1043
  const r = i.children;
1040
- for (let s = 0; s < r.length; s++) {
1041
- const l = t._visibleColumns[s];
1042
- l && l.editable && H(t, n.rowData, n.rowIndex, l, r[s], !0);
1044
+ for (let l = 0; l < r.length; l++) {
1045
+ const s = t._visibleColumns[l];
1046
+ s && s.editable && H(t, n.rowData, n.rowIndex, s, r[l], !0);
1043
1047
  }
1044
1048
  queueMicrotask(() => {
1045
- const s = i.querySelector(`.cell[data-col="${t._focusCol}"]`);
1046
- if (s?.classList.contains("editing")) {
1047
- const l = s.querySelector(B);
1049
+ const l = i.querySelector(`.cell[data-col="${t._focusCol}"]`);
1050
+ if (l?.classList.contains("editing")) {
1051
+ const s = l.querySelector(q);
1048
1052
  try {
1049
- l?.focus({ preventScroll: !0 });
1053
+ s?.focus({ preventScroll: !0 });
1050
1054
  } catch {
1051
1055
  }
1052
1056
  }
1053
1057
  });
1054
1058
  }
1055
1059
  }
1056
- function Pt(t, e, o) {
1060
+ function Ht(t, e, o) {
1057
1061
  const n = oe(t, e);
1058
1062
  if (!n) return;
1059
- const { rowIndex: i, colIndex: r, rowData: s, col: l } = n, a = e.classList.contains("editing");
1060
- if ((l.type === "select" || l.type === "typeahead") && !a && o.key === "Enter") {
1061
- o.preventDefault(), t._activeEditRows !== i && G(t, i, s), H(t, s, i, l, e), setTimeout(() => {
1063
+ const { rowIndex: i, colIndex: r, rowData: l, col: s } = n, a = e.classList.contains("editing");
1064
+ if ((s.type === "select" || s.type === "typeahead") && !a && o.key === "Enter") {
1065
+ o.preventDefault(), t._activeEditRows !== i && G(t, i, l), H(t, l, i, s, e), setTimeout(() => {
1062
1066
  const c = e.querySelector("select");
1063
1067
  try {
1064
1068
  c?.showPicker?.();
@@ -1068,44 +1072,44 @@ function Pt(t, e, o) {
1068
1072
  }, 0);
1069
1073
  return;
1070
1074
  }
1071
- if (l.type === "boolean" && o.key === " " && !a) {
1072
- o.preventDefault(), t._activeEditRows !== i && G(t, i, s);
1073
- const c = !s[l.field];
1074
- ce(t, i, l, c, s), e.innerHTML = ae(!!c);
1075
+ if (s.type === "boolean" && o.key === " " && !a) {
1076
+ o.preventDefault(), t._activeEditRows !== i && G(t, i, l);
1077
+ const c = !l[s.field];
1078
+ ce(t, i, s, c, l), e.innerHTML = ae(!!c);
1075
1079
  return;
1076
1080
  }
1077
1081
  if (o.key === "Enter" && !a) {
1078
- o.preventDefault(), o.stopPropagation(), t._focusRow = i, t._focusCol = r, typeof t.beginBulkEdit == "function" ? t.beginBulkEdit(i) : H(t, s, i, l, e);
1082
+ o.preventDefault(), o.stopPropagation(), t._focusRow = i, t._focusCol = r, typeof t.beginBulkEdit == "function" ? t.beginBulkEdit(i) : H(t, l, i, s, e);
1079
1083
  return;
1080
1084
  }
1081
1085
  if (o.key === "F2" && !a) {
1082
- o.preventDefault(), H(t, s, i, l, e);
1086
+ o.preventDefault(), H(t, l, i, s, e);
1083
1087
  return;
1084
1088
  }
1085
1089
  }
1086
- function Ht(t, e, o) {
1090
+ function Mt(t, e, o) {
1087
1091
  const n = () => t.effectiveConfig?.editOn || t.editOn;
1088
1092
  e.addEventListener(
1089
1093
  "mousedown",
1090
1094
  (i) => {
1091
1095
  const r = i.target.closest(".cell[data-col]");
1092
1096
  if (!r) return;
1093
- const s = X(r);
1094
- if (s < 0) return;
1095
- const l = t._visibleColumns[s];
1096
- l && l.editable && xt(t, r);
1097
+ const l = X(r);
1098
+ if (l < 0) return;
1099
+ const s = t._visibleColumns[l];
1100
+ s && s.editable && At(t, r);
1097
1101
  },
1098
1102
  { signal: o }
1099
1103
  ), e.addEventListener(
1100
1104
  "click",
1101
1105
  (i) => {
1102
1106
  if (n() !== "click") return;
1103
- const s = i.target.closest(".cell[data-col]");
1104
- if (!s) return;
1105
- const l = X(s);
1106
- if (l < 0) return;
1107
- const a = t._visibleColumns[l];
1108
- a && a.editable && At(t, s, i);
1107
+ const l = i.target.closest(".cell[data-col]");
1108
+ if (!l) return;
1109
+ const s = X(l);
1110
+ if (s < 0) return;
1111
+ const a = t._visibleColumns[s];
1112
+ a && a.editable && Lt(t, l, i);
1109
1113
  },
1110
1114
  { signal: o }
1111
1115
  ), e.addEventListener(
@@ -1113,12 +1117,12 @@ function Ht(t, e, o) {
1113
1117
  (i) => {
1114
1118
  const r = n();
1115
1119
  if ((r === "dblclick" ? "dblClick" : r) === "click" || r === !1) return;
1116
- const l = i.target.closest(".cell[data-col]");
1117
- if (!l) return;
1118
- const a = X(l);
1120
+ const s = i.target.closest(".cell[data-col]");
1121
+ if (!s) return;
1122
+ const a = X(s);
1119
1123
  if (a < 0) return;
1120
1124
  const c = t._visibleColumns[a];
1121
- c && c.editable && Lt(t, l, i);
1125
+ c && c.editable && Pt(t, s, i);
1122
1126
  },
1123
1127
  { signal: o }
1124
1128
  ), e.addEventListener(
@@ -1126,20 +1130,20 @@ function Ht(t, e, o) {
1126
1130
  (i) => {
1127
1131
  const r = i.target.closest(".cell[data-col]");
1128
1132
  if (!r) return;
1129
- const s = X(r);
1130
- if (s < 0) return;
1131
- const l = t._visibleColumns[s];
1132
- l && l.editable && Pt(t, r, i);
1133
+ const l = X(r);
1134
+ if (l < 0) return;
1135
+ const s = t._visibleColumns[l];
1136
+ s && s.editable && Ht(t, r, i);
1133
1137
  },
1134
1138
  { signal: o }
1135
1139
  );
1136
1140
  }
1137
- function Mt(t, e) {
1141
+ function Ot(t, e) {
1138
1142
  return t == null && e == null ? 0 : t == null ? -1 : e == null || t > e ? 1 : t < e ? -1 : 0;
1139
1143
  }
1140
- function Ot(t, e, o) {
1141
- const i = o.find((l) => l.field === e.field)?.sortComparator ?? Mt, { field: r, direction: s } = e;
1142
- return [...t].sort((l, a) => i(l[r], a[r], l, a) * s);
1144
+ function kt(t, e, o) {
1145
+ const i = o.find((s) => s.field === e.field)?.sortComparator ?? Ot, { field: r, direction: l } = e;
1146
+ return [...t].sort((s, a) => i(s[r], a[r], s, a) * l);
1143
1147
  }
1144
1148
  function ge(t, e, o, n) {
1145
1149
  t._rows = e, t.__rowRenderEpoch++, t._rowPool.forEach((i) => i.__epoch = -1), F(t), t.refreshVirtualWindow(!0), t.dispatchEvent(
@@ -1155,12 +1159,12 @@ function me(t, e) {
1155
1159
  }
1156
1160
  function ve(t, e, o) {
1157
1161
  t._sortState = { field: e.field, direction: o };
1158
- const n = { field: e.field, direction: o }, i = t._columns, s = (t.effectiveConfig?.sortHandler ?? Ot)(t._rows, n, i);
1159
- s && typeof s.then == "function" ? s.then((l) => {
1160
- ge(t, l, e, o);
1161
- }) : ge(t, s, e, o);
1162
+ const n = { field: e.field, direction: o }, i = t._columns, l = (t.effectiveConfig?.sortHandler ?? kt)(t._rows, n, i);
1163
+ l && typeof l.then == "function" ? l.then((s) => {
1164
+ ge(t, s, e, o);
1165
+ }) : ge(t, l, e, o);
1162
1166
  }
1163
- function kt(t, e) {
1167
+ function Dt(t, e) {
1164
1168
  typeof e == "string" ? t.textContent = e : e instanceof HTMLElement && (t.innerHTML = "", t.appendChild(e.cloneNode(!0)));
1165
1169
  }
1166
1170
  function F(t) {
@@ -1170,17 +1174,17 @@ function F(t) {
1170
1174
  const i = document.createElement("div");
1171
1175
  i.className = "cell", fe(i, "header-cell"), i.setAttribute("role", "columnheader"), i.setAttribute("aria-colindex", String(n + 1)), i.setAttribute("data-field", o.field), i.setAttribute("data-col", String(n));
1172
1176
  const r = o.__headerTemplate;
1173
- if (r) Array.from(r.childNodes).forEach((s) => i.appendChild(s.cloneNode(!0)));
1177
+ if (r) Array.from(r.childNodes).forEach((l) => i.appendChild(l.cloneNode(!0)));
1174
1178
  else {
1175
- const s = o.header || o.field, l = document.createElement("span");
1176
- l.textContent = s, i.appendChild(l);
1179
+ const l = o.header || o.field, s = document.createElement("span");
1180
+ s.textContent = l, i.appendChild(s);
1177
1181
  }
1178
1182
  if (o.sortable) {
1179
1183
  i.classList.add("sortable"), i.tabIndex = 0;
1180
- const s = document.createElement("span");
1181
- fe(s, "sort-indicator");
1182
- const l = t._sortState?.field === o.field ? t._sortState.direction : 0, a = { ...O, ...t.icons }, c = l === 1 ? a.sortAsc : l === -1 ? a.sortDesc : a.sortNone;
1183
- kt(s, c), i.appendChild(s), i.setAttribute("aria-sort", l === 0 ? "none" : l === 1 ? "ascending" : "descending"), i.addEventListener("click", (f) => {
1184
+ const l = document.createElement("span");
1185
+ fe(l, "sort-indicator");
1186
+ const s = t._sortState?.field === o.field ? t._sortState.direction : 0, a = { ...O, ...t.icons }, c = s === 1 ? a.sortAsc : s === -1 ? a.sortDesc : a.sortNone;
1187
+ Dt(l, c), i.appendChild(l), i.setAttribute("aria-sort", s === 0 ? "none" : s === 1 ? "ascending" : "descending"), i.addEventListener("click", (f) => {
1184
1188
  t._resizeController?.isResizing || t._dispatchHeaderClick?.(f, n, i) || me(t, o);
1185
1189
  }), i.addEventListener("keydown", (f) => {
1186
1190
  if (f.key === "Enter" || f.key === " ") {
@@ -1191,12 +1195,12 @@ function F(t) {
1191
1195
  }
1192
1196
  if (o.resizable) {
1193
1197
  i.style.position = "relative";
1194
- const s = document.createElement("div");
1195
- s.className = "resize-handle", s.setAttribute("aria-hidden", "true"), s.addEventListener("mousedown", (l) => {
1196
- l.stopPropagation(), l.preventDefault(), t._resizeController.start(l, n, i);
1197
- }), s.addEventListener("dblclick", (l) => {
1198
- l.stopPropagation(), l.preventDefault(), t._resizeController.resetColumn(n);
1199
- }), i.appendChild(s);
1198
+ const l = document.createElement("div");
1199
+ l.className = "resize-handle", l.setAttribute("aria-hidden", "true"), l.addEventListener("mousedown", (s) => {
1200
+ s.stopPropagation(), s.preventDefault(), t._resizeController.start(s, n, i);
1201
+ }), l.addEventListener("dblclick", (s) => {
1202
+ s.stopPropagation(), s.preventDefault(), t._resizeController.resetColumn(n);
1203
+ }), i.appendChild(l);
1200
1204
  }
1201
1205
  e.appendChild(i);
1202
1206
  }), e.querySelectorAll(".cell.sortable").forEach((o) => {
@@ -1204,7 +1208,7 @@ function F(t) {
1204
1208
  }), e.children.length > 0 ? (e.setAttribute("role", "row"), e.setAttribute("aria-rowindex", "1")) : (e.removeAttribute("role"), e.removeAttribute("aria-rowindex"));
1205
1209
  }
1206
1210
  const Ne = typeof requestIdleCallback == "function";
1207
- function Dt(t, e) {
1211
+ function zt(t, e) {
1208
1212
  return Ne ? requestIdleCallback(t, e) : window.setTimeout(() => {
1209
1213
  const o = Date.now();
1210
1214
  t({
@@ -1216,7 +1220,7 @@ function Dt(t, e) {
1216
1220
  function _e(t) {
1217
1221
  Ne ? cancelIdleCallback(t) : clearTimeout(t);
1218
1222
  }
1219
- function zt(t) {
1223
+ function Nt(t) {
1220
1224
  let e = null, o = null, n = null, i = null;
1221
1225
  const r = (a) => {
1222
1226
  if (!e) return;
@@ -1227,21 +1231,21 @@ function zt(t) {
1227
1231
  new CustomEvent("column-resize", { detail: { field: d.field, width: f } })
1228
1232
  );
1229
1233
  };
1230
- let s = !1;
1231
- const l = () => {
1234
+ let l = !1;
1235
+ const s = () => {
1232
1236
  const a = e !== null;
1233
- a && (s = !0, requestAnimationFrame(() => {
1234
- s = !1;
1235
- })), window.removeEventListener("mousemove", r), window.removeEventListener("mouseup", l), n !== null && (document.documentElement.style.cursor = n, n = null), i !== null && (document.body.style.userSelect = i, i = null), e = null, a && t.requestStateChange && t.requestStateChange();
1237
+ a && (l = !0, requestAnimationFrame(() => {
1238
+ l = !1;
1239
+ })), window.removeEventListener("mousemove", r), window.removeEventListener("mouseup", s), n !== null && (document.documentElement.style.cursor = n, n = null), i !== null && (document.body.style.userSelect = i, i = null), e = null, a && t.requestStateChange && t.requestStateChange();
1236
1240
  };
1237
1241
  return {
1238
1242
  get isResizing() {
1239
- return e !== null || s;
1243
+ return e !== null || l;
1240
1244
  },
1241
1245
  start(a, c, f) {
1242
1246
  a.preventDefault();
1243
1247
  const d = f.getBoundingClientRect();
1244
- e = { startX: a.clientX, colIndex: c, startWidth: d.width }, window.addEventListener("mousemove", r), window.addEventListener("mouseup", l), 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";
1248
+ e = { startX: a.clientX, colIndex: c, startWidth: d.width }, window.addEventListener("mousemove", r), window.addEventListener("mouseup", s), 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";
1245
1249
  },
1246
1250
  resetColumn(a) {
1247
1251
  const c = t._visibleColumns[a];
@@ -1250,7 +1254,7 @@ function zt(t) {
1250
1254
  ));
1251
1255
  },
1252
1256
  dispose() {
1253
- l();
1257
+ s();
1254
1258
  }
1255
1259
  };
1256
1260
  }
@@ -1285,8 +1289,8 @@ function Ce(t) {
1285
1289
  const e = document.createElement("slot");
1286
1290
  return t && (e.name = t), e;
1287
1291
  }
1288
- const Be = document.createElement("template");
1289
- Be.innerHTML = `
1292
+ const qe = document.createElement("template");
1293
+ qe.innerHTML = `
1290
1294
  <div class="tbw-scroll-area">
1291
1295
  <div class="rows-body-wrapper">
1292
1296
  <div class="rows-body" role="grid">
@@ -1305,8 +1309,8 @@ Be.innerHTML = `
1305
1309
  <div class="faux-vscroll-spacer"></div>
1306
1310
  </div>
1307
1311
  `;
1308
- function qe() {
1309
- return Be.content.cloneNode(!0);
1312
+ function Be() {
1313
+ return qe.content.cloneNode(!0);
1310
1314
  }
1311
1315
  function Ee(t) {
1312
1316
  const e = document.createDocumentFragment(), o = T(t.hasShell ? "tbw-grid-root has-shell" : "tbw-grid-root");
@@ -1314,11 +1318,11 @@ function Ee(t) {
1314
1318
  o.appendChild(t.shellHeader), o.appendChild(t.shellBody);
1315
1319
  else {
1316
1320
  const n = T("tbw-grid-content");
1317
- n.appendChild(qe()), o.appendChild(n);
1321
+ n.appendChild(Be()), o.appendChild(n);
1318
1322
  }
1319
1323
  return e.appendChild(o), e;
1320
1324
  }
1321
- function Nt(t) {
1325
+ function It(t) {
1322
1326
  const e = T("tbw-shell-header", { part: "shell-header", role: "presentation" });
1323
1327
  if (t.title) {
1324
1328
  const r = T("tbw-shell-title");
@@ -1343,9 +1347,9 @@ function Nt(t) {
1343
1347
  }
1344
1348
  return e.appendChild(n), e;
1345
1349
  }
1346
- function It(t) {
1350
+ function qt(t) {
1347
1351
  const e = T("tbw-shell-body"), o = t.panels.length > 0, n = t.panels.length === 1, i = T("tbw-grid-content");
1348
- i.appendChild(qe());
1352
+ i.appendChild(Be());
1349
1353
  let r = null;
1350
1354
  if (o) {
1351
1355
  r = Z("aside", {
@@ -1355,15 +1359,15 @@ function It(t) {
1355
1359
  role: "presentation",
1356
1360
  id: "tbw-tool-panel"
1357
1361
  });
1358
- const s = t.position === "left" ? "right" : "left";
1362
+ const l = t.position === "left" ? "right" : "left";
1359
1363
  r.appendChild(
1360
1364
  T("tbw-tool-panel-resize", {
1361
1365
  "data-resize-handle": "",
1362
- "data-handle-position": s,
1366
+ "data-handle-position": l,
1363
1367
  "aria-hidden": "true"
1364
1368
  })
1365
1369
  );
1366
- const l = T("tbw-tool-panel-content", { role: "presentation" }), a = T("tbw-accordion");
1370
+ const s = T("tbw-tool-panel-content", { role: "presentation" }), a = T("tbw-accordion");
1367
1371
  for (const c of t.panels) {
1368
1372
  const f = `tbw-accordion-section${c.isExpanded ? " expanded" : ""}${n ? " single" : ""}`, d = T(f, { "data-section": c.id }), u = Ie("tbw-accordion-header", {
1369
1373
  "aria-expanded": String(c.isExpanded),
@@ -1385,7 +1389,7 @@ function It(t) {
1385
1389
  })
1386
1390
  ), a.appendChild(d);
1387
1391
  }
1388
- l.appendChild(a), r.appendChild(l);
1392
+ s.appendChild(a), r.appendChild(s);
1389
1393
  }
1390
1394
  return t.position === "left" && r ? (e.appendChild(r), e.appendChild(i)) : (e.appendChild(i), r && e.appendChild(r)), e;
1391
1395
  }
@@ -1413,7 +1417,7 @@ function We(t, e) {
1413
1417
  return !!(t?.header?.title || e.lightDomTitle || t?.header?.toolbarButtons?.length || e.toolPanels.size > 0 || e.headerContents.size > 0 || e.toolbarButtons.size > 0 || e.lightDomHeaderContent.length > 0 || e.hasToolButtonsContainer);
1414
1418
  }
1415
1419
  function ye(t, e, o = "☰") {
1416
- const n = t?.header?.title ?? e.lightDomTitle ?? "", i = !!n, r = N(o), s = t?.header?.toolbarButtons ?? [], l = s.some((p) => p.element || p.render), a = [...e.toolbarButtons.values()].some((p) => p.element || p.render), c = e.toolPanels.size > 0, d = (l || a) && c, u = [...s].sort((p, g) => (p.order ?? 100) - (g.order ?? 100)), w = [...e.toolbarButtons.values()].sort((p, g) => (p.order ?? 100) - (g.order ?? 100));
1420
+ const n = t?.header?.title ?? e.lightDomTitle ?? "", i = !!n, r = N(o), l = t?.header?.toolbarButtons ?? [], s = l.some((p) => p.element || p.render), a = [...e.toolbarButtons.values()].some((p) => p.element || p.render), c = e.toolPanels.size > 0, d = (s || a) && c, u = [...l].sort((p, g) => (p.order ?? 100) - (g.order ?? 100)), w = [...e.toolbarButtons.values()].sort((p, g) => (p.order ?? 100) - (g.order ?? 100));
1417
1421
  let h = "";
1418
1422
  for (const p of u)
1419
1423
  (p.element || p.render) && (h += `<div class="tbw-toolbar-btn-slot" data-btn-slot="${p.id}"></div>`);
@@ -1425,7 +1429,7 @@ function ye(t, e, o = "☰") {
1425
1429
  }
1426
1430
  return `
1427
1431
  <div class="tbw-shell-header" part="shell-header" role="presentation">
1428
- ${i ? `<div class="tbw-shell-title">${n}</div>` : ""}
1432
+ ${i ? `<div class="tbw-shell-title">${it(n)}</div>` : ""}
1429
1433
  <div class="tbw-shell-content" part="shell-content" role="presentation">
1430
1434
  <slot name="header-content"></slot>
1431
1435
  </div>
@@ -1435,7 +1439,7 @@ function ye(t, e, o = "☰") {
1435
1439
  </div>
1436
1440
  `;
1437
1441
  }
1438
- function q(t, e) {
1442
+ function B(t, e) {
1439
1443
  const o = t.querySelector("tbw-grid-header");
1440
1444
  if (!o) return;
1441
1445
  if (!e.lightDomTitle) {
@@ -1453,10 +1457,10 @@ function W(t, e) {
1453
1457
  }
1454
1458
  function V(t, e, o) {
1455
1459
  t.querySelectorAll(":scope > tbw-grid-tool-panel").forEach((i) => {
1456
- const r = i, s = r.getAttribute("id"), l = r.getAttribute("title");
1457
- if (!s || !l) {
1460
+ const r = i, l = r.getAttribute("id"), s = r.getAttribute("title");
1461
+ if (!l || !s) {
1458
1462
  console.warn(
1459
- `[parseLightDomToolPanels] Tool panel missing required id or title attribute: id="${s ?? ""}", title="${l ?? ""}"`
1463
+ `[parseLightDomToolPanels] Tool panel missing required id or title attribute: id="${l ?? ""}", title="${s ?? ""}"`
1460
1464
  );
1461
1465
  return;
1462
1466
  }
@@ -1472,60 +1476,60 @@ function V(t, e, o) {
1472
1476
  return b.innerHTML = p, g.appendChild(b), () => b.remove();
1473
1477
  };
1474
1478
  }
1475
- const w = e.toolPanels.get(s);
1479
+ const w = e.toolPanels.get(l);
1476
1480
  if (w) {
1477
1481
  if (u) {
1478
1482
  w.render = d, w.order = f, w.icon = a, w.tooltip = c;
1479
- const p = e.panelCleanups.get(s);
1480
- p && (p(), e.panelCleanups.delete(s));
1483
+ const p = e.panelCleanups.get(l);
1484
+ p && (p(), e.panelCleanups.delete(l));
1481
1485
  }
1482
1486
  return;
1483
1487
  }
1484
1488
  const h = {
1485
- id: s,
1486
- title: l,
1489
+ id: l,
1490
+ title: s,
1487
1491
  icon: a,
1488
1492
  tooltip: c,
1489
1493
  order: f,
1490
1494
  render: d
1491
1495
  };
1492
- e.toolPanels.set(s, h), e.lightDomToolPanelIds.add(s), r.style.display = "none";
1496
+ e.toolPanels.set(l, h), e.lightDomToolPanelIds.add(l), r.style.display = "none";
1493
1497
  });
1494
1498
  }
1495
- function qt(t, e, o, n) {
1499
+ function Wt(t, e, o, n) {
1496
1500
  const i = t.querySelector(".tbw-shell-toolbar");
1497
- i && i.addEventListener("click", (s) => {
1498
- const l = s.target;
1499
- if (l.closest("[data-panel-toggle]")) {
1501
+ i && i.addEventListener("click", (l) => {
1502
+ const s = l.target;
1503
+ if (s.closest("[data-panel-toggle]")) {
1500
1504
  n.onPanelToggle();
1501
1505
  return;
1502
1506
  }
1503
- const c = l.closest("[data-btn]");
1507
+ const c = s.closest("[data-btn]");
1504
1508
  if (c) {
1505
1509
  const f = c.getAttribute("data-btn");
1506
1510
  f && n.onToolbarButtonClick(f);
1507
1511
  }
1508
1512
  });
1509
1513
  const r = t.querySelector(".tbw-accordion");
1510
- r && r.addEventListener("click", (s) => {
1511
- const a = s.target.closest(".tbw-accordion-header");
1514
+ r && r.addEventListener("click", (l) => {
1515
+ const a = l.target.closest(".tbw-accordion-header");
1512
1516
  if (a) {
1513
1517
  const f = a.closest("[data-section]")?.getAttribute("data-section");
1514
1518
  f && n.onSectionToggle(f);
1515
1519
  }
1516
1520
  });
1517
1521
  }
1518
- function Wt(t, e, o) {
1522
+ function Vt(t, e, o) {
1519
1523
  const n = t.querySelector(".tbw-tool-panel"), i = t.querySelector("[data-resize-handle]"), r = t.querySelector(".tbw-shell-body");
1520
1524
  if (!n || !i || !r)
1521
1525
  return () => {
1522
1526
  };
1523
- const s = e?.toolPanel?.position ?? "right", l = 200;
1527
+ const l = e?.toolPanel?.position ?? "right", s = 200;
1524
1528
  let a = 0, c = 0, f = 0, d = !1;
1525
1529
  const u = (p) => {
1526
1530
  if (!d) return;
1527
1531
  p.preventDefault();
1528
- const g = s === "left" ? p.clientX - a : a - p.clientX, b = Math.min(f, Math.max(l, c + g));
1532
+ const g = l === "left" ? p.clientX - a : a - p.clientX, b = Math.min(f, Math.max(s, c + g));
1529
1533
  n.style.width = `${b}px`;
1530
1534
  }, w = () => {
1531
1535
  if (!d) return;
@@ -1539,46 +1543,46 @@ function Wt(t, e, o) {
1539
1543
  i.removeEventListener("mousedown", h), document.removeEventListener("mousemove", u), document.removeEventListener("mouseup", w);
1540
1544
  };
1541
1545
  }
1542
- function Vt(t, e, o) {
1546
+ function $t(t, e, o) {
1543
1547
  const n = [...e?.header?.toolbarButtons ?? [], ...o.toolbarButtons.values()];
1544
1548
  for (const i of n) {
1545
1549
  const r = t.querySelector(`[data-btn-slot="${i.id}"]`);
1546
1550
  if (!r) continue;
1547
- const s = o.toolbarButtonCleanups.get(i.id);
1548
- if (s && (s(), o.toolbarButtonCleanups.delete(i.id)), i.element)
1551
+ const l = o.toolbarButtonCleanups.get(i.id);
1552
+ if (l && (l(), o.toolbarButtonCleanups.delete(i.id)), i.element)
1549
1553
  r.appendChild(i.element);
1550
1554
  else if (i.render) {
1551
- const l = i.render(r);
1552
- l && o.toolbarButtonCleanups.set(i.id, l);
1555
+ const s = i.render(r);
1556
+ s && o.toolbarButtonCleanups.set(i.id, s);
1553
1557
  }
1554
1558
  }
1555
1559
  }
1556
1560
  function Ve(t, e) {
1557
1561
  const o = t.querySelector(".tbw-shell-content");
1558
1562
  if (!o) return;
1559
- const n = [...e.headerContents.values()].sort((r, s) => (r.order ?? 100) - (s.order ?? 100)), i = o.querySelector('slot[name="header-content"]');
1563
+ const n = [...e.headerContents.values()].sort((r, l) => (r.order ?? 100) - (l.order ?? 100)), i = o.querySelector('slot[name="header-content"]');
1560
1564
  for (const r of n) {
1561
- const s = e.headerContentCleanups.get(r.id);
1562
- s && (s(), e.headerContentCleanups.delete(r.id));
1563
- let l = o.querySelector(`[data-header-content="${r.id}"]`);
1564
- l || (l = document.createElement("div"), l.setAttribute("data-header-content", r.id), i ? o.insertBefore(l, i) : o.appendChild(l));
1565
- const a = r.render(l);
1565
+ const l = e.headerContentCleanups.get(r.id);
1566
+ l && (l(), e.headerContentCleanups.delete(r.id));
1567
+ let s = o.querySelector(`[data-header-content="${r.id}"]`);
1568
+ s || (s = document.createElement("div"), s.setAttribute("data-header-content", r.id), i ? o.insertBefore(s, i) : o.appendChild(s));
1569
+ const a = r.render(s);
1566
1570
  a && e.headerContentCleanups.set(r.id, a);
1567
1571
  }
1568
1572
  }
1569
- function $t(t, e, o) {
1573
+ function Ft(t, e, o) {
1570
1574
  if (!e.isPanelOpen) return;
1571
1575
  const n = N(o?.expand ?? O.expand), i = N(o?.collapse ?? O.collapse);
1572
- for (const [r, s] of e.toolPanels) {
1573
- const l = e.expandedSections.has(r), a = t.querySelector(`[data-section="${r}"]`), c = a?.querySelector(".tbw-accordion-content");
1576
+ for (const [r, l] of e.toolPanels) {
1577
+ const s = e.expandedSections.has(r), a = t.querySelector(`[data-section="${r}"]`), c = a?.querySelector(".tbw-accordion-content");
1574
1578
  if (!a || !c) continue;
1575
- a.classList.toggle("expanded", l);
1579
+ a.classList.toggle("expanded", s);
1576
1580
  const f = a.querySelector(".tbw-accordion-header");
1577
- f && f.setAttribute("aria-expanded", String(l));
1581
+ f && f.setAttribute("aria-expanded", String(s));
1578
1582
  const d = a.querySelector(".tbw-accordion-chevron");
1579
- if (d && (d.innerHTML = l ? i : n), l) {
1583
+ if (d && (d.innerHTML = s ? i : n), s) {
1580
1584
  if (c.children.length === 0) {
1581
- const u = s.render(c);
1585
+ const u = l.render(c);
1582
1586
  u && e.panelCleanups.set(r, u);
1583
1587
  }
1584
1588
  } else {
@@ -1595,7 +1599,7 @@ function Re(t, e) {
1595
1599
  const o = t.querySelector(".tbw-tool-panel");
1596
1600
  o && (o.classList.toggle("open", e.isPanelOpen), e.isPanelOpen || (o.style.width = ""));
1597
1601
  }
1598
- function Ft(t, e) {
1602
+ function Gt(t, e) {
1599
1603
  const o = [];
1600
1604
  for (const n of t?.header?.toolbarButtons ?? [])
1601
1605
  o.push({
@@ -1618,7 +1622,7 @@ function Ft(t, e) {
1618
1622
  });
1619
1623
  return o;
1620
1624
  }
1621
- function Gt(t) {
1625
+ function Ut(t) {
1622
1626
  for (const e of t.headerContentCleanups.values())
1623
1627
  e();
1624
1628
  t.headerContentCleanups.clear();
@@ -1632,7 +1636,7 @@ function Gt(t) {
1632
1636
  t.toolPanels.get(e)?.onClose?.();
1633
1637
  t.isPanelOpen = !1, t.expandedSections.clear(), t.toolPanels.clear(), t.headerContents.clear(), t.toolbarButtons.clear(), t.lightDomHeaderContent = [];
1634
1638
  }
1635
- function Ut(t, e) {
1639
+ function Xt(t, e) {
1636
1640
  let o = !1;
1637
1641
  const n = {
1638
1642
  get isInitialized() {
@@ -1657,11 +1661,11 @@ function Ut(t, e) {
1657
1661
  return;
1658
1662
  }
1659
1663
  if (t.isPanelOpen = !0, t.expandedSections.size === 0 && t.toolPanels.size > 0) {
1660
- const s = [...t.toolPanels.values()].sort((l, a) => (l.order ?? 100) - (a.order ?? 100))[0];
1661
- s && t.expandedSections.add(s.id);
1664
+ const l = [...t.toolPanels.values()].sort((s, a) => (s.order ?? 100) - (a.order ?? 100))[0];
1665
+ l && t.expandedSections.add(l.id);
1662
1666
  }
1663
1667
  const i = e.getShadow();
1664
- Se(i, t), Re(i, t), $t(i, t, e.getAccordionIcons()), e.emit("tool-panel-open", { sections: n.expandedSections });
1668
+ Se(i, t), Re(i, t), Ft(i, t, e.getAccordionIcons()), e.emit("tool-panel-open", { sections: n.expandedSections });
1665
1669
  },
1666
1670
  closeToolPanel() {
1667
1671
  if (!t.isPanelOpen) return;
@@ -1685,21 +1689,21 @@ function Ut(t, e) {
1685
1689
  }
1686
1690
  if (t.toolPanels.size === 1)
1687
1691
  return;
1688
- const s = e.getShadow(), l = t.expandedSections.has(i);
1689
- if (l) {
1692
+ const l = e.getShadow(), s = t.expandedSections.has(i);
1693
+ if (s) {
1690
1694
  const a = t.panelCleanups.get(i);
1691
- a && (a(), t.panelCleanups.delete(i)), r.onClose?.(), t.expandedSections.delete(i), ie(s, i, !1);
1695
+ a && (a(), t.panelCleanups.delete(i)), r.onClose?.(), t.expandedSections.delete(i), ie(l, i, !1);
1692
1696
  } else {
1693
1697
  for (const [a, c] of t.toolPanels)
1694
1698
  if (a !== i && t.expandedSections.has(a)) {
1695
1699
  const f = t.panelCleanups.get(a);
1696
- f && (f(), t.panelCleanups.delete(a)), c.onClose?.(), t.expandedSections.delete(a), ie(s, a, !1);
1697
- const d = s.querySelector(`[data-section="${a}"] .tbw-accordion-content`);
1700
+ f && (f(), t.panelCleanups.delete(a)), c.onClose?.(), t.expandedSections.delete(a), ie(l, a, !1);
1701
+ const d = l.querySelector(`[data-section="${a}"] .tbw-accordion-content`);
1698
1702
  d && (d.innerHTML = "");
1699
1703
  }
1700
- t.expandedSections.add(i), ie(s, i, !0), Xt(s, t, i);
1704
+ t.expandedSections.add(i), ie(l, i, !0), Yt(l, t, i);
1701
1705
  }
1702
- e.emit("tool-panel-section-toggle", { id: i, expanded: !l });
1706
+ e.emit("tool-panel-section-toggle", { id: i, expanded: !s });
1703
1707
  },
1704
1708
  getToolPanels() {
1705
1709
  return [...t.toolPanels.values()];
@@ -1733,7 +1737,7 @@ function Ut(t, e) {
1733
1737
  r && (r(), t.headerContentCleanups.delete(i)), t.headerContents.get(i)?.onDestroy?.(), t.headerContents.delete(i), e.getShadow().querySelector(`[data-header-content="${i}"]`)?.remove();
1734
1738
  },
1735
1739
  getToolbarButtons() {
1736
- return Ft(e.getShellConfig(), t);
1740
+ return Gt(e.getShellConfig(), t);
1737
1741
  },
1738
1742
  registerToolbarButton(i) {
1739
1743
  if (t.toolbarButtons.has(i.id)) {
@@ -1761,7 +1765,7 @@ function ie(t, e, o) {
1761
1765
  const n = t.querySelector(`[data-section="${e}"]`);
1762
1766
  n && n.classList.toggle("expanded", o);
1763
1767
  }
1764
- function Xt(t, e, o) {
1768
+ function Yt(t, e, o) {
1765
1769
  const n = e.toolPanels.get(o);
1766
1770
  if (!n?.render) return;
1767
1771
  const i = t.querySelector(`[data-section="${o}"] .tbw-accordion-content`);
@@ -1769,10 +1773,10 @@ function Xt(t, e, o) {
1769
1773
  const r = n.render(i);
1770
1774
  r && e.panelCleanups.set(o, r);
1771
1775
  }
1772
- function Yt(t, e, o, n) {
1776
+ function jt(t, e, o, n) {
1773
1777
  const i = We(e, o);
1774
1778
  if (t.replaceChildren(), i) {
1775
- const r = N(n?.toolPanel ?? O.toolPanel), s = N(n?.expand ?? O.expand), l = N(n?.collapse ?? O.collapse), c = [...e?.header?.toolbarButtons ?? []].sort((b, _) => (b.order ?? 100) - (_.order ?? 100)), f = [...o.toolbarButtons.values()].sort((b, _) => (b.order ?? 100) - (_.order ?? 100)), d = {
1779
+ const r = N(n?.toolPanel ?? O.toolPanel), l = N(n?.expand ?? O.expand), s = N(n?.collapse ?? O.collapse), c = [...e?.header?.toolbarButtons ?? []].sort((b, _) => (b.order ?? 100) - (_.order ?? 100)), f = [...o.toolbarButtons.values()].sort((b, _) => (b.order ?? 100) - (_.order ?? 100)), d = {
1776
1780
  title: e?.header?.title ?? o.lightDomTitle ?? void 0,
1777
1781
  hasPanels: o.toolPanels.size > 0,
1778
1782
  isPanelOpen: o.isPanelOpen,
@@ -1790,15 +1794,15 @@ function Yt(t, e, o, n) {
1790
1794
  }, u = [...o.toolPanels.values()].sort((b, _) => (b.order ?? 100) - (_.order ?? 100)), w = {
1791
1795
  position: e?.toolPanel?.position ?? "right",
1792
1796
  isPanelOpen: o.isPanelOpen,
1793
- expandIcon: s,
1794
- collapseIcon: l,
1797
+ expandIcon: l,
1798
+ collapseIcon: s,
1795
1799
  panels: u.map((b) => ({
1796
1800
  id: b.id,
1797
1801
  title: b.title,
1798
1802
  icon: N(b.icon),
1799
1803
  isExpanded: o.expandedSections.has(b.id)
1800
1804
  }))
1801
- }, h = Nt(d), p = It(w), g = Ee({
1805
+ }, h = It(d), p = qt(w), g = Ee({
1802
1806
  hasShell: !0,
1803
1807
  shellHeader: h,
1804
1808
  shellBody: p
@@ -1810,7 +1814,7 @@ function Yt(t, e, o, n) {
1810
1814
  }
1811
1815
  return i;
1812
1816
  }
1813
- function jt() {
1817
+ function Kt() {
1814
1818
  return {
1815
1819
  startY: null,
1816
1820
  startX: null,
@@ -1824,59 +1828,59 @@ function jt() {
1824
1828
  momentumRaf: 0
1825
1829
  };
1826
1830
  }
1827
- function Kt(t) {
1831
+ function Zt(t) {
1828
1832
  t.startY = null, t.startX = null, t.scrollTop = null, t.scrollLeft = null, t.lastY = null, t.lastX = null, t.lastTime = null;
1829
1833
  }
1830
1834
  function $e(t) {
1831
1835
  t.momentumRaf && (cancelAnimationFrame(t.momentumRaf), t.momentumRaf = 0);
1832
1836
  }
1833
- function Zt(t, e, o) {
1837
+ function Jt(t, e, o) {
1834
1838
  if (t.touches.length !== 1) return;
1835
1839
  $e(e);
1836
1840
  const n = t.touches[0];
1837
1841
  e.startY = n.clientY, e.startX = n.clientX, e.lastY = n.clientY, e.lastX = n.clientX, e.lastTime = performance.now(), e.scrollTop = o.fauxScrollbar.scrollTop, e.scrollLeft = o.scrollArea?.scrollLeft ?? 0, e.velocityY = 0, e.velocityX = 0;
1838
1842
  }
1839
- function Jt(t, e, o) {
1843
+ function Qt(t, e, o) {
1840
1844
  if (t.touches.length !== 1 || e.startY === null || e.startX === null || e.scrollTop === null || e.scrollLeft === null)
1841
1845
  return !1;
1842
- const n = t.touches[0], i = n.clientY, r = n.clientX, s = performance.now(), l = e.startY - i, a = e.startX - r;
1846
+ const n = t.touches[0], i = n.clientY, r = n.clientX, l = performance.now(), s = e.startY - i, a = e.startX - r;
1843
1847
  if (e.lastTime !== null && e.lastY !== null && e.lastX !== null) {
1844
- const p = s - e.lastTime;
1848
+ const p = l - e.lastTime;
1845
1849
  p > 0 && (e.velocityY = (e.lastY - i) / p, e.velocityX = (e.lastX - r) / p);
1846
1850
  }
1847
- e.lastY = i, e.lastX = r, e.lastTime = s;
1848
- const { scrollTop: c, scrollHeight: f, clientHeight: d } = o.fauxScrollbar, u = f - d, w = l > 0 && c < u || l < 0 && c > 0;
1851
+ e.lastY = i, e.lastX = r, e.lastTime = l;
1852
+ const { scrollTop: c, scrollHeight: f, clientHeight: d } = o.fauxScrollbar, u = f - d, w = s > 0 && c < u || s < 0 && c > 0;
1849
1853
  let h = !1;
1850
1854
  if (o.scrollArea) {
1851
1855
  const { scrollLeft: p, scrollWidth: g, clientWidth: b } = o.scrollArea, _ = g - b;
1852
1856
  h = a > 0 && p < _ || a < 0 && p > 0;
1853
1857
  }
1854
- return w && (o.fauxScrollbar.scrollTop = e.scrollTop + l), h && o.scrollArea && (o.scrollArea.scrollLeft = e.scrollLeft + a), w || h;
1855
- }
1856
- function Qt(t, e) {
1857
- (Math.abs(t.velocityY) > 0.1 || Math.abs(t.velocityX) > 0.1) && eo(t, e), Kt(t);
1858
+ return w && (o.fauxScrollbar.scrollTop = e.scrollTop + s), h && o.scrollArea && (o.scrollArea.scrollLeft = e.scrollLeft + a), w || h;
1858
1859
  }
1859
1860
  function eo(t, e) {
1861
+ (Math.abs(t.velocityY) > 0.1 || Math.abs(t.velocityX) > 0.1) && to(t, e), Zt(t);
1862
+ }
1863
+ function to(t, e) {
1860
1864
  const i = () => {
1861
1865
  t.velocityY *= 0.95, t.velocityX *= 0.95;
1862
- const r = t.velocityY * 16, s = t.velocityX * 16;
1863
- Math.abs(t.velocityY) > 0.01 && (e.fauxScrollbar.scrollTop += r), Math.abs(t.velocityX) > 0.01 && e.scrollArea && (e.scrollArea.scrollLeft += s), Math.abs(t.velocityY) > 0.01 || Math.abs(t.velocityX) > 0.01 ? t.momentumRaf = requestAnimationFrame(i) : t.momentumRaf = 0;
1866
+ const r = t.velocityY * 16, l = t.velocityX * 16;
1867
+ Math.abs(t.velocityY) > 0.01 && (e.fauxScrollbar.scrollTop += r), Math.abs(t.velocityX) > 0.01 && e.scrollArea && (e.scrollArea.scrollLeft += l), Math.abs(t.velocityY) > 0.01 || Math.abs(t.velocityX) > 0.01 ? t.momentumRaf = requestAnimationFrame(i) : t.momentumRaf = 0;
1864
1868
  };
1865
1869
  t.momentumRaf = requestAnimationFrame(i);
1866
1870
  }
1867
- function to(t, e, o, n) {
1868
- t.addEventListener("touchstart", (i) => Zt(i, e, o), {
1871
+ function oo(t, e, o, n) {
1872
+ t.addEventListener("touchstart", (i) => Jt(i, e, o), {
1869
1873
  passive: !0,
1870
1874
  signal: n
1871
1875
  }), t.addEventListener(
1872
1876
  "touchmove",
1873
1877
  (i) => {
1874
- Jt(i, e, o) && i.preventDefault();
1878
+ Qt(i, e, o) && i.preventDefault();
1875
1879
  },
1876
1880
  { passive: !1, signal: n }
1877
- ), t.addEventListener("touchend", () => Qt(e, o), { passive: !0, signal: n });
1881
+ ), t.addEventListener("touchend", () => eo(e, o), { passive: !0, signal: n });
1878
1882
  }
1879
- class oo {
1883
+ class no {
1880
1884
  constructor(e) {
1881
1885
  this.grid = e;
1882
1886
  }
@@ -2038,8 +2042,8 @@ class oo {
2038
2042
  let i = e;
2039
2043
  for (const r of this.plugins)
2040
2044
  if (typeof r.adjustVirtualStart == "function") {
2041
- const s = r.adjustVirtualStart(e, o, n);
2042
- s < i && (i = s);
2045
+ const l = r.adjustVirtualStart(e, o, n);
2046
+ l < i && (i = l);
2043
2047
  }
2044
2048
  return i;
2045
2049
  }
@@ -2159,9 +2163,9 @@ class oo {
2159
2163
  */
2160
2164
  getHorizontalScrollOffsets(e, o) {
2161
2165
  let n = 0, i = 0, r = !1;
2162
- for (const s of this.plugins) {
2163
- const l = s.getHorizontalScrollOffsets?.(e, o);
2164
- l && (n += l.left, i += l.right, l.skipScroll && (r = !0));
2166
+ for (const l of this.plugins) {
2167
+ const s = l.getHorizontalScrollOffsets?.(e, o);
2168
+ s && (n += s.left, i += s.right, s.skipScroll && (r = !0));
2165
2169
  }
2166
2170
  return { left: n, right: i, skipScroll: r };
2167
2171
  }
@@ -2196,7 +2200,7 @@ class oo {
2196
2200
  class I extends HTMLElement {
2197
2201
  // TODO: Rename to 'data-grid' when migration is complete
2198
2202
  static tagName = "tbw-grid";
2199
- static version = "0.3.2";
2203
+ static version = "0.3.3";
2200
2204
  // ---------------- Framework Adapters ----------------
2201
2205
  /**
2202
2206
  * Registry of framework adapters that handle converting light DOM elements
@@ -2246,7 +2250,7 @@ class I extends HTMLElement {
2246
2250
  // These backing fields store raw user input. They are merged into
2247
2251
  // #effectiveConfig by #mergeEffectiveConfig(). Never read directly
2248
2252
  // for rendering logic - always use effectiveConfig or derived state.
2249
- #s = [];
2253
+ #l = [];
2250
2254
  #c;
2251
2255
  #g;
2252
2256
  #E;
@@ -2275,8 +2279,8 @@ class I extends HTMLElement {
2275
2279
  #k;
2276
2280
  // Cached hook to avoid closures
2277
2281
  #T = !1;
2278
- #K = jt();
2279
- #l;
2282
+ #K = Kt();
2283
+ #s;
2280
2284
  #p;
2281
2285
  #w;
2282
2286
  // Watches first row for size changes (CSS loading, custom renderers)
@@ -2376,15 +2380,15 @@ class I extends HTMLElement {
2376
2380
  return this._rows;
2377
2381
  }
2378
2382
  set rows(e) {
2379
- const o = this.#s;
2380
- this.#s = e, o !== e && this.#_("rows");
2383
+ const o = this.#l;
2384
+ this.#l = e, o !== e && this.#_("rows");
2381
2385
  }
2382
2386
  /**
2383
2387
  * Get the original unfiltered/unprocessed rows.
2384
2388
  * Use this when you need access to all source data regardless of active filters.
2385
2389
  */
2386
2390
  get sourceRows() {
2387
- return this.#s;
2391
+ return this.#l;
2388
2392
  }
2389
2393
  get columns() {
2390
2394
  return [...this._columns];
@@ -2432,22 +2436,22 @@ class I extends HTMLElement {
2432
2436
  * element.addEventListener('click', handler, { signal: this.grid.disconnectSignal });
2433
2437
  */
2434
2438
  get disconnectSignal() {
2435
- return this.#l || (this.#l = new AbortController()), this.#l.signal;
2439
+ return this.#s || (this.#s = new AbortController()), this.#s.signal;
2436
2440
  }
2437
2441
  // #endregion
2438
2442
  constructor() {
2439
- super(), this.#n = this.attachShadow({ mode: "open" }), this.#se(), this.#Y = new Promise((e) => this.#j = e), this.#i = Ut(this.#e, {
2443
+ super(), this.#n = this.attachShadow({ mode: "open" }), this.#le(), this.#Y = new Promise((e) => this.#j = e), this.#i = Xt(this.#e, {
2440
2444
  getShadow: () => this.#n,
2441
2445
  getShellConfig: () => this.#o?.shell,
2442
2446
  getAccordionIcons: () => ({
2443
2447
  expand: this.#o?.icons?.expand ?? O.expand,
2444
2448
  collapse: this.#o?.icons?.collapse ?? O.collapse
2445
2449
  }),
2446
- emit: (e, o) => this.#q(e, o),
2450
+ emit: (e, o) => this.#B(e, o),
2447
2451
  refreshShellHeader: () => this.refreshShellHeader()
2448
2452
  });
2449
2453
  }
2450
- async #se() {
2454
+ async #le() {
2451
2455
  const e = new CSSStyleSheet();
2452
2456
  if (de.length > 0) {
2453
2457
  e.replaceSync(de), this.#n.adoptedStyleSheets = [e];
@@ -2458,7 +2462,7 @@ class I extends HTMLElement {
2458
2462
  let o = "";
2459
2463
  for (const n of Array.from(document.styleSheets))
2460
2464
  try {
2461
- const r = Array.from(n.cssRules || []).map((s) => s.cssText).join(`
2465
+ const r = Array.from(n.cssRules || []).map((l) => l.cssText).join(`
2462
2466
  `);
2463
2467
  if (r.includes(".tbw-grid-root") && r.includes(":host")) {
2464
2468
  o = r;
@@ -2524,7 +2528,7 @@ class I extends HTMLElement {
2524
2528
  * Plugins are class instances passed in gridConfig.plugins[].
2525
2529
  */
2526
2530
  #Z() {
2527
- this.#t = new oo(this);
2531
+ this.#t = new no(this);
2528
2532
  const e = this.#o?.plugins, o = Array.isArray(e) ? e : [];
2529
2533
  this.#t.attachAll(o);
2530
2534
  }
@@ -2561,7 +2565,7 @@ class I extends HTMLElement {
2561
2565
  /**
2562
2566
  * Clean up plugin states when grid disconnects.
2563
2567
  */
2564
- #le() {
2568
+ #se() {
2565
2569
  this.#t?.detachAll();
2566
2570
  }
2567
2571
  /**
@@ -2599,7 +2603,7 @@ class I extends HTMLElement {
2599
2603
  }
2600
2604
  // ---------------- Lifecycle ----------------
2601
2605
  connectedCallback() {
2602
- this.hasAttribute("tabindex") || (this.tabIndex = 0), this.hasAttribute("version") || this.setAttribute("version", I.version), this._rows = Array.isArray(this.#s) ? [...this.#s] : [], this.#l && (this.#l.abort(), this.#x = !1), this.#l = new AbortController(), this.#u && (_e(this.#u), this.#u = void 0), q(this, this.#e), W(this, this.#e), V(this, this.#e, this.#b()), this.#r(), this.#Z(), this.#ee(), this.#H || (this.#U(), this.#J(), this.#H = !0), this.#I(), this.#u = Dt(
2606
+ this.hasAttribute("tabindex") || (this.tabIndex = 0), this.hasAttribute("version") || this.setAttribute("version", I.version), this._rows = Array.isArray(this.#l) ? [...this.#l] : [], this.#s && (this.#s.abort(), this.#x = !1), this.#s = new AbortController(), this.#u && (_e(this.#u), this.#u = void 0), B(this, this.#e), W(this, this.#e), V(this, this.#e, this.#b()), this.#r(), this.#Z(), this.#ee(), this.#H || (this.#U(), this.#J(), this.#H = !0), this.#I(), this.#u = zt(
2603
2607
  () => {
2604
2608
  this.#Se();
2605
2609
  },
@@ -2607,7 +2611,7 @@ class I extends HTMLElement {
2607
2611
  );
2608
2612
  }
2609
2613
  disconnectedCallback() {
2610
- this.#u && (_e(this.#u), this.#u = void 0), this.#le(), Gt(this.#e), this.#i.setInitialized(!1), this.#A?.(), this.#A = void 0, $e(this.#K), this.#l && (this.#l.abort(), this.#l = void 0), this.#v?.abort(), this.#v = void 0, this.#x = !1, this._resizeController && this._resizeController.dispose(), this.#p && (this.#p.disconnect(), this.#p = void 0), this.#w && (this.#w.disconnect(), this.#w = void 0, this.#B = !1), this.#d && (this.#d.disconnect(), this.#d = void 0), Y(this), this._rowEditSnapshots.clear(), this._changedRowIndices.clear(), this.#C.clear();
2614
+ this.#u && (_e(this.#u), this.#u = void 0), this.#se(), Ut(this.#e), this.#i.setInitialized(!1), this.#A?.(), this.#A = void 0, $e(this.#K), this.#s && (this.#s.abort(), this.#s = void 0), this.#v?.abort(), this.#v = void 0, this.#x = !1, this._resizeController && this._resizeController.dispose(), this.#p && (this.#p.disconnect(), this.#p = void 0), this.#w && (this.#w.disconnect(), this.#w = void 0, this.#q = !1), this.#d && (this.#d.disconnect(), this.#d = void 0), Y(this), this._rowEditSnapshots.clear(), this._changedRowIndices.clear(), this.#C.clear();
2611
2615
  for (const e of this._rowPool)
2612
2616
  e.remove();
2613
2617
  this._rowPool.length = 0, this.__rowsBodyEl = null, this.#M = !1;
@@ -2639,15 +2643,15 @@ class I extends HTMLElement {
2639
2643
  #I() {
2640
2644
  const o = this.#n.querySelector(".tbw-grid-content") ?? this.#n.querySelector(".tbw-grid-root");
2641
2645
  if (this._headerRowEl = o?.querySelector(".header-row"), this._virtualization.totalHeightEl = o?.querySelector(".faux-vscroll-spacer"), this._virtualization.viewportEl = o?.querySelector(".rows-viewport"), this._bodyEl = o?.querySelector(".rows"), this.__rowsBodyEl = o?.querySelector(".rows-body"), this.#i.isInitialized) {
2642
- Ve(this.#n, this.#e), Vt(this.#n, this.#o?.shell, this.#e);
2646
+ Ve(this.#n, this.#e), $t(this.#n, this.#o?.shell, this.#e);
2643
2647
  const r = this.#o?.shell?.toolPanel?.defaultOpen;
2644
2648
  r && this.#e.toolPanels.has(r) && (this.openToolPanel(), this.#e.expandedSections.add(r));
2645
2649
  }
2646
- if (this.setAttribute("data-upgraded", ""), this.#M = !0, this._resizeController = zt(this), this.#a(), this.#ae(o), this.#x)
2650
+ if (this.setAttribute("data-upgraded", ""), this.#M = !0, this._resizeController = Nt(this), this.#a(), this.#ae(o), this.#x)
2647
2651
  return;
2648
2652
  this.#x = !0;
2649
2653
  const n = this.disconnectSignal;
2650
- this.addEventListener("keydown", (r) => pt(this, r), { signal: n }), document.addEventListener(
2654
+ this.addEventListener("keydown", (r) => wt(this, r), { signal: n }), document.addEventListener(
2651
2655
  "keydown",
2652
2656
  (r) => {
2653
2657
  r.key === "Escape" && this._activeEditRows !== -1 && D(this, this._activeEditRows, !0);
@@ -2657,8 +2661,8 @@ class I extends HTMLElement {
2657
2661
  "mousedown",
2658
2662
  (r) => {
2659
2663
  if (this._activeEditRows === -1) return;
2660
- const s = this.findRenderedRowElement(this._activeEditRows);
2661
- !s || (r.composedPath && r.composedPath() || []).includes(s) || D(this, this._activeEditRows, !1);
2664
+ const l = this.findRenderedRowElement(this._activeEditRows);
2665
+ !l || (r.composedPath && r.composedPath() || []).includes(l) || D(this, this._activeEditRows, !1);
2662
2666
  },
2663
2667
  { signal: n }
2664
2668
  ), this.#n.addEventListener("mousedown", (r) => this.#_e(r), { signal: n }), document.addEventListener("mousemove", (r) => this.#Ce(r), { signal: n }), document.addEventListener("mouseup", (r) => this.#Ee(r), { signal: n });
@@ -2674,9 +2678,9 @@ class I extends HTMLElement {
2674
2678
  if (!e) return;
2675
2679
  const o = e.querySelectorAll(".cell");
2676
2680
  let n = 0;
2677
- o.forEach((s) => {
2678
- const l = s.offsetHeight;
2679
- l > n && (n = l);
2681
+ o.forEach((l) => {
2682
+ const s = l.offsetHeight;
2683
+ s > n && (n = s);
2680
2684
  });
2681
2685
  const i = e.getBoundingClientRect(), r = Math.max(i.height, n);
2682
2686
  r > 0 && r !== this._virtualization.rowHeight && (this._virtualization.rowHeight = r, this.refreshVirtualWindow(!0));
@@ -2694,36 +2698,36 @@ class I extends HTMLElement {
2694
2698
  "scroll",
2695
2699
  () => {
2696
2700
  if (!this._virtualization.enabled && !this.#R) return;
2697
- const l = n.scrollTop, a = this._virtualization.rowHeight;
2701
+ const s = n.scrollTop, a = this._virtualization.rowHeight;
2698
2702
  if (this._rows.length <= this._virtualization.bypassThreshold)
2699
- i.style.transform = `translateY(${-l}px)`;
2703
+ i.style.transform = `translateY(${-s}px)`;
2700
2704
  else {
2701
- const c = Math.floor(l / a), f = c - c % 2, d = -(l - f * a);
2705
+ const c = Math.floor(s / a), f = c - c % 2, d = -(s - f * a);
2702
2706
  i.style.transform = `translateY(${d}px)`;
2703
2707
  }
2704
- this.#S = l, this.#f || (this.#f = requestAnimationFrame(() => {
2708
+ this.#S = s, this.#f || (this.#f = requestAnimationFrame(() => {
2705
2709
  this.#f = 0, this.#S !== null && (this.#ve(this.#S), this.#S = null);
2706
2710
  }));
2707
2711
  },
2708
2712
  { passive: !0, signal: o }
2709
2713
  );
2710
- const r = this.#n.querySelector(".tbw-grid-content"), s = this.#n.querySelector(".tbw-scroll-area");
2714
+ const r = this.#n.querySelector(".tbw-grid-content"), l = this.#n.querySelector(".tbw-scroll-area");
2711
2715
  r && (r.addEventListener(
2712
2716
  "wheel",
2713
- (l) => {
2714
- const a = l.shiftKey || Math.abs(l.deltaX) > Math.abs(l.deltaY);
2715
- if (a && s) {
2716
- const c = l.shiftKey ? l.deltaY : l.deltaX, { scrollLeft: f, scrollWidth: d, clientWidth: u } = s;
2717
- (c > 0 && f < d - u || c < 0 && f > 0) && (l.preventDefault(), s.scrollLeft += c);
2717
+ (s) => {
2718
+ const a = s.shiftKey || Math.abs(s.deltaX) > Math.abs(s.deltaY);
2719
+ if (a && l) {
2720
+ const c = s.shiftKey ? s.deltaY : s.deltaX, { scrollLeft: f, scrollWidth: d, clientWidth: u } = l;
2721
+ (c > 0 && f < d - u || c < 0 && f > 0) && (s.preventDefault(), l.scrollLeft += c);
2718
2722
  } else if (!a) {
2719
2723
  const { scrollTop: c, scrollHeight: f, clientHeight: d } = n;
2720
- (l.deltaY > 0 && c < f - d || l.deltaY < 0 && c > 0) && (l.preventDefault(), n.scrollTop += l.deltaY);
2724
+ (s.deltaY > 0 && c < f - d || s.deltaY < 0 && c > 0) && (s.preventDefault(), n.scrollTop += s.deltaY);
2721
2725
  }
2722
2726
  },
2723
2727
  { passive: !1, signal: o }
2724
- ), to(r, this.#K, { fauxScrollbar: n, scrollArea: s }, o));
2728
+ ), oo(r, this.#K, { fauxScrollbar: n, scrollArea: l }, o));
2725
2729
  }
2726
- this._bodyEl && Ht(this, this._bodyEl, o), this.#p?.disconnect(), this._virtualization.viewportEl && (this.#p = new ResizeObserver(() => {
2730
+ this._bodyEl && Mt(this, this._bodyEl, o), this.#p?.disconnect(), this._virtualization.viewportEl && (this.#p = new ResizeObserver(() => {
2727
2731
  this.#f || (this.#f = requestAnimationFrame(() => {
2728
2732
  this.#f = 0, this.refreshVirtualWindow(!0), k(this);
2729
2733
  }));
@@ -2736,28 +2740,28 @@ class I extends HTMLElement {
2736
2740
  * Called after rows are rendered to observe the actual content cells.
2737
2741
  * Handles dynamic CSS loading, lazy images, font loading, etc.
2738
2742
  */
2739
- #B = !1;
2743
+ #q = !1;
2740
2744
  // Only set up once per lifecycle
2741
2745
  #ce() {
2742
- if (this.#B) return;
2746
+ if (this.#q) return;
2743
2747
  const e = this._bodyEl?.querySelector(".data-grid-row");
2744
2748
  if (!e) return;
2745
- this.#B = !0, this.#w?.disconnect();
2749
+ this.#q = !0, this.#w?.disconnect();
2746
2750
  const o = e.querySelectorAll(".cell");
2747
2751
  o.length > 0 && (this.#w = new ResizeObserver(() => {
2748
2752
  this.#te();
2749
2753
  }), o.forEach((n) => this.#w.observe(n)));
2750
2754
  }
2751
2755
  // ---------------- Event Emitters ----------------
2752
- #q(e, o) {
2756
+ #B(e, o) {
2753
2757
  this.dispatchEvent(new CustomEvent(e, { detail: o, bubbles: !0, composed: !0 }));
2754
2758
  }
2755
2759
  /** Update ARIA selection attributes on rendered rows/cells */
2756
2760
  #de() {
2757
2761
  this._bodyEl?.querySelectorAll(".data-grid-row")?.forEach((o, n) => {
2758
2762
  const i = n === this._focusRow;
2759
- o.setAttribute("aria-selected", String(i)), o.querySelectorAll(".cell").forEach((r, s) => {
2760
- r.setAttribute("aria-selected", String(i && s === this._focusCol));
2763
+ o.setAttribute("aria-selected", String(i)), o.querySelectorAll(".cell").forEach((r, l) => {
2764
+ r.setAttribute("aria-selected", String(i && l === this._focusCol));
2761
2765
  });
2762
2766
  });
2763
2767
  }
@@ -2795,7 +2799,7 @@ class I extends HTMLElement {
2795
2799
  }
2796
2800
  // Individual update applicators - these do the actual work
2797
2801
  #he() {
2798
- this._rows = Array.isArray(this.#s) ? [...this.#s] : [], this.#P(), this._columns.length > 0 || Array.isArray(this.#o?.columns) && this.#o.columns.length > 0 || Array.isArray(this.#c) && this.#c.length > 0 ? (this.#L(), this.refreshVirtualWindow(!0)) : this.#a();
2802
+ this._rows = Array.isArray(this.#l) ? [...this.#l] : [], this.#P(), this._columns.length > 0 || Array.isArray(this.#o?.columns) && this.#o.columns.length > 0 || Array.isArray(this.#c) && this.#c.length > 0 ? (this.#L(), this.refreshVirtualWindow(!0)) : this.#a();
2799
2803
  }
2800
2804
  #fe() {
2801
2805
  Y(this), this.#r(), this.#a();
@@ -2809,11 +2813,11 @@ class I extends HTMLElement {
2809
2813
  this.#r(), this._rowPool.length = 0, this._bodyEl && (this._bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.refreshVirtualWindow(!0);
2810
2814
  }
2811
2815
  #be() {
2812
- q(this, this.#e), W(this, this.#e);
2816
+ B(this, this.#e), W(this, this.#e);
2813
2817
  const e = !!this.#n.querySelector(".has-shell"), o = !!this.#n.querySelector(".tbw-tool-panel"), n = this.#n.querySelectorAll(".tbw-accordion-section").length;
2814
2818
  pe(this), this.#r(), this.#Q(), V(this, this.#e, this.#b());
2815
- const i = We(this.#o, this.#e), r = this.#e.toolPanels.size > 0, s = this.#e.toolPanels.size !== n;
2816
- if (e !== i || !e && i || !o && r || o && s) {
2819
+ const i = We(this.#o, this.#e), r = this.#e.toolPanels.size > 0, l = this.#e.toolPanels.size !== n;
2820
+ if (e !== i || !e && i || !o && r || o && l) {
2817
2821
  this.#U(), this.#I();
2818
2822
  return;
2819
2823
  }
@@ -2838,16 +2842,16 @@ class I extends HTMLElement {
2838
2842
  if (this.#t) {
2839
2843
  const e = this.#N.length > 0 ? this.#N : this._columns, o = e.filter((r) => !r.hidden), n = e.filter((r) => r.hidden), i = this.#t.processColumns([...o]);
2840
2844
  if (i !== o) {
2841
- const r = new Map(i.map((l, a) => [l.field, { col: l, order: a }]));
2842
- if (!o.some((l) => r.has(l.field)) && i.length > 0)
2845
+ const r = new Map(i.map((s, a) => [s.field, { col: s, order: a }]));
2846
+ if (!o.some((s) => r.has(s.field)) && i.length > 0)
2843
2847
  this._columns = [...i, ...n];
2844
2848
  else {
2845
- const l = e.map((a) => {
2849
+ const s = e.map((a) => {
2846
2850
  if (a.hidden) return a;
2847
2851
  const c = r.get(a.field);
2848
2852
  return c ? c.col : a;
2849
2853
  });
2850
- this._columns = l;
2854
+ this._columns = s;
2851
2855
  }
2852
2856
  } else
2853
2857
  this._columns = [...e];
@@ -2856,7 +2860,7 @@ class I extends HTMLElement {
2856
2860
  /** Recompute row model via plugin hooks. */
2857
2861
  #P() {
2858
2862
  Y(this);
2859
- const e = Array.isArray(this.#s) ? [...this.#s] : [], o = this.#t?.processRows(e) ?? e;
2863
+ const e = Array.isArray(this.#l) ? [...this.#l] : [], o = this.#t?.processRows(e) ?? e;
2860
2864
  this._rows = o;
2861
2865
  }
2862
2866
  /**
@@ -2886,24 +2890,24 @@ class I extends HTMLElement {
2886
2890
  if (n.length) {
2887
2891
  const i = {};
2888
2892
  o.forEach((r) => i[r.field] = r), n.forEach((r) => {
2889
- const s = i[r.field];
2890
- if (!s)
2893
+ const l = i[r.field];
2894
+ if (!l)
2891
2895
  o.push(r), i[r.field] = r;
2892
2896
  else {
2893
- r.header && !s.header && (s.header = r.header), r.type && !s.type && (s.type = r.type), s.sortable = s.sortable || r.sortable, r.resizable && (s.resizable = !0), r.editable && (s.editable = !0);
2894
- const l = r.renderer || r.viewRenderer, a = s.renderer || s.viewRenderer;
2895
- l && !a && (s.viewRenderer = l, r.renderer && (s.renderer = l)), r.editor && !s.editor && (s.editor = r.editor);
2897
+ r.header && !l.header && (l.header = r.header), r.type && !l.type && (l.type = r.type), l.sortable = l.sortable || r.sortable, r.resizable && (l.resizable = !0), r.editable && (l.editable = !0);
2898
+ const s = r.renderer || r.viewRenderer, a = l.renderer || l.viewRenderer;
2899
+ s && !a && (l.viewRenderer = s, r.renderer && (l.renderer = s)), r.editor && !l.editor && (l.editor = r.editor);
2896
2900
  }
2897
2901
  });
2898
2902
  }
2899
2903
  if (this.#c && this.#c.length && (o = [...this.#c]), (!o || o.length === 0) && this._rows.length && (o = Le(this._rows).columns), o.length) {
2900
- o.forEach((s) => {
2901
- s.sortable === void 0 && (s.sortable = !0), s.resizable === void 0 && (s.resizable = !0);
2902
- const l = s;
2903
- l.__originalWidth === void 0 && typeof s.width == "number" && (l.__originalWidth = s.width);
2904
+ o.forEach((l) => {
2905
+ l.sortable === void 0 && (l.sortable = !0), l.resizable === void 0 && (l.resizable = !0);
2906
+ const s = l;
2907
+ s.__originalWidth === void 0 && typeof l.width == "number" && (s.__originalWidth = l.width);
2904
2908
  });
2905
2909
  const i = this.#o.columns;
2906
- i?.some((s) => s.__compiledView || s.__compiledEditor) ? e.columns = i : e.columns = o;
2910
+ i?.some((l) => l.__compiledView || l.__compiledEditor) ? e.columns = i : e.columns = o;
2907
2911
  } else {
2908
2912
  const i = this.#o.columns;
2909
2913
  i?.some((r) => r.__compiledView || r.__compiledEditor) && (e.columns = i);
@@ -2926,7 +2930,7 @@ class I extends HTMLElement {
2926
2930
  }
2927
2931
  // ---------------- Delegate Wrappers ----------------
2928
2932
  #W(e, o, n = this.__rowRenderEpoch) {
2929
- this.#k || (this.#k = (i, r, s) => this.#t?.renderRow(i, r, s) ?? !1), vt(this, e, o, n, this.#k);
2933
+ this.#k || (this.#k = (i, r, l) => this.#t?.renderRow(i, r, l) ?? !1), _t(this, e, o, n, this.#k);
2930
2934
  }
2931
2935
  // Cache for ARIA counts to avoid redundant DOM writes on scroll (hot path)
2932
2936
  #V = -1;
@@ -2965,7 +2969,7 @@ class I extends HTMLElement {
2965
2969
  const o = this.#o.columns ?? [], n = this.#t?.getAll() ?? [];
2966
2970
  Ge(this, e, o, n);
2967
2971
  for (const i of e.columns) {
2968
- const r = o.find((s) => s.field === i.field);
2972
+ const r = o.find((l) => l.field === i.field);
2969
2973
  r && (r.hidden = !i.visible);
2970
2974
  }
2971
2975
  }
@@ -3001,18 +3005,18 @@ class I extends HTMLElement {
3001
3005
  * Returns true if any plugin handled the event.
3002
3006
  */
3003
3007
  _dispatchCellClick(e, o, n, i) {
3004
- const r = this._rows[o], s = this._columns[n];
3005
- if (!r || !s) return !1;
3006
- const l = {
3008
+ const r = this._rows[o], l = this._columns[n];
3009
+ if (!r || !l) return !1;
3010
+ const s = {
3007
3011
  row: r,
3008
3012
  rowIndex: o,
3009
3013
  colIndex: n,
3010
- field: s.field,
3011
- value: r[s.field],
3014
+ field: l.field,
3015
+ value: r[l.field],
3012
3016
  cellEl: i,
3013
3017
  originalEvent: e
3014
3018
  };
3015
- return this.#t?.onCellClick(l) ?? !1;
3019
+ return this.#t?.onCellClick(s) ?? !1;
3016
3020
  }
3017
3021
  /**
3018
3022
  * Dispatch a row click event to the plugin system.
@@ -3083,7 +3087,7 @@ class I extends HTMLElement {
3083
3087
  const h = this.#n.elementFromPoint(e.clientX, e.clientY);
3084
3088
  h && (n = h);
3085
3089
  }
3086
- const r = n?.closest?.("[data-col]"), s = n?.closest?.(".data-grid-row"), l = n?.closest?.(".header-row");
3090
+ const r = n?.closest?.("[data-col]"), l = n?.closest?.(".data-grid-row"), s = n?.closest?.(".header-row");
3087
3091
  let a, c, f, d, u, w;
3088
3092
  return r && (a = parseInt(r.getAttribute("data-row") ?? "-1", 10), c = parseInt(r.getAttribute("data-col") ?? "-1", 10), a >= 0 && c >= 0 && (f = this._rows[a], w = this._columns[c], d = w?.field, u = f && d ? f[d] : void 0)), {
3089
3093
  type: o,
@@ -3095,8 +3099,8 @@ class I extends HTMLElement {
3095
3099
  column: w,
3096
3100
  originalEvent: e,
3097
3101
  cellElement: r ?? void 0,
3098
- rowElement: s ?? void 0,
3099
- isHeader: !!l,
3102
+ rowElement: l ?? void 0,
3103
+ isHeader: !!s,
3100
3104
  cell: a !== void 0 && c !== void 0 && a >= 0 && c >= 0 ? { row: a, col: c } : void 0
3101
3105
  };
3102
3106
  }
@@ -3131,18 +3135,18 @@ class I extends HTMLElement {
3131
3135
  return ze(this);
3132
3136
  }
3133
3137
  async resetChangedRows(e) {
3134
- yt(this, e);
3138
+ St(this, e);
3135
3139
  }
3136
3140
  async beginBulkEdit(e) {
3137
- St(this, e, {
3141
+ Rt(this, e, {
3138
3142
  findRenderedRowElement: (o) => this.findRenderedRowElement?.(o) ?? null
3139
3143
  });
3140
3144
  }
3141
3145
  async commitActiveRowEdit() {
3142
- Rt(this);
3146
+ Tt(this);
3143
3147
  }
3144
3148
  async cancelActiveRowEdit() {
3145
- Tt(this);
3149
+ xt(this);
3146
3150
  }
3147
3151
  async ready() {
3148
3152
  return this.#Y;
@@ -3158,7 +3162,7 @@ class I extends HTMLElement {
3158
3162
  // Delegates to column-state.ts pure functions
3159
3163
  /** Visibility callbacks for column-state.ts functions */
3160
3164
  #F = {
3161
- emit: (e, o) => this.#q(e, o),
3165
+ emit: (e, o) => this.#B(e, o),
3162
3166
  clearRowPool: () => {
3163
3167
  this._rowPool.length = 0, this._bodyEl && (this._bodyEl.innerHTML = ""), this.__rowRenderEpoch++;
3164
3168
  },
@@ -3231,7 +3235,7 @@ class I extends HTMLElement {
3231
3235
  this.#z || (this.#z = Ue(
3232
3236
  this,
3233
3237
  () => this.#t?.getAll() ?? [],
3234
- (e) => this.#q("column-state-change", e)
3238
+ (e) => this.#B("column-state-change", e)
3235
3239
  )), this.#z();
3236
3240
  }
3237
3241
  /**
@@ -3333,7 +3337,7 @@ class I extends HTMLElement {
3333
3337
  * Call this after dynamically modifying <tbw-grid-header> children.
3334
3338
  */
3335
3339
  refreshShellHeader() {
3336
- q(this, this.#e), W(this, this.#e), V(this, this.#e, this.#b()), this.#U(), this.#I();
3340
+ B(this, this.#e), W(this, this.#e), V(this, this.#e, this.#b()), this.#U(), this.#I();
3337
3341
  }
3338
3342
  // #region Custom Styles API
3339
3343
  /** Map of registered custom style elements by ID */
@@ -3390,10 +3394,10 @@ class I extends HTMLElement {
3390
3394
  let e = null, o = !1, n = !1;
3391
3395
  const i = () => {
3392
3396
  if (e = null, o) {
3393
- const r = this.#e.lightDomTitle, s = this.#e.hasToolButtonsContainer;
3394
- q(this, this.#e), W(this, this.#e), V(this, this.#e, this.#b());
3395
- const l = this.#e.lightDomTitle, a = this.#e.hasToolButtonsContainer;
3396
- if (l && !r || a && !s) {
3397
+ const r = this.#e.lightDomTitle, l = this.#e.hasToolButtonsContainer;
3398
+ B(this, this.#e), W(this, this.#e), V(this, this.#e, this.#b());
3399
+ const s = this.#e.lightDomTitle, a = this.#e.hasToolButtonsContainer;
3400
+ if (s && !r || a && !l) {
3397
3401
  this.#r();
3398
3402
  const c = this.#n.querySelector(".tbw-shell-header");
3399
3403
  if (c) {
@@ -3412,14 +3416,14 @@ class I extends HTMLElement {
3412
3416
  n && (this.__lightDomColumnsCache = void 0, this.#a(), n = !1);
3413
3417
  };
3414
3418
  this.#d = new MutationObserver((r) => {
3415
- for (const s of r) {
3416
- for (const l of s.addedNodes) {
3417
- if (l.nodeType !== Node.ELEMENT_NODE) continue;
3418
- const c = l.tagName.toLowerCase();
3419
+ for (const l of r) {
3420
+ for (const s of l.addedNodes) {
3421
+ if (s.nodeType !== Node.ELEMENT_NODE) continue;
3422
+ const c = s.tagName.toLowerCase();
3419
3423
  c === "tbw-grid-header" ? o = !0 : (c === "tbw-grid-column" || c === "tbw-grid-detail") && (n = !0);
3420
3424
  }
3421
- if (s.type === "attributes" && s.target.nodeType === Node.ELEMENT_NODE) {
3422
- const a = s.target.tagName.toLowerCase();
3425
+ if (l.type === "attributes" && l.target.nodeType === Node.ELEMENT_NODE) {
3426
+ const a = l.target.tagName.toLowerCase();
3423
3427
  a === "tbw-grid-header" ? o = !0 : a === "tbw-grid-column" && (n = !0);
3424
3428
  }
3425
3429
  }
@@ -3448,20 +3452,20 @@ class I extends HTMLElement {
3448
3452
  #Re() {
3449
3453
  this.__lightDomColumnsCache = void 0, Y(this);
3450
3454
  const e = this.#e.lightDomTitle, o = this.#e.hasToolButtonsContainer;
3451
- q(this, this.#e), W(this, this.#e), V(this, this.#e, this.#b());
3455
+ B(this, this.#e), W(this, this.#e), V(this, this.#e, this.#b());
3452
3456
  const n = this.#e.lightDomTitle, i = this.#e.hasToolButtonsContainer;
3453
3457
  if (n && !e || i && !o) {
3454
3458
  this.#r();
3455
- const s = this.#n.querySelector(".tbw-shell-header");
3456
- if (s) {
3457
- const l = ye(
3459
+ const l = this.#n.querySelector(".tbw-shell-header");
3460
+ if (l) {
3461
+ const s = ye(
3458
3462
  this.#o.shell,
3459
3463
  this.#e,
3460
3464
  this.#o.icons?.toolPanel
3461
3465
  ), a = document.createElement("div");
3462
- a.innerHTML = l;
3466
+ a.innerHTML = s;
3463
3467
  const c = a.firstElementChild;
3464
- c && (s.replaceWith(c), this.#X());
3468
+ c && (l.replaceWith(c), this.#X());
3465
3469
  }
3466
3470
  }
3467
3471
  this.#a();
@@ -3472,7 +3476,7 @@ class I extends HTMLElement {
3472
3476
  * Used by both bypass and virtualized rendering paths to ensure consistent scroll behavior.
3473
3477
  */
3474
3478
  #G(e) {
3475
- const o = this._virtualization.rowHeight, n = this._virtualization.container ?? this, i = this._virtualization.viewportEl ?? n, r = n.clientHeight, s = i.clientHeight, a = this.shadowRoot?.querySelector(".tbw-scroll-area"), c = a ? a.clientHeight : r, d = c - s, u = this.#t?.getExtraHeight() ?? 0, w = Math.max(0, r - c);
3479
+ const o = this._virtualization.rowHeight, n = this._virtualization.container ?? this, i = this._virtualization.viewportEl ?? n, r = n.clientHeight, l = i.clientHeight, a = this.shadowRoot?.querySelector(".tbw-scroll-area"), c = a ? a.clientHeight : r, d = c - l, u = this.#t?.getExtraHeight() ?? 0, w = Math.max(0, r - c);
3476
3480
  return e * o + d + u + w;
3477
3481
  }
3478
3482
  /**
@@ -3491,18 +3495,18 @@ class I extends HTMLElement {
3491
3495
  this._virtualization.start = 0, this._virtualization.end = o, e && (this._bodyEl.style.transform = "translateY(0px)"), this.#W(0, o, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch), this._virtualization.totalHeightEl && (this._virtualization.totalHeightEl.style.height = `${this.#G(o)}px`), this.#ne(o, this._visibleColumns.length), this.#t?.afterRender();
3492
3496
  return;
3493
3497
  }
3494
- const n = this._virtualization.container ?? this, i = this._virtualization.viewportEl ?? n, r = i.clientHeight, s = this._virtualization.rowHeight, l = n.scrollTop;
3495
- let a = Math.floor(l / s), c = 0;
3498
+ const n = this._virtualization.container ?? this, i = this._virtualization.viewportEl ?? n, r = i.clientHeight, l = this._virtualization.rowHeight, s = n.scrollTop;
3499
+ let a = Math.floor(s / l), c = 0;
3496
3500
  const f = 10;
3497
3501
  for (; c < f; ) {
3498
- const _ = this.#t?.getExtraHeightBefore?.(a) ?? 0, v = Math.floor((l - _) / s);
3502
+ const _ = this.#t?.getExtraHeightBefore?.(a) ?? 0, v = Math.floor((s - _) / l);
3499
3503
  if (v >= a || v < 0) break;
3500
3504
  a = v, c++;
3501
3505
  }
3502
3506
  a = a - a % 2, a < 0 && (a = 0);
3503
- const d = this.#t?.adjustVirtualStart(a, l, s);
3507
+ const d = this.#t?.adjustVirtualStart(a, s, l);
3504
3508
  d !== void 0 && d < a && (a = d, a = a - a % 2, a < 0 && (a = 0));
3505
- const u = Math.ceil(r / s) + 3;
3509
+ const u = Math.ceil(r / l) + 3;
3506
3510
  let w = a + u;
3507
3511
  if (w > o && (w = o), this._virtualization.start = a, this._virtualization.end = w, n.clientHeight === 0 && r > 0) {
3508
3512
  requestAnimationFrame(() => this.refreshVirtualWindow(e));
@@ -3510,7 +3514,7 @@ class I extends HTMLElement {
3510
3514
  }
3511
3515
  const p = this.#G(o);
3512
3516
  this._virtualization.totalHeightEl && (this._virtualization.totalHeightEl.style.height = `${p}px`);
3513
- const g = this.#t?.getExtraHeightBefore?.(a) ?? 0, b = -(l - a * s - g);
3517
+ const g = this.#t?.getExtraHeightBefore?.(a) ?? 0, b = -(s - a * l - g);
3514
3518
  this._bodyEl.style.transform = `translateY(${b}px)`, this.#W(a, w, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch), this.#ne(o, this._visibleColumns.length), e && (this.#t?.afterRender(), queueMicrotask(() => {
3515
3519
  const _ = n.clientHeight, v = i.clientHeight;
3516
3520
  if (_ === 0 && v > 0) return;
@@ -3520,19 +3524,19 @@ class I extends HTMLElement {
3520
3524
  }
3521
3525
  // ---------------- Render ----------------
3522
3526
  #U() {
3523
- q(this, this.#e), W(this, this.#e), V(this, this.#e, this.#b()), this.#r();
3527
+ B(this, this.#e), W(this, this.#e), V(this, this.#e, this.#b()), this.#r();
3524
3528
  const e = this.#o?.shell;
3525
- Yt(this.#n, e, this.#e, this.#o?.icons) && (this.#X(), this.#i.setInitialized(!0));
3529
+ jt(this.#n, e, this.#e, this.#o?.icons) && (this.#X(), this.#i.setInitialized(!0));
3526
3530
  }
3527
3531
  /**
3528
3532
  * Set up shell event listeners after render.
3529
3533
  */
3530
3534
  #X() {
3531
- qt(this.#n, this.#o?.shell, this.#e, {
3535
+ Wt(this.#n, this.#o?.shell, this.#e, {
3532
3536
  onPanelToggle: () => this.toggleToolPanel(),
3533
3537
  onSectionToggle: (e) => this.toggleToolPanelSection(e),
3534
3538
  onToolbarButtonClick: (e) => this.#Te(e)
3535
- }), this.#A?.(), this.#A = Wt(this.#n, this.#o?.shell, (e) => {
3539
+ }), this.#A?.(), this.#A = Vt(this.#n, this.#o?.shell, (e) => {
3536
3540
  this.style.setProperty("--tbw-tool-panel-width", `${e}px`);
3537
3541
  });
3538
3542
  }
@@ -3547,13 +3551,13 @@ class I extends HTMLElement {
3547
3551
  }
3548
3552
  customElements.get(I.tagName) || customElements.define(I.tagName, I);
3549
3553
  globalThis.DataGridElement = I;
3550
- const io = {
3554
+ const ro = {
3551
3555
  /** Ask if a column can be moved. Context: ColumnConfig. Response: boolean | undefined */
3552
3556
  CAN_MOVE_COLUMN: "canMoveColumn",
3553
3557
  /** Get context menu items. Context: ContextMenuParams. Response: ContextMenuItem[] */
3554
3558
  GET_CONTEXT_MENU_ITEMS: "getContextMenuItems"
3555
3559
  };
3556
- class ro {
3560
+ class lo {
3557
3561
  /** Plugin version - override in subclass if needed */
3558
3562
  version = "1.0.0";
3559
3563
  /** CSS styles to inject into the grid's shadow DOM */
@@ -3786,7 +3790,7 @@ const y = {
3786
3790
  // State selectors
3787
3791
  SELECTED_ROWS: `.${y.DATA_ROW}.${y.SELECTED}`,
3788
3792
  EDITING_CELL: `.${y.DATA_CELL}.${y.EDITING}`
3789
- }, lo = {
3793
+ }, ao = {
3790
3794
  // Colors
3791
3795
  COLOR_BG: "--tbw-color-bg",
3792
3796
  COLOR_FG: "--tbw-color-fg",
@@ -3808,7 +3812,7 @@ const y = {
3808
3812
  // Borders
3809
3813
  BORDER_RADIUS: "--tbw-border-radius",
3810
3814
  FOCUS_OUTLINE: "--tbw-focus-outline"
3811
- }, ao = {
3815
+ }, co = {
3812
3816
  CELL_COMMIT: "cell-commit",
3813
3817
  ROW_COMMIT: "row-commit",
3814
3818
  CHANGED_ROWS_RESET: "changed-rows-reset",
@@ -3819,7 +3823,7 @@ const y = {
3819
3823
  ACTIVATE_CELL: "activate-cell",
3820
3824
  GROUP_TOGGLE: "group-toggle",
3821
3825
  COLUMN_STATE_CHANGE: "column-state-change"
3822
- }, co = {
3826
+ }, uo = {
3823
3827
  // Selection plugin
3824
3828
  SELECTION_CHANGE: "selection-change",
3825
3829
  // Tree plugin
@@ -3909,42 +3913,42 @@ const y = {
3909
3913
  first: (t) => t[0] ?? 0,
3910
3914
  last: (t) => t[t.length - 1] ?? 0
3911
3915
  };
3912
- function no(t) {
3916
+ function io(t) {
3913
3917
  return Te[t] ?? Te.sum;
3914
3918
  }
3915
- function uo(t, e) {
3916
- return no(t)(e);
3919
+ function ho(t, e) {
3920
+ return io(t)(e);
3917
3921
  }
3918
- const ho = M.register.bind(M), fo = M.unregister.bind(M), po = M.get.bind(M), wo = M.run.bind(M), bo = M.list.bind(M);
3922
+ const fo = M.register.bind(M), po = M.unregister.bind(M), wo = M.get.bind(M), bo = M.run.bind(M), go = M.list.bind(M);
3919
3923
  export {
3920
- ro as BaseGridPlugin,
3924
+ lo as BaseGridPlugin,
3921
3925
  Qe as DEFAULT_ANIMATION_CONFIG,
3922
3926
  O as DEFAULT_GRID_ICONS,
3923
- ao as DGEvents,
3927
+ co as DGEvents,
3924
3928
  I as DataGridElement,
3925
3929
  j as FitModeEnum,
3926
- lo as GridCSSVars,
3930
+ ao as GridCSSVars,
3927
3931
  y as GridClasses,
3928
3932
  J as GridDataAttrs,
3929
3933
  I as GridElement,
3930
3934
  so as GridSelectors,
3931
- io as PLUGIN_QUERIES,
3932
- co as PluginEvents,
3933
- oo as PluginManager,
3935
+ ro as PLUGIN_QUERIES,
3936
+ uo as PluginEvents,
3937
+ no as PluginManager,
3934
3938
  k as a,
3935
3939
  M as aggregatorRegistry,
3936
- Ot as builtInSort,
3937
- se as c,
3938
- Mt as defaultComparator,
3940
+ kt as builtInSort,
3941
+ le as c,
3942
+ Ot as defaultComparator,
3939
3943
  Pe as e,
3940
3944
  Me as g,
3941
- po as getAggregator,
3942
- no as getValueAggregator,
3943
- bo as listAggregators,
3944
- ho as registerAggregator,
3945
- wo as runAggregator,
3946
- uo as runValueAggregator,
3945
+ wo as getAggregator,
3946
+ io as getValueAggregator,
3947
+ go as listAggregators,
3948
+ fo as registerAggregator,
3949
+ bo as runAggregator,
3950
+ ho as runValueAggregator,
3947
3951
  Q as s,
3948
- fo as unregisterAggregator
3952
+ po as unregisterAggregator
3949
3953
  };
3950
3954
  //# sourceMappingURL=index.js.map