@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.
- package/dist/controllers/activeRowFollowController.cjs +1 -0
- package/dist/controllers/activeRowFollowController.d.ts +18 -0
- package/dist/controllers/activeRowFollowController.js +68 -0
- package/dist/controllers/autoHeightMeasurer.cjs +1 -1
- package/dist/controllers/autoHeightMeasurer.js +17 -17
- package/dist/controllers/clipboardController.cjs +1 -1
- package/dist/controllers/clipboardController.d.ts +2 -0
- package/dist/controllers/clipboardController.js +74 -64
- package/dist/controllers/columnAutosizeRunner.cjs +1 -1
- package/dist/controllers/columnAutosizeRunner.js +10 -10
- package/dist/controllers/contextMenuController.cjs +1 -1
- package/dist/controllers/contextMenuController.d.ts +1 -0
- package/dist/controllers/contextMenuController.js +12 -7
- package/dist/controllers/detailRowController.cjs +1 -0
- package/dist/controllers/detailRowController.d.ts +41 -0
- package/dist/controllers/detailRowController.js +96 -0
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.d.ts +1 -0
- package/dist/controllers/editController.js +106 -99
- package/dist/controllers/fillHandleController.cjs +1 -1
- package/dist/controllers/fillHandleController.js +78 -78
- package/dist/controllers/filterPopoverController.cjs +1 -1
- package/dist/controllers/filterPopoverController.js +6 -6
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +1 -0
- package/dist/controllers/findController.js +16 -15
- package/dist/controllers/imeInputController.cjs +1 -1
- package/dist/controllers/imeInputController.js +65 -54
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +1 -0
- package/dist/controllers/keyboardController.js +113 -111
- package/dist/controllers/liveUiState.cjs +1 -0
- package/dist/controllers/liveUiState.d.ts +7 -0
- package/dist/controllers/liveUiState.js +4 -0
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.d.ts +1 -0
- package/dist/controllers/pointerInteractionsController.js +157 -156
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +1 -0
- package/dist/controllers/rowDragController.js +117 -104
- package/dist/controllers/scrollSyncController.cjs +1 -1
- package/dist/controllers/scrollSyncController.js +45 -43
- package/dist/controllers/serverSideRowModel.cjs +1 -1
- package/dist/controllers/serverSideRowModel.js +19 -19
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.d.ts +1 -0
- package/dist/controllers/viewportSyncController.js +1 -1
- package/dist/engine/cellCommands.cjs +1 -0
- package/dist/engine/cellCommands.d.ts +27 -0
- package/dist/engine/cellCommands.js +89 -0
- package/dist/engine/columnCommands.cjs +1 -1
- package/dist/engine/columnCommands.js +113 -113
- package/dist/engine/createGridEngine.cjs +3 -3
- package/dist/engine/createGridEngine.d.ts +2 -0
- package/dist/engine/createGridEngine.js +72 -70
- package/dist/engine/exportCommands.cjs +1 -1
- package/dist/engine/exportCommands.js +4 -2
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +6 -6
- package/dist/engine/gridApi.cjs +6 -6
- package/dist/engine/gridApi.d.ts +4 -0
- package/dist/engine/gridApi.js +208 -192
- package/dist/engine/notifiers.cjs +1 -1
- package/dist/engine/notifiers.d.ts +4 -0
- package/dist/engine/notifiers.js +7 -7
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +2 -0
- package/dist/logic/cellPlacement.cjs +1 -0
- package/dist/logic/cellPlacement.d.ts +22 -0
- package/dist/logic/cellPlacement.js +44 -0
- package/dist/logic/density.cjs +1 -0
- package/dist/logic/density.d.ts +5 -0
- package/dist/logic/density.js +17 -0
- package/dist/logic/detailRow.cjs +1 -1
- package/dist/logic/detailRow.d.ts +4 -0
- package/dist/logic/detailRow.js +10 -7
- package/dist/logic/domGuards.cjs +1 -1
- package/dist/logic/domGuards.d.ts +5 -0
- package/dist/logic/domGuards.js +8 -2
- package/dist/logic/editorKeys.cjs +1 -0
- package/dist/logic/editorKeys.d.ts +30 -0
- package/dist/logic/editorKeys.js +34 -0
- package/dist/logic/editorStart.cjs +1 -0
- package/dist/logic/editorStart.d.ts +7 -0
- package/dist/logic/editorStart.js +23 -0
- package/dist/logic/exportCsv.cjs +2 -2
- package/dist/logic/exportCsv.d.ts +2 -1
- package/dist/logic/exportCsv.js +13 -13
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +2 -1
- package/dist/logic/exportData.js +18 -18
- package/dist/logic/geometry.cjs +1 -1
- package/dist/logic/geometry.d.ts +2 -0
- package/dist/logic/geometry.js +41 -20
- package/dist/logic/gridBarSummary.cjs +1 -0
- package/dist/logic/gridBarSummary.d.ts +27 -0
- package/dist/logic/gridBarSummary.js +137 -0
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +3 -2
- package/dist/logic/gridState.js +32 -23
- package/dist/logic/grouping.cjs +1 -1
- package/dist/logic/grouping.js +1 -1
- package/dist/logic/imeInput.cjs +1 -1
- package/dist/logic/imeInput.js +6 -4
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +4 -0
- package/dist/logic/localeTextFeatures.js +8 -5
- package/dist/logic/pasteFill.cjs +1 -0
- package/dist/logic/pasteFill.d.ts +2 -0
- package/dist/logic/pasteFill.js +25 -0
- package/dist/logic/selectEditorState.cjs +1 -1
- package/dist/logic/selectEditorState.d.ts +28 -2
- package/dist/logic/selectEditorState.js +29 -14
- package/dist/logic/selectionAggregates.cjs +1 -1
- package/dist/logic/selectionAggregates.js +2 -3
- package/dist/logic/validation.cjs +1 -1
- package/dist/logic/validation.d.ts +1 -1
- package/dist/logic/validation.js +21 -21
- package/dist/model/gridActions.cjs +1 -1
- package/dist/model/gridActions.d.ts +13 -0
- package/dist/model/gridActions.js +11 -0
- package/dist/model/gridReducer.cjs +1 -1
- package/dist/model/gridReducer.js +128 -65
- package/dist/model/gridTypes.core.d.ts +172 -26
- package/dist/utils/editorVisibleBounds.cjs +1 -0
- package/dist/utils/editorVisibleBounds.d.ts +10 -0
- package/dist/utils/editorVisibleBounds.js +40 -0
- package/dist/utils/errorBubblePlacement.cjs +1 -0
- package/dist/utils/errorBubblePlacement.d.ts +8 -0
- package/dist/utils/errorBubblePlacement.js +26 -0
- package/dist/utils/gridVisibleBand.cjs +1 -0
- package/dist/utils/gridVisibleBand.d.ts +4 -0
- package/dist/utils/gridVisibleBand.js +24 -0
- package/dist/utils/multilineEditor.cjs +2 -0
- package/dist/utils/multilineEditor.d.ts +7 -0
- package/dist/utils/multilineEditor.js +22 -0
- package/dist/utils/scrollBottom.cjs +1 -0
- package/dist/utils/scrollBottom.d.ts +1 -0
- package/dist/utils/scrollBottom.js +4 -0
- package/dist/utils/topAlignedInput.cjs +1 -0
- package/dist/utils/topAlignedInput.d.ts +3 -0
- package/dist/utils/topAlignedInput.js +23 -0
- 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
|
|
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
|
-
},
|
|
13
|
-
let e = null,
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
let
|
|
17
|
-
if (!
|
|
18
|
-
let
|
|
19
|
-
if (!
|
|
20
|
-
let
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
39
|
+
p = null;
|
|
29
40
|
return;
|
|
30
41
|
}
|
|
31
|
-
let t = e.activeCell,
|
|
32
|
-
|
|
42
|
+
let t = e.activeCell, n = e.canStartEdit(t);
|
|
43
|
+
p = {
|
|
33
44
|
cell: t,
|
|
34
|
-
allowed:
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
let n =
|
|
38
|
-
|
|
39
|
-
let r =
|
|
40
|
-
if (
|
|
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 =
|
|
55
|
+
let i = l.value || t.data || "";
|
|
45
56
|
queueMicrotask(() => {
|
|
46
|
-
let t =
|
|
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
|
-
|
|
57
|
-
|
|
67
|
+
m = !0, e.startEdit(n.cell, r), requestAnimationFrame(() => {
|
|
68
|
+
m && e !== null && !e.editing && (m = !1, x());
|
|
58
69
|
});
|
|
59
70
|
});
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
if (e.target !==
|
|
64
|
-
let n =
|
|
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
|
-
|
|
77
|
+
h = !0;
|
|
67
78
|
try {
|
|
68
79
|
n.focus({ preventScroll: !0 });
|
|
69
80
|
} finally {
|
|
70
|
-
|
|
81
|
+
h = !1;
|
|
71
82
|
}
|
|
72
83
|
}
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
},
|
|
78
|
-
typeof document > "u" ||
|
|
79
|
-
},
|
|
80
|
-
|
|
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 (
|
|
87
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
107
|
+
A(null), O(null), k(!1), p = null, m = !1, e = null;
|
|
97
108
|
}
|
|
98
109
|
};
|
|
99
110
|
};
|
|
100
111
|
//#endregion
|
|
101
|
-
export {
|
|
112
|
+
export { o as IME_INPUT_COMPOSING_CLASS, l as createImeInputController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../
|
|
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;
|
|
@@ -1,220 +1,222 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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 {
|
|
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
|
|
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
|
-
},
|
|
14
|
-
row:
|
|
15
|
-
col:
|
|
16
|
-
}),
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
},
|
|
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
|
|
22
|
-
},
|
|
23
|
-
if (
|
|
24
|
-
let {
|
|
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
|
|
27
|
-
|
|
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
|
-
|
|
31
|
-
},
|
|
32
|
-
if (
|
|
33
|
-
let { rowModel: e, visibleColumns:
|
|
34
|
-
if (e.getRowCount() === 0 ||
|
|
35
|
-
let r =
|
|
36
|
-
return
|
|
37
|
-
},
|
|
38
|
-
let
|
|
39
|
-
return e &&
|
|
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
|
-
},
|
|
44
|
-
if (
|
|
45
|
-
let { rowModel: a, visibleColumns: o } =
|
|
46
|
-
if (s === 0 || o.length === 0 ||
|
|
47
|
-
let c =
|
|
48
|
-
|
|
49
|
-
let
|
|
50
|
-
row:
|
|
51
|
-
col: r(c.col +
|
|
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
|
-
|
|
54
|
-
},
|
|
55
|
-
if (
|
|
56
|
-
let {
|
|
57
|
-
if (
|
|
58
|
-
let s =
|
|
59
|
-
row:
|
|
60
|
-
col:
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
row:
|
|
64
|
-
col: r(
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
let a =
|
|
68
|
-
return
|
|
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:
|
|
73
|
+
update: g,
|
|
72
74
|
handleKeyDown: async (r) => {
|
|
73
|
-
if (
|
|
74
|
-
let {
|
|
75
|
-
if (o(r.target) ||
|
|
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
|
|
79
|
+
r.preventDefault(), await x();
|
|
78
80
|
return;
|
|
79
81
|
}
|
|
80
|
-
if ((r.ctrlKey || r.metaKey) && r.key.toLowerCase() === "f" &&
|
|
81
|
-
r.preventDefault(),
|
|
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(),
|
|
86
|
-
|
|
87
|
+
if (r.preventDefault(), I) {
|
|
88
|
+
y(e.clearSelection()), y(e.activateCell(null));
|
|
87
89
|
return;
|
|
88
90
|
}
|
|
89
|
-
|
|
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 ?
|
|
96
|
+
r.preventDefault(), r.shiftKey ? k() : O();
|
|
95
97
|
return;
|
|
96
98
|
}
|
|
97
99
|
if (r.key.toLowerCase() === "y" && !r.shiftKey) {
|
|
98
|
-
r.preventDefault(),
|
|
100
|
+
r.preventDefault(), k();
|
|
99
101
|
return;
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
|
-
let
|
|
103
|
-
if ((r.key === "ContextMenu" || r.key === "F10" && r.shiftKey) && !
|
|
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 && !
|
|
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 (
|
|
113
|
+
if (L && !r.altKey && (r.key === "ArrowUp" || r.key === "ArrowDown")) {
|
|
112
114
|
r.preventDefault();
|
|
113
115
|
let e = r.key === "ArrowDown";
|
|
114
|
-
|
|
115
|
-
row: e ?
|
|
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 (
|
|
122
|
+
if (L && !r.altKey && (r.key === "ArrowLeft" || r.key === "ArrowRight")) {
|
|
121
123
|
r.preventDefault();
|
|
122
124
|
let e = r.key === "ArrowRight";
|
|
123
|
-
|
|
125
|
+
C((t, n, r) => ({
|
|
124
126
|
row: t.row,
|
|
125
|
-
col: e ? r.length - 1 :
|
|
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
|
-
|
|
133
|
-
row:
|
|
134
|
-
col: e ? r.length - 1 :
|
|
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") && !
|
|
139
|
-
if (r.preventDefault(),
|
|
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
|
-
|
|
142
|
-
row:
|
|
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(),
|
|
150
|
+
r.preventDefault(), S(-1, 0, r.shiftKey);
|
|
149
151
|
return;
|
|
150
152
|
}
|
|
151
153
|
if (r.key === "ArrowDown") {
|
|
152
|
-
r.preventDefault(),
|
|
154
|
+
r.preventDefault(), S(1, 0, r.shiftKey);
|
|
153
155
|
return;
|
|
154
156
|
}
|
|
155
157
|
if (r.key === "ArrowLeft") {
|
|
156
|
-
r.preventDefault(),
|
|
158
|
+
r.preventDefault(), S(0, -1, r.shiftKey);
|
|
157
159
|
return;
|
|
158
160
|
}
|
|
159
161
|
if (r.key === "ArrowRight") {
|
|
160
|
-
r.preventDefault(),
|
|
162
|
+
r.preventDefault(), S(0, 1, r.shiftKey);
|
|
161
163
|
return;
|
|
162
164
|
}
|
|
163
165
|
if (r.key === "Tab") {
|
|
164
|
-
if (!
|
|
165
|
-
if (
|
|
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 =
|
|
170
|
-
if (r.shiftKey ? e <=
|
|
171
|
-
!r.shiftKey &&
|
|
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(),
|
|
176
|
+
r.preventDefault(), S(0, r.shiftKey ? -1 : 1, !1);
|
|
175
177
|
return;
|
|
176
178
|
}
|
|
177
179
|
if (r.key === "Escape") {
|
|
178
|
-
|
|
180
|
+
u(F.selection) && r.preventDefault(), y(e.clearSelection());
|
|
179
181
|
return;
|
|
180
182
|
}
|
|
181
|
-
if ((r.key === "Delete" || r.key === "Backspace") &&
|
|
182
|
-
r.preventDefault(),
|
|
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 === " ") &&
|
|
186
|
-
let e =
|
|
187
|
+
if ((r.key === "Enter" || r.key === " ") && F.activeCell) {
|
|
188
|
+
let e = d.getGroupRow?.(F.activeCell.row);
|
|
187
189
|
if (e) {
|
|
188
|
-
r.preventDefault(),
|
|
190
|
+
r.preventDefault(), N(e.groupKey);
|
|
189
191
|
return;
|
|
190
192
|
}
|
|
191
|
-
if (
|
|
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(),
|
|
198
|
-
|
|
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) &&
|
|
205
|
-
let
|
|
206
|
-
if (!
|
|
207
|
-
readOnly:
|
|
208
|
-
canEditCell:
|
|
209
|
-
},
|
|
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 === " " &&
|
|
213
|
+
r.preventDefault(), r.key === " " && M(F.activeCell);
|
|
212
214
|
return;
|
|
213
215
|
}
|
|
214
|
-
r.preventDefault(),
|
|
216
|
+
r.preventDefault(), _(r.key), y(e.startEdit(F.activeCell));
|
|
215
217
|
}
|
|
216
218
|
}
|
|
217
219
|
};
|
|
218
220
|
};
|
|
219
221
|
//#endregion
|
|
220
|
-
export {
|
|
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;
|