@ringcentral/spring-ui 1.11.1 → 1.12.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/AccordionHeader.js +4 -2
- package/Animation.js +10 -9
- package/Autocomplete.js +7 -2
- package/BlockHeader.js +3 -1
- package/DatePicker.js +5 -3
- package/Dialer.js +36 -21
- package/Dialog.js +4 -3
- package/Dropdown.js +8 -4
- package/EmptyState.js +3 -1
- package/FormField.js +2 -0
- package/ListItem.js +1 -0
- package/ListItemText.js +9 -3
- package/MenuHeader.js +5 -1
- package/MenuItem.js +3 -0
- package/MenuItemText.js +2 -0
- package/MenuList.js +3 -0
- package/Option.js +4 -1
- package/PickerTextField.js +2 -0
- package/Popper.js +28 -25
- package/Rating.js +2 -2
- package/Select.js +4 -0
- package/SingleFilter.js +4 -0
- package/Slider.js +3 -2
- package/SortableListItem.js +1 -0
- package/SortableVirtualizedList.js +11 -10
- package/SplitButton.js +4 -0
- package/Squircle.js +2 -2
- package/StepContent.js +1 -1
- package/SubMenu.js +4 -0
- package/SwipeableDrawer.js +16 -18
- package/TableCell.js +1 -1
- package/TablePagination.js +4 -0
- package/Tabs.js +11 -5
- package/TextField.js +2 -0
- package/Textarea.js +2 -0
- package/TimePicker.js +3 -1
- package/TrayMenu.js +3 -0
- package/VirtualizedList.js +7 -5
- package/VirtualizedMenu.js +1 -0
- package/chunks/Alert.js +2 -2
- package/chunks/Badge.js +1 -1
- package/chunks/Drawer.js +3 -2
- package/chunks/MenuItemText.js +3 -1
- package/chunks/MenuList.js +2 -1
- package/chunks/Modal.js +132 -9
- package/chunks/Popover.js +13 -5
- package/chunks/Select.js +26 -21
- package/chunks/SlideIn.js +2 -1
- package/chunks/Squircle.js +2 -2
- package/chunks/VirtualizedMenu.js +5 -5
- package/chunks/composeEventHandlers.js +10 -0
- package/chunks/getSlideIn.js +2 -2
- package/chunks/hasContent.js +3 -0
- package/chunks/useAnimationFrame.js +15 -0
- package/chunks/useFocusTrapStack.js +3 -1
- package/chunks/useHelperTextId.js +4 -2
- package/chunks/useMenuItemSelect.js +37 -26
- package/index.css +205 -172
- package/index.js +4 -0
- package/internal/hooks/index.d.ts +1 -0
- package/internal/hooks/useAnimationFrame.d.ts +4 -0
- package/internal/utils/hasContent.d.ts +2 -0
- package/internal/utils/index.d.ts +3 -0
- package/internal/utils/setRef.d.ts +1 -0
- package/package.json +8 -8
- package/src/Accordion/Accordion.d.ts +1 -1
- package/src/AccordionHeader/AccordionHeader.d.ts +1 -1
- 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/Announcement/Announcement.d.ts +1 -1
- package/src/Autocomplete/SuggestionList/SuggestionList.d.ts +1 -1
- package/src/Autocomplete/SuggestionList/SuggestionListItem.d.ts +1 -1
- package/src/Autocomplete/SuggestionList/utils/useSuggestionList.d.ts +1 -1
- package/src/Autocomplete/useAutocomplete.d.ts +74 -50
- package/src/Autocomplete/useAutocompleteTag.d.ts +68 -44
- package/src/Backdrop/Backdrop.d.ts +1 -1
- package/src/Badge/Badge.d.ts +2 -2
- package/src/BottomNavigation/BottomNavigationGroup/BottomNavigationGroup.d.ts +1 -1
- package/src/CircularProgressIndicator/CircularProgressIndicator.d.ts +1 -1
- package/src/DatePicker/DatePicker.d.ts +1 -1
- package/src/DatePicker/Day.d.ts +1 -1
- package/src/DatePicker/Year.d.ts +1 -1
- package/src/DatePicker/utils/DatePickerAriaLabelUtils.d.ts +2 -1
- package/src/Dialer/DialDelete/DialDelete.d.ts +2 -2
- package/src/Dialer/DialPad/DialPad.d.ts +2 -2
- package/src/Dialer/DialTextField/DialTextField.d.ts +1 -1
- package/src/Dialer/Dialer.d.ts +4 -2
- package/src/Dialog/Dialog.d.ts +4 -4
- package/src/Drawer/Drawer.d.ts +1 -1
- package/src/Dropdown/Dropdown.type.d.ts +2 -2
- package/src/EmptyState/EmptyState.d.ts +1 -1
- package/src/FormField/FormField.d.ts +1 -1
- package/src/FormLabel/FormLabel.d.ts +1 -1
- package/src/Icon/Icon.d.ts +1 -1
- package/src/IconButton/IconButtonLabel.d.ts +1 -1
- package/src/InlineEditable/InlineEditable.type.d.ts +2 -1
- package/src/LinearProgressIndicator/LinearProgressIndicator.d.ts +1 -1
- package/src/List/List.d.ts +1 -1
- package/src/ListItem/ListItem.d.ts +1 -1
- package/src/ListItemText/ListItemText.d.ts +1 -1
- package/src/ListNavigation/useListNavigation.d.ts +3 -3
- package/src/Menu/Menu.d.ts +1 -1
- package/src/MenuActions/MenuActions.d.ts +3 -3
- package/src/MenuDivider/MenuDivider.d.ts +1 -1
- package/src/MenuFooter/MenuFooter.d.ts +1 -1
- package/src/MenuHeader/MenuHeader.d.ts +1 -1
- package/src/MenuItem/MenuItem.d.ts +1 -1
- package/src/MenuItem/useMenuItem.d.ts +1 -1
- package/src/MenuItem/useVirtualizedMenuItem.d.ts +1 -1
- package/src/MenuItemText/MenuItemText.d.ts +1 -1
- package/src/MenuList/MenuList.type.d.ts +1 -1
- package/src/Modal/InnerModal.d.ts +2 -16
- package/src/Modal/InnerModal.type.d.ts +1 -0
- package/src/Modal/Modal.d.ts +2 -21
- package/src/Modal/ModalContext.d.ts +3 -0
- package/src/Modal/OverlayBranchRegistry.d.ts +8 -0
- package/src/Modal/useOverlayBranch.d.ts +8 -0
- package/src/NestedMenuContext/MenuOverlayGroupContext.d.ts +2 -2
- package/src/Option/Option.d.ts +1 -1
- package/src/PageHeader/PageHeader.d.ts +5 -5
- package/src/PickerTextField/PickerTextField.d.ts +1 -1
- package/src/Popover/Popover.d.ts +1 -1
- package/src/Popper/Popper.d.ts +1 -1
- package/src/Popper/Popper.type.d.ts +10 -7
- package/src/PopperPaper/PopperPaper.d.ts +1 -1
- package/src/RadioGroup/RadioGroup.d.ts +1 -1
- package/src/Rating/Rating.d.ts +1 -1
- package/src/Rating/RatingItem.d.ts +1 -1
- package/src/Rating/utils.d.ts +3 -3
- package/src/Select/Select.type.d.ts +1 -1
- package/src/SingleFilter/FilterButton/FilterButton.d.ts +1 -1
- package/src/SingleFilter/SingleFilter.d.ts +1 -1
- package/src/Skeleton/Skeleton.d.ts +1 -1
- package/src/Slider/Slider.d.ts +2 -2
- package/src/Slider/SliderThumb.d.ts +2 -2
- package/src/Snackbar/Snackbar.d.ts +1 -1
- package/src/Snackbar/SnackbarContent/SnackbarContent.d.ts +1 -1
- package/src/SortableListItem/SortableListItem.d.ts +1 -1
- package/src/SortableListItem/SortableListItemOverlay.d.ts +1 -1
- package/src/SplitButton/SplitButton.d.ts +1 -1
- package/src/Squircle/Squircle.d.ts +1 -1
- package/src/StatusIndicator/StatusIndicator.d.ts +2 -2
- package/src/StepConnector/StepConnector.d.ts +1 -1
- package/src/StepContent/StepContent.d.ts +1 -1
- package/src/StepIcon/StepIcon.d.ts +1 -1
- package/src/StepLabel/StepLabel.d.ts +1 -1
- package/src/SubMenu/PopperMenu.d.ts +1 -1
- package/src/SubMenu/PopperMenu.type.d.ts +4 -1
- package/src/SubMenu/SubMenu.d.ts +1 -1
- package/src/SwipeableDrawer/SwipeableDrawer.d.ts +1 -1
- package/src/Tab/Tab.d.ts +1 -1
- package/src/TabPanel/TabPanel.d.ts +1 -1
- package/src/TableFooter/TableFooter.d.ts +1 -1
- package/src/Tabs/TabMoreMenu.d.ts +1 -1
- package/src/Tabs/TabScrollButton.d.ts +1 -1
- package/src/Tabs/Tabs.d.ts +1 -1
- package/src/Tag/Tag.d.ts +1 -1
- package/src/TextField/TextField.d.ts +1 -1
- package/src/Textarea/Textarea.d.ts +1 -1
- package/src/TimePicker/NumberPicker.d.ts +1 -1
- package/src/TimePicker/TimeButton.d.ts +1 -1
- package/src/TimePicker/ToggleText.d.ts +1 -1
- package/src/Tray/Tray.d.ts +1 -1
- package/src/Tray/TrayPanel.d.ts +1 -1
- package/src/TrayMenu/TrayMenu.d.ts +1 -1
- package/src/TrayMenu/TrayMenuItem.d.ts +1 -1
- package/src/VirtualizedList/VirtuosoComponents.d.ts +4 -4
- package/src/VisuallyHidden/VisuallyHidden.d.ts +1 -1
- package/src/internal/utils/index.d.ts +0 -1
- /package/{src/internal → internal}/utils/composeEventHandlers.d.ts +0 -0
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
2
|
import { createContext, useContext, forwardRef, useRef, useLayoutEffect, useCallback, useMemo } from 'react';
|
|
3
|
-
import { useFocusVisible, useActive, useForkRef, useId, useHover, useEventCallback } from '@ringcentral/spring-base';
|
|
3
|
+
import { useFocusVisible, useActive, useForkRef, combineProps, useId, useHover, useEventCallback } from '@ringcentral/spring-base';
|
|
4
4
|
import { CheckBoldMd } from '@ringcentral/spring-icon';
|
|
5
5
|
import { useThemeProps, useClassesWithMode } from '@ringcentral/spring-theme';
|
|
6
6
|
import { I as Icon } from './Icon.js';
|
|
7
|
+
import { u as useAnimationFrame } from './useAnimationFrame.js';
|
|
7
8
|
import './useNestedParentMenu.js';
|
|
8
9
|
import { u as useNestedMenuItem } from './useNestedMenuItem.js';
|
|
9
10
|
import { useVirtualizedItemPropsContext } from '../VirtualizedList.js';
|
|
11
|
+
import { c as composeEventHandlers } from './composeEventHandlers.js';
|
|
12
|
+
import { unstable_setRef } from '@mui/utils';
|
|
10
13
|
import { useItemNavigation } from '../ListNavigation.js';
|
|
11
14
|
import { u as useMenuContext } from './Menu.js';
|
|
12
15
|
|
|
@@ -20,15 +23,6 @@ const SubMenuTriggerNestedIdContext = createContext(null);
|
|
|
20
23
|
const MenuItemSelectContext = createContext(null);
|
|
21
24
|
const useMenuItemSelectContext = () => useContext(MenuItemSelectContext);
|
|
22
25
|
|
|
23
|
-
const composeEventHandlers = (externalEventHandler, internalEventHandler, options = {}) => (event, ...args) => {
|
|
24
|
-
const { checkForDefaultPrevented = true } = options;
|
|
25
|
-
externalEventHandler?.(event, ...args);
|
|
26
|
-
if (checkForDefaultPrevented && event.defaultPrevented) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
internalEventHandler?.(event, ...args);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
26
|
const useMenuItem = (props) => {
|
|
33
27
|
const { onBlur, onFocus, onKeyDown, onKeyUp, onClick, ref, disabled, autoClose, } = props;
|
|
34
28
|
const { keyboardNavHandlers, itemRef } = useItemNavigation() ?? {};
|
|
@@ -59,15 +53,20 @@ const useMenuItem = (props) => {
|
|
|
59
53
|
onClick: handleClick,
|
|
60
54
|
});
|
|
61
55
|
const handleItemRef = useForkRef(ref, focusVisibleRef, itemRef);
|
|
62
|
-
const getRootProps = (otherProps) => {
|
|
56
|
+
const getRootProps = (otherProps = {}) => {
|
|
57
|
+
const { ref: otherRef, ...restOtherProps } = otherProps;
|
|
63
58
|
return {
|
|
64
59
|
role: 'menuitem',
|
|
65
60
|
tabIndex: '-1',
|
|
66
|
-
disabled,
|
|
67
|
-
...
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
61
|
+
...(disabled ? { 'aria-disabled': true } : null),
|
|
62
|
+
...combineProps(restOtherProps, {
|
|
63
|
+
...focusVisibleHandlers,
|
|
64
|
+
...activeHandlers,
|
|
65
|
+
}),
|
|
66
|
+
ref: (instance) => {
|
|
67
|
+
unstable_setRef(otherRef, instance);
|
|
68
|
+
unstable_setRef(handleItemRef, instance);
|
|
69
|
+
},
|
|
71
70
|
};
|
|
72
71
|
};
|
|
73
72
|
return { getRootProps, focusVisible, active };
|
|
@@ -104,15 +103,21 @@ const useVirtualizedMenuItem = (props) => {
|
|
|
104
103
|
onClick: handleClick,
|
|
105
104
|
});
|
|
106
105
|
const handleItemRef = useForkRef(ref, focusVisibleRef, itemRef);
|
|
107
|
-
const getRootProps = (otherProps) => {
|
|
106
|
+
const getRootProps = (otherProps = {}) => {
|
|
107
|
+
const { ref: otherRef, ...restOtherProps } = otherProps;
|
|
108
108
|
return {
|
|
109
109
|
role: 'menuitem',
|
|
110
110
|
tabIndex: -1,
|
|
111
|
-
...
|
|
112
|
-
...
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
111
|
+
...(disabled ? { 'aria-disabled': true } : null),
|
|
112
|
+
...combineProps(restOtherProps, {
|
|
113
|
+
...focusVisibleHandlers,
|
|
114
|
+
...activeHandlers,
|
|
115
|
+
...vlItemProps,
|
|
116
|
+
}),
|
|
117
|
+
ref: (instance) => {
|
|
118
|
+
unstable_setRef(otherRef, instance);
|
|
119
|
+
unstable_setRef(handleItemRef, instance);
|
|
120
|
+
},
|
|
116
121
|
};
|
|
117
122
|
};
|
|
118
123
|
return { getRootProps, focusVisible, active };
|
|
@@ -120,10 +125,11 @@ const useVirtualizedMenuItem = (props) => {
|
|
|
120
125
|
|
|
121
126
|
const MenuItem = forwardRef((inProps, ref) => {
|
|
122
127
|
const props = useThemeProps({ props: inProps, name: 'MenuItem' });
|
|
123
|
-
const { classes, className, children, selected, disabled, onMouseEnter, onMouseLeave, onPointerMove, highlighted = false, focused = false, autoClose = true, autoFocus, ...rest } = props;
|
|
128
|
+
const { classes, className, children, selected, disabled, onMouseEnter, onMouseLeave, onPointerMove, onBlur, onFocus, onKeyDown, onKeyUp, onClick, highlighted = false, focused = false, autoClose = true, autoFocus, ...rest } = props;
|
|
124
129
|
const cls = useClassesWithMode('menu-item', classes, className);
|
|
125
130
|
const vlItemProps = useVirtualizedItemPropsContext();
|
|
126
131
|
const isInVlRef = useRef(Boolean(vlItemProps));
|
|
132
|
+
const { requestAnimationFrame } = useAnimationFrame();
|
|
127
133
|
const useMenuItemHook = (() => {
|
|
128
134
|
if (isInVlRef.current) {
|
|
129
135
|
return useVirtualizedMenuItem;
|
|
@@ -135,8 +141,13 @@ const MenuItem = forwardRef((inProps, ref) => {
|
|
|
135
141
|
const itemRef = useRef(null);
|
|
136
142
|
const handleRef = useForkRef(itemRef, ref);
|
|
137
143
|
const { getRootProps, focusVisible, active } = useMenuItemHook({
|
|
138
|
-
...props,
|
|
139
144
|
autoClose,
|
|
145
|
+
disabled,
|
|
146
|
+
onBlur,
|
|
147
|
+
onClick,
|
|
148
|
+
onFocus,
|
|
149
|
+
onKeyDown,
|
|
150
|
+
onKeyUp,
|
|
140
151
|
ref: handleRef,
|
|
141
152
|
});
|
|
142
153
|
const selectable = !(selected === undefined);
|
|
@@ -177,7 +188,7 @@ const MenuItem = forwardRef((inProps, ref) => {
|
|
|
177
188
|
});
|
|
178
189
|
});
|
|
179
190
|
}
|
|
180
|
-
}, [autoFocus]);
|
|
191
|
+
}, [autoFocus, requestAnimationFrame]);
|
|
181
192
|
return (jsx("div", { className: cls('root', {
|
|
182
193
|
selectable,
|
|
183
194
|
selected,
|
|
@@ -268,4 +279,4 @@ const useMenuItemSelect = (props) => {
|
|
|
268
279
|
};
|
|
269
280
|
};
|
|
270
281
|
|
|
271
|
-
export { Action as A, MenuItem as M, SubMenuTriggerNestedIdContext as S, MenuItemSelectContext as a, useMenuItem as b, useMenuItemSelect as c, useVirtualizedMenuItem as d, MenuListContext as e, useMenuListContext as f,
|
|
282
|
+
export { Action as A, MenuItem as M, SubMenuTriggerNestedIdContext as S, MenuItemSelectContext as a, useMenuItem as b, useMenuItemSelect as c, useVirtualizedMenuItem as d, MenuListContext as e, useMenuListContext as f, useMenuItemSelectContext as u };
|