@sheetxl/grid-react 0.3.2 → 0.3.4
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 +1374 -1373
- package/licenses/dependencies.txt +22 -22
- package/node/assets/style.css +1 -1
- package/node/esm/index.mjs +159 -158
- package/package.json +3 -3
package/browser/esm/index.mjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._sheetxl-
|
|
2
|
-
import { jsx as
|
|
3
|
-
import Sn, { memo as
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._sheetxl-grid_h9wwa_7{position:relative;box-sizing:border-box;user-select:none}._sheetxl-grid_h9wwa_7 *{box-sizing:border-box!important}._sheetxl-grid_h9wwa_7 *:focus{outline:none}._sheetxl-grid_h9wwa_7 .cell-container{position:absolute;overflow:visible;white-space:pre}._sheetxl-grid_h9wwa_7 .cell-container>*{inset:0;position:absolute}._sheetxl-grid_h9wwa_7 .sheetxl-stage{contain:strict}._sheetxl-grid_h9wwa_7 .sheetxl-stage>*{contain:strict}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
|
+
import { jsx as q, jsxs as Ht, Fragment as wn } from "react/jsx-runtime";
|
|
3
|
+
import Sn, { memo as At, useCallback as D, useRef as Z, useEffect as st, useImperativeHandle as Ur, forwardRef as Ut, useMemo as _e, useLayoutEffect as tn, useState as Ze, 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.4
|
|
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", Ke = "right", uo = "tl", Hn = "t", Nn = "l", Xt = "c",
|
|
12
|
+
const it = "up", lt = "down", ot = "left", Ke = "right", uo = "tl", Hn = "t", Nn = "l", Xt = "c", Ft = "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
|
-
const Nt = "column",
|
|
14
|
+
const Nt = "column", an = "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 = an, 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;
|
|
16
16
|
if (!e || !t || e.length !== t.length) return !1;
|
|
17
17
|
for (let n = 0; n < e.length; n++) if (!jo(e[n], t[n])) return !1;
|
|
@@ -34,54 +34,54 @@ const Nt = "column", cn = "row", $i = Object.freeze({ colIndex: 0, rowIndex: 0 }
|
|
|
34
34
|
}, Vi = [null, null], Wi = (e, t, n) => {
|
|
35
35
|
if (e[0].value === e[1].value) return t;
|
|
36
36
|
};
|
|
37
|
-
function cr(e, t = 2, n, o =
|
|
37
|
+
function cr(e, t = 2, n, o = an, r) {
|
|
38
38
|
let i = [...e];
|
|
39
39
|
if (t <= 0 || e.length <= 1) return i;
|
|
40
40
|
let l = o === Nt, s = 0, a = !1;
|
|
41
41
|
do {
|
|
42
|
-
const d = i.sort(Gr(l ?
|
|
42
|
+
const d = i.sort(Gr(l ? an : Nt));
|
|
43
43
|
i = [], i.push(d[0]);
|
|
44
44
|
const g = d.length;
|
|
45
|
-
let m = 0, f = d[0], x = f.colStart,
|
|
45
|
+
let m = 0, f = d[0], x = f.colStart, _ = f.rowStart, I = f.colEnd, R = f.rowEnd;
|
|
46
46
|
for (let ae = 1; ae < g; ae++) {
|
|
47
|
-
const
|
|
48
|
-
let
|
|
49
|
-
if (
|
|
50
|
-
let
|
|
51
|
-
if (f.value !== void 0 && (
|
|
47
|
+
const P = d[ae];
|
|
48
|
+
let C = !1;
|
|
49
|
+
if (C = l ? f && _ === P.rowStart && R === P.rowEnd && I + 1 === P.colStart : f && x === P.colStart && I === P.colEnd && R + 1 === P.rowStart, C) {
|
|
50
|
+
let z = { colStart: x, rowStart: _, colEnd: l ? P.colEnd : I, rowEnd: l ? R : P.rowEnd };
|
|
51
|
+
if (f.value !== void 0 && (z.value = f.value), n) {
|
|
52
52
|
const le = r ?? [null, null];
|
|
53
|
-
le[0] = f, le[1] =
|
|
53
|
+
le[0] = f, le[1] = P, z = n(le, z, o);
|
|
54
54
|
}
|
|
55
|
-
if (
|
|
56
|
-
i[m] =
|
|
55
|
+
if (z) {
|
|
56
|
+
i[m] = z, a = !0, f = z, x = f.colStart, _ = f.rowStart, I = f.colEnd, R = f.rowEnd;
|
|
57
57
|
continue;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
i[++m] =
|
|
60
|
+
i[++m] = P, f = P, x = f.colStart, _ = f.rowStart, I = f.colEnd, R = f.rowEnd;
|
|
61
61
|
}
|
|
62
62
|
s++, l = !l, s === 1 && (a = !0);
|
|
63
63
|
} while (s < t && a && i.length > 1);
|
|
64
64
|
return i;
|
|
65
65
|
}
|
|
66
|
-
const
|
|
66
|
+
const G = Object.freeze(Object.defineProperty({ __proto__: null, EmptyCell: $i, EmptyRange: Bi, cellToRange: (e, t) => {
|
|
67
67
|
if (!e) return null;
|
|
68
68
|
let n = t;
|
|
69
69
|
return n || (n = { ...e }, delete n.colIndex, delete n.rowIndex), n.colStart = e.colIndex ?? 0, n.rowStart = e.rowIndex ?? 0, n.colEnd = e.colIndex ?? 0, n.rowEnd = e.rowIndex ?? 0, n;
|
|
70
|
-
}, columnFirstCellComparator: or, columnFirstRangeComparator: Yr, createCellComparator: (e =
|
|
70
|
+
}, columnFirstCellComparator: or, columnFirstRangeComparator: Yr, createCellComparator: (e = an, t = !1) => t ? e !== Nt ? (n, o) => n.rowIndex === o.rowIndex ? o.colIndex - n.colIndex : o.rowIndex - n.rowIndex : (n, o) => n.colIndex === o.colIndex ? o.rowIndex - n.rowIndex : o.colIndex - n.colIndex : e !== Nt ? rr : or, createConflatingRanges: (e, t = !1) => {
|
|
71
71
|
const n = [];
|
|
72
72
|
let o, r, i = Number.MIN_SAFE_INTEGER, l = Number.MIN_SAFE_INTEGER;
|
|
73
73
|
return { append: (s, a, d) => {
|
|
74
74
|
let g = !0;
|
|
75
75
|
const m = d !== void 0;
|
|
76
76
|
if (m) {
|
|
77
|
-
const
|
|
78
|
-
|
|
77
|
+
const _ = e ? e(r, d, t) : r === d ? d : void 0;
|
|
78
|
+
_ === void 0 ? g = !1 : d = _;
|
|
79
79
|
}
|
|
80
80
|
if (g && a === l + 1 && s === i) return t ? o.rowEnd = a : o.colEnd = a, l = a, void (r = d);
|
|
81
81
|
o && n.push(o);
|
|
82
82
|
const f = t ? s : a, x = t ? a : s;
|
|
83
83
|
o = { colStart: f, rowStart: x, colEnd: f, rowEnd: x }, m && (o.value = d), i = s, l = a, r = d;
|
|
84
|
-
}, done: (s) => (o && (n.push(o), o = null), s ? cr(n, 3, s === !0 ? Wi : s, t ? Nt :
|
|
84
|
+
}, done: (s) => (o && (n.push(o), o = null), s ? cr(n, 3, s === !0 ? Wi : s, t ? Nt : an, Vi) : n) };
|
|
85
85
|
}, createRangeComparator: Gr, defaultRange: (e, t, n) => e ? n ? (n.colStart = e.colStart ?? t.colStart, n.rowStart = e.rowStart ?? t.rowStart, n.colEnd = e.colEnd ?? t.colEnd, n.rowEnd = e.rowEnd ?? t.rowEnd, n) : { colStart: e.colStart ?? t.colStart, rowStart: e.rowStart ?? t.rowStart, colEnd: e.colEnd ?? t.colEnd, rowEnd: e.rowEnd ?? t.rowEnd } : t, extendRangeToIntersectingRanges: sr, extendRangeToUnionRanges: (e, t) => {
|
|
86
86
|
if (!t || t.length === 0) return e;
|
|
87
87
|
let n = e, o = null;
|
|
@@ -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) {
|
|
@@ -174,15 +174,15 @@ const qi = Object.freeze([]), Ki = Object.freeze({}), ur = (e) => e, so = () =>
|
|
|
174
174
|
Qr(e[l], t?.[l], n) === null && (r = !0, delete e[l]);
|
|
175
175
|
}
|
|
176
176
|
return r && Object.keys(e).length === 0 ? null : void 0;
|
|
177
|
-
}, hr = typeof performance == "object" && typeof performance.now == "function" ? () => performance.now() : () => Date.now(), fr = (e) => e == null, pr = (e, t) => !(t.left > e.right || t.right < e.left || t.top > e.bottom || t.bottom < e.top), gr = !(typeof window > "u" || !window.document || !window.document.createElement),
|
|
178
|
-
if (ei()) return
|
|
177
|
+
}, hr = typeof performance == "object" && typeof performance.now == "function" ? () => performance.now() : () => Date.now(), fr = (e) => e == null, pr = (e, t) => !(t.left > e.right || t.right < e.left || t.top > e.bottom || t.bottom < e.top), gr = !(typeof window > "u" || !window.document || !window.document.createElement), jt = { Windows: "windows", MacOS: "macos", IOS: "ios", Linux: "linux", Android: "android", Safari: "safari", Firefox: "firefox", Node: "node", Unknown: "unknown" }, Un = () => {
|
|
178
|
+
if (ei()) return jt.Node;
|
|
179
179
|
const e = globalThis.navigator !== void 0 && globalThis.navigator.userAgent ? globalThis.navigator.userAgent.toLowerCase() : "";
|
|
180
|
-
return e ? /(win32|win64|windows|wince)/i.test(e) ?
|
|
180
|
+
return e ? /(win32|win64|windows|wince)/i.test(e) ? jt.Windows : /(macintosh|macintel|macppc|mac68k|macos)/i.test(e) ? jt.MacOS : /(iphone|ipad|ipod)/i.test(e) ? jt.IOS : /android/.test(e) ? jt.Android : /linux/.test(e) ? jt.Linux : /^((?!chrome|android|).)*safari/i.test(e) ? jt.Safari : /^((?!chrome|android|Seamonkey).)*firefox/i.test(e) ? jt.Firefox : jt.Unknown : jt.Unknown;
|
|
181
181
|
};
|
|
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: jt, 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) => {
|
|
@@ -530,12 +530,12 @@ Please use Chrome or Edge if external copy and paste is required.`, ko = `You do
|
|
|
530
530
|
All copy and paste operations will be limited to the browser tab.`, ri = { Safari: `The Safari browser does not support advanced copy and paste.
|
|
531
531
|
Copy and paste will be limited to within the browser tab.
|
|
532
532
|
|
|
533
|
-
Please use Chrome or Edge if external copy and paste is required.`, Perms: ko, PermsWrite: Un() ===
|
|
533
|
+
Please use Chrome or Edge if external copy and paste is required.`, Perms: ko, PermsWrite: Un() === jt.Safari ? yr : ko, PermsRead: Un() === jt.Safari ? yr : ko }, Po = async () => new Promise((e) => {
|
|
534
534
|
document.hasFocus() ? e() : globalThis.addEventListener?.("focus", () => {
|
|
535
535
|
e();
|
|
536
536
|
}, { once: !0 }), document.activeElement.focus?.();
|
|
537
537
|
}), Oo = async (e, t, n) => {
|
|
538
|
-
if (Un() ===
|
|
538
|
+
if (Un() === jt.Safari) return await n(new Error(ri.Safari));
|
|
539
539
|
try {
|
|
540
540
|
const o = async (l) => {
|
|
541
541
|
try {
|
|
@@ -552,7 +552,7 @@ Please use Chrome or Edge if external copy and paste is required.`, Perms: ko, P
|
|
|
552
552
|
}
|
|
553
553
|
}, ii = async (e) => {
|
|
554
554
|
try {
|
|
555
|
-
return await e.read({ unsanitized: [
|
|
555
|
+
return await e.read({ unsanitized: [Ft] });
|
|
556
556
|
} catch {
|
|
557
557
|
}
|
|
558
558
|
return await e.read();
|
|
@@ -582,7 +582,7 @@ if (!globalThis.ClipboardItem) {
|
|
|
582
582
|
}
|
|
583
583
|
globalThis.ClipboardItem = t;
|
|
584
584
|
}
|
|
585
|
-
const Ho = async (e, t =
|
|
585
|
+
const Ho = async (e, t = Ft) => new Promise(async (n, o) => {
|
|
586
586
|
try {
|
|
587
587
|
const r = await (async (i, l) => {
|
|
588
588
|
if (!i) return null;
|
|
@@ -602,21 +602,21 @@ const Ho = async (e, t = Bt) => new Promise(async (n, o) => {
|
|
|
602
602
|
} catch (r) {
|
|
603
603
|
o(r);
|
|
604
604
|
}
|
|
605
|
-
}), br = async (e, t =
|
|
605
|
+
}), br = async (e, t = Ft) => {
|
|
606
606
|
const n = await Ho(e, t);
|
|
607
607
|
if (!n) return null;
|
|
608
608
|
let o = null;
|
|
609
609
|
try {
|
|
610
|
-
o = new DOMParser().parseFromString(n,
|
|
610
|
+
o = new DOMParser().parseFromString(n, Ft);
|
|
611
611
|
} catch {
|
|
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
|
-
const o = new DOMParser().parseFromString(t,
|
|
619
|
-
o.body.firstElementChild.setAttribute(
|
|
618
|
+
const o = new DOMParser().parseFromString(t, Ft);
|
|
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;
|
|
@@ -647,10 +647,10 @@ let ho = class {
|
|
|
647
647
|
await Po();
|
|
648
648
|
const e = await Ho(this._nativeClipboard, Tn);
|
|
649
649
|
if (!this._state || e && e === this._state.uuid) return !0;
|
|
650
|
-
const t = await br(this._nativeClipboard,
|
|
650
|
+
const t = await br(this._nativeClipboard, Ft);
|
|
651
651
|
return !this._state || (Er(this._state.uuid, t) || this.clear(), !0);
|
|
652
652
|
}, async (e) => {
|
|
653
|
-
e?.message === "denied" || e.message?.includes("Document is not focused") || Un() ===
|
|
653
|
+
e?.message === "denied" || e.message?.includes("Document is not focused") || Un() === jt.Safari || console.warn("Unable to detect clipboard changes: ", e);
|
|
654
654
|
});
|
|
655
655
|
}
|
|
656
656
|
_init() {
|
|
@@ -670,7 +670,7 @@ let ho = class {
|
|
|
670
670
|
if (await Po(), this._state?.uuid) {
|
|
671
671
|
const t = await Ho(this._nativeClipboard, Tn);
|
|
672
672
|
if (t && t === e._state.uuid) return !0;
|
|
673
|
-
const n = await br(this._nativeClipboard,
|
|
673
|
+
const n = await br(this._nativeClipboard, Ft);
|
|
674
674
|
if (Er(e._state?.uuid, n)) return !0;
|
|
675
675
|
}
|
|
676
676
|
return e._state = { items: await ii(this._nativeClipboard), uuid: null, ref: null }, this.dispatchEvent(new Event("clipboardread")), !0;
|
|
@@ -689,32 +689,32 @@ let ho = class {
|
|
|
689
689
|
t._state = { uuid: o, ref: e.ref, items: n }, t.dispatchEvent(new Event("clipboardwrite")), t.dispatchEvent(new Event("clipboardchange"));
|
|
690
690
|
};
|
|
691
691
|
await Oo("clipboard-write", async () => {
|
|
692
|
-
await Po(), o && r.length === 0 && (r.push(new ClipboardItem({ [Tn]: new Blob([o], { type: Tn }) })), r.push(new ClipboardItem({ [
|
|
692
|
+
await Po(), o && r.length === 0 && (r.push(new ClipboardItem({ [Tn]: new Blob([o], { type: Tn }) })), r.push(new ClipboardItem({ [Ft]: new Blob([Sr(o)], { type: Ft }) })));
|
|
693
693
|
for (let l = 0; l < Math.min(1, r.length); l++) {
|
|
694
694
|
const s = r[l];
|
|
695
|
-
let a = s.types.indexOf(
|
|
695
|
+
let a = s.types.indexOf(Ft), d = null;
|
|
696
696
|
if (a !== -1) {
|
|
697
|
-
const f = await s.getType(
|
|
697
|
+
const f = await s.getType(Ft);
|
|
698
698
|
d = await Wo(f), d && (d = Xi(o, d));
|
|
699
699
|
}
|
|
700
700
|
if (!d && s.types.includes(fn)) {
|
|
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
|
-
const g = new Blob([d ?? ""], { type:
|
|
712
|
+
const g = new Blob([d ?? ""], { type: Ft }), m = {};
|
|
713
713
|
for (let f = 0; f < s.types.length; f++) {
|
|
714
714
|
const x = s.types[f];
|
|
715
715
|
m[x] = f === a ? g : s.getType(x);
|
|
716
716
|
}
|
|
717
|
-
d && a === -1 && (m[
|
|
717
|
+
d && a === -1 && (m[Ft] = g), o && (m[Tn] = new Blob([o], { type: Tn })), n.push(new ClipboardItem(m));
|
|
718
718
|
}
|
|
719
719
|
try {
|
|
720
720
|
n && n.length !== 0 ? await this._nativeClipboard.write(n) : await (async (l) => {
|
|
@@ -740,7 +740,7 @@ let ho = class {
|
|
|
740
740
|
}
|
|
741
741
|
try {
|
|
742
742
|
const r = await e.toHtml?.() ?? null;
|
|
743
|
-
r && (n[
|
|
743
|
+
r && (n[Ft] = new Blob([r], { type: Ft }));
|
|
744
744
|
} catch (r) {
|
|
745
745
|
t = r, console.warn("export to html", r);
|
|
746
746
|
}
|
|
@@ -810,13 +810,13 @@ 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);
|
|
817
817
|
}
|
|
818
818
|
}();
|
|
819
|
-
const Wn = { Left: "left", Right: "right", Center: "center" }, It = "shift", yn = "alt",
|
|
819
|
+
const Wn = { Left: "left", Right: "right", Center: "center" }, It = "shift", yn = "alt", zt = "ctrl", Gi = 9, Zi = 13, Ji = 27, Qi = 37, el = 38, tl = 39, nl = 40, ol = 113, _r = 3, mn = { Horizontal: "horizontal", Vertical: "vertical" };
|
|
820
820
|
function li(e) {
|
|
821
821
|
var t, n, o = "";
|
|
822
822
|
if (typeof e == "string" || typeof e == "number") o += e;
|
|
@@ -831,13 +831,13 @@ function Rn() {
|
|
|
831
831
|
return o;
|
|
832
832
|
}
|
|
833
833
|
var rl = function() {
|
|
834
|
-
}, si = typeof window < "u", il = si ?
|
|
834
|
+
}, si = typeof window < "u", il = si ? tn : st, Ir = { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, bottom: 0, right: 0 };
|
|
835
835
|
const In = si && window.ResizeObserver !== void 0 ? function() {
|
|
836
|
-
var e =
|
|
836
|
+
var e = Ze(null), t = e[0], n = e[1], o = Ze(Ir), r = o[0], i = o[1], l = _e(function() {
|
|
837
837
|
return new window.ResizeObserver(function(s) {
|
|
838
838
|
if (s[0]) {
|
|
839
|
-
var a = s[0].contentRect, d = a.x, g = a.y, m = a.width, f = a.height, x = a.top,
|
|
840
|
-
i({ x: d, y: g, width: m, height: f, top: x, left:
|
|
839
|
+
var a = s[0].contentRect, d = a.x, g = a.y, m = a.width, f = a.height, x = a.top, _ = a.left, I = a.bottom, R = a.right;
|
|
840
|
+
i({ x: d, y: g, width: m, height: f, top: x, left: _, bottom: I, right: R });
|
|
841
841
|
}
|
|
842
842
|
});
|
|
843
843
|
}, []);
|
|
@@ -848,17 +848,17 @@ const In = si && window.ResizeObserver !== void 0 ? function() {
|
|
|
848
848
|
}, [t]), [n, r];
|
|
849
849
|
} : function() {
|
|
850
850
|
return [rl, Ir];
|
|
851
|
-
},
|
|
852
|
-
const n =
|
|
851
|
+
}, k = (e, t) => {
|
|
852
|
+
const n = D((...i) => e?.(...i), t), o = Z(null);
|
|
853
853
|
o.current = n;
|
|
854
|
-
const r =
|
|
854
|
+
const r = D((...i) => o.current?.(...i), []);
|
|
855
855
|
if (o.current) return r;
|
|
856
856
|
}, ll = (e) => {
|
|
857
857
|
const { style: t, orientation: n = mn.Vertical, ...o } = e, r = n === mn.Vertical;
|
|
858
|
-
return
|
|
858
|
+
return q("div", { style: { paddingBottom: "0px", paddingRight: "0px", paddingLeft: r ? "0px" : "3px", paddingTop: r ? "3px" : "0px", display: "flex", alignItems: "center", justifyContent: "center", ...t }, ...o, children: q("button", { style: { padding: "0", display: "flex", alignItems: "center", justifyContent: "center", border: "none" }, className: `scrollbar-button ${r ? "vertical" : "horizontal"} single-button start`, children: q("svg", { width: "9", height: "9", viewBox: "0 0 6 6", style: { opacity: "inherit" }, children: q("path", { d: r ? "m 3.7274761,0.68060577 1.11969,1.93863003 1.12075,1.93912 c 0.0895,0.155 0.12152,0.33658 0.0904,0.51283 -0.0311,0.17625 -0.12336,0.33591 -0.26054,0.45091 -0.13715,0.11495 -0.31044,0.17793 -0.4894,0.17781 H 0.83095614 c -0.20186,0 -0.39542,-0.0802 -0.53814,-0.2229 -0.14272,-0.14272 -0.22291,-0.33629 -0.22291,-0.53814 -3e-4,-0.13308 0.0347,-0.26385 0.10147,-0.379 l 1.11872996,-1.94066 1.11921,-1.93864003 c 0.13594,-0.23541 0.38717,-0.38047 0.65905,-0.38047 0.27188,0 0.52311,0.14506 0.65905,0.38047 z" : "m 0.75051,2.3424298 1.93863,-1.11969 1.93912,-1.12075 c 0.155,-0.0895 0.33658,-0.12152 0.51283,-0.0904 0.17625,0.0311 0.33591,0.12336 0.45091,0.26054 0.11495,0.13715 0.17793,0.31044 0.17781,0.4894 v 4.47742 c 0,0.20186 -0.0802,0.39542 -0.2229,0.53814 -0.14272,0.14272 -0.33629,0.22291 -0.53814,0.22291 -0.13308,3e-4 -0.26385,-0.0347 -0.379,-0.10147 L 2.68911,4.7797998 0.75047,3.6605898 C 0.51506,3.5246498 0.37,3.2734198 0.37,3.0015398 c 0,-0.27188 0.14506,-0.52311 0.38047,-0.65905 z" }) }) }) });
|
|
859
859
|
}, sl = (e) => {
|
|
860
860
|
const { style: t, orientation: n = mn.Vertical, ...o } = e, r = n === mn.Vertical;
|
|
861
|
-
return
|
|
861
|
+
return q("div", { style: { paddingLeft: "0px", paddingTop: "0px", paddingRight: r ? "0px" : "3px", paddingBottom: r ? "3px" : "0px", display: "flex", alignItems: "center", justifyContent: "center", ...t }, ...o, children: q("button", { style: { padding: "0", display: "flex", alignItems: "center", justifyContent: "center", border: "none" }, className: `scrollbar-button ${r ? "vertical" : "horizontal"} single-button end`, children: q("svg", { width: "9", height: "9", viewBox: "0 0 6 6", style: { opacity: "inherit" }, children: q("path", { d: r ? "M 2.412334,5.319396 1.292644,3.3807659 0.17189405,1.4416459 c -0.0895,-0.155 -0.12152,-0.33658 -0.0904,-0.51282998 0.0311,-0.17625 0.12336,-0.33591 0.26054,-0.45091 0.13715,-0.11495 0.31044,-0.17793 0.4894,-0.17781 H 5.308854 c 0.20186,0 0.39542,0.0802 0.53814,0.2229 0.14272,0.14272 0.22291,0.33629 0.22291,0.53813998 3e-4,0.13308 -0.0347,0.26385 -0.10147,0.379 l -1.11873,1.94066 -1.11921,1.9386401 c -0.13594,0.23541 -0.38717,0.38047 -0.65905,0.38047 -0.27188,0 -0.52311,-0.14506 -0.65905,-0.38047 z" : "m 5.3893002,3.6575719 -1.9386301,1.11969 -1.93912,1.12075 c -0.155,0.0895 -0.33658,0.12152 -0.51282997,0.0904 -0.17625,-0.0311 -0.33591,-0.12336 -0.45091,-0.26054 -0.11495,-0.13715 -0.17793,-0.31044 -0.17781,-0.4894 V 0.76105195 c 0,-0.20186 0.0802,-0.39542 0.2229,-0.53814 C 0.73562013,0.08019195 0.92919013,1.9467784e-6 1.1310401,1.9467784e-6 1.2641201,-2.9805322e-4 1.3948901,0.03470195 1.5100401,0.10147195 l 1.94066,1.11872995 1.9386401,1.11921 c 0.23541,0.13594 0.38047,0.38717 0.38047,0.65905 0,0.27188 -0.14506,0.52311 -0.38047,0.65905 z" }) }) }) });
|
|
862
862
|
}, No = (e, t, n, o, r = 0) => {
|
|
863
863
|
for (let i = 0; i < n.length; i++) {
|
|
864
864
|
const l = n[i].getBoundingClientRect();
|
|
@@ -870,47 +870,47 @@ const In = si && window.ResizeObserver !== void 0 ? function() {
|
|
|
870
870
|
return r;
|
|
871
871
|
};
|
|
872
872
|
Object.freeze(Object.defineProperty({ __proto__: null, getScrollTo: No }, Symbol.toStringTag, { value: "Module" }));
|
|
873
|
-
const er =
|
|
874
|
-
const { offset: n = 0, totalSize: o = 0, viewportSize: r = 0, style: i, className: l, orientation: s = mn.Vertical, onScrollOffset: a, onScroll: d, showCustomScrollButtons: g = !1, scrollButtonIncrement: m = 200, scrollButtonInitialRepeatDelay: f = 260, scrollButtonAdditionalRepeatDelay: x = 120, createScrollStartButton:
|
|
873
|
+
const er = At(Ut((e, t) => {
|
|
874
|
+
const { offset: n = 0, totalSize: o = 0, viewportSize: r = 0, style: i, className: l, orientation: s = mn.Vertical, onScrollOffset: a, onScroll: d, showCustomScrollButtons: g = !1, scrollButtonIncrement: m = 200, scrollButtonInitialRepeatDelay: f = 260, scrollButtonAdditionalRepeatDelay: x = 120, createScrollStartButton: _ = ll, createScrollEndButton: I = sl, ...R } = e, ae = k(d, [d]), P = Z(null), [C, { width: z, height: le }] = In(), [B, { width: oe, height: ve }] = In(), N = s === mn.Vertical, H = N ? "top" : "left", X = N ? "scrollTop" : "scrollLeft", T = N ? le : z, S = N ? ve : oe, [h, J] = Ze(null);
|
|
875
875
|
st(() => {
|
|
876
|
-
|
|
877
|
-
}, [
|
|
878
|
-
const
|
|
879
|
-
if (!
|
|
880
|
-
const
|
|
881
|
-
return
|
|
882
|
-
}, []),
|
|
883
|
-
if (!
|
|
884
|
-
const
|
|
885
|
-
return
|
|
886
|
-
}, [
|
|
887
|
-
|
|
888
|
-
const
|
|
889
|
-
a(
|
|
876
|
+
h !== null && P.current && P.current.scrollTo({ behavior: "smooth", [H]: h });
|
|
877
|
+
}, [h, N]);
|
|
878
|
+
const K = D((Ye, $ = !1) => {
|
|
879
|
+
if (!P.current) return 0;
|
|
880
|
+
const E = P.current.querySelector(".scrollbar-viewport"), Me = E.getBoundingClientRect(), ue = E.children, me = $ ? 0 : No(Ye, Me[H], ue, !0, Math.max(0, Ye - m));
|
|
881
|
+
return J(me), Math.max(0, me);
|
|
882
|
+
}, []), L = D((Ye, $ = !1) => {
|
|
883
|
+
if (!P.current) return 0;
|
|
884
|
+
const E = P.current.querySelector(".scrollbar-viewport"), Me = E.getBoundingClientRect(), ue = E.children, me = Math.ceil(S - T), Ve = $ ? me : No(Ye, Me[H], ue, !1, Math.max(0, Ye + m));
|
|
885
|
+
return J(Ve), Math.min(me, Ve);
|
|
886
|
+
}, [S, T]), U = Z(null), ee = D((Ye) => {
|
|
887
|
+
U.current = n;
|
|
888
|
+
const $ = Ye.target[X];
|
|
889
|
+
a($, r, o), ae?.(Ye);
|
|
890
890
|
}, [a, r, o, n]);
|
|
891
891
|
st(() => {
|
|
892
|
-
const
|
|
893
|
-
|
|
892
|
+
const Ye = U.current;
|
|
893
|
+
U.current = null, n !== Ye && (P.current[X] = n);
|
|
894
894
|
}, [n, X]);
|
|
895
|
-
const
|
|
896
|
-
|
|
897
|
-
}, []),
|
|
898
|
-
|
|
899
|
-
const
|
|
900
|
-
|
|
901
|
-
},
|
|
902
|
-
}, [
|
|
895
|
+
const te = Z(null), Y = Z(null), He = D(() => {
|
|
896
|
+
te.current && (clearTimeout(te.current), te.current = null, Y.current = null);
|
|
897
|
+
}, []), je = D((Ye, $, E, Me = f) => {
|
|
898
|
+
Y.current = Ye, te.current = setTimeout(() => {
|
|
899
|
+
const ue = E ? K(Y.current || Ye) : L(Y.current || Ye);
|
|
900
|
+
ue !== Y.current ? je(ue, !1, E, x) : He();
|
|
901
|
+
}, $ ? 0 : Me);
|
|
902
|
+
}, [K, L, He]);
|
|
903
903
|
st(() => () => He(), [He]);
|
|
904
|
-
const
|
|
904
|
+
const Ne = n, at = _e(() => {
|
|
905
905
|
if (!g) return null;
|
|
906
|
-
const
|
|
907
|
-
return
|
|
908
|
-
}, [g, s,
|
|
906
|
+
const Ye = { orientation: s, disabled: Math.floor(Ne) <= 0 || Math.floor(S - T) === 0, onMouseUp: He, onMouseLeave: He, onMouseDown: () => je(Ne, !0, !0) };
|
|
907
|
+
return _?.(Ye);
|
|
908
|
+
}, [g, s, Ne, h, S, T]), Se = _e(() => {
|
|
909
909
|
if (!g) return null;
|
|
910
|
-
const
|
|
911
|
-
return I?.(
|
|
912
|
-
}, [g, s,
|
|
913
|
-
return Ht("div", { ref: t, style: { display: "flex", flex: "1", flexDirection:
|
|
910
|
+
const Ye = { orientation: s, disabled: Math.floor(S - T) <= Math.ceil(Ne), onMouseUp: He, onMouseLeave: He, onMouseDown: () => je(Ne, !0, !1) };
|
|
911
|
+
return I?.(Ye);
|
|
912
|
+
}, [g, s, Ne, h, S, T]);
|
|
913
|
+
return Ht("div", { ref: t, style: { display: "flex", flex: "1", flexDirection: N ? "column" : "row", padding: "0", ...i }, className: Rn("_sheetxl-scrollbar_eblx4_6", l), ...R, children: [at, q("div", { className: "pseudo-scrollbar", style: { flex: "1 1 100%", display: "flex", boxSizing: "content-box", flexDirection: N ? "column" : "row", justifyContent: "center", alignItems: "center" }, ref: C, children: q("div", { tabIndex: -1, style: { flex: "1 1 100%", overflowY: N ? "scroll" : "hidden", overflowX: N ? "hidden" : "scroll", position: "relative", willChange: "transform" }, onScroll: ee, ref: P, children: q("div", { ref: B, style: { position: "absolute", height: N ? o - r + (le ?? 0) : 1, width: N ? 1 : o - r + (z ?? 0) }, className: "scrollbar-viewport" }) }) }), Se] });
|
|
914
914
|
}));
|
|
915
915
|
er.displayName = "Scrollbar";
|
|
916
916
|
let Cr = Date.now, gn = {}, cl = 1;
|
|
@@ -929,11 +929,11 @@ const jn = (e) => {
|
|
|
929
929
|
if (!gn[d] || t && !t(d)) return gn[d] = null, void n(60 - a / ((x - i) / 1e3), d, !1);
|
|
930
930
|
if (f) {
|
|
931
931
|
const I = Math.round((x - l) / 16.666666666666668) - 1;
|
|
932
|
-
for (let
|
|
932
|
+
for (let R = 0; R < Math.min(I, 4); R++) g(!0), a++;
|
|
933
933
|
}
|
|
934
934
|
o && (s = (x - i) / o, s > 1 && (s = 1));
|
|
935
|
-
const
|
|
936
|
-
e(
|
|
935
|
+
const _ = r ? r(s) : s;
|
|
936
|
+
e(_, x, f) !== !1 && s !== 1 || !f ? f && (l = x, requestAnimationFrame(g)) : (gn[d] = null, n(60 - a / ((x - i) / 1e3), d, s === 1 || o === void 0));
|
|
937
937
|
};
|
|
938
938
|
return gn[d] = !0, requestAnimationFrame(g), d;
|
|
939
939
|
};
|
|
@@ -1004,8 +1004,8 @@ ci.prototype = { __isSingleTouch: !1, __isTracking: !1, __didDecelerationComplet
|
|
|
1004
1004
|
}
|
|
1005
1005
|
if (this.__enableScrollX) {
|
|
1006
1006
|
a -= l * this.options.speedMultiplier;
|
|
1007
|
-
var
|
|
1008
|
-
(a >
|
|
1007
|
+
var _ = this.__maxScrollLeft;
|
|
1008
|
+
(a > _ || a < 0) && (this.options.bouncing ? a += l / 2 * this.options.speedMultiplier : a = a > _ ? _ : 0);
|
|
1009
1009
|
}
|
|
1010
1010
|
if (this.__enableScrollY) {
|
|
1011
1011
|
d -= s * this.options.speedMultiplier;
|
|
@@ -1014,8 +1014,8 @@ ci.prototype = { __isSingleTouch: !1, __isTracking: !1, __didDecelerationComplet
|
|
|
1014
1014
|
}
|
|
1015
1015
|
i.length > 60 && i.splice(0, 30), i.push(a, d, t), this.__publish(a, d, g);
|
|
1016
1016
|
} else {
|
|
1017
|
-
var
|
|
1018
|
-
this.__enableScrollX = this.options.scrollingX && ae >=
|
|
1017
|
+
var R = this.options.locking ? 3 : 0, ae = Math.abs(o - this.__initialTouchLeft), P = Math.abs(r - this.__initialTouchTop);
|
|
1018
|
+
this.__enableScrollX = this.options.scrollingX && ae >= R, this.__enableScrollY = this.options.scrollingY && P >= R, i.push(this.__scrollLeft, this.__scrollTop, t), this.__isDragging = (this.__enableScrollX || this.__enableScrollY) && (ae >= 5 || P >= 5), this.__isDragging && (this.__interruptedAnimation = !1);
|
|
1019
1019
|
}
|
|
1020
1020
|
this.__lastTouchLeft = o, this.__lastTouchTop = r, this.__lastTouchMove = t, this.__lastScale = n;
|
|
1021
1021
|
}
|
|
@@ -1037,12 +1037,12 @@ ci.prototype = { __isSingleTouch: !1, __isTracking: !1, __didDecelerationComplet
|
|
|
1037
1037
|
var r = this.__isAnimating;
|
|
1038
1038
|
if (r && (jn(r), this.__isAnimating = !1), o && this.options.animating) {
|
|
1039
1039
|
this.__scheduledLeft = e, this.__scheduledTop = t, this.__scheduledZoom = n;
|
|
1040
|
-
var i = this.__scrollLeft, l = this.__scrollTop, s = this.__zoomLevel, a = e - i, d = t - l, g = n - s, m = function(
|
|
1041
|
-
|
|
1042
|
-
}.bind(this), f = function(
|
|
1043
|
-
return this.__isAnimating ===
|
|
1044
|
-
}.bind(this), x = function(
|
|
1045
|
-
I === this.__isAnimating && (this.__isAnimating = !1), (this.__didDecelerationComplete ||
|
|
1040
|
+
var i = this.__scrollLeft, l = this.__scrollTop, s = this.__zoomLevel, a = e - i, d = t - l, g = n - s, m = function(_, I, R) {
|
|
1041
|
+
R && (this.__scrollLeft = i + a * _, this.__scrollTop = l + d * _, this.__zoomLevel = s + g * _, this.__callback && this.__callback(this.__scrollLeft, this.__scrollTop, this.__zoomLevel));
|
|
1042
|
+
}.bind(this), f = function(_) {
|
|
1043
|
+
return this.__isAnimating === _;
|
|
1044
|
+
}.bind(this), x = function(_, I, R) {
|
|
1045
|
+
I === this.__isAnimating && (this.__isAnimating = !1), (this.__didDecelerationComplete || R) && this.options.scrollingComplete(), this.options.zooming && (this.__computeScrollMax(), this.__zoomComplete && (this.__zoomComplete(), this.__zoomComplete = null));
|
|
1046
1046
|
}.bind(this);
|
|
1047
1047
|
this.__isAnimating = Mr(m, f, x, this.options.animationDuration, r ? dl : ul);
|
|
1048
1048
|
} else this.__scheduledLeft = this.__scrollLeft = e, this.__scheduledTop = this.__scrollTop = t, this.__scheduledZoom = this.__zoomLevel = n, this.__callback && this.__callback(e, t, n), this.options.zooming && (this.__computeScrollMax(), this.__zoomComplete && (this.__zoomComplete(), this.__zoomComplete = null));
|
|
@@ -1084,10 +1084,10 @@ 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
|
-
const
|
|
1090
|
+
const we = Object.freeze(Object.defineProperty({ __proto__: null, EmptyCssProperties: fi, boundPixel: function(e, t = !1, n = 0) {
|
|
1091
1091
|
return e;
|
|
1092
1092
|
}, createSyntheticEvent: (e) => {
|
|
1093
1093
|
let t = !1, n = !1;
|
|
@@ -1097,9 +1097,9 @@ 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
|
-
const o =
|
|
1102
|
+
const o = Z(null);
|
|
1103
1103
|
return Ur(e, () => {
|
|
1104
1104
|
if (!o.current) return;
|
|
1105
1105
|
const r = o.current, i = t?.();
|
|
@@ -1112,45 +1112,45 @@ function wo(e, t, n = yl) {
|
|
|
1112
1112
|
return r;
|
|
1113
1113
|
}, n), o;
|
|
1114
1114
|
}
|
|
1115
|
-
const kr = (e) =>
|
|
1116
|
-
const { children: n, viewport: o, onScrollViewport: r, showHorizontalScrollbar: i = !0, showVerticalScrollbar: l = !0, createScrollCorner: s = bl, createHorizontalScrollbar: a = kr, createVerticalScrollbar: d = kr, style: g, touchElement: m, disableTouch: f, ...x } = e,
|
|
1115
|
+
const kr = (e) => q(er, { ...e }), bl = ({ width: e, height: t }) => q("div", { className: "corner", style: { minWidth: `${e}px`, width: `${e}px`, minHeight: `${t}px`, height: `${t}px` } }), pi = At(Ut((e, t) => {
|
|
1116
|
+
const { children: n, viewport: o, onScrollViewport: r, showHorizontalScrollbar: i = !0, showVerticalScrollbar: l = !0, createScrollCorner: s = bl, createHorizontalScrollbar: a = kr, createVerticalScrollbar: d = kr, style: g, touchElement: m, disableTouch: f, ...x } = e, _ = k(r, [r]), I = wo(t, () => ({ isScrollPane: () => !0 }), []), R = Z(null);
|
|
1117
1117
|
st(() => {
|
|
1118
|
-
|
|
1118
|
+
R.current && (R.current.__scrollTop === o?.top && R.current.__scrollLeft !== !o?.left || R.current?.scrollTo(o?.left, o?.top, !1));
|
|
1119
1119
|
}, [o?.left, o?.top, m]);
|
|
1120
|
-
const ae =
|
|
1121
|
-
|
|
1122
|
-
}, []),
|
|
1123
|
-
|
|
1124
|
-
}, []),
|
|
1125
|
-
|
|
1126
|
-
}, []),
|
|
1127
|
-
|
|
1128
|
-
}, []), le =
|
|
1129
|
-
|
|
1120
|
+
const ae = D((T, S) => {
|
|
1121
|
+
_?.({ left: T, top: S });
|
|
1122
|
+
}, []), P = D((T) => {
|
|
1123
|
+
R.current?.doTouchStart(T.touches, T.timeStamp);
|
|
1124
|
+
}, []), C = D((T) => {
|
|
1125
|
+
T.preventDefault(), R.current?.doTouchMove(T.touches, T.timeStamp);
|
|
1126
|
+
}, []), z = D((T) => {
|
|
1127
|
+
R.current?.doTouchEnd(T.timeStamp);
|
|
1128
|
+
}, []), le = D(({ containerWidth: T, containerHeight: S, totalWidth: h, totalHeight: J }) => {
|
|
1129
|
+
R.current.setDimensions(T, S, h, J);
|
|
1130
1130
|
}, []);
|
|
1131
1131
|
st(() => {
|
|
1132
|
-
const
|
|
1133
|
-
if (!f &&
|
|
1134
|
-
if (!
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1132
|
+
const T = m ?? I.current;
|
|
1133
|
+
if (!f && Ko().supportsTouchEvents && T && o) {
|
|
1134
|
+
if (!R.current) {
|
|
1135
|
+
const S = { scrollingX: !0, scrollingY: !0, decelerationRate: 0.95, penetrationAcceleration: 0.08 };
|
|
1136
|
+
R.current = new ci(ae, S);
|
|
1137
1137
|
}
|
|
1138
|
-
|
|
1138
|
+
Ko().supportsTouchEvents && (T.addEventListener("touchstart", P), T.addEventListener("touchend", z), T.addEventListener("touchmove", C)), le({ containerWidth: o?.width, containerHeight: o?.height, totalWidth: o?.totalWidth, totalHeight: o?.totalHeight });
|
|
1139
1139
|
}
|
|
1140
1140
|
return () => {
|
|
1141
|
-
|
|
1141
|
+
T?.removeEventListener("touchstart", P), T?.removeEventListener("touchend", z), T?.removeEventListener("touchmove", C);
|
|
1142
1142
|
};
|
|
1143
1143
|
}, [o?.width, o?.height, o?.totalWidth, o?.totalHeight, f, m]);
|
|
1144
|
-
const [
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1144
|
+
const [B, { width: oe }] = In(), [ve, { height: N }] = In(), H = _e(() => {
|
|
1145
|
+
const T = d({ orientation: mn.Vertical, offset: o?.top, viewportSize: o?.height, totalSize: o?.totalHeight, onScrollOffset: (S) => {
|
|
1146
|
+
_?.({ top: S });
|
|
1147
1147
|
} });
|
|
1148
|
-
return
|
|
1149
|
-
}, [d, o?.top, o?.height, o?.totalHeight]), X =
|
|
1150
|
-
const
|
|
1151
|
-
return Ht("div", { style: { display: "flex", flex: "none", flexDirection: "row", alignItems: "stretch", justifyContent: "center" }, children: [
|
|
1152
|
-
}, [a, o?.left, o?.width, o?.totalWidth, l, s, oe,
|
|
1153
|
-
return
|
|
1148
|
+
return q("div", { style: { display: "flex", flex: "0" }, ref: B, children: T });
|
|
1149
|
+
}, [d, o?.top, o?.height, o?.totalHeight]), X = _e(() => {
|
|
1150
|
+
const T = a({ orientation: mn.Horizontal, offset: o?.left, viewportSize: o?.width, totalSize: o?.totalWidth, onScrollOffset: (S) => _?.({ left: S }) });
|
|
1151
|
+
return Ht("div", { style: { display: "flex", flex: "none", flexDirection: "row", alignItems: "stretch", justifyContent: "center" }, children: [q("div", { style: { display: "flex", flex: "1 1 100%", flexDirection: "column", width: `calc(100% - ${oe}px)` }, children: q("div", { ref: ve, className: "sizer", children: T }) }), l ? s({ width: oe, height: N }) : q(wn, {})] });
|
|
1152
|
+
}, [a, o?.left, o?.width, o?.totalWidth, l, s, oe, N]);
|
|
1153
|
+
return q("div", { style: { position: "relative", display: "flex", minWidth: l ? `${oe}px` : void 0, minHeight: i ? `${N}px` : void 0, ...g }, ...x, ref: I, children: Ht("div", { style: { position: "relative", width: "100%", flex: "1 1 100%", display: "flex", flexDirection: "column", boxSizing: "border-box" }, children: [Ht("div", { style: { display: "flex", flex: "1 1 100%", overflow: "hidden" }, children: [q("div", { style: { display: "flex", flex: "1 1 100%", overflow: "hidden" }, children: n }), l ? H : q(wn, {})] }), i ? X : q(wn, {})] }) });
|
|
1154
1154
|
}));
|
|
1155
1155
|
pi.displayName = "ScrollPane";
|
|
1156
1156
|
const Sl = () => {
|
|
@@ -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) => {
|
|
@@ -1173,34 +1173,34 @@ function gi() {
|
|
|
1173
1173
|
};
|
|
1174
1174
|
}, []), { getPortalContainer: Sl };
|
|
1175
1175
|
}
|
|
1176
|
-
const El = 100, _l = 100, Il = 1e6, Cl = 100, Ml = 50, Tl =
|
|
1177
|
-
const { offset: n = 0, viewportSize: o = 0, totalSize: r = 0, minSize: i = 0, endGap: l = El, endScrollIncrement: s = _l, style: a = fi, onMouseDown: d, onScrollOffset: g, onScroll: m, scaleLimit: f = Il, scaleFactor: x = Cl, precisionFactor:
|
|
1176
|
+
const El = 100, _l = 100, Il = 1e6, Cl = 100, Ml = 50, Tl = At(Ut((e, t) => {
|
|
1177
|
+
const { offset: n = 0, viewportSize: o = 0, totalSize: r = 0, minSize: i = 0, endGap: l = El, endScrollIncrement: s = _l, style: a = fi, onMouseDown: d, onScrollOffset: g, onScroll: m, scaleLimit: f = Il, scaleFactor: x = Cl, precisionFactor: _ = Ml, ...I } = e;
|
|
1178
1178
|
m && console.warn("onScroll not supported for VirtualScrollbar. Use onScrollOffset instead");
|
|
1179
|
-
const
|
|
1180
|
-
}, []), [H, X] =
|
|
1181
|
-
|
|
1179
|
+
const R = k(d, [d]), ae = () => ({ offset: n, totalSize: f === 0 ? r : Math.min(r ?? 0, Math.max(i ?? 0, (n ?? 0) + (o ?? 0)) + (l ?? 0)) }), [P, C] = Ze(ae), z = f !== 0 && P.totalSize > f ? x : 1, le = z / _, B = Math.ceil(P.totalSize / z), oe = Math.ceil(P.offset / z), ve = Math.ceil(o / z), N = D((K) => {
|
|
1180
|
+
}, []), [H, X] = Ze(!1), T = Z(null);
|
|
1181
|
+
tn(() => {
|
|
1182
1182
|
if (!H) {
|
|
1183
|
-
|
|
1184
|
-
const
|
|
1185
|
-
|
|
1183
|
+
T.current = { propTotalSize: r, propViewportSize: o, propOffset: n };
|
|
1184
|
+
const K = ae();
|
|
1185
|
+
C(K);
|
|
1186
1186
|
}
|
|
1187
1187
|
}, [r, o, n, H, i, l, s]);
|
|
1188
|
-
const
|
|
1189
|
-
const
|
|
1190
|
-
|
|
1191
|
-
}, [g,
|
|
1192
|
-
document.removeEventListener("mousemove",
|
|
1193
|
-
}, []),
|
|
1194
|
-
|
|
1195
|
-
}, [
|
|
1196
|
-
return
|
|
1188
|
+
const S = k((K, L, U) => {
|
|
1189
|
+
const ee = T.current;
|
|
1190
|
+
T.current = null, ee && ee.propTotalSize === r && ee.propViewportSize === o && ee.propOffset === n || (Math.abs(K - oe) < le && (K = oe), g?.(K * z, oe, ve));
|
|
1191
|
+
}, [g, z, le, oe, ve]), h = D((K) => {
|
|
1192
|
+
document.removeEventListener("mousemove", N), document.removeEventListener("mouseup", h), X(!1);
|
|
1193
|
+
}, []), J = D((K) => {
|
|
1194
|
+
R?.(K), X(!0), document.addEventListener("mousemove", N, { passive: !0 }), document.addEventListener("mouseup", h, { passive: !0 });
|
|
1195
|
+
}, [N, h]);
|
|
1196
|
+
return q(er, { ref: t, style: { ...a }, ...I, offset: oe, totalSize: B, viewportSize: ve, onMouseDown: J, onScrollOffset: S });
|
|
1197
1197
|
}));
|
|
1198
1198
|
function Do(e, t) {
|
|
1199
1199
|
if (typeof e == "function") return 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) {
|
|
@@ -1216,8 +1216,8 @@ var fo = parseInt(qr.split(".")[0], 10) >= 19 ? function(e) {
|
|
|
1216
1216
|
for (const n of e) Do(n, t);
|
|
1217
1217
|
};
|
|
1218
1218
|
};
|
|
1219
|
-
|
|
1220
|
-
const { refFocusStart: n, ...o } = e, r =
|
|
1219
|
+
At(Ut((e, t) => {
|
|
1220
|
+
const { refFocusStart: n, ...o } = e, r = Z(null), i = D(() => {
|
|
1221
1221
|
if (n) return void n?.current?.focus();
|
|
1222
1222
|
const l = r.current.parentElement.children;
|
|
1223
1223
|
let s = [];
|
|
@@ -1231,62 +1231,62 @@ Dt(Ut((e, t) => {
|
|
|
1231
1231
|
return a.tabindex - d.tabindex;
|
|
1232
1232
|
}), s[0].child.focus());
|
|
1233
1233
|
}, [n]);
|
|
1234
|
-
return
|
|
1235
|
-
})),
|
|
1236
|
-
const { className: n, style: o, children: r, radius: i = 4, strokeWidth: l = 1, strokeColor: s = "grey", ...a } = e, [d, { width: g, height: m }] = In(), f =
|
|
1237
|
-
const
|
|
1238
|
-
return function(le,
|
|
1239
|
-
if (
|
|
1240
|
-
function
|
|
1241
|
-
let
|
|
1242
|
-
return
|
|
1234
|
+
return q("div", { tabIndex: 0, ref: fo([r, t]), onFocus: i, ...o });
|
|
1235
|
+
})), At(Ut((e, t) => {
|
|
1236
|
+
const { className: n, style: o, children: r, radius: i = 4, strokeWidth: l = 1, strokeColor: s = "grey", ...a } = e, [d, { width: g, height: m }] = In(), f = Z(null), x = (ae, P = 0) => {
|
|
1237
|
+
const C = ae / 2, z = m - C + P;
|
|
1238
|
+
return function(le, B, oe = !1) {
|
|
1239
|
+
if (B === 0) return le;
|
|
1240
|
+
function ve(h, J, K) {
|
|
1241
|
+
let L = J.x - h.x, U = J.y - h.y, ee = Math.sqrt(L * L + U * U);
|
|
1242
|
+
return N(h, J, Math.min(1, K / ee));
|
|
1243
1243
|
}
|
|
1244
|
-
function
|
|
1245
|
-
return { x:
|
|
1244
|
+
function N(h, J, K) {
|
|
1245
|
+
return { x: h.x + (J.x - h.x) * K, y: h.y + (J.y - h.y) * K };
|
|
1246
1246
|
}
|
|
1247
|
-
function H(
|
|
1248
|
-
|
|
1247
|
+
function H(h, J) {
|
|
1248
|
+
h.length > 2 && (h[h.length - 2] = J.x, h[h.length - 1] = J.y);
|
|
1249
1249
|
}
|
|
1250
|
-
function X(
|
|
1251
|
-
return { x: parseFloat(
|
|
1250
|
+
function X(h) {
|
|
1251
|
+
return { x: parseFloat(h[h.length - 2]), y: parseFloat(h[h.length - 1]) };
|
|
1252
1252
|
}
|
|
1253
|
-
let
|
|
1254
|
-
let
|
|
1255
|
-
return
|
|
1256
|
-
}, []).reduce(function(
|
|
1257
|
-
return parseFloat(
|
|
1258
|
-
}, []),
|
|
1259
|
-
if (
|
|
1260
|
-
let
|
|
1261
|
-
|
|
1262
|
-
for (let
|
|
1263
|
-
let
|
|
1264
|
-
if (
|
|
1265
|
-
let
|
|
1266
|
-
oe ? (
|
|
1267
|
-
let
|
|
1268
|
-
|
|
1269
|
-
} else
|
|
1253
|
+
let T = le.split(/[,\s]/).reduce(function(h, J) {
|
|
1254
|
+
let K = J.match("([a-zA-Z])(.+)");
|
|
1255
|
+
return K ? (h.push(K[1]), h.push(K[2])) : h.push(J), h;
|
|
1256
|
+
}, []).reduce(function(h, J) {
|
|
1257
|
+
return parseFloat(J) == J && h.length ? h[h.length - 1].push(J) : h.push([J]), h;
|
|
1258
|
+
}, []), S = [];
|
|
1259
|
+
if (T.length > 1) {
|
|
1260
|
+
let h = X(T[0]), J = null;
|
|
1261
|
+
T[T.length - 1][0] === "Z" && T[0].length > 2 && (J = ["L", h.x, h.y], T[T.length - 1] = J), S.push(T[0]);
|
|
1262
|
+
for (let K = 1; K < T.length; K++) {
|
|
1263
|
+
let L = S[S.length - 1], U = T[K], ee = U === J ? T[1] : T[K + 1];
|
|
1264
|
+
if (ee && L && L.length > 2 && U[0] === "L" && ee.length > 2 && ee[0] === "L") {
|
|
1265
|
+
let te, Y, He = X(L), je = X(U), Ne = X(ee);
|
|
1266
|
+
oe ? (te = N(je, L.origPoint || He, B), Y = N(je, ee.origPoint || Ne, B)) : (te = ve(je, He, B), Y = ve(je, Ne, B)), H(U, te), U.origPoint = je, S.push(U);
|
|
1267
|
+
let at = N(te, je, 0.5), Se = N(je, Y, 0.5), Ye = ["C", at.x, at.y, Se.x, Se.y, Y.x, Y.y];
|
|
1268
|
+
Ye.origPoint = je, S.push(Ye);
|
|
1269
|
+
} else S.push(U);
|
|
1270
1270
|
}
|
|
1271
|
-
if (
|
|
1272
|
-
let
|
|
1273
|
-
|
|
1271
|
+
if (J) {
|
|
1272
|
+
let K = X(S[S.length - 1]);
|
|
1273
|
+
S.push(["Z"]), H(S[0], K);
|
|
1274
1274
|
}
|
|
1275
|
-
} else
|
|
1276
|
-
return
|
|
1277
|
-
return
|
|
1275
|
+
} else S = T;
|
|
1276
|
+
return S.reduce(function(h, J) {
|
|
1277
|
+
return h + J.join(" ") + " ";
|
|
1278
1278
|
}, "");
|
|
1279
|
-
}(`M 0 ${
|
|
1280
|
-
},
|
|
1279
|
+
}(`M 0 ${C} L ${i - 0.5} ${C} L ${i - 0.5} ${z} L ${2 * i} ${z} L ${g - 2 * i} ${z} M ${g - 2 * i} ${z} L ${g - i} ${z} L ${g - i} ${C} L ${g} ${C}`, i);
|
|
1280
|
+
}, _ = _e(() => x(l), [g, m, i, l]), I = _e(() => {
|
|
1281
1281
|
if (i === 0) return;
|
|
1282
1282
|
const ae = i / 2;
|
|
1283
1283
|
return x(i) + `L ${g} 0 L 0 0 L 0 ${ae}`;
|
|
1284
|
-
}, [
|
|
1285
|
-
return Ht("div", { className: n, style: { display: "flex", flexDirection: "row", ...o }, ...a, ref: fo([f, d, t]), children: [Sn.isValidElement(r) ? Sn.cloneElement(r,
|
|
1284
|
+
}, [_, i, l]), R = _e(() => ({ style: { clipPath: `path('${I}')` } }), [I]);
|
|
1285
|
+
return Ht("div", { className: n, style: { display: "flex", flexDirection: "row", ...o }, ...a, ref: fo([f, d, t]), children: [Sn.isValidElement(r) ? Sn.cloneElement(r, R) : q(wn, {}), q("svg", { style: { position: "absolute", top: 0, left: 0, pointerEvents: "none" }, width: g, height: m, viewBox: `0 0 ${g} ${m}`, children: q("path", { d: _, stroke: s, fill: "none", vectorEffect: "non-scaling-stroke", strokeWidth: l }) })] });
|
|
1286
1286
|
}));
|
|
1287
1287
|
const Rl = {}, kl = (e) => {
|
|
1288
1288
|
const { onPointerDown: t, style: n, splitDirection: o, paddingBefore: r = 0, paddingAfter: i = 0, disabled: l, key: s, hitAreaProps: a = Rl, ...d } = e, g = o === "row", { style: m, className: f, ...x } = a;
|
|
1289
|
-
return
|
|
1289
|
+
return q("div", { style: { ...n, position: "relative" }, ...d, children: q("div", { className: Rn("hit-box", f), style: { left: (g ? -r : 0) + "px", width: `calc(100% + ${g ? r + i : 0}px)`, top: (g ? 0 : -r) + "px", height: `calc(100% + ${g ? 0 : r + i}px)`, position: "absolute", ...m }, onPointerDown: l ? void 0 : t, ...x }) }, s);
|
|
1290
1290
|
}, oo = {}, bn = (e, t, n = !0) => e === null ? null : e.pixels !== null ? n ? e.pixels : t - e.pixels : (n ? e.percent : 100 - e.percent) / 100 * t, ro = (e, t = !0) => e?.percent ? `${t ? e.percent : 100 - e.percent}%` : e?.pixels ? `${e.pixels}px` : void 0, pn = (e, t) => {
|
|
1291
1291
|
if (e == null) return null;
|
|
1292
1292
|
const n = { percent: null, pixels: null };
|
|
@@ -1295,119 +1295,119 @@ const Rl = {}, kl = (e) => {
|
|
|
1295
1295
|
};
|
|
1296
1296
|
function On(e) {
|
|
1297
1297
|
if (!e) throw new Error("must have a PointerHandlerOptions");
|
|
1298
|
-
const { onPointerDown: t, onPointerUp: n, onPointerMoveOrWait: o, processTouch: r = !1, consumeTouch: i = !0 } = e, l =
|
|
1298
|
+
const { onPointerDown: t, onPointerUp: n, onPointerMoveOrWait: o, processTouch: r = !1, consumeTouch: i = !0 } = e, l = k(t, [t]), s = k(n, [n]), a = k(o, [o]), d = Z(!1), g = e?.timerInitial ?? 230, m = e?.timerContinuous ?? g / 2, f = Z(null), x = Z(null), _ = Z(null), I = Z(null), R = D(() => {
|
|
1299
1299
|
I.current && (clearTimeout(I.current), I.current = null);
|
|
1300
|
-
}, []), ae =
|
|
1300
|
+
}, []), ae = D((H) => {
|
|
1301
1301
|
I.current = setTimeout(() => {
|
|
1302
1302
|
window.requestAnimationFrame(() => {
|
|
1303
|
-
d.current !== !1 && a?.(x.current,
|
|
1303
|
+
d.current !== !1 && a?.(x.current, _.current, f.current);
|
|
1304
1304
|
}), ae(m);
|
|
1305
1305
|
}, H ?? g);
|
|
1306
1306
|
}, []);
|
|
1307
|
-
st(() => () =>
|
|
1308
|
-
const
|
|
1307
|
+
st(() => () => R(), []);
|
|
1308
|
+
const P = r ? "pointer" : "mouse", C = D((H) => {
|
|
1309
1309
|
H.stopPropagation(), H.stopImmediatePropagation(), H.preventDefault();
|
|
1310
|
-
}, []),
|
|
1311
|
-
document.removeEventListener(`${
|
|
1312
|
-
d.current !== !1 && (d.current = !1, s?.(H,
|
|
1310
|
+
}, []), z = k((H) => {
|
|
1311
|
+
document.removeEventListener(`${P}move`, oe), document.removeEventListener(`${P}up`, z), document.removeEventListener("keydown", ve), document.removeEventListener("keyup", N), document.removeEventListener("touchstart", C, { capture: !0 }), document.removeEventListener("touchmove", C, { capture: !0 }), window.removeEventListener("blur", le), R(), window.requestAnimationFrame(() => {
|
|
1312
|
+
d.current !== !1 && (d.current = !1, s?.(H, _.current, f.current), _.current = null);
|
|
1313
1313
|
});
|
|
1314
|
-
}, []), le =
|
|
1315
|
-
d.current !== !1 && (d.current = !1,
|
|
1316
|
-
}, []),
|
|
1317
|
-
|
|
1318
|
-
d.current !== !1 && a?.(x.current,
|
|
1314
|
+
}, []), le = D(() => {
|
|
1315
|
+
d.current !== !1 && (d.current = !1, z(x.current));
|
|
1316
|
+
}, []), B = k(() => {
|
|
1317
|
+
R(), ae(m), window.requestAnimationFrame(() => {
|
|
1318
|
+
d.current !== !1 && a?.(x.current, _.current, f.current);
|
|
1319
1319
|
});
|
|
1320
|
-
}, [m]), oe =
|
|
1321
|
-
x.current = H,
|
|
1322
|
-
}, []),
|
|
1323
|
-
|
|
1324
|
-
}, []),
|
|
1325
|
-
|
|
1320
|
+
}, [m]), oe = k((H) => {
|
|
1321
|
+
x.current = H, B();
|
|
1322
|
+
}, []), ve = k((H) => {
|
|
1323
|
+
_.current = { ctrlKey: H.ctrlKey, shiftKey: H.shiftKey, altKey: H.altKey, metaKey: H.metaKey }, B();
|
|
1324
|
+
}, []), N = k((H) => {
|
|
1325
|
+
_.current = { ctrlKey: H.ctrlKey, shiftKey: H.shiftKey, altKey: H.altKey, metaKey: H.metaKey }, B();
|
|
1326
1326
|
}, [m]);
|
|
1327
|
-
return
|
|
1328
|
-
H.isDefaultPrevented() || (
|
|
1327
|
+
return k((H) => {
|
|
1328
|
+
H.isDefaultPrevented() || (_.current = { ctrlKey: H.ctrlKey, shiftKey: H.shiftKey, altKey: H.altKey, metaKey: H.metaKey }, l(H, _.current) !== !1 && (f.current = H, x.current = H.nativeEvent, document.addEventListener(`${P}up`, z, { passive: !1 }), document.addEventListener(`${P}move`, oe, { passive: !1 }), document.addEventListener("keydown", ve, { passive: !1 }), document.addEventListener("keyup", N, { passive: !1 }), window.addEventListener("blur", le, { passive: !0 }), r && i && (document.addEventListener("touchstart", C, { passive: !1, capture: !0 }), document.addEventListener("touchmove", C, { passive: !1, capture: !0 })), d.current = !0, ae(g)));
|
|
1329
1329
|
}, [g, r]);
|
|
1330
1330
|
}
|
|
1331
|
-
|
|
1332
|
-
const { elementBefore: n, elementAfter: o, splitDirection: r = "row", fixedPane: i = null, position: l, onPositionChange: s, minBefore: a, maxBefore: d, minAfter: g, maxAfter: m, children: f, className: x, style:
|
|
1331
|
+
At(Ut((e, t) => {
|
|
1332
|
+
const { elementBefore: n, elementAfter: o, splitDirection: r = "row", fixedPane: i = null, position: l, onPositionChange: s, minBefore: a, maxBefore: d, minAfter: g, maxAfter: m, children: f, className: x, style: _, disabled: I = !1, onDragStart: R, onDragResize: ae, onDragFinish: P, resizerProps: C = oo, paneProps: z = oo, paneBeforeProps: le = oo, paneAfterProps: B = oo, createResizer: oe = kl } = e;
|
|
1333
1333
|
if (f) throw new Error("Use elementBefore and elementAfter instead of children.");
|
|
1334
|
-
const
|
|
1334
|
+
const ve = _e(() => Sn.isValidElement(o) && Sn.isValidElement(n), [o, n]), N = _e(() => {
|
|
1335
1335
|
let Q = null;
|
|
1336
1336
|
i && (i === "before" ? Q = 0 : i === "after" && (Q = 1));
|
|
1337
1337
|
const et = Q === null;
|
|
1338
1338
|
return { fixedPaneOffset: Q, isPercent: et, minBefore: pn(a, et), maxBefore: pn(d, et), minAfter: pn(g, et), maxAfter: pn(m, et) };
|
|
1339
|
-
}, [a, d, g, m]), H =
|
|
1339
|
+
}, [a, d, g, m]), H = k(s, [s]), [X, T] = Ze(() => pn(l, i === null));
|
|
1340
1340
|
st(() => {
|
|
1341
|
-
|
|
1341
|
+
T(pn(l, i === null));
|
|
1342
1342
|
}, [l, i]);
|
|
1343
|
-
const [
|
|
1344
|
-
const Ie = [null, null],
|
|
1345
|
-
if (Q || (Q = { percent:
|
|
1346
|
-
let rt = bn(Q, et,
|
|
1347
|
-
|
|
1343
|
+
const [S, { width: h, height: J }] = In(), [K, { width: L, height: U }] = In(), ee = r === "row" ? L : U, te = r === "row" ? h : J, Y = _e(() => ((Q, et, Ue, ht) => {
|
|
1344
|
+
const Ie = [null, null], Oe = [null, null];
|
|
1345
|
+
if (Q || (Q = { percent: ht.fixedPaneOffset === null ? 50 : null, pixels: ht.fixedPaneOffset === null ? null : 0 }), et === 0) return Q?.pixels != null ? ht.fixedPaneOffset !== 1 ? (Ie[0] = Q?.pixels, Oe[1] = 100) : (Ie[1] = Q?.pixels - Ue, Oe[0] = 100) : Q?.percent != null && (ht.fixedPaneOffset !== 1 ? (Oe[0] = Q?.percent, Oe[1] = 100 - Q?.percent) : (Oe[1] = Q?.percent, Oe[0] = 100 - Q?.percent)), { percents: Oe, pixels: Ie, minBefore: ro(ht.minBefore, !0), maxBefore: ro(ht.maxBefore, !0), minAfter: ro(ht.minAfter), maxAfter: ro(ht.maxAfter) };
|
|
1346
|
+
let rt = bn(Q, et, ht.fixedPaneOffset !== 1), tt = et - Ue, ze = bn(ht.minBefore, tt, !0) ?? 0, rn = bn(ht.maxBefore, tt, !0) ?? tt, Tt = 0, nt = 0, Rt = 0, Ot = tt;
|
|
1347
|
+
Tt = (bn(ht.maxAfter, et, !1) ?? Ue) - Ue, nt = bn(ht.minAfter, et, !1) ?? et, Rt = Math.max(ze, Tt), Ot = Math.min(rn, nt), rt = Math.max(Rt, Math.min(rt, Ot)), nt = Math.min(tt - rt, bn(ht.maxAfter, tt - rt, !0) ?? tt), Tt = Math.min(tt - rt, bn(ht.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
|
-
return
|
|
1350
|
-
})(X,
|
|
1349
|
+
return Oe[0] = hn, Oe[1] = 100 - Oe[0], { percents: Oe, pixels: Ie, minBefore: `${ze}px`, minAfter: `${Tt}px`, maxBefore: `${Ie[0]}px`, maxAfter: `${Ie[1]}px` };
|
|
1350
|
+
})(X, te, ee, N), [N, X, te, ee, r]), [He, je] = Ze(!1), Ne = k(R, [R]), at = k(ae, [ae]), Se = k(P, [P]), Ye = Z(null), $ = Z(null), E = Z(null), { style: Me, className: ue, ...me } = z, Ve = { minWidth: 0, minHeight: 0, maxWidth: "100%", maxHeight: "100%", display: "flex", overflow: "hidden", ...Me }, { className: dt, style: kt, ...ut } = le, { className: Zt, style: St, ...M } = B, ye = { flex: "1 1 100%", width: "100%", ..._, flexDirection: r, display: "flex" }, { className: Je, style: mt, onPointerDown: Qe, ...cn } = C, on = k((Q) => {
|
|
1351
1351
|
const et = pn(Q, i === null);
|
|
1352
|
-
|
|
1353
|
-
}, [i]),
|
|
1352
|
+
T(et);
|
|
1353
|
+
}, [i]), Mt = k((Q) => {
|
|
1354
1354
|
if (I || !He) return;
|
|
1355
|
-
const et =
|
|
1356
|
-
let
|
|
1357
|
-
|
|
1358
|
-
}, [
|
|
1359
|
-
if (document.removeEventListener("pointermove",
|
|
1360
|
-
if (
|
|
1355
|
+
const et = De.current?.getBoundingClientRect();
|
|
1356
|
+
let Ue = 0;
|
|
1357
|
+
Ue = r === "row" ? (Q.clientX ?? Q.touches?.[0]?.clientX) - et.x : (Q.clientY ?? Q.touches?.[0]?.clientY) - et.y, Ue = Math.max(0, Math.min(te, Ue)), N.fixedPaneOffset === 1 && (Ue = te - Ue), l && X.pixels === Ue || T({ pixels: Ue, percent: null }), at?.(Ue), Q.stopPropagation(), Q.preventDefault();
|
|
1358
|
+
}, [N, r, I, He, X, te]), dn = k((Q) => {
|
|
1359
|
+
if (document.removeEventListener("pointermove", Mt), document.removeEventListener("touchmove", Mt), document.removeEventListener("pointerup", dn), He && (je(!1), X)) {
|
|
1360
|
+
if (Se(X.pixels), !pn(l, i === null) || X.pixels !== l) {
|
|
1361
1361
|
const et = { ...X };
|
|
1362
|
-
et.percent === null && (et.percent = et.pixels /
|
|
1362
|
+
et.percent === null && (et.percent = et.pixels / te * 100), H(et);
|
|
1363
1363
|
}
|
|
1364
1364
|
Q.stopPropagation(), Q.preventDefault();
|
|
1365
1365
|
}
|
|
1366
|
-
}, [X, He, l, i,
|
|
1367
|
-
|
|
1368
|
-
}, [
|
|
1369
|
-
return Ht("div", { ref: fo([
|
|
1366
|
+
}, [X, He, l, i, te]), nn = k((Q) => {
|
|
1367
|
+
Qe?.(Q), Q.defaultPrevented || I || He || (je(!0), Ne(), document.addEventListener("pointermove", Mt, { passive: !1 }), document.addEventListener("touchmove", Mt, { passive: !1 }), document.addEventListener("pointerup", dn, { passive: !1 }));
|
|
1368
|
+
}, [Qe]), De = wo(t, () => ({ setPosition: on, isSplitPane: () => !0 }), []), Kt = _e(() => ve ? oe?.({ key: "resizer", ref: fo([K, $]), className: Rn("resizer", Je), onPointerDownCapture: nn, 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, ...mt }, splitDirection: r, disabled: I, ...cn }) : null, [ve, Je, cn, r, mt, I]), xt = r === "row" ? "Width" : "Height", Vt = { ...Ve, ...kt, flex: N.fixedPaneOffset === 0 && Y?.pixels[0] !== null ? `0 0 ${Math.round(Y?.pixels[0])}px` : `1 1 ${Math.round(Y?.percents[0] ?? 100)}%`, [`min${xt}`]: Y?.minBefore, [`max${xt}`]: o ? Y?.maxBefore : "100%" }, Cn = { ...Ve, ...St, flex: N.fixedPaneOffset === 1 && Y?.pixels[1] !== null ? `0 0 ${Math.round(Y?.pixels[1])}px` : `1 1 ${Math.round(Y?.percents[1] ?? 100)}%`, [`min${xt}`]: Y?.minAfter, [`max${xt}`]: n ? Y?.maxAfter : "100%" }, un = _e(() => n ? q("div", { ref: Ye, className: Rn("before", ue, dt), style: Vt, ...me, ...ut, children: n }, "before") : null, [n, z, le, N, Y]), We = _e(() => o ? q("div", { ref: E, className: Rn("after", ue, Zt), style: Cn, ...me, ...M, children: o }, "after") : null, [o, z, B, N, Y]);
|
|
1369
|
+
return Ht("div", { ref: fo([S, De]), className: Rn("splitPane", r === "row" ? "vertical" : "horizontal", { dragging: He }, x), style: ye, children: [un, Kt, We] });
|
|
1370
1370
|
}));
|
|
1371
1371
|
const Pl = ({ initValue: e, useHookBody: t, applyStateChange: n }) => {
|
|
1372
|
-
const o =
|
|
1372
|
+
const o = Z(e);
|
|
1373
1373
|
if (typeof t != "function") throw new Error("function expected as hook body parameter. got " + typeof t);
|
|
1374
1374
|
const r = t();
|
|
1375
|
-
return
|
|
1375
|
+
return tn(() => {
|
|
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;
|
|
1382
1382
|
const co = [], kn = [], po = () => {
|
|
1383
1383
|
kn.forEach((e) => e());
|
|
1384
1384
|
}, Ll = ({ automaticContainerInternalUseOnly: e }) => {
|
|
1385
|
-
const [t, n] =
|
|
1385
|
+
const [t, n] = Ze([]), o = Z([]);
|
|
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
|
-
}, [e]),
|
|
1394
|
+
}, [e]), q(wn, { children: t.map(({ hook: r, key: i }) => Jo(Pl, { ...r, key: i })) });
|
|
1395
1395
|
}, mi = (e, t, n = {}) => {
|
|
1396
1396
|
let o, r, i = !1, l = !1, s = [], { unmountIfNoConsumers: a = !1 } = n;
|
|
1397
1397
|
const d = (m) => {
|
|
1398
1398
|
r = m, Li(() => s.forEach((f) => f(m)));
|
|
1399
1399
|
}, g = () => (l || (r = typeof e == "function" ? e() : e, l = !0), r);
|
|
1400
1400
|
return () => {
|
|
1401
|
-
const [m, f] =
|
|
1401
|
+
const [m, f] = Ze(g);
|
|
1402
1402
|
return st(() => (i || (i = !0, o = ((x) => {
|
|
1403
|
-
const
|
|
1404
|
-
return co.push({ hook: x, key:
|
|
1403
|
+
const _ = Ol++;
|
|
1404
|
+
return co.push({ hook: x, key: _ }), kn.length === 0 && wi === !1 && (Yo = !0, ((I) => {
|
|
1405
1405
|
if (zo.document && zo.document.createElement) {
|
|
1406
|
-
const
|
|
1407
|
-
Oi(
|
|
1408
|
-
} else
|
|
1406
|
+
const R = zo.document.createElement("div");
|
|
1407
|
+
Oi(R).render(q(I, { automaticContainerInternalUseOnly: !0 }));
|
|
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
|
-
co.splice(co.findIndex((I) => I.key ===
|
|
1410
|
+
co.splice(co.findIndex((I) => I.key === _), 1), po();
|
|
1411
1411
|
};
|
|
1412
1412
|
})({ initValue: e, useHookBody: t, applyStateChange: d })), s.push(f), r !== m && f(r), () => {
|
|
1413
1413
|
s.splice(s.indexOf(f), 1), s.length === 0 && a && (o(), i = !1);
|
|
@@ -1415,7 +1415,7 @@ const co = [], kn = [], po = () => {
|
|
|
1415
1415
|
};
|
|
1416
1416
|
};
|
|
1417
1417
|
mi(null, () => {
|
|
1418
|
-
const [e, t] =
|
|
1418
|
+
const [e, t] = Ze(null);
|
|
1419
1419
|
return e;
|
|
1420
1420
|
});
|
|
1421
1421
|
class Dl {
|
|
@@ -1529,16 +1529,16 @@ class Dl {
|
|
|
1529
1529
|
}), n;
|
|
1530
1530
|
}
|
|
1531
1531
|
}
|
|
1532
|
-
class
|
|
1532
|
+
class Ee extends Dl {
|
|
1533
1533
|
}
|
|
1534
1534
|
Ct.getOS() === Ct.OSType.MacOS || (Ct.getOS(), Ct.OSType.IOS), Ct.getOS() === Ct.OSType.MacOS || (Ct.getOS(), Ct.OSType.IOS), mi({ setClipboard: (e) => {
|
|
1535
1535
|
throw new Error("This is only available via the useClipboard.");
|
|
1536
1536
|
}, getClipboard: () => ho.Global, refNativeCopy: { current: null }, refNativeLastKey: { current: null } }, () => {
|
|
1537
|
-
const [e, t] =
|
|
1538
|
-
return { setClipboard: (n) => t(n), getClipboard: () => e, refNativeCopy:
|
|
1537
|
+
const [e, t] = Ze(ho.Global);
|
|
1538
|
+
return { setClipboard: (n) => t(n), getClipboard: () => e, refNativeCopy: Z(null), refNativeLastKey: Z(null) };
|
|
1539
1539
|
});
|
|
1540
1540
|
let Ao = !1, zl = 0;
|
|
1541
|
-
var Al = typeof document < "u" ?
|
|
1541
|
+
var Al = typeof document < "u" ? tn : st;
|
|
1542
1542
|
const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
1543
1543
|
const [e, t] = Sn.useState(() => Ao ? Pr() : void 0);
|
|
1544
1544
|
return Al(() => {
|
|
@@ -1580,10 +1580,10 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1580
1580
|
for (; r < n && Pn({ itemType: e, itemSize: t, index: r, instanceProps: o, scale: l }).offset < i; ) r += s, s *= 2;
|
|
1581
1581
|
return xi({ itemType: e, itemSize: t, instanceProps: o, high: Math.min(r, n - 1), low: Math.floor(r / 2), offset: i, scale: l });
|
|
1582
1582
|
}, Fl = (e) => {
|
|
1583
|
-
const { rowCount: t, columnCount: n, defaultRowHeight: o, getRowHeight: r, defaultColumnWidth: i, getColumnWidth: l } = e || {}, s =
|
|
1583
|
+
const { rowCount: t, columnCount: n, defaultRowHeight: o, getRowHeight: r, defaultColumnWidth: i, getColumnWidth: l } = e || {}, s = Z({ columnMetadataMap: {}, rowMetadataMap: {}, lastMeasuredColumnIndex: -1, lastMeasuredRowIndex: -1, recalcColumnIndices: [], recalcRowIndices: [] }), a = k((C) => Or({ itemType: "row", itemCount: t, itemSize: r ?? (() => o ?? 20), instanceProps: s.current, offset: C }), [t, r, o]), d = k((C) => C === -1 ? 0 : Pn({ itemType: "row", index: C, itemSize: r ?? (() => o ?? 20), instanceProps: s.current }).offset, [r, o]), g = k((C) => Pn({ itemType: "row", index: C, itemSize: r ?? (() => o ?? 20), instanceProps: s.current }).size, [r, o]), m = k((C) => Or({ itemType: "column", itemCount: n, itemSize: l ?? (() => i ?? 75), instanceProps: s.current, offset: C }), [n, l, i]), f = k((C) => C === -1 ? 0 : Pn({ itemType: "column", index: C, itemSize: l ?? (() => i ?? 75), instanceProps: s.current }).offset, [l, i]), x = k((C) => Pn({ itemType: "column", index: C, itemSize: l ?? (() => i ?? 75), instanceProps: s.current }).size, [l, i]), [_, I] = Qo((C) => C + 1, 0), R = () => ({ getRowOffset: d, getColOffset: f, getRowIndex: a, getColIndex: m }), [ae, P] = Ze(() => e ? R() : null);
|
|
1584
1584
|
return st(() => {
|
|
1585
|
-
|
|
1586
|
-
}, [
|
|
1585
|
+
P(e ? R() : null);
|
|
1586
|
+
}, [_, t, n, i, o, g, x]), ae;
|
|
1587
1587
|
}, vi = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ~`!@#$%^&*()-_=+[{]};:'\",<.>/?|\\", Lr = (e) => {
|
|
1588
1588
|
if (!e) return null;
|
|
1589
1589
|
if (e.eventType === "start") return { type: e.eventType };
|
|
@@ -1597,240 +1597,241 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1597
1597
|
}
|
|
1598
1598
|
return { type: e.eventType ?? "unknown" };
|
|
1599
1599
|
}, jl = (e) => !0, Vl = (e) => !!e && !(e.ctrlKey || e.metaKey || e.altKey || e.isComposing) && (!(e.shiftKey || e.key !== "F2" && e.key !== " " && e.key !== "Backspace") || (!e.shiftKey || e.key !== " ") && vi.indexOf(e.key) !== -1), Wl = (e) => !!e && e.type === "dblclick" && { editMode: !0 }, Hl = (e) => {
|
|
1600
|
-
const { session: t, refLatestCoords: n, handleSubmitEdit: o, handleCancelEdit: r, cellBounds: i, isInBounds: l, getCellEditor: s, propsEditor: a, borderStrokeFill: d = "rgb(33, 115, 70)", borderStrokeWidth: g = 2, alignment: m = Wn.Left, style: f, ...x } = e,
|
|
1601
|
-
if (
|
|
1600
|
+
const { session: t, refLatestCoords: n, handleSubmitEdit: o, handleCancelEdit: r, cellBounds: i, isInBounds: l, getCellEditor: s, propsEditor: a, borderStrokeFill: d = "rgb(33, 115, 70)", borderStrokeWidth: g = 2, alignment: m = Wn.Left, style: f, ...x } = e, _ = Z(null), I = Z(null), [R, ae] = Ze(!1), P = t.coords, C = D(async (X) => {
|
|
1601
|
+
if (_.current?.getBoundingClientRect()) {
|
|
1602
1602
|
if (X.eventType === "keyboard") {
|
|
1603
|
-
const
|
|
1604
|
-
|
|
1603
|
+
const S = X.event, h = new KeyboardEvent(S.type, { bubbles: !0, cancelable: !0, view: window, key: S.key, code: S.code, location: S.location, repeat: S.repeat, isComposing: S.isComposing, charCode: S.charCode, keyCode: S.keyCode, which: S.which, ctrlKey: S.ctrlKey, shiftKey: S.shiftKey, altKey: S.altKey, metaKey: S.metaKey });
|
|
1604
|
+
h.isSynthetic = !0, h.key, I.current?.dispatchEvent(h);
|
|
1605
1605
|
} else X.eventType === "pointer" || console.warn("unsupported event type", X);
|
|
1606
|
-
await new Promise((
|
|
1606
|
+
await new Promise((S) => requestAnimationFrame(S));
|
|
1607
1607
|
}
|
|
1608
1608
|
}, []);
|
|
1609
1609
|
st(() => {
|
|
1610
1610
|
const X = I.current;
|
|
1611
1611
|
return ae(!0), I.current.startEdit?.(t.startEvent), (async () => {
|
|
1612
|
-
t.editorRefs.push(X), t.editorRefsDispatchEditorEvent.push(
|
|
1613
|
-
const
|
|
1614
|
-
for (let
|
|
1612
|
+
t.editorRefs.push(X), t.editorRefsDispatchEditorEvent.push(C);
|
|
1613
|
+
const T = [...t.events];
|
|
1614
|
+
for (let S = 0; S < T.length; S++) await C(T[S]);
|
|
1615
1615
|
t.onMount(X);
|
|
1616
1616
|
})(), () => {
|
|
1617
|
-
const
|
|
1618
|
-
|
|
1617
|
+
const T = t.editorRefs.indexOf(X);
|
|
1618
|
+
T !== -1 && t.editorRefs.splice(T, 1), t.onUnmount(X);
|
|
1619
1619
|
};
|
|
1620
1620
|
}, []);
|
|
1621
|
-
const
|
|
1621
|
+
const z = D(() => o(t), []), le = D(() => {
|
|
1622
1622
|
r(t);
|
|
1623
|
-
}, []),
|
|
1624
|
-
return
|
|
1623
|
+
}, []), B = n.current && G.isEqualCells(n.current, P), oe = l && B && R, ve = s({ autoFocus: !!t.startEvent?.autoFocus, ...a, onSubmitEdit: z, onCancelEdit: le, ref: I }, P), N = i.x + we.boundPixel(-g / 2), H = we.boundPixel(i.width + g / 2, !0);
|
|
1624
|
+
return q("div", { tabIndex: 0, ref: _, style: { background: void 0, ...f, opacity: oe ? f?.opacity ?? 1 : 0, pointerEvents: "auto", position: "absolute", boxSizing: "border-box", top: `${i.y + we.boundPixel(-g / 2)}px`, height: we.boundPixel(i.height + g / 2, !0), left: `${N}px`, width: H }, ...x, children: q("div", { className: "editor-container", style: { position: "absolute", boxSizing: "border-box", left: `${we.boundPixel(1)}px`, top: `${we.boundPixel(1)}px`, width: we.boundPixel(i.width - 2, !0), height: we.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: ve }) });
|
|
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:
|
|
1627
|
-
if (!
|
|
1628
|
-
const
|
|
1629
|
-
if (!
|
|
1630
|
-
|
|
1631
|
-
let
|
|
1632
|
-
if (
|
|
1633
|
-
let
|
|
1634
|
-
for (; !
|
|
1635
|
-
|
|
1636
|
-
const
|
|
1637
|
-
|
|
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: _ = null, activeCoords: I, alignment: R = Wn.Left } = e, [ae, P] = Ze(!1), [C, z] = Ze(void 0), le = k(($, E, Me, ue, me, Ve) => {
|
|
1627
|
+
if (!E) return null;
|
|
1628
|
+
const dt = me?.(E, $), kt = $.getRangeCoordsBounds(dt), ut = $.toClipBounds(kt), Zt = kt, St = $.getZoom();
|
|
1629
|
+
if (!ut) return null;
|
|
1630
|
+
Me && (Me *= St), ue && (ue *= St);
|
|
1631
|
+
let M = Zt, ye = !1;
|
|
1632
|
+
if (Me !== void 0) {
|
|
1633
|
+
let Qe = { ...dt }, cn = 0;
|
|
1634
|
+
for (; !ye && M.width <= Me && cn < 20; ) {
|
|
1635
|
+
cn++, cn > 19 && console.warn("max width reached");
|
|
1636
|
+
const on = $.getTotalRangeCoords(), Mt = $.getLayout();
|
|
1637
|
+
Ve === Wn.Left ? Qe.colEnd + 1 < on.colEnd ? Qe.colEnd = Mt.getColIndex(M.x + Me) : ye = !0 : Ve === Wn.Right ? Qe.colStart - 1 >= 0 ? Qe.colStart = Mt.getColIndex(M.x - (Me - M.width)) : ye = !0 : Ve === Wn.Center && Qe.colEnd + 1 < on.colEnd && Qe.colStart - 1 >= 0 ? (Qe.colStart = Mt.getColIndex(M.x - (Me - M.width) / 2), Qe.colEnd = Mt.getColIndex(M.x + M.width + (Me - M.width) / 2)) : ye = !0, ye || (M = $.getRangeCoordsBounds(Qe));
|
|
1638
1638
|
}
|
|
1639
1639
|
}
|
|
1640
|
-
|
|
1641
|
-
const { width:
|
|
1642
|
-
return { x:
|
|
1643
|
-
}, [
|
|
1640
|
+
M.height = Zt.height, ue !== void 0 && (M.height = Math.max(ue + 1, Zt.height));
|
|
1641
|
+
const { width: Je, height: mt } = $.getViewportSize();
|
|
1642
|
+
return { x: M.x ?? 0, y: M.y ?? 0, height: Math.min(mt - M.y, M.height) + 1, width: Math.min(Je - M.x, M.width) + 1 };
|
|
1643
|
+
}, [R]), B = k(n, [n]), oe = D(() => {
|
|
1644
1644
|
t?.getStage()?.focus();
|
|
1645
|
-
}, [t]),
|
|
1646
|
-
r?.(
|
|
1647
|
-
}, [r]),
|
|
1648
|
-
i?.(
|
|
1649
|
-
}, [i]),
|
|
1650
|
-
|
|
1651
|
-
}, [s]),
|
|
1652
|
-
if (
|
|
1645
|
+
}, [t]), ve = Z(null), N = k(($) => {
|
|
1646
|
+
r?.($), te(), P(!0), ve.current = null;
|
|
1647
|
+
}, [r]), H = k(($) => {
|
|
1648
|
+
i?.($.coords);
|
|
1649
|
+
}, [i]), X = k(($) => {
|
|
1650
|
+
$.isSubmitted || $.isCancelled || (h.current.isEditorClosed = !0, oe(), $.isCancelled = !0, s?.($.coords), te());
|
|
1651
|
+
}, [s]), T = k(($) => {
|
|
1652
|
+
if ($.isSubmitted || $.isCancelled) return !1;
|
|
1653
1653
|
try {
|
|
1654
|
-
return
|
|
1655
|
-
} catch (
|
|
1656
|
-
throw
|
|
1657
|
-
}
|
|
1658
|
-
}, [l]),
|
|
1659
|
-
|
|
1660
|
-
}, [a]),
|
|
1661
|
-
|
|
1662
|
-
}, []),
|
|
1663
|
-
if (
|
|
1664
|
-
const
|
|
1665
|
-
|
|
1666
|
-
}, [t]),
|
|
1667
|
-
const
|
|
1668
|
-
|
|
1669
|
-
}, [t]),
|
|
1670
|
-
if (
|
|
1671
|
-
const
|
|
1672
|
-
d(
|
|
1654
|
+
return ve.current = $.coords, $.isEditorClosing = !0, $.isSubmitted = !0, $.isEditorSubmitted || ($.isEditorSubmitted = !0, $.editorRefs[0]?.submitEdit?.()), $.coords, l?.($.coords), $.isEditorClosed = !0, oe(), te(), !0;
|
|
1655
|
+
} catch (E) {
|
|
1656
|
+
throw $.isEditorClosing = !1, $.isSubmitted = !1, E;
|
|
1657
|
+
}
|
|
1658
|
+
}, [l]), S = k(($) => {
|
|
1659
|
+
P(!1), a?.($.coords), te();
|
|
1660
|
+
}, [a]), h = Z(null), J = Z(null), K = Z(null), L = Z([]), [U, ee] = Qo(($) => $ + 1, 0), te = D(($) => {
|
|
1661
|
+
$ && L.current.push($), ee();
|
|
1662
|
+
}, []), Y = k(($) => {
|
|
1663
|
+
if ($.defaultPrevented || $.isSynthetic || !t) return;
|
|
1664
|
+
const E = t?.getCellCoordsFromClient($.clientX, $.clientY);
|
|
1665
|
+
E && te({ eventType: "pointer", event: $, coords: E });
|
|
1666
|
+
}, [t]), He = k(($) => {
|
|
1667
|
+
const E = $.nativeEvent;
|
|
1668
|
+
Y(E);
|
|
1669
|
+
}, [t]), je = k(($) => {
|
|
1670
|
+
if ($.defaultPrevented || $.isSynthetic || !t?.getStage()) return;
|
|
1671
|
+
const E = J.current;
|
|
1672
|
+
d($, E) && ($.stopPropagation(), $.preventDefault()), $.key, te({ eventType: "keyboard", event: $, coords: E });
|
|
1673
1673
|
}, [t]);
|
|
1674
|
-
|
|
1675
|
-
const
|
|
1676
|
-
const
|
|
1677
|
-
if (!
|
|
1678
|
-
const
|
|
1679
|
-
if (
|
|
1680
|
-
|
|
1681
|
-
const
|
|
1682
|
-
|
|
1683
|
-
const
|
|
1684
|
-
|
|
1685
|
-
}, onUnmount: (
|
|
1686
|
-
if (
|
|
1687
|
-
const
|
|
1688
|
-
|
|
1674
|
+
tn(() => {
|
|
1675
|
+
const $ = (ue, me) => {
|
|
1676
|
+
const Ve = me?.cell ?? ue;
|
|
1677
|
+
if (!Ve) return null;
|
|
1678
|
+
const dt = Ve;
|
|
1679
|
+
if (!B(Ve)) return null;
|
|
1680
|
+
N?.(Ve);
|
|
1681
|
+
const kt = Ct.uuidV4();
|
|
1682
|
+
me = Object.freeze({ autoFocus: !0, ...me }), K.current = Ve;
|
|
1683
|
+
const ut = { coords: dt, startEvent: me, uuid: kt, isMounted: !1, isStarted: !1, isSubmitted: !1, isEditorSubmitted: !1, isEditorClosing: !1, isEditorClosed: !1, isCancelled: !1, events: [], editorRefsDispatchEditorEvent: [], editorRefs: [], onMount: (Zt) => {
|
|
1684
|
+
ut.isMounted || (ut.isMounted = !0, te());
|
|
1685
|
+
}, onUnmount: (Zt) => {
|
|
1686
|
+
if (ut.editorRefs.length === 0) {
|
|
1687
|
+
const St = () => {
|
|
1688
|
+
ut.isMounted = !1, te();
|
|
1689
1689
|
};
|
|
1690
|
-
if (document.activeElement !== document.body)
|
|
1690
|
+
if (document.activeElement !== document.body) St();
|
|
1691
1691
|
else {
|
|
1692
|
-
const
|
|
1693
|
-
|
|
1692
|
+
const M = (ye) => {
|
|
1693
|
+
ye.defaultPrevented || ye.target !== document.body || je(ye);
|
|
1694
1694
|
};
|
|
1695
|
-
window.addEventListener("keydown",
|
|
1696
|
-
window.removeEventListener("keydown",
|
|
1695
|
+
window.addEventListener("keydown", M, !0), t.getStage()?.addEventListener("focusin", () => {
|
|
1696
|
+
window.removeEventListener("keydown", M), St();
|
|
1697
1697
|
}, { once: !0 }), oe();
|
|
1698
1698
|
}
|
|
1699
1699
|
}
|
|
1700
1700
|
} };
|
|
1701
|
-
return
|
|
1701
|
+
return ut;
|
|
1702
1702
|
};
|
|
1703
|
-
if (
|
|
1704
|
-
const
|
|
1705
|
-
Lr(
|
|
1706
|
-
const
|
|
1707
|
-
for (let
|
|
1708
|
-
const
|
|
1709
|
-
|
|
1703
|
+
if (L.current.length <= 0 && !h.current) return;
|
|
1704
|
+
const E = L.current[0];
|
|
1705
|
+
Lr(E), ((ue) => {
|
|
1706
|
+
const me = [], Ve = ue?.length ?? 0;
|
|
1707
|
+
for (let dt = 0; dt < Ve; dt++) {
|
|
1708
|
+
const kt = ue[dt];
|
|
1709
|
+
me.push(Lr(kt));
|
|
1710
1710
|
}
|
|
1711
|
-
})(
|
|
1712
|
-
let
|
|
1713
|
-
if (
|
|
1714
|
-
if (
|
|
1715
|
-
else if (
|
|
1716
|
-
if (
|
|
1717
|
-
|
|
1711
|
+
})(L.current), h.current, h.current;
|
|
1712
|
+
let Me = h.current;
|
|
1713
|
+
if (h.current) {
|
|
1714
|
+
if (h.current.isDone) h.current = null;
|
|
1715
|
+
else if (h.current.isSubmitted || h.current.isCancelled) {
|
|
1716
|
+
if (h.current.isMounted) return;
|
|
1717
|
+
h.current.isDone || (S(h.current), h.current.isDone = !0);
|
|
1718
1718
|
}
|
|
1719
1719
|
}
|
|
1720
|
-
if (
|
|
1721
|
-
if (
|
|
1722
|
-
const
|
|
1723
|
-
|
|
1724
|
-
} else if (
|
|
1725
|
-
const
|
|
1726
|
-
if (
|
|
1727
|
-
|
|
1728
|
-
for (let
|
|
1729
|
-
} else if (d(
|
|
1730
|
-
let
|
|
1731
|
-
const
|
|
1732
|
-
|
|
1720
|
+
if (E) {
|
|
1721
|
+
if (E.eventType === "start") {
|
|
1722
|
+
const ue = E, me = ue.startEvent?.cell ?? J.current;
|
|
1723
|
+
h.current && G.isEqualCells(h.current.coords, me) || (h.current = $(me, ue.startEvent));
|
|
1724
|
+
} else if (E.eventType === "keyboard") {
|
|
1725
|
+
const ue = E.event;
|
|
1726
|
+
if (h.current) {
|
|
1727
|
+
ue.key, h.current.events, h.current.events.push(E);
|
|
1728
|
+
for (let me = 0; me < h.current.editorRefsDispatchEditorEvent.length; me++) h.current.editorRefsDispatchEditorEvent[me](E);
|
|
1729
|
+
} else if (d(ue, E.coords)) {
|
|
1730
|
+
let me;
|
|
1731
|
+
const Ve = $(me?.cell ?? J.current, me);
|
|
1732
|
+
Ve && Ve.events.push(E), h.current = Ve;
|
|
1733
1733
|
}
|
|
1734
|
-
} else if (
|
|
1735
|
-
const
|
|
1736
|
-
if (
|
|
1737
|
-
|
|
1738
|
-
for (let
|
|
1734
|
+
} else if (E.eventType === "pointer") {
|
|
1735
|
+
const ue = E.event;
|
|
1736
|
+
if (h.current) {
|
|
1737
|
+
h.current.events.push(E);
|
|
1738
|
+
for (let me = 0; me < h.current.editorRefsDispatchEditorEvent.length; me++) h.current.editorRefsDispatchEditorEvent[me](E);
|
|
1739
1739
|
} else {
|
|
1740
|
-
const
|
|
1741
|
-
if (
|
|
1742
|
-
let
|
|
1743
|
-
typeof
|
|
1744
|
-
const
|
|
1745
|
-
|
|
1740
|
+
const me = E?.coords ?? J.current, Ve = g(ue, me);
|
|
1741
|
+
if (Ve) {
|
|
1742
|
+
let dt;
|
|
1743
|
+
typeof dt != "boolean" && (dt = Ve);
|
|
1744
|
+
const kt = $(me, dt);
|
|
1745
|
+
kt && kt.events.push(E), h.current = kt;
|
|
1746
1746
|
}
|
|
1747
1747
|
}
|
|
1748
|
-
} else if (
|
|
1749
|
-
if (
|
|
1750
|
-
if (!
|
|
1751
|
-
|
|
1748
|
+
} else if (E.eventType === "submit") {
|
|
1749
|
+
if (h.current && !h.current.isSubmitted && !h.current.isCancelled) {
|
|
1750
|
+
if (!h.current.isMounted) return;
|
|
1751
|
+
T(h.current);
|
|
1752
1752
|
}
|
|
1753
|
-
} else if (
|
|
1754
|
-
if (
|
|
1755
|
-
if (!
|
|
1756
|
-
|
|
1753
|
+
} else if (E.eventType === "cancel") {
|
|
1754
|
+
if (h.current && !h.current.isSubmitted && !h.current.isCancelled) {
|
|
1755
|
+
if (!h.current.isMounted) return;
|
|
1756
|
+
X(h.current);
|
|
1757
1757
|
}
|
|
1758
|
-
} else if (
|
|
1759
|
-
const
|
|
1760
|
-
if (
|
|
1761
|
-
if (!
|
|
1758
|
+
} else if (E.eventType === "coordsChange") {
|
|
1759
|
+
const ue = E;
|
|
1760
|
+
if (J.current = ue.activeCoords, h.current, h.current && !h.current.isSubmitted && !h.current.isCancelled) {
|
|
1761
|
+
if (!h.current.isMounted) return;
|
|
1762
1762
|
try {
|
|
1763
|
-
|
|
1763
|
+
T(h.current);
|
|
1764
1764
|
} catch {
|
|
1765
1765
|
}
|
|
1766
1766
|
}
|
|
1767
1767
|
}
|
|
1768
1768
|
}
|
|
1769
|
-
|
|
1770
|
-
t &&
|
|
1769
|
+
L.current.length > 0 && (L.current.shift(), te()), L.current.length === 0 && (!h.current || h.current.isEditorClosing || h.current.isEditorClosed ? !h.current && Me && oe() : h.current.isMounted && !h.current.isStarted && (h.current.isStarted = !0, h.current.startEvent.autoFocus && (typeof h.current.startEvent.autoFocus == "string" ? h.current.editorRefs[0]?.autoFocus(h.current.startEvent.autoFocus) : h.current.editorRefs[0]?.autoFocus()), H?.(h.current), requestAnimationFrame(() => {
|
|
1770
|
+
t && h.current?.coords && t.scrollCellCoordsIntoView(h.current.coords);
|
|
1771
1771
|
})));
|
|
1772
|
-
}, [
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1772
|
+
}, [U]), st(() => {
|
|
1773
|
+
if (ve.current && G.isEqualCells(ve.current, I)) return;
|
|
1774
|
+
K.current = I;
|
|
1775
|
+
const $ = h.current?.coords;
|
|
1776
|
+
G.isEqualCells($, I) || (h.current && (h.current.isEditorClosing = !0), te({ eventType: "coordsChange", activeCoords: I }));
|
|
1776
1777
|
}, [I]);
|
|
1777
|
-
const
|
|
1778
|
-
|
|
1779
|
-
}, []), { width:
|
|
1780
|
-
return { overlay:
|
|
1781
|
-
if (!
|
|
1782
|
-
|
|
1783
|
-
let
|
|
1784
|
-
|
|
1785
|
-
const
|
|
1786
|
-
return
|
|
1787
|
-
}, [o,
|
|
1788
|
-
|
|
1789
|
-
}, []), submitEdit:
|
|
1790
|
-
|
|
1791
|
-
}, []), cancelEdit:
|
|
1792
|
-
|
|
1793
|
-
}, []), onKeyboardEvent:
|
|
1794
|
-
}, ws = ({ gridRef: e, gridMainRef: t, orientation: n =
|
|
1795
|
-
const
|
|
1796
|
-
|
|
1797
|
-
},
|
|
1778
|
+
const Ne = D(($) => {
|
|
1779
|
+
je($.nativeEvent);
|
|
1780
|
+
}, []), { width: at = 0, height: Se = 0 } = C ?? { width: 0, height: 0 }, Ye = k(o, [o]);
|
|
1781
|
+
return { overlay: k(($) => {
|
|
1782
|
+
if (!h.current || h.current.isEditorClosed) return h.current, null;
|
|
1783
|
+
h.current.coords;
|
|
1784
|
+
let E = le($, h.current.coords, at, Se, _, R), Me = !0;
|
|
1785
|
+
E && E.width !== 0 && E.height !== 0 || (E = { x: 0, y: 0, width: at, height: at }, Me = !1);
|
|
1786
|
+
const ue = $.getZoom(), me = { containerBounds: { x: 0, y: 0, width: E.width / ue, height: E.height / ue }, setNaturalDimensions: z, zoom: ue };
|
|
1787
|
+
return q(Hl, { session: h.current, refLatestCoords: K, handleSubmitEdit: T, handleCancelEdit: X, cellBounds: E, borderStrokeWidth: x, borderStrokeFill: f, isInBounds: Me, getCellEditor: Ye, propsEditor: me, alignment: R, ...m }, "editor:" + h.current.uuid);
|
|
1788
|
+
}, [o, _, U, at, Se, R, x, f]), startEdit: D(($) => {
|
|
1789
|
+
te({ eventType: "start", startEvent: $ });
|
|
1790
|
+
}, []), submitEdit: D(() => {
|
|
1791
|
+
te({ eventType: "submit" });
|
|
1792
|
+
}, []), cancelEdit: D(() => {
|
|
1793
|
+
te({ eventType: "cancel" });
|
|
1794
|
+
}, []), onKeyboardEvent: Ne, onPointerEvent: He, onKeyboardEventNative: je, onPointerEventNative: Y, isEditing: ae };
|
|
1795
|
+
}, ws = ({ gridRef: e, gridMainRef: t, orientation: n = an, headerCount: o, selectionPolicy: r = "multiple", newSelectionMode: i = "clear", alwaysScrollToActiveCoords: l = !0, onDragStart: s, onDragEnd: a, pointerDownInterceptor: d, pointerMoveInterceptor: g, onPointerUp: m, newSelection: f, modifySelection: x, appendSelection: _, clearSelections: I }) => {
|
|
1796
|
+
const R = o ?? ((n === an ? e.current?.rowCount : e.current?.columnCount) || 0), ae = Z(null), P = Z(null), C = Z(!1), z = Z(null), le = D((S) => n === Nt ? { rowIndex: 0, colIndex: S.colIndex } : { rowIndex: S.rowIndex, colIndex: 0 }, [n]), B = D((S) => n === Nt ? { rowIndex: t.current ? t.current.rowCount - 1 : 0, colIndex: S.colIndex } : { rowIndex: S.rowIndex, colIndex: t.current ? t.current.columnCount - 1 : 0 }, [n]), oe = (S) => {
|
|
1797
|
+
P.current = B(S), x(P.current, ae.current);
|
|
1798
|
+
}, ve = D((S, h) => {
|
|
1798
1799
|
if (!e.current) return;
|
|
1799
|
-
const
|
|
1800
|
-
return
|
|
1801
|
-
}, []),
|
|
1802
|
-
let
|
|
1803
|
-
return
|
|
1804
|
-
}, [n]), H =
|
|
1805
|
-
if (!e || !e.current ||
|
|
1806
|
-
const
|
|
1807
|
-
if (!
|
|
1808
|
-
|
|
1809
|
-
const
|
|
1810
|
-
if (d?.(
|
|
1811
|
-
X?.(),
|
|
1812
|
-
const
|
|
1813
|
-
if (
|
|
1800
|
+
const J = e.current.getViewFromClient(S, h)?.getCellCoordsFromClient(S, h);
|
|
1801
|
+
return J ? (n === Nt ? J.rowIndex = t.current.getViewport().rowStart : J.colIndex = t.current.getViewport().colStart, J) : void 0;
|
|
1802
|
+
}, []), N = D((S, h = !1) => {
|
|
1803
|
+
let J = S;
|
|
1804
|
+
return h || (J = { ...S }, n === an ? delete J.colIndex : delete J.rowIndex), t.current?.scrollCellCoordsIntoView(J);
|
|
1805
|
+
}, [n]), H = k(a, [a]), X = k(s, [s]), T = _e(() => ({ onPointerDown: (S) => {
|
|
1806
|
+
if (!e || !e.current || S.nativeEvent.defaultPrevented) return;
|
|
1807
|
+
const h = ve(S.nativeEvent.clientX, S.nativeEvent.clientY);
|
|
1808
|
+
if (!h) return;
|
|
1809
|
+
S.nativeEvent.which;
|
|
1810
|
+
const J = S.nativeEvent.shiftKey, K = S.nativeEvent.ctrlKey || S.nativeEvent.metaKey;
|
|
1811
|
+
if (d?.(S, h) === !1) return;
|
|
1812
|
+
X?.(), C.current = !0;
|
|
1813
|
+
const L = t.current?.getViewFromClient(S.nativeEvent.clientX, S.nativeEvent.clientY), U = ((ee, te) => n === Nt ? { ...ee, rowIndex: te.rowStart } : { ...ee, colIndex: te.colStart })(h, L.getVisibleRangeCoords());
|
|
1814
|
+
if (J) oe(h);
|
|
1814
1815
|
else {
|
|
1815
|
-
if (
|
|
1816
|
-
ae.current = le(
|
|
1817
|
-
})(
|
|
1818
|
-
((
|
|
1819
|
-
ae.current = le(
|
|
1820
|
-
})(
|
|
1821
|
-
}
|
|
1822
|
-
}, onPointerMoveOrWait: Ct.throttle((
|
|
1823
|
-
if (!
|
|
1824
|
-
const
|
|
1825
|
-
if (
|
|
1826
|
-
if (
|
|
1827
|
-
oe(
|
|
1828
|
-
}
|
|
1829
|
-
}, 60), onPointerUp: (
|
|
1830
|
-
|
|
1831
|
-
}, processTouch: !0, consumeTouch: !0 }), [r, l,
|
|
1832
|
-
return { onPointerDown:
|
|
1833
|
-
},
|
|
1816
|
+
if (K) return ((ee, te = ee, Y) => {
|
|
1817
|
+
ae.current = le(ee), P.current = B(te), _(ae.current, P.current, Y);
|
|
1818
|
+
})(h, h, U), void (l && N(U, !0));
|
|
1819
|
+
((ee, te = ee, Y) => {
|
|
1820
|
+
ae.current = le(ee), P.current = B(te), f(ae.current, P.current, Y);
|
|
1821
|
+
})(h, h, U), oe(h), l && N(U, !0);
|
|
1822
|
+
}
|
|
1823
|
+
}, onPointerMoveOrWait: Ct.throttle((S) => {
|
|
1824
|
+
if (!C.current || !e?.current) return;
|
|
1825
|
+
const h = ve(S.clientX, S.clientY);
|
|
1826
|
+
if (h && g?.(S, h) !== !1) {
|
|
1827
|
+
if (G.isEqualCells(z.current, h)) return I();
|
|
1828
|
+
oe(h), N(h);
|
|
1829
|
+
}
|
|
1830
|
+
}, 60), onPointerUp: (S) => {
|
|
1831
|
+
C.current = !1, H?.(), m?.(S);
|
|
1832
|
+
}, processTouch: !0, consumeTouch: !0 }), [r, l, R, i, I, d, m]);
|
|
1833
|
+
return { onPointerDown: k(On(T), []), getCellCoordsFromClient: ve };
|
|
1834
|
+
}, qe = (e, t, n) => {
|
|
1834
1835
|
if (!e) return t;
|
|
1835
1836
|
let o = t;
|
|
1836
1837
|
const r = n === Ke || n === lt;
|
|
@@ -1852,27 +1853,27 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1852
1853
|
let { rowIndex: l, colIndex: s } = e;
|
|
1853
1854
|
switch (o) {
|
|
1854
1855
|
case lt: {
|
|
1855
|
-
l =
|
|
1856
|
+
l = qe(n, Math.min(l + 1, i), o);
|
|
1856
1857
|
let a = t({ rowIndex: l, colIndex: s });
|
|
1857
|
-
for (; !a && l < i; ) l =
|
|
1858
|
+
for (; !a && l < i; ) l = qe(n, Math.min(++l, i), o), a = t({ rowIndex: l, colIndex: s });
|
|
1858
1859
|
return l;
|
|
1859
1860
|
}
|
|
1860
1861
|
case it: {
|
|
1861
|
-
l =
|
|
1862
|
+
l = qe(n, Math.max(l - 1, i), o);
|
|
1862
1863
|
let a = t({ rowIndex: l, colIndex: s });
|
|
1863
|
-
for (; !a && l > i; ) l =
|
|
1864
|
+
for (; !a && l > i; ) l = qe(n, Math.max(--l, i), o), a = t({ rowIndex: l, colIndex: s });
|
|
1864
1865
|
return l;
|
|
1865
1866
|
}
|
|
1866
1867
|
case Ke: {
|
|
1867
|
-
s =
|
|
1868
|
+
s = qe(n, Math.min(s + 1, i), o);
|
|
1868
1869
|
let a = t({ rowIndex: l, colIndex: s });
|
|
1869
|
-
for (; !a && s < i; ) s =
|
|
1870
|
+
for (; !a && s < i; ) s = qe(n, Math.min(++s, i), o), a = t({ rowIndex: l, colIndex: s });
|
|
1870
1871
|
return s;
|
|
1871
1872
|
}
|
|
1872
1873
|
case ot: {
|
|
1873
|
-
s =
|
|
1874
|
+
s = qe(n, Math.max(s - 1, i), o);
|
|
1874
1875
|
let a = t({ rowIndex: l, colIndex: s });
|
|
1875
|
-
for (; !a && s > i; ) s =
|
|
1876
|
+
for (; !a && s > i; ) s = qe(n, Math.max(--s, i), o), a = t({ rowIndex: l, colIndex: s });
|
|
1876
1877
|
return s;
|
|
1877
1878
|
}
|
|
1878
1879
|
default:
|
|
@@ -1882,33 +1883,33 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1882
1883
|
let { rowIndex: l, colIndex: s } = e;
|
|
1883
1884
|
switch (o) {
|
|
1884
1885
|
case lt: {
|
|
1885
|
-
l =
|
|
1886
|
+
l = qe(n, Math.min(l + 1, i), o);
|
|
1886
1887
|
let a = t?.({ rowIndex: l, colIndex: s });
|
|
1887
|
-
for (; a && l < i; ) l =
|
|
1888
|
+
for (; a && l < i; ) l = qe(n, Math.min(++l, i), o), a = t?.({ rowIndex: l, colIndex: s });
|
|
1888
1889
|
return t?.({ rowIndex: l, colIndex: s }) ? l : l - 1;
|
|
1889
1890
|
}
|
|
1890
1891
|
case it: {
|
|
1891
|
-
l =
|
|
1892
|
+
l = qe(n, Math.max(l - 1, i), o);
|
|
1892
1893
|
let a = t?.({ rowIndex: l, colIndex: s });
|
|
1893
|
-
for (; a && l > i; ) l =
|
|
1894
|
+
for (; a && l > i; ) l = qe(n, Math.max(--l, i), o), a = t?.({ rowIndex: l, colIndex: s });
|
|
1894
1895
|
return t?.({ rowIndex: l, colIndex: s }) ? l : l + 1;
|
|
1895
1896
|
}
|
|
1896
1897
|
case Ke: {
|
|
1897
|
-
s =
|
|
1898
|
+
s = qe(n, Math.min(s + 1, i), o);
|
|
1898
1899
|
let a = t?.({ rowIndex: l, colIndex: s });
|
|
1899
|
-
for (; a && s < i; ) s =
|
|
1900
|
+
for (; a && s < i; ) s = qe(n, Math.min(++s, i), o), a = t?.({ rowIndex: l, colIndex: s });
|
|
1900
1901
|
return t?.({ rowIndex: l, colIndex: s }) ? s : s - 1;
|
|
1901
1902
|
}
|
|
1902
1903
|
case ot: {
|
|
1903
|
-
s =
|
|
1904
|
+
s = qe(n, Math.max(s - 1, i), o);
|
|
1904
1905
|
let a = t?.({ rowIndex: l, colIndex: s });
|
|
1905
|
-
for (; a && s > i; ) s =
|
|
1906
|
+
for (; a && s > i; ) s = qe(n, Math.max(--s, i), o), a = t?.({ rowIndex: l, colIndex: s });
|
|
1906
1907
|
return t?.({ rowIndex: l, colIndex: s }) ? s : s + 1;
|
|
1907
1908
|
}
|
|
1908
1909
|
default:
|
|
1909
1910
|
return null;
|
|
1910
1911
|
}
|
|
1911
|
-
},
|
|
1912
|
+
}, Kl = (e, t, n, o, r, i) => {
|
|
1912
1913
|
if (!t) return i;
|
|
1913
1914
|
let l, { rowIndex: s, colIndex: a } = e;
|
|
1914
1915
|
o === lt ? l = { rowIndex: s + 1, colIndex: a } : o === it ? l = { rowIndex: s - 1, colIndex: a } : o === Ke ? l = { rowIndex: s, colIndex: a + 1 } : o === ot && (l = { rowIndex: s, colIndex: a - 1 });
|
|
@@ -1920,22 +1921,22 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1920
1921
|
let l = o;
|
|
1921
1922
|
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
1923
|
}, Ar = (e, t, n, o) => (console.log("todo: implement convertToVisibleRanges"), e), Xo = (e, t = Ke, n, o, r, i = null) => {
|
|
1923
|
-
if (i &&
|
|
1924
|
+
if (i && G.isEqualSelectionCoords(i, e)) return e;
|
|
1924
1925
|
const l = e.ranges[e.rangeIndex];
|
|
1925
|
-
if (!
|
|
1926
|
+
if (!G.isRangesIntersect({ rowStart: e.cell.rowIndex, colStart: e.cell.colIndex, rowEnd: e.cell.rowIndex, colEnd: e.cell.colIndex }, l)) return e;
|
|
1926
1927
|
let s = { ...e.cell }, a = e.rangeIndex;
|
|
1927
1928
|
switch (t) {
|
|
1928
1929
|
case Ke:
|
|
1929
|
-
s.colIndex =
|
|
1930
|
+
s.colIndex = qe(r, s.colIndex + 1, t);
|
|
1930
1931
|
break;
|
|
1931
1932
|
case ot:
|
|
1932
|
-
s.colIndex =
|
|
1933
|
+
s.colIndex = qe(r, s.colIndex - 1, t);
|
|
1933
1934
|
break;
|
|
1934
1935
|
case lt:
|
|
1935
|
-
s.rowIndex =
|
|
1936
|
+
s.rowIndex = qe(o, s.rowIndex + 1, t);
|
|
1936
1937
|
break;
|
|
1937
1938
|
case it:
|
|
1938
|
-
s.rowIndex =
|
|
1939
|
+
s.rowIndex = qe(o, s.rowIndex - 1, t);
|
|
1939
1940
|
}
|
|
1940
1941
|
const d = (f) => {
|
|
1941
1942
|
if (f) {
|
|
@@ -1956,25 +1957,25 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
1956
1957
|
let f = s.rowIndex, x = s.colIndex;
|
|
1957
1958
|
switch (t) {
|
|
1958
1959
|
case Ke:
|
|
1959
|
-
x > l.colEnd && (f =
|
|
1960
|
+
x > l.colEnd && (f = qe(o, f + 1, t), x = l.colStart, f > l.rowEnd && (f = l.rowStart));
|
|
1960
1961
|
break;
|
|
1961
1962
|
case ot:
|
|
1962
|
-
x < l.colStart && (f =
|
|
1963
|
+
x < l.colStart && (f = qe(o, f - 1, t), x = l.colEnd, f < l.rowStart && (f = l.rowEnd));
|
|
1963
1964
|
break;
|
|
1964
1965
|
case lt:
|
|
1965
|
-
f > l.rowEnd && (x =
|
|
1966
|
+
f > l.rowEnd && (x = qe(r, x + 1, t), f = l.rowStart, x > l.colEnd && (x = l.colStart));
|
|
1966
1967
|
break;
|
|
1967
1968
|
case it:
|
|
1968
|
-
f < l.rowStart && (x =
|
|
1969
|
+
f < l.rowStart && (x = qe(r, x - 1, t), f = l.rowEnd, x < l.colStart && (x = l.colEnd));
|
|
1969
1970
|
}
|
|
1970
1971
|
s = { rowIndex: f, colIndex: x };
|
|
1971
1972
|
}
|
|
1972
1973
|
let g = n(s);
|
|
1973
|
-
if (!
|
|
1974
|
-
const f =
|
|
1974
|
+
if (!G.isRangeWithinRange(g, l)) {
|
|
1975
|
+
const f = G.intersectRanges(g, l);
|
|
1975
1976
|
f && (g = f);
|
|
1976
1977
|
}
|
|
1977
|
-
let m = { rowStart:
|
|
1978
|
+
let m = { rowStart: qe(o, g.rowStart, lt), colStart: qe(r, g.colStart, Ke), rowEnd: qe(o, g.rowEnd, it), colEnd: qe(r, g.colEnd, ot) };
|
|
1978
1979
|
if (m.rowStart !== s.rowIndex || m.colStart !== s.colIndex) {
|
|
1979
1980
|
switch (t) {
|
|
1980
1981
|
case Ke:
|
|
@@ -2017,36 +2018,36 @@ const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
|
2017
2018
|
}, Fr = (e, t, n) => {
|
|
2018
2019
|
const o = e.getColOffset(t.colStart) + (n?.left ?? 0), r = e.getRowOffset(t.rowStart) + (n?.top ?? 0);
|
|
2019
2020
|
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
|
-
},
|
|
2021
|
+
}, 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 ${we.boundPixel(e.left)} ${we.boundPixel(e.top)} L ${we.boundPixel(e.right, !0)} ${we.boundPixel(e.top)} L ${we.boundPixel(e.right, !0)} ${we.boundPixel(e.bottom, !0)} L ${we.boundPixel(e.left)} ${we.boundPixel(e.bottom, !0)} L ${we.boundPixel(e.left)} ${we.boundPixel(e.top)} ${t ? "Z" : ""}`, jr = (e) => {
|
|
2021
2022
|
const { linePoints: t, bounds: n, pathProps: o, style: r, ...i } = e;
|
|
2022
|
-
return
|
|
2023
|
+
return q("svg", { width: `${we.boundPixel(n.width, !0)}`, height: `${we.boundPixel(n.height, !0)}`, viewBox: `0 0 ${we.boundPixel(n.width, !0)} ${we.boundPixel(n.height, !0)}`, style: { position: "absolute", left: `${we.boundPixel(n.x)}px`, top: `${we.boundPixel(n.y)}px`, width: `${we.boundPixel(n.width, !0)}px`, height: `${we.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: q("path", { d: `M ${we.boundPixel(t[0])} ${we.boundPixel(t[1])} L ${we.boundPixel(t[2])} ${we.boundPixel(t[3])}`, fill: "none", vectorEffect: "non-scaling-stroke", stroke: "black", ...o }) });
|
|
2023
2024
|
}, Yl = (e) => {
|
|
2024
|
-
const { x: t = 0, y: n = 0, width: o = 0, height: r = 0, fill: i, stroke: l, strokeWidth: s = 0, strokeDasharray: a, strokeDashoffset: d, clipPath: g, pathBounds: m, pathProps: f, style: x, ...
|
|
2025
|
-
let
|
|
2025
|
+
const { x: t = 0, y: n = 0, width: o = 0, height: r = 0, fill: i, stroke: l, strokeWidth: s = 0, strokeDasharray: a, strokeDashoffset: d, clipPath: g, pathBounds: m, pathProps: f, style: x, ..._ } = e, I = n, R = t, ae = o, P = r;
|
|
2026
|
+
let C = null;
|
|
2026
2027
|
if (i) {
|
|
2027
|
-
let
|
|
2028
|
-
m && (
|
|
2028
|
+
let z = $o({ top: 0, left: 0, bottom: P, right: ae });
|
|
2029
|
+
m && (z = z + " " + $o({ top: m.y - I, left: m.x - R, bottom: m.height + m.y - I, right: m.width + m.x - R })), C = [q("path", { d: z, fill: i, stroke: "none", fillRule: "evenodd" }, "fill")];
|
|
2029
2030
|
}
|
|
2030
|
-
return Ht("svg", { width: `${
|
|
2031
|
+
return Ht("svg", { width: `${we.boundPixel(o, !0)}`, height: `${we.boundPixel(r, !0)}`, viewBox: `0 0 ${we.boundPixel(o, !0)} ${we.boundPixel(r, !0)}`, preserveAspectRatio: "none", style: { position: "absolute", left: `${we.boundPixel(t)}px`, top: `${we.boundPixel(n)}px`, pointerEvents: "none", transitionDuration: "0ms", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top, width, height", willChange: "left, top, width, height, stroke-dashoffset", boxShadow: "rgb(60 64 67 / 5%) 0px 1px 4px 2px, rgb(255 255 255 / 15%) 0px 0px 2px 1px", overflow: "visible", ...x }, ..._, children: [C, q("path", { d: $o({ top: 0, left: 0, right: ae, bottom: P }), fill: "none", strokeDasharray: a, strokeDashoffset: d, stroke: l, vectorEffect: "non-scaling-stroke", strokeWidth: s, ...f })] });
|
|
2031
2032
|
}, Xl = (e) => {
|
|
2032
2033
|
const { key: t, ...n } = e;
|
|
2033
|
-
return
|
|
2034
|
-
}, yi =
|
|
2035
|
-
const { stroke: t, fill: n, x: o = 0, y: r = 0, width: i = 0, height: l = 0, style: s, isAnimatedStroke: a, animatedStrokeProps: d, range: g, cell: m, ...f } = e, x = a || !!d,
|
|
2036
|
-
let I =
|
|
2037
|
-
const
|
|
2038
|
-
let
|
|
2034
|
+
return q(yi, { ...n }, t);
|
|
2035
|
+
}, yi = At((e) => {
|
|
2036
|
+
const { stroke: t, fill: n, x: o = 0, y: r = 0, width: i = 0, height: l = 0, style: s, isAnimatedStroke: a, animatedStrokeProps: d, range: g, cell: m, ...f } = e, x = a || !!d, _ = { name: "walking-offset", dashGap: 2, speed: 50, dashLength: 8, ...d };
|
|
2037
|
+
let I = _.dashGap + _.dashLength;
|
|
2038
|
+
const R = _.speed * I, ae = $l().replaceAll(":", ""), P = `${_.name}-${ae}`;
|
|
2039
|
+
let C;
|
|
2039
2040
|
return st(() => {
|
|
2040
2041
|
if (!x) return;
|
|
2041
|
-
const
|
|
2042
|
+
const z = `@keyframes ${P} {
|
|
2042
2043
|
to {
|
|
2043
2044
|
stroke-dashoffset: 0px;
|
|
2044
2045
|
}
|
|
2045
2046
|
}`, le = document.createElement("style");
|
|
2046
|
-
return le.appendChild(document.createTextNode(
|
|
2047
|
+
return le.appendChild(document.createTextNode(z)), document.head.appendChild(le), le.sheet.insertRule(z, 0), () => {
|
|
2047
2048
|
document.head.removeChild(le);
|
|
2048
2049
|
};
|
|
2049
|
-
}, [x]), x && (
|
|
2050
|
+
}, [x]), x && (C = { strokeDasharray: `${_.dashLength}px ${_.dashGap}px`, strokeDashoffset: `${I}px`, animation: `${P} ${R}ms linear infinite`, willChange: "stroke-dashoffset" }), q(Yl, { x: o, y: r, width: i, height: l, stroke: t, fill: n, shapeRendering: "crispEdges", style: { ...C, ...s }, ...f });
|
|
2050
2051
|
});
|
|
2051
2052
|
function bi(e) {
|
|
2052
2053
|
var t, n, o = "";
|
|
@@ -2062,10 +2063,10 @@ function En() {
|
|
|
2062
2063
|
return o;
|
|
2063
2064
|
}
|
|
2064
2065
|
yi.displayName = "Selection";
|
|
2065
|
-
const Si =
|
|
2066
|
+
const Si = At(Ut((e, t) => {
|
|
2066
2067
|
const { x: n = 0, y: o = 0, borderWidth: r = 1, size: i = 6, borderStroke: l, corner: s, style: a, className: d, background: g, ...m } = e;
|
|
2067
2068
|
if (n === 0 || o === 0) return null;
|
|
2068
|
-
let f = !0, x = !0,
|
|
2069
|
+
let f = !0, x = !0, _ = !0, I = !0;
|
|
2069
2070
|
switch (s) {
|
|
2070
2071
|
case "tl":
|
|
2071
2072
|
f = !1, x = !1;
|
|
@@ -2074,22 +2075,22 @@ const Si = Dt(Ut((e, t) => {
|
|
|
2074
2075
|
f = !1, I = !1;
|
|
2075
2076
|
break;
|
|
2076
2077
|
case "br":
|
|
2077
|
-
|
|
2078
|
+
_ = !1, I = !1;
|
|
2078
2079
|
break;
|
|
2079
2080
|
case "tr":
|
|
2080
|
-
x = !1,
|
|
2081
|
+
x = !1, _ = !1;
|
|
2081
2082
|
}
|
|
2082
|
-
return
|
|
2083
|
+
return q("div", { className: En("fill-handle", d), style: { position: "absolute", left: n - (i + (f ? r : 0)) / 2, top: o - (i + (x ? r : 0)) / 2, width: i, height: i, borderLeft: f ? `${r}px ${l}` : void 0, borderTop: x ? `${r}px ${l}` : void 0, borderRight: _ ? `${r}px ${l}` : void 0, borderBottom: I ? `${r}px ${l}` : void 0, background: g, cursor: "crosshair", pointerEvents: "all", transitionDuration: "0ms", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top", willChange: "left, top", ...a }, tabIndex: -1, ...m });
|
|
2083
2084
|
}));
|
|
2084
2085
|
Si.displayName = "FillHandle";
|
|
2085
2086
|
var Gl = function() {
|
|
2086
|
-
}, Ei = typeof window < "u", Zl = Ei ?
|
|
2087
|
+
}, Ei = typeof window < "u", Zl = Ei ? tn : st, Vr = { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, bottom: 0, right: 0 };
|
|
2087
2088
|
const _i = Ei && window.ResizeObserver !== void 0 ? function() {
|
|
2088
|
-
var e =
|
|
2089
|
+
var e = Ze(null), t = e[0], n = e[1], o = Ze(Vr), r = o[0], i = o[1], l = _e(function() {
|
|
2089
2090
|
return new window.ResizeObserver(function(s) {
|
|
2090
2091
|
if (s[0]) {
|
|
2091
|
-
var a = s[0].contentRect, d = a.x, g = a.y, m = a.width, f = a.height, x = a.top,
|
|
2092
|
-
i({ x: d, y: g, width: m, height: f, top: x, left:
|
|
2092
|
+
var a = s[0].contentRect, d = a.x, g = a.y, m = a.width, f = a.height, x = a.top, _ = a.left, I = a.bottom, R = a.right;
|
|
2093
|
+
i({ x: d, y: g, width: m, height: f, top: x, left: _, bottom: I, right: R });
|
|
2093
2094
|
}
|
|
2094
2095
|
});
|
|
2095
2096
|
}, []);
|
|
@@ -2105,7 +2106,7 @@ function Bo(e, t) {
|
|
|
2105
2106
|
if (typeof e == "function") return e(t);
|
|
2106
2107
|
e && (e.current = t);
|
|
2107
2108
|
}
|
|
2108
|
-
var Jl = parseInt(
|
|
2109
|
+
var Jl = parseInt(Kr.split(".")[0], 10) >= 19 ? function(e) {
|
|
2109
2110
|
return (t) => {
|
|
2110
2111
|
const n = [];
|
|
2111
2112
|
for (const o of e) {
|
|
@@ -2121,315 +2122,315 @@ var Jl = parseInt(qr.split(".")[0], 10) >= 19 ? function(e) {
|
|
|
2121
2122
|
for (const n of e) Bo(n, t);
|
|
2122
2123
|
};
|
|
2123
2124
|
};
|
|
2124
|
-
const Go =
|
|
2125
|
-
const { range: n, view: o, anchor: r, borderStroke: i = "rgb(33, 115, 70)", background: l = "white", borderWidth: s = 1.5, size: a = 22, style: d, className: g, selectionTouchPointerHandler: m, onTouchSelectStart: f, onTouchSelectEnd: x, currentTouchAnchor:
|
|
2125
|
+
const Go = At(Ut((e, t) => {
|
|
2126
|
+
const { range: n, view: o, anchor: r, borderStroke: i = "rgb(33, 115, 70)", background: l = "white", borderWidth: s = 1.5, size: a = 22, style: d, className: g, selectionTouchPointerHandler: m, onTouchSelectStart: f, onTouchSelectEnd: x, currentTouchAnchor: _, scrollableElement: I, scrollableRoot: R = document.body, ...ae } = e, P = k(f, [f]), C = k(x, [x]), { bounds: z, coordsPivot: le, key: B } = _e(() => {
|
|
2126
2127
|
if (!n || !o) return null;
|
|
2127
|
-
let
|
|
2128
|
+
let K = null, L = null;
|
|
2128
2129
|
switch (r) {
|
|
2129
2130
|
case "tl":
|
|
2130
|
-
|
|
2131
|
+
K = { colIndex: n.colEnd, rowIndex: n.rowEnd }, L = { colIndex: n.colStart, rowIndex: n.rowStart };
|
|
2131
2132
|
break;
|
|
2132
2133
|
case "br":
|
|
2133
|
-
|
|
2134
|
+
K = { colIndex: n.colStart, rowIndex: n.rowStart }, L = { colIndex: n.colEnd, rowIndex: n.rowEnd };
|
|
2134
2135
|
break;
|
|
2135
2136
|
case "t":
|
|
2136
2137
|
case "l":
|
|
2137
|
-
|
|
2138
|
+
K = { colIndex: n.colEnd, rowIndex: n.rowEnd };
|
|
2138
2139
|
break;
|
|
2139
2140
|
case "b":
|
|
2140
|
-
|
|
2141
|
+
K = { colIndex: n.colStart, rowIndex: n.rowStart };
|
|
2141
2142
|
break;
|
|
2142
2143
|
case "r":
|
|
2143
|
-
|
|
2144
|
+
K = { colIndex: n.colStart, rowIndex: n.rowEnd };
|
|
2144
2145
|
}
|
|
2145
|
-
let
|
|
2146
|
-
const
|
|
2146
|
+
let U = o.getRangeCoordsBounds(L ? { rowStart: L.rowIndex, colStart: L.colIndex, rowEnd: L.rowIndex, colEnd: L.colIndex } : n);
|
|
2147
|
+
const ee = o.getBounds(), te = o.getViewportSize(), Y = ee.x, He = ee.y, je = te.width, Ne = te.height;
|
|
2147
2148
|
switch (r) {
|
|
2148
2149
|
case "tl":
|
|
2149
2150
|
break;
|
|
2150
2151
|
case "br":
|
|
2151
|
-
|
|
2152
|
+
U.x = U.x + U.width, U.y = U.y + U.height;
|
|
2152
2153
|
break;
|
|
2153
2154
|
case "t":
|
|
2154
|
-
|
|
2155
|
+
U.x = je / 2 - Y;
|
|
2155
2156
|
break;
|
|
2156
2157
|
case "b":
|
|
2157
|
-
|
|
2158
|
+
U.x = je / 2 - Y, U.y = U.y + U.height;
|
|
2158
2159
|
break;
|
|
2159
2160
|
case "l":
|
|
2160
|
-
|
|
2161
|
+
U.y = Ne / 2 - He;
|
|
2161
2162
|
break;
|
|
2162
2163
|
case "r":
|
|
2163
|
-
|
|
2164
|
-
}
|
|
2165
|
-
const
|
|
2166
|
-
return !
|
|
2167
|
-
}, [n, o, r]), oe =
|
|
2168
|
-
const
|
|
2169
|
-
return { processTouch: !0, consumeTouch: !0, onPointerDown: (
|
|
2170
|
-
const
|
|
2171
|
-
return oe.current = { coordsPivot: le },
|
|
2172
|
-
}, onPointerMoveOrWait: (
|
|
2173
|
-
const
|
|
2174
|
-
return m.onSelectionPointerMoveOrWait(
|
|
2175
|
-
}, onPointerUp: (
|
|
2176
|
-
}, [m, n, o, r])), [
|
|
2164
|
+
U.x = U.x + U.width, U.y = Ne / 2 - He;
|
|
2165
|
+
}
|
|
2166
|
+
const at = o.toClipBounds(U, 0);
|
|
2167
|
+
return !at || at.width <= 0 || at.height <= 0 || U.x < 0 || U.y < 0 || U.x > je || U.y > Ne ? { bounds: null, coordsAnchor: null, coordsPivot: null, key: null } : { bounds: U, coordsAnchor: null, coordsPivot: K, key: "touchSelect-" + o.getAnchor() + "-" + r };
|
|
2168
|
+
}, [n, o, r]), oe = Z(null), ve = On(_e(() => {
|
|
2169
|
+
const K = (L) => r === "t" || r === "b" ? { ...L, colIndex: void 0 } : r === "l" || r === "r" ? { ...L, rowIndex: void 0 } : L;
|
|
2170
|
+
return { processTouch: !0, consumeTouch: !0, onPointerDown: (L, U) => {
|
|
2171
|
+
const ee = K(o.getCellCoordsFromClient(L.clientX, L.clientY));
|
|
2172
|
+
return oe.current = { coordsPivot: le }, P?.(r), m.onSelectionPointerDown(L, U, o, ee, le, !1, !0);
|
|
2173
|
+
}, onPointerMoveOrWait: (L, U, ee) => {
|
|
2174
|
+
const te = K(o.getCellCoordsFromClient(L.clientX, L.clientY));
|
|
2175
|
+
return m.onSelectionPointerMoveOrWait(L, U, ee, o, te, oe.current?.coordsPivot, !0, !0);
|
|
2176
|
+
}, onPointerUp: (L, U, ee) => (oe.current = null, C?.(r), m.onPointerUp(L, U, ee)) };
|
|
2177
|
+
}, [m, n, o, r])), [N, { y: H, x: X }] = _i(), T = Z(null), { getPortalContainer: S } = gi(), [h, J] = Ze(null);
|
|
2177
2178
|
return st(() => {
|
|
2178
|
-
const
|
|
2179
|
-
if (!
|
|
2180
|
-
let
|
|
2181
|
-
for (;
|
|
2182
|
-
|
|
2183
|
-
}, [H, X,
|
|
2179
|
+
const K = T.current?.getBoundingClientRect();
|
|
2180
|
+
if (!K || !z) return void J(null);
|
|
2181
|
+
let L = 0, U = 0, ee = I;
|
|
2182
|
+
for (; ee; ) L += ee.scrollLeft, U += ee.scrollTop, ee = R && ee === R.parentElement ? null : ee.parentElement;
|
|
2183
|
+
J(qr(q("div", { className: En("touch-select-handle", g), ref: t, style: { position: "absolute", left: L + (K?.x ?? 0) - (a + s) / 2, top: U + (K?.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: _ ? 0 : 1, transitionDuration: "160ms", transitionProperty: "opacity", ...d }, tabIndex: -1, onPointerDown: ve, ...ae }), R ?? S(), B));
|
|
2184
|
+
}, [H, X, z?.x, z?.y, z?.width, z?.height, g, _, l, a, s, i, I]), z ? Ht(wn, { children: [q("div", { ref: Jl([N, T]), style: { position: "absolute", left: z.x, top: z.y, opacity: 0 } }), h] }) : null;
|
|
2184
2185
|
}));
|
|
2185
2186
|
Go.displayName = "TouchSelectHandle";
|
|
2186
|
-
const
|
|
2187
|
+
const en = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd: 0 }), Ii = Object.freeze({ colIndex: 0, rowIndex: 0 }), Zo = Object.freeze([]), Yt = (e) => {
|
|
2187
2188
|
if (e && e.cell && e.ranges && e.rangeIndex > -1 && e.rangeIndex <= e.ranges.length) return e;
|
|
2188
2189
|
const t = { cell: null, ranges: e?.ranges ?? Zo };
|
|
2189
|
-
return t.rangeIndex = e?.rangeIndex ?? t.ranges.length - 1, t.cell = e?.cell, !t.cell && t.ranges.length > 0 && (t.cell = { rowIndex: t.ranges[t.rangeIndex].rowStart, colIndex: t.ranges[t.rangeIndex].colStart }), t.cell || (t.cell = Ii),
|
|
2190
|
+
return t.rangeIndex = e?.rangeIndex ?? t.ranges.length - 1, t.cell = e?.cell, !t.cell && t.ranges.length > 0 && (t.cell = { rowIndex: t.ranges[t.rangeIndex].rowStart, colIndex: t.ranges[t.rangeIndex].colStart }), t.cell || (t.cell = Ii), G.isEqualSelectionCoords(t, e) ? e : t;
|
|
2190
2191
|
}, lo = (e, t, n) => {
|
|
2191
2192
|
const o = e.getVisibleRangeCoords(), r = e.getScrollOrientation();
|
|
2192
2193
|
!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:
|
|
2194
|
-
const
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
const
|
|
2199
|
-
return
|
|
2194
|
+
}, 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: _ = !x, fillHandleBorderColor: I = "white", hiddenRowsAt: R, hiddenColumnsAt: ae, isContentfulCell: P, contentfulCellFinder: C = Kl, getDataCoords: z, alwaysScrollToActiveCoords: le = !1, selectionBounds: B, pointerDownInterceptor: oe, pointerMoveInterceptor: ve, mergedRanges: N, canSelectionSpanMergedCells: H = es, onMoveDragStart: X, onMoveDragUpdate: T, onMoveDragEnd: S, onMoveDragDone: h, selectionRenderer: J = Xl, disableMoveDrag: K = !S, getCellCoordsAsRangeCoords: L = G.cellToRange, moveDragHitSize: U = 6, moveDragOutlineSize: ee = 4, selectionBackgroundColor: te = "rgba(16, 124, 65, 0.1)", selectionBorderColor: Y = "rgb(33, 115, 70)", selectionRemoveBorderColor: He = "rgb(255, 0, 0)", selectionRemoveBackgroundColor: je = "rgba(250, 10, 10, 0.1)", disableTouchSelection: Ne = !1, touchSelectHandleProps: at }) => {
|
|
2195
|
+
const Se = D(() => ({ top: B?.top ?? 0, left: B?.left ?? 0, bottom: e.current?.rowCount - 1 || 0, right: e.current?.columnCount - 1 || 0 }), []), Ye = k(x, [x]), $ = k(g, [g]), E = k(m, [m]), Me = k(f, [f]), ue = k(P, [P]), me = k(J, [J]), Ve = k((c, u = !1) => go(c, u, n.getRowOffset, u ? Se().bottom : Se().top), [n?.getRowOffset]), dt = k(R ?? Ve, [R]), kt = k((c, u = !1) => go(c, u, n.getColOffset, u ? Se().right : Se().left), [n?.getColOffset]), ut = k(ae ?? kt, [ae]), [Zt, St] = Ze(() => Yt(o)), M = _e(() => Yt(Zt), [Zt]), ye = Z(M), Je = Z(!0);
|
|
2196
|
+
tn(Ct.throttle(() => {
|
|
2197
|
+
St((c) => {
|
|
2198
|
+
Je.current = !0;
|
|
2199
|
+
const u = Yt(o);
|
|
2200
|
+
return G.isEqualSelectionCoords(u, c) ? c : u;
|
|
2200
2201
|
});
|
|
2201
|
-
}, 0), [o]),
|
|
2202
|
-
|
|
2203
|
-
}, [
|
|
2204
|
-
|
|
2205
|
-
}, [
|
|
2206
|
-
const
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
let w = typeof c == "function" ? c(
|
|
2210
|
-
if (
|
|
2211
|
-
let p = Math.max(w.length ? 0 : -1, Math.min(
|
|
2212
|
-
p === -1 ||
|
|
2213
|
-
const
|
|
2214
|
-
return
|
|
2202
|
+
}, 0), [o]), tn(() => {
|
|
2203
|
+
ye.current = M;
|
|
2204
|
+
}, [M]), st(() => {
|
|
2205
|
+
Je.current || !r || G.isEqualSelectionCoords(o, M) || r(M);
|
|
2206
|
+
}, [M]);
|
|
2207
|
+
const mt = D((c) => {
|
|
2208
|
+
St((u) => {
|
|
2209
|
+
Je.current = !1, u = Yt(u);
|
|
2210
|
+
let w = typeof c == "function" ? c(u.ranges) : c ?? Zo;
|
|
2211
|
+
if (G.isEqualRangesArrays(w, u.ranges)) return u;
|
|
2212
|
+
let p = Math.max(w.length ? 0 : -1, Math.min(u.rangeIndex, w.length - 1)), y = u.cell;
|
|
2213
|
+
p === -1 || G.isCellWithinRange(y, w[p]) || (y = { rowIndex: w[p].rowStart, colIndex: w[p].colStart }), w.length === 1 && G.isSingleCell(w[0]) && G.isCellWithinRange(y, w[0]) && (w = [], p = -1);
|
|
2214
|
+
const W = { cell: y, ranges: w, rangeIndex: p };
|
|
2215
|
+
return G.isEqualSelectionCoords(W, u) ? u : W;
|
|
2215
2216
|
});
|
|
2216
|
-
}, []),
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
const w = c ?? Ii, p =
|
|
2220
|
-
if (!
|
|
2221
|
-
if (
|
|
2222
|
-
let y =
|
|
2223
|
-
|
|
2224
|
-
const b = { ranges: y, rangeIndex:
|
|
2225
|
-
return
|
|
2217
|
+
}, []), Qe = k((c) => {
|
|
2218
|
+
St((u) => {
|
|
2219
|
+
Je.current = !1, u = Yt(u);
|
|
2220
|
+
const w = c ?? Ii, p = L(w);
|
|
2221
|
+
if (!G.isSingleCell(p) && u.ranges.length === 0) return { ranges: [p], rangeIndex: 0, cell: w };
|
|
2222
|
+
if (G.isEqualCells(w, u.cell)) return u;
|
|
2223
|
+
let y = u.ranges, W = u.rangeIndex;
|
|
2224
|
+
u.ranges.length === 1 && (G.isSingleCell(u.ranges[0]) && G.isCellWithinRange(w, u.ranges[0]) || !G.isCellWithinRange(w, u.ranges[0])) && (y = [], W = -1);
|
|
2225
|
+
const b = { ranges: y, rangeIndex: W, cell: w };
|
|
2226
|
+
return G.isEqualSelectionCoords(b, u) ? u : b;
|
|
2226
2227
|
});
|
|
2227
|
-
}, [
|
|
2228
|
+
}, [L]), [cn, on] = Ze(null), [Mt, dn] = Ze(null), nn = Z(null), [De, Kt] = Ze(null), xt = Z(null), Vt = Z(null), [Cn, un] = Ze(null), We = Z(null), Q = Z(null), et = Z(N);
|
|
2228
2229
|
st(() => {
|
|
2229
|
-
et.current =
|
|
2230
|
-
}, [
|
|
2231
|
-
const
|
|
2230
|
+
et.current = N;
|
|
2231
|
+
}, [N]);
|
|
2232
|
+
const Ue = k((c, u = { inline: "nearest", block: "nearest" }) => {
|
|
2232
2233
|
let { rowIndex: w, colIndex: p } = c;
|
|
2233
|
-
w === void 0 &&
|
|
2234
|
-
}, [
|
|
2235
|
-
const
|
|
2236
|
-
return c.rowIndex <
|
|
2237
|
-
}, []), Ie =
|
|
2234
|
+
w === void 0 && M?.cell && (w = M.cell.rowIndex), p === void 0 && M?.cell && (p = M.cell.colIndex), w !== void 0 && p !== void 0 && e.current?.scrollCellCoordsIntoView({ rowIndex: w, colIndex: p }, u);
|
|
2235
|
+
}, [M]), ht = D((c) => {
|
|
2236
|
+
const u = Se();
|
|
2237
|
+
return c.rowIndex < u.top || c.colIndex < u.left || c.colIndex > u.right || c.rowIndex > u.bottom;
|
|
2238
|
+
}, []), Ie = k((c, u) => {
|
|
2238
2239
|
if (!e?.current) return null;
|
|
2239
|
-
const w = { rowStart: Math.min(c.rowIndex,
|
|
2240
|
+
const w = { rowStart: Math.min(c.rowIndex, u.rowIndex), colStart: Math.min(c.colIndex, u.colIndex), rowEnd: Math.max(c.rowIndex, u.rowIndex), colEnd: Math.max(c.colIndex, u.colIndex) };
|
|
2240
2241
|
if (H?.(w)) return w;
|
|
2241
|
-
const y =
|
|
2242
|
+
const y = L(c), W = L(u), b = { rowStart: Math.min(y.rowStart, W.rowStart), colStart: Math.min(y.colStart, W.colStart), rowEnd: Math.max(y.rowEnd, W.rowEnd), colEnd: Math.max(y.colEnd, W.colEnd) };
|
|
2242
2243
|
let he;
|
|
2243
|
-
return typeof et.current == "function" ? he = et.current(b) :
|
|
2244
|
-
}, [H,
|
|
2245
|
-
const p = c.ranges.length > 0 ? c.ranges[c.rangeIndex] : { rowStart: c.cell.rowIndex, colStart: c.cell.colIndex, rowEnd: c.cell.rowIndex, colEnd: c.cell.colIndex }, y = { rowStart: Math.min(
|
|
2246
|
-
if (!(
|
|
2247
|
-
return Ie(
|
|
2248
|
-
}, [Ie]), rt =
|
|
2249
|
-
if (s === "single" || !
|
|
2250
|
-
const p =
|
|
2244
|
+
return typeof et.current == "function" ? he = et.current(b) : N && (he = N), he ? G.extendRangeToUnionRanges(b, he) : b;
|
|
2245
|
+
}, [H, L]), Oe = k((c, u, w) => {
|
|
2246
|
+
const p = c.ranges.length > 0 ? c.ranges[c.rangeIndex] : { rowStart: c.cell.rowIndex, colStart: c.cell.colIndex, rowEnd: c.cell.rowIndex, colEnd: c.cell.colIndex }, y = { rowStart: Math.min(u.rowIndex ?? p.rowStart, w.rowIndex ?? p.rowStart), colStart: Math.min(u.colIndex ?? p.colStart, w.colIndex ?? p.colStart), rowEnd: Math.max(u.rowIndex ?? p.rowEnd, w.rowIndex ?? p.rowEnd), colEnd: Math.max(u.colIndex ?? p.colEnd, w.colIndex ?? p.colEnd) }, W = { rowIndex: y.rowStart, colIndex: y.colStart }, b = { rowIndex: y.rowEnd, colIndex: y.colEnd };
|
|
2247
|
+
if (!(ht(W) || ht(b)))
|
|
2248
|
+
return Ie(W, b);
|
|
2249
|
+
}, [Ie]), rt = k((c, u, w) => {
|
|
2250
|
+
if (s === "single" || !ye.current) return;
|
|
2251
|
+
const p = Oe(ye.current, c, u ?? ye.current.cell);
|
|
2251
2252
|
if (!p) return;
|
|
2252
|
-
const y =
|
|
2253
|
-
|
|
2254
|
-
}, []), tt =
|
|
2255
|
-
if (!
|
|
2256
|
-
c = { ...
|
|
2257
|
-
const p =
|
|
2253
|
+
const y = ye.current.rangeIndex;
|
|
2254
|
+
mt((W) => W.length ? W.map((b, he) => y === he ? p : b) : [p]), w && p && Qe({ colIndex: p.colStart, rowIndex: p.rowStart });
|
|
2255
|
+
}, []), tt = D((c, u, w) => {
|
|
2256
|
+
if (!ye.current) return;
|
|
2257
|
+
c = { ...ye.current?.cell, ...c }, u = u ?? c;
|
|
2258
|
+
const p = Oe(ye.current, c, u);
|
|
2258
2259
|
if (!p) return;
|
|
2259
|
-
const y = { rowIndex: p.rowStart, colIndex: p.colStart },
|
|
2260
|
-
a === "clear" ? (
|
|
2261
|
-
}, []),
|
|
2262
|
-
s !== "multiple" || !c ||
|
|
2263
|
-
|
|
2264
|
-
const y = Ie(c,
|
|
2260
|
+
const y = { rowIndex: p.rowStart, colIndex: p.colStart }, W = { ...y, ...w };
|
|
2261
|
+
a === "clear" ? (We.current = W, rn()) : a === "modify" ? rt(y) : ze(y), Qe(W);
|
|
2262
|
+
}, []), ze = D((c, u = c, w) => {
|
|
2263
|
+
s !== "multiple" || !c || ht(c) || ht(u) || St((p) => {
|
|
2264
|
+
Je.current = !1, p = Yt(p);
|
|
2265
|
+
const y = Ie(c, u);
|
|
2265
2266
|
if (!y) return p;
|
|
2266
|
-
let
|
|
2267
|
-
|
|
2268
|
-
const b = { ranges:
|
|
2269
|
-
return
|
|
2267
|
+
let W = p.ranges.length > 0 ? [...p.ranges] : [Ie(p.cell, p.cell)];
|
|
2268
|
+
W.push(y);
|
|
2269
|
+
const b = { ranges: W, cell: { rowIndex: y.rowStart, colIndex: y.colStart, ...w }, rangeIndex: W.length - 1 };
|
|
2270
|
+
return G.isEqualSelectionCoords(b, p) ? p : b;
|
|
2270
2271
|
});
|
|
2271
2272
|
}, []), rn = () => {
|
|
2272
|
-
|
|
2273
|
-
},
|
|
2273
|
+
mt(Zo);
|
|
2274
|
+
}, Tt = we.detectIt().primaryInput === "touch", nt = Z(null), Rt = Z(null), Ot = Z(null), hn = _e(() => ({ onPointerDown: (c) => {
|
|
2274
2275
|
if (!e || !e.current) return !1;
|
|
2275
|
-
const
|
|
2276
|
-
if (
|
|
2276
|
+
const u = c.nativeEvent, w = e.current.getViewFromClient(u.clientX, u.clientY);
|
|
2277
|
+
if (u.pointerType === "touch" || u.type === "touchstart") return Rt.current = { topLeft: w.getScrollTopLeft(), point: { x: u.clientX, y: u.clientY } }, !0;
|
|
2277
2278
|
const p = w.getCellCoordsFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY);
|
|
2278
2279
|
if (!p) return !1;
|
|
2279
2280
|
nt.current = { anchor: w.getAnchor(), coords: p }, Q.current = null;
|
|
2280
2281
|
const y = c.nativeEvent.which === _r;
|
|
2281
|
-
if (y &&
|
|
2282
|
+
if (y && G.indexOfCoords(p, M.ranges) !== -1)
|
|
2282
2283
|
return !1;
|
|
2283
|
-
const
|
|
2284
|
-
if (oe?.(c, p,
|
|
2285
|
-
i?.(
|
|
2286
|
-
const
|
|
2287
|
-
if (
|
|
2288
|
-
const de =
|
|
2284
|
+
const W = c.nativeEvent.shiftKey, b = c.nativeEvent.ctrlKey || c.nativeEvent.metaKey, he = b, ne = d, re = M.ranges.length > 0, ge = b && ne;
|
|
2285
|
+
if (oe?.(c, p, M) === !1) return !1;
|
|
2286
|
+
i?.(ye.current, c.nativeEvent);
|
|
2287
|
+
const Le = !y && s !== "single";
|
|
2288
|
+
if (W) return rt(p), Le;
|
|
2289
|
+
const de = G.isEqualCells(p, M.cell);
|
|
2289
2290
|
if (he) {
|
|
2290
|
-
if (de && (!
|
|
2291
|
-
if (b &&
|
|
2292
|
-
|
|
2291
|
+
if (de && (!ge || !re)) return Le;
|
|
2292
|
+
if (b && G.indexOfCoords(p, M.ranges) !== -1 && ne) {
|
|
2293
|
+
xt.current = p;
|
|
2293
2294
|
const ie = Ie(p, p);
|
|
2294
|
-
return Vt.current = ie,
|
|
2295
|
+
return Vt.current = ie, Kt(ie), Le;
|
|
2295
2296
|
}
|
|
2296
|
-
return
|
|
2297
|
+
return ze(p), Le;
|
|
2297
2298
|
}
|
|
2298
|
-
le &&
|
|
2299
|
-
}, onPointerMoveOrWait: Ct.throttle((c,
|
|
2299
|
+
le && Ue(p), de && M.ranges.length === 0 || tt(p);
|
|
2300
|
+
}, onPointerMoveOrWait: Ct.throttle((c, u) => {
|
|
2300
2301
|
if (!e?.current || c.pointerType === "touch" || c.type === "touchmove" || !nt.current) return;
|
|
2301
2302
|
const w = nt.current.anchor;
|
|
2302
2303
|
let p = e.current.getViewFromLocation(w), y = p.getCellCoordsFromClient(c.clientX, c.clientY);
|
|
2303
|
-
if (!
|
|
2304
|
-
if (
|
|
2305
|
-
const
|
|
2306
|
-
if (
|
|
2304
|
+
if (!G.isEqualCells(y, nt.current?.coords) && (nt.current = { anchor: w, coords: y }, y && ve?.(c, y, ye.current) !== !1)) {
|
|
2305
|
+
if (xt.current) {
|
|
2306
|
+
const W = { rowStart: Math.min(y.rowIndex, xt.current.rowIndex), colStart: Math.min(y.colIndex, xt.current.colIndex), rowEnd: Math.max(y.rowIndex, xt.current.rowIndex), colEnd: Math.max(y.colIndex, xt.current.colIndex) }, b = { rowIndex: W.rowStart, colIndex: W.colStart }, he = { rowIndex: W.rowEnd, colIndex: W.colEnd };
|
|
2307
|
+
if (ht(b) || ht(he)) return;
|
|
2307
2308
|
const ne = Ie(b, he);
|
|
2308
|
-
Vt.current = ne,
|
|
2309
|
+
Vt.current = ne, Kt(ne);
|
|
2309
2310
|
} else rt(y);
|
|
2310
|
-
|
|
2311
|
+
Ot.current = u, lo(p, y, e);
|
|
2311
2312
|
}
|
|
2312
2313
|
}, 60), onPointerUp: (c) => {
|
|
2313
2314
|
if (nt.current = null, c.pointerType === "touch" || c.type === "touchend") {
|
|
2314
|
-
if (
|
|
2315
|
-
const w = e.current.getViewFromClient(
|
|
2316
|
-
if (p.left ===
|
|
2317
|
-
const y = w.getCellCoordsFromClient(
|
|
2315
|
+
if (Rt.current) {
|
|
2316
|
+
const w = e.current.getViewFromClient(Rt.current.point.x, Rt.current.point.y), p = w.getScrollTopLeft();
|
|
2317
|
+
if (p.left === Rt.current.topLeft.left && p.top === Rt.current.topLeft.top) {
|
|
2318
|
+
const y = w.getCellCoordsFromClient(Rt.current.point.x, Rt.current.point.y);
|
|
2318
2319
|
tt(y);
|
|
2319
2320
|
}
|
|
2320
2321
|
}
|
|
2321
|
-
return
|
|
2322
|
+
return Rt.current = null, void (nt.current = null);
|
|
2322
2323
|
}
|
|
2323
2324
|
try {
|
|
2324
|
-
l?.(
|
|
2325
|
+
l?.(ye.current, c);
|
|
2325
2326
|
} catch (w) {
|
|
2326
2327
|
console.warn(w);
|
|
2327
2328
|
}
|
|
2328
|
-
if (!
|
|
2329
|
-
const
|
|
2330
|
-
|
|
2331
|
-
if (
|
|
2332
|
-
let p = [], y = -1,
|
|
2329
|
+
if (!xt.current) return;
|
|
2330
|
+
const u = Vt.current;
|
|
2331
|
+
xt.current = null, Vt.current = null, Kt(null), St((w) => {
|
|
2332
|
+
if (Je.current = !1, (w = Yt(w)).ranges.length === 0) return w;
|
|
2333
|
+
let p = [], y = -1, W = w.cell;
|
|
2333
2334
|
for (let he = 0; he < w.ranges.length; he++) {
|
|
2334
2335
|
const ne = w.ranges[he];
|
|
2335
|
-
if (
|
|
2336
|
-
const re = Ct.subtractRect({ top: ne.rowStart, left: ne.colStart, bottom: ne.rowEnd + 1, right: ne.colEnd + 1 }, { top:
|
|
2337
|
-
for (let
|
|
2338
|
-
const
|
|
2339
|
-
p.push(
|
|
2336
|
+
if (G.isRangesIntersect(ne, u)) {
|
|
2337
|
+
const re = Ct.subtractRect({ top: ne.rowStart, left: ne.colStart, bottom: ne.rowEnd + 1, right: ne.colEnd + 1 }, { top: u.rowStart, left: u.colStart, bottom: u.rowEnd + 1, right: u.colEnd + 1 });
|
|
2338
|
+
for (let ge = 0; ge < re.length; ge++) {
|
|
2339
|
+
const Le = { rowStart: re[ge].top, colStart: re[ge].left, rowEnd: re[ge].bottom - 1, colEnd: re[ge].right - 1 };
|
|
2340
|
+
p.push(Le), G.isCellWithinRange(w.cell, Le) && (y = p.length - 1);
|
|
2340
2341
|
}
|
|
2341
2342
|
} else p.push(ne);
|
|
2342
|
-
p.length > 0 && y === -1 &&
|
|
2343
|
+
p.length > 0 && y === -1 && G.isCellWithinRange(w.cell, ne) && (y = p.length - 1, W = { rowIndex: p[p.length - 1].rowStart, colIndex: p[p.length - 1].colStart });
|
|
2343
2344
|
}
|
|
2344
|
-
const b = { cell:
|
|
2345
|
-
return
|
|
2345
|
+
const b = { cell: W, rangeIndex: y, ranges: p };
|
|
2346
|
+
return G.isEqualSelectionCoords(b, w) ? w : b;
|
|
2346
2347
|
});
|
|
2347
|
-
}, processTouch: !0, consumeTouch: !1 }), [
|
|
2348
|
+
}, processTouch: !0, consumeTouch: !1 }), [M, s, d, le, a]), mo = k(On(hn), []), xo = _e(() => ({ onSelectionPointerDown: (c, u, w, p, y = M.cell, W = le, b = c.nativeEvent.shiftKey, he = !1) => {
|
|
2348
2349
|
if (!e || !e.current) return !1;
|
|
2349
2350
|
c.stopPropagation(), c.preventDefault(), c.nativeEvent.stopImmediatePropagation();
|
|
2350
2351
|
const ne = w ?? e.current.getViewFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY), re = p ?? ne.getCellCoordsFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY);
|
|
2351
2352
|
if (!re) return !1;
|
|
2352
2353
|
nt.current = { anchor: ne.getAnchor(), coords: re }, Q.current = null;
|
|
2353
|
-
const
|
|
2354
|
-
if (
|
|
2354
|
+
const ge = c.nativeEvent.which === _r;
|
|
2355
|
+
if (ge && G.indexOfCoords(re, M.ranges) !== -1)
|
|
2355
2356
|
return !1;
|
|
2356
|
-
const
|
|
2357
|
-
if (oe?.(c, re,
|
|
2358
|
-
i?.(
|
|
2359
|
-
const
|
|
2360
|
-
if (b) return rt(re, y, he),
|
|
2361
|
-
const
|
|
2357
|
+
const Le = c.nativeEvent.ctrlKey || c.nativeEvent.metaKey, de = Le, ie = d, _t = M.ranges.length > 0, F = Le && ie;
|
|
2358
|
+
if (oe?.(c, re, M) === !1) return !1;
|
|
2359
|
+
i?.(ye.current, c.nativeEvent);
|
|
2360
|
+
const ke = !ge && s !== "single";
|
|
2361
|
+
if (b) return rt(re, y, he), ke;
|
|
2362
|
+
const Pt = G.isEqualCells(re, y);
|
|
2362
2363
|
if (de) {
|
|
2363
|
-
if (
|
|
2364
|
-
if (
|
|
2365
|
-
|
|
2366
|
-
const
|
|
2367
|
-
return Vt.current =
|
|
2364
|
+
if (Pt && (!F || !_t)) return ke;
|
|
2365
|
+
if (F && G.indexOfCoords(re, M.ranges) !== -1 && ie) {
|
|
2366
|
+
xt.current = re;
|
|
2367
|
+
const Re = Ie(re, re);
|
|
2368
|
+
return Vt.current = Re, Kt(Re), ke;
|
|
2368
2369
|
}
|
|
2369
|
-
return
|
|
2370
|
+
return ze(re), ke;
|
|
2370
2371
|
}
|
|
2371
|
-
|
|
2372
|
-
}, onSelectionPointerMoveOrWait: (c,
|
|
2372
|
+
W && Ue(re), Pt && M.ranges.length === 0 || tt(re);
|
|
2373
|
+
}, onSelectionPointerMoveOrWait: (c, u, w, p, y, W = M.cell, b = !0, he = !1) => {
|
|
2373
2374
|
if (!e?.current || (c.stopPropagation(), c.preventDefault(), c.stopImmediatePropagation(), !nt.current)) return;
|
|
2374
2375
|
const ne = nt.current.anchor;
|
|
2375
|
-
let re = p ?? e.current.getViewFromLocation(ne),
|
|
2376
|
-
if (!
|
|
2377
|
-
if (
|
|
2378
|
-
const
|
|
2379
|
-
if (
|
|
2376
|
+
let re = p ?? e.current.getViewFromLocation(ne), ge = y ?? re.getCellCoordsFromClient(c.clientX, c.clientY);
|
|
2377
|
+
if (!G.isEqualCells(ge, nt.current?.coords) && (nt.current = { anchor: ne, coords: ge }, ge && ve?.(c, ge, ye.current) !== !1)) {
|
|
2378
|
+
if (xt.current) {
|
|
2379
|
+
const Le = { rowStart: Math.min(ge.rowIndex, xt.current.rowIndex), colStart: Math.min(ge.colIndex, xt.current.colIndex), rowEnd: Math.max(ge.rowIndex, xt.current.rowIndex), colEnd: Math.max(ge.colIndex, xt.current.colIndex) }, de = { rowIndex: Le.rowStart, colIndex: Le.colStart }, ie = { rowIndex: Le.rowEnd, colIndex: Le.colEnd };
|
|
2380
|
+
if (ht(de) || ht(ie)) return;
|
|
2380
2381
|
const _t = Ie(de, ie);
|
|
2381
|
-
Vt.current = _t,
|
|
2382
|
-
} else rt(
|
|
2383
|
-
b && lo(re,
|
|
2382
|
+
Vt.current = _t, Kt(_t);
|
|
2383
|
+
} else rt(ge, W, he);
|
|
2384
|
+
b && lo(re, ge, e);
|
|
2384
2385
|
}
|
|
2385
2386
|
}, onPointerUp: (c) => {
|
|
2386
2387
|
nt.current = null, c.stopPropagation(), c.preventDefault(), c.stopImmediatePropagation();
|
|
2387
2388
|
try {
|
|
2388
|
-
l?.(
|
|
2389
|
+
l?.(ye.current, c);
|
|
2389
2390
|
} catch (w) {
|
|
2390
2391
|
console.warn(w);
|
|
2391
2392
|
}
|
|
2392
|
-
if (!
|
|
2393
|
-
const
|
|
2394
|
-
|
|
2395
|
-
if (
|
|
2396
|
-
let p = [], y = -1,
|
|
2393
|
+
if (!xt.current) return;
|
|
2394
|
+
const u = Vt.current;
|
|
2395
|
+
xt.current = null, Vt.current = null, Kt(null), St((w) => {
|
|
2396
|
+
if (Je.current = !1, (w = Yt(w)).ranges.length === 0) return w;
|
|
2397
|
+
let p = [], y = -1, W = w.cell;
|
|
2397
2398
|
for (let he = 0; he < w.ranges.length; he++) {
|
|
2398
2399
|
const ne = w.ranges[he];
|
|
2399
|
-
if (
|
|
2400
|
-
const re = Ct.subtractRect({ top: ne.rowStart, left: ne.colStart, bottom: ne.rowEnd + 1, right: ne.colEnd + 1 }, { top:
|
|
2401
|
-
for (let
|
|
2402
|
-
const
|
|
2403
|
-
p.push(
|
|
2400
|
+
if (G.isRangesIntersect(ne, u)) {
|
|
2401
|
+
const re = Ct.subtractRect({ top: ne.rowStart, left: ne.colStart, bottom: ne.rowEnd + 1, right: ne.colEnd + 1 }, { top: u.rowStart, left: u.colStart, bottom: u.rowEnd + 1, right: u.colEnd + 1 });
|
|
2402
|
+
for (let ge = 0; ge < re.length; ge++) {
|
|
2403
|
+
const Le = { rowStart: re[ge].top, colStart: re[ge].left, rowEnd: re[ge].bottom - 1, colEnd: re[ge].right - 1 };
|
|
2404
|
+
p.push(Le), G.isCellWithinRange(w.cell, Le) && (y = p.length - 1);
|
|
2404
2405
|
}
|
|
2405
2406
|
} else p.push(ne);
|
|
2406
|
-
p.length > 0 && y === -1 &&
|
|
2407
|
+
p.length > 0 && y === -1 && G.isCellWithinRange(w.cell, ne) && (y = p.length - 1, W = { rowIndex: p[p.length - 1].rowStart, colIndex: p[p.length - 1].colStart });
|
|
2407
2408
|
}
|
|
2408
|
-
const b = { cell:
|
|
2409
|
-
return
|
|
2409
|
+
const b = { cell: W, rangeIndex: y, ranges: p };
|
|
2410
|
+
return G.isEqualSelectionCoords(b, w) ? w : b;
|
|
2410
2411
|
});
|
|
2411
|
-
} }), [
|
|
2412
|
-
if (!e.current || !
|
|
2413
|
-
let y =
|
|
2414
|
-
if (
|
|
2415
|
-
const
|
|
2412
|
+
} }), [M, s, d, le, a]), pt = k((c, u = !1, w = !1, p = 0) => {
|
|
2413
|
+
if (!e.current || !M.cell) return;
|
|
2414
|
+
let y = M.cell, W = M.cell;
|
|
2415
|
+
if (u && M.ranges.length > 0) {
|
|
2416
|
+
const F = M.ranges[M.rangeIndex], ke = M.cell;
|
|
2416
2417
|
switch (c) {
|
|
2417
2418
|
case it:
|
|
2418
|
-
|
|
2419
|
+
W = { rowIndex: ke.rowIndex === F.rowStart ? F.rowEnd : F.rowStart, colIndex: F.colEnd }, y = { rowIndex: ke.rowIndex === F.rowStart ? F.rowStart : F.rowEnd, colIndex: F.colStart };
|
|
2419
2420
|
break;
|
|
2420
2421
|
case lt:
|
|
2421
|
-
|
|
2422
|
+
W = { rowIndex: ke.rowIndex === F.rowEnd ? F.rowStart : F.rowEnd, colIndex: F.colEnd }, y = { rowIndex: ke.rowIndex === F.rowEnd ? F.rowEnd : F.rowStart, colIndex: F.colStart };
|
|
2422
2423
|
break;
|
|
2423
2424
|
case ot:
|
|
2424
|
-
|
|
2425
|
+
W = { rowIndex: F.rowEnd, colIndex: ke.colIndex === F.colStart ? F.colEnd : F.colStart }, y = { rowIndex: F.rowStart, colIndex: ke.colIndex === F.colStart ? F.colStart : F.colEnd };
|
|
2425
2426
|
break;
|
|
2426
2427
|
case Ke:
|
|
2427
|
-
|
|
2428
|
+
W = { rowIndex: F.rowEnd, colIndex: ke.colIndex === F.colEnd ? F.colStart : F.colEnd }, y = { rowIndex: F.rowStart, colIndex: ke.colIndex === F.colEnd ? F.colEnd : F.colStart };
|
|
2428
2429
|
}
|
|
2429
2430
|
}
|
|
2430
|
-
const b =
|
|
2431
|
+
const b = L(W);
|
|
2431
2432
|
let { rowStart: he, colStart: ne } = b;
|
|
2432
|
-
const re =
|
|
2433
|
+
const re = Se();
|
|
2433
2434
|
if (Q.current) switch (c) {
|
|
2434
2435
|
case it:
|
|
2435
2436
|
case lt:
|
|
@@ -2442,805 +2443,805 @@ const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd
|
|
|
2442
2443
|
if (!p) {
|
|
2443
2444
|
switch (c) {
|
|
2444
2445
|
case it:
|
|
2445
|
-
he =
|
|
2446
|
+
he = qe(dt, Math.max(b.rowStart - 1, re.top), c);
|
|
2446
2447
|
break;
|
|
2447
2448
|
case lt:
|
|
2448
|
-
he =
|
|
2449
|
+
he = qe(dt, Math.min(b.rowEnd + 1, re.bottom), c);
|
|
2449
2450
|
break;
|
|
2450
2451
|
case ot:
|
|
2451
|
-
ne =
|
|
2452
|
+
ne = qe(ut, Math.max(b.colStart - 1, re.left), c);
|
|
2452
2453
|
break;
|
|
2453
2454
|
case Ke:
|
|
2454
|
-
ne =
|
|
2455
|
+
ne = qe(ut, Math.min(b.colEnd + 1, re.right), c);
|
|
2455
2456
|
}
|
|
2456
2457
|
if (w) switch (c) {
|
|
2457
2458
|
case it:
|
|
2458
|
-
he =
|
|
2459
|
+
he = C({ ...W, colIndex: M.cell.colIndex }, ue, dt, c, !1, Math.max(re.top, dt(re.top, !1)));
|
|
2459
2460
|
break;
|
|
2460
2461
|
case lt:
|
|
2461
|
-
he =
|
|
2462
|
+
he = C({ ...W, colIndex: M.cell.colIndex }, ue, dt, c, !1, Math.min(re.bottom, re.bottom - dt(re.bottom, !0)));
|
|
2462
2463
|
break;
|
|
2463
2464
|
case ot:
|
|
2464
|
-
ne =
|
|
2465
|
+
ne = C({ ...W, rowIndex: M.cell.rowIndex }, ue, ut, c, !1, Math.max(re.left, ut(re.left, !1)));
|
|
2465
2466
|
break;
|
|
2466
2467
|
case Ke:
|
|
2467
|
-
ne =
|
|
2468
|
+
ne = C({ ...W, rowIndex: M.cell.rowIndex }, ue, ut, c, !1, Math.min(re.right, re.right - ut(re.right, !0)));
|
|
2468
2469
|
}
|
|
2469
2470
|
}
|
|
2470
|
-
let
|
|
2471
|
+
let ge = null;
|
|
2471
2472
|
if (p) {
|
|
2472
|
-
let
|
|
2473
|
+
let F = 0;
|
|
2473
2474
|
switch (c) {
|
|
2474
2475
|
case it:
|
|
2475
|
-
|
|
2476
|
+
F = n.getRowOffset(he + 1), he = Math.max(re.top, n.getRowIndex(F - p)), ge = { top: n.getRowOffset(he + 1) - (F - e.current.getScrollPosition().top) };
|
|
2476
2477
|
break;
|
|
2477
2478
|
case lt:
|
|
2478
|
-
|
|
2479
|
+
F = n.getRowOffset(he), he = Math.min(re.bottom, n.getRowIndex(F + p)), ge = { top: n.getRowOffset(he) - (F - e.current.getScrollPosition().top) };
|
|
2479
2480
|
break;
|
|
2480
2481
|
case ot:
|
|
2481
|
-
|
|
2482
|
+
F = n.getColOffset(ne + 1), ne = Math.max(re.left, n.getColIndex(F - p)), ge = { left: n.getColOffset(ne + 1) - (F - e.current.getScrollPosition().left) };
|
|
2482
2483
|
break;
|
|
2483
2484
|
case Ke:
|
|
2484
|
-
|
|
2485
|
+
F = n.getColOffset(ne), ne = Math.min(re.right, n.getColIndex(F + p)), ge = { left: n.getColOffset(ne) - (F - e.current.getScrollPosition().left) };
|
|
2485
2486
|
}
|
|
2486
2487
|
}
|
|
2487
|
-
const
|
|
2488
|
-
|
|
2489
|
-
const _t =
|
|
2490
|
-
if (
|
|
2488
|
+
const Le = { rowIndex: he, colIndex: ne }, de = L(Le), ie = { rowIndex: de.rowStart, colIndex: de.colStart };
|
|
2489
|
+
u || (Q.current = Le);
|
|
2490
|
+
const _t = G.isEqualCells(We.current, ie) && G.isEqualCells(We.current, y);
|
|
2491
|
+
if (u && !_t ? rt(ie, y) : tt(ie), ge) e.current.scrollTo(ge);
|
|
2491
2492
|
else {
|
|
2492
|
-
if (
|
|
2493
|
-
const
|
|
2494
|
-
if (c === Ke &&
|
|
2493
|
+
if (u && We.current) {
|
|
2494
|
+
const F = Se();
|
|
2495
|
+
if (c === Ke && We.current.colIndex === F.left || c === ot && We.current.colIndex === F.right || c === it && We.current.rowIndex === F.bottom || c === lt && We.current.rowIndex === F.top) return;
|
|
2495
2496
|
}
|
|
2496
|
-
c === ot || c === Ke ?
|
|
2497
|
+
c === ot || c === Ke ? Ue({ colIndex: Le.colIndex }) : c !== it && c !== lt || Ue({ rowIndex: Le.rowIndex });
|
|
2497
2498
|
}
|
|
2498
|
-
}, [
|
|
2499
|
+
}, [M, L]), ln = k((c) => {
|
|
2499
2500
|
if (!e.current) return;
|
|
2500
|
-
if (
|
|
2501
|
-
const
|
|
2502
|
-
if (
|
|
2503
|
-
const w = Xo(
|
|
2504
|
-
|
|
2505
|
-
|
|
2501
|
+
if (M.ranges.length === 0) return void pt(c);
|
|
2502
|
+
const u = L(M.cell);
|
|
2503
|
+
if (G.isEqualRangesArrays([u], M.ranges)) return void pt(c);
|
|
2504
|
+
const w = Xo(M, c, L, dt, ut);
|
|
2505
|
+
St((p) => {
|
|
2506
|
+
Je.current = !1, p = Yt(p);
|
|
2506
2507
|
const y = { ...p, cell: w.cell, rangeIndex: w.rangeIndex };
|
|
2507
|
-
return
|
|
2508
|
-
}), w.cell &&
|
|
2509
|
-
}, [
|
|
2510
|
-
const c =
|
|
2508
|
+
return G.isEqualSelectionCoords(y, p) ? p : y;
|
|
2509
|
+
}), w.cell && Ue(w.cell);
|
|
2510
|
+
}, [M, L]), vo = D(() => {
|
|
2511
|
+
const c = Se();
|
|
2511
2512
|
rt({ rowIndex: c.top }, { rowIndex: c.bottom });
|
|
2512
|
-
}, []), yo =
|
|
2513
|
-
const c =
|
|
2513
|
+
}, []), yo = D(() => {
|
|
2514
|
+
const c = Se();
|
|
2514
2515
|
rt({ colIndex: c.left }, { colIndex: c.right });
|
|
2515
|
-
}, []), xn =
|
|
2516
|
-
|
|
2517
|
-
}, [
|
|
2518
|
-
const
|
|
2519
|
-
c ? rt(
|
|
2520
|
-
}, []), Yn =
|
|
2521
|
-
const
|
|
2522
|
-
c ? rt(
|
|
2523
|
-
}, []), Dn =
|
|
2524
|
-
const
|
|
2525
|
-
c ? rt(
|
|
2526
|
-
}, []), Mn =
|
|
2527
|
-
const
|
|
2528
|
-
c ? rt(w) : tt(w),
|
|
2529
|
-
}, []), zn =
|
|
2530
|
-
const
|
|
2531
|
-
c ? rt(w) : tt(w),
|
|
2532
|
-
}, [
|
|
2533
|
-
const
|
|
2534
|
-
c ? rt(w) : tt(w),
|
|
2535
|
-
}, [
|
|
2536
|
-
if (!e.current ||
|
|
2537
|
-
const
|
|
2538
|
-
let w =
|
|
2539
|
-
w < 0 ? w =
|
|
2540
|
-
const p =
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
const b = { ...
|
|
2544
|
-
return
|
|
2545
|
-
}), y.cell &&
|
|
2546
|
-
}, [
|
|
2547
|
-
const c = Ar(
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
const w = { ...
|
|
2551
|
-
return
|
|
2552
|
-
}), c.cell &&
|
|
2553
|
-
}, [
|
|
2554
|
-
if (!e.current ||
|
|
2555
|
-
const c =
|
|
2516
|
+
}, []), xn = k(() => {
|
|
2517
|
+
M.cell && e?.current && Ue(M.cell);
|
|
2518
|
+
}, [M.cell]), qn = D((c = !1) => {
|
|
2519
|
+
const u = { rowIndex: Se().top };
|
|
2520
|
+
c ? rt(u) : tt(u), Ue(u);
|
|
2521
|
+
}, []), Yn = D((c = !1) => {
|
|
2522
|
+
const u = { rowIndex: Se().bottom };
|
|
2523
|
+
c ? rt(u) : tt(u), Ue(u);
|
|
2524
|
+
}, []), Dn = D((c = !1) => {
|
|
2525
|
+
const u = { colIndex: Se().left };
|
|
2526
|
+
c ? rt(u) : tt(u), Ue(u);
|
|
2527
|
+
}, []), Mn = D((c = !1) => {
|
|
2528
|
+
const u = Se(), w = { rowIndex: u.top, colIndex: u.left };
|
|
2529
|
+
c ? rt(w) : tt(w), Ue(w);
|
|
2530
|
+
}, []), zn = D((c = !1) => {
|
|
2531
|
+
const u = Se(), w = { colIndex: z?.()?.colEnd ?? u.right };
|
|
2532
|
+
c ? rt(w) : tt(w), Ue(w);
|
|
2533
|
+
}, [z]), vn = D((c = !1) => {
|
|
2534
|
+
const u = Se(), w = { rowIndex: z?.()?.rowEnd ?? u.bottom, colIndex: z?.()?.colEnd ?? u.right };
|
|
2535
|
+
c ? rt(w) : tt(w), Ue(w);
|
|
2536
|
+
}, [z]), An = k((c) => {
|
|
2537
|
+
if (!e.current || M.ranges.length <= 1) return;
|
|
2538
|
+
const u = c === ot || c === it;
|
|
2539
|
+
let w = M.rangeIndex + (u ? -1 : 1);
|
|
2540
|
+
w < 0 ? w = M.ranges.length - 1 : w > M.ranges.length - 1 && (w = 0);
|
|
2541
|
+
const p = M.ranges[w], y = Xo({ cell: { rowIndex: p.rowEnd, colIndex: p.colEnd }, rangeIndex: 0, ranges: [p] }, Ke, L, dt, ut);
|
|
2542
|
+
St((W) => {
|
|
2543
|
+
Je.current = !1, W = Yt(W);
|
|
2544
|
+
const b = { ...W, cell: y.cell, rangeIndex: w };
|
|
2545
|
+
return G.isEqualSelectionCoords(b, W) ? W : b;
|
|
2546
|
+
}), y.cell && Ue(y.cell);
|
|
2547
|
+
}, [M, L]), bo = k(() => {
|
|
2548
|
+
const c = Ar(M);
|
|
2549
|
+
St((u) => {
|
|
2550
|
+
Je.current = !1, u = Yt(u);
|
|
2551
|
+
const w = { ...u, visibleSelection: c };
|
|
2552
|
+
return G.isEqualSelectionCoords(w, u) ? u : w;
|
|
2553
|
+
}), c.cell && Ue(c.cell);
|
|
2554
|
+
}, [M, L]), So = k(() => {
|
|
2555
|
+
if (!e.current || M.ranges.length === 0) return;
|
|
2556
|
+
const c = M.cell, u = M.ranges[M.rangeIndex], w = Ar({ cell: c, rangeIndex: 0, ranges: [u] }), p = w.ranges[w.rangeIndex];
|
|
2556
2557
|
let y;
|
|
2557
|
-
y = p.rowStart === c.rowIndex && p.colStart === c.colIndex ? { rowIndex: p.rowStart, colIndex: p.colEnd } : p.rowStart === c.rowIndex && p.colEnd === c.colIndex ? { rowIndex: p.rowEnd, colIndex: p.colStart } : p.rowEnd === c.rowIndex && p.colStart === c.colIndex ? { rowIndex: p.rowEnd, colIndex: p.colEnd } : { rowIndex: p.rowStart, colIndex: p.colStart },
|
|
2558
|
-
|
|
2559
|
-
const b = { ...
|
|
2560
|
-
return
|
|
2561
|
-
}), y &&
|
|
2562
|
-
}, [
|
|
2563
|
-
|
|
2564
|
-
}, []),
|
|
2565
|
-
|
|
2566
|
-
}, []), Gn =
|
|
2567
|
-
|
|
2568
|
-
}, []), $n =
|
|
2569
|
-
|
|
2570
|
-
}, []), Zn =
|
|
2558
|
+
y = p.rowStart === c.rowIndex && p.colStart === c.colIndex ? { rowIndex: p.rowStart, colIndex: p.colEnd } : p.rowStart === c.rowIndex && p.colEnd === c.colIndex ? { rowIndex: p.rowEnd, colIndex: p.colStart } : p.rowEnd === c.rowIndex && p.colStart === c.colIndex ? { rowIndex: p.rowEnd, colIndex: p.colEnd } : { rowIndex: p.rowStart, colIndex: p.colStart }, St((W) => {
|
|
2559
|
+
W = Yt(W);
|
|
2560
|
+
const b = { ...W, cell: y };
|
|
2561
|
+
return G.isEqualSelectionCoords(b, W) ? W : b;
|
|
2562
|
+
}), y && Ue(y);
|
|
2563
|
+
}, [M, L]), Xn = D((c = !1) => {
|
|
2564
|
+
pt(lt, c, !1, e.current.getDimensions().containerHeight);
|
|
2565
|
+
}, []), Jt = D((c = !1) => {
|
|
2566
|
+
pt(it, c, !1, e.current.getDimensions().containerHeight);
|
|
2567
|
+
}, []), Gn = D((c = !1) => {
|
|
2568
|
+
pt(Ke, c, !1, e.current.getDimensions().containerWidth);
|
|
2569
|
+
}, []), $n = D((c = !1) => {
|
|
2570
|
+
pt(ot, c, !1, e.current.getDimensions().containerWidth);
|
|
2571
|
+
}, []), Zn = D(() => {
|
|
2571
2572
|
ln(ot);
|
|
2572
|
-
}, []), Jn =
|
|
2573
|
+
}, []), Jn = D(() => {
|
|
2573
2574
|
ln(Ke);
|
|
2574
|
-
}, []), Eo =
|
|
2575
|
+
}, []), Eo = D(() => {
|
|
2575
2576
|
ln(it);
|
|
2576
|
-
}, []), _o =
|
|
2577
|
+
}, []), _o = D(() => {
|
|
2577
2578
|
ln(lt);
|
|
2578
|
-
}, []), Bn =
|
|
2579
|
+
}, []), Bn = D(() => {
|
|
2579
2580
|
An(ot);
|
|
2580
|
-
}, []), Io =
|
|
2581
|
+
}, []), Io = D(() => {
|
|
2581
2582
|
An(Ke);
|
|
2582
|
-
}, []), Co =
|
|
2583
|
+
}, []), Co = D(() => {
|
|
2583
2584
|
So();
|
|
2584
|
-
}, []), Qn =
|
|
2585
|
-
|
|
2586
|
-
}, []), v =
|
|
2587
|
-
|
|
2588
|
-
}, []),
|
|
2589
|
-
|
|
2590
|
-
}, []),
|
|
2591
|
-
|
|
2592
|
-
}, []),
|
|
2593
|
-
|
|
2594
|
-
}, []),
|
|
2595
|
-
|
|
2596
|
-
}, []), fe =
|
|
2597
|
-
|
|
2598
|
-
}, []), se =
|
|
2599
|
-
|
|
2600
|
-
}, []),
|
|
2601
|
-
|
|
2602
|
-
}, []),
|
|
2603
|
-
|
|
2604
|
-
}, []), ce =
|
|
2605
|
-
|
|
2606
|
-
}, []),
|
|
2607
|
-
|
|
2608
|
-
}, []),
|
|
2609
|
-
|
|
2610
|
-
}, []),
|
|
2611
|
-
|
|
2612
|
-
}, []),
|
|
2613
|
-
|
|
2614
|
-
}, []),
|
|
2615
|
-
|
|
2616
|
-
}, []),
|
|
2617
|
-
|
|
2618
|
-
}, []),
|
|
2619
|
-
const c =
|
|
2620
|
-
return ((
|
|
2621
|
-
for (let b = 0; b <
|
|
2622
|
-
const he =
|
|
2623
|
-
if (he.rowStart === w && he.colStart === p && he.rowEnd === y && he.colEnd ===
|
|
2585
|
+
}, []), Qn = D(() => {
|
|
2586
|
+
pt(ot, !1, !1);
|
|
2587
|
+
}, []), v = D(() => {
|
|
2588
|
+
pt(ot, !0, !1);
|
|
2589
|
+
}, []), O = D(() => {
|
|
2590
|
+
pt(ot, !1, !0);
|
|
2591
|
+
}, []), A = D(() => {
|
|
2592
|
+
pt(ot, !0, !0);
|
|
2593
|
+
}, []), j = D(() => {
|
|
2594
|
+
pt(Ke, !1, !1);
|
|
2595
|
+
}, []), V = D(() => {
|
|
2596
|
+
pt(Ke, !0, !1);
|
|
2597
|
+
}, []), fe = D(() => {
|
|
2598
|
+
pt(Ke, !1, !0);
|
|
2599
|
+
}, []), se = D(() => {
|
|
2600
|
+
pt(Ke, !0, !0);
|
|
2601
|
+
}, []), xe = D(() => {
|
|
2602
|
+
pt(it, !1, !1);
|
|
2603
|
+
}, []), be = D(() => {
|
|
2604
|
+
pt(it, !0, !1);
|
|
2605
|
+
}, []), ce = D(() => {
|
|
2606
|
+
pt(it, !1, !0);
|
|
2607
|
+
}, []), Fe = D(() => {
|
|
2608
|
+
pt(it, !0, !0);
|
|
2609
|
+
}, []), ft = D(() => {
|
|
2610
|
+
pt(lt, !1, !1);
|
|
2611
|
+
}, []), $e = D(() => {
|
|
2612
|
+
pt(lt, !0, !1);
|
|
2613
|
+
}, []), Be = D(() => {
|
|
2614
|
+
pt(lt, !1, !0);
|
|
2615
|
+
}, []), gt = D(() => {
|
|
2616
|
+
pt(lt, !0, !0);
|
|
2617
|
+
}, []), Xe = D(() => {
|
|
2618
|
+
mt((c) => c.slice(0, -1));
|
|
2619
|
+
}, []), Lt = _e(() => {
|
|
2620
|
+
const c = Se();
|
|
2621
|
+
return ((u, w, p, y, W) => {
|
|
2622
|
+
for (let b = 0; b < u.length; b++) {
|
|
2623
|
+
const he = u[b];
|
|
2624
|
+
if (he.rowStart === w && he.colStart === p && he.rowEnd === y && he.colEnd === W) return !0;
|
|
2624
2625
|
}
|
|
2625
2626
|
return !1;
|
|
2626
|
-
})(
|
|
2627
|
-
}, [
|
|
2628
|
-
|
|
2629
|
-
}, []),
|
|
2630
|
-
const
|
|
2631
|
-
if (!
|
|
2632
|
-
const w =
|
|
2633
|
-
if (!p || !
|
|
2627
|
+
})(M.ranges, c.top, c.left, c.bottom, c.right);
|
|
2628
|
+
}, [B, M.ranges]), vt = D((c, u = !0) => {
|
|
2629
|
+
We.current = c, Qe(c), u && c && e?.current && Ue(c);
|
|
2630
|
+
}, []), pe = k((c = !0) => {
|
|
2631
|
+
const u = nn.current;
|
|
2632
|
+
if (!ye.current?.cell) return;
|
|
2633
|
+
const w = ye.current?.ranges, p = ye.current?.cell;
|
|
2634
|
+
if (!p || !u || !u) return;
|
|
2634
2635
|
let y = null;
|
|
2635
|
-
if (y = w.length > 0 ? w[w.length - 1] :
|
|
2636
|
-
const
|
|
2637
|
-
let b = c ?
|
|
2636
|
+
if (y = w.length > 0 ? w[w.length - 1] : L(p), y.colEnd >= y.colStart && y.rowEnd >= y.rowStart) {
|
|
2637
|
+
const W = $r(y, u);
|
|
2638
|
+
let b = c ? Ye : $;
|
|
2638
2639
|
try {
|
|
2639
|
-
b?.(y,
|
|
2640
|
+
b?.(y, u, W.direction);
|
|
2640
2641
|
} catch (he) {
|
|
2641
2642
|
console.warn(he);
|
|
2642
2643
|
} finally {
|
|
2643
|
-
c &&
|
|
2644
|
+
c && Me?.();
|
|
2644
2645
|
}
|
|
2645
2646
|
}
|
|
2646
|
-
}, [
|
|
2647
|
-
if (
|
|
2647
|
+
}, [L]), wt = Z(null), $t = On(_e(() => ({ onPointerDown: (c, u) => {
|
|
2648
|
+
if (Ot.current = u, !e || !e.current) return !1;
|
|
2648
2649
|
const w = e.current.getViewFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY), p = w?.getCellCoordsFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY);
|
|
2649
|
-
p && (c.stopPropagation(),
|
|
2650
|
-
}, onPointerMoveOrWait: (c,
|
|
2651
|
-
if (
|
|
2652
|
-
const w =
|
|
2650
|
+
p && (c.stopPropagation(), on("crosshair"), wt.current = { anchor: w.getAnchor(), coords: p });
|
|
2651
|
+
}, onPointerMoveOrWait: (c, u) => {
|
|
2652
|
+
if (_ || !e?.current || !ye.current || !wt.current) return;
|
|
2653
|
+
const w = wt.current.anchor;
|
|
2653
2654
|
let p = e.current.getViewFromLocation(w), y = p.getCellCoordsFromClient(c.clientX, c.clientY);
|
|
2654
2655
|
if (!y) return;
|
|
2655
|
-
|
|
2656
|
-
const
|
|
2657
|
-
let b = Ie(
|
|
2656
|
+
wt.current = { anchor: w, coords: y };
|
|
2657
|
+
const W = ye.current.ranges;
|
|
2658
|
+
let b = Ie(ye.current.cell, y);
|
|
2658
2659
|
if (!b) return;
|
|
2659
|
-
const he =
|
|
2660
|
+
const he = W.length > 0, ne = he ? W[W.length - 1] : L(ye.current.cell);
|
|
2660
2661
|
if (!b) return;
|
|
2661
|
-
const re = b.rowStart < ne.rowStart ? it : b.rowEnd > ne.rowEnd ? lt : b.colEnd > ne.colEnd ? Ke : ot,
|
|
2662
|
-
re === ot && (b = { ...ne, colStart: Math.max(
|
|
2663
|
-
const
|
|
2662
|
+
const re = b.rowStart < ne.rowStart ? it : b.rowEnd > ne.rowEnd ? lt : b.colEnd > ne.colEnd ? Ke : ot, ge = Se();
|
|
2663
|
+
re === ot && (b = { ...ne, colStart: Math.max(ge.left, b.colStart) }), re === it && (b = { ...ne, rowStart: Math.max(ge.top, b.rowStart) }), re === Ke && (b = { ...ne, colEnd: Math.min(ge.right, b.colEnd) }), re === lt && (b = { ...ne, rowEnd: Math.min(ge.bottom, b.rowEnd) });
|
|
2664
|
+
const Le = $r(ne, b);
|
|
2664
2665
|
if (!H?.(ne)) {
|
|
2665
2666
|
let de;
|
|
2666
|
-
typeof et.current == "function" ? de = et.current(ne) :
|
|
2667
|
-
const
|
|
2668
|
-
if (
|
|
2669
|
-
if (
|
|
2670
|
-
const
|
|
2671
|
-
|
|
2672
|
-
} else if (
|
|
2673
|
-
const
|
|
2674
|
-
|
|
2675
|
-
} else if (
|
|
2676
|
-
const
|
|
2677
|
-
|
|
2678
|
-
} else if (
|
|
2679
|
-
const
|
|
2680
|
-
|
|
2667
|
+
typeof et.current == "function" ? de = et.current(ne) : N && (de = N), b = ((ie, _t, F, ke, Pt, Re) => {
|
|
2668
|
+
const Te = { ..._t };
|
|
2669
|
+
if (F.length === 0) return Te;
|
|
2670
|
+
if (Pt === ot) {
|
|
2671
|
+
const bt = ie.colEnd + 1 - ie.colStart;
|
|
2672
|
+
Te.colStart = ie.colStart - Math.ceil(Re / bt) * bt, Te.colStart < ke.left && (Te.colStart = Te.colStart + Math.ceil((ke.left - Te.colStart) / bt) * bt);
|
|
2673
|
+
} else if (Pt === Ke) {
|
|
2674
|
+
const bt = ie.colEnd + 1 - ie.colStart;
|
|
2675
|
+
Te.colEnd = ie.colEnd + Math.ceil(Re / bt) * bt, Te.colEnd > ke.right && (Te.colEnd = Te.colEnd - Math.ceil((ke.right - Te.colEnd) / bt) * bt);
|
|
2676
|
+
} else if (Pt === it) {
|
|
2677
|
+
const bt = ie.rowEnd + 1 - ie.rowStart;
|
|
2678
|
+
Te.rowStart = ie.rowStart - Math.ceil(Re / bt) * bt, Te.rowStart < ke.top && (Te.rowStart = Te.rowStart + Math.ceil((ke.top - Te.rowStart) / bt) * bt);
|
|
2679
|
+
} else if (Pt === lt) {
|
|
2680
|
+
const bt = ie.rowEnd + 1 - ie.rowStart;
|
|
2681
|
+
Te.rowEnd = ie.rowEnd + Math.ceil(Re / bt) * bt, Te.rowEnd > ke.bottom && (Te.rowEnd = Te.rowEnd - Math.ceil((ke.bottom - Te.rowEnd) / bt) * bt);
|
|
2681
2682
|
}
|
|
2682
|
-
return
|
|
2683
|
-
})(ne, b, de,
|
|
2683
|
+
return Te;
|
|
2684
|
+
})(ne, b, de, ge, Le.direction, Le.amount);
|
|
2684
2685
|
}
|
|
2685
|
-
if (he &&
|
|
2686
|
-
if (dn(b),
|
|
2686
|
+
if (he && G.isRangeWithinRange(b, ne) && (b = null), !G.isEqualRanges(b, nn.current)) {
|
|
2687
|
+
if (dn(b), nn.current = b, !b) {
|
|
2687
2688
|
try {
|
|
2688
|
-
|
|
2689
|
+
E?.();
|
|
2689
2690
|
} catch {
|
|
2690
2691
|
}
|
|
2691
|
-
return void
|
|
2692
|
+
return void Me?.();
|
|
2692
2693
|
}
|
|
2693
|
-
|
|
2694
|
+
pe(!1);
|
|
2694
2695
|
}
|
|
2695
|
-
|
|
2696
|
-
}, onPointerUp: (c,
|
|
2697
|
-
|
|
2698
|
-
|
|
2696
|
+
Ot.current = u, lo(p, y, e);
|
|
2697
|
+
}, onPointerUp: (c, u) => {
|
|
2698
|
+
Ot.current = u, Promise.resolve(pe(!0)).finally(() => {
|
|
2699
|
+
Me?.(), dn(null), nn.current = null, wt.current = null, on(null), e.current?.focus();
|
|
2699
2700
|
});
|
|
2700
|
-
} }), [
|
|
2701
|
-
if (
|
|
2701
|
+
} }), [L])), Wt = _e(() => ({ onPointerDown: $t }), [$t]), [Ce, Ge] = Ze(null), Ae = Z(null), ct = _e(() => ({ onPointerDown: (c, u) => {
|
|
2702
|
+
if (Ot.current = u, !e || !e.current) return !1;
|
|
2702
2703
|
const w = e.current.getViewFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY), p = w?.getCellCoordsFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY);
|
|
2703
2704
|
if (!p) return;
|
|
2704
|
-
if (oe?.(c, p,
|
|
2705
|
-
c.stopPropagation(),
|
|
2706
|
-
const y = w.getRelativePointFromClient(0, 0),
|
|
2707
|
-
b.x - y.x > c.nativeEvent.clientX ? he.x = c.nativeEvent.clientX - (b.x - y.x) : c.nativeEvent.clientX >= b.x - y.x + b.width && (he.x = Math.max(0, c.nativeEvent.clientX - (b.x - y.x + b.width)) + 1), b.y - y.y > c.nativeEvent.clientY ? he.y = c.nativeEvent.clientY - (b.y - y.y) : c.nativeEvent.clientY >= b.y - y.y + b.height && (he.y = Math.max(0, c.nativeEvent.clientY - (b.y - y.y + b.height)) + 1), X?.(
|
|
2708
|
-
}, onPointerMoveOrWait: (c,
|
|
2709
|
-
if (
|
|
2705
|
+
if (oe?.(c, p, M) === !1) return !1;
|
|
2706
|
+
c.stopPropagation(), on("default");
|
|
2707
|
+
const y = w.getRelativePointFromClient(0, 0), W = ye.current?.ranges[ye.current?.ranges.length - 1] ?? G.cellToRange(ye.current?.cell), b = w.toClipBounds(w.getRangeCoordsBounds(W)), he = { x: 0, y: 0 };
|
|
2708
|
+
b.x - y.x > c.nativeEvent.clientX ? he.x = c.nativeEvent.clientX - (b.x - y.x) : c.nativeEvent.clientX >= b.x - y.x + b.width && (he.x = Math.max(0, c.nativeEvent.clientX - (b.x - y.x + b.width)) + 1), b.y - y.y > c.nativeEvent.clientY ? he.y = c.nativeEvent.clientY - (b.y - y.y) : c.nativeEvent.clientY >= b.y - y.y + b.height && (he.y = Math.max(0, c.nativeEvent.clientY - (b.y - y.y + b.height)) + 1), X?.(W, c.nativeEvent, u), Ae.current = { range: W, anchor: w.getAnchor(), cell: p, isMoving: !1, extrusion: he };
|
|
2709
|
+
}, onPointerMoveOrWait: (c, u, w) => {
|
|
2710
|
+
if (K || !e?.current || !ye.current || !Ae.current) return;
|
|
2710
2711
|
const p = c.clientX - w.clientX, y = c.clientY - w.clientY;
|
|
2711
|
-
if (
|
|
2712
|
-
const
|
|
2713
|
-
let he = e.current.getViewFromLocation(
|
|
2712
|
+
if (Ae.current.isMoving = Ae.current.isMoving || Math.abs(p) > Math.max(1, 2) || Math.abs(y) > Math.max(1, 2) || performance.now() - w.timeStamp > 500, !Ae.current.isMoving) return;
|
|
2713
|
+
const W = Ae.current.anchor, b = Ae.current.extrusion;
|
|
2714
|
+
let he = e.current.getViewFromLocation(W), ne = he.getCellCoordsFromClient(c.clientX - b.x, c.clientY - b.y, !0);
|
|
2714
2715
|
if (!ne) return;
|
|
2715
|
-
const re =
|
|
2716
|
-
|
|
2717
|
-
}, onPointerUp: (c,
|
|
2718
|
-
|
|
2716
|
+
const re = Ae.current.cell, ge = Ae.current.range, Le = Se(), de = ge.colEnd - ge.colStart + 1, ie = Math.min(Math.max(0, re.colIndex - ge.colStart), de - 1), _t = Math.min(Le.right - de + 1, Math.max(Le.left, ne.colIndex - ie)), F = ge.rowEnd - ge.rowStart + 1, ke = Math.min(Math.max(0, re.rowIndex - ge.rowStart), F - 1), Pt = Math.min(Le.bottom - F + 1, Math.max(Le.top, ne.rowIndex - ke)), Re = { colStart: _t, colEnd: _t + de - 1, rowStart: Pt, rowEnd: Pt + F - 1 };
|
|
2717
|
+
G.isEqualRanges(Ce, Re) && !((Te) => !Te || !Ot.current || Ot.current.ctrlKey !== Te.ctrlKey || Ot.current.shiftKey !== Te.shiftKey || Ot.current.altKey !== Te.altKey || Ot.current.metaKey !== Te.metaKey)(c) || (Ge(Re), T?.(Re, c, u)), Ot.current = u, lo(he, ne, e);
|
|
2718
|
+
}, onPointerUp: (c, u) => {
|
|
2719
|
+
Ot.current = u;
|
|
2719
2720
|
const w = () => {
|
|
2720
|
-
|
|
2721
|
+
Ge(null), Ae.current = null, on(null), e.current?.focus();
|
|
2721
2722
|
};
|
|
2722
|
-
if (
|
|
2723
|
-
const p =
|
|
2724
|
-
|
|
2723
|
+
if (!Ae.current) return void w();
|
|
2724
|
+
const p = Ae.current.range, y = Ce;
|
|
2725
|
+
S?.(p, c, u), Promise.resolve(p && y && h?.(p, y, c, u)).finally(() => {
|
|
2725
2726
|
w();
|
|
2726
2727
|
});
|
|
2727
|
-
} }), [Ce]),
|
|
2728
|
-
const c =
|
|
2729
|
-
return
|
|
2730
|
-
}, [
|
|
2731
|
-
let
|
|
2732
|
-
const p = [], y = { stroke: I, fill:
|
|
2733
|
-
const
|
|
2734
|
-
if (!
|
|
2735
|
-
|
|
2736
|
-
const
|
|
2728
|
+
} }), [Ce]), Pe = On(ct), Et = _e(() => ({ onPointerDown: Pe }), [Pe]), yt = Z(null), Bt = _e(() => {
|
|
2729
|
+
const c = G.isEqualSelectionCoords(M, yt.current) ? yt.current : M;
|
|
2730
|
+
return yt.current = c, c;
|
|
2731
|
+
}, [M]), qt = D((c) => {
|
|
2732
|
+
let u = null, w = "br";
|
|
2733
|
+
const p = [], y = { stroke: I, fill: te, strokeWidth: 0.5 }, W = (de, ie, _t) => {
|
|
2734
|
+
const F = c.toClipBounds(c.getRangeCoordsBounds(de), en);
|
|
2735
|
+
if (!F) return;
|
|
2736
|
+
F.x = F.width > 0 ? F.x : F.x - y.strokeWidth / 2, F.y = F.height > 0 ? F.y : F.y - y.strokeWidth / 2, F.width = Math.max(F.width, y.strokeWidth), F.height = Math.max(F.height, y.strokeWidth);
|
|
2737
|
+
const ke = { key: `selection-fill-${ie}`, range: de, ...F, ...y };
|
|
2737
2738
|
if (_t) {
|
|
2738
|
-
const
|
|
2739
|
-
|
|
2739
|
+
const Pt = c.getCellCoordsAsRangeCoords(_t);
|
|
2740
|
+
ke.cell = _t, ke.pathBounds = c.toClipBounds(c.getRangeCoordsBounds(Pt), en), ke.pathBounds && (ke.pathBounds.width <= 0 || ke.pathBounds.height <= 0) && (delete ke.pathBounds, delete ke.cell);
|
|
2740
2741
|
}
|
|
2741
|
-
return
|
|
2742
|
+
return me(ke);
|
|
2742
2743
|
};
|
|
2743
|
-
let b =
|
|
2744
|
+
let b = M ? Yt(M) : null;
|
|
2744
2745
|
const he = b?.cell ? c.getCellCoordsAsRangeCoords(b?.cell) : Ql;
|
|
2745
2746
|
!b || b.ranges && b.ranges.length !== 0 || (b = { ranges: [he], rangeIndex: 0, cell: b.cell });
|
|
2746
2747
|
for (let de = 0; b && de < b.ranges.length; de++) {
|
|
2747
|
-
const ie = b.ranges[de], _t =
|
|
2748
|
+
const ie = b.ranges[de], _t = W(ie, de, de === b.rangeIndex ? b.cell : null);
|
|
2748
2749
|
_t && p.push(_t);
|
|
2749
|
-
const
|
|
2750
|
-
if (
|
|
2751
|
-
const
|
|
2752
|
-
p.push(
|
|
2750
|
+
const F = 2, ke = 0.5, Pt = c.toClipBounds(c.getRangeCoordsBounds(ie, { top: 0, left: 0, right: 0, bottom: 0 }), en);
|
|
2751
|
+
if (Pt) {
|
|
2752
|
+
const Re = (b.ranges.length, 4);
|
|
2753
|
+
p.push(me({ range: ie, key: `selection-inside-edge-${de}`, x: Pt.x - 1, y: Pt.y - 1, width: Math.max(Pt.width + 1, 0), height: Math.max(Pt.height + 1, 0), style: { overflow: "hidden" }, stroke: I, strokeWidth: Re }));
|
|
2753
2754
|
}
|
|
2754
2755
|
if (b.ranges.length === 1) {
|
|
2755
|
-
const
|
|
2756
|
-
if (
|
|
2757
|
-
|
|
2758
|
-
const
|
|
2759
|
-
p.push(
|
|
2756
|
+
const Re = c.toClipBounds(c.getRangeCoordsBounds(ie), en);
|
|
2757
|
+
if (Re) {
|
|
2758
|
+
K || p.push(me({ range: ie, key: `move-selection-hit-box-${de}`, x: Re.width > 1 ? Re.x : Re.x - (U / 2 + 1), y: Re.height > 1 ? Re.y : Re.y - (U / 2 + 1), width: Math.max(Re.width + 2, 1), height: Math.max(Re.height + 2, 1), stroke: "transparent", style: { boxShadow: "none" }, pathProps: { cursor: Ce ? void 0 : "move", pointerEvents: "stroke" }, strokeWidth: U, ...Et }));
|
|
2759
|
+
const Te = F;
|
|
2760
|
+
p.push(me({ range: ie, key: `selection-single-${de}`, x: Re.x - Te / 2, y: Re.y - Te / 2, width: Math.max(Re.width + Te / 2, 1), height: Math.max(Re.height + Te / 2, 1), stroke: Y, strokeWidth: Te }));
|
|
2760
2761
|
}
|
|
2761
2762
|
} else {
|
|
2762
|
-
const
|
|
2763
|
-
|
|
2763
|
+
const Re = c.toClipBounds(c.getRangeCoordsBounds(ie, { top: -1, left: -1, right: -2, bottom: -2 }), en);
|
|
2764
|
+
Re && p.push(me({ range: ie, key: `selection-multi-${de}`, x: Re.width > 1 ? Re.x : Re.x - ke / 2, y: Re.height > 1 ? Re.y : Re.y - ke / 2, width: Math.max(Re.width, ke) + 1, height: Math.max(Re.height, ke) + 1, stroke: Y, style: { overflow: "hidden" }, strokeWidth: 2 }));
|
|
2764
2765
|
}
|
|
2765
2766
|
if (b.ranges.length > 1 && de === b.rangeIndex) {
|
|
2766
|
-
const
|
|
2767
|
-
|
|
2767
|
+
const Re = c.getCellCoordsAsRangeCoords(b.cell), Te = c.toClipBounds(c.getRangeCoordsBounds(Re, { top: 1, left: 1, right: -1, bottom: -1 }), en);
|
|
2768
|
+
Te && p.push(me({ range: ie, key: `selection-anchor-${de}`, x: Te.x, y: Te.y, width: Math.max(Te.width, ke), height: Math.max(Te.height, ke), stroke: Y, style: { overflow: "hidden" }, strokeWidth: 2 }));
|
|
2768
2769
|
}
|
|
2769
2770
|
if (de === b.ranges.length - 1) {
|
|
2770
|
-
|
|
2771
|
-
const
|
|
2772
|
-
let
|
|
2773
|
-
if (
|
|
2774
|
-
if (
|
|
2771
|
+
u = null, w = null;
|
|
2772
|
+
const Re = ie.rowStart === Se().top && ie.rowEnd === Se().bottom, Te = ie.colStart === Se().left && ie.colEnd === Se().right, bt = c.getRangeCoordsBounds(ie);
|
|
2773
|
+
let Qt = null;
|
|
2774
|
+
if (Re || Te) {
|
|
2775
|
+
if (Qt = c.toClipBounds(bt, en), Object.keys(c.allViews()).length > 1) {
|
|
2775
2776
|
const eo = c.getVisibleRangeCoords(), nr = c.allViews()[uo], ki = c.allViews()[Hn], Pi = c.allViews()[Nn], to = c.getAnchor();
|
|
2776
|
-
(
|
|
2777
|
+
(Te && (to === Hn && nr || to === Xt && Pi || !G.isCellWithinRange({ colIndex: ie.colStart, rowIndex: ie.rowEnd }, eo) && !G.isCellWithinRange({ colIndex: ie.colStart, rowIndex: ie.rowEnd + 1 }, eo)) || Re && (to === Nn && nr || to === Xt && ki || !G.isCellWithinRange({ colIndex: ie.colEnd, rowIndex: ie.rowStart }, eo) && !G.isCellWithinRange({ colIndex: ie.colEnd + 1, rowIndex: ie.rowStart }, eo))) && (Qt = null);
|
|
2777
2778
|
}
|
|
2778
|
-
} else
|
|
2779
|
-
if (!
|
|
2780
|
-
|
|
2779
|
+
} else Qt = c.toClipBounds(bt, en);
|
|
2780
|
+
if (!Qt || Qt.width === 0 || Qt.height === 0) continue;
|
|
2781
|
+
u = { x: Qt.x + Qt.width + 1, y: Qt.y + Qt.height + 1 }, Qt.width === 0 || Qt.height === 0 || ie.rowStart === Se().top && ie.colStart === Se().left && ie.rowEnd === Se().bottom && ie.colEnd === Se().right || (Re ? (u.y = F, w = "tr") : Te && (u.x = F, w = "bl"));
|
|
2781
2782
|
}
|
|
2782
2783
|
}
|
|
2783
2784
|
let ne = null;
|
|
2784
|
-
if (
|
|
2785
|
-
const de = c.toClipBounds(c.getRangeCoordsBounds(
|
|
2786
|
-
de && (ne =
|
|
2785
|
+
if (De) {
|
|
2786
|
+
const de = c.toClipBounds(c.getRangeCoordsBounds(De, { top: 0, left: 0, right: 0, bottom: 0 }), en);
|
|
2787
|
+
de && (ne = me({ ...y, range: De, key: "remove-selection", x: de.x, y: de.y, width: de.width, height: de.height, strokeWidth: 2, stroke: He, fill: je }));
|
|
2787
2788
|
}
|
|
2788
2789
|
let re = null;
|
|
2789
|
-
if (
|
|
2790
|
-
const de = c.toClipBounds(c.getRangeCoordsBounds(
|
|
2791
|
-
de && (re =
|
|
2790
|
+
if (Mt) {
|
|
2791
|
+
const de = c.toClipBounds(c.getRangeCoordsBounds(Mt, { top: 0, left: 0, right: 0, bottom: 0 }), en);
|
|
2792
|
+
de && (re = me({ range: Mt, key: "selection-fill-outline", x: de.x - 2 / 2, y: de.y - 2 / 2, width: de.width + 2 / 2, height: de.height + 2 / 2, strokeWidth: 2, stroke: Y, strokeDasharray: "3 2" }));
|
|
2792
2793
|
}
|
|
2793
|
-
let
|
|
2794
|
-
!
|
|
2795
|
-
const
|
|
2796
|
-
if (ne &&
|
|
2797
|
-
const de = b.ranges[b.ranges.length - 1], ie = de.rowStart ===
|
|
2798
|
-
|
|
2794
|
+
let ge = null;
|
|
2795
|
+
!_ && u && !Ce && (ge = Jo(Si, { ...u, corner: w, size: 7.5, borderStroke: `${I} solid`, style: { borderRadius: 1 }, background: Y, ...Wt, key: "fillHandle" }));
|
|
2796
|
+
const Le = [...p];
|
|
2797
|
+
if (ne && Le.push(ne), re && Le.push(re), ge && Le.push(ge), !Ne && Tt && b?.ranges.length === 1 && b.ranges[b.ranges.length - 1]) {
|
|
2798
|
+
const de = b.ranges[b.ranges.length - 1], ie = de.rowStart === Se().top && de.rowEnd === Se().bottom, _t = de.colStart === Se().left && de.colEnd === Se().right, F = { view: c, range: de, borderStroke: `${Y} solid`, background: I, selectionTouchPointerHandler: xo, ...at, onTouchSelectStart: (ke) => un(ke), onTouchSelectEnd: () => un(null), currentTouchAnchor: Cn };
|
|
2799
|
+
Le.push(q(Go, { anchor: _t ? "b" : ie ? "r" : "br", scrollableElement: e.current, ...F }, "touch-select-handle-after")), Le.push(q(Go, { anchor: _t ? "t" : ie ? "l" : "tl", scrollableElement: e.current, ...F }, "touch-select-handle-before"));
|
|
2799
2800
|
}
|
|
2800
2801
|
if (Ce) {
|
|
2801
|
-
const de = c.toClipBounds(c.getRangeCoordsBounds(Ce, { top: 1, left: 1, right: 1, bottom: 1 }),
|
|
2802
|
-
de &&
|
|
2802
|
+
const de = c.toClipBounds(c.getRangeCoordsBounds(Ce, { top: 1, left: 1, right: 1, bottom: 1 }), en);
|
|
2803
|
+
de && Le.push(me({ range: Ce, key: "selection-move-outline", x: de.x - ee / 2, y: de.y - ee / 2, width: Math.max(de.width + ee / 2, 1), height: Math.max(de.height + ee / 2, 1), stroke: Y, style: { boxShadow: "none", transitionDuration: "70ms", transitionTimingFunction: "ease-in", transitionProperty: "left, top, width, height", willChange: "left, top, width, height" }, strokeWidth: ee }));
|
|
2803
2804
|
}
|
|
2804
|
-
return
|
|
2805
|
-
}, [
|
|
2805
|
+
return q("div", { children: Le }, "selection");
|
|
2806
|
+
}, [Bt, De, _, Mt, K, Ce, Se, I, Y, te, He, je, Ne, at, Cn]), Dt = _e(() => {
|
|
2806
2807
|
const c = () => e.current;
|
|
2807
|
-
return [new
|
|
2808
|
-
rn(),
|
|
2809
|
-
}), new
|
|
2808
|
+
return [new Ee("moveToPageDown", c, { label: "Page Down", description: "Shift viewport down one page.", shortcut: [{ key: "PageDown" }] }, () => Xn(!1)), new Ee("selectToPageDown", c, { label: "Select To Page Down", description: "Shift viewport and select down one page.", shortcut: [{ key: "PageDown", modifiers: [It] }] }, () => Xn(!0)), new Ee("moveToPageRight", c, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [yn] }] }, () => Gn(!1)), new Ee("selectToPageRight", c, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [yn, It] }] }, () => Gn(!0)), new Ee("moveToPageUp", c, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp" }] }, () => Jt(!1)), new Ee("selectToPageUp", c, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp", modifiers: [It] }] }, () => Jt(!0)), new Ee("moveToPageLeft", c, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [yn] }] }, () => $n(!1)), new Ee("selectToPageLeft", c, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [yn, It] }] }, () => $n(!0)), new Ee("selectColumn", c, { label: "Select Column", description: "Select the columns for the selected cells.", shortcut: { key: "Space", modifiers: [zt] } }, vo), new Ee("selectRow", c, { label: "Select Row", description: "Select the rows for the selected cells.", shortcut: { key: "Space", modifiers: [It] } }, yo), new Ee("selectToColumnStart", c, { label: "Select To Column Start", description: "Select the columns to the beginning of the sheet." }, () => qn(!0)), new Ee("selectToColumnEnd", c, { label: "Select To Column End", description: "Select the columns to the end of the sheet." }, () => Yn(!0)), new Ee("moveToRowStart", c, { label: "Move to Row Home", description: "Move to the beginning of the row.", shortcut: [{ key: "Home" }] }, () => Dn(!1)), new Ee("selectToRowStart", c, { label: "Select to Row Home", description: "Select to the beginning of the row.", shortcut: [{ key: "Home", modifiers: [It] }] }, () => Dn(!0)), new Ee("moveToSheetStart", c, { label: "Move to Sheet Home", description: "Move to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [zt] }] }, () => Mn(!1)), new Ee("selectToSheetStart", c, { label: "Select to Sheet Home", description: "Select to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [zt, It] }] }, () => Mn(!0)), new Ee("moveToRowEnd", c, { label: "Move to Row End", description: "Move to the end of the row.", shortcut: [{ key: "End" }] }, () => zn(!1)), new Ee("selectToRowEnd", c, { label: "Select to Row End", description: "Select to the end of the row.", shortcut: [{ key: "End", modifiers: [It] }] }, () => zn(!0)), new Ee("moveToSheetEnd", c, { label: "Move to Sheet End", description: "Move to the end of the sheet.", shortcut: [{ key: "End", modifiers: [zt] }] }, () => vn(!1)), new Ee("selectToSheetEnd", c, { label: "Select to Sheet End", description: "Select to the end of the sheet.", shortcut: [{ key: "End", modifiers: [zt, It] }] }, () => vn(!0)), new Ee("scrollToActiveCoords", c, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell.", shortcut: { key: "Backspace", modifiers: [zt] } }, xn), new Ee("scrollToActiveCoordsClearSelection", c, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell and clear selection.", shortcut: { key: "Backspace", modifiers: [It] } }, () => {
|
|
2809
|
+
rn(), vt(M.cell, !0);
|
|
2810
|
+
}), new Ee("traverseSelectionRight", c, { label: "Traverse Right", description: "Traverse the selection moving rightward.", shortcut: { key: "Tab" } }, Jn), new Ee("traverseSelectionLeft", c, { label: "Traverse Left", description: "Traverse the selection moving leftward.", shortcut: { key: "Tab", modifiers: [It] } }, Zn), new Ee("traverseSelectionDown", c, { label: "Traverse Down", description: "Traverse the selection moving downward.", shortcut: [{ key: "Enter" }, { key: "NumpadEnter" }] }, _o), new Ee("traverseSelectionUp", c, { label: "Traverse Up", description: "Traverse the selection moving upward.", shortcut: [{ key: "Enter", modifiers: [It] }, { key: "NumpadEnter", modifiers: [It] }] }, Eo), new Ee("moveLeft", c, { label: "Move Left", description: "Move active cell to the left.", shortcut: [{ key: "ArrowLeft" }] }, Qn), new Ee("selectLeft", c, { label: "Select Left", description: "Extend selection left.", shortcut: [{ key: "ArrowLeft", modifiers: [It] }] }, v), new Ee("moveContentfulLeft", c, { label: "Move Left Contentful", description: "Move left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [zt] }] }, O), new Ee("selectContentfulLeft", c, { label: "Select Left Contentful", description: "Extend selection left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [zt, It] }] }, A), new Ee("moveRight", c, { label: "Move Right", description: "Move active cell to the right.", shortcut: [{ key: "ArrowRight" }] }, j), new Ee("selectRight", c, { label: "Select Right", description: "Extend selection right.", shortcut: [{ key: "ArrowRight", modifiers: [It] }] }, V), new Ee("moveContentfulRight", c, { label: "Move Right Contentful", description: "Move right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [zt] }] }, fe), new Ee("selectContentfulRight", c, { label: "Select Right Contentful", description: "Extend selection right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [zt, It] }] }, se), new Ee("moveUp", c, { label: "Move Up", description: "Move active cell to the up.", shortcut: [{ key: "ArrowUp" }] }, xe), new Ee("selectUp", c, { label: "Select Up", description: "Extend selection up.", shortcut: [{ key: "ArrowUp", modifiers: [It] }] }, be), new Ee("moveContentfulUp", c, { label: "Move Up Contentful", description: "Move up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [zt] }] }, ce), new Ee("selectContentfulUp", c, { label: "Select Up Contentful", description: "Extend selection up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [zt, It] }] }, Fe), new Ee("moveDown", c, { label: "Move Down", description: "Move active cell to the down.", shortcut: [{ key: "ArrowDown" }] }, ft), new Ee("selectDown", c, { label: "Select Down", description: "Extend selection down.", shortcut: [{ key: "ArrowDown", modifiers: [It] }] }, $e), new Ee("moveContentfulDown", c, { label: "Move Down Contentful", description: "Move down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [zt] }] }, Be), new Ee("selectContentfulDown", c, { label: "Select Down Contentful", description: "Extend selection down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [zt, It] }] }, gt), new Ee("selectVisible", c, { label: "Select Visible", description: "Select visible cells only.", shortcut: { key: ";", modifiers: [yn] } }, bo), new Ee("traverseSelectionPreviousRange", c, { label: "Traverse Previous Range", description: "Traverse the selection to the previous range.", shortcut: { key: "ArrowLeft", modifiers: [zt, yn] } }, Bn), new Ee("traverseSelectionNextRange", c, { label: "Traverse Next Range", description: "Traverse the selection to the next range.", shortcut: { key: "ArrowRight", modifiers: [zt, yn] } }, Io), new Ee("traverseSelectionCorners", c, { label: "Traverse Corners", description: "Traverse the selection through the corners of the selected range.", shortcut: { key: ".", modifiers: [zt] } }, Co)];
|
|
2810
2811
|
}, []);
|
|
2811
|
-
return
|
|
2812
|
-
t?.addCommands(
|
|
2813
|
-
}, [t]), { selection:
|
|
2812
|
+
return _e(() => {
|
|
2813
|
+
t?.addCommands(Dt, !0);
|
|
2814
|
+
}, [t]), { selection: Bt, setSelectionCell: vt, setSelectionRanges: mt, overlay: qt, cursor: cn, onPointerDown: mo, clearLastSelection: Xe, newSelection: tt, modifySelection: rt, appendSelection: ze, clearSelections: rn, isEntire: Lt, navigate: pt, navigateSelection: ln };
|
|
2814
2815
|
};
|
|
2815
2816
|
function ao(e, t) {
|
|
2816
2817
|
if (!e) throw new Error("Invariant failed");
|
|
2817
2818
|
}
|
|
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:
|
|
2819
|
+
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 = At(Ut((e, t) => {
|
|
2820
|
+
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: _ = "rgb(224, 224, 224)", gridLineRowsProps: I, gridLineColumnsProps: R, clipCells: ae = !0, cursor: P, freezeLeft: C = 0, freezeTop: z = 0, freezeLeftProps: le, freezeTopProps: B, cellRenderer: oe, onViewportChange: ve, onFirstRender: N, overlayRenderer: H, overlayProps: X, overlays: T, overlaysProps: S, allowOverlaysOverflow: h = !1, stageProps: J, stageWrapper: K = null, hiddenRowsAt: L, hiddenColumnsAt: U, hiddenCellAt: ee, getVisibleCells: te, zoom: Y = 1, enableMouseWheel: He = !0, onWheelScroll: je, getCellCoordsAsRangeCoords: Ne = G.cellToRange, scrollPoint: at = ts, style: Se = {}, ...Ye } = e;
|
|
2820
2821
|
ao(oe), ao(!e?.children);
|
|
2821
|
-
const
|
|
2822
|
+
const $ = k(f, [f]), E = k(ve, [ve]), Me = k(m, [m]), ue = k(je, [je]), me = k(N, [N]), Ve = Z(null), dt = Z(null), kt = Z(null), [ut, Zt] = Qo((v) => v + 1, 0), [St, M] = Ze({ left: at?.left ?? 0, top: at?.top ?? 0, horizontalScrollDirection: null, verticalScrollDirection: null }), ye = Z(null), Je = Z(St), { top: mt, left: Qe, verticalScrollDirection: cn, horizontalScrollDirection: on } = St, Mt = Z(!1), dn = Fl({ rowCount: r, columnCount: i, defaultRowHeight: l, defaultColumnWidth: s, getRowHeight: a, getColumnWidth: d }), nn = Z(null), De = _e(() => {
|
|
2822
2823
|
const v = g || dn;
|
|
2823
|
-
return
|
|
2824
|
-
}, [dn, g,
|
|
2825
|
-
const
|
|
2826
|
-
return { getColOffset: (fe) => v.getColOffset(fe) -
|
|
2827
|
-
},
|
|
2824
|
+
return nn.current = null, { getColOffset: (O) => v.getColOffset(O) * Y, getColIndex: (O) => v.getColIndex(O / Y), getRowOffset: (O) => v.getRowOffset(O) * Y, getRowIndex: (O) => v.getRowIndex(O / Y) };
|
|
2825
|
+
}, [dn, g, Y]), Kt = (v, O, A) => {
|
|
2826
|
+
const j = (O?.left ?? 0) + 0, V = (O?.top ?? 0) + 0;
|
|
2827
|
+
return { getColOffset: (fe) => v.getColOffset(fe) - j, getColIndex: (fe) => v.getColIndex(fe + j), getRowOffset: (fe) => v.getRowOffset(fe) - V, getRowIndex: (fe) => v.getRowIndex(fe + V) };
|
|
2828
|
+
}, xt = D((v, O = !1) => go(v, O, De.getRowOffset, O ? 0 : r), [r, De?.getRowOffset]), Vt = k(L ?? xt, [L]), Cn = D((v, O = !1) => go(v, O, De.getColOffset, O ? i : 0), [i, De?.getColOffset]), un = k(U ?? Cn, [U]), We = _e(() => Math.min(n ?? 800, De.getColOffset(i)), [De.getColOffset, i, n]), Q = _e(() => Math.min(o ?? 600, De.getRowOffset(r)), [De.getRowOffset, r, o]), et = D((v) => {
|
|
2828
2829
|
Ct.canUseDOM && setTimeout(() => {
|
|
2829
|
-
|
|
2830
|
+
Ve.current?.focus({ preventScroll: !0, ...v });
|
|
2830
2831
|
}, 0);
|
|
2831
|
-
}, []),
|
|
2832
|
+
}, []), Ue = D((v) => Ve.current?.contains(v) || dt.current?.contains(v), []);
|
|
2832
2833
|
st(() => {
|
|
2833
|
-
|
|
2834
|
-
}, [
|
|
2835
|
-
const
|
|
2834
|
+
Mt.current && (ye.current && ye.current.left !== Je.current?.left && ye.current.top !== Je.current?.top || (ye.current = null, Me?.({ left: Qe, top: mt })));
|
|
2835
|
+
}, [Qe, mt]);
|
|
2836
|
+
const ht = k(() => ({ top: mt, left: Qe }), [mt, Qe]), Ie = _e(() => {
|
|
2836
2837
|
const v = [];
|
|
2837
|
-
let
|
|
2838
|
-
typeof
|
|
2839
|
-
const
|
|
2840
|
-
if (
|
|
2841
|
-
const
|
|
2842
|
-
let
|
|
2843
|
-
v[1] = { minIndex:
|
|
2844
|
-
}
|
|
2845
|
-
const se = Math.max(0, Q - fe),
|
|
2846
|
-
let
|
|
2847
|
-
return v[0] = { minIndex:
|
|
2848
|
-
}, [
|
|
2838
|
+
let O = 0, A = 0;
|
|
2839
|
+
typeof z == "number" ? O = z : (O = z.index ?? 0, A = (z.scrollOffset ?? 0) * Y);
|
|
2840
|
+
const j = A, V = De.getRowOffset(O), fe = V - j;
|
|
2841
|
+
if (O > 0) {
|
|
2842
|
+
const ft = Kt(De, { top: A + De.getRowOffset(0) }), $e = De.getRowIndex(j), Be = De.getRowIndex(V - 1);
|
|
2843
|
+
let gt;
|
|
2844
|
+
v[1] = { minIndex: $e, maxIndex: Be, minCoord: 0, maxCoord: O - 1, minBounds: 0, maxBounds: fe, visibleIndices: () => gt || (gt = Object.freeze(io(Vt, $e, Be)), gt), layout: ft, maxVirtualBounds: V, scrollOffset: A, freezeOffset: A };
|
|
2845
|
+
}
|
|
2846
|
+
const se = Math.max(0, Q - fe), xe = Kt(De, { top: mt + fe }), be = xe.getRowIndex(0), ce = xe.getRowIndex(se);
|
|
2847
|
+
let Fe;
|
|
2848
|
+
return v[0] = { minIndex: be, maxIndex: ce, minCoord: O, maxCoord: r - 1, minBounds: fe, maxBounds: se, visibleIndices: () => Fe || (Fe = Object.freeze(io(Vt, be, ce)), Fe), layout: xe, maxVirtualBounds: De.getRowOffset(r), scrollOffset: mt, freezeOffset: (O > 0 ? De.getRowOffset(O) : 0) - A }, v;
|
|
2849
|
+
}, [De.getRowIndex, De.getRowOffset, Vt, Q, r, z, mt, Y]), Oe = _e(() => {
|
|
2849
2850
|
const v = [];
|
|
2850
|
-
let
|
|
2851
|
-
typeof
|
|
2852
|
-
const
|
|
2853
|
-
if (
|
|
2854
|
-
const
|
|
2855
|
-
let
|
|
2856
|
-
v[1] = { minIndex:
|
|
2857
|
-
}
|
|
2858
|
-
const se = Math.max(0,
|
|
2859
|
-
let
|
|
2860
|
-
return v[0] = { minIndex:
|
|
2861
|
-
}, [
|
|
2851
|
+
let O = 0, A = 0;
|
|
2852
|
+
typeof C == "number" ? O = C : (O = C.index ?? 0, A = (C.scrollOffset ?? 0) * Y);
|
|
2853
|
+
const j = A, V = De.getColOffset(O), fe = V - j;
|
|
2854
|
+
if (O > 0) {
|
|
2855
|
+
const ft = Kt(De, { left: A + De.getColOffset(0) }), $e = De.getColIndex(j), Be = De.getColIndex(V - 1);
|
|
2856
|
+
let gt;
|
|
2857
|
+
v[1] = { minIndex: $e, maxIndex: Be, minCoord: 0, maxCoord: O - 1, minBounds: 0, maxBounds: fe, visibleIndices: () => gt || (gt = Object.freeze(io(un, $e, Be)), gt), layout: ft, maxVirtualBounds: V, scrollOffset: A, freezeOffset: A };
|
|
2858
|
+
}
|
|
2859
|
+
const se = Math.max(0, We - fe), xe = Kt(De, { left: Qe + fe }), be = xe.getColIndex(0), ce = xe.getColIndex(se);
|
|
2860
|
+
let Fe;
|
|
2861
|
+
return v[0] = { minIndex: be, maxIndex: ce, minCoord: O, maxCoord: i - 1, minBounds: fe, maxBounds: se, visibleIndices: () => Fe || (Fe = Object.freeze(io(un, be, ce)), Fe), layout: xe, maxVirtualBounds: De.getColOffset(i), scrollOffset: Qe, freezeOffset: (O > 0 ? De.getColOffset(O) : 0) - A }, v;
|
|
2862
|
+
}, [De.getColIndex, De.getColOffset, un, We, i, C, Qe, Y]), rt = Z({}), tt = Z([]), ze = _e(() => {
|
|
2862
2863
|
let v = {};
|
|
2863
|
-
const
|
|
2864
|
-
const
|
|
2865
|
-
if (
|
|
2866
|
-
const ce = { rowStart: Ie[
|
|
2864
|
+
const O = (j, V, fe, se, xe) => {
|
|
2865
|
+
const be = { vertical: se?.vertical || !1, horizontal: se?.horizontal || !1 };
|
|
2866
|
+
if (j >= Oe.length || V >= Ie.length) return null;
|
|
2867
|
+
const ce = { rowStart: Ie[V].minIndex, colStart: Oe[j].minIndex, rowEnd: Ie[V].maxIndex, colEnd: Oe[j].maxIndex };
|
|
2867
2868
|
if (ce.rowStart > ce.rowEnd || ce.colStart > ce.colEnd) return null;
|
|
2868
|
-
const
|
|
2869
|
-
let
|
|
2870
|
-
const
|
|
2871
|
-
return { getStage: () =>
|
|
2872
|
-
let
|
|
2873
|
-
return
|
|
2874
|
-
if (
|
|
2875
|
-
const
|
|
2869
|
+
const Fe = { getColIndex: (Ce) => Oe[j].layout.getColIndex(Ce), getColOffset: (Ce) => Oe[j].layout.getColOffset(Ce), getRowIndex: (Ce) => Ie[V].layout.getRowIndex(Ce), getRowOffset: (Ce) => Ie[V].layout.getRowOffset(Ce) }, ft = Object.freeze({ left: xe?.left ?? 0, top: xe?.top ?? 0, right: xe?.right ?? 0, bottom: xe?.bottom ?? 0 }), $e = Object.freeze({ x: Oe[j].minBounds, y: Ie[V].minBounds, width: Oe[j].maxBounds, height: Ie[V].maxBounds }), Be = (Ce, Ge) => Fr(Fe, Ce ?? ce, Ge), gt = { width: Oe[j].maxVirtualBounds, height: Ie[V].maxVirtualBounds }, Xe = { left: Oe[j].scrollOffset, top: Ie[V].scrollOffset }, Lt = { left: Oe[j].freezeOffset, top: Ie[V].freezeOffset }, vt = { width: We, height: Q };
|
|
2870
|
+
let pe = null, wt = null;
|
|
2871
|
+
const $t = (Lt.top + (se.vertical ? Xe.top : 0)) / Y, Wt = (Lt.left + (se.horizontal ? Xe.left : 0)) / Y;
|
|
2872
|
+
return { getStage: () => Ve.current ?? null, getVisibleRangeCoords: () => ce, toClipBounds: (Ce, Ge) => {
|
|
2873
|
+
let Ae, ct = 0;
|
|
2874
|
+
return Ge === void 0 || typeof Ge == "number" ? (Ae = Be(ce), ct = Ge) : Ae = Ge, ((Pe, Et, yt = 0) => {
|
|
2875
|
+
if (Pe.x > Et.width || Pe.y > Et.height) return null;
|
|
2876
|
+
const Bt = { left: Pe.x, top: Pe.y, bottom: Pe.height + Pe.y, right: Pe.width + Pe.x }, qt = { left: Et.x + yt, top: Et.y + yt, bottom: Et.height - 2 * yt + Et.y, right: Et.width - 2 * yt + Et.x }, Dt = { left: Math.max(Bt.left, qt.left), top: Math.max(Bt.top, qt.top), bottom: Math.min(Bt.bottom, qt.bottom), right: Math.min(Bt.right, qt.right) }, c = { x: Dt.left, y: Dt.top, width: Dt.right - Dt.left, height: Dt.bottom - Dt.top };
|
|
2876
2877
|
return c.height < 0 || c.width < 0 ? null : c;
|
|
2877
|
-
})(Ce ?? { x: 0, y: 0, width:
|
|
2878
|
-
}, toViewBounds: (Ce) => Wt === 0 &&
|
|
2879
|
-
const
|
|
2880
|
-
return { x:
|
|
2881
|
-
}, getLayout: () =>
|
|
2882
|
-
const ct = hn(Ce,
|
|
2878
|
+
})(Ce ?? { x: 0, y: 0, width: $e.width, height: $e.height }, Ae, ct);
|
|
2879
|
+
}, toViewBounds: (Ce) => Wt === 0 && $t === 0 && Y === 1 ? Ce : { x: (Ce.x - Wt) * Y, y: (Ce.y - $t) * Y, width: Ce.width * Y, height: Ce.height * Y }, toAbsoluteBounds: (Ce) => Wt === 0 && $t === 0 && Y === 1 ? Ce : { x: Ce.x / Y + Wt, y: Ce.y / Y + $t, width: Ce.width / Y, height: Ce.height / Y }, getRelativePointFromClient: (Ce, Ge) => {
|
|
2880
|
+
const Ae = hn(Ce, Ge);
|
|
2881
|
+
return { x: Ae.x - $e.x, y: Ae.y - $e.y };
|
|
2882
|
+
}, getLayout: () => Fe, getCellCoordsAsRangeCoords: Ne, getVisibleColumns: () => Oe[j].visibleIndices(), getVisibleRows: () => Ie[V].visibleIndices(), getVisibleColumnOffsets: () => (pe || (pe = Br(Oe[j].layout, !0, Oe[j].visibleIndices(), ce.colStart, ce.colEnd)), pe), getVisibleRowOffsets: () => (wt || (wt = Br(Ie[V].layout, !1, Ie[V].visibleIndices(), ce.rowStart, ce.rowEnd)), wt), getTotalRangeCoords: () => ({ colStart: Oe[j].minCoord, colEnd: Oe[j].maxCoord, rowStart: Ie[V].minCoord, rowEnd: Ie[V].maxCoord }), getRangeCoordsBounds: Be, scrollCellCoordsIntoView: (Ce, Ge) => Dn(Ce, Ge, fe), getCellCoordsFromClient: (Ce, Ge, Ae = !1) => {
|
|
2883
|
+
const ct = hn(Ce, Ge);
|
|
2883
2884
|
if (!ct) return null;
|
|
2884
|
-
const
|
|
2885
|
-
if (
|
|
2886
|
-
const
|
|
2887
|
-
return { rowIndex:
|
|
2888
|
-
}, getZoom: () =>
|
|
2885
|
+
const Pe = Fe.getColIndex(ct.x - $e.x), Et = { rowIndex: Fe.getRowIndex(ct.y - $e.y), colIndex: Pe };
|
|
2886
|
+
if (Ae) return Et;
|
|
2887
|
+
const yt = Ne(Et);
|
|
2888
|
+
return { rowIndex: yt.rowStart, colIndex: yt.colStart };
|
|
2889
|
+
}, getZoom: () => Y, getAnchor: () => fe, getBounds: () => $e, getInsets: () => ft, getTotalSize: () => gt, getViewportSize: () => vt, getScrollTopLeft: () => Xe, getFreezeTopLeft: () => Lt, getScrollOrientation: () => be, allViews: () => v };
|
|
2889
2890
|
};
|
|
2890
|
-
let
|
|
2891
|
-
return
|
|
2892
|
-
}, [Ie,
|
|
2891
|
+
let A = v[Xt] = O(0, 0, Xt, os, ns);
|
|
2892
|
+
return A && (v[Xt] = A), A = O(0, 1, Hn, { horizontal: !0 }), A && (v[Hn] = A), A = O(1, 0, Nn, { vertical: !0 }), A && (v[Nn] = A), A = O(1, 1, uo, {}), A && (v[uo] = A), rt.current = null, v = Object.freeze(v);
|
|
2893
|
+
}, [Ie, Oe, Ne]), rn = Object.keys(ze), Tt = Oe[0]?.maxVirtualBounds ?? 0, nt = Ie[0]?.maxVirtualBounds ?? 0, Rt = _e(() => ({ left: Oe[1] ? Oe[1].layout.getColOffset(Oe[1].maxIndex + 1) : 0, top: Ie[1] ? Ie[1].layout.getRowOffset(Ie[1].maxIndex + 1) : 0 }), [ze]);
|
|
2893
2894
|
st(() => {
|
|
2894
2895
|
if (tt.current.length > 0) {
|
|
2895
2896
|
for (let v = 0; v < tt.current.length; v++) tt.current[v]();
|
|
2896
2897
|
tt.current = [];
|
|
2897
2898
|
}
|
|
2898
|
-
}, [
|
|
2899
|
-
const
|
|
2899
|
+
}, [ze]);
|
|
2900
|
+
const Ot = k(() => ({ containerWidth: We, containerHeight: Q, totalWidth: Tt, totalHeight: nt }), [We, Q, De]);
|
|
2900
2901
|
st(() => {
|
|
2901
|
-
!
|
|
2902
|
-
}, [
|
|
2903
|
-
|
|
2904
|
-
}, [
|
|
2905
|
-
const hn =
|
|
2906
|
-
ao(typeof v == "number" && typeof
|
|
2907
|
-
const
|
|
2908
|
-
return
|
|
2909
|
-
}, []), mo =
|
|
2910
|
-
if (Object.keys(
|
|
2911
|
-
const
|
|
2912
|
-
if (!
|
|
2913
|
-
const { x:
|
|
2902
|
+
!ye.current && Mt.current && E({ top: mt, left: Qe, width: We, height: Q, totalWidth: Tt, totalHeight: nt });
|
|
2903
|
+
}, [mt, Qe, Tt, nt]), st(() => {
|
|
2904
|
+
Mt.current && E({ top: mt, left: Qe, width: We, height: Q, totalWidth: Tt, totalHeight: nt });
|
|
2905
|
+
}, [We, Q]);
|
|
2906
|
+
const hn = D((v, O) => {
|
|
2907
|
+
ao(typeof v == "number" && typeof O == "number");
|
|
2908
|
+
const A = Ve.current?.getBoundingClientRect();
|
|
2909
|
+
return A ? { x: v - A.x, y: O - A.y } : { x: v, y: O };
|
|
2910
|
+
}, []), mo = k((v) => ze[v] || null, [ze]), xo = k((v, O) => {
|
|
2911
|
+
if (Object.keys(ze).length === 1) return ze[Xt];
|
|
2912
|
+
const A = hn(v, O);
|
|
2913
|
+
if (!A) return null;
|
|
2914
|
+
const { x: j, y: V } = A;
|
|
2914
2915
|
let fe = null;
|
|
2915
2916
|
const se = Hr;
|
|
2916
|
-
for (let
|
|
2917
|
-
const
|
|
2918
|
-
|
|
2917
|
+
for (let xe = 0; !fe && xe < se.length; xe++) {
|
|
2918
|
+
const be = ze[se[xe]];
|
|
2919
|
+
be && ql(j, V, be.getBounds()) && (fe = be);
|
|
2919
2920
|
}
|
|
2920
|
-
return fe || (fe =
|
|
2921
|
-
}, [
|
|
2921
|
+
return fe || (fe = ze[Xt]), fe;
|
|
2922
|
+
}, [ze, Ne]), pt = k(() => ze[Xt].getVisibleRangeCoords(), [ze[Xt]]), ln = Z(null), vo = D(() => {
|
|
2922
2923
|
ln.current !== null && Ct.cancelTimeout(ln.current), ln.current = Ct.requestTimeout(yo, 150);
|
|
2923
|
-
}, []), yo =
|
|
2924
|
-
ln.current = null,
|
|
2925
|
-
const
|
|
2926
|
-
return
|
|
2924
|
+
}, []), yo = D(() => {
|
|
2925
|
+
ln.current = null, M((v) => {
|
|
2926
|
+
const O = { ...v, verticalScrollDirection: null, horizontalScrollDirection: null };
|
|
2927
|
+
return Je.current = O, O;
|
|
2927
2928
|
});
|
|
2928
|
-
}, []), xn =
|
|
2929
|
-
const
|
|
2930
|
-
if (
|
|
2929
|
+
}, []), xn = k((v) => {
|
|
2930
|
+
const O = v?.left ?? v?.[0], A = v?.top ?? v?.[1], j = O !== void 0 ? Math.min(Tt - We, Math.max(Oe?.[1]?.scrollOffset ?? 0, O)) : Je.current.left, V = A !== void 0 ? Math.min(nt - Q, Math.max(Ie?.[1]?.scrollOffset ?? 0, A)) : Je.current.top;
|
|
2931
|
+
if (Je.current.left === j && Je.current.top === V) return;
|
|
2931
2932
|
let fe = null, se = null;
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
const
|
|
2935
|
-
return
|
|
2933
|
+
Je.current.left > j ? fe = ot : Je.current.left < j && (fe = Ke), Je.current.top > V ? se = it : Je.current.top < V && (se = lt), Ct.throttle(() => {
|
|
2934
|
+
M((xe) => {
|
|
2935
|
+
const be = { ...xe, left: j, top: V, horizontalScrollDirection: fe, verticalScrollDirection: se };
|
|
2936
|
+
return Je.current = be, be;
|
|
2936
2937
|
});
|
|
2937
|
-
}, 17)(),
|
|
2938
|
-
}, [
|
|
2938
|
+
}, 17)(), ye.current?.top === V && ye.current?.left === j || (ye.current = { left: j, top: V }, $({ left: j, top: V }), E({ left: j, top: V, width: We, height: Q, totalWidth: Tt, totalHeight: nt })), vo();
|
|
2939
|
+
}, [Tt, nt, Ie, Oe]);
|
|
2939
2940
|
st(() => {
|
|
2940
|
-
|
|
2941
|
-
}, [
|
|
2942
|
-
|
|
2943
|
-
}, [
|
|
2944
|
-
const
|
|
2945
|
-
const
|
|
2946
|
-
|
|
2947
|
-
}, [
|
|
2948
|
-
let
|
|
2949
|
-
if (Object.keys(
|
|
2950
|
-
const
|
|
2951
|
-
for (let
|
|
2952
|
-
const
|
|
2953
|
-
|
|
2941
|
+
ye.current || xn({ left: Qe, top: mt });
|
|
2942
|
+
}, [Tt, We, nt, Q]), tn(() => {
|
|
2943
|
+
ye.current = { left: at?.left, top: at?.top }, xn(ye.current);
|
|
2944
|
+
}, [at?.left, at?.top]);
|
|
2945
|
+
const qn = k((v) => {
|
|
2946
|
+
const O = v?.left ?? v?.[0], A = v?.top ?? v?.[1], j = v?.behavior ?? "auto", V = { left: Je.current.left + (O ?? 0), top: Je.current.top + (A ?? 0) };
|
|
2947
|
+
j && (V.behavior = j), xn(V);
|
|
2948
|
+
}, [Tt, We, nt, Q]), Yn = D((v) => {
|
|
2949
|
+
let O = null;
|
|
2950
|
+
if (Object.keys(ze).length > 1) {
|
|
2951
|
+
const A = Hr;
|
|
2952
|
+
for (let j = 0; !O && j < A.length; j++) {
|
|
2953
|
+
const V = ze[A[j]];
|
|
2954
|
+
V && G.isCellWithinRange(v, V.getVisibleRangeCoords()) && (O = V);
|
|
2954
2955
|
}
|
|
2955
2956
|
}
|
|
2956
|
-
return
|
|
2957
|
-
}, [
|
|
2958
|
-
const
|
|
2959
|
-
let
|
|
2960
|
-
if (
|
|
2961
|
-
if (
|
|
2962
|
-
|
|
2957
|
+
return O || (O = ze[Xt]), O;
|
|
2958
|
+
}, [ze]), Dn = k((v, O = { inline: "nearest", block: "nearest" }, A = null) => {
|
|
2959
|
+
const j = { rowIndex: 0, colIndex: 0, ...v };
|
|
2960
|
+
let V = null;
|
|
2961
|
+
if (A !== null) {
|
|
2962
|
+
if (V = ze[A], V === null) return new Promise((vt, pe) => {
|
|
2963
|
+
pe("Invalid view");
|
|
2963
2964
|
});
|
|
2964
|
-
} else
|
|
2965
|
-
const fe =
|
|
2966
|
-
|
|
2967
|
-
const
|
|
2968
|
-
return
|
|
2965
|
+
} else V = Yn(j);
|
|
2966
|
+
const fe = Ne(j), se = V.getLayout(), xe = se.getColOffset(fe.colStart), be = se.getRowOffset(fe.rowStart), ce = se.getColOffset(fe.colEnd + 1), Fe = se.getRowOffset(fe.rowEnd + 1), ft = V.getBounds(), $e = V.getTotalSize(), Be = V.getScrollTopLeft(), gt = ((vt, pe, wt = !0) => (wt = wt === !0 ? { block: "start", inline: "end" } : wt === !1 ? { block: "end", inline: "end" } : { block: "end", inline: "end", ...wt }, { left: zr(wt.inline, vt.x, vt.x + vt.width, pe.left, pe.left + pe.width, pe.totalWidth), top: zr(wt.block, vt.y, vt.y + vt.height, pe.top, pe.top + pe.height, pe.totalHeight) }))({ x: xe + Be.left, y: be + Be.top, width: ce - xe, height: Fe - be }, { left: Be.left, top: Be.top, width: ft.width, height: ft.height, totalWidth: $e.width, totalHeight: $e.height }, O), Xe = { ...gt };
|
|
2967
|
+
Xe.left > Qe ? Xe.left += 20 : Xe.left < Qe && (Xe.left -= 0), Xe.top > mt ? Xe.top += 20 : Xe.top < mt && (Xe.top -= 0);
|
|
2968
|
+
const Lt = V.getScrollOrientation();
|
|
2969
|
+
return Lt.horizontal && v.colIndex !== void 0 || delete Xe.left, Lt.vertical && v.rowIndex !== void 0 || delete Xe.top, new Promise((vt, pe) => {
|
|
2969
2970
|
try {
|
|
2970
|
-
xn(
|
|
2971
|
-
} catch (
|
|
2972
|
-
|
|
2971
|
+
xn(Xe), vt(Xe);
|
|
2972
|
+
} catch (wt) {
|
|
2973
|
+
pe(wt);
|
|
2973
2974
|
}
|
|
2974
2975
|
});
|
|
2975
|
-
}, [
|
|
2976
|
-
const
|
|
2976
|
+
}, [Tt, nt, ze, Ne]), Mn = k((v) => {
|
|
2977
|
+
const O = v.shiftKey;
|
|
2977
2978
|
v.preventDefault();
|
|
2978
|
-
const { deltaX:
|
|
2979
|
-
if (
|
|
2980
|
-
let se =
|
|
2981
|
-
const
|
|
2982
|
-
|
|
2983
|
-
|
|
2979
|
+
const { deltaX: A, deltaY: j, deltaMode: V } = v;
|
|
2980
|
+
if (kt.current || ue?.(v) === !1) return;
|
|
2981
|
+
let se = O ? j : A, xe = j;
|
|
2982
|
+
const be = O || Math.abs(se) > Math.abs(xe);
|
|
2983
|
+
V === 1 && (xe *= 0), kt.current = window.requestAnimationFrame(() => {
|
|
2984
|
+
kt.current = null, qn(be ? { left: se } : { top: xe });
|
|
2984
2985
|
});
|
|
2985
|
-
}, [
|
|
2986
|
-
|
|
2986
|
+
}, [Tt, We, nt, Q, ue]), zn = D((v = null) => {
|
|
2987
|
+
nn.current = null, rt.current = null, Zt();
|
|
2987
2988
|
}, []);
|
|
2988
|
-
|
|
2989
|
+
tn(() => {
|
|
2989
2990
|
zn();
|
|
2990
2991
|
}, [oe]);
|
|
2991
|
-
const vn = wo(t, () => ({ stage:
|
|
2992
|
+
const vn = wo(t, () => ({ stage: Ve.current, focus: et, contains: Ue, invalidate: zn, scrollTo: xn, scrollBy: qn, scrollCellCoordsIntoView: Dn, getScrollPosition: ht, getDimensions: Ot, getViewport: pt, handleWheel: Mn, rowCount: r, columnCount: i, getLayout: () => De, getRelativePointFromClient: hn, getViewFromClient: xo, getViewFromCellCoords: Yn, getViewFromLocation: mo, onViewChangeOnce: (v) => {
|
|
2992
2993
|
tt.current.push(v);
|
|
2993
|
-
} }), [r, i,
|
|
2994
|
-
st(() => (He && vn.current?.addEventListener("wheel", Mn, { passive: !1 }),
|
|
2994
|
+
} }), [r, i, ze]);
|
|
2995
|
+
st(() => (He && vn.current?.addEventListener("wheel", Mn, { passive: !1 }), Mt.current = !0, ye.current = null, () => {
|
|
2995
2996
|
vn.current?.removeEventListener("wheel", Mn);
|
|
2996
2997
|
}), [He]);
|
|
2997
|
-
const An =
|
|
2998
|
-
!v || !H || (An.current = [],
|
|
2999
|
-
const
|
|
2998
|
+
const An = Z([]), bo = (v, O) => {
|
|
2999
|
+
!v || !H || (An.current = [], O.push(((A, j) => {
|
|
3000
|
+
const V = `view:${A.getAnchor()}:overlay:${O.length}`, fe = H?.({ key: V, view: A }, (xe) => An.current[j] = xe);
|
|
3000
3001
|
if (!fe) return null;
|
|
3001
|
-
const se =
|
|
3002
|
-
return
|
|
3002
|
+
const se = A.getBounds();
|
|
3003
|
+
return q("div", { style: { position: "absolute", left: "0px", top: "0px", width: `${se.width}px`, height: `${se.height}px`, overflow: "hidden" }, children: fe }, `overlay-${A.getAnchor()}-${j}`);
|
|
3003
3004
|
})(v, 0)));
|
|
3004
|
-
}, So =
|
|
3005
|
-
const v = {},
|
|
3006
|
-
for (let
|
|
3007
|
-
const
|
|
3008
|
-
bo(
|
|
3005
|
+
}, So = _e(() => {
|
|
3006
|
+
const v = {}, O = Object.keys(ze);
|
|
3007
|
+
for (let A = 0; A < O.length; A++) {
|
|
3008
|
+
const j = O[A], V = [];
|
|
3009
|
+
bo(ze[j], V), v[j] = { overlays: V };
|
|
3009
3010
|
}
|
|
3010
3011
|
return v;
|
|
3011
|
-
}, [
|
|
3012
|
+
}, [ut, H, r, i, Ie, Oe]), Xn = (v, O, A, j, V, fe, se) => {
|
|
3012
3013
|
if (!v) return;
|
|
3013
|
-
const
|
|
3014
|
-
if (
|
|
3014
|
+
const xe = v.getVisibleColumns(), be = v.getVisibleRows();
|
|
3015
|
+
if (xe.length === 0 || be.length === 0) return;
|
|
3015
3016
|
let ce = null;
|
|
3016
|
-
if (
|
|
3017
|
+
if (te) ce = te(v);
|
|
3017
3018
|
else {
|
|
3018
3019
|
ce = [];
|
|
3019
|
-
for (let
|
|
3020
|
-
const ct = { rowIndex:
|
|
3021
|
-
if (
|
|
3022
|
-
const
|
|
3023
|
-
ce.push(
|
|
3020
|
+
for (let Ge = 0; Ge < be.length; Ge++) for (let Ae = 0; Ae < xe.length; Ae++) {
|
|
3021
|
+
const ct = { rowIndex: be[Ge], colIndex: xe[Ae] };
|
|
3022
|
+
if (ee?.(ct)) continue;
|
|
3023
|
+
const Pe = { coords: ct, range: Ne(ct) };
|
|
3024
|
+
ce.push(Pe);
|
|
3024
3025
|
}
|
|
3025
3026
|
}
|
|
3026
|
-
const
|
|
3027
|
-
const
|
|
3028
|
-
|
|
3029
|
-
let
|
|
3030
|
-
|
|
3031
|
-
let w = fe?.get(
|
|
3027
|
+
const Fe = v.getVisibleColumnOffsets(), ft = v.getVisibleRowOffsets(), $e = v.getScrollTopLeft(), Be = v.getFreezeTopLeft(), gt = $e.left + Be.left, Xe = $e.top + Be.top, Lt = Math.trunc(gt / sn), vt = Math.trunc(Xe / sn), pe = {}, wt = (Ge, Ae, ct, Pe, Et) => {
|
|
3028
|
+
const yt = `view:${Ge.getAnchor()}:cell:${Dr(Ae.rowIndex, Ae.colIndex)}`, Bt = Pe.x, qt = Pe.y, Dt = Math.trunc((gt + Bt) / sn) - Lt, c = Math.trunc((Xe + qt) / sn) - vt;
|
|
3029
|
+
pe[c] || (pe[c] = {});
|
|
3030
|
+
let u = pe[c][Dt];
|
|
3031
|
+
u || (u = pe[c][Dt] = []);
|
|
3032
|
+
let w = fe?.get(yt);
|
|
3032
3033
|
if (!w) {
|
|
3033
|
-
const p = (
|
|
3034
|
-
w = oe({ key:
|
|
3034
|
+
const p = (gt + Bt) % sn, y = (Xe + qt) % sn;
|
|
3035
|
+
w = oe({ key: yt, coords: Ae, bounds: Pe, zoom: Y, range: ct, view: Ge, value: Et, style: { left: we.boundPixel(p), top: we.boundPixel(y), width: we.boundPixel(Pe.width, !0), height: we.boundPixel(Pe.height, !0) } });
|
|
3035
3036
|
}
|
|
3036
|
-
se?.set(
|
|
3037
|
+
se?.set(yt, w), u.push(w);
|
|
3037
3038
|
};
|
|
3038
|
-
for (let
|
|
3039
|
-
const
|
|
3039
|
+
for (let Ge = 0; ce && Ge < ce.length; Ge++) {
|
|
3040
|
+
const Ae = ce[Ge], ct = Ae?.coords ?? Ae;
|
|
3040
3041
|
if (!ct) continue;
|
|
3041
|
-
const
|
|
3042
|
-
if (!
|
|
3043
|
-
const
|
|
3044
|
-
if (!
|
|
3045
|
-
const
|
|
3046
|
-
let
|
|
3047
|
-
|
|
3048
|
-
const w = Dr(
|
|
3049
|
-
if (
|
|
3050
|
-
if (
|
|
3051
|
-
|
|
3042
|
+
const Pe = Ae?.range ?? { rowStart: ct.rowIndex, colStart: ct.colIndex, rowEnd: ct.rowIndex, colEnd: ct.colIndex }, Et = v.getVisibleRangeCoords();
|
|
3043
|
+
if (!G.isRangesIntersect(Pe, Et) && !G.isRangeWithinRange(Pe, Et)) continue;
|
|
3044
|
+
const yt = Pe && !G.isSingleCell(Pe);
|
|
3045
|
+
if (!yt && ee?.(ct)) continue;
|
|
3046
|
+
const Bt = ct.rowIndex, qt = ct.colIndex, Dt = ft[Bt], c = Fe[qt];
|
|
3047
|
+
let u = null;
|
|
3048
|
+
Dt && c && (u = { x: c.offset, y: Dt.offset, width: c.size, height: Dt.size });
|
|
3049
|
+
const w = Dr(Pe.rowStart, Pe.colStart);
|
|
3050
|
+
if (yt) {
|
|
3051
|
+
if (V.has(w)) continue;
|
|
3052
|
+
V.add(w), Pe.rowEnd - Pe.rowStart > 0 && A.push(Pe), Pe.colEnd - Pe.colStart > 0 && j.push(Pe);
|
|
3052
3053
|
}
|
|
3053
|
-
if (
|
|
3054
|
+
if (yt && (u = Fr(v.getLayout(), Pe)), !u) {
|
|
3054
3055
|
console.warn("no bounds for cell", w);
|
|
3055
3056
|
continue;
|
|
3056
3057
|
}
|
|
3057
|
-
const p =
|
|
3058
|
-
|
|
3059
|
-
}
|
|
3060
|
-
const
|
|
3061
|
-
for (let
|
|
3062
|
-
const
|
|
3063
|
-
if (
|
|
3064
|
-
const ct = Object.keys(
|
|
3065
|
-
for (let
|
|
3066
|
-
const Et =
|
|
3058
|
+
const p = Ae?.value;
|
|
3059
|
+
wt(v, ct, Pe, u, p);
|
|
3060
|
+
}
|
|
3061
|
+
const $t = gt % sn, Wt = Xe % sn, Ce = Object.keys(pe);
|
|
3062
|
+
for (let Ge = 0; Ge < Ce.length; Ge++) {
|
|
3063
|
+
const Ae = pe[Ce[Ge]];
|
|
3064
|
+
if (!Ae) continue;
|
|
3065
|
+
const ct = Object.keys(Ae);
|
|
3066
|
+
for (let Pe = 0; Pe < ct.length; Pe++) {
|
|
3067
|
+
const Et = Ae[ct[Pe]];
|
|
3067
3068
|
if (!Et) continue;
|
|
3068
|
-
const
|
|
3069
|
-
|
|
3069
|
+
const yt = parseInt(Ce[Ge]), Bt = parseInt(ct[Pe]), qt = yt + vt, Dt = Bt + Lt, c = `view:${v.getAnchor()}:segment:${Dt}:${qt}`;
|
|
3070
|
+
O.push(q("div", { className: "cell-container", style: { transform: `translate(${we.boundPixel(Bt * sn - $t, !0)}px, ${we.boundPixel(yt * sn - Wt, !0)}px)`, willChange: "transform" }, children: Et }, c));
|
|
3070
3071
|
}
|
|
3071
3072
|
}
|
|
3072
|
-
},
|
|
3073
|
-
const v =
|
|
3074
|
-
for (let
|
|
3075
|
-
const fe =
|
|
3076
|
-
Xn(
|
|
3073
|
+
}, Jt = _e(() => {
|
|
3074
|
+
const v = nn.current, O = /* @__PURE__ */ new Map(), A = {}, j = Object.keys(ze);
|
|
3075
|
+
for (let V = 0; V < j.length; V++) {
|
|
3076
|
+
const fe = j[V], se = [], xe = [], be = [];
|
|
3077
|
+
Xn(ze[fe], be, se, xe, /* @__PURE__ */ new Set(), v, O), A[fe] = { cells: be, rangesH: se, rangesV: xe };
|
|
3077
3078
|
}
|
|
3078
|
-
return
|
|
3079
|
-
}, [
|
|
3080
|
-
if (v) if (
|
|
3079
|
+
return nn.current = O, A;
|
|
3080
|
+
}, [ut, r, i, Ie, Oe, x, Se, ae, ee, te, Ne]), Gn = (v, O, A, j, V) => {
|
|
3081
|
+
if (v) if (O) {
|
|
3081
3082
|
const fe = `view:${v.getAnchor()}:hl:`, se = v.getVisibleRows();
|
|
3082
3083
|
if (!se || se.length === 0) return;
|
|
3083
|
-
const
|
|
3084
|
+
const xe = 0, be = v.getBounds().width;
|
|
3084
3085
|
let ce = [];
|
|
3085
|
-
const
|
|
3086
|
-
for (let
|
|
3087
|
-
const
|
|
3088
|
-
if (
|
|
3089
|
-
let
|
|
3090
|
-
for (;
|
|
3091
|
-
const
|
|
3092
|
-
|
|
3086
|
+
const Fe = V.sort(G.rowFirstRangeComparator), ft = v.getVisibleRangeCoords();
|
|
3087
|
+
for (let $e = 0; $e < se.length && se[$e] <= ft.rowEnd; $e++) {
|
|
3088
|
+
const Be = se[$e];
|
|
3089
|
+
if (Be < ft.rowStart) continue;
|
|
3090
|
+
let gt = !1;
|
|
3091
|
+
for (; Fe.length > 0 && Fe[0].rowStart <= Be; ) {
|
|
3092
|
+
const pe = Fe.shift();
|
|
3093
|
+
pe.rowEnd > Be && (ce.push(pe), gt = !0);
|
|
3093
3094
|
}
|
|
3094
|
-
|
|
3095
|
-
const
|
|
3096
|
-
let
|
|
3097
|
-
for (let
|
|
3098
|
-
let
|
|
3099
|
-
const Wt = ce[
|
|
3100
|
-
|
|
3095
|
+
gt && (ce = ce.sort(G.columnFirstRangeComparator));
|
|
3096
|
+
const Xe = v.getLayout(), Lt = Xe.getRowOffset(Be + 1);
|
|
3097
|
+
let vt = xe;
|
|
3098
|
+
for (let pe = 0; pe < ce.length + 1; pe++) {
|
|
3099
|
+
let wt = vt, $t = be;
|
|
3100
|
+
const Wt = ce[pe];
|
|
3101
|
+
pe < ce.length && ($t = Math.min(be, Xe.getColOffset(Wt.colStart)), vt = Math.min(be, Xe.getColOffset(Wt.colEnd + 1))), j.push(Jo("path", { d: `M ${we.boundPixel(wt)} ${we.boundPixel(Lt, !1, A)} L ${we.boundPixel($t)} ${we.boundPixel(Lt, !1, A)}`, stroke: _, strokeWidth: 1, vectorEffect: "non-scaling-stroke", ...I, key: fe + Be + ":" + pe }));
|
|
3101
3102
|
}
|
|
3102
|
-
for (let
|
|
3103
|
+
for (let pe = ce.length - 1; pe >= 0; pe--) ce[pe].rowEnd <= se[$e + 1] && ce.splice(pe, 1);
|
|
3103
3104
|
}
|
|
3104
3105
|
} else {
|
|
3105
3106
|
const fe = `view:${v.getAnchor()}:vl:`, se = v.getVisibleColumns();
|
|
3106
3107
|
if (!se || se.length === 0) return;
|
|
3107
|
-
const
|
|
3108
|
+
const xe = 0, be = v.getBounds().height;
|
|
3108
3109
|
let ce = [];
|
|
3109
|
-
const
|
|
3110
|
-
for (let
|
|
3111
|
-
const
|
|
3112
|
-
if (
|
|
3113
|
-
let
|
|
3114
|
-
for (;
|
|
3115
|
-
const
|
|
3116
|
-
|
|
3110
|
+
const Fe = V.sort(G.columnFirstRangeComparator), ft = v.getVisibleRangeCoords();
|
|
3111
|
+
for (let $e = 0; $e < se.length && se[$e] <= ft.colEnd; $e++) {
|
|
3112
|
+
const Be = se[$e];
|
|
3113
|
+
if (Be < ft.colStart) continue;
|
|
3114
|
+
let gt = !1;
|
|
3115
|
+
for (; Fe.length > 0 && Fe[0].colStart <= Be; ) {
|
|
3116
|
+
const pe = Fe.shift();
|
|
3117
|
+
pe.colEnd > Be && (ce.push(pe), gt = !0);
|
|
3117
3118
|
}
|
|
3118
|
-
|
|
3119
|
-
const
|
|
3120
|
-
let
|
|
3121
|
-
for (let
|
|
3122
|
-
let
|
|
3123
|
-
const Wt = ce[
|
|
3124
|
-
|
|
3125
|
-
let Ce =
|
|
3126
|
-
|
|
3119
|
+
gt && (ce = ce.sort(G.rowFirstRangeComparator));
|
|
3120
|
+
const Xe = v.getLayout(), Lt = Xe.getColOffset(Be + 1);
|
|
3121
|
+
let vt = xe;
|
|
3122
|
+
for (let pe = 0; pe < ce.length + 1; pe++) {
|
|
3123
|
+
let wt = vt, $t = be;
|
|
3124
|
+
const Wt = ce[pe];
|
|
3125
|
+
pe < ce.length && ($t = Math.min(be, Xe.getRowOffset(Wt.rowStart)), vt = Math.min(be, Xe.getRowOffset(Wt.rowEnd + 1)));
|
|
3126
|
+
let Ce = _;
|
|
3127
|
+
j.push(q("path", { d: `M ${we.boundPixel(Lt, !1, A)} ${we.boundPixel(wt)} L ${we.boundPixel(Lt, !1, A)} ${we.boundPixel($t)}`, stroke: Ce, strokeWidth: 1, vectorEffect: "non-scaling-stroke", ...R }, fe + Be + ":" + pe));
|
|
3127
3128
|
}
|
|
3128
|
-
for (let
|
|
3129
|
+
for (let pe = ce.length - 1; pe >= 0; pe--) ce[pe].colEnd <= se[$e + 1] && ce.splice(pe, 1);
|
|
3129
3130
|
}
|
|
3130
3131
|
}
|
|
3131
3132
|
}, $n = (v) => {
|
|
3132
|
-
if (!
|
|
3133
|
-
const
|
|
3134
|
-
for (let
|
|
3135
|
-
const
|
|
3136
|
-
Gn(
|
|
3137
|
-
const se =
|
|
3138
|
-
|
|
3139
|
-
}
|
|
3140
|
-
return
|
|
3141
|
-
}, Zn =
|
|
3142
|
-
const v = [],
|
|
3143
|
-
if (!
|
|
3144
|
-
const
|
|
3145
|
-
return Ht("div", { style: { position: "absolute", pointerEvents: "none", left:
|
|
3133
|
+
if (!Jt) return;
|
|
3134
|
+
const O = {};
|
|
3135
|
+
for (let A = 0; A < rn.length; A++) {
|
|
3136
|
+
const j = rn[A], V = ze[j], fe = [];
|
|
3137
|
+
Gn(V, v, 0, fe, v ? Jt[j].rangesH : Jt[j].rangesV);
|
|
3138
|
+
const se = V.getRangeCoordsBounds(), xe = Math.ceil(se.width), be = Math.ceil(se.height);
|
|
3139
|
+
O[j] = q("svg", { width: `${xe}`, height: `${be}`, viewBox: `0 0 ${xe} ${be}`, preserveAspectRatio: "none", shapeRendering: "crispEdges", style: { position: "absolute" }, children: fe });
|
|
3140
|
+
}
|
|
3141
|
+
return O;
|
|
3142
|
+
}, Zn = _e(() => x === !0 || x?.horizontal === !0 ? $n(!0) : null, [ut, x, Ie, z, C, _, I, r, i, We, Tt, Jt]), Jn = _e(() => x === !0 || x?.vertical === !0 ? $n(!1) : null, [ut, x, Oe, z, C, _, R, r, i, Q, nt, Jt]), Eo = _e(() => Rt.left === 0 ? null : q(jr, { linePoints: [0, 0, 0, Q + 1], bounds: { x: Rt.left, y: 0, width: 1, height: Q + 1 }, ...le }), [ut, Rt.left, Q, le]), _o = _e(() => Rt.top === 0 ? null : q(jr, { linePoints: [0, 0, We + 1, 0], bounds: { x: 0, y: Rt.top, width: We + 1, height: 1 }, ...B }), [ut, Rt.top, We, B]), Bn = _e(() => {
|
|
3143
|
+
const v = [], O = (A) => {
|
|
3144
|
+
if (!A || !ze[A]) return;
|
|
3145
|
+
const j = ze[A].getBounds();
|
|
3146
|
+
return Ht("div", { style: { position: "absolute", pointerEvents: "none", left: j.x, top: j.y, width: j.width, height: j.height, clip: `rect(0, ${j.width + 1}px, ${j.height + 1}px, 0)` }, className: `view view-${A}`, children: [Zn?.[A], Jn?.[A], Jt?.[A].cells] }, `view:${A}`);
|
|
3146
3147
|
};
|
|
3147
|
-
for (let
|
|
3148
|
-
return
|
|
3149
|
-
}, [
|
|
3148
|
+
for (let A = 0; A < rn.length; A++) v.push(O(rn[A]));
|
|
3149
|
+
return q(wn, { children: v });
|
|
3150
|
+
}, [ze, Zn, Jn, Jt]), Io = _e(() => {
|
|
3150
3151
|
if (!t) return;
|
|
3151
|
-
const v = (se,
|
|
3152
|
+
const v = (se, xe, be, ce) => {
|
|
3152
3153
|
if (!ce || ce.length === 0) return;
|
|
3153
|
-
const
|
|
3154
|
-
for (let
|
|
3155
|
-
const
|
|
3156
|
-
let
|
|
3157
|
-
|
|
3154
|
+
const Fe = [];
|
|
3155
|
+
for (let ft = 0; ft < ce.length; ft++) {
|
|
3156
|
+
const $e = ce[ft];
|
|
3157
|
+
let Be = se?.get($e);
|
|
3158
|
+
Be !== Fo && (Be = $e(be) ?? Fo), xe.set($e, Be), Be && Be !== Fo && Fe.push(Be);
|
|
3158
3159
|
}
|
|
3159
|
-
return
|
|
3160
|
-
},
|
|
3161
|
-
if (!
|
|
3162
|
-
const ce =
|
|
3163
|
-
return Ht("div", { className: En("view", `view-${
|
|
3164
|
-
},
|
|
3160
|
+
return Fe;
|
|
3161
|
+
}, O = (se, xe, be) => {
|
|
3162
|
+
if (!be) return;
|
|
3163
|
+
const ce = be.getBounds(), Fe = be.getInsets(), ft = be.getAnchor();
|
|
3164
|
+
return Ht("div", { className: En("view", `view-${ft}`, Wr.view), style: { position: "absolute", pointerEvents: "none", left: ce.x - Fe.left, top: ce.y - Fe.top, width: ce.width - (Fe.left + Fe.right), height: ce.height - (Fe.top + Fe.bottom), clipPath: h ? "inset(-2px)" : "inset(0px)" }, children: [v(se, xe, be, T), So?.[ft].overlays] }, `view:${ft}`);
|
|
3165
|
+
}, A = rt.current, j = {}, V = [], fe = Object.keys(ze);
|
|
3165
3166
|
for (let se = 0; se < fe.length; se++) {
|
|
3166
|
-
const
|
|
3167
|
-
|
|
3168
|
-
}
|
|
3169
|
-
return rt.current =
|
|
3170
|
-
}, [
|
|
3171
|
-
const { style: v, ...
|
|
3172
|
-
return
|
|
3173
|
-
}, [
|
|
3167
|
+
const xe = fe[se], be = A?.[xe], ce = j[xe] = /* @__PURE__ */ new Map();
|
|
3168
|
+
V.push(O(be, ce, ze[xe]));
|
|
3169
|
+
}
|
|
3170
|
+
return rt.current = j, V;
|
|
3171
|
+
}, [ut, ze, h, T]), Co = _e(() => {
|
|
3172
|
+
const { style: v, ...O } = J ?? {};
|
|
3173
|
+
return q("div", { style: { width: We, height: Q, ...v }, className: "sheetxl-stage", tabIndex: 0, ref: Ve, ...O, ...Ye, children: K ? K(Bn) : Bn });
|
|
3174
|
+
}, [We, Q, Bn, J, K]), Qn = Z(!1);
|
|
3174
3175
|
return st(() => {
|
|
3175
|
-
!Qn.current &&
|
|
3176
|
-
}, [
|
|
3176
|
+
!Qn.current && Jt && (Qn.current = !0, me?.(vn.current));
|
|
3177
|
+
}, [Jt]), Ht("div", { className: En("sheetxl-grid", Wr["sheetxl-grid"]), style: { overflow: "visible", cursor: P, maxWidth: We, maxHeight: Q, width: We, height: Q, ...Se }, ref: vn, children: [Co, Ht("div", { className: En("sheetxl-overlays"), ref: dt, ...S, children: [Io, Eo, _o] })] });
|
|
3177
3178
|
}));
|
|
3178
3179
|
Ci.displayName = "BaseGrid";
|
|
3179
|
-
const Mi =
|
|
3180
|
+
const Mi = At(Ut((e, t) => {
|
|
3180
3181
|
const { width: n, height: o, style: r = {}, className: i, ...l } = e, [s, { width: a, height: d }] = _i();
|
|
3181
|
-
return
|
|
3182
|
+
return q("div", { className: i, style: { ...r }, children: q("div", { style: { position: "relative", top: "0px", left: "0px", width: "100%", height: "100%", maxWidth: "100%", maxHeight: "100%", boxSizing: "content-box" }, ref: s, children: q(Ci, { ref: t, width: n ?? a, height: o ?? d, ...l }) }) });
|
|
3182
3183
|
}));
|
|
3183
3184
|
Mi.displayName = "Grid";
|
|
3184
|
-
const rs =
|
|
3185
|
-
const { showVerticalScrollbar: n, showHorizontalScrollbar: o, createHorizontalScrollbar: r, createVerticalScrollbar: i, createScrollCorner: l, viewport: s, onScrollViewport: a, style: d = {}, className: g, onScroll: m, ...f } = e, [x,
|
|
3186
|
-
ao(!s), Ur(t, () =>
|
|
3187
|
-
const ae =
|
|
3188
|
-
|
|
3185
|
+
const rs = At(Ut((e, t) => {
|
|
3186
|
+
const { showVerticalScrollbar: n, showHorizontalScrollbar: o, createHorizontalScrollbar: r, createVerticalScrollbar: i, createScrollCorner: l, viewport: s, onScrollViewport: a, style: d = {}, className: g, onScroll: m, ...f } = e, [x, _] = Ze(null), I = Z(null), R = Z(null);
|
|
3187
|
+
ao(!s), Ur(t, () => R.current && I.current ? Object.assign(R.current, I.current) : null);
|
|
3188
|
+
const ae = D((P) => {
|
|
3189
|
+
R.current?.scrollTo(P), a?.(P);
|
|
3189
3190
|
}, []);
|
|
3190
|
-
return
|
|
3191
|
+
return q(pi, { className: g, style: d, ref: I, showVerticalScrollbar: n, showHorizontalScrollbar: o, createHorizontalScrollbar: r, createVerticalScrollbar: i, createScrollCorner: l, viewport: x, onScrollViewport: ae, children: q(Mi, { style: { width: "100%", height: "100%" }, ...f, onViewportChange: (P) => _(P), ref: R }) });
|
|
3191
3192
|
}));
|
|
3192
3193
|
rs.displayName = "ScrollableGrid";
|
|
3193
|
-
const Nr = () => !1, is =
|
|
3194
|
-
const { index: t, value: n, zoom: o, zoomScale: r = 100, headerText: i = (
|
|
3194
|
+
const Nr = () => !1, is = At((e) => {
|
|
3195
|
+
const { index: t, value: n, zoom: o, zoomScale: r = 100, headerText: i = (T) => `${T}`, headerStyle: l, headerStyleSelect: s = l, headerStyleSelectAll: a = s, headerStyleHover: d = a, verticalPadding: g = 0, horizontalPadding: m = 0, isSelected: f = Nr, isSelectedAll: x = Nr, coords: _, bounds: I, range: R, orientation: ae, view: P, style: C, ...z } = e, le = r / 100, B = Z(null), [oe, ve] = Ze(!1), N = f?.(t) || !1, H = x?.(t) ? a : N ? s : l;
|
|
3195
3196
|
let X = H;
|
|
3196
3197
|
if (oe) {
|
|
3197
|
-
let
|
|
3198
|
-
typeof d == "function" && (
|
|
3198
|
+
let T = d;
|
|
3199
|
+
typeof d == "function" && (T = d(H)), X = Ct.mergeContentful(H, T);
|
|
3199
3200
|
}
|
|
3200
|
-
return
|
|
3201
|
-
|
|
3202
|
-
}, onMouseOut: (
|
|
3203
|
-
|
|
3201
|
+
return q("div", { ref: B, style: { background: X.fill, color: X.text?.fill, fontFamily: X.text?.fontFamily ?? l.text?.fontFamily, fontSize: 96 * (X.text?.fontSize ?? 11) / 72 * le, fontStyle: X.text?.fontStyle, fontWeight: X.text?.fontWeight, lineHeight: 1.2, display: "flex", justifyContent: "center", alignItems: "end", pointerEvents: "auto", paddingBottom: `${le}px`, ...C, left: C.left - (ae === Nt ? 1 : 0), top: C.top - (ae === an ? 1 : 0), width: C.width + 1, height: C.height + 1, overflow: "hidden" }, ...z, onMouseMove: (T) => {
|
|
3202
|
+
we.detectIt().primaryInput !== "touch" && T.buttons === 0 && ve(!0);
|
|
3203
|
+
}, onMouseOut: (T) => {
|
|
3204
|
+
ve(!1);
|
|
3204
3205
|
}, children: i(t) });
|
|
3205
3206
|
});
|
|
3206
3207
|
is.displayName = "HeaderRenderer";
|
|
3207
|
-
const Ti = "ew-resize", Ri = "ns-resize", ls =
|
|
3208
|
-
const { orientation: n, view: o, index: r, className: i, style: l, disabled: s = !1, disabledResize: a = !1, isNextHidden: d, isHidden: g, isSelected: m, isSelectedAll: f, showTouchDivider: x, headerStyle:
|
|
3209
|
-
let oe =
|
|
3210
|
-
m && I && (oe = I), f &&
|
|
3211
|
-
const
|
|
3212
|
-
let
|
|
3213
|
-
d && (X = -2), g && (X = 2), g && (
|
|
3214
|
-
let
|
|
3215
|
-
return !(m || f) && X === 0 && (
|
|
3216
|
-
})), ss = (e, t) =>
|
|
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:
|
|
3218
|
-
let
|
|
3219
|
-
|
|
3220
|
-
const
|
|
3221
|
-
if (ae?.(
|
|
3222
|
-
const
|
|
3223
|
-
|
|
3224
|
-
}
|
|
3225
|
-
|
|
3226
|
-
}, onPointerUp: (
|
|
3227
|
-
if (
|
|
3228
|
-
|
|
3229
|
-
const
|
|
3230
|
-
|
|
3231
|
-
}, onPointerMoveOrWait: (
|
|
3232
|
-
if (
|
|
3233
|
-
const
|
|
3234
|
-
|
|
3235
|
-
} }),
|
|
3236
|
-
|
|
3208
|
+
const Ti = "ew-resize", Ri = "ns-resize", ls = At(Ut((e, t) => {
|
|
3209
|
+
const { orientation: n, view: o, index: r, className: i, style: l, disabled: s = !1, disabledResize: a = !1, isNextHidden: d, isHidden: g, isSelected: m, isSelectedAll: f, showTouchDivider: x, headerStyle: _, headerStyleSelect: I, headerStyleSelectAll: R, headerStyleHover: ae, bounds: P, onPointerDown: C, onAutoFit: z, ...le } = e, B = n === Nt;
|
|
3210
|
+
let oe = _;
|
|
3211
|
+
m && I && (oe = I), f && R && (oe = R);
|
|
3212
|
+
const ve = we.detectIt().primaryInput === "touch";
|
|
3213
|
+
let N = B ? 14 : 8, H = N / 2, X = 0;
|
|
3214
|
+
d && (X = -2), g && (X = 2), g && (N = N / 2 + X, H = 2 * X);
|
|
3215
|
+
let T = oe.dividerStrokeFill ?? oe.strokeFill;
|
|
3216
|
+
return !(m || f) && X === 0 && (T = `linear-gradient(${B ? 180 : 90}deg, ${oe.fill}, ${T} 55%, ${T} 100%)`), Ht("div", { className: En("header-divider", { disabled: s }, i, `index-${r}`), ref: t, onPointerDown: ve ? void 0 : C, onDoubleClick: ve ? void 0 : () => z?.(), style: { top: (B ? 0 : -N / 2 + (X - 1)) + "px", left: (B ? -N / 2 + (X - 1) : 0) + "px", width: B ? N : "calc(100% + 1px)", height: B ? "calc(100% + 1px)" : N, position: "absolute", overflow: "visible", pointerEvents: "all", cursor: s || a || ve ? void 0 : B ? Ti : Ri, ...l }, ...le, children: [q("div", { style: { position: "relative", top: `${B ? 0 : H}px`, left: `${B ? H : 0}px`, width: B ? 1 : "100%", height: B ? "100%" : 1, background: T }, onDoubleClick: () => z?.() }), x && ve ? q("div", { style: { position: "absolute", cursor: "grab", zIndex: 1, borderRadius: "4px", right: B ? "-6px" : "2px", bottom: B ? "2px" : "-9px", height: "24px", width: B ? "24px" : "18px", maxHeight: B ? "calc(100% - 4px)" : void 0, maxWidth: B ? void 0 : "calc(100% - 4px)", background: oe.fill, border: `${R.edgeStrokeFill} solid 1px`, boxShadow: `0.5px 0.5px 0px 0px ${_.text.fill}`, display: "flex", alignItems: "center", justifyContent: "center" }, onPointerDown: C, children: q("div", { style: { width: "6.4px", height: "12px", backgroundImage: `url("data:image/svg+xml,%3Csvg width='6.4' height='12' viewBox='0 0 9.6 16' version='1.1' fill='${encodeURIComponent(I.text.fill)}' xmlns='http://www.w3.org/2000/svg' xmlns:svg='http://www.w3.org/2000/svg'%3E%3Cpath d='M 9.60008,14.40009 C 9.60008,15.28374 8.88368,16 8.00003,16 7.11639,16 6.40012,15.28374 6.40012,14.40009 c 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40012 c 0,0.88364 -0.7164,1.60004 -1.60005,1.60004 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60004 0,-0.88365 0.71627,-1.60005 1.59991,-1.60005 0.88365,0 1.60005,0.7164 1.60005,1.60005 m 0,-6.40006 c 0,0.88365 -0.7164,1.60005 -1.60005,1.60005 -0.88364,0 -1.59991,-0.7164 -1.59991,-1.60005 C 6.40012,0.71626 7.11639,0 8.00003,0 8.88368,0 9.60008,0.71626 9.60008,1.59991 M 3.19996,14.40009 C 3.19996,15.28374 2.48369,16 1.60005,16 0.7164,16 0,15.28374 0,14.40009 c 0,-0.88365 0.7164,-1.60005 1.60005,-1.60005 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40012 c 0,0.88364 -0.71627,1.60004 -1.59991,1.60004 C 0.7164,9.60001 0,8.88361 0,7.99997 0,7.11632 0.7164,6.39992 1.60005,6.39992 c 0.88364,0 1.59991,0.7164 1.59991,1.60005 m 0,-6.40006 c 0,0.88365 -0.71627,1.60005 -1.59991,1.60005 C 0.7164,3.19996 0,2.48356 0,1.59991 0,0.71626 0.7164,0 1.60005,0 2.48369,0 3.19996,0.71626 3.19996,1.59991' /%3E%3C/svg%3E%0A")`, backgroundRepeat: "no-repeat", backgroundPosition: "center", transform: B ? void 0 : "rotate(90deg)" } }) }) : null] });
|
|
3217
|
+
})), ss = (e, t) => q(ls, { ...e, ref: t }), vs = At(Ut((e, t) => {
|
|
3218
|
+
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: _, onPointerDown: I, ...R } = e, ae = k(I, [I]), P = k(_, [_]), C = n === Nt;
|
|
3219
|
+
let z = C ? o.getVisibleColumns() : o.getVisibleRows(), le = null;
|
|
3220
|
+
z.length > 0 && (C ? le = o.getRangeCoordsBounds({ rowStart: 0, rowEnd: 0, colStart: z[0], colEnd: z[z.length - 1] }) : o.getRangeCoordsBounds({ rowStart: z[0], rowEnd: z[z.length - 1], colStart: 0, colEnd: 0 }), le = o.toClipBounds(le, en));
|
|
3221
|
+
const B = Z(null), [oe, ve] = Ze(null), N = (L, U) => C ? L.clientX - U.clientX : L.clientY - U.clientY, H = o.getLayout(), X = C ? H.getColOffset(r + 1) : H.getRowOffset(r + 1), T = On({ processTouch: !0, onPointerDown: (L) => {
|
|
3222
|
+
if (ae?.(L), !i && !l) {
|
|
3223
|
+
const U = C ? H.getColOffset(r) : H.getRowOffset(r), ee = X - U;
|
|
3224
|
+
B.current = { isResizing: !1, startSize: ee, index: r, view: o, orientation: n, onDividerMouseDown: d, onDividerResizeStart: g, onDividerResize: m, onDividerResizeEnd: f, onDividerMouseUp: x }, ve(B.current), d?.(r, ee);
|
|
3225
|
+
}
|
|
3226
|
+
L.stopPropagation(), L.preventDefault();
|
|
3227
|
+
}, onPointerUp: (L, U, ee) => {
|
|
3228
|
+
if (!B.current) return;
|
|
3229
|
+
B.current.isResizing && B.current.onDividerResizeEnd?.(B.current.index, Math.max(0, B.current.startSize + N(L, ee)), B.current.startSize);
|
|
3230
|
+
const te = B.current;
|
|
3231
|
+
B.current = null, ve(B.current), te.onDividerMouseUp?.(te.index);
|
|
3232
|
+
}, onPointerMoveOrWait: (L, U, ee) => {
|
|
3233
|
+
if (!B.current) return;
|
|
3234
|
+
const te = N(L, ee);
|
|
3235
|
+
B.current.isResizing ? B.current.onDividerResize?.(B.current.index, Math.max(0, B.current.startSize + te), B.current.startSize) : Math.abs(te) > Math.max(1, s) && (B.current = { ...B.current, isResizing: !0 }, ve(B.current), B.current.onDividerResizeStart?.(B.current.index, Math.max(0, B.current.startSize + te))), L.stopPropagation(), L.preventDefault();
|
|
3236
|
+
} }), S = k(() => {
|
|
3237
|
+
P?.(r);
|
|
3237
3238
|
}, [r]);
|
|
3238
3239
|
if (!le) return;
|
|
3239
|
-
const
|
|
3240
|
-
if (!
|
|
3241
|
-
const { getPortalContainer:
|
|
3242
|
-
let
|
|
3243
|
-
return oe && oe.isResizing && oe.index === r && (
|
|
3240
|
+
const h = a({ bounds: le, orientation: n, view: o, index: r, disabled: i, disabledResize: l, onAutoFit: S, onPointerDown: T, ...R }, t);
|
|
3241
|
+
if (!h) return;
|
|
3242
|
+
const { getPortalContainer: J } = gi();
|
|
3243
|
+
let K = null;
|
|
3244
|
+
return oe && oe.isResizing && oe.index === r && (K = qr(q("div", { style: { position: "absolute", cursor: C ? Ti : Ri, left: 0, top: 0, width: "100%", height: "100%" } }), J(), "divider:" + r)), Ht(wn, { children: [K, q("div", { className: En("header-divider-anchor"), style: { position: "absolute", pointerEvents: "auto", top: `${C ? le.y : X}px`, left: `${C ? X : le.x}px`, width: (C ? 0 : le.width - 1) + "px", height: (C ? le.height - 1 : 0) + "px", display: "flex" }, tabIndex: -1, children: h })] });
|
|
3244
3245
|
}));
|
|
3245
3246
|
class cs {
|
|
3246
3247
|
naturalDimensions(t, n = {}) {
|
|
@@ -3260,92 +3261,92 @@ class cs {
|
|
|
3260
3261
|
return i.remove(), { width: s.width, height: s.height, maxLineHeight: 1.2 * (n.paintableText?.fontSize || 1056 / 72) };
|
|
3261
3262
|
}
|
|
3262
3263
|
}
|
|
3263
|
-
const as = (e = void 0) => Object.freeze({ clean: e, dirty: void 0, editMode: !1 }), ds = as(), ys =
|
|
3264
|
-
const { editState: n = ds, defaultTextStyle: o, onStartEdit: r, onChangeEdit: i, onSubmitEdit: l, onCancelEdit: s, onDoneEdit: a, containerBounds: d, setNaturalDimensions: g, onNavigate: m, textProperties: f, style: x, autoFocus:
|
|
3264
|
+
const as = (e = void 0) => Object.freeze({ clean: e, dirty: void 0, editMode: !1 }), ds = as(), ys = At(Ut((e, t) => {
|
|
3265
|
+
const { editState: n = ds, defaultTextStyle: o, onStartEdit: r, onChangeEdit: i, onSubmitEdit: l, onCancelEdit: s, onDoneEdit: a, containerBounds: d, setNaturalDimensions: g, onNavigate: m, textProperties: f, style: x, autoFocus: _, ...I } = e, R = Z(null), { width: ae = 0 } = d ?? {}, [P, C] = Ze(() => n);
|
|
3265
3266
|
st(() => {
|
|
3266
|
-
|
|
3267
|
+
C(n);
|
|
3267
3268
|
}, [n]);
|
|
3268
|
-
const
|
|
3269
|
-
let
|
|
3270
|
-
const
|
|
3271
|
-
le === "right" && (
|
|
3272
|
-
const
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
}, [d,
|
|
3276
|
-
g?.({ width: oe === "wrap" ? void 0 :
|
|
3277
|
-
}, [
|
|
3278
|
-
const
|
|
3279
|
-
if (
|
|
3280
|
-
const
|
|
3281
|
-
|
|
3282
|
-
}, [
|
|
3283
|
-
if (
|
|
3284
|
-
const
|
|
3285
|
-
|
|
3286
|
-
}, [
|
|
3269
|
+
const z = f?.align || "left", le = f?.vAlign || "middle", B = f?.fill || "#040404", oe = f?.wrap || "wrap", ve = f?.fontFamily || "Calibri", N = f?.fontSize || 11, H = f?.fontWeight || 400, X = f?.fontStyle || "normal", T = P.dirty ?? P.clean ?? "";
|
|
3270
|
+
let S = 2;
|
|
3271
|
+
const h = 96 * N / 72, J = 1.2 * h;
|
|
3272
|
+
le === "right" && (S += 1);
|
|
3273
|
+
const K = _e(() => new cs().naturalDimensions(T, { maxWidth: oe === "wrap" ? ae - S : void 0, lineHeight: `${J}px`, paintableText: { fontStyle: X, wrap: oe, letterSpacing: -0.25 } }), [T, oe, S, h, ve, H, X, g, ae]), L = D(() => K.maxLineHeight ? K.maxLineHeight + "px" : "1.2", [K]), [U, ee] = Ze(L);
|
|
3274
|
+
tn(() => {
|
|
3275
|
+
ee(L());
|
|
3276
|
+
}, [d, K]), tn(() => {
|
|
3277
|
+
g?.({ width: oe === "wrap" ? void 0 : K.width + S, height: K.height });
|
|
3278
|
+
}, [K, g]);
|
|
3279
|
+
const te = k(i, [i]), Y = k((E) => {
|
|
3280
|
+
if (P.dirty === E) return;
|
|
3281
|
+
const Me = { ...P };
|
|
3282
|
+
Me.dirty = E, R.current, C(Me), te?.(Me);
|
|
3283
|
+
}, [P]), He = k((E) => {
|
|
3284
|
+
if (P.editMode === E) return;
|
|
3285
|
+
const Me = { ...P };
|
|
3286
|
+
Me.editMode = E, C(Me), te?.(Me);
|
|
3287
|
+
}, [P]), je = k(() => {
|
|
3287
3288
|
try {
|
|
3288
|
-
return l?.(
|
|
3289
|
+
return l?.(P), a?.(), !0;
|
|
3289
3290
|
} catch {
|
|
3290
3291
|
return !1;
|
|
3291
3292
|
}
|
|
3292
|
-
}, [l,
|
|
3293
|
-
|
|
3294
|
-
}, [s, n]),
|
|
3295
|
-
if (!
|
|
3296
|
-
if (
|
|
3297
|
-
const
|
|
3298
|
-
return
|
|
3299
|
-
}
|
|
3300
|
-
const
|
|
3301
|
-
if (
|
|
3302
|
-
if (
|
|
3303
|
-
if (
|
|
3304
|
-
if (!
|
|
3305
|
-
let
|
|
3306
|
-
switch (
|
|
3293
|
+
}, [l, P]), Ne = k(() => {
|
|
3294
|
+
C(n), s?.(), a?.();
|
|
3295
|
+
}, [s, n]), at = k((E) => {
|
|
3296
|
+
if (!R.current) return;
|
|
3297
|
+
if (E.isDefaultPrevented(), !(E.isTrusted || E.nativeEvent.ctrlKey || E.nativeEvent.metaKey || E.nativeEvent.altKey || E.nativeEvent.isComposing) && vi.indexOf(E.nativeEvent.key) !== -1) {
|
|
3298
|
+
const ue = { ...P };
|
|
3299
|
+
return ue.dirty = E.nativeEvent.key === "Backspace" ? "" : (ue.dirty ?? "") + E.key, C(ue), te?.(ue), void E.preventDefault();
|
|
3300
|
+
}
|
|
3301
|
+
const Me = E.nativeEvent.shiftKey;
|
|
3302
|
+
if (E.which === Ji) return E.preventDefault(), void Ne();
|
|
3303
|
+
if (E.which === ol) return He(!0), void E.preventDefault();
|
|
3304
|
+
if (E.which === Zi && (E.preventDefault(), je() && m?.(Me ? it : lt)), E.which === Gi) return E.preventDefault(), void (je() && m?.(Me ? ot : Ke));
|
|
3305
|
+
if (!P.editMode) {
|
|
3306
|
+
let ue = null;
|
|
3307
|
+
switch (E.which) {
|
|
3307
3308
|
case Qi:
|
|
3308
|
-
|
|
3309
|
+
ue = ot;
|
|
3309
3310
|
break;
|
|
3310
3311
|
case tl:
|
|
3311
|
-
|
|
3312
|
+
ue = Ke;
|
|
3312
3313
|
break;
|
|
3313
3314
|
case el:
|
|
3314
|
-
|
|
3315
|
+
ue = it;
|
|
3315
3316
|
break;
|
|
3316
3317
|
case nl:
|
|
3317
|
-
|
|
3318
|
+
ue = lt;
|
|
3318
3319
|
}
|
|
3319
|
-
if (
|
|
3320
|
+
if (ue) return void je();
|
|
3320
3321
|
}
|
|
3321
|
-
}, [
|
|
3322
|
+
}, [P, m]), [Se, Ye] = Ze(!_);
|
|
3322
3323
|
st(() => {
|
|
3323
|
-
|
|
3324
|
+
Ye(!1);
|
|
3324
3325
|
}, []);
|
|
3325
|
-
const
|
|
3326
|
-
let
|
|
3327
|
-
if (!
|
|
3328
|
-
const
|
|
3329
|
-
|
|
3330
|
-
}
|
|
3331
|
-
|
|
3332
|
-
const
|
|
3333
|
-
|
|
3334
|
-
}, submitEdit: () =>
|
|
3335
|
-
|
|
3326
|
+
const $ = wo(t, () => ({ startEdit(E) {
|
|
3327
|
+
let Me = E?.initialSelection;
|
|
3328
|
+
if (!Me) {
|
|
3329
|
+
const me = R.current.value.length ?? 0;
|
|
3330
|
+
Me = { start: me, end: me, direction: "forward" };
|
|
3331
|
+
}
|
|
3332
|
+
R.current?.setSelectionRange(Me.start, Me.end, Me.direction);
|
|
3333
|
+
const ue = { ...n, editMode: E?.editMode ?? !1 };
|
|
3334
|
+
E?.text !== void 0 && (ue.dirty = E.text), ue.editMode === n.editMode && ue.dirty === n.dirty || (C(ue), te?.(ue));
|
|
3335
|
+
}, submitEdit: () => je(), cancelEdit() {
|
|
3336
|
+
Ne();
|
|
3336
3337
|
}, autoFocus() {
|
|
3337
|
-
|
|
3338
|
-
}, getLineHeight: () =>
|
|
3339
|
-
return
|
|
3340
|
-
|
|
3341
|
-
}, onDoubleClick: (
|
|
3342
|
-
|
|
3343
|
-
}, onMouseDown: (
|
|
3338
|
+
R.current?.focus();
|
|
3339
|
+
}, getLineHeight: () => K?.maxLineHeight ?? J, dispatchEvent: (E) => R.current.dispatchEvent(E) }), [n, r]);
|
|
3340
|
+
return q("div", { ref: $, ...I, style: { background: "transparent", display: "flex", flexGrow: 1, alignSelf: "center", height: K.height, maxWidth: "100%", maxHeight: "100%", ...x }, children: q("textarea", { spellCheck: "false", ref: R, value: T, autoFocus: !1, disabled: Se, name: "cell-editor", autoComplete: "off", autoCapitalize: "off", style: { flex: "1 1 100%", position: "relative", fontSize: `${h}px`, fontFamily: `${ve}`, fontWeight: `${H}`, fontStyle: `${X}`, padding: "0px", marginRight: z === "right" ? "3px" : "0px", marginLeft: z === "left" ? "2px" : "0px", lineHeight: U, height: K.height, textRendering: "geometricPrecision", letterSpacing: "-0.25px", boxSizing: "border-box", borderWidth: 0, outline: "none", resize: "none", overflow: "hidden", verticalAlign: "baseline", textAlign: z, background: "transparent", color: B, marginBottom: "0px", userSelect: "text", maxHeight: "100%", whiteSpace: oe === "wrap" ? "break-spaces" : "pre", wordWrap: "break-word" }, onChange: (E) => {
|
|
3341
|
+
Y(E.target.value);
|
|
3342
|
+
}, onDoubleClick: (E) => {
|
|
3343
|
+
E.isTrusted;
|
|
3344
|
+
}, onMouseDown: (E) => {
|
|
3344
3345
|
He(!0);
|
|
3345
|
-
}, onKeyDown:
|
|
3346
|
-
})), bs =
|
|
3346
|
+
}, onKeyDown: at }) });
|
|
3347
|
+
})), bs = At((e) => {
|
|
3347
3348
|
const { value: t, view: n, bounds: o, range: r, zoom: i, children: l, style: s, ...a } = e;
|
|
3348
|
-
return
|
|
3349
|
+
return q("div", { style: { padding: "2px 4px", fontFamily: "Calibri", letterSpacing: -0.25, lineHeight: 1.2, fontSize: s?.fontSize || 1056 / 72, ...s }, ...a, children: t });
|
|
3349
3350
|
});
|
|
3350
3351
|
export {
|
|
3351
3352
|
Ci as BaseGrid,
|
|
@@ -3357,7 +3358,7 @@ export {
|
|
|
3357
3358
|
vs as HeaderDivider,
|
|
3358
3359
|
is as HeaderRenderer,
|
|
3359
3360
|
xs as RESET_SCROLL_EVENTS_DEBOUNCE_INTERVAL,
|
|
3360
|
-
|
|
3361
|
+
en as SELECTION_CLIP_INSETS,
|
|
3361
3362
|
vi as STANDARD_KEY_CHARS,
|
|
3362
3363
|
jr as SVGLine,
|
|
3363
3364
|
Yl as SVGRect,
|