@ariakit/react-core 0.2.8 → 0.2.9

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.
Files changed (211) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/cjs/__chunks/{6UH7OSG5.cjs → 364WU3DX.cjs} +2 -2
  3. package/cjs/__chunks/4CQBSK3W.cjs +46 -0
  4. package/cjs/__chunks/{6UM5H74J.cjs → 6GU25WKL.cjs} +2 -2
  5. package/cjs/__chunks/{4K22VVH6.cjs → 6WLP7YXF.cjs} +2 -2
  6. package/cjs/__chunks/{MJQOSYPH.cjs → 6Y7OJ66S.cjs} +2 -2
  7. package/cjs/__chunks/{HBWDRXN5.cjs → 7BSXU2OL.cjs} +2 -2
  8. package/cjs/__chunks/{JV2X54UE.cjs → BWQVQDGC.cjs} +6 -5
  9. package/cjs/__chunks/{TSZDLL4X.cjs → CEDXB2ML.cjs} +2 -2
  10. package/cjs/__chunks/{LULOLUTN.cjs → DFJJN2WM.cjs} +7 -13
  11. package/cjs/__chunks/{UUHO6ZXS.cjs → EYNBXS3C.cjs} +2 -2
  12. package/cjs/__chunks/{AYLR4G5I.cjs → FIEVSSEV.cjs} +1 -1
  13. package/cjs/__chunks/{7F62IPL4.cjs → FSADYSOP.cjs} +14 -6
  14. package/cjs/__chunks/{QAEK22OL.cjs → G2UKCWYO.cjs} +2 -2
  15. package/cjs/__chunks/{6WWAF5Y2.cjs → GJ2WWSXI.cjs} +2 -2
  16. package/cjs/__chunks/{FMIZNXEA.cjs → GQUXK6V2.cjs} +18 -10
  17. package/cjs/__chunks/{S35Z3MRE.cjs → HM3GZVEF.cjs} +2 -2
  18. package/cjs/__chunks/{5NZUFDNS.cjs → HTXMZNNP.cjs} +4 -4
  19. package/cjs/__chunks/{GZNLXFK3.cjs → HVCML4SE.cjs} +2 -2
  20. package/cjs/__chunks/{QUOAEQQ7.cjs → I4VW4CPQ.cjs} +2 -2
  21. package/cjs/__chunks/{6SZXUPLG.cjs → LGMGD2LT.cjs} +2 -2
  22. package/cjs/__chunks/{K3VYU4RD.cjs → MOOOVIIV.cjs} +2 -2
  23. package/cjs/__chunks/{NRIAM6MC.cjs → O22LNQHS.cjs} +8 -2
  24. package/cjs/__chunks/{FM2UUSFC.cjs → OEERYQSB.cjs} +2 -2
  25. package/cjs/__chunks/{3VAV4ULL.cjs → OZQD6TLQ.cjs} +2 -2
  26. package/cjs/__chunks/{GOWDAADN.cjs → PZBTPQEZ.cjs} +36 -45
  27. package/cjs/__chunks/{MUDM7N7Y.cjs → R32BMUUT.cjs} +2 -2
  28. package/cjs/__chunks/{RYACMEZB.cjs → S2VSVWFY.cjs} +12 -6
  29. package/cjs/__chunks/{47DEI3MG.cjs → SDW7WM6J.cjs} +2 -2
  30. package/cjs/__chunks/{QGYOOPA2.cjs → XIQNHQGW.cjs} +2 -2
  31. package/cjs/__chunks/Z3TLXRS7.cjs +19 -0
  32. package/cjs/__chunks/{RYADB3U4.cjs → ZEDBIWF2.cjs} +2 -2
  33. package/cjs/button/button.cjs +4 -4
  34. package/cjs/checkbox/checkbox.cjs +4 -4
  35. package/cjs/combobox/combobox-cancel.cjs +4 -4
  36. package/cjs/combobox/combobox-disclosure.cjs +6 -6
  37. package/cjs/combobox/combobox-item.cjs +4 -4
  38. package/cjs/combobox/combobox-list.cjs +3 -3
  39. package/cjs/combobox/combobox-popover.cjs +18 -14
  40. package/cjs/combobox/combobox-store.d.ts +1 -0
  41. package/cjs/combobox/combobox.cjs +3 -3
  42. package/cjs/command/command.cjs +3 -3
  43. package/cjs/composite/composite-item.cjs +4 -4
  44. package/cjs/composite/composite-overflow-disclosure.cjs +9 -9
  45. package/cjs/composite/composite-overflow.cjs +16 -12
  46. package/cjs/composite/composite.cjs +3 -3
  47. package/cjs/dialog/dialog-backdrop.cjs +7 -4
  48. package/cjs/dialog/dialog-disclosure.cjs +6 -6
  49. package/cjs/dialog/dialog-dismiss.cjs +5 -5
  50. package/cjs/dialog/dialog.cjs +15 -11
  51. package/cjs/dialog/dialog.d.ts +2 -0
  52. package/cjs/dialog/utils/disable-accessibility-tree-outside.cjs +4 -3
  53. package/cjs/dialog/utils/disable-tree-outside.cjs +5 -4
  54. package/cjs/dialog/utils/is-backdrop.cjs +4 -18
  55. package/cjs/dialog/utils/is-backdrop.d.ts +1 -1
  56. package/cjs/dialog/utils/mark-tree-outside.cjs +4 -3
  57. package/cjs/dialog/utils/orchestrate.cjs +2 -2
  58. package/cjs/dialog/utils/orchestrate.d.ts +2 -7
  59. package/cjs/dialog/utils/use-hide-on-interact-outside.cjs +6 -5
  60. package/cjs/dialog/utils/use-prevent-body-scroll.cjs +4 -3
  61. package/cjs/dialog/utils/use-prevent-body-scroll.d.ts +1 -2
  62. package/cjs/dialog/utils/use-root-dialog.cjs +9 -0
  63. package/cjs/dialog/utils/use-root-dialog.d.ts +8 -0
  64. package/cjs/disclosure/disclosure.cjs +5 -5
  65. package/cjs/focusable/focusable.cjs +2 -2
  66. package/cjs/form/form-checkbox.cjs +4 -4
  67. package/cjs/form/form-input.cjs +2 -2
  68. package/cjs/form/form-push.cjs +4 -4
  69. package/cjs/form/form-radio.cjs +5 -5
  70. package/cjs/form/form-remove.cjs +4 -4
  71. package/cjs/form/form-reset.cjs +4 -4
  72. package/cjs/form/form-submit.cjs +4 -4
  73. package/cjs/hovercard/hovercard-anchor.cjs +3 -3
  74. package/cjs/hovercard/hovercard-disclosure.cjs +6 -6
  75. package/cjs/hovercard/hovercard-dismiss.cjs +7 -7
  76. package/cjs/hovercard/hovercard.cjs +17 -13
  77. package/cjs/menu/menu-bar.cjs +3 -3
  78. package/cjs/menu/menu-button.cjs +9 -9
  79. package/cjs/menu/menu-dismiss.cjs +7 -7
  80. package/cjs/menu/menu-item-checkbox.cjs +7 -7
  81. package/cjs/menu/menu-item-radio.cjs +7 -7
  82. package/cjs/menu/menu-item.cjs +5 -5
  83. package/cjs/menu/menu-list.cjs +4 -4
  84. package/cjs/menu/menu-store.d.ts +1 -0
  85. package/cjs/menu/menu.cjs +19 -16
  86. package/cjs/popover/popover-disclosure.cjs +7 -7
  87. package/cjs/popover/popover-dismiss.cjs +6 -6
  88. package/cjs/popover/popover.cjs +16 -12
  89. package/cjs/radio/radio-group.cjs +3 -3
  90. package/cjs/radio/radio.cjs +5 -5
  91. package/cjs/select/select-item.cjs +4 -4
  92. package/cjs/select/select-list.cjs +4 -4
  93. package/cjs/select/select-popover.cjs +19 -15
  94. package/cjs/select/select-store.d.ts +1 -0
  95. package/cjs/select/select.cjs +7 -7
  96. package/cjs/tab/tab-list.cjs +3 -3
  97. package/cjs/tab/tab-panel.cjs +2 -2
  98. package/cjs/tab/tab.cjs +4 -4
  99. package/cjs/toolbar/toolbar-container.cjs +5 -5
  100. package/cjs/toolbar/toolbar-input.cjs +5 -5
  101. package/cjs/toolbar/toolbar-item.cjs +5 -5
  102. package/cjs/toolbar/toolbar.cjs +3 -3
  103. package/cjs/tooltip/tooltip-anchor.cjs +3 -3
  104. package/cjs/tooltip/tooltip.cjs +17 -13
  105. package/cjs/tsconfig.build.tsbuildinfo +1 -1
  106. package/dialog/utils/use-root-dialog/package.json +8 -0
  107. package/esm/__chunks/{IVDTLBEM.js → 2NDM3R77.js} +1 -1
  108. package/esm/__chunks/{J3XSDPNL.js → 6ICCUPPR.js} +1 -1
  109. package/esm/__chunks/{7GXM6KPX.js → 77C2ITJF.js} +1 -1
  110. package/esm/__chunks/{ZAKCZSVG.js → 7MJF27QJ.js} +1 -1
  111. package/esm/__chunks/{265D6T7T.js → CYJJUQU3.js} +7 -1
  112. package/esm/__chunks/{WANT555J.js → EUD77B6Z.js} +1 -1
  113. package/esm/__chunks/{T6V23Y6E.js → FW6QFGFT.js} +6 -5
  114. package/esm/__chunks/{ITSGLTHL.js → FYZCYWPI.js} +1 -1
  115. package/esm/__chunks/{6P5ZHMMU.js → GMDF663U.js} +1 -1
  116. package/esm/__chunks/{TJKNVC7W.js → HCZMY53N.js} +10 -2
  117. package/esm/__chunks/{VC2N3HOU.js → HNO7M6GL.js} +1 -1
  118. package/esm/__chunks/IXXFVVA2.js +19 -0
  119. package/esm/__chunks/{YKJNQJWA.js → KF3PP2P3.js} +1 -1
  120. package/esm/__chunks/{QTOJ32BQ.js → LIFXUQPU.js} +7 -13
  121. package/esm/__chunks/{DCSOYJXT.js → MO5Q5FB7.js} +1 -1
  122. package/esm/__chunks/{JTITB4L3.js → N36XUJ4I.js} +1 -1
  123. package/esm/__chunks/{THTPXSX5.js → OTMCQXXR.js} +1 -1
  124. package/esm/__chunks/{WKNIYKJV.js → OUTTLNN7.js} +1 -1
  125. package/esm/__chunks/PYB45PRS.js +46 -0
  126. package/esm/__chunks/{FB4T6LXQ.js → Q6CBZJ7X.js} +1 -1
  127. package/esm/__chunks/{CKSO3V6B.js → QLHUIPVK.js} +8 -2
  128. package/esm/__chunks/{5EHZOHU4.js → QTPMBYCP.js} +1 -1
  129. package/esm/__chunks/{MCW3SATG.js → RU5SBKR3.js} +16 -8
  130. package/esm/__chunks/{B4DAIM7E.js → TQ2K6WFI.js} +1 -1
  131. package/esm/__chunks/{MQRO7CTY.js → UYTR2SZP.js} +1 -1
  132. package/esm/__chunks/{RJWQJQSA.js → VSM5JGQO.js} +1 -1
  133. package/esm/__chunks/{PZMNV3SF.js → VV72RDTD.js} +3 -3
  134. package/esm/__chunks/{6R5NAG5K.js → WQIYBPAY.js} +1 -1
  135. package/esm/__chunks/{4E4RWZ6B.js → XECTFJQS.js} +28 -37
  136. package/esm/__chunks/{ZNCBVBWF.js → XJM2RD5W.js} +1 -1
  137. package/esm/__chunks/{OMYYUT2M.js → YNUPNUID.js} +1 -1
  138. package/esm/button/button.js +3 -3
  139. package/esm/checkbox/checkbox.js +3 -3
  140. package/esm/combobox/combobox-cancel.js +3 -3
  141. package/esm/combobox/combobox-disclosure.js +5 -5
  142. package/esm/combobox/combobox-item.js +3 -3
  143. package/esm/combobox/combobox-list.js +2 -2
  144. package/esm/combobox/combobox-popover.js +16 -12
  145. package/esm/combobox/combobox-store.d.ts +1 -0
  146. package/esm/combobox/combobox.js +2 -2
  147. package/esm/command/command.js +2 -2
  148. package/esm/composite/composite-item.js +3 -3
  149. package/esm/composite/composite-overflow-disclosure.js +7 -7
  150. package/esm/composite/composite-overflow.js +15 -11
  151. package/esm/composite/composite.js +2 -2
  152. package/esm/dialog/dialog-backdrop.js +6 -3
  153. package/esm/dialog/dialog-disclosure.js +5 -5
  154. package/esm/dialog/dialog-dismiss.js +4 -4
  155. package/esm/dialog/dialog.d.ts +2 -0
  156. package/esm/dialog/dialog.js +14 -10
  157. package/esm/dialog/utils/disable-accessibility-tree-outside.js +3 -2
  158. package/esm/dialog/utils/disable-tree-outside.js +4 -3
  159. package/esm/dialog/utils/is-backdrop.d.ts +1 -1
  160. package/esm/dialog/utils/is-backdrop.js +3 -17
  161. package/esm/dialog/utils/mark-tree-outside.js +3 -2
  162. package/esm/dialog/utils/orchestrate.d.ts +2 -7
  163. package/esm/dialog/utils/orchestrate.js +1 -1
  164. package/esm/dialog/utils/use-hide-on-interact-outside.js +5 -4
  165. package/esm/dialog/utils/use-prevent-body-scroll.d.ts +1 -2
  166. package/esm/dialog/utils/use-prevent-body-scroll.js +3 -2
  167. package/esm/dialog/utils/use-root-dialog.d.ts +8 -0
  168. package/esm/dialog/utils/use-root-dialog.js +9 -0
  169. package/esm/disclosure/disclosure.js +4 -4
  170. package/esm/focusable/focusable.js +1 -1
  171. package/esm/form/form-checkbox.js +3 -3
  172. package/esm/form/form-input.js +1 -1
  173. package/esm/form/form-push.js +3 -3
  174. package/esm/form/form-radio.js +4 -4
  175. package/esm/form/form-remove.js +3 -3
  176. package/esm/form/form-reset.js +3 -3
  177. package/esm/form/form-submit.js +3 -3
  178. package/esm/hovercard/hovercard-anchor.js +2 -2
  179. package/esm/hovercard/hovercard-disclosure.js +5 -5
  180. package/esm/hovercard/hovercard-dismiss.js +6 -6
  181. package/esm/hovercard/hovercard.js +16 -12
  182. package/esm/menu/menu-bar.js +2 -2
  183. package/esm/menu/menu-button.js +7 -7
  184. package/esm/menu/menu-dismiss.js +6 -6
  185. package/esm/menu/menu-item-checkbox.js +5 -5
  186. package/esm/menu/menu-item-radio.js +5 -5
  187. package/esm/menu/menu-item.js +4 -4
  188. package/esm/menu/menu-list.js +3 -3
  189. package/esm/menu/menu-store.d.ts +1 -0
  190. package/esm/menu/menu.js +17 -14
  191. package/esm/popover/popover-disclosure.js +6 -6
  192. package/esm/popover/popover-dismiss.js +5 -5
  193. package/esm/popover/popover.js +15 -11
  194. package/esm/radio/radio-group.js +2 -2
  195. package/esm/radio/radio.js +4 -4
  196. package/esm/select/select-item.js +3 -3
  197. package/esm/select/select-list.js +3 -3
  198. package/esm/select/select-popover.js +17 -13
  199. package/esm/select/select-store.d.ts +1 -0
  200. package/esm/select/select.js +6 -6
  201. package/esm/tab/tab-list.js +2 -2
  202. package/esm/tab/tab-panel.js +1 -1
  203. package/esm/tab/tab.js +3 -3
  204. package/esm/toolbar/toolbar-container.js +4 -4
  205. package/esm/toolbar/toolbar-input.js +4 -4
  206. package/esm/toolbar/toolbar-item.js +4 -4
  207. package/esm/toolbar/toolbar.js +2 -2
  208. package/esm/tooltip/tooltip-anchor.js +2 -2
  209. package/esm/tooltip/tooltip.js +16 -12
  210. package/esm/tsconfig.build.tsbuildinfo +1 -1
  211. package/package.json +6 -2
@@ -10,7 +10,7 @@ import {
10
10
  } from "./Z3X3QN6P.js";
11
11
  import {
12
12
  useFocusable
13
- } from "./OMYYUT2M.js";
13
+ } from "./YNUPNUID.js";
14
14
  import {
15
15
  createComponent,
16
16
  createElement,
@@ -1,6 +1,9 @@
1
+ import {
2
+ isBackdrop
3
+ } from "./IXXFVVA2.js";
1
4
  import {
2
5
  setAttribute
3
- } from "./T6V23Y6E.js";
6
+ } from "./FW6QFGFT.js";
4
7
  import {
5
8
  walkTreeOutside
6
9
  } from "./FV23EKJL.js";
@@ -11,7 +14,10 @@ function hideElementFromAccessibilityTree(element) {
11
14
  }
12
15
  function disableAccessibilityTreeOutside(...elements) {
13
16
  const cleanups = [];
17
+ const ids = elements.map((el) => el == null ? void 0 : el.id);
14
18
  walkTreeOutside(elements, (element) => {
19
+ if (isBackdrop(element, ...ids))
20
+ return;
15
21
  cleanups.unshift(hideElementFromAccessibilityTree(element));
16
22
  });
17
23
  const restoreAccessibilityTree = () => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCommand
3
- } from "./6R5NAG5K.js";
3
+ } from "./WQIYBPAY.js";
4
4
  import {
5
5
  createComponent,
6
6
  createElement,
@@ -1,10 +1,10 @@
1
1
  // src/dialog/utils/orchestrate.ts
2
- var cleanups = Symbol();
2
+ var cleanups = /* @__PURE__ */ new WeakMap();
3
3
  function orchestrate(element, key, setup) {
4
- if (!element[cleanups]) {
5
- element[cleanups] = /* @__PURE__ */ new Map();
4
+ if (!cleanups.has(element)) {
5
+ cleanups.set(element, /* @__PURE__ */ new Map());
6
6
  }
7
- const elementCleanups = element[cleanups];
7
+ const elementCleanups = cleanups.get(element);
8
8
  const prevCleanup = elementCleanups.get(key);
9
9
  if (!prevCleanup) {
10
10
  elementCleanups.set(key, setup());
@@ -22,7 +22,8 @@ function orchestrate(element, key, setup) {
22
22
  };
23
23
  elementCleanups.set(key, nextCleanup);
24
24
  return () => {
25
- if (elementCleanups.get(key) !== nextCleanup)
25
+ const isCurrent = elementCleanups.get(key) === nextCleanup;
26
+ if (!isCurrent)
26
27
  return;
27
28
  cleanup();
28
29
  elementCleanups.set(key, prevCleanup);
@@ -3,7 +3,7 @@ import {
3
3
  } from "./M5KYRTQG.js";
4
4
  import {
5
5
  useCommand
6
- } from "./6R5NAG5K.js";
6
+ } from "./WQIYBPAY.js";
7
7
  import {
8
8
  createComponent,
9
9
  createElement,
@@ -7,7 +7,7 @@ import {
7
7
  } from "./ZSRI7KJ2.js";
8
8
  import {
9
9
  useComposite
10
- } from "./ZAKCZSVG.js";
10
+ } from "./7MJF27QJ.js";
11
11
  import {
12
12
  isHidden
13
13
  } from "./WFPVIVLA.js";
@@ -1,6 +1,9 @@
1
+ import {
2
+ isBackdrop
3
+ } from "./IXXFVVA2.js";
1
4
  import {
2
5
  setProperty
3
- } from "./T6V23Y6E.js";
6
+ } from "./FW6QFGFT.js";
4
7
  import {
5
8
  walkTreeOutside
6
9
  } from "./FV23EKJL.js";
@@ -37,9 +40,14 @@ function isElementMarked(element, id) {
37
40
  }
38
41
  function markTreeOutside(dialogId, ...elements) {
39
42
  const cleanups = [];
43
+ const ids = elements.map((el) => el == null ? void 0 : el.id);
40
44
  walkTreeOutside(
41
45
  elements,
42
- (element) => cleanups.unshift(markElement(element, dialogId)),
46
+ (element) => {
47
+ if (isBackdrop(element, ...ids))
48
+ return;
49
+ cleanups.unshift(markElement(element, dialogId));
50
+ },
43
51
  (ancestor) => cleanups.unshift(markAncestor(ancestor, dialogId))
44
52
  );
45
53
  const restoreAccessibilityTree = () => {
@@ -10,7 +10,7 @@ import {
10
10
  } from "./VTOOL4S4.js";
11
11
  import {
12
12
  useCompositeItem
13
- } from "./WKNIYKJV.js";
13
+ } from "./OUTTLNN7.js";
14
14
  import {
15
15
  createElement,
16
16
  createHook,
@@ -0,0 +1,19 @@
1
+ // src/dialog/utils/is-backdrop.ts
2
+ function isBackdrop(element, ...ids) {
3
+ if (!element)
4
+ return false;
5
+ const backdrop = element.getAttribute("data-backdrop");
6
+ if (backdrop == null)
7
+ return false;
8
+ if (backdrop === "")
9
+ return true;
10
+ if (backdrop === "true")
11
+ return true;
12
+ if (!ids.length)
13
+ return true;
14
+ return ids.some((id) => backdrop === id);
15
+ }
16
+
17
+ export {
18
+ isBackdrop
19
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useDisclosure
3
- } from "./THTPXSX5.js";
3
+ } from "./OTMCQXXR.js";
4
4
  import {
5
5
  createComponent,
6
6
  createElement,
@@ -1,12 +1,15 @@
1
1
  import {
2
2
  markAncestor
3
- } from "./TJKNVC7W.js";
3
+ } from "./HCZMY53N.js";
4
4
  import {
5
5
  Role
6
6
  } from "./TZIIKRHF.js";
7
7
  import {
8
8
  useDisclosureContent
9
9
  } from "./WFPVIVLA.js";
10
+ import {
11
+ useDisclosureStore
12
+ } from "./2XOPWNSQ.js";
10
13
  import {
11
14
  useMergeRefs,
12
15
  useSafeLayoutEffect
@@ -17,8 +20,7 @@ import {
17
20
  } from "./4BKCJXBM.js";
18
21
 
19
22
  // src/dialog/dialog-backdrop.tsx
20
- import { isValidElement, useMemo, useRef } from "react";
21
- import { noop } from "@ariakit/core/utils/misc";
23
+ import { isValidElement, useRef } from "react";
22
24
  import { jsx } from "react/jsx-runtime";
23
25
  function DialogBackdrop({
24
26
  store,
@@ -28,14 +30,7 @@ function DialogBackdrop({
28
30
  hidden
29
31
  }) {
30
32
  const ref = useRef(null);
31
- store = useMemo(
32
- () => __spreadProps(__spreadValues({}, store), {
33
- // Override the setContentElement method to prevent the backdrop from
34
- // overwriting the dialog's content element. TODO: Refactor this.
35
- setContentElement: noop
36
- }),
37
- [store]
38
- );
33
+ const disclosure = useDisclosureStore({ disclosure: store });
39
34
  const contentElement = store.useState("contentElement");
40
35
  useSafeLayoutEffect(() => {
41
36
  const backdrop2 = ref.current;
@@ -59,8 +54,7 @@ function DialogBackdrop({
59
54
  backdropProps = __spreadProps(__spreadValues({}, backdropProps), { hidden });
60
55
  }
61
56
  const props = useDisclosureContent(__spreadProps(__spreadValues({
62
- store,
63
- id: void 0,
57
+ store: disclosure,
64
58
  role: "presentation",
65
59
  "data-backdrop": (contentElement == null ? void 0 : contentElement.id) || "",
66
60
  alwaysVisible
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useDialogDismiss
3
- } from "./B4DAIM7E.js";
3
+ } from "./TQ2K6WFI.js";
4
4
  import {
5
5
  createComponent,
6
6
  createElement,
@@ -5,7 +5,7 @@ import {
5
5
  } from "./X7FKJQME.js";
6
6
  import {
7
7
  usePopover
8
- } from "./ZNCBVBWF.js";
8
+ } from "./XJM2RD5W.js";
9
9
  import {
10
10
  createComponent,
11
11
  createElement,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useButton
3
- } from "./WANT555J.js";
3
+ } from "./EUD77B6Z.js";
4
4
  import {
5
5
  createComponent,
6
6
  createElement,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCommand
3
- } from "./6R5NAG5K.js";
3
+ } from "./WQIYBPAY.js";
4
4
  import {
5
5
  useCollectionItem
6
6
  } from "./EJLZ2L22.js";
@@ -0,0 +1,46 @@
1
+ import {
2
+ useForceUpdate
3
+ } from "./SN2N5P2D.js";
4
+
5
+ // src/dialog/utils/use-root-dialog.ts
6
+ import { useCallback, useEffect } from "react";
7
+ import { getDocument } from "@ariakit/core/utils/dom";
8
+ import { flushSync } from "react-dom";
9
+ function useRootDialog({
10
+ attribute,
11
+ contentId,
12
+ contentElement,
13
+ enabled
14
+ }) {
15
+ const [updated, retry] = useForceUpdate();
16
+ const isRootDialog = useCallback(() => {
17
+ if (!enabled)
18
+ return false;
19
+ if (!contentElement)
20
+ return false;
21
+ const { body } = getDocument(contentElement);
22
+ const id = body.getAttribute(attribute);
23
+ return !id || id === contentId;
24
+ }, [updated, enabled, contentElement, attribute, contentId]);
25
+ useEffect(() => {
26
+ if (!enabled)
27
+ return;
28
+ if (!contentId)
29
+ return;
30
+ if (!contentElement)
31
+ return;
32
+ const { body } = getDocument(contentElement);
33
+ if (isRootDialog()) {
34
+ body.setAttribute(attribute, contentId);
35
+ return () => body.removeAttribute(attribute);
36
+ }
37
+ const observer = new MutationObserver(() => flushSync(retry));
38
+ observer.observe(body, { attributeFilter: [attribute] });
39
+ return () => observer.disconnect();
40
+ }, [updated, enabled, contentId, contentElement, isRootDialog, attribute]);
41
+ return isRootDialog;
42
+ }
43
+
44
+ export {
45
+ useRootDialog
46
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCompositeItem
3
- } from "./WKNIYKJV.js";
3
+ } from "./OUTTLNN7.js";
4
4
  import {
5
5
  createElement,
6
6
  createHook,
@@ -1,14 +1,17 @@
1
1
  import {
2
2
  hideElementFromAccessibilityTree
3
- } from "./265D6T7T.js";
3
+ } from "./CYJJUQU3.js";
4
4
  import {
5
5
  supportsInert
6
6
  } from "./KOVUJERF.js";
7
+ import {
8
+ isBackdrop
9
+ } from "./IXXFVVA2.js";
7
10
  import {
8
11
  assignStyle,
9
12
  setAttribute,
10
13
  setProperty
11
- } from "./T6V23Y6E.js";
14
+ } from "./FW6QFGFT.js";
12
15
  import {
13
16
  walkTreeOutside
14
17
  } from "./FV23EKJL.js";
@@ -34,6 +37,7 @@ function disableElement(element) {
34
37
  }
35
38
  function disableTreeOutside(...elements) {
36
39
  const cleanups = [];
40
+ const ids = elements.map((el) => el == null ? void 0 : el.id);
37
41
  if (!supportsInert()) {
38
42
  getAllTabbable().forEach((element) => {
39
43
  if (elements.some((el) => el && contains(el, element)))
@@ -42,6 +46,8 @@ function disableTreeOutside(...elements) {
42
46
  });
43
47
  }
44
48
  walkTreeOutside(elements, (element) => {
49
+ if (isBackdrop(element, ...ids))
50
+ return;
45
51
  cleanups.unshift(disableElement(element));
46
52
  });
47
53
  const restoreTreeOutside = () => {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useFocusable
3
- } from "./OMYYUT2M.js";
3
+ } from "./YNUPNUID.js";
4
4
  import {
5
5
  createComponent,
6
6
  createElement,
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  assignStyle,
3
3
  setCSSProperty
4
- } from "./T6V23Y6E.js";
4
+ } from "./FW6QFGFT.js";
5
5
  import {
6
- useSafeLayoutEffect
7
- } from "./SN2N5P2D.js";
6
+ useRootDialog
7
+ } from "./PYB45PRS.js";
8
8
 
9
9
  // src/dialog/utils/use-prevent-body-scroll.ts
10
+ import { useEffect } from "react";
10
11
  import { getDocument, getWindow } from "@ariakit/core/utils/dom";
11
12
  import { chain } from "@ariakit/core/utils/misc";
12
13
  import { isApple, isMac } from "@ariakit/core/utils/platform";
@@ -15,11 +16,18 @@ function getPaddingProperty(documentElement) {
15
16
  const scrollbarX = Math.round(documentLeft) + documentElement.scrollLeft;
16
17
  return scrollbarX ? "paddingLeft" : "paddingRight";
17
18
  }
18
- function usePreventBodyScroll(store, enabled) {
19
- useSafeLayoutEffect(() => {
20
- if (!enabled)
19
+ function usePreventBodyScroll(contentElement, contentId, enabled) {
20
+ const isRootDialog = useRootDialog({
21
+ attribute: "data-dialog-prevent-body-scroll",
22
+ contentElement,
23
+ contentId,
24
+ enabled
25
+ });
26
+ useEffect(() => {
27
+ if (!isRootDialog())
28
+ return;
29
+ if (!contentElement)
21
30
  return;
22
- const { contentElement } = store.getState();
23
31
  const doc = getDocument(contentElement);
24
32
  const win = getWindow(contentElement);
25
33
  const { documentElement, body } = doc;
@@ -60,7 +68,7 @@ function usePreventBodyScroll(store, enabled) {
60
68
  setScrollbarWidthProperty(),
61
69
  isIOS ? setIOSStyle() : setStyle()
62
70
  );
63
- }, [enabled]);
71
+ }, [isRootDialog, contentElement]);
64
72
  }
65
73
 
66
74
  export {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useButton
3
- } from "./WANT555J.js";
3
+ } from "./EUD77B6Z.js";
4
4
  import {
5
5
  DialogContext
6
6
  } from "./LNHZLQEK.js";
@@ -6,7 +6,7 @@ import {
6
6
  } from "./EEVSGAZW.js";
7
7
  import {
8
8
  useComposite
9
- } from "./ZAKCZSVG.js";
9
+ } from "./7MJF27QJ.js";
10
10
  import {
11
11
  isHidden
12
12
  } from "./WFPVIVLA.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  usePopoverDismiss
3
- } from "./DCSOYJXT.js";
3
+ } from "./MO5Q5FB7.js";
4
4
  import {
5
5
  createComponent,
6
6
  createElement,
@@ -1,9 +1,9 @@
1
- import {
2
- isElementMarked
3
- } from "./TJKNVC7W.js";
4
1
  import {
5
2
  usePreviousMouseDownRef
6
3
  } from "./7JNF6I52.js";
4
+ import {
5
+ isElementMarked
6
+ } from "./HCZMY53N.js";
7
7
  import {
8
8
  useEvent
9
9
  } from "./SN2N5P2D.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useFocusable
3
- } from "./OMYYUT2M.js";
3
+ } from "./YNUPNUID.js";
4
4
  import {
5
5
  createComponent,
6
6
  createElement,
@@ -1,28 +1,28 @@
1
1
  import {
2
2
  DialogBackdrop
3
- } from "./QTOJ32BQ.js";
3
+ } from "./LIFXUQPU.js";
4
4
  import {
5
5
  disableTreeOutside
6
- } from "./CKSO3V6B.js";
6
+ } from "./QLHUIPVK.js";
7
7
  import {
8
8
  disableAccessibilityTreeOutside
9
- } from "./265D6T7T.js";
9
+ } from "./CYJJUQU3.js";
10
10
  import {
11
11
  usePreventBodyScroll
12
- } from "./MCW3SATG.js";
12
+ } from "./RU5SBKR3.js";
13
13
  import {
14
14
  useNestedDialogs
15
15
  } from "./J4BKICPJ.js";
16
16
  import {
17
17
  useHideOnInteractOutside
18
- } from "./PZMNV3SF.js";
18
+ } from "./VV72RDTD.js";
19
19
  import {
20
20
  prependHiddenDismiss
21
21
  } from "./62DFK33R.js";
22
22
  import {
23
23
  isElementMarked,
24
24
  markTreeOutside
25
- } from "./TJKNVC7W.js";
25
+ } from "./HCZMY53N.js";
26
26
  import {
27
27
  useFocusableContainer
28
28
  } from "./GKH7N3JM.js";
@@ -43,7 +43,7 @@ import {
43
43
  } from "./WFPVIVLA.js";
44
44
  import {
45
45
  useFocusable
46
- } from "./OMYYUT2M.js";
46
+ } from "./YNUPNUID.js";
47
47
  import {
48
48
  createComponent,
49
49
  createElement,
@@ -140,10 +140,7 @@ var useDialog = createHook(
140
140
  "finalFocus"
141
141
  ]);
142
142
  const ref = useRef(null);
143
- const { portalRef, portalNode, domReady } = usePortalRef(
144
- portal,
145
- props.portalRef
146
- );
143
+ const { portalRef, domReady } = usePortalRef(portal, props.portalRef);
147
144
  const preserveTabOrderProp = props.preserveTabOrder;
148
145
  const preserveTabOrder = store.useState(
149
146
  (state) => preserveTabOrderProp && !modal && state.mounted
@@ -153,7 +150,7 @@ var useDialog = createHook(
153
150
  const mounted = store.useState("mounted");
154
151
  const contentElement = store.useState("contentElement");
155
152
  const hidden = isHidden(mounted, props.hidden, props.alwaysVisible);
156
- usePreventBodyScroll(store, preventBodyScroll && !hidden);
153
+ usePreventBodyScroll(contentElement, id, preventBodyScroll && !hidden);
157
154
  useHideOnInteractOutside(store, hideOnInteractOutside);
158
155
  const { wrapElement, nestedDialogs } = useNestedDialogs(store);
159
156
  props = useWrapElement(props, wrapElement, [wrapElement]);
@@ -222,6 +219,8 @@ var useDialog = createHook(
222
219
  }, [mounted, domReady, shouldDisableAccessibilityTree]);
223
220
  const getPersistentElementsProp = useEvent(getPersistentElements);
224
221
  useSafeLayoutEffect(() => {
222
+ if (!domReady)
223
+ return;
225
224
  if (!id)
226
225
  return;
227
226
  if (!open)
@@ -230,14 +229,8 @@ var useDialog = createHook(
230
229
  const dialog = ref.current;
231
230
  const persistentElements = getPersistentElementsProp() || [];
232
231
  const allElements = [
233
- // In addition to the dialog element, we also include the portal node
234
- // here so nested dialogs are considered as well.
235
232
  dialog,
236
- portalNode,
237
233
  ...persistentElements,
238
- // We still need to include nested dialogs here because they may be
239
- // outside the portal node or the parent dialog may not be using a
240
- // portal.
241
234
  ...nestedDialogs.map((dialog2) => dialog2.getState().contentElement)
242
235
  ];
243
236
  if (!shouldDisableAccessibilityTree) {
@@ -254,13 +247,12 @@ var useDialog = createHook(
254
247
  disableAccessibilityTreeOutside(...allElements)
255
248
  );
256
249
  }, [
250
+ domReady,
257
251
  id,
258
252
  open,
259
253
  store,
260
- portal,
261
- portalNode,
262
- nestedDialogs,
263
254
  getPersistentElementsProp,
255
+ nestedDialogs,
264
256
  shouldDisableAccessibilityTree,
265
257
  modal
266
258
  ]);
@@ -407,22 +399,21 @@ var useDialog = createHook(
407
399
  props = useWrapElement(
408
400
  props,
409
401
  (element) => {
410
- if (backdrop) {
411
- return /* @__PURE__ */ jsxs(Fragment, { children: [
412
- backdrop && /* @__PURE__ */ jsx(
413
- DialogBackdrop,
414
- {
415
- store,
416
- backdrop,
417
- backdropProps,
418
- hidden: hiddenProp,
419
- alwaysVisible
420
- }
421
- ),
422
- element
423
- ] });
424
- }
425
- return element;
402
+ if (!backdrop)
403
+ return element;
404
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
405
+ /* @__PURE__ */ jsx(
406
+ DialogBackdrop,
407
+ {
408
+ store,
409
+ backdrop,
410
+ backdropProps,
411
+ hidden: hiddenProp,
412
+ alwaysVisible
413
+ }
414
+ ),
415
+ element
416
+ ] });
426
417
  },
427
418
  [store, backdrop, backdropProps, hiddenProp, alwaysVisible]
428
419
  );
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useDialog
3
- } from "./4E4RWZ6B.js";
3
+ } from "./XECTFJQS.js";
4
4
  import {
5
5
  PopoverContext
6
6
  } from "./6GS36SYX.js";
@@ -232,7 +232,7 @@ var useFocusable = createHook(
232
232
  receivedFocus = true;
233
233
  };
234
234
  const options = { capture: true, once: true };
235
- document.body.addEventListener("focusin", onFocus, options);
235
+ element.addEventListener("focusin", onFocus, options);
236
236
  queueBeforeEvent(element, "mouseup", () => {
237
237
  element.removeEventListener("focusin", onFocus, true);
238
238
  if (receivedFocus)
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  Button,
3
3
  useButton
4
- } from "../__chunks/WANT555J.js";
5
- import "../__chunks/6R5NAG5K.js";
6
- import "../__chunks/OMYYUT2M.js";
4
+ } from "../__chunks/EUD77B6Z.js";
5
+ import "../__chunks/WQIYBPAY.js";
6
+ import "../__chunks/YNUPNUID.js";
7
7
  import "../__chunks/BMLNRUFQ.js";
8
8
  import "../__chunks/7GCARSHZ.js";
9
9
  import "../__chunks/SN2N5P2D.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  Checkbox,
3
3
  useCheckbox
4
- } from "../__chunks/ITSGLTHL.js";
4
+ } from "../__chunks/FYZCYWPI.js";
5
5
  import "../__chunks/M5KYRTQG.js";
6
- import "../__chunks/6R5NAG5K.js";
7
- import "../__chunks/OMYYUT2M.js";
6
+ import "../__chunks/WQIYBPAY.js";
7
+ import "../__chunks/YNUPNUID.js";
8
8
  import "../__chunks/BMLNRUFQ.js";
9
9
  import "../__chunks/7GCARSHZ.js";
10
10
  import "../__chunks/USB5JBON.js";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  useButton
3
- } from "../__chunks/WANT555J.js";
4
- import "../__chunks/6R5NAG5K.js";
5
- import "../__chunks/OMYYUT2M.js";
3
+ } from "../__chunks/EUD77B6Z.js";
4
+ import "../__chunks/WQIYBPAY.js";
5
+ import "../__chunks/YNUPNUID.js";
6
6
  import "../__chunks/BMLNRUFQ.js";
7
7
  import {
8
8
  createComponent,
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  useDialogDisclosure
3
- } from "../__chunks/YKJNQJWA.js";
4
- import "../__chunks/THTPXSX5.js";
5
- import "../__chunks/WANT555J.js";
6
- import "../__chunks/6R5NAG5K.js";
7
- import "../__chunks/OMYYUT2M.js";
3
+ } from "../__chunks/KF3PP2P3.js";
4
+ import "../__chunks/OTMCQXXR.js";
5
+ import "../__chunks/EUD77B6Z.js";
6
+ import "../__chunks/WQIYBPAY.js";
7
+ import "../__chunks/YNUPNUID.js";
8
8
  import "../__chunks/BMLNRUFQ.js";
9
9
  import {
10
10
  createComponent,