@ariakit/react-core 0.2.15 → 0.2.16

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 (178) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/cjs/__chunks/{GHDSJPDP.cjs → 2CBM6TG2.cjs} +9 -1
  3. package/cjs/__chunks/{2BUZEL3H.cjs → 4PH5LF7R.cjs} +2 -2
  4. package/cjs/__chunks/{LHLJ5HWH.cjs → 5SFIKBWF.cjs} +2 -2
  5. package/cjs/__chunks/{XE2DJMCI.cjs → 6BAHKJ5K.cjs} +14 -20
  6. package/cjs/__chunks/{5PVFQNEK.cjs → AHLK6SVF.cjs} +10 -10
  7. package/cjs/__chunks/{7AY74MRV.cjs → BIJBAZHT.cjs} +2 -2
  8. package/cjs/__chunks/{KAIRFV3B.cjs → BW4OCE2W.cjs} +4 -4
  9. package/cjs/__chunks/{GJDDV2DB.cjs → CY7GQARX.cjs} +13 -13
  10. package/cjs/__chunks/{SIVNE3PR.cjs → ETK4FMZH.cjs} +12 -12
  11. package/cjs/__chunks/{PJQOOE4T.cjs → EVXAMK7D.cjs} +6 -8
  12. package/cjs/__chunks/{YBLCB5MM.cjs → EWI7RF64.cjs} +5 -5
  13. package/cjs/__chunks/{IIT6ECXG.cjs → EYVMZOCS.cjs} +8 -8
  14. package/cjs/__chunks/{ZC54XMTA.cjs → FNKDTHTN.cjs} +4 -4
  15. package/cjs/__chunks/{4ALK6CLY.cjs → FVVV75ZK.cjs} +2 -2
  16. package/cjs/__chunks/{UQ677BGW.cjs → GAQNLEPX.cjs} +6 -6
  17. package/cjs/__chunks/{AGHEZ6QM.cjs → JLC4GR5L.cjs} +2 -2
  18. package/cjs/__chunks/{VXMYNJ4Z.cjs → KKAG47JR.cjs} +2 -2
  19. package/cjs/__chunks/{VBRBBWCP.cjs → NH6Q6YSM.cjs} +2 -2
  20. package/cjs/__chunks/{HV7BPIPP.cjs → OHBR6IPU.cjs} +7 -7
  21. package/cjs/__chunks/{RS6F2A54.cjs → PBJASQI6.cjs} +4 -4
  22. package/cjs/__chunks/{COQS7NEY.cjs → QCWWP2P4.cjs} +2 -2
  23. package/cjs/__chunks/{MEIHBPXG.cjs → QW7NAUIX.cjs} +30 -25
  24. package/cjs/__chunks/{RO6U6W2X.cjs → VB7SPR3I.cjs} +7 -7
  25. package/cjs/__chunks/{GYMLYZWR.cjs → VGBPLBUZ.cjs} +3 -3
  26. package/cjs/__chunks/{B4KY2VS7.cjs → VKPXIX7D.cjs} +3 -3
  27. package/cjs/checkbox/checkbox-store.cjs +3 -3
  28. package/cjs/checkbox/checkbox.cjs +3 -3
  29. package/cjs/collection/collection-item.cjs +2 -2
  30. package/cjs/collection/collection-renderer.cjs +3 -3
  31. package/cjs/collection/collection-store.cjs +3 -3
  32. package/cjs/combobox/combobox-item.cjs +4 -4
  33. package/cjs/combobox/combobox-popover.cjs +7 -7
  34. package/cjs/combobox/combobox-store.cjs +11 -11
  35. package/cjs/combobox/combobox.cjs +3 -3
  36. package/cjs/composite/composite-container.cjs +3 -3
  37. package/cjs/composite/composite-item.cjs +4 -4
  38. package/cjs/composite/composite-overflow-disclosure.cjs +7 -6
  39. package/cjs/composite/composite-overflow-store.cjs +7 -7
  40. package/cjs/composite/composite-overflow.cjs +7 -7
  41. package/cjs/composite/composite-renderer.cjs +4 -4
  42. package/cjs/composite/composite-store.cjs +4 -4
  43. package/cjs/dialog/dialog-backdrop.cjs +4 -4
  44. package/cjs/dialog/dialog-store.cjs +4 -4
  45. package/cjs/dialog/dialog.cjs +6 -6
  46. package/cjs/dialog/utils/use-nested-dialogs.cjs +2 -2
  47. package/cjs/disclosure/disclosure-store.cjs +3 -3
  48. package/cjs/focusable/focusable.d.ts +52 -13
  49. package/cjs/form/form-checkbox.cjs +8 -8
  50. package/cjs/form/form-description.cjs +2 -2
  51. package/cjs/form/form-error.cjs +2 -2
  52. package/cjs/form/form-field.cjs +3 -3
  53. package/cjs/form/form-input.cjs +3 -3
  54. package/cjs/form/form-label.cjs +2 -2
  55. package/cjs/form/form-push.cjs +2 -2
  56. package/cjs/form/form-radio.cjs +7 -7
  57. package/cjs/form/form-store.cjs +8 -8
  58. package/cjs/hovercard/hovercard-anchor.cjs +2 -2
  59. package/cjs/hovercard/hovercard-disclosure.cjs +12 -14
  60. package/cjs/hovercard/hovercard-store.cjs +6 -6
  61. package/cjs/hovercard/hovercard.cjs +8 -8
  62. package/cjs/menu/menu-bar-store.cjs +6 -6
  63. package/cjs/menu/menu-button.cjs +9 -6
  64. package/cjs/menu/menu-item-checkbox.cjs +9 -9
  65. package/cjs/menu/menu-item-radio.cjs +7 -7
  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 +13 -13
  69. package/cjs/menu/menu.cjs +10 -10
  70. package/cjs/popover/popover-store.cjs +5 -5
  71. package/cjs/popover/popover.cjs +7 -7
  72. package/cjs/radio/radio-store.cjs +7 -7
  73. package/cjs/radio/radio.cjs +5 -5
  74. package/cjs/select/select-item.cjs +4 -4
  75. package/cjs/select/select-popover.cjs +7 -7
  76. package/cjs/select/select-renderer.cjs +7 -7
  77. package/cjs/select/select-store.cjs +11 -11
  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 -4
  81. package/cjs/toolbar/toolbar-container.cjs +7 -7
  82. package/cjs/toolbar/toolbar-input.cjs +5 -5
  83. package/cjs/toolbar/toolbar-item.cjs +5 -5
  84. package/cjs/toolbar/toolbar-store.cjs +6 -6
  85. package/cjs/tooltip/tooltip-anchor.cjs +22 -28
  86. package/cjs/tooltip/tooltip-store.cjs +10 -10
  87. package/cjs/tooltip/tooltip.cjs +8 -8
  88. package/cjs/tsconfig.build.tsbuildinfo +1 -1
  89. package/cjs/utils/store.cjs +2 -2
  90. package/esm/__chunks/{H3BU75TA.js → 432NLB7J.js} +1 -1
  91. package/esm/__chunks/{QLIKSQTQ.js → 5PDNXTAR.js} +1 -1
  92. package/esm/__chunks/{QHXLY5NM.js → 5QHNNZNE.js} +1 -1
  93. package/esm/__chunks/{ISVIGIQD.js → 6F6CCCKT.js} +1 -1
  94. package/esm/__chunks/{VVJJXZ6R.js → 7SIWUER2.js} +2 -2
  95. package/esm/__chunks/{I6WUAEGK.js → CEBWVZJQ.js} +2 -2
  96. package/esm/__chunks/{JHKKFNCJ.js → CU3AKJBN.js} +1 -1
  97. package/esm/__chunks/{4LTL37RB.js → CYNFBMYS.js} +1 -1
  98. package/esm/__chunks/{SPTQP5I5.js → EICJBDBV.js} +2 -2
  99. package/esm/__chunks/{JJW3R5IK.js → F6PEGR7W.js} +1 -1
  100. package/esm/__chunks/{WNGYZL6A.js → FSTINJD5.js} +1 -1
  101. package/esm/__chunks/{RRY7OZXM.js → FW5SU7FV.js} +2 -2
  102. package/esm/__chunks/{XE25NQP3.js → JD3UVZX5.js} +1 -1
  103. package/esm/__chunks/{ID2DTD7Z.js → ORZC42PG.js} +5 -7
  104. package/esm/__chunks/{OEA63YXU.js → PLOINBVB.js} +14 -20
  105. package/esm/__chunks/{XEEFNNEM.js → Q52PUUUL.js} +1 -1
  106. package/esm/__chunks/{OJNIJGF2.js → QJUX534W.js} +2 -2
  107. package/esm/__chunks/{MXMUDZTV.js → QPTZ2G2N.js} +29 -24
  108. package/esm/__chunks/{JWSYWSCR.js → R4VIEIUH.js} +1 -1
  109. package/esm/__chunks/{BIPBU2AE.js → TG7IDXTX.js} +5 -5
  110. package/esm/__chunks/{JFQ4TNZX.js → TQ5BKSY4.js} +2 -2
  111. package/esm/__chunks/{74BBE733.js → UKOZA6YP.js} +2 -2
  112. package/esm/__chunks/{HGFTMLQ7.js → VFNGSUSF.js} +13 -13
  113. package/esm/__chunks/{36V3RYFS.js → X5CHG5LF.js} +2 -2
  114. package/esm/__chunks/{I3PXTXPI.js → Y5XLHDDM.js} +9 -1
  115. package/esm/checkbox/checkbox-store.js +2 -2
  116. package/esm/checkbox/checkbox.js +2 -2
  117. package/esm/collection/collection-item.js +1 -1
  118. package/esm/collection/collection-renderer.js +2 -2
  119. package/esm/collection/collection-store.js +2 -2
  120. package/esm/combobox/combobox-item.js +3 -3
  121. package/esm/combobox/combobox-popover.js +6 -6
  122. package/esm/combobox/combobox-store.js +6 -6
  123. package/esm/combobox/combobox.js +3 -3
  124. package/esm/composite/composite-container.js +2 -2
  125. package/esm/composite/composite-item.js +3 -3
  126. package/esm/composite/composite-overflow-disclosure.js +6 -5
  127. package/esm/composite/composite-overflow-store.js +4 -4
  128. package/esm/composite/composite-overflow.js +6 -6
  129. package/esm/composite/composite-renderer.js +3 -3
  130. package/esm/composite/composite-store.js +3 -3
  131. package/esm/dialog/dialog-backdrop.js +3 -3
  132. package/esm/dialog/dialog-store.js +3 -3
  133. package/esm/dialog/dialog.js +5 -5
  134. package/esm/dialog/utils/use-nested-dialogs.js +1 -1
  135. package/esm/disclosure/disclosure-store.js +2 -2
  136. package/esm/focusable/focusable.d.ts +52 -13
  137. package/esm/form/form-checkbox.js +5 -5
  138. package/esm/form/form-description.js +1 -1
  139. package/esm/form/form-error.js +1 -1
  140. package/esm/form/form-field.js +2 -2
  141. package/esm/form/form-input.js +2 -2
  142. package/esm/form/form-label.js +1 -1
  143. package/esm/form/form-push.js +1 -1
  144. package/esm/form/form-radio.js +5 -5
  145. package/esm/form/form-store.js +2 -2
  146. package/esm/hovercard/hovercard-anchor.js +1 -1
  147. package/esm/hovercard/hovercard-disclosure.js +12 -14
  148. package/esm/hovercard/hovercard-store.js +5 -5
  149. package/esm/hovercard/hovercard.js +7 -7
  150. package/esm/menu/menu-bar-store.js +3 -3
  151. package/esm/menu/menu-button.js +7 -4
  152. package/esm/menu/menu-item-checkbox.js +6 -6
  153. package/esm/menu/menu-item-radio.js +5 -5
  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 +8 -8
  158. package/esm/popover/popover-store.js +4 -4
  159. package/esm/popover/popover.js +6 -6
  160. package/esm/radio/radio-store.js +3 -3
  161. package/esm/radio/radio.js +4 -4
  162. package/esm/select/select-item.js +3 -3
  163. package/esm/select/select-popover.js +6 -6
  164. package/esm/select/select-renderer.js +3 -3
  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 -3
  169. package/esm/toolbar/toolbar-container.js +5 -5
  170. package/esm/toolbar/toolbar-input.js +4 -4
  171. package/esm/toolbar/toolbar-item.js +4 -4
  172. package/esm/toolbar/toolbar-store.js +3 -3
  173. package/esm/tooltip/tooltip-anchor.js +22 -28
  174. package/esm/tooltip/tooltip-store.js +5 -5
  175. package/esm/tooltip/tooltip.js +7 -7
  176. package/esm/tsconfig.build.tsbuildinfo +1 -1
  177. package/esm/utils/store.js +1 -1
  178. package/package.json +2 -2
@@ -18,7 +18,7 @@ import {
18
18
  } from "./NQJBHION.js";
19
19
  import {
20
20
  useStoreState
21
- } from "./MXMUDZTV.js";
21
+ } from "./QPTZ2G2N.js";
22
22
  import {
23
23
  useEvent,
24
24
  useId,
@@ -3,7 +3,7 @@ import {
3
3
  } from "./P4RGQGTG.js";
4
4
  import {
5
5
  useCollectionItem
6
- } from "./HGFTMLQ7.js";
6
+ } from "./VFNGSUSF.js";
7
7
  import {
8
8
  focusSilently,
9
9
  getEnabledItem,
@@ -21,7 +21,7 @@ import {
21
21
  } from "./NQJBHION.js";
22
22
  import {
23
23
  useStoreState
24
- } from "./MXMUDZTV.js";
24
+ } from "./QPTZ2G2N.js";
25
25
  import {
26
26
  useBooleanEvent,
27
27
  useEvent,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getCollectionRendererItemId,
3
3
  useCollectionRenderer
4
- } from "./QLIKSQTQ.js";
4
+ } from "./5PDNXTAR.js";
5
5
  import {
6
6
  CompositeContext
7
7
  } from "./WJ37OVG2.js";
@@ -11,7 +11,7 @@ import {
11
11
  } from "./NQJBHION.js";
12
12
  import {
13
13
  useStoreState
14
- } from "./MXMUDZTV.js";
14
+ } from "./QPTZ2G2N.js";
15
15
  import {
16
16
  useId
17
17
  } from "./J7Q2EO23.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useDialog
3
- } from "./BIPBU2AE.js";
3
+ } from "./TG7IDXTX.js";
4
4
  import {
5
5
  PopoverContext
6
6
  } from "./6GS36SYX.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  useStore,
3
3
  useStoreProps
4
- } from "./MXMUDZTV.js";
4
+ } from "./QPTZ2G2N.js";
5
5
 
6
6
  // src/checkbox/checkbox-store.ts
7
7
  import * as Core from "@ariakit/core/checkbox/checkbox-store";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  useDialogStoreOptions,
3
3
  useDialogStoreProps
4
- } from "./RRY7OZXM.js";
4
+ } from "./FW5SU7FV.js";
5
5
  import {
6
6
  useStore,
7
7
  useStoreProps
8
- } from "./MXMUDZTV.js";
8
+ } from "./QPTZ2G2N.js";
9
9
  import {
10
10
  __spreadValues
11
11
  } from "./PNRLI7OV.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  useStore,
3
3
  useStoreProps
4
- } from "./MXMUDZTV.js";
4
+ } from "./QPTZ2G2N.js";
5
5
  import {
6
6
  __spreadValues
7
7
  } from "./PNRLI7OV.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  useStore,
3
3
  useStoreProps
4
- } from "./MXMUDZTV.js";
4
+ } from "./QPTZ2G2N.js";
5
5
  import {
6
6
  __spreadValues
7
7
  } from "./PNRLI7OV.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  useDisclosureStoreOptions,
3
3
  useDisclosureStoreProps
4
- } from "./JJW3R5IK.js";
4
+ } from "./F6PEGR7W.js";
5
5
  import {
6
6
  useStore
7
- } from "./MXMUDZTV.js";
7
+ } from "./QPTZ2G2N.js";
8
8
  import {
9
9
  __spreadValues
10
10
  } from "./PNRLI7OV.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useCompositeItem
3
- } from "./VVJJXZ6R.js";
3
+ } from "./7SIWUER2.js";
4
4
  import {
5
5
  createElement,
6
6
  createHook,
@@ -5,7 +5,7 @@ import {
5
5
  } from "./X7FKJQME.js";
6
6
  import {
7
7
  usePopover
8
- } from "./JHKKFNCJ.js";
8
+ } from "./CU3AKJBN.js";
9
9
  import {
10
10
  createComponent,
11
11
  createElement,
@@ -39,6 +39,7 @@ import { contains } from "@ariakit/core/utils/dom";
39
39
  import { addGlobalEventListener } from "@ariakit/core/utils/events";
40
40
  import { hasFocusWithin } from "@ariakit/core/utils/focus";
41
41
  import { chain, isFalsyBooleanCallback } from "@ariakit/core/utils/misc";
42
+ import { sync } from "@ariakit/core/utils/store";
42
43
  import { jsx } from "react/jsx-runtime";
43
44
  function isMovingOnHovercard(target, card, anchor, nested) {
44
45
  if (hasFocusWithin(card))
@@ -95,12 +96,9 @@ function useAutoFocusOnHide(_a) {
95
96
  });
96
97
  const finalFocusRef = useRef(null);
97
98
  useEffect(() => {
98
- return store.sync(
99
- (state) => {
100
- finalFocusRef.current = state.anchorElement;
101
- },
102
- ["anchorElement"]
103
- );
99
+ return sync(store, ["anchorElement"], (state) => {
100
+ finalFocusRef.current = state.anchorElement;
101
+ });
104
102
  }, []);
105
103
  props = __spreadProps(__spreadValues({
106
104
  autoFocusOnHide,
@@ -11,6 +11,7 @@ import {
11
11
  useState
12
12
  } from "react";
13
13
  import { chain } from "@ariakit/core/utils/misc";
14
+ import { sync } from "@ariakit/core/utils/store";
14
15
  import { jsx } from "react/jsx-runtime";
15
16
  var NestedDialogsContext = createContext({});
16
17
  function useNestedDialogs(store) {
@@ -27,28 +28,21 @@ function useNestedDialogs(store) {
27
28
  [context]
28
29
  );
29
30
  useSafeLayoutEffect(() => {
30
- return store.sync(
31
- (state) => {
32
- var _a;
33
- if (!state.open)
34
- return;
35
- if (!state.contentElement)
36
- return;
37
- return (_a = context.add) == null ? void 0 : _a.call(context, store);
38
- },
39
- ["open", "contentElement"]
40
- );
31
+ return sync(store, ["open", "contentElement"], (state) => {
32
+ var _a;
33
+ if (!state.open)
34
+ return;
35
+ if (!state.contentElement)
36
+ return;
37
+ return (_a = context.add) == null ? void 0 : _a.call(context, store);
38
+ });
41
39
  }, [store, context]);
42
40
  useSafeLayoutEffect(() => {
43
- var _a;
44
- return (_a = context.store) == null ? void 0 : _a.sync(
45
- (state) => {
46
- if (state.open)
47
- return;
48
- store.hide();
49
- },
50
- ["open"]
51
- );
41
+ return sync(context.store, ["open"], (state) => {
42
+ if (state.open)
43
+ return;
44
+ store.hide();
45
+ });
52
46
  }, [context, store]);
53
47
  const providerValue = useMemo(() => ({ store, add }), [store, add]);
54
48
  const wrapElement = useCallback(
@@ -11,7 +11,7 @@ import {
11
11
  } from "./NQJBHION.js";
12
12
  import {
13
13
  useStoreState
14
- } from "./MXMUDZTV.js";
14
+ } from "./QPTZ2G2N.js";
15
15
  import {
16
16
  useEvent,
17
17
  useMergeRefs
@@ -3,7 +3,7 @@ import {
3
3
  } from "./6I2PARRP.js";
4
4
  import {
5
5
  useCompositeItem
6
- } from "./VVJJXZ6R.js";
6
+ } from "./7SIWUER2.js";
7
7
  import {
8
8
  createElement,
9
9
  createHook,
@@ -11,7 +11,7 @@ import {
11
11
  } from "./NQJBHION.js";
12
12
  import {
13
13
  useStoreState
14
- } from "./MXMUDZTV.js";
14
+ } from "./QPTZ2G2N.js";
15
15
  import {
16
16
  useEvent,
17
17
  useId,
@@ -9,8 +9,9 @@ import {
9
9
  } from "./PNRLI7OV.js";
10
10
 
11
11
  // src/utils/store.tsx
12
- import { useCallback, useMemo } from "react";
12
+ import * as React from "react";
13
13
  import { hasOwnProperty, identity } from "@ariakit/core/utils/misc";
14
+ import { batch, init, subscribe, sync } from "@ariakit/core/utils/store";
14
15
  import { flushSync } from "react-dom";
15
16
  import { useSyncExternalStore } from "use-sync-external-store/shim/index.js";
16
17
  var noopSubscribe = () => () => {
@@ -38,6 +39,14 @@ function safeFlushSync(fn, canFlushSync = true) {
38
39
  }
39
40
  }
40
41
  function useStoreState(store, keyOrSelector = identity) {
42
+ const storeSubscribe = React.useCallback(
43
+ (callback) => {
44
+ if (!store)
45
+ return noopSubscribe();
46
+ return subscribe(store, null, callback);
47
+ },
48
+ [store]
49
+ );
41
50
  const getSnapshot = () => {
42
51
  if (!store)
43
52
  return;
@@ -52,11 +61,7 @@ function useStoreState(store, keyOrSelector = identity) {
52
61
  return;
53
62
  return state[key];
54
63
  };
55
- return useSyncExternalStore(
56
- (store == null ? void 0 : store.subscribe) || noopSubscribe,
57
- getSnapshot,
58
- getSnapshot
59
- );
64
+ return useSyncExternalStore(storeSubscribe, getSnapshot, getSnapshot);
60
65
  }
61
66
  function useStoreProps(store, props, key, setKey) {
62
67
  const value = hasOwnProperty(props, key) ? props[key] : void 0;
@@ -69,36 +74,36 @@ function useStoreProps(store, props, key, setKey) {
69
74
  queueMicrotask(() => {
70
75
  canFlushSync = true;
71
76
  });
72
- return store.sync(
73
- (state, prev) => {
74
- const { value: value2, setValue } = propsRef.current;
75
- if (!setValue)
76
- return;
77
- if (state[key] === prev[key])
78
- return;
79
- if (state[key] === value2)
80
- return;
81
- safeFlushSync(() => setValue(state[key]), canFlushSync);
82
- },
83
- [key]
84
- );
77
+ return sync(store, [key], (state, prev) => {
78
+ const { value: value2, setValue } = propsRef.current;
79
+ if (!setValue)
80
+ return;
81
+ if (state[key] === prev[key])
82
+ return;
83
+ if (state[key] === value2)
84
+ return;
85
+ safeFlushSync(() => setValue(state[key]), canFlushSync);
86
+ });
85
87
  }, [store, key]);
86
88
  useSafeLayoutEffect(() => {
87
- return store.sync(() => {
89
+ return batch(store, [key], () => {
88
90
  if (value === void 0)
89
91
  return;
90
92
  store.setState(key, value);
91
- }, [key]);
93
+ });
92
94
  }, [store, key, value]);
93
95
  }
94
96
  function useStore(createStore) {
95
97
  const store = useLazyValue(createStore);
96
- useSafeLayoutEffect(() => store.init(), [store]);
97
- const useState = useCallback(
98
+ useSafeLayoutEffect(() => init(store), [store]);
99
+ const useState = React.useCallback(
98
100
  (keyOrSelector) => useStoreState(store, keyOrSelector),
99
101
  [store]
100
102
  );
101
- return useMemo(() => __spreadProps(__spreadValues({}, store), { useState }), [store, useState]);
103
+ return React.useMemo(
104
+ () => __spreadProps(__spreadValues({}, store), { useState }),
105
+ [store, useState]
106
+ );
102
107
  }
103
108
 
104
109
  export {
@@ -11,7 +11,7 @@ import {
11
11
  } from "./NQJBHION.js";
12
12
  import {
13
13
  useStoreState
14
- } from "./MXMUDZTV.js";
14
+ } from "./QPTZ2G2N.js";
15
15
  import {
16
16
  useEvent,
17
17
  useMergeRefs,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  DialogBackdrop
3
- } from "./H3BU75TA.js";
3
+ } from "./432NLB7J.js";
4
4
  import {
5
5
  disableTreeOutside
6
6
  } from "./NHPU54IO.js";
@@ -12,7 +12,7 @@ import {
12
12
  } from "./3LAWLNOX.js";
13
13
  import {
14
14
  useNestedDialogs
15
- } from "./OEA63YXU.js";
15
+ } from "./PLOINBVB.js";
16
16
  import {
17
17
  useHideOnInteractOutside
18
18
  } from "./E5XSMSHD.js";
@@ -166,7 +166,7 @@ var useDialog = createHook(
166
166
  if (dialog && contains(dialog, activeElement))
167
167
  return;
168
168
  store.setDisclosureElement(activeElement);
169
- }, [open]);
169
+ }, [open, store]);
170
170
  if (isSafariBrowser) {
171
171
  useEffect(() => {
172
172
  if (!mounted)
@@ -194,7 +194,7 @@ var useDialog = createHook(
194
194
  return () => {
195
195
  disclosureElement.removeEventListener("mousedown", onMouseDown);
196
196
  };
197
- }, [mounted]);
197
+ }, [mounted, store]);
198
198
  }
199
199
  const shouldDisableAccessibilityTree = modal || // Usually, we only want to disable the accessibility tree outside if the
200
200
  // dialog is a modal. But the Portal component can't preserve the tab
@@ -405,7 +405,7 @@ var useDialog = createHook(
405
405
  store.hide();
406
406
  };
407
407
  return addGlobalEventListener("keydown", onKeyDown);
408
- }, [mounted, domReady, hideOnEscapeProp]);
408
+ }, [mounted, domReady, store, hideOnEscapeProp]);
409
409
  props = useWrapElement(
410
410
  props,
411
411
  (element) => /* @__PURE__ */ jsx(HeadingLevel, { level: modal ? 1 : void 0, children: element }),
@@ -10,7 +10,7 @@ import {
10
10
  } from "./W5P7IKOU.js";
11
11
  import {
12
12
  useCompositeItem
13
- } from "./VVJJXZ6R.js";
13
+ } from "./7SIWUER2.js";
14
14
  import {
15
15
  createElement,
16
16
  createHook,
@@ -18,7 +18,7 @@ import {
18
18
  } from "./NQJBHION.js";
19
19
  import {
20
20
  useStoreState
21
- } from "./MXMUDZTV.js";
21
+ } from "./QPTZ2G2N.js";
22
22
  import {
23
23
  useBooleanEvent,
24
24
  useEvent
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  usePopoverStoreOptions,
3
3
  usePopoverStoreProps
4
- } from "./SPTQP5I5.js";
4
+ } from "./EICJBDBV.js";
5
5
  import {
6
6
  useStore,
7
7
  useStoreProps
8
- } from "./MXMUDZTV.js";
8
+ } from "./QPTZ2G2N.js";
9
9
  import {
10
10
  __spreadValues
11
11
  } from "./PNRLI7OV.js";
@@ -17,7 +17,7 @@ import {
17
17
  } from "./PNRLI7OV.js";
18
18
 
19
19
  // src/collection/collection-item.ts
20
- import { useCallback, useContext, useRef } from "react";
20
+ import { useContext, useEffect, useRef } from "react";
21
21
  import { identity } from "@ariakit/core/utils/misc";
22
22
  var useCollectionItem = createHook(
23
23
  (_a) => {
@@ -36,18 +36,18 @@ var useCollectionItem = createHook(
36
36
  const context = useContext(CollectionContext);
37
37
  store = store || context;
38
38
  const id = useId(props.id);
39
- const unrenderItem = useRef();
40
- const ref = useCallback(
41
- (element2) => {
42
- var _a2;
43
- if (!element2 || !id || !shouldRegisterItem) {
44
- return (_a2 = unrenderItem.current) == null ? void 0 : _a2.call(unrenderItem);
45
- }
46
- const item = getItem({ id, element: element2 });
47
- unrenderItem.current = store == null ? void 0 : store.renderItem(item);
48
- },
49
- [id, shouldRegisterItem, getItem, store]
50
- );
39
+ const ref = useRef(element);
40
+ useEffect(() => {
41
+ const element2 = ref.current;
42
+ if (!id)
43
+ return;
44
+ if (!element2)
45
+ return;
46
+ if (!shouldRegisterItem)
47
+ return;
48
+ const item = getItem({ id, element: element2 });
49
+ return store == null ? void 0 : store.renderItem(item);
50
+ }, [id, shouldRegisterItem, getItem, store]);
51
51
  props = __spreadProps(__spreadValues({}, props), {
52
52
  ref: useMergeRefs(ref, props.ref)
53
53
  });
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  useCollectionStoreOptions,
3
3
  useCollectionStoreProps
4
- } from "./WNGYZL6A.js";
4
+ } from "./FSTINJD5.js";
5
5
  import {
6
6
  useStore,
7
7
  useStoreProps
8
- } from "./MXMUDZTV.js";
8
+ } from "./QPTZ2G2N.js";
9
9
  import {
10
10
  __spreadValues
11
11
  } from "./PNRLI7OV.js";
@@ -24,6 +24,7 @@ import { addGlobalEventListener } from "@ariakit/core/utils/events";
24
24
  var useHovercardAnchor = createHook(
25
25
  (_a) => {
26
26
  var _b = _a, { store, showOnHover = true } = _b, props = __objRest(_b, ["store", "showOnHover"]);
27
+ const mounted = store.useState("mounted");
27
28
  const disabled = props.disabled || props["aria-disabled"] === true || props["aria-disabled"] === "true";
28
29
  const showTimeoutRef = useRef(0);
29
30
  useEffect(() => () => window.clearTimeout(showTimeoutRef.current), []);
@@ -66,7 +67,14 @@ var useHovercardAnchor = createHook(
66
67
  }
67
68
  );
68
69
  props = __spreadProps(__spreadValues({}, props), {
69
- ref: useMergeRefs(store.setAnchorElement, props.ref),
70
+ ref: useMergeRefs(
71
+ store.setAnchorElement,
72
+ // We need to set the anchor element as the hovercard disclosure
73
+ // disclosure element only when the hovercard is shown so it doesn't get
74
+ // assigned an arbitrary element by the dialog component.
75
+ mounted ? store.setDisclosureElement : void 0,
76
+ props.ref
77
+ ),
70
78
  onMouseMove
71
79
  });
72
80
  props = useFocusable(props);
@@ -2,8 +2,8 @@ import {
2
2
  useCheckboxStore,
3
3
  useCheckboxStoreOptions,
4
4
  useCheckboxStoreProps
5
- } from "../__chunks/4LTL37RB.js";
6
- import "../__chunks/MXMUDZTV.js";
5
+ } from "../__chunks/CYNFBMYS.js";
6
+ import "../__chunks/QPTZ2G2N.js";
7
7
  import "../__chunks/J7Q2EO23.js";
8
8
  import "../__chunks/CP3U4HPL.js";
9
9
  import "../__chunks/PNRLI7OV.js";
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  Checkbox,
3
3
  useCheckbox
4
- } from "../__chunks/JWSYWSCR.js";
4
+ } from "../__chunks/R4VIEIUH.js";
5
5
  import "../__chunks/M5KYRTQG.js";
6
6
  import "../__chunks/P4RGQGTG.js";
7
7
  import "../__chunks/MYID4V27.js";
8
8
  import "../__chunks/BMLNRUFQ.js";
9
9
  import "../__chunks/NQJBHION.js";
10
- import "../__chunks/MXMUDZTV.js";
10
+ import "../__chunks/QPTZ2G2N.js";
11
11
  import "../__chunks/J7Q2EO23.js";
12
12
  import "../__chunks/CP3U4HPL.js";
13
13
  import "../__chunks/PNRLI7OV.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CollectionItem,
3
3
  useCollectionItem
4
- } from "../__chunks/HGFTMLQ7.js";
4
+ } from "../__chunks/VFNGSUSF.js";
5
5
  import "../__chunks/T3DJZG63.js";
6
6
  import "../__chunks/NQJBHION.js";
7
7
  import "../__chunks/J7Q2EO23.js";
@@ -3,10 +3,10 @@ import {
3
3
  getCollectionRendererItem,
4
4
  getCollectionRendererItemId,
5
5
  useCollectionRenderer
6
- } from "../__chunks/QLIKSQTQ.js";
6
+ } from "../__chunks/5PDNXTAR.js";
7
7
  import "../__chunks/T3DJZG63.js";
8
8
  import "../__chunks/NQJBHION.js";
9
- import "../__chunks/MXMUDZTV.js";
9
+ import "../__chunks/QPTZ2G2N.js";
10
10
  import "../__chunks/J7Q2EO23.js";
11
11
  import "../__chunks/CP3U4HPL.js";
12
12
  import "../__chunks/PNRLI7OV.js";
@@ -2,8 +2,8 @@ import {
2
2
  useCollectionStore,
3
3
  useCollectionStoreOptions,
4
4
  useCollectionStoreProps
5
- } from "../__chunks/WNGYZL6A.js";
6
- import "../__chunks/MXMUDZTV.js";
5
+ } from "../__chunks/FSTINJD5.js";
6
+ import "../__chunks/QPTZ2G2N.js";
7
7
  import "../__chunks/J7Q2EO23.js";
8
8
  import "../__chunks/CP3U4HPL.js";
9
9
  import "../__chunks/PNRLI7OV.js";
@@ -7,9 +7,9 @@ import {
7
7
  } from "../__chunks/W5P7IKOU.js";
8
8
  import {
9
9
  useCompositeItem
10
- } from "../__chunks/VVJJXZ6R.js";
10
+ } from "../__chunks/7SIWUER2.js";
11
11
  import "../__chunks/P4RGQGTG.js";
12
- import "../__chunks/HGFTMLQ7.js";
12
+ import "../__chunks/VFNGSUSF.js";
13
13
  import "../__chunks/T3DJZG63.js";
14
14
  import "../__chunks/OXPV2NBK.js";
15
15
  import "../__chunks/WJ37OVG2.js";
@@ -20,7 +20,7 @@ import {
20
20
  createHook,
21
21
  createMemoComponent
22
22
  } from "../__chunks/NQJBHION.js";
23
- import "../__chunks/MXMUDZTV.js";
23
+ import "../__chunks/QPTZ2G2N.js";
24
24
  import {
25
25
  useBooleanEvent,
26
26
  useEvent,
@@ -4,14 +4,14 @@ import {
4
4
  import "../__chunks/5VGBBGF5.js";
5
5
  import {
6
6
  usePopover
7
- } from "../__chunks/JHKKFNCJ.js";
8
- import "../__chunks/BIPBU2AE.js";
9
- import "../__chunks/H3BU75TA.js";
7
+ } from "../__chunks/CU3AKJBN.js";
8
+ import "../__chunks/TG7IDXTX.js";
9
+ import "../__chunks/432NLB7J.js";
10
10
  import "../__chunks/NHPU54IO.js";
11
11
  import "../__chunks/GDORSOK6.js";
12
12
  import "../__chunks/3LAWLNOX.js";
13
13
  import "../__chunks/CJI67A3R.js";
14
- import "../__chunks/OEA63YXU.js";
14
+ import "../__chunks/PLOINBVB.js";
15
15
  import "../__chunks/E5XSMSHD.js";
16
16
  import "../__chunks/LEBYH5FW.js";
17
17
  import "../__chunks/IXXFVVA2.js";
@@ -38,8 +38,8 @@ import {
38
38
  createElement,
39
39
  createHook
40
40
  } from "../__chunks/NQJBHION.js";
41
- import "../__chunks/JJW3R5IK.js";
42
- import "../__chunks/MXMUDZTV.js";
41
+ import "../__chunks/F6PEGR7W.js";
42
+ import "../__chunks/QPTZ2G2N.js";
43
43
  import "../__chunks/J7Q2EO23.js";
44
44
  import "../__chunks/CP3U4HPL.js";
45
45
  import {
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  useCompositeStoreOptions,
3
3
  useCompositeStoreProps
4
- } from "../__chunks/36V3RYFS.js";
5
- import "../__chunks/WNGYZL6A.js";
4
+ } from "../__chunks/X5CHG5LF.js";
5
+ import "../__chunks/FSTINJD5.js";
6
6
  import {
7
7
  usePopoverStoreOptions,
8
8
  usePopoverStoreProps
9
- } from "../__chunks/SPTQP5I5.js";
10
- import "../__chunks/RRY7OZXM.js";
11
- import "../__chunks/JJW3R5IK.js";
9
+ } from "../__chunks/EICJBDBV.js";
10
+ import "../__chunks/FW5SU7FV.js";
11
+ import "../__chunks/F6PEGR7W.js";
12
12
  import {
13
13
  useStore,
14
14
  useStoreProps
15
- } from "../__chunks/MXMUDZTV.js";
15
+ } from "../__chunks/QPTZ2G2N.js";
16
16
  import "../__chunks/J7Q2EO23.js";
17
17
  import "../__chunks/CP3U4HPL.js";
18
18
  import {
@@ -271,9 +271,6 @@ var useCombobox = createHook(
271
271
  setCanInline(textInserted && caretAtEnd);
272
272
  }
273
273
  }
274
- if (showOnChangeProp(event)) {
275
- store.show();
276
- }
277
274
  if (setValueOnChangeProp(event)) {
278
275
  const isSameValue = value2 === store.getState().value;
279
276
  store.setValue(value2);
@@ -281,6 +278,9 @@ var useCombobox = createHook(
281
278
  forceValueUpdate();
282
279
  }
283
280
  }
281
+ if (showOnChangeProp(event)) {
282
+ store.show();
283
+ }
284
284
  if (!autoSelect || !canAutoSelectRef.current) {
285
285
  store.setActiveId(null);
286
286
  }