@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/4535.js
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useThemeProps } from "@ringcentral/spring-theme";
|
|
3
|
+
import { AnimatePresence } from "framer-motion";
|
|
4
|
+
import { cloneElement, forwardRef, useEffect, useRef } from "react";
|
|
5
|
+
import { combineProps, logInDev, useClasses, useControlled, useEventListener, useForkRef, useId, useIsFocusVisible, useWindowContext } from "@ringcentral/spring-base";
|
|
6
|
+
import clsx from "clsx";
|
|
7
|
+
import { getFade } from "./4476.js";
|
|
8
|
+
import { Icon as Icon_Icon } from "./8307.js";
|
|
9
|
+
import { Popper } from "../Popper.js";
|
|
10
|
+
import { PopperPaper as PopperPaper_PopperPaper } from "../PopperPaper.js";
|
|
11
|
+
import { usePrefersReducedMotion } from "./1294.js";
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Accessibility naming strategy:
|
|
25
|
+
* - Default (label mode): `title` is treated as an accessible label
|
|
26
|
+
* - string `title` → `aria-label`
|
|
27
|
+
* - React element `title` → `aria-labelledby` while the tooltip is open
|
|
28
|
+
* - Description mode (`describeChild = true`): `title` is treated as an accessible description
|
|
29
|
+
* - when closed → native `title` attribute
|
|
30
|
+
* - when open → `aria-describedby` pointing to the tooltip id
|
|
31
|
+
*/ const ARIA_DESCRIBEDBY = 'aria-describedby';
|
|
32
|
+
const ARIA_LABEL = 'aria-label';
|
|
33
|
+
const ARIA_LABELLEDBY = 'aria-labelledby';
|
|
34
|
+
const HTML_TITLE = 'title';
|
|
35
|
+
let hasWarnedTriggerWhenDisabledNonStringTitle = false;
|
|
36
|
+
function computeTooltipA11y({ title, describeChild, triggerWhenDisabled, open, tooltipId, child }) {
|
|
37
|
+
const nameOrDescProps = {};
|
|
38
|
+
const disabledOverrides = {};
|
|
39
|
+
const titleIsString = typeof title === 'string';
|
|
40
|
+
const childProps = child.props;
|
|
41
|
+
const hasAriaDescribedBy = ARIA_DESCRIBEDBY in childProps;
|
|
42
|
+
const hasAriaLabel = ARIA_LABEL in childProps;
|
|
43
|
+
const hasAriaLabelledBy = ARIA_LABELLEDBY in childProps;
|
|
44
|
+
const hasUserTitle = HTML_TITLE in childProps;
|
|
45
|
+
if (process.env.NODE_ENV !== 'production' && triggerWhenDisabled && !titleIsString && title != null && !hasUserTitle && !hasWarnedTriggerWhenDisabledNonStringTitle) {
|
|
46
|
+
hasWarnedTriggerWhenDisabledNonStringTitle = true;
|
|
47
|
+
logInDev({
|
|
48
|
+
scope: 'Tooltip',
|
|
49
|
+
level: 'warn',
|
|
50
|
+
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.'
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (describeChild) {
|
|
54
|
+
// Description mode: tooltip acts as an accessible description
|
|
55
|
+
// When closed: add title attribute (unless user provided their own)
|
|
56
|
+
// When open: swap to aria-describedby
|
|
57
|
+
if (!hasAriaDescribedBy) {
|
|
58
|
+
if (!hasUserTitle) {
|
|
59
|
+
// Only set tooltip title if user hasn't provided one
|
|
60
|
+
nameOrDescProps.title = !open && titleIsString ? title : null;
|
|
61
|
+
} else if (open) {
|
|
62
|
+
// If user provided a title and tooltip is open, remove native title to prevent duplicate
|
|
63
|
+
nameOrDescProps.title = null;
|
|
64
|
+
}
|
|
65
|
+
nameOrDescProps[ARIA_DESCRIBEDBY] = open ? tooltipId : null;
|
|
66
|
+
}
|
|
67
|
+
} else {
|
|
68
|
+
// Label mode (default): tooltip acts as an accessible label
|
|
69
|
+
// Use aria-label for strings, aria-labelledby for React elements
|
|
70
|
+
if (titleIsString && !hasAriaLabel) {
|
|
71
|
+
nameOrDescProps[ARIA_LABEL] = title;
|
|
72
|
+
// For string titles, Tooltip fully owns the label; always remove native title
|
|
73
|
+
nameOrDescProps.title = null;
|
|
74
|
+
} else if (!titleIsString && !hasAriaLabelledBy && title) {
|
|
75
|
+
// Only set aria-labelledby if title is truthy (React element exists)
|
|
76
|
+
nameOrDescProps[ARIA_LABELLEDBY] = open ? tooltipId : null;
|
|
77
|
+
// Only remove native title when tooltip is open to prevent duplicate tooltips.
|
|
78
|
+
// When closed, leave existing title as a fallback accessible name.
|
|
79
|
+
if (open) {
|
|
80
|
+
nameOrDescProps.title = null;
|
|
81
|
+
}
|
|
82
|
+
} else if (open) {
|
|
83
|
+
// Tooltip is open but we're not providing a label (e.g. child already has aria-label);
|
|
84
|
+
// still remove native title to avoid double tooltips.
|
|
85
|
+
nameOrDescProps.title = null;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (triggerWhenDisabled) {
|
|
89
|
+
// When open and child does not already have aria-describedby: use tooltip id,
|
|
90
|
+
// and always remove native title on the disabled control to avoid double tooltips.
|
|
91
|
+
// When closed and title is a string: use native title as a fallback for SR on disabled.
|
|
92
|
+
if (open) {
|
|
93
|
+
if (!hasAriaDescribedBy) {
|
|
94
|
+
disabledOverrides[ARIA_DESCRIBEDBY] = tooltipId;
|
|
95
|
+
}
|
|
96
|
+
disabledOverrides.title = null;
|
|
97
|
+
} else if (titleIsString) {
|
|
98
|
+
disabledOverrides.title = title;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
nameOrDescProps,
|
|
103
|
+
disabledOverrides
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
const getDelayTime = (delay)=>{
|
|
113
|
+
if (!delay) return null;
|
|
114
|
+
if (delay === true) return 1500;
|
|
115
|
+
return delay;
|
|
116
|
+
};
|
|
117
|
+
const TooltipTrigger = (props, ref)=>{
|
|
118
|
+
const { renderTooltip, children, open: openProp, delay = false, onOpenStateChange, triggerWhenDisabled, triggerWrapperProps, disableFocusListener, tooltipId: tooltipIdProp, title, describeChild = false } = props;
|
|
119
|
+
const anchorRef = useRef(null);
|
|
120
|
+
const didInitiateWithTouch = useRef(false);
|
|
121
|
+
const { document } = useWindowContext();
|
|
122
|
+
const generatedId = useId();
|
|
123
|
+
const tooltipId = tooltipIdProp ?? generatedId;
|
|
124
|
+
const [open, setOpen] = useControlled({
|
|
125
|
+
controlled: openProp,
|
|
126
|
+
default: false,
|
|
127
|
+
name: 'Tooltip',
|
|
128
|
+
state: 'open'
|
|
129
|
+
});
|
|
130
|
+
const { isFocusVisibleRef, onFocus: handleFocusVisible, onBlur: handleBlurVisible, ref: focusVisibleRef } = useIsFocusVisible();
|
|
131
|
+
const handleAnchorRef = useForkRef(anchorRef, focusVisibleRef, children.ref);
|
|
132
|
+
const delayTimerRef = useRef();
|
|
133
|
+
useEffect(()=>()=>{
|
|
134
|
+
clearTimeout(delayTimerRef.current);
|
|
135
|
+
}, []);
|
|
136
|
+
const handleOpen = (e)=>{
|
|
137
|
+
const delayTime = getDelayTime(delay);
|
|
138
|
+
if (delayTime) {
|
|
139
|
+
delayTimerRef.current = setTimeout(()=>{
|
|
140
|
+
setOpen(true);
|
|
141
|
+
onOpenStateChange?.(e, true);
|
|
142
|
+
}, delayTime);
|
|
143
|
+
} else {
|
|
144
|
+
setOpen(true);
|
|
145
|
+
onOpenStateChange?.(e, true);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const handleClose = (e)=>{
|
|
149
|
+
clearTimeout(delayTimerRef.current);
|
|
150
|
+
delayTimerRef.current = undefined;
|
|
151
|
+
setOpen(false);
|
|
152
|
+
onOpenStateChange?.(e, false);
|
|
153
|
+
};
|
|
154
|
+
useEventListener(anchorRef, 'mouseenter', (e)=>{
|
|
155
|
+
// Ensures touch devices do not trigger the tooltip, mouseleave will never be fired and the tooltip will be stuck open
|
|
156
|
+
if (didInitiateWithTouch.current) {
|
|
157
|
+
// Immediately reset the flag, touchstart will fire again on the next tap and will set the flag back to true
|
|
158
|
+
didInitiateWithTouch.current = false;
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
// Remove the title ahead of time from the trigger.
|
|
162
|
+
// We don't want to wait for the next render commit.
|
|
163
|
+
// We would risk displaying two tooltips at the same time (native + this one).
|
|
164
|
+
if (anchorRef.current) {
|
|
165
|
+
anchorRef.current.removeAttribute('title');
|
|
166
|
+
}
|
|
167
|
+
handleOpen(e);
|
|
168
|
+
});
|
|
169
|
+
useEventListener(anchorRef, 'mouseleave', (e)=>{
|
|
170
|
+
handleClose(e);
|
|
171
|
+
});
|
|
172
|
+
useEventListener(anchorRef, 'touchstart', (e)=>{
|
|
173
|
+
didInitiateWithTouch.current = true;
|
|
174
|
+
}, {
|
|
175
|
+
passive: true
|
|
176
|
+
});
|
|
177
|
+
useEventListener(anchorRef, 'focus', (e)=>{
|
|
178
|
+
if (disableFocusListener) return;
|
|
179
|
+
// handleFocusVisible only support react event type, but it only need target event
|
|
180
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
181
|
+
handleFocusVisible(e);
|
|
182
|
+
if (isFocusVisibleRef.current === true) {
|
|
183
|
+
handleOpen(e);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
useEventListener(anchorRef, 'blur', (e)=>{
|
|
187
|
+
// handleBlurVisible only support react event type, but this param is useless
|
|
188
|
+
// oxlint-disable-next-line @typescript-eslint/no-explicit-any
|
|
189
|
+
handleBlurVisible(e);
|
|
190
|
+
if (isFocusVisibleRef.current === false) {
|
|
191
|
+
handleClose(e);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
// Handle Escape key to close tooltip
|
|
195
|
+
useEventListener(open ? document : null, 'keydown', (e)=>{
|
|
196
|
+
if (e.key === 'Escape') {
|
|
197
|
+
handleClose(e);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
const { nameOrDescProps, disabledOverrides } = computeTooltipA11y({
|
|
201
|
+
title,
|
|
202
|
+
describeChild,
|
|
203
|
+
triggerWhenDisabled,
|
|
204
|
+
open,
|
|
205
|
+
tooltipId,
|
|
206
|
+
child: children
|
|
207
|
+
});
|
|
208
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
209
|
+
children: [
|
|
210
|
+
triggerWhenDisabled ? /*#__PURE__*/ jsx("span", {
|
|
211
|
+
...triggerWrapperProps,
|
|
212
|
+
className: clsx('sui-tooltip-trigger-wrapper', triggerWrapperProps?.className),
|
|
213
|
+
ref: handleAnchorRef,
|
|
214
|
+
children: /*#__PURE__*/ cloneElement(children, disabledOverrides)
|
|
215
|
+
}) : /*#__PURE__*/ cloneElement(children, {
|
|
216
|
+
ref: handleAnchorRef,
|
|
217
|
+
...nameOrDescProps
|
|
218
|
+
}),
|
|
219
|
+
renderTooltip(open, ()=>anchorRef.current, tooltipId)
|
|
220
|
+
]
|
|
221
|
+
});
|
|
222
|
+
};
|
|
223
|
+
TooltipTrigger.displayName = 'SuiTooltipTrigger';
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
// extracted by css-extract-rspack-plugin
|
|
230
|
+
/* export default */ var TooltipView = ({"sui-tooltip-view-root":"sui-tooltip-view-root","sui-tooltip-view-disable-interactions":"sui-tooltip-view-disable-interactions","sui-tooltip-trigger-wrapper":"sui-tooltip-trigger-wrapper","sui-tooltip-view-paper":"sui-tooltip-view-paper","sui-tooltip-view-paper-content":"sui-tooltip-view-paper-content","sui-tooltip-view-paper-content-medium":"sui-tooltip-view-paper-content-medium","sui-tooltip-view-icon":"sui-tooltip-view-icon","sui-tooltip-view-content":"sui-tooltip-view-content","sui-tooltip-view-neutral":"sui-tooltip-view-neutral","sui-tooltip-view-success":"sui-tooltip-view-success","sui-tooltip-view-danger":"sui-tooltip-view-danger","sui-tooltip-view-inverted":"sui-tooltip-view-inverted","sui-tooltip-view-force-hide":"sui-tooltip-view-force-hide"});
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
const TooltipView_TooltipView = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
240
|
+
const { className, icon, size = 'small', classes, children, placement = 'bottom', PopperProps, color = 'neutral', anchorEl, motionProps, tooltipForceHide = false, disableInteractions = true, PopperPaperProps: popperPaperPropsProp } = props;
|
|
241
|
+
const prefersReducedMotion = usePrefersReducedMotion();
|
|
242
|
+
const cls = useClasses('tooltip-view', classes, className);
|
|
243
|
+
const padding = PopperProps?.padding;
|
|
244
|
+
const popperPadding = typeof padding === 'object' ? {
|
|
245
|
+
top: padding.top ?? 16,
|
|
246
|
+
right: padding.right ?? 16,
|
|
247
|
+
bottom: padding.bottom ?? 16,
|
|
248
|
+
left: padding.left ?? 16
|
|
249
|
+
} : padding ?? 16;
|
|
250
|
+
return /*#__PURE__*/ jsx(Popper, {
|
|
251
|
+
role: "tooltip",
|
|
252
|
+
placement: placement,
|
|
253
|
+
offset: 4,
|
|
254
|
+
...PopperProps,
|
|
255
|
+
padding: popperPadding,
|
|
256
|
+
className: cls('root', {
|
|
257
|
+
'force-hide': tooltipForceHide,
|
|
258
|
+
'disable-interactions': disableInteractions
|
|
259
|
+
}),
|
|
260
|
+
anchorEl: anchorEl,
|
|
261
|
+
arrowHeight: 6,
|
|
262
|
+
arrowPadding: 8,
|
|
263
|
+
ref: ref,
|
|
264
|
+
children: ({ arrowRef, arrowStyle })=>/*#__PURE__*/ jsxs(PopperPaper_PopperPaper, {
|
|
265
|
+
...motionProps ?? getFade({
|
|
266
|
+
prefersReducedMotion
|
|
267
|
+
}),
|
|
268
|
+
...combineProps({
|
|
269
|
+
arrowRef,
|
|
270
|
+
arrowStyle,
|
|
271
|
+
classes: {
|
|
272
|
+
root: cls('paper', color),
|
|
273
|
+
content: cls('paper-content', `paper-content-${size}`)
|
|
274
|
+
}
|
|
275
|
+
}, popperPaperPropsProp),
|
|
276
|
+
children: [
|
|
277
|
+
icon && /*#__PURE__*/ jsx(Icon_Icon, {
|
|
278
|
+
symbol: icon,
|
|
279
|
+
size: "small",
|
|
280
|
+
className: cls('icon')
|
|
281
|
+
}),
|
|
282
|
+
/*#__PURE__*/ jsx("div", {
|
|
283
|
+
className: cls('content', `content-${size}`),
|
|
284
|
+
children: children
|
|
285
|
+
})
|
|
286
|
+
]
|
|
287
|
+
})
|
|
288
|
+
});
|
|
289
|
+
});
|
|
290
|
+
TooltipView_TooltipView.displayName = 'SuiTooltipView';
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
const Tooltip = /*#__PURE__*/ forwardRef((inProps, ref)=>{
|
|
300
|
+
const props = useThemeProps({
|
|
301
|
+
props: inProps,
|
|
302
|
+
name: 'Tooltip'
|
|
303
|
+
});
|
|
304
|
+
const { children, open: openProp, delay, onOpenStateChange, title, disableFocusListener, disableBackdropAnimation, triggerWhenDisabled, triggerWrapperProps, PopperProps, describeChild = false, ...rest } = props;
|
|
305
|
+
const renderTooltip = (open, getAnchorEl, tooltipId)=>{
|
|
306
|
+
// hides '', null/undefined, false, NaN)
|
|
307
|
+
const effectiveOpen = open && !(!title && title !== 0);
|
|
308
|
+
const content = effectiveOpen ? /*#__PURE__*/ jsx(TooltipView_TooltipView, {
|
|
309
|
+
disableInteractions: openProp === undefined,
|
|
310
|
+
...rest,
|
|
311
|
+
PopperProps: {
|
|
312
|
+
...PopperProps,
|
|
313
|
+
id: tooltipId
|
|
314
|
+
},
|
|
315
|
+
anchorEl: getAnchorEl,
|
|
316
|
+
ref: ref,
|
|
317
|
+
children: title
|
|
318
|
+
}) : null;
|
|
319
|
+
return disableBackdropAnimation ? /*#__PURE__*/ jsx(Fragment, {
|
|
320
|
+
children: content
|
|
321
|
+
}) : /*#__PURE__*/ jsx(AnimatePresence, {
|
|
322
|
+
children: content
|
|
323
|
+
});
|
|
324
|
+
};
|
|
325
|
+
return /*#__PURE__*/ jsx(TooltipTrigger, {
|
|
326
|
+
disableFocusListener: disableFocusListener,
|
|
327
|
+
open: openProp,
|
|
328
|
+
delay: delay,
|
|
329
|
+
onOpenStateChange: onOpenStateChange,
|
|
330
|
+
renderTooltip: renderTooltip,
|
|
331
|
+
triggerWhenDisabled: triggerWhenDisabled,
|
|
332
|
+
triggerWrapperProps: triggerWrapperProps,
|
|
333
|
+
tooltipId: PopperProps?.id,
|
|
334
|
+
title: title,
|
|
335
|
+
describeChild: describeChild,
|
|
336
|
+
children: children
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
Tooltip.displayName = 'SuiTooltip';
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
function withTooltip(Component) {
|
|
348
|
+
return /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
349
|
+
const { TooltipProps, ...rest } = props;
|
|
350
|
+
const content = /*#__PURE__*/ jsx(Component, {
|
|
351
|
+
...rest,
|
|
352
|
+
ref: ref
|
|
353
|
+
});
|
|
354
|
+
if (!TooltipProps) return content;
|
|
355
|
+
return /*#__PURE__*/ jsx(Tooltip, {
|
|
356
|
+
...TooltipProps,
|
|
357
|
+
children: content
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
export { Tooltip, TooltipTrigger, TooltipView as tooltipViewStyle, TooltipView_TooltipView as TooltipView, withTooltip };
|
package/chunks/5047.js
ADDED
package/chunks/6335.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useWindowContext } from "@ringcentral/spring-base";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
function useAnimationFrame() {
|
|
9
|
+
const { externalWindow, globalThis: contextGlobal } = useWindowContext();
|
|
10
|
+
return useMemo(()=>{
|
|
11
|
+
const contextWindow = externalWindow ?? contextGlobal;
|
|
12
|
+
return {
|
|
13
|
+
requestAnimationFrame: (callback)=>contextWindow.requestAnimationFrame(callback),
|
|
14
|
+
cancelAnimationFrame: (handle)=>contextWindow.cancelAnimationFrame(handle)
|
|
15
|
+
};
|
|
16
|
+
}, [
|
|
17
|
+
externalWindow,
|
|
18
|
+
contextGlobal
|
|
19
|
+
]);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
export { useAnimationFrame };
|
package/chunks/7279.js
ADDED
package/chunks/8011.js
ADDED
package/chunks/8307.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cloneElement, forwardRef, useMemo } from "react";
|
|
3
|
+
import { useClasses } from "@ringcentral/spring-base";
|
|
4
|
+
import { useThemeProps } from "@ringcentral/spring-theme";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
// extracted by css-extract-rspack-plugin
|
|
11
|
+
/* export default */ var Icon = ({"sui-icon-root":"sui-icon-root","sui-icon-svg":"sui-icon-svg","sui-icon-xsmall":"sui-icon-xsmall","sui-icon-small":"sui-icon-small","sui-icon-medium":"sui-icon-medium","sui-icon-large":"sui-icon-large","sui-icon-xlarge":"sui-icon-xlarge","sui-icon-xxlarge":"sui-icon-xxlarge","sui-icon-xxxlarge":"sui-icon-xxxlarge"});
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const Icon_Icon = /*#__PURE__*/ forwardRef((inProps, ref)=>{
|
|
18
|
+
const props = useThemeProps({
|
|
19
|
+
props: inProps,
|
|
20
|
+
name: 'Icon'
|
|
21
|
+
});
|
|
22
|
+
const { size = 'medium', symbol, children: childrenProp, className, classes, ...rest } = props;
|
|
23
|
+
const cls = useClasses('icon', classes, className);
|
|
24
|
+
const svgClassName = cls('svg');
|
|
25
|
+
const children = useMemo(()=>{
|
|
26
|
+
if (symbol) {
|
|
27
|
+
const Comp = symbol;
|
|
28
|
+
return /*#__PURE__*/ jsx(Comp, {
|
|
29
|
+
className: svgClassName
|
|
30
|
+
});
|
|
31
|
+
} else if (childrenProp) {
|
|
32
|
+
return /*#__PURE__*/ cloneElement(childrenProp, {
|
|
33
|
+
className: svgClassName
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}, [
|
|
38
|
+
childrenProp,
|
|
39
|
+
svgClassName,
|
|
40
|
+
symbol
|
|
41
|
+
]);
|
|
42
|
+
return /*#__PURE__*/ jsx("span", {
|
|
43
|
+
className: cls('root', size),
|
|
44
|
+
...rest,
|
|
45
|
+
ref: ref,
|
|
46
|
+
children: children
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
Icon_Icon.displayName = 'SuiIcon';
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
export { Icon as iconStyle, Icon_Icon as Icon };
|
package/chunks/8467.js
ADDED
package/chunks/8809.js
ADDED
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
import { createContext, useContext } from
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
|
|
3
|
+
|
|
2
4
|
|
|
3
5
|
const RadioGroupContext = createContext({});
|
|
4
6
|
function callbacksInSeries(...callbacks) {
|
|
5
|
-
return function
|
|
6
|
-
callbacks.forEach((cb)
|
|
7
|
+
return function(...params) {
|
|
8
|
+
callbacks.forEach((cb)=>cb?.(...params));
|
|
7
9
|
};
|
|
8
10
|
}
|
|
9
|
-
function useRadioGroup({ name, value, checked, onChange
|
|
11
|
+
function useRadioGroup({ name, value, checked, onChange }) {
|
|
10
12
|
const context = useContext(RadioGroupContext);
|
|
11
13
|
if (context.onChange) {
|
|
12
14
|
name = context.name ?? name;
|
|
13
15
|
checked = value === context.value;
|
|
14
16
|
onChange = callbacksInSeries(onChange, context.onChange);
|
|
15
17
|
}
|
|
16
|
-
return {
|
|
18
|
+
return {
|
|
19
|
+
name,
|
|
20
|
+
checked,
|
|
21
|
+
onChange
|
|
22
|
+
};
|
|
17
23
|
}
|
|
18
24
|
|
|
19
|
-
export { RadioGroupContext
|
|
25
|
+
export { RadioGroupContext, callbacksInSeries, useRadioGroup };
|