@linzjs/windows 16.1.0 → 16.3.0

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/index.js CHANGED
@@ -2023,7 +2023,9 @@ const NoContextError$2 = () => {
2023
2023
  const LuiModalAsyncInstanceContext = createContext({
2024
2024
  ownerRef: { current: null },
2025
2025
  close: NoContextError$2,
2026
- resolve: NoContextError$2
2026
+ resolve: NoContextError$2,
2027
+ isModalInstance: false,
2028
+ getOwnerWindow: () => window
2027
2029
  });
2028
2030
 
2029
2031
  const LuiModalAsync = ({
@@ -2238,7 +2240,9 @@ const LuiModalAsyncContextProvider = ({ children }) => {
2238
2240
  value: {
2239
2241
  ownerRef: modalInstance.ownerRef,
2240
2242
  close: () => modalInstance.resolve(void 0),
2241
- resolve: modalInstance.resolve
2243
+ resolve: modalInstance.resolve,
2244
+ isModalInstance: true,
2245
+ getOwnerWindow: () => modalInstance.ownerRef.current?.ownerDocument.defaultView ?? window
2242
2246
  },
2243
2247
  children: portalOwners(modalInstance).map(
2244
2248
  (element) => createPortal(/* @__PURE__ */ jsx(Fragment, { children: modalInstance.componentInstance }), element)
@@ -2253,50 +2257,6 @@ const LuiModalAsyncContextProvider = ({ children }) => {
2253
2257
  );
2254
2258
  };
2255
2259
 
2256
- const NoContext = () => {
2257
- console.error("Missing PanelContext Provider");
2258
- return void 0;
2259
- };
2260
- const PanelsContext = createContext({
2261
- openPanels: /* @__PURE__ */ new Set(),
2262
- hasOpenPanel: () => false,
2263
- openPanel: NoContext,
2264
- closePanel: NoContext,
2265
- hidePanel: NoContext,
2266
- hideAllPanels: NoContext,
2267
- unhidePanel: NoContext,
2268
- unhideAllPanels: NoContext,
2269
- hasHiddenPanel: NoContext,
2270
- bringPanelToFront: NoContext,
2271
- dockElements: {},
2272
- setDockElement: NoContext,
2273
- nextStackPosition: () => ({ x: 0, y: 0 })
2274
- });
2275
-
2276
- const OpenPanelButton = ({
2277
- buttonText,
2278
- testId,
2279
- uniqueId = buttonText,
2280
- ...openPanelOptions
2281
- }) => {
2282
- const { openPanel, closePanel, hidePanel, unhidePanel, hasOpenPanel, hasHiddenPanel } = useContext(PanelsContext);
2283
- const open = hasOpenPanel(uniqueId);
2284
- const hidden = hasHiddenPanel(uniqueId);
2285
- return /* @__PURE__ */ jsxs("div", { children: [
2286
- /* @__PURE__ */ jsxs("b", { children: [
2287
- buttonText,
2288
- " ",
2289
- open ? "(Open)" : ""
2290
- ] }),
2291
- /* @__PURE__ */ jsx("br", {}),
2292
- !open && /* @__PURE__ */ jsx("button", { "data-testid": testId + "Open", onClick: () => openPanel({ uniqueId, ...openPanelOptions }), children: "Open" }),
2293
- open && /* @__PURE__ */ jsxs(Fragment, { children: [
2294
- /* @__PURE__ */ jsx("button", { "data-testid": testId + "Close", onClick: () => closePanel(uniqueId), children: "Close" }),
2295
- hidden ? /* @__PURE__ */ jsx("button", { "data-testid": testId + "Unhide", onClick: () => unhidePanel(uniqueId), children: "Unhide" }) : /* @__PURE__ */ jsx("button", { "data-testid": testId + "Hide", onClick: () => hidePanel(uniqueId), children: "Hide" })
2296
- ] })
2297
- ] });
2298
- };
2299
-
2300
2260
  const NoContextError$1 = () => {
2301
2261
  console.error("Missing PanelInstanceContext Provider");
2302
2262
  };
@@ -2315,7 +2275,29 @@ const PanelInstanceContext = createContext({
2315
2275
  dockId: void 0,
2316
2276
  panelPoppedOut: false,
2317
2277
  zIndex: 0,
2318
- hidden: false
2278
+ hidden: false,
2279
+ isPanelInstance: false,
2280
+ getOwnerWindow: () => window
2281
+ });
2282
+
2283
+ const NoContext = () => {
2284
+ console.error("Missing PanelContext Provider");
2285
+ return void 0;
2286
+ };
2287
+ const PanelsContext = createContext({
2288
+ openPanels: /* @__PURE__ */ new Set(),
2289
+ hasOpenPanel: () => false,
2290
+ openPanel: NoContext,
2291
+ closePanel: NoContext,
2292
+ hidePanel: NoContext,
2293
+ hideAllPanels: NoContext,
2294
+ unhidePanel: NoContext,
2295
+ unhideAllPanels: NoContext,
2296
+ hasHiddenPanel: NoContext,
2297
+ bringPanelToFront: NoContext,
2298
+ dockElements: {},
2299
+ setDockElement: NoContext,
2300
+ nextStackPosition: () => ({ x: 0, y: 0 })
2319
2301
  });
2320
2302
 
2321
2303
  function getDefaultExportFromCjs (x) {
@@ -7181,7 +7163,9 @@ const PanelInline = forwardRef(function PanelInline2({ title, className, width,
7181
7163
  undock: () => {
7182
7164
  },
7183
7165
  panelPoppedOut: false,
7184
- bounds: void 0
7166
+ bounds: void 0,
7167
+ isPanelInstance: true,
7168
+ getOwnerWindow: () => window
7185
7169
  },
7186
7170
  children: /* @__PURE__ */ jsx("div", { ref, className: clsx("WindowPanel", className), title, style: { width, height }, children })
7187
7171
  }
@@ -7236,7 +7220,9 @@ const PanelInstanceContextProvider = ({
7236
7220
  dockId,
7237
7221
  dock,
7238
7222
  undock,
7239
- hidden
7223
+ hidden,
7224
+ isPanelInstance: true,
7225
+ getOwnerWindow: () => panelInstance.window ?? window
7240
7226
  },
7241
7227
  children
7242
7228
  }
@@ -7474,10 +7460,21 @@ const LuiModalAsyncMain = ({ children }) => /* @__PURE__ */ jsx("div", { classNa
7474
7460
 
7475
7461
  const useShowAsyncModal = () => {
7476
7462
  const { showModal } = useContext(LuiModalAsyncContext);
7463
+ const panelInstanceContext = useContext(PanelInstanceContext);
7464
+ const modalInstanceContext = useContext(LuiModalAsyncInstanceContext);
7477
7465
  const modalOwnerRef = useRef(document.body);
7478
7466
  const showModalAsync = useCallback(
7479
- (component, args, props) => showModal(props?.showOnAllWindows ? openModalOnAllWindows : modalOwnerRef, component, args, props),
7480
- [showModal]
7467
+ (component, args, props) => {
7468
+ if (!props?.showOnAllWindows) {
7469
+ if (modalInstanceContext.isModalInstance) {
7470
+ modalOwnerRef.current = modalInstanceContext.getOwnerWindow().document.body;
7471
+ } else if (panelInstanceContext.isPanelInstance) {
7472
+ modalOwnerRef.current = panelInstanceContext.getOwnerWindow().document.body;
7473
+ }
7474
+ }
7475
+ return showModal(props?.showOnAllWindows ? openModalOnAllWindows : modalOwnerRef, component, args, props);
7476
+ },
7477
+ [showModal, panelInstanceContext, modalInstanceContext]
7481
7478
  );
7482
7479
  return useMemo(
7483
7480
  () => ({
@@ -8010,5 +8007,5 @@ const focusNextRibbonButton = () => {
8010
8007
  button?.focus();
8011
8008
  };
8012
8009
 
8013
- export { ButtonIconHorizontalGroup, ButtonIconSeparator, ButtonIconVerticalGroup, CopyableText, LuiModalAsync, LuiModalAsyncButtonContinue, LuiModalAsyncButtonDismiss, LuiModalAsyncButtonGroup, LuiModalAsyncContent, LuiModalAsyncContext, LuiModalAsyncContextProvider, LuiModalAsyncHeader, LuiModalAsyncInstanceContext, LuiModalAsyncMain, LuiModalDontShowSessionCheck, LuiModalDontShowSessionRemove, LuiModalDontShowSessionSet, LuiModalPrefab, LuiModalUpload, OpenPanelButton, OpenPanelIcon, Panel, PanelContent, PanelContext, PanelDock, PanelFooter, PanelHeader, PanelHeaderButton, PanelInline, PanelInstanceContext, PanelInstanceContextProvider, PanelsContext, PanelsContextProvider, RibbonButton, RibbonButtonLink, RibbonButtonOpenPanel, RibbonButtonSlider, RibbonButtonSliderContext, RibbonContainer, RibbonMenu, RibbonMenuContext, RibbonMenuOption, RibbonMenuSeparator, RibbonSeparator, getIconForLevel, openModalOnAllWindows, ribbonSliderAlignments, tabToNextSiblingElement, tabToPreviousSiblingElement, tabToSiblingElement, useConstFunction, useLuiModalPrefab, useLuiModalUpload, useShowAsyncModal };
8010
+ export { ButtonIconHorizontalGroup, ButtonIconSeparator, ButtonIconVerticalGroup, CopyableText, LuiModalAsync, LuiModalAsyncButtonContinue, LuiModalAsyncButtonDismiss, LuiModalAsyncButtonGroup, LuiModalAsyncContent, LuiModalAsyncContext, LuiModalAsyncContextProvider, LuiModalAsyncHeader, LuiModalAsyncInstanceContext, LuiModalAsyncMain, LuiModalDontShowSessionCheck, LuiModalDontShowSessionRemove, LuiModalDontShowSessionSet, LuiModalPrefab, LuiModalUpload, OpenPanelIcon, Panel, PanelContent, PanelContext, PanelDock, PanelFooter, PanelHeader, PanelHeaderButton, PanelInline, PanelInstanceContext, PanelInstanceContextProvider, PanelsContext, PanelsContextProvider, RibbonButton, RibbonButtonLink, RibbonButtonOpenPanel, RibbonButtonSlider, RibbonButtonSliderContext, RibbonContainer, RibbonMenu, RibbonMenuContext, RibbonMenuOption, RibbonMenuSeparator, RibbonSeparator, getIconForLevel, openModalOnAllWindows, ribbonSliderAlignments, tabToNextSiblingElement, tabToPreviousSiblingElement, tabToSiblingElement, useConstFunction, useLuiModalPrefab, useLuiModalUpload, useShowAsyncModal };
8014
8011
  //# sourceMappingURL=index.js.map