@react-aria/menu 3.21.0 → 3.22.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.
- package/dist/import.mjs +2 -10
- package/dist/main.js +6 -14
- package/dist/main.js.map +1 -1
- package/dist/module.js +2 -10
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +2 -0
- package/package.json +15 -24
- package/src/index.ts +2 -11
- package/dist/ar-AE.main.js +0 -6
- package/dist/ar-AE.main.js.map +0 -1
- package/dist/ar-AE.mjs +0 -8
- package/dist/ar-AE.module.js +0 -8
- package/dist/ar-AE.module.js.map +0 -1
- package/dist/bg-BG.main.js +0 -6
- package/dist/bg-BG.main.js.map +0 -1
- package/dist/bg-BG.mjs +0 -8
- package/dist/bg-BG.module.js +0 -8
- package/dist/bg-BG.module.js.map +0 -1
- package/dist/cs-CZ.main.js +0 -6
- package/dist/cs-CZ.main.js.map +0 -1
- package/dist/cs-CZ.mjs +0 -8
- package/dist/cs-CZ.module.js +0 -8
- package/dist/cs-CZ.module.js.map +0 -1
- package/dist/da-DK.main.js +0 -6
- package/dist/da-DK.main.js.map +0 -1
- package/dist/da-DK.mjs +0 -8
- package/dist/da-DK.module.js +0 -8
- package/dist/da-DK.module.js.map +0 -1
- package/dist/de-DE.main.js +0 -6
- package/dist/de-DE.main.js.map +0 -1
- package/dist/de-DE.mjs +0 -8
- package/dist/de-DE.module.js +0 -8
- package/dist/de-DE.module.js.map +0 -1
- package/dist/el-GR.main.js +0 -6
- package/dist/el-GR.main.js.map +0 -1
- package/dist/el-GR.mjs +0 -8
- package/dist/el-GR.module.js +0 -8
- package/dist/el-GR.module.js.map +0 -1
- package/dist/en-US.main.js +0 -6
- package/dist/en-US.main.js.map +0 -1
- package/dist/en-US.mjs +0 -8
- package/dist/en-US.module.js +0 -8
- package/dist/en-US.module.js.map +0 -1
- package/dist/es-ES.main.js +0 -6
- package/dist/es-ES.main.js.map +0 -1
- package/dist/es-ES.mjs +0 -8
- package/dist/es-ES.module.js +0 -8
- package/dist/es-ES.module.js.map +0 -1
- package/dist/et-EE.main.js +0 -6
- package/dist/et-EE.main.js.map +0 -1
- package/dist/et-EE.mjs +0 -8
- package/dist/et-EE.module.js +0 -8
- package/dist/et-EE.module.js.map +0 -1
- package/dist/fi-FI.main.js +0 -6
- package/dist/fi-FI.main.js.map +0 -1
- package/dist/fi-FI.mjs +0 -8
- package/dist/fi-FI.module.js +0 -8
- package/dist/fi-FI.module.js.map +0 -1
- package/dist/fr-FR.main.js +0 -6
- package/dist/fr-FR.main.js.map +0 -1
- package/dist/fr-FR.mjs +0 -8
- package/dist/fr-FR.module.js +0 -8
- package/dist/fr-FR.module.js.map +0 -1
- package/dist/he-IL.main.js +0 -6
- package/dist/he-IL.main.js.map +0 -1
- package/dist/he-IL.mjs +0 -8
- package/dist/he-IL.module.js +0 -8
- package/dist/he-IL.module.js.map +0 -1
- package/dist/hr-HR.main.js +0 -6
- package/dist/hr-HR.main.js.map +0 -1
- package/dist/hr-HR.mjs +0 -8
- package/dist/hr-HR.module.js +0 -8
- package/dist/hr-HR.module.js.map +0 -1
- package/dist/hu-HU.main.js +0 -6
- package/dist/hu-HU.main.js.map +0 -1
- package/dist/hu-HU.mjs +0 -8
- package/dist/hu-HU.module.js +0 -8
- package/dist/hu-HU.module.js.map +0 -1
- package/dist/intlStrings.main.js +0 -108
- package/dist/intlStrings.main.js.map +0 -1
- package/dist/intlStrings.mjs +0 -110
- package/dist/intlStrings.module.js +0 -110
- package/dist/intlStrings.module.js.map +0 -1
- package/dist/it-IT.main.js +0 -6
- package/dist/it-IT.main.js.map +0 -1
- package/dist/it-IT.mjs +0 -8
- package/dist/it-IT.module.js +0 -8
- package/dist/it-IT.module.js.map +0 -1
- package/dist/ja-JP.main.js +0 -6
- package/dist/ja-JP.main.js.map +0 -1
- package/dist/ja-JP.mjs +0 -8
- package/dist/ja-JP.module.js +0 -8
- package/dist/ja-JP.module.js.map +0 -1
- package/dist/ko-KR.main.js +0 -6
- package/dist/ko-KR.main.js.map +0 -1
- package/dist/ko-KR.mjs +0 -8
- package/dist/ko-KR.module.js +0 -8
- package/dist/ko-KR.module.js.map +0 -1
- package/dist/lt-LT.main.js +0 -6
- package/dist/lt-LT.main.js.map +0 -1
- package/dist/lt-LT.mjs +0 -8
- package/dist/lt-LT.module.js +0 -8
- package/dist/lt-LT.module.js.map +0 -1
- package/dist/lv-LV.main.js +0 -6
- package/dist/lv-LV.main.js.map +0 -1
- package/dist/lv-LV.mjs +0 -8
- package/dist/lv-LV.module.js +0 -8
- package/dist/lv-LV.module.js.map +0 -1
- package/dist/nb-NO.main.js +0 -6
- package/dist/nb-NO.main.js.map +0 -1
- package/dist/nb-NO.mjs +0 -8
- package/dist/nb-NO.module.js +0 -8
- package/dist/nb-NO.module.js.map +0 -1
- package/dist/nl-NL.main.js +0 -6
- package/dist/nl-NL.main.js.map +0 -1
- package/dist/nl-NL.mjs +0 -8
- package/dist/nl-NL.module.js +0 -8
- package/dist/nl-NL.module.js.map +0 -1
- package/dist/pl-PL.main.js +0 -6
- package/dist/pl-PL.main.js.map +0 -1
- package/dist/pl-PL.mjs +0 -8
- package/dist/pl-PL.module.js +0 -8
- package/dist/pl-PL.module.js.map +0 -1
- package/dist/pt-BR.main.js +0 -6
- package/dist/pt-BR.main.js.map +0 -1
- package/dist/pt-BR.mjs +0 -8
- package/dist/pt-BR.module.js +0 -8
- package/dist/pt-BR.module.js.map +0 -1
- package/dist/pt-PT.main.js +0 -6
- package/dist/pt-PT.main.js.map +0 -1
- package/dist/pt-PT.mjs +0 -8
- package/dist/pt-PT.module.js +0 -8
- package/dist/pt-PT.module.js.map +0 -1
- package/dist/ro-RO.main.js +0 -6
- package/dist/ro-RO.main.js.map +0 -1
- package/dist/ro-RO.mjs +0 -8
- package/dist/ro-RO.module.js +0 -8
- package/dist/ro-RO.module.js.map +0 -1
- package/dist/ru-RU.main.js +0 -6
- package/dist/ru-RU.main.js.map +0 -1
- package/dist/ru-RU.mjs +0 -8
- package/dist/ru-RU.module.js +0 -8
- package/dist/ru-RU.module.js.map +0 -1
- package/dist/sk-SK.main.js +0 -6
- package/dist/sk-SK.main.js.map +0 -1
- package/dist/sk-SK.mjs +0 -8
- package/dist/sk-SK.module.js +0 -8
- package/dist/sk-SK.module.js.map +0 -1
- package/dist/sl-SI.main.js +0 -6
- package/dist/sl-SI.main.js.map +0 -1
- package/dist/sl-SI.mjs +0 -8
- package/dist/sl-SI.module.js +0 -8
- package/dist/sl-SI.module.js.map +0 -1
- package/dist/sr-SP.main.js +0 -6
- package/dist/sr-SP.main.js.map +0 -1
- package/dist/sr-SP.mjs +0 -8
- package/dist/sr-SP.module.js +0 -8
- package/dist/sr-SP.module.js.map +0 -1
- package/dist/sv-SE.main.js +0 -6
- package/dist/sv-SE.main.js.map +0 -1
- package/dist/sv-SE.mjs +0 -8
- package/dist/sv-SE.module.js +0 -8
- package/dist/sv-SE.module.js.map +0 -1
- package/dist/tr-TR.main.js +0 -6
- package/dist/tr-TR.main.js.map +0 -1
- package/dist/tr-TR.mjs +0 -8
- package/dist/tr-TR.module.js +0 -8
- package/dist/tr-TR.module.js.map +0 -1
- package/dist/types.d.ts +0 -193
- package/dist/types.d.ts.map +0 -1
- package/dist/uk-UA.main.js +0 -6
- package/dist/uk-UA.main.js.map +0 -1
- package/dist/uk-UA.mjs +0 -8
- package/dist/uk-UA.module.js +0 -8
- package/dist/uk-UA.module.js.map +0 -1
- package/dist/useMenu.main.js +0 -61
- package/dist/useMenu.main.js.map +0 -1
- package/dist/useMenu.mjs +0 -56
- package/dist/useMenu.module.js +0 -56
- package/dist/useMenu.module.js.map +0 -1
- package/dist/useMenuItem.main.js +0 -225
- package/dist/useMenuItem.main.js.map +0 -1
- package/dist/useMenuItem.mjs +0 -220
- package/dist/useMenuItem.module.js +0 -220
- package/dist/useMenuItem.module.js.map +0 -1
- package/dist/useMenuSection.main.js +0 -43
- package/dist/useMenuSection.main.js.map +0 -1
- package/dist/useMenuSection.mjs +0 -38
- package/dist/useMenuSection.module.js +0 -38
- package/dist/useMenuSection.module.js.map +0 -1
- package/dist/useMenuTrigger.main.js +0 -117
- package/dist/useMenuTrigger.main.js.map +0 -1
- package/dist/useMenuTrigger.mjs +0 -112
- package/dist/useMenuTrigger.module.js +0 -112
- package/dist/useMenuTrigger.module.js.map +0 -1
- package/dist/useSafelyMouseToSubmenu.main.js +0 -143
- package/dist/useSafelyMouseToSubmenu.main.js.map +0 -1
- package/dist/useSafelyMouseToSubmenu.mjs +0 -138
- package/dist/useSafelyMouseToSubmenu.module.js +0 -138
- package/dist/useSafelyMouseToSubmenu.module.js.map +0 -1
- package/dist/useSubmenuTrigger.main.js +0 -184
- package/dist/useSubmenuTrigger.main.js.map +0 -1
- package/dist/useSubmenuTrigger.mjs +0 -179
- package/dist/useSubmenuTrigger.module.js +0 -179
- package/dist/useSubmenuTrigger.module.js.map +0 -1
- package/dist/utils.main.js +0 -20
- package/dist/utils.main.js.map +0 -1
- package/dist/utils.mjs +0 -15
- package/dist/utils.module.js +0 -15
- package/dist/utils.module.js.map +0 -1
- package/dist/zh-CN.main.js +0 -6
- package/dist/zh-CN.main.js.map +0 -1
- package/dist/zh-CN.mjs +0 -8
- package/dist/zh-CN.module.js +0 -8
- package/dist/zh-CN.module.js.map +0 -1
- package/dist/zh-TW.main.js +0 -6
- package/dist/zh-TW.main.js.map +0 -1
- package/dist/zh-TW.mjs +0 -8
- package/dist/zh-TW.module.js +0 -8
- package/dist/zh-TW.module.js.map +0 -1
- package/src/useMenu.ts +0 -86
- package/src/useMenuItem.ts +0 -362
- package/src/useMenuSection.ts +0 -61
- package/src/useMenuTrigger.ts +0 -156
- package/src/useSafelyMouseToSubmenu.ts +0 -178
- package/src/useSubmenuTrigger.ts +0 -262
- package/src/utils.ts +0 -22
package/dist/useMenuItem.mjs
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import {menuData as $fc79756100351201$export$6f49b4016bfc8d56} from "./utils.mjs";
|
|
2
|
-
import {useRouter as $7Kjv5$useRouter, useSlotId as $7Kjv5$useSlotId, handleLinkClick as $7Kjv5$handleLinkClick, getEventTarget as $7Kjv5$getEventTarget, 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, setInteractionModality as $7Kjv5$setInteractionModality, useFocusable as $7Kjv5$useFocusable} from "@react-aria/interactions";
|
|
5
|
-
import {useRef as $7Kjv5$useRef} from "react";
|
|
6
|
-
import {useSelectableItem as $7Kjv5$useSelectableItem} from "@react-aria/selection";
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
10
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
11
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
12
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
*
|
|
14
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
15
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
16
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
17
|
-
* governing permissions and limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function $a2e5df62f93c7633$export$9d32628fc2aea7da(props, state, ref) {
|
|
25
|
-
let { id: id, key: key, closeOnSelect: closeOnSelect, shouldCloseOnSelect: shouldCloseOnSelect, isVirtualized: isVirtualized, 'aria-haspopup': hasPopup, onPressStart: onPressStart, onPressUp: pressUpProp, onPress: onPress, onPressChange: pressChangeProp, onPressEnd: onPressEnd, onClick: onClickProp, onHoverStart: hoverStartProp, onHoverChange: onHoverChange, onHoverEnd: onHoverEnd, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onFocus: onFocus, onFocusChange: onFocusChange, onBlur: onBlur, selectionManager: selectionManager = state.selectionManager } = props;
|
|
26
|
-
let isTrigger = !!hasPopup;
|
|
27
|
-
let isTriggerExpanded = isTrigger && props['aria-expanded'] === 'true';
|
|
28
|
-
var _props_isDisabled;
|
|
29
|
-
let isDisabled = (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : selectionManager.isDisabled(key);
|
|
30
|
-
var _props_isSelected;
|
|
31
|
-
let isSelected = (_props_isSelected = props.isSelected) !== null && _props_isSelected !== void 0 ? _props_isSelected : selectionManager.isSelected(key);
|
|
32
|
-
let data = (0, $fc79756100351201$export$6f49b4016bfc8d56).get(state);
|
|
33
|
-
let item = state.collection.getItem(key);
|
|
34
|
-
let onClose = props.onClose || data.onClose;
|
|
35
|
-
let router = (0, $7Kjv5$useRouter)();
|
|
36
|
-
let performAction = ()=>{
|
|
37
|
-
var _item_props;
|
|
38
|
-
if (isTrigger) return;
|
|
39
|
-
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();
|
|
40
|
-
else if (props.onAction) props.onAction(key);
|
|
41
|
-
if (data.onAction) {
|
|
42
|
-
// Must reassign to variable otherwise `this` binding gets messed up. Something to do with WeakMap.
|
|
43
|
-
let onAction = data.onAction;
|
|
44
|
-
onAction(key);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
let role = 'menuitem';
|
|
48
|
-
if (!isTrigger) {
|
|
49
|
-
if (selectionManager.selectionMode === 'single') role = 'menuitemradio';
|
|
50
|
-
else if (selectionManager.selectionMode === 'multiple') role = 'menuitemcheckbox';
|
|
51
|
-
}
|
|
52
|
-
let labelId = (0, $7Kjv5$useSlotId)();
|
|
53
|
-
let descriptionId = (0, $7Kjv5$useSlotId)();
|
|
54
|
-
let keyboardId = (0, $7Kjv5$useSlotId)();
|
|
55
|
-
let ariaProps = {
|
|
56
|
-
id: id,
|
|
57
|
-
'aria-disabled': isDisabled || undefined,
|
|
58
|
-
role: role,
|
|
59
|
-
'aria-label': props['aria-label'],
|
|
60
|
-
'aria-labelledby': labelId,
|
|
61
|
-
'aria-describedby': [
|
|
62
|
-
props['aria-describedby'],
|
|
63
|
-
descriptionId,
|
|
64
|
-
keyboardId
|
|
65
|
-
].filter(Boolean).join(' ') || undefined,
|
|
66
|
-
'aria-controls': props['aria-controls'],
|
|
67
|
-
'aria-haspopup': hasPopup,
|
|
68
|
-
'aria-expanded': props['aria-expanded']
|
|
69
|
-
};
|
|
70
|
-
if (selectionManager.selectionMode !== 'none' && !isTrigger) ariaProps['aria-checked'] = isSelected;
|
|
71
|
-
if (isVirtualized) {
|
|
72
|
-
let index = Number(item === null || item === void 0 ? void 0 : item.index);
|
|
73
|
-
ariaProps['aria-posinset'] = Number.isNaN(index) ? undefined : index + 1;
|
|
74
|
-
ariaProps['aria-setsize'] = (0, $7Kjv5$getItemCount)(state.collection);
|
|
75
|
-
}
|
|
76
|
-
let isPressedRef = (0, $7Kjv5$useRef)(false);
|
|
77
|
-
let onPressChange = (isPressed)=>{
|
|
78
|
-
pressChangeProp === null || pressChangeProp === void 0 ? void 0 : pressChangeProp(isPressed);
|
|
79
|
-
isPressedRef.current = isPressed;
|
|
80
|
-
};
|
|
81
|
-
let interaction = (0, $7Kjv5$useRef)(null);
|
|
82
|
-
let onPressUp = (e)=>{
|
|
83
|
-
if (e.pointerType !== 'keyboard') interaction.current = {
|
|
84
|
-
pointerType: e.pointerType
|
|
85
|
-
};
|
|
86
|
-
// If interacting with mouse, allow the user to mouse down on the trigger button,
|
|
87
|
-
// drag, and release over an item (matching native behavior).
|
|
88
|
-
if (e.pointerType === 'mouse') {
|
|
89
|
-
if (!isPressedRef.current) e.target.click();
|
|
90
|
-
}
|
|
91
|
-
pressUpProp === null || pressUpProp === void 0 ? void 0 : pressUpProp(e);
|
|
92
|
-
};
|
|
93
|
-
let onClick = (e)=>{
|
|
94
|
-
var _interaction_current, _interaction_current1;
|
|
95
|
-
onClickProp === null || onClickProp === void 0 ? void 0 : onClickProp(e);
|
|
96
|
-
performAction();
|
|
97
|
-
(0, $7Kjv5$handleLinkClick)(e, router, item.props.href, item === null || item === void 0 ? void 0 : item.props.routerOptions);
|
|
98
|
-
let shouldClose = ((_interaction_current = interaction.current) === null || _interaction_current === void 0 ? void 0 : _interaction_current.pointerType) === 'keyboard' ? ((_interaction_current1 = interaction.current) === null || _interaction_current1 === void 0 ? void 0 : _interaction_current1.key) === 'Enter' || selectionManager.selectionMode === 'none' || selectionManager.isLink(key) : selectionManager.selectionMode !== 'multiple' || selectionManager.isLink(key);
|
|
99
|
-
var _ref;
|
|
100
|
-
shouldClose = (_ref = shouldCloseOnSelect !== null && shouldCloseOnSelect !== void 0 ? shouldCloseOnSelect : closeOnSelect) !== null && _ref !== void 0 ? _ref : shouldClose;
|
|
101
|
-
if (onClose && !isTrigger && shouldClose) onClose();
|
|
102
|
-
interaction.current = null;
|
|
103
|
-
};
|
|
104
|
-
let { itemProps: itemProps, isFocused: isFocused } = (0, $7Kjv5$useSelectableItem)({
|
|
105
|
-
id: id,
|
|
106
|
-
selectionManager: selectionManager,
|
|
107
|
-
key: key,
|
|
108
|
-
ref: ref,
|
|
109
|
-
shouldSelectOnPressUp: true,
|
|
110
|
-
allowsDifferentPressOrigin: true,
|
|
111
|
-
// Disable all handling of links in useSelectable item
|
|
112
|
-
// because we handle it ourselves. The behavior of menus
|
|
113
|
-
// is slightly different from other collections because
|
|
114
|
-
// actions are performed on key down rather than key up.
|
|
115
|
-
linkBehavior: 'none',
|
|
116
|
-
shouldUseVirtualFocus: data.shouldUseVirtualFocus
|
|
117
|
-
});
|
|
118
|
-
let { pressProps: pressProps, isPressed: isPressed } = (0, $7Kjv5$usePress)({
|
|
119
|
-
onPressStart: onPressStart,
|
|
120
|
-
onPress: onPress,
|
|
121
|
-
onPressUp: onPressUp,
|
|
122
|
-
onPressChange: onPressChange,
|
|
123
|
-
onPressEnd: onPressEnd,
|
|
124
|
-
isDisabled: isDisabled
|
|
125
|
-
});
|
|
126
|
-
let { hoverProps: hoverProps } = (0, $7Kjv5$useHover)({
|
|
127
|
-
isDisabled: isDisabled,
|
|
128
|
-
onHoverStart (e) {
|
|
129
|
-
// Hovering over an already expanded sub dialog trigger should keep focus in the dialog.
|
|
130
|
-
if (!(0, $7Kjv5$isFocusVisible)() && !(isTriggerExpanded && hasPopup)) {
|
|
131
|
-
selectionManager.setFocused(true);
|
|
132
|
-
selectionManager.setFocusedKey(key);
|
|
133
|
-
}
|
|
134
|
-
hoverStartProp === null || hoverStartProp === void 0 ? void 0 : hoverStartProp(e);
|
|
135
|
-
},
|
|
136
|
-
onHoverChange: onHoverChange,
|
|
137
|
-
onHoverEnd: onHoverEnd
|
|
138
|
-
});
|
|
139
|
-
let { keyboardProps: keyboardProps } = (0, $7Kjv5$useKeyboard)({
|
|
140
|
-
onKeyDown: (e)=>{
|
|
141
|
-
// Ignore repeating events, which may have started on the menu trigger before moving
|
|
142
|
-
// focus to the menu item. We want to wait for a second complete key press sequence.
|
|
143
|
-
if (e.repeat) {
|
|
144
|
-
e.continuePropagation();
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
switch(e.key){
|
|
148
|
-
case ' ':
|
|
149
|
-
interaction.current = {
|
|
150
|
-
pointerType: 'keyboard',
|
|
151
|
-
key: ' '
|
|
152
|
-
};
|
|
153
|
-
(0, $7Kjv5$getEventTarget)(e).click();
|
|
154
|
-
// click above sets modality to "virtual", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus
|
|
155
|
-
// to the newly opened submenu's first item.
|
|
156
|
-
(0, $7Kjv5$setInteractionModality)('keyboard');
|
|
157
|
-
break;
|
|
158
|
-
case 'Enter':
|
|
159
|
-
interaction.current = {
|
|
160
|
-
pointerType: 'keyboard',
|
|
161
|
-
key: 'Enter'
|
|
162
|
-
};
|
|
163
|
-
// Trigger click unless this is a link. Links trigger click natively.
|
|
164
|
-
if ((0, $7Kjv5$getEventTarget)(e).tagName !== 'A') (0, $7Kjv5$getEventTarget)(e).click();
|
|
165
|
-
// click above sets modality to "virtual", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus
|
|
166
|
-
// to the newly opened submenu's first item.
|
|
167
|
-
(0, $7Kjv5$setInteractionModality)('keyboard');
|
|
168
|
-
break;
|
|
169
|
-
default:
|
|
170
|
-
if (!isTrigger) e.continuePropagation();
|
|
171
|
-
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
onKeyUp: onKeyUp
|
|
176
|
-
});
|
|
177
|
-
let { focusableProps: focusableProps } = (0, $7Kjv5$useFocusable)({
|
|
178
|
-
onBlur: onBlur,
|
|
179
|
-
onFocus: onFocus,
|
|
180
|
-
onFocusChange: onFocusChange
|
|
181
|
-
}, ref);
|
|
182
|
-
let domProps = (0, $7Kjv5$filterDOMProps)(item === null || item === void 0 ? void 0 : item.props);
|
|
183
|
-
delete domProps.id;
|
|
184
|
-
let linkProps = (0, $7Kjv5$useLinkProps)(item === null || item === void 0 ? void 0 : item.props);
|
|
185
|
-
return {
|
|
186
|
-
menuItemProps: {
|
|
187
|
-
...ariaProps,
|
|
188
|
-
...(0, $7Kjv5$mergeProps)(domProps, linkProps, isTrigger ? {
|
|
189
|
-
onFocus: itemProps.onFocus,
|
|
190
|
-
'data-collection': itemProps['data-collection'],
|
|
191
|
-
'data-key': itemProps['data-key']
|
|
192
|
-
} : itemProps, pressProps, hoverProps, keyboardProps, focusableProps, // Prevent DOM focus from moving on mouse down when using virtual focus or this is a submenu/subdialog trigger.
|
|
193
|
-
data.shouldUseVirtualFocus || isTrigger ? {
|
|
194
|
-
onMouseDown: (e)=>e.preventDefault()
|
|
195
|
-
} : undefined, isDisabled ? undefined : {
|
|
196
|
-
onClick: onClick
|
|
197
|
-
}),
|
|
198
|
-
// 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.
|
|
199
|
-
tabIndex: itemProps.tabIndex != null && isTriggerExpanded && !data.shouldUseVirtualFocus ? -1 : itemProps.tabIndex
|
|
200
|
-
},
|
|
201
|
-
labelProps: {
|
|
202
|
-
id: labelId
|
|
203
|
-
},
|
|
204
|
-
descriptionProps: {
|
|
205
|
-
id: descriptionId
|
|
206
|
-
},
|
|
207
|
-
keyboardShortcutProps: {
|
|
208
|
-
id: keyboardId
|
|
209
|
-
},
|
|
210
|
-
isFocused: isFocused,
|
|
211
|
-
isFocusVisible: isFocused && selectionManager.isFocused && (0, $7Kjv5$isFocusVisible)() && !isTriggerExpanded,
|
|
212
|
-
isSelected: isSelected,
|
|
213
|
-
isPressed: isPressed,
|
|
214
|
-
isDisabled: isDisabled
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
export {$a2e5df62f93c7633$export$9d32628fc2aea7da as useMenuItem};
|
|
220
|
-
//# sourceMappingURL=useMenuItem.module.js.map
|
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import {menuData as $fc79756100351201$export$6f49b4016bfc8d56} from "./utils.module.js";
|
|
2
|
-
import {useRouter as $7Kjv5$useRouter, useSlotId as $7Kjv5$useSlotId, handleLinkClick as $7Kjv5$handleLinkClick, getEventTarget as $7Kjv5$getEventTarget, 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, setInteractionModality as $7Kjv5$setInteractionModality, useFocusable as $7Kjv5$useFocusable} from "@react-aria/interactions";
|
|
5
|
-
import {useRef as $7Kjv5$useRef} from "react";
|
|
6
|
-
import {useSelectableItem as $7Kjv5$useSelectableItem} from "@react-aria/selection";
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
10
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
11
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
12
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
-
*
|
|
14
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
15
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
16
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
17
|
-
* governing permissions and limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function $a2e5df62f93c7633$export$9d32628fc2aea7da(props, state, ref) {
|
|
25
|
-
let { id: id, key: key, closeOnSelect: closeOnSelect, shouldCloseOnSelect: shouldCloseOnSelect, isVirtualized: isVirtualized, 'aria-haspopup': hasPopup, onPressStart: onPressStart, onPressUp: pressUpProp, onPress: onPress, onPressChange: pressChangeProp, onPressEnd: onPressEnd, onClick: onClickProp, onHoverStart: hoverStartProp, onHoverChange: onHoverChange, onHoverEnd: onHoverEnd, onKeyDown: onKeyDown, onKeyUp: onKeyUp, onFocus: onFocus, onFocusChange: onFocusChange, onBlur: onBlur, selectionManager: selectionManager = state.selectionManager } = props;
|
|
26
|
-
let isTrigger = !!hasPopup;
|
|
27
|
-
let isTriggerExpanded = isTrigger && props['aria-expanded'] === 'true';
|
|
28
|
-
var _props_isDisabled;
|
|
29
|
-
let isDisabled = (_props_isDisabled = props.isDisabled) !== null && _props_isDisabled !== void 0 ? _props_isDisabled : selectionManager.isDisabled(key);
|
|
30
|
-
var _props_isSelected;
|
|
31
|
-
let isSelected = (_props_isSelected = props.isSelected) !== null && _props_isSelected !== void 0 ? _props_isSelected : selectionManager.isSelected(key);
|
|
32
|
-
let data = (0, $fc79756100351201$export$6f49b4016bfc8d56).get(state);
|
|
33
|
-
let item = state.collection.getItem(key);
|
|
34
|
-
let onClose = props.onClose || data.onClose;
|
|
35
|
-
let router = (0, $7Kjv5$useRouter)();
|
|
36
|
-
let performAction = ()=>{
|
|
37
|
-
var _item_props;
|
|
38
|
-
if (isTrigger) return;
|
|
39
|
-
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();
|
|
40
|
-
else if (props.onAction) props.onAction(key);
|
|
41
|
-
if (data.onAction) {
|
|
42
|
-
// Must reassign to variable otherwise `this` binding gets messed up. Something to do with WeakMap.
|
|
43
|
-
let onAction = data.onAction;
|
|
44
|
-
onAction(key);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
let role = 'menuitem';
|
|
48
|
-
if (!isTrigger) {
|
|
49
|
-
if (selectionManager.selectionMode === 'single') role = 'menuitemradio';
|
|
50
|
-
else if (selectionManager.selectionMode === 'multiple') role = 'menuitemcheckbox';
|
|
51
|
-
}
|
|
52
|
-
let labelId = (0, $7Kjv5$useSlotId)();
|
|
53
|
-
let descriptionId = (0, $7Kjv5$useSlotId)();
|
|
54
|
-
let keyboardId = (0, $7Kjv5$useSlotId)();
|
|
55
|
-
let ariaProps = {
|
|
56
|
-
id: id,
|
|
57
|
-
'aria-disabled': isDisabled || undefined,
|
|
58
|
-
role: role,
|
|
59
|
-
'aria-label': props['aria-label'],
|
|
60
|
-
'aria-labelledby': labelId,
|
|
61
|
-
'aria-describedby': [
|
|
62
|
-
props['aria-describedby'],
|
|
63
|
-
descriptionId,
|
|
64
|
-
keyboardId
|
|
65
|
-
].filter(Boolean).join(' ') || undefined,
|
|
66
|
-
'aria-controls': props['aria-controls'],
|
|
67
|
-
'aria-haspopup': hasPopup,
|
|
68
|
-
'aria-expanded': props['aria-expanded']
|
|
69
|
-
};
|
|
70
|
-
if (selectionManager.selectionMode !== 'none' && !isTrigger) ariaProps['aria-checked'] = isSelected;
|
|
71
|
-
if (isVirtualized) {
|
|
72
|
-
let index = Number(item === null || item === void 0 ? void 0 : item.index);
|
|
73
|
-
ariaProps['aria-posinset'] = Number.isNaN(index) ? undefined : index + 1;
|
|
74
|
-
ariaProps['aria-setsize'] = (0, $7Kjv5$getItemCount)(state.collection);
|
|
75
|
-
}
|
|
76
|
-
let isPressedRef = (0, $7Kjv5$useRef)(false);
|
|
77
|
-
let onPressChange = (isPressed)=>{
|
|
78
|
-
pressChangeProp === null || pressChangeProp === void 0 ? void 0 : pressChangeProp(isPressed);
|
|
79
|
-
isPressedRef.current = isPressed;
|
|
80
|
-
};
|
|
81
|
-
let interaction = (0, $7Kjv5$useRef)(null);
|
|
82
|
-
let onPressUp = (e)=>{
|
|
83
|
-
if (e.pointerType !== 'keyboard') interaction.current = {
|
|
84
|
-
pointerType: e.pointerType
|
|
85
|
-
};
|
|
86
|
-
// If interacting with mouse, allow the user to mouse down on the trigger button,
|
|
87
|
-
// drag, and release over an item (matching native behavior).
|
|
88
|
-
if (e.pointerType === 'mouse') {
|
|
89
|
-
if (!isPressedRef.current) e.target.click();
|
|
90
|
-
}
|
|
91
|
-
pressUpProp === null || pressUpProp === void 0 ? void 0 : pressUpProp(e);
|
|
92
|
-
};
|
|
93
|
-
let onClick = (e)=>{
|
|
94
|
-
var _interaction_current, _interaction_current1;
|
|
95
|
-
onClickProp === null || onClickProp === void 0 ? void 0 : onClickProp(e);
|
|
96
|
-
performAction();
|
|
97
|
-
(0, $7Kjv5$handleLinkClick)(e, router, item.props.href, item === null || item === void 0 ? void 0 : item.props.routerOptions);
|
|
98
|
-
let shouldClose = ((_interaction_current = interaction.current) === null || _interaction_current === void 0 ? void 0 : _interaction_current.pointerType) === 'keyboard' ? ((_interaction_current1 = interaction.current) === null || _interaction_current1 === void 0 ? void 0 : _interaction_current1.key) === 'Enter' || selectionManager.selectionMode === 'none' || selectionManager.isLink(key) : selectionManager.selectionMode !== 'multiple' || selectionManager.isLink(key);
|
|
99
|
-
var _ref;
|
|
100
|
-
shouldClose = (_ref = shouldCloseOnSelect !== null && shouldCloseOnSelect !== void 0 ? shouldCloseOnSelect : closeOnSelect) !== null && _ref !== void 0 ? _ref : shouldClose;
|
|
101
|
-
if (onClose && !isTrigger && shouldClose) onClose();
|
|
102
|
-
interaction.current = null;
|
|
103
|
-
};
|
|
104
|
-
let { itemProps: itemProps, isFocused: isFocused } = (0, $7Kjv5$useSelectableItem)({
|
|
105
|
-
id: id,
|
|
106
|
-
selectionManager: selectionManager,
|
|
107
|
-
key: key,
|
|
108
|
-
ref: ref,
|
|
109
|
-
shouldSelectOnPressUp: true,
|
|
110
|
-
allowsDifferentPressOrigin: true,
|
|
111
|
-
// Disable all handling of links in useSelectable item
|
|
112
|
-
// because we handle it ourselves. The behavior of menus
|
|
113
|
-
// is slightly different from other collections because
|
|
114
|
-
// actions are performed on key down rather than key up.
|
|
115
|
-
linkBehavior: 'none',
|
|
116
|
-
shouldUseVirtualFocus: data.shouldUseVirtualFocus
|
|
117
|
-
});
|
|
118
|
-
let { pressProps: pressProps, isPressed: isPressed } = (0, $7Kjv5$usePress)({
|
|
119
|
-
onPressStart: onPressStart,
|
|
120
|
-
onPress: onPress,
|
|
121
|
-
onPressUp: onPressUp,
|
|
122
|
-
onPressChange: onPressChange,
|
|
123
|
-
onPressEnd: onPressEnd,
|
|
124
|
-
isDisabled: isDisabled
|
|
125
|
-
});
|
|
126
|
-
let { hoverProps: hoverProps } = (0, $7Kjv5$useHover)({
|
|
127
|
-
isDisabled: isDisabled,
|
|
128
|
-
onHoverStart (e) {
|
|
129
|
-
// Hovering over an already expanded sub dialog trigger should keep focus in the dialog.
|
|
130
|
-
if (!(0, $7Kjv5$isFocusVisible)() && !(isTriggerExpanded && hasPopup)) {
|
|
131
|
-
selectionManager.setFocused(true);
|
|
132
|
-
selectionManager.setFocusedKey(key);
|
|
133
|
-
}
|
|
134
|
-
hoverStartProp === null || hoverStartProp === void 0 ? void 0 : hoverStartProp(e);
|
|
135
|
-
},
|
|
136
|
-
onHoverChange: onHoverChange,
|
|
137
|
-
onHoverEnd: onHoverEnd
|
|
138
|
-
});
|
|
139
|
-
let { keyboardProps: keyboardProps } = (0, $7Kjv5$useKeyboard)({
|
|
140
|
-
onKeyDown: (e)=>{
|
|
141
|
-
// Ignore repeating events, which may have started on the menu trigger before moving
|
|
142
|
-
// focus to the menu item. We want to wait for a second complete key press sequence.
|
|
143
|
-
if (e.repeat) {
|
|
144
|
-
e.continuePropagation();
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
switch(e.key){
|
|
148
|
-
case ' ':
|
|
149
|
-
interaction.current = {
|
|
150
|
-
pointerType: 'keyboard',
|
|
151
|
-
key: ' '
|
|
152
|
-
};
|
|
153
|
-
(0, $7Kjv5$getEventTarget)(e).click();
|
|
154
|
-
// click above sets modality to "virtual", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus
|
|
155
|
-
// to the newly opened submenu's first item.
|
|
156
|
-
(0, $7Kjv5$setInteractionModality)('keyboard');
|
|
157
|
-
break;
|
|
158
|
-
case 'Enter':
|
|
159
|
-
interaction.current = {
|
|
160
|
-
pointerType: 'keyboard',
|
|
161
|
-
key: 'Enter'
|
|
162
|
-
};
|
|
163
|
-
// Trigger click unless this is a link. Links trigger click natively.
|
|
164
|
-
if ((0, $7Kjv5$getEventTarget)(e).tagName !== 'A') (0, $7Kjv5$getEventTarget)(e).click();
|
|
165
|
-
// click above sets modality to "virtual", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus
|
|
166
|
-
// to the newly opened submenu's first item.
|
|
167
|
-
(0, $7Kjv5$setInteractionModality)('keyboard');
|
|
168
|
-
break;
|
|
169
|
-
default:
|
|
170
|
-
if (!isTrigger) e.continuePropagation();
|
|
171
|
-
onKeyDown === null || onKeyDown === void 0 ? void 0 : onKeyDown(e);
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
onKeyUp: onKeyUp
|
|
176
|
-
});
|
|
177
|
-
let { focusableProps: focusableProps } = (0, $7Kjv5$useFocusable)({
|
|
178
|
-
onBlur: onBlur,
|
|
179
|
-
onFocus: onFocus,
|
|
180
|
-
onFocusChange: onFocusChange
|
|
181
|
-
}, ref);
|
|
182
|
-
let domProps = (0, $7Kjv5$filterDOMProps)(item === null || item === void 0 ? void 0 : item.props);
|
|
183
|
-
delete domProps.id;
|
|
184
|
-
let linkProps = (0, $7Kjv5$useLinkProps)(item === null || item === void 0 ? void 0 : item.props);
|
|
185
|
-
return {
|
|
186
|
-
menuItemProps: {
|
|
187
|
-
...ariaProps,
|
|
188
|
-
...(0, $7Kjv5$mergeProps)(domProps, linkProps, isTrigger ? {
|
|
189
|
-
onFocus: itemProps.onFocus,
|
|
190
|
-
'data-collection': itemProps['data-collection'],
|
|
191
|
-
'data-key': itemProps['data-key']
|
|
192
|
-
} : itemProps, pressProps, hoverProps, keyboardProps, focusableProps, // Prevent DOM focus from moving on mouse down when using virtual focus or this is a submenu/subdialog trigger.
|
|
193
|
-
data.shouldUseVirtualFocus || isTrigger ? {
|
|
194
|
-
onMouseDown: (e)=>e.preventDefault()
|
|
195
|
-
} : undefined, isDisabled ? undefined : {
|
|
196
|
-
onClick: onClick
|
|
197
|
-
}),
|
|
198
|
-
// 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.
|
|
199
|
-
tabIndex: itemProps.tabIndex != null && isTriggerExpanded && !data.shouldUseVirtualFocus ? -1 : itemProps.tabIndex
|
|
200
|
-
},
|
|
201
|
-
labelProps: {
|
|
202
|
-
id: labelId
|
|
203
|
-
},
|
|
204
|
-
descriptionProps: {
|
|
205
|
-
id: descriptionId
|
|
206
|
-
},
|
|
207
|
-
keyboardShortcutProps: {
|
|
208
|
-
id: keyboardId
|
|
209
|
-
},
|
|
210
|
-
isFocused: isFocused,
|
|
211
|
-
isFocusVisible: isFocused && selectionManager.isFocused && (0, $7Kjv5$isFocusVisible)() && !isTriggerExpanded,
|
|
212
|
-
isSelected: isSelected,
|
|
213
|
-
isPressed: isPressed,
|
|
214
|
-
isDisabled: isDisabled
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
export {$a2e5df62f93c7633$export$9d32628fc2aea7da as useMenuItem};
|
|
220
|
-
//# sourceMappingURL=useMenuItem.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"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","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} from '@react-types/shared';\nimport {filterDOMProps, getEventTarget, handleLinkClick, mergeProps, useLinkProps, useRouter, useSlotId} from '@react-aria/utils';\nimport {getItemCount} from '@react-stately/collections';\nimport {isFocusVisible, setInteractionModality, useFocusable, useHover, useKeyboard, usePress} from '@react-aria/interactions';\nimport {menuData} from './utils';\nimport {MouseEvent, useRef} from 'react';\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 * @deprecated - use shouldCloseOnSelect instead.\n */\n closeOnSelect?: boolean,\n\n /** Whether the menu should close when the menu item is selected. */\n shouldCloseOnSelect?: 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 /** Identifies the element(s) that describe the menu item. */\n 'aria-describedby'?: 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 shouldCloseOnSelect,\n isVirtualized,\n 'aria-haspopup': hasPopup,\n onPressStart,\n onPressUp: pressUpProp,\n onPress,\n onPressChange: pressChangeProp,\n onPressEnd,\n onClick: onClickProp,\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 = () => {\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\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': [props['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 let index = Number(item?.index);\n ariaProps['aria-posinset'] = Number.isNaN(index) ? undefined : index + 1;\n ariaProps['aria-setsize'] = getItemCount(state.collection);\n }\n\n let isPressedRef = useRef(false);\n let onPressChange = (isPressed: boolean) => {\n pressChangeProp?.(isPressed);\n isPressedRef.current = isPressed;\n };\n\n let interaction = useRef<{pointerType: string, key?: string} | null>(null);\n let onPressUp = (e: PressEvent) => {\n if (e.pointerType !== 'keyboard') {\n interaction.current = {pointerType: e.pointerType};\n }\n\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 if (!isPressedRef.current) {\n (e.target as HTMLElement).click();\n }\n }\n\n pressUpProp?.(e);\n };\n\n let onClick = (e: MouseEvent<FocusableElement>) => {\n onClickProp?.(e);\n performAction();\n handleLinkClick(e, router, item!.props.href, item?.props.routerOptions);\n\n let shouldClose = interaction.current?.pointerType === 'keyboard'\n // Always close when pressing Enter key, or if item is not selectable.\n ? interaction.current?.key === 'Enter' || selectionManager.selectionMode === 'none' || selectionManager.isLink(key)\n // Close except if multi-select is enabled.\n : selectionManager.selectionMode !== 'multiple' || selectionManager.isLink(key);\n\n\n shouldClose = shouldCloseOnSelect ?? closeOnSelect ?? shouldClose;\n\n if (onClose && !isTrigger && shouldClose) {\n onClose();\n }\n\n interaction.current = null;\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 interaction.current = {pointerType: 'keyboard', key: ' '};\n (getEventTarget(e) as HTMLElement).click();\n\n // click above sets modality to \"virtual\", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus\n // to the newly opened submenu's first item.\n setInteractionModality('keyboard');\n break;\n case 'Enter':\n interaction.current = {pointerType: 'keyboard', key: 'Enter'};\n\n // Trigger click unless this is a link. Links trigger click natively.\n if ((getEventTarget(e) as HTMLElement).tagName !== 'A') {\n (getEventTarget(e) as HTMLElement).click();\n }\n\n // click above sets modality to \"virtual\", need to set interaction modality back to 'keyboard' so focusSafely calls properly move focus\n // to the newly opened submenu's first item.\n setInteractionModality('keyboard');\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 {focusableProps} = useFocusable({onBlur, onFocus, onFocusChange}, ref);\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 focusableProps,\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 isDisabled ? undefined : {onClick}\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.module.js.map"}
|
|
@@ -1,43 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
package/dist/useMenuSection.mjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
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
|
|
@@ -1,38 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|