@sheetxl/grid-react 0.7.9 → 0.7.11
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 +1307 -1341
- package/licenses/dependencies.txt +39 -39
- package/node/esm/index.mjs +722 -755
- package/package.json +3 -3
- package/types/index.d.ts +0 -40
package/browser/esm/index.mjs
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._sheetxl-grid_h9wwa_7{position:relative;box-sizing:border-box;user-select:none}._sheetxl-grid_h9wwa_7 *{box-sizing:border-box!important}._sheetxl-grid_h9wwa_7 *:focus{outline:none}._sheetxl-grid_h9wwa_7 .cell-container{position:absolute;overflow:visible;white-space:pre}._sheetxl-grid_h9wwa_7 .cell-container>*{inset:0;position:absolute}._sheetxl-grid_h9wwa_7 .sheetxl-stage{contain:strict}._sheetxl-grid_h9wwa_7 .sheetxl-stage>*{contain:strict}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
|
-
import { jsx as Ce, jsxs as
|
|
3
|
-
import { useCallbackRef as
|
|
4
|
-
import { useRef as
|
|
5
|
-
import { CoordUtils as
|
|
6
|
-
import { createPortal as
|
|
2
|
+
import { jsx as Ce, jsxs as Qt, Fragment as _n } from "react/jsx-runtime";
|
|
3
|
+
import { useCallbackRef as P, HorizontalAlignment as mn, KeyCodes as Ot, ReactUtils as X, MouseButtonCodes as jn, useSynchronizedPointerHandler as un, useId as To, useAnimatedMeasure as Do, useFullscreenPortal as fo, SimpleCommand as ie, KeyModifiers as ce, useImperativeElement as go, ScrollPane as Oo } from "@sheetxl/utils-react";
|
|
4
|
+
import { useRef as se, useReducer as Zn, useState as gt, useEffect as It, useCallback as V, useLayoutEffect as en, useMemo as Ae, memo as Kt, forwardRef as tn, version as zo, createElement as wo, useImperativeHandle as Lo } from "react";
|
|
5
|
+
import { CoordUtils as F, CommonUtils as Nt, RangeOrientation as Ht, Direction as g, AnchorLocation as Qe } from "@sheetxl/utils";
|
|
6
|
+
import { createPortal as xo } from "react-dom";
|
|
7
7
|
/**
|
|
8
|
-
* @license @sheetxl/grid-react - Grid React - Advanced grid component for React - v0.7.
|
|
8
|
+
* @license @sheetxl/grid-react - Grid React - Advanced grid component for React - v0.7.11
|
|
9
9
|
*
|
|
10
10
|
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
11
11
|
* License: The license can be found at https://www.sheetxl.com/license.
|
|
12
12
|
*/
|
|
13
13
|
const dn = ({ itemType: t, index: n, itemSize: o, instanceProps: r, scale: c = 1 }) => {
|
|
14
|
-
let
|
|
15
|
-
t === "column" ? (
|
|
16
|
-
const
|
|
14
|
+
let d, i, l;
|
|
15
|
+
t === "column" ? (d = r.columnMetadataMap, i = r.lastMeasuredColumnIndex, l = r.recalcColumnIndices) : (d = r.rowMetadataMap, i = r.lastMeasuredRowIndex, l = r.recalcRowIndices);
|
|
16
|
+
const w = l.length > 0;
|
|
17
17
|
if (n > i) {
|
|
18
|
-
let
|
|
18
|
+
let L = 0;
|
|
19
19
|
if (i >= 0) {
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
const O = d[i];
|
|
21
|
+
L = O.offset + O.size;
|
|
22
22
|
}
|
|
23
|
-
for (let
|
|
24
|
-
let
|
|
25
|
-
|
|
23
|
+
for (let O = i + 1; O <= n; O++) {
|
|
24
|
+
let R = w ? l.includes(O) ? o(O) * c : d[O]?.size || o(O) * c : o(O) * c;
|
|
25
|
+
d[O] = { offset: L, size: R }, L += R;
|
|
26
26
|
}
|
|
27
27
|
t === "column" ? r.lastMeasuredColumnIndex = n : r.lastMeasuredRowIndex = n;
|
|
28
28
|
}
|
|
29
|
-
return
|
|
30
|
-
},
|
|
29
|
+
return d[n], d[n];
|
|
30
|
+
}, Qn = ({ itemType: t, itemSize: n, itemCount: o, instanceProps: r, offset: c, scale: d }) => {
|
|
31
31
|
let i, l;
|
|
32
32
|
t === "column" ? (i = r.columnMetadataMap, l = r.lastMeasuredColumnIndex) : (i = r.rowMetadataMap, l = r.lastMeasuredRowIndex);
|
|
33
|
-
let
|
|
34
|
-
return
|
|
35
|
-
},
|
|
33
|
+
let w = 0;
|
|
34
|
+
return w = (l > 0 ? i[l].offset : 0) >= c ? po({ itemType: t, itemSize: n, instanceProps: r, high: l, low: 0, offset: c, scale: d }) : $o({ itemType: t, itemSize: n, itemCount: o, instanceProps: r, index: Math.max(0, l), offset: c, scale: d }), w = Math.min(w, o), w;
|
|
35
|
+
}, po = ({ itemType: t, itemSize: n, instanceProps: o, high: r, low: c, offset: d, scale: i }) => {
|
|
36
36
|
for (; c <= r; ) {
|
|
37
|
-
const l = c + Math.floor((r - c) / 2),
|
|
38
|
-
if (
|
|
39
|
-
|
|
37
|
+
const l = c + Math.floor((r - c) / 2), w = dn({ itemType: t, itemSize: n, index: l, instanceProps: o, scale: i }).offset;
|
|
38
|
+
if (w === d) return l;
|
|
39
|
+
w < d ? c = l + 1 : w > d && (r = l - 1);
|
|
40
40
|
}
|
|
41
41
|
return c > 0 ? c - 1 : 0;
|
|
42
|
-
},
|
|
42
|
+
}, $o = ({ itemType: t, itemSize: n, itemCount: o, instanceProps: r, index: c, offset: d, scale: i }) => {
|
|
43
43
|
let l = 1;
|
|
44
|
-
for (; c < o && dn({ itemType: t, itemSize: n, index: c, instanceProps: r, scale: i }).offset <
|
|
45
|
-
return
|
|
46
|
-
},
|
|
47
|
-
const { rowCount: n, columnCount: o, defaultRowHeight: r, getRowHeight: c, defaultColumnWidth:
|
|
48
|
-
return
|
|
49
|
-
|
|
50
|
-
}, [
|
|
51
|
-
},
|
|
44
|
+
for (; c < o && dn({ itemType: t, itemSize: n, index: c, instanceProps: r, scale: i }).offset < d; ) c += l, l *= 2;
|
|
45
|
+
return po({ itemType: t, itemSize: n, instanceProps: r, high: Math.min(c, o - 1), low: Math.floor(c / 2), offset: d, scale: i });
|
|
46
|
+
}, Bo = (t) => {
|
|
47
|
+
const { rowCount: n, columnCount: o, defaultRowHeight: r, getRowHeight: c, defaultColumnWidth: d, getColumnWidth: i } = t || {}, l = se({ columnMetadataMap: {}, rowMetadataMap: {}, lastMeasuredColumnIndex: -1, lastMeasuredRowIndex: -1, recalcColumnIndices: [], recalcRowIndices: [] }), w = P((T) => Qn({ itemType: "row", itemCount: n, itemSize: c ?? (() => r ?? 20), instanceProps: l.current, offset: T }), [n, c, r]), L = P((T) => T === -1 ? 0 : dn({ itemType: "row", index: T, itemSize: c ?? (() => r ?? 20), instanceProps: l.current }).offset, [c, r]), O = P((T) => dn({ itemType: "row", index: T, itemSize: c ?? (() => r ?? 20), instanceProps: l.current }).size, [c, r]), R = P((T) => Qn({ itemType: "column", itemCount: o, itemSize: i ?? (() => d ?? 75), instanceProps: l.current, offset: T }), [o, i, d]), M = P((T) => T === -1 ? 0 : dn({ itemType: "column", index: T, itemSize: i ?? (() => d ?? 75), instanceProps: l.current }).offset, [i, d]), A = P((T) => dn({ itemType: "column", index: T, itemSize: i ?? (() => d ?? 75), instanceProps: l.current }).size, [i, d]), [le, J] = Zn((T) => T + 1, 0), te = () => ({ getRowOffset: L, getColOffset: M, getRowIndex: w, getColIndex: R }), [ze, Q] = gt(() => t ? te() : null);
|
|
48
|
+
return It(() => {
|
|
49
|
+
Q(t ? te() : null);
|
|
50
|
+
}, [le, n, o, d, r, O, A]), ze;
|
|
51
|
+
}, mo = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ~`!@#$%^&*()-_=+[{]};:'\",<.>/?|\\", eo = (t) => {
|
|
52
52
|
if (!t) return null;
|
|
53
53
|
if (t.eventType === "start") return { type: t.eventType };
|
|
54
54
|
if (t.eventType === "submit") return { type: t.eventType };
|
|
@@ -60,164 +60,164 @@ const dn = ({ itemType: t, index: n, itemSize: o, instanceProps: r, scale: c = 1
|
|
|
60
60
|
return t.activeCoords && (n.activeCoords = t.activeCoords), n;
|
|
61
61
|
}
|
|
62
62
|
return { type: t.eventType ?? "unknown" };
|
|
63
|
-
},
|
|
64
|
-
const { session: n, refLatestCoords: o, handleSubmitEdit: r, handleCancelEdit: c, cellBounds:
|
|
65
|
-
if (
|
|
66
|
-
if (
|
|
67
|
-
const
|
|
68
|
-
p.isSynthetic = !0, p.key,
|
|
69
|
-
} else
|
|
70
|
-
await new Promise((
|
|
63
|
+
}, Ao = (t) => !0, Fo = (t) => !!t && !(t.ctrlKey || t.metaKey || t.altKey || t.isComposing) && (!(t.shiftKey || t.key !== "F2" && t.key !== " " && t.key !== "Backspace") || (!t.shiftKey || t.key !== " ") && mo.indexOf(t.key) !== -1), Vo = (t) => !!t && t.type === "dblclick" && { editMode: !0 }, Wo = (t) => {
|
|
64
|
+
const { session: n, refLatestCoords: o, handleSubmitEdit: r, handleCancelEdit: c, cellBounds: d, isInBounds: i, getCellEditor: l, propsEditor: w, borderStrokeFill: L = "rgb(33, 115, 70)", borderStrokeWidth: O = 2, alignment: R = mn.Left, style: M, ...A } = t, le = se(null), J = se(null), [te, ze] = gt(!1), Q = n.coords, T = V(async (ue) => {
|
|
65
|
+
if (le.current?.getBoundingClientRect()) {
|
|
66
|
+
if (ue.eventType === "keyboard") {
|
|
67
|
+
const $ = ue.event, p = new KeyboardEvent($.type, { bubbles: !0, cancelable: !0, view: window, key: $.key, code: $.code, location: $.location, repeat: $.repeat, isComposing: $.isComposing, charCode: $.charCode, keyCode: $.keyCode, which: $.which, ctrlKey: $.ctrlKey, shiftKey: $.shiftKey, altKey: $.altKey, metaKey: $.metaKey });
|
|
68
|
+
p.isSynthetic = !0, p.key, J.current?.dispatchEvent(p);
|
|
69
|
+
} else ue.eventType === "pointer" || console.warn("unsupported event type", ue);
|
|
70
|
+
await new Promise(($) => requestAnimationFrame($));
|
|
71
71
|
}
|
|
72
72
|
}, []);
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
return
|
|
76
|
-
n.editorRefs.push(
|
|
73
|
+
It(() => {
|
|
74
|
+
const ue = J.current;
|
|
75
|
+
return ze(!0), J.current.startEdit?.(n.startEvent), (async () => {
|
|
76
|
+
n.editorRefs.push(ue), n.editorRefsDispatchEditorEvent.push(T);
|
|
77
77
|
const ye = [...n.events];
|
|
78
|
-
for (let
|
|
79
|
-
n.onMount(
|
|
78
|
+
for (let $ = 0; $ < ye.length; $++) await T(ye[$]);
|
|
79
|
+
n.onMount(ue);
|
|
80
80
|
})(), () => {
|
|
81
|
-
const ye = n.editorRefs.indexOf(
|
|
82
|
-
ye !== -1 && n.editorRefs.splice(ye, 1), n.onUnmount(
|
|
81
|
+
const ye = n.editorRefs.indexOf(ue);
|
|
82
|
+
ye !== -1 && n.editorRefs.splice(ye, 1), n.onUnmount(ue);
|
|
83
83
|
};
|
|
84
84
|
}, []);
|
|
85
|
-
const
|
|
85
|
+
const _ = V(() => r(n), []), ve = V(() => {
|
|
86
86
|
c(n);
|
|
87
|
-
}, []),
|
|
88
|
-
return Ce("div", { tabIndex: 0, ref:
|
|
89
|
-
},
|
|
90
|
-
const { view: n, canEdit: o =
|
|
87
|
+
}, []), W = o.current && F.isEqualCells(o.current, Q), me = i && W && te, Ve = l({ autoFocus: !!n.startEvent?.autoFocus, ...w, onSubmitEdit: _, onCancelEdit: ve, ref: J }, Q), ke = d.x + X.boundPixel(-O / 2), We = X.boundPixel(d.width + O / 2, !0);
|
|
88
|
+
return Ce("div", { tabIndex: 0, ref: le, style: { background: void 0, ...M, opacity: me ? M?.opacity ?? 1 : 0, pointerEvents: "auto", position: "absolute", boxSizing: "border-box", top: `${d.y + X.boundPixel(-O / 2)}px`, height: X.boundPixel(d.height + O / 2, !0), left: `${ke}px`, width: We }, ...A, children: Ce("div", { className: "editor-container", style: { position: "absolute", boxSizing: "border-box", left: `${X.boundPixel(1)}px`, top: `${X.boundPixel(1)}px`, width: X.boundPixel(d.width - 2, !0), height: X.boundPixel(d.height - 2, !0), outline: `${O}px ${L} solid`, boxShadow: "rgba(60,64,67,.35) 2px 2px 6px 3px", maxHeight: "100%", overflow: "hidden", display: "flex" }, children: Ve }) });
|
|
89
|
+
}, xr = (t) => {
|
|
90
|
+
const { view: n, canEdit: o = Ao, getCellEditor: r, onBeforeStartEdit: c, onStartEdit: d, onSubmitEdit: i, onCancelEdit: l, onDoneEdit: w, isEditorStartKeyEvent: L = Fo, isEditorStartPointerEvent: O = Vo, containerProps: R, borderStrokeFill: M, borderStrokeWidth: A = 2, getRangeCoords: le = null, activeCoords: J, alignment: te = mn.Left } = t, [ze, Q] = gt(!1), [T, _] = gt(void 0), ve = P((k, b, Re, ne, we, Ue) => {
|
|
91
91
|
if (!b) return null;
|
|
92
|
-
const lt =
|
|
92
|
+
const lt = we?.(b, k), Mt = k.getRangeCoordsBounds(lt), it = k.toClipBounds(Mt), qt = Mt, xt = k.getZoom();
|
|
93
93
|
if (!it) return null;
|
|
94
|
-
|
|
95
|
-
let v =
|
|
96
|
-
if (
|
|
97
|
-
let
|
|
98
|
-
for (; !
|
|
94
|
+
Re && (Re *= xt), ne && (ne *= xt);
|
|
95
|
+
let v = qt, oe = !1;
|
|
96
|
+
if (Re !== void 0) {
|
|
97
|
+
let Je = { ...lt }, ln = 0;
|
|
98
|
+
for (; !oe && v.width <= Re && ln < 20; ) {
|
|
99
99
|
ln++, ln > 19 && console.warn("max width reached");
|
|
100
|
-
const
|
|
101
|
-
Ue === mn.Left ?
|
|
100
|
+
const _t = k.getTotalRangeCoords(), Tt = k.getLayout();
|
|
101
|
+
Ue === mn.Left ? Je.colEnd + 1 < _t.colEnd ? Je.colEnd = Tt.getColIndex(v.x + Re) : oe = !0 : Ue === mn.Right ? Je.colStart - 1 >= 0 ? Je.colStart = Tt.getColIndex(v.x - (Re - v.width)) : oe = !0 : Ue === mn.Center && Je.colEnd + 1 < _t.colEnd && Je.colStart - 1 >= 0 ? (Je.colStart = Tt.getColIndex(v.x - (Re - v.width) / 2), Je.colEnd = Tt.getColIndex(v.x + v.width + (Re - v.width) / 2)) : oe = !0, oe || (v = k.getRangeCoordsBounds(Je));
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
v.height =
|
|
105
|
-
const { width: He, height:
|
|
106
|
-
return { x: v.x ?? 0, y: v.y ?? 0, height: Math.min(
|
|
107
|
-
}, [
|
|
104
|
+
v.height = qt.height, ne !== void 0 && (v.height = Math.max(ne + 1, qt.height));
|
|
105
|
+
const { width: He, height: ht } = k.getViewportSize();
|
|
106
|
+
return { x: v.x ?? 0, y: v.y ?? 0, height: Math.min(ht - v.y, v.height) + 1, width: Math.min(He - v.x, v.width) + 1 };
|
|
107
|
+
}, [te]), W = P(o, [o]), me = V(() => {
|
|
108
108
|
n?.getStage()?.focus();
|
|
109
|
-
}, [n]), Ve =
|
|
110
|
-
c?.(
|
|
111
|
-
}, [c]), We =
|
|
112
|
-
|
|
113
|
-
}, [
|
|
114
|
-
|
|
115
|
-
}, [l]), ye =
|
|
116
|
-
if (
|
|
109
|
+
}, [n]), Ve = se(null), ke = P((k) => {
|
|
110
|
+
c?.(k), D(), Q(!0), Ve.current = null;
|
|
111
|
+
}, [c]), We = P((k) => {
|
|
112
|
+
d?.(k.coords);
|
|
113
|
+
}, [d]), ue = P((k) => {
|
|
114
|
+
k.isSubmitted || k.isCancelled || (p.current.isEditorClosed = !0, me(), k.isCancelled = !0, l?.(k.coords), D());
|
|
115
|
+
}, [l]), ye = P((k) => {
|
|
116
|
+
if (k.isSubmitted || k.isCancelled) return !1;
|
|
117
117
|
try {
|
|
118
|
-
return Ve.current =
|
|
118
|
+
return Ve.current = k.coords, k.isEditorClosing = !0, k.isSubmitted = !0, k.isEditorSubmitted || (k.isEditorSubmitted = !0, k.editorRefs[0]?.submitEdit?.()), k.coords, i?.(k.coords), k.isEditorClosed = !0, me(), D(), !0;
|
|
119
119
|
} catch (b) {
|
|
120
|
-
throw
|
|
120
|
+
throw k.isEditorClosing = !1, k.isSubmitted = !1, b;
|
|
121
121
|
}
|
|
122
|
-
}, [i]),
|
|
123
|
-
|
|
124
|
-
}, [
|
|
125
|
-
|
|
126
|
-
}, []),
|
|
127
|
-
if (
|
|
128
|
-
const b = n?.getCellCoordsFromClient(
|
|
129
|
-
b &&
|
|
130
|
-
}, [n]), Pt =
|
|
131
|
-
const b =
|
|
132
|
-
|
|
133
|
-
}, [n]), Et =
|
|
134
|
-
if (
|
|
122
|
+
}, [i]), $ = P((k) => {
|
|
123
|
+
Q(!1), w?.(k.coords), D();
|
|
124
|
+
}, [w]), p = se(null), Ne = se(null), Xe = se(null), Z = se([]), [be, Y] = Zn((k) => k + 1, 0), D = V((k) => {
|
|
125
|
+
k && Z.current.push(k), Y();
|
|
126
|
+
}, []), q = P((k) => {
|
|
127
|
+
if (k.defaultPrevented || k.isSynthetic || !n) return;
|
|
128
|
+
const b = n?.getCellCoordsFromClient(k.clientX, k.clientY);
|
|
129
|
+
b && D({ eventType: "pointer", event: k, coords: b });
|
|
130
|
+
}, [n]), Pt = P((k) => {
|
|
131
|
+
const b = k.nativeEvent;
|
|
132
|
+
q(b);
|
|
133
|
+
}, [n]), Et = P((k) => {
|
|
134
|
+
if (k.defaultPrevented || k.isSynthetic || !n?.getStage()) return;
|
|
135
135
|
const b = Ne.current;
|
|
136
|
-
|
|
136
|
+
L(k, b) && (k.stopPropagation(), k.preventDefault()), k.key, D({ eventType: "keyboard", event: k, coords: b });
|
|
137
137
|
}, [n]);
|
|
138
138
|
en(() => {
|
|
139
|
-
const
|
|
140
|
-
const Ue =
|
|
139
|
+
const k = (ne, we) => {
|
|
140
|
+
const Ue = we?.cell ?? ne;
|
|
141
141
|
if (!Ue) return null;
|
|
142
142
|
const lt = Ue;
|
|
143
|
-
if (!
|
|
144
|
-
|
|
143
|
+
if (!W(Ue)) return null;
|
|
144
|
+
ke?.(Ue);
|
|
145
145
|
const Mt = Nt.uuidV4();
|
|
146
|
-
|
|
147
|
-
const it = { coords: lt, startEvent:
|
|
148
|
-
it.isMounted || (it.isMounted = !0,
|
|
149
|
-
}, onUnmount: (
|
|
146
|
+
we = Object.freeze({ autoFocus: !0, ...we }), Xe.current = Ue;
|
|
147
|
+
const it = { coords: lt, startEvent: we, uuid: Mt, isMounted: !1, isStarted: !1, isSubmitted: !1, isEditorSubmitted: !1, isEditorClosing: !1, isEditorClosed: !1, isCancelled: !1, events: [], editorRefsDispatchEditorEvent: [], editorRefs: [], onMount: (qt) => {
|
|
148
|
+
it.isMounted || (it.isMounted = !0, D());
|
|
149
|
+
}, onUnmount: (qt) => {
|
|
150
150
|
if (it.editorRefs.length === 0) {
|
|
151
|
-
const
|
|
152
|
-
it.isMounted = !1,
|
|
151
|
+
const xt = () => {
|
|
152
|
+
it.isMounted = !1, D();
|
|
153
153
|
};
|
|
154
|
-
if (document.activeElement !== document.body)
|
|
154
|
+
if (document.activeElement !== document.body) xt();
|
|
155
155
|
else {
|
|
156
|
-
const v = (
|
|
157
|
-
|
|
156
|
+
const v = (oe) => {
|
|
157
|
+
oe.defaultPrevented || oe.target !== document.body || Et(oe);
|
|
158
158
|
};
|
|
159
159
|
window.addEventListener("keydown", v, !0), n.getStage()?.addEventListener("focusin", () => {
|
|
160
|
-
window.removeEventListener("keydown", v),
|
|
161
|
-
},
|
|
160
|
+
window.removeEventListener("keydown", v), xt();
|
|
161
|
+
}, Uo), me();
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
} };
|
|
165
165
|
return it;
|
|
166
166
|
};
|
|
167
|
-
if (
|
|
168
|
-
const b =
|
|
169
|
-
|
|
170
|
-
const
|
|
167
|
+
if (Z.current.length <= 0 && !p.current) return;
|
|
168
|
+
const b = Z.current[0];
|
|
169
|
+
eo(b), ((ne) => {
|
|
170
|
+
const we = [], Ue = ne?.length ?? 0;
|
|
171
171
|
for (let lt = 0; lt < Ue; lt++) {
|
|
172
|
-
const Mt =
|
|
173
|
-
|
|
172
|
+
const Mt = ne[lt];
|
|
173
|
+
we.push(eo(Mt));
|
|
174
174
|
}
|
|
175
|
-
})(
|
|
176
|
-
let
|
|
175
|
+
})(Z.current), p.current, p.current;
|
|
176
|
+
let Re = p.current;
|
|
177
177
|
if (p.current) {
|
|
178
178
|
if (p.current.isDone) p.current = null;
|
|
179
179
|
else if (p.current.isSubmitted || p.current.isCancelled) {
|
|
180
180
|
if (p.current.isMounted) return;
|
|
181
|
-
p.current.isDone || (
|
|
181
|
+
p.current.isDone || ($(p.current), p.current.isDone = !0);
|
|
182
182
|
}
|
|
183
183
|
}
|
|
184
184
|
if (b) {
|
|
185
185
|
if (b.eventType === "start") {
|
|
186
|
-
const
|
|
187
|
-
p.current &&
|
|
186
|
+
const ne = b, we = ne.startEvent?.cell ?? Ne.current;
|
|
187
|
+
p.current && F.isEqualCells(p.current.coords, we) || (p.current = k(we, ne.startEvent));
|
|
188
188
|
} else if (b.eventType === "keyboard") {
|
|
189
|
-
const
|
|
189
|
+
const ne = b.event;
|
|
190
190
|
if (p.current) {
|
|
191
|
-
let
|
|
192
|
-
switch (
|
|
191
|
+
let we = !1;
|
|
192
|
+
switch (ne.which) {
|
|
193
193
|
case Ot.Left:
|
|
194
194
|
case Ot.Right:
|
|
195
195
|
case Ot.Up:
|
|
196
196
|
case Ot.Down:
|
|
197
197
|
case Ot.Enter:
|
|
198
198
|
case Ot.Tab:
|
|
199
|
-
|
|
199
|
+
we = !0;
|
|
200
200
|
}
|
|
201
|
-
if (!
|
|
201
|
+
if (!we) {
|
|
202
202
|
p.current.events.push(b);
|
|
203
203
|
for (let Ue = 0; Ue < p.current.editorRefsDispatchEditorEvent.length; Ue++) p.current.editorRefsDispatchEditorEvent[Ue](b);
|
|
204
204
|
}
|
|
205
|
-
} else if (
|
|
206
|
-
let
|
|
207
|
-
const Ue =
|
|
205
|
+
} else if (L(ne, b.coords)) {
|
|
206
|
+
let we;
|
|
207
|
+
const Ue = k(we?.cell ?? Ne.current, we);
|
|
208
208
|
Ue && Ue.events.push(b), p.current = Ue;
|
|
209
209
|
}
|
|
210
210
|
} else if (b.eventType === "pointer") {
|
|
211
|
-
const
|
|
211
|
+
const ne = b.event;
|
|
212
212
|
if (p.current) {
|
|
213
213
|
p.current.events.push(b);
|
|
214
|
-
for (let
|
|
214
|
+
for (let we = 0; we < p.current.editorRefsDispatchEditorEvent.length; we++) p.current.editorRefsDispatchEditorEvent[we](b);
|
|
215
215
|
} else {
|
|
216
|
-
const
|
|
216
|
+
const we = b?.coords ?? Ne.current, Ue = O(ne, we);
|
|
217
217
|
if (Ue) {
|
|
218
218
|
let lt;
|
|
219
219
|
typeof lt != "boolean" && (lt = Ue);
|
|
220
|
-
const Mt =
|
|
220
|
+
const Mt = k(we, lt);
|
|
221
221
|
Mt && Mt.events.push(b), p.current = Mt;
|
|
222
222
|
}
|
|
223
223
|
}
|
|
@@ -229,11 +229,11 @@ const dn = ({ itemType: t, index: n, itemSize: o, instanceProps: r, scale: c = 1
|
|
|
229
229
|
} else if (b.eventType === "cancel") {
|
|
230
230
|
if (p.current && !p.current.isSubmitted && !p.current.isCancelled) {
|
|
231
231
|
if (!p.current.isMounted) return;
|
|
232
|
-
|
|
232
|
+
ue(p.current);
|
|
233
233
|
}
|
|
234
234
|
} else if (b.eventType === "coordsChange") {
|
|
235
|
-
const
|
|
236
|
-
if (Ne.current =
|
|
235
|
+
const ne = b;
|
|
236
|
+
if (Ne.current = ne.activeCoords, p.current, p.current && !p.current.isSubmitted && !p.current.isCancelled) {
|
|
237
237
|
if (!p.current.isMounted) return;
|
|
238
238
|
try {
|
|
239
239
|
ye(p.current);
|
|
@@ -242,390 +242,339 @@ const dn = ({ itemType: t, index: n, itemSize: o, instanceProps: r, scale: c = 1
|
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
|
-
|
|
245
|
+
Z.current.length > 0 && (Z.current.shift(), D()), Z.current.length === 0 && (!p.current || p.current.isEditorClosing || p.current.isEditorClosed ? !p.current && Re && me() : p.current.isMounted && !p.current.isStarted && (p.current.isStarted = !0, p.current.startEvent.autoFocus && (typeof p.current.startEvent.autoFocus == "string" ? p.current.editorRefs[0]?.autoFocus(p.current.startEvent.autoFocus) : p.current.editorRefs[0]?.autoFocus()), We?.(p.current), requestAnimationFrame(() => {
|
|
246
246
|
n && p.current?.coords && n.scrollCellCoordsIntoView(p.current.coords);
|
|
247
247
|
})));
|
|
248
|
-
}, [be]),
|
|
249
|
-
Xe.current =
|
|
250
|
-
const
|
|
251
|
-
|
|
252
|
-
}, [
|
|
253
|
-
const
|
|
254
|
-
Et(
|
|
255
|
-
}, []), { width:
|
|
256
|
-
return { overlay:
|
|
248
|
+
}, [be]), It(() => {
|
|
249
|
+
Xe.current = J;
|
|
250
|
+
const k = p.current?.coords;
|
|
251
|
+
F.isEqualCells(k, J) || (p.current && (p.current.isEditorClosing = !0), D({ eventType: "coordsChange", activeCoords: J }));
|
|
252
|
+
}, [J]);
|
|
253
|
+
const wt = V((k) => {
|
|
254
|
+
Et(k.nativeEvent);
|
|
255
|
+
}, []), { width: ut = 0, height: he = 0 } = T ?? { width: 0, height: 0 }, Wt = P(r, [r]);
|
|
256
|
+
return { overlay: P((k) => {
|
|
257
257
|
if (!p.current || p.current.isEditorClosed) return p.current, null;
|
|
258
258
|
p.current.coords;
|
|
259
|
-
let b =
|
|
260
|
-
b && b.width !== 0 && b.height !== 0 || (b = { x: 0, y: 0, width:
|
|
261
|
-
const
|
|
262
|
-
return Ce(
|
|
263
|
-
}, [r,
|
|
264
|
-
|
|
265
|
-
}, []), submitEdit:
|
|
266
|
-
|
|
267
|
-
}, []), cancelEdit:
|
|
268
|
-
|
|
269
|
-
}, []), onKeyboardEvent:
|
|
270
|
-
},
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
var t = ut(null), n = t[0], o = t[1], r = ut(no), c = r[0], s = r[1], i = Ae(function() {
|
|
275
|
-
return new window.ResizeObserver(function(l) {
|
|
276
|
-
if (l[0]) {
|
|
277
|
-
var h = l[0].contentRect, O = h.x, z = h.y, M = h.width, R = h.height, $ = h.top, Y = h.left, q = h.bottom, _ = h.right;
|
|
278
|
-
s({ x: O, y: z, width: M, height: R, top: $, left: Y, bottom: q, right: _ });
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
}, []);
|
|
282
|
-
return Ko(function() {
|
|
283
|
-
if (n) return i.observe(n), function() {
|
|
284
|
-
i.disconnect();
|
|
285
|
-
};
|
|
286
|
-
}, [n]), [o, c];
|
|
287
|
-
} : function() {
|
|
288
|
-
return [No, no];
|
|
289
|
-
}, jo = 3, qo = 0.5, Yo = 50, Kn = (t) => ({ x: t.x, y: t.y, width: t.width, height: t.height, top: t.top, left: t.left, right: t.right, bottom: t.bottom });
|
|
290
|
-
function Xo(t = {}) {
|
|
291
|
-
const { threshold: n = qo, stillnessThreshold: o = jo, maxHierarchyDepth: r = Yo } = t, [c, s] = yo(), i = ie(null), [l, h] = zn((Y) => Y + 1, 0), O = ie(void 0), z = ie({ x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, right: 0, bottom: 0 }), M = W((Y) => {
|
|
292
|
-
i.current = Y, typeof c == "function" && c(Y);
|
|
293
|
-
}, [c]), [R, $] = ut(s);
|
|
294
|
-
return wt(() => {
|
|
295
|
-
s && !R && $(s);
|
|
296
|
-
}, [s, R]), wt(() => {
|
|
297
|
-
const Y = i.current;
|
|
298
|
-
if (!Y) return;
|
|
299
|
-
let q = !1, _ = 0;
|
|
300
|
-
const Ie = () => {
|
|
301
|
-
if (!Y) return;
|
|
302
|
-
const P = Y.getBoundingClientRect(), ce = z.current;
|
|
303
|
-
Math.abs(P.x - ce.x) > n || Math.abs(P.y - ce.y) > n || Math.abs(P.width - ce.width) > n || Math.abs(P.height - ce.height) > n ? (q || (q = !0, $(Kn(P)), h()), _ = 0) : _++, q && _ >= o && (q = !1, $(Kn(P)), h()), z.current = Kn(P), O.current = requestAnimationFrame(Ie);
|
|
304
|
-
};
|
|
305
|
-
O.current = requestAnimationFrame(Ie);
|
|
306
|
-
const Z = (P) => {
|
|
307
|
-
q = !0, h();
|
|
308
|
-
}, k = (P) => {
|
|
309
|
-
q = !1, _ = o, h();
|
|
310
|
-
};
|
|
311
|
-
let U = Y;
|
|
312
|
-
const he = [];
|
|
313
|
-
for (; U && U !== document.documentElement && (U.addEventListener("animationstart", Z, !0), U.addEventListener("animationend", k, !0), U.addEventListener("transitionstart", Z, !0), U.addEventListener("transitionend", k, !0), he.push(U), U = U.parentElement, !(he.length > r)); ) ;
|
|
314
|
-
return () => {
|
|
315
|
-
O.current && cancelAnimationFrame(O.current), he.forEach((P) => {
|
|
316
|
-
P.removeEventListener("animationstart", Z, !0), P.removeEventListener("animationend", k, !0), P.removeEventListener("transitionstart", Z, !0), P.removeEventListener("transitionend", k, !0);
|
|
317
|
-
});
|
|
318
|
-
};
|
|
319
|
-
}, [l, s, n, o, r]), [M, R];
|
|
320
|
-
}
|
|
321
|
-
const yr = ({ gridRef: t, gridMainRef: n, orientation: o = Ht.Row, headerCount: r, selectionPolicy: c = "multiple", newSelectionMode: s = "clear", alwaysScrollToActiveCoords: i = !0, onDragStart: l, onDragEnd: h, pointerDownInterceptor: O, pointerMoveInterceptor: z, onPointerUp: M, newSelection: R, modifySelection: $, appendSelection: Y, clearSelections: q }) => {
|
|
322
|
-
const _ = r ?? ((o === Ht.Row ? t.current?.rowCount : t.current?.columnCount) || 0), Ie = ie(null), Z = ie(null), k = ie(!1), U = ie(null), he = W((A) => o === Ht.Column ? { rowIndex: 0, colIndex: A.colIndex } : { rowIndex: A.rowIndex, colIndex: 0 }, [o]), P = W((A) => o === Ht.Column ? { rowIndex: n.current ? n.current.rowCount - 1 : 0, colIndex: A.colIndex } : { rowIndex: A.rowIndex, colIndex: n.current ? n.current.columnCount - 1 : 0 }, [o]), ce = (A) => {
|
|
323
|
-
Z.current = P(A), $(Z.current, Ie.current);
|
|
324
|
-
}, Ve = W((A, p) => {
|
|
259
|
+
let b = ve(k, p.current.coords, ut, he, le, te), Re = !0;
|
|
260
|
+
b && b.width !== 0 && b.height !== 0 || (b = { x: 0, y: 0, width: ut, height: ut }, Re = !1);
|
|
261
|
+
const ne = k.getZoom(), we = { containerBounds: { x: 0, y: 0, width: b.width / ne, height: b.height / ne }, setNaturalSize: _, zoom: ne };
|
|
262
|
+
return Ce(Wo, { session: p.current, refLatestCoords: Xe, handleSubmitEdit: ye, handleCancelEdit: ue, cellBounds: b, borderStrokeWidth: A, borderStrokeFill: M, isInBounds: Re, getCellEditor: Wt, propsEditor: we, alignment: te, ...R }, "editor:" + p.current.uuid);
|
|
263
|
+
}, [r, le, be, ut, he, te, A, M]), startEdit: V((k) => {
|
|
264
|
+
D({ eventType: "start", startEvent: k });
|
|
265
|
+
}, []), submitEdit: V(() => {
|
|
266
|
+
D({ eventType: "submit" });
|
|
267
|
+
}, []), cancelEdit: V(() => {
|
|
268
|
+
D({ eventType: "cancel" });
|
|
269
|
+
}, []), onKeyboardEvent: wt, onPointerEvent: Pt, onKeyboardEventNative: Et, onPointerEventNative: q, isEditing: ze };
|
|
270
|
+
}, Uo = Object.freeze({ once: !0 }), pr = ({ gridRef: t, gridMainRef: n, orientation: o = Ht.Row, headerCount: r, selectionPolicy: c = "multiple", newSelectionMode: d = "clear", alwaysScrollToActiveCoords: i = !0, onDragStart: l, onDragEnd: w, pointerDownInterceptor: L, pointerMoveInterceptor: O, onPointerUp: R, newSelection: M, modifySelection: A, appendSelection: le, clearSelections: J }) => {
|
|
271
|
+
const te = r ?? ((o === Ht.Row ? t.current?.rowCount : t.current?.columnCount) || 0), ze = se(null), Q = se(null), T = se(!1), _ = se(null), ve = V(($) => o === Ht.Column ? { rowIndex: 0, colIndex: $.colIndex } : { rowIndex: $.rowIndex, colIndex: 0 }, [o]), W = V(($) => o === Ht.Column ? { rowIndex: n.current ? n.current.rowCount - 1 : 0, colIndex: $.colIndex } : { rowIndex: $.rowIndex, colIndex: n.current ? n.current.columnCount - 1 : 0 }, [o]), me = ($) => {
|
|
272
|
+
Q.current = W($), A(Q.current, ze.current);
|
|
273
|
+
}, Ve = V(($, p) => {
|
|
325
274
|
if (!t.current) return;
|
|
326
|
-
const Ne = t.current.getViewFromClient(
|
|
275
|
+
const Ne = t.current.getViewFromClient($, p)?.getCellCoordsFromClient($, p);
|
|
327
276
|
return Ne ? (o === Ht.Column ? Ne.rowIndex = n.current.getViewport().rowStart : Ne.colIndex = n.current.getViewport().colStart, Ne) : void 0;
|
|
328
|
-
}, []),
|
|
329
|
-
let Ne =
|
|
330
|
-
return p || (Ne = {
|
|
331
|
-
}, [o]), We =
|
|
332
|
-
if (!t || !t.current ||
|
|
333
|
-
const p = Ve(
|
|
277
|
+
}, []), ke = V(($, p = !1) => {
|
|
278
|
+
let Ne = $;
|
|
279
|
+
return p || (Ne = { ...$ }, o === Ht.Row ? delete Ne.colIndex : delete Ne.rowIndex), n.current?.scrollCellCoordsIntoView(Ne);
|
|
280
|
+
}, [o]), We = P(w, [w]), ue = P(l, [l]), ye = Ae(() => ({ onPointerDown: ($) => {
|
|
281
|
+
if (!t || !t.current || $.nativeEvent.defaultPrevented) return;
|
|
282
|
+
const p = Ve($.nativeEvent.clientX, $.nativeEvent.clientY);
|
|
334
283
|
if (!p) return;
|
|
335
|
-
|
|
336
|
-
const Ne =
|
|
337
|
-
if (
|
|
338
|
-
|
|
339
|
-
const
|
|
340
|
-
if (Ne)
|
|
284
|
+
$.nativeEvent.which, jn.Right;
|
|
285
|
+
const Ne = $.nativeEvent.shiftKey, Xe = $.nativeEvent.ctrlKey || $.nativeEvent.metaKey;
|
|
286
|
+
if (L?.($, p) === !1) return;
|
|
287
|
+
ue?.(), T.current = !0;
|
|
288
|
+
const Z = n.current?.getViewFromClient($.nativeEvent.clientX, $.nativeEvent.clientY), be = ((Y, D) => o === Ht.Column ? { ...Y, rowIndex: D.rowStart } : { ...Y, colIndex: D.colStart })(p, Z.getVisibleRangeCoords());
|
|
289
|
+
if (Ne) me(p);
|
|
341
290
|
else {
|
|
342
|
-
if (Xe) return ((
|
|
343
|
-
|
|
344
|
-
})(p, p, be), void (i &&
|
|
345
|
-
((
|
|
346
|
-
|
|
347
|
-
})(p, p, be),
|
|
291
|
+
if (Xe) return ((Y, D = Y, q) => {
|
|
292
|
+
ze.current = ve(Y), Q.current = W(D), le(ze.current, Q.current, q);
|
|
293
|
+
})(p, p, be), void (i && ke(be, !0));
|
|
294
|
+
((Y, D = Y, q) => {
|
|
295
|
+
ze.current = ve(Y), Q.current = W(D), M(ze.current, Q.current, q);
|
|
296
|
+
})(p, p, be), me(p), i && ke(be, !0);
|
|
348
297
|
}
|
|
349
|
-
}, onPointerMoveOrWait: Nt.throttle((
|
|
350
|
-
if (!
|
|
351
|
-
const p = Ve(
|
|
352
|
-
if (p &&
|
|
353
|
-
if (
|
|
354
|
-
|
|
298
|
+
}, onPointerMoveOrWait: Nt.throttle(($) => {
|
|
299
|
+
if (!T.current || !t?.current) return;
|
|
300
|
+
const p = Ve($.clientX, $.clientY);
|
|
301
|
+
if (p && O?.($, p) !== !1) {
|
|
302
|
+
if (F.isEqualCells(_.current, p)) return J();
|
|
303
|
+
me(p), ke(p);
|
|
355
304
|
}
|
|
356
|
-
}, 60), onPointerUp: (
|
|
357
|
-
|
|
358
|
-
}, processTouch: !0, consumeTouch: !0 }), [c, i,
|
|
359
|
-
return { onPointerDown:
|
|
305
|
+
}, 60), onPointerUp: ($) => {
|
|
306
|
+
T.current = !1, We?.(), R?.($);
|
|
307
|
+
}, processTouch: !0, consumeTouch: !0 }), [c, i, te, d, J, L, R]);
|
|
308
|
+
return { onPointerDown: P(un(ye), []), getCellCoordsFromClient: Ve };
|
|
360
309
|
}, Fe = (t, n, o) => {
|
|
361
310
|
if (!t) return n;
|
|
362
311
|
let r = n;
|
|
363
|
-
const c = o ===
|
|
312
|
+
const c = o === g.Right || o === g.Down;
|
|
364
313
|
for (; ; ) {
|
|
365
|
-
const
|
|
366
|
-
if (
|
|
367
|
-
c ? r +=
|
|
314
|
+
const d = t(r, !c);
|
|
315
|
+
if (d === 0) return r;
|
|
316
|
+
c ? r += d : r -= d;
|
|
368
317
|
}
|
|
369
318
|
}, Pn = (t, n, o) => {
|
|
370
319
|
const r = [];
|
|
371
320
|
let c = n;
|
|
372
321
|
for (; c <= o; ) {
|
|
373
|
-
const
|
|
374
|
-
|
|
322
|
+
const d = Math.max(0, t(c));
|
|
323
|
+
d === 0 ? (r.push(c), c++) : c += d;
|
|
375
324
|
}
|
|
376
325
|
return r;
|
|
377
|
-
},
|
|
378
|
-
if (!n) return
|
|
326
|
+
}, Ho = (t, n, o, r, c, d) => {
|
|
327
|
+
if (!n) return d;
|
|
379
328
|
let { rowIndex: i, colIndex: l } = t;
|
|
380
329
|
switch (r) {
|
|
381
|
-
case
|
|
382
|
-
i = Fe(o, Math.min(i + 1,
|
|
383
|
-
let
|
|
384
|
-
for (; !
|
|
330
|
+
case g.Down: {
|
|
331
|
+
i = Fe(o, Math.min(i + 1, d), r);
|
|
332
|
+
let w = n({ rowIndex: i, colIndex: l });
|
|
333
|
+
for (; !w && i < d; ) i = Fe(o, Math.min(++i, d), r), w = n({ rowIndex: i, colIndex: l });
|
|
385
334
|
return i;
|
|
386
335
|
}
|
|
387
|
-
case
|
|
388
|
-
i = Fe(o, Math.max(i - 1,
|
|
389
|
-
let
|
|
390
|
-
for (; !
|
|
336
|
+
case g.Up: {
|
|
337
|
+
i = Fe(o, Math.max(i - 1, d), r);
|
|
338
|
+
let w = n({ rowIndex: i, colIndex: l });
|
|
339
|
+
for (; !w && i > d; ) i = Fe(o, Math.max(--i, d), r), w = n({ rowIndex: i, colIndex: l });
|
|
391
340
|
return i;
|
|
392
341
|
}
|
|
393
|
-
case
|
|
394
|
-
l = Fe(o, Math.min(l + 1,
|
|
395
|
-
let
|
|
396
|
-
for (; !
|
|
342
|
+
case g.Right: {
|
|
343
|
+
l = Fe(o, Math.min(l + 1, d), r);
|
|
344
|
+
let w = n({ rowIndex: i, colIndex: l });
|
|
345
|
+
for (; !w && l < d; ) l = Fe(o, Math.min(++l, d), r), w = n({ rowIndex: i, colIndex: l });
|
|
397
346
|
return l;
|
|
398
347
|
}
|
|
399
|
-
case
|
|
400
|
-
l = Fe(o, Math.max(l - 1,
|
|
401
|
-
let
|
|
402
|
-
for (; !
|
|
348
|
+
case g.Left: {
|
|
349
|
+
l = Fe(o, Math.max(l - 1, d), r);
|
|
350
|
+
let w = n({ rowIndex: i, colIndex: l });
|
|
351
|
+
for (; !w && l > d; ) l = Fe(o, Math.max(--l, d), r), w = n({ rowIndex: i, colIndex: l });
|
|
403
352
|
return l;
|
|
404
353
|
}
|
|
405
354
|
default:
|
|
406
|
-
return
|
|
355
|
+
return d;
|
|
407
356
|
}
|
|
408
|
-
},
|
|
357
|
+
}, No = (t, n = () => !0, o, r, c, d) => {
|
|
409
358
|
let { rowIndex: i, colIndex: l } = t;
|
|
410
359
|
switch (r) {
|
|
411
|
-
case
|
|
412
|
-
i = Fe(o, Math.min(i + 1,
|
|
413
|
-
let
|
|
414
|
-
for (;
|
|
360
|
+
case g.Down: {
|
|
361
|
+
i = Fe(o, Math.min(i + 1, d), r);
|
|
362
|
+
let w = n?.({ rowIndex: i, colIndex: l });
|
|
363
|
+
for (; w && i < d; ) i = Fe(o, Math.min(++i, d), r), w = n?.({ rowIndex: i, colIndex: l });
|
|
415
364
|
return n?.({ rowIndex: i, colIndex: l }) ? i : i - 1;
|
|
416
365
|
}
|
|
417
|
-
case
|
|
418
|
-
i = Fe(o, Math.max(i - 1,
|
|
419
|
-
let
|
|
420
|
-
for (;
|
|
366
|
+
case g.Up: {
|
|
367
|
+
i = Fe(o, Math.max(i - 1, d), r);
|
|
368
|
+
let w = n?.({ rowIndex: i, colIndex: l });
|
|
369
|
+
for (; w && i > d; ) i = Fe(o, Math.max(--i, d), r), w = n?.({ rowIndex: i, colIndex: l });
|
|
421
370
|
return n?.({ rowIndex: i, colIndex: l }) ? i : i + 1;
|
|
422
371
|
}
|
|
423
|
-
case
|
|
424
|
-
l = Fe(o, Math.min(l + 1,
|
|
425
|
-
let
|
|
426
|
-
for (;
|
|
372
|
+
case g.Right: {
|
|
373
|
+
l = Fe(o, Math.min(l + 1, d), r);
|
|
374
|
+
let w = n?.({ rowIndex: i, colIndex: l });
|
|
375
|
+
for (; w && l < d; ) l = Fe(o, Math.min(++l, d), r), w = n?.({ rowIndex: i, colIndex: l });
|
|
427
376
|
return n?.({ rowIndex: i, colIndex: l }) ? l : l - 1;
|
|
428
377
|
}
|
|
429
|
-
case
|
|
430
|
-
l = Fe(o, Math.max(l - 1,
|
|
431
|
-
let
|
|
432
|
-
for (;
|
|
378
|
+
case g.Left: {
|
|
379
|
+
l = Fe(o, Math.max(l - 1, d), r);
|
|
380
|
+
let w = n?.({ rowIndex: i, colIndex: l });
|
|
381
|
+
for (; w && l > d; ) l = Fe(o, Math.max(--l, d), r), w = n?.({ rowIndex: i, colIndex: l });
|
|
433
382
|
return n?.({ rowIndex: i, colIndex: l }) ? l : l + 1;
|
|
434
383
|
}
|
|
435
384
|
default:
|
|
436
385
|
return null;
|
|
437
386
|
}
|
|
438
|
-
},
|
|
439
|
-
if (!n) return
|
|
440
|
-
let i, { rowIndex: l, colIndex:
|
|
441
|
-
r ===
|
|
442
|
-
const
|
|
443
|
-
var
|
|
444
|
-
return (
|
|
445
|
-
},
|
|
387
|
+
}, Ko = (t, n, o, r, c, d) => {
|
|
388
|
+
if (!n) return d;
|
|
389
|
+
let i, { rowIndex: l, colIndex: w } = t;
|
|
390
|
+
r === g.Down ? i = { rowIndex: l + 1, colIndex: w } : r === g.Up ? i = { rowIndex: l - 1, colIndex: w } : r === g.Right ? i = { rowIndex: l, colIndex: w + 1 } : r === g.Left && (i = { rowIndex: l, colIndex: w - 1 });
|
|
391
|
+
const L = n(t), O = n(i);
|
|
392
|
+
var R, M;
|
|
393
|
+
return (M = O, !(R = L) && !M || !R && M || R && !M ? Ho : No)(t, n, o, r, !1, d) ?? d;
|
|
394
|
+
}, to = (t, n) => `${t}:${n}`, no = (t, n, o, r, c, d) => {
|
|
446
395
|
if (o - n >= c - r) return r;
|
|
447
396
|
let i = r;
|
|
448
|
-
return t === "nearest" && (r - n > 0 ? t = "start" : o - c > 0 && (t = "end")), t === "start" ? i = n : t === "end" ? i = o - (c - r) : t === "center" && (i = n + (o - n) / 2 - (c - r) / 2), i < r ? Math.max(0, i) : i > r ? Math.min(i,
|
|
449
|
-
},
|
|
450
|
-
if (
|
|
397
|
+
return t === "nearest" && (r - n > 0 ? t = "start" : o - c > 0 && (t = "end")), t === "start" ? i = n : t === "end" ? i = o - (c - r) : t === "center" && (i = n + (o - n) / 2 - (c - r) / 2), i < r ? Math.max(0, i) : i > r ? Math.min(i, d - (c - r)) : void 0;
|
|
398
|
+
}, oo = (t, n, o, r) => (console.log("todo: implement convertToVisibleRanges"), t), Yn = (t, n = g.Right, o, r, c, d = null) => {
|
|
399
|
+
if (d && F.isEqualSelectionCoords(d, t)) return t;
|
|
451
400
|
const i = t.ranges[t.rangeIndex];
|
|
452
|
-
if (!
|
|
453
|
-
let l = { ...t.cell },
|
|
401
|
+
if (!F.isRangesIntersect({ rowStart: t.cell.rowIndex, colStart: t.cell.colIndex, rowEnd: t.cell.rowIndex, colEnd: t.cell.colIndex }, i)) return t;
|
|
402
|
+
let l = { ...t.cell }, w = t.rangeIndex;
|
|
454
403
|
switch (n) {
|
|
455
|
-
case
|
|
404
|
+
case g.Right:
|
|
456
405
|
l.colIndex = Fe(c, l.colIndex + 1, n);
|
|
457
406
|
break;
|
|
458
|
-
case
|
|
407
|
+
case g.Left:
|
|
459
408
|
l.colIndex = Fe(c, l.colIndex - 1, n);
|
|
460
409
|
break;
|
|
461
|
-
case
|
|
410
|
+
case g.Down:
|
|
462
411
|
l.rowIndex = Fe(r, l.rowIndex + 1, n);
|
|
463
412
|
break;
|
|
464
|
-
case
|
|
413
|
+
case g.Up:
|
|
465
414
|
l.rowIndex = Fe(r, l.rowIndex - 1, n);
|
|
466
415
|
}
|
|
467
|
-
const
|
|
468
|
-
if (
|
|
469
|
-
|
|
470
|
-
const
|
|
471
|
-
l = { colIndex:
|
|
416
|
+
const L = (M) => {
|
|
417
|
+
if (M) {
|
|
418
|
+
w = t.rangeIndex >= t.ranges.length - 1 ? 0 : t.rangeIndex + 1;
|
|
419
|
+
const A = t.ranges[w];
|
|
420
|
+
l = { colIndex: A.colStart, rowIndex: A.rowStart };
|
|
472
421
|
} else {
|
|
473
|
-
|
|
474
|
-
const
|
|
475
|
-
l = { colIndex:
|
|
422
|
+
w = t.rangeIndex <= 0 ? t.ranges.length - 1 : t.rangeIndex - 1;
|
|
423
|
+
const A = t.ranges[w];
|
|
424
|
+
l = { colIndex: A.colEnd, rowIndex: A.rowEnd };
|
|
476
425
|
}
|
|
477
426
|
};
|
|
478
|
-
if (n ===
|
|
479
|
-
else if (n ===
|
|
480
|
-
else if (n ===
|
|
481
|
-
else if (n ===
|
|
427
|
+
if (n === g.Right && l.colIndex > i.colEnd && l.rowIndex === i.rowEnd) L(!0);
|
|
428
|
+
else if (n === g.Left && l.colIndex < i.colStart && l.rowIndex === i.rowStart) L(!1);
|
|
429
|
+
else if (n === g.Down && l.colIndex === i.colEnd && l.rowIndex > i.rowEnd) L(!0);
|
|
430
|
+
else if (n === g.Up && l.colIndex === i.colStart && l.rowIndex < i.rowStart) L(!1);
|
|
482
431
|
else {
|
|
483
|
-
let
|
|
432
|
+
let M = l.rowIndex, A = l.colIndex;
|
|
484
433
|
switch (n) {
|
|
485
|
-
case
|
|
486
|
-
|
|
434
|
+
case g.Right:
|
|
435
|
+
A > i.colEnd && (M = Fe(r, M + 1, n), A = i.colStart, M > i.rowEnd && (M = i.rowStart));
|
|
487
436
|
break;
|
|
488
|
-
case
|
|
489
|
-
|
|
437
|
+
case g.Left:
|
|
438
|
+
A < i.colStart && (M = Fe(r, M - 1, n), A = i.colEnd, M < i.rowStart && (M = i.rowEnd));
|
|
490
439
|
break;
|
|
491
|
-
case
|
|
492
|
-
|
|
440
|
+
case g.Down:
|
|
441
|
+
M > i.rowEnd && (A = Fe(c, A + 1, n), M = i.rowStart, A > i.colEnd && (A = i.colStart));
|
|
493
442
|
break;
|
|
494
|
-
case
|
|
495
|
-
|
|
443
|
+
case g.Up:
|
|
444
|
+
M < i.rowStart && (A = Fe(c, A - 1, n), M = i.rowEnd, A < i.colStart && (A = i.colEnd));
|
|
496
445
|
}
|
|
497
|
-
l = { rowIndex:
|
|
446
|
+
l = { rowIndex: M, colIndex: A };
|
|
498
447
|
}
|
|
499
|
-
let
|
|
500
|
-
if (!
|
|
501
|
-
const
|
|
502
|
-
|
|
448
|
+
let O = o(l);
|
|
449
|
+
if (!F.isRangeWithinRange(O, i)) {
|
|
450
|
+
const M = F.intersectRanges(O, i);
|
|
451
|
+
M && (O = M);
|
|
503
452
|
}
|
|
504
|
-
let
|
|
505
|
-
if (
|
|
453
|
+
let R = { rowStart: Fe(r, O.rowStart, g.Down), colStart: Fe(c, O.colStart, g.Right), rowEnd: Fe(r, O.rowEnd, g.Up), colEnd: Fe(c, O.colEnd, g.Left) };
|
|
454
|
+
if (R.rowStart !== l.rowIndex || R.colStart !== l.colIndex) {
|
|
506
455
|
switch (n) {
|
|
507
|
-
case
|
|
508
|
-
t.ranges[
|
|
456
|
+
case g.Right:
|
|
457
|
+
t.ranges[w].colStart === R.colStart && t.ranges[w].colEnd === R.colEnd && (l.rowIndex = R.rowEnd), l.colIndex = R.colEnd;
|
|
509
458
|
break;
|
|
510
|
-
case
|
|
511
|
-
t.ranges[
|
|
459
|
+
case g.Left:
|
|
460
|
+
t.ranges[w].colStart === R.colStart && t.ranges[w].colEnd === R.colEnd && (l.rowIndex = R.rowStart), l.rowIndex === R.rowStart ? l.colIndex = R.colStart + 1 : l.colIndex = R.colStart;
|
|
512
461
|
break;
|
|
513
|
-
case
|
|
514
|
-
t.ranges[
|
|
462
|
+
case g.Down:
|
|
463
|
+
t.ranges[w].rowStart === R.rowStart && t.ranges[w].rowEnd === R.rowEnd && (l.colIndex = R.colEnd), l.rowIndex = R.rowEnd;
|
|
515
464
|
break;
|
|
516
|
-
case
|
|
517
|
-
t.ranges[
|
|
465
|
+
case g.Up:
|
|
466
|
+
t.ranges[w].rowStart === R.rowStart && t.ranges[w].rowEnd === R.rowEnd && (l.colIndex = R.colStart), l.colIndex === R.colStart ? l.rowIndex = R.rowStart + 1 : l.rowIndex = R.rowStart;
|
|
518
467
|
}
|
|
519
|
-
return
|
|
468
|
+
return Yn({ cell: l, ranges: t.ranges, rangeIndex: w }, n, o, r, c, d ?? t);
|
|
520
469
|
}
|
|
521
|
-
return { ranges: t.ranges, cell: l, rangeIndex:
|
|
522
|
-
},
|
|
470
|
+
return { ranges: t.ranges, cell: l, rangeIndex: w };
|
|
471
|
+
}, ro = (t, n) => {
|
|
523
472
|
let o, r = 0, c = 0;
|
|
524
|
-
return n.colStart < t.colStart ? (o =
|
|
473
|
+
return n.colStart < t.colStart ? (o = g.Left, r = t.colStart - n.colStart, c = n.colStart) : n.colEnd > t.colEnd ? (o = g.Right, r = n.colEnd - t.colEnd, c = n.colEnd) : n.rowStart < t.rowStart ? (o = g.Up, r = t.rowStart - n.rowStart, c = n.rowStart) : n.rowEnd > t.rowEnd && (o = g.Down, r = n.rowEnd - t.rowEnd, c = n.rowEnd), { direction: o, amount: r, index: c };
|
|
525
474
|
}, On = (t, n = !1, o, r) => {
|
|
526
475
|
if (!o) return 0;
|
|
527
|
-
const c = !n,
|
|
528
|
-
let i = o(c ? t : t + 1), l = o(c ? t + 1 : t),
|
|
529
|
-
for (; (l - i) *
|
|
530
|
-
if (c &&
|
|
531
|
-
i = l, l = o(
|
|
476
|
+
const c = !n, d = c ? 1 : -1;
|
|
477
|
+
let i = o(c ? t : t + 1), l = o(c ? t + 1 : t), w = t + (c ? 2 : -1), L = 0;
|
|
478
|
+
for (; (l - i) * d <= 0; ) {
|
|
479
|
+
if (c && w - 1 > r + 1 || !c && w + 1 < r) return L;
|
|
480
|
+
i = l, l = o(w), w += d, L++;
|
|
532
481
|
}
|
|
533
|
-
return
|
|
534
|
-
},
|
|
535
|
-
const
|
|
482
|
+
return L;
|
|
483
|
+
}, lo = (t, n, o, r, c) => {
|
|
484
|
+
const d = {};
|
|
536
485
|
let i = null, l = null;
|
|
537
|
-
const
|
|
538
|
-
for (let
|
|
539
|
-
const
|
|
540
|
-
if (
|
|
541
|
-
const
|
|
542
|
-
i =
|
|
486
|
+
const w = o.length;
|
|
487
|
+
for (let L = 0; L < w && o[L] <= c; L++) {
|
|
488
|
+
const O = o[L];
|
|
489
|
+
if (O < r) continue;
|
|
490
|
+
const R = i === O ? l : n ? t.getColOffset(O) : t.getRowOffset(O), M = n ? t.getColOffset(O + 1) : t.getRowOffset(O + 1);
|
|
491
|
+
i = O + 1, l = M, d[O] = Object.freeze({ offset: R, size: M - R, spanIndex: L });
|
|
543
492
|
}
|
|
544
|
-
return Object.freeze(
|
|
545
|
-
},
|
|
493
|
+
return Object.freeze(d);
|
|
494
|
+
}, io = (t, n, o) => {
|
|
546
495
|
const r = t.getColOffset(n.colStart) + (o?.left ?? 0), c = t.getRowOffset(n.rowStart) + (o?.top ?? 0);
|
|
547
496
|
return { x: r, y: c, width: t.getColOffset(n.colEnd + 1) + (o?.right ?? 0) - (o?.left ?? 0) - r, height: t.getRowOffset(n.rowEnd + 1) + (o?.bottom ?? 0) - (o?.top ?? 0) - c };
|
|
548
|
-
},
|
|
497
|
+
}, qo = (t, n, o) => {
|
|
549
498
|
if (!o) return !1;
|
|
550
499
|
const r = o.x;
|
|
551
500
|
if (t < r || t > r + o.width) return !1;
|
|
552
501
|
const c = o.y;
|
|
553
502
|
return !(n < c || n > c + o.height);
|
|
554
|
-
},
|
|
555
|
-
const { linePoints: n, bounds: o, pathProps: r, style: c, ...
|
|
556
|
-
return Ce("svg", { width: `${
|
|
557
|
-
},
|
|
558
|
-
const { x: n = 0, y: o = 0, width: r = 0, height: c = 0, fill:
|
|
559
|
-
let
|
|
560
|
-
if (
|
|
561
|
-
let
|
|
562
|
-
|
|
503
|
+
}, Nn = (t, n = !0) => `M ${X.boundPixel(t.left)} ${X.boundPixel(t.top)} L ${X.boundPixel(t.right, !0)} ${X.boundPixel(t.top)} L ${X.boundPixel(t.right, !0)} ${X.boundPixel(t.bottom, !0)} L ${X.boundPixel(t.left)} ${X.boundPixel(t.bottom, !0)} L ${X.boundPixel(t.left)} ${X.boundPixel(t.top)} ${n ? "Z" : ""}`, co = (t) => {
|
|
504
|
+
const { linePoints: n, bounds: o, pathProps: r, style: c, ...d } = t;
|
|
505
|
+
return Ce("svg", { width: `${X.boundPixel(o.width, !0)}`, height: `${X.boundPixel(o.height, !0)}`, viewBox: `0 0 ${X.boundPixel(o.width, !0)} ${X.boundPixel(o.height, !0)}`, style: { position: "absolute", left: `${X.boundPixel(o.x)}px`, top: `${X.boundPixel(o.y)}px`, width: `${X.boundPixel(o.width, !0)}px`, height: `${X.boundPixel(o.height, !0)}px`, pointerEvents: "none", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top, width, height", willChange: "left, top, width, height, stroke-dashoffset", ...c }, ...d, children: Ce("path", { d: `M ${X.boundPixel(n[0])} ${X.boundPixel(n[1])} L ${X.boundPixel(n[2])} ${X.boundPixel(n[3])}`, fill: "none", vectorEffect: "non-scaling-stroke", stroke: "black", ...r }) });
|
|
506
|
+
}, jo = (t) => {
|
|
507
|
+
const { x: n = 0, y: o = 0, width: r = 0, height: c = 0, fill: d, stroke: i, strokeWidth: l = 0, strokeDasharray: w, strokeDashoffset: L, clipPath: O, pathBounds: R, pathProps: M, style: A, ...le } = t, J = o, te = n, ze = r, Q = c;
|
|
508
|
+
let T = null;
|
|
509
|
+
if (d) {
|
|
510
|
+
let _ = Nn({ top: 0, left: 0, bottom: Q, right: ze });
|
|
511
|
+
R && (_ = _ + " " + Nn({ top: R.y - J, left: R.x - te, bottom: R.height + R.y - J, right: R.width + R.x - te })), T = [Ce("path", { d: _, fill: d, stroke: "none", fillRule: "evenodd" }, "fill")];
|
|
563
512
|
}
|
|
564
|
-
return
|
|
565
|
-
},
|
|
513
|
+
return Qt("svg", { width: `${X.boundPixel(r, !0)}`, height: `${X.boundPixel(c, !0)}`, viewBox: `0 0 ${X.boundPixel(r, !0)} ${X.boundPixel(c, !0)}`, preserveAspectRatio: "none", style: { position: "absolute", left: `${X.boundPixel(n)}px`, top: `${X.boundPixel(o)}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", ...A }, ...le, children: [T, Ce("path", { d: Nn({ top: 0, left: 0, right: ze, bottom: Q }), fill: "none", strokeDasharray: w, strokeDashoffset: L, stroke: i, vectorEffect: "non-scaling-stroke", strokeWidth: l, ...M })] });
|
|
514
|
+
}, Yo = (t) => {
|
|
566
515
|
const { key: n, ...o } = t;
|
|
567
|
-
return Ce(
|
|
568
|
-
},
|
|
569
|
-
const { stroke: n, fill: o, x: r = 0, y: c = 0, width:
|
|
570
|
-
let
|
|
571
|
-
const
|
|
572
|
-
let
|
|
573
|
-
return
|
|
574
|
-
if (
|
|
575
|
-
const
|
|
516
|
+
return Ce(vo, { ...o }, n);
|
|
517
|
+
}, vo = Kt((t) => {
|
|
518
|
+
const { stroke: n, fill: o, x: r = 0, y: c = 0, width: d = 0, height: i = 0, style: l, isAnimatedStroke: w, animatedStrokeProps: L, range: O, cell: R, ...M } = t, A = w || !!L, le = { name: "walking-offset", dashGap: 2, speed: 50, dashLength: 8, ...L };
|
|
519
|
+
let J = le.dashGap + le.dashLength;
|
|
520
|
+
const te = le.speed * J, ze = To().replaceAll(":", ""), Q = `${le.name}-${ze}`;
|
|
521
|
+
let T;
|
|
522
|
+
return It(() => {
|
|
523
|
+
if (!A) return;
|
|
524
|
+
const _ = `@keyframes ${Q} {
|
|
576
525
|
to {
|
|
577
526
|
stroke-dashoffset: 0px;
|
|
578
527
|
}
|
|
579
|
-
}`,
|
|
580
|
-
return
|
|
581
|
-
document.head.removeChild(
|
|
528
|
+
}`, ve = document.createElement("style");
|
|
529
|
+
return ve.appendChild(document.createTextNode(_)), document.head.appendChild(ve), ve.sheet.insertRule(_, 0), () => {
|
|
530
|
+
document.head.removeChild(ve);
|
|
582
531
|
};
|
|
583
|
-
}, [
|
|
532
|
+
}, [A]), A && (T = { strokeDasharray: `${le.dashLength}px ${le.dashGap}px`, strokeDashoffset: `${J}px`, animation: `${Q} ${te}ms linear infinite`, willChange: "stroke-dashoffset" }), Ce(jo, { x: r, y: c, width: d, height: i, stroke: n, fill: o, shapeRendering: "crispEdges", style: { ...T, ...l }, ...M });
|
|
584
533
|
});
|
|
585
|
-
function
|
|
534
|
+
function So(t) {
|
|
586
535
|
var n, o, r = "";
|
|
587
536
|
if (typeof t == "string" || typeof t == "number") r += t;
|
|
588
537
|
else if (typeof t == "object") if (Array.isArray(t)) {
|
|
589
538
|
var c = t.length;
|
|
590
|
-
for (n = 0; n < c; n++) t[n] && (o =
|
|
539
|
+
for (n = 0; n < c; n++) t[n] && (o = So(t[n])) && (r && (r += " "), r += o);
|
|
591
540
|
} else for (o in t) t[o] && (r && (r += " "), r += o);
|
|
592
541
|
return r;
|
|
593
542
|
}
|
|
594
543
|
function rn() {
|
|
595
|
-
for (var t, n, o = 0, r = "", c = arguments.length; o < c; o++) (t = arguments[o]) && (n =
|
|
544
|
+
for (var t, n, o = 0, r = "", c = arguments.length; o < c; o++) (t = arguments[o]) && (n = So(t)) && (r && (r += " "), r += n);
|
|
596
545
|
return r;
|
|
597
546
|
}
|
|
598
|
-
|
|
599
|
-
const
|
|
600
|
-
const { x: o = 0, y: r = 0, borderWidth: c = 1, size:
|
|
547
|
+
vo.displayName = "Selection";
|
|
548
|
+
const yo = Kt(tn((t, n) => {
|
|
549
|
+
const { x: o = 0, y: r = 0, borderWidth: c = 1, size: d = 6, borderStroke: i, corner: l, style: w, className: L, background: O, ...R } = t;
|
|
601
550
|
if (o === 0 || r === 0) return null;
|
|
602
|
-
let
|
|
551
|
+
let M = !0, A = !0, le = !0, J = !0;
|
|
603
552
|
switch (l) {
|
|
604
553
|
case "tl":
|
|
605
|
-
|
|
554
|
+
M = !1, A = !1;
|
|
606
555
|
break;
|
|
607
556
|
case "bl":
|
|
608
|
-
|
|
557
|
+
M = !1, J = !1;
|
|
609
558
|
break;
|
|
610
559
|
case "br":
|
|
611
|
-
|
|
560
|
+
le = !1, J = !1;
|
|
612
561
|
break;
|
|
613
562
|
case "tr":
|
|
614
|
-
|
|
563
|
+
A = !1, le = !1;
|
|
615
564
|
}
|
|
616
|
-
return Ce("div", { className: rn("fill-handle",
|
|
565
|
+
return Ce("div", { className: rn("fill-handle", L), style: { position: "absolute", left: o - (d + (M ? c : 0)) / 2, top: r - (d + (A ? c : 0)) / 2, width: d, height: d, borderLeft: M ? `${c}px ${i}` : void 0, borderTop: A ? `${c}px ${i}` : void 0, borderRight: le ? `${c}px ${i}` : void 0, borderBottom: J ? `${c}px ${i}` : void 0, background: O, cursor: "crosshair", pointerEvents: "all", transitionDuration: "0ms", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top", willChange: "left, top", ...w }, tabIndex: -1, ...R });
|
|
617
566
|
}));
|
|
618
|
-
function
|
|
567
|
+
function Kn(t, n) {
|
|
619
568
|
if (typeof t == "function") return t(n);
|
|
620
569
|
t && (t.current = n);
|
|
621
570
|
}
|
|
622
|
-
|
|
623
|
-
var
|
|
571
|
+
yo.displayName = "FillHandle";
|
|
572
|
+
var Xo = parseInt(zo.split(".")[0], 10) >= 19 ? function(t) {
|
|
624
573
|
return (n) => {
|
|
625
574
|
const o = [];
|
|
626
575
|
for (const r of t) {
|
|
627
|
-
const c =
|
|
628
|
-
o.push(
|
|
576
|
+
const c = Kn(r, n), d = typeof c == "function";
|
|
577
|
+
o.push(d ? c : () => Kn(r, null));
|
|
629
578
|
}
|
|
630
579
|
return () => {
|
|
631
580
|
for (const r of o) r();
|
|
@@ -633,21 +582,21 @@ var tr = parseInt(Lo.split(".")[0], 10) >= 19 ? function(t) {
|
|
|
633
582
|
};
|
|
634
583
|
} : function(t) {
|
|
635
584
|
return (n) => {
|
|
636
|
-
for (const o of t)
|
|
585
|
+
for (const o of t) Kn(o, n);
|
|
637
586
|
};
|
|
638
587
|
};
|
|
639
|
-
const
|
|
640
|
-
const { range: o, view: r, anchor: c, borderStroke:
|
|
641
|
-
if (!
|
|
642
|
-
const
|
|
588
|
+
const Go = X.detectIt().supportsTouchEvents, Xn = Kt(tn((t, n) => {
|
|
589
|
+
const { range: o, view: r, anchor: c, borderStroke: d = "rgb(33, 115, 70)", background: i = "white", borderWidth: l = 1.5, size: w = 22, style: L, className: O, selectionTouchPointerHandler: R, onTouchSelectStart: M, onTouchSelectEnd: A, currentTouchAnchor: le, scrollableElement: J, scrollableRoot: te, ...ze } = t;
|
|
590
|
+
if (!Go) return null;
|
|
591
|
+
const Q = P(M, [M]), T = P(A, [A]), { bounds: _, coordsPivot: ve, key: W } = Ae(() => {
|
|
643
592
|
if (!o || !r) return null;
|
|
644
|
-
let be = null,
|
|
593
|
+
let be = null, Y = null;
|
|
645
594
|
switch (c) {
|
|
646
595
|
case "tl":
|
|
647
|
-
be = { colIndex: o.colEnd, rowIndex: o.rowEnd },
|
|
596
|
+
be = { colIndex: o.colEnd, rowIndex: o.rowEnd }, Y = { colIndex: o.colStart, rowIndex: o.rowStart };
|
|
648
597
|
break;
|
|
649
598
|
case "br":
|
|
650
|
-
be = { colIndex: o.colStart, rowIndex: o.rowStart },
|
|
599
|
+
be = { colIndex: o.colStart, rowIndex: o.rowStart }, Y = { colIndex: o.colEnd, rowIndex: o.rowEnd };
|
|
651
600
|
break;
|
|
652
601
|
case "t":
|
|
653
602
|
case "l":
|
|
@@ -659,1253 +608,1270 @@ const nr = Q.detectIt().supportsTouchEvents, Zn = Kt(tn((t, n) => {
|
|
|
659
608
|
case "r":
|
|
660
609
|
be = { colIndex: o.colStart, rowIndex: o.rowEnd };
|
|
661
610
|
}
|
|
662
|
-
let
|
|
663
|
-
const
|
|
611
|
+
let D = r.getRangeCoordsBounds(Y ? { rowStart: Y.rowIndex, colStart: Y.colIndex, rowEnd: Y.rowIndex, colEnd: Y.colIndex } : o);
|
|
612
|
+
const q = r.getBounds(), Pt = r.getViewportSize(), Et = q.x, wt = q.y, ut = Pt.width, he = Pt.height;
|
|
664
613
|
switch (c) {
|
|
665
614
|
case "tl":
|
|
666
615
|
break;
|
|
667
616
|
case "br":
|
|
668
|
-
|
|
617
|
+
D.x = D.x + D.width, D.y = D.y + D.height;
|
|
669
618
|
break;
|
|
670
619
|
case "t":
|
|
671
|
-
|
|
620
|
+
D.x = ut / 2 - Et;
|
|
672
621
|
break;
|
|
673
622
|
case "b":
|
|
674
|
-
|
|
623
|
+
D.x = ut / 2 - Et, D.y = D.y + D.height;
|
|
675
624
|
break;
|
|
676
625
|
case "l":
|
|
677
|
-
|
|
626
|
+
D.y = he / 2 - wt;
|
|
678
627
|
break;
|
|
679
628
|
case "r":
|
|
680
|
-
|
|
629
|
+
D.x = D.x + D.width, D.y = he / 2 - wt;
|
|
681
630
|
}
|
|
682
|
-
const Wt = r.toClipBounds(
|
|
683
|
-
return !Wt || Wt.width <= 0 || Wt.height <= 0 ||
|
|
684
|
-
}, [o, r, c]),
|
|
685
|
-
const be = (
|
|
686
|
-
return { processTouch: !0, consumeTouch: !0, onPointerDown: (
|
|
687
|
-
const
|
|
688
|
-
return
|
|
689
|
-
}, onPointerMoveOrWait: (
|
|
690
|
-
const Pt = be(r.getCellCoordsFromClient(
|
|
691
|
-
return
|
|
692
|
-
}, onPointerUp: (
|
|
693
|
-
}, [
|
|
694
|
-
return
|
|
695
|
-
const be =
|
|
696
|
-
if (!be || !
|
|
697
|
-
let
|
|
698
|
-
for (;
|
|
699
|
-
|
|
700
|
-
}, [
|
|
631
|
+
const Wt = r.toClipBounds(D, 0);
|
|
632
|
+
return !Wt || Wt.width <= 0 || Wt.height <= 0 || D.x < 0 || D.y < 0 || D.x > ut || D.y > he ? { bounds: null, coordsAnchor: null, coordsPivot: null, key: null } : { bounds: D, coordsAnchor: null, coordsPivot: be, key: "touchSelect-" + r.getAnchor() + "-" + c };
|
|
633
|
+
}, [o, r, c]), me = se(null), Ve = Ae(() => {
|
|
634
|
+
const be = (Y) => c === "t" || c === "b" ? { ...Y, colIndex: void 0 } : c === "l" || c === "r" ? { ...Y, rowIndex: void 0 } : Y;
|
|
635
|
+
return { processTouch: !0, consumeTouch: !0, onPointerDown: (Y, D) => {
|
|
636
|
+
const q = be(r.getCellCoordsFromClient(Y.clientX, Y.clientY));
|
|
637
|
+
return me.current = { coordsPivot: ve }, Q?.(c), R.onSelectionPointerDown(Y, D, r, q, ve, !1, !0);
|
|
638
|
+
}, onPointerMoveOrWait: (Y, D, q) => {
|
|
639
|
+
const Pt = be(r.getCellCoordsFromClient(Y.clientX, Y.clientY));
|
|
640
|
+
return R.onSelectionPointerMoveOrWait(Y, D, q, r, Pt, me.current?.coordsPivot, !0, !0);
|
|
641
|
+
}, onPointerUp: (Y, D, q) => (me.current = null, T?.(c), R.onPointerUp(Y, D, q)) };
|
|
642
|
+
}, [R, o, r, c]), ke = un(Ve), [We, { y: ue, x: ye }] = Do(), $ = se(null), { getPortalContainer: p, isFullscreen: Ne } = fo(), [Xe, Z] = gt(null);
|
|
643
|
+
return It(() => {
|
|
644
|
+
const be = $.current?.getBoundingClientRect();
|
|
645
|
+
if (!be || !_) return void Z(null);
|
|
646
|
+
let Y = 0, D = 0, q = J;
|
|
647
|
+
for (; q; ) Y += q.scrollLeft, D += q.scrollTop, q = te && q === te.parentElement ? null : q.parentElement;
|
|
648
|
+
Z(xo(Ce("div", { className: rn("touch-select-handle", O), ref: n, style: { position: "absolute", left: Y + (be?.x ?? 0) - (w + l) / 2, top: D + (be?.y ?? 0) - (w + l) / 2, width: w, height: w, borderWidth: `${l}px`, border: d, borderRadius: "50%", background: i, boxShadow: `0 0 0 1.5px ${i}`, cursor: "grab", pointerEvents: "all", opacity: le ? 0 : 1, transitionDuration: "160ms", transitionProperty: "opacity", ...L }, tabIndex: -1, onPointerDown: ke, ...ze }), te ?? p(), W));
|
|
649
|
+
}, [ue, ye, _?.x, _?.y, _?.width, _?.height, O, le, i, w, l, d, J, Ne]), _ ? Qt(_n, { children: [Ce("div", { ref: Xo([We, $]), style: { position: "absolute", left: _.x, top: _.y, opacity: 0 } }), Xe] }) : null;
|
|
701
650
|
}));
|
|
702
|
-
|
|
703
|
-
const Vt = -10,
|
|
651
|
+
Xn.displayName = "TouchSelectHandle";
|
|
652
|
+
const Vt = -10, _o = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd: 0 }), bo = Object.freeze({ colIndex: 0, rowIndex: 0 }), Gn = Object.freeze([]), $t = (t) => {
|
|
704
653
|
if (t && t.cell && t.ranges && t.rangeIndex > -1 && t.rangeIndex <= t.ranges.length) return t;
|
|
705
|
-
const n = { cell: null, ranges: t?.ranges ??
|
|
706
|
-
return n.rangeIndex = t?.rangeIndex ?? n.ranges.length - 1, n.cell = t?.cell, !n.cell && n.ranges.length > 0 && (n.cell = { rowIndex: n.ranges[n.rangeIndex].rowStart, colIndex: n.ranges[n.rangeIndex].colStart }), n.cell || (n.cell =
|
|
707
|
-
},
|
|
654
|
+
const n = { cell: null, ranges: t?.ranges ?? Gn };
|
|
655
|
+
return n.rangeIndex = t?.rangeIndex ?? n.ranges.length - 1, n.cell = t?.cell, !n.cell && n.ranges.length > 0 && (n.cell = { rowIndex: n.ranges[n.rangeIndex].rowStart, colIndex: n.ranges[n.rangeIndex].colStart }), n.cell || (n.cell = bo), F.isEqualSelectionCoords(n, t) ? t : n;
|
|
656
|
+
}, Tn = (t, n, o) => {
|
|
708
657
|
const r = t.getVisibleRangeCoords(), c = t.getScrollOrientation();
|
|
709
|
-
!c.horizontal && (n.colIndex > r.colEnd || n.colIndex < r.colStart) && (n = { ...n, colIndex: n.colIndex > r.colEnd ? r.colEnd + 1 : r.colEnd - 1 }, t = o.current.getViewFromLocation(
|
|
710
|
-
},
|
|
711
|
-
const
|
|
658
|
+
!c.horizontal && (n.colIndex > r.colEnd || n.colIndex < r.colStart) && (n = { ...n, colIndex: n.colIndex > r.colEnd ? r.colEnd + 1 : r.colEnd - 1 }, t = o.current.getViewFromLocation(Qe.Center)), !c.vertical && (n.rowIndex > r.rowEnd || n.rowIndex < r.rowStart) && (n = { ...n, rowIndex: n.rowIndex > r.rowEnd ? r.rowEnd + 1 : r.rowEnd - 1 }, t = o.current.getViewFromLocation(Qe.Center)), t.scrollCellCoordsIntoView(n);
|
|
659
|
+
}, Zo = () => !1, mr = ({ gridRef: t, commands: n, layout: o, selection: r, onSelectionChange: c, onSelectionDragStart: d, onSelectionDragEnd: i, selectionPolicy: l = "multiple", newSelectionMode: w = "clear", allowDeselectSelection: L = !0, onFillPreview: O, onFillCancel: R, onFillDone: M, onFill: A, disableFillDrag: le = !A, fillHandleBorderColor: J = "white", hiddenRowsAt: te, hiddenColumnsAt: ze, isContentfulCell: Q, contentfulCellFinder: T = Ko, getDataCoords: _, alwaysScrollToActiveCoords: ve = !1, selectionBounds: W, pointerDownInterceptor: me, pointerMoveInterceptor: Ve, mergedRanges: ke, canSelectionSpanMergedCells: We = Zo, onMoveDragStart: ue, onMoveDragUpdate: ye, onMoveDragEnd: $, onMoveDragDone: p, selectionRenderer: Ne = Yo, disableMoveDrag: Xe = !$, getCellCoordsAsRangeCoords: Z = F.cellToRange, moveDragHitSize: be = 6, moveDragOutlineSize: Y = 4, selectionBackgroundColor: D = "rgba(16, 124, 65, 0.1)", selectionBorderColor: q = "rgb(33, 115, 70)", selectionRemoveBorderColor: Pt = "rgb(255, 0, 0)", selectionRemoveBackgroundColor: Et = "rgba(250, 10, 10, 0.1)", disableTouchSelection: wt = !1, touchSelectHandleProps: ut }) => {
|
|
660
|
+
const he = V(() => ({ top: W?.top ?? 0, left: W?.left ?? 0, bottom: t.current?.rowCount - 1 || 0, right: t.current?.columnCount - 1 || 0 }), []), Wt = P(A, [A]), k = P(O, [O]), b = P(R, [R]), Re = P(M, [M]), ne = P(Q, [Q]), we = P(Ne, [Ne]), Ue = P((e, s = !1) => On(e, s, o.getRowOffset, s ? he().bottom : he().top), [o?.getRowOffset]), lt = P(te ?? Ue, [te]), Mt = P((e, s = !1) => On(e, s, o.getColOffset, s ? he().right : he().left), [o?.getColOffset]), it = P(ze ?? Mt, [ze]), [qt, xt] = gt(() => $t(r)), v = Ae(() => $t(qt), [qt]), oe = se(v), He = se(!0);
|
|
712
661
|
en(Nt.throttle(() => {
|
|
713
|
-
|
|
662
|
+
xt((e) => {
|
|
714
663
|
He.current = !0;
|
|
715
|
-
const
|
|
716
|
-
return
|
|
664
|
+
const s = $t(r);
|
|
665
|
+
return F.isEqualSelectionCoords(s, e) ? e : s;
|
|
717
666
|
});
|
|
718
667
|
}, 0), [r]), en(() => {
|
|
719
|
-
|
|
720
|
-
}, [v]),
|
|
721
|
-
He.current || !c ||
|
|
668
|
+
oe.current = v;
|
|
669
|
+
}, [v]), It(() => {
|
|
670
|
+
He.current || !c || F.isEqualSelectionCoords(r, v) || c(v);
|
|
722
671
|
}, [v]);
|
|
723
|
-
const
|
|
724
|
-
|
|
725
|
-
He.current = !1,
|
|
726
|
-
let u = typeof e == "function" ? e(
|
|
727
|
-
if (
|
|
728
|
-
let
|
|
729
|
-
|
|
730
|
-
const E = { cell:
|
|
731
|
-
return
|
|
672
|
+
const ht = V((e) => {
|
|
673
|
+
xt((s) => {
|
|
674
|
+
He.current = !1, s = $t(s);
|
|
675
|
+
let u = typeof e == "function" ? e(s.ranges) : e ?? Gn;
|
|
676
|
+
if (F.isEqualRangesArrays(u, s.ranges)) return s;
|
|
677
|
+
let a = Math.max(u.length ? 0 : -1, Math.min(s.rangeIndex, u.length - 1)), f = s.cell;
|
|
678
|
+
a === -1 || F.isCellWithinRange(f, u[a]) || (f = { rowIndex: u[a].rowStart, colIndex: u[a].colStart }), u.length === 1 && F.isSingleCell(u[0]) && F.isCellWithinRange(f, u[0]) && (u = [], a = -1);
|
|
679
|
+
const E = { cell: f, ranges: u, rangeIndex: a };
|
|
680
|
+
return F.isEqualSelectionCoords(E, s) ? s : E;
|
|
732
681
|
});
|
|
733
|
-
}, []),
|
|
734
|
-
|
|
735
|
-
He.current = !1,
|
|
736
|
-
const u = e ??
|
|
737
|
-
if (!
|
|
738
|
-
if (
|
|
739
|
-
let
|
|
740
|
-
|
|
741
|
-
const x = { ranges:
|
|
742
|
-
return
|
|
682
|
+
}, []), Je = P((e) => {
|
|
683
|
+
xt((s) => {
|
|
684
|
+
He.current = !1, s = $t(s);
|
|
685
|
+
const u = e ?? bo, a = Z(u);
|
|
686
|
+
if (!F.isSingleCell(a) && s.ranges.length === 0) return { ranges: [a], rangeIndex: 0, cell: u };
|
|
687
|
+
if (F.isEqualCells(u, s.cell)) return s;
|
|
688
|
+
let f = s.ranges, E = s.rangeIndex;
|
|
689
|
+
s.ranges.length === 1 && (F.isSingleCell(s.ranges[0]) && F.isCellWithinRange(u, s.ranges[0]) || !F.isCellWithinRange(u, s.ranges[0])) && (f = [], E = -1);
|
|
690
|
+
const x = { ranges: f, rangeIndex: E, cell: u };
|
|
691
|
+
return F.isEqualSelectionCoords(x, s) ? s : x;
|
|
743
692
|
});
|
|
744
|
-
}, [
|
|
745
|
-
|
|
746
|
-
nn.current =
|
|
747
|
-
}, [
|
|
748
|
-
const
|
|
749
|
-
let { rowIndex: u, colIndex:
|
|
750
|
-
u === void 0 && v?.cell && (u = v.cell.rowIndex),
|
|
751
|
-
}, [v]),
|
|
752
|
-
const
|
|
753
|
-
return e.rowIndex <
|
|
754
|
-
}, []),
|
|
693
|
+
}, [Z]), [ln, _t] = gt(null), [Tt, hn] = gt(null), Gt = se(null), [Pe, Ut] = gt(null), vt = se(null), Bt = se(null), [vn, cn] = gt(null), Ge = se(null), Ke = se(null), nn = se(ke);
|
|
694
|
+
It(() => {
|
|
695
|
+
nn.current = ke;
|
|
696
|
+
}, [ke]);
|
|
697
|
+
const St = P((e, s = { inline: "nearest", block: "nearest" }) => {
|
|
698
|
+
let { rowIndex: u, colIndex: a } = e;
|
|
699
|
+
u === void 0 && v?.cell && (u = v.cell.rowIndex), a === void 0 && v?.cell && (a = v.cell.colIndex), u !== void 0 && a !== void 0 && t.current?.scrollCellCoordsIntoView({ rowIndex: u, colIndex: a }, s);
|
|
700
|
+
}, [v]), jt = V((e) => {
|
|
701
|
+
const s = he();
|
|
702
|
+
return e.rowIndex < s.top || e.colIndex < s.left || e.colIndex > s.right || e.rowIndex > s.bottom;
|
|
703
|
+
}, []), Me = P((e, s) => {
|
|
755
704
|
if (!t?.current) return null;
|
|
756
|
-
const u = { rowStart: Math.min(e.rowIndex,
|
|
705
|
+
const u = { rowStart: Math.min(e.rowIndex, s.rowIndex), colStart: Math.min(e.colIndex, s.colIndex), rowEnd: Math.max(e.rowIndex, s.rowIndex), colEnd: Math.max(e.colIndex, s.colIndex) };
|
|
757
706
|
if (We?.(u)) return u;
|
|
758
|
-
const
|
|
759
|
-
let
|
|
760
|
-
return typeof nn.current == "function" ?
|
|
761
|
-
}, [We,
|
|
762
|
-
const
|
|
763
|
-
if (!(
|
|
764
|
-
return
|
|
765
|
-
}, [
|
|
766
|
-
if (l === "single" || !
|
|
767
|
-
const
|
|
768
|
-
if (!
|
|
769
|
-
const
|
|
770
|
-
|
|
771
|
-
}, []), Rt =
|
|
772
|
-
if (!
|
|
773
|
-
e = { ...
|
|
774
|
-
const
|
|
775
|
-
if (!
|
|
776
|
-
const
|
|
777
|
-
|
|
778
|
-
}, []),
|
|
779
|
-
l !== "multiple" || !e ||
|
|
780
|
-
He.current = !1,
|
|
781
|
-
const
|
|
782
|
-
if (!
|
|
783
|
-
let E =
|
|
784
|
-
E.push(
|
|
785
|
-
const x = { ranges: E, cell: { rowIndex:
|
|
786
|
-
return
|
|
707
|
+
const f = Z(e), E = Z(s), x = { rowStart: Math.min(f.rowStart, E.rowStart), colStart: Math.min(f.colStart, E.colStart), rowEnd: Math.max(f.rowEnd, E.rowEnd), colEnd: Math.max(f.colEnd, E.colEnd) };
|
|
708
|
+
let j;
|
|
709
|
+
return typeof nn.current == "function" ? j = nn.current(x) : ke && (j = ke), j ? F.extendRangeToUnionRanges(x, j) : x;
|
|
710
|
+
}, [We, Z]), _e = P((e, s, u) => {
|
|
711
|
+
const a = e.ranges.length > 0 ? e.ranges[e.rangeIndex] : { rowStart: e.cell.rowIndex, colStart: e.cell.colIndex, rowEnd: e.cell.rowIndex, colEnd: e.cell.colIndex }, f = { rowStart: Math.min(s.rowIndex ?? a.rowStart, u.rowIndex ?? a.rowStart), colStart: Math.min(s.colIndex ?? a.colStart, u.colIndex ?? a.colStart), rowEnd: Math.max(s.rowIndex ?? a.rowEnd, u.rowIndex ?? a.rowEnd), colEnd: Math.max(s.colIndex ?? a.colEnd, u.colIndex ?? a.colEnd) }, E = { rowIndex: f.rowStart, colIndex: f.colStart }, x = { rowIndex: f.rowEnd, colIndex: f.colEnd };
|
|
712
|
+
if (!(jt(E) || jt(x)))
|
|
713
|
+
return Me(E, x);
|
|
714
|
+
}, [Me]), ft = P((e, s, u) => {
|
|
715
|
+
if (l === "single" || !oe.current) return;
|
|
716
|
+
const a = _e(oe.current, e, s ?? oe.current.cell);
|
|
717
|
+
if (!a) return;
|
|
718
|
+
const f = oe.current.rangeIndex;
|
|
719
|
+
ht((E) => E.length ? E.map((x, j) => f === j ? a : x) : [a]), u && a && Je({ colIndex: a.colStart, rowIndex: a.rowStart });
|
|
720
|
+
}, []), Rt = V((e, s, u) => {
|
|
721
|
+
if (!oe.current) return;
|
|
722
|
+
e = { ...oe.current?.cell, ...e }, s = s ?? e;
|
|
723
|
+
const a = _e(oe.current, e, s);
|
|
724
|
+
if (!a) return;
|
|
725
|
+
const f = { rowIndex: a.rowStart, colIndex: a.colStart }, E = { ...f, ...u };
|
|
726
|
+
w === "clear" ? (Ge.current = E, Zt()) : w === "modify" ? ft(f) : Ie(f), Je(E);
|
|
727
|
+
}, []), Ie = V((e, s = e, u) => {
|
|
728
|
+
l !== "multiple" || !e || jt(e) || jt(s) || xt((a) => {
|
|
729
|
+
He.current = !1, a = $t(a);
|
|
730
|
+
const f = Me(e, s);
|
|
731
|
+
if (!f) return a;
|
|
732
|
+
let E = a.ranges.length > 0 ? [...a.ranges] : [Me(a.cell, a.cell)];
|
|
733
|
+
E.push(f);
|
|
734
|
+
const x = { ranges: E, cell: { rowIndex: f.rowStart, colIndex: f.colStart, ...u }, rangeIndex: E.length - 1 };
|
|
735
|
+
return F.isEqualSelectionCoords(x, a) ? a : x;
|
|
787
736
|
});
|
|
788
|
-
}, []),
|
|
789
|
-
|
|
790
|
-
}, zt =
|
|
737
|
+
}, []), Zt = () => {
|
|
738
|
+
ht(Gn);
|
|
739
|
+
}, zt = X.detectIt().primaryInput === "touch", ot = se(null), kt = se(null), Dt = se(null), sn = Ae(() => ({ onPointerDown: (e) => {
|
|
791
740
|
if (!t || !t.current) return !1;
|
|
792
|
-
const
|
|
793
|
-
if (
|
|
794
|
-
const
|
|
795
|
-
if (!
|
|
796
|
-
ot.current = { anchor: u.getAnchor(), coords:
|
|
797
|
-
const
|
|
798
|
-
if (
|
|
741
|
+
const s = e.nativeEvent, u = t.current.getViewFromClient(s.clientX, s.clientY);
|
|
742
|
+
if (s.pointerType === "touch" || s.type === "touchstart") return kt.current = { topLeft: u.getScrollTopLeft(), point: { x: s.clientX, y: s.clientY } }, !0;
|
|
743
|
+
const a = u.getCellCoordsFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY);
|
|
744
|
+
if (!a) return !1;
|
|
745
|
+
ot.current = { anchor: u.getAnchor(), coords: a }, Ke.current = null;
|
|
746
|
+
const f = e.nativeEvent.which === jn.Right;
|
|
747
|
+
if (f && F.indexOfCoords(a, v.ranges) !== -1)
|
|
799
748
|
return !1;
|
|
800
|
-
const E = e.nativeEvent.shiftKey, x = e.nativeEvent.ctrlKey || e.nativeEvent.metaKey,
|
|
801
|
-
if (
|
|
802
|
-
|
|
803
|
-
const Se = !
|
|
804
|
-
if (E) return
|
|
805
|
-
const
|
|
806
|
-
if (
|
|
807
|
-
if (
|
|
808
|
-
if (x &&
|
|
809
|
-
|
|
810
|
-
const
|
|
811
|
-
return Bt.current =
|
|
749
|
+
const E = e.nativeEvent.shiftKey, x = e.nativeEvent.ctrlKey || e.nativeEvent.metaKey, j = x, B = L, H = v.ranges.length > 0, G = x && B;
|
|
750
|
+
if (me?.(e, a, v) === !1) return !1;
|
|
751
|
+
d?.(oe.current, e.nativeEvent);
|
|
752
|
+
const Se = !f && l !== "single";
|
|
753
|
+
if (E) return ft(a), Se;
|
|
754
|
+
const K = F.isEqualCells(a, v.cell);
|
|
755
|
+
if (j) {
|
|
756
|
+
if (K && (!G || !H)) return Se;
|
|
757
|
+
if (x && F.indexOfCoords(a, v.ranges) !== -1 && B) {
|
|
758
|
+
vt.current = a;
|
|
759
|
+
const N = Me(a, a);
|
|
760
|
+
return Bt.current = N, Ut(N), Se;
|
|
812
761
|
}
|
|
813
|
-
return
|
|
762
|
+
return Ie(a), Se;
|
|
814
763
|
}
|
|
815
|
-
|
|
816
|
-
}, onPointerMoveOrWait: Nt.throttle((e,
|
|
764
|
+
ve && St(a), K && v.ranges.length === 0 || Rt(a);
|
|
765
|
+
}, onPointerMoveOrWait: Nt.throttle((e, s) => {
|
|
817
766
|
if (!t?.current || e.pointerType === "touch" || e.type === "touchmove" || !ot.current) return;
|
|
818
767
|
const u = ot.current.anchor;
|
|
819
|
-
let
|
|
820
|
-
if (!
|
|
821
|
-
if (
|
|
822
|
-
const E = { rowStart: Math.min(
|
|
823
|
-
if (
|
|
824
|
-
const
|
|
825
|
-
Bt.current =
|
|
826
|
-
} else
|
|
827
|
-
|
|
768
|
+
let a = t.current.getViewFromLocation(u), f = a.getCellCoordsFromClient(e.clientX, e.clientY);
|
|
769
|
+
if (!F.isEqualCells(f, ot.current?.coords) && (ot.current = { anchor: u, coords: f }, f && Ve?.(e, f, oe.current) !== !1)) {
|
|
770
|
+
if (vt.current) {
|
|
771
|
+
const E = { rowStart: Math.min(f.rowIndex, vt.current.rowIndex), colStart: Math.min(f.colIndex, vt.current.colIndex), rowEnd: Math.max(f.rowIndex, vt.current.rowIndex), colEnd: Math.max(f.colIndex, vt.current.colIndex) }, x = { rowIndex: E.rowStart, colIndex: E.colStart }, j = { rowIndex: E.rowEnd, colIndex: E.colEnd };
|
|
772
|
+
if (jt(x) || jt(j)) return;
|
|
773
|
+
const B = Me(x, j);
|
|
774
|
+
Bt.current = B, Ut(B);
|
|
775
|
+
} else ft(f);
|
|
776
|
+
Dt.current = s, Tn(a, f, t);
|
|
828
777
|
}
|
|
829
778
|
}, 60), onPointerUp: (e) => {
|
|
830
779
|
if (ot.current = null, e.pointerType === "touch" || e.type === "touchend") {
|
|
831
780
|
if (kt.current) {
|
|
832
|
-
const u = t.current.getViewFromClient(kt.current.point.x, kt.current.point.y),
|
|
833
|
-
if (
|
|
834
|
-
const
|
|
835
|
-
Rt(
|
|
781
|
+
const u = t.current.getViewFromClient(kt.current.point.x, kt.current.point.y), a = u.getScrollTopLeft();
|
|
782
|
+
if (a.left === kt.current.topLeft.left && a.top === kt.current.topLeft.top) {
|
|
783
|
+
const f = u.getCellCoordsFromClient(kt.current.point.x, kt.current.point.y);
|
|
784
|
+
Rt(f);
|
|
836
785
|
}
|
|
837
786
|
}
|
|
838
787
|
return kt.current = null, void (ot.current = null);
|
|
839
788
|
}
|
|
840
789
|
try {
|
|
841
|
-
i?.(
|
|
790
|
+
i?.(oe.current, e);
|
|
842
791
|
} catch (u) {
|
|
843
792
|
console.warn(u);
|
|
844
793
|
}
|
|
845
|
-
if (!
|
|
846
|
-
const
|
|
847
|
-
|
|
794
|
+
if (!vt.current) return;
|
|
795
|
+
const s = Bt.current;
|
|
796
|
+
vt.current = null, Bt.current = null, Ut(null), xt((u) => {
|
|
848
797
|
if (He.current = !1, (u = $t(u)).ranges.length === 0) return u;
|
|
849
|
-
let
|
|
850
|
-
for (let
|
|
851
|
-
const
|
|
852
|
-
if (
|
|
853
|
-
const
|
|
854
|
-
for (let
|
|
855
|
-
const Se = { rowStart:
|
|
856
|
-
|
|
798
|
+
let a = [], f = -1, E = u.cell;
|
|
799
|
+
for (let j = 0; j < u.ranges.length; j++) {
|
|
800
|
+
const B = u.ranges[j];
|
|
801
|
+
if (F.isRangesIntersect(B, s)) {
|
|
802
|
+
const H = Nt.subtractRect({ top: B.rowStart, left: B.colStart, bottom: B.rowEnd + 1, right: B.colEnd + 1 }, { top: s.rowStart, left: s.colStart, bottom: s.rowEnd + 1, right: s.colEnd + 1 });
|
|
803
|
+
for (let G = 0; G < H.length; G++) {
|
|
804
|
+
const Se = { rowStart: H[G].top, colStart: H[G].left, rowEnd: H[G].bottom - 1, colEnd: H[G].right - 1 };
|
|
805
|
+
a.push(Se), F.isCellWithinRange(u.cell, Se) && (f = a.length - 1);
|
|
857
806
|
}
|
|
858
|
-
} else
|
|
859
|
-
|
|
807
|
+
} else a.push(B);
|
|
808
|
+
a.length > 0 && f === -1 && F.isCellWithinRange(u.cell, B) && (f = a.length - 1, E = { rowIndex: a[a.length - 1].rowStart, colIndex: a[a.length - 1].colStart });
|
|
860
809
|
}
|
|
861
|
-
const x = { cell: E, rangeIndex:
|
|
862
|
-
return
|
|
810
|
+
const x = { cell: E, rangeIndex: f, ranges: a };
|
|
811
|
+
return F.isEqualSelectionCoords(x, u) ? u : x;
|
|
863
812
|
});
|
|
864
|
-
}, processTouch: !0, consumeTouch: !1 }), [v, l,
|
|
813
|
+
}, processTouch: !0, consumeTouch: !1 }), [v, l, L, ve, w]), zn = P(un(sn), []), Ln = Ae(() => ({ onSelectionPointerDown: (e, s, u, a, f = v.cell, E = ve, x = e.nativeEvent.shiftKey, j = !1) => {
|
|
865
814
|
if (!t || !t.current) return !1;
|
|
866
815
|
e.stopPropagation(), e.preventDefault(), e.nativeEvent.stopImmediatePropagation();
|
|
867
|
-
const
|
|
868
|
-
if (!
|
|
869
|
-
ot.current = { anchor:
|
|
870
|
-
const
|
|
871
|
-
if (
|
|
816
|
+
const B = u ?? t.current.getViewFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY), H = a ?? B.getCellCoordsFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY);
|
|
817
|
+
if (!H) return !1;
|
|
818
|
+
ot.current = { anchor: B.getAnchor(), coords: H }, Ke.current = null;
|
|
819
|
+
const G = e.nativeEvent.which === jn.Right;
|
|
820
|
+
if (G && F.indexOfCoords(H, v.ranges) !== -1)
|
|
872
821
|
return !1;
|
|
873
|
-
const Se = e.nativeEvent.ctrlKey || e.nativeEvent.metaKey,
|
|
874
|
-
if (
|
|
875
|
-
|
|
876
|
-
const
|
|
877
|
-
if (x) return
|
|
878
|
-
const
|
|
879
|
-
if (
|
|
880
|
-
if (
|
|
881
|
-
if (I &&
|
|
882
|
-
|
|
883
|
-
const
|
|
884
|
-
return Bt.current =
|
|
822
|
+
const Se = e.nativeEvent.ctrlKey || e.nativeEvent.metaKey, K = Se, N = L, dt = v.ranges.length > 0, I = Se && N;
|
|
823
|
+
if (me?.(e, H, v) === !1) return !1;
|
|
824
|
+
d?.(oe.current, e.nativeEvent);
|
|
825
|
+
const pe = !G && l !== "single";
|
|
826
|
+
if (x) return ft(H, f, j), pe;
|
|
827
|
+
const Ct = F.isEqualCells(H, f);
|
|
828
|
+
if (K) {
|
|
829
|
+
if (Ct && (!I || !dt)) return pe;
|
|
830
|
+
if (I && F.indexOfCoords(H, v.ranges) !== -1 && N) {
|
|
831
|
+
vt.current = H;
|
|
832
|
+
const ge = Me(H, H);
|
|
833
|
+
return Bt.current = ge, Ut(ge), pe;
|
|
885
834
|
}
|
|
886
|
-
return
|
|
835
|
+
return Ie(H), pe;
|
|
887
836
|
}
|
|
888
|
-
E &&
|
|
889
|
-
}, onSelectionPointerMoveOrWait: (e,
|
|
837
|
+
E && St(H), Ct && v.ranges.length === 0 || Rt(H);
|
|
838
|
+
}, onSelectionPointerMoveOrWait: (e, s, u, a, f, E = v.cell, x = !0, j = !1) => {
|
|
890
839
|
if (!t?.current || (e.stopPropagation(), e.preventDefault(), e.stopImmediatePropagation(), !ot.current)) return;
|
|
891
|
-
const
|
|
892
|
-
let
|
|
893
|
-
if (!
|
|
894
|
-
if (
|
|
895
|
-
const Se = { rowStart: Math.min(
|
|
896
|
-
if (
|
|
897
|
-
const dt =
|
|
840
|
+
const B = ot.current.anchor;
|
|
841
|
+
let H = a ?? t.current.getViewFromLocation(B), G = f ?? H.getCellCoordsFromClient(e.clientX, e.clientY);
|
|
842
|
+
if (!F.isEqualCells(G, ot.current?.coords) && (ot.current = { anchor: B, coords: G }, G && Ve?.(e, G, oe.current) !== !1)) {
|
|
843
|
+
if (vt.current) {
|
|
844
|
+
const Se = { rowStart: Math.min(G.rowIndex, vt.current.rowIndex), colStart: Math.min(G.colIndex, vt.current.colIndex), rowEnd: Math.max(G.rowIndex, vt.current.rowIndex), colEnd: Math.max(G.colIndex, vt.current.colIndex) }, K = { rowIndex: Se.rowStart, colIndex: Se.colStart }, N = { rowIndex: Se.rowEnd, colIndex: Se.colEnd };
|
|
845
|
+
if (jt(K) || jt(N)) return;
|
|
846
|
+
const dt = Me(K, N);
|
|
898
847
|
Bt.current = dt, Ut(dt);
|
|
899
|
-
} else
|
|
900
|
-
x &&
|
|
848
|
+
} else ft(G, E, j);
|
|
849
|
+
x && Tn(H, G, t);
|
|
901
850
|
}
|
|
902
851
|
}, onPointerUp: (e) => {
|
|
903
852
|
ot.current = null, e.stopPropagation(), e.preventDefault(), e.stopImmediatePropagation();
|
|
904
853
|
try {
|
|
905
|
-
i?.(
|
|
854
|
+
i?.(oe.current, e);
|
|
906
855
|
} catch (u) {
|
|
907
856
|
console.warn(u);
|
|
908
857
|
}
|
|
909
|
-
if (!
|
|
910
|
-
const
|
|
911
|
-
|
|
858
|
+
if (!vt.current) return;
|
|
859
|
+
const s = Bt.current;
|
|
860
|
+
vt.current = null, Bt.current = null, Ut(null), xt((u) => {
|
|
912
861
|
if (He.current = !1, (u = $t(u)).ranges.length === 0) return u;
|
|
913
|
-
let
|
|
914
|
-
for (let
|
|
915
|
-
const
|
|
916
|
-
if (
|
|
917
|
-
const
|
|
918
|
-
for (let
|
|
919
|
-
const Se = { rowStart:
|
|
920
|
-
|
|
862
|
+
let a = [], f = -1, E = u.cell;
|
|
863
|
+
for (let j = 0; j < u.ranges.length; j++) {
|
|
864
|
+
const B = u.ranges[j];
|
|
865
|
+
if (F.isRangesIntersect(B, s)) {
|
|
866
|
+
const H = Nt.subtractRect({ top: B.rowStart, left: B.colStart, bottom: B.rowEnd + 1, right: B.colEnd + 1 }, { top: s.rowStart, left: s.colStart, bottom: s.rowEnd + 1, right: s.colEnd + 1 });
|
|
867
|
+
for (let G = 0; G < H.length; G++) {
|
|
868
|
+
const Se = { rowStart: H[G].top, colStart: H[G].left, rowEnd: H[G].bottom - 1, colEnd: H[G].right - 1 };
|
|
869
|
+
a.push(Se), F.isCellWithinRange(u.cell, Se) && (f = a.length - 1);
|
|
921
870
|
}
|
|
922
|
-
} else
|
|
923
|
-
|
|
871
|
+
} else a.push(B);
|
|
872
|
+
a.length > 0 && f === -1 && F.isCellWithinRange(u.cell, B) && (f = a.length - 1, E = { rowIndex: a[a.length - 1].rowStart, colIndex: a[a.length - 1].colStart });
|
|
924
873
|
}
|
|
925
|
-
const x = { cell: E, rangeIndex:
|
|
926
|
-
return
|
|
874
|
+
const x = { cell: E, rangeIndex: f, ranges: a };
|
|
875
|
+
return F.isEqualSelectionCoords(x, u) ? u : x;
|
|
927
876
|
});
|
|
928
|
-
} }), [v, l,
|
|
877
|
+
} }), [v, l, L, ve, w]), rt = P((e, s = !1, u = !1, a = 0) => {
|
|
929
878
|
if (!t.current || !v.cell) return;
|
|
930
|
-
let
|
|
931
|
-
if (
|
|
932
|
-
const I = v.ranges[v.rangeIndex],
|
|
879
|
+
let f = v.cell, E = v.cell;
|
|
880
|
+
if (s && v.ranges.length > 0) {
|
|
881
|
+
const I = v.ranges[v.rangeIndex], pe = v.cell;
|
|
933
882
|
switch (e) {
|
|
934
|
-
case
|
|
935
|
-
E = { rowIndex:
|
|
883
|
+
case g.Up:
|
|
884
|
+
E = { rowIndex: pe.rowIndex === I.rowStart ? I.rowEnd : I.rowStart, colIndex: I.colEnd }, f = { rowIndex: pe.rowIndex === I.rowStart ? I.rowStart : I.rowEnd, colIndex: I.colStart };
|
|
936
885
|
break;
|
|
937
|
-
case
|
|
938
|
-
E = { rowIndex:
|
|
886
|
+
case g.Down:
|
|
887
|
+
E = { rowIndex: pe.rowIndex === I.rowEnd ? I.rowStart : I.rowEnd, colIndex: I.colEnd }, f = { rowIndex: pe.rowIndex === I.rowEnd ? I.rowEnd : I.rowStart, colIndex: I.colStart };
|
|
939
888
|
break;
|
|
940
|
-
case
|
|
941
|
-
E = { rowIndex: I.rowEnd, colIndex:
|
|
889
|
+
case g.Left:
|
|
890
|
+
E = { rowIndex: I.rowEnd, colIndex: pe.colIndex === I.colStart ? I.colEnd : I.colStart }, f = { rowIndex: I.rowStart, colIndex: pe.colIndex === I.colStart ? I.colStart : I.colEnd };
|
|
942
891
|
break;
|
|
943
|
-
case
|
|
944
|
-
E = { rowIndex: I.rowEnd, colIndex:
|
|
892
|
+
case g.Right:
|
|
893
|
+
E = { rowIndex: I.rowEnd, colIndex: pe.colIndex === I.colEnd ? I.colStart : I.colEnd }, f = { rowIndex: I.rowStart, colIndex: pe.colIndex === I.colEnd ? I.colEnd : I.colStart };
|
|
945
894
|
}
|
|
946
895
|
}
|
|
947
|
-
const x =
|
|
948
|
-
let { rowStart:
|
|
949
|
-
const
|
|
896
|
+
const x = Z(E);
|
|
897
|
+
let { rowStart: j, colStart: B } = x;
|
|
898
|
+
const H = he();
|
|
950
899
|
if (Ke.current) switch (e) {
|
|
951
|
-
case
|
|
952
|
-
case
|
|
953
|
-
Ke.current.colIndex >= x.colStart && Ke.current.colIndex <= x.colEnd && (
|
|
900
|
+
case g.Up:
|
|
901
|
+
case g.Down:
|
|
902
|
+
Ke.current.colIndex >= x.colStart && Ke.current.colIndex <= x.colEnd && (B = Ke.current.colIndex);
|
|
954
903
|
break;
|
|
955
|
-
case
|
|
956
|
-
case
|
|
957
|
-
Ke.current.rowIndex >= x.rowStart && Ke.current.rowIndex <= x.rowEnd && (
|
|
904
|
+
case g.Left:
|
|
905
|
+
case g.Right:
|
|
906
|
+
Ke.current.rowIndex >= x.rowStart && Ke.current.rowIndex <= x.rowEnd && (j = Ke.current.rowIndex);
|
|
958
907
|
}
|
|
959
|
-
if (!
|
|
908
|
+
if (!a) {
|
|
960
909
|
switch (e) {
|
|
961
|
-
case
|
|
962
|
-
|
|
910
|
+
case g.Up:
|
|
911
|
+
j = Fe(lt, Math.max(x.rowStart - 1, H.top), e);
|
|
963
912
|
break;
|
|
964
|
-
case
|
|
965
|
-
|
|
913
|
+
case g.Down:
|
|
914
|
+
j = Fe(lt, Math.min(x.rowEnd + 1, H.bottom), e);
|
|
966
915
|
break;
|
|
967
|
-
case
|
|
968
|
-
|
|
916
|
+
case g.Left:
|
|
917
|
+
B = Fe(it, Math.max(x.colStart - 1, H.left), e);
|
|
969
918
|
break;
|
|
970
|
-
case
|
|
971
|
-
|
|
919
|
+
case g.Right:
|
|
920
|
+
B = Fe(it, Math.min(x.colEnd + 1, H.right), e);
|
|
972
921
|
}
|
|
973
922
|
if (u) switch (e) {
|
|
974
|
-
case
|
|
975
|
-
|
|
923
|
+
case g.Up:
|
|
924
|
+
j = T({ ...E, colIndex: v.cell.colIndex }, ne, lt, e, !1, Math.max(H.top, lt(H.top, !1)));
|
|
976
925
|
break;
|
|
977
|
-
case
|
|
978
|
-
|
|
926
|
+
case g.Down:
|
|
927
|
+
j = T({ ...E, colIndex: v.cell.colIndex }, ne, lt, e, !1, Math.min(H.bottom, H.bottom - lt(H.bottom, !0)));
|
|
979
928
|
break;
|
|
980
|
-
case
|
|
981
|
-
|
|
929
|
+
case g.Left:
|
|
930
|
+
B = T({ ...E, rowIndex: v.cell.rowIndex }, ne, it, e, !1, Math.max(H.left, it(H.left, !1)));
|
|
982
931
|
break;
|
|
983
|
-
case
|
|
984
|
-
|
|
932
|
+
case g.Right:
|
|
933
|
+
B = T({ ...E, rowIndex: v.cell.rowIndex }, ne, it, e, !1, Math.min(H.right, H.right - it(H.right, !0)));
|
|
985
934
|
}
|
|
986
935
|
}
|
|
987
|
-
let
|
|
988
|
-
if (
|
|
936
|
+
let G = null;
|
|
937
|
+
if (a) {
|
|
989
938
|
let I = 0;
|
|
990
939
|
switch (e) {
|
|
991
|
-
case
|
|
992
|
-
I = o.getRowOffset(
|
|
940
|
+
case g.Up:
|
|
941
|
+
I = o.getRowOffset(j + 1), j = Math.max(H.top, o.getRowIndex(I - a)), G = { top: o.getRowOffset(j + 1) - (I - t.current.getScrollPosition().top) };
|
|
993
942
|
break;
|
|
994
|
-
case
|
|
995
|
-
I = o.getRowOffset(
|
|
943
|
+
case g.Down:
|
|
944
|
+
I = o.getRowOffset(j), j = Math.min(H.bottom, o.getRowIndex(I + a)), G = { top: o.getRowOffset(j) - (I - t.current.getScrollPosition().top) };
|
|
996
945
|
break;
|
|
997
|
-
case
|
|
998
|
-
I = o.getColOffset(
|
|
946
|
+
case g.Left:
|
|
947
|
+
I = o.getColOffset(B + 1), B = Math.max(H.left, o.getColIndex(I - a)), G = { left: o.getColOffset(B + 1) - (I - t.current.getScrollPosition().left) };
|
|
999
948
|
break;
|
|
1000
|
-
case
|
|
1001
|
-
I = o.getColOffset(
|
|
949
|
+
case g.Right:
|
|
950
|
+
I = o.getColOffset(B), B = Math.min(H.right, o.getColIndex(I + a)), G = { left: o.getColOffset(B) - (I - t.current.getScrollPosition().left) };
|
|
1002
951
|
}
|
|
1003
952
|
}
|
|
1004
|
-
const Se = { rowIndex:
|
|
1005
|
-
|
|
1006
|
-
const dt =
|
|
1007
|
-
if (
|
|
953
|
+
const Se = { rowIndex: j, colIndex: B }, K = Z(Se), N = { rowIndex: K.rowStart, colIndex: K.colStart };
|
|
954
|
+
s || (Ke.current = Se);
|
|
955
|
+
const dt = F.isEqualCells(Ge.current, N) && F.isEqualCells(Ge.current, f);
|
|
956
|
+
if (s && !dt ? ft(N, f) : Rt(N), G) t.current.scrollTo(G);
|
|
1008
957
|
else {
|
|
1009
|
-
if (
|
|
1010
|
-
const I =
|
|
1011
|
-
if (e ===
|
|
958
|
+
if (s && Ge.current) {
|
|
959
|
+
const I = he();
|
|
960
|
+
if (e === g.Right && Ge.current.colIndex === I.left || e === g.Left && Ge.current.colIndex === I.right || e === g.Up && Ge.current.rowIndex === I.bottom || e === g.Down && Ge.current.rowIndex === I.top) return;
|
|
1012
961
|
}
|
|
1013
|
-
e ===
|
|
962
|
+
e === g.Left || e === g.Right ? St({ colIndex: Se.colIndex }) : e !== g.Up && e !== g.Down || St({ rowIndex: Se.rowIndex });
|
|
1014
963
|
}
|
|
1015
|
-
}, [v,
|
|
964
|
+
}, [v, Z]), Yt = P((e) => {
|
|
1016
965
|
if (!t.current) return;
|
|
1017
966
|
if (v.ranges.length === 0) return void rt(e);
|
|
1018
|
-
const
|
|
1019
|
-
if (
|
|
1020
|
-
const u =
|
|
1021
|
-
|
|
1022
|
-
He.current = !1,
|
|
1023
|
-
const
|
|
1024
|
-
return
|
|
1025
|
-
}), u.cell &&
|
|
1026
|
-
}, [v,
|
|
1027
|
-
const e =
|
|
1028
|
-
|
|
1029
|
-
}, []),
|
|
1030
|
-
const e =
|
|
1031
|
-
|
|
1032
|
-
}, []),
|
|
1033
|
-
v.cell && t?.current &&
|
|
1034
|
-
}, [v.cell]), Sn =
|
|
1035
|
-
const
|
|
1036
|
-
e ?
|
|
1037
|
-
}, []), yn =
|
|
1038
|
-
const
|
|
1039
|
-
e ?
|
|
1040
|
-
}, []), fn =
|
|
1041
|
-
const
|
|
1042
|
-
e ?
|
|
1043
|
-
}, []), an =
|
|
1044
|
-
const
|
|
1045
|
-
e ?
|
|
1046
|
-
}, []), gn =
|
|
1047
|
-
const
|
|
1048
|
-
e ?
|
|
1049
|
-
}, [
|
|
1050
|
-
const
|
|
1051
|
-
e ?
|
|
1052
|
-
}, [
|
|
967
|
+
const s = Z(v.cell);
|
|
968
|
+
if (F.isEqualRangesArrays([s], v.ranges)) return void rt(e);
|
|
969
|
+
const u = Yn(v, e, Z, lt, it);
|
|
970
|
+
xt((a) => {
|
|
971
|
+
He.current = !1, a = $t(a);
|
|
972
|
+
const f = { ...a, cell: u.cell, rangeIndex: u.rangeIndex };
|
|
973
|
+
return F.isEqualSelectionCoords(f, a) ? a : f;
|
|
974
|
+
}), u.cell && St(u.cell);
|
|
975
|
+
}, [v, Z]), $n = V(() => {
|
|
976
|
+
const e = he();
|
|
977
|
+
ft({ rowIndex: e.top }, { rowIndex: e.bottom });
|
|
978
|
+
}, []), Bn = V(() => {
|
|
979
|
+
const e = he();
|
|
980
|
+
ft({ colIndex: e.left }, { colIndex: e.right });
|
|
981
|
+
}, []), Jt = P(() => {
|
|
982
|
+
v.cell && t?.current && St(v.cell);
|
|
983
|
+
}, [v.cell]), Sn = V((e = !1) => {
|
|
984
|
+
const s = { rowIndex: he().top };
|
|
985
|
+
e ? ft(s) : Rt(s), St(s);
|
|
986
|
+
}, []), yn = V((e = !1) => {
|
|
987
|
+
const s = { rowIndex: he().bottom };
|
|
988
|
+
e ? ft(s) : Rt(s), St(s);
|
|
989
|
+
}, []), fn = V((e = !1) => {
|
|
990
|
+
const s = { colIndex: he().left };
|
|
991
|
+
e ? ft(s) : Rt(s), St(s);
|
|
992
|
+
}, []), an = V((e = !1) => {
|
|
993
|
+
const s = he(), u = { rowIndex: s.top, colIndex: s.left };
|
|
994
|
+
e ? ft(u) : Rt(u), St(u);
|
|
995
|
+
}, []), gn = V((e = !1) => {
|
|
996
|
+
const s = he(), u = { colIndex: _?.()?.colEnd ?? s.right };
|
|
997
|
+
e ? ft(u) : Rt(u), St(u);
|
|
998
|
+
}, [_]), on = V((e = !1) => {
|
|
999
|
+
const s = he(), u = { rowIndex: _?.()?.rowEnd ?? s.bottom, colIndex: _?.()?.colEnd ?? s.right };
|
|
1000
|
+
e ? ft(u) : Rt(u), St(u);
|
|
1001
|
+
}, [_]), wn = P((e) => {
|
|
1053
1002
|
if (!t.current || v.ranges.length <= 1) return;
|
|
1054
|
-
const
|
|
1055
|
-
let u = v.rangeIndex + (
|
|
1003
|
+
const s = e === g.Left || e === g.Up;
|
|
1004
|
+
let u = v.rangeIndex + (s ? -1 : 1);
|
|
1056
1005
|
u < 0 ? u = v.ranges.length - 1 : u > v.ranges.length - 1 && (u = 0);
|
|
1057
|
-
const
|
|
1058
|
-
|
|
1006
|
+
const a = v.ranges[u], f = Yn({ cell: { rowIndex: a.rowEnd, colIndex: a.colEnd }, rangeIndex: 0, ranges: [a] }, g.Right, Z, lt, it);
|
|
1007
|
+
xt((E) => {
|
|
1059
1008
|
He.current = !1, E = $t(E);
|
|
1060
|
-
const x = { ...E, cell:
|
|
1061
|
-
return
|
|
1062
|
-
}),
|
|
1063
|
-
}, [v,
|
|
1064
|
-
const e =
|
|
1065
|
-
|
|
1066
|
-
He.current = !1,
|
|
1067
|
-
const u = { ...
|
|
1068
|
-
return
|
|
1069
|
-
}), e.cell &&
|
|
1070
|
-
}, [v,
|
|
1009
|
+
const x = { ...E, cell: f.cell, rangeIndex: u };
|
|
1010
|
+
return F.isEqualSelectionCoords(x, E) ? E : x;
|
|
1011
|
+
}), f.cell && St(f.cell);
|
|
1012
|
+
}, [v, Z]), An = P(() => {
|
|
1013
|
+
const e = oo(v);
|
|
1014
|
+
xt((s) => {
|
|
1015
|
+
He.current = !1, s = $t(s);
|
|
1016
|
+
const u = { ...s, visibleSelection: e };
|
|
1017
|
+
return F.isEqualSelectionCoords(u, s) ? s : u;
|
|
1018
|
+
}), e.cell && St(e.cell);
|
|
1019
|
+
}, [v, Z]), Fn = P(() => {
|
|
1071
1020
|
if (!t.current || v.ranges.length === 0) return;
|
|
1072
|
-
const e = v.cell,
|
|
1073
|
-
let
|
|
1074
|
-
|
|
1021
|
+
const e = v.cell, s = v.ranges[v.rangeIndex], u = oo({ cell: e, rangeIndex: 0, ranges: [s] }), a = u.ranges[u.rangeIndex];
|
|
1022
|
+
let f;
|
|
1023
|
+
f = a.rowStart === e.rowIndex && a.colStart === e.colIndex ? { rowIndex: a.rowStart, colIndex: a.colEnd } : a.rowStart === e.rowIndex && a.colEnd === e.colIndex ? { rowIndex: a.rowEnd, colIndex: a.colStart } : a.rowEnd === e.rowIndex && a.colStart === e.colIndex ? { rowIndex: a.rowEnd, colIndex: a.colEnd } : { rowIndex: a.rowStart, colIndex: a.colStart }, xt((E) => {
|
|
1075
1024
|
E = $t(E);
|
|
1076
|
-
const x = { ...E, cell:
|
|
1077
|
-
return
|
|
1078
|
-
}),
|
|
1079
|
-
}, [v,
|
|
1080
|
-
rt(
|
|
1081
|
-
}, []), At =
|
|
1082
|
-
rt(
|
|
1083
|
-
}, []), Cn =
|
|
1084
|
-
rt(
|
|
1085
|
-
}, []), xn =
|
|
1086
|
-
rt(
|
|
1087
|
-
}, []), In =
|
|
1088
|
-
Yt(
|
|
1089
|
-
}, []), En =
|
|
1090
|
-
Yt(
|
|
1091
|
-
}, []),
|
|
1092
|
-
Yt(
|
|
1093
|
-
}, []),
|
|
1094
|
-
Yt(
|
|
1095
|
-
}, []), pn =
|
|
1096
|
-
wn(
|
|
1097
|
-
}, []),
|
|
1098
|
-
wn(
|
|
1099
|
-
}, []),
|
|
1100
|
-
|
|
1101
|
-
}, []), Rn =
|
|
1102
|
-
rt(
|
|
1103
|
-
}, []),
|
|
1104
|
-
rt(
|
|
1105
|
-
}, []), m =
|
|
1106
|
-
rt(
|
|
1107
|
-
}, []), C =
|
|
1108
|
-
rt(
|
|
1109
|
-
}, []), S =
|
|
1110
|
-
rt(
|
|
1111
|
-
}, []), y =
|
|
1112
|
-
rt(
|
|
1113
|
-
}, []),
|
|
1114
|
-
rt(
|
|
1115
|
-
}, []),
|
|
1116
|
-
rt(
|
|
1117
|
-
}, []),
|
|
1118
|
-
rt(
|
|
1119
|
-
}, []),
|
|
1120
|
-
rt(
|
|
1121
|
-
}, []),
|
|
1122
|
-
rt(
|
|
1123
|
-
}, []),
|
|
1124
|
-
rt(
|
|
1125
|
-
}, []),
|
|
1126
|
-
rt(
|
|
1127
|
-
}, []), $e =
|
|
1128
|
-
rt(
|
|
1129
|
-
}, []),
|
|
1130
|
-
rt(
|
|
1131
|
-
}, []), Te =
|
|
1132
|
-
rt(
|
|
1133
|
-
}, []),
|
|
1134
|
-
|
|
1025
|
+
const x = { ...E, cell: f };
|
|
1026
|
+
return F.isEqualSelectionCoords(x, E) ? E : x;
|
|
1027
|
+
}), f && St(f);
|
|
1028
|
+
}, [v, Z]), bn = V((e = !1) => {
|
|
1029
|
+
rt(g.Down, e, !1, t.current.getDimensions().containerHeight);
|
|
1030
|
+
}, []), At = V((e = !1) => {
|
|
1031
|
+
rt(g.Up, e, !1, t.current.getDimensions().containerHeight);
|
|
1032
|
+
}, []), Cn = V((e = !1) => {
|
|
1033
|
+
rt(g.Right, e, !1, t.current.getDimensions().containerWidth);
|
|
1034
|
+
}, []), xn = V((e = !1) => {
|
|
1035
|
+
rt(g.Left, e, !1, t.current.getDimensions().containerWidth);
|
|
1036
|
+
}, []), In = V(() => {
|
|
1037
|
+
Yt(g.Left);
|
|
1038
|
+
}, []), En = V(() => {
|
|
1039
|
+
Yt(g.Right);
|
|
1040
|
+
}, []), Vn = V(() => {
|
|
1041
|
+
Yt(g.Up);
|
|
1042
|
+
}, []), Wn = V(() => {
|
|
1043
|
+
Yt(g.Down);
|
|
1044
|
+
}, []), pn = V(() => {
|
|
1045
|
+
wn(g.Left);
|
|
1046
|
+
}, []), Un = V(() => {
|
|
1047
|
+
wn(g.Right);
|
|
1048
|
+
}, []), Hn = V(() => {
|
|
1049
|
+
Fn();
|
|
1050
|
+
}, []), Rn = V(() => {
|
|
1051
|
+
rt(g.Left, !1, !1);
|
|
1052
|
+
}, []), h = V(() => {
|
|
1053
|
+
rt(g.Left, !0, !1);
|
|
1054
|
+
}, []), m = V(() => {
|
|
1055
|
+
rt(g.Left, !1, !0);
|
|
1056
|
+
}, []), C = V(() => {
|
|
1057
|
+
rt(g.Left, !0, !0);
|
|
1058
|
+
}, []), S = V(() => {
|
|
1059
|
+
rt(g.Right, !1, !1);
|
|
1060
|
+
}, []), y = V(() => {
|
|
1061
|
+
rt(g.Right, !0, !1);
|
|
1062
|
+
}, []), z = V(() => {
|
|
1063
|
+
rt(g.Right, !1, !0);
|
|
1064
|
+
}, []), xe = V(() => {
|
|
1065
|
+
rt(g.Right, !0, !0);
|
|
1066
|
+
}, []), re = V(() => {
|
|
1067
|
+
rt(g.Up, !1, !1);
|
|
1068
|
+
}, []), fe = V(() => {
|
|
1069
|
+
rt(g.Up, !0, !1);
|
|
1070
|
+
}, []), U = V(() => {
|
|
1071
|
+
rt(g.Up, !1, !0);
|
|
1072
|
+
}, []), Ee = V(() => {
|
|
1073
|
+
rt(g.Up, !0, !0);
|
|
1074
|
+
}, []), qe = V(() => {
|
|
1075
|
+
rt(g.Down, !1, !1);
|
|
1076
|
+
}, []), $e = V(() => {
|
|
1077
|
+
rt(g.Down, !0, !1);
|
|
1078
|
+
}, []), Ze = V(() => {
|
|
1079
|
+
rt(g.Down, !1, !0);
|
|
1080
|
+
}, []), Te = V(() => {
|
|
1081
|
+
rt(g.Down, !0, !0);
|
|
1082
|
+
}, []), ae = V(() => {
|
|
1083
|
+
ht((e) => e.slice(0, -1));
|
|
1135
1084
|
}, []), ct = Ae(() => {
|
|
1136
|
-
const e =
|
|
1137
|
-
return ((
|
|
1138
|
-
const x =
|
|
1139
|
-
for (let
|
|
1140
|
-
const
|
|
1141
|
-
if (
|
|
1085
|
+
const e = he();
|
|
1086
|
+
return ((s, u, a, f, E) => {
|
|
1087
|
+
const x = s.length;
|
|
1088
|
+
for (let j = 0; j < x; j++) {
|
|
1089
|
+
const B = s[j];
|
|
1090
|
+
if (B.rowStart === u && B.colStart === a && B.rowEnd === f && B.colEnd === E) return !0;
|
|
1142
1091
|
}
|
|
1143
1092
|
return !1;
|
|
1144
1093
|
})(v.ranges, e.top, e.left, e.bottom, e.right);
|
|
1145
|
-
}, [
|
|
1146
|
-
Ge.current = e,
|
|
1147
|
-
}, []), Be =
|
|
1148
|
-
const
|
|
1149
|
-
if (!
|
|
1150
|
-
const u =
|
|
1151
|
-
if (!
|
|
1152
|
-
let
|
|
1153
|
-
if (
|
|
1154
|
-
const E =
|
|
1155
|
-
let x = e ? Wt :
|
|
1094
|
+
}, [W, v.ranges]), et = V((e, s = !0) => {
|
|
1095
|
+
Ge.current = e, Je(e), s && e && t?.current && St(e);
|
|
1096
|
+
}, []), Be = P((e = !0) => {
|
|
1097
|
+
const s = Gt.current;
|
|
1098
|
+
if (!oe.current?.cell) return;
|
|
1099
|
+
const u = oe.current?.ranges, a = oe.current?.cell;
|
|
1100
|
+
if (!a || !s || !s) return;
|
|
1101
|
+
let f = null;
|
|
1102
|
+
if (f = u.length > 0 ? u[u.length - 1] : Z(a), f.colEnd >= f.colStart && f.rowEnd >= f.rowStart) {
|
|
1103
|
+
const E = ro(f, s);
|
|
1104
|
+
let x = e ? Wt : k;
|
|
1156
1105
|
try {
|
|
1157
|
-
x?.(
|
|
1158
|
-
} catch (
|
|
1159
|
-
console.warn(
|
|
1106
|
+
x?.(f, s, E.direction);
|
|
1107
|
+
} catch (j) {
|
|
1108
|
+
console.warn(j);
|
|
1160
1109
|
} finally {
|
|
1161
|
-
e &&
|
|
1110
|
+
e && Re?.();
|
|
1162
1111
|
}
|
|
1163
1112
|
}
|
|
1164
|
-
}, [
|
|
1165
|
-
if (
|
|
1166
|
-
const u = t.current.getViewFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY),
|
|
1167
|
-
|
|
1168
|
-
}, onPointerMoveOrWait: (e,
|
|
1169
|
-
if (
|
|
1113
|
+
}, [Z]), tt = se(null), yt = Ae(() => ({ onPointerDown: (e, s) => {
|
|
1114
|
+
if (Dt.current = s, !t || !t.current) return !1;
|
|
1115
|
+
const u = t.current.getViewFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY), a = u?.getCellCoordsFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY);
|
|
1116
|
+
a && (e.stopPropagation(), _t("crosshair"), tt.current = { anchor: u.getAnchor(), coords: a });
|
|
1117
|
+
}, onPointerMoveOrWait: (e, s) => {
|
|
1118
|
+
if (le || !t?.current || !oe.current || !tt.current) return;
|
|
1170
1119
|
const u = tt.current.anchor;
|
|
1171
|
-
let
|
|
1172
|
-
if (!
|
|
1173
|
-
tt.current = { anchor: u, coords:
|
|
1174
|
-
const E =
|
|
1175
|
-
let x =
|
|
1120
|
+
let a = t.current.getViewFromLocation(u), f = a.getCellCoordsFromClient(e.clientX, e.clientY);
|
|
1121
|
+
if (!f) return;
|
|
1122
|
+
tt.current = { anchor: u, coords: f };
|
|
1123
|
+
const E = oe.current.ranges;
|
|
1124
|
+
let x = Me(oe.current.cell, f);
|
|
1176
1125
|
if (!x) return;
|
|
1177
|
-
const
|
|
1126
|
+
const j = E.length > 0, B = j ? E[E.length - 1] : Z(oe.current.cell);
|
|
1178
1127
|
if (!x) return;
|
|
1179
|
-
const
|
|
1180
|
-
|
|
1181
|
-
const Se =
|
|
1182
|
-
if (!We?.(
|
|
1183
|
-
let
|
|
1184
|
-
typeof nn.current == "function" ?
|
|
1185
|
-
const
|
|
1186
|
-
if (I.length === 0) return
|
|
1187
|
-
if (
|
|
1188
|
-
const at =
|
|
1189
|
-
|
|
1190
|
-
} else if (
|
|
1191
|
-
const at =
|
|
1192
|
-
|
|
1193
|
-
} else if (
|
|
1194
|
-
const at =
|
|
1195
|
-
|
|
1196
|
-
} else if (
|
|
1197
|
-
const at =
|
|
1198
|
-
|
|
1128
|
+
const H = x.rowStart < B.rowStart ? g.Up : x.rowEnd > B.rowEnd ? g.Down : x.colEnd > B.colEnd ? g.Right : g.Left, G = he();
|
|
1129
|
+
H === g.Left && (x = { ...B, colStart: Math.max(G.left, x.colStart) }), H === g.Up && (x = { ...B, rowStart: Math.max(G.top, x.rowStart) }), H === g.Right && (x = { ...B, colEnd: Math.min(G.right, x.colEnd) }), H === g.Down && (x = { ...B, rowEnd: Math.min(G.bottom, x.rowEnd) });
|
|
1130
|
+
const Se = ro(B, x);
|
|
1131
|
+
if (!We?.(B)) {
|
|
1132
|
+
let K;
|
|
1133
|
+
typeof nn.current == "function" ? K = nn.current(B) : ke && (K = ke), x = ((N, dt, I, pe, Ct, ge) => {
|
|
1134
|
+
const de = { ...dt };
|
|
1135
|
+
if (I.length === 0) return de;
|
|
1136
|
+
if (Ct === g.Left) {
|
|
1137
|
+
const at = N.colEnd + 1 - N.colStart;
|
|
1138
|
+
de.colStart = N.colStart - Math.ceil(ge / at) * at, de.colStart < pe.left && (de.colStart = de.colStart + Math.ceil((pe.left - de.colStart) / at) * at);
|
|
1139
|
+
} else if (Ct === g.Right) {
|
|
1140
|
+
const at = N.colEnd + 1 - N.colStart;
|
|
1141
|
+
de.colEnd = N.colEnd + Math.ceil(ge / at) * at, de.colEnd > pe.right && (de.colEnd = de.colEnd - Math.ceil((pe.right - de.colEnd) / at) * at);
|
|
1142
|
+
} else if (Ct === g.Up) {
|
|
1143
|
+
const at = N.rowEnd + 1 - N.rowStart;
|
|
1144
|
+
de.rowStart = N.rowStart - Math.ceil(ge / at) * at, de.rowStart < pe.top && (de.rowStart = de.rowStart + Math.ceil((pe.top - de.rowStart) / at) * at);
|
|
1145
|
+
} else if (Ct === g.Down) {
|
|
1146
|
+
const at = N.rowEnd + 1 - N.rowStart;
|
|
1147
|
+
de.rowEnd = N.rowEnd + Math.ceil(ge / at) * at, de.rowEnd > pe.bottom && (de.rowEnd = de.rowEnd - Math.ceil((pe.bottom - de.rowEnd) / at) * at);
|
|
1199
1148
|
}
|
|
1200
|
-
return
|
|
1201
|
-
})(
|
|
1149
|
+
return de;
|
|
1150
|
+
})(B, x, K, G, Se.direction, Se.amount);
|
|
1202
1151
|
}
|
|
1203
|
-
if (
|
|
1152
|
+
if (j && F.isRangeWithinRange(x, B) && (x = null), !F.isEqualRanges(x, Gt.current)) {
|
|
1204
1153
|
if (hn(x), Gt.current = x, !x) {
|
|
1205
1154
|
try {
|
|
1206
1155
|
b?.();
|
|
1207
1156
|
} catch {
|
|
1208
1157
|
}
|
|
1209
|
-
return void
|
|
1158
|
+
return void Re?.();
|
|
1210
1159
|
}
|
|
1211
1160
|
Be(!1);
|
|
1212
1161
|
}
|
|
1213
|
-
|
|
1214
|
-
}, onPointerUp: (e,
|
|
1215
|
-
|
|
1216
|
-
|
|
1162
|
+
Dt.current = s, Tn(a, f, t);
|
|
1163
|
+
}, onPointerUp: (e, s) => {
|
|
1164
|
+
Dt.current = s, Promise.resolve(Be(!0)).finally(() => {
|
|
1165
|
+
Re?.(), hn(null), Gt.current = null, tt.current = null, _t(null), t.current?.focus();
|
|
1217
1166
|
});
|
|
1218
|
-
} }), [
|
|
1219
|
-
if (
|
|
1220
|
-
const u = t.current.getViewFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY),
|
|
1221
|
-
if (!
|
|
1222
|
-
if (
|
|
1223
|
-
e.stopPropagation(),
|
|
1224
|
-
const
|
|
1225
|
-
x.x -
|
|
1226
|
-
}, onPointerMoveOrWait: (e,
|
|
1227
|
-
if (Xe || !t?.current || !
|
|
1228
|
-
const
|
|
1229
|
-
if (
|
|
1230
|
-
const E =
|
|
1231
|
-
let
|
|
1232
|
-
if (!
|
|
1233
|
-
const
|
|
1234
|
-
|
|
1235
|
-
}, onPointerUp: (e,
|
|
1236
|
-
|
|
1167
|
+
} }), [Z]), je = un(yt), ee = Ae(() => ({ onPointerDown: je }), [je]), [Ye, pt] = gt(null), De = se(null), nt = Ae(() => ({ onPointerDown: (e, s) => {
|
|
1168
|
+
if (Dt.current = s, !t || !t.current) return !1;
|
|
1169
|
+
const u = t.current.getViewFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY), a = u?.getCellCoordsFromClient(e.nativeEvent.clientX, e.nativeEvent.clientY);
|
|
1170
|
+
if (!a) return;
|
|
1171
|
+
if (me?.(e, a, v) === !1) return !1;
|
|
1172
|
+
e.stopPropagation(), _t("default");
|
|
1173
|
+
const f = u.getRelativePointFromClient(0, 0), E = oe.current?.ranges[oe.current?.ranges.length - 1] ?? F.cellToRange(oe.current?.cell), x = u.toClipBounds(u.getRangeCoordsBounds(E)), j = { x: 0, y: 0 };
|
|
1174
|
+
x.x - f.x > e.nativeEvent.clientX ? j.x = e.nativeEvent.clientX - (x.x - f.x) : e.nativeEvent.clientX >= x.x - f.x + x.width && (j.x = Math.max(0, e.nativeEvent.clientX - (x.x - f.x + x.width)) + 1), x.y - f.y > e.nativeEvent.clientY ? j.y = e.nativeEvent.clientY - (x.y - f.y) : e.nativeEvent.clientY >= x.y - f.y + x.height && (j.y = Math.max(0, e.nativeEvent.clientY - (x.y - f.y + x.height)) + 1), ue?.(E, e.nativeEvent, s), De.current = { range: E, anchor: u.getAnchor(), cell: a, isMoving: !1, extrusion: j };
|
|
1175
|
+
}, onPointerMoveOrWait: (e, s, u) => {
|
|
1176
|
+
if (Xe || !t?.current || !oe.current || !De.current) return;
|
|
1177
|
+
const a = e.clientX - u.clientX, f = e.clientY - u.clientY;
|
|
1178
|
+
if (De.current.isMoving = De.current.isMoving || Math.abs(a) > Math.max(1, 2) || Math.abs(f) > Math.max(1, 2) || performance.now() - u.timeStamp > 500, !De.current.isMoving) return;
|
|
1179
|
+
const E = De.current.anchor, x = De.current.extrusion;
|
|
1180
|
+
let j = t.current.getViewFromLocation(E), B = j.getCellCoordsFromClient(e.clientX - x.x, e.clientY - x.y, !0);
|
|
1181
|
+
if (!B) return;
|
|
1182
|
+
const H = De.current.cell, G = De.current.range, Se = he(), K = G.colEnd - G.colStart + 1, N = Math.min(Math.max(0, H.colIndex - G.colStart), K - 1), dt = Math.min(Se.right - K + 1, Math.max(Se.left, B.colIndex - N)), I = G.rowEnd - G.rowStart + 1, pe = Math.min(Math.max(0, H.rowIndex - G.rowStart), I - 1), Ct = Math.min(Se.bottom - I + 1, Math.max(Se.top, B.rowIndex - pe)), ge = { colStart: dt, colEnd: dt + K - 1, rowStart: Ct, rowEnd: Ct + I - 1 };
|
|
1183
|
+
F.isEqualRanges(Ye, ge) && !((de) => !de || !Dt.current || Dt.current.ctrlKey !== de.ctrlKey || Dt.current.shiftKey !== de.shiftKey || Dt.current.altKey !== de.altKey || Dt.current.metaKey !== de.metaKey)(e) || (pt(ge), ye?.(ge, e, s)), Dt.current = s, Tn(j, B, t);
|
|
1184
|
+
}, onPointerUp: (e, s) => {
|
|
1185
|
+
Dt.current = s;
|
|
1237
1186
|
const u = () => {
|
|
1238
|
-
|
|
1187
|
+
pt(null), De.current = null, _t(null), t.current?.focus();
|
|
1239
1188
|
};
|
|
1240
|
-
if (!
|
|
1241
|
-
const
|
|
1242
|
-
|
|
1189
|
+
if (!De.current) return void u();
|
|
1190
|
+
const a = De.current.range, f = Ye;
|
|
1191
|
+
$?.(a, e, s), Promise.resolve(a && f && p?.(a, f, e, s)).finally(() => {
|
|
1243
1192
|
u();
|
|
1244
1193
|
});
|
|
1245
|
-
} }), [Ye]), Le = un(nt),
|
|
1246
|
-
const e =
|
|
1247
|
-
return
|
|
1248
|
-
}, [v]),
|
|
1249
|
-
let
|
|
1250
|
-
const
|
|
1251
|
-
const I = e.toClipBounds(e.getRangeCoordsBounds(
|
|
1194
|
+
} }), [Ye]), Le = un(nt), Oe = Ae(() => ({ onPointerDown: Le }), [Le]), mt = se(null), st = Ae(() => {
|
|
1195
|
+
const e = F.isEqualSelectionCoords(v, mt.current) ? mt.current : v;
|
|
1196
|
+
return mt.current = e, e;
|
|
1197
|
+
}, [v]), bt = V((e) => {
|
|
1198
|
+
let s = null, u = "br";
|
|
1199
|
+
const a = [], f = { stroke: J, fill: D, strokeWidth: 0.5 }, E = (K, N, dt) => {
|
|
1200
|
+
const I = e.toClipBounds(e.getRangeCoordsBounds(K), Vt);
|
|
1252
1201
|
if (!I) return;
|
|
1253
|
-
I.x = I.width > 0 ? I.x : I.x -
|
|
1254
|
-
const
|
|
1202
|
+
I.x = I.width > 0 ? I.x : I.x - f.strokeWidth / 2, I.y = I.height > 0 ? I.y : I.y - f.strokeWidth / 2, I.width = Math.max(I.width, f.strokeWidth), I.height = Math.max(I.height, f.strokeWidth);
|
|
1203
|
+
const pe = { key: `selection-fill-${N}`, range: K, ...I, ...f };
|
|
1255
1204
|
if (dt) {
|
|
1256
|
-
const
|
|
1257
|
-
|
|
1205
|
+
const Ct = e.getCellCoordsAsRangeCoords(dt);
|
|
1206
|
+
pe.cell = dt, pe.pathBounds = e.toClipBounds(e.getRangeCoordsBounds(Ct), Vt), pe.pathBounds && (pe.pathBounds.width <= 0 || pe.pathBounds.height <= 0) && (delete pe.pathBounds, delete pe.cell);
|
|
1258
1207
|
}
|
|
1259
|
-
return pe
|
|
1208
|
+
return we(pe);
|
|
1260
1209
|
};
|
|
1261
1210
|
let x = v ? $t(v) : null;
|
|
1262
|
-
const
|
|
1263
|
-
!x || x.ranges && x.ranges.length !== 0 || (x = { ranges: [
|
|
1264
|
-
for (let
|
|
1265
|
-
const
|
|
1266
|
-
dt &&
|
|
1267
|
-
const I = 2,
|
|
1268
|
-
if (
|
|
1269
|
-
const
|
|
1270
|
-
|
|
1211
|
+
const j = x?.cell ? e.getCellCoordsAsRangeCoords(x?.cell) : _o;
|
|
1212
|
+
!x || x.ranges && x.ranges.length !== 0 || (x = { ranges: [j], rangeIndex: 0, cell: x.cell });
|
|
1213
|
+
for (let K = 0; x && K < x.ranges.length; K++) {
|
|
1214
|
+
const N = x.ranges[K], dt = E(N, K, K === x.rangeIndex ? x.cell : null);
|
|
1215
|
+
dt && a.push(dt);
|
|
1216
|
+
const I = 2, pe = 0.5, Ct = e.toClipBounds(e.getRangeCoordsBounds(N, { top: 0, left: 0, right: 0, bottom: 0 }), Vt);
|
|
1217
|
+
if (Ct) {
|
|
1218
|
+
const ge = (x.ranges.length, 4);
|
|
1219
|
+
a.push(we({ range: N, key: `selection-inside-edge-${K}`, x: Ct.x - 1, y: Ct.y - 1, width: Math.max(Ct.width + 1, 0), height: Math.max(Ct.height + 1, 0), style: { overflow: "hidden" }, stroke: J, strokeWidth: ge }));
|
|
1271
1220
|
}
|
|
1272
1221
|
if (x.ranges.length === 1) {
|
|
1273
|
-
const
|
|
1274
|
-
if (
|
|
1275
|
-
Xe ||
|
|
1276
|
-
const
|
|
1277
|
-
|
|
1222
|
+
const ge = e.toClipBounds(e.getRangeCoordsBounds(N), Vt);
|
|
1223
|
+
if (ge) {
|
|
1224
|
+
Xe || a.push(we({ range: N, key: `move-selection-hit-box-${K}`, x: ge.width > 1 ? ge.x : ge.x - (be / 2 + 1), y: ge.height > 1 ? ge.y : ge.y - (be / 2 + 1), width: Math.max(ge.width + 2, 1), height: Math.max(ge.height + 2, 1), stroke: "transparent", style: { boxShadow: "none" }, pathProps: { cursor: Ye ? void 0 : "move", pointerEvents: "stroke" }, strokeWidth: be, ...Oe }));
|
|
1225
|
+
const de = I;
|
|
1226
|
+
a.push(we({ range: N, key: `selection-single-${K}`, x: ge.x - de / 2, y: ge.y - de / 2, width: Math.max(ge.width + de / 2, 1), height: Math.max(ge.height + de / 2, 1), stroke: q, strokeWidth: de }));
|
|
1278
1227
|
}
|
|
1279
1228
|
} else {
|
|
1280
|
-
const
|
|
1281
|
-
|
|
1229
|
+
const ge = e.toClipBounds(e.getRangeCoordsBounds(N, { top: -1, left: -1, right: -2, bottom: -2 }), Vt);
|
|
1230
|
+
ge && a.push(we({ range: N, key: `selection-multi-${K}`, x: ge.width > 1 ? ge.x : ge.x - pe / 2, y: ge.height > 1 ? ge.y : ge.y - pe / 2, width: Math.max(ge.width, pe) + 1, height: Math.max(ge.height, pe) + 1, stroke: q, style: { overflow: "hidden" }, strokeWidth: 2 }));
|
|
1282
1231
|
}
|
|
1283
|
-
if (x.ranges.length > 1 &&
|
|
1284
|
-
const
|
|
1285
|
-
|
|
1232
|
+
if (x.ranges.length > 1 && K === x.rangeIndex) {
|
|
1233
|
+
const ge = e.getCellCoordsAsRangeCoords(x.cell), de = e.toClipBounds(e.getRangeCoordsBounds(ge, { top: 1, left: 1, right: -1, bottom: -1 }), Vt);
|
|
1234
|
+
de && a.push(we({ range: N, key: `selection-anchor-${K}`, x: de.x, y: de.y, width: Math.max(de.width, pe), height: Math.max(de.height, pe), stroke: q, style: { overflow: "hidden" }, strokeWidth: 2 }));
|
|
1286
1235
|
}
|
|
1287
|
-
if (
|
|
1288
|
-
|
|
1289
|
-
const
|
|
1236
|
+
if (K === x.ranges.length - 1) {
|
|
1237
|
+
s = null, u = null;
|
|
1238
|
+
const ge = N.rowStart === he().top && N.rowEnd === he().bottom, de = N.colStart === he().left && N.colEnd === he().right, at = e.getRangeCoordsBounds(N);
|
|
1290
1239
|
let Ft = null;
|
|
1291
|
-
if (
|
|
1240
|
+
if (ge || de) {
|
|
1292
1241
|
if (Ft = e.toClipBounds(at, Vt), Object.keys(e.allViews()).length > 1) {
|
|
1293
|
-
const Mn = e.getVisibleRangeCoords(),
|
|
1294
|
-
(
|
|
1242
|
+
const Mn = e.getVisibleRangeCoords(), Jn = e.allViews()[Qe.TopLeft], ko = e.allViews()[Qe.Top], Po = e.allViews()[Qe.Left], kn = e.getAnchor();
|
|
1243
|
+
(de && (kn === Qe.Top && Jn || kn === Qe.Center && Po || !F.isCellWithinRange({ colIndex: N.colStart, rowIndex: N.rowEnd }, Mn) && !F.isCellWithinRange({ colIndex: N.colStart, rowIndex: N.rowEnd + 1 }, Mn)) || ge && (kn === Qe.Left && Jn || kn === Qe.Center && ko || !F.isCellWithinRange({ colIndex: N.colEnd, rowIndex: N.rowStart }, Mn) && !F.isCellWithinRange({ colIndex: N.colEnd + 1, rowIndex: N.rowStart }, Mn))) && (Ft = null);
|
|
1295
1244
|
}
|
|
1296
1245
|
} else Ft = e.toClipBounds(at, Vt);
|
|
1297
1246
|
if (!Ft || Ft.width === 0 || Ft.height === 0) continue;
|
|
1298
|
-
|
|
1247
|
+
s = { x: Ft.x + Ft.width + 1, y: Ft.y + Ft.height + 1 }, Ft.width === 0 || Ft.height === 0 || N.rowStart === he().top && N.colStart === he().left && N.rowEnd === he().bottom && N.colEnd === he().right || (ge ? (s.y = I, u = "tr") : de && (s.x = I, u = "bl"));
|
|
1299
1248
|
}
|
|
1300
1249
|
}
|
|
1301
|
-
let
|
|
1302
|
-
if (
|
|
1303
|
-
const
|
|
1304
|
-
|
|
1250
|
+
let B = null;
|
|
1251
|
+
if (Pe) {
|
|
1252
|
+
const K = e.toClipBounds(e.getRangeCoordsBounds(Pe, { top: 0, left: 0, right: 0, bottom: 0 }), Vt);
|
|
1253
|
+
K && (B = we({ ...f, range: Pe, key: "remove-selection", x: K.x, y: K.y, width: K.width, height: K.height, strokeWidth: 2, stroke: Pt, fill: Et }));
|
|
1305
1254
|
}
|
|
1306
|
-
let
|
|
1307
|
-
if (
|
|
1308
|
-
const
|
|
1309
|
-
|
|
1255
|
+
let H = null;
|
|
1256
|
+
if (Tt) {
|
|
1257
|
+
const K = e.toClipBounds(e.getRangeCoordsBounds(Tt, { top: 0, left: 0, right: 0, bottom: 0 }), Vt);
|
|
1258
|
+
K && (H = we({ range: Tt, key: "selection-fill-outline", x: K.x - 2 / 2, y: K.y - 2 / 2, width: K.width + 2 / 2, height: K.height + 2 / 2, strokeWidth: 2, stroke: q, strokeDasharray: "3 2" }));
|
|
1310
1259
|
}
|
|
1311
|
-
let
|
|
1312
|
-
!
|
|
1313
|
-
const Se = [...
|
|
1314
|
-
if (
|
|
1315
|
-
const
|
|
1316
|
-
Se.push(Ce(
|
|
1260
|
+
let G = null;
|
|
1261
|
+
!le && s && !Ye && (G = wo(yo, { ...s, corner: u, size: 7.5, borderStroke: `${J} solid`, style: { borderRadius: 1 }, background: q, ...ee, key: "fillHandle" }));
|
|
1262
|
+
const Se = [...a];
|
|
1263
|
+
if (B && Se.push(B), H && Se.push(H), G && Se.push(G), !wt && zt && x?.ranges.length === 1 && x.ranges[x.ranges.length - 1]) {
|
|
1264
|
+
const K = x.ranges[x.ranges.length - 1], N = K.rowStart === he().top && K.rowEnd === he().bottom, dt = K.colStart === he().left && K.colEnd === he().right, I = { view: e, range: K, borderStroke: `${q} solid`, background: J, selectionTouchPointerHandler: Ln, ...ut, onTouchSelectStart: (pe) => cn(pe), onTouchSelectEnd: () => cn(null), currentTouchAnchor: vn };
|
|
1265
|
+
Se.push(Ce(Xn, { anchor: dt ? "b" : N ? "r" : "br", scrollableElement: t.current, ...I }, "touch-select-handle-after")), Se.push(Ce(Xn, { anchor: dt ? "t" : N ? "l" : "tl", scrollableElement: t.current, ...I }, "touch-select-handle-before"));
|
|
1317
1266
|
}
|
|
1318
1267
|
if (Ye) {
|
|
1319
|
-
const
|
|
1320
|
-
|
|
1268
|
+
const K = e.toClipBounds(e.getRangeCoordsBounds(Ye, { top: 1, left: 1, right: 1, bottom: 1 }), Vt);
|
|
1269
|
+
K && Se.push(we({ range: Ye, key: "selection-move-outline", x: K.x - Y / 2, y: K.y - Y / 2, width: Math.max(K.width + Y / 2, 1), height: Math.max(K.height + Y / 2, 1), stroke: q, style: { boxShadow: "none", transitionDuration: "70ms", transitionTimingFunction: "ease-in", transitionProperty: "left, top, width, height", willChange: "left, top, width, height" }, strokeWidth: Y }));
|
|
1321
1270
|
}
|
|
1322
1271
|
return Ce("div", { children: Se }, "selection");
|
|
1323
|
-
}, [st,
|
|
1272
|
+
}, [st, Pe, le, Tt, Xe, Ye, he, J, q, D, Pt, Et, wt, ut, vn]), Lt = Ae(() => {
|
|
1324
1273
|
const e = () => t.current;
|
|
1325
|
-
return [new
|
|
1326
|
-
|
|
1327
|
-
}), new
|
|
1274
|
+
return [new ie("moveToPageDown", e, { label: "Page Down", description: "Shift viewport down one page.", shortcut: [{ key: "PageDown" }] }, () => bn(!1)), new ie("selectToPageDown", e, { label: "Select To Page Down", description: "Shift viewport and select down one page.", shortcut: [{ key: "PageDown", modifiers: [ce.Shift] }] }, () => bn(!0)), new ie("moveToPageRight", e, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [ce.Alt] }] }, () => Cn(!1)), new ie("selectToPageRight", e, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [ce.Alt, ce.Shift] }] }, () => Cn(!0)), new ie("moveToPageUp", e, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp" }] }, () => At(!1)), new ie("selectToPageUp", e, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp", modifiers: [ce.Shift] }] }, () => At(!0)), new ie("moveToPageLeft", e, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [ce.Alt] }] }, () => xn(!1)), new ie("selectToPageLeft", e, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [ce.Alt, ce.Shift] }] }, () => xn(!0)), new ie("selectColumn", e, { label: "Select Column", description: "Select the columns for the selected cells.", shortcut: { key: "Space", modifiers: [ce.Ctrl] } }, $n), new ie("selectRow", e, { label: "Select Row", description: "Select the rows for the selected cells.", shortcut: { key: "Space", modifiers: [ce.Shift] } }, Bn), new ie("selectToColumnStart", e, { label: "Select To Column Start", description: "Select the columns to the beginning of the sheet." }, () => Sn(!0)), new ie("selectToColumnEnd", e, { label: "Select To Column End", description: "Select the columns to the end of the sheet." }, () => yn(!0)), new ie("moveToRowStart", e, { label: "Move to Row Home", description: "Move to the beginning of the row.", shortcut: [{ key: "Home" }] }, () => fn(!1)), new ie("selectToRowStart", e, { label: "Select to Row Home", description: "Select to the beginning of the row.", shortcut: [{ key: "Home", modifiers: [ce.Shift] }] }, () => fn(!0)), new ie("moveToSheetStart", e, { label: "Move to Sheet Home", description: "Move to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [ce.Ctrl] }] }, () => an(!1)), new ie("selectToSheetStart", e, { label: "Select to Sheet Home", description: "Select to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [ce.Ctrl, ce.Shift] }] }, () => an(!0)), new ie("moveToRowEnd", e, { label: "Move to Row End", description: "Move to the end of the row.", shortcut: [{ key: "End" }] }, () => gn(!1)), new ie("selectToRowEnd", e, { label: "Select to Row End", description: "Select to the end of the row.", shortcut: [{ key: "End", modifiers: [ce.Shift] }] }, () => gn(!0)), new ie("moveToSheetEnd", e, { label: "Move to Sheet End", description: "Move to the end of the sheet.", shortcut: [{ key: "End", modifiers: [ce.Ctrl] }] }, () => on(!1)), new ie("selectToSheetEnd", e, { label: "Select to Sheet End", description: "Select to the end of the sheet.", shortcut: [{ key: "End", modifiers: [ce.Ctrl, ce.Shift] }] }, () => on(!0)), new ie("scrollToActiveCoords", e, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell.", shortcut: { key: "Backspace", modifiers: [ce.Ctrl] } }, Jt), new ie("scrollToActiveCoordsClearSelection", e, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell and clear selection.", shortcut: { key: "Backspace", modifiers: [ce.Shift] } }, () => {
|
|
1275
|
+
Zt(), et(v.cell, !0);
|
|
1276
|
+
}), new ie("traverseSelectionRight", e, { label: "Traverse Right", description: "Traverse the selection moving rightward.", shortcut: { key: "Tab" } }, En), new ie("traverseSelectionLeft", e, { label: "Traverse Left", description: "Traverse the selection moving leftward.", shortcut: { key: "Tab", modifiers: [ce.Shift] } }, In), new ie("traverseSelectionDown", e, { label: "Traverse Down", description: "Traverse the selection moving downward.", shortcut: [{ key: "Enter" }, { key: "NumpadEnter" }] }, Wn), new ie("traverseSelectionUp", e, { label: "Traverse Up", description: "Traverse the selection moving upward.", shortcut: [{ key: "Enter", modifiers: [ce.Shift] }, { key: "NumpadEnter", modifiers: [ce.Shift] }] }, Vn), new ie("moveLeft", e, { label: "Move Left", description: "Move active cell to the left.", shortcut: [{ key: "ArrowLeft" }] }, Rn), new ie("selectLeft", e, { label: "Select Left", description: "Extend selection left.", shortcut: [{ key: "ArrowLeft", modifiers: [ce.Shift] }] }, h), new ie("moveContentfulLeft", e, { label: "Move Left Contentful", description: "Move left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [ce.Ctrl] }] }, m), new ie("selectContentfulLeft", e, { label: "Select Left Contentful", description: "Extend selection left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [ce.Ctrl, ce.Shift] }] }, C), new ie("moveRight", e, { label: "Move Right", description: "Move active cell to the right.", shortcut: [{ key: "ArrowRight" }] }, S), new ie("selectRight", e, { label: "Select Right", description: "Extend selection right.", shortcut: [{ key: "ArrowRight", modifiers: [ce.Shift] }] }, y), new ie("moveContentfulRight", e, { label: "Move Right Contentful", description: "Move right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [ce.Ctrl] }] }, z), new ie("selectContentfulRight", e, { label: "Select Right Contentful", description: "Extend selection right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [ce.Ctrl, ce.Shift] }] }, xe), new ie("moveUp", e, { label: "Move Up", description: "Move active cell to the up.", shortcut: [{ key: "ArrowUp" }] }, re), new ie("selectUp", e, { label: "Select Up", description: "Extend selection up.", shortcut: [{ key: "ArrowUp", modifiers: [ce.Shift] }] }, fe), new ie("moveContentfulUp", e, { label: "Move Up Contentful", description: "Move up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [ce.Ctrl] }] }, U), new ie("selectContentfulUp", e, { label: "Select Up Contentful", description: "Extend selection up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [ce.Ctrl, ce.Shift] }] }, Ee), new ie("moveDown", e, { label: "Move Down", description: "Move active cell to the down.", shortcut: [{ key: "ArrowDown" }] }, qe), new ie("selectDown", e, { label: "Select Down", description: "Extend selection down.", shortcut: [{ key: "ArrowDown", modifiers: [ce.Shift] }] }, $e), new ie("moveContentfulDown", e, { label: "Move Down Contentful", description: "Move down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [ce.Ctrl] }] }, Ze), new ie("selectContentfulDown", e, { label: "Select Down Contentful", description: "Extend selection down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [ce.Ctrl, ce.Shift] }] }, Te), new ie("selectVisible", e, { label: "Select Visible", description: "Select visible cells only.", shortcut: { key: ";", modifiers: [ce.Alt] } }, An), new ie("traverseSelectionPreviousRange", e, { label: "Traverse Previous Range", description: "Traverse the selection to the previous range.", shortcut: { key: "ArrowLeft", modifiers: [ce.Ctrl, ce.Alt] } }, pn), new ie("traverseSelectionNextRange", e, { label: "Traverse Next Range", description: "Traverse the selection to the next range.", shortcut: { key: "ArrowRight", modifiers: [ce.Ctrl, ce.Alt] } }, Un), new ie("traverseSelectionCorners", e, { label: "Traverse Corners", description: "Traverse the selection through the corners of the selected range.", shortcut: { key: ".", modifiers: [ce.Ctrl] } }, Hn)];
|
|
1328
1277
|
}, []);
|
|
1329
1278
|
return Ae(() => {
|
|
1330
1279
|
n?.addCommands(Lt, !0);
|
|
1331
|
-
}, [n]), { selection: st, setSelectionCell: et, setSelectionRanges:
|
|
1280
|
+
}, [n]), { selection: st, setSelectionCell: et, setSelectionRanges: ht, overlay: bt, cursor: ln, onPointerDown: zn, clearLastSelection: ae, newSelection: Rt, modifySelection: ft, appendSelection: Ie, clearSelections: Zt, isEntire: ct, navigate: rt, navigateSelection: Yt };
|
|
1332
1281
|
};
|
|
1333
|
-
function
|
|
1282
|
+
function Dn(t, n) {
|
|
1334
1283
|
if (!t) throw new Error("Invariant failed");
|
|
1335
1284
|
}
|
|
1336
|
-
const
|
|
1337
|
-
const { width: o, height: r, rowCount: c = 1, columnCount:
|
|
1338
|
-
|
|
1339
|
-
const
|
|
1340
|
-
const
|
|
1341
|
-
return Gt.current = null, { getColOffset: (m) =>
|
|
1342
|
-
}, [hn,
|
|
1285
|
+
const so = { "sheetxl-grid": "_sheetxl-grid_h9wwa_7" }, Jo = Object.freeze({ top: 0, left: 0 }), Qo = Object.freeze({ bottom: -4, right: -4 }), er = Object.freeze({ horizontal: !0, vertical: !0 }), ao = [Qe.TopLeft, Qe.Top, Qe.Left, Qe.Center], vr = 150, Xt = 3e3, qn = {}, Co = Kt(tn((t, n) => {
|
|
1286
|
+
const { width: o, height: r, rowCount: c = 1, columnCount: d = 1, defaultRowHeight: i, defaultColumnWidth: l, getRowHeight: w, getColumnWidth: L, layout: O, onViewportScroll: R, onImmediateScroll: M, showGridLines: A = !0, gridLineColor: le = "rgb(224, 224, 224)", gridLineRowsProps: J, gridLineColumnsProps: te, clipCells: ze = !0, cursor: Q, freezeLeft: T = 0, freezeTop: _ = 0, freezeLeftProps: ve, freezeTopProps: W, cellRenderer: me, onViewportChange: Ve, onFirstRender: ke, overlayRenderer: We, overlayProps: ue, overlays: ye, overlaysProps: $, allowOverlaysOverflow: p = !1, stageProps: Ne, stageWrapper: Xe = null, hiddenRowsAt: Z, hiddenColumnsAt: be, hiddenCellAt: Y, getVisibleCells: D, zoom: q = 1, enableMouseWheel: Pt = !0, onWheelScroll: Et, getCellCoordsAsRangeCoords: wt = F.cellToRange, scrollPoint: ut = Jo, style: he = {}, ...Wt } = t;
|
|
1287
|
+
Dn(me), Dn(!t?.children);
|
|
1288
|
+
const k = P(M, [M]), b = P(Ve, [Ve]), Re = P(R, [R]), ne = P(Et, [Et]), we = P(ke, [ke]), Ue = se(null), lt = se(null), Mt = se(null), [it, qt] = Zn((h) => h + 1, 0), [xt, v] = gt({ left: ut?.left ?? 0, top: ut?.top ?? 0, horizontalScrollDirection: null, verticalScrollDirection: null }), oe = se(null), He = se(xt), { top: ht, left: Je, verticalScrollDirection: ln, horizontalScrollDirection: _t } = xt, Tt = se(!1), hn = Bo({ rowCount: c, columnCount: d, defaultRowHeight: i, defaultColumnWidth: l, getRowHeight: w, getColumnWidth: L }), Gt = se(null), Pe = Ae(() => {
|
|
1289
|
+
const h = O || hn;
|
|
1290
|
+
return Gt.current = null, { getColOffset: (m) => h.getColOffset(m) * q, getColIndex: (m) => h.getColIndex(m / q), getRowOffset: (m) => h.getRowOffset(m) * q, getRowIndex: (m) => h.getRowIndex(m / q) };
|
|
1291
|
+
}, [hn, O, q]), Ut = (h, m, C) => {
|
|
1343
1292
|
const S = (m?.left ?? 0) + 0, y = (m?.top ?? 0) + 0;
|
|
1344
|
-
return { getColOffset: (
|
|
1345
|
-
},
|
|
1293
|
+
return { getColOffset: (z) => h.getColOffset(z) - S, getColIndex: (z) => h.getColIndex(z + S), getRowOffset: (z) => h.getRowOffset(z) - y, getRowIndex: (z) => h.getRowIndex(z + y) };
|
|
1294
|
+
}, vt = P((h, m = !1) => On(h, m, Pe.getRowOffset, m ? 0 : c), [c, Pe?.getRowOffset]), Bt = P(Z ?? vt, [Z]), vn = P((h, m = !1) => On(h, m, Pe.getColOffset, m ? d : 0), [d, Pe?.getColOffset]), cn = P(be ?? vn, [be]), Ge = Ae(() => Math.min(o ?? 800, Pe.getColOffset(d)), [Pe.getColOffset, d, o]), Ke = Ae(() => Math.min(r ?? 600, Pe.getRowOffset(c)), [Pe.getRowOffset, c, r]), nn = V((h) => {
|
|
1346
1295
|
Nt.canUseDOM && setTimeout(() => {
|
|
1347
|
-
Ue.current?.focus({ preventScroll: !0, ...
|
|
1296
|
+
Ue.current?.focus({ preventScroll: !0, ...h });
|
|
1348
1297
|
}, 0);
|
|
1349
|
-
}, []),
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
}, [
|
|
1353
|
-
const
|
|
1354
|
-
const
|
|
1298
|
+
}, []), St = V((h) => Ue.current?.contains(h) || lt.current?.contains(h), []);
|
|
1299
|
+
It(() => {
|
|
1300
|
+
Tt.current && (oe.current && oe.current.left !== He.current?.left && oe.current.top !== He.current?.top || (oe.current = null, Re?.({ left: Je, top: ht })));
|
|
1301
|
+
}, [Je, ht]);
|
|
1302
|
+
const jt = P(() => ({ top: ht, left: Je }), [ht, Je]), Me = Ae(() => {
|
|
1303
|
+
const h = [];
|
|
1355
1304
|
let m = 0, C = 0;
|
|
1356
|
-
typeof
|
|
1357
|
-
const S = C, y =
|
|
1305
|
+
typeof _ == "number" ? m = _ : (m = _.index ?? 0, C = (_.scrollOffset ?? 0) * q);
|
|
1306
|
+
const S = C, y = Pe.getRowOffset(m), z = y - S;
|
|
1358
1307
|
if (m > 0) {
|
|
1359
|
-
const
|
|
1308
|
+
const qe = Ut(Pe, { top: C + Pe.getRowOffset(0) }), $e = Pe.getRowIndex(S), Ze = Pe.getRowIndex(y - 1);
|
|
1360
1309
|
let Te;
|
|
1361
|
-
|
|
1310
|
+
h[1] = { minIndex: $e, maxIndex: Ze, minCoord: 0, maxCoord: m - 1, minBounds: 0, maxBounds: z, visibleIndices: () => Te || (Te = Object.freeze(Pn(Bt, $e, Ze)), Te), layout: qe, maxVirtualBounds: y, scrollOffset: C, freezeOffset: C };
|
|
1362
1311
|
}
|
|
1363
|
-
const
|
|
1364
|
-
let
|
|
1365
|
-
return
|
|
1366
|
-
}, [
|
|
1367
|
-
const
|
|
1312
|
+
const xe = Math.max(0, Ke - z), re = Ut(Pe, { top: ht + z }), fe = re.getRowIndex(0), U = re.getRowIndex(xe);
|
|
1313
|
+
let Ee;
|
|
1314
|
+
return h[0] = { minIndex: fe, maxIndex: U, minCoord: m, maxCoord: c - 1, minBounds: z, maxBounds: xe, visibleIndices: () => Ee || (Ee = Object.freeze(Pn(Bt, fe, U)), Ee), layout: re, maxVirtualBounds: Pe.getRowOffset(c), scrollOffset: ht, freezeOffset: (m > 0 ? Pe.getRowOffset(m) : 0) - C }, h;
|
|
1315
|
+
}, [Pe.getRowIndex, Pe.getRowOffset, Bt, Ke, c, _, ht, q]), _e = Ae(() => {
|
|
1316
|
+
const h = [];
|
|
1368
1317
|
let m = 0, C = 0;
|
|
1369
|
-
typeof
|
|
1370
|
-
const S = C, y =
|
|
1318
|
+
typeof T == "number" ? m = T : (m = T.index ?? 0, C = (T.scrollOffset ?? 0) * q);
|
|
1319
|
+
const S = C, y = Pe.getColOffset(m), z = y - S;
|
|
1371
1320
|
if (m > 0) {
|
|
1372
|
-
const
|
|
1321
|
+
const qe = Ut(Pe, { left: C + Pe.getColOffset(0) }), $e = Pe.getColIndex(S), Ze = Pe.getColIndex(y - 1);
|
|
1373
1322
|
let Te;
|
|
1374
|
-
|
|
1323
|
+
h[1] = { minIndex: $e, maxIndex: Ze, minCoord: 0, maxCoord: m - 1, minBounds: 0, maxBounds: z, visibleIndices: () => Te || (Te = Object.freeze(Pn(cn, $e, Ze)), Te), layout: qe, maxVirtualBounds: y, scrollOffset: C, freezeOffset: C };
|
|
1375
1324
|
}
|
|
1376
|
-
const
|
|
1377
|
-
let
|
|
1378
|
-
return
|
|
1379
|
-
}, [
|
|
1380
|
-
let
|
|
1381
|
-
const m = (S, y,
|
|
1382
|
-
const
|
|
1383
|
-
if (S >=
|
|
1384
|
-
const
|
|
1385
|
-
if (
|
|
1386
|
-
const
|
|
1325
|
+
const xe = Math.max(0, Ge - z), re = Ut(Pe, { left: Je + z }), fe = re.getColIndex(0), U = re.getColIndex(xe);
|
|
1326
|
+
let Ee;
|
|
1327
|
+
return h[0] = { minIndex: fe, maxIndex: U, minCoord: m, maxCoord: d - 1, minBounds: z, maxBounds: xe, visibleIndices: () => Ee || (Ee = Object.freeze(Pn(cn, fe, U)), Ee), layout: re, maxVirtualBounds: Pe.getColOffset(d), scrollOffset: Je, freezeOffset: (m > 0 ? Pe.getColOffset(m) : 0) - C }, h;
|
|
1328
|
+
}, [Pe.getColIndex, Pe.getColOffset, cn, Ge, d, T, Je, q]), ft = se({}), Rt = se([]), Ie = Ae(() => {
|
|
1329
|
+
let h = {};
|
|
1330
|
+
const m = (S, y, z, xe, re) => {
|
|
1331
|
+
const fe = { vertical: xe?.vertical || !1, horizontal: xe?.horizontal || !1 };
|
|
1332
|
+
if (S >= _e.length || y >= Me.length) return null;
|
|
1333
|
+
const U = { rowStart: Me[y].minIndex, colStart: _e[S].minIndex, rowEnd: Me[y].maxIndex, colEnd: _e[S].maxIndex };
|
|
1334
|
+
if (U.rowStart > U.rowEnd || U.colStart > U.colEnd) return null;
|
|
1335
|
+
const Ee = { getColIndex: (ee) => _e[S].layout.getColIndex(ee), getColOffset: (ee) => _e[S].layout.getColOffset(ee), getRowIndex: (ee) => Me[y].layout.getRowIndex(ee), getRowOffset: (ee) => Me[y].layout.getRowOffset(ee) }, qe = Object.freeze({ left: re?.left ?? 0, top: re?.top ?? 0, right: re?.right ?? 0, bottom: re?.bottom ?? 0 }), $e = Object.freeze({ x: _e[S].minBounds, y: Me[y].minBounds, width: _e[S].maxBounds, height: Me[y].maxBounds }), Ze = (ee, Ye) => io(Ee, ee ?? U, Ye), Te = { width: _e[S].maxVirtualBounds, height: Me[y].maxVirtualBounds }, ae = { left: _e[S].scrollOffset, top: Me[y].scrollOffset }, ct = { left: _e[S].freezeOffset, top: Me[y].freezeOffset }, et = { width: Ge, height: Ke };
|
|
1387
1336
|
let Be = null, tt = null;
|
|
1388
|
-
const
|
|
1389
|
-
return { getStage: () => Ue.current ?? null, getVisibleRangeCoords: () =>
|
|
1390
|
-
let
|
|
1391
|
-
return Ye === void 0 || typeof Ye == "number" ? (
|
|
1337
|
+
const yt = (ct.top + (xe.vertical ? ae.top : 0)) / q, je = (ct.left + (xe.horizontal ? ae.left : 0)) / q;
|
|
1338
|
+
return { getStage: () => Ue.current ?? null, getVisibleRangeCoords: () => U, toClipBounds: (ee, Ye) => {
|
|
1339
|
+
let pt, De = 0;
|
|
1340
|
+
return Ye === void 0 || typeof Ye == "number" ? (pt = Ze(U), De = Ye) : pt = Ye, ((nt, Le, Oe = 0) => {
|
|
1392
1341
|
if (nt.x > Le.width || nt.y > Le.height) return null;
|
|
1393
|
-
const
|
|
1342
|
+
const mt = { left: nt.x, top: nt.y, bottom: nt.height + nt.y, right: nt.width + nt.x }, st = { left: Le.x + Oe, top: Le.y + Oe, bottom: Le.height - 2 * Oe + Le.y, right: Le.width - 2 * Oe + Le.x }, bt = { left: Math.max(mt.left, st.left), top: Math.max(mt.top, st.top), bottom: Math.min(mt.bottom, st.bottom), right: Math.min(mt.right, st.right) }, Lt = { x: bt.left, y: bt.top, width: bt.right - bt.left, height: bt.bottom - bt.top };
|
|
1394
1343
|
return Lt.height < 0 || Lt.width < 0 ? null : Lt;
|
|
1395
|
-
})(
|
|
1396
|
-
}, toViewBounds: (
|
|
1397
|
-
const
|
|
1398
|
-
return { x:
|
|
1399
|
-
}, getLayout: () =>
|
|
1400
|
-
const
|
|
1401
|
-
if (!
|
|
1402
|
-
const nt =
|
|
1403
|
-
if (
|
|
1404
|
-
const
|
|
1405
|
-
return { rowIndex:
|
|
1406
|
-
}, getZoom: () =>
|
|
1344
|
+
})(ee ?? { x: 0, y: 0, width: $e.width, height: $e.height }, pt, De);
|
|
1345
|
+
}, toViewBounds: (ee) => je === 0 && yt === 0 && q === 1 ? ee : { x: (ee.x - je) * q, y: (ee.y - yt) * q, width: ee.width * q, height: ee.height * q }, toAbsoluteBounds: (ee) => je === 0 && yt === 0 && q === 1 ? ee : { x: ee.x / q + je, y: ee.y / q + yt, width: ee.width / q, height: ee.height / q }, getRelativePointFromClient: (ee, Ye) => {
|
|
1346
|
+
const pt = sn(ee, Ye);
|
|
1347
|
+
return { x: pt.x - $e.x, y: pt.y - $e.y };
|
|
1348
|
+
}, getLayout: () => Ee, getCellCoordsAsRangeCoords: wt, getVisibleColumns: () => _e[S].visibleIndices(), getVisibleRows: () => Me[y].visibleIndices(), getVisibleColumnOffsets: () => (Be || (Be = lo(_e[S].layout, !0, _e[S].visibleIndices(), U.colStart, U.colEnd)), Be), getVisibleRowOffsets: () => (tt || (tt = lo(Me[y].layout, !1, Me[y].visibleIndices(), U.rowStart, U.rowEnd)), tt), getTotalRangeCoords: () => ({ colStart: _e[S].minCoord, colEnd: _e[S].maxCoord, rowStart: Me[y].minCoord, rowEnd: Me[y].maxCoord }), getRangeCoordsBounds: Ze, scrollCellCoordsIntoView: (ee, Ye) => fn(ee, Ye, z), getCellCoordsFromClient: (ee, Ye, pt = !1) => {
|
|
1349
|
+
const De = sn(ee, Ye);
|
|
1350
|
+
if (!De) return null;
|
|
1351
|
+
const nt = Ee.getColIndex(De.x - $e.x), Le = { rowIndex: Ee.getRowIndex(De.y - $e.y), colIndex: nt };
|
|
1352
|
+
if (pt) return Le;
|
|
1353
|
+
const Oe = wt(Le);
|
|
1354
|
+
return { rowIndex: Oe.rowStart, colIndex: Oe.colStart };
|
|
1355
|
+
}, getZoom: () => q, getAnchor: () => z, getBounds: () => $e, getInsets: () => qe, getTotalSize: () => Te, getViewportSize: () => et, getScrollTopLeft: () => ae, getFreezeTopLeft: () => ct, getScrollOrientation: () => fe, allViews: () => h };
|
|
1407
1356
|
};
|
|
1408
|
-
let C =
|
|
1409
|
-
return C && (
|
|
1410
|
-
}, [
|
|
1411
|
-
|
|
1357
|
+
let C = h[Qe.Center] = m(0, 0, Qe.Center, er, Qo);
|
|
1358
|
+
return C && (h[Qe.Center] = C), C = m(0, 1, Qe.Top, { horizontal: !0 }), C && (h[Qe.Top] = C), C = m(1, 0, Qe.Left, { vertical: !0 }), C && (h[Qe.Left] = C), C = m(1, 1, Qe.TopLeft, {}), C && (h[Qe.TopLeft] = C), ft.current = null, h = Object.freeze(h);
|
|
1359
|
+
}, [Me, _e, wt]), Zt = Object.keys(Ie), zt = _e[0]?.maxVirtualBounds ?? 0, ot = Me[0]?.maxVirtualBounds ?? 0, kt = Ae(() => ({ left: _e[1] ? _e[1].layout.getColOffset(_e[1].maxIndex + 1) : 0, top: Me[1] ? Me[1].layout.getRowOffset(Me[1].maxIndex + 1) : 0 }), [Ie]);
|
|
1360
|
+
It(() => {
|
|
1412
1361
|
if (Rt.current.length > 0) {
|
|
1413
|
-
for (let
|
|
1362
|
+
for (let h = 0; h < Rt.current.length; h++) Rt.current[h]();
|
|
1414
1363
|
Rt.current = [];
|
|
1415
1364
|
}
|
|
1416
|
-
}, [
|
|
1417
|
-
const
|
|
1418
|
-
|
|
1419
|
-
!
|
|
1420
|
-
}, [
|
|
1421
|
-
|
|
1365
|
+
}, [Ie]);
|
|
1366
|
+
const Dt = P(() => ({ containerWidth: Ge, containerHeight: Ke, totalWidth: zt, totalHeight: ot }), [Ge, Ke, Pe]);
|
|
1367
|
+
It(() => {
|
|
1368
|
+
!oe.current && Tt.current && b({ top: ht, left: Je, width: Ge, height: Ke, totalWidth: zt, totalHeight: ot });
|
|
1369
|
+
}, [ht, Je, zt, ot]), It(() => {
|
|
1370
|
+
Tt.current && b({ top: ht, left: Je, width: Ge, height: Ke, totalWidth: zt, totalHeight: ot });
|
|
1422
1371
|
}, [Ge, Ke]);
|
|
1423
|
-
const sn =
|
|
1424
|
-
|
|
1372
|
+
const sn = V((h, m) => {
|
|
1373
|
+
Dn(typeof h == "number" && typeof m == "number");
|
|
1425
1374
|
const C = Ue.current?.getBoundingClientRect();
|
|
1426
|
-
return C ? { x:
|
|
1427
|
-
}, []),
|
|
1428
|
-
if (Object.keys(
|
|
1429
|
-
const C = sn(
|
|
1375
|
+
return C ? { x: h - C.x, y: m - C.y } : { x: h, y: m };
|
|
1376
|
+
}, []), zn = P((h) => Ie[h] || null, [Ie]), Ln = P((h, m) => {
|
|
1377
|
+
if (Object.keys(Ie).length === 1) return Ie[Qe.Center];
|
|
1378
|
+
const C = sn(h, m);
|
|
1430
1379
|
if (!C) return null;
|
|
1431
1380
|
const { x: S, y } = C;
|
|
1432
|
-
let
|
|
1433
|
-
const
|
|
1434
|
-
for (let
|
|
1435
|
-
const
|
|
1436
|
-
|
|
1381
|
+
let z = null;
|
|
1382
|
+
const xe = ao, re = xe.length;
|
|
1383
|
+
for (let fe = 0; !z && fe < re; fe++) {
|
|
1384
|
+
const U = Ie[xe[fe]];
|
|
1385
|
+
U && qo(S, y, U.getBounds()) && (z = U);
|
|
1437
1386
|
}
|
|
1438
|
-
return
|
|
1439
|
-
}, [
|
|
1440
|
-
Yt.current !== null && Nt.cancelTimeout(Yt.current), Yt.current = Nt.requestTimeout(
|
|
1441
|
-
}, []),
|
|
1442
|
-
Yt.current = null, v((
|
|
1443
|
-
const m = { ...
|
|
1387
|
+
return z || (z = Ie[Qe.Center]), z;
|
|
1388
|
+
}, [Ie, wt]), rt = P(() => Ie[Qe.Center].getVisibleRangeCoords(), [Ie[Qe.Center]]), Yt = se(null), $n = V(() => {
|
|
1389
|
+
Yt.current !== null && Nt.cancelTimeout(Yt.current), Yt.current = Nt.requestTimeout(Bn, 150);
|
|
1390
|
+
}, []), Bn = V(() => {
|
|
1391
|
+
Yt.current = null, v((h) => {
|
|
1392
|
+
const m = { ...h, verticalScrollDirection: null, horizontalScrollDirection: null };
|
|
1444
1393
|
return He.current = m, m;
|
|
1445
1394
|
});
|
|
1446
|
-
}, []),
|
|
1447
|
-
const m =
|
|
1395
|
+
}, []), Jt = P((h) => {
|
|
1396
|
+
const m = h?.left ?? h?.[0], C = h?.top ?? h?.[1];
|
|
1448
1397
|
let S = He.current.left;
|
|
1449
|
-
m !== void 0 && m !== S && (m > S ? (S = Math.max(
|
|
1398
|
+
m !== void 0 && m !== S && (m > S ? (S = Math.max(_e?.[1]?.scrollOffset ?? 0, m), S = Math.min(zt - Ge, S)) : S = Math.max(_e?.[1]?.scrollOffset ?? 0, m));
|
|
1450
1399
|
let y = He.current.top;
|
|
1451
|
-
if (C !== void 0 && C !== y && (C > y ? (y = Math.max(
|
|
1452
|
-
let
|
|
1453
|
-
He.current.left > S ?
|
|
1454
|
-
v((
|
|
1455
|
-
const
|
|
1456
|
-
return He.current =
|
|
1400
|
+
if (C !== void 0 && C !== y && (C > y ? (y = Math.max(Me?.[1]?.scrollOffset ?? 0, C), y = Math.min(ot - Ke, y)) : y = Math.max(Me?.[1]?.scrollOffset ?? 0, C)), He.current.left === S && He.current.top === y) return;
|
|
1401
|
+
let z = null, xe = null;
|
|
1402
|
+
He.current.left > S ? z = g.Left : He.current.left < S && (z = g.Right), He.current.top > y ? xe = g.Up : He.current.top < y && (xe = g.Down), Nt.throttle(() => {
|
|
1403
|
+
v((re) => {
|
|
1404
|
+
const fe = { ...re, left: S, top: y, horizontalScrollDirection: z, verticalScrollDirection: xe };
|
|
1405
|
+
return He.current = fe, fe;
|
|
1457
1406
|
});
|
|
1458
|
-
}, 17)(),
|
|
1459
|
-
}, [zt, ot,
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
}, [Ge, Ke]),
|
|
1463
|
-
let
|
|
1464
|
-
He.current.left > zt && (
|
|
1407
|
+
}, 17)(), oe.current?.top === y && oe.current?.left === S || (oe.current = { left: S, top: y }, k({ left: S, top: y }), b({ left: S, top: y, width: Ge, height: Ke, totalWidth: zt, totalHeight: ot })), $n();
|
|
1408
|
+
}, [zt, ot, Me, _e]);
|
|
1409
|
+
It(() => {
|
|
1410
|
+
oe.current || Jt({ left: Je, top: ht });
|
|
1411
|
+
}, [Ge, Ke]), It(() => {
|
|
1412
|
+
let h, m, C = !1;
|
|
1413
|
+
He.current.left > zt && (h = 0, C = !0), He.current.top > ot && (m = 0, C = !0), C && Jt({ left: h, top: m });
|
|
1465
1414
|
}, [zt, ot]), en(() => {
|
|
1466
|
-
|
|
1467
|
-
}, [
|
|
1468
|
-
const Sn =
|
|
1469
|
-
let m =
|
|
1415
|
+
oe.current = { left: ut?.left, top: ut?.top }, Jt(oe.current);
|
|
1416
|
+
}, [ut?.left, ut?.top]);
|
|
1417
|
+
const Sn = P((h) => {
|
|
1418
|
+
let m = h?.left ?? h?.[0], C = h?.top ?? h?.[1];
|
|
1470
1419
|
if (m === void 0 && C === void 0) return;
|
|
1471
|
-
const S =
|
|
1472
|
-
m !== void 0 && (m = He.current.left + (m ?? 0)), C !== void 0 && (C = He.current.top + (C ?? 0)), !(He.current.left === m && He.current.top === C) &&
|
|
1473
|
-
}, []), yn =
|
|
1420
|
+
const S = h?.behavior ?? "auto";
|
|
1421
|
+
m !== void 0 && (m = He.current.left + (m ?? 0)), C !== void 0 && (C = He.current.top + (C ?? 0)), !(He.current.left === m && He.current.top === C) && Jt({ left: m, top: C, behavior: S });
|
|
1422
|
+
}, []), yn = V((h) => {
|
|
1474
1423
|
let m = null;
|
|
1475
|
-
if (Object.keys(
|
|
1476
|
-
const C =
|
|
1424
|
+
if (Object.keys(Ie).length > 1) {
|
|
1425
|
+
const C = ao, S = C.length;
|
|
1477
1426
|
for (let y = 0; !m && y < S; y++) {
|
|
1478
|
-
const
|
|
1479
|
-
|
|
1427
|
+
const z = Ie[C[y]];
|
|
1428
|
+
z && F.isCellWithinRange(h, z.getVisibleRangeCoords()) && (m = z);
|
|
1480
1429
|
}
|
|
1481
1430
|
}
|
|
1482
|
-
return m || (m =
|
|
1483
|
-
}, [
|
|
1484
|
-
const S = { rowIndex: 0, colIndex: 0, ...
|
|
1431
|
+
return m || (m = Ie[Qe.Center]), m;
|
|
1432
|
+
}, [Ie]), fn = P((h, m = { inline: "nearest", block: "nearest" }, C = null) => {
|
|
1433
|
+
const S = { rowIndex: 0, colIndex: 0, ...h };
|
|
1485
1434
|
let y = null;
|
|
1486
1435
|
if (C !== null) {
|
|
1487
|
-
if (y =
|
|
1436
|
+
if (y = Ie[C], y === null) return new Promise((et, Be) => {
|
|
1488
1437
|
Be("Invalid view");
|
|
1489
1438
|
});
|
|
1490
1439
|
} else y = yn(S);
|
|
1491
|
-
const
|
|
1440
|
+
const z = wt(S), xe = y.getLayout(), re = xe.getColOffset(z.colStart), fe = xe.getRowOffset(z.rowStart), U = xe.getColOffset(z.colEnd + 1), Ee = xe.getRowOffset(z.rowEnd + 1), qe = y.getBounds(), $e = y.getTotalSize(), Ze = y.getScrollTopLeft(), Te = ((et, Be, tt = !0) => {
|
|
1492
1441
|
tt = tt === !0 ? { block: "start", inline: "end" } : tt === !1 ? { block: "end", inline: "end" } : { block: "end", inline: "end", ...tt };
|
|
1493
|
-
const
|
|
1494
|
-
if (
|
|
1495
|
-
})({ x:
|
|
1496
|
-
if (!Te) return Promise.resolve({ ...
|
|
1497
|
-
const
|
|
1498
|
-
|
|
1442
|
+
const yt = no(tt.inline, et.x, et.x + et.width, Be.left, Be.left + Be.width, Be.totalWidth), je = no(tt.block, et.y, et.y + et.height, Be.top, Be.top + Be.height, Be.totalHeight);
|
|
1443
|
+
if (yt !== void 0 || je !== void 0) return { left: yt, top: je };
|
|
1444
|
+
})({ x: re + Ze.left, y: fe + Ze.top, width: U - re, height: Ee - fe }, { left: Ze.left, top: Ze.top, width: qe.width, height: qe.height, totalWidth: $e.width, totalHeight: $e.height }, m);
|
|
1445
|
+
if (!Te) return Promise.resolve({ ...Ze });
|
|
1446
|
+
const ae = { ...Te };
|
|
1447
|
+
ae.left > Je ? ae.left += 20 : ae.left < Je && (ae.left -= 0), ae.top > ht ? ae.top += 20 : ae.top < ht && (ae.top -= 0);
|
|
1499
1448
|
const ct = y.getScrollOrientation();
|
|
1500
|
-
return ct.horizontal &&
|
|
1449
|
+
return ct.horizontal && h.colIndex !== void 0 || delete ae.left, ct.vertical && h.rowIndex !== void 0 || delete ae.top, new Promise((et, Be) => {
|
|
1501
1450
|
try {
|
|
1502
|
-
|
|
1451
|
+
Jt(ae), et(ae);
|
|
1503
1452
|
} catch (tt) {
|
|
1504
1453
|
Be(tt);
|
|
1505
1454
|
}
|
|
1506
1455
|
});
|
|
1507
|
-
}, [zt, ot,
|
|
1508
|
-
const m =
|
|
1509
|
-
|
|
1510
|
-
const { deltaX: C, deltaY: S, deltaMode: y } =
|
|
1511
|
-
if (Mt.current ||
|
|
1512
|
-
let
|
|
1513
|
-
const
|
|
1514
|
-
y === 1 && (
|
|
1515
|
-
Mt.current = null, Sn(
|
|
1456
|
+
}, [zt, ot, Ie, wt]), an = P((h) => {
|
|
1457
|
+
const m = h.shiftKey;
|
|
1458
|
+
h.preventDefault();
|
|
1459
|
+
const { deltaX: C, deltaY: S, deltaMode: y } = h;
|
|
1460
|
+
if (Mt.current || ne?.(h) === !1) return;
|
|
1461
|
+
let xe = m ? S : C, re = S;
|
|
1462
|
+
const fe = m || Math.abs(xe) > Math.abs(re);
|
|
1463
|
+
y === 1 && (re *= 0), Mt.current = window.requestAnimationFrame(() => {
|
|
1464
|
+
Mt.current = null, Sn(fe ? { left: xe } : { top: re });
|
|
1516
1465
|
});
|
|
1517
|
-
}, [
|
|
1518
|
-
Gt.current = null,
|
|
1466
|
+
}, [ne]), gn = V((h = null) => {
|
|
1467
|
+
Gt.current = null, ft.current = null, qt();
|
|
1519
1468
|
}, []);
|
|
1520
1469
|
en(() => {
|
|
1521
1470
|
gn();
|
|
1522
|
-
}, [
|
|
1523
|
-
const on =
|
|
1524
|
-
Rt.current.push(
|
|
1525
|
-
} }), [c,
|
|
1526
|
-
|
|
1471
|
+
}, [me]);
|
|
1472
|
+
const on = go(n, () => ({ stage: Ue.current, focus: nn, contains: St, invalidate: gn, scrollTo: Jt, scrollBy: Sn, scrollCellCoordsIntoView: fn, getScrollPosition: jt, getDimensions: Dt, getViewport: rt, handleWheel: an, rowCount: c, columnCount: d, getLayout: () => Pe, getRelativePointFromClient: sn, getViewFromClient: Ln, getViewFromCellCoords: yn, getViewFromLocation: zn, onViewChangeOnce: (h) => {
|
|
1473
|
+
Rt.current.push(h);
|
|
1474
|
+
} }), [c, d, Ie]);
|
|
1475
|
+
It(() => (Pt && on.current?.addEventListener("wheel", an, { passive: !1 }), Tt.current = !0, oe.current = null, () => {
|
|
1527
1476
|
on.current?.removeEventListener("wheel", an);
|
|
1528
1477
|
}), [Pt]);
|
|
1529
|
-
const wn =
|
|
1530
|
-
!
|
|
1531
|
-
const y = `view:${C.getAnchor()}:overlay:${m.length}`,
|
|
1532
|
-
if (!
|
|
1533
|
-
const
|
|
1534
|
-
return Ce("div", { style: { position: "absolute", left: "0px", top: "0px", width: `${
|
|
1535
|
-
})(
|
|
1536
|
-
},
|
|
1537
|
-
const
|
|
1478
|
+
const wn = se([]), An = (h, m) => {
|
|
1479
|
+
!h || !We || (wn.current = [], m.push(((C, S) => {
|
|
1480
|
+
const y = `view:${C.getAnchor()}:overlay:${m.length}`, z = We?.({ key: y, view: C }, (re) => wn.current[S] = re);
|
|
1481
|
+
if (!z) return null;
|
|
1482
|
+
const xe = C.getBounds();
|
|
1483
|
+
return Ce("div", { style: { position: "absolute", left: "0px", top: "0px", width: `${xe.width}px`, height: `${xe.height}px`, overflow: "hidden" }, children: z }, `overlay-${C.getAnchor()}-${S}`);
|
|
1484
|
+
})(h, 0)));
|
|
1485
|
+
}, Fn = Ae(() => {
|
|
1486
|
+
const h = {}, m = Object.keys(Ie), C = m.length;
|
|
1538
1487
|
for (let S = 0; S < C; S++) {
|
|
1539
|
-
const y = m[S],
|
|
1540
|
-
|
|
1488
|
+
const y = m[S], z = [];
|
|
1489
|
+
An(Ie[y], z), h[y] = { overlays: z };
|
|
1541
1490
|
}
|
|
1542
|
-
return
|
|
1543
|
-
}, [it, We, c,
|
|
1544
|
-
if (!
|
|
1545
|
-
const
|
|
1546
|
-
if (
|
|
1547
|
-
let
|
|
1548
|
-
if (
|
|
1491
|
+
return h;
|
|
1492
|
+
}, [it, We, c, d, Me, _e]), bn = (h, m, C, S, y, z, xe) => {
|
|
1493
|
+
if (!h) return;
|
|
1494
|
+
const re = h.getVisibleColumns(), fe = h.getVisibleRows();
|
|
1495
|
+
if (re.length === 0 || fe.length === 0) return;
|
|
1496
|
+
let U = null;
|
|
1497
|
+
if (D) U = D(h);
|
|
1549
1498
|
else {
|
|
1550
|
-
|
|
1551
|
-
const
|
|
1552
|
-
for (let Le = 0; Le <
|
|
1553
|
-
const
|
|
1554
|
-
for (let
|
|
1555
|
-
const st = { rowIndex:
|
|
1556
|
-
if (
|
|
1557
|
-
const
|
|
1558
|
-
|
|
1499
|
+
U = [];
|
|
1500
|
+
const De = fe.length, nt = re.length;
|
|
1501
|
+
for (let Le = 0; Le < De; Le++) {
|
|
1502
|
+
const Oe = fe[Le];
|
|
1503
|
+
for (let mt = 0; mt < nt; mt++) {
|
|
1504
|
+
const st = { rowIndex: Oe, colIndex: re[mt] };
|
|
1505
|
+
if (Y?.(st)) continue;
|
|
1506
|
+
const bt = { coords: st, range: wt(st) };
|
|
1507
|
+
U.push(bt);
|
|
1559
1508
|
}
|
|
1560
1509
|
}
|
|
1561
1510
|
}
|
|
1562
|
-
const
|
|
1563
|
-
const st = `view:${
|
|
1564
|
-
Be[
|
|
1565
|
-
let u = Be[
|
|
1566
|
-
u || (u = Be[
|
|
1567
|
-
let
|
|
1568
|
-
if (!
|
|
1569
|
-
const
|
|
1570
|
-
|
|
1511
|
+
const Ee = h.getVisibleColumnOffsets(), qe = h.getVisibleRowOffsets(), $e = h.getScrollTopLeft(), Ze = h.getFreezeTopLeft(), Te = $e.left + Ze.left, ae = $e.top + Ze.top, ct = Math.trunc(Te / Xt), et = Math.trunc(ae / Xt), Be = {}, tt = (De, nt, Le, Oe, mt) => {
|
|
1512
|
+
const st = `view:${De.getAnchor()}:cell:${to(nt.rowIndex, nt.colIndex)}`, bt = Oe.x, Lt = Oe.y, e = Math.trunc((Te + bt) / Xt) - ct, s = Math.trunc((ae + Lt) / Xt) - et;
|
|
1513
|
+
Be[s] || (Be[s] = {});
|
|
1514
|
+
let u = Be[s][e];
|
|
1515
|
+
u || (u = Be[s][e] = []);
|
|
1516
|
+
let a = z?.get(st);
|
|
1517
|
+
if (!a) {
|
|
1518
|
+
const f = (Te + bt) % Xt, E = (ae + Lt) % Xt;
|
|
1519
|
+
a = me({ key: st, coords: nt, bounds: Oe, zoom: q, range: Le, view: De, value: mt, style: { left: X.boundPixel(f), top: X.boundPixel(E), width: X.boundPixel(Oe.width, !0), height: X.boundPixel(Oe.height, !0) } });
|
|
1571
1520
|
}
|
|
1572
|
-
|
|
1573
|
-
},
|
|
1574
|
-
for (let
|
|
1575
|
-
const nt =
|
|
1521
|
+
xe?.set(st, a), u.push(a);
|
|
1522
|
+
}, yt = U.length;
|
|
1523
|
+
for (let De = 0; U && De < yt; De++) {
|
|
1524
|
+
const nt = U[De], Le = nt?.coords ?? nt;
|
|
1576
1525
|
if (!Le) continue;
|
|
1577
|
-
const
|
|
1578
|
-
if (!
|
|
1579
|
-
const st =
|
|
1580
|
-
if (!st &&
|
|
1581
|
-
const
|
|
1526
|
+
const Oe = nt?.range ?? { rowStart: Le.rowIndex, colStart: Le.colIndex, rowEnd: Le.rowIndex, colEnd: Le.colIndex }, mt = h.getVisibleRangeCoords();
|
|
1527
|
+
if (!F.isRangesIntersect(Oe, mt) && !F.isRangeWithinRange(Oe, mt)) continue;
|
|
1528
|
+
const st = Oe && !F.isSingleCell(Oe);
|
|
1529
|
+
if (!st && Y?.(Le)) continue;
|
|
1530
|
+
const bt = Le.rowIndex, Lt = Le.colIndex, e = qe[bt], s = Ee[Lt];
|
|
1582
1531
|
let u = null;
|
|
1583
|
-
e &&
|
|
1584
|
-
const
|
|
1532
|
+
e && s && (u = { x: s.offset, y: e.offset, width: s.size, height: e.size });
|
|
1533
|
+
const a = to(Oe.rowStart, Oe.colStart);
|
|
1585
1534
|
if (st) {
|
|
1586
|
-
if (y.has(
|
|
1587
|
-
y.add(
|
|
1535
|
+
if (y.has(a)) continue;
|
|
1536
|
+
y.add(a), Oe.rowEnd - Oe.rowStart > 0 && C.push(Oe), Oe.colEnd - Oe.colStart > 0 && S.push(Oe);
|
|
1588
1537
|
}
|
|
1589
|
-
if (st && (u =
|
|
1590
|
-
console.warn("no bounds for cell",
|
|
1538
|
+
if (st && (u = io(h.getLayout(), Oe)), !u) {
|
|
1539
|
+
console.warn("no bounds for cell", a);
|
|
1591
1540
|
continue;
|
|
1592
1541
|
}
|
|
1593
|
-
const
|
|
1594
|
-
tt(
|
|
1542
|
+
const f = nt?.value;
|
|
1543
|
+
tt(h, Le, Oe, u, f);
|
|
1595
1544
|
}
|
|
1596
|
-
const
|
|
1597
|
-
for (let
|
|
1598
|
-
const nt = Ye[
|
|
1545
|
+
const je = Te % Xt, ee = ae % Xt, Ye = Object.keys(Be), pt = Ye.length;
|
|
1546
|
+
for (let De = 0; De < pt; De++) {
|
|
1547
|
+
const nt = Ye[De], Le = Be[nt];
|
|
1599
1548
|
if (!Le) continue;
|
|
1600
|
-
const
|
|
1601
|
-
for (let st = 0; st <
|
|
1602
|
-
const
|
|
1549
|
+
const Oe = Object.keys(Le), mt = Oe.length;
|
|
1550
|
+
for (let st = 0; st < mt; st++) {
|
|
1551
|
+
const bt = Oe[st], Lt = Le[bt];
|
|
1603
1552
|
if (!Lt) continue;
|
|
1604
|
-
const e = parseInt(nt),
|
|
1605
|
-
m.push(Ce("div", { className: "cell-container", style: { transform: `translate(${
|
|
1553
|
+
const e = parseInt(nt), s = parseInt(bt), u = e + et, a = s + ct, f = `view:${h.getAnchor()}:segment:${a}:${u}`;
|
|
1554
|
+
m.push(Ce("div", { className: "cell-container", style: { transform: `translate(${X.boundPixel(s * Xt - je, !0)}px, ${X.boundPixel(e * Xt - ee, !0)}px)`, willChange: "transform" }, children: Lt }, f));
|
|
1606
1555
|
}
|
|
1607
1556
|
}
|
|
1608
1557
|
}, At = Ae(() => {
|
|
1609
|
-
const
|
|
1610
|
-
for (let
|
|
1611
|
-
const
|
|
1612
|
-
bn(
|
|
1558
|
+
const h = Gt.current, m = /* @__PURE__ */ new Map(), C = {}, S = Object.keys(Ie), y = S.length;
|
|
1559
|
+
for (let z = 0; z < y; z++) {
|
|
1560
|
+
const xe = S[z], re = [], fe = [], U = [];
|
|
1561
|
+
bn(Ie[xe], U, re, fe, /* @__PURE__ */ new Set(), h, m), C[xe] = { cells: U, rangesH: re, rangesV: fe };
|
|
1613
1562
|
}
|
|
1614
1563
|
return Gt.current = m, C;
|
|
1615
|
-
}, [it, c,
|
|
1616
|
-
if (!
|
|
1617
|
-
const
|
|
1564
|
+
}, [it, c, d, Me, _e, A, he, ze, Y, D, be, Z, wt]), Cn = (h, m, C, S, y) => {
|
|
1565
|
+
if (!h) return;
|
|
1566
|
+
const z = h.getLayout(), xe = window.devicePixelRatio || 1, re = String(1 / xe);
|
|
1618
1567
|
if (m) {
|
|
1619
|
-
const
|
|
1620
|
-
if ((
|
|
1621
|
-
const
|
|
1568
|
+
const fe = `view:${h.getAnchor()}:hl:`, U = h.getVisibleRows();
|
|
1569
|
+
if ((U ? U.length : 0) === 0) return;
|
|
1570
|
+
const Ee = y.sort(F.rowFirstRangeComparator), qe = h.getVisibleRangeCoords(), $e = 0, Ze = Math.min(h.getBounds().width, z.getColOffset(qe.colEnd + 1));
|
|
1622
1571
|
let Te = [];
|
|
1623
|
-
for (let
|
|
1624
|
-
const ct =
|
|
1625
|
-
if (ct <
|
|
1572
|
+
for (let ae = 0; ae < U.length && U[ae] <= qe.rowEnd; ae++) {
|
|
1573
|
+
const ct = U[ae];
|
|
1574
|
+
if (ct < qe.rowStart) continue;
|
|
1626
1575
|
let et = !1;
|
|
1627
|
-
for (;
|
|
1628
|
-
const
|
|
1629
|
-
|
|
1576
|
+
for (; Ee.length > 0 && Ee[0].rowStart <= ct; ) {
|
|
1577
|
+
const je = Ee.shift();
|
|
1578
|
+
je.rowEnd > ct && (Te.push(je), et = !0);
|
|
1630
1579
|
}
|
|
1631
|
-
et && (Te = Te.sort(
|
|
1632
|
-
const Be =
|
|
1580
|
+
et && (Te = Te.sort(F.columnFirstRangeComparator));
|
|
1581
|
+
const Be = z.getRowOffset(ct + 1);
|
|
1633
1582
|
let tt = $e;
|
|
1634
|
-
const
|
|
1635
|
-
for (let
|
|
1636
|
-
let
|
|
1637
|
-
const
|
|
1638
|
-
|
|
1583
|
+
const yt = Te.length;
|
|
1584
|
+
for (let je = 0; je < yt + 1; je++) {
|
|
1585
|
+
let ee = tt, Ye = Ze;
|
|
1586
|
+
const pt = Te[je];
|
|
1587
|
+
je < yt && (Ye = Math.min(Ze, z.getColOffset(pt.colStart)), tt = Math.min(Ze, z.getColOffset(pt.colEnd + 1))), S.push(wo("path", { d: `M ${X.boundPixel(ee)} ${X.boundPixel(Be, !1, C)} L ${X.boundPixel(Ye)} ${X.boundPixel(Be, !1, C)}`, stroke: le, strokeWidth: re, vectorEffect: "non-scaling-stroke", ...J, key: fe + ct + ":" + je }));
|
|
1639
1588
|
}
|
|
1640
|
-
for (let
|
|
1589
|
+
for (let je = yt - 1; je >= 0; je--) Te[je].rowEnd <= U[ae + 1] && Te.splice(je, 1);
|
|
1641
1590
|
}
|
|
1642
1591
|
} else {
|
|
1643
|
-
const
|
|
1644
|
-
if (
|
|
1645
|
-
const
|
|
1646
|
-
let
|
|
1647
|
-
for (let ct = 0; ct <
|
|
1648
|
-
const et =
|
|
1592
|
+
const fe = `view:${h.getAnchor()}:vl:`, U = h.getVisibleColumns(), Ee = U ? U.length : 0;
|
|
1593
|
+
if (Ee === 0) return;
|
|
1594
|
+
const qe = y.sort(F.columnFirstRangeComparator), $e = h.getVisibleRangeCoords(), Ze = 0, Te = Math.min(h.getBounds().height, z.getRowOffset($e.rowEnd + 1));
|
|
1595
|
+
let ae = [];
|
|
1596
|
+
for (let ct = 0; ct < Ee && U[ct] <= $e.colEnd; ct++) {
|
|
1597
|
+
const et = U[ct];
|
|
1649
1598
|
if (et < $e.colStart) continue;
|
|
1650
1599
|
let Be = !1;
|
|
1651
|
-
for (;
|
|
1652
|
-
const
|
|
1653
|
-
|
|
1600
|
+
for (; qe.length > 0 && qe[0].colStart <= et; ) {
|
|
1601
|
+
const ee = qe.shift();
|
|
1602
|
+
ee.colEnd > et && (ae.push(ee), Be = !0);
|
|
1654
1603
|
}
|
|
1655
|
-
Be && (
|
|
1656
|
-
const tt =
|
|
1657
|
-
let
|
|
1658
|
-
const
|
|
1659
|
-
for (let
|
|
1660
|
-
let Ye =
|
|
1661
|
-
const
|
|
1662
|
-
|
|
1604
|
+
Be && (ae = ae.sort(F.rowFirstRangeComparator));
|
|
1605
|
+
const tt = z.getColOffset(et + 1);
|
|
1606
|
+
let yt = Ze;
|
|
1607
|
+
const je = ae.length;
|
|
1608
|
+
for (let ee = 0; ee < je + 1; ee++) {
|
|
1609
|
+
let Ye = yt, pt = Te;
|
|
1610
|
+
const De = ae[ee];
|
|
1611
|
+
ee < je && (pt = Math.min(Te, z.getRowOffset(De.rowStart)), yt = Math.min(Te, z.getRowOffset(De.rowEnd + 1))), S.push(Ce("path", { d: `M ${X.boundPixel(tt, !1, C)} ${X.boundPixel(Ye)} L ${X.boundPixel(tt, !1, C)} ${X.boundPixel(pt)}`, stroke: le, strokeWidth: re, vectorEffect: "non-scaling-stroke", ...te }, fe + et + ":" + ee));
|
|
1663
1612
|
}
|
|
1664
|
-
for (let
|
|
1613
|
+
for (let ee = je - 1; ee >= 0; ee--) ae[ee].colEnd <= U[ct + 1] && ae.splice(ee, 1);
|
|
1665
1614
|
}
|
|
1666
1615
|
}
|
|
1667
|
-
}, xn = (
|
|
1616
|
+
}, xn = (h) => {
|
|
1668
1617
|
if (!At) return;
|
|
1669
|
-
const m = {}, C =
|
|
1618
|
+
const m = {}, C = Zt.length;
|
|
1670
1619
|
for (let S = 0; S < C; S++) {
|
|
1671
|
-
const y =
|
|
1672
|
-
Cn(
|
|
1673
|
-
const
|
|
1674
|
-
m[y] = Ce("svg", { width: `${
|
|
1620
|
+
const y = Zt[S], z = Ie[y], xe = [];
|
|
1621
|
+
Cn(z, h, 0, xe, h ? At[y].rangesH : At[y].rangesV);
|
|
1622
|
+
const re = z.getRangeCoordsBounds(), fe = Math.ceil(re.width), U = Math.ceil(re.height);
|
|
1623
|
+
m[y] = Ce("svg", { width: `${fe}`, height: `${U}`, viewBox: `0 0 ${fe} ${U}`, preserveAspectRatio: "none", shapeRendering: "crispEdges", style: { position: "absolute" }, children: xe });
|
|
1675
1624
|
}
|
|
1676
1625
|
return m;
|
|
1677
|
-
}, In = Ae(() =>
|
|
1678
|
-
const
|
|
1679
|
-
if (!S || !
|
|
1680
|
-
const y =
|
|
1681
|
-
return
|
|
1682
|
-
}, C =
|
|
1683
|
-
for (let S = 0; S < C; S++)
|
|
1684
|
-
return Ce(
|
|
1685
|
-
}, [
|
|
1626
|
+
}, In = Ae(() => A === !0 || A?.horizontal === !0 ? xn(!0) : null, [it, A, Me, _, T, le, J, c, d, Ge, zt, Ie, At]), En = Ae(() => A === !0 || A?.vertical === !0 ? xn(!1) : null, [it, A, _e, _, T, le, te, c, d, Ke, ot, Ie, At]), Vn = Ae(() => kt.left === 0 ? null : Ce(co, { linePoints: [0, 0, 0, Ke + 1], bounds: { x: kt.left, y: 0, width: 1, height: Ke + 1 }, ...ve }), [it, kt.left, Ke, ve]), Wn = Ae(() => kt.top === 0 ? null : Ce(co, { linePoints: [0, 0, Ge + 1, 0], bounds: { x: 0, y: kt.top, width: Ge + 1, height: 1 }, ...W }), [it, kt.top, Ge, W]), pn = Ae(() => {
|
|
1627
|
+
const h = [], m = (S) => {
|
|
1628
|
+
if (!S || !Ie[S]) return;
|
|
1629
|
+
const y = Ie[S].getBounds();
|
|
1630
|
+
return Qt("div", { style: { position: "absolute", pointerEvents: "none", left: y.x, top: y.y, width: y.width, height: y.height, clip: `rect(0, ${y.width + 1}px, ${y.height + 1}px, 0)` }, className: `view view-${S}`, children: [In?.[S], En?.[S], At?.[S].cells] }, `view:${S}`);
|
|
1631
|
+
}, C = Zt.length;
|
|
1632
|
+
for (let S = 0; S < C; S++) h.push(m(Zt[S]));
|
|
1633
|
+
return Ce(_n, { children: h });
|
|
1634
|
+
}, [Ie, In, En, At]), Un = Ae(() => {
|
|
1686
1635
|
if (!n) return;
|
|
1687
|
-
const
|
|
1688
|
-
if (!
|
|
1689
|
-
const
|
|
1690
|
-
for (let
|
|
1691
|
-
const Te =
|
|
1692
|
-
let
|
|
1693
|
-
|
|
1636
|
+
const h = (re, fe, U, Ee) => {
|
|
1637
|
+
if (!Ee || Ee.length === 0) return;
|
|
1638
|
+
const qe = [], $e = Ee.length;
|
|
1639
|
+
for (let Ze = 0; Ze < $e; Ze++) {
|
|
1640
|
+
const Te = Ee[Ze];
|
|
1641
|
+
let ae = re?.get(Te);
|
|
1642
|
+
ae !== qn && (ae = Te(U) ?? qn), fe.set(Te, ae), ae && ae !== qn && qe.push(ae);
|
|
1694
1643
|
}
|
|
1695
|
-
return
|
|
1696
|
-
}, m = (
|
|
1697
|
-
if (!
|
|
1698
|
-
const
|
|
1699
|
-
return
|
|
1700
|
-
}, C =
|
|
1701
|
-
for (let
|
|
1702
|
-
const
|
|
1703
|
-
y.push(m(
|
|
1644
|
+
return qe;
|
|
1645
|
+
}, m = (re, fe, U) => {
|
|
1646
|
+
if (!U) return;
|
|
1647
|
+
const Ee = U.getBounds(), qe = U.getInsets(), $e = U.getAnchor();
|
|
1648
|
+
return Qt("div", { className: rn("view", `view-${$e}`, so.view), style: { position: "absolute", pointerEvents: "none", left: Ee.x - qe.left, top: Ee.y - qe.top, width: Ee.width - (qe.left + qe.right), height: Ee.height - (qe.top + qe.bottom), clipPath: p ? "inset(-2px)" : "inset(0px)" }, children: [h(re, fe, U, ye), Fn?.[$e].overlays] }, `view:${$e}`);
|
|
1649
|
+
}, C = ft.current, S = {}, y = [], z = Object.keys(Ie), xe = z.length;
|
|
1650
|
+
for (let re = 0; re < xe; re++) {
|
|
1651
|
+
const fe = z[re], U = C?.[fe], Ee = S[fe] = /* @__PURE__ */ new Map();
|
|
1652
|
+
y.push(m(U, Ee, Ie[fe]));
|
|
1704
1653
|
}
|
|
1705
|
-
return
|
|
1706
|
-
}, [it,
|
|
1707
|
-
const { style:
|
|
1708
|
-
return Ce("div", { style: { width: Ge, height: Ke, ...
|
|
1709
|
-
}, [Ge, Ke, pn, Ne, Xe]), Rn =
|
|
1710
|
-
return
|
|
1711
|
-
!Rn.current && At && (Rn.current = !0,
|
|
1712
|
-
}, [At]),
|
|
1654
|
+
return ft.current = S, y;
|
|
1655
|
+
}, [it, Ie, p, ye]), Hn = Ae(() => {
|
|
1656
|
+
const { style: h, ...m } = Ne ?? {};
|
|
1657
|
+
return Ce("div", { style: { width: Ge, height: Ke, ...h }, className: "sheetxl-stage", tabIndex: 0, ref: Ue, ...m, ...Wt, children: Xe ? Xe(pn) : pn });
|
|
1658
|
+
}, [Ge, Ke, pn, Ne, Xe]), Rn = se(!1);
|
|
1659
|
+
return It(() => {
|
|
1660
|
+
!Rn.current && At && (Rn.current = !0, we?.(on.current));
|
|
1661
|
+
}, [At]), Qt("div", { className: rn("sheetxl-grid", so["sheetxl-grid"]), style: { overflow: "visible", cursor: Q, maxWidth: Ge, maxHeight: Ke, width: Ge, height: Ke, ...he }, ref: on, children: [Hn, Qt("div", { className: rn("sheetxl-overlays"), ref: lt, ...$, children: [Un, Vn, Wn] })] });
|
|
1713
1662
|
}));
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1663
|
+
Co.displayName = "BaseGrid";
|
|
1664
|
+
var tr = function() {
|
|
1665
|
+
}, Io = typeof window < "u", nr = Io ? en : It, uo = { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, bottom: 0, right: 0 };
|
|
1666
|
+
const or = Io && window.ResizeObserver !== void 0 ? function() {
|
|
1667
|
+
var t = gt(null), n = t[0], o = t[1], r = gt(uo), c = r[0], d = r[1], i = Ae(function() {
|
|
1668
|
+
return new window.ResizeObserver(function(l) {
|
|
1669
|
+
if (l[0]) {
|
|
1670
|
+
var w = l[0].contentRect, L = w.x, O = w.y, R = w.width, M = w.height, A = w.top, le = w.left, J = w.bottom, te = w.right;
|
|
1671
|
+
d({ x: L, y: O, width: R, height: M, top: A, left: le, bottom: J, right: te });
|
|
1672
|
+
}
|
|
1673
|
+
});
|
|
1674
|
+
}, []);
|
|
1675
|
+
return nr(function() {
|
|
1676
|
+
if (n) return i.observe(n), function() {
|
|
1677
|
+
i.disconnect();
|
|
1678
|
+
};
|
|
1679
|
+
}, [n]), [o, c];
|
|
1680
|
+
} : function() {
|
|
1681
|
+
return [tr, uo];
|
|
1682
|
+
}, Eo = Kt(tn((t, n) => {
|
|
1683
|
+
const { width: o, height: r, style: c = {}, className: d, ...i } = t, [l, { width: w, height: L }] = or();
|
|
1684
|
+
return Ce("div", { className: d, style: { ...c }, children: Ce("div", { style: { position: "relative", top: "0px", left: "0px", width: "100%", height: "100%", maxWidth: "100%", maxHeight: "100%", boxSizing: "content-box" }, ref: l, children: Ce(Co, { ref: n, width: o ?? w, height: r ?? L, ...i }) }) });
|
|
1718
1685
|
}));
|
|
1719
|
-
|
|
1720
|
-
const
|
|
1721
|
-
const { showVerticalScrollbar: o, showHorizontalScrollbar: r, createHorizontalScrollbar: c, createVerticalScrollbar:
|
|
1722
|
-
|
|
1723
|
-
const
|
|
1724
|
-
|
|
1686
|
+
Eo.displayName = "Grid";
|
|
1687
|
+
const rr = Kt(tn((t, n) => {
|
|
1688
|
+
const { showVerticalScrollbar: o, showHorizontalScrollbar: r, createHorizontalScrollbar: c, createVerticalScrollbar: d, createScrollCorner: i, viewport: l, onScrollViewport: w, style: L = {}, className: O, onScroll: R, ...M } = t, [A, le] = gt(null), J = se(null), te = se(null);
|
|
1689
|
+
Dn(!l), Lo(n, () => te.current && J.current ? Object.assign(te.current, J.current) : null);
|
|
1690
|
+
const ze = V((Q) => {
|
|
1691
|
+
te.current?.scrollTo(Q), w?.(Q);
|
|
1725
1692
|
}, []);
|
|
1726
|
-
return Ce(
|
|
1693
|
+
return Ce(Oo, { className: O, style: L, ref: J, showVerticalScrollbar: o, showHorizontalScrollbar: r, createHorizontalScrollbar: c, createVerticalScrollbar: d, createScrollCorner: i, viewport: A, onScrollViewport: ze, children: Ce(Eo, { style: { width: "100%", height: "100%" }, ...M, onViewportChange: (Q) => le(Q), ref: te }) });
|
|
1727
1694
|
}));
|
|
1728
|
-
|
|
1729
|
-
const
|
|
1730
|
-
const { index: n, value: o, zoom: r, zoomScale: c = 100, headerText:
|
|
1731
|
-
let
|
|
1732
|
-
if (
|
|
1733
|
-
let ye =
|
|
1734
|
-
typeof
|
|
1695
|
+
rr.displayName = "ScrollableGrid";
|
|
1696
|
+
const ho = () => !1, lr = Kt((t) => {
|
|
1697
|
+
const { index: n, value: o, zoom: r, zoomScale: c = 100, headerText: d = (ye) => `${ye}`, headerStyle: i, headerStyleSelect: l = i, headerStyleSelectAll: w = l, headerStyleHover: L = w, verticalPadding: O = 0, horizontalPadding: R = 0, isSelected: M = ho, isSelectedAll: A = ho, coords: le, bounds: J, range: te, orientation: ze, view: Q, style: T, ..._ } = t, ve = c / 100, W = se(null), [me, Ve] = gt(!1), ke = M?.(n) || !1, We = A?.(n) ? w : ke ? l : i;
|
|
1698
|
+
let ue = We;
|
|
1699
|
+
if (me) {
|
|
1700
|
+
let ye = L;
|
|
1701
|
+
typeof L == "function" && (ye = L(We)), ue = Nt.mergeContentful(We, ye);
|
|
1735
1702
|
}
|
|
1736
|
-
return Ce("div", { ref:
|
|
1737
|
-
|
|
1703
|
+
return Ce("div", { ref: W, style: { background: ue.fill, color: ue.text?.fill, fontFamily: ue.text?.fontFamily ?? i.text?.fontFamily, fontSize: 96 * (ue.text?.fontSize ?? 11) / 72 * ve, fontStyle: ue.text?.fontStyle, fontWeight: ue.text?.fontWeight, lineHeight: 1.2, display: "flex", justifyContent: "center", alignItems: "end", pointerEvents: "auto", paddingBottom: `${ve}px`, ...T, left: T.left - (ze === Ht.Column ? 1 : 0), top: T.top - (ze === Ht.Row ? 1 : 0), width: T.width + 1, height: T.height + 1, overflow: "hidden" }, ..._, onMouseMove: (ye) => {
|
|
1704
|
+
X.detectIt().primaryInput !== "touch" && ye.buttons === 0 && Ve(!0);
|
|
1738
1705
|
}, onMouseOut: (ye) => {
|
|
1739
1706
|
Ve(!1);
|
|
1740
|
-
}, children:
|
|
1707
|
+
}, children: d(n) });
|
|
1741
1708
|
});
|
|
1742
|
-
|
|
1743
|
-
const
|
|
1744
|
-
const { orientation: o, view: r, index: c, className:
|
|
1745
|
-
let
|
|
1746
|
-
|
|
1747
|
-
const Ve =
|
|
1748
|
-
let
|
|
1749
|
-
|
|
1750
|
-
let ye =
|
|
1751
|
-
return !(
|
|
1752
|
-
})),
|
|
1753
|
-
const { orientation: o, view: r, index: c, disabled:
|
|
1754
|
-
let
|
|
1755
|
-
|
|
1756
|
-
const
|
|
1757
|
-
if (
|
|
1758
|
-
const be =
|
|
1759
|
-
|
|
1709
|
+
lr.displayName = "HeaderRenderer";
|
|
1710
|
+
const Ro = "ew-resize", Mo = "ns-resize", ir = Kt(tn((t, n) => {
|
|
1711
|
+
const { orientation: o, view: r, index: c, className: d, style: i, disabled: l = !1, disabledResize: w = !1, isNextHidden: L, isHidden: O, isSelected: R, isSelectedAll: M, showTouchDivider: A, headerStyle: le, headerStyleSelect: J, headerStyleSelectAll: te, headerStyleHover: ze, bounds: Q, onPointerDown: T, onAutoFit: _, ...ve } = t, W = o === Ht.Column;
|
|
1712
|
+
let me = le;
|
|
1713
|
+
R && J && (me = J), M && te && (me = te);
|
|
1714
|
+
const Ve = X.detectIt().primaryInput === "touch";
|
|
1715
|
+
let ke = W ? 14 : 8, We = ke / 2, ue = 0;
|
|
1716
|
+
L && (ue = -2), O && (ue = 2), O && (ke = ke / 2 + ue, We = 2 * ue);
|
|
1717
|
+
let ye = me.dividerStrokeFill ?? me.strokeFill;
|
|
1718
|
+
return !(R || M) && ue === 0 && (ye = `linear-gradient(${W ? 180 : 90}deg, ${me.fill}, ${ye} 55%, ${ye} 100%)`), Qt("div", { className: rn("header-divider", { disabled: l }, d, `index-${c}`), ref: n, onPointerDown: Ve ? void 0 : T, onDoubleClick: Ve ? void 0 : () => _?.(), style: { top: (W ? 0 : -ke / 2 + (ue - 1)) + "px", left: (W ? -ke / 2 + (ue - 1) : 0) + "px", width: W ? ke : "calc(100% + 1px)", height: W ? "calc(100% + 1px)" : ke, position: "absolute", overflow: "visible", pointerEvents: "all", cursor: l || w || Ve ? void 0 : W ? Ro : Mo, ...i }, ...ve, children: [Ce("div", { style: { position: "relative", top: `${W ? 0 : We}px`, left: `${W ? We : 0}px`, width: W ? 1 : "100%", height: W ? "100%" : 1, background: ye }, onDoubleClick: () => _?.() }), A && Ve ? Ce("div", { style: { position: "absolute", cursor: "grab", zIndex: 1, borderRadius: "4px", right: W ? "-6px" : "2px", bottom: W ? "2px" : "-9px", height: "24px", width: W ? "24px" : "18px", maxHeight: W ? "calc(100% - 4px)" : void 0, maxWidth: W ? void 0 : "calc(100% - 4px)", background: me.fill, border: `${te.edgeStrokeFill} solid 1px`, boxShadow: `0.5px 0.5px 0px 0px ${le.text.fill}`, display: "flex", alignItems: "center", justifyContent: "center" }, onPointerDown: T, children: Ce("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(J.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: W ? void 0 : "rotate(90deg)" } }) }) : null] });
|
|
1719
|
+
})), cr = (t, n) => Ce(ir, { ...t, ref: n }), Sr = Kt(tn((t, n) => {
|
|
1720
|
+
const { orientation: o, view: r, index: c, disabled: d = !1, disabledResize: i = !1, resizeThreshold: l = 1, dividerRenderer: w = cr, onDividerMouseDown: L, onDividerResizeStart: O, onDividerResize: R, onDividerResizeEnd: M, onDividerMouseUp: A, onDividerAutoFit: le, onPointerDown: J, ...te } = t, ze = P(J, [J]), Q = P(le, [le]), T = o === Ht.Column;
|
|
1721
|
+
let _ = T ? r.getVisibleColumns() : r.getVisibleRows(), ve = null;
|
|
1722
|
+
_.length > 0 && (T ? ve = r.getRangeCoordsBounds({ rowStart: 0, rowEnd: 0, colStart: _[0], colEnd: _[_.length - 1] }) : r.getRangeCoordsBounds({ rowStart: _[0], rowEnd: _[_.length - 1], colStart: 0, colEnd: 0 }), ve = r.toClipBounds(ve, Vt));
|
|
1723
|
+
const W = se(null), [me, Ve] = gt(null), ke = (Z, be) => T ? Z.clientX - be.clientX : Z.clientY - be.clientY, We = r.getLayout(), ue = T ? We.getColOffset(c + 1) : We.getRowOffset(c + 1), ye = un({ processTouch: !0, onPointerDown: (Z) => {
|
|
1724
|
+
if (ze?.(Z), !d && !i) {
|
|
1725
|
+
const be = T ? We.getColOffset(c) : We.getRowOffset(c), Y = ue - be;
|
|
1726
|
+
W.current = { isResizing: !1, startSize: Y, index: c, view: r, orientation: o, onDividerMouseDown: L, onDividerResizeStart: O, onDividerResize: R, onDividerResizeEnd: M, onDividerMouseUp: A }, Ve(W.current), L?.(c, Y);
|
|
1760
1727
|
}
|
|
1761
|
-
|
|
1762
|
-
}, onPointerUp: (
|
|
1763
|
-
if (!
|
|
1764
|
-
|
|
1765
|
-
const
|
|
1766
|
-
|
|
1767
|
-
}, onPointerMoveOrWait: (
|
|
1768
|
-
if (!
|
|
1769
|
-
const
|
|
1770
|
-
|
|
1771
|
-
} }),
|
|
1772
|
-
|
|
1728
|
+
Z.stopPropagation(), Z.preventDefault();
|
|
1729
|
+
}, onPointerUp: (Z, be, Y) => {
|
|
1730
|
+
if (!W.current) return;
|
|
1731
|
+
W.current.isResizing && W.current.onDividerResizeEnd?.(W.current.index, Math.max(0, W.current.startSize + ke(Z, Y)), W.current.startSize);
|
|
1732
|
+
const D = W.current;
|
|
1733
|
+
W.current = null, Ve(W.current), D.onDividerMouseUp?.(D.index);
|
|
1734
|
+
}, onPointerMoveOrWait: (Z, be, Y) => {
|
|
1735
|
+
if (!W.current) return;
|
|
1736
|
+
const D = ke(Z, Y);
|
|
1737
|
+
W.current.isResizing ? W.current.onDividerResize?.(W.current.index, Math.max(0, W.current.startSize + D), W.current.startSize) : Math.abs(D) > Math.max(1, l) && (W.current = { ...W.current, isResizing: !0 }, Ve(W.current), W.current.onDividerResizeStart?.(W.current.index, Math.max(0, W.current.startSize + D))), Z.stopPropagation(), Z.preventDefault();
|
|
1738
|
+
} }), $ = P(() => {
|
|
1739
|
+
Q?.(c);
|
|
1773
1740
|
}, [c]);
|
|
1774
|
-
if (!
|
|
1775
|
-
const p =
|
|
1741
|
+
if (!ve) return;
|
|
1742
|
+
const p = w({ bounds: ve, orientation: o, view: r, index: c, disabled: d, disabledResize: i, onAutoFit: $, onPointerDown: ye, ...te }, n);
|
|
1776
1743
|
if (!p) return;
|
|
1777
|
-
const { getPortalContainer: Ne } =
|
|
1744
|
+
const { getPortalContainer: Ne } = fo();
|
|
1778
1745
|
let Xe = null;
|
|
1779
|
-
return
|
|
1746
|
+
return me && me.isResizing && me.index === c && (Xe = xo(Ce("div", { style: { position: "absolute", cursor: T ? Ro : Mo, left: 0, top: 0, width: "100%", height: "100%" } }), Ne(), "divider:" + c)), Qt(_n, { children: [Xe, Ce("div", { className: rn("header-divider-anchor"), style: { position: "absolute", pointerEvents: "auto", top: `${T ? ve.y : ue}px`, left: `${T ? ue : ve.x}px`, width: (T ? 0 : ve.width - 1) + "px", height: (T ? ve.height - 1 : 0) + "px", display: "flex" }, tabIndex: -1, children: p })] });
|
|
1780
1747
|
}));
|
|
1781
|
-
class
|
|
1748
|
+
class sr {
|
|
1782
1749
|
naturalDimensions(n, o = {}) {
|
|
1783
1750
|
const r = document.createElement("div");
|
|
1784
1751
|
let c = o?.lineHeight ?? "1";
|
|
1785
1752
|
!o?.lineHeight && o.paintableText?.fontSize && (c = Math.ceil(1.2 * o.paintableText.fontSize) + "px");
|
|
1786
|
-
const
|
|
1787
|
-
|
|
1753
|
+
const d = document.createElement("div");
|
|
1754
|
+
d.style.visibility = "hidden", d.style.position = "absolute", d.style.textRendering = "geometricprecision", d.style.display = "inline-grid", d.style.overflowWrap = "break-word", d.style.maxWidth = o.maxWidth ? o.maxWidth + "px" : "100%", d.style.lineHeight = c, d.style.letterSpacing = (o.paintableText?.letterSpacing ?? 0) + "px", d.style.fontSize = o.paintableText?.fontSize ? o.paintableText.fontSize + "px" : "unset", d.style.fontFamily = o.paintableText?.fontSize ? o.paintableText.fontFamily : "unset", d.style.fontWeight = o.paintableText?.fontWeight ? "" + o.paintableText.fontWeight : "400", d.style.fontStyle = o.paintableText?.fontStyle ? o.paintableText.fontStyle : "normal", d.style.whiteSpace = o.paintableText?.wrap === "wrap" ? "break-spaces" : "pre", r.appendChild(d);
|
|
1788
1755
|
const i = n.split(`
|
|
1789
1756
|
`);
|
|
1790
|
-
for (let
|
|
1791
|
-
let
|
|
1792
|
-
|
|
1757
|
+
for (let w = 0; w < i.length; w++) {
|
|
1758
|
+
let L = document.createElement("span");
|
|
1759
|
+
d.appendChild(L), L.textContent = i[w];
|
|
1793
1760
|
}
|
|
1794
|
-
i.length !== 0 && i[i.length - 1].length !== 0 ||
|
|
1795
|
-
let l =
|
|
1796
|
-
return
|
|
1761
|
+
i.length !== 0 && i[i.length - 1].length !== 0 || d.appendChild(document.createElement("br")), document.body.appendChild(d);
|
|
1762
|
+
let l = d.getBoundingClientRect();
|
|
1763
|
+
return d.remove(), { width: l.width, height: l.height, maxLineHeight: 1.2 * (o.paintableText?.fontSize || 1056 / 72) };
|
|
1797
1764
|
}
|
|
1798
1765
|
}
|
|
1799
|
-
const
|
|
1800
|
-
const { editState: o =
|
|
1801
|
-
|
|
1802
|
-
|
|
1766
|
+
const ar = (t = void 0) => Object.freeze({ clean: t, dirty: void 0, editMode: !1 }), dr = ar(), yr = Kt(tn((t, n) => {
|
|
1767
|
+
const { editState: o = dr, defaultTextStyle: r, onStartEdit: c, onChangeEdit: d, onSubmitEdit: i, onCancelEdit: l, onDoneEdit: w, containerBounds: L, setNaturalSize: O, onNavigate: R, textProperties: M, style: A, autoFocus: le, ...J } = t, te = se(null), { width: ze = 0 } = L ?? {}, [Q, T] = gt(() => o);
|
|
1768
|
+
It(() => {
|
|
1769
|
+
T(o);
|
|
1803
1770
|
}, [o]);
|
|
1804
|
-
const
|
|
1805
|
-
let
|
|
1806
|
-
const p = 96 *
|
|
1807
|
-
|
|
1808
|
-
const Xe = Ae(() => new
|
|
1771
|
+
const _ = M?.align || "left", ve = M?.vAlign || "middle", W = M?.fill || "#040404", me = M?.wrap || "wrap", Ve = M?.fontFamily || "Calibri", ke = M?.fontSize || 11, We = M?.fontWeight || 400, ue = M?.fontStyle || "normal", ye = Q.dirty ?? Q.clean ?? "";
|
|
1772
|
+
let $ = 2;
|
|
1773
|
+
const p = 96 * ke / 72, Ne = 1.2 * p;
|
|
1774
|
+
ve === "right" && ($ += 1);
|
|
1775
|
+
const Xe = Ae(() => new sr().naturalDimensions(ye, { maxWidth: me === "wrap" ? ze - $ : void 0, lineHeight: `${Ne}px`, paintableText: { fontStyle: ue, wrap: me, letterSpacing: -0.25 } }), [ye, me, $, p, Ve, We, ue, O, ze]), Z = V(() => Xe.maxLineHeight ? Xe.maxLineHeight + "px" : "1.2", [Xe]), [be, Y] = gt(Z);
|
|
1809
1776
|
en(() => {
|
|
1810
|
-
|
|
1811
|
-
}, [
|
|
1812
|
-
|
|
1813
|
-
}, [Xe,
|
|
1814
|
-
const
|
|
1815
|
-
if (
|
|
1816
|
-
const
|
|
1817
|
-
|
|
1818
|
-
}, [
|
|
1819
|
-
if (
|
|
1820
|
-
const
|
|
1821
|
-
|
|
1822
|
-
}, [
|
|
1777
|
+
Y(Z());
|
|
1778
|
+
}, [L, Xe]), en(() => {
|
|
1779
|
+
O?.({ width: me === "wrap" ? void 0 : Xe.width + $, height: Xe.height });
|
|
1780
|
+
}, [Xe, O]);
|
|
1781
|
+
const D = P(d, [d]), q = P((b) => {
|
|
1782
|
+
if (Q.dirty === b) return;
|
|
1783
|
+
const Re = { ...Q };
|
|
1784
|
+
Re.dirty = b, te.current, T(Re), D?.(Re);
|
|
1785
|
+
}, [Q]), Pt = P((b) => {
|
|
1786
|
+
if (Q.editMode === b) return;
|
|
1787
|
+
const Re = { ...Q };
|
|
1788
|
+
Re.editMode = b, T(Re), D?.(Re);
|
|
1789
|
+
}, [Q]), Et = P(() => {
|
|
1823
1790
|
try {
|
|
1824
|
-
return i?.(
|
|
1791
|
+
return i?.(Q), w?.(), !0;
|
|
1825
1792
|
} catch {
|
|
1826
1793
|
return !1;
|
|
1827
1794
|
}
|
|
1828
|
-
}, [i,
|
|
1829
|
-
|
|
1830
|
-
}, [l, o]),
|
|
1831
|
-
if (!
|
|
1832
|
-
if (b.isDefaultPrevented(), !(b.isTrusted || b.nativeEvent.ctrlKey || b.nativeEvent.metaKey || b.nativeEvent.altKey || b.nativeEvent.isComposing) &&
|
|
1833
|
-
const
|
|
1834
|
-
return
|
|
1795
|
+
}, [i, Q]), wt = P(() => {
|
|
1796
|
+
T(o), l?.(), w?.();
|
|
1797
|
+
}, [l, o]), ut = P((b) => {
|
|
1798
|
+
if (!te.current) return;
|
|
1799
|
+
if (b.isDefaultPrevented(), !(b.isTrusted || b.nativeEvent.ctrlKey || b.nativeEvent.metaKey || b.nativeEvent.altKey || b.nativeEvent.isComposing) && mo.indexOf(b.nativeEvent.key) !== -1) {
|
|
1800
|
+
const ne = { ...Q };
|
|
1801
|
+
return ne.dirty = b.nativeEvent.key === "Backspace" ? "" : (ne.dirty ?? "") + b.key, T(ne), D?.(ne), void b.preventDefault();
|
|
1835
1802
|
}
|
|
1836
|
-
const
|
|
1837
|
-
if (b.which === Ot.Escape) return b.preventDefault(), void
|
|
1803
|
+
const Re = b.nativeEvent.shiftKey;
|
|
1804
|
+
if (b.which === Ot.Escape) return b.preventDefault(), void wt();
|
|
1838
1805
|
if (b.which === Ot.F2) return Pt(!0), void b.preventDefault();
|
|
1839
|
-
if (b.which === Ot.Enter && (b.preventDefault(), Et() &&
|
|
1840
|
-
if (!
|
|
1841
|
-
let
|
|
1806
|
+
if (b.which === Ot.Enter && (b.preventDefault(), Et() && R?.(Re ? g.Up : g.Down)), b.which === Ot.Tab) return b.preventDefault(), void (Et() && R?.(Re ? g.Left : g.Right));
|
|
1807
|
+
if (!Q.editMode) {
|
|
1808
|
+
let ne = null;
|
|
1842
1809
|
switch (b.which) {
|
|
1843
1810
|
case Ot.Left:
|
|
1844
|
-
|
|
1811
|
+
ne = g.Left;
|
|
1845
1812
|
break;
|
|
1846
1813
|
case Ot.Right:
|
|
1847
|
-
|
|
1814
|
+
ne = g.Right;
|
|
1848
1815
|
break;
|
|
1849
1816
|
case Ot.Up:
|
|
1850
|
-
|
|
1817
|
+
ne = g.Up;
|
|
1851
1818
|
break;
|
|
1852
1819
|
case Ot.Down:
|
|
1853
|
-
|
|
1820
|
+
ne = g.Down;
|
|
1854
1821
|
}
|
|
1855
|
-
if (
|
|
1822
|
+
if (ne) return void Et();
|
|
1856
1823
|
}
|
|
1857
|
-
}, [
|
|
1858
|
-
|
|
1824
|
+
}, [Q, R]), [he, Wt] = gt(!le);
|
|
1825
|
+
It(() => {
|
|
1859
1826
|
Wt(!1);
|
|
1860
1827
|
}, []);
|
|
1861
|
-
const
|
|
1862
|
-
let
|
|
1863
|
-
if (!
|
|
1864
|
-
const
|
|
1865
|
-
|
|
1828
|
+
const k = go(n, () => ({ startEdit(b) {
|
|
1829
|
+
let Re = b?.initialSelection;
|
|
1830
|
+
if (!Re) {
|
|
1831
|
+
const we = te.current.value.length ?? 0;
|
|
1832
|
+
Re = { start: we, end: we, direction: "forward" };
|
|
1866
1833
|
}
|
|
1867
|
-
|
|
1868
|
-
const
|
|
1869
|
-
b?.text !== void 0 && (
|
|
1834
|
+
te.current?.setSelectionRange(Re.start, Re.end, Re.direction);
|
|
1835
|
+
const ne = { ...o, editMode: b?.editMode ?? !1 };
|
|
1836
|
+
b?.text !== void 0 && (ne.dirty = b.text), ne.editMode === o.editMode && ne.dirty === o.dirty || (T(ne), D?.(ne));
|
|
1870
1837
|
}, submitEdit: () => Et(), cancelEdit() {
|
|
1871
|
-
|
|
1838
|
+
wt();
|
|
1872
1839
|
}, autoFocus() {
|
|
1873
|
-
|
|
1874
|
-
}, getLineHeight: () => Xe?.maxLineHeight ?? Ne, dispatchEvent: (b) =>
|
|
1875
|
-
return Ce("div", { ref:
|
|
1876
|
-
|
|
1840
|
+
te.current?.focus();
|
|
1841
|
+
}, getLineHeight: () => Xe?.maxLineHeight ?? Ne, dispatchEvent: (b) => te.current.dispatchEvent(b) }), [o, c]);
|
|
1842
|
+
return Ce("div", { ref: k, ...J, style: { background: "transparent", display: "flex", flexGrow: 1, alignSelf: "center", height: Xe.height, maxWidth: "100%", maxHeight: "100%", ...A }, children: Ce("textarea", { spellCheck: "false", ref: te, value: ye, autoFocus: !1, disabled: he, name: "cell-editor", autoComplete: "off", autoCapitalize: "off", style: { flex: "1 1 100%", position: "relative", fontSize: `${p}px`, fontFamily: `${Ve}`, fontWeight: `${We}`, fontStyle: `${ue}`, padding: "0px", marginRight: _ === "right" ? "3px" : "0px", marginLeft: _ === "left" ? "2px" : "0px", lineHeight: be, height: Xe.height, textRendering: "geometricPrecision", letterSpacing: "-0.25px", boxSizing: "border-box", borderWidth: 0, outline: "none", resize: "none", overflow: "hidden", verticalAlign: "baseline", textAlign: _, background: "transparent", color: W, marginBottom: "0px", userSelect: "text", maxHeight: "100%", whiteSpace: me === "wrap" ? "break-spaces" : "pre", wordWrap: "break-word" }, onChange: (b) => {
|
|
1843
|
+
q(b.target.value);
|
|
1877
1844
|
}, onDoubleClick: (b) => {
|
|
1878
1845
|
b.isTrusted;
|
|
1879
1846
|
}, onMouseDown: (b) => {
|
|
1880
1847
|
Pt(!0);
|
|
1881
|
-
}, onKeyDown:
|
|
1882
|
-
})),
|
|
1883
|
-
const { value: n, view: o, bounds: r, range: c, zoom:
|
|
1884
|
-
return Ce("div", { style: { padding: "2px 4px", fontFamily: "Calibri", letterSpacing: -0.25, lineHeight: 1.2, fontSize: l?.fontSize || 1056 / 72, ...l }, ...
|
|
1848
|
+
}, onKeyDown: ut }) });
|
|
1849
|
+
})), br = Kt((t) => {
|
|
1850
|
+
const { value: n, view: o, bounds: r, range: c, zoom: d, children: i, style: l, ...w } = t;
|
|
1851
|
+
return Ce("div", { style: { padding: "2px 4px", fontFamily: "Calibri", letterSpacing: -0.25, lineHeight: 1.2, fontSize: l?.fontSize || 1056 / 72, ...l }, ...w, children: n });
|
|
1885
1852
|
});
|
|
1886
1853
|
export {
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1854
|
+
Co as BaseGrid,
|
|
1855
|
+
yr as DefaultCellEditor,
|
|
1856
|
+
br as DefaultCellRenderer,
|
|
1857
|
+
ir as DefaultHeaderDivider,
|
|
1858
|
+
yo as FillHandle,
|
|
1859
|
+
Eo as Grid,
|
|
1860
|
+
Sr as HeaderDivider,
|
|
1861
|
+
lr as HeaderRenderer,
|
|
1862
|
+
vr as RESET_SCROLL_EVENTS_DEBOUNCE_INTERVAL,
|
|
1896
1863
|
Vt as SELECTION_CLIP_INSETS,
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1864
|
+
mo as STANDARD_KEY_CHARS,
|
|
1865
|
+
co as SVGLine,
|
|
1866
|
+
jo as SVGRect,
|
|
1867
|
+
rr as ScrollableGrid,
|
|
1868
|
+
vo as Selection,
|
|
1869
|
+
Xn as TouchSelectHandle,
|
|
1870
|
+
Yo as defaultSelectionRenderer,
|
|
1871
|
+
ar as getDefaultStringEditState,
|
|
1905
1872
|
$t as safeSelectionCoords,
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
br as useSelection
|
|
1873
|
+
Bo as useCellLayout,
|
|
1874
|
+
pr as useHeaderSelection,
|
|
1875
|
+
xr as useKeyboardEditorOverlay,
|
|
1876
|
+
mr as useSelection
|
|
1911
1877
|
};
|