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