@ringcentral/spring-ui 1.12.0 → 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 +71 -21
- package/Alert.js +120 -28
- package/Animation.js +2 -46
- package/Announcement.js +46 -35
- package/Autocomplete.js +1011 -583
- 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 +57 -15
- 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 -192
- package/DateUtilsContext.js +43 -25
- package/Dialer.js +564 -253
- package/Dialog.js +99 -45
- package/Divider.js +43 -7
- package/DragHandle.js +32 -6
- package/Drawer.js +117 -19
- package/Dropdown.js +154 -77
- package/EmptyState.js +65 -15
- package/FabButton.js +51 -17
- package/FocusTrap.js +109 -12
- package/FormField.js +108 -12
- 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 -17
- 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 -16
- package/MenuItem.js +402 -35
- package/MenuItemText.js +51 -9
- package/MenuList.js +87 -36
- package/Modal.js +345 -16
- package/NestedMenuContext.js +183 -11
- package/Option.js +32 -36
- package/Overlap.js +54 -7
- package/PageHeader.js +62 -24
- package/PickerTextField.js +156 -35
- package/Popover.js +262 -21
- package/Popper.js +112 -62
- 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 -44
- package/SingleFilter.js +148 -79
- package/Skeleton.js +68 -17
- package/Slider.js +167 -69
- package/Snackbar.js +122 -59
- package/SortableList.js +32 -12
- package/SortableListDndContext.js +69 -22
- package/SortableListItem.js +92 -47
- package/SortableVirtualizedList.js +44 -20
- package/SplitButton.js +124 -89
- 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 +67 -24
- package/StepIcon.js +90 -9
- package/StepLabel.js +90 -14
- package/Stepper.js +65 -23
- package/SubMenu.js +203 -101
- 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 -79
- package/TableRow.js +60 -21
- package/Tabs.js +592 -271
- package/Tag.js +51 -16
- package/Text.js +68 -37
- package/TextField.js +209 -31
- package/Textarea.js +51 -42
- package/TimePicker.js +490 -232
- package/Tooltip.js +48 -23
- package/Tray.js +237 -13
- package/TrayMenu.js +62 -43
- package/VirtualizedList.js +205 -107
- 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 +2436 -2261
- package/index.js +245 -195
- package/internal/utils/setRef.d.ts +2 -1
- package/package.json +4 -4
- package/src/Animation/hooks/useMotionSafeTransition/useMotionSafeTransition.d.ts +2 -0
- package/src/Autocomplete/SuggestionList/SuggestionList.d.ts +1 -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/DatePickerUtils.d.ts +1 -1
- package/src/MenuItem/MenuItem.type.d.ts +1 -0
- package/src/MenuList/MenuListContext.d.ts +2 -3
- package/src/Modal/Modal.type.d.ts +1 -0
- 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/Select/Select.type.d.ts +6 -4
- 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 -33
- 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 -18
- package/chunks/MenuList.js +0 -47
- package/chunks/Modal.js +0 -211
- package/chunks/Overlap.js +0 -25
- package/chunks/PickerTextField.js +0 -85
- package/chunks/Popover.js +0 -61
- package/chunks/PopperPaper.js +0 -15
- package/chunks/Select.js +0 -225
- package/chunks/ShowHideEye.js +0 -56
- package/chunks/SlideIn.js +0 -20
- 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 -162
- package/chunks/VisuallyHidden.js +0 -12
- package/chunks/composeEventHandlers.js +0 -10
- 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 -38
- package/chunks/useHelperTextId.js +0 -24
- package/chunks/useListNavigation.js +0 -199
- package/chunks/useMenuItemSelect.js +0 -282
- 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,128 +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/Backdrop.js';
|
|
26
|
-
import './chunks/useAnimationFrame.js';
|
|
27
|
-
import './chunks/composeEventHandlers.js';
|
|
28
|
-
import './ListNavigation.js';
|
|
29
|
-
import './chunks/Popover.js';
|
|
30
|
-
import './chunks/getGrow.js';
|
|
31
|
-
import './chunks/PopperPaper.js';
|
|
32
|
-
import 'react-virtuoso';
|
|
33
|
-
import './chunks/List.js';
|
|
34
|
-
import './chunks/hasContent.js';
|
|
35
|
-
|
|
36
|
-
var PopperMenu$1 = {"sui-popper-menu-root":"sui-popper-menu-root","sui-popper-menu-paper":"sui-popper-menu-paper"};
|
|
37
|
-
|
|
38
|
-
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)=>{
|
|
39
25
|
const { classes, children, actions, className, onClickCapture, onPointerMove, ...rest } = props;
|
|
40
26
|
const cls = useClasses('popper-menu', classes, className);
|
|
41
27
|
const { contentClickHandlers, contentPointerHandlers, contextValue } = useNestedParentMenu({
|
|
42
|
-
open: true
|
|
28
|
+
open: true
|
|
43
29
|
});
|
|
44
|
-
return
|
|
30
|
+
return /*#__PURE__*/ jsx(Popper, {
|
|
31
|
+
className: cls('root'),
|
|
32
|
+
...rest,
|
|
33
|
+
onClickCapture: (event)=>{
|
|
45
34
|
onClickCapture?.(event);
|
|
46
35
|
contentClickHandlers.onClickCapture(event);
|
|
47
|
-
},
|
|
36
|
+
},
|
|
37
|
+
onPointerMove: (event)=>{
|
|
48
38
|
onPointerMove?.(event);
|
|
49
39
|
contentPointerHandlers.onPointerMove(event);
|
|
50
|
-
},
|
|
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
|
+
});
|
|
51
50
|
});
|
|
52
|
-
|
|
51
|
+
PopperMenu_PopperMenu.displayName = 'SuiPopperMenu';
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
53
57
|
|
|
54
|
-
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
const useSubMenuInteractionState = ({ open, focusVisibleWithin, isPointerGraceActive, clearPointerGrace })=>{
|
|
55
62
|
const [hasEnteredMenuContent, setHasEnteredMenuContent] = useState(false);
|
|
56
63
|
const [isPointerInsideTrigger, setIsPointerInsideTrigger] = useState(false);
|
|
57
|
-
const resetInteractionState = useCallback(()
|
|
64
|
+
const resetInteractionState = useCallback(()=>{
|
|
58
65
|
setHasEnteredMenuContent(false);
|
|
59
66
|
setIsPointerInsideTrigger(false);
|
|
60
67
|
}, []);
|
|
61
|
-
const markTriggerPointerMoved = useCallback(()
|
|
68
|
+
const markTriggerPointerMoved = useCallback(()=>{
|
|
62
69
|
setIsPointerInsideTrigger(true);
|
|
63
70
|
setHasEnteredMenuContent(false);
|
|
64
71
|
}, []);
|
|
65
|
-
const markTriggerPointerLeft = useCallback(()
|
|
72
|
+
const markTriggerPointerLeft = useCallback(()=>{
|
|
66
73
|
setIsPointerInsideTrigger(false);
|
|
67
74
|
setHasEnteredMenuContent(false);
|
|
68
75
|
}, []);
|
|
69
|
-
const markMenuContentEntered = useCallback(()
|
|
76
|
+
const markMenuContentEntered = useCallback(()=>{
|
|
70
77
|
setHasEnteredMenuContent(true);
|
|
71
78
|
clearPointerGrace();
|
|
72
|
-
}, [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
useEffect(() => {
|
|
79
|
+
}, [
|
|
80
|
+
clearPointerGrace
|
|
81
|
+
]);
|
|
82
|
+
const shouldKeepSubMenuOpen = isPointerInsideTrigger || hasEnteredMenuContent || focusVisibleWithin || isPointerGraceActive;
|
|
83
|
+
useEffect(()=>{
|
|
78
84
|
if (!open) {
|
|
79
85
|
resetInteractionState();
|
|
80
86
|
}
|
|
81
|
-
}, [
|
|
87
|
+
}, [
|
|
88
|
+
open,
|
|
89
|
+
resetInteractionState
|
|
90
|
+
]);
|
|
82
91
|
return {
|
|
83
92
|
markTriggerPointerLeft,
|
|
84
93
|
markTriggerPointerMoved,
|
|
85
94
|
markMenuContentEntered,
|
|
86
95
|
resetInteractionState,
|
|
87
|
-
shouldKeepSubMenuOpen
|
|
96
|
+
shouldKeepSubMenuOpen
|
|
88
97
|
};
|
|
89
98
|
};
|
|
90
99
|
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
91
104
|
const POINTER_GRACE_TIMEOUT = 300;
|
|
92
105
|
const POINTER_GRACE_BLEED = 5;
|
|
93
|
-
const getSubMenuSide = (anchorRect, menuRect)
|
|
106
|
+
const getSubMenuSide = (anchorRect, menuRect)=>{
|
|
94
107
|
const anchorCenterX = anchorRect.left + anchorRect.width / 2;
|
|
95
108
|
const menuCenterX = menuRect.left + menuRect.width / 2;
|
|
96
109
|
return menuCenterX >= anchorCenterX ? 'right' : 'left';
|
|
97
110
|
};
|
|
98
|
-
const getPointerGraceIntent = (event, menuRect, side)
|
|
111
|
+
const getPointerGraceIntent = (event, menuRect, side)=>{
|
|
99
112
|
const bleed = side === 'right' ? -POINTER_GRACE_BLEED : POINTER_GRACE_BLEED;
|
|
100
113
|
const contentNearEdge = menuRect[side === 'right' ? 'left' : 'right'];
|
|
101
114
|
const contentFarEdge = menuRect[side === 'right' ? 'right' : 'left'];
|
|
102
115
|
return {
|
|
103
116
|
area: [
|
|
104
|
-
{
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
{
|
|
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
|
+
}
|
|
109
137
|
],
|
|
110
|
-
side
|
|
138
|
+
side
|
|
111
139
|
};
|
|
112
140
|
};
|
|
113
|
-
const useSubMenuPointerGrace = (props)
|
|
141
|
+
const useSubMenuPointerGrace = (props)=>{
|
|
114
142
|
const { isPointerMovingToSubMenu, onPointerGraceIntentChange } = props;
|
|
115
143
|
const { externalWindow, globalThis: contextGlobal } = useWindowContext();
|
|
116
144
|
const contextWindow = externalWindow ?? contextGlobal;
|
|
117
145
|
const [isPointerGraceActive, setIsPointerGraceActive] = useState(false);
|
|
118
146
|
const timerRef = useRef();
|
|
119
|
-
const clearPointerGrace = useCallback(()
|
|
147
|
+
const clearPointerGrace = useCallback(()=>{
|
|
120
148
|
contextWindow.clearTimeout(timerRef.current);
|
|
121
149
|
timerRef.current = undefined;
|
|
122
150
|
setIsPointerGraceActive(false);
|
|
123
151
|
onPointerGraceIntentChange?.(null);
|
|
124
|
-
}, [
|
|
125
|
-
|
|
152
|
+
}, [
|
|
153
|
+
contextWindow,
|
|
154
|
+
onPointerGraceIntentChange
|
|
155
|
+
]);
|
|
156
|
+
const startPointerGrace = useCallback((event, anchorElement, menuElement)=>{
|
|
126
157
|
if (!anchorElement || !menuElement) {
|
|
127
158
|
clearPointerGrace();
|
|
128
159
|
return;
|
|
@@ -148,23 +179,43 @@ const useSubMenuPointerGrace = (props) => {
|
|
|
148
179
|
clearPointerGrace,
|
|
149
180
|
contextWindow,
|
|
150
181
|
isPointerMovingToSubMenu,
|
|
151
|
-
onPointerGraceIntentChange
|
|
182
|
+
onPointerGraceIntentChange
|
|
152
183
|
]);
|
|
153
|
-
useEffect(()
|
|
184
|
+
useEffect(()=>{
|
|
154
185
|
return clearPointerGrace;
|
|
155
|
-
}, [
|
|
186
|
+
}, [
|
|
187
|
+
clearPointerGrace
|
|
188
|
+
]);
|
|
156
189
|
return {
|
|
157
190
|
isPointerGraceActive,
|
|
158
191
|
clearPointerGrace,
|
|
159
|
-
startPointerGrace
|
|
192
|
+
startPointerGrace
|
|
160
193
|
};
|
|
161
194
|
};
|
|
162
195
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
+
});
|
|
168
219
|
const { classes, children, itemContent, onClick: onClickProp, onKeyDown: onKeyDownProp, onPointerLeave: onPointerLeaveProp, onPointerMove: onPointerMoveProp, disabled, ...rest } = props;
|
|
169
220
|
const [anchor, setAnchor] = useState(null);
|
|
170
221
|
const itemRef = useRef(null);
|
|
@@ -172,21 +223,23 @@ const SubMenu = forwardRef((inProps, ref) => {
|
|
|
172
223
|
const menuRef = useRef(null);
|
|
173
224
|
const open = Boolean(anchor);
|
|
174
225
|
const id = useId();
|
|
175
|
-
const { isPointerMovingToSubMenu, onPointerGraceIntentChange } = useNestedMenuItem({
|
|
226
|
+
const { isPointerMovingToSubMenu, onPointerGraceIntentChange } = useNestedMenuItem({
|
|
227
|
+
id
|
|
228
|
+
});
|
|
176
229
|
const { isPointerGraceActive, clearPointerGrace, startPointerGrace } = useSubMenuPointerGrace({
|
|
177
230
|
isPointerMovingToSubMenu,
|
|
178
|
-
onPointerGraceIntentChange
|
|
231
|
+
onPointerGraceIntentChange
|
|
179
232
|
});
|
|
180
233
|
const { focusVisibleWithin, focusVisibleHandlers } = useFocusVisible({
|
|
181
|
-
within: true
|
|
234
|
+
within: true
|
|
182
235
|
});
|
|
183
|
-
const { markTriggerPointerLeft, markTriggerPointerMoved, markMenuContentEntered, resetInteractionState, shouldKeepSubMenuOpen
|
|
236
|
+
const { markTriggerPointerLeft, markTriggerPointerMoved, markMenuContentEntered, resetInteractionState, shouldKeepSubMenuOpen } = useSubMenuInteractionState({
|
|
184
237
|
open,
|
|
185
238
|
focusVisibleWithin,
|
|
186
239
|
isPointerGraceActive,
|
|
187
|
-
clearPointerGrace
|
|
240
|
+
clearPointerGrace
|
|
188
241
|
});
|
|
189
|
-
const closeSubMenu = useEventCallback((options)
|
|
242
|
+
const closeSubMenu = useEventCallback((options)=>{
|
|
190
243
|
if (options?.restoreFocus) {
|
|
191
244
|
itemRef.current?.focus();
|
|
192
245
|
}
|
|
@@ -196,7 +249,7 @@ const SubMenu = forwardRef((inProps, ref) => {
|
|
|
196
249
|
});
|
|
197
250
|
const overlayGroupContext = useMenuOverlayGroupContext();
|
|
198
251
|
const overlayContainer = overlayGroupContext?.container;
|
|
199
|
-
const handleTriggerPointerMove = (event)
|
|
252
|
+
const handleTriggerPointerMove = (event)=>{
|
|
200
253
|
onPointerMoveProp?.(event);
|
|
201
254
|
if (event.pointerType !== 'mouse' || event.defaultPrevented || disabled) {
|
|
202
255
|
return;
|
|
@@ -209,32 +262,45 @@ const SubMenu = forwardRef((inProps, ref) => {
|
|
|
209
262
|
clearPointerGrace();
|
|
210
263
|
setAnchor(event.currentTarget);
|
|
211
264
|
};
|
|
212
|
-
const handleTriggerPointerLeave = (event)
|
|
265
|
+
const handleTriggerPointerLeave = (event)=>{
|
|
213
266
|
onPointerLeaveProp?.(event);
|
|
214
267
|
if (event.pointerType === 'mouse') {
|
|
215
268
|
markTriggerPointerLeft();
|
|
216
269
|
startPointerGrace(event, itemRef.current, menuRef.current);
|
|
217
270
|
}
|
|
218
271
|
};
|
|
219
|
-
const openSubMenuFromTrigger = (trigger)
|
|
272
|
+
const openSubMenuFromTrigger = (trigger)=>{
|
|
220
273
|
markMenuContentEntered();
|
|
221
274
|
setAnchor(trigger);
|
|
222
275
|
};
|
|
223
|
-
const getAnchorElement = useCallback(()
|
|
276
|
+
const getAnchorElement = useCallback(()=>itemRef.current, []);
|
|
224
277
|
useNestedChildMenu({
|
|
225
278
|
open,
|
|
226
279
|
closeMenu: closeSubMenu,
|
|
227
280
|
getAnchorElement,
|
|
228
|
-
id
|
|
281
|
+
id
|
|
229
282
|
});
|
|
230
|
-
useEffect(()
|
|
231
|
-
if (!open)
|
|
232
|
-
return;
|
|
283
|
+
useEffect(()=>{
|
|
284
|
+
if (!open) return;
|
|
233
285
|
if (!shouldKeepSubMenuOpen) {
|
|
234
286
|
closeSubMenu();
|
|
235
287
|
}
|
|
236
|
-
}, [
|
|
237
|
-
|
|
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)=>{
|
|
238
304
|
if (disabled) {
|
|
239
305
|
return;
|
|
240
306
|
}
|
|
@@ -245,7 +311,8 @@ const SubMenu = forwardRef((inProps, ref) => {
|
|
|
245
311
|
if (isSubMenuNavigationOpenEvent(e)) {
|
|
246
312
|
openSubMenuFromTrigger(e.currentTarget);
|
|
247
313
|
}
|
|
248
|
-
},
|
|
314
|
+
},
|
|
315
|
+
onClick: (e)=>{
|
|
249
316
|
if (disabled) {
|
|
250
317
|
return;
|
|
251
318
|
}
|
|
@@ -256,18 +323,53 @@ const SubMenu = forwardRef((inProps, ref) => {
|
|
|
256
323
|
if (isSubMenuKeyboardActivationEvent(e)) {
|
|
257
324
|
openSubMenuFromTrigger(e.currentTarget);
|
|
258
325
|
}
|
|
259
|
-
},
|
|
260
|
-
|
|
261
|
-
|
|
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)) {
|
|
262
349
|
e.stopPropagation();
|
|
263
|
-
closeSubMenu({
|
|
350
|
+
closeSubMenu({
|
|
351
|
+
restoreFocus: true
|
|
352
|
+
});
|
|
264
353
|
}
|
|
265
|
-
},
|
|
354
|
+
},
|
|
355
|
+
onPointerMove: (event)=>{
|
|
266
356
|
if (event.pointerType === 'mouse') {
|
|
267
357
|
markMenuContentEntered();
|
|
268
358
|
}
|
|
269
|
-
},
|
|
359
|
+
},
|
|
360
|
+
...focusVisibleHandlers,
|
|
361
|
+
children: children
|
|
362
|
+
})
|
|
363
|
+
]
|
|
364
|
+
});
|
|
270
365
|
});
|
|
271
366
|
SubMenu.displayName = 'SuiSubMenu';
|
|
272
367
|
|
|
273
|
-
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
export { PopperMenu as popperMenuStyle, PopperMenu_PopperMenu as PopperMenu, SubMenu };
|