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