@ishibashi0112/spreadsheet-grid-core 1.9.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/changeTracker.cjs +1 -1
- package/dist/controllers/changeTracker.d.ts +5 -0
- package/dist/controllers/changeTracker.js +338 -165
- package/dist/controllers/clipboardController.cjs +2 -1
- package/dist/controllers/clipboardController.d.ts +5 -1
- package/dist/controllers/clipboardController.js +219 -96
- 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/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 +152 -142
- 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/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 +256 -0
- 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 +157 -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 +8 -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/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/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/imeInput.cjs +1 -1
- package/dist/logic/imeInput.js +22 -21
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +10 -0
- package/dist/logic/localeTextFeatures.js +17 -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 +1 -1
- 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 +175 -22
- package/dist/model/gridTypes.unbound.d.ts +1 -0
- 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
|
@@ -2,13 +2,14 @@ import { gridActions as e } from "../model/gridActions.js";
|
|
|
2
2
|
import { isViewCellEditable as t } from "../utils/permissions.js";
|
|
3
3
|
import { getActiveElement as n } from "../utils/shadowDom.js";
|
|
4
4
|
import { createValueStore as r } from "../logic/valueStore.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
5
|
+
import { getSelectableRowCount as i } from "../logic/newRow.js";
|
|
6
|
+
import { computeNextScrollPosition as a, hasPointerLeftActivationRadius as o, resolveAutoScrollAxisDirection as s, resolveScrollContentBox as c, resolveTopAutoScrollStart as l } from "../logic/autoScrollGeometry.js";
|
|
7
|
+
import { resolveElementScale as u } from "../logic/elementScale.js";
|
|
8
|
+
import { beginEscapeCancelableDrag as d } from "./escapeClaimController.js";
|
|
9
|
+
import { createPopoverWindowBindings as f, isInsideGridRoot as p, restoreGridFocus as m } from "./popoverSupport.js";
|
|
10
|
+
import { applyFillEditsToRows as h, buildFillEdits as g, isSameFillRange as _, previewFillValue as ee, resolveFillColumnBounds as v, resolveFillDoubleClickTarget as te, resolveFillSource as y, resolveFillTarget as b, unionFillRange as x } from "../logic/fillHandle.js";
|
|
10
11
|
//#region src/controllers/fillHandleController.ts
|
|
11
|
-
var
|
|
12
|
+
var S = 168, C = 84, w = 106, ne = () => typeof matchMedia == "function" && matchMedia("(pointer: coarse)").matches ? w : C, T = 8, E = { status: "idle" }, D = (e, t, n) => {
|
|
12
13
|
if (e.valueFormatter) try {
|
|
13
14
|
return e.valueFormatter({
|
|
14
15
|
value: n,
|
|
@@ -19,54 +20,54 @@ var ee = 168, C = 84, w = 106, T = () => typeof matchMedia == "function" && matc
|
|
|
19
20
|
return String(n ?? "");
|
|
20
21
|
}
|
|
21
22
|
return String(n ?? "");
|
|
22
|
-
},
|
|
23
|
+
}, O = (e, t) => e === t || e.length === t.length && e.every((e, n) => e.key === t[n].key), k = 500, A = 6, j = 2, re = (e) => {
|
|
23
24
|
let t = e.currentTarget;
|
|
24
25
|
if (!(t instanceof Element)) return !0;
|
|
25
26
|
let n = t.getBoundingClientRect();
|
|
26
|
-
return e.clientX >= n.left -
|
|
27
|
-
},
|
|
28
|
-
let C = null, w = r(
|
|
27
|
+
return e.clientX >= n.left - j && e.clientX <= n.right + j && e.clientY >= n.top - j && e.clientY <= n.bottom + j;
|
|
28
|
+
}, M = (e, t) => e === t || e !== void 0 && t !== void 0 && e.length === t.length && e.every((e, n) => Object.is(e, t[n])), N = (e, t) => Object.is(e, t) || e instanceof Date && t instanceof Date && e.getTime() === t.getTime(), P = (e, t) => e.length === t.length && e.every((e, n) => e.viewIndex === t[n].viewIndex && e.column.key === t[n].column.key && N(e.value, t[n].value)), F = () => {
|
|
29
|
+
let C = null, w = r(E), j = r(null), N = { current: null }, F = { current: null }, I = null, L = null, R = null, z = (e) => e ? "toggled" : "auto", B = (e) => (n, r, i, a) => t({
|
|
29
30
|
readOnly: e.readOnly,
|
|
30
31
|
canEditCell: e.canEditCell
|
|
31
|
-
}, e.rowModel, n, r, i, a),
|
|
32
|
-
if (
|
|
32
|
+
}, e.rowModel, n, r, i, a), V = () => {
|
|
33
|
+
if (R === null || C === null) return;
|
|
33
34
|
let e = w.getSnapshot();
|
|
34
|
-
if (e.status === "dragging" && e.toggled ===
|
|
35
|
+
if (e.status === "dragging" && e.toggled === R.toggled && (e.target === R.target || e.target !== null && R.target !== null && e.target.direction === R.target.direction && _(e.target.range, R.target.range))) return;
|
|
35
36
|
let t = null;
|
|
36
|
-
if (
|
|
37
|
-
let e =
|
|
37
|
+
if (R.target !== null) {
|
|
38
|
+
let e = ee({
|
|
38
39
|
rowModel: C.rowModel,
|
|
39
40
|
columns: C.columns,
|
|
40
|
-
source:
|
|
41
|
-
target:
|
|
42
|
-
request:
|
|
43
|
-
canWriteCell:
|
|
41
|
+
source: R.source,
|
|
42
|
+
target: R.target,
|
|
43
|
+
request: z(R.toggled),
|
|
44
|
+
canWriteCell: B(C),
|
|
44
45
|
getFillValue: C.getFillValue
|
|
45
46
|
});
|
|
46
|
-
t = e &&
|
|
47
|
+
t = e && D(e.column, e.row, e.value) || null;
|
|
47
48
|
}
|
|
48
49
|
w.setSnapshot({
|
|
49
50
|
status: "dragging",
|
|
50
|
-
source:
|
|
51
|
-
target:
|
|
52
|
-
toggled:
|
|
51
|
+
source: R.source,
|
|
52
|
+
target: R.target,
|
|
53
|
+
toggled: R.toggled,
|
|
53
54
|
previewText: t
|
|
54
55
|
});
|
|
55
|
-
},
|
|
56
|
-
if (
|
|
57
|
-
let e = v(C.columns), t = C.hitTest(
|
|
58
|
-
e === null || t === null || (
|
|
59
|
-
},
|
|
60
|
-
if (
|
|
61
|
-
let e =
|
|
62
|
-
e.rafId = requestAnimationFrame(
|
|
56
|
+
}, H = () => {
|
|
57
|
+
if (R === null || C === null) return;
|
|
58
|
+
let e = v(C.columns), t = C.hitTest(R.pointer.x, R.pointer.y);
|
|
59
|
+
e === null || t === null || (R.target = b(R.source, t, i(C.rowModel), e), V());
|
|
60
|
+
}, U = () => {
|
|
61
|
+
if (R === null || C === null) return;
|
|
62
|
+
let e = R;
|
|
63
|
+
e.rafId = requestAnimationFrame(U);
|
|
63
64
|
let t = C.scrollContainerRef.current;
|
|
64
65
|
if (!t) return;
|
|
65
66
|
if (!e.armed) {
|
|
66
|
-
if (!
|
|
67
|
+
if (!o(e.origin, e.pointer, 6)) return;
|
|
67
68
|
e.armed = !0;
|
|
68
69
|
}
|
|
69
|
-
let n = t.getBoundingClientRect(), r =
|
|
70
|
+
let n = t.getBoundingClientRect(), r = u(t, n), i = c({
|
|
70
71
|
rectLeft: n.left,
|
|
71
72
|
rectTop: n.top,
|
|
72
73
|
clientLeft: t.clientLeft,
|
|
@@ -74,26 +75,26 @@ var ee = 168, C = 84, w = 106, T = () => typeof matchMedia == "function" && matc
|
|
|
74
75
|
clientWidth: t.clientWidth,
|
|
75
76
|
clientHeight: t.clientHeight,
|
|
76
77
|
scale: r
|
|
77
|
-
}), d =
|
|
78
|
+
}), d = a(t.scrollTop, s(e.pointer.y, l(i.top, (C.stickyTopHeight ?? 0) * r.y, 24), i.bottom - (C.footerHeight ?? 0), 24), 18, t.scrollHeight - t.clientHeight), f = a(t.scrollLeft, s(e.pointer.x, i.left, i.right, 24), 18, t.scrollWidth - t.clientWidth);
|
|
78
79
|
(d !== t.scrollTop || f !== t.scrollLeft) && (t.scrollTo({
|
|
79
80
|
top: d,
|
|
80
81
|
left: f,
|
|
81
82
|
behavior: "auto"
|
|
82
|
-
}),
|
|
83
|
-
},
|
|
84
|
-
let n =
|
|
83
|
+
}), H());
|
|
84
|
+
}, W = (e, t) => {
|
|
85
|
+
let n = R;
|
|
85
86
|
if (n !== null) {
|
|
86
|
-
if (
|
|
87
|
-
|
|
87
|
+
if (R = null, n.cleanup(), n.rafId !== null && cancelAnimationFrame(n.rafId), j.setSnapshot(null), w.setSnapshot(E), e && n.target !== null) {
|
|
88
|
+
L = null, q(n.source, n.target, z(n.toggled), n.activeCell);
|
|
88
89
|
return;
|
|
89
90
|
}
|
|
90
|
-
|
|
91
|
+
L = e && t !== void 0 && n.onSquare ? {
|
|
91
92
|
time: t,
|
|
92
93
|
x: n.origin.x,
|
|
93
94
|
y: n.origin.y
|
|
94
95
|
} : null;
|
|
95
96
|
}
|
|
96
|
-
},
|
|
97
|
+
}, G = (t, n) => {
|
|
97
98
|
if (C === null) return;
|
|
98
99
|
let { dispatch: r } = C;
|
|
99
100
|
r(e.startSelection({
|
|
@@ -106,33 +107,33 @@ var ee = 168, C = 84, w = 106, T = () => typeof matchMedia == "function" && matc
|
|
|
106
107
|
row: t.startRow,
|
|
107
108
|
col: t.startCol
|
|
108
109
|
}));
|
|
109
|
-
},
|
|
110
|
+
}, K = (e, t) => {
|
|
110
111
|
let n = [];
|
|
111
112
|
for (let r = t.startRow; r <= t.endRow; r += 1) n.push(e.getRowKey(r));
|
|
112
113
|
return n;
|
|
113
114
|
}, q = (e, t, n, r) => {
|
|
114
115
|
if (C === null || !C.enabled) return;
|
|
115
|
-
let i = C, a =
|
|
116
|
+
let i = C, a = g({
|
|
116
117
|
rowModel: i.rowModel,
|
|
117
118
|
columns: i.columns,
|
|
118
119
|
source: e,
|
|
119
120
|
target: t,
|
|
120
121
|
request: n,
|
|
121
|
-
canWriteCell:
|
|
122
|
+
canWriteCell: B(i),
|
|
122
123
|
getFillValue: i.getFillValue
|
|
123
124
|
});
|
|
124
125
|
if (a.edits.length === 0) return;
|
|
125
|
-
let o =
|
|
126
|
+
let o = x(e, t), s = null, c = [], l = null;
|
|
126
127
|
if (i.isServerSide) {
|
|
127
128
|
if (!i.applyServerSideCellEdits) return;
|
|
128
|
-
l =
|
|
129
|
+
l = K(i.rowModel, o), i.applyServerSideCellEdits(a.edits);
|
|
129
130
|
} else {
|
|
130
131
|
if (!i.applyRowsChange) return;
|
|
131
|
-
let e =
|
|
132
|
+
let e = h(i.rows, i.rowModel, a.edits);
|
|
132
133
|
if (e === i.rows) return;
|
|
133
134
|
s = i.rows, c.push(e), i.applyRowsChange(e);
|
|
134
135
|
}
|
|
135
|
-
|
|
136
|
+
I = {
|
|
136
137
|
source: e,
|
|
137
138
|
target: t,
|
|
138
139
|
range: o,
|
|
@@ -146,20 +147,20 @@ var ee = 168, C = 84, w = 106, T = () => typeof matchMedia == "function" && matc
|
|
|
146
147
|
baseRowModel: i.isServerSide ? null : i.rowModel,
|
|
147
148
|
emittedRows: c,
|
|
148
149
|
rowKeys: l
|
|
149
|
-
},
|
|
150
|
+
}, G(o, r), w.setSnapshot({
|
|
150
151
|
status: "filled",
|
|
151
152
|
range: o,
|
|
152
153
|
kind: a.kind,
|
|
153
154
|
seriesAvailable: a.seriesAvailable,
|
|
154
155
|
menu: null
|
|
155
156
|
});
|
|
156
|
-
}, J =
|
|
157
|
+
}, J = f({
|
|
157
158
|
onScroll: (e) => {
|
|
158
|
-
e.target instanceof Node &&
|
|
159
|
+
e.target instanceof Node && N.current?.contains(e.target) || X(!1);
|
|
159
160
|
},
|
|
160
161
|
onResize: () => X(!1),
|
|
161
|
-
isInside: (e) =>
|
|
162
|
-
onOutsidePointerDown: (e) => X(C !== null &&
|
|
162
|
+
isInside: (e) => N.current?.contains(e) === !0 || F.current?.contains(e) === !0,
|
|
163
|
+
onOutsidePointerDown: (e) => X(C !== null && p(C.gridRootRef, e)),
|
|
163
164
|
getGridRoot: () => C?.gridRootRef.current ?? null,
|
|
164
165
|
onGridHidden: () => X(!1),
|
|
165
166
|
onKeyDown: (e) => {
|
|
@@ -172,48 +173,48 @@ var ee = 168, C = 84, w = 106, T = () => typeof matchMedia == "function" && matc
|
|
|
172
173
|
menu: e
|
|
173
174
|
});
|
|
174
175
|
}, X = (e) => {
|
|
175
|
-
J.detach(), Y(null), e && C !== null &&
|
|
176
|
+
J.detach(), Y(null), e && C !== null && m(C.gridRootRef);
|
|
176
177
|
}, Z = () => {
|
|
177
|
-
let e = typeof document < "u" &&
|
|
178
|
-
|
|
179
|
-
},
|
|
178
|
+
let e = typeof document < "u" && N.current?.contains(n(N.current)) === !0;
|
|
179
|
+
I = null, J.detach(), w.getSnapshot().status === "filled" && w.setSnapshot(E), e && C !== null && m(C.gridRootRef);
|
|
180
|
+
}, ie = (e) => {
|
|
180
181
|
let t = w.getSnapshot();
|
|
181
182
|
if (t.status !== "filled") return;
|
|
182
183
|
if (t.menu !== null) {
|
|
183
184
|
X(!0);
|
|
184
185
|
return;
|
|
185
186
|
}
|
|
186
|
-
let n = Math.min(e.left, window.innerWidth -
|
|
187
|
-
n = Math.max(
|
|
188
|
-
let r = e.bottom + 4, i =
|
|
189
|
-
r + i > window.innerHeight -
|
|
187
|
+
let n = Math.min(e.left, window.innerWidth - S - T);
|
|
188
|
+
n = Math.max(T, n);
|
|
189
|
+
let r = e.bottom + 4, i = ne();
|
|
190
|
+
r + i > window.innerHeight - T && (r = Math.max(T, e.top - 4 - i)), Y({
|
|
190
191
|
top: r,
|
|
191
192
|
left: n
|
|
192
193
|
}), J.attach();
|
|
193
|
-
},
|
|
194
|
+
}, ae = (e, t) => {
|
|
194
195
|
let n = t.rowKeys;
|
|
195
196
|
if (n === null) return !1;
|
|
196
197
|
for (let r = 0; r < n.length; r += 1) if (e.getRowKey(t.range.startRow + r) !== n[r]) return !1;
|
|
197
198
|
return !0;
|
|
198
|
-
},
|
|
199
|
-
let n = w.getSnapshot(), r =
|
|
199
|
+
}, oe = (e) => {
|
|
200
|
+
let n = w.getSnapshot(), r = I;
|
|
200
201
|
if (X(!0), C === null || r === null || n.status !== "filled" || r.request === e) return;
|
|
201
202
|
let i = C;
|
|
202
203
|
if (i.isServerSide) {
|
|
203
|
-
if (!i.applyServerSideCellEdits || !
|
|
204
|
+
if (!i.applyServerSideCellEdits || !ae(i.rowModel, r)) {
|
|
204
205
|
Z();
|
|
205
206
|
return;
|
|
206
207
|
}
|
|
207
|
-
let t =
|
|
208
|
+
let t = g({
|
|
208
209
|
rowModel: i.rowModel,
|
|
209
210
|
columns: r.columns,
|
|
210
211
|
source: r.source,
|
|
211
212
|
target: r.target,
|
|
212
213
|
request: e,
|
|
213
|
-
canWriteCell:
|
|
214
|
+
canWriteCell: B(i),
|
|
214
215
|
getFillValue: i.getFillValue
|
|
215
216
|
});
|
|
216
|
-
r.request = e, t.edits.length > 0 && !
|
|
217
|
+
r.request = e, t.edits.length > 0 && !P(t.edits, r.edits) && i.applyServerSideCellEdits(t.edits), r.edits = t.edits, w.setSnapshot({
|
|
217
218
|
...n,
|
|
218
219
|
kind: t.kind,
|
|
219
220
|
menu: null
|
|
@@ -224,7 +225,7 @@ var ee = 168, C = 84, w = 106, T = () => typeof matchMedia == "function" && matc
|
|
|
224
225
|
Z();
|
|
225
226
|
return;
|
|
226
227
|
}
|
|
227
|
-
let a = r.baseRowModel, o =
|
|
228
|
+
let a = r.baseRowModel, o = g({
|
|
228
229
|
rowModel: a,
|
|
229
230
|
columns: r.columns,
|
|
230
231
|
source: r.source,
|
|
@@ -236,8 +237,8 @@ var ee = 168, C = 84, w = 106, T = () => typeof matchMedia == "function" && matc
|
|
|
236
237
|
}, a, e, n, r, o),
|
|
237
238
|
getFillValue: i.getFillValue
|
|
238
239
|
});
|
|
239
|
-
if (r.request = e, !
|
|
240
|
-
let e =
|
|
240
|
+
if (r.request = e, !P(o.edits, r.edits)) {
|
|
241
|
+
let e = h(r.baseRows, a, o.edits);
|
|
241
242
|
r.emittedRows.push(e), r.edits = o.edits, i.amendRowsChange(e);
|
|
242
243
|
}
|
|
243
244
|
w.setSnapshot({
|
|
@@ -248,16 +249,16 @@ var ee = 168, C = 84, w = 106, T = () => typeof matchMedia == "function" && matc
|
|
|
248
249
|
}, Q = (e, t) => {
|
|
249
250
|
if (e?.type !== "cell") return !1;
|
|
250
251
|
let { start: n, end: r } = e.range;
|
|
251
|
-
return
|
|
252
|
+
return _(t, {
|
|
252
253
|
startRow: Math.min(n.row, r.row),
|
|
253
254
|
endRow: Math.max(n.row, r.row),
|
|
254
255
|
startCol: Math.min(n.col, r.col),
|
|
255
256
|
endCol: Math.max(n.col, r.col)
|
|
256
257
|
});
|
|
257
|
-
},
|
|
258
|
-
let t =
|
|
258
|
+
}, se = (e) => {
|
|
259
|
+
let t = I;
|
|
259
260
|
if (t !== null) {
|
|
260
|
-
if (!e.enabled || e.editing || !
|
|
261
|
+
if (!e.enabled || e.editing || !O(e.columns, t.columns) || !M(e.viewKey, t.viewKey)) {
|
|
261
262
|
Z();
|
|
262
263
|
return;
|
|
263
264
|
}
|
|
@@ -271,82 +272,82 @@ var ee = 168, C = 84, w = 106, T = () => typeof matchMedia == "function" && matc
|
|
|
271
272
|
}
|
|
272
273
|
!t.selectionConfirmed && Q(e.selection, t.previousSource) || Z();
|
|
273
274
|
}
|
|
274
|
-
},
|
|
275
|
-
if (C === null || e.button !== 0 || (e.preventDefault(),
|
|
276
|
-
let t =
|
|
275
|
+
}, ce = (e) => {
|
|
276
|
+
if (C === null || e.button !== 0 || (e.preventDefault(), R !== null || !C.enabled || C.editing)) return;
|
|
277
|
+
let t = y(C.selection, C.activeCell, i(C.rowModel), C.columns.length);
|
|
277
278
|
if (t === null) return;
|
|
278
|
-
let n =
|
|
279
|
-
|
|
280
|
-
let r =
|
|
281
|
-
if (n !== null && r && e.timeStamp - n.time <=
|
|
279
|
+
let n = L;
|
|
280
|
+
L = null;
|
|
281
|
+
let r = re(e);
|
|
282
|
+
if (n !== null && r && e.timeStamp - n.time <= k && Math.abs(e.clientX - n.x) <= A && Math.abs(e.clientY - n.y) <= A) {
|
|
282
283
|
C.gridRootRef.current?.focus({ preventScroll: !0 }), $();
|
|
283
284
|
return;
|
|
284
285
|
}
|
|
285
286
|
Z(), C.gridRootRef.current?.focus({ preventScroll: !0 });
|
|
286
|
-
let
|
|
287
|
-
|
|
287
|
+
let a = e.pointerId, o = (e) => {
|
|
288
|
+
R === null || e.pointerId !== a || (R.pointer = {
|
|
288
289
|
x: e.clientX,
|
|
289
290
|
y: e.clientY
|
|
290
|
-
},
|
|
291
|
-
}, o = (e) => {
|
|
292
|
-
B === null || e.pointerId !== i || (B.toggled = e.ctrlKey || e.metaKey, K(!0, e.timeStamp));
|
|
291
|
+
}, R.toggled = e.ctrlKey || e.metaKey, j.setSnapshot(R.pointer), H());
|
|
293
292
|
}, s = (e) => {
|
|
294
|
-
e.pointerId
|
|
293
|
+
R === null || e.pointerId !== a || (R.toggled = e.ctrlKey || e.metaKey, W(!0, e.timeStamp));
|
|
295
294
|
}, c = (e) => {
|
|
296
|
-
|
|
295
|
+
e.pointerId === a && W(!1);
|
|
296
|
+
}, l = (e) => {
|
|
297
|
+
if (R === null) return;
|
|
297
298
|
if (e.preventDefault(), e.stopPropagation(), e.type === "keydown" && e.key === "Escape") {
|
|
298
|
-
|
|
299
|
+
W(!1);
|
|
299
300
|
return;
|
|
300
301
|
}
|
|
301
302
|
let t = e.ctrlKey || e.metaKey;
|
|
302
|
-
t !==
|
|
303
|
-
},
|
|
304
|
-
window.addEventListener("pointermove",
|
|
305
|
-
let
|
|
303
|
+
t !== R.toggled && (R.toggled = t, V());
|
|
304
|
+
}, u = () => W(!1);
|
|
305
|
+
window.addEventListener("pointermove", o), window.addEventListener("pointerup", s), window.addEventListener("pointercancel", c), window.addEventListener("keydown", l, !0), window.addEventListener("keyup", l, !0), window.addEventListener("blur", u);
|
|
306
|
+
let f = d(), p = {
|
|
306
307
|
x: e.clientX,
|
|
307
308
|
y: e.clientY
|
|
308
309
|
};
|
|
309
|
-
|
|
310
|
-
pointerId:
|
|
310
|
+
R = {
|
|
311
|
+
pointerId: a,
|
|
311
312
|
source: t,
|
|
312
313
|
activeCell: C.activeCell,
|
|
313
|
-
origin:
|
|
314
|
+
origin: p,
|
|
314
315
|
onSquare: r,
|
|
315
|
-
pointer:
|
|
316
|
+
pointer: p,
|
|
316
317
|
toggled: e.ctrlKey || e.metaKey,
|
|
317
318
|
target: null,
|
|
318
319
|
armed: !1,
|
|
319
320
|
rafId: null,
|
|
320
321
|
cleanup: () => {
|
|
321
|
-
window.removeEventListener("pointermove",
|
|
322
|
+
window.removeEventListener("pointermove", o), window.removeEventListener("pointerup", s), window.removeEventListener("pointercancel", c), window.removeEventListener("keydown", l, !0), window.removeEventListener("keyup", l, !0), window.removeEventListener("blur", u), f();
|
|
322
323
|
}
|
|
323
|
-
},
|
|
324
|
+
}, j.setSnapshot(p), V(), R.rafId = requestAnimationFrame(U);
|
|
324
325
|
}, $ = () => {
|
|
325
|
-
if (C === null ||
|
|
326
|
-
let e =
|
|
326
|
+
if (C === null || R !== null || !C.enabled || C.editing) return;
|
|
327
|
+
let e = y(C.selection, C.activeCell, i(C.rowModel), C.columns.length);
|
|
327
328
|
if (e === null) return;
|
|
328
|
-
let t =
|
|
329
|
+
let t = te(e, C.rowModel, C.columns);
|
|
329
330
|
t !== null && (Z(), q(e, t, "auto", C.activeCell));
|
|
330
331
|
};
|
|
331
332
|
return {
|
|
332
333
|
update: (e) => {
|
|
333
|
-
C = e,
|
|
334
|
+
C = e, R !== null && (!e.enabled || e.editing) && W(!1), se(e);
|
|
334
335
|
},
|
|
335
336
|
subscribe: w.subscribe,
|
|
336
337
|
getSnapshot: w.getSnapshot,
|
|
337
|
-
subscribePointer:
|
|
338
|
-
getPointerSnapshot:
|
|
339
|
-
handlePointerDown:
|
|
338
|
+
subscribePointer: j.subscribe,
|
|
339
|
+
getPointerSnapshot: j.getSnapshot,
|
|
340
|
+
handlePointerDown: ce,
|
|
340
341
|
handleDoubleClick: $,
|
|
341
|
-
toggleMenu:
|
|
342
|
+
toggleMenu: ie,
|
|
342
343
|
closeMenu: () => X(!0),
|
|
343
|
-
chooseKind:
|
|
344
|
-
menuPanel:
|
|
345
|
-
chipElement:
|
|
344
|
+
chooseKind: oe,
|
|
345
|
+
menuPanel: N,
|
|
346
|
+
chipElement: F,
|
|
346
347
|
dispose: () => {
|
|
347
|
-
|
|
348
|
+
W(!1), J.detach(), I = null;
|
|
348
349
|
}
|
|
349
350
|
};
|
|
350
351
|
};
|
|
351
352
|
//#endregion
|
|
352
|
-
export {
|
|
353
|
+
export { F as createFillHandleController };
|
|
@@ -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/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;
|