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