@ringcentral/spring-ui 1.12.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Accordion.js +90 -34
- package/AccordionHeader.js +71 -21
- package/Alert.js +120 -28
- package/Animation.js +2 -46
- package/Announcement.js +46 -35
- package/Autocomplete.js +1011 -583
- package/Avatar.js +134 -73
- package/AvatarGroup.js +50 -7
- package/Backdrop.js +45 -7
- package/Badge.js +77 -15
- package/Block.js +34 -12
- package/BlockHeader.js +57 -15
- package/BottomNavigation.js +181 -65
- package/BottomNavigationItem.js +93 -30
- package/Button.js +160 -24
- package/CallButton.js +53 -31
- package/Checkbox.js +88 -26
- package/Chip.js +126 -26
- package/CircularProgressIndicator.js +80 -8
- package/ClickAwayListener.js +4 -1
- package/ComponentsProps.js +1 -0
- package/DatePicker.js +611 -192
- package/DateUtilsContext.js +43 -25
- package/Dialer.js +564 -253
- package/Dialog.js +99 -45
- package/Divider.js +43 -7
- package/DragHandle.js +32 -6
- package/Drawer.js +117 -19
- package/Dropdown.js +154 -77
- package/EmptyState.js +65 -15
- package/FabButton.js +51 -17
- package/FocusTrap.js +109 -12
- package/FormField.js +108 -12
- package/FormLabel.js +81 -7
- package/Icon.js +1 -8
- package/IconButton.js +142 -26
- package/IconButtonGroup.js +35 -12
- package/InlineEditable.js +98 -44
- package/LinearProgressIndicator.js +73 -24
- package/Link.js +40 -11
- package/List.js +54 -9
- package/ListItem.js +152 -23
- package/ListItemText.js +44 -17
- package/ListNavigation.js +272 -20
- package/Menu.js +139 -23
- package/MenuActions.js +37 -12
- package/MenuDivider.js +34 -8
- package/MenuFooter.js +36 -12
- package/MenuHeader.js +54 -16
- package/MenuItem.js +402 -35
- package/MenuItemText.js +51 -9
- package/MenuList.js +87 -36
- package/Modal.js +345 -16
- package/NestedMenuContext.js +183 -11
- package/Option.js +32 -36
- package/Overlap.js +54 -7
- package/PageHeader.js +62 -24
- package/PickerTextField.js +156 -35
- package/Popover.js +262 -21
- package/Popper.js +112 -62
- package/PopperPaper.js +54 -8
- package/Portal.js +6 -1
- package/Radio.js +65 -21
- package/RadioGroup.js +56 -17
- package/Rating.js +223 -87
- package/Select.js +387 -44
- package/SingleFilter.js +148 -79
- package/Skeleton.js +68 -17
- package/Slider.js +167 -69
- package/Snackbar.js +122 -59
- package/SortableList.js +32 -12
- package/SortableListDndContext.js +69 -22
- package/SortableListItem.js +92 -47
- package/SortableVirtualizedList.js +44 -20
- package/SplitButton.js +124 -89
- package/Squircle.js +4 -7
- package/StatusIndicator.js +51 -9
- package/Step.js +63 -38
- package/StepButton.js +51 -23
- package/StepConnector.js +48 -8
- package/StepContent.js +67 -24
- package/StepIcon.js +90 -9
- package/StepLabel.js +90 -14
- package/Stepper.js +65 -23
- package/SubMenu.js +203 -101
- package/SwipeableDrawer.js +439 -194
- package/Switch.js +70 -23
- package/Tab.js +120 -57
- package/TabContext.js +59 -15
- package/TabPanel.js +40 -13
- package/Table.js +60 -17
- package/TableBody.js +42 -12
- package/TableCell.js +84 -50
- package/TableContainer.js +32 -10
- package/TableFooter.js +38 -10
- package/TableHead.js +49 -15
- package/TablePagination.js +153 -79
- package/TableRow.js +60 -21
- package/Tabs.js +592 -271
- package/Tag.js +51 -16
- package/Text.js +68 -37
- package/TextField.js +209 -31
- package/Textarea.js +51 -42
- package/TimePicker.js +490 -232
- package/Tooltip.js +48 -23
- package/Tray.js +237 -13
- package/TrayMenu.js +62 -43
- package/VirtualizedList.js +205 -107
- package/VirtualizedMenu.js +359 -29
- package/VisuallyHidden.js +29 -6
- package/chunks/1250.js +98 -0
- package/chunks/1294.js +126 -0
- package/chunks/2956.js +18 -0
- package/chunks/4476.js +460 -0
- package/chunks/4491.js +10 -0
- package/chunks/4535.js +364 -0
- package/chunks/5047.js +3 -0
- package/chunks/6335.js +24 -0
- package/chunks/7279.js +10 -0
- package/chunks/8011.js +8 -0
- package/chunks/8307.js +56 -0
- package/chunks/8467.js +8 -0
- package/chunks/8809.js +8 -0
- package/chunks/{RadioGroup.context.js → 9551.js} +12 -6
- package/chunks/987.js +8 -0
- package/index.css +2436 -2261
- package/index.js +245 -195
- package/internal/utils/setRef.d.ts +2 -1
- package/package.json +4 -4
- package/src/Animation/hooks/useMotionSafeTransition/useMotionSafeTransition.d.ts +2 -0
- package/src/Autocomplete/SuggestionList/SuggestionList.d.ts +1 -1
- package/src/Button/Button.classes.d.ts +1 -1
- package/src/ComponentsProps.d.ts +111 -110
- package/src/DatePicker/DatePickerDataAttributes.d.ts +11 -0
- package/src/DatePicker/utils/DatePickerUtils.d.ts +1 -1
- package/src/MenuItem/MenuItem.type.d.ts +1 -0
- package/src/MenuList/MenuListContext.d.ts +2 -3
- package/src/Modal/Modal.type.d.ts +1 -0
- package/src/Popover/Popover.classes.d.ts +1 -1
- package/src/Popover/Popover.internal.d.ts +8 -0
- package/src/Popover/Popover.type.d.ts +1 -0
- package/src/Select/Select.type.d.ts +6 -4
- package/src/Table/Table.type.d.ts +3 -0
- package/src/Table/TableContext.d.ts +3 -0
- package/src/Table/TableRowContext.d.ts +7 -0
- package/src/Table/index.d.ts +1 -0
- package/src/TableCell/TableCell.classes.d.ts +1 -1
- package/src/TableFooter/TableFooter.classes.d.ts +1 -1
- package/src/TableFooter/TableFooter.type.d.ts +1 -0
- package/src/TableHead/TableHead.classes.d.ts +1 -1
- package/src/TableHead/TableHead.type.d.ts +1 -0
- package/src/TableRow/TableRow.type.d.ts +2 -0
- package/chunks/AccordionContext.js +0 -6
- package/chunks/Alert.js +0 -48
- package/chunks/AvatarGroup.js +0 -22
- package/chunks/Backdrop.js +0 -18
- package/chunks/Badge.js +0 -32
- package/chunks/BottomNavigationItem.js +0 -36
- package/chunks/Button.js +0 -88
- package/chunks/Chip.js +0 -73
- package/chunks/CircularProgressIndicator.js +0 -36
- package/chunks/Divider.js +0 -19
- package/chunks/DragHandle.js +0 -11
- package/chunks/Drawer.js +0 -33
- package/chunks/ExpandCollapseCaret.js +0 -24
- package/chunks/FormLabel.js +0 -27
- package/chunks/Icon.js +0 -25
- package/chunks/IconButtonLabel.js +0 -68
- package/chunks/List.js +0 -22
- package/chunks/ListItem.js +0 -83
- package/chunks/Menu.js +0 -61
- package/chunks/MenuDivider.js +0 -14
- package/chunks/MenuItemText.js +0 -18
- package/chunks/MenuList.js +0 -47
- package/chunks/Modal.js +0 -211
- package/chunks/Overlap.js +0 -25
- package/chunks/PickerTextField.js +0 -85
- package/chunks/Popover.js +0 -61
- package/chunks/PopperPaper.js +0 -15
- package/chunks/Select.js +0 -225
- package/chunks/ShowHideEye.js +0 -56
- package/chunks/SlideIn.js +0 -20
- package/chunks/SortableArrow.js +0 -73
- package/chunks/Squircle.js +0 -31
- package/chunks/StatusIndicator.js +0 -20
- package/chunks/StepConnector.js +0 -21
- package/chunks/StepIcon.js +0 -43
- package/chunks/StepLabel.js +0 -29
- package/chunks/StepperContext.js +0 -9
- package/chunks/TableContext.js +0 -6
- package/chunks/Tablelvl2Context.js +0 -6
- package/chunks/TabsContext.js +0 -6
- package/chunks/TextField.js +0 -110
- package/chunks/Tooltip.js +0 -217
- package/chunks/VirtualizedMenu.js +0 -162
- package/chunks/VisuallyHidden.js +0 -12
- package/chunks/composeEventHandlers.js +0 -10
- package/chunks/getFade.js +0 -27
- package/chunks/getGrow.js +0 -70
- package/chunks/getSlideIn.js +0 -30
- package/chunks/hasContent.js +0 -3
- package/chunks/useAnimationFrame.js +0 -15
- package/chunks/useFocusTrapStack.js +0 -38
- package/chunks/useHelperTextId.js +0 -24
- package/chunks/useListNavigation.js +0 -199
- package/chunks/useMenuItemSelect.js +0 -282
- package/chunks/useMotionSafeTransition.js +0 -9
- package/chunks/useNestedMenuItem.js +0 -27
- package/chunks/useNestedParentMenu.js +0 -113
- package/chunks/usePrefersReducedMotion.js +0 -36
- package/chunks/useTooltipForceHide.js +0 -27
- package/chunks/useTrayNavigate.js +0 -150
- package/chunks/withTooltip.js +0 -15
package/chunks/Tooltip.js
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
3
|
-
import { AnimatePresence } from 'framer-motion';
|
|
4
|
-
import { useRef, useEffect, cloneElement, forwardRef } from 'react';
|
|
5
|
-
import { logInDev, useWindowContext, useId, useControlled, useIsFocusVisible, useForkRef, useEventListener, useClasses, combineProps } from '@ringcentral/spring-base';
|
|
6
|
-
import clsx from 'clsx';
|
|
7
|
-
import { I as Icon } from './Icon.js';
|
|
8
|
-
import { u as usePrefersReducedMotion } from './usePrefersReducedMotion.js';
|
|
9
|
-
import { g as getFade } from './getFade.js';
|
|
10
|
-
import { Popper } from '../Popper.js';
|
|
11
|
-
import { P as PopperPaper } from './PopperPaper.js';
|
|
12
|
-
|
|
13
|
-
const ARIA_DESCRIBEDBY = 'aria-describedby';
|
|
14
|
-
const ARIA_LABEL = 'aria-label';
|
|
15
|
-
const ARIA_LABELLEDBY = 'aria-labelledby';
|
|
16
|
-
const HTML_TITLE = 'title';
|
|
17
|
-
let hasWarnedTriggerWhenDisabledNonStringTitle = false;
|
|
18
|
-
function computeTooltipA11y({ title, describeChild, triggerWhenDisabled, open, tooltipId, child, }) {
|
|
19
|
-
const nameOrDescProps = {};
|
|
20
|
-
const disabledOverrides = {};
|
|
21
|
-
const titleIsString = typeof title === 'string';
|
|
22
|
-
const childProps = child.props;
|
|
23
|
-
const hasAriaDescribedBy = ARIA_DESCRIBEDBY in childProps;
|
|
24
|
-
const hasAriaLabel = ARIA_LABEL in childProps;
|
|
25
|
-
const hasAriaLabelledBy = ARIA_LABELLEDBY in childProps;
|
|
26
|
-
const hasUserTitle = HTML_TITLE in childProps;
|
|
27
|
-
if (process.env.NODE_ENV !== 'production' &&
|
|
28
|
-
triggerWhenDisabled &&
|
|
29
|
-
!titleIsString &&
|
|
30
|
-
title != null &&
|
|
31
|
-
!hasUserTitle &&
|
|
32
|
-
!hasWarnedTriggerWhenDisabledNonStringTitle) {
|
|
33
|
-
hasWarnedTriggerWhenDisabledNonStringTitle = true;
|
|
34
|
-
logInDev({
|
|
35
|
-
scope: 'Tooltip',
|
|
36
|
-
level: 'warn',
|
|
37
|
-
message: 'Using Tooltip with `triggerWhenDisabled` and a non-string `title` is not fully accessible. Use a string `title` when explaining why a control is disabled.',
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
if (describeChild) {
|
|
41
|
-
if (!hasAriaDescribedBy) {
|
|
42
|
-
if (!hasUserTitle) {
|
|
43
|
-
nameOrDescProps.title =
|
|
44
|
-
!open && titleIsString ? title : null;
|
|
45
|
-
}
|
|
46
|
-
else if (open) {
|
|
47
|
-
nameOrDescProps.title = null;
|
|
48
|
-
}
|
|
49
|
-
nameOrDescProps[ARIA_DESCRIBEDBY] = open ? tooltipId : null;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
if (titleIsString && !hasAriaLabel) {
|
|
54
|
-
nameOrDescProps[ARIA_LABEL] = title;
|
|
55
|
-
nameOrDescProps.title = null;
|
|
56
|
-
}
|
|
57
|
-
else if (!titleIsString && !hasAriaLabelledBy && title) {
|
|
58
|
-
nameOrDescProps[ARIA_LABELLEDBY] = open ? tooltipId : null;
|
|
59
|
-
if (open) {
|
|
60
|
-
nameOrDescProps.title = null;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else if (open) {
|
|
64
|
-
nameOrDescProps.title = null;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
if (triggerWhenDisabled) {
|
|
68
|
-
if (open) {
|
|
69
|
-
if (!hasAriaDescribedBy) {
|
|
70
|
-
disabledOverrides[ARIA_DESCRIBEDBY] = tooltipId;
|
|
71
|
-
}
|
|
72
|
-
disabledOverrides.title = null;
|
|
73
|
-
}
|
|
74
|
-
else if (titleIsString) {
|
|
75
|
-
disabledOverrides.title = title;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return { nameOrDescProps, disabledOverrides };
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const getDelayTime = (delay) => {
|
|
82
|
-
if (!delay)
|
|
83
|
-
return null;
|
|
84
|
-
if (delay === true)
|
|
85
|
-
return 1500;
|
|
86
|
-
return delay;
|
|
87
|
-
};
|
|
88
|
-
const TooltipTrigger = (props, ref) => {
|
|
89
|
-
const { renderTooltip, children, open: openProp, delay = false, onOpenStateChange, triggerWhenDisabled, triggerWrapperProps, disableFocusListener, tooltipId: tooltipIdProp, title, describeChild = false, } = props;
|
|
90
|
-
const anchorRef = useRef(null);
|
|
91
|
-
const didInitiateWithTouch = useRef(false);
|
|
92
|
-
const { document } = useWindowContext();
|
|
93
|
-
const generatedId = useId();
|
|
94
|
-
const tooltipId = tooltipIdProp ?? generatedId;
|
|
95
|
-
const [open, setOpen] = useControlled({
|
|
96
|
-
controlled: openProp,
|
|
97
|
-
default: false,
|
|
98
|
-
name: 'Tooltip',
|
|
99
|
-
state: 'open',
|
|
100
|
-
});
|
|
101
|
-
const { isFocusVisibleRef, onFocus: handleFocusVisible, onBlur: handleBlurVisible, ref: focusVisibleRef, } = useIsFocusVisible();
|
|
102
|
-
const handleAnchorRef = useForkRef(anchorRef, focusVisibleRef, children.ref);
|
|
103
|
-
const delayTimerRef = useRef();
|
|
104
|
-
useEffect(() => () => {
|
|
105
|
-
clearTimeout(delayTimerRef.current);
|
|
106
|
-
}, []);
|
|
107
|
-
const handleOpen = (e) => {
|
|
108
|
-
const delayTime = getDelayTime(delay);
|
|
109
|
-
if (delayTime) {
|
|
110
|
-
delayTimerRef.current = setTimeout(() => {
|
|
111
|
-
setOpen(true);
|
|
112
|
-
onOpenStateChange?.(e, true);
|
|
113
|
-
}, delayTime);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
setOpen(true);
|
|
117
|
-
onOpenStateChange?.(e, true);
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
const handleClose = (e) => {
|
|
121
|
-
clearTimeout(delayTimerRef.current);
|
|
122
|
-
delayTimerRef.current = undefined;
|
|
123
|
-
setOpen(false);
|
|
124
|
-
onOpenStateChange?.(e, false);
|
|
125
|
-
};
|
|
126
|
-
useEventListener(anchorRef, 'mouseenter', (e) => {
|
|
127
|
-
if (didInitiateWithTouch.current) {
|
|
128
|
-
didInitiateWithTouch.current = false;
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
if (anchorRef.current) {
|
|
132
|
-
anchorRef.current.removeAttribute('title');
|
|
133
|
-
}
|
|
134
|
-
handleOpen(e);
|
|
135
|
-
});
|
|
136
|
-
useEventListener(anchorRef, 'mouseleave', (e) => {
|
|
137
|
-
handleClose(e);
|
|
138
|
-
});
|
|
139
|
-
useEventListener(anchorRef, 'touchstart', (e) => {
|
|
140
|
-
didInitiateWithTouch.current = true;
|
|
141
|
-
}, {
|
|
142
|
-
passive: true,
|
|
143
|
-
});
|
|
144
|
-
useEventListener(anchorRef, 'focus', (e) => {
|
|
145
|
-
if (disableFocusListener)
|
|
146
|
-
return;
|
|
147
|
-
handleFocusVisible(e);
|
|
148
|
-
if (isFocusVisibleRef.current === true) {
|
|
149
|
-
handleOpen(e);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
useEventListener(anchorRef, 'blur', (e) => {
|
|
153
|
-
handleBlurVisible(e);
|
|
154
|
-
if (isFocusVisibleRef.current === false) {
|
|
155
|
-
handleClose(e);
|
|
156
|
-
}
|
|
157
|
-
});
|
|
158
|
-
useEventListener(open ? document : null, 'keydown', (e) => {
|
|
159
|
-
if (e.key === 'Escape') {
|
|
160
|
-
handleClose(e);
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
const { nameOrDescProps, disabledOverrides } = computeTooltipA11y({
|
|
164
|
-
title,
|
|
165
|
-
describeChild,
|
|
166
|
-
triggerWhenDisabled,
|
|
167
|
-
open,
|
|
168
|
-
tooltipId,
|
|
169
|
-
child: children,
|
|
170
|
-
});
|
|
171
|
-
return (jsxs(Fragment, { children: [triggerWhenDisabled ? (jsx("span", { ...triggerWrapperProps, className: clsx('sui-tooltip-trigger-wrapper', triggerWrapperProps?.className), ref: handleAnchorRef, children: cloneElement(children, disabledOverrides) })) : (cloneElement(children, {
|
|
172
|
-
ref: handleAnchorRef,
|
|
173
|
-
...nameOrDescProps,
|
|
174
|
-
})), renderTooltip(open, () => anchorRef.current, tooltipId)] }));
|
|
175
|
-
};
|
|
176
|
-
TooltipTrigger.displayName = 'SuiTooltipTrigger';
|
|
177
|
-
|
|
178
|
-
const TooltipView = forwardRef((props, ref) => {
|
|
179
|
-
const { className, icon, size = 'small', classes, children, placement = 'bottom', PopperProps, color = 'neutral', anchorEl, motionProps, tooltipForceHide = false, disableInteractions = true, PopperPaperProps: popperPaperPropsProp, } = props;
|
|
180
|
-
const prefersReducedMotion = usePrefersReducedMotion();
|
|
181
|
-
const cls = useClasses('tooltip-view', classes, className);
|
|
182
|
-
const padding = PopperProps?.padding;
|
|
183
|
-
const popperPadding = typeof padding === 'object'
|
|
184
|
-
? {
|
|
185
|
-
top: padding.top ?? 16,
|
|
186
|
-
right: padding.right ?? 16,
|
|
187
|
-
bottom: padding.bottom ?? 16,
|
|
188
|
-
left: padding.left ?? 16,
|
|
189
|
-
}
|
|
190
|
-
: (padding ?? 16);
|
|
191
|
-
return (jsx(Popper, { role: "tooltip", placement: placement, offset: 4, ...PopperProps, padding: popperPadding, className: cls('root', {
|
|
192
|
-
'force-hide': tooltipForceHide,
|
|
193
|
-
'disable-interactions': disableInteractions,
|
|
194
|
-
}), anchorEl: anchorEl, arrowHeight: 6, arrowPadding: 8, ref: ref, children: ({ arrowRef, arrowStyle }) => (jsxs(PopperPaper, { ...(motionProps ?? getFade({ prefersReducedMotion })), ...combineProps({
|
|
195
|
-
arrowRef,
|
|
196
|
-
arrowStyle,
|
|
197
|
-
classes: {
|
|
198
|
-
root: cls('paper', color),
|
|
199
|
-
content: cls('paper-content', `paper-content-${size}`),
|
|
200
|
-
},
|
|
201
|
-
}, popperPaperPropsProp), children: [icon && jsx(Icon, { symbol: icon, size: "small", className: cls('icon') }), jsx("div", { className: cls('content', `content-${size}`), children: children })] })) }));
|
|
202
|
-
});
|
|
203
|
-
TooltipView.displayName = 'SuiTooltipView';
|
|
204
|
-
|
|
205
|
-
const Tooltip = forwardRef((inProps, ref) => {
|
|
206
|
-
const props = useThemeProps({ props: inProps, name: 'Tooltip' });
|
|
207
|
-
const { children, open: openProp, delay, onOpenStateChange, title, disableFocusListener, disableBackdropAnimation, triggerWhenDisabled, triggerWrapperProps, PopperProps, describeChild = false, ...rest } = props;
|
|
208
|
-
const renderTooltip = (open, getAnchorEl, tooltipId) => {
|
|
209
|
-
const effectiveOpen = open && !(!title && title !== 0);
|
|
210
|
-
const content = effectiveOpen ? (jsx(TooltipView, { disableInteractions: openProp === undefined, ...rest, PopperProps: { ...PopperProps, id: tooltipId }, anchorEl: getAnchorEl, ref: ref, children: title })) : null;
|
|
211
|
-
return disableBackdropAnimation ? (jsx(Fragment, { children: content })) : (jsx(AnimatePresence, { children: content }));
|
|
212
|
-
};
|
|
213
|
-
return (jsx(TooltipTrigger, { disableFocusListener: disableFocusListener, open: openProp, delay: delay, onOpenStateChange: onOpenStateChange, renderTooltip: renderTooltip, triggerWhenDisabled: triggerWhenDisabled, triggerWrapperProps: triggerWrapperProps, tooltipId: PopperProps?.id, title: title, describeChild: describeChild, children: children }));
|
|
214
|
-
});
|
|
215
|
-
Tooltip.displayName = 'SuiTooltip';
|
|
216
|
-
|
|
217
|
-
export { Tooltip as T, TooltipTrigger as a, TooltipView as b };
|
|
@@ -1,162 +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, actions, 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 (paperContentContainerRef.current) {
|
|
78
|
-
paperContentContainerRef.current.style.height = `auto`;
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
const handleTotalListHeightChanged = useEventCallback((listHeight) => {
|
|
82
|
-
if (!hasItemsRenderedRef.current) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
const adjustedHeight = listHeight + MENU_VERTICAL_PADDING * 2
|
|
86
|
-
;
|
|
87
|
-
computedListHeight.current = adjustedHeight;
|
|
88
|
-
if (paperContentContainerRef.current) {
|
|
89
|
-
paperContentContainerRef.current.style.height = `${adjustedHeight}px`;
|
|
90
|
-
}
|
|
91
|
-
updateMenuHeight();
|
|
92
|
-
popperActions.current?.update();
|
|
93
|
-
if (waitForHeightCompute) {
|
|
94
|
-
requestAnimationFrame(() => {
|
|
95
|
-
setDeferPendingVirtualizedListActions(false);
|
|
96
|
-
requestAnimationFrame(() => {
|
|
97
|
-
setWaitForHeightCompute(false);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
const handleAvailableHeightChange = useEventCallback((value) => {
|
|
103
|
-
if (computedListHeight.current === -1 || !hasItemsRenderedRef.current) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
availableHeight.current = value;
|
|
107
|
-
updateMenuHeight();
|
|
108
|
-
updatePopoverHeight();
|
|
109
|
-
});
|
|
110
|
-
useEffect(() => {
|
|
111
|
-
if (!open) {
|
|
112
|
-
hasItemsRenderedRef.current = false;
|
|
113
|
-
}
|
|
114
|
-
if (open) {
|
|
115
|
-
if (computedListHeight.current !== -1) {
|
|
116
|
-
updateMenuHeight();
|
|
117
|
-
setWaitForHeightCompute(false);
|
|
118
|
-
setDeferPendingVirtualizedListActions(false);
|
|
119
|
-
popperActions.current?.update();
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
setMenuHeight(MENU_VERTICAL_PADDING * 2);
|
|
123
|
-
setWaitForHeightCompute(true);
|
|
124
|
-
setDeferPendingVirtualizedListActions(true);
|
|
125
|
-
}
|
|
126
|
-
if (popperPaperContentRef.current) {
|
|
127
|
-
popperPaperContentRef.current.style.maxHeight = 'none';
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}, [open]);
|
|
131
|
-
return (jsx(Popover, { bordered: true, PopperProps: { ...PopperProps, padding: popperPadding }, ...rest, open: open, className: clsx(cls('root'), waitForHeightCompute && 'opacity-0'), PopperPaperProps: {
|
|
132
|
-
contentRef: popperPaperContentRef,
|
|
133
|
-
}, 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, actions: actions, ...combineProps(VirtualizedListProps, {
|
|
134
|
-
style: { height: menuHeight },
|
|
135
|
-
ListProps: combineProps(VirtualizedListProps?.ListProps, {
|
|
136
|
-
className: cls('list'),
|
|
137
|
-
style: {
|
|
138
|
-
['--sui-virtualized-menu-vertical-padding']: `${MENU_VERTICAL_PADDING}px`,
|
|
139
|
-
},
|
|
140
|
-
}),
|
|
141
|
-
totalListHeightChanged: handleTotalListHeightChanged,
|
|
142
|
-
itemsRendered: (items) => {
|
|
143
|
-
if (totalCount === 0 ||
|
|
144
|
-
(totalCount === undefined &&
|
|
145
|
-
data !== undefined &&
|
|
146
|
-
data.length === 0) ||
|
|
147
|
-
(items && items.length > 0)) {
|
|
148
|
-
hasItemsRenderedRef.current = true;
|
|
149
|
-
}
|
|
150
|
-
VirtualizedListProps?.itemsRendered?.(items);
|
|
151
|
-
},
|
|
152
|
-
onKeyDown: (e) => {
|
|
153
|
-
if (e.key === 'Tab') {
|
|
154
|
-
e.preventDefault();
|
|
155
|
-
onClose?.();
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
}), children: children }) }) }) }) }));
|
|
159
|
-
});
|
|
160
|
-
VirtualizedMenu.displayName = 'SuiVirtualizedMenu';
|
|
161
|
-
|
|
162
|
-
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 };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const composeEventHandlers = (externalEventHandler, internalEventHandler, options = {}) => (event, ...args) => {
|
|
2
|
-
const { checkForDefaultPrevented = true } = options;
|
|
3
|
-
externalEventHandler?.(event, ...args);
|
|
4
|
-
if (checkForDefaultPrevented && event.defaultPrevented) {
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
internalEventHandler?.(event, ...args);
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export { composeEventHandlers as c };
|
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, transition, } = {}) => {
|
|
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
|
-
: (transition ?? 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,38 +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
|
-
if (stack.indexOf(id) < 0) {
|
|
18
|
-
stack.push(id);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return () => {
|
|
22
|
-
const stack = getFocusTrapStack(globalThis);
|
|
23
|
-
const index = stack.indexOf(id);
|
|
24
|
-
if (index >= 0) {
|
|
25
|
-
stack.splice(index, 1);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
}, [open]);
|
|
29
|
-
const isEnabled = useEventCallback(() => {
|
|
30
|
-
const stack = getFocusTrapStack(globalThis);
|
|
31
|
-
return stack.at(-1) === id;
|
|
32
|
-
});
|
|
33
|
-
return {
|
|
34
|
-
isEnabled,
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export { useFocusTrapStack as u };
|
|
@@ -1,24 +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
|
-
import { h as hasContent } from './hasContent.js';
|
|
7
|
-
import '@mui/utils';
|
|
8
|
-
|
|
9
|
-
const FormField = forwardRef((inProps, ref) => {
|
|
10
|
-
const props = useThemeProps({ props: inProps, name: 'FormField' });
|
|
11
|
-
const { classes, className, children, htmlFor, label, labelProps, helperText, required, disabled, error, variant = 'standard', size = 'xlarge', contentRef, contentProps, focused, FormHelperTextProps, ...rest } = props;
|
|
12
|
-
const cls = useClasses('form-field', classes, className);
|
|
13
|
-
return (jsxs("div", { ...rest, ref: ref, className: cls('root', variant, { disabled, error, focused }), "aria-disabled": disabled, children: [hasContent(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') })] }), hasContent(helperText) && (jsx("div", { ...FormHelperTextProps, className: clsx(cls('helper-text', error && 'error-helper-text'), FormHelperTextProps?.className), children: helperText }))] }));
|
|
14
|
-
});
|
|
15
|
-
FormField.displayName = 'SuiFormField';
|
|
16
|
-
|
|
17
|
-
const useHelperTextId = ({ helperText, id, FormHelperTextProps, }) => {
|
|
18
|
-
if (!hasContent(helperText)) {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
return FormHelperTextProps?.id || `${id}-helper-text`;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export { FormField as F, useHelperTextId as u };
|