@react-aria/menu 3.13.2-nightly.4555 → 3.13.2-nightly.4560

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 (75) hide show
  1. package/dist/ar-AE.mjs +1 -1
  2. package/dist/bg-BG.mjs +1 -1
  3. package/dist/cs-CZ.mjs +1 -1
  4. package/dist/da-DK.mjs +1 -1
  5. package/dist/de-DE.mjs +1 -1
  6. package/dist/el-GR.mjs +1 -1
  7. package/dist/en-US.mjs +1 -1
  8. package/dist/es-ES.mjs +1 -1
  9. package/dist/et-EE.mjs +1 -1
  10. package/dist/fi-FI.mjs +1 -1
  11. package/dist/fr-FR.mjs +1 -1
  12. package/dist/he-IL.mjs +1 -1
  13. package/dist/hr-HR.mjs +1 -1
  14. package/dist/hu-HU.mjs +1 -1
  15. package/dist/import.mjs +5 -721
  16. package/dist/intlStrings.main.js +108 -0
  17. package/dist/intlStrings.main.js.map +1 -0
  18. package/dist/intlStrings.mjs +110 -0
  19. package/dist/intlStrings.module.js +110 -0
  20. package/dist/intlStrings.module.js.map +1 -0
  21. package/dist/it-IT.mjs +1 -1
  22. package/dist/ja-JP.mjs +1 -1
  23. package/dist/ko-KR.mjs +1 -1
  24. package/dist/lt-LT.mjs +1 -1
  25. package/dist/lv-LV.mjs +1 -1
  26. package/dist/main.js +10 -726
  27. package/dist/main.js.map +1 -1
  28. package/dist/module.js +5 -721
  29. package/dist/module.js.map +1 -1
  30. package/dist/nb-NO.mjs +1 -1
  31. package/dist/nl-NL.mjs +1 -1
  32. package/dist/pl-PL.mjs +1 -1
  33. package/dist/pt-BR.mjs +1 -1
  34. package/dist/pt-PT.mjs +1 -1
  35. package/dist/ro-RO.mjs +1 -1
  36. package/dist/ru-RU.mjs +1 -1
  37. package/dist/sk-SK.mjs +1 -1
  38. package/dist/sl-SI.mjs +1 -1
  39. package/dist/sr-SP.mjs +1 -1
  40. package/dist/sv-SE.mjs +1 -1
  41. package/dist/tr-TR.mjs +1 -1
  42. package/dist/uk-UA.mjs +1 -1
  43. package/dist/useMenu.main.js +59 -0
  44. package/dist/useMenu.main.js.map +1 -0
  45. package/dist/useMenu.mjs +53 -0
  46. package/dist/useMenu.module.js +53 -0
  47. package/dist/useMenu.module.js.map +1 -0
  48. package/dist/useMenuItem.main.js +175 -0
  49. package/dist/useMenuItem.main.js.map +1 -0
  50. package/dist/useMenuItem.mjs +170 -0
  51. package/dist/useMenuItem.module.js +170 -0
  52. package/dist/useMenuItem.module.js.map +1 -0
  53. package/dist/useMenuSection.main.js +43 -0
  54. package/dist/useMenuSection.main.js.map +1 -0
  55. package/dist/useMenuSection.mjs +38 -0
  56. package/dist/useMenuSection.module.js +38 -0
  57. package/dist/useMenuSection.module.js.map +1 -0
  58. package/dist/useMenuTrigger.main.js +103 -0
  59. package/dist/useMenuTrigger.main.js.map +1 -0
  60. package/dist/useMenuTrigger.mjs +98 -0
  61. package/dist/useMenuTrigger.module.js +98 -0
  62. package/dist/useMenuTrigger.module.js.map +1 -0
  63. package/dist/useSafelyMouseToSubmenu.main.js +134 -0
  64. package/dist/useSafelyMouseToSubmenu.main.js.map +1 -0
  65. package/dist/useSafelyMouseToSubmenu.mjs +129 -0
  66. package/dist/useSafelyMouseToSubmenu.module.js +129 -0
  67. package/dist/useSafelyMouseToSubmenu.module.js.map +1 -0
  68. package/dist/useSubmenuTrigger.main.js +169 -0
  69. package/dist/useSubmenuTrigger.main.js.map +1 -0
  70. package/dist/useSubmenuTrigger.mjs +164 -0
  71. package/dist/useSubmenuTrigger.module.js +164 -0
  72. package/dist/useSubmenuTrigger.module.js.map +1 -0
  73. package/dist/zh-CN.mjs +1 -1
  74. package/dist/zh-TW.mjs +1 -1
  75. package/package.json +14 -14
@@ -0,0 +1,170 @@
1
+ import {menuData as $d5336fe17ce95402$export$6f49b4016bfc8d56} from "./useMenu.mjs";
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
+ import {getItemCount as $7Kjv5$getItemCount} from "@react-stately/collections";
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";
5
+ import {useSelectableItem as $7Kjv5$useSelectableItem} from "@react-aria/selection";
6
+
7
+ /*
8
+ * Copyright 2020 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */
18
+
19
+
20
+
21
+
22
+ function $a2e5df62f93c7633$export$9d32628fc2aea7da(props, state, ref) {
23
+ let { 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 } = props;
24
+ let isTrigger = !!hasPopup;
25
+ var _props_isDisabled;
26
+ let isDisabled = (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : state.selectionManager.isDisabled(key);
27
+ var _props_isSelected;
28
+ let isSelected = (_props_isSelected = props.isSelected) !== null && _props_isSelected !== void 0 ? _props_isSelected : state.selectionManager.isSelected(key);
29
+ let data = (0, $d5336fe17ce95402$export$6f49b4016bfc8d56).get(state);
30
+ let item = state.collection.getItem(key);
31
+ let onClose = props.onClose || data.onClose;
32
+ let router = (0, $7Kjv5$useRouter)();
33
+ let performAction = (e)=>{
34
+ var _item_props;
35
+ if (isTrigger) return;
36
+ if (item === null || item === void 0 ? void 0 : (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.onAction) item.props.onAction();
37
+ if (props.onAction) props.onAction(key);
38
+ else if (data.onAction) data.onAction(key);
39
+ if (e.target instanceof HTMLAnchorElement) router.open(e.target, e, item.props.href, item.props.routerOptions);
40
+ };
41
+ let role = "menuitem";
42
+ if (!isTrigger) {
43
+ if (state.selectionManager.selectionMode === "single") role = "menuitemradio";
44
+ else if (state.selectionManager.selectionMode === "multiple") role = "menuitemcheckbox";
45
+ }
46
+ let labelId = (0, $7Kjv5$useSlotId)();
47
+ let descriptionId = (0, $7Kjv5$useSlotId)();
48
+ let keyboardId = (0, $7Kjv5$useSlotId)();
49
+ let ariaProps = {
50
+ "aria-disabled": isDisabled || undefined,
51
+ role: role,
52
+ "aria-label": props["aria-label"],
53
+ "aria-labelledby": labelId,
54
+ "aria-describedby": [
55
+ descriptionId,
56
+ keyboardId
57
+ ].filter(Boolean).join(" ") || undefined,
58
+ "aria-controls": props["aria-controls"],
59
+ "aria-haspopup": hasPopup,
60
+ "aria-expanded": props["aria-expanded"]
61
+ };
62
+ if (state.selectionManager.selectionMode !== "none" && !isTrigger) ariaProps["aria-checked"] = isSelected;
63
+ if (isVirtualized) {
64
+ ariaProps["aria-posinset"] = item === null || item === void 0 ? void 0 : item.index;
65
+ ariaProps["aria-setsize"] = (0, $7Kjv5$getItemCount)(state.collection);
66
+ }
67
+ let onPressStart = (e)=>{
68
+ if (e.pointerType === "keyboard") performAction(e);
69
+ pressStartProp === null || pressStartProp === void 0 ? void 0 : pressStartProp(e);
70
+ };
71
+ let onPressUp = (e)=>{
72
+ if (e.pointerType !== "keyboard") {
73
+ performAction(e);
74
+ // Pressing a menu item should close by default in single selection mode but not multiple
75
+ // selection mode, except if overridden by the closeOnSelect prop.
76
+ if (!isTrigger && onClose && (closeOnSelect !== null && closeOnSelect !== void 0 ? closeOnSelect : state.selectionManager.selectionMode !== "multiple" || state.selectionManager.isLink(key))) onClose();
77
+ }
78
+ pressUpProp === null || pressUpProp === void 0 ? void 0 : pressUpProp(e);
79
+ };
80
+ let { itemProps: itemProps, isFocused: isFocused } = (0, $7Kjv5$useSelectableItem)({
81
+ selectionManager: state.selectionManager,
82
+ key: key,
83
+ ref: ref,
84
+ shouldSelectOnPressUp: true,
85
+ allowsDifferentPressOrigin: true,
86
+ // Disable all handling of links in useSelectable item
87
+ // because we handle it ourselves. The behavior of menus
88
+ // is slightly different from other collections because
89
+ // actions are performed on key down rather than key up.
90
+ linkBehavior: "none"
91
+ });
92
+ let { pressProps: pressProps, isPressed: isPressed } = (0, $7Kjv5$usePress)({
93
+ onPressStart: onPressStart,
94
+ onPress: onPress,
95
+ onPressUp: onPressUp,
96
+ onPressChange: onPressChange,
97
+ onPressEnd: onPressEnd,
98
+ isDisabled: isDisabled
99
+ });
100
+ let { hoverProps: hoverProps } = (0, $7Kjv5$useHover)({
101
+ isDisabled: isDisabled,
102
+ onHoverStart (e) {
103
+ if (!(0, $7Kjv5$isFocusVisible)()) {
104
+ state.selectionManager.setFocused(true);
105
+ state.selectionManager.setFocusedKey(key);
106
+ }
107
+ hoverStartProp === null || hoverStartProp === void 0 ? void 0 : hoverStartProp(e);
108
+ },
109
+ onHoverChange: onHoverChange,
110
+ onHoverEnd: onHoverEnd
111
+ });
112
+ let { keyboardProps: keyboardProps } = (0, $7Kjv5$useKeyboard)({
113
+ onKeyDown: (e)=>{
114
+ // Ignore repeating events, which may have started on the menu trigger before moving
115
+ // focus to the menu item. We want to wait for a second complete key press sequence.
116
+ if (e.repeat) {
117
+ e.continuePropagation();
118
+ return;
119
+ }
120
+ switch(e.key){
121
+ case " ":
122
+ if (!isDisabled && state.selectionManager.selectionMode === "none" && !isTrigger && closeOnSelect !== false && onClose) onClose();
123
+ break;
124
+ case "Enter":
125
+ // The Enter key should always close on select, except if overridden.
126
+ if (!isDisabled && closeOnSelect !== false && !isTrigger && onClose) onClose();
127
+ break;
128
+ default:
129
+ if (!isTrigger) e.continuePropagation();
130
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
131
+ break;
132
+ }
133
+ },
134
+ onKeyUp: onKeyUp
135
+ });
136
+ let { focusProps: focusProps } = (0, $7Kjv5$useFocus)({
137
+ onBlur: onBlur,
138
+ onFocus: onFocus,
139
+ onFocusChange: onFocusChange
140
+ });
141
+ let domProps = (0, $7Kjv5$filterDOMProps)(item.props);
142
+ delete domProps.id;
143
+ let linkProps = (0, $7Kjv5$useLinkProps)(item.props);
144
+ return {
145
+ menuItemProps: {
146
+ ...ariaProps,
147
+ ...(0, $7Kjv5$mergeProps)(domProps, linkProps, isTrigger ? {
148
+ onFocus: itemProps.onFocus
149
+ } : itemProps, pressProps, hoverProps, keyboardProps, focusProps),
150
+ tabIndex: itemProps.tabIndex != null ? -1 : undefined
151
+ },
152
+ labelProps: {
153
+ id: labelId
154
+ },
155
+ descriptionProps: {
156
+ id: descriptionId
157
+ },
158
+ keyboardShortcutProps: {
159
+ id: keyboardId
160
+ },
161
+ isFocused: isFocused,
162
+ isSelected: isSelected,
163
+ isPressed: isPressed,
164
+ isDisabled: isDisabled
165
+ };
166
+ }
167
+
168
+
169
+ export {$a2e5df62f93c7633$export$9d32628fc2aea7da as useMenuItem};
170
+ //# sourceMappingURL=useMenuItem.mjs.map
@@ -0,0 +1,170 @@
1
+ import {menuData as $d5336fe17ce95402$export$6f49b4016bfc8d56} from "./useMenu.module.js";
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
+ import {getItemCount as $7Kjv5$getItemCount} from "@react-stately/collections";
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";
5
+ import {useSelectableItem as $7Kjv5$useSelectableItem} from "@react-aria/selection";
6
+
7
+ /*
8
+ * Copyright 2020 Adobe. All rights reserved.
9
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
10
+ * you may not use this file except in compliance with the License. You may obtain a copy
11
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software distributed under
14
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
15
+ * OF ANY KIND, either express or implied. See the License for the specific language
16
+ * governing permissions and limitations under the License.
17
+ */
18
+
19
+
20
+
21
+
22
+ function $a2e5df62f93c7633$export$9d32628fc2aea7da(props, state, ref) {
23
+ let { 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 } = props;
24
+ let isTrigger = !!hasPopup;
25
+ var _props_isDisabled;
26
+ let isDisabled = (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : state.selectionManager.isDisabled(key);
27
+ var _props_isSelected;
28
+ let isSelected = (_props_isSelected = props.isSelected) !== null && _props_isSelected !== void 0 ? _props_isSelected : state.selectionManager.isSelected(key);
29
+ let data = (0, $d5336fe17ce95402$export$6f49b4016bfc8d56).get(state);
30
+ let item = state.collection.getItem(key);
31
+ let onClose = props.onClose || data.onClose;
32
+ let router = (0, $7Kjv5$useRouter)();
33
+ let performAction = (e)=>{
34
+ var _item_props;
35
+ if (isTrigger) return;
36
+ if (item === null || item === void 0 ? void 0 : (_item_props = item.props) === null || _item_props === void 0 ? void 0 : _item_props.onAction) item.props.onAction();
37
+ if (props.onAction) props.onAction(key);
38
+ else if (data.onAction) data.onAction(key);
39
+ if (e.target instanceof HTMLAnchorElement) router.open(e.target, e, item.props.href, item.props.routerOptions);
40
+ };
41
+ let role = "menuitem";
42
+ if (!isTrigger) {
43
+ if (state.selectionManager.selectionMode === "single") role = "menuitemradio";
44
+ else if (state.selectionManager.selectionMode === "multiple") role = "menuitemcheckbox";
45
+ }
46
+ let labelId = (0, $7Kjv5$useSlotId)();
47
+ let descriptionId = (0, $7Kjv5$useSlotId)();
48
+ let keyboardId = (0, $7Kjv5$useSlotId)();
49
+ let ariaProps = {
50
+ "aria-disabled": isDisabled || undefined,
51
+ role: role,
52
+ "aria-label": props["aria-label"],
53
+ "aria-labelledby": labelId,
54
+ "aria-describedby": [
55
+ descriptionId,
56
+ keyboardId
57
+ ].filter(Boolean).join(" ") || undefined,
58
+ "aria-controls": props["aria-controls"],
59
+ "aria-haspopup": hasPopup,
60
+ "aria-expanded": props["aria-expanded"]
61
+ };
62
+ if (state.selectionManager.selectionMode !== "none" && !isTrigger) ariaProps["aria-checked"] = isSelected;
63
+ if (isVirtualized) {
64
+ ariaProps["aria-posinset"] = item === null || item === void 0 ? void 0 : item.index;
65
+ ariaProps["aria-setsize"] = (0, $7Kjv5$getItemCount)(state.collection);
66
+ }
67
+ let onPressStart = (e)=>{
68
+ if (e.pointerType === "keyboard") performAction(e);
69
+ pressStartProp === null || pressStartProp === void 0 ? void 0 : pressStartProp(e);
70
+ };
71
+ let onPressUp = (e)=>{
72
+ if (e.pointerType !== "keyboard") {
73
+ performAction(e);
74
+ // Pressing a menu item should close by default in single selection mode but not multiple
75
+ // selection mode, except if overridden by the closeOnSelect prop.
76
+ if (!isTrigger && onClose && (closeOnSelect !== null && closeOnSelect !== void 0 ? closeOnSelect : state.selectionManager.selectionMode !== "multiple" || state.selectionManager.isLink(key))) onClose();
77
+ }
78
+ pressUpProp === null || pressUpProp === void 0 ? void 0 : pressUpProp(e);
79
+ };
80
+ let { itemProps: itemProps, isFocused: isFocused } = (0, $7Kjv5$useSelectableItem)({
81
+ selectionManager: state.selectionManager,
82
+ key: key,
83
+ ref: ref,
84
+ shouldSelectOnPressUp: true,
85
+ allowsDifferentPressOrigin: true,
86
+ // Disable all handling of links in useSelectable item
87
+ // because we handle it ourselves. The behavior of menus
88
+ // is slightly different from other collections because
89
+ // actions are performed on key down rather than key up.
90
+ linkBehavior: "none"
91
+ });
92
+ let { pressProps: pressProps, isPressed: isPressed } = (0, $7Kjv5$usePress)({
93
+ onPressStart: onPressStart,
94
+ onPress: onPress,
95
+ onPressUp: onPressUp,
96
+ onPressChange: onPressChange,
97
+ onPressEnd: onPressEnd,
98
+ isDisabled: isDisabled
99
+ });
100
+ let { hoverProps: hoverProps } = (0, $7Kjv5$useHover)({
101
+ isDisabled: isDisabled,
102
+ onHoverStart (e) {
103
+ if (!(0, $7Kjv5$isFocusVisible)()) {
104
+ state.selectionManager.setFocused(true);
105
+ state.selectionManager.setFocusedKey(key);
106
+ }
107
+ hoverStartProp === null || hoverStartProp === void 0 ? void 0 : hoverStartProp(e);
108
+ },
109
+ onHoverChange: onHoverChange,
110
+ onHoverEnd: onHoverEnd
111
+ });
112
+ let { keyboardProps: keyboardProps } = (0, $7Kjv5$useKeyboard)({
113
+ onKeyDown: (e)=>{
114
+ // Ignore repeating events, which may have started on the menu trigger before moving
115
+ // focus to the menu item. We want to wait for a second complete key press sequence.
116
+ if (e.repeat) {
117
+ e.continuePropagation();
118
+ return;
119
+ }
120
+ switch(e.key){
121
+ case " ":
122
+ if (!isDisabled && state.selectionManager.selectionMode === "none" && !isTrigger && closeOnSelect !== false && onClose) onClose();
123
+ break;
124
+ case "Enter":
125
+ // The Enter key should always close on select, except if overridden.
126
+ if (!isDisabled && closeOnSelect !== false && !isTrigger && onClose) onClose();
127
+ break;
128
+ default:
129
+ if (!isTrigger) e.continuePropagation();
130
+ onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
131
+ break;
132
+ }
133
+ },
134
+ onKeyUp: onKeyUp
135
+ });
136
+ let { focusProps: focusProps } = (0, $7Kjv5$useFocus)({
137
+ onBlur: onBlur,
138
+ onFocus: onFocus,
139
+ onFocusChange: onFocusChange
140
+ });
141
+ let domProps = (0, $7Kjv5$filterDOMProps)(item.props);
142
+ delete domProps.id;
143
+ let linkProps = (0, $7Kjv5$useLinkProps)(item.props);
144
+ return {
145
+ menuItemProps: {
146
+ ...ariaProps,
147
+ ...(0, $7Kjv5$mergeProps)(domProps, linkProps, isTrigger ? {
148
+ onFocus: itemProps.onFocus
149
+ } : itemProps, pressProps, hoverProps, keyboardProps, focusProps),
150
+ tabIndex: itemProps.tabIndex != null ? -1 : undefined
151
+ },
152
+ labelProps: {
153
+ id: labelId
154
+ },
155
+ descriptionProps: {
156
+ id: descriptionId
157
+ },
158
+ keyboardShortcutProps: {
159
+ id: keyboardId
160
+ },
161
+ isFocused: isFocused,
162
+ isSelected: isSelected,
163
+ isPressed: isPressed,
164
+ isDisabled: isDisabled
165
+ };
166
+ }
167
+
168
+
169
+ export {$a2e5df62f93c7633$export$9d32628fc2aea7da as useMenuItem};
170
+ //# sourceMappingURL=useMenuItem.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA0FM,SAAS,0CAAe,KAAwB,EAAE,KAAmB,EAAE,GAAgC;IAC5G,IAAI,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,EACP,GAAG;IAEJ,IAAI,YAAY,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. 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, 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 {RefObject} from 'react';\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\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>): MenuItemAria {\n let {\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 } = props;\n\n let isTrigger = !!hasPopup;\n let isDisabled = props.isDisabled ?? state.selectionManager.isDisabled(key);\n let isSelected = props.isSelected ?? state.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 }\n\n if (props.onAction) {\n props.onAction(key);\n } else if (data.onAction) {\n data.onAction(key);\n }\n\n if (e.target instanceof HTMLAnchorElement) {\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 (state.selectionManager.selectionMode === 'single') {\n role = 'menuitemradio';\n } else if (state.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 '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 (state.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 ?? (state.selectionManager.selectionMode !== 'multiple' || state.selectionManager.isLink(key)))) {\n onClose();\n }\n }\n\n pressUpProp?.(e);\n };\n\n let {itemProps, isFocused} = useSelectableItem({\n selectionManager: state.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 if (!isFocusVisible()) {\n state.selectionManager.setFocused(true);\n state.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 && state.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} : itemProps, pressProps, hoverProps, keyboardProps, focusProps),\n tabIndex: itemProps.tabIndex != null ? -1 : undefined\n },\n labelProps: {\n id: labelId\n },\n descriptionProps: {\n id: descriptionId\n },\n keyboardShortcutProps: {\n id: keyboardId\n },\n isFocused,\n isSelected,\n isPressed,\n isDisabled\n };\n}\n"],"names":[],"version":3,"file":"useMenuItem.module.js.map"}
@@ -0,0 +1,43 @@
1
+ var $c1jOQ$reactariautils = require("@react-aria/utils");
2
+
3
+
4
+ function $parcel$export(e, n, v, s) {
5
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
+ }
7
+
8
+ $parcel$export(module.exports, "useMenuSection", () => $63008655e23408c5$export$73f7a44322579622);
9
+ /*
10
+ * Copyright 2020 Adobe. All rights reserved.
11
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
+ * you may not use this file except in compliance with the License. You may obtain a copy
13
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
+ *
15
+ * Unless required by applicable law or agreed to in writing, software distributed under
16
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
+ * OF ANY KIND, either express or implied. See the License for the specific language
18
+ * governing permissions and limitations under the License.
19
+ */
20
+ function $63008655e23408c5$export$73f7a44322579622(props) {
21
+ let { heading: heading, "aria-label": ariaLabel } = props;
22
+ let headingId = (0, $c1jOQ$reactariautils.useId)();
23
+ return {
24
+ itemProps: {
25
+ role: "presentation"
26
+ },
27
+ headingProps: heading ? {
28
+ // Techincally, menus cannot contain headings according to ARIA.
29
+ // We hide the heading from assistive technology, using role="presentation",
30
+ // and only use it as a label for the nested group.
31
+ id: headingId,
32
+ role: "presentation"
33
+ } : {},
34
+ groupProps: {
35
+ role: "group",
36
+ "aria-label": ariaLabel,
37
+ "aria-labelledby": heading ? headingId : undefined
38
+ }
39
+ };
40
+ }
41
+
42
+
43
+ //# sourceMappingURL=useMenuSection.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AA6BM,SAAS,0CAAe,KAA2B;IACxD,IAAI,WAAC,OAAO,EAAE,cAAc,SAAS,EAAC,GAAG;IACzC,IAAI,YAAY,CAAA,GAAA,2BAAI;IAEpB,OAAO;QACL,WAAW;YACT,MAAM;QACR;QACA,cAAc,UAAU;YACtB,gEAAgE;YAChE,4EAA4E;YAC5E,mDAAmD;YACnD,IAAI;YACJ,MAAM;QACR,IAAI,CAAC;QACL,YAAY;YACV,MAAM;YACN,cAAc;YACd,mBAAmB,UAAU,YAAY;QAC3C;IACF;AACF","sources":["packages/@react-aria/menu/src/useMenuSection.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} from '@react-types/shared';\nimport {ReactNode} from 'react';\nimport {useId} from '@react-aria/utils';\n\nexport interface AriaMenuSectionProps {\n /** The heading for the section. */\n heading?: ReactNode,\n /** An accessibility label for the section. Required if `heading` is not present. */\n 'aria-label'?: string\n}\n\nexport interface MenuSectionAria {\n /** Props for the wrapper list item. */\n itemProps: DOMAttributes,\n\n /** Props for the heading element, if any. */\n headingProps: DOMAttributes,\n\n /** Props for the group element. */\n groupProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a section in a menu.\n * See `useMenu` for more details about menus.\n * @param props - Props for the section.\n */\nexport function useMenuSection(props: AriaMenuSectionProps): MenuSectionAria {\n let {heading, 'aria-label': ariaLabel} = props;\n let headingId = useId();\n\n return {\n itemProps: {\n role: 'presentation'\n },\n headingProps: heading ? {\n // Techincally, menus cannot contain headings according to ARIA.\n // We hide the heading from assistive technology, using role=\"presentation\",\n // and only use it as a label for the nested group.\n id: headingId,\n role: 'presentation'\n } : {},\n groupProps: {\n role: 'group',\n 'aria-label': ariaLabel,\n 'aria-labelledby': heading ? headingId : undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"useMenuSection.main.js.map"}
@@ -0,0 +1,38 @@
1
+ import {useId as $7Mibs$useId} from "@react-aria/utils";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+ function $3e5eb2498db5b506$export$73f7a44322579622(props) {
15
+ let { heading: heading, "aria-label": ariaLabel } = props;
16
+ let headingId = (0, $7Mibs$useId)();
17
+ return {
18
+ itemProps: {
19
+ role: "presentation"
20
+ },
21
+ headingProps: heading ? {
22
+ // Techincally, menus cannot contain headings according to ARIA.
23
+ // We hide the heading from assistive technology, using role="presentation",
24
+ // and only use it as a label for the nested group.
25
+ id: headingId,
26
+ role: "presentation"
27
+ } : {},
28
+ groupProps: {
29
+ role: "group",
30
+ "aria-label": ariaLabel,
31
+ "aria-labelledby": heading ? headingId : undefined
32
+ }
33
+ };
34
+ }
35
+
36
+
37
+ export {$3e5eb2498db5b506$export$73f7a44322579622 as useMenuSection};
38
+ //# sourceMappingURL=useMenuSection.mjs.map
@@ -0,0 +1,38 @@
1
+ import {useId as $7Mibs$useId} from "@react-aria/utils";
2
+
3
+ /*
4
+ * Copyright 2020 Adobe. All rights reserved.
5
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License. You may obtain a copy
7
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software distributed under
10
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
+ * OF ANY KIND, either express or implied. See the License for the specific language
12
+ * governing permissions and limitations under the License.
13
+ */
14
+ function $3e5eb2498db5b506$export$73f7a44322579622(props) {
15
+ let { heading: heading, "aria-label": ariaLabel } = props;
16
+ let headingId = (0, $7Mibs$useId)();
17
+ return {
18
+ itemProps: {
19
+ role: "presentation"
20
+ },
21
+ headingProps: heading ? {
22
+ // Techincally, menus cannot contain headings according to ARIA.
23
+ // We hide the heading from assistive technology, using role="presentation",
24
+ // and only use it as a label for the nested group.
25
+ id: headingId,
26
+ role: "presentation"
27
+ } : {},
28
+ groupProps: {
29
+ role: "group",
30
+ "aria-label": ariaLabel,
31
+ "aria-labelledby": heading ? headingId : undefined
32
+ }
33
+ };
34
+ }
35
+
36
+
37
+ export {$3e5eb2498db5b506$export$73f7a44322579622 as useMenuSection};
38
+ //# sourceMappingURL=useMenuSection.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AA6BM,SAAS,0CAAe,KAA2B;IACxD,IAAI,WAAC,OAAO,EAAE,cAAc,SAAS,EAAC,GAAG;IACzC,IAAI,YAAY,CAAA,GAAA,YAAI;IAEpB,OAAO;QACL,WAAW;YACT,MAAM;QACR;QACA,cAAc,UAAU;YACtB,gEAAgE;YAChE,4EAA4E;YAC5E,mDAAmD;YACnD,IAAI;YACJ,MAAM;QACR,IAAI,CAAC;QACL,YAAY;YACV,MAAM;YACN,cAAc;YACd,mBAAmB,UAAU,YAAY;QAC3C;IACF;AACF","sources":["packages/@react-aria/menu/src/useMenuSection.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} from '@react-types/shared';\nimport {ReactNode} from 'react';\nimport {useId} from '@react-aria/utils';\n\nexport interface AriaMenuSectionProps {\n /** The heading for the section. */\n heading?: ReactNode,\n /** An accessibility label for the section. Required if `heading` is not present. */\n 'aria-label'?: string\n}\n\nexport interface MenuSectionAria {\n /** Props for the wrapper list item. */\n itemProps: DOMAttributes,\n\n /** Props for the heading element, if any. */\n headingProps: DOMAttributes,\n\n /** Props for the group element. */\n groupProps: DOMAttributes\n}\n\n/**\n * Provides the behavior and accessibility implementation for a section in a menu.\n * See `useMenu` for more details about menus.\n * @param props - Props for the section.\n */\nexport function useMenuSection(props: AriaMenuSectionProps): MenuSectionAria {\n let {heading, 'aria-label': ariaLabel} = props;\n let headingId = useId();\n\n return {\n itemProps: {\n role: 'presentation'\n },\n headingProps: heading ? {\n // Techincally, menus cannot contain headings according to ARIA.\n // We hide the heading from assistive technology, using role=\"presentation\",\n // and only use it as a label for the nested group.\n id: headingId,\n role: 'presentation'\n } : {},\n groupProps: {\n role: 'group',\n 'aria-label': ariaLabel,\n 'aria-labelledby': heading ? headingId : undefined\n }\n };\n}\n"],"names":[],"version":3,"file":"useMenuSection.module.js.map"}
@@ -0,0 +1,103 @@
1
+ var $d1742ec2644a0949$exports = require("./intlStrings.main.js");
2
+ var $jo7gW$reactariautils = require("@react-aria/utils");
3
+ var $jo7gW$reactariai18n = require("@react-aria/i18n");
4
+ var $jo7gW$reactariainteractions = require("@react-aria/interactions");
5
+ var $jo7gW$reactariaoverlays = require("@react-aria/overlays");
6
+
7
+
8
+ function $parcel$interopDefault(a) {
9
+ return a && a.__esModule ? a.default : a;
10
+ }
11
+
12
+ function $parcel$export(e, n, v, s) {
13
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
14
+ }
15
+
16
+ $parcel$export(module.exports, "useMenuTrigger", () => $7211ab9328763fb9$export$dc9c12ed27dd1b49);
17
+ /*
18
+ * Copyright 2020 Adobe. All rights reserved.
19
+ * This file is licensed to you under the Apache License, Version 2.0 (the "License");
20
+ * you may not use this file except in compliance with the License. You may obtain a copy
21
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing, software distributed under
24
+ * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
25
+ * OF ANY KIND, either express or implied. See the License for the specific language
26
+ * governing permissions and limitations under the License.
27
+ */
28
+
29
+
30
+
31
+
32
+ function $7211ab9328763fb9$export$dc9c12ed27dd1b49(props, state, ref) {
33
+ let { type: type = "menu", isDisabled: isDisabled, trigger: trigger = "press" } = props;
34
+ let menuTriggerId = (0, $jo7gW$reactariautils.useId)();
35
+ let { triggerProps: triggerProps, overlayProps: overlayProps } = (0, $jo7gW$reactariaoverlays.useOverlayTrigger)({
36
+ type: type
37
+ }, state, ref);
38
+ let onKeyDown = (e)=>{
39
+ if (isDisabled) return;
40
+ if (trigger === "longPress" && !e.altKey) return;
41
+ if (ref && ref.current) switch(e.key){
42
+ case "Enter":
43
+ case " ":
44
+ if (trigger === "longPress") return;
45
+ // fallthrough
46
+ case "ArrowDown":
47
+ // Stop propagation, unless it would already be handled by useKeyboard.
48
+ if (!("continuePropagation" in e)) e.stopPropagation();
49
+ e.preventDefault();
50
+ state.toggle("first");
51
+ break;
52
+ case "ArrowUp":
53
+ if (!("continuePropagation" in e)) e.stopPropagation();
54
+ e.preventDefault();
55
+ state.toggle("last");
56
+ break;
57
+ default:
58
+ // Allow other keys.
59
+ if ("continuePropagation" in e) e.continuePropagation();
60
+ }
61
+ };
62
+ let stringFormatter = (0, $jo7gW$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($d1742ec2644a0949$exports))), "@react-aria/menu");
63
+ let { longPressProps: longPressProps } = (0, $jo7gW$reactariainteractions.useLongPress)({
64
+ isDisabled: isDisabled || trigger !== "longPress",
65
+ accessibilityDescription: stringFormatter.format("longPressMessage"),
66
+ onLongPressStart () {
67
+ state.close();
68
+ },
69
+ onLongPress () {
70
+ state.open("first");
71
+ }
72
+ });
73
+ let pressProps = {
74
+ onPressStart (e) {
75
+ // For consistency with native, open the menu on mouse/key down, but touch up.
76
+ if (e.pointerType !== "touch" && e.pointerType !== "keyboard" && !isDisabled) // If opened with a screen reader, auto focus the first item.
77
+ // Otherwise, the menu itself will be focused.
78
+ state.open(e.pointerType === "virtual" ? "first" : null);
79
+ },
80
+ onPress (e) {
81
+ if (e.pointerType === "touch" && !isDisabled) state.toggle();
82
+ }
83
+ };
84
+ // omit onPress from triggerProps since we override it above.
85
+ delete triggerProps.onPress;
86
+ return {
87
+ menuTriggerProps: {
88
+ ...triggerProps,
89
+ ...trigger === "press" ? pressProps : longPressProps,
90
+ id: menuTriggerId,
91
+ onKeyDown: onKeyDown
92
+ },
93
+ menuProps: {
94
+ ...overlayProps,
95
+ "aria-labelledby": menuTriggerId,
96
+ autoFocus: state.focusStrategy || true,
97
+ onClose: state.close
98
+ }
99
+ };
100
+ }
101
+
102
+
103
+ //# sourceMappingURL=useMenuTrigger.main.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;AAqCM,SAAS,0CAAkB,KAA2B,EAAE,KAAuB,EAAE,GAAuB;IAC7G,IAAI,QACF,OAAO,oBACP,UAAU,WACV,UAAU,SACX,GAAG;IAEJ,IAAI,gBAAgB,CAAA,GAAA,2BAAI;IACxB,IAAI,gBAAC,YAAY,gBAAE,YAAY,EAAC,GAAG,CAAA,GAAA,0CAAgB,EAAE;cAAC;IAAI,GAAG,OAAO;IAEpE,IAAI,YAAY,CAAC;QACf,IAAI,YACF;QAGF,IAAI,YAAY,eAAe,CAAC,EAAE,MAAM,EACtC;QAGF,IAAI,OAAO,IAAI,OAAO,EACpB,OAAQ,EAAE,GAAG;YACX,KAAK;YACL,KAAK;gBACH,IAAI,YAAY,aACd;YAEF,cAAc;YAChB,KAAK;gBACH,uEAAuE;gBACvE,IAAI,CAAE,CAAA,yBAAyB,CAAA,GAC7B,EAAE,eAAe;gBAEnB,EAAE,cAAc;gBAChB,MAAM,MAAM,CAAC;gBACb;YACF,KAAK;gBACH,IAAI,CAAE,CAAA,yBAAyB,CAAA,GAC7B,EAAE,eAAe;gBAEnB,EAAE,cAAc;gBAChB,MAAM,MAAM,CAAC;gBACb;YACF;gBACE,oBAAoB;gBACpB,IAAI,yBAAyB,GAC3B,EAAE,mBAAmB;QAE3B;IAEJ;IAEA,IAAI,kBAAkB,CAAA,GAAA,gDAA0B,EAAE,CAAA,GAAA,mDAAW,GAAG;IAChE,IAAI,kBAAC,cAAc,EAAC,GAAG,CAAA,GAAA,yCAAW,EAAE;QAClC,YAAY,cAAc,YAAY;QACtC,0BAA0B,gBAAgB,MAAM,CAAC;QACjD;YACE,MAAM,KAAK;QACb;QACA;YACE,MAAM,IAAI,CAAC;QACb;IACF;IAEA,IAAI,aAAc;QAChB,cAAa,CAAC;YACZ,8EAA8E;YAC9E,IAAI,EAAE,WAAW,KAAK,WAAW,EAAE,WAAW,KAAK,cAAc,CAAC,YAChE,6DAA6D;YAC7D,8CAA8C;YAC9C,MAAM,IAAI,CAAC,EAAE,WAAW,KAAK,YAAY,UAAU;QAEvD;QACA,SAAQ,CAAC;YACP,IAAI,EAAE,WAAW,KAAK,WAAW,CAAC,YAChC,MAAM,MAAM;QAEhB;IACF;IAEA,6DAA6D;IAC7D,OAAO,aAAa,OAAO;IAE3B,OAAO;QACL,kBAAkB;YAChB,GAAG,YAAY;YACf,GAAI,YAAY,UAAU,aAAa,cAAc;YACrD,IAAI;uBACJ;QACF;QACA,WAAW;YACT,GAAG,YAAY;YACf,mBAAmB;YACnB,WAAW,MAAM,aAAa,IAAI;YAClC,SAAS,MAAM,KAAK;QACtB;IACF;AACF","sources":["packages/@react-aria/menu/src/useMenuTrigger.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 {AriaButtonProps} from '@react-types/button';\nimport {AriaMenuOptions} from './useMenu';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {MenuTriggerState} from '@react-stately/menu';\nimport {MenuTriggerType} from '@react-types/menu';\nimport {RefObject} from 'react';\nimport {useId} from '@react-aria/utils';\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useLongPress} from '@react-aria/interactions';\nimport {useOverlayTrigger} from '@react-aria/overlays';\n\nexport interface AriaMenuTriggerProps {\n /** The type of menu that the menu trigger opens. */\n type?: 'menu' | 'listbox',\n /** Whether menu trigger is disabled. */\n isDisabled?: boolean,\n /** How menu is triggered. */\n trigger?: MenuTriggerType\n}\n\nexport interface MenuTriggerAria<T> {\n /** Props for the menu trigger element. */\n menuTriggerProps: AriaButtonProps,\n\n /** Props for the menu. */\n menuProps: AriaMenuOptions<T>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a menu trigger.\n * @param props - Props for the menu trigger.\n * @param state - State for the menu trigger.\n * @param ref - Ref to the HTML element trigger for the menu.\n */\nexport function useMenuTrigger<T>(props: AriaMenuTriggerProps, state: MenuTriggerState, ref: RefObject<Element>): MenuTriggerAria<T> {\n let {\n type = 'menu' as AriaMenuTriggerProps['type'],\n isDisabled,\n trigger = 'press'\n } = props;\n\n let menuTriggerId = useId();\n let {triggerProps, overlayProps} = useOverlayTrigger({type}, state, ref);\n\n let onKeyDown = (e) => {\n if (isDisabled) {\n return;\n }\n\n if (trigger === 'longPress' && !e.altKey) {\n return;\n }\n\n if (ref && ref.current) {\n switch (e.key) {\n case 'Enter':\n case ' ':\n if (trigger === 'longPress') {\n return;\n }\n // fallthrough\n case 'ArrowDown':\n // Stop propagation, unless it would already be handled by useKeyboard.\n if (!('continuePropagation' in e)) {\n e.stopPropagation();\n }\n e.preventDefault();\n state.toggle('first');\n break;\n case 'ArrowUp':\n if (!('continuePropagation' in e)) {\n e.stopPropagation();\n }\n e.preventDefault();\n state.toggle('last');\n break;\n default:\n // Allow other keys.\n if ('continuePropagation' in e) {\n e.continuePropagation();\n }\n }\n }\n };\n\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-aria/menu');\n let {longPressProps} = useLongPress({\n isDisabled: isDisabled || trigger !== 'longPress',\n accessibilityDescription: stringFormatter.format('longPressMessage'),\n onLongPressStart() {\n state.close();\n },\n onLongPress() {\n state.open('first');\n }\n });\n\n let pressProps = {\n onPressStart(e) {\n // For consistency with native, open the menu on mouse/key down, but touch up.\n if (e.pointerType !== 'touch' && e.pointerType !== 'keyboard' && !isDisabled) {\n // If opened with a screen reader, auto focus the first item.\n // Otherwise, the menu itself will be focused.\n state.open(e.pointerType === 'virtual' ? 'first' : null);\n }\n },\n onPress(e) {\n if (e.pointerType === 'touch' && !isDisabled) {\n state.toggle();\n }\n }\n };\n\n // omit onPress from triggerProps since we override it above.\n delete triggerProps.onPress;\n\n return {\n menuTriggerProps: {\n ...triggerProps,\n ...(trigger === 'press' ? pressProps : longPressProps),\n id: menuTriggerId,\n onKeyDown\n },\n menuProps: {\n ...overlayProps,\n 'aria-labelledby': menuTriggerId,\n autoFocus: state.focusStrategy || true,\n onClose: state.close\n }\n };\n}\n"],"names":[],"version":3,"file":"useMenuTrigger.main.js.map"}