@sheetxl/grid-react 0.1.98
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 -0
- package/README.md +9 -0
- package/build/browser/cjs/index.cjs +24 -0
- package/build/browser/esm/index.mjs +3386 -0
- package/build/licenses/dependencies.txt +143 -0
- package/build/node/assets/style.css +1 -0
- package/build/node/esm/index.mjs +3311 -0
- package/build/package.json +48 -0
- package/build/types/index.d.ts +1487 -0
- package/package.json +63 -0
|
@@ -0,0 +1,3386 @@
|
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._sheetxl-grid_11irg_13{position:relative;box-sizing:border-box;user-select:none}._sheetxl-grid_11irg_13 *{box-sizing:border-box!important}._sheetxl-grid_11irg_13 *:focus{outline:none}._sheetxl-grid_11irg_13 .cell-container{position:absolute;overflow:visible;white-space:pre}._sheetxl-grid_11irg_13 .cell-container>*{inset:0;position:absolute}._sheetxl-grid_11irg_13 .sheetxl-stage{contain:strict}._sheetxl-grid_11irg_13 .sheetxl-stage>*{contain:strict}")),document.head.appendChild(e)}}catch(i){console.error("vite-plugin-css-injected-by-js",i)}})();
|
|
2
|
+
import { jsx as Y, jsxs as Ht, Fragment as wn } from "react/jsx-runtime";
|
|
3
|
+
import Sn, { memo as Dt, useCallback as O, useRef as J, useEffect as st, useImperativeHandle as Ur, forwardRef as Ut, useMemo as Ee, useLayoutEffect as nn, useState as Je, version as qr, createElement as Jo, useReducer as Qo } from "react";
|
|
4
|
+
import { createRoot as Oi } from "react-dom/client";
|
|
5
|
+
import { unstable_batchedUpdates as Li, createPortal as Kr } from "react-dom";
|
|
6
|
+
/**
|
|
7
|
+
* @license @sheetxl/grid-react - Grid - Advanced data grid component for React - v0.0.0
|
|
8
|
+
*
|
|
9
|
+
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
10
|
+
* License: The license can be found at https://www.sheetxl.com/license.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* @license @sheetxl/utils - Utils - Utilities used by most SheetXL components. - v0.1.93
|
|
14
|
+
*
|
|
15
|
+
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
16
|
+
* License: The license can be found at https://www.sheetxl.com/license.
|
|
17
|
+
*/
|
|
18
|
+
const it = "up", lt = "down", ot = "left", Ke = "right", uo = "tl", Hn = "t", Nn = "l", Xt = "c", Bt = "text/html", fn = "text/plain", Mo = "image/png", Di = Object.freeze({ left: 0, top: 0 }), zi = Object.freeze({ left: 0, top: 0, bottom: 0, right: 0 }), Ai = Object.freeze({ x: 0, y: 0, width: 0, height: 0 });
|
|
19
|
+
Object.freeze(Object.defineProperty({ __proto__: null, EmptyBounds: Ai, EmptyRect: zi, EmptyTopLeft: Di }, Symbol.toStringTag, { value: "Module" }));
|
|
20
|
+
const Nt = "column", cn = "row", $i = Object.freeze({ colIndex: 0, rowIndex: 0 }), Bi = Object.freeze({ colStart: 0, rowStart: 0, colEnd: 0, rowEnd: 0 }), Yr = (e, t) => e.colStart === t.colStart ? e.rowStart - t.rowStart : e.colStart - t.colStart, Xr = (e, t) => e.rowStart === t.rowStart ? e.colStart - t.colStart : e.rowStart - t.rowStart, Fi = (e, t) => e.rowEnd === t.rowEnd ? t.colEnd - e.colEnd : t.rowEnd - e.rowEnd, ji = (e, t) => e.colEnd === t.colEnd ? t.rowEnd - e.rowEnd : t.colEnd - e.colEnd, or = (e, t) => e.colIndex === t.colIndex ? e.rowIndex - t.rowIndex : e.colIndex - t.colIndex, rr = (e, t) => e.rowIndex === t.rowIndex ? e.colIndex - t.colIndex : e.rowIndex - t.rowIndex, Gr = (e = cn, t = !1) => t ? e !== Nt ? Fi : ji : e !== Nt ? Xr : Yr, ir = (e, t) => e === t || !(!e || !t) && e.rowIndex === t.rowIndex && e.colIndex === t.colIndex, jo = (e, t) => e === t || !(!e || !t) && e.rowStart === t.rowStart && e.rowEnd === t.rowEnd && e.colStart === t.colStart && e.colEnd === t.colEnd, Vo = (e, t) => !(!e || !t || e.colStart > t.colEnd || t.colStart > e.colEnd || e.rowStart > t.rowEnd || t.rowStart > e.rowEnd), lr = (e, t) => {
|
|
21
|
+
if (e === t) return !0;
|
|
22
|
+
if (!e || !t || e.length !== t.length) return !1;
|
|
23
|
+
for (let n = 0; n < e.length; n++) if (!jo(e[n], t[n])) return !1;
|
|
24
|
+
return !0;
|
|
25
|
+
}, To = (e, t, n) => {
|
|
26
|
+
if (!e && !t) return null;
|
|
27
|
+
if (!e) return n ? t : { ...t };
|
|
28
|
+
if (!t) return n ? e : { ...e };
|
|
29
|
+
const o = Math.min(e.colStart, t.colStart), r = Math.min(e.rowStart, t.rowStart), i = Math.max(e.colEnd, t.colEnd), l = Math.max(e.rowEnd, t.rowEnd);
|
|
30
|
+
let s = n;
|
|
31
|
+
return s ? (s.colStart = o, s.rowStart = r, s.colEnd = i, s.rowEnd = l) : s = { colStart: o, rowStart: r, colEnd: i, rowEnd: l }, s;
|
|
32
|
+
}, sr = (e, t) => {
|
|
33
|
+
if (!t || t.length === 0) return e;
|
|
34
|
+
const n = { ...e };
|
|
35
|
+
for (let o = 0; o < t.length; o++) {
|
|
36
|
+
const r = t[o];
|
|
37
|
+
Vo(n, r) && (n.rowStart = Math.min(n.rowStart, r.rowStart), n.colStart = Math.min(n.colStart, r.colStart), n.rowEnd = Math.max(n.rowEnd, r.rowEnd), n.colEnd = Math.max(n.colEnd, r.colEnd));
|
|
38
|
+
}
|
|
39
|
+
return n;
|
|
40
|
+
}, Vi = [null, null], Wi = (e, t, n) => {
|
|
41
|
+
if (e[0].value === e[1].value) return t;
|
|
42
|
+
};
|
|
43
|
+
function cr(e, t = 2, n, o = cn, r) {
|
|
44
|
+
let i = [...e];
|
|
45
|
+
if (t <= 0 || e.length <= 1) return i;
|
|
46
|
+
let l = o === Nt, s = 0, a = !1;
|
|
47
|
+
do {
|
|
48
|
+
const d = i.sort(Gr(l ? cn : Nt));
|
|
49
|
+
i = [], i.push(d[0]);
|
|
50
|
+
const g = d.length;
|
|
51
|
+
let m = 0, f = d[0], x = f.colStart, E = f.rowStart, I = f.colEnd, M = f.rowEnd;
|
|
52
|
+
for (let ae = 1; ae < g; ae++) {
|
|
53
|
+
const R = d[ae];
|
|
54
|
+
let _ = !1;
|
|
55
|
+
if (_ = l ? f && E === R.rowStart && M === R.rowEnd && I + 1 === R.colStart : f && x === R.colStart && I === R.colEnd && M + 1 === R.rowStart, _) {
|
|
56
|
+
let L = { colStart: x, rowStart: E, colEnd: l ? R.colEnd : I, rowEnd: l ? M : R.rowEnd };
|
|
57
|
+
if (f.value !== void 0 && (L.value = f.value), n) {
|
|
58
|
+
const le = r ?? [null, null];
|
|
59
|
+
le[0] = f, le[1] = R, L = n(le, L, o);
|
|
60
|
+
}
|
|
61
|
+
if (L) {
|
|
62
|
+
i[m] = L, a = !0, f = L, x = f.colStart, E = f.rowStart, I = f.colEnd, M = f.rowEnd;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
i[++m] = R, f = R, x = f.colStart, E = f.rowStart, I = f.colEnd, M = f.rowEnd;
|
|
67
|
+
}
|
|
68
|
+
s++, l = !l, s === 1 && (a = !0);
|
|
69
|
+
} while (s < t && a && i.length > 1);
|
|
70
|
+
return i;
|
|
71
|
+
}
|
|
72
|
+
const Z = Object.freeze(Object.defineProperty({ __proto__: null, EmptyCell: $i, EmptyRange: Bi, cellToRange: (e, t) => {
|
|
73
|
+
if (!e) return null;
|
|
74
|
+
let n = t;
|
|
75
|
+
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;
|
|
76
|
+
}, columnFirstCellComparator: or, columnFirstRangeComparator: Yr, createCellComparator: (e = cn, 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) => {
|
|
77
|
+
const n = [];
|
|
78
|
+
let o, r, i = Number.MIN_SAFE_INTEGER, l = Number.MIN_SAFE_INTEGER;
|
|
79
|
+
return { append: (s, a, d) => {
|
|
80
|
+
let g = !0;
|
|
81
|
+
const m = d !== void 0;
|
|
82
|
+
if (m) {
|
|
83
|
+
const E = e ? e(r, d, t) : r === d ? d : void 0;
|
|
84
|
+
E === void 0 ? g = !1 : d = E;
|
|
85
|
+
}
|
|
86
|
+
if (g && a === l + 1 && s === i) return t ? o.rowEnd = a : o.colEnd = a, l = a, void (r = d);
|
|
87
|
+
o && n.push(o);
|
|
88
|
+
const f = t ? s : a, x = t ? a : s;
|
|
89
|
+
o = { colStart: f, rowStart: x, colEnd: f, rowEnd: x }, m && (o.value = d), i = s, l = a, r = d;
|
|
90
|
+
}, done: (s) => (o && (n.push(o), o = null), s ? cr(n, 3, s === !0 ? Wi : s, t ? Nt : cn, Vi) : n) };
|
|
91
|
+
}, 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) => {
|
|
92
|
+
if (!t || t.length === 0) return e;
|
|
93
|
+
let n = e, o = null;
|
|
94
|
+
for (; !jo(n, o); ) o = n, n = sr(o, t);
|
|
95
|
+
return n;
|
|
96
|
+
}, indexOfCoords: (e, t) => {
|
|
97
|
+
const n = { colStart: e.colIndex, rowStart: e.rowIndex, colEnd: e.colIndex, rowEnd: e.rowIndex };
|
|
98
|
+
for (let o = t.length - 1; o >= 0; o--) if (Vo(n, t[o])) return o;
|
|
99
|
+
return -1;
|
|
100
|
+
}, intersectRanges: (e, t, n) => {
|
|
101
|
+
if (!e) return n ? t : { ...t };
|
|
102
|
+
if (!t) return n ? e : { ...e };
|
|
103
|
+
if (!e && !t || e.rowStart > t.rowEnd || e.rowEnd < t.rowStart || e.colStart > t.colEnd || e.colEnd < t.colStart) return null;
|
|
104
|
+
const o = Math.max(e.colStart, t.colStart), r = Math.max(e.rowStart, t.rowStart), i = Math.min(e.colEnd, t.colEnd), l = Math.min(e.rowEnd, t.rowEnd);
|
|
105
|
+
let s = n;
|
|
106
|
+
return s ? (s.colStart = o, s.rowStart = r, s.colEnd = i, s.rowEnd = l) : s = { colStart: o, rowStart: r, colEnd: i, rowEnd: l }, s;
|
|
107
|
+
}, isCellWithinRange: (e, t) => !(!e || !t || e.rowIndex < t.rowStart || e.rowIndex > t.rowEnd || e.colIndex < t.colStart || e.colIndex > t.colEnd), isEqualCells: ir, isEqualRanges: jo, isEqualRangesArrays: lr, isEqualSelectionCoords: (e, t) => e === t || !(!e || !t) && e.rangeIndex === t.rangeIndex && !!ir(e.cell, t.cell) && lr(e.ranges, t.ranges), isRangeWithinRange: (e, t) => !(e.rowStart < t.rowStart || e.rowEnd > t.rowEnd || e.colStart < t.colStart || e.colEnd > t.colEnd), isRangesIntersect: Vo, isSingleCell: (e) => !!e && e.rowEnd === e.rowStart && e.colStart === e.colEnd, isValidRange: (e) => !(!e || typeof e.colStart != "number" || e.colStart < 0 || typeof e.colEnd != "number" || e.colEnd < e.colStart || typeof e.rowStart != "number" || e.rowStart < 0 || typeof e.rowEnd != "number" || e.rowEnd < e.rowStart), mergeRangedValues: cr, rowFirstCellComparator: rr, rowFirstRangeComparator: Xr, sanitizeRange: (e) => e ? { colStart: e.colIndex ?? e.colStart ?? 0, rowStart: e.rowIndex ?? e.rowStart ?? 0, colEnd: e.colIndex ?? e.colEnd ?? 0, rowEnd: e.rowIndex ?? e.rowEnd ?? 0 } : null, translateRange: (e, t = -e.rowStart, n = -e.colStart, o) => o ? (o.colStart = e.colStart + n, o.rowStart = e.rowStart + t, o.colEnd = e.colEnd + n, o.rowEnd = e.rowEnd + t, o) : { colStart: e.colStart + n, rowStart: e.rowStart + t, colEnd: e.colEnd + n, rowEnd: e.rowEnd + t }, unionRanges: To, unionRangesArrays: (e, t, n) => {
|
|
108
|
+
if (!e || e.length === 0) return null;
|
|
109
|
+
if (e.length === 1 && !t) return e[0];
|
|
110
|
+
let o = e[0];
|
|
111
|
+
for (let r = 1; r < e.length; r++) o = To(o, e[r], n);
|
|
112
|
+
return t && (o = To(o, t, n)), o;
|
|
113
|
+
} }, Symbol.toStringTag, { value: "Module" })), Hi = typeof Symbol == "function" && Symbol.for ? Symbol.for("react.element") : 60103;
|
|
114
|
+
function Ni(e) {
|
|
115
|
+
return /* @__PURE__ */ function(t) {
|
|
116
|
+
return !!t && typeof t == "object";
|
|
117
|
+
}(e) && !function(t) {
|
|
118
|
+
const n = Object.prototype.toString.call(t);
|
|
119
|
+
return n === "[object RegExp]" || n === "[object Date]" || t.$$typeof === Hi;
|
|
120
|
+
}(e);
|
|
121
|
+
}
|
|
122
|
+
function Vn(e, t) {
|
|
123
|
+
return t.clone !== !1 && t.isMergeableObject(e) ? _n((n = e, Array.isArray(n) ? [] : {}), e, t) : e;
|
|
124
|
+
var n;
|
|
125
|
+
}
|
|
126
|
+
function Ui(e, t, n) {
|
|
127
|
+
return e.concat(t).map(function(o) {
|
|
128
|
+
return Vn(o, n);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function ar(e) {
|
|
132
|
+
return Object.keys(e).concat((t = e, Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(t).filter(function(n) {
|
|
133
|
+
return Object.propertyIsEnumerable.call(t, n);
|
|
134
|
+
}) : []));
|
|
135
|
+
var t;
|
|
136
|
+
}
|
|
137
|
+
function dr(e, t) {
|
|
138
|
+
try {
|
|
139
|
+
return t in e;
|
|
140
|
+
} catch {
|
|
141
|
+
return !1;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function _n(e, t, n) {
|
|
145
|
+
(n = n || {}).arrayMerge = n.arrayMerge || Ui, n.isMergeableObject = n.isMergeableObject || Ni, n.cloneUnlessOtherwiseSpecified = Vn;
|
|
146
|
+
const o = Array.isArray(t);
|
|
147
|
+
return o === Array.isArray(e) ? o ? n.arrayMerge(e, t, n) : function(r, i, l) {
|
|
148
|
+
const s = {};
|
|
149
|
+
return l.isMergeableObject(r) && ar(r).forEach(function(a) {
|
|
150
|
+
s[a] = Vn(r[a], l);
|
|
151
|
+
}), ar(i).forEach(function(a) {
|
|
152
|
+
var d, g;
|
|
153
|
+
dr(d = r, g = a) && (!Object.hasOwnProperty.call(d, g) || !Object.propertyIsEnumerable.call(d, g)) || (dr(r, a) && l.isMergeableObject(i[a]) ? s[a] = function(m, f) {
|
|
154
|
+
if (!f.customMerge) return _n;
|
|
155
|
+
const x = f.customMerge(m);
|
|
156
|
+
return typeof x == "function" ? x : _n;
|
|
157
|
+
}(a, l)(r[a], i[a], l) : s[a] = Vn(i[a], l));
|
|
158
|
+
}), s;
|
|
159
|
+
}(e, t, n) : Vn(t, n);
|
|
160
|
+
}
|
|
161
|
+
_n.all = function(e, t) {
|
|
162
|
+
if (!Array.isArray(e)) throw new Error("first argument should be an array");
|
|
163
|
+
return e.reduce(function(n, o) {
|
|
164
|
+
return _n(n, o, t);
|
|
165
|
+
}, {});
|
|
166
|
+
};
|
|
167
|
+
const qi = Object.freeze([]), Ki = Object.freeze({}), ur = (e) => e, so = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(e) {
|
|
168
|
+
let t = 16 * Math.random() | 0;
|
|
169
|
+
return (e === "x" ? t : 3 & t | 8).toString(16);
|
|
170
|
+
}), 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) {
|
|
171
|
+
e[t] && typeof e[t] == "object" ? Jr(e[t]) : e[t] !== null && e[t] !== void 0 || delete e[t], typeof e[t] == "object" && Object.keys(e[t]).length === 0 && delete e[t];
|
|
172
|
+
}), Object.keys(e).length === 0 ? null : e), Yi = (e, t) => !(e !== t && !Zr(e, t) && !e.isEqual?.(t)), Qr = (e, t, n = Yi) => {
|
|
173
|
+
if (e == null || e === t) return null;
|
|
174
|
+
if (!e || typeof e != "object" || Array.isArray(e) || e.isImmutable?.()) return n(e, t) ? null : e;
|
|
175
|
+
const o = Object.keys(e);
|
|
176
|
+
if (o.length === 0) return null;
|
|
177
|
+
let r = !1;
|
|
178
|
+
for (let i = 0; i < o.length; i++) {
|
|
179
|
+
const l = o[i];
|
|
180
|
+
Qr(e[l], t?.[l], n) === null && (r = !0, delete e[l]);
|
|
181
|
+
}
|
|
182
|
+
return r && Object.keys(e).length === 0 ? null : void 0;
|
|
183
|
+
}, 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), Ft = { Windows: "windows", MacOS: "macos", IOS: "ios", Linux: "linux", Android: "android", Safari: "safari", Firefox: "firefox", Node: "node", Unknown: "unknown" }, Un = () => {
|
|
184
|
+
if (ei()) return Ft.Node;
|
|
185
|
+
const e = globalThis.navigator !== void 0 && globalThis.navigator.userAgent ? globalThis.navigator.userAgent.toLowerCase() : "";
|
|
186
|
+
return e ? /(win32|win64|windows|wince)/i.test(e) ? Ft.Windows : /(macintosh|macintel|macppc|mac68k|macos)/i.test(e) ? Ft.MacOS : /(iphone|ipad|ipod)/i.test(e) ? Ft.IOS : /android/.test(e) ? Ft.Android : /linux/.test(e) ? Ft.Linux : /^((?!chrome|android|).)*safari/i.test(e) ? Ft.Safari : /^((?!chrome|android|Seamonkey).)*firefox/i.test(e) ? Ft.Firefox : Ft.Unknown : Ft.Unknown;
|
|
187
|
+
};
|
|
188
|
+
function ei() {
|
|
189
|
+
return typeof process < "u" && process.release?.name === "node" || (typeof process < "u" && process.browser, !1);
|
|
190
|
+
}
|
|
191
|
+
const wr = (e, t = !1) => (document.hasFocus() || t) && (e === document.activeElement || e?.contains(document.activeElement)), Ct = Object.freeze(Object.defineProperty({ __proto__: null, EmptyArray: qi, EmptyObject: Ki, OSType: Ft, arrayMove: function(e, t, n) {
|
|
192
|
+
const o = e.slice();
|
|
193
|
+
return o.splice(n < 0 ? o.length + n : n, 0, o.splice(t, 1)[0]), o;
|
|
194
|
+
}, asNumber: (e) => {
|
|
195
|
+
const t = ((n) => 1 * n)(e);
|
|
196
|
+
return Number.isFinite(t) ? t : 0;
|
|
197
|
+
}, camelToPrettyCase: (e) => e.length === 1 ? e.toUpperCase() : e.replace(/([A-Z])/g, " $1").replace(/^./, function(t) {
|
|
198
|
+
return t.toUpperCase();
|
|
199
|
+
}).trim(), canUseDOM: gr, cancelTimeout: (e) => {
|
|
200
|
+
cancelAnimationFrame(e.id);
|
|
201
|
+
}, castToString: (e) => e == null || e === void 0 ? "" : typeof e != "string" ? "" + e : e, cloneObject: (e) => fr(e) ? e : JSON.parse(JSON.stringify(e)), consoleWithNoSource: (...e) => new Promise((t) => {
|
|
202
|
+
setTimeout(() => {
|
|
203
|
+
Function("console.log.apply(console, arguments)").apply(null, e), t();
|
|
204
|
+
});
|
|
205
|
+
}), debounce: function(e, t = 300, n = !1) {
|
|
206
|
+
let o, r, i, l, s = 0;
|
|
207
|
+
function a() {
|
|
208
|
+
let g = Date.now() - s;
|
|
209
|
+
g < t && g >= 0 ? o = setTimeout(a, t - g) : (o = null, n || (l = e.apply(i, r), i = r = null));
|
|
210
|
+
}
|
|
211
|
+
t == null && (t = 100);
|
|
212
|
+
const d = function() {
|
|
213
|
+
i = globalThis, r = arguments, s = Date.now();
|
|
214
|
+
var g = n && !o;
|
|
215
|
+
return o || (o = setTimeout(a, t)), g && (l = e.apply(i, r), i = r = null), l;
|
|
216
|
+
};
|
|
217
|
+
return d.clear = function() {
|
|
218
|
+
o && (clearTimeout(o), o = null);
|
|
219
|
+
}, d.flush = function() {
|
|
220
|
+
o && (l = e.apply(i, r), i = r = null, clearTimeout(o), o = null);
|
|
221
|
+
}, d;
|
|
222
|
+
}, deepEqual: function e(t, n) {
|
|
223
|
+
if (t === n) return !0;
|
|
224
|
+
if (t && n && typeof t == "object" && typeof n == "object") {
|
|
225
|
+
if (t.constructor !== n.constructor) return !1;
|
|
226
|
+
let o, r, i;
|
|
227
|
+
if (Array.isArray(t)) {
|
|
228
|
+
if (o = t.length, o != n.length) return !1;
|
|
229
|
+
for (r = o; r-- !== 0; ) if (!e(t[r], n[r])) return !1;
|
|
230
|
+
return !0;
|
|
231
|
+
}
|
|
232
|
+
if (t instanceof Map && n instanceof Map) {
|
|
233
|
+
if (t.size !== n.size) return !1;
|
|
234
|
+
for (r of t.entries()) if (!n.has(r[0])) return !1;
|
|
235
|
+
for (r of t.entries()) if (!e(r[1], n.get(r[0]))) return !1;
|
|
236
|
+
return !0;
|
|
237
|
+
}
|
|
238
|
+
if (t instanceof Set && n instanceof Set) {
|
|
239
|
+
if (t.size !== n.size) return !1;
|
|
240
|
+
for (r of t.entries()) if (!n.has(r[0])) return !1;
|
|
241
|
+
return !0;
|
|
242
|
+
}
|
|
243
|
+
if (ArrayBuffer.isView(t) && ArrayBuffer.isView(n)) {
|
|
244
|
+
if (o = t.length, o != n.length) return !1;
|
|
245
|
+
for (r = o; r-- !== 0; ) if (t[r] !== n[r]) return !1;
|
|
246
|
+
return !0;
|
|
247
|
+
}
|
|
248
|
+
if (t.constructor === RegExp) return t.source === n.source && t.flags === n.flags;
|
|
249
|
+
if (t.valueOf !== Object.prototype.valueOf) return t.valueOf() === n.valueOf();
|
|
250
|
+
if (t.toString !== Object.prototype.toString) return t.toString() === n.toString();
|
|
251
|
+
if (i = Object.keys(t), o = i.length, o !== Object.keys(n).length) return !1;
|
|
252
|
+
for (r = o; r-- !== 0; ) if (!Object.prototype.hasOwnProperty.call(n, i[r])) return !1;
|
|
253
|
+
for (r = o; r-- !== 0; ) {
|
|
254
|
+
let l = i[r];
|
|
255
|
+
if (!(l === "_owner" && t.$$typeof || e(t[l], n[l]))) return !1;
|
|
256
|
+
}
|
|
257
|
+
return !0;
|
|
258
|
+
}
|
|
259
|
+
return t != t && n != n;
|
|
260
|
+
}, deepFreeze: function e(t) {
|
|
261
|
+
return Object.freeze(t), Object.keys(t).forEach((n) => {
|
|
262
|
+
typeof t[n] != "object" || t[n] === null || Object.isFrozen(t[n]) || e(t[n]);
|
|
263
|
+
}), t;
|
|
264
|
+
}, deepMerge: _n, diffValues: (e, t) => {
|
|
265
|
+
const n = {}, o = Object.keys(t), r = o.length;
|
|
266
|
+
for (let i = 0; i < r; i++) {
|
|
267
|
+
const l = o[i];
|
|
268
|
+
e[l] !== t[l] && (e[l] === void 0 ? n[l] = t[l] : n[l] = e[l]);
|
|
269
|
+
}
|
|
270
|
+
return Object.keys(n).length === 0 ? null : n;
|
|
271
|
+
}, findEqualOrGreater: function(e, t, n = ur) {
|
|
272
|
+
let o = 0, r = e.length - 1;
|
|
273
|
+
for (; o <= r; ) {
|
|
274
|
+
let i = Math.floor((o + r) / 2), l = n(e[i]);
|
|
275
|
+
if (l === t) return i;
|
|
276
|
+
l < t ? o = i + 1 : r = i - 1;
|
|
277
|
+
}
|
|
278
|
+
return o;
|
|
279
|
+
}, findEqualOrLesser: function(e, t, n = ur) {
|
|
280
|
+
let o = e.length - 1, r = 0;
|
|
281
|
+
for (; o >= r; ) {
|
|
282
|
+
let i = Math.floor((o + r) / 2), l = n(e[i]);
|
|
283
|
+
if (l === t) return i;
|
|
284
|
+
l > t ? o = i - 1 : r = i + 1;
|
|
285
|
+
}
|
|
286
|
+
return o;
|
|
287
|
+
}, findNextStep: (e, t = !0, n = 15, o = 10, r = 400) => {
|
|
288
|
+
const i = Math.max(e - o, 0) + (t ? 1 : -1);
|
|
289
|
+
return Math.min(r, Math[t ? "ceil" : "floor"](i / n) * n + o);
|
|
290
|
+
}, getBuildEnv: () => "browser2-build", getDPI: () => {
|
|
291
|
+
let e = 1;
|
|
292
|
+
return typeof window == "object" && (e = window.devicePixelRatio || 1), e;
|
|
293
|
+
}, getFromPath: (e, t) => {
|
|
294
|
+
const n = t.split(".");
|
|
295
|
+
let o = e;
|
|
296
|
+
for (let r = 0; r < n.length; r++) {
|
|
297
|
+
const i = n[r];
|
|
298
|
+
if (!o) return null;
|
|
299
|
+
let l = o[i];
|
|
300
|
+
if (typeof l == "function" && (l = l.bind(o)()), !l || !Fn(l)) return l;
|
|
301
|
+
o = l;
|
|
302
|
+
}
|
|
303
|
+
return o ?? null;
|
|
304
|
+
}, getOS: Un, hasFocus: wr, isDefined: (e) => e != null, isEmpty: (e) => e == null || e === "", isEqualArrays: Zr, isEqualBounds: (e, t) => e === t || !(e && !t || t && !e) && e.x === t.x && e.y === t.y && e.width === t.width && e.height === t.height, isEqualObjectKeys: (e, t) => {
|
|
305
|
+
if (e === t) return !0;
|
|
306
|
+
if (e && !t || t && !e) return !1;
|
|
307
|
+
const n = Object.keys(e);
|
|
308
|
+
if (n.length !== Object.keys(t).length) return !1;
|
|
309
|
+
for (let o = 0; o < n.length; o++) if (e[n[o]] !== t[n[o]]) return !1;
|
|
310
|
+
return !0;
|
|
311
|
+
}, isNode: ei, isNullOrUndefined: fr, isNumeric: (e) => {
|
|
312
|
+
const t = 1 * e;
|
|
313
|
+
return Number.isFinite(t) && typeof t == "number";
|
|
314
|
+
}, isObject: Fn, isPromiseLike: (e) => !!e && typeof e.then == "function", isRectInsideRect: (e, t) => e.top >= t.top && e.bottom <= t.bottom && e.left >= t.left && e.right <= t.right, isRectIntersect: pr, mergeContentful: (...e) => {
|
|
315
|
+
const t = e.length;
|
|
316
|
+
if (t > 0 && e[t - 1] !== void 0 && !Fn(e[t - 1])) return e[t - 1];
|
|
317
|
+
let n = e[0] || {};
|
|
318
|
+
for (let o = 1; o < t; o++) n = _n(n, e[o] || {}, { arrayMerge: (r, i) => [...i] });
|
|
319
|
+
return n;
|
|
320
|
+
}, nextTick: (e) => {
|
|
321
|
+
typeof window < "u" && typeof window.requestAnimationFrame == "function" ? window.requestAnimationFrame(() => {
|
|
322
|
+
e();
|
|
323
|
+
}) : (typeof setImmediate == "function" ? setImmediate : setTimeout)(() => {
|
|
324
|
+
e();
|
|
325
|
+
});
|
|
326
|
+
}, openFileDialog: (e = "*.*") => new Promise((t, n) => {
|
|
327
|
+
if (!gr) return void n("Unable to open dialog with no dom.");
|
|
328
|
+
const o = document.createElement("input");
|
|
329
|
+
o.type = "file", o.accept = e;
|
|
330
|
+
let r = null, i = !1;
|
|
331
|
+
globalThis.addEventListener?.("focus", () => {
|
|
332
|
+
setTimeout(() => {
|
|
333
|
+
r || i || (i = !0, t(null));
|
|
334
|
+
}, 1e3);
|
|
335
|
+
}, { once: !0, passive: !0 }), o.onchange = () => {
|
|
336
|
+
if (r = o.files[0], r) {
|
|
337
|
+
if (i) return void console.warn("File open detected after faux cancel.", r);
|
|
338
|
+
t(r);
|
|
339
|
+
}
|
|
340
|
+
}, o.autofocus = !0, o.click();
|
|
341
|
+
}), rafThrottle: (e) => {
|
|
342
|
+
let t, n = !1, o = function() {
|
|
343
|
+
n = !1, e(t);
|
|
344
|
+
};
|
|
345
|
+
return function(r) {
|
|
346
|
+
t = r, t && t.persist && t.persist(), n || (n = !0, requestAnimationFrame(o));
|
|
347
|
+
};
|
|
348
|
+
}, removeEmptyProperties: Jr, removeEqualValues: Qr, removeListenerAll: (e) => {
|
|
349
|
+
if (!e) return [];
|
|
350
|
+
for (let t = 0; t < e.length; t++) e[t] && e[t]();
|
|
351
|
+
return [];
|
|
352
|
+
}, requestTimeout: (e, t) => {
|
|
353
|
+
const n = hr(), o = { id: requestAnimationFrame(function r() {
|
|
354
|
+
hr() - n >= t ? e.call(null) : o.id = requestAnimationFrame(r);
|
|
355
|
+
}) };
|
|
356
|
+
return o;
|
|
357
|
+
}, roundAccurately: (e, t = 0) => {
|
|
358
|
+
if (e == null || !isFinite(e)) return null;
|
|
359
|
+
const n = 10 ** t;
|
|
360
|
+
return Number(Math.round(e * n) / n);
|
|
361
|
+
}, setToPath: (e, t, n) => {
|
|
362
|
+
const o = t.split(".");
|
|
363
|
+
let r = e;
|
|
364
|
+
if (!r) throw new Error("Can not set path to a null path.");
|
|
365
|
+
for (let i = 0; r && i < o.length - 1; i++) {
|
|
366
|
+
const l = o[i];
|
|
367
|
+
let s = r[l];
|
|
368
|
+
if (s == null && (s = {}, r[l] = s), !Fn(s)) throw new Error("Can not set path to a non object path.");
|
|
369
|
+
r = s;
|
|
370
|
+
}
|
|
371
|
+
if (typeof n != "number" && typeof n != "boolean" && typeof n != "string" && !Fn(n)) throw new Error(`Can not set path to ${n} that is not a a supported primitive.`);
|
|
372
|
+
return r[o[o.length - 1]] = n, e;
|
|
373
|
+
}, splitNumber: (e) => {
|
|
374
|
+
let t = Math.abs(e);
|
|
375
|
+
if (isNaN(t) || !isFinite(e)) return null;
|
|
376
|
+
let n = 0 | t, o = t - n, r = 0, i = 0, l = 1;
|
|
377
|
+
if (o > 5e-8) for (; i < 8 && Math.abs(r / l - o) > 5e-8; ) i++, l *= 10, r = Math.round(o * l);
|
|
378
|
+
return { ip: Math.trunc(e), fp: r, ipLength: Math.ceil(Math.log10(n + 1)), fpLength: i };
|
|
379
|
+
}, subtractRect: (e, t, n = !1) => {
|
|
380
|
+
if (!t) return [e];
|
|
381
|
+
if (!pr(e, t)) return [];
|
|
382
|
+
const o = [];
|
|
383
|
+
let r = e;
|
|
384
|
+
const i = () => {
|
|
385
|
+
t.top > r.top && t.top < r.bottom && (o.push({ ...r, bottom: t.top }), r = { ...r, top: t.top });
|
|
386
|
+
}, l = () => {
|
|
387
|
+
t.bottom > r.top && t.bottom < r.bottom && (o.push({ ...r, top: t.bottom }), r = { ...r, bottom: t.bottom });
|
|
388
|
+
}, s = () => {
|
|
389
|
+
t.right > r.left && t.right < r.right && (o.push({ ...r, left: t.right }), r = { ...r, right: t.right });
|
|
390
|
+
}, a = () => {
|
|
391
|
+
t.left > r.left && t.left < r.right && (o.push({ ...r, right: t.left }), r = { ...r, left: t.left });
|
|
392
|
+
};
|
|
393
|
+
return n ? (a(), s(), i(), l()) : (i(), l(), s(), a()), o;
|
|
394
|
+
}, textToKey: (e) => e.replace(/[^a-zA-Z0-9]/g, "").toLowerCase(), throttle: function(e, t) {
|
|
395
|
+
let n = null;
|
|
396
|
+
return (...o) => {
|
|
397
|
+
const r = Date.now();
|
|
398
|
+
(!n || r - n >= t) && (n = r, e(...o));
|
|
399
|
+
};
|
|
400
|
+
}, toSafeJSON: function e(t) {
|
|
401
|
+
if (t === null || typeof t != "object") return t;
|
|
402
|
+
if (typeof t.toJSON == "function") return t.toJSON();
|
|
403
|
+
if (Array.isArray(t)) return t.map((o) => e(o));
|
|
404
|
+
if (typeof t.toString == "function" && t.toString !== Object.prototype.toString) return t.toString();
|
|
405
|
+
const n = {};
|
|
406
|
+
for (const o in t) t.hasOwnProperty(o) && (n[o] = e(t[o]));
|
|
407
|
+
return n;
|
|
408
|
+
}, transpose: (e) => {
|
|
409
|
+
if (!e) return e;
|
|
410
|
+
const t = e.length, n = e[0].length, o = [];
|
|
411
|
+
for (let r = 0; r < n; r++) o[r] = Array(t);
|
|
412
|
+
for (let r = 0; r < t; r++) for (let i = 0; i < n; i++) o[i][r] = e[r][i];
|
|
413
|
+
return o;
|
|
414
|
+
}, uuidV4: so, validEnumValue: (e, t) => {
|
|
415
|
+
if (!Object.values(e).includes(t)) throw new Error(`Invalid type: ${t ?? "null"}. Must be one of: ${Object.values(t).join(", ")}.`);
|
|
416
|
+
}, whenFocus: async (e, t = !1) => new Promise((n) => {
|
|
417
|
+
wr(e, t) ? n(!0) : e.addEventListener("focusin", () => {
|
|
418
|
+
n(!0);
|
|
419
|
+
}, { once: !0 }), e.focus();
|
|
420
|
+
}) }, Symbol.toStringTag, { value: "Module" }));
|
|
421
|
+
Object.freeze(Object.defineProperty({ __proto__: null, MESSAGE_ERROR_INVALID_ARG: (e) => `Invalid argument: '${e}'.` }, Symbol.toStringTag, { value: "Module" }));
|
|
422
|
+
const ti = (e) => {
|
|
423
|
+
const t = new Uint8Array(e), n = t.byteLength;
|
|
424
|
+
let o = "";
|
|
425
|
+
for (let r = 0; r < n; r++) o += String.fromCharCode(t[r]);
|
|
426
|
+
if (typeof window < "u" && typeof globalThis.btoa == "function") return globalThis.btoa(o);
|
|
427
|
+
if (typeof Buffer < "u") return Buffer.from(o, "binary").toString("base64");
|
|
428
|
+
throw new Error("Unsupported environment");
|
|
429
|
+
}, Wo = (e) => new Promise((t, n) => {
|
|
430
|
+
if (e) if (typeof FileReader < "u") {
|
|
431
|
+
const o = new FileReader();
|
|
432
|
+
o.onload = () => {
|
|
433
|
+
t(o.result);
|
|
434
|
+
}, o.onerror = () => {
|
|
435
|
+
n(o.error);
|
|
436
|
+
}, o.readAsText(e);
|
|
437
|
+
} else if (typeof Buffer < "u") {
|
|
438
|
+
const o = (r) => Buffer.from(r).toString("utf-8");
|
|
439
|
+
e.arrayBuffer().then((r) => {
|
|
440
|
+
t(o(r));
|
|
441
|
+
}).catch((r) => {
|
|
442
|
+
n(r);
|
|
443
|
+
});
|
|
444
|
+
} else n(new Error("Unsupported environment"));
|
|
445
|
+
else t("");
|
|
446
|
+
});
|
|
447
|
+
Object.freeze(Object.defineProperty({ __proto__: null, DEFAULT_MIME_TYPE: "*/*", arrayBufferToBase64: ti, base64ToArrayBuffer: (e) => {
|
|
448
|
+
const t = typeof window < "u" && typeof globalThis.atob == "function" ? globalThis.atob(e) : Buffer.from(e, "base64").toString("binary"), n = t.length, o = new Uint8Array(n);
|
|
449
|
+
for (let r = 0; r < n; r++) o[r] = t.charCodeAt(r);
|
|
450
|
+
return o.buffer;
|
|
451
|
+
}, blobToString: Wo }, Symbol.toStringTag, { value: "Module" }));
|
|
452
|
+
const ni = "data:image/png;base64,", oi = "Unable to resolve image.", mr = (e) => new Promise(async (t, n) => {
|
|
453
|
+
let o = null;
|
|
454
|
+
try {
|
|
455
|
+
o = new Image(), o.src = e, o.addEventListener("load", function() {
|
|
456
|
+
t({ width: o.naturalWidth, height: o.naturalHeight });
|
|
457
|
+
}, { once: !0 }), o.addEventListener("error", function() {
|
|
458
|
+
URL.revokeObjectURL(e), n("Invalid Image");
|
|
459
|
+
}, { once: !0 }), await o.decode("sync");
|
|
460
|
+
} catch {
|
|
461
|
+
o?.src && URL.revokeObjectURL(o.src);
|
|
462
|
+
}
|
|
463
|
+
o || n(oi);
|
|
464
|
+
}), Ro = "image/svg+xml";
|
|
465
|
+
var xr, vr;
|
|
466
|
+
Object.freeze(Object.defineProperty({ __proto__: null, DATA_URL_PNG_PREFIX: ni, getImageDataUrl: (e, t = 1) => new Promise(async (n, o) => {
|
|
467
|
+
let r = null;
|
|
468
|
+
try {
|
|
469
|
+
r = new Image(), r.src = e, r.addEventListener("load", function() {
|
|
470
|
+
try {
|
|
471
|
+
const i = document.createElement("canvas");
|
|
472
|
+
i.width = r.naturalWidth, i.height = r.naturalHeight, i.getContext("2d").drawImage(r, 0, 0);
|
|
473
|
+
const l = i.toDataURL("image/png", t);
|
|
474
|
+
n({ elemImg: r, dataUrl: l });
|
|
475
|
+
} catch (i) {
|
|
476
|
+
URL.revokeObjectURL(e), o(i);
|
|
477
|
+
}
|
|
478
|
+
}, { once: !0 }), r.addEventListener("error", function() {
|
|
479
|
+
URL.revokeObjectURL(e), o("Invalid Image");
|
|
480
|
+
}, { once: !0 }), await r.decode("sync");
|
|
481
|
+
} catch {
|
|
482
|
+
r?.src && URL.revokeObjectURL(r.src);
|
|
483
|
+
}
|
|
484
|
+
r || o(oi);
|
|
485
|
+
}), loadImageDetails: async (e, t = null) => {
|
|
486
|
+
let n = null;
|
|
487
|
+
const o = async () => {
|
|
488
|
+
try {
|
|
489
|
+
const i = t ?? "image/*", l = URL.createObjectURL(new Blob([e], { type: i })), s = await mr(l);
|
|
490
|
+
n = { mimeType: i, naturalDimensions: s, asUrl: l };
|
|
491
|
+
} catch {
|
|
492
|
+
}
|
|
493
|
+
}, r = async () => {
|
|
494
|
+
try {
|
|
495
|
+
const i = new TextDecoder().decode(e), l = URL.createObjectURL(new Blob([i], { type: Ro })), s = await mr(l);
|
|
496
|
+
n = { mimeType: t ?? Ro, naturalDimensions: s, asUrl: l, asSVGText: i };
|
|
497
|
+
} catch {
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
if (t === Ro ? await r() : t.startsWith("image/") ? await o() : (await o(), n || await r()), !n) throw new Error("Failed to load image");
|
|
501
|
+
return n;
|
|
502
|
+
} }, Symbol.toStringTag, { value: "Module" })), (vr = xr || (xr = {})).resolveTypedUpdates = (e, t, n, o) => {
|
|
503
|
+
if (e === null) return e;
|
|
504
|
+
if (e === void 0) return o;
|
|
505
|
+
let r = e;
|
|
506
|
+
if (t?.shorthand) {
|
|
507
|
+
const a = t?.shorthand(e, n);
|
|
508
|
+
a !== void 0 && (r = a);
|
|
509
|
+
}
|
|
510
|
+
if (r !== null && t?.getSubType) {
|
|
511
|
+
const a = t.getSubType(r);
|
|
512
|
+
a && (t = a);
|
|
513
|
+
}
|
|
514
|
+
const i = t?.properties, l = t?.arrayType ?? !1;
|
|
515
|
+
let s = r;
|
|
516
|
+
if (t && t.merge && s && o) s = t.merge(s, o, n);
|
|
517
|
+
else if (!l && i) {
|
|
518
|
+
const a = Object.keys({ ...r, ...o });
|
|
519
|
+
s = null;
|
|
520
|
+
for (let d = 0; d < a.length; d++) {
|
|
521
|
+
const g = a[d];
|
|
522
|
+
let m, f = r[g];
|
|
523
|
+
if (f !== void 0) {
|
|
524
|
+
const x = i[g];
|
|
525
|
+
m = x ? (0, vr.resolveTypedUpdates)(f, x, n, o?.[g]) : f;
|
|
526
|
+
} else m = o?.[g];
|
|
527
|
+
m != null && (s = s ?? {}, s[g] = m);
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
return s;
|
|
531
|
+
};
|
|
532
|
+
const yr = `The Safari browser does not support advanced copy and paste.
|
|
533
|
+
Copy and paste will be limited to within the browser tab.
|
|
534
|
+
|
|
535
|
+
Please use Chrome or Edge if external copy and paste is required.`, ko = `You do not have permissions to access the clipboard.
|
|
536
|
+
All copy and paste operations will be limited to the browser tab.`, ri = { Safari: `The Safari browser does not support advanced copy and paste.
|
|
537
|
+
Copy and paste will be limited to within the browser tab.
|
|
538
|
+
|
|
539
|
+
Please use Chrome or Edge if external copy and paste is required.`, Perms: ko, PermsWrite: Un() === Ft.Safari ? yr : ko, PermsRead: Un() === Ft.Safari ? yr : ko }, Po = async () => new Promise((e) => {
|
|
540
|
+
document.hasFocus() ? e() : globalThis.addEventListener?.("focus", () => {
|
|
541
|
+
e();
|
|
542
|
+
}, { once: !0 }), document.activeElement.focus?.();
|
|
543
|
+
}), Oo = async (e, t, n) => {
|
|
544
|
+
if (Un() === Ft.Safari) return await n(new Error(ri.Safari));
|
|
545
|
+
try {
|
|
546
|
+
const o = async (l) => {
|
|
547
|
+
try {
|
|
548
|
+
return await l();
|
|
549
|
+
} catch (s) {
|
|
550
|
+
if (s.message?.includes("Document is not focused")) return !1;
|
|
551
|
+
throw s;
|
|
552
|
+
}
|
|
553
|
+
}, r = await globalThis?.navigator?.permissions?.query({ name: e, allowWithoutGesture: !0, allowWithoutSanitization: !0 });
|
|
554
|
+
let i = !1;
|
|
555
|
+
if (r.state === "prompt" && (i = await o(t)), i || r.state !== "granted" || (i = await t()), !i) return await n(new Error(r.state));
|
|
556
|
+
} catch (o) {
|
|
557
|
+
return o.message === "No valid data on clipboard" || o.name === "DataError" ? void 0 : await n(o);
|
|
558
|
+
}
|
|
559
|
+
}, ii = async (e) => {
|
|
560
|
+
try {
|
|
561
|
+
return await e.read({ unsanitized: [Bt] });
|
|
562
|
+
} catch {
|
|
563
|
+
}
|
|
564
|
+
return await e.read();
|
|
565
|
+
};
|
|
566
|
+
if (!globalThis.ClipboardItem) {
|
|
567
|
+
const e = (n, o) => new Blob([o], { type: n });
|
|
568
|
+
class t {
|
|
569
|
+
constructor(o, r) {
|
|
570
|
+
this._items = {}, this._types = Object.keys(o);
|
|
571
|
+
const i = {}, l = Object.keys(o);
|
|
572
|
+
for (let s = 0; s < l.length; s++) {
|
|
573
|
+
const a = l[s];
|
|
574
|
+
let d = o[a];
|
|
575
|
+
i[a] = typeof d == "string" ? e(a, d) : d;
|
|
576
|
+
}
|
|
577
|
+
this._items = i, this._presentationStyle = r?.presentationStyle ?? "unspecified";
|
|
578
|
+
}
|
|
579
|
+
get types() {
|
|
580
|
+
return this._types;
|
|
581
|
+
}
|
|
582
|
+
getType(o) {
|
|
583
|
+
return Promise.resolve(this._items[o]);
|
|
584
|
+
}
|
|
585
|
+
supports(o) {
|
|
586
|
+
return !0;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
globalThis.ClipboardItem = t;
|
|
590
|
+
}
|
|
591
|
+
const Ho = async (e, t = Bt) => new Promise(async (n, o) => {
|
|
592
|
+
try {
|
|
593
|
+
const r = await (async (i, l) => {
|
|
594
|
+
if (!i) return null;
|
|
595
|
+
const s = await ii(i);
|
|
596
|
+
let a = !1;
|
|
597
|
+
for (let d = 0; !a && s && d < s.length; d++) if (a = s[d].types.includes(l), a) return await s[d].getType(l);
|
|
598
|
+
return a ? void 0 : null;
|
|
599
|
+
})(e, t);
|
|
600
|
+
if (r) {
|
|
601
|
+
const i = new FileReader();
|
|
602
|
+
i.onload = () => {
|
|
603
|
+
n(i.result);
|
|
604
|
+
}, i.onerror = () => {
|
|
605
|
+
n("");
|
|
606
|
+
}, i.readAsText(r);
|
|
607
|
+
} else n("");
|
|
608
|
+
} catch (r) {
|
|
609
|
+
o(r);
|
|
610
|
+
}
|
|
611
|
+
}), br = async (e, t = Bt) => {
|
|
612
|
+
const n = await Ho(e, t);
|
|
613
|
+
if (!n) return null;
|
|
614
|
+
let o = null;
|
|
615
|
+
try {
|
|
616
|
+
o = new DOMParser().parseFromString(n, Bt);
|
|
617
|
+
} catch {
|
|
618
|
+
console.warn("Can't parse html from clipboard.");
|
|
619
|
+
}
|
|
620
|
+
return o;
|
|
621
|
+
}, qn = "clipboard-uuid", Tn = "web text/uuid", Sr = (e) => `<div style="display:none" ${qn}="${e}"/>`, Xi = (e, t) => {
|
|
622
|
+
let n = null;
|
|
623
|
+
try {
|
|
624
|
+
const o = new DOMParser().parseFromString(t, Bt);
|
|
625
|
+
o.body.firstElementChild.setAttribute(qn, e), n = o.getElementsByTagName("body")[0].innerHTML;
|
|
626
|
+
} catch (o) {
|
|
627
|
+
console.warn("Can't embed uuid.", o);
|
|
628
|
+
}
|
|
629
|
+
return n;
|
|
630
|
+
}, Er = (e, t) => {
|
|
631
|
+
if (!t || !e) return !1;
|
|
632
|
+
try {
|
|
633
|
+
const n = t.querySelectorAll(`[${qn}="${e}"]`);
|
|
634
|
+
if (n && n.length === 1) return !0;
|
|
635
|
+
if (t.querySelector("parsererror")) throw new Error("We are unable to parse node");
|
|
636
|
+
return !1;
|
|
637
|
+
} catch {
|
|
638
|
+
return !1;
|
|
639
|
+
}
|
|
640
|
+
};
|
|
641
|
+
let ho = class {
|
|
642
|
+
constructor(e) {
|
|
643
|
+
if (e?.nativeClipboard === void 0 || e?.nativeClipboard === !0) try {
|
|
644
|
+
this._nativeClipboard = globalThis?.navigator.clipboard;
|
|
645
|
+
} catch {
|
|
646
|
+
e?.nativeClipboard === !0 && console.warn("NativeClipboard option set to true but no native clipboard available.");
|
|
647
|
+
}
|
|
648
|
+
else this._nativeClipboard = e?.nativeClipboard === !1 ? null : e?.nativeClipboard;
|
|
649
|
+
this._disableCheckOnFocus = e?.disableCheckOnFocus ?? !1, this._init();
|
|
650
|
+
}
|
|
651
|
+
async _checkForChanges() {
|
|
652
|
+
this._nativeClipboard && this._state && !this._disableCheckOnFocus && await Oo("clipboard-read", async () => {
|
|
653
|
+
await Po();
|
|
654
|
+
const e = await Ho(this._nativeClipboard, Tn);
|
|
655
|
+
if (!this._state || e && e === this._state.uuid) return !0;
|
|
656
|
+
const t = await br(this._nativeClipboard, Bt);
|
|
657
|
+
return !this._state || (Er(this._state.uuid, t) || this.clear(), !0);
|
|
658
|
+
}, async (e) => {
|
|
659
|
+
e?.message === "denied" || e.message?.includes("Document is not focused") || Un() === Ft.Safari || console.warn("Unable to detect clipboard changes: ", e);
|
|
660
|
+
});
|
|
661
|
+
}
|
|
662
|
+
_init() {
|
|
663
|
+
const e = this;
|
|
664
|
+
this._listeners = /* @__PURE__ */ new Map(), this._listenersCapture = /* @__PURE__ */ new Map(), this._state = null, this._nativeClipboard && (this._onFocus = () => {
|
|
665
|
+
e._checkForChanges();
|
|
666
|
+
}, this._onBlur = () => {
|
|
667
|
+
globalThis.addEventListener?.("focus", e._onFocus, { once: !0 });
|
|
668
|
+
}, globalThis.addEventListener?.("blur", this._onBlur), this._nativeClipboard.addEventListener("clipboardchange", (t) => {
|
|
669
|
+
e._checkForChanges();
|
|
670
|
+
}));
|
|
671
|
+
}
|
|
672
|
+
async read() {
|
|
673
|
+
if (!this._nativeClipboard) return this._state?.items ?? null;
|
|
674
|
+
const e = this;
|
|
675
|
+
return await Oo("clipboard-read", async () => {
|
|
676
|
+
if (await Po(), this._state?.uuid) {
|
|
677
|
+
const t = await Ho(this._nativeClipboard, Tn);
|
|
678
|
+
if (t && t === e._state.uuid) return !0;
|
|
679
|
+
const n = await br(this._nativeClipboard, Bt);
|
|
680
|
+
if (Er(e._state?.uuid, n)) return !0;
|
|
681
|
+
}
|
|
682
|
+
return e._state = { items: await ii(this._nativeClipboard), uuid: null, ref: null }, this.dispatchEvent(new Event("clipboardread")), !0;
|
|
683
|
+
}, async (t) => {
|
|
684
|
+
this.dispatchEvent(new Event("clipboarderrorread"));
|
|
685
|
+
}), this._state?.items ?? [];
|
|
686
|
+
}
|
|
687
|
+
async write(e) {
|
|
688
|
+
return this._write({ uuid: so(), items: e, ref: null });
|
|
689
|
+
}
|
|
690
|
+
async _write(e) {
|
|
691
|
+
if (!this._nativeClipboard) return this._state = e, this.dispatchEvent(new Event("clipboardwrite")), this.dispatchEvent(new Event("clipboardchange")), null;
|
|
692
|
+
const t = this, n = [], o = e.uuid;
|
|
693
|
+
let r = e.items ?? [];
|
|
694
|
+
const i = () => {
|
|
695
|
+
t._state = { uuid: o, ref: e.ref, items: n }, t.dispatchEvent(new Event("clipboardwrite")), t.dispatchEvent(new Event("clipboardchange"));
|
|
696
|
+
};
|
|
697
|
+
await Oo("clipboard-write", async () => {
|
|
698
|
+
await Po(), o && r.length === 0 && (r.push(new ClipboardItem({ [Tn]: new Blob([o], { type: Tn }) })), r.push(new ClipboardItem({ [Bt]: new Blob([Sr(o)], { type: Bt }) })));
|
|
699
|
+
for (let l = 0; l < Math.min(1, r.length); l++) {
|
|
700
|
+
const s = r[l];
|
|
701
|
+
let a = s.types.indexOf(Bt), d = null;
|
|
702
|
+
if (a !== -1) {
|
|
703
|
+
const f = await s.getType(Bt);
|
|
704
|
+
d = await Wo(f), d && (d = Xi(o, d));
|
|
705
|
+
}
|
|
706
|
+
if (!d && s.types.includes(fn)) {
|
|
707
|
+
const f = await s.getType(fn);
|
|
708
|
+
if (f) {
|
|
709
|
+
let x = null;
|
|
710
|
+
typeof f == "string" ? (console.warn("text as string", f), x = f) : x = await Wo(f), x && (d = `<div ${qn}="${o}">${x}</div>`);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
if (!d && s.types.includes(Mo)) {
|
|
714
|
+
const f = await s.getType(Mo), x = ti(await f.arrayBuffer());
|
|
715
|
+
d = `<div ${qn}="${o}"><img src="${ni + x}"/></div>`;
|
|
716
|
+
}
|
|
717
|
+
!d && o && (d = Sr(o));
|
|
718
|
+
const g = new Blob([d ?? ""], { type: Bt }), m = {};
|
|
719
|
+
for (let f = 0; f < s.types.length; f++) {
|
|
720
|
+
const x = s.types[f];
|
|
721
|
+
m[x] = f === a ? g : s.getType(x);
|
|
722
|
+
}
|
|
723
|
+
d && a === -1 && (m[Bt] = g), o && (m[Tn] = new Blob([o], { type: Tn })), n.push(new ClipboardItem(m));
|
|
724
|
+
}
|
|
725
|
+
try {
|
|
726
|
+
n && n.length !== 0 ? await this._nativeClipboard.write(n) : await (async (l) => {
|
|
727
|
+
l && await l.writeText("");
|
|
728
|
+
})(this._nativeClipboard);
|
|
729
|
+
} catch (l) {
|
|
730
|
+
l.message?.includes("Document is not focused") || console.warn("Unable to write to native clipboard: ", l);
|
|
731
|
+
}
|
|
732
|
+
return i(), !0;
|
|
733
|
+
}, async (l) => {
|
|
734
|
+
this.dispatchEvent(new Event("clipboarderrorwrite")), i();
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
async writeReference(e) {
|
|
738
|
+
if (!e) return void this.clear();
|
|
739
|
+
let t = null;
|
|
740
|
+
const n = {};
|
|
741
|
+
try {
|
|
742
|
+
const r = await e.toText?.() ?? null;
|
|
743
|
+
r && (n[fn] = new Blob([r ?? ""], { type: fn }));
|
|
744
|
+
} catch (r) {
|
|
745
|
+
t = r;
|
|
746
|
+
}
|
|
747
|
+
try {
|
|
748
|
+
const r = await e.toHtml?.() ?? null;
|
|
749
|
+
r && (n[Bt] = new Blob([r], { type: Bt }));
|
|
750
|
+
} catch (r) {
|
|
751
|
+
t = r, console.warn("export to html", r);
|
|
752
|
+
}
|
|
753
|
+
try {
|
|
754
|
+
const r = await e.toImage?.() ?? null;
|
|
755
|
+
r && (n[Mo] = r);
|
|
756
|
+
} catch (r) {
|
|
757
|
+
t = r, console.warn("export to png", r);
|
|
758
|
+
}
|
|
759
|
+
const o = this._write({ uuid: so(), ref: e, items: Object.keys(n).length > 0 ? [new ClipboardItem(n)] : null });
|
|
760
|
+
if (t) throw t;
|
|
761
|
+
return o;
|
|
762
|
+
}
|
|
763
|
+
clear(e = !1) {
|
|
764
|
+
this._state && (this._state = null, e && this._write({ uuid: null, ref: null, items: null }), this.dispatchEvent(new Event("clipboardwrite")), this.dispatchEvent(new Event("clipboardchange")));
|
|
765
|
+
}
|
|
766
|
+
async readReference() {
|
|
767
|
+
return await this.read(), this._state?.ref ?? null;
|
|
768
|
+
}
|
|
769
|
+
readText() {
|
|
770
|
+
return new Promise(async (e, t) => {
|
|
771
|
+
const n = await this.read();
|
|
772
|
+
let o = null;
|
|
773
|
+
for (let i = 0; !o && n && i < n.length; i++) n[i].types.includes(fn) && (o = await n[i].getType(fn));
|
|
774
|
+
if (!o) return void e("");
|
|
775
|
+
const r = new FileReader();
|
|
776
|
+
r.onload = () => {
|
|
777
|
+
e(r.result);
|
|
778
|
+
}, r.readAsText(o), r.onerror = (i) => {
|
|
779
|
+
t(i);
|
|
780
|
+
};
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
async writeText(e) {
|
|
784
|
+
const t = [new ClipboardItem({ [fn]: new Blob([e], { type: fn }) })];
|
|
785
|
+
return this._write({ uuid: so(), items: t, ref: null });
|
|
786
|
+
}
|
|
787
|
+
addEventListener(e, t, n = {}) {
|
|
788
|
+
const o = n?.capture ? this._listenersCapture : this._listeners;
|
|
789
|
+
let r = o.get(e);
|
|
790
|
+
r || (r = /* @__PURE__ */ new Map(), o.set(e, r)), r.set(t, typeof n == "boolean" ? {} : n);
|
|
791
|
+
}
|
|
792
|
+
dispatchEvent(e) {
|
|
793
|
+
if (!e) return;
|
|
794
|
+
const t = (n) => {
|
|
795
|
+
const o = n.get(e.type);
|
|
796
|
+
o && o.forEach((r, i) => {
|
|
797
|
+
try {
|
|
798
|
+
typeof i == "function" ? i(e) : i.handleEvent && i.handleEvent(e), r.once && o.delete(i);
|
|
799
|
+
} catch (l) {
|
|
800
|
+
console.warn(l);
|
|
801
|
+
}
|
|
802
|
+
});
|
|
803
|
+
};
|
|
804
|
+
return t(this._listenersCapture), t(this._listeners), !0;
|
|
805
|
+
}
|
|
806
|
+
removeEventListener(e, t, n) {
|
|
807
|
+
const o = n?.capture ? this._listenersCapture : this._listeners, r = o.get(e);
|
|
808
|
+
r && (r.delete(t), r.size === 0 && o.delete(e));
|
|
809
|
+
}
|
|
810
|
+
close() {
|
|
811
|
+
globalThis.removeEventListener?.("focus", this._onFocus), globalThis.removeEventListener?.("blur", this._onBlur);
|
|
812
|
+
}
|
|
813
|
+
};
|
|
814
|
+
var Lo;
|
|
815
|
+
(Lo = ho || (ho = {})).ErrorMessages = ri, Lo.Global = new Lo(), function() {
|
|
816
|
+
try {
|
|
817
|
+
if (typeof document < "u") {
|
|
818
|
+
var e = document.createElement("style");
|
|
819
|
+
e.appendChild(document.createTextNode("._sheetxl-scrollbar_18qzf_11 ::-webkit-scrollbar-button{background:transparent}._fullscreen-portal-root_5qk7s_7{pointer-events:none;position:absolute;inset:0;width:100%;height:100%;z-index:1200}._fullscreen-portal-root_5qk7s_7>*{pointer-events:auto}")), document.head.appendChild(e);
|
|
820
|
+
}
|
|
821
|
+
} catch (t) {
|
|
822
|
+
console.error("vite-plugin-css-injected-by-js", t);
|
|
823
|
+
}
|
|
824
|
+
}();
|
|
825
|
+
/**
|
|
826
|
+
* @license @sheetxl/utils-react - Utils React - Utilities for React capabilities needed for all SheetXL components. - v0.1.95
|
|
827
|
+
*
|
|
828
|
+
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
829
|
+
* License: The license can be found at https://www.sheetxl.com/license.
|
|
830
|
+
*/
|
|
831
|
+
const Wn = { Left: "left", Right: "right", Center: "center" }, It = "shift", yn = "alt", Lt = "ctrl", Gi = 9, Zi = 13, Ji = 27, Qi = 37, el = 38, tl = 39, nl = 40, ol = 113, _r = 3, mn = { Horizontal: "horizontal", Vertical: "vertical" };
|
|
832
|
+
function li(e) {
|
|
833
|
+
var t, n, o = "";
|
|
834
|
+
if (typeof e == "string" || typeof e == "number") o += e;
|
|
835
|
+
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
836
|
+
var r = e.length;
|
|
837
|
+
for (t = 0; t < r; t++) e[t] && (n = li(e[t])) && (o && (o += " "), o += n);
|
|
838
|
+
} else for (n in e) e[n] && (o && (o += " "), o += n);
|
|
839
|
+
return o;
|
|
840
|
+
}
|
|
841
|
+
function Rn() {
|
|
842
|
+
for (var e, t, n = 0, o = "", r = arguments.length; n < r; n++) (e = arguments[n]) && (t = li(e)) && (o && (o += " "), o += t);
|
|
843
|
+
return o;
|
|
844
|
+
}
|
|
845
|
+
var rl = function() {
|
|
846
|
+
}, si = typeof window < "u", il = si ? nn : st, Ir = { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, bottom: 0, right: 0 };
|
|
847
|
+
const In = si && window.ResizeObserver !== void 0 ? function() {
|
|
848
|
+
var e = Je(null), t = e[0], n = e[1], o = Je(Ir), r = o[0], i = o[1], l = Ee(function() {
|
|
849
|
+
return new window.ResizeObserver(function(s) {
|
|
850
|
+
if (s[0]) {
|
|
851
|
+
var a = s[0].contentRect, d = a.x, g = a.y, m = a.width, f = a.height, x = a.top, E = a.left, I = a.bottom, M = a.right;
|
|
852
|
+
i({ x: d, y: g, width: m, height: f, top: x, left: E, bottom: I, right: M });
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
}, []);
|
|
856
|
+
return il(function() {
|
|
857
|
+
if (t) return l.observe(t), function() {
|
|
858
|
+
l.disconnect();
|
|
859
|
+
};
|
|
860
|
+
}, [t]), [n, r];
|
|
861
|
+
} : function() {
|
|
862
|
+
return [rl, Ir];
|
|
863
|
+
}, T = (e, t) => {
|
|
864
|
+
const n = O((...i) => e?.(...i), t), o = J(null);
|
|
865
|
+
o.current = n;
|
|
866
|
+
const r = O((...i) => o.current?.(...i), []);
|
|
867
|
+
if (o.current) return r;
|
|
868
|
+
}, ll = (e) => {
|
|
869
|
+
const { style: t, orientation: n = mn.Vertical, ...o } = e, r = n === mn.Vertical;
|
|
870
|
+
return Y("div", { style: { paddingBottom: "0px", paddingRight: "0px", paddingLeft: r ? "0px" : "3px", paddingTop: r ? "3px" : "0px", display: "flex", alignItems: "center", justifyContent: "center", ...t }, ...o, children: Y("button", { style: { padding: "0", display: "flex", alignItems: "center", justifyContent: "center", border: "none" }, className: `scrollbar-button ${r ? "vertical" : "horizontal"} single-button start`, children: Y("svg", { width: "9", height: "9", viewBox: "0 0 6 6", style: { opacity: "inherit" }, children: Y("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" }) }) }) });
|
|
871
|
+
}, sl = (e) => {
|
|
872
|
+
const { style: t, orientation: n = mn.Vertical, ...o } = e, r = n === mn.Vertical;
|
|
873
|
+
return Y("div", { style: { paddingLeft: "0px", paddingTop: "0px", paddingRight: r ? "0px" : "3px", paddingBottom: r ? "3px" : "0px", display: "flex", alignItems: "center", justifyContent: "center", ...t }, ...o, children: Y("button", { style: { padding: "0", display: "flex", alignItems: "center", justifyContent: "center", border: "none" }, className: `scrollbar-button ${r ? "vertical" : "horizontal"} single-button end`, children: Y("svg", { width: "9", height: "9", viewBox: "0 0 6 6", style: { opacity: "inherit" }, children: Y("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" }) }) }) });
|
|
874
|
+
}, No = (e, t, n, o, r = 0) => {
|
|
875
|
+
for (let i = 0; i < n.length; i++) {
|
|
876
|
+
const l = n[i].getBoundingClientRect();
|
|
877
|
+
let s = l.left - t, a = s + l.width;
|
|
878
|
+
if (o) {
|
|
879
|
+
if (s < e && a >= e) return s;
|
|
880
|
+
} else if (Math.ceil(a) > Math.ceil(e) + 2) return a;
|
|
881
|
+
}
|
|
882
|
+
return r;
|
|
883
|
+
};
|
|
884
|
+
Object.freeze(Object.defineProperty({ __proto__: null, getScrollTo: No }, Symbol.toStringTag, { value: "Module" }));
|
|
885
|
+
const er = Dt(Ut((e, t) => {
|
|
886
|
+
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: E = ll, createScrollEndButton: I = sl, ...M } = e, ae = T(d, [d]), R = J(null), [_, { width: L, height: le }] = In(), [$, { width: oe, height: be }] = In(), U = s === mn.Vertical, H = U ? "top" : "left", X = U ? "scrollTop" : "scrollLeft", k = U ? le : L, u = U ? be : oe, [C, ee] = Je(null);
|
|
887
|
+
st(() => {
|
|
888
|
+
C !== null && R.current && R.current.scrollTo({ behavior: "smooth", [H]: C });
|
|
889
|
+
}, [C, U]);
|
|
890
|
+
const W = O((S, ue = !1) => {
|
|
891
|
+
if (!R.current) return 0;
|
|
892
|
+
const K = R.current.querySelector(".scrollbar-viewport"), pe = K.getBoundingClientRect(), te = K.children, Re = ue ? 0 : No(S, pe[H], te, !0, Math.max(0, S - m));
|
|
893
|
+
return ee(Re), Math.max(0, Re);
|
|
894
|
+
}, []), A = O((S, ue = !1) => {
|
|
895
|
+
if (!R.current) return 0;
|
|
896
|
+
const K = R.current.querySelector(".scrollbar-viewport"), pe = K.getBoundingClientRect(), te = K.children, Re = Math.ceil(u - k), at = ue ? Re : No(S, pe[H], te, !1, Math.max(0, S + m));
|
|
897
|
+
return ee(at), Math.min(Re, at);
|
|
898
|
+
}, [u, k]), q = J(null), N = O((S) => {
|
|
899
|
+
q.current = n;
|
|
900
|
+
const ue = S.target[X];
|
|
901
|
+
a(ue, r, o), ae?.(S);
|
|
902
|
+
}, [a, r, o, n]);
|
|
903
|
+
st(() => {
|
|
904
|
+
const S = q.current;
|
|
905
|
+
q.current = null, n !== S && (R.current[X] = n);
|
|
906
|
+
}, [n, X]);
|
|
907
|
+
const xe = J(null), G = J(null), He = O(() => {
|
|
908
|
+
xe.current && (clearTimeout(xe.current), xe.current = null, G.current = null);
|
|
909
|
+
}, []), Ue = O((S, ue, K, pe = f) => {
|
|
910
|
+
G.current = S, xe.current = setTimeout(() => {
|
|
911
|
+
const te = K ? W(G.current || S) : A(G.current || S);
|
|
912
|
+
te !== G.current ? Ue(te, !1, K, x) : He();
|
|
913
|
+
}, ue ? 0 : pe);
|
|
914
|
+
}, [W, A, He]);
|
|
915
|
+
st(() => () => He(), [He]);
|
|
916
|
+
const We = n, ht = Ee(() => {
|
|
917
|
+
if (!g) return null;
|
|
918
|
+
const S = { orientation: s, disabled: Math.floor(We) <= 0 || Math.floor(u - k) === 0, onMouseUp: He, onMouseLeave: He, onMouseDown: () => Ue(We, !0, !0) };
|
|
919
|
+
return E?.(S);
|
|
920
|
+
}, [g, s, We, C, u, k]), _e = Ee(() => {
|
|
921
|
+
if (!g) return null;
|
|
922
|
+
const S = { orientation: s, disabled: Math.floor(u - k) <= Math.ceil(We), onMouseUp: He, onMouseLeave: He, onMouseDown: () => Ue(We, !0, !1) };
|
|
923
|
+
return I?.(S);
|
|
924
|
+
}, [g, s, We, C, u, k]);
|
|
925
|
+
return Ht("div", { ref: t, style: { display: "flex", flex: "1", flexDirection: U ? "column" : "row", padding: "0", ...i }, className: Rn("_sheetxl-scrollbar_18qzf_11", l), ...M, children: [ht, Y("div", { className: "pseudo-scrollbar", style: { flex: "1 1 100%", display: "flex", boxSizing: "content-box", flexDirection: U ? "column" : "row", justifyContent: "center", alignItems: "center" }, ref: _, children: Y("div", { tabIndex: -1, style: { flex: "1 1 100%", overflowY: U ? "scroll" : "hidden", overflowX: U ? "hidden" : "scroll", position: "relative", willChange: "transform" }, onScroll: N, ref: R, children: Y("div", { ref: $, style: { position: "absolute", height: U ? o - r + (le ?? 0) : 1, width: U ? 1 : o - r + (L ?? 0) }, className: "scrollbar-viewport" }) }) }), _e] });
|
|
926
|
+
}));
|
|
927
|
+
er.displayName = "Scrollbar";
|
|
928
|
+
let Cr = Date.now, gn = {}, cl = 1;
|
|
929
|
+
const jn = (e) => {
|
|
930
|
+
let t = gn[e] !== null;
|
|
931
|
+
return t && (gn[e] = null), t;
|
|
932
|
+
}, Mr = (e, t, n, o = 0, r) => {
|
|
933
|
+
let i = Cr(), l = i, s = 0, a = 0, d = cl++;
|
|
934
|
+
if (d % 20 == 0) {
|
|
935
|
+
const m = {};
|
|
936
|
+
for (let f in gn) m[f] = !0;
|
|
937
|
+
gn = m;
|
|
938
|
+
}
|
|
939
|
+
const g = function(m) {
|
|
940
|
+
const f = m !== !0, x = Cr();
|
|
941
|
+
if (!gn[d] || t && !t(d)) return gn[d] = null, void n(60 - a / ((x - i) / 1e3), d, !1);
|
|
942
|
+
if (f) {
|
|
943
|
+
const I = Math.round((x - l) / 16.666666666666668) - 1;
|
|
944
|
+
for (let M = 0; M < Math.min(I, 4); M++) g(!0), a++;
|
|
945
|
+
}
|
|
946
|
+
o && (s = (x - i) / o, s > 1 && (s = 1));
|
|
947
|
+
const E = r ? r(s) : s;
|
|
948
|
+
e(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));
|
|
949
|
+
};
|
|
950
|
+
return gn[d] = !0, requestAnimationFrame(g), d;
|
|
951
|
+
};
|
|
952
|
+
var al = function() {
|
|
953
|
+
}, dl = function(e) {
|
|
954
|
+
return Math.pow(e - 1, 3) + 1;
|
|
955
|
+
}, ul = function(e) {
|
|
956
|
+
return (e /= 0.5) < 1 ? 0.5 * Math.pow(e, 3) : 0.5 * (Math.pow(e - 2, 3) + 2);
|
|
957
|
+
}, ci = function(e, t) {
|
|
958
|
+
for (var n in this.__callback = e, this.options = { scrollingX: !0, scrollingY: !0, animating: !0, animationDuration: 250, bouncing: !0, locking: !0, paging: !1, snapping: !1, zooming: !1, minZoom: 0.5, maxZoom: 3, speedMultiplier: 1, scrollingComplete: al, penetrationDeceleration: 0.03, penetrationAcceleration: 0.08 }, t) this.options[n] = t[n];
|
|
959
|
+
};
|
|
960
|
+
ci.prototype = { __isSingleTouch: !1, __isTracking: !1, __didDecelerationComplete: !1, __isGesturing: !1, __isDragging: !1, __isDecelerating: !1, __isAnimating: !1, __clientLeft: 0, __clientTop: 0, __clientWidth: 0, __clientHeight: 0, __contentWidth: 0, __contentHeight: 0, __snapWidth: 100, __snapHeight: 100, __zoomLevel: 1, __scrollLeft: 0, __scrollTop: 0, __maxScrollLeft: 0, __maxScrollTop: 0, __scheduledLeft: 0, __scheduledTop: 0, __scheduledZoom: 0, __lastTouchLeft: null, __lastTouchTop: null, __lastTouchMove: null, __positions: null, __minDecelerationScrollLeft: null, __minDecelerationScrollTop: null, __maxDecelerationScrollLeft: null, __maxDecelerationScrollTop: null, __decelerationVelocityX: null, __decelerationVelocityY: null, setDimensions: function(e, t, n, o) {
|
|
961
|
+
e !== null && (this.__clientWidth = e), t !== null && (this.__clientHeight = t), n !== null && (this.__contentWidth = n), o !== null && (this.__contentHeight = o), this.__computeScrollMax(), this.scrollTo(this.__scrollLeft, this.__scrollTop, !0);
|
|
962
|
+
}, setPosition: function(e, t) {
|
|
963
|
+
this.__clientLeft = e || 0, this.__clientTop = t || 0;
|
|
964
|
+
}, setSnapSize: function(e, t) {
|
|
965
|
+
this.__snapWidth = e, this.__snapHeight = t;
|
|
966
|
+
}, getValues: function() {
|
|
967
|
+
return { left: this.__scrollLeft, top: this.__scrollTop, right: this.__scrollLeft + this.__clientWidth / this.__zoomLevel, bottom: this.__scrollTop + this.__clientHeight / this.__zoomLevel, zoom: this.__zoomLevel };
|
|
968
|
+
}, getPoint: function(e, t) {
|
|
969
|
+
var n = this.getValues();
|
|
970
|
+
return { left: e / n.zoom, top: t / n.zoom };
|
|
971
|
+
}, getScrollMax: function() {
|
|
972
|
+
return { left: this.__maxScrollLeft, top: this.__maxScrollTop };
|
|
973
|
+
}, zoomTo: function(e, t, n, o, r) {
|
|
974
|
+
if (!this.options.zooming) throw new Error("Zooming is not enabled!");
|
|
975
|
+
r && (this.__zoomComplete = r), this.__isDecelerating && (jn(this.__isDecelerating), this.__isDecelerating = !1);
|
|
976
|
+
var i = this.__zoomLevel;
|
|
977
|
+
n === void 0 && (n = this.__clientWidth / 2), o === void 0 && (o = this.__clientHeight / 2), e = Math.max(Math.min(e, this.options.maxZoom), this.options.minZoom), this.__computeScrollMax(e);
|
|
978
|
+
var l = e / i, s = l * (this.__scrollLeft + n) - n, a = l * (this.__scrollTop + o) - o;
|
|
979
|
+
s > this.__maxScrollLeft ? s = this.__maxScrollLeft : s < 0 && (s = 0), a > this.__maxScrollTop ? a = this.__maxScrollTop : a < 0 && (a = 0), this.__publish(s, a, e, t);
|
|
980
|
+
}, zoomBy: function(e, t, n, o, r) {
|
|
981
|
+
this.zoomTo(this.__zoomLevel * e, t, n, o, r);
|
|
982
|
+
}, scrollTo: function(e, t, n, o) {
|
|
983
|
+
if (this.__isDecelerating && (jn(this.__isDecelerating), this.__isDecelerating = !1), o !== void 0 && o !== this.__zoomLevel) {
|
|
984
|
+
if (!this.options.zooming) throw new Error("Zooming is not enabled!");
|
|
985
|
+
e *= o, t *= o, this.__computeScrollMax(o);
|
|
986
|
+
} else o = this.__zoomLevel;
|
|
987
|
+
this.options.scrollingX ? this.options.paging ? e = Math.round(e / this.__clientWidth) * this.__clientWidth : this.options.snapping && (e = Math.round(e / this.__snapWidth) * this.__snapWidth) : e = this.__scrollLeft, this.options.scrollingY ? this.options.paging ? t = Math.round(t / this.__clientHeight) * this.__clientHeight : this.options.snapping && (t = Math.round(t / this.__snapHeight) * this.__snapHeight) : t = this.__scrollTop, e = Math.max(Math.min(this.__maxScrollLeft, e), 0), t = Math.max(Math.min(this.__maxScrollTop, t), 0), e === this.__scrollLeft && t === this.__scrollTop && (n = !1), this.__publish(e, t, o, n);
|
|
988
|
+
}, scrollBy: function(e, t, n) {
|
|
989
|
+
var o = this.__isAnimating ? this.__scheduledLeft : this.__scrollLeft, r = this.__isAnimating ? this.__scheduledTop : this.__scrollTop;
|
|
990
|
+
this.scrollTo(o + (e || 0), r + (t || 0), n);
|
|
991
|
+
}, doMouseZoom: function(e, t, n, o) {
|
|
992
|
+
var r = e > 0 ? 0.97 : 1.03;
|
|
993
|
+
return this.zoomTo(this.__zoomLevel * r, !1, n - this.__clientLeft, o - this.__clientTop);
|
|
994
|
+
}, doTouchStart: function(e, t) {
|
|
995
|
+
if (e.length === void 0) throw new Error("Invalid touch list: " + e);
|
|
996
|
+
if (t instanceof Date && (t = t.valueOf()), typeof t != "number") throw new Error("Invalid timestamp value: " + t);
|
|
997
|
+
var n, o;
|
|
998
|
+
this.__interruptedAnimation = !0, this.__isDecelerating && (jn(this.__isDecelerating), this.__isDecelerating = !1, this.__interruptedAnimation = !0), this.__isAnimating && (jn(this.__isAnimating), this.__isAnimating = !1, this.__interruptedAnimation = !0);
|
|
999
|
+
var r = e.length === 1;
|
|
1000
|
+
r ? (n = e[0].pageX, o = e[0].pageY) : (n = Math.abs(e[0].pageX + e[1].pageX) / 2, o = Math.abs(e[0].pageY + e[1].pageY) / 2), this.__initialTouchLeft = n, this.__initialTouchTop = o, this.__zoomLevelStart = this.__zoomLevel, this.__lastTouchLeft = n, this.__lastTouchTop = o, this.__lastTouchMove = t, this.__lastScale = 1, this.__enableScrollX = !r && this.options.scrollingX, this.__enableScrollY = !r && this.options.scrollingY, this.__isTracking = !0, this.__didDecelerationComplete = !1, this.__isDragging = !r, this.__isSingleTouch = r, this.__positions = [];
|
|
1001
|
+
}, doTouchMove: function(e, t, n) {
|
|
1002
|
+
if (e.length === void 0) throw new Error("Invalid touch list: " + e);
|
|
1003
|
+
if (t instanceof Date && (t = t.valueOf()), typeof t != "number") throw new Error("Invalid timestamp value: " + t);
|
|
1004
|
+
if (this.__isTracking) {
|
|
1005
|
+
var o, r;
|
|
1006
|
+
e.length === 2 ? (o = Math.abs(e[0].pageX + e[1].pageX) / 2, r = Math.abs(e[0].pageY + e[1].pageY) / 2) : (o = e[0].pageX, r = e[0].pageY);
|
|
1007
|
+
var i = this.__positions;
|
|
1008
|
+
if (this.__isDragging) {
|
|
1009
|
+
var l = o - this.__lastTouchLeft, s = r - this.__lastTouchTop, a = this.__scrollLeft, d = this.__scrollTop, g = this.__zoomLevel;
|
|
1010
|
+
if (n !== void 0 && this.options.zooming) {
|
|
1011
|
+
var m = g;
|
|
1012
|
+
if (g = g / this.__lastScale * n, m !== (g = Math.max(Math.min(g, this.options.maxZoom), this.options.minZoom))) {
|
|
1013
|
+
var f = o - this.__clientLeft, x = r - this.__clientTop;
|
|
1014
|
+
a = (f + a) * g / m - f, d = (x + d) * g / m - x, this.__computeScrollMax(g);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
if (this.__enableScrollX) {
|
|
1018
|
+
a -= l * this.options.speedMultiplier;
|
|
1019
|
+
var E = this.__maxScrollLeft;
|
|
1020
|
+
(a > E || a < 0) && (this.options.bouncing ? a += l / 2 * this.options.speedMultiplier : a = a > E ? E : 0);
|
|
1021
|
+
}
|
|
1022
|
+
if (this.__enableScrollY) {
|
|
1023
|
+
d -= s * this.options.speedMultiplier;
|
|
1024
|
+
var I = this.__maxScrollTop;
|
|
1025
|
+
(d > I || d < 0) && (this.options.bouncing ? d += s / 2 * this.options.speedMultiplier : d = d > I ? I : 0);
|
|
1026
|
+
}
|
|
1027
|
+
i.length > 60 && i.splice(0, 30), i.push(a, d, t), this.__publish(a, d, g);
|
|
1028
|
+
} else {
|
|
1029
|
+
var M = this.options.locking ? 3 : 0, ae = Math.abs(o - this.__initialTouchLeft), R = Math.abs(r - this.__initialTouchTop);
|
|
1030
|
+
this.__enableScrollX = this.options.scrollingX && ae >= M, this.__enableScrollY = this.options.scrollingY && R >= M, i.push(this.__scrollLeft, this.__scrollTop, t), this.__isDragging = (this.__enableScrollX || this.__enableScrollY) && (ae >= 5 || R >= 5), this.__isDragging && (this.__interruptedAnimation = !1);
|
|
1031
|
+
}
|
|
1032
|
+
this.__lastTouchLeft = o, this.__lastTouchTop = r, this.__lastTouchMove = t, this.__lastScale = n;
|
|
1033
|
+
}
|
|
1034
|
+
}, doTouchEnd: function(e) {
|
|
1035
|
+
if (e instanceof Date && (e = e.valueOf()), typeof e != "number") throw new Error("Invalid timestamp value: " + e);
|
|
1036
|
+
if (this.__isTracking) {
|
|
1037
|
+
if (this.__isTracking = !1, this.__isDragging) if (this.__isDragging = !1, this.__isSingleTouch && this.options.animating && e - this.__lastTouchMove <= 100) {
|
|
1038
|
+
for (var t = this.__positions, n = t.length - 1, o = n, r = n; r > 0 && t[r] > this.__lastTouchMove - 100; r -= 3) o = r;
|
|
1039
|
+
if (o !== n) {
|
|
1040
|
+
var i = t[n] - t[o], l = this.__scrollLeft - t[o - 2], s = this.__scrollTop - t[o - 1];
|
|
1041
|
+
this.__decelerationVelocityX = l / i * (1e3 / 60), this.__decelerationVelocityY = s / i * (1e3 / 60);
|
|
1042
|
+
var a = this.options.paging || this.options.snapping ? 4 : 1;
|
|
1043
|
+
(Math.abs(this.__decelerationVelocityX) > a || Math.abs(this.__decelerationVelocityY) > a) && this.__startDeceleration(e);
|
|
1044
|
+
} else this.options.scrollingComplete();
|
|
1045
|
+
} else e - this.__lastTouchMove > 100 && this.options.scrollingComplete();
|
|
1046
|
+
this.__isDecelerating || ((this.__interruptedAnimation || this.__isDragging) && this.options.scrollingComplete(), this.scrollTo(this.__scrollLeft, this.__scrollTop, !0, this.__zoomLevel)), this.__positions.length = 0;
|
|
1047
|
+
}
|
|
1048
|
+
}, __publish: function(e, t, n, o) {
|
|
1049
|
+
var r = this.__isAnimating;
|
|
1050
|
+
if (r && (jn(r), this.__isAnimating = !1), o && this.options.animating) {
|
|
1051
|
+
this.__scheduledLeft = e, this.__scheduledTop = t, this.__scheduledZoom = n;
|
|
1052
|
+
var i = this.__scrollLeft, l = this.__scrollTop, s = this.__zoomLevel, a = e - i, d = t - l, g = n - s, m = function(E, I, M) {
|
|
1053
|
+
M && (this.__scrollLeft = i + a * E, this.__scrollTop = l + d * E, this.__zoomLevel = s + g * E, this.__callback && this.__callback(this.__scrollLeft, this.__scrollTop, this.__zoomLevel));
|
|
1054
|
+
}.bind(this), f = function(E) {
|
|
1055
|
+
return this.__isAnimating === E;
|
|
1056
|
+
}.bind(this), x = function(E, I, M) {
|
|
1057
|
+
I === this.__isAnimating && (this.__isAnimating = !1), (this.__didDecelerationComplete || M) && this.options.scrollingComplete(), this.options.zooming && (this.__computeScrollMax(), this.__zoomComplete && (this.__zoomComplete(), this.__zoomComplete = null));
|
|
1058
|
+
}.bind(this);
|
|
1059
|
+
this.__isAnimating = Mr(m, f, x, this.options.animationDuration, r ? dl : ul);
|
|
1060
|
+
} 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));
|
|
1061
|
+
}, __computeScrollMax: function(e) {
|
|
1062
|
+
e === void 0 && (e = this.__zoomLevel), this.__maxScrollLeft = Math.max(this.__contentWidth * e - this.__clientWidth, 0), this.__maxScrollTop = Math.max(this.__contentHeight * e - this.__clientHeight, 0);
|
|
1063
|
+
}, __startDeceleration: function(e) {
|
|
1064
|
+
if (this.options.paging) {
|
|
1065
|
+
var t = Math.max(Math.min(this.__scrollLeft, this.__maxScrollLeft), 0), n = Math.max(Math.min(this.__scrollTop, this.__maxScrollTop), 0), o = this.__clientWidth, r = this.__clientHeight;
|
|
1066
|
+
this.__minDecelerationScrollLeft = Math.floor(t / o) * o, this.__minDecelerationScrollTop = Math.floor(n / r) * r, this.__maxDecelerationScrollLeft = Math.ceil(t / o) * o, this.__maxDecelerationScrollTop = Math.ceil(n / r) * r;
|
|
1067
|
+
} else this.__minDecelerationScrollLeft = 0, this.__minDecelerationScrollTop = 0, this.__maxDecelerationScrollLeft = this.__maxScrollLeft, this.__maxDecelerationScrollTop = this.__maxScrollTop;
|
|
1068
|
+
var i = function(d, g, m) {
|
|
1069
|
+
this.__stepThroughDeceleration(m);
|
|
1070
|
+
}.bind(this), l = this.options.snapping ? 4 : 0.1, s = function() {
|
|
1071
|
+
var d = Math.abs(this.__decelerationVelocityX) >= l || Math.abs(this.__decelerationVelocityY) >= l;
|
|
1072
|
+
return d || (this.__didDecelerationComplete = !0), d;
|
|
1073
|
+
}.bind(this), a = function(d, g, m) {
|
|
1074
|
+
this.__isDecelerating = !1, this.__didDecelerationComplete && this.options.scrollingComplete(), this.scrollTo(this.__scrollLeft, this.__scrollTop, this.options.snapping);
|
|
1075
|
+
}.bind(this);
|
|
1076
|
+
this.__isDecelerating = Mr(i, s, a);
|
|
1077
|
+
}, __stepThroughDeceleration: function(e) {
|
|
1078
|
+
var t = this.__scrollLeft + this.__decelerationVelocityX, n = this.__scrollTop + this.__decelerationVelocityY;
|
|
1079
|
+
if (!this.options.bouncing) {
|
|
1080
|
+
var o = Math.max(Math.min(this.__maxDecelerationScrollLeft, t), this.__minDecelerationScrollLeft);
|
|
1081
|
+
o !== t && (t = o, this.__decelerationVelocityX = 0);
|
|
1082
|
+
var r = Math.max(Math.min(this.__maxDecelerationScrollTop, n), this.__minDecelerationScrollTop);
|
|
1083
|
+
r !== n && (n = r, this.__decelerationVelocityY = 0);
|
|
1084
|
+
}
|
|
1085
|
+
if (e ? this.__publish(t, n, this.__zoomLevel) : (this.__scrollLeft = t, this.__scrollTop = n), !this.options.paging && (this.__decelerationVelocityX *= 0.95, this.__decelerationVelocityY *= 0.95), this.options.bouncing) {
|
|
1086
|
+
var i = 0, l = 0, s = this.options.penetrationDeceleration, a = this.options.penetrationAcceleration;
|
|
1087
|
+
t < this.__minDecelerationScrollLeft ? i = this.__minDecelerationScrollLeft - t : t > this.__maxDecelerationScrollLeft && (i = this.__maxDecelerationScrollLeft - t), n < this.__minDecelerationScrollTop ? l = this.__minDecelerationScrollTop - n : n > this.__maxDecelerationScrollTop && (l = this.__maxDecelerationScrollTop - n), i !== 0 && (i * this.__decelerationVelocityX <= 0 ? this.__decelerationVelocityX += i * s : this.__decelerationVelocityX = i * a), l !== 0 && (l * this.__decelerationVelocityY <= 0 ? this.__decelerationVelocityY += l * s : this.__decelerationVelocityY = l * a);
|
|
1088
|
+
}
|
|
1089
|
+
} };
|
|
1090
|
+
var Gt = typeof window < "u" ? window : { screen: {}, navigator: {} }, Ln = (Gt.matchMedia || function() {
|
|
1091
|
+
return { matches: !1 };
|
|
1092
|
+
}).bind(Gt), ai = !1, hl = { get passive() {
|
|
1093
|
+
return ai = !0;
|
|
1094
|
+
} }, Tr = function() {
|
|
1095
|
+
};
|
|
1096
|
+
Gt.addEventListener && Gt.addEventListener("p", Tr, hl), Gt.removeEventListener && Gt.removeEventListener("p", Tr, !1);
|
|
1097
|
+
var fl = ai, pl = "PointerEvent" in Gt, tr = "ontouchstart" in Gt, di = tr || "TouchEvent" in Gt && Ln("(any-pointer: coarse)").matches, Rr = (Gt.navigator.maxTouchPoints || 0) > 0 || di, ui = Gt.navigator.userAgent || "", gl = Ln("(pointer: coarse)").matches && /iPad|Macintosh/.test(ui) && Math.min(Gt.screen.width || 0, Gt.screen.height || 0) >= 768, hi = (Ln("(pointer: coarse)").matches || !Ln("(pointer: fine)").matches && tr) && !/Windows.*Firefox/.test(ui), wl = Ln("(any-pointer: fine)").matches || Ln("(any-hover: hover)").matches || gl || !tr, Uo = !Rr || !wl && hi ? Rr ? "touchOnly" : "mouseOnly" : "hybrid", ml = Uo === "mouseOnly" ? "mouse" : Uo === "touchOnly" || hi ? "touch" : "mouse";
|
|
1098
|
+
const xl = Object.freeze(Object.defineProperty({ __proto__: null, deviceType: Uo, primaryInput: ml, supportsPassiveEvents: fl, supportsPointerEvents: pl, supportsTouchEvents: di }, Symbol.toStringTag, { value: "Module" })), vl = /* @__PURE__ */ new Set(["INPUT", "TEXTAREA", "SELECT"]), fi = {};
|
|
1099
|
+
function qo() {
|
|
1100
|
+
return xl;
|
|
1101
|
+
}
|
|
1102
|
+
const me = Object.freeze(Object.defineProperty({ __proto__: null, EmptyCssProperties: fi, boundPixel: function(e, t = !1, n = 0) {
|
|
1103
|
+
return e;
|
|
1104
|
+
}, createSyntheticEvent: (e) => {
|
|
1105
|
+
let t = !1, n = !1;
|
|
1106
|
+
return { nativeEvent: e, currentTarget: e.currentTarget, target: e.target, bubbles: e.bubbles, cancelable: e.cancelable, defaultPrevented: e.defaultPrevented, eventPhase: e.eventPhase, isTrusted: e.isTrusted, preventDefault: () => {
|
|
1107
|
+
t = !0, e.preventDefault();
|
|
1108
|
+
}, isDefaultPrevented: () => t, stopPropagation: () => {
|
|
1109
|
+
n = !0, e.stopPropagation();
|
|
1110
|
+
}, isPropagationStopped: () => n, persist: () => {
|
|
1111
|
+
}, timeStamp: e.timeStamp, type: e.type };
|
|
1112
|
+
}, detectIt: qo, focusableNodeNames: vl, toPrettyKeyCode: (e) => e === "BracketLeft" ? "[" : e === "BracketRight" ? "]" : Ct.camelToPrettyCase(e) }, Symbol.toStringTag, { value: "Module" })), yl = [];
|
|
1113
|
+
function wo(e, t, n = yl) {
|
|
1114
|
+
const o = J(null);
|
|
1115
|
+
return Ur(e, () => {
|
|
1116
|
+
if (!o.current) return;
|
|
1117
|
+
const r = o.current, i = t?.();
|
|
1118
|
+
if (!i || typeof i != "object") throw new Error("attributes must return a plain object of values");
|
|
1119
|
+
const l = Object.keys(i), s = l.length;
|
|
1120
|
+
for (let a = 0; a < s; a++) {
|
|
1121
|
+
const d = l[a], g = i[d];
|
|
1122
|
+
Object.defineProperty(r, d, { value: g, writable: !0, configurable: !0, enumerable: !0 });
|
|
1123
|
+
}
|
|
1124
|
+
return r;
|
|
1125
|
+
}, n), o;
|
|
1126
|
+
}
|
|
1127
|
+
const kr = (e) => Y(er, { ...e }), bl = ({ width: e, height: t }) => Y("div", { className: "corner", style: { minWidth: `${e}px`, width: `${e}px`, minHeight: `${t}px`, height: `${t}px` } }), pi = Dt(Ut((e, t) => {
|
|
1128
|
+
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, E = T(r, [r]), I = wo(t, () => ({ isScrollPane: () => !0 }), []), M = J(null);
|
|
1129
|
+
st(() => {
|
|
1130
|
+
M.current && (M.current.__scrollTop === o?.top && M.current.__scrollLeft !== !o?.left || M.current?.scrollTo(o?.left, o?.top, !1));
|
|
1131
|
+
}, [o?.left, o?.top, m]);
|
|
1132
|
+
const ae = O((k, u) => {
|
|
1133
|
+
E?.({ left: k, top: u });
|
|
1134
|
+
}, []), R = O((k) => {
|
|
1135
|
+
M.current?.doTouchStart(k.touches, k.timeStamp);
|
|
1136
|
+
}, []), _ = O((k) => {
|
|
1137
|
+
k.preventDefault(), M.current?.doTouchMove(k.touches, k.timeStamp);
|
|
1138
|
+
}, []), L = O((k) => {
|
|
1139
|
+
M.current?.doTouchEnd(k.timeStamp);
|
|
1140
|
+
}, []), le = O(({ containerWidth: k, containerHeight: u, totalWidth: C, totalHeight: ee }) => {
|
|
1141
|
+
M.current.setDimensions(k, u, C, ee);
|
|
1142
|
+
}, []);
|
|
1143
|
+
st(() => {
|
|
1144
|
+
const k = m ?? I.current;
|
|
1145
|
+
if (!f && qo().supportsTouchEvents && k && o) {
|
|
1146
|
+
if (!M.current) {
|
|
1147
|
+
const u = { scrollingX: !0, scrollingY: !0, decelerationRate: 0.95, penetrationAcceleration: 0.08 };
|
|
1148
|
+
M.current = new ci(ae, u);
|
|
1149
|
+
}
|
|
1150
|
+
qo().supportsTouchEvents && (k.addEventListener("touchstart", R), k.addEventListener("touchend", L), k.addEventListener("touchmove", _)), le({ containerWidth: o?.width, containerHeight: o?.height, totalWidth: o?.totalWidth, totalHeight: o?.totalHeight });
|
|
1151
|
+
}
|
|
1152
|
+
return () => {
|
|
1153
|
+
k?.removeEventListener("touchstart", R), k?.removeEventListener("touchend", L), k?.removeEventListener("touchmove", _);
|
|
1154
|
+
};
|
|
1155
|
+
}, [o?.width, o?.height, o?.totalWidth, o?.totalHeight, f, m]);
|
|
1156
|
+
const [$, { width: oe }] = In(), [be, { height: U }] = In(), H = Ee(() => {
|
|
1157
|
+
const k = d({ orientation: mn.Vertical, offset: o?.top, viewportSize: o?.height, totalSize: o?.totalHeight, onScrollOffset: (u) => {
|
|
1158
|
+
E?.({ top: u });
|
|
1159
|
+
} });
|
|
1160
|
+
return Y("div", { style: { display: "flex", flex: "0" }, ref: $, children: k });
|
|
1161
|
+
}, [d, o?.top, o?.height, o?.totalHeight]), X = Ee(() => {
|
|
1162
|
+
const k = a({ orientation: mn.Horizontal, offset: o?.left, viewportSize: o?.width, totalSize: o?.totalWidth, onScrollOffset: (u) => E?.({ left: u }) });
|
|
1163
|
+
return Ht("div", { style: { display: "flex", flex: "none", flexDirection: "row", alignItems: "stretch", justifyContent: "center" }, children: [Y("div", { style: { display: "flex", flex: "1 1 100%", flexDirection: "column", width: `calc(100% - ${oe}px)` }, children: Y("div", { ref: be, className: "sizer", children: k }) }), l ? s({ width: oe, height: U }) : Y(wn, {})] });
|
|
1164
|
+
}, [a, o?.left, o?.width, o?.totalWidth, l, s, oe, U]);
|
|
1165
|
+
return Y("div", { style: { position: "relative", display: "flex", minWidth: l ? `${oe}px` : void 0, minHeight: i ? `${U}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: [Y("div", { style: { display: "flex", flex: "1 1 100%", overflow: "hidden" }, children: n }), l ? H : Y(wn, {})] }), i ? X : Y(wn, {})] }) });
|
|
1166
|
+
}));
|
|
1167
|
+
pi.displayName = "ScrollPane";
|
|
1168
|
+
const Sl = () => {
|
|
1169
|
+
const e = document.fullscreenElement;
|
|
1170
|
+
return e ? e.querySelector(".fullscreen-portal-root") || e : document.body;
|
|
1171
|
+
};
|
|
1172
|
+
let no = 0;
|
|
1173
|
+
function gi() {
|
|
1174
|
+
return st(() => {
|
|
1175
|
+
function e() {
|
|
1176
|
+
const t = document.fullscreenElement;
|
|
1177
|
+
if (!t) return;
|
|
1178
|
+
let n = t.querySelector(".fullscreen-portal-root");
|
|
1179
|
+
n || (n = document.createElement("div"), n.className = "fullscreen-portal-root _fullscreen-portal-root_5qk7s_7", t.appendChild(n));
|
|
1180
|
+
}
|
|
1181
|
+
return no++, e(), document.addEventListener("fullscreenchange", e), () => {
|
|
1182
|
+
document.removeEventListener("fullscreenchange", e), no--, no <= 0 && (document.querySelectorAll(".fullscreen-portal-root").forEach((t) => {
|
|
1183
|
+
t.parentNode && t.parentNode.removeChild(t);
|
|
1184
|
+
}), no = 0);
|
|
1185
|
+
};
|
|
1186
|
+
}, []), { getPortalContainer: Sl };
|
|
1187
|
+
}
|
|
1188
|
+
const El = 100, _l = 100, Il = 1e6, Cl = 100, Ml = 50, Tl = Dt(Ut((e, t) => {
|
|
1189
|
+
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: E = Ml, ...I } = e;
|
|
1190
|
+
m && console.warn("onScroll not supported for VirtualScrollbar. Use onScrollOffset instead");
|
|
1191
|
+
const M = T(d, [d]), ae = () => ({ offset: n, totalSize: f === 0 ? r : Math.min(r ?? 0, Math.max(i ?? 0, (n ?? 0) + (o ?? 0)) + (l ?? 0)) }), [R, _] = Je(ae), L = f !== 0 && R.totalSize > f ? x : 1, le = L / E, $ = Math.ceil(R.totalSize / L), oe = Math.ceil(R.offset / L), be = Math.ceil(o / L), U = O((W) => {
|
|
1192
|
+
}, []), [H, X] = Je(!1), k = J(null);
|
|
1193
|
+
nn(() => {
|
|
1194
|
+
if (!H) {
|
|
1195
|
+
k.current = { propTotalSize: r, propViewportSize: o, propOffset: n };
|
|
1196
|
+
const W = ae();
|
|
1197
|
+
_(W);
|
|
1198
|
+
}
|
|
1199
|
+
}, [r, o, n, H, i, l, s]);
|
|
1200
|
+
const u = T((W, A, q) => {
|
|
1201
|
+
const N = k.current;
|
|
1202
|
+
k.current = null, N && N.propTotalSize === r && N.propViewportSize === o && N.propOffset === n || (Math.abs(W - oe) < le && (W = oe), g?.(W * L, oe, be));
|
|
1203
|
+
}, [g, L, le, oe, be]), C = O((W) => {
|
|
1204
|
+
document.removeEventListener("mousemove", U), document.removeEventListener("mouseup", C), X(!1);
|
|
1205
|
+
}, []), ee = O((W) => {
|
|
1206
|
+
M?.(W), X(!0), document.addEventListener("mousemove", U, { passive: !0 }), document.addEventListener("mouseup", C, { passive: !0 });
|
|
1207
|
+
}, [U, C]);
|
|
1208
|
+
return Y(er, { ref: t, style: { ...a }, ...I, offset: oe, totalSize: $, viewportSize: be, onMouseDown: ee, onScrollOffset: u });
|
|
1209
|
+
}));
|
|
1210
|
+
function Do(e, t) {
|
|
1211
|
+
if (typeof e == "function") return e(t);
|
|
1212
|
+
e && (e.current = t);
|
|
1213
|
+
}
|
|
1214
|
+
Tl.displayName = "VirtualScrollbar";
|
|
1215
|
+
var fo = parseInt(qr.split(".")[0], 10) >= 19 ? function(e) {
|
|
1216
|
+
return (t) => {
|
|
1217
|
+
const n = [];
|
|
1218
|
+
for (const o of e) {
|
|
1219
|
+
const r = Do(o, t), i = typeof r == "function";
|
|
1220
|
+
n.push(i ? r : () => Do(o, null));
|
|
1221
|
+
}
|
|
1222
|
+
return () => {
|
|
1223
|
+
for (const o of n) o();
|
|
1224
|
+
};
|
|
1225
|
+
};
|
|
1226
|
+
} : function(e) {
|
|
1227
|
+
return (t) => {
|
|
1228
|
+
for (const n of e) Do(n, t);
|
|
1229
|
+
};
|
|
1230
|
+
};
|
|
1231
|
+
Dt(Ut((e, t) => {
|
|
1232
|
+
const { refFocusStart: n, ...o } = e, r = J(null), i = O(() => {
|
|
1233
|
+
if (n) return void n?.current?.focus();
|
|
1234
|
+
const l = r.current.parentElement.children;
|
|
1235
|
+
let s = [];
|
|
1236
|
+
for (let a = 0; a < l.length && l[a] !== r.current; a++) {
|
|
1237
|
+
const d = l[a].getAttribute("tabindex");
|
|
1238
|
+
if (d == null || d === "-1" || l[a].getAttribute("disabled") === "true") continue;
|
|
1239
|
+
const g = l[a];
|
|
1240
|
+
g.focus && s.push({ tabindex: parseInt(d), child: g });
|
|
1241
|
+
}
|
|
1242
|
+
s.length !== 0 && (s.sort(function(a, d) {
|
|
1243
|
+
return a.tabindex - d.tabindex;
|
|
1244
|
+
}), s[0].child.focus());
|
|
1245
|
+
}, [n]);
|
|
1246
|
+
return Y("div", { tabIndex: 0, ref: fo([r, t]), onFocus: i, ...o });
|
|
1247
|
+
})), Dt(Ut((e, t) => {
|
|
1248
|
+
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 = J(null), x = (ae, R = 0) => {
|
|
1249
|
+
const _ = ae / 2, L = m - _ + R;
|
|
1250
|
+
return function(le, $, oe = !1) {
|
|
1251
|
+
if ($ === 0) return le;
|
|
1252
|
+
function be(C, ee, W) {
|
|
1253
|
+
let A = ee.x - C.x, q = ee.y - C.y, N = Math.sqrt(A * A + q * q);
|
|
1254
|
+
return U(C, ee, Math.min(1, W / N));
|
|
1255
|
+
}
|
|
1256
|
+
function U(C, ee, W) {
|
|
1257
|
+
return { x: C.x + (ee.x - C.x) * W, y: C.y + (ee.y - C.y) * W };
|
|
1258
|
+
}
|
|
1259
|
+
function H(C, ee) {
|
|
1260
|
+
C.length > 2 && (C[C.length - 2] = ee.x, C[C.length - 1] = ee.y);
|
|
1261
|
+
}
|
|
1262
|
+
function X(C) {
|
|
1263
|
+
return { x: parseFloat(C[C.length - 2]), y: parseFloat(C[C.length - 1]) };
|
|
1264
|
+
}
|
|
1265
|
+
let k = le.split(/[,\s]/).reduce(function(C, ee) {
|
|
1266
|
+
let W = ee.match("([a-zA-Z])(.+)");
|
|
1267
|
+
return W ? (C.push(W[1]), C.push(W[2])) : C.push(ee), C;
|
|
1268
|
+
}, []).reduce(function(C, ee) {
|
|
1269
|
+
return parseFloat(ee) == ee && C.length ? C[C.length - 1].push(ee) : C.push([ee]), C;
|
|
1270
|
+
}, []), u = [];
|
|
1271
|
+
if (k.length > 1) {
|
|
1272
|
+
let C = X(k[0]), ee = null;
|
|
1273
|
+
k[k.length - 1][0] === "Z" && k[0].length > 2 && (ee = ["L", C.x, C.y], k[k.length - 1] = ee), u.push(k[0]);
|
|
1274
|
+
for (let W = 1; W < k.length; W++) {
|
|
1275
|
+
let A = u[u.length - 1], q = k[W], N = q === ee ? k[1] : k[W + 1];
|
|
1276
|
+
if (N && A && A.length > 2 && q[0] === "L" && N.length > 2 && N[0] === "L") {
|
|
1277
|
+
let xe, G, He = X(A), Ue = X(q), We = X(N);
|
|
1278
|
+
oe ? (xe = U(Ue, A.origPoint || He, $), G = U(Ue, N.origPoint || We, $)) : (xe = be(Ue, He, $), G = be(Ue, We, $)), H(q, xe), q.origPoint = Ue, u.push(q);
|
|
1279
|
+
let ht = U(xe, Ue, 0.5), _e = U(Ue, G, 0.5), S = ["C", ht.x, ht.y, _e.x, _e.y, G.x, G.y];
|
|
1280
|
+
S.origPoint = Ue, u.push(S);
|
|
1281
|
+
} else u.push(q);
|
|
1282
|
+
}
|
|
1283
|
+
if (ee) {
|
|
1284
|
+
let W = X(u[u.length - 1]);
|
|
1285
|
+
u.push(["Z"]), H(u[0], W);
|
|
1286
|
+
}
|
|
1287
|
+
} else u = k;
|
|
1288
|
+
return u.reduce(function(C, ee) {
|
|
1289
|
+
return C + ee.join(" ") + " ";
|
|
1290
|
+
}, "");
|
|
1291
|
+
}(`M 0 ${_} L ${i - 0.5} ${_} L ${i - 0.5} ${L} L ${2 * i} ${L} L ${g - 2 * i} ${L} M ${g - 2 * i} ${L} L ${g - i} ${L} L ${g - i} ${_} L ${g} ${_}`, i);
|
|
1292
|
+
}, E = Ee(() => x(l), [g, m, i, l]), I = Ee(() => {
|
|
1293
|
+
if (i === 0) return;
|
|
1294
|
+
const ae = i / 2;
|
|
1295
|
+
return x(i) + `L ${g} 0 L 0 0 L 0 ${ae}`;
|
|
1296
|
+
}, [E, i, l]), M = Ee(() => ({ style: { clipPath: `path('${I}')` } }), [I]);
|
|
1297
|
+
return Ht("div", { className: n, style: { display: "flex", flexDirection: "row", ...o }, ...a, ref: fo([f, d, t]), children: [Sn.isValidElement(r) ? Sn.cloneElement(r, M) : Y(wn, {}), Y("svg", { style: { position: "absolute", top: 0, left: 0, pointerEvents: "none" }, width: g, height: m, viewBox: `0 0 ${g} ${m}`, children: Y("path", { d: E, stroke: s, fill: "none", vectorEffect: "non-scaling-stroke", strokeWidth: l }) })] });
|
|
1298
|
+
}));
|
|
1299
|
+
const Rl = {}, kl = (e) => {
|
|
1300
|
+
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;
|
|
1301
|
+
return Y("div", { style: { ...n, position: "relative" }, ...d, children: Y("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);
|
|
1302
|
+
}, 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) => {
|
|
1303
|
+
if (e == null) return null;
|
|
1304
|
+
const n = { percent: null, pixels: null };
|
|
1305
|
+
let o = t;
|
|
1306
|
+
return typeof e == "string" && ((e = e.trim().toLowerCase()).endsWith("px") ? (e = e.substring(0, e.length - 2), o = !1) : e.endsWith("%") && (e = e.substring(0, e.length - 1), o = !0), e = parseFloat(e)), o ? n.percent = e : n.pixels = e, Object.freeze(n);
|
|
1307
|
+
};
|
|
1308
|
+
function On(e) {
|
|
1309
|
+
if (!e) throw new Error("must have a PointerHandlerOptions");
|
|
1310
|
+
const { onPointerDown: t, onPointerUp: n, onPointerMoveOrWait: o, processTouch: r = !1, consumeTouch: i = !0 } = e, l = T(t, [t]), s = T(n, [n]), a = T(o, [o]), d = J(!1), g = e?.timerInitial ?? 230, m = e?.timerContinuous ?? g / 2, f = J(null), x = J(null), E = J(null), I = J(null), M = O(() => {
|
|
1311
|
+
I.current && (clearTimeout(I.current), I.current = null);
|
|
1312
|
+
}, []), ae = O((H) => {
|
|
1313
|
+
I.current = setTimeout(() => {
|
|
1314
|
+
window.requestAnimationFrame(() => {
|
|
1315
|
+
d.current !== !1 && a?.(x.current, E.current, f.current);
|
|
1316
|
+
}), ae(m);
|
|
1317
|
+
}, H ?? g);
|
|
1318
|
+
}, []);
|
|
1319
|
+
st(() => () => M(), []);
|
|
1320
|
+
const R = r ? "pointer" : "mouse", _ = O((H) => {
|
|
1321
|
+
H.stopPropagation(), H.stopImmediatePropagation(), H.preventDefault();
|
|
1322
|
+
}, []), L = T((H) => {
|
|
1323
|
+
document.removeEventListener(`${R}move`, oe), document.removeEventListener(`${R}up`, L), document.removeEventListener("keydown", be), document.removeEventListener("keyup", U), document.removeEventListener("touchstart", _, { capture: !0 }), document.removeEventListener("touchmove", _, { capture: !0 }), window.removeEventListener("blur", le), M(), window.requestAnimationFrame(() => {
|
|
1324
|
+
d.current !== !1 && (d.current = !1, s?.(H, E.current, f.current), E.current = null);
|
|
1325
|
+
});
|
|
1326
|
+
}, []), le = O(() => {
|
|
1327
|
+
d.current !== !1 && (d.current = !1, L(x.current));
|
|
1328
|
+
}, []), $ = T(() => {
|
|
1329
|
+
M(), ae(m), window.requestAnimationFrame(() => {
|
|
1330
|
+
d.current !== !1 && a?.(x.current, E.current, f.current);
|
|
1331
|
+
});
|
|
1332
|
+
}, [m]), oe = T((H) => {
|
|
1333
|
+
x.current = H, $();
|
|
1334
|
+
}, []), be = T((H) => {
|
|
1335
|
+
E.current = { ctrlKey: H.ctrlKey, shiftKey: H.shiftKey, altKey: H.altKey, metaKey: H.metaKey }, $();
|
|
1336
|
+
}, []), U = T((H) => {
|
|
1337
|
+
E.current = { ctrlKey: H.ctrlKey, shiftKey: H.shiftKey, altKey: H.altKey, metaKey: H.metaKey }, $();
|
|
1338
|
+
}, [m]);
|
|
1339
|
+
return T((H) => {
|
|
1340
|
+
H.isDefaultPrevented() || (E.current = { ctrlKey: H.ctrlKey, shiftKey: H.shiftKey, altKey: H.altKey, metaKey: H.metaKey }, l(H, E.current) !== !1 && (f.current = H, x.current = H.nativeEvent, document.addEventListener(`${R}up`, L, { passive: !1 }), document.addEventListener(`${R}move`, oe, { passive: !1 }), document.addEventListener("keydown", be, { passive: !1 }), document.addEventListener("keyup", U, { passive: !1 }), window.addEventListener("blur", le, { passive: !0 }), r && i && (document.addEventListener("touchstart", _, { passive: !1, capture: !0 }), document.addEventListener("touchmove", _, { passive: !1, capture: !0 })), d.current = !0, ae(g)));
|
|
1341
|
+
}, [g, r]);
|
|
1342
|
+
}
|
|
1343
|
+
Dt(Ut((e, t) => {
|
|
1344
|
+
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: E, disabled: I = !1, onDragStart: M, onDragResize: ae, onDragFinish: R, resizerProps: _ = oo, paneProps: L = oo, paneBeforeProps: le = oo, paneAfterProps: $ = oo, createResizer: oe = kl } = e;
|
|
1345
|
+
if (f) throw new Error("Use elementBefore and elementAfter instead of children.");
|
|
1346
|
+
const be = Ee(() => Sn.isValidElement(o) && Sn.isValidElement(n), [o, n]), U = Ee(() => {
|
|
1347
|
+
let Q = null;
|
|
1348
|
+
i && (i === "before" ? Q = 0 : i === "after" && (Q = 1));
|
|
1349
|
+
const et = Q === null;
|
|
1350
|
+
return { fixedPaneOffset: Q, isPercent: et, minBefore: pn(a, et), maxBefore: pn(d, et), minAfter: pn(g, et), maxAfter: pn(m, et) };
|
|
1351
|
+
}, [a, d, g, m]), H = T(s, [s]), [X, k] = Je(() => pn(l, i === null));
|
|
1352
|
+
st(() => {
|
|
1353
|
+
k(pn(l, i === null));
|
|
1354
|
+
}, [l, i]);
|
|
1355
|
+
const [u, { width: C, height: ee }] = In(), [W, { width: A, height: q }] = In(), N = r === "row" ? A : q, xe = r === "row" ? C : ee, G = Ee(() => ((Q, et, qe, dt) => {
|
|
1356
|
+
const Ie = [null, null], Le = [null, null];
|
|
1357
|
+
if (Q || (Q = { percent: dt.fixedPaneOffset === null ? 50 : null, pixels: dt.fixedPaneOffset === null ? null : 0 }), et === 0) return Q?.pixels != null ? dt.fixedPaneOffset !== 1 ? (Ie[0] = Q?.pixels, Le[1] = 100) : (Ie[1] = Q?.pixels - qe, Le[0] = 100) : Q?.percent != null && (dt.fixedPaneOffset !== 1 ? (Le[0] = Q?.percent, Le[1] = 100 - Q?.percent) : (Le[1] = Q?.percent, Le[0] = 100 - Q?.percent)), { percents: Le, pixels: Ie, minBefore: ro(dt.minBefore, !0), maxBefore: ro(dt.maxBefore, !0), minAfter: ro(dt.minAfter), maxAfter: ro(dt.maxAfter) };
|
|
1358
|
+
let rt = bn(Q, et, dt.fixedPaneOffset !== 1), tt = et - qe, Ae = bn(dt.minBefore, tt, !0) ?? 0, rn = bn(dt.maxBefore, tt, !0) ?? tt, Mt = 0, nt = 0, Tt = 0, kt = tt;
|
|
1359
|
+
Mt = (bn(dt.maxAfter, et, !1) ?? qe) - qe, nt = bn(dt.minAfter, et, !1) ?? et, Tt = Math.max(Ae, Mt), kt = Math.min(rn, nt), rt = Math.max(Tt, Math.min(rt, kt)), nt = Math.min(tt - rt, bn(dt.maxAfter, tt - rt, !0) ?? tt), Mt = Math.min(tt - rt, bn(dt.minAfter, tt - rt, !0) ?? tt), Ie[0] = rt, Ie[1] = tt - Ie[0];
|
|
1360
|
+
const hn = Math.max(0, Math.min(100, rt / tt * 100));
|
|
1361
|
+
return Le[0] = hn, Le[1] = 100 - Le[0], { percents: Le, pixels: Ie, minBefore: `${Ae}px`, minAfter: `${Mt}px`, maxBefore: `${Ie[0]}px`, maxAfter: `${Ie[1]}px` };
|
|
1362
|
+
})(X, xe, N, U), [U, X, xe, N, r]), [He, Ue] = Je(!1), We = T(M, [M]), ht = T(ae, [ae]), _e = T(R, [R]), S = J(null), ue = J(null), K = J(null), { style: pe, className: te, ...Re } = L, at = { minWidth: 0, minHeight: 0, maxWidth: "100%", maxHeight: "100%", display: "flex", overflow: "hidden", ...pe }, { className: pt, style: zt, ...gt } = le, { className: Zt, style: Be, ...z } = $, ke = { flex: "1 1 100%", width: "100%", ...E, flexDirection: r, display: "flex" }, { className: Qe, style: Xe, onPointerDown: wt, ...an } = _, Jt = T((Q) => {
|
|
1363
|
+
const et = pn(Q, i === null);
|
|
1364
|
+
k(et);
|
|
1365
|
+
}, [i]), jt = T((Q) => {
|
|
1366
|
+
if (I || !He) return;
|
|
1367
|
+
const et = ze.current?.getBoundingClientRect();
|
|
1368
|
+
let qe = 0;
|
|
1369
|
+
qe = r === "row" ? (Q.clientX ?? Q.touches?.[0]?.clientX) - et.x : (Q.clientY ?? Q.touches?.[0]?.clientY) - et.y, qe = Math.max(0, Math.min(xe, qe)), U.fixedPaneOffset === 1 && (qe = xe - qe), l && X.pixels === qe || k({ pixels: qe, percent: null }), ht?.(qe), Q.stopPropagation(), Q.preventDefault();
|
|
1370
|
+
}, [U, r, I, He, X, xe]), dn = T((Q) => {
|
|
1371
|
+
if (document.removeEventListener("pointermove", jt), document.removeEventListener("touchmove", jt), document.removeEventListener("pointerup", dn), He && (Ue(!1), X)) {
|
|
1372
|
+
if (_e(X.pixels), !pn(l, i === null) || X.pixels !== l) {
|
|
1373
|
+
const et = { ...X };
|
|
1374
|
+
et.percent === null && (et.percent = et.pixels / xe * 100), H(et);
|
|
1375
|
+
}
|
|
1376
|
+
Q.stopPropagation(), Q.preventDefault();
|
|
1377
|
+
}
|
|
1378
|
+
}, [X, He, l, i, xe]), on = T((Q) => {
|
|
1379
|
+
wt?.(Q), Q.defaultPrevented || I || He || (Ue(!0), We(), document.addEventListener("pointermove", jt, { passive: !1 }), document.addEventListener("touchmove", jt, { passive: !1 }), document.addEventListener("pointerup", dn, { passive: !1 }));
|
|
1380
|
+
}, [wt]), ze = wo(t, () => ({ setPosition: Jt, isSplitPane: () => !0 }), []), qt = Ee(() => be ? oe?.({ key: "resizer", ref: fo([W, ue]), className: Rn("resizer", Qe), onPointerDownCapture: on, style: { cursor: I ? void 0 : r === "row" ? "ew-resize" : "ns-resize", minWidth: r === "row" ? "2px" : void 0, minHeight: r !== "row" ? "2px" : void 0, boxSizing: "border-box", pointerEvents: "all", zIndex: 1, ...Xe }, splitDirection: r, disabled: I, ...an }) : null, [be, Qe, an, r, Xe, I]), vt = r === "row" ? "Width" : "Height", Vt = { ...at, ...zt, flex: U.fixedPaneOffset === 0 && G?.pixels[0] !== null ? `0 0 ${Math.round(G?.pixels[0])}px` : `1 1 ${Math.round(G?.percents[0] ?? 100)}%`, [`min${vt}`]: G?.minBefore, [`max${vt}`]: o ? G?.maxBefore : "100%" }, Cn = { ...at, ...Be, flex: U.fixedPaneOffset === 1 && G?.pixels[1] !== null ? `0 0 ${Math.round(G?.pixels[1])}px` : `1 1 ${Math.round(G?.percents[1] ?? 100)}%`, [`min${vt}`]: G?.minAfter, [`max${vt}`]: n ? G?.maxAfter : "100%" }, un = Ee(() => n ? Y("div", { ref: S, className: Rn("before", te, pt), style: Vt, ...Re, ...gt, children: n }, "before") : null, [n, L, le, U, G]), Ne = Ee(() => o ? Y("div", { ref: K, className: Rn("after", te, Zt), style: Cn, ...Re, ...z, children: o }, "after") : null, [o, L, $, U, G]);
|
|
1381
|
+
return Ht("div", { ref: fo([u, ze]), className: Rn("splitPane", r === "row" ? "vertical" : "horizontal", { dragging: He }, x), style: ke, children: [un, qt, Ne] });
|
|
1382
|
+
}));
|
|
1383
|
+
const Pl = ({ initValue: e, useHookBody: t, applyStateChange: n }) => {
|
|
1384
|
+
const o = J(e);
|
|
1385
|
+
if (typeof t != "function") throw new Error("function expected as hook body parameter. got " + typeof t);
|
|
1386
|
+
const r = t();
|
|
1387
|
+
return nn(() => {
|
|
1388
|
+
o.current !== r && (o.current = r, n(r));
|
|
1389
|
+
}, [n, r]), null;
|
|
1390
|
+
}, Ko = (e) => {
|
|
1391
|
+
console && console.warn && console.warn(e);
|
|
1392
|
+
}, zo = typeof self == "object" && self.self === self && self || typeof global == "object" && global.global === global && global || void 0;
|
|
1393
|
+
let Ol = 1, Yo = !1, wi = !1;
|
|
1394
|
+
const co = [], kn = [], po = () => {
|
|
1395
|
+
kn.forEach((e) => e());
|
|
1396
|
+
}, Ll = ({ automaticContainerInternalUseOnly: e }) => {
|
|
1397
|
+
const [t, n] = Je([]), o = J([]);
|
|
1398
|
+
return o.current = t, e || Yo !== !1 || (wi = !0), st(() => {
|
|
1399
|
+
let r = !0;
|
|
1400
|
+
function i() {
|
|
1401
|
+
if (r) return kn[0] !== i ? (e || Yo !== !0 || Ko("SingletonHooksContainer is mounted after some singleton hook has been used.Your SingletonHooksContainer will not be used in favor of internal one."), void n((l) => [])) : void n([...co]);
|
|
1402
|
+
}
|
|
1403
|
+
return kn.push(i), po(), () => {
|
|
1404
|
+
r = !1, o.current?.length > 0 && Ko("SingletonHooksContainer is unmounted, but it has active singleton hooks. They will be reevaluated once SingletonHooksContainer is mounted again"), kn.splice(kn.indexOf(i), 1), po();
|
|
1405
|
+
};
|
|
1406
|
+
}, [e]), Y(wn, { children: t.map(({ hook: r, key: i }) => Jo(Pl, { ...r, key: i })) });
|
|
1407
|
+
}, mi = (e, t, n = {}) => {
|
|
1408
|
+
let o, r, i = !1, l = !1, s = [], { unmountIfNoConsumers: a = !1 } = n;
|
|
1409
|
+
const d = (m) => {
|
|
1410
|
+
r = m, Li(() => s.forEach((f) => f(m)));
|
|
1411
|
+
}, g = () => (l || (r = typeof e == "function" ? e() : e, l = !0), r);
|
|
1412
|
+
return () => {
|
|
1413
|
+
const [m, f] = Je(g);
|
|
1414
|
+
return st(() => (i || (i = !0, o = ((x) => {
|
|
1415
|
+
const E = Ol++;
|
|
1416
|
+
return co.push({ hook: x, key: E }), kn.length === 0 && wi === !1 && (Yo = !0, ((I) => {
|
|
1417
|
+
if (zo.document && zo.document.createElement) {
|
|
1418
|
+
const M = zo.document.createElement("div");
|
|
1419
|
+
Oi(M).render(Y(I, { automaticContainerInternalUseOnly: !0 }));
|
|
1420
|
+
} else Ko("Can not mount SingletonHooksContainer on server side. Did you manage to run useEffect on server? Please mount SingletonHooksContainer into your components tree manually.");
|
|
1421
|
+
})(Ll)), po(), () => {
|
|
1422
|
+
co.splice(co.findIndex((I) => I.key === E), 1), po();
|
|
1423
|
+
};
|
|
1424
|
+
})({ initValue: e, useHookBody: t, applyStateChange: d })), s.push(f), r !== m && f(r), () => {
|
|
1425
|
+
s.splice(s.indexOf(f), 1), s.length === 0 && a && (o(), i = !1);
|
|
1426
|
+
}), []), m;
|
|
1427
|
+
};
|
|
1428
|
+
};
|
|
1429
|
+
mi(null, () => {
|
|
1430
|
+
const [e, t] = Je(null);
|
|
1431
|
+
return e;
|
|
1432
|
+
});
|
|
1433
|
+
class Dl {
|
|
1434
|
+
constructor(t, n, o, r) {
|
|
1435
|
+
this._listenersProperties = /* @__PURE__ */ new Set(), this._listenersExecute = /* @__PURE__ */ new Set(), this._key = t, this._target = n, this._applyProps(o || {}), this._callback = r, r === void 0 && (this._callback = () => {
|
|
1436
|
+
console.log(`implement: ${this.label()} : ${this.description()}`);
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
key() {
|
|
1440
|
+
return this._key;
|
|
1441
|
+
}
|
|
1442
|
+
_resolve(t, n) {
|
|
1443
|
+
if (typeof t == "function") {
|
|
1444
|
+
const o = n ?? this._context;
|
|
1445
|
+
return t(typeof o == "function" ? o() : o);
|
|
1446
|
+
}
|
|
1447
|
+
return t;
|
|
1448
|
+
}
|
|
1449
|
+
target() {
|
|
1450
|
+
return typeof this._target == "function" ? this._target() : this._target;
|
|
1451
|
+
}
|
|
1452
|
+
label(t, n) {
|
|
1453
|
+
const o = this._scopedLabels?.[t] || this._label;
|
|
1454
|
+
let r = null;
|
|
1455
|
+
if (typeof o == "function") {
|
|
1456
|
+
const i = n ?? this._context;
|
|
1457
|
+
r = o(typeof i == "function" ? i() : i);
|
|
1458
|
+
} else r = o;
|
|
1459
|
+
return r;
|
|
1460
|
+
}
|
|
1461
|
+
description(t) {
|
|
1462
|
+
return this._resolve(this._description, t);
|
|
1463
|
+
}
|
|
1464
|
+
tags(t) {
|
|
1465
|
+
return this._resolve(this._tags, t);
|
|
1466
|
+
}
|
|
1467
|
+
icon(t) {
|
|
1468
|
+
return this._resolve(this._icon, t);
|
|
1469
|
+
}
|
|
1470
|
+
shortcut() {
|
|
1471
|
+
return this._resolve(this._shortcut);
|
|
1472
|
+
}
|
|
1473
|
+
disabled() {
|
|
1474
|
+
return this._resolve(this._disabled) || !this._callback;
|
|
1475
|
+
}
|
|
1476
|
+
state() {
|
|
1477
|
+
return this._resolve(this._state);
|
|
1478
|
+
}
|
|
1479
|
+
context() {
|
|
1480
|
+
return typeof this._context == "function" ? this._context() : this._context;
|
|
1481
|
+
}
|
|
1482
|
+
async execute(t, n) {
|
|
1483
|
+
if (!this.disabled() && this._callback) {
|
|
1484
|
+
try {
|
|
1485
|
+
let o = !0;
|
|
1486
|
+
if (n?.beforeExecute && (o = n?.beforeExecute(this, t)), await Promise.resolve(o) === !1) return !1;
|
|
1487
|
+
const r = this._callback.bind(this)(t, this);
|
|
1488
|
+
if (await Promise.resolve(r) === !1) return !1;
|
|
1489
|
+
n?.onExecute?.(this, t), this._notifyExecute(t);
|
|
1490
|
+
} catch (o) {
|
|
1491
|
+
return console.warn(o), n?.onError(this, o, t), this._notifyError(t, o), !1;
|
|
1492
|
+
}
|
|
1493
|
+
return !0;
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
addPropertyListener(t, n = !1) {
|
|
1497
|
+
if (!t) throw new Error("listener must be specified");
|
|
1498
|
+
const o = this._listenersProperties;
|
|
1499
|
+
return o.add(t), n && t({}, this), () => {
|
|
1500
|
+
o.delete(t);
|
|
1501
|
+
};
|
|
1502
|
+
}
|
|
1503
|
+
addExecuteListener(t) {
|
|
1504
|
+
if (!t) throw new Error("listener must be specified");
|
|
1505
|
+
const n = this._listenersExecute;
|
|
1506
|
+
return n.add(t), function() {
|
|
1507
|
+
n.delete(t);
|
|
1508
|
+
};
|
|
1509
|
+
}
|
|
1510
|
+
_notifyExecute(t) {
|
|
1511
|
+
const n = this;
|
|
1512
|
+
this._listenersExecute.forEach((o) => {
|
|
1513
|
+
o.onExecute(n, t);
|
|
1514
|
+
});
|
|
1515
|
+
}
|
|
1516
|
+
_notifyError(t, n) {
|
|
1517
|
+
const o = this;
|
|
1518
|
+
this._listenersExecute.forEach((r) => {
|
|
1519
|
+
r.onError?.(o, t, n);
|
|
1520
|
+
});
|
|
1521
|
+
}
|
|
1522
|
+
updateCallback(t) {
|
|
1523
|
+
return this._callback = t || null, this;
|
|
1524
|
+
}
|
|
1525
|
+
update(t) {
|
|
1526
|
+
if (!t) return;
|
|
1527
|
+
const n = this._applyProps(t);
|
|
1528
|
+
return Object.keys(n).length > 0 && this._notifyPropertyChange(n), this;
|
|
1529
|
+
}
|
|
1530
|
+
_notifyPropertyChange(t) {
|
|
1531
|
+
const n = this;
|
|
1532
|
+
this._listenersProperties.forEach((o) => {
|
|
1533
|
+
o(t, n);
|
|
1534
|
+
});
|
|
1535
|
+
}
|
|
1536
|
+
_applyProps(t) {
|
|
1537
|
+
let n = {}, o = this;
|
|
1538
|
+
return Object.keys(t).forEach((r) => {
|
|
1539
|
+
let i = t[r];
|
|
1540
|
+
o["_" + r] !== i && (o["_" + r] = n[r] = i);
|
|
1541
|
+
}), n;
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
class Se extends Dl {
|
|
1545
|
+
}
|
|
1546
|
+
Ct.getOS() === Ct.OSType.MacOS || (Ct.getOS(), Ct.OSType.IOS), Ct.getOS() === Ct.OSType.MacOS || (Ct.getOS(), Ct.OSType.IOS), mi({ setClipboard: (e) => {
|
|
1547
|
+
throw new Error("This is only available via the useClipboard.");
|
|
1548
|
+
}, getClipboard: () => ho.Global, refNativeCopy: { current: null }, refNativeLastKey: { current: null } }, () => {
|
|
1549
|
+
const [e, t] = Je(ho.Global);
|
|
1550
|
+
return { setClipboard: (n) => t(n), getClipboard: () => e, refNativeCopy: J(null), refNativeLastKey: J(null) };
|
|
1551
|
+
});
|
|
1552
|
+
let Ao = !1, zl = 0;
|
|
1553
|
+
var Al = typeof document < "u" ? nn : st;
|
|
1554
|
+
const Pr = () => "sheetxl-ui-" + zl++, $l = Sn.useId ?? function() {
|
|
1555
|
+
const [e, t] = Sn.useState(() => Ao ? Pr() : void 0);
|
|
1556
|
+
return Al(() => {
|
|
1557
|
+
e == null && t(Pr());
|
|
1558
|
+
}, []), Sn.useEffect(() => {
|
|
1559
|
+
Ao || (Ao = !0);
|
|
1560
|
+
}, []), e;
|
|
1561
|
+
}, Pn = ({ itemType: e, index: t, itemSize: n, instanceProps: o, scale: r = 1 }) => {
|
|
1562
|
+
let i, l, s;
|
|
1563
|
+
e === "column" ? (i = o.columnMetadataMap, l = o.lastMeasuredColumnIndex, s = o.recalcColumnIndices) : (i = o.rowMetadataMap, l = o.lastMeasuredRowIndex, s = o.recalcRowIndices);
|
|
1564
|
+
const a = s.length > 0;
|
|
1565
|
+
if (t > l) {
|
|
1566
|
+
let d = 0;
|
|
1567
|
+
if (l >= 0) {
|
|
1568
|
+
const g = i[l];
|
|
1569
|
+
d = g.offset + g.size;
|
|
1570
|
+
}
|
|
1571
|
+
for (let g = l + 1; g <= t; g++) {
|
|
1572
|
+
let m = a ? s.includes(g) ? n(g) * r : i[g]?.size || n(g) * r : n(g) * r;
|
|
1573
|
+
i[g] = { offset: d, size: m }, d += m;
|
|
1574
|
+
}
|
|
1575
|
+
e === "column" ? o.lastMeasuredColumnIndex = t : o.lastMeasuredRowIndex = t;
|
|
1576
|
+
}
|
|
1577
|
+
return i[t], i[t];
|
|
1578
|
+
}, Or = ({ itemType: e, itemSize: t, itemCount: n, instanceProps: o, offset: r, scale: i }) => {
|
|
1579
|
+
let l, s;
|
|
1580
|
+
e === "column" ? (l = o.columnMetadataMap, s = o.lastMeasuredColumnIndex) : (l = o.rowMetadataMap, s = o.lastMeasuredRowIndex);
|
|
1581
|
+
let a = 0;
|
|
1582
|
+
return a = (s > 0 ? l[s].offset : 0) >= r ? xi({ itemType: e, itemSize: t, instanceProps: o, high: s, low: 0, offset: r, scale: i }) : Bl({ itemType: e, itemSize: t, itemCount: n, instanceProps: o, index: Math.max(0, s), offset: r, scale: i }), a = Math.min(a, n), a;
|
|
1583
|
+
}, xi = ({ itemType: e, itemSize: t, instanceProps: n, high: o, low: r, offset: i, scale: l }) => {
|
|
1584
|
+
for (; r <= o; ) {
|
|
1585
|
+
const s = r + Math.floor((o - r) / 2), a = Pn({ itemType: e, itemSize: t, index: s, instanceProps: n, scale: l }).offset;
|
|
1586
|
+
if (a === i) return s;
|
|
1587
|
+
a < i ? r = s + 1 : a > i && (o = s - 1);
|
|
1588
|
+
}
|
|
1589
|
+
return r > 0 ? r - 1 : 0;
|
|
1590
|
+
}, Bl = ({ itemType: e, itemSize: t, itemCount: n, instanceProps: o, index: r, offset: i, scale: l }) => {
|
|
1591
|
+
let s = 1;
|
|
1592
|
+
for (; r < n && Pn({ itemType: e, itemSize: t, index: r, instanceProps: o, scale: l }).offset < i; ) r += s, s *= 2;
|
|
1593
|
+
return xi({ itemType: e, itemSize: t, instanceProps: o, high: Math.min(r, n - 1), low: Math.floor(r / 2), offset: i, scale: l });
|
|
1594
|
+
}, Fl = (e) => {
|
|
1595
|
+
const { rowCount: t, columnCount: n, defaultRowHeight: o, getRowHeight: r, defaultColumnWidth: i, getColumnWidth: l } = e || {}, s = J({ columnMetadataMap: {}, rowMetadataMap: {}, lastMeasuredColumnIndex: -1, lastMeasuredRowIndex: -1, recalcColumnIndices: [], recalcRowIndices: [] }), a = T((_) => Or({ itemType: "row", itemCount: t, itemSize: r ?? (() => o ?? 20), instanceProps: s.current, offset: _ }), [t, r, o]), d = T((_) => _ === -1 ? 0 : Pn({ itemType: "row", index: _, itemSize: r ?? (() => o ?? 20), instanceProps: s.current }).offset, [r, o]), g = T((_) => Pn({ itemType: "row", index: _, itemSize: r ?? (() => o ?? 20), instanceProps: s.current }).size, [r, o]), m = T((_) => Or({ itemType: "column", itemCount: n, itemSize: l ?? (() => i ?? 75), instanceProps: s.current, offset: _ }), [n, l, i]), f = T((_) => _ === -1 ? 0 : Pn({ itemType: "column", index: _, itemSize: l ?? (() => i ?? 75), instanceProps: s.current }).offset, [l, i]), x = T((_) => Pn({ itemType: "column", index: _, itemSize: l ?? (() => i ?? 75), instanceProps: s.current }).size, [l, i]), [E, I] = Qo((_) => _ + 1, 0), M = () => ({ getRowOffset: d, getColOffset: f, getRowIndex: a, getColIndex: m }), [ae, R] = Je(() => e ? M() : null);
|
|
1596
|
+
return st(() => {
|
|
1597
|
+
R(e ? M() : null);
|
|
1598
|
+
}, [E, t, n, i, o, g, x]), ae;
|
|
1599
|
+
}, vi = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ~`!@#$%^&*()-_=+[{]};:'\",<.>/?|\\", Lr = (e) => {
|
|
1600
|
+
if (!e) return null;
|
|
1601
|
+
if (e.eventType === "start") return { type: e.eventType };
|
|
1602
|
+
if (e.eventType === "submit") return { type: e.eventType };
|
|
1603
|
+
if (e.eventType === "cancel") return { type: e.eventType };
|
|
1604
|
+
if (e.eventType === "keyboard") return { type: e.eventType, key: e.event.key };
|
|
1605
|
+
if (e.eventType === "pointer") return { type: e.eventType };
|
|
1606
|
+
if (e.eventType === "coordsChange") {
|
|
1607
|
+
const t = { type: e.eventType };
|
|
1608
|
+
return e.activeCoords && (t.activeCoords = e.activeCoords), t;
|
|
1609
|
+
}
|
|
1610
|
+
return { type: e.eventType ?? "unknown" };
|
|
1611
|
+
}, 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) => {
|
|
1612
|
+
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, E = J(null), I = J(null), [M, ae] = Je(!1), R = t.coords, _ = O(async (X) => {
|
|
1613
|
+
if (E.current?.getBoundingClientRect()) {
|
|
1614
|
+
if (X.eventType === "keyboard") {
|
|
1615
|
+
const u = X.event, C = new KeyboardEvent(u.type, { bubbles: !0, cancelable: !0, view: window, key: u.key, code: u.code, location: u.location, repeat: u.repeat, isComposing: u.isComposing, charCode: u.charCode, keyCode: u.keyCode, which: u.which, ctrlKey: u.ctrlKey, shiftKey: u.shiftKey, altKey: u.altKey, metaKey: u.metaKey });
|
|
1616
|
+
C.isSynthetic = !0, C.key, I.current?.dispatchEvent(C);
|
|
1617
|
+
} else X.eventType === "pointer" || console.warn("unsupported event type", X);
|
|
1618
|
+
await new Promise((u) => requestAnimationFrame(u));
|
|
1619
|
+
}
|
|
1620
|
+
}, []);
|
|
1621
|
+
st(() => {
|
|
1622
|
+
const X = I.current;
|
|
1623
|
+
return ae(!0), I.current.startEdit?.(t.startEvent), (async () => {
|
|
1624
|
+
t.editorRefs.push(X), t.editorRefsDispatchEditorEvent.push(_);
|
|
1625
|
+
const k = [...t.events];
|
|
1626
|
+
for (let u = 0; u < k.length; u++) await _(k[u]);
|
|
1627
|
+
t.onMount(X);
|
|
1628
|
+
})(), () => {
|
|
1629
|
+
const k = t.editorRefs.indexOf(X);
|
|
1630
|
+
k !== -1 && t.editorRefs.splice(k, 1), t.onUnmount(X);
|
|
1631
|
+
};
|
|
1632
|
+
}, []);
|
|
1633
|
+
const L = O(() => o(t), []), le = O(() => {
|
|
1634
|
+
r(t);
|
|
1635
|
+
}, []), $ = n.current && Z.isEqualCells(n.current, R), oe = l && $ && M, be = s({ autoFocus: !!t.startEvent?.autoFocus, ...a, onSubmitEdit: L, onCancelEdit: le, ref: I }, R), U = i.x + me.boundPixel(-g / 2), H = me.boundPixel(i.width + g / 2, !0);
|
|
1636
|
+
return Y("div", { tabIndex: 0, ref: E, style: { background: void 0, ...f, opacity: oe ? f?.opacity ?? 1 : 0, pointerEvents: "auto", position: "absolute", boxSizing: "border-box", top: `${i.y + me.boundPixel(-g / 2)}px`, height: me.boundPixel(i.height + g / 2, !0), left: `${U}px`, width: H }, ...x, children: Y("div", { className: "editor-container", style: { position: "absolute", boxSizing: "border-box", left: `${me.boundPixel(1)}px`, top: `${me.boundPixel(1)}px`, width: me.boundPixel(i.width - 2, !0), height: me.boundPixel(i.height - 2, !0), outline: `${g}px ${d} solid`, boxShadow: "rgba(60,64,67,.35) 2px 2px 6px 3px", maxHeight: "100%", overflow: "hidden", display: "flex" }, children: be }) });
|
|
1637
|
+
}, gs = (e) => {
|
|
1638
|
+
const { view: t, canEdit: n = jl, getCellEditor: o, onBeforeStartEdit: r, onStartEdit: i, onSubmitEdit: l, onCancelEdit: s, onDoneEdit: a, isEditorStartKeyEvent: d = Vl, isEditorStartPointerEvent: g = Wl, containerProps: m, borderStrokeFill: f, borderStrokeWidth: x = 2, getRangeCoords: E = null, activeCoords: I, alignment: M = Wn.Left } = e, [ae, R] = Je(!1), [_, L] = Je(void 0), le = T((S, ue, K, pe, te, Re) => {
|
|
1639
|
+
if (!ue) return null;
|
|
1640
|
+
const at = te?.(ue, S), pt = S.getRangeCoordsBounds(at), zt = S.toClipBounds(pt), gt = pt, Zt = S.getZoom();
|
|
1641
|
+
if (!zt) return null;
|
|
1642
|
+
K && (K *= Zt), pe && (pe *= Zt);
|
|
1643
|
+
let Be = gt, z = !1;
|
|
1644
|
+
if (K !== void 0) {
|
|
1645
|
+
let Xe = { ...at }, wt = 0;
|
|
1646
|
+
for (; !z && Be.width <= K && wt < 20; ) {
|
|
1647
|
+
wt++, wt > 19 && console.warn("max width reached");
|
|
1648
|
+
const an = S.getTotalRangeCoords(), Jt = S.getLayout();
|
|
1649
|
+
Re === Wn.Left ? Xe.colEnd + 1 < an.colEnd ? Xe.colEnd = Jt.getColIndex(Be.x + K) : z = !0 : Re === Wn.Right ? Xe.colStart - 1 >= 0 ? Xe.colStart = Jt.getColIndex(Be.x - (K - Be.width)) : z = !0 : Re === Wn.Center && Xe.colEnd + 1 < an.colEnd && Xe.colStart - 1 >= 0 ? (Xe.colStart = Jt.getColIndex(Be.x - (K - Be.width) / 2), Xe.colEnd = Jt.getColIndex(Be.x + Be.width + (K - Be.width) / 2)) : z = !0, z || (Be = S.getRangeCoordsBounds(Xe));
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
Be.height = gt.height, pe !== void 0 && (Be.height = Math.max(pe + 1, gt.height));
|
|
1653
|
+
const { width: ke, height: Qe } = S.getViewportSize();
|
|
1654
|
+
return { x: Be.x ?? 0, y: Be.y ?? 0, height: Math.min(Qe - Be.y, Be.height) + 1, width: Math.min(ke - Be.x, Be.width) + 1 };
|
|
1655
|
+
}, [M]), $ = T(n, [n]), oe = O(() => {
|
|
1656
|
+
t?.getStage()?.focus();
|
|
1657
|
+
}, [t]), be = T((S) => {
|
|
1658
|
+
r?.(S), N(), R(!0);
|
|
1659
|
+
}, [r]), U = T((S) => {
|
|
1660
|
+
i?.(S.coords);
|
|
1661
|
+
}, [i]), H = T((S) => {
|
|
1662
|
+
S.isSubmitted || S.isCancelled || (u.current.isEditorClosed = !0, oe(), S.isCancelled = !0, s?.(S.coords), N());
|
|
1663
|
+
}, [s]), X = T((S) => {
|
|
1664
|
+
if (S.isSubmitted || S.isCancelled) return !1;
|
|
1665
|
+
try {
|
|
1666
|
+
return S.isEditorClosing = !0, S.isSubmitted = !0, S.isEditorSubmitted || (S.isEditorSubmitted = !0, S.editorRefs[0]?.submitEdit?.()), S.coords, l?.(S.coords), S.isEditorClosed = !0, oe(), N(), !0;
|
|
1667
|
+
} catch (ue) {
|
|
1668
|
+
throw S.isEditorClosing = !1, S.isSubmitted = !1, ue;
|
|
1669
|
+
}
|
|
1670
|
+
}, [l]), k = T((S) => {
|
|
1671
|
+
R(!1), a?.(S.coords), N();
|
|
1672
|
+
}, [a]), u = J(null), C = J(null), ee = J(null), W = J([]), [A, q] = Qo((S) => S + 1, 0), N = O((S) => {
|
|
1673
|
+
S && W.current.push(S), q();
|
|
1674
|
+
}, []), xe = T((S) => {
|
|
1675
|
+
if (S.defaultPrevented || S.isSynthetic || !t) return;
|
|
1676
|
+
const ue = t?.getCellCoordsFromClient(S.clientX, S.clientY);
|
|
1677
|
+
ue && N({ eventType: "pointer", event: S, coords: ue });
|
|
1678
|
+
}, [t]), G = T((S) => {
|
|
1679
|
+
const ue = S.nativeEvent;
|
|
1680
|
+
xe(ue);
|
|
1681
|
+
}, [t]), He = T((S) => {
|
|
1682
|
+
if (S.defaultPrevented || S.isSynthetic || !t?.getStage()) return;
|
|
1683
|
+
const ue = C.current;
|
|
1684
|
+
d(S, ue) && (S.stopPropagation(), S.preventDefault()), S.key, N({ eventType: "keyboard", event: S, coords: ue });
|
|
1685
|
+
}, [t]);
|
|
1686
|
+
nn(() => {
|
|
1687
|
+
const S = (pe, te) => {
|
|
1688
|
+
const Re = te?.cell ?? pe;
|
|
1689
|
+
if (!Re) return null;
|
|
1690
|
+
const at = Re;
|
|
1691
|
+
if (!$(Re)) return null;
|
|
1692
|
+
be?.(Re);
|
|
1693
|
+
const pt = Ct.uuidV4();
|
|
1694
|
+
te = Object.freeze({ autoFocus: !0, ...te }), ee.current = Re;
|
|
1695
|
+
const zt = { coords: at, startEvent: te, uuid: pt, isMounted: !1, isStarted: !1, isSubmitted: !1, isEditorSubmitted: !1, isEditorClosing: !1, isEditorClosed: !1, isCancelled: !1, events: [], editorRefsDispatchEditorEvent: [], editorRefs: [], onMount: (gt) => {
|
|
1696
|
+
zt.isMounted || (zt.isMounted = !0, N());
|
|
1697
|
+
}, onUnmount: (gt) => {
|
|
1698
|
+
if (zt.editorRefs.length === 0) {
|
|
1699
|
+
const Zt = () => {
|
|
1700
|
+
zt.isMounted = !1, N();
|
|
1701
|
+
};
|
|
1702
|
+
if (document.activeElement !== document.body) Zt();
|
|
1703
|
+
else {
|
|
1704
|
+
const Be = (z) => {
|
|
1705
|
+
z.defaultPrevented || z.target !== document.body || He(z);
|
|
1706
|
+
};
|
|
1707
|
+
window.addEventListener("keydown", Be, !0), t.getStage()?.addEventListener("focusin", () => {
|
|
1708
|
+
window.removeEventListener("keydown", Be), Zt();
|
|
1709
|
+
}, { once: !0 }), oe();
|
|
1710
|
+
}
|
|
1711
|
+
}
|
|
1712
|
+
} };
|
|
1713
|
+
return zt;
|
|
1714
|
+
};
|
|
1715
|
+
if (W.current.length <= 0 && !u.current) return;
|
|
1716
|
+
const ue = W.current[0];
|
|
1717
|
+
Lr(ue), ((pe) => {
|
|
1718
|
+
const te = [], Re = pe?.length ?? 0;
|
|
1719
|
+
for (let at = 0; at < Re; at++) {
|
|
1720
|
+
const pt = pe[at];
|
|
1721
|
+
te.push(Lr(pt));
|
|
1722
|
+
}
|
|
1723
|
+
})(W.current), u.current, u.current;
|
|
1724
|
+
let K = u.current;
|
|
1725
|
+
if (u.current) {
|
|
1726
|
+
if (u.current.isDone) u.current = null;
|
|
1727
|
+
else if (u.current.isSubmitted || u.current.isCancelled) {
|
|
1728
|
+
if (u.current.isMounted) return;
|
|
1729
|
+
u.current.isDone || (k(u.current), u.current.isDone = !0);
|
|
1730
|
+
}
|
|
1731
|
+
}
|
|
1732
|
+
if (ue) {
|
|
1733
|
+
if (ue.eventType === "start") {
|
|
1734
|
+
const pe = ue, te = pe.startEvent?.cell ?? C.current;
|
|
1735
|
+
u.current && Z.isEqualCells(u.current.coords, te) || (u.current = S(te, pe.startEvent));
|
|
1736
|
+
} else if (ue.eventType === "keyboard") {
|
|
1737
|
+
const pe = ue.event;
|
|
1738
|
+
if (u.current) {
|
|
1739
|
+
pe.key, u.current.events, u.current.events.push(ue);
|
|
1740
|
+
for (let te = 0; te < u.current.editorRefsDispatchEditorEvent.length; te++) u.current.editorRefsDispatchEditorEvent[te](ue);
|
|
1741
|
+
} else if (d(pe, ue.coords)) {
|
|
1742
|
+
let te;
|
|
1743
|
+
const Re = S(te?.cell ?? C.current, te);
|
|
1744
|
+
Re && Re.events.push(ue), u.current = Re;
|
|
1745
|
+
}
|
|
1746
|
+
} else if (ue.eventType === "pointer") {
|
|
1747
|
+
const pe = ue.event;
|
|
1748
|
+
if (u.current) {
|
|
1749
|
+
u.current.events.push(ue);
|
|
1750
|
+
for (let te = 0; te < u.current.editorRefsDispatchEditorEvent.length; te++) u.current.editorRefsDispatchEditorEvent[te](ue);
|
|
1751
|
+
} else {
|
|
1752
|
+
const te = ue?.coords ?? C.current, Re = g(pe, te);
|
|
1753
|
+
if (Re) {
|
|
1754
|
+
let at;
|
|
1755
|
+
typeof at != "boolean" && (at = Re);
|
|
1756
|
+
const pt = S(te, at);
|
|
1757
|
+
pt && pt.events.push(ue), u.current = pt;
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
} else if (ue.eventType === "submit") {
|
|
1761
|
+
if (u.current && !u.current.isSubmitted && !u.current.isCancelled) {
|
|
1762
|
+
if (!u.current.isMounted) return;
|
|
1763
|
+
X(u.current);
|
|
1764
|
+
}
|
|
1765
|
+
} else if (ue.eventType === "cancel") {
|
|
1766
|
+
if (u.current && !u.current.isSubmitted && !u.current.isCancelled) {
|
|
1767
|
+
if (!u.current.isMounted) return;
|
|
1768
|
+
H(u.current);
|
|
1769
|
+
}
|
|
1770
|
+
} else if (ue.eventType === "coordsChange") {
|
|
1771
|
+
const pe = ue;
|
|
1772
|
+
if (C.current = pe.activeCoords, u.current, u.current && !u.current.isSubmitted && !u.current.isCancelled) {
|
|
1773
|
+
if (!u.current.isMounted) return;
|
|
1774
|
+
try {
|
|
1775
|
+
X(u.current);
|
|
1776
|
+
} catch {
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
W.current.length > 0 && (W.current.shift(), N()), W.current.length === 0 && (!u.current || u.current.isEditorClosing || u.current.isEditorClosed ? !u.current && K && oe() : u.current.isMounted && !u.current.isStarted && (u.current.isStarted = !0, u.current.startEvent.autoFocus && (typeof u.current.startEvent.autoFocus == "string" ? u.current.editorRefs[0]?.autoFocus(u.current.startEvent.autoFocus) : u.current.editorRefs[0]?.autoFocus()), U?.(u.current), requestAnimationFrame(() => {
|
|
1782
|
+
t && u.current?.coords && t.scrollCellCoordsIntoView(u.current.coords);
|
|
1783
|
+
})));
|
|
1784
|
+
}, [A]), st(() => {
|
|
1785
|
+
ee.current = I;
|
|
1786
|
+
const S = u.current?.coords;
|
|
1787
|
+
Z.isEqualCells(S, I) || (u.current && (u.current.isEditorClosing = !0), N({ eventType: "coordsChange", activeCoords: I }));
|
|
1788
|
+
}, [I]);
|
|
1789
|
+
const Ue = O((S) => {
|
|
1790
|
+
He(S.nativeEvent);
|
|
1791
|
+
}, []), { width: We = 0, height: ht = 0 } = _ ?? { width: 0, height: 0 }, _e = T(o, [o]);
|
|
1792
|
+
return { overlay: T((S) => {
|
|
1793
|
+
if (!u.current || u.current.isEditorClosed) return u.current, null;
|
|
1794
|
+
u.current.coords;
|
|
1795
|
+
let ue = le(S, u.current.coords, We, ht, E, M), K = !0;
|
|
1796
|
+
ue && ue.width !== 0 && ue.height !== 0 || (ue = { x: 0, y: 0, width: We, height: We }, K = !1);
|
|
1797
|
+
const pe = S.getZoom(), te = { containerBounds: { x: 0, y: 0, width: ue.width / pe, height: ue.height / pe }, setNaturalDimensions: L, zoom: pe };
|
|
1798
|
+
return Y(Hl, { session: u.current, refLatestCoords: ee, handleSubmitEdit: X, handleCancelEdit: H, cellBounds: ue, borderStrokeWidth: x, borderStrokeFill: f, isInBounds: K, getCellEditor: _e, propsEditor: te, alignment: M, ...m }, "editor:" + u.current.uuid);
|
|
1799
|
+
}, [o, E, A, We, ht, M, x, f]), startEdit: O((S) => {
|
|
1800
|
+
N({ eventType: "start", startEvent: S });
|
|
1801
|
+
}, []), submitEdit: O(() => {
|
|
1802
|
+
N({ eventType: "submit" });
|
|
1803
|
+
}, []), cancelEdit: O(() => {
|
|
1804
|
+
N({ eventType: "cancel" });
|
|
1805
|
+
}, []), onKeyboardEvent: Ue, onPointerEvent: G, onKeyboardEventNative: He, onPointerEventNative: xe, isEditing: ae };
|
|
1806
|
+
}, ws = ({ gridRef: e, gridMainRef: t, orientation: n = cn, 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: E, clearSelections: I }) => {
|
|
1807
|
+
const M = o ?? ((n === cn ? e.current?.rowCount : e.current?.columnCount) || 0), ae = J(null), R = J(null), _ = J(!1), L = J(null), le = O((u) => n === Nt ? { rowIndex: 0, colIndex: u.colIndex } : { rowIndex: u.rowIndex, colIndex: 0 }, [n]), $ = O((u) => n === Nt ? { rowIndex: t.current ? t.current.rowCount - 1 : 0, colIndex: u.colIndex } : { rowIndex: u.rowIndex, colIndex: t.current ? t.current.columnCount - 1 : 0 }, [n]), oe = (u) => {
|
|
1808
|
+
R.current = $(u), x(R.current, ae.current);
|
|
1809
|
+
}, be = O((u, C) => {
|
|
1810
|
+
if (!e.current) return;
|
|
1811
|
+
const ee = e.current.getViewFromClient(u, C)?.getCellCoordsFromClient(u, C);
|
|
1812
|
+
return ee ? (n === Nt ? ee.rowIndex = t.current.getViewport().rowStart : ee.colIndex = t.current.getViewport().colStart, ee) : void 0;
|
|
1813
|
+
}, []), U = O((u, C = !1) => {
|
|
1814
|
+
let ee = u;
|
|
1815
|
+
return C || (ee = { ...u }, n === cn ? delete ee.colIndex : delete ee.rowIndex), t.current?.scrollCellCoordsIntoView(ee);
|
|
1816
|
+
}, [n]), H = T(a, [a]), X = T(s, [s]), k = Ee(() => ({ onPointerDown: (u) => {
|
|
1817
|
+
if (!e || !e.current || u.nativeEvent.defaultPrevented) return;
|
|
1818
|
+
const C = be(u.nativeEvent.clientX, u.nativeEvent.clientY);
|
|
1819
|
+
if (!C) return;
|
|
1820
|
+
u.nativeEvent.which;
|
|
1821
|
+
const ee = u.nativeEvent.shiftKey, W = u.nativeEvent.ctrlKey || u.nativeEvent.metaKey;
|
|
1822
|
+
if (d?.(u, C) === !1) return;
|
|
1823
|
+
X?.(), _.current = !0;
|
|
1824
|
+
const A = t.current?.getViewFromClient(u.nativeEvent.clientX, u.nativeEvent.clientY), q = ((N, xe) => n === Nt ? { ...N, rowIndex: xe.rowStart } : { ...N, colIndex: xe.colStart })(C, A.getVisibleRangeCoords());
|
|
1825
|
+
if (ee) oe(C);
|
|
1826
|
+
else {
|
|
1827
|
+
if (W) return ((N, xe = N, G) => {
|
|
1828
|
+
ae.current = le(N), R.current = $(xe), E(ae.current, R.current, G);
|
|
1829
|
+
})(C, C, q), void (l && U(q, !0));
|
|
1830
|
+
((N, xe = N, G) => {
|
|
1831
|
+
ae.current = le(N), R.current = $(xe), f(ae.current, R.current, G);
|
|
1832
|
+
})(C, C, q), oe(C), l && U(q, !0);
|
|
1833
|
+
}
|
|
1834
|
+
}, onPointerMoveOrWait: Ct.throttle((u) => {
|
|
1835
|
+
if (!_.current || !e?.current) return;
|
|
1836
|
+
const C = be(u.clientX, u.clientY);
|
|
1837
|
+
if (C && g?.(u, C) !== !1) {
|
|
1838
|
+
if (Z.isEqualCells(L.current, C)) return I();
|
|
1839
|
+
oe(C), U(C);
|
|
1840
|
+
}
|
|
1841
|
+
}, 60), onPointerUp: (u) => {
|
|
1842
|
+
_.current = !1, H?.(), m?.(u);
|
|
1843
|
+
}, processTouch: !0, consumeTouch: !0 }), [r, l, M, i, I, d, m]);
|
|
1844
|
+
return { onPointerDown: T(On(k), []), getCellCoordsFromClient: be };
|
|
1845
|
+
}, Ye = (e, t, n) => {
|
|
1846
|
+
if (!e) return t;
|
|
1847
|
+
let o = t;
|
|
1848
|
+
const r = n === Ke || n === lt;
|
|
1849
|
+
for (; ; ) {
|
|
1850
|
+
const i = e(o, !r);
|
|
1851
|
+
if (i === 0) return o;
|
|
1852
|
+
r ? o += i : o -= i;
|
|
1853
|
+
}
|
|
1854
|
+
}, io = (e, t, n) => {
|
|
1855
|
+
const o = [];
|
|
1856
|
+
let r = t;
|
|
1857
|
+
for (; r <= n; ) {
|
|
1858
|
+
const i = Math.max(0, e(r));
|
|
1859
|
+
i === 0 ? (o.push(r), r++) : r += i;
|
|
1860
|
+
}
|
|
1861
|
+
return o;
|
|
1862
|
+
}, Nl = (e, t, n, o, r, i) => {
|
|
1863
|
+
if (!t) return i;
|
|
1864
|
+
let { rowIndex: l, colIndex: s } = e;
|
|
1865
|
+
switch (o) {
|
|
1866
|
+
case lt: {
|
|
1867
|
+
l = Ye(n, Math.min(l + 1, i), o);
|
|
1868
|
+
let a = t({ rowIndex: l, colIndex: s });
|
|
1869
|
+
for (; !a && l < i; ) l = Ye(n, Math.min(++l, i), o), a = t({ rowIndex: l, colIndex: s });
|
|
1870
|
+
return l;
|
|
1871
|
+
}
|
|
1872
|
+
case it: {
|
|
1873
|
+
l = Ye(n, Math.max(l - 1, i), o);
|
|
1874
|
+
let a = t({ rowIndex: l, colIndex: s });
|
|
1875
|
+
for (; !a && l > i; ) l = Ye(n, Math.max(--l, i), o), a = t({ rowIndex: l, colIndex: s });
|
|
1876
|
+
return l;
|
|
1877
|
+
}
|
|
1878
|
+
case Ke: {
|
|
1879
|
+
s = Ye(n, Math.min(s + 1, i), o);
|
|
1880
|
+
let a = t({ rowIndex: l, colIndex: s });
|
|
1881
|
+
for (; !a && s < i; ) s = Ye(n, Math.min(++s, i), o), a = t({ rowIndex: l, colIndex: s });
|
|
1882
|
+
return s;
|
|
1883
|
+
}
|
|
1884
|
+
case ot: {
|
|
1885
|
+
s = Ye(n, Math.max(s - 1, i), o);
|
|
1886
|
+
let a = t({ rowIndex: l, colIndex: s });
|
|
1887
|
+
for (; !a && s > i; ) s = Ye(n, Math.max(--s, i), o), a = t({ rowIndex: l, colIndex: s });
|
|
1888
|
+
return s;
|
|
1889
|
+
}
|
|
1890
|
+
default:
|
|
1891
|
+
return i;
|
|
1892
|
+
}
|
|
1893
|
+
}, Ul = (e, t = () => !0, n, o, r, i) => {
|
|
1894
|
+
let { rowIndex: l, colIndex: s } = e;
|
|
1895
|
+
switch (o) {
|
|
1896
|
+
case lt: {
|
|
1897
|
+
l = Ye(n, Math.min(l + 1, i), o);
|
|
1898
|
+
let a = t?.({ rowIndex: l, colIndex: s });
|
|
1899
|
+
for (; a && l < i; ) l = Ye(n, Math.min(++l, i), o), a = t?.({ rowIndex: l, colIndex: s });
|
|
1900
|
+
return t?.({ rowIndex: l, colIndex: s }) ? l : l - 1;
|
|
1901
|
+
}
|
|
1902
|
+
case it: {
|
|
1903
|
+
l = Ye(n, Math.max(l - 1, i), o);
|
|
1904
|
+
let a = t?.({ rowIndex: l, colIndex: s });
|
|
1905
|
+
for (; a && l > i; ) l = Ye(n, Math.max(--l, i), o), a = t?.({ rowIndex: l, colIndex: s });
|
|
1906
|
+
return t?.({ rowIndex: l, colIndex: s }) ? l : l + 1;
|
|
1907
|
+
}
|
|
1908
|
+
case Ke: {
|
|
1909
|
+
s = Ye(n, Math.min(s + 1, i), o);
|
|
1910
|
+
let a = t?.({ rowIndex: l, colIndex: s });
|
|
1911
|
+
for (; a && s < i; ) s = Ye(n, Math.min(++s, i), o), a = t?.({ rowIndex: l, colIndex: s });
|
|
1912
|
+
return t?.({ rowIndex: l, colIndex: s }) ? s : s - 1;
|
|
1913
|
+
}
|
|
1914
|
+
case ot: {
|
|
1915
|
+
s = Ye(n, Math.max(s - 1, i), o);
|
|
1916
|
+
let a = t?.({ rowIndex: l, colIndex: s });
|
|
1917
|
+
for (; a && s > i; ) s = Ye(n, Math.max(--s, i), o), a = t?.({ rowIndex: l, colIndex: s });
|
|
1918
|
+
return t?.({ rowIndex: l, colIndex: s }) ? s : s + 1;
|
|
1919
|
+
}
|
|
1920
|
+
default:
|
|
1921
|
+
return null;
|
|
1922
|
+
}
|
|
1923
|
+
}, ql = (e, t, n, o, r, i) => {
|
|
1924
|
+
if (!t) return i;
|
|
1925
|
+
let l, { rowIndex: s, colIndex: a } = e;
|
|
1926
|
+
o === lt ? l = { rowIndex: s + 1, colIndex: a } : o === it ? l = { rowIndex: s - 1, colIndex: a } : o === Ke ? l = { rowIndex: s, colIndex: a + 1 } : o === ot && (l = { rowIndex: s, colIndex: a - 1 });
|
|
1927
|
+
const d = t(e), g = t(l);
|
|
1928
|
+
var m, f;
|
|
1929
|
+
return (f = g, !(m = d) && !f || !m && f || m && !f ? Nl : Ul)(e, t, n, o, !1, i) ?? i;
|
|
1930
|
+
}, Dr = (e, t) => `${e}:${t}`, zr = (e, t, n, o, r, i) => {
|
|
1931
|
+
if (n - t >= r - o) return o;
|
|
1932
|
+
let l = o;
|
|
1933
|
+
return e === "nearest" && (o - t > 0 ? e = "start" : n - r > 0 && (e = "end")), e === "start" ? l = t : e === "end" ? l = n - (r - o) : e === "center" && (l = t + (n - t) / 2 - (r - o) / 2), Math.max(0, Math.min(l, i - (r - o)));
|
|
1934
|
+
}, Ar = (e, t, n, o) => (console.log("todo: implement convertToVisibleRanges"), e), Xo = (e, t = Ke, n, o, r, i = null) => {
|
|
1935
|
+
if (i && Z.isEqualSelectionCoords(i, e)) return e;
|
|
1936
|
+
const l = e.ranges[e.rangeIndex];
|
|
1937
|
+
if (!Z.isRangesIntersect({ rowStart: e.cell.rowIndex, colStart: e.cell.colIndex, rowEnd: e.cell.rowIndex, colEnd: e.cell.colIndex }, l)) return e;
|
|
1938
|
+
let s = { ...e.cell }, a = e.rangeIndex;
|
|
1939
|
+
switch (t) {
|
|
1940
|
+
case Ke:
|
|
1941
|
+
s.colIndex = Ye(r, s.colIndex + 1, t);
|
|
1942
|
+
break;
|
|
1943
|
+
case ot:
|
|
1944
|
+
s.colIndex = Ye(r, s.colIndex - 1, t);
|
|
1945
|
+
break;
|
|
1946
|
+
case lt:
|
|
1947
|
+
s.rowIndex = Ye(o, s.rowIndex + 1, t);
|
|
1948
|
+
break;
|
|
1949
|
+
case it:
|
|
1950
|
+
s.rowIndex = Ye(o, s.rowIndex - 1, t);
|
|
1951
|
+
}
|
|
1952
|
+
const d = (f) => {
|
|
1953
|
+
if (f) {
|
|
1954
|
+
a = e.rangeIndex >= e.ranges.length - 1 ? 0 : e.rangeIndex + 1;
|
|
1955
|
+
const x = e.ranges[a];
|
|
1956
|
+
s = { colIndex: x.colStart, rowIndex: x.rowStart };
|
|
1957
|
+
} else {
|
|
1958
|
+
a = e.rangeIndex <= 0 ? e.ranges.length - 1 : e.rangeIndex - 1;
|
|
1959
|
+
const x = e.ranges[a];
|
|
1960
|
+
s = { colIndex: x.colEnd, rowIndex: x.rowEnd };
|
|
1961
|
+
}
|
|
1962
|
+
};
|
|
1963
|
+
if (t === Ke && s.colIndex > l.colEnd && s.rowIndex === l.rowEnd) d(!0);
|
|
1964
|
+
else if (t === ot && s.colIndex < l.colStart && s.rowIndex === l.rowStart) d(!1);
|
|
1965
|
+
else if (t === lt && s.colIndex === l.colEnd && s.rowIndex > l.rowEnd) d(!0);
|
|
1966
|
+
else if (t === it && s.colIndex === l.colStart && s.rowIndex < l.rowStart) d(!1);
|
|
1967
|
+
else {
|
|
1968
|
+
let f = s.rowIndex, x = s.colIndex;
|
|
1969
|
+
switch (t) {
|
|
1970
|
+
case Ke:
|
|
1971
|
+
x > l.colEnd && (f = Ye(o, f + 1, t), x = l.colStart, f > l.rowEnd && (f = l.rowStart));
|
|
1972
|
+
break;
|
|
1973
|
+
case ot:
|
|
1974
|
+
x < l.colStart && (f = Ye(o, f - 1, t), x = l.colEnd, f < l.rowStart && (f = l.rowEnd));
|
|
1975
|
+
break;
|
|
1976
|
+
case lt:
|
|
1977
|
+
f > l.rowEnd && (x = Ye(r, x + 1, t), f = l.rowStart, x > l.colEnd && (x = l.colStart));
|
|
1978
|
+
break;
|
|
1979
|
+
case it:
|
|
1980
|
+
f < l.rowStart && (x = Ye(r, x - 1, t), f = l.rowEnd, x < l.colStart && (x = l.colEnd));
|
|
1981
|
+
}
|
|
1982
|
+
s = { rowIndex: f, colIndex: x };
|
|
1983
|
+
}
|
|
1984
|
+
let g = n(s);
|
|
1985
|
+
if (!Z.isRangeWithinRange(g, l)) {
|
|
1986
|
+
const f = Z.intersectRanges(g, l);
|
|
1987
|
+
f && (g = f);
|
|
1988
|
+
}
|
|
1989
|
+
let m = { rowStart: Ye(o, g.rowStart, lt), colStart: Ye(r, g.colStart, Ke), rowEnd: Ye(o, g.rowEnd, it), colEnd: Ye(r, g.colEnd, ot) };
|
|
1990
|
+
if (m.rowStart !== s.rowIndex || m.colStart !== s.colIndex) {
|
|
1991
|
+
switch (t) {
|
|
1992
|
+
case Ke:
|
|
1993
|
+
e.ranges[a].colStart === m.colStart && e.ranges[a].colEnd === m.colEnd && (s.rowIndex = m.rowEnd), s.colIndex = m.colEnd;
|
|
1994
|
+
break;
|
|
1995
|
+
case ot:
|
|
1996
|
+
e.ranges[a].colStart === m.colStart && e.ranges[a].colEnd === m.colEnd && (s.rowIndex = m.rowStart), s.rowIndex === m.rowStart ? s.colIndex = m.colStart + 1 : s.colIndex = m.colStart;
|
|
1997
|
+
break;
|
|
1998
|
+
case lt:
|
|
1999
|
+
e.ranges[a].rowStart === m.rowStart && e.ranges[a].rowEnd === m.rowEnd && (s.colIndex = m.colEnd), s.rowIndex = m.rowEnd;
|
|
2000
|
+
break;
|
|
2001
|
+
case it:
|
|
2002
|
+
e.ranges[a].rowStart === m.rowStart && e.ranges[a].rowEnd === m.rowEnd && (s.colIndex = m.colStart), s.colIndex === m.colStart ? s.rowIndex = m.rowStart + 1 : s.rowIndex = m.rowStart;
|
|
2003
|
+
}
|
|
2004
|
+
return Xo({ cell: s, ranges: e.ranges, rangeIndex: a }, t, n, o, r, i ?? e);
|
|
2005
|
+
}
|
|
2006
|
+
return { ranges: e.ranges, cell: s, rangeIndex: a };
|
|
2007
|
+
}, $r = (e, t) => {
|
|
2008
|
+
let n, o = 0, r = 0;
|
|
2009
|
+
return t.colStart < e.colStart ? (n = ot, o = e.colStart - t.colStart, r = t.colStart) : t.colEnd > e.colEnd ? (n = Ke, o = t.colEnd - e.colEnd, r = t.colEnd) : t.rowStart < e.rowStart ? (n = it, o = e.rowStart - t.rowStart, r = t.rowStart) : t.rowEnd > e.rowEnd && (n = lt, o = t.rowEnd - e.rowEnd, r = t.rowEnd), { direction: n, amount: o, index: r };
|
|
2010
|
+
}, go = (e, t = !1, n, o) => {
|
|
2011
|
+
if (!n) return 0;
|
|
2012
|
+
const r = !t, i = r ? 1 : -1;
|
|
2013
|
+
let l = n(r ? e : e + 1), s = n(r ? e + 1 : e), a = e + (r ? 2 : -1), d = 0;
|
|
2014
|
+
for (; (s - l) * i <= 0; ) {
|
|
2015
|
+
if (r && a - 1 > o + 1 || !r && a + 1 < o) return d;
|
|
2016
|
+
l = s, s = n(a), a += i, d++;
|
|
2017
|
+
}
|
|
2018
|
+
return d;
|
|
2019
|
+
}, Br = (e, t, n, o, r) => {
|
|
2020
|
+
const i = {};
|
|
2021
|
+
let l = null, s = null;
|
|
2022
|
+
for (let a = 0; a <= n.length && n[a] <= r; a++) {
|
|
2023
|
+
const d = n[a];
|
|
2024
|
+
if (d < o) continue;
|
|
2025
|
+
const g = l === d ? s : t ? e.getColOffset(d) : e.getRowOffset(d), m = t ? e.getColOffset(d + 1) : e.getRowOffset(d + 1);
|
|
2026
|
+
l = d + 1, s = m, i[d] = Object.freeze({ offset: g, size: m - g, spanIndex: a });
|
|
2027
|
+
}
|
|
2028
|
+
return Object.freeze(i);
|
|
2029
|
+
}, Fr = (e, t, n) => {
|
|
2030
|
+
const o = e.getColOffset(t.colStart) + (n?.left ?? 0), r = e.getRowOffset(t.rowStart) + (n?.top ?? 0);
|
|
2031
|
+
return { x: o, y: r, width: e.getColOffset(t.colEnd + 1) + (n?.right ?? 0) - (n?.left ?? 0) - o, height: e.getRowOffset(t.rowEnd + 1) + (n?.bottom ?? 0) - (n?.top ?? 0) - r };
|
|
2032
|
+
}, Kl = (e, t, n) => !!n && !(e < n.x || e > n.x + n.width) && !(t < n.y || t > n.y + n.height), $o = (e, t = !0) => `M ${me.boundPixel(e.left)} ${me.boundPixel(e.top)} L ${me.boundPixel(e.right, !0)} ${me.boundPixel(e.top)} L ${me.boundPixel(e.right, !0)} ${me.boundPixel(e.bottom, !0)} L ${me.boundPixel(e.left)} ${me.boundPixel(e.bottom, !0)} L ${me.boundPixel(e.left)} ${me.boundPixel(e.top)} ${t ? "Z" : ""}`, jr = (e) => {
|
|
2033
|
+
const { linePoints: t, bounds: n, pathProps: o, style: r, ...i } = e;
|
|
2034
|
+
return Y("svg", { width: `${me.boundPixel(n.width, !0)}`, height: `${me.boundPixel(n.height, !0)}`, viewBox: `0 0 ${me.boundPixel(n.width, !0)} ${me.boundPixel(n.height, !0)}`, style: { position: "absolute", left: `${me.boundPixel(n.x)}px`, top: `${me.boundPixel(n.y)}px`, width: `${me.boundPixel(n.width, !0)}px`, height: `${me.boundPixel(n.height, !0)}px`, pointerEvents: "none", transitionTimingFunction: "linear", transitionDelay: "0", transitionProperty: "left, top, width, height", willChange: "left, top, width, height, stroke-dashoffset", ...r }, ...i, children: Y("path", { d: `M ${me.boundPixel(t[0])} ${me.boundPixel(t[1])} L ${me.boundPixel(t[2])} ${me.boundPixel(t[3])}`, fill: "none", vectorEffect: "non-scaling-stroke", stroke: "black", ...o }) });
|
|
2035
|
+
}, Yl = (e) => {
|
|
2036
|
+
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 } = e, I = n, M = t, ae = o, R = r;
|
|
2037
|
+
let _ = null;
|
|
2038
|
+
if (i) {
|
|
2039
|
+
let L = $o({ top: 0, left: 0, bottom: R, right: ae });
|
|
2040
|
+
m && (L = L + " " + $o({ top: m.y - I, left: m.x - M, bottom: m.height + m.y - I, right: m.width + m.x - M })), _ = [Y("path", { d: L, fill: i, stroke: "none", fillRule: "evenodd" }, "fill")];
|
|
2041
|
+
}
|
|
2042
|
+
return Ht("svg", { width: `${me.boundPixel(o, !0)}`, height: `${me.boundPixel(r, !0)}`, viewBox: `0 0 ${me.boundPixel(o, !0)} ${me.boundPixel(r, !0)}`, preserveAspectRatio: "none", style: { position: "absolute", left: `${me.boundPixel(t)}px`, top: `${me.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 }, ...E, children: [_, Y("path", { d: $o({ top: 0, left: 0, right: ae, bottom: R }), fill: "none", strokeDasharray: a, strokeDashoffset: d, stroke: l, vectorEffect: "non-scaling-stroke", strokeWidth: s, ...f })] });
|
|
2043
|
+
}, Xl = (e) => {
|
|
2044
|
+
const { key: t, ...n } = e;
|
|
2045
|
+
return Y(yi, { ...n }, t);
|
|
2046
|
+
}, yi = Dt((e) => {
|
|
2047
|
+
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, E = { name: "walking-offset", dashGap: 2, speed: 50, dashLength: 8, ...d };
|
|
2048
|
+
let I = E.dashGap + E.dashLength;
|
|
2049
|
+
const M = E.speed * I, ae = $l().replaceAll(":", ""), R = `${E.name}-${ae}`;
|
|
2050
|
+
let _;
|
|
2051
|
+
return st(() => {
|
|
2052
|
+
if (!x) return;
|
|
2053
|
+
const L = `@keyframes ${R} {
|
|
2054
|
+
to {
|
|
2055
|
+
stroke-dashoffset: 0px;
|
|
2056
|
+
}
|
|
2057
|
+
}`, le = document.createElement("style");
|
|
2058
|
+
return le.appendChild(document.createTextNode(L)), document.head.appendChild(le), le.sheet.insertRule(L, 0), () => {
|
|
2059
|
+
document.head.removeChild(le);
|
|
2060
|
+
};
|
|
2061
|
+
}, [x]), x && (_ = { strokeDasharray: `${E.dashLength}px ${E.dashGap}px`, strokeDashoffset: `${I}px`, animation: `${R} ${M}ms linear infinite`, willChange: "stroke-dashoffset" }), Y(Yl, { x: o, y: r, width: i, height: l, stroke: t, fill: n, shapeRendering: "crispEdges", style: { ..._, ...s }, ...f });
|
|
2062
|
+
});
|
|
2063
|
+
function bi(e) {
|
|
2064
|
+
var t, n, o = "";
|
|
2065
|
+
if (typeof e == "string" || typeof e == "number") o += e;
|
|
2066
|
+
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
2067
|
+
var r = e.length;
|
|
2068
|
+
for (t = 0; t < r; t++) e[t] && (n = bi(e[t])) && (o && (o += " "), o += n);
|
|
2069
|
+
} else for (n in e) e[n] && (o && (o += " "), o += n);
|
|
2070
|
+
return o;
|
|
2071
|
+
}
|
|
2072
|
+
function En() {
|
|
2073
|
+
for (var e, t, n = 0, o = "", r = arguments.length; n < r; n++) (e = arguments[n]) && (t = bi(e)) && (o && (o += " "), o += t);
|
|
2074
|
+
return o;
|
|
2075
|
+
}
|
|
2076
|
+
yi.displayName = "Selection";
|
|
2077
|
+
const Si = Dt(Ut((e, t) => {
|
|
2078
|
+
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;
|
|
2079
|
+
if (n === 0 || o === 0) return null;
|
|
2080
|
+
let f = !0, x = !0, E = !0, I = !0;
|
|
2081
|
+
switch (s) {
|
|
2082
|
+
case "tl":
|
|
2083
|
+
f = !1, x = !1;
|
|
2084
|
+
break;
|
|
2085
|
+
case "bl":
|
|
2086
|
+
f = !1, I = !1;
|
|
2087
|
+
break;
|
|
2088
|
+
case "br":
|
|
2089
|
+
E = !1, I = !1;
|
|
2090
|
+
break;
|
|
2091
|
+
case "tr":
|
|
2092
|
+
x = !1, E = !1;
|
|
2093
|
+
}
|
|
2094
|
+
return Y("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: E ? `${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 });
|
|
2095
|
+
}));
|
|
2096
|
+
Si.displayName = "FillHandle";
|
|
2097
|
+
var Gl = function() {
|
|
2098
|
+
}, Ei = typeof window < "u", Zl = Ei ? nn : st, Vr = { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, bottom: 0, right: 0 };
|
|
2099
|
+
const _i = Ei && window.ResizeObserver !== void 0 ? function() {
|
|
2100
|
+
var e = Je(null), t = e[0], n = e[1], o = Je(Vr), r = o[0], i = o[1], l = Ee(function() {
|
|
2101
|
+
return new window.ResizeObserver(function(s) {
|
|
2102
|
+
if (s[0]) {
|
|
2103
|
+
var a = s[0].contentRect, d = a.x, g = a.y, m = a.width, f = a.height, x = a.top, E = a.left, I = a.bottom, M = a.right;
|
|
2104
|
+
i({ x: d, y: g, width: m, height: f, top: x, left: E, bottom: I, right: M });
|
|
2105
|
+
}
|
|
2106
|
+
});
|
|
2107
|
+
}, []);
|
|
2108
|
+
return Zl(function() {
|
|
2109
|
+
if (t) return l.observe(t), function() {
|
|
2110
|
+
l.disconnect();
|
|
2111
|
+
};
|
|
2112
|
+
}, [t]), [n, r];
|
|
2113
|
+
} : function() {
|
|
2114
|
+
return [Gl, Vr];
|
|
2115
|
+
};
|
|
2116
|
+
function Bo(e, t) {
|
|
2117
|
+
if (typeof e == "function") return e(t);
|
|
2118
|
+
e && (e.current = t);
|
|
2119
|
+
}
|
|
2120
|
+
var Jl = parseInt(qr.split(".")[0], 10) >= 19 ? function(e) {
|
|
2121
|
+
return (t) => {
|
|
2122
|
+
const n = [];
|
|
2123
|
+
for (const o of e) {
|
|
2124
|
+
const r = Bo(o, t), i = typeof r == "function";
|
|
2125
|
+
n.push(i ? r : () => Bo(o, null));
|
|
2126
|
+
}
|
|
2127
|
+
return () => {
|
|
2128
|
+
for (const o of n) o();
|
|
2129
|
+
};
|
|
2130
|
+
};
|
|
2131
|
+
} : function(e) {
|
|
2132
|
+
return (t) => {
|
|
2133
|
+
for (const n of e) Bo(n, t);
|
|
2134
|
+
};
|
|
2135
|
+
};
|
|
2136
|
+
const Go = Dt(Ut((e, t) => {
|
|
2137
|
+
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: E, scrollableElement: I, scrollableRoot: M = document.body, ...ae } = e, R = T(f, [f]), _ = T(x, [x]), { bounds: L, coordsPivot: le, key: $ } = Ee(() => {
|
|
2138
|
+
if (!n || !o) return null;
|
|
2139
|
+
let W = null, A = null;
|
|
2140
|
+
switch (r) {
|
|
2141
|
+
case "tl":
|
|
2142
|
+
W = { colIndex: n.colEnd, rowIndex: n.rowEnd }, A = { colIndex: n.colStart, rowIndex: n.rowStart };
|
|
2143
|
+
break;
|
|
2144
|
+
case "br":
|
|
2145
|
+
W = { colIndex: n.colStart, rowIndex: n.rowStart }, A = { colIndex: n.colEnd, rowIndex: n.rowEnd };
|
|
2146
|
+
break;
|
|
2147
|
+
case "t":
|
|
2148
|
+
case "l":
|
|
2149
|
+
W = { colIndex: n.colEnd, rowIndex: n.rowEnd };
|
|
2150
|
+
break;
|
|
2151
|
+
case "b":
|
|
2152
|
+
W = { colIndex: n.colStart, rowIndex: n.rowStart };
|
|
2153
|
+
break;
|
|
2154
|
+
case "r":
|
|
2155
|
+
W = { colIndex: n.colStart, rowIndex: n.rowEnd };
|
|
2156
|
+
}
|
|
2157
|
+
let q = o.getRangeCoordsBounds(A ? { rowStart: A.rowIndex, colStart: A.colIndex, rowEnd: A.rowIndex, colEnd: A.colIndex } : n);
|
|
2158
|
+
const N = o.getBounds(), xe = o.getViewportSize(), G = N.x, He = N.y, Ue = xe.width, We = xe.height;
|
|
2159
|
+
switch (r) {
|
|
2160
|
+
case "tl":
|
|
2161
|
+
break;
|
|
2162
|
+
case "br":
|
|
2163
|
+
q.x = q.x + q.width, q.y = q.y + q.height;
|
|
2164
|
+
break;
|
|
2165
|
+
case "t":
|
|
2166
|
+
q.x = Ue / 2 - G;
|
|
2167
|
+
break;
|
|
2168
|
+
case "b":
|
|
2169
|
+
q.x = Ue / 2 - G, q.y = q.y + q.height;
|
|
2170
|
+
break;
|
|
2171
|
+
case "l":
|
|
2172
|
+
q.y = We / 2 - He;
|
|
2173
|
+
break;
|
|
2174
|
+
case "r":
|
|
2175
|
+
q.x = q.x + q.width, q.y = We / 2 - He;
|
|
2176
|
+
}
|
|
2177
|
+
const ht = o.toClipBounds(q, 0);
|
|
2178
|
+
return !ht || ht.width <= 0 || ht.height <= 0 || q.x < 0 || q.y < 0 || q.x > Ue || q.y > We ? { bounds: null, coordsAnchor: null, coordsPivot: null, key: null } : { bounds: q, coordsAnchor: null, coordsPivot: W, key: "touchSelect-" + o.getAnchor() + "-" + r };
|
|
2179
|
+
}, [n, o, r]), oe = J(null), be = On(Ee(() => {
|
|
2180
|
+
const W = (A) => r === "t" || r === "b" ? { ...A, colIndex: void 0 } : r === "l" || r === "r" ? { ...A, rowIndex: void 0 } : A;
|
|
2181
|
+
return { processTouch: !0, consumeTouch: !0, onPointerDown: (A, q) => {
|
|
2182
|
+
const N = W(o.getCellCoordsFromClient(A.clientX, A.clientY));
|
|
2183
|
+
return oe.current = { coordsPivot: le }, R?.(r), m.onSelectionPointerDown(A, q, o, N, le, !1, !0);
|
|
2184
|
+
}, onPointerMoveOrWait: (A, q, N) => {
|
|
2185
|
+
const xe = W(o.getCellCoordsFromClient(A.clientX, A.clientY));
|
|
2186
|
+
return m.onSelectionPointerMoveOrWait(A, q, N, o, xe, oe.current?.coordsPivot, !0, !0);
|
|
2187
|
+
}, onPointerUp: (A, q, N) => (oe.current = null, _?.(r), m.onPointerUp(A, q, N)) };
|
|
2188
|
+
}, [m, n, o, r])), [U, { y: H, x: X }] = _i(), k = J(null), { getPortalContainer: u } = gi(), [C, ee] = Je(null);
|
|
2189
|
+
return st(() => {
|
|
2190
|
+
const W = k.current?.getBoundingClientRect();
|
|
2191
|
+
if (!W || !L) return void ee(null);
|
|
2192
|
+
let A = 0, q = 0, N = I;
|
|
2193
|
+
for (; N; ) A += N.scrollLeft, q += N.scrollTop, N = M && N === M.parentElement ? null : N.parentElement;
|
|
2194
|
+
ee(Kr(Y("div", { className: En("touch-select-handle", g), ref: t, style: { position: "absolute", left: A + (W?.x ?? 0) - (a + s) / 2, top: q + (W?.y ?? 0) - (a + s) / 2, width: a, height: a, borderWidth: `${s}px`, border: i, borderRadius: "50%", background: l, boxShadow: `0 0 0 1.5px ${l}`, cursor: "grab", pointerEvents: "all", opacity: E ? 0 : 1, transitionDuration: "160ms", transitionProperty: "opacity", ...d }, tabIndex: -1, onPointerDown: be, ...ae }), M ?? u(), $));
|
|
2195
|
+
}, [H, X, L?.x, L?.y, L?.width, L?.height, g, E, l, a, s, i, I]), L ? Ht(wn, { children: [Y("div", { ref: Jl([U, k]), style: { position: "absolute", left: L.x, top: L.y, opacity: 0 } }), C] }) : null;
|
|
2196
|
+
}));
|
|
2197
|
+
Go.displayName = "TouchSelectHandle";
|
|
2198
|
+
const tn = -10, Ql = Object.freeze({ rowStart: 0, colStart: 0, rowEnd: 0, colEnd: 0 }), Ii = Object.freeze({ colIndex: 0, rowIndex: 0 }), Zo = Object.freeze([]), Yt = (e) => {
|
|
2199
|
+
if (e && e.cell && e.ranges && e.rangeIndex > -1 && e.rangeIndex <= e.ranges.length) return e;
|
|
2200
|
+
const t = { cell: null, ranges: e?.ranges ?? Zo };
|
|
2201
|
+
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), Z.isEqualSelectionCoords(t, e) ? e : t;
|
|
2202
|
+
}, lo = (e, t, n) => {
|
|
2203
|
+
const o = e.getVisibleRangeCoords(), r = e.getScrollOrientation();
|
|
2204
|
+
!r.horizontal && (t.colIndex > o.colEnd || t.colIndex < o.colStart) && (t = { ...t, colIndex: t.colIndex > o.colEnd ? o.colEnd + 1 : o.colEnd - 1 }, e = n.current.getViewFromLocation(Xt)), !r.vertical && (t.rowIndex > o.rowEnd || t.rowIndex < o.rowStart) && (t = { ...t, rowIndex: t.rowIndex > o.rowEnd ? o.rowEnd + 1 : o.rowEnd - 1 }, e = n.current.getViewFromLocation(Xt)), e.scrollCellCoordsIntoView(t);
|
|
2205
|
+
}, es = () => !1, ms = ({ gridRef: e, commands: t, layout: n, selection: o, onSelectionChange: r, onSelectionDragStart: i, onSelectionDragEnd: l, selectionPolicy: s = "multiple", newSelectionMode: a = "clear", allowDeselectSelection: d = !0, onFillPreview: g, onFillCancel: m, onFillDone: f, onFill: x, disableFillDrag: E = !x, fillHandleBorderColor: I = "white", hiddenRowsAt: M, hiddenColumnsAt: ae, isContentfulCell: R, contentfulCellFinder: _ = ql, getDataCoords: L, alwaysScrollToActiveCoords: le = !1, selectionBounds: $, pointerDownInterceptor: oe, pointerMoveInterceptor: be, mergedRanges: U, canSelectionSpanMergedCells: H = es, onMoveDragStart: X, onMoveDragUpdate: k, onMoveDragEnd: u, onMoveDragDone: C, selectionRenderer: ee = Xl, disableMoveDrag: W = !u, getCellCoordsAsRangeCoords: A = Z.cellToRange, moveDragHitSize: q = 6, moveDragOutlineSize: N = 4, selectionBackgroundColor: xe = "rgba(16, 124, 65, 0.1)", selectionBorderColor: G = "rgb(33, 115, 70)", selectionRemoveBorderColor: He = "rgb(255, 0, 0)", selectionRemoveBackgroundColor: Ue = "rgba(250, 10, 10, 0.1)", disableTouchSelection: We = !1, touchSelectHandleProps: ht }) => {
|
|
2206
|
+
const _e = O(() => ({ top: $?.top ?? 0, left: $?.left ?? 0, bottom: e.current?.rowCount - 1 || 0, right: e.current?.columnCount - 1 || 0 }), []), S = T(x, [x]), ue = T(g, [g]), K = T(m, [m]), pe = T(f, [f]), te = T(R, [R]), Re = T(ee, [ee]), at = T((c, h = !1) => go(c, h, n.getRowOffset, h ? _e().bottom : _e().top), [n?.getRowOffset]), pt = T(M ?? at, [M]), zt = T((c, h = !1) => go(c, h, n.getColOffset, h ? _e().right : _e().left), [n?.getColOffset]), gt = T(ae ?? zt, [ae]), [Zt, Be] = Je(() => Yt(o)), z = Ee(() => Yt(Zt), [Zt]), ke = J(z), Qe = J(!0);
|
|
2207
|
+
nn(Ct.throttle(() => {
|
|
2208
|
+
Be((c) => {
|
|
2209
|
+
Qe.current = !0;
|
|
2210
|
+
const h = Yt(o);
|
|
2211
|
+
return Z.isEqualSelectionCoords(h, c) ? c : h;
|
|
2212
|
+
});
|
|
2213
|
+
}, 0), [o]), nn(() => {
|
|
2214
|
+
ke.current = z;
|
|
2215
|
+
}, [z]), st(() => {
|
|
2216
|
+
Qe.current || !r || Z.isEqualSelectionCoords(o, z) || r(z);
|
|
2217
|
+
}, [z]);
|
|
2218
|
+
const Xe = O((c) => {
|
|
2219
|
+
Be((h) => {
|
|
2220
|
+
Qe.current = !1, h = Yt(h);
|
|
2221
|
+
let w = typeof c == "function" ? c(h.ranges) : c ?? Zo;
|
|
2222
|
+
if (Z.isEqualRangesArrays(w, h.ranges)) return h;
|
|
2223
|
+
let p = Math.max(w.length ? 0 : -1, Math.min(h.rangeIndex, w.length - 1)), y = h.cell;
|
|
2224
|
+
p === -1 || Z.isCellWithinRange(y, w[p]) || (y = { rowIndex: w[p].rowStart, colIndex: w[p].colStart }), w.length === 1 && Z.isSingleCell(w[0]) && Z.isCellWithinRange(y, w[0]) && (w = [], p = -1);
|
|
2225
|
+
const V = { cell: y, ranges: w, rangeIndex: p };
|
|
2226
|
+
return Z.isEqualSelectionCoords(V, h) ? h : V;
|
|
2227
|
+
});
|
|
2228
|
+
}, []), wt = T((c) => {
|
|
2229
|
+
Be((h) => {
|
|
2230
|
+
Qe.current = !1, h = Yt(h);
|
|
2231
|
+
const w = c ?? Ii, p = A(w);
|
|
2232
|
+
if (!Z.isSingleCell(p) && h.ranges.length === 0) return { ranges: [p], rangeIndex: 0, cell: w };
|
|
2233
|
+
if (Z.isEqualCells(w, h.cell)) return h;
|
|
2234
|
+
let y = h.ranges, V = h.rangeIndex;
|
|
2235
|
+
h.ranges.length === 1 && (Z.isSingleCell(h.ranges[0]) && Z.isCellWithinRange(w, h.ranges[0]) || !Z.isCellWithinRange(w, h.ranges[0])) && (y = [], V = -1);
|
|
2236
|
+
const b = { ranges: y, rangeIndex: V, cell: w };
|
|
2237
|
+
return Z.isEqualSelectionCoords(b, h) ? h : b;
|
|
2238
|
+
});
|
|
2239
|
+
}, [A]), [an, Jt] = Je(null), [jt, dn] = Je(null), on = J(null), [ze, qt] = Je(null), vt = J(null), Vt = J(null), [Cn, un] = Je(null), Ne = J(null), Q = J(null), et = J(U);
|
|
2240
|
+
st(() => {
|
|
2241
|
+
et.current = U;
|
|
2242
|
+
}, [U]);
|
|
2243
|
+
const qe = T((c, h = { inline: "nearest", block: "nearest" }) => {
|
|
2244
|
+
let { rowIndex: w, colIndex: p } = c;
|
|
2245
|
+
w === void 0 && z?.cell && (w = z.cell.rowIndex), p === void 0 && z?.cell && (p = z.cell.colIndex), w !== void 0 && p !== void 0 && e.current?.scrollCellCoordsIntoView({ rowIndex: w, colIndex: p }, h);
|
|
2246
|
+
}, [z]), dt = O((c) => {
|
|
2247
|
+
const h = _e();
|
|
2248
|
+
return c.rowIndex < h.top || c.colIndex < h.left || c.colIndex > h.right || c.rowIndex > h.bottom;
|
|
2249
|
+
}, []), Ie = T((c, h) => {
|
|
2250
|
+
if (!e?.current) return null;
|
|
2251
|
+
const w = { rowStart: Math.min(c.rowIndex, h.rowIndex), colStart: Math.min(c.colIndex, h.colIndex), rowEnd: Math.max(c.rowIndex, h.rowIndex), colEnd: Math.max(c.colIndex, h.colIndex) };
|
|
2252
|
+
if (H?.(w)) return w;
|
|
2253
|
+
const y = A(c), V = A(h), b = { rowStart: Math.min(y.rowStart, V.rowStart), colStart: Math.min(y.colStart, V.colStart), rowEnd: Math.max(y.rowEnd, V.rowEnd), colEnd: Math.max(y.colEnd, V.colEnd) };
|
|
2254
|
+
let he;
|
|
2255
|
+
return typeof et.current == "function" ? he = et.current(b) : U && (he = U), he ? Z.extendRangeToUnionRanges(b, he) : b;
|
|
2256
|
+
}, [H, A]), Le = T((c, h, w) => {
|
|
2257
|
+
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(h.rowIndex ?? p.rowStart, w.rowIndex ?? p.rowStart), colStart: Math.min(h.colIndex ?? p.colStart, w.colIndex ?? p.colStart), rowEnd: Math.max(h.rowIndex ?? p.rowEnd, w.rowIndex ?? p.rowEnd), colEnd: Math.max(h.colIndex ?? p.colEnd, w.colIndex ?? p.colEnd) }, V = { rowIndex: y.rowStart, colIndex: y.colStart }, b = { rowIndex: y.rowEnd, colIndex: y.colEnd };
|
|
2258
|
+
if (!(dt(V) || dt(b)))
|
|
2259
|
+
return Ie(V, b);
|
|
2260
|
+
}, [Ie]), rt = T((c, h, w) => {
|
|
2261
|
+
if (s === "single" || !ke.current) return;
|
|
2262
|
+
const p = Le(ke.current, c, h ?? ke.current.cell);
|
|
2263
|
+
if (!p) return;
|
|
2264
|
+
const y = ke.current.rangeIndex;
|
|
2265
|
+
Xe((V) => V.length ? V.map((b, he) => y === he ? p : b) : [p]), w && p && wt({ colIndex: p.colStart, rowIndex: p.rowStart });
|
|
2266
|
+
}, []), tt = O((c, h, w) => {
|
|
2267
|
+
if (!ke.current) return;
|
|
2268
|
+
c = { ...ke.current?.cell, ...c }, h = h ?? c;
|
|
2269
|
+
const p = Le(ke.current, c, h);
|
|
2270
|
+
if (!p) return;
|
|
2271
|
+
const y = { rowIndex: p.rowStart, colIndex: p.colStart }, V = { ...y, ...w };
|
|
2272
|
+
a === "clear" ? (Ne.current = V, rn()) : a === "modify" ? rt(y) : Ae(y), wt(V);
|
|
2273
|
+
}, []), Ae = O((c, h = c, w) => {
|
|
2274
|
+
s !== "multiple" || !c || dt(c) || dt(h) || Be((p) => {
|
|
2275
|
+
Qe.current = !1, p = Yt(p);
|
|
2276
|
+
const y = Ie(c, h);
|
|
2277
|
+
if (!y) return p;
|
|
2278
|
+
let V = p.ranges.length > 0 ? [...p.ranges] : [Ie(p.cell, p.cell)];
|
|
2279
|
+
V.push(y);
|
|
2280
|
+
const b = { ranges: V, cell: { rowIndex: y.rowStart, colIndex: y.colStart, ...w }, rangeIndex: V.length - 1 };
|
|
2281
|
+
return Z.isEqualSelectionCoords(b, p) ? p : b;
|
|
2282
|
+
});
|
|
2283
|
+
}, []), rn = () => {
|
|
2284
|
+
Xe(Zo);
|
|
2285
|
+
}, Mt = me.detectIt().primaryInput === "touch", nt = J(null), Tt = J(null), kt = J(null), hn = Ee(() => ({ onPointerDown: (c) => {
|
|
2286
|
+
if (!e || !e.current) return !1;
|
|
2287
|
+
const h = c.nativeEvent, w = e.current.getViewFromClient(h.clientX, h.clientY);
|
|
2288
|
+
if (h.pointerType === "touch" || h.type === "touchstart") return Tt.current = { topLeft: w.getScrollTopLeft(), point: { x: h.clientX, y: h.clientY } }, !0;
|
|
2289
|
+
const p = w.getCellCoordsFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY);
|
|
2290
|
+
if (!p) return !1;
|
|
2291
|
+
nt.current = { anchor: w.getAnchor(), coords: p }, Q.current = null;
|
|
2292
|
+
const y = c.nativeEvent.which === _r;
|
|
2293
|
+
if (y && Z.indexOfCoords(p, z.ranges) !== -1)
|
|
2294
|
+
return !1;
|
|
2295
|
+
const V = c.nativeEvent.shiftKey, b = c.nativeEvent.ctrlKey || c.nativeEvent.metaKey, he = b, ne = d, re = z.ranges.length > 0, we = b && ne;
|
|
2296
|
+
if (oe?.(c, p, z) === !1) return !1;
|
|
2297
|
+
i?.(ke.current, c.nativeEvent);
|
|
2298
|
+
const De = !y && s !== "single";
|
|
2299
|
+
if (V) return rt(p), De;
|
|
2300
|
+
const de = Z.isEqualCells(p, z.cell);
|
|
2301
|
+
if (he) {
|
|
2302
|
+
if (de && (!we || !re)) return De;
|
|
2303
|
+
if (b && Z.indexOfCoords(p, z.ranges) !== -1 && ne) {
|
|
2304
|
+
vt.current = p;
|
|
2305
|
+
const ie = Ie(p, p);
|
|
2306
|
+
return Vt.current = ie, qt(ie), De;
|
|
2307
|
+
}
|
|
2308
|
+
return Ae(p), De;
|
|
2309
|
+
}
|
|
2310
|
+
le && qe(p), de && z.ranges.length === 0 || tt(p);
|
|
2311
|
+
}, onPointerMoveOrWait: Ct.throttle((c, h) => {
|
|
2312
|
+
if (!e?.current || c.pointerType === "touch" || c.type === "touchmove" || !nt.current) return;
|
|
2313
|
+
const w = nt.current.anchor;
|
|
2314
|
+
let p = e.current.getViewFromLocation(w), y = p.getCellCoordsFromClient(c.clientX, c.clientY);
|
|
2315
|
+
if (!Z.isEqualCells(y, nt.current?.coords) && (nt.current = { anchor: w, coords: y }, y && be?.(c, y, ke.current) !== !1)) {
|
|
2316
|
+
if (vt.current) {
|
|
2317
|
+
const V = { rowStart: Math.min(y.rowIndex, vt.current.rowIndex), colStart: Math.min(y.colIndex, vt.current.colIndex), rowEnd: Math.max(y.rowIndex, vt.current.rowIndex), colEnd: Math.max(y.colIndex, vt.current.colIndex) }, b = { rowIndex: V.rowStart, colIndex: V.colStart }, he = { rowIndex: V.rowEnd, colIndex: V.colEnd };
|
|
2318
|
+
if (dt(b) || dt(he)) return;
|
|
2319
|
+
const ne = Ie(b, he);
|
|
2320
|
+
Vt.current = ne, qt(ne);
|
|
2321
|
+
} else rt(y);
|
|
2322
|
+
kt.current = h, lo(p, y, e);
|
|
2323
|
+
}
|
|
2324
|
+
}, 60), onPointerUp: (c) => {
|
|
2325
|
+
if (nt.current = null, c.pointerType === "touch" || c.type === "touchend") {
|
|
2326
|
+
if (Tt.current) {
|
|
2327
|
+
const w = e.current.getViewFromClient(Tt.current.point.x, Tt.current.point.y), p = w.getScrollTopLeft();
|
|
2328
|
+
if (p.left === Tt.current.topLeft.left && p.top === Tt.current.topLeft.top) {
|
|
2329
|
+
const y = w.getCellCoordsFromClient(Tt.current.point.x, Tt.current.point.y);
|
|
2330
|
+
tt(y);
|
|
2331
|
+
}
|
|
2332
|
+
}
|
|
2333
|
+
return Tt.current = null, void (nt.current = null);
|
|
2334
|
+
}
|
|
2335
|
+
try {
|
|
2336
|
+
l?.(ke.current, c);
|
|
2337
|
+
} catch (w) {
|
|
2338
|
+
console.warn(w);
|
|
2339
|
+
}
|
|
2340
|
+
if (!vt.current) return;
|
|
2341
|
+
const h = Vt.current;
|
|
2342
|
+
vt.current = null, Vt.current = null, qt(null), Be((w) => {
|
|
2343
|
+
if (Qe.current = !1, (w = Yt(w)).ranges.length === 0) return w;
|
|
2344
|
+
let p = [], y = -1, V = w.cell;
|
|
2345
|
+
for (let he = 0; he < w.ranges.length; he++) {
|
|
2346
|
+
const ne = w.ranges[he];
|
|
2347
|
+
if (Z.isRangesIntersect(ne, h)) {
|
|
2348
|
+
const re = Ct.subtractRect({ top: ne.rowStart, left: ne.colStart, bottom: ne.rowEnd + 1, right: ne.colEnd + 1 }, { top: h.rowStart, left: h.colStart, bottom: h.rowEnd + 1, right: h.colEnd + 1 });
|
|
2349
|
+
for (let we = 0; we < re.length; we++) {
|
|
2350
|
+
const De = { rowStart: re[we].top, colStart: re[we].left, rowEnd: re[we].bottom - 1, colEnd: re[we].right - 1 };
|
|
2351
|
+
p.push(De), Z.isCellWithinRange(w.cell, De) && (y = p.length - 1);
|
|
2352
|
+
}
|
|
2353
|
+
} else p.push(ne);
|
|
2354
|
+
p.length > 0 && y === -1 && Z.isCellWithinRange(w.cell, ne) && (y = p.length - 1, V = { rowIndex: p[p.length - 1].rowStart, colIndex: p[p.length - 1].colStart });
|
|
2355
|
+
}
|
|
2356
|
+
const b = { cell: V, rangeIndex: y, ranges: p };
|
|
2357
|
+
return Z.isEqualSelectionCoords(b, w) ? w : b;
|
|
2358
|
+
});
|
|
2359
|
+
}, processTouch: !0, consumeTouch: !1 }), [z, s, d, le, a]), mo = T(On(hn), []), xo = Ee(() => ({ onSelectionPointerDown: (c, h, w, p, y = z.cell, V = le, b = c.nativeEvent.shiftKey, he = !1) => {
|
|
2360
|
+
if (!e || !e.current) return !1;
|
|
2361
|
+
c.stopPropagation(), c.preventDefault(), c.nativeEvent.stopImmediatePropagation();
|
|
2362
|
+
const ne = w ?? e.current.getViewFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY), re = p ?? ne.getCellCoordsFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY);
|
|
2363
|
+
if (!re) return !1;
|
|
2364
|
+
nt.current = { anchor: ne.getAnchor(), coords: re }, Q.current = null;
|
|
2365
|
+
const we = c.nativeEvent.which === _r;
|
|
2366
|
+
if (we && Z.indexOfCoords(re, z.ranges) !== -1)
|
|
2367
|
+
return !1;
|
|
2368
|
+
const De = c.nativeEvent.ctrlKey || c.nativeEvent.metaKey, de = De, ie = d, _t = z.ranges.length > 0, B = De && ie;
|
|
2369
|
+
if (oe?.(c, re, z) === !1) return !1;
|
|
2370
|
+
i?.(ke.current, c.nativeEvent);
|
|
2371
|
+
const Pe = !we && s !== "single";
|
|
2372
|
+
if (b) return rt(re, y, he), Pe;
|
|
2373
|
+
const Rt = Z.isEqualCells(re, y);
|
|
2374
|
+
if (de) {
|
|
2375
|
+
if (Rt && (!B || !_t)) return Pe;
|
|
2376
|
+
if (B && Z.indexOfCoords(re, z.ranges) !== -1 && ie) {
|
|
2377
|
+
vt.current = re;
|
|
2378
|
+
const Te = Ie(re, re);
|
|
2379
|
+
return Vt.current = Te, qt(Te), Pe;
|
|
2380
|
+
}
|
|
2381
|
+
return Ae(re), Pe;
|
|
2382
|
+
}
|
|
2383
|
+
V && qe(re), Rt && z.ranges.length === 0 || tt(re);
|
|
2384
|
+
}, onSelectionPointerMoveOrWait: (c, h, w, p, y, V = z.cell, b = !0, he = !1) => {
|
|
2385
|
+
if (!e?.current || (c.stopPropagation(), c.preventDefault(), c.stopImmediatePropagation(), !nt.current)) return;
|
|
2386
|
+
const ne = nt.current.anchor;
|
|
2387
|
+
let re = p ?? e.current.getViewFromLocation(ne), we = y ?? re.getCellCoordsFromClient(c.clientX, c.clientY);
|
|
2388
|
+
if (!Z.isEqualCells(we, nt.current?.coords) && (nt.current = { anchor: ne, coords: we }, we && be?.(c, we, ke.current) !== !1)) {
|
|
2389
|
+
if (vt.current) {
|
|
2390
|
+
const De = { rowStart: Math.min(we.rowIndex, vt.current.rowIndex), colStart: Math.min(we.colIndex, vt.current.colIndex), rowEnd: Math.max(we.rowIndex, vt.current.rowIndex), colEnd: Math.max(we.colIndex, vt.current.colIndex) }, de = { rowIndex: De.rowStart, colIndex: De.colStart }, ie = { rowIndex: De.rowEnd, colIndex: De.colEnd };
|
|
2391
|
+
if (dt(de) || dt(ie)) return;
|
|
2392
|
+
const _t = Ie(de, ie);
|
|
2393
|
+
Vt.current = _t, qt(_t);
|
|
2394
|
+
} else rt(we, V, he);
|
|
2395
|
+
b && lo(re, we, e);
|
|
2396
|
+
}
|
|
2397
|
+
}, onPointerUp: (c) => {
|
|
2398
|
+
nt.current = null, c.stopPropagation(), c.preventDefault(), c.stopImmediatePropagation();
|
|
2399
|
+
try {
|
|
2400
|
+
l?.(ke.current, c);
|
|
2401
|
+
} catch (w) {
|
|
2402
|
+
console.warn(w);
|
|
2403
|
+
}
|
|
2404
|
+
if (!vt.current) return;
|
|
2405
|
+
const h = Vt.current;
|
|
2406
|
+
vt.current = null, Vt.current = null, qt(null), Be((w) => {
|
|
2407
|
+
if (Qe.current = !1, (w = Yt(w)).ranges.length === 0) return w;
|
|
2408
|
+
let p = [], y = -1, V = w.cell;
|
|
2409
|
+
for (let he = 0; he < w.ranges.length; he++) {
|
|
2410
|
+
const ne = w.ranges[he];
|
|
2411
|
+
if (Z.isRangesIntersect(ne, h)) {
|
|
2412
|
+
const re = Ct.subtractRect({ top: ne.rowStart, left: ne.colStart, bottom: ne.rowEnd + 1, right: ne.colEnd + 1 }, { top: h.rowStart, left: h.colStart, bottom: h.rowEnd + 1, right: h.colEnd + 1 });
|
|
2413
|
+
for (let we = 0; we < re.length; we++) {
|
|
2414
|
+
const De = { rowStart: re[we].top, colStart: re[we].left, rowEnd: re[we].bottom - 1, colEnd: re[we].right - 1 };
|
|
2415
|
+
p.push(De), Z.isCellWithinRange(w.cell, De) && (y = p.length - 1);
|
|
2416
|
+
}
|
|
2417
|
+
} else p.push(ne);
|
|
2418
|
+
p.length > 0 && y === -1 && Z.isCellWithinRange(w.cell, ne) && (y = p.length - 1, V = { rowIndex: p[p.length - 1].rowStart, colIndex: p[p.length - 1].colStart });
|
|
2419
|
+
}
|
|
2420
|
+
const b = { cell: V, rangeIndex: y, ranges: p };
|
|
2421
|
+
return Z.isEqualSelectionCoords(b, w) ? w : b;
|
|
2422
|
+
});
|
|
2423
|
+
} }), [z, s, d, le, a]), ft = T((c, h = !1, w = !1, p = 0) => {
|
|
2424
|
+
if (!e.current || !z.cell) return;
|
|
2425
|
+
let y = z.cell, V = z.cell;
|
|
2426
|
+
if (h && z.ranges.length > 0) {
|
|
2427
|
+
const B = z.ranges[z.rangeIndex], Pe = z.cell;
|
|
2428
|
+
switch (c) {
|
|
2429
|
+
case it:
|
|
2430
|
+
V = { rowIndex: Pe.rowIndex === B.rowStart ? B.rowEnd : B.rowStart, colIndex: B.colEnd }, y = { rowIndex: Pe.rowIndex === B.rowStart ? B.rowStart : B.rowEnd, colIndex: B.colStart };
|
|
2431
|
+
break;
|
|
2432
|
+
case lt:
|
|
2433
|
+
V = { rowIndex: Pe.rowIndex === B.rowEnd ? B.rowStart : B.rowEnd, colIndex: B.colEnd }, y = { rowIndex: Pe.rowIndex === B.rowEnd ? B.rowEnd : B.rowStart, colIndex: B.colStart };
|
|
2434
|
+
break;
|
|
2435
|
+
case ot:
|
|
2436
|
+
V = { rowIndex: B.rowEnd, colIndex: Pe.colIndex === B.colStart ? B.colEnd : B.colStart }, y = { rowIndex: B.rowStart, colIndex: Pe.colIndex === B.colStart ? B.colStart : B.colEnd };
|
|
2437
|
+
break;
|
|
2438
|
+
case Ke:
|
|
2439
|
+
V = { rowIndex: B.rowEnd, colIndex: Pe.colIndex === B.colEnd ? B.colStart : B.colEnd }, y = { rowIndex: B.rowStart, colIndex: Pe.colIndex === B.colEnd ? B.colEnd : B.colStart };
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
const b = A(V);
|
|
2443
|
+
let { rowStart: he, colStart: ne } = b;
|
|
2444
|
+
const re = _e();
|
|
2445
|
+
if (Q.current) switch (c) {
|
|
2446
|
+
case it:
|
|
2447
|
+
case lt:
|
|
2448
|
+
Q.current.colIndex >= b.colStart && Q.current.colIndex <= b.colEnd && (ne = Q.current.colIndex);
|
|
2449
|
+
break;
|
|
2450
|
+
case ot:
|
|
2451
|
+
case Ke:
|
|
2452
|
+
Q.current.rowIndex >= b.rowStart && Q.current.rowIndex <= b.rowEnd && (he = Q.current.rowIndex);
|
|
2453
|
+
}
|
|
2454
|
+
if (!p) {
|
|
2455
|
+
switch (c) {
|
|
2456
|
+
case it:
|
|
2457
|
+
he = Ye(pt, Math.max(b.rowStart - 1, re.top), c);
|
|
2458
|
+
break;
|
|
2459
|
+
case lt:
|
|
2460
|
+
he = Ye(pt, Math.min(b.rowEnd + 1, re.bottom), c);
|
|
2461
|
+
break;
|
|
2462
|
+
case ot:
|
|
2463
|
+
ne = Ye(gt, Math.max(b.colStart - 1, re.left), c);
|
|
2464
|
+
break;
|
|
2465
|
+
case Ke:
|
|
2466
|
+
ne = Ye(gt, Math.min(b.colEnd + 1, re.right), c);
|
|
2467
|
+
}
|
|
2468
|
+
if (w) switch (c) {
|
|
2469
|
+
case it:
|
|
2470
|
+
he = _({ ...V, colIndex: z.cell.colIndex }, te, pt, c, !1, Math.max(re.top, pt(re.top, !1)));
|
|
2471
|
+
break;
|
|
2472
|
+
case lt:
|
|
2473
|
+
he = _({ ...V, colIndex: z.cell.colIndex }, te, pt, c, !1, Math.min(re.bottom, re.bottom - pt(re.bottom, !0)));
|
|
2474
|
+
break;
|
|
2475
|
+
case ot:
|
|
2476
|
+
ne = _({ ...V, rowIndex: z.cell.rowIndex }, te, gt, c, !1, Math.max(re.left, gt(re.left, !1)));
|
|
2477
|
+
break;
|
|
2478
|
+
case Ke:
|
|
2479
|
+
ne = _({ ...V, rowIndex: z.cell.rowIndex }, te, gt, c, !1, Math.min(re.right, re.right - gt(re.right, !0)));
|
|
2480
|
+
}
|
|
2481
|
+
}
|
|
2482
|
+
let we = null;
|
|
2483
|
+
if (p) {
|
|
2484
|
+
let B = 0;
|
|
2485
|
+
switch (c) {
|
|
2486
|
+
case it:
|
|
2487
|
+
B = n.getRowOffset(he + 1), he = Math.max(re.top, n.getRowIndex(B - p)), we = { top: n.getRowOffset(he + 1) - (B - e.current.getScrollPosition().top) };
|
|
2488
|
+
break;
|
|
2489
|
+
case lt:
|
|
2490
|
+
B = n.getRowOffset(he), he = Math.min(re.bottom, n.getRowIndex(B + p)), we = { top: n.getRowOffset(he) - (B - e.current.getScrollPosition().top) };
|
|
2491
|
+
break;
|
|
2492
|
+
case ot:
|
|
2493
|
+
B = n.getColOffset(ne + 1), ne = Math.max(re.left, n.getColIndex(B - p)), we = { left: n.getColOffset(ne + 1) - (B - e.current.getScrollPosition().left) };
|
|
2494
|
+
break;
|
|
2495
|
+
case Ke:
|
|
2496
|
+
B = n.getColOffset(ne), ne = Math.min(re.right, n.getColIndex(B + p)), we = { left: n.getColOffset(ne) - (B - e.current.getScrollPosition().left) };
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
const De = { rowIndex: he, colIndex: ne }, de = A(De), ie = { rowIndex: de.rowStart, colIndex: de.colStart };
|
|
2500
|
+
h || (Q.current = De);
|
|
2501
|
+
const _t = Z.isEqualCells(Ne.current, ie) && Z.isEqualCells(Ne.current, y);
|
|
2502
|
+
if (h && !_t ? rt(ie, y) : tt(ie), we) e.current.scrollTo(we);
|
|
2503
|
+
else {
|
|
2504
|
+
if (h && Ne.current) {
|
|
2505
|
+
const B = _e();
|
|
2506
|
+
if (c === Ke && Ne.current.colIndex === B.left || c === ot && Ne.current.colIndex === B.right || c === it && Ne.current.rowIndex === B.bottom || c === lt && Ne.current.rowIndex === B.top) return;
|
|
2507
|
+
}
|
|
2508
|
+
c === ot || c === Ke ? qe({ colIndex: De.colIndex }) : c !== it && c !== lt || qe({ rowIndex: De.rowIndex });
|
|
2509
|
+
}
|
|
2510
|
+
}, [z, A]), ln = T((c) => {
|
|
2511
|
+
if (!e.current) return;
|
|
2512
|
+
if (z.ranges.length === 0) return void ft(c);
|
|
2513
|
+
const h = A(z.cell);
|
|
2514
|
+
if (Z.isEqualRangesArrays([h], z.ranges)) return void ft(c);
|
|
2515
|
+
const w = Xo(z, c, A, pt, gt);
|
|
2516
|
+
Be((p) => {
|
|
2517
|
+
Qe.current = !1, p = Yt(p);
|
|
2518
|
+
const y = { ...p, cell: w.cell, rangeIndex: w.rangeIndex };
|
|
2519
|
+
return Z.isEqualSelectionCoords(y, p) ? p : y;
|
|
2520
|
+
}), w.cell && qe(w.cell);
|
|
2521
|
+
}, [z, A]), vo = O(() => {
|
|
2522
|
+
const c = _e();
|
|
2523
|
+
rt({ rowIndex: c.top }, { rowIndex: c.bottom });
|
|
2524
|
+
}, []), yo = O(() => {
|
|
2525
|
+
const c = _e();
|
|
2526
|
+
rt({ colIndex: c.left }, { colIndex: c.right });
|
|
2527
|
+
}, []), xn = T(() => {
|
|
2528
|
+
z.cell && e?.current && qe(z.cell);
|
|
2529
|
+
}, [z.cell]), Kn = O((c = !1) => {
|
|
2530
|
+
const h = { rowIndex: _e().top };
|
|
2531
|
+
c ? rt(h) : tt(h), qe(h);
|
|
2532
|
+
}, []), Yn = O((c = !1) => {
|
|
2533
|
+
const h = { rowIndex: _e().bottom };
|
|
2534
|
+
c ? rt(h) : tt(h), qe(h);
|
|
2535
|
+
}, []), Dn = O((c = !1) => {
|
|
2536
|
+
const h = { colIndex: _e().left };
|
|
2537
|
+
c ? rt(h) : tt(h), qe(h);
|
|
2538
|
+
}, []), Mn = O((c = !1) => {
|
|
2539
|
+
const h = _e(), w = { rowIndex: h.top, colIndex: h.left };
|
|
2540
|
+
c ? rt(w) : tt(w), qe(w);
|
|
2541
|
+
}, []), zn = O((c = !1) => {
|
|
2542
|
+
const h = _e(), w = { colIndex: L?.()?.colEnd ?? h.right };
|
|
2543
|
+
c ? rt(w) : tt(w), qe(w);
|
|
2544
|
+
}, [L]), vn = O((c = !1) => {
|
|
2545
|
+
const h = _e(), w = { rowIndex: L?.()?.rowEnd ?? h.bottom, colIndex: L?.()?.colEnd ?? h.right };
|
|
2546
|
+
c ? rt(w) : tt(w), qe(w);
|
|
2547
|
+
}, [L]), An = T((c) => {
|
|
2548
|
+
if (!e.current || z.ranges.length <= 1) return;
|
|
2549
|
+
const h = c === ot || c === it;
|
|
2550
|
+
let w = z.rangeIndex + (h ? -1 : 1);
|
|
2551
|
+
w < 0 ? w = z.ranges.length - 1 : w > z.ranges.length - 1 && (w = 0);
|
|
2552
|
+
const p = z.ranges[w], y = Xo({ cell: { rowIndex: p.rowEnd, colIndex: p.colEnd }, rangeIndex: 0, ranges: [p] }, Ke, A, pt, gt);
|
|
2553
|
+
Be((V) => {
|
|
2554
|
+
Qe.current = !1, V = Yt(V);
|
|
2555
|
+
const b = { ...V, cell: y.cell, rangeIndex: w };
|
|
2556
|
+
return Z.isEqualSelectionCoords(b, V) ? V : b;
|
|
2557
|
+
}), y.cell && qe(y.cell);
|
|
2558
|
+
}, [z, A]), bo = T(() => {
|
|
2559
|
+
const c = Ar(z);
|
|
2560
|
+
Be((h) => {
|
|
2561
|
+
Qe.current = !1, h = Yt(h);
|
|
2562
|
+
const w = { ...h, visibleSelection: c };
|
|
2563
|
+
return Z.isEqualSelectionCoords(w, h) ? h : w;
|
|
2564
|
+
}), c.cell && qe(c.cell);
|
|
2565
|
+
}, [z, A]), So = T(() => {
|
|
2566
|
+
if (!e.current || z.ranges.length === 0) return;
|
|
2567
|
+
const c = z.cell, h = z.ranges[z.rangeIndex], w = Ar({ cell: c, rangeIndex: 0, ranges: [h] }), p = w.ranges[w.rangeIndex];
|
|
2568
|
+
let y;
|
|
2569
|
+
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 }, Be((V) => {
|
|
2570
|
+
V = Yt(V);
|
|
2571
|
+
const b = { ...V, cell: y };
|
|
2572
|
+
return Z.isEqualSelectionCoords(b, V) ? V : b;
|
|
2573
|
+
}), y && qe(y);
|
|
2574
|
+
}, [z, A]), Xn = O((c = !1) => {
|
|
2575
|
+
ft(lt, c, !1, e.current.getDimensions().containerHeight);
|
|
2576
|
+
}, []), Qt = O((c = !1) => {
|
|
2577
|
+
ft(it, c, !1, e.current.getDimensions().containerHeight);
|
|
2578
|
+
}, []), Gn = O((c = !1) => {
|
|
2579
|
+
ft(Ke, c, !1, e.current.getDimensions().containerWidth);
|
|
2580
|
+
}, []), $n = O((c = !1) => {
|
|
2581
|
+
ft(ot, c, !1, e.current.getDimensions().containerWidth);
|
|
2582
|
+
}, []), Zn = O(() => {
|
|
2583
|
+
ln(ot);
|
|
2584
|
+
}, []), Jn = O(() => {
|
|
2585
|
+
ln(Ke);
|
|
2586
|
+
}, []), Eo = O(() => {
|
|
2587
|
+
ln(it);
|
|
2588
|
+
}, []), _o = O(() => {
|
|
2589
|
+
ln(lt);
|
|
2590
|
+
}, []), Bn = O(() => {
|
|
2591
|
+
An(ot);
|
|
2592
|
+
}, []), Io = O(() => {
|
|
2593
|
+
An(Ke);
|
|
2594
|
+
}, []), Co = O(() => {
|
|
2595
|
+
So();
|
|
2596
|
+
}, []), Qn = O(() => {
|
|
2597
|
+
ft(ot, !1, !1);
|
|
2598
|
+
}, []), v = O(() => {
|
|
2599
|
+
ft(ot, !0, !1);
|
|
2600
|
+
}, []), P = O(() => {
|
|
2601
|
+
ft(ot, !1, !0);
|
|
2602
|
+
}, []), D = O(() => {
|
|
2603
|
+
ft(ot, !0, !0);
|
|
2604
|
+
}, []), F = O(() => {
|
|
2605
|
+
ft(Ke, !1, !1);
|
|
2606
|
+
}, []), j = O(() => {
|
|
2607
|
+
ft(Ke, !0, !1);
|
|
2608
|
+
}, []), fe = O(() => {
|
|
2609
|
+
ft(Ke, !1, !0);
|
|
2610
|
+
}, []), se = O(() => {
|
|
2611
|
+
ft(Ke, !0, !0);
|
|
2612
|
+
}, []), ve = O(() => {
|
|
2613
|
+
ft(it, !1, !1);
|
|
2614
|
+
}, []), ye = O(() => {
|
|
2615
|
+
ft(it, !0, !1);
|
|
2616
|
+
}, []), ce = O(() => {
|
|
2617
|
+
ft(it, !1, !0);
|
|
2618
|
+
}, []), Ve = O(() => {
|
|
2619
|
+
ft(it, !0, !0);
|
|
2620
|
+
}, []), ut = O(() => {
|
|
2621
|
+
ft(lt, !1, !1);
|
|
2622
|
+
}, []), Fe = O(() => {
|
|
2623
|
+
ft(lt, !0, !1);
|
|
2624
|
+
}, []), je = O(() => {
|
|
2625
|
+
ft(lt, !1, !0);
|
|
2626
|
+
}, []), mt = O(() => {
|
|
2627
|
+
ft(lt, !0, !0);
|
|
2628
|
+
}, []), Ge = O(() => {
|
|
2629
|
+
Xe((c) => c.slice(0, -1));
|
|
2630
|
+
}, []), Pt = Ee(() => {
|
|
2631
|
+
const c = _e();
|
|
2632
|
+
return ((h, w, p, y, V) => {
|
|
2633
|
+
for (let b = 0; b < h.length; b++) {
|
|
2634
|
+
const he = h[b];
|
|
2635
|
+
if (he.rowStart === w && he.colStart === p && he.rowEnd === y && he.colEnd === V) return !0;
|
|
2636
|
+
}
|
|
2637
|
+
return !1;
|
|
2638
|
+
})(z.ranges, c.top, c.left, c.bottom, c.right);
|
|
2639
|
+
}, [$, z.ranges]), yt = O((c, h = !0) => {
|
|
2640
|
+
Ne.current = c, wt(c), h && c && e?.current && qe(c);
|
|
2641
|
+
}, []), ge = T((c = !0) => {
|
|
2642
|
+
const h = on.current;
|
|
2643
|
+
if (!ke.current?.cell) return;
|
|
2644
|
+
const w = ke.current?.ranges, p = ke.current?.cell;
|
|
2645
|
+
if (!p || !h || !h) return;
|
|
2646
|
+
let y = null;
|
|
2647
|
+
if (y = w.length > 0 ? w[w.length - 1] : A(p), y.colEnd >= y.colStart && y.rowEnd >= y.rowStart) {
|
|
2648
|
+
const V = $r(y, h);
|
|
2649
|
+
let b = c ? S : ue;
|
|
2650
|
+
try {
|
|
2651
|
+
b?.(y, h, V.direction);
|
|
2652
|
+
} catch (he) {
|
|
2653
|
+
console.warn(he);
|
|
2654
|
+
} finally {
|
|
2655
|
+
c && pe?.();
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
}, [A]), xt = J(null), At = On(Ee(() => ({ onPointerDown: (c, h) => {
|
|
2659
|
+
if (kt.current = h, !e || !e.current) return !1;
|
|
2660
|
+
const w = e.current.getViewFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY), p = w?.getCellCoordsFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY);
|
|
2661
|
+
p && (c.stopPropagation(), Jt("crosshair"), xt.current = { anchor: w.getAnchor(), coords: p });
|
|
2662
|
+
}, onPointerMoveOrWait: (c, h) => {
|
|
2663
|
+
if (E || !e?.current || !ke.current || !xt.current) return;
|
|
2664
|
+
const w = xt.current.anchor;
|
|
2665
|
+
let p = e.current.getViewFromLocation(w), y = p.getCellCoordsFromClient(c.clientX, c.clientY);
|
|
2666
|
+
if (!y) return;
|
|
2667
|
+
xt.current = { anchor: w, coords: y };
|
|
2668
|
+
const V = ke.current.ranges;
|
|
2669
|
+
let b = Ie(ke.current.cell, y);
|
|
2670
|
+
if (!b) return;
|
|
2671
|
+
const he = V.length > 0, ne = he ? V[V.length - 1] : A(ke.current.cell);
|
|
2672
|
+
if (!b) return;
|
|
2673
|
+
const re = b.rowStart < ne.rowStart ? it : b.rowEnd > ne.rowEnd ? lt : b.colEnd > ne.colEnd ? Ke : ot, we = _e();
|
|
2674
|
+
re === ot && (b = { ...ne, colStart: Math.max(we.left, b.colStart) }), re === it && (b = { ...ne, rowStart: Math.max(we.top, b.rowStart) }), re === Ke && (b = { ...ne, colEnd: Math.min(we.right, b.colEnd) }), re === lt && (b = { ...ne, rowEnd: Math.min(we.bottom, b.rowEnd) });
|
|
2675
|
+
const De = $r(ne, b);
|
|
2676
|
+
if (!H?.(ne)) {
|
|
2677
|
+
let de;
|
|
2678
|
+
typeof et.current == "function" ? de = et.current(ne) : U && (de = U), b = ((ie, _t, B, Pe, Rt, Te) => {
|
|
2679
|
+
const Me = { ..._t };
|
|
2680
|
+
if (B.length === 0) return Me;
|
|
2681
|
+
if (Rt === ot) {
|
|
2682
|
+
const St = ie.colEnd + 1 - ie.colStart;
|
|
2683
|
+
Me.colStart = ie.colStart - Math.ceil(Te / St) * St, Me.colStart < Pe.left && (Me.colStart = Me.colStart + Math.ceil((Pe.left - Me.colStart) / St) * St);
|
|
2684
|
+
} else if (Rt === Ke) {
|
|
2685
|
+
const St = ie.colEnd + 1 - ie.colStart;
|
|
2686
|
+
Me.colEnd = ie.colEnd + Math.ceil(Te / St) * St, Me.colEnd > Pe.right && (Me.colEnd = Me.colEnd - Math.ceil((Pe.right - Me.colEnd) / St) * St);
|
|
2687
|
+
} else if (Rt === it) {
|
|
2688
|
+
const St = ie.rowEnd + 1 - ie.rowStart;
|
|
2689
|
+
Me.rowStart = ie.rowStart - Math.ceil(Te / St) * St, Me.rowStart < Pe.top && (Me.rowStart = Me.rowStart + Math.ceil((Pe.top - Me.rowStart) / St) * St);
|
|
2690
|
+
} else if (Rt === lt) {
|
|
2691
|
+
const St = ie.rowEnd + 1 - ie.rowStart;
|
|
2692
|
+
Me.rowEnd = ie.rowEnd + Math.ceil(Te / St) * St, Me.rowEnd > Pe.bottom && (Me.rowEnd = Me.rowEnd - Math.ceil((Pe.bottom - Me.rowEnd) / St) * St);
|
|
2693
|
+
}
|
|
2694
|
+
return Me;
|
|
2695
|
+
})(ne, b, de, we, De.direction, De.amount);
|
|
2696
|
+
}
|
|
2697
|
+
if (he && Z.isRangeWithinRange(b, ne) && (b = null), !Z.isEqualRanges(b, on.current)) {
|
|
2698
|
+
if (dn(b), on.current = b, !b) {
|
|
2699
|
+
try {
|
|
2700
|
+
K?.();
|
|
2701
|
+
} catch {
|
|
2702
|
+
}
|
|
2703
|
+
return void pe?.();
|
|
2704
|
+
}
|
|
2705
|
+
ge(!1);
|
|
2706
|
+
}
|
|
2707
|
+
kt.current = h, lo(p, y, e);
|
|
2708
|
+
}, onPointerUp: (c, h) => {
|
|
2709
|
+
kt.current = h, Promise.resolve(ge(!0)).finally(() => {
|
|
2710
|
+
pe?.(), dn(null), on.current = null, xt.current = null, Jt(null), e.current?.focus();
|
|
2711
|
+
});
|
|
2712
|
+
} }), [A])), Wt = Ee(() => ({ onPointerDown: At }), [At]), [Ce, Ze] = Je(null), $e = J(null), ct = Ee(() => ({ onPointerDown: (c, h) => {
|
|
2713
|
+
if (kt.current = h, !e || !e.current) return !1;
|
|
2714
|
+
const w = e.current.getViewFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY), p = w?.getCellCoordsFromClient(c.nativeEvent.clientX, c.nativeEvent.clientY);
|
|
2715
|
+
if (!p) return;
|
|
2716
|
+
if (oe?.(c, p, z) === !1) return !1;
|
|
2717
|
+
c.stopPropagation(), Jt("default");
|
|
2718
|
+
const y = w.getRelativePointFromClient(0, 0), V = ke.current?.ranges[ke.current?.ranges.length - 1] ?? Z.cellToRange(ke.current?.cell), b = w.toClipBounds(w.getRangeCoordsBounds(V)), he = { x: 0, y: 0 };
|
|
2719
|
+
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?.(V, c.nativeEvent, h), $e.current = { range: V, anchor: w.getAnchor(), cell: p, isMoving: !1, extrusion: he };
|
|
2720
|
+
}, onPointerMoveOrWait: (c, h, w) => {
|
|
2721
|
+
if (W || !e?.current || !ke.current || !$e.current) return;
|
|
2722
|
+
const p = c.clientX - w.clientX, y = c.clientY - w.clientY;
|
|
2723
|
+
if ($e.current.isMoving = $e.current.isMoving || Math.abs(p) > Math.max(1, 2) || Math.abs(y) > Math.max(1, 2) || performance.now() - w.timeStamp > 500, !$e.current.isMoving) return;
|
|
2724
|
+
const V = $e.current.anchor, b = $e.current.extrusion;
|
|
2725
|
+
let he = e.current.getViewFromLocation(V), ne = he.getCellCoordsFromClient(c.clientX - b.x, c.clientY - b.y, !0);
|
|
2726
|
+
if (!ne) return;
|
|
2727
|
+
const re = $e.current.cell, we = $e.current.range, De = _e(), de = we.colEnd - we.colStart + 1, ie = Math.min(Math.max(0, re.colIndex - we.colStart), de - 1), _t = Math.min(De.right - de + 1, Math.max(De.left, ne.colIndex - ie)), B = we.rowEnd - we.rowStart + 1, Pe = Math.min(Math.max(0, re.rowIndex - we.rowStart), B - 1), Rt = Math.min(De.bottom - B + 1, Math.max(De.top, ne.rowIndex - Pe)), Te = { colStart: _t, colEnd: _t + de - 1, rowStart: Rt, rowEnd: Rt + B - 1 };
|
|
2728
|
+
Z.isEqualRanges(Ce, Te) && !((Me) => !Me || !kt.current || kt.current.ctrlKey !== Me.ctrlKey || kt.current.shiftKey !== Me.shiftKey || kt.current.altKey !== Me.altKey || kt.current.metaKey !== Me.metaKey)(c) || (Ze(Te), k?.(Te, c, h)), kt.current = h, lo(he, ne, e);
|
|
2729
|
+
}, onPointerUp: (c, h) => {
|
|
2730
|
+
kt.current = h;
|
|
2731
|
+
const w = () => {
|
|
2732
|
+
Ze(null), $e.current = null, Jt(null), e.current?.focus();
|
|
2733
|
+
};
|
|
2734
|
+
if (!$e.current) return void w();
|
|
2735
|
+
const p = $e.current.range, y = Ce;
|
|
2736
|
+
u?.(p, c, h), Promise.resolve(p && y && C?.(p, y, c, h)).finally(() => {
|
|
2737
|
+
w();
|
|
2738
|
+
});
|
|
2739
|
+
} }), [Ce]), Oe = On(ct), Et = Ee(() => ({ onPointerDown: Oe }), [Oe]), bt = J(null), $t = Ee(() => {
|
|
2740
|
+
const c = Z.isEqualSelectionCoords(z, bt.current) ? bt.current : z;
|
|
2741
|
+
return bt.current = c, c;
|
|
2742
|
+
}, [z]), Kt = O((c) => {
|
|
2743
|
+
let h = null, w = "br";
|
|
2744
|
+
const p = [], y = { stroke: I, fill: xe, strokeWidth: 0.5 }, V = (de, ie, _t) => {
|
|
2745
|
+
const B = c.toClipBounds(c.getRangeCoordsBounds(de), tn);
|
|
2746
|
+
if (!B) return;
|
|
2747
|
+
B.x = B.width > 0 ? B.x : B.x - y.strokeWidth / 2, B.y = B.height > 0 ? B.y : B.y - y.strokeWidth / 2, B.width = Math.max(B.width, y.strokeWidth), B.height = Math.max(B.height, y.strokeWidth);
|
|
2748
|
+
const Pe = { key: `selection-fill-${ie}`, range: de, ...B, ...y };
|
|
2749
|
+
if (_t) {
|
|
2750
|
+
const Rt = c.getCellCoordsAsRangeCoords(_t);
|
|
2751
|
+
Pe.cell = _t, Pe.pathBounds = c.toClipBounds(c.getRangeCoordsBounds(Rt), tn), Pe.pathBounds && (Pe.pathBounds.width <= 0 || Pe.pathBounds.height <= 0) && (delete Pe.pathBounds, delete Pe.cell);
|
|
2752
|
+
}
|
|
2753
|
+
return Re(Pe);
|
|
2754
|
+
};
|
|
2755
|
+
let b = z ? Yt(z) : null;
|
|
2756
|
+
const he = b?.cell ? c.getCellCoordsAsRangeCoords(b?.cell) : Ql;
|
|
2757
|
+
!b || b.ranges && b.ranges.length !== 0 || (b = { ranges: [he], rangeIndex: 0, cell: b.cell });
|
|
2758
|
+
for (let de = 0; b && de < b.ranges.length; de++) {
|
|
2759
|
+
const ie = b.ranges[de], _t = V(ie, de, de === b.rangeIndex ? b.cell : null);
|
|
2760
|
+
_t && p.push(_t);
|
|
2761
|
+
const B = 2, Pe = 0.5, Rt = c.toClipBounds(c.getRangeCoordsBounds(ie, { top: 0, left: 0, right: 0, bottom: 0 }), tn);
|
|
2762
|
+
if (Rt) {
|
|
2763
|
+
const Te = (b.ranges.length, 4);
|
|
2764
|
+
p.push(Re({ range: ie, key: `selection-inside-edge-${de}`, x: Rt.x - 1, y: Rt.y - 1, width: Math.max(Rt.width + 1, 0), height: Math.max(Rt.height + 1, 0), style: { overflow: "hidden" }, stroke: I, strokeWidth: Te }));
|
|
2765
|
+
}
|
|
2766
|
+
if (b.ranges.length === 1) {
|
|
2767
|
+
const Te = c.toClipBounds(c.getRangeCoordsBounds(ie), tn);
|
|
2768
|
+
if (Te) {
|
|
2769
|
+
W || p.push(Re({ range: ie, key: `move-selection-hit-box-${de}`, x: Te.width > 1 ? Te.x : Te.x - (q / 2 + 1), y: Te.height > 1 ? Te.y : Te.y - (q / 2 + 1), width: Math.max(Te.width + 2, 1), height: Math.max(Te.height + 2, 1), stroke: "transparent", style: { boxShadow: "none" }, pathProps: { cursor: Ce ? void 0 : "move", pointerEvents: "stroke" }, strokeWidth: q, ...Et }));
|
|
2770
|
+
const Me = B;
|
|
2771
|
+
p.push(Re({ range: ie, key: `selection-single-${de}`, x: Te.x - Me / 2, y: Te.y - Me / 2, width: Math.max(Te.width + Me / 2, 1), height: Math.max(Te.height + Me / 2, 1), stroke: G, strokeWidth: Me }));
|
|
2772
|
+
}
|
|
2773
|
+
} else {
|
|
2774
|
+
const Te = c.toClipBounds(c.getRangeCoordsBounds(ie, { top: -1, left: -1, right: -2, bottom: -2 }), tn);
|
|
2775
|
+
Te && p.push(Re({ range: ie, key: `selection-multi-${de}`, x: Te.width > 1 ? Te.x : Te.x - Pe / 2, y: Te.height > 1 ? Te.y : Te.y - Pe / 2, width: Math.max(Te.width, Pe) + 1, height: Math.max(Te.height, Pe) + 1, stroke: G, style: { overflow: "hidden" }, strokeWidth: 2 }));
|
|
2776
|
+
}
|
|
2777
|
+
if (b.ranges.length > 1 && de === b.rangeIndex) {
|
|
2778
|
+
const Te = c.getCellCoordsAsRangeCoords(b.cell), Me = c.toClipBounds(c.getRangeCoordsBounds(Te, { top: 1, left: 1, right: -1, bottom: -1 }), tn);
|
|
2779
|
+
Me && p.push(Re({ range: ie, key: `selection-anchor-${de}`, x: Me.x, y: Me.y, width: Math.max(Me.width, Pe), height: Math.max(Me.height, Pe), stroke: G, style: { overflow: "hidden" }, strokeWidth: 2 }));
|
|
2780
|
+
}
|
|
2781
|
+
if (de === b.ranges.length - 1) {
|
|
2782
|
+
h = null, w = null;
|
|
2783
|
+
const Te = ie.rowStart === _e().top && ie.rowEnd === _e().bottom, Me = ie.colStart === _e().left && ie.colEnd === _e().right, St = c.getRangeCoordsBounds(ie);
|
|
2784
|
+
let en = null;
|
|
2785
|
+
if (Te || Me) {
|
|
2786
|
+
if (en = c.toClipBounds(St, tn), Object.keys(c.allViews()).length > 1) {
|
|
2787
|
+
const eo = c.getVisibleRangeCoords(), nr = c.allViews()[uo], ki = c.allViews()[Hn], Pi = c.allViews()[Nn], to = c.getAnchor();
|
|
2788
|
+
(Me && (to === Hn && nr || to === Xt && Pi || !Z.isCellWithinRange({ colIndex: ie.colStart, rowIndex: ie.rowEnd }, eo) && !Z.isCellWithinRange({ colIndex: ie.colStart, rowIndex: ie.rowEnd + 1 }, eo)) || Te && (to === Nn && nr || to === Xt && ki || !Z.isCellWithinRange({ colIndex: ie.colEnd, rowIndex: ie.rowStart }, eo) && !Z.isCellWithinRange({ colIndex: ie.colEnd + 1, rowIndex: ie.rowStart }, eo))) && (en = null);
|
|
2789
|
+
}
|
|
2790
|
+
} else en = c.toClipBounds(St, tn);
|
|
2791
|
+
if (!en || en.width === 0 || en.height === 0) continue;
|
|
2792
|
+
h = { x: en.x + en.width + 1, y: en.y + en.height + 1 }, en.width === 0 || en.height === 0 || ie.rowStart === _e().top && ie.colStart === _e().left && ie.rowEnd === _e().bottom && ie.colEnd === _e().right || (Te ? (h.y = B, w = "tr") : Me && (h.x = B, w = "bl"));
|
|
2793
|
+
}
|
|
2794
|
+
}
|
|
2795
|
+
let ne = null;
|
|
2796
|
+
if (ze) {
|
|
2797
|
+
const de = c.toClipBounds(c.getRangeCoordsBounds(ze, { top: 0, left: 0, right: 0, bottom: 0 }), tn);
|
|
2798
|
+
de && (ne = Re({ ...y, range: ze, key: "remove-selection", x: de.x, y: de.y, width: de.width, height: de.height, strokeWidth: 2, stroke: He, fill: Ue }));
|
|
2799
|
+
}
|
|
2800
|
+
let re = null;
|
|
2801
|
+
if (jt) {
|
|
2802
|
+
const de = c.toClipBounds(c.getRangeCoordsBounds(jt, { top: 0, left: 0, right: 0, bottom: 0 }), tn);
|
|
2803
|
+
de && (re = Re({ range: jt, 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: G, strokeDasharray: "3 2" }));
|
|
2804
|
+
}
|
|
2805
|
+
let we = null;
|
|
2806
|
+
!E && h && !Ce && (we = Jo(Si, { ...h, corner: w, size: 7.5, borderStroke: `${I} solid`, style: { borderRadius: 1 }, background: G, ...Wt, key: "fillHandle" }));
|
|
2807
|
+
const De = [...p];
|
|
2808
|
+
if (ne && De.push(ne), re && De.push(re), we && De.push(we), !We && Mt && b?.ranges.length === 1 && b.ranges[b.ranges.length - 1]) {
|
|
2809
|
+
const de = b.ranges[b.ranges.length - 1], ie = de.rowStart === _e().top && de.rowEnd === _e().bottom, _t = de.colStart === _e().left && de.colEnd === _e().right, B = { view: c, range: de, borderStroke: `${G} solid`, background: I, selectionTouchPointerHandler: xo, ...ht, onTouchSelectStart: (Pe) => un(Pe), onTouchSelectEnd: () => un(null), currentTouchAnchor: Cn };
|
|
2810
|
+
De.push(Y(Go, { anchor: _t ? "b" : ie ? "r" : "br", scrollableElement: e.current, ...B }, "touch-select-handle-after")), De.push(Y(Go, { anchor: _t ? "t" : ie ? "l" : "tl", scrollableElement: e.current, ...B }, "touch-select-handle-before"));
|
|
2811
|
+
}
|
|
2812
|
+
if (Ce) {
|
|
2813
|
+
const de = c.toClipBounds(c.getRangeCoordsBounds(Ce, { top: 1, left: 1, right: 1, bottom: 1 }), tn);
|
|
2814
|
+
de && De.push(Re({ range: Ce, key: "selection-move-outline", x: de.x - N / 2, y: de.y - N / 2, width: Math.max(de.width + N / 2, 1), height: Math.max(de.height + N / 2, 1), stroke: G, style: { boxShadow: "none", transitionDuration: "70ms", transitionTimingFunction: "ease-in", transitionProperty: "left, top, width, height", willChange: "left, top, width, height" }, strokeWidth: N }));
|
|
2815
|
+
}
|
|
2816
|
+
return Y("div", { children: De }, "selection");
|
|
2817
|
+
}, [$t, ze, E, jt, W, Ce, _e, I, G, xe, He, Ue, We, ht, Cn]), Ot = Ee(() => {
|
|
2818
|
+
const c = () => e.current;
|
|
2819
|
+
return [new Se("moveToPageDown", c, { label: "Page Down", description: "Shift viewport down one page.", shortcut: [{ key: "PageDown" }] }, () => Xn(!1)), new Se("selectToPageDown", c, { label: "Select To Page Down", description: "Shift viewport and select down one page.", shortcut: [{ key: "PageDown", modifiers: [It] }] }, () => Xn(!0)), new Se("moveToPageRight", c, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [yn] }] }, () => Gn(!1)), new Se("selectToPageRight", c, { label: "Page Right", description: "Shift viewport right one page.", shortcut: [{ key: "PageDown", modifiers: [yn, It] }] }, () => Gn(!0)), new Se("moveToPageUp", c, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp" }] }, () => Qt(!1)), new Se("selectToPageUp", c, { label: "Page Up", description: "Shift viewport up one page.", shortcut: [{ key: "PageUp", modifiers: [It] }] }, () => Qt(!0)), new Se("moveToPageLeft", c, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [yn] }] }, () => $n(!1)), new Se("selectToPageLeft", c, { label: "Page Left", description: "Shift viewport left one page.", shortcut: [{ key: "PageUp", modifiers: [yn, It] }] }, () => $n(!0)), new Se("selectColumn", c, { label: "Select Column", description: "Select the columns for the selected cells.", shortcut: { key: "Space", modifiers: [Lt] } }, vo), new Se("selectRow", c, { label: "Select Row", description: "Select the rows for the selected cells.", shortcut: { key: "Space", modifiers: [It] } }, yo), new Se("selectToColumnStart", c, { label: "Select To Column Start", description: "Select the columns to the beginning of the sheet." }, () => Kn(!0)), new Se("selectToColumnEnd", c, { label: "Select To Column End", description: "Select the columns to the end of the sheet." }, () => Yn(!0)), new Se("moveToRowStart", c, { label: "Move to Row Home", description: "Move to the beginning of the row.", shortcut: [{ key: "Home" }] }, () => Dn(!1)), new Se("selectToRowStart", c, { label: "Select to Row Home", description: "Select to the beginning of the row.", shortcut: [{ key: "Home", modifiers: [It] }] }, () => Dn(!0)), new Se("moveToSheetStart", c, { label: "Move to Sheet Home", description: "Move to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [Lt] }] }, () => Mn(!1)), new Se("selectToSheetStart", c, { label: "Select to Sheet Home", description: "Select to the beginning of the sheet.", shortcut: [{ key: "Home", modifiers: [Lt, It] }] }, () => Mn(!0)), new Se("moveToRowEnd", c, { label: "Move to Row End", description: "Move to the end of the row.", shortcut: [{ key: "End" }] }, () => zn(!1)), new Se("selectToRowEnd", c, { label: "Select to Row End", description: "Select to the end of the row.", shortcut: [{ key: "End", modifiers: [It] }] }, () => zn(!0)), new Se("moveToSheetEnd", c, { label: "Move to Sheet End", description: "Move to the end of the sheet.", shortcut: [{ key: "End", modifiers: [Lt] }] }, () => vn(!1)), new Se("selectToSheetEnd", c, { label: "Select to Sheet End", description: "Select to the end of the sheet.", shortcut: [{ key: "End", modifiers: [Lt, It] }] }, () => vn(!0)), new Se("scrollToActiveCoords", c, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell.", shortcut: { key: "Backspace", modifiers: [Lt] } }, xn), new Se("scrollToActiveCoordsClearSelection", c, { label: "Scroll to Active Cell", description: "Scroll to the Active Cell and clear selection.", shortcut: { key: "Backspace", modifiers: [It] } }, () => {
|
|
2820
|
+
rn(), yt(z.cell, !0);
|
|
2821
|
+
}), new Se("traverseSelectionRight", c, { label: "Traverse Right", description: "Traverse the selection moving rightward.", shortcut: { key: "Tab" } }, Jn), new Se("traverseSelectionLeft", c, { label: "Traverse Left", description: "Traverse the selection moving leftward.", shortcut: { key: "Tab", modifiers: [It] } }, Zn), new Se("traverseSelectionDown", c, { label: "Traverse Down", description: "Traverse the selection moving downward.", shortcut: [{ key: "Enter" }, { key: "NumpadEnter" }] }, _o), new Se("traverseSelectionUp", c, { label: "Traverse Up", description: "Traverse the selection moving upward.", shortcut: [{ key: "Enter", modifiers: [It] }, { key: "NumpadEnter", modifiers: [It] }] }, Eo), new Se("moveLeft", c, { label: "Move Left", description: "Move active cell to the left.", shortcut: [{ key: "ArrowLeft" }] }, Qn), new Se("selectLeft", c, { label: "Select Left", description: "Extend selection left.", shortcut: [{ key: "ArrowLeft", modifiers: [It] }] }, v), new Se("moveContentfulLeft", c, { label: "Move Left Contentful", description: "Move left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [Lt] }] }, P), new Se("selectContentfulLeft", c, { label: "Select Left Contentful", description: "Extend selection left to the next cell with content.", shortcut: [{ key: "ArrowLeft", modifiers: [Lt, It] }] }, D), new Se("moveRight", c, { label: "Move Right", description: "Move active cell to the right.", shortcut: [{ key: "ArrowRight" }] }, F), new Se("selectRight", c, { label: "Select Right", description: "Extend selection right.", shortcut: [{ key: "ArrowRight", modifiers: [It] }] }, j), new Se("moveContentfulRight", c, { label: "Move Right Contentful", description: "Move right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [Lt] }] }, fe), new Se("selectContentfulRight", c, { label: "Select Right Contentful", description: "Extend selection right to the next cell with content.", shortcut: [{ key: "ArrowRight", modifiers: [Lt, It] }] }, se), new Se("moveUp", c, { label: "Move Up", description: "Move active cell to the up.", shortcut: [{ key: "ArrowUp" }] }, ve), new Se("selectUp", c, { label: "Select Up", description: "Extend selection up.", shortcut: [{ key: "ArrowUp", modifiers: [It] }] }, ye), new Se("moveContentfulUp", c, { label: "Move Up Contentful", description: "Move up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [Lt] }] }, ce), new Se("selectContentfulUp", c, { label: "Select Up Contentful", description: "Extend selection up to the next cell with content.", shortcut: [{ key: "ArrowUp", modifiers: [Lt, It] }] }, Ve), new Se("moveDown", c, { label: "Move Down", description: "Move active cell to the down.", shortcut: [{ key: "ArrowDown" }] }, ut), new Se("selectDown", c, { label: "Select Down", description: "Extend selection down.", shortcut: [{ key: "ArrowDown", modifiers: [It] }] }, Fe), new Se("moveContentfulDown", c, { label: "Move Down Contentful", description: "Move down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [Lt] }] }, je), new Se("selectContentfulDown", c, { label: "Select Down Contentful", description: "Extend selection down to the next cell with content.", shortcut: [{ key: "ArrowDown", modifiers: [Lt, It] }] }, mt), new Se("selectVisible", c, { label: "Select Visible", description: "Select visible cells only.", shortcut: { key: ";", modifiers: [yn] } }, bo), new Se("traverseSelectionPreviousRange", c, { label: "Traverse Previous Range", description: "Traverse the selection to the previous range.", shortcut: { key: "ArrowLeft", modifiers: [Lt, yn] } }, Bn), new Se("traverseSelectionNextRange", c, { label: "Traverse Next Range", description: "Traverse the selection to the next range.", shortcut: { key: "ArrowRight", modifiers: [Lt, yn] } }, Io), new Se("traverseSelectionCorners", c, { label: "Traverse Corners", description: "Traverse the selection through the corners of the selected range.", shortcut: { key: ".", modifiers: [Lt] } }, Co)];
|
|
2822
|
+
}, []);
|
|
2823
|
+
return Ee(() => {
|
|
2824
|
+
t?.addCommands(Ot, !0);
|
|
2825
|
+
}, [t]), { selection: $t, setSelectionCell: yt, setSelectionRanges: Xe, overlay: Kt, cursor: an, onPointerDown: mo, clearLastSelection: Ge, newSelection: tt, modifySelection: rt, appendSelection: Ae, clearSelections: rn, isEntire: Pt, navigate: ft, navigateSelection: ln };
|
|
2826
|
+
};
|
|
2827
|
+
function ao(e, t) {
|
|
2828
|
+
if (!e) throw new Error("Invariant failed");
|
|
2829
|
+
}
|
|
2830
|
+
const Wr = { "sheetxl-grid": "_sheetxl-grid_11irg_13" }, ts = Object.freeze({ top: 0, left: 0 }), ns = Object.freeze({ bottom: -4, right: -4 }), os = Object.freeze({ horizontal: !0, vertical: !0 }), Hr = [uo, Hn, Nn, Xt], xs = 150, sn = 3e3, Fo = {}, Ci = Dt(Ut((e, t) => {
|
|
2831
|
+
const { width: n, height: o, rowCount: r = 1, columnCount: i = 1, defaultRowHeight: l, defaultColumnWidth: s, getRowHeight: a, getColumnWidth: d, layout: g, onViewportScroll: m, onImmediateScroll: f, showGridLines: x = !0, gridLineColor: E = "rgb(224, 224, 224)", gridLineRowsProps: I, gridLineColumnsProps: M, clipCells: ae = !0, cursor: R, freezeLeft: _ = 0, freezeTop: L = 0, freezeLeftProps: le, freezeTopProps: $, cellRenderer: oe, onViewportChange: be, onFirstRender: U, overlayRenderer: H, overlayProps: X, overlays: k, overlaysProps: u, allowOverlaysOverflow: C = !1, stageProps: ee, stageWrapper: W = null, hiddenRowsAt: A, hiddenColumnsAt: q, hiddenCellAt: N, getVisibleCells: xe, zoom: G = 1, enableMouseWheel: He = !0, onWheelScroll: Ue, getCellCoordsAsRangeCoords: We = Z.cellToRange, scrollPoint: ht = ts, style: _e = {}, ...S } = e;
|
|
2832
|
+
ao(oe), ao(!e?.children);
|
|
2833
|
+
const ue = T(f, [f]), K = T(be, [be]), pe = T(m, [m]), te = T(Ue, [Ue]), Re = T(U, [U]), at = J(null), pt = J(null), zt = J(null), [gt, Zt] = Qo((v) => v + 1, 0), [Be, z] = Je({ left: ht?.left ?? 0, top: ht?.top ?? 0, horizontalScrollDirection: null, verticalScrollDirection: null }), ke = J(null), Qe = J(Be), { top: Xe, left: wt, verticalScrollDirection: an, horizontalScrollDirection: Jt } = Be, jt = J(!1), dn = Fl({ rowCount: r, columnCount: i, defaultRowHeight: l, defaultColumnWidth: s, getRowHeight: a, getColumnWidth: d }), on = J(null), ze = Ee(() => {
|
|
2834
|
+
const v = g || dn;
|
|
2835
|
+
return on.current = null, { getColOffset: (P) => v.getColOffset(P) * G, getColIndex: (P) => v.getColIndex(P / G), getRowOffset: (P) => v.getRowOffset(P) * G, getRowIndex: (P) => v.getRowIndex(P / G) };
|
|
2836
|
+
}, [dn, g, G]), qt = (v, P, D) => {
|
|
2837
|
+
const F = (P?.left ?? 0) + 0, j = (P?.top ?? 0) + 0;
|
|
2838
|
+
return { getColOffset: (fe) => v.getColOffset(fe) - F, getColIndex: (fe) => v.getColIndex(fe + F), getRowOffset: (fe) => v.getRowOffset(fe) - j, getRowIndex: (fe) => v.getRowIndex(fe + j) };
|
|
2839
|
+
}, vt = O((v, P = !1) => go(v, P, ze.getRowOffset, P ? 0 : r), [r, ze?.getRowOffset]), Vt = T(A ?? vt, [A]), Cn = O((v, P = !1) => go(v, P, ze.getColOffset, P ? i : 0), [i, ze?.getColOffset]), un = T(q ?? Cn, [q]), Ne = Ee(() => Math.min(n ?? 800, ze.getColOffset(i)), [ze.getColOffset, i, n]), Q = Ee(() => Math.min(o ?? 600, ze.getRowOffset(r)), [ze.getRowOffset, r, o]), et = O((v) => {
|
|
2840
|
+
Ct.canUseDOM && setTimeout(() => {
|
|
2841
|
+
at.current?.focus({ preventScroll: !0, ...v });
|
|
2842
|
+
}, 0);
|
|
2843
|
+
}, []), qe = O((v) => at.current?.contains(v) || pt.current?.contains(v), []);
|
|
2844
|
+
st(() => {
|
|
2845
|
+
jt.current && (ke.current && ke.current.left !== Qe.current?.left && ke.current.top !== Qe.current?.top || (ke.current = null, pe?.({ left: wt, top: Xe })));
|
|
2846
|
+
}, [wt, Xe]);
|
|
2847
|
+
const dt = T(() => ({ top: Xe, left: wt }), [Xe, wt]), Ie = Ee(() => {
|
|
2848
|
+
const v = [];
|
|
2849
|
+
let P = 0, D = 0;
|
|
2850
|
+
typeof L == "number" ? P = L : (P = L.index ?? 0, D = (L.scrollOffset ?? 0) * G);
|
|
2851
|
+
const F = D, j = ze.getRowOffset(P), fe = j - F;
|
|
2852
|
+
if (P > 0) {
|
|
2853
|
+
const ut = qt(ze, { top: D + ze.getRowOffset(0) }), Fe = ze.getRowIndex(F), je = ze.getRowIndex(j - 1);
|
|
2854
|
+
let mt;
|
|
2855
|
+
v[1] = { minIndex: Fe, maxIndex: je, minCoord: 0, maxCoord: P - 1, minBounds: 0, maxBounds: fe, visibleIndices: () => mt || (mt = Object.freeze(io(Vt, Fe, je)), mt), layout: ut, maxVirtualBounds: j, scrollOffset: D, freezeOffset: D };
|
|
2856
|
+
}
|
|
2857
|
+
const se = Math.max(0, Q - fe), ve = qt(ze, { top: Xe + fe }), ye = ve.getRowIndex(0), ce = ve.getRowIndex(se);
|
|
2858
|
+
let Ve;
|
|
2859
|
+
return v[0] = { minIndex: ye, maxIndex: ce, minCoord: P, maxCoord: r - 1, minBounds: fe, maxBounds: se, visibleIndices: () => Ve || (Ve = Object.freeze(io(Vt, ye, ce)), Ve), layout: ve, maxVirtualBounds: ze.getRowOffset(r), scrollOffset: Xe, freezeOffset: (P > 0 ? ze.getRowOffset(P) : 0) - D }, v;
|
|
2860
|
+
}, [ze.getRowIndex, ze.getRowOffset, Vt, Q, r, L, Xe, G]), Le = Ee(() => {
|
|
2861
|
+
const v = [];
|
|
2862
|
+
let P = 0, D = 0;
|
|
2863
|
+
typeof _ == "number" ? P = _ : (P = _.index ?? 0, D = (_.scrollOffset ?? 0) * G);
|
|
2864
|
+
const F = D, j = ze.getColOffset(P), fe = j - F;
|
|
2865
|
+
if (P > 0) {
|
|
2866
|
+
const ut = qt(ze, { left: D + ze.getColOffset(0) }), Fe = ze.getColIndex(F), je = ze.getColIndex(j - 1);
|
|
2867
|
+
let mt;
|
|
2868
|
+
v[1] = { minIndex: Fe, maxIndex: je, minCoord: 0, maxCoord: P - 1, minBounds: 0, maxBounds: fe, visibleIndices: () => mt || (mt = Object.freeze(io(un, Fe, je)), mt), layout: ut, maxVirtualBounds: j, scrollOffset: D, freezeOffset: D };
|
|
2869
|
+
}
|
|
2870
|
+
const se = Math.max(0, Ne - fe), ve = qt(ze, { left: wt + fe }), ye = ve.getColIndex(0), ce = ve.getColIndex(se);
|
|
2871
|
+
let Ve;
|
|
2872
|
+
return v[0] = { minIndex: ye, maxIndex: ce, minCoord: P, maxCoord: i - 1, minBounds: fe, maxBounds: se, visibleIndices: () => Ve || (Ve = Object.freeze(io(un, ye, ce)), Ve), layout: ve, maxVirtualBounds: ze.getColOffset(i), scrollOffset: wt, freezeOffset: (P > 0 ? ze.getColOffset(P) : 0) - D }, v;
|
|
2873
|
+
}, [ze.getColIndex, ze.getColOffset, un, Ne, i, _, wt, G]), rt = J({}), tt = J([]), Ae = Ee(() => {
|
|
2874
|
+
let v = {};
|
|
2875
|
+
const P = (F, j, fe, se, ve) => {
|
|
2876
|
+
const ye = { vertical: se?.vertical || !1, horizontal: se?.horizontal || !1 };
|
|
2877
|
+
if (F >= Le.length || j >= Ie.length) return null;
|
|
2878
|
+
const ce = { rowStart: Ie[j].minIndex, colStart: Le[F].minIndex, rowEnd: Ie[j].maxIndex, colEnd: Le[F].maxIndex };
|
|
2879
|
+
if (ce.rowStart > ce.rowEnd || ce.colStart > ce.colEnd) return null;
|
|
2880
|
+
const Ve = { getColIndex: (Ce) => Le[F].layout.getColIndex(Ce), getColOffset: (Ce) => Le[F].layout.getColOffset(Ce), getRowIndex: (Ce) => Ie[j].layout.getRowIndex(Ce), getRowOffset: (Ce) => Ie[j].layout.getRowOffset(Ce) }, ut = Object.freeze({ left: ve?.left ?? 0, top: ve?.top ?? 0, right: ve?.right ?? 0, bottom: ve?.bottom ?? 0 }), Fe = Object.freeze({ x: Le[F].minBounds, y: Ie[j].minBounds, width: Le[F].maxBounds, height: Ie[j].maxBounds }), je = (Ce, Ze) => Fr(Ve, Ce ?? ce, Ze), mt = { width: Le[F].maxVirtualBounds, height: Ie[j].maxVirtualBounds }, Ge = { left: Le[F].scrollOffset, top: Ie[j].scrollOffset }, Pt = { left: Le[F].freezeOffset, top: Ie[j].freezeOffset }, yt = { width: Ne, height: Q };
|
|
2881
|
+
let ge = null, xt = null;
|
|
2882
|
+
const At = (Pt.top + (se.vertical ? Ge.top : 0)) / G, Wt = (Pt.left + (se.horizontal ? Ge.left : 0)) / G;
|
|
2883
|
+
return { getStage: () => at.current ?? null, getVisibleRangeCoords: () => ce, toClipBounds: (Ce, Ze) => {
|
|
2884
|
+
let $e, ct = 0;
|
|
2885
|
+
return Ze === void 0 || typeof Ze == "number" ? ($e = je(ce), ct = Ze) : $e = Ze, ((Oe, Et, bt = 0) => {
|
|
2886
|
+
if (Oe.x > Et.width || Oe.y > Et.height) return null;
|
|
2887
|
+
const $t = { left: Oe.x, top: Oe.y, bottom: Oe.height + Oe.y, right: Oe.width + Oe.x }, Kt = { left: Et.x + bt, top: Et.y + bt, bottom: Et.height - 2 * bt + Et.y, right: Et.width - 2 * bt + Et.x }, Ot = { left: Math.max($t.left, Kt.left), top: Math.max($t.top, Kt.top), bottom: Math.min($t.bottom, Kt.bottom), right: Math.min($t.right, Kt.right) }, c = { x: Ot.left, y: Ot.top, width: Ot.right - Ot.left, height: Ot.bottom - Ot.top };
|
|
2888
|
+
return c.height < 0 || c.width < 0 ? null : c;
|
|
2889
|
+
})(Ce ?? { x: 0, y: 0, width: Fe.width, height: Fe.height }, $e, ct);
|
|
2890
|
+
}, toViewBounds: (Ce) => Wt === 0 && At === 0 && G === 1 ? Ce : { x: (Ce.x - Wt) * G, y: (Ce.y - At) * G, width: Ce.width * G, height: Ce.height * G }, toAbsoluteBounds: (Ce) => Wt === 0 && At === 0 && G === 1 ? Ce : { x: Ce.x / G + Wt, y: Ce.y / G + At, width: Ce.width / G, height: Ce.height / G }, getRelativePointFromClient: (Ce, Ze) => {
|
|
2891
|
+
const $e = hn(Ce, Ze);
|
|
2892
|
+
return { x: $e.x - Fe.x, y: $e.y - Fe.y };
|
|
2893
|
+
}, getLayout: () => Ve, getCellCoordsAsRangeCoords: We, getVisibleColumns: () => Le[F].visibleIndices(), getVisibleRows: () => Ie[j].visibleIndices(), getVisibleColumnOffsets: () => (ge || (ge = Br(Le[F].layout, !0, Le[F].visibleIndices(), ce.colStart, ce.colEnd)), ge), getVisibleRowOffsets: () => (xt || (xt = Br(Ie[j].layout, !1, Ie[j].visibleIndices(), ce.rowStart, ce.rowEnd)), xt), getTotalRangeCoords: () => ({ colStart: Le[F].minCoord, colEnd: Le[F].maxCoord, rowStart: Ie[j].minCoord, rowEnd: Ie[j].maxCoord }), getRangeCoordsBounds: je, scrollCellCoordsIntoView: (Ce, Ze) => Dn(Ce, Ze, fe), getCellCoordsFromClient: (Ce, Ze, $e = !1) => {
|
|
2894
|
+
const ct = hn(Ce, Ze);
|
|
2895
|
+
if (!ct) return null;
|
|
2896
|
+
const Oe = Ve.getColIndex(ct.x - Fe.x), Et = { rowIndex: Ve.getRowIndex(ct.y - Fe.y), colIndex: Oe };
|
|
2897
|
+
if ($e) return Et;
|
|
2898
|
+
const bt = We(Et);
|
|
2899
|
+
return { rowIndex: bt.rowStart, colIndex: bt.colStart };
|
|
2900
|
+
}, getZoom: () => G, getAnchor: () => fe, getBounds: () => Fe, getInsets: () => ut, getTotalSize: () => mt, getViewportSize: () => yt, getScrollTopLeft: () => Ge, getFreezeTopLeft: () => Pt, getScrollOrientation: () => ye, allViews: () => v };
|
|
2901
|
+
};
|
|
2902
|
+
let D = v[Xt] = P(0, 0, Xt, os, ns);
|
|
2903
|
+
return D && (v[Xt] = D), D = P(0, 1, Hn, { horizontal: !0 }), D && (v[Hn] = D), D = P(1, 0, Nn, { vertical: !0 }), D && (v[Nn] = D), D = P(1, 1, uo, {}), D && (v[uo] = D), rt.current = null, v = Object.freeze(v);
|
|
2904
|
+
}, [Ie, Le, We]), rn = Object.keys(Ae), Mt = Le[0]?.maxVirtualBounds ?? 0, nt = Ie[0]?.maxVirtualBounds ?? 0, Tt = Ee(() => ({ left: Le[1] ? Le[1].layout.getColOffset(Le[1].maxIndex + 1) : 0, top: Ie[1] ? Ie[1].layout.getRowOffset(Ie[1].maxIndex + 1) : 0 }), [Ae]);
|
|
2905
|
+
st(() => {
|
|
2906
|
+
if (tt.current.length > 0) {
|
|
2907
|
+
for (let v = 0; v < tt.current.length; v++) tt.current[v]();
|
|
2908
|
+
tt.current = [];
|
|
2909
|
+
}
|
|
2910
|
+
}, [Ae]);
|
|
2911
|
+
const kt = T(() => ({ containerWidth: Ne, containerHeight: Q, totalWidth: Mt, totalHeight: nt }), [Ne, Q, ze]);
|
|
2912
|
+
st(() => {
|
|
2913
|
+
!ke.current && jt.current && K({ top: Xe, left: wt, width: Ne, height: Q, totalWidth: Mt, totalHeight: nt });
|
|
2914
|
+
}, [Xe, wt, Mt, nt]), st(() => {
|
|
2915
|
+
jt.current && K({ top: Xe, left: wt, width: Ne, height: Q, totalWidth: Mt, totalHeight: nt });
|
|
2916
|
+
}, [Ne, Q]);
|
|
2917
|
+
const hn = O((v, P) => {
|
|
2918
|
+
ao(typeof v == "number" && typeof P == "number");
|
|
2919
|
+
const D = at.current?.getBoundingClientRect();
|
|
2920
|
+
return D ? { x: v - D.x, y: P - D.y } : { x: v, y: P };
|
|
2921
|
+
}, []), mo = T((v) => Ae[v] || null, [Ae]), xo = T((v, P) => {
|
|
2922
|
+
if (Object.keys(Ae).length === 1) return Ae[Xt];
|
|
2923
|
+
const D = hn(v, P);
|
|
2924
|
+
if (!D) return null;
|
|
2925
|
+
const { x: F, y: j } = D;
|
|
2926
|
+
let fe = null;
|
|
2927
|
+
const se = Hr;
|
|
2928
|
+
for (let ve = 0; !fe && ve < se.length; ve++) {
|
|
2929
|
+
const ye = Ae[se[ve]];
|
|
2930
|
+
ye && Kl(F, j, ye.getBounds()) && (fe = ye);
|
|
2931
|
+
}
|
|
2932
|
+
return fe || (fe = Ae[Xt]), fe;
|
|
2933
|
+
}, [Ae, We]), ft = T(() => Ae[Xt].getVisibleRangeCoords(), [Ae[Xt]]), ln = J(null), vo = O(() => {
|
|
2934
|
+
ln.current !== null && Ct.cancelTimeout(ln.current), ln.current = Ct.requestTimeout(yo, 150);
|
|
2935
|
+
}, []), yo = O(() => {
|
|
2936
|
+
ln.current = null, z((v) => {
|
|
2937
|
+
const P = { ...v, verticalScrollDirection: null, horizontalScrollDirection: null };
|
|
2938
|
+
return Qe.current = P, P;
|
|
2939
|
+
});
|
|
2940
|
+
}, []), xn = T((v) => {
|
|
2941
|
+
const P = v?.left ?? v?.[0], D = v?.top ?? v?.[1], F = P !== void 0 ? Math.min(Mt - Ne, Math.max(Le?.[1]?.scrollOffset ?? 0, P)) : Qe.current.left, j = D !== void 0 ? Math.min(nt - Q, Math.max(Ie?.[1]?.scrollOffset ?? 0, D)) : Qe.current.top;
|
|
2942
|
+
if (Qe.current.left === F && Qe.current.top === j) return;
|
|
2943
|
+
let fe = null, se = null;
|
|
2944
|
+
Qe.current.left > F ? fe = ot : Qe.current.left < F && (fe = Ke), Qe.current.top > j ? se = it : Qe.current.top < j && (se = lt), Ct.throttle(() => {
|
|
2945
|
+
z((ve) => {
|
|
2946
|
+
const ye = { ...ve, left: F, top: j, horizontalScrollDirection: fe, verticalScrollDirection: se };
|
|
2947
|
+
return Qe.current = ye, ye;
|
|
2948
|
+
});
|
|
2949
|
+
}, 17)(), ke.current?.top === j && ke.current?.left === F || (ke.current = { left: F, top: j }, ue({ left: F, top: j }), K({ left: F, top: j, width: Ne, height: Q, totalWidth: Mt, totalHeight: nt })), vo();
|
|
2950
|
+
}, [Mt, nt, Ie, Le]);
|
|
2951
|
+
st(() => {
|
|
2952
|
+
ke.current || xn({ left: wt, top: Xe });
|
|
2953
|
+
}, [Mt, Ne, nt, Q]), nn(() => {
|
|
2954
|
+
ke.current = { left: ht?.left, top: ht?.top }, xn(ke.current);
|
|
2955
|
+
}, [ht?.left, ht?.top]);
|
|
2956
|
+
const Kn = T((v) => {
|
|
2957
|
+
const P = v?.left ?? v?.[0], D = v?.top ?? v?.[1], F = v?.behavior ?? "auto", j = { left: Qe.current.left + (P ?? 0), top: Qe.current.top + (D ?? 0) };
|
|
2958
|
+
F && (j.behavior = F), xn(j);
|
|
2959
|
+
}, [Mt, Ne, nt, Q]), Yn = O((v) => {
|
|
2960
|
+
let P = null;
|
|
2961
|
+
if (Object.keys(Ae).length > 1) {
|
|
2962
|
+
const D = Hr;
|
|
2963
|
+
for (let F = 0; !P && F < D.length; F++) {
|
|
2964
|
+
const j = Ae[D[F]];
|
|
2965
|
+
j && Z.isCellWithinRange(v, j.getVisibleRangeCoords()) && (P = j);
|
|
2966
|
+
}
|
|
2967
|
+
}
|
|
2968
|
+
return P || (P = Ae[Xt]), P;
|
|
2969
|
+
}, [Ae]), Dn = T((v, P = { inline: "nearest", block: "nearest" }, D = null) => {
|
|
2970
|
+
const F = { rowIndex: 0, colIndex: 0, ...v };
|
|
2971
|
+
let j = null;
|
|
2972
|
+
if (D !== null) {
|
|
2973
|
+
if (j = Ae[D], j === null) return new Promise((yt, ge) => {
|
|
2974
|
+
ge("Invalid view");
|
|
2975
|
+
});
|
|
2976
|
+
} else j = Yn(F);
|
|
2977
|
+
const fe = We(F), se = j.getLayout(), ve = se.getColOffset(fe.colStart), ye = se.getRowOffset(fe.rowStart), ce = se.getColOffset(fe.colEnd + 1), Ve = se.getRowOffset(fe.rowEnd + 1), ut = j.getBounds(), Fe = j.getTotalSize(), je = j.getScrollTopLeft(), mt = ((yt, ge, xt = !0) => (xt = xt === !0 ? { block: "start", inline: "end" } : xt === !1 ? { block: "end", inline: "end" } : { block: "end", inline: "end", ...xt }, { left: zr(xt.inline, yt.x, yt.x + yt.width, ge.left, ge.left + ge.width, ge.totalWidth), top: zr(xt.block, yt.y, yt.y + yt.height, ge.top, ge.top + ge.height, ge.totalHeight) }))({ x: ve + je.left, y: ye + je.top, width: ce - ve, height: Ve - ye }, { left: je.left, top: je.top, width: ut.width, height: ut.height, totalWidth: Fe.width, totalHeight: Fe.height }, P), Ge = { ...mt };
|
|
2978
|
+
Ge.left > wt ? Ge.left += 20 : Ge.left < wt && (Ge.left -= 0), Ge.top > Xe ? Ge.top += 20 : Ge.top < Xe && (Ge.top -= 0);
|
|
2979
|
+
const Pt = j.getScrollOrientation();
|
|
2980
|
+
return Pt.horizontal && v.colIndex !== void 0 || delete Ge.left, Pt.vertical && v.rowIndex !== void 0 || delete Ge.top, new Promise((yt, ge) => {
|
|
2981
|
+
try {
|
|
2982
|
+
xn(Ge), yt(Ge);
|
|
2983
|
+
} catch (xt) {
|
|
2984
|
+
ge(xt);
|
|
2985
|
+
}
|
|
2986
|
+
});
|
|
2987
|
+
}, [Mt, nt, Ae, We]), Mn = T((v) => {
|
|
2988
|
+
const P = v.shiftKey;
|
|
2989
|
+
v.preventDefault();
|
|
2990
|
+
const { deltaX: D, deltaY: F, deltaMode: j } = v;
|
|
2991
|
+
if (zt.current || te?.(v) === !1) return;
|
|
2992
|
+
let se = P ? F : D, ve = F;
|
|
2993
|
+
const ye = P || Math.abs(se) > Math.abs(ve);
|
|
2994
|
+
j === 1 && (ve *= 0), zt.current = window.requestAnimationFrame(() => {
|
|
2995
|
+
zt.current = null, Kn(ye ? { left: se } : { top: ve });
|
|
2996
|
+
});
|
|
2997
|
+
}, [Mt, Ne, nt, Q, te]), zn = O((v = null) => {
|
|
2998
|
+
on.current = null, rt.current = null, Zt();
|
|
2999
|
+
}, []);
|
|
3000
|
+
nn(() => {
|
|
3001
|
+
zn();
|
|
3002
|
+
}, [oe]);
|
|
3003
|
+
const vn = wo(t, () => ({ stage: at.current, focus: et, contains: qe, invalidate: zn, scrollTo: xn, scrollBy: Kn, scrollCellCoordsIntoView: Dn, getScrollPosition: dt, getDimensions: kt, getViewport: ft, handleWheel: Mn, rowCount: r, columnCount: i, getLayout: () => ze, getRelativePointFromClient: hn, getViewFromClient: xo, getViewFromCellCoords: Yn, getViewFromLocation: mo, onViewChangeOnce: (v) => {
|
|
3004
|
+
tt.current.push(v);
|
|
3005
|
+
} }), [r, i, Ae]);
|
|
3006
|
+
st(() => (He && vn.current?.addEventListener("wheel", Mn, { passive: !1 }), jt.current = !0, ke.current = null, () => {
|
|
3007
|
+
vn.current?.removeEventListener("wheel", Mn);
|
|
3008
|
+
}), [He]);
|
|
3009
|
+
const An = J([]), bo = (v, P) => {
|
|
3010
|
+
!v || !H || (An.current = [], P.push(((D, F) => {
|
|
3011
|
+
const j = `view:${D.getAnchor()}:overlay:${P.length}`, fe = H?.({ key: j, view: D }, (ve) => An.current[F] = ve);
|
|
3012
|
+
if (!fe) return null;
|
|
3013
|
+
const se = D.getBounds();
|
|
3014
|
+
return Y("div", { style: { position: "absolute", left: "0px", top: "0px", width: `${se.width}px`, height: `${se.height}px`, overflow: "hidden" }, children: fe }, `overlay-${D.getAnchor()}-${F}`);
|
|
3015
|
+
})(v, 0)));
|
|
3016
|
+
}, So = Ee(() => {
|
|
3017
|
+
const v = {}, P = Object.keys(Ae);
|
|
3018
|
+
for (let D = 0; D < P.length; D++) {
|
|
3019
|
+
const F = P[D], j = [];
|
|
3020
|
+
bo(Ae[F], j), v[F] = { overlays: j };
|
|
3021
|
+
}
|
|
3022
|
+
return v;
|
|
3023
|
+
}, [gt, H, r, i, Ie, Le]), Xn = (v, P, D, F, j, fe, se) => {
|
|
3024
|
+
if (!v) return;
|
|
3025
|
+
const ve = v.getVisibleColumns(), ye = v.getVisibleRows();
|
|
3026
|
+
if (ve.length === 0 || ye.length === 0) return;
|
|
3027
|
+
let ce = null;
|
|
3028
|
+
if (xe) ce = xe(v);
|
|
3029
|
+
else {
|
|
3030
|
+
ce = [];
|
|
3031
|
+
for (let Ze = 0; Ze < ye.length; Ze++) for (let $e = 0; $e < ve.length; $e++) {
|
|
3032
|
+
const ct = { rowIndex: ye[Ze], colIndex: ve[$e] };
|
|
3033
|
+
if (N?.(ct)) continue;
|
|
3034
|
+
const Oe = { coords: ct, range: We(ct) };
|
|
3035
|
+
ce.push(Oe);
|
|
3036
|
+
}
|
|
3037
|
+
}
|
|
3038
|
+
const Ve = v.getVisibleColumnOffsets(), ut = v.getVisibleRowOffsets(), Fe = v.getScrollTopLeft(), je = v.getFreezeTopLeft(), mt = Fe.left + je.left, Ge = Fe.top + je.top, Pt = Math.trunc(mt / sn), yt = Math.trunc(Ge / sn), ge = {}, xt = (Ze, $e, ct, Oe, Et) => {
|
|
3039
|
+
const bt = `view:${Ze.getAnchor()}:cell:${Dr($e.rowIndex, $e.colIndex)}`, $t = Oe.x, Kt = Oe.y, Ot = Math.trunc((mt + $t) / sn) - Pt, c = Math.trunc((Ge + Kt) / sn) - yt;
|
|
3040
|
+
ge[c] || (ge[c] = {});
|
|
3041
|
+
let h = ge[c][Ot];
|
|
3042
|
+
h || (h = ge[c][Ot] = []);
|
|
3043
|
+
let w = fe?.get(bt);
|
|
3044
|
+
if (!w) {
|
|
3045
|
+
const p = (mt + $t) % sn, y = (Ge + Kt) % sn;
|
|
3046
|
+
w = oe({ key: bt, coords: $e, bounds: Oe, zoom: G, range: ct, view: Ze, value: Et, style: { left: me.boundPixel(p), top: me.boundPixel(y), width: me.boundPixel(Oe.width, !0), height: me.boundPixel(Oe.height, !0) } });
|
|
3047
|
+
}
|
|
3048
|
+
se?.set(bt, w), h.push(w);
|
|
3049
|
+
};
|
|
3050
|
+
for (let Ze = 0; ce && Ze < ce.length; Ze++) {
|
|
3051
|
+
const $e = ce[Ze], ct = $e?.coords ?? $e;
|
|
3052
|
+
if (!ct) continue;
|
|
3053
|
+
const Oe = $e?.range ?? { rowStart: ct.rowIndex, colStart: ct.colIndex, rowEnd: ct.rowIndex, colEnd: ct.colIndex }, Et = v.getVisibleRangeCoords();
|
|
3054
|
+
if (!Z.isRangesIntersect(Oe, Et) && !Z.isRangeWithinRange(Oe, Et)) continue;
|
|
3055
|
+
const bt = Oe && !Z.isSingleCell(Oe);
|
|
3056
|
+
if (!bt && N?.(ct)) continue;
|
|
3057
|
+
const $t = ct.rowIndex, Kt = ct.colIndex, Ot = ut[$t], c = Ve[Kt];
|
|
3058
|
+
let h = null;
|
|
3059
|
+
Ot && c && (h = { x: c.offset, y: Ot.offset, width: c.size, height: Ot.size });
|
|
3060
|
+
const w = Dr(Oe.rowStart, Oe.colStart);
|
|
3061
|
+
if (bt) {
|
|
3062
|
+
if (j.has(w)) continue;
|
|
3063
|
+
j.add(w), Oe.rowEnd - Oe.rowStart > 0 && D.push(Oe), Oe.colEnd - Oe.colStart > 0 && F.push(Oe);
|
|
3064
|
+
}
|
|
3065
|
+
if (bt && (h = Fr(v.getLayout(), Oe)), !h) {
|
|
3066
|
+
console.warn("no bounds for cell", w);
|
|
3067
|
+
continue;
|
|
3068
|
+
}
|
|
3069
|
+
const p = $e?.value;
|
|
3070
|
+
xt(v, ct, Oe, h, p);
|
|
3071
|
+
}
|
|
3072
|
+
const At = mt % sn, Wt = Ge % sn, Ce = Object.keys(ge);
|
|
3073
|
+
for (let Ze = 0; Ze < Ce.length; Ze++) {
|
|
3074
|
+
const $e = ge[Ce[Ze]];
|
|
3075
|
+
if (!$e) continue;
|
|
3076
|
+
const ct = Object.keys($e);
|
|
3077
|
+
for (let Oe = 0; Oe < ct.length; Oe++) {
|
|
3078
|
+
const Et = $e[ct[Oe]];
|
|
3079
|
+
if (!Et) continue;
|
|
3080
|
+
const bt = parseInt(Ce[Ze]), $t = parseInt(ct[Oe]), Kt = bt + yt, Ot = $t + Pt, c = `view:${v.getAnchor()}:segment:${Ot}:${Kt}`;
|
|
3081
|
+
P.push(Y("div", { className: "cell-container", style: { transform: `translate(${me.boundPixel($t * sn - At, !0)}px, ${me.boundPixel(bt * sn - Wt, !0)}px)`, willChange: "transform" }, children: Et }, c));
|
|
3082
|
+
}
|
|
3083
|
+
}
|
|
3084
|
+
}, Qt = Ee(() => {
|
|
3085
|
+
const v = on.current, P = /* @__PURE__ */ new Map(), D = {}, F = Object.keys(Ae);
|
|
3086
|
+
for (let j = 0; j < F.length; j++) {
|
|
3087
|
+
const fe = F[j], se = [], ve = [], ye = [];
|
|
3088
|
+
Xn(Ae[fe], ye, se, ve, /* @__PURE__ */ new Set(), v, P), D[fe] = { cells: ye, rangesH: se, rangesV: ve };
|
|
3089
|
+
}
|
|
3090
|
+
return on.current = P, D;
|
|
3091
|
+
}, [gt, r, i, Ie, Le, x, _e, ae, N, xe, We]), Gn = (v, P, D, F, j) => {
|
|
3092
|
+
if (v) if (P) {
|
|
3093
|
+
const fe = `view:${v.getAnchor()}:hl:`, se = v.getVisibleRows();
|
|
3094
|
+
if (!se || se.length === 0) return;
|
|
3095
|
+
const ve = 0, ye = v.getBounds().width;
|
|
3096
|
+
let ce = [];
|
|
3097
|
+
const Ve = j.sort(Z.rowFirstRangeComparator), ut = v.getVisibleRangeCoords();
|
|
3098
|
+
for (let Fe = 0; Fe < se.length && se[Fe] <= ut.rowEnd; Fe++) {
|
|
3099
|
+
const je = se[Fe];
|
|
3100
|
+
if (je < ut.rowStart) continue;
|
|
3101
|
+
let mt = !1;
|
|
3102
|
+
for (; Ve.length > 0 && Ve[0].rowStart <= je; ) {
|
|
3103
|
+
const ge = Ve.shift();
|
|
3104
|
+
ge.rowEnd > je && (ce.push(ge), mt = !0);
|
|
3105
|
+
}
|
|
3106
|
+
mt && (ce = ce.sort(Z.columnFirstRangeComparator));
|
|
3107
|
+
const Ge = v.getLayout(), Pt = Ge.getRowOffset(je + 1);
|
|
3108
|
+
let yt = ve;
|
|
3109
|
+
for (let ge = 0; ge < ce.length + 1; ge++) {
|
|
3110
|
+
let xt = yt, At = ye;
|
|
3111
|
+
const Wt = ce[ge];
|
|
3112
|
+
ge < ce.length && (At = Math.min(ye, Ge.getColOffset(Wt.colStart)), yt = Math.min(ye, Ge.getColOffset(Wt.colEnd + 1))), F.push(Jo("path", { d: `M ${me.boundPixel(xt)} ${me.boundPixel(Pt, !1, D)} L ${me.boundPixel(At)} ${me.boundPixel(Pt, !1, D)}`, stroke: E, strokeWidth: 1, vectorEffect: "non-scaling-stroke", ...I, key: fe + je + ":" + ge }));
|
|
3113
|
+
}
|
|
3114
|
+
for (let ge = ce.length - 1; ge >= 0; ge--) ce[ge].rowEnd <= se[Fe + 1] && ce.splice(ge, 1);
|
|
3115
|
+
}
|
|
3116
|
+
} else {
|
|
3117
|
+
const fe = `view:${v.getAnchor()}:vl:`, se = v.getVisibleColumns();
|
|
3118
|
+
if (!se || se.length === 0) return;
|
|
3119
|
+
const ve = 0, ye = v.getBounds().height;
|
|
3120
|
+
let ce = [];
|
|
3121
|
+
const Ve = j.sort(Z.columnFirstRangeComparator), ut = v.getVisibleRangeCoords();
|
|
3122
|
+
for (let Fe = 0; Fe < se.length && se[Fe] <= ut.colEnd; Fe++) {
|
|
3123
|
+
const je = se[Fe];
|
|
3124
|
+
if (je < ut.colStart) continue;
|
|
3125
|
+
let mt = !1;
|
|
3126
|
+
for (; Ve.length > 0 && Ve[0].colStart <= je; ) {
|
|
3127
|
+
const ge = Ve.shift();
|
|
3128
|
+
ge.colEnd > je && (ce.push(ge), mt = !0);
|
|
3129
|
+
}
|
|
3130
|
+
mt && (ce = ce.sort(Z.rowFirstRangeComparator));
|
|
3131
|
+
const Ge = v.getLayout(), Pt = Ge.getColOffset(je + 1);
|
|
3132
|
+
let yt = ve;
|
|
3133
|
+
for (let ge = 0; ge < ce.length + 1; ge++) {
|
|
3134
|
+
let xt = yt, At = ye;
|
|
3135
|
+
const Wt = ce[ge];
|
|
3136
|
+
ge < ce.length && (At = Math.min(ye, Ge.getRowOffset(Wt.rowStart)), yt = Math.min(ye, Ge.getRowOffset(Wt.rowEnd + 1)));
|
|
3137
|
+
let Ce = E;
|
|
3138
|
+
F.push(Y("path", { d: `M ${me.boundPixel(Pt, !1, D)} ${me.boundPixel(xt)} L ${me.boundPixel(Pt, !1, D)} ${me.boundPixel(At)}`, stroke: Ce, strokeWidth: 1, vectorEffect: "non-scaling-stroke", ...M }, fe + je + ":" + ge));
|
|
3139
|
+
}
|
|
3140
|
+
for (let ge = ce.length - 1; ge >= 0; ge--) ce[ge].colEnd <= se[Fe + 1] && ce.splice(ge, 1);
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3143
|
+
}, $n = (v) => {
|
|
3144
|
+
if (!Qt) return;
|
|
3145
|
+
const P = {};
|
|
3146
|
+
for (let D = 0; D < rn.length; D++) {
|
|
3147
|
+
const F = rn[D], j = Ae[F], fe = [];
|
|
3148
|
+
Gn(j, v, 0, fe, v ? Qt[F].rangesH : Qt[F].rangesV);
|
|
3149
|
+
const se = j.getRangeCoordsBounds(), ve = Math.ceil(se.width), ye = Math.ceil(se.height);
|
|
3150
|
+
P[F] = Y("svg", { width: `${ve}`, height: `${ye}`, viewBox: `0 0 ${ve} ${ye}`, preserveAspectRatio: "none", shapeRendering: "crispEdges", style: { position: "absolute" }, children: fe });
|
|
3151
|
+
}
|
|
3152
|
+
return P;
|
|
3153
|
+
}, Zn = Ee(() => x === !0 || x?.horizontal === !0 ? $n(!0) : null, [gt, x, Ie, L, _, E, I, r, i, Ne, Mt, Qt]), Jn = Ee(() => x === !0 || x?.vertical === !0 ? $n(!1) : null, [gt, x, Le, L, _, E, M, r, i, Q, nt, Qt]), Eo = Ee(() => Tt.left === 0 ? null : Y(jr, { linePoints: [0, 0, 0, Q + 1], bounds: { x: Tt.left, y: 0, width: 1, height: Q + 1 }, ...le }), [gt, Tt.left, Q, le]), _o = Ee(() => Tt.top === 0 ? null : Y(jr, { linePoints: [0, 0, Ne + 1, 0], bounds: { x: 0, y: Tt.top, width: Ne + 1, height: 1 }, ...$ }), [gt, Tt.top, Ne, $]), Bn = Ee(() => {
|
|
3154
|
+
const v = [], P = (D) => {
|
|
3155
|
+
if (!D || !Ae[D]) return;
|
|
3156
|
+
const F = Ae[D].getBounds();
|
|
3157
|
+
return Ht("div", { style: { position: "absolute", pointerEvents: "none", left: F.x, top: F.y, width: F.width, height: F.height, clip: `rect(0, ${F.width + 1}px, ${F.height + 1}px, 0)` }, className: `view view-${D}`, children: [Zn?.[D], Jn?.[D], Qt?.[D].cells] }, `view:${D}`);
|
|
3158
|
+
};
|
|
3159
|
+
for (let D = 0; D < rn.length; D++) v.push(P(rn[D]));
|
|
3160
|
+
return Y(wn, { children: v });
|
|
3161
|
+
}, [Ae, Zn, Jn, Qt]), Io = Ee(() => {
|
|
3162
|
+
if (!t) return;
|
|
3163
|
+
const v = (se, ve, ye, ce) => {
|
|
3164
|
+
if (!ce || ce.length === 0) return;
|
|
3165
|
+
const Ve = [];
|
|
3166
|
+
for (let ut = 0; ut < ce.length; ut++) {
|
|
3167
|
+
const Fe = ce[ut];
|
|
3168
|
+
let je = se?.get(Fe);
|
|
3169
|
+
je !== Fo && (je = Fe(ye) ?? Fo), ve.set(Fe, je), je && je !== Fo && Ve.push(je);
|
|
3170
|
+
}
|
|
3171
|
+
return Ve;
|
|
3172
|
+
}, P = (se, ve, ye) => {
|
|
3173
|
+
if (!ye) return;
|
|
3174
|
+
const ce = ye.getBounds(), Ve = ye.getInsets(), ut = ye.getAnchor();
|
|
3175
|
+
return Ht("div", { className: En("view", `view-${ut}`, Wr.view), style: { position: "absolute", pointerEvents: "none", left: ce.x - Ve.left, top: ce.y - Ve.top, width: ce.width - (Ve.left + Ve.right), height: ce.height - (Ve.top + Ve.bottom), clipPath: C ? "inset(-2px)" : "inset(0px)" }, children: [v(se, ve, ye, k), So?.[ut].overlays] }, `view:${ut}`);
|
|
3176
|
+
}, D = rt.current, F = {}, j = [], fe = Object.keys(Ae);
|
|
3177
|
+
for (let se = 0; se < fe.length; se++) {
|
|
3178
|
+
const ve = fe[se], ye = D?.[ve], ce = F[ve] = /* @__PURE__ */ new Map();
|
|
3179
|
+
j.push(P(ye, ce, Ae[ve]));
|
|
3180
|
+
}
|
|
3181
|
+
return rt.current = F, j;
|
|
3182
|
+
}, [gt, Ae, C, k]), Co = Ee(() => {
|
|
3183
|
+
const { style: v, ...P } = ee ?? {};
|
|
3184
|
+
return Y("div", { style: { width: Ne, height: Q, ...v }, className: "sheetxl-stage", tabIndex: 0, ref: at, ...P, ...S, children: W ? W(Bn) : Bn });
|
|
3185
|
+
}, [Ne, Q, Bn, ee, W]), Qn = J(!1);
|
|
3186
|
+
return st(() => {
|
|
3187
|
+
!Qn.current && Qt && (Qn.current = !0, Re?.(vn.current));
|
|
3188
|
+
}, [Qt]), Ht("div", { className: En("sheetxl-grid", Wr["sheetxl-grid"]), style: { overflow: "visible", cursor: R, maxWidth: Ne, maxHeight: Q, width: Ne, height: Q, ..._e }, ref: vn, children: [Co, Ht("div", { className: En("sheetxl-overlays"), ref: pt, ...u, children: [Io, Eo, _o] })] });
|
|
3189
|
+
}));
|
|
3190
|
+
Ci.displayName = "BaseGrid";
|
|
3191
|
+
const Mi = Dt(Ut((e, t) => {
|
|
3192
|
+
const { width: n, height: o, style: r = {}, className: i, ...l } = e, [s, { width: a, height: d }] = _i();
|
|
3193
|
+
return Y("div", { className: i, style: { ...r }, children: Y("div", { style: { position: "relative", top: "0px", left: "0px", width: "100%", height: "100%", maxWidth: "100%", maxHeight: "100%", boxSizing: "content-box" }, ref: s, children: Y(Ci, { ref: t, width: n ?? a, height: o ?? d, ...l }) }) });
|
|
3194
|
+
}));
|
|
3195
|
+
Mi.displayName = "Grid";
|
|
3196
|
+
const rs = Dt(Ut((e, t) => {
|
|
3197
|
+
const { showVerticalScrollbar: n, showHorizontalScrollbar: o, createHorizontalScrollbar: r, createVerticalScrollbar: i, createScrollCorner: l, viewport: s, onScrollViewport: a, style: d = {}, className: g, onScroll: m, ...f } = e, [x, E] = Je(null), I = J(null), M = J(null);
|
|
3198
|
+
ao(!s), Ur(t, () => M.current && I.current ? Object.assign(M.current, I.current) : null);
|
|
3199
|
+
const ae = O((R) => {
|
|
3200
|
+
M.current?.scrollTo(R), a?.(R);
|
|
3201
|
+
}, []);
|
|
3202
|
+
return Y(pi, { className: g, style: d, ref: I, showVerticalScrollbar: n, showHorizontalScrollbar: o, createHorizontalScrollbar: r, createVerticalScrollbar: i, createScrollCorner: l, viewport: x, onScrollViewport: ae, children: Y(Mi, { style: { width: "100%", height: "100%" }, ...f, onViewportChange: (R) => E(R), ref: M }) });
|
|
3203
|
+
}));
|
|
3204
|
+
rs.displayName = "ScrollableGrid";
|
|
3205
|
+
const Nr = () => !1, is = Dt((e) => {
|
|
3206
|
+
const { index: t, value: n, zoom: o, zoomScale: r = 100, headerText: i = (k) => `${k}`, headerStyle: l, headerStyleSelect: s = l, headerStyleSelectAll: a = s, headerStyleHover: d = a, verticalPadding: g = 0, horizontalPadding: m = 0, isSelected: f = Nr, isSelectedAll: x = Nr, coords: E, bounds: I, range: M, orientation: ae, view: R, style: _, ...L } = e, le = r / 100, $ = J(null), [oe, be] = Je(!1), U = f?.(t) || !1, H = x?.(t) ? a : U ? s : l;
|
|
3207
|
+
let X = H;
|
|
3208
|
+
if (oe) {
|
|
3209
|
+
let k = d;
|
|
3210
|
+
typeof d == "function" && (k = d(H)), X = Ct.mergeContentful(H, k);
|
|
3211
|
+
}
|
|
3212
|
+
return Y("div", { ref: $, 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`, ..._, left: _.left - (ae === Nt ? 1 : 0), top: _.top - (ae === cn ? 1 : 0), width: _.width + 1, height: _.height + 1, overflow: "hidden" }, ...L, onMouseMove: (k) => {
|
|
3213
|
+
me.detectIt().primaryInput !== "touch" && k.buttons === 0 && be(!0);
|
|
3214
|
+
}, onMouseOut: (k) => {
|
|
3215
|
+
be(!1);
|
|
3216
|
+
}, children: i(t) });
|
|
3217
|
+
});
|
|
3218
|
+
is.displayName = "HeaderRenderer";
|
|
3219
|
+
const Ti = "ew-resize", Ri = "ns-resize", ls = Dt(Ut((e, t) => {
|
|
3220
|
+
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: E, headerStyleSelect: I, headerStyleSelectAll: M, headerStyleHover: ae, bounds: R, onPointerDown: _, onAutoFit: L, ...le } = e, $ = n === Nt;
|
|
3221
|
+
let oe = E;
|
|
3222
|
+
m && I && (oe = I), f && M && (oe = M);
|
|
3223
|
+
const be = me.detectIt().primaryInput === "touch";
|
|
3224
|
+
let U = $ ? 14 : 8, H = U / 2, X = 0;
|
|
3225
|
+
d && (X = -2), g && (X = 2), g && (U = U / 2 + X, H = 2 * X);
|
|
3226
|
+
let k = oe.dividerStrokeFill ?? oe.strokeFill;
|
|
3227
|
+
return !(m || f) && X === 0 && (k = `linear-gradient(${$ ? 180 : 90}deg, ${oe.fill}, ${k} 55%, ${k} 100%)`), Ht("div", { className: En("header-divider", { disabled: s }, i, `index-${r}`), ref: t, onPointerDown: be ? void 0 : _, onDoubleClick: be ? void 0 : () => L?.(), style: { top: ($ ? 0 : -U / 2 + (X - 1)) + "px", left: ($ ? -U / 2 + (X - 1) : 0) + "px", width: $ ? U : "calc(100% + 1px)", height: $ ? "calc(100% + 1px)" : U, position: "absolute", overflow: "visible", pointerEvents: "all", cursor: s || a || be ? void 0 : $ ? Ti : Ri, ...l }, ...le, children: [Y("div", { style: { position: "relative", top: `${$ ? 0 : H}px`, left: `${$ ? H : 0}px`, width: $ ? 1 : "100%", height: $ ? "100%" : 1, background: k }, onDoubleClick: () => L?.() }), x && be ? Y("div", { style: { position: "absolute", cursor: "grab", zIndex: 1, borderRadius: "4px", right: $ ? "-6px" : "2px", bottom: $ ? "2px" : "-9px", height: "24px", width: $ ? "24px" : "18px", maxHeight: $ ? "calc(100% - 4px)" : void 0, maxWidth: $ ? void 0 : "calc(100% - 4px)", background: oe.fill, border: `${M.edgeStrokeFill} solid 1px`, boxShadow: `0.5px 0.5px 0px 0px ${E.text.fill}`, display: "flex", alignItems: "center", justifyContent: "center" }, onPointerDown: _, children: Y("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: $ ? void 0 : "rotate(90deg)" } }) }) : null] });
|
|
3228
|
+
})), ss = (e, t) => Y(ls, { ...e, ref: t }), vs = Dt(Ut((e, t) => {
|
|
3229
|
+
const { orientation: n, view: o, index: r, disabled: i = !1, disabledResize: l = !1, resizeThreshold: s = 1, dividerRenderer: a = ss, onDividerMouseDown: d, onDividerResizeStart: g, onDividerResize: m, onDividerResizeEnd: f, onDividerMouseUp: x, onDividerAutoFit: E, onPointerDown: I, ...M } = e, ae = T(I, [I]), R = T(E, [E]), _ = n === Nt;
|
|
3230
|
+
let L = _ ? o.getVisibleColumns() : o.getVisibleRows(), le = null;
|
|
3231
|
+
L.length > 0 && (_ ? le = o.getRangeCoordsBounds({ rowStart: 0, rowEnd: 0, colStart: L[0], colEnd: L[L.length - 1] }) : o.getRangeCoordsBounds({ rowStart: L[0], rowEnd: L[L.length - 1], colStart: 0, colEnd: 0 }), le = o.toClipBounds(le, tn));
|
|
3232
|
+
const $ = J(null), [oe, be] = Je(null), U = (A, q) => _ ? A.clientX - q.clientX : A.clientY - q.clientY, H = o.getLayout(), X = _ ? H.getColOffset(r + 1) : H.getRowOffset(r + 1), k = On({ processTouch: !0, onPointerDown: (A) => {
|
|
3233
|
+
if (ae?.(A), !i && !l) {
|
|
3234
|
+
const q = _ ? H.getColOffset(r) : H.getRowOffset(r), N = X - q;
|
|
3235
|
+
$.current = { isResizing: !1, startSize: N, index: r, view: o, orientation: n, onDividerMouseDown: d, onDividerResizeStart: g, onDividerResize: m, onDividerResizeEnd: f, onDividerMouseUp: x }, be($.current), d?.(r, N);
|
|
3236
|
+
}
|
|
3237
|
+
A.stopPropagation(), A.preventDefault();
|
|
3238
|
+
}, onPointerUp: (A, q, N) => {
|
|
3239
|
+
if (!$.current) return;
|
|
3240
|
+
$.current.isResizing && $.current.onDividerResizeEnd?.($.current.index, Math.max(0, $.current.startSize + U(A, N)), $.current.startSize);
|
|
3241
|
+
const xe = $.current;
|
|
3242
|
+
$.current = null, be($.current), xe.onDividerMouseUp?.(xe.index);
|
|
3243
|
+
}, onPointerMoveOrWait: (A, q, N) => {
|
|
3244
|
+
if (!$.current) return;
|
|
3245
|
+
const xe = U(A, N);
|
|
3246
|
+
$.current.isResizing ? $.current.onDividerResize?.($.current.index, Math.max(0, $.current.startSize + xe), $.current.startSize) : Math.abs(xe) > Math.max(1, s) && ($.current = { ...$.current, isResizing: !0 }, be($.current), $.current.onDividerResizeStart?.($.current.index, Math.max(0, $.current.startSize + xe))), A.stopPropagation(), A.preventDefault();
|
|
3247
|
+
} }), u = T(() => {
|
|
3248
|
+
R?.(r);
|
|
3249
|
+
}, [r]);
|
|
3250
|
+
if (!le) return;
|
|
3251
|
+
const C = a({ bounds: le, orientation: n, view: o, index: r, disabled: i, disabledResize: l, onAutoFit: u, onPointerDown: k, ...M }, t);
|
|
3252
|
+
if (!C) return;
|
|
3253
|
+
const { getPortalContainer: ee } = gi();
|
|
3254
|
+
let W = null;
|
|
3255
|
+
return oe && oe.isResizing && oe.index === r && (W = Kr(Y("div", { style: { position: "absolute", cursor: _ ? Ti : Ri, left: 0, top: 0, width: "100%", height: "100%" } }), ee(), "divider:" + r)), Ht(wn, { children: [W, Y("div", { className: En("header-divider-anchor"), style: { position: "absolute", pointerEvents: "auto", top: `${_ ? le.y : X}px`, left: `${_ ? X : le.x}px`, width: (_ ? 0 : le.width - 1) + "px", height: (_ ? le.height - 1 : 0) + "px", display: "flex" }, tabIndex: -1, children: C })] });
|
|
3256
|
+
}));
|
|
3257
|
+
class cs {
|
|
3258
|
+
naturalDimensions(t, n = {}) {
|
|
3259
|
+
const o = document.createElement("div");
|
|
3260
|
+
let r = n?.lineHeight ?? "1";
|
|
3261
|
+
!n?.lineHeight && n.paintableText?.fontSize && (r = Math.ceil(1.2 * n.paintableText.fontSize) + "px");
|
|
3262
|
+
const i = document.createElement("div");
|
|
3263
|
+
i.style.visibility = "hidden", i.style.position = "absolute", i.style.textRendering = "geometricprecision", i.style.display = "inline-grid", i.style.overflowWrap = "break-word", i.style.maxWidth = n.maxWidth ? n.maxWidth + "px" : "100%", i.style.lineHeight = r, i.style.letterSpacing = (n.paintableText?.letterSpacing ?? 0) + "px", i.style.fontSize = n.paintableText?.fontSize ? n.paintableText.fontSize + "px" : "unset", i.style.fontFamily = n.paintableText?.fontSize ? n.paintableText.fontFamily : "unset", i.style.fontWeight = n.paintableText?.fontWeight ? "" + n.paintableText.fontWeight : "400", i.style.fontStyle = n.paintableText?.fontStyle ? n.paintableText.fontStyle : "normal", i.style.whiteSpace = n.paintableText?.wrap === "wrap" ? "break-spaces" : "pre", o.appendChild(i);
|
|
3264
|
+
const l = t.split(`
|
|
3265
|
+
`);
|
|
3266
|
+
for (let a = 0; a < l.length; a++) {
|
|
3267
|
+
let d = document.createElement("span");
|
|
3268
|
+
i.appendChild(d), d.textContent = l[a];
|
|
3269
|
+
}
|
|
3270
|
+
l.length !== 0 && l[l.length - 1].length !== 0 || i.appendChild(document.createElement("br")), document.body.appendChild(i);
|
|
3271
|
+
let s = i.getBoundingClientRect();
|
|
3272
|
+
return i.remove(), { width: s.width, height: s.height, maxLineHeight: 1.2 * (n.paintableText?.fontSize || 1056 / 72) };
|
|
3273
|
+
}
|
|
3274
|
+
}
|
|
3275
|
+
const as = (e = void 0) => Object.freeze({ clean: e, dirty: void 0, editMode: !1 }), ds = as(), ys = Dt(Ut((e, t) => {
|
|
3276
|
+
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: E, ...I } = e, M = J(null), { width: ae = 0 } = d ?? {}, [R, _] = Je(() => n);
|
|
3277
|
+
st(() => {
|
|
3278
|
+
_(n);
|
|
3279
|
+
}, [n]);
|
|
3280
|
+
const L = f?.align || "left", le = f?.vAlign || "middle", $ = f?.fill || "#040404", oe = f?.wrap || "wrap", be = f?.fontFamily || "Calibri", U = f?.fontSize || 11, H = f?.fontWeight || 400, X = f?.fontStyle || "normal", k = R.dirty ?? R.clean ?? "";
|
|
3281
|
+
let u = 2;
|
|
3282
|
+
const C = 96 * U / 72, ee = 1.2 * C;
|
|
3283
|
+
le === "right" && (u += 1);
|
|
3284
|
+
const W = Ee(() => new cs().naturalDimensions(k, { maxWidth: oe === "wrap" ? ae - u : void 0, lineHeight: `${ee}px`, paintableText: { fontStyle: X, wrap: oe, letterSpacing: -0.25 } }), [k, oe, u, C, be, H, X, g, ae]), A = O(() => W.maxLineHeight ? W.maxLineHeight + "px" : "1.2", [W]), [q, N] = Je(A);
|
|
3285
|
+
nn(() => {
|
|
3286
|
+
N(A());
|
|
3287
|
+
}, [d, W]), nn(() => {
|
|
3288
|
+
g?.({ width: oe === "wrap" ? void 0 : W.width + u, height: W.height });
|
|
3289
|
+
}, [W, g]);
|
|
3290
|
+
const xe = T(i, [i]), G = T((K) => {
|
|
3291
|
+
if (R.dirty === K) return;
|
|
3292
|
+
const pe = { ...R };
|
|
3293
|
+
pe.dirty = K, M.current, _(pe), xe?.(pe);
|
|
3294
|
+
}, [R]), He = T((K) => {
|
|
3295
|
+
if (R.editMode === K) return;
|
|
3296
|
+
const pe = { ...R };
|
|
3297
|
+
pe.editMode = K, _(pe), xe?.(pe);
|
|
3298
|
+
}, [R]), Ue = T(() => {
|
|
3299
|
+
try {
|
|
3300
|
+
return l?.(R), a?.(), !0;
|
|
3301
|
+
} catch {
|
|
3302
|
+
return !1;
|
|
3303
|
+
}
|
|
3304
|
+
}, [l, R]), We = T(() => {
|
|
3305
|
+
_(n), s?.(), a?.();
|
|
3306
|
+
}, [s, n]), ht = T((K) => {
|
|
3307
|
+
if (!M.current) return;
|
|
3308
|
+
if (K.isDefaultPrevented(), !(K.isTrusted || K.nativeEvent.ctrlKey || K.nativeEvent.metaKey || K.nativeEvent.altKey || K.nativeEvent.isComposing) && vi.indexOf(K.nativeEvent.key) !== -1) {
|
|
3309
|
+
const te = { ...R };
|
|
3310
|
+
return te.dirty = K.nativeEvent.key === "Backspace" ? "" : (te.dirty ?? "") + K.key, _(te), xe?.(te), void K.preventDefault();
|
|
3311
|
+
}
|
|
3312
|
+
const pe = K.nativeEvent.shiftKey;
|
|
3313
|
+
if (K.which === Ji) return K.preventDefault(), void We();
|
|
3314
|
+
if (K.which === ol) return He(!0), void K.preventDefault();
|
|
3315
|
+
if (K.which === Zi && (K.preventDefault(), Ue() && m?.(pe ? it : lt)), K.which === Gi) return K.preventDefault(), void (Ue() && m?.(pe ? ot : Ke));
|
|
3316
|
+
if (!R.editMode) {
|
|
3317
|
+
let te = null;
|
|
3318
|
+
switch (K.which) {
|
|
3319
|
+
case Qi:
|
|
3320
|
+
te = ot;
|
|
3321
|
+
break;
|
|
3322
|
+
case tl:
|
|
3323
|
+
te = Ke;
|
|
3324
|
+
break;
|
|
3325
|
+
case el:
|
|
3326
|
+
te = it;
|
|
3327
|
+
break;
|
|
3328
|
+
case nl:
|
|
3329
|
+
te = lt;
|
|
3330
|
+
}
|
|
3331
|
+
if (te) return void Ue();
|
|
3332
|
+
}
|
|
3333
|
+
}, [R, m]), [_e, S] = Je(!E);
|
|
3334
|
+
st(() => {
|
|
3335
|
+
S(!1);
|
|
3336
|
+
}, []);
|
|
3337
|
+
const ue = wo(t, () => ({ startEdit(K) {
|
|
3338
|
+
let pe = K?.initialSelection;
|
|
3339
|
+
if (!pe) {
|
|
3340
|
+
const Re = M.current.value.length ?? 0;
|
|
3341
|
+
pe = { start: Re, end: Re, direction: "forward" };
|
|
3342
|
+
}
|
|
3343
|
+
M.current?.setSelectionRange(pe.start, pe.end, pe.direction);
|
|
3344
|
+
const te = { ...n, editMode: K?.editMode ?? !1 };
|
|
3345
|
+
K?.text !== void 0 && (te.dirty = K.text), te.editMode === n.editMode && te.dirty === n.dirty || (_(te), xe?.(te));
|
|
3346
|
+
}, submitEdit: () => Ue(), cancelEdit() {
|
|
3347
|
+
We();
|
|
3348
|
+
}, autoFocus() {
|
|
3349
|
+
M.current?.focus();
|
|
3350
|
+
}, getLineHeight: () => W?.maxLineHeight ?? ee, dispatchEvent: (K) => M.current.dispatchEvent(K) }), [n, r]);
|
|
3351
|
+
return Y("div", { ref: ue, ...I, style: { background: "transparent", display: "flex", flexGrow: 1, alignSelf: "center", height: W.height, maxWidth: "100%", maxHeight: "100%", ...x }, children: Y("textarea", { spellCheck: "false", ref: M, value: k, autoFocus: !1, disabled: _e, name: "cell-editor", autoComplete: "off", autoCapitalize: "off", style: { flex: "1 1 100%", position: "relative", fontSize: `${C}px`, fontFamily: `${be}`, fontWeight: `${H}`, fontStyle: `${X}`, padding: "0px", marginRight: L === "right" ? "3px" : "0px", marginLeft: L === "left" ? "2px" : "0px", lineHeight: q, height: W.height, textRendering: "geometricPrecision", letterSpacing: "-0.25px", boxSizing: "border-box", borderWidth: 0, outline: "none", resize: "none", overflow: "hidden", verticalAlign: "baseline", textAlign: L, background: "transparent", color: $, marginBottom: "0px", userSelect: "text", maxHeight: "100%", whiteSpace: oe === "wrap" ? "break-spaces" : "pre", wordWrap: "break-word" }, onChange: (K) => {
|
|
3352
|
+
G(K.target.value);
|
|
3353
|
+
}, onDoubleClick: (K) => {
|
|
3354
|
+
K.isTrusted;
|
|
3355
|
+
}, onMouseDown: (K) => {
|
|
3356
|
+
He(!0);
|
|
3357
|
+
}, onKeyDown: ht }) });
|
|
3358
|
+
})), bs = Dt((e) => {
|
|
3359
|
+
const { value: t, view: n, bounds: o, range: r, zoom: i, children: l, style: s, ...a } = e;
|
|
3360
|
+
return Y("div", { style: { padding: "2px 4px", fontFamily: "Calibri", letterSpacing: -0.25, lineHeight: 1.2, fontSize: s?.fontSize || 1056 / 72, ...s }, ...a, children: t });
|
|
3361
|
+
});
|
|
3362
|
+
export {
|
|
3363
|
+
Ci as BaseGrid,
|
|
3364
|
+
ys as DefaultCellEditor,
|
|
3365
|
+
bs as DefaultCellRenderer,
|
|
3366
|
+
ls as DefaultHeaderDivider,
|
|
3367
|
+
Si as FillHandle,
|
|
3368
|
+
Mi as Grid,
|
|
3369
|
+
vs as HeaderDivider,
|
|
3370
|
+
is as HeaderRenderer,
|
|
3371
|
+
xs as RESET_SCROLL_EVENTS_DEBOUNCE_INTERVAL,
|
|
3372
|
+
tn as SELECTION_CLIP_INSETS,
|
|
3373
|
+
vi as STANDARD_KEY_CHARS,
|
|
3374
|
+
jr as SVGLine,
|
|
3375
|
+
Yl as SVGRect,
|
|
3376
|
+
rs as ScrollableGrid,
|
|
3377
|
+
yi as Selection,
|
|
3378
|
+
Go as TouchSelectHandle,
|
|
3379
|
+
Xl as defaultSelectionRenderer,
|
|
3380
|
+
as as getDefaultStringEditState,
|
|
3381
|
+
Yt as safeSelectionCoords,
|
|
3382
|
+
Fl as useCellLayout,
|
|
3383
|
+
ws as useHeaderSelection,
|
|
3384
|
+
gs as useKeyboardEditorOverlay,
|
|
3385
|
+
ms as useSelection
|
|
3386
|
+
};
|