@react-aria/menu 3.16.0 → 3.18.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 (39) hide show
  1. package/dist/types.d.ts +8 -0
  2. package/dist/types.d.ts.map +1 -1
  3. package/dist/useMenu.main.js +6 -5
  4. package/dist/useMenu.main.js.map +1 -1
  5. package/dist/useMenu.mjs +7 -5
  6. package/dist/useMenu.module.js +7 -5
  7. package/dist/useMenu.module.js.map +1 -1
  8. package/dist/useMenuItem.main.js +30 -11
  9. package/dist/useMenuItem.main.js.map +1 -1
  10. package/dist/useMenuItem.mjs +30 -11
  11. package/dist/useMenuItem.module.js +30 -11
  12. package/dist/useMenuItem.module.js.map +1 -1
  13. package/dist/useMenuTrigger.main.js +9 -4
  14. package/dist/useMenuTrigger.main.js.map +1 -1
  15. package/dist/useMenuTrigger.mjs +10 -5
  16. package/dist/useMenuTrigger.module.js +10 -5
  17. package/dist/useMenuTrigger.module.js.map +1 -1
  18. package/dist/useSafelyMouseToSubmenu.main.js +9 -1
  19. package/dist/useSafelyMouseToSubmenu.main.js.map +1 -1
  20. package/dist/useSafelyMouseToSubmenu.mjs +9 -1
  21. package/dist/useSafelyMouseToSubmenu.module.js +9 -1
  22. package/dist/useSafelyMouseToSubmenu.module.js.map +1 -1
  23. package/dist/useSubmenuTrigger.main.js +20 -14
  24. package/dist/useSubmenuTrigger.main.js.map +1 -1
  25. package/dist/useSubmenuTrigger.mjs +20 -14
  26. package/dist/useSubmenuTrigger.module.js +20 -14
  27. package/dist/useSubmenuTrigger.module.js.map +1 -1
  28. package/dist/utils.main.js +20 -0
  29. package/dist/utils.main.js.map +1 -0
  30. package/dist/utils.mjs +15 -0
  31. package/dist/utils.module.js +15 -0
  32. package/dist/utils.module.js.map +1 -0
  33. package/package.json +15 -15
  34. package/src/useMenu.ts +10 -12
  35. package/src/useMenuItem.ts +44 -13
  36. package/src/useMenuTrigger.ts +8 -4
  37. package/src/useSafelyMouseToSubmenu.ts +19 -2
  38. package/src/useSubmenuTrigger.ts +32 -14
  39. package/src/utils.ts +22 -0
package/dist/types.d.ts CHANGED
@@ -18,6 +18,10 @@ export interface AriaMenuOptions<T> extends Omit<AriaMenuProps<T>, 'children'>,
18
18
  * to override the default.
19
19
  */
20
20
  keyboardDelegate?: KeyboardDelegate;
21
+ /**
22
+ * Whether the menu items should use virtual focus instead of being focused directly.
23
+ */
24
+ shouldUseVirtualFocus?: boolean;
21
25
  }
22
26
  /**
23
27
  * Provides the behavior and accessibility implementation for a menu component.
@@ -58,6 +62,8 @@ export interface MenuItemAria {
58
62
  keyboardShortcutProps: DOMAttributes;
59
63
  /** Whether the item is currently focused. */
60
64
  isFocused: boolean;
65
+ /** Whether the item is keyboard focused. */
66
+ isFocusVisible: boolean;
61
67
  /** Whether the item is currently selected. */
62
68
  isSelected: boolean;
63
69
  /** Whether the item is currently in a pressed state. */
@@ -152,6 +158,8 @@ export interface AriaSubmenuTriggerProps {
152
158
  * @default 200
153
159
  */
154
160
  delay?: number;
161
+ /** Whether the submenu trigger uses virtual focus. */
162
+ shouldUseVirtualFocus?: boolean;
155
163
  }
156
164
  interface SubmenuTriggerProps extends Omit<AriaMenuItemProps, 'key'> {
157
165
  /** Whether the submenu trigger is in an expanded state. */
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;AAkBA;IACE,kCAAkC;IAClC,SAAS,EAAE,aAAa,CAAA;CACzB;AAED,iCAAiC,CAAC,CAAE,SAAQ,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,cAAc;IAC5F,+CAA+C;IAC/C,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;CACpC;AASD;;;;;GAKG;AACH,wBAAwB,CAAC,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,WAAW,G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AAG,IAAI,CAAC,CAAC;IAC1C;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED,6BAA8B,SAAQ,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC;IAClE,2DAA2D;IAC3D,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,uBAAuB,CAAC,CAAE,SAAQ,gBAAgB,CAAC,CAAC;IAClD,gCAAgC;IAChC,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,oCAAoC,CAAC;IACnC,+CAA+C;IAC/C,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,yEAAyE;IACzE,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC;IAC9B,iDAAiD;IACjD,YAAY,EAAE,IAAI,CAAC,gBAAgB,EAAE,YAAY,GAAG,8BAA8B,CAAC,GAAG,IAAI,CAAC,YAAY,EAAE,wBAAwB,CAAC,CAAA;CACnI;AAED;;;;;GAKG;AACH,kCAAkC,CAAC,EAAE,KAAK,EAAE,uBAAuB,EAAE,KAAK,EAAE,mBAAmB,EAAE,GAAG,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,mBAAmB,CAAC,CAAC,CA8K/J;AChOD,YAAY,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC","sources":["packages/@react-aria/menu/src/packages/@react-aria/menu/src/useMenu.ts","packages/@react-aria/menu/src/packages/@react-aria/menu/src/useMenuTrigger.ts","packages/@react-aria/menu/src/packages/@react-aria/menu/src/useMenuItem.ts","packages/@react-aria/menu/src/packages/@react-aria/menu/src/useMenuSection.ts","packages/@react-aria/menu/src/packages/@react-aria/menu/src/useSafelyMouseToSubmenu.ts","packages/@react-aria/menu/src/packages/@react-aria/menu/src/useSubmenuTrigger.ts","packages/@react-aria/menu/src/packages/@react-aria/menu/src/index.ts","packages/@react-aria/menu/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,"/*\n * Copyright 2020 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\nexport {useMenuTrigger} from './useMenuTrigger';\nexport {useMenu} from './useMenu';\nexport {useMenuItem} from './useMenuItem';\nexport {useMenuSection} from './useMenuSection';\nexport {useSubmenuTrigger} from './useSubmenuTrigger';\n\nexport type {AriaMenuProps} from '@react-types/menu';\nexport type {AriaMenuTriggerProps, MenuTriggerAria} from './useMenuTrigger';\nexport type {AriaMenuOptions, MenuAria} from './useMenu';\nexport type {AriaMenuItemProps, MenuItemAria} from './useMenuItem';\nexport type {AriaMenuSectionProps, MenuSectionAria} from './useMenuSection';\nexport type {AriaSubmenuTriggerProps, SubmenuTriggerAria} from './useSubmenuTrigger';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;;;;;;ACmBA;IACE,kCAAkC;IAClC,SAAS,EAAE,aAAa,CAAA;CACzB;AAED,iCAAiC,CAAC,CAAE,SAAQ,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE,UAAU,CAAC,EAAE,cAAc;IAC5F,+CAA+C;IAC/C,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC;;OAEG;IACH,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC;AAED;;;;;GAKG;AACH,wBAAwB,CAAC,EAAE,KAAK,EAAE,gBAAgB,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,EAAE,GAAG,EAAE,UAAU,WAAW,GAAG,IAAI,CAAC,GAAG,QAAQ,CAyCvH;AC7DD;IACE,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC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E,MAAM,CAAC;IACf,sDAAsD;IACtD,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC;AAED,6BAA8B,SAAQ,IAAI,CAAC,iBAAiB,EAAE,KAAK,CAAC;IAClE,2DAA2D;IAC3D,MAAM,EAAE,OAAO,CAAA;CAChB;AAED,uBAAuB,CAAC,CAAE,SAAQ,gBAAgB,CAAC,CAAC;IAClD,gCAAgC;IAChC,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,oCAAoC,CAAC;IACnC,+CAA+C;IAC/C,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,yEAAyE;IACzE,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC;IAC9B,iDAAiD;IACjD,YAAY,EAAE,IAAI,CAAC,gBAAgB,EAAE,YAAY,GAAG,8BAA8B,CAAC,GAAG,IAAI,CAAC,YAAY,EAAE,wBAAwB,CAAC,CAAA;CACnI;AAED;;;;;GAKG;AACH,kCAAkC,CAAC,EAAE,KAAK,EAAE,uBAAuB,EAAE,KAAK,EAAE,mBAAmB,EAAE,GAAG,EAAE,UAAU,gBAAgB,GAAG,IAAI,CAAC,GAAG,mBAAmB,CAAC,CAAC,CA8L/J;AClPD,YAAY,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC","sources":["packages/@react-aria/menu/src/packages/@react-aria/menu/src/utils.ts","packages/@react-aria/menu/src/packages/@react-aria/menu/src/useMenu.ts","packages/@react-aria/menu/src/packages/@react-aria/menu/src/useMenuTrigger.ts","packages/@react-aria/menu/src/packages/@react-aria/menu/src/useMenuItem.ts","packages/@react-aria/menu/src/packages/@react-aria/menu/src/useMenuSection.ts","packages/@react-aria/menu/src/packages/@react-aria/menu/src/useSafelyMouseToSubmenu.ts","packages/@react-aria/menu/src/packages/@react-aria/menu/src/useSubmenuTrigger.ts","packages/@react-aria/menu/src/packages/@react-aria/menu/src/index.ts","packages/@react-aria/menu/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,"/*\n * Copyright 2020 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\nexport {useMenuTrigger} from './useMenuTrigger';\nexport {useMenu} from './useMenu';\nexport {useMenuItem} from './useMenuItem';\nexport {useMenuSection} from './useMenuSection';\nexport {useSubmenuTrigger} from './useSubmenuTrigger';\n\nexport type {AriaMenuProps} from '@react-types/menu';\nexport type {AriaMenuTriggerProps, MenuTriggerAria} from './useMenuTrigger';\nexport type {AriaMenuOptions, MenuAria} from './useMenu';\nexport type {AriaMenuItemProps, MenuItemAria} from './useMenuItem';\nexport type {AriaMenuSectionProps, MenuSectionAria} from './useMenuSection';\nexport type {AriaSubmenuTriggerProps, SubmenuTriggerAria} from './useSubmenuTrigger';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
@@ -1,3 +1,4 @@
1
+ var $815e346b11b84016$exports = require("./utils.main.js");
1
2
  var $6CumN$reactariautils = require("@react-aria/utils");
2
3
  var $6CumN$reactariaselection = require("@react-aria/selection");
3
4
 
@@ -6,7 +7,6 @@ function $parcel$export(e, n, v, s) {
6
7
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
8
  }
8
9
 
9
- $parcel$export(module.exports, "menuData", () => $a3815f0132802737$export$6f49b4016bfc8d56);
10
10
  $parcel$export(module.exports, "useMenu", () => $a3815f0132802737$export$38eaa17faae8f579);
11
11
  /*
12
12
  * Copyright 2020 Adobe. All rights reserved.
@@ -20,7 +20,7 @@ $parcel$export(module.exports, "useMenu", () => $a3815f0132802737$export$38eaa17
20
20
  * governing permissions and limitations under the License.
21
21
  */
22
22
 
23
- const $a3815f0132802737$export$6f49b4016bfc8d56 = new WeakMap();
23
+
24
24
  function $a3815f0132802737$export$38eaa17faae8f579(props, state, ref) {
25
25
  let { shouldFocusWrap: shouldFocusWrap = true, onKeyDown: onKeyDown, onKeyUp: onKeyUp, ...otherProps } = props;
26
26
  if (!props['aria-label'] && !props['aria-labelledby']) console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
@@ -36,9 +36,10 @@ function $a3815f0132802737$export$38eaa17faae8f579(props, state, ref) {
36
36
  shouldFocusWrap: shouldFocusWrap,
37
37
  linkBehavior: 'override'
38
38
  });
39
- $a3815f0132802737$export$6f49b4016bfc8d56.set(state, {
39
+ (0, $815e346b11b84016$exports.menuData).set(state, {
40
40
  onClose: props.onClose,
41
- onAction: props.onAction
41
+ onAction: props.onAction,
42
+ shouldUseVirtualFocus: props.shouldUseVirtualFocus
42
43
  });
43
44
  return {
44
45
  menuProps: (0, $6CumN$reactariautils.mergeProps)(domProps, {
@@ -50,7 +51,7 @@ function $a3815f0132802737$export$38eaa17faae8f579(props, state, ref) {
50
51
  onKeyDown: (e)=>{
51
52
  var _listProps_onKeyDown;
52
53
  // don't clear the menu selected keys if the user is presses escape since escape closes the menu
53
- if (e.key !== 'Escape') (_listProps_onKeyDown = listProps.onKeyDown) === null || _listProps_onKeyDown === void 0 ? void 0 : _listProps_onKeyDown.call(listProps, e);
54
+ if (e.key !== 'Escape' || props.shouldUseVirtualFocus) (_listProps_onKeyDown = listProps.onKeyDown) === null || _listProps_onKeyDown === void 0 ? void 0 : _listProps_onKeyDown.call(listProps, e);
54
55
  }
55
56
  })
56
57
  };
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;AA6BM,MAAM,4CAAW,IAAI;AAQrB,SAAS,0CAAW,KAAyB,EAAE,KAAmB,EAAE,GAAkC;IAC3G,IAAI,mBACF,kBAAkB,iBAClB,SAAS,WACT,OAAO,EACP,GAAG,YACJ,GAAG;IAEJ,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB,EACnD,QAAQ,IAAI,CAAC;IAGf,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,2CAAgB,EAAE;QAClC,GAAG,UAAU;aACb;QACA,kBAAkB,MAAM,gBAAgB;QACxC,YAAY,MAAM,UAAU;QAC5B,cAAc,MAAM,YAAY;yBAChC;QACA,cAAc;IAChB;IAEA,0CAAS,GAAG,CAAC,OAAO;QAClB,SAAS,MAAM,OAAO;QACtB,UAAU,MAAM,QAAQ;IAC1B;IAEA,OAAO;QACL,WAAW,CAAA,GAAA,gCAAS,EAAE,UAAU;uBAAC;qBAAW;QAAO,GAAG;YACpD,MAAM;YACN,GAAG,SAAS;YACZ,WAAW,CAAC;oBAGR;gBAFF,gGAAgG;gBAChG,IAAI,EAAE,GAAG,KAAK,WACZ,uBAAA,UAAU,SAAS,cAAnB,2CAAA,0BAAA,WAAsB;YAE1B;QACF;IACF;AACF","sources":["packages/@react-aria/menu/src/useMenu.ts"],"sourcesContent":["/*\n * Copyright 2020 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\nimport {AriaMenuProps} from '@react-types/menu';\nimport {DOMAttributes, Key, KeyboardDelegate, KeyboardEvents, RefObject} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {TreeState} from '@react-stately/tree';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface MenuAria {\n /** Props for the menu element. */\n menuProps: DOMAttributes\n}\n\nexport interface AriaMenuOptions<T> extends Omit<AriaMenuProps<T>, 'children'>, KeyboardEvents {\n /** Whether the menu uses virtual scrolling. */\n isVirtualized?: boolean,\n\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate\n}\n\ninterface MenuData {\n onClose?: () => void,\n onAction?: (key: Key) => void\n}\n\nexport const menuData = new WeakMap<TreeState<unknown>, MenuData>();\n\n/**\n * Provides the behavior and accessibility implementation for a menu component.\n * A menu displays a list of actions or options that a user can choose.\n * @param props - Props for the menu.\n * @param state - State for the menu, as returned by `useListState`.\n */\nexport function useMenu<T>(props: AriaMenuOptions<T>, state: TreeState<T>, ref: RefObject<HTMLElement | null>): MenuAria {\n let {\n shouldFocusWrap = true,\n onKeyDown,\n onKeyUp,\n ...otherProps\n } = props;\n\n if (!props['aria-label'] && !props['aria-labelledby']) {\n console.warn('An aria-label or aria-labelledby prop is required for accessibility.');\n }\n\n let domProps = filterDOMProps(props, {labelable: true});\n let {listProps} = useSelectableList({\n ...otherProps,\n ref,\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n shouldFocusWrap,\n linkBehavior: 'override'\n });\n\n menuData.set(state, {\n onClose: props.onClose,\n onAction: props.onAction\n });\n\n return {\n menuProps: mergeProps(domProps, {onKeyDown, onKeyUp}, {\n role: 'menu',\n ...listProps,\n onKeyDown: (e) => {\n // don't clear the menu selected keys if the user is presses escape since escape closes the menu\n if (e.key !== 'Escape') {\n listProps.onKeyDown?.(e);\n }\n }\n })\n };\n}\n"],"names":[],"version":3,"file":"useMenu.main.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAkCM,SAAS,0CAAW,KAAyB,EAAE,KAAmB,EAAE,GAAkC;IAC3G,IAAI,mBACF,kBAAkB,iBAClB,SAAS,WACT,OAAO,EACP,GAAG,YACJ,GAAG;IAEJ,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB,EACnD,QAAQ,IAAI,CAAC;IAGf,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,2CAAgB,EAAE;QAClC,GAAG,UAAU;aACb;QACA,kBAAkB,MAAM,gBAAgB;QACxC,YAAY,MAAM,UAAU;QAC5B,cAAc,MAAM,YAAY;yBAChC;QACA,cAAc;IAChB;IAEA,CAAA,GAAA,kCAAO,EAAE,GAAG,CAAC,OAAO;QAClB,SAAS,MAAM,OAAO;QACtB,UAAU,MAAM,QAAQ;QACxB,uBAAuB,MAAM,qBAAqB;IACpD;IAEA,OAAO;QACL,WAAW,CAAA,GAAA,gCAAS,EAAE,UAAU;uBAAC;qBAAW;QAAO,GAAG;YACpD,MAAM;YACN,GAAG,SAAS;YACZ,WAAW,CAAC;oBAGR;gBAFF,gGAAgG;gBAChG,IAAI,EAAE,GAAG,KAAK,YAAY,MAAM,qBAAqB,GACnD,uBAAA,UAAU,SAAS,cAAnB,2CAAA,0BAAA,WAAsB;YAE1B;QACF;IACF;AACF","sources":["packages/@react-aria/menu/src/useMenu.ts"],"sourcesContent":["/*\n * Copyright 2020 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\nimport {AriaMenuProps} from '@react-types/menu';\nimport {DOMAttributes, KeyboardDelegate, KeyboardEvents, RefObject} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {menuData} from './utils';\nimport {TreeState} from '@react-stately/tree';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface MenuAria {\n /** Props for the menu element. */\n menuProps: DOMAttributes\n}\n\nexport interface AriaMenuOptions<T> extends Omit<AriaMenuProps<T>, 'children'>, KeyboardEvents {\n /** Whether the menu uses virtual scrolling. */\n isVirtualized?: boolean,\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate,\n /**\n * Whether the menu items should use virtual focus instead of being focused directly.\n */\n shouldUseVirtualFocus?: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a menu component.\n * A menu displays a list of actions or options that a user can choose.\n * @param props - Props for the menu.\n * @param state - State for the menu, as returned by `useListState`.\n */\nexport function useMenu<T>(props: AriaMenuOptions<T>, state: TreeState<T>, ref: RefObject<HTMLElement | null>): MenuAria {\n let {\n shouldFocusWrap = true,\n onKeyDown,\n onKeyUp,\n ...otherProps\n } = props;\n\n if (!props['aria-label'] && !props['aria-labelledby']) {\n console.warn('An aria-label or aria-labelledby prop is required for accessibility.');\n }\n\n let domProps = filterDOMProps(props, {labelable: true});\n let {listProps} = useSelectableList({\n ...otherProps,\n ref,\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n shouldFocusWrap,\n linkBehavior: 'override'\n });\n\n menuData.set(state, {\n onClose: props.onClose,\n onAction: props.onAction,\n shouldUseVirtualFocus: props.shouldUseVirtualFocus\n });\n\n return {\n menuProps: mergeProps(domProps, {onKeyDown, onKeyUp}, {\n role: 'menu',\n ...listProps,\n onKeyDown: (e) => {\n // don't clear the menu selected keys if the user is presses escape since escape closes the menu\n if (e.key !== 'Escape' || props.shouldUseVirtualFocus) {\n listProps.onKeyDown?.(e);\n }\n }\n })\n };\n}\n"],"names":[],"version":3,"file":"useMenu.main.js.map"}
package/dist/useMenu.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import {menuData as $fc79756100351201$export$6f49b4016bfc8d56} from "./utils.mjs";
1
2
  import {filterDOMProps as $ieN2F$filterDOMProps, mergeProps as $ieN2F$mergeProps} from "@react-aria/utils";
2
3
  import {useSelectableList as $ieN2F$useSelectableList} from "@react-aria/selection";
3
4
 
@@ -13,7 +14,7 @@ import {useSelectableList as $ieN2F$useSelectableList} from "@react-aria/selecti
13
14
  * governing permissions and limitations under the License.
14
15
  */
15
16
 
16
- const $d5336fe17ce95402$export$6f49b4016bfc8d56 = new WeakMap();
17
+
17
18
  function $d5336fe17ce95402$export$38eaa17faae8f579(props, state, ref) {
18
19
  let { shouldFocusWrap: shouldFocusWrap = true, onKeyDown: onKeyDown, onKeyUp: onKeyUp, ...otherProps } = props;
19
20
  if (!props['aria-label'] && !props['aria-labelledby']) console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
@@ -29,9 +30,10 @@ function $d5336fe17ce95402$export$38eaa17faae8f579(props, state, ref) {
29
30
  shouldFocusWrap: shouldFocusWrap,
30
31
  linkBehavior: 'override'
31
32
  });
32
- $d5336fe17ce95402$export$6f49b4016bfc8d56.set(state, {
33
+ (0, $fc79756100351201$export$6f49b4016bfc8d56).set(state, {
33
34
  onClose: props.onClose,
34
- onAction: props.onAction
35
+ onAction: props.onAction,
36
+ shouldUseVirtualFocus: props.shouldUseVirtualFocus
35
37
  });
36
38
  return {
37
39
  menuProps: (0, $ieN2F$mergeProps)(domProps, {
@@ -43,12 +45,12 @@ function $d5336fe17ce95402$export$38eaa17faae8f579(props, state, ref) {
43
45
  onKeyDown: (e)=>{
44
46
  var _listProps_onKeyDown;
45
47
  // don't clear the menu selected keys if the user is presses escape since escape closes the menu
46
- if (e.key !== 'Escape') (_listProps_onKeyDown = listProps.onKeyDown) === null || _listProps_onKeyDown === void 0 ? void 0 : _listProps_onKeyDown.call(listProps, e);
48
+ if (e.key !== 'Escape' || props.shouldUseVirtualFocus) (_listProps_onKeyDown = listProps.onKeyDown) === null || _listProps_onKeyDown === void 0 ? void 0 : _listProps_onKeyDown.call(listProps, e);
47
49
  }
48
50
  })
49
51
  };
50
52
  }
51
53
 
52
54
 
53
- export {$d5336fe17ce95402$export$6f49b4016bfc8d56 as menuData, $d5336fe17ce95402$export$38eaa17faae8f579 as useMenu};
55
+ export {$d5336fe17ce95402$export$38eaa17faae8f579 as useMenu};
54
56
  //# sourceMappingURL=useMenu.module.js.map
@@ -1,3 +1,4 @@
1
+ import {menuData as $fc79756100351201$export$6f49b4016bfc8d56} from "./utils.module.js";
1
2
  import {filterDOMProps as $ieN2F$filterDOMProps, mergeProps as $ieN2F$mergeProps} from "@react-aria/utils";
2
3
  import {useSelectableList as $ieN2F$useSelectableList} from "@react-aria/selection";
3
4
 
@@ -13,7 +14,7 @@ import {useSelectableList as $ieN2F$useSelectableList} from "@react-aria/selecti
13
14
  * governing permissions and limitations under the License.
14
15
  */
15
16
 
16
- const $d5336fe17ce95402$export$6f49b4016bfc8d56 = new WeakMap();
17
+
17
18
  function $d5336fe17ce95402$export$38eaa17faae8f579(props, state, ref) {
18
19
  let { shouldFocusWrap: shouldFocusWrap = true, onKeyDown: onKeyDown, onKeyUp: onKeyUp, ...otherProps } = props;
19
20
  if (!props['aria-label'] && !props['aria-labelledby']) console.warn('An aria-label or aria-labelledby prop is required for accessibility.');
@@ -29,9 +30,10 @@ function $d5336fe17ce95402$export$38eaa17faae8f579(props, state, ref) {
29
30
  shouldFocusWrap: shouldFocusWrap,
30
31
  linkBehavior: 'override'
31
32
  });
32
- $d5336fe17ce95402$export$6f49b4016bfc8d56.set(state, {
33
+ (0, $fc79756100351201$export$6f49b4016bfc8d56).set(state, {
33
34
  onClose: props.onClose,
34
- onAction: props.onAction
35
+ onAction: props.onAction,
36
+ shouldUseVirtualFocus: props.shouldUseVirtualFocus
35
37
  });
36
38
  return {
37
39
  menuProps: (0, $ieN2F$mergeProps)(domProps, {
@@ -43,12 +45,12 @@ function $d5336fe17ce95402$export$38eaa17faae8f579(props, state, ref) {
43
45
  onKeyDown: (e)=>{
44
46
  var _listProps_onKeyDown;
45
47
  // don't clear the menu selected keys if the user is presses escape since escape closes the menu
46
- if (e.key !== 'Escape') (_listProps_onKeyDown = listProps.onKeyDown) === null || _listProps_onKeyDown === void 0 ? void 0 : _listProps_onKeyDown.call(listProps, e);
48
+ if (e.key !== 'Escape' || props.shouldUseVirtualFocus) (_listProps_onKeyDown = listProps.onKeyDown) === null || _listProps_onKeyDown === void 0 ? void 0 : _listProps_onKeyDown.call(listProps, e);
47
49
  }
48
50
  })
49
51
  };
50
52
  }
51
53
 
52
54
 
53
- export {$d5336fe17ce95402$export$6f49b4016bfc8d56 as menuData, $d5336fe17ce95402$export$38eaa17faae8f579 as useMenu};
55
+ export {$d5336fe17ce95402$export$38eaa17faae8f579 as useMenu};
54
56
  //# sourceMappingURL=useMenu.module.js.map
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AA6BM,MAAM,4CAAW,IAAI;AAQrB,SAAS,0CAAW,KAAyB,EAAE,KAAmB,EAAE,GAAkC;IAC3G,IAAI,mBACF,kBAAkB,iBAClB,SAAS,WACT,OAAO,EACP,GAAG,YACJ,GAAG;IAEJ,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB,EACnD,QAAQ,IAAI,CAAC;IAGf,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,wBAAgB,EAAE;QAClC,GAAG,UAAU;aACb;QACA,kBAAkB,MAAM,gBAAgB;QACxC,YAAY,MAAM,UAAU;QAC5B,cAAc,MAAM,YAAY;yBAChC;QACA,cAAc;IAChB;IAEA,0CAAS,GAAG,CAAC,OAAO;QAClB,SAAS,MAAM,OAAO;QACtB,UAAU,MAAM,QAAQ;IAC1B;IAEA,OAAO;QACL,WAAW,CAAA,GAAA,iBAAS,EAAE,UAAU;uBAAC;qBAAW;QAAO,GAAG;YACpD,MAAM;YACN,GAAG,SAAS;YACZ,WAAW,CAAC;oBAGR;gBAFF,gGAAgG;gBAChG,IAAI,EAAE,GAAG,KAAK,WACZ,uBAAA,UAAU,SAAS,cAAnB,2CAAA,0BAAA,WAAsB;YAE1B;QACF;IACF;AACF","sources":["packages/@react-aria/menu/src/useMenu.ts"],"sourcesContent":["/*\n * Copyright 2020 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\nimport {AriaMenuProps} from '@react-types/menu';\nimport {DOMAttributes, Key, KeyboardDelegate, KeyboardEvents, RefObject} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {TreeState} from '@react-stately/tree';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface MenuAria {\n /** Props for the menu element. */\n menuProps: DOMAttributes\n}\n\nexport interface AriaMenuOptions<T> extends Omit<AriaMenuProps<T>, 'children'>, KeyboardEvents {\n /** Whether the menu uses virtual scrolling. */\n isVirtualized?: boolean,\n\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate\n}\n\ninterface MenuData {\n onClose?: () => void,\n onAction?: (key: Key) => void\n}\n\nexport const menuData = new WeakMap<TreeState<unknown>, MenuData>();\n\n/**\n * Provides the behavior and accessibility implementation for a menu component.\n * A menu displays a list of actions or options that a user can choose.\n * @param props - Props for the menu.\n * @param state - State for the menu, as returned by `useListState`.\n */\nexport function useMenu<T>(props: AriaMenuOptions<T>, state: TreeState<T>, ref: RefObject<HTMLElement | null>): MenuAria {\n let {\n shouldFocusWrap = true,\n onKeyDown,\n onKeyUp,\n ...otherProps\n } = props;\n\n if (!props['aria-label'] && !props['aria-labelledby']) {\n console.warn('An aria-label or aria-labelledby prop is required for accessibility.');\n }\n\n let domProps = filterDOMProps(props, {labelable: true});\n let {listProps} = useSelectableList({\n ...otherProps,\n ref,\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n shouldFocusWrap,\n linkBehavior: 'override'\n });\n\n menuData.set(state, {\n onClose: props.onClose,\n onAction: props.onAction\n });\n\n return {\n menuProps: mergeProps(domProps, {onKeyDown, onKeyUp}, {\n role: 'menu',\n ...listProps,\n onKeyDown: (e) => {\n // don't clear the menu selected keys if the user is presses escape since escape closes the menu\n if (e.key !== 'Escape') {\n listProps.onKeyDown?.(e);\n }\n }\n })\n };\n}\n"],"names":[],"version":3,"file":"useMenu.module.js.map"}
1
+ {"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAkCM,SAAS,0CAAW,KAAyB,EAAE,KAAmB,EAAE,GAAkC;IAC3G,IAAI,mBACF,kBAAkB,iBAClB,SAAS,WACT,OAAO,EACP,GAAG,YACJ,GAAG;IAEJ,IAAI,CAAC,KAAK,CAAC,aAAa,IAAI,CAAC,KAAK,CAAC,kBAAkB,EACnD,QAAQ,IAAI,CAAC;IAGf,IAAI,WAAW,CAAA,GAAA,qBAAa,EAAE,OAAO;QAAC,WAAW;IAAI;IACrD,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,wBAAgB,EAAE;QAClC,GAAG,UAAU;aACb;QACA,kBAAkB,MAAM,gBAAgB;QACxC,YAAY,MAAM,UAAU;QAC5B,cAAc,MAAM,YAAY;yBAChC;QACA,cAAc;IAChB;IAEA,CAAA,GAAA,yCAAO,EAAE,GAAG,CAAC,OAAO;QAClB,SAAS,MAAM,OAAO;QACtB,UAAU,MAAM,QAAQ;QACxB,uBAAuB,MAAM,qBAAqB;IACpD;IAEA,OAAO;QACL,WAAW,CAAA,GAAA,iBAAS,EAAE,UAAU;uBAAC;qBAAW;QAAO,GAAG;YACpD,MAAM;YACN,GAAG,SAAS;YACZ,WAAW,CAAC;oBAGR;gBAFF,gGAAgG;gBAChG,IAAI,EAAE,GAAG,KAAK,YAAY,MAAM,qBAAqB,GACnD,uBAAA,UAAU,SAAS,cAAnB,2CAAA,0BAAA,WAAsB;YAE1B;QACF;IACF;AACF","sources":["packages/@react-aria/menu/src/useMenu.ts"],"sourcesContent":["/*\n * Copyright 2020 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\nimport {AriaMenuProps} from '@react-types/menu';\nimport {DOMAttributes, KeyboardDelegate, KeyboardEvents, RefObject} from '@react-types/shared';\nimport {filterDOMProps, mergeProps} from '@react-aria/utils';\nimport {menuData} from './utils';\nimport {TreeState} from '@react-stately/tree';\nimport {useSelectableList} from '@react-aria/selection';\n\nexport interface MenuAria {\n /** Props for the menu element. */\n menuProps: DOMAttributes\n}\n\nexport interface AriaMenuOptions<T> extends Omit<AriaMenuProps<T>, 'children'>, KeyboardEvents {\n /** Whether the menu uses virtual scrolling. */\n isVirtualized?: boolean,\n /**\n * An optional keyboard delegate implementation for type to select,\n * to override the default.\n */\n keyboardDelegate?: KeyboardDelegate,\n /**\n * Whether the menu items should use virtual focus instead of being focused directly.\n */\n shouldUseVirtualFocus?: boolean\n}\n\n/**\n * Provides the behavior and accessibility implementation for a menu component.\n * A menu displays a list of actions or options that a user can choose.\n * @param props - Props for the menu.\n * @param state - State for the menu, as returned by `useListState`.\n */\nexport function useMenu<T>(props: AriaMenuOptions<T>, state: TreeState<T>, ref: RefObject<HTMLElement | null>): MenuAria {\n let {\n shouldFocusWrap = true,\n onKeyDown,\n onKeyUp,\n ...otherProps\n } = props;\n\n if (!props['aria-label'] && !props['aria-labelledby']) {\n console.warn('An aria-label or aria-labelledby prop is required for accessibility.');\n }\n\n let domProps = filterDOMProps(props, {labelable: true});\n let {listProps} = useSelectableList({\n ...otherProps,\n ref,\n selectionManager: state.selectionManager,\n collection: state.collection,\n disabledKeys: state.disabledKeys,\n shouldFocusWrap,\n linkBehavior: 'override'\n });\n\n menuData.set(state, {\n onClose: props.onClose,\n onAction: props.onAction,\n shouldUseVirtualFocus: props.shouldUseVirtualFocus\n });\n\n return {\n menuProps: mergeProps(domProps, {onKeyDown, onKeyUp}, {\n role: 'menu',\n ...listProps,\n onKeyDown: (e) => {\n // don't clear the menu selected keys if the user is presses escape since escape closes the menu\n if (e.key !== 'Escape' || props.shouldUseVirtualFocus) {\n listProps.onKeyDown?.(e);\n }\n }\n })\n };\n}\n"],"names":[],"version":3,"file":"useMenu.module.js.map"}
@@ -1,4 +1,4 @@
1
- var $a3815f0132802737$exports = require("./useMenu.main.js");
1
+ var $815e346b11b84016$exports = require("./utils.main.js");
2
2
  var $byVdR$reactariautils = require("@react-aria/utils");
3
3
  var $byVdR$reactstatelycollections = require("@react-stately/collections");
4
4
  var $byVdR$reactariainteractions = require("@react-aria/interactions");
@@ -26,14 +26,14 @@ $parcel$export(module.exports, "useMenuItem", () => $38191ed02615ec07$export$9d3
26
26
 
27
27
 
28
28
  function $38191ed02615ec07$export$9d32628fc2aea7da(props, state, ref) {
29
- let { id: id, key: key, closeOnSelect: closeOnSelect, isVirtualized: isVirtualized, 'aria-haspopup': hasPopup, onPressStart: pressStartProp, onPressUp: pressUpProp, onPress: onPress, onPressChange: onPressChange, onPressEnd: onPressEnd, onHoverStart: hoverStartProp, onHoverChange: onHoverChange, onHoverEnd: onHoverEnd, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onFocus: onFocus, onFocusChange: onFocusChange, onBlur: onBlur, selectionManager: selectionManager = state.selectionManager } = props;
29
+ let { id: id, key: key, closeOnSelect: closeOnSelect, isVirtualized: isVirtualized, 'aria-haspopup': hasPopup, onPressStart: pressStartProp, onPressUp: pressUpProp, onPress: pressProp, onPressChange: onPressChange, onPressEnd: onPressEnd, onHoverStart: hoverStartProp, onHoverChange: onHoverChange, onHoverEnd: onHoverEnd, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onFocus: onFocus, onFocusChange: onFocusChange, onBlur: onBlur, selectionManager: selectionManager = state.selectionManager } = props;
30
30
  let isTrigger = !!hasPopup;
31
31
  let isTriggerExpanded = isTrigger && props['aria-expanded'] === 'true';
32
32
  var _props_isDisabled;
33
33
  let isDisabled = (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : selectionManager.isDisabled(key);
34
34
  var _props_isSelected;
35
35
  let isSelected = (_props_isSelected = props.isSelected) !== null && _props_isSelected !== void 0 ? _props_isSelected : selectionManager.isSelected(key);
36
- let data = (0, $a3815f0132802737$exports.menuData).get(state);
36
+ let data = (0, $815e346b11b84016$exports.menuData).get(state);
37
37
  let item = state.collection.getItem(key);
38
38
  let onClose = props.onClose || data.onClose;
39
39
  let router = (0, $byVdR$reactariautils.useRouter)();
@@ -80,16 +80,29 @@ function $38191ed02615ec07$export$9d32628fc2aea7da(props, state, ref) {
80
80
  if (e.pointerType === 'keyboard') performAction(e);
81
81
  pressStartProp === null || pressStartProp === void 0 ? void 0 : pressStartProp(e);
82
82
  };
83
+ let maybeClose = ()=>{
84
+ // Pressing a menu item should close by default in single selection mode but not multiple
85
+ // selection mode, except if overridden by the closeOnSelect prop.
86
+ if (!isTrigger && onClose && (closeOnSelect !== null && closeOnSelect !== void 0 ? closeOnSelect : selectionManager.selectionMode !== 'multiple' || selectionManager.isLink(key))) onClose();
87
+ };
83
88
  let onPressUp = (e)=>{
84
- if (e.pointerType !== 'keyboard') {
89
+ // If interacting with mouse, allow the user to mouse down on the trigger button,
90
+ // drag, and release over an item (matching native behavior).
91
+ if (e.pointerType === 'mouse') {
85
92
  performAction(e);
86
- // Pressing a menu item should close by default in single selection mode but not multiple
87
- // selection mode, except if overridden by the closeOnSelect prop.
88
- if (!isTrigger && onClose && (closeOnSelect !== null && closeOnSelect !== void 0 ? closeOnSelect : selectionManager.selectionMode !== 'multiple' || selectionManager.isLink(key))) onClose();
93
+ maybeClose();
89
94
  }
90
95
  pressUpProp === null || pressUpProp === void 0 ? void 0 : pressUpProp(e);
91
96
  };
97
+ let onPress = (e)=>{
98
+ if (e.pointerType !== 'keyboard' && e.pointerType !== 'mouse') {
99
+ performAction(e);
100
+ maybeClose();
101
+ }
102
+ pressProp === null || pressProp === void 0 ? void 0 : pressProp(e);
103
+ };
92
104
  let { itemProps: itemProps, isFocused: isFocused } = (0, $byVdR$reactariaselection.useSelectableItem)({
105
+ id: id,
93
106
  selectionManager: selectionManager,
94
107
  key: key,
95
108
  ref: ref,
@@ -99,7 +112,8 @@ function $38191ed02615ec07$export$9d32628fc2aea7da(props, state, ref) {
99
112
  // because we handle it ourselves. The behavior of menus
100
113
  // is slightly different from other collections because
101
114
  // actions are performed on key down rather than key up.
102
- linkBehavior: 'none'
115
+ linkBehavior: 'none',
116
+ shouldUseVirtualFocus: data.shouldUseVirtualFocus
103
117
  });
104
118
  let { pressProps: pressProps, isPressed: isPressed } = (0, $byVdR$reactariainteractions.usePress)({
105
119
  onPressStart: onPressStart,
@@ -113,7 +127,7 @@ function $38191ed02615ec07$export$9d32628fc2aea7da(props, state, ref) {
113
127
  isDisabled: isDisabled,
114
128
  onHoverStart (e) {
115
129
  // Hovering over an already expanded sub dialog trigger should keep focus in the dialog.
116
- if (!(0, $byVdR$reactariainteractions.isFocusVisible)() && !(isTriggerExpanded && hasPopup === 'dialog')) {
130
+ if (!(0, $byVdR$reactariainteractions.isFocusVisible)() && !(isTriggerExpanded && hasPopup)) {
117
131
  selectionManager.setFocused(true);
118
132
  selectionManager.setFocusedKey(key);
119
133
  }
@@ -159,10 +173,14 @@ function $38191ed02615ec07$export$9d32628fc2aea7da(props, state, ref) {
159
173
  ...ariaProps,
160
174
  ...(0, $byVdR$reactariautils.mergeProps)(domProps, linkProps, isTrigger ? {
161
175
  onFocus: itemProps.onFocus,
176
+ 'data-collection': itemProps['data-collection'],
162
177
  'data-key': itemProps['data-key']
163
- } : itemProps, pressProps, hoverProps, keyboardProps, focusProps),
178
+ } : itemProps, pressProps, hoverProps, keyboardProps, focusProps, // Prevent DOM focus from moving on mouse down when using virtual focus or this is a submenu/subdialog trigger.
179
+ data.shouldUseVirtualFocus || isTrigger ? {
180
+ onMouseDown: (e)=>e.preventDefault()
181
+ } : undefined),
164
182
  // If a submenu is expanded, set the tabIndex to -1 so that shift tabbing goes out of the menu instead of the parent menu item.
165
- tabIndex: itemProps.tabIndex != null && isTriggerExpanded ? -1 : itemProps.tabIndex
183
+ tabIndex: itemProps.tabIndex != null && isTriggerExpanded && !data.shouldUseVirtualFocus ? -1 : itemProps.tabIndex
166
184
  },
167
185
  labelProps: {
168
186
  id: labelId
@@ -174,6 +192,7 @@ function $38191ed02615ec07$export$9d32628fc2aea7da(props, state, ref) {
174
192
  id: keyboardId
175
193
  },
176
194
  isFocused: isFocused,
195
+ isFocusVisible: isFocused && selectionManager.isFocused && (0, $byVdR$reactariainteractions.isFocusVisible)() && !isTriggerExpanded,
177
196
  isSelected: isSelected,
178
197
  isPressed: isPressed,
179
198
  isDisabled: isDisabled
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA6FM,SAAS,0CAAe,KAAwB,EAAE,KAAmB,EAAE,GAAuC;IACnH,IAAI,MACF,EAAE,OACF,GAAG,iBACH,aAAa,iBACb,aAAa,EACb,iBAAiB,QAAQ,EACzB,cAAc,cAAc,EAC5B,WAAW,WAAW,WACtB,OAAO,iBACP,aAAa,cACb,UAAU,EACV,cAAc,cAAc,iBAC5B,aAAa,cACb,UAAU,aACV,SAAS,WACT,OAAO,WACP,OAAO,iBACP,aAAa,UACb,MAAM,oBACN,mBAAmB,MAAM,gBAAgB,EAC1C,GAAG;IAEJ,IAAI,YAAY,CAAC,CAAC;IAClB,IAAI,oBAAoB,aAAa,KAAK,CAAC,gBAAgB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F;AACF","sources":["packages/@react-aria/menu/src/useMenuItem.ts"],"sourcesContent":["/*\n * Copyright 2020 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\nimport {DOMAttributes, DOMProps, FocusableElement, FocusEvents, HoverEvents, Key, KeyboardEvents, PressEvent, PressEvents, RefObject, RouterOptions} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useLinkProps, useRouter, useSlotId} from '@react-aria/utils';\nimport {getItemCount} from '@react-stately/collections';\nimport {isFocusVisible, useFocus, useHover, useKeyboard, usePress} from '@react-aria/interactions';\nimport {menuData} from './useMenu';\nimport {SelectionManager} from '@react-stately/selection';\nimport {TreeState} from '@react-stately/tree';\nimport {useSelectableItem} from '@react-aria/selection';\n\nexport interface MenuItemAria {\n /** Props for the menu item element. */\n menuItemProps: DOMAttributes,\n\n /** Props for the main text element inside the menu item. */\n labelProps: DOMAttributes,\n\n /** Props for the description text element inside the menu item, if any. */\n descriptionProps: DOMAttributes,\n\n /** Props for the keyboard shortcut text element inside the item, if any. */\n keyboardShortcutProps: DOMAttributes,\n\n /** Whether the item is currently focused. */\n isFocused: boolean,\n /** Whether the item is currently selected. */\n isSelected: boolean,\n /** Whether the item is currently in a pressed state. */\n isPressed: boolean,\n /** Whether the item is disabled. */\n isDisabled: boolean\n}\n\nexport interface AriaMenuItemProps extends DOMProps, PressEvents, HoverEvents, KeyboardEvents, FocusEvents {\n /**\n * Whether the menu item is disabled.\n * @deprecated - pass disabledKeys to useTreeState instead.\n */\n isDisabled?: boolean,\n\n /**\n * Whether the menu item is selected.\n * @deprecated - pass selectedKeys to useTreeState instead.\n */\n isSelected?: boolean,\n\n /** A screen reader only label for the menu item. */\n 'aria-label'?: string,\n\n /** The unique key for the menu item. */\n key: Key,\n\n /**\n * Handler that is called when the menu should close after selecting an item.\n * @deprecated - pass to the menu instead.\n */\n onClose?: () => void,\n\n /**\n * Whether the menu should close when the menu item is selected.\n * @default true\n */\n closeOnSelect?: boolean,\n\n /** Whether the menu item is contained in a virtual scrolling menu. */\n isVirtualized?: boolean,\n\n /**\n * Handler that is called when the user activates the item.\n * @deprecated - pass to the menu instead.\n */\n onAction?: (key: Key) => void,\n\n /** What kind of popup the item opens. */\n 'aria-haspopup'?: 'menu' | 'dialog',\n\n /** Indicates whether the menu item's popup element is expanded or collapsed. */\n 'aria-expanded'?: boolean | 'true' | 'false',\n\n /** Identifies the menu item's popup element whose contents or presence is controlled by the menu item. */\n 'aria-controls'?: string,\n\n /** Override of the selection manager. By default, `state.selectionManager` is used. */\n selectionManager?: SelectionManager\n}\n\n/**\n * Provides the behavior and accessibility implementation for an item in a menu.\n * See `useMenu` for more details about menus.\n * @param props - Props for the item.\n * @param state - State for the menu, as returned by `useTreeState`.\n */\nexport function useMenuItem<T>(props: AriaMenuItemProps, state: TreeState<T>, ref: RefObject<FocusableElement | null>): MenuItemAria {\n let {\n id,\n key,\n closeOnSelect,\n isVirtualized,\n 'aria-haspopup': hasPopup,\n onPressStart: pressStartProp,\n onPressUp: pressUpProp,\n onPress,\n onPressChange,\n onPressEnd,\n onHoverStart: hoverStartProp,\n onHoverChange,\n onHoverEnd,\n onKeyDown,\n onKeyUp,\n onFocus,\n onFocusChange,\n onBlur,\n selectionManager = state.selectionManager\n } = props;\n\n let isTrigger = !!hasPopup;\n let isTriggerExpanded = isTrigger && props['aria-expanded'] === 'true';\n let isDisabled = props.isDisabled ?? selectionManager.isDisabled(key);\n let isSelected = props.isSelected ?? selectionManager.isSelected(key);\n let data = menuData.get(state)!;\n let item = state.collection.getItem(key);\n let onClose = props.onClose || data.onClose;\n let router = useRouter();\n let performAction = (e: PressEvent) => {\n if (isTrigger) {\n return;\n }\n\n if (item?.props?.onAction) {\n item.props.onAction();\n } else if (props.onAction) {\n props.onAction(key);\n }\n\n if (data.onAction) {\n // Must reassign to variable otherwise `this` binding gets messed up. Something to do with WeakMap.\n let onAction = data.onAction;\n onAction(key);\n }\n\n if (e.target instanceof HTMLAnchorElement && item) {\n router.open(e.target, e, item.props.href, item.props.routerOptions as RouterOptions);\n }\n };\n\n let role = 'menuitem';\n if (!isTrigger) {\n if (selectionManager.selectionMode === 'single') {\n role = 'menuitemradio';\n } else if (selectionManager.selectionMode === 'multiple') {\n role = 'menuitemcheckbox';\n }\n }\n\n let labelId = useSlotId();\n let descriptionId = useSlotId();\n let keyboardId = useSlotId();\n\n let ariaProps = {\n id,\n 'aria-disabled': isDisabled || undefined,\n role,\n 'aria-label': props['aria-label'],\n 'aria-labelledby': labelId,\n 'aria-describedby': [descriptionId, keyboardId].filter(Boolean).join(' ') || undefined,\n 'aria-controls': props['aria-controls'],\n 'aria-haspopup': hasPopup,\n 'aria-expanded': props['aria-expanded']\n };\n\n if (selectionManager.selectionMode !== 'none' && !isTrigger) {\n ariaProps['aria-checked'] = isSelected;\n }\n\n if (isVirtualized) {\n ariaProps['aria-posinset'] = item?.index;\n ariaProps['aria-setsize'] = getItemCount(state.collection);\n }\n\n let onPressStart = (e: PressEvent) => {\n if (e.pointerType === 'keyboard') {\n performAction(e);\n }\n\n pressStartProp?.(e);\n };\n\n let onPressUp = (e: PressEvent) => {\n if (e.pointerType !== 'keyboard') {\n performAction(e);\n\n // Pressing a menu item should close by default in single selection mode but not multiple\n // selection mode, except if overridden by the closeOnSelect prop.\n if (!isTrigger && onClose && (closeOnSelect ?? (selectionManager.selectionMode !== 'multiple' || selectionManager.isLink(key)))) {\n onClose();\n }\n }\n\n pressUpProp?.(e);\n };\n\n let {itemProps, isFocused} = useSelectableItem({\n selectionManager: selectionManager,\n key,\n ref,\n shouldSelectOnPressUp: true,\n allowsDifferentPressOrigin: true,\n // Disable all handling of links in useSelectable item\n // because we handle it ourselves. The behavior of menus\n // is slightly different from other collections because\n // actions are performed on key down rather than key up.\n linkBehavior: 'none'\n });\n\n let {pressProps, isPressed} = usePress({\n onPressStart,\n onPress,\n onPressUp,\n onPressChange,\n onPressEnd,\n isDisabled\n });\n let {hoverProps} = useHover({\n isDisabled,\n onHoverStart(e) {\n // Hovering over an already expanded sub dialog trigger should keep focus in the dialog.\n if (!isFocusVisible() && !(isTriggerExpanded && hasPopup === 'dialog')) {\n selectionManager.setFocused(true);\n selectionManager.setFocusedKey(key);\n }\n hoverStartProp?.(e);\n },\n onHoverChange,\n onHoverEnd\n });\n\n let {keyboardProps} = useKeyboard({\n onKeyDown: (e) => {\n // Ignore repeating events, which may have started on the menu trigger before moving\n // focus to the menu item. We want to wait for a second complete key press sequence.\n if (e.repeat) {\n e.continuePropagation();\n return;\n }\n\n switch (e.key) {\n case ' ':\n if (!isDisabled && selectionManager.selectionMode === 'none' && !isTrigger && closeOnSelect !== false && onClose) {\n onClose();\n }\n break;\n case 'Enter':\n // The Enter key should always close on select, except if overridden.\n if (!isDisabled && closeOnSelect !== false && !isTrigger && onClose) {\n onClose();\n }\n break;\n default:\n if (!isTrigger) {\n e.continuePropagation();\n }\n\n onKeyDown?.(e);\n break;\n }\n },\n onKeyUp\n });\n\n let {focusProps} = useFocus({onBlur, onFocus, onFocusChange});\n let domProps = filterDOMProps(item?.props);\n delete domProps.id;\n let linkProps = useLinkProps(item?.props);\n\n return {\n menuItemProps: {\n ...ariaProps,\n ...mergeProps(domProps, linkProps, isTrigger ? {onFocus: itemProps.onFocus, 'data-key': itemProps['data-key']} : itemProps, pressProps, hoverProps, keyboardProps, focusProps),\n // If a submenu is expanded, set the tabIndex to -1 so that shift tabbing goes out of the menu instead of the parent menu item.\n tabIndex: itemProps.tabIndex != null && isTriggerExpanded ? -1 : itemProps.tabIndex\n },\n labelProps: {\n id: labelId\n },\n descriptionProps: {\n id: descriptionId\n },\n keyboardShortcutProps: {\n id: keybo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AAkB,SAAS,CAAC,aAAa,SAC1D;oBAEF;gBACF;oBACE,IAAI,CAAC,WACH,EAAE,mBAAmB;oBAGvB,sBAAA,gCAAA,UAAY;oBACZ;YACJ;QACF;iBACA;IACF;IAEA,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,qCAAO,EAAE;gBAAC;iBAAQ;uBAAS;IAAa;IAC3D,IAAI,WAAW,CAAA,GAAA,oCAAa,EAAE,iBAAA,2BAAA,KAAM,KAAK;IACzC,OAAO,SAAS,EAAE;IAClB,IAAI,YAAY,CAAA,GAAA,kCAAW,EAAE,iBAAA,2BAAA,KAAM,KAAK;IAExC,OAAO;QACL,eAAe;YACb,GAAG,SAAS;YACZ,GAAG,CAAA,GAAA,gCAAS,EACV,UACA,WACA,YACI;gBAAC,SAAS,UAAU,OAAO;gBAAE,mBAAmB,SAAS,CAAC,kBAAkB;gBAAE,YAAY,SAAS,CAAC,WAAW;YAAA,IAC/G,WACJ,YACA,YACA,eACA,YACA,+GAA+G;YAC/G,KAAK,qBAAqB,IAAI,YAAY;gBAAC,aAAa,CAAA,IAAK,EAAE,cAAc;YAAE,IAAI,UACpF;YACD,+HAA+H;YAC/H,UAAU,UAAU,QAAQ,IAAI,QAAQ,qBAAqB,CAAC,KAAK,qBAAqB,GAAG,KAAK,UAAU,QAAQ;QACpH;QACA,YAAY;YACV,IAAI;QACN;QACA,kBAAkB;YAChB,IAAI;QACN;QACA,uBAAuB;YACrB,IAAI;QACN;mBACA;QACA,gBAAgB,aAAa,iBAAiB,SAAS,IAAI,CAAA,GAAA,2CAAa,OAAO,CAAC;oBAChF;mBACA;oBACA;IACF;AACF","sources":["packages/@react-aria/menu/src/useMenuItem.ts"],"sourcesContent":["/*\n * Copyright 2020 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\nimport {DOMAttributes, DOMProps, FocusableElement, FocusEvents, HoverEvents, Key, KeyboardEvents, PressEvent, PressEvents, RefObject, RouterOptions} from '@react-types/shared';\nimport {filterDOMProps, mergeProps, useLinkProps, useRouter, useSlotId} from '@react-aria/utils';\nimport {getItemCount} from '@react-stately/collections';\nimport {isFocusVisible, useFocus, useHover, useKeyboard, usePress} from '@react-aria/interactions';\nimport {menuData} from './utils';\nimport {SelectionManager} from '@react-stately/selection';\nimport {TreeState} from '@react-stately/tree';\nimport {useSelectableItem} from '@react-aria/selection';\n\nexport interface MenuItemAria {\n /** Props for the menu item element. */\n menuItemProps: DOMAttributes,\n\n /** Props for the main text element inside the menu item. */\n labelProps: DOMAttributes,\n\n /** Props for the description text element inside the menu item, if any. */\n descriptionProps: DOMAttributes,\n\n /** Props for the keyboard shortcut text element inside the item, if any. */\n keyboardShortcutProps: DOMAttributes,\n\n /** Whether the item is currently focused. */\n isFocused: boolean,\n /** Whether the item is keyboard focused. */\n isFocusVisible: boolean,\n /** Whether the item is currently selected. */\n isSelected: boolean,\n /** Whether the item is currently in a pressed state. */\n isPressed: boolean,\n /** Whether the item is disabled. */\n isDisabled: boolean\n}\n\nexport interface AriaMenuItemProps extends DOMProps, PressEvents, HoverEvents, KeyboardEvents, FocusEvents {\n /**\n * Whether the menu item is disabled.\n * @deprecated - pass disabledKeys to useTreeState instead.\n */\n isDisabled?: boolean,\n\n /**\n * Whether the menu item is selected.\n * @deprecated - pass selectedKeys to useTreeState instead.\n */\n isSelected?: boolean,\n\n /** A screen reader only label for the menu item. */\n 'aria-label'?: string,\n\n /** The unique key for the menu item. */\n key: Key,\n\n /**\n * Handler that is called when the menu should close after selecting an item.\n * @deprecated - pass to the menu instead.\n */\n onClose?: () => void,\n\n /**\n * Whether the menu should close when the menu item is selected.\n * @default true\n */\n closeOnSelect?: boolean,\n\n /** Whether the menu item is contained in a virtual scrolling menu. */\n isVirtualized?: boolean,\n\n /**\n * Handler that is called when the user activates the item.\n * @deprecated - pass to the menu instead.\n */\n onAction?: (key: Key) => void,\n\n /** What kind of popup the item opens. */\n 'aria-haspopup'?: 'menu' | 'dialog',\n\n /** Indicates whether the menu item's popup element is expanded or collapsed. */\n 'aria-expanded'?: boolean | 'true' | 'false',\n\n /** Identifies the menu item's popup element whose contents or presence is controlled by the menu item. */\n 'aria-controls'?: string,\n\n /** Override of the selection manager. By default, `state.selectionManager` is used. */\n selectionManager?: SelectionManager\n}\n\n/**\n * Provides the behavior and accessibility implementation for an item in a menu.\n * See `useMenu` for more details about menus.\n * @param props - Props for the item.\n * @param state - State for the menu, as returned by `useTreeState`.\n */\nexport function useMenuItem<T>(props: AriaMenuItemProps, state: TreeState<T>, ref: RefObject<FocusableElement | null>): MenuItemAria {\n let {\n id,\n key,\n closeOnSelect,\n isVirtualized,\n 'aria-haspopup': hasPopup,\n onPressStart: pressStartProp,\n onPressUp: pressUpProp,\n onPress: pressProp,\n onPressChange,\n onPressEnd,\n onHoverStart: hoverStartProp,\n onHoverChange,\n onHoverEnd,\n onKeyDown,\n onKeyUp,\n onFocus,\n onFocusChange,\n onBlur,\n selectionManager = state.selectionManager\n } = props;\n\n let isTrigger = !!hasPopup;\n let isTriggerExpanded = isTrigger && props['aria-expanded'] === 'true';\n let isDisabled = props.isDisabled ?? selectionManager.isDisabled(key);\n let isSelected = props.isSelected ?? selectionManager.isSelected(key);\n let data = menuData.get(state)!;\n let item = state.collection.getItem(key);\n let onClose = props.onClose || data.onClose;\n let router = useRouter();\n let performAction = (e: PressEvent) => {\n if (isTrigger) {\n return;\n }\n\n if (item?.props?.onAction) {\n item.props.onAction();\n } else if (props.onAction) {\n props.onAction(key);\n }\n\n if (data.onAction) {\n // Must reassign to variable otherwise `this` binding gets messed up. Something to do with WeakMap.\n let onAction = data.onAction;\n onAction(key);\n }\n\n if (e.target instanceof HTMLAnchorElement && item) {\n router.open(e.target, e, item.props.href, item.props.routerOptions as RouterOptions);\n }\n };\n\n let role = 'menuitem';\n if (!isTrigger) {\n if (selectionManager.selectionMode === 'single') {\n role = 'menuitemradio';\n } else if (selectionManager.selectionMode === 'multiple') {\n role = 'menuitemcheckbox';\n }\n }\n\n let labelId = useSlotId();\n let descriptionId = useSlotId();\n let keyboardId = useSlotId();\n\n let ariaProps = {\n id,\n 'aria-disabled': isDisabled || undefined,\n role,\n 'aria-label': props['aria-label'],\n 'aria-labelledby': labelId,\n 'aria-describedby': [descriptionId, keyboardId].filter(Boolean).join(' ') || undefined,\n 'aria-controls': props['aria-controls'],\n 'aria-haspopup': hasPopup,\n 'aria-expanded': props['aria-expanded']\n };\n\n if (selectionManager.selectionMode !== 'none' && !isTrigger) {\n ariaProps['aria-checked'] = isSelected;\n }\n\n if (isVirtualized) {\n ariaProps['aria-posinset'] = item?.index;\n ariaProps['aria-setsize'] = getItemCount(state.collection);\n }\n\n let onPressStart = (e: PressEvent) => {\n if (e.pointerType === 'keyboard') {\n performAction(e);\n }\n\n pressStartProp?.(e);\n };\n\n let maybeClose = () => {\n // Pressing a menu item should close by default in single selection mode but not multiple\n // selection mode, except if overridden by the closeOnSelect prop.\n if (!isTrigger && onClose && (closeOnSelect ?? (selectionManager.selectionMode !== 'multiple' || selectionManager.isLink(key)))) {\n onClose();\n }\n };\n\n let onPressUp = (e: PressEvent) => {\n // If interacting with mouse, allow the user to mouse down on the trigger button,\n // drag, and release over an item (matching native behavior).\n if (e.pointerType === 'mouse') {\n performAction(e);\n maybeClose();\n }\n\n pressUpProp?.(e);\n };\n\n let onPress = (e: PressEvent) => {\n if (e.pointerType !== 'keyboard' && e.pointerType !== 'mouse') {\n performAction(e);\n maybeClose();\n }\n\n pressProp?.(e);\n };\n\n let {itemProps, isFocused} = useSelectableItem({\n id,\n selectionManager: selectionManager,\n key,\n ref,\n shouldSelectOnPressUp: true,\n allowsDifferentPressOrigin: true,\n // Disable all handling of links in useSelectable item\n // because we handle it ourselves. The behavior of menus\n // is slightly different from other collections because\n // actions are performed on key down rather than key up.\n linkBehavior: 'none',\n shouldUseVirtualFocus: data.shouldUseVirtualFocus\n });\n\n let {pressProps, isPressed} = usePress({\n onPressStart,\n onPress,\n onPressUp,\n onPressChange,\n onPressEnd,\n isDisabled\n });\n let {hoverProps} = useHover({\n isDisabled,\n onHoverStart(e) {\n // Hovering over an already expanded sub dialog trigger should keep focus in the dialog.\n if (!isFocusVisible() && !(isTriggerExpanded && hasPopup)) {\n selectionManager.setFocused(true);\n selectionManager.setFocusedKey(key);\n }\n hoverStartProp?.(e);\n },\n onHoverChange,\n onHoverEnd\n });\n\n let {keyboardProps} = useKeyboard({\n onKeyDown: (e) => {\n // Ignore repeating events, which may have started on the menu trigger before moving\n // focus to the menu item. We want to wait for a second complete key press sequence.\n if (e.repeat) {\n e.continuePropagation();\n return;\n }\n\n switch (e.key) {\n case ' ':\n if (!isDisabled && selectionManager.selectionMode === 'none' && !isTrigger && closeOnSelect !== false && onClose) {\n onClose();\n }\n break;\n case 'Enter':\n // The Enter key should always close on select, except if overridden.\n if (!isDisabled && closeOnSelect !== false && !isTrigger && onClose) {\n onClose();\n }\n break;\n default:\n if (!isTrigger) {\n e.continuePropagation();\n }\n\n onKeyDown?.(e);\n break;\n }\n },\n onKeyUp\n });\n\n let {focusProps} = useFocus({onBlur, onFocus, onFocusChange});\n let domProps = filterDOMProps(item?.props);\n delete domProps.id;\n let linkProps = useLinkProps(item?.props);\n\n return {\n menuItemProps: {\n ...ariaProps,\n ...mergeProps(\n domProps,\n linkProps,\n isTrigger \n ? {onFocus: itemProps.onFocus, 'data-collection': itemProps['data-collection'], 'data-key': itemProps['data-key']} \n : itemProps,\n pressProps,\n hoverProps,\n keyboardProps,\n focusProps,\n // Prevent DOM focus from moving on mouse down when using virtual focus or this is a submenu/subdialog trigger.\n data.shouldUseVirtualFocus || isTrigger ? {onMouseDown: e => e.preventDefault()} : undefined\n ),\n // If a submenu is expanded, set the tabIndex to -1 so that shift tabbing goes out of the menu instead of the parent menu item.\n tabIndex: itemProps.tabIndex != null && isTriggerExpanded && !data.shouldUseVirtualFocus ? -1 : itemProps.tabIndex\n },\n labelProps: {\n id: labelId\n },\n descriptionProps: {\n id: descriptionId\n },\n keyboardShortcutProps: {\n id: keyboardId\n },\n isFocused,\n isFocusVisible: isFocused && selectionManager.isFocused && isFocusVisible() && !isTriggerExpanded,\n isSelected,\n isPressed,\n isDisabled\n };\n}\n"],"names":[],"version":3,"file":"useMenuItem.main.js.map"}
@@ -1,4 +1,4 @@
1
- import {menuData as $d5336fe17ce95402$export$6f49b4016bfc8d56} from "./useMenu.mjs";
1
+ import {menuData as $fc79756100351201$export$6f49b4016bfc8d56} from "./utils.mjs";
2
2
  import {useRouter as $7Kjv5$useRouter, useSlotId as $7Kjv5$useSlotId, filterDOMProps as $7Kjv5$filterDOMProps, useLinkProps as $7Kjv5$useLinkProps, mergeProps as $7Kjv5$mergeProps} from "@react-aria/utils";
3
3
  import {getItemCount as $7Kjv5$getItemCount} from "@react-stately/collections";
4
4
  import {usePress as $7Kjv5$usePress, useHover as $7Kjv5$useHover, isFocusVisible as $7Kjv5$isFocusVisible, useKeyboard as $7Kjv5$useKeyboard, useFocus as $7Kjv5$useFocus} from "@react-aria/interactions";
@@ -20,14 +20,14 @@ import {useSelectableItem as $7Kjv5$useSelectableItem} from "@react-aria/selecti
20
20
 
21
21
 
22
22
  function $a2e5df62f93c7633$export$9d32628fc2aea7da(props, state, ref) {
23
- let { id: id, key: key, closeOnSelect: closeOnSelect, isVirtualized: isVirtualized, 'aria-haspopup': hasPopup, onPressStart: pressStartProp, onPressUp: pressUpProp, onPress: onPress, onPressChange: onPressChange, onPressEnd: onPressEnd, onHoverStart: hoverStartProp, onHoverChange: onHoverChange, onHoverEnd: onHoverEnd, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onFocus: onFocus, onFocusChange: onFocusChange, onBlur: onBlur, selectionManager: selectionManager = state.selectionManager } = props;
23
+ let { id: id, key: key, closeOnSelect: closeOnSelect, isVirtualized: isVirtualized, 'aria-haspopup': hasPopup, onPressStart: pressStartProp, onPressUp: pressUpProp, onPress: pressProp, onPressChange: onPressChange, onPressEnd: onPressEnd, onHoverStart: hoverStartProp, onHoverChange: onHoverChange, onHoverEnd: onHoverEnd, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onFocus: onFocus, onFocusChange: onFocusChange, onBlur: onBlur, selectionManager: selectionManager = state.selectionManager } = props;
24
24
  let isTrigger = !!hasPopup;
25
25
  let isTriggerExpanded = isTrigger && props['aria-expanded'] === 'true';
26
26
  var _props_isDisabled;
27
27
  let isDisabled = (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : selectionManager.isDisabled(key);
28
28
  var _props_isSelected;
29
29
  let isSelected = (_props_isSelected = props.isSelected) !== null && _props_isSelected !== void 0 ? _props_isSelected : selectionManager.isSelected(key);
30
- let data = (0, $d5336fe17ce95402$export$6f49b4016bfc8d56).get(state);
30
+ let data = (0, $fc79756100351201$export$6f49b4016bfc8d56).get(state);
31
31
  let item = state.collection.getItem(key);
32
32
  let onClose = props.onClose || data.onClose;
33
33
  let router = (0, $7Kjv5$useRouter)();
@@ -74,16 +74,29 @@ function $a2e5df62f93c7633$export$9d32628fc2aea7da(props, state, ref) {
74
74
  if (e.pointerType === 'keyboard') performAction(e);
75
75
  pressStartProp === null || pressStartProp === void 0 ? void 0 : pressStartProp(e);
76
76
  };
77
+ let maybeClose = ()=>{
78
+ // Pressing a menu item should close by default in single selection mode but not multiple
79
+ // selection mode, except if overridden by the closeOnSelect prop.
80
+ if (!isTrigger && onClose && (closeOnSelect !== null && closeOnSelect !== void 0 ? closeOnSelect : selectionManager.selectionMode !== 'multiple' || selectionManager.isLink(key))) onClose();
81
+ };
77
82
  let onPressUp = (e)=>{
78
- if (e.pointerType !== 'keyboard') {
83
+ // If interacting with mouse, allow the user to mouse down on the trigger button,
84
+ // drag, and release over an item (matching native behavior).
85
+ if (e.pointerType === 'mouse') {
79
86
  performAction(e);
80
- // Pressing a menu item should close by default in single selection mode but not multiple
81
- // selection mode, except if overridden by the closeOnSelect prop.
82
- if (!isTrigger && onClose && (closeOnSelect !== null && closeOnSelect !== void 0 ? closeOnSelect : selectionManager.selectionMode !== 'multiple' || selectionManager.isLink(key))) onClose();
87
+ maybeClose();
83
88
  }
84
89
  pressUpProp === null || pressUpProp === void 0 ? void 0 : pressUpProp(e);
85
90
  };
91
+ let onPress = (e)=>{
92
+ if (e.pointerType !== 'keyboard' && e.pointerType !== 'mouse') {
93
+ performAction(e);
94
+ maybeClose();
95
+ }
96
+ pressProp === null || pressProp === void 0 ? void 0 : pressProp(e);
97
+ };
86
98
  let { itemProps: itemProps, isFocused: isFocused } = (0, $7Kjv5$useSelectableItem)({
99
+ id: id,
87
100
  selectionManager: selectionManager,
88
101
  key: key,
89
102
  ref: ref,
@@ -93,7 +106,8 @@ function $a2e5df62f93c7633$export$9d32628fc2aea7da(props, state, ref) {
93
106
  // because we handle it ourselves. The behavior of menus
94
107
  // is slightly different from other collections because
95
108
  // actions are performed on key down rather than key up.
96
- linkBehavior: 'none'
109
+ linkBehavior: 'none',
110
+ shouldUseVirtualFocus: data.shouldUseVirtualFocus
97
111
  });
98
112
  let { pressProps: pressProps, isPressed: isPressed } = (0, $7Kjv5$usePress)({
99
113
  onPressStart: onPressStart,
@@ -107,7 +121,7 @@ function $a2e5df62f93c7633$export$9d32628fc2aea7da(props, state, ref) {
107
121
  isDisabled: isDisabled,
108
122
  onHoverStart (e) {
109
123
  // Hovering over an already expanded sub dialog trigger should keep focus in the dialog.
110
- if (!(0, $7Kjv5$isFocusVisible)() && !(isTriggerExpanded && hasPopup === 'dialog')) {
124
+ if (!(0, $7Kjv5$isFocusVisible)() && !(isTriggerExpanded && hasPopup)) {
111
125
  selectionManager.setFocused(true);
112
126
  selectionManager.setFocusedKey(key);
113
127
  }
@@ -153,10 +167,14 @@ function $a2e5df62f93c7633$export$9d32628fc2aea7da(props, state, ref) {
153
167
  ...ariaProps,
154
168
  ...(0, $7Kjv5$mergeProps)(domProps, linkProps, isTrigger ? {
155
169
  onFocus: itemProps.onFocus,
170
+ 'data-collection': itemProps['data-collection'],
156
171
  'data-key': itemProps['data-key']
157
- } : itemProps, pressProps, hoverProps, keyboardProps, focusProps),
172
+ } : itemProps, pressProps, hoverProps, keyboardProps, focusProps, // Prevent DOM focus from moving on mouse down when using virtual focus or this is a submenu/subdialog trigger.
173
+ data.shouldUseVirtualFocus || isTrigger ? {
174
+ onMouseDown: (e)=>e.preventDefault()
175
+ } : undefined),
158
176
  // If a submenu is expanded, set the tabIndex to -1 so that shift tabbing goes out of the menu instead of the parent menu item.
159
- tabIndex: itemProps.tabIndex != null && isTriggerExpanded ? -1 : itemProps.tabIndex
177
+ tabIndex: itemProps.tabIndex != null && isTriggerExpanded && !data.shouldUseVirtualFocus ? -1 : itemProps.tabIndex
160
178
  },
161
179
  labelProps: {
162
180
  id: labelId
@@ -168,6 +186,7 @@ function $a2e5df62f93c7633$export$9d32628fc2aea7da(props, state, ref) {
168
186
  id: keyboardId
169
187
  },
170
188
  isFocused: isFocused,
189
+ isFocusVisible: isFocused && selectionManager.isFocused && (0, $7Kjv5$isFocusVisible)() && !isTriggerExpanded,
171
190
  isSelected: isSelected,
172
191
  isPressed: isPressed,
173
192
  isDisabled: isDisabled
@@ -1,4 +1,4 @@
1
- import {menuData as $d5336fe17ce95402$export$6f49b4016bfc8d56} from "./useMenu.module.js";
1
+ import {menuData as $fc79756100351201$export$6f49b4016bfc8d56} from "./utils.module.js";
2
2
  import {useRouter as $7Kjv5$useRouter, useSlotId as $7Kjv5$useSlotId, filterDOMProps as $7Kjv5$filterDOMProps, useLinkProps as $7Kjv5$useLinkProps, mergeProps as $7Kjv5$mergeProps} from "@react-aria/utils";
3
3
  import {getItemCount as $7Kjv5$getItemCount} from "@react-stately/collections";
4
4
  import {usePress as $7Kjv5$usePress, useHover as $7Kjv5$useHover, isFocusVisible as $7Kjv5$isFocusVisible, useKeyboard as $7Kjv5$useKeyboard, useFocus as $7Kjv5$useFocus} from "@react-aria/interactions";
@@ -20,14 +20,14 @@ import {useSelectableItem as $7Kjv5$useSelectableItem} from "@react-aria/selecti
20
20
 
21
21
 
22
22
  function $a2e5df62f93c7633$export$9d32628fc2aea7da(props, state, ref) {
23
- let { id: id, key: key, closeOnSelect: closeOnSelect, isVirtualized: isVirtualized, 'aria-haspopup': hasPopup, onPressStart: pressStartProp, onPressUp: pressUpProp, onPress: onPress, onPressChange: onPressChange, onPressEnd: onPressEnd, onHoverStart: hoverStartProp, onHoverChange: onHoverChange, onHoverEnd: onHoverEnd, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onFocus: onFocus, onFocusChange: onFocusChange, onBlur: onBlur, selectionManager: selectionManager = state.selectionManager } = props;
23
+ let { id: id, key: key, closeOnSelect: closeOnSelect, isVirtualized: isVirtualized, 'aria-haspopup': hasPopup, onPressStart: pressStartProp, onPressUp: pressUpProp, onPress: pressProp, onPressChange: onPressChange, onPressEnd: onPressEnd, onHoverStart: hoverStartProp, onHoverChange: onHoverChange, onHoverEnd: onHoverEnd, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onFocus: onFocus, onFocusChange: onFocusChange, onBlur: onBlur, selectionManager: selectionManager = state.selectionManager } = props;
24
24
  let isTrigger = !!hasPopup;
25
25
  let isTriggerExpanded = isTrigger && props['aria-expanded'] === 'true';
26
26
  var _props_isDisabled;
27
27
  let isDisabled = (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : selectionManager.isDisabled(key);
28
28
  var _props_isSelected;
29
29
  let isSelected = (_props_isSelected = props.isSelected) !== null && _props_isSelected !== void 0 ? _props_isSelected : selectionManager.isSelected(key);
30
- let data = (0, $d5336fe17ce95402$export$6f49b4016bfc8d56).get(state);
30
+ let data = (0, $fc79756100351201$export$6f49b4016bfc8d56).get(state);
31
31
  let item = state.collection.getItem(key);
32
32
  let onClose = props.onClose || data.onClose;
33
33
  let router = (0, $7Kjv5$useRouter)();
@@ -74,16 +74,29 @@ function $a2e5df62f93c7633$export$9d32628fc2aea7da(props, state, ref) {
74
74
  if (e.pointerType === 'keyboard') performAction(e);
75
75
  pressStartProp === null || pressStartProp === void 0 ? void 0 : pressStartProp(e);
76
76
  };
77
+ let maybeClose = ()=>{
78
+ // Pressing a menu item should close by default in single selection mode but not multiple
79
+ // selection mode, except if overridden by the closeOnSelect prop.
80
+ if (!isTrigger && onClose && (closeOnSelect !== null && closeOnSelect !== void 0 ? closeOnSelect : selectionManager.selectionMode !== 'multiple' || selectionManager.isLink(key))) onClose();
81
+ };
77
82
  let onPressUp = (e)=>{
78
- if (e.pointerType !== 'keyboard') {
83
+ // If interacting with mouse, allow the user to mouse down on the trigger button,
84
+ // drag, and release over an item (matching native behavior).
85
+ if (e.pointerType === 'mouse') {
79
86
  performAction(e);
80
- // Pressing a menu item should close by default in single selection mode but not multiple
81
- // selection mode, except if overridden by the closeOnSelect prop.
82
- if (!isTrigger && onClose && (closeOnSelect !== null && closeOnSelect !== void 0 ? closeOnSelect : selectionManager.selectionMode !== 'multiple' || selectionManager.isLink(key))) onClose();
87
+ maybeClose();
83
88
  }
84
89
  pressUpProp === null || pressUpProp === void 0 ? void 0 : pressUpProp(e);
85
90
  };
91
+ let onPress = (e)=>{
92
+ if (e.pointerType !== 'keyboard' && e.pointerType !== 'mouse') {
93
+ performAction(e);
94
+ maybeClose();
95
+ }
96
+ pressProp === null || pressProp === void 0 ? void 0 : pressProp(e);
97
+ };
86
98
  let { itemProps: itemProps, isFocused: isFocused } = (0, $7Kjv5$useSelectableItem)({
99
+ id: id,
87
100
  selectionManager: selectionManager,
88
101
  key: key,
89
102
  ref: ref,
@@ -93,7 +106,8 @@ function $a2e5df62f93c7633$export$9d32628fc2aea7da(props, state, ref) {
93
106
  // because we handle it ourselves. The behavior of menus
94
107
  // is slightly different from other collections because
95
108
  // actions are performed on key down rather than key up.
96
- linkBehavior: 'none'
109
+ linkBehavior: 'none',
110
+ shouldUseVirtualFocus: data.shouldUseVirtualFocus
97
111
  });
98
112
  let { pressProps: pressProps, isPressed: isPressed } = (0, $7Kjv5$usePress)({
99
113
  onPressStart: onPressStart,
@@ -107,7 +121,7 @@ function $a2e5df62f93c7633$export$9d32628fc2aea7da(props, state, ref) {
107
121
  isDisabled: isDisabled,
108
122
  onHoverStart (e) {
109
123
  // Hovering over an already expanded sub dialog trigger should keep focus in the dialog.
110
- if (!(0, $7Kjv5$isFocusVisible)() && !(isTriggerExpanded && hasPopup === 'dialog')) {
124
+ if (!(0, $7Kjv5$isFocusVisible)() && !(isTriggerExpanded && hasPopup)) {
111
125
  selectionManager.setFocused(true);
112
126
  selectionManager.setFocusedKey(key);
113
127
  }
@@ -153,10 +167,14 @@ function $a2e5df62f93c7633$export$9d32628fc2aea7da(props, state, ref) {
153
167
  ...ariaProps,
154
168
  ...(0, $7Kjv5$mergeProps)(domProps, linkProps, isTrigger ? {
155
169
  onFocus: itemProps.onFocus,
170
+ 'data-collection': itemProps['data-collection'],
156
171
  'data-key': itemProps['data-key']
157
- } : itemProps, pressProps, hoverProps, keyboardProps, focusProps),
172
+ } : itemProps, pressProps, hoverProps, keyboardProps, focusProps, // Prevent DOM focus from moving on mouse down when using virtual focus or this is a submenu/subdialog trigger.
173
+ data.shouldUseVirtualFocus || isTrigger ? {
174
+ onMouseDown: (e)=>e.preventDefault()
175
+ } : undefined),
158
176
  // If a submenu is expanded, set the tabIndex to -1 so that shift tabbing goes out of the menu instead of the parent menu item.
159
- tabIndex: itemProps.tabIndex != null && isTriggerExpanded ? -1 : itemProps.tabIndex
177
+ tabIndex: itemProps.tabIndex != null && isTriggerExpanded && !data.shouldUseVirtualFocus ? -1 : itemProps.tabIndex
160
178
  },
161
179
  labelProps: {
162
180
  id: labelId
@@ -168,6 +186,7 @@ function $a2e5df62f93c7633$export$9d32628fc2aea7da(props, state, ref) {
168
186
  id: keyboardId
169
187
  },
170
188
  isFocused: isFocused,
189
+ isFocusVisible: isFocused && selectionManager.isFocused && (0, $7Kjv5$isFocusVisible)() && !isTriggerExpanded,
171
190
  isSelected: isSelected,
172
191
  isPressed: isPressed,
173
192
  isDisabled: isDisabled