@ishibashi0112/spreadsheet-grid-core 1.0.2 → 1.2.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.
- 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 +4 -0
- package/dist/controllers/clipboardController.js +82 -54
- package/dist/controllers/columnAutosizeRunner.cjs +1 -1
- package/dist/controllers/columnAutosizeRunner.d.ts +1 -0
- package/dist/controllers/columnAutosizeRunner.js +17 -16
- package/dist/controllers/columnHeaderDragController.cjs +1 -1
- package/dist/controllers/columnHeaderDragController.js +169 -168
- package/dist/controllers/columnMenuController.cjs +1 -1
- package/dist/controllers/columnMenuController.js +71 -69
- package/dist/controllers/contextMenuController.cjs +1 -1
- package/dist/controllers/contextMenuController.d.ts +5 -1
- package/dist/controllers/contextMenuController.js +62 -40
- 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.d.ts +1 -0
- package/dist/controllers/fillHandleController.js +157 -157
- 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/historyController.cjs +1 -1
- package/dist/controllers/historyController.d.ts +6 -0
- package/dist/controllers/historyController.js +79 -37
- 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 +46 -42
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.d.ts +1 -0
- package/dist/controllers/pointerInteractionsController.js +172 -172
- package/dist/controllers/popoverSupport.cjs +1 -1
- package/dist/controllers/popoverSupport.d.ts +1 -0
- package/dist/controllers/popoverSupport.js +9 -4
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +2 -0
- package/dist/controllers/rowDragController.js +160 -146
- 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/toolPanelController.cjs +1 -1
- package/dist/controllers/toolPanelController.js +26 -14
- package/dist/controllers/tooltipController.cjs +1 -1
- package/dist/controllers/tooltipController.js +74 -72
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.d.ts +4 -1
- package/dist/controllers/viewportSyncController.js +66 -28
- 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 +18 -9
- 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 +8 -2
- package/dist/engine/gridApi.js +197 -187
- 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 +3 -1
- package/dist/index.js +7 -6
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +5 -0
- package/dist/logic/autoScrollGeometry.cjs +1 -1
- package/dist/logic/autoScrollGeometry.d.ts +2 -0
- package/dist/logic/autoScrollGeometry.js +3 -3
- package/dist/logic/editorValues.cjs +1 -1
- package/dist/logic/editorValues.js +37 -34
- package/dist/logic/exportCsv.cjs +3 -3
- package/dist/logic/exportCsv.d.ts +4 -1
- package/dist/logic/exportCsv.js +22 -20
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +4 -1
- package/dist/logic/exportData.js +40 -36
- package/dist/logic/filtering.cjs +1 -1
- package/dist/logic/filtering.d.ts +2 -1
- package/dist/logic/filtering.js +16 -3
- 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/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +3 -2
- package/dist/logic/gridState.js +32 -23
- package/dist/logic/groupExport.cjs +1 -1
- package/dist/logic/groupExport.js +28 -27
- package/dist/logic/grouping.cjs +1 -1
- package/dist/logic/grouping.d.ts +1 -0
- package/dist/logic/grouping.js +52 -41
- package/dist/logic/historyRebase.cjs +1 -0
- package/dist/logic/historyRebase.d.ts +5 -0
- package/dist/logic/historyRebase.js +36 -0
- 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 +8 -0
- package/dist/logic/localeTextFeatures.js +11 -5
- package/dist/logic/localeTextPopups.cjs +1 -1
- package/dist/logic/localeTextPopups.d.ts +1 -0
- package/dist/logic/localeTextPopups.js +1 -0
- 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 +4 -1
- package/dist/logic/selectEditorState.js +14 -14
- package/dist/logic/selectLabels.cjs +1 -0
- package/dist/logic/selectLabels.d.ts +3 -0
- package/dist/logic/selectLabels.js +41 -0
- 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/logic/valueParsers.cjs +1 -0
- package/dist/logic/valueParsers.d.ts +14 -0
- package/dist/logic/valueParsers.js +23 -0
- 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 +345 -43
- package/dist/utils/clipboard.cjs +4 -4
- package/dist/utils/clipboard.d.ts +14 -2
- package/dist/utils/clipboard.js +101 -49
- 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/popupContainer.cjs +1 -0
- package/dist/utils/popupContainer.d.ts +8 -0
- package/dist/utils/popupContainer.js +60 -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,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { isSyntheticColumnKey as e } from "../logic/detailRow.js";
|
|
2
|
+
import { createValueStore as t } from "../logic/valueStore.js";
|
|
3
|
+
import { runChunked as n } from "../logic/chunkedLoop.js";
|
|
4
4
|
import { buildFindIndex as r, findRangesInText as i, isFindableColumn as a, resolveCurrentAfterRescan as o, resolveFindCellText as s, stepFindIndex as c } from "../logic/find.js";
|
|
5
5
|
//#region src/controllers/findController.ts
|
|
6
6
|
var l = 1e4, u = 5e4, d = /* @__PURE__ */ new Map(), f = [], p = (e, t) => e.length === t.length && e.every((e, n) => {
|
|
7
7
|
let r = t[n];
|
|
8
8
|
return e.rowIndex === r.rowIndex && e.colIndex === r.colIndex && e.columnKey === r.columnKey && e.start === r.start && e.length === r.length;
|
|
9
9
|
}), m = () => {
|
|
10
|
-
let l = null, m = 0, h = null, g = !1, _ = null, v =
|
|
10
|
+
let l = null, m = 0, h = null, g = !1, _ = null, v = t({
|
|
11
11
|
open: !1,
|
|
12
12
|
query: "",
|
|
13
13
|
matches: [],
|
|
@@ -25,9 +25,10 @@ var l = 1e4, u = 5e4, d = /* @__PURE__ */ new Map(), f = [], p = (e, t) => e.len
|
|
|
25
25
|
query: e.query,
|
|
26
26
|
matchCount: e.matches.length,
|
|
27
27
|
currentIndex: e.currentIndex,
|
|
28
|
-
open: e.open
|
|
28
|
+
open: e.open,
|
|
29
|
+
truncated: e.truncated
|
|
29
30
|
};
|
|
30
|
-
b !== null && b.query === t.query && b.matchCount === t.matchCount && b.currentIndex === t.currentIndex && b.open === t.open || (b = t, l?.onChange?.(t));
|
|
31
|
+
b !== null && b.query === t.query && b.matchCount === t.matchCount && b.currentIndex === t.currentIndex && b.open === t.open && b.truncated === t.truncated || (b = t, l?.onChange?.(t));
|
|
31
32
|
}, S = () => {
|
|
32
33
|
let e = v.getSnapshot();
|
|
33
34
|
if (e.currentIndex === null) return;
|
|
@@ -41,7 +42,7 @@ var l = 1e4, u = 5e4, d = /* @__PURE__ */ new Map(), f = [], p = (e, t) => e.len
|
|
|
41
42
|
scanning: !1,
|
|
42
43
|
truncated: !1
|
|
43
44
|
});
|
|
44
|
-
}, w = (
|
|
45
|
+
}, w = (t, c = !1) => {
|
|
45
46
|
let d = l, b = v.getSnapshot();
|
|
46
47
|
if (!d || !b.open || b.query.length === 0) {
|
|
47
48
|
C(), x();
|
|
@@ -62,16 +63,16 @@ var l = 1e4, u = 5e4, d = /* @__PURE__ */ new Map(), f = [], p = (e, t) => e.len
|
|
|
62
63
|
conditionalFormatShown: k,
|
|
63
64
|
byRow: /* @__PURE__ */ new WeakMap()
|
|
64
65
|
});
|
|
65
|
-
let M = h.byRow, N = 0, P =
|
|
66
|
+
let M = h.byRow, N = 0, P = t || g;
|
|
66
67
|
g = P;
|
|
67
|
-
let F = b.currentIndex === null ? null : b.matches[b.currentIndex] ?? null, I = [], L = !1, R = E.getRowCount(), z = R > u, B = (
|
|
68
|
+
let F = b.currentIndex === null ? null : b.matches[b.currentIndex] ?? null, I = [], L = !1, R = E.getRowCount(), z = R > u, B = (t, n) => {
|
|
68
69
|
let r = [];
|
|
69
70
|
return D.forEach((o, c) => {
|
|
70
|
-
if (
|
|
71
|
-
let l = s(o,
|
|
72
|
-
rowIndex:
|
|
73
|
-
sourceRowIndex: E.getSourceIndex(
|
|
74
|
-
rowKey: E.getRowKey(
|
|
71
|
+
if (e(o.key) || !a(o, k)) return;
|
|
72
|
+
let l = s(o, t, !k || o.conditionalFormat?.chips === void 0 ? void 0 : {
|
|
73
|
+
rowIndex: n,
|
|
74
|
+
sourceRowIndex: E.getSourceIndex(n) ?? n,
|
|
75
|
+
rowKey: E.getRowKey(n) ?? n,
|
|
75
76
|
colIndex: c
|
|
76
77
|
});
|
|
77
78
|
for (let e of i(l, A, O)) r.push({
|
|
@@ -82,7 +83,7 @@ var l = 1e4, u = 5e4, d = /* @__PURE__ */ new Map(), f = [], p = (e, t) => e.len
|
|
|
82
83
|
});
|
|
83
84
|
}), r.length === 0 ? f : r;
|
|
84
85
|
};
|
|
85
|
-
!j && !b.scanning && y({ scanning: !0 }),
|
|
86
|
+
!j && !b.scanning && y({ scanning: !0 }), n(R, (e) => {
|
|
86
87
|
if (L) return;
|
|
87
88
|
let t = E.getRow(e);
|
|
88
89
|
if (t === void 0) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../logic/history.cjs");var
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../logic/historyRebase.cjs"),n=require("../logic/history.cjs");var r=()=>{let r=null,i=n.createHistoryStack(),a=null,o=null,s={canUndo:!1,canRedo:!1},c=null,l=!1,u=()=>r!==null&&r.enabled&&r.onRowsChange!=null,d=()=>u()&&n.canUndoHistory(i),f=()=>u()&&n.canRedoHistory(i),p=()=>{let e={canUndo:d(),canRedo:f()};e.canUndo===s.canUndo&&e.canRedo===s.canRedo||(s=e,r?.onUndoRedoStateChange?.(e))},m=e=>{r=e,e.rows!==o&&(c=null),o===null?o=e.rows:e.rows!==o&&(o=e.rows,a===e.rows?a=null:(a=null,i=n.createHistoryStack(),l=!1)),p()},h=t=>{if(r===null)return;let{dispatch:n}=r,i=t.selection;i?.type===`cell`?(n(e.gridActions.startSelection(i.range.start)),n(e.gridActions.updateSelection(i.range.end)),n(e.gridActions.endSelection())):i?.type===`row`?(n(e.gridActions.startRowSelection(i.startRow)),n(e.gridActions.updateRowSelection(i.endRow)),n(e.gridActions.endSelection())):i?.type===`col`?(n(e.gridActions.startColumnSelection(i.startCol)),n(e.gridActions.updateColumnSelection(i.endCol)),n(e.gridActions.endSelection())):n(e.gridActions.clearSelection()),n(e.gridActions.activateCell(t.activeCell))},g=(e,t)=>{r===null||!r.onRowsChange||(r.enabled&&(i=n.pushHistory(i,{rows:e,after:t,selection:r.selection,activeCell:r.activeCell},r.limit),a=t,p()),c=t,r.onRowsChange(t))},_=e=>{r===null||!r.onRowsChange||g(r.rows,e)},v=e=>{if(!(r===null||!r.onRowsChange)){if(r.enabled){a=e;let t=i.past[i.past.length-1];t&&(i={...i,past:[...i.past.slice(0,-1),{...t,after:e}]})}c=e,r.onRowsChange(e)}},y=(e,t)=>{if(r===null||!r.onRowsChange)return;let n=c??r.rows,i=Array.isArray(e)?e:e(n);if(t?.undoable!==!1){g(n,i);return}r.enabled&&(a=i,l=!0),c=i,r.onRowsChange(i)},b=(e,n)=>{if(!e)return null;if(!l||e.after===n)return e.rows;let i=r?.rowKeyGetter;return!i&&(e.rows.length!==e.after.length||e.after.length!==n.length)?e.rows:t.revertRowsChange(e.rows,e.after,n,i??((e,t)=>t))},x=e=>{e===null||r===null||!r.onRowsChange||(i=e.stack,a=e.snapshot.rows,c=e.snapshot.rows,r.onRowsChange(e.snapshot.rows),h(e.snapshot),r.onAfterRestore?.(e.snapshot.activeCell),p())},S=(e,t)=>r===null?null:{rows:e,after:t,selection:r.selection,activeCell:r.activeCell},C=(e,t)=>{if(!u()||r===null)return;let n=c??r.rows,a=b(e,n),o=a===null?null:S(n,a);if(a===null||o===null)return;let s=t(i,o);x(s===null?null:{stack:s.stack,snapshot:{...s.snapshot,rows:a}})};return{update:m,handleRowsChange:_,amendRowsChange:v,applyRows:y,undo:()=>{C(i.past[i.past.length-1],n.undoHistory)},redo:()=>{C(i.future[i.future.length-1],n.redoHistory)},canUndo:d,canRedo:f,clearHistory:()=>{i=n.createHistoryStack(),l=!1,p()}}};exports.createHistoryController=r;
|
|
@@ -2,9 +2,13 @@ import { type GridUiAction } from '../model/gridActions.js';
|
|
|
2
2
|
import type { CellCoord, GridSelection, UndoRedoState } from '../model/gridTypes.unbound.js';
|
|
3
3
|
export type GridHistoryEntry<T> = {
|
|
4
4
|
rows: T[];
|
|
5
|
+
after: T[];
|
|
5
6
|
selection: GridSelection;
|
|
6
7
|
activeCell: CellCoord | null;
|
|
7
8
|
};
|
|
9
|
+
export type HistoryApplyRowsOptions = {
|
|
10
|
+
undoable?: boolean | undefined;
|
|
11
|
+
};
|
|
8
12
|
export type HistoryControllerArgs<T> = {
|
|
9
13
|
rows: T[];
|
|
10
14
|
selection: GridSelection;
|
|
@@ -15,11 +19,13 @@ export type HistoryControllerArgs<T> = {
|
|
|
15
19
|
limit: number;
|
|
16
20
|
onUndoRedoStateChange?: (state: UndoRedoState) => void;
|
|
17
21
|
onAfterRestore?: (activeCell: CellCoord | null) => void;
|
|
22
|
+
rowKeyGetter?: ((row: T, index: number) => unknown) | undefined;
|
|
18
23
|
};
|
|
19
24
|
export type HistoryController<T> = {
|
|
20
25
|
update: (args: HistoryControllerArgs<T>) => void;
|
|
21
26
|
handleRowsChange: (nextRows: T[]) => void;
|
|
22
27
|
amendRowsChange: (nextRows: T[]) => void;
|
|
28
|
+
applyRows: (next: T[] | ((prev: T[]) => T[]), options?: HistoryApplyRowsOptions) => void;
|
|
23
29
|
undo: () => void;
|
|
24
30
|
redo: () => void;
|
|
25
31
|
canUndo: () => boolean;
|
|
@@ -1,55 +1,97 @@
|
|
|
1
1
|
import { gridActions as e } from "../model/gridActions.js";
|
|
2
|
-
import {
|
|
2
|
+
import { revertRowsChange as t } from "../logic/historyRebase.js";
|
|
3
|
+
import { canRedoHistory as n, canUndoHistory as r, createHistoryStack as i, pushHistory as a, redoHistory as o, undoHistory as s } from "../logic/history.js";
|
|
3
4
|
//#region src/controllers/historyController.ts
|
|
4
|
-
var
|
|
5
|
-
let
|
|
5
|
+
var c = () => {
|
|
6
|
+
let c = null, l = i(), u = null, d = null, f = {
|
|
6
7
|
canUndo: !1,
|
|
7
8
|
canRedo: !1
|
|
8
|
-
},
|
|
9
|
+
}, p = null, m = !1, h = () => c !== null && c.enabled && c.onRowsChange != null, g = () => h() && r(l), _ = () => h() && n(l), v = () => {
|
|
9
10
|
let e = {
|
|
10
|
-
canUndo:
|
|
11
|
-
canRedo:
|
|
11
|
+
canUndo: g(),
|
|
12
|
+
canRedo: _()
|
|
12
13
|
};
|
|
13
|
-
e.canUndo ===
|
|
14
|
-
}, g = (e) => {
|
|
15
|
-
s = e, u === null ? u = e.rows : e.rows !== u && (u = e.rows, l === e.rows ? l = null : (l = null, c = r())), h();
|
|
16
|
-
}, _ = (t) => {
|
|
17
|
-
if (s === null) return;
|
|
18
|
-
let { dispatch: n } = s, r = t.selection;
|
|
19
|
-
r?.type === "cell" ? (n(e.startSelection(r.range.start)), n(e.updateSelection(r.range.end)), n(e.endSelection())) : r?.type === "row" ? (n(e.startRowSelection(r.startRow)), n(e.updateRowSelection(r.endRow)), n(e.endSelection())) : r?.type === "col" ? (n(e.startColumnSelection(r.startCol)), n(e.updateColumnSelection(r.endCol)), n(e.endSelection())) : n(e.clearSelection()), n(e.activateCell(t.activeCell));
|
|
20
|
-
}, v = (e) => {
|
|
21
|
-
s === null || !s.onRowsChange || (s.enabled && (c = i(c, {
|
|
22
|
-
rows: s.rows,
|
|
23
|
-
selection: s.selection,
|
|
24
|
-
activeCell: s.activeCell
|
|
25
|
-
}, s.limit), l = e, h()), s.onRowsChange(e));
|
|
14
|
+
e.canUndo === f.canUndo && e.canRedo === f.canRedo || (f = e, c?.onUndoRedoStateChange?.(e));
|
|
26
15
|
}, y = (e) => {
|
|
27
|
-
|
|
28
|
-
}, b = (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
16
|
+
c = e, e.rows !== d && (p = null), d === null ? d = e.rows : e.rows !== d && (d = e.rows, u === e.rows ? u = null : (u = null, l = i(), m = !1)), v();
|
|
17
|
+
}, b = (t) => {
|
|
18
|
+
if (c === null) return;
|
|
19
|
+
let { dispatch: n } = c, r = t.selection;
|
|
20
|
+
r?.type === "cell" ? (n(e.startSelection(r.range.start)), n(e.updateSelection(r.range.end)), n(e.endSelection())) : r?.type === "row" ? (n(e.startRowSelection(r.startRow)), n(e.updateRowSelection(r.endRow)), n(e.endSelection())) : r?.type === "col" ? (n(e.startColumnSelection(r.startCol)), n(e.updateColumnSelection(r.endCol)), n(e.endSelection())) : n(e.clearSelection()), n(e.activateCell(t.activeCell));
|
|
21
|
+
}, x = (e, t) => {
|
|
22
|
+
c === null || !c.onRowsChange || (c.enabled && (l = a(l, {
|
|
23
|
+
rows: e,
|
|
24
|
+
after: t,
|
|
25
|
+
selection: c.selection,
|
|
26
|
+
activeCell: c.activeCell
|
|
27
|
+
}, c.limit), u = t, v()), p = t, c.onRowsChange(t));
|
|
28
|
+
}, S = (e) => {
|
|
29
|
+
c === null || !c.onRowsChange || x(c.rows, e);
|
|
30
|
+
}, C = (e) => {
|
|
31
|
+
if (!(c === null || !c.onRowsChange)) {
|
|
32
|
+
if (c.enabled) {
|
|
33
|
+
u = e;
|
|
34
|
+
let t = l.past[l.past.length - 1];
|
|
35
|
+
t && (l = {
|
|
36
|
+
...l,
|
|
37
|
+
past: [...l.past.slice(0, -1), {
|
|
38
|
+
...t,
|
|
39
|
+
after: e
|
|
40
|
+
}]
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
p = e, c.onRowsChange(e);
|
|
44
|
+
}
|
|
45
|
+
}, w = (e, t) => {
|
|
46
|
+
if (c === null || !c.onRowsChange) return;
|
|
47
|
+
let n = p ?? c.rows, r = Array.isArray(e) ? e : e(n);
|
|
48
|
+
if (t?.undoable !== !1) {
|
|
49
|
+
x(n, r);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
c.enabled && (u = r, m = !0), p = r, c.onRowsChange(r);
|
|
53
|
+
}, T = (e, n) => {
|
|
54
|
+
if (!e) return null;
|
|
55
|
+
if (!m || e.after === n) return e.rows;
|
|
56
|
+
let r = c?.rowKeyGetter;
|
|
57
|
+
return !r && (e.rows.length !== e.after.length || e.after.length !== n.length) ? e.rows : t(e.rows, e.after, n, r ?? ((e, t) => t));
|
|
58
|
+
}, E = (e) => {
|
|
59
|
+
e === null || c === null || !c.onRowsChange || (l = e.stack, u = e.snapshot.rows, p = e.snapshot.rows, c.onRowsChange(e.snapshot.rows), b(e.snapshot), c.onAfterRestore?.(e.snapshot.activeCell), v());
|
|
60
|
+
}, D = (e, t) => c === null ? null : {
|
|
61
|
+
rows: e,
|
|
62
|
+
after: t,
|
|
63
|
+
selection: c.selection,
|
|
64
|
+
activeCell: c.activeCell
|
|
65
|
+
}, O = (e, t) => {
|
|
66
|
+
if (!h() || c === null) return;
|
|
67
|
+
let n = p ?? c.rows, r = T(e, n), i = r === null ? null : D(n, r);
|
|
68
|
+
if (r === null || i === null) return;
|
|
69
|
+
let a = t(l, i);
|
|
70
|
+
E(a === null ? null : {
|
|
71
|
+
stack: a.stack,
|
|
72
|
+
snapshot: {
|
|
73
|
+
...a.snapshot,
|
|
74
|
+
rows: r
|
|
75
|
+
}
|
|
76
|
+
});
|
|
34
77
|
};
|
|
35
78
|
return {
|
|
36
|
-
update:
|
|
37
|
-
handleRowsChange:
|
|
38
|
-
amendRowsChange:
|
|
79
|
+
update: y,
|
|
80
|
+
handleRowsChange: S,
|
|
81
|
+
amendRowsChange: C,
|
|
82
|
+
applyRows: w,
|
|
39
83
|
undo: () => {
|
|
40
|
-
|
|
41
|
-
!f() || e === null || b(o(c, e));
|
|
84
|
+
O(l.past[l.past.length - 1], s);
|
|
42
85
|
},
|
|
43
86
|
redo: () => {
|
|
44
|
-
|
|
45
|
-
!f() || e === null || b(a(c, e));
|
|
87
|
+
O(l.future[l.future.length - 1], o);
|
|
46
88
|
},
|
|
47
|
-
canUndo:
|
|
48
|
-
canRedo:
|
|
89
|
+
canUndo: g,
|
|
90
|
+
canRedo: _,
|
|
49
91
|
clearHistory: () => {
|
|
50
|
-
|
|
92
|
+
l = i(), m = !1, v();
|
|
51
93
|
}
|
|
52
94
|
};
|
|
53
95
|
};
|
|
54
96
|
//#endregion
|
|
55
|
-
export {
|
|
97
|
+
export { c as createHistoryController };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs"),t=require("../logic/domGuards.cjs");var
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/detailRow.cjs"),t=require("../logic/domGuards.cjs"),n=require("../logic/elementScale.cjs"),r=require("../utils/gridVisibleBand.cjs"),i=require("../utils/topAlignedInput.cjs");var a=24,o=`ssg-ime-input--composing`,s=(t,n,r)=>{let i=t.querySelectorAll(`.ssg-body-row[data-row-index="${n.row}"]`);for(let n of Array.from(i)){if(e.isInsideDetailCardOf(t,n))continue;let i=n.querySelectorAll(`.ssg-body-cell`);for(let e of Array.from(i))if(e.getAttribute(`data-ssg-col-key`)===r)return e}return null},c=(e,t)=>e===t||e!==null&&t!==null&&e.row===t.row&&e.col===t.col,l=()=>{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=()=>{l&&l.ownerDocument.activeElement!==l&&l.focus({preventScroll:!0})},b=(t,o)=>{let c=v(),u=e?.resolveCell(t)??null;if(!l||!c||!u)return!1;let d=s(c,t,u.colKey);if(!d)return!1;let f=c.getBoundingClientRect(),p=d.getBoundingClientRect(),m=n.resolveElementScale(c,f),h=p.top,g=p.bottom;if(o){let e=r.resolveGridVisibleBand(d);if(e!==null){let t=Math.max(h,e.top),n=Math.min(g,e.bottom);n-t>=a*m.y&&(h=t,g=n)}}let _=(g-h)/m.y;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.alignInputTextToTop(l,o&&d.classList.contains(`ssg-body-cell--valign-top`),_),!0},x=()=>{l&&(l.classList.remove(o),l.value=``,l.style.textAlign=``,i.alignInputTextToTop(l,!1,0))},S=t=>{e===null||!e.enabled||e.editing||h||t.target===u&&y()},C=()=>{if(e===null||!e.enabled||e.editing||e.activeCell===null){p=null;return}let t=e.activeCell,n=e.canStartEdit(t);p={cell:t,allowed:n},g=!1,n&&(l?.classList.add(o),b(t,!0),_=t)},w=t=>{let n=p;p=null;let r=g;if(g=!1,!l||n===null||!n.allowed||r){x();return}let i=l.value||t.data||``;queueMicrotask(()=>{let t=l;if(e===null||!e.enabled||!t||i===``||t.ownerDocument.activeElement!==t||!e.canStartEdit(n.cell)){x();return}let r=e.resolveEditText?e.resolveEditText(n.cell,i):i;if(r===null||r===``){x();return}m=!0,e.startEdit(n.cell,r),requestAnimationFrame(()=>{m&&e!==null&&!e.editing&&(m=!1,x())})})},T=()=>{p===null&&!m&&l&&(l.value=``)},E=e=>{if(e.target!==l||e.key!==`Tab`||e.defaultPrevented||t.isImeComposingKeyEvent(e)||document.activeElement!==l)return;let n=v();if(n){h=!0;try{n.focus({preventScroll:!0})}finally{h=!1}}},D=()=>{p!==null&&(g=!0)},O=e=>{u!==e&&(u?.removeEventListener(`focus`,S),u=e,u?.addEventListener(`focus`,S))},k=e=>{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)))},A=e=>{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)))};return{update:t=>{e=t;let n=t.gridRootRef.current;if(O(t.enabled?n:null),A(t.enabled?l:null),k(t.enabled),!t.enabled){p=null,m=!1,x(),l&&n&&l.ownerDocument.activeElement===l&&n.focus({preventScroll:!0});return}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())},attach:t=>{l!==t&&(l=t,A(e?.enabled?l:null),l&&(typeof matchMedia==`function`&&matchMedia(`(pointer: coarse)`).matches&&(l.inputMode=`none`),_=null))},dispose:()=>{A(null),O(null),k(!1),p=null,m=!1,e=null}}};exports.IME_INPUT_COMPOSING_CLASS=o,exports.createImeInputController=l;
|
|
@@ -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("./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=>n.resolveFirstDataColIndex(e),u=(e,t)=>({row:c(e),col:l(t)}),d=()=>{let n=null,d=e=>{n=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=(t,r,i)=>{if(n===null)return;let{uiState:a,dispatch:o}=n;if(i){let n=a.selection?.type===`cell`?a.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))},h=()=>{if(n===null||n.uiState.activeCell)return!1;let{rowModel:e,visibleColumns:t}=n;if(e.getRowCount()===0||t.length===0)return!0;let r=u(e,t);return m(r,r,!1),!0},g=e=>{let t=n?.uiState;return e&&t?.selection?.type===`cell`?t.selection.range.end:t?.activeCell??{row:0,col:0}},_=(e,t,i)=>{if(n===null)return;let{rowModel:a,visibleColumns:o}=n,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+t,0,o.length-1)};m(l,d,i)},v=(e,t)=>{if(n===null)return;let{uiState:i,rowModel:a,visibleColumns:o}=n;if(a.getRowCount()===0||o.length===0)return;let s=i.activeCell?g(t):{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)},t&&i.activeCell!==null)},y=(e,t,i)=>{let a=t.getRowCount(),c=n?.resolvePageRow?n.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(t,l,i,-1);return u>=0?u:s(t,l,i>0?-1:1,e.row)};return{update:d,handleKeyDown:async r=>{if(n===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}=n;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(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 M=r.ctrlKey||r.metaKey;if((r.key===`ContextMenu`||r.key===`F10`&&r.shiftKey)&&!M&&!r.altKey&&o.activeCell&&n.openContextMenu?.(o.activeCell)){r.preventDefault();return}if(r.key===`ArrowDown`&&r.altKey&&!M&&!r.shiftKey&&o.activeCell&&n.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(n.rowModel.getRowCount()===0||n.visibleColumns.length===0)return;r.preventDefault(),h();return}let e=o.activeCell?.col??0;if(r.shiftKey?e<=l(n.visibleColumns):e>=n.visibleColumns.length-1){!r.shiftKey&&o.activeCell&&n.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(e.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 n=s.getRow(o.activeCell.row),i=u[o.activeCell.col];if(!n||!i||!t.isViewCellEditable({readOnly:d,canEditCell:f},s,o.activeCell.row,o.activeCell.col,n,i))return;if(i.editor?.type===`checkbox`){r.preventDefault(),r.key===` `&&k(o.activeCell);return}r.preventDefault(),m(r.key),g(e.gridActions.startEdit(o.activeCell))}}}};exports.createKeyboardController=d,exports.resolveFirstDataCell=u;
|
|
@@ -32,6 +32,7 @@ export type KeyboardControllerArgs<T> = {
|
|
|
32
32
|
onToggleDetailRow?: (cell: CellCoord) => boolean;
|
|
33
33
|
resolvePageRow?: (fromRow: number, direction: 1 | -1) => number;
|
|
34
34
|
openColumnMenu?: (col: number) => boolean;
|
|
35
|
+
openContextMenu?: (cell: CellCoord) => boolean;
|
|
35
36
|
onTabPastLastColumn?: (viewRowIndex: number) => boolean;
|
|
36
37
|
};
|
|
37
38
|
export declare const resolveFirstDataCell: <T>(rowModel: RowModel<T>, visibleColumns: GridColumn<T>[]) => CellCoord;
|