@asup/context-menu 1.5.1 → 1.5.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/dist/cjs/main.js +219 -185
- package/dist/cjs/main.js.map +1 -1
- package/dist/context-menu.d.ts +24 -11
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/main.js +219 -185
- package/dist/main.js.map +1 -1
- package/package.json +11 -6
package/dist/main.js
CHANGED
|
@@ -152,9 +152,13 @@ $47067f35ca62d4a5$export$664c6d24e3175067 = `aiw-ContextMenu-module-WinFxq-visib
|
|
|
152
152
|
|
|
153
153
|
|
|
154
154
|
|
|
155
|
-
|
|
155
|
+
|
|
156
|
+
const $6ca59110355c8bf1$export$7e4e6110f96afd7e = ({ entries: entries, toClose: toClose })=>{
|
|
157
|
+
const [visible, setVisible] = (0, $duWW8$useState)(false);
|
|
156
158
|
return /*#__PURE__*/ (0, $duWW8$jsxs)("span", {
|
|
157
159
|
className: (0, (/*@__PURE__*/$parcel$interopDefault($47067f35ca62d4a5$exports))).caretHolder,
|
|
160
|
+
onMouseEnter: ()=>setVisible(true),
|
|
161
|
+
onMouseLeave: ()=>setVisible(false),
|
|
158
162
|
children: [
|
|
159
163
|
/*#__PURE__*/ (0, $duWW8$jsx)("svg", {
|
|
160
164
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -166,10 +170,10 @@ const $6ca59110355c8bf1$export$7e4e6110f96afd7e = ({ entries: entries, toClose:
|
|
|
166
170
|
d: "m12.14 8.753-5.482 4.796c-.646.566-1.658.106-1.658-.753V3.204a1 1 0 0 1 1.659-.753l5.48 4.796a1 1 0 0 1 0 1.506z"
|
|
167
171
|
})
|
|
168
172
|
}),
|
|
169
|
-
/*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
173
|
+
visible && /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
170
174
|
className: (0, (/*@__PURE__*/$parcel$interopDefault($47067f35ca62d4a5$exports))).subMenu,
|
|
171
175
|
children: /*#__PURE__*/ (0, $duWW8$jsx)((0, $567ed433af94513f$export$8dc6765e8be191c7), {
|
|
172
|
-
visible:
|
|
176
|
+
visible: true,
|
|
173
177
|
entries: entries,
|
|
174
178
|
xPos: 14,
|
|
175
179
|
yPos: -21,
|
|
@@ -184,21 +188,14 @@ $6ca59110355c8bf1$export$7e4e6110f96afd7e.displayName = "ContextSubMenu";
|
|
|
184
188
|
|
|
185
189
|
const $813754bb7a4251f1$export$c868ef28d2ba36f1 = ({ entry: entry, toClose: toClose })=>{
|
|
186
190
|
const [target, setTarget] = (0, $duWW8$useState)(null);
|
|
187
|
-
const [subMenuVisible, setSubMenuVisible] = (0, $duWW8$useState)(false);
|
|
188
191
|
return /*#__PURE__*/ (0, $duWW8$jsxs)("div", {
|
|
189
192
|
className: [
|
|
190
193
|
(0, (/*@__PURE__*/$parcel$interopDefault($47067f35ca62d4a5$exports))).contextMenuItem,
|
|
191
194
|
entry.disabled ? (0, (/*@__PURE__*/$parcel$interopDefault($47067f35ca62d4a5$exports))).disabled : ""
|
|
192
195
|
].filter((c)=>c !== "").join(" "),
|
|
193
|
-
onMouseEnter: ()=>{
|
|
194
|
-
setSubMenuVisible(true);
|
|
195
|
-
},
|
|
196
|
-
onMouseLeave: ()=>{
|
|
197
|
-
setSubMenuVisible(false);
|
|
198
|
-
},
|
|
199
196
|
children: [
|
|
200
197
|
typeof entry.label === "string" ? /*#__PURE__*/ (0, $duWW8$jsx)("span", {
|
|
201
|
-
"aria-label":
|
|
198
|
+
"aria-label": entry.label,
|
|
202
199
|
"aria-disabled": entry.disabled,
|
|
203
200
|
className: (0, (/*@__PURE__*/$parcel$interopDefault($47067f35ca62d4a5$exports))).contextMenuItemLabel,
|
|
204
201
|
onMouseEnter: ()=>{
|
|
@@ -221,24 +218,27 @@ const $813754bb7a4251f1$export$c868ef28d2ba36f1 = ({ entry: entry, toClose: toCl
|
|
|
221
218
|
}) : entry.label,
|
|
222
219
|
entry.group && /*#__PURE__*/ (0, $duWW8$jsx)((0, $6ca59110355c8bf1$export$7e4e6110f96afd7e), {
|
|
223
220
|
toClose: toClose,
|
|
224
|
-
entries: entry.group
|
|
225
|
-
visible: subMenuVisible
|
|
221
|
+
entries: entry.group
|
|
226
222
|
})
|
|
227
223
|
]
|
|
228
224
|
});
|
|
229
225
|
};
|
|
230
226
|
|
|
231
227
|
|
|
228
|
+
// Constants for menu size estimation when ref is not yet available
|
|
229
|
+
const $567ed433af94513f$var$ESTIMATED_MENU_ITEM_HEIGHT = 34;
|
|
230
|
+
const $567ed433af94513f$var$ESTIMATED_MENU_PADDING = 4;
|
|
231
|
+
const $567ed433af94513f$var$ESTIMATED_MENU_WIDTH = 200;
|
|
232
232
|
const $567ed433af94513f$export$8dc6765e8be191c7 = /*#__PURE__*/ (0, $duWW8$forwardRef)(({ visible: visible, entries: entries, xPos: xPos, yPos: yPos, toClose: toClose }, ref)=>{
|
|
233
233
|
// Check that menu can fit inside the window
|
|
234
|
-
let menuHeight = entries.length *
|
|
235
|
-
let menuWidth =
|
|
234
|
+
let menuHeight = entries.length * $567ed433af94513f$var$ESTIMATED_MENU_ITEM_HEIGHT + $567ed433af94513f$var$ESTIMATED_MENU_PADDING;
|
|
235
|
+
let menuWidth = $567ed433af94513f$var$ESTIMATED_MENU_WIDTH;
|
|
236
236
|
if (ref && typeof ref !== "function" && ref.current instanceof HTMLDivElement) {
|
|
237
237
|
menuHeight = ref.current.offsetHeight;
|
|
238
238
|
menuWidth = ref.current.offsetWidth;
|
|
239
239
|
}
|
|
240
|
-
|
|
241
|
-
|
|
240
|
+
const adjustedYPos = yPos + menuHeight > window.innerHeight ? Math.max(window.innerHeight - menuHeight - $567ed433af94513f$var$ESTIMATED_MENU_PADDING, 0) : yPos;
|
|
241
|
+
const adjustedXPos = xPos + menuWidth > window.innerWidth ? Math.max(window.innerWidth - menuWidth - $567ed433af94513f$var$ESTIMATED_MENU_PADDING, 0) : xPos;
|
|
242
242
|
return /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
243
243
|
ref: ref,
|
|
244
244
|
className: [
|
|
@@ -246,8 +246,8 @@ const $567ed433af94513f$export$8dc6765e8be191c7 = /*#__PURE__*/ (0, $duWW8$forwa
|
|
|
246
246
|
visible ? (0, (/*@__PURE__*/$parcel$interopDefault($47067f35ca62d4a5$exports))).visible : (0, (/*@__PURE__*/$parcel$interopDefault($47067f35ca62d4a5$exports))).hidden
|
|
247
247
|
].filter((c)=>c !== "").join(" "),
|
|
248
248
|
style: {
|
|
249
|
-
top: `${
|
|
250
|
-
left: `${
|
|
249
|
+
top: `${adjustedYPos}px`,
|
|
250
|
+
left: `${adjustedXPos}px`
|
|
251
251
|
},
|
|
252
252
|
onContextMenu: (e)=>{
|
|
253
253
|
e.preventDefault();
|
|
@@ -278,18 +278,29 @@ const $c3e82278b501f10c$export$d4ebdd58e04c6ace = (_param)=>{
|
|
|
278
278
|
const menuRef = (0, $duWW8$useRef)(null);
|
|
279
279
|
// Handle click off the menu
|
|
280
280
|
const handleClick = (0, $duWW8$useCallback)((e)=>{
|
|
281
|
-
|
|
282
|
-
if (menuRef.current && (e.target instanceof Element && !((_menuRef_current = menuRef.current) === null || _menuRef_current === void 0 ? void 0 : _menuRef_current.contains(e.target)) || !(e.target instanceof Element))) setMenuInDom(false);
|
|
281
|
+
if (menuRef.current && (e.target instanceof Element && !menuRef.current.contains(e.target) || !(e.target instanceof Element))) setMenuInDom(false);
|
|
283
282
|
}, []);
|
|
284
|
-
const removeController = (0, $duWW8$useRef)(
|
|
283
|
+
const removeController = (0, $duWW8$useRef)(null);
|
|
284
|
+
const removeTimeoutRef = (0, $duWW8$useRef)(null);
|
|
285
285
|
(0, $duWW8$useEffect)(()=>{
|
|
286
|
-
if (!menuVisible) {
|
|
287
|
-
|
|
286
|
+
if (!menuVisible && removeTimeoutRef.current === null) {
|
|
287
|
+
// Only create a new controller when scheduling a new timeout
|
|
288
|
+
if (removeController.current) removeController.current.abort();
|
|
288
289
|
removeController.current = new AbortController();
|
|
289
|
-
|
|
290
|
-
|
|
290
|
+
const controller = removeController.current;
|
|
291
|
+
// Set up the timeout with a reference to the current controller
|
|
292
|
+
removeTimeoutRef.current = setTimeout(()=>{
|
|
293
|
+
if (!controller.signal.aborted) setMenuInDom(false);
|
|
294
|
+
removeTimeoutRef.current = null;
|
|
291
295
|
}, 300);
|
|
292
296
|
}
|
|
297
|
+
return ()=>{
|
|
298
|
+
// Clean up on unmount or when menuVisible changes
|
|
299
|
+
if (removeTimeoutRef.current) {
|
|
300
|
+
clearTimeout(removeTimeoutRef.current);
|
|
301
|
+
removeTimeoutRef.current = null;
|
|
302
|
+
}
|
|
303
|
+
};
|
|
293
304
|
}, [
|
|
294
305
|
menuVisible
|
|
295
306
|
]);
|
|
@@ -298,7 +309,7 @@ const $c3e82278b501f10c$export$d4ebdd58e04c6ace = (_param)=>{
|
|
|
298
309
|
if (menuInDom) document.addEventListener("mousedown", handleClick);
|
|
299
310
|
return ()=>{
|
|
300
311
|
document.removeEventListener("mousedown", handleClick);
|
|
301
|
-
removeController.current.abort();
|
|
312
|
+
if (removeController.current) removeController.current.abort();
|
|
302
313
|
};
|
|
303
314
|
}, [
|
|
304
315
|
handleClick,
|
|
@@ -315,7 +326,7 @@ const $c3e82278b501f10c$export$d4ebdd58e04c6ace = (_param)=>{
|
|
|
315
326
|
e.preventDefault();
|
|
316
327
|
e.stopPropagation();
|
|
317
328
|
setTimeout(()=>{
|
|
318
|
-
removeController.current.abort();
|
|
329
|
+
if (removeController.current) removeController.current.abort();
|
|
319
330
|
setMenuVisible(true);
|
|
320
331
|
setMenuXPos(e.pageX);
|
|
321
332
|
setMenuYPos(e.pageY);
|
|
@@ -468,7 +479,7 @@ $556d6f9158abfc99$export$aafc28aea571c4bc.displayName = "LowMenuButton";
|
|
|
468
479
|
|
|
469
480
|
const $914758b0c9d59759$export$49e8edc8ebca5f25 = ({ entries: entries, visible: visible, xPos: xPos, yPos: yPos, maxWidth: maxWidth })=>{
|
|
470
481
|
// Only show the low menu if it is on the screen
|
|
471
|
-
if (xPos
|
|
482
|
+
if (xPos >= window.innerWidth || yPos >= window.innerHeight) return /*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$Fragment), {});
|
|
472
483
|
// Show the menu
|
|
473
484
|
return /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
474
485
|
className: [
|
|
@@ -536,8 +547,9 @@ const $1e1c1e9e0b943830$export$ed4f9641643dc7e4 = (_param)=>{
|
|
|
536
547
|
const [menuInDom, setMenuInDom] = (0, $duWW8$useState)(false);
|
|
537
548
|
const [mouseOverHandlerDiv, setMouseOverHandlerDiv] = (0, $duWW8$useState)(false);
|
|
538
549
|
const [mouseOverMenu, setMouseOverMenu] = (0, $duWW8$useState)(false);
|
|
550
|
+
var _divHandlderRef_current_getBoundingClientRect;
|
|
539
551
|
// Get holder position
|
|
540
|
-
const divHandlerPos =
|
|
552
|
+
const divHandlerPos = (_divHandlderRef_current_getBoundingClientRect = (_divHandlderRef_current = divHandlderRef.current) === null || _divHandlderRef_current === void 0 ? void 0 : _divHandlderRef_current.getBoundingClientRect()) !== null && _divHandlderRef_current_getBoundingClientRect !== void 0 ? _divHandlderRef_current_getBoundingClientRect : null;
|
|
541
553
|
// Handle click off the menu
|
|
542
554
|
const handleClick = (0, $duWW8$useCallback)((e)=>{
|
|
543
555
|
var _menuRef_current;
|
|
@@ -703,62 +715,39 @@ $ddf7153c7c69b209$export$cebbac70b4d99c48 = `aiw-ContextWindow-module-RIIF9a-con
|
|
|
703
715
|
$ddf7153c7c69b209$export$d03a2f3acc60252b = `aiw-ContextWindow-module-RIIF9a-moving`;
|
|
704
716
|
|
|
705
717
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
const $
|
|
710
|
-
const
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
windowId: windowId,
|
|
718
|
-
zIndex: minZIndex + otherWindows.length
|
|
718
|
+
const $b5e8657823def5be$export$4f9fb66ac71c7da5 = 3000;
|
|
719
|
+
const $b5e8657823def5be$var$CONTEXT_WINDOW_DATA_ATTR = "data-context-window";
|
|
720
|
+
// Helper function to get the highest zIndex from all context windows in the DOM
|
|
721
|
+
const $b5e8657823def5be$var$getMaxZIndex = (componentMinZIndex)=>{
|
|
722
|
+
const windows = document.body.querySelectorAll(`[${$b5e8657823def5be$var$CONTEXT_WINDOW_DATA_ATTR}]`);
|
|
723
|
+
let maxZIndex = componentMinZIndex - 1;
|
|
724
|
+
windows.forEach((win)=>{
|
|
725
|
+
const zIndexStr = win.style.zIndex;
|
|
726
|
+
if (zIndexStr) {
|
|
727
|
+
const zIndex = parseInt(zIndexStr, 10);
|
|
728
|
+
if (!isNaN(zIndex) && zIndex > maxZIndex) maxZIndex = zIndex;
|
|
719
729
|
}
|
|
720
|
-
]);
|
|
721
|
-
};
|
|
722
|
-
const $17c46b9e6a2eb66e$export$9f37482ccd50dad2 = ({ minZIndex: minZIndex = 1000, children: children })=>{
|
|
723
|
-
const [currentWindows, setCurrentWindows] = (0, $duWW8$useState)([]);
|
|
724
|
-
return /*#__PURE__*/ (0, $duWW8$jsx)($17c46b9e6a2eb66e$export$aff5d0593e3727b0.Provider, {
|
|
725
|
-
value: {
|
|
726
|
-
currentWindows: currentWindows.map((w)=>({
|
|
727
|
-
windowId: w.windowId,
|
|
728
|
-
zIndex: minZIndex + w.zIndex
|
|
729
|
-
})),
|
|
730
|
-
pushToTop: (ret)=>$17c46b9e6a2eb66e$var$pushToTop(ret, minZIndex, currentWindows, setCurrentWindows)
|
|
731
|
-
},
|
|
732
|
-
children: children
|
|
733
730
|
});
|
|
731
|
+
return maxZIndex;
|
|
734
732
|
};
|
|
735
|
-
$17c46b9e6a2eb66e$export$9f37482ccd50dad2.displayName = "ContextWindowStack";
|
|
736
|
-
|
|
737
|
-
|
|
738
733
|
const $b5e8657823def5be$export$1af8984c69ba1b24 = (_param)=>{
|
|
739
|
-
var { id: id, visible: visible, title: title, titleElement: titleElement, children: children, onOpen: onOpen, onClose: onClose } = _param, rest = (0, $duWW8$_2)(_param, [
|
|
734
|
+
var { id: id, visible: visible, title: title, titleElement: titleElement, children: children, onOpen: onOpen, onClose: onClose, minZIndex: minZIndex = $b5e8657823def5be$export$4f9fb66ac71c7da5 } = _param, rest = (0, $duWW8$_2)(_param, [
|
|
740
735
|
"id",
|
|
741
736
|
"visible",
|
|
742
737
|
"title",
|
|
743
738
|
"titleElement",
|
|
744
739
|
"children",
|
|
745
740
|
"onOpen",
|
|
746
|
-
"onClose"
|
|
741
|
+
"onClose",
|
|
742
|
+
"minZIndex"
|
|
747
743
|
]);
|
|
748
744
|
var _rest_style, _rest_style1, _rest_style2, _rest_style3;
|
|
749
|
-
const windowStack = (0, $duWW8$useContext)((0, $17c46b9e6a2eb66e$export$aff5d0593e3727b0));
|
|
750
|
-
const windowId = (0, $duWW8$useRef)(null);
|
|
751
745
|
const divRef = (0, $duWW8$useRef)(null);
|
|
752
746
|
const windowRef = (0, $duWW8$useRef)(null);
|
|
753
747
|
const [windowInDOM, setWindowInDOM] = (0, $duWW8$useState)(false);
|
|
754
748
|
const [windowVisible, setWindowVisible] = (0, $duWW8$useState)(false);
|
|
755
|
-
const zIndex = (0, $duWW8$
|
|
756
|
-
|
|
757
|
-
var _windowStack_currentWindows_find_zIndex;
|
|
758
|
-
return (_windowStack_currentWindows_find_zIndex = windowStack === null || windowStack === void 0 ? void 0 : (_windowStack_currentWindows_find = windowStack.currentWindows.find((w)=>w.windowId === windowId.current)) === null || _windowStack_currentWindows_find === void 0 ? void 0 : _windowStack_currentWindows_find.zIndex) !== null && _windowStack_currentWindows_find_zIndex !== void 0 ? _windowStack_currentWindows_find_zIndex : 1;
|
|
759
|
-
}, [
|
|
760
|
-
windowStack === null || windowStack === void 0 ? void 0 : windowStack.currentWindows
|
|
761
|
-
]);
|
|
749
|
+
const [zIndex, setZIndex] = (0, $duWW8$useState)(minZIndex);
|
|
750
|
+
const resizeListenerRef = (0, $duWW8$useRef)(null);
|
|
762
751
|
// Position
|
|
763
752
|
const windowPos = (0, $duWW8$useRef)({
|
|
764
753
|
x: 0,
|
|
@@ -787,145 +776,158 @@ const $b5e8657823def5be$export$1af8984c69ba1b24 = (_param)=>{
|
|
|
787
776
|
}, [
|
|
788
777
|
move
|
|
789
778
|
]);
|
|
779
|
+
// Store stable references to mouseMove and mouseUp for cleanup
|
|
780
|
+
const mouseMoveRef = (0, $duWW8$useRef)(mouseMove);
|
|
781
|
+
const mouseUpRef = (0, $duWW8$useRef)(()=>{});
|
|
790
782
|
const mouseUp = (0, $duWW8$useCallback)((e)=>{
|
|
791
783
|
e.preventDefault();
|
|
792
784
|
e.stopPropagation();
|
|
793
785
|
setMoving(false);
|
|
794
786
|
checkPosition();
|
|
795
|
-
document.removeEventListener("mousemove",
|
|
796
|
-
document.removeEventListener("mouseup",
|
|
797
|
-
|
|
787
|
+
document.removeEventListener("mousemove", mouseMoveRef.current);
|
|
788
|
+
document.removeEventListener("mouseup", mouseUpRef.current);
|
|
789
|
+
if (resizeListenerRef.current) {
|
|
790
|
+
window.removeEventListener("resize", resizeListenerRef.current);
|
|
791
|
+
resizeListenerRef.current = null;
|
|
792
|
+
}
|
|
798
793
|
if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement)) e.target.style.userSelect = "auto";
|
|
799
794
|
}, [
|
|
800
|
-
checkPosition
|
|
801
|
-
|
|
795
|
+
checkPosition
|
|
796
|
+
]);
|
|
797
|
+
// Update refs when callbacks change
|
|
798
|
+
(0, $duWW8$useEffect)(()=>{
|
|
799
|
+
mouseMoveRef.current = mouseMove;
|
|
800
|
+
mouseUpRef.current = mouseUp;
|
|
801
|
+
}, [
|
|
802
|
+
mouseMove,
|
|
803
|
+
mouseUp
|
|
804
|
+
]);
|
|
805
|
+
// Helper function to push this window to the top
|
|
806
|
+
const pushToTop = (0, $duWW8$useCallback)(()=>{
|
|
807
|
+
const maxZIndex = $b5e8657823def5be$var$getMaxZIndex(minZIndex);
|
|
808
|
+
setZIndex(maxZIndex + 1);
|
|
809
|
+
}, [
|
|
810
|
+
minZIndex
|
|
802
811
|
]);
|
|
803
812
|
// Update visibility
|
|
804
813
|
(0, $duWW8$useEffect)(()=>{
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
};
|
|
828
|
-
}
|
|
829
|
-
checkPosition();
|
|
830
|
-
} else if (windowId.current && !visible && windowVisible) setWindowVisible(false);
|
|
831
|
-
else if (windowId.current && !visible && windowInDOM) setWindowInDOM(false);
|
|
832
|
-
}
|
|
814
|
+
// Visible set, but not in DOM
|
|
815
|
+
if (visible && !windowInDOM) setWindowInDOM(true);
|
|
816
|
+
else if (visible && windowInDOM && !windowVisible) {
|
|
817
|
+
pushToTop();
|
|
818
|
+
setWindowVisible(visible);
|
|
819
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
820
|
+
// Get starting position
|
|
821
|
+
if (divRef.current && windowRef.current) {
|
|
822
|
+
const parentPos = divRef.current.getBoundingClientRect();
|
|
823
|
+
const pos = windowRef.current.getBoundingClientRect();
|
|
824
|
+
const windowHeight = pos.bottom - pos.top;
|
|
825
|
+
windowRef.current.style.left = `${parentPos.left}px`;
|
|
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
|
+
}
|
|
833
|
+
checkPosition();
|
|
834
|
+
} else if (!visible && windowVisible) setWindowVisible(false);
|
|
835
|
+
else if (!visible && windowInDOM) setWindowInDOM(false);
|
|
833
836
|
}, [
|
|
834
837
|
checkPosition,
|
|
835
838
|
onOpen,
|
|
839
|
+
pushToTop,
|
|
836
840
|
visible,
|
|
837
841
|
windowInDOM,
|
|
838
|
-
windowStack,
|
|
839
842
|
windowVisible
|
|
840
843
|
]);
|
|
844
|
+
// Cleanup effect to remove event listeners on unmount
|
|
845
|
+
(0, $duWW8$useEffect)(()=>{
|
|
846
|
+
return ()=>{
|
|
847
|
+
// Clean up event listeners if component unmounts while dragging
|
|
848
|
+
document.removeEventListener("mousemove", mouseMoveRef.current);
|
|
849
|
+
document.removeEventListener("mouseup", mouseUpRef.current);
|
|
850
|
+
if (resizeListenerRef.current) {
|
|
851
|
+
window.removeEventListener("resize", resizeListenerRef.current);
|
|
852
|
+
resizeListenerRef.current = null;
|
|
853
|
+
}
|
|
854
|
+
};
|
|
855
|
+
}, []);
|
|
841
856
|
var _rest_style_minHeight, _rest_style_minWidth, _rest_style_maxHeight, _rest_style_maxWidth;
|
|
842
|
-
return /*#__PURE__*/ (0, $duWW8$
|
|
857
|
+
return /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
843
858
|
className: (0, (/*@__PURE__*/$parcel$interopDefault($ddf7153c7c69b209$exports))).contextWindowAnchor,
|
|
844
859
|
ref: divRef,
|
|
845
|
-
children:
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
role: "button",
|
|
904
|
-
"aria-label": "Close",
|
|
905
|
-
onClick: onClose,
|
|
906
|
-
title: `Close ${title && title.trim() !== "" ? title : "window"}`,
|
|
907
|
-
children: /*#__PURE__*/ (0, $duWW8$jsx)("svg", {
|
|
908
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
909
|
-
width: "16",
|
|
910
|
-
height: "16",
|
|
911
|
-
fill: "currentColor",
|
|
912
|
-
viewBox: "0 0 16 16",
|
|
913
|
-
children: /*#__PURE__*/ (0, $duWW8$jsx)("path", {
|
|
914
|
-
d: "M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"
|
|
915
|
-
})
|
|
860
|
+
children: windowInDOM && /*#__PURE__*/ (0, $duWW8$createPortal)(/*#__PURE__*/ (0, $duWW8$jsxs)("div", (0, $duWW8$_1)((0, $duWW8$_)({}, rest), {
|
|
861
|
+
ref: windowRef,
|
|
862
|
+
id: id,
|
|
863
|
+
[$b5e8657823def5be$var$CONTEXT_WINDOW_DATA_ATTR]: "true",
|
|
864
|
+
className: [
|
|
865
|
+
(0, (/*@__PURE__*/$parcel$interopDefault($ddf7153c7c69b209$exports))).contextWindow,
|
|
866
|
+
rest.className
|
|
867
|
+
].filter((c)=>c).join(" "),
|
|
868
|
+
style: (0, $duWW8$_1)((0, $duWW8$_)({}, rest.style), {
|
|
869
|
+
opacity: moving ? 0.8 : windowVisible ? 1 : 0,
|
|
870
|
+
visibility: windowVisible ? "visible" : "hidden",
|
|
871
|
+
zIndex: zIndex,
|
|
872
|
+
minHeight: (_rest_style_minHeight = (_rest_style = rest.style) === null || _rest_style === void 0 ? void 0 : _rest_style.minHeight) !== null && _rest_style_minHeight !== void 0 ? _rest_style_minHeight : "150px",
|
|
873
|
+
minWidth: (_rest_style_minWidth = (_rest_style1 = rest.style) === null || _rest_style1 === void 0 ? void 0 : _rest_style1.minWidth) !== null && _rest_style_minWidth !== void 0 ? _rest_style_minWidth : "200px",
|
|
874
|
+
maxHeight: (_rest_style_maxHeight = (_rest_style2 = rest.style) === null || _rest_style2 === void 0 ? void 0 : _rest_style2.maxHeight) !== null && _rest_style_maxHeight !== void 0 ? _rest_style_maxHeight : "1000px",
|
|
875
|
+
maxWidth: (_rest_style_maxWidth = (_rest_style3 = rest.style) === null || _rest_style3 === void 0 ? void 0 : _rest_style3.maxWidth) !== null && _rest_style_maxWidth !== void 0 ? _rest_style_maxWidth : "1000px"
|
|
876
|
+
}),
|
|
877
|
+
onClickCapture: (e)=>{
|
|
878
|
+
var _rest_onClickCapture;
|
|
879
|
+
pushToTop();
|
|
880
|
+
(_rest_onClickCapture = rest.onClickCapture) === null || _rest_onClickCapture === void 0 ? void 0 : _rest_onClickCapture.call(rest, e);
|
|
881
|
+
},
|
|
882
|
+
children: [
|
|
883
|
+
/*#__PURE__*/ (0, $duWW8$jsxs)("div", {
|
|
884
|
+
className: [
|
|
885
|
+
(0, (/*@__PURE__*/$parcel$interopDefault($ddf7153c7c69b209$exports))).contextWindowTitle,
|
|
886
|
+
moving ? (0, (/*@__PURE__*/$parcel$interopDefault($ddf7153c7c69b209$exports))).moving : ""
|
|
887
|
+
].filter((c)=>c !== "").join(" "),
|
|
888
|
+
onMouseDown: (e)=>{
|
|
889
|
+
if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement)) e.target.style.userSelect = "none";
|
|
890
|
+
setMoving(true);
|
|
891
|
+
pushToTop();
|
|
892
|
+
document.addEventListener("mouseup", mouseUpRef.current);
|
|
893
|
+
document.addEventListener("mousemove", mouseMoveRef.current);
|
|
894
|
+
const resizeListener = ()=>checkPosition();
|
|
895
|
+
resizeListenerRef.current = resizeListener;
|
|
896
|
+
window.addEventListener("resize", resizeListener);
|
|
897
|
+
},
|
|
898
|
+
children: [
|
|
899
|
+
/*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
900
|
+
className: (0, (/*@__PURE__*/$parcel$interopDefault($ddf7153c7c69b209$exports))).contextWindowTitleText,
|
|
901
|
+
title: title,
|
|
902
|
+
children: titleElement ? titleElement : title
|
|
903
|
+
}),
|
|
904
|
+
/*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
905
|
+
className: (0, (/*@__PURE__*/$parcel$interopDefault($ddf7153c7c69b209$exports))).contextWindowTitleClose,
|
|
906
|
+
role: "button",
|
|
907
|
+
"aria-label": "Close",
|
|
908
|
+
onClick: onClose,
|
|
909
|
+
title: `Close ${title && title.trim() !== "" ? title : "window"}`,
|
|
910
|
+
children: /*#__PURE__*/ (0, $duWW8$jsx)("svg", {
|
|
911
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
912
|
+
width: "16",
|
|
913
|
+
height: "16",
|
|
914
|
+
fill: "currentColor",
|
|
915
|
+
viewBox: "0 0 16 16",
|
|
916
|
+
children: /*#__PURE__*/ (0, $duWW8$jsx)("path", {
|
|
917
|
+
d: "M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.5.5 0 0 1 0-.708z"
|
|
916
918
|
})
|
|
917
919
|
})
|
|
918
|
-
]
|
|
919
|
-
}),
|
|
920
|
-
/*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
921
|
-
className: (0, (/*@__PURE__*/$parcel$interopDefault($ddf7153c7c69b209$exports))).contextWindowBody,
|
|
922
|
-
children: /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
923
|
-
children: children
|
|
924
920
|
})
|
|
921
|
+
]
|
|
922
|
+
}),
|
|
923
|
+
/*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
924
|
+
className: (0, (/*@__PURE__*/$parcel$interopDefault($ddf7153c7c69b209$exports))).contextWindowBody,
|
|
925
|
+
children: /*#__PURE__*/ (0, $duWW8$jsx)("div", {
|
|
926
|
+
children: children
|
|
925
927
|
})
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
928
|
+
})
|
|
929
|
+
]
|
|
930
|
+
})), document.body)
|
|
929
931
|
});
|
|
930
932
|
};
|
|
931
933
|
$b5e8657823def5be$export$1af8984c69ba1b24.displayName = "ContextWindow";
|
|
@@ -933,6 +935,38 @@ $b5e8657823def5be$export$1af8984c69ba1b24.displayName = "ContextWindow";
|
|
|
933
935
|
|
|
934
936
|
|
|
935
937
|
|
|
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
|
+
|
|
936
970
|
|
|
937
971
|
|
|
938
972
|
|