@toolbox-web/grid 0.2.7 → 0.2.8

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/all.js CHANGED
@@ -1,5 +1,5 @@
1
- import { B as v, D as Ve, r as se, P as N, g as le, a as Oe, e as Ge } from "./index-DG2CZ_Zo.js";
2
- import { k as Kn, i as Nn, b as qn, F as Dn, o as Hn, G as Vn, p as On, b as Gn, q as Bn, j as zn, c as Wn, d as $n, m as jn, n as Un, l as Yn, f as Zn, h as Xn, u as Jn } from "./index-DG2CZ_Zo.js";
1
+ import { B as v, D as Ve, r as se, P as N, g as le, a as Oe, e as Ge } from "./index-YjW60MHD.js";
2
+ import { k as Kn, i as Nn, b as qn, F as Dn, o as Hn, G as Vn, p as On, b as Gn, q as Bn, j as zn, c as Wn, d as $n, m as jn, n as Un, l as Yn, f as Zn, h as Xn, u as Jn } from "./index-YjW60MHD.js";
3
3
  function Be(s, e, t, n) {
4
4
  if (n.processCell)
5
5
  return n.processCell(s, e, t);
@@ -275,9 +275,9 @@ function te(t) {
275
275
  }
276
276
  }
277
277
  l > 0 && (i.width = l + 2, i.__autoSized = !0, n = !0);
278
- }), n && z(t), t.__didInitialAutoSize = !0;
278
+ }), n && M(t), t.__didInitialAutoSize = !0;
279
279
  }
280
- function z(t) {
280
+ function M(t) {
281
281
  (t.effectiveConfig?.fitMode || t.fitMode || $.STRETCH) === $.STRETCH ? t._gridTemplate = t._visibleColumns.map((o) => {
282
282
  if (o.width) return `${o.width}px`;
283
283
  const n = o.minWidth;
@@ -335,7 +335,7 @@ function Oe(t) {
335
335
  };
336
336
  }
337
337
  }
338
- function Me(t, e) {
338
+ function ze(t, e) {
339
339
  if (t._dispatchKeyDown?.(e))
340
340
  return;
341
341
  const o = t._rows.length - 1, n = t._visibleColumns.length - 1, i = t._activeEditRows !== void 0 && t._activeEditRows !== -1, r = t._visibleColumns[t._focusCol]?.type, l = e.composedPath ? e.composedPath() : [], a = l && l.length ? l[0] : e.target, d = (f) => {
@@ -346,7 +346,7 @@ function Me(t, e) {
346
346
  if (!(d(a) && (e.key === "Home" || e.key === "End")) && !(d(a) && (e.key === "ArrowUp" || e.key === "ArrowDown") && a.tagName === "INPUT" && a.type === "number") && !(d(a) && (e.key === "ArrowLeft" || e.key === "ArrowRight")) && !(d(a) && (e.key === "Enter" || e.key === "Escape")) && !(i && (r === "select" || r === "typeahead") && (e.key === "ArrowDown" || e.key === "ArrowUp"))) {
347
347
  switch (e.key) {
348
348
  case "Tab": {
349
- 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), M(t);
349
+ 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), z(t);
350
350
  return;
351
351
  }
352
352
  case "ArrowDown":
@@ -362,10 +362,10 @@ function Me(t, e) {
362
362
  t._focusCol = Math.max(0, t._focusCol - 1), e.preventDefault();
363
363
  break;
364
364
  case "Home":
365
- (e.ctrlKey || e.metaKey) && (i && typeof t.commitActiveRowEdit == "function" && t.commitActiveRowEdit(), t._focusRow = 0), t._focusCol = 0, e.preventDefault(), M(t, { forceScrollLeft: !0 });
365
+ (e.ctrlKey || e.metaKey) && (i && typeof t.commitActiveRowEdit == "function" && t.commitActiveRowEdit(), t._focusRow = 0), t._focusCol = 0, e.preventDefault(), z(t, { forceScrollLeft: !0 });
366
366
  return;
367
367
  case "End":
368
- (e.ctrlKey || e.metaKey) && (i && typeof t.commitActiveRowEdit == "function" && t.commitActiveRowEdit(), t._focusRow = o), t._focusCol = n, e.preventDefault(), M(t, { forceScrollRight: !0 });
368
+ (e.ctrlKey || e.metaKey) && (i && typeof t.commitActiveRowEdit == "function" && t.commitActiveRowEdit(), t._focusRow = o), t._focusCol = n, e.preventDefault(), z(t, { forceScrollRight: !0 });
369
369
  return;
370
370
  case "PageDown":
371
371
  t._focusRow = Math.min(o, t._focusRow + 20), e.preventDefault();
@@ -376,14 +376,14 @@ function Me(t, e) {
376
376
  case "Enter":
377
377
  return typeof t.beginBulkEdit == "function" ? t.beginBulkEdit(t._focusRow) : t.dispatchEvent(
378
378
  new CustomEvent("activate-cell", { detail: { row: t._focusRow, col: t._focusCol } })
379
- ), M(t);
379
+ ), z(t);
380
380
  default:
381
381
  return;
382
382
  }
383
- M(t);
383
+ z(t);
384
384
  }
385
385
  }
386
- function M(t, e) {
386
+ function z(t, e) {
387
387
  if (t._virtualization?.enabled) {
388
388
  const { rowHeight: r, container: l, viewportEl: a } = t._virtualization, d = l, f = a?.clientHeight ?? d?.clientHeight ?? 0;
389
389
  if (d && f > 0) {
@@ -431,9 +431,9 @@ function M(t, e) {
431
431
  }
432
432
  }
433
433
  }
434
- const ze = "__cellDisplayCache", De = "__cellCacheEpoch";
434
+ const Me = "__cellDisplayCache", De = "__cellCacheEpoch";
435
435
  function K(t) {
436
- t[ze] = void 0, t[De] = void 0, t.__hasSpecialColumns = void 0;
436
+ t[Me] = void 0, t[De] = void 0, t.__hasSpecialColumns = void 0;
437
437
  }
438
438
  function Ne(t, e, o, n, i) {
439
439
  const s = Math.max(0, o - e), r = t._bodyEl, l = t._visibleColumns, a = l.length;
@@ -456,9 +456,9 @@ function Ne(t, e, o, n, i) {
456
456
  u.__epoch = n, u.__rowDataRef = c, u.parentNode !== r && r.appendChild(u);
457
457
  continue;
458
458
  }
459
- const b = u.__epoch, w = u.__rowDataRef, v = u.children.length, R = b === n && v === a, E = w !== c;
459
+ const b = u.__epoch, w = u.__rowDataRef, v = u.children.length, R = b === n && v === a, C = w !== c;
460
460
  let g = !1;
461
- if (R && E) {
461
+ if (R && C) {
462
462
  for (let _ = 0; _ < a; _++)
463
463
  if (l[_].externalView && !u.querySelector(`.cell[data-col="${_}"] [data-external-view]`)) {
464
464
  g = !0;
@@ -466,23 +466,23 @@ function Ne(t, e, o, n, i) {
466
466
  }
467
467
  }
468
468
  if (!R || g) {
469
- const _ = u.querySelector(".cell.editing"), y = t._activeEditRows === p;
470
- if (_ && !y)
469
+ const _ = u.querySelector(".cell.editing"), E = t._activeEditRows === p;
470
+ if (_ && !E)
471
471
  u.__isCustomRow && (u.className = "data-grid-row", u.setAttribute("role", "row"), u.__isCustomRow = !1), N(t, u, c, p), u.__epoch = n, u.__rowDataRef = c;
472
- else if (_ && y)
472
+ else if (_ && E)
473
473
  U(t, u, c, p), u.__rowDataRef = c;
474
- else if (u.__isCustomRow && (u.className = "data-grid-row", u.setAttribute("role", "row"), u.__isCustomRow = !1), N(t, u, c, p), u.__epoch = n, u.__rowDataRef = c, y) {
474
+ else if (u.__isCustomRow && (u.className = "data-grid-row", u.setAttribute("role", "row"), u.__isCustomRow = !1), N(t, u, c, p), u.__epoch = n, u.__rowDataRef = c, E) {
475
475
  const x = u.children;
476
476
  for (let A = 0; A < x.length; A++) {
477
477
  const P = t._visibleColumns[A];
478
478
  P && P.editable && k(t, c, p, P, x[A]);
479
479
  }
480
480
  }
481
- } else if (E) {
482
- const _ = u.querySelector(".cell.editing"), y = t._activeEditRows === p;
483
- if (_ && !y)
481
+ } else if (C) {
482
+ const _ = u.querySelector(".cell.editing"), E = t._activeEditRows === p;
483
+ if (_ && !E)
484
484
  N(t, u, c, p), u.__epoch = n, u.__rowDataRef = c;
485
- else if (U(t, u, c, p), u.__rowDataRef = c, y && !_) {
485
+ else if (U(t, u, c, p), u.__rowDataRef = c, E && !_) {
486
486
  const x = u.children;
487
487
  for (let A = 0; A < x.length; A++) {
488
488
  const P = t._visibleColumns[A];
@@ -490,10 +490,10 @@ function Ne(t, e, o, n, i) {
490
490
  }
491
491
  }
492
492
  } else {
493
- const _ = u.querySelector(".cell.editing"), y = t._activeEditRows === p;
494
- if (_ && !y)
493
+ const _ = u.querySelector(".cell.editing"), E = t._activeEditRows === p;
494
+ if (_ && !E)
495
495
  N(t, u, c, p), u.__epoch = n, u.__rowDataRef = c;
496
- else if (U(t, u, c, p), y && !_) {
496
+ else if (U(t, u, c, p), E && !_) {
497
497
  const x = u.children;
498
498
  for (let A = 0; A < x.length; A++) {
499
499
  const P = t._visibleColumns[A];
@@ -501,8 +501,8 @@ function Ne(t, e, o, n, i) {
501
501
  }
502
502
  }
503
503
  }
504
- const m = t._changedRowIndices.has(p), C = u.classList.contains("changed");
505
- m !== C && u.classList.toggle("changed", m), u.parentNode !== r && r.appendChild(u);
504
+ const m = t._changedRowIndices.has(p), S = u.classList.contains("changed");
505
+ m !== S && u.classList.toggle("changed", m), u.parentNode !== r && r.appendChild(u);
506
506
  }
507
507
  }
508
508
  function U(t, e, o, n) {
@@ -540,36 +540,36 @@ function U(t, e, o, n) {
540
540
  const w = d === n && f === c, v = b.classList.contains("cell-focus");
541
541
  if (w !== v && (b.classList.toggle("cell-focus", w), b.setAttribute("aria-selected", String(w))), b.classList.contains("editing")) continue;
542
542
  if (u.viewRenderer) {
543
- const E = o[u.field], g = u.viewRenderer({ row: o, value: E, field: u.field, column: u });
544
- typeof g == "string" ? b.innerHTML = F(g) : g ? (b.innerHTML = "", b.appendChild(g)) : b.textContent = E == null ? "" : String(E);
543
+ const C = o[u.field], g = u.viewRenderer({ row: o, value: C, field: u.field, column: u });
544
+ typeof g == "string" ? b.innerHTML = F(g) : g ? (b.innerHTML = "", b.appendChild(g)) : b.textContent = C == null ? "" : String(C);
545
545
  continue;
546
546
  }
547
547
  if (u.__viewTemplate || u.__compiledView || u.externalView)
548
548
  continue;
549
- const S = o[u.field];
549
+ const y = o[u.field];
550
550
  let R;
551
551
  if (u.format)
552
552
  try {
553
- const E = u.format(S, o);
554
- R = E == null ? "" : String(E);
553
+ const C = u.format(y, o);
554
+ R = C == null ? "" : String(C);
555
555
  } catch {
556
- R = S == null ? "" : String(S);
556
+ R = y == null ? "" : String(y);
557
557
  }
558
558
  else if (u.type === "date") {
559
- if (S == null || S === "")
559
+ if (y == null || y === "")
560
560
  R = "";
561
- else if (S instanceof Date)
562
- R = isNaN(S.getTime()) ? "" : S.toLocaleDateString();
561
+ else if (y instanceof Date)
562
+ R = isNaN(y.getTime()) ? "" : y.toLocaleDateString();
563
563
  else {
564
- const E = new Date(S);
565
- R = isNaN(E.getTime()) ? "" : E.toLocaleDateString();
564
+ const C = new Date(y);
565
+ R = isNaN(C.getTime()) ? "" : C.toLocaleDateString();
566
566
  }
567
567
  b.textContent = R;
568
568
  } else if (u.type === "boolean") {
569
- const E = !!S;
570
- b.innerHTML = `<span role="checkbox" aria-checked="${E}" aria-label="${E}">${E ? "&#x1F5F9;" : "&#9744;"}</span>`;
569
+ const C = !!y;
570
+ b.innerHTML = `<span role="checkbox" aria-checked="${C}" aria-label="${C}">${C ? "&#x1F5F9;" : "&#9744;"}</span>`;
571
571
  } else
572
- R = S == null ? "" : String(S), b.textContent = R;
572
+ R = y == null ? "" : String(y), b.textContent = R;
573
573
  }
574
574
  }
575
575
  function N(t, e, o, n) {
@@ -585,18 +585,18 @@ function N(t, e, o, n) {
585
585
  u = b(u, o);
586
586
  } catch {
587
587
  }
588
- const w = p.__compiledView, v = p.__viewTemplate, S = p.viewRenderer, R = p.externalView;
589
- let E = !1;
590
- if (S) {
591
- const g = S({ row: o, value: u, field: p.field, column: p });
592
- typeof g == "string" ? (c.innerHTML = F(g), E = !0) : g ? c.appendChild(g) : c.textContent = u == null ? "" : String(u);
588
+ const w = p.__compiledView, v = p.__viewTemplate, y = p.viewRenderer, R = p.externalView;
589
+ let C = !1;
590
+ if (y) {
591
+ const g = y({ row: o, value: u, field: p.field, column: p });
592
+ typeof g == "string" ? (c.innerHTML = F(g), C = !0) : g ? c.appendChild(g) : c.textContent = u == null ? "" : String(u);
593
593
  } else if (R) {
594
594
  const g = R, m = document.createElement("div");
595
595
  m.setAttribute("data-external-view", ""), m.setAttribute("data-field", p.field), c.appendChild(m);
596
- const C = { row: o, value: u, field: p.field, column: p };
596
+ const S = { row: o, value: u, field: p.field, column: p };
597
597
  if (g.mount)
598
598
  try {
599
- g.mount({ placeholder: m, context: C, spec: g });
599
+ g.mount({ placeholder: m, context: S, spec: g });
600
600
  } catch {
601
601
  }
602
602
  else
@@ -606,7 +606,7 @@ function N(t, e, o, n) {
606
606
  new CustomEvent("mount-external-view", {
607
607
  bubbles: !0,
608
608
  composed: !0,
609
- detail: { placeholder: m, spec: g, context: C }
609
+ detail: { placeholder: m, spec: g, context: S }
610
610
  })
611
611
  );
612
612
  } catch {
@@ -615,10 +615,10 @@ function N(t, e, o, n) {
615
615
  m.setAttribute("data-mounted", "");
616
616
  } else if (w) {
617
617
  const g = w({ row: o, value: u, field: p.field, column: p }), m = w.__blocked;
618
- c.innerHTML = m ? "" : F(g), E = !0, m && (c.textContent = "", c.setAttribute("data-blocked-template", ""));
618
+ c.innerHTML = m ? "" : F(g), C = !0, m && (c.textContent = "", c.setAttribute("data-blocked-template", ""));
619
619
  } else if (v) {
620
620
  const g = v.innerHTML;
621
- /Reflect\.|\bProxy\b|ownKeys\(/.test(g) ? (c.textContent = "", c.setAttribute("data-blocked-template", "")) : (c.innerHTML = F(he(g, { row: o, value: u })), E = !0);
621
+ /Reflect\.|\bProxy\b|ownKeys\(/.test(g) ? (c.textContent = "", c.setAttribute("data-blocked-template", "")) : (c.innerHTML = F(he(g, { row: o, value: u })), C = !0);
622
622
  } else if (p.type === "date")
623
623
  if (u == null || u === "")
624
624
  c.textContent = "";
@@ -636,7 +636,7 @@ function N(t, e, o, n) {
636
636
  c.innerHTML = `<span role="checkbox" aria-checked="${g}" aria-label="${g}">${g ? "&#x1F5F9;" : "&#9744;"}</span>`;
637
637
  } else
638
638
  c.textContent = u == null ? "" : String(u);
639
- if (E) {
639
+ if (C) {
640
640
  Le(c);
641
641
  const g = c.textContent || "";
642
642
  /Proxy|Reflect\.ownKeys/.test(g) && (c.textContent = g.replace(/Proxy|Reflect\.ownKeys/g, "").trim(), /Proxy|Reflect\.ownKeys/.test(c.textContent || "") && (c.textContent = ""));
@@ -644,36 +644,36 @@ function N(t, e, o, n) {
644
644
  c.hasAttribute("data-blocked-template") && (c.textContent || "").trim().length && (c.textContent = ""), p.editable ? (c.tabIndex = 0, c.addEventListener("mousedown", () => {
645
645
  if (c.classList.contains("editing")) return;
646
646
  const g = Number(c.getAttribute("data-row")), m = Number(c.getAttribute("data-col"));
647
- isNaN(g) || isNaN(m) || (t._focusRow = g, t._focusCol = m, M(t));
647
+ isNaN(g) || isNaN(m) || (t._focusRow = g, t._focusCol = m, z(t));
648
648
  }), a === "click" ? c.addEventListener("click", (g) => {
649
649
  if (c.classList.contains("editing")) return;
650
650
  g.stopPropagation();
651
- const m = Number(c.getAttribute("data-row")), C = Number(c.getAttribute("data-col"));
652
- if (isNaN(m) || isNaN(C)) return;
653
- const _ = t._rows[m], y = t._visibleColumns[C];
654
- !_ || !y || (t._focusRow = m, t._focusCol = C, k(t, _, m, y, c));
651
+ const m = Number(c.getAttribute("data-row")), S = Number(c.getAttribute("data-col"));
652
+ if (isNaN(m) || isNaN(S)) return;
653
+ const _ = t._rows[m], E = t._visibleColumns[S];
654
+ !_ || !E || (t._focusRow = m, t._focusCol = S, k(t, _, m, E, c));
655
655
  }) : c.addEventListener("dblclick", (g) => {
656
656
  g.stopPropagation();
657
657
  const m = Number(c.getAttribute("data-row"));
658
658
  if (isNaN(m)) return;
659
- const C = t._rows[m];
660
- if (!C) return;
661
- B(t, m, C);
659
+ const S = t._rows[m];
660
+ if (!S) return;
661
+ B(t, m, S);
662
662
  const _ = t.findRenderedRowElement?.(m);
663
663
  if (_) {
664
- const y = _.children;
665
- for (let x = 0; x < y.length; x++) {
664
+ const E = _.children;
665
+ for (let x = 0; x < E.length; x++) {
666
666
  const A = t._visibleColumns[x];
667
- A && A.editable && k(t, C, m, A, y[x]);
667
+ A && A.editable && k(t, S, m, A, E[x]);
668
668
  }
669
669
  }
670
670
  }), c.addEventListener("keydown", (g) => {
671
- const m = Number(c.getAttribute("data-row")), C = Number(c.getAttribute("data-col"));
672
- if (isNaN(m) || isNaN(C)) return;
673
- const _ = t._rows[m], y = t._visibleColumns[C];
674
- if (!(!_ || !y)) {
675
- if ((y.type === "select" || y.type === "typeahead") && !c.classList.contains("editing") && g.key === "Enter") {
676
- g.preventDefault(), t._activeEditRows !== m && B(t, m, _), k(t, _, m, y, c), setTimeout(() => {
671
+ const m = Number(c.getAttribute("data-row")), S = Number(c.getAttribute("data-col"));
672
+ if (isNaN(m) || isNaN(S)) return;
673
+ const _ = t._rows[m], E = t._visibleColumns[S];
674
+ if (!(!_ || !E)) {
675
+ if ((E.type === "select" || E.type === "typeahead") && !c.classList.contains("editing") && g.key === "Enter") {
676
+ g.preventDefault(), t._activeEditRows !== m && B(t, m, _), k(t, _, m, E, c), setTimeout(() => {
677
677
  const x = c.querySelector("select");
678
678
  try {
679
679
  x?.showPicker?.();
@@ -683,18 +683,18 @@ function N(t, e, o, n) {
683
683
  }, 0);
684
684
  return;
685
685
  }
686
- if (y.type === "boolean" && g.key === " " && !c.classList.contains("editing")) {
686
+ if (E.type === "boolean" && g.key === " " && !c.classList.contains("editing")) {
687
687
  g.preventDefault(), t._activeEditRows !== m && B(t, m, _);
688
- const x = !_[y.field];
689
- J(t, m, y, x, _), c.innerHTML = `<span role="checkbox" aria-checked="${x}" aria-label="${x}">${x ? "&#x1F5F9;" : "&#9744;"}</span>`;
688
+ const x = !_[E.field];
689
+ J(t, m, E, x, _), c.innerHTML = `<span role="checkbox" aria-checked="${x}" aria-label="${x}">${x ? "&#x1F5F9;" : "&#9744;"}</span>`;
690
690
  return;
691
691
  }
692
692
  if (g.key === "Enter" && !c.classList.contains("editing")) {
693
- g.preventDefault(), g.stopPropagation(), t._focusRow = m, t._focusCol = C, typeof t.beginBulkEdit == "function" ? t.beginBulkEdit(m) : k(t, _, m, y, c);
693
+ g.preventDefault(), g.stopPropagation(), t._focusRow = m, t._focusCol = S, typeof t.beginBulkEdit == "function" ? t.beginBulkEdit(m) : k(t, _, m, E, c);
694
694
  return;
695
695
  }
696
696
  if (g.key === "F2" && !c.classList.contains("editing")) {
697
- g.preventDefault(), k(t, _, m, y, c);
697
+ g.preventDefault(), k(t, _, m, E, c);
698
698
  return;
699
699
  }
700
700
  }
@@ -718,7 +718,7 @@ function oe(t, e, o, n) {
718
718
  if (!isNaN(d)) {
719
719
  if (t._dispatchCellClick?.(e, s, d, l))
720
720
  return;
721
- t._focusRow = s, t._focusCol = d, M(t);
721
+ t._focusRow = s, t._focusCol = d, z(t);
722
722
  }
723
723
  }
724
724
  if (o.querySelector(".cell.editing")) {
@@ -834,8 +834,8 @@ function k(t, e, o, n, i) {
834
834
  if (h === "template" && f) {
835
835
  const c = f.cloneNode(!0), u = n.__compiledEditor;
836
836
  u ? c.innerHTML = u({ row: e, value: s, field: n.field, column: n }) : c.querySelectorAll("*").forEach((w) => {
837
- w.childNodes.length === 1 && w.firstChild?.nodeType === Node.TEXT_NODE && (w.textContent = w.textContent?.replace(/{{\s*value\s*}}/g, s == null ? "" : String(s)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (v, S) => {
838
- const R = e[S];
837
+ w.childNodes.length === 1 && w.firstChild?.nodeType === Node.TEXT_NODE && (w.textContent = w.textContent?.replace(/{{\s*value\s*}}/g, s == null ? "" : String(s)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (v, y) => {
838
+ const R = e[y];
839
839
  return R == null ? "" : String(R);
840
840
  }) || "");
841
841
  });
@@ -848,8 +848,8 @@ function k(t, e, o, n, i) {
848
848
  }), b.addEventListener("keydown", (v) => {
849
849
  if (v.key === "Enter") {
850
850
  v.stopPropagation(), v.preventDefault(), r = !0;
851
- const S = w && b instanceof HTMLInputElement && b.type === "checkbox" ? b.checked : b.value;
852
- l(S), D(t, o, !1);
851
+ const y = w && b instanceof HTMLInputElement && b.type === "checkbox" ? b.checked : b.value;
852
+ l(y), D(t, o, !1);
853
853
  }
854
854
  v.key === "Escape" && (v.stopPropagation(), v.preventDefault(), a(), D(t, o, !0));
855
855
  }), w && b instanceof HTMLInputElement && b.type === "checkbox" && b.addEventListener("change", () => {
@@ -1695,13 +1695,13 @@ class et {
1695
1695
  class W extends HTMLElement {
1696
1696
  // TODO: Rename to 'data-grid' when migration is complete
1697
1697
  static tagName = "tbw-grid";
1698
- static version = "0.2.7";
1698
+ static version = "0.2.8";
1699
1699
  // ---------------- Observed Attributes ----------------
1700
1700
  static get observedAttributes() {
1701
1701
  return ["rows", "columns", "grid-config", "fit-mode", "edit-on"];
1702
1702
  }
1703
1703
  #o;
1704
- #M = !1;
1704
+ #z = !1;
1705
1705
  // ---------------- Ready Promise ----------------
1706
1706
  #I;
1707
1707
  #$;
@@ -1724,7 +1724,7 @@ class W extends HTMLElement {
1724
1724
  #S = null;
1725
1725
  #R = !1;
1726
1726
  // Cached flag for plugin scroll handlers
1727
- #z;
1727
+ #M;
1728
1728
  // Cached hook to avoid closures
1729
1729
  #x = !1;
1730
1730
  #A = null;
@@ -1913,7 +1913,7 @@ class W extends HTMLElement {
1913
1913
  * @internal Plugin API
1914
1914
  */
1915
1915
  requestRender() {
1916
- this.#O(), this.#k(), q(this), z(this), this.refreshVirtualWindow(!0);
1916
+ this.#O(), this.#k(), q(this), M(this), this.refreshVirtualWindow(!0);
1917
1917
  }
1918
1918
  /**
1919
1919
  * Update the grid's column template CSS.
@@ -1921,7 +1921,7 @@ class W extends HTMLElement {
1921
1921
  * @internal
1922
1922
  */
1923
1923
  updateTemplate() {
1924
- z(this);
1924
+ M(this);
1925
1925
  }
1926
1926
  /**
1927
1927
  * Request a lightweight style update without rebuilding DOM.
@@ -1980,7 +1980,7 @@ class W extends HTMLElement {
1980
1980
  }
1981
1981
  // ---------------- Lifecycle ----------------
1982
1982
  connectedCallback() {
1983
- this.hasAttribute("tabindex") || (this.tabIndex = 0), this.hasAttribute("version") || this.setAttribute("version", W.version), this._rows = Array.isArray(this.#r) ? [...this.#r] : [], this.#a?.abort(), this.#a = new AbortController(), this.#f(), this.#W(), this.#K(), this.#M || (this.#X(), this.#V(), this.#M = !0), this.#F();
1983
+ this.hasAttribute("tabindex") || (this.tabIndex = 0), this.hasAttribute("version") || this.setAttribute("version", W.version), this._rows = Array.isArray(this.#r) ? [...this.#r] : [], this.#a?.abort(), this.#a = new AbortController(), this.#f(), this.#W(), this.#K(), this.#z || (this.#X(), this.#V(), this.#z = !0), this.#F();
1984
1984
  }
1985
1985
  disconnectedCallback() {
1986
1986
  this.#j(), Ze(this.#i), this.#n.setInitialized(!1), this.#H?.(), this.#H = void 0, this.#a && (this.#a.abort(), this.#a = void 0), this._resizeController && this._resizeController.dispose(), this.#E && (this.#E.disconnect(), this.#E = void 0), this.#p = !1;
@@ -2018,7 +2018,7 @@ class W extends HTMLElement {
2018
2018
  }
2019
2019
  this.setAttribute("data-upgraded", ""), this.#p = !0;
2020
2020
  const n = this.disconnectSignal;
2021
- this._resizeController = $e(this), this.#c(), this.addEventListener("keydown", (l) => Me(this, l), { signal: n }), document.addEventListener(
2021
+ this._resizeController = $e(this), this.#c(), this.addEventListener("keydown", (l) => ze(this, l), { signal: n }), document.addEventListener(
2022
2022
  "keydown",
2023
2023
  (l) => {
2024
2024
  l.key === "Escape" && this._activeEditRows !== -1 && D(this, this._activeEditRows, !0);
@@ -2039,8 +2039,14 @@ class W extends HTMLElement {
2039
2039
  "scroll",
2040
2040
  () => {
2041
2041
  if (!this._virtualization.enabled && !this.#R) return;
2042
- const d = i.scrollTop, f = this._virtualization.rowHeight, h = Math.floor(d / f), p = h - h % 2, c = -(d - p * f);
2043
- s.style.transform = `translateY(${c}px)`, this.#S = d, this.#b || (this.#b = requestAnimationFrame(() => {
2042
+ const d = i.scrollTop, f = this._virtualization.rowHeight;
2043
+ if (this._rows.length <= this._virtualization.bypassThreshold)
2044
+ s.style.transform = `translateY(${-d}px)`;
2045
+ else {
2046
+ const h = Math.floor(d / f), p = h - h % 2, c = -(d - p * f);
2047
+ s.style.transform = `translateY(${c}px)`;
2048
+ }
2049
+ this.#S = d, this.#b || (this.#b = requestAnimationFrame(() => {
2044
2050
  this.#b = 0, this.#S !== null && (this.#ie(this.#S), this.#S = null);
2045
2051
  }));
2046
2052
  },
@@ -2076,13 +2082,13 @@ class W extends HTMLElement {
2076
2082
  g > 0 && (this.#d = (this.#m - f) / g, this.#u = (this.#v - h) / g);
2077
2083
  }
2078
2084
  this.#m = f, this.#v = h, this.#_ = p;
2079
- const { scrollTop: b, scrollHeight: w, clientHeight: v } = i, S = w - v, R = c > 0 && b < S || c < 0 && b > 0;
2080
- let E = !1;
2085
+ const { scrollTop: b, scrollHeight: w, clientHeight: v } = i, y = w - v, R = c > 0 && b < y || c < 0 && b > 0;
2086
+ let C = !1;
2081
2087
  if (a) {
2082
- const { scrollLeft: g, scrollWidth: m, clientWidth: C } = a, _ = m - C;
2083
- E = u > 0 && g < _ || u < 0 && g > 0;
2088
+ const { scrollLeft: g, scrollWidth: m, clientWidth: S } = a, _ = m - S;
2089
+ C = u > 0 && g < _ || u < 0 && g > 0;
2084
2090
  }
2085
- R && (i.scrollTop = this.#L + c), E && a && (a.scrollLeft = this.#P + u), (R || E) && d.preventDefault();
2091
+ R && (i.scrollTop = this.#L + c), C && a && (a.scrollLeft = this.#P + u), (R || C) && d.preventDefault();
2086
2092
  }
2087
2093
  },
2088
2094
  { passive: !1, signal: n }
@@ -2104,7 +2110,7 @@ class W extends HTMLElement {
2104
2110
  }
2105
2111
  }), this._virtualization.viewportEl && (this.#E = new ResizeObserver(() => {
2106
2112
  this.#b || (this.#b = requestAnimationFrame(() => {
2107
- this.#b = 0, this.refreshVirtualWindow(!0), M(this);
2113
+ this.#b = 0, this.refreshVirtualWindow(!0), z(this);
2108
2114
  }));
2109
2115
  }), this.#E.observe(this._virtualization.viewportEl)), queueMicrotask(() => this.#Z()), requestAnimationFrame(() => requestAnimationFrame(() => this.#$?.()));
2110
2116
  }
@@ -2141,7 +2147,7 @@ class W extends HTMLElement {
2141
2147
  if (!this.#p) return;
2142
2148
  this.#f(), this.#t.fitMode === "fixed" ? (this.__didInitialAutoSize = !1, te(this)) : (this._columns.forEach((o) => {
2143
2149
  !o.__userResized && o.__autoSized && delete o.width;
2144
- }), z(this));
2150
+ }), M(this));
2145
2151
  }
2146
2152
  #Q() {
2147
2153
  this.#p && (this.#f(), this._rowPool.length = 0, this._bodyEl && (this._bodyEl.innerHTML = ""), this.__rowRenderEpoch++, this.refreshVirtualWindow(!0));
@@ -2153,7 +2159,7 @@ class W extends HTMLElement {
2153
2159
  K(this), this.#p && (this.#f(), this.#c());
2154
2160
  }
2155
2161
  #oe() {
2156
- this.#p && (this.#f(), this.#G(), this.#O(), this.#k(), q(this), z(this), this.refreshVirtualWindow(!0));
2162
+ this.#p && (this.#f(), this.#G(), this.#O(), this.#k(), q(this), M(this), this.refreshVirtualWindow(!0));
2157
2163
  }
2158
2164
  #k() {
2159
2165
  if (this.#e) {
@@ -2241,7 +2247,7 @@ class W extends HTMLElement {
2241
2247
  }
2242
2248
  // ---------------- Delegate Wrappers ----------------
2243
2249
  #q(e, o, n = this.__rowRenderEpoch) {
2244
- this.#z || (this.#z = (i, s, r) => this.#e?.renderRow(i, s, r) ?? !1), Ne(this, e, o, n, this.#z);
2250
+ this.#M || (this.#M = (i, s, r) => this.#e?.renderRow(i, s, r) ?? !1), Ne(this, e, o, n, this.#M);
2245
2251
  }
2246
2252
  // ---------------- Core Helpers ----------------
2247
2253
  #c() {
@@ -2259,7 +2265,7 @@ class W extends HTMLElement {
2259
2265
  const n = this.#h;
2260
2266
  this.#h = void 0, this.#U(n);
2261
2267
  }
2262
- q(this), z(this), this.refreshVirtualWindow(!0), this.#t.fitMode === "fixed" && !this.__didInitialAutoSize && requestAnimationFrame(() => te(this)), this._bodyEl && (this._bodyEl.style.display = "", this._bodyEl.style.gridTemplateColumns = ""), queueMicrotask(() => this.#e?.afterRender());
2268
+ q(this), M(this), this.refreshVirtualWindow(!0), this.#t.fitMode === "fixed" && !this.__didInitialAutoSize && requestAnimationFrame(() => te(this)), this._bodyEl && (this._bodyEl.style.display = "", this._bodyEl.style.gridTemplateColumns = ""), queueMicrotask(() => this.#e?.afterRender());
2263
2269
  }
2264
2270
  /** Internal method to apply column state without triggering setup loop */
2265
2271
  #U(e) {
@@ -2566,7 +2572,7 @@ class W extends HTMLElement {
2566
2572
  }
2567
2573
  for (const i of o.values())
2568
2574
  n.push(i);
2569
- this._columns = n, q(this), z(this), this.refreshVirtualWindow(!0);
2575
+ this._columns = n, q(this), M(this), this.refreshVirtualWindow(!0);
2570
2576
  }
2571
2577
  /**
2572
2578
  * Get the current column order as an array of field names.
@@ -2589,7 +2595,7 @@ class W extends HTMLElement {
2589
2595
  * Use this to restore previously saved column state.
2590
2596
  */
2591
2597
  set columnState(e) {
2592
- e && (this.#h = e, this.#M && this.#ce(e));
2598
+ e && (this.#h = e, this.#z && this.#ce(e));
2593
2599
  }
2594
2600
  /**
2595
2601
  * Get the current column state.
@@ -2734,9 +2740,9 @@ class W extends HTMLElement {
2734
2740
  return;
2735
2741
  }
2736
2742
  if (this._rows.length <= this._virtualization.bypassThreshold) {
2737
- if (this._virtualization.start = 0, this._virtualization.end = o, this._bodyEl.style.transform = "translateY(0px)", this.#q(0, o, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch), this._virtualization.totalHeightEl) {
2738
- const C = this.#o.querySelector(".tbw-scroll-area"), _ = C ? C.offsetHeight - C.clientHeight : 0;
2739
- this._virtualization.totalHeightEl.style.height = `${o * this._virtualization.rowHeight + _}px`;
2743
+ if (this._virtualization.start = 0, this._virtualization.end = o, e && (this._bodyEl.style.transform = "translateY(0px)"), this.#q(0, o, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch), this._virtualization.totalHeightEl) {
2744
+ const S = this._virtualization.container?.clientHeight ?? 0, _ = this._virtualization.viewportEl?.clientHeight ?? S, E = S - _;
2745
+ this._virtualization.totalHeightEl.style.height = `${o * this._virtualization.rowHeight + E}px`;
2740
2746
  }
2741
2747
  const m = this.#o.querySelector(".rows-body");
2742
2748
  m?.setAttribute("aria-rowcount", String(o)), m?.setAttribute("aria-colcount", String(this._visibleColumns.length)), this.#e?.afterRender();
@@ -2746,9 +2752,9 @@ class W extends HTMLElement {
2746
2752
  let a = Math.floor(l / r), d = 0;
2747
2753
  const f = 10;
2748
2754
  for (; d < f; ) {
2749
- const m = this.#e?.getExtraHeightBefore?.(a) ?? 0, C = Math.floor((l - m) / r);
2750
- if (C >= a || C < 0) break;
2751
- a = C, d++;
2755
+ const m = this.#e?.getExtraHeightBefore?.(a) ?? 0, S = Math.floor((l - m) / r);
2756
+ if (S >= a || S < 0) break;
2757
+ a = S, d++;
2752
2758
  }
2753
2759
  a = a - a % 2, a < 0 && (a = 0);
2754
2760
  const h = this.#e?.adjustVirtualStart(a, l, r);
@@ -2756,10 +2762,10 @@ class W extends HTMLElement {
2756
2762
  const p = Math.ceil(s / r) + 3;
2757
2763
  let c = a + p;
2758
2764
  c > o && (c = o), this._virtualization.start = a, this._virtualization.end = c;
2759
- const b = this.#o.querySelector(".tbw-footer")?.offsetHeight ?? 0, w = this.#e?.getExtraHeight() ?? 0, v = this.#o.querySelector(".tbw-scroll-area"), S = v ? v.offsetHeight - v.clientHeight : 0;
2760
- this._virtualization.totalHeightEl && (this._virtualization.totalHeightEl.style.height = `${o * r + r + b + w + S}px`);
2761
- const R = this.#e?.getExtraHeightBefore?.(a) ?? 0, E = -(l - a * r - R);
2762
- this._bodyEl.style.transform = `translateY(${E}px)`, this.#q(a, c, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch);
2765
+ const b = this.#o.querySelector(".tbw-footer")?.offsetHeight ?? 0, w = this.#e?.getExtraHeight() ?? 0, v = this.#o.querySelector(".tbw-scroll-area"), y = v ? v.offsetHeight - v.clientHeight : 0;
2766
+ this._virtualization.totalHeightEl && (this._virtualization.totalHeightEl.style.height = `${o * r + r + b + w + y}px`);
2767
+ const R = this.#e?.getExtraHeightBefore?.(a) ?? 0, C = -(l - a * r - R);
2768
+ this._bodyEl.style.transform = `translateY(${C}px)`, this.#q(a, c, e ? ++this.__rowRenderEpoch : this.__rowRenderEpoch);
2763
2769
  const g = this.#o.querySelector(".rows-body");
2764
2770
  g?.setAttribute("aria-rowcount", String(o)), g?.setAttribute("aria-colcount", String(this._visibleColumns.length)), e && this.#e?.afterRender();
2765
2771
  }
@@ -3210,7 +3216,7 @@ export {
3210
3216
  W as b,
3211
3217
  et as c,
3212
3218
  O as d,
3213
- M as e,
3219
+ z as e,
3214
3220
  ct as f,
3215
3221
  ut as g,
3216
3222
  at as h,
@@ -3226,4 +3232,4 @@ export {
3226
3232
  ht as r,
3227
3233
  dt as u
3228
3234
  };
3229
- //# sourceMappingURL=index-DG2CZ_Zo.js.map
3235
+ //# sourceMappingURL=index-YjW60MHD.js.map