@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
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { createContext, useContext, useRef, useLayoutEffect, forwardRef, useState, useMemo, useEffect } from 'react';
|
|
3
|
-
import { useForkRef, combineProps, useClasses, useEventCallback } from '@ringcentral/spring-base';
|
|
4
|
-
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
5
|
-
import clsx from 'clsx';
|
|
6
|
-
import { u as useAnimationFrame } from './useAnimationFrame.js';
|
|
7
|
-
import { P as Popover } from './Popover.js';
|
|
8
|
-
import { VirtualizedList } from '../VirtualizedList.js';
|
|
9
|
-
|
|
10
|
-
const VirtualizedMenuContext = createContext(null);
|
|
11
|
-
const useVirtualizedMenuContext = () => useContext(VirtualizedMenuContext);
|
|
12
|
-
|
|
13
|
-
const VirtualizedMenuList = (props) => {
|
|
14
|
-
const { children, actions: actionsProp, initialFocus: initialFocusProps, totalListHeightChanged: totalListHeightChangedProp, ...rest } = props;
|
|
15
|
-
const actions = useRef(null);
|
|
16
|
-
const handleListActions = useForkRef(actions, actionsProp);
|
|
17
|
-
const listRef = useRef(null);
|
|
18
|
-
const virtualizedMenuContext = useVirtualizedMenuContext();
|
|
19
|
-
useLayoutEffect(() => {
|
|
20
|
-
if (!virtualizedMenuContext?.open) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const initialFocus = typeof initialFocusProps === 'function'
|
|
24
|
-
? initialFocusProps()
|
|
25
|
-
: initialFocusProps;
|
|
26
|
-
if (initialFocus === true) {
|
|
27
|
-
actions.current?.focus();
|
|
28
|
-
}
|
|
29
|
-
else if (typeof initialFocus === 'number') {
|
|
30
|
-
actions.current?.focusByIndex(initialFocus);
|
|
31
|
-
}
|
|
32
|
-
}, [virtualizedMenuContext?.open]);
|
|
33
|
-
return (jsx(VirtualizedList, { actions: handleListActions, ...rest, ListProps: combineProps({
|
|
34
|
-
role: 'menu',
|
|
35
|
-
}, rest.ListProps), ref: listRef, totalListHeightChanged: totalListHeightChangedProp, children: children }));
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const MENU_VERTICAL_PADDING = 8;
|
|
39
|
-
const VirtualizedMenu = forwardRef((inProps, ref) => {
|
|
40
|
-
const props = useThemeProps({ props: inProps, name: 'VirtualizedMenu' });
|
|
41
|
-
const { classes, className, children, open, onClose, data, totalCount, isItemDisabled, VirtualizedListProps, popperActions: popperActionsProp, initialFocus = true, maxHeight, PopperProps, ...rest } = props;
|
|
42
|
-
const popperPaperContentRef = useRef(null);
|
|
43
|
-
const paperContentContainerRef = useRef(null);
|
|
44
|
-
const hasItemsRenderedRef = useRef(false);
|
|
45
|
-
const [waitForHeightCompute, setWaitForHeightCompute] = useState(true);
|
|
46
|
-
const [menuHeight, setMenuHeight] = useState(MENU_VERTICAL_PADDING * 2);
|
|
47
|
-
const [deferPendingVirtualizedListActions, setDeferPendingVirtualizedListActions,] = useState(true);
|
|
48
|
-
const computedListHeight = useRef(-1);
|
|
49
|
-
const availableHeight = useRef(-1);
|
|
50
|
-
const cls = useClasses('virtualized-menu', classes, className);
|
|
51
|
-
const padding = PopperProps?.padding;
|
|
52
|
-
const popperPadding = typeof padding === 'object'
|
|
53
|
-
? {
|
|
54
|
-
top: padding.top ?? 16,
|
|
55
|
-
right: padding.right ?? 16,
|
|
56
|
-
bottom: padding.bottom ?? 16,
|
|
57
|
-
left: padding.left ?? 16,
|
|
58
|
-
}
|
|
59
|
-
: (padding ?? 16);
|
|
60
|
-
const popperActions = useRef(null);
|
|
61
|
-
const handlePopperActions = useForkRef(popperActions, popperActionsProp);
|
|
62
|
-
const { requestAnimationFrame } = useAnimationFrame();
|
|
63
|
-
const menuContextValue = useMemo(() => {
|
|
64
|
-
return { open };
|
|
65
|
-
}, [open]);
|
|
66
|
-
const updateMenuHeight = useEventCallback(() => {
|
|
67
|
-
let computedMenuHeight = computedListHeight.current;
|
|
68
|
-
if (computedMenuHeight > availableHeight.current) {
|
|
69
|
-
computedMenuHeight = availableHeight.current;
|
|
70
|
-
}
|
|
71
|
-
if (maxHeight !== undefined && computedMenuHeight > maxHeight) {
|
|
72
|
-
computedMenuHeight = maxHeight;
|
|
73
|
-
}
|
|
74
|
-
setMenuHeight(computedMenuHeight);
|
|
75
|
-
});
|
|
76
|
-
const updatePopoverHeight = useEventCallback(() => {
|
|
77
|
-
if (!popperPaperContentRef.current)
|
|
78
|
-
return;
|
|
79
|
-
popperPaperContentRef.current.style.maxHeight = `${availableHeight.current}px`;
|
|
80
|
-
if (paperContentContainerRef.current) {
|
|
81
|
-
paperContentContainerRef.current.style.height = `auto`;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
const handleTotalListHeightChanged = useEventCallback((listHeight) => {
|
|
85
|
-
if (!hasItemsRenderedRef.current) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
const adjustedHeight = listHeight + MENU_VERTICAL_PADDING * 2
|
|
89
|
-
;
|
|
90
|
-
computedListHeight.current = adjustedHeight;
|
|
91
|
-
if (paperContentContainerRef.current) {
|
|
92
|
-
paperContentContainerRef.current.style.height = `${adjustedHeight}px`;
|
|
93
|
-
}
|
|
94
|
-
updateMenuHeight();
|
|
95
|
-
popperActions.current?.update();
|
|
96
|
-
if (waitForHeightCompute) {
|
|
97
|
-
requestAnimationFrame(() => {
|
|
98
|
-
setDeferPendingVirtualizedListActions(false);
|
|
99
|
-
requestAnimationFrame(() => {
|
|
100
|
-
setWaitForHeightCompute(false);
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
const handleAvailableHeightChange = useEventCallback((value) => {
|
|
106
|
-
if (computedListHeight.current === -1 || !hasItemsRenderedRef.current) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
availableHeight.current = value;
|
|
110
|
-
updateMenuHeight();
|
|
111
|
-
updatePopoverHeight();
|
|
112
|
-
});
|
|
113
|
-
useEffect(() => {
|
|
114
|
-
if (!open) {
|
|
115
|
-
hasItemsRenderedRef.current = false;
|
|
116
|
-
}
|
|
117
|
-
if (open) {
|
|
118
|
-
if (computedListHeight.current !== -1) {
|
|
119
|
-
updateMenuHeight();
|
|
120
|
-
setWaitForHeightCompute(false);
|
|
121
|
-
setDeferPendingVirtualizedListActions(false);
|
|
122
|
-
popperActions.current?.update();
|
|
123
|
-
}
|
|
124
|
-
else {
|
|
125
|
-
setMenuHeight(MENU_VERTICAL_PADDING * 2);
|
|
126
|
-
setWaitForHeightCompute(true);
|
|
127
|
-
setDeferPendingVirtualizedListActions(true);
|
|
128
|
-
}
|
|
129
|
-
if (popperPaperContentRef.current) {
|
|
130
|
-
popperPaperContentRef.current.style.maxHeight = 'none';
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}, [open]);
|
|
134
|
-
return (jsx(Popover, { bordered: true, PopperProps: { ...PopperProps, padding: popperPadding }, ...rest, open: open, className: clsx(cls('root'), waitForHeightCompute && 'opacity-0'), PopperPaperProps: {
|
|
135
|
-
contentRef: popperPaperContentRef,
|
|
136
|
-
}, onClose: onClose, onAvailableHeightChange: handleAvailableHeightChange, ref: ref, motionProps: { variants: undefined }, actions: handlePopperActions, children: jsx("div", { className: cls('paper'), children: jsx("div", { ref: paperContentContainerRef, className: cls('paper-content-container'), children: jsx(VirtualizedMenuContext.Provider, { value: menuContextValue, children: jsx(VirtualizedMenuList, { data: data, totalCount: totalCount, isReady: !deferPendingVirtualizedListActions, isItemDisabled: isItemDisabled, initialFocus: initialFocus, style: { height: menuHeight }, ...combineProps(VirtualizedListProps, {
|
|
137
|
-
ListProps: combineProps(VirtualizedListProps?.ListProps, {
|
|
138
|
-
className: cls('list'),
|
|
139
|
-
style: {
|
|
140
|
-
['--sui-virtualized-menu-vertical-padding']: `${MENU_VERTICAL_PADDING}px`,
|
|
141
|
-
},
|
|
142
|
-
}),
|
|
143
|
-
totalListHeightChanged: handleTotalListHeightChanged,
|
|
144
|
-
itemsRendered: (items) => {
|
|
145
|
-
if (totalCount === 0 ||
|
|
146
|
-
(totalCount === undefined &&
|
|
147
|
-
data !== undefined &&
|
|
148
|
-
data.length === 0) ||
|
|
149
|
-
(items && items.length > 0)) {
|
|
150
|
-
hasItemsRenderedRef.current = true;
|
|
151
|
-
}
|
|
152
|
-
VirtualizedListProps?.itemsRendered?.(items);
|
|
153
|
-
},
|
|
154
|
-
onKeyDown: (e) => {
|
|
155
|
-
if (e.key === 'Tab') {
|
|
156
|
-
e.preventDefault();
|
|
157
|
-
onClose?.();
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
}), children: children }) }) }) }) }));
|
|
161
|
-
});
|
|
162
|
-
VirtualizedMenu.displayName = 'SuiVirtualizedMenu';
|
|
163
|
-
|
|
164
|
-
export { VirtualizedMenuContext as V, VirtualizedMenu as a, VirtualizedMenuList as b, useVirtualizedMenuContext as u };
|
package/chunks/VisuallyHidden.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
|
-
import { useClasses } from '@ringcentral/spring-base';
|
|
4
|
-
|
|
5
|
-
const VisuallyHidden = forwardRef((props, ref) => {
|
|
6
|
-
const { classes, className, children, ...rest } = props;
|
|
7
|
-
const cls = useClasses('visually-hidden', classes, className);
|
|
8
|
-
return (jsx("span", { className: cls('root'), ...rest, ref: ref, children: children }));
|
|
9
|
-
});
|
|
10
|
-
VisuallyHidden.displayName = 'SuiVisuallyHidden';
|
|
11
|
-
|
|
12
|
-
export { VisuallyHidden as V };
|
package/chunks/getFade.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { motionTransition } from '@ringcentral/spring-theme';
|
|
2
|
-
|
|
3
|
-
const getFade = ({ toggle = true, prefersReducedMotion = false, toggleOnTransition, toggleOffTransition, } = {}) => ({
|
|
4
|
-
initial: 'hidden',
|
|
5
|
-
animate: toggle ? 'show' : 'hidden',
|
|
6
|
-
exit: 'hidden',
|
|
7
|
-
variants: {
|
|
8
|
-
show: {
|
|
9
|
-
opacity: 1,
|
|
10
|
-
transition: prefersReducedMotion
|
|
11
|
-
? motionTransition.instant
|
|
12
|
-
: toggleOnTransition || motionTransition['haste-01-fast'],
|
|
13
|
-
},
|
|
14
|
-
hidden: {
|
|
15
|
-
opacity: 0,
|
|
16
|
-
transition: prefersReducedMotion
|
|
17
|
-
? motionTransition.instant
|
|
18
|
-
: toggleOffTransition || motionTransition['haste-01-slow'],
|
|
19
|
-
pointerEvents: 'none',
|
|
20
|
-
transitionEnd: {
|
|
21
|
-
pointerEvents: undefined,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export { getFade as g };
|
package/chunks/getGrow.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { motionTransition } from '@ringcentral/spring-theme';
|
|
2
|
-
|
|
3
|
-
const getGrow = ({ toggle = true, direction = 'both', prefersReducedMotion = false, toggleOffTransition, toggleOnTransition, transformOrigin, } = {}) => {
|
|
4
|
-
const directionStr = direction === 'both' ? '' : direction.toUpperCase();
|
|
5
|
-
return {
|
|
6
|
-
style: {
|
|
7
|
-
transformOrigin: transformOriginToString(transformOrigin),
|
|
8
|
-
},
|
|
9
|
-
initial: 'invisible',
|
|
10
|
-
animate: toggle ? 'visible' : 'invisible',
|
|
11
|
-
exit: 'invisible',
|
|
12
|
-
variants: {
|
|
13
|
-
invisible: {
|
|
14
|
-
transform: `scale${directionStr}(0.618)`,
|
|
15
|
-
opacity: 0,
|
|
16
|
-
...(!prefersReducedMotion &&
|
|
17
|
-
toggleOffTransition && { transition: toggleOffTransition }),
|
|
18
|
-
},
|
|
19
|
-
visible: {
|
|
20
|
-
transform: `scale${directionStr}(1)`,
|
|
21
|
-
opacity: 1,
|
|
22
|
-
...(!prefersReducedMotion &&
|
|
23
|
-
toggleOnTransition && { transition: toggleOnTransition }),
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
transition: prefersReducedMotion
|
|
27
|
-
? motionTransition.instant
|
|
28
|
-
: motionTransition['spring-01-fast'],
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
const transformOriginToString = (transformOrigin) => {
|
|
32
|
-
if (!transformOrigin)
|
|
33
|
-
return undefined;
|
|
34
|
-
return `${typeof transformOrigin.vertical === 'number'
|
|
35
|
-
? transformOrigin.vertical + 'px'
|
|
36
|
-
: transformOrigin.vertical} ${typeof transformOrigin.horizontal === 'number'
|
|
37
|
-
? transformOrigin.horizontal + 'px'
|
|
38
|
-
: transformOrigin.horizontal}`;
|
|
39
|
-
};
|
|
40
|
-
const alignmentToHorizontalTransformOrigin = {
|
|
41
|
-
start: 'left',
|
|
42
|
-
end: 'right',
|
|
43
|
-
};
|
|
44
|
-
const alignmentToVerticalTransformOrigin = {
|
|
45
|
-
start: 'top',
|
|
46
|
-
end: 'bottom',
|
|
47
|
-
};
|
|
48
|
-
const getTransformOriginStringForPlacement = (params) => {
|
|
49
|
-
const { placement } = params;
|
|
50
|
-
const [base, alignment] = placement.split('-');
|
|
51
|
-
if (base === 'top' || base === 'bottom') {
|
|
52
|
-
return transformOriginToString({
|
|
53
|
-
vertical: base === 'top' ? 'bottom' : 'top',
|
|
54
|
-
horizontal: !alignment
|
|
55
|
-
? 'center'
|
|
56
|
-
: alignmentToHorizontalTransformOrigin[alignment],
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
else if (base === 'left' || base === 'right') {
|
|
60
|
-
return transformOriginToString({
|
|
61
|
-
vertical: !alignment
|
|
62
|
-
? 'center'
|
|
63
|
-
: alignmentToVerticalTransformOrigin[alignment],
|
|
64
|
-
horizontal: base === 'left' ? 'right' : 'left',
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return undefined;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export { getTransformOriginStringForPlacement as a, getGrow as g };
|
package/chunks/getSlideIn.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { motionTransition } from '@ringcentral/spring-theme';
|
|
2
|
-
|
|
3
|
-
const horizontal = ['right', 'left'];
|
|
4
|
-
const plus = ['right', 'bottom'];
|
|
5
|
-
const getSlideIn = ({ toggle = true, from = 'right', prefersReducedMotion = false, toggleOnTransition, toggleOffTransition, } = {}) => {
|
|
6
|
-
const axis = horizontal.includes(from) ? 'x' : 'y';
|
|
7
|
-
const invisibleValue = plus.includes(from) ? '100%' : '-100%';
|
|
8
|
-
return {
|
|
9
|
-
initial: 'invisible',
|
|
10
|
-
animate: toggle ? 'visible' : 'invisible',
|
|
11
|
-
exit: 'invisible',
|
|
12
|
-
variants: {
|
|
13
|
-
visible: {
|
|
14
|
-
[axis]: 0,
|
|
15
|
-
...(!prefersReducedMotion &&
|
|
16
|
-
toggleOnTransition && { transition: toggleOnTransition }),
|
|
17
|
-
},
|
|
18
|
-
invisible: {
|
|
19
|
-
[axis]: invisibleValue,
|
|
20
|
-
...(!prefersReducedMotion &&
|
|
21
|
-
toggleOffTransition && { transition: toggleOffTransition }),
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
transition: prefersReducedMotion
|
|
25
|
-
? motionTransition.instant
|
|
26
|
-
: motionTransition['spring-01-fast'],
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export { getSlideIn as g };
|
package/chunks/hasContent.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import { useWindowContext } from '@ringcentral/spring-base';
|
|
3
|
-
|
|
4
|
-
function useAnimationFrame() {
|
|
5
|
-
const { externalWindow, globalThis: contextGlobal } = useWindowContext();
|
|
6
|
-
return useMemo(() => {
|
|
7
|
-
const contextWindow = externalWindow ?? contextGlobal;
|
|
8
|
-
return {
|
|
9
|
-
requestAnimationFrame: (callback) => contextWindow.requestAnimationFrame(callback),
|
|
10
|
-
cancelAnimationFrame: (handle) => contextWindow.cancelAnimationFrame(handle),
|
|
11
|
-
};
|
|
12
|
-
}, [externalWindow, contextGlobal]);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export { useAnimationFrame as u };
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
import { useWindowContext, useId, useEventCallback } from '@ringcentral/spring-base';
|
|
3
|
-
|
|
4
|
-
const FOCUS_TRAP_STACK = '__SUI_FOCUS_TRAP_STACK__';
|
|
5
|
-
const getFocusTrapStack = (global) => {
|
|
6
|
-
if (!global[FOCUS_TRAP_STACK]) {
|
|
7
|
-
global[FOCUS_TRAP_STACK] = [];
|
|
8
|
-
}
|
|
9
|
-
return global[FOCUS_TRAP_STACK];
|
|
10
|
-
};
|
|
11
|
-
const useFocusTrapStack = ({ open, }) => {
|
|
12
|
-
const { globalThis } = useWindowContext();
|
|
13
|
-
const id = useId();
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
if (open) {
|
|
16
|
-
const stack = getFocusTrapStack(globalThis);
|
|
17
|
-
stack.push(id);
|
|
18
|
-
}
|
|
19
|
-
return () => {
|
|
20
|
-
const stack = getFocusTrapStack(globalThis);
|
|
21
|
-
const index = stack.indexOf(id);
|
|
22
|
-
if (index >= 0) {
|
|
23
|
-
stack.splice(index, 1);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}, [open]);
|
|
27
|
-
const isEnabled = useEventCallback(() => {
|
|
28
|
-
const stack = getFocusTrapStack(globalThis);
|
|
29
|
-
return stack.at(-1) === id;
|
|
30
|
-
});
|
|
31
|
-
return {
|
|
32
|
-
isEnabled,
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export { useFocusTrapStack as u };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
|
-
import clsx from 'clsx';
|
|
4
|
-
import { useClasses } from '@ringcentral/spring-base';
|
|
5
|
-
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
6
|
-
|
|
7
|
-
const FormField = forwardRef((inProps, ref) => {
|
|
8
|
-
const props = useThemeProps({ props: inProps, name: 'FormField' });
|
|
9
|
-
const { classes, className, children, htmlFor, label, labelProps, helperText, required, disabled, error, variant = 'standard', size = 'xlarge', contentRef, contentProps, focused, FormHelperTextProps, ...rest } = props;
|
|
10
|
-
const cls = useClasses('form-field', classes, className);
|
|
11
|
-
return (jsxs("div", { ...rest, ref: ref, className: cls('root', variant, { disabled, error, focused }), "aria-disabled": disabled, children: [label && (jsxs("label", { htmlFor: htmlFor, ...labelProps, className: clsx(cls('label', `${variant}-label`, error && 'error-label'), labelProps?.className), children: [label, required ? ' *' : ''] })), jsxs("div", { className: cls('container', error && 'error-container'), children: [jsx("div", { className: cls('content', size, `${size}-content`, `${variant}-${size}`, `${variant}-content`, error && 'error-content', error && `error-${variant}-content`), ref: contentRef, ...contentProps, children: children }), jsx("div", { className: cls('focus-effect', `${variant}-focus-effect`, error && 'error-focus-effect') })] }), helperText && (jsx("div", { ...FormHelperTextProps, className: clsx(cls('helper-text', error && 'error-helper-text'), FormHelperTextProps?.className), children: helperText }))] }));
|
|
12
|
-
});
|
|
13
|
-
FormField.displayName = 'SuiFormField';
|
|
14
|
-
|
|
15
|
-
const useHelperTextId = ({ helperText, id, FormHelperTextProps, }) => {
|
|
16
|
-
if (!helperText) {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
return FormHelperTextProps?.id || `${id}-helper-text`;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export { FormField as F, useHelperTextId as u };
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useEventCallback } from '@ringcentral/spring-base';
|
|
3
|
-
import { createContext, useContext, useRef, useMemo, useImperativeHandle } from 'react';
|
|
4
|
-
|
|
5
|
-
const ListNavigationContext = createContext(null);
|
|
6
|
-
const useListNavigationContext = () => useContext(ListNavigationContext);
|
|
7
|
-
|
|
8
|
-
const useListNavigation = (props) => {
|
|
9
|
-
const { preventContainerScroll = true, searchAndFocusItemHandler: searchAndFocusItemHandlerProp = defaultSearchAndFocusItem, actions, } = props;
|
|
10
|
-
const currentFocusedItemRef = useRef(null);
|
|
11
|
-
const listRef = useRef(null);
|
|
12
|
-
const sentinelArrowNavRef = useRef(null);
|
|
13
|
-
const sentinelTabBoundaryRef = useRef(null);
|
|
14
|
-
const skipEnforceFocusRef = useRef(false);
|
|
15
|
-
const focusList = () => {
|
|
16
|
-
skipEnforceFocusRef.current = true;
|
|
17
|
-
listRef.current.focus();
|
|
18
|
-
};
|
|
19
|
-
const focusTabBoundary = () => {
|
|
20
|
-
skipEnforceFocusRef.current = true;
|
|
21
|
-
sentinelTabBoundaryRef.current.focus();
|
|
22
|
-
};
|
|
23
|
-
const itemActions = useMemo(() => ({
|
|
24
|
-
onTab: () => {
|
|
25
|
-
skipEnforceFocusRef.current = true;
|
|
26
|
-
sentinelTabBoundaryRef.current.focus();
|
|
27
|
-
},
|
|
28
|
-
onShiftTab: () => {
|
|
29
|
-
skipEnforceFocusRef.current = true;
|
|
30
|
-
listRef.current.focus();
|
|
31
|
-
},
|
|
32
|
-
updateFocusedItem: (el) => {
|
|
33
|
-
currentFocusedItemRef.current = el;
|
|
34
|
-
},
|
|
35
|
-
}), []);
|
|
36
|
-
const focusFirstItem = useEventCallback(() => {
|
|
37
|
-
const { focused } = searchAndFocusItemHandler('first');
|
|
38
|
-
if (!focused) {
|
|
39
|
-
focusList();
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
useImperativeHandle(actions, () => ({
|
|
43
|
-
focus: focusFirstItem,
|
|
44
|
-
}), []);
|
|
45
|
-
const sentinelFocusHandler = (e) => {
|
|
46
|
-
if (e.target === e.currentTarget) {
|
|
47
|
-
const skipEnforceFocus = skipEnforceFocusRef.current;
|
|
48
|
-
if (skipEnforceFocus) {
|
|
49
|
-
skipEnforceFocusRef.current = false;
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
focusFirstItem();
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
const searchAndFocusItemHandler = (searchElementOption) => {
|
|
56
|
-
return searchAndFocusItemHandlerProp(searchElementOption, {
|
|
57
|
-
sentinelEnd: sentinelArrowNavRef.current,
|
|
58
|
-
list: listRef.current,
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
const listKeyDownHandler = (e) => {
|
|
62
|
-
const focusedItem = currentFocusedItemRef.current;
|
|
63
|
-
const key = e.key;
|
|
64
|
-
if (focusedItem) {
|
|
65
|
-
const searchElementOption = {
|
|
66
|
-
ArrowDown: {
|
|
67
|
-
baseElement: focusedItem,
|
|
68
|
-
direction: 'down',
|
|
69
|
-
},
|
|
70
|
-
ArrowUp: {
|
|
71
|
-
baseElement: focusedItem,
|
|
72
|
-
direction: 'up',
|
|
73
|
-
},
|
|
74
|
-
Home: 'first',
|
|
75
|
-
End: 'last',
|
|
76
|
-
}[key];
|
|
77
|
-
if (searchElementOption) {
|
|
78
|
-
const { focused, isAfterBaseElement } = searchAndFocusItemHandler(searchElementOption);
|
|
79
|
-
if (!focused) {
|
|
80
|
-
focusList();
|
|
81
|
-
}
|
|
82
|
-
if (!isAfterBaseElement || preventContainerScroll) {
|
|
83
|
-
e.preventDefault();
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
if (e.target === e.currentTarget && key === 'Tab' && !e.shiftKey) {
|
|
89
|
-
focusTabBoundary();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
const getListProps = (otherHandler) => {
|
|
94
|
-
const { onKeyDown, onFocus } = otherHandler;
|
|
95
|
-
const handleKeyDown = (e) => {
|
|
96
|
-
onKeyDown?.(e);
|
|
97
|
-
if (e.defaultPrevented) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
listKeyDownHandler(e);
|
|
101
|
-
};
|
|
102
|
-
const handleFocus = (e) => {
|
|
103
|
-
sentinelFocusHandler(e);
|
|
104
|
-
onFocus?.(e);
|
|
105
|
-
};
|
|
106
|
-
return {
|
|
107
|
-
tabIndex: 0,
|
|
108
|
-
onKeyDown: handleKeyDown,
|
|
109
|
-
onFocus: handleFocus,
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
const renderItems = (items) => {
|
|
113
|
-
return (jsxs(ListNavigationContext.Provider, { value: itemActions, children: [items, jsx("div", { "aria-hidden": "true", ref: sentinelArrowNavRef })] }));
|
|
114
|
-
};
|
|
115
|
-
const renderTabBoundary = () => {
|
|
116
|
-
return (jsx("div", { style: { position: 'fixed', bottom: '50%' }, ref: sentinelTabBoundaryRef, tabIndex: 0, onFocus: sentinelFocusHandler }));
|
|
117
|
-
};
|
|
118
|
-
return { renderItems, renderTabBoundary, getListProps, listRef };
|
|
119
|
-
};
|
|
120
|
-
const isUnfocusable = (el) => el.matches('.sui-disabled, :disabled, hr, [role="separator"], [disabled]');
|
|
121
|
-
const defaultSearchAndFocusItem = (searchElementOption, helperElements) => {
|
|
122
|
-
const { list, sentinelEnd } = helperElements;
|
|
123
|
-
if (list.firstElementChild === sentinelEnd) {
|
|
124
|
-
return { focused: false };
|
|
125
|
-
}
|
|
126
|
-
const getFirstItem = () => {
|
|
127
|
-
const firstItem = list.firstElementChild;
|
|
128
|
-
if (firstItem === sentinelEnd) {
|
|
129
|
-
throw Error('SPRING [useListNavigation]: must have child element');
|
|
130
|
-
}
|
|
131
|
-
return firstItem;
|
|
132
|
-
};
|
|
133
|
-
const getLastItem = () => {
|
|
134
|
-
const lastItem = sentinelEnd.previousElementSibling;
|
|
135
|
-
if (!lastItem) {
|
|
136
|
-
throw Error('SPRING [useListNavigation]: must have child element');
|
|
137
|
-
}
|
|
138
|
-
return lastItem;
|
|
139
|
-
};
|
|
140
|
-
let direction;
|
|
141
|
-
let startElement;
|
|
142
|
-
if (typeof searchElementOption === 'string') {
|
|
143
|
-
if (searchElementOption === 'first') {
|
|
144
|
-
startElement = getFirstItem();
|
|
145
|
-
direction = 'down';
|
|
146
|
-
}
|
|
147
|
-
else {
|
|
148
|
-
startElement = getLastItem();
|
|
149
|
-
direction = 'up';
|
|
150
|
-
}
|
|
151
|
-
if (!isUnfocusable(startElement)) {
|
|
152
|
-
startElement.focus();
|
|
153
|
-
return { focused: true };
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
startElement = searchElementOption.baseElement;
|
|
158
|
-
direction = searchElementOption.direction;
|
|
159
|
-
}
|
|
160
|
-
let pointer = startElement;
|
|
161
|
-
let isAfterBaseElement = true;
|
|
162
|
-
if (direction === 'up') {
|
|
163
|
-
do {
|
|
164
|
-
if (!pointer.previousElementSibling) {
|
|
165
|
-
pointer = getLastItem();
|
|
166
|
-
isAfterBaseElement = false;
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
pointer = pointer.previousElementSibling;
|
|
170
|
-
}
|
|
171
|
-
if (!isUnfocusable(pointer)) {
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
} while (pointer !== startElement);
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
do {
|
|
178
|
-
if (pointer.nextElementSibling === sentinelEnd) {
|
|
179
|
-
pointer = getFirstItem();
|
|
180
|
-
isAfterBaseElement = false;
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
pointer = pointer.nextElementSibling;
|
|
184
|
-
}
|
|
185
|
-
if (!isUnfocusable(pointer)) {
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
} while (pointer !== startElement);
|
|
189
|
-
}
|
|
190
|
-
if (isUnfocusable(pointer)) {
|
|
191
|
-
return { focused: false };
|
|
192
|
-
}
|
|
193
|
-
pointer.focus();
|
|
194
|
-
return typeof searchElementOption === 'string'
|
|
195
|
-
? { focused: true }
|
|
196
|
-
: { focused: true, isAfterBaseElement };
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
export { ListNavigationContext as L, useListNavigation as a, useListNavigationContext as u };
|