@asup/context-menu 1.5.2 → 2.0.2
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/README.md +117 -65
- package/dist/cjs/main.js +192 -142
- package/dist/cjs/main.js.map +1 -1
- package/dist/context-menu.d.ts +12 -33
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/main.js +194 -144
- package/dist/main.js.map +1 -1
- package/package.json +31 -23
package/dist/main.js
CHANGED
|
@@ -3,7 +3,7 @@ import {_ as $duWW8$_} from "@swc/helpers/_/_object_spread";
|
|
|
3
3
|
import {_ as $duWW8$_1} from "@swc/helpers/_/_object_spread_props";
|
|
4
4
|
import {_ as $duWW8$_2} from "@swc/helpers/_/_object_without_properties";
|
|
5
5
|
import {jsx as $duWW8$jsx, jsxs as $duWW8$jsxs, Fragment as $duWW8$Fragment} from "react/jsx-runtime";
|
|
6
|
-
import {useRef as $duWW8$useRef, useState as $duWW8$useState,
|
|
6
|
+
import {useRef as $duWW8$useRef, useState as $duWW8$useState, useEffectEvent as $duWW8$useEffectEvent, useLayoutEffect as $duWW8$useLayoutEffect, useEffect as $duWW8$useEffect, forwardRef as $duWW8$forwardRef, createContext as $duWW8$createContext, useContext as $duWW8$useContext, useCallback as $duWW8$useCallback, useTransition as $duWW8$useTransition} from "react";
|
|
7
7
|
import {createPortal as $duWW8$createPortal} from "react-dom";
|
|
8
8
|
|
|
9
9
|
|
|
@@ -23,7 +23,6 @@ $parcel$export($b65191f6d0a0a991$exports, "ClickForMenu", function () { return $
|
|
|
23
23
|
$parcel$export($b65191f6d0a0a991$exports, "ContextMenu", function () { return $567ed433af94513f$export$8dc6765e8be191c7; });
|
|
24
24
|
$parcel$export($b65191f6d0a0a991$exports, "ContextMenuHandler", function () { return $1e1c1e9e0b943830$export$ed4f9641643dc7e4; });
|
|
25
25
|
$parcel$export($b65191f6d0a0a991$exports, "ContextWindow", function () { return $b5e8657823def5be$export$1af8984c69ba1b24; });
|
|
26
|
-
$parcel$export($b65191f6d0a0a991$exports, "ContextWindowStack", function () { return $17c46b9e6a2eb66e$export$9f37482ccd50dad2; });
|
|
27
26
|
|
|
28
27
|
|
|
29
28
|
|
|
@@ -40,7 +39,7 @@ $181673e3e0e596f3$export$563bd8f955c52746 = `aiw-AutoHeight-module-pDlSVW-autoHe
|
|
|
40
39
|
|
|
41
40
|
|
|
42
41
|
function $62873e7e5aeec7f1$export$77bf000da9303d1(_param) {
|
|
43
|
-
var { children: children, hide: hide, duration: duration = 300 } = _param, rest = (0, $duWW8$_2)(_param, [
|
|
42
|
+
var { children: children, hide: hide = false, duration: duration = 300 } = _param, rest = (0, $duWW8$_2)(_param, [
|
|
44
43
|
"children",
|
|
45
44
|
"hide",
|
|
46
45
|
"duration"
|
|
@@ -48,29 +47,63 @@ function $62873e7e5aeec7f1$export$77bf000da9303d1(_param) {
|
|
|
48
47
|
const wrapperRef = (0, $duWW8$useRef)(null);
|
|
49
48
|
const innerRef = (0, $duWW8$useRef)(null);
|
|
50
49
|
const [height, setHeight] = (0, $duWW8$useState)(null);
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
50
|
+
const [animationState, setAnimationState] = (0, $duWW8$useState)(!hide ? "open" : "closed");
|
|
51
|
+
const rafRef = (0, $duWW8$useRef)(null);
|
|
52
|
+
const timeoutRef = (0, $duWW8$useRef)(null);
|
|
53
|
+
const targetChildren = animationState === "closed" || !children ? null : children;
|
|
54
|
+
const setTargetHeight = (0, $duWW8$useEffectEvent)((newHeight)=>{
|
|
55
|
+
setHeight(newHeight);
|
|
56
|
+
});
|
|
57
|
+
const transitionToOpening = (0, $duWW8$useEffectEvent)(()=>{
|
|
58
|
+
// Cancel any pending close timeout
|
|
59
|
+
if (timeoutRef.current !== null) {
|
|
60
|
+
clearTimeout(timeoutRef.current);
|
|
61
|
+
timeoutRef.current = null;
|
|
62
|
+
}
|
|
63
|
+
setAnimationState("opening");
|
|
64
|
+
const id = window.requestAnimationFrame(()=>{
|
|
65
|
+
rafRef.current = null;
|
|
66
|
+
setTargetHeight(1);
|
|
67
|
+
const frameId = window.requestAnimationFrame(()=>{
|
|
68
|
+
const inner = innerRef.current;
|
|
69
|
+
if (inner) {
|
|
70
|
+
setTargetHeight(inner.offsetHeight);
|
|
71
|
+
setAnimationState("open");
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
rafRef.current = frameId;
|
|
75
|
+
});
|
|
76
|
+
rafRef.current = id;
|
|
77
|
+
});
|
|
78
|
+
const transitionToClosing = (0, $duWW8$useEffectEvent)(()=>{
|
|
79
|
+
// Cancel any pending RAF
|
|
80
|
+
if (rafRef.current !== null) {
|
|
81
|
+
cancelAnimationFrame(rafRef.current);
|
|
82
|
+
rafRef.current = null;
|
|
83
|
+
}
|
|
84
|
+
setAnimationState("closing");
|
|
85
|
+
setTargetHeight(1);
|
|
86
|
+
timeoutRef.current = window.setTimeout(()=>{
|
|
87
|
+
timeoutRef.current = null;
|
|
88
|
+
setAnimationState("closed");
|
|
89
|
+
}, duration);
|
|
90
|
+
});
|
|
91
|
+
(0, $duWW8$useLayoutEffect)(()=>{
|
|
92
|
+
if (!hide) // Want to show: transition to open
|
|
93
|
+
{
|
|
94
|
+
if (animationState === "closed" || animationState === "closing") transitionToOpening();
|
|
95
|
+
} else // Want to hide: transition to closed
|
|
96
|
+
if (animationState === "open" || animationState === "opening") transitionToClosing();
|
|
65
97
|
}, [
|
|
66
|
-
hide
|
|
98
|
+
hide,
|
|
99
|
+
animationState
|
|
67
100
|
]);
|
|
68
|
-
//
|
|
101
|
+
// Setup ResizeObserver to track content size changes
|
|
69
102
|
(0, $duWW8$useEffect)(()=>{
|
|
70
103
|
const transition = innerRef.current;
|
|
71
104
|
if (transition) {
|
|
72
105
|
const observer = new ResizeObserver(()=>{
|
|
73
|
-
setTargetHeight();
|
|
106
|
+
if (animationState === "open") setTargetHeight(transition.offsetHeight);
|
|
74
107
|
});
|
|
75
108
|
observer.observe(transition);
|
|
76
109
|
return ()=>{
|
|
@@ -78,19 +111,26 @@ function $62873e7e5aeec7f1$export$77bf000da9303d1(_param) {
|
|
|
78
111
|
};
|
|
79
112
|
}
|
|
80
113
|
}, [
|
|
81
|
-
|
|
82
|
-
]);
|
|
83
|
-
// Trigger height change on children update
|
|
84
|
-
(0, $duWW8$useLayoutEffect)(()=>{
|
|
85
|
-
setTargetHeight();
|
|
86
|
-
}, [
|
|
87
|
-
setTargetHeight,
|
|
88
|
-
children
|
|
114
|
+
animationState
|
|
89
115
|
]);
|
|
116
|
+
// Cleanup on unmount
|
|
117
|
+
(0, $duWW8$useEffect)(()=>{
|
|
118
|
+
return ()=>{
|
|
119
|
+
if (rafRef.current !== null) {
|
|
120
|
+
cancelAnimationFrame(rafRef.current);
|
|
121
|
+
rafRef.current = null;
|
|
122
|
+
}
|
|
123
|
+
if (timeoutRef.current !== null) {
|
|
124
|
+
clearTimeout(timeoutRef.current);
|
|
125
|
+
timeoutRef.current = null;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}, []);
|
|
90
129
|
return /*#__PURE__*/ (0, $duWW8$jsx)("div", (0, $duWW8$_1)((0, $duWW8$_)({}, rest), {
|
|
91
130
|
className: (0, (/*@__PURE__*/$parcel$interopDefault($181673e3e0e596f3$exports))).autoHeightWrapper,
|
|
92
131
|
ref: wrapperRef,
|
|
93
132
|
style: (0, $duWW8$_1)((0, $duWW8$_)({}, rest.style), {
|
|
133
|
+
display: animationState === "closed" ? "none" : undefined,
|
|
94
134
|
height: height ? `${height}px` : "auto",
|
|
95
135
|
transitionDuration: `${duration}ms`
|
|
96
136
|
}),
|
|
@@ -230,13 +270,25 @@ const $567ed433af94513f$var$ESTIMATED_MENU_ITEM_HEIGHT = 34;
|
|
|
230
270
|
const $567ed433af94513f$var$ESTIMATED_MENU_PADDING = 4;
|
|
231
271
|
const $567ed433af94513f$var$ESTIMATED_MENU_WIDTH = 200;
|
|
232
272
|
const $567ed433af94513f$export$8dc6765e8be191c7 = /*#__PURE__*/ (0, $duWW8$forwardRef)(({ visible: visible, entries: entries, xPos: xPos, yPos: yPos, toClose: toClose }, ref)=>{
|
|
233
|
-
//
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
273
|
+
// Measure menu size after mount/render to avoid accessing refs during render
|
|
274
|
+
const [menuHeight, setMenuHeight] = (0, $duWW8$useState)(entries.length * $567ed433af94513f$var$ESTIMATED_MENU_ITEM_HEIGHT + $567ed433af94513f$var$ESTIMATED_MENU_PADDING);
|
|
275
|
+
const [menuWidth, setMenuWidth] = (0, $duWW8$useState)($567ed433af94513f$var$ESTIMATED_MENU_WIDTH);
|
|
276
|
+
(0, $duWW8$useLayoutEffect)(()=>{
|
|
277
|
+
// Only measure when visible; ref access inside effect is allowed
|
|
278
|
+
if (visible && ref && typeof ref !== "function" && ref.current instanceof HTMLDivElement) {
|
|
279
|
+
setMenuHeight(ref.current.offsetHeight);
|
|
280
|
+
setMenuWidth(ref.current.offsetWidth);
|
|
281
|
+
}
|
|
282
|
+
// When not visible, fall back to estimates
|
|
283
|
+
if (!visible) {
|
|
284
|
+
setMenuHeight(entries.length * $567ed433af94513f$var$ESTIMATED_MENU_ITEM_HEIGHT + $567ed433af94513f$var$ESTIMATED_MENU_PADDING);
|
|
285
|
+
setMenuWidth($567ed433af94513f$var$ESTIMATED_MENU_WIDTH);
|
|
286
|
+
}
|
|
287
|
+
}, [
|
|
288
|
+
visible,
|
|
289
|
+
entries,
|
|
290
|
+
ref
|
|
291
|
+
]);
|
|
240
292
|
const adjustedYPos = yPos + menuHeight > window.innerHeight ? Math.max(window.innerHeight - menuHeight - $567ed433af94513f$var$ESTIMATED_MENU_PADDING, 0) : yPos;
|
|
241
293
|
const adjustedXPos = xPos + menuWidth > window.innerWidth ? Math.max(window.innerWidth - menuWidth - $567ed433af94513f$var$ESTIMATED_MENU_PADDING, 0) : xPos;
|
|
242
294
|
return /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
@@ -277,9 +329,10 @@ const $c3e82278b501f10c$export$d4ebdd58e04c6ace = (_param)=>{
|
|
|
277
329
|
// Set up outsideClick handler
|
|
278
330
|
const menuRef = (0, $duWW8$useRef)(null);
|
|
279
331
|
// Handle click off the menu
|
|
280
|
-
|
|
332
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
333
|
+
const handleClick = (e)=>{
|
|
281
334
|
if (menuRef.current && (e.target instanceof Element && !menuRef.current.contains(e.target) || !(e.target instanceof Element))) setMenuInDom(false);
|
|
282
|
-
}
|
|
335
|
+
};
|
|
283
336
|
const removeController = (0, $duWW8$useRef)(null);
|
|
284
337
|
const removeTimeoutRef = (0, $duWW8$useRef)(null);
|
|
285
338
|
(0, $duWW8$useEffect)(()=>{
|
|
@@ -514,30 +567,26 @@ const $1e1c1e9e0b943830$export$ed4f9641643dc7e4 = (_param)=>{
|
|
|
514
567
|
"menuItems",
|
|
515
568
|
"showLowMenu"
|
|
516
569
|
]);
|
|
517
|
-
var _divHandlderRef_current;
|
|
518
570
|
// Check for higher content menu
|
|
519
571
|
const higherContext = (0, $duWW8$useContext)($1e1c1e9e0b943830$export$fc58dc71afe92de2);
|
|
520
|
-
const thisMenuItems =
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
higherContext,
|
|
539
|
-
menuItems
|
|
540
|
-
]);
|
|
572
|
+
const thisMenuItems = [
|
|
573
|
+
...higherContext !== null ? [
|
|
574
|
+
...higherContext.menuItems,
|
|
575
|
+
...[
|
|
576
|
+
higherContext.menuItems.length > 0 && !$1e1c1e9e0b943830$var$isDivider(higherContext.menuItems[higherContext.menuItems.length - 1].label) && menuItems.length > 0 && !$1e1c1e9e0b943830$var$isDivider(menuItems[0].label) ? {
|
|
577
|
+
label: /*#__PURE__*/ (0, $duWW8$jsx)("hr", {
|
|
578
|
+
style: {
|
|
579
|
+
flexGrow: 1,
|
|
580
|
+
cursor: "none",
|
|
581
|
+
margin: "0",
|
|
582
|
+
padding: "0"
|
|
583
|
+
}
|
|
584
|
+
})
|
|
585
|
+
} : null
|
|
586
|
+
].filter((item)=>item !== null)
|
|
587
|
+
] : [],
|
|
588
|
+
...menuItems
|
|
589
|
+
];
|
|
541
590
|
// Menu resources
|
|
542
591
|
const divHandlderRef = (0, $duWW8$useRef)(null);
|
|
543
592
|
const menuRef = (0, $duWW8$useRef)(null);
|
|
@@ -547,9 +596,34 @@ const $1e1c1e9e0b943830$export$ed4f9641643dc7e4 = (_param)=>{
|
|
|
547
596
|
const [menuInDom, setMenuInDom] = (0, $duWW8$useState)(false);
|
|
548
597
|
const [mouseOverHandlerDiv, setMouseOverHandlerDiv] = (0, $duWW8$useState)(false);
|
|
549
598
|
const [mouseOverMenu, setMouseOverMenu] = (0, $duWW8$useState)(false);
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
599
|
+
// Holder position - measured in an effect to avoid reading refs during render
|
|
600
|
+
const [divHandlerPos, setDivHandlerPos] = (0, $duWW8$useState)(null);
|
|
601
|
+
(0, $duWW8$useLayoutEffect)(()=>{
|
|
602
|
+
function updatePos() {
|
|
603
|
+
if (divHandlderRef.current) setDivHandlerPos(divHandlderRef.current.getBoundingClientRect());
|
|
604
|
+
}
|
|
605
|
+
// When the handler is hovered or the menu is mounted, ensure we have a fresh position
|
|
606
|
+
if (mouseOverHandlerDiv || menuInDom) updatePos();
|
|
607
|
+
// Attach listeners while the menu/low-menu may be visible so the position stays correct
|
|
608
|
+
if (mouseOverHandlerDiv || menuInDom) {
|
|
609
|
+
window.addEventListener("resize", updatePos);
|
|
610
|
+
// listen on capture to catch scrolls from ancestor elements as well
|
|
611
|
+
window.addEventListener("scroll", updatePos, true);
|
|
612
|
+
let ro = null;
|
|
613
|
+
if (typeof ResizeObserver !== "undefined" && divHandlderRef.current) {
|
|
614
|
+
ro = new ResizeObserver(()=>updatePos());
|
|
615
|
+
ro.observe(divHandlderRef.current);
|
|
616
|
+
}
|
|
617
|
+
return ()=>{
|
|
618
|
+
window.removeEventListener("resize", updatePos);
|
|
619
|
+
window.removeEventListener("scroll", updatePos, true);
|
|
620
|
+
if (ro) ro.disconnect();
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
}, [
|
|
624
|
+
mouseOverHandlerDiv,
|
|
625
|
+
menuInDom
|
|
626
|
+
]);
|
|
553
627
|
// Handle click off the menu
|
|
554
628
|
const handleClick = (0, $duWW8$useCallback)((e)=>{
|
|
555
629
|
var _menuRef_current;
|
|
@@ -744,17 +818,19 @@ const $b5e8657823def5be$export$1af8984c69ba1b24 = (_param)=>{
|
|
|
744
818
|
var _rest_style, _rest_style1, _rest_style2, _rest_style3;
|
|
745
819
|
const divRef = (0, $duWW8$useRef)(null);
|
|
746
820
|
const windowRef = (0, $duWW8$useRef)(null);
|
|
747
|
-
const [windowInDOM, setWindowInDOM] = (0, $duWW8$useState)(false);
|
|
748
|
-
const [windowVisible, setWindowVisible] = (0, $duWW8$useState)(false);
|
|
749
821
|
const [zIndex, setZIndex] = (0, $duWW8$useState)(minZIndex);
|
|
750
822
|
const resizeListenerRef = (0, $duWW8$useRef)(null);
|
|
823
|
+
// Track internal state: whether window is in DOM and whether it's been positioned
|
|
824
|
+
const [windowInDOM, setWindowInDOM] = (0, $duWW8$useState)(false);
|
|
825
|
+
const [windowVisible, setWindowVisible] = (0, $duWW8$useState)(false);
|
|
826
|
+
const [, startTransition] = (0, $duWW8$useTransition)();
|
|
751
827
|
// Position
|
|
752
828
|
const windowPos = (0, $duWW8$useRef)({
|
|
753
829
|
x: 0,
|
|
754
830
|
y: 0
|
|
755
831
|
});
|
|
756
832
|
const [moving, setMoving] = (0, $duWW8$useState)(false);
|
|
757
|
-
const move = (
|
|
833
|
+
const move = (x, y)=>{
|
|
758
834
|
if (windowRef.current && windowPos.current) {
|
|
759
835
|
const window1 = windowRef.current;
|
|
760
836
|
const pos = windowPos.current;
|
|
@@ -762,24 +838,21 @@ const $b5e8657823def5be$export$1af8984c69ba1b24 = (_param)=>{
|
|
|
762
838
|
pos.y += y;
|
|
763
839
|
window1.style.transform = `translate(${pos.x}px, ${pos.y}px)`;
|
|
764
840
|
}
|
|
765
|
-
}
|
|
766
|
-
|
|
841
|
+
};
|
|
842
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
843
|
+
const checkPosition = ()=>{
|
|
767
844
|
const chkPos = (0, $ab4d5d6bf03370d0$export$d81cfea7c54be196)(windowRef);
|
|
768
845
|
move(chkPos.translateX, chkPos.translateY);
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
]);
|
|
772
|
-
const mouseMove = (0, $duWW8$useCallback)((e)=>{
|
|
846
|
+
};
|
|
847
|
+
const mouseMove = (e)=>{
|
|
773
848
|
e.preventDefault();
|
|
774
849
|
e.stopPropagation();
|
|
775
850
|
move(e.movementX, e.movementY);
|
|
776
|
-
}
|
|
777
|
-
move
|
|
778
|
-
]);
|
|
851
|
+
};
|
|
779
852
|
// Store stable references to mouseMove and mouseUp for cleanup
|
|
780
853
|
const mouseMoveRef = (0, $duWW8$useRef)(mouseMove);
|
|
781
854
|
const mouseUpRef = (0, $duWW8$useRef)(()=>{});
|
|
782
|
-
const mouseUp = (
|
|
855
|
+
const mouseUp = (e)=>{
|
|
783
856
|
e.preventDefault();
|
|
784
857
|
e.stopPropagation();
|
|
785
858
|
setMoving(false);
|
|
@@ -791,55 +864,65 @@ const $b5e8657823def5be$export$1af8984c69ba1b24 = (_param)=>{
|
|
|
791
864
|
resizeListenerRef.current = null;
|
|
792
865
|
}
|
|
793
866
|
if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement)) e.target.style.userSelect = "auto";
|
|
794
|
-
}
|
|
795
|
-
checkPosition
|
|
796
|
-
]);
|
|
867
|
+
};
|
|
797
868
|
// Update refs when callbacks change
|
|
798
869
|
(0, $duWW8$useEffect)(()=>{
|
|
799
870
|
mouseMoveRef.current = mouseMove;
|
|
800
871
|
mouseUpRef.current = mouseUp;
|
|
801
|
-
}
|
|
802
|
-
mouseMove,
|
|
803
|
-
mouseUp
|
|
804
|
-
]);
|
|
872
|
+
});
|
|
805
873
|
// Helper function to push this window to the top
|
|
806
|
-
const pushToTop = (
|
|
874
|
+
const pushToTop = ()=>{
|
|
807
875
|
const maxZIndex = $b5e8657823def5be$var$getMaxZIndex(minZIndex);
|
|
808
876
|
setZIndex(maxZIndex + 1);
|
|
877
|
+
};
|
|
878
|
+
// Sync windowInDOM with visible prop using a layout effect to avoid ESLint warnings
|
|
879
|
+
// This effect derives state from props, which is acceptable when there's no synchronous setState
|
|
880
|
+
(0, $duWW8$useEffect)(()=>{
|
|
881
|
+
if (visible && !windowInDOM) // Window should be in DOM when visible becomes true
|
|
882
|
+
startTransition(()=>{
|
|
883
|
+
setWindowInDOM(true);
|
|
884
|
+
});
|
|
885
|
+
else if (!visible && windowInDOM) // Window should leave DOM when visible becomes false
|
|
886
|
+
startTransition(()=>{
|
|
887
|
+
setWindowInDOM(false);
|
|
888
|
+
setWindowVisible(false);
|
|
889
|
+
});
|
|
809
890
|
}, [
|
|
810
|
-
|
|
891
|
+
visible,
|
|
892
|
+
windowInDOM,
|
|
893
|
+
startTransition
|
|
811
894
|
]);
|
|
812
|
-
//
|
|
895
|
+
// Position and show window after it's added to DOM
|
|
813
896
|
(0, $duWW8$useEffect)(()=>{
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
windowRef.current.style.top = `${parentPos.bottom + windowHeight < window.innerHeight ? parentPos.bottom : Math.max(0, parentPos.top - windowHeight)}px`;
|
|
827
|
-
windowRef.current.style.transform = "";
|
|
828
|
-
windowPos.current = {
|
|
829
|
-
x: 0,
|
|
830
|
-
y: 0
|
|
831
|
-
};
|
|
832
|
-
}
|
|
897
|
+
if (windowInDOM && !windowVisible && visible && divRef.current && windowRef.current) {
|
|
898
|
+
// Position the window
|
|
899
|
+
const parentPos = divRef.current.getBoundingClientRect();
|
|
900
|
+
const pos = windowRef.current.getBoundingClientRect();
|
|
901
|
+
const windowHeight = pos.bottom - pos.top;
|
|
902
|
+
windowRef.current.style.left = `${parentPos.left}px`;
|
|
903
|
+
windowRef.current.style.top = `${parentPos.bottom + windowHeight < window.innerHeight ? parentPos.bottom : Math.max(0, parentPos.top - windowHeight)}px`;
|
|
904
|
+
windowRef.current.style.transform = "";
|
|
905
|
+
windowPos.current = {
|
|
906
|
+
x: 0,
|
|
907
|
+
y: 0
|
|
908
|
+
};
|
|
833
909
|
checkPosition();
|
|
834
|
-
|
|
835
|
-
|
|
910
|
+
// Update z-index and make visible - use startTransition
|
|
911
|
+
const maxZ = $b5e8657823def5be$var$getMaxZIndex(minZIndex);
|
|
912
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
913
|
+
startTransition(()=>{
|
|
914
|
+
setZIndex(maxZ + 1);
|
|
915
|
+
setWindowVisible(true);
|
|
916
|
+
});
|
|
917
|
+
}
|
|
836
918
|
}, [
|
|
919
|
+
windowInDOM,
|
|
920
|
+
windowVisible,
|
|
921
|
+
visible,
|
|
837
922
|
checkPosition,
|
|
923
|
+
minZIndex,
|
|
838
924
|
onOpen,
|
|
839
|
-
|
|
840
|
-
visible,
|
|
841
|
-
windowInDOM,
|
|
842
|
-
windowVisible
|
|
925
|
+
startTransition
|
|
843
926
|
]);
|
|
844
927
|
// Cleanup effect to remove event listeners on unmount
|
|
845
928
|
(0, $duWW8$useEffect)(()=>{
|
|
@@ -935,40 +1018,7 @@ $b5e8657823def5be$export$1af8984c69ba1b24.displayName = "ContextWindow";
|
|
|
935
1018
|
|
|
936
1019
|
|
|
937
1020
|
|
|
938
|
-
const $17c46b9e6a2eb66e$var$SESSION_KEY = "context-menu.ContextWindowStack.rendered";
|
|
939
|
-
const $17c46b9e6a2eb66e$export$9f37482ccd50dad2 = ({ children: children })=>{
|
|
940
|
-
(0, $duWW8$useEffect)(()=>{
|
|
941
|
-
const doWarn = ()=>console.warn("ContextWindowStack is deprecated and no longer required. ContextWindow now manages z-index automatically. Please remove the ContextWindowStack wrapper from your code.");
|
|
942
|
-
try {
|
|
943
|
-
// Prefer sessionStorage so the warning lasts for the browser session.
|
|
944
|
-
if (typeof window !== "undefined" && window.sessionStorage) {
|
|
945
|
-
const already = window.sessionStorage.getItem($17c46b9e6a2eb66e$var$SESSION_KEY);
|
|
946
|
-
if (!already) {
|
|
947
|
-
window.sessionStorage.setItem($17c46b9e6a2eb66e$var$SESSION_KEY, "1");
|
|
948
|
-
doWarn();
|
|
949
|
-
}
|
|
950
|
-
return;
|
|
951
|
-
}
|
|
952
|
-
} catch (e) {
|
|
953
|
-
// sessionStorage may be unavailable (privacy mode). Fall through to global fallback.
|
|
954
|
-
}
|
|
955
|
-
// Fallback: use a global flag for environments where sessionStorage isn't available.
|
|
956
|
-
const g = globalThis;
|
|
957
|
-
if (!g.__ContextWindowStackRendered) {
|
|
958
|
-
g.__ContextWindowStackRendered = true;
|
|
959
|
-
doWarn();
|
|
960
|
-
}
|
|
961
|
-
}, []);
|
|
962
|
-
return /*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$Fragment), {
|
|
963
|
-
children: children
|
|
964
|
-
});
|
|
965
|
-
};
|
|
966
|
-
$17c46b9e6a2eb66e$export$9f37482ccd50dad2.displayName = "ContextWindowStack";
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
1021
|
|
|
972
1022
|
|
|
973
|
-
export {$62873e7e5aeec7f1$export$77bf000da9303d1 as AutoHeight, $c3e82278b501f10c$export$d4ebdd58e04c6ace as ClickForMenu, $567ed433af94513f$export$8dc6765e8be191c7 as ContextMenu, $1e1c1e9e0b943830$export$ed4f9641643dc7e4 as ContextMenuHandler, $b5e8657823def5be$export$1af8984c69ba1b24 as ContextWindow
|
|
1023
|
+
export {$62873e7e5aeec7f1$export$77bf000da9303d1 as AutoHeight, $c3e82278b501f10c$export$d4ebdd58e04c6ace as ClickForMenu, $567ed433af94513f$export$8dc6765e8be191c7 as ContextMenu, $1e1c1e9e0b943830$export$ed4f9641643dc7e4 as ContextMenuHandler, $b5e8657823def5be$export$1af8984c69ba1b24 as ContextWindow};
|
|
974
1024
|
//# sourceMappingURL=main.js.map
|