@ringcentral/spring-ui 1.11.2 → 1.13.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/Accordion.js +90 -34
- package/AccordionHeader.js +72 -20
- package/Alert.js +120 -28
- package/Animation.js +2 -45
- package/Announcement.js +46 -35
- package/Autocomplete.js +1011 -580
- package/Avatar.js +134 -73
- package/AvatarGroup.js +50 -7
- package/Backdrop.js +45 -7
- package/Badge.js +77 -15
- package/Block.js +34 -12
- package/BlockHeader.js +55 -11
- package/BottomNavigation.js +181 -65
- package/BottomNavigationItem.js +93 -30
- package/Button.js +160 -24
- package/CallButton.js +53 -31
- package/Checkbox.js +88 -26
- package/Chip.js +126 -26
- package/CircularProgressIndicator.js +80 -8
- package/ClickAwayListener.js +4 -1
- package/ComponentsProps.js +1 -0
- package/DatePicker.js +611 -190
- package/DateUtilsContext.js +43 -25
- package/Dialer.js +576 -250
- package/Dialog.js +100 -45
- package/Divider.js +43 -7
- package/DragHandle.js +32 -6
- package/Drawer.js +117 -19
- package/Dropdown.js +154 -74
- package/EmptyState.js +63 -11
- package/FabButton.js +51 -17
- package/FocusTrap.js +109 -12
- package/FormField.js +106 -8
- package/FormLabel.js +81 -7
- package/Icon.js +1 -8
- package/IconButton.js +142 -26
- package/IconButtonGroup.js +35 -12
- package/InlineEditable.js +98 -44
- package/LinearProgressIndicator.js +73 -24
- package/Link.js +40 -11
- package/List.js +54 -9
- package/ListItem.js +152 -23
- package/ListItemText.js +44 -16
- package/ListNavigation.js +272 -20
- package/Menu.js +139 -23
- package/MenuActions.js +37 -12
- package/MenuDivider.js +34 -8
- package/MenuFooter.js +36 -12
- package/MenuHeader.js +54 -15
- package/MenuItem.js +402 -33
- package/MenuItemText.js +51 -8
- package/MenuList.js +87 -34
- package/Modal.js +345 -16
- package/NestedMenuContext.js +183 -11
- package/Option.js +32 -34
- package/Overlap.js +54 -7
- package/PageHeader.js +62 -24
- package/PickerTextField.js +156 -33
- package/Popover.js +262 -21
- package/Popper.js +130 -77
- package/PopperPaper.js +54 -8
- package/Portal.js +6 -1
- package/Radio.js +65 -21
- package/RadioGroup.js +56 -17
- package/Rating.js +223 -87
- package/Select.js +387 -41
- package/SingleFilter.js +148 -77
- package/Skeleton.js +68 -17
- package/Slider.js +168 -69
- package/Snackbar.js +122 -59
- package/SortableList.js +32 -12
- package/SortableListDndContext.js +69 -22
- package/SortableListItem.js +92 -47
- package/SortableVirtualizedList.js +52 -28
- package/SplitButton.js +124 -86
- package/Squircle.js +4 -7
- package/StatusIndicator.js +51 -9
- package/Step.js +63 -38
- package/StepButton.js +51 -23
- package/StepConnector.js +48 -8
- package/StepContent.js +68 -25
- package/StepIcon.js +90 -9
- package/StepLabel.js +90 -14
- package/Stepper.js +65 -23
- package/SubMenu.js +203 -99
- package/SwipeableDrawer.js +439 -194
- package/Switch.js +70 -23
- package/Tab.js +120 -57
- package/TabContext.js +59 -15
- package/TabPanel.js +40 -13
- package/Table.js +60 -17
- package/TableBody.js +42 -12
- package/TableCell.js +84 -50
- package/TableContainer.js +32 -10
- package/TableFooter.js +38 -10
- package/TableHead.js +49 -15
- package/TablePagination.js +153 -77
- package/TableRow.js +60 -21
- package/Tabs.js +593 -268
- package/Tag.js +51 -16
- package/Text.js +68 -37
- package/TextField.js +209 -29
- package/Textarea.js +51 -40
- package/TimePicker.js +490 -230
- package/Tooltip.js +48 -23
- package/Tray.js +237 -13
- package/TrayMenu.js +62 -41
- package/VirtualizedList.js +208 -109
- package/VirtualizedMenu.js +359 -29
- package/VisuallyHidden.js +29 -6
- package/chunks/1250.js +98 -0
- package/chunks/1294.js +126 -0
- package/chunks/2956.js +18 -0
- package/chunks/4476.js +460 -0
- package/chunks/4491.js +10 -0
- package/chunks/4535.js +364 -0
- package/chunks/5047.js +3 -0
- package/chunks/6335.js +24 -0
- package/chunks/7279.js +10 -0
- package/chunks/8011.js +8 -0
- package/chunks/8307.js +56 -0
- package/chunks/8467.js +8 -0
- package/chunks/8809.js +8 -0
- package/chunks/{RadioGroup.context.js → 9551.js} +12 -6
- package/chunks/987.js +8 -0
- package/index.css +2624 -2416
- package/index.js +245 -193
- package/internal/utils/index.d.ts +1 -0
- package/internal/utils/setRef.d.ts +2 -0
- package/package.json +8 -8
- package/src/Alert/Alert.type.d.ts +2 -1
- package/src/Animation/components/Fade/Fade.d.ts +4 -2
- package/src/Animation/components/Grow/Grow.d.ts +4 -2
- package/src/Animation/components/ShowHideEye/ShowHideEye.d.ts +1 -1
- package/src/Animation/components/SlideIn/SlideIn.d.ts +4 -2
- package/src/Animation/components/SlideIn/getSlideIn.d.ts +1 -1
- package/src/Animation/hooks/useMotionSafeTransition/useMotionSafeTransition.d.ts +2 -0
- package/src/Autocomplete/SuggestionList/SuggestionList.d.ts +1 -1
- package/src/Autocomplete/useAutocomplete.d.ts +18 -18
- package/src/Autocomplete/useAutocompleteTag.d.ts +18 -18
- package/src/Badge/Badge.d.ts +2 -1
- package/src/Button/Button.classes.d.ts +1 -1
- package/src/ComponentsProps.d.ts +111 -110
- package/src/DatePicker/DatePickerDataAttributes.d.ts +11 -0
- package/src/DatePicker/utils/DatePickerAriaLabelUtils.d.ts +2 -1
- package/src/DatePicker/utils/DatePickerUtils.d.ts +1 -1
- package/src/Dialer/DialDelete/DialDelete.d.ts +2 -2
- package/src/Dialer/DialPad/DialPad.d.ts +2 -2
- package/src/Dialer/Dialer.d.ts +4 -2
- package/src/Dropdown/Dropdown.type.d.ts +2 -2
- package/src/InlineEditable/InlineEditable.type.d.ts +2 -1
- package/src/ListNavigation/useListNavigation.d.ts +3 -3
- package/src/MenuActions/MenuActions.d.ts +2 -2
- package/src/MenuItem/MenuItem.type.d.ts +1 -0
- package/src/MenuItem/useMenuItem.d.ts +1 -1
- package/src/MenuItem/useVirtualizedMenuItem.d.ts +1 -1
- package/src/MenuList/MenuList.type.d.ts +1 -1
- package/src/MenuList/MenuListContext.d.ts +2 -3
- package/src/Modal/Modal.type.d.ts +1 -0
- package/src/NestedMenuContext/MenuOverlayGroupContext.d.ts +2 -2
- package/src/Popover/Popover.classes.d.ts +1 -1
- package/src/Popover/Popover.internal.d.ts +8 -0
- package/src/Popover/Popover.type.d.ts +1 -0
- package/src/Popper/Popper.type.d.ts +10 -7
- package/src/Rating/utils.d.ts +3 -2
- package/src/Select/Select.type.d.ts +7 -5
- package/src/Slider/Slider.d.ts +2 -2
- package/src/Slider/SliderThumb.d.ts +2 -1
- package/src/Squircle/Squircle.d.ts +1 -1
- package/src/StatusIndicator/StatusIndicator.d.ts +2 -1
- package/src/SubMenu/PopperMenu.type.d.ts +4 -1
- package/src/Table/Table.type.d.ts +3 -0
- package/src/Table/TableContext.d.ts +3 -0
- package/src/Table/TableRowContext.d.ts +7 -0
- package/src/Table/index.d.ts +1 -0
- package/src/TableCell/TableCell.classes.d.ts +1 -1
- package/src/TableFooter/TableFooter.classes.d.ts +1 -1
- package/src/TableFooter/TableFooter.type.d.ts +1 -0
- package/src/TableHead/TableHead.classes.d.ts +1 -1
- package/src/TableHead/TableHead.type.d.ts +1 -0
- package/src/TableRow/TableRow.type.d.ts +2 -0
- package/chunks/AccordionContext.js +0 -6
- package/chunks/Alert.js +0 -48
- package/chunks/AvatarGroup.js +0 -22
- package/chunks/Backdrop.js +0 -18
- package/chunks/Badge.js +0 -32
- package/chunks/BottomNavigationItem.js +0 -36
- package/chunks/Button.js +0 -88
- package/chunks/Chip.js +0 -73
- package/chunks/CircularProgressIndicator.js +0 -36
- package/chunks/Divider.js +0 -19
- package/chunks/DragHandle.js +0 -11
- package/chunks/Drawer.js +0 -32
- package/chunks/ExpandCollapseCaret.js +0 -24
- package/chunks/FormLabel.js +0 -27
- package/chunks/Icon.js +0 -25
- package/chunks/IconButtonLabel.js +0 -68
- package/chunks/List.js +0 -22
- package/chunks/ListItem.js +0 -83
- package/chunks/Menu.js +0 -61
- package/chunks/MenuDivider.js +0 -14
- package/chunks/MenuItemText.js +0 -17
- package/chunks/MenuList.js +0 -46
- package/chunks/Modal.js +0 -212
- package/chunks/Overlap.js +0 -25
- package/chunks/PickerTextField.js +0 -85
- package/chunks/Popover.js +0 -53
- package/chunks/PopperPaper.js +0 -15
- package/chunks/Select.js +0 -220
- package/chunks/ShowHideEye.js +0 -56
- package/chunks/SlideIn.js +0 -19
- package/chunks/SortableArrow.js +0 -73
- package/chunks/Squircle.js +0 -31
- package/chunks/StatusIndicator.js +0 -20
- package/chunks/StepConnector.js +0 -21
- package/chunks/StepIcon.js +0 -43
- package/chunks/StepLabel.js +0 -29
- package/chunks/StepperContext.js +0 -9
- package/chunks/TableContext.js +0 -6
- package/chunks/Tablelvl2Context.js +0 -6
- package/chunks/TabsContext.js +0 -6
- package/chunks/TextField.js +0 -110
- package/chunks/Tooltip.js +0 -217
- package/chunks/VirtualizedMenu.js +0 -164
- package/chunks/VisuallyHidden.js +0 -12
- package/chunks/getFade.js +0 -27
- package/chunks/getGrow.js +0 -70
- package/chunks/getSlideIn.js +0 -30
- package/chunks/hasContent.js +0 -3
- package/chunks/useAnimationFrame.js +0 -15
- package/chunks/useFocusTrapStack.js +0 -36
- package/chunks/useHelperTextId.js +0 -22
- package/chunks/useListNavigation.js +0 -199
- package/chunks/useMenuItemSelect.js +0 -273
- package/chunks/useMotionSafeTransition.js +0 -9
- package/chunks/useNestedMenuItem.js +0 -27
- package/chunks/useNestedParentMenu.js +0 -113
- package/chunks/usePrefersReducedMotion.js +0 -36
- package/chunks/useTooltipForceHide.js +0 -27
- package/chunks/useTrayNavigate.js +0 -150
- package/chunks/withTooltip.js +0 -15
package/SubMenu.js
CHANGED
|
@@ -1,126 +1,159 @@
|
|
|
1
|
-
import { jsx, jsxs
|
|
2
|
-
import { forwardRef,
|
|
3
|
-
import { useClasses,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
import './chunks/useAnimationFrame.js';
|
|
26
|
-
import './ListNavigation.js';
|
|
27
|
-
import './chunks/Popover.js';
|
|
28
|
-
import './chunks/getGrow.js';
|
|
29
|
-
import './chunks/PopperPaper.js';
|
|
30
|
-
import 'react-virtuoso';
|
|
31
|
-
import './chunks/List.js';
|
|
32
|
-
import './chunks/hasContent.js';
|
|
33
|
-
|
|
34
|
-
var PopperMenu$1 = {"sui-popper-menu-root":"sui-popper-menu-root","sui-popper-menu-paper":"sui-popper-menu-paper"};
|
|
35
|
-
|
|
36
|
-
const PopperMenu = forwardRef((props, ref) => {
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
+
import { useClasses, useEventCallback, useFocusVisible, useForkRef, useId, useWindowContext } from "@ringcentral/spring-base";
|
|
4
|
+
import { CaretRightMd } from "@ringcentral/spring-icon";
|
|
5
|
+
import { useThemeProps } from "@ringcentral/spring-theme";
|
|
6
|
+
import { useNestedParentMenu, useNestedChildMenu, useNestedMenuItem, NestedMenuContext } from "./NestedMenuContext.js";
|
|
7
|
+
import { Popper } from "./Popper.js";
|
|
8
|
+
import { Icon as Icon_Icon } from "./chunks/8307.js";
|
|
9
|
+
import { SubMenuTriggerNestedIdContext, MenuItem as MenuItem_MenuItem } from "./MenuItem.js";
|
|
10
|
+
import { useMenuOverlayGroupContext } from "./Menu.js";
|
|
11
|
+
import { MenuItemText as MenuItemText_MenuItemText } from "./MenuItemText.js";
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// extracted by css-extract-rspack-plugin
|
|
17
|
+
/* export default */ var PopperMenu = ({"sui-popper-menu-root":"sui-popper-menu-root","sui-popper-menu-paper":"sui-popper-menu-paper"});
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
const PopperMenu_PopperMenu = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
37
25
|
const { classes, children, actions, className, onClickCapture, onPointerMove, ...rest } = props;
|
|
38
26
|
const cls = useClasses('popper-menu', classes, className);
|
|
39
27
|
const { contentClickHandlers, contentPointerHandlers, contextValue } = useNestedParentMenu({
|
|
40
|
-
open: true
|
|
28
|
+
open: true
|
|
41
29
|
});
|
|
42
|
-
return
|
|
30
|
+
return /*#__PURE__*/ jsx(Popper, {
|
|
31
|
+
className: cls('root'),
|
|
32
|
+
...rest,
|
|
33
|
+
onClickCapture: (event)=>{
|
|
43
34
|
onClickCapture?.(event);
|
|
44
35
|
contentClickHandlers.onClickCapture(event);
|
|
45
|
-
},
|
|
36
|
+
},
|
|
37
|
+
onPointerMove: (event)=>{
|
|
46
38
|
onPointerMove?.(event);
|
|
47
39
|
contentPointerHandlers.onPointerMove(event);
|
|
48
|
-
},
|
|
40
|
+
},
|
|
41
|
+
ref: ref,
|
|
42
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
43
|
+
className: cls('paper'),
|
|
44
|
+
children: /*#__PURE__*/ jsx(NestedMenuContext.Provider, {
|
|
45
|
+
value: contextValue,
|
|
46
|
+
children: children
|
|
47
|
+
})
|
|
48
|
+
})
|
|
49
|
+
});
|
|
49
50
|
});
|
|
50
|
-
|
|
51
|
+
PopperMenu_PopperMenu.displayName = 'SuiPopperMenu';
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
51
57
|
|
|
52
|
-
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
const useSubMenuInteractionState = ({ open, focusVisibleWithin, isPointerGraceActive, clearPointerGrace })=>{
|
|
53
62
|
const [hasEnteredMenuContent, setHasEnteredMenuContent] = useState(false);
|
|
54
63
|
const [isPointerInsideTrigger, setIsPointerInsideTrigger] = useState(false);
|
|
55
|
-
const resetInteractionState = useCallback(()
|
|
64
|
+
const resetInteractionState = useCallback(()=>{
|
|
56
65
|
setHasEnteredMenuContent(false);
|
|
57
66
|
setIsPointerInsideTrigger(false);
|
|
58
67
|
}, []);
|
|
59
|
-
const markTriggerPointerMoved = useCallback(()
|
|
68
|
+
const markTriggerPointerMoved = useCallback(()=>{
|
|
60
69
|
setIsPointerInsideTrigger(true);
|
|
61
70
|
setHasEnteredMenuContent(false);
|
|
62
71
|
}, []);
|
|
63
|
-
const markTriggerPointerLeft = useCallback(()
|
|
72
|
+
const markTriggerPointerLeft = useCallback(()=>{
|
|
64
73
|
setIsPointerInsideTrigger(false);
|
|
65
74
|
setHasEnteredMenuContent(false);
|
|
66
75
|
}, []);
|
|
67
|
-
const markMenuContentEntered = useCallback(()
|
|
76
|
+
const markMenuContentEntered = useCallback(()=>{
|
|
68
77
|
setHasEnteredMenuContent(true);
|
|
69
78
|
clearPointerGrace();
|
|
70
|
-
}, [
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
useEffect(() => {
|
|
79
|
+
}, [
|
|
80
|
+
clearPointerGrace
|
|
81
|
+
]);
|
|
82
|
+
const shouldKeepSubMenuOpen = isPointerInsideTrigger || hasEnteredMenuContent || focusVisibleWithin || isPointerGraceActive;
|
|
83
|
+
useEffect(()=>{
|
|
76
84
|
if (!open) {
|
|
77
85
|
resetInteractionState();
|
|
78
86
|
}
|
|
79
|
-
}, [
|
|
87
|
+
}, [
|
|
88
|
+
open,
|
|
89
|
+
resetInteractionState
|
|
90
|
+
]);
|
|
80
91
|
return {
|
|
81
92
|
markTriggerPointerLeft,
|
|
82
93
|
markTriggerPointerMoved,
|
|
83
94
|
markMenuContentEntered,
|
|
84
95
|
resetInteractionState,
|
|
85
|
-
shouldKeepSubMenuOpen
|
|
96
|
+
shouldKeepSubMenuOpen
|
|
86
97
|
};
|
|
87
98
|
};
|
|
88
99
|
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
89
104
|
const POINTER_GRACE_TIMEOUT = 300;
|
|
90
105
|
const POINTER_GRACE_BLEED = 5;
|
|
91
|
-
const getSubMenuSide = (anchorRect, menuRect)
|
|
106
|
+
const getSubMenuSide = (anchorRect, menuRect)=>{
|
|
92
107
|
const anchorCenterX = anchorRect.left + anchorRect.width / 2;
|
|
93
108
|
const menuCenterX = menuRect.left + menuRect.width / 2;
|
|
94
109
|
return menuCenterX >= anchorCenterX ? 'right' : 'left';
|
|
95
110
|
};
|
|
96
|
-
const getPointerGraceIntent = (event, menuRect, side)
|
|
111
|
+
const getPointerGraceIntent = (event, menuRect, side)=>{
|
|
97
112
|
const bleed = side === 'right' ? -POINTER_GRACE_BLEED : POINTER_GRACE_BLEED;
|
|
98
113
|
const contentNearEdge = menuRect[side === 'right' ? 'left' : 'right'];
|
|
99
114
|
const contentFarEdge = menuRect[side === 'right' ? 'right' : 'left'];
|
|
100
115
|
return {
|
|
101
116
|
area: [
|
|
102
|
-
{
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
{
|
|
117
|
+
{
|
|
118
|
+
x: event.clientX + bleed,
|
|
119
|
+
y: event.clientY
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
x: contentNearEdge,
|
|
123
|
+
y: menuRect.top
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
x: contentFarEdge,
|
|
127
|
+
y: menuRect.top
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
x: contentFarEdge,
|
|
131
|
+
y: menuRect.bottom
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
x: contentNearEdge,
|
|
135
|
+
y: menuRect.bottom
|
|
136
|
+
}
|
|
107
137
|
],
|
|
108
|
-
side
|
|
138
|
+
side
|
|
109
139
|
};
|
|
110
140
|
};
|
|
111
|
-
const useSubMenuPointerGrace = (props)
|
|
141
|
+
const useSubMenuPointerGrace = (props)=>{
|
|
112
142
|
const { isPointerMovingToSubMenu, onPointerGraceIntentChange } = props;
|
|
113
143
|
const { externalWindow, globalThis: contextGlobal } = useWindowContext();
|
|
114
144
|
const contextWindow = externalWindow ?? contextGlobal;
|
|
115
145
|
const [isPointerGraceActive, setIsPointerGraceActive] = useState(false);
|
|
116
146
|
const timerRef = useRef();
|
|
117
|
-
const clearPointerGrace = useCallback(()
|
|
147
|
+
const clearPointerGrace = useCallback(()=>{
|
|
118
148
|
contextWindow.clearTimeout(timerRef.current);
|
|
119
149
|
timerRef.current = undefined;
|
|
120
150
|
setIsPointerGraceActive(false);
|
|
121
151
|
onPointerGraceIntentChange?.(null);
|
|
122
|
-
}, [
|
|
123
|
-
|
|
152
|
+
}, [
|
|
153
|
+
contextWindow,
|
|
154
|
+
onPointerGraceIntentChange
|
|
155
|
+
]);
|
|
156
|
+
const startPointerGrace = useCallback((event, anchorElement, menuElement)=>{
|
|
124
157
|
if (!anchorElement || !menuElement) {
|
|
125
158
|
clearPointerGrace();
|
|
126
159
|
return;
|
|
@@ -146,23 +179,43 @@ const useSubMenuPointerGrace = (props) => {
|
|
|
146
179
|
clearPointerGrace,
|
|
147
180
|
contextWindow,
|
|
148
181
|
isPointerMovingToSubMenu,
|
|
149
|
-
onPointerGraceIntentChange
|
|
182
|
+
onPointerGraceIntentChange
|
|
150
183
|
]);
|
|
151
|
-
useEffect(()
|
|
184
|
+
useEffect(()=>{
|
|
152
185
|
return clearPointerGrace;
|
|
153
|
-
}, [
|
|
186
|
+
}, [
|
|
187
|
+
clearPointerGrace
|
|
188
|
+
]);
|
|
154
189
|
return {
|
|
155
190
|
isPointerGraceActive,
|
|
156
191
|
clearPointerGrace,
|
|
157
|
-
startPointerGrace
|
|
192
|
+
startPointerGrace
|
|
158
193
|
};
|
|
159
194
|
};
|
|
160
195
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
const isSubMenuNavigationOpenEvent = (event)=>[
|
|
211
|
+
'ArrowRight'
|
|
212
|
+
].includes(event.key);
|
|
213
|
+
const isSubMenuKeyboardActivationEvent = (event)=>event.type === 'keydown' && event.key === 'Enter' || event.type === 'keyup' && event.key === ' ';
|
|
214
|
+
const SubMenu = /*#__PURE__*/ forwardRef((inProps, ref)=>{
|
|
215
|
+
const props = useThemeProps({
|
|
216
|
+
props: inProps,
|
|
217
|
+
name: 'SubMenu'
|
|
218
|
+
});
|
|
166
219
|
const { classes, children, itemContent, onClick: onClickProp, onKeyDown: onKeyDownProp, onPointerLeave: onPointerLeaveProp, onPointerMove: onPointerMoveProp, disabled, ...rest } = props;
|
|
167
220
|
const [anchor, setAnchor] = useState(null);
|
|
168
221
|
const itemRef = useRef(null);
|
|
@@ -170,21 +223,23 @@ const SubMenu = forwardRef((inProps, ref) => {
|
|
|
170
223
|
const menuRef = useRef(null);
|
|
171
224
|
const open = Boolean(anchor);
|
|
172
225
|
const id = useId();
|
|
173
|
-
const { isPointerMovingToSubMenu, onPointerGraceIntentChange } = useNestedMenuItem({
|
|
226
|
+
const { isPointerMovingToSubMenu, onPointerGraceIntentChange } = useNestedMenuItem({
|
|
227
|
+
id
|
|
228
|
+
});
|
|
174
229
|
const { isPointerGraceActive, clearPointerGrace, startPointerGrace } = useSubMenuPointerGrace({
|
|
175
230
|
isPointerMovingToSubMenu,
|
|
176
|
-
onPointerGraceIntentChange
|
|
231
|
+
onPointerGraceIntentChange
|
|
177
232
|
});
|
|
178
233
|
const { focusVisibleWithin, focusVisibleHandlers } = useFocusVisible({
|
|
179
|
-
within: true
|
|
234
|
+
within: true
|
|
180
235
|
});
|
|
181
|
-
const { markTriggerPointerLeft, markTriggerPointerMoved, markMenuContentEntered, resetInteractionState, shouldKeepSubMenuOpen
|
|
236
|
+
const { markTriggerPointerLeft, markTriggerPointerMoved, markMenuContentEntered, resetInteractionState, shouldKeepSubMenuOpen } = useSubMenuInteractionState({
|
|
182
237
|
open,
|
|
183
238
|
focusVisibleWithin,
|
|
184
239
|
isPointerGraceActive,
|
|
185
|
-
clearPointerGrace
|
|
240
|
+
clearPointerGrace
|
|
186
241
|
});
|
|
187
|
-
const closeSubMenu = useEventCallback((options)
|
|
242
|
+
const closeSubMenu = useEventCallback((options)=>{
|
|
188
243
|
if (options?.restoreFocus) {
|
|
189
244
|
itemRef.current?.focus();
|
|
190
245
|
}
|
|
@@ -194,7 +249,7 @@ const SubMenu = forwardRef((inProps, ref) => {
|
|
|
194
249
|
});
|
|
195
250
|
const overlayGroupContext = useMenuOverlayGroupContext();
|
|
196
251
|
const overlayContainer = overlayGroupContext?.container;
|
|
197
|
-
const handleTriggerPointerMove = (event)
|
|
252
|
+
const handleTriggerPointerMove = (event)=>{
|
|
198
253
|
onPointerMoveProp?.(event);
|
|
199
254
|
if (event.pointerType !== 'mouse' || event.defaultPrevented || disabled) {
|
|
200
255
|
return;
|
|
@@ -207,32 +262,45 @@ const SubMenu = forwardRef((inProps, ref) => {
|
|
|
207
262
|
clearPointerGrace();
|
|
208
263
|
setAnchor(event.currentTarget);
|
|
209
264
|
};
|
|
210
|
-
const handleTriggerPointerLeave = (event)
|
|
265
|
+
const handleTriggerPointerLeave = (event)=>{
|
|
211
266
|
onPointerLeaveProp?.(event);
|
|
212
267
|
if (event.pointerType === 'mouse') {
|
|
213
268
|
markTriggerPointerLeft();
|
|
214
269
|
startPointerGrace(event, itemRef.current, menuRef.current);
|
|
215
270
|
}
|
|
216
271
|
};
|
|
217
|
-
const openSubMenuFromTrigger = (trigger)
|
|
272
|
+
const openSubMenuFromTrigger = (trigger)=>{
|
|
218
273
|
markMenuContentEntered();
|
|
219
274
|
setAnchor(trigger);
|
|
220
275
|
};
|
|
221
|
-
const getAnchorElement = useCallback(()
|
|
276
|
+
const getAnchorElement = useCallback(()=>itemRef.current, []);
|
|
222
277
|
useNestedChildMenu({
|
|
223
278
|
open,
|
|
224
279
|
closeMenu: closeSubMenu,
|
|
225
280
|
getAnchorElement,
|
|
226
|
-
id
|
|
281
|
+
id
|
|
227
282
|
});
|
|
228
|
-
useEffect(()
|
|
229
|
-
if (!open)
|
|
230
|
-
return;
|
|
283
|
+
useEffect(()=>{
|
|
284
|
+
if (!open) return;
|
|
231
285
|
if (!shouldKeepSubMenuOpen) {
|
|
232
286
|
closeSubMenu();
|
|
233
287
|
}
|
|
234
|
-
}, [
|
|
235
|
-
|
|
288
|
+
}, [
|
|
289
|
+
closeSubMenu,
|
|
290
|
+
open,
|
|
291
|
+
shouldKeepSubMenuOpen
|
|
292
|
+
]);
|
|
293
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
294
|
+
children: [
|
|
295
|
+
/*#__PURE__*/ jsx(SubMenuTriggerNestedIdContext.Provider, {
|
|
296
|
+
value: id,
|
|
297
|
+
children: /*#__PURE__*/ jsxs(MenuItem_MenuItem, {
|
|
298
|
+
"aria-haspopup": "menu",
|
|
299
|
+
...rest,
|
|
300
|
+
"aria-expanded": open,
|
|
301
|
+
autoClose: false,
|
|
302
|
+
disabled: disabled,
|
|
303
|
+
onKeyDown: (e)=>{
|
|
236
304
|
if (disabled) {
|
|
237
305
|
return;
|
|
238
306
|
}
|
|
@@ -243,7 +311,8 @@ const SubMenu = forwardRef((inProps, ref) => {
|
|
|
243
311
|
if (isSubMenuNavigationOpenEvent(e)) {
|
|
244
312
|
openSubMenuFromTrigger(e.currentTarget);
|
|
245
313
|
}
|
|
246
|
-
},
|
|
314
|
+
},
|
|
315
|
+
onClick: (e)=>{
|
|
247
316
|
if (disabled) {
|
|
248
317
|
return;
|
|
249
318
|
}
|
|
@@ -254,18 +323,53 @@ const SubMenu = forwardRef((inProps, ref) => {
|
|
|
254
323
|
if (isSubMenuKeyboardActivationEvent(e)) {
|
|
255
324
|
openSubMenuFromTrigger(e.currentTarget);
|
|
256
325
|
}
|
|
257
|
-
},
|
|
258
|
-
|
|
259
|
-
|
|
326
|
+
},
|
|
327
|
+
onPointerMove: handleTriggerPointerMove,
|
|
328
|
+
onPointerLeave: handleTriggerPointerLeave,
|
|
329
|
+
ref: handleRef,
|
|
330
|
+
children: [
|
|
331
|
+
typeof itemContent === 'string' ? /*#__PURE__*/ jsx(MenuItemText_MenuItemText, {
|
|
332
|
+
children: itemContent
|
|
333
|
+
}) : itemContent,
|
|
334
|
+
/*#__PURE__*/ jsx(Icon_Icon, {
|
|
335
|
+
symbol: CaretRightMd
|
|
336
|
+
})
|
|
337
|
+
]
|
|
338
|
+
})
|
|
339
|
+
}),
|
|
340
|
+
open && /*#__PURE__*/ jsx(PopperMenu_PopperMenu, {
|
|
341
|
+
anchorEl: anchor,
|
|
342
|
+
container: overlayContainer ?? undefined,
|
|
343
|
+
disablePortal: overlayContainer ? false : undefined,
|
|
344
|
+
placement: "right-start",
|
|
345
|
+
offset: -4,
|
|
346
|
+
ref: menuRef,
|
|
347
|
+
onKeyDown: (e)=>{
|
|
348
|
+
if ((e.key === 'ArrowLeft' || e.key === 'Escape') && e.currentTarget.contains(e.target)) {
|
|
260
349
|
e.stopPropagation();
|
|
261
|
-
closeSubMenu({
|
|
350
|
+
closeSubMenu({
|
|
351
|
+
restoreFocus: true
|
|
352
|
+
});
|
|
262
353
|
}
|
|
263
|
-
},
|
|
354
|
+
},
|
|
355
|
+
onPointerMove: (event)=>{
|
|
264
356
|
if (event.pointerType === 'mouse') {
|
|
265
357
|
markMenuContentEntered();
|
|
266
358
|
}
|
|
267
|
-
},
|
|
359
|
+
},
|
|
360
|
+
...focusVisibleHandlers,
|
|
361
|
+
children: children
|
|
362
|
+
})
|
|
363
|
+
]
|
|
364
|
+
});
|
|
268
365
|
});
|
|
269
366
|
SubMenu.displayName = 'SuiSubMenu';
|
|
270
367
|
|
|
271
|
-
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
export { PopperMenu as popperMenuStyle, PopperMenu_PopperMenu as PopperMenu, SubMenu };
|