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