@ishibashi0112/spreadsheet-grid-core 1.1.0 → 1.2.1

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 (146) hide show
  1. package/dist/controllers/activeRowFollowController.cjs +1 -0
  2. package/dist/controllers/activeRowFollowController.d.ts +18 -0
  3. package/dist/controllers/activeRowFollowController.js +68 -0
  4. package/dist/controllers/autoHeightMeasurer.cjs +1 -1
  5. package/dist/controllers/autoHeightMeasurer.js +17 -17
  6. package/dist/controllers/clipboardController.cjs +1 -1
  7. package/dist/controllers/clipboardController.d.ts +2 -0
  8. package/dist/controllers/clipboardController.js +74 -64
  9. package/dist/controllers/columnAutosizeRunner.cjs +1 -1
  10. package/dist/controllers/columnAutosizeRunner.js +10 -10
  11. package/dist/controllers/contextMenuController.cjs +1 -1
  12. package/dist/controllers/contextMenuController.d.ts +1 -0
  13. package/dist/controllers/contextMenuController.js +12 -7
  14. package/dist/controllers/detailRowController.cjs +1 -0
  15. package/dist/controllers/detailRowController.d.ts +41 -0
  16. package/dist/controllers/detailRowController.js +96 -0
  17. package/dist/controllers/editController.cjs +1 -1
  18. package/dist/controllers/editController.d.ts +1 -0
  19. package/dist/controllers/editController.js +106 -99
  20. package/dist/controllers/fillHandleController.cjs +1 -1
  21. package/dist/controllers/fillHandleController.js +78 -78
  22. package/dist/controllers/filterPopoverController.cjs +1 -1
  23. package/dist/controllers/filterPopoverController.js +6 -6
  24. package/dist/controllers/findController.cjs +1 -1
  25. package/dist/controllers/findController.d.ts +1 -0
  26. package/dist/controllers/findController.js +16 -15
  27. package/dist/controllers/imeInputController.cjs +1 -1
  28. package/dist/controllers/imeInputController.js +65 -54
  29. package/dist/controllers/keyboardController.cjs +1 -1
  30. package/dist/controllers/keyboardController.d.ts +1 -0
  31. package/dist/controllers/keyboardController.js +113 -111
  32. package/dist/controllers/liveUiState.cjs +1 -0
  33. package/dist/controllers/liveUiState.d.ts +7 -0
  34. package/dist/controllers/liveUiState.js +4 -0
  35. package/dist/controllers/pointerInteractionsController.cjs +1 -1
  36. package/dist/controllers/pointerInteractionsController.d.ts +1 -0
  37. package/dist/controllers/pointerInteractionsController.js +157 -156
  38. package/dist/controllers/rowDragController.cjs +1 -1
  39. package/dist/controllers/rowDragController.d.ts +1 -0
  40. package/dist/controllers/rowDragController.js +117 -104
  41. package/dist/controllers/scrollSyncController.cjs +1 -1
  42. package/dist/controllers/scrollSyncController.js +45 -43
  43. package/dist/controllers/serverSideRowModel.cjs +1 -1
  44. package/dist/controllers/serverSideRowModel.js +19 -19
  45. package/dist/controllers/viewportSyncController.cjs +1 -1
  46. package/dist/controllers/viewportSyncController.d.ts +1 -0
  47. package/dist/controllers/viewportSyncController.js +1 -1
  48. package/dist/engine/cellCommands.cjs +1 -0
  49. package/dist/engine/cellCommands.d.ts +27 -0
  50. package/dist/engine/cellCommands.js +89 -0
  51. package/dist/engine/columnCommands.cjs +1 -1
  52. package/dist/engine/columnCommands.js +113 -113
  53. package/dist/engine/createGridEngine.cjs +3 -3
  54. package/dist/engine/createGridEngine.d.ts +2 -0
  55. package/dist/engine/createGridEngine.js +72 -70
  56. package/dist/engine/exportCommands.cjs +1 -1
  57. package/dist/engine/exportCommands.js +4 -2
  58. package/dist/engine/fullFeatures.cjs +1 -1
  59. package/dist/engine/fullFeatures.js +6 -6
  60. package/dist/engine/gridApi.cjs +6 -6
  61. package/dist/engine/gridApi.d.ts +4 -0
  62. package/dist/engine/gridApi.js +208 -192
  63. package/dist/engine/notifiers.cjs +1 -1
  64. package/dist/engine/notifiers.d.ts +4 -0
  65. package/dist/engine/notifiers.js +7 -7
  66. package/dist/index.cjs +1 -1
  67. package/dist/index.d.ts +1 -1
  68. package/dist/index.js +4 -4
  69. package/dist/locales/en.cjs +1 -1
  70. package/dist/locales/en.js +2 -0
  71. package/dist/logic/cellPlacement.cjs +1 -0
  72. package/dist/logic/cellPlacement.d.ts +22 -0
  73. package/dist/logic/cellPlacement.js +44 -0
  74. package/dist/logic/density.cjs +1 -0
  75. package/dist/logic/density.d.ts +5 -0
  76. package/dist/logic/density.js +17 -0
  77. package/dist/logic/detailRow.cjs +1 -1
  78. package/dist/logic/detailRow.d.ts +4 -0
  79. package/dist/logic/detailRow.js +10 -7
  80. package/dist/logic/domGuards.cjs +1 -1
  81. package/dist/logic/domGuards.d.ts +5 -0
  82. package/dist/logic/domGuards.js +8 -2
  83. package/dist/logic/editorKeys.cjs +1 -0
  84. package/dist/logic/editorKeys.d.ts +30 -0
  85. package/dist/logic/editorKeys.js +34 -0
  86. package/dist/logic/editorStart.cjs +1 -0
  87. package/dist/logic/editorStart.d.ts +7 -0
  88. package/dist/logic/editorStart.js +23 -0
  89. package/dist/logic/exportCsv.cjs +2 -2
  90. package/dist/logic/exportCsv.d.ts +2 -1
  91. package/dist/logic/exportCsv.js +13 -13
  92. package/dist/logic/exportData.cjs +1 -1
  93. package/dist/logic/exportData.d.ts +2 -1
  94. package/dist/logic/exportData.js +18 -18
  95. package/dist/logic/geometry.cjs +1 -1
  96. package/dist/logic/geometry.d.ts +2 -0
  97. package/dist/logic/geometry.js +41 -20
  98. package/dist/logic/gridBarSummary.cjs +1 -0
  99. package/dist/logic/gridBarSummary.d.ts +27 -0
  100. package/dist/logic/gridBarSummary.js +137 -0
  101. package/dist/logic/gridState.cjs +1 -1
  102. package/dist/logic/gridState.d.ts +3 -2
  103. package/dist/logic/gridState.js +32 -23
  104. package/dist/logic/grouping.cjs +1 -1
  105. package/dist/logic/grouping.js +1 -1
  106. package/dist/logic/imeInput.cjs +1 -1
  107. package/dist/logic/imeInput.js +6 -4
  108. package/dist/logic/localeTextFeatures.cjs +1 -1
  109. package/dist/logic/localeTextFeatures.d.ts +4 -0
  110. package/dist/logic/localeTextFeatures.js +8 -5
  111. package/dist/logic/pasteFill.cjs +1 -0
  112. package/dist/logic/pasteFill.d.ts +2 -0
  113. package/dist/logic/pasteFill.js +25 -0
  114. package/dist/logic/selectEditorState.cjs +1 -1
  115. package/dist/logic/selectEditorState.d.ts +28 -2
  116. package/dist/logic/selectEditorState.js +29 -14
  117. package/dist/logic/selectionAggregates.cjs +1 -1
  118. package/dist/logic/selectionAggregates.js +2 -3
  119. package/dist/logic/validation.cjs +1 -1
  120. package/dist/logic/validation.d.ts +1 -1
  121. package/dist/logic/validation.js +21 -21
  122. package/dist/model/gridActions.cjs +1 -1
  123. package/dist/model/gridActions.d.ts +13 -0
  124. package/dist/model/gridActions.js +11 -0
  125. package/dist/model/gridReducer.cjs +1 -1
  126. package/dist/model/gridReducer.js +128 -65
  127. package/dist/model/gridTypes.core.d.ts +172 -26
  128. package/dist/utils/editorVisibleBounds.cjs +1 -0
  129. package/dist/utils/editorVisibleBounds.d.ts +10 -0
  130. package/dist/utils/editorVisibleBounds.js +40 -0
  131. package/dist/utils/errorBubblePlacement.cjs +1 -0
  132. package/dist/utils/errorBubblePlacement.d.ts +8 -0
  133. package/dist/utils/errorBubblePlacement.js +26 -0
  134. package/dist/utils/gridVisibleBand.cjs +1 -0
  135. package/dist/utils/gridVisibleBand.d.ts +4 -0
  136. package/dist/utils/gridVisibleBand.js +24 -0
  137. package/dist/utils/multilineEditor.cjs +2 -0
  138. package/dist/utils/multilineEditor.d.ts +7 -0
  139. package/dist/utils/multilineEditor.js +22 -0
  140. package/dist/utils/scrollBottom.cjs +1 -0
  141. package/dist/utils/scrollBottom.d.ts +1 -0
  142. package/dist/utils/scrollBottom.js +4 -0
  143. package/dist/utils/topAlignedInput.cjs +1 -0
  144. package/dist/utils/topAlignedInput.d.ts +3 -0
  145. package/dist/utils/topAlignedInput.js +23 -0
  146. package/package.json +1 -1
@@ -1,7 +1,10 @@
1
1
  import { isInsideDetailCardOf as e } from "../logic/detailRow.js";
2
2
  import { isImeComposingKeyEvent as t } from "../logic/domGuards.js";
3
+ import { resolveElementScale as n } from "../logic/elementScale.js";
4
+ import { resolveGridVisibleBand as r } from "../utils/gridVisibleBand.js";
5
+ import { alignInputTextToTop as i } from "../utils/topAlignedInput.js";
3
6
  //#region src/controllers/imeInputController.ts
4
- var n = "ssg-ime-input--composing", r = (t, n, r) => {
7
+ var a = 24, o = "ssg-ime-input--composing", s = (t, n, r) => {
5
8
  let i = t.querySelectorAll(`.ssg-body-row[data-row-index="${n.row}"]`);
6
9
  for (let n of Array.from(i)) {
7
10
  if (e(t, n)) continue;
@@ -9,93 +12,101 @@ var n = "ssg-ime-input--composing", r = (t, n, r) => {
9
12
  for (let e of Array.from(i)) if (e.getAttribute("data-ssg-col-key") === r) return e;
10
13
  }
11
14
  return null;
12
- }, i = (e, t) => e === t || e !== null && t !== null && e.row === t.row && e.col === t.col, a = () => {
13
- let e = null, a = null, o = null, s = null, c = !1, l = null, u = !1, d = !1, f = !1, p = null, m = () => e?.gridRootRef.current ?? null, h = () => {
14
- a && a.ownerDocument.activeElement !== a && a.focus({ preventScroll: !0 });
15
- }, g = (t, n) => {
16
- let i = m(), o = e?.resolveCell(t) ?? null;
17
- if (!a || !i || !o) return !1;
18
- let s = r(i, t, o.colKey);
19
- if (!s) return !1;
20
- let c = i.getBoundingClientRect(), l = s.getBoundingClientRect();
21
- return a.style.left = `${l.left - c.left - i.clientLeft}px`, a.style.top = `${l.top - c.top - i.clientTop}px`, a.style.width = `${l.width}px`, a.style.height = `${l.height}px`, a.style.textAlign = n && o.align ? o.align : "", !0;
22
- }, _ = () => {
23
- a && (a.classList.remove(n), a.value = "", a.style.textAlign = "");
24
- }, v = (t) => {
25
- e === null || !e.enabled || e.editing || d || t.target === o && h();
26
- }, y = () => {
15
+ }, c = (e, t) => e === t || e !== null && t !== null && e.row === t.row && e.col === t.col, l = () => {
16
+ let e = null, l = null, u = null, d = null, f = !1, p = null, m = !1, h = !1, g = !1, _ = null, v = () => e?.gridRootRef.current ?? null, y = () => {
17
+ l && l.ownerDocument.activeElement !== l && l.focus({ preventScroll: !0 });
18
+ }, b = (t, o) => {
19
+ let c = v(), u = e?.resolveCell(t) ?? null;
20
+ if (!l || !c || !u) return !1;
21
+ let d = s(c, t, u.colKey);
22
+ if (!d) return !1;
23
+ let f = c.getBoundingClientRect(), p = d.getBoundingClientRect(), m = n(c, f), h = p.top, g = p.bottom;
24
+ if (o) {
25
+ let e = r(d);
26
+ if (e !== null) {
27
+ let t = Math.max(h, e.top), n = Math.min(g, e.bottom);
28
+ n - t >= a * m.y && (h = t, g = n);
29
+ }
30
+ }
31
+ let _ = (g - h) / m.y;
32
+ return l.style.left = `${(p.left - f.left) / m.x - c.clientLeft}px`, l.style.top = `${(h - f.top) / m.y - c.clientTop}px`, l.style.width = `${p.width / m.x}px`, l.style.height = `${_}px`, l.style.textAlign = o && u.align ? u.align : "", i(l, o && d.classList.contains("ssg-body-cell--valign-top"), _), !0;
33
+ }, x = () => {
34
+ l && (l.classList.remove(o), l.value = "", l.style.textAlign = "", i(l, !1, 0));
35
+ }, S = (t) => {
36
+ e === null || !e.enabled || e.editing || h || t.target === u && y();
37
+ }, C = () => {
27
38
  if (e === null || !e.enabled || e.editing || e.activeCell === null) {
28
- l = null;
39
+ p = null;
29
40
  return;
30
41
  }
31
- let t = e.activeCell, r = e.canStartEdit(t);
32
- l = {
42
+ let t = e.activeCell, n = e.canStartEdit(t);
43
+ p = {
33
44
  cell: t,
34
- allowed: r
35
- }, f = !1, r && (g(t, !0), p = t, a?.classList.add(n));
36
- }, b = (t) => {
37
- let n = l;
38
- l = null;
39
- let r = f;
40
- if (f = !1, !a || n === null || !n.allowed || r) {
41
- _();
45
+ allowed: n
46
+ }, g = !1, n && (l?.classList.add(o), b(t, !0), _ = t);
47
+ }, w = (t) => {
48
+ let n = p;
49
+ p = null;
50
+ let r = g;
51
+ if (g = !1, !l || n === null || !n.allowed || r) {
52
+ x();
42
53
  return;
43
54
  }
44
- let i = a.value || t.data || "";
55
+ let i = l.value || t.data || "";
45
56
  queueMicrotask(() => {
46
- let t = a;
57
+ let t = l;
47
58
  if (e === null || !e.enabled || !t || i === "" || t.ownerDocument.activeElement !== t || !e.canStartEdit(n.cell)) {
48
- _();
59
+ x();
49
60
  return;
50
61
  }
51
62
  let r = e.resolveEditText ? e.resolveEditText(n.cell, i) : i;
52
63
  if (r === null || r === "") {
53
- _();
64
+ x();
54
65
  return;
55
66
  }
56
- u = !0, e.startEdit(n.cell, r), requestAnimationFrame(() => {
57
- u && e !== null && !e.editing && (u = !1, _());
67
+ m = !0, e.startEdit(n.cell, r), requestAnimationFrame(() => {
68
+ m && e !== null && !e.editing && (m = !1, x());
58
69
  });
59
70
  });
60
- }, x = () => {
61
- l === null && !u && a && (a.value = "");
62
- }, S = (e) => {
63
- if (e.target !== a || e.key !== "Tab" || e.defaultPrevented || t(e) || document.activeElement !== a) return;
64
- let n = m();
71
+ }, T = () => {
72
+ p === null && !m && l && (l.value = "");
73
+ }, E = (e) => {
74
+ if (e.target !== l || e.key !== "Tab" || e.defaultPrevented || t(e) || document.activeElement !== l) return;
75
+ let n = v();
65
76
  if (n) {
66
- d = !0;
77
+ h = !0;
67
78
  try {
68
79
  n.focus({ preventScroll: !0 });
69
80
  } finally {
70
- d = !1;
81
+ h = !1;
71
82
  }
72
83
  }
73
- }, C = () => {
74
- l !== null && (f = !0);
75
- }, w = (e) => {
76
- o !== e && (o?.removeEventListener("focus", v), o = e, o?.addEventListener("focus", v));
77
- }, T = (e) => {
78
- typeof document > "u" || c === e || (c = e, e ? (document.addEventListener("keydown", S), document.addEventListener("pointerdown", C, !0)) : (document.removeEventListener("keydown", S), document.removeEventListener("pointerdown", C, !0)));
79
- }, E = (e) => {
80
- s !== e && (s && (s.removeEventListener("compositionstart", y), s.removeEventListener("compositionend", b), s.removeEventListener("input", x)), s = e, s && (s.addEventListener("compositionstart", y), s.addEventListener("compositionend", b), s.addEventListener("input", x)));
84
+ }, D = () => {
85
+ p !== null && (g = !0);
86
+ }, O = (e) => {
87
+ u !== e && (u?.removeEventListener("focus", S), u = e, u?.addEventListener("focus", S));
88
+ }, k = (e) => {
89
+ typeof document > "u" || f === e || (f = e, e ? (document.addEventListener("keydown", E), document.addEventListener("pointerdown", D, !0)) : (document.removeEventListener("keydown", E), document.removeEventListener("pointerdown", D, !0)));
90
+ }, A = (e) => {
91
+ d !== e && (d && (d.removeEventListener("compositionstart", C), d.removeEventListener("compositionend", w), d.removeEventListener("input", T)), d = e, d && (d.addEventListener("compositionstart", C), d.addEventListener("compositionend", w), d.addEventListener("input", T)));
81
92
  };
82
93
  return {
83
94
  update: (t) => {
84
95
  e = t;
85
96
  let n = t.gridRootRef.current;
86
- if (w(t.enabled ? n : null), E(t.enabled ? a : null), T(t.enabled), !t.enabled) {
87
- l = null, u = !1, _(), a && n && a.ownerDocument.activeElement === a && n.focus({ preventScroll: !0 });
97
+ if (O(t.enabled ? n : null), A(t.enabled ? l : null), k(t.enabled), !t.enabled) {
98
+ p = null, m = !1, x(), l && n && l.ownerDocument.activeElement === l && n.focus({ preventScroll: !0 });
88
99
  return;
89
100
  }
90
- u && t.editing && (u = !1, _()), !(l !== null || u) && (t.activeCell !== null && !i(p, t.activeCell) && g(t.activeCell, !1) && (p = t.activeCell), !t.editing && n && n.ownerDocument.activeElement === n && h());
101
+ m && t.editing && (m = !1, x()), !(p !== null || m) && (t.activeCell !== null && !c(_, t.activeCell) && b(t.activeCell, !1) && (_ = t.activeCell), !t.editing && n && n.ownerDocument.activeElement === n && y());
91
102
  },
92
103
  attach: (t) => {
93
- a !== t && (a = t, E(e?.enabled ? a : null), a && (typeof matchMedia == "function" && matchMedia("(pointer: coarse)").matches && (a.inputMode = "none"), p = null));
104
+ l !== t && (l = t, A(e?.enabled ? l : null), l && (typeof matchMedia == "function" && matchMedia("(pointer: coarse)").matches && (l.inputMode = "none"), _ = null));
94
105
  },
95
106
  dispose: () => {
96
- E(null), w(null), T(!1), l = null, u = !1, e = null;
107
+ A(null), O(null), k(!1), p = null, m = !1, e = null;
97
108
  }
98
109
  };
99
110
  };
100
111
  //#endregion
101
- export { n as IME_INPUT_COMPOSING_CLASS, a as createImeInputController };
112
+ export { o as IME_INPUT_COMPOSING_CLASS, l as createImeInputController };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/permissions.cjs"),t=require("../logic/detailRow.cjs"),n=require("../model/gridActions.cjs"),r=require("../logic/geometry.cjs"),i=require("../logic/domGuards.cjs"),a=require("./escapeClaimController.cjs");var o=10,s=(e,t,n,r)=>{if(!e.getLabelRow)return t;let i=e.getRowCount(),a=t;for(;a>=0&&a<i&&e.getLabelRow(a);)a+=n;return a>=0&&a<i?a:r},c=e=>s(e,0,1,0),l=e=>t.resolveFirstDataColIndex(e),u=(e,t)=>({row:c(e),col:l(t)}),d=()=>{let t=null,d=e=>{t=e},f=(e,t)=>s(e,t,-1,s(e,t,1,t)),p=e=>{let t=e.getRowCount()-1;return s(e,t,-1,t)},m=(e,r,i)=>{if(t===null)return;let{uiState:a,dispatch:o}=t;if(i){let t=a.selection?.type===`cell`?a.selection.range.start:e;o(n.gridActions.startSelection(t)),o(n.gridActions.updateSelection(r)),o(n.gridActions.endSelection()),o(n.gridActions.activateCell(r));return}o(n.gridActions.startSelection(r)),o(n.gridActions.endSelection()),o(n.gridActions.activateCell(r))},h=()=>{if(t===null||t.uiState.activeCell)return!1;let{rowModel:e,visibleColumns:n}=t;if(e.getRowCount()===0||n.length===0)return!0;let r=u(e,n);return m(r,r,!1),!0},g=e=>{let n=t?.uiState;return e&&n?.selection?.type===`cell`?n.selection.range.end:n?.activeCell??{row:0,col:0}},_=(e,n,i)=>{if(t===null)return;let{rowModel:a,visibleColumns:o}=t,c=a.getRowCount();if(c===0||o.length===0||h())return;let l=g(i),u=r.clamp(l.row+e,0,c-1);u=e===0?f(a,u):s(a,u,e>0?1:-1,l.row);let d={row:u,col:r.clamp(l.col+n,0,o.length-1)};m(l,d,i)},v=(e,n)=>{if(t===null)return;let{uiState:i,rowModel:a,visibleColumns:o}=t;if(a.getRowCount()===0||o.length===0)return;let s=i.activeCell?g(n):{row:c(a),col:l(o)},u=e(s,a,o);m(s,{row:f(a,r.clamp(u.row,0,a.getRowCount()-1)),col:r.clamp(u.col,0,o.length-1)},n&&i.activeCell!==null)},y=(e,n,i)=>{let a=n.getRowCount(),c=t?.resolvePageRow?t.resolvePageRow(e.row,i):e.row+i*o,l=r.clamp(i>0?Math.max(c,e.row+1):Math.min(c,e.row-1),0,a-1),u=s(n,l,i,-1);return u>=0?u:s(n,l,i>0?-1:1,e.row)};return{update:d,handleKeyDown:async r=>{if(t===null)return;let{uiState:o,rowModel:s,visibleColumns:u,readOnly:d,canEditCell:f,setEditorInitialValue:m,dispatch:g,handleCopy:b,openFind:x,handleCellDoubleClick:S,isWholeGridSelected:C,selectEntireGrid:w,onUndo:T,onRedo:E,onClearSelection:D,enableClearOnDelete:O,onToggleCheckboxCell:k,onToggleGroup:A,onToggleDetailRow:j}=t;if(i.shouldIgnoreGridKeydown(r.target)||o.editingCell||r.isComposing&&i.isImeInputTarget(r.target))return;if((r.ctrlKey||r.metaKey)&&r.key.toLowerCase()===`c`){r.preventDefault(),await b();return}if((r.ctrlKey||r.metaKey)&&r.key.toLowerCase()===`f`&&x){r.preventDefault(),x();return}if((r.ctrlKey||r.metaKey)&&r.key.toLowerCase()===`a`){if(r.preventDefault(),C){g(n.gridActions.clearSelection()),g(n.gridActions.activateCell(null));return}w();return}if((r.ctrlKey||r.metaKey)&&!r.isComposing){if(r.key.toLowerCase()===`z`){r.preventDefault(),r.shiftKey?E():T();return}if(r.key.toLowerCase()===`y`&&!r.shiftKey){r.preventDefault(),E();return}}let M=r.ctrlKey||r.metaKey;if((r.key===`ContextMenu`||r.key===`F10`&&r.shiftKey)&&!M&&!r.altKey&&o.activeCell&&t.openContextMenu?.(o.activeCell)){r.preventDefault();return}if(r.key===`ArrowDown`&&r.altKey&&!M&&!r.shiftKey&&o.activeCell&&t.openColumnMenu?.(o.activeCell.col)){r.preventDefault();return}if(M&&!r.altKey&&(r.key===`ArrowUp`||r.key===`ArrowDown`)){r.preventDefault();let e=r.key===`ArrowDown`;v((t,n)=>({row:e?p(n):c(n),col:t.col}),r.shiftKey);return}if(M&&!r.altKey&&(r.key===`ArrowLeft`||r.key===`ArrowRight`)){r.preventDefault();let e=r.key===`ArrowRight`;v((t,n,r)=>({row:t.row,col:e?r.length-1:l(r)}),r.shiftKey);return}if((r.key===`Home`||r.key===`End`)&&!r.altKey){r.preventDefault();let e=r.key===`End`;v((t,n,r)=>({row:M?e?p(n):c(n):t.row,col:e?r.length-1:l(r)}),r.shiftKey);return}if((r.key===`PageDown`||r.key===`PageUp`)&&!M&&!r.altKey){if(r.preventDefault(),h())return;let e=r.key===`PageDown`?1:-1;v((t,n)=>({row:y(t,n,e),col:t.col}),r.shiftKey);return}if(r.key===`ArrowUp`){r.preventDefault(),_(-1,0,r.shiftKey);return}if(r.key===`ArrowDown`){r.preventDefault(),_(1,0,r.shiftKey);return}if(r.key===`ArrowLeft`){r.preventDefault(),_(0,-1,r.shiftKey);return}if(r.key===`ArrowRight`){r.preventDefault(),_(0,1,r.shiftKey);return}if(r.key===`Tab`){if(!o.activeCell&&!r.shiftKey){if(t.rowModel.getRowCount()===0||t.visibleColumns.length===0)return;r.preventDefault(),h();return}let e=o.activeCell?.col??0;if(r.shiftKey?e<=l(t.visibleColumns):e>=t.visibleColumns.length-1){!r.shiftKey&&o.activeCell&&t.onTabPastLastColumn?.(o.activeCell.row)&&r.preventDefault();return}r.preventDefault(),_(0,r.shiftKey?-1:1,!1);return}if(r.key===`Escape`){a.isClearableSelection(o.selection)&&r.preventDefault(),g(n.gridActions.clearSelection());return}if((r.key===`Delete`||r.key===`Backspace`)&&O){r.preventDefault(),D();return}if((r.key===`Enter`||r.key===` `)&&o.activeCell){let e=s.getGroupRow?.(o.activeCell.row);if(e){r.preventDefault(),A(e.groupKey);return}if(j&&u[o.activeCell.col]?.key===`__ssg_detail_toggle__`&&j(o.activeCell)){r.preventDefault();return}}if(r.key===`Enter`||r.key===`F2`){if(r.preventDefault(),o.activeCell){S(o.activeCell);return}r.key===`Enter`&&h();return}if(r.key===` `&&!r.ctrlKey&&!r.metaKey&&!r.altKey&&r.preventDefault(),i.isPrintableKey(r)&&o.activeCell){let t=s.getRow(o.activeCell.row),i=u[o.activeCell.col];if(!t||!i||!e.isViewCellEditable({readOnly:d,canEditCell:f},s,o.activeCell.row,o.activeCell.col,t,i))return;if(i.editor?.type===`checkbox`){r.preventDefault(),r.key===` `&&k(o.activeCell);return}r.preventDefault(),m(r.key),g(n.gridActions.startEdit(o.activeCell))}}}};exports.createKeyboardController=d,exports.resolveFirstDataCell=u;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../logic/detailRow.cjs"),r=require("../logic/geometry.cjs"),i=require("../logic/domGuards.cjs"),a=require("./liveUiState.cjs"),o=require("./clipboardController.cjs"),s=require("./escapeClaimController.cjs");var c=10,l=(e,t,n,r)=>{if(!e.getLabelRow)return t;let i=e.getRowCount(),a=t;for(;a>=0&&a<i&&e.getLabelRow(a);)a+=n;return a>=0&&a<i?a:r},u=e=>l(e,0,1,0),d=e=>n.resolveFirstDataColIndex(e),f=(e,t)=>({row:u(e),col:d(t)}),p=()=>{let n=null,p=e=>{n=e},m=(e,t)=>l(e,t,-1,l(e,t,1,t)),h=e=>{let t=e.getRowCount()-1;return l(e,t,-1,t)},g=(t,r,i)=>{if(n===null)return;let{dispatch:o}=n,s=a.readLiveUiState(n);if(i){let n=s.selection?.type===`cell`?s.selection.range.start:t;o(e.gridActions.startSelection(n)),o(e.gridActions.updateSelection(r)),o(e.gridActions.endSelection()),o(e.gridActions.activateCell(r));return}o(e.gridActions.startSelection(r)),o(e.gridActions.endSelection()),o(e.gridActions.activateCell(r))},_=()=>{if(n===null||a.readLiveUiState(n).activeCell)return!1;let{rowModel:e,visibleColumns:t}=n;if(e.getRowCount()===0||t.length===0)return!0;let r=f(e,t);return g(r,r,!1),!0},v=e=>{let t=n===null?void 0:a.readLiveUiState(n);return e&&t?.selection?.type===`cell`?t.selection.range.end:t?.activeCell??{row:0,col:0}},y=(e,t,i)=>{if(n===null)return;let{rowModel:a,visibleColumns:o}=n,s=a.getRowCount();if(s===0||o.length===0||_())return;let c=v(i),u=r.clamp(c.row+e,0,s-1);u=e===0?m(a,u):l(a,u,e>0?1:-1,c.row);let d={row:u,col:r.clamp(c.col+t,0,o.length-1)};g(c,d,i)},b=(e,t)=>{if(n===null)return;let{rowModel:i,visibleColumns:o}=n,s=a.readLiveUiState(n);if(i.getRowCount()===0||o.length===0)return;let c=s.activeCell?v(t):{row:u(i),col:d(o)},l=e(c,i,o);g(c,{row:m(i,r.clamp(l.row,0,i.getRowCount()-1)),col:r.clamp(l.col,0,o.length-1)},t&&s.activeCell!==null)},x=(e,t,i)=>{let a=t.getRowCount(),o=n?.resolvePageRow?n.resolvePageRow(e.row,i):e.row+i*c,s=r.clamp(i>0?Math.max(o,e.row+1):Math.min(o,e.row-1),0,a-1),u=l(t,s,i,-1);return u>=0?u:l(t,s,i>0?-1:1,e.row)};return{update:p,handleKeyDown:async r=>{if(n===null)return;let{rowModel:c,visibleColumns:l,readOnly:f,canEditCell:p,setEditorInitialValue:m,dispatch:g,handleCopy:v,openFind:S,handleCellDoubleClick:C,selectEntireGrid:w,onUndo:T,onRedo:E,onClearSelection:D,enableClearOnDelete:O,onToggleCheckboxCell:k,onToggleGroup:A,onToggleDetailRow:j}=n,M=a.readLiveUiState(n),N=n.getUiState?o.computeIsWholeGridSelected(M.selection,c.getRowCount(),l.length):n.isWholeGridSelected;if(i.shouldIgnoreGridKeydown(r.target)||a.isEditingAtEvent(n)||r.isComposing&&i.isImeInputTarget(r.target))return;if((r.ctrlKey||r.metaKey)&&r.key.toLowerCase()===`c`){r.preventDefault(),await v();return}if((r.ctrlKey||r.metaKey)&&r.key.toLowerCase()===`f`&&S){r.preventDefault(),S();return}if((r.ctrlKey||r.metaKey)&&r.key.toLowerCase()===`a`){if(r.preventDefault(),N){g(e.gridActions.clearSelection()),g(e.gridActions.activateCell(null));return}w();return}if((r.ctrlKey||r.metaKey)&&!r.isComposing){if(r.key.toLowerCase()===`z`){r.preventDefault(),r.shiftKey?E():T();return}if(r.key.toLowerCase()===`y`&&!r.shiftKey){r.preventDefault(),E();return}}let P=r.ctrlKey||r.metaKey;if((r.key===`ContextMenu`||r.key===`F10`&&r.shiftKey)&&!P&&!r.altKey&&M.activeCell&&n.openContextMenu?.(M.activeCell)){r.preventDefault();return}if(r.key===`ArrowDown`&&r.altKey&&!P&&!r.shiftKey&&M.activeCell&&n.openColumnMenu?.(M.activeCell.col)){r.preventDefault();return}if(P&&!r.altKey&&(r.key===`ArrowUp`||r.key===`ArrowDown`)){r.preventDefault();let e=r.key===`ArrowDown`;b((t,n)=>({row:e?h(n):u(n),col:t.col}),r.shiftKey);return}if(P&&!r.altKey&&(r.key===`ArrowLeft`||r.key===`ArrowRight`)){r.preventDefault();let e=r.key===`ArrowRight`;b((t,n,r)=>({row:t.row,col:e?r.length-1:d(r)}),r.shiftKey);return}if((r.key===`Home`||r.key===`End`)&&!r.altKey){r.preventDefault();let e=r.key===`End`;b((t,n,r)=>({row:P?e?h(n):u(n):t.row,col:e?r.length-1:d(r)}),r.shiftKey);return}if((r.key===`PageDown`||r.key===`PageUp`)&&!P&&!r.altKey){if(r.preventDefault(),_())return;let e=r.key===`PageDown`?1:-1;b((t,n)=>({row:x(t,n,e),col:t.col}),r.shiftKey);return}if(r.key===`ArrowUp`){r.preventDefault(),y(-1,0,r.shiftKey);return}if(r.key===`ArrowDown`){r.preventDefault(),y(1,0,r.shiftKey);return}if(r.key===`ArrowLeft`){r.preventDefault(),y(0,-1,r.shiftKey);return}if(r.key===`ArrowRight`){r.preventDefault(),y(0,1,r.shiftKey);return}if(r.key===`Tab`){if(!M.activeCell&&!r.shiftKey){if(n.rowModel.getRowCount()===0||n.visibleColumns.length===0)return;r.preventDefault(),_();return}let e=M.activeCell?.col??0;if(r.shiftKey?e<=d(n.visibleColumns):e>=n.visibleColumns.length-1){!r.shiftKey&&M.activeCell&&n.onTabPastLastColumn?.(M.activeCell.row)&&r.preventDefault();return}r.preventDefault(),y(0,r.shiftKey?-1:1,!1);return}if(r.key===`Escape`){s.isClearableSelection(M.selection)&&r.preventDefault(),g(e.gridActions.clearSelection());return}if((r.key===`Delete`||r.key===`Backspace`)&&O){r.preventDefault(),D();return}if((r.key===`Enter`||r.key===` `)&&M.activeCell){let e=c.getGroupRow?.(M.activeCell.row);if(e){r.preventDefault(),A(e.groupKey);return}if(j&&l[M.activeCell.col]?.key===`__ssg_detail_toggle__`&&j(M.activeCell)){r.preventDefault();return}}if(r.key===`Enter`||r.key===`F2`){if(r.preventDefault(),M.activeCell){C(M.activeCell);return}r.key===`Enter`&&_();return}if(r.key===` `&&!r.ctrlKey&&!r.metaKey&&!r.altKey&&r.preventDefault(),i.isPrintableKey(r)&&M.activeCell){let n=c.getRow(M.activeCell.row),i=l[M.activeCell.col];if(!n||!i||!t.isViewCellEditable({readOnly:f,canEditCell:p},c,M.activeCell.row,M.activeCell.col,n,i))return;if(i.editor?.type===`checkbox`){r.preventDefault(),r.key===` `&&k(M.activeCell);return}r.preventDefault(),m(r.key),g(e.gridActions.startEdit(M.activeCell))}}}};exports.createKeyboardController=p,exports.resolveFirstDataCell=f;
@@ -12,6 +12,7 @@ export type GridKeyboardEventLike = {
12
12
  };
13
13
  export type KeyboardControllerArgs<T> = {
14
14
  uiState: GridUiState;
15
+ getUiState?: (() => GridUiState) | undefined;
15
16
  rowModel: RowModel<T>;
16
17
  visibleColumns: GridColumn<T>[];
17
18
  readOnly: boolean;
@@ -1,220 +1,222 @@
1
- import { isViewCellEditable as e } from "../utils/permissions.js";
2
- import { resolveFirstDataColIndex as t } from "../logic/detailRow.js";
3
- import { gridActions as n } from "../model/gridActions.js";
1
+ import { gridActions as e } from "../model/gridActions.js";
2
+ import { isViewCellEditable as t } from "../utils/permissions.js";
3
+ import { resolveFirstDataColIndex as n } from "../logic/detailRow.js";
4
4
  import { clamp as r } from "../logic/geometry.js";
5
5
  import { isImeInputTarget as i, isPrintableKey as a, shouldIgnoreGridKeydown as o } from "../logic/domGuards.js";
6
- import { isClearableSelection as s } from "./escapeClaimController.js";
6
+ import { isEditingAtEvent as s, readLiveUiState as c } from "./liveUiState.js";
7
+ import { computeIsWholeGridSelected as l } from "./clipboardController.js";
8
+ import { isClearableSelection as u } from "./escapeClaimController.js";
7
9
  //#region src/controllers/keyboardController.ts
8
- var c = 10, l = (e, t, n, r) => {
10
+ var d = 10, f = (e, t, n, r) => {
9
11
  if (!e.getLabelRow) return t;
10
12
  let i = e.getRowCount(), a = t;
11
13
  for (; a >= 0 && a < i && e.getLabelRow(a);) a += n;
12
14
  return a >= 0 && a < i ? a : r;
13
- }, u = (e) => l(e, 0, 1, 0), d = (e) => t(e), f = (e, t) => ({
14
- row: u(e),
15
- col: d(t)
16
- }), p = () => {
17
- let t = null, p = (e) => {
18
- t = e;
19
- }, m = (e, t) => l(e, t, -1, l(e, t, 1, t)), h = (e) => {
15
+ }, p = (e) => f(e, 0, 1, 0), m = (e) => n(e), h = (e, t) => ({
16
+ row: p(e),
17
+ col: m(t)
18
+ }), g = () => {
19
+ let n = null, g = (e) => {
20
+ n = e;
21
+ }, _ = (e, t) => f(e, t, -1, f(e, t, 1, t)), v = (e) => {
20
22
  let t = e.getRowCount() - 1;
21
- return l(e, t, -1, t);
22
- }, g = (e, r, i) => {
23
- if (t === null) return;
24
- let { uiState: a, dispatch: o } = t;
23
+ return f(e, t, -1, t);
24
+ }, y = (t, r, i) => {
25
+ if (n === null) return;
26
+ let { dispatch: a } = n, o = c(n);
25
27
  if (i) {
26
- let t = a.selection?.type === "cell" ? a.selection.range.start : e;
27
- o(n.startSelection(t)), o(n.updateSelection(r)), o(n.endSelection()), o(n.activateCell(r));
28
+ let n = o.selection?.type === "cell" ? o.selection.range.start : t;
29
+ a(e.startSelection(n)), a(e.updateSelection(r)), a(e.endSelection()), a(e.activateCell(r));
28
30
  return;
29
31
  }
30
- o(n.startSelection(r)), o(n.endSelection()), o(n.activateCell(r));
31
- }, _ = () => {
32
- if (t === null || t.uiState.activeCell) return !1;
33
- let { rowModel: e, visibleColumns: n } = t;
34
- if (e.getRowCount() === 0 || n.length === 0) return !0;
35
- let r = f(e, n);
36
- return g(r, r, !1), !0;
37
- }, v = (e) => {
38
- let n = t?.uiState;
39
- return e && n?.selection?.type === "cell" ? n.selection.range.end : n?.activeCell ?? {
32
+ a(e.startSelection(r)), a(e.endSelection()), a(e.activateCell(r));
33
+ }, b = () => {
34
+ if (n === null || c(n).activeCell) return !1;
35
+ let { rowModel: e, visibleColumns: t } = n;
36
+ if (e.getRowCount() === 0 || t.length === 0) return !0;
37
+ let r = h(e, t);
38
+ return y(r, r, !1), !0;
39
+ }, x = (e) => {
40
+ let t = n === null ? void 0 : c(n);
41
+ return e && t?.selection?.type === "cell" ? t.selection.range.end : t?.activeCell ?? {
40
42
  row: 0,
41
43
  col: 0
42
44
  };
43
- }, y = (e, n, i) => {
44
- if (t === null) return;
45
- let { rowModel: a, visibleColumns: o } = t, s = a.getRowCount();
46
- if (s === 0 || o.length === 0 || _()) return;
47
- let c = v(i), u = r(c.row + e, 0, s - 1);
48
- u = e === 0 ? m(a, u) : l(a, u, e > 0 ? 1 : -1, c.row);
49
- let d = {
50
- row: u,
51
- col: r(c.col + n, 0, o.length - 1)
45
+ }, S = (e, t, i) => {
46
+ if (n === null) return;
47
+ let { rowModel: a, visibleColumns: o } = n, s = a.getRowCount();
48
+ if (s === 0 || o.length === 0 || b()) return;
49
+ let c = x(i), l = r(c.row + e, 0, s - 1);
50
+ l = e === 0 ? _(a, l) : f(a, l, e > 0 ? 1 : -1, c.row);
51
+ let u = {
52
+ row: l,
53
+ col: r(c.col + t, 0, o.length - 1)
52
54
  };
53
- g(c, d, i);
54
- }, b = (e, n) => {
55
- if (t === null) return;
56
- let { uiState: i, rowModel: a, visibleColumns: o } = t;
57
- if (a.getRowCount() === 0 || o.length === 0) return;
58
- let s = i.activeCell ? v(n) : {
59
- row: u(a),
60
- col: d(o)
61
- }, c = e(s, a, o);
62
- g(s, {
63
- row: m(a, r(c.row, 0, a.getRowCount() - 1)),
64
- col: r(c.col, 0, o.length - 1)
65
- }, n && i.activeCell !== null);
66
- }, x = (e, n, i) => {
67
- let a = n.getRowCount(), o = t?.resolvePageRow ? t.resolvePageRow(e.row, i) : e.row + i * c, s = r(i > 0 ? Math.max(o, e.row + 1) : Math.min(o, e.row - 1), 0, a - 1), u = l(n, s, i, -1);
68
- return u >= 0 ? u : l(n, s, i > 0 ? -1 : 1, e.row);
55
+ y(c, u, i);
56
+ }, C = (e, t) => {
57
+ if (n === null) return;
58
+ let { rowModel: i, visibleColumns: a } = n, o = c(n);
59
+ if (i.getRowCount() === 0 || a.length === 0) return;
60
+ let s = o.activeCell ? x(t) : {
61
+ row: p(i),
62
+ col: m(a)
63
+ }, l = e(s, i, a);
64
+ y(s, {
65
+ row: _(i, r(l.row, 0, i.getRowCount() - 1)),
66
+ col: r(l.col, 0, a.length - 1)
67
+ }, t && o.activeCell !== null);
68
+ }, w = (e, t, i) => {
69
+ let a = t.getRowCount(), o = n?.resolvePageRow ? n.resolvePageRow(e.row, i) : e.row + i * d, s = r(i > 0 ? Math.max(o, e.row + 1) : Math.min(o, e.row - 1), 0, a - 1), c = f(t, s, i, -1);
70
+ return c >= 0 ? c : f(t, s, i > 0 ? -1 : 1, e.row);
69
71
  };
70
72
  return {
71
- update: p,
73
+ update: g,
72
74
  handleKeyDown: async (r) => {
73
- if (t === null) return;
74
- let { uiState: c, rowModel: l, visibleColumns: f, readOnly: p, canEditCell: m, setEditorInitialValue: g, dispatch: v, handleCopy: S, openFind: C, handleCellDoubleClick: w, isWholeGridSelected: T, selectEntireGrid: E, onUndo: D, onRedo: O, onClearSelection: k, enableClearOnDelete: A, onToggleCheckboxCell: j, onToggleGroup: M, onToggleDetailRow: N } = t;
75
- if (o(r.target) || c.editingCell || r.isComposing && i(r.target)) return;
75
+ if (n === null) return;
76
+ let { rowModel: d, visibleColumns: f, readOnly: h, canEditCell: g, setEditorInitialValue: _, dispatch: y, handleCopy: x, openFind: T, handleCellDoubleClick: E, selectEntireGrid: D, onUndo: O, onRedo: k, onClearSelection: A, enableClearOnDelete: j, onToggleCheckboxCell: M, onToggleGroup: N, onToggleDetailRow: P } = n, F = c(n), I = n.getUiState ? l(F.selection, d.getRowCount(), f.length) : n.isWholeGridSelected;
77
+ if (o(r.target) || s(n) || r.isComposing && i(r.target)) return;
76
78
  if ((r.ctrlKey || r.metaKey) && r.key.toLowerCase() === "c") {
77
- r.preventDefault(), await S();
79
+ r.preventDefault(), await x();
78
80
  return;
79
81
  }
80
- if ((r.ctrlKey || r.metaKey) && r.key.toLowerCase() === "f" && C) {
81
- r.preventDefault(), C();
82
+ if ((r.ctrlKey || r.metaKey) && r.key.toLowerCase() === "f" && T) {
83
+ r.preventDefault(), T();
82
84
  return;
83
85
  }
84
86
  if ((r.ctrlKey || r.metaKey) && r.key.toLowerCase() === "a") {
85
- if (r.preventDefault(), T) {
86
- v(n.clearSelection()), v(n.activateCell(null));
87
+ if (r.preventDefault(), I) {
88
+ y(e.clearSelection()), y(e.activateCell(null));
87
89
  return;
88
90
  }
89
- E();
91
+ D();
90
92
  return;
91
93
  }
92
94
  if ((r.ctrlKey || r.metaKey) && !r.isComposing) {
93
95
  if (r.key.toLowerCase() === "z") {
94
- r.preventDefault(), r.shiftKey ? O() : D();
96
+ r.preventDefault(), r.shiftKey ? k() : O();
95
97
  return;
96
98
  }
97
99
  if (r.key.toLowerCase() === "y" && !r.shiftKey) {
98
- r.preventDefault(), O();
100
+ r.preventDefault(), k();
99
101
  return;
100
102
  }
101
103
  }
102
- let P = r.ctrlKey || r.metaKey;
103
- if ((r.key === "ContextMenu" || r.key === "F10" && r.shiftKey) && !P && !r.altKey && c.activeCell && t.openContextMenu?.(c.activeCell)) {
104
+ let L = r.ctrlKey || r.metaKey;
105
+ if ((r.key === "ContextMenu" || r.key === "F10" && r.shiftKey) && !L && !r.altKey && F.activeCell && n.openContextMenu?.(F.activeCell)) {
104
106
  r.preventDefault();
105
107
  return;
106
108
  }
107
- if (r.key === "ArrowDown" && r.altKey && !P && !r.shiftKey && c.activeCell && t.openColumnMenu?.(c.activeCell.col)) {
109
+ if (r.key === "ArrowDown" && r.altKey && !L && !r.shiftKey && F.activeCell && n.openColumnMenu?.(F.activeCell.col)) {
108
110
  r.preventDefault();
109
111
  return;
110
112
  }
111
- if (P && !r.altKey && (r.key === "ArrowUp" || r.key === "ArrowDown")) {
113
+ if (L && !r.altKey && (r.key === "ArrowUp" || r.key === "ArrowDown")) {
112
114
  r.preventDefault();
113
115
  let e = r.key === "ArrowDown";
114
- b((t, n) => ({
115
- row: e ? h(n) : u(n),
116
+ C((t, n) => ({
117
+ row: e ? v(n) : p(n),
116
118
  col: t.col
117
119
  }), r.shiftKey);
118
120
  return;
119
121
  }
120
- if (P && !r.altKey && (r.key === "ArrowLeft" || r.key === "ArrowRight")) {
122
+ if (L && !r.altKey && (r.key === "ArrowLeft" || r.key === "ArrowRight")) {
121
123
  r.preventDefault();
122
124
  let e = r.key === "ArrowRight";
123
- b((t, n, r) => ({
125
+ C((t, n, r) => ({
124
126
  row: t.row,
125
- col: e ? r.length - 1 : d(r)
127
+ col: e ? r.length - 1 : m(r)
126
128
  }), r.shiftKey);
127
129
  return;
128
130
  }
129
131
  if ((r.key === "Home" || r.key === "End") && !r.altKey) {
130
132
  r.preventDefault();
131
133
  let e = r.key === "End";
132
- b((t, n, r) => ({
133
- row: P ? e ? h(n) : u(n) : t.row,
134
- col: e ? r.length - 1 : d(r)
134
+ C((t, n, r) => ({
135
+ row: L ? e ? v(n) : p(n) : t.row,
136
+ col: e ? r.length - 1 : m(r)
135
137
  }), r.shiftKey);
136
138
  return;
137
139
  }
138
- if ((r.key === "PageDown" || r.key === "PageUp") && !P && !r.altKey) {
139
- if (r.preventDefault(), _()) return;
140
+ if ((r.key === "PageDown" || r.key === "PageUp") && !L && !r.altKey) {
141
+ if (r.preventDefault(), b()) return;
140
142
  let e = r.key === "PageDown" ? 1 : -1;
141
- b((t, n) => ({
142
- row: x(t, n, e),
143
+ C((t, n) => ({
144
+ row: w(t, n, e),
143
145
  col: t.col
144
146
  }), r.shiftKey);
145
147
  return;
146
148
  }
147
149
  if (r.key === "ArrowUp") {
148
- r.preventDefault(), y(-1, 0, r.shiftKey);
150
+ r.preventDefault(), S(-1, 0, r.shiftKey);
149
151
  return;
150
152
  }
151
153
  if (r.key === "ArrowDown") {
152
- r.preventDefault(), y(1, 0, r.shiftKey);
154
+ r.preventDefault(), S(1, 0, r.shiftKey);
153
155
  return;
154
156
  }
155
157
  if (r.key === "ArrowLeft") {
156
- r.preventDefault(), y(0, -1, r.shiftKey);
158
+ r.preventDefault(), S(0, -1, r.shiftKey);
157
159
  return;
158
160
  }
159
161
  if (r.key === "ArrowRight") {
160
- r.preventDefault(), y(0, 1, r.shiftKey);
162
+ r.preventDefault(), S(0, 1, r.shiftKey);
161
163
  return;
162
164
  }
163
165
  if (r.key === "Tab") {
164
- if (!c.activeCell && !r.shiftKey) {
165
- if (t.rowModel.getRowCount() === 0 || t.visibleColumns.length === 0) return;
166
- r.preventDefault(), _();
166
+ if (!F.activeCell && !r.shiftKey) {
167
+ if (n.rowModel.getRowCount() === 0 || n.visibleColumns.length === 0) return;
168
+ r.preventDefault(), b();
167
169
  return;
168
170
  }
169
- let e = c.activeCell?.col ?? 0;
170
- if (r.shiftKey ? e <= d(t.visibleColumns) : e >= t.visibleColumns.length - 1) {
171
- !r.shiftKey && c.activeCell && t.onTabPastLastColumn?.(c.activeCell.row) && r.preventDefault();
171
+ let e = F.activeCell?.col ?? 0;
172
+ if (r.shiftKey ? e <= m(n.visibleColumns) : e >= n.visibleColumns.length - 1) {
173
+ !r.shiftKey && F.activeCell && n.onTabPastLastColumn?.(F.activeCell.row) && r.preventDefault();
172
174
  return;
173
175
  }
174
- r.preventDefault(), y(0, r.shiftKey ? -1 : 1, !1);
176
+ r.preventDefault(), S(0, r.shiftKey ? -1 : 1, !1);
175
177
  return;
176
178
  }
177
179
  if (r.key === "Escape") {
178
- s(c.selection) && r.preventDefault(), v(n.clearSelection());
180
+ u(F.selection) && r.preventDefault(), y(e.clearSelection());
179
181
  return;
180
182
  }
181
- if ((r.key === "Delete" || r.key === "Backspace") && A) {
182
- r.preventDefault(), k();
183
+ if ((r.key === "Delete" || r.key === "Backspace") && j) {
184
+ r.preventDefault(), A();
183
185
  return;
184
186
  }
185
- if ((r.key === "Enter" || r.key === " ") && c.activeCell) {
186
- let e = l.getGroupRow?.(c.activeCell.row);
187
+ if ((r.key === "Enter" || r.key === " ") && F.activeCell) {
188
+ let e = d.getGroupRow?.(F.activeCell.row);
187
189
  if (e) {
188
- r.preventDefault(), M(e.groupKey);
190
+ r.preventDefault(), N(e.groupKey);
189
191
  return;
190
192
  }
191
- if (N && f[c.activeCell.col]?.key === "__ssg_detail_toggle__" && N(c.activeCell)) {
193
+ if (P && f[F.activeCell.col]?.key === "__ssg_detail_toggle__" && P(F.activeCell)) {
192
194
  r.preventDefault();
193
195
  return;
194
196
  }
195
197
  }
196
198
  if (r.key === "Enter" || r.key === "F2") {
197
- if (r.preventDefault(), c.activeCell) {
198
- w(c.activeCell);
199
+ if (r.preventDefault(), F.activeCell) {
200
+ E(F.activeCell);
199
201
  return;
200
202
  }
201
- r.key === "Enter" && _();
203
+ r.key === "Enter" && b();
202
204
  return;
203
205
  }
204
- if (r.key === " " && !r.ctrlKey && !r.metaKey && !r.altKey && r.preventDefault(), a(r) && c.activeCell) {
205
- let t = l.getRow(c.activeCell.row), i = f[c.activeCell.col];
206
- if (!t || !i || !e({
207
- readOnly: p,
208
- canEditCell: m
209
- }, l, c.activeCell.row, c.activeCell.col, t, i)) return;
206
+ if (r.key === " " && !r.ctrlKey && !r.metaKey && !r.altKey && r.preventDefault(), a(r) && F.activeCell) {
207
+ let n = d.getRow(F.activeCell.row), i = f[F.activeCell.col];
208
+ if (!n || !i || !t({
209
+ readOnly: h,
210
+ canEditCell: g
211
+ }, d, F.activeCell.row, F.activeCell.col, n, i)) return;
210
212
  if (i.editor?.type === "checkbox") {
211
- r.preventDefault(), r.key === " " && j(c.activeCell);
213
+ r.preventDefault(), r.key === " " && M(F.activeCell);
212
214
  return;
213
215
  }
214
- r.preventDefault(), g(r.key), v(n.startEdit(c.activeCell));
216
+ r.preventDefault(), _(r.key), y(e.startEdit(F.activeCell));
215
217
  }
216
218
  }
217
219
  };
218
220
  };
219
221
  //#endregion
220
- export { p as createKeyboardController, f as resolveFirstDataCell };
222
+ export { g as createKeyboardController, h as resolveFirstDataCell };
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=e=>e.getUiState?.()??e.uiState,t=t=>t.uiState.editingCell!==null||e(t).editingCell!==null;exports.isEditingAtEvent=t,exports.readLiveUiState=e;
@@ -0,0 +1,7 @@
1
+ import type { GridUiState } from '../model/gridTypes.unbound.js';
2
+ export type LiveUiStateArgs = {
3
+ uiState: GridUiState;
4
+ getUiState?: (() => GridUiState) | undefined;
5
+ };
6
+ export declare const readLiveUiState: (args: LiveUiStateArgs) => GridUiState;
7
+ export declare const isEditingAtEvent: (args: LiveUiStateArgs) => boolean;
@@ -0,0 +1,4 @@
1
+ //#region src/controllers/liveUiState.ts
2
+ var e = (e) => e.getUiState?.() ?? e.uiState, t = (t) => t.uiState.editingCell !== null || e(t).editingCell !== null;
3
+ //#endregion
4
+ export { t as isEditingAtEvent, e as readLiveUiState };