@ishibashi0112/spreadsheet-grid-core 1.8.0 → 1.10.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 -1
- package/dist/controllers/activeRowFollowController.d.ts +1 -0
- package/dist/controllers/activeRowFollowController.js +33 -24
- package/dist/controllers/changeTracker.cjs +1 -1
- package/dist/controllers/changeTracker.d.ts +6 -0
- package/dist/controllers/changeTracker.js +338 -160
- package/dist/controllers/clipboardController.cjs +2 -1
- package/dist/controllers/clipboardController.d.ts +5 -1
- package/dist/controllers/clipboardController.js +217 -91
- package/dist/controllers/columnAutosizeRunner.cjs +1 -1
- package/dist/controllers/columnAutosizeRunner.d.ts +3 -1
- package/dist/controllers/columnAutosizeRunner.js +12 -11
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.js +231 -159
- package/dist/controllers/fillHandleController.cjs +1 -1
- package/dist/controllers/fillHandleController.js +114 -113
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +3 -1
- package/dist/controllers/findController.js +80 -75
- package/dist/controllers/historyController.cjs +1 -1
- package/dist/controllers/historyController.d.ts +25 -1
- package/dist/controllers/historyController.js +115 -64
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +5 -0
- package/dist/controllers/keyboardController.js +154 -140
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +1 -0
- package/dist/controllers/rowDragController.js +1 -0
- package/dist/engine/cellCommands.cjs +1 -1
- package/dist/engine/cellCommands.js +81 -62
- package/dist/engine/columnLayout.cjs +1 -1
- package/dist/engine/columnLayout.d.ts +1 -0
- package/dist/engine/columnLayout.js +10 -10
- package/dist/engine/createGridEngine.cjs +1 -1
- package/dist/engine/createGridEngine.d.ts +6 -1
- package/dist/engine/createGridEngine.js +58 -50
- package/dist/engine/excelShortcutCommands.cjs +1 -0
- package/dist/engine/excelShortcutCommands.d.ts +29 -0
- package/dist/engine/excelShortcutCommands.js +256 -0
- package/dist/engine/exportCommands.cjs +2 -2
- package/dist/engine/exportCommands.js +82 -34
- package/dist/engine/features.cjs +1 -1
- package/dist/engine/features.d.ts +21 -0
- package/dist/engine/features.js +23 -2
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +24 -10
- package/dist/engine/gridApi.cjs +10 -9
- package/dist/engine/gridApi.d.ts +21 -2
- package/dist/engine/gridApi.js +239 -101
- package/dist/engine/memo.cjs +1 -1
- package/dist/engine/memo.d.ts +1 -1
- package/dist/engine/memo.js +12 -11
- package/dist/engine/newRowController.cjs +1 -0
- package/dist/engine/newRowController.d.ts +31 -0
- package/dist/engine/newRowController.js +157 -0
- package/dist/engine/notifiers.cjs +1 -1
- package/dist/engine/notifiers.d.ts +9 -1
- package/dist/engine/notifiers.js +23 -8
- package/dist/engine/rowPipeline.cjs +1 -1
- package/dist/engine/rowPipeline.d.ts +29 -2
- package/dist/engine/rowPipeline.js +76 -50
- package/dist/engine/treeStage.cjs +1 -0
- package/dist/engine/treeStage.d.ts +46 -0
- package/dist/engine/treeStage.js +171 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +12 -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/changeTracking.cjs +1 -1
- package/dist/logic/changeTracking.d.ts +26 -1
- package/dist/logic/changeTracking.js +139 -32
- 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.d.ts +4 -1
- package/dist/logic/columnAutosize.js +89 -72
- package/dist/logic/conditionalFormat.cjs +1 -1
- package/dist/logic/conditionalFormat.js +8 -5
- 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/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 +11 -1
- package/dist/logic/exportCsv.js +30 -22
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +3 -2
- package/dist/logic/exportData.js +40 -28
- package/dist/logic/featureWarnings.cjs +1 -1
- package/dist/logic/featureWarnings.js +16 -6
- package/dist/logic/fillHandle.cjs +1 -1
- package/dist/logic/fillHandle.js +1 -1
- package/dist/logic/find.cjs +1 -1
- package/dist/logic/find.d.ts +1 -1
- package/dist/logic/find.js +11 -9
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +3 -2
- package/dist/logic/gridState.js +6 -6
- package/dist/logic/imeInput.cjs +1 -1
- package/dist/logic/imeInput.js +22 -21
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +16 -0
- package/dist/logic/localeTextFeatures.js +22 -8
- package/dist/logic/newRow.cjs +1 -0
- package/dist/logic/newRow.d.ts +9 -0
- package/dist/logic/newRow.js +69 -0
- package/dist/logic/selectionAggregates.cjs +1 -1
- package/dist/logic/selectionAggregates.js +3 -2
- package/dist/logic/sorting.cjs +1 -1
- package/dist/logic/sorting.d.ts +1 -1
- package/dist/logic/sorting.js +32 -32
- package/dist/logic/treeData.cjs +7 -0
- package/dist/logic/treeData.d.ts +83 -0
- package/dist/logic/treeData.js +438 -0
- package/dist/logic/validation.cjs +1 -1
- package/dist/logic/validation.d.ts +1 -1
- package/dist/logic/validation.js +10 -9
- package/dist/model/gridActions.cjs +1 -1
- package/dist/model/gridActions.d.ts +15 -0
- package/dist/model/gridActions.js +15 -0
- package/dist/model/gridReducer.cjs +1 -1
- package/dist/model/gridReducer.js +175 -156
- 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 +325 -25
- package/dist/model/gridTypes.unbound.d.ts +1 -0
- package/dist/utils/clipboard.cjs +1 -1
- package/dist/utils/clipboard.d.ts +1 -1
- package/dist/utils/clipboard.js +13 -10
- 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
|
@@ -7,7 +7,7 @@ var l = 1e4, u = 5e4, d = /* @__PURE__ */ new Map(), f = [], p = (e, t) => e.len
|
|
|
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,
|
|
10
|
+
let l = null, m = 0, h = null, g = !1, _, v = null, y = t({
|
|
11
11
|
open: !1,
|
|
12
12
|
query: "",
|
|
13
13
|
matches: [],
|
|
@@ -15,67 +15,67 @@ var l = 1e4, u = 5e4, d = /* @__PURE__ */ new Map(), f = [], p = (e, t) => e.len
|
|
|
15
15
|
currentIndex: null,
|
|
16
16
|
scanning: !1,
|
|
17
17
|
truncated: !1
|
|
18
|
-
}),
|
|
19
|
-
|
|
20
|
-
...
|
|
18
|
+
}), b = (e) => {
|
|
19
|
+
y.setSnapshot({
|
|
20
|
+
...y.getSnapshot(),
|
|
21
21
|
...e
|
|
22
22
|
});
|
|
23
|
-
},
|
|
24
|
-
let e =
|
|
23
|
+
}, x = null, S = () => {
|
|
24
|
+
let e = y.getSnapshot(), t = {
|
|
25
25
|
query: e.query,
|
|
26
26
|
matchCount: e.matches.length,
|
|
27
27
|
currentIndex: e.currentIndex,
|
|
28
28
|
open: e.open,
|
|
29
29
|
truncated: e.truncated
|
|
30
30
|
};
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
let
|
|
34
|
-
if (
|
|
35
|
-
let
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
m += 1,
|
|
31
|
+
x !== null && x.query === t.query && x.matchCount === t.matchCount && x.currentIndex === t.currentIndex && x.open === t.open && x.truncated === t.truncated || (x = t, l?.onChange?.(t));
|
|
32
|
+
}, C = (e) => {
|
|
33
|
+
let t = y.getSnapshot();
|
|
34
|
+
if (t.currentIndex === null) return;
|
|
35
|
+
let n = t.matches[t.currentIndex];
|
|
36
|
+
n && l?.onNavigate(n.rowIndex, n.colIndex, e);
|
|
37
|
+
}, w = () => {
|
|
38
|
+
m += 1, v = null, h = null, g = !1, b({
|
|
39
39
|
matches: [],
|
|
40
40
|
index: d,
|
|
41
41
|
currentIndex: null,
|
|
42
42
|
scanning: !1,
|
|
43
43
|
truncated: !1
|
|
44
44
|
});
|
|
45
|
-
},
|
|
46
|
-
let d = l,
|
|
47
|
-
if (!d || !
|
|
48
|
-
|
|
45
|
+
}, T = (t, c = !1) => {
|
|
46
|
+
let d = l, x = y.getSnapshot();
|
|
47
|
+
if (!d || !x.open || x.query.length === 0) {
|
|
48
|
+
w(), S();
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
m += 1;
|
|
52
|
-
let
|
|
53
|
-
|
|
54
|
-
rowModel:
|
|
55
|
-
columns:
|
|
56
|
-
query:
|
|
57
|
-
caseSensitive:
|
|
58
|
-
conditionalFormatShown:
|
|
59
|
-
}, (c || h === null || h.columns !==
|
|
60
|
-
columns:
|
|
61
|
-
query:
|
|
62
|
-
caseSensitive:
|
|
63
|
-
conditionalFormatShown:
|
|
52
|
+
let E = m, { rowModel: D, columns: O, caseSensitive: k } = d, A = d.conditionalFormat !== !1, j = x.query, M = v !== null && v.query === j && v.caseSensitive === k;
|
|
53
|
+
v = {
|
|
54
|
+
rowModel: D,
|
|
55
|
+
columns: O,
|
|
56
|
+
query: j,
|
|
57
|
+
caseSensitive: k,
|
|
58
|
+
conditionalFormatShown: A
|
|
59
|
+
}, (c || h === null || h.columns !== O || h.query !== j || h.caseSensitive !== k || h.conditionalFormatShown !== A) && (h = {
|
|
60
|
+
columns: O,
|
|
61
|
+
query: j,
|
|
62
|
+
caseSensitive: k,
|
|
63
|
+
conditionalFormatShown: A,
|
|
64
64
|
byRow: /* @__PURE__ */ new WeakMap()
|
|
65
65
|
});
|
|
66
|
-
let
|
|
67
|
-
g =
|
|
68
|
-
let
|
|
66
|
+
let N = h.byRow, P = 0, F = t || g;
|
|
67
|
+
g = F;
|
|
68
|
+
let I = x.currentIndex === null ? null : x.matches[x.currentIndex] ?? null, L = [], R = !1, z = D.getRowCount(), B = z > u, V = (t, n) => {
|
|
69
69
|
let r = [];
|
|
70
|
-
return
|
|
71
|
-
if (e(o.key) || !a(o,
|
|
72
|
-
let l = s(o, t, !
|
|
70
|
+
return O.forEach((o, c) => {
|
|
71
|
+
if (e(o.key) || !a(o, A)) return;
|
|
72
|
+
let l = s(o, t, !A || o.conditionalFormat?.chips === void 0 ? void 0 : {
|
|
73
73
|
rowIndex: n,
|
|
74
|
-
sourceRowIndex:
|
|
75
|
-
rowKey:
|
|
74
|
+
sourceRowIndex: D.getSourceIndex(n) ?? n,
|
|
75
|
+
rowKey: D.getRowKey(n) ?? n,
|
|
76
76
|
colIndex: c
|
|
77
77
|
});
|
|
78
|
-
for (let e of i(l,
|
|
78
|
+
for (let e of i(l, j, k)) r.push({
|
|
79
79
|
colIndex: c,
|
|
80
80
|
columnKey: String(o.key),
|
|
81
81
|
start: e.start,
|
|
@@ -83,18 +83,18 @@ var l = 1e4, u = 5e4, d = /* @__PURE__ */ new Map(), f = [], p = (e, t) => e.len
|
|
|
83
83
|
});
|
|
84
84
|
}), r.length === 0 ? f : r;
|
|
85
85
|
};
|
|
86
|
-
!
|
|
87
|
-
if (
|
|
88
|
-
let t =
|
|
86
|
+
!M && !x.scanning && b({ scanning: !0 }), n(z, (e) => {
|
|
87
|
+
if (R) return;
|
|
88
|
+
let t = D.getRow(e);
|
|
89
89
|
if (t === void 0) return;
|
|
90
|
-
let n;
|
|
91
|
-
|
|
92
|
-
for (let t of n) {
|
|
93
|
-
if (
|
|
94
|
-
|
|
90
|
+
let n = D.getTreeRow?.(e)?.aggregates, r;
|
|
91
|
+
B && typeof t == "object" && t ? (r = N.get(t), r === void 0 ? (r = V(t, e), N.set(t, r)) : P += 1) : r = V(t, e);
|
|
92
|
+
for (let t of r) if (!(n !== void 0 && t.columnKey in n)) {
|
|
93
|
+
if (L.length >= 1e4) {
|
|
94
|
+
R = !0;
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
|
-
|
|
97
|
+
L.push({
|
|
98
98
|
rowIndex: e,
|
|
99
99
|
colIndex: t.colIndex,
|
|
100
100
|
columnKey: t.columnKey,
|
|
@@ -102,61 +102,66 @@ var l = 1e4, u = 5e4, d = /* @__PURE__ */ new Map(), f = [], p = (e, t) => e.len
|
|
|
102
102
|
length: t.length
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
-
}, { isCancelled: () => m !==
|
|
106
|
-
if (!e || m !==
|
|
107
|
-
let t = o(
|
|
108
|
-
|
|
109
|
-
matches:
|
|
110
|
-
index: r(
|
|
105
|
+
}, { isCancelled: () => m !== E }).then((e) => {
|
|
106
|
+
if (!e || m !== E || (g = !1, c && R === y.getSnapshot().truncated && p(y.getSnapshot().matches, L))) return;
|
|
107
|
+
let t = o(L, I);
|
|
108
|
+
b({
|
|
109
|
+
matches: L,
|
|
110
|
+
index: r(L, l?.toViewRow),
|
|
111
111
|
currentIndex: t,
|
|
112
112
|
scanning: !1,
|
|
113
|
-
truncated:
|
|
114
|
-
}),
|
|
113
|
+
truncated: R
|
|
114
|
+
}), _ = l?.toViewRow, S(), F && C("query"), !c && P > 0 && T(!1, !0);
|
|
115
115
|
});
|
|
116
|
-
},
|
|
117
|
-
let e =
|
|
118
|
-
return !l || !e.open || e.query.length === 0 ? !1 :
|
|
116
|
+
}, E = () => {
|
|
117
|
+
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);
|
|
119
119
|
};
|
|
120
120
|
return {
|
|
121
121
|
update: (e) => {
|
|
122
122
|
let t = l;
|
|
123
123
|
if (l = e, !e.enabled) {
|
|
124
|
-
|
|
124
|
+
y.getSnapshot().open && (b({
|
|
125
125
|
open: !1,
|
|
126
126
|
query: ""
|
|
127
|
-
}),
|
|
127
|
+
}), w(), S());
|
|
128
128
|
return;
|
|
129
129
|
}
|
|
130
|
-
t !== e &&
|
|
130
|
+
if (t !== e && E()) {
|
|
131
|
+
T(!1);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
let n = y.getSnapshot();
|
|
135
|
+
e.toViewRow !== _ && !n.scanning && (_ = e.toViewRow, n.matches.length > 0 && b({ index: r(n.matches, e.toViewRow) }));
|
|
131
136
|
},
|
|
132
137
|
open: (e) => {
|
|
133
138
|
if (!l?.enabled) return;
|
|
134
|
-
let t =
|
|
135
|
-
|
|
139
|
+
let t = y.getSnapshot(), n = e ?? t.query;
|
|
140
|
+
b({
|
|
136
141
|
open: !0,
|
|
137
142
|
query: n
|
|
138
|
-
}), n !== t.query || !t.open ?
|
|
143
|
+
}), n !== t.query || !t.open ? T(!0) : S();
|
|
139
144
|
},
|
|
140
145
|
close: () => {
|
|
141
|
-
|
|
146
|
+
y.getSnapshot().open && (b({
|
|
142
147
|
open: !1,
|
|
143
148
|
query: ""
|
|
144
|
-
}),
|
|
149
|
+
}), w(), S());
|
|
145
150
|
},
|
|
146
151
|
setQuery: (e) => {
|
|
147
|
-
let t =
|
|
148
|
-
!t.open || e === t.query || (
|
|
152
|
+
let t = y.getSnapshot();
|
|
153
|
+
!t.open || e === t.query || (b({ query: e }), T(!0));
|
|
149
154
|
},
|
|
150
155
|
next: () => {
|
|
151
|
-
let e =
|
|
152
|
-
|
|
156
|
+
let e = y.getSnapshot(), t = c(e.currentIndex, e.matches.length, 1);
|
|
157
|
+
b({ currentIndex: t }), S(), C("step");
|
|
153
158
|
},
|
|
154
159
|
prev: () => {
|
|
155
|
-
let e =
|
|
156
|
-
|
|
160
|
+
let e = y.getSnapshot(), t = c(e.currentIndex, e.matches.length, -1);
|
|
161
|
+
b({ currentIndex: t }), S(), C("step");
|
|
157
162
|
},
|
|
158
|
-
subscribe:
|
|
159
|
-
getSnapshot:
|
|
163
|
+
subscribe: y.subscribe,
|
|
164
|
+
getSnapshot: y.getSnapshot,
|
|
160
165
|
dispose: () => {
|
|
161
166
|
m += 1, l = null;
|
|
162
167
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../model/gridActions.cjs"),t=require("../logic/
|
|
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;
|
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
import { type GridUiAction } from '../model/gridActions.js';
|
|
2
|
-
import type { CellCoord, GridSelection, UndoRedoState } from '../model/gridTypes.unbound.js';
|
|
2
|
+
import type { CellCoord, GridRowKey, GridSelection, RowModel, UndoRedoState } from '../model/gridTypes.unbound.js';
|
|
3
3
|
export type GridHistoryEntry<T> = {
|
|
4
4
|
rows: T[];
|
|
5
5
|
after: T[];
|
|
6
6
|
selection: GridSelection;
|
|
7
7
|
activeCell: CellCoord | null;
|
|
8
|
+
rowKeys?: HistoryRowKeys | undefined;
|
|
8
9
|
};
|
|
10
|
+
type HistoryRowKeys = {
|
|
11
|
+
active: GridRowKey | undefined;
|
|
12
|
+
start: GridRowKey | undefined;
|
|
13
|
+
end: GridRowKey | undefined;
|
|
14
|
+
};
|
|
15
|
+
export type HistoryRowLocator = {
|
|
16
|
+
getRowKey: (viewIndex: number) => GridRowKey | undefined;
|
|
17
|
+
viewIndexOf: (rowKey: GridRowKey) => number;
|
|
18
|
+
};
|
|
19
|
+
type HistoryTreeLookup = {
|
|
20
|
+
structure: {
|
|
21
|
+
keyToIndex: ReadonlyMap<GridRowKey, number>;
|
|
22
|
+
parent: Int32Array;
|
|
23
|
+
};
|
|
24
|
+
display: {
|
|
25
|
+
viewIndexOf: Int32Array;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
export declare const createHistoryRowLocator: <T>(rowModel: RowModel<T>, tree?: HistoryTreeLookup | null | undefined) => HistoryRowLocator;
|
|
9
29
|
export type HistoryApplyRowsOptions = {
|
|
10
30
|
undoable?: boolean | undefined;
|
|
11
31
|
};
|
|
@@ -21,6 +41,9 @@ export type HistoryControllerArgs<T> = {
|
|
|
21
41
|
onAfterRestore?: (activeCell: CellCoord | null) => void;
|
|
22
42
|
rowKeyGetter?: ((row: T, index: number) => unknown) | undefined;
|
|
23
43
|
onGridRowsChange?: ((prevRows: T[], nextRows: T[]) => void) | undefined;
|
|
44
|
+
rowLocator?: HistoryRowLocator | undefined;
|
|
45
|
+
noteFollowMove?: ((cell: CellCoord) => void) | undefined;
|
|
46
|
+
beforeRestore?: (() => void) | undefined;
|
|
24
47
|
};
|
|
25
48
|
export type HistoryController<T> = {
|
|
26
49
|
update: (args: HistoryControllerArgs<T>) => void;
|
|
@@ -34,3 +57,4 @@ export type HistoryController<T> = {
|
|
|
34
57
|
clearHistory: () => void;
|
|
35
58
|
};
|
|
36
59
|
export declare const createHistoryController: <T>() => HistoryController<T>;
|
|
60
|
+
export {};
|
|
@@ -1,35 +1,82 @@
|
|
|
1
1
|
import { gridActions as e } from "../model/gridActions.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { findViewRowIndexByKey as t } from "../logic/detailRow.js";
|
|
3
|
+
import { revertRowsChange as n } from "../logic/historyRebase.js";
|
|
4
|
+
import { canRedoHistory as r, canUndoHistory as i, createHistoryStack as a, pushHistory as o, redoHistory as s, undoHistory as c } from "../logic/history.js";
|
|
4
5
|
//#region src/controllers/historyController.ts
|
|
5
|
-
var
|
|
6
|
-
let
|
|
6
|
+
var l = (e, n) => {
|
|
7
|
+
let r = /* @__PURE__ */ new Map();
|
|
8
|
+
return {
|
|
9
|
+
getRowKey: (t) => t >= 0 && t < e.getRowCount() ? e.getRowKey(t) : void 0,
|
|
10
|
+
viewIndexOf: (i) => {
|
|
11
|
+
if (n) {
|
|
12
|
+
let e = n.structure.keyToIndex.get(i);
|
|
13
|
+
for (; e !== void 0 && e >= 0;) {
|
|
14
|
+
let t = n.display.viewIndexOf[e];
|
|
15
|
+
if (t >= 0) return t;
|
|
16
|
+
e = n.structure.parent[e];
|
|
17
|
+
}
|
|
18
|
+
return -1;
|
|
19
|
+
}
|
|
20
|
+
return t(e, i, r);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}, u = () => {
|
|
24
|
+
let t = null, l = a(), u = null, d = null, f = {
|
|
7
25
|
canUndo: !1,
|
|
8
26
|
canRedo: !1
|
|
9
|
-
}, p = null, m = !1, h = () =>
|
|
27
|
+
}, p = null, m = !1, h = null, g = () => t !== null && t.enabled && t.onRowsChange != null, _ = () => g() && i(l), v = () => g() && r(l), y = () => {
|
|
10
28
|
let e = {
|
|
11
|
-
canUndo:
|
|
12
|
-
canRedo:
|
|
29
|
+
canUndo: _(),
|
|
30
|
+
canRedo: v()
|
|
13
31
|
};
|
|
14
|
-
e.canUndo === f.canUndo && e.canRedo === f.canRedo || (f = e,
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
32
|
+
e.canUndo === f.canUndo && e.canRedo === f.canRedo || (f = e, t?.onUndoRedoStateChange?.(e));
|
|
33
|
+
}, b = (e) => {
|
|
34
|
+
let n = d !== null && e.rows !== d;
|
|
35
|
+
t = 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 = a(), m = !1)), y();
|
|
36
|
+
let r = h;
|
|
37
|
+
r !== null && (e.rows === r.rows ? (h = null, e.onAfterRestore?.(S(r.entry))) : n && (h = null));
|
|
38
|
+
}, x = (e, n) => {
|
|
39
|
+
let r = t?.rowLocator;
|
|
40
|
+
if (!r) return;
|
|
41
|
+
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];
|
|
42
|
+
return {
|
|
43
|
+
active: i(n?.row),
|
|
44
|
+
start: i(a[0]),
|
|
45
|
+
end: i(a[1])
|
|
46
|
+
};
|
|
47
|
+
}, S = (n) => {
|
|
48
|
+
let r = t?.rowLocator, i = n.rowKeys;
|
|
49
|
+
if (!t || !r || !i) return n.activeCell;
|
|
50
|
+
let { dispatch: a } = t, o = (e) => e === void 0 ? -1 : r.viewIndexOf(e), s = n.activeCell, c = o(i.active);
|
|
51
|
+
s && c >= 0 && c !== s.row && (s = {
|
|
52
|
+
row: c,
|
|
53
|
+
col: s.col
|
|
54
|
+
});
|
|
55
|
+
let l = n.selection, u = o(i.start), d = o(i.end);
|
|
56
|
+
return l?.type === "cell" && u >= 0 && d >= 0 ? (a(e.startSelection({
|
|
57
|
+
row: u,
|
|
58
|
+
col: l.range.start.col
|
|
59
|
+
})), a(e.updateSelection({
|
|
60
|
+
row: d,
|
|
61
|
+
col: l.range.end.col
|
|
62
|
+
})), a(e.endSelection())) : l?.type === "row" && u >= 0 && d >= 0 && (a(e.startRowSelection(u)), a(e.updateRowSelection(d)), a(e.endSelection())), s !== null && t.noteFollowMove?.(s), a(e.activateCell(s)), s;
|
|
63
|
+
}, C = (n) => {
|
|
64
|
+
if (t === null) return;
|
|
65
|
+
let { dispatch: r } = t, i = n.selection;
|
|
66
|
+
i?.type === "cell" ? (r(e.startSelection(i.range.start)), r(e.updateSelection(i.range.end)), r(e.endSelection())) : i?.type === "row" ? (r(e.startRowSelection(i.startRow)), r(e.updateRowSelection(i.endRow)), r(e.endSelection())) : i?.type === "col" ? (r(e.startColumnSelection(i.startCol)), r(e.updateColumnSelection(i.endCol)), r(e.endSelection())) : r(e.clearSelection()), r(e.activateCell(n.activeCell));
|
|
67
|
+
}, w = (e, n) => {
|
|
68
|
+
t === null || !t.onRowsChange || (t.enabled && (l = o(l, {
|
|
23
69
|
rows: e,
|
|
24
|
-
after:
|
|
25
|
-
selection:
|
|
26
|
-
activeCell:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (
|
|
70
|
+
after: n,
|
|
71
|
+
selection: t.selection,
|
|
72
|
+
activeCell: t.activeCell,
|
|
73
|
+
rowKeys: x(t.selection, t.activeCell)
|
|
74
|
+
}, t.limit), u = n, y()), p = n, t.onGridRowsChange?.(e, n), t.onRowsChange(n));
|
|
75
|
+
}, T = (e) => {
|
|
76
|
+
t === null || !t.onRowsChange || w(t.rows, e);
|
|
77
|
+
}, E = (e) => {
|
|
78
|
+
if (t === null || !t.onRowsChange) return;
|
|
79
|
+
if (t.enabled) {
|
|
33
80
|
u = e;
|
|
34
81
|
let t = l.past[l.past.length - 1];
|
|
35
82
|
t && (l = {
|
|
@@ -40,61 +87,65 @@ var c = () => {
|
|
|
40
87
|
}]
|
|
41
88
|
});
|
|
42
89
|
}
|
|
43
|
-
let
|
|
44
|
-
p = e,
|
|
45
|
-
},
|
|
46
|
-
if (
|
|
47
|
-
let
|
|
48
|
-
if (
|
|
49
|
-
|
|
90
|
+
let n = p ?? t.rows;
|
|
91
|
+
p = e, t.onGridRowsChange?.(n, e), t.onRowsChange(e);
|
|
92
|
+
}, D = (e, n) => {
|
|
93
|
+
if (t === null || !t.onRowsChange) return;
|
|
94
|
+
let r = p ?? t.rows, i = Array.isArray(e) ? e : e(r);
|
|
95
|
+
if (n?.undoable !== !1) {
|
|
96
|
+
w(r, i);
|
|
50
97
|
return;
|
|
51
98
|
}
|
|
52
|
-
|
|
53
|
-
},
|
|
99
|
+
t.enabled && (u = i, m = !0), p = i, t.onRowsChange(i);
|
|
100
|
+
}, O = (e, r) => {
|
|
54
101
|
if (!e) return null;
|
|
55
|
-
if (!m || e.after ===
|
|
56
|
-
let
|
|
57
|
-
return !
|
|
58
|
-
},
|
|
59
|
-
if (e === null ||
|
|
102
|
+
if (!m || e.after === r) return e.rows;
|
|
103
|
+
let i = t?.rowKeyGetter;
|
|
104
|
+
return !i && (e.rows.length !== e.after.length || e.after.length !== r.length) ? e.rows : n(e.rows, e.after, r, i ?? ((e, t) => t));
|
|
105
|
+
}, k = (e) => {
|
|
106
|
+
if (e === null || t === null || !t.onRowsChange) return;
|
|
60
107
|
l = e.stack, u = e.snapshot.rows;
|
|
61
|
-
let
|
|
62
|
-
p = e.snapshot.rows,
|
|
63
|
-
|
|
108
|
+
let n = p ?? t.rows;
|
|
109
|
+
p = 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), C(e.snapshot), e.snapshot.rowKeys && t.rowLocator ? h = {
|
|
110
|
+
rows: e.snapshot.rows,
|
|
111
|
+
entry: e.snapshot
|
|
112
|
+
} : t.onAfterRestore?.(e.snapshot.activeCell), y();
|
|
113
|
+
}, A = (e, n) => t === null ? null : {
|
|
64
114
|
rows: e,
|
|
65
|
-
after:
|
|
66
|
-
selection:
|
|
67
|
-
activeCell:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
115
|
+
after: n,
|
|
116
|
+
selection: t.selection,
|
|
117
|
+
activeCell: t.activeCell,
|
|
118
|
+
rowKeys: x(t.selection, t.activeCell)
|
|
119
|
+
}, j = (e, n) => {
|
|
120
|
+
if (!g() || t === null) return;
|
|
121
|
+
let r = p ?? t.rows, i = O(e, r), a = i === null ? null : A(r, i);
|
|
122
|
+
if (i === null || a === null) return;
|
|
123
|
+
let o = n(l, a);
|
|
124
|
+
k(o === null ? null : {
|
|
125
|
+
stack: o.stack,
|
|
75
126
|
snapshot: {
|
|
76
|
-
...
|
|
77
|
-
rows:
|
|
127
|
+
...o.snapshot,
|
|
128
|
+
rows: i
|
|
78
129
|
}
|
|
79
130
|
});
|
|
80
131
|
};
|
|
81
132
|
return {
|
|
82
|
-
update:
|
|
83
|
-
handleRowsChange:
|
|
84
|
-
amendRowsChange:
|
|
85
|
-
applyRows:
|
|
133
|
+
update: b,
|
|
134
|
+
handleRowsChange: T,
|
|
135
|
+
amendRowsChange: E,
|
|
136
|
+
applyRows: D,
|
|
86
137
|
undo: () => {
|
|
87
|
-
|
|
138
|
+
g() && t?.beforeRestore?.(), j(l.past[l.past.length - 1], c);
|
|
88
139
|
},
|
|
89
140
|
redo: () => {
|
|
90
|
-
|
|
141
|
+
g() && t?.beforeRestore?.(), j(l.future[l.future.length - 1], s);
|
|
91
142
|
},
|
|
92
|
-
canUndo:
|
|
93
|
-
canRedo:
|
|
143
|
+
canUndo: _,
|
|
144
|
+
canRedo: v,
|
|
94
145
|
clearHistory: () => {
|
|
95
|
-
l =
|
|
146
|
+
l = a(), m = !1, y();
|
|
96
147
|
}
|
|
97
148
|
};
|
|
98
149
|
};
|
|
99
150
|
//#endregion
|
|
100
|
-
export {
|
|
151
|
+
export { u as createHistoryController, l as createHistoryRowLocator };
|
|
@@ -1 +1 @@
|
|
|
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"),
|
|
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("../logic/newRow.cjs"),o=require("./liveUiState.cjs"),s=require("./clipboardController.cjs"),c=require("./escapeClaimController.cjs");var l=10,u=(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},d=e=>u(e,0,1,0),f=e=>n.resolveFirstDataColIndex(e),p=(e,t)=>({row:d(e),col:f(t)}),m=()=>{let n=null,m=e=>{n=e},h=(e,t)=>u(e,t,-1,u(e,t,1,t)),g=e=>{let t=a.getSelectableRowCount(e),n=(t>0?t:e.getRowCount())-1;return u(e,n,-1,n)},_=(t,r,i)=>{if(n===null)return;let{dispatch:a}=n,s=o.readLiveUiState(n);if(i){let n=s.selection?.type===`cell`?s.selection.range.start:t;a(e.gridActions.startSelection(n)),a(e.gridActions.updateSelection(r)),a(e.gridActions.endSelection()),a(e.gridActions.activateCell(r));return}a(e.gridActions.startSelection(r)),a(e.gridActions.endSelection()),a(e.gridActions.activateCell(r))},v=()=>{if(n===null||o.readLiveUiState(n).activeCell)return!1;let{rowModel:e,visibleColumns:t}=n;if(e.getRowCount()===0||t.length===0)return!0;let r=p(e,t);return _(r,r,!1),!0},y=e=>{let t=n===null?void 0:o.readLiveUiState(n);return e&&t?.selection?.type===`cell`?t.selection.range.end:t?.activeCell??{row:0,col:0}},b=(e,t,i)=>{if(n===null)return;let{rowModel:a,visibleColumns:o}=n,s=a.getRowCount();if(s===0||o.length===0||v())return;let c=y(i),l=r.clamp(c.row+e,0,s-1);l=e===0?h(a,l):u(a,l,e>0?1:-1,c.row);let d={row:l,col:r.clamp(c.col+t,0,o.length-1)};_(c,d,i)},x=(e,t,i)=>{if(n===null)return;let{rowModel:a,visibleColumns:s}=n,c=o.readLiveUiState(n);if(a.getRowCount()===0||s.length===0)return;let l=c.activeCell?y(t):{row:d(a),col:f(s)},u=e(l,a,s),p=r.clamp(u.col,0,s.length-1);_(l,{row:h(a,r.clamp(u.row,0,a.getRowCount()-1)),col:p},t&&c.activeCell!==null);let m=i===void 0?null:n.scrollContainerRef?.current??null,g=s[p]?.pinned;m!==null&&(i===`start`?g===`left`:g===`right`)&&(m.scrollLeft=i===`start`?0:Math.max(m.scrollWidth-m.clientWidth,0))},S=(e,t,i)=>{let a=t.getRowCount(),o=n?.resolvePageRow?n.resolvePageRow(e.row,i):e.row+i*l,s=r.clamp(i>0?Math.max(o,e.row+1):Math.min(o,e.row-1),0,a-1),c=u(t,s,i,-1);return c>=0?c:u(t,s,i>0?-1:1,e.row)};return{update:m,handleKeyDown:async r=>{if(n===null)return;let{rowModel:l,visibleColumns:u,readOnly:p,canEditCell:m,setEditorInitialValue:h,dispatch:_,handleCopy:y,openFind:C,handleCellDoubleClick:w,selectEntireGrid:T,onUndo:E,onRedo:D,onClearSelection:O,enableClearOnDelete:k,onToggleCheckboxCell:A,onToggleGroup:j,onToggleDetailRow:M}=n,N=o.readLiveUiState(n),P=n.getUiState?s.computeIsWholeGridSelected(N.selection,a.getSelectableRowCount(l),u.length):n.isWholeGridSelected;if(i.shouldIgnoreGridKeydown(r.target)||o.isEditingAtEvent(n)||r.isComposing&&i.isImeInputTarget(r.target))return;if((r.ctrlKey||r.metaKey)&&r.key.toLowerCase()===`c`){r.preventDefault(),await y();return}if((r.ctrlKey||r.metaKey)&&!r.altKey&&r.key.toLowerCase()===`x`&&n.handleCut){r.preventDefault(),await n.handleCut();return}if((r.ctrlKey||r.metaKey)&&r.key.toLowerCase()===`f`&&C){r.preventDefault(),C();return}if((r.ctrlKey||r.metaKey)&&r.key.toLowerCase()===`a`){if(r.preventDefault(),P){_(e.gridActions.clearSelection()),_(e.gridActions.activateCell(null));return}T();return}if((r.ctrlKey||r.metaKey)&&!r.isComposing){if(r.key.toLowerCase()===`z`){r.preventDefault(),r.shiftKey?D():E();return}if(r.key.toLowerCase()===`y`&&!r.shiftKey){r.preventDefault(),D();return}}if(n.onShortcutKeyDown?.(r))return;let F=r.ctrlKey||r.metaKey;if((r.key===`ContextMenu`||r.key===`F10`&&r.shiftKey)&&!F&&!r.altKey&&N.activeCell&&n.openContextMenu?.(N.activeCell)){r.preventDefault();return}if((r.key===`ArrowDown`||r.key===`ArrowUp`)&&r.altKey&&r.shiftKey&&!F&&N.activeCell&&n.onToggleTreeRow?.(N.activeCell,r.key===`ArrowDown`)){r.preventDefault();return}if(r.key===`ArrowDown`&&r.altKey&&!F&&!r.shiftKey&&N.activeCell&&n.openColumnMenu?.(N.activeCell.col)){r.preventDefault();return}if(F&&!r.altKey&&(r.key===`ArrowUp`||r.key===`ArrowDown`)){r.preventDefault();let e=r.key===`ArrowDown`;x((t,n)=>({row:e?g(n):d(n),col:t.col}),r.shiftKey);return}if(F&&!r.altKey&&(r.key===`ArrowLeft`||r.key===`ArrowRight`)){r.preventDefault();let e=r.key===`ArrowRight`;x((t,n,r)=>({row:t.row,col:e?r.length-1:f(r)}),r.shiftKey,e?`end`:`start`);return}if((r.key===`Home`||r.key===`End`)&&!r.altKey){r.preventDefault();let e=r.key===`End`;x((t,n,r)=>({row:F?e?g(n):d(n):t.row,col:e?r.length-1:f(r)}),r.shiftKey,e?`end`:`start`);return}if((r.key===`PageDown`||r.key===`PageUp`)&&!F&&!r.altKey){if(r.preventDefault(),v())return;let e=r.key===`PageDown`?1:-1;x((t,n)=>({row:S(t,n,e),col:t.col}),r.shiftKey);return}if(r.key===`ArrowUp`){r.preventDefault(),b(-1,0,r.shiftKey);return}if(r.key===`ArrowDown`){r.preventDefault(),b(1,0,r.shiftKey);return}if(r.key===`ArrowLeft`){r.preventDefault(),b(0,-1,r.shiftKey);return}if(r.key===`ArrowRight`){r.preventDefault(),b(0,1,r.shiftKey);return}if(r.key===`Tab`){if(!N.activeCell&&!r.shiftKey){if(n.rowModel.getRowCount()===0||n.visibleColumns.length===0)return;r.preventDefault(),v();return}let e=N.activeCell?.col??0;if(r.shiftKey?e<=f(n.visibleColumns):e>=n.visibleColumns.length-1){!r.shiftKey&&N.activeCell&&(n.onTabPastLastColumn?.(N.activeCell.row)||n.onTabPastNewRowDraft?.(N.activeCell,a.resolveFirstEditableColIndex(n.visibleColumns,n.readOnly)))&&r.preventDefault();return}r.preventDefault(),b(0,r.shiftKey?-1:1,!1);return}if(r.key===`Escape`){if(N.activeCell&&n.onEscapeNewRow?.(N.activeCell)){r.preventDefault();return}c.isClearableSelection(N.selection)&&r.preventDefault(),_(e.gridActions.clearSelection());return}if((r.key===`Delete`||r.key===`Backspace`)&&k){r.preventDefault(),O();return}if((r.key===`Enter`||r.key===` `)&&N.activeCell){let e=l.getGroupRow?.(N.activeCell.row);if(e){r.preventDefault(),j(e.groupKey);return}if(M&&u[N.activeCell.col]?.key===`__ssg_detail_toggle__`&&M(N.activeCell)){r.preventDefault();return}}if(r.key===`Enter`||r.key===`F2`){if(r.preventDefault(),N.activeCell){w(N.activeCell);return}r.key===`Enter`&&v();return}if(r.key===` `&&!r.ctrlKey&&!r.metaKey&&!r.altKey&&r.preventDefault(),i.isPrintableKey(r)&&N.activeCell){let n=u[N.activeCell.col],i=a.resolveEditRow(l,N.activeCell.row,n!==void 0&&t.isColumnEditable(p,n));if(!i||!n||!t.isViewCellEditable({readOnly:p,canEditCell:m},l,N.activeCell.row,N.activeCell.col,i,n))return;if(n.editor?.type===`checkbox`){r.preventDefault(),r.key===` `&&A(N.activeCell);return}r.preventDefault(),h(r.key),_(e.gridActions.startEdit(N.activeCell))}}}};exports.createKeyboardController=m,exports.resolveFirstDataCell=p;
|
|
@@ -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;
|
|
@@ -32,6 +36,7 @@ export type KeyboardControllerArgs<T> = {
|
|
|
32
36
|
onToggleGroup: (groupKey: string) => void;
|
|
33
37
|
onToggleDetailRow?: (cell: CellCoord) => boolean;
|
|
34
38
|
resolvePageRow?: (fromRow: number, direction: 1 | -1) => number;
|
|
39
|
+
onToggleTreeRow?: ((cell: CellCoord, open: boolean) => boolean) | undefined;
|
|
35
40
|
openColumnMenu?: (col: number) => boolean;
|
|
36
41
|
openContextMenu?: (cell: CellCoord) => boolean;
|
|
37
42
|
onTabPastLastColumn?: (viewRowIndex: number) => boolean;
|