@ishibashi0112/spreadsheet-grid-core 1.9.0 → 1.11.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/changeHighlightController.cjs +1 -1
- package/dist/controllers/changeHighlightController.js +69 -71
- package/dist/controllers/changeTracker.cjs +1 -1
- package/dist/controllers/changeTracker.d.ts +5 -0
- package/dist/controllers/changeTracker.js +342 -168
- package/dist/controllers/clipboardController.cjs +2 -1
- package/dist/controllers/clipboardController.d.ts +5 -1
- package/dist/controllers/clipboardController.js +224 -91
- package/dist/controllers/dateTimeEditorController.cjs +1 -0
- package/dist/controllers/dateTimeEditorController.d.ts +62 -0
- package/dist/controllers/dateTimeEditorController.js +201 -0
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.js +259 -178
- package/dist/controllers/fillHandleController.cjs +1 -1
- package/dist/controllers/fillHandleController.js +188 -186
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +1 -0
- package/dist/controllers/findController.js +27 -25
- package/dist/controllers/historyController.cjs +1 -1
- package/dist/controllers/historyController.d.ts +1 -0
- package/dist/controllers/historyController.js +2 -2
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +4 -0
- package/dist/controllers/keyboardController.js +155 -144
- package/dist/controllers/multiSelectEditorController.cjs +1 -0
- package/dist/controllers/multiSelectEditorController.d.ts +54 -0
- package/dist/controllers/multiSelectEditorController.js +200 -0
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.js +155 -154
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +1 -0
- package/dist/controllers/rowDragController.js +1 -0
- package/dist/controllers/selectOptionsCollector.cjs +1 -1
- package/dist/controllers/selectOptionsCollector.d.ts +2 -1
- package/dist/controllers/selectOptionsCollector.js +53 -52
- package/dist/controllers/tooltipController.cjs +1 -1
- package/dist/controllers/tooltipController.js +6 -1
- package/dist/engine/cellCommands.cjs +1 -1
- package/dist/engine/cellCommands.js +74 -54
- package/dist/engine/createGridEngine.cjs +1 -1
- package/dist/engine/createGridEngine.d.ts +4 -0
- package/dist/engine/createGridEngine.js +36 -34
- package/dist/engine/excelShortcutCommands.cjs +1 -0
- package/dist/engine/excelShortcutCommands.d.ts +29 -0
- package/dist/engine/excelShortcutCommands.js +281 -0
- package/dist/engine/exportCommands.cjs +1 -1
- package/dist/engine/exportCommands.js +3 -1
- package/dist/engine/features.cjs +1 -1
- package/dist/engine/features.d.ts +10 -0
- package/dist/engine/features.js +22 -2
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +16 -12
- package/dist/engine/gridApi.cjs +10 -10
- package/dist/engine/gridApi.d.ts +1 -0
- package/dist/engine/gridApi.js +49 -31
- package/dist/engine/newRowController.cjs +1 -0
- package/dist/engine/newRowController.d.ts +31 -0
- package/dist/engine/newRowController.js +158 -0
- 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 +19 -0
- package/dist/logic/cellPlacement.cjs +1 -1
- package/dist/logic/cellPlacement.d.ts +1 -1
- package/dist/logic/cellPlacement.js +1 -1
- package/dist/logic/cellText.cjs +1 -0
- package/dist/logic/cellText.d.ts +3 -0
- package/dist/logic/cellText.js +11 -0
- package/dist/logic/cellValueTransfer.cjs +1 -0
- package/dist/logic/cellValueTransfer.d.ts +8 -0
- package/dist/logic/cellValueTransfer.js +11 -0
- package/dist/logic/changeTracking.cjs +1 -1
- package/dist/logic/changeTracking.d.ts +26 -1
- package/dist/logic/changeTracking.js +194 -84
- package/dist/logic/clearCells.cjs +1 -1
- package/dist/logic/clearCells.d.ts +4 -2
- package/dist/logic/clearCells.js +24 -24
- package/dist/logic/columnAutosize.cjs +1 -1
- package/dist/logic/columnAutosize.js +133 -115
- package/dist/logic/columnEditor.cjs +1 -0
- package/dist/logic/columnEditor.d.ts +26 -0
- package/dist/logic/columnEditor.js +15 -0
- package/dist/logic/dateTimeEditor.cjs +1 -0
- package/dist/logic/dateTimeEditor.d.ts +54 -0
- package/dist/logic/dateTimeEditor.js +100 -0
- package/dist/logic/dateTimeValues.cjs +1 -0
- package/dist/logic/dateTimeValues.d.ts +19 -0
- package/dist/logic/dateTimeValues.js +42 -0
- package/dist/logic/editorKeys.cjs +1 -1
- package/dist/logic/editorKeys.d.ts +9 -1
- package/dist/logic/editorKeys.js +23 -17
- package/dist/logic/editorValues.cjs +1 -1
- package/dist/logic/editorValues.d.ts +4 -4
- package/dist/logic/editorValues.js +60 -49
- package/dist/logic/excelShortcuts.cjs +1 -0
- package/dist/logic/excelShortcuts.d.ts +13 -0
- package/dist/logic/excelShortcuts.js +36 -0
- package/dist/logic/exportCsv.cjs +2 -2
- package/dist/logic/exportCsv.d.ts +2 -1
- package/dist/logic/exportCsv.js +17 -17
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +2 -1
- package/dist/logic/exportData.js +26 -26
- package/dist/logic/featureWarnings.cjs +1 -1
- package/dist/logic/featureWarnings.js +25 -6
- package/dist/logic/fillHandle.cjs +1 -1
- package/dist/logic/fillHandle.js +147 -100
- package/dist/logic/fillSeries.cjs +1 -1
- package/dist/logic/fillSeries.d.ts +2 -0
- package/dist/logic/fillSeries.js +104 -64
- package/dist/logic/filterSummary.cjs +1 -1
- package/dist/logic/filterSummary.js +38 -37
- package/dist/logic/filtering.cjs +1 -1
- package/dist/logic/filtering.js +160 -118
- package/dist/logic/find.cjs +1 -1
- package/dist/logic/find.d.ts +6 -2
- package/dist/logic/find.js +36 -20
- package/dist/logic/gridAsk.cjs +3 -3
- package/dist/logic/gridAsk.js +216 -211
- package/dist/logic/grouping.cjs +1 -1
- package/dist/logic/grouping.js +34 -38
- package/dist/logic/imeInput.cjs +1 -1
- package/dist/logic/imeInput.d.ts +1 -1
- package/dist/logic/imeInput.js +24 -22
- package/dist/logic/inferFilterType.cjs +1 -1
- package/dist/logic/inferFilterType.js +1 -1
- package/dist/logic/localeText.cjs +1 -1
- package/dist/logic/localeText.d.ts +3 -0
- package/dist/logic/localeText.js +3 -0
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +22 -0
- package/dist/logic/localeTextFeatures.js +27 -8
- package/dist/logic/multiSelect.cjs +1 -0
- package/dist/logic/multiSelect.d.ts +55 -0
- package/dist/logic/multiSelect.js +150 -0
- package/dist/logic/newRow.cjs +1 -0
- package/dist/logic/newRow.d.ts +9 -0
- package/dist/logic/newRow.js +70 -0
- package/dist/logic/rowDragTarget.cjs +1 -1
- package/dist/logic/rowDragTarget.js +21 -23
- package/dist/logic/selectEditorState.cjs +1 -1
- package/dist/logic/selectEditorState.d.ts +1 -0
- package/dist/logic/selectEditorState.js +1 -1
- package/dist/logic/selectFillRow.cjs +1 -1
- package/dist/logic/selectFillRow.js +19 -18
- package/dist/logic/selectLabels.cjs +1 -1
- package/dist/logic/selectLabels.d.ts +4 -2
- package/dist/logic/selectLabels.js +36 -32
- package/dist/logic/selectOptions.cjs +1 -1
- package/dist/logic/selectOptions.d.ts +3 -2
- package/dist/logic/selectOptions.js +37 -16
- package/dist/logic/selectionAggregates.cjs +1 -1
- package/dist/logic/selectionAggregates.js +2 -2
- package/dist/logic/sorting.cjs +1 -1
- package/dist/logic/sorting.js +108 -102
- package/dist/logic/validation.cjs +1 -1
- package/dist/logic/validation.d.ts +1 -1
- package/dist/logic/validation.js +28 -21
- package/dist/model/gridStore.cjs +1 -1
- package/dist/model/gridStore.d.ts +17 -1
- package/dist/model/gridStore.js +4 -4
- package/dist/model/gridTypes.core.d.ts +291 -30
- package/dist/model/gridTypes.unbound.d.ts +1 -0
- package/dist/utils/clipboard.cjs +1 -1
- package/dist/utils/clipboard.d.ts +2 -2
- package/dist/utils/clipboard.js +13 -13
- package/dist/utils/editorVisibleBounds.cjs +1 -1
- package/dist/utils/editorVisibleBounds.js +1 -1
- package/dist/utils/permissions.cjs +1 -1
- package/dist/utils/permissions.d.ts +2 -2
- package/dist/utils/permissions.js +1 -1
- package/package.json +1 -1
|
@@ -17,6 +17,7 @@ export type FindArgs<T> = {
|
|
|
17
17
|
onChange?: (params: FindChangeParams) => void;
|
|
18
18
|
conditionalFormat?: boolean | undefined;
|
|
19
19
|
toViewRow?: ((rowIndex: number) => number) | undefined;
|
|
20
|
+
multiSelectSeparator?: string | undefined;
|
|
20
21
|
};
|
|
21
22
|
export type FindSnapshot = {
|
|
22
23
|
open: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isSyntheticColumnKey as e } from "../logic/detailRow.js";
|
|
2
2
|
import { createValueStore as t } from "../logic/valueStore.js";
|
|
3
3
|
import { runChunked as n } from "../logic/chunkedLoop.js";
|
|
4
|
-
import { buildFindIndex as r,
|
|
4
|
+
import { buildFindIndex as r, findRangesInCell 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];
|
|
@@ -49,33 +49,35 @@ var l = 1e4, u = 5e4, d = /* @__PURE__ */ new Map(), f = [], p = (e, t) => e.len
|
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
m += 1;
|
|
52
|
-
let E = m, { rowModel: D, columns: O, caseSensitive: k } = d, A = d.conditionalFormat !== !1, j = x.query,
|
|
52
|
+
let E = m, { rowModel: D, columns: O, caseSensitive: k } = d, A = d.conditionalFormat !== !1, j = d.multiSelectSeparator, M = x.query, N = v !== null && v.query === M && v.caseSensitive === k;
|
|
53
53
|
v = {
|
|
54
54
|
rowModel: D,
|
|
55
55
|
columns: O,
|
|
56
|
-
query:
|
|
56
|
+
query: M,
|
|
57
57
|
caseSensitive: k,
|
|
58
|
-
conditionalFormatShown: A
|
|
59
|
-
|
|
58
|
+
conditionalFormatShown: A,
|
|
59
|
+
separator: j
|
|
60
|
+
}, (c || h === null || h.columns !== O || h.query !== M || h.caseSensitive !== k || h.conditionalFormatShown !== A || h.separator !== j) && (h = {
|
|
60
61
|
columns: O,
|
|
61
|
-
query:
|
|
62
|
+
query: M,
|
|
62
63
|
caseSensitive: k,
|
|
63
64
|
conditionalFormatShown: A,
|
|
65
|
+
separator: j,
|
|
64
66
|
byRow: /* @__PURE__ */ new WeakMap()
|
|
65
67
|
});
|
|
66
|
-
let
|
|
67
|
-
g =
|
|
68
|
-
let
|
|
68
|
+
let P = h.byRow, F = 0, I = t || g;
|
|
69
|
+
g = I;
|
|
70
|
+
let L = x.currentIndex === null ? null : x.matches[x.currentIndex] ?? null, R = [], z = !1, B = D.getRowCount(), V = B > u, H = (t, n) => {
|
|
69
71
|
let r = [];
|
|
70
72
|
return O.forEach((o, c) => {
|
|
71
|
-
if (e(o.key) || !a(o, A)) return;
|
|
73
|
+
if (e(o.key) || !a(o, A, t)) return;
|
|
72
74
|
let l = s(o, t, !A || o.conditionalFormat?.chips === void 0 ? void 0 : {
|
|
73
75
|
rowIndex: n,
|
|
74
76
|
sourceRowIndex: D.getSourceIndex(n) ?? n,
|
|
75
77
|
rowKey: D.getRowKey(n) ?? n,
|
|
76
78
|
colIndex: c
|
|
77
|
-
});
|
|
78
|
-
for (let e of i(l,
|
|
79
|
+
}, j);
|
|
80
|
+
for (let e of i(o, t, l, M, k, j)) r.push({
|
|
79
81
|
colIndex: c,
|
|
80
82
|
columnKey: String(o.key),
|
|
81
83
|
start: e.start,
|
|
@@ -83,18 +85,18 @@ var l = 1e4, u = 5e4, d = /* @__PURE__ */ new Map(), f = [], p = (e, t) => e.len
|
|
|
83
85
|
});
|
|
84
86
|
}), r.length === 0 ? f : r;
|
|
85
87
|
};
|
|
86
|
-
!
|
|
87
|
-
if (
|
|
88
|
+
!N && !x.scanning && b({ scanning: !0 }), n(B, (e) => {
|
|
89
|
+
if (z) return;
|
|
88
90
|
let t = D.getRow(e);
|
|
89
91
|
if (t === void 0) return;
|
|
90
92
|
let n = D.getTreeRow?.(e)?.aggregates, r;
|
|
91
|
-
|
|
93
|
+
V && typeof t == "object" && t ? (r = P.get(t), r === void 0 ? (r = H(t, e), P.set(t, r)) : F += 1) : r = H(t, e);
|
|
92
94
|
for (let t of r) if (!(n !== void 0 && t.columnKey in n)) {
|
|
93
|
-
if (
|
|
94
|
-
|
|
95
|
+
if (R.length >= 1e4) {
|
|
96
|
+
z = !0;
|
|
95
97
|
return;
|
|
96
98
|
}
|
|
97
|
-
|
|
99
|
+
R.push({
|
|
98
100
|
rowIndex: e,
|
|
99
101
|
colIndex: t.colIndex,
|
|
100
102
|
columnKey: t.columnKey,
|
|
@@ -103,19 +105,19 @@ var l = 1e4, u = 5e4, d = /* @__PURE__ */ new Map(), f = [], p = (e, t) => e.len
|
|
|
103
105
|
});
|
|
104
106
|
}
|
|
105
107
|
}, { isCancelled: () => m !== E }).then((e) => {
|
|
106
|
-
if (!e || m !== E || (g = !1, c &&
|
|
107
|
-
let t = o(
|
|
108
|
+
if (!e || m !== E || (g = !1, c && z === y.getSnapshot().truncated && p(y.getSnapshot().matches, R))) return;
|
|
109
|
+
let t = o(R, L);
|
|
108
110
|
b({
|
|
109
|
-
matches:
|
|
110
|
-
index: r(
|
|
111
|
+
matches: R,
|
|
112
|
+
index: r(R, l?.toViewRow),
|
|
111
113
|
currentIndex: t,
|
|
112
114
|
scanning: !1,
|
|
113
|
-
truncated:
|
|
114
|
-
}), _ = l?.toViewRow, S(),
|
|
115
|
+
truncated: z
|
|
116
|
+
}), _ = l?.toViewRow, S(), I && C("query"), !c && F > 0 && T(!1, !0);
|
|
115
117
|
});
|
|
116
118
|
}, E = () => {
|
|
117
119
|
let e = y.getSnapshot();
|
|
118
|
-
return !l || !e.open || e.query.length === 0 ? !1 : v === null || v.rowModel !== l.rowModel || v.columns !== l.columns || v.query !== e.query || v.caseSensitive !== l.caseSensitive || v.conditionalFormatShown !== (l.conditionalFormat !== !1);
|
|
120
|
+
return !l || !e.open || e.query.length === 0 ? !1 : v === null || v.rowModel !== l.rowModel || v.columns !== l.columns || v.query !== e.query || v.caseSensitive !== l.caseSensitive || v.conditionalFormatShown !== (l.conditionalFormat !== !1) || v.separator !== l.multiSelectSeparator;
|
|
119
121
|
};
|
|
120
122
|
return {
|
|
121
123
|
update: (e) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../logic/detailRow.cjs"),n=require("../logic/historyRebase.cjs"),r=require("../logic/history.cjs");var i=(e,n)=>{let r=new Map;return{getRowKey:t=>t>=0&&t<e.getRowCount()?e.getRowKey(t):void 0,viewIndexOf:i=>{if(n){let e=n.structure.keyToIndex.get(i);for(;e!==void 0&&e>=0;){let t=n.display.viewIndexOf[e];if(t>=0)return t;e=n.structure.parent[e]}return-1}return t.findViewRowIndexByKey(e,i,r)}}},a=()=>{let t=null,i=r.createHistoryStack(),a=null,o=null,s={canUndo:!1,canRedo:!1},c=null,l=!1,u=null,d=()=>t!==null&&t.enabled&&t.onRowsChange!=null,f=()=>d()&&r.canUndoHistory(i),p=()=>d()&&r.canRedoHistory(i),m=()=>{let e={canUndo:f(),canRedo:p()};e.canUndo===s.canUndo&&e.canRedo===s.canRedo||(s=e,t?.onUndoRedoStateChange?.(e))},h=e=>{let n=o!==null&&e.rows!==o;t=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=r.createHistoryStack(),l=!1)),m();let s=u;s!==null&&(e.rows===s.rows?(u=null,e.onAfterRestore?.(_(s.entry))):n&&(u=null))},g=(e,n)=>{let r=t?.rowLocator;if(!r)return;let i=e=>e===void 0||e<0?void 0:r.getRowKey(e),a=e?.type===`cell`?[e.range.start.row,e.range.end.row]:e?.type===`row`?[e.startRow,e.endRow]:[void 0,void 0];return{active:i(n?.row),start:i(a[0]),end:i(a[1])}},_=n=>{let r=t?.rowLocator,i=n.rowKeys;if(!t||!r||!i)return n.activeCell;let{dispatch:a}=t,o=e=>e===void 0?-1:r.viewIndexOf(e),s=n.activeCell,c=o(i.active);s&&c>=0&&c!==s.row&&(s={row:c,col:s.col});let l=n.selection,u=o(i.start),d=o(i.end);return l?.type===`cell`&&u>=0&&d>=0?(a(e.gridActions.startSelection({row:u,col:l.range.start.col})),a(e.gridActions.updateSelection({row:d,col:l.range.end.col})),a(e.gridActions.endSelection())):l?.type===`row`&&u>=0&&d>=0&&(a(e.gridActions.startRowSelection(u)),a(e.gridActions.updateRowSelection(d)),a(e.gridActions.endSelection())),s!==null&&t.noteFollowMove?.(s),a(e.gridActions.activateCell(s)),s},v=n=>{if(t===null)return;let{dispatch:r}=t,i=n.selection;i?.type===`cell`?(r(e.gridActions.startSelection(i.range.start)),r(e.gridActions.updateSelection(i.range.end)),r(e.gridActions.endSelection())):i?.type===`row`?(r(e.gridActions.startRowSelection(i.startRow)),r(e.gridActions.updateRowSelection(i.endRow)),r(e.gridActions.endSelection())):i?.type===`col`?(r(e.gridActions.startColumnSelection(i.startCol)),r(e.gridActions.updateColumnSelection(i.endCol)),r(e.gridActions.endSelection())):r(e.gridActions.clearSelection()),r(e.gridActions.activateCell(n.activeCell))},y=(e,n)=>{t===null||!t.onRowsChange||(t.enabled&&(i=r.pushHistory(i,{rows:e,after:n,selection:t.selection,activeCell:t.activeCell,rowKeys:g(t.selection,t.activeCell)},t.limit),a=n,m()),c=n,t.onGridRowsChange?.(e,n),t.onRowsChange(n))},b=e=>{t===null||!t.onRowsChange||y(t.rows,e)},x=e=>{if(t===null||!t.onRowsChange)return;if(t.enabled){a=e;let t=i.past[i.past.length-1];t&&(i={...i,past:[...i.past.slice(0,-1),{...t,after:e}]})}let n=c??t.rows;c=e,t.onGridRowsChange?.(n,e),t.onRowsChange(e)},S=(e,n)=>{if(t===null||!t.onRowsChange)return;let r=c??t.rows,i=Array.isArray(e)?e:e(r);if(n?.undoable!==!1){y(r,i);return}t.enabled&&(a=i,l=!0),c=i,t.onRowsChange(i)},C=(e,r)=>{if(!e)return null;if(!l||e.after===r)return e.rows;let i=t?.rowKeyGetter;return!i&&(e.rows.length!==e.after.length||e.after.length!==r.length)?e.rows:n.revertRowsChange(e.rows,e.after,r,i??((e,t)=>t))},w=e=>{if(e===null||t===null||!t.onRowsChange)return;i=e.stack,a=e.snapshot.rows;let n=c??t.rows;c=e.snapshot.rows,t.onGridRowsChange?.(n,e.snapshot.rows),t.onRowsChange(e.snapshot.rows),e.snapshot.rowKeys&&t.rowLocator&&e.snapshot.activeCell!==null&&t.noteFollowMove?.(e.snapshot.activeCell),v(e.snapshot),e.snapshot.rowKeys&&t.rowLocator?u={rows:e.snapshot.rows,entry:e.snapshot}:t.onAfterRestore?.(e.snapshot.activeCell),m()},T=(e,n)=>t===null?null:{rows:e,after:n,selection:t.selection,activeCell:t.activeCell,rowKeys:g(t.selection,t.activeCell)},E=(e,n)=>{if(!d()||t===null)return;let r=c??t.rows,a=C(e,r),o=a===null?null:T(r,a);if(a===null||o===null)return;let s=n(i,o);w(s===null?null:{stack:s.stack,snapshot:{...s.snapshot,rows:a}})};return{update:h,handleRowsChange:b,amendRowsChange:x,applyRows:S,undo:()=>{E(i.past[i.past.length-1],r.undoHistory)},redo:()=>{E(i.future[i.future.length-1],r.redoHistory)},canUndo:f,canRedo:p,clearHistory:()=>{i=r.createHistoryStack(),l=!1,m()}}};exports.createHistoryController=a,exports.createHistoryRowLocator=i;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../logic/detailRow.cjs"),n=require("../logic/historyRebase.cjs"),r=require("../logic/history.cjs");var i=(e,n)=>{let r=new Map;return{getRowKey:t=>t>=0&&t<e.getRowCount()?e.getRowKey(t):void 0,viewIndexOf:i=>{if(n){let e=n.structure.keyToIndex.get(i);for(;e!==void 0&&e>=0;){let t=n.display.viewIndexOf[e];if(t>=0)return t;e=n.structure.parent[e]}return-1}return t.findViewRowIndexByKey(e,i,r)}}},a=()=>{let t=null,i=r.createHistoryStack(),a=null,o=null,s={canUndo:!1,canRedo:!1},c=null,l=!1,u=null,d=()=>t!==null&&t.enabled&&t.onRowsChange!=null,f=()=>d()&&r.canUndoHistory(i),p=()=>d()&&r.canRedoHistory(i),m=()=>{let e={canUndo:f(),canRedo:p()};e.canUndo===s.canUndo&&e.canRedo===s.canRedo||(s=e,t?.onUndoRedoStateChange?.(e))},h=e=>{let n=o!==null&&e.rows!==o;t=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=r.createHistoryStack(),l=!1)),m();let s=u;s!==null&&(e.rows===s.rows?(u=null,e.onAfterRestore?.(_(s.entry))):n&&(u=null))},g=(e,n)=>{let r=t?.rowLocator;if(!r)return;let i=e=>e===void 0||e<0?void 0:r.getRowKey(e),a=e?.type===`cell`?[e.range.start.row,e.range.end.row]:e?.type===`row`?[e.startRow,e.endRow]:[void 0,void 0];return{active:i(n?.row),start:i(a[0]),end:i(a[1])}},_=n=>{let r=t?.rowLocator,i=n.rowKeys;if(!t||!r||!i)return n.activeCell;let{dispatch:a}=t,o=e=>e===void 0?-1:r.viewIndexOf(e),s=n.activeCell,c=o(i.active);s&&c>=0&&c!==s.row&&(s={row:c,col:s.col});let l=n.selection,u=o(i.start),d=o(i.end);return l?.type===`cell`&&u>=0&&d>=0?(a(e.gridActions.startSelection({row:u,col:l.range.start.col})),a(e.gridActions.updateSelection({row:d,col:l.range.end.col})),a(e.gridActions.endSelection())):l?.type===`row`&&u>=0&&d>=0&&(a(e.gridActions.startRowSelection(u)),a(e.gridActions.updateRowSelection(d)),a(e.gridActions.endSelection())),s!==null&&t.noteFollowMove?.(s),a(e.gridActions.activateCell(s)),s},v=n=>{if(t===null)return;let{dispatch:r}=t,i=n.selection;i?.type===`cell`?(r(e.gridActions.startSelection(i.range.start)),r(e.gridActions.updateSelection(i.range.end)),r(e.gridActions.endSelection())):i?.type===`row`?(r(e.gridActions.startRowSelection(i.startRow)),r(e.gridActions.updateRowSelection(i.endRow)),r(e.gridActions.endSelection())):i?.type===`col`?(r(e.gridActions.startColumnSelection(i.startCol)),r(e.gridActions.updateColumnSelection(i.endCol)),r(e.gridActions.endSelection())):r(e.gridActions.clearSelection()),r(e.gridActions.activateCell(n.activeCell))},y=(e,n)=>{t===null||!t.onRowsChange||(t.enabled&&(i=r.pushHistory(i,{rows:e,after:n,selection:t.selection,activeCell:t.activeCell,rowKeys:g(t.selection,t.activeCell)},t.limit),a=n,m()),c=n,t.onGridRowsChange?.(e,n),t.onRowsChange(n))},b=e=>{t===null||!t.onRowsChange||y(t.rows,e)},x=e=>{if(t===null||!t.onRowsChange)return;if(t.enabled){a=e;let t=i.past[i.past.length-1];t&&(i={...i,past:[...i.past.slice(0,-1),{...t,after:e}]})}let n=c??t.rows;c=e,t.onGridRowsChange?.(n,e),t.onRowsChange(e)},S=(e,n)=>{if(t===null||!t.onRowsChange)return;let r=c??t.rows,i=Array.isArray(e)?e:e(r);if(n?.undoable!==!1){y(r,i);return}t.enabled&&(a=i,l=!0),c=i,t.onRowsChange(i)},C=(e,r)=>{if(!e)return null;if(!l||e.after===r)return e.rows;let i=t?.rowKeyGetter;return!i&&(e.rows.length!==e.after.length||e.after.length!==r.length)?e.rows:n.revertRowsChange(e.rows,e.after,r,i??((e,t)=>t))},w=e=>{if(e===null||t===null||!t.onRowsChange)return;i=e.stack,a=e.snapshot.rows;let n=c??t.rows;c=e.snapshot.rows,t.onGridRowsChange?.(n,e.snapshot.rows),t.onRowsChange(e.snapshot.rows),e.snapshot.rowKeys&&t.rowLocator&&e.snapshot.activeCell!==null&&t.noteFollowMove?.(e.snapshot.activeCell),v(e.snapshot),e.snapshot.rowKeys&&t.rowLocator?u={rows:e.snapshot.rows,entry:e.snapshot}:t.onAfterRestore?.(e.snapshot.activeCell),m()},T=(e,n)=>t===null?null:{rows:e,after:n,selection:t.selection,activeCell:t.activeCell,rowKeys:g(t.selection,t.activeCell)},E=(e,n)=>{if(!d()||t===null)return;let r=c??t.rows,a=C(e,r),o=a===null?null:T(r,a);if(a===null||o===null)return;let s=n(i,o);w(s===null?null:{stack:s.stack,snapshot:{...s.snapshot,rows:a}})};return{update:h,handleRowsChange:b,amendRowsChange:x,applyRows:S,undo:()=>{d()&&t?.beforeRestore?.(),E(i.past[i.past.length-1],r.undoHistory)},redo:()=>{d()&&t?.beforeRestore?.(),E(i.future[i.future.length-1],r.redoHistory)},canUndo:f,canRedo:p,clearHistory:()=>{i=r.createHistoryStack(),l=!1,m()}}};exports.createHistoryController=a,exports.createHistoryRowLocator=i;
|
|
@@ -43,6 +43,7 @@ export type HistoryControllerArgs<T> = {
|
|
|
43
43
|
onGridRowsChange?: ((prevRows: T[], nextRows: T[]) => void) | undefined;
|
|
44
44
|
rowLocator?: HistoryRowLocator | undefined;
|
|
45
45
|
noteFollowMove?: ((cell: CellCoord) => void) | undefined;
|
|
46
|
+
beforeRestore?: (() => void) | undefined;
|
|
46
47
|
};
|
|
47
48
|
export type HistoryController<T> = {
|
|
48
49
|
update: (args: HistoryControllerArgs<T>) => void;
|
|
@@ -135,10 +135,10 @@ var l = (e, n) => {
|
|
|
135
135
|
amendRowsChange: E,
|
|
136
136
|
applyRows: D,
|
|
137
137
|
undo: () => {
|
|
138
|
-
j(l.past[l.past.length - 1], c);
|
|
138
|
+
g() && t?.beforeRestore?.(), j(l.past[l.past.length - 1], c);
|
|
139
139
|
},
|
|
140
140
|
redo: () => {
|
|
141
|
-
j(l.future[l.future.length - 1], s);
|
|
141
|
+
g() && t?.beforeRestore?.(), j(l.future[l.future.length - 1], s);
|
|
142
142
|
},
|
|
143
143
|
canUndo: _,
|
|
144
144
|
canRedo: v,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../logic/
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../utils/permissions.cjs"),n=require("../logic/columnEditor.cjs"),r=require("../logic/detailRow.cjs"),i=require("../logic/geometry.cjs"),a=require("../logic/domGuards.cjs"),o=require("../logic/newRow.cjs"),s=require("./liveUiState.cjs"),c=require("./clipboardController.cjs"),l=require("./escapeClaimController.cjs");var u=10,d=(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},f=e=>d(e,0,1,0),p=e=>r.resolveFirstDataColIndex(e),m=(e,t)=>({row:f(e),col:p(t)}),h=()=>{let r=null,h=e=>{r=e},g=(e,t)=>d(e,t,-1,d(e,t,1,t)),_=e=>{let t=o.getSelectableRowCount(e),n=(t>0?t:e.getRowCount())-1;return d(e,n,-1,n)},v=(t,n,i)=>{if(r===null)return;let{dispatch:a}=r,o=s.readLiveUiState(r);if(i){let r=o.selection?.type===`cell`?o.selection.range.start:t;a(e.gridActions.startSelection(r)),a(e.gridActions.updateSelection(n)),a(e.gridActions.endSelection()),a(e.gridActions.activateCell(n));return}a(e.gridActions.startSelection(n)),a(e.gridActions.endSelection()),a(e.gridActions.activateCell(n))},y=()=>{if(r===null||s.readLiveUiState(r).activeCell)return!1;let{rowModel:e,visibleColumns:t}=r;if(e.getRowCount()===0||t.length===0)return!0;let n=m(e,t);return v(n,n,!1),!0},b=e=>{let t=r===null?void 0:s.readLiveUiState(r);return e&&t?.selection?.type===`cell`?t.selection.range.end:t?.activeCell??{row:0,col:0}},x=(e,t,n)=>{if(r===null)return;let{rowModel:a,visibleColumns:o}=r,s=a.getRowCount();if(s===0||o.length===0||y())return;let c=b(n),l=i.clamp(c.row+e,0,s-1);l=e===0?g(a,l):d(a,l,e>0?1:-1,c.row);let u={row:l,col:i.clamp(c.col+t,0,o.length-1)};v(c,u,n)},S=(e,t,n)=>{if(r===null)return;let{rowModel:a,visibleColumns:o}=r,c=s.readLiveUiState(r);if(a.getRowCount()===0||o.length===0)return;let l=c.activeCell?b(t):{row:f(a),col:p(o)},u=e(l,a,o),d=i.clamp(u.col,0,o.length-1);v(l,{row:g(a,i.clamp(u.row,0,a.getRowCount()-1)),col:d},t&&c.activeCell!==null);let m=n===void 0?null:r.scrollContainerRef?.current??null,h=o[d]?.pinned;m!==null&&(n===`start`?h===`left`:h===`right`)&&(m.scrollLeft=n===`start`?0:Math.max(m.scrollWidth-m.clientWidth,0))},C=(e,t,n)=>{let a=t.getRowCount(),o=r?.resolvePageRow?r.resolvePageRow(e.row,n):e.row+n*u,s=i.clamp(n>0?Math.max(o,e.row+1):Math.min(o,e.row-1),0,a-1),c=d(t,s,n,-1);return c>=0?c:d(t,s,n>0?-1:1,e.row)};return{update:h,handleKeyDown:async i=>{if(r===null)return;let{rowModel:u,visibleColumns:d,readOnly:m,canEditCell:h,setEditorInitialValue:g,dispatch:v,handleCopy:b,openFind:w,handleCellDoubleClick:T,selectEntireGrid:E,onUndo:D,onRedo:O,onClearSelection:k,enableClearOnDelete:A,onToggleCheckboxCell:j,onToggleGroup:M,onToggleDetailRow:N}=r,P=s.readLiveUiState(r),F=r.getUiState?c.computeIsWholeGridSelected(P.selection,o.getSelectableRowCount(u),d.length):r.isWholeGridSelected;if(a.shouldIgnoreGridKeydown(i.target)||s.isEditingAtEvent(r)||i.isComposing&&a.isImeInputTarget(i.target))return;if((i.ctrlKey||i.metaKey)&&i.key.toLowerCase()===`c`){i.preventDefault(),await b();return}if((i.ctrlKey||i.metaKey)&&!i.altKey&&i.key.toLowerCase()===`x`&&r.handleCut){i.preventDefault(),await r.handleCut();return}if((i.ctrlKey||i.metaKey)&&i.key.toLowerCase()===`f`&&w){i.preventDefault(),w();return}if((i.ctrlKey||i.metaKey)&&i.key.toLowerCase()===`a`){if(i.preventDefault(),F){v(e.gridActions.clearSelection()),v(e.gridActions.activateCell(null));return}E();return}if((i.ctrlKey||i.metaKey)&&!i.isComposing){if(i.key.toLowerCase()===`z`){i.preventDefault(),i.shiftKey?O():D();return}if(i.key.toLowerCase()===`y`&&!i.shiftKey){i.preventDefault(),O();return}}if(r.onShortcutKeyDown?.(i))return;let I=i.ctrlKey||i.metaKey;if((i.key===`ContextMenu`||i.key===`F10`&&i.shiftKey)&&!I&&!i.altKey&&P.activeCell&&r.openContextMenu?.(P.activeCell)){i.preventDefault();return}if((i.key===`ArrowDown`||i.key===`ArrowUp`)&&i.altKey&&i.shiftKey&&!I&&P.activeCell&&r.onToggleTreeRow?.(P.activeCell,i.key===`ArrowDown`)){i.preventDefault();return}if(i.key===`ArrowDown`&&i.altKey&&!I&&!i.shiftKey&&P.activeCell&&r.openColumnMenu?.(P.activeCell.col)){i.preventDefault();return}if(I&&!i.altKey&&(i.key===`ArrowUp`||i.key===`ArrowDown`)){i.preventDefault();let e=i.key===`ArrowDown`;S((t,n)=>({row:e?_(n):f(n),col:t.col}),i.shiftKey);return}if(I&&!i.altKey&&(i.key===`ArrowLeft`||i.key===`ArrowRight`)){i.preventDefault();let e=i.key===`ArrowRight`;S((t,n,r)=>({row:t.row,col:e?r.length-1:p(r)}),i.shiftKey,e?`end`:`start`);return}if((i.key===`Home`||i.key===`End`)&&!i.altKey){i.preventDefault();let e=i.key===`End`;S((t,n,r)=>({row:I?e?_(n):f(n):t.row,col:e?r.length-1:p(r)}),i.shiftKey,e?`end`:`start`);return}if((i.key===`PageDown`||i.key===`PageUp`)&&!I&&!i.altKey){if(i.preventDefault(),y())return;let e=i.key===`PageDown`?1:-1;S((t,n)=>({row:C(t,n,e),col:t.col}),i.shiftKey);return}if(i.key===`ArrowUp`){i.preventDefault(),x(-1,0,i.shiftKey);return}if(i.key===`ArrowDown`){i.preventDefault(),x(1,0,i.shiftKey);return}if(i.key===`ArrowLeft`){i.preventDefault(),x(0,-1,i.shiftKey);return}if(i.key===`ArrowRight`){i.preventDefault(),x(0,1,i.shiftKey);return}if(i.key===`Tab`){if(!P.activeCell&&!i.shiftKey){if(r.rowModel.getRowCount()===0||r.visibleColumns.length===0)return;i.preventDefault(),y();return}let e=P.activeCell?.col??0;if(i.shiftKey?e<=p(r.visibleColumns):e>=r.visibleColumns.length-1){!i.shiftKey&&P.activeCell&&(r.onTabPastLastColumn?.(P.activeCell.row)||r.onTabPastNewRowDraft?.(P.activeCell,o.resolveFirstEditableColIndex(r.visibleColumns,r.readOnly)))&&i.preventDefault();return}i.preventDefault(),x(0,i.shiftKey?-1:1,!1);return}if(i.key===`Escape`){if(P.activeCell&&r.onEscapeNewRow?.(P.activeCell)){i.preventDefault();return}l.isClearableSelection(P.selection)&&i.preventDefault(),v(e.gridActions.clearSelection());return}if((i.key===`Delete`||i.key===`Backspace`)&&A){i.preventDefault(),k();return}if((i.key===`Enter`||i.key===` `)&&P.activeCell){let e=u.getGroupRow?.(P.activeCell.row);if(e){i.preventDefault(),M(e.groupKey);return}if(N&&d[P.activeCell.col]?.key===`__ssg_detail_toggle__`&&N(P.activeCell)){i.preventDefault();return}}if(i.key===`Enter`||i.key===`F2`){if(i.preventDefault(),P.activeCell){T(P.activeCell);return}i.key===`Enter`&&y();return}if(i.key===` `&&!i.ctrlKey&&!i.metaKey&&!i.altKey&&i.preventDefault(),a.isPrintableKey(i)&&P.activeCell){let r=d[P.activeCell.col],a=o.resolveEditRow(u,P.activeCell.row,r!==void 0&&t.isColumnEditable(m,r));if(!a||!r||!t.isViewCellEditable({readOnly:m,canEditCell:h},u,P.activeCell.row,P.activeCell.col,a,r))return;if(n.resolveColumnEditor(r,a)?.type===`checkbox`){i.preventDefault(),i.key===` `&&j(P.activeCell);return}i.preventDefault(),g(i.key),v(e.gridActions.startEdit(P.activeCell))}}}};exports.createKeyboardController=h,exports.resolveFirstDataCell=m;
|
|
@@ -20,6 +20,10 @@ export type KeyboardControllerArgs<T> = {
|
|
|
20
20
|
setEditorInitialValue: (value: string) => void;
|
|
21
21
|
dispatch: (action: GridUiAction) => void;
|
|
22
22
|
handleCopy: () => Promise<void>;
|
|
23
|
+
handleCut?: (() => Promise<void>) | undefined;
|
|
24
|
+
onShortcutKeyDown?: ((event: GridKeyboardEventLike) => boolean) | undefined;
|
|
25
|
+
onEscapeNewRow?: ((cell: CellCoord) => boolean) | undefined;
|
|
26
|
+
onTabPastNewRowDraft?: ((cell: CellCoord, firstCol: number) => boolean) | undefined;
|
|
23
27
|
openFind?: () => void;
|
|
24
28
|
handleCellDoubleClick: (cell: CellCoord) => void;
|
|
25
29
|
isWholeGridSelected: boolean;
|
|
@@ -1,228 +1,239 @@
|
|
|
1
1
|
import { gridActions as e } from "../model/gridActions.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
2
|
+
import { isColumnEditable as t, isViewCellEditable as n } from "../utils/permissions.js";
|
|
3
|
+
import { resolveColumnEditor as r } from "../logic/columnEditor.js";
|
|
4
|
+
import { resolveFirstDataColIndex as i } from "../logic/detailRow.js";
|
|
5
|
+
import { clamp as a } from "../logic/geometry.js";
|
|
6
|
+
import { isImeInputTarget as o, isPrintableKey as s, shouldIgnoreGridKeydown as c } from "../logic/domGuards.js";
|
|
7
|
+
import { getSelectableRowCount as l, resolveEditRow as u, resolveFirstEditableColIndex as d } from "../logic/newRow.js";
|
|
8
|
+
import { isEditingAtEvent as f, readLiveUiState as p } from "./liveUiState.js";
|
|
9
|
+
import { computeIsWholeGridSelected as m } from "./clipboardController.js";
|
|
10
|
+
import { isClearableSelection as h } from "./escapeClaimController.js";
|
|
9
11
|
//#region src/controllers/keyboardController.ts
|
|
10
|
-
var
|
|
12
|
+
var g = 10, _ = (e, t, n, r) => {
|
|
11
13
|
if (!e.getLabelRow) return t;
|
|
12
14
|
let i = e.getRowCount(), a = t;
|
|
13
15
|
for (; a >= 0 && a < i && e.getLabelRow(a);) a += n;
|
|
14
16
|
return a >= 0 && a < i ? a : r;
|
|
15
|
-
},
|
|
16
|
-
row:
|
|
17
|
-
col:
|
|
18
|
-
}),
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
let t = e.getRowCount() - 1;
|
|
23
|
-
return
|
|
24
|
-
},
|
|
25
|
-
if (
|
|
26
|
-
let { dispatch: a } =
|
|
27
|
-
if (
|
|
28
|
-
let
|
|
29
|
-
a(e.startSelection(
|
|
17
|
+
}, v = (e) => _(e, 0, 1, 0), y = (e) => i(e), b = (e, t) => ({
|
|
18
|
+
row: v(e),
|
|
19
|
+
col: y(t)
|
|
20
|
+
}), x = () => {
|
|
21
|
+
let i = null, x = (e) => {
|
|
22
|
+
i = e;
|
|
23
|
+
}, S = (e, t) => _(e, t, -1, _(e, t, 1, t)), C = (e) => {
|
|
24
|
+
let t = l(e), n = (t > 0 ? t : e.getRowCount()) - 1;
|
|
25
|
+
return _(e, n, -1, n);
|
|
26
|
+
}, w = (t, n, r) => {
|
|
27
|
+
if (i === null) return;
|
|
28
|
+
let { dispatch: a } = i, o = p(i);
|
|
29
|
+
if (r) {
|
|
30
|
+
let r = o.selection?.type === "cell" ? o.selection.range.start : t;
|
|
31
|
+
a(e.startSelection(r)), a(e.updateSelection(n)), a(e.endSelection()), a(e.activateCell(n));
|
|
30
32
|
return;
|
|
31
33
|
}
|
|
32
|
-
a(e.startSelection(
|
|
33
|
-
},
|
|
34
|
-
if (
|
|
35
|
-
let { rowModel: e, visibleColumns: t } =
|
|
34
|
+
a(e.startSelection(n)), a(e.endSelection()), a(e.activateCell(n));
|
|
35
|
+
}, T = () => {
|
|
36
|
+
if (i === null || p(i).activeCell) return !1;
|
|
37
|
+
let { rowModel: e, visibleColumns: t } = i;
|
|
36
38
|
if (e.getRowCount() === 0 || t.length === 0) return !0;
|
|
37
|
-
let
|
|
38
|
-
return
|
|
39
|
-
},
|
|
40
|
-
let t =
|
|
39
|
+
let n = b(e, t);
|
|
40
|
+
return w(n, n, !1), !0;
|
|
41
|
+
}, E = (e) => {
|
|
42
|
+
let t = i === null ? void 0 : p(i);
|
|
41
43
|
return e && t?.selection?.type === "cell" ? t.selection.range.end : t?.activeCell ?? {
|
|
42
44
|
row: 0,
|
|
43
45
|
col: 0
|
|
44
46
|
};
|
|
45
|
-
},
|
|
46
|
-
if (
|
|
47
|
-
let { rowModel:
|
|
48
|
-
if (s === 0 || o.length === 0 ||
|
|
49
|
-
let c =
|
|
50
|
-
l = e === 0 ?
|
|
47
|
+
}, D = (e, t, n) => {
|
|
48
|
+
if (i === null) return;
|
|
49
|
+
let { rowModel: r, visibleColumns: o } = i, s = r.getRowCount();
|
|
50
|
+
if (s === 0 || o.length === 0 || T()) return;
|
|
51
|
+
let c = E(n), l = a(c.row + e, 0, s - 1);
|
|
52
|
+
l = e === 0 ? S(r, l) : _(r, l, e > 0 ? 1 : -1, c.row);
|
|
51
53
|
let u = {
|
|
52
54
|
row: l,
|
|
53
|
-
col:
|
|
55
|
+
col: a(c.col + t, 0, o.length - 1)
|
|
54
56
|
};
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
if (
|
|
58
|
-
let { rowModel:
|
|
59
|
-
if (
|
|
60
|
-
let
|
|
61
|
-
row:
|
|
62
|
-
col:
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
row:
|
|
66
|
-
col:
|
|
57
|
+
w(c, u, n);
|
|
58
|
+
}, O = (e, t, n) => {
|
|
59
|
+
if (i === null) return;
|
|
60
|
+
let { rowModel: r, visibleColumns: o } = i, s = p(i);
|
|
61
|
+
if (r.getRowCount() === 0 || o.length === 0) return;
|
|
62
|
+
let c = s.activeCell ? E(t) : {
|
|
63
|
+
row: v(r),
|
|
64
|
+
col: y(o)
|
|
65
|
+
}, l = e(c, r, o), u = a(l.col, 0, o.length - 1);
|
|
66
|
+
w(c, {
|
|
67
|
+
row: S(r, a(l.row, 0, r.getRowCount() - 1)),
|
|
68
|
+
col: u
|
|
67
69
|
}, t && s.activeCell !== null);
|
|
68
|
-
let
|
|
69
|
-
|
|
70
|
-
},
|
|
71
|
-
let
|
|
72
|
-
return c >= 0 ? c :
|
|
70
|
+
let d = n === void 0 ? null : i.scrollContainerRef?.current ?? null, f = o[u]?.pinned;
|
|
71
|
+
d !== null && (n === "start" ? f === "left" : f === "right") && (d.scrollLeft = n === "start" ? 0 : Math.max(d.scrollWidth - d.clientWidth, 0));
|
|
72
|
+
}, k = (e, t, n) => {
|
|
73
|
+
let r = t.getRowCount(), o = i?.resolvePageRow ? i.resolvePageRow(e.row, n) : e.row + n * g, s = a(n > 0 ? Math.max(o, e.row + 1) : Math.min(o, e.row - 1), 0, r - 1), c = _(t, s, n, -1);
|
|
74
|
+
return c >= 0 ? c : _(t, s, n > 0 ? -1 : 1, e.row);
|
|
73
75
|
};
|
|
74
76
|
return {
|
|
75
|
-
update:
|
|
76
|
-
handleKeyDown: async (
|
|
77
|
-
if (
|
|
78
|
-
let { rowModel:
|
|
79
|
-
if (
|
|
80
|
-
if ((
|
|
81
|
-
|
|
77
|
+
update: x,
|
|
78
|
+
handleKeyDown: async (a) => {
|
|
79
|
+
if (i === null) return;
|
|
80
|
+
let { rowModel: g, visibleColumns: _, readOnly: b, canEditCell: x, setEditorInitialValue: S, dispatch: w, handleCopy: E, openFind: A, handleCellDoubleClick: j, selectEntireGrid: M, onUndo: N, onRedo: P, onClearSelection: F, enableClearOnDelete: I, onToggleCheckboxCell: L, onToggleGroup: R, onToggleDetailRow: z } = i, B = p(i), V = i.getUiState ? m(B.selection, l(g), _.length) : i.isWholeGridSelected;
|
|
81
|
+
if (c(a.target) || f(i) || a.isComposing && o(a.target)) return;
|
|
82
|
+
if ((a.ctrlKey || a.metaKey) && a.key.toLowerCase() === "c") {
|
|
83
|
+
a.preventDefault(), await E();
|
|
82
84
|
return;
|
|
83
85
|
}
|
|
84
|
-
if ((
|
|
85
|
-
|
|
86
|
+
if ((a.ctrlKey || a.metaKey) && !a.altKey && a.key.toLowerCase() === "x" && i.handleCut) {
|
|
87
|
+
a.preventDefault(), await i.handleCut();
|
|
86
88
|
return;
|
|
87
89
|
}
|
|
88
|
-
if ((
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
if ((a.ctrlKey || a.metaKey) && a.key.toLowerCase() === "f" && A) {
|
|
91
|
+
a.preventDefault(), A();
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if ((a.ctrlKey || a.metaKey) && a.key.toLowerCase() === "a") {
|
|
95
|
+
if (a.preventDefault(), V) {
|
|
96
|
+
w(e.clearSelection()), w(e.activateCell(null));
|
|
91
97
|
return;
|
|
92
98
|
}
|
|
93
|
-
|
|
99
|
+
M();
|
|
94
100
|
return;
|
|
95
101
|
}
|
|
96
|
-
if ((
|
|
97
|
-
if (
|
|
98
|
-
|
|
102
|
+
if ((a.ctrlKey || a.metaKey) && !a.isComposing) {
|
|
103
|
+
if (a.key.toLowerCase() === "z") {
|
|
104
|
+
a.preventDefault(), a.shiftKey ? P() : N();
|
|
99
105
|
return;
|
|
100
106
|
}
|
|
101
|
-
if (
|
|
102
|
-
|
|
107
|
+
if (a.key.toLowerCase() === "y" && !a.shiftKey) {
|
|
108
|
+
a.preventDefault(), P();
|
|
103
109
|
return;
|
|
104
110
|
}
|
|
105
111
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
112
|
+
if (i.onShortcutKeyDown?.(a)) return;
|
|
113
|
+
let H = a.ctrlKey || a.metaKey;
|
|
114
|
+
if ((a.key === "ContextMenu" || a.key === "F10" && a.shiftKey) && !H && !a.altKey && B.activeCell && i.openContextMenu?.(B.activeCell)) {
|
|
115
|
+
a.preventDefault();
|
|
109
116
|
return;
|
|
110
117
|
}
|
|
111
|
-
if ((
|
|
112
|
-
|
|
118
|
+
if ((a.key === "ArrowDown" || a.key === "ArrowUp") && a.altKey && a.shiftKey && !H && B.activeCell && i.onToggleTreeRow?.(B.activeCell, a.key === "ArrowDown")) {
|
|
119
|
+
a.preventDefault();
|
|
113
120
|
return;
|
|
114
121
|
}
|
|
115
|
-
if (
|
|
116
|
-
|
|
122
|
+
if (a.key === "ArrowDown" && a.altKey && !H && !a.shiftKey && B.activeCell && i.openColumnMenu?.(B.activeCell.col)) {
|
|
123
|
+
a.preventDefault();
|
|
117
124
|
return;
|
|
118
125
|
}
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
let e =
|
|
122
|
-
|
|
123
|
-
row: e ?
|
|
126
|
+
if (H && !a.altKey && (a.key === "ArrowUp" || a.key === "ArrowDown")) {
|
|
127
|
+
a.preventDefault();
|
|
128
|
+
let e = a.key === "ArrowDown";
|
|
129
|
+
O((t, n) => ({
|
|
130
|
+
row: e ? C(n) : v(n),
|
|
124
131
|
col: t.col
|
|
125
|
-
}),
|
|
132
|
+
}), a.shiftKey);
|
|
126
133
|
return;
|
|
127
134
|
}
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
let e =
|
|
131
|
-
|
|
135
|
+
if (H && !a.altKey && (a.key === "ArrowLeft" || a.key === "ArrowRight")) {
|
|
136
|
+
a.preventDefault();
|
|
137
|
+
let e = a.key === "ArrowRight";
|
|
138
|
+
O((t, n, r) => ({
|
|
132
139
|
row: t.row,
|
|
133
|
-
col: e ? r.length - 1 :
|
|
134
|
-
}),
|
|
140
|
+
col: e ? r.length - 1 : y(r)
|
|
141
|
+
}), a.shiftKey, e ? "end" : "start");
|
|
135
142
|
return;
|
|
136
143
|
}
|
|
137
|
-
if ((
|
|
138
|
-
|
|
139
|
-
let e =
|
|
140
|
-
|
|
141
|
-
row:
|
|
142
|
-
col: e ? r.length - 1 :
|
|
143
|
-
}),
|
|
144
|
+
if ((a.key === "Home" || a.key === "End") && !a.altKey) {
|
|
145
|
+
a.preventDefault();
|
|
146
|
+
let e = a.key === "End";
|
|
147
|
+
O((t, n, r) => ({
|
|
148
|
+
row: H ? e ? C(n) : v(n) : t.row,
|
|
149
|
+
col: e ? r.length - 1 : y(r)
|
|
150
|
+
}), a.shiftKey, e ? "end" : "start");
|
|
144
151
|
return;
|
|
145
152
|
}
|
|
146
|
-
if ((
|
|
147
|
-
if (
|
|
148
|
-
let e =
|
|
149
|
-
|
|
150
|
-
row:
|
|
153
|
+
if ((a.key === "PageDown" || a.key === "PageUp") && !H && !a.altKey) {
|
|
154
|
+
if (a.preventDefault(), T()) return;
|
|
155
|
+
let e = a.key === "PageDown" ? 1 : -1;
|
|
156
|
+
O((t, n) => ({
|
|
157
|
+
row: k(t, n, e),
|
|
151
158
|
col: t.col
|
|
152
|
-
}),
|
|
159
|
+
}), a.shiftKey);
|
|
153
160
|
return;
|
|
154
161
|
}
|
|
155
|
-
if (
|
|
156
|
-
|
|
162
|
+
if (a.key === "ArrowUp") {
|
|
163
|
+
a.preventDefault(), D(-1, 0, a.shiftKey);
|
|
157
164
|
return;
|
|
158
165
|
}
|
|
159
|
-
if (
|
|
160
|
-
|
|
166
|
+
if (a.key === "ArrowDown") {
|
|
167
|
+
a.preventDefault(), D(1, 0, a.shiftKey);
|
|
161
168
|
return;
|
|
162
169
|
}
|
|
163
|
-
if (
|
|
164
|
-
|
|
170
|
+
if (a.key === "ArrowLeft") {
|
|
171
|
+
a.preventDefault(), D(0, -1, a.shiftKey);
|
|
165
172
|
return;
|
|
166
173
|
}
|
|
167
|
-
if (
|
|
168
|
-
|
|
174
|
+
if (a.key === "ArrowRight") {
|
|
175
|
+
a.preventDefault(), D(0, 1, a.shiftKey);
|
|
169
176
|
return;
|
|
170
177
|
}
|
|
171
|
-
if (
|
|
172
|
-
if (!
|
|
173
|
-
if (
|
|
174
|
-
|
|
178
|
+
if (a.key === "Tab") {
|
|
179
|
+
if (!B.activeCell && !a.shiftKey) {
|
|
180
|
+
if (i.rowModel.getRowCount() === 0 || i.visibleColumns.length === 0) return;
|
|
181
|
+
a.preventDefault(), T();
|
|
175
182
|
return;
|
|
176
183
|
}
|
|
177
|
-
let e =
|
|
178
|
-
if (
|
|
179
|
-
!
|
|
184
|
+
let e = B.activeCell?.col ?? 0;
|
|
185
|
+
if (a.shiftKey ? e <= y(i.visibleColumns) : e >= i.visibleColumns.length - 1) {
|
|
186
|
+
!a.shiftKey && B.activeCell && (i.onTabPastLastColumn?.(B.activeCell.row) || i.onTabPastNewRowDraft?.(B.activeCell, d(i.visibleColumns, i.readOnly))) && a.preventDefault();
|
|
180
187
|
return;
|
|
181
188
|
}
|
|
182
|
-
|
|
189
|
+
a.preventDefault(), D(0, a.shiftKey ? -1 : 1, !1);
|
|
183
190
|
return;
|
|
184
191
|
}
|
|
185
|
-
if (
|
|
186
|
-
|
|
192
|
+
if (a.key === "Escape") {
|
|
193
|
+
if (B.activeCell && i.onEscapeNewRow?.(B.activeCell)) {
|
|
194
|
+
a.preventDefault();
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
h(B.selection) && a.preventDefault(), w(e.clearSelection());
|
|
187
198
|
return;
|
|
188
199
|
}
|
|
189
|
-
if ((
|
|
190
|
-
|
|
200
|
+
if ((a.key === "Delete" || a.key === "Backspace") && I) {
|
|
201
|
+
a.preventDefault(), F();
|
|
191
202
|
return;
|
|
192
203
|
}
|
|
193
|
-
if ((
|
|
194
|
-
let e =
|
|
204
|
+
if ((a.key === "Enter" || a.key === " ") && B.activeCell) {
|
|
205
|
+
let e = g.getGroupRow?.(B.activeCell.row);
|
|
195
206
|
if (e) {
|
|
196
|
-
|
|
207
|
+
a.preventDefault(), R(e.groupKey);
|
|
197
208
|
return;
|
|
198
209
|
}
|
|
199
|
-
if (
|
|
200
|
-
|
|
210
|
+
if (z && _[B.activeCell.col]?.key === "__ssg_detail_toggle__" && z(B.activeCell)) {
|
|
211
|
+
a.preventDefault();
|
|
201
212
|
return;
|
|
202
213
|
}
|
|
203
214
|
}
|
|
204
|
-
if (
|
|
205
|
-
if (
|
|
206
|
-
|
|
215
|
+
if (a.key === "Enter" || a.key === "F2") {
|
|
216
|
+
if (a.preventDefault(), B.activeCell) {
|
|
217
|
+
j(B.activeCell);
|
|
207
218
|
return;
|
|
208
219
|
}
|
|
209
|
-
|
|
220
|
+
a.key === "Enter" && T();
|
|
210
221
|
return;
|
|
211
222
|
}
|
|
212
|
-
if (
|
|
213
|
-
let
|
|
214
|
-
if (!
|
|
215
|
-
readOnly:
|
|
216
|
-
canEditCell:
|
|
217
|
-
},
|
|
218
|
-
if (i
|
|
219
|
-
|
|
223
|
+
if (a.key === " " && !a.ctrlKey && !a.metaKey && !a.altKey && a.preventDefault(), s(a) && B.activeCell) {
|
|
224
|
+
let i = _[B.activeCell.col], o = u(g, B.activeCell.row, i !== void 0 && t(b, i));
|
|
225
|
+
if (!o || !i || !n({
|
|
226
|
+
readOnly: b,
|
|
227
|
+
canEditCell: x
|
|
228
|
+
}, g, B.activeCell.row, B.activeCell.col, o, i)) return;
|
|
229
|
+
if (r(i, o)?.type === "checkbox") {
|
|
230
|
+
a.preventDefault(), a.key === " " && L(B.activeCell);
|
|
220
231
|
return;
|
|
221
232
|
}
|
|
222
|
-
|
|
233
|
+
a.preventDefault(), S(a.key), w(e.startEdit(B.activeCell));
|
|
223
234
|
}
|
|
224
235
|
}
|
|
225
236
|
};
|
|
226
237
|
};
|
|
227
238
|
//#endregion
|
|
228
|
-
export {
|
|
239
|
+
export { x as createKeyboardController, b as resolveFirstDataCell };
|