@sheetxl/utils-react 0.3.17 → 0.3.19
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/browser/cjs/index.cjs +2 -2
- package/browser/esm/index.mjs +897 -868
- package/node/esm/index.mjs +741 -711
- package/package.json +2 -2
package/browser/esm/index.mjs
CHANGED
|
@@ -1,707 +1,736 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode("._sheetxl-scrollbar_eblx4_6 ::-webkit-scrollbar-button{background:transparent}._fullscreen-portal-root_1mjsr_4{pointer-events:none;position:absolute;inset:0;width:100%;height:100%;z-index:1200}._fullscreen-portal-root_1mjsr_4>*{pointer-events:auto}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
|
|
2
|
-
import { jsx as L, jsxs as
|
|
3
|
-
import
|
|
4
|
-
import { CommonUtils as
|
|
5
|
-
import { createRoot as
|
|
6
|
-
import { unstable_batchedUpdates as
|
|
2
|
+
import { jsx as L, jsxs as be, Fragment as Me } from "react/jsx-runtime";
|
|
3
|
+
import me, { useLayoutEffect as Ve, useEffect as V, useState as Q, useMemo as N, useCallback as R, useRef as A, memo as Se, forwardRef as Le, useImperativeHandle as en, version as tn, createElement as nn, useReducer as on } from "react";
|
|
4
|
+
import { CommonUtils as te, ClipboardUtils as Ie, MimeType as Ne, InternalClipboard as Ke } from "@sheetxl/utils";
|
|
5
|
+
import { createRoot as rn } from "react-dom/client";
|
|
6
|
+
import { unstable_batchedUpdates as sn } from "react-dom";
|
|
7
7
|
/**
|
|
8
|
-
* @license @sheetxl/utils-react - Utils React - Utilities for React capabilities needed for all SheetXL components. - v0.3.
|
|
8
|
+
* @license @sheetxl/utils-react - Utils React - Utilities for React capabilities needed for all SheetXL components. - v0.3.19
|
|
9
9
|
*
|
|
10
10
|
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
11
11
|
* License: The license can be found at https://www.sheetxl.com/license.
|
|
12
12
|
*/
|
|
13
|
-
const
|
|
14
|
-
function
|
|
15
|
-
var t, n
|
|
16
|
-
if (typeof
|
|
17
|
-
else if (typeof
|
|
18
|
-
var
|
|
19
|
-
for (
|
|
20
|
-
} else for (
|
|
21
|
-
return
|
|
13
|
+
const Qn = { General: "general", Left: "left", Right: "right", Center: "center", Justify: "justify", Fill: "fill", Distributed: "distributed", CenterContinuous: "centerContinuous" }, Z = { Shift: "shift", Alt: "alt", Ctrl: "ctrl", Meta: "meta" }, eo = { BackSpace: 8, Tab: 9, Clear: 12, Enter: 13, Shift: 16, Control: 17, Alt: 18, Pause: 19, CapsLock: 20, Escape: 27, Space: 32, PageUp: 33, PageDown: 34, End: 35, Home: 36, Left: 37, Up: 38, Right: 39, Down: 40, Insert: 45, Delete: 46, Digit_8: 56, Y: 89, Z: 90, Meta: 91, F1: 112, F2: 113, F3: 114, F4: 115, F5: 116, F6: 117, F7: 118, F8: 119, F9: 120, F10: 121, F11: 122, F12: 123, NumLock: 144, ScrollLock: 145, BackSlash: 220, Slash: 191, BracketRight: 221, BracketLeft: 219 }, to = { Left: 1, Middle: 2, Right: 3 }, re = { Horizontal: "horizontal", Vertical: "vertical" };
|
|
14
|
+
function Lt(i) {
|
|
15
|
+
var e, t, n = "";
|
|
16
|
+
if (typeof i == "string" || typeof i == "number") n += i;
|
|
17
|
+
else if (typeof i == "object") if (Array.isArray(i)) {
|
|
18
|
+
var o = i.length;
|
|
19
|
+
for (e = 0; e < o; e++) i[e] && (t = Lt(i[e])) && (n && (n += " "), n += t);
|
|
20
|
+
} else for (t in i) i[t] && (n && (n += " "), n += t);
|
|
21
|
+
return n;
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
for (var e, t
|
|
25
|
-
return
|
|
23
|
+
function ve() {
|
|
24
|
+
for (var i, e, t = 0, n = "", o = arguments.length; t < o; t++) (i = arguments[t]) && (e = Lt(i)) && (n && (n += " "), n += e);
|
|
25
|
+
return n;
|
|
26
26
|
}
|
|
27
|
-
var
|
|
28
|
-
},
|
|
29
|
-
const
|
|
30
|
-
var
|
|
31
|
-
return new window.ResizeObserver(function(
|
|
32
|
-
if (
|
|
33
|
-
var
|
|
34
|
-
r({ x: c, y: h, width: u, height:
|
|
27
|
+
var ln = function() {
|
|
28
|
+
}, Ct = typeof window < "u", an = Ct ? Ve : V, ut = { x: 0, y: 0, width: 0, height: 0, top: 0, left: 0, bottom: 0, right: 0 };
|
|
29
|
+
const fe = Ct && window.ResizeObserver !== void 0 ? function() {
|
|
30
|
+
var i = Q(null), e = i[0], t = i[1], n = Q(ut), o = n[0], r = n[1], s = N(function() {
|
|
31
|
+
return new window.ResizeObserver(function(l) {
|
|
32
|
+
if (l[0]) {
|
|
33
|
+
var a = l[0].contentRect, c = a.x, h = a.y, u = a.width, d = a.height, w = a.top, b = a.left, x = a.bottom, S = a.right;
|
|
34
|
+
r({ x: c, y: h, width: u, height: d, top: w, left: b, bottom: x, right: S });
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
}, []);
|
|
38
|
-
return
|
|
39
|
-
if (
|
|
38
|
+
return an(function() {
|
|
39
|
+
if (e) return s.observe(e), function() {
|
|
40
40
|
s.disconnect();
|
|
41
41
|
};
|
|
42
|
-
}, [
|
|
42
|
+
}, [e]), [t, o];
|
|
43
43
|
} : function() {
|
|
44
|
-
return [
|
|
45
|
-
}, T = (
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
50
|
-
},
|
|
51
|
-
const { style:
|
|
52
|
-
return L("div", { style: { paddingBottom: "0px", paddingRight: "0px", paddingLeft:
|
|
53
|
-
},
|
|
54
|
-
const { style:
|
|
55
|
-
return L("div", { style: { paddingLeft: "0px", paddingTop: "0px", paddingRight:
|
|
56
|
-
},
|
|
57
|
-
const { style:
|
|
58
|
-
return L("div", { style: { display: "flex", justifyContent: "center", alignItems: "end", transition: "fill-opacity 1s", zIndex: 1, width: "24px", height: "24px", ...
|
|
59
|
-
},
|
|
60
|
-
for (let r = 0; r <
|
|
61
|
-
const s =
|
|
62
|
-
let
|
|
63
|
-
if (
|
|
64
|
-
if (
|
|
65
|
-
} else if (Math.ceil(
|
|
44
|
+
return [ln, ut];
|
|
45
|
+
}, T = (i, e) => {
|
|
46
|
+
const t = R((...r) => i?.(...r), e), n = A(null);
|
|
47
|
+
n.current = t;
|
|
48
|
+
const o = R((...r) => n.current?.(...r), []);
|
|
49
|
+
if (n.current) return o;
|
|
50
|
+
}, cn = (i) => {
|
|
51
|
+
const { style: e, orientation: t = re.Vertical, ...n } = i, o = t === re.Vertical;
|
|
52
|
+
return L("div", { style: { paddingBottom: "0px", paddingRight: "0px", paddingLeft: o ? "0px" : "3px", paddingTop: o ? "3px" : "0px", display: "flex", alignItems: "center", justifyContent: "center", ...e }, ...n, children: L("button", { style: { padding: "0", display: "flex", alignItems: "center", justifyContent: "center", border: "none" }, className: `scrollbar-button ${o ? "vertical" : "horizontal"} single-button start`, children: L("svg", { width: "9", height: "9", viewBox: "0 0 6 6", style: { opacity: "inherit" }, children: L("path", { d: o ? "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" }) }) }) });
|
|
53
|
+
}, hn = (i) => {
|
|
54
|
+
const { style: e, orientation: t = re.Vertical, ...n } = i, o = t === re.Vertical;
|
|
55
|
+
return L("div", { style: { paddingLeft: "0px", paddingTop: "0px", paddingRight: o ? "0px" : "3px", paddingBottom: o ? "3px" : "0px", display: "flex", alignItems: "center", justifyContent: "center", ...e }, ...n, children: L("button", { style: { padding: "0", display: "flex", alignItems: "center", justifyContent: "center", border: "none" }, className: `scrollbar-button ${o ? "vertical" : "horizontal"} single-button end`, children: L("svg", { width: "9", height: "9", viewBox: "0 0 6 6", style: { opacity: "inherit" }, children: L("path", { d: o ? "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" }) }) }) });
|
|
56
|
+
}, no = (i) => {
|
|
57
|
+
const { style: e, orientation: t = re.Vertical, ...n } = i, o = t === re.Vertical;
|
|
58
|
+
return L("div", { style: { display: "flex", justifyContent: "center", alignItems: "end", transition: "fill-opacity 1s", zIndex: 1, width: "24px", height: "24px", ...e }, className: `scrollbar-button ${o ? "vertical" : "horizontal"} edge`, ...n, children: L("svg", { width: "24", height: "24", viewBox: "0 0 24 24", transform: o ? "rotate(90) " : "", children: L("path", { style: { transition: "opacity 240ms ease 0s", opacity: i.disabled ? 0 : 1 }, d: "M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2" }) }) });
|
|
59
|
+
}, Ue = (i, e, t, n, o = 0) => {
|
|
60
|
+
for (let r = 0; r < t.length; r++) {
|
|
61
|
+
const s = t[r].getBoundingClientRect();
|
|
62
|
+
let l = s.left - e, a = l + s.width;
|
|
63
|
+
if (n) {
|
|
64
|
+
if (l < i && a >= i) return l;
|
|
65
|
+
} else if (Math.ceil(a) > Math.ceil(i) + 2) return a;
|
|
66
66
|
}
|
|
67
|
-
return
|
|
68
|
-
},
|
|
69
|
-
const { offset:
|
|
67
|
+
return o;
|
|
68
|
+
}, oo = Object.freeze(Object.defineProperty({ __proto__: null, getScrollTo: Ue }, Symbol.toStringTag, { value: "Module" })), un = "_sheetxl-scrollbar_eblx4_6", et = Se(Le((i, e) => {
|
|
69
|
+
const { offset: t = 0, totalSize: n = 0, viewportSize: o = 0, style: r, className: s, orientation: l = re.Vertical, onScrollOffset: a, onScroll: c, showCustomScrollButtons: h = !1, scrollButtonIncrement: u = 200, scrollButtonInitialRepeatDelay: d = 260, scrollButtonAdditionalRepeatDelay: w = 120, createScrollStartButton: b = cn, createScrollEndButton: x = hn, ...S } = i, P = T(c, [c]), _ = A(null), [y, { width: f, height: k }] = fe(), [z, { width: O, height: F }] = fe(), g = l === re.Vertical, v = g ? "top" : "left", B = g ? "scrollTop" : "scrollLeft", p = g ? k : f, C = g ? F : O, [m, E] = Q(null);
|
|
70
70
|
V(() => {
|
|
71
|
-
|
|
72
|
-
}, [
|
|
73
|
-
const D = R((K,
|
|
71
|
+
m !== null && _.current && _.current.scrollTo({ behavior: "smooth", [v]: m });
|
|
72
|
+
}, [m, g]);
|
|
73
|
+
const D = R((K, se = !1) => {
|
|
74
74
|
if (!_.current) return 0;
|
|
75
|
-
const
|
|
76
|
-
return E(
|
|
77
|
-
}, []), G = R((K,
|
|
75
|
+
const ie = _.current.querySelector(".scrollbar-viewport"), pe = ie.getBoundingClientRect(), le = ie.children, ce = se ? 0 : Ue(K, pe[v], le, !0, Math.max(0, K - u));
|
|
76
|
+
return E(ce), Math.max(0, ce);
|
|
77
|
+
}, []), G = R((K, se = !1) => {
|
|
78
78
|
if (!_.current) return 0;
|
|
79
|
-
const
|
|
80
|
-
return E(
|
|
81
|
-
}, [C,
|
|
82
|
-
W.current =
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
}, [
|
|
79
|
+
const ie = _.current.querySelector(".scrollbar-viewport"), pe = ie.getBoundingClientRect(), le = ie.children, ce = Math.ceil(C - p), Ce = se ? ce : Ue(K, pe[v], le, !1, Math.max(0, K + u));
|
|
80
|
+
return E(Ce), Math.min(ce, Ce);
|
|
81
|
+
}, [C, p]), W = A(null), Y = R((K) => {
|
|
82
|
+
W.current = t;
|
|
83
|
+
const se = K.target[B];
|
|
84
|
+
a(se, o, n), P?.(K);
|
|
85
|
+
}, [a, o, n, t]);
|
|
86
86
|
V(() => {
|
|
87
87
|
const K = W.current;
|
|
88
|
-
W.current = null,
|
|
89
|
-
}, [
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
}, []),
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
},
|
|
88
|
+
W.current = null, t !== K && (_.current[B] = t);
|
|
89
|
+
}, [t, B]);
|
|
90
|
+
const X = A(null), $ = A(null), I = R(() => {
|
|
91
|
+
X.current && (clearTimeout(X.current), X.current = null, $.current = null);
|
|
92
|
+
}, []), j = R((K, se, ie, pe = d) => {
|
|
93
|
+
$.current = K, X.current = setTimeout(() => {
|
|
94
|
+
const le = ie ? D($.current || K) : G($.current || K);
|
|
95
|
+
le !== $.current ? j(le, !1, ie, w) : I();
|
|
96
|
+
}, se ? 0 : pe);
|
|
97
97
|
}, [D, G, I]);
|
|
98
98
|
V(() => () => I(), [I]);
|
|
99
|
-
const
|
|
99
|
+
const ne = t, ge = N(() => {
|
|
100
100
|
if (!h) return null;
|
|
101
|
-
const K = { orientation:
|
|
101
|
+
const K = { orientation: l, disabled: Math.floor(ne) <= 0 || Math.floor(C - p) === 0, onMouseUp: I, onMouseLeave: I, onMouseDown: () => j(ne, !0, !0) };
|
|
102
102
|
return b?.(K);
|
|
103
|
-
}, [h,
|
|
103
|
+
}, [h, l, ne, m, C, p]), ye = N(() => {
|
|
104
104
|
if (!h) return null;
|
|
105
|
-
const K = { orientation:
|
|
106
|
-
return
|
|
107
|
-
}, [h,
|
|
108
|
-
return
|
|
105
|
+
const K = { orientation: l, disabled: Math.floor(C - p) <= Math.ceil(ne), onMouseUp: I, onMouseLeave: I, onMouseDown: () => j(ne, !0, !1) };
|
|
106
|
+
return x?.(K);
|
|
107
|
+
}, [h, l, ne, m, C, p]);
|
|
108
|
+
return be("div", { ref: e, style: { display: "flex", flex: "1", flexDirection: g ? "column" : "row", padding: "0", ...r }, className: ve(un, s), ...S, children: [ge, L("div", { className: "pseudo-scrollbar", style: { flex: "1 1 100%", display: "flex", boxSizing: "content-box", flexDirection: g ? "column" : "row", justifyContent: "center", alignItems: "center" }, ref: y, children: L("div", { tabIndex: -1, style: { flex: "1 1 100%", overflowY: g ? "scroll" : "hidden", overflowX: g ? "hidden" : "scroll", position: "relative", willChange: "transform" }, onScroll: Y, ref: _, children: L("div", { ref: z, style: { position: "absolute", height: g ? n - o + (k ?? 0) : 1, width: g ? 1 : n - o + (f ?? 0) }, className: "scrollbar-viewport" }) }) }), ye] });
|
|
109
109
|
}));
|
|
110
|
-
|
|
111
|
-
let
|
|
112
|
-
const
|
|
113
|
-
let
|
|
114
|
-
return
|
|
115
|
-
},
|
|
116
|
-
let r =
|
|
117
|
-
if (
|
|
118
|
-
const
|
|
119
|
-
for (let
|
|
120
|
-
|
|
110
|
+
et.displayName = "Scrollbar";
|
|
111
|
+
let dt = Date.now, pt = 1e3, de = {}, dn = 1;
|
|
112
|
+
const Ee = (i) => {
|
|
113
|
+
let e = de[i] !== null;
|
|
114
|
+
return e && (de[i] = null), e;
|
|
115
|
+
}, _t = (i, e, t, n = 0, o) => {
|
|
116
|
+
let r = dt(), s = r, l = 0, a = 0, c = 0, h = dn++;
|
|
117
|
+
if (h % 20 == 0) {
|
|
118
|
+
const d = {};
|
|
119
|
+
for (let w in de) d[w] = !0;
|
|
120
|
+
de = d;
|
|
121
121
|
}
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
const u = function(d) {
|
|
123
|
+
let w = d !== !0, b = dt(), x = !0;
|
|
124
|
+
try {
|
|
125
|
+
x = (!e || e(h)) ?? !0;
|
|
126
|
+
} catch {
|
|
127
|
+
x = !1;
|
|
128
|
+
}
|
|
129
|
+
if (!de[h] || !x) return de[h] = null, void t?.(60 - a / ((b - r) / pt), h, !1);
|
|
130
|
+
if (w) {
|
|
131
|
+
c = Math.round((b - s) / 16.666666666666668) - 1;
|
|
132
|
+
for (let _ = 0; _ < Math.min(c, 4); _++) u(!0), a++;
|
|
128
133
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
134
|
+
n && (l = (b - r) / n, l > 1 && (l = 1));
|
|
135
|
+
let S = o ? o(l) : l, P = !1;
|
|
136
|
+
try {
|
|
137
|
+
P = i(S, b, w);
|
|
138
|
+
} catch {
|
|
139
|
+
P = !1;
|
|
140
|
+
}
|
|
141
|
+
P !== !1 && l !== 1 || !w ? w && (s = b, requestAnimationFrame(u)) : (de[h] = null, t?.(60 - a / ((b - r) / pt), h, l === 1 || n == null));
|
|
132
142
|
};
|
|
133
|
-
return
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
},
|
|
137
|
-
return Math.pow(
|
|
138
|
-
}, mn = function(e) {
|
|
139
|
-
return (e /= 0.5) < 1 ? 0.5 * Math.pow(e, 3) : 0.5 * (Math.pow(e - 2, 3) + 2);
|
|
140
|
-
}, Ee = function(e, t) {
|
|
141
|
-
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: _n, penetrationDeceleration: 0.03, penetrationAcceleration: 0.08 }, t) this.options[n] = t[n];
|
|
143
|
+
return de[h] = !0, requestAnimationFrame(u), h;
|
|
144
|
+
}, pn = function(i) {
|
|
145
|
+
return Math.pow(i - 1, 3) + 1;
|
|
146
|
+
}, _n = function(i) {
|
|
147
|
+
return (i /= 0.5) < 1 ? 0.5 * Math.pow(i, 3) : 0.5 * (Math.pow(i - 2, 3) + 2);
|
|
142
148
|
};
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
149
|
+
class mn {
|
|
150
|
+
constructor(e, t) {
|
|
151
|
+
this.__isSingleTouch = !1, this.__isTracking = !1, this.__didDecelerationComplete = !1, this.__isGesturing = !1, this.__isDragging = !1, this.__isDecelerating = 0, this.__isAnimating = 0, this.__interruptedAnimation = !1, this.__lastScale = 1, this.__enableScrollX = !0, this.__enableScrollY = !0, this.__clientLeft = 0, this.__clientTop = 0, this.__clientWidth = 0, this.__clientHeight = 0, this.__contentWidth = 0, this.__contentHeight = 0, this.__snapWidth = 100, this.__snapHeight = 100, this.__zoomLevel = 1, this.__scrollLeft = 0, this.__scrollTop = 0, this.__maxScrollLeft = 0, this.__maxScrollTop = 0, this.__scheduledLeft = 0, this.__scheduledTop = 0, this.__scheduledZoom = 0, this.__lastTouchLeft = 0, this.__lastTouchTop = 0, this.__lastTouchMove = 0, this.__positions = [], this.__initialTouchLeft = 0, this.__initialTouchTop = 0, this.__zoomLevelStart = 1, this.__minDecelerationScrollLeft = null, this.__minDecelerationScrollTop = null, this.__maxDecelerationScrollLeft = null, this.__maxDecelerationScrollTop = null, this.__decelerationVelocityX = null, this.__decelerationVelocityY = 0, 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: void 0, penetrationDeceleration: 0.03, penetrationAcceleration: 0.08, ...t };
|
|
152
|
+
}
|
|
153
|
+
setDimensions(e, t, n, o) {
|
|
154
|
+
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);
|
|
155
|
+
}
|
|
156
|
+
setPosition(e, t) {
|
|
157
|
+
this.__clientLeft = e || 0, this.__clientTop = t || 0;
|
|
158
|
+
}
|
|
159
|
+
setSnapSize(e, t) {
|
|
160
|
+
this.__snapWidth = e, this.__snapHeight = t;
|
|
161
|
+
}
|
|
162
|
+
getValues() {
|
|
163
|
+
return { left: this.__scrollLeft, top: this.__scrollTop, right: this.__scrollLeft + this.__clientWidth / this.__zoomLevel, bottom: this.__scrollTop + this.__clientHeight / this.__zoomLevel, zoom: this.__zoomLevel };
|
|
164
|
+
}
|
|
165
|
+
getPoint(e, t) {
|
|
166
|
+
const n = this.getValues();
|
|
167
|
+
return { left: e / n.zoom, top: t / n.zoom };
|
|
168
|
+
}
|
|
169
|
+
getScrollMax() {
|
|
170
|
+
return { left: this.__maxScrollLeft, top: this.__maxScrollTop };
|
|
171
|
+
}
|
|
172
|
+
zoomTo(e, t = !1, n, o, r) {
|
|
167
173
|
if (!this.options.zooming) throw new Error("Zooming is not enabled!");
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
174
|
+
r && (this.__zoomComplete = r), this.__isDecelerating && (Ee(this.__isDecelerating), this.__isDecelerating = 0);
|
|
175
|
+
const s = this.__zoomLevel;
|
|
176
|
+
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);
|
|
177
|
+
const l = e / s;
|
|
178
|
+
let a = l * (this.__scrollLeft + n) - n, c = l * (this.__scrollTop + o) - o;
|
|
179
|
+
a > this.__maxScrollLeft ? a = this.__maxScrollLeft : a < 0 && (a = 0), c > this.__maxScrollTop ? c = this.__maxScrollTop : c < 0 && (c = 0), this.__publish(a, c, e, t);
|
|
180
|
+
}
|
|
181
|
+
zoomBy(e, t = !1, n = 0, o = 0, r) {
|
|
182
|
+
this.zoomTo(this.__zoomLevel * e, t, n, o, r);
|
|
183
|
+
}
|
|
184
|
+
scrollTo(e, t, n = !1, o = 1) {
|
|
185
|
+
if (this.__isDecelerating && (Ee(this.__isDecelerating), this.__isDecelerating = 0), o !== void 0 && o !== this.__zoomLevel) {
|
|
186
|
+
if (!this.options.zooming) throw new Error("Zooming is not enabled!");
|
|
187
|
+
e *= o, t *= o, this.__computeScrollMax(o);
|
|
188
|
+
} else o = this.__zoomLevel;
|
|
189
|
+
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);
|
|
190
|
+
}
|
|
191
|
+
scrollBy(e = 0, t = 0, n = !1) {
|
|
192
|
+
const o = this.__isAnimating ? this.__scheduledLeft : this.__scrollLeft, r = this.__isAnimating ? this.__scheduledTop : this.__scrollTop;
|
|
193
|
+
this.scrollTo(o + (e || 0), r + (t || 0), n);
|
|
194
|
+
}
|
|
195
|
+
doMouseZoom(e, t, n, o) {
|
|
196
|
+
const r = e > 0 ? 0.97 : 1.03;
|
|
197
|
+
return this.zoomTo(this.__zoomLevel * r, !1, n - this.__clientLeft, o - this.__clientTop);
|
|
198
|
+
}
|
|
199
|
+
doTouchStart(e, t) {
|
|
200
|
+
if (e.length === void 0) throw new Error("Invalid touch list: " + e);
|
|
201
|
+
if (t instanceof Date && (t = t.valueOf()), typeof t != "number") throw new Error("Invalid timestamp value: " + t);
|
|
202
|
+
let n, o;
|
|
203
|
+
this.__interruptedAnimation = !0, this.__isDecelerating && (Ee(this.__isDecelerating), this.__isDecelerating = 0, this.__interruptedAnimation = !0), this.__isAnimating && (Ee(this.__isAnimating), this.__isAnimating = 0, this.__interruptedAnimation = !0);
|
|
204
|
+
let r = e.length === 1;
|
|
205
|
+
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 = [];
|
|
206
|
+
}
|
|
207
|
+
doTouchMove(e, t, n = 1) {
|
|
208
|
+
if (e.length === void 0) throw new Error("Invalid touch list: " + e);
|
|
209
|
+
if (t instanceof Date && (t = t.valueOf()), typeof t != "number") throw new Error("Invalid timestamp value: " + t);
|
|
210
|
+
if (!this.__isTracking) return;
|
|
211
|
+
let o, r;
|
|
212
|
+
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);
|
|
213
|
+
let s = this.__positions;
|
|
191
214
|
if (this.__isDragging) {
|
|
192
|
-
|
|
215
|
+
let l = o - this.__lastTouchLeft, a = r - this.__lastTouchTop, c = this.__scrollLeft, h = this.__scrollTop, u = this.__zoomLevel;
|
|
193
216
|
if (n !== void 0 && this.options.zooming) {
|
|
194
|
-
|
|
195
|
-
if (
|
|
196
|
-
|
|
197
|
-
|
|
217
|
+
let d = u;
|
|
218
|
+
if (u = u / this.__lastScale * n, u = Math.max(Math.min(u, this.options.maxZoom), this.options.minZoom), d !== u) {
|
|
219
|
+
let w = o - this.__clientLeft, b = r - this.__clientTop;
|
|
220
|
+
c = (w + c) * u / d - w, h = (b + h) * u / d - b, this.__computeScrollMax(u);
|
|
198
221
|
}
|
|
199
222
|
}
|
|
200
223
|
if (this.__enableScrollX) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
(
|
|
224
|
+
c -= l * this.options.speedMultiplier;
|
|
225
|
+
let d = this.__maxScrollLeft;
|
|
226
|
+
(c > d || c < 0) && (this.options.bouncing ? c += l / 2 * this.options.speedMultiplier : c = c > d ? d : 0);
|
|
204
227
|
}
|
|
205
228
|
if (this.__enableScrollY) {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
(
|
|
229
|
+
h -= a * this.options.speedMultiplier;
|
|
230
|
+
const d = this.__maxScrollTop;
|
|
231
|
+
(h > d || h < 0) && (this.options.bouncing ? h += a / 2 * this.options.speedMultiplier : h = h > d ? d : 0);
|
|
209
232
|
}
|
|
210
|
-
|
|
233
|
+
s.length > 60 && s.splice(0, 30), s.push(c, h, t), this.__publish(c, h, u);
|
|
211
234
|
} else {
|
|
212
|
-
|
|
213
|
-
this.__enableScrollX = this.options.scrollingX &&
|
|
235
|
+
let l = this.options.locking ? 3 : 0, a = 5, c = Math.abs(o - this.__initialTouchLeft), h = Math.abs(r - this.__initialTouchTop);
|
|
236
|
+
this.__enableScrollX = this.options.scrollingX && c >= l, this.__enableScrollY = this.options.scrollingY && h >= l, s.push(this.__scrollLeft, this.__scrollTop, t), this.__isDragging = (this.__enableScrollX || this.__enableScrollY) && (c >= a || h >= a), this.__isDragging && (this.__interruptedAnimation = !1);
|
|
237
|
+
}
|
|
238
|
+
this.__lastTouchLeft = o, this.__lastTouchTop = r, this.__lastTouchMove = t, this.__lastScale = n;
|
|
239
|
+
}
|
|
240
|
+
doTouchEnd(e) {
|
|
241
|
+
if (e instanceof Date && (e = e.valueOf()), typeof e != "number") throw new Error("Invalid timestamp value: " + e);
|
|
242
|
+
if (this.__isTracking) {
|
|
243
|
+
if (this.__isTracking = !1, this.__isDragging) if (this.__isDragging = !1, this.__isSingleTouch && this.options.animating && e - this.__lastTouchMove <= 100) {
|
|
244
|
+
let t = this.__positions, n = t.length - 1, o = n;
|
|
245
|
+
for (let r = n; r > 0 && t[r] > this.__lastTouchMove - 100; r -= 3) o = r;
|
|
246
|
+
if (o !== n) {
|
|
247
|
+
const r = t[n] - t[o], s = this.__scrollLeft - t[o - 2], l = this.__scrollTop - t[o - 1];
|
|
248
|
+
this.__decelerationVelocityX = s / r * (1e3 / 60), this.__decelerationVelocityY = l / r * (1e3 / 60);
|
|
249
|
+
const a = this.options.paging || this.options.snapping ? 4 : 1;
|
|
250
|
+
(Math.abs(this.__decelerationVelocityX) > a || Math.abs(this.__decelerationVelocityY) > a) && this.__startDeceleration(e);
|
|
251
|
+
} else this.options.scrollingComplete?.();
|
|
252
|
+
} else e - this.__lastTouchMove > 100 && this.options.scrollingComplete?.();
|
|
253
|
+
this.__isDecelerating || ((this.__interruptedAnimation || this.__isDragging) && this.options.scrollingComplete?.(), this.scrollTo(this.__scrollLeft, this.__scrollTop, !0, this.__zoomLevel)), this.__positions.length = 0;
|
|
214
254
|
}
|
|
215
|
-
this.__lastTouchLeft = o, this.__lastTouchTop = i, this.__lastTouchMove = t, this.__lastScale = n;
|
|
216
255
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
this.
|
|
256
|
+
__publish(e, t, n, o = !1) {
|
|
257
|
+
const r = this.__isAnimating;
|
|
258
|
+
if (r && (Ee(r), this.__isAnimating = 0), o && this.options.animating) {
|
|
259
|
+
this.__scheduledLeft = e, this.__scheduledTop = t, this.__scheduledZoom = n;
|
|
260
|
+
const s = this.__scrollLeft, l = this.__scrollTop, a = this.__zoomLevel, c = e - s, h = t - l, u = n - a, d = function(x, S, P) {
|
|
261
|
+
P && (this.__scrollLeft = s + c * x, this.__scrollTop = l + h * x, this.__zoomLevel = a + u * x, this.__callback && this.__callback(this.__scrollLeft, this.__scrollTop, this.__zoomLevel));
|
|
262
|
+
}.bind(this), w = function(x) {
|
|
263
|
+
return this.__isAnimating === x;
|
|
264
|
+
}.bind(this), b = function(x, S, P) {
|
|
265
|
+
S === this.__isAnimating && (this.__isAnimating = !1), (this.__didDecelerationComplete || P) && this.options.scrollingComplete?.(), this.options.zooming && (this.__computeScrollMax(), this.__zoomComplete && (this.__zoomComplete(), this.__zoomComplete = null));
|
|
266
|
+
}.bind(this);
|
|
267
|
+
this.__isAnimating = _t(d, w, b, this.options.animationDuration, r ? pn : _n);
|
|
268
|
+
} 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));
|
|
230
269
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
270
|
+
__computeScrollMax(e = this.__zoomLevel) {
|
|
271
|
+
this.__maxScrollLeft = Math.max(this.__contentWidth * e - this.__clientWidth, 0), this.__maxScrollTop = Math.max(this.__contentHeight * e - this.__clientHeight, 0);
|
|
272
|
+
}
|
|
273
|
+
__startDeceleration(e) {
|
|
274
|
+
if (this.options.paging) {
|
|
275
|
+
const s = Math.max(Math.min(this.__scrollLeft, this.__maxScrollLeft), 0), l = Math.max(Math.min(this.__scrollTop, this.__maxScrollTop), 0), a = this.__clientWidth, c = this.__clientHeight;
|
|
276
|
+
this.__minDecelerationScrollLeft = Math.floor(s / a) * a, this.__minDecelerationScrollTop = Math.floor(l / c) * c, this.__maxDecelerationScrollLeft = Math.ceil(s / a) * a, this.__maxDecelerationScrollTop = Math.ceil(l / c) * c;
|
|
277
|
+
} else this.__minDecelerationScrollLeft = 0, this.__minDecelerationScrollTop = 0, this.__maxDecelerationScrollLeft = this.__maxScrollLeft, this.__maxDecelerationScrollTop = this.__maxScrollTop;
|
|
278
|
+
const t = function(s, l, a) {
|
|
279
|
+
this.__stepThroughDeceleration(a);
|
|
280
|
+
}.bind(this), n = this.options.snapping ? 4 : 0.1, o = function() {
|
|
281
|
+
const s = Math.abs(this.__decelerationVelocityX) >= n || Math.abs(this.__decelerationVelocityY) >= n;
|
|
282
|
+
return s || (this.__didDecelerationComplete = !0), s;
|
|
283
|
+
}.bind(this), r = function(s, l, a) {
|
|
284
|
+
this.__isDecelerating = 0, this.__didDecelerationComplete && this.options.scrollingComplete?.(), this.scrollTo(this.__scrollLeft, this.__scrollTop, this.options.snapping);
|
|
241
285
|
}.bind(this);
|
|
242
|
-
this.
|
|
243
|
-
} 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));
|
|
244
|
-
}, __computeScrollMax: function(e) {
|
|
245
|
-
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);
|
|
246
|
-
}, __startDeceleration: function(e) {
|
|
247
|
-
if (this.options.paging) {
|
|
248
|
-
var t = Math.max(Math.min(this.__scrollLeft, this.__maxScrollLeft), 0), n = Math.max(Math.min(this.__scrollTop, this.__maxScrollTop), 0), o = this.__clientWidth, i = this.__clientHeight;
|
|
249
|
-
this.__minDecelerationScrollLeft = Math.floor(t / o) * o, this.__minDecelerationScrollTop = Math.floor(n / i) * i, this.__maxDecelerationScrollLeft = Math.ceil(t / o) * o, this.__maxDecelerationScrollTop = Math.ceil(n / i) * i;
|
|
250
|
-
} else this.__minDecelerationScrollLeft = 0, this.__minDecelerationScrollTop = 0, this.__maxDecelerationScrollLeft = this.__maxScrollLeft, this.__maxDecelerationScrollTop = this.__maxScrollTop;
|
|
251
|
-
var r = function(c, h, u) {
|
|
252
|
-
this.__stepThroughDeceleration(u);
|
|
253
|
-
}.bind(this), s = this.options.snapping ? 4 : 0.1, a = function() {
|
|
254
|
-
var c = Math.abs(this.__decelerationVelocityX) >= s || Math.abs(this.__decelerationVelocityY) >= s;
|
|
255
|
-
return c || (this.__didDecelerationComplete = !0), c;
|
|
256
|
-
}.bind(this), l = function(c, h, u) {
|
|
257
|
-
this.__isDecelerating = !1, this.__didDecelerationComplete && this.options.scrollingComplete(), this.scrollTo(this.__scrollLeft, this.__scrollTop, this.options.snapping);
|
|
258
|
-
}.bind(this);
|
|
259
|
-
this.__isDecelerating = _e(r, a, l);
|
|
260
|
-
}, __stepThroughDeceleration: function(e) {
|
|
261
|
-
var t = this.__scrollLeft + this.__decelerationVelocityX, n = this.__scrollTop + this.__decelerationVelocityY;
|
|
262
|
-
if (!this.options.bouncing) {
|
|
263
|
-
var o = Math.max(Math.min(this.__maxDecelerationScrollLeft, t), this.__minDecelerationScrollLeft);
|
|
264
|
-
o !== t && (t = o, this.__decelerationVelocityX = 0);
|
|
265
|
-
var i = Math.max(Math.min(this.__maxDecelerationScrollTop, n), this.__minDecelerationScrollTop);
|
|
266
|
-
i !== n && (n = i, this.__decelerationVelocityY = 0);
|
|
286
|
+
this.__isDecelerating = _t(t, o, r);
|
|
267
287
|
}
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
288
|
+
__stepThroughDeceleration(e) {
|
|
289
|
+
let t = this.__scrollLeft + this.__decelerationVelocityX, n = this.__scrollTop + this.__decelerationVelocityY;
|
|
290
|
+
if (!this.options.bouncing) {
|
|
291
|
+
const o = Math.max(Math.min(this.__maxDecelerationScrollLeft, t), this.__minDecelerationScrollLeft);
|
|
292
|
+
o !== t && (t = o, this.__decelerationVelocityX = 0);
|
|
293
|
+
const r = Math.max(Math.min(this.__maxDecelerationScrollTop, n), this.__minDecelerationScrollTop);
|
|
294
|
+
r !== n && (n = r, this.__decelerationVelocityY = 0);
|
|
295
|
+
}
|
|
296
|
+
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) {
|
|
297
|
+
let o = 0, r = 0, s = this.options.penetrationDeceleration, l = this.options.penetrationAcceleration;
|
|
298
|
+
t < this.__minDecelerationScrollLeft ? o = this.__minDecelerationScrollLeft - t : t > this.__maxDecelerationScrollLeft && (o = this.__maxDecelerationScrollLeft - t), n < this.__minDecelerationScrollTop ? r = this.__minDecelerationScrollTop - n : n > this.__maxDecelerationScrollTop && (r = this.__maxDecelerationScrollTop - n), o !== 0 && (o * this.__decelerationVelocityX <= 0 ? this.__decelerationVelocityX += o * s : this.__decelerationVelocityX = o * l), r !== 0 && (r * this.__decelerationVelocityY <= 0 ? this.__decelerationVelocityY += r * s : this.__decelerationVelocityY = r * l);
|
|
299
|
+
}
|
|
271
300
|
}
|
|
272
|
-
}
|
|
273
|
-
var J = typeof window < "u" ? window : { screen: {}, navigator: {} },
|
|
301
|
+
}
|
|
302
|
+
var J = typeof window < "u" ? window : { screen: {}, navigator: {} }, we = (J.matchMedia || function() {
|
|
274
303
|
return { matches: !1 };
|
|
275
|
-
}).bind(J),
|
|
276
|
-
return
|
|
277
|
-
} },
|
|
304
|
+
}).bind(J), Et = !1, fn = { get passive() {
|
|
305
|
+
return Et = !0;
|
|
306
|
+
} }, mt = function() {
|
|
278
307
|
};
|
|
279
|
-
J.addEventListener && J.addEventListener("p",
|
|
280
|
-
var
|
|
281
|
-
const
|
|
282
|
-
function
|
|
283
|
-
return
|
|
308
|
+
J.addEventListener && J.addEventListener("p", mt, fn), J.removeEventListener && J.removeEventListener("p", mt, !1);
|
|
309
|
+
var gn = Et, yn = "PointerEvent" in J, tt = "ontouchstart" in J, Tt = tt || "TouchEvent" in J && we("(any-pointer: coarse)").matches, ft = (J.navigator.maxTouchPoints || 0) > 0 || Tt, Mt = J.navigator.userAgent || "", vn = we("(pointer: coarse)").matches && /iPad|Macintosh/.test(Mt) && Math.min(J.screen.width || 0, J.screen.height || 0) >= 768, Dt = (we("(pointer: coarse)").matches || !we("(pointer: fine)").matches && tt) && !/Windows.*Firefox/.test(Mt), xn = we("(any-pointer: fine)").matches || we("(any-hover: hover)").matches || vn || !tt, Ze = !ft || !xn && Dt ? ft ? "touchOnly" : "mouseOnly" : "hybrid", bn = Ze === "mouseOnly" ? "mouse" : Ze === "touchOnly" || Dt ? "touch" : "mouse";
|
|
310
|
+
const wn = Object.freeze(Object.defineProperty({ __proto__: null, deviceType: Ze, primaryInput: bn, supportsPassiveEvents: gn, supportsPointerEvents: yn, supportsTouchEvents: Tt }, Symbol.toStringTag, { value: "Module" })), Sn = /* @__PURE__ */ new Set(["INPUT", "TEXTAREA", "SELECT"]), Pt = {};
|
|
311
|
+
function Ge() {
|
|
312
|
+
return wn;
|
|
284
313
|
}
|
|
285
|
-
const
|
|
286
|
-
return
|
|
287
|
-
}, createSyntheticEvent: (
|
|
288
|
-
let
|
|
289
|
-
return { nativeEvent:
|
|
290
|
-
|
|
291
|
-
}, isDefaultPrevented: () =>
|
|
292
|
-
|
|
293
|
-
}, isPropagationStopped: () =>
|
|
294
|
-
}, timeStamp:
|
|
295
|
-
}, detectIt:
|
|
296
|
-
function
|
|
297
|
-
const
|
|
298
|
-
return en(
|
|
299
|
-
if (!
|
|
300
|
-
const
|
|
314
|
+
const zt = (i) => i === "BracketLeft" ? "[" : i === "BracketRight" ? "]" : te.camelToPrettyCase(i), io = Object.freeze(Object.defineProperty({ __proto__: null, EmptyCssProperties: Pt, boundPixel: function(i, e = !1, t = 0) {
|
|
315
|
+
return i;
|
|
316
|
+
}, createSyntheticEvent: (i) => {
|
|
317
|
+
let e = !1, t = !1;
|
|
318
|
+
return { nativeEvent: i, currentTarget: i.currentTarget, target: i.target, bubbles: i.bubbles, cancelable: i.cancelable, defaultPrevented: i.defaultPrevented, eventPhase: i.eventPhase, isTrusted: i.isTrusted, preventDefault: () => {
|
|
319
|
+
e = !0, i.preventDefault();
|
|
320
|
+
}, isDefaultPrevented: () => e, stopPropagation: () => {
|
|
321
|
+
t = !0, i.stopPropagation();
|
|
322
|
+
}, isPropagationStopped: () => t, persist: () => {
|
|
323
|
+
}, timeStamp: i.timeStamp, type: i.type };
|
|
324
|
+
}, detectIt: Ge, focusableNodeNames: Sn, toPrettyKeyCode: zt }, Symbol.toStringTag, { value: "Module" })), Ln = [];
|
|
325
|
+
function kt(i, e, t = Ln) {
|
|
326
|
+
const n = A(null);
|
|
327
|
+
return en(i, () => {
|
|
328
|
+
if (!n.current) return;
|
|
329
|
+
const o = n.current, r = e?.();
|
|
301
330
|
if (!r || typeof r != "object") throw new Error("attributes must return a plain object of values");
|
|
302
|
-
const s = Object.keys(r),
|
|
303
|
-
for (let
|
|
304
|
-
const c = s[
|
|
305
|
-
Object.defineProperty(
|
|
331
|
+
const s = Object.keys(r), l = s.length;
|
|
332
|
+
for (let a = 0; a < l; a++) {
|
|
333
|
+
const c = s[a], h = r[c];
|
|
334
|
+
Object.defineProperty(o, c, { value: h, writable: !0, configurable: !0, enumerable: !0 });
|
|
306
335
|
}
|
|
307
|
-
return
|
|
308
|
-
},
|
|
336
|
+
return o;
|
|
337
|
+
}, t), n;
|
|
309
338
|
}
|
|
310
|
-
const
|
|
311
|
-
const { children:
|
|
339
|
+
const gt = (i) => L(et, { ...i }), Cn = ({ width: i, height: e }) => L("div", { className: "corner", style: { minWidth: `${i}px`, width: `${i}px`, minHeight: `${e}px`, height: `${e}px` } }), En = Se(Le((i, e) => {
|
|
340
|
+
const { children: t, viewport: n, onScrollViewport: o, showHorizontalScrollbar: r = !0, showVerticalScrollbar: s = !0, createScrollCorner: l = Cn, createHorizontalScrollbar: a = gt, createVerticalScrollbar: c = gt, style: h, touchElement: u, disableTouch: d, ...w } = i, b = T(o, [o]), x = kt(e, () => ({ isScrollPane: () => !0 }), []), S = A(null);
|
|
312
341
|
V(() => {
|
|
313
|
-
|
|
314
|
-
}, [
|
|
315
|
-
const
|
|
316
|
-
b?.({ left:
|
|
317
|
-
}, []), _ = R((
|
|
318
|
-
|
|
319
|
-
}, []), y = R((
|
|
320
|
-
|
|
321
|
-
}, []),
|
|
322
|
-
|
|
323
|
-
}, []),
|
|
324
|
-
|
|
342
|
+
S.current && (S.current.__scrollTop === n?.top && S.current.__scrollLeft === n?.left || S.current.__isDecelerating || S.current?.scrollTo(n?.left, n?.top, !1));
|
|
343
|
+
}, [n?.left, n?.top, u]);
|
|
344
|
+
const P = R((p, C) => {
|
|
345
|
+
b?.({ left: p, top: C });
|
|
346
|
+
}, []), _ = R((p) => {
|
|
347
|
+
S.current?.doTouchStart(p.touches, p.timeStamp);
|
|
348
|
+
}, []), y = R((p) => {
|
|
349
|
+
p.preventDefault(), S.current?.doTouchMove(p.touches, p.timeStamp);
|
|
350
|
+
}, []), f = R((p) => {
|
|
351
|
+
S.current?.doTouchEnd(p.timeStamp);
|
|
352
|
+
}, []), k = R(({ containerWidth: p, containerHeight: C, totalWidth: m, totalHeight: E }) => {
|
|
353
|
+
S.current.setDimensions(p, C, m, E);
|
|
325
354
|
}, []);
|
|
326
355
|
V(() => {
|
|
327
|
-
const
|
|
328
|
-
if (!
|
|
329
|
-
if (!
|
|
356
|
+
const p = u ?? x.current;
|
|
357
|
+
if (!d && Ge().supportsTouchEvents && p && n) {
|
|
358
|
+
if (!S.current) {
|
|
330
359
|
const C = { scrollingX: !0, scrollingY: !0, decelerationRate: 0.95, penetrationAcceleration: 0.08 };
|
|
331
|
-
|
|
360
|
+
S.current = new mn(P, C);
|
|
332
361
|
}
|
|
333
|
-
|
|
362
|
+
Ge().supportsTouchEvents && (p.addEventListener("touchstart", _), p.addEventListener("touchend", f), p.addEventListener("touchmove", y)), k({ containerWidth: n?.width, containerHeight: n?.height, totalWidth: n?.totalWidth, totalHeight: n?.totalHeight });
|
|
334
363
|
}
|
|
335
364
|
return () => {
|
|
336
|
-
|
|
365
|
+
p?.removeEventListener("touchstart", _), p?.removeEventListener("touchend", f), p?.removeEventListener("touchmove", y);
|
|
337
366
|
};
|
|
338
|
-
}, [
|
|
339
|
-
const [
|
|
340
|
-
const
|
|
367
|
+
}, [n?.width, n?.height, n?.totalWidth, n?.totalHeight, d, u]);
|
|
368
|
+
const [z, { width: O }] = fe(), [F, { height: g }] = fe(), v = N(() => {
|
|
369
|
+
const p = c({ orientation: re.Vertical, offset: n?.top, viewportSize: n?.height, totalSize: n?.totalHeight, onScrollOffset: (C) => {
|
|
341
370
|
b?.({ top: C });
|
|
342
371
|
} });
|
|
343
|
-
return L("div", { style: { display: "flex", flex: "0" }, ref:
|
|
344
|
-
}, [c,
|
|
345
|
-
const
|
|
346
|
-
return
|
|
347
|
-
}, [
|
|
348
|
-
return L("div", { style: { position: "relative", display: "flex", minWidth: s ? `${O}px` : void 0, minHeight: r ? `${g}px` : void 0, ...h }, ...w, ref:
|
|
372
|
+
return L("div", { style: { display: "flex", flex: "0" }, ref: z, children: p });
|
|
373
|
+
}, [c, n?.top, n?.height, n?.totalHeight]), B = N(() => {
|
|
374
|
+
const p = a({ orientation: re.Horizontal, offset: n?.left, viewportSize: n?.width, totalSize: n?.totalWidth, onScrollOffset: (C) => b?.({ left: C }) });
|
|
375
|
+
return be("div", { style: { display: "flex", flex: "none", flexDirection: "row", alignItems: "stretch", justifyContent: "center" }, children: [L("div", { style: { display: "flex", flex: "1 1 100%", flexDirection: "column", width: `calc(100% - ${O}px)` }, children: L("div", { ref: F, className: "sizer", children: p }) }), s ? l({ width: O, height: g }) : L(Me, {})] });
|
|
376
|
+
}, [a, n?.left, n?.width, n?.totalWidth, s, l, O, g]);
|
|
377
|
+
return L("div", { style: { position: "relative", display: "flex", minWidth: s ? `${O}px` : void 0, minHeight: r ? `${g}px` : void 0, ...h }, ...w, ref: x, children: be("div", { style: { position: "relative", width: "100%", flex: "1 1 100%", display: "flex", flexDirection: "column", boxSizing: "border-box" }, children: [be("div", { style: { display: "flex", flex: "1 1 100%", overflow: "hidden" }, children: [L("div", { style: { display: "flex", flex: "1 1 100%", overflow: "hidden" }, children: t }), s ? v : L(Me, {})] }), r ? B : L(Me, {})] }) });
|
|
349
378
|
}));
|
|
350
|
-
|
|
351
|
-
const
|
|
352
|
-
if (
|
|
353
|
-
if (
|
|
354
|
-
|
|
379
|
+
En.displayName = "ScrollPane";
|
|
380
|
+
const yt = { Default: "default", Error: "error", Success: "success", Warning: "warning", Info: "info" }, vt = /* @__PURE__ */ new Set(), At = { showMessage: (i, e) => {
|
|
381
|
+
if (e?.onceKey) {
|
|
382
|
+
if (vt.has(e.onceKey)) return;
|
|
383
|
+
vt.add(e.onceKey);
|
|
355
384
|
}
|
|
356
|
-
let
|
|
357
|
-
|
|
358
|
-
}, showBusy: (
|
|
359
|
-
|
|
385
|
+
let t = console.log;
|
|
386
|
+
e?.type !== yt.Warning && e?.type !== yt.Error || (t = console.warn), t(i);
|
|
387
|
+
}, showBusy: (i, e) => new Promise((t) => {
|
|
388
|
+
t(() => {
|
|
360
389
|
});
|
|
361
|
-
}), showError: (
|
|
362
|
-
console.error(
|
|
363
|
-
} },
|
|
364
|
-
const
|
|
365
|
-
return
|
|
390
|
+
}), showError: (i) => {
|
|
391
|
+
console.error(i);
|
|
392
|
+
} }, Tn = () => {
|
|
393
|
+
const i = document.fullscreenElement;
|
|
394
|
+
return i ? i.querySelector(".fullscreen-portal-root") || i : document.body;
|
|
366
395
|
};
|
|
367
|
-
let
|
|
368
|
-
function
|
|
396
|
+
let ke = 0;
|
|
397
|
+
function ro() {
|
|
369
398
|
return V(() => {
|
|
370
|
-
function
|
|
371
|
-
const
|
|
372
|
-
if (!
|
|
373
|
-
let
|
|
374
|
-
|
|
399
|
+
function i() {
|
|
400
|
+
const e = document.fullscreenElement;
|
|
401
|
+
if (!e) return;
|
|
402
|
+
let t = e.querySelector(".fullscreen-portal-root");
|
|
403
|
+
t || (t = document.createElement("div"), t.className = "fullscreen-portal-root _fullscreen-portal-root_1mjsr_4", e.appendChild(t));
|
|
375
404
|
}
|
|
376
|
-
return
|
|
377
|
-
document.removeEventListener("fullscreenchange",
|
|
378
|
-
|
|
379
|
-
}),
|
|
405
|
+
return ke++, i(), document.addEventListener("fullscreenchange", i), () => {
|
|
406
|
+
document.removeEventListener("fullscreenchange", i), ke--, ke <= 0 && (document.querySelectorAll(".fullscreen-portal-root").forEach((e) => {
|
|
407
|
+
e.parentNode && e.parentNode.removeChild(e);
|
|
408
|
+
}), ke = 0);
|
|
380
409
|
};
|
|
381
|
-
}, []), { getPortalContainer:
|
|
410
|
+
}, []), { getPortalContainer: Tn };
|
|
382
411
|
}
|
|
383
|
-
const
|
|
384
|
-
const { offset:
|
|
412
|
+
const Mn = 100, Dn = 100, Pn = 1e6, zn = 100, kn = 50, An = Se(Le((i, e) => {
|
|
413
|
+
const { offset: t = 0, viewportSize: n = 0, totalSize: o = 0, minSize: r = 0, endGap: s = Mn, endScrollIncrement: l = Dn, style: a = Pt, onMouseDown: c, onScrollOffset: h, onScroll: u, scaleLimit: d = Pn, scaleFactor: w = zn, precisionFactor: b = kn, ...x } = i;
|
|
385
414
|
u && console.warn("onScroll not supported for VirtualScrollbar. Use onScrollOffset instead");
|
|
386
|
-
const
|
|
387
|
-
}, []), [
|
|
388
|
-
|
|
389
|
-
if (!
|
|
390
|
-
|
|
391
|
-
const D =
|
|
415
|
+
const S = T(c, [c]), P = () => ({ offset: t, totalSize: d === 0 ? o : Math.min(o ?? 0, Math.max(r ?? 0, (t ?? 0) + (n ?? 0)) + (s ?? 0)) }), [_, y] = Q(P), f = d !== 0 && _.totalSize > d ? w : 1, k = f / b, z = Math.ceil(_.totalSize / f), O = Math.ceil(_.offset / f), F = Math.ceil(n / f), g = R((D) => {
|
|
416
|
+
}, []), [v, B] = Q(!1), p = A(null);
|
|
417
|
+
Ve(() => {
|
|
418
|
+
if (!v) {
|
|
419
|
+
p.current = { propTotalSize: o, propViewportSize: n, propOffset: t };
|
|
420
|
+
const D = P();
|
|
392
421
|
y(D);
|
|
393
422
|
}
|
|
394
|
-
}, [
|
|
423
|
+
}, [o, n, t, v, r, s, l]);
|
|
395
424
|
const C = T((D, G, W) => {
|
|
396
|
-
const Y =
|
|
397
|
-
|
|
398
|
-
}, [h,
|
|
399
|
-
document.removeEventListener("mousemove", g), document.removeEventListener("mouseup",
|
|
425
|
+
const Y = p.current;
|
|
426
|
+
p.current = null, Y && Y.propTotalSize === o && Y.propViewportSize === n && Y.propOffset === t || (Math.abs(D - O) < k && (D = O), h?.(D * f, O, F));
|
|
427
|
+
}, [h, f, k, O, F]), m = R((D) => {
|
|
428
|
+
document.removeEventListener("mousemove", g), document.removeEventListener("mouseup", m), B(!1);
|
|
400
429
|
}, []), E = R((D) => {
|
|
401
|
-
|
|
402
|
-
}, [g,
|
|
403
|
-
return L(
|
|
430
|
+
S?.(D), B(!0), document.addEventListener("mousemove", g, { passive: !0 }), document.addEventListener("mouseup", m, { passive: !0 });
|
|
431
|
+
}, [g, m]);
|
|
432
|
+
return L(et, { ref: e, style: { ...a }, ...x, offset: O, totalSize: z, viewportSize: F, onMouseDown: E, onScrollOffset: C });
|
|
404
433
|
}));
|
|
405
|
-
|
|
406
|
-
const
|
|
407
|
-
function
|
|
408
|
-
if (typeof
|
|
409
|
-
|
|
434
|
+
An.displayName = "VirtualScrollbar";
|
|
435
|
+
const so = { BottomEnd: "bottom-end", BottomStart: "bottom-start", Bottom: "bottom", LeftEnd: "left-end", LeftStart: "left-start", Left: "left", RightEnd: "right-end", RightStart: "right-start", Right: "right", TopEnd: "top-end", TopStart: "top-start", Top: "top" };
|
|
436
|
+
function We(i, e) {
|
|
437
|
+
if (typeof i == "function") return i(e);
|
|
438
|
+
i && (i.current = e);
|
|
410
439
|
}
|
|
411
|
-
var
|
|
412
|
-
return (
|
|
413
|
-
const
|
|
414
|
-
for (const
|
|
415
|
-
const
|
|
416
|
-
|
|
440
|
+
var He = parseInt(tn.split(".")[0], 10) >= 19 ? function(i) {
|
|
441
|
+
return (e) => {
|
|
442
|
+
const t = [];
|
|
443
|
+
for (const n of i) {
|
|
444
|
+
const o = We(n, e), r = typeof o == "function";
|
|
445
|
+
t.push(r ? o : () => We(n, null));
|
|
417
446
|
}
|
|
418
447
|
return () => {
|
|
419
|
-
for (const
|
|
448
|
+
for (const n of t) n();
|
|
420
449
|
};
|
|
421
450
|
};
|
|
422
|
-
} : function(
|
|
423
|
-
return (
|
|
424
|
-
for (const
|
|
451
|
+
} : function(i) {
|
|
452
|
+
return (e) => {
|
|
453
|
+
for (const t of i) We(t, e);
|
|
425
454
|
};
|
|
426
455
|
};
|
|
427
|
-
const
|
|
428
|
-
const { refFocusStart:
|
|
429
|
-
if (
|
|
430
|
-
const s =
|
|
431
|
-
let
|
|
432
|
-
for (let
|
|
433
|
-
const c = s[
|
|
434
|
-
if (c == null || c === "-1" || s[
|
|
435
|
-
const h = s[
|
|
436
|
-
h.focus &&
|
|
456
|
+
const lo = Se(Le((i, e) => {
|
|
457
|
+
const { refFocusStart: t, ...n } = i, o = A(null), r = R(() => {
|
|
458
|
+
if (t) return void t?.current?.focus();
|
|
459
|
+
const s = o.current.parentElement.children;
|
|
460
|
+
let l = [];
|
|
461
|
+
for (let a = 0; a < s.length && s[a] !== o.current; a++) {
|
|
462
|
+
const c = s[a].getAttribute("tabindex");
|
|
463
|
+
if (c == null || c === "-1" || s[a].getAttribute("disabled") === "true") continue;
|
|
464
|
+
const h = s[a];
|
|
465
|
+
h.focus && l.push({ tabindex: parseInt(c), child: h });
|
|
437
466
|
}
|
|
438
|
-
|
|
439
|
-
return
|
|
440
|
-
}),
|
|
441
|
-
}, [
|
|
442
|
-
return L("div", { tabIndex: 0, ref:
|
|
443
|
-
})),
|
|
444
|
-
const { className:
|
|
445
|
-
const y =
|
|
446
|
-
return function(
|
|
447
|
-
if (
|
|
448
|
-
function F(
|
|
449
|
-
let G = E.x -
|
|
450
|
-
return g(
|
|
467
|
+
l.length !== 0 && (l.sort(function(a, c) {
|
|
468
|
+
return a.tabindex - c.tabindex;
|
|
469
|
+
}), l[0].child.focus());
|
|
470
|
+
}, [t]);
|
|
471
|
+
return L("div", { tabIndex: 0, ref: He([o, e]), onFocus: r, ...n });
|
|
472
|
+
})), ao = Se(Le((i, e) => {
|
|
473
|
+
const { className: t, style: n, children: o, radius: r = 4, strokeWidth: s = 1, strokeColor: l = "grey", ...a } = i, [c, { width: h, height: u }] = fe(), d = A(null), w = (P, _ = 0) => {
|
|
474
|
+
const y = P / 2, f = u - y + _;
|
|
475
|
+
return function(k, z, O = !1) {
|
|
476
|
+
if (z === 0) return k;
|
|
477
|
+
function F(m, E, D) {
|
|
478
|
+
let G = E.x - m.x, W = E.y - m.y, Y = Math.sqrt(G * G + W * W);
|
|
479
|
+
return g(m, E, Math.min(1, D / Y));
|
|
451
480
|
}
|
|
452
|
-
function g(
|
|
453
|
-
return { x:
|
|
481
|
+
function g(m, E, D) {
|
|
482
|
+
return { x: m.x + (E.x - m.x) * D, y: m.y + (E.y - m.y) * D };
|
|
454
483
|
}
|
|
455
|
-
function
|
|
456
|
-
|
|
484
|
+
function v(m, E) {
|
|
485
|
+
m.length > 2 && (m[m.length - 2] = E.x, m[m.length - 1] = E.y);
|
|
457
486
|
}
|
|
458
|
-
function
|
|
459
|
-
return { x: parseFloat(
|
|
487
|
+
function B(m) {
|
|
488
|
+
return { x: parseFloat(m[m.length - 2]), y: parseFloat(m[m.length - 1]) };
|
|
460
489
|
}
|
|
461
|
-
let
|
|
490
|
+
let p = k.split(/[,\s]/).reduce(function(m, E) {
|
|
462
491
|
let D = E.match("([a-zA-Z])(.+)");
|
|
463
|
-
return D ? (
|
|
464
|
-
}, []).reduce(function(
|
|
465
|
-
return parseFloat(E) == E &&
|
|
492
|
+
return D ? (m.push(D[1]), m.push(D[2])) : m.push(E), m;
|
|
493
|
+
}, []).reduce(function(m, E) {
|
|
494
|
+
return parseFloat(E) == E && m.length ? m[m.length - 1].push(E) : m.push([E]), m;
|
|
466
495
|
}, []), C = [];
|
|
467
|
-
if (
|
|
468
|
-
let
|
|
469
|
-
|
|
470
|
-
for (let D = 1; D <
|
|
471
|
-
let G = C[C.length - 1], W =
|
|
496
|
+
if (p.length > 1) {
|
|
497
|
+
let m = B(p[0]), E = null;
|
|
498
|
+
p[p.length - 1][0] === "Z" && p[0].length > 2 && (E = ["L", m.x, m.y], p[p.length - 1] = E), C.push(p[0]);
|
|
499
|
+
for (let D = 1; D < p.length; D++) {
|
|
500
|
+
let G = C[C.length - 1], W = p[D], Y = W === E ? p[1] : p[D + 1];
|
|
472
501
|
if (Y && G && G.length > 2 && W[0] === "L" && Y.length > 2 && Y[0] === "L") {
|
|
473
|
-
let
|
|
474
|
-
O ? (
|
|
475
|
-
let
|
|
476
|
-
K.origPoint =
|
|
502
|
+
let X, $, I = B(G), j = B(W), ne = B(Y);
|
|
503
|
+
O ? (X = g(j, G.origPoint || I, z), $ = g(j, Y.origPoint || ne, z)) : (X = F(j, I, z), $ = F(j, ne, z)), v(W, X), W.origPoint = j, C.push(W);
|
|
504
|
+
let ge = g(X, j, 0.5), ye = g(j, $, 0.5), K = ["C", ge.x, ge.y, ye.x, ye.y, $.x, $.y];
|
|
505
|
+
K.origPoint = j, C.push(K);
|
|
477
506
|
} else C.push(W);
|
|
478
507
|
}
|
|
479
508
|
if (E) {
|
|
480
|
-
let D =
|
|
481
|
-
C.push(["Z"]),
|
|
509
|
+
let D = B(C[C.length - 1]);
|
|
510
|
+
C.push(["Z"]), v(C[0], D);
|
|
482
511
|
}
|
|
483
|
-
} else C =
|
|
484
|
-
return C.reduce(function(
|
|
485
|
-
return
|
|
512
|
+
} else C = p;
|
|
513
|
+
return C.reduce(function(m, E) {
|
|
514
|
+
return m + E.join(" ") + " ";
|
|
486
515
|
}, "");
|
|
487
|
-
}(`${`M 0 ${y} L ${r - 0.5} ${y} L ${r - 0.5} ${
|
|
488
|
-
}, b = N(() => w(s), [h, u, r, s]),
|
|
516
|
+
}(`${`M 0 ${y} L ${r - 0.5} ${y} L ${r - 0.5} ${f} L ${2 * r} ${f}`} ${`L ${h - 2 * r} ${f}`} ${`M ${h - 2 * r} ${f} L ${h - r} ${f} L ${h - r} ${y} L ${h} ${y}`}`, r);
|
|
517
|
+
}, b = N(() => w(s), [h, u, r, s]), x = N(() => {
|
|
489
518
|
if (r === 0) return;
|
|
490
|
-
const
|
|
491
|
-
return w(r) + `L ${h} 0 L 0 0 L 0 ${
|
|
492
|
-
}, [b, r, s]),
|
|
493
|
-
return
|
|
494
|
-
})),
|
|
495
|
-
const { onPointerDown:
|
|
496
|
-
return L("div", { style: { ...
|
|
497
|
-
},
|
|
498
|
-
if (
|
|
499
|
-
const
|
|
500
|
-
let
|
|
501
|
-
return typeof
|
|
502
|
-
},
|
|
503
|
-
const { elementBefore:
|
|
504
|
-
if (
|
|
505
|
-
const F = N(() =>
|
|
519
|
+
const P = r / 2;
|
|
520
|
+
return w(r) + `L ${h} 0 L 0 0 L 0 ${P}`;
|
|
521
|
+
}, [b, r, s]), S = N(() => ({ style: { clipPath: `path('${x}')` } }), [x]);
|
|
522
|
+
return be("div", { className: t, style: { display: "flex", flexDirection: "row", ...n }, ...a, ref: He([d, c, e]), children: [me.isValidElement(o) ? me.cloneElement(o, S) : L(Me, {}), L("svg", { style: { position: "absolute", top: 0, left: 0, pointerEvents: "none" }, width: h, height: u, viewBox: `0 0 ${h} ${u}`, children: L("path", { d: b, stroke: l, fill: "none", vectorEffect: "non-scaling-stroke", strokeWidth: s }) })] });
|
|
523
|
+
})), Bn = {}, $n = (i) => {
|
|
524
|
+
const { onPointerDown: e, style: t, splitDirection: n, paddingBefore: o = 0, paddingAfter: r = 0, disabled: s, key: l, hitAreaProps: a = Bn, ...c } = i, h = n === "row", { style: u, className: d, ...w } = a;
|
|
525
|
+
return L("div", { style: { ...t, position: "relative" }, ...c, children: L("div", { className: ve("hit-box", d), style: { left: (h ? -o : 0) + "px", width: `calc(100% + ${h ? o + r : 0}px)`, top: (h ? 0 : -o) + "px", height: `calc(100% + ${h ? 0 : o + r}px)`, position: "absolute", ...u }, onPointerDown: s ? void 0 : e, ...w }) }, l);
|
|
526
|
+
}, Ae = {}, _e = (i, e, t = !0) => i === null ? null : i.pixels !== null ? t ? i.pixels : e - i.pixels : (t ? i.percent : 100 - i.percent) / 100 * e, Be = (i, e = !0) => i?.percent ? `${e ? i.percent : 100 - i.percent}%` : i?.pixels ? `${i.pixels}px` : void 0, ue = (i, e) => {
|
|
527
|
+
if (i == null) return null;
|
|
528
|
+
const t = { percent: null, pixels: null };
|
|
529
|
+
let n = e;
|
|
530
|
+
return typeof i == "string" && ((i = i.trim().toLowerCase()).endsWith("px") ? (i = i.substring(0, i.length - 2), n = !1) : i.endsWith("%") && (i = i.substring(0, i.length - 1), n = !0), i = parseFloat(i)), n ? t.percent = i : t.pixels = i, Object.freeze(t);
|
|
531
|
+
}, co = Se(Le((i, e) => {
|
|
532
|
+
const { elementBefore: t, elementAfter: n, splitDirection: o = "row", fixedPane: r = null, position: s, onPositionChange: l, minBefore: a, maxBefore: c, minAfter: h, maxAfter: u, children: d, className: w, style: b, disabled: x = !1, onDragStart: S, onDragResize: P, onDragFinish: _, resizerProps: y = Ae, paneProps: f = Ae, paneBeforeProps: k = Ae, paneAfterProps: z = Ae, createResizer: O = $n } = i;
|
|
533
|
+
if (d) throw new Error("Use elementBefore and elementAfter instead of children.");
|
|
534
|
+
const F = N(() => me.isValidElement(n) && me.isValidElement(t), [n, t]), g = N(() => {
|
|
506
535
|
let M = null;
|
|
507
536
|
r && (r === "before" ? M = 0 : r === "after" && (M = 1));
|
|
508
537
|
const H = M === null;
|
|
509
|
-
return { fixedPaneOffset: M, isPercent: H, minBefore:
|
|
510
|
-
}, [
|
|
538
|
+
return { fixedPaneOffset: M, isPercent: H, minBefore: ue(a, H), maxBefore: ue(c, H), minAfter: ue(h, H), maxAfter: ue(u, H) };
|
|
539
|
+
}, [a, c, h, u]), v = T(l, [l]), [B, p] = Q(() => ue(s, r === null));
|
|
511
540
|
V(() => {
|
|
512
|
-
|
|
541
|
+
p(ue(s, r === null));
|
|
513
542
|
}, [s, r]);
|
|
514
|
-
const [C, { width:
|
|
515
|
-
const
|
|
516
|
-
if (M || (M = { percent: U.fixedPaneOffset === null ? 50 : null, pixels: U.fixedPaneOffset === null ? null : 0 }), H === 0) return M?.pixels != null ? U.fixedPaneOffset !== 1 ? (
|
|
517
|
-
let
|
|
518
|
-
|
|
519
|
-
const
|
|
520
|
-
return
|
|
521
|
-
})(
|
|
522
|
-
const H =
|
|
523
|
-
|
|
524
|
-
}, [r]),
|
|
525
|
-
if (
|
|
526
|
-
const H =
|
|
543
|
+
const [C, { width: m, height: E }] = fe(), [D, { width: G, height: W }] = fe(), Y = o === "row" ? G : W, X = o === "row" ? m : E, $ = N(() => ((M, H, q, U) => {
|
|
544
|
+
const ae = [null, null], oe = [null, null];
|
|
545
|
+
if (M || (M = { percent: U.fixedPaneOffset === null ? 50 : null, pixels: U.fixedPaneOffset === null ? null : 0 }), H === 0) return M?.pixels != null ? U.fixedPaneOffset !== 1 ? (ae[0] = M?.pixels, oe[1] = 100) : (ae[1] = M?.pixels - q, oe[0] = 100) : M?.percent != null && (U.fixedPaneOffset !== 1 ? (oe[0] = M?.percent, oe[1] = 100 - M?.percent) : (oe[1] = M?.percent, oe[0] = 100 - M?.percent)), { percents: oe, pixels: ae, minBefore: Be(U.minBefore, !0), maxBefore: Be(U.maxBefore, !0), minAfter: Be(U.minAfter), maxAfter: Be(U.maxAfter) };
|
|
546
|
+
let he = _e(M, H, U.fixedPaneOffset !== 1), ee = H - q, at = _e(U.minBefore, ee, !0) ?? 0, Jt = _e(U.maxBefore, ee, !0) ?? ee, ze = 0, Fe = 0, ct = 0, ht = ee;
|
|
547
|
+
ze = (_e(U.maxAfter, H, !1) ?? q) - q, Fe = _e(U.minAfter, H, !1) ?? H, ct = Math.max(at, ze), ht = Math.min(Jt, Fe), he = Math.max(ct, Math.min(he, ht)), Fe = Math.min(ee - he, _e(U.maxAfter, ee - he, !0) ?? ee), ze = Math.min(ee - he, _e(U.minAfter, ee - he, !0) ?? ee), ae[0] = he, ae[1] = ee - ae[0];
|
|
548
|
+
const Qt = Math.max(0, Math.min(100, he / ee * 100));
|
|
549
|
+
return oe[0] = Qt, oe[1] = 100 - oe[0], { percents: oe, pixels: ae, minBefore: `${at}px`, minAfter: `${ze}px`, maxBefore: `${ae[0]}px`, maxAfter: `${ae[1]}px` };
|
|
550
|
+
})(B, X, Y, g), [g, B, X, Y, o]), [I, j] = Q(!1), ne = T(S, [S]), ge = T(P, [P]), ye = T(_, [_]), K = A(null), se = A(null), ie = A(null), { style: pe, className: le, ...ce } = f, Ce = { minWidth: 0, minHeight: 0, maxWidth: "100%", maxHeight: "100%", display: "flex", overflow: "hidden", ...pe }, { className: Ht, style: Rt, ...Vt } = k, { className: Ft, style: It, ...Nt } = z, Wt = { flex: "1 1 100%", width: "100%", ...b, flexDirection: o, display: "flex" }, { className: nt, style: ot, onPointerDown: it, ...rt } = y, Yt = T((M) => {
|
|
551
|
+
const H = ue(M, r === null);
|
|
552
|
+
p(H);
|
|
553
|
+
}, [r]), De = T((M) => {
|
|
554
|
+
if (x || !I) return;
|
|
555
|
+
const H = lt.current?.getBoundingClientRect();
|
|
527
556
|
let q = 0;
|
|
528
|
-
q =
|
|
529
|
-
}, [g,
|
|
530
|
-
if (document.removeEventListener("pointermove",
|
|
531
|
-
if (
|
|
532
|
-
const H = { ...
|
|
533
|
-
H.percent === null && (H.percent = H.pixels /
|
|
557
|
+
q = o === "row" ? (M.clientX ?? M.touches?.[0]?.clientX) - H.x : (M.clientY ?? M.touches?.[0]?.clientY) - H.y, q = Math.max(0, Math.min(X, q)), g.fixedPaneOffset === 1 && (q = X - q), s && B.pixels === q || p({ pixels: q, percent: null }), ge?.(q), M.stopPropagation(), M.preventDefault();
|
|
558
|
+
}, [g, o, x, I, B, X]), st = T((M) => {
|
|
559
|
+
if (document.removeEventListener("pointermove", De), document.removeEventListener("touchmove", De), document.removeEventListener("pointerup", st), !!I && (j(!1), !!B)) {
|
|
560
|
+
if (ye(B.pixels), !ue(s, r === null) || B.pixels !== s) {
|
|
561
|
+
const H = { ...B };
|
|
562
|
+
H.percent === null && (H.percent = H.pixels / X * 100), v(H);
|
|
534
563
|
}
|
|
535
564
|
M.stopPropagation(), M.preventDefault();
|
|
536
565
|
}
|
|
537
|
-
}, [
|
|
538
|
-
|
|
539
|
-
}, [
|
|
540
|
-
return
|
|
566
|
+
}, [B, I, s, r, X]), Xt = T((M) => {
|
|
567
|
+
it?.(M), M.defaultPrevented || x || I || (j(!0), ne(), document.addEventListener("pointermove", De, { passive: !1 }), document.addEventListener("touchmove", De, { passive: !1 }), document.addEventListener("pointerup", st, { passive: !1 }));
|
|
568
|
+
}, [it]), lt = kt(e, () => ({ setPosition: Yt, isSplitPane: () => !0 }), []), jt = N(() => F ? O?.({ key: "resizer", ref: He([D, se]), className: ve("resizer", nt), onPointerDownCapture: Xt, style: { cursor: x ? void 0 : o === "row" ? "ew-resize" : "ns-resize", minWidth: o === "row" ? "2px" : void 0, minHeight: o !== "row" ? "2px" : void 0, boxSizing: "border-box", pointerEvents: "all", zIndex: 1, ...ot }, splitDirection: o, disabled: x, ...rt }) : null, [F, nt, rt, o, ot, x]), Pe = o === "row" ? "Width" : "Height", Ut = { ...Ce, ...Rt, flex: g.fixedPaneOffset === 0 && $?.pixels[0] !== null ? `0 0 ${Math.round($?.pixels[0])}px` : `1 1 ${Math.round($?.percents[0] ?? 100)}%`, [`min${Pe}`]: $?.minBefore, [`max${Pe}`]: n ? $?.maxBefore : "100%" }, Zt = { ...Ce, ...It, flex: g.fixedPaneOffset === 1 && $?.pixels[1] !== null ? `0 0 ${Math.round($?.pixels[1])}px` : `1 1 ${Math.round($?.percents[1] ?? 100)}%`, [`min${Pe}`]: $?.minAfter, [`max${Pe}`]: t ? $?.maxAfter : "100%" }, Gt = N(() => t ? L("div", { ref: K, className: ve("before", le, Ht), style: Ut, ...ce, ...Vt, children: t }, "before") : null, [t, f, k, g, $]), qt = N(() => n ? L("div", { ref: ie, className: ve("after", le, Ft), style: Zt, ...ce, ...Nt, children: n }, "after") : null, [n, f, z, g, $]);
|
|
569
|
+
return be("div", { ref: He([C, lt]), className: ve("splitPane", o === "row" ? "vertical" : "horizontal", { dragging: I }, w), style: Wt, children: [Gt, jt, qt] });
|
|
541
570
|
}));
|
|
542
|
-
function
|
|
543
|
-
const [
|
|
571
|
+
function ho(i) {
|
|
572
|
+
const [e, t] = Q(typeof window < "u" ? window.devicePixelRatio : 1), n = A(null);
|
|
544
573
|
return V(() => {
|
|
545
574
|
if (!(typeof window < "u" && "matchMedia" in window)) return;
|
|
546
|
-
const
|
|
575
|
+
const o = () => {
|
|
547
576
|
const r = window.matchMedia(`screen and (resolution: ${window.devicePixelRatio}dppx)`);
|
|
548
|
-
r.addEventListener("change",
|
|
577
|
+
r.addEventListener("change", o, { once: !0, passive: !0 }), t(window.devicePixelRatio), n.current = { mediaMatcher: r, listener: o };
|
|
549
578
|
};
|
|
550
|
-
return
|
|
551
|
-
|
|
579
|
+
return o(), () => {
|
|
580
|
+
n.current && n.current.mediaMatcher.removeEventListener("change", n.current.listener);
|
|
552
581
|
};
|
|
553
|
-
}, [
|
|
582
|
+
}, [i]), e;
|
|
554
583
|
}
|
|
555
|
-
function
|
|
584
|
+
function uo(i) {
|
|
556
585
|
if (typeof window > "u") return 1;
|
|
557
|
-
const { defaultDpr:
|
|
558
|
-
return Math.min(Math.max(1,
|
|
586
|
+
const { defaultDpr: e = 1, maxDpr: t = 3, round: n = !0 } = i || {}, o = typeof window < "u" && typeof window.devicePixelRatio == "number" ? window.devicePixelRatio : e;
|
|
587
|
+
return Math.min(Math.max(1, n ? Math.floor(o) : o), t);
|
|
559
588
|
}
|
|
560
|
-
function
|
|
561
|
-
const
|
|
589
|
+
function po(i, e, t) {
|
|
590
|
+
const n = T(e, [e]);
|
|
562
591
|
V(() => {
|
|
563
|
-
const
|
|
564
|
-
|
|
592
|
+
const o = (r) => {
|
|
593
|
+
i.current && !i.current.contains(r.target) && n(r);
|
|
565
594
|
};
|
|
566
|
-
return
|
|
567
|
-
document.removeEventListener("mousedown",
|
|
595
|
+
return t && t.mouseEvents === !1 || (document.addEventListener("mousedown", o), document.addEventListener("touchstart", o)), t && t.focusEvents === !1 || document.addEventListener("focus", o), () => {
|
|
596
|
+
document.removeEventListener("mousedown", o), document.removeEventListener("touchstart", o), document.removeEventListener("focus", o);
|
|
568
597
|
};
|
|
569
|
-
}, [
|
|
598
|
+
}, [i]);
|
|
570
599
|
}
|
|
571
|
-
function
|
|
572
|
-
if (!
|
|
573
|
-
const { onPointerDown:
|
|
574
|
-
|
|
575
|
-
}, []),
|
|
576
|
-
|
|
600
|
+
function On(i) {
|
|
601
|
+
if (!i) throw new Error("must have a PointerHandlerOptions");
|
|
602
|
+
const { onPointerDown: e, onPointerUp: t, onPointerMoveOrWait: n, processTouch: o = !1, consumeTouch: r = !0 } = i, s = T(e, [e]), l = T(t, [t]), a = T(n, [n]), c = A(!1), h = i?.timerInitial ?? 230, u = i?.timerContinuous ?? h / 2, d = A(null), w = A(null), b = A(null), x = A(null), S = R(() => {
|
|
603
|
+
x.current && (clearTimeout(x.current), x.current = null);
|
|
604
|
+
}, []), P = R((v) => {
|
|
605
|
+
x.current = setTimeout(() => {
|
|
577
606
|
window.requestAnimationFrame(() => {
|
|
578
|
-
c.current !== !1 &&
|
|
579
|
-
}),
|
|
580
|
-
},
|
|
607
|
+
c.current !== !1 && a?.(w.current, b.current, d.current);
|
|
608
|
+
}), P(u);
|
|
609
|
+
}, v ?? h);
|
|
581
610
|
}, []);
|
|
582
|
-
V(() => () =>
|
|
583
|
-
const _ =
|
|
584
|
-
|
|
585
|
-
}, []),
|
|
586
|
-
document.removeEventListener(`${_}move`, O), document.removeEventListener(`${_}up`,
|
|
587
|
-
c.current !== !1 && (c.current = !1,
|
|
611
|
+
V(() => () => S(), []);
|
|
612
|
+
const _ = o ? "pointer" : "mouse", y = R((v) => {
|
|
613
|
+
v.stopPropagation(), v.stopImmediatePropagation(), v.preventDefault();
|
|
614
|
+
}, []), f = T((v) => {
|
|
615
|
+
document.removeEventListener(`${_}move`, O), document.removeEventListener(`${_}up`, f), document.removeEventListener("keydown", F), document.removeEventListener("keyup", g), document.removeEventListener("touchstart", y, { capture: !0 }), document.removeEventListener("touchmove", y, { capture: !0 }), window.removeEventListener("blur", k), S(), window.requestAnimationFrame(() => {
|
|
616
|
+
c.current !== !1 && (c.current = !1, l?.(v, b.current, d.current), b.current = null);
|
|
588
617
|
});
|
|
589
|
-
}, []),
|
|
590
|
-
c.current !== !1 && (c.current = !1,
|
|
591
|
-
}, []),
|
|
592
|
-
|
|
593
|
-
c.current !== !1 &&
|
|
618
|
+
}, []), k = R(() => {
|
|
619
|
+
c.current !== !1 && (c.current = !1, f(w.current));
|
|
620
|
+
}, []), z = T(() => {
|
|
621
|
+
S(), P(u), window.requestAnimationFrame(() => {
|
|
622
|
+
c.current !== !1 && a?.(w.current, b.current, d.current);
|
|
594
623
|
});
|
|
595
|
-
}, [u]), O = T((
|
|
596
|
-
w.current =
|
|
597
|
-
}, []), F = T((
|
|
598
|
-
b.current = { ctrlKey:
|
|
599
|
-
}, []), g = T((
|
|
600
|
-
b.current = { ctrlKey:
|
|
624
|
+
}, [u]), O = T((v) => {
|
|
625
|
+
w.current = v, z();
|
|
626
|
+
}, []), F = T((v) => {
|
|
627
|
+
b.current = { ctrlKey: v.ctrlKey, shiftKey: v.shiftKey, altKey: v.altKey, metaKey: v.metaKey }, z();
|
|
628
|
+
}, []), g = T((v) => {
|
|
629
|
+
b.current = { ctrlKey: v.ctrlKey, shiftKey: v.shiftKey, altKey: v.altKey, metaKey: v.metaKey }, z();
|
|
601
630
|
}, [u]);
|
|
602
|
-
return T((
|
|
603
|
-
|
|
604
|
-
}, [h,
|
|
631
|
+
return T((v) => {
|
|
632
|
+
v.isDefaultPrevented() || (b.current = { ctrlKey: v.ctrlKey, shiftKey: v.shiftKey, altKey: v.altKey, metaKey: v.metaKey }, s(v, b.current) !== !1 && (d.current = v, w.current = v.nativeEvent, document.addEventListener(`${_}up`, f, { passive: !1 }), document.addEventListener(`${_}move`, O, { passive: !1 }), document.addEventListener("keydown", F, { passive: !1 }), document.addEventListener("keyup", g, { passive: !1 }), window.addEventListener("blur", k, { passive: !0 }), o && r && (document.addEventListener("touchstart", y, { passive: !1, capture: !0 }), document.addEventListener("touchmove", y, { passive: !1, capture: !0 })), c.current = !0, P(h)));
|
|
633
|
+
}, [h, o]);
|
|
605
634
|
}
|
|
606
|
-
function
|
|
607
|
-
return
|
|
608
|
-
|
|
609
|
-
}, ...
|
|
635
|
+
function _o(i, e) {
|
|
636
|
+
return On({ onPointerDown: i, onPointerMoveOrWait: (t, n, o) => {
|
|
637
|
+
i?.(o);
|
|
638
|
+
}, ...e });
|
|
610
639
|
}
|
|
611
|
-
const
|
|
612
|
-
const
|
|
613
|
-
if (typeof
|
|
614
|
-
const
|
|
615
|
-
return
|
|
616
|
-
|
|
617
|
-
}, [
|
|
618
|
-
},
|
|
619
|
-
console && console.warn && console.warn(
|
|
620
|
-
},
|
|
621
|
-
let
|
|
622
|
-
const
|
|
623
|
-
|
|
624
|
-
},
|
|
625
|
-
const [
|
|
626
|
-
return
|
|
627
|
-
let
|
|
640
|
+
const Kn = ({ initValue: i, useHookBody: e, applyStateChange: t }) => {
|
|
641
|
+
const n = A(i);
|
|
642
|
+
if (typeof e != "function") throw new Error("function expected as hook body parameter. got " + typeof e);
|
|
643
|
+
const o = e();
|
|
644
|
+
return Ve(() => {
|
|
645
|
+
n.current !== o && (n.current = o, t(o));
|
|
646
|
+
}, [t, o]), null;
|
|
647
|
+
}, qe = (i) => {
|
|
648
|
+
console && console.warn && console.warn(i);
|
|
649
|
+
}, Ye = typeof self == "object" && self.self === self && self || typeof global == "object" && global.global === global && global || void 0;
|
|
650
|
+
let Hn = 1, Je = !1, Bt = !1;
|
|
651
|
+
const Oe = [], xe = [], Re = () => {
|
|
652
|
+
xe.forEach((i) => i());
|
|
653
|
+
}, Rn = ({ automaticContainerInternalUseOnly: i }) => {
|
|
654
|
+
const [e, t] = Q([]), n = A([]);
|
|
655
|
+
return n.current = e, i || Je !== !1 || (Bt = !0), V(() => {
|
|
656
|
+
let o = !0;
|
|
628
657
|
function r() {
|
|
629
|
-
if (
|
|
658
|
+
if (o) return xe[0] !== r ? (i || Je !== !0 || qe("SingletonHooksContainer is mounted after some singleton hook has been used.Your SingletonHooksContainer will not be used in favor of internal one."), void t((s) => [])) : void t([...Oe]);
|
|
630
659
|
}
|
|
631
|
-
return
|
|
632
|
-
|
|
660
|
+
return xe.push(r), Re(), () => {
|
|
661
|
+
o = !1, n.current?.length > 0 && qe("SingletonHooksContainer is unmounted, but it has active singleton hooks. They will be reevaluated once SingletonHooksContainer is mounted again"), xe.splice(xe.indexOf(r), 1), Re();
|
|
633
662
|
};
|
|
634
|
-
}, [
|
|
635
|
-
},
|
|
636
|
-
const
|
|
637
|
-
return
|
|
638
|
-
if (
|
|
639
|
-
const
|
|
640
|
-
|
|
641
|
-
} else
|
|
642
|
-
})(
|
|
643
|
-
|
|
663
|
+
}, [i]), L(Me, { children: e.map(({ hook: o, key: r }) => nn(Kn, { ...o, key: r })) });
|
|
664
|
+
}, Vn = (i) => {
|
|
665
|
+
const e = Hn++;
|
|
666
|
+
return Oe.push({ hook: i, key: e }), xe.length === 0 && Bt === !1 && (Je = !0, ((t) => {
|
|
667
|
+
if (Ye.document && Ye.document.createElement) {
|
|
668
|
+
const n = Ye.document.createElement("div");
|
|
669
|
+
rn(n).render(L(t, { automaticContainerInternalUseOnly: !0 }));
|
|
670
|
+
} else qe("Can not mount SingletonHooksContainer on server side. Did you manage to run useEffect on server? Please mount SingletonHooksContainer into your components tree manually.");
|
|
671
|
+
})(Rn)), Re(), () => {
|
|
672
|
+
Oe.splice(Oe.findIndex((t) => t.key === e), 1), Re();
|
|
644
673
|
};
|
|
645
|
-
},
|
|
646
|
-
let
|
|
674
|
+
}, $t = (i, e, t = {}) => {
|
|
675
|
+
let n, o, r = !1, s = !1, l = [], { unmountIfNoConsumers: a = !1 } = t;
|
|
647
676
|
const c = (u) => {
|
|
648
|
-
|
|
649
|
-
}, h = () => (s || (
|
|
677
|
+
o = u, sn(() => l.forEach((d) => d(u)));
|
|
678
|
+
}, h = () => (s || (o = typeof i == "function" ? i() : i, s = !0), o);
|
|
650
679
|
return () => {
|
|
651
|
-
const [u,
|
|
652
|
-
return V(() => (r || (r = !0,
|
|
653
|
-
|
|
680
|
+
const [u, d] = Q(h);
|
|
681
|
+
return V(() => (r || (r = !0, n = Vn({ initValue: i, useHookBody: e, applyStateChange: c })), l.push(d), o !== u && d(o), () => {
|
|
682
|
+
l.splice(l.indexOf(d), 1), l.length === 0 && a && (n(), r = !1);
|
|
654
683
|
}), []), u;
|
|
655
684
|
};
|
|
656
685
|
};
|
|
657
|
-
let
|
|
686
|
+
let Ot = () => {
|
|
658
687
|
console.warn("You must call useEditMode before setting its state.");
|
|
659
688
|
};
|
|
660
|
-
const
|
|
661
|
-
const [
|
|
662
|
-
return
|
|
689
|
+
const Fn = $t(null, () => {
|
|
690
|
+
const [i, e] = Q(null);
|
|
691
|
+
return Ot = e, i;
|
|
663
692
|
}), mo = () => {
|
|
664
|
-
const
|
|
665
|
-
return N(() => ({ setMode: (
|
|
666
|
-
|
|
667
|
-
}, getMode: () =>
|
|
693
|
+
const i = Fn();
|
|
694
|
+
return N(() => ({ setMode: (e) => {
|
|
695
|
+
Ot((t) => (typeof e == "function" && (e = e(t)), e?.onModeChange?.(e ?? null), e));
|
|
696
|
+
}, getMode: () => i }), [i]);
|
|
668
697
|
};
|
|
669
|
-
class
|
|
670
|
-
constructor(t, n, o
|
|
671
|
-
this._listenersProperties = /* @__PURE__ */ new Set(), this._listenersExecute = /* @__PURE__ */ new Set(), this._key =
|
|
698
|
+
class Qe {
|
|
699
|
+
constructor(e, t, n, o) {
|
|
700
|
+
this._listenersProperties = /* @__PURE__ */ new Set(), this._listenersExecute = /* @__PURE__ */ new Set(), this._key = e, this._target = t, this._applyProps(n || {}), this._callback = o, o === void 0 && (this._callback = () => {
|
|
672
701
|
console.log(`implement: ${this.label()} : ${this.description()}`);
|
|
673
702
|
});
|
|
674
703
|
}
|
|
675
704
|
key() {
|
|
676
705
|
return this._key;
|
|
677
706
|
}
|
|
678
|
-
_resolve(
|
|
679
|
-
if (typeof
|
|
680
|
-
const
|
|
681
|
-
return
|
|
707
|
+
_resolve(e, t) {
|
|
708
|
+
if (typeof e == "function") {
|
|
709
|
+
const n = t ?? this._context;
|
|
710
|
+
return e(typeof n == "function" ? n() : n);
|
|
682
711
|
}
|
|
683
|
-
return
|
|
712
|
+
return e;
|
|
684
713
|
}
|
|
685
714
|
target() {
|
|
686
715
|
return typeof this._target == "function" ? this._target() : this._target;
|
|
687
716
|
}
|
|
688
|
-
label(
|
|
689
|
-
const
|
|
690
|
-
let
|
|
691
|
-
if (typeof
|
|
692
|
-
const r =
|
|
693
|
-
|
|
694
|
-
} else
|
|
695
|
-
return
|
|
717
|
+
label(e, t) {
|
|
718
|
+
const n = this._scopedLabels?.[e] || this._label;
|
|
719
|
+
let o = null;
|
|
720
|
+
if (typeof n == "function") {
|
|
721
|
+
const r = t ?? this._context;
|
|
722
|
+
o = n(typeof r == "function" ? r() : r);
|
|
723
|
+
} else o = n;
|
|
724
|
+
return o;
|
|
696
725
|
}
|
|
697
|
-
description(
|
|
698
|
-
return this._resolve(this._description,
|
|
726
|
+
description(e) {
|
|
727
|
+
return this._resolve(this._description, e);
|
|
699
728
|
}
|
|
700
|
-
tags(
|
|
701
|
-
return this._resolve(this._tags,
|
|
729
|
+
tags(e) {
|
|
730
|
+
return this._resolve(this._tags, e);
|
|
702
731
|
}
|
|
703
|
-
icon(
|
|
704
|
-
return this._resolve(this._icon,
|
|
732
|
+
icon(e) {
|
|
733
|
+
return this._resolve(this._icon, e);
|
|
705
734
|
}
|
|
706
735
|
shortcut() {
|
|
707
736
|
return this._resolve(this._shortcut);
|
|
@@ -715,176 +744,176 @@ class Qt {
|
|
|
715
744
|
context() {
|
|
716
745
|
return typeof this._context == "function" ? this._context() : this._context;
|
|
717
746
|
}
|
|
718
|
-
async execute(
|
|
747
|
+
async execute(e, t) {
|
|
719
748
|
if (!this.disabled() && this._callback) {
|
|
720
749
|
try {
|
|
721
|
-
let
|
|
722
|
-
if (
|
|
723
|
-
const
|
|
724
|
-
if (await Promise.resolve(
|
|
725
|
-
|
|
726
|
-
} catch (
|
|
727
|
-
return console.warn(
|
|
750
|
+
let n = !0;
|
|
751
|
+
if (t?.beforeExecute && (n = t?.beforeExecute(this, e)), await Promise.resolve(n) === !1) return !1;
|
|
752
|
+
const o = this._callback.bind(this)(e, this);
|
|
753
|
+
if (await Promise.resolve(o) === !1) return !1;
|
|
754
|
+
t?.onExecute?.(this, e), this._notifyExecute(e);
|
|
755
|
+
} catch (n) {
|
|
756
|
+
return console.warn(n), t?.onError(this, n, e), this._notifyError(e, n), !1;
|
|
728
757
|
}
|
|
729
758
|
return !0;
|
|
730
759
|
}
|
|
731
760
|
}
|
|
732
|
-
addPropertyListener(
|
|
733
|
-
if (!
|
|
734
|
-
const
|
|
735
|
-
return
|
|
736
|
-
|
|
761
|
+
addPropertyListener(e, t = !1) {
|
|
762
|
+
if (!e) throw new Error("listener must be specified");
|
|
763
|
+
const n = this._listenersProperties;
|
|
764
|
+
return n.add(e), t && e({}, this), () => {
|
|
765
|
+
n.delete(e);
|
|
737
766
|
};
|
|
738
767
|
}
|
|
739
|
-
addExecuteListener(
|
|
740
|
-
if (!
|
|
741
|
-
const
|
|
742
|
-
return
|
|
743
|
-
|
|
768
|
+
addExecuteListener(e) {
|
|
769
|
+
if (!e) throw new Error("listener must be specified");
|
|
770
|
+
const t = this._listenersExecute;
|
|
771
|
+
return t.add(e), function() {
|
|
772
|
+
t.delete(e);
|
|
744
773
|
};
|
|
745
774
|
}
|
|
746
|
-
_notifyExecute(
|
|
747
|
-
const
|
|
748
|
-
this._listenersExecute.forEach((
|
|
749
|
-
|
|
775
|
+
_notifyExecute(e) {
|
|
776
|
+
const t = this;
|
|
777
|
+
this._listenersExecute.forEach((n) => {
|
|
778
|
+
n.onExecute(t, e);
|
|
750
779
|
});
|
|
751
780
|
}
|
|
752
|
-
_notifyError(
|
|
753
|
-
const
|
|
754
|
-
this._listenersExecute.forEach((
|
|
755
|
-
|
|
781
|
+
_notifyError(e, t) {
|
|
782
|
+
const n = this;
|
|
783
|
+
this._listenersExecute.forEach((o) => {
|
|
784
|
+
o.onError?.(n, e, t);
|
|
756
785
|
});
|
|
757
786
|
}
|
|
758
|
-
updateCallback(
|
|
759
|
-
return this._callback =
|
|
787
|
+
updateCallback(e) {
|
|
788
|
+
return this._callback = e || null, this;
|
|
760
789
|
}
|
|
761
|
-
update(
|
|
762
|
-
if (!
|
|
763
|
-
const
|
|
764
|
-
return Object.keys(
|
|
790
|
+
update(e) {
|
|
791
|
+
if (!e) return;
|
|
792
|
+
const t = this._applyProps(e);
|
|
793
|
+
return Object.keys(t).length > 0 && this._notifyPropertyChange(t), this;
|
|
765
794
|
}
|
|
766
|
-
_notifyPropertyChange(
|
|
767
|
-
const
|
|
768
|
-
this._listenersProperties.forEach((
|
|
769
|
-
|
|
795
|
+
_notifyPropertyChange(e) {
|
|
796
|
+
const t = this;
|
|
797
|
+
this._listenersProperties.forEach((n) => {
|
|
798
|
+
n(e, t);
|
|
770
799
|
});
|
|
771
800
|
}
|
|
772
|
-
_applyProps(
|
|
773
|
-
let
|
|
774
|
-
return Object.keys(
|
|
775
|
-
let r =
|
|
776
|
-
|
|
777
|
-
}),
|
|
801
|
+
_applyProps(e) {
|
|
802
|
+
let t = {}, n = this;
|
|
803
|
+
return Object.keys(e).forEach((o) => {
|
|
804
|
+
let r = e[o];
|
|
805
|
+
n["_" + o] !== r && (n["_" + o] = t[o] = r);
|
|
806
|
+
}), t;
|
|
778
807
|
}
|
|
779
808
|
}
|
|
780
|
-
class
|
|
809
|
+
class Xe extends Qe {
|
|
781
810
|
}
|
|
782
|
-
class
|
|
783
|
-
constructor(
|
|
784
|
-
this._target = null, this._groupKey = null, this._root = null, this._parent = null, this._uuid =
|
|
785
|
-
const
|
|
786
|
-
this._unListenersByCommand = /* @__PURE__ */ new Map(), this._listenersByKey = /* @__PURE__ */ new Map(), this._commandsPropertyListener = (
|
|
787
|
-
const s =
|
|
788
|
-
|
|
811
|
+
class Kt {
|
|
812
|
+
constructor(e, t) {
|
|
813
|
+
this._target = null, this._groupKey = null, this._root = null, this._parent = null, this._uuid = te.uuidV4(), this._target = e, this._groupKey = t ?? null, this._root = this, this._nodes = /* @__PURE__ */ new Map(), this._nodes.set(t, this), this._children = /* @__PURE__ */ new Map(), this._listeners = /* @__PURE__ */ new Set(), this._commandsByKey = /* @__PURE__ */ new Map(), this._commandsByShortcut = /* @__PURE__ */ new Map();
|
|
814
|
+
const n = this;
|
|
815
|
+
this._unListenersByCommand = /* @__PURE__ */ new Map(), this._listenersByKey = /* @__PURE__ */ new Map(), this._commandsPropertyListener = (o, r) => {
|
|
816
|
+
const s = n._root._listenersByKey, l = r.key(), a = s.get(l);
|
|
817
|
+
a && n._notifyCommands(a, "onCommandChange", r);
|
|
789
818
|
};
|
|
790
819
|
}
|
|
791
|
-
_getCommand(
|
|
792
|
-
return this._commandsByKey.get(
|
|
820
|
+
_getCommand(e) {
|
|
821
|
+
return this._commandsByKey.get(e) || (this._parent?._getCommand(e) ?? null);
|
|
793
822
|
}
|
|
794
|
-
getCommand(
|
|
795
|
-
const
|
|
796
|
-
let
|
|
797
|
-
for (; !r &&
|
|
798
|
-
return (r ?
|
|
823
|
+
getCommand(e, t = !1) {
|
|
824
|
+
const n = this._root._focused;
|
|
825
|
+
let o = n, r = n === this;
|
|
826
|
+
for (; !r && o; ) o === this && (r = !0), o = o._parent;
|
|
827
|
+
return (r ? n : this)._getCommand(e);
|
|
799
828
|
}
|
|
800
|
-
createChildGroup(t, n
|
|
801
|
-
let
|
|
802
|
-
if (!
|
|
803
|
-
let
|
|
804
|
-
for (;
|
|
805
|
-
let
|
|
806
|
-
|
|
829
|
+
createChildGroup(e, t, n) {
|
|
830
|
+
let o;
|
|
831
|
+
if (!n) {
|
|
832
|
+
let l = this;
|
|
833
|
+
for (; l && !o; ) {
|
|
834
|
+
let a = l._nodes.get(t);
|
|
835
|
+
a && (o = a), l = l._parent;
|
|
807
836
|
}
|
|
808
837
|
}
|
|
809
|
-
|
|
810
|
-
const r = (
|
|
811
|
-
!
|
|
838
|
+
o || (o = new Kt(e, t), o._parent = this, o._root = this._root, o._unListenersByCommand = null, o._listenersByKey = null, o._commandsPropertyListener = null);
|
|
839
|
+
const r = (l, a) => {
|
|
840
|
+
!l.has(t) || n ? l.set(t, a) : n === void 0 && console.warn("commandGroup already registered", t);
|
|
812
841
|
};
|
|
813
|
-
r(this._root._nodes,
|
|
842
|
+
r(this._root._nodes, o);
|
|
814
843
|
let s = this._parent;
|
|
815
|
-
for (; s; ) r(this._nodes,
|
|
816
|
-
return this._children.set(
|
|
844
|
+
for (; s; ) r(this._nodes, o), s = s._parent;
|
|
845
|
+
return this._children.set(t, o), this._notify("onGroupChange"), o;
|
|
817
846
|
}
|
|
818
847
|
getKey() {
|
|
819
848
|
return this._groupKey;
|
|
820
849
|
}
|
|
821
|
-
getGroup(
|
|
822
|
-
return this._nodes.get(
|
|
850
|
+
getGroup(e) {
|
|
851
|
+
return this._nodes.get(e);
|
|
823
852
|
}
|
|
824
|
-
_addCommands(
|
|
825
|
-
const
|
|
826
|
-
for (let
|
|
827
|
-
const
|
|
828
|
-
if (
|
|
829
|
-
|
|
853
|
+
_addCommands(e, t = void 0) {
|
|
854
|
+
const n = this._commandsByKey, o = this._commandsByShortcut, r = this._root._commandsPropertyListener, s = this._root._unListenersByCommand;
|
|
855
|
+
for (let l = 0; l < e.length; l++) {
|
|
856
|
+
const a = e[l], c = a.key();
|
|
857
|
+
if (n.has(c) && !t) {
|
|
858
|
+
t === void 0 && console.warn("command already registered", c);
|
|
830
859
|
continue;
|
|
831
860
|
}
|
|
832
|
-
|
|
833
|
-
let h = s.get(
|
|
834
|
-
h && (h(), s.delete(
|
|
835
|
-
const u =
|
|
836
|
-
s.set(
|
|
837
|
-
const
|
|
838
|
-
if (!
|
|
839
|
-
const w = Array.isArray(
|
|
861
|
+
n.set(c, a);
|
|
862
|
+
let h = s.get(a);
|
|
863
|
+
h && (h(), s.delete(a));
|
|
864
|
+
const u = a.addPropertyListener(r);
|
|
865
|
+
s.set(a, u);
|
|
866
|
+
const d = a.shortcut();
|
|
867
|
+
if (!d) continue;
|
|
868
|
+
const w = Array.isArray(d) ? d : [d];
|
|
840
869
|
for (let b = 0; b < w.length; b++) {
|
|
841
|
-
const
|
|
842
|
-
|
|
870
|
+
const x = Te(w[b]), S = o.get(x);
|
|
871
|
+
S && !t && t === void 0 && console.warn(`Shortcut already registered: ${x}, ${c}, ${S}.`), o.set(x, c);
|
|
843
872
|
}
|
|
844
873
|
}
|
|
845
874
|
}
|
|
846
875
|
removeFromParent() {
|
|
847
876
|
if (!this._parent) return;
|
|
848
|
-
let
|
|
849
|
-
const
|
|
850
|
-
for (;
|
|
851
|
-
|
|
852
|
-
const
|
|
877
|
+
let e = this._parent, t = [];
|
|
878
|
+
const n = this._groupKey;
|
|
879
|
+
for (; e; ) t.push(e._nodes), e._nodes.delete(n), e = e._parent;
|
|
880
|
+
e = this._parent;
|
|
881
|
+
const o = (r) => {
|
|
853
882
|
r._children.forEach((s) => {
|
|
854
|
-
for (let
|
|
855
|
-
|
|
883
|
+
for (let l = 0; l < t.length; l++) s._nodes.delete(t[l]);
|
|
884
|
+
o(s);
|
|
856
885
|
});
|
|
857
886
|
};
|
|
858
|
-
|
|
887
|
+
o(this), this._parent = null, this._notify("onGroupChange");
|
|
859
888
|
}
|
|
860
|
-
addCommands(
|
|
861
|
-
this._addCommands(
|
|
889
|
+
addCommands(e, t) {
|
|
890
|
+
this._addCommands(e, t), this._notify("onGroupChange");
|
|
862
891
|
}
|
|
863
892
|
getActive() {
|
|
864
893
|
return this._root._focused ?? this._root;
|
|
865
894
|
}
|
|
866
|
-
activate(
|
|
867
|
-
let
|
|
868
|
-
if (
|
|
869
|
-
let
|
|
870
|
-
for (;
|
|
871
|
-
this._root._focused !==
|
|
895
|
+
activate(e) {
|
|
896
|
+
let t = this;
|
|
897
|
+
if (e && (t = this._nodes.get(e), !t)) return void console.warn("group not found", e);
|
|
898
|
+
let n = this._root._focused ?? this._root;
|
|
899
|
+
for (; n; ) n = n._parent;
|
|
900
|
+
this._root._focused !== t && (this._root._focused = t, this._notify("onGroupChange"), this._notify("onActiveChange"));
|
|
872
901
|
}
|
|
873
|
-
findCommandByEvent(
|
|
874
|
-
const
|
|
875
|
-
|
|
876
|
-
let
|
|
877
|
-
const
|
|
878
|
-
let r =
|
|
879
|
-
r || (
|
|
902
|
+
findCommandByEvent(e) {
|
|
903
|
+
const t = [];
|
|
904
|
+
e.altKey && t.push(Z.Alt), e.shiftKey && t.push(Z.Shift), e.ctrlKey && t.push(Z.Ctrl), e.metaKey && t.push(Z.Meta);
|
|
905
|
+
let n = Te({ key: e.code, modifiers: t });
|
|
906
|
+
const o = this._commandsByShortcut;
|
|
907
|
+
let r = o.get(n);
|
|
908
|
+
r || (n = Te({ key: e.key, modifiers: t }), r = o.get(n)), !r && e.code.startsWith("Digit") && (n = Te({ key: e.code.substring(5, e.code.length), modifiers: t }), r = this._commandsByShortcut.get(n)), !r && e.code.startsWith("Key") && (r = Te({ key: e.code.substring(3, e.code.length), modifiers: t }), r = o.get(n));
|
|
880
909
|
let s = null;
|
|
881
|
-
return r && (s = this._commandsByKey.get(r), s && s.disabled() && (s = null), !s || s.target() && s.target().contains(
|
|
910
|
+
return r && (s = this._commandsByKey.get(r), s && s.disabled() && (s = null), !s || s.target() && s.target().contains(e.target) || (s = null)), s || (this._parent?.findCommandByEvent(e) ?? null);
|
|
882
911
|
}
|
|
883
|
-
dispatchToFocusedCommand(
|
|
884
|
-
const
|
|
885
|
-
if (!
|
|
886
|
-
const
|
|
887
|
-
return !!
|
|
912
|
+
dispatchToFocusedCommand(e) {
|
|
913
|
+
const t = this.getActive();
|
|
914
|
+
if (!t || e.isDefaultPrevented()) return !1;
|
|
915
|
+
const n = t.findCommandByEvent?.(e);
|
|
916
|
+
return !!n && (n.execute(), e.preventDefault(), !0);
|
|
888
917
|
}
|
|
889
918
|
getRoot() {
|
|
890
919
|
return this._parent ? this._parent.getRoot() : this;
|
|
@@ -892,297 +921,297 @@ class He {
|
|
|
892
921
|
getParent() {
|
|
893
922
|
return this._parent;
|
|
894
923
|
}
|
|
895
|
-
addListener(
|
|
896
|
-
const
|
|
897
|
-
if (
|
|
924
|
+
addListener(e, t) {
|
|
925
|
+
const n = this._listeners, o = t?.keys, r = this._root._listenersByKey;
|
|
926
|
+
if (o && !e.onCommandChange) throw new Error("keys were provided but the listener does not contain 'onCommandChange'.");
|
|
898
927
|
let s = null;
|
|
899
|
-
if (
|
|
900
|
-
const
|
|
901
|
-
if (!
|
|
902
|
-
let c = r.get(
|
|
903
|
-
c || (c = /* @__PURE__ */ new Set(), r.set(
|
|
928
|
+
if (o) for (let l = 0; l < o.length; l++) {
|
|
929
|
+
const a = o[l];
|
|
930
|
+
if (!a) continue;
|
|
931
|
+
let c = r.get(a);
|
|
932
|
+
c || (c = /* @__PURE__ */ new Set(), r.set(a, c)), s || (s = []), s.push(c), c.add(e);
|
|
904
933
|
}
|
|
905
|
-
return
|
|
906
|
-
if (s) for (let
|
|
907
|
-
s[
|
|
908
|
-
|
|
934
|
+
return n.add(e), () => {
|
|
935
|
+
if (s) for (let l = 0; l < s.length; l++)
|
|
936
|
+
s[l].delete(e);
|
|
937
|
+
n.delete(e);
|
|
909
938
|
};
|
|
910
939
|
}
|
|
911
|
-
_notifyCommands(t, n
|
|
912
|
-
const
|
|
940
|
+
_notifyCommands(e, t, n) {
|
|
941
|
+
const o = this;
|
|
913
942
|
setTimeout(() => {
|
|
914
|
-
|
|
915
|
-
r[
|
|
943
|
+
e.forEach((r) => {
|
|
944
|
+
r[t]?.(o, n);
|
|
916
945
|
});
|
|
917
946
|
}, 0);
|
|
918
947
|
}
|
|
919
|
-
_notify(
|
|
920
|
-
const
|
|
948
|
+
_notify(e, t) {
|
|
949
|
+
const n = this;
|
|
921
950
|
setTimeout(() => {
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
}),
|
|
951
|
+
n._listeners.forEach((o) => {
|
|
952
|
+
o[e]?.(n, t);
|
|
953
|
+
}), n._parent && n._parent._notify(e, t);
|
|
925
954
|
}, 0);
|
|
926
955
|
}
|
|
927
956
|
getAllCommands() {
|
|
928
|
-
const
|
|
929
|
-
return this._commandsByKey.forEach((
|
|
930
|
-
|
|
931
|
-
}), this._children.forEach((
|
|
932
|
-
|
|
933
|
-
}),
|
|
957
|
+
const e = [], t = this._groupKey;
|
|
958
|
+
return this._commandsByKey.forEach((n) => {
|
|
959
|
+
e.push({ command: n, groupKey: t });
|
|
960
|
+
}), this._children.forEach((n) => {
|
|
961
|
+
e.push(...n.getAllCommands());
|
|
962
|
+
}), e;
|
|
934
963
|
}
|
|
935
964
|
}
|
|
936
|
-
const
|
|
937
|
-
const
|
|
938
|
-
for (let
|
|
939
|
-
let
|
|
940
|
-
return (
|
|
965
|
+
const In = te.getOS() === te.OSType.MacOS || te.getOS() === te.OSType.IOS ? "Cmd" : "Ctrl", Nn = te.getOS() === te.OSType.MacOS || te.getOS() === te.OSType.IOS ? "⌘" : "^", Te = (i, e = !1) => {
|
|
966
|
+
const t = {};
|
|
967
|
+
for (let o = 0; i.modifiers && o < i.modifiers.length; o++) t[i.modifiers[o]] = !0;
|
|
968
|
+
let n = "";
|
|
969
|
+
return (t?.[Z.Ctrl] || t?.[Z.Meta]) && (n += (n.length > 0 ? "+" : "") + (e ? Nn : In)), t?.[Z.Alt] && (n += e ? "⌥" : "Alt"), t?.[Z.Shift] && (n += (n.length > 0 ? "+" : "") + (e ? "⇧" : "Shift")), n += (n.length > 0 ? "+" : "") + zt(i.key), n;
|
|
941
970
|
};
|
|
942
|
-
function
|
|
943
|
-
const
|
|
944
|
-
|
|
945
|
-
const [
|
|
971
|
+
function fo(i, e = null) {
|
|
972
|
+
const t = A(e);
|
|
973
|
+
t.current = e;
|
|
974
|
+
const [n, o] = on((s) => s + 1, 0), r = N(() => Array.isArray(i) ? i : [i], [i]);
|
|
946
975
|
return V(() => {
|
|
947
976
|
if (!r || r.length === 0) return;
|
|
948
977
|
const s = (c, h) => {
|
|
949
|
-
|
|
978
|
+
t.current?.onChange?.(h), o();
|
|
950
979
|
};
|
|
951
|
-
let
|
|
952
|
-
|
|
953
|
-
|
|
980
|
+
let l = null;
|
|
981
|
+
e && (l = { onExecute(c, h) {
|
|
982
|
+
t.current?.onExecute?.(c, h);
|
|
954
983
|
}, onError(c, h, u) {
|
|
955
|
-
|
|
984
|
+
t.current?.onError?.(c, h, u);
|
|
956
985
|
} });
|
|
957
|
-
const
|
|
958
|
-
for (let c = 0; c < r.length; c++)
|
|
986
|
+
const a = /* @__PURE__ */ new Set();
|
|
987
|
+
for (let c = 0; c < r.length; c++) a.add(r[c]?.addPropertyListener(te.debounce(s, 0), !0)), e && a.add(r[c]?.addExecuteListener(l));
|
|
959
988
|
return () => {
|
|
960
|
-
|
|
989
|
+
a.forEach((c) => {
|
|
961
990
|
c?.();
|
|
962
991
|
});
|
|
963
992
|
};
|
|
964
|
-
}, [
|
|
993
|
+
}, [i]), n;
|
|
965
994
|
}
|
|
966
|
-
const $
|
|
967
|
-
const
|
|
968
|
-
if (
|
|
969
|
-
const
|
|
970
|
-
|
|
995
|
+
const $e = (i, e) => {
|
|
996
|
+
const t = [];
|
|
997
|
+
if (e) for (let n = 0; n < e.length; n++) {
|
|
998
|
+
const o = e[n], r = o ? i?.getCommand(o) : null;
|
|
999
|
+
t.push(r);
|
|
971
1000
|
}
|
|
972
|
-
return
|
|
1001
|
+
return t;
|
|
973
1002
|
};
|
|
974
|
-
function
|
|
975
|
-
const
|
|
976
|
-
|
|
977
|
-
const [r, s] = Q($
|
|
1003
|
+
function go(i, e = null, t = null, n) {
|
|
1004
|
+
const o = A(t);
|
|
1005
|
+
o.current = t, e && !Array.isArray(e) && (e = [e]);
|
|
1006
|
+
const [r, s] = Q($e(i, e)), l = n ? [...n, i] : [i];
|
|
978
1007
|
return V(() => {
|
|
979
|
-
const
|
|
980
|
-
const
|
|
981
|
-
s(
|
|
1008
|
+
const a = { onGroupChange: () => {
|
|
1009
|
+
const d = $e(i, e);
|
|
1010
|
+
s(d), o.current?.onChange?.(this);
|
|
982
1011
|
} };
|
|
983
1012
|
let c;
|
|
984
|
-
|
|
985
|
-
|
|
1013
|
+
e && e.length > 0 && (c = { keys: e }, a.onCommandChange = (d, w) => {
|
|
1014
|
+
o.current?.onChange?.(i), s($e(i, e));
|
|
986
1015
|
});
|
|
987
|
-
const h =
|
|
988
|
-
return s(u),
|
|
1016
|
+
const h = i?.addListener(a, c), u = $e(i, e);
|
|
1017
|
+
return s(u), o.current?.onChange && o.current?.onChange(i), () => {
|
|
989
1018
|
h?.();
|
|
990
1019
|
};
|
|
991
|
-
},
|
|
1020
|
+
}, l), r;
|
|
992
1021
|
}
|
|
993
|
-
const
|
|
1022
|
+
const yo = { Toolbar: "toolbar", Menuitem: "menuitem" }, Wn = $t({ setClipboard: (i) => {
|
|
994
1023
|
throw new Error("This is only available via the useClipboard.");
|
|
995
|
-
}, getClipboard: () =>
|
|
996
|
-
const [
|
|
997
|
-
return { setClipboard: (
|
|
998
|
-
}),
|
|
999
|
-
const { source:
|
|
1024
|
+
}, getClipboard: () => Ke.Global, refNativeCopy: { current: null }, refNativeLastKey: { current: null } }, () => {
|
|
1025
|
+
const [i, e] = Q(Ke.Global);
|
|
1026
|
+
return { setClipboard: (t) => e(t), getClipboard: () => i, refNativeCopy: A(null), refNativeLastKey: A(null) };
|
|
1027
|
+
}), vo = (i) => {
|
|
1028
|
+
const { source: e, target: t, onPaste: n, onClipboardUpdate: o, notifier: r = At, commands: s } = i, l = T(o, [o]), a = T(n, [n]), { getClipboard: c, refNativeCopy: h } = Wn(), u = c();
|
|
1000
1029
|
N(() => {
|
|
1001
|
-
const _ =
|
|
1030
|
+
const _ = e?.element, y = t?.element ?? e?.element;
|
|
1002
1031
|
if (!s) return;
|
|
1003
|
-
const
|
|
1004
|
-
s?.addCommands(
|
|
1032
|
+
const f = [new Xe("cut", _, { label: "Cut", description: "Remove the selection and put it on the clipboard so you can paste it somewhere else.", shortcut: { key: "X", modifiers: [Z.Ctrl] } }), new Xe("copy", _, { label: "Copy", description: "Put a copy of the selection on the clipboard so you can paste it somewhere else.", shortcut: { key: "C", modifiers: [Z.Ctrl] } }), new Xe("paste", y, { label: "Paste", description: "Add content on the clipboard to your document.", shortcut: [{ key: "V", modifiers: [Z.Ctrl] }, { key: "F8", modifiers: [Z.Ctrl] }] })];
|
|
1033
|
+
s?.addCommands(f, !0);
|
|
1005
1034
|
}, [s]);
|
|
1006
|
-
const
|
|
1007
|
-
if (!
|
|
1035
|
+
const d = T(async (_) => {
|
|
1036
|
+
if (!e?.element) return;
|
|
1008
1037
|
let y = null;
|
|
1009
1038
|
try {
|
|
1010
|
-
y =
|
|
1011
|
-
} catch (
|
|
1012
|
-
throw
|
|
1039
|
+
y = e.doCopy?.(_), typeof y == "string" ? await u.writeText(y) : await u.writeReference(y);
|
|
1040
|
+
} catch (f) {
|
|
1041
|
+
throw f;
|
|
1013
1042
|
}
|
|
1014
|
-
}, [
|
|
1015
|
-
const y =
|
|
1043
|
+
}, [e, r]), w = T(async (_) => {
|
|
1044
|
+
const y = e?.element?.();
|
|
1016
1045
|
if (y) {
|
|
1017
1046
|
h.current = { sourceElement: y, args: _ };
|
|
1018
1047
|
try {
|
|
1019
|
-
await
|
|
1020
|
-
} catch (
|
|
1021
|
-
r?.showError?.(
|
|
1048
|
+
await d(_);
|
|
1049
|
+
} catch (f) {
|
|
1050
|
+
r?.showError?.(f);
|
|
1022
1051
|
}
|
|
1023
1052
|
}
|
|
1024
|
-
}, [
|
|
1053
|
+
}, [e?.element, r]), b = R(() => {
|
|
1025
1054
|
w({ isCut: !0 });
|
|
1026
|
-
}, []),
|
|
1055
|
+
}, []), x = T(async (_, y, f) => {
|
|
1027
1056
|
try {
|
|
1028
|
-
if (await _.doPaste(y,
|
|
1029
|
-
|
|
1030
|
-
} catch (
|
|
1031
|
-
r?.showError?.(
|
|
1057
|
+
if (await _.doPaste(y, f) === !1) return;
|
|
1058
|
+
a?.(y, f);
|
|
1059
|
+
} catch (k) {
|
|
1060
|
+
r?.showError?.(k);
|
|
1032
1061
|
}
|
|
1033
|
-
}, [
|
|
1034
|
-
const
|
|
1035
|
-
if (
|
|
1036
|
-
const
|
|
1062
|
+
}, [a]), S = T(async (_, y, f) => {
|
|
1063
|
+
const k = t?.element?.();
|
|
1064
|
+
if (k && await te.whenFocus(k), !_ && !y) return;
|
|
1065
|
+
const z = await r?.showBusy?.("Pasting...");
|
|
1037
1066
|
if (y) try {
|
|
1038
|
-
return await
|
|
1067
|
+
return await x(t, y, f), void z?.();
|
|
1039
1068
|
} catch (g) {
|
|
1040
|
-
|
|
1069
|
+
z?.(), r?.showError?.(g);
|
|
1041
1070
|
}
|
|
1042
|
-
let O, F =
|
|
1043
|
-
F || (F = (g,
|
|
1071
|
+
let O, F = t.importFromExternal;
|
|
1072
|
+
F || (F = (g, v) => ({ getItemType: () => "text", toText: () => _.text, isClipboardItem: !0 }));
|
|
1044
1073
|
try {
|
|
1045
1074
|
O = await F(_, { isCut: !1 });
|
|
1046
1075
|
} catch (g) {
|
|
1047
|
-
|
|
1076
|
+
z?.(), r?.showError?.(g);
|
|
1048
1077
|
}
|
|
1049
1078
|
if (O) try {
|
|
1050
1079
|
const g = await Promise.resolve(O);
|
|
1051
|
-
await
|
|
1080
|
+
await x(t, g, f), z?.();
|
|
1052
1081
|
} catch (g) {
|
|
1053
|
-
|
|
1082
|
+
z?.(), r?.showError?.(g);
|
|
1054
1083
|
}
|
|
1055
|
-
else
|
|
1056
|
-
}, [
|
|
1057
|
-
if (
|
|
1084
|
+
else z?.();
|
|
1085
|
+
}, [x, t, r]), P = T(async (_) => {
|
|
1086
|
+
if (t?.element) try {
|
|
1058
1087
|
const y = await u.readReference();
|
|
1059
|
-
if (y) return void await
|
|
1060
|
-
const
|
|
1061
|
-
|
|
1062
|
-
const
|
|
1063
|
-
await
|
|
1088
|
+
if (y) return void await S(null, y, _);
|
|
1089
|
+
const f = [];
|
|
1090
|
+
f[0] = await Ie.readStringFromClipboard(u, Ne.plain), f[1] = await Ie.readHTMLFromClipboard(u, Ne.html), f[2] = await Ie.readBlobFromClipboard(u, Ne.png);
|
|
1091
|
+
const k = { text: f[0] ?? null, html: f[1] ?? null, image: f[2] ?? null };
|
|
1092
|
+
await S(k, null, _);
|
|
1064
1093
|
} catch (y) {
|
|
1065
1094
|
if (y?.message === "Document is not focused.") return;
|
|
1066
1095
|
r?.showError?.(y);
|
|
1067
1096
|
}
|
|
1068
|
-
}, [
|
|
1097
|
+
}, [S, t?.element, r]);
|
|
1069
1098
|
return T(async (_) => {
|
|
1070
|
-
}, [
|
|
1071
|
-
}, [
|
|
1099
|
+
}, [e?.element]), T(async (_) => {
|
|
1100
|
+
}, [t?.element, S, r]), V(() => {
|
|
1072
1101
|
if (!u) return;
|
|
1073
|
-
const _ = async (
|
|
1074
|
-
const
|
|
1075
|
-
|
|
1076
|
-
}, y = (
|
|
1077
|
-
r?.showMessage?.(
|
|
1078
|
-
},
|
|
1079
|
-
r?.showMessage?.(
|
|
1102
|
+
const _ = async (k) => {
|
|
1103
|
+
const z = await u.readReference();
|
|
1104
|
+
l?.(z);
|
|
1105
|
+
}, y = (k) => {
|
|
1106
|
+
r?.showMessage?.(Ke.ErrorMessages.PermsRead, { onceKey: "clipboard.features" });
|
|
1107
|
+
}, f = (k) => {
|
|
1108
|
+
r?.showMessage?.(Ke.ErrorMessages.PermsWrite, { onceKey: "clipboard.features" });
|
|
1080
1109
|
};
|
|
1081
|
-
return u.addEventListener("clipboardchange", _), u.addEventListener("clipboarderrorread", y), u.addEventListener("clipboarderrorwrite",
|
|
1082
|
-
u.removeEventListener("clipboardchange", _), u.removeEventListener("clipboarderrorread", y), u.removeEventListener("clipboarderrorwrite",
|
|
1110
|
+
return u.addEventListener("clipboardchange", _), u.addEventListener("clipboarderrorread", y), u.addEventListener("clipboarderrorwrite", f), () => {
|
|
1111
|
+
u.removeEventListener("clipboardchange", _), u.removeEventListener("clipboarderrorread", y), u.removeEventListener("clipboarderrorwrite", f);
|
|
1083
1112
|
};
|
|
1084
1113
|
}, [u, r]), V(() => {
|
|
1085
|
-
}, [
|
|
1086
|
-
s?.getCommand("cut")?.updateCallback(b).update({ disabled: !
|
|
1087
|
-
}, [
|
|
1114
|
+
}, [d, S, e, t]), V(() => {
|
|
1115
|
+
s?.getCommand("cut")?.updateCallback(b).update({ disabled: !e || !t }), s?.getCommand("copy")?.updateCallback(w).update({ disabled: !e }), s?.getCommand("paste")?.updateCallback(P).update({ disabled: !t });
|
|
1116
|
+
}, [e, t, s]), { paste: P, copy: w, clipboard: u };
|
|
1088
1117
|
};
|
|
1089
|
-
function
|
|
1090
|
-
const
|
|
1118
|
+
function xo(i, e = !0) {
|
|
1119
|
+
const t = A(i);
|
|
1091
1120
|
V(() => {
|
|
1092
|
-
if (
|
|
1093
|
-
const
|
|
1094
|
-
Object.keys(
|
|
1121
|
+
if (e) {
|
|
1122
|
+
const n = Object.entries(i).reduce((o, [r, s]) => (t.current[r] !== s && (o[r] = [t.current[r], s]), o), {});
|
|
1123
|
+
Object.keys(n).length > 0 && console.log("Changed props:", n);
|
|
1095
1124
|
}
|
|
1096
|
-
|
|
1125
|
+
t.current = i;
|
|
1097
1126
|
});
|
|
1098
1127
|
}
|
|
1099
|
-
let
|
|
1100
|
-
var Xn = typeof document < "u" ?
|
|
1101
|
-
const
|
|
1102
|
-
const [
|
|
1128
|
+
let je = !1, Yn = 0;
|
|
1129
|
+
var Xn = typeof document < "u" ? Ve : V;
|
|
1130
|
+
const xt = () => "sheetxl-ui-" + Yn++, bt = me.useId, bo = bt ?? function() {
|
|
1131
|
+
const [i, e] = me.useState(() => je ? xt() : void 0);
|
|
1103
1132
|
return Xn(() => {
|
|
1104
|
-
|
|
1105
|
-
}, []),
|
|
1106
|
-
|
|
1107
|
-
}, []),
|
|
1108
|
-
},
|
|
1109
|
-
const
|
|
1133
|
+
i == null && e(xt());
|
|
1134
|
+
}, []), me.useEffect(() => {
|
|
1135
|
+
je || (je = !0);
|
|
1136
|
+
}, []), i;
|
|
1137
|
+
}, wt = "Undo the last action.", St = "Repeat the last action or undo the redo.", jn = (i) => `Redo ${i}`, wo = ({ manager: i, commands: e, disabled: t, notifier: n = At }) => {
|
|
1138
|
+
const o = T((s) => {
|
|
1110
1139
|
try {
|
|
1111
|
-
|
|
1112
|
-
} catch (
|
|
1113
|
-
|
|
1140
|
+
i?.undo(s);
|
|
1141
|
+
} catch (l) {
|
|
1142
|
+
n.showError?.(l);
|
|
1114
1143
|
}
|
|
1115
|
-
}, [
|
|
1144
|
+
}, [i]), r = T((s) => {
|
|
1116
1145
|
try {
|
|
1117
|
-
|
|
1118
|
-
} catch (
|
|
1119
|
-
|
|
1146
|
+
i?.redo(s);
|
|
1147
|
+
} catch (l) {
|
|
1148
|
+
n.showError?.(l);
|
|
1120
1149
|
}
|
|
1121
|
-
}, [
|
|
1150
|
+
}, [i]);
|
|
1122
1151
|
return N(() => {
|
|
1123
|
-
if (!
|
|
1124
|
-
const s = { contains: (
|
|
1125
|
-
} },
|
|
1126
|
-
|
|
1127
|
-
}, [
|
|
1128
|
-
if (!
|
|
1152
|
+
if (!e) return;
|
|
1153
|
+
const s = { contains: (a) => !0, focus() {
|
|
1154
|
+
} }, l = [new Qe("undo", s, { label: "Undo", description: wt, shortcut: { key: "z", modifiers: [Z.Ctrl] }, disabled: !0 }, o), new Qe("redo", s, { label: "Redo", description: St, shortcut: [{ key: "y", modifiers: [Z.Ctrl] }, { key: "F4" }, { key: "Enter", modifiers: [Z.Alt] }], disabled: !0 }, r)];
|
|
1155
|
+
e?.addCommands(l, !0);
|
|
1156
|
+
}, [e]), V(() => {
|
|
1157
|
+
if (!e) return;
|
|
1129
1158
|
const s = () => {
|
|
1130
|
-
const
|
|
1159
|
+
const a = i?.getTopUndoDescription(), c = {};
|
|
1131
1160
|
var h;
|
|
1132
|
-
|
|
1133
|
-
const u =
|
|
1134
|
-
|
|
1161
|
+
e.getCommand("undo").update({ disabled: t || !i || !i.hasUndo(), description: a ? (h = a, `Undo ${h}`) : wt, state: c, context: { undoManager: i } });
|
|
1162
|
+
const u = i?.getTopRedoDescription();
|
|
1163
|
+
e.getCommand("redo").update({ disabled: t || !i || !i.hasRedo(), description: u ? jn(u) : St, state: c, context: { undoManager: i } });
|
|
1135
1164
|
};
|
|
1136
|
-
if (s(), !
|
|
1137
|
-
const
|
|
1165
|
+
if (s(), !i) return;
|
|
1166
|
+
const l = i.addListener({ onStackChange() {
|
|
1138
1167
|
s();
|
|
1139
1168
|
} });
|
|
1140
|
-
return () =>
|
|
1141
|
-
}, [e, t
|
|
1169
|
+
return () => l?.();
|
|
1170
|
+
}, [i, e, t]), { undo: o, redo: r };
|
|
1142
1171
|
};
|
|
1143
1172
|
export {
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1173
|
+
Qe as Command,
|
|
1174
|
+
yo as CommandButtonType,
|
|
1175
|
+
Kt as CommandGroup,
|
|
1176
|
+
At as DefaultNotifier,
|
|
1177
|
+
lo as FocusKeyNavigation,
|
|
1178
|
+
Qn as HorizontalAlignment,
|
|
1150
1179
|
eo as KeyCodes,
|
|
1151
1180
|
Z as KeyModifiers,
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1181
|
+
to as MouseButtonCodes,
|
|
1182
|
+
yt as NotificationType,
|
|
1183
|
+
io as ReactUtils,
|
|
1184
|
+
ao as RoundedTab,
|
|
1185
|
+
En as ScrollPane,
|
|
1186
|
+
oo as ScrollUtils,
|
|
1187
|
+
et as Scrollbar,
|
|
1188
|
+
re as ScrollbarOrientation,
|
|
1189
|
+
Xe as SimpleCommand,
|
|
1190
|
+
co as SplitPane,
|
|
1191
|
+
$n as SplitPaneResizer,
|
|
1192
|
+
so as ToolTipPlacement,
|
|
1193
|
+
An as VirtualScrollbar,
|
|
1194
|
+
Cn as defaultCreateScrollCorner,
|
|
1195
|
+
no as defaultCreateScrollEdgeButton,
|
|
1196
|
+
hn as defaultCreateScrollEndButton,
|
|
1197
|
+
cn as defaultCreateScrollStartButton,
|
|
1198
|
+
gt as defaultCreateScrollbar,
|
|
1199
|
+
uo as getDevicePixelRatio,
|
|
1200
|
+
Tn as getPortalContainer,
|
|
1201
|
+
Te as toShortcutString,
|
|
1173
1202
|
T as useCallbackRef,
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1203
|
+
fo as useCommand,
|
|
1204
|
+
go as useCommands,
|
|
1205
|
+
vo as useCopyPaste,
|
|
1206
|
+
ho as useDevicePixelRatio,
|
|
1178
1207
|
mo as useEditMode,
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1208
|
+
ro as useFullscreenPortal,
|
|
1209
|
+
Wn as useGlobalClipboard,
|
|
1210
|
+
bo as useId,
|
|
1211
|
+
kt as useImperativeElement,
|
|
1212
|
+
_o as useMouseDownAndHoldListener,
|
|
1213
|
+
po as useOnClickOrFocusAway,
|
|
1214
|
+
On as useSynchronizedPointerHandler,
|
|
1215
|
+
xo as useTraceUpdate,
|
|
1216
|
+
wo as useUndoManager
|
|
1188
1217
|
};
|