@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/cjs/main.js
CHANGED
|
@@ -169,9 +169,13 @@ $da5a7b95ca760552$export$664c6d24e3175067 = `aiw-ContextMenu-module-WinFxq-visib
|
|
|
169
169
|
|
|
170
170
|
|
|
171
171
|
|
|
172
|
-
|
|
172
|
+
|
|
173
|
+
const $d35a356381c44181$export$7e4e6110f96afd7e = ({ entries: entries, toClose: toClose })=>{
|
|
174
|
+
const [visible, setVisible] = (0, $gTuX4$react.useState)(false);
|
|
173
175
|
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("span", {
|
|
174
176
|
className: (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).caretHolder,
|
|
177
|
+
onMouseEnter: ()=>setVisible(true),
|
|
178
|
+
onMouseLeave: ()=>setVisible(false),
|
|
175
179
|
children: [
|
|
176
180
|
/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("svg", {
|
|
177
181
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -183,10 +187,10 @@ const $d35a356381c44181$export$7e4e6110f96afd7e = ({ entries: entries, toClose:
|
|
|
183
187
|
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"
|
|
184
188
|
})
|
|
185
189
|
}),
|
|
186
|
-
/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
190
|
+
visible && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
187
191
|
className: (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).subMenu,
|
|
188
192
|
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $5150b66b01c99189$export$8dc6765e8be191c7), {
|
|
189
|
-
visible:
|
|
193
|
+
visible: true,
|
|
190
194
|
entries: entries,
|
|
191
195
|
xPos: 14,
|
|
192
196
|
yPos: -21,
|
|
@@ -201,21 +205,14 @@ $d35a356381c44181$export$7e4e6110f96afd7e.displayName = "ContextSubMenu";
|
|
|
201
205
|
|
|
202
206
|
const $1e1f300656d89038$export$c868ef28d2ba36f1 = ({ entry: entry, toClose: toClose })=>{
|
|
203
207
|
const [target, setTarget] = (0, $gTuX4$react.useState)(null);
|
|
204
|
-
const [subMenuVisible, setSubMenuVisible] = (0, $gTuX4$react.useState)(false);
|
|
205
208
|
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
|
|
206
209
|
className: [
|
|
207
210
|
(0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).contextMenuItem,
|
|
208
211
|
entry.disabled ? (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).disabled : ""
|
|
209
212
|
].filter((c)=>c !== "").join(" "),
|
|
210
|
-
onMouseEnter: ()=>{
|
|
211
|
-
setSubMenuVisible(true);
|
|
212
|
-
},
|
|
213
|
-
onMouseLeave: ()=>{
|
|
214
|
-
setSubMenuVisible(false);
|
|
215
|
-
},
|
|
216
213
|
children: [
|
|
217
214
|
typeof entry.label === "string" ? /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("span", {
|
|
218
|
-
"aria-label":
|
|
215
|
+
"aria-label": entry.label,
|
|
219
216
|
"aria-disabled": entry.disabled,
|
|
220
217
|
className: (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).contextMenuItemLabel,
|
|
221
218
|
onMouseEnter: ()=>{
|
|
@@ -238,24 +235,27 @@ const $1e1f300656d89038$export$c868ef28d2ba36f1 = ({ entry: entry, toClose: toCl
|
|
|
238
235
|
}) : entry.label,
|
|
239
236
|
entry.group && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $d35a356381c44181$export$7e4e6110f96afd7e), {
|
|
240
237
|
toClose: toClose,
|
|
241
|
-
entries: entry.group
|
|
242
|
-
visible: subMenuVisible
|
|
238
|
+
entries: entry.group
|
|
243
239
|
})
|
|
244
240
|
]
|
|
245
241
|
});
|
|
246
242
|
};
|
|
247
243
|
|
|
248
244
|
|
|
245
|
+
// Constants for menu size estimation when ref is not yet available
|
|
246
|
+
const $5150b66b01c99189$var$ESTIMATED_MENU_ITEM_HEIGHT = 34;
|
|
247
|
+
const $5150b66b01c99189$var$ESTIMATED_MENU_PADDING = 4;
|
|
248
|
+
const $5150b66b01c99189$var$ESTIMATED_MENU_WIDTH = 200;
|
|
249
249
|
const $5150b66b01c99189$export$8dc6765e8be191c7 = /*#__PURE__*/ (0, $gTuX4$react.forwardRef)(({ visible: visible, entries: entries, xPos: xPos, yPos: yPos, toClose: toClose }, ref)=>{
|
|
250
250
|
// Check that menu can fit inside the window
|
|
251
|
-
let menuHeight = entries.length *
|
|
252
|
-
let menuWidth =
|
|
251
|
+
let menuHeight = entries.length * $5150b66b01c99189$var$ESTIMATED_MENU_ITEM_HEIGHT + $5150b66b01c99189$var$ESTIMATED_MENU_PADDING;
|
|
252
|
+
let menuWidth = $5150b66b01c99189$var$ESTIMATED_MENU_WIDTH;
|
|
253
253
|
if (ref && typeof ref !== "function" && ref.current instanceof HTMLDivElement) {
|
|
254
254
|
menuHeight = ref.current.offsetHeight;
|
|
255
255
|
menuWidth = ref.current.offsetWidth;
|
|
256
256
|
}
|
|
257
|
-
|
|
258
|
-
|
|
257
|
+
const adjustedYPos = yPos + menuHeight > window.innerHeight ? Math.max(window.innerHeight - menuHeight - $5150b66b01c99189$var$ESTIMATED_MENU_PADDING, 0) : yPos;
|
|
258
|
+
const adjustedXPos = xPos + menuWidth > window.innerWidth ? Math.max(window.innerWidth - menuWidth - $5150b66b01c99189$var$ESTIMATED_MENU_PADDING, 0) : xPos;
|
|
259
259
|
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
260
260
|
ref: ref,
|
|
261
261
|
className: [
|
|
@@ -263,8 +263,8 @@ const $5150b66b01c99189$export$8dc6765e8be191c7 = /*#__PURE__*/ (0, $gTuX4$react
|
|
|
263
263
|
visible ? (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).visible : (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).hidden
|
|
264
264
|
].filter((c)=>c !== "").join(" "),
|
|
265
265
|
style: {
|
|
266
|
-
top: `${
|
|
267
|
-
left: `${
|
|
266
|
+
top: `${adjustedYPos}px`,
|
|
267
|
+
left: `${adjustedXPos}px`
|
|
268
268
|
},
|
|
269
269
|
onContextMenu: (e)=>{
|
|
270
270
|
e.preventDefault();
|
|
@@ -295,18 +295,29 @@ const $a79b75d040e03c92$export$d4ebdd58e04c6ace = (_param)=>{
|
|
|
295
295
|
const menuRef = (0, $gTuX4$react.useRef)(null);
|
|
296
296
|
// Handle click off the menu
|
|
297
297
|
const handleClick = (0, $gTuX4$react.useCallback)((e)=>{
|
|
298
|
-
|
|
299
|
-
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);
|
|
298
|
+
if (menuRef.current && (e.target instanceof Element && !menuRef.current.contains(e.target) || !(e.target instanceof Element))) setMenuInDom(false);
|
|
300
299
|
}, []);
|
|
301
|
-
const removeController = (0, $gTuX4$react.useRef)(
|
|
300
|
+
const removeController = (0, $gTuX4$react.useRef)(null);
|
|
301
|
+
const removeTimeoutRef = (0, $gTuX4$react.useRef)(null);
|
|
302
302
|
(0, $gTuX4$react.useEffect)(()=>{
|
|
303
|
-
if (!menuVisible) {
|
|
304
|
-
|
|
303
|
+
if (!menuVisible && removeTimeoutRef.current === null) {
|
|
304
|
+
// Only create a new controller when scheduling a new timeout
|
|
305
|
+
if (removeController.current) removeController.current.abort();
|
|
305
306
|
removeController.current = new AbortController();
|
|
306
|
-
|
|
307
|
-
|
|
307
|
+
const controller = removeController.current;
|
|
308
|
+
// Set up the timeout with a reference to the current controller
|
|
309
|
+
removeTimeoutRef.current = setTimeout(()=>{
|
|
310
|
+
if (!controller.signal.aborted) setMenuInDom(false);
|
|
311
|
+
removeTimeoutRef.current = null;
|
|
308
312
|
}, 300);
|
|
309
313
|
}
|
|
314
|
+
return ()=>{
|
|
315
|
+
// Clean up on unmount or when menuVisible changes
|
|
316
|
+
if (removeTimeoutRef.current) {
|
|
317
|
+
clearTimeout(removeTimeoutRef.current);
|
|
318
|
+
removeTimeoutRef.current = null;
|
|
319
|
+
}
|
|
320
|
+
};
|
|
310
321
|
}, [
|
|
311
322
|
menuVisible
|
|
312
323
|
]);
|
|
@@ -315,7 +326,7 @@ const $a79b75d040e03c92$export$d4ebdd58e04c6ace = (_param)=>{
|
|
|
315
326
|
if (menuInDom) document.addEventListener("mousedown", handleClick);
|
|
316
327
|
return ()=>{
|
|
317
328
|
document.removeEventListener("mousedown", handleClick);
|
|
318
|
-
removeController.current.abort();
|
|
329
|
+
if (removeController.current) removeController.current.abort();
|
|
319
330
|
};
|
|
320
331
|
}, [
|
|
321
332
|
handleClick,
|
|
@@ -332,7 +343,7 @@ const $a79b75d040e03c92$export$d4ebdd58e04c6ace = (_param)=>{
|
|
|
332
343
|
e.preventDefault();
|
|
333
344
|
e.stopPropagation();
|
|
334
345
|
setTimeout(()=>{
|
|
335
|
-
removeController.current.abort();
|
|
346
|
+
if (removeController.current) removeController.current.abort();
|
|
336
347
|
setMenuVisible(true);
|
|
337
348
|
setMenuXPos(e.pageX);
|
|
338
349
|
setMenuYPos(e.pageY);
|
|
@@ -485,7 +496,7 @@ $b34598671fff4a77$export$aafc28aea571c4bc.displayName = "LowMenuButton";
|
|
|
485
496
|
|
|
486
497
|
const $10d1ee4e7fc9bbbd$export$49e8edc8ebca5f25 = ({ entries: entries, visible: visible, xPos: xPos, yPos: yPos, maxWidth: maxWidth })=>{
|
|
487
498
|
// Only show the low menu if it is on the screen
|
|
488
|
-
if (xPos
|
|
499
|
+
if (xPos >= window.innerWidth || yPos >= window.innerHeight) return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactjsxruntime.Fragment), {});
|
|
489
500
|
// Show the menu
|
|
490
501
|
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
491
502
|
className: [
|
|
@@ -553,8 +564,9 @@ const $3c568ee547c732c3$export$ed4f9641643dc7e4 = (_param)=>{
|
|
|
553
564
|
const [menuInDom, setMenuInDom] = (0, $gTuX4$react.useState)(false);
|
|
554
565
|
const [mouseOverHandlerDiv, setMouseOverHandlerDiv] = (0, $gTuX4$react.useState)(false);
|
|
555
566
|
const [mouseOverMenu, setMouseOverMenu] = (0, $gTuX4$react.useState)(false);
|
|
567
|
+
var _divHandlderRef_current_getBoundingClientRect;
|
|
556
568
|
// Get holder position
|
|
557
|
-
const divHandlerPos =
|
|
569
|
+
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;
|
|
558
570
|
// Handle click off the menu
|
|
559
571
|
const handleClick = (0, $gTuX4$react.useCallback)((e)=>{
|
|
560
572
|
var _menuRef_current;
|
|
@@ -720,62 +732,39 @@ $7c5fb3f6c1601913$export$cebbac70b4d99c48 = `aiw-ContextWindow-module-RIIF9a-con
|
|
|
720
732
|
$7c5fb3f6c1601913$export$d03a2f3acc60252b = `aiw-ContextWindow-module-RIIF9a-moving`;
|
|
721
733
|
|
|
722
734
|
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
const $
|
|
727
|
-
const
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
windowId: windowId,
|
|
735
|
-
zIndex: minZIndex + otherWindows.length
|
|
735
|
+
const $46fb0088a1bbb6d8$export$4f9fb66ac71c7da5 = 3000;
|
|
736
|
+
const $46fb0088a1bbb6d8$var$CONTEXT_WINDOW_DATA_ATTR = "data-context-window";
|
|
737
|
+
// Helper function to get the highest zIndex from all context windows in the DOM
|
|
738
|
+
const $46fb0088a1bbb6d8$var$getMaxZIndex = (componentMinZIndex)=>{
|
|
739
|
+
const windows = document.body.querySelectorAll(`[${$46fb0088a1bbb6d8$var$CONTEXT_WINDOW_DATA_ATTR}]`);
|
|
740
|
+
let maxZIndex = componentMinZIndex - 1;
|
|
741
|
+
windows.forEach((win)=>{
|
|
742
|
+
const zIndexStr = win.style.zIndex;
|
|
743
|
+
if (zIndexStr) {
|
|
744
|
+
const zIndex = parseInt(zIndexStr, 10);
|
|
745
|
+
if (!isNaN(zIndex) && zIndex > maxZIndex) maxZIndex = zIndex;
|
|
736
746
|
}
|
|
737
|
-
]);
|
|
738
|
-
};
|
|
739
|
-
const $16208d559c772441$export$9f37482ccd50dad2 = ({ minZIndex: minZIndex = 1000, children: children })=>{
|
|
740
|
-
const [currentWindows, setCurrentWindows] = (0, $gTuX4$react.useState)([]);
|
|
741
|
-
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)($16208d559c772441$export$aff5d0593e3727b0.Provider, {
|
|
742
|
-
value: {
|
|
743
|
-
currentWindows: currentWindows.map((w)=>({
|
|
744
|
-
windowId: w.windowId,
|
|
745
|
-
zIndex: minZIndex + w.zIndex
|
|
746
|
-
})),
|
|
747
|
-
pushToTop: (ret)=>$16208d559c772441$var$pushToTop(ret, minZIndex, currentWindows, setCurrentWindows)
|
|
748
|
-
},
|
|
749
|
-
children: children
|
|
750
747
|
});
|
|
748
|
+
return maxZIndex;
|
|
751
749
|
};
|
|
752
|
-
$16208d559c772441$export$9f37482ccd50dad2.displayName = "ContextWindowStack";
|
|
753
|
-
|
|
754
|
-
|
|
755
750
|
const $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = (_param)=>{
|
|
756
|
-
var { id: id, visible: visible, title: title, titleElement: titleElement, children: children, onOpen: onOpen, onClose: onClose } = _param, rest = (0, $gTuX4$swchelperscjs_object_without_propertiescjs._)(_param, [
|
|
751
|
+
var { id: id, visible: visible, title: title, titleElement: titleElement, children: children, onOpen: onOpen, onClose: onClose, minZIndex: minZIndex = $46fb0088a1bbb6d8$export$4f9fb66ac71c7da5 } = _param, rest = (0, $gTuX4$swchelperscjs_object_without_propertiescjs._)(_param, [
|
|
757
752
|
"id",
|
|
758
753
|
"visible",
|
|
759
754
|
"title",
|
|
760
755
|
"titleElement",
|
|
761
756
|
"children",
|
|
762
757
|
"onOpen",
|
|
763
|
-
"onClose"
|
|
758
|
+
"onClose",
|
|
759
|
+
"minZIndex"
|
|
764
760
|
]);
|
|
765
761
|
var _rest_style, _rest_style1, _rest_style2, _rest_style3;
|
|
766
|
-
const windowStack = (0, $gTuX4$react.useContext)((0, $16208d559c772441$export$aff5d0593e3727b0));
|
|
767
|
-
const windowId = (0, $gTuX4$react.useRef)(null);
|
|
768
762
|
const divRef = (0, $gTuX4$react.useRef)(null);
|
|
769
763
|
const windowRef = (0, $gTuX4$react.useRef)(null);
|
|
770
764
|
const [windowInDOM, setWindowInDOM] = (0, $gTuX4$react.useState)(false);
|
|
771
765
|
const [windowVisible, setWindowVisible] = (0, $gTuX4$react.useState)(false);
|
|
772
|
-
const zIndex = (0, $gTuX4$react.
|
|
773
|
-
|
|
774
|
-
var _windowStack_currentWindows_find_zIndex;
|
|
775
|
-
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;
|
|
776
|
-
}, [
|
|
777
|
-
windowStack === null || windowStack === void 0 ? void 0 : windowStack.currentWindows
|
|
778
|
-
]);
|
|
766
|
+
const [zIndex, setZIndex] = (0, $gTuX4$react.useState)(minZIndex);
|
|
767
|
+
const resizeListenerRef = (0, $gTuX4$react.useRef)(null);
|
|
779
768
|
// Position
|
|
780
769
|
const windowPos = (0, $gTuX4$react.useRef)({
|
|
781
770
|
x: 0,
|
|
@@ -804,145 +793,158 @@ const $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = (_param)=>{
|
|
|
804
793
|
}, [
|
|
805
794
|
move
|
|
806
795
|
]);
|
|
796
|
+
// Store stable references to mouseMove and mouseUp for cleanup
|
|
797
|
+
const mouseMoveRef = (0, $gTuX4$react.useRef)(mouseMove);
|
|
798
|
+
const mouseUpRef = (0, $gTuX4$react.useRef)(()=>{});
|
|
807
799
|
const mouseUp = (0, $gTuX4$react.useCallback)((e)=>{
|
|
808
800
|
e.preventDefault();
|
|
809
801
|
e.stopPropagation();
|
|
810
802
|
setMoving(false);
|
|
811
803
|
checkPosition();
|
|
812
|
-
document.removeEventListener("mousemove",
|
|
813
|
-
document.removeEventListener("mouseup",
|
|
814
|
-
|
|
804
|
+
document.removeEventListener("mousemove", mouseMoveRef.current);
|
|
805
|
+
document.removeEventListener("mouseup", mouseUpRef.current);
|
|
806
|
+
if (resizeListenerRef.current) {
|
|
807
|
+
window.removeEventListener("resize", resizeListenerRef.current);
|
|
808
|
+
resizeListenerRef.current = null;
|
|
809
|
+
}
|
|
815
810
|
if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement)) e.target.style.userSelect = "auto";
|
|
816
811
|
}, [
|
|
817
|
-
checkPosition
|
|
818
|
-
|
|
812
|
+
checkPosition
|
|
813
|
+
]);
|
|
814
|
+
// Update refs when callbacks change
|
|
815
|
+
(0, $gTuX4$react.useEffect)(()=>{
|
|
816
|
+
mouseMoveRef.current = mouseMove;
|
|
817
|
+
mouseUpRef.current = mouseUp;
|
|
818
|
+
}, [
|
|
819
|
+
mouseMove,
|
|
820
|
+
mouseUp
|
|
821
|
+
]);
|
|
822
|
+
// Helper function to push this window to the top
|
|
823
|
+
const pushToTop = (0, $gTuX4$react.useCallback)(()=>{
|
|
824
|
+
const maxZIndex = $46fb0088a1bbb6d8$var$getMaxZIndex(minZIndex);
|
|
825
|
+
setZIndex(maxZIndex + 1);
|
|
826
|
+
}, [
|
|
827
|
+
minZIndex
|
|
819
828
|
]);
|
|
820
829
|
// Update visibility
|
|
821
830
|
(0, $gTuX4$react.useEffect)(()=>{
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
};
|
|
845
|
-
}
|
|
846
|
-
checkPosition();
|
|
847
|
-
} else if (windowId.current && !visible && windowVisible) setWindowVisible(false);
|
|
848
|
-
else if (windowId.current && !visible && windowInDOM) setWindowInDOM(false);
|
|
849
|
-
}
|
|
831
|
+
// Visible set, but not in DOM
|
|
832
|
+
if (visible && !windowInDOM) setWindowInDOM(true);
|
|
833
|
+
else if (visible && windowInDOM && !windowVisible) {
|
|
834
|
+
pushToTop();
|
|
835
|
+
setWindowVisible(visible);
|
|
836
|
+
onOpen === null || onOpen === void 0 ? void 0 : onOpen();
|
|
837
|
+
// Get starting position
|
|
838
|
+
if (divRef.current && windowRef.current) {
|
|
839
|
+
const parentPos = divRef.current.getBoundingClientRect();
|
|
840
|
+
const pos = windowRef.current.getBoundingClientRect();
|
|
841
|
+
const windowHeight = pos.bottom - pos.top;
|
|
842
|
+
windowRef.current.style.left = `${parentPos.left}px`;
|
|
843
|
+
windowRef.current.style.top = `${parentPos.bottom + windowHeight < window.innerHeight ? parentPos.bottom : Math.max(0, parentPos.top - windowHeight)}px`;
|
|
844
|
+
windowRef.current.style.transform = "";
|
|
845
|
+
windowPos.current = {
|
|
846
|
+
x: 0,
|
|
847
|
+
y: 0
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
checkPosition();
|
|
851
|
+
} else if (!visible && windowVisible) setWindowVisible(false);
|
|
852
|
+
else if (!visible && windowInDOM) setWindowInDOM(false);
|
|
850
853
|
}, [
|
|
851
854
|
checkPosition,
|
|
852
855
|
onOpen,
|
|
856
|
+
pushToTop,
|
|
853
857
|
visible,
|
|
854
858
|
windowInDOM,
|
|
855
|
-
windowStack,
|
|
856
859
|
windowVisible
|
|
857
860
|
]);
|
|
861
|
+
// Cleanup effect to remove event listeners on unmount
|
|
862
|
+
(0, $gTuX4$react.useEffect)(()=>{
|
|
863
|
+
return ()=>{
|
|
864
|
+
// Clean up event listeners if component unmounts while dragging
|
|
865
|
+
document.removeEventListener("mousemove", mouseMoveRef.current);
|
|
866
|
+
document.removeEventListener("mouseup", mouseUpRef.current);
|
|
867
|
+
if (resizeListenerRef.current) {
|
|
868
|
+
window.removeEventListener("resize", resizeListenerRef.current);
|
|
869
|
+
resizeListenerRef.current = null;
|
|
870
|
+
}
|
|
871
|
+
};
|
|
872
|
+
}, []);
|
|
858
873
|
var _rest_style_minHeight, _rest_style_minWidth, _rest_style_maxHeight, _rest_style_maxWidth;
|
|
859
|
-
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.
|
|
874
|
+
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
860
875
|
className: (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowAnchor,
|
|
861
876
|
ref: divRef,
|
|
862
|
-
children:
|
|
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
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
role: "button",
|
|
921
|
-
"aria-label": "Close",
|
|
922
|
-
onClick: onClose,
|
|
923
|
-
title: `Close ${title && title.trim() !== "" ? title : "window"}`,
|
|
924
|
-
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("svg", {
|
|
925
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
926
|
-
width: "16",
|
|
927
|
-
height: "16",
|
|
928
|
-
fill: "currentColor",
|
|
929
|
-
viewBox: "0 0 16 16",
|
|
930
|
-
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("path", {
|
|
931
|
-
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"
|
|
932
|
-
})
|
|
877
|
+
children: windowInDOM && /*#__PURE__*/ (0, $gTuX4$reactdom.createPortal)(/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", (0, $gTuX4$swchelperscjs_object_spread_propscjs._)((0, $gTuX4$swchelperscjs_object_spreadcjs._)({}, rest), {
|
|
878
|
+
ref: windowRef,
|
|
879
|
+
id: id,
|
|
880
|
+
[$46fb0088a1bbb6d8$var$CONTEXT_WINDOW_DATA_ATTR]: "true",
|
|
881
|
+
className: [
|
|
882
|
+
(0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindow,
|
|
883
|
+
rest.className
|
|
884
|
+
].filter((c)=>c).join(" "),
|
|
885
|
+
style: (0, $gTuX4$swchelperscjs_object_spread_propscjs._)((0, $gTuX4$swchelperscjs_object_spreadcjs._)({}, rest.style), {
|
|
886
|
+
opacity: moving ? 0.8 : windowVisible ? 1 : 0,
|
|
887
|
+
visibility: windowVisible ? "visible" : "hidden",
|
|
888
|
+
zIndex: zIndex,
|
|
889
|
+
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",
|
|
890
|
+
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",
|
|
891
|
+
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",
|
|
892
|
+
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"
|
|
893
|
+
}),
|
|
894
|
+
onClickCapture: (e)=>{
|
|
895
|
+
var _rest_onClickCapture;
|
|
896
|
+
pushToTop();
|
|
897
|
+
(_rest_onClickCapture = rest.onClickCapture) === null || _rest_onClickCapture === void 0 ? void 0 : _rest_onClickCapture.call(rest, e);
|
|
898
|
+
},
|
|
899
|
+
children: [
|
|
900
|
+
/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
|
|
901
|
+
className: [
|
|
902
|
+
(0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowTitle,
|
|
903
|
+
moving ? (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).moving : ""
|
|
904
|
+
].filter((c)=>c !== "").join(" "),
|
|
905
|
+
onMouseDown: (e)=>{
|
|
906
|
+
if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement)) e.target.style.userSelect = "none";
|
|
907
|
+
setMoving(true);
|
|
908
|
+
pushToTop();
|
|
909
|
+
document.addEventListener("mouseup", mouseUpRef.current);
|
|
910
|
+
document.addEventListener("mousemove", mouseMoveRef.current);
|
|
911
|
+
const resizeListener = ()=>checkPosition();
|
|
912
|
+
resizeListenerRef.current = resizeListener;
|
|
913
|
+
window.addEventListener("resize", resizeListener);
|
|
914
|
+
},
|
|
915
|
+
children: [
|
|
916
|
+
/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
917
|
+
className: (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowTitleText,
|
|
918
|
+
title: title,
|
|
919
|
+
children: titleElement ? titleElement : title
|
|
920
|
+
}),
|
|
921
|
+
/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
922
|
+
className: (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowTitleClose,
|
|
923
|
+
role: "button",
|
|
924
|
+
"aria-label": "Close",
|
|
925
|
+
onClick: onClose,
|
|
926
|
+
title: `Close ${title && title.trim() !== "" ? title : "window"}`,
|
|
927
|
+
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("svg", {
|
|
928
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
929
|
+
width: "16",
|
|
930
|
+
height: "16",
|
|
931
|
+
fill: "currentColor",
|
|
932
|
+
viewBox: "0 0 16 16",
|
|
933
|
+
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("path", {
|
|
934
|
+
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"
|
|
933
935
|
})
|
|
934
936
|
})
|
|
935
|
-
]
|
|
936
|
-
}),
|
|
937
|
-
/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
938
|
-
className: (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowBody,
|
|
939
|
-
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
940
|
-
children: children
|
|
941
937
|
})
|
|
938
|
+
]
|
|
939
|
+
}),
|
|
940
|
+
/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
941
|
+
className: (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowBody,
|
|
942
|
+
children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
|
|
943
|
+
children: children
|
|
942
944
|
})
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
945
|
+
})
|
|
946
|
+
]
|
|
947
|
+
})), document.body)
|
|
946
948
|
});
|
|
947
949
|
};
|
|
948
950
|
$46fb0088a1bbb6d8$export$1af8984c69ba1b24.displayName = "ContextWindow";
|
|
@@ -950,6 +952,38 @@ $46fb0088a1bbb6d8$export$1af8984c69ba1b24.displayName = "ContextWindow";
|
|
|
950
952
|
|
|
951
953
|
|
|
952
954
|
|
|
955
|
+
const $16208d559c772441$var$SESSION_KEY = "context-menu.ContextWindowStack.rendered";
|
|
956
|
+
const $16208d559c772441$export$9f37482ccd50dad2 = ({ children: children })=>{
|
|
957
|
+
(0, $gTuX4$react.useEffect)(()=>{
|
|
958
|
+
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.");
|
|
959
|
+
try {
|
|
960
|
+
// Prefer sessionStorage so the warning lasts for the browser session.
|
|
961
|
+
if (typeof window !== "undefined" && window.sessionStorage) {
|
|
962
|
+
const already = window.sessionStorage.getItem($16208d559c772441$var$SESSION_KEY);
|
|
963
|
+
if (!already) {
|
|
964
|
+
window.sessionStorage.setItem($16208d559c772441$var$SESSION_KEY, "1");
|
|
965
|
+
doWarn();
|
|
966
|
+
}
|
|
967
|
+
return;
|
|
968
|
+
}
|
|
969
|
+
} catch (e) {
|
|
970
|
+
// sessionStorage may be unavailable (privacy mode). Fall through to global fallback.
|
|
971
|
+
}
|
|
972
|
+
// Fallback: use a global flag for environments where sessionStorage isn't available.
|
|
973
|
+
const g = globalThis;
|
|
974
|
+
if (!g.__ContextWindowStackRendered) {
|
|
975
|
+
g.__ContextWindowStackRendered = true;
|
|
976
|
+
doWarn();
|
|
977
|
+
}
|
|
978
|
+
}, []);
|
|
979
|
+
return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactjsxruntime.Fragment), {
|
|
980
|
+
children: children
|
|
981
|
+
});
|
|
982
|
+
};
|
|
983
|
+
$16208d559c772441$export$9f37482ccd50dad2.displayName = "ContextWindowStack";
|
|
984
|
+
|
|
985
|
+
|
|
986
|
+
|
|
953
987
|
|
|
954
988
|
$parcel$exportWildcard(module.exports, $a68bd8a6c0fd98c2$exports);
|
|
955
989
|
|