@sheetxl/utils-react 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/cjs/index.cjs +2 -2
- package/browser/esm/index.mjs +120 -120
- package/node/esm/index.mjs +172 -172
- package/package.json +2 -2
- package/types/index.d.ts +2 -2
package/node/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license @sheetxl/utils-react - Utils React - Utilities for React capabilities needed for all SheetXL components. - v0.
|
|
2
|
+
* @license @sheetxl/utils-react - Utils React - Utilities for React capabilities needed for all SheetXL components. - v0.6.0
|
|
3
3
|
*
|
|
4
4
|
* (C) 2025-present SheetXL Inc. & Michael T. Ford
|
|
5
5
|
* License: The license can be found at https://www.sheetxl.com/license.
|
|
@@ -13,7 +13,7 @@ import * as b from "detect-it";
|
|
|
13
13
|
import { mergeRefs as w } from "react-merge-refs";
|
|
14
14
|
import { createRoot as S } from "react-dom/client";
|
|
15
15
|
import { unstable_batchedUpdates as L } from "react-dom";
|
|
16
|
-
const
|
|
16
|
+
const E = { General: "general", Left: "left", Right: "right", Center: "center", Justify: "justify", Fill: "fill", Distributed: "distributed", CenterContinuous: "centerContinuous" }, C = { 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 = (t2, e2) => {
|
|
17
17
|
const n2 = i((...e3) => t2?.(...e3), e2), o2 = r(null);
|
|
18
18
|
o2.current = n2;
|
|
19
19
|
const s2 = i((...t3) => o2.current?.(...t3), []);
|
|
@@ -37,7 +37,7 @@ const C = { General: "general", Left: "left", Right: "right", Center: "center",
|
|
|
37
37
|
}
|
|
38
38
|
return i2;
|
|
39
39
|
}, $ = Object.freeze(Object.defineProperty({ __proto__: null, getScrollTo: B }, Symbol.toStringTag, { value: "Module" })), K = "_sheetxl-scrollbar_eblx4_6", 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, ...
|
|
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, ...E2 } = n2, C2 = 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", F2 = W2 ? "scrollTop" : "scrollLeft", R2 = W2 ? $2 : A2, I2 = W2 ? H2 : V2, [Y2, X2] = a(null);
|
|
41
41
|
c(() => {
|
|
42
42
|
null !== Y2 && T2.current && T2.current.scrollTo({ behavior: "smooth", [N2]: Y2 });
|
|
43
43
|
}, [Y2, W2]);
|
|
@@ -47,17 +47,17 @@ const C = { General: "general", Left: "left", Right: "right", Center: "center",
|
|
|
47
47
|
return X2(r2), Math.max(0, r2);
|
|
48
48
|
}, []), U2 = i((t2, e2 = false) => {
|
|
49
49
|
if (!T2.current) return 0;
|
|
50
|
-
const n3 = T2.current.querySelector(".scrollbar-viewport"), o3 = n3.getBoundingClientRect(), i2 = n3.children, r2 = Math.ceil(I2 -
|
|
50
|
+
const n3 = T2.current.querySelector(".scrollbar-viewport"), o3 = n3.getBoundingClientRect(), i2 = n3.children, r2 = Math.ceil(I2 - R2), s3 = e2 ? r2 : B(t2, o3[N2], i2, false, Math.max(0, t2 + x2));
|
|
51
51
|
return X2(s3), Math.min(r2, s3);
|
|
52
|
-
}, [I2,
|
|
52
|
+
}, [I2, R2]), Z2 = r(null), G2 = i((t2) => {
|
|
53
53
|
Z2.current = s2;
|
|
54
|
-
const e2 = t2.target[
|
|
55
|
-
g2(e2, u2, l2),
|
|
54
|
+
const e2 = t2.target[F2];
|
|
55
|
+
g2(e2, u2, l2), C2?.(t2);
|
|
56
56
|
}, [g2, u2, l2, s2]);
|
|
57
57
|
c(() => {
|
|
58
58
|
const t2 = Z2.current;
|
|
59
|
-
Z2.current = null, s2 !== t2 && (T2.current[
|
|
60
|
-
}, [s2,
|
|
59
|
+
Z2.current = null, s2 !== t2 && (T2.current[F2] = s2);
|
|
60
|
+
}, [s2, F2]);
|
|
61
61
|
const q2 = r(null), J2 = r(null), Q2 = i(() => {
|
|
62
62
|
q2.current && (clearTimeout(q2.current), q2.current = null, J2.current = null);
|
|
63
63
|
}, []), tt2 = i((t2, e2, n3, o3 = b2) => {
|
|
@@ -69,21 +69,21 @@ const C = { General: "general", Left: "left", Right: "right", Center: "center",
|
|
|
69
69
|
c(() => () => Q2(), [Q2]);
|
|
70
70
|
const et2 = s2, nt2 = h(() => {
|
|
71
71
|
if (!v2) return null;
|
|
72
|
-
const t2 = { orientation: p2, disabled: Math.floor(et2) <= 0 || 0 === Math.floor(I2 -
|
|
72
|
+
const t2 = { orientation: p2, disabled: Math.floor(et2) <= 0 || 0 === Math.floor(I2 - R2), onMouseUp: Q2, onMouseLeave: Q2, onMouseDown: () => tt2(et2, true, true) };
|
|
73
73
|
return S2?.(t2);
|
|
74
|
-
}, [v2, p2, et2, Y2, I2,
|
|
74
|
+
}, [v2, p2, et2, Y2, I2, R2]), ot2 = h(() => {
|
|
75
75
|
if (!v2) return null;
|
|
76
|
-
const t2 = { orientation: p2, disabled: Math.floor(I2 -
|
|
76
|
+
const t2 = { orientation: p2, disabled: Math.floor(I2 - R2) <= Math.ceil(et2), onMouseUp: Q2, onMouseLeave: Q2, onMouseDown: () => tt2(et2, true, false) };
|
|
77
77
|
return L2?.(t2);
|
|
78
|
-
}, [v2, p2, et2, Y2, I2,
|
|
79
|
-
return e("div", { ref: o2, style: { display: "flex", flex: "1", flexDirection: W2 ? "column" : "row", padding: "0", ...d2 }, className: m(K, _2), ...
|
|
78
|
+
}, [v2, p2, et2, Y2, I2, R2]);
|
|
79
|
+
return e("div", { ref: o2, style: { display: "flex", flex: "1", flexDirection: W2 ? "column" : "row", padding: "0", ...d2 }, className: m(K, _2), ...E2, children: [nt2, t("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: t("div", { tabIndex: -1, style: { flex: "1 1 100%", overflowY: W2 ? "scroll" : "hidden", overflowX: W2 ? "hidden" : "scroll", position: "relative", willChange: "transform" }, onScroll: G2, ref: T2, children: t("div", { ref: O2, style: { position: "absolute", height: W2 ? l2 - u2 + ($2 ?? 0) : 1, width: W2 ? 1 : l2 - u2 + (A2 ?? 0) }, className: "scrollbar-viewport" }) }) }), ot2] });
|
|
80
80
|
}));
|
|
81
81
|
O.displayName = "Scrollbar";
|
|
82
82
|
let V = Date.now, H = 1e3, W = {}, N = 1;
|
|
83
|
-
const
|
|
83
|
+
const F = (t2) => {
|
|
84
84
|
let e2 = null !== W[t2];
|
|
85
85
|
return e2 && (W[t2] = null), e2;
|
|
86
|
-
},
|
|
86
|
+
}, R = (t2, e2, n2, o2 = 0, i2) => {
|
|
87
87
|
let r2 = V(), s2 = r2, l2 = 0, a2 = 0, c2 = 0, h2 = N++;
|
|
88
88
|
if (h2 % 20 == 0) {
|
|
89
89
|
const t3 = {};
|
|
@@ -142,7 +142,7 @@ class X {
|
|
|
142
142
|
}
|
|
143
143
|
zoomTo(t2, e2 = false, n2, o2, i2) {
|
|
144
144
|
if (!this.options.zooming) throw new Error("Zooming is not enabled!");
|
|
145
|
-
i2 && (this.__zoomComplete = i2), this.__isDecelerating && (
|
|
145
|
+
i2 && (this.__zoomComplete = i2), this.__isDecelerating && (F(this.__isDecelerating), this.__isDecelerating = 0);
|
|
146
146
|
const r2 = this.__zoomLevel;
|
|
147
147
|
void 0 === n2 && (n2 = this.__clientWidth / 2), void 0 === o2 && (o2 = this.__clientHeight / 2), t2 = Math.max(Math.min(t2, this.options.maxZoom), this.options.minZoom), this.__computeScrollMax(t2);
|
|
148
148
|
const s2 = t2 / r2;
|
|
@@ -153,7 +153,7 @@ class X {
|
|
|
153
153
|
this.zoomTo(this.__zoomLevel * t2, e2, n2, o2, i2);
|
|
154
154
|
}
|
|
155
155
|
scrollTo(t2, e2, n2 = false, o2 = 1) {
|
|
156
|
-
if (this.__isDecelerating && (
|
|
156
|
+
if (this.__isDecelerating && (F(this.__isDecelerating), this.__isDecelerating = 0), void 0 !== o2 && o2 !== this.__zoomLevel) {
|
|
157
157
|
if (!this.options.zooming) throw new Error("Zooming is not enabled!");
|
|
158
158
|
t2 *= o2, e2 *= o2, this.__computeScrollMax(o2);
|
|
159
159
|
} else o2 = this.__zoomLevel;
|
|
@@ -171,7 +171,7 @@ class X {
|
|
|
171
171
|
if (void 0 === t2.length) throw new Error("Invalid touch list: " + t2);
|
|
172
172
|
if (e2 instanceof Date && (e2 = e2.valueOf()), "number" != typeof e2) throw new Error("Invalid timestamp value: " + e2);
|
|
173
173
|
let n2, o2;
|
|
174
|
-
this.__interruptedAnimation = true, this.__isDecelerating && (
|
|
174
|
+
this.__interruptedAnimation = true, this.__isDecelerating && (F(this.__isDecelerating), this.__isDecelerating = 0, this.__interruptedAnimation = true), this.__isAnimating && (F(this.__isAnimating), this.__isAnimating = 0, this.__interruptedAnimation = true);
|
|
175
175
|
let i2 = 1 === t2.length;
|
|
176
176
|
i2 ? (n2 = t2[0].pageX, o2 = t2[0].pageY) : (n2 = Math.abs(t2[0].pageX + t2[1].pageX) / 2, o2 = Math.abs(t2[0].pageY + t2[1].pageY) / 2), this.__initialTouchLeft = n2, this.__initialTouchTop = o2, this.__zoomLevelStart = this.__zoomLevel, this.__lastTouchLeft = n2, this.__lastTouchTop = o2, this.__lastTouchMove = e2, 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 = [];
|
|
177
177
|
}
|
|
@@ -226,7 +226,7 @@ class X {
|
|
|
226
226
|
}
|
|
227
227
|
__publish(t2, e2, n2, o2 = false) {
|
|
228
228
|
const i2 = this.__isAnimating;
|
|
229
|
-
if (i2 && (
|
|
229
|
+
if (i2 && (F(i2), this.__isAnimating = 0), o2 && this.options.animating) {
|
|
230
230
|
this.__scheduledLeft = t2, this.__scheduledTop = e2, this.__scheduledZoom = n2;
|
|
231
231
|
const o3 = this.__scrollLeft, r2 = this.__scrollTop, s2 = this.__zoomLevel, l2 = t2 - o3, a2 = e2 - r2, c2 = n2 - s2, h2 = function(t3, e3, n3) {
|
|
232
232
|
n3 && (this.__scrollLeft = o3 + l2 * t3, this.__scrollTop = r2 + a2 * t3, this.__zoomLevel = s2 + c2 * t3, this.__callback && this.__callback(this.__scrollLeft, this.__scrollTop, this.__zoomLevel));
|
|
@@ -235,7 +235,7 @@ class X {
|
|
|
235
235
|
}.bind(this), d2 = function(t3, e3, n3) {
|
|
236
236
|
e3 === this.__isAnimating && (this.__isAnimating = false), (this.__didDecelerationComplete || n3) && this.options.scrollingComplete?.(), this.options.zooming && (this.__computeScrollMax(), this.__zoomComplete && (this.__zoomComplete(), this.__zoomComplete = null));
|
|
237
237
|
}.bind(this);
|
|
238
|
-
this.__isAnimating =
|
|
238
|
+
this.__isAnimating = R(h2, u2, d2, this.options.animationDuration, i2 ? I : Y);
|
|
239
239
|
} else this.__scheduledLeft = this.__scrollLeft = t2, this.__scheduledTop = this.__scrollTop = e2, this.__scheduledZoom = this.__zoomLevel = n2, this.__callback && this.__callback(t2, e2, n2), this.options.zooming && (this.__computeScrollMax(), this.__zoomComplete && (this.__zoomComplete(), this.__zoomComplete = null));
|
|
240
240
|
}
|
|
241
241
|
__computeScrollMax(t2 = this.__zoomLevel) {
|
|
@@ -254,7 +254,7 @@ class X {
|
|
|
254
254
|
}.bind(this), i2 = function(t3, e3, n3) {
|
|
255
255
|
this.__isDecelerating = 0, this.__didDecelerationComplete && this.options.scrollingComplete?.(), this.scrollTo(this.__scrollLeft, this.__scrollTop, this.options.snapping);
|
|
256
256
|
}.bind(this);
|
|
257
|
-
this.__isDecelerating =
|
|
257
|
+
this.__isDecelerating = R(e2, o2, i2);
|
|
258
258
|
}
|
|
259
259
|
__stepThroughDeceleration(t2) {
|
|
260
260
|
let e2 = this.__scrollLeft + this.__decelerationVelocityX, n2 = this.__scrollTop + this.__decelerationVelocityY;
|
|
@@ -308,9 +308,9 @@ const tt = (e2) => t(O, { ...e2 }), et = ({ width: e2, height: n2 }) => t("div",
|
|
|
308
308
|
c(() => {
|
|
309
309
|
L2.current && (L2.current.__scrollTop === a2?.top && L2.current.__scrollLeft === a2?.left || L2.current.__isDecelerating || L2.current?.scrollTo(a2?.left, a2?.top, false));
|
|
310
310
|
}, [a2?.left, a2?.top, v2]);
|
|
311
|
-
const
|
|
311
|
+
const E2 = i((t2, e2) => {
|
|
312
312
|
w2?.({ left: t2, top: e2 });
|
|
313
|
-
}, []),
|
|
313
|
+
}, []), C2 = i((t2) => {
|
|
314
314
|
L2.current?.doTouchStart(t2.touches, t2.timeStamp);
|
|
315
315
|
}, []), T2 = i((t2) => {
|
|
316
316
|
t2.preventDefault(), L2.current?.doTouchMove(t2.touches, t2.timeStamp);
|
|
@@ -324,12 +324,12 @@ const tt = (e2) => t(O, { ...e2 }), et = ({ width: e2, height: n2 }) => t("div",
|
|
|
324
324
|
if (!x2 && Z().supportsTouchEvents && t2 && a2) {
|
|
325
325
|
if (!L2.current) {
|
|
326
326
|
const t3 = { scrollingX: true, scrollingY: true, decelerationRate: 0.95, penetrationAcceleration: 0.08 };
|
|
327
|
-
L2.current = new X(
|
|
327
|
+
L2.current = new X(E2, t3);
|
|
328
328
|
}
|
|
329
|
-
Z().supportsTouchEvents && (t2.addEventListener("touchstart",
|
|
329
|
+
Z().supportsTouchEvents && (t2.addEventListener("touchstart", C2), t2.addEventListener("touchend", M2), t2.addEventListener("touchmove", T2)), z2({ containerWidth: a2?.width, containerHeight: a2?.height, totalWidth: a2?.totalWidth, totalHeight: a2?.totalHeight });
|
|
330
330
|
}
|
|
331
331
|
return () => {
|
|
332
|
-
t2?.removeEventListener("touchstart",
|
|
332
|
+
t2?.removeEventListener("touchstart", C2), t2?.removeEventListener("touchend", M2), t2?.removeEventListener("touchmove", T2);
|
|
333
333
|
};
|
|
334
334
|
}, [a2?.width, a2?.height, a2?.totalWidth, a2?.totalHeight, x2, v2]);
|
|
335
335
|
const [k2, { width: A2 }] = f(), [B2, { height: $2 }] = f(), K2 = h(() => {
|
|
@@ -356,30 +356,31 @@ const ot = { Default: "default", Error: "error", Success: "success", Warning: "w
|
|
|
356
356
|
});
|
|
357
357
|
}), showError: (t2) => {
|
|
358
358
|
console.error(t2);
|
|
359
|
-
} }
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
359
|
+
} };
|
|
360
|
+
let st = 0;
|
|
361
|
+
function lt() {
|
|
362
|
+
const [t2, e2] = a(!!document.fullscreenElement), n2 = i(() => {
|
|
363
|
+
const t3 = document.fullscreenElement;
|
|
364
|
+
return t3 ? t3.querySelector(".fullscreen-portal-root") || t3 : document.body;
|
|
365
|
+
}, []);
|
|
365
366
|
return c(() => {
|
|
366
|
-
function
|
|
367
|
-
const
|
|
368
|
-
if (!
|
|
369
|
-
let
|
|
370
|
-
|
|
367
|
+
function t3() {
|
|
368
|
+
const t4 = document.fullscreenElement;
|
|
369
|
+
if (e2(!!t4), !t4) return;
|
|
370
|
+
let n3 = t4.querySelector(".fullscreen-portal-root");
|
|
371
|
+
n3 || (n3 = document.createElement("div"), n3.className = "fullscreen-portal-root _fullscreen-portal-root_1mjsr_4", t4.appendChild(n3));
|
|
371
372
|
}
|
|
372
|
-
return
|
|
373
|
-
document.removeEventListener("fullscreenchange",
|
|
374
|
-
|
|
375
|
-
}),
|
|
373
|
+
return st++, t3(), document.addEventListener("fullscreenchange", t3), () => {
|
|
374
|
+
document.removeEventListener("fullscreenchange", t3), st--, st <= 0 && (document.querySelectorAll(".fullscreen-portal-root").forEach((t4) => {
|
|
375
|
+
t4.parentNode && t4.parentNode.removeChild(t4);
|
|
376
|
+
}), st = 0);
|
|
376
377
|
};
|
|
377
|
-
}, []), { getPortalContainer:
|
|
378
|
+
}, []), { getPortalContainer: n2, isFullscreen: t2 };
|
|
378
379
|
}
|
|
379
|
-
const
|
|
380
|
-
const { offset: o2 = 0, viewportSize: s2 = 0, totalSize: l2 = 0, minSize: c2 = 0, endGap: h2 =
|
|
380
|
+
const at = 100, ct = 100, ht = 1e6, ut = 100, dt = 50, _t = s(l((e2, n2) => {
|
|
381
|
+
const { offset: o2 = 0, viewportSize: s2 = 0, totalSize: l2 = 0, minSize: c2 = 0, endGap: h2 = at, endScrollIncrement: u2 = ct, style: _2 = U, onMouseDown: p2, onScrollOffset: m2, onScroll: f2, scaleLimit: g2 = ht, scaleFactor: y2 = ut, precisionFactor: v2 = dt, ...x2 } = e2;
|
|
381
382
|
f2 && console.warn("onScroll not supported for VirtualScrollbar. Use onScrollOffset instead");
|
|
382
|
-
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),
|
|
383
|
+
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), E2 = 0 !== g2 && S2.totalSize > g2 ? y2 : 1, C2 = E2 / v2, T2 = Math.ceil(S2.totalSize / E2), M2 = Math.ceil(S2.offset / E2), D2 = Math.ceil(s2 / E2), z2 = i((t2) => {
|
|
383
384
|
}, []), [k2, A2] = a(false), B2 = r(null);
|
|
384
385
|
d(() => {
|
|
385
386
|
if (!k2) {
|
|
@@ -390,16 +391,16 @@ const ct = 100, ht = 100, ut = 1e6, dt = 100, _t = 50, pt = s(l((e2, n2) => {
|
|
|
390
391
|
}, [l2, s2, o2, k2, c2, h2, u2]);
|
|
391
392
|
const $2 = P((t2, e3, n3) => {
|
|
392
393
|
const i2 = B2.current;
|
|
393
|
-
B2.current = null, i2 && i2.propTotalSize === l2 && i2.propViewportSize === s2 && i2.propOffset === o2 || (Math.abs(t2 - M2) <
|
|
394
|
-
}, [m2,
|
|
394
|
+
B2.current = null, i2 && i2.propTotalSize === l2 && i2.propViewportSize === s2 && i2.propOffset === o2 || (Math.abs(t2 - M2) < C2 && (t2 = M2), m2?.(t2 * E2, M2, D2));
|
|
395
|
+
}, [m2, E2, C2, M2, D2]), K2 = i((t2) => {
|
|
395
396
|
document.removeEventListener("mousemove", z2), document.removeEventListener("mouseup", K2), A2(false);
|
|
396
397
|
}, []), V2 = i((t2) => {
|
|
397
398
|
b2?.(t2), A2(true), document.addEventListener("mousemove", z2, { passive: true }), document.addEventListener("mouseup", K2, { passive: true });
|
|
398
399
|
}, [z2, K2]);
|
|
399
400
|
return t(O, { ref: n2, style: { ..._2 }, ...x2, offset: M2, totalSize: T2, viewportSize: D2, onMouseDown: V2, onScrollOffset: $2 });
|
|
400
401
|
}));
|
|
401
|
-
|
|
402
|
-
const
|
|
402
|
+
_t.displayName = "VirtualScrollbar";
|
|
403
|
+
const pt = { 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" }, mt = s(l((e2, n2) => {
|
|
403
404
|
const { refFocusStart: o2, ...s2 } = e2, l2 = r(null), a2 = i(() => {
|
|
404
405
|
if (o2) return void o2?.current?.focus();
|
|
405
406
|
const t2 = l2.current.parentElement.children;
|
|
@@ -417,7 +418,7 @@ const mt = { BottomEnd: "bottom-end", BottomStart: "bottom-start", Bottom: "bott
|
|
|
417
418
|
}, [o2]);
|
|
418
419
|
return t("div", { tabIndex: 0, ref: w([l2, n2]), onFocus: a2, ...s2 });
|
|
419
420
|
}));
|
|
420
|
-
const
|
|
421
|
+
const ft = s(l((i2, s2) => {
|
|
421
422
|
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 = (t2, e2 = 0) => {
|
|
422
423
|
const n2 = t2 / 2, o2 = y2 - n2 + e2;
|
|
423
424
|
return function(t3, e3, n3 = false) {
|
|
@@ -468,56 +469,56 @@ const gt = s(l((i2, s2) => {
|
|
|
468
469
|
return x2(u2) + `L ${g2} 0 L 0 0 L 0 ${t2}`;
|
|
469
470
|
}, [b2, u2, d2]), L2 = h(() => ({ style: { clipPath: `path('${S2}')` } }), [S2]);
|
|
470
471
|
return e("div", { className: l2, style: { display: "flex", flexDirection: "row", ...a2 }, ...p2, ref: w([v2, m2, s2]), children: [o.isValidElement(c2) ? o.cloneElement(c2, L2) : t(n, {}), t("svg", { style: { position: "absolute", top: 0, left: 0, pointerEvents: "none" }, width: g2, height: y2, viewBox: `0 0 ${g2} ${y2}`, children: t("path", { d: b2, stroke: _2, fill: "none", vectorEffect: "non-scaling-stroke", strokeWidth: d2 }) })] });
|
|
471
|
-
})),
|
|
472
|
-
const { onPointerDown: n2, style: o2, splitDirection: i2, paddingBefore: r2 = 0, paddingAfter: s2 = 0, disabled: l2, key: a2, hitAreaProps: c2 =
|
|
472
|
+
})), gt = {}, yt = (e2) => {
|
|
473
|
+
const { onPointerDown: n2, style: o2, splitDirection: i2, paddingBefore: r2 = 0, paddingAfter: s2 = 0, disabled: l2, key: a2, hitAreaProps: c2 = gt, ...h2 } = e2, u2 = "row" === i2, { style: d2, className: _2, ...p2 } = c2;
|
|
473
474
|
return t("div", { style: { ...o2, position: "relative" }, ...h2, children: t("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);
|
|
474
|
-
},
|
|
475
|
+
}, vt = {}, xt = (t2, e2, n2 = true) => null === t2 ? null : null !== t2.pixels ? n2 ? t2.pixels : e2 - t2.pixels : (n2 ? t2.percent : 100 - t2.percent) / 100 * e2, bt = (t2, e2 = true) => t2?.percent ? `${e2 ? t2.percent : 100 - t2.percent}%` : t2?.pixels ? `${t2.pixels}px` : void 0, wt = (t2, e2) => {
|
|
475
476
|
if (null == t2) return null;
|
|
476
477
|
const n2 = { percent: null, pixels: null };
|
|
477
478
|
let o2 = e2;
|
|
478
479
|
return "string" == typeof t2 && ((t2 = t2.trim().toLowerCase()).endsWith("px") ? (t2 = t2.substring(0, t2.length - 2), o2 = false) : t2.endsWith("%") && (t2 = t2.substring(0, t2.length - 1), o2 = true), t2 = parseFloat(t2)), o2 ? n2.percent = t2 : n2.pixels = t2, Object.freeze(n2);
|
|
479
|
-
},
|
|
480
|
-
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:
|
|
480
|
+
}, St = s(l((n2, i2) => {
|
|
481
|
+
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: E2 = false, onDragStart: C2, onDragResize: T2, onDragFinish: M2, resizerProps: D2 = vt, paneProps: z2 = vt, paneBeforeProps: k2 = vt, paneAfterProps: A2 = vt, createResizer: B2 = yt } = n2;
|
|
481
482
|
if (b2) throw new Error("Use elementBefore and elementAfter instead of children.");
|
|
482
483
|
const $2 = h(() => o.isValidElement(l2) && o.isValidElement(s2), [l2, s2]), K2 = h(() => {
|
|
483
484
|
let t2 = null;
|
|
484
485
|
d2 && ("before" === d2 ? t2 = 0 : "after" === d2 && (t2 = 1));
|
|
485
486
|
const e2 = null === t2;
|
|
486
|
-
return { fixedPaneOffset: t2, isPercent: e2, minBefore:
|
|
487
|
-
}, [g2, y2, v2, x2]), O2 = P(p2, [p2]), [V2, H2] = a(() =>
|
|
487
|
+
return { fixedPaneOffset: t2, isPercent: e2, minBefore: wt(g2, e2), maxBefore: wt(y2, e2), minAfter: wt(v2, e2), maxAfter: wt(x2, e2) };
|
|
488
|
+
}, [g2, y2, v2, x2]), O2 = P(p2, [p2]), [V2, H2] = a(() => wt(_2, null === d2));
|
|
488
489
|
c(() => {
|
|
489
|
-
H2(
|
|
490
|
+
H2(wt(_2, null === d2));
|
|
490
491
|
}, [_2, d2]);
|
|
491
|
-
const [W2, { width: N2, height:
|
|
492
|
+
const [W2, { width: N2, height: F2 }] = f(), [R2, { width: I2, height: Y2 }] = f(), X2 = "row" === u2 ? I2 : Y2, j2 = "row" === u2 ? N2 : F2, U2 = h(() => ((t2, e2, n3, o2) => {
|
|
492
493
|
const i3 = [null, null], r2 = [null, null];
|
|
493
|
-
if (t2 || (t2 = { percent: null === o2.fixedPaneOffset ? 50 : null, pixels: null === o2.fixedPaneOffset ? null : 0 }), 0 === e2) return null != t2?.pixels ? 1 !== o2.fixedPaneOffset ? (i3[0] = t2?.pixels, r2[1] = 100) : (i3[1] = t2?.pixels - n3, r2[0] = 100) : null != t2?.percent && (1 !== o2.fixedPaneOffset ? (r2[0] = t2?.percent, r2[1] = 100 - t2?.percent) : (r2[1] = t2?.percent, r2[0] = 100 - t2?.percent)), { percents: r2, pixels: i3, minBefore:
|
|
494
|
-
let s3 =
|
|
495
|
-
h2 = (
|
|
494
|
+
if (t2 || (t2 = { percent: null === o2.fixedPaneOffset ? 50 : null, pixels: null === o2.fixedPaneOffset ? null : 0 }), 0 === e2) return null != t2?.pixels ? 1 !== o2.fixedPaneOffset ? (i3[0] = t2?.pixels, r2[1] = 100) : (i3[1] = t2?.pixels - n3, r2[0] = 100) : null != t2?.percent && (1 !== o2.fixedPaneOffset ? (r2[0] = t2?.percent, r2[1] = 100 - t2?.percent) : (r2[1] = t2?.percent, r2[0] = 100 - t2?.percent)), { percents: r2, pixels: i3, minBefore: bt(o2.minBefore, true), maxBefore: bt(o2.maxBefore, true), minAfter: bt(o2.minAfter), maxAfter: bt(o2.maxAfter) };
|
|
495
|
+
let s3 = xt(t2, e2, 1 !== o2.fixedPaneOffset), l3 = e2 - n3, a2 = xt(o2.minBefore, l3, true) ?? 0, c2 = xt(o2.maxBefore, l3, true) ?? l3, h2 = 0, u3 = 0, d3 = 0, _3 = l3;
|
|
496
|
+
h2 = (xt(o2.maxAfter, e2, false) ?? n3) - n3, u3 = xt(o2.minAfter, e2, false) ?? e2, d3 = Math.max(a2, h2), _3 = Math.min(c2, u3), s3 = Math.max(d3, Math.min(s3, _3)), u3 = Math.min(l3 - s3, xt(o2.maxAfter, l3 - s3, true) ?? l3), h2 = Math.min(l3 - s3, xt(o2.minAfter, l3 - s3, true) ?? l3), i3[0] = s3, i3[1] = l3 - i3[0];
|
|
496
497
|
const p3 = Math.max(0, Math.min(100, s3 / l3 * 100));
|
|
497
498
|
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` };
|
|
498
|
-
})(V2, j2, X2, K2), [K2, V2, j2, X2, u2]), [Z2, G2] = a(false), q2 = P(
|
|
499
|
-
const e2 =
|
|
499
|
+
})(V2, j2, X2, K2), [K2, V2, j2, X2, u2]), [Z2, G2] = a(false), q2 = P(C2, [C2]), J2 = P(T2, [T2]), tt2 = P(M2, [M2]), et2 = r(null), nt2 = r(null), ot2 = r(null), { style: it2, className: rt2, ...st2 } = z2, lt2 = { minWidth: 0, minHeight: 0, maxWidth: "100%", maxHeight: "100%", display: "flex", overflow: "hidden", ...it2 }, { className: at2, style: ct2, ...ht2 } = k2, { className: ut2, style: dt2, ..._t2 } = A2, pt2 = { flex: "1 1 100%", width: "100%", ...L2, flexDirection: u2, display: "flex" }, { className: mt2, style: ft2, onPointerDown: gt2, ...St2 } = D2, Lt2 = P((t2) => {
|
|
500
|
+
const e2 = wt(t2, null === d2);
|
|
500
501
|
H2(e2);
|
|
501
|
-
}, [d2]),
|
|
502
|
-
if (
|
|
502
|
+
}, [d2]), Et2 = P((t2) => {
|
|
503
|
+
if (E2 || !Z2) return;
|
|
503
504
|
const e2 = Mt2.current?.getBoundingClientRect();
|
|
504
505
|
let n3 = 0;
|
|
505
506
|
n3 = "row" === u2 ? (t2.clientX ?? t2.touches?.[0]?.clientX) - e2.x : (t2.clientY ?? t2.touches?.[0]?.clientY) - e2.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), t2.stopPropagation(), t2.preventDefault();
|
|
506
|
-
}, [K2, u2,
|
|
507
|
-
if (document.removeEventListener("pointermove",
|
|
507
|
+
}, [K2, u2, E2, Z2, V2, j2]), Ct2 = P((t2) => {
|
|
508
|
+
if (document.removeEventListener("pointermove", Et2), document.removeEventListener("touchmove", Et2), document.removeEventListener("pointerup", Ct2), !Z2) return;
|
|
508
509
|
if (G2(false), !V2) return;
|
|
509
510
|
tt2(V2.pixels);
|
|
510
|
-
if (!
|
|
511
|
+
if (!wt(_2, null === d2) || V2.pixels !== _2) {
|
|
511
512
|
const t3 = { ...V2 };
|
|
512
513
|
null === t3.percent && (t3.percent = t3.pixels / j2 * 100), O2(t3);
|
|
513
514
|
}
|
|
514
515
|
t2.stopPropagation(), t2.preventDefault();
|
|
515
516
|
}, [V2, Z2, _2, d2, j2]), Tt2 = P((t2) => {
|
|
516
|
-
gt2?.(t2), t2.defaultPrevented ||
|
|
517
|
-
}, [gt2]), Mt2 = Q(i2, () => ({ setPosition: Lt2, isSplitPane: () => true }), []), Dt2 = h(() => $2 ? B2?.({ key: "resizer", ref: w([
|
|
517
|
+
gt2?.(t2), t2.defaultPrevented || E2 || Z2 || (G2(true), q2(), document.addEventListener("pointermove", Et2, { passive: false }), document.addEventListener("touchmove", Et2, { passive: false }), document.addEventListener("pointerup", Ct2, { passive: false }));
|
|
518
|
+
}, [gt2]), Mt2 = Q(i2, () => ({ setPosition: Lt2, isSplitPane: () => true }), []), Dt2 = h(() => $2 ? B2?.({ key: "resizer", ref: w([R2, nt2]), className: m("resizer", mt2), onPointerDownCapture: Tt2, style: { cursor: E2 ? 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, ...ft2 }, splitDirection: u2, disabled: E2, ...St2 }) : null, [$2, mt2, St2, u2, ft2, E2]), Pt2 = "row" === u2 ? "Width" : "Height", zt2 = { ...lt2, ...ct2, 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${Pt2}`]: U2?.minBefore, [`max${Pt2}`]: l2 ? U2?.maxBefore : "100%" }, kt2 = { ...lt2, ...dt2, 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${Pt2}`]: U2?.minAfter, [`max${Pt2}`]: s2 ? U2?.maxAfter : "100%" }, At2 = h(() => s2 ? t("div", { ref: et2, className: m("before", rt2, at2), style: zt2, ...st2, ...ht2, children: s2 }, "before") : null, [s2, z2, k2, K2, U2]), Bt2 = h(() => l2 ? t("div", { ref: ot2, className: m("after", rt2, ut2), style: kt2, ...st2, ..._t2, children: l2 }, "after") : null, [l2, z2, A2, K2, U2]);
|
|
518
519
|
return e("div", { ref: w([W2, Mt2]), className: m("splitPane", "row" === u2 ? "vertical" : "horizontal", { dragging: Z2 }, S2), style: pt2, children: [At2, Dt2, Bt2] });
|
|
519
520
|
}));
|
|
520
|
-
function
|
|
521
|
+
function Lt(t2) {
|
|
521
522
|
const [e2, n2] = a("undefined" != typeof window ? window.devicePixelRatio : 1), o2 = r(null);
|
|
522
523
|
return c(() => {
|
|
523
524
|
if (!("undefined" != typeof window && "matchMedia" in window)) return;
|
|
@@ -535,7 +536,7 @@ function Et(t2) {
|
|
|
535
536
|
const { defaultDpr: e2 = 1, maxDpr: n2 = 3, round: o2 = true } = t2 || {}, i2 = "undefined" != typeof window && "number" == typeof window.devicePixelRatio ? window.devicePixelRatio : e2;
|
|
536
537
|
return Math.min(Math.max(1, o2 ? Math.floor(i2) : i2), n2);
|
|
537
538
|
}
|
|
538
|
-
function
|
|
539
|
+
function Ct(t2, e2, n2) {
|
|
539
540
|
const o2 = P(e2, [e2]);
|
|
540
541
|
c(() => {
|
|
541
542
|
const e3 = (e4) => {
|
|
@@ -546,7 +547,7 @@ function Tt(t2, e2, n2) {
|
|
|
546
547
|
};
|
|
547
548
|
}, [t2]);
|
|
548
549
|
}
|
|
549
|
-
function
|
|
550
|
+
function Tt(t2) {
|
|
550
551
|
if (!t2) throw new Error("must have a PointerHandlerOptions");
|
|
551
552
|
const { onPointerDown: e2, onPointerUp: n2, onPointerMoveOrWait: o2, processTouch: s2 = false, consumeTouch: l2 = true } = t2, a2 = P(e2, [e2]), h2 = P(n2, [n2]), u2 = P(o2, [o2]), d2 = r(false), _2 = t2?.timerInitial ?? 230, p2 = t2?.timerContinuous ?? _2 / 2, m2 = r(null), f2 = r(null), g2 = r(null), y2 = r(null), v2 = i(() => {
|
|
552
553
|
y2.current && (clearTimeout(y2.current), y2.current = null);
|
|
@@ -561,95 +562,95 @@ function Mt(t2) {
|
|
|
561
562
|
const b2 = s2 ? "pointer" : "mouse", w2 = i((t3) => {
|
|
562
563
|
t3.stopPropagation(), t3.stopImmediatePropagation(), t3.preventDefault();
|
|
563
564
|
}, []), S2 = P((t3) => {
|
|
564
|
-
document.removeEventListener(`${b2}move`,
|
|
565
|
+
document.removeEventListener(`${b2}move`, C2), 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(() => {
|
|
565
566
|
false !== d2.current && (d2.current = false, h2?.(t3, g2.current, m2.current), g2.current = null);
|
|
566
567
|
});
|
|
567
568
|
}, []), L2 = i(() => {
|
|
568
569
|
false !== d2.current && (d2.current = false, S2(f2.current));
|
|
569
|
-
}, []),
|
|
570
|
+
}, []), E2 = P(() => {
|
|
570
571
|
v2(), x2(p2), window.requestAnimationFrame(() => {
|
|
571
572
|
false !== d2.current && u2?.(f2.current, g2.current, m2.current);
|
|
572
573
|
});
|
|
573
|
-
}, [p2]),
|
|
574
|
-
f2.current = t3,
|
|
574
|
+
}, [p2]), C2 = P((t3) => {
|
|
575
|
+
f2.current = t3, E2();
|
|
575
576
|
}, []), T2 = P((t3) => {
|
|
576
|
-
g2.current = { ctrlKey: t3.ctrlKey, shiftKey: t3.shiftKey, altKey: t3.altKey, metaKey: t3.metaKey },
|
|
577
|
+
g2.current = { ctrlKey: t3.ctrlKey, shiftKey: t3.shiftKey, altKey: t3.altKey, metaKey: t3.metaKey }, E2();
|
|
577
578
|
}, []), M2 = P((t3) => {
|
|
578
|
-
g2.current = { ctrlKey: t3.ctrlKey, shiftKey: t3.shiftKey, altKey: t3.altKey, metaKey: t3.metaKey },
|
|
579
|
+
g2.current = { ctrlKey: t3.ctrlKey, shiftKey: t3.shiftKey, altKey: t3.altKey, metaKey: t3.metaKey }, E2();
|
|
579
580
|
}, [p2]);
|
|
580
581
|
return P((t3) => {
|
|
581
582
|
if (t3.isDefaultPrevented()) return;
|
|
582
583
|
g2.current = { ctrlKey: t3.ctrlKey, shiftKey: t3.shiftKey, altKey: t3.altKey, metaKey: t3.metaKey };
|
|
583
|
-
false !== a2(t3, g2.current) && (m2.current = t3, f2.current = t3.nativeEvent, document.addEventListener(`${b2}up`, S2, { passive: false }), document.addEventListener(`${b2}move`,
|
|
584
|
+
false !== a2(t3, g2.current) && (m2.current = t3, f2.current = t3.nativeEvent, document.addEventListener(`${b2}up`, S2, { passive: false }), document.addEventListener(`${b2}move`, C2, { 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));
|
|
584
585
|
}, [_2, s2]);
|
|
585
586
|
}
|
|
586
|
-
function
|
|
587
|
-
return
|
|
587
|
+
function Mt(t2, e2) {
|
|
588
|
+
return Tt({ onPointerDown: t2, onPointerMoveOrWait: (e3, n2, o2) => {
|
|
588
589
|
t2?.(o2);
|
|
589
590
|
}, ...e2 });
|
|
590
591
|
}
|
|
591
|
-
const
|
|
592
|
+
const Dt = ({ initValue: t2, useHookBody: e2, applyStateChange: n2 }) => {
|
|
592
593
|
const o2 = r(t2);
|
|
593
594
|
if ("function" != typeof e2) throw new Error("function expected as hook body parameter. got " + typeof e2);
|
|
594
595
|
const i2 = e2();
|
|
595
596
|
return d(() => {
|
|
596
597
|
o2.current !== i2 && (o2.current = i2, n2(i2));
|
|
597
598
|
}, [n2, i2]), null;
|
|
598
|
-
},
|
|
599
|
+
}, Pt = (t2) => {
|
|
599
600
|
console && console.warn && console.warn(t2);
|
|
600
|
-
},
|
|
601
|
-
let
|
|
602
|
-
const
|
|
603
|
-
|
|
604
|
-
},
|
|
601
|
+
}, zt = "object" == typeof self && self.self === self && self || "object" == typeof global && global.global === global && global || void 0;
|
|
602
|
+
let kt = 1, At = false, Bt = false;
|
|
603
|
+
const $t = [], Kt = [], Ot = () => {
|
|
604
|
+
Kt.forEach((t2) => t2());
|
|
605
|
+
}, Vt = ({ automaticContainerInternalUseOnly: e2 }) => {
|
|
605
606
|
const [o2, i2] = a([]), s2 = r([]);
|
|
606
|
-
return s2.current = o2, e2 || false !==
|
|
607
|
+
return s2.current = o2, e2 || false !== At || (Bt = true), c(() => {
|
|
607
608
|
let t2 = true;
|
|
608
609
|
function n2() {
|
|
609
|
-
if (t2) return
|
|
610
|
+
if (t2) return Kt[0] !== n2 ? (e2 || true !== At || Pt("SingletonHooksContainer is mounted after some singleton hook has been used.Your SingletonHooksContainer will not be used in favor of internal one."), void i2((t3) => [])) : void i2([...$t]);
|
|
610
611
|
}
|
|
611
|
-
return
|
|
612
|
-
t2 = false, s2.current?.length > 0 &&
|
|
612
|
+
return Kt.push(n2), Ot(), () => {
|
|
613
|
+
t2 = false, s2.current?.length > 0 && Pt("SingletonHooksContainer is unmounted, but it has active singleton hooks. They will be reevaluated once SingletonHooksContainer is mounted again"), Kt.splice(Kt.indexOf(n2), 1), Ot();
|
|
613
614
|
};
|
|
614
|
-
}, [e2]), t(n, { children: o2.map(({ hook: t2, key: e3 }) => _(
|
|
615
|
-
},
|
|
616
|
-
const n2 =
|
|
617
|
-
return
|
|
618
|
-
if (
|
|
619
|
-
const n3 =
|
|
615
|
+
}, [e2]), t(n, { children: o2.map(({ hook: t2, key: e3 }) => _(Dt, { ...t2, key: e3 })) });
|
|
616
|
+
}, Ht = (e2) => {
|
|
617
|
+
const n2 = kt++;
|
|
618
|
+
return $t.push({ hook: e2, key: n2 }), 0 === Kt.length && false === Bt && (At = true, ((e3) => {
|
|
619
|
+
if (zt.document && zt.document.createElement) {
|
|
620
|
+
const n3 = zt.document.createElement("div");
|
|
620
621
|
S(n3).render(t(e3, { automaticContainerInternalUseOnly: true }));
|
|
621
|
-
} else
|
|
622
|
-
})(
|
|
623
|
-
|
|
622
|
+
} else Pt("Can not mount SingletonHooksContainer on server side. Did you manage to run useEffect on server? Please mount SingletonHooksContainer into your components tree manually.");
|
|
623
|
+
})(Vt)), Ot(), () => {
|
|
624
|
+
$t.splice($t.findIndex((t2) => t2.key === n2), 1), Ot();
|
|
624
625
|
};
|
|
625
626
|
};
|
|
626
|
-
let
|
|
627
|
-
|
|
627
|
+
let Wt = null;
|
|
628
|
+
Wt || (Wt = (t2, e2, n2 = {}) => {
|
|
628
629
|
let o2, i2, r2 = false, s2 = false, l2 = [], { unmountIfNoConsumers: h2 = false } = n2;
|
|
629
630
|
const u2 = (t3) => {
|
|
630
631
|
i2 = t3, L(() => l2.forEach((e3) => e3(t3)));
|
|
631
632
|
}, d2 = () => (s2 || (i2 = "function" == typeof t2 ? t2() : t2, s2 = true), i2);
|
|
632
633
|
return () => {
|
|
633
634
|
const [n3, s3] = a(d2);
|
|
634
|
-
return c(() => (r2 || (r2 = true, o2 =
|
|
635
|
+
return c(() => (r2 || (r2 = true, o2 = Ht({ initValue: t2, useHookBody: e2, applyStateChange: u2 })), l2.push(s3), i2 !== n3 && s3(i2), () => {
|
|
635
636
|
l2.splice(l2.indexOf(s3), 1), 0 === l2.length && h2 && (o2(), r2 = false);
|
|
636
637
|
}), []), n3;
|
|
637
638
|
};
|
|
638
639
|
});
|
|
639
|
-
const
|
|
640
|
+
const Nt = Wt;
|
|
640
641
|
let Ft = () => {
|
|
641
642
|
console.warn("You must call useEditMode before setting its state.");
|
|
642
643
|
};
|
|
643
|
-
const
|
|
644
|
+
const Rt = Nt(null, () => {
|
|
644
645
|
const [t2, e2] = a(null);
|
|
645
646
|
return Ft = e2, t2;
|
|
646
|
-
}),
|
|
647
|
-
const t2 =
|
|
647
|
+
}), It = () => {
|
|
648
|
+
const t2 = Rt();
|
|
648
649
|
return h(() => ({ setMode: (t3) => {
|
|
649
650
|
Ft((e2) => ("function" == typeof t3 && (t3 = t3(e2)), t3?.onModeChange?.(t3 ?? null), t3));
|
|
650
651
|
}, getMode: () => t2 }), [t2]);
|
|
651
652
|
};
|
|
652
|
-
class
|
|
653
|
+
class Yt {
|
|
653
654
|
constructor(t2, e2, n2, o2) {
|
|
654
655
|
this._listenersProperties = /* @__PURE__ */ new Set(), this._listenersExecute = /* @__PURE__ */ new Set(), this._key = t2, this._target = e2, this._applyProps(n2 || {}), this._callback = o2, void 0 === o2 && (this._callback = () => {
|
|
655
656
|
console.log(`implement: ${this.label()} : ${this.description()}`);
|
|
@@ -761,9 +762,9 @@ class Xt {
|
|
|
761
762
|
}), e2;
|
|
762
763
|
}
|
|
763
764
|
}
|
|
764
|
-
class
|
|
765
|
+
class Xt extends Yt {
|
|
765
766
|
}
|
|
766
|
-
class
|
|
767
|
+
class jt {
|
|
767
768
|
constructor(t2, e2) {
|
|
768
769
|
this._target = null, this._groupKey = null, this._root = null, this._parent = null, this._uuid = g.uuidV4(), this._target = t2, this._groupKey = e2 ?? null, this._root = this, this._nodes = /* @__PURE__ */ new Map(), this._nodes.set(e2, this), this._children = /* @__PURE__ */ new Map(), this._listeners = /* @__PURE__ */ new Set(), this._commandsByKey = /* @__PURE__ */ new Map(), this._commandsByShortcut = /* @__PURE__ */ new Map();
|
|
769
770
|
const n2 = this;
|
|
@@ -791,7 +792,7 @@ class Ut {
|
|
|
791
792
|
n3 && (o2 = n3), t3 = t3._parent;
|
|
792
793
|
}
|
|
793
794
|
}
|
|
794
|
-
o2 || (o2 = new
|
|
795
|
+
o2 || (o2 = new jt(t2, e2), o2._parent = this, o2._root = this._root, o2._unListenersByCommand = null, o2._listenersByKey = null, o2._commandsPropertyListener = null);
|
|
795
796
|
const i2 = (t3, o3) => {
|
|
796
797
|
!t3.has(e2) || n2 ? t3.set(e2, o3) : void 0 === n2 && console.warn("commandGroup already registered", e2);
|
|
797
798
|
};
|
|
@@ -823,7 +824,7 @@ class Ut {
|
|
|
823
824
|
if (!u2) continue;
|
|
824
825
|
const d2 = Array.isArray(u2) ? u2 : [u2];
|
|
825
826
|
for (let t3 = 0; t3 < d2.length; t3++) {
|
|
826
|
-
const n3 =
|
|
827
|
+
const n3 = Gt(d2[t3]), i3 = o2.get(n3);
|
|
827
828
|
i3 && !e2 && void 0 === e2 && console.warn(`Shortcut already registered: ${n3}, ${a2}, ${i3}.`), o2.set(n3, a2);
|
|
828
829
|
}
|
|
829
830
|
}
|
|
@@ -857,11 +858,11 @@ class Ut {
|
|
|
857
858
|
}
|
|
858
859
|
findCommandByEvent(t2) {
|
|
859
860
|
const e2 = [];
|
|
860
|
-
t2.altKey && e2.push(
|
|
861
|
-
let n2 =
|
|
861
|
+
t2.altKey && e2.push(C.Alt), t2.shiftKey && e2.push(C.Shift), t2.ctrlKey && e2.push(C.Ctrl), t2.metaKey && e2.push(C.Meta);
|
|
862
|
+
let n2 = Gt({ key: t2.code, modifiers: e2 });
|
|
862
863
|
const o2 = this._commandsByShortcut;
|
|
863
864
|
let i2 = o2.get(n2);
|
|
864
|
-
i2 || (n2 =
|
|
865
|
+
i2 || (n2 = Gt({ key: t2.key, modifiers: e2 }), i2 = o2.get(n2)), !i2 && t2.code.startsWith("Digit") && (n2 = Gt({ key: t2.code.substring(5, t2.code.length), modifiers: e2 }), i2 = this._commandsByShortcut.get(n2)), !i2 && t2.code.startsWith("Key") && (i2 = Gt({ key: t2.code.substring(3, t2.code.length), modifiers: e2 }), i2 = o2.get(n2));
|
|
865
866
|
let r2 = null;
|
|
866
867
|
return i2 && (r2 = this._commandsByKey.get(i2), r2 && r2.disabled() && (r2 = null), !r2 || r2.target() && r2.target().contains(t2.target) || (r2 = null)), r2 || (this._parent?.findCommandByEvent(t2) ?? null);
|
|
867
868
|
}
|
|
@@ -920,13 +921,13 @@ class Ut {
|
|
|
920
921
|
}), t2;
|
|
921
922
|
}
|
|
922
923
|
}
|
|
923
|
-
const
|
|
924
|
+
const Ut = g.getOS() === g.OSType.MacOS || g.getOS() === g.OSType.IOS ? "Cmd" : "Ctrl", Zt = g.getOS() === g.OSType.MacOS || g.getOS() === g.OSType.IOS ? "⌘" : "^", Gt = (t2, e2 = false) => {
|
|
924
925
|
const n2 = {};
|
|
925
926
|
for (let e3 = 0; t2.modifiers && e3 < t2.modifiers.length; e3++) n2[t2.modifiers[e3]] = true;
|
|
926
927
|
let o2 = "";
|
|
927
|
-
return (n2?.[
|
|
928
|
+
return (n2?.[C.Ctrl] || n2?.[C.Meta]) && (o2 += (o2.length > 0 ? "+" : "") + (e2 ? Zt : Ut)), n2?.[C.Alt] && (o2 += e2 ? "⌥" : "Alt"), n2?.[C.Shift] && (o2 += (o2.length > 0 ? "+" : "") + (e2 ? "⇧" : "Shift")), o2 += (o2.length > 0 ? "+" : "") + G(t2.key), o2;
|
|
928
929
|
};
|
|
929
|
-
function
|
|
930
|
+
function qt(t2, e2 = null) {
|
|
930
931
|
const n2 = r(e2);
|
|
931
932
|
n2.current = e2;
|
|
932
933
|
const [o2, i2] = p((t3) => t3 + 1, 0), s2 = h(() => Array.isArray(t2) ? t2 : [t2], [t2]);
|
|
@@ -950,7 +951,7 @@ function Jt(t2, e2 = null) {
|
|
|
950
951
|
};
|
|
951
952
|
}, [t2]), o2;
|
|
952
953
|
}
|
|
953
|
-
const
|
|
954
|
+
const Jt = (t2, e2) => {
|
|
954
955
|
const n2 = [];
|
|
955
956
|
if (e2) for (let o2 = 0; o2 < e2.length; o2++) {
|
|
956
957
|
const i2 = e2[o2], r2 = i2 ? t2?.getCommand(i2) : null;
|
|
@@ -958,36 +959,36 @@ const Qt = (t2, e2) => {
|
|
|
958
959
|
}
|
|
959
960
|
return n2;
|
|
960
961
|
};
|
|
961
|
-
function
|
|
962
|
+
function Qt(t2, e2 = null, n2 = null, o2) {
|
|
962
963
|
const i2 = r(n2);
|
|
963
964
|
i2.current = n2, e2 && !Array.isArray(e2) && (e2 = [e2]);
|
|
964
|
-
const [s2, l2] = a(
|
|
965
|
+
const [s2, l2] = a(Jt(t2, e2)), h2 = o2 ? [...o2, t2] : [t2];
|
|
965
966
|
return c(() => {
|
|
966
967
|
const n3 = { onGroupChange: () => {
|
|
967
|
-
const n4 =
|
|
968
|
+
const n4 = Jt(t2, e2);
|
|
968
969
|
l2(n4), i2.current?.onChange?.(this);
|
|
969
970
|
} };
|
|
970
971
|
let o3;
|
|
971
972
|
e2 && e2.length > 0 && (o3 = { keys: e2 }, n3.onCommandChange = (n4, o4) => {
|
|
972
|
-
i2.current?.onChange?.(t2), l2(
|
|
973
|
+
i2.current?.onChange?.(t2), l2(Jt(t2, e2));
|
|
973
974
|
});
|
|
974
|
-
const r2 = t2?.addListener(n3, o3), s3 =
|
|
975
|
+
const r2 = t2?.addListener(n3, o3), s3 = Jt(t2, e2);
|
|
975
976
|
return l2(s3), i2.current?.onChange && i2.current?.onChange(t2), () => {
|
|
976
977
|
r2?.();
|
|
977
978
|
};
|
|
978
979
|
}, h2), s2;
|
|
979
980
|
}
|
|
980
|
-
const
|
|
981
|
+
const te = { Toolbar: "toolbar", Menuitem: "menuitem" }, ee = Nt({ setClipboard: (t2) => {
|
|
981
982
|
throw new Error("This is only available via the useClipboard.");
|
|
982
983
|
}, getClipboard: () => y.Global, refNativeCopy: { current: null }, refNativeLastKey: { current: null } }, () => {
|
|
983
984
|
const [t2, e2] = a(y.Global);
|
|
984
985
|
return { setClipboard: (t3) => e2(t3), getClipboard: () => t2, refNativeCopy: r(null), refNativeLastKey: r(null) };
|
|
985
|
-
}),
|
|
986
|
-
const { source: e2, target: n2, onPaste: o2, onClipboardUpdate: r2, notifier: s2 = rt, commands: l2 } = t2, a2 = P(r2, [r2]), u2 = P(o2, [o2]), { getClipboard: d2, refNativeCopy: _2 } =
|
|
986
|
+
}), ne = (t2) => {
|
|
987
|
+
const { source: e2, target: n2, onPaste: o2, onClipboardUpdate: r2, notifier: s2 = rt, commands: l2 } = t2, a2 = P(r2, [r2]), u2 = P(o2, [o2]), { getClipboard: d2, refNativeCopy: _2 } = ee(), p2 = d2();
|
|
987
988
|
h(() => {
|
|
988
989
|
const t3 = e2?.element, o3 = n2?.element ?? e2?.element;
|
|
989
990
|
if (!l2) return;
|
|
990
|
-
const i2 = [new
|
|
991
|
+
const i2 = [new Xt("cut", t3, { label: "Cut", description: "Remove the selection and put it on the clipboard so you can paste it somewhere else.", shortcut: { key: "X", modifiers: [C.Ctrl] } }), new Xt("copy", t3, { label: "Copy", description: "Put a copy of the selection on the clipboard so you can paste it somewhere else.", shortcut: { key: "C", modifiers: [C.Ctrl] } }), new Xt("paste", o3, { label: "Paste", description: "Add content on the clipboard to your document.", shortcut: [{ key: "V", modifiers: [C.Ctrl] }, { key: "F8", modifiers: [C.Ctrl] }] })];
|
|
991
992
|
l2?.addCommands(i2, true);
|
|
992
993
|
}, [l2]);
|
|
993
994
|
const m2 = P(async (t3) => {
|
|
@@ -1073,7 +1074,7 @@ const ee = { Toolbar: "toolbar", Menuitem: "menuitem" }, ne = Rt({ setClipboard:
|
|
|
1073
1074
|
l2?.getCommand("cut")?.updateCallback(b2).update({ disabled: !e2 || !n2 }), l2?.getCommand("copy")?.updateCallback(f2).update({ disabled: !e2 }), l2?.getCommand("paste")?.updateCallback(L2).update({ disabled: !n2 });
|
|
1074
1075
|
}, [e2, n2, l2]), { paste: L2, copy: f2, clipboard: p2 };
|
|
1075
1076
|
};
|
|
1076
|
-
function
|
|
1077
|
+
function oe(t2, e2 = true) {
|
|
1077
1078
|
const n2 = r(t2);
|
|
1078
1079
|
c(() => {
|
|
1079
1080
|
if (e2) {
|
|
@@ -1083,17 +1084,17 @@ function ie(t2, e2 = true) {
|
|
|
1083
1084
|
n2.current = t2;
|
|
1084
1085
|
});
|
|
1085
1086
|
}
|
|
1086
|
-
let
|
|
1087
|
-
var
|
|
1088
|
-
const
|
|
1089
|
-
const
|
|
1090
|
-
const [t2, e2] = o.useState(() =>
|
|
1091
|
-
return
|
|
1092
|
-
null == t2 && e2(
|
|
1087
|
+
let ie = false, re = 0;
|
|
1088
|
+
var se = "undefined" != typeof document ? d : c;
|
|
1089
|
+
const le = () => "sheetxl-ui-" + re++;
|
|
1090
|
+
const ae = o["useId".toString()], ce = null != ae ? ae : function() {
|
|
1091
|
+
const [t2, e2] = o.useState(() => ie ? le() : void 0);
|
|
1092
|
+
return se(() => {
|
|
1093
|
+
null == t2 && e2(le());
|
|
1093
1094
|
}, []), o.useEffect(() => {
|
|
1094
|
-
|
|
1095
|
+
ie || (ie = true);
|
|
1095
1096
|
}, []), t2;
|
|
1096
|
-
},
|
|
1097
|
+
}, he = "Undo the last action.", ue = "Repeat the last action or undo the redo.", de = (t2) => `Redo ${t2}`, _e = ({ manager: t2, commands: e2, disabled: n2, notifier: o2 = rt }) => {
|
|
1097
1098
|
const i2 = P((e3) => {
|
|
1098
1099
|
try {
|
|
1099
1100
|
t2?.undo(e3);
|
|
@@ -1110,16 +1111,16 @@ const ce = o["useId".toString()], he = null != ce ? ce : function() {
|
|
|
1110
1111
|
return h(() => {
|
|
1111
1112
|
if (!e2) return;
|
|
1112
1113
|
const t3 = { contains: (t4) => true, focus() {
|
|
1113
|
-
} }, n3 = [new
|
|
1114
|
+
} }, n3 = [new Yt("undo", t3, { label: "Undo", description: he, shortcut: { key: "z", modifiers: [C.Ctrl] }, disabled: true }, i2), new Yt("redo", t3, { label: "Redo", description: ue, shortcut: [{ key: "y", modifiers: [C.Ctrl] }, { key: "F4" }, { key: "Enter", modifiers: [C.Alt] }], disabled: true }, r2)];
|
|
1114
1115
|
e2?.addCommands(n3, true);
|
|
1115
1116
|
}, [e2]), c(() => {
|
|
1116
1117
|
if (!e2) return;
|
|
1117
1118
|
const o3 = () => {
|
|
1118
1119
|
const o4 = t2?.getTopUndoDescription(), i4 = {};
|
|
1119
1120
|
var r3;
|
|
1120
|
-
e2.getCommand("undo").update({ disabled: n2 || !t2 || !t2.hasUndo(), description: o4 ? (r3 = o4, `Undo ${r3}`) :
|
|
1121
|
+
e2.getCommand("undo").update({ disabled: n2 || !t2 || !t2.hasUndo(), description: o4 ? (r3 = o4, `Undo ${r3}`) : he, state: i4, context: { undoManager: t2 } });
|
|
1121
1122
|
const s2 = t2?.getTopRedoDescription();
|
|
1122
|
-
e2.getCommand("redo").update({ disabled: n2 || !t2 || !t2.hasRedo(), description: s2 ?
|
|
1123
|
+
e2.getCommand("redo").update({ disabled: n2 || !t2 || !t2.hasRedo(), description: s2 ? de(s2) : ue, state: i4, context: { undoManager: t2 } });
|
|
1123
1124
|
};
|
|
1124
1125
|
if (o3(), !t2) return;
|
|
1125
1126
|
const i3 = t2.addListener({ onStackChange() {
|
|
@@ -1129,48 +1130,47 @@ const ce = o["useId".toString()], he = null != ce ? ce : function() {
|
|
|
1129
1130
|
}, [t2, e2, n2]), { undo: i2, redo: r2 };
|
|
1130
1131
|
};
|
|
1131
1132
|
export {
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1133
|
+
Yt as Command,
|
|
1134
|
+
te as CommandButtonType,
|
|
1135
|
+
jt as CommandGroup,
|
|
1135
1136
|
rt as DefaultNotifier,
|
|
1136
|
-
|
|
1137
|
-
|
|
1137
|
+
mt as FocusKeyNavigation,
|
|
1138
|
+
E as HorizontalAlignment,
|
|
1138
1139
|
T as KeyCodes,
|
|
1139
|
-
|
|
1140
|
+
C as KeyModifiers,
|
|
1140
1141
|
M as MouseButtonCodes,
|
|
1141
1142
|
ot as NotificationType,
|
|
1142
1143
|
q as ReactUtils,
|
|
1143
|
-
|
|
1144
|
+
ft as RoundedTab,
|
|
1144
1145
|
nt as ScrollPane,
|
|
1145
1146
|
$ as ScrollUtils,
|
|
1146
1147
|
O as Scrollbar,
|
|
1147
1148
|
D as ScrollbarOrientation,
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1149
|
+
Xt as SimpleCommand,
|
|
1150
|
+
St as SplitPane,
|
|
1151
|
+
yt as SplitPaneResizer,
|
|
1152
|
+
pt as ToolTipPlacement,
|
|
1153
|
+
_t as VirtualScrollbar,
|
|
1153
1154
|
et as defaultCreateScrollCorner,
|
|
1154
1155
|
A as defaultCreateScrollEdgeButton,
|
|
1155
1156
|
k as defaultCreateScrollEndButton,
|
|
1156
1157
|
z as defaultCreateScrollStartButton,
|
|
1157
1158
|
tt as defaultCreateScrollbar,
|
|
1158
1159
|
Et as getDevicePixelRatio,
|
|
1159
|
-
|
|
1160
|
-
qt as toShortcutString,
|
|
1160
|
+
Gt as toShortcutString,
|
|
1161
1161
|
P as useCallbackRef,
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1162
|
+
qt as useCommand,
|
|
1163
|
+
Qt as useCommands,
|
|
1164
|
+
ne as useCopyPaste,
|
|
1165
|
+
Lt as useDevicePixelRatio,
|
|
1166
|
+
It as useEditMode,
|
|
1167
|
+
lt as useFullscreenPortal,
|
|
1168
|
+
ee as useGlobalClipboard,
|
|
1169
|
+
ce as useId,
|
|
1170
1170
|
Q as useImperativeElement,
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1171
|
+
Mt as useMouseDownAndHoldListener,
|
|
1172
|
+
Ct as useOnClickOrFocusAway,
|
|
1173
|
+
Tt as useSynchronizedPointerHandler,
|
|
1174
|
+
oe as useTraceUpdate,
|
|
1175
|
+
_e as useUndoManager
|
|
1176
1176
|
};
|