@sheetxl/grid-react 0.3.0 → 0.3.2
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 +11 -11
- package/README.md +8 -8
- package/browser/cjs/index.cjs +6 -11
- package/browser/esm/index.mjs +197 -209
- package/licenses/dependencies.txt +22 -22
- package/node/assets/style.css +1 -1
- package/node/esm/index.mjs +93 -105
- package/package.json +3 -6
package/browser/esm/index.mjs
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._sheetxl-
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._sheetxl-grid_11irg_13{position:relative;box-sizing:border-box;user-select:none}._sheetxl-grid_11irg_13 *{box-sizing:border-box!important}._sheetxl-grid_11irg_13 *:focus{outline:none}._sheetxl-grid_11irg_13 .cell-container{position:absolute;overflow:visible;white-space:pre}._sheetxl-grid_11irg_13 .cell-container>*{inset:0;position:absolute}._sheetxl-grid_11irg_13 .sheetxl-stage{contain:strict}._sheetxl-grid_11irg_13 .sheetxl-stage>*{contain:strict}")),document.head.appendChild(e)}}catch(i){console.error("vite-plugin-css-injected-by-js",i)}})();
|
|
2
2
|
import { jsx as Y, jsxs as Ht, Fragment as wn } from "react/jsx-runtime";
|
|
3
|
-
import Sn, { memo as Dt, useCallback as O, useRef as J, useEffect as st, useImperativeHandle as Ur, forwardRef as Ut, useMemo as Ee, useLayoutEffect as nn, useState as Je, version as
|
|
3
|
+
import Sn, { memo as Dt, useCallback as O, useRef as J, useEffect as st, useImperativeHandle as Ur, forwardRef as Ut, useMemo as Ee, useLayoutEffect as nn, useState as Je, version as qr, createElement as Jo, useReducer as Qo } from "react";
|
|
4
4
|
import { createRoot as Oi } from "react-dom/client";
|
|
5
|
-
import { unstable_batchedUpdates as Li, createPortal as
|
|
5
|
+
import { unstable_batchedUpdates as Li, createPortal as Kr } from "react-dom";
|
|
6
6
|
/**
|
|
7
|
-
* @license @sheetxl/grid-react - Grid - Advanced data grid component for React - v0.3.
|
|
7
|
+
* @license @sheetxl/grid-react - Grid - Advanced data grid component for React - v0.3.2
|
|
8
8
|
*
|
|
9
9
|
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
10
10
|
* License: The license can be found at https://www.sheetxl.com/license.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
* @license @sheetxl/utils - Utils - Utilities used by most SheetXL components. - v0.3.0
|
|
14
|
-
*
|
|
15
|
-
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
16
|
-
* License: The license can be found at https://www.sheetxl.com/license.
|
|
17
|
-
*/
|
|
18
|
-
const it = "up", lt = "down", ot = "left", qe = "right", uo = "tl", Hn = "t", Nn = "l", Xt = "c", Bt = "text/html", fn = "text/plain", Mo = "image/png", Di = Object.freeze({ left: 0, top: 0 }), zi = Object.freeze({ left: 0, top: 0, bottom: 0, right: 0 }), Ai = Object.freeze({ x: 0, y: 0, width: 0, height: 0 });
|
|
12
|
+
const it = "up", lt = "down", ot = "left", Ke = "right", uo = "tl", Hn = "t", Nn = "l", Xt = "c", Bt = "text/html", fn = "text/plain", Mo = "image/png", Di = Object.freeze({ left: 0, top: 0 }), zi = Object.freeze({ left: 0, top: 0, bottom: 0, right: 0 }), Ai = Object.freeze({ x: 0, y: 0, width: 0, height: 0 });
|
|
19
13
|
Object.freeze(Object.defineProperty({ __proto__: null, EmptyBounds: Ai, EmptyRect: zi, EmptyTopLeft: Di }, Symbol.toStringTag, { value: "Module" }));
|
|
20
14
|
const Nt = "column", cn = "row", $i = Object.freeze({ colIndex: 0, rowIndex: 0 }), Bi = Object.freeze({ colStart: 0, rowStart: 0, colEnd: 0, rowEnd: 0 }), Yr = (e, t) => e.colStart === t.colStart ? e.rowStart - t.rowStart : e.colStart - t.colStart, Xr = (e, t) => e.rowStart === t.rowStart ? e.colStart - t.colStart : e.rowStart - t.rowStart, Fi = (e, t) => e.rowEnd === t.rowEnd ? t.colEnd - e.colEnd : t.rowEnd - e.rowEnd, ji = (e, t) => e.colEnd === t.colEnd ? t.rowEnd - e.rowEnd : t.colEnd - e.colEnd, or = (e, t) => e.colIndex === t.colIndex ? e.rowIndex - t.rowIndex : e.colIndex - t.colIndex, rr = (e, t) => e.rowIndex === t.rowIndex ? e.colIndex - t.colIndex : e.rowIndex - t.rowIndex, Gr = (e = cn, t = !1) => t ? e !== Nt ? Fi : ji : e !== Nt ? Xr : Yr, ir = (e, t) => e === t || !(!e || !t) && e.rowIndex === t.rowIndex && e.colIndex === t.colIndex, jo = (e, t) => e === t || !(!e || !t) && e.rowStart === t.rowStart && e.rowEnd === t.rowEnd && e.colStart === t.colStart && e.colEnd === t.colEnd, Vo = (e, t) => !(!e || !t || e.colStart > t.colEnd || t.colStart > e.colEnd || e.rowStart > t.rowEnd || t.rowStart > e.rowEnd), lr = (e, t) => {
|
|
21
15
|
if (e === t) return !0;
|
|
@@ -164,7 +158,7 @@ _n.all = function(e, t) {
|
|
|
164
158
|
return _n(n, o, t);
|
|
165
159
|
}, {});
|
|
166
160
|
};
|
|
167
|
-
const
|
|
161
|
+
const qi = Object.freeze([]), Ki = Object.freeze({}), ur = (e) => e, so = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
|
|
168
162
|
let t = 16 * Math.random() | 0;
|
|
169
163
|
return (e === "x" ? t : 3 & t | 8).toString(16);
|
|
170
164
|
}), Zr = (e, t) => e === t || !(!Array.isArray(e) || !Array.isArray(t) || e.length !== t.length) && e.every((n, o) => n === t[o]), Fn = (e) => typeof e == "object" && !Array.isArray(e) && e !== null, Jr = (e) => typeof e != "object" || Array.isArray(e) || e === null ? e : (Object.keys(e).forEach(function(t) {
|
|
@@ -188,7 +182,7 @@ const Ki = Object.freeze([]), qi = Object.freeze({}), ur = (e) => e, so = () =>
|
|
|
188
182
|
function ei() {
|
|
189
183
|
return typeof process < "u" && process.release?.name === "node" || (typeof process < "u" && process.browser, !1);
|
|
190
184
|
}
|
|
191
|
-
const wr = (e, t = !1) => (document.hasFocus() || t) && (e === document.activeElement || e?.contains(document.activeElement)), Ct = Object.freeze(Object.defineProperty({ __proto__: null, EmptyArray:
|
|
185
|
+
const wr = (e, t = !1) => (document.hasFocus() || t) && (e === document.activeElement || e?.contains(document.activeElement)), Ct = Object.freeze(Object.defineProperty({ __proto__: null, EmptyArray: qi, EmptyObject: Ki, OSType: Ft, arrayMove: function(e, t, n) {
|
|
192
186
|
const o = e.slice();
|
|
193
187
|
return o.splice(n < 0 ? o.length + n : n, 0, o.splice(t, 1)[0]), o;
|
|
194
188
|
}, asNumber: (e) => {
|
|
@@ -287,7 +281,7 @@ const wr = (e, t = !1) => (document.hasFocus() || t) && (e === document.activeEl
|
|
|
287
281
|
}, findNextStep: (e, t = !0, n = 15, o = 10, r = 400) => {
|
|
288
282
|
const i = Math.max(e - o, 0) + (t ? 1 : -1);
|
|
289
283
|
return Math.min(r, Math[t ? "ceil" : "floor"](i / n) * n + o);
|
|
290
|
-
},
|
|
284
|
+
}, getDPI: () => {
|
|
291
285
|
let e = 1;
|
|
292
286
|
return typeof window == "object" && (e = window.devicePixelRatio || 1), e;
|
|
293
287
|
}, getFromPath: (e, t) => {
|
|
@@ -618,11 +612,11 @@ const Ho = async (e, t = Bt) => new Promise(async (n, o) => {
|
|
|
618
612
|
console.warn("Can't parse html from clipboard.");
|
|
619
613
|
}
|
|
620
614
|
return o;
|
|
621
|
-
},
|
|
615
|
+
}, qn = "clipboard-uuid", Tn = "web text/uuid", Sr = (e) => `<div style="display:none" ${qn}="${e}"/>`, Xi = (e, t) => {
|
|
622
616
|
let n = null;
|
|
623
617
|
try {
|
|
624
618
|
const o = new DOMParser().parseFromString(t, Bt);
|
|
625
|
-
o.body.firstElementChild.setAttribute(
|
|
619
|
+
o.body.firstElementChild.setAttribute(qn, e), n = o.getElementsByTagName("body")[0].innerHTML;
|
|
626
620
|
} catch (o) {
|
|
627
621
|
console.warn("Can't embed uuid.", o);
|
|
628
622
|
}
|
|
@@ -630,7 +624,7 @@ const Ho = async (e, t = Bt) => new Promise(async (n, o) => {
|
|
|
630
624
|
}, Er = (e, t) => {
|
|
631
625
|
if (!t || !e) return !1;
|
|
632
626
|
try {
|
|
633
|
-
const n = t.querySelectorAll(`[${
|
|
627
|
+
const n = t.querySelectorAll(`[${qn}="${e}"]`);
|
|
634
628
|
if (n && n.length === 1) return !0;
|
|
635
629
|
if (t.querySelector("parsererror")) throw new Error("We are unable to parse node");
|
|
636
630
|
return !1;
|
|
@@ -707,12 +701,12 @@ let ho = class {
|
|
|
707
701
|
const f = await s.getType(fn);
|
|
708
702
|
if (f) {
|
|
709
703
|
let x = null;
|
|
710
|
-
typeof f == "string" ? (console.warn("text as string", f), x = f) : x = await Wo(f), x && (d = `<div ${
|
|
704
|
+
typeof f == "string" ? (console.warn("text as string", f), x = f) : x = await Wo(f), x && (d = `<div ${qn}="${o}">${x}</div>`);
|
|
711
705
|
}
|
|
712
706
|
}
|
|
713
707
|
if (!d && s.types.includes(Mo)) {
|
|
714
708
|
const f = await s.getType(Mo), x = ti(await f.arrayBuffer());
|
|
715
|
-
d = `<div ${
|
|
709
|
+
d = `<div ${qn}="${o}"><img src="${ni + x}"/></div>`;
|
|
716
710
|
}
|
|
717
711
|
!d && o && (d = Sr(o));
|
|
718
712
|
const g = new Blob([d ?? ""], { type: Bt }), m = {};
|
|
@@ -816,18 +810,12 @@ var Lo;
|
|
|
816
810
|
try {
|
|
817
811
|
if (typeof document < "u") {
|
|
818
812
|
var e = document.createElement("style");
|
|
819
|
-
e.appendChild(document.createTextNode("._sheetxl-
|
|
813
|
+
e.appendChild(document.createTextNode("._sheetxl-scrollbar_18qzf_11 ::-webkit-scrollbar-button{background:transparent}._fullscreen-portal-root_5qk7s_7{pointer-events:none;position:absolute;inset:0;width:100%;height:100%;z-index:1200}._fullscreen-portal-root_5qk7s_7>*{pointer-events:auto}")), document.head.appendChild(e);
|
|
820
814
|
}
|
|
821
815
|
} catch (t) {
|
|
822
816
|
console.error("vite-plugin-css-injected-by-js", t);
|
|
823
817
|
}
|
|
824
818
|
}();
|
|
825
|
-
/**
|
|
826
|
-
* @license @sheetxl/utils-react - Utils React - Utilities for React capabilities needed for all SheetXL components. - v0.3.0
|
|
827
|
-
*
|
|
828
|
-
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
829
|
-
* License: The license can be found at https://www.sheetxl.com/license.
|
|
830
|
-
*/
|
|
831
819
|
const Wn = { Left: "left", Right: "right", Center: "center" }, It = "shift", yn = "alt", Lt = "ctrl", Gi = 9, Zi = 13, Ji = 27, Qi = 37, el = 38, tl = 39, nl = 40, ol = 113, _r = 3, mn = { Horizontal: "horizontal", Vertical: "vertical" };
|
|
832
820
|
function li(e) {
|
|
833
821
|
var t, n, o = "";
|
|
@@ -889,27 +877,27 @@ const er = Dt(Ut((e, t) => {
|
|
|
889
877
|
}, [C, U]);
|
|
890
878
|
const W = O((S, ue = !1) => {
|
|
891
879
|
if (!R.current) return 0;
|
|
892
|
-
const
|
|
880
|
+
const K = R.current.querySelector(".scrollbar-viewport"), pe = K.getBoundingClientRect(), te = K.children, Re = ue ? 0 : No(S, pe[H], te, !0, Math.max(0, S - m));
|
|
893
881
|
return ee(Re), Math.max(0, Re);
|
|
894
882
|
}, []), A = O((S, ue = !1) => {
|
|
895
883
|
if (!R.current) return 0;
|
|
896
|
-
const
|
|
884
|
+
const K = R.current.querySelector(".scrollbar-viewport"), pe = K.getBoundingClientRect(), te = K.children, Re = Math.ceil(u - k), at = ue ? Re : No(S, pe[H], te, !1, Math.max(0, S + m));
|
|
897
885
|
return ee(at), Math.min(Re, at);
|
|
898
|
-
}, [u, k]),
|
|
899
|
-
|
|
886
|
+
}, [u, k]), q = J(null), N = O((S) => {
|
|
887
|
+
q.current = n;
|
|
900
888
|
const ue = S.target[X];
|
|
901
889
|
a(ue, r, o), ae?.(S);
|
|
902
890
|
}, [a, r, o, n]);
|
|
903
891
|
st(() => {
|
|
904
|
-
const S =
|
|
905
|
-
|
|
892
|
+
const S = q.current;
|
|
893
|
+
q.current = null, n !== S && (R.current[X] = n);
|
|
906
894
|
}, [n, X]);
|
|
907
895
|
const xe = J(null), G = J(null), He = O(() => {
|
|
908
896
|
xe.current && (clearTimeout(xe.current), xe.current = null, G.current = null);
|
|
909
|
-
}, []), Ue = O((S, ue,
|
|
897
|
+
}, []), Ue = O((S, ue, K, pe = f) => {
|
|
910
898
|
G.current = S, xe.current = setTimeout(() => {
|
|
911
|
-
const te =
|
|
912
|
-
te !== G.current ? Ue(te, !1,
|
|
899
|
+
const te = K ? W(G.current || S) : A(G.current || S);
|
|
900
|
+
te !== G.current ? Ue(te, !1, K, x) : He();
|
|
913
901
|
}, ue ? 0 : pe);
|
|
914
902
|
}, [W, A, He]);
|
|
915
903
|
st(() => () => He(), [He]);
|
|
@@ -922,7 +910,7 @@ const er = Dt(Ut((e, t) => {
|
|
|
922
910
|
const S = { orientation: s, disabled: Math.floor(u - k) <= Math.ceil(We), onMouseUp: He, onMouseLeave: He, onMouseDown: () => Ue(We, !0, !1) };
|
|
923
911
|
return I?.(S);
|
|
924
912
|
}, [g, s, We, C, u, k]);
|
|
925
|
-
return Ht("div", { ref: t, style: { display: "flex", flex: "1", flexDirection: U ? "column" : "row", padding: "0", ...i }, className: Rn("_sheetxl-
|
|
913
|
+
return Ht("div", { ref: t, style: { display: "flex", flex: "1", flexDirection: U ? "column" : "row", padding: "0", ...i }, className: Rn("_sheetxl-scrollbar_18qzf_11", l), ...M, children: [ht, Y("div", { className: "pseudo-scrollbar", style: { flex: "1 1 100%", display: "flex", boxSizing: "content-box", flexDirection: U ? "column" : "row", justifyContent: "center", alignItems: "center" }, ref: _, children: Y("div", { tabIndex: -1, style: { flex: "1 1 100%", overflowY: U ? "scroll" : "hidden", overflowX: U ? "hidden" : "scroll", position: "relative", willChange: "transform" }, onScroll: N, ref: R, children: Y("div", { ref: $, style: { position: "absolute", height: U ? o - r + (le ?? 0) : 1, width: U ? 1 : o - r + (L ?? 0) }, className: "scrollbar-viewport" }) }) }), _e] });
|
|
926
914
|
}));
|
|
927
915
|
er.displayName = "Scrollbar";
|
|
928
916
|
let Cr = Date.now, gn = {}, cl = 1;
|
|
@@ -1096,7 +1084,7 @@ var Gt = typeof window < "u" ? window : { screen: {}, navigator: {} }, Ln = (Gt.
|
|
|
1096
1084
|
Gt.addEventListener && Gt.addEventListener("p", Tr, hl), Gt.removeEventListener && Gt.removeEventListener("p", Tr, !1);
|
|
1097
1085
|
var fl = ai, pl = "PointerEvent" in Gt, tr = "ontouchstart" in Gt, di = tr || "TouchEvent" in Gt && Ln("(any-pointer: coarse)").matches, Rr = (Gt.navigator.maxTouchPoints || 0) > 0 || di, ui = Gt.navigator.userAgent || "", gl = Ln("(pointer: coarse)").matches && /iPad|Macintosh/.test(ui) && Math.min(Gt.screen.width || 0, Gt.screen.height || 0) >= 768, hi = (Ln("(pointer: coarse)").matches || !Ln("(pointer: fine)").matches && tr) && !/Windows.*Firefox/.test(ui), wl = Ln("(any-pointer: fine)").matches || Ln("(any-hover: hover)").matches || gl || !tr, Uo = !Rr || !wl && hi ? Rr ? "touchOnly" : "mouseOnly" : "hybrid", ml = Uo === "mouseOnly" ? "mouse" : Uo === "touchOnly" || hi ? "touch" : "mouse";
|
|
1098
1086
|
const xl = Object.freeze(Object.defineProperty({ __proto__: null, deviceType: Uo, primaryInput: ml, supportsPassiveEvents: fl, supportsPointerEvents: pl, supportsTouchEvents: di }, Symbol.toStringTag, { value: "Module" })), vl = /* @__PURE__ */ new Set(["INPUT", "TEXTAREA", "SELECT"]), fi = {};
|
|
1099
|
-
function
|
|
1087
|
+
function qo() {
|
|
1100
1088
|
return xl;
|
|
1101
1089
|
}
|
|
1102
1090
|
const me = Object.freeze(Object.defineProperty({ __proto__: null, EmptyCssProperties: fi, boundPixel: function(e, t = !1, n = 0) {
|
|
@@ -1109,7 +1097,7 @@ const me = Object.freeze(Object.defineProperty({ __proto__: null, EmptyCssProper
|
|
|
1109
1097
|
n = !0, e.stopPropagation();
|
|
1110
1098
|
}, isPropagationStopped: () => n, persist: () => {
|
|
1111
1099
|
}, timeStamp: e.timeStamp, type: e.type };
|
|
1112
|
-
}, detectIt:
|
|
1100
|
+
}, detectIt: qo, focusableNodeNames: vl, toPrettyKeyCode: (e) => e === "BracketLeft" ? "[" : e === "BracketRight" ? "]" : Ct.camelToPrettyCase(e) }, Symbol.toStringTag, { value: "Module" })), yl = [];
|
|
1113
1101
|
function wo(e, t, n = yl) {
|
|
1114
1102
|
const o = J(null);
|
|
1115
1103
|
return Ur(e, () => {
|
|
@@ -1142,12 +1130,12 @@ const kr = (e) => Y(er, { ...e }), bl = ({ width: e, height: t }) => Y("div", {
|
|
|
1142
1130
|
}, []);
|
|
1143
1131
|
st(() => {
|
|
1144
1132
|
const k = m ?? I.current;
|
|
1145
|
-
if (!f &&
|
|
1133
|
+
if (!f && qo().supportsTouchEvents && k && o) {
|
|
1146
1134
|
if (!M.current) {
|
|
1147
1135
|
const u = { scrollingX: !0, scrollingY: !0, decelerationRate: 0.95, penetrationAcceleration: 0.08 };
|
|
1148
1136
|
M.current = new ci(ae, u);
|
|
1149
1137
|
}
|
|
1150
|
-
|
|
1138
|
+
qo().supportsTouchEvents && (k.addEventListener("touchstart", R), k.addEventListener("touchend", L), k.addEventListener("touchmove", _)), le({ containerWidth: o?.width, containerHeight: o?.height, totalWidth: o?.totalWidth, totalHeight: o?.totalHeight });
|
|
1151
1139
|
}
|
|
1152
1140
|
return () => {
|
|
1153
1141
|
k?.removeEventListener("touchstart", R), k?.removeEventListener("touchend", L), k?.removeEventListener("touchmove", _);
|
|
@@ -1176,7 +1164,7 @@ function gi() {
|
|
|
1176
1164
|
const t = document.fullscreenElement;
|
|
1177
1165
|
if (!t) return;
|
|
1178
1166
|
let n = t.querySelector(".fullscreen-portal-root");
|
|
1179
|
-
n || (n = document.createElement("div"), n.className = "fullscreen-portal-root _fullscreen-portal-
|
|
1167
|
+
n || (n = document.createElement("div"), n.className = "fullscreen-portal-root _fullscreen-portal-root_5qk7s_7", t.appendChild(n));
|
|
1180
1168
|
}
|
|
1181
1169
|
return no++, e(), document.addEventListener("fullscreenchange", e), () => {
|
|
1182
1170
|
document.removeEventListener("fullscreenchange", e), no--, no <= 0 && (document.querySelectorAll(".fullscreen-portal-root").forEach((t) => {
|
|
@@ -1197,7 +1185,7 @@ const El = 100, _l = 100, Il = 1e6, Cl = 100, Ml = 50, Tl = Dt(Ut((e, t) => {
|
|
|
1197
1185
|
_(W);
|
|
1198
1186
|
}
|
|
1199
1187
|
}, [r, o, n, H, i, l, s]);
|
|
1200
|
-
const u = T((W, A,
|
|
1188
|
+
const u = T((W, A, q) => {
|
|
1201
1189
|
const N = k.current;
|
|
1202
1190
|
k.current = null, N && N.propTotalSize === r && N.propViewportSize === o && N.propOffset === n || (Math.abs(W - oe) < le && (W = oe), g?.(W * L, oe, be));
|
|
1203
1191
|
}, [g, L, le, oe, be]), C = O((W) => {
|
|
@@ -1212,7 +1200,7 @@ function Do(e, t) {
|
|
|
1212
1200
|
e && (e.current = t);
|
|
1213
1201
|
}
|
|
1214
1202
|
Tl.displayName = "VirtualScrollbar";
|
|
1215
|
-
var fo = parseInt(
|
|
1203
|
+
var fo = parseInt(qr.split(".")[0], 10) >= 19 ? function(e) {
|
|
1216
1204
|
return (t) => {
|
|
1217
1205
|
const n = [];
|
|
1218
1206
|
for (const o of e) {
|
|
@@ -1250,7 +1238,7 @@ Dt(Ut((e, t) => {
|
|
|
1250
1238
|
return function(le, $, oe = !1) {
|
|
1251
1239
|
if ($ === 0) return le;
|
|
1252
1240
|
function be(C, ee, W) {
|
|
1253
|
-
let A = ee.x - C.x,
|
|
1241
|
+
let A = ee.x - C.x, q = ee.y - C.y, N = Math.sqrt(A * A + q * q);
|
|
1254
1242
|
return U(C, ee, Math.min(1, W / N));
|
|
1255
1243
|
}
|
|
1256
1244
|
function U(C, ee, W) {
|
|
@@ -1272,13 +1260,13 @@ Dt(Ut((e, t) => {
|
|
|
1272
1260
|
let C = X(k[0]), ee = null;
|
|
1273
1261
|
k[k.length - 1][0] === "Z" && k[0].length > 2 && (ee = ["L", C.x, C.y], k[k.length - 1] = ee), u.push(k[0]);
|
|
1274
1262
|
for (let W = 1; W < k.length; W++) {
|
|
1275
|
-
let A = u[u.length - 1],
|
|
1276
|
-
if (N && A && A.length > 2 &&
|
|
1277
|
-
let xe, G, He = X(A), Ue = X(
|
|
1278
|
-
oe ? (xe = U(Ue, A.origPoint || He, $), G = U(Ue, N.origPoint || We, $)) : (xe = be(Ue, He, $), G = be(Ue, We, $)), H(
|
|
1263
|
+
let A = u[u.length - 1], q = k[W], N = q === ee ? k[1] : k[W + 1];
|
|
1264
|
+
if (N && A && A.length > 2 && q[0] === "L" && N.length > 2 && N[0] === "L") {
|
|
1265
|
+
let xe, G, He = X(A), Ue = X(q), We = X(N);
|
|
1266
|
+
oe ? (xe = U(Ue, A.origPoint || He, $), G = U(Ue, N.origPoint || We, $)) : (xe = be(Ue, He, $), G = be(Ue, We, $)), H(q, xe), q.origPoint = Ue, u.push(q);
|
|
1279
1267
|
let ht = U(xe, Ue, 0.5), _e = U(Ue, G, 0.5), S = ["C", ht.x, ht.y, _e.x, _e.y, G.x, G.y];
|
|
1280
1268
|
S.origPoint = Ue, u.push(S);
|
|
1281
|
-
} else u.push(
|
|
1269
|
+
} else u.push(q);
|
|
1282
1270
|
}
|
|
1283
1271
|
if (ee) {
|
|
1284
1272
|
let W = X(u[u.length - 1]);
|
|
@@ -1352,21 +1340,21 @@ Dt(Ut((e, t) => {
|
|
|
1352
1340
|
st(() => {
|
|
1353
1341
|
k(pn(l, i === null));
|
|
1354
1342
|
}, [l, i]);
|
|
1355
|
-
const [u, { width: C, height: ee }] = In(), [W, { width: A, height:
|
|
1343
|
+
const [u, { width: C, height: ee }] = In(), [W, { width: A, height: q }] = In(), N = r === "row" ? A : q, xe = r === "row" ? C : ee, G = Ee(() => ((Q, et, qe, dt) => {
|
|
1356
1344
|
const Ie = [null, null], Le = [null, null];
|
|
1357
|
-
if (Q || (Q = { percent: dt.fixedPaneOffset === null ? 50 : null, pixels: dt.fixedPaneOffset === null ? null : 0 }), et === 0) return Q?.pixels != null ? dt.fixedPaneOffset !== 1 ? (Ie[0] = Q?.pixels, Le[1] = 100) : (Ie[1] = Q?.pixels -
|
|
1358
|
-
let rt = bn(Q, et, dt.fixedPaneOffset !== 1), tt = et -
|
|
1359
|
-
Mt = (bn(dt.maxAfter, et, !1) ??
|
|
1345
|
+
if (Q || (Q = { percent: dt.fixedPaneOffset === null ? 50 : null, pixels: dt.fixedPaneOffset === null ? null : 0 }), et === 0) return Q?.pixels != null ? dt.fixedPaneOffset !== 1 ? (Ie[0] = Q?.pixels, Le[1] = 100) : (Ie[1] = Q?.pixels - qe, Le[0] = 100) : Q?.percent != null && (dt.fixedPaneOffset !== 1 ? (Le[0] = Q?.percent, Le[1] = 100 - Q?.percent) : (Le[1] = Q?.percent, Le[0] = 100 - Q?.percent)), { percents: Le, pixels: Ie, minBefore: ro(dt.minBefore, !0), maxBefore: ro(dt.maxBefore, !0), minAfter: ro(dt.minAfter), maxAfter: ro(dt.maxAfter) };
|
|
1346
|
+
let rt = bn(Q, et, dt.fixedPaneOffset !== 1), tt = et - qe, Ae = bn(dt.minBefore, tt, !0) ?? 0, rn = bn(dt.maxBefore, tt, !0) ?? tt, Mt = 0, nt = 0, Tt = 0, kt = tt;
|
|
1347
|
+
Mt = (bn(dt.maxAfter, et, !1) ?? qe) - qe, nt = bn(dt.minAfter, et, !1) ?? et, Tt = Math.max(Ae, Mt), kt = Math.min(rn, nt), rt = Math.max(Tt, Math.min(rt, kt)), nt = Math.min(tt - rt, bn(dt.maxAfter, tt - rt, !0) ?? tt), Mt = Math.min(tt - rt, bn(dt.minAfter, tt - rt, !0) ?? tt), Ie[0] = rt, Ie[1] = tt - Ie[0];
|
|
1360
1348
|
const hn = Math.max(0, Math.min(100, rt / tt * 100));
|
|
1361
1349
|
return Le[0] = hn, Le[1] = 100 - Le[0], { percents: Le, pixels: Ie, minBefore: `${Ae}px`, minAfter: `${Mt}px`, maxBefore: `${Ie[0]}px`, maxAfter: `${Ie[1]}px` };
|
|
1362
|
-
})(X, xe, N, U), [U, X, xe, N, r]), [He, Ue] = Je(!1), We = T(M, [M]), ht = T(ae, [ae]), _e = T(R, [R]), S = J(null), ue = J(null),
|
|
1350
|
+
})(X, xe, N, U), [U, X, xe, N, r]), [He, Ue] = Je(!1), We = T(M, [M]), ht = T(ae, [ae]), _e = T(R, [R]), S = J(null), ue = J(null), K = J(null), { style: pe, className: te, ...Re } = L, at = { minWidth: 0, minHeight: 0, maxWidth: "100%", maxHeight: "100%", display: "flex", overflow: "hidden", ...pe }, { className: pt, style: zt, ...gt } = le, { className: Zt, style: Be, ...z } = $, ke = { flex: "1 1 100%", width: "100%", ...E, flexDirection: r, display: "flex" }, { className: Qe, style: Xe, onPointerDown: wt, ...an } = _, Jt = T((Q) => {
|
|
1363
1351
|
const et = pn(Q, i === null);
|
|
1364
1352
|
k(et);
|
|
1365
1353
|
}, [i]), jt = T((Q) => {
|
|
1366
1354
|
if (I || !He) return;
|
|
1367
1355
|
const et = ze.current?.getBoundingClientRect();
|
|
1368
|
-
let
|
|
1369
|
-
|
|
1356
|
+
let qe = 0;
|
|
1357
|
+
qe = r === "row" ? (Q.clientX ?? Q.touches?.[0]?.clientX) - et.x : (Q.clientY ?? Q.touches?.[0]?.clientY) - et.y, qe = Math.max(0, Math.min(xe, qe)), U.fixedPaneOffset === 1 && (qe = xe - qe), l && X.pixels === qe || k({ pixels: qe, percent: null }), ht?.(qe), Q.stopPropagation(), Q.preventDefault();
|
|
1370
1358
|
}, [U, r, I, He, X, xe]), dn = T((Q) => {
|
|
1371
1359
|
if (document.removeEventListener("pointermove", jt), document.removeEventListener("touchmove", jt), document.removeEventListener("pointerup", dn), He && (Ue(!1), X)) {
|
|
1372
1360
|
if (_e(X.pixels), !pn(l, i === null) || X.pixels !== l) {
|
|
@@ -1377,8 +1365,8 @@ Dt(Ut((e, t) => {
|
|
|
1377
1365
|
}
|
|
1378
1366
|
}, [X, He, l, i, xe]), on = T((Q) => {
|
|
1379
1367
|
wt?.(Q), Q.defaultPrevented || I || He || (Ue(!0), We(), document.addEventListener("pointermove", jt, { passive: !1 }), document.addEventListener("touchmove", jt, { passive: !1 }), document.addEventListener("pointerup", dn, { passive: !1 }));
|
|
1380
|
-
}, [wt]), ze = wo(t, () => ({ setPosition: Jt, isSplitPane: () => !0 }), []),
|
|
1381
|
-
return Ht("div", { ref: fo([u, ze]), className: Rn("splitPane", r === "row" ? "vertical" : "horizontal", { dragging: He }, x), style: ke, children: [un,
|
|
1368
|
+
}, [wt]), ze = wo(t, () => ({ setPosition: Jt, isSplitPane: () => !0 }), []), qt = Ee(() => be ? oe?.({ key: "resizer", ref: fo([W, ue]), className: Rn("resizer", Qe), onPointerDownCapture: on, style: { cursor: I ? void 0 : r === "row" ? "ew-resize" : "ns-resize", minWidth: r === "row" ? "2px" : void 0, minHeight: r !== "row" ? "2px" : void 0, boxSizing: "border-box", pointerEvents: "all", zIndex: 1, ...Xe }, splitDirection: r, disabled: I, ...an }) : null, [be, Qe, an, r, Xe, I]), vt = r === "row" ? "Width" : "Height", Vt = { ...at, ...zt, flex: U.fixedPaneOffset === 0 && G?.pixels[0] !== null ? `0 0 ${Math.round(G?.pixels[0])}px` : `1 1 ${Math.round(G?.percents[0] ?? 100)}%`, [`min${vt}`]: G?.minBefore, [`max${vt}`]: o ? G?.maxBefore : "100%" }, Cn = { ...at, ...Be, flex: U.fixedPaneOffset === 1 && G?.pixels[1] !== null ? `0 0 ${Math.round(G?.pixels[1])}px` : `1 1 ${Math.round(G?.percents[1] ?? 100)}%`, [`min${vt}`]: G?.minAfter, [`max${vt}`]: n ? G?.maxAfter : "100%" }, un = Ee(() => n ? Y("div", { ref: S, className: Rn("before", te, pt), style: Vt, ...Re, ...gt, children: n }, "before") : null, [n, L, le, U, G]), Ne = Ee(() => o ? Y("div", { ref: K, className: Rn("after", te, Zt), style: Cn, ...Re, ...z, children: o }, "after") : null, [o, L, $, U, G]);
|
|
1369
|
+
return Ht("div", { ref: fo([u, ze]), className: Rn("splitPane", r === "row" ? "vertical" : "horizontal", { dragging: He }, x), style: ke, children: [un, qt, Ne] });
|
|
1382
1370
|
}));
|
|
1383
1371
|
const Pl = ({ initValue: e, useHookBody: t, applyStateChange: n }) => {
|
|
1384
1372
|
const o = J(e);
|
|
@@ -1387,7 +1375,7 @@ const Pl = ({ initValue: e, useHookBody: t, applyStateChange: n }) => {
|
|
|
1387
1375
|
return nn(() => {
|
|
1388
1376
|
o.current !== r && (o.current = r, n(r));
|
|
1389
1377
|
}, [n, r]), null;
|
|
1390
|
-
},
|
|
1378
|
+
}, Ko = (e) => {
|
|
1391
1379
|
console && console.warn && console.warn(e);
|
|
1392
1380
|
}, zo = typeof self == "object" && self.self === self && self || typeof global == "object" && global.global === global && global || void 0;
|
|
1393
1381
|
let Ol = 1, Yo = !1, wi = !1;
|
|
@@ -1398,10 +1386,10 @@ const co = [], kn = [], po = () => {
|
|
|
1398
1386
|
return o.current = t, e || Yo !== !1 || (wi = !0), st(() => {
|
|
1399
1387
|
let r = !0;
|
|
1400
1388
|
function i() {
|
|
1401
|
-
if (r) return kn[0] !== i ? (e || Yo !== !0 ||
|
|
1389
|
+
if (r) return kn[0] !== i ? (e || Yo !== !0 || Ko("SingletonHooksContainer is mounted after some singleton hook has been used.Your SingletonHooksContainer will not be used in favor of internal one."), void n((l) => [])) : void n([...co]);
|
|
1402
1390
|
}
|
|
1403
1391
|
return kn.push(i), po(), () => {
|
|
1404
|
-
r = !1, o.current?.length > 0 &&
|
|
1392
|
+
r = !1, o.current?.length > 0 && Ko("SingletonHooksContainer is unmounted, but it has active singleton hooks. They will be reevaluated once SingletonHooksContainer is mounted again"), kn.splice(kn.indexOf(i), 1), po();
|
|
1405
1393
|
};
|
|
1406
1394
|
}, [e]), Y(wn, { children: t.map(({ hook: r, key: i }) => Jo(Pl, { ...r, key: i })) });
|
|
1407
1395
|
}, mi = (e, t, n = {}) => {
|
|
@@ -1417,7 +1405,7 @@ const co = [], kn = [], po = () => {
|
|
|
1417
1405
|
if (zo.document && zo.document.createElement) {
|
|
1418
1406
|
const M = zo.document.createElement("div");
|
|
1419
1407
|
Oi(M).render(Y(I, { automaticContainerInternalUseOnly: !0 }));
|
|
1420
|
-
} else
|
|
1408
|
+
} else Ko("Can not mount SingletonHooksContainer on server side. Did you manage to run useEffect on server? Please mount SingletonHooksContainer into your components tree manually.");
|
|
1421
1409
|
})(Ll)), po(), () => {
|
|
1422
1410
|
co.splice(co.findIndex((I) => I.key === E), 1), po();
|
|
1423
1411
|
};
|
|
@@ -1635,18 +1623,18 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1635
1623
|
}, []), $ = n.current && Z.isEqualCells(n.current, R), oe = l && $ && M, be = s({ autoFocus: !!t.startEvent?.autoFocus, ...a, onSubmitEdit: L, onCancelEdit: le, ref: I }, R), U = i.x + me.boundPixel(-g / 2), H = me.boundPixel(i.width + g / 2, !0);
|
|
1636
1624
|
return Y("div", { tabIndex: 0, ref: E, style: { background: void 0, ...f, opacity: oe ? f?.opacity ?? 1 : 0, pointerEvents: "auto", position: "absolute", boxSizing: "border-box", top: `${i.y + me.boundPixel(-g / 2)}px`, height: me.boundPixel(i.height + g / 2, !0), left: `${U}px`, width: H }, ...x, children: Y("div", { className: "editor-container", style: { position: "absolute", boxSizing: "border-box", left: `${me.boundPixel(1)}px`, top: `${me.boundPixel(1)}px`, width: me.boundPixel(i.width - 2, !0), height: me.boundPixel(i.height - 2, !0), outline: `${g}px ${d} solid`, boxShadow: "rgba(60,64,67,.35) 2px 2px 6px 3px", maxHeight: "100%", overflow: "hidden", display: "flex" }, children: be }) });
|
|
1637
1625
|
}, gs = (e) => {
|
|
1638
|
-
const { view: t, canEdit: n = jl, getCellEditor: o, onBeforeStartEdit: r, onStartEdit: i, onSubmitEdit: l, onCancelEdit: s, onDoneEdit: a, isEditorStartKeyEvent: d = Vl, isEditorStartPointerEvent: g = Wl, containerProps: m, borderStrokeFill: f, borderStrokeWidth: x = 2, getRangeCoords: E = null, activeCoords: I, alignment: M = Wn.Left } = e, [ae, R] = Je(!1), [_, L] = Je(void 0), le = T((S, ue,
|
|
1626
|
+
const { view: t, canEdit: n = jl, getCellEditor: o, onBeforeStartEdit: r, onStartEdit: i, onSubmitEdit: l, onCancelEdit: s, onDoneEdit: a, isEditorStartKeyEvent: d = Vl, isEditorStartPointerEvent: g = Wl, containerProps: m, borderStrokeFill: f, borderStrokeWidth: x = 2, getRangeCoords: E = null, activeCoords: I, alignment: M = Wn.Left } = e, [ae, R] = Je(!1), [_, L] = Je(void 0), le = T((S, ue, K, pe, te, Re) => {
|
|
1639
1627
|
if (!ue) return null;
|
|
1640
1628
|
const at = te?.(ue, S), pt = S.getRangeCoordsBounds(at), zt = S.toClipBounds(pt), gt = pt, Zt = S.getZoom();
|
|
1641
1629
|
if (!zt) return null;
|
|
1642
|
-
|
|
1630
|
+
K && (K *= Zt), pe && (pe *= Zt);
|
|
1643
1631
|
let Be = gt, z = !1;
|
|
1644
|
-
if (
|
|
1632
|
+
if (K !== void 0) {
|
|
1645
1633
|
let Xe = { ...at }, wt = 0;
|
|
1646
|
-
for (; !z && Be.width <=
|
|
1634
|
+
for (; !z && Be.width <= K && wt < 20; ) {
|
|
1647
1635
|
wt++, wt > 19 && console.warn("max width reached");
|
|
1648
1636
|
const an = S.getTotalRangeCoords(), Jt = S.getLayout();
|
|
1649
|
-
Re === Wn.Left ? Xe.colEnd + 1 < an.colEnd ? Xe.colEnd = Jt.getColIndex(Be.x +
|
|
1637
|
+
Re === Wn.Left ? Xe.colEnd + 1 < an.colEnd ? Xe.colEnd = Jt.getColIndex(Be.x + K) : z = !0 : Re === Wn.Right ? Xe.colStart - 1 >= 0 ? Xe.colStart = Jt.getColIndex(Be.x - (K - Be.width)) : z = !0 : Re === Wn.Center && Xe.colEnd + 1 < an.colEnd && Xe.colStart - 1 >= 0 ? (Xe.colStart = Jt.getColIndex(Be.x - (K - Be.width) / 2), Xe.colEnd = Jt.getColIndex(Be.x + Be.width + (K - Be.width) / 2)) : z = !0, z || (Be = S.getRangeCoordsBounds(Xe));
|
|
1650
1638
|
}
|
|
1651
1639
|
}
|
|
1652
1640
|
Be.height = gt.height, pe !== void 0 && (Be.height = Math.max(pe + 1, gt.height));
|
|
@@ -1669,8 +1657,8 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1669
1657
|
}
|
|
1670
1658
|
}, [l]), k = T((S) => {
|
|
1671
1659
|
R(!1), a?.(S.coords), N();
|
|
1672
|
-
}, [a]), u = J(null), C = J(null), ee = J(null), W = J([]), [A,
|
|
1673
|
-
S && W.current.push(S),
|
|
1660
|
+
}, [a]), u = J(null), C = J(null), ee = J(null), W = J([]), [A, q] = Qo((S) => S + 1, 0), N = O((S) => {
|
|
1661
|
+
S && W.current.push(S), q();
|
|
1674
1662
|
}, []), xe = T((S) => {
|
|
1675
1663
|
if (S.defaultPrevented || S.isSynthetic || !t) return;
|
|
1676
1664
|
const ue = t?.getCellCoordsFromClient(S.clientX, S.clientY);
|
|
@@ -1721,7 +1709,7 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1721
1709
|
te.push(Lr(pt));
|
|
1722
1710
|
}
|
|
1723
1711
|
})(W.current), u.current, u.current;
|
|
1724
|
-
let
|
|
1712
|
+
let K = u.current;
|
|
1725
1713
|
if (u.current) {
|
|
1726
1714
|
if (u.current.isDone) u.current = null;
|
|
1727
1715
|
else if (u.current.isSubmitted || u.current.isCancelled) {
|
|
@@ -1778,7 +1766,7 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1778
1766
|
}
|
|
1779
1767
|
}
|
|
1780
1768
|
}
|
|
1781
|
-
W.current.length > 0 && (W.current.shift(), N()), W.current.length === 0 && (!u.current || u.current.isEditorClosing || u.current.isEditorClosed ? !u.current &&
|
|
1769
|
+
W.current.length > 0 && (W.current.shift(), N()), W.current.length === 0 && (!u.current || u.current.isEditorClosing || u.current.isEditorClosed ? !u.current && K && oe() : u.current.isMounted && !u.current.isStarted && (u.current.isStarted = !0, u.current.startEvent.autoFocus && (typeof u.current.startEvent.autoFocus == "string" ? u.current.editorRefs[0]?.autoFocus(u.current.startEvent.autoFocus) : u.current.editorRefs[0]?.autoFocus()), U?.(u.current), requestAnimationFrame(() => {
|
|
1782
1770
|
t && u.current?.coords && t.scrollCellCoordsIntoView(u.current.coords);
|
|
1783
1771
|
})));
|
|
1784
1772
|
}, [A]), st(() => {
|
|
@@ -1792,10 +1780,10 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1792
1780
|
return { overlay: T((S) => {
|
|
1793
1781
|
if (!u.current || u.current.isEditorClosed) return u.current, null;
|
|
1794
1782
|
u.current.coords;
|
|
1795
|
-
let ue = le(S, u.current.coords, We, ht, E, M),
|
|
1796
|
-
ue && ue.width !== 0 && ue.height !== 0 || (ue = { x: 0, y: 0, width: We, height: We },
|
|
1783
|
+
let ue = le(S, u.current.coords, We, ht, E, M), K = !0;
|
|
1784
|
+
ue && ue.width !== 0 && ue.height !== 0 || (ue = { x: 0, y: 0, width: We, height: We }, K = !1);
|
|
1797
1785
|
const pe = S.getZoom(), te = { containerBounds: { x: 0, y: 0, width: ue.width / pe, height: ue.height / pe }, setNaturalDimensions: L, zoom: pe };
|
|
1798
|
-
return Y(Hl, { session: u.current, refLatestCoords: ee, handleSubmitEdit: X, handleCancelEdit: H, cellBounds: ue, borderStrokeWidth: x, borderStrokeFill: f, isInBounds:
|
|
1786
|
+
return Y(Hl, { session: u.current, refLatestCoords: ee, handleSubmitEdit: X, handleCancelEdit: H, cellBounds: ue, borderStrokeWidth: x, borderStrokeFill: f, isInBounds: K, getCellEditor: _e, propsEditor: te, alignment: M, ...m }, "editor:" + u.current.uuid);
|
|
1799
1787
|
}, [o, E, A, We, ht, M, x, f]), startEdit: O((S) => {
|
|
1800
1788
|
N({ eventType: "start", startEvent: S });
|
|
1801
1789
|
}, []), submitEdit: O(() => {
|
|
@@ -1821,15 +1809,15 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1821
1809
|
const ee = u.nativeEvent.shiftKey, W = u.nativeEvent.ctrlKey || u.nativeEvent.metaKey;
|
|
1822
1810
|
if (d?.(u, C) === !1) return;
|
|
1823
1811
|
X?.(), _.current = !0;
|
|
1824
|
-
const A = t.current?.getViewFromClient(u.nativeEvent.clientX, u.nativeEvent.clientY),
|
|
1812
|
+
const A = t.current?.getViewFromClient(u.nativeEvent.clientX, u.nativeEvent.clientY), q = ((N, xe) => n === Nt ? { ...N, rowIndex: xe.rowStart } : { ...N, colIndex: xe.colStart })(C, A.getVisibleRangeCoords());
|
|
1825
1813
|
if (ee) oe(C);
|
|
1826
1814
|
else {
|
|
1827
1815
|
if (W) return ((N, xe = N, G) => {
|
|
1828
1816
|
ae.current = le(N), R.current = $(xe), E(ae.current, R.current, G);
|
|
1829
|
-
})(C, C,
|
|
1817
|
+
})(C, C, q), void (l && U(q, !0));
|
|
1830
1818
|
((N, xe = N, G) => {
|
|
1831
1819
|
ae.current = le(N), R.current = $(xe), f(ae.current, R.current, G);
|
|
1832
|
-
})(C, C,
|
|
1820
|
+
})(C, C, q), oe(C), l && U(q, !0);
|
|
1833
1821
|
}
|
|
1834
1822
|
}, onPointerMoveOrWait: Ct.throttle((u) => {
|
|
1835
1823
|
if (!_.current || !e?.current) return;
|
|
@@ -1845,7 +1833,7 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1845
1833
|
}, Ye = (e, t, n) => {
|
|
1846
1834
|
if (!e) return t;
|
|
1847
1835
|
let o = t;
|
|
1848
|
-
const r = n ===
|
|
1836
|
+
const r = n === Ke || n === lt;
|
|
1849
1837
|
for (; ; ) {
|
|
1850
1838
|
const i = e(o, !r);
|
|
1851
1839
|
if (i === 0) return o;
|
|
@@ -1875,7 +1863,7 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1875
1863
|
for (; !a && l > i; ) l = Ye(n, Math.max(--l, i), o), a = t({ rowIndex: l, colIndex: s });
|
|
1876
1864
|
return l;
|
|
1877
1865
|
}
|
|
1878
|
-
case
|
|
1866
|
+
case Ke: {
|
|
1879
1867
|
s = Ye(n, Math.min(s + 1, i), o);
|
|
1880
1868
|
let a = t({ rowIndex: l, colIndex: s });
|
|
1881
1869
|
for (; !a && s < i; ) s = Ye(n, Math.min(++s, i), o), a = t({ rowIndex: l, colIndex: s });
|
|
@@ -1905,7 +1893,7 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1905
1893
|
for (; a && l > i; ) l = Ye(n, Math.max(--l, i), o), a = t?.({ rowIndex: l, colIndex: s });
|
|
1906
1894
|
return t?.({ rowIndex: l, colIndex: s }) ? l : l + 1;
|
|
1907
1895
|
}
|
|
1908
|
-
case
|
|
1896
|
+
case Ke: {
|
|
1909
1897
|
s = Ye(n, Math.min(s + 1, i), o);
|
|
1910
1898
|
let a = t?.({ rowIndex: l, colIndex: s });
|
|
1911
1899
|
for (; a && s < i; ) s = Ye(n, Math.min(++s, i), o), a = t?.({ rowIndex: l, colIndex: s });
|
|
@@ -1920,10 +1908,10 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1920
1908
|
default:
|
|
1921
1909
|
return null;
|
|
1922
1910
|
}
|
|
1923
|
-
},
|
|
1911
|
+
}, ql = (e, t, n, o, r, i) => {
|
|
1924
1912
|
if (!t) return i;
|
|
1925
1913
|
let l, { rowIndex: s, colIndex: a } = e;
|
|
1926
|
-
o === lt ? l = { rowIndex: s + 1, colIndex: a } : o === it ? l = { rowIndex: s - 1, colIndex: a } : o ===
|
|
1914
|
+
o === lt ? l = { rowIndex: s + 1, colIndex: a } : o === it ? l = { rowIndex: s - 1, colIndex: a } : o === Ke ? l = { rowIndex: s, colIndex: a + 1 } : o === ot && (l = { rowIndex: s, colIndex: a - 1 });
|
|
1927
1915
|
const d = t(e), g = t(l);
|
|
1928
1916
|
var m, f;
|
|
1929
1917
|
return (f = g, !(m = d) && !f || !m && f || m && !f ? Nl : Ul)(e, t, n, o, !1, i) ?? i;
|
|
@@ -1931,13 +1919,13 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1931
1919
|
if (n - t >= r - o) return o;
|
|
1932
1920
|
let l = o;
|
|
1933
1921
|
return e === "nearest" && (o - t > 0 ? e = "start" : n - r > 0 && (e = "end")), e === "start" ? l = t : e === "end" ? l = n - (r - o) : e === "center" && (l = t + (n - t) / 2 - (r - o) / 2), Math.max(0, Math.min(l, i - (r - o)));
|
|
1934
|
-
}, Ar = (e, t, n, o) => (console.log("todo: implement convertToVisibleRanges"), e), Xo = (e, t =
|
|
1922
|
+
}, Ar = (e, t, n, o) => (console.log("todo: implement convertToVisibleRanges"), e), Xo = (e, t = Ke, n, o, r, i = null) => {
|
|
1935
1923
|
if (i && Z.isEqualSelectionCoords(i, e)) return e;
|
|
1936
1924
|
const l = e.ranges[e.rangeIndex];
|
|
1937
1925
|
if (!Z.isRangesIntersect({ rowStart: e.cell.rowIndex, colStart: e.cell.colIndex, rowEnd: e.cell.rowIndex, colEnd: e.cell.colIndex }, l)) return e;
|
|
1938
1926
|
let s = { ...e.cell }, a = e.rangeIndex;
|
|
1939
1927
|
switch (t) {
|
|
1940
|
-
case
|
|
1928
|
+
case Ke:
|
|
1941
1929
|
s.colIndex = Ye(r, s.colIndex + 1, t);
|
|
1942
1930
|
break;
|
|
1943
1931
|
case ot:
|
|
@@ -1960,14 +1948,14 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1960
1948
|
s = { colIndex: x.colEnd, rowIndex: x.rowEnd };
|
|
1961
1949
|
}
|
|
1962
1950
|
};
|
|
1963
|
-
if (t ===
|
|
1951
|
+
if (t === Ke && s.colIndex > l.colEnd && s.rowIndex === l.rowEnd) d(!0);
|
|
1964
1952
|
else if (t === ot && s.colIndex < l.colStart && s.rowIndex === l.rowStart) d(!1);
|
|
1965
1953
|
else if (t === lt && s.colIndex === l.colEnd && s.rowIndex > l.rowEnd) d(!0);
|
|
1966
1954
|
else if (t === it && s.colIndex === l.colStart && s.rowIndex < l.rowStart) d(!1);
|
|
1967
1955
|
else {
|
|
1968
1956
|
let f = s.rowIndex, x = s.colIndex;
|
|
1969
1957
|
switch (t) {
|
|
1970
|
-
case
|
|
1958
|
+
case Ke:
|
|
1971
1959
|
x > l.colEnd && (f = Ye(o, f + 1, t), x = l.colStart, f > l.rowEnd && (f = l.rowStart));
|
|
1972
1960
|
break;
|
|
1973
1961
|
case ot:
|
|
@@ -1986,10 +1974,10 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1986
1974
|
const f = Z.intersectRanges(g, l);
|
|
1987
1975
|
f && (g = f);
|
|
1988
1976
|
}
|
|
1989
|
-
let m = { rowStart: Ye(o, g.rowStart, lt), colStart: Ye(r, g.colStart,
|
|
1977
|
+
let m = { rowStart: Ye(o, g.rowStart, lt), colStart: Ye(r, g.colStart, Ke), rowEnd: Ye(o, g.rowEnd, it), colEnd: Ye(r, g.colEnd, ot) };
|
|
1990
1978
|
if (m.rowStart !== s.rowIndex || m.colStart !== s.colIndex) {
|
|
1991
1979
|
switch (t) {
|
|
1992
|
-
case
|
|
1980
|
+
case Ke:
|
|
1993
1981
|
e.ranges[a].colStart === m.colStart && e.ranges[a].colEnd === m.colEnd && (s.rowIndex = m.rowEnd), s.colIndex = m.colEnd;
|
|
1994
1982
|
break;
|
|
1995
1983
|
case ot:
|
|
@@ -2006,7 +1994,7 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
2006
1994
|
return { ranges: e.ranges, cell: s, rangeIndex: a };
|
|
2007
1995
|
}, $r = (e, t) => {
|
|
2008
1996
|
let n, o = 0, r = 0;
|
|
2009
|
-
return t.colStart < e.colStart ? (n = ot, o = e.colStart - t.colStart, r = t.colStart) : t.colEnd > e.colEnd ? (n =
|
|
1997
|
+
return t.colStart < e.colStart ? (n = ot, o = e.colStart - t.colStart, r = t.colStart) : t.colEnd > e.colEnd ? (n = Ke, o = t.colEnd - e.colEnd, r = t.colEnd) : t.rowStart < e.rowStart ? (n = it, o = e.rowStart - t.rowStart, r = t.rowStart) : t.rowEnd > e.rowEnd && (n = lt, o = t.rowEnd - e.rowEnd, r = t.rowEnd), { direction: n, amount: o, index: r };
|
|
2010
1998
|
}, go = (e, t = !1, n, o) => {
|
|
2011
1999
|
if (!n) return 0;
|
|
2012
2000
|
const r = !t, i = r ? 1 : -1;
|
|
@@ -2029,7 +2017,7 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
2029
2017
|
}, Fr = (e, t, n) => {
|
|
2030
2018
|
const o = e.getColOffset(t.colStart) + (n?.left ?? 0), r = e.getRowOffset(t.rowStart) + (n?.top ?? 0);
|
|
2031
2019
|
return { x: o, y: r, width: e.getColOffset(t.colEnd + 1) + (n?.right ?? 0) - (n?.left ?? 0) - o, height: e.getRowOffset(t.rowEnd + 1) + (n?.bottom ?? 0) - (n?.top ?? 0) - r };
|
|
2032
|
-
},
|
|
2020
|
+
}, Kl = (e, t, n) => !!n && !(e < n.x || e > n.x + n.width) && !(t < n.y || t > n.y + n.height), $o = (e, t = !0) => `M ${me.boundPixel(e.left)} ${me.boundPixel(e.top)} L ${me.boundPixel(e.right, !0)} ${me.boundPixel(e.top)} L ${me.boundPixel(e.right, !0)} ${me.boundPixel(e.bottom, !0)} L ${me.boundPixel(e.left)} ${me.boundPixel(e.bottom, !0)} L ${me.boundPixel(e.left)} ${me.boundPixel(e.top)} ${t ? "Z" : ""}`, jr = (e) => {
|
|
2033
2021
|
const { linePoints: t, bounds: n, pathProps: o, style: r, ...i } = e;
|
|
2034
2022
|
return Y("svg", { width: `${me.boundPixel(n.width, !0)}`, height: `${me.boundPixel(n.height, !0)}`, viewBox: `0 0 ${me.boundPixel(n.width, !0)} ${me.boundPixel(n.height, !0)}`, style: { position: "absolute", left: `${me.boundPixel(n.x)}px`, top: `${me.boundPixel(n.y)}px`, width: `${me.boundPixel(n.width, !0)}px`, height: `${me.boundPixel(n.height, !0)}px`, pointerEvents: "none", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top, width, height", willChange: "left, top, width, height, stroke-dashoffset", ...r }, ...i, children: Y("path", { d: `M ${me.boundPixel(t[0])} ${me.boundPixel(t[1])} L ${me.boundPixel(t[2])} ${me.boundPixel(t[3])}`, fill: "none", vectorEffect: "non-scaling-stroke", stroke: "black", ...o }) });
|
|
2035
2023
|
}, Yl = (e) => {
|
|
@@ -2117,7 +2105,7 @@ function Bo(e, t) {
|
|
|
2117
2105
|
if (typeof e == "function") return e(t);
|
|
2118
2106
|
e && (e.current = t);
|
|
2119
2107
|
}
|
|
2120
|
-
var Jl = parseInt(
|
|
2108
|
+
var Jl = parseInt(qr.split(".")[0], 10) >= 19 ? function(e) {
|
|
2121
2109
|
return (t) => {
|
|
2122
2110
|
const n = [];
|
|
2123
2111
|
for (const o of e) {
|
|
@@ -2154,44 +2142,44 @@ const Go = Dt(Ut((e, t) => {
|
|
|
2154
2142
|
case "r":
|
|
2155
2143
|
W = { colIndex: n.colStart, rowIndex: n.rowEnd };
|
|
2156
2144
|
}
|
|
2157
|
-
let
|
|
2145
|
+
let q = o.getRangeCoordsBounds(A ? { rowStart: A.rowIndex, colStart: A.colIndex, rowEnd: A.rowIndex, colEnd: A.colIndex } : n);
|
|
2158
2146
|
const N = o.getBounds(), xe = o.getViewportSize(), G = N.x, He = N.y, Ue = xe.width, We = xe.height;
|
|
2159
2147
|
switch (r) {
|
|
2160
2148
|
case "tl":
|
|
2161
2149
|
break;
|
|
2162
2150
|
case "br":
|
|
2163
|
-
|
|
2151
|
+
q.x = q.x + q.width, q.y = q.y + q.height;
|
|
2164
2152
|
break;
|
|
2165
2153
|
case "t":
|
|
2166
|
-
|
|
2154
|
+
q.x = Ue / 2 - G;
|
|
2167
2155
|
break;
|
|
2168
2156
|
case "b":
|
|
2169
|
-
|
|
2157
|
+
q.x = Ue / 2 - G, q.y = q.y + q.height;
|
|
2170
2158
|
break;
|
|
2171
2159
|
case "l":
|
|
2172
|
-
|
|
2160
|
+
q.y = We / 2 - He;
|
|
2173
2161
|
break;
|
|
2174
2162
|
case "r":
|
|
2175
|
-
|
|
2163
|
+
q.x = q.x + q.width, q.y = We / 2 - He;
|
|
2176
2164
|
}
|
|
2177
|
-
const ht = o.toClipBounds(
|
|
2178
|
-
return !ht || ht.width <= 0 || ht.height <= 0 ||
|
|
2165
|
+
const ht = o.toClipBounds(q, 0);
|
|
2166
|
+
return !ht || ht.width <= 0 || ht.height <= 0 || q.x < 0 || q.y < 0 || q.x > Ue || q.y > We ? { bounds: null, coordsAnchor: null, coordsPivot: null, key: null } : { bounds: q, coordsAnchor: null, coordsPivot: W, key: "touchSelect-" + o.getAnchor() + "-" + r };
|
|
2179
2167
|
}, [n, o, r]), oe = J(null), be = On(Ee(() => {
|
|
2180
2168
|
const W = (A) => r === "t" || r === "b" ? { ...A, colIndex: void 0 } : r === "l" || r === "r" ? { ...A, rowIndex: void 0 } : A;
|
|
2181
|
-
return { processTouch: !0, consumeTouch: !0, onPointerDown: (A,
|
|
2169
|
+
return { processTouch: !0, consumeTouch: !0, onPointerDown: (A, q) => {
|
|
2182
2170
|
const N = W(o.getCellCoordsFromClient(A.clientX, A.clientY));
|
|
2183
|
-
return oe.current = { coordsPivot: le }, R?.(r), m.onSelectionPointerDown(A,
|
|
2184
|
-
}, onPointerMoveOrWait: (A,
|
|
2171
|
+
return oe.current = { coordsPivot: le }, R?.(r), m.onSelectionPointerDown(A, q, o, N, le, !1, !0);
|
|
2172
|
+
}, onPointerMoveOrWait: (A, q, N) => {
|
|
2185
2173
|
const xe = W(o.getCellCoordsFromClient(A.clientX, A.clientY));
|
|
2186
|
-
return m.onSelectionPointerMoveOrWait(A,
|
|
2187
|
-
}, onPointerUp: (A,
|
|
2174
|
+
return m.onSelectionPointerMoveOrWait(A, q, N, o, xe, oe.current?.coordsPivot, !0, !0);
|
|
2175
|
+
}, onPointerUp: (A, q, N) => (oe.current = null, _?.(r), m.onPointerUp(A, q, N)) };
|
|
2188
2176
|
}, [m, n, o, r])), [U, { y: H, x: X }] = _i(), k = J(null), { getPortalContainer: u } = gi(), [C, ee] = Je(null);
|
|
2189
2177
|
return st(() => {
|
|
2190
2178
|
const W = k.current?.getBoundingClientRect();
|
|
2191
2179
|
if (!W || !L) return void ee(null);
|
|
2192
|
-
let A = 0,
|
|
2193
|
-
for (; N; ) A += N.scrollLeft,
|
|
2194
|
-
ee(
|
|
2180
|
+
let A = 0, q = 0, N = I;
|
|
2181
|
+
for (; N; ) A += N.scrollLeft, q += N.scrollTop, N = M && N === M.parentElement ? null : N.parentElement;
|
|
2182
|
+
ee(Kr(Y("div", { className: En("touch-select-handle", g), ref: t, style: { position: "absolute", left: A + (W?.x ?? 0) - (a + s) / 2, top: q + (W?.y ?? 0) - (a + s) / 2, width: a, height: a, borderWidth: `${s}px`, border: i, borderRadius: "50%", background: l, boxShadow: `0 0 0 1.5px ${l}`, cursor: "grab", pointerEvents: "all", opacity: E ? 0 : 1, transitionDuration: "160ms", transitionProperty: "opacity", ...d }, tabIndex: -1, onPointerDown: be, ...ae }), M ?? u(), $));
|
|
2195
2183
|
}, [H, X, L?.x, L?.y, L?.width, L?.height, g, E, l, a, s, i, I]), L ? Ht(wn, { children: [Y("div", { ref: Jl([U, k]), style: { position: "absolute", left: L.x, top: L.y, opacity: 0 } }), C] }) : null;
|
|
2196
2184
|
}));
|
|
2197
2185
|
Go.displayName = "TouchSelectHandle";
|
|
@@ -2202,8 +2190,8 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2202
2190
|
}, lo = (e, t, n) => {
|
|
2203
2191
|
const o = e.getVisibleRangeCoords(), r = e.getScrollOrientation();
|
|
2204
2192
|
!r.horizontal && (t.colIndex > o.colEnd || t.colIndex < o.colStart) && (t = { ...t, colIndex: t.colIndex > o.colEnd ? o.colEnd + 1 : o.colEnd - 1 }, e = n.current.getViewFromLocation(Xt)), !r.vertical && (t.rowIndex > o.rowEnd || t.rowIndex < o.rowStart) && (t = { ...t, rowIndex: t.rowIndex > o.rowEnd ? o.rowEnd + 1 : o.rowEnd - 1 }, e = n.current.getViewFromLocation(Xt)), e.scrollCellCoordsIntoView(t);
|
|
2205
|
-
}, es = () => !1, ms = ({ gridRef: e, commands: t, layout: n, selection: o, onSelectionChange: r, onSelectionDragStart: i, onSelectionDragEnd: l, selectionPolicy: s = "multiple", newSelectionMode: a = "clear", allowDeselectSelection: d = !0, onFillPreview: g, onFillCancel: m, onFillDone: f, onFill: x, disableFillDrag: E = !x, fillHandleBorderColor: I = "white", hiddenRowsAt: M, hiddenColumnsAt: ae, isContentfulCell: R, contentfulCellFinder: _ =
|
|
2206
|
-
const _e = O(() => ({ top: $?.top ?? 0, left: $?.left ?? 0, bottom: e.current?.rowCount - 1 || 0, right: e.current?.columnCount - 1 || 0 }), []), S = T(x, [x]), ue = T(g, [g]),
|
|
2193
|
+
}, es = () => !1, ms = ({ gridRef: e, commands: t, layout: n, selection: o, onSelectionChange: r, onSelectionDragStart: i, onSelectionDragEnd: l, selectionPolicy: s = "multiple", newSelectionMode: a = "clear", allowDeselectSelection: d = !0, onFillPreview: g, onFillCancel: m, onFillDone: f, onFill: x, disableFillDrag: E = !x, fillHandleBorderColor: I = "white", hiddenRowsAt: M, hiddenColumnsAt: ae, isContentfulCell: R, contentfulCellFinder: _ = ql, getDataCoords: L, alwaysScrollToActiveCoords: le = !1, selectionBounds: $, pointerDownInterceptor: oe, pointerMoveInterceptor: be, mergedRanges: U, canSelectionSpanMergedCells: H = es, onMoveDragStart: X, onMoveDragUpdate: k, onMoveDragEnd: u, onMoveDragDone: C, selectionRenderer: ee = Xl, disableMoveDrag: W = !u, getCellCoordsAsRangeCoords: A = Z.cellToRange, moveDragHitSize: q = 6, moveDragOutlineSize: N = 4, selectionBackgroundColor: xe = "rgba(16, 124, 65, 0.1)", selectionBorderColor: G = "rgb(33, 115, 70)", selectionRemoveBorderColor: He = "rgb(255, 0, 0)", selectionRemoveBackgroundColor: Ue = "rgba(250, 10, 10, 0.1)", disableTouchSelection: We = !1, touchSelectHandleProps: ht }) => {
|
|
2194
|
+
const _e = O(() => ({ top: $?.top ?? 0, left: $?.left ?? 0, bottom: e.current?.rowCount - 1 || 0, right: e.current?.columnCount - 1 || 0 }), []), S = T(x, [x]), ue = T(g, [g]), K = T(m, [m]), pe = T(f, [f]), te = T(R, [R]), Re = T(ee, [ee]), at = T((c, h = !1) => go(c, h, n.getRowOffset, h ? _e().bottom : _e().top), [n?.getRowOffset]), pt = T(M ?? at, [M]), zt = T((c, h = !1) => go(c, h, n.getColOffset, h ? _e().right : _e().left), [n?.getColOffset]), gt = T(ae ?? zt, [ae]), [Zt, Be] = Je(() => Yt(o)), z = Ee(() => Yt(Zt), [Zt]), ke = J(z), Qe = J(!0);
|
|
2207
2195
|
nn(Ct.throttle(() => {
|
|
2208
2196
|
Be((c) => {
|
|
2209
2197
|
Qe.current = !0;
|
|
@@ -2236,11 +2224,11 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2236
2224
|
const b = { ranges: y, rangeIndex: V, cell: w };
|
|
2237
2225
|
return Z.isEqualSelectionCoords(b, h) ? h : b;
|
|
2238
2226
|
});
|
|
2239
|
-
}, [A]), [an, Jt] = Je(null), [jt, dn] = Je(null), on = J(null), [ze,
|
|
2227
|
+
}, [A]), [an, Jt] = Je(null), [jt, dn] = Je(null), on = J(null), [ze, qt] = Je(null), vt = J(null), Vt = J(null), [Cn, un] = Je(null), Ne = J(null), Q = J(null), et = J(U);
|
|
2240
2228
|
st(() => {
|
|
2241
2229
|
et.current = U;
|
|
2242
2230
|
}, [U]);
|
|
2243
|
-
const
|
|
2231
|
+
const qe = T((c, h = { inline: "nearest", block: "nearest" }) => {
|
|
2244
2232
|
let { rowIndex: w, colIndex: p } = c;
|
|
2245
2233
|
w === void 0 && z?.cell && (w = z.cell.rowIndex), p === void 0 && z?.cell && (p = z.cell.colIndex), w !== void 0 && p !== void 0 && e.current?.scrollCellCoordsIntoView({ rowIndex: w, colIndex: p }, h);
|
|
2246
2234
|
}, [z]), dt = O((c) => {
|
|
@@ -2303,11 +2291,11 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2303
2291
|
if (b && Z.indexOfCoords(p, z.ranges) !== -1 && ne) {
|
|
2304
2292
|
vt.current = p;
|
|
2305
2293
|
const ie = Ie(p, p);
|
|
2306
|
-
return Vt.current = ie,
|
|
2294
|
+
return Vt.current = ie, qt(ie), De;
|
|
2307
2295
|
}
|
|
2308
2296
|
return Ae(p), De;
|
|
2309
2297
|
}
|
|
2310
|
-
le &&
|
|
2298
|
+
le && qe(p), de && z.ranges.length === 0 || tt(p);
|
|
2311
2299
|
}, onPointerMoveOrWait: Ct.throttle((c, h) => {
|
|
2312
2300
|
if (!e?.current || c.pointerType === "touch" || c.type === "touchmove" || !nt.current) return;
|
|
2313
2301
|
const w = nt.current.anchor;
|
|
@@ -2317,7 +2305,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2317
2305
|
const V = { rowStart: Math.min(y.rowIndex, vt.current.rowIndex), colStart: Math.min(y.colIndex, vt.current.colIndex), rowEnd: Math.max(y.rowIndex, vt.current.rowIndex), colEnd: Math.max(y.colIndex, vt.current.colIndex) }, b = { rowIndex: V.rowStart, colIndex: V.colStart }, he = { rowIndex: V.rowEnd, colIndex: V.colEnd };
|
|
2318
2306
|
if (dt(b) || dt(he)) return;
|
|
2319
2307
|
const ne = Ie(b, he);
|
|
2320
|
-
Vt.current = ne,
|
|
2308
|
+
Vt.current = ne, qt(ne);
|
|
2321
2309
|
} else rt(y);
|
|
2322
2310
|
kt.current = h, lo(p, y, e);
|
|
2323
2311
|
}
|
|
@@ -2339,7 +2327,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2339
2327
|
}
|
|
2340
2328
|
if (!vt.current) return;
|
|
2341
2329
|
const h = Vt.current;
|
|
2342
|
-
vt.current = null, Vt.current = null,
|
|
2330
|
+
vt.current = null, Vt.current = null, qt(null), Be((w) => {
|
|
2343
2331
|
if (Qe.current = !1, (w = Yt(w)).ranges.length === 0) return w;
|
|
2344
2332
|
let p = [], y = -1, V = w.cell;
|
|
2345
2333
|
for (let he = 0; he < w.ranges.length; he++) {
|
|
@@ -2376,11 +2364,11 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2376
2364
|
if (B && Z.indexOfCoords(re, z.ranges) !== -1 && ie) {
|
|
2377
2365
|
vt.current = re;
|
|
2378
2366
|
const Te = Ie(re, re);
|
|
2379
|
-
return Vt.current = Te,
|
|
2367
|
+
return Vt.current = Te, qt(Te), Pe;
|
|
2380
2368
|
}
|
|
2381
2369
|
return Ae(re), Pe;
|
|
2382
2370
|
}
|
|
2383
|
-
V &&
|
|
2371
|
+
V && qe(re), Rt && z.ranges.length === 0 || tt(re);
|
|
2384
2372
|
}, onSelectionPointerMoveOrWait: (c, h, w, p, y, V = z.cell, b = !0, he = !1) => {
|
|
2385
2373
|
if (!e?.current || (c.stopPropagation(), c.preventDefault(), c.stopImmediatePropagation(), !nt.current)) return;
|
|
2386
2374
|
const ne = nt.current.anchor;
|
|
@@ -2390,7 +2378,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2390
2378
|
const De = { rowStart: Math.min(we.rowIndex, vt.current.rowIndex), colStart: Math.min(we.colIndex, vt.current.colIndex), rowEnd: Math.max(we.rowIndex, vt.current.rowIndex), colEnd: Math.max(we.colIndex, vt.current.colIndex) }, de = { rowIndex: De.rowStart, colIndex: De.colStart }, ie = { rowIndex: De.rowEnd, colIndex: De.colEnd };
|
|
2391
2379
|
if (dt(de) || dt(ie)) return;
|
|
2392
2380
|
const _t = Ie(de, ie);
|
|
2393
|
-
Vt.current = _t,
|
|
2381
|
+
Vt.current = _t, qt(_t);
|
|
2394
2382
|
} else rt(we, V, he);
|
|
2395
2383
|
b && lo(re, we, e);
|
|
2396
2384
|
}
|
|
@@ -2403,7 +2391,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2403
2391
|
}
|
|
2404
2392
|
if (!vt.current) return;
|
|
2405
2393
|
const h = Vt.current;
|
|
2406
|
-
vt.current = null, Vt.current = null,
|
|
2394
|
+
vt.current = null, Vt.current = null, qt(null), Be((w) => {
|
|
2407
2395
|
if (Qe.current = !1, (w = Yt(w)).ranges.length === 0) return w;
|
|
2408
2396
|
let p = [], y = -1, V = w.cell;
|
|
2409
2397
|
for (let he = 0; he < w.ranges.length; he++) {
|
|
@@ -2435,7 +2423,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2435
2423
|
case ot:
|
|
2436
2424
|
V = { rowIndex: B.rowEnd, colIndex: Pe.colIndex === B.colStart ? B.colEnd : B.colStart }, y = { rowIndex: B.rowStart, colIndex: Pe.colIndex === B.colStart ? B.colStart : B.colEnd };
|
|
2437
2425
|
break;
|
|
2438
|
-
case
|
|
2426
|
+
case Ke:
|
|
2439
2427
|
V = { rowIndex: B.rowEnd, colIndex: Pe.colIndex === B.colEnd ? B.colStart : B.colEnd }, y = { rowIndex: B.rowStart, colIndex: Pe.colIndex === B.colEnd ? B.colEnd : B.colStart };
|
|
2440
2428
|
}
|
|
2441
2429
|
}
|
|
@@ -2448,7 +2436,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2448
2436
|
Q.current.colIndex >= b.colStart && Q.current.colIndex <= b.colEnd && (ne = Q.current.colIndex);
|
|
2449
2437
|
break;
|
|
2450
2438
|
case ot:
|
|
2451
|
-
case
|
|
2439
|
+
case Ke:
|
|
2452
2440
|
Q.current.rowIndex >= b.rowStart && Q.current.rowIndex <= b.rowEnd && (he = Q.current.rowIndex);
|
|
2453
2441
|
}
|
|
2454
2442
|
if (!p) {
|
|
@@ -2462,7 +2450,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2462
2450
|
case ot:
|
|
2463
2451
|
ne = Ye(gt, Math.max(b.colStart - 1, re.left), c);
|
|
2464
2452
|
break;
|
|
2465
|
-
case
|
|
2453
|
+
case Ke:
|
|
2466
2454
|
ne = Ye(gt, Math.min(b.colEnd + 1, re.right), c);
|
|
2467
2455
|
}
|
|
2468
2456
|
if (w) switch (c) {
|
|
@@ -2475,7 +2463,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2475
2463
|
case ot:
|
|
2476
2464
|
ne = _({ ...V, rowIndex: z.cell.rowIndex }, te, gt, c, !1, Math.max(re.left, gt(re.left, !1)));
|
|
2477
2465
|
break;
|
|
2478
|
-
case
|
|
2466
|
+
case Ke:
|
|
2479
2467
|
ne = _({ ...V, rowIndex: z.cell.rowIndex }, te, gt, c, !1, Math.min(re.right, re.right - gt(re.right, !0)));
|
|
2480
2468
|
}
|
|
2481
2469
|
}
|
|
@@ -2492,7 +2480,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2492
2480
|
case ot:
|
|
2493
2481
|
B = n.getColOffset(ne + 1), ne = Math.max(re.left, n.getColIndex(B - p)), we = { left: n.getColOffset(ne + 1) - (B - e.current.getScrollPosition().left) };
|
|
2494
2482
|
break;
|
|
2495
|
-
case
|
|
2483
|
+
case Ke:
|
|
2496
2484
|
B = n.getColOffset(ne), ne = Math.min(re.right, n.getColIndex(B + p)), we = { left: n.getColOffset(ne) - (B - e.current.getScrollPosition().left) };
|
|
2497
2485
|
}
|
|
2498
2486
|
}
|
|
@@ -2503,9 +2491,9 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2503
2491
|
else {
|
|
2504
2492
|
if (h && Ne.current) {
|
|
2505
2493
|
const B = _e();
|
|
2506
|
-
if (c ===
|
|
2494
|
+
if (c === Ke && Ne.current.colIndex === B.left || c === ot && Ne.current.colIndex === B.right || c === it && Ne.current.rowIndex === B.bottom || c === lt && Ne.current.rowIndex === B.top) return;
|
|
2507
2495
|
}
|
|
2508
|
-
c === ot || c ===
|
|
2496
|
+
c === ot || c === Ke ? qe({ colIndex: De.colIndex }) : c !== it && c !== lt || qe({ rowIndex: De.rowIndex });
|
|
2509
2497
|
}
|
|
2510
2498
|
}, [z, A]), ln = T((c) => {
|
|
2511
2499
|
if (!e.current) return;
|
|
@@ -2517,7 +2505,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2517
2505
|
Qe.current = !1, p = Yt(p);
|
|
2518
2506
|
const y = { ...p, cell: w.cell, rangeIndex: w.rangeIndex };
|
|
2519
2507
|
return Z.isEqualSelectionCoords(y, p) ? p : y;
|
|
2520
|
-
}), w.cell &&
|
|
2508
|
+
}), w.cell && qe(w.cell);
|
|
2521
2509
|
}, [z, A]), vo = O(() => {
|
|
2522
2510
|
const c = _e();
|
|
2523
2511
|
rt({ rowIndex: c.top }, { rowIndex: c.bottom });
|
|
@@ -2525,43 +2513,43 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2525
2513
|
const c = _e();
|
|
2526
2514
|
rt({ colIndex: c.left }, { colIndex: c.right });
|
|
2527
2515
|
}, []), xn = T(() => {
|
|
2528
|
-
z.cell && e?.current &&
|
|
2529
|
-
}, [z.cell]),
|
|
2516
|
+
z.cell && e?.current && qe(z.cell);
|
|
2517
|
+
}, [z.cell]), Kn = O((c = !1) => {
|
|
2530
2518
|
const h = { rowIndex: _e().top };
|
|
2531
|
-
c ? rt(h) : tt(h),
|
|
2519
|
+
c ? rt(h) : tt(h), qe(h);
|
|
2532
2520
|
}, []), Yn = O((c = !1) => {
|
|
2533
2521
|
const h = { rowIndex: _e().bottom };
|
|
2534
|
-
c ? rt(h) : tt(h),
|
|
2522
|
+
c ? rt(h) : tt(h), qe(h);
|
|
2535
2523
|
}, []), Dn = O((c = !1) => {
|
|
2536
2524
|
const h = { colIndex: _e().left };
|
|
2537
|
-
c ? rt(h) : tt(h),
|
|
2525
|
+
c ? rt(h) : tt(h), qe(h);
|
|
2538
2526
|
}, []), Mn = O((c = !1) => {
|
|
2539
2527
|
const h = _e(), w = { rowIndex: h.top, colIndex: h.left };
|
|
2540
|
-
c ? rt(w) : tt(w),
|
|
2528
|
+
c ? rt(w) : tt(w), qe(w);
|
|
2541
2529
|
}, []), zn = O((c = !1) => {
|
|
2542
2530
|
const h = _e(), w = { colIndex: L?.()?.colEnd ?? h.right };
|
|
2543
|
-
c ? rt(w) : tt(w),
|
|
2531
|
+
c ? rt(w) : tt(w), qe(w);
|
|
2544
2532
|
}, [L]), vn = O((c = !1) => {
|
|
2545
2533
|
const h = _e(), w = { rowIndex: L?.()?.rowEnd ?? h.bottom, colIndex: L?.()?.colEnd ?? h.right };
|
|
2546
|
-
c ? rt(w) : tt(w),
|
|
2534
|
+
c ? rt(w) : tt(w), qe(w);
|
|
2547
2535
|
}, [L]), An = T((c) => {
|
|
2548
2536
|
if (!e.current || z.ranges.length <= 1) return;
|
|
2549
2537
|
const h = c === ot || c === it;
|
|
2550
2538
|
let w = z.rangeIndex + (h ? -1 : 1);
|
|
2551
2539
|
w < 0 ? w = z.ranges.length - 1 : w > z.ranges.length - 1 && (w = 0);
|
|
2552
|
-
const p = z.ranges[w], y = Xo({ cell: { rowIndex: p.rowEnd, colIndex: p.colEnd }, rangeIndex: 0, ranges: [p] },
|
|
2540
|
+
const p = z.ranges[w], y = Xo({ cell: { rowIndex: p.rowEnd, colIndex: p.colEnd }, rangeIndex: 0, ranges: [p] }, Ke, A, pt, gt);
|
|
2553
2541
|
Be((V) => {
|
|
2554
2542
|
Qe.current = !1, V = Yt(V);
|
|
2555
2543
|
const b = { ...V, cell: y.cell, rangeIndex: w };
|
|
2556
2544
|
return Z.isEqualSelectionCoords(b, V) ? V : b;
|
|
2557
|
-
}), y.cell &&
|
|
2545
|
+
}), y.cell && qe(y.cell);
|
|
2558
2546
|
}, [z, A]), bo = T(() => {
|
|
2559
2547
|
const c = Ar(z);
|
|
2560
2548
|
Be((h) => {
|
|
2561
2549
|
Qe.current = !1, h = Yt(h);
|
|
2562
2550
|
const w = { ...h, visibleSelection: c };
|
|
2563
2551
|
return Z.isEqualSelectionCoords(w, h) ? h : w;
|
|
2564
|
-
}), c.cell &&
|
|
2552
|
+
}), c.cell && qe(c.cell);
|
|
2565
2553
|
}, [z, A]), So = T(() => {
|
|
2566
2554
|
if (!e.current || z.ranges.length === 0) return;
|
|
2567
2555
|
const c = z.cell, h = z.ranges[z.rangeIndex], w = Ar({ cell: c, rangeIndex: 0, ranges: [h] }), p = w.ranges[w.rangeIndex];
|
|
@@ -2570,19 +2558,19 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2570
2558
|
V = Yt(V);
|
|
2571
2559
|
const b = { ...V, cell: y };
|
|
2572
2560
|
return Z.isEqualSelectionCoords(b, V) ? V : b;
|
|
2573
|
-
}), y &&
|
|
2561
|
+
}), y && qe(y);
|
|
2574
2562
|
}, [z, A]), Xn = O((c = !1) => {
|
|
2575
2563
|
ft(lt, c, !1, e.current.getDimensions().containerHeight);
|
|
2576
2564
|
}, []), Qt = O((c = !1) => {
|
|
2577
2565
|
ft(it, c, !1, e.current.getDimensions().containerHeight);
|
|
2578
2566
|
}, []), Gn = O((c = !1) => {
|
|
2579
|
-
ft(
|
|
2567
|
+
ft(Ke, c, !1, e.current.getDimensions().containerWidth);
|
|
2580
2568
|
}, []), $n = O((c = !1) => {
|
|
2581
2569
|
ft(ot, c, !1, e.current.getDimensions().containerWidth);
|
|
2582
2570
|
}, []), Zn = O(() => {
|
|
2583
2571
|
ln(ot);
|
|
2584
2572
|
}, []), Jn = O(() => {
|
|
2585
|
-
ln(
|
|
2573
|
+
ln(Ke);
|
|
2586
2574
|
}, []), Eo = O(() => {
|
|
2587
2575
|
ln(it);
|
|
2588
2576
|
}, []), _o = O(() => {
|
|
@@ -2590,7 +2578,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2590
2578
|
}, []), Bn = O(() => {
|
|
2591
2579
|
An(ot);
|
|
2592
2580
|
}, []), Io = O(() => {
|
|
2593
|
-
An(
|
|
2581
|
+
An(Ke);
|
|
2594
2582
|
}, []), Co = O(() => {
|
|
2595
2583
|
So();
|
|
2596
2584
|
}, []), Qn = O(() => {
|
|
@@ -2602,13 +2590,13 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2602
2590
|
}, []), D = O(() => {
|
|
2603
2591
|
ft(ot, !0, !0);
|
|
2604
2592
|
}, []), F = O(() => {
|
|
2605
|
-
ft(
|
|
2593
|
+
ft(Ke, !1, !1);
|
|
2606
2594
|
}, []), j = O(() => {
|
|
2607
|
-
ft(
|
|
2595
|
+
ft(Ke, !0, !1);
|
|
2608
2596
|
}, []), fe = O(() => {
|
|
2609
|
-
ft(
|
|
2597
|
+
ft(Ke, !1, !0);
|
|
2610
2598
|
}, []), se = O(() => {
|
|
2611
|
-
ft(
|
|
2599
|
+
ft(Ke, !0, !0);
|
|
2612
2600
|
}, []), ve = O(() => {
|
|
2613
2601
|
ft(it, !1, !1);
|
|
2614
2602
|
}, []), ye = O(() => {
|
|
@@ -2637,7 +2625,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2637
2625
|
return !1;
|
|
2638
2626
|
})(z.ranges, c.top, c.left, c.bottom, c.right);
|
|
2639
2627
|
}, [$, z.ranges]), yt = O((c, h = !0) => {
|
|
2640
|
-
Ne.current = c, wt(c), h && c && e?.current &&
|
|
2628
|
+
Ne.current = c, wt(c), h && c && e?.current && qe(c);
|
|
2641
2629
|
}, []), ge = T((c = !0) => {
|
|
2642
2630
|
const h = on.current;
|
|
2643
2631
|
if (!ke.current?.cell) return;
|
|
@@ -2670,8 +2658,8 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2670
2658
|
if (!b) return;
|
|
2671
2659
|
const he = V.length > 0, ne = he ? V[V.length - 1] : A(ke.current.cell);
|
|
2672
2660
|
if (!b) return;
|
|
2673
|
-
const re = b.rowStart < ne.rowStart ? it : b.rowEnd > ne.rowEnd ? lt : b.colEnd > ne.colEnd ?
|
|
2674
|
-
re === ot && (b = { ...ne, colStart: Math.max(we.left, b.colStart) }), re === it && (b = { ...ne, rowStart: Math.max(we.top, b.rowStart) }), re ===
|
|
2661
|
+
const re = b.rowStart < ne.rowStart ? it : b.rowEnd > ne.rowEnd ? lt : b.colEnd > ne.colEnd ? Ke : ot, we = _e();
|
|
2662
|
+
re === ot && (b = { ...ne, colStart: Math.max(we.left, b.colStart) }), re === it && (b = { ...ne, rowStart: Math.max(we.top, b.rowStart) }), re === Ke && (b = { ...ne, colEnd: Math.min(we.right, b.colEnd) }), re === lt && (b = { ...ne, rowEnd: Math.min(we.bottom, b.rowEnd) });
|
|
2675
2663
|
const De = $r(ne, b);
|
|
2676
2664
|
if (!H?.(ne)) {
|
|
2677
2665
|
let de;
|
|
@@ -2681,7 +2669,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2681
2669
|
if (Rt === ot) {
|
|
2682
2670
|
const St = ie.colEnd + 1 - ie.colStart;
|
|
2683
2671
|
Me.colStart = ie.colStart - Math.ceil(Te / St) * St, Me.colStart < Pe.left && (Me.colStart = Me.colStart + Math.ceil((Pe.left - Me.colStart) / St) * St);
|
|
2684
|
-
} else if (Rt ===
|
|
2672
|
+
} else if (Rt === Ke) {
|
|
2685
2673
|
const St = ie.colEnd + 1 - ie.colStart;
|
|
2686
2674
|
Me.colEnd = ie.colEnd + Math.ceil(Te / St) * St, Me.colEnd > Pe.right && (Me.colEnd = Me.colEnd - Math.ceil((Pe.right - Me.colEnd) / St) * St);
|
|
2687
2675
|
} else if (Rt === it) {
|
|
@@ -2697,7 +2685,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2697
2685
|
if (he && Z.isRangeWithinRange(b, ne) && (b = null), !Z.isEqualRanges(b, on.current)) {
|
|
2698
2686
|
if (dn(b), on.current = b, !b) {
|
|
2699
2687
|
try {
|
|
2700
|
-
|
|
2688
|
+
K?.();
|
|
2701
2689
|
} catch {
|
|
2702
2690
|
}
|
|
2703
2691
|
return void pe?.();
|
|
@@ -2739,7 +2727,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2739
2727
|
} }), [Ce]), Oe = On(ct), Et = Ee(() => ({ onPointerDown: Oe }), [Oe]), bt = J(null), $t = Ee(() => {
|
|
2740
2728
|
const c = Z.isEqualSelectionCoords(z, bt.current) ? bt.current : z;
|
|
2741
2729
|
return bt.current = c, c;
|
|
2742
|
-
}, [z]),
|
|
2730
|
+
}, [z]), Kt = O((c) => {
|
|
2743
2731
|
let h = null, w = "br";
|
|
2744
2732
|
const p = [], y = { stroke: I, fill: xe, strokeWidth: 0.5 }, V = (de, ie, _t) => {
|
|
2745
2733
|
const B = c.toClipBounds(c.getRangeCoordsBounds(de), tn);
|
|
@@ -2766,7 +2754,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2766
2754
|
if (b.ranges.length === 1) {
|
|
2767
2755
|
const Te = c.toClipBounds(c.getRangeCoordsBounds(ie), tn);
|
|
2768
2756
|
if (Te) {
|
|
2769
|
-
W || p.push(Re({ range: ie, key: `move-selection-hit-box-${de}`, x: Te.width > 1 ? Te.x : Te.x - (
|
|
2757
|
+
W || p.push(Re({ range: ie, key: `move-selection-hit-box-${de}`, x: Te.width > 1 ? Te.x : Te.x - (q / 2 + 1), y: Te.height > 1 ? Te.y : Te.y - (q / 2 + 1), width: Math.max(Te.width + 2, 1), height: Math.max(Te.height + 2, 1), stroke: "transparent", style: { boxShadow: "none" }, pathProps: { cursor: Ce ? void 0 : "move", pointerEvents: "stroke" }, strokeWidth: q, ...Et }));
|
|
2770
2758
|
const Me = B;
|
|
2771
2759
|
p.push(Re({ range: ie, key: `selection-single-${de}`, x: Te.x - Me / 2, y: Te.y - Me / 2, width: Math.max(Te.width + Me / 2, 1), height: Math.max(Te.height + Me / 2, 1), stroke: G, strokeWidth: Me }));
|
|
2772
2760
|
}
|
|
@@ -2816,31 +2804,31 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2816
2804
|
return Y("div", { children: De }, "selection");
|
|
2817
2805
|
}, [$t, ze, E, jt, W, Ce, _e, I, G, xe, He, Ue, We, ht, Cn]), Ot = Ee(() => {
|
|
2818
2806
|
const c = () => e.current;
|
|
2819
|
-
return [new Se("moveToPageDown", c, { label: "Page Down", description: "Shift viewport down one page.", shortcut: [{ key: "PageDown" }] }, () => Xn(!1)), new Se("selectToPageDown", c, { label: "Select To Page Down", description: "Shift viewport and select down one page.", shortcut: [{ key: "PageDown", modifiers: [It] }] }, () => Xn(!0)), new Se("moveToPageRight", c, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [yn] }] }, () => Gn(!1)), new Se("selectToPageRight", c, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [yn, It] }] }, () => Gn(!0)), new Se("moveToPageUp", c, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp" }] }, () => Qt(!1)), new Se("selectToPageUp", c, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp", modifiers: [It] }] }, () => Qt(!0)), new Se("moveToPageLeft", c, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [yn] }] }, () => $n(!1)), new Se("selectToPageLeft", c, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [yn, It] }] }, () => $n(!0)), new Se("selectColumn", c, { label: "Select Column", description: "Select the columns for the selected cells.", shortcut: { key: "Space", modifiers: [Lt] } }, vo), new Se("selectRow", c, { label: "Select Row", description: "Select the rows for the selected cells.", shortcut: { key: "Space", modifiers: [It] } }, yo), new Se("selectToColumnStart", c, { label: "Select To Column Start", description: "Select the columns to the beginning of the sheet." }, () =>
|
|
2807
|
+
return [new Se("moveToPageDown", c, { label: "Page Down", description: "Shift viewport down one page.", shortcut: [{ key: "PageDown" }] }, () => Xn(!1)), new Se("selectToPageDown", c, { label: "Select To Page Down", description: "Shift viewport and select down one page.", shortcut: [{ key: "PageDown", modifiers: [It] }] }, () => Xn(!0)), new Se("moveToPageRight", c, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [yn] }] }, () => Gn(!1)), new Se("selectToPageRight", c, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [yn, It] }] }, () => Gn(!0)), new Se("moveToPageUp", c, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp" }] }, () => Qt(!1)), new Se("selectToPageUp", c, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp", modifiers: [It] }] }, () => Qt(!0)), new Se("moveToPageLeft", c, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [yn] }] }, () => $n(!1)), new Se("selectToPageLeft", c, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [yn, It] }] }, () => $n(!0)), new Se("selectColumn", c, { label: "Select Column", description: "Select the columns for the selected cells.", shortcut: { key: "Space", modifiers: [Lt] } }, vo), new Se("selectRow", c, { label: "Select Row", description: "Select the rows for the selected cells.", shortcut: { key: "Space", modifiers: [It] } }, yo), new Se("selectToColumnStart", c, { label: "Select To Column Start", description: "Select the columns to the beginning of the sheet." }, () => Kn(!0)), new Se("selectToColumnEnd", c, { label: "Select To Column End", description: "Select the columns to the end of the sheet." }, () => Yn(!0)), new Se("moveToRowStart", c, { label: "Move to Row Home", description: "Move to the beginning of the row.", shortcut: [{ key: "Home" }] }, () => Dn(!1)), new Se("selectToRowStart", c, { label: "Select to Row Home", description: "Select to the beginning of the row.", shortcut: [{ key: "Home", modifiers: [It] }] }, () => Dn(!0)), new Se("moveToSheetStart", c, { label: "Move to Sheet Home", description: "Move to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [Lt] }] }, () => Mn(!1)), new Se("selectToSheetStart", c, { label: "Select to Sheet Home", description: "Select to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [Lt, It] }] }, () => Mn(!0)), new Se("moveToRowEnd", c, { label: "Move to Row End", description: "Move to the end of the row.", shortcut: [{ key: "End" }] }, () => zn(!1)), new Se("selectToRowEnd", c, { label: "Select to Row End", description: "Select to the end of the row.", shortcut: [{ key: "End", modifiers: [It] }] }, () => zn(!0)), new Se("moveToSheetEnd", c, { label: "Move to Sheet End", description: "Move to the end of the sheet.", shortcut: [{ key: "End", modifiers: [Lt] }] }, () => vn(!1)), new Se("selectToSheetEnd", c, { label: "Select to Sheet End", description: "Select to the end of the sheet.", shortcut: [{ key: "End", modifiers: [Lt, It] }] }, () => vn(!0)), new Se("scrollToActiveCoords", c, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell.", shortcut: { key: "Backspace", modifiers: [Lt] } }, xn), new Se("scrollToActiveCoordsClearSelection", c, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell and clear selection.", shortcut: { key: "Backspace", modifiers: [It] } }, () => {
|
|
2820
2808
|
rn(), yt(z.cell, !0);
|
|
2821
2809
|
}), new Se("traverseSelectionRight", c, { label: "Traverse Right", description: "Traverse the selection moving rightward.", shortcut: { key: "Tab" } }, Jn), new Se("traverseSelectionLeft", c, { label: "Traverse Left", description: "Traverse the selection moving leftward.", shortcut: { key: "Tab", modifiers: [It] } }, Zn), new Se("traverseSelectionDown", c, { label: "Traverse Down", description: "Traverse the selection moving downward.", shortcut: [{ key: "Enter" }, { key: "NumpadEnter" }] }, _o), new Se("traverseSelectionUp", c, { label: "Traverse Up", description: "Traverse the selection moving upward.", shortcut: [{ key: "Enter", modifiers: [It] }, { key: "NumpadEnter", modifiers: [It] }] }, Eo), new Se("moveLeft", c, { label: "Move Left", description: "Move active cell to the left.", shortcut: [{ key: "ArrowLeft" }] }, Qn), new Se("selectLeft", c, { label: "Select Left", description: "Extend selection left.", shortcut: [{ key: "ArrowLeft", modifiers: [It] }] }, v), new Se("moveContentfulLeft", c, { label: "Move Left Contentful", description: "Move left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [Lt] }] }, P), new Se("selectContentfulLeft", c, { label: "Select Left Contentful", description: "Extend selection left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [Lt, It] }] }, D), new Se("moveRight", c, { label: "Move Right", description: "Move active cell to the right.", shortcut: [{ key: "ArrowRight" }] }, F), new Se("selectRight", c, { label: "Select Right", description: "Extend selection right.", shortcut: [{ key: "ArrowRight", modifiers: [It] }] }, j), new Se("moveContentfulRight", c, { label: "Move Right Contentful", description: "Move right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [Lt] }] }, fe), new Se("selectContentfulRight", c, { label: "Select Right Contentful", description: "Extend selection right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [Lt, It] }] }, se), new Se("moveUp", c, { label: "Move Up", description: "Move active cell to the up.", shortcut: [{ key: "ArrowUp" }] }, ve), new Se("selectUp", c, { label: "Select Up", description: "Extend selection up.", shortcut: [{ key: "ArrowUp", modifiers: [It] }] }, ye), new Se("moveContentfulUp", c, { label: "Move Up Contentful", description: "Move up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [Lt] }] }, ce), new Se("selectContentfulUp", c, { label: "Select Up Contentful", description: "Extend selection up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [Lt, It] }] }, Ve), new Se("moveDown", c, { label: "Move Down", description: "Move active cell to the down.", shortcut: [{ key: "ArrowDown" }] }, ut), new Se("selectDown", c, { label: "Select Down", description: "Extend selection down.", shortcut: [{ key: "ArrowDown", modifiers: [It] }] }, Fe), new Se("moveContentfulDown", c, { label: "Move Down Contentful", description: "Move down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [Lt] }] }, je), new Se("selectContentfulDown", c, { label: "Select Down Contentful", description: "Extend selection down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [Lt, It] }] }, mt), new Se("selectVisible", c, { label: "Select Visible", description: "Select visible cells only.", shortcut: { key: ";", modifiers: [yn] } }, bo), new Se("traverseSelectionPreviousRange", c, { label: "Traverse Previous Range", description: "Traverse the selection to the previous range.", shortcut: { key: "ArrowLeft", modifiers: [Lt, yn] } }, Bn), new Se("traverseSelectionNextRange", c, { label: "Traverse Next Range", description: "Traverse the selection to the next range.", shortcut: { key: "ArrowRight", modifiers: [Lt, yn] } }, Io), new Se("traverseSelectionCorners", c, { label: "Traverse Corners", description: "Traverse the selection through the corners of the selected range.", shortcut: { key: ".", modifiers: [Lt] } }, Co)];
|
|
2822
2810
|
}, []);
|
|
2823
2811
|
return Ee(() => {
|
|
2824
2812
|
t?.addCommands(Ot, !0);
|
|
2825
|
-
}, [t]), { selection: $t, setSelectionCell: yt, setSelectionRanges: Xe, overlay:
|
|
2813
|
+
}, [t]), { selection: $t, setSelectionCell: yt, setSelectionRanges: Xe, overlay: Kt, cursor: an, onPointerDown: mo, clearLastSelection: Ge, newSelection: tt, modifySelection: rt, appendSelection: Ae, clearSelections: rn, isEntire: Pt, navigate: ft, navigateSelection: ln };
|
|
2826
2814
|
};
|
|
2827
2815
|
function ao(e, t) {
|
|
2828
2816
|
if (!e) throw new Error("Invariant failed");
|
|
2829
2817
|
}
|
|
2830
|
-
const Wr = { "sheetxl-grid": "_sheetxl-
|
|
2831
|
-
const { width: n, height: o, rowCount: r = 1, columnCount: i = 1, defaultRowHeight: l, defaultColumnWidth: s, getRowHeight: a, getColumnWidth: d, layout: g, onViewportScroll: m, onImmediateScroll: f, showGridLines: x = !0, gridLineColor: E = "rgb(224, 224, 224)", gridLineRowsProps: I, gridLineColumnsProps: M, clipCells: ae = !0, cursor: R, freezeLeft: _ = 0, freezeTop: L = 0, freezeLeftProps: le, freezeTopProps: $, cellRenderer: oe, onViewportChange: be, onFirstRender: U, overlayRenderer: H, overlayProps: X, overlays: k, overlaysProps: u, allowOverlaysOverflow: C = !1, stageProps: ee, stageWrapper: W = null, hiddenRowsAt: A, hiddenColumnsAt:
|
|
2818
|
+
const Wr = { "sheetxl-grid": "_sheetxl-grid_11irg_13" }, ts = Object.freeze({ top: 0, left: 0 }), ns = Object.freeze({ bottom: -4, right: -4 }), os = Object.freeze({ horizontal: !0, vertical: !0 }), Hr = [uo, Hn, Nn, Xt], xs = 150, sn = 3e3, Fo = {}, Ci = Dt(Ut((e, t) => {
|
|
2819
|
+
const { width: n, height: o, rowCount: r = 1, columnCount: i = 1, defaultRowHeight: l, defaultColumnWidth: s, getRowHeight: a, getColumnWidth: d, layout: g, onViewportScroll: m, onImmediateScroll: f, showGridLines: x = !0, gridLineColor: E = "rgb(224, 224, 224)", gridLineRowsProps: I, gridLineColumnsProps: M, clipCells: ae = !0, cursor: R, freezeLeft: _ = 0, freezeTop: L = 0, freezeLeftProps: le, freezeTopProps: $, cellRenderer: oe, onViewportChange: be, onFirstRender: U, overlayRenderer: H, overlayProps: X, overlays: k, overlaysProps: u, allowOverlaysOverflow: C = !1, stageProps: ee, stageWrapper: W = null, hiddenRowsAt: A, hiddenColumnsAt: q, hiddenCellAt: N, getVisibleCells: xe, zoom: G = 1, enableMouseWheel: He = !0, onWheelScroll: Ue, getCellCoordsAsRangeCoords: We = Z.cellToRange, scrollPoint: ht = ts, style: _e = {}, ...S } = e;
|
|
2832
2820
|
ao(oe), ao(!e?.children);
|
|
2833
|
-
const ue = T(f, [f]),
|
|
2821
|
+
const ue = T(f, [f]), K = T(be, [be]), pe = T(m, [m]), te = T(Ue, [Ue]), Re = T(U, [U]), at = J(null), pt = J(null), zt = J(null), [gt, Zt] = Qo((v) => v + 1, 0), [Be, z] = Je({ left: ht?.left ?? 0, top: ht?.top ?? 0, horizontalScrollDirection: null, verticalScrollDirection: null }), ke = J(null), Qe = J(Be), { top: Xe, left: wt, verticalScrollDirection: an, horizontalScrollDirection: Jt } = Be, jt = J(!1), dn = Fl({ rowCount: r, columnCount: i, defaultRowHeight: l, defaultColumnWidth: s, getRowHeight: a, getColumnWidth: d }), on = J(null), ze = Ee(() => {
|
|
2834
2822
|
const v = g || dn;
|
|
2835
2823
|
return on.current = null, { getColOffset: (P) => v.getColOffset(P) * G, getColIndex: (P) => v.getColIndex(P / G), getRowOffset: (P) => v.getRowOffset(P) * G, getRowIndex: (P) => v.getRowIndex(P / G) };
|
|
2836
|
-
}, [dn, g, G]),
|
|
2824
|
+
}, [dn, g, G]), qt = (v, P, D) => {
|
|
2837
2825
|
const F = (P?.left ?? 0) + 0, j = (P?.top ?? 0) + 0;
|
|
2838
2826
|
return { getColOffset: (fe) => v.getColOffset(fe) - F, getColIndex: (fe) => v.getColIndex(fe + F), getRowOffset: (fe) => v.getRowOffset(fe) - j, getRowIndex: (fe) => v.getRowIndex(fe + j) };
|
|
2839
|
-
}, vt = O((v, P = !1) => go(v, P, ze.getRowOffset, P ? 0 : r), [r, ze?.getRowOffset]), Vt = T(A ?? vt, [A]), Cn = O((v, P = !1) => go(v, P, ze.getColOffset, P ? i : 0), [i, ze?.getColOffset]), un = T(
|
|
2827
|
+
}, vt = O((v, P = !1) => go(v, P, ze.getRowOffset, P ? 0 : r), [r, ze?.getRowOffset]), Vt = T(A ?? vt, [A]), Cn = O((v, P = !1) => go(v, P, ze.getColOffset, P ? i : 0), [i, ze?.getColOffset]), un = T(q ?? Cn, [q]), Ne = Ee(() => Math.min(n ?? 800, ze.getColOffset(i)), [ze.getColOffset, i, n]), Q = Ee(() => Math.min(o ?? 600, ze.getRowOffset(r)), [ze.getRowOffset, r, o]), et = O((v) => {
|
|
2840
2828
|
Ct.canUseDOM && setTimeout(() => {
|
|
2841
2829
|
at.current?.focus({ preventScroll: !0, ...v });
|
|
2842
2830
|
}, 0);
|
|
2843
|
-
}, []),
|
|
2831
|
+
}, []), qe = O((v) => at.current?.contains(v) || pt.current?.contains(v), []);
|
|
2844
2832
|
st(() => {
|
|
2845
2833
|
jt.current && (ke.current && ke.current.left !== Qe.current?.left && ke.current.top !== Qe.current?.top || (ke.current = null, pe?.({ left: wt, top: Xe })));
|
|
2846
2834
|
}, [wt, Xe]);
|
|
@@ -2850,11 +2838,11 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_h9wwa_7" }, ts = Object.freeze({ top
|
|
|
2850
2838
|
typeof L == "number" ? P = L : (P = L.index ?? 0, D = (L.scrollOffset ?? 0) * G);
|
|
2851
2839
|
const F = D, j = ze.getRowOffset(P), fe = j - F;
|
|
2852
2840
|
if (P > 0) {
|
|
2853
|
-
const ut =
|
|
2841
|
+
const ut = qt(ze, { top: D + ze.getRowOffset(0) }), Fe = ze.getRowIndex(F), je = ze.getRowIndex(j - 1);
|
|
2854
2842
|
let mt;
|
|
2855
2843
|
v[1] = { minIndex: Fe, maxIndex: je, minCoord: 0, maxCoord: P - 1, minBounds: 0, maxBounds: fe, visibleIndices: () => mt || (mt = Object.freeze(io(Vt, Fe, je)), mt), layout: ut, maxVirtualBounds: j, scrollOffset: D, freezeOffset: D };
|
|
2856
2844
|
}
|
|
2857
|
-
const se = Math.max(0, Q - fe), ve =
|
|
2845
|
+
const se = Math.max(0, Q - fe), ve = qt(ze, { top: Xe + fe }), ye = ve.getRowIndex(0), ce = ve.getRowIndex(se);
|
|
2858
2846
|
let Ve;
|
|
2859
2847
|
return v[0] = { minIndex: ye, maxIndex: ce, minCoord: P, maxCoord: r - 1, minBounds: fe, maxBounds: se, visibleIndices: () => Ve || (Ve = Object.freeze(io(Vt, ye, ce)), Ve), layout: ve, maxVirtualBounds: ze.getRowOffset(r), scrollOffset: Xe, freezeOffset: (P > 0 ? ze.getRowOffset(P) : 0) - D }, v;
|
|
2860
2848
|
}, [ze.getRowIndex, ze.getRowOffset, Vt, Q, r, L, Xe, G]), Le = Ee(() => {
|
|
@@ -2863,11 +2851,11 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_h9wwa_7" }, ts = Object.freeze({ top
|
|
|
2863
2851
|
typeof _ == "number" ? P = _ : (P = _.index ?? 0, D = (_.scrollOffset ?? 0) * G);
|
|
2864
2852
|
const F = D, j = ze.getColOffset(P), fe = j - F;
|
|
2865
2853
|
if (P > 0) {
|
|
2866
|
-
const ut =
|
|
2854
|
+
const ut = qt(ze, { left: D + ze.getColOffset(0) }), Fe = ze.getColIndex(F), je = ze.getColIndex(j - 1);
|
|
2867
2855
|
let mt;
|
|
2868
2856
|
v[1] = { minIndex: Fe, maxIndex: je, minCoord: 0, maxCoord: P - 1, minBounds: 0, maxBounds: fe, visibleIndices: () => mt || (mt = Object.freeze(io(un, Fe, je)), mt), layout: ut, maxVirtualBounds: j, scrollOffset: D, freezeOffset: D };
|
|
2869
2857
|
}
|
|
2870
|
-
const se = Math.max(0, Ne - fe), ve =
|
|
2858
|
+
const se = Math.max(0, Ne - fe), ve = qt(ze, { left: wt + fe }), ye = ve.getColIndex(0), ce = ve.getColIndex(se);
|
|
2871
2859
|
let Ve;
|
|
2872
2860
|
return v[0] = { minIndex: ye, maxIndex: ce, minCoord: P, maxCoord: i - 1, minBounds: fe, maxBounds: se, visibleIndices: () => Ve || (Ve = Object.freeze(io(un, ye, ce)), Ve), layout: ve, maxVirtualBounds: ze.getColOffset(i), scrollOffset: wt, freezeOffset: (P > 0 ? ze.getColOffset(P) : 0) - D }, v;
|
|
2873
2861
|
}, [ze.getColIndex, ze.getColOffset, un, Ne, i, _, wt, G]), rt = J({}), tt = J([]), Ae = Ee(() => {
|
|
@@ -2884,7 +2872,7 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_h9wwa_7" }, ts = Object.freeze({ top
|
|
|
2884
2872
|
let $e, ct = 0;
|
|
2885
2873
|
return Ze === void 0 || typeof Ze == "number" ? ($e = je(ce), ct = Ze) : $e = Ze, ((Oe, Et, bt = 0) => {
|
|
2886
2874
|
if (Oe.x > Et.width || Oe.y > Et.height) return null;
|
|
2887
|
-
const $t = { left: Oe.x, top: Oe.y, bottom: Oe.height + Oe.y, right: Oe.width + Oe.x },
|
|
2875
|
+
const $t = { left: Oe.x, top: Oe.y, bottom: Oe.height + Oe.y, right: Oe.width + Oe.x }, Kt = { left: Et.x + bt, top: Et.y + bt, bottom: Et.height - 2 * bt + Et.y, right: Et.width - 2 * bt + Et.x }, Ot = { left: Math.max($t.left, Kt.left), top: Math.max($t.top, Kt.top), bottom: Math.min($t.bottom, Kt.bottom), right: Math.min($t.right, Kt.right) }, c = { x: Ot.left, y: Ot.top, width: Ot.right - Ot.left, height: Ot.bottom - Ot.top };
|
|
2888
2876
|
return c.height < 0 || c.width < 0 ? null : c;
|
|
2889
2877
|
})(Ce ?? { x: 0, y: 0, width: Fe.width, height: Fe.height }, $e, ct);
|
|
2890
2878
|
}, toViewBounds: (Ce) => Wt === 0 && At === 0 && G === 1 ? Ce : { x: (Ce.x - Wt) * G, y: (Ce.y - At) * G, width: Ce.width * G, height: Ce.height * G }, toAbsoluteBounds: (Ce) => Wt === 0 && At === 0 && G === 1 ? Ce : { x: Ce.x / G + Wt, y: Ce.y / G + At, width: Ce.width / G, height: Ce.height / G }, getRelativePointFromClient: (Ce, Ze) => {
|
|
@@ -2910,9 +2898,9 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_h9wwa_7" }, ts = Object.freeze({ top
|
|
|
2910
2898
|
}, [Ae]);
|
|
2911
2899
|
const kt = T(() => ({ containerWidth: Ne, containerHeight: Q, totalWidth: Mt, totalHeight: nt }), [Ne, Q, ze]);
|
|
2912
2900
|
st(() => {
|
|
2913
|
-
!ke.current && jt.current &&
|
|
2901
|
+
!ke.current && jt.current && K({ top: Xe, left: wt, width: Ne, height: Q, totalWidth: Mt, totalHeight: nt });
|
|
2914
2902
|
}, [Xe, wt, Mt, nt]), st(() => {
|
|
2915
|
-
jt.current &&
|
|
2903
|
+
jt.current && K({ top: Xe, left: wt, width: Ne, height: Q, totalWidth: Mt, totalHeight: nt });
|
|
2916
2904
|
}, [Ne, Q]);
|
|
2917
2905
|
const hn = O((v, P) => {
|
|
2918
2906
|
ao(typeof v == "number" && typeof P == "number");
|
|
@@ -2927,7 +2915,7 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_h9wwa_7" }, ts = Object.freeze({ top
|
|
|
2927
2915
|
const se = Hr;
|
|
2928
2916
|
for (let ve = 0; !fe && ve < se.length; ve++) {
|
|
2929
2917
|
const ye = Ae[se[ve]];
|
|
2930
|
-
ye &&
|
|
2918
|
+
ye && Kl(F, j, ye.getBounds()) && (fe = ye);
|
|
2931
2919
|
}
|
|
2932
2920
|
return fe || (fe = Ae[Xt]), fe;
|
|
2933
2921
|
}, [Ae, We]), ft = T(() => Ae[Xt].getVisibleRangeCoords(), [Ae[Xt]]), ln = J(null), vo = O(() => {
|
|
@@ -2941,19 +2929,19 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_h9wwa_7" }, ts = Object.freeze({ top
|
|
|
2941
2929
|
const P = v?.left ?? v?.[0], D = v?.top ?? v?.[1], F = P !== void 0 ? Math.min(Mt - Ne, Math.max(Le?.[1]?.scrollOffset ?? 0, P)) : Qe.current.left, j = D !== void 0 ? Math.min(nt - Q, Math.max(Ie?.[1]?.scrollOffset ?? 0, D)) : Qe.current.top;
|
|
2942
2930
|
if (Qe.current.left === F && Qe.current.top === j) return;
|
|
2943
2931
|
let fe = null, se = null;
|
|
2944
|
-
Qe.current.left > F ? fe = ot : Qe.current.left < F && (fe =
|
|
2932
|
+
Qe.current.left > F ? fe = ot : Qe.current.left < F && (fe = Ke), Qe.current.top > j ? se = it : Qe.current.top < j && (se = lt), Ct.throttle(() => {
|
|
2945
2933
|
z((ve) => {
|
|
2946
2934
|
const ye = { ...ve, left: F, top: j, horizontalScrollDirection: fe, verticalScrollDirection: se };
|
|
2947
2935
|
return Qe.current = ye, ye;
|
|
2948
2936
|
});
|
|
2949
|
-
}, 17)(), ke.current?.top === j && ke.current?.left === F || (ke.current = { left: F, top: j }, ue({ left: F, top: j }),
|
|
2937
|
+
}, 17)(), ke.current?.top === j && ke.current?.left === F || (ke.current = { left: F, top: j }, ue({ left: F, top: j }), K({ left: F, top: j, width: Ne, height: Q, totalWidth: Mt, totalHeight: nt })), vo();
|
|
2950
2938
|
}, [Mt, nt, Ie, Le]);
|
|
2951
2939
|
st(() => {
|
|
2952
2940
|
ke.current || xn({ left: wt, top: Xe });
|
|
2953
2941
|
}, [Mt, Ne, nt, Q]), nn(() => {
|
|
2954
2942
|
ke.current = { left: ht?.left, top: ht?.top }, xn(ke.current);
|
|
2955
2943
|
}, [ht?.left, ht?.top]);
|
|
2956
|
-
const
|
|
2944
|
+
const Kn = T((v) => {
|
|
2957
2945
|
const P = v?.left ?? v?.[0], D = v?.top ?? v?.[1], F = v?.behavior ?? "auto", j = { left: Qe.current.left + (P ?? 0), top: Qe.current.top + (D ?? 0) };
|
|
2958
2946
|
F && (j.behavior = F), xn(j);
|
|
2959
2947
|
}, [Mt, Ne, nt, Q]), Yn = O((v) => {
|
|
@@ -2992,7 +2980,7 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_h9wwa_7" }, ts = Object.freeze({ top
|
|
|
2992
2980
|
let se = P ? F : D, ve = F;
|
|
2993
2981
|
const ye = P || Math.abs(se) > Math.abs(ve);
|
|
2994
2982
|
j === 1 && (ve *= 0), zt.current = window.requestAnimationFrame(() => {
|
|
2995
|
-
zt.current = null,
|
|
2983
|
+
zt.current = null, Kn(ye ? { left: se } : { top: ve });
|
|
2996
2984
|
});
|
|
2997
2985
|
}, [Mt, Ne, nt, Q, te]), zn = O((v = null) => {
|
|
2998
2986
|
on.current = null, rt.current = null, Zt();
|
|
@@ -3000,7 +2988,7 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_h9wwa_7" }, ts = Object.freeze({ top
|
|
|
3000
2988
|
nn(() => {
|
|
3001
2989
|
zn();
|
|
3002
2990
|
}, [oe]);
|
|
3003
|
-
const vn = wo(t, () => ({ stage: at.current, focus: et, contains:
|
|
2991
|
+
const vn = wo(t, () => ({ stage: at.current, focus: et, contains: qe, invalidate: zn, scrollTo: xn, scrollBy: Kn, scrollCellCoordsIntoView: Dn, getScrollPosition: dt, getDimensions: kt, getViewport: ft, handleWheel: Mn, rowCount: r, columnCount: i, getLayout: () => ze, getRelativePointFromClient: hn, getViewFromClient: xo, getViewFromCellCoords: Yn, getViewFromLocation: mo, onViewChangeOnce: (v) => {
|
|
3004
2992
|
tt.current.push(v);
|
|
3005
2993
|
} }), [r, i, Ae]);
|
|
3006
2994
|
st(() => (He && vn.current?.addEventListener("wheel", Mn, { passive: !1 }), jt.current = !0, ke.current = null, () => {
|
|
@@ -3036,13 +3024,13 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_h9wwa_7" }, ts = Object.freeze({ top
|
|
|
3036
3024
|
}
|
|
3037
3025
|
}
|
|
3038
3026
|
const Ve = v.getVisibleColumnOffsets(), ut = v.getVisibleRowOffsets(), Fe = v.getScrollTopLeft(), je = v.getFreezeTopLeft(), mt = Fe.left + je.left, Ge = Fe.top + je.top, Pt = Math.trunc(mt / sn), yt = Math.trunc(Ge / sn), ge = {}, xt = (Ze, $e, ct, Oe, Et) => {
|
|
3039
|
-
const bt = `view:${Ze.getAnchor()}:cell:${Dr($e.rowIndex, $e.colIndex)}`, $t = Oe.x,
|
|
3027
|
+
const bt = `view:${Ze.getAnchor()}:cell:${Dr($e.rowIndex, $e.colIndex)}`, $t = Oe.x, Kt = Oe.y, Ot = Math.trunc((mt + $t) / sn) - Pt, c = Math.trunc((Ge + Kt) / sn) - yt;
|
|
3040
3028
|
ge[c] || (ge[c] = {});
|
|
3041
3029
|
let h = ge[c][Ot];
|
|
3042
3030
|
h || (h = ge[c][Ot] = []);
|
|
3043
3031
|
let w = fe?.get(bt);
|
|
3044
3032
|
if (!w) {
|
|
3045
|
-
const p = (mt + $t) % sn, y = (Ge +
|
|
3033
|
+
const p = (mt + $t) % sn, y = (Ge + Kt) % sn;
|
|
3046
3034
|
w = oe({ key: bt, coords: $e, bounds: Oe, zoom: G, range: ct, view: Ze, value: Et, style: { left: me.boundPixel(p), top: me.boundPixel(y), width: me.boundPixel(Oe.width, !0), height: me.boundPixel(Oe.height, !0) } });
|
|
3047
3035
|
}
|
|
3048
3036
|
se?.set(bt, w), h.push(w);
|
|
@@ -3054,7 +3042,7 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_h9wwa_7" }, ts = Object.freeze({ top
|
|
|
3054
3042
|
if (!Z.isRangesIntersect(Oe, Et) && !Z.isRangeWithinRange(Oe, Et)) continue;
|
|
3055
3043
|
const bt = Oe && !Z.isSingleCell(Oe);
|
|
3056
3044
|
if (!bt && N?.(ct)) continue;
|
|
3057
|
-
const $t = ct.rowIndex,
|
|
3045
|
+
const $t = ct.rowIndex, Kt = ct.colIndex, Ot = ut[$t], c = Ve[Kt];
|
|
3058
3046
|
let h = null;
|
|
3059
3047
|
Ot && c && (h = { x: c.offset, y: Ot.offset, width: c.size, height: Ot.size });
|
|
3060
3048
|
const w = Dr(Oe.rowStart, Oe.colStart);
|
|
@@ -3077,7 +3065,7 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_h9wwa_7" }, ts = Object.freeze({ top
|
|
|
3077
3065
|
for (let Oe = 0; Oe < ct.length; Oe++) {
|
|
3078
3066
|
const Et = $e[ct[Oe]];
|
|
3079
3067
|
if (!Et) continue;
|
|
3080
|
-
const bt = parseInt(Ce[Ze]), $t = parseInt(ct[Oe]),
|
|
3068
|
+
const bt = parseInt(Ce[Ze]), $t = parseInt(ct[Oe]), Kt = bt + yt, Ot = $t + Pt, c = `view:${v.getAnchor()}:segment:${Ot}:${Kt}`;
|
|
3081
3069
|
P.push(Y("div", { className: "cell-container", style: { transform: `translate(${me.boundPixel($t * sn - At, !0)}px, ${me.boundPixel(bt * sn - Wt, !0)}px)`, willChange: "transform" }, children: Et }, c));
|
|
3082
3070
|
}
|
|
3083
3071
|
}
|
|
@@ -3229,18 +3217,18 @@ const Ti = "ew-resize", Ri = "ns-resize", ls = Dt(Ut((e, t) => {
|
|
|
3229
3217
|
const { orientation: n, view: o, index: r, disabled: i = !1, disabledResize: l = !1, resizeThreshold: s = 1, dividerRenderer: a = ss, onDividerMouseDown: d, onDividerResizeStart: g, onDividerResize: m, onDividerResizeEnd: f, onDividerMouseUp: x, onDividerAutoFit: E, onPointerDown: I, ...M } = e, ae = T(I, [I]), R = T(E, [E]), _ = n === Nt;
|
|
3230
3218
|
let L = _ ? o.getVisibleColumns() : o.getVisibleRows(), le = null;
|
|
3231
3219
|
L.length > 0 && (_ ? le = o.getRangeCoordsBounds({ rowStart: 0, rowEnd: 0, colStart: L[0], colEnd: L[L.length - 1] }) : o.getRangeCoordsBounds({ rowStart: L[0], rowEnd: L[L.length - 1], colStart: 0, colEnd: 0 }), le = o.toClipBounds(le, tn));
|
|
3232
|
-
const $ = J(null), [oe, be] = Je(null), U = (A,
|
|
3220
|
+
const $ = J(null), [oe, be] = Je(null), U = (A, q) => _ ? A.clientX - q.clientX : A.clientY - q.clientY, H = o.getLayout(), X = _ ? H.getColOffset(r + 1) : H.getRowOffset(r + 1), k = On({ processTouch: !0, onPointerDown: (A) => {
|
|
3233
3221
|
if (ae?.(A), !i && !l) {
|
|
3234
|
-
const
|
|
3222
|
+
const q = _ ? H.getColOffset(r) : H.getRowOffset(r), N = X - q;
|
|
3235
3223
|
$.current = { isResizing: !1, startSize: N, index: r, view: o, orientation: n, onDividerMouseDown: d, onDividerResizeStart: g, onDividerResize: m, onDividerResizeEnd: f, onDividerMouseUp: x }, be($.current), d?.(r, N);
|
|
3236
3224
|
}
|
|
3237
3225
|
A.stopPropagation(), A.preventDefault();
|
|
3238
|
-
}, onPointerUp: (A,
|
|
3226
|
+
}, onPointerUp: (A, q, N) => {
|
|
3239
3227
|
if (!$.current) return;
|
|
3240
3228
|
$.current.isResizing && $.current.onDividerResizeEnd?.($.current.index, Math.max(0, $.current.startSize + U(A, N)), $.current.startSize);
|
|
3241
3229
|
const xe = $.current;
|
|
3242
3230
|
$.current = null, be($.current), xe.onDividerMouseUp?.(xe.index);
|
|
3243
|
-
}, onPointerMoveOrWait: (A,
|
|
3231
|
+
}, onPointerMoveOrWait: (A, q, N) => {
|
|
3244
3232
|
if (!$.current) return;
|
|
3245
3233
|
const xe = U(A, N);
|
|
3246
3234
|
$.current.isResizing ? $.current.onDividerResize?.($.current.index, Math.max(0, $.current.startSize + xe), $.current.startSize) : Math.abs(xe) > Math.max(1, s) && ($.current = { ...$.current, isResizing: !0 }, be($.current), $.current.onDividerResizeStart?.($.current.index, Math.max(0, $.current.startSize + xe))), A.stopPropagation(), A.preventDefault();
|
|
@@ -3252,7 +3240,7 @@ const Ti = "ew-resize", Ri = "ns-resize", ls = Dt(Ut((e, t) => {
|
|
|
3252
3240
|
if (!C) return;
|
|
3253
3241
|
const { getPortalContainer: ee } = gi();
|
|
3254
3242
|
let W = null;
|
|
3255
|
-
return oe && oe.isResizing && oe.index === r && (W =
|
|
3243
|
+
return oe && oe.isResizing && oe.index === r && (W = Kr(Y("div", { style: { position: "absolute", cursor: _ ? Ti : Ri, left: 0, top: 0, width: "100%", height: "100%" } }), ee(), "divider:" + r)), Ht(wn, { children: [W, Y("div", { className: En("header-divider-anchor"), style: { position: "absolute", pointerEvents: "auto", top: `${_ ? le.y : X}px`, left: `${_ ? X : le.x}px`, width: (_ ? 0 : le.width - 1) + "px", height: (_ ? le.height - 1 : 0) + "px", display: "flex" }, tabIndex: -1, children: C })] });
|
|
3256
3244
|
}));
|
|
3257
3245
|
class cs {
|
|
3258
3246
|
naturalDimensions(t, n = {}) {
|
|
@@ -3281,20 +3269,20 @@ const as = (e = void 0) => Object.freeze({ clean: e, dirty: void 0, editMode: !1
|
|
|
3281
3269
|
let u = 2;
|
|
3282
3270
|
const C = 96 * U / 72, ee = 1.2 * C;
|
|
3283
3271
|
le === "right" && (u += 1);
|
|
3284
|
-
const W = Ee(() => new cs().naturalDimensions(k, { maxWidth: oe === "wrap" ? ae - u : void 0, lineHeight: `${ee}px`, paintableText: { fontStyle: X, wrap: oe, letterSpacing: -0.25 } }), [k, oe, u, C, be, H, X, g, ae]), A = O(() => W.maxLineHeight ? W.maxLineHeight + "px" : "1.2", [W]), [
|
|
3272
|
+
const W = Ee(() => new cs().naturalDimensions(k, { maxWidth: oe === "wrap" ? ae - u : void 0, lineHeight: `${ee}px`, paintableText: { fontStyle: X, wrap: oe, letterSpacing: -0.25 } }), [k, oe, u, C, be, H, X, g, ae]), A = O(() => W.maxLineHeight ? W.maxLineHeight + "px" : "1.2", [W]), [q, N] = Je(A);
|
|
3285
3273
|
nn(() => {
|
|
3286
3274
|
N(A());
|
|
3287
3275
|
}, [d, W]), nn(() => {
|
|
3288
3276
|
g?.({ width: oe === "wrap" ? void 0 : W.width + u, height: W.height });
|
|
3289
3277
|
}, [W, g]);
|
|
3290
|
-
const xe = T(i, [i]), G = T((
|
|
3291
|
-
if (R.dirty ===
|
|
3278
|
+
const xe = T(i, [i]), G = T((K) => {
|
|
3279
|
+
if (R.dirty === K) return;
|
|
3292
3280
|
const pe = { ...R };
|
|
3293
|
-
pe.dirty =
|
|
3294
|
-
}, [R]), He = T((
|
|
3295
|
-
if (R.editMode ===
|
|
3281
|
+
pe.dirty = K, M.current, _(pe), xe?.(pe);
|
|
3282
|
+
}, [R]), He = T((K) => {
|
|
3283
|
+
if (R.editMode === K) return;
|
|
3296
3284
|
const pe = { ...R };
|
|
3297
|
-
pe.editMode =
|
|
3285
|
+
pe.editMode = K, _(pe), xe?.(pe);
|
|
3298
3286
|
}, [R]), Ue = T(() => {
|
|
3299
3287
|
try {
|
|
3300
3288
|
return l?.(R), a?.(), !0;
|
|
@@ -3303,24 +3291,24 @@ const as = (e = void 0) => Object.freeze({ clean: e, dirty: void 0, editMode: !1
|
|
|
3303
3291
|
}
|
|
3304
3292
|
}, [l, R]), We = T(() => {
|
|
3305
3293
|
_(n), s?.(), a?.();
|
|
3306
|
-
}, [s, n]), ht = T((
|
|
3294
|
+
}, [s, n]), ht = T((K) => {
|
|
3307
3295
|
if (!M.current) return;
|
|
3308
|
-
if (
|
|
3296
|
+
if (K.isDefaultPrevented(), !(K.isTrusted || K.nativeEvent.ctrlKey || K.nativeEvent.metaKey || K.nativeEvent.altKey || K.nativeEvent.isComposing) && vi.indexOf(K.nativeEvent.key) !== -1) {
|
|
3309
3297
|
const te = { ...R };
|
|
3310
|
-
return te.dirty =
|
|
3298
|
+
return te.dirty = K.nativeEvent.key === "Backspace" ? "" : (te.dirty ?? "") + K.key, _(te), xe?.(te), void K.preventDefault();
|
|
3311
3299
|
}
|
|
3312
|
-
const pe =
|
|
3313
|
-
if (
|
|
3314
|
-
if (
|
|
3315
|
-
if (
|
|
3300
|
+
const pe = K.nativeEvent.shiftKey;
|
|
3301
|
+
if (K.which === Ji) return K.preventDefault(), void We();
|
|
3302
|
+
if (K.which === ol) return He(!0), void K.preventDefault();
|
|
3303
|
+
if (K.which === Zi && (K.preventDefault(), Ue() && m?.(pe ? it : lt)), K.which === Gi) return K.preventDefault(), void (Ue() && m?.(pe ? ot : Ke));
|
|
3316
3304
|
if (!R.editMode) {
|
|
3317
3305
|
let te = null;
|
|
3318
|
-
switch (
|
|
3306
|
+
switch (K.which) {
|
|
3319
3307
|
case Qi:
|
|
3320
3308
|
te = ot;
|
|
3321
3309
|
break;
|
|
3322
3310
|
case tl:
|
|
3323
|
-
te =
|
|
3311
|
+
te = Ke;
|
|
3324
3312
|
break;
|
|
3325
3313
|
case el:
|
|
3326
3314
|
te = it;
|
|
@@ -3334,25 +3322,25 @@ const as = (e = void 0) => Object.freeze({ clean: e, dirty: void 0, editMode: !1
|
|
|
3334
3322
|
st(() => {
|
|
3335
3323
|
S(!1);
|
|
3336
3324
|
}, []);
|
|
3337
|
-
const ue = wo(t, () => ({ startEdit(
|
|
3338
|
-
let pe =
|
|
3325
|
+
const ue = wo(t, () => ({ startEdit(K) {
|
|
3326
|
+
let pe = K?.initialSelection;
|
|
3339
3327
|
if (!pe) {
|
|
3340
3328
|
const Re = M.current.value.length ?? 0;
|
|
3341
3329
|
pe = { start: Re, end: Re, direction: "forward" };
|
|
3342
3330
|
}
|
|
3343
3331
|
M.current?.setSelectionRange(pe.start, pe.end, pe.direction);
|
|
3344
|
-
const te = { ...n, editMode:
|
|
3345
|
-
|
|
3332
|
+
const te = { ...n, editMode: K?.editMode ?? !1 };
|
|
3333
|
+
K?.text !== void 0 && (te.dirty = K.text), te.editMode === n.editMode && te.dirty === n.dirty || (_(te), xe?.(te));
|
|
3346
3334
|
}, submitEdit: () => Ue(), cancelEdit() {
|
|
3347
3335
|
We();
|
|
3348
3336
|
}, autoFocus() {
|
|
3349
3337
|
M.current?.focus();
|
|
3350
|
-
}, getLineHeight: () => W?.maxLineHeight ?? ee, dispatchEvent: (
|
|
3351
|
-
return Y("div", { ref: ue, ...I, style: { background: "transparent", display: "flex", flexGrow: 1, alignSelf: "center", height: W.height, maxWidth: "100%", maxHeight: "100%", ...x }, children: Y("textarea", { spellCheck: "false", ref: M, value: k, autoFocus: !1, disabled: _e, name: "cell-editor", autoComplete: "off", autoCapitalize: "off", style: { flex: "1 1 100%", position: "relative", fontSize: `${C}px`, fontFamily: `${be}`, fontWeight: `${H}`, fontStyle: `${X}`, padding: "0px", marginRight: L === "right" ? "3px" : "0px", marginLeft: L === "left" ? "2px" : "0px", lineHeight:
|
|
3352
|
-
G(
|
|
3353
|
-
}, onDoubleClick: (
|
|
3354
|
-
|
|
3355
|
-
}, onMouseDown: (
|
|
3338
|
+
}, getLineHeight: () => W?.maxLineHeight ?? ee, dispatchEvent: (K) => M.current.dispatchEvent(K) }), [n, r]);
|
|
3339
|
+
return Y("div", { ref: ue, ...I, style: { background: "transparent", display: "flex", flexGrow: 1, alignSelf: "center", height: W.height, maxWidth: "100%", maxHeight: "100%", ...x }, children: Y("textarea", { spellCheck: "false", ref: M, value: k, autoFocus: !1, disabled: _e, name: "cell-editor", autoComplete: "off", autoCapitalize: "off", style: { flex: "1 1 100%", position: "relative", fontSize: `${C}px`, fontFamily: `${be}`, fontWeight: `${H}`, fontStyle: `${X}`, padding: "0px", marginRight: L === "right" ? "3px" : "0px", marginLeft: L === "left" ? "2px" : "0px", lineHeight: q, height: W.height, textRendering: "geometricPrecision", letterSpacing: "-0.25px", boxSizing: "border-box", borderWidth: 0, outline: "none", resize: "none", overflow: "hidden", verticalAlign: "baseline", textAlign: L, background: "transparent", color: $, marginBottom: "0px", userSelect: "text", maxHeight: "100%", whiteSpace: oe === "wrap" ? "break-spaces" : "pre", wordWrap: "break-word" }, onChange: (K) => {
|
|
3340
|
+
G(K.target.value);
|
|
3341
|
+
}, onDoubleClick: (K) => {
|
|
3342
|
+
K.isTrusted;
|
|
3343
|
+
}, onMouseDown: (K) => {
|
|
3356
3344
|
He(!0);
|
|
3357
3345
|
}, onKeyDown: ht }) });
|
|
3358
3346
|
})), bs = Dt((e) => {
|