react-aria-components 1.4.0 → 1.5.0

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 (183) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +1 -1
  3. package/dist/Breadcrumbs.main.js +2 -2
  4. package/dist/Breadcrumbs.main.js.map +1 -1
  5. package/dist/Breadcrumbs.mjs +2 -2
  6. package/dist/Breadcrumbs.module.js +2 -2
  7. package/dist/Breadcrumbs.module.js.map +1 -1
  8. package/dist/Button.main.js.map +1 -1
  9. package/dist/Button.module.js.map +1 -1
  10. package/dist/Checkbox.main.js +2 -3
  11. package/dist/Checkbox.main.js.map +1 -1
  12. package/dist/Checkbox.mjs +3 -4
  13. package/dist/Checkbox.module.js +3 -4
  14. package/dist/Checkbox.module.js.map +1 -1
  15. package/dist/Collection.main.js +3 -2
  16. package/dist/Collection.main.js.map +1 -1
  17. package/dist/Collection.mjs +3 -2
  18. package/dist/Collection.module.js +3 -2
  19. package/dist/Collection.module.js.map +1 -1
  20. package/dist/ComboBox.main.js +2 -2
  21. package/dist/ComboBox.main.js.map +1 -1
  22. package/dist/ComboBox.mjs +2 -2
  23. package/dist/ComboBox.module.js +2 -2
  24. package/dist/ComboBox.module.js.map +1 -1
  25. package/dist/Dialog.main.js +34 -10
  26. package/dist/Dialog.main.js.map +1 -1
  27. package/dist/Dialog.mjs +36 -12
  28. package/dist/Dialog.module.js +36 -12
  29. package/dist/Dialog.module.js.map +1 -1
  30. package/dist/Disclosure.main.js +3 -1
  31. package/dist/Disclosure.main.js.map +1 -1
  32. package/dist/Disclosure.mjs +3 -1
  33. package/dist/Disclosure.module.js +3 -1
  34. package/dist/Disclosure.module.js.map +1 -1
  35. package/dist/DragAndDrop.main.js +1 -1
  36. package/dist/DragAndDrop.main.js.map +1 -1
  37. package/dist/DragAndDrop.mjs +1 -1
  38. package/dist/DragAndDrop.module.js +1 -1
  39. package/dist/DragAndDrop.module.js.map +1 -1
  40. package/dist/GridList.main.js +1 -0
  41. package/dist/GridList.main.js.map +1 -1
  42. package/dist/GridList.mjs +1 -0
  43. package/dist/GridList.module.js +1 -0
  44. package/dist/GridList.module.js.map +1 -1
  45. package/dist/Heading.main.js.map +1 -1
  46. package/dist/Heading.module.js.map +1 -1
  47. package/dist/ListBox.main.js +7 -2
  48. package/dist/ListBox.main.js.map +1 -1
  49. package/dist/ListBox.mjs +8 -4
  50. package/dist/ListBox.module.js +8 -4
  51. package/dist/ListBox.module.js.map +1 -1
  52. package/dist/Menu.main.js +67 -56
  53. package/dist/Menu.main.js.map +1 -1
  54. package/dist/Menu.mjs +69 -59
  55. package/dist/Menu.module.js +69 -59
  56. package/dist/Menu.module.js.map +1 -1
  57. package/dist/OverlayArrow.main.js +1 -1
  58. package/dist/OverlayArrow.main.js.map +1 -1
  59. package/dist/OverlayArrow.mjs +1 -1
  60. package/dist/OverlayArrow.module.js +1 -1
  61. package/dist/OverlayArrow.module.js.map +1 -1
  62. package/dist/Popover.main.js +1 -0
  63. package/dist/Popover.main.js.map +1 -1
  64. package/dist/Popover.mjs +1 -0
  65. package/dist/Popover.module.js +1 -0
  66. package/dist/Popover.module.js.map +1 -1
  67. package/dist/Select.main.js.map +1 -1
  68. package/dist/Select.module.js.map +1 -1
  69. package/dist/Table.main.js +3 -10
  70. package/dist/Table.main.js.map +1 -1
  71. package/dist/Table.mjs +3 -10
  72. package/dist/Table.module.js +3 -10
  73. package/dist/Table.module.js.map +1 -1
  74. package/dist/ToggleButton.main.js +20 -5
  75. package/dist/ToggleButton.main.js.map +1 -1
  76. package/dist/ToggleButton.mjs +22 -7
  77. package/dist/ToggleButton.module.js +22 -7
  78. package/dist/ToggleButton.module.js.map +1 -1
  79. package/dist/ToggleButtonGroup.main.js +62 -0
  80. package/dist/ToggleButtonGroup.main.js.map +1 -0
  81. package/dist/ToggleButtonGroup.mjs +51 -0
  82. package/dist/ToggleButtonGroup.module.js +51 -0
  83. package/dist/ToggleButtonGroup.module.js.map +1 -0
  84. package/dist/Tooltip.main.js +3 -2
  85. package/dist/Tooltip.main.js.map +1 -1
  86. package/dist/Tooltip.mjs +3 -2
  87. package/dist/Tooltip.module.js +3 -2
  88. package/dist/Tooltip.module.js.map +1 -1
  89. package/dist/Virtualizer.main.js.map +1 -1
  90. package/dist/Virtualizer.module.js.map +1 -1
  91. package/dist/import.mjs +5 -3
  92. package/dist/main.js +10 -3
  93. package/dist/main.js.map +1 -1
  94. package/dist/module.js +5 -3
  95. package/dist/module.js.map +1 -1
  96. package/dist/types.d.ts +149 -112
  97. package/dist/types.d.ts.map +1 -1
  98. package/i18n/ar-AE.js +1 -1
  99. package/i18n/ar-AE.mjs +1 -1
  100. package/i18n/bg-BG.js +1 -1
  101. package/i18n/bg-BG.mjs +1 -1
  102. package/i18n/cs-CZ.js +1 -1
  103. package/i18n/cs-CZ.mjs +1 -1
  104. package/i18n/da-DK.js +1 -1
  105. package/i18n/da-DK.mjs +1 -1
  106. package/i18n/de-DE.js +1 -1
  107. package/i18n/de-DE.mjs +1 -1
  108. package/i18n/el-GR.js +1 -1
  109. package/i18n/el-GR.mjs +1 -1
  110. package/i18n/en-US.js +1 -1
  111. package/i18n/en-US.mjs +1 -1
  112. package/i18n/es-ES.js +1 -1
  113. package/i18n/es-ES.mjs +1 -1
  114. package/i18n/et-EE.js +1 -1
  115. package/i18n/et-EE.mjs +1 -1
  116. package/i18n/fi-FI.js +1 -1
  117. package/i18n/fi-FI.mjs +1 -1
  118. package/i18n/fr-FR.js +1 -1
  119. package/i18n/fr-FR.mjs +1 -1
  120. package/i18n/he-IL.js +1 -1
  121. package/i18n/he-IL.mjs +1 -1
  122. package/i18n/hr-HR.js +1 -1
  123. package/i18n/hr-HR.mjs +1 -1
  124. package/i18n/hu-HU.js +1 -1
  125. package/i18n/hu-HU.mjs +1 -1
  126. package/i18n/it-IT.js +1 -1
  127. package/i18n/it-IT.mjs +1 -1
  128. package/i18n/ja-JP.js +1 -1
  129. package/i18n/ja-JP.mjs +1 -1
  130. package/i18n/ko-KR.js +1 -1
  131. package/i18n/ko-KR.mjs +1 -1
  132. package/i18n/lt-LT.js +1 -1
  133. package/i18n/lt-LT.mjs +1 -1
  134. package/i18n/lv-LV.js +1 -1
  135. package/i18n/lv-LV.mjs +1 -1
  136. package/i18n/nb-NO.js +1 -1
  137. package/i18n/nb-NO.mjs +1 -1
  138. package/i18n/nl-NL.js +1 -1
  139. package/i18n/nl-NL.mjs +1 -1
  140. package/i18n/pl-PL.js +1 -1
  141. package/i18n/pl-PL.mjs +1 -1
  142. package/i18n/pt-BR.js +1 -1
  143. package/i18n/pt-BR.mjs +1 -1
  144. package/i18n/pt-PT.js +1 -1
  145. package/i18n/pt-PT.mjs +1 -1
  146. package/i18n/ro-RO.js +1 -1
  147. package/i18n/ro-RO.mjs +1 -1
  148. package/i18n/ru-RU.js +1 -1
  149. package/i18n/ru-RU.mjs +1 -1
  150. package/i18n/sk-SK.js +1 -1
  151. package/i18n/sk-SK.mjs +1 -1
  152. package/i18n/sl-SI.js +1 -1
  153. package/i18n/sl-SI.mjs +1 -1
  154. package/i18n/sr-SP.js +1 -1
  155. package/i18n/sr-SP.mjs +1 -1
  156. package/i18n/sv-SE.js +1 -1
  157. package/i18n/sv-SE.mjs +1 -1
  158. package/i18n/tr-TR.js +1 -1
  159. package/i18n/tr-TR.mjs +1 -1
  160. package/i18n/uk-UA.js +1 -1
  161. package/i18n/uk-UA.mjs +1 -1
  162. package/i18n/zh-CN.js +1 -1
  163. package/i18n/zh-CN.mjs +1 -1
  164. package/i18n/zh-TW.js +1 -1
  165. package/i18n/zh-TW.mjs +1 -1
  166. package/package.json +35 -34
  167. package/src/Checkbox.tsx +3 -4
  168. package/src/Collection.tsx +7 -4
  169. package/src/Dialog.tsx +29 -14
  170. package/src/Disclosure.tsx +14 -6
  171. package/src/DragAndDrop.tsx +2 -2
  172. package/src/GridList.tsx +1 -0
  173. package/src/ListBox.tsx +12 -4
  174. package/src/Menu.tsx +74 -45
  175. package/src/OverlayArrow.tsx +5 -3
  176. package/src/Popover.tsx +2 -2
  177. package/src/Select.tsx +2 -2
  178. package/src/Table.tsx +2 -2
  179. package/src/ToggleButton.tsx +26 -9
  180. package/src/ToggleButtonGroup.tsx +68 -0
  181. package/src/Tooltip.tsx +4 -3
  182. package/src/Virtualizer.tsx +2 -2
  183. package/src/index.ts +8 -6
package/dist/Menu.main.js CHANGED
@@ -10,6 +10,7 @@ var $2JTht$reactaria = require("react-aria");
10
10
  var $2JTht$reactstately = require("react-stately");
11
11
  var $2JTht$reactariacollections = require("@react-aria/collections");
12
12
  var $2JTht$reactariautils = require("@react-aria/utils");
13
+ var $2JTht$reactstatelyselection = require("@react-stately/selection");
13
14
  var $2JTht$reactariainteractions = require("@react-aria/interactions");
14
15
  var $2JTht$react = require("react");
15
16
  var $2JTht$reactstatelymenu = require("@react-stately/menu");
@@ -30,6 +31,7 @@ $parcel$export(module.exports, "RootMenuTriggerStateContext", () => $a8f6e7d095d
30
31
  $parcel$export(module.exports, "MenuTrigger", () => $a8f6e7d095d1cc86$export$27d2ad3c5815583e);
31
32
  $parcel$export(module.exports, "SubmenuTrigger", () => $a8f6e7d095d1cc86$export$ecabc99eeffab7ca);
32
33
  $parcel$export(module.exports, "Menu", () => $a8f6e7d095d1cc86$export$d9b273488cd8ce6f);
34
+ $parcel$export(module.exports, "MenuSection", () => $a8f6e7d095d1cc86$export$4b1545b4f2016d26);
33
35
  $parcel$export(module.exports, "MenuItem", () => $a8f6e7d095d1cc86$export$2ce376c2cc3355c8);
34
36
  /*
35
37
  * Copyright 2022 Adobe. All rights reserved.
@@ -57,9 +59,11 @@ $parcel$export(module.exports, "MenuItem", () => $a8f6e7d095d1cc86$export$2ce376
57
59
 
58
60
 
59
61
 
62
+
60
63
  const $a8f6e7d095d1cc86$export$c7e742effb1c51e2 = /*#__PURE__*/ (0, $2JTht$react.createContext)(null);
61
64
  const $a8f6e7d095d1cc86$export$24aad8519b95b41b = /*#__PURE__*/ (0, $2JTht$react.createContext)(null);
62
65
  const $a8f6e7d095d1cc86$export$795aec4671cbae19 = /*#__PURE__*/ (0, $2JTht$react.createContext)(null);
66
+ const $a8f6e7d095d1cc86$var$SelectionManagerContext = /*#__PURE__*/ (0, $2JTht$react.createContext)(null);
63
67
  function $a8f6e7d095d1cc86$export$27d2ad3c5815583e(props) {
64
68
  let state = (0, $2JTht$reactstately.useMenuTriggerState)(props);
65
69
  let ref = (0, $2JTht$react.useRef)(null);
@@ -125,7 +129,6 @@ const $a8f6e7d095d1cc86$export$ecabc99eeffab7ca = /*#__PURE__*/ (0, $2JTht$react
125
129
  }, rootMenuTriggerState);
126
130
  let submenuRef = (0, $2JTht$react.useRef)(null);
127
131
  let itemRef = (0, $2JTht$reactariautils.useObjectRef)(ref);
128
- let popoverContext = (0, $c5ccf687772c0422$exports.useSlottedContext)((0, $61e2b7078adb18bc$exports.PopoverContext));
129
132
  let { parentMenuRef: parentMenuRef } = (0, $2JTht$react.useContext)($a8f6e7d095d1cc86$var$SubmenuTriggerContext);
130
133
  let { submenuTriggerProps: submenuTriggerProps, submenuProps: submenuProps, popoverProps: popoverProps } = (0, $2JTht$reactariamenu.useSubmenuTrigger)({
131
134
  parentMenuRef: parentMenuRef,
@@ -157,7 +160,9 @@ const $a8f6e7d095d1cc86$export$ecabc99eeffab7ca = /*#__PURE__*/ (0, $2JTht$react
157
160
  trigger: 'SubmenuTrigger',
158
161
  triggerRef: itemRef,
159
162
  placement: 'end top',
160
- UNSTABLE_portalContainer: popoverContext.UNSTABLE_portalContainer || undefined,
163
+ // Prevent parent popover from hiding submenu.
164
+ // @ts-ignore
165
+ 'data-react-aria-top-layer': true,
161
166
  ...popoverProps
162
167
  }
163
168
  ]
@@ -184,38 +189,13 @@ function $a8f6e7d095d1cc86$var$MenuInner({ props: props, collection: collection,
184
189
  collection: collection,
185
190
  children: undefined
186
191
  });
187
- let [popoverContainer, setPopoverContainer] = (0, $2JTht$react.useState)(null);
192
+ let triggerState = (0, $2JTht$react.useContext)($a8f6e7d095d1cc86$export$795aec4671cbae19);
188
193
  let { isVirtualized: isVirtualized, CollectionRoot: CollectionRoot } = (0, $2JTht$react.useContext)((0, $3114c2382242bdc0$exports.CollectionRendererContext));
189
194
  let { menuProps: menuProps } = (0, $2JTht$reactaria.useMenu)({
190
195
  ...props,
191
- isVirtualized: isVirtualized
196
+ isVirtualized: isVirtualized,
197
+ onClose: props.onClose || (triggerState === null || triggerState === void 0 ? void 0 : triggerState.close)
192
198
  }, state, ref);
193
- let rootMenuTriggerState = (0, $2JTht$react.useContext)($a8f6e7d095d1cc86$export$795aec4671cbae19);
194
- let popoverContext = (0, $2JTht$react.useContext)((0, $61e2b7078adb18bc$exports.PopoverContext));
195
- let isSubmenu = (popoverContext === null || popoverContext === void 0 ? void 0 : popoverContext.trigger) === 'SubmenuTrigger';
196
- (0, $2JTht$reactariainteractions.useInteractOutside)({
197
- ref: ref,
198
- onInteractOutside: (e)=>{
199
- if (rootMenuTriggerState && !(popoverContainer === null || popoverContainer === void 0 ? void 0 : popoverContainer.contains(e.target))) rootMenuTriggerState.close();
200
- },
201
- isDisabled: isSubmenu || (rootMenuTriggerState === null || rootMenuTriggerState === void 0 ? void 0 : rootMenuTriggerState.expandedKeysStack.length) === 0
202
- });
203
- let prevPopoverContainer = (0, $2JTht$react.useRef)(null);
204
- let [leftOffset, setLeftOffset] = (0, $2JTht$react.useState)({
205
- left: 0
206
- });
207
- (0, $2JTht$react.useEffect)(()=>{
208
- if (popoverContainer && prevPopoverContainer.current !== popoverContainer && leftOffset.left === 0) {
209
- prevPopoverContainer.current = popoverContainer;
210
- let { left: left } = popoverContainer.getBoundingClientRect();
211
- setLeftOffset({
212
- left: -1 * left
213
- });
214
- }
215
- }, [
216
- leftOffset,
217
- popoverContainer
218
- ]);
219
199
  let renderProps = (0, $c5ccf687772c0422$exports.useRenderProps)({
220
200
  defaultClassName: 'react-aria-Menu',
221
201
  className: props.className,
@@ -241,15 +221,10 @@ function $a8f6e7d095d1cc86$var$MenuInner({ props: props, collection: collection,
241
221
  elementType: 'div'
242
222
  }
243
223
  ],
244
- [
245
- (0, $61e2b7078adb18bc$exports.PopoverContext),
246
- {
247
- UNSTABLE_portalContainer: popoverContainer || undefined
248
- }
249
- ],
250
224
  [
251
225
  (0, $3114c2382242bdc0$exports.SectionContext),
252
226
  {
227
+ name: 'MenuSection',
253
228
  render: $a8f6e7d095d1cc86$var$MenuSection
254
229
  }
255
230
  ],
@@ -262,26 +237,45 @@ function $a8f6e7d095d1cc86$var$MenuInner({ props: props, collection: collection,
262
237
  [
263
238
  $a8f6e7d095d1cc86$var$MenuItemContext,
264
239
  null
240
+ ],
241
+ [
242
+ $a8f6e7d095d1cc86$var$SelectionManagerContext,
243
+ state.selectionManager
265
244
  ]
266
245
  ]
267
246
  }, /*#__PURE__*/ (0, ($parcel$interopDefault($2JTht$react))).createElement(CollectionRoot, {
268
247
  collection: collection,
269
248
  persistedKeys: (0, $3114c2382242bdc0$exports.usePersistedKeys)(state.selectionManager.focusedKey),
270
249
  scrollRef: ref
271
- }))), /*#__PURE__*/ (0, ($parcel$interopDefault($2JTht$react))).createElement("div", {
272
- ref: setPopoverContainer,
273
- style: {
274
- width: '100vw',
275
- position: 'absolute',
276
- top: 0,
277
- ...leftOffset
278
- }
279
- }));
250
+ }))));
280
251
  }
281
252
  /**
282
253
  * A menu displays a list of actions or options that a user can choose.
283
254
  */ const $a8f6e7d095d1cc86$export$d9b273488cd8ce6f = /*#__PURE__*/ (0, $2JTht$react.forwardRef)($a8f6e7d095d1cc86$var$Menu);
284
- function $a8f6e7d095d1cc86$var$MenuSection(props, ref, section) {
255
+ // A subclass of SelectionManager that forwards focus-related properties to the parent,
256
+ // but has its own local selection state.
257
+ class $a8f6e7d095d1cc86$var$GroupSelectionManager extends (0, $2JTht$reactstatelyselection.SelectionManager) {
258
+ get focusedKey() {
259
+ return this.parent.focusedKey;
260
+ }
261
+ get isFocused() {
262
+ return this.parent.isFocused;
263
+ }
264
+ setFocusedKey(key, childFocusStrategy) {
265
+ return this.parent.setFocusedKey(key, childFocusStrategy);
266
+ }
267
+ setFocused(isFocused) {
268
+ this.parent.setFocused(isFocused);
269
+ }
270
+ get childFocusStrategy() {
271
+ return this.parent.childFocusStrategy;
272
+ }
273
+ constructor(parent, state){
274
+ super(parent.collection, state);
275
+ this.parent = parent;
276
+ }
277
+ }
278
+ function $a8f6e7d095d1cc86$var$MenuSection(props, ref, section, className = 'react-aria-MenuSection') {
285
279
  var _section_props, _section_props1;
286
280
  let state = (0, $2JTht$react.useContext)($a8f6e7d095d1cc86$export$24aad8519b95b41b);
287
281
  let { CollectionBranch: CollectionBranch } = (0, $2JTht$react.useContext)((0, $3114c2382242bdc0$exports.CollectionRendererContext));
@@ -292,26 +286,41 @@ function $a8f6e7d095d1cc86$var$MenuSection(props, ref, section) {
292
286
  'aria-label': (_section_props_arialabel = section.props['aria-label']) !== null && _section_props_arialabel !== void 0 ? _section_props_arialabel : undefined
293
287
  });
294
288
  let renderProps = (0, $c5ccf687772c0422$exports.useRenderProps)({
295
- defaultClassName: 'react-aria-Section',
289
+ defaultClassName: className,
296
290
  className: (_section_props = section.props) === null || _section_props === void 0 ? void 0 : _section_props.className,
297
291
  style: (_section_props1 = section.props) === null || _section_props1 === void 0 ? void 0 : _section_props1.style,
298
292
  values: {}
299
293
  });
294
+ let parent = (0, $2JTht$react.useContext)($a8f6e7d095d1cc86$var$SelectionManagerContext);
295
+ let selectionState = (0, $2JTht$reactstatelyselection.useMultipleSelectionState)(props);
296
+ let manager = props.selectionMode != null ? new $a8f6e7d095d1cc86$var$GroupSelectionManager(parent, selectionState) : parent;
300
297
  return /*#__PURE__*/ (0, ($parcel$interopDefault($2JTht$react))).createElement("section", {
301
298
  ...(0, $2JTht$reactariautils.filterDOMProps)(props),
302
299
  ...groupProps,
303
300
  ...renderProps,
304
301
  ref: ref
305
- }, /*#__PURE__*/ (0, ($parcel$interopDefault($2JTht$react))).createElement((0, $c7efb75a1a3fe2d2$exports.HeaderContext).Provider, {
306
- value: {
307
- ...headingProps,
308
- ref: headingRef
309
- }
302
+ }, /*#__PURE__*/ (0, ($parcel$interopDefault($2JTht$react))).createElement((0, $c5ccf687772c0422$exports.Provider), {
303
+ values: [
304
+ [
305
+ (0, $c7efb75a1a3fe2d2$exports.HeaderContext),
306
+ {
307
+ ...headingProps,
308
+ ref: headingRef
309
+ }
310
+ ],
311
+ [
312
+ $a8f6e7d095d1cc86$var$SelectionManagerContext,
313
+ manager
314
+ ]
315
+ ]
310
316
  }, /*#__PURE__*/ (0, ($parcel$interopDefault($2JTht$react))).createElement(CollectionBranch, {
311
317
  collection: state.collection,
312
318
  parent: section
313
319
  })));
314
320
  }
321
+ /**
322
+ * A MenuSection represents a section within a Menu.
323
+ */ const $a8f6e7d095d1cc86$export$4b1545b4f2016d26 = /*#__PURE__*/ (0, $2JTht$reactariacollections.createBranchComponent)('section', $a8f6e7d095d1cc86$var$MenuSection);
315
324
  const $a8f6e7d095d1cc86$var$MenuItemContext = /*#__PURE__*/ (0, $2JTht$react.createContext)(null);
316
325
  const $a8f6e7d095d1cc86$export$2ce376c2cc3355c8 = /*#__PURE__*/ (0, $2JTht$reactariacollections.createLeafComponent)('item', function MenuItem(props, forwardedRef, item) {
317
326
  var _useSlottedContext;
@@ -319,10 +328,12 @@ const $a8f6e7d095d1cc86$export$2ce376c2cc3355c8 = /*#__PURE__*/ (0, $2JTht$react
319
328
  let id = (_useSlottedContext = (0, $c5ccf687772c0422$exports.useSlottedContext)($a8f6e7d095d1cc86$var$MenuItemContext)) === null || _useSlottedContext === void 0 ? void 0 : _useSlottedContext.id;
320
329
  let state = (0, $2JTht$react.useContext)($a8f6e7d095d1cc86$export$24aad8519b95b41b);
321
330
  let ref = (0, $2JTht$reactariautils.useObjectRef)(forwardedRef);
331
+ let selectionManager = (0, $2JTht$react.useContext)($a8f6e7d095d1cc86$var$SelectionManagerContext);
322
332
  let { menuItemProps: menuItemProps, labelProps: labelProps, descriptionProps: descriptionProps, keyboardShortcutProps: keyboardShortcutProps, ...states } = (0, $2JTht$reactaria.useMenuItem)({
323
333
  ...props,
324
334
  id: id,
325
- key: item.key
335
+ key: item.key,
336
+ selectionManager: selectionManager
326
337
  }, state, ref);
327
338
  let { isFocusVisible: isFocusVisible, focusProps: focusProps } = (0, $2JTht$reactaria.useFocusRing)();
328
339
  let { hoverProps: hoverProps, isHovered: isHovered } = (0, $2JTht$reactariainteractions.useHover)({
@@ -337,8 +348,8 @@ const $a8f6e7d095d1cc86$export$2ce376c2cc3355c8 = /*#__PURE__*/ (0, $2JTht$react
337
348
  ...states,
338
349
  isHovered: isHovered,
339
350
  isFocusVisible: isFocusVisible,
340
- selectionMode: state.selectionManager.selectionMode,
341
- selectionBehavior: state.selectionManager.selectionBehavior,
351
+ selectionMode: selectionManager.selectionMode,
352
+ selectionBehavior: selectionManager.selectionBehavior,
342
353
  hasSubmenu: !!props['aria-haspopup'],
343
354
  isOpen: props['aria-expanded'] === 'true'
344
355
  }
@@ -354,7 +365,7 @@ const $a8f6e7d095d1cc86$export$2ce376c2cc3355c8 = /*#__PURE__*/ (0, $2JTht$react
354
365
  "data-focus-visible": isFocusVisible || undefined,
355
366
  "data-pressed": states.isPressed || undefined,
356
367
  "data-selected": states.isSelected || undefined,
357
- "data-selection-mode": state.selectionManager.selectionMode === 'none' ? undefined : state.selectionManager.selectionMode,
368
+ "data-selection-mode": selectionManager.selectionMode === 'none' ? undefined : selectionManager.selectionMode,
358
369
  "data-has-submenu": !!props['aria-haspopup'] || undefined,
359
370
  "data-open": props['aria-expanded'] === 'true' || undefined
360
371
  }, /*#__PURE__*/ (0, ($parcel$interopDefault($2JTht$react))).createElement((0, $c5ccf687772c0422$exports.Provider), {
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;AAiCM,MAAM,0DAAc,CAAA,GAAA,0BAAY,EAAgD;AAChF,MAAM,0DAAmB,CAAA,G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;YACN;gBAAC,CAAA,GAAA,qCAAU;gBAAG;oBACZ,OAAO;wBACL,OAAO;wBACP,aAAa;oBACf;gBACF;aAAE;YACF;gBAAC,CAAA,GAAA,yCAAc;gBAAG;aAAsB;SACzC;OACA,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/Menu.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n\nimport {AriaMenuProps, FocusScope, mergeProps, useFocusRing, useMenu, useMenuItem, useMenuSection, useMenuTrigger} from 'react-aria';\nimport {MenuTriggerProps as BaseMenuTriggerProps, Collection as ICollection, Node, TreeState, useMenuTriggerState, useTreeState} from 'react-stately';\nimport {Collection, CollectionBuilder, createBranchComponent, createLeafComponent} from '@react-aria/collections';\nimport {CollectionProps, CollectionRendererContext, ItemRenderProps, SectionContext, SectionProps, usePersistedKeys} from './Collection';\nimport {ContextValue, Provider, RenderProps, ScrollableProps, SlotProps, StyleProps, useContextProps, useRenderProps, useSlot, useSlottedContext} from './utils';\nimport {filterDOMProps, useObjectRef, useResizeObserver} from '@react-aria/utils';\nimport {forwardRefType, HoverEvents, Key, LinkDOMProps} from '@react-types/shared';\nimport {HeaderContext} from './Header';\nimport {KeyboardContext} from './Keyboard';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext, PopoverProps} from './Popover';\nimport {PressResponder, useHover, useInteractOutside} from '@react-aria/interactions';\nimport React, {\n createContext,\n ForwardedRef,\n forwardRef,\n ReactElement,\n ReactNode,\n RefObject,\n useCallback,\n useContext,\n useEffect,\n useRef,\n useState\n} from 'react';\nimport {RootMenuTriggerState, useSubmenuTriggerState} from '@react-stately/menu';\nimport {SeparatorContext} from './Separator';\nimport {TextContext} from './Text';\nimport {useSubmenuTrigger} from '@react-aria/menu';\n\nexport const MenuContext = createContext<ContextValue<MenuProps<any>, HTMLDivElement>>(null);\nexport const MenuStateContext = createContext<TreeState<any> | null>(null);\nexport const RootMenuTriggerStateContext = createContext<RootMenuTriggerState | null>(null);\n\nexport interface MenuTriggerProps extends BaseMenuTriggerProps {\n children: ReactNode\n}\n\nexport function MenuTrigger(props: MenuTriggerProps) {\n let state = useMenuTriggerState(props);\n\n let ref = useRef<HTMLButtonElement>(null);\n let {menuTriggerProps, menuProps} = useMenuTrigger({\n ...props,\n type: 'menu'\n }, state, ref);\n // Allows menu width to match button\n let [buttonWidth, setButtonWidth] = useState<string | null>(null);\n let onResize = useCallback(() => {\n if (ref.current) {\n setButtonWidth(ref.current.offsetWidth + 'px');\n }\n }, [ref]);\n\n useResizeObserver({\n ref: ref,\n onResize: onResize\n });\n\n let scrollRef = useRef(null);\n\n return (\n <Provider\n values={[\n [MenuContext, {...menuProps, ref: scrollRef}],\n [OverlayTriggerStateContext, state],\n [RootMenuTriggerStateContext, state],\n [PopoverContext, {\n trigger: 'MenuTrigger',\n triggerRef: ref,\n scrollRef,\n placement: 'bottom start',\n style: {'--trigger-width': buttonWidth} as React.CSSProperties\n }]\n ]}>\n <PressResponder {...menuTriggerProps} ref={ref} isPressed={state.isOpen}>\n {props.children}\n </PressResponder>\n </Provider>\n );\n}\n\nexport interface SubmenuTriggerProps {\n /**\n * The contents of the SubmenuTrigger. The first child should be an Item (the trigger) and the second child should be the Popover (for the submenu).\n */\n children: ReactElement[],\n /**\n * The delay time in milliseconds for the submenu to appear after hovering over the trigger.\n * @default 200\n */\n delay?: number\n}\n\nconst SubmenuTriggerContext = createContext<{parentMenuRef: RefObject<HTMLElement | null>} | null>(null);\n\n/**\n * A submenu trigger is used to wrap a submenu's trigger item and the submenu itself.\n *\n * @version alpha\n */\nexport const SubmenuTrigger = /*#__PURE__*/ createBranchComponent('submenutrigger', (props: SubmenuTriggerProps, ref: ForwardedRef<HTMLDivElement>, item) => {\n let {CollectionBranch} = useContext(CollectionRendererContext);\n let state = useContext(MenuStateContext)!;\n let rootMenuTriggerState = useContext(RootMenuTriggerStateContext)!;\n let submenuTriggerState = useSubmenuTriggerState({triggerKey: item.key}, rootMenuTriggerState);\n let submenuRef = useRef<HTMLDivElement>(null);\n let itemRef = useObjectRef(ref);\n let popoverContext = useSlottedContext(PopoverContext)!;\n let {parentMenuRef} = useContext(SubmenuTriggerContext)!;\n let {submenuTriggerProps, submenuProps, popoverProps} = useSubmenuTrigger({\n parentMenuRef,\n submenuRef,\n delay: props.delay\n }, submenuTriggerState, itemRef);\n\n return (\n <Provider\n values={[\n [MenuItemContext, {...submenuTriggerProps, onAction: undefined, ref: itemRef}],\n [MenuContext, submenuProps],\n [OverlayTriggerStateContext, submenuTriggerState],\n [PopoverContext, {\n ref: submenuRef,\n trigger: 'SubmenuTrigger',\n triggerRef: itemRef,\n placement: 'end top',\n UNSTABLE_portalContainer: popoverContext.UNSTABLE_portalContainer || undefined,\n ...popoverProps\n }]\n ]}>\n <CollectionBranch collection={state.collection} parent={item} />\n {props.children[1]}\n </Provider>\n );\n}, props => props.children[0]);\n\nexport interface MenuProps<T> extends Omit<AriaMenuProps<T>, 'children'>, CollectionProps<T>, StyleProps, SlotProps, ScrollableProps<HTMLDivElement> {}\n\nfunction Menu<T extends object>(props: MenuProps<T>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, MenuContext);\n\n // Delay rendering the actual menu until we have the collection so that auto focus works properly.\n return (\n <CollectionBuilder content={<Collection {...props} />}>\n {collection => collection.size > 0 && <MenuInner props={props} collection={collection} menuRef={ref} />}\n </CollectionBuilder>\n );\n}\n\ninterface MenuInnerProps<T> {\n props: MenuProps<T>,\n collection: ICollection<Node<object>>,\n menuRef: RefObject<HTMLDivElement | null>\n}\n\nfunction MenuInner<T extends object>({props, collection, menuRef: ref}: MenuInnerProps<T>) {\n let state = useTreeState({\n ...props,\n collection,\n children: undefined\n });\n let [popoverContainer, setPopoverContainer] = useState<HTMLDivElement | null>(null);\n let {isVirtualized, CollectionRoot} = useContext(CollectionRendererContext);\n let {menuProps} = useMenu({...props, isVirtualized}, state, ref);\n let rootMenuTriggerState = useContext(RootMenuTriggerStateContext)!;\n let popoverContext = useContext(PopoverContext)!;\n\n let isSubmenu = (popoverContext as PopoverProps)?.trigger === 'SubmenuTrigger';\n useInteractOutside({\n ref,\n onInteractOutside: (e) => {\n if (rootMenuTriggerState && !popoverContainer?.contains(e.target as HTMLElement)) {\n rootMenuTriggerState.close();\n }\n },\n isDisabled: isSubmenu || rootMenuTriggerState?.expandedKeysStack.length === 0\n });\n\n let prevPopoverContainer = useRef<HTMLDivElement | null>(null) ;\n let [leftOffset, setLeftOffset] = useState({left: 0});\n useEffect(() => {\n if (popoverContainer && prevPopoverContainer.current !== popoverContainer && leftOffset.left === 0) {\n prevPopoverContainer.current = popoverContainer;\n let {left} = popoverContainer.getBoundingClientRect();\n setLeftOffset({left: -1 * left});\n }\n }, [leftOffset, popoverContainer]);\n\n let renderProps = useRenderProps({\n defaultClassName: 'react-aria-Menu',\n className: props.className,\n style: props.style,\n values: {}\n });\n\n return (\n <FocusScope>\n <div\n {...filterDOMProps(props)}\n {...menuProps}\n {...renderProps}\n ref={ref}\n slot={props.slot || undefined}\n onScroll={props.onScroll}>\n <Provider\n values={[\n [MenuStateContext, state],\n [SeparatorContext, {elementType: 'div'}],\n [PopoverContext, {UNSTABLE_portalContainer: popoverContainer || undefined}],\n [SectionContext, {render: MenuSection}],\n [SubmenuTriggerContext, {parentMenuRef: ref}],\n [MenuItemContext, null]\n ]}>\n <CollectionRoot\n collection={collection}\n persistedKeys={usePersistedKeys(state.selectionManager.focusedKey)}\n scrollRef={ref} />\n </Provider>\n </div>\n <div ref={setPopoverContainer} style={{width: '100vw', position: 'absolute', top: 0, ...leftOffset}} />\n </FocusScope>\n );\n}\n\n/**\n * A menu displays a list of actions or options that a user can choose.\n */\nconst _Menu = /*#__PURE__*/ (forwardRef as forwardRefType)(Menu);\nexport {_Menu as Menu};\n\nfunction MenuSection<T extends object>(props: SectionProps<T>, ref: ForwardedRef<HTMLElement>, section: Node<T>) {\n let state = useContext(MenuStateContext)!;\n let {CollectionBranch} = useContext(CollectionRendererContext);\n let [headingRef, heading] = useSlot();\n let {headingProps, groupProps} = useMenuSection({\n heading,\n 'aria-label': section.props['aria-label'] ?? undefined\n });\n let renderProps = useRenderProps({\n defaultClassName: 'react-aria-Section',\n className: section.props?.className,\n style: section.props?.style,\n values: {}\n });\n\n return (\n <section\n {...filterDOMProps(props as any)}\n {...groupProps}\n {...renderProps}\n ref={ref}>\n <HeaderContext.Provider value={{...headingProps, ref: headingRef}}>\n <CollectionBranch collection={state.collection} parent={section} />\n </HeaderContext.Provider>\n </section>\n );\n}\n\nexport interface MenuItemRenderProps extends ItemRenderProps {\n /**\n * Whether the item has a submenu.\n *\n * @selector [data-has-submenu]\n */\n hasSubmenu: boolean,\n /**\n * Whether the item's submenu is open.\n *\n * @selector [data-open]\n */\n isOpen: boolean\n}\n\nexport interface MenuItemProps<T = object> extends RenderProps<MenuItemRenderProps>, LinkDOMProps, HoverEvents {\n /** The unique id of the item. */\n id?: Key,\n /** The object value that this item represents. When using dynamic collections, this is set automatically. */\n value?: T,\n /** A string representation of the item's contents, used for features like typeahead. */\n textValue?: string,\n /** An accessibility label for this item. */\n 'aria-label'?: string,\n /** Whether the item is disabled. */\n isDisabled?: boolean,\n /** Handler that is called when the item is selected. */\n onAction?: () => void\n}\n\nconst MenuItemContext = createContext<ContextValue<MenuItemProps, HTMLDivElement>>(null);\n\n/**\n * A MenuItem represents an individual action in a Menu.\n */\nexport const MenuItem = /*#__PURE__*/ createLeafComponent('item', function MenuItem<T extends object>(props: MenuItemProps<T>, forwardedRef: ForwardedRef<HTMLDivElement>, item: Node<T>) {\n [props, forwardedRef] = useContextProps(props, forwardedRef, MenuItemContext);\n let id = useSlottedContext(MenuItemContext)?.id as string;\n let state = useContext(MenuStateContext)!;\n let ref = useObjectRef<any>(forwardedRef);\n\n let {menuItemProps, labelProps, descriptionProps, keyboardShortcutProps, ...states} = useMenuItem({...props, id, key: item.key}, state, ref);\n\n let {isFocusVisible, focusProps} = useFocusRing();\n let {hoverProps, isHovered} = useHover({\n isDisabled: states.isDisabled\n });\n let renderProps = useRenderProps({\n ...props,\n id: undefined,\n children: item.rendered,\n defaultClassName: 'react-aria-MenuItem',\n values: {\n ...states,\n isHovered,\n isFocusVisible,\n selectionMode: state.selectionManager.selectionMode,\n selectionBehavior: state.selectionManager.selectionBehavior,\n hasSubmenu: !!props['aria-haspopup'],\n isOpen: props['aria-expanded'] === 'true'\n }\n });\n\n let ElementType: React.ElementType = props.href ? 'a' : 'div';\n\n return (\n <ElementType\n {...mergeProps(menuItemProps, focusProps, hoverProps)}\n {...renderProps}\n ref={ref}\n data-disabled={states.isDisabled || undefined}\n data-hovered={isHovered || undefined}\n data-focused={states.isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-pressed={states.isPressed || undefined}\n data-selected={states.isSelected || undefined}\n data-selection-mode={state.selectionManager.selectionMode === 'none' ? undefined : state.selectionManager.selectionMode}\n data-has-submenu={!!props['aria-haspopup'] || undefined}\n data-open={props['aria-expanded'] === 'true' || undefined}>\n <Provider\n values={[\n [TextContext, {\n slots: {\n label: labelProps,\n description: descriptionProps\n }\n }],\n [KeyboardContext, keyboardShortcutProps]\n ]}>\n {renderProps.children}\n </Provider>\n </ElementType>\n );\n});\n"],"names":[],"version":3,"file":"Menu.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;;;;AAiCM,MAAM,0DAAc,CAAA,GAAA,0BAAY,EAAgD;AAChF,MAAM,0DAAmB,CAAA,GAAA,0BAAY,EAAyB;A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AAU;gBAAG;oBACZ,OAAO;wBACL,OAAO;wBACP,aAAa;oBACf;gBACF;aAAE;YACF;gBAAC,CAAA,GAAA,yCAAc;gBAAG;aAAsB;SACzC;OACA,YAAY,QAAQ;AAI7B","sources":["packages/react-aria-components/src/Menu.tsx"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n\nimport {AriaMenuProps, FocusScope, mergeProps, useFocusRing, useMenu, useMenuItem, useMenuSection, useMenuTrigger} from 'react-aria';\nimport {MenuTriggerProps as BaseMenuTriggerProps, Collection as ICollection, Node, TreeState, useMenuTriggerState, useTreeState} from 'react-stately';\nimport {Collection, CollectionBuilder, createBranchComponent, createLeafComponent} from '@react-aria/collections';\nimport {CollectionProps, CollectionRendererContext, ItemRenderProps, SectionContext, SectionProps, usePersistedKeys} from './Collection';\nimport {ContextValue, Provider, RenderProps, ScrollableProps, SlotProps, StyleProps, useContextProps, useRenderProps, useSlot, useSlottedContext} from './utils';\nimport {filterDOMProps, useObjectRef, useResizeObserver} from '@react-aria/utils';\nimport {FocusStrategy, forwardRefType, HoverEvents, Key, LinkDOMProps, MultipleSelection} from '@react-types/shared';\nimport {HeaderContext} from './Header';\nimport {KeyboardContext} from './Keyboard';\nimport {MultipleSelectionState, SelectionManager, useMultipleSelectionState} from '@react-stately/selection';\nimport {OverlayTriggerStateContext} from './Dialog';\nimport {PopoverContext} from './Popover';\nimport {PressResponder, useHover} from '@react-aria/interactions';\nimport React, {\n createContext,\n ForwardedRef,\n forwardRef,\n ReactElement,\n ReactNode,\n RefObject,\n useCallback,\n useContext,\n useRef,\n useState\n} from 'react';\nimport {RootMenuTriggerState, useSubmenuTriggerState} from '@react-stately/menu';\nimport {SeparatorContext} from './Separator';\nimport {TextContext} from './Text';\nimport {useSubmenuTrigger} from '@react-aria/menu';\n\nexport const MenuContext = createContext<ContextValue<MenuProps<any>, HTMLDivElement>>(null);\nexport const MenuStateContext = createContext<TreeState<any> | null>(null);\nexport const RootMenuTriggerStateContext = createContext<RootMenuTriggerState | null>(null);\nconst SelectionManagerContext = createContext<SelectionManager | null>(null);\n\nexport interface MenuTriggerProps extends BaseMenuTriggerProps {\n children: ReactNode\n}\n\nexport function MenuTrigger(props: MenuTriggerProps) {\n let state = useMenuTriggerState(props);\n let ref = useRef<HTMLButtonElement>(null);\n let {menuTriggerProps, menuProps} = useMenuTrigger({\n ...props,\n type: 'menu'\n }, state, ref);\n // Allows menu width to match button\n let [buttonWidth, setButtonWidth] = useState<string | null>(null);\n let onResize = useCallback(() => {\n if (ref.current) {\n setButtonWidth(ref.current.offsetWidth + 'px');\n }\n }, [ref]);\n\n useResizeObserver({\n ref: ref,\n onResize: onResize\n });\n\n let scrollRef = useRef(null);\n\n return (\n <Provider\n values={[\n [MenuContext, {...menuProps, ref: scrollRef}],\n [OverlayTriggerStateContext, state],\n [RootMenuTriggerStateContext, state],\n [PopoverContext, {\n trigger: 'MenuTrigger',\n triggerRef: ref,\n scrollRef,\n placement: 'bottom start',\n style: {'--trigger-width': buttonWidth} as React.CSSProperties\n }]\n ]}>\n <PressResponder {...menuTriggerProps} ref={ref} isPressed={state.isOpen}>\n {props.children}\n </PressResponder>\n </Provider>\n );\n}\n\nexport interface SubmenuTriggerProps {\n /**\n * The contents of the SubmenuTrigger. The first child should be an Item (the trigger) and the second child should be the Popover (for the submenu).\n */\n children: ReactElement[],\n /**\n * The delay time in milliseconds for the submenu to appear after hovering over the trigger.\n * @default 200\n */\n delay?: number\n}\n\nconst SubmenuTriggerContext = createContext<{parentMenuRef: RefObject<HTMLElement | null>} | null>(null);\n\n/**\n * A submenu trigger is used to wrap a submenu's trigger item and the submenu itself.\n *\n * @version alpha\n */\nexport const SubmenuTrigger = /*#__PURE__*/ createBranchComponent('submenutrigger', (props: SubmenuTriggerProps, ref: ForwardedRef<HTMLDivElement>, item) => {\n let {CollectionBranch} = useContext(CollectionRendererContext);\n let state = useContext(MenuStateContext)!;\n let rootMenuTriggerState = useContext(RootMenuTriggerStateContext)!;\n let submenuTriggerState = useSubmenuTriggerState({triggerKey: item.key}, rootMenuTriggerState);\n let submenuRef = useRef<HTMLDivElement>(null);\n let itemRef = useObjectRef(ref);\n let {parentMenuRef} = useContext(SubmenuTriggerContext)!;\n let {submenuTriggerProps, submenuProps, popoverProps} = useSubmenuTrigger({\n parentMenuRef,\n submenuRef,\n delay: props.delay\n }, submenuTriggerState, itemRef);\n\n return (\n <Provider\n values={[\n [MenuItemContext, {...submenuTriggerProps, onAction: undefined, ref: itemRef}],\n [MenuContext, submenuProps],\n [OverlayTriggerStateContext, submenuTriggerState],\n [PopoverContext, {\n ref: submenuRef,\n trigger: 'SubmenuTrigger',\n triggerRef: itemRef,\n placement: 'end top',\n // Prevent parent popover from hiding submenu.\n // @ts-ignore\n 'data-react-aria-top-layer': true,\n ...popoverProps\n }]\n ]}>\n <CollectionBranch collection={state.collection} parent={item} />\n {props.children[1]}\n </Provider>\n );\n}, props => props.children[0]);\n\nexport interface MenuProps<T> extends Omit<AriaMenuProps<T>, 'children'>, CollectionProps<T>, StyleProps, SlotProps, ScrollableProps<HTMLDivElement> {}\n\nfunction Menu<T extends object>(props: MenuProps<T>, ref: ForwardedRef<HTMLDivElement>) {\n [props, ref] = useContextProps(props, ref, MenuContext);\n\n // Delay rendering the actual menu until we have the collection so that auto focus works properly.\n return (\n <CollectionBuilder content={<Collection {...props} />}>\n {collection => collection.size > 0 && <MenuInner props={props} collection={collection} menuRef={ref} />}\n </CollectionBuilder>\n );\n}\n\ninterface MenuInnerProps<T> {\n props: MenuProps<T>,\n collection: ICollection<Node<object>>,\n menuRef: RefObject<HTMLDivElement | null>\n}\n\nfunction MenuInner<T extends object>({props, collection, menuRef: ref}: MenuInnerProps<T>) {\n let state = useTreeState({\n ...props,\n collection,\n children: undefined\n });\n let triggerState = useContext(RootMenuTriggerStateContext);\n let {isVirtualized, CollectionRoot} = useContext(CollectionRendererContext);\n let {menuProps} = useMenu({...props, isVirtualized, onClose: props.onClose || triggerState?.close}, state, ref);\n let renderProps = useRenderProps({\n defaultClassName: 'react-aria-Menu',\n className: props.className,\n style: props.style,\n values: {}\n });\n\n return (\n <FocusScope>\n <div\n {...filterDOMProps(props)}\n {...menuProps}\n {...renderProps}\n ref={ref}\n slot={props.slot || undefined}\n onScroll={props.onScroll}>\n <Provider\n values={[\n [MenuStateContext, state],\n [SeparatorContext, {elementType: 'div'}],\n [SectionContext, {name: 'MenuSection', render: MenuSection}],\n [SubmenuTriggerContext, {parentMenuRef: ref}],\n [MenuItemContext, null],\n [SelectionManagerContext, state.selectionManager]\n ]}>\n <CollectionRoot\n collection={collection}\n persistedKeys={usePersistedKeys(state.selectionManager.focusedKey)}\n scrollRef={ref} />\n </Provider>\n </div>\n </FocusScope>\n );\n}\n\n/**\n * A menu displays a list of actions or options that a user can choose.\n */\nconst _Menu = /*#__PURE__*/ (forwardRef as forwardRefType)(Menu);\nexport {_Menu as Menu};\n\nexport interface MenuSectionProps<T> extends SectionProps<T>, MultipleSelection {}\n\n// A subclass of SelectionManager that forwards focus-related properties to the parent,\n// but has its own local selection state.\nclass GroupSelectionManager extends SelectionManager {\n private parent: SelectionManager;\n\n constructor(parent: SelectionManager, state: MultipleSelectionState) {\n super(parent.collection, state);\n this.parent = parent;\n }\n\n get focusedKey() {\n return this.parent.focusedKey;\n }\n\n get isFocused() {\n return this.parent.isFocused;\n }\n\n setFocusedKey(key: Key | null, childFocusStrategy?: FocusStrategy): void {\n return this.parent.setFocusedKey(key, childFocusStrategy);\n }\n\n setFocused(isFocused: boolean): void {\n this.parent.setFocused(isFocused);\n }\n\n get childFocusStrategy() {\n return this.parent.childFocusStrategy;\n }\n}\n\nfunction MenuSection<T extends object>(props: MenuSectionProps<T>, ref: ForwardedRef<HTMLElement>, section: Node<T>, className = 'react-aria-MenuSection') {\n let state = useContext(MenuStateContext)!;\n let {CollectionBranch} = useContext(CollectionRendererContext);\n let [headingRef, heading] = useSlot();\n let {headingProps, groupProps} = useMenuSection({\n heading,\n 'aria-label': section.props['aria-label'] ?? undefined\n });\n let renderProps = useRenderProps({\n defaultClassName: className,\n className: section.props?.className,\n style: section.props?.style,\n values: {}\n });\n\n let parent = useContext(SelectionManagerContext)!;\n let selectionState = useMultipleSelectionState(props);\n let manager = props.selectionMode != null ? new GroupSelectionManager(parent, selectionState) : parent;\n\n return (\n <section\n {...filterDOMProps(props as any)}\n {...groupProps}\n {...renderProps}\n ref={ref}>\n <Provider\n values={[\n [HeaderContext, {...headingProps, ref: headingRef}],\n [SelectionManagerContext, manager]\n ]}>\n <CollectionBranch collection={state.collection} parent={section} />\n </Provider>\n </section>\n );\n}\n\n/**\n * A MenuSection represents a section within a Menu.\n */\nconst _MenuSection = /*#__PURE__*/ createBranchComponent('section', MenuSection);\nexport {_MenuSection as MenuSection};\n\nexport interface MenuItemRenderProps extends ItemRenderProps {\n /**\n * Whether the item has a submenu.\n *\n * @selector [data-has-submenu]\n */\n hasSubmenu: boolean,\n /**\n * Whether the item's submenu is open.\n *\n * @selector [data-open]\n */\n isOpen: boolean\n}\n\nexport interface MenuItemProps<T = object> extends RenderProps<MenuItemRenderProps>, LinkDOMProps, HoverEvents {\n /** The unique id of the item. */\n id?: Key,\n /** The object value that this item represents. When using dynamic collections, this is set automatically. */\n value?: T,\n /** A string representation of the item's contents, used for features like typeahead. */\n textValue?: string,\n /** An accessibility label for this item. */\n 'aria-label'?: string,\n /** Whether the item is disabled. */\n isDisabled?: boolean,\n /** Handler that is called when the item is selected. */\n onAction?: () => void\n}\n\nconst MenuItemContext = createContext<ContextValue<MenuItemProps, HTMLDivElement>>(null);\n\n/**\n * A MenuItem represents an individual action in a Menu.\n */\nexport const MenuItem = /*#__PURE__*/ createLeafComponent('item', function MenuItem<T extends object>(props: MenuItemProps<T>, forwardedRef: ForwardedRef<HTMLDivElement>, item: Node<T>) {\n [props, forwardedRef] = useContextProps(props, forwardedRef, MenuItemContext);\n let id = useSlottedContext(MenuItemContext)?.id as string;\n let state = useContext(MenuStateContext)!;\n let ref = useObjectRef<any>(forwardedRef);\n let selectionManager = useContext(SelectionManagerContext)!;\n\n let {menuItemProps, labelProps, descriptionProps, keyboardShortcutProps, ...states} = useMenuItem({\n ...props,\n id,\n key: item.key,\n selectionManager\n }, state, ref);\n\n let {isFocusVisible, focusProps} = useFocusRing();\n let {hoverProps, isHovered} = useHover({\n isDisabled: states.isDisabled\n });\n let renderProps = useRenderProps({\n ...props,\n id: undefined,\n children: item.rendered,\n defaultClassName: 'react-aria-MenuItem',\n values: {\n ...states,\n isHovered,\n isFocusVisible,\n selectionMode: selectionManager.selectionMode,\n selectionBehavior: selectionManager.selectionBehavior,\n hasSubmenu: !!props['aria-haspopup'],\n isOpen: props['aria-expanded'] === 'true'\n }\n });\n\n let ElementType: React.ElementType = props.href ? 'a' : 'div';\n\n return (\n <ElementType\n {...mergeProps(menuItemProps, focusProps, hoverProps)}\n {...renderProps}\n ref={ref}\n data-disabled={states.isDisabled || undefined}\n data-hovered={isHovered || undefined}\n data-focused={states.isFocused || undefined}\n data-focus-visible={isFocusVisible || undefined}\n data-pressed={states.isPressed || undefined}\n data-selected={states.isSelected || undefined}\n data-selection-mode={selectionManager.selectionMode === 'none' ? undefined : selectionManager.selectionMode}\n data-has-submenu={!!props['aria-haspopup'] || undefined}\n data-open={props['aria-expanded'] === 'true' || undefined}>\n <Provider\n values={[\n [TextContext, {\n slots: {\n label: labelProps,\n description: descriptionProps\n }\n }],\n [KeyboardContext, keyboardShortcutProps]\n ]}>\n {renderProps.children}\n </Provider>\n </ElementType>\n );\n});\n"],"names":[],"version":3,"file":"Menu.main.js.map"}
package/dist/Menu.mjs CHANGED
@@ -10,8 +10,9 @@ import {useMenuTrigger as $kM2ZM$useMenuTrigger, useMenu as $kM2ZM$useMenu, Focu
10
10
  import {useMenuTriggerState as $kM2ZM$useMenuTriggerState, useTreeState as $kM2ZM$useTreeState} from "react-stately";
11
11
  import {createBranchComponent as $kM2ZM$createBranchComponent, CollectionBuilder as $kM2ZM$CollectionBuilder, Collection as $kM2ZM$Collection, createLeafComponent as $kM2ZM$createLeafComponent} from "@react-aria/collections";
12
12
  import {useResizeObserver as $kM2ZM$useResizeObserver, useObjectRef as $kM2ZM$useObjectRef, filterDOMProps as $kM2ZM$filterDOMProps} from "@react-aria/utils";
13
- import {PressResponder as $kM2ZM$PressResponder, useInteractOutside as $kM2ZM$useInteractOutside, useHover as $kM2ZM$useHover} from "@react-aria/interactions";
14
- import $kM2ZM$react, {createContext as $kM2ZM$createContext, useRef as $kM2ZM$useRef, useState as $kM2ZM$useState, useCallback as $kM2ZM$useCallback, useContext as $kM2ZM$useContext, useEffect as $kM2ZM$useEffect, forwardRef as $kM2ZM$forwardRef} from "react";
13
+ import {SelectionManager as $kM2ZM$SelectionManager, useMultipleSelectionState as $kM2ZM$useMultipleSelectionState} from "@react-stately/selection";
14
+ import {PressResponder as $kM2ZM$PressResponder, useHover as $kM2ZM$useHover} from "@react-aria/interactions";
15
+ import $kM2ZM$react, {createContext as $kM2ZM$createContext, useRef as $kM2ZM$useRef, useState as $kM2ZM$useState, useCallback as $kM2ZM$useCallback, useContext as $kM2ZM$useContext, forwardRef as $kM2ZM$forwardRef} from "react";
15
16
  import {useSubmenuTriggerState as $kM2ZM$useSubmenuTriggerState} from "@react-stately/menu";
16
17
  import {useSubmenuTrigger as $kM2ZM$useSubmenuTrigger} from "@react-aria/menu";
17
18
 
@@ -41,9 +42,11 @@ import {useSubmenuTrigger as $kM2ZM$useSubmenuTrigger} from "@react-aria/menu";
41
42
 
42
43
 
43
44
 
45
+
44
46
  const $3674c52c6b3c5bce$export$c7e742effb1c51e2 = /*#__PURE__*/ (0, $kM2ZM$createContext)(null);
45
47
  const $3674c52c6b3c5bce$export$24aad8519b95b41b = /*#__PURE__*/ (0, $kM2ZM$createContext)(null);
46
48
  const $3674c52c6b3c5bce$export$795aec4671cbae19 = /*#__PURE__*/ (0, $kM2ZM$createContext)(null);
49
+ const $3674c52c6b3c5bce$var$SelectionManagerContext = /*#__PURE__*/ (0, $kM2ZM$createContext)(null);
47
50
  function $3674c52c6b3c5bce$export$27d2ad3c5815583e(props) {
48
51
  let state = (0, $kM2ZM$useMenuTriggerState)(props);
49
52
  let ref = (0, $kM2ZM$useRef)(null);
@@ -109,7 +112,6 @@ const $3674c52c6b3c5bce$export$ecabc99eeffab7ca = /*#__PURE__*/ (0, $kM2ZM$creat
109
112
  }, rootMenuTriggerState);
110
113
  let submenuRef = (0, $kM2ZM$useRef)(null);
111
114
  let itemRef = (0, $kM2ZM$useObjectRef)(ref);
112
- let popoverContext = (0, $64fa3d84918910a7$export$fabf2dc03a41866e)((0, $07b14b47974efb58$export$9b9a0cd73afb7ca4));
113
115
  let { parentMenuRef: parentMenuRef } = (0, $kM2ZM$useContext)($3674c52c6b3c5bce$var$SubmenuTriggerContext);
114
116
  let { submenuTriggerProps: submenuTriggerProps, submenuProps: submenuProps, popoverProps: popoverProps } = (0, $kM2ZM$useSubmenuTrigger)({
115
117
  parentMenuRef: parentMenuRef,
@@ -141,7 +143,9 @@ const $3674c52c6b3c5bce$export$ecabc99eeffab7ca = /*#__PURE__*/ (0, $kM2ZM$creat
141
143
  trigger: 'SubmenuTrigger',
142
144
  triggerRef: itemRef,
143
145
  placement: 'end top',
144
- UNSTABLE_portalContainer: popoverContext.UNSTABLE_portalContainer || undefined,
146
+ // Prevent parent popover from hiding submenu.
147
+ // @ts-ignore
148
+ 'data-react-aria-top-layer': true,
145
149
  ...popoverProps
146
150
  }
147
151
  ]
@@ -168,38 +172,13 @@ function $3674c52c6b3c5bce$var$MenuInner({ props: props, collection: collection,
168
172
  collection: collection,
169
173
  children: undefined
170
174
  });
171
- let [popoverContainer, setPopoverContainer] = (0, $kM2ZM$useState)(null);
175
+ let triggerState = (0, $kM2ZM$useContext)($3674c52c6b3c5bce$export$795aec4671cbae19);
172
176
  let { isVirtualized: isVirtualized, CollectionRoot: CollectionRoot } = (0, $kM2ZM$useContext)((0, $7135fc7d473fd974$export$4feb769f8ddf26c5));
173
177
  let { menuProps: menuProps } = (0, $kM2ZM$useMenu)({
174
178
  ...props,
175
- isVirtualized: isVirtualized
179
+ isVirtualized: isVirtualized,
180
+ onClose: props.onClose || (triggerState === null || triggerState === void 0 ? void 0 : triggerState.close)
176
181
  }, state, ref);
177
- let rootMenuTriggerState = (0, $kM2ZM$useContext)($3674c52c6b3c5bce$export$795aec4671cbae19);
178
- let popoverContext = (0, $kM2ZM$useContext)((0, $07b14b47974efb58$export$9b9a0cd73afb7ca4));
179
- let isSubmenu = (popoverContext === null || popoverContext === void 0 ? void 0 : popoverContext.trigger) === 'SubmenuTrigger';
180
- (0, $kM2ZM$useInteractOutside)({
181
- ref: ref,
182
- onInteractOutside: (e)=>{
183
- if (rootMenuTriggerState && !(popoverContainer === null || popoverContainer === void 0 ? void 0 : popoverContainer.contains(e.target))) rootMenuTriggerState.close();
184
- },
185
- isDisabled: isSubmenu || (rootMenuTriggerState === null || rootMenuTriggerState === void 0 ? void 0 : rootMenuTriggerState.expandedKeysStack.length) === 0
186
- });
187
- let prevPopoverContainer = (0, $kM2ZM$useRef)(null);
188
- let [leftOffset, setLeftOffset] = (0, $kM2ZM$useState)({
189
- left: 0
190
- });
191
- (0, $kM2ZM$useEffect)(()=>{
192
- if (popoverContainer && prevPopoverContainer.current !== popoverContainer && leftOffset.left === 0) {
193
- prevPopoverContainer.current = popoverContainer;
194
- let { left: left } = popoverContainer.getBoundingClientRect();
195
- setLeftOffset({
196
- left: -1 * left
197
- });
198
- }
199
- }, [
200
- leftOffset,
201
- popoverContainer
202
- ]);
203
182
  let renderProps = (0, $64fa3d84918910a7$export$4d86445c2cf5e3)({
204
183
  defaultClassName: 'react-aria-Menu',
205
184
  className: props.className,
@@ -225,15 +204,10 @@ function $3674c52c6b3c5bce$var$MenuInner({ props: props, collection: collection,
225
204
  elementType: 'div'
226
205
  }
227
206
  ],
228
- [
229
- (0, $07b14b47974efb58$export$9b9a0cd73afb7ca4),
230
- {
231
- UNSTABLE_portalContainer: popoverContainer || undefined
232
- }
233
- ],
234
207
  [
235
208
  (0, $7135fc7d473fd974$export$d40e14dec8b060a8),
236
209
  {
210
+ name: 'MenuSection',
237
211
  render: $3674c52c6b3c5bce$var$MenuSection
238
212
  }
239
213
  ],
@@ -246,26 +220,45 @@ function $3674c52c6b3c5bce$var$MenuInner({ props: props, collection: collection,
246
220
  [
247
221
  $3674c52c6b3c5bce$var$MenuItemContext,
248
222
  null
223
+ ],
224
+ [
225
+ $3674c52c6b3c5bce$var$SelectionManagerContext,
226
+ state.selectionManager
249
227
  ]
250
228
  ]
251
229
  }, /*#__PURE__*/ (0, $kM2ZM$react).createElement(CollectionRoot, {
252
230
  collection: collection,
253
231
  persistedKeys: (0, $7135fc7d473fd974$export$90e00781bc59d8f9)(state.selectionManager.focusedKey),
254
232
  scrollRef: ref
255
- }))), /*#__PURE__*/ (0, $kM2ZM$react).createElement("div", {
256
- ref: setPopoverContainer,
257
- style: {
258
- width: '100vw',
259
- position: 'absolute',
260
- top: 0,
261
- ...leftOffset
262
- }
263
- }));
233
+ }))));
264
234
  }
265
235
  /**
266
236
  * A menu displays a list of actions or options that a user can choose.
267
237
  */ const $3674c52c6b3c5bce$export$d9b273488cd8ce6f = /*#__PURE__*/ (0, $kM2ZM$forwardRef)($3674c52c6b3c5bce$var$Menu);
268
- function $3674c52c6b3c5bce$var$MenuSection(props, ref, section) {
238
+ // A subclass of SelectionManager that forwards focus-related properties to the parent,
239
+ // but has its own local selection state.
240
+ class $3674c52c6b3c5bce$var$GroupSelectionManager extends (0, $kM2ZM$SelectionManager) {
241
+ get focusedKey() {
242
+ return this.parent.focusedKey;
243
+ }
244
+ get isFocused() {
245
+ return this.parent.isFocused;
246
+ }
247
+ setFocusedKey(key, childFocusStrategy) {
248
+ return this.parent.setFocusedKey(key, childFocusStrategy);
249
+ }
250
+ setFocused(isFocused) {
251
+ this.parent.setFocused(isFocused);
252
+ }
253
+ get childFocusStrategy() {
254
+ return this.parent.childFocusStrategy;
255
+ }
256
+ constructor(parent, state){
257
+ super(parent.collection, state);
258
+ this.parent = parent;
259
+ }
260
+ }
261
+ function $3674c52c6b3c5bce$var$MenuSection(props, ref, section, className = 'react-aria-MenuSection') {
269
262
  var _section_props, _section_props1;
270
263
  let state = (0, $kM2ZM$useContext)($3674c52c6b3c5bce$export$24aad8519b95b41b);
271
264
  let { CollectionBranch: CollectionBranch } = (0, $kM2ZM$useContext)((0, $7135fc7d473fd974$export$4feb769f8ddf26c5));
@@ -276,26 +269,41 @@ function $3674c52c6b3c5bce$var$MenuSection(props, ref, section) {
276
269
  'aria-label': (_section_props_arialabel = section.props['aria-label']) !== null && _section_props_arialabel !== void 0 ? _section_props_arialabel : undefined
277
270
  });
278
271
  let renderProps = (0, $64fa3d84918910a7$export$4d86445c2cf5e3)({
279
- defaultClassName: 'react-aria-Section',
272
+ defaultClassName: className,
280
273
  className: (_section_props = section.props) === null || _section_props === void 0 ? void 0 : _section_props.className,
281
274
  style: (_section_props1 = section.props) === null || _section_props1 === void 0 ? void 0 : _section_props1.style,
282
275
  values: {}
283
276
  });
277
+ let parent = (0, $kM2ZM$useContext)($3674c52c6b3c5bce$var$SelectionManagerContext);
278
+ let selectionState = (0, $kM2ZM$useMultipleSelectionState)(props);
279
+ let manager = props.selectionMode != null ? new $3674c52c6b3c5bce$var$GroupSelectionManager(parent, selectionState) : parent;
284
280
  return /*#__PURE__*/ (0, $kM2ZM$react).createElement("section", {
285
281
  ...(0, $kM2ZM$filterDOMProps)(props),
286
282
  ...groupProps,
287
283
  ...renderProps,
288
284
  ref: ref
289
- }, /*#__PURE__*/ (0, $kM2ZM$react).createElement((0, $72a5793c14baf454$export$e0e4026c12a8bdbb).Provider, {
290
- value: {
291
- ...headingProps,
292
- ref: headingRef
293
- }
285
+ }, /*#__PURE__*/ (0, $kM2ZM$react).createElement((0, $64fa3d84918910a7$export$2881499e37b75b9a), {
286
+ values: [
287
+ [
288
+ (0, $72a5793c14baf454$export$e0e4026c12a8bdbb),
289
+ {
290
+ ...headingProps,
291
+ ref: headingRef
292
+ }
293
+ ],
294
+ [
295
+ $3674c52c6b3c5bce$var$SelectionManagerContext,
296
+ manager
297
+ ]
298
+ ]
294
299
  }, /*#__PURE__*/ (0, $kM2ZM$react).createElement(CollectionBranch, {
295
300
  collection: state.collection,
296
301
  parent: section
297
302
  })));
298
303
  }
304
+ /**
305
+ * A MenuSection represents a section within a Menu.
306
+ */ const $3674c52c6b3c5bce$export$4b1545b4f2016d26 = /*#__PURE__*/ (0, $kM2ZM$createBranchComponent)('section', $3674c52c6b3c5bce$var$MenuSection);
299
307
  const $3674c52c6b3c5bce$var$MenuItemContext = /*#__PURE__*/ (0, $kM2ZM$createContext)(null);
300
308
  const $3674c52c6b3c5bce$export$2ce376c2cc3355c8 = /*#__PURE__*/ (0, $kM2ZM$createLeafComponent)('item', function MenuItem(props, forwardedRef, item) {
301
309
  var _useSlottedContext;
@@ -303,10 +311,12 @@ const $3674c52c6b3c5bce$export$2ce376c2cc3355c8 = /*#__PURE__*/ (0, $kM2ZM$creat
303
311
  let id = (_useSlottedContext = (0, $64fa3d84918910a7$export$fabf2dc03a41866e)($3674c52c6b3c5bce$var$MenuItemContext)) === null || _useSlottedContext === void 0 ? void 0 : _useSlottedContext.id;
304
312
  let state = (0, $kM2ZM$useContext)($3674c52c6b3c5bce$export$24aad8519b95b41b);
305
313
  let ref = (0, $kM2ZM$useObjectRef)(forwardedRef);
314
+ let selectionManager = (0, $kM2ZM$useContext)($3674c52c6b3c5bce$var$SelectionManagerContext);
306
315
  let { menuItemProps: menuItemProps, labelProps: labelProps, descriptionProps: descriptionProps, keyboardShortcutProps: keyboardShortcutProps, ...states } = (0, $kM2ZM$useMenuItem)({
307
316
  ...props,
308
317
  id: id,
309
- key: item.key
318
+ key: item.key,
319
+ selectionManager: selectionManager
310
320
  }, state, ref);
311
321
  let { isFocusVisible: isFocusVisible, focusProps: focusProps } = (0, $kM2ZM$useFocusRing)();
312
322
  let { hoverProps: hoverProps, isHovered: isHovered } = (0, $kM2ZM$useHover)({
@@ -321,8 +331,8 @@ const $3674c52c6b3c5bce$export$2ce376c2cc3355c8 = /*#__PURE__*/ (0, $kM2ZM$creat
321
331
  ...states,
322
332
  isHovered: isHovered,
323
333
  isFocusVisible: isFocusVisible,
324
- selectionMode: state.selectionManager.selectionMode,
325
- selectionBehavior: state.selectionManager.selectionBehavior,
334
+ selectionMode: selectionManager.selectionMode,
335
+ selectionBehavior: selectionManager.selectionBehavior,
326
336
  hasSubmenu: !!props['aria-haspopup'],
327
337
  isOpen: props['aria-expanded'] === 'true'
328
338
  }
@@ -338,7 +348,7 @@ const $3674c52c6b3c5bce$export$2ce376c2cc3355c8 = /*#__PURE__*/ (0, $kM2ZM$creat
338
348
  "data-focus-visible": isFocusVisible || undefined,
339
349
  "data-pressed": states.isPressed || undefined,
340
350
  "data-selected": states.isSelected || undefined,
341
- "data-selection-mode": state.selectionManager.selectionMode === 'none' ? undefined : state.selectionManager.selectionMode,
351
+ "data-selection-mode": selectionManager.selectionMode === 'none' ? undefined : selectionManager.selectionMode,
342
352
  "data-has-submenu": !!props['aria-haspopup'] || undefined,
343
353
  "data-open": props['aria-expanded'] === 'true' || undefined
344
354
  }, /*#__PURE__*/ (0, $kM2ZM$react).createElement((0, $64fa3d84918910a7$export$2881499e37b75b9a), {
@@ -361,5 +371,5 @@ const $3674c52c6b3c5bce$export$2ce376c2cc3355c8 = /*#__PURE__*/ (0, $kM2ZM$creat
361
371
  });
362
372
 
363
373
 
364
- export {$3674c52c6b3c5bce$export$c7e742effb1c51e2 as MenuContext, $3674c52c6b3c5bce$export$24aad8519b95b41b as MenuStateContext, $3674c52c6b3c5bce$export$795aec4671cbae19 as RootMenuTriggerStateContext, $3674c52c6b3c5bce$export$27d2ad3c5815583e as MenuTrigger, $3674c52c6b3c5bce$export$ecabc99eeffab7ca as SubmenuTrigger, $3674c52c6b3c5bce$export$d9b273488cd8ce6f as Menu, $3674c52c6b3c5bce$export$2ce376c2cc3355c8 as MenuItem};
374
+ export {$3674c52c6b3c5bce$export$c7e742effb1c51e2 as MenuContext, $3674c52c6b3c5bce$export$24aad8519b95b41b as MenuStateContext, $3674c52c6b3c5bce$export$795aec4671cbae19 as RootMenuTriggerStateContext, $3674c52c6b3c5bce$export$27d2ad3c5815583e as MenuTrigger, $3674c52c6b3c5bce$export$ecabc99eeffab7ca as SubmenuTrigger, $3674c52c6b3c5bce$export$d9b273488cd8ce6f as Menu, $3674c52c6b3c5bce$export$4b1545b4f2016d26 as MenuSection, $3674c52c6b3c5bce$export$2ce376c2cc3355c8 as MenuItem};
365
375
  //# sourceMappingURL=Menu.module.js.map