@asup/context-menu 1.5.0 → 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 CHANGED
@@ -169,9 +169,13 @@ $da5a7b95ca760552$export$664c6d24e3175067 = `aiw-ContextMenu-module-WinFxq-visib
169
169
 
170
170
 
171
171
 
172
- const $d35a356381c44181$export$7e4e6110f96afd7e = ({ entries: entries, toClose: toClose, visible: visible })=>{
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: 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": typeof entry.label === "string" ? entry.label : undefined,
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,15 +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
+ // Check that menu can fit inside the window
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
+ if (ref && typeof ref !== "function" && ref.current instanceof HTMLDivElement) {
254
+ menuHeight = ref.current.offsetHeight;
255
+ menuWidth = ref.current.offsetWidth;
256
+ }
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;
250
259
  return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
251
260
  ref: ref,
252
261
  className: [
@@ -254,8 +263,8 @@ const $5150b66b01c99189$export$8dc6765e8be191c7 = /*#__PURE__*/ (0, $gTuX4$react
254
263
  visible ? (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).visible : (0, (/*@__PURE__*/$parcel$interopDefault($da5a7b95ca760552$exports))).hidden
255
264
  ].filter((c)=>c !== "").join(" "),
256
265
  style: {
257
- top: `${yPos}px`,
258
- left: `${xPos}px`
266
+ top: `${adjustedYPos}px`,
267
+ left: `${adjustedXPos}px`
259
268
  },
260
269
  onContextMenu: (e)=>{
261
270
  e.preventDefault();
@@ -286,18 +295,29 @@ const $a79b75d040e03c92$export$d4ebdd58e04c6ace = (_param)=>{
286
295
  const menuRef = (0, $gTuX4$react.useRef)(null);
287
296
  // Handle click off the menu
288
297
  const handleClick = (0, $gTuX4$react.useCallback)((e)=>{
289
- var _menuRef_current;
290
- 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);
291
299
  }, []);
292
- const removeController = (0, $gTuX4$react.useRef)(new AbortController());
300
+ const removeController = (0, $gTuX4$react.useRef)(null);
301
+ const removeTimeoutRef = (0, $gTuX4$react.useRef)(null);
293
302
  (0, $gTuX4$react.useEffect)(()=>{
294
- if (!menuVisible) {
295
- removeController.current.abort();
303
+ if (!menuVisible && removeTimeoutRef.current === null) {
304
+ // Only create a new controller when scheduling a new timeout
305
+ if (removeController.current) removeController.current.abort();
296
306
  removeController.current = new AbortController();
297
- setTimeout(()=>{
298
- if (!removeController.current.signal.aborted) setMenuInDom(false);
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;
299
312
  }, 300);
300
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
+ };
301
321
  }, [
302
322
  menuVisible
303
323
  ]);
@@ -306,7 +326,7 @@ const $a79b75d040e03c92$export$d4ebdd58e04c6ace = (_param)=>{
306
326
  if (menuInDom) document.addEventListener("mousedown", handleClick);
307
327
  return ()=>{
308
328
  document.removeEventListener("mousedown", handleClick);
309
- removeController.current.abort();
329
+ if (removeController.current) removeController.current.abort();
310
330
  };
311
331
  }, [
312
332
  handleClick,
@@ -323,7 +343,7 @@ const $a79b75d040e03c92$export$d4ebdd58e04c6ace = (_param)=>{
323
343
  e.preventDefault();
324
344
  e.stopPropagation();
325
345
  setTimeout(()=>{
326
- removeController.current.abort();
346
+ if (removeController.current) removeController.current.abort();
327
347
  setMenuVisible(true);
328
348
  setMenuXPos(e.pageX);
329
349
  setMenuYPos(e.pageY);
@@ -475,6 +495,9 @@ $b34598671fff4a77$export$aafc28aea571c4bc.displayName = "LowMenuButton";
475
495
 
476
496
 
477
497
  const $10d1ee4e7fc9bbbd$export$49e8edc8ebca5f25 = ({ entries: entries, visible: visible, xPos: xPos, yPos: yPos, maxWidth: maxWidth })=>{
498
+ // Only show the low menu if it is on the screen
499
+ if (xPos >= window.innerWidth || yPos >= window.innerHeight) return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)((0, $gTuX4$reactjsxruntime.Fragment), {});
500
+ // Show the menu
478
501
  return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
479
502
  className: [
480
503
  (0, (/*@__PURE__*/$parcel$interopDefault($63cdf2819565020c$exports))).lowMenu,
@@ -541,8 +564,9 @@ const $3c568ee547c732c3$export$ed4f9641643dc7e4 = (_param)=>{
541
564
  const [menuInDom, setMenuInDom] = (0, $gTuX4$react.useState)(false);
542
565
  const [mouseOverHandlerDiv, setMouseOverHandlerDiv] = (0, $gTuX4$react.useState)(false);
543
566
  const [mouseOverMenu, setMouseOverMenu] = (0, $gTuX4$react.useState)(false);
567
+ var _divHandlderRef_current_getBoundingClientRect;
544
568
  // Get holder position
545
- const divHandlerPos = divHandlderRef ? (_divHandlderRef_current = divHandlderRef.current) === null || _divHandlderRef_current === void 0 ? void 0 : _divHandlderRef_current.getBoundingClientRect() : null;
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;
546
570
  // Handle click off the menu
547
571
  const handleClick = (0, $gTuX4$react.useCallback)((e)=>{
548
572
  var _menuRef_current;
@@ -708,62 +732,39 @@ $7c5fb3f6c1601913$export$cebbac70b4d99c48 = `aiw-ContextWindow-module-RIIF9a-con
708
732
  $7c5fb3f6c1601913$export$d03a2f3acc60252b = `aiw-ContextWindow-module-RIIF9a-moving`;
709
733
 
710
734
 
711
-
712
-
713
- const $16208d559c772441$export$aff5d0593e3727b0 = /*#__PURE__*/ (0, $gTuX4$react.createContext)(null);
714
- const $16208d559c772441$var$pushToTop = (windowId, minZIndex, windowList, setWindowList)=>{
715
- const otherWindows = windowList.filter((w)=>w.windowId !== windowId).map((w, i)=>({
716
- windowId: w.windowId,
717
- zIndex: minZIndex + i
718
- }));
719
- setWindowList([
720
- ...otherWindows,
721
- {
722
- windowId: windowId,
723
- 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;
724
746
  }
725
- ]);
726
- };
727
- const $16208d559c772441$export$9f37482ccd50dad2 = ({ minZIndex: minZIndex = 1000, children: children })=>{
728
- const [currentWindows, setCurrentWindows] = (0, $gTuX4$react.useState)([]);
729
- return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)($16208d559c772441$export$aff5d0593e3727b0.Provider, {
730
- value: {
731
- currentWindows: currentWindows.map((w)=>({
732
- windowId: w.windowId,
733
- zIndex: minZIndex + w.zIndex
734
- })),
735
- pushToTop: (ret)=>$16208d559c772441$var$pushToTop(ret, minZIndex, currentWindows, setCurrentWindows)
736
- },
737
- children: children
738
747
  });
748
+ return maxZIndex;
739
749
  };
740
- $16208d559c772441$export$9f37482ccd50dad2.displayName = "ContextWindowStack";
741
-
742
-
743
750
  const $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = (_param)=>{
744
- 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, [
745
752
  "id",
746
753
  "visible",
747
754
  "title",
748
755
  "titleElement",
749
756
  "children",
750
757
  "onOpen",
751
- "onClose"
758
+ "onClose",
759
+ "minZIndex"
752
760
  ]);
753
761
  var _rest_style, _rest_style1, _rest_style2, _rest_style3;
754
- const windowStack = (0, $gTuX4$react.useContext)((0, $16208d559c772441$export$aff5d0593e3727b0));
755
- const windowId = (0, $gTuX4$react.useRef)(null);
756
762
  const divRef = (0, $gTuX4$react.useRef)(null);
757
763
  const windowRef = (0, $gTuX4$react.useRef)(null);
758
764
  const [windowInDOM, setWindowInDOM] = (0, $gTuX4$react.useState)(false);
759
765
  const [windowVisible, setWindowVisible] = (0, $gTuX4$react.useState)(false);
760
- const zIndex = (0, $gTuX4$react.useMemo)(()=>{
761
- var _windowStack_currentWindows_find;
762
- var _windowStack_currentWindows_find_zIndex;
763
- 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;
764
- }, [
765
- windowStack === null || windowStack === void 0 ? void 0 : windowStack.currentWindows
766
- ]);
766
+ const [zIndex, setZIndex] = (0, $gTuX4$react.useState)(minZIndex);
767
+ const resizeListenerRef = (0, $gTuX4$react.useRef)(null);
767
768
  // Position
768
769
  const windowPos = (0, $gTuX4$react.useRef)({
769
770
  x: 0,
@@ -792,145 +793,158 @@ const $46fb0088a1bbb6d8$export$1af8984c69ba1b24 = (_param)=>{
792
793
  }, [
793
794
  move
794
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)(()=>{});
795
799
  const mouseUp = (0, $gTuX4$react.useCallback)((e)=>{
796
800
  e.preventDefault();
797
801
  e.stopPropagation();
798
802
  setMoving(false);
799
803
  checkPosition();
800
- document.removeEventListener("mousemove", mouseMove);
801
- document.removeEventListener("mouseup", mouseUp);
802
- window.removeEventListener("resize", checkPosition);
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
+ }
803
810
  if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement)) e.target.style.userSelect = "auto";
804
811
  }, [
805
- checkPosition,
806
- mouseMove
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
807
828
  ]);
808
829
  // Update visibility
809
830
  (0, $gTuX4$react.useEffect)(()=>{
810
- if (windowStack) {
811
- // Visible set, but not in DOM
812
- if (visible && !windowInDOM) setWindowInDOM(true);
813
- else if (visible && windowInDOM && !windowVisible) {
814
- if (!windowId.current) {
815
- const maxWindowId = Math.max(0, ...windowStack.currentWindows.map((w)=>w.windowId));
816
- windowId.current = maxWindowId + 1;
817
- }
818
- windowStack.pushToTop(windowId.current);
819
- setWindowVisible(visible);
820
- onOpen === null || onOpen === void 0 ? void 0 : onOpen();
821
- // Get starting position
822
- if (divRef.current && windowRef.current) {
823
- const parentPos = divRef.current.getBoundingClientRect();
824
- const pos = windowRef.current.getBoundingClientRect();
825
- const windowHeight = pos.bottom - pos.top;
826
- windowRef.current.style.left = `${parentPos.left}px`;
827
- windowRef.current.style.top = `${parentPos.bottom + windowHeight < window.innerHeight ? parentPos.bottom : Math.max(0, parentPos.top - windowHeight)}px`;
828
- windowRef.current.style.transform = "";
829
- windowPos.current = {
830
- x: 0,
831
- y: 0
832
- };
833
- }
834
- checkPosition();
835
- } else if (windowId.current && !visible && windowVisible) setWindowVisible(false);
836
- else if (windowId.current && !visible && windowInDOM) setWindowInDOM(false);
837
- }
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);
838
853
  }, [
839
854
  checkPosition,
840
855
  onOpen,
856
+ pushToTop,
841
857
  visible,
842
858
  windowInDOM,
843
- windowStack,
844
859
  windowVisible
845
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
+ }, []);
846
873
  var _rest_style_minHeight, _rest_style_minWidth, _rest_style_maxHeight, _rest_style_maxWidth;
847
- return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
874
+ return /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
848
875
  className: (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowAnchor,
849
876
  ref: divRef,
850
- children: [
851
- !windowStack && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", (0, $gTuX4$swchelperscjs_object_spread_propscjs._)((0, $gTuX4$swchelperscjs_object_spreadcjs._)({}, rest), {
852
- children: [
853
- process.env.NODE_ENV !== "production" && /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
854
- style: {
855
- backgroundColor: "red",
856
- color: "white",
857
- padding: "8px",
858
- fontSize: "48px"
859
- },
860
- children: "WARNING: No ContextWindowStack found"
861
- }),
862
- children
863
- ]
864
- })),
865
- windowStack && windowInDOM && /*#__PURE__*/ (0, $gTuX4$reactdom.createPortal)(/*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", (0, $gTuX4$swchelperscjs_object_spread_propscjs._)((0, $gTuX4$swchelperscjs_object_spreadcjs._)({}, rest), {
866
- ref: windowRef,
867
- id: id,
868
- className: [
869
- (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindow,
870
- rest.className
871
- ].filter((c)=>c).join(" "),
872
- style: (0, $gTuX4$swchelperscjs_object_spread_propscjs._)((0, $gTuX4$swchelperscjs_object_spreadcjs._)({}, rest.style), {
873
- opacity: moving ? 0.8 : windowVisible ? 1 : 0,
874
- visibility: windowVisible ? "visible" : "hidden",
875
- zIndex: zIndex !== null && zIndex !== void 0 ? zIndex : 1,
876
- 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",
877
- 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",
878
- 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",
879
- 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"
880
- }),
881
- onClickCapture: (e)=>{
882
- var _rest_onClickCapture;
883
- if (windowId.current) windowStack.pushToTop(windowId.current);
884
- (_rest_onClickCapture = rest.onClickCapture) === null || _rest_onClickCapture === void 0 ? void 0 : _rest_onClickCapture.call(rest, e);
885
- },
886
- children: [
887
- /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsxs)("div", {
888
- className: [
889
- (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowTitle,
890
- moving ? (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).moving : ""
891
- ].filter((c)=>c !== "").join(" "),
892
- onMouseDown: (e)=>{
893
- if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement)) e.target.style.userSelect = "none";
894
- setMoving(true);
895
- if (windowId.current) windowStack.pushToTop(windowId.current);
896
- document.addEventListener("mouseup", mouseUp);
897
- document.addEventListener("mousemove", mouseMove);
898
- window.addEventListener("resize", ()=>checkPosition());
899
- },
900
- children: [
901
- /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
902
- className: (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowTitleText,
903
- title: title,
904
- children: titleElement ? titleElement : title
905
- }),
906
- /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
907
- className: (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowTitleClose,
908
- role: "button",
909
- "aria-label": "Close",
910
- onClick: onClose,
911
- title: `Close ${title && title.trim() !== "" ? title : "window"}`,
912
- children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("svg", {
913
- xmlns: "http://www.w3.org/2000/svg",
914
- width: "16",
915
- height: "16",
916
- fill: "currentColor",
917
- viewBox: "0 0 16 16",
918
- children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("path", {
919
- 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"
920
- })
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"
921
935
  })
922
936
  })
923
- ]
924
- }),
925
- /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
926
- className: (0, (/*@__PURE__*/$parcel$interopDefault($7c5fb3f6c1601913$exports))).contextWindowBody,
927
- children: /*#__PURE__*/ (0, $gTuX4$reactjsxruntime.jsx)("div", {
928
- children: children
929
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
930
944
  })
931
- ]
932
- })), document.body)
933
- ]
945
+ })
946
+ ]
947
+ })), document.body)
934
948
  });
935
949
  };
936
950
  $46fb0088a1bbb6d8$export$1af8984c69ba1b24.displayName = "ContextWindow";
@@ -938,6 +952,38 @@ $46fb0088a1bbb6d8$export$1af8984c69ba1b24.displayName = "ContextWindow";
938
952
 
939
953
 
940
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
+
941
987
 
942
988
  $parcel$exportWildcard(module.exports, $a68bd8a6c0fd98c2$exports);
943
989