@sheetxl/grid-react 0.7.19 → 0.7.21
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/browser/cjs/index.cjs +4 -4
- package/browser/esm/index.mjs +1126 -1123
- package/node/esm/index.mjs +517 -513
- package/package.json +3 -3
- package/types/index.d.ts +307 -297
package/node/esm/index.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license @sheetxl/grid-react - Grid React - Advanced grid component for React - v0.7.
|
|
2
|
+
* @license @sheetxl/grid-react - Grid React - Advanced grid component for React - v0.7.21
|
|
3
3
|
*
|
|
4
4
|
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
5
5
|
* License: The license can be found at https://www.sheetxl.com/license.
|
|
6
6
|
*/
|
|
7
7
|
import { jsx as e, jsxs as t, Fragment as n } from "react/jsx-runtime";
|
|
8
8
|
import { useCallbackRef as o, HorizontalAlignment as r, KeyCodes as l, ReactUtils as i, MouseButtonCodes as c, useSynchronizedPointerHandler as s, useId as a, useAnimatedMeasure as d, useFullscreenPortal as u, SimpleCommand as h, KeyModifiers as g, useImperativeElement as f, ScrollPane as w } from "@sheetxl/utils-react";
|
|
9
|
-
import { useRef as x, useReducer as p, useState as m, useEffect as v, useCallback as S, useLayoutEffect as y, useMemo as b, memo as C, forwardRef as I, createElement as E
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { CoordUtils as
|
|
13
|
-
import { useMeasure as
|
|
9
|
+
import { useRef as x, useReducer as p, useState as m, useEffect as v, useCallback as S, useLayoutEffect as y, useMemo as b, memo as C, forwardRef as I, createElement as E } from "react";
|
|
10
|
+
import R from "tiny-invariant";
|
|
11
|
+
import M from "clsx";
|
|
12
|
+
import { CoordUtils as k, CommonUtils as P, RangeOrientation as T, Direction as D, AnchorLocation as O } from "@sheetxl/utils";
|
|
13
|
+
import { useMeasure as z } from "react-use";
|
|
14
|
+
import { mergeRefs as L } from "react-merge-refs";
|
|
14
15
|
import { createPortal as $ } from "react-dom";
|
|
15
|
-
|
|
16
|
-
const F = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2 = 1 }) => {
|
|
16
|
+
const B = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2 = 1 }) => {
|
|
17
17
|
let l2, i2, c2;
|
|
18
18
|
"column" === e2 ? (l2 = o2.columnMetadataMap, i2 = o2.lastMeasuredColumnIndex, c2 = o2.recalcColumnIndices) : (l2 = o2.rowMetadataMap, i2 = o2.lastMeasuredRowIndex, c2 = o2.recalcRowIndices);
|
|
19
19
|
const s2 = c2.length > 0;
|
|
@@ -30,28 +30,28 @@ const F = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2
|
|
|
30
30
|
"column" === e2 ? o2.lastMeasuredColumnIndex = t2 : o2.lastMeasuredRowIndex = t2;
|
|
31
31
|
}
|
|
32
32
|
return l2[t2], l2[t2];
|
|
33
|
-
},
|
|
33
|
+
}, F = ({ itemType: e2, itemSize: t2, itemCount: n2, instanceProps: o2, offset: r2, scale: l2 }) => {
|
|
34
34
|
let i2, c2;
|
|
35
35
|
"column" === e2 ? (i2 = o2.columnMetadataMap, c2 = o2.lastMeasuredColumnIndex) : (i2 = o2.rowMetadataMap, c2 = o2.lastMeasuredRowIndex);
|
|
36
36
|
let s2 = 0;
|
|
37
|
-
return s2 = (c2 > 0 ? i2[c2].offset : 0) >= r2 ? A({ itemType: e2, itemSize: t2, instanceProps: o2, high: c2, low: 0, offset: r2, scale: l2 }) :
|
|
37
|
+
return s2 = (c2 > 0 ? i2[c2].offset : 0) >= r2 ? A({ itemType: e2, itemSize: t2, instanceProps: o2, high: c2, low: 0, offset: r2, scale: l2 }) : W({ itemType: e2, itemSize: t2, itemCount: n2, instanceProps: o2, index: Math.max(0, c2), offset: r2, scale: l2 }), s2 = Math.min(s2, n2), s2;
|
|
38
38
|
}, A = ({ itemType: e2, itemSize: t2, instanceProps: n2, high: o2, low: r2, offset: l2, scale: i2 }) => {
|
|
39
39
|
for (; r2 <= o2; ) {
|
|
40
|
-
const c2 = r2 + Math.floor((o2 - r2) / 2), s2 =
|
|
40
|
+
const c2 = r2 + Math.floor((o2 - r2) / 2), s2 = B({ itemType: e2, itemSize: t2, index: c2, instanceProps: n2, scale: i2 }).offset;
|
|
41
41
|
if (s2 === l2) return c2;
|
|
42
42
|
s2 < l2 ? r2 = c2 + 1 : s2 > l2 && (o2 = c2 - 1);
|
|
43
43
|
}
|
|
44
44
|
return r2 > 0 ? r2 - 1 : 0;
|
|
45
|
-
},
|
|
45
|
+
}, W = ({ itemType: e2, itemSize: t2, itemCount: n2, instanceProps: o2, index: r2, offset: l2, scale: i2 }) => {
|
|
46
46
|
let c2 = 1;
|
|
47
|
-
for (; r2 < n2 &&
|
|
47
|
+
for (; r2 < n2 && B({ itemType: e2, itemSize: t2, index: r2, instanceProps: o2, scale: i2 }).offset < l2; ) r2 += c2, c2 *= 2;
|
|
48
48
|
return A({ itemType: e2, itemSize: t2, instanceProps: o2, high: Math.min(r2, n2 - 1), low: Math.floor(r2 / 2), offset: l2, scale: i2 });
|
|
49
|
-
},
|
|
50
|
-
const { rowCount: t2, columnCount: n2, defaultRowHeight: r2, getRowHeight: l2, defaultColumnWidth: i2, getColumnWidth: c2 } = e2 || {}, s2 = x({ columnMetadataMap: {}, rowMetadataMap: {}, lastMeasuredColumnIndex: -1, lastMeasuredRowIndex: -1, recalcColumnIndices: [], recalcRowIndices: [] }), a2 = o((e3) =>
|
|
49
|
+
}, V = (e2) => {
|
|
50
|
+
const { rowCount: t2, columnCount: n2, defaultRowHeight: r2, getRowHeight: l2, defaultColumnWidth: i2, getColumnWidth: c2 } = e2 || {}, s2 = x({ columnMetadataMap: {}, rowMetadataMap: {}, lastMeasuredColumnIndex: -1, lastMeasuredRowIndex: -1, recalcColumnIndices: [], recalcRowIndices: [] }), a2 = o((e3) => F({ itemType: "row", itemCount: t2, itemSize: l2 ?? (() => r2 ?? 20), instanceProps: s2.current, offset: e3 }), [t2, l2, r2]), d2 = o((e3) => -1 === e3 ? 0 : B({ itemType: "row", index: e3, itemSize: l2 ?? (() => r2 ?? 20), instanceProps: s2.current }).offset, [l2, r2]), u2 = o((e3) => B({ itemType: "row", index: e3, itemSize: l2 ?? (() => r2 ?? 20), instanceProps: s2.current }).size, [l2, r2]), h2 = o((e3) => F({ itemType: "column", itemCount: n2, itemSize: c2 ?? (() => i2 ?? 75), instanceProps: s2.current, offset: e3 }), [n2, c2, i2]), g2 = o((e3) => -1 === e3 ? 0 : B({ itemType: "column", index: e3, itemSize: c2 ?? (() => i2 ?? 75), instanceProps: s2.current }).offset, [c2, i2]), f2 = o((e3) => B({ itemType: "column", index: e3, itemSize: c2 ?? (() => i2 ?? 75), instanceProps: s2.current }).size, [c2, i2]), [w2, S2] = p((e3) => e3 + 1, 0), y2 = () => ({ getRowOffset: d2, getColOffset: g2, getRowIndex: a2, getColIndex: h2 }), [b2, C2] = m(() => e2 ? y2() : null);
|
|
51
51
|
return v(() => {
|
|
52
52
|
C2(e2 ? y2() : null);
|
|
53
53
|
}, [w2, t2, n2, i2, r2, u2, f2]), b2;
|
|
54
|
-
},
|
|
54
|
+
}, U = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ~`!@#$%^&*()-_=+[{]};:'\",<.>/?|\\", H = (e2) => {
|
|
55
55
|
if (!e2) return null;
|
|
56
56
|
if ("start" === e2.eventType) return { type: e2.eventType };
|
|
57
57
|
if ("submit" === e2.eventType) return { type: e2.eventType };
|
|
@@ -63,7 +63,7 @@ const F = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2
|
|
|
63
63
|
return e2.activeCoords && (t2.activeCoords = e2.activeCoords), t2;
|
|
64
64
|
}
|
|
65
65
|
return { type: e2.eventType ?? "unknown" };
|
|
66
|
-
},
|
|
66
|
+
}, K = (e2) => true, N = (e2) => !!e2 && (!(e2.ctrlKey || e2.metaKey || e2.altKey || e2.isComposing) && (!(e2.shiftKey || "F2" !== e2.key && " " !== e2.key && "Backspace" !== e2.key) || (!e2.shiftKey || " " !== e2.key) && -1 !== U.indexOf(e2.key))), q = (e2) => !!e2 && ("dblclick" === e2.type && { editMode: true }), j = (t2) => {
|
|
67
67
|
const { session: n2, refLatestCoords: o2, handleSubmitEdit: l2, handleCancelEdit: c2, cellBounds: s2, isInBounds: a2, getCellEditor: d2, propsEditor: u2, borderStrokeFill: h2 = "rgb(33, 115, 70)", borderStrokeWidth: g2 = 2, alignment: f2 = r.Left, style: w2, ...p2 } = t2, y2 = x(null), b2 = x(null), [C2, I2] = m(false), E2 = n2.coords, R2 = S(async (e2) => {
|
|
68
68
|
const t3 = y2.current?.getBoundingClientRect();
|
|
69
69
|
if (t3) {
|
|
@@ -87,12 +87,12 @@ const F = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2
|
|
|
87
87
|
-1 !== t3 && n2.editorRefs.splice(t3, 1), n2.onUnmount(e2);
|
|
88
88
|
};
|
|
89
89
|
}, []);
|
|
90
|
-
const M2 = S(() => l2(n2), []),
|
|
90
|
+
const M2 = S(() => l2(n2), []), P2 = S(() => {
|
|
91
91
|
c2(n2);
|
|
92
|
-
}, []), T2 = o2.current &&
|
|
92
|
+
}, []), T2 = o2.current && k.isEqualCells(o2.current, E2), D2 = a2 && T2 && C2, O2 = d2({ autoFocus: !!n2.startEvent?.autoFocus, ...u2, onSubmitEdit: M2, onCancelEdit: P2, ref: b2 }, E2), z2 = s2.x + i.boundPixel(-g2 / 2), L2 = i.boundPixel(s2.width + g2 / 2, true);
|
|
93
93
|
return e("div", { tabIndex: 0, ref: y2, style: { background: void 0, ...w2, opacity: D2 ? w2?.opacity ?? 1 : 0, pointerEvents: "auto", position: "absolute", boxSizing: "border-box", top: `${s2.y + i.boundPixel(-g2 / 2)}px`, height: i.boundPixel(s2.height + g2 / 2, true), left: `${z2}px`, width: L2 }, ...p2, children: e("div", { className: "editor-container", style: { position: "absolute", boxSizing: "border-box", left: `${i.boundPixel(1)}px`, top: `${i.boundPixel(1)}px`, width: i.boundPixel(s2.width - 2, true), height: i.boundPixel(s2.height - 2, true), outline: `${g2}px ${h2} solid`, boxShadow: "rgba(60,64,67,.35) 2px 2px 6px 3px", maxHeight: "100%", overflow: "hidden", display: "flex" }, children: O2 }) });
|
|
94
|
-
},
|
|
95
|
-
const { view: n2, canEdit: i2 =
|
|
94
|
+
}, X = (t2) => {
|
|
95
|
+
const { view: n2, canEdit: i2 = K, getCellEditor: c2, onBeforeStartEdit: s2, onStartEdit: a2, onSubmitEdit: d2, onCancelEdit: u2, onDoneEdit: h2, isEditorStartKeyEvent: g2 = N, isEditorStartPointerEvent: f2 = q, propsContainer: w2, borderStrokeFill: b2, borderStrokeWidth: C2 = 2, getRangeCoords: I2 = null, activeCoords: E2, alignment: R2 = r.Left } = t2, [M2, T2] = m(false), [D2, O2] = m(void 0), z2 = o((e2, t3, n3, o2, l2, i3) => {
|
|
96
96
|
if (!t3) return null;
|
|
97
97
|
const c3 = l2?.(t3, e2), s3 = e2.getRangeCoordsBounds(c3), a3 = e2.toClipBounds(s3), d3 = s3, u3 = e2.getZoom();
|
|
98
98
|
if (!a3) return null;
|
|
@@ -112,11 +112,11 @@ const F = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2
|
|
|
112
112
|
}, [R2]), L2 = o(i2, [i2]), $2 = S(() => {
|
|
113
113
|
n2?.getStage()?.focus();
|
|
114
114
|
}, [n2]), B2 = x(null), F2 = o((e2) => {
|
|
115
|
-
s2?.(e2), ee2(),
|
|
116
|
-
}, [s2]),
|
|
115
|
+
s2?.(e2), ee2(), T2(true), B2.current = null;
|
|
116
|
+
}, [s2]), A2 = o((e2) => {
|
|
117
117
|
a2?.(e2.coords);
|
|
118
|
-
}, [a2]),
|
|
119
|
-
e2.isSubmitted || e2.isCancelled || (
|
|
118
|
+
}, [a2]), W2 = o((e2) => {
|
|
119
|
+
e2.isSubmitted || e2.isCancelled || (X2.current.isEditorClosed = true, $2(), e2.isCancelled = true, u2?.(e2.coords), ee2());
|
|
120
120
|
}, [u2]), V2 = o((e2) => {
|
|
121
121
|
if (e2.isSubmitted || e2.isCancelled) return false;
|
|
122
122
|
try {
|
|
@@ -125,8 +125,8 @@ const F = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2
|
|
|
125
125
|
throw e2.isEditorClosing = false, e2.isSubmitted = false, t3;
|
|
126
126
|
}
|
|
127
127
|
}, [d2]), U2 = o((e2) => {
|
|
128
|
-
|
|
129
|
-
}, [h2]),
|
|
128
|
+
T2(false), h2?.(e2.coords), ee2();
|
|
129
|
+
}, [h2]), X2 = x(null), G2 = x(null), Z2 = x(null), _2 = x([]), [J2, Q2] = p((e2) => e2 + 1, 0), ee2 = S((e2) => {
|
|
130
130
|
e2 && _2.current.push(e2), Q2();
|
|
131
131
|
}, []), te2 = o((e2) => {
|
|
132
132
|
if (e2.defaultPrevented || e2.isSynthetic) return;
|
|
@@ -140,7 +140,7 @@ const F = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2
|
|
|
140
140
|
}, [n2]), oe2 = o((e2) => {
|
|
141
141
|
if (e2.defaultPrevented || e2.isSynthetic) return;
|
|
142
142
|
if (!n2?.getStage()) return;
|
|
143
|
-
const t3 =
|
|
143
|
+
const t3 = G2.current;
|
|
144
144
|
g2(e2, t3) && (e2.stopPropagation(), e2.preventDefault()), e2.key;
|
|
145
145
|
ee2({ eventType: "keyboard", event: e2, coords: t3 });
|
|
146
146
|
}, [n2]);
|
|
@@ -151,7 +151,7 @@ const F = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2
|
|
|
151
151
|
const r2 = o3;
|
|
152
152
|
if (!L2(o3)) return null;
|
|
153
153
|
F2?.(o3);
|
|
154
|
-
const l2 =
|
|
154
|
+
const l2 = P.uuidV4();
|
|
155
155
|
t4 = Object.freeze({ autoFocus: true, ...t4 }), Z2.current = o3;
|
|
156
156
|
const i3 = { coords: r2, startEvent: t4, uuid: l2, isMounted: false, isStarted: false, isSubmitted: false, isEditorSubmitted: false, isEditorClosing: false, isEditorClosed: false, isCancelled: false, events: [], editorRefsDispatchEditorEvent: [], editorRefs: [], onMount: (e4) => {
|
|
157
157
|
i3.isMounted || (i3.isMounted = true, ee2());
|
|
@@ -167,36 +167,36 @@ const F = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2
|
|
|
167
167
|
};
|
|
168
168
|
window.addEventListener("keydown", t5, true), n2.getStage()?.addEventListener("focusin", () => {
|
|
169
169
|
window.removeEventListener("keydown", t5), e5();
|
|
170
|
-
},
|
|
170
|
+
}, Y), $2();
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
} };
|
|
174
174
|
return i3;
|
|
175
175
|
};
|
|
176
|
-
if (_2.current.length <= 0 && !
|
|
176
|
+
if (_2.current.length <= 0 && !X2.current) return;
|
|
177
177
|
const t3 = _2.current[0];
|
|
178
|
-
|
|
178
|
+
H(t3), ((e3) => {
|
|
179
179
|
const t4 = [], n3 = e3?.length ?? 0;
|
|
180
180
|
for (let o3 = 0; o3 < n3; o3++) {
|
|
181
181
|
const n4 = e3[o3];
|
|
182
|
-
t4.push(
|
|
182
|
+
t4.push(H(n4));
|
|
183
183
|
}
|
|
184
|
-
})(_2.current),
|
|
185
|
-
let o2 =
|
|
186
|
-
if (
|
|
187
|
-
if (
|
|
188
|
-
else if (
|
|
189
|
-
if (
|
|
190
|
-
|
|
184
|
+
})(_2.current), X2.current, X2.current;
|
|
185
|
+
let o2 = X2.current;
|
|
186
|
+
if (X2.current) {
|
|
187
|
+
if (X2.current.isDone) X2.current = null;
|
|
188
|
+
else if (X2.current.isSubmitted || X2.current.isCancelled) {
|
|
189
|
+
if (X2.current.isMounted) return;
|
|
190
|
+
X2.current.isDone || (U2(X2.current), X2.current.isDone = true);
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
if (t3) {
|
|
194
194
|
if ("start" === t3.eventType) {
|
|
195
|
-
const n3 = t3, o3 = n3.startEvent?.cell ??
|
|
196
|
-
|
|
195
|
+
const n3 = t3, o3 = n3.startEvent?.cell ?? G2.current;
|
|
196
|
+
X2.current && k.isEqualCells(X2.current.coords, o3) || (X2.current = e2(o3, n3.startEvent));
|
|
197
197
|
} else if ("keyboard" === t3.eventType) {
|
|
198
198
|
const n3 = t3.event;
|
|
199
|
-
if (
|
|
199
|
+
if (X2.current) {
|
|
200
200
|
let e3 = false;
|
|
201
201
|
switch (n3.which) {
|
|
202
202
|
case l.Left:
|
|
@@ -208,72 +208,72 @@ const F = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2
|
|
|
208
208
|
e3 = true;
|
|
209
209
|
}
|
|
210
210
|
if (!e3) {
|
|
211
|
-
|
|
212
|
-
for (let e4 = 0; e4 <
|
|
211
|
+
X2.current.events.push(t3);
|
|
212
|
+
for (let e4 = 0; e4 < X2.current.editorRefsDispatchEditorEvent.length; e4++) X2.current.editorRefsDispatchEditorEvent[e4](t3);
|
|
213
213
|
}
|
|
214
214
|
} else {
|
|
215
215
|
if (g2(n3, t3.coords)) {
|
|
216
216
|
let n4;
|
|
217
|
-
const o3 = e2(n4?.cell ??
|
|
218
|
-
o3 && o3.events.push(t3),
|
|
217
|
+
const o3 = e2(n4?.cell ?? G2.current, n4);
|
|
218
|
+
o3 && o3.events.push(t3), X2.current = o3;
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
} else if ("pointer" === t3.eventType) {
|
|
222
222
|
const n3 = t3.event;
|
|
223
|
-
if (
|
|
224
|
-
|
|
225
|
-
for (let e3 = 0; e3 <
|
|
223
|
+
if (X2.current) {
|
|
224
|
+
X2.current.events.push(t3);
|
|
225
|
+
for (let e3 = 0; e3 < X2.current.editorRefsDispatchEditorEvent.length; e3++) X2.current.editorRefsDispatchEditorEvent[e3](t3);
|
|
226
226
|
} else {
|
|
227
|
-
const o3 = t3?.coords ??
|
|
227
|
+
const o3 = t3?.coords ?? G2.current, r2 = f2(n3, o3);
|
|
228
228
|
if (r2) {
|
|
229
229
|
let n4;
|
|
230
230
|
"boolean" != typeof n4 && (n4 = r2);
|
|
231
231
|
const l2 = e2(o3, n4);
|
|
232
|
-
l2 && l2.events.push(t3),
|
|
232
|
+
l2 && l2.events.push(t3), X2.current = l2;
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
} else if ("submit" === t3.eventType) {
|
|
236
|
-
if (
|
|
237
|
-
if (!
|
|
238
|
-
V2(
|
|
236
|
+
if (X2.current && !X2.current.isSubmitted && !X2.current.isCancelled) {
|
|
237
|
+
if (!X2.current.isMounted) return;
|
|
238
|
+
V2(X2.current);
|
|
239
239
|
}
|
|
240
240
|
} else if ("cancel" === t3.eventType) {
|
|
241
|
-
if (
|
|
242
|
-
if (!
|
|
243
|
-
|
|
241
|
+
if (X2.current && !X2.current.isSubmitted && !X2.current.isCancelled) {
|
|
242
|
+
if (!X2.current.isMounted) return;
|
|
243
|
+
W2(X2.current);
|
|
244
244
|
}
|
|
245
245
|
} else if ("coordsChange" === t3.eventType) {
|
|
246
246
|
const e3 = t3;
|
|
247
|
-
if (
|
|
248
|
-
if (!
|
|
247
|
+
if (G2.current = e3.activeCoords, X2.current, X2.current && !X2.current.isSubmitted && !X2.current.isCancelled) {
|
|
248
|
+
if (!X2.current.isMounted) return;
|
|
249
249
|
try {
|
|
250
|
-
V2(
|
|
250
|
+
V2(X2.current);
|
|
251
251
|
} catch (e4) {
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
|
-
_2.current.length > 0 && (_2.current.shift(), ee2()), 0 === _2.current.length && (!
|
|
257
|
-
n2 &&
|
|
256
|
+
_2.current.length > 0 && (_2.current.shift(), ee2()), 0 === _2.current.length && (!X2.current || X2.current.isEditorClosing || X2.current.isEditorClosed ? !X2.current && o2 && $2() : X2.current.isMounted && !X2.current.isStarted && (X2.current.isStarted = true, X2.current.startEvent.autoFocus && ("string" == typeof X2.current.startEvent.autoFocus ? X2.current.editorRefs[0]?.autoFocus(X2.current.startEvent.autoFocus) : X2.current.editorRefs[0]?.autoFocus()), A2?.(X2.current), requestAnimationFrame(() => {
|
|
257
|
+
n2 && X2.current?.coords && n2.scrollCellCoordsIntoView(X2.current.coords);
|
|
258
258
|
})));
|
|
259
259
|
}, [J2]), v(() => {
|
|
260
260
|
Z2.current = E2;
|
|
261
|
-
const e2 =
|
|
262
|
-
if (!
|
|
263
|
-
|
|
261
|
+
const e2 = X2.current?.coords;
|
|
262
|
+
if (!k.isEqualCells(e2, E2)) {
|
|
263
|
+
X2.current && (X2.current.isEditorClosing = true);
|
|
264
264
|
ee2({ eventType: "coordsChange", activeCoords: E2 });
|
|
265
265
|
}
|
|
266
266
|
}, [E2]);
|
|
267
267
|
const re2 = S((e2) => {
|
|
268
268
|
oe2(e2.nativeEvent);
|
|
269
269
|
}, []), { width: le2 = 0, height: ie2 = 0 } = D2 ?? { width: 0, height: 0 }, ce2 = o(c2, [c2]);
|
|
270
|
-
return {
|
|
271
|
-
if (!
|
|
272
|
-
|
|
273
|
-
let n3 = z2(t3,
|
|
270
|
+
return { renderOverlay: o((t3) => {
|
|
271
|
+
if (!X2.current || X2.current.isEditorClosed) return X2.current, null;
|
|
272
|
+
X2.current.coords;
|
|
273
|
+
let n3 = z2(t3, X2.current.coords, le2, ie2, I2, R2), o2 = true;
|
|
274
274
|
n3 && 0 !== n3.width && 0 !== n3.height || (n3 = { x: 0, y: 0, width: le2, height: le2 }, o2 = false);
|
|
275
275
|
const r2 = t3.getZoom(), l2 = { containerBounds: { x: 0, y: 0, width: n3.width / r2, height: n3.height / r2 }, setNaturalSize: O2, zoom: r2 };
|
|
276
|
-
return e(
|
|
276
|
+
return e(j, { session: X2.current, refLatestCoords: Z2, handleSubmitEdit: V2, handleCancelEdit: W2, cellBounds: n3, borderStrokeWidth: C2, borderStrokeFill: b2, isInBounds: o2, getCellEditor: ce2, propsEditor: l2, alignment: R2, ...w2 }, "editor:" + X2.current.uuid);
|
|
277
277
|
}, [c2, I2, J2, le2, ie2, R2, C2, b2]), startEdit: S((e2) => {
|
|
278
278
|
ee2({ eventType: "start", startEvent: e2 });
|
|
279
279
|
}, []), submitEdit: S(() => {
|
|
@@ -281,16 +281,16 @@ const F = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2
|
|
|
281
281
|
}, []), cancelEdit: S(() => {
|
|
282
282
|
ee2({ eventType: "cancel" });
|
|
283
283
|
}, []), onKeyboardEvent: re2, onPointerEvent: ne2, onKeyboardEventNative: oe2, onPointerEventNative: te2, isEditing: M2 };
|
|
284
|
-
},
|
|
285
|
-
const y2 = r2 ?? ((n2 ===
|
|
286
|
-
I2.current =
|
|
284
|
+
}, Y = Object.freeze({ once: true }), G = ({ gridRef: e2, gridMainRef: t2, orientation: n2 = T.Row, headerCount: r2, selectionPolicy: l2 = "multiple", newSelectionMode: i2 = "clear", alwaysScrollToActiveCoords: a2 = true, onDragStart: d2, onDragEnd: u2, pointerDownInterceptor: h2, pointerMoveInterceptor: g2, onPointerUp: f2, newSelection: w2, modifySelection: p2, appendSelection: m2, clearSelections: v2 }) => {
|
|
285
|
+
const y2 = r2 ?? ((n2 === T.Row ? e2.current?.rowCount : e2.current?.columnCount) || 0), C2 = x(null), I2 = x(null), E2 = x(false), R2 = x(null), M2 = S((e3) => n2 === T.Column ? { rowIndex: 0, colIndex: e3.colIndex } : { rowIndex: e3.rowIndex, colIndex: 0 }, [n2]), D2 = S((e3) => n2 === T.Column ? { rowIndex: t2.current ? t2.current.rowCount - 1 : 0, colIndex: e3.colIndex } : { rowIndex: e3.rowIndex, colIndex: t2.current ? t2.current.columnCount - 1 : 0 }, [n2]), O2 = (e3) => {
|
|
286
|
+
I2.current = D2(e3), p2(I2.current, C2.current);
|
|
287
287
|
}, z2 = S((o2, r3) => {
|
|
288
288
|
if (!e2.current) return;
|
|
289
289
|
const l3 = e2.current.getViewFromClient(o2, r3)?.getCellCoordsFromClient(o2, r3);
|
|
290
|
-
return l3 ? (n2 ===
|
|
290
|
+
return l3 ? (n2 === T.Column ? l3.rowIndex = t2.current.getViewport().rowStart : l3.colIndex = t2.current.getViewport().colStart, l3) : void 0;
|
|
291
291
|
}, []), L2 = S((e3, o2 = false) => {
|
|
292
292
|
let r3 = e3;
|
|
293
|
-
return o2 || (r3 = { ...e3 }, n2 ===
|
|
293
|
+
return o2 || (r3 = { ...e3 }, n2 === T.Row ? delete r3.colIndex : delete r3.rowIndex), t2.current?.scrollCellCoordsIntoView(r3);
|
|
294
294
|
}, [n2]), $2 = o(u2, [u2]), B2 = o(d2, [d2]), F2 = b(() => ({ onPointerDown: (o2) => {
|
|
295
295
|
if (!e2 || !e2.current) return;
|
|
296
296
|
if (o2.nativeEvent.defaultPrevented) return;
|
|
@@ -300,37 +300,37 @@ const F = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2
|
|
|
300
300
|
const l3 = o2.nativeEvent.shiftKey, i3 = o2.nativeEvent.ctrlKey || o2.nativeEvent.metaKey;
|
|
301
301
|
if (false === h2?.(o2, r3)) return;
|
|
302
302
|
B2?.(), E2.current = true;
|
|
303
|
-
const s2 = t2.current?.getViewFromClient(o2.nativeEvent.clientX, o2.nativeEvent.clientY), d3 = ((e3, t3) => n2 ===
|
|
303
|
+
const s2 = t2.current?.getViewFromClient(o2.nativeEvent.clientX, o2.nativeEvent.clientY), d3 = ((e3, t3) => n2 === T.Column ? { ...e3, rowIndex: t3.rowStart } : { ...e3, colIndex: t3.colStart })(r3, s2.getVisibleRangeCoords());
|
|
304
304
|
if (l3) O2(r3);
|
|
305
305
|
else {
|
|
306
306
|
if (i3) return ((e3, t3 = e3, n3) => {
|
|
307
|
-
C2.current = M2(e3), I2.current =
|
|
307
|
+
C2.current = M2(e3), I2.current = D2(t3), m2(C2.current, I2.current, n3);
|
|
308
308
|
})(r3, r3, d3), void (a2 && L2(d3, true));
|
|
309
309
|
((e3, t3 = e3, n3) => {
|
|
310
|
-
C2.current = M2(e3), I2.current =
|
|
310
|
+
C2.current = M2(e3), I2.current = D2(t3), w2(C2.current, I2.current, n3);
|
|
311
311
|
})(r3, r3, d3), O2(r3), a2 && L2(d3, true);
|
|
312
312
|
}
|
|
313
|
-
}, onPointerMoveOrWait:
|
|
313
|
+
}, onPointerMoveOrWait: P.throttle((t3) => {
|
|
314
314
|
if (!E2.current || !e2?.current) return;
|
|
315
315
|
const n3 = z2(t3.clientX, t3.clientY);
|
|
316
316
|
if (n3 && false !== g2?.(t3, n3)) {
|
|
317
|
-
if (
|
|
317
|
+
if (k.isEqualCells(R2.current, n3)) return v2();
|
|
318
318
|
O2(n3), L2(n3);
|
|
319
319
|
}
|
|
320
320
|
}, 60), onPointerUp: (e3) => {
|
|
321
321
|
E2.current = false, $2?.(), f2?.(e3);
|
|
322
322
|
}, processTouch: true, consumeTouch: true }), [l2, a2, y2, i2, v2, h2, f2]);
|
|
323
323
|
return { onPointerDown: o(s(F2), []), getCellCoordsFromClient: z2 };
|
|
324
|
-
},
|
|
324
|
+
}, Z = (e2, t2, n2) => {
|
|
325
325
|
if (!e2) return t2;
|
|
326
326
|
let o2 = t2;
|
|
327
|
-
const r2 = n2 ===
|
|
327
|
+
const r2 = n2 === D.Right || n2 === D.Down;
|
|
328
328
|
for (; ; ) {
|
|
329
329
|
const t3 = e2(o2, !r2);
|
|
330
330
|
if (0 === t3) return o2;
|
|
331
331
|
r2 ? o2 += t3 : o2 -= t3;
|
|
332
332
|
}
|
|
333
|
-
},
|
|
333
|
+
}, _ = (e2, t2, n2) => {
|
|
334
334
|
const o2 = [];
|
|
335
335
|
let r2 = t2;
|
|
336
336
|
for (; r2 <= n2; ) {
|
|
@@ -338,75 +338,75 @@ const F = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2
|
|
|
338
338
|
0 === t3 ? (o2.push(r2), r2++) : r2 += t3;
|
|
339
339
|
}
|
|
340
340
|
return o2;
|
|
341
|
-
},
|
|
341
|
+
}, J = (e2, t2, n2, o2, r2, l2) => {
|
|
342
342
|
if (!t2) return l2;
|
|
343
343
|
let { rowIndex: i2, colIndex: c2 } = e2;
|
|
344
344
|
switch (o2) {
|
|
345
|
-
case
|
|
346
|
-
i2 =
|
|
345
|
+
case D.Down: {
|
|
346
|
+
i2 = Z(n2, Math.min(i2 + 1, l2), o2);
|
|
347
347
|
let e3 = t2({ rowIndex: i2, colIndex: c2 });
|
|
348
|
-
for (; !e3 && i2 < l2; ) i2 =
|
|
348
|
+
for (; !e3 && i2 < l2; ) i2 = Z(n2, Math.min(++i2, l2), o2), e3 = t2({ rowIndex: i2, colIndex: c2 });
|
|
349
349
|
return i2;
|
|
350
350
|
}
|
|
351
|
-
case
|
|
352
|
-
i2 =
|
|
351
|
+
case D.Up: {
|
|
352
|
+
i2 = Z(n2, Math.max(i2 - 1, l2), o2);
|
|
353
353
|
let e3 = t2({ rowIndex: i2, colIndex: c2 });
|
|
354
|
-
for (; !e3 && i2 > l2; ) i2 =
|
|
354
|
+
for (; !e3 && i2 > l2; ) i2 = Z(n2, Math.max(--i2, l2), o2), e3 = t2({ rowIndex: i2, colIndex: c2 });
|
|
355
355
|
return i2;
|
|
356
356
|
}
|
|
357
|
-
case
|
|
358
|
-
c2 =
|
|
357
|
+
case D.Right: {
|
|
358
|
+
c2 = Z(n2, Math.min(c2 + 1, l2), o2);
|
|
359
359
|
let e3 = t2({ rowIndex: i2, colIndex: c2 });
|
|
360
|
-
for (; !e3 && c2 < l2; ) c2 =
|
|
360
|
+
for (; !e3 && c2 < l2; ) c2 = Z(n2, Math.min(++c2, l2), o2), e3 = t2({ rowIndex: i2, colIndex: c2 });
|
|
361
361
|
return c2;
|
|
362
362
|
}
|
|
363
|
-
case
|
|
364
|
-
c2 =
|
|
363
|
+
case D.Left: {
|
|
364
|
+
c2 = Z(n2, Math.max(c2 - 1, l2), o2);
|
|
365
365
|
let e3 = t2({ rowIndex: i2, colIndex: c2 });
|
|
366
|
-
for (; !e3 && c2 > l2; ) c2 =
|
|
366
|
+
for (; !e3 && c2 > l2; ) c2 = Z(n2, Math.max(--c2, l2), o2), e3 = t2({ rowIndex: i2, colIndex: c2 });
|
|
367
367
|
return c2;
|
|
368
368
|
}
|
|
369
369
|
default:
|
|
370
370
|
return l2;
|
|
371
371
|
}
|
|
372
|
-
},
|
|
372
|
+
}, Q = (e2, t2 = () => true, n2, o2, r2, l2) => {
|
|
373
373
|
let { rowIndex: i2, colIndex: c2 } = e2;
|
|
374
374
|
switch (o2) {
|
|
375
|
-
case
|
|
376
|
-
i2 =
|
|
375
|
+
case D.Down: {
|
|
376
|
+
i2 = Z(n2, Math.min(i2 + 1, l2), o2);
|
|
377
377
|
let e3 = t2?.({ rowIndex: i2, colIndex: c2 });
|
|
378
|
-
for (; e3 && i2 < l2; ) i2 =
|
|
378
|
+
for (; e3 && i2 < l2; ) i2 = Z(n2, Math.min(++i2, l2), o2), e3 = t2?.({ rowIndex: i2, colIndex: c2 });
|
|
379
379
|
return t2?.({ rowIndex: i2, colIndex: c2 }) ? i2 : i2 - 1;
|
|
380
380
|
}
|
|
381
|
-
case
|
|
382
|
-
i2 =
|
|
381
|
+
case D.Up: {
|
|
382
|
+
i2 = Z(n2, Math.max(i2 - 1, l2), o2);
|
|
383
383
|
let e3 = t2?.({ rowIndex: i2, colIndex: c2 });
|
|
384
|
-
for (; e3 && i2 > l2; ) i2 =
|
|
384
|
+
for (; e3 && i2 > l2; ) i2 = Z(n2, Math.max(--i2, l2), o2), e3 = t2?.({ rowIndex: i2, colIndex: c2 });
|
|
385
385
|
return t2?.({ rowIndex: i2, colIndex: c2 }) ? i2 : i2 + 1;
|
|
386
386
|
}
|
|
387
|
-
case
|
|
388
|
-
c2 =
|
|
387
|
+
case D.Right: {
|
|
388
|
+
c2 = Z(n2, Math.min(c2 + 1, l2), o2);
|
|
389
389
|
let e3 = t2?.({ rowIndex: i2, colIndex: c2 });
|
|
390
|
-
for (; e3 && c2 < l2; ) c2 =
|
|
390
|
+
for (; e3 && c2 < l2; ) c2 = Z(n2, Math.min(++c2, l2), o2), e3 = t2?.({ rowIndex: i2, colIndex: c2 });
|
|
391
391
|
return t2?.({ rowIndex: i2, colIndex: c2 }) ? c2 : c2 - 1;
|
|
392
392
|
}
|
|
393
|
-
case
|
|
394
|
-
c2 =
|
|
393
|
+
case D.Left: {
|
|
394
|
+
c2 = Z(n2, Math.max(c2 - 1, l2), o2);
|
|
395
395
|
let e3 = t2?.({ rowIndex: i2, colIndex: c2 });
|
|
396
|
-
for (; e3 && c2 > l2; ) c2 =
|
|
396
|
+
for (; e3 && c2 > l2; ) c2 = Z(n2, Math.max(--c2, l2), o2), e3 = t2?.({ rowIndex: i2, colIndex: c2 });
|
|
397
397
|
return t2?.({ rowIndex: i2, colIndex: c2 }) ? c2 : c2 + 1;
|
|
398
398
|
}
|
|
399
399
|
default:
|
|
400
400
|
return null;
|
|
401
401
|
}
|
|
402
|
-
},
|
|
402
|
+
}, ee = (e2, t2, n2, o2, r2, l2) => {
|
|
403
403
|
if (!t2) return l2;
|
|
404
404
|
let i2, { rowIndex: c2, colIndex: s2 } = e2;
|
|
405
|
-
o2 ===
|
|
405
|
+
o2 === D.Down ? i2 = { rowIndex: c2 + 1, colIndex: s2 } : o2 === D.Up ? i2 = { rowIndex: c2 - 1, colIndex: s2 } : o2 === D.Right ? i2 = { rowIndex: c2, colIndex: s2 + 1 } : o2 === D.Left && (i2 = { rowIndex: c2, colIndex: s2 - 1 });
|
|
406
406
|
const a2 = t2(e2), d2 = t2(i2);
|
|
407
407
|
var u2, h2;
|
|
408
|
-
return (h2 = d2, !(u2 = a2) && !h2 || !u2 && h2 || u2 && !h2 ?
|
|
409
|
-
},
|
|
408
|
+
return (h2 = d2, !(u2 = a2) && !h2 || !u2 && h2 || u2 && !h2 ? J : Q)(e2, t2, n2, o2, false, l2) ?? l2;
|
|
409
|
+
}, te = (e2, t2) => `${e2}:${t2}`, ne = (e2, t2, n2, o2, r2, l2) => {
|
|
410
410
|
if (n2 - t2 >= r2 - o2) return o2;
|
|
411
411
|
let i2 = o2;
|
|
412
412
|
if ("nearest" === e2 && (o2 - t2 > 0 ? e2 = "start" : n2 - r2 > 0 && (e2 = "end")), "start" === e2) i2 = t2;
|
|
@@ -415,23 +415,23 @@ const F = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2
|
|
|
415
415
|
i2 = t2 + (n2 - t2) / 2 - (r2 - o2) / 2;
|
|
416
416
|
}
|
|
417
417
|
return i2 < o2 ? Math.max(0, i2) : i2 > o2 ? Math.min(i2, l2 - (r2 - o2)) : void 0;
|
|
418
|
-
},
|
|
419
|
-
if (l2 &&
|
|
418
|
+
}, oe = (e2, t2, n2, o2) => (console.log("todo: implement convertToVisibleRanges"), e2), re = (e2, t2 = D.Right, n2, o2, r2, l2 = null) => {
|
|
419
|
+
if (l2 && k.isEqualSelectionCoords(l2, e2)) return e2;
|
|
420
420
|
const i2 = e2.ranges[e2.rangeIndex];
|
|
421
|
-
if (!
|
|
421
|
+
if (!k.isRangesIntersect({ rowStart: e2.cell.rowIndex, colStart: e2.cell.colIndex, rowEnd: e2.cell.rowIndex, colEnd: e2.cell.colIndex }, i2)) return e2;
|
|
422
422
|
let c2 = { ...e2.cell }, s2 = e2.rangeIndex;
|
|
423
423
|
switch (t2) {
|
|
424
|
-
case
|
|
425
|
-
c2.colIndex =
|
|
424
|
+
case D.Right:
|
|
425
|
+
c2.colIndex = Z(r2, c2.colIndex + 1, t2);
|
|
426
426
|
break;
|
|
427
|
-
case
|
|
428
|
-
c2.colIndex =
|
|
427
|
+
case D.Left:
|
|
428
|
+
c2.colIndex = Z(r2, c2.colIndex - 1, t2);
|
|
429
429
|
break;
|
|
430
|
-
case
|
|
431
|
-
c2.rowIndex =
|
|
430
|
+
case D.Down:
|
|
431
|
+
c2.rowIndex = Z(o2, c2.rowIndex + 1, t2);
|
|
432
432
|
break;
|
|
433
|
-
case
|
|
434
|
-
c2.rowIndex =
|
|
433
|
+
case D.Up:
|
|
434
|
+
c2.rowIndex = Z(o2, c2.rowIndex - 1, t2);
|
|
435
435
|
}
|
|
436
436
|
const a2 = (t3) => {
|
|
437
437
|
if (t3) {
|
|
@@ -444,54 +444,54 @@ const F = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2
|
|
|
444
444
|
c2 = { colIndex: t4.colEnd, rowIndex: t4.rowEnd };
|
|
445
445
|
}
|
|
446
446
|
};
|
|
447
|
-
if (t2 ===
|
|
448
|
-
else if (t2 ===
|
|
449
|
-
else if (t2 ===
|
|
450
|
-
else if (t2 ===
|
|
447
|
+
if (t2 === D.Right && c2.colIndex > i2.colEnd && c2.rowIndex === i2.rowEnd) a2(true);
|
|
448
|
+
else if (t2 === D.Left && c2.colIndex < i2.colStart && c2.rowIndex === i2.rowStart) a2(false);
|
|
449
|
+
else if (t2 === D.Down && c2.colIndex === i2.colEnd && c2.rowIndex > i2.rowEnd) a2(true);
|
|
450
|
+
else if (t2 === D.Up && c2.colIndex === i2.colStart && c2.rowIndex < i2.rowStart) a2(false);
|
|
451
451
|
else {
|
|
452
452
|
let e3 = c2.rowIndex, n3 = c2.colIndex;
|
|
453
453
|
switch (t2) {
|
|
454
|
-
case
|
|
455
|
-
n3 > i2.colEnd && (e3 =
|
|
454
|
+
case D.Right:
|
|
455
|
+
n3 > i2.colEnd && (e3 = Z(o2, e3 + 1, t2), n3 = i2.colStart, e3 > i2.rowEnd && (e3 = i2.rowStart));
|
|
456
456
|
break;
|
|
457
|
-
case
|
|
458
|
-
n3 < i2.colStart && (e3 =
|
|
457
|
+
case D.Left:
|
|
458
|
+
n3 < i2.colStart && (e3 = Z(o2, e3 - 1, t2), n3 = i2.colEnd, e3 < i2.rowStart && (e3 = i2.rowEnd));
|
|
459
459
|
break;
|
|
460
|
-
case
|
|
461
|
-
e3 > i2.rowEnd && (n3 =
|
|
460
|
+
case D.Down:
|
|
461
|
+
e3 > i2.rowEnd && (n3 = Z(r2, n3 + 1, t2), e3 = i2.rowStart, n3 > i2.colEnd && (n3 = i2.colStart));
|
|
462
462
|
break;
|
|
463
|
-
case
|
|
464
|
-
e3 < i2.rowStart && (n3 =
|
|
463
|
+
case D.Up:
|
|
464
|
+
e3 < i2.rowStart && (n3 = Z(r2, n3 - 1, t2), e3 = i2.rowEnd, n3 < i2.colStart && (n3 = i2.colEnd));
|
|
465
465
|
}
|
|
466
466
|
c2 = { rowIndex: e3, colIndex: n3 };
|
|
467
467
|
}
|
|
468
468
|
let d2 = n2(c2);
|
|
469
|
-
if (!
|
|
470
|
-
const e3 =
|
|
469
|
+
if (!k.isRangeWithinRange(d2, i2)) {
|
|
470
|
+
const e3 = k.intersectRanges(d2, i2);
|
|
471
471
|
e3 && (d2 = e3);
|
|
472
472
|
}
|
|
473
|
-
let u2 = { rowStart:
|
|
473
|
+
let u2 = { rowStart: Z(o2, d2.rowStart, D.Down), colStart: Z(r2, d2.colStart, D.Right), rowEnd: Z(o2, d2.rowEnd, D.Up), colEnd: Z(r2, d2.colEnd, D.Left) };
|
|
474
474
|
if (u2.rowStart !== c2.rowIndex || u2.colStart !== c2.colIndex) {
|
|
475
475
|
switch (t2) {
|
|
476
|
-
case
|
|
476
|
+
case D.Right:
|
|
477
477
|
e2.ranges[s2].colStart === u2.colStart && e2.ranges[s2].colEnd === u2.colEnd && (c2.rowIndex = u2.rowEnd), c2.colIndex = u2.colEnd;
|
|
478
478
|
break;
|
|
479
|
-
case
|
|
479
|
+
case D.Left:
|
|
480
480
|
e2.ranges[s2].colStart === u2.colStart && e2.ranges[s2].colEnd === u2.colEnd && (c2.rowIndex = u2.rowStart), c2.rowIndex === u2.rowStart ? c2.colIndex = u2.colStart + 1 : c2.colIndex = u2.colStart;
|
|
481
481
|
break;
|
|
482
|
-
case
|
|
482
|
+
case D.Down:
|
|
483
483
|
e2.ranges[s2].rowStart === u2.rowStart && e2.ranges[s2].rowEnd === u2.rowEnd && (c2.colIndex = u2.colEnd), c2.rowIndex = u2.rowEnd;
|
|
484
484
|
break;
|
|
485
|
-
case
|
|
485
|
+
case D.Up:
|
|
486
486
|
e2.ranges[s2].rowStart === u2.rowStart && e2.ranges[s2].rowEnd === u2.rowEnd && (c2.colIndex = u2.colStart), c2.colIndex === u2.colStart ? c2.rowIndex = u2.rowStart + 1 : c2.rowIndex = u2.rowStart;
|
|
487
487
|
}
|
|
488
|
-
return
|
|
488
|
+
return re({ cell: c2, ranges: e2.ranges, rangeIndex: s2 }, t2, n2, o2, r2, l2 ?? e2);
|
|
489
489
|
}
|
|
490
490
|
return { ranges: e2.ranges, cell: c2, rangeIndex: s2 };
|
|
491
|
-
},
|
|
491
|
+
}, le = (e2, t2) => {
|
|
492
492
|
let n2, o2 = 0, r2 = 0;
|
|
493
|
-
return t2.colStart < e2.colStart ? (n2 =
|
|
494
|
-
},
|
|
493
|
+
return t2.colStart < e2.colStart ? (n2 = D.Left, o2 = e2.colStart - t2.colStart, r2 = t2.colStart) : t2.colEnd > e2.colEnd ? (n2 = D.Right, o2 = t2.colEnd - e2.colEnd, r2 = t2.colEnd) : t2.rowStart < e2.rowStart ? (n2 = D.Up, o2 = e2.rowStart - t2.rowStart, r2 = t2.rowStart) : t2.rowEnd > e2.rowEnd && (n2 = D.Down, o2 = t2.rowEnd - e2.rowEnd, r2 = t2.rowEnd), { direction: n2, amount: o2, index: r2 };
|
|
494
|
+
}, ie = (e2, t2 = false, n2, o2) => {
|
|
495
495
|
if (!n2) return 0;
|
|
496
496
|
const r2 = !t2, l2 = r2 ? 1 : -1;
|
|
497
497
|
let i2 = n2(r2 ? e2 : e2 + 1), c2 = n2(r2 ? e2 + 1 : e2), s2 = e2 + (r2 ? 2 : -1), a2 = 0;
|
|
@@ -500,7 +500,7 @@ const F = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2
|
|
|
500
500
|
i2 = c2, c2 = n2(s2), s2 += l2, a2++;
|
|
501
501
|
}
|
|
502
502
|
return a2;
|
|
503
|
-
},
|
|
503
|
+
}, ce = (e2, t2, n2, o2, r2) => {
|
|
504
504
|
const l2 = {};
|
|
505
505
|
let i2 = null, c2 = null;
|
|
506
506
|
const s2 = n2.length;
|
|
@@ -511,31 +511,31 @@ const F = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2
|
|
|
511
511
|
i2 = r3 + 1, c2 = d2, l2[r3] = Object.freeze({ offset: s3, size: d2 - s3, spanIndex: a2 });
|
|
512
512
|
}
|
|
513
513
|
return Object.freeze(l2);
|
|
514
|
-
},
|
|
514
|
+
}, se = (e2, t2, n2) => {
|
|
515
515
|
const o2 = e2.getColOffset(t2.colStart) + (n2?.left ?? 0), r2 = e2.getRowOffset(t2.rowStart) + (n2?.top ?? 0);
|
|
516
516
|
return { x: o2, y: r2, width: e2.getColOffset(t2.colEnd + 1) + (n2?.right ?? 0) - (n2?.left ?? 0) - o2, height: e2.getRowOffset(t2.rowEnd + 1) + (n2?.bottom ?? 0) - (n2?.top ?? 0) - r2 };
|
|
517
|
-
},
|
|
517
|
+
}, ae = (e2, t2, n2) => {
|
|
518
518
|
if (!n2) return false;
|
|
519
519
|
const o2 = n2.x;
|
|
520
520
|
if (e2 < o2 || e2 > o2 + n2.width) return false;
|
|
521
521
|
const r2 = n2.y;
|
|
522
522
|
return !(t2 < r2 || t2 > r2 + n2.height);
|
|
523
|
-
},
|
|
524
|
-
const { linePoints: n2, bounds: o2,
|
|
523
|
+
}, de = (e2, t2 = true) => `M ${i.boundPixel(e2.left)} ${i.boundPixel(e2.top)} L ${i.boundPixel(e2.right, true)} ${i.boundPixel(e2.top)} L ${i.boundPixel(e2.right, true)} ${i.boundPixel(e2.bottom, true)} L ${i.boundPixel(e2.left)} ${i.boundPixel(e2.bottom, true)} L ${i.boundPixel(e2.left)} ${i.boundPixel(e2.top)} ${t2 ? "Z" : ""}`, ue = (t2) => {
|
|
524
|
+
const { linePoints: n2, bounds: o2, propsPath: r2, style: l2, ...c2 } = t2;
|
|
525
525
|
return e("svg", { width: `${i.boundPixel(o2.width, true)}`, height: `${i.boundPixel(o2.height, true)}`, viewBox: `0 0 ${i.boundPixel(o2.width, true)} ${i.boundPixel(o2.height, true)}`, style: { position: "absolute", left: `${i.boundPixel(o2.x)}px`, top: `${i.boundPixel(o2.y)}px`, width: `${i.boundPixel(o2.width, true)}px`, height: `${i.boundPixel(o2.height, true)}px`, pointerEvents: "none", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top, width, height", willChange: "left, top, width, height, stroke-dashoffset", ...l2 }, ...c2, children: e("path", { d: `M ${i.boundPixel(n2[0])} ${i.boundPixel(n2[1])} L ${i.boundPixel(n2[2])} ${i.boundPixel(n2[3])}`, fill: "none", vectorEffect: "non-scaling-stroke", stroke: "black", ...r2 }) });
|
|
526
|
-
},
|
|
527
|
-
const { x: o2 = 0, y: r2 = 0, width: l2 = 0, height: c2 = 0, fill: s2, stroke: a2, strokeWidth: d2 = 0, strokeDasharray: u2, strokeDashoffset: h2, clipPath: g2,
|
|
526
|
+
}, he = (n2) => {
|
|
527
|
+
const { x: o2 = 0, y: r2 = 0, width: l2 = 0, height: c2 = 0, fill: s2, stroke: a2, strokeWidth: d2 = 0, strokeDasharray: u2, strokeDashoffset: h2, clipPath: g2, boundsPath: f2, propsPath: w2, style: x2, ...p2 } = n2, m2 = r2, v2 = o2, S2 = l2, y2 = c2;
|
|
528
528
|
let b2 = null;
|
|
529
529
|
if (s2) {
|
|
530
|
-
let t2 =
|
|
531
|
-
f2 && (t2 = t2 + " " +
|
|
530
|
+
let t2 = de({ top: 0, left: 0, bottom: y2, right: S2 });
|
|
531
|
+
f2 && (t2 = t2 + " " + de({ top: f2.y - m2, left: f2.x - v2, bottom: f2.height + f2.y - m2, right: f2.width + f2.x - v2 })), b2 = [e("path", { d: t2, fill: s2, stroke: "none", fillRule: "evenodd" }, "fill")];
|
|
532
532
|
}
|
|
533
|
-
return t("svg", { width: `${i.boundPixel(l2, true)}`, height: `${i.boundPixel(c2, true)}`, viewBox: `0 0 ${i.boundPixel(l2, true)} ${i.boundPixel(c2, true)}`, preserveAspectRatio: "none", style: { position: "absolute", left: `${i.boundPixel(o2)}px`, top: `${i.boundPixel(r2)}px`, pointerEvents: "none", transitionDuration: "0ms", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top, width, height", willChange: "left, top, width, height, stroke-dashoffset", boxShadow: "rgb(60 64 67 / 5%) 0px 1px 4px 2px, rgb(255 255 255 / 15%) 0px 0px 2px 1px", overflow: "visible", ...x2 }, ...p2, children: [b2, e("path", { d:
|
|
534
|
-
},
|
|
533
|
+
return t("svg", { width: `${i.boundPixel(l2, true)}`, height: `${i.boundPixel(c2, true)}`, viewBox: `0 0 ${i.boundPixel(l2, true)} ${i.boundPixel(c2, true)}`, preserveAspectRatio: "none", style: { position: "absolute", left: `${i.boundPixel(o2)}px`, top: `${i.boundPixel(r2)}px`, pointerEvents: "none", transitionDuration: "0ms", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top, width, height", willChange: "left, top, width, height, stroke-dashoffset", boxShadow: "rgb(60 64 67 / 5%) 0px 1px 4px 2px, rgb(255 255 255 / 15%) 0px 0px 2px 1px", overflow: "visible", ...x2 }, ...p2, children: [b2, e("path", { d: de({ top: 0, left: 0, right: S2, bottom: y2 }), fill: "none", strokeDasharray: u2, strokeDashoffset: h2, stroke: a2, vectorEffect: "non-scaling-stroke", strokeWidth: d2, ...w2 })] });
|
|
534
|
+
}, ge = (t2) => {
|
|
535
535
|
const { key: n2, ...o2 } = t2;
|
|
536
|
-
return e(
|
|
537
|
-
},
|
|
538
|
-
const { stroke: n2, fill: o2, x: r2 = 0, y: l2 = 0, width: i2 = 0, height: c2 = 0, style: s2, isAnimatedStroke: d2,
|
|
536
|
+
return e(fe, { ...o2 }, n2);
|
|
537
|
+
}, fe = C((t2) => {
|
|
538
|
+
const { stroke: n2, fill: o2, x: r2 = 0, y: l2 = 0, width: i2 = 0, height: c2 = 0, style: s2, isAnimatedStroke: d2, propsAnimatedStroke: u2, range: h2, cell: g2, ...f2 } = t2, w2 = d2 || !!u2, x2 = { name: "walking-offset", dashGap: 2, speed: 50, dashLength: 8, ...u2 };
|
|
539
539
|
let p2 = x2.dashGap + x2.dashLength;
|
|
540
540
|
const m2 = x2.speed * p2, S2 = a().replaceAll(":", ""), y2 = `${x2.name}-${S2}`;
|
|
541
541
|
let b2;
|
|
@@ -550,33 +550,33 @@ const F = ({ itemType: e2, index: t2, itemSize: n2, instanceProps: o2, scale: r2
|
|
|
550
550
|
return t3.sheet.insertRule(e2, 0), () => {
|
|
551
551
|
document.head.removeChild(t3);
|
|
552
552
|
};
|
|
553
|
-
}, [w2]), w2 && (b2 = { strokeDasharray: `${x2.dashLength}px ${x2.dashGap}px`, strokeDashoffset: `${p2}px`, animation: `${y2} ${m2}ms linear infinite`, willChange: "stroke-dashoffset" }), e(
|
|
553
|
+
}, [w2]), w2 && (b2 = { strokeDasharray: `${x2.dashLength}px ${x2.dashGap}px`, strokeDashoffset: `${p2}px`, animation: `${y2} ${m2}ms linear infinite`, willChange: "stroke-dashoffset" }), e(he, { x: r2, y: l2, width: i2, height: c2, stroke: n2, fill: o2, shapeRendering: "crispEdges", style: { ...b2, ...s2 }, ...f2 });
|
|
554
554
|
});
|
|
555
|
-
|
|
556
|
-
const
|
|
557
|
-
const { x: o2 = 0, y: r2 = 0, borderWidth: l2 = 1, size: i2 = 6, borderStroke: c2, corner: s2, style: a2, className: d2, background: u2,
|
|
555
|
+
fe.displayName = "Selection";
|
|
556
|
+
const we = C(I((t2, n2) => {
|
|
557
|
+
const { x: o2 = 0, y: r2 = 0, borderWidth: l2 = 1, size: i2 = 6, borderStroke: c2, corner: s2, style: a2, className: d2, background: u2, ref: h2, ...g2 } = t2;
|
|
558
558
|
if (0 === o2 || 0 === r2) return null;
|
|
559
|
-
let
|
|
559
|
+
let f2 = true, w2 = true, x2 = true, p2 = true;
|
|
560
560
|
switch (s2) {
|
|
561
561
|
case "tl":
|
|
562
|
-
|
|
562
|
+
f2 = false, w2 = false;
|
|
563
563
|
break;
|
|
564
564
|
case "bl":
|
|
565
|
-
|
|
565
|
+
f2 = false, p2 = false;
|
|
566
566
|
break;
|
|
567
567
|
case "br":
|
|
568
|
-
|
|
568
|
+
x2 = false, p2 = false;
|
|
569
569
|
break;
|
|
570
570
|
case "tr":
|
|
571
|
-
|
|
571
|
+
w2 = false, x2 = false;
|
|
572
572
|
}
|
|
573
|
-
return e("div", { className:
|
|
573
|
+
return e("div", { className: M("fill-handle", d2), style: { position: "absolute", left: o2 - (i2 + (f2 ? l2 : 0)) / 2, top: r2 - (i2 + (w2 ? l2 : 0)) / 2, width: i2, height: i2, borderLeft: f2 ? `${l2}px ${c2}` : void 0, borderTop: w2 ? `${l2}px ${c2}` : void 0, borderRight: x2 ? `${l2}px ${c2}` : void 0, borderBottom: p2 ? `${l2}px ${c2}` : void 0, background: u2, cursor: "crosshair", pointerEvents: "all", transitionDuration: "0ms", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top", willChange: "left, top", ...a2 }, tabIndex: -1, ...g2 });
|
|
574
574
|
}));
|
|
575
|
-
|
|
576
|
-
const
|
|
577
|
-
const { range: i2, view: c2, anchor: a2, borderStroke: h2 = "var(--sxl-app-color-primary, rgb(33, 115, 70))", background: g2 = "var(--sxl-app-color-background, white)", borderWidth: f2 = 3, size: w2 = 22, style: p2, className: S2, selectionTouchPointerHandler: y2, onTouchSelectStart: C2, onTouchSelectEnd: I2, currentTouchAnchor: E2, scrollableElement: R2, scrollableRoot:
|
|
578
|
-
if (!
|
|
579
|
-
const T2 = o(C2, [C2]), D2 = o(I2, [I2]), { bounds: O2, coordsPivot: z2, key:
|
|
575
|
+
we.displayName = "FillHandle";
|
|
576
|
+
const xe = i.detectIt().supportsTouchEvents, pe = C(I((r2, l2) => {
|
|
577
|
+
const { range: i2, view: c2, anchor: a2, borderStroke: h2 = "var(--sxl-app-color-primary, rgb(33, 115, 70))", background: g2 = "var(--sxl-app-color-background, white)", borderWidth: f2 = 3, size: w2 = 22, style: p2, className: S2, selectionTouchPointerHandler: y2, onTouchSelectStart: C2, onTouchSelectEnd: I2, currentTouchAnchor: E2, scrollableElement: R2, scrollableRoot: k2, ...P2 } = r2;
|
|
578
|
+
if (!xe) return null;
|
|
579
|
+
const T2 = o(C2, [C2]), D2 = o(I2, [I2]), { bounds: O2, coordsPivot: z2, key: B2 } = b(() => {
|
|
580
580
|
if (!i2 || !c2) return null;
|
|
581
581
|
let e2 = null, t2 = null;
|
|
582
582
|
switch (a2) {
|
|
@@ -618,7 +618,7 @@ const pe = i.detectIt().supportsTouchEvents, me = C(I((r2, l2) => {
|
|
|
618
618
|
}
|
|
619
619
|
const h3 = c2.toClipBounds(n2, 0);
|
|
620
620
|
return !h3 || h3.width <= 0 || h3.height <= 0 || n2.x < 0 || n2.y < 0 || n2.x > d2 || n2.y > u2 ? { bounds: null, coordsAnchor: null, coordsPivot: null, key: null } : { bounds: n2, coordsAnchor: null, coordsPivot: e2, key: "touchSelect-" + c2.getAnchor() + "-" + a2 };
|
|
621
|
-
}, [i2, c2, a2]), F2 = x(null),
|
|
621
|
+
}, [i2, c2, a2]), F2 = x(null), A2 = b(() => {
|
|
622
622
|
const e2 = (e3) => "t" === a2 || "b" === a2 ? { ...e3, colIndex: void 0 } : "l" === a2 || "r" === a2 ? { ...e3, rowIndex: void 0 } : e3;
|
|
623
623
|
return { processTouch: true, consumeTouch: true, onPointerDown: (t2, n2) => {
|
|
624
624
|
const o2 = e2(c2.getCellCoordsFromClient(t2.clientX, t2.clientY));
|
|
@@ -627,58 +627,60 @@ const pe = i.detectIt().supportsTouchEvents, me = C(I((r2, l2) => {
|
|
|
627
627
|
const r3 = e2(c2.getCellCoordsFromClient(t2.clientX, t2.clientY));
|
|
628
628
|
return y2.onSelectionPointerMoveOrWait(t2, n2, o2, c2, r3, F2.current?.coordsPivot, true, true);
|
|
629
629
|
}, onPointerUp: (e3, t2, n2) => (F2.current = null, D2?.(a2), y2.onPointerUp(e3, t2, n2)) };
|
|
630
|
-
}, [y2, i2, c2, a2]),
|
|
630
|
+
}, [y2, i2, c2, a2]), W2 = s(A2), [V2, { y: U2, x: H2 }] = d(), K2 = x(null), { getPortalContainer: N2, isFullscreen: q2 } = u(), [j2, X2] = m(null);
|
|
631
631
|
return v(() => {
|
|
632
632
|
const t2 = K2.current?.getBoundingClientRect();
|
|
633
633
|
if (!t2 || !O2) return void X2(null);
|
|
634
634
|
let n2 = 0, o2 = 0, r3 = R2;
|
|
635
|
-
for (; r3; ) n2 += r3.scrollLeft, o2 += r3.scrollTop, r3 =
|
|
636
|
-
X2($(e("div", { className:
|
|
637
|
-
}, [U2, H2, O2?.x, O2?.y, O2?.width, O2?.height, S2, E2, g2, w2, f2, h2, R2, q2]), O2 ? t(n, { children: [e("div", { ref:
|
|
635
|
+
for (; r3; ) n2 += r3.scrollLeft, o2 += r3.scrollTop, r3 = k2 && r3 === k2.parentElement ? null : r3.parentElement;
|
|
636
|
+
X2($(e("div", { className: M("touch-select-handle", S2), ref: l2, style: { position: "absolute", left: n2 + (t2?.x ?? 0) - (w2 + f2) / 2, top: o2 + (t2?.y ?? 0) - (w2 + f2) / 2, width: w2, height: w2, borderWidth: `${f2}px`, border: h2, borderRadius: "50%", background: g2, boxShadow: `0 0 0 1.5px ${g2}`, cursor: "grab", pointerEvents: "all", opacity: E2 ? 0 : 1, transitionDuration: "160ms", transitionProperty: "opacity", ...p2 }, tabIndex: -1, onPointerDown: W2, ...P2 }), k2 ?? N2(), B2));
|
|
637
|
+
}, [U2, H2, O2?.x, O2?.y, O2?.width, O2?.height, S2, E2, g2, w2, f2, h2, R2, q2]), O2 ? t(n, { children: [e("div", { ref: L([V2, K2]), style: { position: "absolute", left: O2.x, top: O2.y, opacity: 0 } }), j2] }) : null;
|
|
638
638
|
}));
|
|
639
|
-
|
|
640
|
-
const
|
|
639
|
+
pe.displayName = "TouchSelectHandle";
|
|
640
|
+
const me = -10, ve = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd: 0 }), Se = Object.freeze({ colIndex: 0, rowIndex: 0 }), ye = Object.freeze([]), be = (e2) => {
|
|
641
641
|
if (e2 && e2.cell && e2.ranges && e2.rangeIndex > -1 && e2.rangeIndex <= e2.ranges.length) return e2;
|
|
642
|
-
const t2 = { cell: null, ranges: e2?.ranges ??
|
|
643
|
-
return t2.rangeIndex = e2?.rangeIndex ?? t2.ranges.length - 1, t2.cell = e2?.cell, !t2.cell && t2.ranges.length > 0 && (t2.cell = { rowIndex: t2.ranges[t2.rangeIndex].rowStart, colIndex: t2.ranges[t2.rangeIndex].colStart }), t2.cell || (t2.cell =
|
|
644
|
-
},
|
|
642
|
+
const t2 = { cell: null, ranges: e2?.ranges ?? ye };
|
|
643
|
+
return t2.rangeIndex = e2?.rangeIndex ?? t2.ranges.length - 1, t2.cell = e2?.cell, !t2.cell && t2.ranges.length > 0 && (t2.cell = { rowIndex: t2.ranges[t2.rangeIndex].rowStart, colIndex: t2.ranges[t2.rangeIndex].colStart }), t2.cell || (t2.cell = Se), k.isEqualSelectionCoords(t2, e2) ? e2 : t2;
|
|
644
|
+
}, Ce = (e2, t2, n2) => {
|
|
645
645
|
const o2 = e2.getVisibleRangeCoords(), r2 = e2.getScrollOrientation();
|
|
646
|
-
!r2.horizontal && (t2.colIndex > o2.colEnd || t2.colIndex < o2.colStart) && (t2 = { ...t2, colIndex: t2.colIndex > o2.colEnd ? o2.colEnd + 1 : o2.colEnd - 1 }, e2 = n2.current.getViewFromLocation(
|
|
647
|
-
},
|
|
648
|
-
const he2 = S(() => ({ top: V2?.top ?? 0, left: V2?.left ?? 0, bottom: t2.current?.rowCount - 1 || 0, right: t2.current?.columnCount - 1 || 0 }), []),
|
|
649
|
-
|
|
646
|
+
!r2.horizontal && (t2.colIndex > o2.colEnd || t2.colIndex < o2.colStart) && (t2 = { ...t2, colIndex: t2.colIndex > o2.colEnd ? o2.colEnd + 1 : o2.colEnd - 1 }, e2 = n2.current.getViewFromLocation(O.Center)), !r2.vertical && (t2.rowIndex > o2.rowEnd || t2.rowIndex < o2.rowStart) && (t2 = { ...t2, rowIndex: t2.rowIndex > o2.rowEnd ? o2.rowEnd + 1 : o2.rowEnd - 1 }, e2 = n2.current.getViewFromLocation(O.Center)), e2.scrollCellCoordsIntoView(t2);
|
|
647
|
+
}, Ie = () => false, Ee = ({ gridRef: t2, commands: n2, layout: r2, selection: l2, onSelectionChange: a2, onSelectionDragStart: d2, onSelectionDragEnd: u2, selectionPolicy: f2 = "multiple", newSelectionMode: w2 = "clear", allowDeselectSelection: p2 = true, onFillPreview: C2, onFillCancel: I2, onFillDone: R2, onFill: M2, disableFillDrag: T2 = !M2, fillHandleBorderColor: z2 = "white", hiddenRowsAt: L2, hiddenColumnsAt: $2, isContentfulCell: B2, contentfulCellFinder: F2 = ee, getDataCoords: A2, alwaysScrollToActiveCoords: W2 = false, selectionBounds: V2, pointerDownInterceptor: U2, pointerMoveInterceptor: H2, mergedRanges: K2, canSelectionSpanMergedCells: N2 = Ie, onMoveDragStart: q2, onMoveDragUpdate: j2, onMoveDragEnd: X2, onMoveDragDone: Y2, renderSelection: G2 = ge, disableMoveDrag: _2 = !X2, getCellCoordsAsRangeCoords: J2 = k.cellToRange, moveDragHitSize: Q2 = 6, moveDragOutlineSize: te2 = 4, selectionBackgroundColor: ne2 = "rgba(16, 124, 65, 0.1)", selectionBorderColor: ce2 = "rgb(33, 115, 70)", selectionRemoveBorderColor: se2 = "rgb(255, 0, 0)", selectionRemoveBackgroundColor: ae2 = "rgba(250, 10, 10, 0.1)", disableTouchSelection: de2 = false, propsTouchSelectHandle: ue2 }) => {
|
|
648
|
+
const he2 = S(() => ({ top: V2?.top ?? 0, left: V2?.left ?? 0, bottom: t2.current?.rowCount - 1 || 0, right: t2.current?.columnCount - 1 || 0 }), []), fe2 = o(M2, [M2]), xe2 = o(C2, [C2]), Ee2 = o(I2, [I2]), Re2 = o(R2, [R2]), Me2 = o(B2, [B2]), ke2 = o(G2, [G2]), Pe2 = o((e2, t3 = false) => ie(e2, t3, r2.getRowOffset, t3 ? he2().bottom : he2().top), [r2?.getRowOffset]), Te2 = o(L2 ?? Pe2, [L2]), De2 = o((e2, t3 = false) => ie(e2, t3, r2.getColOffset, t3 ? he2().right : he2().left), [r2?.getColOffset]), Oe2 = o($2 ?? De2, [$2]), [ze2, Le2] = m(() => be(l2)), $e2 = b(() => be(ze2), [ze2]), Be2 = x($e2), Fe2 = x(null);
|
|
649
|
+
b(() => {
|
|
650
|
+
Fe2.current = l2;
|
|
651
|
+
}, [l2]), y(P.throttle(() => {
|
|
650
652
|
Le2((e2) => {
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
return
|
|
653
|
+
const t3 = be(l2);
|
|
654
|
+
Fe2.current = t3;
|
|
655
|
+
return k.isEqualSelectionCoords(t3, e2) ? e2 : t3;
|
|
654
656
|
});
|
|
655
657
|
}, 0), [l2]), y(() => {
|
|
656
658
|
Be2.current = $e2;
|
|
657
659
|
}, [$e2]), v(() => {
|
|
658
|
-
Fe2.current || !a2 ||
|
|
660
|
+
Fe2.current || !a2 || k.isEqualSelectionCoords(l2, $e2) || a2($e2);
|
|
659
661
|
}, [$e2]);
|
|
660
|
-
const
|
|
662
|
+
const Ae2 = S((e2) => {
|
|
661
663
|
Le2((t3) => {
|
|
662
|
-
Fe2.current =
|
|
663
|
-
let n3 = "function" == typeof e2 ? e2(t3.ranges) : e2 ??
|
|
664
|
-
if (
|
|
664
|
+
Fe2.current = null, t3 = be(t3);
|
|
665
|
+
let n3 = "function" == typeof e2 ? e2(t3.ranges) : e2 ?? ye;
|
|
666
|
+
if (k.isEqualRangesArrays(n3, t3.ranges)) return t3;
|
|
665
667
|
let o2 = Math.max(n3.length ? 0 : -1, Math.min(t3.rangeIndex, n3.length - 1)), r3 = t3.cell;
|
|
666
|
-
-1 === o2 ||
|
|
668
|
+
-1 === o2 || k.isCellWithinRange(r3, n3[o2]) || (r3 = { rowIndex: n3[o2].rowStart, colIndex: n3[o2].colStart }), 1 === n3.length && k.isSingleCell(n3[0]) && k.isCellWithinRange(r3, n3[0]) && (n3 = [], o2 = -1);
|
|
667
669
|
const l3 = { cell: r3, ranges: n3, rangeIndex: o2 };
|
|
668
|
-
return
|
|
670
|
+
return k.isEqualSelectionCoords(l3, t3) ? t3 : l3;
|
|
669
671
|
});
|
|
670
|
-
}, []),
|
|
672
|
+
}, []), We2 = o((e2) => {
|
|
671
673
|
Le2((t3) => {
|
|
672
|
-
Fe2.current =
|
|
673
|
-
const n3 = e2 ??
|
|
674
|
-
if (!
|
|
675
|
-
if (
|
|
674
|
+
Fe2.current = null, t3 = be(t3);
|
|
675
|
+
const n3 = e2 ?? Se, o2 = J2(n3);
|
|
676
|
+
if (!k.isSingleCell(o2) && 0 === t3.ranges.length) return { ranges: [o2], rangeIndex: 0, cell: n3 };
|
|
677
|
+
if (k.isEqualCells(n3, t3.cell)) return t3;
|
|
676
678
|
let r3 = t3.ranges, l3 = t3.rangeIndex;
|
|
677
|
-
1 === t3.ranges.length && (
|
|
679
|
+
1 === t3.ranges.length && (k.isSingleCell(t3.ranges[0]) && k.isCellWithinRange(n3, t3.ranges[0]) || !k.isCellWithinRange(n3, t3.ranges[0])) && (r3 = [], l3 = -1);
|
|
678
680
|
const i2 = { ranges: r3, rangeIndex: l3, cell: n3 };
|
|
679
|
-
return
|
|
681
|
+
return k.isEqualSelectionCoords(i2, t3) ? t3 : i2;
|
|
680
682
|
});
|
|
681
|
-
}, [J2]), [Ve2, Ue2] = m(null), [He2, Ke2] = m(null), Ne2 = x(null), [qe2, je2] = m(null), Xe2 = x(null), Ye2 = x(null), [
|
|
683
|
+
}, [J2]), [Ve2, Ue2] = m(null), [He2, Ke2] = m(null), Ne2 = x(null), [qe2, je2] = m(null), Xe2 = x(null), Ye2 = x(null), [Ge, Ze] = m(null), _e = x(null), Je = x(null), Qe = x(K2);
|
|
682
684
|
v(() => {
|
|
683
685
|
Qe.current = K2;
|
|
684
686
|
}, [K2]);
|
|
@@ -694,7 +696,7 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
694
696
|
if (r3) return o2;
|
|
695
697
|
const l3 = J2(e2), i2 = J2(n3), c2 = { rowStart: Math.min(l3.rowStart, i2.rowStart), colStart: Math.min(l3.colStart, i2.colStart), rowEnd: Math.max(l3.rowEnd, i2.rowEnd), colEnd: Math.max(l3.colEnd, i2.colEnd) };
|
|
696
698
|
let s2;
|
|
697
|
-
return "function" == typeof Qe.current ? s2 = Qe.current(c2) : K2 && (s2 = K2), s2 ?
|
|
699
|
+
return "function" == typeof Qe.current ? s2 = Qe.current(c2) : K2 && (s2 = K2), s2 ? k.extendRangeToUnionRanges(c2, s2) : c2;
|
|
698
700
|
}, [N2, J2]), ot = o((e2, t3, n3) => {
|
|
699
701
|
const o2 = e2.ranges.length > 0 ? e2.ranges[e2.rangeIndex] : { rowStart: e2.cell.rowIndex, colStart: e2.cell.colIndex, rowEnd: e2.cell.rowIndex, colEnd: e2.cell.colIndex }, r3 = { rowStart: Math.min(t3.rowIndex ?? o2.rowStart, n3.rowIndex ?? o2.rowStart), colStart: Math.min(t3.colIndex ?? o2.colStart, n3.colIndex ?? o2.colStart), rowEnd: Math.max(t3.rowIndex ?? o2.rowEnd, n3.rowIndex ?? o2.rowEnd), colEnd: Math.max(t3.colIndex ?? o2.colEnd, n3.colIndex ?? o2.colEnd) }, l3 = { rowIndex: r3.rowStart, colIndex: r3.colStart }, i2 = { rowIndex: r3.rowEnd, colIndex: r3.colEnd };
|
|
700
702
|
if (tt(l3) || tt(i2)) return;
|
|
@@ -705,26 +707,26 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
705
707
|
const o2 = ot(Be2.current, e2, t3 ?? Be2.current.cell);
|
|
706
708
|
if (!o2) return;
|
|
707
709
|
const r3 = Be2.current.rangeIndex;
|
|
708
|
-
|
|
710
|
+
Ae2((e3) => e3.length ? e3.map((e4, t4) => r3 === t4 ? o2 : e4) : [o2]), n3 && o2 && We2({ colIndex: o2.colStart, rowIndex: o2.rowStart });
|
|
709
711
|
}, []), lt = S((e2, t3, n3) => {
|
|
710
712
|
if (!Be2.current) return;
|
|
711
713
|
e2 = { ...Be2.current?.cell, ...e2 }, t3 = t3 ?? e2;
|
|
712
714
|
const o2 = ot(Be2.current, e2, t3);
|
|
713
715
|
if (!o2) return;
|
|
714
716
|
const r3 = { rowIndex: o2.rowStart, colIndex: o2.colStart }, l3 = { ...r3, ...n3 };
|
|
715
|
-
"clear" === w2 ? (_e.current = l3, ct()) : "modify" === w2 ? rt(r3) : it(r3),
|
|
717
|
+
"clear" === w2 ? (_e.current = l3, ct()) : "modify" === w2 ? rt(r3) : it(r3), We2(l3);
|
|
716
718
|
}, []), it = S((e2, t3 = e2, n3) => {
|
|
717
719
|
"multiple" !== f2 || !e2 || tt(e2) || tt(t3) || Le2((o2) => {
|
|
718
|
-
Fe2.current =
|
|
720
|
+
Fe2.current = null, o2 = be(o2);
|
|
719
721
|
const r3 = nt(e2, t3);
|
|
720
722
|
if (!r3) return o2;
|
|
721
723
|
let l3 = o2.ranges.length > 0 ? [...o2.ranges] : [nt(o2.cell, o2.cell)];
|
|
722
724
|
l3.push(r3);
|
|
723
725
|
const i2 = { ranges: l3, cell: { rowIndex: r3.rowStart, colIndex: r3.colStart, ...n3 }, rangeIndex: l3.length - 1 };
|
|
724
|
-
return
|
|
726
|
+
return k.isEqualSelectionCoords(i2, o2) ? o2 : i2;
|
|
725
727
|
});
|
|
726
728
|
}, []), ct = () => {
|
|
727
|
-
|
|
729
|
+
Ae2(ye);
|
|
728
730
|
}, st = "touch" === i.detectIt().primaryInput, at = x(null), dt = x(null), ut = x(null), ht = b(() => ({ onPointerDown: (e2) => {
|
|
729
731
|
if (!t2 || !t2.current) return false;
|
|
730
732
|
const n3 = e2.nativeEvent, o2 = t2.current.getViewFromClient(n3.clientX, n3.clientY);
|
|
@@ -734,18 +736,18 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
734
736
|
at.current = { anchor: o2.getAnchor(), coords: r3 }, Je.current = null;
|
|
735
737
|
const l3 = e2.nativeEvent.which === c.Right;
|
|
736
738
|
if (l3) {
|
|
737
|
-
if (-1 !==
|
|
739
|
+
if (-1 !== k.indexOfCoords(r3, $e2.ranges)) return false;
|
|
738
740
|
}
|
|
739
741
|
const i2 = e2.nativeEvent.shiftKey, s2 = e2.nativeEvent.ctrlKey || e2.nativeEvent.metaKey, a3 = s2, u3 = p2, h2 = $e2.ranges.length > 0, g2 = s2 && u3;
|
|
740
742
|
if (false === U2?.(e2, r3, $e2)) return false;
|
|
741
743
|
d2?.(Be2.current, e2);
|
|
742
744
|
const w3 = !l3 && "single" !== f2;
|
|
743
745
|
if (i2) return rt(r3), w3;
|
|
744
|
-
const x2 =
|
|
746
|
+
const x2 = k.isEqualCells(r3, $e2.cell);
|
|
745
747
|
if (a3) {
|
|
746
748
|
if (x2 && (!g2 || !h2)) return w3;
|
|
747
749
|
if (s2) {
|
|
748
|
-
if (-1 !==
|
|
750
|
+
if (-1 !== k.indexOfCoords(r3, $e2.ranges) && u3) {
|
|
749
751
|
Xe2.current = r3;
|
|
750
752
|
const e3 = nt(r3, r3);
|
|
751
753
|
return Ye2.current = e3, je2(e3), w3;
|
|
@@ -753,21 +755,21 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
753
755
|
}
|
|
754
756
|
return it(r3), w3;
|
|
755
757
|
}
|
|
756
|
-
|
|
757
|
-
}, onPointerMoveOrWait:
|
|
758
|
+
W2 && et(r3), x2 && 0 === $e2.ranges.length || lt(r3);
|
|
759
|
+
}, onPointerMoveOrWait: P.throttle((e2, n3) => {
|
|
758
760
|
if (!t2?.current) return;
|
|
759
761
|
if ("touch" === e2.pointerType || "touchmove" === e2.type) return;
|
|
760
762
|
if (!at.current) return;
|
|
761
763
|
const o2 = at.current.anchor;
|
|
762
764
|
let r3 = t2.current.getViewFromLocation(o2), l3 = r3.getCellCoordsFromClient(e2.clientX, e2.clientY);
|
|
763
|
-
if (!
|
|
765
|
+
if (!k.isEqualCells(l3, at.current?.coords) && (at.current = { anchor: o2, coords: l3 }, l3 && false !== H2?.(e2, l3, Be2.current))) {
|
|
764
766
|
if (Xe2.current) {
|
|
765
767
|
const e3 = { rowStart: Math.min(l3.rowIndex, Xe2.current.rowIndex), colStart: Math.min(l3.colIndex, Xe2.current.colIndex), rowEnd: Math.max(l3.rowIndex, Xe2.current.rowIndex), colEnd: Math.max(l3.colIndex, Xe2.current.colIndex) }, t3 = { rowIndex: e3.rowStart, colIndex: e3.colStart }, n4 = { rowIndex: e3.rowEnd, colIndex: e3.colEnd };
|
|
766
768
|
if (tt(t3) || tt(n4)) return;
|
|
767
769
|
const o3 = nt(t3, n4);
|
|
768
770
|
Ye2.current = o3, je2(o3);
|
|
769
771
|
} else rt(l3);
|
|
770
|
-
ut.current = n3,
|
|
772
|
+
ut.current = n3, Ce(r3, l3, t2);
|
|
771
773
|
}
|
|
772
774
|
}, 60), onPointerUp: (e2) => {
|
|
773
775
|
if (at.current = null, "touch" === e2.pointerType || "touchend" === e2.type) {
|
|
@@ -788,23 +790,23 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
788
790
|
if (!Xe2.current) return;
|
|
789
791
|
const n3 = Ye2.current;
|
|
790
792
|
Xe2.current = null, Ye2.current = null, je2(null), Le2((e3) => {
|
|
791
|
-
if (Fe2.current =
|
|
793
|
+
if (Fe2.current = null, 0 === (e3 = be(e3)).ranges.length) return e3;
|
|
792
794
|
let t3 = [], o2 = -1, r3 = e3.cell;
|
|
793
795
|
for (let l4 = 0; l4 < e3.ranges.length; l4++) {
|
|
794
796
|
const i2 = e3.ranges[l4];
|
|
795
|
-
if (
|
|
796
|
-
const r4 =
|
|
797
|
+
if (k.isRangesIntersect(i2, n3)) {
|
|
798
|
+
const r4 = P.subtractRect({ top: i2.rowStart, left: i2.colStart, bottom: i2.rowEnd + 1, right: i2.colEnd + 1 }, { top: n3.rowStart, left: n3.colStart, bottom: n3.rowEnd + 1, right: n3.colEnd + 1 });
|
|
797
799
|
for (let n4 = 0; n4 < r4.length; n4++) {
|
|
798
800
|
const l5 = { rowStart: r4[n4].top, colStart: r4[n4].left, rowEnd: r4[n4].bottom - 1, colEnd: r4[n4].right - 1 };
|
|
799
|
-
t3.push(l5),
|
|
801
|
+
t3.push(l5), k.isCellWithinRange(e3.cell, l5) && (o2 = t3.length - 1);
|
|
800
802
|
}
|
|
801
803
|
} else t3.push(i2);
|
|
802
|
-
t3.length > 0 && -1 === o2 &&
|
|
804
|
+
t3.length > 0 && -1 === o2 && k.isCellWithinRange(e3.cell, i2) && (o2 = t3.length - 1, r3 = { rowIndex: t3[t3.length - 1].rowStart, colIndex: t3[t3.length - 1].colStart });
|
|
803
805
|
}
|
|
804
806
|
const l3 = { cell: r3, rangeIndex: o2, ranges: t3 };
|
|
805
|
-
return
|
|
807
|
+
return k.isEqualSelectionCoords(l3, e3) ? e3 : l3;
|
|
806
808
|
});
|
|
807
|
-
}, processTouch: true, consumeTouch: false }), [$e2, f2, p2,
|
|
809
|
+
}, processTouch: true, consumeTouch: false }), [$e2, f2, p2, W2, w2]), gt = o(s(ht), []), ft = b(() => ({ onSelectionPointerDown: (e2, n3, o2, r3, l3 = $e2.cell, i2 = W2, s2 = e2.nativeEvent.shiftKey, a3 = false) => {
|
|
808
810
|
if (!t2 || !t2.current) return false;
|
|
809
811
|
e2.stopPropagation(), e2.preventDefault(), e2.nativeEvent.stopImmediatePropagation();
|
|
810
812
|
const u3 = o2 ?? t2.current.getViewFromClient(e2.nativeEvent.clientX, e2.nativeEvent.clientY), h2 = r3 ?? u3.getCellCoordsFromClient(e2.nativeEvent.clientX, e2.nativeEvent.clientY);
|
|
@@ -812,18 +814,18 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
812
814
|
at.current = { anchor: u3.getAnchor(), coords: h2 }, Je.current = null;
|
|
813
815
|
const g2 = e2.nativeEvent.which === c.Right;
|
|
814
816
|
if (g2) {
|
|
815
|
-
if (-1 !==
|
|
817
|
+
if (-1 !== k.indexOfCoords(h2, $e2.ranges)) return false;
|
|
816
818
|
}
|
|
817
819
|
const w3 = e2.nativeEvent.ctrlKey || e2.nativeEvent.metaKey, x2 = w3, m2 = p2, v2 = $e2.ranges.length > 0, S2 = w3 && m2;
|
|
818
820
|
if (false === U2?.(e2, h2, $e2)) return false;
|
|
819
821
|
d2?.(Be2.current, e2);
|
|
820
822
|
const y2 = !g2 && "single" !== f2;
|
|
821
823
|
if (s2) return rt(h2, l3, a3), y2;
|
|
822
|
-
const b2 =
|
|
824
|
+
const b2 = k.isEqualCells(h2, l3);
|
|
823
825
|
if (x2) {
|
|
824
826
|
if (b2 && (!S2 || !v2)) return y2;
|
|
825
827
|
if (S2) {
|
|
826
|
-
if (-1 !==
|
|
828
|
+
if (-1 !== k.indexOfCoords(h2, $e2.ranges) && m2) {
|
|
827
829
|
Xe2.current = h2;
|
|
828
830
|
const e3 = nt(h2, h2);
|
|
829
831
|
return Ye2.current = e3, je2(e3), y2;
|
|
@@ -837,14 +839,14 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
837
839
|
if (e2.stopPropagation(), e2.preventDefault(), e2.nativeEvent.stopImmediatePropagation(), !at.current) return;
|
|
838
840
|
const a3 = at.current.anchor;
|
|
839
841
|
let d3 = r3 ?? t2.current.getViewFromLocation(a3), u3 = l3 ?? d3.getCellCoordsFromClient(e2.clientX, e2.clientY);
|
|
840
|
-
if (!
|
|
842
|
+
if (!k.isEqualCells(u3, at.current?.coords) && (at.current = { anchor: a3, coords: u3 }, u3 && false !== H2?.(e2, u3, Be2.current))) {
|
|
841
843
|
if (Xe2.current) {
|
|
842
844
|
const e3 = { rowStart: Math.min(u3.rowIndex, Xe2.current.rowIndex), colStart: Math.min(u3.colIndex, Xe2.current.colIndex), rowEnd: Math.max(u3.rowIndex, Xe2.current.rowIndex), colEnd: Math.max(u3.colIndex, Xe2.current.colIndex) }, t3 = { rowIndex: e3.rowStart, colIndex: e3.colStart }, n4 = { rowIndex: e3.rowEnd, colIndex: e3.colEnd };
|
|
843
845
|
if (tt(t3) || tt(n4)) return;
|
|
844
846
|
const o3 = nt(t3, n4);
|
|
845
847
|
Ye2.current = o3, je2(o3);
|
|
846
848
|
} else rt(u3, i2, s2);
|
|
847
|
-
c2 &&
|
|
849
|
+
c2 && Ce(d3, u3, t2);
|
|
848
850
|
}
|
|
849
851
|
}, onPointerUp: (e2) => {
|
|
850
852
|
at.current = null, e2.stopPropagation(), e2.preventDefault(), e2.nativeEvent.stopImmediatePropagation();
|
|
@@ -856,38 +858,38 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
856
858
|
if (!Xe2.current) return;
|
|
857
859
|
const t3 = Ye2.current;
|
|
858
860
|
Xe2.current = null, Ye2.current = null, je2(null), Le2((e3) => {
|
|
859
|
-
if (Fe2.current =
|
|
861
|
+
if (Fe2.current = null, 0 === (e3 = be(e3)).ranges.length) return e3;
|
|
860
862
|
let n3 = [], o2 = -1, r3 = e3.cell;
|
|
861
863
|
for (let l4 = 0; l4 < e3.ranges.length; l4++) {
|
|
862
864
|
const i2 = e3.ranges[l4];
|
|
863
|
-
if (
|
|
864
|
-
const r4 =
|
|
865
|
+
if (k.isRangesIntersect(i2, t3)) {
|
|
866
|
+
const r4 = P.subtractRect({ top: i2.rowStart, left: i2.colStart, bottom: i2.rowEnd + 1, right: i2.colEnd + 1 }, { top: t3.rowStart, left: t3.colStart, bottom: t3.rowEnd + 1, right: t3.colEnd + 1 });
|
|
865
867
|
for (let t4 = 0; t4 < r4.length; t4++) {
|
|
866
868
|
const l5 = { rowStart: r4[t4].top, colStart: r4[t4].left, rowEnd: r4[t4].bottom - 1, colEnd: r4[t4].right - 1 };
|
|
867
|
-
n3.push(l5),
|
|
869
|
+
n3.push(l5), k.isCellWithinRange(e3.cell, l5) && (o2 = n3.length - 1);
|
|
868
870
|
}
|
|
869
871
|
} else n3.push(i2);
|
|
870
|
-
n3.length > 0 && -1 === o2 &&
|
|
872
|
+
n3.length > 0 && -1 === o2 && k.isCellWithinRange(e3.cell, i2) && (o2 = n3.length - 1, r3 = { rowIndex: n3[n3.length - 1].rowStart, colIndex: n3[n3.length - 1].colStart });
|
|
871
873
|
}
|
|
872
874
|
const l3 = { cell: r3, rangeIndex: o2, ranges: n3 };
|
|
873
|
-
return
|
|
875
|
+
return k.isEqualSelectionCoords(l3, e3) ? e3 : l3;
|
|
874
876
|
});
|
|
875
|
-
} }), [$e2, f2, p2,
|
|
877
|
+
} }), [$e2, f2, p2, W2, w2]), wt = o((e2, n3 = false, o2 = false, l3 = 0) => {
|
|
876
878
|
if (!t2.current || !$e2.cell) return;
|
|
877
879
|
let i2 = $e2.cell, c2 = $e2.cell;
|
|
878
880
|
if (n3 && $e2.ranges.length > 0) {
|
|
879
881
|
const t3 = $e2.ranges[$e2.rangeIndex], n4 = $e2.cell;
|
|
880
882
|
switch (e2) {
|
|
881
|
-
case
|
|
883
|
+
case D.Up:
|
|
882
884
|
c2 = { rowIndex: n4.rowIndex === t3.rowStart ? t3.rowEnd : t3.rowStart, colIndex: t3.colEnd }, i2 = { rowIndex: n4.rowIndex === t3.rowStart ? t3.rowStart : t3.rowEnd, colIndex: t3.colStart };
|
|
883
885
|
break;
|
|
884
|
-
case
|
|
886
|
+
case D.Down:
|
|
885
887
|
c2 = { rowIndex: n4.rowIndex === t3.rowEnd ? t3.rowStart : t3.rowEnd, colIndex: t3.colEnd }, i2 = { rowIndex: n4.rowIndex === t3.rowEnd ? t3.rowEnd : t3.rowStart, colIndex: t3.colStart };
|
|
886
888
|
break;
|
|
887
|
-
case
|
|
889
|
+
case D.Left:
|
|
888
890
|
c2 = { rowIndex: t3.rowEnd, colIndex: n4.colIndex === t3.colStart ? t3.colEnd : t3.colStart }, i2 = { rowIndex: t3.rowStart, colIndex: n4.colIndex === t3.colStart ? t3.colStart : t3.colEnd };
|
|
889
891
|
break;
|
|
890
|
-
case
|
|
892
|
+
case D.Right:
|
|
891
893
|
c2 = { rowIndex: t3.rowEnd, colIndex: n4.colIndex === t3.colEnd ? t3.colStart : t3.colEnd }, i2 = { rowIndex: t3.rowStart, colIndex: n4.colIndex === t3.colEnd ? t3.colEnd : t3.colStart };
|
|
892
894
|
}
|
|
893
895
|
}
|
|
@@ -895,39 +897,39 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
895
897
|
let { rowStart: a3, colStart: d3 } = s2;
|
|
896
898
|
const u3 = he2();
|
|
897
899
|
if (Je.current) switch (e2) {
|
|
898
|
-
case
|
|
899
|
-
case
|
|
900
|
+
case D.Up:
|
|
901
|
+
case D.Down:
|
|
900
902
|
Je.current.colIndex >= s2.colStart && Je.current.colIndex <= s2.colEnd && (d3 = Je.current.colIndex);
|
|
901
903
|
break;
|
|
902
|
-
case
|
|
903
|
-
case
|
|
904
|
+
case D.Left:
|
|
905
|
+
case D.Right:
|
|
904
906
|
Je.current.rowIndex >= s2.rowStart && Je.current.rowIndex <= s2.rowEnd && (a3 = Je.current.rowIndex);
|
|
905
907
|
}
|
|
906
908
|
if (!l3) {
|
|
907
909
|
switch (e2) {
|
|
908
|
-
case
|
|
909
|
-
a3 =
|
|
910
|
+
case D.Up:
|
|
911
|
+
a3 = Z(Te2, Math.max(s2.rowStart - 1, u3.top), e2);
|
|
910
912
|
break;
|
|
911
|
-
case
|
|
912
|
-
a3 =
|
|
913
|
+
case D.Down:
|
|
914
|
+
a3 = Z(Te2, Math.min(s2.rowEnd + 1, u3.bottom), e2);
|
|
913
915
|
break;
|
|
914
|
-
case
|
|
915
|
-
d3 =
|
|
916
|
+
case D.Left:
|
|
917
|
+
d3 = Z(Oe2, Math.max(s2.colStart - 1, u3.left), e2);
|
|
916
918
|
break;
|
|
917
|
-
case
|
|
918
|
-
d3 =
|
|
919
|
+
case D.Right:
|
|
920
|
+
d3 = Z(Oe2, Math.min(s2.colEnd + 1, u3.right), e2);
|
|
919
921
|
}
|
|
920
922
|
if (o2) switch (e2) {
|
|
921
|
-
case
|
|
923
|
+
case D.Up:
|
|
922
924
|
a3 = F2({ ...c2, colIndex: $e2.cell.colIndex }, Me2, Te2, e2, false, Math.max(u3.top, Te2(u3.top, false)));
|
|
923
925
|
break;
|
|
924
|
-
case
|
|
926
|
+
case D.Down:
|
|
925
927
|
a3 = F2({ ...c2, colIndex: $e2.cell.colIndex }, Me2, Te2, e2, false, Math.min(u3.bottom, u3.bottom - Te2(u3.bottom, true)));
|
|
926
928
|
break;
|
|
927
|
-
case
|
|
929
|
+
case D.Left:
|
|
928
930
|
d3 = F2({ ...c2, rowIndex: $e2.cell.rowIndex }, Me2, Oe2, e2, false, Math.max(u3.left, Oe2(u3.left, false)));
|
|
929
931
|
break;
|
|
930
|
-
case
|
|
932
|
+
case D.Right:
|
|
931
933
|
d3 = F2({ ...c2, rowIndex: $e2.cell.rowIndex }, Me2, Oe2, e2, false, Math.min(u3.right, u3.right - Oe2(u3.right, true)));
|
|
932
934
|
}
|
|
933
935
|
}
|
|
@@ -935,40 +937,40 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
935
937
|
if (l3) {
|
|
936
938
|
let n4 = 0;
|
|
937
939
|
switch (e2) {
|
|
938
|
-
case
|
|
940
|
+
case D.Up:
|
|
939
941
|
n4 = r2.getRowOffset(a3 + 1), a3 = Math.max(u3.top, r2.getRowIndex(n4 - l3)), h2 = { top: r2.getRowOffset(a3 + 1) - (n4 - t2.current.getScrollPosition().top) };
|
|
940
942
|
break;
|
|
941
|
-
case
|
|
943
|
+
case D.Down:
|
|
942
944
|
n4 = r2.getRowOffset(a3), a3 = Math.min(u3.bottom, r2.getRowIndex(n4 + l3)), h2 = { top: r2.getRowOffset(a3) - (n4 - t2.current.getScrollPosition().top) };
|
|
943
945
|
break;
|
|
944
|
-
case
|
|
946
|
+
case D.Left:
|
|
945
947
|
n4 = r2.getColOffset(d3 + 1), d3 = Math.max(u3.left, r2.getColIndex(n4 - l3)), h2 = { left: r2.getColOffset(d3 + 1) - (n4 - t2.current.getScrollPosition().left) };
|
|
946
948
|
break;
|
|
947
|
-
case
|
|
949
|
+
case D.Right:
|
|
948
950
|
n4 = r2.getColOffset(d3), d3 = Math.min(u3.right, r2.getColIndex(n4 + l3)), h2 = { left: r2.getColOffset(d3) - (n4 - t2.current.getScrollPosition().left) };
|
|
949
951
|
}
|
|
950
952
|
}
|
|
951
953
|
const g2 = { rowIndex: a3, colIndex: d3 }, f3 = J2(g2), w3 = { rowIndex: f3.rowStart, colIndex: f3.colStart };
|
|
952
954
|
n3 || (Je.current = g2);
|
|
953
|
-
const x2 =
|
|
955
|
+
const x2 = k.isEqualCells(_e.current, w3) && k.isEqualCells(_e.current, i2);
|
|
954
956
|
if (n3 && !x2 ? rt(w3, i2) : lt(w3), h2) t2.current.scrollTo(h2);
|
|
955
957
|
else {
|
|
956
958
|
if (n3 && _e.current) {
|
|
957
959
|
const t3 = he2();
|
|
958
|
-
if (e2 ===
|
|
960
|
+
if (e2 === D.Right && _e.current.colIndex === t3.left || e2 === D.Left && _e.current.colIndex === t3.right || e2 === D.Up && _e.current.rowIndex === t3.bottom || e2 === D.Down && _e.current.rowIndex === t3.top) return;
|
|
959
961
|
}
|
|
960
|
-
e2 ===
|
|
962
|
+
e2 === D.Left || e2 === D.Right ? et({ colIndex: g2.colIndex }) : e2 !== D.Up && e2 !== D.Down || et({ rowIndex: g2.rowIndex });
|
|
961
963
|
}
|
|
962
964
|
}, [$e2, J2]), xt = o((e2) => {
|
|
963
965
|
if (!t2.current) return;
|
|
964
966
|
if (0 === $e2.ranges.length) return void wt(e2);
|
|
965
967
|
const n3 = J2($e2.cell);
|
|
966
|
-
if (
|
|
967
|
-
const o2 =
|
|
968
|
+
if (k.isEqualRangesArrays([n3], $e2.ranges)) return void wt(e2);
|
|
969
|
+
const o2 = re($e2, e2, J2, Te2, Oe2);
|
|
968
970
|
Le2((e3) => {
|
|
969
|
-
Fe2.current =
|
|
971
|
+
Fe2.current = null, e3 = be(e3);
|
|
970
972
|
const t3 = { ...e3, cell: o2.cell, rangeIndex: o2.rangeIndex };
|
|
971
|
-
return
|
|
973
|
+
return k.isEqualSelectionCoords(t3, e3) ? e3 : t3;
|
|
972
974
|
}), o2.cell && et(o2.cell);
|
|
973
975
|
}, [$e2, J2]), pt = S(() => {
|
|
974
976
|
const e2 = he2();
|
|
@@ -991,96 +993,96 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
991
993
|
const t3 = he2(), n3 = { rowIndex: t3.top, colIndex: t3.left };
|
|
992
994
|
e2 ? rt(n3) : lt(n3), et(n3);
|
|
993
995
|
}, []), It = S((e2 = false) => {
|
|
994
|
-
const t3 = he2(), n3 = { colIndex:
|
|
996
|
+
const t3 = he2(), n3 = { colIndex: A2?.()?.colEnd ?? t3.right };
|
|
995
997
|
e2 ? rt(n3) : lt(n3), et(n3);
|
|
996
|
-
}, [
|
|
997
|
-
const t3 = he2(), n3 = { rowIndex:
|
|
998
|
+
}, [A2]), Et = S((e2 = false) => {
|
|
999
|
+
const t3 = he2(), n3 = { rowIndex: A2?.()?.rowEnd ?? t3.bottom, colIndex: A2?.()?.colEnd ?? t3.right };
|
|
998
1000
|
e2 ? rt(n3) : lt(n3), et(n3);
|
|
999
|
-
}, [
|
|
1001
|
+
}, [A2]), Rt = o((e2) => {
|
|
1000
1002
|
if (!t2.current) return;
|
|
1001
1003
|
if ($e2.ranges.length <= 1) return;
|
|
1002
|
-
const n3 = e2 ===
|
|
1004
|
+
const n3 = e2 === D.Left || e2 === D.Up;
|
|
1003
1005
|
let o2 = $e2.rangeIndex + (n3 ? -1 : 1);
|
|
1004
1006
|
o2 < 0 ? o2 = $e2.ranges.length - 1 : o2 > $e2.ranges.length - 1 && (o2 = 0);
|
|
1005
|
-
const r3 = $e2.ranges[o2], l3 =
|
|
1007
|
+
const r3 = $e2.ranges[o2], l3 = re({ cell: { rowIndex: r3.rowEnd, colIndex: r3.colEnd }, rangeIndex: 0, ranges: [r3] }, D.Right, J2, Te2, Oe2);
|
|
1006
1008
|
Le2((e3) => {
|
|
1007
|
-
Fe2.current =
|
|
1009
|
+
Fe2.current = null, e3 = be(e3);
|
|
1008
1010
|
const t3 = { ...e3, cell: l3.cell, rangeIndex: o2 };
|
|
1009
|
-
return
|
|
1011
|
+
return k.isEqualSelectionCoords(t3, e3) ? e3 : t3;
|
|
1010
1012
|
}), l3.cell && et(l3.cell);
|
|
1011
1013
|
}, [$e2, J2]), Mt = o(() => {
|
|
1012
|
-
const e2 =
|
|
1014
|
+
const e2 = oe($e2);
|
|
1013
1015
|
Le2((t3) => {
|
|
1014
|
-
Fe2.current =
|
|
1016
|
+
Fe2.current = null, t3 = be(t3);
|
|
1015
1017
|
const n3 = { ...t3, visibleSelection: e2 };
|
|
1016
|
-
return
|
|
1018
|
+
return k.isEqualSelectionCoords(n3, t3) ? t3 : n3;
|
|
1017
1019
|
}), e2.cell && et(e2.cell);
|
|
1018
1020
|
}, [$e2, J2]), kt = o(() => {
|
|
1019
1021
|
if (!t2.current) return;
|
|
1020
1022
|
if (0 === $e2.ranges.length) return;
|
|
1021
|
-
const e2 = $e2.cell, n3 = $e2.ranges[$e2.rangeIndex], o2 =
|
|
1023
|
+
const e2 = $e2.cell, n3 = $e2.ranges[$e2.rangeIndex], o2 = oe({ cell: e2, rangeIndex: 0, ranges: [n3] }), r3 = o2.ranges[o2.rangeIndex];
|
|
1022
1024
|
let l3;
|
|
1023
1025
|
l3 = r3.rowStart === e2.rowIndex && r3.colStart === e2.colIndex ? { rowIndex: r3.rowStart, colIndex: r3.colEnd } : r3.rowStart === e2.rowIndex && r3.colEnd === e2.colIndex ? { rowIndex: r3.rowEnd, colIndex: r3.colStart } : r3.rowEnd === e2.rowIndex && r3.colStart === e2.colIndex ? { rowIndex: r3.rowEnd, colIndex: r3.colEnd } : { rowIndex: r3.rowStart, colIndex: r3.colStart }, Le2((e3) => {
|
|
1024
|
-
e3 =
|
|
1026
|
+
e3 = be(e3);
|
|
1025
1027
|
const t3 = { ...e3, cell: l3 };
|
|
1026
|
-
return
|
|
1028
|
+
return k.isEqualSelectionCoords(t3, e3) ? e3 : t3;
|
|
1027
1029
|
}), l3 && et(l3);
|
|
1028
1030
|
}, [$e2, J2]), Pt = S((e2 = false) => {
|
|
1029
|
-
wt(
|
|
1031
|
+
wt(D.Down, e2, false, t2.current.getDimensions().containerHeight);
|
|
1030
1032
|
}, []), Tt = S((e2 = false) => {
|
|
1031
|
-
wt(
|
|
1033
|
+
wt(D.Up, e2, false, t2.current.getDimensions().containerHeight);
|
|
1032
1034
|
}, []), Dt = S((e2 = false) => {
|
|
1033
|
-
wt(
|
|
1035
|
+
wt(D.Right, e2, false, t2.current.getDimensions().containerWidth);
|
|
1034
1036
|
}, []), Ot = S((e2 = false) => {
|
|
1035
|
-
wt(
|
|
1037
|
+
wt(D.Left, e2, false, t2.current.getDimensions().containerWidth);
|
|
1036
1038
|
}, []), zt = S(() => {
|
|
1037
|
-
xt(
|
|
1039
|
+
xt(D.Left);
|
|
1038
1040
|
}, []), Lt = S(() => {
|
|
1039
|
-
xt(
|
|
1041
|
+
xt(D.Right);
|
|
1040
1042
|
}, []), $t = S(() => {
|
|
1041
|
-
xt(
|
|
1043
|
+
xt(D.Up);
|
|
1042
1044
|
}, []), Bt = S(() => {
|
|
1043
|
-
xt(
|
|
1045
|
+
xt(D.Down);
|
|
1044
1046
|
}, []), Ft = S(() => {
|
|
1045
|
-
Rt(
|
|
1046
|
-
}, []), Wt = S(() => {
|
|
1047
|
-
Rt(O.Right);
|
|
1047
|
+
Rt(D.Left);
|
|
1048
1048
|
}, []), At = S(() => {
|
|
1049
|
+
Rt(D.Right);
|
|
1050
|
+
}, []), Wt = S(() => {
|
|
1049
1051
|
kt();
|
|
1050
1052
|
}, []), Vt = S(() => {
|
|
1051
|
-
wt(
|
|
1053
|
+
wt(D.Left, false, false);
|
|
1052
1054
|
}, []), Ut = S(() => {
|
|
1053
|
-
wt(
|
|
1055
|
+
wt(D.Left, true, false);
|
|
1054
1056
|
}, []), Ht = S(() => {
|
|
1055
|
-
wt(
|
|
1057
|
+
wt(D.Left, false, true);
|
|
1056
1058
|
}, []), Kt = S(() => {
|
|
1057
|
-
wt(
|
|
1059
|
+
wt(D.Left, true, true);
|
|
1058
1060
|
}, []), Nt = S(() => {
|
|
1059
|
-
wt(
|
|
1061
|
+
wt(D.Right, false, false);
|
|
1060
1062
|
}, []), qt = S(() => {
|
|
1061
|
-
wt(
|
|
1063
|
+
wt(D.Right, true, false);
|
|
1062
1064
|
}, []), jt = S(() => {
|
|
1063
|
-
wt(
|
|
1065
|
+
wt(D.Right, false, true);
|
|
1064
1066
|
}, []), Xt = S(() => {
|
|
1065
|
-
wt(
|
|
1067
|
+
wt(D.Right, true, true);
|
|
1066
1068
|
}, []), Yt = S(() => {
|
|
1067
|
-
wt(
|
|
1069
|
+
wt(D.Up, false, false);
|
|
1068
1070
|
}, []), Gt = S(() => {
|
|
1069
|
-
wt(
|
|
1071
|
+
wt(D.Up, true, false);
|
|
1070
1072
|
}, []), Zt = S(() => {
|
|
1071
|
-
wt(
|
|
1073
|
+
wt(D.Up, false, true);
|
|
1072
1074
|
}, []), _t = S(() => {
|
|
1073
|
-
wt(
|
|
1075
|
+
wt(D.Up, true, true);
|
|
1074
1076
|
}, []), Jt = S(() => {
|
|
1075
|
-
wt(
|
|
1077
|
+
wt(D.Down, false, false);
|
|
1076
1078
|
}, []), Qt = S(() => {
|
|
1077
|
-
wt(
|
|
1079
|
+
wt(D.Down, true, false);
|
|
1078
1080
|
}, []), en = S(() => {
|
|
1079
|
-
wt(
|
|
1081
|
+
wt(D.Down, false, true);
|
|
1080
1082
|
}, []), tn = S(() => {
|
|
1081
|
-
wt(
|
|
1083
|
+
wt(D.Down, true, true);
|
|
1082
1084
|
}, []), nn = S(() => {
|
|
1083
|
-
|
|
1085
|
+
Ae2((e2) => e2.slice(0, -1));
|
|
1084
1086
|
}, []), on = b(() => {
|
|
1085
1087
|
const e2 = he2();
|
|
1086
1088
|
return ((e3, t3, n3, o2, r3) => {
|
|
@@ -1092,7 +1094,7 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1092
1094
|
return false;
|
|
1093
1095
|
})($e2.ranges, e2.top, e2.left, e2.bottom, e2.right);
|
|
1094
1096
|
}, [V2, $e2.ranges]), rn = S((e2, n3 = true) => {
|
|
1095
|
-
_e.current = e2,
|
|
1097
|
+
_e.current = e2, We2(e2), n3 && e2 && t2?.current && et(e2);
|
|
1096
1098
|
}, []), ln = o((e2 = true) => {
|
|
1097
1099
|
const t3 = Ne2.current;
|
|
1098
1100
|
if (!Be2.current?.cell) return;
|
|
@@ -1101,8 +1103,8 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1101
1103
|
if (!t3) return;
|
|
1102
1104
|
let r3 = null;
|
|
1103
1105
|
if (r3 = n3.length > 0 ? n3[n3.length - 1] : J2(o2), r3.colEnd >= r3.colStart && r3.rowEnd >= r3.rowStart) {
|
|
1104
|
-
const n4 =
|
|
1105
|
-
let o3 = e2 ?
|
|
1106
|
+
const n4 = le(r3, t3);
|
|
1107
|
+
let o3 = e2 ? fe2 : xe2;
|
|
1106
1108
|
try {
|
|
1107
1109
|
o3?.(r3, t3, n4.direction);
|
|
1108
1110
|
} catch (e3) {
|
|
@@ -1116,7 +1118,7 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1116
1118
|
const o2 = t2.current.getViewFromClient(e2.nativeEvent.clientX, e2.nativeEvent.clientY), r3 = o2?.getCellCoordsFromClient(e2.nativeEvent.clientX, e2.nativeEvent.clientY);
|
|
1117
1119
|
r3 && (e2.stopPropagation(), Ue2("crosshair"), cn.current = { anchor: o2.getAnchor(), coords: r3 });
|
|
1118
1120
|
}, onPointerMoveOrWait: (e2, n3) => {
|
|
1119
|
-
if (
|
|
1121
|
+
if (T2 || !t2?.current || !Be2.current || !cn.current) return;
|
|
1120
1122
|
const o2 = cn.current.anchor;
|
|
1121
1123
|
let r3 = t2.current.getViewFromLocation(o2), l3 = r3.getCellCoordsFromClient(e2.clientX, e2.clientY);
|
|
1122
1124
|
if (!l3) return;
|
|
@@ -1126,41 +1128,41 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1126
1128
|
if (!c2) return;
|
|
1127
1129
|
const s2 = i2.length > 0, a3 = s2 ? i2[i2.length - 1] : J2(Be2.current.cell);
|
|
1128
1130
|
if (!c2) return;
|
|
1129
|
-
const d3 = c2.rowStart < a3.rowStart ?
|
|
1130
|
-
d3 ===
|
|
1131
|
-
const h2 =
|
|
1131
|
+
const d3 = c2.rowStart < a3.rowStart ? D.Up : c2.rowEnd > a3.rowEnd ? D.Down : c2.colEnd > a3.colEnd ? D.Right : D.Left, u3 = he2();
|
|
1132
|
+
d3 === D.Left && (c2 = { ...a3, colStart: Math.max(u3.left, c2.colStart) }), d3 === D.Up && (c2 = { ...a3, rowStart: Math.max(u3.top, c2.rowStart) }), d3 === D.Right && (c2 = { ...a3, colEnd: Math.min(u3.right, c2.colEnd) }), d3 === D.Down && (c2 = { ...a3, rowEnd: Math.min(u3.bottom, c2.rowEnd) });
|
|
1133
|
+
const h2 = le(a3, c2);
|
|
1132
1134
|
if (!N2?.(a3)) {
|
|
1133
1135
|
let e3;
|
|
1134
1136
|
"function" == typeof Qe.current ? e3 = Qe.current(a3) : K2 && (e3 = K2), c2 = ((e4, t3, n4, o3, r4, l4) => {
|
|
1135
1137
|
const i3 = { ...t3 };
|
|
1136
1138
|
if (0 === n4.length) return i3;
|
|
1137
|
-
if (r4 ===
|
|
1139
|
+
if (r4 === D.Left) {
|
|
1138
1140
|
const t4 = e4.colEnd + 1 - e4.colStart;
|
|
1139
1141
|
i3.colStart = e4.colStart - Math.ceil(l4 / t4) * t4, i3.colStart < o3.left && (i3.colStart = i3.colStart + Math.ceil((o3.left - i3.colStart) / t4) * t4);
|
|
1140
|
-
} else if (r4 ===
|
|
1142
|
+
} else if (r4 === D.Right) {
|
|
1141
1143
|
const t4 = e4.colEnd + 1 - e4.colStart;
|
|
1142
1144
|
i3.colEnd = e4.colEnd + Math.ceil(l4 / t4) * t4, i3.colEnd > o3.right && (i3.colEnd = i3.colEnd - Math.ceil((o3.right - i3.colEnd) / t4) * t4);
|
|
1143
|
-
} else if (r4 ===
|
|
1145
|
+
} else if (r4 === D.Up) {
|
|
1144
1146
|
const t4 = e4.rowEnd + 1 - e4.rowStart;
|
|
1145
1147
|
i3.rowStart = e4.rowStart - Math.ceil(l4 / t4) * t4, i3.rowStart < o3.top && (i3.rowStart = i3.rowStart + Math.ceil((o3.top - i3.rowStart) / t4) * t4);
|
|
1146
|
-
} else if (r4 ===
|
|
1148
|
+
} else if (r4 === D.Down) {
|
|
1147
1149
|
const t4 = e4.rowEnd + 1 - e4.rowStart;
|
|
1148
1150
|
i3.rowEnd = e4.rowEnd + Math.ceil(l4 / t4) * t4, i3.rowEnd > o3.bottom && (i3.rowEnd = i3.rowEnd - Math.ceil((o3.bottom - i3.rowEnd) / t4) * t4);
|
|
1149
1151
|
}
|
|
1150
1152
|
return i3;
|
|
1151
1153
|
})(a3, c2, e3, u3, h2.direction, h2.amount);
|
|
1152
1154
|
}
|
|
1153
|
-
if (s2 &&
|
|
1155
|
+
if (s2 && k.isRangeWithinRange(c2, a3) && (c2 = null), !k.isEqualRanges(c2, Ne2.current)) {
|
|
1154
1156
|
if (Ke2(c2), Ne2.current = c2, !c2) {
|
|
1155
1157
|
try {
|
|
1156
|
-
|
|
1158
|
+
Ee2?.();
|
|
1157
1159
|
} catch (e3) {
|
|
1158
1160
|
}
|
|
1159
1161
|
return void Re2?.();
|
|
1160
1162
|
}
|
|
1161
1163
|
ln(false);
|
|
1162
1164
|
}
|
|
1163
|
-
ut.current = n3,
|
|
1165
|
+
ut.current = n3, Ce(r3, l3, t2);
|
|
1164
1166
|
}, onPointerUp: (e2, n3) => {
|
|
1165
1167
|
ut.current = n3, Promise.resolve(ln(true)).finally(() => {
|
|
1166
1168
|
Re2?.(), Ke2(null), Ne2.current = null, cn.current = null, Ue2(null), t2.current?.focus();
|
|
@@ -1171,17 +1173,17 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1171
1173
|
if (!r3) return;
|
|
1172
1174
|
if (false === U2?.(e2, r3, $e2)) return false;
|
|
1173
1175
|
e2.stopPropagation(), Ue2("default");
|
|
1174
|
-
const l3 = o2.getRelativePointFromClient(0, 0), i2 = Be2.current?.ranges[Be2.current?.ranges.length - 1] ??
|
|
1176
|
+
const l3 = o2.getRelativePointFromClient(0, 0), i2 = Be2.current?.ranges[Be2.current?.ranges.length - 1] ?? k.cellToRange(Be2.current?.cell), c2 = o2.toClipBounds(o2.getRangeCoordsBounds(i2)), s2 = { x: 0, y: 0 };
|
|
1175
1177
|
c2.x - l3.x > e2.nativeEvent.clientX ? s2.x = e2.nativeEvent.clientX - (c2.x - l3.x) : e2.nativeEvent.clientX >= c2.x - l3.x + c2.width && (s2.x = Math.max(0, e2.nativeEvent.clientX - (c2.x - l3.x + c2.width)) + 1), c2.y - l3.y > e2.nativeEvent.clientY ? s2.y = e2.nativeEvent.clientY - (c2.y - l3.y) : e2.nativeEvent.clientY >= c2.y - l3.y + c2.height && (s2.y = Math.max(0, e2.nativeEvent.clientY - (c2.y - l3.y + c2.height)) + 1), q2?.(i2, e2, n3), gn.current = { range: i2, anchor: o2.getAnchor(), cell: r3, isMoving: false, extrusion: s2 };
|
|
1176
1178
|
}, onPointerMoveOrWait: (e2, n3, o2) => {
|
|
1177
|
-
if (
|
|
1179
|
+
if (_2 || !t2?.current || !Be2.current || !gn.current) return;
|
|
1178
1180
|
const r3 = e2.clientX - o2.clientX, l3 = e2.clientY - o2.clientY;
|
|
1179
1181
|
if (gn.current.isMoving = gn.current.isMoving || Math.abs(r3) > Math.max(1, 2) || Math.abs(l3) > Math.max(1, 2) || performance.now() - o2.timeStamp > 500, !gn.current.isMoving) return;
|
|
1180
1182
|
const i2 = gn.current.anchor, c2 = gn.current.extrusion;
|
|
1181
1183
|
let s2 = t2.current.getViewFromLocation(i2), a3 = s2.getCellCoordsFromClient(e2.clientX - c2.x, e2.clientY - c2.y, true);
|
|
1182
1184
|
if (!a3) return;
|
|
1183
1185
|
const d3 = gn.current.cell, u3 = gn.current.range, h2 = he2(), g2 = u3.colEnd - u3.colStart + 1, f3 = Math.min(Math.max(0, d3.colIndex - u3.colStart), g2 - 1), w3 = Math.min(h2.right - g2 + 1, Math.max(h2.left, a3.colIndex - f3)), x2 = u3.rowEnd - u3.rowStart + 1, p3 = Math.min(Math.max(0, d3.rowIndex - u3.rowStart), x2 - 1), m2 = Math.min(h2.bottom - x2 + 1, Math.max(h2.top, a3.rowIndex - p3)), v2 = { colStart: w3, colEnd: w3 + g2 - 1, rowStart: m2, rowEnd: m2 + x2 - 1 };
|
|
1184
|
-
|
|
1186
|
+
k.isEqualRanges(un, v2) && !((e3) => !e3 || !ut.current || ut.current.ctrlKey !== e3.ctrlKey || ut.current.shiftKey !== e3.shiftKey || ut.current.altKey !== e3.altKey || ut.current.metaKey !== e3.metaKey)(e2) || (hn(v2), j2?.(v2, e2, n3)), ut.current = n3, Ce(s2, a3, t2);
|
|
1185
1187
|
}, onPointerUp: (e2, n3) => {
|
|
1186
1188
|
ut.current = n3;
|
|
1187
1189
|
const o2 = () => {
|
|
@@ -1193,151 +1195,153 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1193
1195
|
o2();
|
|
1194
1196
|
});
|
|
1195
1197
|
} }), [un]), wn = s(fn), xn = b(() => ({ onPointerDown: wn }), [wn]), pn = x(null), mn = b(() => {
|
|
1196
|
-
const e2 =
|
|
1198
|
+
const e2 = k.isEqualSelectionCoords($e2, pn.current) ? pn.current : $e2;
|
|
1197
1199
|
return pn.current = e2, e2;
|
|
1198
1200
|
}, [$e2]), vn = S((n3) => {
|
|
1199
1201
|
let o2 = null, r3 = "br";
|
|
1200
|
-
const l3 = [], i2 = { stroke:
|
|
1201
|
-
const r4 = n3.toClipBounds(n3.getRangeCoordsBounds(e2),
|
|
1202
|
+
const l3 = [], i2 = { stroke: z2, fill: ne2, strokeWidth: 0.5 }, c2 = (e2, t3, o3) => {
|
|
1203
|
+
const r4 = n3.toClipBounds(n3.getRangeCoordsBounds(e2), me);
|
|
1202
1204
|
if (!r4) return;
|
|
1203
1205
|
r4.x = r4.width > 0 ? r4.x : r4.x - i2.strokeWidth / 2, r4.y = r4.height > 0 ? r4.y : r4.y - i2.strokeWidth / 2, r4.width = Math.max(r4.width, i2.strokeWidth), r4.height = Math.max(r4.height, i2.strokeWidth);
|
|
1204
1206
|
const l4 = { key: `selection-fill-${t3}`, range: e2, ...r4, ...i2 };
|
|
1205
1207
|
if (o3) {
|
|
1206
1208
|
const e3 = n3.getCellCoordsAsRangeCoords(o3);
|
|
1207
|
-
l4.cell = o3, l4.
|
|
1209
|
+
l4.cell = o3, l4.boundsPath = n3.toClipBounds(n3.getRangeCoordsBounds(e3), me), l4.boundsPath && (l4.boundsPath.width <= 0 || l4.boundsPath.height <= 0) && (delete l4.boundsPath, delete l4.cell);
|
|
1208
1210
|
}
|
|
1209
1211
|
return ke2(l4);
|
|
1210
1212
|
};
|
|
1211
|
-
let s2 = $e2 ?
|
|
1212
|
-
const a3 = s2?.cell ? n3.getCellCoordsAsRangeCoords(s2?.cell) :
|
|
1213
|
+
let s2 = Fe2.current || ($e2 ? be($e2) : null);
|
|
1214
|
+
const a3 = s2?.cell ? n3.getCellCoordsAsRangeCoords(s2?.cell) : ve;
|
|
1213
1215
|
!s2 || s2.ranges && 0 !== s2.ranges.length || (s2 = { ranges: [a3], rangeIndex: 0, cell: s2.cell });
|
|
1216
|
+
const d3 = s2 ? s2.ranges : null;
|
|
1217
|
+
d3 && d3.length;
|
|
1214
1218
|
for (let e2 = 0; s2 && e2 < s2.ranges.length; e2++) {
|
|
1215
1219
|
const t3 = s2.ranges[e2], i3 = c2(t3, e2, e2 === s2.rangeIndex ? s2.cell : null);
|
|
1216
1220
|
i3 && l3.push(i3);
|
|
1217
|
-
const a4 = 2, d4 = 0.5, u4 = n3.toClipBounds(n3.getRangeCoordsBounds(t3, { top: 0, left: 0, right: 0, bottom: 0 }),
|
|
1221
|
+
const a4 = 2, d4 = 0.5, u4 = n3.toClipBounds(n3.getRangeCoordsBounds(t3, { top: 0, left: 0, right: 0, bottom: 0 }), me);
|
|
1218
1222
|
if (u4) {
|
|
1219
1223
|
const n4 = (s2.ranges.length, 4);
|
|
1220
|
-
l3.push(ke2({ range: t3, key: `selection-inside-edge-${e2}`, x: u4.x - 1, y: u4.y - 1, width: Math.max(u4.width + 1, 0), height: Math.max(u4.height + 1, 0), style: { overflow: "hidden" }, stroke:
|
|
1224
|
+
l3.push(ke2({ range: t3, key: `selection-inside-edge-${e2}`, x: u4.x - 1, y: u4.y - 1, width: Math.max(u4.width + 1, 0), height: Math.max(u4.height + 1, 0), style: { overflow: "hidden" }, stroke: z2, strokeWidth: n4 }));
|
|
1221
1225
|
}
|
|
1222
1226
|
if (1 === s2.ranges.length) {
|
|
1223
|
-
const o3 = n3.toClipBounds(n3.getRangeCoordsBounds(t3),
|
|
1227
|
+
const o3 = n3.toClipBounds(n3.getRangeCoordsBounds(t3), me);
|
|
1224
1228
|
if (o3) {
|
|
1225
|
-
|
|
1229
|
+
_2 || l3.push(ke2({ range: t3, key: `move-selection-hit-box-${e2}`, x: o3.width > 1 ? o3.x : o3.x - (Q2 / 2 + 1), y: o3.height > 1 ? o3.y : o3.y - (Q2 / 2 + 1), width: Math.max(o3.width + 2, 1), height: Math.max(o3.height + 2, 1), stroke: "transparent", style: { boxShadow: "none" }, propsPath: { cursor: un ? void 0 : "move", pointerEvents: "stroke" }, strokeWidth: Q2, ...xn }));
|
|
1226
1230
|
const n4 = a4;
|
|
1227
|
-
l3.push(ke2({ range: t3, key: `selection-single-${e2}`, x: o3.x - n4 / 2, y: o3.y - n4 / 2, width: Math.max(o3.width + n4 / 2, 1), height: Math.max(o3.height + n4 / 2, 1), stroke:
|
|
1231
|
+
l3.push(ke2({ range: t3, key: `selection-single-${e2}`, x: o3.x - n4 / 2, y: o3.y - n4 / 2, width: Math.max(o3.width + n4 / 2, 1), height: Math.max(o3.height + n4 / 2, 1), stroke: ce2, strokeWidth: n4 }));
|
|
1228
1232
|
}
|
|
1229
1233
|
} else {
|
|
1230
|
-
const o3 = n3.toClipBounds(n3.getRangeCoordsBounds(t3, { top: -1, left: -1, right: -2, bottom: -2 }),
|
|
1231
|
-
o3 && l3.push(ke2({ range: t3, key: `selection-multi-${e2}`, x: o3.width > 1 ? o3.x : o3.x - d4 / 2, y: o3.height > 1 ? o3.y : o3.y - d4 / 2, width: Math.max(o3.width, d4) + 1, height: Math.max(o3.height, d4) + 1, stroke:
|
|
1234
|
+
const o3 = n3.toClipBounds(n3.getRangeCoordsBounds(t3, { top: -1, left: -1, right: -2, bottom: -2 }), me);
|
|
1235
|
+
o3 && l3.push(ke2({ range: t3, key: `selection-multi-${e2}`, x: o3.width > 1 ? o3.x : o3.x - d4 / 2, y: o3.height > 1 ? o3.y : o3.y - d4 / 2, width: Math.max(o3.width, d4) + 1, height: Math.max(o3.height, d4) + 1, stroke: ce2, style: { overflow: "hidden" }, strokeWidth: 2 }));
|
|
1232
1236
|
}
|
|
1233
1237
|
if (s2.ranges.length > 1 && e2 === s2.rangeIndex) {
|
|
1234
|
-
const o3 = n3.getCellCoordsAsRangeCoords(s2.cell), r4 = n3.toClipBounds(n3.getRangeCoordsBounds(o3, { top: 1, left: 1, right: -1, bottom: -1 }),
|
|
1235
|
-
r4 && l3.push(ke2({ range: t3, key: `selection-anchor-${e2}`, x: r4.x, y: r4.y, width: Math.max(r4.width, d4), height: Math.max(r4.height, d4), stroke:
|
|
1238
|
+
const o3 = n3.getCellCoordsAsRangeCoords(s2.cell), r4 = n3.toClipBounds(n3.getRangeCoordsBounds(o3, { top: 1, left: 1, right: -1, bottom: -1 }), me);
|
|
1239
|
+
r4 && l3.push(ke2({ range: t3, key: `selection-anchor-${e2}`, x: r4.x, y: r4.y, width: Math.max(r4.width, d4), height: Math.max(r4.height, d4), stroke: ce2, style: { overflow: "hidden" }, strokeWidth: 2 }));
|
|
1236
1240
|
}
|
|
1237
1241
|
if (e2 === s2.ranges.length - 1) {
|
|
1238
1242
|
o2 = null, r3 = null;
|
|
1239
1243
|
const e3 = t3.rowStart === he2().top && t3.rowEnd === he2().bottom, l4 = t3.colStart === he2().left && t3.colEnd === he2().right, i4 = n3.getRangeCoordsBounds(t3);
|
|
1240
1244
|
let c3 = null;
|
|
1241
1245
|
if (e3 || l4) {
|
|
1242
|
-
if (c3 = n3.toClipBounds(i4,
|
|
1243
|
-
const o3 = n3.getVisibleRangeCoords(), r4 = n3.allViews()[
|
|
1244
|
-
(l4 && (a5 ===
|
|
1246
|
+
if (c3 = n3.toClipBounds(i4, me), Object.keys(n3.allViews()).length > 1) {
|
|
1247
|
+
const o3 = n3.getVisibleRangeCoords(), r4 = n3.allViews()[O.TopLeft], i5 = n3.allViews()[O.Top], s3 = n3.allViews()[O.Left], a5 = n3.getAnchor();
|
|
1248
|
+
(l4 && (a5 === O.Top && r4 || a5 === O.Center && s3 || !k.isCellWithinRange({ colIndex: t3.colStart, rowIndex: t3.rowEnd }, o3) && !k.isCellWithinRange({ colIndex: t3.colStart, rowIndex: t3.rowEnd + 1 }, o3)) || e3 && (a5 === O.Left && r4 || a5 === O.Center && i5 || !k.isCellWithinRange({ colIndex: t3.colEnd, rowIndex: t3.rowStart }, o3) && !k.isCellWithinRange({ colIndex: t3.colEnd + 1, rowIndex: t3.rowStart }, o3))) && (c3 = null);
|
|
1245
1249
|
}
|
|
1246
|
-
} else c3 = n3.toClipBounds(i4,
|
|
1250
|
+
} else c3 = n3.toClipBounds(i4, me);
|
|
1247
1251
|
if (!c3 || 0 === c3.width || 0 === c3.height) continue;
|
|
1248
1252
|
o2 = { x: c3.x + c3.width + 1, y: c3.y + c3.height + 1 }, 0 === c3.width || 0 === c3.height || t3.rowStart === he2().top && t3.colStart === he2().left && t3.rowEnd === he2().bottom && t3.colEnd === he2().right || (e3 ? (o2.y = a4, r3 = "tr") : l4 && (o2.x = a4, r3 = "bl"));
|
|
1249
1253
|
}
|
|
1250
1254
|
}
|
|
1251
|
-
let
|
|
1255
|
+
let u3 = null;
|
|
1252
1256
|
if (qe2) {
|
|
1253
|
-
const e2 = n3.toClipBounds(n3.getRangeCoordsBounds(qe2, { top: 0, left: 0, right: 0, bottom: 0 }),
|
|
1257
|
+
const e2 = n3.toClipBounds(n3.getRangeCoordsBounds(qe2, { top: 0, left: 0, right: 0, bottom: 0 }), me);
|
|
1254
1258
|
if (e2) {
|
|
1255
1259
|
const t3 = 2;
|
|
1256
|
-
|
|
1260
|
+
u3 = ke2({ ...i2, range: qe2, key: "remove-selection", x: e2.x, y: e2.y, width: e2.width, height: e2.height, strokeWidth: t3, stroke: se2, fill: ae2 });
|
|
1257
1261
|
}
|
|
1258
1262
|
}
|
|
1259
|
-
let
|
|
1263
|
+
let h2 = null;
|
|
1260
1264
|
if (He2) {
|
|
1261
|
-
const e2 = n3.toClipBounds(n3.getRangeCoordsBounds(He2, { top: 0, left: 0, right: 0, bottom: 0 }),
|
|
1265
|
+
const e2 = n3.toClipBounds(n3.getRangeCoordsBounds(He2, { top: 0, left: 0, right: 0, bottom: 0 }), me);
|
|
1262
1266
|
if (e2) {
|
|
1263
1267
|
const t3 = 2;
|
|
1264
|
-
|
|
1268
|
+
h2 = ke2({ range: He2, key: "selection-fill-outline", x: e2.x - t3 / 2, y: e2.y - t3 / 2, width: e2.width + t3 / 2, height: e2.height + t3 / 2, strokeWidth: t3, stroke: ce2, strokeDasharray: "3 2" });
|
|
1265
1269
|
}
|
|
1266
1270
|
}
|
|
1267
|
-
let
|
|
1268
|
-
!
|
|
1269
|
-
const
|
|
1270
|
-
if (
|
|
1271
|
-
const o3 = s2.ranges[s2.ranges.length - 1], r4 = o3.rowStart === he2().top && o3.rowEnd === he2().bottom, l4 = o3.colStart === he2().left && o3.colEnd === he2().right, i3 = { view: n3, range: o3, borderStroke: `${
|
|
1272
|
-
|
|
1271
|
+
let g2 = null;
|
|
1272
|
+
!T2 && o2 && !un && (g2 = E(we, { ...o2, corner: r3, size: 7.5, borderStroke: `${z2} solid`, style: { borderRadius: 1 }, background: ce2, ...dn, key: "fillHandle" }));
|
|
1273
|
+
const f3 = [...l3];
|
|
1274
|
+
if (u3 && f3.push(u3), h2 && f3.push(h2), g2 && f3.push(g2), !de2 && st && 1 === s2?.ranges.length && s2.ranges[s2.ranges.length - 1]) {
|
|
1275
|
+
const o3 = s2.ranges[s2.ranges.length - 1], r4 = o3.rowStart === he2().top && o3.rowEnd === he2().bottom, l4 = o3.colStart === he2().left && o3.colEnd === he2().right, i3 = { view: n3, range: o3, borderStroke: `${ce2} solid 3px`, background: z2, selectionTouchPointerHandler: ft, ...ue2, onTouchSelectStart: (e2) => Ze(e2), onTouchSelectEnd: () => Ze(null), currentTouchAnchor: Ge };
|
|
1276
|
+
f3.push(e(pe, { anchor: l4 ? "b" : r4 ? "r" : "br", scrollableElement: t2.current, ...i3 }, "touch-select-handle-after")), f3.push(e(pe, { anchor: l4 ? "t" : r4 ? "l" : "tl", scrollableElement: t2.current, ...i3 }, "touch-select-handle-before"));
|
|
1273
1277
|
}
|
|
1274
1278
|
if (un) {
|
|
1275
|
-
const e2 = n3.toClipBounds(n3.getRangeCoordsBounds(un, { top: 1, left: 1, right: 1, bottom: 1 }),
|
|
1276
|
-
e2 &&
|
|
1279
|
+
const e2 = n3.toClipBounds(n3.getRangeCoordsBounds(un, { top: 1, left: 1, right: 1, bottom: 1 }), me);
|
|
1280
|
+
e2 && f3.push(ke2({ range: un, key: "selection-move-outline", x: e2.x - te2 / 2, y: e2.y - te2 / 2, width: Math.max(e2.width + te2 / 2, 1), height: Math.max(e2.height + te2 / 2, 1), stroke: ce2, style: { boxShadow: "none", transitionDuration: "70ms", transitionTimingFunction: "ease-in", transitionProperty: "left, top, width, height", willChange: "left, top, width, height" }, strokeWidth: te2 }));
|
|
1277
1281
|
}
|
|
1278
|
-
return e("div", { children:
|
|
1279
|
-
}, [mn, qe2,
|
|
1282
|
+
return e("div", { children: f3 }, "selection");
|
|
1283
|
+
}, [mn, qe2, T2, He2, _2, un, he2, z2, ce2, ne2, se2, ae2, de2, ue2, Ge]), Sn = b(() => {
|
|
1280
1284
|
const e2 = () => t2.current;
|
|
1281
1285
|
return [new h("moveToPageDown", e2, { label: "Page Down", description: "Shift viewport down one page.", shortcut: [{ key: "PageDown" }] }, () => Pt(false)), new h("selectToPageDown", e2, { label: "Select To Page Down", description: "Shift viewport and select down one page.", shortcut: [{ key: "PageDown", modifiers: [g.Shift] }] }, () => Pt(true)), new h("moveToPageRight", e2, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [g.Alt] }] }, () => Dt(false)), new h("selectToPageRight", e2, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [g.Alt, g.Shift] }] }, () => Dt(true)), new h("moveToPageUp", e2, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp" }] }, () => Tt(false)), new h("selectToPageUp", e2, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp", modifiers: [g.Shift] }] }, () => Tt(true)), new h("moveToPageLeft", e2, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [g.Alt] }] }, () => Ot(false)), new h("selectToPageLeft", e2, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [g.Alt, g.Shift] }] }, () => Ot(true)), new h("selectColumn", e2, { label: "Select Column", description: "Select the columns for the selected cells.", shortcut: { key: "Space", modifiers: [g.Ctrl] } }, pt), new h("selectRow", e2, { label: "Select Row", description: "Select the rows for the selected cells.", shortcut: { key: "Space", modifiers: [g.Shift] } }, mt), new h("selectToColumnStart", e2, { label: "Select To Column Start", description: "Select the columns to the beginning of the sheet." }, () => St(true)), new h("selectToColumnEnd", e2, { label: "Select To Column End", description: "Select the columns to the end of the sheet." }, () => yt(true)), new h("moveToRowStart", e2, { label: "Move to Row Home", description: "Move to the beginning of the row.", shortcut: [{ key: "Home" }] }, () => bt(false)), new h("selectToRowStart", e2, { label: "Select to Row Home", description: "Select to the beginning of the row.", shortcut: [{ key: "Home", modifiers: [g.Shift] }] }, () => bt(true)), new h("moveToSheetStart", e2, { label: "Move to Sheet Home", description: "Move to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [g.Ctrl] }] }, () => Ct(false)), new h("selectToSheetStart", e2, { label: "Select to Sheet Home", description: "Select to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [g.Ctrl, g.Shift] }] }, () => Ct(true)), new h("moveToRowEnd", e2, { label: "Move to Row End", description: "Move to the end of the row.", shortcut: [{ key: "End" }] }, () => It(false)), new h("selectToRowEnd", e2, { label: "Select to Row End", description: "Select to the end of the row.", shortcut: [{ key: "End", modifiers: [g.Shift] }] }, () => It(true)), new h("moveToSheetEnd", e2, { label: "Move to Sheet End", description: "Move to the end of the sheet.", shortcut: [{ key: "End", modifiers: [g.Ctrl] }] }, () => Et(false)), new h("selectToSheetEnd", e2, { label: "Select to Sheet End", description: "Select to the end of the sheet.", shortcut: [{ key: "End", modifiers: [g.Ctrl, g.Shift] }] }, () => Et(true)), new h("scrollToActiveCoords", e2, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell.", shortcut: { key: "Backspace", modifiers: [g.Ctrl] } }, vt), new h("scrollToActiveCoordsClearSelection", e2, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell and clear selection.", shortcut: { key: "Backspace", modifiers: [g.Shift] } }, () => {
|
|
1282
1286
|
ct(), rn($e2.cell, true);
|
|
1283
|
-
}), new h("traverseSelectionRight", e2, { label: "Traverse Right", description: "Traverse the selection moving rightward.", shortcut: { key: "Tab" } }, Lt), new h("traverseSelectionLeft", e2, { label: "Traverse Left", description: "Traverse the selection moving leftward.", shortcut: { key: "Tab", modifiers: [g.Shift] } }, zt), new h("traverseSelectionDown", e2, { label: "Traverse Down", description: "Traverse the selection moving downward.", shortcut: [{ key: "Enter" }, { key: "NumpadEnter" }] }, Bt), new h("traverseSelectionUp", e2, { label: "Traverse Up", description: "Traverse the selection moving upward.", shortcut: [{ key: "Enter", modifiers: [g.Shift] }, { key: "NumpadEnter", modifiers: [g.Shift] }] }, $t), new h("moveLeft", e2, { label: "Move Left", description: "Move active cell to the left.", shortcut: [{ key: "ArrowLeft" }] }, Vt), new h("selectLeft", e2, { label: "Select Left", description: "Extend selection left.", shortcut: [{ key: "ArrowLeft", modifiers: [g.Shift] }] }, Ut), new h("moveContentfulLeft", e2, { label: "Move Left Contentful", description: "Move left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [g.Ctrl] }] }, Ht), new h("selectContentfulLeft", e2, { label: "Select Left Contentful", description: "Extend selection left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [g.Ctrl, g.Shift] }] }, Kt), new h("moveRight", e2, { label: "Move Right", description: "Move active cell to the right.", shortcut: [{ key: "ArrowRight" }] }, Nt), new h("selectRight", e2, { label: "Select Right", description: "Extend selection right.", shortcut: [{ key: "ArrowRight", modifiers: [g.Shift] }] }, qt), new h("moveContentfulRight", e2, { label: "Move Right Contentful", description: "Move right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [g.Ctrl] }] }, jt), new h("selectContentfulRight", e2, { label: "Select Right Contentful", description: "Extend selection right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [g.Ctrl, g.Shift] }] }, Xt), new h("moveUp", e2, { label: "Move Up", description: "Move active cell to the up.", shortcut: [{ key: "ArrowUp" }] }, Yt), new h("selectUp", e2, { label: "Select Up", description: "Extend selection up.", shortcut: [{ key: "ArrowUp", modifiers: [g.Shift] }] }, Gt), new h("moveContentfulUp", e2, { label: "Move Up Contentful", description: "Move up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [g.Ctrl] }] }, Zt), new h("selectContentfulUp", e2, { label: "Select Up Contentful", description: "Extend selection up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [g.Ctrl, g.Shift] }] }, _t), new h("moveDown", e2, { label: "Move Down", description: "Move active cell to the down.", shortcut: [{ key: "ArrowDown" }] }, Jt), new h("selectDown", e2, { label: "Select Down", description: "Extend selection down.", shortcut: [{ key: "ArrowDown", modifiers: [g.Shift] }] }, Qt), new h("moveContentfulDown", e2, { label: "Move Down Contentful", description: "Move down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [g.Ctrl] }] }, en), new h("selectContentfulDown", e2, { label: "Select Down Contentful", description: "Extend selection down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [g.Ctrl, g.Shift] }] }, tn), new h("selectVisible", e2, { label: "Select Visible", description: "Select visible cells only.", shortcut: { key: ";", modifiers: [g.Alt] } }, Mt), new h("traverseSelectionPreviousRange", e2, { label: "Traverse Previous Range", description: "Traverse the selection to the previous range.", shortcut: { key: "ArrowLeft", modifiers: [g.Ctrl, g.Alt] } }, Ft), new h("traverseSelectionNextRange", e2, { label: "Traverse Next Range", description: "Traverse the selection to the next range.", shortcut: { key: "ArrowRight", modifiers: [g.Ctrl, g.Alt] } },
|
|
1287
|
+
}), new h("traverseSelectionRight", e2, { label: "Traverse Right", description: "Traverse the selection moving rightward.", shortcut: { key: "Tab" } }, Lt), new h("traverseSelectionLeft", e2, { label: "Traverse Left", description: "Traverse the selection moving leftward.", shortcut: { key: "Tab", modifiers: [g.Shift] } }, zt), new h("traverseSelectionDown", e2, { label: "Traverse Down", description: "Traverse the selection moving downward.", shortcut: [{ key: "Enter" }, { key: "NumpadEnter" }] }, Bt), new h("traverseSelectionUp", e2, { label: "Traverse Up", description: "Traverse the selection moving upward.", shortcut: [{ key: "Enter", modifiers: [g.Shift] }, { key: "NumpadEnter", modifiers: [g.Shift] }] }, $t), new h("moveLeft", e2, { label: "Move Left", description: "Move active cell to the left.", shortcut: [{ key: "ArrowLeft" }] }, Vt), new h("selectLeft", e2, { label: "Select Left", description: "Extend selection left.", shortcut: [{ key: "ArrowLeft", modifiers: [g.Shift] }] }, Ut), new h("moveContentfulLeft", e2, { label: "Move Left Contentful", description: "Move left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [g.Ctrl] }] }, Ht), new h("selectContentfulLeft", e2, { label: "Select Left Contentful", description: "Extend selection left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [g.Ctrl, g.Shift] }] }, Kt), new h("moveRight", e2, { label: "Move Right", description: "Move active cell to the right.", shortcut: [{ key: "ArrowRight" }] }, Nt), new h("selectRight", e2, { label: "Select Right", description: "Extend selection right.", shortcut: [{ key: "ArrowRight", modifiers: [g.Shift] }] }, qt), new h("moveContentfulRight", e2, { label: "Move Right Contentful", description: "Move right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [g.Ctrl] }] }, jt), new h("selectContentfulRight", e2, { label: "Select Right Contentful", description: "Extend selection right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [g.Ctrl, g.Shift] }] }, Xt), new h("moveUp", e2, { label: "Move Up", description: "Move active cell to the up.", shortcut: [{ key: "ArrowUp" }] }, Yt), new h("selectUp", e2, { label: "Select Up", description: "Extend selection up.", shortcut: [{ key: "ArrowUp", modifiers: [g.Shift] }] }, Gt), new h("moveContentfulUp", e2, { label: "Move Up Contentful", description: "Move up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [g.Ctrl] }] }, Zt), new h("selectContentfulUp", e2, { label: "Select Up Contentful", description: "Extend selection up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [g.Ctrl, g.Shift] }] }, _t), new h("moveDown", e2, { label: "Move Down", description: "Move active cell to the down.", shortcut: [{ key: "ArrowDown" }] }, Jt), new h("selectDown", e2, { label: "Select Down", description: "Extend selection down.", shortcut: [{ key: "ArrowDown", modifiers: [g.Shift] }] }, Qt), new h("moveContentfulDown", e2, { label: "Move Down Contentful", description: "Move down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [g.Ctrl] }] }, en), new h("selectContentfulDown", e2, { label: "Select Down Contentful", description: "Extend selection down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [g.Ctrl, g.Shift] }] }, tn), new h("selectVisible", e2, { label: "Select Visible", description: "Select visible cells only.", shortcut: { key: ";", modifiers: [g.Alt] } }, Mt), new h("traverseSelectionPreviousRange", e2, { label: "Traverse Previous Range", description: "Traverse the selection to the previous range.", shortcut: { key: "ArrowLeft", modifiers: [g.Ctrl, g.Alt] } }, Ft), new h("traverseSelectionNextRange", e2, { label: "Traverse Next Range", description: "Traverse the selection to the next range.", shortcut: { key: "ArrowRight", modifiers: [g.Ctrl, g.Alt] } }, At), new h("traverseSelectionCorners", e2, { label: "Traverse Corners", description: "Traverse the selection through the corners of the selected range.", shortcut: { key: ".", modifiers: [g.Ctrl] } }, Wt)];
|
|
1284
1288
|
}, []);
|
|
1285
1289
|
return b(() => {
|
|
1286
1290
|
n2?.addCommands(Sn, true);
|
|
1287
|
-
}, [n2]), { selection: mn, setSelectionCell: rn, setSelectionRanges:
|
|
1288
|
-
},
|
|
1289
|
-
const { width: c2, height: s2, rowCount: a2 = 1, columnCount: d2 = 1, defaultRowHeight: u2, defaultColumnWidth: h2, getRowHeight: g2, getColumnWidth: w2, layout: C2, onViewportScroll: I2, onImmediateScroll:
|
|
1290
|
-
|
|
1291
|
-
const ve2 = o(
|
|
1291
|
+
}, [n2]), { selection: mn, setSelectionCell: rn, setSelectionRanges: Ae2, renderOverlay: vn, cursor: Ve2, onPointerDown: gt, clearLastSelection: nn, newSelection: lt, modifySelection: rt, appendSelection: it, clearSelections: ct, isEntire: on, navigate: wt, navigateSelection: xt };
|
|
1292
|
+
}, Re = { "sheetxl-grid": "_sheetxl-grid_h9wwa_7" }, Me = Object.freeze({ top: 0, left: 0 }), ke = Object.freeze({ bottom: -4, right: -4 }), Pe = Object.freeze({ horizontal: true, vertical: true }), Te = [O.TopLeft, O.Top, O.Left, O.Center], De = 150, Oe = 3e3, ze = {}, Le = C(I((r2, l2) => {
|
|
1293
|
+
const { width: c2, height: s2, rowCount: a2 = 1, columnCount: d2 = 1, defaultRowHeight: u2, defaultColumnWidth: h2, getRowHeight: g2, getColumnWidth: w2, layout: C2, onViewportScroll: I2, onImmediateScroll: T2, showGridLines: z2 = true, gridLineColor: L2 = "rgb(224, 224, 224)", propsGridLineRows: $2, propsGridLineColumns: B2, clipCells: F2 = true, cursor: A2, freezeLeft: W2 = 0, freezeTop: U2 = 0, propsFreezeLeft: H2, propsFreezeTop: K2, renderCell: N2, onViewportChange: q2, onFirstRender: j2, renderOverlay: X2, propsOverlay: Y2, renderOverlays: G2, propsOverlays: Z2, allowOverlaysOverflow: J2 = false, propsStage: Q2, wrapperStage: ee2 = null, hiddenRowsAt: oe2, hiddenColumnsAt: re2, hiddenCellAt: le2, getVisibleCells: de2, zoom: he2 = 1, enableMouseWheel: ge2 = true, onWheelScroll: fe2, getCellCoordsAsRangeCoords: we2 = k.cellToRange, scrollPoint: xe2 = Me, style: pe2 = {}, ...me2 } = r2;
|
|
1294
|
+
R(N2, "No renderCell specified. This is probably not what you wanted"), R(!r2?.children, "Grid does not support children elements");
|
|
1295
|
+
const ve2 = o(T2, [T2]), Se2 = o(q2, [q2]), ye2 = o(I2, [I2]), be2 = o(fe2, [fe2]), Ce2 = o(j2, [j2]), Ie2 = x(null), Ee2 = x(null), De2 = x(null), [Le2, $e2] = p((e2) => e2 + 1, 0), [Be2, Fe2] = m({ left: xe2?.left ?? 0, top: xe2?.top ?? 0, horizontalScrollDirection: null, verticalScrollDirection: null }), Ae2 = x(null), We2 = x(Be2), { top: Ve2, left: Ue2, verticalScrollDirection: He2, horizontalScrollDirection: Ke2 } = Be2, Ne2 = x(false), qe2 = V({ rowCount: a2, columnCount: d2, defaultRowHeight: u2, defaultColumnWidth: h2, getRowHeight: g2, getColumnWidth: w2 }), je2 = x(null), Xe2 = b(() => {
|
|
1292
1296
|
const e2 = C2 || qe2;
|
|
1293
|
-
return je2.current = null, { getColOffset: (t2) => e2.getColOffset(t2) *
|
|
1294
|
-
}, [qe2, C2,
|
|
1297
|
+
return je2.current = null, { getColOffset: (t2) => e2.getColOffset(t2) * he2, getColIndex: (t2) => e2.getColIndex(t2 / he2), getRowOffset: (t2) => e2.getRowOffset(t2) * he2, getRowIndex: (t2) => e2.getRowIndex(t2 / he2) };
|
|
1298
|
+
}, [qe2, C2, he2]), Ye2 = (e2, t2, n2) => {
|
|
1295
1299
|
const o2 = (t2?.left ?? 0) + 0, r3 = (t2?.top ?? 0) + 0;
|
|
1296
1300
|
return { getColOffset: (t3) => e2.getColOffset(t3) - o2, getColIndex: (t3) => e2.getColIndex(t3 + o2), getRowOffset: (t3) => e2.getRowOffset(t3) - r3, getRowIndex: (t3) => e2.getRowIndex(t3 + r3) };
|
|
1297
|
-
},
|
|
1298
|
-
|
|
1301
|
+
}, Ge = o((e2, t2 = false) => ie(e2, t2, Xe2.getRowOffset, t2 ? 0 : a2), [a2, Xe2?.getRowOffset]), Ze = o(oe2 ?? Ge, [oe2]), _e = o((e2, t2 = false) => ie(e2, t2, Xe2.getColOffset, t2 ? d2 : 0), [d2, Xe2?.getColOffset]), Je = o(re2 ?? _e, [re2]), Qe = b(() => Math.min(c2 ?? 800, Xe2.getColOffset(d2)), [Xe2.getColOffset, d2, c2]), et = b(() => Math.min(s2 ?? 600, Xe2.getRowOffset(a2)), [Xe2.getRowOffset, a2, s2]), tt = S((e2) => {
|
|
1302
|
+
P.canUseDOM && setTimeout(() => {
|
|
1299
1303
|
Ie2.current?.focus({ preventScroll: true, ...e2 });
|
|
1300
1304
|
}, 0);
|
|
1301
1305
|
}, []), nt = S((e2) => Ie2.current?.contains(e2) || Ee2.current?.contains(e2), []);
|
|
1302
1306
|
v(() => {
|
|
1303
|
-
Ne2.current && (
|
|
1307
|
+
Ne2.current && (Ae2.current && Ae2.current.left !== We2.current?.left && Ae2.current.top !== We2.current?.top || (Ae2.current = null, ye2?.({ left: Ue2, top: Ve2 })));
|
|
1304
1308
|
}, [Ue2, Ve2]);
|
|
1305
1309
|
const ot = o(() => ({ top: Ve2, left: Ue2 }), [Ve2, Ue2]), rt = b(() => {
|
|
1306
1310
|
const e2 = [];
|
|
1307
1311
|
let t2 = 0, n2 = 0;
|
|
1308
|
-
"number" == typeof
|
|
1312
|
+
"number" == typeof U2 ? t2 = U2 : (t2 = U2.index ?? 0, n2 = (U2.scrollOffset ?? 0) * he2);
|
|
1309
1313
|
const o2 = n2, r3 = Xe2.getRowOffset(t2), l3 = r3 - o2;
|
|
1310
1314
|
if (t2 > 0) {
|
|
1311
1315
|
const i3 = Ye2(Xe2, { top: n2 + Xe2.getRowOffset(0) }), c4 = Xe2.getRowIndex(o2), s4 = Xe2.getRowIndex(r3 - 1);
|
|
1312
1316
|
let a3;
|
|
1313
|
-
e2[1] = { minIndex: c4, maxIndex: s4, minCoord: 0, maxCoord: t2 - 1, minBounds: 0, maxBounds: l3, visibleIndices: () => a3 || (a3 = Object.freeze(
|
|
1317
|
+
e2[1] = { minIndex: c4, maxIndex: s4, minCoord: 0, maxCoord: t2 - 1, minBounds: 0, maxBounds: l3, visibleIndices: () => a3 || (a3 = Object.freeze(_(Ze, c4, s4)), a3), layout: i3, maxVirtualBounds: r3, scrollOffset: n2, freezeOffset: n2 };
|
|
1314
1318
|
}
|
|
1315
1319
|
const i2 = Math.max(0, et - l3), c3 = Ye2(Xe2, { top: Ve2 + l3 }), s3 = c3.getRowIndex(0), d3 = c3.getRowIndex(i2);
|
|
1316
1320
|
let u3;
|
|
1317
|
-
return e2[0] = { minIndex: s3, maxIndex: d3, minCoord: t2, maxCoord: a2 - 1, minBounds: l3, maxBounds: i2, visibleIndices: () => u3 || (u3 = Object.freeze(
|
|
1318
|
-
}, [Xe2.getRowIndex, Xe2.getRowOffset, Ze, et, a2,
|
|
1321
|
+
return e2[0] = { minIndex: s3, maxIndex: d3, minCoord: t2, maxCoord: a2 - 1, minBounds: l3, maxBounds: i2, visibleIndices: () => u3 || (u3 = Object.freeze(_(Ze, s3, d3)), u3), layout: c3, maxVirtualBounds: Xe2.getRowOffset(a2), scrollOffset: Ve2, freezeOffset: (t2 > 0 ? Xe2.getRowOffset(t2) : 0) - n2 }, e2;
|
|
1322
|
+
}, [Xe2.getRowIndex, Xe2.getRowOffset, Ze, et, a2, U2, Ve2, he2]), lt = b(() => {
|
|
1319
1323
|
const e2 = [];
|
|
1320
1324
|
let t2 = 0, n2 = 0;
|
|
1321
|
-
"number" == typeof
|
|
1325
|
+
"number" == typeof W2 ? t2 = W2 : (t2 = W2.index ?? 0, n2 = (W2.scrollOffset ?? 0) * he2);
|
|
1322
1326
|
const o2 = n2, r3 = Xe2.getColOffset(t2), l3 = r3 - o2;
|
|
1323
1327
|
if (t2 > 0) {
|
|
1324
1328
|
const i3 = Ye2(Xe2, { left: n2 + Xe2.getColOffset(0) }), c4 = Xe2.getColIndex(o2), s4 = Xe2.getColIndex(r3 - 1);
|
|
1325
1329
|
let a4;
|
|
1326
|
-
e2[1] = { minIndex: c4, maxIndex: s4, minCoord: 0, maxCoord: t2 - 1, minBounds: 0, maxBounds: l3, visibleIndices: () => a4 || (a4 = Object.freeze(
|
|
1330
|
+
e2[1] = { minIndex: c4, maxIndex: s4, minCoord: 0, maxCoord: t2 - 1, minBounds: 0, maxBounds: l3, visibleIndices: () => a4 || (a4 = Object.freeze(_(Je, c4, s4)), a4), layout: i3, maxVirtualBounds: r3, scrollOffset: n2, freezeOffset: n2 };
|
|
1327
1331
|
}
|
|
1328
1332
|
const i2 = Math.max(0, Qe - l3), c3 = Ye2(Xe2, { left: Ue2 + l3 }), s3 = c3.getColIndex(0), a3 = c3.getColIndex(i2);
|
|
1329
1333
|
let u3;
|
|
1330
|
-
return e2[0] = { minIndex: s3, maxIndex: a3, minCoord: t2, maxCoord: d2 - 1, minBounds: l3, maxBounds: i2, visibleIndices: () => u3 || (u3 = Object.freeze(
|
|
1331
|
-
}, [Xe2.getColIndex, Xe2.getColOffset, Je, Qe, d2,
|
|
1334
|
+
return e2[0] = { minIndex: s3, maxIndex: a3, minCoord: t2, maxCoord: d2 - 1, minBounds: l3, maxBounds: i2, visibleIndices: () => u3 || (u3 = Object.freeze(_(Je, s3, a3)), u3), layout: c3, maxVirtualBounds: Xe2.getColOffset(d2), scrollOffset: Ue2, freezeOffset: (t2 > 0 ? Xe2.getColOffset(t2) : 0) - n2 }, e2;
|
|
1335
|
+
}, [Xe2.getColIndex, Xe2.getColOffset, Je, Qe, d2, W2, Ue2, he2]), it = x({}), ct = x([]), st = b(() => {
|
|
1332
1336
|
let e2 = {};
|
|
1333
1337
|
const t2 = (t3, n3, o2, r3, l3) => {
|
|
1334
1338
|
const i2 = { vertical: r3?.vertical || false, horizontal: r3?.horizontal || false };
|
|
1335
1339
|
if (t3 >= lt.length || n3 >= rt.length) return null;
|
|
1336
1340
|
const c3 = { rowStart: rt[n3].minIndex, colStart: lt[t3].minIndex, rowEnd: rt[n3].maxIndex, colEnd: lt[t3].maxIndex };
|
|
1337
1341
|
if (c3.rowStart > c3.rowEnd || c3.colStart > c3.colEnd) return null;
|
|
1338
|
-
const s3 = { getColIndex: (e3) => lt[t3].layout.getColIndex(e3), getColOffset: (e3) => lt[t3].layout.getColOffset(e3), getRowIndex: (e3) => rt[n3].layout.getRowIndex(e3), getRowOffset: (e3) => rt[n3].layout.getRowOffset(e3) }, a3 = Object.freeze({ left: l3?.left ?? 0, top: l3?.top ?? 0, right: l3?.right ?? 0, bottom: l3?.bottom ?? 0 }), d3 = Object.freeze({ x: lt[t3].minBounds, y: rt[n3].minBounds, width: lt[t3].maxBounds, height: rt[n3].maxBounds }), u3 = (e3, t4) =>
|
|
1342
|
+
const s3 = { getColIndex: (e3) => lt[t3].layout.getColIndex(e3), getColOffset: (e3) => lt[t3].layout.getColOffset(e3), getRowIndex: (e3) => rt[n3].layout.getRowIndex(e3), getRowOffset: (e3) => rt[n3].layout.getRowOffset(e3) }, a3 = Object.freeze({ left: l3?.left ?? 0, top: l3?.top ?? 0, right: l3?.right ?? 0, bottom: l3?.bottom ?? 0 }), d3 = Object.freeze({ x: lt[t3].minBounds, y: rt[n3].minBounds, width: lt[t3].maxBounds, height: rt[n3].maxBounds }), u3 = (e3, t4) => se(s3, e3 ?? c3, t4), h3 = { width: lt[t3].maxVirtualBounds, height: rt[n3].maxVirtualBounds }, g3 = { left: lt[t3].scrollOffset, top: rt[n3].scrollOffset }, f2 = { left: lt[t3].freezeOffset, top: rt[n3].freezeOffset }, w3 = { width: Qe, height: et };
|
|
1339
1343
|
let x2 = null, p2 = null;
|
|
1340
|
-
const m2 = (f2.top + (r3.vertical ? g3.top : 0)) /
|
|
1344
|
+
const m2 = (f2.top + (r3.vertical ? g3.top : 0)) / he2, v2 = (f2.left + (r3.horizontal ? g3.left : 0)) / he2;
|
|
1341
1345
|
return { getStage: () => Ie2.current ?? null, getVisibleRangeCoords: () => c3, toClipBounds: (e3, t4) => {
|
|
1342
1346
|
let n4, o3 = 0;
|
|
1343
1347
|
return void 0 === t4 || "number" == typeof t4 ? (n4 = u3(c3), o3 = t4) : n4 = t4, ((e4, t5, n5 = 0) => {
|
|
@@ -1345,20 +1349,20 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1345
1349
|
const o4 = { left: e4.x, top: e4.y, bottom: e4.height + e4.y, right: e4.width + e4.x }, r4 = { left: t5.x + n5, top: t5.y + n5, bottom: t5.height - 2 * n5 + t5.y, right: t5.width - 2 * n5 + t5.x }, l4 = { left: Math.max(o4.left, r4.left), top: Math.max(o4.top, r4.top), bottom: Math.min(o4.bottom, r4.bottom), right: Math.min(o4.right, r4.right) }, i3 = { x: l4.left, y: l4.top, width: l4.right - l4.left, height: l4.bottom - l4.top };
|
|
1346
1350
|
return i3.height < 0 || i3.width < 0 ? null : i3;
|
|
1347
1351
|
})(e3 ?? { x: 0, y: 0, width: d3.width, height: d3.height }, n4, o3);
|
|
1348
|
-
}, toViewBounds: (e3) => 0 === v2 && 0 === m2 && 1 ===
|
|
1352
|
+
}, toViewBounds: (e3) => 0 === v2 && 0 === m2 && 1 === he2 ? e3 : { x: (e3.x - v2) * he2, y: (e3.y - m2) * he2, width: e3.width * he2, height: e3.height * he2 }, toAbsoluteBounds: (e3) => 0 === v2 && 0 === m2 && 1 === he2 ? e3 : { x: e3.x / he2 + v2, y: e3.y / he2 + m2, width: e3.width / he2, height: e3.height / he2 }, getRelativePointFromClient: (e3, t4) => {
|
|
1349
1353
|
const n4 = ft(e3, t4);
|
|
1350
1354
|
return { x: n4.x - d3.x, y: n4.y - d3.y };
|
|
1351
|
-
}, getLayout: () => s3, getCellCoordsAsRangeCoords: we2, getVisibleColumns: () => lt[t3].visibleIndices(), getVisibleRows: () => rt[n3].visibleIndices(), getVisibleColumnOffsets: () => (x2 || (x2 =
|
|
1355
|
+
}, getLayout: () => s3, getCellCoordsAsRangeCoords: we2, getVisibleColumns: () => lt[t3].visibleIndices(), getVisibleRows: () => rt[n3].visibleIndices(), getVisibleColumnOffsets: () => (x2 || (x2 = ce(lt[t3].layout, true, lt[t3].visibleIndices(), c3.colStart, c3.colEnd)), x2), getVisibleRowOffsets: () => (p2 || (p2 = ce(rt[n3].layout, false, rt[n3].visibleIndices(), c3.rowStart, c3.rowEnd)), p2), getTotalRangeCoords: () => ({ colStart: lt[t3].minCoord, colEnd: lt[t3].maxCoord, rowStart: rt[n3].minCoord, rowEnd: rt[n3].maxCoord }), getRangeCoordsBounds: u3, scrollCellCoordsIntoView: (e3, t4) => It(e3, t4, o2), getCellCoordsFromClient: (e3, t4, n4 = false) => {
|
|
1352
1356
|
const o3 = ft(e3, t4);
|
|
1353
1357
|
if (!o3) return null;
|
|
1354
1358
|
const r4 = s3.getColIndex(o3.x - d3.x), l4 = { rowIndex: s3.getRowIndex(o3.y - d3.y), colIndex: r4 };
|
|
1355
1359
|
if (n4) return l4;
|
|
1356
1360
|
const i3 = we2(l4);
|
|
1357
1361
|
return { rowIndex: i3.rowStart, colIndex: i3.colStart };
|
|
1358
|
-
}, getZoom: () =>
|
|
1362
|
+
}, getZoom: () => he2, getAnchor: () => o2, getBounds: () => d3, getInsets: () => a3, getTotalSize: () => h3, getViewportSize: () => w3, getScrollTopLeft: () => g3, getFreezeTopLeft: () => f2, getScrollOrientation: () => i2, allViews: () => e2 };
|
|
1359
1363
|
};
|
|
1360
|
-
let n2 = e2[
|
|
1361
|
-
return n2 && (e2[
|
|
1364
|
+
let n2 = e2[O.Center] = t2(0, 0, O.Center, Pe, ke);
|
|
1365
|
+
return n2 && (e2[O.Center] = n2), n2 = t2(0, 1, O.Top, { horizontal: true }), n2 && (e2[O.Top] = n2), n2 = t2(1, 0, O.Left, { vertical: true }), n2 && (e2[O.Left] = n2), n2 = t2(1, 1, O.TopLeft, {}), n2 && (e2[O.TopLeft] = n2), it.current = null, e2 = Object.freeze(e2);
|
|
1362
1366
|
}, [rt, lt, we2]), at = Object.keys(st), dt = lt[0]?.maxVirtualBounds ?? 0, ut = rt[0]?.maxVirtualBounds ?? 0, ht = b(() => ({ left: lt[1] ? lt[1].layout.getColOffset(lt[1].maxIndex + 1) : 0, top: rt[1] ? rt[1].layout.getRowOffset(rt[1].maxIndex + 1) : 0 }), [st]);
|
|
1363
1367
|
v(() => {
|
|
1364
1368
|
if (ct.current.length > 0) {
|
|
@@ -1368,71 +1372,71 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1368
1372
|
}, [st]);
|
|
1369
1373
|
const gt = o(() => ({ containerWidth: Qe, containerHeight: et, totalWidth: dt, totalHeight: ut }), [Qe, et, Xe2]);
|
|
1370
1374
|
v(() => {
|
|
1371
|
-
!
|
|
1375
|
+
!Ae2.current && Ne2.current && Se2({ top: Ve2, left: Ue2, width: Qe, height: et, totalWidth: dt, totalHeight: ut });
|
|
1372
1376
|
}, [Ve2, Ue2, dt, ut]), v(() => {
|
|
1373
1377
|
Ne2.current && Se2({ top: Ve2, left: Ue2, width: Qe, height: et, totalWidth: dt, totalHeight: ut });
|
|
1374
1378
|
}, [Qe, et]);
|
|
1375
1379
|
const ft = S((e2, t2) => {
|
|
1376
|
-
|
|
1380
|
+
R("number" == typeof e2 && "number" == typeof t2, "Top and left should be a number.");
|
|
1377
1381
|
const n2 = Ie2.current?.getBoundingClientRect();
|
|
1378
1382
|
return n2 ? { x: e2 - n2.x, y: t2 - n2.y } : { x: e2, y: t2 };
|
|
1379
1383
|
}, []), wt = o((e2) => st[e2] || null, [st]), xt = o((e2, t2) => {
|
|
1380
|
-
if (1 === Object.keys(st).length) return st[
|
|
1384
|
+
if (1 === Object.keys(st).length) return st[O.Center];
|
|
1381
1385
|
const n2 = ft(e2, t2);
|
|
1382
1386
|
if (!n2) return null;
|
|
1383
1387
|
const { x: o2, y: r3 } = n2;
|
|
1384
1388
|
let l3 = null;
|
|
1385
|
-
const i2 =
|
|
1389
|
+
const i2 = Te, c3 = i2.length;
|
|
1386
1390
|
for (let e3 = 0; !l3 && e3 < c3; e3++) {
|
|
1387
1391
|
const t3 = st[i2[e3]];
|
|
1388
|
-
t3 &&
|
|
1392
|
+
t3 && ae(o2, r3, t3.getBounds()) && (l3 = t3);
|
|
1389
1393
|
}
|
|
1390
|
-
return l3 || (l3 = st[
|
|
1391
|
-
}, [st, we2]), pt = o(() => st[
|
|
1392
|
-
null !== mt.current &&
|
|
1394
|
+
return l3 || (l3 = st[O.Center]), l3;
|
|
1395
|
+
}, [st, we2]), pt = o(() => st[O.Center].getVisibleRangeCoords(), [st[O.Center]]), mt = x(null), vt = S(() => {
|
|
1396
|
+
null !== mt.current && P.cancelTimeout(mt.current), mt.current = P.requestTimeout(St, 150);
|
|
1393
1397
|
}, []), St = S(() => {
|
|
1394
1398
|
mt.current = null, Fe2((e2) => {
|
|
1395
1399
|
const t2 = { ...e2, verticalScrollDirection: null, horizontalScrollDirection: null };
|
|
1396
|
-
return
|
|
1400
|
+
return We2.current = t2, t2;
|
|
1397
1401
|
});
|
|
1398
1402
|
}, []), yt = o((e2) => {
|
|
1399
1403
|
const t2 = e2?.left ?? e2?.[0], n2 = e2?.top ?? e2?.[1];
|
|
1400
|
-
let o2 =
|
|
1404
|
+
let o2 = We2.current.left;
|
|
1401
1405
|
void 0 !== t2 && t2 !== o2 && (t2 > o2 ? (o2 = Math.max(lt?.[1]?.scrollOffset ?? 0, t2), o2 = Math.min(dt - Qe, o2)) : o2 = Math.max(lt?.[1]?.scrollOffset ?? 0, t2));
|
|
1402
|
-
let r3 =
|
|
1403
|
-
if (void 0 !== n2 && n2 !== r3 && (n2 > r3 ? (r3 = Math.max(rt?.[1]?.scrollOffset ?? 0, n2), r3 = Math.min(ut - et, r3)) : r3 = Math.max(rt?.[1]?.scrollOffset ?? 0, n2)),
|
|
1406
|
+
let r3 = We2.current.top;
|
|
1407
|
+
if (void 0 !== n2 && n2 !== r3 && (n2 > r3 ? (r3 = Math.max(rt?.[1]?.scrollOffset ?? 0, n2), r3 = Math.min(ut - et, r3)) : r3 = Math.max(rt?.[1]?.scrollOffset ?? 0, n2)), We2.current.left === o2 && We2.current.top === r3) return;
|
|
1404
1408
|
let l3 = null, i2 = null;
|
|
1405
|
-
|
|
1409
|
+
We2.current.left > o2 ? l3 = D.Left : We2.current.left < o2 && (l3 = D.Right), We2.current.top > r3 ? i2 = D.Up : We2.current.top < r3 && (i2 = D.Down), P.throttle(() => {
|
|
1406
1410
|
Fe2((e3) => {
|
|
1407
1411
|
const t3 = { ...e3, left: o2, top: r3, horizontalScrollDirection: l3, verticalScrollDirection: i2 };
|
|
1408
|
-
return
|
|
1412
|
+
return We2.current = t3, t3;
|
|
1409
1413
|
});
|
|
1410
|
-
}, 17)(),
|
|
1414
|
+
}, 17)(), Ae2.current?.top === r3 && Ae2.current?.left === o2 || (Ae2.current = { left: o2, top: r3 }, ve2({ left: o2, top: r3 }), Se2({ left: o2, top: r3, width: Qe, height: et, totalWidth: dt, totalHeight: ut })), vt();
|
|
1411
1415
|
}, [dt, ut, rt, lt]);
|
|
1412
1416
|
v(() => {
|
|
1413
|
-
|
|
1417
|
+
Ae2.current || yt({ left: Ue2, top: Ve2 });
|
|
1414
1418
|
}, [Qe, et]), v(() => {
|
|
1415
1419
|
let e2, t2, n2 = false;
|
|
1416
|
-
|
|
1420
|
+
We2.current.left > dt && (e2 = 0, n2 = true), We2.current.top > ut && (t2 = 0, n2 = true), n2 && yt({ left: e2, top: t2 });
|
|
1417
1421
|
}, [dt, ut]), y(() => {
|
|
1418
|
-
|
|
1422
|
+
Ae2.current = { left: xe2?.left, top: xe2?.top }, yt(Ae2.current);
|
|
1419
1423
|
}, [xe2?.left, xe2?.top]);
|
|
1420
1424
|
const bt = o((e2) => {
|
|
1421
1425
|
let t2 = e2?.left ?? e2?.[0], n2 = e2?.top ?? e2?.[1];
|
|
1422
1426
|
if (void 0 === t2 && void 0 === n2) return;
|
|
1423
1427
|
const o2 = e2?.behavior ?? "auto";
|
|
1424
|
-
if (void 0 !== t2 && (t2 =
|
|
1428
|
+
if (void 0 !== t2 && (t2 = We2.current.left + (t2 ?? 0)), void 0 !== n2 && (n2 = We2.current.top + (n2 ?? 0)), We2.current.left === t2 && We2.current.top === n2) return;
|
|
1425
1429
|
yt({ left: t2, top: n2, behavior: o2 });
|
|
1426
1430
|
}, []), Ct = S((e2) => {
|
|
1427
1431
|
let t2 = null;
|
|
1428
1432
|
if (Object.keys(st).length > 1) {
|
|
1429
|
-
const n2 =
|
|
1433
|
+
const n2 = Te, o2 = n2.length;
|
|
1430
1434
|
for (let r3 = 0; !t2 && r3 < o2; r3++) {
|
|
1431
1435
|
const o3 = st[n2[r3]];
|
|
1432
|
-
o3 &&
|
|
1436
|
+
o3 && k.isCellWithinRange(e2, o3.getVisibleRangeCoords()) && (t2 = o3);
|
|
1433
1437
|
}
|
|
1434
1438
|
}
|
|
1435
|
-
return t2 || (t2 = st[
|
|
1439
|
+
return t2 || (t2 = st[O.Center]), t2;
|
|
1436
1440
|
}, [st]), It = o((e2, t2 = { inline: "nearest", block: "nearest" }, n2 = null) => {
|
|
1437
1441
|
const o2 = { rowIndex: 0, colIndex: 0, ...e2 };
|
|
1438
1442
|
let r3 = null;
|
|
@@ -1443,7 +1447,7 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1443
1447
|
} else r3 = Ct(o2);
|
|
1444
1448
|
const l3 = we2(o2), i2 = r3.getLayout(), c3 = i2.getColOffset(l3.colStart), s3 = i2.getRowOffset(l3.rowStart), a3 = i2.getColOffset(l3.colEnd + 1), d3 = i2.getRowOffset(l3.rowEnd + 1), u3 = r3.getBounds(), h3 = r3.getTotalSize(), g3 = r3.getScrollTopLeft(), f2 = ((e3, t3, n3 = true) => {
|
|
1445
1449
|
n3 = true === n3 ? { block: "start", inline: "end" } : false === n3 ? { block: "end", inline: "end" } : { block: "end", inline: "end", ...n3 };
|
|
1446
|
-
const o3 =
|
|
1450
|
+
const o3 = ne(n3.inline, e3.x, e3.x + e3.width, t3.left, t3.left + t3.width, t3.totalWidth), r4 = ne(n3.block, e3.y, e3.y + e3.height, t3.top, t3.top + t3.height, t3.totalHeight);
|
|
1447
1451
|
if (void 0 !== o3 || void 0 !== r4) return { left: o3, top: r4 };
|
|
1448
1452
|
})({ x: c3 + g3.left, y: s3 + g3.top, width: a3 - c3, height: d3 - s3 }, { left: g3.left, top: g3.top, width: u3.width, height: u3.height, totalWidth: h3.width, totalHeight: h3.height }, t2);
|
|
1449
1453
|
if (!f2) return Promise.resolve({ ...g3 });
|
|
@@ -1461,13 +1465,13 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1461
1465
|
const t2 = e2.shiftKey;
|
|
1462
1466
|
e2.preventDefault();
|
|
1463
1467
|
const { deltaX: n2, deltaY: o2, deltaMode: r3 } = e2;
|
|
1464
|
-
if (
|
|
1468
|
+
if (De2.current) return;
|
|
1465
1469
|
let l3 = be2?.(e2);
|
|
1466
1470
|
if (false === l3) return;
|
|
1467
1471
|
let i2 = t2 ? o2 : n2, c3 = o2;
|
|
1468
1472
|
const s3 = t2 || Math.abs(i2) > Math.abs(c3);
|
|
1469
|
-
1 === r3 && (c3 *= 0),
|
|
1470
|
-
|
|
1473
|
+
1 === r3 && (c3 *= 0), De2.current = window.requestAnimationFrame(() => {
|
|
1474
|
+
De2.current = null, bt(s3 ? { left: i2 } : { top: c3 });
|
|
1471
1475
|
});
|
|
1472
1476
|
}, [be2]), Rt = S((e2 = null) => {
|
|
1473
1477
|
je2.current = null, it.current = null, $e2();
|
|
@@ -1478,14 +1482,14 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1478
1482
|
const Mt = f(l2, () => ({ stage: Ie2.current, focus: tt, contains: nt, invalidate: Rt, scrollTo: yt, scrollBy: bt, scrollCellCoordsIntoView: It, getScrollPosition: ot, getDimensions: gt, getViewport: pt, handleWheel: Et, rowCount: a2, columnCount: d2, getLayout: () => Xe2, getRelativePointFromClient: ft, getViewFromClient: xt, getViewFromCellCoords: Ct, getViewFromLocation: wt, onViewChangeOnce: (e2) => {
|
|
1479
1483
|
ct.current.push(e2);
|
|
1480
1484
|
} }), [a2, d2, st]);
|
|
1481
|
-
v(() => (ge2 && Mt.current?.addEventListener("wheel", Et, { passive: false }), Ne2.current = true,
|
|
1485
|
+
v(() => (ge2 && Mt.current?.addEventListener("wheel", Et, { passive: false }), Ne2.current = true, Ae2.current = null, () => {
|
|
1482
1486
|
Mt.current?.removeEventListener("wheel", Et);
|
|
1483
1487
|
}), [ge2]);
|
|
1484
1488
|
const kt = x([]), Pt = (t2, n2) => {
|
|
1485
1489
|
if (!t2 || !X2) return;
|
|
1486
1490
|
kt.current = [];
|
|
1487
1491
|
n2.push(((t3, o2) => {
|
|
1488
|
-
const r3 = `view:${t3.getAnchor()}:overlay:${n2.length}`, l3 = X2
|
|
1492
|
+
const r3 = `view:${t3.getAnchor()}:overlay:${n2.length}`, l3 = X2({ key: r3, view: t3, ref: (e2) => kt.current[o2] = e2 });
|
|
1489
1493
|
if (!l3) return null;
|
|
1490
1494
|
const i2 = t3.getBounds();
|
|
1491
1495
|
return e("div", { style: { position: "absolute", left: "0px", top: "0px", width: `${i2.width}px`, height: `${i2.height}px`, overflow: "hidden" }, children: l3 }, `overlay-${t3.getAnchor()}-${o2}`);
|
|
@@ -1497,12 +1501,12 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1497
1501
|
Pt(st[n3], r3), e2[n3] = { overlays: r3 };
|
|
1498
1502
|
}
|
|
1499
1503
|
return e2;
|
|
1500
|
-
}, [
|
|
1504
|
+
}, [Le2, X2, a2, d2, rt, lt]), Dt = (t2, n2, o2, r3, l3, c3, s3) => {
|
|
1501
1505
|
if (!t2) return;
|
|
1502
1506
|
const a3 = t2.getVisibleColumns(), d3 = t2.getVisibleRows();
|
|
1503
1507
|
if (0 === a3.length || 0 === d3.length) return;
|
|
1504
1508
|
let u3 = null;
|
|
1505
|
-
if (
|
|
1509
|
+
if (de2) u3 = de2(t2);
|
|
1506
1510
|
else {
|
|
1507
1511
|
u3 = [];
|
|
1508
1512
|
const e2 = d3.length, t3 = a3.length;
|
|
@@ -1516,15 +1520,15 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1516
1520
|
}
|
|
1517
1521
|
}
|
|
1518
1522
|
}
|
|
1519
|
-
const h3 = t2.getVisibleColumnOffsets(), g3 = t2.getVisibleRowOffsets(), f2 = t2.getScrollTopLeft(), w3 = t2.getFreezeTopLeft(), x2 = f2.left + w3.left, p2 = f2.top + w3.top, m2 = Math.trunc(x2 /
|
|
1520
|
-
const l4 = `view:${e2.getAnchor()}:cell:${
|
|
1523
|
+
const h3 = t2.getVisibleColumnOffsets(), g3 = t2.getVisibleRowOffsets(), f2 = t2.getScrollTopLeft(), w3 = t2.getFreezeTopLeft(), x2 = f2.left + w3.left, p2 = f2.top + w3.top, m2 = Math.trunc(x2 / Oe), v2 = Math.trunc(p2 / Oe), S2 = {}, y2 = (e2, t3, n3, o3, r4) => {
|
|
1524
|
+
const l4 = `view:${e2.getAnchor()}:cell:${te(t3.rowIndex, t3.colIndex)}`, a4 = o3.x, d4 = o3.y, u4 = Math.trunc((x2 + a4) / Oe) - m2, h4 = Math.trunc((p2 + d4) / Oe) - v2;
|
|
1521
1525
|
S2[h4] || (S2[h4] = {});
|
|
1522
1526
|
let g4 = S2[h4][u4];
|
|
1523
1527
|
g4 || (g4 = S2[h4][u4] = []);
|
|
1524
1528
|
let f3 = c3?.get(l4);
|
|
1525
1529
|
if (!f3) {
|
|
1526
|
-
const c4 = (x2 + a4) %
|
|
1527
|
-
f3 = N2({ key: l4, coords: t3, bounds: o3, zoom:
|
|
1530
|
+
const c4 = (x2 + a4) % Oe, s4 = (p2 + d4) % Oe;
|
|
1531
|
+
f3 = N2({ key: l4, coords: t3, bounds: o3, zoom: he2, range: n3, view: e2, value: r4, style: { left: i.boundPixel(c4), top: i.boundPixel(s4), width: i.boundPixel(o3.width, true), height: i.boundPixel(o3.height, true) } });
|
|
1528
1532
|
}
|
|
1529
1533
|
s3?.set(l4, f3), g4.push(f3);
|
|
1530
1534
|
}, b2 = u3.length;
|
|
@@ -1532,26 +1536,26 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1532
1536
|
const n3 = u3[e2], i2 = n3?.coords ?? n3;
|
|
1533
1537
|
if (!i2) continue;
|
|
1534
1538
|
const c4 = n3?.range ?? { rowStart: i2.rowIndex, colStart: i2.colIndex, rowEnd: i2.rowIndex, colEnd: i2.colIndex }, s4 = t2.getVisibleRangeCoords();
|
|
1535
|
-
if (!
|
|
1536
|
-
const a4 = c4 && !
|
|
1539
|
+
if (!k.isRangesIntersect(c4, s4) && !k.isRangeWithinRange(c4, s4)) continue;
|
|
1540
|
+
const a4 = c4 && !k.isSingleCell(c4);
|
|
1537
1541
|
if (!a4 && le2?.(i2)) continue;
|
|
1538
1542
|
const d4 = i2.rowIndex, f3 = i2.colIndex, w4 = g3[d4], x3 = h3[f3];
|
|
1539
1543
|
let p3 = null;
|
|
1540
1544
|
w4 && x3 && (p3 = { x: x3.offset, y: w4.offset, width: x3.size, height: w4.size });
|
|
1541
|
-
const m3 =
|
|
1545
|
+
const m3 = te(c4.rowStart, c4.colStart);
|
|
1542
1546
|
if (a4) {
|
|
1543
1547
|
if (l3.has(m3)) continue;
|
|
1544
1548
|
l3.add(m3), c4.rowEnd - c4.rowStart > 0 && o2.push(c4), c4.colEnd - c4.colStart > 0 && r3.push(c4);
|
|
1545
1549
|
}
|
|
1546
|
-
if (a4 && (p3 =
|
|
1550
|
+
if (a4 && (p3 = se(t2.getLayout(), c4)), !p3) {
|
|
1547
1551
|
console.warn("no bounds for cell", m3);
|
|
1548
1552
|
continue;
|
|
1549
1553
|
}
|
|
1550
1554
|
const v3 = n3?.value;
|
|
1551
1555
|
y2(t2, i2, c4, p3, v3);
|
|
1552
1556
|
}
|
|
1553
|
-
const C3 = x2 %
|
|
1554
|
-
for (let o3 = 0; o3 <
|
|
1557
|
+
const C3 = x2 % Oe, I3 = p2 % Oe, E2 = Object.keys(S2), R2 = E2.length;
|
|
1558
|
+
for (let o3 = 0; o3 < R2; o3++) {
|
|
1555
1559
|
const r4 = E2[o3], l4 = S2[r4];
|
|
1556
1560
|
if (!l4) continue;
|
|
1557
1561
|
const c4 = Object.keys(l4), s4 = c4.length;
|
|
@@ -1559,7 +1563,7 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1559
1563
|
const s5 = c4[o4], a4 = l4[s5];
|
|
1560
1564
|
if (!a4) continue;
|
|
1561
1565
|
const d4 = parseInt(r4), u4 = parseInt(s5), h4 = d4 + v2, g4 = u4 + m2, f3 = `view:${t2.getAnchor()}:segment:${g4}:${h4}`;
|
|
1562
|
-
n2.push(e("div", { className: "cell-container", style: { transform: `translate(${i.boundPixel(u4 *
|
|
1566
|
+
n2.push(e("div", { className: "cell-container", style: { transform: `translate(${i.boundPixel(u4 * Oe - C3, true)}px, ${i.boundPixel(d4 * Oe - I3, true)}px)`, willChange: "transform" }, children: a4 }, f3));
|
|
1563
1567
|
}
|
|
1564
1568
|
}
|
|
1565
1569
|
}, Ot = b(() => {
|
|
@@ -1569,13 +1573,13 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1569
1573
|
Dt(st[r4], s3, i2, c3, /* @__PURE__ */ new Set(), e2, t2), n2[r4] = { cells: s3, rangesH: i2, rangesV: c3 };
|
|
1570
1574
|
}
|
|
1571
1575
|
return je2.current = t2, n2;
|
|
1572
|
-
}, [
|
|
1576
|
+
}, [Le2, a2, d2, rt, lt, z2, pe2, F2, le2, de2, re2, oe2, we2]), zt = (t2, n2, o2, r3, l3) => {
|
|
1573
1577
|
if (!t2) return;
|
|
1574
1578
|
const c3 = t2.getLayout(), s3 = window.devicePixelRatio || 1, a3 = String(1 / s3);
|
|
1575
1579
|
if (n2) {
|
|
1576
1580
|
const e2 = `view:${t2.getAnchor()}:hl:`, n3 = t2.getVisibleRows();
|
|
1577
1581
|
if (0 === (n3 ? n3.length : 0)) return;
|
|
1578
|
-
const s4 = l3.sort(
|
|
1582
|
+
const s4 = l3.sort(k.rowFirstRangeComparator), d3 = t2.getVisibleRangeCoords(), u3 = 0, h3 = Math.min(t2.getBounds().width, c3.getColOffset(d3.colEnd + 1));
|
|
1579
1583
|
let g3 = [];
|
|
1580
1584
|
for (let t3 = 0; t3 < n3.length && n3[t3] <= d3.rowEnd; t3++) {
|
|
1581
1585
|
const l4 = n3[t3];
|
|
@@ -1585,7 +1589,7 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1585
1589
|
const e3 = s4.shift();
|
|
1586
1590
|
e3.rowEnd > l4 && (g3.push(e3), f2 = true);
|
|
1587
1591
|
}
|
|
1588
|
-
f2 && (g3 = g3.sort(
|
|
1592
|
+
f2 && (g3 = g3.sort(k.columnFirstRangeComparator));
|
|
1589
1593
|
const w3 = c3.getRowOffset(l4 + 1);
|
|
1590
1594
|
let x2 = u3;
|
|
1591
1595
|
const p2 = g3.length;
|
|
@@ -1599,7 +1603,7 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1599
1603
|
} else {
|
|
1600
1604
|
const n3 = `view:${t2.getAnchor()}:vl:`, s4 = t2.getVisibleColumns(), d3 = s4 ? s4.length : 0;
|
|
1601
1605
|
if (0 === d3) return;
|
|
1602
|
-
const u3 = l3.sort(
|
|
1606
|
+
const u3 = l3.sort(k.columnFirstRangeComparator), h3 = t2.getVisibleRangeCoords(), g3 = 0, f2 = Math.min(t2.getBounds().height, c3.getRowOffset(h3.rowEnd + 1));
|
|
1603
1607
|
let w3 = [];
|
|
1604
1608
|
for (let t3 = 0; t3 < d3 && s4[t3] <= h3.colEnd; t3++) {
|
|
1605
1609
|
const l4 = s4[t3];
|
|
@@ -1609,7 +1613,7 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1609
1613
|
const e2 = u3.shift();
|
|
1610
1614
|
e2.colEnd > l4 && (w3.push(e2), d4 = true);
|
|
1611
1615
|
}
|
|
1612
|
-
d4 && (w3 = w3.sort(
|
|
1616
|
+
d4 && (w3 = w3.sort(k.rowFirstRangeComparator));
|
|
1613
1617
|
const x2 = c3.getColOffset(l4 + 1);
|
|
1614
1618
|
let p2 = g3;
|
|
1615
1619
|
const m2 = w3.length;
|
|
@@ -1631,7 +1635,7 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1631
1635
|
n2[o3] = e("svg", { width: `${s3}`, height: `${a3}`, viewBox: `0 0 ${s3} ${a3}`, preserveAspectRatio: "none", shapeRendering: "crispEdges", style: { position: "absolute" }, children: i2 });
|
|
1632
1636
|
}
|
|
1633
1637
|
return n2;
|
|
1634
|
-
}, $t = b(() => true ===
|
|
1638
|
+
}, $t = b(() => true === z2 || true === z2?.horizontal ? Lt(true) : null, [Le2, z2, rt, U2, W2, L2, $2, a2, d2, Qe, dt, st, Ot]), Bt = b(() => true === z2 || true === z2?.vertical ? Lt(false) : null, [Le2, z2, lt, U2, W2, L2, B2, a2, d2, et, ut, st, Ot]), Ft = b(() => 0 === ht.left ? null : e(ue, { linePoints: [0, 0, 0, et + 1], bounds: { x: ht.left, y: 0, width: 1, height: et + 1 }, ...H2 }), [Le2, ht.left, et, H2]), At = b(() => 0 === ht.top ? null : e(ue, { linePoints: [0, 0, Qe + 1, 0], bounds: { x: 0, y: ht.top, width: Qe + 1, height: 1 }, ...K2 }), [Le2, ht.top, Qe, K2]), Wt = b(() => {
|
|
1635
1639
|
const o2 = [], r3 = (e2) => {
|
|
1636
1640
|
if (!e2 || !st[e2]) return;
|
|
1637
1641
|
const n2 = st[e2].getBounds();
|
|
@@ -1647,72 +1651,72 @@ const ve = -10, Se = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
1647
1651
|
for (let i3 = 0; i3 < l3; i3++) {
|
|
1648
1652
|
const l4 = o3[i3];
|
|
1649
1653
|
let c4 = e3?.get(l4);
|
|
1650
|
-
c4 !==
|
|
1654
|
+
c4 !== ze && (c4 = l4(n3) ?? ze), t2.set(l4, c4), c4 && c4 !== ze && r4.push(c4);
|
|
1651
1655
|
}
|
|
1652
1656
|
return r4;
|
|
1653
1657
|
}, n2 = (n3, o3, r4) => {
|
|
1654
1658
|
if (!r4) return;
|
|
1655
1659
|
const l3 = r4.getBounds(), i3 = r4.getInsets(), c4 = r4.getAnchor();
|
|
1656
|
-
return t("div", { className:
|
|
1660
|
+
return t("div", { className: M("view", `view-${c4}`, Re.view), style: { position: "absolute", pointerEvents: "none", left: l3.x - i3.left, top: l3.y - i3.top, width: l3.width - (i3.left + i3.right), height: l3.height - (i3.top + i3.bottom), clipPath: J2 ? "inset(-2px)" : "inset(0px)" }, children: [e2(n3, o3, r4, G2), Tt?.[c4].overlays] }, `view:${c4}`);
|
|
1657
1661
|
}, o2 = it.current, r3 = {}, i2 = [], c3 = Object.keys(st), s3 = c3.length;
|
|
1658
1662
|
for (let e3 = 0; e3 < s3; e3++) {
|
|
1659
1663
|
const t2 = c3[e3], l3 = o2?.[t2], s4 = r3[t2] = /* @__PURE__ */ new Map();
|
|
1660
1664
|
i2.push(n2(l3, s4, st[t2]));
|
|
1661
1665
|
}
|
|
1662
1666
|
return it.current = r3, i2;
|
|
1663
|
-
}, [
|
|
1664
|
-
const { style: t2, ...n2 } = Q2 ??
|
|
1665
|
-
return e("div", { style: { width: Qe, height: et, ...t2 }, className: "sheetxl-stage", tabIndex: 0, ref: Ie2, ...n2, ...me2, children: ee2 ? ee2(
|
|
1666
|
-
}, [Qe, et,
|
|
1667
|
+
}, [Le2, st, J2, G2]), Ut = b(() => {
|
|
1668
|
+
const { style: t2, ...n2 } = Q2 ?? P.EmptyObject;
|
|
1669
|
+
return e("div", { style: { width: Qe, height: et, ...t2 }, className: "sheetxl-stage", tabIndex: 0, ref: Ie2, ...n2, ...me2, children: ee2 ? ee2(Wt) : Wt });
|
|
1670
|
+
}, [Qe, et, Wt, Q2, ee2]), Ht = x(false);
|
|
1667
1671
|
return v(() => {
|
|
1668
1672
|
!Ht.current && Ot && (Ht.current = true, Ce2?.(Mt.current));
|
|
1669
|
-
}, [Ot]), t("div", { className:
|
|
1673
|
+
}, [Ot]), t("div", { className: M("sheetxl-grid", Re["sheetxl-grid"]), style: { overflow: "visible", cursor: A2, maxWidth: Qe, maxHeight: et, width: Qe, height: et, ...pe2 }, ref: Mt, children: [Ut, t("div", { className: M("sheetxl-overlays"), ref: Ee2, ...Z2, children: [Vt, Ft, At] })] });
|
|
1670
1674
|
}));
|
|
1671
|
-
|
|
1672
|
-
const
|
|
1673
|
-
const { width: o2, height: r2, style: l2 = {}, className: i2, ...c2 } = t2, [s2, { width: a2, height: d2 }] =
|
|
1674
|
-
return e("div", { className: i2, style: { ...l2 }, children: e("div", { style: { position: "relative", top: "0px", left: "0px", width: "100%", height: "100%", maxWidth: "100%", maxHeight: "100%", boxSizing: "content-box" }, ref: s2, children: e(
|
|
1675
|
+
Le.displayName = "BaseGrid";
|
|
1676
|
+
const $e = C(I((t2, n2) => {
|
|
1677
|
+
const { width: o2, height: r2, style: l2 = {}, className: i2, ...c2 } = t2, [s2, { width: a2, height: d2 }] = z();
|
|
1678
|
+
return e("div", { className: i2, style: { ...l2 }, children: e("div", { style: { position: "relative", top: "0px", left: "0px", width: "100%", height: "100%", maxWidth: "100%", maxHeight: "100%", boxSizing: "content-box" }, ref: s2, children: e(Le, { ref: n2, width: o2 ?? a2, height: r2 ?? d2, ...c2 }) }) });
|
|
1675
1679
|
}));
|
|
1676
|
-
|
|
1677
|
-
const
|
|
1678
|
-
const { showVerticalScrollbar: o2, showHorizontalScrollbar: r2,
|
|
1679
|
-
|
|
1680
|
-
const b2 = S((e2) => {
|
|
1680
|
+
$e.displayName = "Grid";
|
|
1681
|
+
const Be = C(I((t2, n2) => {
|
|
1682
|
+
const { showVerticalScrollbar: o2, showHorizontalScrollbar: r2, renderScrollbarHorizontal: l2, renderScrollbarVertical: i2, createScrollCorner: c2, viewport: s2, onScrollViewport: a2, style: d2 = {}, className: u2, onScroll: h2, ...g2 } = t2, [f2, p2] = m(null), v2 = x(null), y2 = x(null);
|
|
1683
|
+
R(!s2, "Viewport can not be specified");
|
|
1684
|
+
const b2 = L([y2, n2]), C2 = S((e2) => {
|
|
1681
1685
|
y2.current?.scrollTo(e2), a2?.(e2);
|
|
1682
1686
|
}, []);
|
|
1683
|
-
return e(w, { className: u2, style: d2, ref: v2, showVerticalScrollbar: o2, showHorizontalScrollbar: r2,
|
|
1687
|
+
return e(w, { className: u2, style: d2, ref: v2, showVerticalScrollbar: o2, showHorizontalScrollbar: r2, renderScrollbarHorizontal: l2, renderScrollbarVertical: i2, createScrollCorner: c2, viewport: f2, onScrollViewport: C2, children: e($e, { style: { width: "100%", height: "100%" }, ...g2, onViewportChange: (e2) => p2(e2), ref: b2 }) });
|
|
1684
1688
|
}));
|
|
1685
|
-
|
|
1686
|
-
const
|
|
1687
|
-
const { index: n2, value: o2, zoom: r2, zoomScale: l2 = 100, headerText: c2 = (e2) => `${e2}`, headerStyle: s2, headerStyleSelect: a2 = s2, headerStyleSelectAll: d2 = a2, headerStyleHover: u2 = d2, verticalPadding: h2 = 0, horizontalPadding: g2 = 0, isSelected: f2 =
|
|
1689
|
+
Be.displayName = "ScrollableGrid";
|
|
1690
|
+
const Fe = () => false, Ae = C((t2) => {
|
|
1691
|
+
const { index: n2, value: o2, zoom: r2, zoomScale: l2 = 100, headerText: c2 = (e2) => `${e2}`, headerStyle: s2, headerStyleSelect: a2 = s2, headerStyleSelectAll: d2 = a2, headerStyleHover: u2 = d2, verticalPadding: h2 = 0, horizontalPadding: g2 = 0, isSelected: f2 = Fe, isSelectedAll: w2 = Fe, coords: p2, bounds: v2, range: S2, orientation: y2, view: b2, style: C2, ...I2 } = t2, E2 = l2 / 100, R2 = x(null), [M2, k2] = m(false), D2 = f2?.(n2) || false, O2 = w2?.(n2) || false ? d2 : D2 ? a2 : s2;
|
|
1688
1692
|
let z2 = O2;
|
|
1689
1693
|
if (M2) {
|
|
1690
1694
|
let e2 = u2;
|
|
1691
|
-
"function" == typeof u2 && (e2 = u2(O2)), z2 =
|
|
1695
|
+
"function" == typeof u2 && (e2 = u2(O2)), z2 = P.mergeContentful(O2, e2);
|
|
1692
1696
|
}
|
|
1693
|
-
return e("div", { ref: R2, style: { background: z2.fill, color: z2.text?.fill, fontFamily: z2.text?.fontFamily ?? s2.text?.fontFamily, fontSize: 96 * (z2.text?.fontSize ?? 11) / 72 * E2, fontStyle: z2.text?.fontStyle, fontWeight: z2.text?.fontWeight, lineHeight: 1.2, display: "flex", justifyContent: "center", alignItems: "end", pointerEvents: "auto", paddingBottom: `${E2}px`, ...C2, left: C2.left - (y2 ===
|
|
1697
|
+
return e("div", { ref: R2, style: { background: z2.fill, color: z2.text?.fill, fontFamily: z2.text?.fontFamily ?? s2.text?.fontFamily, fontSize: 96 * (z2.text?.fontSize ?? 11) / 72 * E2, fontStyle: z2.text?.fontStyle, fontWeight: z2.text?.fontWeight, lineHeight: 1.2, display: "flex", justifyContent: "center", alignItems: "end", pointerEvents: "auto", paddingBottom: `${E2}px`, ...C2, left: C2.left - (y2 === T.Column ? 1 : 0), top: C2.top - (y2 === T.Row ? 1 : 0), width: C2.width + 1, height: C2.height + 1, overflow: "hidden" }, ...I2, onMouseMove: (e2) => {
|
|
1694
1698
|
"touch" !== i.detectIt().primaryInput && 0 === e2.buttons && k2(true);
|
|
1695
1699
|
}, onMouseOut: (e2) => {
|
|
1696
1700
|
k2(false);
|
|
1697
1701
|
}, children: c2(n2) });
|
|
1698
1702
|
});
|
|
1699
1703
|
Ae.displayName = "HeaderRenderer";
|
|
1700
|
-
const
|
|
1701
|
-
const { orientation: r2, view: l2, index: c2, className: s2, style: a2, disabled: d2 = false, disabledResize: u2 = false, isNextHidden: h2, isHidden: g2, isSelected: f2, isSelectedAll: w2, showTouchDivider: x2, headerStyle: p2, headerStyleSelect: m2, headerStyleSelectAll: v2, headerStyleHover: S2, bounds: y2, onPointerDown: b2, onAutoFit: C2, ...I2 } = n2, E2 = r2 ===
|
|
1704
|
+
const We = "ew-resize", Ve = "ns-resize", Ue = C(I((n2, o2) => {
|
|
1705
|
+
const { orientation: r2, view: l2, index: c2, className: s2, style: a2, disabled: d2 = false, disabledResize: u2 = false, isNextHidden: h2, isHidden: g2, isSelected: f2, isSelectedAll: w2, showTouchDivider: x2, headerStyle: p2, headerStyleSelect: m2, headerStyleSelectAll: v2, headerStyleHover: S2, bounds: y2, onPointerDown: b2, onAutoFit: C2, ...I2 } = n2, E2 = r2 === T.Column;
|
|
1702
1706
|
let R2 = p2;
|
|
1703
1707
|
f2 && m2 && (R2 = m2), w2 && v2 && (R2 = v2);
|
|
1704
|
-
const
|
|
1705
|
-
let P2 = E2 ? 14 : 8,
|
|
1706
|
-
h2 && (O2 = -2), g2 && (O2 = 2), g2 && (P2 = P2 / 2 + O2,
|
|
1708
|
+
const k2 = "touch" === i.detectIt().primaryInput;
|
|
1709
|
+
let P2 = E2 ? 14 : 8, D2 = P2 / 2, O2 = 0;
|
|
1710
|
+
h2 && (O2 = -2), g2 && (O2 = 2), g2 && (P2 = P2 / 2 + O2, D2 = 2 * O2);
|
|
1707
1711
|
let z2 = R2.dividerStrokeFill ?? R2.strokeFill;
|
|
1708
|
-
return !(f2 || w2) && 0 === O2 && (z2 = `linear-gradient(${E2 ? 180 : 90}deg, ${R2.fill}, ${z2} 55%, ${z2} 100%)`), t("div", { className:
|
|
1709
|
-
})),
|
|
1710
|
-
const { orientation: i2, view: c2, index: a2, disabled: d2 = false, disabledResize: h2 = false, resizeThreshold: g2 = 1,
|
|
1711
|
-
let P2 =
|
|
1712
|
-
P2.length > 0 && (
|
|
1713
|
-
const O2 = x(null), [z2, L2] = m(null), B2 = (e2, t2) =>
|
|
1712
|
+
return !(f2 || w2) && 0 === O2 && (z2 = `linear-gradient(${E2 ? 180 : 90}deg, ${R2.fill}, ${z2} 55%, ${z2} 100%)`), t("div", { className: M("header-divider", { disabled: d2 }, s2, `index-${c2}`), ref: o2, onPointerDown: k2 ? void 0 : b2, onDoubleClick: k2 ? void 0 : () => C2?.(), style: { top: (E2 ? 0 : -P2 / 2 + (O2 - 1)) + "px", left: (E2 ? -P2 / 2 + (O2 - 1) : 0) + "px", width: E2 ? P2 : "calc(100% + 1px)", height: E2 ? "calc(100% + 1px)" : P2, position: "absolute", overflow: "visible", pointerEvents: "all", cursor: d2 || u2 || k2 ? void 0 : E2 ? We : Ve, ...a2 }, ...I2, children: [e("div", { style: { position: "relative", top: `${E2 ? 0 : D2}px`, left: `${E2 ? D2 : 0}px`, width: E2 ? 1 : "100%", height: E2 ? "100%" : 1, background: z2 }, onDoubleClick: () => C2?.() }), x2 && k2 ? e("div", { style: { position: "absolute", cursor: "grab", zIndex: 1, borderRadius: "4px", right: E2 ? "-6px" : "2px", bottom: E2 ? "2px" : "-9px", height: "24px", width: E2 ? "24px" : "18px", maxHeight: E2 ? "calc(100% - 4px)" : void 0, maxWidth: E2 ? void 0 : "calc(100% - 4px)", background: R2.fill, border: `${v2.edgeStrokeFill} solid 1px`, boxShadow: `0.5px 0.5px 0px 0px ${p2.text.fill}`, display: "flex", alignItems: "center", justifyContent: "center" }, onPointerDown: b2, children: e("div", { style: { width: "6.4px", height: "12px", backgroundImage: `url("data:image/svg+xml,%3Csvg width='6.4' height='12' viewBox='0 0 9.6 16' version='1.1' fill='${encodeURIComponent(m2.text.fill)}' xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg'%3E%3Cpath d='M 9.60008,14.40009 C 9.60008,15.28374 8.88368,16 8.00003,16 7.11639,16 6.40012,15.28374 6.40012,14.40009 c 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40012 c 0,0.88364 -0.7164,1.60004 -1.60005,1.60004 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60004 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40006 c 0,0.88365 -0.7164,1.60005 -1.60005,1.60005 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60005 C 6.40012,0.71626 7.11639,0 8.00003,0 8.88368,0 9.60008,0.71626 9.60008,1.59991 M 3.19996,14.40009 C 3.19996,15.28374 2.48369,16 1.60005,16 0.7164,16 0,15.28374 0,14.40009 c 0,-0.88365 0.7164,-1.60005 1.60005,-1.60005 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40012 c 0,0.88364 -0.71627,1.60004 -1.59991,1.60004 C 0.7164,9.60001 0,8.88361 0,7.99997 0,7.11632 0.7164,6.39992 1.60005,6.39992 c 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40006 c 0,0.88365 -0.71627,1.60005 -1.59991,1.60005 C 0.7164,3.19996 0,2.48356 0,1.59991 0,0.71626 0.7164,0 1.60005,0 2.48369,0 3.19996,0.71626 3.19996,1.59991' /%3E%3C/svg%3E%0A")`, backgroundRepeat: "no-repeat", backgroundPosition: "center", transform: E2 ? void 0 : "rotate(90deg)" } }) }) : null] });
|
|
1713
|
+
})), He = (t2) => e(Ue, { ...t2 }), Ke = C(I((r2, l2) => {
|
|
1714
|
+
const { orientation: i2, view: c2, index: a2, disabled: d2 = false, disabledResize: h2 = false, resizeThreshold: g2 = 1, renderDivider: f2 = He, onDividerMouseDown: w2, onDividerResizeStart: p2, onDividerResize: v2, onDividerResizeEnd: S2, onDividerMouseUp: y2, onDividerAutoFit: b2, onPointerDown: C2, ...I2 } = r2, E2 = o(C2, [C2]), R2 = o(b2, [b2]), k2 = i2 === T.Column;
|
|
1715
|
+
let P2 = k2 ? c2.getVisibleColumns() : c2.getVisibleRows(), D2 = null;
|
|
1716
|
+
P2.length > 0 && (k2 ? D2 = c2.getRangeCoordsBounds({ rowStart: 0, rowEnd: 0, colStart: P2[0], colEnd: P2[P2.length - 1] }) : c2.getRangeCoordsBounds({ rowStart: P2[0], rowEnd: P2[P2.length - 1], colStart: 0, colEnd: 0 }), D2 = c2.toClipBounds(D2, me));
|
|
1717
|
+
const O2 = x(null), [z2, L2] = m(null), B2 = (e2, t2) => k2 ? e2.clientX - t2.clientX : e2.clientY - t2.clientY, F2 = c2.getLayout(), A2 = k2 ? F2.getColOffset(a2 + 1) : F2.getRowOffset(a2 + 1), W2 = s({ processTouch: true, onPointerDown: (e2) => {
|
|
1714
1718
|
if (E2?.(e2), !d2 && !h2) {
|
|
1715
|
-
const e3 =
|
|
1719
|
+
const e3 = k2 ? F2.getColOffset(a2) : F2.getRowOffset(a2), t2 = A2 - e3;
|
|
1716
1720
|
O2.current = { isResizing: false, startSize: t2, index: a2, view: c2, orientation: i2, onDividerMouseDown: w2, onDividerResizeStart: p2, onDividerResize: v2, onDividerResizeEnd: S2, onDividerMouseUp: y2 }, L2(O2.current), w2?.(a2, t2);
|
|
1717
1721
|
}
|
|
1718
1722
|
e2.stopPropagation(), e2.preventDefault();
|
|
@@ -1728,14 +1732,14 @@ const Ve = "ew-resize", Ue = "ns-resize", He = C(I((n2, o2) => {
|
|
|
1728
1732
|
} }), V2 = o(() => {
|
|
1729
1733
|
R2?.(a2);
|
|
1730
1734
|
}, [a2]);
|
|
1731
|
-
if (!
|
|
1732
|
-
const U2 = f2({ bounds:
|
|
1735
|
+
if (!D2) return;
|
|
1736
|
+
const U2 = f2({ bounds: D2, orientation: i2, view: c2, index: a2, disabled: d2, disabledResize: h2, onAutoFit: V2, onPointerDown: W2, ref: l2, ...I2 });
|
|
1733
1737
|
if (!U2) return;
|
|
1734
1738
|
const { getPortalContainer: H2 } = u();
|
|
1735
1739
|
let K2 = null;
|
|
1736
|
-
return z2 && z2.isResizing && z2.index === a2 && (K2 = $(e("div", { style: { position: "absolute", cursor:
|
|
1740
|
+
return z2 && z2.isResizing && z2.index === a2 && (K2 = $(e("div", { style: { position: "absolute", cursor: k2 ? We : Ve, left: 0, top: 0, width: "100%", height: "100%" } }), H2(), "divider:" + a2)), t(n, { children: [K2, e("div", { className: M("header-divider-anchor"), style: { position: "absolute", pointerEvents: "auto", top: `${k2 ? D2.y : A2}px`, left: `${k2 ? A2 : D2.x}px`, width: (k2 ? 0 : D2.width - 1) + "px", height: (k2 ? D2.height - 1 : 0) + "px", display: "flex" }, tabIndex: -1, children: U2 })] });
|
|
1737
1741
|
}));
|
|
1738
|
-
class
|
|
1742
|
+
class Ne {
|
|
1739
1743
|
naturalDimensions(e2, t2 = {}) {
|
|
1740
1744
|
const n2 = document.createElement("div");
|
|
1741
1745
|
let o2 = t2?.lineHeight ?? "1";
|
|
@@ -1752,16 +1756,16 @@ class qe {
|
|
|
1752
1756
|
return r2.remove(), { width: i2.width, height: i2.height, maxLineHeight: 1.2 * (t2.paintableText?.fontSize || 1056 / 72) };
|
|
1753
1757
|
}
|
|
1754
1758
|
}
|
|
1755
|
-
const
|
|
1756
|
-
const { editState: r2 =
|
|
1759
|
+
const qe = (e2 = void 0) => Object.freeze({ clean: e2, dirty: void 0, editMode: false }), je = qe(), Xe = C(I((t2, n2) => {
|
|
1760
|
+
const { editState: r2 = je, defaultTextStyle: i2, onStartEdit: c2, onChangeEdit: s2, onSubmitEdit: a2, onCancelEdit: d2, onDoneEdit: u2, containerBounds: h2, setNaturalSize: g2, onNavigate: w2, textProperties: p2, style: C2, autoFocus: I2, ...E2 } = t2, R2 = x(null), { width: M2 = 0 } = h2 ?? {}, [k2, P2] = m(() => r2);
|
|
1757
1761
|
v(() => {
|
|
1758
1762
|
P2(r2);
|
|
1759
1763
|
}, [r2]);
|
|
1760
|
-
const T2 = p2?.align || "left",
|
|
1764
|
+
const T2 = p2?.align || "left", O2 = p2?.vAlign || "middle", z2 = p2?.fill || "#040404", L2 = p2?.wrap || "wrap", $2 = p2?.fontFamily || "Calibri", B2 = p2?.fontSize || 11, F2 = p2?.fontWeight || 400, A2 = p2?.fontStyle || "normal", W2 = k2.dirty ?? k2.clean ?? "";
|
|
1761
1765
|
let V2 = 2;
|
|
1762
|
-
const
|
|
1763
|
-
"right" ===
|
|
1764
|
-
const N2 = b(() => new
|
|
1766
|
+
const H2 = 96 * B2 / 72, K2 = 1.2 * H2;
|
|
1767
|
+
"right" === O2 && (V2 += 1);
|
|
1768
|
+
const N2 = b(() => new Ne().naturalDimensions(W2, { maxWidth: "wrap" === L2 ? M2 - V2 : void 0, lineHeight: `${K2}px`, paintableText: { fontStyle: A2, wrap: L2, letterSpacing: -0.25 } }), [W2, L2, V2, H2, $2, F2, A2, g2, M2]), q2 = S(() => N2.maxLineHeight ? N2.maxLineHeight + "px" : "1.2", [N2]), [j2, X2] = m(q2);
|
|
1765
1769
|
y(() => {
|
|
1766
1770
|
X2(q2());
|
|
1767
1771
|
}, [h2, N2]), y(() => {
|
|
@@ -1785,28 +1789,28 @@ const je = (e2 = void 0) => Object.freeze({ clean: e2, dirty: void 0, editMode:
|
|
|
1785
1789
|
P2(r2), d2?.(), u2?.();
|
|
1786
1790
|
}, [d2, r2]), Q2 = o((e2) => {
|
|
1787
1791
|
if (!R2.current) return;
|
|
1788
|
-
if (e2.isDefaultPrevented(), !(e2.isTrusted || e2.nativeEvent.ctrlKey || e2.nativeEvent.metaKey || e2.nativeEvent.altKey || e2.nativeEvent.isComposing) && -1 !==
|
|
1792
|
+
if (e2.isDefaultPrevented(), !(e2.isTrusted || e2.nativeEvent.ctrlKey || e2.nativeEvent.metaKey || e2.nativeEvent.altKey || e2.nativeEvent.isComposing) && -1 !== U.indexOf(e2.nativeEvent.key)) {
|
|
1789
1793
|
const t4 = { ...k2 };
|
|
1790
1794
|
return t4.dirty = "Backspace" === e2.nativeEvent.key ? "" : (t4.dirty ?? "") + e2.key, P2(t4), Y2?.(t4), void e2.preventDefault();
|
|
1791
1795
|
}
|
|
1792
1796
|
const t3 = e2.nativeEvent.shiftKey;
|
|
1793
1797
|
if (e2.which === l.Escape) return e2.preventDefault(), void J2();
|
|
1794
1798
|
if (e2.which === l.F2) return Z2(true), void e2.preventDefault();
|
|
1795
|
-
if (e2.which === l.Enter && (e2.preventDefault(), _2() && w2?.(t3 ?
|
|
1799
|
+
if (e2.which === l.Enter && (e2.preventDefault(), _2() && w2?.(t3 ? D.Up : D.Down)), e2.which === l.Tab) return e2.preventDefault(), void (_2() && w2?.(t3 ? D.Left : D.Right));
|
|
1796
1800
|
if (!k2.editMode) {
|
|
1797
1801
|
let t4 = null;
|
|
1798
1802
|
switch (e2.which) {
|
|
1799
1803
|
case l.Left:
|
|
1800
|
-
t4 =
|
|
1804
|
+
t4 = D.Left;
|
|
1801
1805
|
break;
|
|
1802
1806
|
case l.Right:
|
|
1803
|
-
t4 =
|
|
1807
|
+
t4 = D.Right;
|
|
1804
1808
|
break;
|
|
1805
1809
|
case l.Up:
|
|
1806
|
-
t4 =
|
|
1810
|
+
t4 = D.Up;
|
|
1807
1811
|
break;
|
|
1808
1812
|
case l.Down:
|
|
1809
|
-
t4 =
|
|
1813
|
+
t4 = D.Down;
|
|
1810
1814
|
}
|
|
1811
1815
|
if (t4) return void _2();
|
|
1812
1816
|
}
|
|
@@ -1828,39 +1832,39 @@ const je = (e2 = void 0) => Object.freeze({ clean: e2, dirty: void 0, editMode:
|
|
|
1828
1832
|
}, autoFocus() {
|
|
1829
1833
|
R2.current?.focus();
|
|
1830
1834
|
}, getLineHeight: () => N2?.maxLineHeight ?? K2, dispatchEvent: (e2) => R2.current.dispatchEvent(e2) }), [r2, c2]);
|
|
1831
|
-
return e("div", { ref: ne2, ...E2, style: { background: "transparent", display: "flex", flexGrow: 1, alignSelf: "center", height: N2.height, maxWidth: "100%", maxHeight: "100%", ...C2 }, children: e("textarea", { spellCheck: "false", ref: R2, value:
|
|
1835
|
+
return e("div", { ref: ne2, ...E2, style: { background: "transparent", display: "flex", flexGrow: 1, alignSelf: "center", height: N2.height, maxWidth: "100%", maxHeight: "100%", ...C2 }, children: e("textarea", { spellCheck: "false", ref: R2, value: W2, autoFocus: false, disabled: ee2, name: "cell-editor", autoComplete: "off", autoCapitalize: "off", style: { flex: "1 1 100%", position: "relative", fontSize: `${H2}px`, fontFamily: `${$2}`, fontWeight: `${F2}`, fontStyle: `${A2}`, padding: "0px", marginRight: "right" === T2 ? "3px" : "0px", marginLeft: "left" === T2 ? "2px" : "0px", lineHeight: j2, height: N2.height, textRendering: "geometricPrecision", letterSpacing: "-0.25px", boxSizing: "border-box", borderWidth: 0, outline: "none", resize: "none", overflow: "hidden", verticalAlign: "baseline", textAlign: T2, background: "transparent", color: z2, marginBottom: "0px", userSelect: "text", maxHeight: "100%", whiteSpace: "wrap" === L2 ? "break-spaces" : "pre", wordWrap: "break-word" }, onChange: (e2) => {
|
|
1832
1836
|
G2(e2.target.value);
|
|
1833
1837
|
}, onDoubleClick: (e2) => {
|
|
1834
1838
|
e2.isTrusted;
|
|
1835
1839
|
}, onMouseDown: (e2) => {
|
|
1836
1840
|
Z2(true);
|
|
1837
1841
|
}, onKeyDown: Q2 }) });
|
|
1838
|
-
})),
|
|
1842
|
+
})), Ye = C((t2) => {
|
|
1839
1843
|
const { value: n2, view: o2, bounds: r2, range: l2, zoom: i2, children: c2, style: s2, ...a2 } = t2;
|
|
1840
1844
|
return e("div", { style: { padding: "2px 4px", fontFamily: "Calibri", letterSpacing: -0.25, lineHeight: 1.2, fontSize: s2?.fontSize || 1056 / 72, ...s2 }, ...a2, children: n2 });
|
|
1841
1845
|
});
|
|
1842
1846
|
export {
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1847
|
+
Le as BaseGrid,
|
|
1848
|
+
Xe as DefaultCellEditor,
|
|
1849
|
+
Ye as DefaultCellRenderer,
|
|
1850
|
+
Ue as DefaultHeaderDivider,
|
|
1851
|
+
we as FillHandle,
|
|
1852
|
+
$e as Grid,
|
|
1853
|
+
Ke as HeaderDivider,
|
|
1850
1854
|
Ae as HeaderRenderer,
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1855
|
+
De as RESET_SCROLL_EVENTS_DEBOUNCE_INTERVAL,
|
|
1856
|
+
me as SELECTION_CLIP_INSETS,
|
|
1857
|
+
U as STANDARD_KEY_CHARS,
|
|
1858
|
+
ue as SVGLine,
|
|
1859
|
+
he as SVGRect,
|
|
1860
|
+
Be as ScrollableGrid,
|
|
1861
|
+
fe as Selection,
|
|
1862
|
+
pe as TouchSelectHandle,
|
|
1863
|
+
ge as defaultSelectionRenderer,
|
|
1864
|
+
qe as getDefaultStringEditState,
|
|
1865
|
+
be as safeSelectionCoords,
|
|
1866
|
+
V as useCellLayout,
|
|
1867
|
+
G as useHeaderSelection,
|
|
1868
|
+
X as useKeyboardEditorOverlay,
|
|
1869
|
+
Ee as useSelection
|
|
1866
1870
|
};
|