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