@react-spectrum/menu 3.22.10 → 3.23.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 +6 -8
- package/dist/main.js +12 -14
- package/dist/main.js.map +1 -1
- package/dist/module.js +6 -8
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +8 -0
- package/package.json +14 -46
- package/src/index.ts +9 -9
- package/dist/ActionMenu.main.js +0 -67
- package/dist/ActionMenu.main.js.map +0 -1
- package/dist/ActionMenu.mjs +0 -62
- package/dist/ActionMenu.module.js +0 -62
- package/dist/ActionMenu.module.js.map +0 -1
- package/dist/ContextualHelpTrigger.main.js +0 -192
- package/dist/ContextualHelpTrigger.main.js.map +0 -1
- package/dist/ContextualHelpTrigger.mjs +0 -187
- package/dist/ContextualHelpTrigger.module.js +0 -187
- package/dist/ContextualHelpTrigger.module.js.map +0 -1
- package/dist/Menu.main.js +0 -235
- package/dist/Menu.main.js.map +0 -1
- package/dist/Menu.mjs +0 -229
- package/dist/Menu.module.js +0 -229
- package/dist/Menu.module.js.map +0 -1
- package/dist/MenuItem.main.js +0 -149
- package/dist/MenuItem.main.js.map +0 -1
- package/dist/MenuItem.mjs +0 -144
- package/dist/MenuItem.module.js +0 -144
- package/dist/MenuItem.module.js.map +0 -1
- package/dist/MenuSection.main.js +0 -81
- package/dist/MenuSection.main.js.map +0 -1
- package/dist/MenuSection.mjs +0 -76
- package/dist/MenuSection.module.js +0 -76
- package/dist/MenuSection.module.js.map +0 -1
- package/dist/MenuTrigger.main.js +0 -128
- package/dist/MenuTrigger.main.js.map +0 -1
- package/dist/MenuTrigger.mjs +0 -123
- package/dist/MenuTrigger.module.js +0 -123
- package/dist/MenuTrigger.module.js.map +0 -1
- package/dist/Popover.main.js +0 -196
- package/dist/Popover.main.js.map +0 -1
- package/dist/Popover.mjs +0 -191
- package/dist/Popover.module.js +0 -191
- package/dist/Popover.module.js.map +0 -1
- package/dist/SubmenuTrigger.main.js +0 -154
- package/dist/SubmenuTrigger.main.js.map +0 -1
- package/dist/SubmenuTrigger.mjs +0 -149
- package/dist/SubmenuTrigger.module.js +0 -149
- package/dist/SubmenuTrigger.module.js.map +0 -1
- package/dist/Underlay.main.js +0 -54
- package/dist/Underlay.main.js.map +0 -1
- package/dist/Underlay.mjs +0 -49
- package/dist/Underlay.module.js +0 -49
- package/dist/Underlay.module.js.map +0 -1
- package/dist/ar-AE.main.js +0 -8
- package/dist/ar-AE.main.js.map +0 -1
- package/dist/ar-AE.mjs +0 -10
- package/dist/ar-AE.module.js +0 -10
- package/dist/ar-AE.module.js.map +0 -1
- package/dist/bg-BG.main.js +0 -8
- package/dist/bg-BG.main.js.map +0 -1
- package/dist/bg-BG.mjs +0 -10
- package/dist/bg-BG.module.js +0 -10
- package/dist/bg-BG.module.js.map +0 -1
- package/dist/calculatePosition.main.js +0 -392
- package/dist/calculatePosition.main.js.map +0 -1
- package/dist/calculatePosition.mjs +0 -386
- package/dist/calculatePosition.module.js +0 -386
- package/dist/calculatePosition.module.js.map +0 -1
- package/dist/context.main.js +0 -43
- package/dist/context.main.js.map +0 -1
- package/dist/context.mjs +0 -29
- package/dist/context.module.js +0 -29
- package/dist/context.module.js.map +0 -1
- package/dist/contextualhelp_vars_css.main.js +0 -23
- package/dist/contextualhelp_vars_css.main.js.map +0 -1
- package/dist/contextualhelp_vars_css.mjs +0 -25
- package/dist/contextualhelp_vars_css.module.js +0 -25
- package/dist/contextualhelp_vars_css.module.js.map +0 -1
- package/dist/cs-CZ.main.js +0 -8
- package/dist/cs-CZ.main.js.map +0 -1
- package/dist/cs-CZ.mjs +0 -10
- package/dist/cs-CZ.module.js +0 -10
- package/dist/cs-CZ.module.js.map +0 -1
- package/dist/da-DK.main.js +0 -8
- package/dist/da-DK.main.js.map +0 -1
- package/dist/da-DK.mjs +0 -10
- package/dist/da-DK.module.js +0 -10
- package/dist/da-DK.module.js.map +0 -1
- package/dist/de-DE.main.js +0 -8
- package/dist/de-DE.main.js.map +0 -1
- package/dist/de-DE.mjs +0 -10
- package/dist/de-DE.module.js +0 -10
- package/dist/de-DE.module.js.map +0 -1
- package/dist/el-GR.main.js +0 -8
- package/dist/el-GR.main.js.map +0 -1
- package/dist/el-GR.mjs +0 -10
- package/dist/el-GR.module.js +0 -10
- package/dist/el-GR.module.js.map +0 -1
- package/dist/en-US.main.js +0 -8
- package/dist/en-US.main.js.map +0 -1
- package/dist/en-US.mjs +0 -10
- package/dist/en-US.module.js +0 -10
- package/dist/en-US.module.js.map +0 -1
- package/dist/es-ES.main.js +0 -8
- package/dist/es-ES.main.js.map +0 -1
- package/dist/es-ES.mjs +0 -10
- package/dist/es-ES.module.js +0 -10
- package/dist/es-ES.module.js.map +0 -1
- package/dist/et-EE.main.js +0 -8
- package/dist/et-EE.main.js.map +0 -1
- package/dist/et-EE.mjs +0 -10
- package/dist/et-EE.module.js +0 -10
- package/dist/et-EE.module.js.map +0 -1
- package/dist/fi-FI.main.js +0 -8
- package/dist/fi-FI.main.js.map +0 -1
- package/dist/fi-FI.mjs +0 -10
- package/dist/fi-FI.module.js +0 -10
- package/dist/fi-FI.module.js.map +0 -1
- package/dist/fr-FR.main.js +0 -8
- package/dist/fr-FR.main.js.map +0 -1
- package/dist/fr-FR.mjs +0 -10
- package/dist/fr-FR.module.js +0 -10
- package/dist/fr-FR.module.js.map +0 -1
- package/dist/he-IL.main.js +0 -8
- package/dist/he-IL.main.js.map +0 -1
- package/dist/he-IL.mjs +0 -10
- package/dist/he-IL.module.js +0 -10
- package/dist/he-IL.module.js.map +0 -1
- package/dist/hr-HR.main.js +0 -8
- package/dist/hr-HR.main.js.map +0 -1
- package/dist/hr-HR.mjs +0 -10
- package/dist/hr-HR.module.js +0 -10
- package/dist/hr-HR.module.js.map +0 -1
- package/dist/hu-HU.main.js +0 -8
- package/dist/hu-HU.main.js.map +0 -1
- package/dist/hu-HU.mjs +0 -10
- package/dist/hu-HU.module.js +0 -10
- 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 -8
- package/dist/it-IT.main.js.map +0 -1
- package/dist/it-IT.mjs +0 -10
- package/dist/it-IT.module.js +0 -10
- package/dist/it-IT.module.js.map +0 -1
- package/dist/ja-JP.main.js +0 -8
- package/dist/ja-JP.main.js.map +0 -1
- package/dist/ja-JP.mjs +0 -10
- package/dist/ja-JP.module.js +0 -10
- package/dist/ja-JP.module.js.map +0 -1
- package/dist/ko-KR.main.js +0 -8
- package/dist/ko-KR.main.js.map +0 -1
- package/dist/ko-KR.mjs +0 -10
- package/dist/ko-KR.module.js +0 -10
- package/dist/ko-KR.module.js.map +0 -1
- package/dist/lt-LT.main.js +0 -8
- package/dist/lt-LT.main.js.map +0 -1
- package/dist/lt-LT.mjs +0 -10
- package/dist/lt-LT.module.js +0 -10
- package/dist/lt-LT.module.js.map +0 -1
- package/dist/lv-LV.main.js +0 -8
- package/dist/lv-LV.main.js.map +0 -1
- package/dist/lv-LV.mjs +0 -10
- package/dist/lv-LV.module.js +0 -10
- package/dist/lv-LV.module.js.map +0 -1
- package/dist/menu.2259a533.css +0 -210
- package/dist/menu.2259a533.css.map +0 -1
- package/dist/menu.2ec1fdaf.css +0 -570
- package/dist/menu.2ec1fdaf.css.map +0 -1
- package/dist/menu.359a0c0a.css +0 -131
- package/dist/menu.359a0c0a.css.map +0 -1
- package/dist/menu.57b3a408.css +0 -12
- package/dist/menu.57b3a408.css.map +0 -1
- package/dist/menu.5b49954a.css +0 -30
- package/dist/menu.5b49954a.css.map +0 -1
- package/dist/menu_vars_css.main.js +0 -177
- package/dist/menu_vars_css.main.js.map +0 -1
- package/dist/menu_vars_css.mjs +0 -179
- package/dist/menu_vars_css.module.js +0 -179
- package/dist/menu_vars_css.module.js.map +0 -1
- package/dist/nb-NO.main.js +0 -8
- package/dist/nb-NO.main.js.map +0 -1
- package/dist/nb-NO.mjs +0 -10
- package/dist/nb-NO.module.js +0 -10
- package/dist/nb-NO.module.js.map +0 -1
- package/dist/nl-NL.main.js +0 -8
- package/dist/nl-NL.main.js.map +0 -1
- package/dist/nl-NL.mjs +0 -10
- package/dist/nl-NL.module.js +0 -10
- package/dist/nl-NL.module.js.map +0 -1
- package/dist/overlays_css.main.js +0 -35
- package/dist/overlays_css.main.js.map +0 -1
- package/dist/overlays_css.mjs +0 -37
- package/dist/overlays_css.module.js +0 -37
- package/dist/overlays_css.module.js.map +0 -1
- package/dist/pl-PL.main.js +0 -8
- package/dist/pl-PL.main.js.map +0 -1
- package/dist/pl-PL.mjs +0 -10
- package/dist/pl-PL.module.js +0 -10
- package/dist/pl-PL.module.js.map +0 -1
- package/dist/popover_vars_css.main.js +0 -83
- package/dist/popover_vars_css.main.js.map +0 -1
- package/dist/popover_vars_css.mjs +0 -85
- package/dist/popover_vars_css.module.js +0 -85
- package/dist/popover_vars_css.module.js.map +0 -1
- package/dist/pt-BR.main.js +0 -8
- package/dist/pt-BR.main.js.map +0 -1
- package/dist/pt-BR.mjs +0 -10
- package/dist/pt-BR.module.js +0 -10
- package/dist/pt-BR.module.js.map +0 -1
- package/dist/pt-PT.main.js +0 -8
- package/dist/pt-PT.main.js.map +0 -1
- package/dist/pt-PT.mjs +0 -10
- package/dist/pt-PT.module.js +0 -10
- package/dist/pt-PT.module.js.map +0 -1
- package/dist/ro-RO.main.js +0 -8
- package/dist/ro-RO.main.js.map +0 -1
- package/dist/ro-RO.mjs +0 -10
- package/dist/ro-RO.module.js +0 -10
- package/dist/ro-RO.module.js.map +0 -1
- package/dist/ru-RU.main.js +0 -8
- package/dist/ru-RU.main.js.map +0 -1
- package/dist/ru-RU.mjs +0 -10
- package/dist/ru-RU.module.js +0 -10
- package/dist/ru-RU.module.js.map +0 -1
- package/dist/sk-SK.main.js +0 -8
- package/dist/sk-SK.main.js.map +0 -1
- package/dist/sk-SK.mjs +0 -10
- package/dist/sk-SK.module.js +0 -10
- package/dist/sk-SK.module.js.map +0 -1
- package/dist/sl-SI.main.js +0 -8
- package/dist/sl-SI.main.js.map +0 -1
- package/dist/sl-SI.mjs +0 -10
- package/dist/sl-SI.module.js +0 -10
- package/dist/sl-SI.module.js.map +0 -1
- package/dist/sr-SP.main.js +0 -8
- package/dist/sr-SP.main.js.map +0 -1
- package/dist/sr-SP.mjs +0 -10
- package/dist/sr-SP.module.js +0 -10
- package/dist/sr-SP.module.js.map +0 -1
- package/dist/sv-SE.main.js +0 -8
- package/dist/sv-SE.main.js.map +0 -1
- package/dist/sv-SE.mjs +0 -10
- package/dist/sv-SE.module.js +0 -10
- package/dist/sv-SE.module.js.map +0 -1
- package/dist/tr-TR.main.js +0 -8
- package/dist/tr-TR.main.js.map +0 -1
- package/dist/tr-TR.mjs +0 -10
- package/dist/tr-TR.module.js +0 -10
- package/dist/tr-TR.module.js.map +0 -1
- package/dist/types.d.ts +0 -43
- package/dist/types.d.ts.map +0 -1
- package/dist/uk-UA.main.js +0 -8
- package/dist/uk-UA.main.js.map +0 -1
- package/dist/uk-UA.mjs +0 -10
- package/dist/uk-UA.module.js +0 -10
- package/dist/uk-UA.module.js.map +0 -1
- package/dist/underlay_vars_css.main.js +0 -50
- package/dist/underlay_vars_css.main.js.map +0 -1
- package/dist/underlay_vars_css.mjs +0 -52
- package/dist/underlay_vars_css.module.js +0 -52
- package/dist/underlay_vars_css.module.js.map +0 -1
- package/dist/useCloseOnScroll.main.js +0 -51
- package/dist/useCloseOnScroll.main.js.map +0 -1
- package/dist/useCloseOnScroll.mjs +0 -46
- package/dist/useCloseOnScroll.module.js +0 -46
- package/dist/useCloseOnScroll.module.js.map +0 -1
- package/dist/useOverlayPosition.main.js +0 -225
- package/dist/useOverlayPosition.main.js.map +0 -1
- package/dist/useOverlayPosition.mjs +0 -220
- package/dist/useOverlayPosition.module.js +0 -220
- package/dist/useOverlayPosition.module.js.map +0 -1
- package/dist/usePopover.main.js +0 -73
- package/dist/usePopover.main.js.map +0 -1
- package/dist/usePopover.mjs +0 -68
- package/dist/usePopover.module.js +0 -68
- package/dist/usePopover.module.js.map +0 -1
- package/dist/zh-CN.main.js +0 -8
- package/dist/zh-CN.main.js.map +0 -1
- package/dist/zh-CN.mjs +0 -10
- package/dist/zh-CN.module.js +0 -10
- package/dist/zh-CN.module.js.map +0 -1
- package/dist/zh-TW.main.js +0 -8
- package/dist/zh-TW.main.js.map +0 -1
- package/dist/zh-TW.mjs +0 -10
- package/dist/zh-TW.module.js +0 -10
- package/dist/zh-TW.module.js.map +0 -1
- package/src/ActionMenu.tsx +0 -58
- package/src/ContextualHelpTrigger.tsx +0 -194
- package/src/Menu.tsx +0 -228
- package/src/MenuItem.tsx +0 -159
- package/src/MenuSection.tsx +0 -100
- package/src/MenuTrigger.tsx +0 -125
- package/src/Popover.tsx +0 -240
- package/src/SubmenuTrigger.tsx +0 -154
- package/src/Underlay.tsx +0 -43
- package/src/calculatePosition.ts +0 -627
- package/src/context.ts +0 -63
- package/src/overlays.css +0 -32
- package/src/useCloseOnScroll.ts +0 -65
- package/src/useOverlayPosition.ts +0 -327
- package/src/usePopover.ts +0 -136
package/dist/usePopover.mjs
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import {useOverlayPosition as $e235061053e33ff6$export$d39e1813b3bdd0e1} from "./useOverlayPosition.mjs";
|
|
2
|
-
import {useOverlay as $2m0nK$useOverlay, usePreventScroll as $2m0nK$usePreventScroll, ariaHideOutside as $2m0nK$ariaHideOutside} from "@react-aria/overlays";
|
|
3
|
-
import {mergeProps as $2m0nK$mergeProps} from "@react-aria/utils";
|
|
4
|
-
import {useEffect as $2m0nK$useEffect} from "react";
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* Copyright 2022 Adobe. All rights reserved.
|
|
8
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
9
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
10
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
13
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
14
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
15
|
-
* governing permissions and limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function $87eca3bd2e28ca01$export$542a6fd13ac93354(props, state) {
|
|
21
|
-
let { triggerRef: triggerRef, popoverRef: popoverRef, groupRef: groupRef, isNonModal: isNonModal, isKeyboardDismissDisabled: isKeyboardDismissDisabled, shouldCloseOnInteractOutside: shouldCloseOnInteractOutside, ...otherProps } = props;
|
|
22
|
-
let isSubmenu = otherProps['trigger'] === 'SubmenuTrigger';
|
|
23
|
-
let { overlayProps: overlayProps, underlayProps: underlayProps } = (0, $2m0nK$useOverlay)({
|
|
24
|
-
isOpen: state.isOpen,
|
|
25
|
-
onClose: state.close,
|
|
26
|
-
shouldCloseOnBlur: true,
|
|
27
|
-
isDismissable: !isNonModal || isSubmenu,
|
|
28
|
-
isKeyboardDismissDisabled: isKeyboardDismissDisabled,
|
|
29
|
-
shouldCloseOnInteractOutside: shouldCloseOnInteractOutside
|
|
30
|
-
}, groupRef !== null && groupRef !== void 0 ? groupRef : popoverRef);
|
|
31
|
-
let { overlayProps: positionProps, arrowProps: arrowProps, placement: placement, triggerAnchorPoint: origin } = (0, $e235061053e33ff6$export$d39e1813b3bdd0e1)({
|
|
32
|
-
...otherProps,
|
|
33
|
-
targetRef: triggerRef,
|
|
34
|
-
overlayRef: popoverRef,
|
|
35
|
-
isOpen: state.isOpen,
|
|
36
|
-
onClose: isNonModal && !isSubmenu ? state.close : null
|
|
37
|
-
});
|
|
38
|
-
(0, $2m0nK$usePreventScroll)({
|
|
39
|
-
isDisabled: isNonModal || !state.isOpen
|
|
40
|
-
});
|
|
41
|
-
(0, $2m0nK$useEffect)(()=>{
|
|
42
|
-
if (state.isOpen && popoverRef.current) {
|
|
43
|
-
var _groupRef_current;
|
|
44
|
-
if (isNonModal) return;
|
|
45
|
-
else return (0, $2m0nK$ariaHideOutside)([
|
|
46
|
-
(_groupRef_current = groupRef === null || groupRef === void 0 ? void 0 : groupRef.current) !== null && _groupRef_current !== void 0 ? _groupRef_current : popoverRef.current
|
|
47
|
-
], {
|
|
48
|
-
shouldUseInert: true
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}, [
|
|
52
|
-
isNonModal,
|
|
53
|
-
state.isOpen,
|
|
54
|
-
popoverRef,
|
|
55
|
-
groupRef
|
|
56
|
-
]);
|
|
57
|
-
return {
|
|
58
|
-
popoverProps: (0, $2m0nK$mergeProps)(overlayProps, positionProps),
|
|
59
|
-
arrowProps: arrowProps,
|
|
60
|
-
underlayProps: underlayProps,
|
|
61
|
-
placement: placement,
|
|
62
|
-
triggerAnchorPoint: origin
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
export {$87eca3bd2e28ca01$export$542a6fd13ac93354 as usePopover};
|
|
68
|
-
//# sourceMappingURL=usePopover.module.js.map
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import {useOverlayPosition as $e235061053e33ff6$export$d39e1813b3bdd0e1} from "./useOverlayPosition.module.js";
|
|
2
|
-
import {useOverlay as $2m0nK$useOverlay, usePreventScroll as $2m0nK$usePreventScroll, ariaHideOutside as $2m0nK$ariaHideOutside} from "@react-aria/overlays";
|
|
3
|
-
import {mergeProps as $2m0nK$mergeProps} from "@react-aria/utils";
|
|
4
|
-
import {useEffect as $2m0nK$useEffect} from "react";
|
|
5
|
-
|
|
6
|
-
/*
|
|
7
|
-
* Copyright 2022 Adobe. All rights reserved.
|
|
8
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
9
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
10
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
-
*
|
|
12
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
13
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
14
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
15
|
-
* governing permissions and limitations under the License.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function $87eca3bd2e28ca01$export$542a6fd13ac93354(props, state) {
|
|
21
|
-
let { triggerRef: triggerRef, popoverRef: popoverRef, groupRef: groupRef, isNonModal: isNonModal, isKeyboardDismissDisabled: isKeyboardDismissDisabled, shouldCloseOnInteractOutside: shouldCloseOnInteractOutside, ...otherProps } = props;
|
|
22
|
-
let isSubmenu = otherProps['trigger'] === 'SubmenuTrigger';
|
|
23
|
-
let { overlayProps: overlayProps, underlayProps: underlayProps } = (0, $2m0nK$useOverlay)({
|
|
24
|
-
isOpen: state.isOpen,
|
|
25
|
-
onClose: state.close,
|
|
26
|
-
shouldCloseOnBlur: true,
|
|
27
|
-
isDismissable: !isNonModal || isSubmenu,
|
|
28
|
-
isKeyboardDismissDisabled: isKeyboardDismissDisabled,
|
|
29
|
-
shouldCloseOnInteractOutside: shouldCloseOnInteractOutside
|
|
30
|
-
}, groupRef !== null && groupRef !== void 0 ? groupRef : popoverRef);
|
|
31
|
-
let { overlayProps: positionProps, arrowProps: arrowProps, placement: placement, triggerAnchorPoint: origin } = (0, $e235061053e33ff6$export$d39e1813b3bdd0e1)({
|
|
32
|
-
...otherProps,
|
|
33
|
-
targetRef: triggerRef,
|
|
34
|
-
overlayRef: popoverRef,
|
|
35
|
-
isOpen: state.isOpen,
|
|
36
|
-
onClose: isNonModal && !isSubmenu ? state.close : null
|
|
37
|
-
});
|
|
38
|
-
(0, $2m0nK$usePreventScroll)({
|
|
39
|
-
isDisabled: isNonModal || !state.isOpen
|
|
40
|
-
});
|
|
41
|
-
(0, $2m0nK$useEffect)(()=>{
|
|
42
|
-
if (state.isOpen && popoverRef.current) {
|
|
43
|
-
var _groupRef_current;
|
|
44
|
-
if (isNonModal) return;
|
|
45
|
-
else return (0, $2m0nK$ariaHideOutside)([
|
|
46
|
-
(_groupRef_current = groupRef === null || groupRef === void 0 ? void 0 : groupRef.current) !== null && _groupRef_current !== void 0 ? _groupRef_current : popoverRef.current
|
|
47
|
-
], {
|
|
48
|
-
shouldUseInert: true
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}, [
|
|
52
|
-
isNonModal,
|
|
53
|
-
state.isOpen,
|
|
54
|
-
popoverRef,
|
|
55
|
-
groupRef
|
|
56
|
-
]);
|
|
57
|
-
return {
|
|
58
|
-
popoverProps: (0, $2m0nK$mergeProps)(overlayProps, positionProps),
|
|
59
|
-
arrowProps: arrowProps,
|
|
60
|
-
underlayProps: underlayProps,
|
|
61
|
-
placement: placement,
|
|
62
|
-
triggerAnchorPoint: origin
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
export {$87eca3bd2e28ca01$export$542a6fd13ac93354 as usePopover};
|
|
68
|
-
//# sourceMappingURL=usePopover.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;AAAA;;;;;;;;;;CAUC;;;;AAuEM,SAAS,0CAAW,KAAuB,EAAE,KAA0B;IAC5E,IAAI,cACF,UAAU,cACV,UAAU,YACV,QAAQ,cACR,UAAU,6BACV,yBAAyB,gCACzB,4BAA4B,EAC5B,GAAG,YACJ,GAAG;IAEJ,IAAI,YAAY,UAAU,CAAC,UAAU,KAAK;IAE1C,IAAI,gBAAC,YAAY,iBAAE,aAAa,EAAC,GAAG,CAAA,GAAA,iBAAS,EAC3C;QACE,QAAQ,MAAM,MAAM;QACpB,SAAS,MAAM,KAAK;QACpB,mBAAmB;QACnB,eAAe,CAAC,cAAc;mCAC9B;sCACA;IACF,GACA,qBAAA,sBAAA,WAAY;IAGd,IAAI,EAAC,cAAc,aAAa,cAAE,UAAU,aAAE,SAAS,EAAE,oBAAoB,MAAM,EAAC,GAAG,CAAA,GAAA,yCAAiB,EAAE;QACxG,GAAG,UAAU;QACb,WAAW;QACX,YAAY;QACZ,QAAQ,MAAM,MAAM;QACpB,SAAS,cAAc,CAAC,YAAY,MAAM,KAAK,GAAG;IACpD;IAEA,CAAA,GAAA,uBAAe,EAAE;QACf,YAAY,cAAc,CAAC,MAAM,MAAM;IACzC;IAEA,CAAA,GAAA,gBAAQ,EAAE;QACR,IAAI,MAAM,MAAM,IAAI,WAAW,OAAO,EAAE;gBAIZ;YAH1B,IAAI,YACF;iBAEA,OAAO,CAAA,GAAA,sBAAc,EAAE;gBAAC,CAAA,oBAAA,qBAAA,+BAAA,SAAU,OAAO,cAAjB,+BAAA,oBAAqB,WAAW,OAAO;aAAC,EAAE;gBAAC,gBAAgB;YAAI;QAE3F;IACF,GAAG;QAAC;QAAY,MAAM,MAAM;QAAE;QAAY;KAAS;IAEnD,OAAO;QACL,cAAc,CAAA,GAAA,iBAAS,EAAE,cAAc;oBACvC;uBACA;mBACA;QACA,oBAAoB;IACtB;AACF","sources":["packages/@react-spectrum/menu/src/usePopover.ts"],"sourcesContent":["/*\n * Copyright 2022 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {ariaHideOutside, AriaPositionProps, useOverlay, usePreventScroll} from '@react-aria/overlays';\nimport {DOMAttributes, RefObject} from '@react-types/shared';\nimport {mergeProps} from '@react-aria/utils';\nimport {OverlayTriggerState} from '@react-stately/overlays';\nimport {PlacementAxis} from '@react-types/overlays';\nimport {useEffect} from 'react';\nimport {useOverlayPosition} from './useOverlayPosition';\n\nexport interface AriaPopoverProps extends Omit<AriaPositionProps, 'isOpen' | 'onClose' | 'targetRef' | 'overlayRef'> {\n /**\n * The ref for the element which the popover positions itself with respect to.\n */\n triggerRef: RefObject<Element | null>,\n /**\n * The ref for the popover element.\n */\n popoverRef: RefObject<Element | null>,\n /** A ref for the popover arrow element. */\n arrowRef?: RefObject<Element | null>,\n /**\n * An optional ref for a group of popovers, e.g. submenus.\n * When provided, this element is used to detect outside interactions\n * and hiding elements from assistive technologies instead of the popoverRef.\n */\n groupRef?: RefObject<Element | null>,\n /**\n * Whether the popover is non-modal, i.e. elements outside the popover may be\n * interacted with by assistive technologies.\n *\n * Most popovers should not use this option as it may negatively impact the screen\n * reader experience. Only use with components such as combobox, which are designed\n * to handle this situation carefully.\n */\n isNonModal?: boolean,\n /**\n * Whether pressing the escape key to close the popover should be disabled.\n *\n * Most popovers should not use this option. When set to true, an alternative\n * way to close the popover with a keyboard must be provided.\n *\n * @default false\n */\n isKeyboardDismissDisabled?: boolean,\n /**\n * When user interacts with the argument element outside of the popover ref,\n * return true if onClose should be called. This gives you a chance to filter\n * out interaction with elements that should not dismiss the popover.\n * By default, onClose will always be called on interaction outside the popover ref.\n */\n shouldCloseOnInteractOutside?: (element: Element) => boolean\n}\n\nexport interface PopoverAria {\n /** Props for the popover element. */\n popoverProps: DOMAttributes,\n /** Props for the popover tip arrow if any. */\n arrowProps: DOMAttributes,\n /** Props to apply to the underlay element, if any. */\n underlayProps: DOMAttributes,\n /** Placement of the popover with respect to the trigger. */\n placement: PlacementAxis | null,\n /** The origin of the target in the overlay's coordinate system. Useful for animations. */\n triggerAnchorPoint: {x: number, y: number} | null\n}\n\n/**\n * Provides the behavior and accessibility implementation for a popover component.\n * A popover is an overlay element positioned relative to a trigger.\n */\nexport function usePopover(props: AriaPopoverProps, state: OverlayTriggerState): PopoverAria {\n let {\n triggerRef,\n popoverRef,\n groupRef,\n isNonModal,\n isKeyboardDismissDisabled,\n shouldCloseOnInteractOutside,\n ...otherProps\n } = props;\n\n let isSubmenu = otherProps['trigger'] === 'SubmenuTrigger';\n\n let {overlayProps, underlayProps} = useOverlay(\n {\n isOpen: state.isOpen,\n onClose: state.close,\n shouldCloseOnBlur: true,\n isDismissable: !isNonModal || isSubmenu,\n isKeyboardDismissDisabled,\n shouldCloseOnInteractOutside\n },\n groupRef ?? popoverRef\n );\n\n let {overlayProps: positionProps, arrowProps, placement, triggerAnchorPoint: origin} = useOverlayPosition({\n ...otherProps,\n targetRef: triggerRef,\n overlayRef: popoverRef,\n isOpen: state.isOpen,\n onClose: isNonModal && !isSubmenu ? state.close : null\n });\n\n usePreventScroll({\n isDisabled: isNonModal || !state.isOpen\n });\n\n useEffect(() => {\n if (state.isOpen && popoverRef.current) {\n if (isNonModal) {\n return;\n } else {\n return ariaHideOutside([groupRef?.current ?? popoverRef.current], {shouldUseInert: true});\n }\n }\n }, [isNonModal, state.isOpen, popoverRef, groupRef]);\n\n return {\n popoverProps: mergeProps(overlayProps, positionProps),\n arrowProps,\n underlayProps,\n placement,\n triggerAnchorPoint: origin\n };\n}\n"],"names":[],"version":3,"file":"usePopover.module.js.map"}
|
package/dist/zh-CN.main.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
"backButton": (args)=>`\u{8FD4}\u{56DE} ${args.prevMenuButton}`,
|
|
3
|
-
"moreActions": `\u{66F4}\u{591A}\u{64CD}\u{4F5C}`,
|
|
4
|
-
"unavailable": `\u{4E0D}\u{53EF}\u{7528}\u{FF0C}\u{5C55}\u{5F00}\u{4EE5}\u{67E5}\u{770B}\u{8BE6}\u{7EC6}\u{4FE1}\u{606F}`
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//# sourceMappingURL=zh-CN.main.js.map
|
package/dist/zh-CN.main.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA,iBAAiB;IAAG,cAAc,CAAC,OAAS,CAAC,iBAAG,EAAE,KAAK,cAAc,EAAE;IACrE,eAAe,CAAC,gCAAI,CAAC;IACrB,eAAe,CAAC,wGAAa,CAAC;AAChC","sources":["packages/@react-spectrum/menu/intl/zh-CN.json"],"sourcesContent":["{\n \"backButton\": \"返回 {prevMenuButton}\",\n \"moreActions\": \"更多操作\",\n \"unavailable\": \"不可用,展开以查看详细信息\"\n}\n"],"names":[],"version":3,"file":"zh-CN.main.js.map"}
|
package/dist/zh-CN.mjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var $57bb191f18e8be40$exports = {};
|
|
2
|
-
$57bb191f18e8be40$exports = {
|
|
3
|
-
"backButton": (args)=>`\u{8FD4}\u{56DE} ${args.prevMenuButton}`,
|
|
4
|
-
"moreActions": `\u{66F4}\u{591A}\u{64CD}\u{4F5C}`,
|
|
5
|
-
"unavailable": `\u{4E0D}\u{53EF}\u{7528}\u{FF0C}\u{5C55}\u{5F00}\u{4EE5}\u{67E5}\u{770B}\u{8BE6}\u{7EC6}\u{4FE1}\u{606F}`
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export {$57bb191f18e8be40$exports as default};
|
|
10
|
-
//# sourceMappingURL=zh-CN.module.js.map
|
package/dist/zh-CN.module.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var $57bb191f18e8be40$exports = {};
|
|
2
|
-
$57bb191f18e8be40$exports = {
|
|
3
|
-
"backButton": (args)=>`\u{8FD4}\u{56DE} ${args.prevMenuButton}`,
|
|
4
|
-
"moreActions": `\u{66F4}\u{591A}\u{64CD}\u{4F5C}`,
|
|
5
|
-
"unavailable": `\u{4E0D}\u{53EF}\u{7528}\u{FF0C}\u{5C55}\u{5F00}\u{4EE5}\u{67E5}\u{770B}\u{8BE6}\u{7EC6}\u{4FE1}\u{606F}`
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export {$57bb191f18e8be40$exports as default};
|
|
10
|
-
//# sourceMappingURL=zh-CN.module.js.map
|
package/dist/zh-CN.module.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";AAAA,4BAAiB;IAAG,cAAc,CAAC,OAAS,CAAC,iBAAG,EAAE,KAAK,cAAc,EAAE;IACrE,eAAe,CAAC,gCAAI,CAAC;IACrB,eAAe,CAAC,wGAAa,CAAC;AAChC","sources":["packages/@react-spectrum/menu/intl/zh-CN.json"],"sourcesContent":["{\n \"backButton\": \"返回 {prevMenuButton}\",\n \"moreActions\": \"更多操作\",\n \"unavailable\": \"不可用,展开以查看详细信息\"\n}\n"],"names":[],"version":3,"file":"zh-CN.module.js.map"}
|
package/dist/zh-TW.main.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
"backButton": (args)=>`\u{8FD4}\u{56DE} ${args.prevMenuButton}`,
|
|
3
|
-
"moreActions": `\u{66F4}\u{591A}\u{52D5}\u{4F5C}`,
|
|
4
|
-
"unavailable": `\u{7121}\u{6CD5}\u{4F7F}\u{7528}\u{FF0C}\u{5C55}\u{958B}\u{4EE5}\u{53D6}\u{5F97}\u{8A73}\u{7D30}\u{8CC7}\u{6599}`
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//# sourceMappingURL=zh-TW.main.js.map
|
package/dist/zh-TW.main.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA,iBAAiB;IAAG,cAAc,CAAC,OAAS,CAAC,iBAAG,EAAE,KAAK,cAAc,EAAE;IACrE,eAAe,CAAC,gCAAI,CAAC;IACrB,eAAe,CAAC,gHAAc,CAAC;AACjC","sources":["packages/@react-spectrum/menu/intl/zh-TW.json"],"sourcesContent":["{\n \"backButton\": \"返回 {prevMenuButton}\",\n \"moreActions\": \"更多動作\",\n \"unavailable\": \"無法使用,展開以取得詳細資料\"\n}\n"],"names":[],"version":3,"file":"zh-TW.main.js.map"}
|
package/dist/zh-TW.mjs
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var $56f3d9ca2967952d$exports = {};
|
|
2
|
-
$56f3d9ca2967952d$exports = {
|
|
3
|
-
"backButton": (args)=>`\u{8FD4}\u{56DE} ${args.prevMenuButton}`,
|
|
4
|
-
"moreActions": `\u{66F4}\u{591A}\u{52D5}\u{4F5C}`,
|
|
5
|
-
"unavailable": `\u{7121}\u{6CD5}\u{4F7F}\u{7528}\u{FF0C}\u{5C55}\u{958B}\u{4EE5}\u{53D6}\u{5F97}\u{8A73}\u{7D30}\u{8CC7}\u{6599}`
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export {$56f3d9ca2967952d$exports as default};
|
|
10
|
-
//# sourceMappingURL=zh-TW.module.js.map
|
package/dist/zh-TW.module.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
var $56f3d9ca2967952d$exports = {};
|
|
2
|
-
$56f3d9ca2967952d$exports = {
|
|
3
|
-
"backButton": (args)=>`\u{8FD4}\u{56DE} ${args.prevMenuButton}`,
|
|
4
|
-
"moreActions": `\u{66F4}\u{591A}\u{52D5}\u{4F5C}`,
|
|
5
|
-
"unavailable": `\u{7121}\u{6CD5}\u{4F7F}\u{7528}\u{FF0C}\u{5C55}\u{958B}\u{4EE5}\u{53D6}\u{5F97}\u{8A73}\u{7D30}\u{8CC7}\u{6599}`
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export {$56f3d9ca2967952d$exports as default};
|
|
10
|
-
//# sourceMappingURL=zh-TW.module.js.map
|
package/dist/zh-TW.module.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";AAAA,4BAAiB;IAAG,cAAc,CAAC,OAAS,CAAC,iBAAG,EAAE,KAAK,cAAc,EAAE;IACrE,eAAe,CAAC,gCAAI,CAAC;IACrB,eAAe,CAAC,gHAAc,CAAC;AACjC","sources":["packages/@react-spectrum/menu/intl/zh-TW.json"],"sourcesContent":["{\n \"backButton\": \"返回 {prevMenuButton}\",\n \"moreActions\": \"更多動作\",\n \"unavailable\": \"無法使用,展開以取得詳細資料\"\n}\n"],"names":[],"version":3,"file":"zh-TW.module.js.map"}
|
package/src/ActionMenu.tsx
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2021 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {ActionButton} from '@react-spectrum/button';
|
|
14
|
-
import {filterDOMProps} from '@react-aria/utils';
|
|
15
|
-
import {FocusableRef} from '@react-types/shared';
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
import intlMessages from '../intl/*.json';
|
|
18
|
-
import {Menu} from './Menu';
|
|
19
|
-
import {MenuTrigger} from './MenuTrigger';
|
|
20
|
-
import More from '@spectrum-icons/workflow/More';
|
|
21
|
-
import React, {forwardRef, ReactElement} from 'react';
|
|
22
|
-
import {SpectrumActionMenuProps} from '@react-types/menu';
|
|
23
|
-
import {useLocalizedStringFormatter} from '@react-aria/i18n';
|
|
24
|
-
import {useSlotProps} from '@react-spectrum/utils';
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* ActionMenu combines an ActionButton with a Menu for simple "more actions" use cases.
|
|
28
|
-
*/
|
|
29
|
-
export const ActionMenu = forwardRef(function ActionMenu<T extends object>(props: SpectrumActionMenuProps<T>, ref: FocusableRef<HTMLButtonElement>) {
|
|
30
|
-
props = useSlotProps(props, 'actionMenu');
|
|
31
|
-
let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/menu');
|
|
32
|
-
let buttonProps = filterDOMProps(props, {labelable: true});
|
|
33
|
-
if (buttonProps['aria-label'] === undefined) {
|
|
34
|
-
buttonProps['aria-label'] = stringFormatter.format('moreActions');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<MenuTrigger
|
|
39
|
-
isOpen={props.isOpen}
|
|
40
|
-
defaultOpen={props.defaultOpen}
|
|
41
|
-
onOpenChange={props.onOpenChange}
|
|
42
|
-
align={props.align}
|
|
43
|
-
direction={props.direction}
|
|
44
|
-
shouldFlip={props.shouldFlip}>
|
|
45
|
-
<ActionButton
|
|
46
|
-
ref={ref}
|
|
47
|
-
{...props}
|
|
48
|
-
{...buttonProps}>
|
|
49
|
-
<More />
|
|
50
|
-
</ActionButton>
|
|
51
|
-
<Menu
|
|
52
|
-
children={props.children}
|
|
53
|
-
items={props.items}
|
|
54
|
-
disabledKeys={props.disabledKeys}
|
|
55
|
-
onAction={props.onAction} />
|
|
56
|
-
</MenuTrigger>
|
|
57
|
-
);
|
|
58
|
-
}) as <T>(props: SpectrumActionMenuProps<T> & {ref?: FocusableRef<HTMLButtonElement>}) => ReactElement;
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2023 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {classNames, SlotProvider, unwrapDOMRef, useIsMobileDevice} from '@react-spectrum/utils';
|
|
14
|
-
import {DOMRefValue, ItemProps, Key} from '@react-types/shared';
|
|
15
|
-
import {FocusScope} from '@react-aria/focus';
|
|
16
|
-
import {getInteractionModality} from '@react-aria/interactions';
|
|
17
|
-
import helpStyles from '@adobe/spectrum-css-temp/components/contextualhelp/vars.css';
|
|
18
|
-
import {nodeContains} from '@react-aria/utils';
|
|
19
|
-
import {Popover} from './Popover';
|
|
20
|
-
import React, {JSX, KeyboardEventHandler, ReactElement, useEffect, useRef, useState} from 'react';
|
|
21
|
-
import ReactDOM from 'react-dom';
|
|
22
|
-
import styles from '@adobe/spectrum-css-temp/components/menu/vars.css';
|
|
23
|
-
import {SubmenuTriggerContext, useMenuStateContext} from './context';
|
|
24
|
-
import {TrayHeaderWrapper} from './Menu';
|
|
25
|
-
import {useSubmenuTrigger} from '@react-aria/menu';
|
|
26
|
-
import {useSubmenuTriggerState} from '@react-stately/menu';
|
|
27
|
-
|
|
28
|
-
interface MenuDialogTriggerProps {
|
|
29
|
-
/** Whether the menu item is currently unavailable. */
|
|
30
|
-
isUnavailable?: boolean,
|
|
31
|
-
/** The triggering Item and the Dialog, respectively. */
|
|
32
|
-
children: [ReactElement, ReactElement]
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface InternalMenuDialogTriggerProps extends MenuDialogTriggerProps {
|
|
36
|
-
targetKey: Key
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface SpectrumMenuDialogTriggerProps extends MenuDialogTriggerProps {}
|
|
40
|
-
|
|
41
|
-
function ContextualHelpTrigger(props: InternalMenuDialogTriggerProps): ReactElement {
|
|
42
|
-
let {isUnavailable = false, targetKey} = props;
|
|
43
|
-
|
|
44
|
-
let triggerRef = useRef<HTMLLIElement>(null);
|
|
45
|
-
let popoverRef = useRef<DOMRefValue<HTMLDivElement> | null>(null);
|
|
46
|
-
let {popoverContainer, trayContainerRef, rootMenuTriggerState, menu: parentMenuRef, state} = useMenuStateContext()!;
|
|
47
|
-
let submenuTriggerState = useSubmenuTriggerState({triggerKey: targetKey}, {...rootMenuTriggerState!, ...state});
|
|
48
|
-
let submenuRef = unwrapDOMRef(popoverRef);
|
|
49
|
-
let {submenuTriggerProps, popoverProps} = useSubmenuTrigger({
|
|
50
|
-
parentMenuRef,
|
|
51
|
-
submenuRef,
|
|
52
|
-
type: 'dialog',
|
|
53
|
-
isDisabled: !isUnavailable
|
|
54
|
-
}, submenuTriggerState, triggerRef);
|
|
55
|
-
let isMobile = useIsMobileDevice();
|
|
56
|
-
let [traySubmenuAnimation, setTraySubmenuAnimation] = useState('');
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
if (submenuTriggerState.isOpen) {
|
|
59
|
-
setTraySubmenuAnimation('spectrum-TraySubmenu-enter');
|
|
60
|
-
}
|
|
61
|
-
}, [submenuTriggerState.isOpen]);
|
|
62
|
-
let slots = {};
|
|
63
|
-
if (isUnavailable) {
|
|
64
|
-
slots = {
|
|
65
|
-
dialog: {
|
|
66
|
-
UNSAFE_className: classNames(
|
|
67
|
-
helpStyles,
|
|
68
|
-
'react-spectrum-ContextualHelp-dialog',
|
|
69
|
-
{
|
|
70
|
-
'react-spectrum-ContextualHelp-dialog--isMobile': isMobile
|
|
71
|
-
},
|
|
72
|
-
classNames(
|
|
73
|
-
styles,
|
|
74
|
-
{
|
|
75
|
-
'spectrum-Menu-subdialog': !isMobile,
|
|
76
|
-
[traySubmenuAnimation]: isMobile
|
|
77
|
-
}
|
|
78
|
-
)
|
|
79
|
-
)
|
|
80
|
-
},
|
|
81
|
-
content: {UNSAFE_className: helpStyles['react-spectrum-ContextualHelp-content']},
|
|
82
|
-
footer: {UNSAFE_className: helpStyles['react-spectrum-ContextualHelp-footer']}
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
let [trigger] = React.Children.toArray(props.children);
|
|
86
|
-
let [, content] = props.children as [ReactElement, ReactElement];
|
|
87
|
-
|
|
88
|
-
let onBlurWithin = (e) => {
|
|
89
|
-
if (e.relatedTarget && popoverRef.current && (!nodeContains(popoverRef.current.UNSAFE_getDOMNode(), e.relatedTarget) && !(e.relatedTarget === triggerRef.current && getInteractionModality() === 'pointer'))) {
|
|
90
|
-
if (submenuTriggerState.isOpen) {
|
|
91
|
-
submenuTriggerState.close();
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
let overlay;
|
|
97
|
-
let tray;
|
|
98
|
-
let onBackButtonPress = () => {
|
|
99
|
-
setTraySubmenuAnimation('spectrum-TraySubmenu-exit');
|
|
100
|
-
setTimeout(() => {
|
|
101
|
-
submenuTriggerState.close();
|
|
102
|
-
if (parentMenuRef.current && !nodeContains(parentMenuRef.current, document.activeElement)) {
|
|
103
|
-
parentMenuRef.current.focus();
|
|
104
|
-
}
|
|
105
|
-
}, 220); // Matches transition duration
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
if (isMobile) {
|
|
109
|
-
delete submenuTriggerProps.onBlur;
|
|
110
|
-
delete submenuTriggerProps.onHoverChange;
|
|
111
|
-
if (trayContainerRef.current && submenuTriggerState.isOpen) {
|
|
112
|
-
let subDialogKeyDown: KeyboardEventHandler = (e) => {
|
|
113
|
-
switch (e.key) {
|
|
114
|
-
case 'Escape':
|
|
115
|
-
e.stopPropagation();
|
|
116
|
-
onBackButtonPress();
|
|
117
|
-
break;
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
tray = (
|
|
122
|
-
<TrayHeaderWrapper
|
|
123
|
-
isSubmenu
|
|
124
|
-
parentMenuTreeState={state}
|
|
125
|
-
rootMenuTriggerState={rootMenuTriggerState}
|
|
126
|
-
wrapperKeyDown={subDialogKeyDown}
|
|
127
|
-
onBackButtonPress={onBackButtonPress}>
|
|
128
|
-
{content}
|
|
129
|
-
</TrayHeaderWrapper>
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
overlay = ReactDOM.createPortal(tray, trayContainerRef.current);
|
|
133
|
-
}
|
|
134
|
-
} else {
|
|
135
|
-
let onDismissButtonPress = () => {
|
|
136
|
-
submenuTriggerState.close();
|
|
137
|
-
parentMenuRef.current?.focus();
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
overlay = (
|
|
141
|
-
<Popover
|
|
142
|
-
{...popoverProps}
|
|
143
|
-
UNSAFE_style={{clipPath: 'unset', overflow: 'visible', filter: 'unset', borderWidth: '0px'}}
|
|
144
|
-
UNSAFE_className={classNames(styles, 'spectrum-Submenu-popover')}
|
|
145
|
-
onDismissButtonPress={onDismissButtonPress}
|
|
146
|
-
onBlurWithin={onBlurWithin}
|
|
147
|
-
container={popoverContainer!}
|
|
148
|
-
state={submenuTriggerState}
|
|
149
|
-
ref={popoverRef}
|
|
150
|
-
triggerRef={triggerRef}
|
|
151
|
-
placement="end top"
|
|
152
|
-
containerPadding={0}
|
|
153
|
-
hideArrow
|
|
154
|
-
enableBothDismissButtons>
|
|
155
|
-
<FocusScope restoreFocus contain>
|
|
156
|
-
{content}
|
|
157
|
-
</FocusScope>
|
|
158
|
-
</Popover>
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return (
|
|
163
|
-
<>
|
|
164
|
-
<SubmenuTriggerContext.Provider value={{isUnavailable, triggerRef, ...submenuTriggerProps}}>{trigger}</SubmenuTriggerContext.Provider>
|
|
165
|
-
<SlotProvider slots={slots}>
|
|
166
|
-
{submenuTriggerState.isOpen && overlay}
|
|
167
|
-
</SlotProvider>
|
|
168
|
-
</>
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
ContextualHelpTrigger.getCollectionNode = function* getCollectionNode<T>(props: ItemProps<T>) {
|
|
173
|
-
let childArray: ReactElement[] = [];
|
|
174
|
-
React.Children.forEach(props.children, child => {
|
|
175
|
-
if (React.isValidElement(child)) {
|
|
176
|
-
childArray.push(child);
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
let [trigger] = childArray;
|
|
180
|
-
let [, content] = props.children as [ReactElement, ReactElement];
|
|
181
|
-
|
|
182
|
-
yield {
|
|
183
|
-
element: React.cloneElement(trigger, {...trigger.props as any, hasChildItems: true, isTrigger: true}),
|
|
184
|
-
wrapper: (element) => (
|
|
185
|
-
<ContextualHelpTrigger key={element.key} targetKey={element.key} {...props}>
|
|
186
|
-
{element}
|
|
187
|
-
{content}
|
|
188
|
-
</ContextualHelpTrigger>
|
|
189
|
-
)
|
|
190
|
-
};
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
let _Item = ContextualHelpTrigger as unknown as (props: SpectrumMenuDialogTriggerProps) => JSX.Element;
|
|
194
|
-
export {_Item as ContextualHelpTrigger};
|