@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/ListItemText.js
CHANGED
|
@@ -1,23 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { forwardRef } from
|
|
3
|
-
import { useClasses } from
|
|
4
|
-
import { useThemeProps } from
|
|
5
|
-
import {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { useClasses } from "@ringcentral/spring-base";
|
|
4
|
+
import { useThemeProps } from "@ringcentral/spring-theme";
|
|
5
|
+
import { hasContent } from "./chunks/5047.js";
|
|
6
6
|
|
|
7
|
-
var ListItemText$1 = {"sui-list-item-text-root":"sui-list-item-text-root","sui-list-item-text-primary-text":"sui-list-item-text-primary-text","sui-list-item-text-secondary-text":"sui-list-item-text-secondary-text","sui-list-item-text-primary":"sui-list-item-text-primary","sui-list-item-text-primary-primary-text":"sui-list-item-text-primary-primary-text","sui-list-item-text-secondary":"sui-list-item-text-secondary","sui-list-item-text-secondary-primary-text":"sui-list-item-text-secondary-primary-text"};
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
// extracted by css-extract-rspack-plugin
|
|
12
|
+
/* export default */ var ListItemText = ({"sui-list-item-text-root":"sui-list-item-text-root","sui-list-item-text-primary-text":"sui-list-item-text-primary-text","sui-list-item-text-secondary-text":"sui-list-item-text-secondary-text","sui-list-item-text-primary":"sui-list-item-text-primary","sui-list-item-text-primary-primary-text":"sui-list-item-text-primary-primary-text","sui-list-item-text-secondary":"sui-list-item-text-secondary","sui-list-item-text-secondary-primary-text":"sui-list-item-text-secondary-primary-text"});
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const ListItemText_ListItemText = /*#__PURE__*/ forwardRef((inProps, ref)=>{
|
|
20
|
+
const props = useThemeProps({
|
|
21
|
+
props: inProps,
|
|
22
|
+
name: 'ListItemText'
|
|
23
|
+
});
|
|
11
24
|
const { classes, className, primary, secondary, primaryText, secondaryText, variant = 'primary', children, ...rest } = props;
|
|
12
25
|
const cls = useClasses('list-item-text', classes, className);
|
|
13
|
-
const primaryContent = hasContent(primary)
|
|
14
|
-
? primary
|
|
15
|
-
: hasContent(primaryText)
|
|
16
|
-
? primaryText
|
|
17
|
-
: children;
|
|
26
|
+
const primaryContent = hasContent(primary) ? primary : hasContent(primaryText) ? primaryText : children;
|
|
18
27
|
const secondaryContent = hasContent(secondary) ? secondary : secondaryText;
|
|
19
|
-
return
|
|
28
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
29
|
+
className: cls('root', variant),
|
|
30
|
+
...rest,
|
|
31
|
+
ref: ref,
|
|
32
|
+
children: [
|
|
33
|
+
/*#__PURE__*/ jsx("span", {
|
|
34
|
+
className: cls('primary-text', `${variant}-primary-text`),
|
|
35
|
+
children: primaryContent
|
|
36
|
+
}),
|
|
37
|
+
hasContent(secondaryContent) && /*#__PURE__*/ jsx("span", {
|
|
38
|
+
className: cls('secondary-text', `${variant}-secondary-text`),
|
|
39
|
+
children: secondaryContent
|
|
40
|
+
})
|
|
41
|
+
]
|
|
42
|
+
});
|
|
20
43
|
});
|
|
21
|
-
|
|
44
|
+
ListItemText_ListItemText.displayName = 'SuiListItemText';
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
22
50
|
|
|
23
|
-
export { ListItemText,
|
|
51
|
+
export { ListItemText as listItemTextStyle, ListItemText_ListItemText as ListItemText };
|
package/ListNavigation.js
CHANGED
|
@@ -1,51 +1,303 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
1
|
+
import { createContext, useContext, useImperativeHandle, useMemo, useRef } from "react";
|
|
2
|
+
import { tabbable } from "tabbable";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { useEventCallback } from "@ringcentral/spring-base";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const ListNavigationContext = createContext(null);
|
|
9
|
+
const useListNavigationContext = ()=>useContext(ListNavigationContext);
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
// oxlint-disable-next-line sonarjs/cognitive-complexity
|
|
17
|
+
const useItemNavigation = ()=>{
|
|
9
18
|
const itemRef = useRef(null);
|
|
10
19
|
const navContextValue = useListNavigationContext();
|
|
11
20
|
if (navContextValue) {
|
|
12
21
|
return {
|
|
13
22
|
keyboardNavHandlers: {
|
|
14
|
-
onKeyDown: (e)
|
|
23
|
+
onKeyDown: (e)=>{
|
|
24
|
+
// There some problems if `itemRef.current` is null.
|
|
25
|
+
// oxlint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
15
26
|
const itemEl = itemRef.current;
|
|
27
|
+
// All tabbable element in item. No include item self.
|
|
16
28
|
const allTabbable = tabbable(itemEl);
|
|
17
29
|
const { key, shiftKey, target, currentTarget } = e;
|
|
18
30
|
if (key === 'Tab') {
|
|
19
31
|
if (shiftKey) {
|
|
20
32
|
if (currentTarget === target) {
|
|
21
33
|
navContextValue.onShiftTab();
|
|
22
|
-
}
|
|
23
|
-
|
|
34
|
+
} else if (allTabbable.at(0) === target) {
|
|
35
|
+
// prevent default focus logic
|
|
24
36
|
e.preventDefault();
|
|
37
|
+
// focus item manual, because tabindex of item is -1
|
|
25
38
|
itemEl.focus();
|
|
26
39
|
}
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
40
|
+
} else {
|
|
29
41
|
if (allTabbable.at(-1) === target || !allTabbable.length) {
|
|
30
42
|
navContextValue.onTab();
|
|
31
43
|
}
|
|
32
44
|
}
|
|
33
45
|
}
|
|
34
46
|
},
|
|
35
|
-
onFocus: (e)
|
|
47
|
+
onFocus: (e)=>{
|
|
36
48
|
navContextValue.updateFocusedItem(e.currentTarget);
|
|
37
49
|
},
|
|
38
|
-
onBlur: (e)
|
|
39
|
-
if (e.relatedTarget &&
|
|
40
|
-
!e.currentTarget.contains(e.relatedTarget)) {
|
|
50
|
+
onBlur: (e)=>{
|
|
51
|
+
if (e.relatedTarget && !e.currentTarget.contains(e.relatedTarget)) {
|
|
41
52
|
navContextValue.updateFocusedItem(null);
|
|
42
53
|
}
|
|
43
|
-
}
|
|
54
|
+
}
|
|
44
55
|
},
|
|
45
|
-
itemRef
|
|
56
|
+
itemRef
|
|
46
57
|
};
|
|
47
58
|
}
|
|
48
59
|
return null;
|
|
49
60
|
};
|
|
50
61
|
|
|
51
|
-
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
const useListNavigation = (props)=>{
|
|
70
|
+
const { preventContainerScroll = true, searchAndFocusItemHandler: searchAndFocusItemHandlerProp = defaultSearchAndFocusItem, actions } = props;
|
|
71
|
+
const currentFocusedItemRef = useRef(null);
|
|
72
|
+
const listRef = useRef(null);
|
|
73
|
+
const sentinelArrowNavRef = useRef(null);
|
|
74
|
+
const sentinelTabBoundaryRef = useRef(null);
|
|
75
|
+
const skipEnforceFocusRef = useRef(false);
|
|
76
|
+
const focusList = ()=>{
|
|
77
|
+
skipEnforceFocusRef.current = true;
|
|
78
|
+
// oxlint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
79
|
+
listRef.current.focus();
|
|
80
|
+
};
|
|
81
|
+
const focusTabBoundary = ()=>{
|
|
82
|
+
skipEnforceFocusRef.current = true;
|
|
83
|
+
// oxlint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
84
|
+
sentinelTabBoundaryRef.current.focus();
|
|
85
|
+
};
|
|
86
|
+
const itemActions = useMemo(()=>({
|
|
87
|
+
// Prevent cache invalidation
|
|
88
|
+
// oxlint-disable-next-line sonarjs/no-identical-functions
|
|
89
|
+
onTab: ()=>{
|
|
90
|
+
skipEnforceFocusRef.current = true;
|
|
91
|
+
// oxlint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
92
|
+
sentinelTabBoundaryRef.current.focus();
|
|
93
|
+
},
|
|
94
|
+
// oxlint-disable-next-line sonarjs/no-identical-functions
|
|
95
|
+
onShiftTab: ()=>{
|
|
96
|
+
skipEnforceFocusRef.current = true;
|
|
97
|
+
// oxlint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
98
|
+
listRef.current.focus();
|
|
99
|
+
},
|
|
100
|
+
updateFocusedItem: (el)=>{
|
|
101
|
+
currentFocusedItemRef.current = el;
|
|
102
|
+
}
|
|
103
|
+
}), []);
|
|
104
|
+
const focusFirstItem = useEventCallback(()=>{
|
|
105
|
+
const { focused } = searchAndFocusItemHandler('first');
|
|
106
|
+
if (!focused) {
|
|
107
|
+
focusList();
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
useImperativeHandle(actions, ()=>({
|
|
111
|
+
focus: focusFirstItem
|
|
112
|
+
}), // oxlint-disable-next-line react-hooks/exhaustive-deps
|
|
113
|
+
[]);
|
|
114
|
+
const sentinelFocusHandler = (e)=>{
|
|
115
|
+
if (e.target === e.currentTarget) {
|
|
116
|
+
const skipEnforceFocus = skipEnforceFocusRef.current;
|
|
117
|
+
if (skipEnforceFocus) {
|
|
118
|
+
skipEnforceFocusRef.current = false;
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
focusFirstItem();
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const searchAndFocusItemHandler = (searchElementOption)=>{
|
|
125
|
+
return searchAndFocusItemHandlerProp(searchElementOption, {
|
|
126
|
+
// oxlint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
127
|
+
sentinelEnd: sentinelArrowNavRef.current,
|
|
128
|
+
// oxlint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
129
|
+
list: listRef.current
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
const listKeyDownHandler = (e)=>{
|
|
133
|
+
const focusedItem = currentFocusedItemRef.current;
|
|
134
|
+
const key = e.key;
|
|
135
|
+
if (focusedItem) {
|
|
136
|
+
const searchElementOption = {
|
|
137
|
+
ArrowDown: {
|
|
138
|
+
baseElement: focusedItem,
|
|
139
|
+
direction: 'down'
|
|
140
|
+
},
|
|
141
|
+
ArrowUp: {
|
|
142
|
+
baseElement: focusedItem,
|
|
143
|
+
direction: 'up'
|
|
144
|
+
},
|
|
145
|
+
Home: 'first',
|
|
146
|
+
End: 'last'
|
|
147
|
+
}[key];
|
|
148
|
+
if (searchElementOption) {
|
|
149
|
+
const { focused, isAfterBaseElement } = searchAndFocusItemHandler(searchElementOption);
|
|
150
|
+
if (!focused) {
|
|
151
|
+
focusList();
|
|
152
|
+
}
|
|
153
|
+
if (!isAfterBaseElement || preventContainerScroll) {
|
|
154
|
+
e.preventDefault();
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
} else {
|
|
158
|
+
// cover case about all item are disabled
|
|
159
|
+
if (e.target === e.currentTarget && key === 'Tab' && !e.shiftKey) {
|
|
160
|
+
focusTabBoundary();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
const getListProps = (otherHandler)=>{
|
|
165
|
+
const { onKeyDown, onFocus } = otherHandler;
|
|
166
|
+
const handleKeyDown = (e)=>{
|
|
167
|
+
onKeyDown?.(e);
|
|
168
|
+
if (e.defaultPrevented) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
listKeyDownHandler(e);
|
|
172
|
+
};
|
|
173
|
+
const handleFocus = (e)=>{
|
|
174
|
+
sentinelFocusHandler(e);
|
|
175
|
+
onFocus?.(e);
|
|
176
|
+
};
|
|
177
|
+
return {
|
|
178
|
+
tabIndex: 0,
|
|
179
|
+
onKeyDown: handleKeyDown,
|
|
180
|
+
onFocus: handleFocus
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
const renderItems = (items)=>{
|
|
184
|
+
return /*#__PURE__*/ jsxs(ListNavigationContext.Provider, {
|
|
185
|
+
value: itemActions,
|
|
186
|
+
children: [
|
|
187
|
+
items,
|
|
188
|
+
/*#__PURE__*/ jsx("div", {
|
|
189
|
+
"aria-hidden": "true",
|
|
190
|
+
ref: sentinelArrowNavRef
|
|
191
|
+
})
|
|
192
|
+
]
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
const renderTabBoundary = ()=>{
|
|
196
|
+
return /*#__PURE__*/ jsx("div", {
|
|
197
|
+
// make sentinel end always render in scroller viewport center to
|
|
198
|
+
// prevent scroll when focus to sentinel end
|
|
199
|
+
style: {
|
|
200
|
+
position: 'fixed',
|
|
201
|
+
bottom: '50%'
|
|
202
|
+
},
|
|
203
|
+
ref: sentinelTabBoundaryRef,
|
|
204
|
+
tabIndex: 0,
|
|
205
|
+
onFocus: sentinelFocusHandler
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
return {
|
|
209
|
+
renderItems,
|
|
210
|
+
renderTabBoundary,
|
|
211
|
+
getListProps,
|
|
212
|
+
listRef
|
|
213
|
+
};
|
|
214
|
+
};
|
|
215
|
+
const isUnfocusable = (el)=>el.matches('.sui-disabled, :disabled, hr, [role="separator"], [disabled]');
|
|
216
|
+
const defaultSearchAndFocusItem = (searchElementOption, helperElements)=>{
|
|
217
|
+
const { list, sentinelEnd } = helperElements;
|
|
218
|
+
// Handle empty list - no items to focus, return focused: false so caller falls back to focusList()
|
|
219
|
+
if (list.firstElementChild === sentinelEnd) {
|
|
220
|
+
return {
|
|
221
|
+
focused: false
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
const getFirstItem = ()=>{
|
|
225
|
+
const firstItem = list.firstElementChild;
|
|
226
|
+
if (firstItem === sentinelEnd) {
|
|
227
|
+
throw Error('SPRING [useListNavigation]: must have child element');
|
|
228
|
+
}
|
|
229
|
+
return firstItem;
|
|
230
|
+
};
|
|
231
|
+
const getLastItem = ()=>{
|
|
232
|
+
const lastItem = sentinelEnd.previousElementSibling;
|
|
233
|
+
if (!lastItem) {
|
|
234
|
+
throw Error('SPRING [useListNavigation]: must have child element');
|
|
235
|
+
}
|
|
236
|
+
return lastItem;
|
|
237
|
+
};
|
|
238
|
+
let direction;
|
|
239
|
+
let startElement;
|
|
240
|
+
if (typeof searchElementOption === 'string') {
|
|
241
|
+
if (searchElementOption === 'first') {
|
|
242
|
+
startElement = getFirstItem();
|
|
243
|
+
direction = 'down';
|
|
244
|
+
} else {
|
|
245
|
+
startElement = getLastItem();
|
|
246
|
+
direction = 'up';
|
|
247
|
+
}
|
|
248
|
+
if (!isUnfocusable(startElement)) {
|
|
249
|
+
startElement.focus();
|
|
250
|
+
return {
|
|
251
|
+
focused: true
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
} else {
|
|
255
|
+
startElement = searchElementOption.baseElement;
|
|
256
|
+
direction = searchElementOption.direction;
|
|
257
|
+
}
|
|
258
|
+
let pointer = startElement;
|
|
259
|
+
let isAfterBaseElement = true;
|
|
260
|
+
if (direction === 'up') {
|
|
261
|
+
do {
|
|
262
|
+
if (!pointer.previousElementSibling) {
|
|
263
|
+
pointer = getLastItem();
|
|
264
|
+
isAfterBaseElement = false;
|
|
265
|
+
} else {
|
|
266
|
+
pointer = pointer.previousElementSibling;
|
|
267
|
+
}
|
|
268
|
+
if (!isUnfocusable(pointer)) {
|
|
269
|
+
break;
|
|
270
|
+
}
|
|
271
|
+
}while (pointer !== startElement);
|
|
272
|
+
} else {
|
|
273
|
+
do {
|
|
274
|
+
if (pointer.nextElementSibling === sentinelEnd) {
|
|
275
|
+
pointer = getFirstItem();
|
|
276
|
+
isAfterBaseElement = false;
|
|
277
|
+
} else {
|
|
278
|
+
pointer = pointer.nextElementSibling;
|
|
279
|
+
}
|
|
280
|
+
if (!isUnfocusable(pointer)) {
|
|
281
|
+
break;
|
|
282
|
+
}
|
|
283
|
+
}while (pointer !== startElement);
|
|
284
|
+
}
|
|
285
|
+
if (isUnfocusable(pointer)) {
|
|
286
|
+
return {
|
|
287
|
+
focused: false
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
pointer.focus();
|
|
291
|
+
return typeof searchElementOption === 'string' ? {
|
|
292
|
+
focused: true
|
|
293
|
+
} : {
|
|
294
|
+
focused: true,
|
|
295
|
+
isAfterBaseElement
|
|
296
|
+
};
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
export { ListNavigationContext, useItemNavigation, useListNavigation, useListNavigationContext };
|
package/Menu.js
CHANGED
|
@@ -1,23 +1,139 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, forwardRef, useContext, useMemo, useState } from "react";
|
|
3
|
+
import { useEventCallback } from "@ringcentral/spring-base";
|
|
4
|
+
import { useClassesWithMode, useThemeProps } from "@ringcentral/spring-theme";
|
|
5
|
+
import { NestedMenuContext, useNestedParentMenu } from "./NestedMenuContext.js";
|
|
6
|
+
import { Popover as Popover_Popover } from "./Popover.js";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const overlayContainerStyle = {
|
|
17
|
+
display: 'contents'
|
|
18
|
+
};
|
|
19
|
+
// Internal-only context for nested submenu portal containers. Keep this
|
|
20
|
+
// separate from NestedMenuContext, which only coordinates hover/open/close state.
|
|
21
|
+
const MenuOverlayGroupContext = /*#__PURE__*/ createContext(null);
|
|
22
|
+
const useMenuOverlayGroupContext = ()=>useContext(MenuOverlayGroupContext);
|
|
23
|
+
const useMenuOverlayGroupValue = ()=>{
|
|
24
|
+
const [container, setContainer] = useState(null);
|
|
25
|
+
const value = useMemo(()=>({
|
|
26
|
+
container
|
|
27
|
+
}), [
|
|
28
|
+
container
|
|
29
|
+
]);
|
|
30
|
+
return {
|
|
31
|
+
setContainer,
|
|
32
|
+
value
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
const MenuOverlayGroupContainer = (props)=>{
|
|
36
|
+
const { setContainer } = props;
|
|
37
|
+
return /*#__PURE__*/ jsx("div", {
|
|
38
|
+
"data-sui-menu-overlay-container": "",
|
|
39
|
+
ref: setContainer,
|
|
40
|
+
style: overlayContainerStyle
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
const MenuContext = createContext(null);
|
|
48
|
+
const useMenuContext = ()=>{
|
|
49
|
+
return useContext(MenuContext);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// extracted by css-extract-rspack-plugin
|
|
53
|
+
/* export default */ var Menu = ({"sui-menu-paper":"sui-menu-paper","sui-menu-root":"sui-menu-root","sui-compact":"sui-compact"});
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
const Menu_Menu = /*#__PURE__*/ forwardRef((inProps, ref)=>{
|
|
64
|
+
const props = useThemeProps({
|
|
65
|
+
props: inProps,
|
|
66
|
+
name: 'Menu'
|
|
67
|
+
});
|
|
68
|
+
const { classes, children, open = false, onClose, autoFocus = true, className, PopperProps, ...rest } = props;
|
|
69
|
+
const cls = useClassesWithMode('menu', classes, className);
|
|
70
|
+
const padding = PopperProps?.padding;
|
|
71
|
+
const popperPadding = typeof padding === 'object' ? {
|
|
72
|
+
top: padding.top ?? 16,
|
|
73
|
+
right: padding.right ?? 16,
|
|
74
|
+
bottom: padding.bottom ?? 16,
|
|
75
|
+
left: padding.left ?? 16
|
|
76
|
+
} : padding ?? 16;
|
|
77
|
+
const { contentClickHandlers, contentPointerHandlers, contextValue } = useNestedParentMenu({
|
|
78
|
+
open
|
|
79
|
+
});
|
|
80
|
+
const { setContainer: setOverlayContainer, value: overlayGroupValue } = useMenuOverlayGroupValue();
|
|
81
|
+
const closeHandler = useEventCallback(()=>{
|
|
82
|
+
onClose?.(undefined, 'Other');
|
|
83
|
+
});
|
|
84
|
+
const menuContextValue = useMemo(()=>{
|
|
85
|
+
// Reset autoFocus when menu closes to ensure focus logic re-runs on reopen.
|
|
86
|
+
const effectiveAutoFocus = open ? autoFocus : false;
|
|
87
|
+
return {
|
|
88
|
+
close: closeHandler,
|
|
89
|
+
autoFocus: effectiveAutoFocus
|
|
90
|
+
};
|
|
91
|
+
}, [
|
|
92
|
+
autoFocus,
|
|
93
|
+
closeHandler,
|
|
94
|
+
open
|
|
95
|
+
]);
|
|
96
|
+
return /*#__PURE__*/ jsx(Popover_Popover, {
|
|
97
|
+
bordered: true,
|
|
98
|
+
className: cls('root'),
|
|
99
|
+
PopperProps: {
|
|
100
|
+
...PopperProps,
|
|
101
|
+
padding: popperPadding
|
|
102
|
+
},
|
|
103
|
+
...rest,
|
|
104
|
+
open: open,
|
|
105
|
+
onClose: (e, reason)=>{
|
|
106
|
+
onClose?.(e, reason);
|
|
107
|
+
},
|
|
108
|
+
ref: ref,
|
|
109
|
+
children: /*#__PURE__*/ jsxs(MenuOverlayGroupContext.Provider, {
|
|
110
|
+
value: overlayGroupValue,
|
|
111
|
+
children: [
|
|
112
|
+
/*#__PURE__*/ jsx("div", {
|
|
113
|
+
className: cls('paper'),
|
|
114
|
+
onClickCapture: contentClickHandlers.onClickCapture,
|
|
115
|
+
onPointerMove: contentPointerHandlers.onPointerMove,
|
|
116
|
+
children: /*#__PURE__*/ jsx(MenuContext.Provider, {
|
|
117
|
+
value: menuContextValue,
|
|
118
|
+
children: /*#__PURE__*/ jsx(NestedMenuContext.Provider, {
|
|
119
|
+
value: contextValue,
|
|
120
|
+
children: children
|
|
121
|
+
})
|
|
122
|
+
})
|
|
123
|
+
}),
|
|
124
|
+
/*#__PURE__*/ jsx(MenuOverlayGroupContainer, {
|
|
125
|
+
setContainer: setOverlayContainer
|
|
126
|
+
})
|
|
127
|
+
]
|
|
128
|
+
})
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
Menu_Menu.displayName = 'SuiMenu';
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
export { Menu as menuStyle, MenuContext, Menu_Menu as Menu, useMenuContext, useMenuOverlayGroupContext };
|
package/MenuActions.js
CHANGED
|
@@ -1,21 +1,46 @@
|
|
|
1
|
-
import { jsx } from
|
|
2
|
-
import { forwardRef } from
|
|
3
|
-
import { useClasses } from
|
|
4
|
-
import { useThemeProps } from
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { useClasses } from "@ringcentral/spring-base";
|
|
4
|
+
import { useThemeProps } from "@ringcentral/spring-theme";
|
|
5
5
|
|
|
6
|
-
var MenuActions$1 = {"sui-menu-actions-root":"sui-menu-actions-root","sui-menu-actions-group-root":"sui-menu-actions-group-root"};
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
// extracted by css-extract-rspack-plugin
|
|
11
|
+
/* export default */ var MenuActions = ({"sui-menu-actions-root":"sui-menu-actions-root","sui-menu-actions-group-root":"sui-menu-actions-group-root"});
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const MenuActions_MenuActions = /*#__PURE__*/ forwardRef((inProps, ref)=>{
|
|
18
|
+
const props = useThemeProps({
|
|
19
|
+
props: inProps,
|
|
20
|
+
name: 'MenuActions'
|
|
21
|
+
});
|
|
10
22
|
const { classes, className, children, ...rest } = props;
|
|
11
23
|
const cls = useClasses('menu-actions', classes, className);
|
|
12
|
-
return
|
|
24
|
+
return /*#__PURE__*/ jsx("div", {
|
|
25
|
+
className: cls('root'),
|
|
26
|
+
...rest,
|
|
27
|
+
ref: ref,
|
|
28
|
+
children: children
|
|
29
|
+
});
|
|
13
30
|
});
|
|
14
|
-
|
|
15
|
-
const MenuActionsGroup = ({ className, ...rest })
|
|
31
|
+
MenuActions_MenuActions.displayName = 'SuiMenuActions';
|
|
32
|
+
const MenuActionsGroup = ({ className, ...rest })=>{
|
|
16
33
|
const cls = useClasses('menu-actions-group', undefined, className);
|
|
17
|
-
return jsx("div", {
|
|
34
|
+
return /*#__PURE__*/ jsx("div", {
|
|
35
|
+
className: cls('root'),
|
|
36
|
+
...rest
|
|
37
|
+
});
|
|
18
38
|
};
|
|
19
39
|
MenuActionsGroup.displayName = 'SuiMenuActionsGroup';
|
|
20
40
|
|
|
21
|
-
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
export { MenuActions as menuActionsStyle, MenuActionsGroup, MenuActions_MenuActions as MenuActions };
|
package/MenuDivider.js
CHANGED
|
@@ -1,10 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import './chunks/Divider.js';
|
|
6
|
-
import '@ringcentral/spring-base';
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { useClassesWithMode, useThemeProps } from "@ringcentral/spring-theme";
|
|
4
|
+
import { Divider as Divider_Divider } from "./Divider.js";
|
|
7
5
|
|
|
8
|
-
var MenuDivider = {"sui-menu-divider-root":"sui-menu-divider-root","sui-compact":"sui-compact"};
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
// extracted by css-extract-rspack-plugin
|
|
10
|
+
/* export default */ var MenuDivider = ({"sui-menu-divider-root":"sui-menu-divider-root","sui-compact":"sui-compact"});
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const MenuDivider_MenuDivider = /*#__PURE__*/ forwardRef((inProps, ref)=>{
|
|
17
|
+
const props = useThemeProps({
|
|
18
|
+
props: inProps,
|
|
19
|
+
name: 'MenuDivider'
|
|
20
|
+
});
|
|
21
|
+
const { classes, className, ...rest } = props;
|
|
22
|
+
const cls = useClassesWithMode('menu-divider', classes, className);
|
|
23
|
+
return /*#__PURE__*/ jsx(Divider_Divider, {
|
|
24
|
+
className: cls('root'),
|
|
25
|
+
...rest,
|
|
26
|
+
ref: ref
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
MenuDivider_MenuDivider.displayName = 'SuiMenuDivider';
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
export { MenuDivider as menuDividerStyle, MenuDivider_MenuDivider as MenuDivider };
|