@ishibashi0112/spreadsheet-grid-core 1.2.0 → 1.3.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 (118) hide show
  1. package/dist/controllers/clipboardController.cjs +1 -1
  2. package/dist/controllers/clipboardController.d.ts +1 -0
  3. package/dist/controllers/clipboardController.js +79 -70
  4. package/dist/controllers/columnMenuController.cjs +1 -1
  5. package/dist/controllers/columnMenuController.js +75 -73
  6. package/dist/controllers/contextMenuController.cjs +1 -1
  7. package/dist/controllers/contextMenuController.js +63 -61
  8. package/dist/controllers/detailRowController.cjs +1 -0
  9. package/dist/controllers/detailRowController.d.ts +41 -0
  10. package/dist/controllers/detailRowController.js +97 -0
  11. package/dist/controllers/detailTabOrder.cjs +1 -1
  12. package/dist/controllers/detailTabOrder.js +17 -16
  13. package/dist/controllers/editController.cjs +1 -1
  14. package/dist/controllers/editController.d.ts +4 -1
  15. package/dist/controllers/editController.js +163 -91
  16. package/dist/controllers/escapeClaimController.cjs +1 -1
  17. package/dist/controllers/escapeClaimController.js +23 -19
  18. package/dist/controllers/fillHandleController.cjs +1 -1
  19. package/dist/controllers/fillHandleController.js +107 -106
  20. package/dist/controllers/filterPopoverController.cjs +1 -1
  21. package/dist/controllers/filterPopoverController.js +1 -0
  22. package/dist/controllers/imeInputController.cjs +1 -1
  23. package/dist/controllers/imeInputController.js +87 -76
  24. package/dist/controllers/keyboardController.cjs +1 -1
  25. package/dist/controllers/keyboardController.d.ts +4 -0
  26. package/dist/controllers/keyboardController.js +101 -97
  27. package/dist/controllers/liveUiState.cjs +1 -0
  28. package/dist/controllers/liveUiState.d.ts +7 -0
  29. package/dist/controllers/liveUiState.js +4 -0
  30. package/dist/controllers/pointerInteractionsController.cjs +1 -1
  31. package/dist/controllers/pointerInteractionsController.d.ts +1 -0
  32. package/dist/controllers/pointerInteractionsController.js +127 -126
  33. package/dist/controllers/popoverSupport.cjs +1 -1
  34. package/dist/controllers/popoverSupport.d.ts +3 -0
  35. package/dist/controllers/popoverSupport.js +62 -41
  36. package/dist/controllers/toolPanelController.cjs +1 -1
  37. package/dist/controllers/toolPanelController.js +74 -73
  38. package/dist/controllers/tooltipController.cjs +1 -1
  39. package/dist/controllers/tooltipController.d.ts +1 -1
  40. package/dist/controllers/tooltipController.js +122 -97
  41. package/dist/controllers/viewportSyncController.cjs +1 -1
  42. package/dist/controllers/viewportSyncController.js +55 -54
  43. package/dist/engine/cellCommands.cjs +1 -0
  44. package/dist/engine/cellCommands.d.ts +27 -0
  45. package/dist/engine/cellCommands.js +89 -0
  46. package/dist/engine/columnCommands.cjs +1 -1
  47. package/dist/engine/columnCommands.d.ts +2 -1
  48. package/dist/engine/columnCommands.js +98 -67
  49. package/dist/engine/exportCommands.cjs +1 -1
  50. package/dist/engine/exportCommands.js +2 -2
  51. package/dist/engine/gridApi.cjs +6 -5
  52. package/dist/engine/gridApi.d.ts +3 -0
  53. package/dist/engine/gridApi.js +158 -144
  54. package/dist/engine/rowSelectionCommands.cjs +1 -1
  55. package/dist/engine/rowSelectionCommands.d.ts +5 -0
  56. package/dist/engine/rowSelectionCommands.js +73 -38
  57. package/dist/locales/en.cjs +1 -1
  58. package/dist/locales/en.js +2 -2
  59. package/dist/logic/cellPlacement.cjs +1 -0
  60. package/dist/logic/cellPlacement.d.ts +22 -0
  61. package/dist/logic/cellPlacement.js +44 -0
  62. package/dist/logic/contextMenuTarget.cjs +1 -1
  63. package/dist/logic/contextMenuTarget.d.ts +20 -2
  64. package/dist/logic/contextMenuTarget.js +62 -3
  65. package/dist/logic/dateFilterCondition.cjs +1 -1
  66. package/dist/logic/dateFilterCondition.d.ts +1 -0
  67. package/dist/logic/dateFilterCondition.js +17 -13
  68. package/dist/logic/density.cjs +1 -0
  69. package/dist/logic/density.d.ts +5 -0
  70. package/dist/logic/density.js +17 -0
  71. package/dist/logic/detailRow.cjs +1 -1
  72. package/dist/logic/detailRow.d.ts +6 -1
  73. package/dist/logic/detailRow.js +21 -17
  74. package/dist/logic/domGuards.cjs +1 -1
  75. package/dist/logic/domGuards.d.ts +10 -0
  76. package/dist/logic/domGuards.js +18 -2
  77. package/dist/logic/editorKeys.cjs +1 -0
  78. package/dist/logic/editorKeys.d.ts +30 -0
  79. package/dist/logic/editorKeys.js +34 -0
  80. package/dist/logic/editorStart.cjs +1 -0
  81. package/dist/logic/editorStart.d.ts +7 -0
  82. package/dist/logic/editorStart.js +23 -0
  83. package/dist/logic/editorValues.cjs +1 -1
  84. package/dist/logic/editorValues.d.ts +1 -0
  85. package/dist/logic/editorValues.js +10 -7
  86. package/dist/logic/gridBarSummary.cjs +1 -0
  87. package/dist/logic/gridBarSummary.d.ts +27 -0
  88. package/dist/logic/gridBarSummary.js +137 -0
  89. package/dist/logic/gridState.cjs +1 -1
  90. package/dist/logic/gridState.d.ts +1 -0
  91. package/dist/logic/gridState.js +19 -16
  92. package/dist/logic/localeText.cjs +1 -1
  93. package/dist/logic/localeText.js +2 -2
  94. package/dist/logic/rowDragTarget.cjs +1 -0
  95. package/dist/logic/rowDragTarget.d.ts +14 -0
  96. package/dist/logic/rowDragTarget.js +47 -0
  97. package/dist/logic/selectEditorState.cjs +1 -1
  98. package/dist/logic/selectEditorState.d.ts +27 -4
  99. package/dist/logic/selectEditorState.js +29 -14
  100. package/dist/logic/valueFormatters.d.ts +8 -3
  101. package/dist/model/gridTypes.core.d.ts +31 -12
  102. package/dist/utils/clipboard.cjs +4 -4
  103. package/dist/utils/clipboard.js +60 -59
  104. package/dist/utils/editorVisibleBounds.cjs +1 -0
  105. package/dist/utils/editorVisibleBounds.d.ts +10 -0
  106. package/dist/utils/editorVisibleBounds.js +40 -0
  107. package/dist/utils/errorBubblePlacement.cjs +1 -0
  108. package/dist/utils/errorBubblePlacement.d.ts +8 -0
  109. package/dist/utils/errorBubblePlacement.js +26 -0
  110. package/dist/utils/multilineEditor.cjs +2 -0
  111. package/dist/utils/multilineEditor.d.ts +7 -0
  112. package/dist/utils/multilineEditor.js +22 -0
  113. package/dist/utils/popupContainer.cjs +1 -1
  114. package/dist/utils/popupContainer.js +35 -28
  115. package/dist/utils/shadowDom.cjs +1 -0
  116. package/dist/utils/shadowDom.d.ts +5 -0
  117. package/dist/utils/shadowDom.js +33 -0
  118. package/package.json +1 -1
@@ -1,143 +1,168 @@
1
- import { applySlotToElement as e } from "../logic/slotDom.js";
2
- import { syncPortalTokens as t } from "../utils/portalTokens.js";
3
- import { appendToPopupContainer as n, getPopupContainerFor as r } from "../utils/popupContainer.js";
4
- import { computeTooltipPlacement as i } from "../logic/tooltipGeometry.js";
1
+ import { findElementById as e, getActiveElement as t, getEventTarget as n, getShadowRoot as r } from "../utils/shadowDom.js";
2
+ import { applySlotToElement as i } from "../logic/slotDom.js";
3
+ import { syncPortalTokens as a } from "../utils/portalTokens.js";
4
+ import { appendToPopupContainer as o, getPopupContainerFor as s } from "../utils/popupContainer.js";
5
+ import { computeTooltipPlacement as c } from "../logic/tooltipGeometry.js";
5
6
  //#region src/controllers/tooltipController.ts
6
- var a = "data-ssg-tooltip", o = "data-ssg-tooltip-overflow", s = `[${a}], [${o}]`, c = 350, l = 800, u = 0, d = null, f = null, p = 0, m = null, h, g, _ = null, v = null, y = /* @__PURE__ */ new WeakMap();
7
- function b(t) {
8
- g = e(t, h, g);
7
+ var l = "data-ssg-tooltip", u = "data-ssg-tooltip-overflow", d = `[${l}], [${u}]`, f = 350, p = 800, m = 0, h = null, g = null, _ = 0, v = null, y, b, x = null, S = null, C = /* @__PURE__ */ new WeakMap();
8
+ function w(e) {
9
+ b = i(e, y, b);
9
10
  }
10
- function x(e) {
11
- let t = r(e);
12
- if (d !== null) return n(d, t), d;
13
- let i = document.createElement("div");
14
- return i.className = "ssg-tooltip", i.setAttribute("aria-hidden", "true"), g = void 0, b(i), n(i, t), d = i, i;
11
+ function T(e) {
12
+ let t = s(e);
13
+ if (h !== null) return o(h, t), h;
14
+ let n = document.createElement("div");
15
+ return n.className = "ssg-tooltip", n.setAttribute("aria-hidden", "true"), b = void 0, w(n), o(n, t), h = n, n;
15
16
  }
16
- function S() {
17
- f !== null && (window.clearTimeout(f), f = null);
17
+ function E() {
18
+ g !== null && (window.clearTimeout(g), g = null);
18
19
  }
19
- var C = null;
20
- function w() {
21
- C !== null && (cancelAnimationFrame(C), C = null);
20
+ var D = null;
21
+ function O() {
22
+ D !== null && (cancelAnimationFrame(D), D = null);
22
23
  }
23
- function T() {
24
- if (w(), typeof requestAnimationFrame != "function") return;
24
+ function k() {
25
+ if (O(), typeof requestAnimationFrame != "function") return;
25
26
  let e = () => {
26
- if (C = null, m !== null) {
27
- if (!m.isConnected) {
28
- E();
27
+ if (D = null, v !== null) {
28
+ if (!v.isConnected) {
29
+ A();
29
30
  return;
30
31
  }
31
- C = requestAnimationFrame(e);
32
+ D = requestAnimationFrame(e);
32
33
  }
33
34
  };
34
- C = requestAnimationFrame(e);
35
+ D = requestAnimationFrame(e);
35
36
  }
36
- function E() {
37
- S(), w(), m !== null && (p = Date.now() + l), m = null, _ = null, v = null, d !== null && d.classList.remove("ssg-tooltip--visible");
37
+ function A() {
38
+ E(), O(), v !== null && (_ = Date.now() + p), v = null, x = null, S = null, h !== null && h.classList.remove("ssg-tooltip--visible");
38
39
  }
39
- function D(e) {
40
+ function j(e) {
40
41
  if (!e.isConnected) return;
41
- let n = e.getAttribute(a), r = e.getAttribute(o), s = n !== null && n !== "" ? n : r !== null && r !== "" ? r : (e.textContent ?? "").trim();
42
- if (s === "") return;
43
- let c = x(e);
44
- c.classList.toggle("ssg-theme-dark", e.closest(".ssg-theme-dark") !== null), c.classList.toggle("ssg-theme-class", e.closest(".ssg-theme-class") !== null), c.classList.toggle("ssg-motion-off", e.closest(".ssg-motion-off") !== null), t(e, c), c.textContent = s, c.style.left = "0px", c.style.top = "0px";
45
- let l = i({
42
+ let t = e.getAttribute(l), n = e.getAttribute(u), r = t !== null && t !== "" ? t : n !== null && n !== "" ? n : (e.textContent ?? "").trim();
43
+ if (r === "") return;
44
+ let i = T(e);
45
+ i.classList.toggle("ssg-theme-dark", e.closest(".ssg-theme-dark") !== null), i.classList.toggle("ssg-theme-class", e.closest(".ssg-theme-class") !== null), i.classList.toggle("ssg-motion-off", e.closest(".ssg-motion-off") !== null), a(e, i), i.textContent = r, i.style.left = "0px", i.style.top = "0px";
46
+ let o = c({
46
47
  targetRect: e.getBoundingClientRect(),
47
- tipWidth: c.offsetWidth,
48
- tipHeight: c.offsetHeight,
48
+ tipWidth: i.offsetWidth,
49
+ tipHeight: i.offsetHeight,
49
50
  viewportWidth: window.innerWidth
50
51
  });
51
- c.style.left = `${l.left}px`, c.style.top = `${l.top}px`, c.classList.add("ssg-tooltip--visible"), m = e, T();
52
+ i.style.left = `${o.left}px`, i.style.top = `${o.top}px`, i.classList.add("ssg-tooltip--visible"), v = e, k();
52
53
  }
53
- function O(e) {
54
+ function M(e) {
54
55
  if (e.scrollWidth > e.clientWidth + 1) return !0;
55
56
  for (let t of Array.from(e.children)) if (t.scrollWidth > t.clientWidth + 1) return !0;
56
57
  return !1;
57
58
  }
58
- function k(e) {
59
- let t = e.target;
59
+ var N = (e) => e.currentTarget;
60
+ function P(e) {
61
+ let t = n(e, N(e));
60
62
  if (!(t instanceof Element) || typeof PointerEvent < "u" && e instanceof PointerEvent && e.buttons !== 0) return;
61
- let n = t.closest(s);
62
- if (n === null || n === m || !n.hasAttribute(a) && !O(n)) return;
63
- let r = m !== null;
64
- E(), r || Date.now() < p ? D(n) : f = window.setTimeout(() => {
65
- f = null, D(n);
66
- }, c);
67
- }
68
- function A(e) {
69
- let t = e.target;
63
+ let r = t.closest(d);
64
+ if (r === null || r === v || !r.hasAttribute(l) && !M(r)) return;
65
+ let i = v !== null;
66
+ A(), i || Date.now() < _ ? j(r) : g = window.setTimeout(() => {
67
+ g = null, j(r);
68
+ }, f);
69
+ }
70
+ function F(e) {
71
+ let t = n(e, N(e));
70
72
  if (!(t instanceof Element)) return;
71
- if (e.type === "focusout" && v !== null && v.contains(t)) {
73
+ if (e.type === "focusout" && S !== null && S.contains(t)) {
72
74
  let t = e.relatedTarget;
73
- if (!(t instanceof Node && v.contains(t))) {
74
- E();
75
+ if (!(t instanceof Node && S.contains(t))) {
76
+ A();
75
77
  return;
76
78
  }
77
79
  }
78
- let n = t.closest(s);
79
- if (n === null || n === _ && typeof PointerEvent < "u" && e instanceof PointerEvent && e.pointerType !== "mouse") return;
80
- let r = e.relatedTarget;
81
- r instanceof Node && n.contains(r) || E();
82
- }
83
- function j() {
84
- E();
85
- }
86
- function M(e) {
87
- _ !== null && m === _ && typeof PointerEvent < "u" && e instanceof PointerEvent && e.pointerType !== "mouse" && e.target instanceof Node && _.contains(e.target) || E();
80
+ let r = t.closest(d);
81
+ if (r === null || r === x && typeof PointerEvent < "u" && e instanceof PointerEvent && e.pointerType !== "mouse") return;
82
+ let i = e.relatedTarget;
83
+ i instanceof Node && r.contains(i) || A();
88
84
  }
89
- function N(e) {
90
- let t = e.target;
91
- if (!(t instanceof Element)) return;
92
- let n = t.closest(".ssg-shell"), r = n === null ? void 0 : y.get(n);
93
- if (n === null || r === void 0) return;
94
- let i = document.getElementById(r);
95
- i === null || m === i || !i.contains(t) || L(r, n);
85
+ function I() {
86
+ A();
96
87
  }
97
- function P(e) {
98
- e.key === "Escape" && E();
88
+ function L(e) {
89
+ let t = n(e, N(e));
90
+ x !== null && v === x && typeof PointerEvent < "u" && e instanceof PointerEvent && e.pointerType !== "mouse" && t instanceof Node && x.contains(t) || A();
99
91
  }
100
- function F() {
101
- window.addEventListener("pointerover", k, !0), window.addEventListener("pointerout", A, !0), window.addEventListener("focusin", k, !0), window.addEventListener("focusout", A, !0), window.addEventListener("pointerdown", M, !0), window.addEventListener("pointerup", N, !0), window.addEventListener("scroll", j, !0), window.addEventListener("keydown", P, !0);
92
+ function R(t) {
93
+ let r = n(t, N(t));
94
+ if (!(r instanceof Element)) return;
95
+ let i = r.closest(".ssg-shell"), a = i === null ? void 0 : C.get(i);
96
+ if (i === null || a === void 0) return;
97
+ let o = e(i, a);
98
+ o === null || v === o || !o.contains(r) || q(a, i);
102
99
  }
103
- function I() {
104
- window.removeEventListener("pointerover", k, !0), window.removeEventListener("pointerout", A, !0), window.removeEventListener("focusin", k, !0), window.removeEventListener("focusout", A, !0), window.removeEventListener("pointerdown", M, !0), window.removeEventListener("pointerup", N, !0), window.removeEventListener("scroll", j, !0), window.removeEventListener("keydown", P, !0);
105
- }
106
- function L(e, t) {
107
- if (typeof requestAnimationFrame != "function" || u === 0) return () => {};
108
- t !== null && y.set(t, e);
109
- let n = requestAnimationFrame(() => {
110
- n = requestAnimationFrame(() => {
111
- if (n = 0, t !== null && y.get(t) !== e) return;
112
- let r = document.getElementById(e);
113
- if (!(r !== null && t !== null && t.contains(document.activeElement) && r.classList.contains("ssg-body-cell--invalid") && (r.getAttribute(a) ?? "") !== "")) {
114
- z(t);
100
+ function z(e) {
101
+ e.key === "Escape" && A();
102
+ }
103
+ var B = [
104
+ ["pointerover", P],
105
+ ["pointerout", F],
106
+ ["focusin", P],
107
+ ["focusout", F],
108
+ ["pointerdown", L],
109
+ ["pointerup", R],
110
+ ["scroll", I],
111
+ ["keydown", z]
112
+ ], V = /* @__PURE__ */ new Map(), H = /* @__PURE__ */ B.map(([e, t]) => [e, (e) => {
113
+ (typeof e.composedPath == "function" ? e.composedPath() : []).some((e) => V.has(e)) || t(e);
114
+ }]);
115
+ function U(e, t = B) {
116
+ for (let [n, r] of t) e.addEventListener(n, r, !0);
117
+ }
118
+ function W(e, t = B) {
119
+ for (let [n, r] of t) e.removeEventListener(n, r, !0);
120
+ }
121
+ function G(e) {
122
+ let t = V.get(e) ?? 0;
123
+ t === 0 && U(e), V.set(e, t + 1);
124
+ }
125
+ function K(e) {
126
+ let t = V.get(e) ?? 0;
127
+ t <= 1 ? (V.delete(e), W(e)) : V.set(e, t - 1);
128
+ }
129
+ function q(n, r) {
130
+ if (typeof requestAnimationFrame != "function" || m === 0) return () => {};
131
+ r !== null && C.set(r, n);
132
+ let i = requestAnimationFrame(() => {
133
+ i = requestAnimationFrame(() => {
134
+ if (i = 0, r !== null && C.get(r) !== n) return;
135
+ let a = e(r, n);
136
+ if (!(a !== null && r !== null && r.contains(t(r)) && a.classList.contains("ssg-body-cell--invalid") && (a.getAttribute(l) ?? "") !== "")) {
137
+ Y(r);
115
138
  return;
116
139
  }
117
- m !== r && (E(), D(r)), m === r && (_ = r, v = t);
140
+ v !== a && (A(), j(a)), v === a && (x = a, S = r);
118
141
  });
119
142
  });
120
143
  return () => {
121
- n !== 0 && cancelAnimationFrame(n);
144
+ i !== 0 && cancelAnimationFrame(i);
122
145
  };
123
146
  }
124
- function R(e) {
125
- e && y.delete(e), z(e);
147
+ function J(e) {
148
+ e && C.delete(e), Y(e);
126
149
  }
127
- function z(e) {
128
- _ === null || e !== void 0 && e !== v || (m === _ && E(), _ = null, v = null);
150
+ function Y(e) {
151
+ x === null || e !== void 0 && e !== S || (v === x && A(), x = null, S = null);
129
152
  }
130
- function B(e) {
131
- u += 1, u === 1 && F();
132
- let t = !1, n = (e) => {
133
- h = e, d !== null && b(d);
153
+ function X(e, t) {
154
+ m += 1, m === 1 && U(window, H);
155
+ let n = r(t);
156
+ n !== null && G(n);
157
+ let i = !1, a = (e) => {
158
+ y = e, h !== null && w(h);
134
159
  };
135
- return n(e), {
136
- setSlot: n,
160
+ return a(e), {
161
+ setSlot: a,
137
162
  dispose: () => {
138
- t || (t = !0, --u, u === 0 && (I(), S(), w(), m = null, _ = null, v = null, d !== null && (d.remove(), d = null)));
163
+ i || (i = !0, n !== null && K(n), --m, m === 0 && (W(window, H), E(), O(), v = null, x = null, S = null, h !== null && (h.remove(), h = null)));
139
164
  }
140
165
  };
141
166
  }
142
167
  //#endregion
143
- export { B as acquireTooltipController, R as hideActiveCellTooltip, L as scheduleActiveCellTooltip };
168
+ export { X as acquireTooltipController, J as hideActiveCellTooltip, q as scheduleActiveCellTooltip };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/verticalGeometry.cjs");var t=(e,t)=>{let n=Math.max(t.totalScrollWidth-e.clientWidth,0),r=Math.max(t.headerHeight+t.physicalBodyHeight+(t.footerHeight??0)-e.clientHeight,0);e.scrollLeft>n&&(e.scrollLeft=n),e.scrollTop>r&&(e.scrollTop=r)},n=(t,n,r)=>{let i=r.headerHeight+n.top,a=i+n.height,o=r.leftPaneWidth+r.centerLeadingWidth+n.left,s=o+n.width,c=e.physicalToLogicalScrollTop(t.scrollTop,r.verticalScaleFactor),l=t.scrollLeft,u=t.clientHeight-(r.footerHeight??0),d=t.clientWidth,f=c,p=l,m=c+r.headerHeight+(r.stickyTopInset?.visibleAt(c)??0),h=c+u,g=()=>Math.max(i-r.headerHeight-(r.stickyTopInset?.coveringRowAt(n.top)??0),0);i<m?f=g():a>h&&(f=n.height>h-m?g():Math.max(a-u,0));let _=l+r.leftPaneWidth,v=l+d-r.rightPaneWidth,y=r.activeCellPinned===!0;if(!y&&o<_||!y&&s>v&&n.width>v-_?p=Math.max(o-r.leftPaneWidth,0):!y&&s>v&&(p=Math.max(s-d+r.rightPaneWidth,0)),f!==c||p!==l){let n=e.logicalToPhysicalScrollTop(f,r.verticalScaleFactor);return t.scrollTo({top:f>c?Math.ceil(n):n,left:p,behavior:`auto`}),!0}return!1},r=(e,t,n,r)=>e<n?e-n:t>r?Math.min(t-r,e-n):0,i=(t,n,i)=>{let a=t.ownerDocument,o=a.defaultView,s=t.closest(`.ssg-shell`),c=a.activeElement;if(!o||!s||!c||c!==s&&!(c.classList.contains(`ssg-ime-input`)&&s.contains(c))||s.hasAttribute(`data-ssg-pointer`))return;let l=t.getBoundingClientRect();if(l.height===0)return;let u=e.physicalToLogicalScrollTop(t.scrollTop,i.verticalScaleFactor),d=l.top+t.clientTop+i.headerHeight+n.top-u,f=d+n.height;for(let e=t.parentElement;e&&e!==a.body&&e!==a.documentElement;e=e.parentElement){let t=e.scrollHeight-e.clientHeight;if(t<=0)continue;let n=o.getComputedStyle(e).overflowY;if(n!==`auto`&&n!==`scroll`&&n!==`overlay`)continue;let i=e.getBoundingClientRect().top+e.clientTop,a=r(d,f,i,i+e.clientHeight);if(a===0)continue;let s=e.scrollTop,c=Math.min(Math.max(s+a,0),t);e.scrollTop=c,d-=c-s,f-=c-s}let p=r(d,f,0,o.innerHeight);p!==0&&o.scrollBy({top:p,behavior:`auto`})},a=()=>{let t=null,n=1,r=0;return{update:(i,a,o)=>{let s=t,c=n,l=r;if(t=i,n=a,r=i!==null&&a!==1?Math.max(i.scrollHeight-i.clientHeight,0):0,i===null||i!==s||c===a)return;let u=i.scrollTop;if(l>0&&u>=l-1)return;let d=e.logicalToPhysicalScrollTop(e.physicalToLogicalScrollTop(u,c),a);Math.abs(d-u)<1||(i.scrollTop=d,i.scrollTop!==u&&o(i.scrollTop))}}},o=1e3,s=[`wheel`,`touchstart`,`pointerdown`,`pointerup`,`pointermove`,`keydown`],c=(e,t)=>e!==null&&e.top===t.top&&e.height===t.height&&e.left===t.left&&e.width===t.width,l=(e,t,n)=>e===null||n.some(n=>!Object.is(e[n],t[n])),u=()=>{let e=null,r=null,a=null,u=null,d=()=>{a=null,u?.(),u=null},f=e=>{e.type===`pointermove`&&!(e.buttons>0)||d()},p=(e,t)=>{d(),a={cell:t,until:Date.now()+o,left:e.scrollLeft};let n=e.ownerDocument,r=setTimeout(d,o);if(typeof n?.addEventListener!=`function`){u=()=>clearTimeout(r);return}for(let e of s)n.addEventListener(e,f,{capture:!0,passive:!0});u=()=>{clearTimeout(r);for(let e of s)n.removeEventListener(e,f,{capture:!0})}};return{update:o=>{if(l(e,o,[`columnVirtualizer`,`columnMeasurements`])&&o.columnVirtualizer.measure(),l(e,o,[`scrollElement`,`totalScrollWidth`,`physicalBodyHeight`,`headerHeight`,`footerHeight`])&&o.scrollElement&&t(o.scrollElement,o),l(e,o,[`scrollElement`,`activeCellRect`,`activeCellPinned`,`activeCell`,`headerHeight`,`leftPaneWidth`,`rightPaneWidth`,`centerLeadingWidth`,`verticalScaleFactor`,`footerHeight`])){let t=r,{activeCell:s}=o,l=t!==null&&s!==null&&t.row===s.row&&t.col===s.col;r=s,!l&&s!==null&&o.isRowFollowMove?.(s)===!0?d():!l&&o.scrollElement&&o.activeCellRect&&s?(n(o.scrollElement,o.activeCellRect,o),i(o.scrollElement,o.activeCellRect,o),p(o.scrollElement,s)):l&&a!==null&&s!==null&&o.scrollElement&&o.activeCellRect&&a.cell.row===s.row&&a.cell.col===s.col&&!c(e?.activeCellRect??null,o.activeCellRect)&&(Date.now()>a.until||Math.abs(o.scrollElement.scrollLeft-a.left)>1?d():(n(o.scrollElement,o.activeCellRect,o),a={...a,left:o.scrollElement.scrollLeft}))}e=o},cancelFollow:d,dispose:d}};exports.clampScrollToContent=t,exports.createScrollScaleAnchor=a,exports.createViewportSyncController=u,exports.revealActiveCellInPage=i,exports.scrollCellIntoView=n;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../utils/shadowDom.cjs"),t=require("../logic/verticalGeometry.cjs");var n=(e,t)=>{let n=Math.max(t.totalScrollWidth-e.clientWidth,0),r=Math.max(t.headerHeight+t.physicalBodyHeight+(t.footerHeight??0)-e.clientHeight,0);e.scrollLeft>n&&(e.scrollLeft=n),e.scrollTop>r&&(e.scrollTop=r)},r=(e,n,r)=>{let i=r.headerHeight+n.top,a=i+n.height,o=r.leftPaneWidth+r.centerLeadingWidth+n.left,s=o+n.width,c=t.physicalToLogicalScrollTop(e.scrollTop,r.verticalScaleFactor),l=e.scrollLeft,u=e.clientHeight-(r.footerHeight??0),d=e.clientWidth,f=c,p=l,m=c+r.headerHeight+(r.stickyTopInset?.visibleAt(c)??0),h=c+u,g=()=>Math.max(i-r.headerHeight-(r.stickyTopInset?.coveringRowAt(n.top)??0),0);i<m?f=g():a>h&&(f=n.height>h-m?g():Math.max(a-u,0));let _=l+r.leftPaneWidth,v=l+d-r.rightPaneWidth,y=r.activeCellPinned===!0;if(!y&&o<_||!y&&s>v&&n.width>v-_?p=Math.max(o-r.leftPaneWidth,0):!y&&s>v&&(p=Math.max(s-d+r.rightPaneWidth,0)),f!==c||p!==l){let n=t.logicalToPhysicalScrollTop(f,r.verticalScaleFactor);return e.scrollTo({top:f>c?Math.ceil(n):n,left:p,behavior:`auto`}),!0}return!1},i=(e,t,n,r)=>e<n?e-n:t>r?Math.min(t-r,e-n):0,a=(n,r,a)=>{let o=n.ownerDocument,s=o.defaultView,c=n.closest(`.ssg-shell`),l=e.getActiveElement(n);if(!s||!c||!l||l!==c&&!(l.classList.contains(`ssg-ime-input`)&&c.contains(l))||c.hasAttribute(`data-ssg-pointer`))return;let u=n.getBoundingClientRect();if(u.height===0)return;let d=t.physicalToLogicalScrollTop(n.scrollTop,a.verticalScaleFactor),f=u.top+n.clientTop+a.headerHeight+r.top-d,p=f+r.height;for(let e=n.parentElement;e&&e!==o.body&&e!==o.documentElement;e=e.parentElement){let t=e.scrollHeight-e.clientHeight;if(t<=0)continue;let n=s.getComputedStyle(e).overflowY;if(n!==`auto`&&n!==`scroll`&&n!==`overlay`)continue;let r=e.getBoundingClientRect().top+e.clientTop,a=i(f,p,r,r+e.clientHeight);if(a===0)continue;let o=e.scrollTop,c=Math.min(Math.max(o+a,0),t);e.scrollTop=c,f-=c-o,p-=c-o}let m=i(f,p,0,s.innerHeight);m!==0&&s.scrollBy({top:m,behavior:`auto`})},o=()=>{let e=null,n=1,r=0;return{update:(i,a,o)=>{let s=e,c=n,l=r;if(e=i,n=a,r=i!==null&&a!==1?Math.max(i.scrollHeight-i.clientHeight,0):0,i===null||i!==s||c===a)return;let u=i.scrollTop;if(l>0&&u>=l-1)return;let d=t.logicalToPhysicalScrollTop(t.physicalToLogicalScrollTop(u,c),a);Math.abs(d-u)<1||(i.scrollTop=d,i.scrollTop!==u&&o(i.scrollTop))}}},s=1e3,c=[`wheel`,`touchstart`,`pointerdown`,`pointerup`,`pointermove`,`keydown`],l=(e,t)=>e!==null&&e.top===t.top&&e.height===t.height&&e.left===t.left&&e.width===t.width,u=(e,t,n)=>e===null||n.some(n=>!Object.is(e[n],t[n])),d=()=>{let e=null,t=null,i=null,o=null,d=()=>{i=null,o?.(),o=null},f=e=>{e.type===`pointermove`&&!(e.buttons>0)||d()},p=(e,t)=>{d(),i={cell:t,until:Date.now()+s,left:e.scrollLeft};let n=e.ownerDocument,r=setTimeout(d,s);if(typeof n?.addEventListener!=`function`){o=()=>clearTimeout(r);return}for(let e of c)n.addEventListener(e,f,{capture:!0,passive:!0});o=()=>{clearTimeout(r);for(let e of c)n.removeEventListener(e,f,{capture:!0})}};return{update:o=>{if(u(e,o,[`columnVirtualizer`,`columnMeasurements`])&&o.columnVirtualizer.measure(),u(e,o,[`scrollElement`,`totalScrollWidth`,`physicalBodyHeight`,`headerHeight`,`footerHeight`])&&o.scrollElement&&n(o.scrollElement,o),u(e,o,[`scrollElement`,`activeCellRect`,`activeCellPinned`,`activeCell`,`headerHeight`,`leftPaneWidth`,`rightPaneWidth`,`centerLeadingWidth`,`verticalScaleFactor`,`footerHeight`])){let n=t,{activeCell:s}=o,c=n!==null&&s!==null&&n.row===s.row&&n.col===s.col;t=s,!c&&s!==null&&o.isRowFollowMove?.(s)===!0?d():!c&&o.scrollElement&&o.activeCellRect&&s?(r(o.scrollElement,o.activeCellRect,o),a(o.scrollElement,o.activeCellRect,o),p(o.scrollElement,s)):c&&i!==null&&s!==null&&o.scrollElement&&o.activeCellRect&&i.cell.row===s.row&&i.cell.col===s.col&&!l(e?.activeCellRect??null,o.activeCellRect)&&(Date.now()>i.until||Math.abs(o.scrollElement.scrollLeft-i.left)>1?d():(r(o.scrollElement,o.activeCellRect,o),i={...i,left:o.scrollElement.scrollLeft}))}e=o},cancelFollow:d,dispose:d}};exports.clampScrollToContent=n,exports.createScrollScaleAnchor=o,exports.createViewportSyncController=d,exports.revealActiveCellInPage=a,exports.scrollCellIntoView=r;
@@ -1,93 +1,94 @@
1
- import { logicalToPhysicalScrollTop as e, physicalToLogicalScrollTop as t } from "../logic/verticalGeometry.js";
1
+ import { getActiveElement as e } from "../utils/shadowDom.js";
2
+ import { logicalToPhysicalScrollTop as t, physicalToLogicalScrollTop as n } from "../logic/verticalGeometry.js";
2
3
  //#region src/controllers/viewportSyncController.ts
3
- var n = (e, t) => {
4
+ var r = (e, t) => {
4
5
  let n = Math.max(t.totalScrollWidth - e.clientWidth, 0), r = Math.max(t.headerHeight + t.physicalBodyHeight + (t.footerHeight ?? 0) - e.clientHeight, 0);
5
6
  e.scrollLeft > n && (e.scrollLeft = n), e.scrollTop > r && (e.scrollTop = r);
6
- }, r = (n, r, i) => {
7
- let a = i.headerHeight + r.top, o = a + r.height, s = i.leftPaneWidth + i.centerLeadingWidth + r.left, c = s + r.width, l = t(n.scrollTop, i.verticalScaleFactor), u = n.scrollLeft, d = n.clientHeight - (i.footerHeight ?? 0), f = n.clientWidth, p = l, m = u, h = l + i.headerHeight + (i.stickyTopInset?.visibleAt(l) ?? 0), g = l + d, _ = () => Math.max(a - i.headerHeight - (i.stickyTopInset?.coveringRowAt(r.top) ?? 0), 0);
7
+ }, i = (e, r, i) => {
8
+ let a = i.headerHeight + r.top, o = a + r.height, s = i.leftPaneWidth + i.centerLeadingWidth + r.left, c = s + r.width, l = n(e.scrollTop, i.verticalScaleFactor), u = e.scrollLeft, d = e.clientHeight - (i.footerHeight ?? 0), f = e.clientWidth, p = l, m = u, h = l + i.headerHeight + (i.stickyTopInset?.visibleAt(l) ?? 0), g = l + d, _ = () => Math.max(a - i.headerHeight - (i.stickyTopInset?.coveringRowAt(r.top) ?? 0), 0);
8
9
  a < h ? p = _() : o > g && (p = r.height > g - h ? _() : Math.max(o - d, 0));
9
10
  let v = u + i.leftPaneWidth, y = u + f - i.rightPaneWidth, b = i.activeCellPinned === !0;
10
11
  if (!b && s < v || !b && c > y && r.width > y - v ? m = Math.max(s - i.leftPaneWidth, 0) : !b && c > y && (m = Math.max(c - f + i.rightPaneWidth, 0)), p !== l || m !== u) {
11
- let t = e(p, i.verticalScaleFactor);
12
- return n.scrollTo({
13
- top: p > l ? Math.ceil(t) : t,
12
+ let n = t(p, i.verticalScaleFactor);
13
+ return e.scrollTo({
14
+ top: p > l ? Math.ceil(n) : n,
14
15
  left: m,
15
16
  behavior: "auto"
16
17
  }), !0;
17
18
  }
18
19
  return !1;
19
- }, i = (e, t, n, r) => e < n ? e - n : t > r ? Math.min(t - r, e - n) : 0, a = (e, n, r) => {
20
- let a = e.ownerDocument, o = a.defaultView, s = e.closest(".ssg-shell"), c = a.activeElement;
21
- if (!o || !s || !c || c !== s && !(c.classList.contains("ssg-ime-input") && s.contains(c)) || s.hasAttribute("data-ssg-pointer")) return;
22
- let l = e.getBoundingClientRect();
23
- if (l.height === 0) return;
24
- let u = t(e.scrollTop, r.verticalScaleFactor), d = l.top + e.clientTop + r.headerHeight + n.top - u, f = d + n.height;
25
- for (let t = e.parentElement; t && t !== a.body && t !== a.documentElement; t = t.parentElement) {
26
- let e = t.scrollHeight - t.clientHeight;
27
- if (e <= 0) continue;
28
- let n = o.getComputedStyle(t).overflowY;
20
+ }, a = (e, t, n, r) => e < n ? e - n : t > r ? Math.min(t - r, e - n) : 0, o = (t, r, i) => {
21
+ let o = t.ownerDocument, s = o.defaultView, c = t.closest(".ssg-shell"), l = e(t);
22
+ if (!s || !c || !l || l !== c && !(l.classList.contains("ssg-ime-input") && c.contains(l)) || c.hasAttribute("data-ssg-pointer")) return;
23
+ let u = t.getBoundingClientRect();
24
+ if (u.height === 0) return;
25
+ let d = n(t.scrollTop, i.verticalScaleFactor), f = u.top + t.clientTop + i.headerHeight + r.top - d, p = f + r.height;
26
+ for (let e = t.parentElement; e && e !== o.body && e !== o.documentElement; e = e.parentElement) {
27
+ let t = e.scrollHeight - e.clientHeight;
28
+ if (t <= 0) continue;
29
+ let n = s.getComputedStyle(e).overflowY;
29
30
  if (n !== "auto" && n !== "scroll" && n !== "overlay") continue;
30
- let r = t.getBoundingClientRect().top + t.clientTop, a = i(d, f, r, r + t.clientHeight);
31
- if (a === 0) continue;
32
- let s = t.scrollTop, c = Math.min(Math.max(s + a, 0), e);
33
- t.scrollTop = c, d -= c - s, f -= c - s;
31
+ let r = e.getBoundingClientRect().top + e.clientTop, i = a(f, p, r, r + e.clientHeight);
32
+ if (i === 0) continue;
33
+ let o = e.scrollTop, c = Math.min(Math.max(o + i, 0), t);
34
+ e.scrollTop = c, f -= c - o, p -= c - o;
34
35
  }
35
- let p = i(d, f, 0, o.innerHeight);
36
- p !== 0 && o.scrollBy({
37
- top: p,
36
+ let m = a(f, p, 0, s.innerHeight);
37
+ m !== 0 && s.scrollBy({
38
+ top: m,
38
39
  behavior: "auto"
39
40
  });
40
- }, o = () => {
41
- let n = null, r = 1, i = 0;
41
+ }, s = () => {
42
+ let e = null, r = 1, i = 0;
42
43
  return { update: (a, o, s) => {
43
- let c = n, l = r, u = i;
44
- if (n = a, r = o, i = a !== null && o !== 1 ? Math.max(a.scrollHeight - a.clientHeight, 0) : 0, a === null || a !== c || l === o) return;
44
+ let c = e, l = r, u = i;
45
+ if (e = a, r = o, i = a !== null && o !== 1 ? Math.max(a.scrollHeight - a.clientHeight, 0) : 0, a === null || a !== c || l === o) return;
45
46
  let d = a.scrollTop;
46
47
  if (u > 0 && d >= u - 1) return;
47
- let f = e(t(d, l), o);
48
+ let f = t(n(d, l), o);
48
49
  Math.abs(f - d) < 1 || (a.scrollTop = f, a.scrollTop !== d && s(a.scrollTop));
49
50
  } };
50
- }, s = 1e3, c = [
51
+ }, c = 1e3, l = [
51
52
  "wheel",
52
53
  "touchstart",
53
54
  "pointerdown",
54
55
  "pointerup",
55
56
  "pointermove",
56
57
  "keydown"
57
- ], l = (e, t) => e !== null && e.top === t.top && e.height === t.height && e.left === t.left && e.width === t.width, u = (e, t, n) => e === null || n.some((n) => !Object.is(e[n], t[n])), d = () => {
58
- let e = null, t = null, i = null, o = null, d = () => {
59
- i = null, o?.(), o = null;
58
+ ], u = (e, t) => e !== null && e.top === t.top && e.height === t.height && e.left === t.left && e.width === t.width, d = (e, t, n) => e === null || n.some((n) => !Object.is(e[n], t[n])), f = () => {
59
+ let e = null, t = null, n = null, a = null, s = () => {
60
+ n = null, a?.(), a = null;
60
61
  }, f = (e) => {
61
- e.type === "pointermove" && !(e.buttons > 0) || d();
62
+ e.type === "pointermove" && !(e.buttons > 0) || s();
62
63
  }, p = (e, t) => {
63
- d(), i = {
64
+ s(), n = {
64
65
  cell: t,
65
- until: Date.now() + s,
66
+ until: Date.now() + c,
66
67
  left: e.scrollLeft
67
68
  };
68
- let n = e.ownerDocument, r = setTimeout(d, s);
69
- if (typeof n?.addEventListener != "function") {
70
- o = () => clearTimeout(r);
69
+ let r = e.ownerDocument, i = setTimeout(s, c);
70
+ if (typeof r?.addEventListener != "function") {
71
+ a = () => clearTimeout(i);
71
72
  return;
72
73
  }
73
- for (let e of c) n.addEventListener(e, f, {
74
+ for (let e of l) r.addEventListener(e, f, {
74
75
  capture: !0,
75
76
  passive: !0
76
77
  });
77
- o = () => {
78
- clearTimeout(r);
79
- for (let e of c) n.removeEventListener(e, f, { capture: !0 });
78
+ a = () => {
79
+ clearTimeout(i);
80
+ for (let e of l) r.removeEventListener(e, f, { capture: !0 });
80
81
  };
81
82
  };
82
83
  return {
83
- update: (o) => {
84
- if (u(e, o, ["columnVirtualizer", "columnMeasurements"]) && o.columnVirtualizer.measure(), u(e, o, [
84
+ update: (a) => {
85
+ if (d(e, a, ["columnVirtualizer", "columnMeasurements"]) && a.columnVirtualizer.measure(), d(e, a, [
85
86
  "scrollElement",
86
87
  "totalScrollWidth",
87
88
  "physicalBodyHeight",
88
89
  "headerHeight",
89
90
  "footerHeight"
90
- ]) && o.scrollElement && n(o.scrollElement, o), u(e, o, [
91
+ ]) && a.scrollElement && r(a.scrollElement, a), d(e, a, [
91
92
  "scrollElement",
92
93
  "activeCellRect",
93
94
  "activeCellPinned",
@@ -99,17 +100,17 @@ var n = (e, t) => {
99
100
  "verticalScaleFactor",
100
101
  "footerHeight"
101
102
  ])) {
102
- let n = t, { activeCell: s } = o, c = n !== null && s !== null && n.row === s.row && n.col === s.col;
103
- t = s, !c && s !== null && o.isRowFollowMove?.(s) === !0 ? d() : !c && o.scrollElement && o.activeCellRect && s ? (r(o.scrollElement, o.activeCellRect, o), a(o.scrollElement, o.activeCellRect, o), p(o.scrollElement, s)) : c && i !== null && s !== null && o.scrollElement && o.activeCellRect && i.cell.row === s.row && i.cell.col === s.col && !l(e?.activeCellRect ?? null, o.activeCellRect) && (Date.now() > i.until || Math.abs(o.scrollElement.scrollLeft - i.left) > 1 ? d() : (r(o.scrollElement, o.activeCellRect, o), i = {
104
- ...i,
105
- left: o.scrollElement.scrollLeft
103
+ let r = t, { activeCell: c } = a, l = r !== null && c !== null && r.row === c.row && r.col === c.col;
104
+ t = c, !l && c !== null && a.isRowFollowMove?.(c) === !0 ? s() : !l && a.scrollElement && a.activeCellRect && c ? (i(a.scrollElement, a.activeCellRect, a), o(a.scrollElement, a.activeCellRect, a), p(a.scrollElement, c)) : l && n !== null && c !== null && a.scrollElement && a.activeCellRect && n.cell.row === c.row && n.cell.col === c.col && !u(e?.activeCellRect ?? null, a.activeCellRect) && (Date.now() > n.until || Math.abs(a.scrollElement.scrollLeft - n.left) > 1 ? s() : (i(a.scrollElement, a.activeCellRect, a), n = {
105
+ ...n,
106
+ left: a.scrollElement.scrollLeft
106
107
  }));
107
108
  }
108
- e = o;
109
+ e = a;
109
110
  },
110
- cancelFollow: d,
111
- dispose: d
111
+ cancelFollow: s,
112
+ dispose: s
112
113
  };
113
114
  };
114
115
  //#endregion
115
- export { n as clampScrollToContent, o as createScrollScaleAnchor, d as createViewportSyncController, a as revealActiveCellInPage, r as scrollCellIntoView };
116
+ export { r as clampScrollToContent, s as createScrollScaleAnchor, f as createViewportSyncController, o as revealActiveCellInPage, i as scrollCellIntoView };
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../logic/checkboxEditor.cjs"),r=require("../logic/editorValues.cjs"),i=require("../logic/validation.cjs"),a=require("../controllers/liveUiState.cjs"),o=require("../controllers/keyboardController.cjs"),s=require("../logic/clearCells.cjs");var c=(e,t,n,a,o)=>{let{rows:s,rowModel:c,handleRowsChange:l,applyServerSideCellEdits:u}=e;if(i.decideCellWrite(a,n,o).action===`reject`)return;if(u){u([{viewIndex:t,column:a,value:o}]);return}if(!l)return;let d=c.getSourceIndex(t);d!==void 0&&l(r.writeRowsCell(s,d,a,o))},l=()=>{let r=null,i=e=>{r=e},l=(e,n,r,i,a)=>t.isViewCellEditable({readOnly:e.readOnly,canEditCell:e.canEditCell},e.rowModel,n,r,i,a),u=e=>{if(r===null)return!1;let n=r.rowModel.getRow(e.row),i=r.orderedColumns[e.col];return!n||!i||!l(r,e.row,e.col,n,i)||i.editor?.type===`checkbox`?!1:(r.startEditWithValue(e,String(t.getCellValue(n,i)??``)),!0)},d=(e,t,n,i)=>{r!==null&&c(r,e,t,n,i)};return{update:i,tryStartEdit:u,toggleCheckbox:e=>{if(r===null)return;let{rowModel:i,orderedColumns:a,handleRowsChange:o,applyServerSideCellEdits:s}=r;if(!o&&!s)return;let c=i.getRow(e.row),u=a[e.col];!c||!u||u.editor?.type!==`checkbox`||!l(r,e.row,e.col,c,u)||d(e.row,c,u,n.toggleCheckboxValue(t.getCellValue(c,u),u.editor))},writeCellValue:d,clearSelectedCells:()=>{if(r===null)return;let e=r,{rows:t,rowModel:n,orderedColumns:i,handleRowsChange:o,applyServerSideCellEdits:c}=e,{selection:u,activeCell:d}=a.readLiveUiState(e),f=n.getRowCount();if(c){let t=s.buildClearCellEdits({getRow:e=>n.getRow(e),columns:i,selection:u,activeCell:d,viewRowCount:f,canWriteCell:(t,n,r,i)=>l(e,t,n,r,i)});t.length>0&&c(t);return}if(!o)return;let{nextRows:p,changed:m}=s.clearCellsInSelection({rows:t,resolveSourceIndex:e=>n.getSourceIndex(e),columns:i,selection:u,activeCell:d,viewRowCount:f,canWriteCell:(t,n,r,i,a)=>l(e,a,n,r,i)});m&&o(p)},selectEntireGrid:()=>{if(r===null)return;let{rowModel:t,orderedColumns:n,dispatch:i}=r,a=t.getRowCount();a===0||n.length===0||(i(e.gridActions.startSelection({row:0,col:0})),i(e.gridActions.updateSelection({row:a-1,col:n.length-1})),i(e.gridActions.endSelection()),i(e.gridActions.activateCell(o.resolveFirstDataCell(t,n))))}}};exports.createCellCommands=l,exports.writeCellValueTo=c;
@@ -0,0 +1,27 @@
1
+ import { type GridUiAction } from '../model/gridActions.js';
2
+ import type { CellCoord, GridColumn, GridUiState, RowModel, SpreadsheetGridProps } from '../model/gridTypes.unbound.js';
3
+ import type { ServerSideCellEditInput } from '../logic/serverSideEdits.js';
4
+ export type CellCommandsArgs<T extends object> = {
5
+ rows: T[];
6
+ rowModel: RowModel<T>;
7
+ orderedColumns: GridColumn<T>[];
8
+ uiState: GridUiState;
9
+ getUiState?: (() => GridUiState) | undefined;
10
+ readOnly: boolean;
11
+ canEditCell: SpreadsheetGridProps<T>['canEditCell'];
12
+ handleRowsChange: ((nextRows: T[]) => void) | undefined;
13
+ applyServerSideCellEdits: ((edits: ServerSideCellEditInput<T>[]) => number) | undefined;
14
+ startEditWithValue: (cell: CellCoord, initialValue: string) => void;
15
+ dispatch: (action: GridUiAction) => void;
16
+ };
17
+ export type CellWriteTarget<T extends object> = Pick<CellCommandsArgs<T>, 'rows' | 'rowModel' | 'handleRowsChange' | 'applyServerSideCellEdits'>;
18
+ export declare const writeCellValueTo: <T extends object>(target: CellWriteTarget<T>, viewIndex: number, row: T, column: GridColumn<T>, nextValue: unknown) => void;
19
+ export type CellCommands<T extends object> = {
20
+ update: (args: CellCommandsArgs<T>) => void;
21
+ tryStartEdit: (cell: CellCoord) => boolean;
22
+ toggleCheckbox: (cell: CellCoord) => void;
23
+ writeCellValue: (viewIndex: number, row: T, column: GridColumn<T>, nextValue: unknown) => void;
24
+ clearSelectedCells: () => void;
25
+ selectEntireGrid: () => void;
26
+ };
27
+ export declare const createCellCommands: <T extends object>() => CellCommands<T>;
@@ -0,0 +1,89 @@
1
+ import { gridActions as e } from "../model/gridActions.js";
2
+ import { getCellValue as t, isViewCellEditable as n } from "../utils/permissions.js";
3
+ import { toggleCheckboxValue as r } from "../logic/checkboxEditor.js";
4
+ import { writeRowsCell as i } from "../logic/editorValues.js";
5
+ import { decideCellWrite as a } from "../logic/validation.js";
6
+ import { readLiveUiState as o } from "../controllers/liveUiState.js";
7
+ import { resolveFirstDataCell as s } from "../controllers/keyboardController.js";
8
+ import { buildClearCellEdits as c, clearCellsInSelection as l } from "../logic/clearCells.js";
9
+ //#region src/engine/cellCommands.ts
10
+ var u = (e, t, n, r, o) => {
11
+ let { rows: s, rowModel: c, handleRowsChange: l, applyServerSideCellEdits: u } = e;
12
+ if (a(r, n, o).action === "reject") return;
13
+ if (u) {
14
+ u([{
15
+ viewIndex: t,
16
+ column: r,
17
+ value: o
18
+ }]);
19
+ return;
20
+ }
21
+ if (!l) return;
22
+ let d = c.getSourceIndex(t);
23
+ d !== void 0 && l(i(s, d, r, o));
24
+ }, d = () => {
25
+ let i = null, a = (e) => {
26
+ i = e;
27
+ }, d = (e, t, r, i, a) => n({
28
+ readOnly: e.readOnly,
29
+ canEditCell: e.canEditCell
30
+ }, e.rowModel, t, r, i, a), f = (e) => {
31
+ if (i === null) return !1;
32
+ let n = i.rowModel.getRow(e.row), r = i.orderedColumns[e.col];
33
+ return !n || !r || !d(i, e.row, e.col, n, r) || r.editor?.type === "checkbox" ? !1 : (i.startEditWithValue(e, String(t(n, r) ?? "")), !0);
34
+ }, p = (e, t, n, r) => {
35
+ i !== null && u(i, e, t, n, r);
36
+ };
37
+ return {
38
+ update: a,
39
+ tryStartEdit: f,
40
+ toggleCheckbox: (e) => {
41
+ if (i === null) return;
42
+ let { rowModel: n, orderedColumns: a, handleRowsChange: o, applyServerSideCellEdits: s } = i;
43
+ if (!o && !s) return;
44
+ let c = n.getRow(e.row), l = a[e.col];
45
+ !c || !l || l.editor?.type !== "checkbox" || !d(i, e.row, e.col, c, l) || p(e.row, c, l, r(t(c, l), l.editor));
46
+ },
47
+ writeCellValue: p,
48
+ clearSelectedCells: () => {
49
+ if (i === null) return;
50
+ let e = i, { rows: t, rowModel: n, orderedColumns: r, handleRowsChange: a, applyServerSideCellEdits: s } = e, { selection: u, activeCell: f } = o(e), p = n.getRowCount();
51
+ if (s) {
52
+ let t = c({
53
+ getRow: (e) => n.getRow(e),
54
+ columns: r,
55
+ selection: u,
56
+ activeCell: f,
57
+ viewRowCount: p,
58
+ canWriteCell: (t, n, r, i) => d(e, t, n, r, i)
59
+ });
60
+ t.length > 0 && s(t);
61
+ return;
62
+ }
63
+ if (!a) return;
64
+ let { nextRows: m, changed: h } = l({
65
+ rows: t,
66
+ resolveSourceIndex: (e) => n.getSourceIndex(e),
67
+ columns: r,
68
+ selection: u,
69
+ activeCell: f,
70
+ viewRowCount: p,
71
+ canWriteCell: (t, n, r, i, a) => d(e, a, n, r, i)
72
+ });
73
+ h && a(m);
74
+ },
75
+ selectEntireGrid: () => {
76
+ if (i === null) return;
77
+ let { rowModel: t, orderedColumns: n, dispatch: r } = i, a = t.getRowCount();
78
+ a === 0 || n.length === 0 || (r(e.startSelection({
79
+ row: 0,
80
+ col: 0
81
+ })), r(e.updateSelection({
82
+ row: a - 1,
83
+ col: n.length - 1
84
+ })), r(e.endSelection()), r(e.activateCell(s(t, n))));
85
+ }
86
+ };
87
+ };
88
+ //#endregion
89
+ export { d as createCellCommands, u as writeCellValueTo };