@toolbox-web/grid 1.14.1 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +5 -1
  2. package/all.js +2013 -1564
  3. package/all.js.map +1 -1
  4. package/index.js +918 -880
  5. package/index.js.map +1 -1
  6. package/lib/core/grid.d.ts.map +1 -1
  7. package/lib/core/internal/columns.d.ts +0 -5
  8. package/lib/core/internal/columns.d.ts.map +1 -1
  9. package/lib/core/internal/rows.d.ts.map +1 -1
  10. package/lib/core/internal/validate-config.d.ts.map +1 -1
  11. package/lib/core/types.d.ts +12 -0
  12. package/lib/core/types.d.ts.map +1 -1
  13. package/lib/plugins/clipboard/index.js.map +1 -1
  14. package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts.map +1 -1
  15. package/lib/plugins/column-virtualization/index.js +1 -1
  16. package/lib/plugins/column-virtualization/index.js.map +1 -1
  17. package/lib/plugins/context-menu/ContextMenuPlugin.d.ts +20 -1
  18. package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
  19. package/lib/plugins/context-menu/index.d.ts +1 -1
  20. package/lib/plugins/context-menu/index.d.ts.map +1 -1
  21. package/lib/plugins/context-menu/index.js +177 -84
  22. package/lib/plugins/context-menu/index.js.map +1 -1
  23. package/lib/plugins/context-menu/menu.d.ts +7 -0
  24. package/lib/plugins/context-menu/menu.d.ts.map +1 -1
  25. package/lib/plugins/context-menu/types.d.ts +48 -2
  26. package/lib/plugins/context-menu/types.d.ts.map +1 -1
  27. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
  28. package/lib/plugins/editing/index.js +327 -298
  29. package/lib/plugins/editing/index.js.map +1 -1
  30. package/lib/plugins/export/index.js.map +1 -1
  31. package/lib/plugins/filtering/FilteringPlugin.d.ts +7 -1
  32. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  33. package/lib/plugins/filtering/filter-model.d.ts.map +1 -1
  34. package/lib/plugins/filtering/index.js +173 -138
  35. package/lib/plugins/filtering/index.js.map +1 -1
  36. package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +5 -1
  37. package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -1
  38. package/lib/plugins/grouping-columns/index.js +242 -109
  39. package/lib/plugins/grouping-columns/index.js.map +1 -1
  40. package/lib/plugins/grouping-columns/types.d.ts +7 -0
  41. package/lib/plugins/grouping-columns/types.d.ts.map +1 -1
  42. package/lib/plugins/grouping-rows/index.js.map +1 -1
  43. package/lib/plugins/master-detail/index.js.map +1 -1
  44. package/lib/plugins/multi-sort/index.js.map +1 -1
  45. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +11 -1
  46. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
  47. package/lib/plugins/pinned-columns/index.d.ts +1 -1
  48. package/lib/plugins/pinned-columns/index.d.ts.map +1 -1
  49. package/lib/plugins/pinned-columns/index.js +174 -79
  50. package/lib/plugins/pinned-columns/index.js.map +1 -1
  51. package/lib/plugins/pinned-columns/pinned-columns.d.ts +23 -4
  52. package/lib/plugins/pinned-columns/pinned-columns.d.ts.map +1 -1
  53. package/lib/plugins/pinned-columns/types.d.ts +21 -9
  54. package/lib/plugins/pinned-columns/types.d.ts.map +1 -1
  55. package/lib/plugins/pinned-rows/index.js.map +1 -1
  56. package/lib/plugins/pivot/index.js.map +1 -1
  57. package/lib/plugins/print/index.js.map +1 -1
  58. package/lib/plugins/reorder/index.js.map +1 -1
  59. package/lib/plugins/responsive/index.js.map +1 -1
  60. package/lib/plugins/row-reorder/index.js.map +1 -1
  61. package/lib/plugins/selection/index.js.map +1 -1
  62. package/lib/plugins/server-side/index.js.map +1 -1
  63. package/lib/plugins/tree/index.js.map +1 -1
  64. package/lib/plugins/undo-redo/index.js.map +1 -1
  65. package/lib/plugins/visibility/VisibilityPlugin.d.ts +42 -2
  66. package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
  67. package/lib/plugins/visibility/index.d.ts +1 -1
  68. package/lib/plugins/visibility/index.d.ts.map +1 -1
  69. package/lib/plugins/visibility/index.js +219 -59
  70. package/lib/plugins/visibility/index.js.map +1 -1
  71. package/lib/plugins/visibility/types.d.ts +25 -0
  72. package/lib/plugins/visibility/types.d.ts.map +1 -1
  73. package/package.json +1 -1
  74. package/umd/grid.all.umd.js +27 -27
  75. package/umd/grid.all.umd.js.map +1 -1
  76. package/umd/grid.umd.js +21 -21
  77. package/umd/grid.umd.js.map +1 -1
  78. package/umd/plugins/column-virtualization.umd.js +1 -1
  79. package/umd/plugins/column-virtualization.umd.js.map +1 -1
  80. package/umd/plugins/context-menu.umd.js +1 -1
  81. package/umd/plugins/context-menu.umd.js.map +1 -1
  82. package/umd/plugins/editing.umd.js +1 -1
  83. package/umd/plugins/editing.umd.js.map +1 -1
  84. package/umd/plugins/filtering.umd.js +1 -1
  85. package/umd/plugins/filtering.umd.js.map +1 -1
  86. package/umd/plugins/grouping-columns.umd.js +1 -1
  87. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  88. package/umd/plugins/pinned-columns.umd.js +1 -1
  89. package/umd/plugins/pinned-columns.umd.js.map +1 -1
  90. package/umd/plugins/visibility.umd.js +1 -1
  91. package/umd/plugins/visibility.umd.js.map +1 -1
@@ -1,59 +1,59 @@
1
- function P(r) {
2
- r && r.querySelectorAll(".cell-focus").forEach((e) => e.classList.remove("cell-focus"));
1
+ function M(o) {
2
+ o && o.querySelectorAll(".cell-focus").forEach((e) => e.classList.remove("cell-focus"));
3
3
  }
4
- const w = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])', M = document.createElement("template");
5
- M.innerHTML = '<div class="cell" role="gridcell" part="cell"></div>';
6
- const H = document.createElement("template");
7
- H.innerHTML = '<div class="data-grid-row" role="row" part="row"></div>';
8
- function L(r, e) {
9
- if (r._virtualization?.enabled) {
10
- const { rowHeight: l, container: o, viewportEl: c } = r._virtualization, a = o, d = c?.clientHeight ?? a?.clientHeight ?? 0;
4
+ const v = 'input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])', P = document.createElement("template");
5
+ P.innerHTML = '<div class="cell" role="gridcell" part="cell"></div>';
6
+ const D = document.createElement("template");
7
+ D.innerHTML = '<div class="data-grid-row" role="row" part="row"></div>';
8
+ function L(o, e) {
9
+ if (o._virtualization?.enabled) {
10
+ const { rowHeight: n, container: l, viewportEl: c } = o._virtualization, a = l, d = c?.clientHeight ?? a?.clientHeight ?? 0;
11
11
  if (a && d > 0) {
12
- const g = r._focusRow * l;
13
- g < a.scrollTop ? a.scrollTop = g : g + l > a.scrollTop + d && (a.scrollTop = g - d + l);
12
+ const g = o._focusRow * n;
13
+ g < a.scrollTop ? a.scrollTop = g : g + n > a.scrollTop + d && (a.scrollTop = g - d + n);
14
14
  }
15
15
  }
16
- const t = r._activeEditRows !== void 0 && r._activeEditRows !== -1;
17
- t || r.refreshVirtualWindow(!1), P(r._bodyEl), Array.from(r._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((l) => {
18
- l.setAttribute("aria-selected", "false");
16
+ const t = o._activeEditRows !== void 0 && o._activeEditRows !== -1;
17
+ t || o.refreshVirtualWindow(!1), M(o._bodyEl), Array.from(o._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach((n) => {
18
+ n.setAttribute("aria-selected", "false");
19
19
  });
20
- const i = r._focusRow, n = r._virtualization.start ?? 0, s = r._virtualization.end ?? r._rows.length;
21
- if (i >= n && i < s) {
22
- const l = r._bodyEl.querySelectorAll(".data-grid-row")[i - n];
23
- let o = l?.children[r._focusCol];
24
- if ((!o || !o.classList?.contains("cell")) && (o = l?.querySelector(`.cell[data-col="${r._focusCol}"]`) ?? l?.querySelector(".cell[data-col]")), o) {
25
- o.classList.add("cell-focus"), o.setAttribute("aria-selected", "true");
26
- const c = r.querySelector(".tbw-scroll-area");
27
- if (c && o && (!t || e?.forceHorizontalScroll))
20
+ const i = o._focusRow, r = o._virtualization.start ?? 0, s = o._virtualization.end ?? o._rows.length;
21
+ if (i >= r && i < s) {
22
+ const n = o._bodyEl.querySelectorAll(".data-grid-row")[i - r];
23
+ let l = n?.children[o._focusCol];
24
+ if ((!l || !l.classList?.contains("cell")) && (l = n?.querySelector(`.cell[data-col="${o._focusCol}"]`) ?? n?.querySelector(".cell[data-col]")), l) {
25
+ l.classList.add("cell-focus"), l.setAttribute("aria-selected", "true");
26
+ const c = o.querySelector(".tbw-scroll-area");
27
+ if (c && l && (!t || e?.forceHorizontalScroll))
28
28
  if (e?.forceScrollLeft)
29
29
  c.scrollLeft = 0;
30
30
  else if (e?.forceScrollRight)
31
31
  c.scrollLeft = c.scrollWidth - c.clientWidth;
32
32
  else {
33
- const a = r._getHorizontalScrollOffsets?.(l ?? void 0, o) ?? { left: 0, right: 0 };
33
+ const a = o._getHorizontalScrollOffsets?.(n ?? void 0, l) ?? { left: 0, right: 0 };
34
34
  if (!a.skipScroll) {
35
- const d = o.getBoundingClientRect(), g = c.getBoundingClientRect(), f = d.left - g.left + c.scrollLeft, E = f + d.width, p = c.scrollLeft + a.left, m = c.scrollLeft + c.clientWidth - a.right;
35
+ const d = l.getBoundingClientRect(), g = c.getBoundingClientRect(), f = d.left - g.left + c.scrollLeft, E = f + d.width, p = c.scrollLeft + a.left, m = c.scrollLeft + c.clientWidth - a.right;
36
36
  f < p ? c.scrollLeft = f - a.left : E > m && (c.scrollLeft = E - c.clientWidth + a.right);
37
37
  }
38
38
  }
39
- if (r._activeEditRows !== void 0 && r._activeEditRows !== -1 && o.classList.contains("editing")) {
40
- const a = o.querySelector(w);
39
+ if (o._activeEditRows !== void 0 && o._activeEditRows !== -1 && l.classList.contains("editing")) {
40
+ const a = l.querySelector(v);
41
41
  if (a && document.activeElement !== a)
42
42
  try {
43
43
  a.focus({ preventScroll: !0 });
44
44
  } catch {
45
45
  }
46
- } else if (!o.contains(document.activeElement)) {
47
- o.hasAttribute("tabindex") || o.setAttribute("tabindex", "-1");
46
+ } else if (!l.contains(document.activeElement)) {
47
+ l.hasAttribute("tabindex") || l.setAttribute("tabindex", "-1");
48
48
  try {
49
- o.focus({ preventScroll: !0 });
49
+ l.focus({ preventScroll: !0 });
50
50
  } catch {
51
51
  }
52
52
  }
53
53
  }
54
54
  }
55
55
  }
56
- const I = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>', D = {
56
+ const I = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>', H = {
57
57
  expand: "▶",
58
58
  collapse: "▼",
59
59
  sortAsc: "▲",
@@ -356,7 +356,7 @@ class O {
356
356
  */
357
357
  get gridIcons() {
358
358
  const e = this.grid?.gridConfig?.icons ?? {};
359
- return { ...D, ...e };
359
+ return { ...H, ...e };
360
360
  }
361
361
  // #region Animation Helpers
362
362
  /**
@@ -432,123 +432,123 @@ class O {
432
432
  }
433
433
  // #endregion
434
434
  }
435
- const x = "@layer tbw-plugins{tbw-grid{--tbw-editing-bg: var(--tbw-color-selection);--tbw-editing-row-bg: var(--tbw-editing-bg);--tbw-editing-border: var(--tbw-border-input, 1px solid var(--tbw-color-border-strong));--tbw-padding-editing-input: var(--tbw-cell-padding-input, 2px 6px);--tbw-font-size-editor: inherit;--tbw-editing-row-outline-color: var(--tbw-color-accent);--tbw-editing-row-outline-width: 1px;--tbw-invalid-bg: light-dark(#fef2f2, #450a0a);--tbw-invalid-border-color: light-dark(#ef4444, #f87171)}tbw-grid:not(.tbw-grid-mode) .data-grid-row:has(.editing){background:var(--tbw-editing-row-bg);outline:var(--tbw-editing-row-outline-width) solid var(--tbw-editing-row-outline-color);outline-offset:calc(-1 * var(--tbw-editing-row-outline-width))}tbw-grid .data-grid-row>.cell.editing{overflow:hidden;padding:0;display:flex;min-height:calc(var(--tbw-row-height) + 2px);align-items:center;justify-content:center}tbw-grid .data-grid-row>.cell.editing input:not([type=checkbox]),tbw-grid .data-grid-row>.cell.editing select,tbw-grid .data-grid-row>.cell.editing textarea{width:100%;height:100%;flex:1 1 auto;min-width:0;border:var(--tbw-editing-border);padding:var(--tbw-padding-editing-input);font-size:var(--tbw-font-size-editor)}tbw-grid .tbw-editor-host{display:contents}tbw-grid .data-grid-row>.cell[data-invalid=true]{background:var(--tbw-invalid-bg);outline:1px solid var(--tbw-invalid-border-color);outline-offset:-1px}}";
436
- function B(r) {
437
- const e = r.options;
435
+ const B = "@layer tbw-plugins{tbw-grid{--tbw-editing-bg: var(--tbw-color-selection);--tbw-editing-row-bg: var(--tbw-editing-bg);--tbw-editing-border: var(--tbw-border-input, 1px solid var(--tbw-color-border-strong));--tbw-padding-editing-input: var(--tbw-cell-padding-input, 2px 6px);--tbw-font-size-editor: inherit;--tbw-editing-row-outline-color: var(--tbw-color-accent);--tbw-editing-row-outline-width: 1px;--tbw-invalid-bg: light-dark(#fef2f2, #450a0a);--tbw-invalid-border-color: light-dark(#ef4444, #f87171)}tbw-grid:not(.tbw-grid-mode) .data-grid-row:has(.editing){background:var(--tbw-editing-row-bg);outline:var(--tbw-editing-row-outline-width) solid var(--tbw-editing-row-outline-color);outline-offset:calc(-1 * var(--tbw-editing-row-outline-width))}tbw-grid .data-grid-row>.cell.editing{overflow:hidden;padding:0;display:flex;min-height:calc(var(--tbw-row-height) + 2px);align-items:center;justify-content:center}tbw-grid .data-grid-row>.cell.editing input:not([type=checkbox]),tbw-grid .data-grid-row>.cell.editing select,tbw-grid .data-grid-row>.cell.editing textarea{width:100%;height:100%;flex:1 1 auto;min-width:0;border:var(--tbw-editing-border);padding:var(--tbw-padding-editing-input);font-size:var(--tbw-font-size-editor)}tbw-grid .tbw-editor-host{display:contents}tbw-grid .data-grid-row>.cell[data-invalid=true]{background:var(--tbw-invalid-bg);outline:1px solid var(--tbw-invalid-border-color);outline-offset:-1px}}";
436
+ function x(o) {
437
+ const e = o.options;
438
438
  return e ? typeof e == "function" ? e() : e : [];
439
439
  }
440
- function N(r) {
440
+ function N(o) {
441
441
  return (e) => {
442
- const t = r.editorParams, i = document.createElement("input");
442
+ const t = o.editorParams, i = document.createElement("input");
443
443
  i.type = "number", i.value = e.value != null ? String(e.value) : "", t?.min !== void 0 && (i.min = String(t.min)), t?.max !== void 0 && (i.max = String(t.max)), t?.step !== void 0 && (i.step = String(t.step)), t?.placeholder && (i.placeholder = t.placeholder);
444
- const n = () => e.commit(i.value === "" ? null : Number(i.value));
445
- return i.addEventListener("blur", n), i.addEventListener("keydown", (s) => {
446
- s.key === "Enter" && n(), s.key === "Escape" && e.cancel();
444
+ const r = () => e.commit(i.value === "" ? null : Number(i.value));
445
+ return i.addEventListener("blur", r), i.addEventListener("keydown", (s) => {
446
+ s.key === "Enter" && r(), s.key === "Escape" && e.cancel();
447
447
  }), i;
448
448
  };
449
449
  }
450
450
  function $() {
451
- return (r) => {
451
+ return (o) => {
452
452
  const e = document.createElement("input");
453
- return e.type = "checkbox", e.checked = !!r.value, e.addEventListener("change", () => r.commit(e.checked)), e;
453
+ return e.type = "checkbox", e.checked = !!o.value, e.addEventListener("change", () => o.commit(e.checked)), e;
454
454
  };
455
455
  }
456
- function z(r) {
456
+ function G(o) {
457
457
  return (e) => {
458
- const t = r.editorParams, i = document.createElement("input");
458
+ const t = o.editorParams, i = document.createElement("input");
459
459
  i.type = "date", e.value instanceof Date ? i.valueAsDate = e.value : typeof e.value == "string" && e.value && (i.value = e.value.split("T")[0]), t?.min && (i.min = t.min), t?.max && (i.max = t.max), t?.placeholder && (i.placeholder = t.placeholder);
460
- const n = () => {
460
+ const r = () => {
461
461
  typeof e.value == "string" ? e.commit(i.value) : e.commit(i.valueAsDate);
462
462
  };
463
- return i.addEventListener("change", n), i.addEventListener("keydown", (s) => {
463
+ return i.addEventListener("change", r), i.addEventListener("keydown", (s) => {
464
464
  s.key === "Escape" && e.cancel();
465
465
  }), i;
466
466
  };
467
467
  }
468
- function G(r) {
468
+ function z(o) {
469
469
  return (e) => {
470
- const t = r.editorParams, i = document.createElement("select");
471
- if (r.multi && (i.multiple = !0), t?.includeEmpty) {
472
- const l = document.createElement("option");
473
- l.value = "", l.textContent = t.emptyLabel ?? "", i.appendChild(l);
470
+ const t = o.editorParams, i = document.createElement("select");
471
+ if (o.multi && (i.multiple = !0), t?.includeEmpty) {
472
+ const n = document.createElement("option");
473
+ n.value = "", n.textContent = t.emptyLabel ?? "", i.appendChild(n);
474
474
  }
475
- B(r).forEach((l) => {
476
- const o = document.createElement("option");
477
- o.value = String(l.value), o.textContent = l.label, (r.multi && Array.isArray(e.value) && e.value.includes(l.value) || !r.multi && e.value === l.value) && (o.selected = !0), i.appendChild(o);
475
+ x(o).forEach((n) => {
476
+ const l = document.createElement("option");
477
+ l.value = String(n.value), l.textContent = n.label, (o.multi && Array.isArray(e.value) && e.value.includes(n.value) || !o.multi && e.value === n.value) && (l.selected = !0), i.appendChild(l);
478
478
  });
479
479
  const s = () => {
480
- if (r.multi) {
481
- const l = Array.from(i.selectedOptions).map((o) => o.value);
482
- e.commit(l);
480
+ if (o.multi) {
481
+ const n = Array.from(i.selectedOptions).map((l) => l.value);
482
+ e.commit(n);
483
483
  } else
484
484
  e.commit(i.value);
485
485
  };
486
- return i.addEventListener("change", s), i.addEventListener("blur", s), i.addEventListener("keydown", (l) => {
487
- l.key === "Escape" && e.cancel();
486
+ return i.addEventListener("change", s), i.addEventListener("blur", s), i.addEventListener("keydown", (n) => {
487
+ n.key === "Escape" && e.cancel();
488
488
  }), i;
489
489
  };
490
490
  }
491
- function F(r) {
491
+ function F(o) {
492
492
  return (e) => {
493
- const t = r.editorParams, i = document.createElement("input");
493
+ const t = o.editorParams, i = document.createElement("input");
494
494
  i.type = "text", i.value = e.value != null ? String(e.value) : "", t?.maxLength !== void 0 && (i.maxLength = t.maxLength), t?.pattern && (i.pattern = t.pattern), t?.placeholder && (i.placeholder = t.placeholder);
495
- const n = () => {
495
+ const r = () => {
496
496
  const s = i.value;
497
497
  (e.value === null || e.value === void 0) && s === "" || typeof e.value == "string" && s === e.value.replace(/[\n\r]/g, "") || (typeof e.value == "number" && s !== "" ? e.commit(Number(s)) : e.commit(s));
498
498
  };
499
- return i.addEventListener("blur", n), i.addEventListener("keydown", (s) => {
500
- s.key === "Enter" && n(), s.key === "Escape" && e.cancel();
499
+ return i.addEventListener("blur", r), i.addEventListener("keydown", (s) => {
500
+ s.key === "Enter" && r(), s.key === "Escape" && e.cancel();
501
501
  }), i;
502
502
  };
503
503
  }
504
- function j(r) {
505
- switch (r.type) {
504
+ function K(o) {
505
+ switch (o.type) {
506
506
  case "number":
507
- return N(r);
507
+ return N(o);
508
508
  case "boolean":
509
509
  return $();
510
510
  case "date":
511
- return z(r);
511
+ return G(o);
512
512
  case "select":
513
- return G(r);
513
+ return z(o);
514
514
  default:
515
- return F(r);
515
+ return F(o);
516
516
  }
517
517
  }
518
- function W(r, e) {
518
+ function j(o, e) {
519
519
  if (e.editor) return e.editor;
520
520
  if (e.__editorTemplate) return "template";
521
521
  if (!e.type) return;
522
- const i = r.effectiveConfig?.typeDefaults;
522
+ const i = o.effectiveConfig?.typeDefaults;
523
523
  if (i?.[e.type]?.editor)
524
524
  return i[e.type].editor;
525
- const n = r.__frameworkAdapter;
526
- if (n?.getTypeDefault) {
527
- const s = n.getTypeDefault(e.type);
525
+ const r = o.__frameworkAdapter;
526
+ if (r?.getTypeDefault) {
527
+ const s = r.getTypeDefault(e.type);
528
528
  if (s?.editor)
529
529
  return s.editor;
530
530
  }
531
531
  }
532
- function S(r) {
533
- return !(typeof r != "string" || r === "__proto__" || r === "constructor" || r === "prototype");
532
+ function S(o) {
533
+ return !(typeof o != "string" || o === "__proto__" || o === "constructor" || o === "prototype");
534
534
  }
535
- function K(r) {
536
- const e = (r.__editingCellCount ?? 0) + 1;
537
- r.__editingCellCount = e, r.setAttribute("data-has-editing", "");
535
+ function W(o) {
536
+ const e = (o.__editingCellCount ?? 0) + 1;
537
+ o.__editingCellCount = e, o.setAttribute("data-has-editing", "");
538
538
  }
539
- function U(r) {
540
- r.__editingCellCount = 0, r.removeAttribute("data-has-editing");
539
+ function U(o) {
540
+ o.__editingCellCount = 0, o.removeAttribute("data-has-editing");
541
541
  }
542
- function _(r, e, t) {
543
- return r instanceof HTMLInputElement ? r.type === "checkbox" ? r.checked : r.type === "number" ? r.value === "" ? null : Number(r.value) : r.type === "date" ? typeof t == "string" ? r.value : r.valueAsDate : typeof t == "number" ? r.value === "" ? null : Number(r.value) : t == null && r.value === "" || typeof t == "string" && r.value === t.replace(/[\n\r]/g, "") ? t : r.value : e?.type === "number" && r.value !== "" || typeof t == "number" && r.value !== "" ? Number(r.value) : t == null && r.value === "" ? t : r.value;
542
+ function _(o, e, t) {
543
+ return o instanceof HTMLInputElement ? o.type === "checkbox" ? o.checked : o.type === "number" ? o.value === "" ? null : Number(o.value) : o.type === "date" ? typeof t == "string" ? o.value : o.valueAsDate : typeof t == "number" ? o.value === "" ? null : Number(o.value) : t == null && o.value === "" || typeof t == "string" && o.value === t.replace(/[\n\r]/g, "") ? t : o.value : e?.type === "number" && o.value !== "" || typeof t == "number" && o.value !== "" ? Number(o.value) : t == null && o.value === "" ? t : o.value;
544
544
  }
545
- function T(r) {
545
+ function T(o) {
546
546
  }
547
- function Q(r, e, t, i) {
548
- const n = r.querySelector("input,textarea,select");
549
- n && (n.addEventListener("blur", () => {
550
- t(_(n, e, i));
551
- }), n instanceof HTMLInputElement && n.type === "checkbox" ? n.addEventListener("change", () => t(n.checked)) : n instanceof HTMLSelectElement && n.addEventListener("change", () => t(_(n, e, i))));
547
+ function Q(o, e, t, i) {
548
+ const r = o.querySelector("input,textarea,select");
549
+ r && (r.addEventListener("blur", () => {
550
+ t(_(r, e, i));
551
+ }), r instanceof HTMLInputElement && r.type === "checkbox" ? r.addEventListener("change", () => t(r.checked)) : r instanceof HTMLSelectElement && r.addEventListener("change", () => t(_(r, e, i))));
552
552
  }
553
553
  class X extends O {
554
554
  /**
@@ -590,7 +590,7 @@ class X extends O {
590
590
  /** @internal */
591
591
  name = "editing";
592
592
  /** @internal */
593
- styles = x;
593
+ styles = B;
594
594
  /** @internal */
595
595
  get defaultConfig() {
596
596
  return {
@@ -608,11 +608,11 @@ class X extends O {
608
608
  /** Currently active edit row index, or -1 if not editing */
609
609
  #e = -1;
610
610
  /** Currently active edit column index, or -1 if not editing */
611
- #d = -1;
611
+ #u = -1;
612
612
  /** Snapshots of row data before editing started */
613
613
  #l = /* @__PURE__ */ new Map();
614
614
  /** Set of row IDs that have been modified (ID-based for stability) */
615
- #s = /* @__PURE__ */ new Set();
615
+ #r = /* @__PURE__ */ new Set();
616
616
  /** Set of cells currently in edit mode: "rowIndex:colIndex" */
617
617
  #o = /* @__PURE__ */ new Set();
618
618
  /**
@@ -622,9 +622,9 @@ class X extends O {
622
622
  */
623
623
  #c = /* @__PURE__ */ new Map();
624
624
  /** Flag to restore focus after next render (used when exiting edit mode) */
625
- #u = !1;
625
+ #f = !1;
626
626
  /** Row index pending animation after render, or -1 if none */
627
- #f = -1;
627
+ #h = -1;
628
628
  /**
629
629
  * Invalid cell tracking: Map<rowId, Map<field, message>>
630
630
  * Used for validation feedback without canceling edits.
@@ -636,13 +636,18 @@ class X extends O {
636
636
  * When false: arrow keys navigate between cells (navigation mode).
637
637
  * Escape switches to navigation mode, Enter switches to edit mode.
638
638
  */
639
- #r = !1;
639
+ #n = !1;
640
640
  /**
641
641
  * In grid mode, when true, prevents inputs from auto-focusing.
642
642
  * This is set when Escape is pressed (navigation mode) and cleared
643
643
  * when Enter is pressed or user explicitly clicks an input.
644
644
  */
645
645
  #a = !1;
646
+ /**
647
+ * When true, only a single cell is being edited (triggered by F2 or `beginCellEdit`).
648
+ * Tab and Arrow keys commit and close the editor instead of navigating to adjacent cells.
649
+ */
650
+ #d = !1;
646
651
  // #endregion
647
652
  // #region Lifecycle
648
653
  /** @internal */
@@ -655,77 +660,80 @@ class X extends O {
655
660
  }), Object.defineProperty(e, "changedRowIds", {
656
661
  get: () => this.changedRowIds,
657
662
  configurable: !0
658
- }), e.resetChangedRows = (n) => this.resetChangedRows(n), e.beginBulkEdit = (n, s) => {
659
- s && this.beginCellEdit(n, s);
663
+ }), e.resetChangedRows = (r) => this.resetChangedRows(r), e.beginBulkEdit = (r, s) => {
664
+ s && this.beginCellEdit(r, s);
660
665
  }, document.addEventListener(
661
666
  "keydown",
662
- (n) => {
663
- if (!this.#t && n.key === "Escape" && this.#e !== -1) {
664
- if (this.config.onBeforeEditClose && this.config.onBeforeEditClose(n) === !1)
667
+ (r) => {
668
+ if (!this.#t && r.key === "Escape" && this.#e !== -1) {
669
+ if (this.config.onBeforeEditClose && this.config.onBeforeEditClose(r) === !1)
665
670
  return;
666
- this.#n(this.#e, !0);
671
+ this.#s(this.#e, !0);
667
672
  }
668
673
  },
669
674
  { capture: !0, signal: t }
670
675
  ), document.addEventListener(
671
676
  "mousedown",
672
- (n) => {
677
+ (r) => {
673
678
  if (this.#t || this.#e === -1) return;
674
679
  const s = i.findRenderedRowElement?.(this.#e);
675
- !s || (n.composedPath && n.composedPath() || []).includes(s) || this.config.onBeforeEditClose && this.config.onBeforeEditClose(n) === !1 || queueMicrotask(() => {
676
- this.#e !== -1 && this.#n(this.#e, !1);
680
+ !s || (r.composedPath && r.composedPath() || []).includes(s) || this.config.onBeforeEditClose && this.config.onBeforeEditClose(r) === !1 || queueMicrotask(() => {
681
+ this.#e !== -1 && this.#s(this.#e, !1);
677
682
  });
678
683
  },
679
684
  { signal: t }
680
685
  ), this.gridElement.addEventListener(
681
686
  "cell-change",
682
- (n) => {
683
- const s = n.detail;
687
+ (r) => {
688
+ const s = r.detail;
684
689
  if (s.source === "user") return;
685
- const l = `${s.rowIndex}:${s.field}`, o = this.#c.get(l);
686
- o && o(s.newValue);
690
+ const n = `${s.rowIndex}:${s.field}`, l = this.#c.get(n);
691
+ l && l(s.newValue);
687
692
  },
688
693
  { signal: t }
689
- ), this.#t && (this.gridElement.classList.add("tbw-grid-mode"), this.requestRender(), this.gridElement.addEventListener(
694
+ ), this.#t && (i._isGridEditMode = !0, this.gridElement.classList.add("tbw-grid-mode"), this.requestRender(), this.gridElement.addEventListener(
690
695
  "focusin",
691
- (n) => {
692
- const s = n.target;
693
- if (s.matches(w)) {
696
+ (r) => {
697
+ const s = r.target;
698
+ if (s.matches(v)) {
694
699
  if (this.#a) {
695
700
  s.blur(), this.gridElement.focus();
696
701
  return;
697
702
  }
698
- this.#r = !0;
703
+ this.#n = !0;
699
704
  }
700
705
  },
701
706
  { signal: t }
702
707
  ), this.gridElement.addEventListener(
703
708
  "focusout",
704
- (n) => {
705
- const s = n.relatedTarget;
706
- (!s || !this.gridElement.contains(s) || !s.matches(w)) && (this.#r = !1);
709
+ (r) => {
710
+ const s = r.relatedTarget;
711
+ (!s || !this.gridElement.contains(s) || !s.matches(v)) && (this.#n = !1);
707
712
  },
708
713
  { signal: t }
709
714
  ), this.gridElement.addEventListener(
710
715
  "keydown",
711
- (n) => {
712
- if (n.key === "Escape" && this.#r) {
716
+ (r) => {
717
+ if (r.key === "Escape" && this.#n) {
718
+ if (this.config.onBeforeEditClose && this.config.onBeforeEditClose(r) === !1)
719
+ return;
713
720
  const s = document.activeElement;
714
- s && this.gridElement.contains(s) && (s.blur(), this.gridElement.focus()), this.#r = !1, this.#a = !0, n.preventDefault(), n.stopPropagation();
721
+ s && this.gridElement.contains(s) && (s.blur(), this.gridElement.focus()), this.#n = !1, this.#a = !0, r.preventDefault(), r.stopPropagation();
715
722
  }
716
723
  },
717
724
  { capture: !0, signal: t }
718
725
  ), this.gridElement.addEventListener(
719
726
  "mousedown",
720
- (n) => {
721
- n.target.matches(w) && (this.#a = !1);
727
+ (r) => {
728
+ r.target.matches(v) && (this.#a = !1);
722
729
  },
723
730
  { signal: t }
724
731
  ));
725
732
  }
726
733
  /** @internal */
727
734
  detach() {
728
- this.gridElement.classList.remove("tbw-grid-mode"), this.#e = -1, this.#d = -1, this.#l.clear(), this.#s.clear(), this.#o.clear(), this.#c.clear(), this.#r = !1, this.#a = !1, super.detach();
735
+ const e = this.gridElement;
736
+ e._isGridEditMode = !1, this.gridElement.classList.remove("tbw-grid-mode"), this.#e = -1, this.#u = -1, this.#l.clear(), this.#r.clear(), this.#o.clear(), this.#c.clear(), this.#n = !1, this.#a = !1, this.#d = !1, super.detach();
729
737
  }
730
738
  /**
731
739
  * Handle plugin queries.
@@ -747,10 +755,10 @@ class X extends O {
747
755
  if (this.#t) return !1;
748
756
  const t = this.grid, i = this.config.editOn ?? t.effectiveConfig?.editOn;
749
757
  if (i === !1 || i === "manual" || i !== "click" && i !== "dblclick") return !1;
750
- const n = e.originalEvent.type === "dblclick";
751
- if (i === "click" && n || i === "dblclick" && !n) return !1;
758
+ const r = e.originalEvent.type === "dblclick";
759
+ if (i === "click" && r || i === "dblclick" && !r) return !1;
752
760
  const { rowIndex: s } = e;
753
- return t._columns?.some((o) => o.editable) ? (e.originalEvent.stopPropagation(), this.beginBulkEdit(s), !0) : !1;
761
+ return t._columns?.some((l) => l.editable) ? (e.originalEvent.stopPropagation(), this.beginBulkEdit(s), !0) : !1;
754
762
  }
755
763
  /**
756
764
  * Handle keyboard events for edit lifecycle.
@@ -759,56 +767,61 @@ class X extends O {
759
767
  onKeyDown(e) {
760
768
  const t = this.grid;
761
769
  if (e.key === "Escape") {
762
- if (this.#t && this.#r) {
770
+ if (this.#t && this.#n) {
771
+ if (this.config.onBeforeEditClose && this.config.onBeforeEditClose(e) === !1)
772
+ return !0;
763
773
  const i = document.activeElement;
764
- return i && this.gridElement.contains(i) && i.blur(), this.#r = !1, this.requestAfterRender(), !0;
774
+ return i && this.gridElement.contains(i) && i.blur(), this.#n = !1, this.requestAfterRender(), !0;
765
775
  }
766
776
  if (this.#e !== -1 && !this.#t)
767
- return this.config.onBeforeEditClose && this.config.onBeforeEditClose(e) === !1 || this.#n(this.#e, !0), !0;
777
+ return this.config.onBeforeEditClose && this.config.onBeforeEditClose(e) === !1 || this.#s(this.#e, !0), !0;
768
778
  }
769
- if (this.#t && !this.#r && (e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "ArrowLeft" || e.key === "ArrowRight"))
779
+ if (this.#t && !this.#n && (e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "ArrowLeft" || e.key === "ArrowRight"))
770
780
  return !1;
781
+ if (this.#t && this.#n && (e.key === "ArrowUp" || e.key === "ArrowDown"))
782
+ return !0;
771
783
  if ((e.key === "ArrowUp" || e.key === "ArrowDown") && this.#e !== -1 && !this.#t) {
772
784
  if (this.config.onBeforeEditClose && this.config.onBeforeEditClose(e) === !1)
773
785
  return !0;
774
- const i = t._rows.length - 1, n = this.#e;
775
- return this.#n(n, !1), e.key === "ArrowDown" ? t._focusRow = Math.min(i, t._focusRow + 1) : t._focusRow = Math.max(0, t._focusRow - 1), e.preventDefault(), L(t), this.requestAfterRender(), !0;
786
+ const i = t._rows.length - 1, r = this.#e;
787
+ return this.#s(r, !1), e.key === "ArrowDown" ? t._focusRow = Math.min(i, t._focusRow + 1) : t._focusRow = Math.max(0, t._focusRow - 1), e.preventDefault(), L(t), this.requestAfterRender(), !0;
776
788
  }
777
789
  if (e.key === "Tab" && (this.#e !== -1 || this.#t)) {
778
- e.preventDefault();
790
+ if (e.preventDefault(), this.#d)
791
+ return this.#s(this.#e, !1), !0;
779
792
  const i = !e.shiftKey;
780
- return this.#y(i), !0;
793
+ return this.#C(i), !0;
781
794
  }
782
795
  if (e.key === " " || e.key === "Spacebar") {
783
796
  if (this.#e !== -1)
784
797
  return !1;
785
- const i = t._focusRow, n = t._focusCol;
786
- if (i >= 0 && n >= 0) {
787
- const s = t._visibleColumns[n], l = t._rows[i];
788
- if (s?.editable && s.type === "boolean" && l) {
789
- const o = s.field;
790
- if (S(o)) {
791
- const a = !l[o];
792
- return this.#m(i, s, a, l), e.preventDefault(), this.requestRender(), !0;
798
+ const i = t._focusRow, r = t._focusCol;
799
+ if (i >= 0 && r >= 0) {
800
+ const s = t._visibleColumns[r], n = t._rows[i];
801
+ if (s?.editable && s.type === "boolean" && n) {
802
+ const l = s.field;
803
+ if (S(l)) {
804
+ const a = !n[l];
805
+ return this.#E(i, s, a, n), e.preventDefault(), this.requestRender(), !0;
793
806
  }
794
807
  }
795
808
  }
796
809
  return !1;
797
810
  }
798
- if (e.key === "Enter" && !e.shiftKey) {
799
- if (this.#t && !this.#r)
800
- return this.#b(), !0;
811
+ if (e.key === "Enter" && !e.shiftKey && !e.ctrlKey && !e.altKey && !e.metaKey) {
812
+ if (this.#t && !this.#n)
813
+ return this.#y(), !0;
801
814
  if (this.#e !== -1)
802
815
  return !!(this.config.onBeforeEditClose && this.config.onBeforeEditClose(e) === !1);
803
816
  const i = this.config.editOn ?? t.effectiveConfig?.editOn;
804
817
  if (i === !1 || i === "manual") return !1;
805
- const n = t._focusRow, s = t._focusCol;
806
- if (n >= 0 && t._columns?.some((o) => o.editable)) {
807
- const o = t._visibleColumns[s], c = t._rows[n], a = o?.field ?? "", d = a && c ? c[a] : void 0, g = this.gridElement.querySelector(`[data-row="${n}"][data-col="${s}"]`), f = new CustomEvent("cell-activate", {
818
+ const r = t._focusRow, s = t._focusCol;
819
+ if (r >= 0 && t._columns?.some((l) => l.editable)) {
820
+ const l = t._visibleColumns[s], c = t._rows[r], a = l?.field ?? "", d = a && c ? c[a] : void 0, g = this.gridElement.querySelector(`[data-row="${r}"][data-col="${s}"]`), f = new CustomEvent("cell-activate", {
808
821
  cancelable: !0,
809
822
  bubbles: !0,
810
823
  detail: {
811
- rowIndex: n,
824
+ rowIndex: r,
812
825
  colIndex: s,
813
826
  field: a,
814
827
  value: d,
@@ -822,9 +835,19 @@ class X extends O {
822
835
  const E = new CustomEvent("activate-cell", {
823
836
  cancelable: !0,
824
837
  bubbles: !0,
825
- detail: { row: n, col: s }
838
+ detail: { row: r, col: s }
826
839
  });
827
- return this.gridElement.dispatchEvent(E), f.defaultPrevented || E.defaultPrevented ? (e.preventDefault(), !0) : (this.beginBulkEdit(n), !0);
840
+ return this.gridElement.dispatchEvent(E), f.defaultPrevented || E.defaultPrevented ? (e.preventDefault(), !0) : (this.beginBulkEdit(r), !0);
841
+ }
842
+ return !1;
843
+ }
844
+ if (e.key === "F2") {
845
+ if (this.#e !== -1 || this.#t || (this.config.editOn ?? t.effectiveConfig?.editOn) === !1) return !1;
846
+ const r = t._focusRow, s = t._focusCol;
847
+ if (r >= 0 && s >= 0) {
848
+ const n = t._visibleColumns[s];
849
+ if (n?.editable && n.field)
850
+ return e.preventDefault(), this.beginCellEdit(r, n.field), !0;
828
851
  }
829
852
  return !1;
830
853
  }
@@ -838,17 +861,17 @@ class X extends O {
838
861
  * @internal
839
862
  */
840
863
  processColumns(e) {
841
- const t = this.grid, i = t.effectiveConfig?.typeDefaults, n = t.__frameworkAdapter;
842
- return !i && !n?.getTypeDefault ? e : e.map((s) => {
864
+ const t = this.grid, i = t.effectiveConfig?.typeDefaults, r = t.__frameworkAdapter;
865
+ return !i && !r?.getTypeDefault ? e : e.map((s) => {
843
866
  if (!s.type) return s;
844
- let l;
845
- if (i?.[s.type]?.editorParams && (l = i[s.type].editorParams), !l && n?.getTypeDefault) {
846
- const o = n.getTypeDefault(s.type);
847
- o?.editorParams && (l = o.editorParams);
867
+ let n;
868
+ if (i?.[s.type]?.editorParams && (n = i[s.type].editorParams), !n && r?.getTypeDefault) {
869
+ const l = r.getTypeDefault(s.type);
870
+ l?.editorParams && (n = l.editorParams);
848
871
  }
849
- return l ? {
872
+ return n ? {
850
873
  ...s,
851
- editorParams: { ...l, ...s.editorParams }
874
+ editorParams: { ...n, ...s.editorParams }
852
875
  } : s;
853
876
  });
854
877
  }
@@ -860,18 +883,18 @@ class X extends O {
860
883
  */
861
884
  afterRender() {
862
885
  const e = this.grid;
863
- if (this.#u && (this.#u = !1, this.#v(e)), this.#f !== -1) {
864
- const t = this.#f;
865
- this.#f = -1, e.animateRow?.(t, "change");
886
+ if (this.#f && (this.#f = !1, this.#v(e)), this.#h !== -1) {
887
+ const t = this.#h;
888
+ this.#h = -1, e.animateRow?.(t, "change");
866
889
  }
867
890
  if (!this.#t && this.#o.size !== 0)
868
891
  for (const t of this.#o) {
869
- const [i, n] = t.split(":"), s = parseInt(i, 10), l = parseInt(n, 10), o = e.findRenderedRowElement?.(s);
870
- if (!o) continue;
871
- const c = o.querySelector(`.cell[data-col="${l}"]`);
892
+ const [i, r] = t.split(":"), s = parseInt(i, 10), n = parseInt(r, 10), l = e.findRenderedRowElement?.(s);
893
+ if (!l) continue;
894
+ const c = l.querySelector(`.cell[data-col="${n}"]`);
872
895
  if (!c || c.classList.contains("editing")) continue;
873
- const a = e._rows[s], d = e._visibleColumns[l];
874
- a && d && this.#p(a, s, d, l, c, !0);
896
+ const a = e._rows[s], d = e._visibleColumns[n];
897
+ a && d && this.#m(a, s, d, n, c, !0);
875
898
  }
876
899
  }
877
900
  /**
@@ -881,8 +904,8 @@ class X extends O {
881
904
  */
882
905
  afterCellRender(e) {
883
906
  if (!this.#t) return;
884
- const { row: t, rowIndex: i, column: n, colIndex: s, cellElement: l } = e;
885
- n.editable && (l.classList.contains("editing") || this.#p(t, i, n, s, l, !0));
907
+ const { row: t, rowIndex: i, column: r, colIndex: s, cellElement: n } = e;
908
+ r.editable && (n.classList.contains("editing") || this.#m(t, i, r, s, n, !0));
886
909
  }
887
910
  /**
888
911
  * On scroll render, reapply editors to recycled cells.
@@ -899,7 +922,7 @@ class X extends O {
899
922
  */
900
923
  get changedRows() {
901
924
  const e = [];
902
- for (const t of this.#s) {
925
+ for (const t of this.#r) {
903
926
  const i = this.grid.getRow(t);
904
927
  i && e.push(i);
905
928
  }
@@ -909,7 +932,7 @@ class X extends O {
909
932
  * Get IDs of all modified rows.
910
933
  */
911
934
  get changedRowIds() {
912
- return Array.from(this.#s);
935
+ return Array.from(this.#r);
913
936
  }
914
937
  /**
915
938
  * Get the currently active edit row index, or -1 if not editing.
@@ -921,7 +944,7 @@ class X extends O {
921
944
  * Get the currently active edit column index, or -1 if not editing.
922
945
  */
923
946
  get activeEditCol() {
924
- return this.#d;
947
+ return this.#u;
925
948
  }
926
949
  /**
927
950
  * Check if a specific row is currently being edited.
@@ -943,8 +966,8 @@ class X extends O {
943
966
  const t = this.grid, i = t._rows[e];
944
967
  if (!i) return !1;
945
968
  try {
946
- const n = t.getRowId?.(i);
947
- return n ? this.#s.has(n) : !1;
969
+ const r = t.getRowId?.(i);
970
+ return r ? this.#r.has(r) : !1;
948
971
  } catch {
949
972
  return !1;
950
973
  }
@@ -954,7 +977,7 @@ class X extends O {
954
977
  * @param rowId - Row ID to check
955
978
  */
956
979
  isRowChangedById(e) {
957
- return this.#s.has(e);
980
+ return this.#r.has(e);
958
981
  }
959
982
  // #region Cell Validation
960
983
  /**
@@ -979,8 +1002,8 @@ class X extends O {
979
1002
  * ```
980
1003
  */
981
1004
  setInvalid(e, t, i = "") {
982
- let n = this.#i.get(e);
983
- n || (n = /* @__PURE__ */ new Map(), this.#i.set(e, n)), n.set(t, i), this.#h(e, t, !0);
1005
+ let r = this.#i.get(e);
1006
+ r || (r = /* @__PURE__ */ new Map(), this.#i.set(e, r)), r.set(t, i), this.#g(e, t, !0);
984
1007
  }
985
1008
  /**
986
1009
  * Clear the invalid state for a specific cell.
@@ -990,7 +1013,7 @@ class X extends O {
990
1013
  */
991
1014
  clearInvalid(e, t) {
992
1015
  const i = this.#i.get(e);
993
- i && (i.delete(t), i.size === 0 && this.#i.delete(e)), this.#h(e, t, !1);
1016
+ i && (i.delete(t), i.size === 0 && this.#i.delete(e)), this.#g(e, t, !1);
994
1017
  }
995
1018
  /**
996
1019
  * Clear all invalid cells for a specific row.
@@ -1001,7 +1024,7 @@ class X extends O {
1001
1024
  const t = this.#i.get(e);
1002
1025
  if (t) {
1003
1026
  const i = Array.from(t.keys());
1004
- this.#i.delete(e), i.forEach((n) => this.#h(e, n, !1));
1027
+ this.#i.delete(e), i.forEach((r) => this.#g(e, r, !1));
1005
1028
  }
1006
1029
  }
1007
1030
  /**
@@ -1010,7 +1033,7 @@ class X extends O {
1010
1033
  clearAllInvalid() {
1011
1034
  const e = Array.from(this.#i.entries());
1012
1035
  this.#i.clear(), e.forEach(([t, i]) => {
1013
- i.forEach((n, s) => this.#h(t, s, !1));
1036
+ i.forEach((r, s) => this.#g(t, s, !1));
1014
1037
  });
1015
1038
  }
1016
1039
  /**
@@ -1055,18 +1078,18 @@ class X extends O {
1055
1078
  /**
1056
1079
  * Sync the data-invalid attribute on a cell element.
1057
1080
  */
1058
- #h(e, t, i) {
1059
- const n = this.grid, s = n._visibleColumns?.findIndex((d) => d.field === t);
1081
+ #g(e, t, i) {
1082
+ const r = this.grid, s = r._visibleColumns?.findIndex((d) => d.field === t);
1060
1083
  if (s === -1 || s === void 0) return;
1061
- const o = n._rows?.findIndex((d) => {
1084
+ const l = r._rows?.findIndex((d) => {
1062
1085
  try {
1063
- return n.getRowId?.(d) === e;
1086
+ return r.getRowId?.(d) === e;
1064
1087
  } catch {
1065
1088
  return !1;
1066
1089
  }
1067
1090
  });
1068
- if (o === -1 || o === void 0) return;
1069
- const a = n.findRenderedRowElement?.(o)?.querySelector(`.cell[data-col="${s}"]`);
1091
+ if (l === -1 || l === void 0) return;
1092
+ const a = r.findRenderedRowElement?.(l)?.querySelector(`.cell[data-col="${s}"]`);
1070
1093
  if (a)
1071
1094
  if (i) {
1072
1095
  a.setAttribute("data-invalid", "true");
@@ -1083,7 +1106,7 @@ class X extends O {
1083
1106
  */
1084
1107
  resetChangedRows(e) {
1085
1108
  const t = this.changedRows, i = this.changedRowIds;
1086
- this.#s.clear(), this.#g(), e || this.emit("changed-rows-reset", { rows: t, ids: i }), this.grid._rowPool?.forEach((s) => s.classList.remove("changed"));
1109
+ this.#r.clear(), this.#p(), e || this.emit("changed-rows-reset", { rows: t, ids: i }), this.grid._rowPool?.forEach((s) => s.classList.remove("changed"));
1087
1110
  }
1088
1111
  /**
1089
1112
  * Programmatically begin editing a cell.
@@ -1092,10 +1115,10 @@ class X extends O {
1092
1115
  * @fires cell-commit - Emitted when the cell value is committed (on blur or Enter)
1093
1116
  */
1094
1117
  beginCellEdit(e, t) {
1095
- const i = this.grid, n = i._visibleColumns.findIndex((c) => c.field === t);
1096
- if (n === -1 || !i._visibleColumns[n]?.editable) return;
1097
- const o = i.findRenderedRowElement?.(e)?.querySelector(`.cell[data-col="${n}"]`);
1098
- o && this.#w(e, n, o);
1118
+ const i = this.grid, r = i._visibleColumns.findIndex((c) => c.field === t);
1119
+ if (r === -1 || !i._visibleColumns[r]?.editable) return;
1120
+ const l = i.findRenderedRowElement?.(e)?.querySelector(`.cell[data-col="${r}"]`);
1121
+ l && (this.#d = !0, this.#b(e, r, l));
1099
1122
  }
1100
1123
  /**
1101
1124
  * Programmatically begin editing all editable cells in a row.
@@ -1105,20 +1128,21 @@ class X extends O {
1105
1128
  */
1106
1129
  beginBulkEdit(e) {
1107
1130
  const t = this.grid;
1108
- if ((this.config.editOn ?? t.effectiveConfig?.editOn) === !1 || !t._columns?.some((o) => o.editable)) return;
1131
+ if ((this.config.editOn ?? t.effectiveConfig?.editOn) === !1 || !t._columns?.some((l) => l.editable)) return;
1109
1132
  const s = t.findRenderedRowElement?.(e);
1110
1133
  if (!s) return;
1111
- const l = t._rows[e];
1112
- this.#E(e, l), Array.from(s.children).forEach((o, c) => {
1134
+ this.#d = !1;
1135
+ const n = t._rows[e];
1136
+ this.#w(e, n), Array.from(s.children).forEach((l, c) => {
1113
1137
  const a = t._visibleColumns[c];
1114
1138
  if (a?.editable) {
1115
- const d = o;
1116
- d.classList.contains("editing") || this.#p(l, e, a, c, d, !0);
1139
+ const d = l;
1140
+ d.classList.contains("editing") || this.#m(n, e, a, c, d, !0);
1117
1141
  }
1118
1142
  }), setTimeout(() => {
1119
- let o = s.querySelector(`.cell[data-col="${t._focusCol}"]`);
1120
- if (o?.classList.contains("editing") || (o = s.querySelector(".cell.editing")), o?.classList.contains("editing")) {
1121
- const c = o.querySelector(w);
1143
+ let l = s.querySelector(`.cell[data-col="${t._focusCol}"]`);
1144
+ if (l?.classList.contains("editing") || (l = s.querySelector(".cell.editing")), l?.classList.contains("editing")) {
1145
+ const c = l.querySelector(v);
1122
1146
  try {
1123
1147
  c?.focus({ preventScroll: !0 });
1124
1148
  } catch {
@@ -1131,34 +1155,34 @@ class X extends O {
1131
1155
  * @fires row-commit - Emitted after the row edit is committed
1132
1156
  */
1133
1157
  commitActiveRowEdit() {
1134
- this.#e !== -1 && this.#n(this.#e, !1);
1158
+ this.#e !== -1 && this.#s(this.#e, !1);
1135
1159
  }
1136
1160
  /**
1137
1161
  * Cancel the currently active row edit.
1138
1162
  */
1139
1163
  cancelActiveRowEdit() {
1140
- this.#e !== -1 && this.#n(this.#e, !0);
1164
+ this.#e !== -1 && this.#s(this.#e, !0);
1141
1165
  }
1142
1166
  // #endregion
1143
1167
  // #region Internal Methods
1144
1168
  /**
1145
1169
  * Begin editing a single cell.
1146
1170
  */
1147
- #w(e, t, i) {
1148
- const n = this.grid, s = n._rows[e], l = n._visibleColumns[t];
1149
- !s || !l?.editable || i.classList.contains("editing") || (this.#e !== e && this.#E(e, s), this.#d = t, this.#p(s, e, l, t, i, !1));
1171
+ #b(e, t, i) {
1172
+ const r = this.grid, s = r._rows[e], n = r._visibleColumns[t];
1173
+ !s || !n?.editable || i.classList.contains("editing") || (this.#e !== e && this.#w(e, s), this.#u = t, this.#m(s, e, n, t, i, !1));
1150
1174
  }
1151
1175
  /**
1152
1176
  * Focus the editor input in the currently focused cell (grid mode only).
1153
1177
  * Used when pressing Enter to enter edit mode from navigation mode.
1154
1178
  */
1155
- #b() {
1179
+ #y() {
1156
1180
  const e = this.grid, t = e._focusRow, i = e._focusCol;
1157
1181
  if (t < 0 || i < 0) return;
1158
1182
  const s = e.findRenderedRowElement?.(t)?.querySelector(`.cell[data-col="${i}"]`);
1159
1183
  if (s?.classList.contains("editing")) {
1160
- const l = s.querySelector(w);
1161
- l && (this.#a = !1, l.focus(), this.#r = !0, l instanceof HTMLInputElement && (l.type === "text" || l.type === "number") && l.select());
1184
+ const n = s.querySelector(v);
1185
+ n && (this.#a = !1, n.focus(), this.#n = !0, n instanceof HTMLInputElement && (n.type === "text" || n.type === "number") && n.select());
1162
1186
  }
1163
1187
  }
1164
1188
  /**
@@ -1166,43 +1190,43 @@ class X extends O {
1166
1190
  * Moves to next/previous editable cell, staying in edit mode.
1167
1191
  * Wraps to next/previous row when reaching row boundaries.
1168
1192
  */
1169
- #y(e) {
1170
- const t = this.grid, i = t._rows, n = this.#t ? t._focusRow : this.#e, s = t._visibleColumns.map((a, d) => a.editable ? d : -1).filter((a) => a >= 0);
1193
+ #C(e) {
1194
+ const t = this.grid, i = t._rows, r = this.#t ? t._focusRow : this.#e, s = t._visibleColumns.map((a, d) => a.editable ? d : -1).filter((a) => a >= 0);
1171
1195
  if (s.length === 0) return;
1172
- const o = s.indexOf(t._focusCol) + (e ? 1 : -1);
1173
- if (o >= 0 && o < s.length) {
1174
- t._focusCol = s[o];
1175
- const d = t.findRenderedRowElement?.(n)?.querySelector(`.cell[data-col="${s[o]}"]`);
1176
- d?.classList.contains("editing") && d.querySelector(w)?.focus({ preventScroll: !0 }), L(t, { forceHorizontalScroll: !0 });
1196
+ const l = s.indexOf(t._focusCol) + (e ? 1 : -1);
1197
+ if (l >= 0 && l < s.length) {
1198
+ t._focusCol = s[l];
1199
+ const d = t.findRenderedRowElement?.(r)?.querySelector(`.cell[data-col="${s[l]}"]`);
1200
+ d?.classList.contains("editing") && d.querySelector(v)?.focus({ preventScroll: !0 }), L(t, { forceHorizontalScroll: !0 });
1177
1201
  return;
1178
1202
  }
1179
- const c = n + (e ? 1 : -1);
1203
+ const c = r + (e ? 1 : -1);
1180
1204
  c >= 0 && c < i.length && (this.#t ? (t._focusRow = c, t._focusCol = e ? s[0] : s[s.length - 1], L(t, { forceHorizontalScroll: !0 }), this.requestAfterRender(), setTimeout(() => {
1181
1205
  const d = t.findRenderedRowElement?.(c)?.querySelector(`.cell[data-col="${t._focusCol}"]`);
1182
- d?.classList.contains("editing") && d.querySelector(w)?.focus({ preventScroll: !0 });
1183
- }, 0)) : (this.#n(n, !1), t._focusRow = c, t._focusCol = e ? s[0] : s[s.length - 1], this.beginBulkEdit(c), L(t, { forceHorizontalScroll: !0 })));
1206
+ d?.classList.contains("editing") && d.querySelector(v)?.focus({ preventScroll: !0 });
1207
+ }, 0)) : (this.#s(r, !1), t._focusRow = c, t._focusCol = e ? s[0] : s[s.length - 1], this.beginBulkEdit(c), L(t, { forceHorizontalScroll: !0 })));
1184
1208
  }
1185
1209
  /**
1186
1210
  * Sync the internal grid state with the plugin's editing state.
1187
1211
  */
1188
- #g() {
1212
+ #p() {
1189
1213
  const e = this.grid;
1190
1214
  e._activeEditRows = this.#e, e._rowEditSnapshots = this.#l;
1191
1215
  }
1192
1216
  /**
1193
1217
  * Snapshot original row data and mark as editing.
1194
1218
  */
1195
- #E(e, t) {
1196
- if (this.#e !== e && (this.#l.set(e, { ...t }), this.#e = e, this.#g(), !this.#t)) {
1219
+ #w(e, t) {
1220
+ if (this.#e !== e && (this.#l.set(e, { ...t }), this.#e = e, this.#p(), !this.#t)) {
1197
1221
  const i = this.grid;
1198
- let n = "";
1222
+ let r = "";
1199
1223
  try {
1200
- n = i.getRowId?.(t) ?? "";
1224
+ r = i.getRowId?.(t) ?? "";
1201
1225
  } catch {
1202
1226
  }
1203
1227
  this.emit("edit-open", {
1204
1228
  rowIndex: e,
1205
- rowId: n,
1229
+ rowId: r,
1206
1230
  row: t
1207
1231
  });
1208
1232
  }
@@ -1210,16 +1234,16 @@ class X extends O {
1210
1234
  /**
1211
1235
  * Exit editing for a row.
1212
1236
  */
1213
- #n(e, t) {
1237
+ #s(e, t) {
1214
1238
  if (this.#e !== e) return;
1215
- const i = this.grid, n = this.#l.get(e), s = i._rows[e], l = i.findRenderedRowElement?.(e);
1216
- let o;
1239
+ const i = this.grid, r = this.#l.get(e), s = i._rows[e], n = i.findRenderedRowElement?.(e);
1240
+ let l;
1217
1241
  if (s)
1218
1242
  try {
1219
- o = i.getRowId?.(s);
1243
+ l = i.getRowId?.(s);
1220
1244
  } catch {
1221
1245
  }
1222
- if (!t && l && s && l.querySelectorAll(".cell.editing").forEach((a) => {
1246
+ if (!t && n && s && n.querySelectorAll(".cell.editing").forEach((a) => {
1223
1247
  const d = Number(a.getAttribute("data-col"));
1224
1248
  if (isNaN(d)) return;
1225
1249
  const g = i._visibleColumns[d];
@@ -1228,37 +1252,37 @@ class X extends O {
1228
1252
  const f = a.querySelector("input,textarea,select");
1229
1253
  if (f) {
1230
1254
  const E = g.field, p = s[E], m = _(f, g, p);
1231
- p !== m && this.#m(e, g, m, s);
1255
+ p !== m && this.#E(e, g, m, s);
1232
1256
  }
1233
- }), t && n && s)
1234
- Object.keys(n).forEach((c) => {
1235
- s[c] = n[c];
1236
- }), o && (this.#s.delete(o), this.clearRowInvalid(o));
1257
+ }), t && r && s)
1258
+ Object.keys(r).forEach((c) => {
1259
+ s[c] = r[c];
1260
+ }), l && (this.#r.delete(l), this.clearRowInvalid(l));
1237
1261
  else if (!t && s) {
1238
- const c = this.#R(n, s), a = o ? this.#s.has(o) : c, d = this.emitCancelable("row-commit", {
1262
+ const c = this.#_(r, s), a = l ? this.#r.has(l) : c, d = this.emitCancelable("row-commit", {
1239
1263
  rowIndex: e,
1240
- rowId: o ?? "",
1264
+ rowId: l ?? "",
1241
1265
  row: s,
1242
- oldValue: n,
1266
+ oldValue: r,
1243
1267
  newValue: s,
1244
1268
  changed: a,
1245
1269
  changedRows: this.changedRows,
1246
1270
  changedRowIds: this.changedRowIds
1247
1271
  });
1248
- d && n ? (Object.keys(n).forEach((g) => {
1249
- s[g] = n[g];
1250
- }), o && (this.#s.delete(o), this.clearRowInvalid(o))) : !d && c && this.isAnimationEnabled && (this.#f = e);
1272
+ d && r ? (Object.keys(r).forEach((g) => {
1273
+ s[g] = r[g];
1274
+ }), l && (this.#r.delete(l), this.clearRowInvalid(l))) : !d && c && this.isAnimationEnabled && (this.#h = e);
1251
1275
  }
1252
- this.#l.delete(e), this.#e = -1, this.#d = -1, this.#g();
1276
+ this.#l.delete(e), this.#e = -1, this.#u = -1, this.#d = !1, this.#p();
1253
1277
  for (const c of this.#o)
1254
1278
  c.startsWith(`${e}:`) && this.#o.delete(c);
1255
1279
  for (const c of this.#c.keys())
1256
1280
  c.startsWith(`${e}:`) && this.#c.delete(c);
1257
- l && (l.querySelectorAll(".cell.editing").forEach((c) => {
1281
+ n && (n.querySelectorAll(".cell.editing").forEach((c) => {
1258
1282
  c.classList.remove("editing"), U(c.parentElement);
1259
- }), this.requestRender()), this.#u = !0, l || (this.#v(i), this.#u = !1), !this.#t && s && this.emit("edit-close", {
1283
+ }), this.requestRender()), this.#f = !0, n || (this.#v(i), this.#f = !1), !this.#t && s && this.emit("edit-close", {
1260
1284
  rowIndex: e,
1261
- rowId: o ?? "",
1285
+ rowId: l ?? "",
1262
1286
  row: s,
1263
1287
  reverted: t
1264
1288
  });
@@ -1267,28 +1291,28 @@ class X extends O {
1267
1291
  * Commit a single cell value change.
1268
1292
  * Uses ID-based change tracking for stability when rows are reordered.
1269
1293
  */
1270
- #m(e, t, i, n) {
1294
+ #E(e, t, i, r) {
1271
1295
  const s = t.field;
1272
1296
  if (!S(s)) return;
1273
- const l = n[s];
1274
- if (l === i) return;
1275
- const o = this.grid;
1297
+ const n = r[s];
1298
+ if (n === i) return;
1299
+ const l = this.grid;
1276
1300
  let c;
1277
1301
  try {
1278
- c = this.grid.getRowId(n);
1302
+ c = this.grid.getRowId(r);
1279
1303
  } catch {
1280
1304
  }
1281
- const a = c ? !this.#s.has(c) : !0, d = c ? (m) => this.grid.updateRow(c, m, "cascade") : T;
1305
+ const a = c ? !this.#r.has(c) : !0, d = c ? (m) => this.grid.updateRow(c, m, "cascade") : T;
1282
1306
  let g = !1;
1283
1307
  const f = c ? (m) => {
1284
1308
  g = !0, this.setInvalid(c, s, m ?? "");
1285
1309
  } : () => {
1286
1310
  };
1287
1311
  if (this.emitCancelable("cell-commit", {
1288
- row: n,
1312
+ row: r,
1289
1313
  rowId: c ?? "",
1290
1314
  field: s,
1291
- oldValue: l,
1315
+ oldValue: n,
1292
1316
  value: i,
1293
1317
  rowIndex: e,
1294
1318
  changedRows: this.changedRows,
@@ -1297,34 +1321,39 @@ class X extends O {
1297
1321
  updateRow: d,
1298
1322
  setInvalid: f
1299
1323
  })) return;
1300
- c && !g && this.isCellInvalid(c, s) && this.clearInvalid(c, s), n[s] = i, c && this.#s.add(c), this.#g(), this.emitPluginEvent("cell-edit-committed", {
1324
+ c && !g && this.isCellInvalid(c, s) && this.clearInvalid(c, s), r[s] = i, c && this.#r.add(c), this.#p(), this.emitPluginEvent("cell-edit-committed", {
1301
1325
  rowIndex: e,
1302
1326
  field: s,
1303
- oldValue: l,
1327
+ oldValue: n,
1304
1328
  newValue: i
1305
1329
  });
1306
- const p = o.findRenderedRowElement?.(e);
1330
+ const p = l.findRenderedRowElement?.(e);
1307
1331
  p && p.classList.add("changed");
1308
1332
  }
1309
1333
  /**
1310
1334
  * Inject an editor into a cell.
1311
1335
  */
1312
- #p(e, t, i, n, s, l) {
1336
+ #m(e, t, i, r, s, n) {
1313
1337
  if (!i.editable || s.classList.contains("editing")) return;
1314
- let o;
1338
+ let l;
1315
1339
  try {
1316
- o = this.grid.getRowId(e);
1340
+ l = this.grid.getRowId(e);
1317
1341
  } catch {
1318
1342
  }
1319
- const c = o ? (u) => this.grid.updateRow(o, u, "cascade") : T, a = S(i.field) ? e[i.field] : void 0;
1320
- s.classList.add("editing"), this.#o.add(`${t}:${n}`);
1343
+ const c = l ? (u) => this.grid.updateRow(l, u, "cascade") : T, a = S(i.field) ? e[i.field] : void 0;
1344
+ s.classList.add("editing"), this.#o.add(`${t}:${r}`);
1321
1345
  const d = s.parentElement;
1322
- d && K(d);
1346
+ d && W(d);
1323
1347
  let g = !1;
1324
1348
  const f = (u) => {
1325
- g || !this.#t && this.#e === -1 || this.#m(t, i, u, e);
1349
+ if (g || !this.#t && this.#e === -1) return;
1350
+ const h = this.grid._rows[t] ?? e;
1351
+ this.#E(t, i, u, h);
1326
1352
  }, E = () => {
1327
- g = !0, S(i.field) && (e[i.field] = a);
1353
+ if (g = !0, S(i.field)) {
1354
+ const u = this.grid._rows[t] ?? e;
1355
+ u[i.field] = a;
1356
+ }
1328
1357
  }, p = document.createElement("div");
1329
1358
  p.className = "tbw-editor-host", s.innerHTML = "", s.appendChild(p), p.addEventListener("keydown", (u) => {
1330
1359
  if (u.key === "Enter") {
@@ -1336,7 +1365,7 @@ class X extends O {
1336
1365
  }
1337
1366
  if (this.config.onBeforeEditClose && this.config.onBeforeEditClose(u) === !1)
1338
1367
  return;
1339
- u.stopPropagation(), u.preventDefault(), g = !0, this.#n(t, !1);
1368
+ u.stopPropagation(), u.preventDefault(), g = !0, this.#s(t, !1);
1340
1369
  }
1341
1370
  if (u.key === "Escape") {
1342
1371
  if (this.#t) {
@@ -1345,34 +1374,34 @@ class X extends O {
1345
1374
  }
1346
1375
  if (this.config.onBeforeEditClose && this.config.onBeforeEditClose(u) === !1)
1347
1376
  return;
1348
- u.stopPropagation(), u.preventDefault(), E(), this.#n(t, !0);
1377
+ u.stopPropagation(), u.preventDefault(), E(), this.#s(t, !0);
1349
1378
  }
1350
1379
  });
1351
- const m = i, y = m.__editorTemplate, v = W(this.grid, m) ?? j(i), k = a, q = `${t}:${i.field}`, A = [];
1380
+ const m = i, y = m.__editorTemplate, w = j(this.grid, m) ?? K(i), k = a, q = `${t}:${i.field}`, A = [];
1352
1381
  this.#c.set(q, (u) => {
1353
1382
  for (const h of A) h(u);
1354
1383
  });
1355
1384
  const C = (u) => {
1356
1385
  A.push(u);
1357
1386
  };
1358
- if (v === "template" && y)
1359
- this.#C(p, m, e, a, f, E, l, t), C((u) => {
1387
+ if (w === "template" && y)
1388
+ this.#R(p, m, e, a, f, E, n, t), C((u) => {
1360
1389
  const h = p.querySelector(
1361
1390
  "input,textarea,select"
1362
1391
  );
1363
1392
  h && (h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked = !!u : h.value = String(u ?? ""));
1364
1393
  });
1365
- else if (typeof v == "string") {
1366
- const u = document.createElement(v);
1394
+ else if (typeof w == "string") {
1395
+ const u = document.createElement(w);
1367
1396
  u.value = k, u.addEventListener("change", () => f(u.value)), C((h) => {
1368
1397
  u.value = h;
1369
- }), p.appendChild(u), l || queueMicrotask(() => {
1370
- p.querySelector(w)?.focus({ preventScroll: !0 });
1398
+ }), p.appendChild(u), n || queueMicrotask(() => {
1399
+ p.querySelector(v)?.focus({ preventScroll: !0 });
1371
1400
  });
1372
- } else if (typeof v == "function") {
1401
+ } else if (typeof w == "function") {
1373
1402
  const u = {
1374
1403
  row: e,
1375
- rowId: o ?? "",
1404
+ rowId: l ?? "",
1376
1405
  value: k,
1377
1406
  field: i.field,
1378
1407
  column: i,
@@ -1380,7 +1409,7 @@ class X extends O {
1380
1409
  cancel: E,
1381
1410
  updateRow: c,
1382
1411
  onValueChange: C
1383
- }, h = v(u);
1412
+ }, h = w(u);
1384
1413
  typeof h == "string" ? (p.innerHTML = h, Q(p, i, f, a), C((R) => {
1385
1414
  const b = p.querySelector(
1386
1415
  "input,textarea,select"
@@ -1388,15 +1417,15 @@ class X extends O {
1388
1417
  b && (b instanceof HTMLInputElement && b.type === "checkbox" ? b.checked = !!R : b.value = String(R ?? ""));
1389
1418
  })) : h instanceof Node && (p.appendChild(h), h instanceof HTMLInputElement || h instanceof HTMLSelectElement || h instanceof HTMLTextAreaElement ? C((b) => {
1390
1419
  h instanceof HTMLInputElement && h.type === "checkbox" ? h.checked = !!b : h.value = String(b ?? "");
1391
- }) : s.setAttribute("data-editor-managed", "")), l || queueMicrotask(() => {
1392
- p.querySelector(w)?.focus({ preventScroll: !0 });
1420
+ }) : s.setAttribute("data-editor-managed", "")), n || queueMicrotask(() => {
1421
+ p.querySelector(v)?.focus({ preventScroll: !0 });
1393
1422
  });
1394
- } else if (v && typeof v == "object") {
1423
+ } else if (w && typeof w == "object") {
1395
1424
  const u = document.createElement("div");
1396
1425
  u.setAttribute("data-external-editor", ""), u.setAttribute("data-field", i.field), p.appendChild(u), s.setAttribute("data-editor-managed", "");
1397
1426
  const h = {
1398
1427
  row: e,
1399
- rowId: o ?? "",
1428
+ rowId: l ?? "",
1400
1429
  value: k,
1401
1430
  field: i.field,
1402
1431
  column: i,
@@ -1405,34 +1434,34 @@ class X extends O {
1405
1434
  updateRow: c,
1406
1435
  onValueChange: C
1407
1436
  };
1408
- if (v.mount)
1437
+ if (w.mount)
1409
1438
  try {
1410
- v.mount({ placeholder: u, context: h, spec: v });
1439
+ w.mount({ placeholder: u, context: h, spec: w });
1411
1440
  } catch (R) {
1412
1441
  console.warn(`[tbw-grid] External editor mount error for column '${i.field}':`, R);
1413
1442
  }
1414
1443
  else
1415
1444
  this.grid.dispatchEvent(
1416
- new CustomEvent("mount-external-editor", { detail: { placeholder: u, spec: v, context: h } })
1445
+ new CustomEvent("mount-external-editor", { detail: { placeholder: u, spec: w, context: h } })
1417
1446
  );
1418
1447
  }
1419
1448
  }
1420
1449
  /**
1421
1450
  * Render a template-based editor.
1422
1451
  */
1423
- #C(e, t, i, n, s, l, o, c) {
1452
+ #R(e, t, i, r, s, n, l, c) {
1424
1453
  const a = t.__editorTemplate;
1425
1454
  if (!a) return;
1426
1455
  const d = a.cloneNode(!0), g = t.__compiledEditor;
1427
1456
  g ? d.innerHTML = g({
1428
1457
  row: i,
1429
- value: n,
1458
+ value: r,
1430
1459
  field: t.field,
1431
1460
  column: t,
1432
1461
  commit: s,
1433
- cancel: l
1462
+ cancel: n
1434
1463
  }) : d.querySelectorAll("*").forEach((E) => {
1435
- E.childNodes.length === 1 && E.firstChild?.nodeType === Node.TEXT_NODE && (E.textContent = E.textContent?.replace(/{{\s*value\s*}}/g, n == null ? "" : String(n)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (p, m) => {
1464
+ E.childNodes.length === 1 && E.firstChild?.nodeType === Node.TEXT_NODE && (E.textContent = E.textContent?.replace(/{{\s*value\s*}}/g, r == null ? "" : String(r)).replace(/{{\s*row\.([a-zA-Z0-9_]+)\s*}}/g, (p, m) => {
1436
1465
  if (!S(m)) return "";
1437
1466
  const y = i[m];
1438
1467
  return y == null ? "" : String(y);
@@ -1442,23 +1471,23 @@ class X extends O {
1442
1471
  "input,textarea,select"
1443
1472
  );
1444
1473
  if (f) {
1445
- f instanceof HTMLInputElement && f.type === "checkbox" ? f.checked = !!n : f.value = String(n ?? "");
1474
+ f instanceof HTMLInputElement && f.type === "checkbox" ? f.checked = !!r : f.value = String(r ?? "");
1446
1475
  let E = !1;
1447
1476
  f.addEventListener("blur", () => {
1448
- E || s(_(f, t, n));
1477
+ E || s(_(f, t, r));
1449
1478
  }), f.addEventListener("keydown", (p) => {
1450
1479
  const m = p;
1451
1480
  if (m.key === "Enter") {
1452
1481
  if (this.config.onBeforeEditClose && this.config.onBeforeEditClose(m) === !1)
1453
1482
  return;
1454
- m.stopPropagation(), m.preventDefault(), E = !0, s(_(f, t, n)), this.#n(c, !1);
1483
+ m.stopPropagation(), m.preventDefault(), E = !0, s(_(f, t, r)), this.#s(c, !1);
1455
1484
  }
1456
1485
  if (m.key === "Escape") {
1457
1486
  if (this.config.onBeforeEditClose && this.config.onBeforeEditClose(m) === !1)
1458
1487
  return;
1459
- m.stopPropagation(), m.preventDefault(), l(), this.#n(c, !0);
1488
+ m.stopPropagation(), m.preventDefault(), n(), this.#s(c, !0);
1460
1489
  }
1461
- }), f instanceof HTMLInputElement && f.type === "checkbox" && f.addEventListener("change", () => s(f.checked)), o || setTimeout(() => f.focus({ preventScroll: !0 }), 0);
1490
+ }), f instanceof HTMLInputElement && f.type === "checkbox" && f.addEventListener("change", () => s(f.checked)), l || setTimeout(() => f.focus({ preventScroll: !0 }), 0);
1462
1491
  }
1463
1492
  e.appendChild(d);
1464
1493
  }
@@ -1466,11 +1495,11 @@ class X extends O {
1466
1495
  * Compare snapshot vs current row to detect if any values changed during this edit session.
1467
1496
  * Uses shallow comparison of all properties.
1468
1497
  */
1469
- #R(e, t) {
1498
+ #_(e, t) {
1470
1499
  if (!e) return !1;
1471
- const i = e, n = t, s = /* @__PURE__ */ new Set([...Object.keys(i), ...Object.keys(n)]);
1472
- for (const l of s)
1473
- if (i[l] !== n[l])
1500
+ const i = e, r = t, s = /* @__PURE__ */ new Set([...Object.keys(i), ...Object.keys(r)]);
1501
+ for (const n of s)
1502
+ if (i[n] !== r[n])
1474
1503
  return !0;
1475
1504
  return !1;
1476
1505
  }
@@ -1480,12 +1509,12 @@ class X extends O {
1480
1509
  #v(e) {
1481
1510
  queueMicrotask(() => {
1482
1511
  try {
1483
- const t = e._focusRow, i = e._focusCol, n = e.findRenderedRowElement?.(t);
1484
- if (n) {
1512
+ const t = e._focusRow, i = e._focusCol, r = e.findRenderedRowElement?.(t);
1513
+ if (r) {
1485
1514
  Array.from(e._bodyEl.querySelectorAll(".cell-focus")).forEach(
1486
- (l) => l.classList.remove("cell-focus")
1515
+ (n) => n.classList.remove("cell-focus")
1487
1516
  );
1488
- const s = n.querySelector(`.cell[data-row="${t}"][data-col="${i}"]`);
1517
+ const s = r.querySelector(`.cell[data-row="${t}"][data-col="${i}"]`);
1489
1518
  s && (s.classList.add("cell-focus"), s.setAttribute("aria-selected", "true"), s.hasAttribute("tabindex") || s.setAttribute("tabindex", "-1"), s.focus({ preventScroll: !0 }));
1490
1519
  }
1491
1520
  } catch {
@@ -1496,6 +1525,6 @@ class X extends O {
1496
1525
  }
1497
1526
  export {
1498
1527
  X as EditingPlugin,
1499
- j as defaultEditorFor
1528
+ K as defaultEditorFor
1500
1529
  };
1501
1530
  //# sourceMappingURL=index.js.map