@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/Tooltip.js
CHANGED
|
@@ -1,23 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* store tooltip open state when forceHide is true and set tooltip open to false
|
|
7
|
+
* restore open state once forceHide changed to false
|
|
8
|
+
*/ const useTooltipForceHide = (forceHide)=>{
|
|
9
|
+
const [open, setOpen] = useState(false);
|
|
10
|
+
const openStateStore = useRef();
|
|
11
|
+
const onOpenStateChange = useCallback((event, isOpen)=>{
|
|
12
|
+
if (openStateStore.current !== undefined) {
|
|
13
|
+
openStateStore.current = isOpen;
|
|
14
|
+
} else {
|
|
15
|
+
setOpen(isOpen);
|
|
16
|
+
}
|
|
17
|
+
}, []);
|
|
18
|
+
useEffect(()=>{
|
|
19
|
+
if (open && forceHide) {
|
|
20
|
+
setOpen(false);
|
|
21
|
+
openStateStore.current = open;
|
|
22
|
+
}
|
|
23
|
+
if (!forceHide && openStateStore.current !== undefined) {
|
|
24
|
+
setOpen(openStateStore.current);
|
|
25
|
+
openStateStore.current = undefined;
|
|
26
|
+
}
|
|
27
|
+
}, [
|
|
28
|
+
open,
|
|
29
|
+
forceHide
|
|
30
|
+
]);
|
|
31
|
+
return {
|
|
32
|
+
open,
|
|
33
|
+
onOpenStateChange
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
export { useTooltipForceHide };
|
|
48
|
+
export { Tooltip, TooltipTrigger, TooltipView, tooltipViewStyle, withTooltip } from "./chunks/4535.js";
|
package/Tray.js
CHANGED
|
@@ -1,13 +1,237 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, forwardRef, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { logInDev, useClasses, useControlled, useEventCallback, useForkRef } from "@ringcentral/spring-base";
|
|
4
|
+
import { motionTransition, useThemeProps } from "@ringcentral/spring-theme";
|
|
5
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
6
|
+
import "./chunks/4476.js";
|
|
7
|
+
import { useMotionSafeTransition } from "./chunks/1294.js";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const useTray = (parameters)=>{
|
|
18
|
+
const { value: valueProp, defaultValue, onChange, containerRef } = parameters;
|
|
19
|
+
const [value, setValue] = useControlled({
|
|
20
|
+
controlled: valueProp,
|
|
21
|
+
default: defaultValue,
|
|
22
|
+
name: 'useTray',
|
|
23
|
+
state: 'value'
|
|
24
|
+
});
|
|
25
|
+
if (value === undefined) {
|
|
26
|
+
throw new Error('Should set default TrayPanel using defaultValue (not controlled) or value (controlled)');
|
|
27
|
+
}
|
|
28
|
+
const [stack, setStack] = useState([
|
|
29
|
+
value
|
|
30
|
+
]);
|
|
31
|
+
const [direction, setDirection] = useState('right');
|
|
32
|
+
const updateValue = (e, newValue)=>{
|
|
33
|
+
setValue(newValue);
|
|
34
|
+
onChange?.(e, newValue);
|
|
35
|
+
if (stack.includes(newValue)) {
|
|
36
|
+
setStack(stack.slice(0, stack.indexOf(newValue) + 1));
|
|
37
|
+
setDirection('left');
|
|
38
|
+
} else {
|
|
39
|
+
setStack([
|
|
40
|
+
...stack,
|
|
41
|
+
newValue
|
|
42
|
+
]);
|
|
43
|
+
setDirection('right');
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
const navigateTo = useEventCallback((newValue, event = null)=>{
|
|
47
|
+
let handledValue = newValue;
|
|
48
|
+
if (handledValue === null && stack.length === 1) {
|
|
49
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
50
|
+
logInDev({
|
|
51
|
+
scope: 'useTray',
|
|
52
|
+
message: 'No TrayPanel left to return to'
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (handledValue === null) {
|
|
58
|
+
// return to previous TrayPanel when value is false
|
|
59
|
+
handledValue = stack[stack.length - 2];
|
|
60
|
+
}
|
|
61
|
+
containerRef.current?.focus();
|
|
62
|
+
updateValue(event, handledValue);
|
|
63
|
+
});
|
|
64
|
+
const trayContextValue = useMemo(()=>{
|
|
65
|
+
return {
|
|
66
|
+
value,
|
|
67
|
+
navigateTo,
|
|
68
|
+
direction,
|
|
69
|
+
containerRef
|
|
70
|
+
};
|
|
71
|
+
}, [
|
|
72
|
+
value,
|
|
73
|
+
navigateTo,
|
|
74
|
+
direction,
|
|
75
|
+
containerRef
|
|
76
|
+
]);
|
|
77
|
+
return {
|
|
78
|
+
trayContextValue
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// extracted by css-extract-rspack-plugin
|
|
83
|
+
/* export default */ var Tray = ({"sui-tray-root":"sui-tray-root","sui-tray-panel-root":"sui-tray-panel-root","sui-tray-panel-activated":"sui-tray-panel-activated"});
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
const TrayContext = createContext(null);
|
|
87
|
+
const useTrayContext = ()=>useContext(TrayContext);
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
const Tray_Tray = /*#__PURE__*/ forwardRef((inProps, ref)=>{
|
|
97
|
+
const props = useThemeProps({
|
|
98
|
+
props: inProps,
|
|
99
|
+
name: 'Tray'
|
|
100
|
+
});
|
|
101
|
+
const { classes, children, value, defaultValue, onChange, actions, className, ...rest } = props;
|
|
102
|
+
const cls = useClasses('tray', classes, className);
|
|
103
|
+
const rootRef = useRef(null);
|
|
104
|
+
const handleRootRef = useForkRef(ref, rootRef);
|
|
105
|
+
const { trayContextValue } = useTray({
|
|
106
|
+
value,
|
|
107
|
+
defaultValue,
|
|
108
|
+
onChange,
|
|
109
|
+
containerRef: rootRef
|
|
110
|
+
});
|
|
111
|
+
const { navigateTo } = trayContextValue;
|
|
112
|
+
useImperativeHandle(actions, ()=>({
|
|
113
|
+
navigateTo
|
|
114
|
+
}), [
|
|
115
|
+
navigateTo
|
|
116
|
+
]);
|
|
117
|
+
return /*#__PURE__*/ jsx("div", {
|
|
118
|
+
className: cls('root'),
|
|
119
|
+
ref: handleRootRef,
|
|
120
|
+
...rest,
|
|
121
|
+
tabIndex: -1,
|
|
122
|
+
children: /*#__PURE__*/ jsx(TrayContext.Provider, {
|
|
123
|
+
value: trayContextValue,
|
|
124
|
+
children: children
|
|
125
|
+
})
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
Tray_Tray.displayName = 'SuiTray';
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
const useTrayPanel = (parameters)=>{
|
|
138
|
+
const { value } = parameters;
|
|
139
|
+
const context = useTrayContext();
|
|
140
|
+
if (context === null) {
|
|
141
|
+
throw new Error('No TrayContext provided, must be used within a Tray');
|
|
142
|
+
}
|
|
143
|
+
const activated = value === context.value;
|
|
144
|
+
return {
|
|
145
|
+
activated,
|
|
146
|
+
containerRef: context.containerRef,
|
|
147
|
+
direction: context.direction
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
const TrayPanel = /*#__PURE__*/ forwardRef((inProps, ref)=>{
|
|
159
|
+
const props = useThemeProps({
|
|
160
|
+
props: inProps,
|
|
161
|
+
name: 'TrayPanel'
|
|
162
|
+
});
|
|
163
|
+
const { children, classes, className } = props;
|
|
164
|
+
const { activated, containerRef, direction } = useTrayPanel(props);
|
|
165
|
+
const [display, setDisplay] = useState(activated);
|
|
166
|
+
useEffect(()=>{
|
|
167
|
+
if (activated) {
|
|
168
|
+
setDisplay(true);
|
|
169
|
+
}
|
|
170
|
+
}, [
|
|
171
|
+
activated
|
|
172
|
+
]);
|
|
173
|
+
const cls = useClasses('tray-panel', classes, className);
|
|
174
|
+
const transition = useMotionSafeTransition(motionTransition["spring-01-fast"]);
|
|
175
|
+
return /*#__PURE__*/ jsx(AnimatePresence, {
|
|
176
|
+
initial: false,
|
|
177
|
+
children: display && /*#__PURE__*/ jsx(motion.div, {
|
|
178
|
+
ref: ref,
|
|
179
|
+
className: cls('root', {
|
|
180
|
+
activated
|
|
181
|
+
}),
|
|
182
|
+
"data-activated": activated,
|
|
183
|
+
transition: transition,
|
|
184
|
+
initial: 'enter',
|
|
185
|
+
animate: activated ? 'center' : 'exit',
|
|
186
|
+
onAnimationComplete: ()=>{
|
|
187
|
+
!activated && setDisplay(false);
|
|
188
|
+
},
|
|
189
|
+
variants: {
|
|
190
|
+
enter: {
|
|
191
|
+
height: containerRef.current?.querySelector('[data-activated="false"]')?.offsetHeight,
|
|
192
|
+
transform: direction === 'right' ? 'translateX(100%)' : 'translateX(-100%)'
|
|
193
|
+
},
|
|
194
|
+
center: {
|
|
195
|
+
height: 'auto',
|
|
196
|
+
transform: 'translateX(0%)'
|
|
197
|
+
},
|
|
198
|
+
exit: {
|
|
199
|
+
transform: direction === 'right' ? 'translateX(-100%)' : 'translateX(100%)'
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
children: children
|
|
203
|
+
})
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
TrayPanel.displayName = 'SuiTrayPanel';
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
const useTrayNavigate = ()=>{
|
|
211
|
+
const context = useTrayContext();
|
|
212
|
+
if (context === null) {
|
|
213
|
+
throw new Error('No TrayContext provided, must be used within a Tray');
|
|
214
|
+
}
|
|
215
|
+
const { navigateTo } = context;
|
|
216
|
+
const back = (event = null)=>{
|
|
217
|
+
context.navigateTo(null, event);
|
|
218
|
+
};
|
|
219
|
+
return {
|
|
220
|
+
navigateTo,
|
|
221
|
+
back
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
export { Tray as trayStyle, TrayContext, TrayPanel, Tray_Tray as Tray, useTray, useTrayContext, useTrayNavigate, useTrayPanel };
|
package/TrayMenu.js
CHANGED
|
@@ -1,61 +1,82 @@
|
|
|
1
|
-
import { jsx } from
|
|
2
|
-
import { useThemeProps } from
|
|
3
|
-
import { forwardRef, useRef } from
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
import './chunks/useFocusTrapStack.js';
|
|
22
|
-
import './chunks/Backdrop.js';
|
|
23
|
-
import './Popper.js';
|
|
24
|
-
import './chunks/PopperPaper.js';
|
|
25
|
-
import './chunks/useMotionSafeTransition.js';
|
|
26
|
-
import '@ringcentral/spring-icon';
|
|
27
|
-
import './chunks/useAnimationFrame.js';
|
|
28
|
-
import './chunks/useNestedMenuItem.js';
|
|
29
|
-
import './ListNavigation.js';
|
|
30
|
-
import 'react-virtuoso';
|
|
31
|
-
import './chunks/List.js';
|
|
32
|
-
|
|
33
|
-
const TrayMenu = forwardRef((inProps, ref) => {
|
|
34
|
-
const props = useThemeProps({ props: inProps, name: 'TrayMenu' });
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useThemeProps } from "@ringcentral/spring-theme";
|
|
3
|
+
import { forwardRef, useRef } from "react";
|
|
4
|
+
import { Menu as Menu_Menu } from "./Menu.js";
|
|
5
|
+
import { Tray as Tray_Tray, useTrayNavigate } from "./Tray.js";
|
|
6
|
+
import { MenuItem as MenuItem_MenuItem } from "./MenuItem.js";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const TrayMenu = /*#__PURE__*/ forwardRef((inProps, ref)=>{
|
|
17
|
+
const props = useThemeProps({
|
|
18
|
+
props: inProps,
|
|
19
|
+
name: 'TrayMenu'
|
|
20
|
+
});
|
|
35
21
|
const { defaultValue, value, onChange, children, ...rest } = props;
|
|
36
22
|
const trayActionsRef = useRef(null);
|
|
37
|
-
return
|
|
23
|
+
return /*#__PURE__*/ jsx(Menu_Menu, {
|
|
24
|
+
...rest,
|
|
25
|
+
ref: ref,
|
|
26
|
+
autoFocus: false,
|
|
27
|
+
children: /*#__PURE__*/ jsx(Tray_Tray, {
|
|
28
|
+
value: value,
|
|
29
|
+
defaultValue: defaultValue,
|
|
30
|
+
onChange: onChange,
|
|
31
|
+
actions: trayActionsRef,
|
|
32
|
+
onKeyDown: (e)=>{
|
|
38
33
|
if (e.key === 'ArrowLeft') {
|
|
39
34
|
trayActionsRef.current?.navigateTo(null);
|
|
40
35
|
}
|
|
41
|
-
},
|
|
36
|
+
},
|
|
37
|
+
children: children
|
|
38
|
+
})
|
|
39
|
+
});
|
|
42
40
|
});
|
|
43
41
|
TrayMenu.displayName = 'SuiTrayMenu';
|
|
44
42
|
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
const TrayMenuItem = /*#__PURE__*/ forwardRef((inProps, ref)=>{
|
|
53
|
+
const props = useThemeProps({
|
|
54
|
+
props: inProps,
|
|
55
|
+
name: 'TrayMenuItem'
|
|
56
|
+
});
|
|
47
57
|
const { value, onClick, onKeyDown } = props;
|
|
48
58
|
const { navigateTo } = useTrayNavigate();
|
|
49
|
-
return
|
|
59
|
+
return /*#__PURE__*/ jsx(MenuItem_MenuItem, {
|
|
60
|
+
...props,
|
|
61
|
+
onClick: (e)=>{
|
|
50
62
|
navigateTo(value, e);
|
|
51
63
|
onClick?.(e);
|
|
52
|
-
},
|
|
64
|
+
},
|
|
65
|
+
onKeyDown: (e)=>{
|
|
53
66
|
if (e.key === 'ArrowRight') {
|
|
54
67
|
navigateTo(value, e);
|
|
55
68
|
}
|
|
56
69
|
onKeyDown?.(e);
|
|
57
|
-
},
|
|
70
|
+
},
|
|
71
|
+
ref: ref,
|
|
72
|
+
autoClose: false
|
|
73
|
+
});
|
|
58
74
|
});
|
|
59
75
|
TrayMenuItem.displayName = 'SuiTrayItem';
|
|
60
76
|
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
61
82
|
export { TrayMenu, TrayMenuItem };
|