@mdbase-dev/ui 0.1.39 → 0.1.40

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.
@@ -1,10 +1,26 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { i18n as _i18n } from "@lingui/core";
3
3
  import { useEffect, useEffectEvent, useLayoutEffect, useRef } from "react";
4
+ import { createPortal } from "react-dom";
4
5
  import { useLocaleRevision } from "./i18n.js";
5
6
  import { anchoredPlacement } from "./popover.js";
6
7
  const FOCUSABLE = ':is(button, input, select, textarea, [tabindex="0"]):not(:disabled)';
7
8
  const OPEN_LIST = '[aria-expanded="true"], [role="listbox"], [role="menu"]';
9
+ /**
10
+ * The topmost open modal `<dialog>`, if one is showing. A modal dialog makes everything outside
11
+ * its subtree inert—even a top-layer popover—so a form opened while one is open mounts inside it.
12
+ */
13
+ function activeModalDialog() {
14
+ if (typeof document === "undefined") return null;
15
+ try {
16
+ const modal = document.querySelectorAll("dialog:modal");
17
+ if (modal.length) return modal[modal.length - 1];
18
+ } catch {
19
+ // Fall through when :modal is unsupported.
20
+ }
21
+ const open = document.querySelectorAll('dialog[open][aria-modal="true"]');
22
+ return open.length ? open[open.length - 1] : null;
23
+ }
8
24
  /**
9
25
  * A short form for a record made in passing, beside the place it is made from: its name, then
10
26
  * the fields the app asks for. It opens in the top layer and takes the keyboard until it is
@@ -107,7 +123,7 @@ export function QuickCreate({
107
123
  window.removeEventListener("resize", place);
108
124
  };
109
125
  }, []);
110
- return _jsx("div", {
126
+ const popover = _jsx("div", {
111
127
  ref: ref,
112
128
  className: `mdbase-quick-create mdbase-overlay${className ? ` ${className}` : ""}`,
113
129
  "data-open": true,
@@ -153,4 +169,6 @@ export function QuickCreate({
153
169
  })]
154
170
  })
155
171
  });
172
+ const host = activeModalDialog();
173
+ return host ? createPortal(popover, host) : popover;
156
174
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mdbase-dev/ui",
3
- "version": "0.1.39",
3
+ "version": "0.1.40",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -258,6 +258,6 @@
258
258
  "typecheck": "node scripts/compile-catalogues.mjs && tsc -p tsconfig.json --noEmit"
259
259
  },
260
260
  "mdbaseRelease": {
261
- "commit": "751b7fb0fde87d60b847d4991274906aba1ffd42"
261
+ "commit": "6597d7342d2187562c82d05af6a609643f9c383a"
262
262
  }
263
263
  }