@ariakit/react-core 0.3.6 → 0.3.7

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 (61) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/cjs/__chunks/{45RPYV4J.cjs → EQ4A5RPW.cjs} +2 -2
  3. package/cjs/__chunks/{RRW7YVFR.cjs → IPYAEPOT.cjs} +17 -6
  4. package/cjs/__chunks/{4GLXDOKG.cjs → YAPOM5RT.cjs} +2 -2
  5. package/cjs/combobox/combobox-item.cjs +2 -2
  6. package/cjs/combobox/combobox-popover.cjs +2 -2
  7. package/cjs/combobox/combobox-store.d.cts +2 -1
  8. package/cjs/combobox/combobox-store.d.ts +2 -1
  9. package/cjs/combobox/combobox.cjs +6 -2
  10. package/cjs/combobox/combobox.d.cts +2 -1
  11. package/cjs/combobox/combobox.d.ts +2 -1
  12. package/cjs/composite/composite-hover.cjs +2 -2
  13. package/cjs/composite/composite-hover.d.cts +6 -0
  14. package/cjs/composite/composite-hover.d.ts +6 -0
  15. package/cjs/composite/composite-overflow.cjs +2 -2
  16. package/cjs/disclosure/disclosure-content.d.cts +2 -1
  17. package/cjs/disclosure/disclosure-content.d.ts +2 -1
  18. package/cjs/focusable/focusable.d.cts +1 -1
  19. package/cjs/focusable/focusable.d.ts +1 -1
  20. package/cjs/hovercard/hovercard.cjs +3 -3
  21. package/cjs/menu/menu-button.cjs +33 -21
  22. package/cjs/menu/menu-item-checkbox.cjs +3 -3
  23. package/cjs/menu/menu-item-radio.cjs +3 -3
  24. package/cjs/menu/menu-item.cjs +3 -3
  25. package/cjs/menu/menu-store.d.cts +4 -46
  26. package/cjs/menu/menu-store.d.ts +4 -46
  27. package/cjs/menu/menu.cjs +3 -3
  28. package/cjs/popover/popover.cjs +2 -2
  29. package/cjs/portal/portal.d.cts +2 -1
  30. package/cjs/portal/portal.d.ts +2 -1
  31. package/cjs/select/select-item.cjs +2 -2
  32. package/cjs/select/select-popover.cjs +2 -2
  33. package/cjs/tooltip/tooltip.cjs +3 -3
  34. package/esm/__chunks/{YGJUONJM.js → BONLQCKO.js} +1 -1
  35. package/esm/__chunks/{BRO2JF5P.js → G6ONQ5EH.js} +20 -9
  36. package/esm/__chunks/{W3TC4TID.js → JRUYDVPB.js} +1 -1
  37. package/esm/combobox/combobox-item.js +1 -1
  38. package/esm/combobox/combobox-popover.js +1 -1
  39. package/esm/combobox/combobox-store.d.ts +2 -1
  40. package/esm/combobox/combobox.d.ts +2 -1
  41. package/esm/combobox/combobox.js +7 -3
  42. package/esm/composite/composite-hover.d.ts +6 -0
  43. package/esm/composite/composite-hover.js +1 -1
  44. package/esm/composite/composite-overflow.js +1 -1
  45. package/esm/disclosure/disclosure-content.d.ts +2 -1
  46. package/esm/focusable/focusable.d.ts +1 -1
  47. package/esm/hovercard/hovercard.js +2 -2
  48. package/esm/menu/menu-button.js +33 -21
  49. package/esm/menu/menu-item-checkbox.js +2 -2
  50. package/esm/menu/menu-item-radio.js +2 -2
  51. package/esm/menu/menu-item.js +2 -2
  52. package/esm/menu/menu-store.d.ts +4 -46
  53. package/esm/menu/menu.js +2 -2
  54. package/esm/popover/popover.js +1 -1
  55. package/esm/portal/portal.d.ts +2 -1
  56. package/esm/select/select-item.js +1 -1
  57. package/esm/select/select-popover.js +1 -1
  58. package/esm/tooltip/tooltip.js +2 -2
  59. package/package.json +2 -2
  60. package/cjs/__chunks/{ISGOCBDC.cjs → RIZYIKBE.cjs} +1 -1
  61. package/esm/__chunks/{KB2HXEVC.js → WBQC3LL4.js} +1 -1
@@ -25,53 +25,11 @@ export declare function useMenuStoreProps<T extends Core.MenuStore>(store: T, up
25
25
  }> & import("@ariakit/core/utils/store").Store<Core.MenuStoreState<{
26
26
  [x: string]: string | number | boolean | (string | number)[];
27
27
  }>>) | null | undefined;
28
- menubar: (import("../menubar/menubar-store.js").MenubarStoreFunctions & import("@ariakit/core/composite/composite-store").CompositeStoreFunctions<{
29
- id: string;
30
- element?: HTMLElement | null | undefined;
31
- } & {
32
- rowId?: string | undefined;
33
- disabled?: boolean | undefined;
34
- children?: string | undefined;
35
- }> & import("@ariakit/core/utils/store").Store<import("@ariakit/core/composite/composite-store").CompositeStoreState<{
36
- id: string;
37
- element?: HTMLElement | null | undefined;
38
- } & {
39
- rowId?: string | undefined;
40
- disabled?: boolean | undefined;
41
- children?: string | undefined;
42
- }>> & {
28
+ menubar: (import("../menubar/menubar-store.js").MenubarStoreFunctions & import("@ariakit/core/menubar/menubar-store").MenubarStore & {
43
29
  useState: {
44
- (): import("@ariakit/core/composite/composite-store").CompositeStoreState<{
45
- id: string;
46
- element?: HTMLElement | null | undefined;
47
- } & {
48
- rowId?: string | undefined;
49
- disabled?: boolean | undefined;
50
- children?: string | undefined;
51
- }>;
52
- <K_2 extends keyof import("@ariakit/core/composite/composite-store").CompositeStoreState<{
53
- id: string;
54
- element?: HTMLElement | null | undefined;
55
- } & {
56
- rowId?: string | undefined;
57
- disabled?: boolean | undefined;
58
- children?: string | undefined;
59
- }>>(key: K_2): import("@ariakit/core/composite/composite-store").CompositeStoreState<{
60
- id: string;
61
- element?: HTMLElement | null | undefined;
62
- } & {
63
- rowId?: string | undefined;
64
- disabled?: boolean | undefined;
65
- children?: string | undefined;
66
- }>[K_2];
67
- <V_2>(selector: (state: import("@ariakit/core/composite/composite-store").CompositeStoreState<{
68
- id: string;
69
- element?: HTMLElement | null | undefined;
70
- } & {
71
- rowId?: string | undefined;
72
- disabled?: boolean | undefined;
73
- children?: string | undefined;
74
- }>) => V_2): V_2;
30
+ (): import("@ariakit/core/menubar/menubar-store").MenubarStoreState;
31
+ <K_2 extends keyof import("@ariakit/core/menubar/menubar-store").MenubarStoreState>(key: K_2): import("@ariakit/core/menubar/menubar-store").MenubarStoreState[K_2];
32
+ <V_2>(selector: (state: import("@ariakit/core/menubar/menubar-store").MenubarStoreState) => V_2): V_2;
75
33
  };
76
34
  }) | null | undefined;
77
35
  };
package/cjs/menu/menu.cjs CHANGED
@@ -13,9 +13,9 @@ require('../__chunks/UZNYSPKP.cjs');
13
13
  require('../__chunks/BZTDJIVT.cjs');
14
14
 
15
15
 
16
- var _45RPYV4Jcjs = require('../__chunks/45RPYV4J.cjs');
16
+ var _EQ4A5RPWcjs = require('../__chunks/EQ4A5RPW.cjs');
17
17
  require('../__chunks/KXQOQQ5B.cjs');
18
- require('../__chunks/ISGOCBDC.cjs');
18
+ require('../__chunks/RIZYIKBE.cjs');
19
19
 
20
20
 
21
21
  var _XFPRAS3Jcjs = require('../__chunks/XFPRAS3J.cjs');
@@ -144,7 +144,7 @@ var useMenu = _RNZNGEL4cjs.createHook.call(void 0,
144
144
  const modal = hasParentMenu ? false : modalProp;
145
145
  const mayAutoFocusOnShow = !!autoFocusOnShow;
146
146
  const canAutoFocusOnShow = !!initialFocusRef || !!props.initialFocus || !!modal;
147
- props = _45RPYV4Jcjs.useHovercard.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
147
+ props = _EQ4A5RPWcjs.useHovercard.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
148
148
  store,
149
149
  alwaysVisible,
150
150
  initialFocus: initialFocusRef,
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
 
5
- var _ISGOCBDCcjs = require('../__chunks/ISGOCBDC.cjs');
5
+ var _RIZYIKBEcjs = require('../__chunks/RIZYIKBE.cjs');
6
6
  require('../__chunks/XFPRAS3J.cjs');
7
7
  require('../__chunks/SHOS7XOU.cjs');
8
8
  require('../__chunks/NKR65BKC.cjs');
@@ -42,4 +42,4 @@ require('../__chunks/AV6KTKLE.cjs');
42
42
 
43
43
 
44
44
 
45
- exports.Popover = _ISGOCBDCcjs.Popover; exports.usePopover = _ISGOCBDCcjs.usePopover;
45
+ exports.Popover = _RIZYIKBEcjs.Popover; exports.usePopover = _RIZYIKBEcjs.usePopover;
@@ -83,7 +83,8 @@ export interface PortalOptions<T extends As = "div"> extends Options<T> {
83
83
  * Determines whether the element should be rendered as a React Portal.
84
84
  *
85
85
  * Live examples:
86
- * - [ComboboxGroup](https://ariakit.org/examples/combobox-group)
86
+ * - [Combobox with integrated
87
+ * filter](https://ariakit.org/examples/combobox-filtering-integrated)
87
88
  * - [Dialog with Menu](https://ariakit.org/examples/dialog-menu)
88
89
  * - [Hovercard with keyboard
89
90
  * support](https://ariakit.org/examples/hovercard-disclosure)
@@ -83,7 +83,8 @@ export interface PortalOptions<T extends As = "div"> extends Options<T> {
83
83
  * Determines whether the element should be rendered as a React Portal.
84
84
  *
85
85
  * Live examples:
86
- * - [ComboboxGroup](https://ariakit.org/examples/combobox-group)
86
+ * - [Combobox with integrated
87
+ * filter](https://ariakit.org/examples/combobox-filtering-integrated)
87
88
  * - [Dialog with Menu](https://ariakit.org/examples/dialog-menu)
88
89
  * - [Hovercard with keyboard
89
90
  * support](https://ariakit.org/examples/hovercard-disclosure)
@@ -1,7 +1,7 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _RRW7YVFRcjs = require('../__chunks/RRW7YVFR.cjs');
4
+ var _IPYAEPOTcjs = require('../__chunks/IPYAEPOT.cjs');
5
5
 
6
6
 
7
7
 
@@ -158,7 +158,7 @@ var useSelectItem = _RNZNGEL4cjs.createHook.call(void 0,
158
158
  preventScrollOnKeyDown
159
159
  }, props));
160
160
  const focusOnHoverProp = _EO6LS72Hcjs.useBooleanEvent.call(void 0, focusOnHover);
161
- props = _RRW7YVFRcjs.useCompositeHover.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
161
+ props = _IPYAEPOTcjs.useCompositeHover.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {
162
162
  store
163
163
  }, props), {
164
164
  // We have to disable focusOnHover when the popup is closed, otherwise
@@ -12,7 +12,7 @@ require('../__chunks/UZNYSPKP.cjs');
12
12
  require('../__chunks/BZTDJIVT.cjs');
13
13
 
14
14
 
15
- var _ISGOCBDCcjs = require('../__chunks/ISGOCBDC.cjs');
15
+ var _RIZYIKBEcjs = require('../__chunks/RIZYIKBE.cjs');
16
16
 
17
17
 
18
18
  var _XFPRAS3Jcjs = require('../__chunks/XFPRAS3J.cjs');
@@ -66,7 +66,7 @@ var useSelectPopover = _RNZNGEL4cjs.createHook.call(void 0,
66
66
  const context = _2WCJJQSKcjs.useSelectProviderContext.call(void 0, );
67
67
  store = store || context;
68
68
  props = _F24A3PBWcjs.useSelectList.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, { store, alwaysVisible }, props));
69
- props = _ISGOCBDCcjs.usePopover.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, { store, alwaysVisible }, props));
69
+ props = _RIZYIKBEcjs.usePopover.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, { store, alwaysVisible }, props));
70
70
  return props;
71
71
  }
72
72
  );
@@ -1,9 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
2
 
3
3
 
4
- var _45RPYV4Jcjs = require('../__chunks/45RPYV4J.cjs');
4
+ var _EQ4A5RPWcjs = require('../__chunks/EQ4A5RPW.cjs');
5
5
  require('../__chunks/KXQOQQ5B.cjs');
6
- require('../__chunks/ISGOCBDC.cjs');
6
+ require('../__chunks/RIZYIKBE.cjs');
7
7
 
8
8
 
9
9
  var _XFPRAS3Jcjs = require('../__chunks/XFPRAS3J.cjs');
@@ -94,7 +94,7 @@ var useTooltip = _RNZNGEL4cjs.createHook.call(void 0,
94
94
  (state) => state.type === "description" ? "tooltip" : "none"
95
95
  );
96
96
  props = _AV6KTKLEcjs.__spreadValues.call(void 0, { role }, props);
97
- props = _45RPYV4Jcjs.useHovercard.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
97
+ props = _EQ4A5RPWcjs.useHovercard.call(void 0, _AV6KTKLEcjs.__spreadProps.call(void 0, _AV6KTKLEcjs.__spreadValues.call(void 0, {}, props), {
98
98
  store,
99
99
  portal,
100
100
  gutter,
@@ -6,7 +6,7 @@ import {
6
6
  } from "./YMV43K4F.js";
7
7
  import {
8
8
  usePopover
9
- } from "./KB2HXEVC.js";
9
+ } from "./WBQC3LL4.js";
10
10
  import {
11
11
  createDialogComponent
12
12
  } from "./U7WGY7YX.js";
@@ -10,7 +10,8 @@ import {
10
10
  import {
11
11
  useBooleanEvent,
12
12
  useEvent,
13
- useIsMouseMoving
13
+ useIsMouseMoving,
14
+ useMergeRefs
14
15
  } from "./6O5OEQGF.js";
15
16
  import {
16
17
  __objRest,
@@ -19,9 +20,10 @@ import {
19
20
  } from "./4R3V3JGP.js";
20
21
 
21
22
  // src/composite/composite-hover.ts
22
- import { closest, contains } from "@ariakit/core/utils/dom";
23
+ import { useCallback } from "react";
24
+ import { contains } from "@ariakit/core/utils/dom";
23
25
  import { hasFocus, hasFocusWithin } from "@ariakit/core/utils/focus";
24
- import { invariant } from "@ariakit/core/utils/misc";
26
+ import { hasOwnProperty, invariant } from "@ariakit/core/utils/misc";
25
27
  function getMouseDestination(event) {
26
28
  const relatedTarget = event.relatedTarget;
27
29
  if ((relatedTarget == null ? void 0 : relatedTarget.nodeType) === Node.ELEMENT_NODE) {
@@ -35,12 +37,17 @@ function hoveringInside(event) {
35
37
  return false;
36
38
  return contains(event.currentTarget, nextElement);
37
39
  }
40
+ var symbol = Symbol("composite-hover");
38
41
  function movingToAnotherItem(event) {
39
- const dest = getMouseDestination(event);
42
+ let dest = getMouseDestination(event);
40
43
  if (!dest)
41
44
  return false;
42
- const item = closest(dest, "[data-composite-hover]");
43
- return !!item;
45
+ do {
46
+ if (hasOwnProperty(dest, symbol) && dest[symbol])
47
+ return true;
48
+ dest = dest.parentElement;
49
+ } while (dest);
50
+ return false;
44
51
  }
45
52
  var useCompositeHover = createHook(
46
53
  (_a) => {
@@ -98,9 +105,13 @@ var useCompositeHover = createHook(
98
105
  store == null ? void 0 : store.setActiveId(null);
99
106
  (_a2 = store == null ? void 0 : store.getState().baseElement) == null ? void 0 : _a2.focus();
100
107
  });
101
- props = __spreadProps(__spreadValues({
102
- "data-composite-hover": ""
103
- }, props), {
108
+ const ref = useCallback((element) => {
109
+ if (!element)
110
+ return;
111
+ element[symbol] = true;
112
+ }, []);
113
+ props = __spreadProps(__spreadValues({}, props), {
114
+ ref: useMergeRefs(ref, props.ref),
104
115
  onMouseMove,
105
116
  onMouseLeave
106
117
  });
@@ -7,7 +7,7 @@ import {
7
7
  } from "./KA4GX64Z.js";
8
8
  import {
9
9
  useCompositeHover
10
- } from "./BRO2JF5P.js";
10
+ } from "./G6ONQ5EH.js";
11
11
  import {
12
12
  useCompositeItem
13
13
  } from "./5PEPOQU7.js";
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  useCompositeHover
4
- } from "../__chunks/BRO2JF5P.js";
4
+ } from "../__chunks/G6ONQ5EH.js";
5
5
  import {
6
6
  ComboboxItemValueContext,
7
7
  useComboboxScopedContext
@@ -9,7 +9,7 @@ import "../__chunks/IB7YUKH5.js";
9
9
  import "../__chunks/4UUKJZ4V.js";
10
10
  import {
11
11
  usePopover
12
- } from "../__chunks/KB2HXEVC.js";
12
+ } from "../__chunks/WBQC3LL4.js";
13
13
  import {
14
14
  createDialogComponent
15
15
  } from "../__chunks/U7WGY7YX.js";
@@ -28,7 +28,8 @@ export interface ComboboxStoreOptions extends Core.ComboboxStoreOptions, Composi
28
28
  * A callback that gets called when the `value` state changes.
29
29
  *
30
30
  * Live examples:
31
- * - [Combobox filtering](https://ariakit.org/examples/combobox-filtering)
31
+ * - [Combobox with integrated
32
+ * filter](https://ariakit.org/examples/combobox-filtering-integrated)
32
33
  * - [ComboboxGroup](https://ariakit.org/examples/combobox-group)
33
34
  * - [Combobox with links](https://ariakit.org/examples/combobox-links)
34
35
  * - [Multi-selectable
@@ -59,7 +59,8 @@ export interface ComboboxOptions<T extends As = "input"> extends CompositeOption
59
59
  * popup opens, but the input value doesn't change.
60
60
  *
61
61
  * Live examples:
62
- * - [ComboboxCancel](https://ariakit.org/examples/combobox-cancel)
62
+ * - [Combobox with integrated
63
+ * filter](https://ariakit.org/examples/combobox-filtering-integrated)
63
64
  * - [ComboboxGroup](https://ariakit.org/examples/combobox-group)
64
65
  * - [Combobox with links](https://ariakit.org/examples/combobox-links)
65
66
  * - [Textarea with inline
@@ -40,7 +40,11 @@ import {
40
40
 
41
41
  // src/combobox/combobox.ts
42
42
  import { useEffect, useMemo, useRef, useState } from "react";
43
- import { getPopupRole, getScrollingElement } from "@ariakit/core/utils/dom";
43
+ import {
44
+ getPopupRole,
45
+ getScrollingElement,
46
+ setSelectionRange
47
+ } from "@ariakit/core/utils/dom";
44
48
  import {
45
49
  isFocusEventOutside,
46
50
  queueBeforeEvent
@@ -173,7 +177,7 @@ var useCombobox = createHook(
173
177
  const element = ref.current;
174
178
  if (!element)
175
179
  return;
176
- element.setSelectionRange(storeValue.length, activeValue.length);
180
+ setSelectionRange(element, storeValue.length, activeValue.length);
177
181
  });
178
182
  }, [
179
183
  valueUpdated,
@@ -296,7 +300,7 @@ var useCombobox = createHook(
296
300
  if (setValueOnChangeProp(event)) {
297
301
  const isSameValue = value2 === store.getState().value;
298
302
  flushSync(() => store == null ? void 0 : store.setValue(value2));
299
- event.currentTarget.setSelectionRange(selectionStart, selectionEnd);
303
+ setSelectionRange(event.currentTarget, selectionStart, selectionEnd);
300
304
  if (inline && autoSelect && isSameValue) {
301
305
  forceValueUpdate();
302
306
  }
@@ -46,6 +46,8 @@ export interface CompositeHoverOptions<T extends As = "div"> extends Options<T>
46
46
  * Determines if the composite item should be focused on hover.
47
47
  *
48
48
  * Live examples:
49
+ * - [Combobox with integrated
50
+ * filter](https://ariakit.org/examples/combobox-filtering-integrated)
49
51
  * - [Textarea with inline
50
52
  * Combobox](https://ariakit.org/examples/combobox-textarea)
51
53
  * @default true
@@ -56,6 +58,10 @@ export interface CompositeHoverOptions<T extends As = "div"> extends Options<T>
56
58
  * By default, this is set to `true` if
57
59
  * [`focusOnHover`](https://ariakit.org/reference/composite-hover#focusonhover)
58
60
  * is `true`.
61
+ *
62
+ * Live examples:
63
+ * - [Combobox with integrated
64
+ * filter](https://ariakit.org/examples/combobox-filtering-integrated)
59
65
  */
60
66
  blurOnHoverEnd?: BooleanOrCallback<ReactMouseEvent<HTMLElement>>;
61
67
  }
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  CompositeHover,
4
4
  useCompositeHover
5
- } from "../__chunks/BRO2JF5P.js";
5
+ } from "../__chunks/G6ONQ5EH.js";
6
6
  import "../__chunks/IB7YUKH5.js";
7
7
  import "../__chunks/4UUKJZ4V.js";
8
8
  import "../__chunks/3ORBWXWF.js";
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  usePopover
4
- } from "../__chunks/KB2HXEVC.js";
4
+ } from "../__chunks/WBQC3LL4.js";
5
5
  import "../__chunks/U7WGY7YX.js";
6
6
  import "../__chunks/JSLLR7RC.js";
7
7
  import "../__chunks/CLF4PQ7T.js";
@@ -61,7 +61,8 @@ export interface DisclosureContentOptions<T extends As = "div"> extends Options<
61
61
  * the DOM when it's hidden.
62
62
  *
63
63
  * Live examples:
64
- * - [Combobox with links](https://ariakit.org/examples/combobox-links)
64
+ * - [Combobox with integrated
65
+ * filter](https://ariakit.org/examples/combobox-filtering-integrated)
65
66
  * - [Textarea with inline
66
67
  * Combobox](https://ariakit.org/examples/combobox-textarea)
67
68
  * - [Standalone Popover](https://ariakit.org/examples/popover-standalone)
@@ -108,6 +108,6 @@ export interface FocusableOptions<T extends As = "div"> extends Options<T> {
108
108
  * Live examples:
109
109
  * - [Custom Checkbox](https://ariakit.org/examples/checkbox-custom)
110
110
  */
111
- onFocusVisible?: BivariantCallback<(event: SyntheticEvent) => void>;
111
+ onFocusVisible?: BivariantCallback<(event: SyntheticEvent<HTMLElement>) => void>;
112
112
  }
113
113
  export type FocusableProps<T extends As = "div"> = Props<FocusableOptions<T>>;
@@ -2,9 +2,9 @@
2
2
  import {
3
3
  Hovercard,
4
4
  useHovercard
5
- } from "../__chunks/YGJUONJM.js";
5
+ } from "../__chunks/BONLQCKO.js";
6
6
  import "../__chunks/YMV43K4F.js";
7
- import "../__chunks/KB2HXEVC.js";
7
+ import "../__chunks/WBQC3LL4.js";
8
8
  import "../__chunks/U7WGY7YX.js";
9
9
  import "../__chunks/JSLLR7RC.js";
10
10
  import "../__chunks/CLF4PQ7T.js";
@@ -65,14 +65,12 @@ function getInitialFocus(event, dir) {
65
65
  };
66
66
  return keyMap[event.key];
67
67
  }
68
- function hasActiveItem(items, currentTarget, relatedTarget) {
68
+ function hasActiveItem(items, excludeElement) {
69
69
  return !!(items == null ? void 0 : items.some((item) => {
70
70
  if (!item.element)
71
71
  return false;
72
- if (item.element === currentTarget)
72
+ if (item.element === excludeElement)
73
73
  return false;
74
- if (item.element === relatedTarget)
75
- return true;
76
74
  return item.element.getAttribute("aria-expanded") === "true";
77
75
  }));
78
76
  }
@@ -91,6 +89,14 @@ var useMenuButton = createHook(
91
89
  const hasParentMenu = !!parentMenu;
92
90
  const parentIsMenubar = !!parentMenubar && !hasParentMenu;
93
91
  const disabled = disabledFromProps(props);
92
+ const showMenu = () => {
93
+ const trigger = ref.current;
94
+ if (!trigger)
95
+ return;
96
+ store == null ? void 0 : store.setDisclosureElement(trigger);
97
+ store == null ? void 0 : store.setAnchorElement(trigger);
98
+ store == null ? void 0 : store.show();
99
+ };
94
100
  const onFocusProp = props.onFocus;
95
101
  const onFocus = useEvent((event) => {
96
102
  onFocusProp == null ? void 0 : onFocusProp(event);
@@ -105,10 +111,8 @@ var useMenuButton = createHook(
105
111
  if (!parentIsMenubar)
106
112
  return;
107
113
  const { items } = parentMenubar.getState();
108
- if (hasActiveItem(items, event.currentTarget, event.relatedTarget)) {
109
- store == null ? void 0 : store.setDisclosureElement(event.currentTarget);
110
- store == null ? void 0 : store.setAnchorElement(event.currentTarget);
111
- store == null ? void 0 : store.show();
114
+ if (hasActiveItem(items, event.currentTarget)) {
115
+ showMenu();
112
116
  }
113
117
  });
114
118
  const dir = store.useState(
@@ -124,9 +128,7 @@ var useMenuButton = createHook(
124
128
  const initialFocus = getInitialFocus(event, dir);
125
129
  if (initialFocus) {
126
130
  event.preventDefault();
127
- store == null ? void 0 : store.setAnchorElement(event.currentTarget);
128
- store == null ? void 0 : store.setDisclosureElement(event.currentTarget);
129
- store == null ? void 0 : store.show();
131
+ showMenu();
130
132
  store == null ? void 0 : store.setAutoFocusOnShow(true);
131
133
  store == null ? void 0 : store.setInitialFocus(initialFocus);
132
134
  }
@@ -147,7 +149,7 @@ var useMenuButton = createHook(
147
149
  store.setInitialFocus(isKeyboardClick ? "first" : "container");
148
150
  }
149
151
  if (hasParentMenu) {
150
- store.show();
152
+ showMenu();
151
153
  }
152
154
  });
153
155
  props = useWrapElement(
@@ -180,16 +182,26 @@ var useMenuButton = createHook(
180
182
  accessibleWhenDisabled
181
183
  }, props), {
182
184
  showOnHover: (event) => {
183
- if (typeof showOnHover === "function")
184
- return showOnHover(event);
185
- if (showOnHover != null)
186
- return showOnHover;
187
- if (hasParentMenu)
188
- return true;
189
- if (!parentMenubar)
185
+ const getShowOnHover = () => {
186
+ if (typeof showOnHover === "function")
187
+ return showOnHover(event);
188
+ if (showOnHover != null)
189
+ return showOnHover;
190
+ if (hasParentMenu)
191
+ return true;
192
+ if (!parentMenubar)
193
+ return false;
194
+ const { items } = parentMenubar.getState();
195
+ return parentIsMenubar && hasActiveItem(items);
196
+ };
197
+ const canShowOnHover = getShowOnHover();
198
+ if (!canShowOnHover)
190
199
  return false;
191
- const { items } = parentMenubar.getState();
192
- return parentIsMenubar && hasActiveItem(items);
200
+ const parent = parentIsMenubar ? parentMenubar : parentMenu;
201
+ if (!parent)
202
+ return true;
203
+ parent.setActiveId(event.currentTarget.id);
204
+ return true;
193
205
  }
194
206
  }));
195
207
  props = usePopoverDisclosure(__spreadValues({
@@ -8,12 +8,12 @@ import {
8
8
  import "../__chunks/VPR2WHQV.js";
9
9
  import {
10
10
  useMenuItem
11
- } from "../__chunks/W3TC4TID.js";
11
+ } from "../__chunks/JRUYDVPB.js";
12
12
  import {
13
13
  useMenuScopedContext
14
14
  } from "../__chunks/YGMEBI3A.js";
15
15
  import "../__chunks/KA4GX64Z.js";
16
- import "../__chunks/BRO2JF5P.js";
16
+ import "../__chunks/G6ONQ5EH.js";
17
17
  import "../__chunks/6XBVQI3K.js";
18
18
  import "../__chunks/5PEPOQU7.js";
19
19
  import "../__chunks/NWCBQ4CV.js";
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  useMenuItem
4
- } from "../__chunks/W3TC4TID.js";
4
+ } from "../__chunks/JRUYDVPB.js";
5
5
  import {
6
6
  MenuItemCheckedContext,
7
7
  useMenuScopedContext
@@ -11,7 +11,7 @@ import {
11
11
  useRadio
12
12
  } from "../__chunks/SZD4L3WR.js";
13
13
  import "../__chunks/XEV62JUQ.js";
14
- import "../__chunks/BRO2JF5P.js";
14
+ import "../__chunks/G6ONQ5EH.js";
15
15
  import "../__chunks/5PEPOQU7.js";
16
16
  import "../__chunks/NWCBQ4CV.js";
17
17
  import "../__chunks/UH3I23HL.js";
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  MenuItem,
4
4
  useMenuItem
5
- } from "../__chunks/W3TC4TID.js";
5
+ } from "../__chunks/JRUYDVPB.js";
6
6
  import "../__chunks/YGMEBI3A.js";
7
7
  import "../__chunks/KA4GX64Z.js";
8
- import "../__chunks/BRO2JF5P.js";
8
+ import "../__chunks/G6ONQ5EH.js";
9
9
  import "../__chunks/5PEPOQU7.js";
10
10
  import "../__chunks/NWCBQ4CV.js";
11
11
  import "../__chunks/UH3I23HL.js";
@@ -25,53 +25,11 @@ export declare function useMenuStoreProps<T extends Core.MenuStore>(store: T, up
25
25
  }> & import("@ariakit/core/utils/store").Store<Core.MenuStoreState<{
26
26
  [x: string]: string | number | boolean | (string | number)[];
27
27
  }>>) | null | undefined;
28
- menubar: (import("../menubar/menubar-store.js").MenubarStoreFunctions & import("@ariakit/core/composite/composite-store").CompositeStoreFunctions<{
29
- id: string;
30
- element?: HTMLElement | null | undefined;
31
- } & {
32
- rowId?: string | undefined;
33
- disabled?: boolean | undefined;
34
- children?: string | undefined;
35
- }> & import("@ariakit/core/utils/store").Store<import("@ariakit/core/composite/composite-store").CompositeStoreState<{
36
- id: string;
37
- element?: HTMLElement | null | undefined;
38
- } & {
39
- rowId?: string | undefined;
40
- disabled?: boolean | undefined;
41
- children?: string | undefined;
42
- }>> & {
28
+ menubar: (import("../menubar/menubar-store.js").MenubarStoreFunctions & import("@ariakit/core/menubar/menubar-store").MenubarStore & {
43
29
  useState: {
44
- (): import("@ariakit/core/composite/composite-store").CompositeStoreState<{
45
- id: string;
46
- element?: HTMLElement | null | undefined;
47
- } & {
48
- rowId?: string | undefined;
49
- disabled?: boolean | undefined;
50
- children?: string | undefined;
51
- }>;
52
- <K_2 extends keyof import("@ariakit/core/composite/composite-store").CompositeStoreState<{
53
- id: string;
54
- element?: HTMLElement | null | undefined;
55
- } & {
56
- rowId?: string | undefined;
57
- disabled?: boolean | undefined;
58
- children?: string | undefined;
59
- }>>(key: K_2): import("@ariakit/core/composite/composite-store").CompositeStoreState<{
60
- id: string;
61
- element?: HTMLElement | null | undefined;
62
- } & {
63
- rowId?: string | undefined;
64
- disabled?: boolean | undefined;
65
- children?: string | undefined;
66
- }>[K_2];
67
- <V_2>(selector: (state: import("@ariakit/core/composite/composite-store").CompositeStoreState<{
68
- id: string;
69
- element?: HTMLElement | null | undefined;
70
- } & {
71
- rowId?: string | undefined;
72
- disabled?: boolean | undefined;
73
- children?: string | undefined;
74
- }>) => V_2): V_2;
30
+ (): import("@ariakit/core/menubar/menubar-store").MenubarStoreState;
31
+ <K_2 extends keyof import("@ariakit/core/menubar/menubar-store").MenubarStoreState>(key: K_2): import("@ariakit/core/menubar/menubar-store").MenubarStoreState[K_2];
32
+ <V_2>(selector: (state: import("@ariakit/core/menubar/menubar-store").MenubarStoreState) => V_2): V_2;
75
33
  };
76
34
  }) | null | undefined;
77
35
  };
package/esm/menu/menu.js CHANGED
@@ -13,9 +13,9 @@ import "../__chunks/IB7YUKH5.js";
13
13
  import "../__chunks/4UUKJZ4V.js";
14
14
  import {
15
15
  useHovercard
16
- } from "../__chunks/YGJUONJM.js";
16
+ } from "../__chunks/BONLQCKO.js";
17
17
  import "../__chunks/YMV43K4F.js";
18
- import "../__chunks/KB2HXEVC.js";
18
+ import "../__chunks/WBQC3LL4.js";
19
19
  import {
20
20
  createDialogComponent
21
21
  } from "../__chunks/U7WGY7YX.js";
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  Popover,
4
4
  usePopover
5
- } from "../__chunks/KB2HXEVC.js";
5
+ } from "../__chunks/WBQC3LL4.js";
6
6
  import "../__chunks/U7WGY7YX.js";
7
7
  import "../__chunks/JSLLR7RC.js";
8
8
  import "../__chunks/CLF4PQ7T.js";