@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/main.js CHANGED
@@ -152,9 +152,13 @@ $47067f35ca62d4a5$export$664c6d24e3175067 = `aiw-ContextMenu-module-WinFxq-visib
152
152
 
153
153
 
154
154
 
155
- const $6ca59110355c8bf1$export$7e4e6110f96afd7e = ({ entries: entries, toClose: toClose, visible: visible })=>{
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: 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": typeof entry.label === "string" ? entry.label : undefined,
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,15 +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
+ // Check that menu can fit inside the window
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
+ if (ref && typeof ref !== "function" && ref.current instanceof HTMLDivElement) {
237
+ menuHeight = ref.current.offsetHeight;
238
+ menuWidth = ref.current.offsetWidth;
239
+ }
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;
233
242
  return /*#__PURE__*/ (0, $duWW8$jsx)("div", {
234
243
  ref: ref,
235
244
  className: [
@@ -237,8 +246,8 @@ const $567ed433af94513f$export$8dc6765e8be191c7 = /*#__PURE__*/ (0, $duWW8$forwa
237
246
  visible ? (0, (/*@__PURE__*/$parcel$interopDefault($47067f35ca62d4a5$exports))).visible : (0, (/*@__PURE__*/$parcel$interopDefault($47067f35ca62d4a5$exports))).hidden
238
247
  ].filter((c)=>c !== "").join(" "),
239
248
  style: {
240
- top: `${yPos}px`,
241
- left: `${xPos}px`
249
+ top: `${adjustedYPos}px`,
250
+ left: `${adjustedXPos}px`
242
251
  },
243
252
  onContextMenu: (e)=>{
244
253
  e.preventDefault();
@@ -269,18 +278,29 @@ const $c3e82278b501f10c$export$d4ebdd58e04c6ace = (_param)=>{
269
278
  const menuRef = (0, $duWW8$useRef)(null);
270
279
  // Handle click off the menu
271
280
  const handleClick = (0, $duWW8$useCallback)((e)=>{
272
- var _menuRef_current;
273
- 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);
274
282
  }, []);
275
- const removeController = (0, $duWW8$useRef)(new AbortController());
283
+ const removeController = (0, $duWW8$useRef)(null);
284
+ const removeTimeoutRef = (0, $duWW8$useRef)(null);
276
285
  (0, $duWW8$useEffect)(()=>{
277
- if (!menuVisible) {
278
- removeController.current.abort();
286
+ if (!menuVisible && removeTimeoutRef.current === null) {
287
+ // Only create a new controller when scheduling a new timeout
288
+ if (removeController.current) removeController.current.abort();
279
289
  removeController.current = new AbortController();
280
- setTimeout(()=>{
281
- if (!removeController.current.signal.aborted) setMenuInDom(false);
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;
282
295
  }, 300);
283
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
+ };
284
304
  }, [
285
305
  menuVisible
286
306
  ]);
@@ -289,7 +309,7 @@ const $c3e82278b501f10c$export$d4ebdd58e04c6ace = (_param)=>{
289
309
  if (menuInDom) document.addEventListener("mousedown", handleClick);
290
310
  return ()=>{
291
311
  document.removeEventListener("mousedown", handleClick);
292
- removeController.current.abort();
312
+ if (removeController.current) removeController.current.abort();
293
313
  };
294
314
  }, [
295
315
  handleClick,
@@ -306,7 +326,7 @@ const $c3e82278b501f10c$export$d4ebdd58e04c6ace = (_param)=>{
306
326
  e.preventDefault();
307
327
  e.stopPropagation();
308
328
  setTimeout(()=>{
309
- removeController.current.abort();
329
+ if (removeController.current) removeController.current.abort();
310
330
  setMenuVisible(true);
311
331
  setMenuXPos(e.pageX);
312
332
  setMenuYPos(e.pageY);
@@ -458,6 +478,9 @@ $556d6f9158abfc99$export$aafc28aea571c4bc.displayName = "LowMenuButton";
458
478
 
459
479
 
460
480
  const $914758b0c9d59759$export$49e8edc8ebca5f25 = ({ entries: entries, visible: visible, xPos: xPos, yPos: yPos, maxWidth: maxWidth })=>{
481
+ // Only show the low menu if it is on the screen
482
+ if (xPos >= window.innerWidth || yPos >= window.innerHeight) return /*#__PURE__*/ (0, $duWW8$jsx)((0, $duWW8$Fragment), {});
483
+ // Show the menu
461
484
  return /*#__PURE__*/ (0, $duWW8$jsx)("div", {
462
485
  className: [
463
486
  (0, (/*@__PURE__*/$parcel$interopDefault($c7a6ae87165004e6$exports))).lowMenu,
@@ -524,8 +547,9 @@ const $1e1c1e9e0b943830$export$ed4f9641643dc7e4 = (_param)=>{
524
547
  const [menuInDom, setMenuInDom] = (0, $duWW8$useState)(false);
525
548
  const [mouseOverHandlerDiv, setMouseOverHandlerDiv] = (0, $duWW8$useState)(false);
526
549
  const [mouseOverMenu, setMouseOverMenu] = (0, $duWW8$useState)(false);
550
+ var _divHandlderRef_current_getBoundingClientRect;
527
551
  // Get holder position
528
- const divHandlerPos = divHandlderRef ? (_divHandlderRef_current = divHandlderRef.current) === null || _divHandlderRef_current === void 0 ? void 0 : _divHandlderRef_current.getBoundingClientRect() : null;
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;
529
553
  // Handle click off the menu
530
554
  const handleClick = (0, $duWW8$useCallback)((e)=>{
531
555
  var _menuRef_current;
@@ -691,62 +715,39 @@ $ddf7153c7c69b209$export$cebbac70b4d99c48 = `aiw-ContextWindow-module-RIIF9a-con
691
715
  $ddf7153c7c69b209$export$d03a2f3acc60252b = `aiw-ContextWindow-module-RIIF9a-moving`;
692
716
 
693
717
 
694
-
695
-
696
- const $17c46b9e6a2eb66e$export$aff5d0593e3727b0 = /*#__PURE__*/ (0, $duWW8$createContext)(null);
697
- const $17c46b9e6a2eb66e$var$pushToTop = (windowId, minZIndex, windowList, setWindowList)=>{
698
- const otherWindows = windowList.filter((w)=>w.windowId !== windowId).map((w, i)=>({
699
- windowId: w.windowId,
700
- zIndex: minZIndex + i
701
- }));
702
- setWindowList([
703
- ...otherWindows,
704
- {
705
- windowId: windowId,
706
- 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;
707
729
  }
708
- ]);
709
- };
710
- const $17c46b9e6a2eb66e$export$9f37482ccd50dad2 = ({ minZIndex: minZIndex = 1000, children: children })=>{
711
- const [currentWindows, setCurrentWindows] = (0, $duWW8$useState)([]);
712
- return /*#__PURE__*/ (0, $duWW8$jsx)($17c46b9e6a2eb66e$export$aff5d0593e3727b0.Provider, {
713
- value: {
714
- currentWindows: currentWindows.map((w)=>({
715
- windowId: w.windowId,
716
- zIndex: minZIndex + w.zIndex
717
- })),
718
- pushToTop: (ret)=>$17c46b9e6a2eb66e$var$pushToTop(ret, minZIndex, currentWindows, setCurrentWindows)
719
- },
720
- children: children
721
730
  });
731
+ return maxZIndex;
722
732
  };
723
- $17c46b9e6a2eb66e$export$9f37482ccd50dad2.displayName = "ContextWindowStack";
724
-
725
-
726
733
  const $b5e8657823def5be$export$1af8984c69ba1b24 = (_param)=>{
727
- 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, [
728
735
  "id",
729
736
  "visible",
730
737
  "title",
731
738
  "titleElement",
732
739
  "children",
733
740
  "onOpen",
734
- "onClose"
741
+ "onClose",
742
+ "minZIndex"
735
743
  ]);
736
744
  var _rest_style, _rest_style1, _rest_style2, _rest_style3;
737
- const windowStack = (0, $duWW8$useContext)((0, $17c46b9e6a2eb66e$export$aff5d0593e3727b0));
738
- const windowId = (0, $duWW8$useRef)(null);
739
745
  const divRef = (0, $duWW8$useRef)(null);
740
746
  const windowRef = (0, $duWW8$useRef)(null);
741
747
  const [windowInDOM, setWindowInDOM] = (0, $duWW8$useState)(false);
742
748
  const [windowVisible, setWindowVisible] = (0, $duWW8$useState)(false);
743
- const zIndex = (0, $duWW8$useMemo)(()=>{
744
- var _windowStack_currentWindows_find;
745
- var _windowStack_currentWindows_find_zIndex;
746
- 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;
747
- }, [
748
- windowStack === null || windowStack === void 0 ? void 0 : windowStack.currentWindows
749
- ]);
749
+ const [zIndex, setZIndex] = (0, $duWW8$useState)(minZIndex);
750
+ const resizeListenerRef = (0, $duWW8$useRef)(null);
750
751
  // Position
751
752
  const windowPos = (0, $duWW8$useRef)({
752
753
  x: 0,
@@ -775,145 +776,158 @@ const $b5e8657823def5be$export$1af8984c69ba1b24 = (_param)=>{
775
776
  }, [
776
777
  move
777
778
  ]);
779
+ // Store stable references to mouseMove and mouseUp for cleanup
780
+ const mouseMoveRef = (0, $duWW8$useRef)(mouseMove);
781
+ const mouseUpRef = (0, $duWW8$useRef)(()=>{});
778
782
  const mouseUp = (0, $duWW8$useCallback)((e)=>{
779
783
  e.preventDefault();
780
784
  e.stopPropagation();
781
785
  setMoving(false);
782
786
  checkPosition();
783
- document.removeEventListener("mousemove", mouseMove);
784
- document.removeEventListener("mouseup", mouseUp);
785
- window.removeEventListener("resize", checkPosition);
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
+ }
786
793
  if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement)) e.target.style.userSelect = "auto";
787
794
  }, [
788
- checkPosition,
789
- mouseMove
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
790
811
  ]);
791
812
  // Update visibility
792
813
  (0, $duWW8$useEffect)(()=>{
793
- if (windowStack) {
794
- // Visible set, but not in DOM
795
- if (visible && !windowInDOM) setWindowInDOM(true);
796
- else if (visible && windowInDOM && !windowVisible) {
797
- if (!windowId.current) {
798
- const maxWindowId = Math.max(0, ...windowStack.currentWindows.map((w)=>w.windowId));
799
- windowId.current = maxWindowId + 1;
800
- }
801
- windowStack.pushToTop(windowId.current);
802
- setWindowVisible(visible);
803
- onOpen === null || onOpen === void 0 ? void 0 : onOpen();
804
- // Get starting position
805
- if (divRef.current && windowRef.current) {
806
- const parentPos = divRef.current.getBoundingClientRect();
807
- const pos = windowRef.current.getBoundingClientRect();
808
- const windowHeight = pos.bottom - pos.top;
809
- windowRef.current.style.left = `${parentPos.left}px`;
810
- windowRef.current.style.top = `${parentPos.bottom + windowHeight < window.innerHeight ? parentPos.bottom : Math.max(0, parentPos.top - windowHeight)}px`;
811
- windowRef.current.style.transform = "";
812
- windowPos.current = {
813
- x: 0,
814
- y: 0
815
- };
816
- }
817
- checkPosition();
818
- } else if (windowId.current && !visible && windowVisible) setWindowVisible(false);
819
- else if (windowId.current && !visible && windowInDOM) setWindowInDOM(false);
820
- }
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);
821
836
  }, [
822
837
  checkPosition,
823
838
  onOpen,
839
+ pushToTop,
824
840
  visible,
825
841
  windowInDOM,
826
- windowStack,
827
842
  windowVisible
828
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
+ }, []);
829
856
  var _rest_style_minHeight, _rest_style_minWidth, _rest_style_maxHeight, _rest_style_maxWidth;
830
- return /*#__PURE__*/ (0, $duWW8$jsxs)("div", {
857
+ return /*#__PURE__*/ (0, $duWW8$jsx)("div", {
831
858
  className: (0, (/*@__PURE__*/$parcel$interopDefault($ddf7153c7c69b209$exports))).contextWindowAnchor,
832
859
  ref: divRef,
833
- children: [
834
- !windowStack && /*#__PURE__*/ (0, $duWW8$jsxs)("div", (0, $duWW8$_1)((0, $duWW8$_)({}, rest), {
835
- children: [
836
- process.env.NODE_ENV !== "production" && /*#__PURE__*/ (0, $duWW8$jsx)("div", {
837
- style: {
838
- backgroundColor: "red",
839
- color: "white",
840
- padding: "8px",
841
- fontSize: "48px"
842
- },
843
- children: "WARNING: No ContextWindowStack found"
844
- }),
845
- children
846
- ]
847
- })),
848
- windowStack && windowInDOM && /*#__PURE__*/ (0, $duWW8$createPortal)(/*#__PURE__*/ (0, $duWW8$jsxs)("div", (0, $duWW8$_1)((0, $duWW8$_)({}, rest), {
849
- ref: windowRef,
850
- id: id,
851
- className: [
852
- (0, (/*@__PURE__*/$parcel$interopDefault($ddf7153c7c69b209$exports))).contextWindow,
853
- rest.className
854
- ].filter((c)=>c).join(" "),
855
- style: (0, $duWW8$_1)((0, $duWW8$_)({}, rest.style), {
856
- opacity: moving ? 0.8 : windowVisible ? 1 : 0,
857
- visibility: windowVisible ? "visible" : "hidden",
858
- zIndex: zIndex !== null && zIndex !== void 0 ? zIndex : 1,
859
- 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",
860
- 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",
861
- 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",
862
- 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"
863
- }),
864
- onClickCapture: (e)=>{
865
- var _rest_onClickCapture;
866
- if (windowId.current) windowStack.pushToTop(windowId.current);
867
- (_rest_onClickCapture = rest.onClickCapture) === null || _rest_onClickCapture === void 0 ? void 0 : _rest_onClickCapture.call(rest, e);
868
- },
869
- children: [
870
- /*#__PURE__*/ (0, $duWW8$jsxs)("div", {
871
- className: [
872
- (0, (/*@__PURE__*/$parcel$interopDefault($ddf7153c7c69b209$exports))).contextWindowTitle,
873
- moving ? (0, (/*@__PURE__*/$parcel$interopDefault($ddf7153c7c69b209$exports))).moving : ""
874
- ].filter((c)=>c !== "").join(" "),
875
- onMouseDown: (e)=>{
876
- if (e.target && (e.target instanceof HTMLElement || e.target instanceof SVGElement)) e.target.style.userSelect = "none";
877
- setMoving(true);
878
- if (windowId.current) windowStack.pushToTop(windowId.current);
879
- document.addEventListener("mouseup", mouseUp);
880
- document.addEventListener("mousemove", mouseMove);
881
- window.addEventListener("resize", ()=>checkPosition());
882
- },
883
- children: [
884
- /*#__PURE__*/ (0, $duWW8$jsx)("div", {
885
- className: (0, (/*@__PURE__*/$parcel$interopDefault($ddf7153c7c69b209$exports))).contextWindowTitleText,
886
- title: title,
887
- children: titleElement ? titleElement : title
888
- }),
889
- /*#__PURE__*/ (0, $duWW8$jsx)("div", {
890
- className: (0, (/*@__PURE__*/$parcel$interopDefault($ddf7153c7c69b209$exports))).contextWindowTitleClose,
891
- role: "button",
892
- "aria-label": "Close",
893
- onClick: onClose,
894
- title: `Close ${title && title.trim() !== "" ? title : "window"}`,
895
- children: /*#__PURE__*/ (0, $duWW8$jsx)("svg", {
896
- xmlns: "http://www.w3.org/2000/svg",
897
- width: "16",
898
- height: "16",
899
- fill: "currentColor",
900
- viewBox: "0 0 16 16",
901
- children: /*#__PURE__*/ (0, $duWW8$jsx)("path", {
902
- 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"
903
- })
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"
904
918
  })
905
919
  })
906
- ]
907
- }),
908
- /*#__PURE__*/ (0, $duWW8$jsx)("div", {
909
- className: (0, (/*@__PURE__*/$parcel$interopDefault($ddf7153c7c69b209$exports))).contextWindowBody,
910
- children: /*#__PURE__*/ (0, $duWW8$jsx)("div", {
911
- children: children
912
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
913
927
  })
914
- ]
915
- })), document.body)
916
- ]
928
+ })
929
+ ]
930
+ })), document.body)
917
931
  });
918
932
  };
919
933
  $b5e8657823def5be$export$1af8984c69ba1b24.displayName = "ContextWindow";
@@ -921,6 +935,38 @@ $b5e8657823def5be$export$1af8984c69ba1b24.displayName = "ContextWindow";
921
935
 
922
936
 
923
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
+
924
970
 
925
971
 
926
972