@react-spectrum/menu 3.0.0-alpha.1 → 3.0.0-nightly-4980928d3-240906
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/README.md +1 -1
- package/dist/ActionMenu.main.js +70 -0
- package/dist/ActionMenu.main.js.map +1 -0
- package/dist/ActionMenu.mjs +65 -0
- package/dist/ActionMenu.module.js +65 -0
- package/dist/ActionMenu.module.js.map +1 -0
- package/dist/ContextualHelpTrigger.main.js +190 -0
- package/dist/ContextualHelpTrigger.main.js.map +1 -0
- package/dist/ContextualHelpTrigger.mjs +185 -0
- package/dist/ContextualHelpTrigger.module.js +185 -0
- package/dist/ContextualHelpTrigger.module.js.map +1 -0
- package/dist/Menu.main.js +241 -0
- package/dist/Menu.main.js.map +1 -0
- package/dist/Menu.mjs +235 -0
- package/dist/Menu.module.js +235 -0
- package/dist/Menu.module.js.map +1 -0
- package/dist/MenuItem.main.js +148 -0
- package/dist/MenuItem.main.js.map +1 -0
- package/dist/MenuItem.mjs +143 -0
- package/dist/MenuItem.module.js +143 -0
- package/dist/MenuItem.module.js.map +1 -0
- package/dist/MenuSection.main.js +80 -0
- package/dist/MenuSection.main.js.map +1 -0
- package/dist/MenuSection.mjs +75 -0
- package/dist/MenuSection.module.js +75 -0
- package/dist/MenuSection.module.js.map +1 -0
- package/dist/MenuTrigger.main.js +119 -0
- package/dist/MenuTrigger.main.js.map +1 -0
- package/dist/MenuTrigger.mjs +114 -0
- package/dist/MenuTrigger.module.js +114 -0
- package/dist/MenuTrigger.module.js.map +1 -0
- package/dist/SubmenuTrigger.main.js +152 -0
- package/dist/SubmenuTrigger.main.js.map +1 -0
- package/dist/SubmenuTrigger.mjs +147 -0
- package/dist/SubmenuTrigger.module.js +147 -0
- package/dist/SubmenuTrigger.module.js.map +1 -0
- package/dist/ar-AE.main.js +8 -0
- package/dist/ar-AE.main.js.map +1 -0
- package/dist/ar-AE.mjs +10 -0
- package/dist/ar-AE.module.js +10 -0
- package/dist/ar-AE.module.js.map +1 -0
- package/dist/bg-BG.main.js +8 -0
- package/dist/bg-BG.main.js.map +1 -0
- package/dist/bg-BG.mjs +10 -0
- package/dist/bg-BG.module.js +10 -0
- package/dist/bg-BG.module.js.map +1 -0
- package/dist/context.main.js +43 -0
- package/dist/context.main.js.map +1 -0
- package/dist/context.mjs +29 -0
- package/dist/context.module.js +29 -0
- package/dist/context.module.js.map +1 -0
- package/dist/contextualhelp_vars_css.main.js +23 -0
- package/dist/contextualhelp_vars_css.main.js.map +1 -0
- package/dist/contextualhelp_vars_css.mjs +25 -0
- package/dist/contextualhelp_vars_css.module.js +25 -0
- package/dist/contextualhelp_vars_css.module.js.map +1 -0
- package/dist/cs-CZ.main.js +8 -0
- package/dist/cs-CZ.main.js.map +1 -0
- package/dist/cs-CZ.mjs +10 -0
- package/dist/cs-CZ.module.js +10 -0
- package/dist/cs-CZ.module.js.map +1 -0
- package/dist/da-DK.main.js +8 -0
- package/dist/da-DK.main.js.map +1 -0
- package/dist/da-DK.mjs +10 -0
- package/dist/da-DK.module.js +10 -0
- package/dist/da-DK.module.js.map +1 -0
- package/dist/de-DE.main.js +8 -0
- package/dist/de-DE.main.js.map +1 -0
- package/dist/de-DE.mjs +10 -0
- package/dist/de-DE.module.js +10 -0
- package/dist/de-DE.module.js.map +1 -0
- package/dist/el-GR.main.js +8 -0
- package/dist/el-GR.main.js.map +1 -0
- package/dist/el-GR.mjs +10 -0
- package/dist/el-GR.module.js +10 -0
- package/dist/el-GR.module.js.map +1 -0
- package/dist/en-US.main.js +8 -0
- package/dist/en-US.main.js.map +1 -0
- package/dist/en-US.mjs +10 -0
- package/dist/en-US.module.js +10 -0
- package/dist/en-US.module.js.map +1 -0
- package/dist/es-ES.main.js +8 -0
- package/dist/es-ES.main.js.map +1 -0
- package/dist/es-ES.mjs +10 -0
- package/dist/es-ES.module.js +10 -0
- package/dist/es-ES.module.js.map +1 -0
- package/dist/et-EE.main.js +8 -0
- package/dist/et-EE.main.js.map +1 -0
- package/dist/et-EE.mjs +10 -0
- package/dist/et-EE.module.js +10 -0
- package/dist/et-EE.module.js.map +1 -0
- package/dist/fi-FI.main.js +8 -0
- package/dist/fi-FI.main.js.map +1 -0
- package/dist/fi-FI.mjs +10 -0
- package/dist/fi-FI.module.js +10 -0
- package/dist/fi-FI.module.js.map +1 -0
- package/dist/fr-FR.main.js +8 -0
- package/dist/fr-FR.main.js.map +1 -0
- package/dist/fr-FR.mjs +10 -0
- package/dist/fr-FR.module.js +10 -0
- package/dist/fr-FR.module.js.map +1 -0
- package/dist/he-IL.main.js +8 -0
- package/dist/he-IL.main.js.map +1 -0
- package/dist/he-IL.mjs +10 -0
- package/dist/he-IL.module.js +10 -0
- package/dist/he-IL.module.js.map +1 -0
- package/dist/hr-HR.main.js +8 -0
- package/dist/hr-HR.main.js.map +1 -0
- package/dist/hr-HR.mjs +10 -0
- package/dist/hr-HR.module.js +10 -0
- package/dist/hr-HR.module.js.map +1 -0
- package/dist/hu-HU.main.js +8 -0
- package/dist/hu-HU.main.js.map +1 -0
- package/dist/hu-HU.mjs +10 -0
- package/dist/hu-HU.module.js +10 -0
- package/dist/hu-HU.module.js.map +1 -0
- package/dist/import.mjs +28 -0
- package/dist/intlStrings.main.js +108 -0
- package/dist/intlStrings.main.js.map +1 -0
- package/dist/intlStrings.mjs +110 -0
- package/dist/intlStrings.module.js +110 -0
- package/dist/intlStrings.module.js.map +1 -0
- package/dist/it-IT.main.js +8 -0
- package/dist/it-IT.main.js.map +1 -0
- package/dist/it-IT.mjs +10 -0
- package/dist/it-IT.module.js +10 -0
- package/dist/it-IT.module.js.map +1 -0
- package/dist/ja-JP.main.js +8 -0
- package/dist/ja-JP.main.js.map +1 -0
- package/dist/ja-JP.mjs +10 -0
- package/dist/ja-JP.module.js +10 -0
- package/dist/ja-JP.module.js.map +1 -0
- package/dist/ko-KR.main.js +8 -0
- package/dist/ko-KR.main.js.map +1 -0
- package/dist/ko-KR.mjs +10 -0
- package/dist/ko-KR.module.js +10 -0
- package/dist/ko-KR.module.js.map +1 -0
- package/dist/lt-LT.main.js +8 -0
- package/dist/lt-LT.main.js.map +1 -0
- package/dist/lt-LT.mjs +10 -0
- package/dist/lt-LT.module.js +10 -0
- package/dist/lt-LT.module.js.map +1 -0
- package/dist/lv-LV.main.js +8 -0
- package/dist/lv-LV.main.js.map +1 -0
- package/dist/lv-LV.mjs +10 -0
- package/dist/lv-LV.module.js +10 -0
- package/dist/lv-LV.module.js.map +1 -0
- package/dist/main.js +27 -364
- package/dist/main.js.map +1 -0
- package/dist/menu_vars_css.main.js +177 -0
- package/dist/menu_vars_css.main.js.map +1 -0
- package/dist/menu_vars_css.mjs +179 -0
- package/dist/menu_vars_css.module.js +179 -0
- package/dist/menu_vars_css.module.js.map +1 -0
- package/dist/module.js +19 -304
- package/dist/module.js.map +1 -0
- package/dist/nb-NO.main.js +8 -0
- package/dist/nb-NO.main.js.map +1 -0
- package/dist/nb-NO.mjs +10 -0
- package/dist/nb-NO.module.js +10 -0
- package/dist/nb-NO.module.js.map +1 -0
- package/dist/nl-NL.main.js +8 -0
- package/dist/nl-NL.main.js.map +1 -0
- package/dist/nl-NL.mjs +10 -0
- package/dist/nl-NL.module.js +10 -0
- package/dist/nl-NL.module.js.map +1 -0
- package/dist/pl-PL.main.js +8 -0
- package/dist/pl-PL.main.js.map +1 -0
- package/dist/pl-PL.mjs +10 -0
- package/dist/pl-PL.module.js +10 -0
- package/dist/pl-PL.module.js.map +1 -0
- package/dist/pt-BR.main.js +8 -0
- package/dist/pt-BR.main.js.map +1 -0
- package/dist/pt-BR.mjs +10 -0
- package/dist/pt-BR.module.js +10 -0
- package/dist/pt-BR.module.js.map +1 -0
- package/dist/pt-PT.main.js +8 -0
- package/dist/pt-PT.main.js.map +1 -0
- package/dist/pt-PT.mjs +10 -0
- package/dist/pt-PT.module.js +10 -0
- package/dist/pt-PT.module.js.map +1 -0
- package/dist/ro-RO.main.js +8 -0
- package/dist/ro-RO.main.js.map +1 -0
- package/dist/ro-RO.mjs +10 -0
- package/dist/ro-RO.module.js +10 -0
- package/dist/ro-RO.module.js.map +1 -0
- package/dist/ru-RU.main.js +8 -0
- package/dist/ru-RU.main.js.map +1 -0
- package/dist/ru-RU.mjs +10 -0
- package/dist/ru-RU.module.js +10 -0
- package/dist/ru-RU.module.js.map +1 -0
- package/dist/sk-SK.main.js +8 -0
- package/dist/sk-SK.main.js.map +1 -0
- package/dist/sk-SK.mjs +10 -0
- package/dist/sk-SK.module.js +10 -0
- package/dist/sk-SK.module.js.map +1 -0
- package/dist/sl-SI.main.js +8 -0
- package/dist/sl-SI.main.js.map +1 -0
- package/dist/sl-SI.mjs +10 -0
- package/dist/sl-SI.module.js +10 -0
- package/dist/sl-SI.module.js.map +1 -0
- package/dist/sr-SP.main.js +8 -0
- package/dist/sr-SP.main.js.map +1 -0
- package/dist/sr-SP.mjs +10 -0
- package/dist/sr-SP.module.js +10 -0
- package/dist/sr-SP.module.js.map +1 -0
- package/dist/sv-SE.main.js +8 -0
- package/dist/sv-SE.main.js.map +1 -0
- package/dist/sv-SE.mjs +10 -0
- package/dist/sv-SE.module.js +10 -0
- package/dist/sv-SE.module.js.map +1 -0
- package/dist/tr-TR.main.js +8 -0
- package/dist/tr-TR.main.js.map +1 -0
- package/dist/tr-TR.mjs +10 -0
- package/dist/tr-TR.module.js +10 -0
- package/dist/tr-TR.module.js.map +1 -0
- package/dist/types.d.ts +39 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/uk-UA.main.js +8 -0
- package/dist/uk-UA.main.js.map +1 -0
- package/dist/uk-UA.mjs +10 -0
- package/dist/uk-UA.module.js +10 -0
- package/dist/uk-UA.module.js.map +1 -0
- package/dist/vars.89a944d6.css +568 -0
- package/dist/vars.89a944d6.css.map +1 -0
- package/dist/vars.c9740d19.css +30 -0
- package/dist/vars.c9740d19.css.map +1 -0
- package/dist/zh-CN.main.js +8 -0
- package/dist/zh-CN.main.js.map +1 -0
- package/dist/zh-CN.mjs +10 -0
- package/dist/zh-CN.module.js +10 -0
- package/dist/zh-CN.module.js.map +1 -0
- package/dist/zh-TW.main.js +8 -0
- package/dist/zh-TW.main.js.map +1 -0
- package/dist/zh-TW.mjs +10 -0
- package/dist/zh-TW.module.js +10 -0
- package/dist/zh-TW.module.js.map +1 -0
- package/package.json +40 -31
- package/src/ActionMenu.tsx +61 -0
- package/src/ContextualHelpTrigger.tsx +193 -0
- package/src/Menu.tsx +221 -0
- package/src/MenuItem.tsx +155 -0
- package/src/MenuSection.tsx +99 -0
- package/src/MenuTrigger.tsx +115 -0
- package/src/SubmenuTrigger.tsx +154 -0
- package/src/context.ts +63 -0
- package/src/index.ts +23 -0
- package/src/overlays.css +32 -0
- package/LICENSE +0 -201
- package/dist/main.css +0 -295
package/dist/Menu.mjs
ADDED
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import $4oXwn$intlStringsmodulejs from "./intlStrings.mjs";
|
|
2
|
+
import {MenuContext as $d94604d52c3e3feb$export$c7e742effb1c51e2, MenuStateContext as $d94604d52c3e3feb$export$24aad8519b95b41b, useMenuStateContext as $d94604d52c3e3feb$export$efa3856fc0e85e7f} from "./context.mjs";
|
|
3
|
+
import {MenuItem as $48fb8f5e1202c980$export$2ce376c2cc3355c8} from "./MenuItem.mjs";
|
|
4
|
+
import {MenuSection as $b966e606890cc5ca$export$4b1545b4f2016d26} from "./MenuSection.mjs";
|
|
5
|
+
import "./vars.89a944d6.css";
|
|
6
|
+
import $4oXwn$menu_vars_cssmodulejs from "./menu_vars_css.mjs";
|
|
7
|
+
import {ActionButton as $4oXwn$ActionButton} from "@react-spectrum/button";
|
|
8
|
+
import $4oXwn$spectrumiconsuiArrowDownSmall from "@spectrum-icons/ui/ArrowDownSmall";
|
|
9
|
+
import {useDOMRef as $4oXwn$useDOMRef, useStyleProps as $4oXwn$useStyleProps, classNames as $4oXwn$classNames, useIsMobileDevice as $4oXwn$useIsMobileDevice} from "@react-spectrum/utils";
|
|
10
|
+
import {FocusScope as $4oXwn$FocusScope} from "@react-aria/focus";
|
|
11
|
+
import {mergeProps as $4oXwn$mergeProps, useSyncRef as $4oXwn$useSyncRef, useSlotId as $4oXwn$useSlotId, useLayoutEffect as $4oXwn$useLayoutEffect} from "@react-aria/utils";
|
|
12
|
+
import $4oXwn$react, {useContext as $4oXwn$useContext, useState as $4oXwn$useState, useRef as $4oXwn$useRef, useEffect as $4oXwn$useEffect} from "react";
|
|
13
|
+
import {useInteractOutside as $4oXwn$useInteractOutside} from "@react-aria/interactions";
|
|
14
|
+
import {useLocalizedStringFormatter as $4oXwn$useLocalizedStringFormatter, useLocale as $4oXwn$useLocale} from "@react-aria/i18n";
|
|
15
|
+
import {useMenu as $4oXwn$useMenu} from "@react-aria/menu";
|
|
16
|
+
import {useTreeState as $4oXwn$useTreeState} from "@react-stately/tree";
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
function $parcel$interopDefault(a) {
|
|
20
|
+
return a && a.__esModule ? a.default : a;
|
|
21
|
+
}
|
|
22
|
+
/*
|
|
23
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
24
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
25
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
26
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
27
|
+
*
|
|
28
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
29
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
30
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
31
|
+
* governing permissions and limitations under the License.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
function $49b26f4b606348f6$var$Menu(props, ref) {
|
|
48
|
+
let isSubmenu = true;
|
|
49
|
+
let contextProps = (0, $4oXwn$useContext)((0, $d94604d52c3e3feb$export$c7e742effb1c51e2));
|
|
50
|
+
let parentMenuContext = (0, $d94604d52c3e3feb$export$efa3856fc0e85e7f)();
|
|
51
|
+
let { rootMenuTriggerState: rootMenuTriggerState, state: parentMenuTreeState } = parentMenuContext || {
|
|
52
|
+
rootMenuTriggerState: contextProps.state
|
|
53
|
+
};
|
|
54
|
+
if (!parentMenuContext) isSubmenu = false;
|
|
55
|
+
let completeProps = {
|
|
56
|
+
...(0, $4oXwn$mergeProps)(contextProps, props)
|
|
57
|
+
};
|
|
58
|
+
let domRef = (0, $4oXwn$useDOMRef)(ref);
|
|
59
|
+
let [popoverContainer, setPopoverContainer] = (0, $4oXwn$useState)(null);
|
|
60
|
+
let trayContainerRef = (0, $4oXwn$useRef)(null);
|
|
61
|
+
let state = (0, $4oXwn$useTreeState)(completeProps);
|
|
62
|
+
let submenuRef = (0, $4oXwn$useRef)(null);
|
|
63
|
+
let { menuProps: menuProps } = (0, $4oXwn$useMenu)(completeProps, state, domRef);
|
|
64
|
+
let { styleProps: styleProps } = (0, $4oXwn$useStyleProps)(completeProps);
|
|
65
|
+
(0, $4oXwn$useSyncRef)(contextProps, domRef);
|
|
66
|
+
let [leftOffset, setLeftOffset] = (0, $4oXwn$useState)({
|
|
67
|
+
left: 0
|
|
68
|
+
});
|
|
69
|
+
let prevPopoverContainer = (0, $4oXwn$useRef)(null);
|
|
70
|
+
(0, $4oXwn$useEffect)(()=>{
|
|
71
|
+
if (popoverContainer && prevPopoverContainer.current !== popoverContainer && leftOffset.left === 0) {
|
|
72
|
+
prevPopoverContainer.current = popoverContainer;
|
|
73
|
+
let { left: left } = popoverContainer.getBoundingClientRect();
|
|
74
|
+
setLeftOffset({
|
|
75
|
+
left: -1 * left
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}, [
|
|
79
|
+
leftOffset,
|
|
80
|
+
popoverContainer
|
|
81
|
+
]);
|
|
82
|
+
var _contextProps_submenuLevel;
|
|
83
|
+
let menuLevel = (_contextProps_submenuLevel = contextProps.submenuLevel) !== null && _contextProps_submenuLevel !== void 0 ? _contextProps_submenuLevel : -1;
|
|
84
|
+
let hasOpenSubmenu = state.collection.getItem(rootMenuTriggerState === null || rootMenuTriggerState === void 0 ? void 0 : rootMenuTriggerState.expandedKeysStack[menuLevel + 1]) != null;
|
|
85
|
+
(0, $4oXwn$useInteractOutside)({
|
|
86
|
+
ref: domRef,
|
|
87
|
+
onInteractOutside: (e)=>{
|
|
88
|
+
var _trayContainerRef_current;
|
|
89
|
+
if (!(popoverContainer === null || popoverContainer === void 0 ? void 0 : popoverContainer.contains(e.target)) && !((_trayContainerRef_current = trayContainerRef.current) === null || _trayContainerRef_current === void 0 ? void 0 : _trayContainerRef_current.contains(e.target))) rootMenuTriggerState.close();
|
|
90
|
+
},
|
|
91
|
+
isDisabled: isSubmenu || !hasOpenSubmenu
|
|
92
|
+
});
|
|
93
|
+
return /*#__PURE__*/ (0, $4oXwn$react).createElement((0, $d94604d52c3e3feb$export$24aad8519b95b41b).Provider, {
|
|
94
|
+
value: {
|
|
95
|
+
popoverContainer: popoverContainer,
|
|
96
|
+
trayContainerRef: trayContainerRef,
|
|
97
|
+
menu: domRef,
|
|
98
|
+
submenu: submenuRef,
|
|
99
|
+
rootMenuTriggerState: rootMenuTriggerState,
|
|
100
|
+
state: state
|
|
101
|
+
}
|
|
102
|
+
}, /*#__PURE__*/ (0, $4oXwn$react).createElement("div", {
|
|
103
|
+
style: {
|
|
104
|
+
height: hasOpenSubmenu ? '100%' : undefined
|
|
105
|
+
},
|
|
106
|
+
ref: trayContainerRef
|
|
107
|
+
}), /*#__PURE__*/ (0, $4oXwn$react).createElement((0, $4oXwn$FocusScope), null, /*#__PURE__*/ (0, $4oXwn$react).createElement($49b26f4b606348f6$export$3dfe97b5c32d8d8c, {
|
|
108
|
+
onBackButtonPress: contextProps.onBackButtonPress,
|
|
109
|
+
hasOpenSubmenu: hasOpenSubmenu,
|
|
110
|
+
isSubmenu: isSubmenu,
|
|
111
|
+
parentMenuTreeState: parentMenuTreeState,
|
|
112
|
+
rootMenuTriggerState: rootMenuTriggerState,
|
|
113
|
+
menuRef: domRef
|
|
114
|
+
}, /*#__PURE__*/ (0, $4oXwn$react).createElement("div", {
|
|
115
|
+
...menuProps,
|
|
116
|
+
style: (0, $4oXwn$mergeProps)(styleProps.style, menuProps.style),
|
|
117
|
+
ref: domRef,
|
|
118
|
+
className: (0, $4oXwn$classNames)((0, ($parcel$interopDefault($4oXwn$menu_vars_cssmodulejs))), 'spectrum-Menu', styleProps.className)
|
|
119
|
+
}, [
|
|
120
|
+
...state.collection
|
|
121
|
+
].map((item)=>{
|
|
122
|
+
if (item.type === 'section') return /*#__PURE__*/ (0, $4oXwn$react).createElement((0, $b966e606890cc5ca$export$4b1545b4f2016d26), {
|
|
123
|
+
key: item.key,
|
|
124
|
+
item: item,
|
|
125
|
+
state: state
|
|
126
|
+
});
|
|
127
|
+
let menuItem = /*#__PURE__*/ (0, $4oXwn$react).createElement((0, $48fb8f5e1202c980$export$2ce376c2cc3355c8), {
|
|
128
|
+
key: item.key,
|
|
129
|
+
item: item,
|
|
130
|
+
state: state
|
|
131
|
+
});
|
|
132
|
+
if (item.wrapper) menuItem = item.wrapper(menuItem);
|
|
133
|
+
return menuItem;
|
|
134
|
+
}))), (rootMenuTriggerState === null || rootMenuTriggerState === void 0 ? void 0 : rootMenuTriggerState.isOpen) && /*#__PURE__*/ (0, $4oXwn$react).createElement("div", {
|
|
135
|
+
ref: setPopoverContainer,
|
|
136
|
+
style: {
|
|
137
|
+
width: '100vw',
|
|
138
|
+
position: 'absolute',
|
|
139
|
+
top: -5,
|
|
140
|
+
...leftOffset
|
|
141
|
+
}
|
|
142
|
+
})));
|
|
143
|
+
}
|
|
144
|
+
function $49b26f4b606348f6$export$3dfe97b5c32d8d8c(props) {
|
|
145
|
+
var _parentMenuTreeState_collection_getItem;
|
|
146
|
+
let { children: children, isSubmenu: isSubmenu, hasOpenSubmenu: hasOpenSubmenu, parentMenuTreeState: parentMenuTreeState, rootMenuTriggerState: rootMenuTriggerState, onBackButtonPress: onBackButtonPress, wrapperKeyDown: wrapperKeyDown, menuRef: menuRef } = props;
|
|
147
|
+
let stringFormatter = (0, $4oXwn$useLocalizedStringFormatter)((0, ($parcel$interopDefault($4oXwn$intlStringsmodulejs))), '@react-spectrum/menu');
|
|
148
|
+
let backButtonText = parentMenuTreeState === null || parentMenuTreeState === void 0 ? void 0 : (_parentMenuTreeState_collection_getItem = parentMenuTreeState.collection.getItem(rootMenuTriggerState === null || rootMenuTriggerState === void 0 ? void 0 : rootMenuTriggerState.expandedKeysStack.slice(-1)[0])) === null || _parentMenuTreeState_collection_getItem === void 0 ? void 0 : _parentMenuTreeState_collection_getItem.textValue;
|
|
149
|
+
let backButtonLabel = stringFormatter.format('backButton', {
|
|
150
|
+
prevMenuButton: backButtonText
|
|
151
|
+
});
|
|
152
|
+
let headingId = (0, $4oXwn$useSlotId)();
|
|
153
|
+
let isMobile = (0, $4oXwn$useIsMobileDevice)();
|
|
154
|
+
let { direction: direction } = (0, $4oXwn$useLocale)();
|
|
155
|
+
let [traySubmenuAnimation, setTraySubmenuAnimation] = (0, $4oXwn$useState)('');
|
|
156
|
+
(0, $4oXwn$useLayoutEffect)(()=>{
|
|
157
|
+
if (!hasOpenSubmenu) setTraySubmenuAnimation('spectrum-TraySubmenu-enter');
|
|
158
|
+
}, [
|
|
159
|
+
hasOpenSubmenu,
|
|
160
|
+
isMobile
|
|
161
|
+
]);
|
|
162
|
+
let timeoutRef = (0, $4oXwn$useRef)(null);
|
|
163
|
+
let handleBackButtonPress = ()=>{
|
|
164
|
+
setTraySubmenuAnimation('spectrum-TraySubmenu-exit');
|
|
165
|
+
timeoutRef.current = setTimeout(()=>{
|
|
166
|
+
onBackButtonPress();
|
|
167
|
+
}, 220); // Matches transition duration
|
|
168
|
+
};
|
|
169
|
+
(0, $4oXwn$useEffect)(()=>{
|
|
170
|
+
return ()=>{
|
|
171
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
172
|
+
};
|
|
173
|
+
}, []);
|
|
174
|
+
// When opening submenu in tray, focus the first item in the submenu after animation completes
|
|
175
|
+
// This fixes an issue with iOS VO where the closed submenu was getting focus
|
|
176
|
+
let focusTimeoutRef = (0, $4oXwn$useRef)(null);
|
|
177
|
+
(0, $4oXwn$useEffect)(()=>{
|
|
178
|
+
if (isMobile && isSubmenu && !hasOpenSubmenu && traySubmenuAnimation === 'spectrum-TraySubmenu-enter') focusTimeoutRef.current = setTimeout(()=>{
|
|
179
|
+
let firstItem = menuRef.current.querySelector('[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]');
|
|
180
|
+
firstItem === null || firstItem === void 0 ? void 0 : firstItem.focus();
|
|
181
|
+
}, 220);
|
|
182
|
+
return ()=>{
|
|
183
|
+
if (focusTimeoutRef.current) clearTimeout(focusTimeoutRef.current);
|
|
184
|
+
};
|
|
185
|
+
}, [
|
|
186
|
+
hasOpenSubmenu,
|
|
187
|
+
isMobile,
|
|
188
|
+
isSubmenu,
|
|
189
|
+
menuRef,
|
|
190
|
+
traySubmenuAnimation
|
|
191
|
+
]);
|
|
192
|
+
return /*#__PURE__*/ (0, $4oXwn$react).createElement((0, $4oXwn$react).Fragment, null, /*#__PURE__*/ (0, $4oXwn$react).createElement("div", {
|
|
193
|
+
role: headingId ? 'dialog' : undefined,
|
|
194
|
+
"aria-labelledby": headingId,
|
|
195
|
+
"aria-hidden": isMobile && hasOpenSubmenu,
|
|
196
|
+
"data-testid": "menu-wrapper",
|
|
197
|
+
className: (0, $4oXwn$classNames)((0, ($parcel$interopDefault($4oXwn$menu_vars_cssmodulejs))), 'spectrum-Menu-wrapper', {
|
|
198
|
+
'spectrum-Menu-wrapper--isMobile': isMobile,
|
|
199
|
+
'is-expanded': hasOpenSubmenu,
|
|
200
|
+
[traySubmenuAnimation]: isMobile
|
|
201
|
+
})
|
|
202
|
+
}, /*#__PURE__*/ (0, $4oXwn$react).createElement("div", {
|
|
203
|
+
role: "presentation",
|
|
204
|
+
className: (0, $4oXwn$classNames)((0, ($parcel$interopDefault($4oXwn$menu_vars_cssmodulejs))), 'spectrum-Submenu-wrapper', {
|
|
205
|
+
'spectrum-Submenu-wrapper--isMobile': isMobile
|
|
206
|
+
}),
|
|
207
|
+
onKeyDown: wrapperKeyDown
|
|
208
|
+
}, isMobile && isSubmenu && !hasOpenSubmenu && /*#__PURE__*/ (0, $4oXwn$react).createElement("div", {
|
|
209
|
+
className: (0, $4oXwn$classNames)((0, ($parcel$interopDefault($4oXwn$menu_vars_cssmodulejs))), 'spectrum-Submenu-headingWrapper')
|
|
210
|
+
}, /*#__PURE__*/ (0, $4oXwn$react).createElement((0, $4oXwn$ActionButton), {
|
|
211
|
+
"aria-label": backButtonLabel,
|
|
212
|
+
isQuiet: true,
|
|
213
|
+
onPress: handleBackButtonPress
|
|
214
|
+
}, direction === 'rtl' ? /*#__PURE__*/ (0, $4oXwn$react).createElement((0, $4oXwn$spectrumiconsuiArrowDownSmall), {
|
|
215
|
+
UNSAFE_style: {
|
|
216
|
+
rotate: '270deg'
|
|
217
|
+
}
|
|
218
|
+
}) : /*#__PURE__*/ (0, $4oXwn$react).createElement((0, $4oXwn$spectrumiconsuiArrowDownSmall), {
|
|
219
|
+
UNSAFE_style: {
|
|
220
|
+
rotate: '90deg'
|
|
221
|
+
}
|
|
222
|
+
})), /*#__PURE__*/ (0, $4oXwn$react).createElement("h1", {
|
|
223
|
+
id: headingId,
|
|
224
|
+
className: (0, $4oXwn$classNames)((0, ($parcel$interopDefault($4oXwn$menu_vars_cssmodulejs))), 'spectrum-Submenu-heading')
|
|
225
|
+
}, backButtonText)), children)));
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Menus display a list of actions or options that a user can choose.
|
|
229
|
+
*/ // forwardRef doesn't support generic parameters, so cast the result to the correct type
|
|
230
|
+
// https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref
|
|
231
|
+
const $49b26f4b606348f6$export$d9b273488cd8ce6f = /*#__PURE__*/ (0, $4oXwn$react).forwardRef($49b26f4b606348f6$var$Menu);
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
export {$49b26f4b606348f6$export$3dfe97b5c32d8d8c as TrayHeaderWrapper, $49b26f4b606348f6$export$d9b273488cd8ce6f as Menu};
|
|
235
|
+
//# sourceMappingURL=Menu.module.js.map
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import $4oXwn$intlStringsmodulejs from "./intlStrings.module.js";
|
|
2
|
+
import {MenuContext as $d94604d52c3e3feb$export$c7e742effb1c51e2, MenuStateContext as $d94604d52c3e3feb$export$24aad8519b95b41b, useMenuStateContext as $d94604d52c3e3feb$export$efa3856fc0e85e7f} from "./context.module.js";
|
|
3
|
+
import {MenuItem as $48fb8f5e1202c980$export$2ce376c2cc3355c8} from "./MenuItem.module.js";
|
|
4
|
+
import {MenuSection as $b966e606890cc5ca$export$4b1545b4f2016d26} from "./MenuSection.module.js";
|
|
5
|
+
import "./vars.89a944d6.css";
|
|
6
|
+
import $4oXwn$menu_vars_cssmodulejs from "./menu_vars_css.module.js";
|
|
7
|
+
import {ActionButton as $4oXwn$ActionButton} from "@react-spectrum/button";
|
|
8
|
+
import $4oXwn$spectrumiconsuiArrowDownSmall from "@spectrum-icons/ui/ArrowDownSmall";
|
|
9
|
+
import {useDOMRef as $4oXwn$useDOMRef, useStyleProps as $4oXwn$useStyleProps, classNames as $4oXwn$classNames, useIsMobileDevice as $4oXwn$useIsMobileDevice} from "@react-spectrum/utils";
|
|
10
|
+
import {FocusScope as $4oXwn$FocusScope} from "@react-aria/focus";
|
|
11
|
+
import {mergeProps as $4oXwn$mergeProps, useSyncRef as $4oXwn$useSyncRef, useSlotId as $4oXwn$useSlotId, useLayoutEffect as $4oXwn$useLayoutEffect} from "@react-aria/utils";
|
|
12
|
+
import $4oXwn$react, {useContext as $4oXwn$useContext, useState as $4oXwn$useState, useRef as $4oXwn$useRef, useEffect as $4oXwn$useEffect} from "react";
|
|
13
|
+
import {useInteractOutside as $4oXwn$useInteractOutside} from "@react-aria/interactions";
|
|
14
|
+
import {useLocalizedStringFormatter as $4oXwn$useLocalizedStringFormatter, useLocale as $4oXwn$useLocale} from "@react-aria/i18n";
|
|
15
|
+
import {useMenu as $4oXwn$useMenu} from "@react-aria/menu";
|
|
16
|
+
import {useTreeState as $4oXwn$useTreeState} from "@react-stately/tree";
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
function $parcel$interopDefault(a) {
|
|
20
|
+
return a && a.__esModule ? a.default : a;
|
|
21
|
+
}
|
|
22
|
+
/*
|
|
23
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
24
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
25
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
26
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
27
|
+
*
|
|
28
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
29
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
30
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
31
|
+
* governing permissions and limitations under the License.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
function $49b26f4b606348f6$var$Menu(props, ref) {
|
|
48
|
+
let isSubmenu = true;
|
|
49
|
+
let contextProps = (0, $4oXwn$useContext)((0, $d94604d52c3e3feb$export$c7e742effb1c51e2));
|
|
50
|
+
let parentMenuContext = (0, $d94604d52c3e3feb$export$efa3856fc0e85e7f)();
|
|
51
|
+
let { rootMenuTriggerState: rootMenuTriggerState, state: parentMenuTreeState } = parentMenuContext || {
|
|
52
|
+
rootMenuTriggerState: contextProps.state
|
|
53
|
+
};
|
|
54
|
+
if (!parentMenuContext) isSubmenu = false;
|
|
55
|
+
let completeProps = {
|
|
56
|
+
...(0, $4oXwn$mergeProps)(contextProps, props)
|
|
57
|
+
};
|
|
58
|
+
let domRef = (0, $4oXwn$useDOMRef)(ref);
|
|
59
|
+
let [popoverContainer, setPopoverContainer] = (0, $4oXwn$useState)(null);
|
|
60
|
+
let trayContainerRef = (0, $4oXwn$useRef)(null);
|
|
61
|
+
let state = (0, $4oXwn$useTreeState)(completeProps);
|
|
62
|
+
let submenuRef = (0, $4oXwn$useRef)(null);
|
|
63
|
+
let { menuProps: menuProps } = (0, $4oXwn$useMenu)(completeProps, state, domRef);
|
|
64
|
+
let { styleProps: styleProps } = (0, $4oXwn$useStyleProps)(completeProps);
|
|
65
|
+
(0, $4oXwn$useSyncRef)(contextProps, domRef);
|
|
66
|
+
let [leftOffset, setLeftOffset] = (0, $4oXwn$useState)({
|
|
67
|
+
left: 0
|
|
68
|
+
});
|
|
69
|
+
let prevPopoverContainer = (0, $4oXwn$useRef)(null);
|
|
70
|
+
(0, $4oXwn$useEffect)(()=>{
|
|
71
|
+
if (popoverContainer && prevPopoverContainer.current !== popoverContainer && leftOffset.left === 0) {
|
|
72
|
+
prevPopoverContainer.current = popoverContainer;
|
|
73
|
+
let { left: left } = popoverContainer.getBoundingClientRect();
|
|
74
|
+
setLeftOffset({
|
|
75
|
+
left: -1 * left
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}, [
|
|
79
|
+
leftOffset,
|
|
80
|
+
popoverContainer
|
|
81
|
+
]);
|
|
82
|
+
var _contextProps_submenuLevel;
|
|
83
|
+
let menuLevel = (_contextProps_submenuLevel = contextProps.submenuLevel) !== null && _contextProps_submenuLevel !== void 0 ? _contextProps_submenuLevel : -1;
|
|
84
|
+
let hasOpenSubmenu = state.collection.getItem(rootMenuTriggerState === null || rootMenuTriggerState === void 0 ? void 0 : rootMenuTriggerState.expandedKeysStack[menuLevel + 1]) != null;
|
|
85
|
+
(0, $4oXwn$useInteractOutside)({
|
|
86
|
+
ref: domRef,
|
|
87
|
+
onInteractOutside: (e)=>{
|
|
88
|
+
var _trayContainerRef_current;
|
|
89
|
+
if (!(popoverContainer === null || popoverContainer === void 0 ? void 0 : popoverContainer.contains(e.target)) && !((_trayContainerRef_current = trayContainerRef.current) === null || _trayContainerRef_current === void 0 ? void 0 : _trayContainerRef_current.contains(e.target))) rootMenuTriggerState.close();
|
|
90
|
+
},
|
|
91
|
+
isDisabled: isSubmenu || !hasOpenSubmenu
|
|
92
|
+
});
|
|
93
|
+
return /*#__PURE__*/ (0, $4oXwn$react).createElement((0, $d94604d52c3e3feb$export$24aad8519b95b41b).Provider, {
|
|
94
|
+
value: {
|
|
95
|
+
popoverContainer: popoverContainer,
|
|
96
|
+
trayContainerRef: trayContainerRef,
|
|
97
|
+
menu: domRef,
|
|
98
|
+
submenu: submenuRef,
|
|
99
|
+
rootMenuTriggerState: rootMenuTriggerState,
|
|
100
|
+
state: state
|
|
101
|
+
}
|
|
102
|
+
}, /*#__PURE__*/ (0, $4oXwn$react).createElement("div", {
|
|
103
|
+
style: {
|
|
104
|
+
height: hasOpenSubmenu ? '100%' : undefined
|
|
105
|
+
},
|
|
106
|
+
ref: trayContainerRef
|
|
107
|
+
}), /*#__PURE__*/ (0, $4oXwn$react).createElement((0, $4oXwn$FocusScope), null, /*#__PURE__*/ (0, $4oXwn$react).createElement($49b26f4b606348f6$export$3dfe97b5c32d8d8c, {
|
|
108
|
+
onBackButtonPress: contextProps.onBackButtonPress,
|
|
109
|
+
hasOpenSubmenu: hasOpenSubmenu,
|
|
110
|
+
isSubmenu: isSubmenu,
|
|
111
|
+
parentMenuTreeState: parentMenuTreeState,
|
|
112
|
+
rootMenuTriggerState: rootMenuTriggerState,
|
|
113
|
+
menuRef: domRef
|
|
114
|
+
}, /*#__PURE__*/ (0, $4oXwn$react).createElement("div", {
|
|
115
|
+
...menuProps,
|
|
116
|
+
style: (0, $4oXwn$mergeProps)(styleProps.style, menuProps.style),
|
|
117
|
+
ref: domRef,
|
|
118
|
+
className: (0, $4oXwn$classNames)((0, ($parcel$interopDefault($4oXwn$menu_vars_cssmodulejs))), 'spectrum-Menu', styleProps.className)
|
|
119
|
+
}, [
|
|
120
|
+
...state.collection
|
|
121
|
+
].map((item)=>{
|
|
122
|
+
if (item.type === 'section') return /*#__PURE__*/ (0, $4oXwn$react).createElement((0, $b966e606890cc5ca$export$4b1545b4f2016d26), {
|
|
123
|
+
key: item.key,
|
|
124
|
+
item: item,
|
|
125
|
+
state: state
|
|
126
|
+
});
|
|
127
|
+
let menuItem = /*#__PURE__*/ (0, $4oXwn$react).createElement((0, $48fb8f5e1202c980$export$2ce376c2cc3355c8), {
|
|
128
|
+
key: item.key,
|
|
129
|
+
item: item,
|
|
130
|
+
state: state
|
|
131
|
+
});
|
|
132
|
+
if (item.wrapper) menuItem = item.wrapper(menuItem);
|
|
133
|
+
return menuItem;
|
|
134
|
+
}))), (rootMenuTriggerState === null || rootMenuTriggerState === void 0 ? void 0 : rootMenuTriggerState.isOpen) && /*#__PURE__*/ (0, $4oXwn$react).createElement("div", {
|
|
135
|
+
ref: setPopoverContainer,
|
|
136
|
+
style: {
|
|
137
|
+
width: '100vw',
|
|
138
|
+
position: 'absolute',
|
|
139
|
+
top: -5,
|
|
140
|
+
...leftOffset
|
|
141
|
+
}
|
|
142
|
+
})));
|
|
143
|
+
}
|
|
144
|
+
function $49b26f4b606348f6$export$3dfe97b5c32d8d8c(props) {
|
|
145
|
+
var _parentMenuTreeState_collection_getItem;
|
|
146
|
+
let { children: children, isSubmenu: isSubmenu, hasOpenSubmenu: hasOpenSubmenu, parentMenuTreeState: parentMenuTreeState, rootMenuTriggerState: rootMenuTriggerState, onBackButtonPress: onBackButtonPress, wrapperKeyDown: wrapperKeyDown, menuRef: menuRef } = props;
|
|
147
|
+
let stringFormatter = (0, $4oXwn$useLocalizedStringFormatter)((0, ($parcel$interopDefault($4oXwn$intlStringsmodulejs))), '@react-spectrum/menu');
|
|
148
|
+
let backButtonText = parentMenuTreeState === null || parentMenuTreeState === void 0 ? void 0 : (_parentMenuTreeState_collection_getItem = parentMenuTreeState.collection.getItem(rootMenuTriggerState === null || rootMenuTriggerState === void 0 ? void 0 : rootMenuTriggerState.expandedKeysStack.slice(-1)[0])) === null || _parentMenuTreeState_collection_getItem === void 0 ? void 0 : _parentMenuTreeState_collection_getItem.textValue;
|
|
149
|
+
let backButtonLabel = stringFormatter.format('backButton', {
|
|
150
|
+
prevMenuButton: backButtonText
|
|
151
|
+
});
|
|
152
|
+
let headingId = (0, $4oXwn$useSlotId)();
|
|
153
|
+
let isMobile = (0, $4oXwn$useIsMobileDevice)();
|
|
154
|
+
let { direction: direction } = (0, $4oXwn$useLocale)();
|
|
155
|
+
let [traySubmenuAnimation, setTraySubmenuAnimation] = (0, $4oXwn$useState)('');
|
|
156
|
+
(0, $4oXwn$useLayoutEffect)(()=>{
|
|
157
|
+
if (!hasOpenSubmenu) setTraySubmenuAnimation('spectrum-TraySubmenu-enter');
|
|
158
|
+
}, [
|
|
159
|
+
hasOpenSubmenu,
|
|
160
|
+
isMobile
|
|
161
|
+
]);
|
|
162
|
+
let timeoutRef = (0, $4oXwn$useRef)(null);
|
|
163
|
+
let handleBackButtonPress = ()=>{
|
|
164
|
+
setTraySubmenuAnimation('spectrum-TraySubmenu-exit');
|
|
165
|
+
timeoutRef.current = setTimeout(()=>{
|
|
166
|
+
onBackButtonPress();
|
|
167
|
+
}, 220); // Matches transition duration
|
|
168
|
+
};
|
|
169
|
+
(0, $4oXwn$useEffect)(()=>{
|
|
170
|
+
return ()=>{
|
|
171
|
+
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
172
|
+
};
|
|
173
|
+
}, []);
|
|
174
|
+
// When opening submenu in tray, focus the first item in the submenu after animation completes
|
|
175
|
+
// This fixes an issue with iOS VO where the closed submenu was getting focus
|
|
176
|
+
let focusTimeoutRef = (0, $4oXwn$useRef)(null);
|
|
177
|
+
(0, $4oXwn$useEffect)(()=>{
|
|
178
|
+
if (isMobile && isSubmenu && !hasOpenSubmenu && traySubmenuAnimation === 'spectrum-TraySubmenu-enter') focusTimeoutRef.current = setTimeout(()=>{
|
|
179
|
+
let firstItem = menuRef.current.querySelector('[role="menuitem"], [role="menuitemcheckbox"], [role="menuitemradio"]');
|
|
180
|
+
firstItem === null || firstItem === void 0 ? void 0 : firstItem.focus();
|
|
181
|
+
}, 220);
|
|
182
|
+
return ()=>{
|
|
183
|
+
if (focusTimeoutRef.current) clearTimeout(focusTimeoutRef.current);
|
|
184
|
+
};
|
|
185
|
+
}, [
|
|
186
|
+
hasOpenSubmenu,
|
|
187
|
+
isMobile,
|
|
188
|
+
isSubmenu,
|
|
189
|
+
menuRef,
|
|
190
|
+
traySubmenuAnimation
|
|
191
|
+
]);
|
|
192
|
+
return /*#__PURE__*/ (0, $4oXwn$react).createElement((0, $4oXwn$react).Fragment, null, /*#__PURE__*/ (0, $4oXwn$react).createElement("div", {
|
|
193
|
+
role: headingId ? 'dialog' : undefined,
|
|
194
|
+
"aria-labelledby": headingId,
|
|
195
|
+
"aria-hidden": isMobile && hasOpenSubmenu,
|
|
196
|
+
"data-testid": "menu-wrapper",
|
|
197
|
+
className: (0, $4oXwn$classNames)((0, ($parcel$interopDefault($4oXwn$menu_vars_cssmodulejs))), 'spectrum-Menu-wrapper', {
|
|
198
|
+
'spectrum-Menu-wrapper--isMobile': isMobile,
|
|
199
|
+
'is-expanded': hasOpenSubmenu,
|
|
200
|
+
[traySubmenuAnimation]: isMobile
|
|
201
|
+
})
|
|
202
|
+
}, /*#__PURE__*/ (0, $4oXwn$react).createElement("div", {
|
|
203
|
+
role: "presentation",
|
|
204
|
+
className: (0, $4oXwn$classNames)((0, ($parcel$interopDefault($4oXwn$menu_vars_cssmodulejs))), 'spectrum-Submenu-wrapper', {
|
|
205
|
+
'spectrum-Submenu-wrapper--isMobile': isMobile
|
|
206
|
+
}),
|
|
207
|
+
onKeyDown: wrapperKeyDown
|
|
208
|
+
}, isMobile && isSubmenu && !hasOpenSubmenu && /*#__PURE__*/ (0, $4oXwn$react).createElement("div", {
|
|
209
|
+
className: (0, $4oXwn$classNames)((0, ($parcel$interopDefault($4oXwn$menu_vars_cssmodulejs))), 'spectrum-Submenu-headingWrapper')
|
|
210
|
+
}, /*#__PURE__*/ (0, $4oXwn$react).createElement((0, $4oXwn$ActionButton), {
|
|
211
|
+
"aria-label": backButtonLabel,
|
|
212
|
+
isQuiet: true,
|
|
213
|
+
onPress: handleBackButtonPress
|
|
214
|
+
}, direction === 'rtl' ? /*#__PURE__*/ (0, $4oXwn$react).createElement((0, $4oXwn$spectrumiconsuiArrowDownSmall), {
|
|
215
|
+
UNSAFE_style: {
|
|
216
|
+
rotate: '270deg'
|
|
217
|
+
}
|
|
218
|
+
}) : /*#__PURE__*/ (0, $4oXwn$react).createElement((0, $4oXwn$spectrumiconsuiArrowDownSmall), {
|
|
219
|
+
UNSAFE_style: {
|
|
220
|
+
rotate: '90deg'
|
|
221
|
+
}
|
|
222
|
+
})), /*#__PURE__*/ (0, $4oXwn$react).createElement("h1", {
|
|
223
|
+
id: headingId,
|
|
224
|
+
className: (0, $4oXwn$classNames)((0, ($parcel$interopDefault($4oXwn$menu_vars_cssmodulejs))), 'spectrum-Submenu-heading')
|
|
225
|
+
}, backButtonText)), children)));
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Menus display a list of actions or options that a user can choose.
|
|
229
|
+
*/ // forwardRef doesn't support generic parameters, so cast the result to the correct type
|
|
230
|
+
// https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref
|
|
231
|
+
const $49b26f4b606348f6$export$d9b273488cd8ce6f = /*#__PURE__*/ (0, $4oXwn$react).forwardRef($49b26f4b606348f6$var$Menu);
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
export {$49b26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GAAA,oCAAa;QAAE,cAAc;YAAC,QAAQ;QAAO;uBAE9H,gCAAC;QAAG,IAAI;QAAW,WAAW,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;OAA8B,kBAGlF;AAKX;AAEA;;CAEC,GACD,wFAAwF;AACxF,2GAA2G;AAC3G,MAAM,0DAAQ,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/menu/src/Menu.tsx"],"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 {ActionButton} from '@react-spectrum/button';\nimport ArrowDownSmall from '@spectrum-icons/ui/ArrowDownSmall';\nimport {classNames, useDOMRef, useIsMobileDevice, useStyleProps} from '@react-spectrum/utils';\nimport {DOMRef} from '@react-types/shared';\nimport {FocusScope} from '@react-aria/focus';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {MenuContext, MenuStateContext, useMenuStateContext} from './context';\nimport {MenuItem} from './MenuItem';\nimport {MenuSection} from './MenuSection';\nimport {mergeProps, useLayoutEffect, useSlotId, useSyncRef} from '@react-aria/utils';\nimport React, {ReactElement, useContext, useEffect, useRef, useState} from 'react';\nimport {SpectrumMenuProps} from '@react-types/menu';\nimport styles from '@adobe/spectrum-css-temp/components/menu/vars.css';\nimport {useInteractOutside} from '@react-aria/interactions';\nimport {useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useMenu} from '@react-aria/menu';\nimport {useTreeState} from '@react-stately/tree';\n\nfunction Menu<T extends object>(props: SpectrumMenuProps<T>, ref: DOMRef<HTMLDivElement>) {\n let isSubmenu = true;\n let contextProps = useContext(MenuContext);\n let parentMenuContext = useMenuStateContext();\n let {rootMenuTriggerState, state: parentMenuTreeState} = parentMenuContext || {rootMenuTriggerState: contextProps.state};\n if (!parentMenuContext) {\n isSubmenu = false;\n }\n let completeProps = {\n ...mergeProps(contextProps, props)\n };\n let domRef = useDOMRef(ref);\n let [popoverContainer, setPopoverContainer] = useState(null);\n let trayContainerRef = useRef(null);\n let state = useTreeState(completeProps);\n let submenuRef = useRef<HTMLDivElement>(null);\n let {menuProps} = useMenu(completeProps, state, domRef);\n let {styleProps} = useStyleProps(completeProps);\n useSyncRef(contextProps, domRef);\n let [leftOffset, setLeftOffset] = useState({left: 0});\n let prevPopoverContainer = useRef(null);\n useEffect(() => {\n if (popoverContainer && prevPopoverContainer.current !== popoverContainer && leftOffset.left === 0) {\n prevPopoverContainer.current = popoverContainer;\n let {left} = popoverContainer.getBoundingClientRect();\n setLeftOffset({left: -1 * left});\n }\n }, [leftOffset, popoverContainer]);\n\n let menuLevel = contextProps.submenuLevel ?? -1;\n let hasOpenSubmenu = state.collection.getItem(rootMenuTriggerState?.expandedKeysStack[menuLevel + 1]) != null;\n useInteractOutside({\n ref: domRef,\n onInteractOutside: (e) => {\n if (!popoverContainer?.contains(e.target) && !trayContainerRef.current?.contains(e.target)) {\n rootMenuTriggerState.close();\n }\n },\n isDisabled: isSubmenu || !hasOpenSubmenu\n });\n\n return (\n <MenuStateContext.Provider value={{popoverContainer, trayContainerRef, menu: domRef, submenu: submenuRef, rootMenuTriggerState, state}}>\n <div style={{height: hasOpenSubmenu ? '100%' : undefined}} ref={trayContainerRef} />\n <FocusScope>\n <TrayHeaderWrapper\n onBackButtonPress={contextProps.onBackButtonPress}\n hasOpenSubmenu={hasOpenSubmenu}\n isSubmenu={isSubmenu}\n parentMenuTreeState={parentMenuTreeState}\n rootMenuTriggerState={rootMenuTriggerState}\n menuRef={domRef}>\n <div\n {...menuProps}\n style={mergeProps(styleProps.style, menuProps.style)}\n ref={domRef}\n className={\n classNames(\n styles,\n 'spectrum-Menu',\n styleProps.className\n )\n }>\n {[...state.collection].map(item => {\n if (item.type === 'section') {\n return (\n <MenuSection\n key={item.key}\n item={item}\n state={state} />\n );\n }\n\n let menuItem = (\n <MenuItem\n key={item.key}\n item={item}\n state={state} />\n );\n\n if (item.wrapper) {\n menuItem = item.wrapper(menuItem);\n }\n\n return menuItem;\n })}\n </div>\n </TrayHeaderWrapper>\n {rootMenuTriggerState?.isOpen && <div ref={setPopoverContainer} style={{width: '100vw', position: 'absolute', top: -5, ...leftOffset}} /> }\n </FocusScope>\n </MenuStateContext.Provider>\n );\n}\n\nexport function TrayHeaderWrapper(props) {\n let {children, isSubmenu, hasOpenSubmenu, parentMenuTreeState, rootMenuTriggerState, onBackButtonPress, wrapperKeyDown, menuRef} = props;\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/menu');\n let backButtonText = parentMenuTreeState?.collection.getItem(rootMenuTriggerState?.expandedKeysStack.slice(-1)[0])?.textValue;\n let backButtonLabel = stringFormatter.format('backButton', {\n prevMenuButton: backButtonText\n });\n let headingId = useSlotId();\n let isMobile = useIsMobileDevice();\n let {direction} = useLocale();\n\n let [traySubmenuAnimation, setTraySubmenuAnimation] = useState('');\n useLayoutEffect(() => {\n if (!hasOpenSubmenu) {\n setTraySubmenuAnimation('spectrum-TraySubmenu-enter');\n }\n }, [hasOpenSubmenu, isMobile]);\n\n let timeoutRef = useRef(null);\n let handleBackButtonPress = () => {\n setTraySubmenuAnimation('spectrum-TraySubmenu-exit');\n timeoutRef.current = setTimeout(() => {\n onBackButtonPress();\n }, 220); // Matches transition duration\n };\n\n useEffect(() => {\n return () => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n };\n }, []);\n\n // When opening submenu in tray, focus the first item in the submenu after animation completes\n // This fixes an issue with iOS VO where the closed submenu was getting focus\n let focusTimeoutRef = useRef(null);\n useEffect(() => {\n if (isMobile && isSubmenu && !hasOpenSubmenu && traySubmenuAnimation === 'spectrum-TraySubmenu-enter') {\n focusTimeoutRef.current = setTimeout(() => {\n let firstItem = menuRef.current.querySelector('[role=\"menuitem\"], [role=\"menuitemcheckbox\"], [role=\"menuitemradio\"]') as HTMLElement;\n firstItem?.focus();\n }, 220);\n }\n return () => {\n if (focusTimeoutRef.current) {\n clearTimeout(focusTimeoutRef.current);\n }\n };\n }, [hasOpenSubmenu, isMobile, isSubmenu, menuRef, traySubmenuAnimation]);\n\n return (\n <>\n <div\n role={headingId ? 'dialog' : undefined}\n aria-labelledby={headingId}\n aria-hidden={isMobile && hasOpenSubmenu}\n data-testid=\"menu-wrapper\"\n className={\n classNames(\n styles,\n 'spectrum-Menu-wrapper',\n {\n 'spectrum-Menu-wrapper--isMobile': isMobile,\n 'is-expanded': hasOpenSubmenu,\n [traySubmenuAnimation]: isMobile\n }\n )\n }>\n <div role=\"presentation\" className={classNames(styles, 'spectrum-Submenu-wrapper', {'spectrum-Submenu-wrapper--isMobile': isMobile})} onKeyDown={wrapperKeyDown}>\n {isMobile && isSubmenu && !hasOpenSubmenu && (\n <div className={classNames(styles, 'spectrum-Submenu-headingWrapper')}>\n <ActionButton\n aria-label={backButtonLabel}\n isQuiet\n onPress={handleBackButtonPress}>\n {/* We don't have a ArrowLeftSmall so make due with ArrowDownSmall and transforms */}\n {direction === 'rtl' ? <ArrowDownSmall UNSAFE_style={{rotate: '270deg'}} /> : <ArrowDownSmall UNSAFE_style={{rotate: '90deg'}} />}\n </ActionButton>\n <h1 id={headingId} className={classNames(styles, 'spectrum-Submenu-heading')}>{backButtonText}</h1>\n </div>\n )}\n {children}\n </div>\n </div>\n </>\n );\n}\n\n/**\n * Menus display a list of actions or options that a user can choose.\n */\n// forwardRef doesn't support generic parameters, so cast the result to the correct type\n// https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref\nconst _Menu = React.forwardRef(Menu) as <T>(props: SpectrumMenuProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\nexport {_Menu as Menu};\n"],"names":[],"version":3,"file":"Menu.module.js.map"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
var $2f9ceea24fba5443$exports = require("./intlStrings.main.js");
|
|
2
|
+
require("./vars.89a944d6.css");
|
|
3
|
+
var $3deee0fd2b46e64f$exports = require("./menu_vars_css.main.js");
|
|
4
|
+
var $cac834c4bc0a51d3$exports = require("./context.main.js");
|
|
5
|
+
var $8PAEC$spectrumiconsuiCheckmarkMedium = require("@spectrum-icons/ui/CheckmarkMedium");
|
|
6
|
+
var $8PAEC$spectrumiconsworkflowChevronLeft = require("@spectrum-icons/workflow/ChevronLeft");
|
|
7
|
+
var $8PAEC$spectrumiconsworkflowChevronRight = require("@spectrum-icons/workflow/ChevronRight");
|
|
8
|
+
var $8PAEC$reactspectrumutils = require("@react-spectrum/utils");
|
|
9
|
+
var $8PAEC$reactariafocus = require("@react-aria/focus");
|
|
10
|
+
var $8PAEC$reactspectrumlayout = require("@react-spectrum/layout");
|
|
11
|
+
var $8PAEC$spectrumiconsworkflowInfoOutline = require("@spectrum-icons/workflow/InfoOutline");
|
|
12
|
+
var $8PAEC$reactariautils = require("@react-aria/utils");
|
|
13
|
+
var $8PAEC$react = require("react");
|
|
14
|
+
var $8PAEC$reactspectrumtext = require("@react-spectrum/text");
|
|
15
|
+
var $8PAEC$reactariai18n = require("@react-aria/i18n");
|
|
16
|
+
var $8PAEC$reactariamenu = require("@react-aria/menu");
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
function $parcel$interopDefault(a) {
|
|
20
|
+
return a && a.__esModule ? a.default : a;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function $parcel$export(e, n, v, s) {
|
|
24
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
$parcel$export(module.exports, "MenuItem", () => $1d718563708db5b5$export$2ce376c2cc3355c8);
|
|
28
|
+
/*
|
|
29
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
30
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
31
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
32
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
33
|
+
*
|
|
34
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
35
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
36
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
37
|
+
* governing permissions and limitations under the License.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
function $1d718563708db5b5$export$2ce376c2cc3355c8(props) {
|
|
54
|
+
let { item: item, state: state, isVirtualized: isVirtualized } = props;
|
|
55
|
+
let { closeOnSelect: closeOnSelect } = (0, $cac834c4bc0a51d3$exports.useMenuContext)();
|
|
56
|
+
let { rendered: rendered, key: key } = item;
|
|
57
|
+
let stringFormatter = (0, $8PAEC$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($2f9ceea24fba5443$exports))), '@react-spectrum/menu');
|
|
58
|
+
let { direction: direction } = (0, $8PAEC$reactariai18n.useLocale)();
|
|
59
|
+
let submenuTriggerContext = (0, $cac834c4bc0a51d3$exports.useSubmenuTriggerContext)();
|
|
60
|
+
let { triggerRef: triggerRef, ...submenuTriggerProps } = submenuTriggerContext || {};
|
|
61
|
+
let isSubmenuTrigger = !!submenuTriggerContext;
|
|
62
|
+
let isUnavailable;
|
|
63
|
+
let ElementType = item.props.href ? 'a' : 'div';
|
|
64
|
+
if (isSubmenuTrigger) isUnavailable = submenuTriggerContext.isUnavailable;
|
|
65
|
+
let isDisabled = state.disabledKeys.has(key);
|
|
66
|
+
let isSelectable = !isSubmenuTrigger && state.selectionManager.selectionMode !== 'none';
|
|
67
|
+
let isSelected = isSelectable && state.selectionManager.isSelected(key);
|
|
68
|
+
let itemref = (0, $8PAEC$react.useRef)(null);
|
|
69
|
+
let ref = (0, $8PAEC$reactariautils.useObjectRef)((0, $8PAEC$react.useMemo)(()=>(0, $8PAEC$reactariautils.mergeRefs)(itemref, triggerRef), [
|
|
70
|
+
itemref,
|
|
71
|
+
triggerRef
|
|
72
|
+
]));
|
|
73
|
+
let { menuItemProps: menuItemProps, labelProps: labelProps, descriptionProps: descriptionProps, keyboardShortcutProps: keyboardShortcutProps } = (0, $8PAEC$reactariamenu.useMenuItem)({
|
|
74
|
+
isSelected: isSelected,
|
|
75
|
+
isDisabled: isDisabled,
|
|
76
|
+
'aria-label': item['aria-label'],
|
|
77
|
+
key: key,
|
|
78
|
+
closeOnSelect: closeOnSelect,
|
|
79
|
+
isVirtualized: isVirtualized,
|
|
80
|
+
...submenuTriggerProps
|
|
81
|
+
}, state, ref);
|
|
82
|
+
let endId = (0, $8PAEC$reactariautils.useSlotId)();
|
|
83
|
+
let endProps = {};
|
|
84
|
+
if (endId) {
|
|
85
|
+
endProps.id = endId;
|
|
86
|
+
menuItemProps['aria-describedby'] = [
|
|
87
|
+
menuItemProps['aria-describedby'],
|
|
88
|
+
endId
|
|
89
|
+
].filter(Boolean).join(' ');
|
|
90
|
+
}
|
|
91
|
+
let contents = typeof rendered === 'string' ? /*#__PURE__*/ (0, ($parcel$interopDefault($8PAEC$react))).createElement((0, $8PAEC$reactspectrumtext.Text), null, rendered) : rendered;
|
|
92
|
+
return /*#__PURE__*/ (0, ($parcel$interopDefault($8PAEC$react))).createElement((0, $8PAEC$reactariafocus.FocusRing), {
|
|
93
|
+
focusRingClass: (0, $8PAEC$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3deee0fd2b46e64f$exports))), 'focus-ring')
|
|
94
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($8PAEC$react))).createElement(ElementType, {
|
|
95
|
+
...menuItemProps,
|
|
96
|
+
ref: ref,
|
|
97
|
+
className: (0, $8PAEC$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3deee0fd2b46e64f$exports))), 'spectrum-Menu-item', {
|
|
98
|
+
'is-disabled': isDisabled,
|
|
99
|
+
'is-selected': isSelected,
|
|
100
|
+
'is-selectable': isSelectable,
|
|
101
|
+
'is-open': submenuTriggerProps.isOpen
|
|
102
|
+
})
|
|
103
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($8PAEC$react))).createElement((0, $8PAEC$reactspectrumlayout.Grid), {
|
|
104
|
+
UNSAFE_className: (0, $8PAEC$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3deee0fd2b46e64f$exports))), 'spectrum-Menu-itemGrid')
|
|
105
|
+
}, /*#__PURE__*/ (0, ($parcel$interopDefault($8PAEC$react))).createElement((0, $8PAEC$reactspectrumutils.ClearSlots), null, /*#__PURE__*/ (0, ($parcel$interopDefault($8PAEC$react))).createElement((0, $8PAEC$reactspectrumutils.SlotProvider), {
|
|
106
|
+
slots: {
|
|
107
|
+
text: {
|
|
108
|
+
UNSAFE_className: (0, ($parcel$interopDefault($3deee0fd2b46e64f$exports)))['spectrum-Menu-itemLabel'],
|
|
109
|
+
...labelProps
|
|
110
|
+
},
|
|
111
|
+
end: {
|
|
112
|
+
UNSAFE_className: (0, ($parcel$interopDefault($3deee0fd2b46e64f$exports)))['spectrum-Menu-end'],
|
|
113
|
+
...endProps
|
|
114
|
+
},
|
|
115
|
+
icon: {
|
|
116
|
+
UNSAFE_className: (0, ($parcel$interopDefault($3deee0fd2b46e64f$exports)))['spectrum-Menu-icon'],
|
|
117
|
+
size: 'S'
|
|
118
|
+
},
|
|
119
|
+
description: {
|
|
120
|
+
UNSAFE_className: (0, ($parcel$interopDefault($3deee0fd2b46e64f$exports)))['spectrum-Menu-description'],
|
|
121
|
+
...descriptionProps
|
|
122
|
+
},
|
|
123
|
+
keyboard: {
|
|
124
|
+
UNSAFE_className: (0, ($parcel$interopDefault($3deee0fd2b46e64f$exports)))['spectrum-Menu-keyboard'],
|
|
125
|
+
...keyboardShortcutProps
|
|
126
|
+
},
|
|
127
|
+
chevron: {
|
|
128
|
+
UNSAFE_className: (0, ($parcel$interopDefault($3deee0fd2b46e64f$exports)))['spectrum-Menu-chevron'],
|
|
129
|
+
size: 'S'
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}, contents, isSelected && /*#__PURE__*/ (0, ($parcel$interopDefault($8PAEC$react))).createElement((0, ($parcel$interopDefault($8PAEC$spectrumiconsuiCheckmarkMedium))), {
|
|
133
|
+
slot: "checkmark",
|
|
134
|
+
UNSAFE_className: (0, $8PAEC$reactspectrumutils.classNames)((0, ($parcel$interopDefault($3deee0fd2b46e64f$exports))), 'spectrum-Menu-checkmark')
|
|
135
|
+
}), isUnavailable && /*#__PURE__*/ (0, ($parcel$interopDefault($8PAEC$react))).createElement((0, ($parcel$interopDefault($8PAEC$spectrumiconsworkflowInfoOutline))), {
|
|
136
|
+
slot: "end",
|
|
137
|
+
size: "XS",
|
|
138
|
+
alignSelf: "center",
|
|
139
|
+
"aria-label": stringFormatter.format('unavailable')
|
|
140
|
+
}), isUnavailable == null && isSubmenuTrigger && (direction === 'rtl' ? /*#__PURE__*/ (0, ($parcel$interopDefault($8PAEC$react))).createElement((0, ($parcel$interopDefault($8PAEC$spectrumiconsworkflowChevronLeft))), {
|
|
141
|
+
slot: "chevron"
|
|
142
|
+
}) : /*#__PURE__*/ (0, ($parcel$interopDefault($8PAEC$react))).createElement((0, ($parcel$interopDefault($8PAEC$spectrumiconsworkflowChevronRight))), {
|
|
143
|
+
slot: "chevron"
|
|
144
|
+
})))))));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
//# sourceMappingURL=MenuItem.main.js.map
|