@sheetxl/grid-react 0.3.1 → 0.3.3
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 -6
- package/browser/esm/index.mjs +196 -196
- package/licenses/dependencies.txt +22 -22
- package/node/assets/style.css +1 -1
- package/node/esm/index.mjs +92 -92
- package/package.json +3 -3
package/browser/esm/index.mjs
CHANGED
|
@@ -1,15 +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_h9wwa_7{position:relative;box-sizing:border-box;user-select:none}._sheetxl-grid_h9wwa_7 *{box-sizing:border-box!important}._sheetxl-grid_h9wwa_7 *:focus{outline:none}._sheetxl-grid_h9wwa_7 .cell-container{position:absolute;overflow:visible;white-space:pre}._sheetxl-grid_h9wwa_7 .cell-container>*{inset:0;position:absolute}._sheetxl-grid_h9wwa_7 .sheetxl-stage{contain:strict}._sheetxl-grid_h9wwa_7 .sheetxl-stage>*{contain:strict}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
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 Kr, 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 qr } 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.3
|
|
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
|
-
const it = "up", lt = "down", ot = "left",
|
|
12
|
+
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 });
|
|
13
13
|
Object.freeze(Object.defineProperty({ __proto__: null, EmptyBounds: Ai, EmptyRect: zi, EmptyTopLeft: Di }, Symbol.toStringTag, { value: "Module" }));
|
|
14
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) => {
|
|
15
15
|
if (e === t) return !0;
|
|
@@ -158,7 +158,7 @@ _n.all = function(e, t) {
|
|
|
158
158
|
return _n(n, o, t);
|
|
159
159
|
}, {});
|
|
160
160
|
};
|
|
161
|
-
const
|
|
161
|
+
const Ki = Object.freeze([]), qi = Object.freeze({}), ur = (e) => e, so = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
|
|
162
162
|
let t = 16 * Math.random() | 0;
|
|
163
163
|
return (e === "x" ? t : 3 & t | 8).toString(16);
|
|
164
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) {
|
|
@@ -182,7 +182,7 @@ const qi = Object.freeze([]), Ki = Object.freeze({}), ur = (e) => e, so = () =>
|
|
|
182
182
|
function ei() {
|
|
183
183
|
return typeof process < "u" && process.release?.name === "node" || (typeof process < "u" && process.browser, !1);
|
|
184
184
|
}
|
|
185
|
-
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: Ki, EmptyObject: qi, OSType: Ft, arrayMove: function(e, t, n) {
|
|
186
186
|
const o = e.slice();
|
|
187
187
|
return o.splice(n < 0 ? o.length + n : n, 0, o.splice(t, 1)[0]), o;
|
|
188
188
|
}, asNumber: (e) => {
|
|
@@ -612,11 +612,11 @@ const Ho = async (e, t = Bt) => new Promise(async (n, o) => {
|
|
|
612
612
|
console.warn("Can't parse html from clipboard.");
|
|
613
613
|
}
|
|
614
614
|
return o;
|
|
615
|
-
},
|
|
615
|
+
}, Kn = "clipboard-uuid", Tn = "web text/uuid", Sr = (e) => `<div style="display:none" ${Kn}="${e}"/>`, Xi = (e, t) => {
|
|
616
616
|
let n = null;
|
|
617
617
|
try {
|
|
618
618
|
const o = new DOMParser().parseFromString(t, Bt);
|
|
619
|
-
o.body.firstElementChild.setAttribute(
|
|
619
|
+
o.body.firstElementChild.setAttribute(Kn, e), n = o.getElementsByTagName("body")[0].innerHTML;
|
|
620
620
|
} catch (o) {
|
|
621
621
|
console.warn("Can't embed uuid.", o);
|
|
622
622
|
}
|
|
@@ -624,7 +624,7 @@ const Ho = async (e, t = Bt) => new Promise(async (n, o) => {
|
|
|
624
624
|
}, Er = (e, t) => {
|
|
625
625
|
if (!t || !e) return !1;
|
|
626
626
|
try {
|
|
627
|
-
const n = t.querySelectorAll(`[${
|
|
627
|
+
const n = t.querySelectorAll(`[${Kn}="${e}"]`);
|
|
628
628
|
if (n && n.length === 1) return !0;
|
|
629
629
|
if (t.querySelector("parsererror")) throw new Error("We are unable to parse node");
|
|
630
630
|
return !1;
|
|
@@ -701,12 +701,12 @@ let ho = class {
|
|
|
701
701
|
const f = await s.getType(fn);
|
|
702
702
|
if (f) {
|
|
703
703
|
let x = null;
|
|
704
|
-
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 ${Kn}="${o}">${x}</div>`);
|
|
705
705
|
}
|
|
706
706
|
}
|
|
707
707
|
if (!d && s.types.includes(Mo)) {
|
|
708
708
|
const f = await s.getType(Mo), x = ti(await f.arrayBuffer());
|
|
709
|
-
d = `<div ${
|
|
709
|
+
d = `<div ${Kn}="${o}"><img src="${ni + x}"/></div>`;
|
|
710
710
|
}
|
|
711
711
|
!d && o && (d = Sr(o));
|
|
712
712
|
const g = new Blob([d ?? ""], { type: Bt }), m = {};
|
|
@@ -810,7 +810,7 @@ var Lo;
|
|
|
810
810
|
try {
|
|
811
811
|
if (typeof document < "u") {
|
|
812
812
|
var e = document.createElement("style");
|
|
813
|
-
e.appendChild(document.createTextNode("._sheetxl-
|
|
813
|
+
e.appendChild(document.createTextNode("._sheetxl-scrollbar_eblx4_6 ::-webkit-scrollbar-button{background:transparent}._fullscreen-portal-root_1mjsr_4{pointer-events:none;position:absolute;inset:0;width:100%;height:100%;z-index:1200}._fullscreen-portal-root_1mjsr_4>*{pointer-events:auto}")), document.head.appendChild(e);
|
|
814
814
|
}
|
|
815
815
|
} catch (t) {
|
|
816
816
|
console.error("vite-plugin-css-injected-by-js", t);
|
|
@@ -877,27 +877,27 @@ const er = Dt(Ut((e, t) => {
|
|
|
877
877
|
}, [C, U]);
|
|
878
878
|
const W = O((S, ue = !1) => {
|
|
879
879
|
if (!R.current) return 0;
|
|
880
|
-
const
|
|
880
|
+
const q = R.current.querySelector(".scrollbar-viewport"), pe = q.getBoundingClientRect(), te = q.children, Re = ue ? 0 : No(S, pe[H], te, !0, Math.max(0, S - m));
|
|
881
881
|
return ee(Re), Math.max(0, Re);
|
|
882
882
|
}, []), A = O((S, ue = !1) => {
|
|
883
883
|
if (!R.current) return 0;
|
|
884
|
-
const
|
|
884
|
+
const q = R.current.querySelector(".scrollbar-viewport"), pe = q.getBoundingClientRect(), te = q.children, Re = Math.ceil(u - k), at = ue ? Re : No(S, pe[H], te, !1, Math.max(0, S + m));
|
|
885
885
|
return ee(at), Math.min(Re, at);
|
|
886
|
-
}, [u, k]),
|
|
887
|
-
|
|
886
|
+
}, [u, k]), K = J(null), N = O((S) => {
|
|
887
|
+
K.current = n;
|
|
888
888
|
const ue = S.target[X];
|
|
889
889
|
a(ue, r, o), ae?.(S);
|
|
890
890
|
}, [a, r, o, n]);
|
|
891
891
|
st(() => {
|
|
892
|
-
const S =
|
|
893
|
-
|
|
892
|
+
const S = K.current;
|
|
893
|
+
K.current = null, n !== S && (R.current[X] = n);
|
|
894
894
|
}, [n, X]);
|
|
895
895
|
const xe = J(null), G = J(null), He = O(() => {
|
|
896
896
|
xe.current && (clearTimeout(xe.current), xe.current = null, G.current = null);
|
|
897
|
-
}, []), Ue = O((S, ue,
|
|
897
|
+
}, []), Ue = O((S, ue, q, pe = f) => {
|
|
898
898
|
G.current = S, xe.current = setTimeout(() => {
|
|
899
|
-
const te =
|
|
900
|
-
te !== G.current ? Ue(te, !1,
|
|
899
|
+
const te = q ? W(G.current || S) : A(G.current || S);
|
|
900
|
+
te !== G.current ? Ue(te, !1, q, x) : He();
|
|
901
901
|
}, ue ? 0 : pe);
|
|
902
902
|
}, [W, A, He]);
|
|
903
903
|
st(() => () => He(), [He]);
|
|
@@ -910,7 +910,7 @@ const er = Dt(Ut((e, t) => {
|
|
|
910
910
|
const S = { orientation: s, disabled: Math.floor(u - k) <= Math.ceil(We), onMouseUp: He, onMouseLeave: He, onMouseDown: () => Ue(We, !0, !1) };
|
|
911
911
|
return I?.(S);
|
|
912
912
|
}, [g, s, We, C, u, k]);
|
|
913
|
-
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_eblx4_6", 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] });
|
|
914
914
|
}));
|
|
915
915
|
er.displayName = "Scrollbar";
|
|
916
916
|
let Cr = Date.now, gn = {}, cl = 1;
|
|
@@ -1084,7 +1084,7 @@ var Gt = typeof window < "u" ? window : { screen: {}, navigator: {} }, Ln = (Gt.
|
|
|
1084
1084
|
Gt.addEventListener && Gt.addEventListener("p", Tr, hl), Gt.removeEventListener && Gt.removeEventListener("p", Tr, !1);
|
|
1085
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";
|
|
1086
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 = {};
|
|
1087
|
-
function
|
|
1087
|
+
function Ko() {
|
|
1088
1088
|
return xl;
|
|
1089
1089
|
}
|
|
1090
1090
|
const me = Object.freeze(Object.defineProperty({ __proto__: null, EmptyCssProperties: fi, boundPixel: function(e, t = !1, n = 0) {
|
|
@@ -1097,7 +1097,7 @@ const me = Object.freeze(Object.defineProperty({ __proto__: null, EmptyCssProper
|
|
|
1097
1097
|
n = !0, e.stopPropagation();
|
|
1098
1098
|
}, isPropagationStopped: () => n, persist: () => {
|
|
1099
1099
|
}, timeStamp: e.timeStamp, type: e.type };
|
|
1100
|
-
}, detectIt:
|
|
1100
|
+
}, detectIt: Ko, focusableNodeNames: vl, toPrettyKeyCode: (e) => e === "BracketLeft" ? "[" : e === "BracketRight" ? "]" : Ct.camelToPrettyCase(e) }, Symbol.toStringTag, { value: "Module" })), yl = [];
|
|
1101
1101
|
function wo(e, t, n = yl) {
|
|
1102
1102
|
const o = J(null);
|
|
1103
1103
|
return Ur(e, () => {
|
|
@@ -1130,12 +1130,12 @@ const kr = (e) => Y(er, { ...e }), bl = ({ width: e, height: t }) => Y("div", {
|
|
|
1130
1130
|
}, []);
|
|
1131
1131
|
st(() => {
|
|
1132
1132
|
const k = m ?? I.current;
|
|
1133
|
-
if (!f &&
|
|
1133
|
+
if (!f && Ko().supportsTouchEvents && k && o) {
|
|
1134
1134
|
if (!M.current) {
|
|
1135
1135
|
const u = { scrollingX: !0, scrollingY: !0, decelerationRate: 0.95, penetrationAcceleration: 0.08 };
|
|
1136
1136
|
M.current = new ci(ae, u);
|
|
1137
1137
|
}
|
|
1138
|
-
|
|
1138
|
+
Ko().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 });
|
|
1139
1139
|
}
|
|
1140
1140
|
return () => {
|
|
1141
1141
|
k?.removeEventListener("touchstart", R), k?.removeEventListener("touchend", L), k?.removeEventListener("touchmove", _);
|
|
@@ -1164,7 +1164,7 @@ function gi() {
|
|
|
1164
1164
|
const t = document.fullscreenElement;
|
|
1165
1165
|
if (!t) return;
|
|
1166
1166
|
let n = t.querySelector(".fullscreen-portal-root");
|
|
1167
|
-
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_1mjsr_4", t.appendChild(n));
|
|
1168
1168
|
}
|
|
1169
1169
|
return no++, e(), document.addEventListener("fullscreenchange", e), () => {
|
|
1170
1170
|
document.removeEventListener("fullscreenchange", e), no--, no <= 0 && (document.querySelectorAll(".fullscreen-portal-root").forEach((t) => {
|
|
@@ -1185,7 +1185,7 @@ const El = 100, _l = 100, Il = 1e6, Cl = 100, Ml = 50, Tl = Dt(Ut((e, t) => {
|
|
|
1185
1185
|
_(W);
|
|
1186
1186
|
}
|
|
1187
1187
|
}, [r, o, n, H, i, l, s]);
|
|
1188
|
-
const u = T((W, A,
|
|
1188
|
+
const u = T((W, A, K) => {
|
|
1189
1189
|
const N = k.current;
|
|
1190
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));
|
|
1191
1191
|
}, [g, L, le, oe, be]), C = O((W) => {
|
|
@@ -1200,7 +1200,7 @@ function Do(e, t) {
|
|
|
1200
1200
|
e && (e.current = t);
|
|
1201
1201
|
}
|
|
1202
1202
|
Tl.displayName = "VirtualScrollbar";
|
|
1203
|
-
var fo = parseInt(
|
|
1203
|
+
var fo = parseInt(Kr.split(".")[0], 10) >= 19 ? function(e) {
|
|
1204
1204
|
return (t) => {
|
|
1205
1205
|
const n = [];
|
|
1206
1206
|
for (const o of e) {
|
|
@@ -1238,7 +1238,7 @@ Dt(Ut((e, t) => {
|
|
|
1238
1238
|
return function(le, $, oe = !1) {
|
|
1239
1239
|
if ($ === 0) return le;
|
|
1240
1240
|
function be(C, ee, W) {
|
|
1241
|
-
let A = ee.x - C.x,
|
|
1241
|
+
let A = ee.x - C.x, K = ee.y - C.y, N = Math.sqrt(A * A + K * K);
|
|
1242
1242
|
return U(C, ee, Math.min(1, W / N));
|
|
1243
1243
|
}
|
|
1244
1244
|
function U(C, ee, W) {
|
|
@@ -1260,13 +1260,13 @@ Dt(Ut((e, t) => {
|
|
|
1260
1260
|
let C = X(k[0]), ee = null;
|
|
1261
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]);
|
|
1262
1262
|
for (let W = 1; W < k.length; W++) {
|
|
1263
|
-
let A = u[u.length - 1],
|
|
1264
|
-
if (N && A && A.length > 2 &&
|
|
1265
|
-
let xe, G, He = X(A), Ue = X(
|
|
1266
|
-
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], K = k[W], N = K === ee ? k[1] : k[W + 1];
|
|
1264
|
+
if (N && A && A.length > 2 && K[0] === "L" && N.length > 2 && N[0] === "L") {
|
|
1265
|
+
let xe, G, He = X(A), Ue = X(K), 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(K, xe), K.origPoint = Ue, u.push(K);
|
|
1267
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];
|
|
1268
1268
|
S.origPoint = Ue, u.push(S);
|
|
1269
|
-
} else u.push(
|
|
1269
|
+
} else u.push(K);
|
|
1270
1270
|
}
|
|
1271
1271
|
if (ee) {
|
|
1272
1272
|
let W = X(u[u.length - 1]);
|
|
@@ -1340,21 +1340,21 @@ Dt(Ut((e, t) => {
|
|
|
1340
1340
|
st(() => {
|
|
1341
1341
|
k(pn(l, i === null));
|
|
1342
1342
|
}, [l, i]);
|
|
1343
|
-
const [u, { width: C, height: ee }] = In(), [W, { width: A, height:
|
|
1343
|
+
const [u, { width: C, height: ee }] = In(), [W, { width: A, height: K }] = In(), N = r === "row" ? A : K, xe = r === "row" ? C : ee, G = Ee(() => ((Q, et, Ke, dt) => {
|
|
1344
1344
|
const Ie = [null, null], Le = [null, null];
|
|
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 -
|
|
1346
|
-
let rt = bn(Q, et, dt.fixedPaneOffset !== 1), tt = et -
|
|
1347
|
-
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 - Ke, 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 - Ke, 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) ?? Ke) - Ke, 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];
|
|
1348
1348
|
const hn = Math.max(0, Math.min(100, rt / tt * 100));
|
|
1349
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` };
|
|
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),
|
|
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), q = 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) => {
|
|
1351
1351
|
const et = pn(Q, i === null);
|
|
1352
1352
|
k(et);
|
|
1353
1353
|
}, [i]), jt = T((Q) => {
|
|
1354
1354
|
if (I || !He) return;
|
|
1355
1355
|
const et = ze.current?.getBoundingClientRect();
|
|
1356
|
-
let
|
|
1357
|
-
|
|
1356
|
+
let Ke = 0;
|
|
1357
|
+
Ke = r === "row" ? (Q.clientX ?? Q.touches?.[0]?.clientX) - et.x : (Q.clientY ?? Q.touches?.[0]?.clientY) - et.y, Ke = Math.max(0, Math.min(xe, Ke)), U.fixedPaneOffset === 1 && (Ke = xe - Ke), l && X.pixels === Ke || k({ pixels: Ke, percent: null }), ht?.(Ke), Q.stopPropagation(), Q.preventDefault();
|
|
1358
1358
|
}, [U, r, I, He, X, xe]), dn = T((Q) => {
|
|
1359
1359
|
if (document.removeEventListener("pointermove", jt), document.removeEventListener("touchmove", jt), document.removeEventListener("pointerup", dn), He && (Ue(!1), X)) {
|
|
1360
1360
|
if (_e(X.pixels), !pn(l, i === null) || X.pixels !== l) {
|
|
@@ -1365,8 +1365,8 @@ Dt(Ut((e, t) => {
|
|
|
1365
1365
|
}
|
|
1366
1366
|
}, [X, He, l, i, xe]), on = T((Q) => {
|
|
1367
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 }));
|
|
1368
|
-
}, [wt]), ze = wo(t, () => ({ setPosition: Jt, isSplitPane: () => !0 }), []),
|
|
1369
|
-
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 }), []), Kt = 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: q, 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, Kt, Ne] });
|
|
1370
1370
|
}));
|
|
1371
1371
|
const Pl = ({ initValue: e, useHookBody: t, applyStateChange: n }) => {
|
|
1372
1372
|
const o = J(e);
|
|
@@ -1375,7 +1375,7 @@ const Pl = ({ initValue: e, useHookBody: t, applyStateChange: n }) => {
|
|
|
1375
1375
|
return nn(() => {
|
|
1376
1376
|
o.current !== r && (o.current = r, n(r));
|
|
1377
1377
|
}, [n, r]), null;
|
|
1378
|
-
},
|
|
1378
|
+
}, qo = (e) => {
|
|
1379
1379
|
console && console.warn && console.warn(e);
|
|
1380
1380
|
}, zo = typeof self == "object" && self.self === self && self || typeof global == "object" && global.global === global && global || void 0;
|
|
1381
1381
|
let Ol = 1, Yo = !1, wi = !1;
|
|
@@ -1386,10 +1386,10 @@ const co = [], kn = [], po = () => {
|
|
|
1386
1386
|
return o.current = t, e || Yo !== !1 || (wi = !0), st(() => {
|
|
1387
1387
|
let r = !0;
|
|
1388
1388
|
function i() {
|
|
1389
|
-
if (r) return kn[0] !== i ? (e || Yo !== !0 ||
|
|
1389
|
+
if (r) return kn[0] !== i ? (e || Yo !== !0 || qo("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]);
|
|
1390
1390
|
}
|
|
1391
1391
|
return kn.push(i), po(), () => {
|
|
1392
|
-
r = !1, o.current?.length > 0 &&
|
|
1392
|
+
r = !1, o.current?.length > 0 && qo("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();
|
|
1393
1393
|
};
|
|
1394
1394
|
}, [e]), Y(wn, { children: t.map(({ hook: r, key: i }) => Jo(Pl, { ...r, key: i })) });
|
|
1395
1395
|
}, mi = (e, t, n = {}) => {
|
|
@@ -1405,7 +1405,7 @@ const co = [], kn = [], po = () => {
|
|
|
1405
1405
|
if (zo.document && zo.document.createElement) {
|
|
1406
1406
|
const M = zo.document.createElement("div");
|
|
1407
1407
|
Oi(M).render(Y(I, { automaticContainerInternalUseOnly: !0 }));
|
|
1408
|
-
} else
|
|
1408
|
+
} else qo("Can not mount SingletonHooksContainer on server side. Did you manage to run useEffect on server? Please mount SingletonHooksContainer into your components tree manually.");
|
|
1409
1409
|
})(Ll)), po(), () => {
|
|
1410
1410
|
co.splice(co.findIndex((I) => I.key === E), 1), po();
|
|
1411
1411
|
};
|
|
@@ -1623,18 +1623,18 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1623
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);
|
|
1624
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 }) });
|
|
1625
1625
|
}, gs = (e) => {
|
|
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,
|
|
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, q, pe, te, Re) => {
|
|
1627
1627
|
if (!ue) return null;
|
|
1628
1628
|
const at = te?.(ue, S), pt = S.getRangeCoordsBounds(at), zt = S.toClipBounds(pt), gt = pt, Zt = S.getZoom();
|
|
1629
1629
|
if (!zt) return null;
|
|
1630
|
-
|
|
1630
|
+
q && (q *= Zt), pe && (pe *= Zt);
|
|
1631
1631
|
let Be = gt, z = !1;
|
|
1632
|
-
if (
|
|
1632
|
+
if (q !== void 0) {
|
|
1633
1633
|
let Xe = { ...at }, wt = 0;
|
|
1634
|
-
for (; !z && Be.width <=
|
|
1634
|
+
for (; !z && Be.width <= q && wt < 20; ) {
|
|
1635
1635
|
wt++, wt > 19 && console.warn("max width reached");
|
|
1636
1636
|
const an = S.getTotalRangeCoords(), Jt = S.getLayout();
|
|
1637
|
-
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 + q) : z = !0 : Re === Wn.Right ? Xe.colStart - 1 >= 0 ? Xe.colStart = Jt.getColIndex(Be.x - (q - Be.width)) : z = !0 : Re === Wn.Center && Xe.colEnd + 1 < an.colEnd && Xe.colStart - 1 >= 0 ? (Xe.colStart = Jt.getColIndex(Be.x - (q - Be.width) / 2), Xe.colEnd = Jt.getColIndex(Be.x + Be.width + (q - Be.width) / 2)) : z = !0, z || (Be = S.getRangeCoordsBounds(Xe));
|
|
1638
1638
|
}
|
|
1639
1639
|
}
|
|
1640
1640
|
Be.height = gt.height, pe !== void 0 && (Be.height = Math.max(pe + 1, gt.height));
|
|
@@ -1657,8 +1657,8 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1657
1657
|
}
|
|
1658
1658
|
}, [l]), k = T((S) => {
|
|
1659
1659
|
R(!1), a?.(S.coords), N();
|
|
1660
|
-
}, [a]), u = J(null), C = J(null), ee = J(null), W = J([]), [A,
|
|
1661
|
-
S && W.current.push(S),
|
|
1660
|
+
}, [a]), u = J(null), C = J(null), ee = J(null), W = J([]), [A, K] = Qo((S) => S + 1, 0), N = O((S) => {
|
|
1661
|
+
S && W.current.push(S), K();
|
|
1662
1662
|
}, []), xe = T((S) => {
|
|
1663
1663
|
if (S.defaultPrevented || S.isSynthetic || !t) return;
|
|
1664
1664
|
const ue = t?.getCellCoordsFromClient(S.clientX, S.clientY);
|
|
@@ -1709,7 +1709,7 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1709
1709
|
te.push(Lr(pt));
|
|
1710
1710
|
}
|
|
1711
1711
|
})(W.current), u.current, u.current;
|
|
1712
|
-
let
|
|
1712
|
+
let q = u.current;
|
|
1713
1713
|
if (u.current) {
|
|
1714
1714
|
if (u.current.isDone) u.current = null;
|
|
1715
1715
|
else if (u.current.isSubmitted || u.current.isCancelled) {
|
|
@@ -1766,7 +1766,7 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1766
1766
|
}
|
|
1767
1767
|
}
|
|
1768
1768
|
}
|
|
1769
|
-
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 && q && 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(() => {
|
|
1770
1770
|
t && u.current?.coords && t.scrollCellCoordsIntoView(u.current.coords);
|
|
1771
1771
|
})));
|
|
1772
1772
|
}, [A]), st(() => {
|
|
@@ -1780,10 +1780,10 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1780
1780
|
return { overlay: T((S) => {
|
|
1781
1781
|
if (!u.current || u.current.isEditorClosed) return u.current, null;
|
|
1782
1782
|
u.current.coords;
|
|
1783
|
-
let ue = le(S, u.current.coords, We, ht, E, M),
|
|
1784
|
-
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), q = !0;
|
|
1784
|
+
ue && ue.width !== 0 && ue.height !== 0 || (ue = { x: 0, y: 0, width: We, height: We }, q = !1);
|
|
1785
1785
|
const pe = S.getZoom(), te = { containerBounds: { x: 0, y: 0, width: ue.width / pe, height: ue.height / pe }, setNaturalDimensions: L, zoom: pe };
|
|
1786
|
-
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: q, getCellEditor: _e, propsEditor: te, alignment: M, ...m }, "editor:" + u.current.uuid);
|
|
1787
1787
|
}, [o, E, A, We, ht, M, x, f]), startEdit: O((S) => {
|
|
1788
1788
|
N({ eventType: "start", startEvent: S });
|
|
1789
1789
|
}, []), submitEdit: O(() => {
|
|
@@ -1809,15 +1809,15 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1809
1809
|
const ee = u.nativeEvent.shiftKey, W = u.nativeEvent.ctrlKey || u.nativeEvent.metaKey;
|
|
1810
1810
|
if (d?.(u, C) === !1) return;
|
|
1811
1811
|
X?.(), _.current = !0;
|
|
1812
|
-
const A = t.current?.getViewFromClient(u.nativeEvent.clientX, u.nativeEvent.clientY),
|
|
1812
|
+
const A = t.current?.getViewFromClient(u.nativeEvent.clientX, u.nativeEvent.clientY), K = ((N, xe) => n === Nt ? { ...N, rowIndex: xe.rowStart } : { ...N, colIndex: xe.colStart })(C, A.getVisibleRangeCoords());
|
|
1813
1813
|
if (ee) oe(C);
|
|
1814
1814
|
else {
|
|
1815
1815
|
if (W) return ((N, xe = N, G) => {
|
|
1816
1816
|
ae.current = le(N), R.current = $(xe), E(ae.current, R.current, G);
|
|
1817
|
-
})(C, C,
|
|
1817
|
+
})(C, C, K), void (l && U(K, !0));
|
|
1818
1818
|
((N, xe = N, G) => {
|
|
1819
1819
|
ae.current = le(N), R.current = $(xe), f(ae.current, R.current, G);
|
|
1820
|
-
})(C, C,
|
|
1820
|
+
})(C, C, K), oe(C), l && U(K, !0);
|
|
1821
1821
|
}
|
|
1822
1822
|
}, onPointerMoveOrWait: Ct.throttle((u) => {
|
|
1823
1823
|
if (!_.current || !e?.current) return;
|
|
@@ -1833,7 +1833,7 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1833
1833
|
}, Ye = (e, t, n) => {
|
|
1834
1834
|
if (!e) return t;
|
|
1835
1835
|
let o = t;
|
|
1836
|
-
const r = n ===
|
|
1836
|
+
const r = n === qe || n === lt;
|
|
1837
1837
|
for (; ; ) {
|
|
1838
1838
|
const i = e(o, !r);
|
|
1839
1839
|
if (i === 0) return o;
|
|
@@ -1863,7 +1863,7 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1863
1863
|
for (; !a && l > i; ) l = Ye(n, Math.max(--l, i), o), a = t({ rowIndex: l, colIndex: s });
|
|
1864
1864
|
return l;
|
|
1865
1865
|
}
|
|
1866
|
-
case
|
|
1866
|
+
case qe: {
|
|
1867
1867
|
s = Ye(n, Math.min(s + 1, i), o);
|
|
1868
1868
|
let a = t({ rowIndex: l, colIndex: s });
|
|
1869
1869
|
for (; !a && s < i; ) s = Ye(n, Math.min(++s, i), o), a = t({ rowIndex: l, colIndex: s });
|
|
@@ -1893,7 +1893,7 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1893
1893
|
for (; a && l > i; ) l = Ye(n, Math.max(--l, i), o), a = t?.({ rowIndex: l, colIndex: s });
|
|
1894
1894
|
return t?.({ rowIndex: l, colIndex: s }) ? l : l + 1;
|
|
1895
1895
|
}
|
|
1896
|
-
case
|
|
1896
|
+
case qe: {
|
|
1897
1897
|
s = Ye(n, Math.min(s + 1, i), o);
|
|
1898
1898
|
let a = t?.({ rowIndex: l, colIndex: s });
|
|
1899
1899
|
for (; a && s < i; ) s = Ye(n, Math.min(++s, i), o), a = t?.({ rowIndex: l, colIndex: s });
|
|
@@ -1908,10 +1908,10 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1908
1908
|
default:
|
|
1909
1909
|
return null;
|
|
1910
1910
|
}
|
|
1911
|
-
},
|
|
1911
|
+
}, Kl = (e, t, n, o, r, i) => {
|
|
1912
1912
|
if (!t) return i;
|
|
1913
1913
|
let l, { rowIndex: s, colIndex: a } = e;
|
|
1914
|
-
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 === qe ? l = { rowIndex: s, colIndex: a + 1 } : o === ot && (l = { rowIndex: s, colIndex: a - 1 });
|
|
1915
1915
|
const d = t(e), g = t(l);
|
|
1916
1916
|
var m, f;
|
|
1917
1917
|
return (f = g, !(m = d) && !f || !m && f || m && !f ? Nl : Ul)(e, t, n, o, !1, i) ?? i;
|
|
@@ -1919,13 +1919,13 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1919
1919
|
if (n - t >= r - o) return o;
|
|
1920
1920
|
let l = o;
|
|
1921
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)));
|
|
1922
|
-
}, 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 = qe, n, o, r, i = null) => {
|
|
1923
1923
|
if (i && Z.isEqualSelectionCoords(i, e)) return e;
|
|
1924
1924
|
const l = e.ranges[e.rangeIndex];
|
|
1925
1925
|
if (!Z.isRangesIntersect({ rowStart: e.cell.rowIndex, colStart: e.cell.colIndex, rowEnd: e.cell.rowIndex, colEnd: e.cell.colIndex }, l)) return e;
|
|
1926
1926
|
let s = { ...e.cell }, a = e.rangeIndex;
|
|
1927
1927
|
switch (t) {
|
|
1928
|
-
case
|
|
1928
|
+
case qe:
|
|
1929
1929
|
s.colIndex = Ye(r, s.colIndex + 1, t);
|
|
1930
1930
|
break;
|
|
1931
1931
|
case ot:
|
|
@@ -1948,14 +1948,14 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1948
1948
|
s = { colIndex: x.colEnd, rowIndex: x.rowEnd };
|
|
1949
1949
|
}
|
|
1950
1950
|
};
|
|
1951
|
-
if (t ===
|
|
1951
|
+
if (t === qe && s.colIndex > l.colEnd && s.rowIndex === l.rowEnd) d(!0);
|
|
1952
1952
|
else if (t === ot && s.colIndex < l.colStart && s.rowIndex === l.rowStart) d(!1);
|
|
1953
1953
|
else if (t === lt && s.colIndex === l.colEnd && s.rowIndex > l.rowEnd) d(!0);
|
|
1954
1954
|
else if (t === it && s.colIndex === l.colStart && s.rowIndex < l.rowStart) d(!1);
|
|
1955
1955
|
else {
|
|
1956
1956
|
let f = s.rowIndex, x = s.colIndex;
|
|
1957
1957
|
switch (t) {
|
|
1958
|
-
case
|
|
1958
|
+
case qe:
|
|
1959
1959
|
x > l.colEnd && (f = Ye(o, f + 1, t), x = l.colStart, f > l.rowEnd && (f = l.rowStart));
|
|
1960
1960
|
break;
|
|
1961
1961
|
case ot:
|
|
@@ -1974,10 +1974,10 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1974
1974
|
const f = Z.intersectRanges(g, l);
|
|
1975
1975
|
f && (g = f);
|
|
1976
1976
|
}
|
|
1977
|
-
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, qe), rowEnd: Ye(o, g.rowEnd, it), colEnd: Ye(r, g.colEnd, ot) };
|
|
1978
1978
|
if (m.rowStart !== s.rowIndex || m.colStart !== s.colIndex) {
|
|
1979
1979
|
switch (t) {
|
|
1980
|
-
case
|
|
1980
|
+
case qe:
|
|
1981
1981
|
e.ranges[a].colStart === m.colStart && e.ranges[a].colEnd === m.colEnd && (s.rowIndex = m.rowEnd), s.colIndex = m.colEnd;
|
|
1982
1982
|
break;
|
|
1983
1983
|
case ot:
|
|
@@ -1994,7 +1994,7 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1994
1994
|
return { ranges: e.ranges, cell: s, rangeIndex: a };
|
|
1995
1995
|
}, $r = (e, t) => {
|
|
1996
1996
|
let n, o = 0, r = 0;
|
|
1997
|
-
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 = qe, 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 };
|
|
1998
1998
|
}, go = (e, t = !1, n, o) => {
|
|
1999
1999
|
if (!n) return 0;
|
|
2000
2000
|
const r = !t, i = r ? 1 : -1;
|
|
@@ -2017,7 +2017,7 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
2017
2017
|
}, Fr = (e, t, n) => {
|
|
2018
2018
|
const o = e.getColOffset(t.colStart) + (n?.left ?? 0), r = e.getRowOffset(t.rowStart) + (n?.top ?? 0);
|
|
2019
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 };
|
|
2020
|
-
},
|
|
2020
|
+
}, ql = (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) => {
|
|
2021
2021
|
const { linePoints: t, bounds: n, pathProps: o, style: r, ...i } = e;
|
|
2022
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 }) });
|
|
2023
2023
|
}, Yl = (e) => {
|
|
@@ -2105,7 +2105,7 @@ function Bo(e, t) {
|
|
|
2105
2105
|
if (typeof e == "function") return e(t);
|
|
2106
2106
|
e && (e.current = t);
|
|
2107
2107
|
}
|
|
2108
|
-
var Jl = parseInt(
|
|
2108
|
+
var Jl = parseInt(Kr.split(".")[0], 10) >= 19 ? function(e) {
|
|
2109
2109
|
return (t) => {
|
|
2110
2110
|
const n = [];
|
|
2111
2111
|
for (const o of e) {
|
|
@@ -2142,44 +2142,44 @@ const Go = Dt(Ut((e, t) => {
|
|
|
2142
2142
|
case "r":
|
|
2143
2143
|
W = { colIndex: n.colStart, rowIndex: n.rowEnd };
|
|
2144
2144
|
}
|
|
2145
|
-
let
|
|
2145
|
+
let K = o.getRangeCoordsBounds(A ? { rowStart: A.rowIndex, colStart: A.colIndex, rowEnd: A.rowIndex, colEnd: A.colIndex } : n);
|
|
2146
2146
|
const N = o.getBounds(), xe = o.getViewportSize(), G = N.x, He = N.y, Ue = xe.width, We = xe.height;
|
|
2147
2147
|
switch (r) {
|
|
2148
2148
|
case "tl":
|
|
2149
2149
|
break;
|
|
2150
2150
|
case "br":
|
|
2151
|
-
|
|
2151
|
+
K.x = K.x + K.width, K.y = K.y + K.height;
|
|
2152
2152
|
break;
|
|
2153
2153
|
case "t":
|
|
2154
|
-
|
|
2154
|
+
K.x = Ue / 2 - G;
|
|
2155
2155
|
break;
|
|
2156
2156
|
case "b":
|
|
2157
|
-
|
|
2157
|
+
K.x = Ue / 2 - G, K.y = K.y + K.height;
|
|
2158
2158
|
break;
|
|
2159
2159
|
case "l":
|
|
2160
|
-
|
|
2160
|
+
K.y = We / 2 - He;
|
|
2161
2161
|
break;
|
|
2162
2162
|
case "r":
|
|
2163
|
-
|
|
2163
|
+
K.x = K.x + K.width, K.y = We / 2 - He;
|
|
2164
2164
|
}
|
|
2165
|
-
const ht = o.toClipBounds(
|
|
2166
|
-
return !ht || ht.width <= 0 || ht.height <= 0 ||
|
|
2165
|
+
const ht = o.toClipBounds(K, 0);
|
|
2166
|
+
return !ht || ht.width <= 0 || ht.height <= 0 || K.x < 0 || K.y < 0 || K.x > Ue || K.y > We ? { bounds: null, coordsAnchor: null, coordsPivot: null, key: null } : { bounds: K, coordsAnchor: null, coordsPivot: W, key: "touchSelect-" + o.getAnchor() + "-" + r };
|
|
2167
2167
|
}, [n, o, r]), oe = J(null), be = On(Ee(() => {
|
|
2168
2168
|
const W = (A) => r === "t" || r === "b" ? { ...A, colIndex: void 0 } : r === "l" || r === "r" ? { ...A, rowIndex: void 0 } : A;
|
|
2169
|
-
return { processTouch: !0, consumeTouch: !0, onPointerDown: (A,
|
|
2169
|
+
return { processTouch: !0, consumeTouch: !0, onPointerDown: (A, K) => {
|
|
2170
2170
|
const N = W(o.getCellCoordsFromClient(A.clientX, A.clientY));
|
|
2171
|
-
return oe.current = { coordsPivot: le }, R?.(r), m.onSelectionPointerDown(A,
|
|
2172
|
-
}, onPointerMoveOrWait: (A,
|
|
2171
|
+
return oe.current = { coordsPivot: le }, R?.(r), m.onSelectionPointerDown(A, K, o, N, le, !1, !0);
|
|
2172
|
+
}, onPointerMoveOrWait: (A, K, N) => {
|
|
2173
2173
|
const xe = W(o.getCellCoordsFromClient(A.clientX, A.clientY));
|
|
2174
|
-
return m.onSelectionPointerMoveOrWait(A,
|
|
2175
|
-
}, onPointerUp: (A,
|
|
2174
|
+
return m.onSelectionPointerMoveOrWait(A, K, N, o, xe, oe.current?.coordsPivot, !0, !0);
|
|
2175
|
+
}, onPointerUp: (A, K, N) => (oe.current = null, _?.(r), m.onPointerUp(A, K, N)) };
|
|
2176
2176
|
}, [m, n, o, r])), [U, { y: H, x: X }] = _i(), k = J(null), { getPortalContainer: u } = gi(), [C, ee] = Je(null);
|
|
2177
2177
|
return st(() => {
|
|
2178
2178
|
const W = k.current?.getBoundingClientRect();
|
|
2179
2179
|
if (!W || !L) return void ee(null);
|
|
2180
|
-
let A = 0,
|
|
2181
|
-
for (; N; ) A += N.scrollLeft,
|
|
2182
|
-
ee(
|
|
2180
|
+
let A = 0, K = 0, N = I;
|
|
2181
|
+
for (; N; ) A += N.scrollLeft, K += N.scrollTop, N = M && N === M.parentElement ? null : N.parentElement;
|
|
2182
|
+
ee(qr(Y("div", { className: En("touch-select-handle", g), ref: t, style: { position: "absolute", left: A + (W?.x ?? 0) - (a + s) / 2, top: K + (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(), $));
|
|
2183
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;
|
|
2184
2184
|
}));
|
|
2185
2185
|
Go.displayName = "TouchSelectHandle";
|
|
@@ -2190,8 +2190,8 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2190
2190
|
}, lo = (e, t, n) => {
|
|
2191
2191
|
const o = e.getVisibleRangeCoords(), r = e.getScrollOrientation();
|
|
2192
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);
|
|
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: _ =
|
|
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]),
|
|
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: _ = Kl, 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: K = 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]), q = 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);
|
|
2195
2195
|
nn(Ct.throttle(() => {
|
|
2196
2196
|
Be((c) => {
|
|
2197
2197
|
Qe.current = !0;
|
|
@@ -2224,11 +2224,11 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2224
2224
|
const b = { ranges: y, rangeIndex: V, cell: w };
|
|
2225
2225
|
return Z.isEqualSelectionCoords(b, h) ? h : b;
|
|
2226
2226
|
});
|
|
2227
|
-
}, [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, Kt] = Je(null), vt = J(null), Vt = J(null), [Cn, un] = Je(null), Ne = J(null), Q = J(null), et = J(U);
|
|
2228
2228
|
st(() => {
|
|
2229
2229
|
et.current = U;
|
|
2230
2230
|
}, [U]);
|
|
2231
|
-
const
|
|
2231
|
+
const Ke = T((c, h = { inline: "nearest", block: "nearest" }) => {
|
|
2232
2232
|
let { rowIndex: w, colIndex: p } = c;
|
|
2233
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);
|
|
2234
2234
|
}, [z]), dt = O((c) => {
|
|
@@ -2291,11 +2291,11 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2291
2291
|
if (b && Z.indexOfCoords(p, z.ranges) !== -1 && ne) {
|
|
2292
2292
|
vt.current = p;
|
|
2293
2293
|
const ie = Ie(p, p);
|
|
2294
|
-
return Vt.current = ie,
|
|
2294
|
+
return Vt.current = ie, Kt(ie), De;
|
|
2295
2295
|
}
|
|
2296
2296
|
return Ae(p), De;
|
|
2297
2297
|
}
|
|
2298
|
-
le &&
|
|
2298
|
+
le && Ke(p), de && z.ranges.length === 0 || tt(p);
|
|
2299
2299
|
}, onPointerMoveOrWait: Ct.throttle((c, h) => {
|
|
2300
2300
|
if (!e?.current || c.pointerType === "touch" || c.type === "touchmove" || !nt.current) return;
|
|
2301
2301
|
const w = nt.current.anchor;
|
|
@@ -2305,7 +2305,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2305
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 };
|
|
2306
2306
|
if (dt(b) || dt(he)) return;
|
|
2307
2307
|
const ne = Ie(b, he);
|
|
2308
|
-
Vt.current = ne,
|
|
2308
|
+
Vt.current = ne, Kt(ne);
|
|
2309
2309
|
} else rt(y);
|
|
2310
2310
|
kt.current = h, lo(p, y, e);
|
|
2311
2311
|
}
|
|
@@ -2327,7 +2327,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2327
2327
|
}
|
|
2328
2328
|
if (!vt.current) return;
|
|
2329
2329
|
const h = Vt.current;
|
|
2330
|
-
vt.current = null, Vt.current = null,
|
|
2330
|
+
vt.current = null, Vt.current = null, Kt(null), Be((w) => {
|
|
2331
2331
|
if (Qe.current = !1, (w = Yt(w)).ranges.length === 0) return w;
|
|
2332
2332
|
let p = [], y = -1, V = w.cell;
|
|
2333
2333
|
for (let he = 0; he < w.ranges.length; he++) {
|
|
@@ -2364,11 +2364,11 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2364
2364
|
if (B && Z.indexOfCoords(re, z.ranges) !== -1 && ie) {
|
|
2365
2365
|
vt.current = re;
|
|
2366
2366
|
const Te = Ie(re, re);
|
|
2367
|
-
return Vt.current = Te,
|
|
2367
|
+
return Vt.current = Te, Kt(Te), Pe;
|
|
2368
2368
|
}
|
|
2369
2369
|
return Ae(re), Pe;
|
|
2370
2370
|
}
|
|
2371
|
-
V &&
|
|
2371
|
+
V && Ke(re), Rt && z.ranges.length === 0 || tt(re);
|
|
2372
2372
|
}, onSelectionPointerMoveOrWait: (c, h, w, p, y, V = z.cell, b = !0, he = !1) => {
|
|
2373
2373
|
if (!e?.current || (c.stopPropagation(), c.preventDefault(), c.stopImmediatePropagation(), !nt.current)) return;
|
|
2374
2374
|
const ne = nt.current.anchor;
|
|
@@ -2378,7 +2378,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2378
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 };
|
|
2379
2379
|
if (dt(de) || dt(ie)) return;
|
|
2380
2380
|
const _t = Ie(de, ie);
|
|
2381
|
-
Vt.current = _t,
|
|
2381
|
+
Vt.current = _t, Kt(_t);
|
|
2382
2382
|
} else rt(we, V, he);
|
|
2383
2383
|
b && lo(re, we, e);
|
|
2384
2384
|
}
|
|
@@ -2391,7 +2391,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2391
2391
|
}
|
|
2392
2392
|
if (!vt.current) return;
|
|
2393
2393
|
const h = Vt.current;
|
|
2394
|
-
vt.current = null, Vt.current = null,
|
|
2394
|
+
vt.current = null, Vt.current = null, Kt(null), Be((w) => {
|
|
2395
2395
|
if (Qe.current = !1, (w = Yt(w)).ranges.length === 0) return w;
|
|
2396
2396
|
let p = [], y = -1, V = w.cell;
|
|
2397
2397
|
for (let he = 0; he < w.ranges.length; he++) {
|
|
@@ -2423,7 +2423,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2423
2423
|
case ot:
|
|
2424
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 };
|
|
2425
2425
|
break;
|
|
2426
|
-
case
|
|
2426
|
+
case qe:
|
|
2427
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 };
|
|
2428
2428
|
}
|
|
2429
2429
|
}
|
|
@@ -2436,7 +2436,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2436
2436
|
Q.current.colIndex >= b.colStart && Q.current.colIndex <= b.colEnd && (ne = Q.current.colIndex);
|
|
2437
2437
|
break;
|
|
2438
2438
|
case ot:
|
|
2439
|
-
case
|
|
2439
|
+
case qe:
|
|
2440
2440
|
Q.current.rowIndex >= b.rowStart && Q.current.rowIndex <= b.rowEnd && (he = Q.current.rowIndex);
|
|
2441
2441
|
}
|
|
2442
2442
|
if (!p) {
|
|
@@ -2450,7 +2450,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2450
2450
|
case ot:
|
|
2451
2451
|
ne = Ye(gt, Math.max(b.colStart - 1, re.left), c);
|
|
2452
2452
|
break;
|
|
2453
|
-
case
|
|
2453
|
+
case qe:
|
|
2454
2454
|
ne = Ye(gt, Math.min(b.colEnd + 1, re.right), c);
|
|
2455
2455
|
}
|
|
2456
2456
|
if (w) switch (c) {
|
|
@@ -2463,7 +2463,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2463
2463
|
case ot:
|
|
2464
2464
|
ne = _({ ...V, rowIndex: z.cell.rowIndex }, te, gt, c, !1, Math.max(re.left, gt(re.left, !1)));
|
|
2465
2465
|
break;
|
|
2466
|
-
case
|
|
2466
|
+
case qe:
|
|
2467
2467
|
ne = _({ ...V, rowIndex: z.cell.rowIndex }, te, gt, c, !1, Math.min(re.right, re.right - gt(re.right, !0)));
|
|
2468
2468
|
}
|
|
2469
2469
|
}
|
|
@@ -2480,7 +2480,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2480
2480
|
case ot:
|
|
2481
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) };
|
|
2482
2482
|
break;
|
|
2483
|
-
case
|
|
2483
|
+
case qe:
|
|
2484
2484
|
B = n.getColOffset(ne), ne = Math.min(re.right, n.getColIndex(B + p)), we = { left: n.getColOffset(ne) - (B - e.current.getScrollPosition().left) };
|
|
2485
2485
|
}
|
|
2486
2486
|
}
|
|
@@ -2491,9 +2491,9 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2491
2491
|
else {
|
|
2492
2492
|
if (h && Ne.current) {
|
|
2493
2493
|
const B = _e();
|
|
2494
|
-
if (c ===
|
|
2494
|
+
if (c === qe && 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;
|
|
2495
2495
|
}
|
|
2496
|
-
c === ot || c ===
|
|
2496
|
+
c === ot || c === qe ? Ke({ colIndex: De.colIndex }) : c !== it && c !== lt || Ke({ rowIndex: De.rowIndex });
|
|
2497
2497
|
}
|
|
2498
2498
|
}, [z, A]), ln = T((c) => {
|
|
2499
2499
|
if (!e.current) return;
|
|
@@ -2505,7 +2505,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2505
2505
|
Qe.current = !1, p = Yt(p);
|
|
2506
2506
|
const y = { ...p, cell: w.cell, rangeIndex: w.rangeIndex };
|
|
2507
2507
|
return Z.isEqualSelectionCoords(y, p) ? p : y;
|
|
2508
|
-
}), w.cell &&
|
|
2508
|
+
}), w.cell && Ke(w.cell);
|
|
2509
2509
|
}, [z, A]), vo = O(() => {
|
|
2510
2510
|
const c = _e();
|
|
2511
2511
|
rt({ rowIndex: c.top }, { rowIndex: c.bottom });
|
|
@@ -2513,43 +2513,43 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2513
2513
|
const c = _e();
|
|
2514
2514
|
rt({ colIndex: c.left }, { colIndex: c.right });
|
|
2515
2515
|
}, []), xn = T(() => {
|
|
2516
|
-
z.cell && e?.current &&
|
|
2517
|
-
}, [z.cell]),
|
|
2516
|
+
z.cell && e?.current && Ke(z.cell);
|
|
2517
|
+
}, [z.cell]), qn = O((c = !1) => {
|
|
2518
2518
|
const h = { rowIndex: _e().top };
|
|
2519
|
-
c ? rt(h) : tt(h),
|
|
2519
|
+
c ? rt(h) : tt(h), Ke(h);
|
|
2520
2520
|
}, []), Yn = O((c = !1) => {
|
|
2521
2521
|
const h = { rowIndex: _e().bottom };
|
|
2522
|
-
c ? rt(h) : tt(h),
|
|
2522
|
+
c ? rt(h) : tt(h), Ke(h);
|
|
2523
2523
|
}, []), Dn = O((c = !1) => {
|
|
2524
2524
|
const h = { colIndex: _e().left };
|
|
2525
|
-
c ? rt(h) : tt(h),
|
|
2525
|
+
c ? rt(h) : tt(h), Ke(h);
|
|
2526
2526
|
}, []), Mn = O((c = !1) => {
|
|
2527
2527
|
const h = _e(), w = { rowIndex: h.top, colIndex: h.left };
|
|
2528
|
-
c ? rt(w) : tt(w),
|
|
2528
|
+
c ? rt(w) : tt(w), Ke(w);
|
|
2529
2529
|
}, []), zn = O((c = !1) => {
|
|
2530
2530
|
const h = _e(), w = { colIndex: L?.()?.colEnd ?? h.right };
|
|
2531
|
-
c ? rt(w) : tt(w),
|
|
2531
|
+
c ? rt(w) : tt(w), Ke(w);
|
|
2532
2532
|
}, [L]), vn = O((c = !1) => {
|
|
2533
2533
|
const h = _e(), w = { rowIndex: L?.()?.rowEnd ?? h.bottom, colIndex: L?.()?.colEnd ?? h.right };
|
|
2534
|
-
c ? rt(w) : tt(w),
|
|
2534
|
+
c ? rt(w) : tt(w), Ke(w);
|
|
2535
2535
|
}, [L]), An = T((c) => {
|
|
2536
2536
|
if (!e.current || z.ranges.length <= 1) return;
|
|
2537
2537
|
const h = c === ot || c === it;
|
|
2538
2538
|
let w = z.rangeIndex + (h ? -1 : 1);
|
|
2539
2539
|
w < 0 ? w = z.ranges.length - 1 : w > z.ranges.length - 1 && (w = 0);
|
|
2540
|
-
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] }, qe, A, pt, gt);
|
|
2541
2541
|
Be((V) => {
|
|
2542
2542
|
Qe.current = !1, V = Yt(V);
|
|
2543
2543
|
const b = { ...V, cell: y.cell, rangeIndex: w };
|
|
2544
2544
|
return Z.isEqualSelectionCoords(b, V) ? V : b;
|
|
2545
|
-
}), y.cell &&
|
|
2545
|
+
}), y.cell && Ke(y.cell);
|
|
2546
2546
|
}, [z, A]), bo = T(() => {
|
|
2547
2547
|
const c = Ar(z);
|
|
2548
2548
|
Be((h) => {
|
|
2549
2549
|
Qe.current = !1, h = Yt(h);
|
|
2550
2550
|
const w = { ...h, visibleSelection: c };
|
|
2551
2551
|
return Z.isEqualSelectionCoords(w, h) ? h : w;
|
|
2552
|
-
}), c.cell &&
|
|
2552
|
+
}), c.cell && Ke(c.cell);
|
|
2553
2553
|
}, [z, A]), So = T(() => {
|
|
2554
2554
|
if (!e.current || z.ranges.length === 0) return;
|
|
2555
2555
|
const c = z.cell, h = z.ranges[z.rangeIndex], w = Ar({ cell: c, rangeIndex: 0, ranges: [h] }), p = w.ranges[w.rangeIndex];
|
|
@@ -2558,19 +2558,19 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2558
2558
|
V = Yt(V);
|
|
2559
2559
|
const b = { ...V, cell: y };
|
|
2560
2560
|
return Z.isEqualSelectionCoords(b, V) ? V : b;
|
|
2561
|
-
}), y &&
|
|
2561
|
+
}), y && Ke(y);
|
|
2562
2562
|
}, [z, A]), Xn = O((c = !1) => {
|
|
2563
2563
|
ft(lt, c, !1, e.current.getDimensions().containerHeight);
|
|
2564
2564
|
}, []), Qt = O((c = !1) => {
|
|
2565
2565
|
ft(it, c, !1, e.current.getDimensions().containerHeight);
|
|
2566
2566
|
}, []), Gn = O((c = !1) => {
|
|
2567
|
-
ft(
|
|
2567
|
+
ft(qe, c, !1, e.current.getDimensions().containerWidth);
|
|
2568
2568
|
}, []), $n = O((c = !1) => {
|
|
2569
2569
|
ft(ot, c, !1, e.current.getDimensions().containerWidth);
|
|
2570
2570
|
}, []), Zn = O(() => {
|
|
2571
2571
|
ln(ot);
|
|
2572
2572
|
}, []), Jn = O(() => {
|
|
2573
|
-
ln(
|
|
2573
|
+
ln(qe);
|
|
2574
2574
|
}, []), Eo = O(() => {
|
|
2575
2575
|
ln(it);
|
|
2576
2576
|
}, []), _o = O(() => {
|
|
@@ -2578,7 +2578,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2578
2578
|
}, []), Bn = O(() => {
|
|
2579
2579
|
An(ot);
|
|
2580
2580
|
}, []), Io = O(() => {
|
|
2581
|
-
An(
|
|
2581
|
+
An(qe);
|
|
2582
2582
|
}, []), Co = O(() => {
|
|
2583
2583
|
So();
|
|
2584
2584
|
}, []), Qn = O(() => {
|
|
@@ -2590,13 +2590,13 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2590
2590
|
}, []), D = O(() => {
|
|
2591
2591
|
ft(ot, !0, !0);
|
|
2592
2592
|
}, []), F = O(() => {
|
|
2593
|
-
ft(
|
|
2593
|
+
ft(qe, !1, !1);
|
|
2594
2594
|
}, []), j = O(() => {
|
|
2595
|
-
ft(
|
|
2595
|
+
ft(qe, !0, !1);
|
|
2596
2596
|
}, []), fe = O(() => {
|
|
2597
|
-
ft(
|
|
2597
|
+
ft(qe, !1, !0);
|
|
2598
2598
|
}, []), se = O(() => {
|
|
2599
|
-
ft(
|
|
2599
|
+
ft(qe, !0, !0);
|
|
2600
2600
|
}, []), ve = O(() => {
|
|
2601
2601
|
ft(it, !1, !1);
|
|
2602
2602
|
}, []), ye = O(() => {
|
|
@@ -2625,7 +2625,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2625
2625
|
return !1;
|
|
2626
2626
|
})(z.ranges, c.top, c.left, c.bottom, c.right);
|
|
2627
2627
|
}, [$, z.ranges]), yt = O((c, h = !0) => {
|
|
2628
|
-
Ne.current = c, wt(c), h && c && e?.current &&
|
|
2628
|
+
Ne.current = c, wt(c), h && c && e?.current && Ke(c);
|
|
2629
2629
|
}, []), ge = T((c = !0) => {
|
|
2630
2630
|
const h = on.current;
|
|
2631
2631
|
if (!ke.current?.cell) return;
|
|
@@ -2658,8 +2658,8 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2658
2658
|
if (!b) return;
|
|
2659
2659
|
const he = V.length > 0, ne = he ? V[V.length - 1] : A(ke.current.cell);
|
|
2660
2660
|
if (!b) return;
|
|
2661
|
-
const re = b.rowStart < ne.rowStart ? it : b.rowEnd > ne.rowEnd ? lt : b.colEnd > ne.colEnd ?
|
|
2662
|
-
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 ? qe : 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 === qe && (b = { ...ne, colEnd: Math.min(we.right, b.colEnd) }), re === lt && (b = { ...ne, rowEnd: Math.min(we.bottom, b.rowEnd) });
|
|
2663
2663
|
const De = $r(ne, b);
|
|
2664
2664
|
if (!H?.(ne)) {
|
|
2665
2665
|
let de;
|
|
@@ -2669,7 +2669,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2669
2669
|
if (Rt === ot) {
|
|
2670
2670
|
const St = ie.colEnd + 1 - ie.colStart;
|
|
2671
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);
|
|
2672
|
-
} else if (Rt ===
|
|
2672
|
+
} else if (Rt === qe) {
|
|
2673
2673
|
const St = ie.colEnd + 1 - ie.colStart;
|
|
2674
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);
|
|
2675
2675
|
} else if (Rt === it) {
|
|
@@ -2685,7 +2685,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2685
2685
|
if (he && Z.isRangeWithinRange(b, ne) && (b = null), !Z.isEqualRanges(b, on.current)) {
|
|
2686
2686
|
if (dn(b), on.current = b, !b) {
|
|
2687
2687
|
try {
|
|
2688
|
-
|
|
2688
|
+
q?.();
|
|
2689
2689
|
} catch {
|
|
2690
2690
|
}
|
|
2691
2691
|
return void pe?.();
|
|
@@ -2727,7 +2727,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2727
2727
|
} }), [Ce]), Oe = On(ct), Et = Ee(() => ({ onPointerDown: Oe }), [Oe]), bt = J(null), $t = Ee(() => {
|
|
2728
2728
|
const c = Z.isEqualSelectionCoords(z, bt.current) ? bt.current : z;
|
|
2729
2729
|
return bt.current = c, c;
|
|
2730
|
-
}, [z]),
|
|
2730
|
+
}, [z]), qt = O((c) => {
|
|
2731
2731
|
let h = null, w = "br";
|
|
2732
2732
|
const p = [], y = { stroke: I, fill: xe, strokeWidth: 0.5 }, V = (de, ie, _t) => {
|
|
2733
2733
|
const B = c.toClipBounds(c.getRangeCoordsBounds(de), tn);
|
|
@@ -2754,7 +2754,7 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2754
2754
|
if (b.ranges.length === 1) {
|
|
2755
2755
|
const Te = c.toClipBounds(c.getRangeCoordsBounds(ie), tn);
|
|
2756
2756
|
if (Te) {
|
|
2757
|
-
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 - (K / 2 + 1), y: Te.height > 1 ? Te.y : Te.y - (K / 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: K, ...Et }));
|
|
2758
2758
|
const Me = B;
|
|
2759
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 }));
|
|
2760
2760
|
}
|
|
@@ -2804,31 +2804,31 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2804
2804
|
return Y("div", { children: De }, "selection");
|
|
2805
2805
|
}, [$t, ze, E, jt, W, Ce, _e, I, G, xe, He, Ue, We, ht, Cn]), Ot = Ee(() => {
|
|
2806
2806
|
const c = () => e.current;
|
|
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." }, () =>
|
|
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." }, () => qn(!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] } }, () => {
|
|
2808
2808
|
rn(), yt(z.cell, !0);
|
|
2809
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)];
|
|
2810
2810
|
}, []);
|
|
2811
2811
|
return Ee(() => {
|
|
2812
2812
|
t?.addCommands(Ot, !0);
|
|
2813
|
-
}, [t]), { selection: $t, setSelectionCell: yt, setSelectionRanges: Xe, overlay:
|
|
2813
|
+
}, [t]), { selection: $t, setSelectionCell: yt, setSelectionRanges: Xe, overlay: qt, cursor: an, onPointerDown: mo, clearLastSelection: Ge, newSelection: tt, modifySelection: rt, appendSelection: Ae, clearSelections: rn, isEntire: Pt, navigate: ft, navigateSelection: ln };
|
|
2814
2814
|
};
|
|
2815
2815
|
function ao(e, t) {
|
|
2816
2816
|
if (!e) throw new Error("Invariant failed");
|
|
2817
2817
|
}
|
|
2818
|
-
const Wr = { "sheetxl-grid": "_sheetxl-
|
|
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:
|
|
2818
|
+
const Wr = { "sheetxl-grid": "_sheetxl-grid_h9wwa_7" }, 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: K, hiddenCellAt: N, getVisibleCells: xe, zoom: G = 1, enableMouseWheel: He = !0, onWheelScroll: Ue, getCellCoordsAsRangeCoords: We = Z.cellToRange, scrollPoint: ht = ts, style: _e = {}, ...S } = e;
|
|
2820
2820
|
ao(oe), ao(!e?.children);
|
|
2821
|
-
const ue = T(f, [f]),
|
|
2821
|
+
const ue = T(f, [f]), q = 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(() => {
|
|
2822
2822
|
const v = g || dn;
|
|
2823
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) };
|
|
2824
|
-
}, [dn, g, G]),
|
|
2824
|
+
}, [dn, g, G]), Kt = (v, P, D) => {
|
|
2825
2825
|
const F = (P?.left ?? 0) + 0, j = (P?.top ?? 0) + 0;
|
|
2826
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) };
|
|
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(
|
|
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(K ?? Cn, [K]), 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) => {
|
|
2828
2828
|
Ct.canUseDOM && setTimeout(() => {
|
|
2829
2829
|
at.current?.focus({ preventScroll: !0, ...v });
|
|
2830
2830
|
}, 0);
|
|
2831
|
-
}, []),
|
|
2831
|
+
}, []), Ke = O((v) => at.current?.contains(v) || pt.current?.contains(v), []);
|
|
2832
2832
|
st(() => {
|
|
2833
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 })));
|
|
2834
2834
|
}, [wt, Xe]);
|
|
@@ -2838,11 +2838,11 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_11irg_13" }, ts = Object.freeze({ to
|
|
|
2838
2838
|
typeof L == "number" ? P = L : (P = L.index ?? 0, D = (L.scrollOffset ?? 0) * G);
|
|
2839
2839
|
const F = D, j = ze.getRowOffset(P), fe = j - F;
|
|
2840
2840
|
if (P > 0) {
|
|
2841
|
-
const ut =
|
|
2841
|
+
const ut = Kt(ze, { top: D + ze.getRowOffset(0) }), Fe = ze.getRowIndex(F), je = ze.getRowIndex(j - 1);
|
|
2842
2842
|
let mt;
|
|
2843
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 };
|
|
2844
2844
|
}
|
|
2845
|
-
const se = Math.max(0, Q - fe), ve =
|
|
2845
|
+
const se = Math.max(0, Q - fe), ve = Kt(ze, { top: Xe + fe }), ye = ve.getRowIndex(0), ce = ve.getRowIndex(se);
|
|
2846
2846
|
let Ve;
|
|
2847
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;
|
|
2848
2848
|
}, [ze.getRowIndex, ze.getRowOffset, Vt, Q, r, L, Xe, G]), Le = Ee(() => {
|
|
@@ -2851,11 +2851,11 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_11irg_13" }, ts = Object.freeze({ to
|
|
|
2851
2851
|
typeof _ == "number" ? P = _ : (P = _.index ?? 0, D = (_.scrollOffset ?? 0) * G);
|
|
2852
2852
|
const F = D, j = ze.getColOffset(P), fe = j - F;
|
|
2853
2853
|
if (P > 0) {
|
|
2854
|
-
const ut =
|
|
2854
|
+
const ut = Kt(ze, { left: D + ze.getColOffset(0) }), Fe = ze.getColIndex(F), je = ze.getColIndex(j - 1);
|
|
2855
2855
|
let mt;
|
|
2856
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 };
|
|
2857
2857
|
}
|
|
2858
|
-
const se = Math.max(0, Ne - fe), ve =
|
|
2858
|
+
const se = Math.max(0, Ne - fe), ve = Kt(ze, { left: wt + fe }), ye = ve.getColIndex(0), ce = ve.getColIndex(se);
|
|
2859
2859
|
let Ve;
|
|
2860
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;
|
|
2861
2861
|
}, [ze.getColIndex, ze.getColOffset, un, Ne, i, _, wt, G]), rt = J({}), tt = J([]), Ae = Ee(() => {
|
|
@@ -2872,7 +2872,7 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_11irg_13" }, ts = Object.freeze({ to
|
|
|
2872
2872
|
let $e, ct = 0;
|
|
2873
2873
|
return Ze === void 0 || typeof Ze == "number" ? ($e = je(ce), ct = Ze) : $e = Ze, ((Oe, Et, bt = 0) => {
|
|
2874
2874
|
if (Oe.x > Et.width || Oe.y > Et.height) return null;
|
|
2875
|
-
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 }, qt = { 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, qt.left), top: Math.max($t.top, qt.top), bottom: Math.min($t.bottom, qt.bottom), right: Math.min($t.right, qt.right) }, c = { x: Ot.left, y: Ot.top, width: Ot.right - Ot.left, height: Ot.bottom - Ot.top };
|
|
2876
2876
|
return c.height < 0 || c.width < 0 ? null : c;
|
|
2877
2877
|
})(Ce ?? { x: 0, y: 0, width: Fe.width, height: Fe.height }, $e, ct);
|
|
2878
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) => {
|
|
@@ -2898,9 +2898,9 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_11irg_13" }, ts = Object.freeze({ to
|
|
|
2898
2898
|
}, [Ae]);
|
|
2899
2899
|
const kt = T(() => ({ containerWidth: Ne, containerHeight: Q, totalWidth: Mt, totalHeight: nt }), [Ne, Q, ze]);
|
|
2900
2900
|
st(() => {
|
|
2901
|
-
!ke.current && jt.current &&
|
|
2901
|
+
!ke.current && jt.current && q({ top: Xe, left: wt, width: Ne, height: Q, totalWidth: Mt, totalHeight: nt });
|
|
2902
2902
|
}, [Xe, wt, Mt, nt]), st(() => {
|
|
2903
|
-
jt.current &&
|
|
2903
|
+
jt.current && q({ top: Xe, left: wt, width: Ne, height: Q, totalWidth: Mt, totalHeight: nt });
|
|
2904
2904
|
}, [Ne, Q]);
|
|
2905
2905
|
const hn = O((v, P) => {
|
|
2906
2906
|
ao(typeof v == "number" && typeof P == "number");
|
|
@@ -2915,7 +2915,7 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_11irg_13" }, ts = Object.freeze({ to
|
|
|
2915
2915
|
const se = Hr;
|
|
2916
2916
|
for (let ve = 0; !fe && ve < se.length; ve++) {
|
|
2917
2917
|
const ye = Ae[se[ve]];
|
|
2918
|
-
ye &&
|
|
2918
|
+
ye && ql(F, j, ye.getBounds()) && (fe = ye);
|
|
2919
2919
|
}
|
|
2920
2920
|
return fe || (fe = Ae[Xt]), fe;
|
|
2921
2921
|
}, [Ae, We]), ft = T(() => Ae[Xt].getVisibleRangeCoords(), [Ae[Xt]]), ln = J(null), vo = O(() => {
|
|
@@ -2929,19 +2929,19 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_11irg_13" }, ts = Object.freeze({ to
|
|
|
2929
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;
|
|
2930
2930
|
if (Qe.current.left === F && Qe.current.top === j) return;
|
|
2931
2931
|
let fe = null, se = null;
|
|
2932
|
-
Qe.current.left > F ? fe = ot : Qe.current.left < F && (fe =
|
|
2932
|
+
Qe.current.left > F ? fe = ot : Qe.current.left < F && (fe = qe), Qe.current.top > j ? se = it : Qe.current.top < j && (se = lt), Ct.throttle(() => {
|
|
2933
2933
|
z((ve) => {
|
|
2934
2934
|
const ye = { ...ve, left: F, top: j, horizontalScrollDirection: fe, verticalScrollDirection: se };
|
|
2935
2935
|
return Qe.current = ye, ye;
|
|
2936
2936
|
});
|
|
2937
|
-
}, 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 }), q({ left: F, top: j, width: Ne, height: Q, totalWidth: Mt, totalHeight: nt })), vo();
|
|
2938
2938
|
}, [Mt, nt, Ie, Le]);
|
|
2939
2939
|
st(() => {
|
|
2940
2940
|
ke.current || xn({ left: wt, top: Xe });
|
|
2941
2941
|
}, [Mt, Ne, nt, Q]), nn(() => {
|
|
2942
2942
|
ke.current = { left: ht?.left, top: ht?.top }, xn(ke.current);
|
|
2943
2943
|
}, [ht?.left, ht?.top]);
|
|
2944
|
-
const
|
|
2944
|
+
const qn = T((v) => {
|
|
2945
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) };
|
|
2946
2946
|
F && (j.behavior = F), xn(j);
|
|
2947
2947
|
}, [Mt, Ne, nt, Q]), Yn = O((v) => {
|
|
@@ -2980,7 +2980,7 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_11irg_13" }, ts = Object.freeze({ to
|
|
|
2980
2980
|
let se = P ? F : D, ve = F;
|
|
2981
2981
|
const ye = P || Math.abs(se) > Math.abs(ve);
|
|
2982
2982
|
j === 1 && (ve *= 0), zt.current = window.requestAnimationFrame(() => {
|
|
2983
|
-
zt.current = null,
|
|
2983
|
+
zt.current = null, qn(ye ? { left: se } : { top: ve });
|
|
2984
2984
|
});
|
|
2985
2985
|
}, [Mt, Ne, nt, Q, te]), zn = O((v = null) => {
|
|
2986
2986
|
on.current = null, rt.current = null, Zt();
|
|
@@ -2988,7 +2988,7 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_11irg_13" }, ts = Object.freeze({ to
|
|
|
2988
2988
|
nn(() => {
|
|
2989
2989
|
zn();
|
|
2990
2990
|
}, [oe]);
|
|
2991
|
-
const vn = wo(t, () => ({ stage: at.current, focus: et, contains:
|
|
2991
|
+
const vn = wo(t, () => ({ stage: at.current, focus: et, contains: Ke, invalidate: zn, scrollTo: xn, scrollBy: qn, 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) => {
|
|
2992
2992
|
tt.current.push(v);
|
|
2993
2993
|
} }), [r, i, Ae]);
|
|
2994
2994
|
st(() => (He && vn.current?.addEventListener("wheel", Mn, { passive: !1 }), jt.current = !0, ke.current = null, () => {
|
|
@@ -3024,13 +3024,13 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_11irg_13" }, ts = Object.freeze({ to
|
|
|
3024
3024
|
}
|
|
3025
3025
|
}
|
|
3026
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) => {
|
|
3027
|
-
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, qt = Oe.y, Ot = Math.trunc((mt + $t) / sn) - Pt, c = Math.trunc((Ge + qt) / sn) - yt;
|
|
3028
3028
|
ge[c] || (ge[c] = {});
|
|
3029
3029
|
let h = ge[c][Ot];
|
|
3030
3030
|
h || (h = ge[c][Ot] = []);
|
|
3031
3031
|
let w = fe?.get(bt);
|
|
3032
3032
|
if (!w) {
|
|
3033
|
-
const p = (mt + $t) % sn, y = (Ge +
|
|
3033
|
+
const p = (mt + $t) % sn, y = (Ge + qt) % sn;
|
|
3034
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) } });
|
|
3035
3035
|
}
|
|
3036
3036
|
se?.set(bt, w), h.push(w);
|
|
@@ -3042,7 +3042,7 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_11irg_13" }, ts = Object.freeze({ to
|
|
|
3042
3042
|
if (!Z.isRangesIntersect(Oe, Et) && !Z.isRangeWithinRange(Oe, Et)) continue;
|
|
3043
3043
|
const bt = Oe && !Z.isSingleCell(Oe);
|
|
3044
3044
|
if (!bt && N?.(ct)) continue;
|
|
3045
|
-
const $t = ct.rowIndex,
|
|
3045
|
+
const $t = ct.rowIndex, qt = ct.colIndex, Ot = ut[$t], c = Ve[qt];
|
|
3046
3046
|
let h = null;
|
|
3047
3047
|
Ot && c && (h = { x: c.offset, y: Ot.offset, width: c.size, height: Ot.size });
|
|
3048
3048
|
const w = Dr(Oe.rowStart, Oe.colStart);
|
|
@@ -3065,7 +3065,7 @@ const Wr = { "sheetxl-grid": "_sheetxl-grid_11irg_13" }, ts = Object.freeze({ to
|
|
|
3065
3065
|
for (let Oe = 0; Oe < ct.length; Oe++) {
|
|
3066
3066
|
const Et = $e[ct[Oe]];
|
|
3067
3067
|
if (!Et) continue;
|
|
3068
|
-
const bt = parseInt(Ce[Ze]), $t = parseInt(ct[Oe]),
|
|
3068
|
+
const bt = parseInt(Ce[Ze]), $t = parseInt(ct[Oe]), qt = bt + yt, Ot = $t + Pt, c = `view:${v.getAnchor()}:segment:${Ot}:${qt}`;
|
|
3069
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));
|
|
3070
3070
|
}
|
|
3071
3071
|
}
|
|
@@ -3217,18 +3217,18 @@ const Ti = "ew-resize", Ri = "ns-resize", ls = Dt(Ut((e, t) => {
|
|
|
3217
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;
|
|
3218
3218
|
let L = _ ? o.getVisibleColumns() : o.getVisibleRows(), le = null;
|
|
3219
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));
|
|
3220
|
-
const $ = J(null), [oe, be] = Je(null), U = (A,
|
|
3220
|
+
const $ = J(null), [oe, be] = Je(null), U = (A, K) => _ ? A.clientX - K.clientX : A.clientY - K.clientY, H = o.getLayout(), X = _ ? H.getColOffset(r + 1) : H.getRowOffset(r + 1), k = On({ processTouch: !0, onPointerDown: (A) => {
|
|
3221
3221
|
if (ae?.(A), !i && !l) {
|
|
3222
|
-
const
|
|
3222
|
+
const K = _ ? H.getColOffset(r) : H.getRowOffset(r), N = X - K;
|
|
3223
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);
|
|
3224
3224
|
}
|
|
3225
3225
|
A.stopPropagation(), A.preventDefault();
|
|
3226
|
-
}, onPointerUp: (A,
|
|
3226
|
+
}, onPointerUp: (A, K, N) => {
|
|
3227
3227
|
if (!$.current) return;
|
|
3228
3228
|
$.current.isResizing && $.current.onDividerResizeEnd?.($.current.index, Math.max(0, $.current.startSize + U(A, N)), $.current.startSize);
|
|
3229
3229
|
const xe = $.current;
|
|
3230
3230
|
$.current = null, be($.current), xe.onDividerMouseUp?.(xe.index);
|
|
3231
|
-
}, onPointerMoveOrWait: (A,
|
|
3231
|
+
}, onPointerMoveOrWait: (A, K, N) => {
|
|
3232
3232
|
if (!$.current) return;
|
|
3233
3233
|
const xe = U(A, N);
|
|
3234
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();
|
|
@@ -3240,7 +3240,7 @@ const Ti = "ew-resize", Ri = "ns-resize", ls = Dt(Ut((e, t) => {
|
|
|
3240
3240
|
if (!C) return;
|
|
3241
3241
|
const { getPortalContainer: ee } = gi();
|
|
3242
3242
|
let W = null;
|
|
3243
|
-
return oe && oe.isResizing && oe.index === r && (W =
|
|
3243
|
+
return oe && oe.isResizing && oe.index === r && (W = qr(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 })] });
|
|
3244
3244
|
}));
|
|
3245
3245
|
class cs {
|
|
3246
3246
|
naturalDimensions(t, n = {}) {
|
|
@@ -3269,20 +3269,20 @@ const as = (e = void 0) => Object.freeze({ clean: e, dirty: void 0, editMode: !1
|
|
|
3269
3269
|
let u = 2;
|
|
3270
3270
|
const C = 96 * U / 72, ee = 1.2 * C;
|
|
3271
3271
|
le === "right" && (u += 1);
|
|
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]), [
|
|
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]), [K, N] = Je(A);
|
|
3273
3273
|
nn(() => {
|
|
3274
3274
|
N(A());
|
|
3275
3275
|
}, [d, W]), nn(() => {
|
|
3276
3276
|
g?.({ width: oe === "wrap" ? void 0 : W.width + u, height: W.height });
|
|
3277
3277
|
}, [W, g]);
|
|
3278
|
-
const xe = T(i, [i]), G = T((
|
|
3279
|
-
if (R.dirty ===
|
|
3278
|
+
const xe = T(i, [i]), G = T((q) => {
|
|
3279
|
+
if (R.dirty === q) return;
|
|
3280
3280
|
const pe = { ...R };
|
|
3281
|
-
pe.dirty =
|
|
3282
|
-
}, [R]), He = T((
|
|
3283
|
-
if (R.editMode ===
|
|
3281
|
+
pe.dirty = q, M.current, _(pe), xe?.(pe);
|
|
3282
|
+
}, [R]), He = T((q) => {
|
|
3283
|
+
if (R.editMode === q) return;
|
|
3284
3284
|
const pe = { ...R };
|
|
3285
|
-
pe.editMode =
|
|
3285
|
+
pe.editMode = q, _(pe), xe?.(pe);
|
|
3286
3286
|
}, [R]), Ue = T(() => {
|
|
3287
3287
|
try {
|
|
3288
3288
|
return l?.(R), a?.(), !0;
|
|
@@ -3291,24 +3291,24 @@ const as = (e = void 0) => Object.freeze({ clean: e, dirty: void 0, editMode: !1
|
|
|
3291
3291
|
}
|
|
3292
3292
|
}, [l, R]), We = T(() => {
|
|
3293
3293
|
_(n), s?.(), a?.();
|
|
3294
|
-
}, [s, n]), ht = T((
|
|
3294
|
+
}, [s, n]), ht = T((q) => {
|
|
3295
3295
|
if (!M.current) return;
|
|
3296
|
-
if (
|
|
3296
|
+
if (q.isDefaultPrevented(), !(q.isTrusted || q.nativeEvent.ctrlKey || q.nativeEvent.metaKey || q.nativeEvent.altKey || q.nativeEvent.isComposing) && vi.indexOf(q.nativeEvent.key) !== -1) {
|
|
3297
3297
|
const te = { ...R };
|
|
3298
|
-
return te.dirty =
|
|
3298
|
+
return te.dirty = q.nativeEvent.key === "Backspace" ? "" : (te.dirty ?? "") + q.key, _(te), xe?.(te), void q.preventDefault();
|
|
3299
3299
|
}
|
|
3300
|
-
const pe =
|
|
3301
|
-
if (
|
|
3302
|
-
if (
|
|
3303
|
-
if (
|
|
3300
|
+
const pe = q.nativeEvent.shiftKey;
|
|
3301
|
+
if (q.which === Ji) return q.preventDefault(), void We();
|
|
3302
|
+
if (q.which === ol) return He(!0), void q.preventDefault();
|
|
3303
|
+
if (q.which === Zi && (q.preventDefault(), Ue() && m?.(pe ? it : lt)), q.which === Gi) return q.preventDefault(), void (Ue() && m?.(pe ? ot : qe));
|
|
3304
3304
|
if (!R.editMode) {
|
|
3305
3305
|
let te = null;
|
|
3306
|
-
switch (
|
|
3306
|
+
switch (q.which) {
|
|
3307
3307
|
case Qi:
|
|
3308
3308
|
te = ot;
|
|
3309
3309
|
break;
|
|
3310
3310
|
case tl:
|
|
3311
|
-
te =
|
|
3311
|
+
te = qe;
|
|
3312
3312
|
break;
|
|
3313
3313
|
case el:
|
|
3314
3314
|
te = it;
|
|
@@ -3322,25 +3322,25 @@ const as = (e = void 0) => Object.freeze({ clean: e, dirty: void 0, editMode: !1
|
|
|
3322
3322
|
st(() => {
|
|
3323
3323
|
S(!1);
|
|
3324
3324
|
}, []);
|
|
3325
|
-
const ue = wo(t, () => ({ startEdit(
|
|
3326
|
-
let pe =
|
|
3325
|
+
const ue = wo(t, () => ({ startEdit(q) {
|
|
3326
|
+
let pe = q?.initialSelection;
|
|
3327
3327
|
if (!pe) {
|
|
3328
3328
|
const Re = M.current.value.length ?? 0;
|
|
3329
3329
|
pe = { start: Re, end: Re, direction: "forward" };
|
|
3330
3330
|
}
|
|
3331
3331
|
M.current?.setSelectionRange(pe.start, pe.end, pe.direction);
|
|
3332
|
-
const te = { ...n, editMode:
|
|
3333
|
-
|
|
3332
|
+
const te = { ...n, editMode: q?.editMode ?? !1 };
|
|
3333
|
+
q?.text !== void 0 && (te.dirty = q.text), te.editMode === n.editMode && te.dirty === n.dirty || (_(te), xe?.(te));
|
|
3334
3334
|
}, submitEdit: () => Ue(), cancelEdit() {
|
|
3335
3335
|
We();
|
|
3336
3336
|
}, autoFocus() {
|
|
3337
3337
|
M.current?.focus();
|
|
3338
|
-
}, getLineHeight: () => W?.maxLineHeight ?? ee, dispatchEvent: (
|
|
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:
|
|
3340
|
-
G(
|
|
3341
|
-
}, onDoubleClick: (
|
|
3342
|
-
|
|
3343
|
-
}, onMouseDown: (
|
|
3338
|
+
}, getLineHeight: () => W?.maxLineHeight ?? ee, dispatchEvent: (q) => M.current.dispatchEvent(q) }), [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: K, 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: (q) => {
|
|
3340
|
+
G(q.target.value);
|
|
3341
|
+
}, onDoubleClick: (q) => {
|
|
3342
|
+
q.isTrusted;
|
|
3343
|
+
}, onMouseDown: (q) => {
|
|
3344
3344
|
He(!0);
|
|
3345
3345
|
}, onKeyDown: ht }) });
|
|
3346
3346
|
})), bs = Dt((e) => {
|