@ariakit/react-core 0.1.3 → 0.1.5

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 (191) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/cjs/__chunks/{NYVIJAIX.cjs → 3CPBCP3F.cjs} +2 -2
  3. package/cjs/__chunks/{FSEBHZVD.cjs → 63KDRM7J.cjs} +4 -4
  4. package/cjs/__chunks/{WYGT6WVD.cjs → BJ6S3SB5.cjs} +16 -16
  5. package/cjs/__chunks/{IYRMREW7.cjs → BX3HGZ7I.cjs} +5 -5
  6. package/cjs/__chunks/{CMHDB7LY.cjs → CP6M4POZ.cjs} +2 -2
  7. package/cjs/__chunks/{YITIRUCT.cjs → DH774RHH.cjs} +2 -2
  8. package/cjs/__chunks/{ND6THRTE.cjs → EQUPHBKX.cjs} +4 -4
  9. package/cjs/__chunks/{RG6JXX7T.cjs → EZLBMRYS.cjs} +13 -13
  10. package/cjs/__chunks/{H5Z2A5K2.cjs → FJEN5XPE.cjs} +5 -5
  11. package/cjs/__chunks/{HJTX27PU.cjs → GSMEXLDS.cjs} +43 -22
  12. package/cjs/__chunks/{KIZFPB5R.cjs → J3TNGZSO.cjs} +5 -5
  13. package/cjs/__chunks/{5LMWS5O4.cjs → KPYDIKOY.cjs} +3 -3
  14. package/cjs/__chunks/{IVRU7X3P.cjs → KUXCWMWW.cjs} +9 -1
  15. package/cjs/__chunks/{XKBGBOWQ.cjs → MWKUZW4E.cjs} +2 -0
  16. package/cjs/__chunks/{3QEUUQVB.cjs → NKZKDBAR.cjs} +0 -4
  17. package/cjs/__chunks/OKPDB2ZM.cjs +44 -0
  18. package/cjs/__chunks/{ABU7PK6G.cjs → PZ72QR7P.cjs} +2 -2
  19. package/cjs/__chunks/{7HZT2AAH.cjs → SGWCIO3J.cjs} +2 -2
  20. package/cjs/__chunks/{F6IOE5QT.cjs → TQ3ZXPQL.cjs} +3 -3
  21. package/cjs/__chunks/{TIVUAJD3.cjs → TZBXRN4U.cjs} +13 -13
  22. package/cjs/__chunks/{T4TB3AAZ.cjs → UK7WFIG4.cjs} +22 -14
  23. package/cjs/__chunks/{LH4INSYS.cjs → UYAQKYEJ.cjs} +2 -2
  24. package/cjs/__chunks/{QRBTWQPI.cjs → YTLECYPS.cjs} +8 -10
  25. package/cjs/__chunks/{NJHMO3XK.cjs → Z5OM7SNB.cjs} +3 -3
  26. package/cjs/__chunks/{KWHAB2F2.cjs → ZDO3DQPW.cjs} +1 -2
  27. package/cjs/__chunks/{3RC6Q4WI.cjs → ZS4MDBUW.cjs} +2 -2
  28. package/cjs/checkbox/checkbox-store.cjs +3 -3
  29. package/cjs/checkbox/checkbox.cjs +3 -3
  30. package/cjs/collection/collection-item.cjs +2 -2
  31. package/cjs/collection/collection-store.cjs +3 -3
  32. package/cjs/combobox/combobox-item.cjs +4 -3
  33. package/cjs/combobox/combobox-popover.cjs +9 -10
  34. package/cjs/combobox/combobox-store.cjs +12 -12
  35. package/cjs/combobox/combobox.cjs +20 -8
  36. package/cjs/composite/composite-container.cjs +3 -3
  37. package/cjs/composite/composite-item.cjs +4 -3
  38. package/cjs/composite/composite-overflow-disclosure.cjs +4 -3
  39. package/cjs/composite/composite-overflow-store.cjs +7 -7
  40. package/cjs/composite/composite-overflow.cjs +9 -10
  41. package/cjs/composite/composite-store.cjs +4 -4
  42. package/cjs/dialog/dialog-store.cjs +4 -4
  43. package/cjs/dialog/dialog.cjs +8 -9
  44. package/cjs/dialog/utils/disable-tree-outside.cjs +7 -0
  45. package/cjs/dialog/utils/disable-tree-outside.d.ts +3 -0
  46. package/cjs/dialog/utils/use-champion-dialog.cjs +2 -2
  47. package/cjs/dialog/utils/use-hide-on-interact-outside.cjs +2 -2
  48. package/cjs/dialog/utils/use-nested-dialogs.cjs +2 -2
  49. package/cjs/dialog/utils/use-prevent-body-scroll.cjs +3 -3
  50. package/cjs/disclosure/disclosure-store.cjs +3 -3
  51. package/cjs/form/form-checkbox.cjs +8 -8
  52. package/cjs/form/form-description.cjs +2 -2
  53. package/cjs/form/form-error.cjs +2 -2
  54. package/cjs/form/form-field.cjs +3 -3
  55. package/cjs/form/form-input.cjs +3 -3
  56. package/cjs/form/form-label.cjs +2 -2
  57. package/cjs/form/form-push.cjs +2 -2
  58. package/cjs/form/form-radio.cjs +7 -7
  59. package/cjs/form/form-store.cjs +28 -17
  60. package/cjs/hovercard/hovercard-store.cjs +6 -6
  61. package/cjs/hovercard/hovercard.cjs +10 -11
  62. package/cjs/menu/menu-bar-store.cjs +6 -6
  63. package/cjs/menu/menu-button.cjs +2 -2
  64. package/cjs/menu/menu-item-checkbox.cjs +10 -10
  65. package/cjs/menu/menu-item-radio.cjs +8 -8
  66. package/cjs/menu/menu-item.cjs +5 -5
  67. package/cjs/menu/menu-list.cjs +3 -3
  68. package/cjs/menu/menu-store.cjs +14 -14
  69. package/cjs/menu/menu.cjs +13 -14
  70. package/cjs/popover/popover-store.cjs +5 -5
  71. package/cjs/popover/popover.cjs +9 -10
  72. package/cjs/portal/portal.cjs +2 -2
  73. package/cjs/radio/radio-store.cjs +7 -7
  74. package/cjs/radio/radio.cjs +5 -5
  75. package/cjs/select/select-item.cjs +4 -3
  76. package/cjs/select/select-popover.cjs +9 -10
  77. package/cjs/select/select-store.cjs +12 -12
  78. package/cjs/tab/tab-panel.cjs +5 -5
  79. package/cjs/tab/tab-store.cjs +9 -9
  80. package/cjs/tab/tab.cjs +4 -3
  81. package/cjs/toolbar/toolbar-container.cjs +7 -7
  82. package/cjs/toolbar/toolbar-input.cjs +5 -4
  83. package/cjs/toolbar/toolbar-item.cjs +5 -4
  84. package/cjs/toolbar/toolbar-store.cjs +6 -6
  85. package/cjs/tooltip/tooltip-store.cjs +7 -7
  86. package/cjs/tooltip/tooltip.cjs +2 -2
  87. package/cjs/tsconfig.build.tsbuildinfo +1 -1
  88. package/cjs/utils/store.cjs +2 -2
  89. package/dialog/utils/disable-tree-outside/package.json +7 -0
  90. package/esm/__chunks/{WOX4XCVH.js → 2EEVGFEH.js} +1 -1
  91. package/esm/__chunks/{56XURSTF.js → 36HCAR3M.js} +1 -1
  92. package/esm/__chunks/{IACKFX3D.js → 7VB6U7Y2.js} +1 -1
  93. package/esm/__chunks/{HLAXMBLL.js → ARIIJA3Z.js} +3 -1
  94. package/esm/__chunks/{RFLPDFU5.js → CDHQAO3X.js} +7 -9
  95. package/esm/__chunks/{ZVCQYVEV.js → FD7UP2TJ.js} +3 -4
  96. package/esm/__chunks/{QCGEDLZG.js → GLAECEAR.js} +1 -1
  97. package/esm/__chunks/{4RNONDN5.js → GM2BWWHD.js} +1 -1
  98. package/esm/__chunks/{LFCJQX2O.js → GWYHKM6Q.js} +1 -1
  99. package/esm/__chunks/{EJZ6BVXG.js → IIX2NU6T.js} +22 -14
  100. package/esm/__chunks/{47TE2UD5.js → JCOAGXR2.js} +2 -2
  101. package/esm/__chunks/{PAZURDJA.js → JIT55CHU.js} +39 -18
  102. package/esm/__chunks/{WHN4PCW7.js → JOV72LYK.js} +12 -12
  103. package/esm/__chunks/{YDNX3N4B.js → KTHONFWV.js} +3 -3
  104. package/esm/__chunks/{4STD3S2Y.js → LBUPFIVF.js} +2 -2
  105. package/esm/__chunks/{6DAEYZ43.js → LTH56VDS.js} +3 -3
  106. package/esm/__chunks/{RSJJ72ZD.js → M6QENKOT.js} +2 -2
  107. package/esm/__chunks/{HRNQJHNJ.js → MAJ5ZZ2S.js} +1 -1
  108. package/esm/__chunks/{3OSYJZM5.js → MPZ7PKON.js} +9 -1
  109. package/esm/__chunks/{OGTE6FGV.js → ND76WTDR.js} +2 -2
  110. package/esm/__chunks/{XQPXGTBO.js → NY7SYLNQ.js} +1 -1
  111. package/esm/__chunks/{OJNRBQKS.js → ON2AV7GH.js} +1 -5
  112. package/esm/__chunks/{CWHDUB4A.js → P4W76ES3.js} +1 -1
  113. package/esm/__chunks/X3J57OQT.js +44 -0
  114. package/esm/__chunks/{OXIHLN45.js → YHRHKO5B.js} +1 -1
  115. package/esm/__chunks/{2EP53RLR.js → ZCEPUYV7.js} +2 -2
  116. package/esm/checkbox/checkbox-store.js +2 -2
  117. package/esm/checkbox/checkbox.js +2 -2
  118. package/esm/collection/collection-item.js +1 -1
  119. package/esm/collection/collection-store.js +2 -2
  120. package/esm/combobox/combobox-item.js +3 -2
  121. package/esm/combobox/combobox-popover.js +8 -9
  122. package/esm/combobox/combobox-store.js +6 -6
  123. package/esm/combobox/combobox.js +20 -8
  124. package/esm/composite/composite-container.js +2 -2
  125. package/esm/composite/composite-item.js +3 -2
  126. package/esm/composite/composite-overflow-disclosure.js +3 -2
  127. package/esm/composite/composite-overflow-store.js +4 -4
  128. package/esm/composite/composite-overflow.js +8 -9
  129. package/esm/composite/composite-store.js +3 -3
  130. package/esm/dialog/dialog-store.js +3 -3
  131. package/esm/dialog/dialog.js +7 -8
  132. package/esm/dialog/utils/disable-tree-outside.d.ts +3 -0
  133. package/esm/dialog/utils/disable-tree-outside.js +7 -0
  134. package/esm/dialog/utils/use-champion-dialog.js +1 -1
  135. package/esm/dialog/utils/use-hide-on-interact-outside.js +1 -1
  136. package/esm/dialog/utils/use-nested-dialogs.js +1 -1
  137. package/esm/dialog/utils/use-prevent-body-scroll.js +2 -2
  138. package/esm/disclosure/disclosure-store.js +2 -2
  139. package/esm/form/form-checkbox.js +7 -7
  140. package/esm/form/form-description.js +1 -1
  141. package/esm/form/form-error.js +1 -1
  142. package/esm/form/form-field.js +2 -2
  143. package/esm/form/form-input.js +2 -2
  144. package/esm/form/form-label.js +1 -1
  145. package/esm/form/form-push.js +1 -1
  146. package/esm/form/form-radio.js +5 -5
  147. package/esm/form/form-store.js +24 -13
  148. package/esm/hovercard/hovercard-store.js +5 -5
  149. package/esm/hovercard/hovercard.js +9 -10
  150. package/esm/menu/menu-bar-store.js +3 -3
  151. package/esm/menu/menu-button.js +1 -1
  152. package/esm/menu/menu-item-checkbox.js +9 -9
  153. package/esm/menu/menu-item-radio.js +6 -6
  154. package/esm/menu/menu-item.js +4 -4
  155. package/esm/menu/menu-list.js +2 -2
  156. package/esm/menu/menu-store.js +7 -7
  157. package/esm/menu/menu.js +11 -12
  158. package/esm/popover/popover-store.js +4 -4
  159. package/esm/popover/popover.js +8 -9
  160. package/esm/portal/portal.js +1 -1
  161. package/esm/radio/radio-store.js +3 -3
  162. package/esm/radio/radio.js +4 -4
  163. package/esm/select/select-item.js +3 -2
  164. package/esm/select/select-popover.js +8 -9
  165. package/esm/select/select-store.js +6 -6
  166. package/esm/tab/tab-panel.js +3 -3
  167. package/esm/tab/tab-store.js +3 -3
  168. package/esm/tab/tab.js +3 -2
  169. package/esm/toolbar/toolbar-container.js +5 -5
  170. package/esm/toolbar/toolbar-input.js +4 -3
  171. package/esm/toolbar/toolbar-item.js +4 -3
  172. package/esm/toolbar/toolbar-store.js +3 -3
  173. package/esm/tooltip/tooltip-store.js +4 -4
  174. package/esm/tooltip/tooltip.js +1 -1
  175. package/esm/tsconfig.build.tsbuildinfo +1 -1
  176. package/esm/utils/store.js +1 -1
  177. package/package.json +5 -9
  178. package/cjs/__chunks/ORRE4SVW.cjs +0 -31
  179. package/cjs/__chunks/RDNP4FTV.cjs +0 -30
  180. package/cjs/dialog/utils/disable-pointer-events-outside.cjs +0 -7
  181. package/cjs/dialog/utils/disable-pointer-events-outside.d.ts +0 -3
  182. package/cjs/dialog/utils/use-focus-on-child-unmount.cjs +0 -6
  183. package/cjs/dialog/utils/use-focus-on-child-unmount.d.ts +0 -6
  184. package/dialog/utils/disable-pointer-events-outside/package.json +0 -7
  185. package/dialog/utils/use-focus-on-child-unmount/package.json +0 -7
  186. package/esm/__chunks/547F7FFZ.js +0 -30
  187. package/esm/__chunks/WO2RXMKK.js +0 -31
  188. package/esm/dialog/utils/disable-pointer-events-outside.d.ts +0 -3
  189. package/esm/dialog/utils/disable-pointer-events-outside.js +0 -7
  190. package/esm/dialog/utils/use-focus-on-child-unmount.d.ts +0 -6
  191. package/esm/dialog/utils/use-focus-on-child-unmount.js +0 -6
@@ -3,7 +3,7 @@ import {
3
3
  } from "./P3I4MECH.js";
4
4
  import {
5
5
  useCollectionItem
6
- } from "./OJNRBQKS.js";
6
+ } from "./ON2AV7GH.js";
7
7
  import {
8
8
  createElement,
9
9
  createHook,
@@ -24,15 +24,13 @@ function getNamedElement(ref, name) {
24
24
  const element = ref.current;
25
25
  if (!element)
26
26
  return null;
27
- if (element.name !== name) {
28
- if (element.form) {
29
- return element.form.elements.namedItem(name);
30
- } else {
31
- const document = getDocument(element);
32
- return document.getElementsByName(name)[0];
33
- }
27
+ if (element.name === name)
28
+ return element;
29
+ if (element.form) {
30
+ return element.form.elements.namedItem(name);
34
31
  }
35
- return element;
32
+ const document = getDocument(element);
33
+ return document.getElementsByName(name)[0];
36
34
  }
37
35
  function useItem(store, name, type) {
38
36
  return store.useState(
@@ -1,10 +1,9 @@
1
1
  import {
2
- useForceUpdate,
3
- useSafeLayoutEffect
2
+ useForceUpdate
4
3
  } from "./B7MIN7YT.js";
5
4
 
6
5
  // src/dialog/utils/use-champion-dialog.ts
7
- import { useCallback } from "react";
6
+ import { useCallback, useEffect } from "react";
8
7
  import { getDocument } from "@ariakit/core/utils/dom";
9
8
  import { flushSync } from "react-dom";
10
9
  function useChampionDialog(attribute, store, enabled) {
@@ -19,7 +18,7 @@ function useChampionDialog(attribute, store, enabled) {
19
18
  const id = body.getAttribute(attribute);
20
19
  return !id || id === dialog.id;
21
20
  }, [updated, store, enabled, attribute]);
22
- useSafeLayoutEffect(() => {
21
+ useEffect(() => {
23
22
  const dialog = store.getState().contentElement;
24
23
  if (!dialog)
25
24
  return;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useDialog
3
- } from "./PAZURDJA.js";
3
+ } from "./JIT55CHU.js";
4
4
  import {
5
5
  PopoverContext
6
6
  } from "./6GS36SYX.js";
@@ -11,7 +11,7 @@ import {
11
11
  } from "./JE5NWDDX.js";
12
12
  import {
13
13
  useStoreState
14
- } from "./6DAEYZ43.js";
14
+ } from "./LTH56VDS.js";
15
15
  import {
16
16
  useEvent,
17
17
  useForkRef,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useChampionDialog
3
- } from "./ZVCQYVEV.js";
3
+ } from "./FD7UP2TJ.js";
4
4
  import {
5
5
  useSafeLayoutEffect
6
6
  } from "./B7MIN7YT.js";
@@ -18,8 +18,6 @@ function useNestedDialogs(store, modal) {
18
18
  const context = useContext(NestedDialogsContext);
19
19
  const [openModals, setOpenModals] = useState([]);
20
20
  const [nestedDialogs, setNestedDialogs] = useState([]);
21
- const open = store.useState("open");
22
- const contentElement = store.useState("contentElement");
23
21
  const addDialog = useCallback(
24
22
  (dialog) => {
25
23
  return chain(
@@ -34,7 +32,7 @@ function useNestedDialogs(store, modal) {
34
32
  })()
35
33
  );
36
34
  },
37
- [context.addDialog]
35
+ [context]
38
36
  );
39
37
  const showModal = useCallback(
40
38
  (dialog) => {
@@ -50,22 +48,32 @@ function useNestedDialogs(store, modal) {
50
48
  })()
51
49
  );
52
50
  },
53
- [context.showModal]
51
+ [context]
54
52
  );
55
53
  useSafeLayoutEffect(() => {
56
- if (!contentElement)
57
- return;
58
- return context.addDialog?.(contentElement);
59
- }, [contentElement, context.addDialog]);
54
+ return store.sync(
55
+ (state) => {
56
+ if (!state.contentElement)
57
+ return;
58
+ return context.addDialog?.(state.contentElement);
59
+ },
60
+ ["contentElement"]
61
+ );
62
+ }, [store, context]);
60
63
  useSafeLayoutEffect(() => {
61
64
  if (!modal)
62
65
  return;
63
- if (!open)
64
- return;
65
- if (!contentElement)
66
- return;
67
- return context.showModal?.(contentElement);
68
- }, [modal, open, contentElement, context.showModal]);
66
+ return store.sync(
67
+ (state) => {
68
+ if (!state.open)
69
+ return;
70
+ if (!state.contentElement)
71
+ return;
72
+ return context.showModal?.(state.contentElement);
73
+ },
74
+ ["open", "contentElement"]
75
+ );
76
+ }, [store, modal, context]);
69
77
  useEffect(() => {
70
78
  return context.store?.syncBatch(
71
79
  (state) => {
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  usePopoverStoreOptions,
3
3
  usePopoverStoreProps
4
- } from "./RSJJ72ZD.js";
4
+ } from "./M6QENKOT.js";
5
5
  import {
6
6
  useStore
7
- } from "./6DAEYZ43.js";
7
+ } from "./LTH56VDS.js";
8
8
 
9
9
  // src/hovercard/hovercard-store.ts
10
10
  import * as Core from "@ariakit/core/hovercard/hovercard-store";
@@ -3,16 +3,13 @@ import {
3
3
  } from "./4U6AOLE4.js";
4
4
  import {
5
5
  useHideOnInteractOutside
6
- } from "./HLAXMBLL.js";
7
- import {
8
- useFocusOnChildUnmount
9
- } from "./WO2RXMKK.js";
6
+ } from "./ARIIJA3Z.js";
10
7
  import {
11
8
  prependHiddenDismiss
12
9
  } from "./PU22SOKH.js";
13
10
  import {
14
- disablePointerEventsOutside
15
- } from "./547F7FFZ.js";
11
+ disableTreeOutside
12
+ } from "./X3J57OQT.js";
16
13
  import {
17
14
  disableAccessibilityTreeOutside
18
15
  } from "./NV7HSBKK.js";
@@ -21,13 +18,13 @@ import {
21
18
  } from "./2SVAPVVI.js";
22
19
  import {
23
20
  usePreventBodyScroll
24
- } from "./LFCJQX2O.js";
21
+ } from "./GWYHKM6Q.js";
25
22
  import {
26
23
  useChampionDialog
27
- } from "./ZVCQYVEV.js";
24
+ } from "./FD7UP2TJ.js";
28
25
  import {
29
26
  useNestedDialogs
30
- } from "./EJZ6BVXG.js";
27
+ } from "./IIX2NU6T.js";
31
28
  import {
32
29
  HeadingLevel
33
30
  } from "./6OMX4H3W.js";
@@ -41,7 +38,7 @@ import {
41
38
  } from "./5TGAWEHD.js";
42
39
  import {
43
40
  usePortal
44
- } from "./3OSYJZM5.js";
41
+ } from "./MPZ7PKON.js";
45
42
  import {
46
43
  useDisclosureContent
47
44
  } from "./FFRIGW5T.js";
@@ -165,13 +162,36 @@ var useDialog = createHook(
165
162
  (state) => preventBodyScroll && state.mounted
166
163
  );
167
164
  usePreventBodyScroll(store, shouldPreventBodyScroll);
168
- useFocusOnChildUnmount(store);
169
165
  useHideOnInteractOutside({
170
166
  store,
171
167
  modal,
172
168
  hideOnInteractOutside,
173
169
  nestedDialogs
174
170
  });
171
+ const shouldRestoreLostFocus = useChampionDialog(
172
+ "data-dialog-restore-lost-focus",
173
+ store,
174
+ open && modal && !openModals.length
175
+ );
176
+ useEffect(() => {
177
+ if (!shouldRestoreLostFocus())
178
+ return;
179
+ let raf = 0;
180
+ const restoreLostFocus = () => {
181
+ const dialog = ref.current;
182
+ raf = requestAnimationFrame(restoreLostFocus);
183
+ if (!dialog)
184
+ return;
185
+ const doc = getDocument(dialog);
186
+ if (!doc.hasFocus())
187
+ return;
188
+ if (doc.activeElement !== doc.body)
189
+ return;
190
+ dialog.focus();
191
+ };
192
+ restoreLostFocus();
193
+ return () => cancelAnimationFrame(raf);
194
+ }, [shouldRestoreLostFocus]);
175
195
  const mounted = store.useState("mounted");
176
196
  if (isSafariBrowser) {
177
197
  useEffect(() => {
@@ -229,13 +249,11 @@ var useDialog = createHook(
229
249
  if (modal) {
230
250
  return chain(
231
251
  disableAccessibilityTreeOutside(element),
232
- // When the backdrop is not visible, we also need to disable pointer
233
- // events outside of the modal dialog.
234
- !backdrop ? disablePointerEventsOutside(element) : null
252
+ disableTreeOutside(element)
235
253
  );
236
254
  }
237
255
  return disableAccessibilityTreeOutside(element);
238
- }, [shouldDisableOutside, portal, portalNode, modal, backdrop]);
256
+ }, [shouldDisableOutside, portal, portalNode, modal]);
239
257
  const mayAutoFocusOnShow = !!autoFocusOnShow;
240
258
  const autoFocusOnShowProp = useBooleanEvent(autoFocusOnShow);
241
259
  useEffect(() => {
@@ -371,9 +389,12 @@ var useDialog = createHook(
371
389
  (element) => /* @__PURE__ */ jsx(HeadingLevel, { level: modal ? 1 : void 0, children: element }),
372
390
  [modal]
373
391
  );
374
- const shouldFocusTrap = store.useState(
375
- (state) => modal && !openModals.length && state.open
376
- );
392
+ const [shouldFocusTrap, setShouldFocusTrap] = useState(false);
393
+ const hasOpenModals = !!openModals.length;
394
+ useSafeLayoutEffect(() => {
395
+ const value = open && modal && !hasOpenModals && !("inert" in HTMLElement.prototype);
396
+ setShouldFocusTrap(value);
397
+ }, [modal, open, hasOpenModals]);
377
398
  props = useFocusTrapRegion({ ...props, enabled: shouldFocusTrap });
378
399
  const hiddenProp = props.hidden;
379
400
  props = useWrapElement(
@@ -3,7 +3,7 @@ import {
3
3
  } from "./SAVDGYCC.js";
4
4
  import {
5
5
  useCollectionItem
6
- } from "./OJNRBQKS.js";
6
+ } from "./ON2AV7GH.js";
7
7
  import {
8
8
  focusSilently,
9
9
  getEnabledItem,
@@ -19,6 +19,9 @@ import {
19
19
  createHook,
20
20
  createMemoComponent
21
21
  } from "./JE5NWDDX.js";
22
+ import {
23
+ useStoreState
24
+ } from "./LTH56VDS.js";
22
25
  import {
23
26
  useBooleanEvent,
24
27
  useEvent,
@@ -36,7 +39,6 @@ import {
36
39
  isTextField
37
40
  } from "@ariakit/core/utils/dom";
38
41
  import { isPortalEvent, isSelfTarget } from "@ariakit/core/utils/events";
39
- import { invariant } from "@ariakit/core/utils/misc";
40
42
  import { jsx } from "react/jsx-runtime";
41
43
  function isEditableElement(element) {
42
44
  if (element.isContentEditable)
@@ -144,14 +146,10 @@ var useCompositeItem = createHook(
144
146
  }) => {
145
147
  const context = useContext(CompositeContext);
146
148
  store = store || context;
147
- invariant(
148
- store,
149
- process.env.NODE_ENV !== "production" && "CompositeItem must be wrapped in a Composite component"
150
- );
151
149
  const id = useId(props.id);
152
150
  const ref = useRef(null);
153
151
  const row = useContext(CompositeRowContext);
154
- const rowId = store.useState((state) => {
152
+ const rowId = useStoreState(store, (state) => {
155
153
  if (rowIdProp)
156
154
  return rowIdProp;
157
155
  if (!row?.baseElement)
@@ -274,7 +272,8 @@ var useCompositeItem = createHook(
274
272
  }
275
273
  }
276
274
  });
277
- const baseElement = store.useState(
275
+ const baseElement = useStoreState(
276
+ store,
278
277
  (state) => state.baseElement || void 0
279
278
  );
280
279
  const providerValue = useMemo(
@@ -286,9 +285,9 @@ var useCompositeItem = createHook(
286
285
  (element) => /* @__PURE__ */ jsx(CompositeItemContext.Provider, { value: providerValue, children: element }),
287
286
  [providerValue]
288
287
  );
289
- const isActiveItem = store.useState((state) => state.activeId === id);
288
+ const isActiveItem = useStoreState(store, (state) => state.activeId === id);
290
289
  const role = useRole(ref, props);
291
- const virtualFocus = store.useState("virtualFocus");
290
+ const virtualFocus = useStoreState(store, "virtualFocus");
292
291
  let ariaSelected;
293
292
  if (isActiveItem) {
294
293
  if (requiresAriaSelected(role)) {
@@ -297,7 +296,8 @@ var useCompositeItem = createHook(
297
296
  ariaSelected = true;
298
297
  }
299
298
  }
300
- const shouldTabIndex = store.useState(
299
+ const shouldTabIndex = useStoreState(
300
+ store,
301
301
  (state) => !state.virtualFocus && isActiveItem
302
302
  );
303
303
  props = {
@@ -306,7 +306,7 @@ var useCompositeItem = createHook(
306
306
  "data-active-item": isActiveItem ? "" : void 0,
307
307
  ...props,
308
308
  ref: useForkRef(ref, props.ref),
309
- tabIndex: shouldTabIndex ? props.tabIndex : -1,
309
+ tabIndex: shouldTabIndex !== false ? props.tabIndex : -1,
310
310
  onFocus,
311
311
  onBlurCapture,
312
312
  onKeyDown
@@ -10,7 +10,7 @@ import {
10
10
  } from "./DRSUYUM5.js";
11
11
  import {
12
12
  useCompositeItem
13
- } from "./WHN4PCW7.js";
13
+ } from "./JOV72LYK.js";
14
14
  import {
15
15
  createElement,
16
16
  createHook,
@@ -18,7 +18,7 @@ import {
18
18
  } from "./JE5NWDDX.js";
19
19
  import {
20
20
  useStoreState
21
- } from "./6DAEYZ43.js";
21
+ } from "./LTH56VDS.js";
22
22
  import {
23
23
  useBooleanEvent,
24
24
  useEvent
@@ -42,7 +42,7 @@ var useMenuItem = createHook(
42
42
  store = store || menuContext || menuBarContext;
43
43
  invariant(
44
44
  store,
45
- process.env.NODE_ENV !== "production" && "MenuItem must be wrapped in a MenuList, MenuPopover or MenuBar component"
45
+ process.env.NODE_ENV !== "production" && "MenuItem must be wrapped in a MenuList, Menu or MenuBar component"
46
46
  );
47
47
  const onClickProp = props.onClick;
48
48
  const hideOnClickProp = useBooleanEvent(hideOnClick);
@@ -3,7 +3,7 @@ import {
3
3
  } from "./6I2PARRP.js";
4
4
  import {
5
5
  useCompositeItem
6
- } from "./WHN4PCW7.js";
6
+ } from "./JOV72LYK.js";
7
7
  import {
8
8
  createElement,
9
9
  createHook,
@@ -11,7 +11,7 @@ import {
11
11
  } from "./JE5NWDDX.js";
12
12
  import {
13
13
  useStoreState
14
- } from "./6DAEYZ43.js";
14
+ } from "./LTH56VDS.js";
15
15
  import {
16
16
  useEvent,
17
17
  useForkRef,
@@ -60,12 +60,12 @@ function useStoreProps(store, props, key, setKey) {
60
60
  }
61
61
  function useStore(createStore) {
62
62
  const store = useLazyValue(createStore);
63
- useSafeLayoutEffect(() => store.init(), []);
63
+ useSafeLayoutEffect(() => store.init(), [store]);
64
64
  const useState = useCallback(
65
65
  (keyOrSelector) => useStoreState(store, keyOrSelector),
66
- []
66
+ [store]
67
67
  );
68
- return useMemo(() => ({ ...store, useState }), []);
68
+ return useMemo(() => ({ ...store, useState }), [store, useState]);
69
69
  }
70
70
 
71
71
  export {
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  useDialogStoreOptions,
3
3
  useDialogStoreProps
4
- } from "./OGTE6FGV.js";
4
+ } from "./ND76WTDR.js";
5
5
  import {
6
6
  useStore,
7
7
  useStoreProps
8
- } from "./6DAEYZ43.js";
8
+ } from "./LTH56VDS.js";
9
9
  import {
10
10
  useEvent
11
11
  } from "./B7MIN7YT.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  useStore,
3
3
  useStoreProps
4
- } from "./6DAEYZ43.js";
4
+ } from "./LTH56VDS.js";
5
5
 
6
6
  // src/checkbox/checkbox-store.ts
7
7
  import * as Core from "@ariakit/core/checkbox/checkbox-store";
@@ -122,7 +122,15 @@ var usePortal = createHook(
122
122
  if (!portal)
123
123
  return element;
124
124
  if (!portalNode) {
125
- return /* @__PURE__ */ jsx("span", { ref: refProp, id: props.id, style: { position: "fixed" } });
125
+ return /* @__PURE__ */ jsx(
126
+ "span",
127
+ {
128
+ ref: refProp,
129
+ id: props.id,
130
+ style: { position: "fixed" },
131
+ hidden: true
132
+ }
133
+ );
126
134
  }
127
135
  element = /* @__PURE__ */ jsxs(Fragment, { children: [
128
136
  preserveTabOrder && portalNode && /* @__PURE__ */ jsx(
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  useDisclosureStoreOptions,
3
3
  useDisclosureStoreProps
4
- } from "./OXIHLN45.js";
4
+ } from "./YHRHKO5B.js";
5
5
  import {
6
6
  useStore
7
- } from "./6DAEYZ43.js";
7
+ } from "./LTH56VDS.js";
8
8
 
9
9
  // src/dialog/dialog-store.ts
10
10
  import * as Core from "@ariakit/core/dialog/dialog-store";
@@ -5,7 +5,7 @@ import {
5
5
  } from "./X7FKJQME.js";
6
6
  import {
7
7
  usePopover
8
- } from "./QCGEDLZG.js";
8
+ } from "./GLAECEAR.js";
9
9
  import {
10
10
  createComponent,
11
11
  createElement,
@@ -13,15 +13,11 @@ import {
13
13
 
14
14
  // src/collection/collection-item.ts
15
15
  import { useCallback, useContext, useRef } from "react";
16
- import { identity, invariant } from "@ariakit/core/utils/misc";
16
+ import { identity } from "@ariakit/core/utils/misc";
17
17
  var useCollectionItem = createHook(
18
18
  ({ store, shouldRegisterItem = true, getItem = identity, ...props }) => {
19
19
  const context = useContext(CollectionContext);
20
20
  store = store || context;
21
- invariant(
22
- store,
23
- process.env.NODE_ENV !== "production" && "CollectionItem must be wrapped in a Collection component"
24
- );
25
21
  const id = useId(props.id);
26
22
  const unrenderItem = useRef();
27
23
  const ref = useCallback(
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCompositeItem
3
- } from "./WHN4PCW7.js";
3
+ } from "./JOV72LYK.js";
4
4
  import {
5
5
  createElement,
6
6
  createHook,
@@ -0,0 +1,44 @@
1
+ import {
2
+ walkTreeOutside
3
+ } from "./HVXLVRRR.js";
4
+
5
+ // src/dialog/utils/disable-tree-outside.ts
6
+ import { chain, noop } from "@ariakit/core/utils/misc";
7
+ function assignStyle(element, style) {
8
+ if (!element)
9
+ return () => {
10
+ };
11
+ const previousStyle = element.style.cssText;
12
+ Object.assign(element.style, style);
13
+ return () => {
14
+ element.style.cssText = previousStyle;
15
+ };
16
+ }
17
+ function disableElement(element) {
18
+ if (!("style" in element))
19
+ return noop;
20
+ const previousInert = element.inert;
21
+ element.inert = true;
22
+ return chain(
23
+ assignStyle(element, {
24
+ pointerEvents: "none",
25
+ userSelect: "none",
26
+ cursor: "default"
27
+ }),
28
+ () => element.inert = previousInert
29
+ );
30
+ }
31
+ function disableTreeOutside(...elements) {
32
+ const cleanups = [];
33
+ walkTreeOutside(elements, (element) => {
34
+ cleanups.unshift(disableElement(element));
35
+ });
36
+ const restorePointerEvents = () => {
37
+ cleanups.forEach((fn) => fn());
38
+ };
39
+ return restorePointerEvents;
40
+ }
41
+
42
+ export {
43
+ disableTreeOutside
44
+ };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  useStore,
3
3
  useStoreProps
4
- } from "./6DAEYZ43.js";
4
+ } from "./LTH56VDS.js";
5
5
 
6
6
  // src/disclosure/disclosure-store.ts
7
7
  import * as Core from "@ariakit/core/disclosure/disclosure-store";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  useCollectionStoreOptions,
3
3
  useCollectionStoreProps
4
- } from "./56XURSTF.js";
4
+ } from "./36HCAR3M.js";
5
5
  import {
6
6
  useStore,
7
7
  useStoreProps
8
- } from "./6DAEYZ43.js";
8
+ } from "./LTH56VDS.js";
9
9
 
10
10
  // src/composite/composite-store.ts
11
11
  import * as Core from "@ariakit/core/composite/composite-store";
@@ -2,8 +2,8 @@ import {
2
2
  useCheckboxStore,
3
3
  useCheckboxStoreOptions,
4
4
  useCheckboxStoreProps
5
- } from "../__chunks/HRNQJHNJ.js";
6
- import "../__chunks/6DAEYZ43.js";
5
+ } from "../__chunks/MAJ5ZZ2S.js";
6
+ import "../__chunks/LTH56VDS.js";
7
7
  import "../__chunks/B7MIN7YT.js";
8
8
  import "../__chunks/SXC6BPOF.js";
9
9
  export {
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  Checkbox,
3
3
  useCheckbox
4
- } from "../__chunks/4RNONDN5.js";
4
+ } from "../__chunks/GM2BWWHD.js";
5
5
  import "../__chunks/M5KYRTQG.js";
6
6
  import "../__chunks/SAVDGYCC.js";
7
7
  import "../__chunks/5TGAWEHD.js";
8
8
  import "../__chunks/JE5NWDDX.js";
9
- import "../__chunks/6DAEYZ43.js";
9
+ import "../__chunks/LTH56VDS.js";
10
10
  import "../__chunks/B7MIN7YT.js";
11
11
  import "../__chunks/SXC6BPOF.js";
12
12
  export {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CollectionItem,
3
3
  useCollectionItem
4
- } from "../__chunks/OJNRBQKS.js";
4
+ } from "../__chunks/ON2AV7GH.js";
5
5
  import "../__chunks/T3DJZG63.js";
6
6
  import "../__chunks/JE5NWDDX.js";
7
7
  import "../__chunks/B7MIN7YT.js";
@@ -2,8 +2,8 @@ import {
2
2
  useCollectionStore,
3
3
  useCollectionStoreOptions,
4
4
  useCollectionStoreProps
5
- } from "../__chunks/56XURSTF.js";
6
- import "../__chunks/6DAEYZ43.js";
5
+ } from "../__chunks/36HCAR3M.js";
6
+ import "../__chunks/LTH56VDS.js";
7
7
  import "../__chunks/B7MIN7YT.js";
8
8
  import "../__chunks/SXC6BPOF.js";
9
9
  export {
@@ -7,9 +7,9 @@ import {
7
7
  } from "../__chunks/DRSUYUM5.js";
8
8
  import {
9
9
  useCompositeItem
10
- } from "../__chunks/WHN4PCW7.js";
10
+ } from "../__chunks/JOV72LYK.js";
11
11
  import "../__chunks/SAVDGYCC.js";
12
- import "../__chunks/OJNRBQKS.js";
12
+ import "../__chunks/ON2AV7GH.js";
13
13
  import "../__chunks/T3DJZG63.js";
14
14
  import "../__chunks/STKLF26R.js";
15
15
  import "../__chunks/5TGAWEHD.js";
@@ -19,6 +19,7 @@ import {
19
19
  createHook,
20
20
  createMemoComponent
21
21
  } from "../__chunks/JE5NWDDX.js";
22
+ import "../__chunks/LTH56VDS.js";
22
23
  import {
23
24
  useBooleanEvent,
24
25
  useEvent,