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