@ringcentral/spring-ui 1.11.2 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Accordion.js +90 -34
- package/AccordionHeader.js +72 -20
- package/Alert.js +120 -28
- package/Animation.js +2 -45
- package/Announcement.js +46 -35
- package/Autocomplete.js +1011 -580
- package/Avatar.js +134 -73
- package/AvatarGroup.js +50 -7
- package/Backdrop.js +45 -7
- package/Badge.js +77 -15
- package/Block.js +34 -12
- package/BlockHeader.js +55 -11
- package/BottomNavigation.js +181 -65
- package/BottomNavigationItem.js +93 -30
- package/Button.js +160 -24
- package/CallButton.js +53 -31
- package/Checkbox.js +88 -26
- package/Chip.js +126 -26
- package/CircularProgressIndicator.js +80 -8
- package/ClickAwayListener.js +4 -1
- package/ComponentsProps.js +1 -0
- package/DatePicker.js +611 -190
- package/DateUtilsContext.js +43 -25
- package/Dialer.js +576 -250
- package/Dialog.js +100 -45
- package/Divider.js +43 -7
- package/DragHandle.js +32 -6
- package/Drawer.js +117 -19
- package/Dropdown.js +154 -74
- package/EmptyState.js +63 -11
- package/FabButton.js +51 -17
- package/FocusTrap.js +109 -12
- package/FormField.js +106 -8
- package/FormLabel.js +81 -7
- package/Icon.js +1 -8
- package/IconButton.js +142 -26
- package/IconButtonGroup.js +35 -12
- package/InlineEditable.js +98 -44
- package/LinearProgressIndicator.js +73 -24
- package/Link.js +40 -11
- package/List.js +54 -9
- package/ListItem.js +152 -23
- package/ListItemText.js +44 -16
- package/ListNavigation.js +272 -20
- package/Menu.js +139 -23
- package/MenuActions.js +37 -12
- package/MenuDivider.js +34 -8
- package/MenuFooter.js +36 -12
- package/MenuHeader.js +54 -15
- package/MenuItem.js +402 -33
- package/MenuItemText.js +51 -8
- package/MenuList.js +87 -34
- package/Modal.js +345 -16
- package/NestedMenuContext.js +183 -11
- package/Option.js +32 -34
- package/Overlap.js +54 -7
- package/PageHeader.js +62 -24
- package/PickerTextField.js +156 -33
- package/Popover.js +262 -21
- package/Popper.js +130 -77
- package/PopperPaper.js +54 -8
- package/Portal.js +6 -1
- package/Radio.js +65 -21
- package/RadioGroup.js +56 -17
- package/Rating.js +223 -87
- package/Select.js +387 -41
- package/SingleFilter.js +148 -77
- package/Skeleton.js +68 -17
- package/Slider.js +168 -69
- package/Snackbar.js +122 -59
- package/SortableList.js +32 -12
- package/SortableListDndContext.js +69 -22
- package/SortableListItem.js +92 -47
- package/SortableVirtualizedList.js +52 -28
- package/SplitButton.js +124 -86
- package/Squircle.js +4 -7
- package/StatusIndicator.js +51 -9
- package/Step.js +63 -38
- package/StepButton.js +51 -23
- package/StepConnector.js +48 -8
- package/StepContent.js +68 -25
- package/StepIcon.js +90 -9
- package/StepLabel.js +90 -14
- package/Stepper.js +65 -23
- package/SubMenu.js +203 -99
- package/SwipeableDrawer.js +439 -194
- package/Switch.js +70 -23
- package/Tab.js +120 -57
- package/TabContext.js +59 -15
- package/TabPanel.js +40 -13
- package/Table.js +60 -17
- package/TableBody.js +42 -12
- package/TableCell.js +84 -50
- package/TableContainer.js +32 -10
- package/TableFooter.js +38 -10
- package/TableHead.js +49 -15
- package/TablePagination.js +153 -77
- package/TableRow.js +60 -21
- package/Tabs.js +593 -268
- package/Tag.js +51 -16
- package/Text.js +68 -37
- package/TextField.js +209 -29
- package/Textarea.js +51 -40
- package/TimePicker.js +490 -230
- package/Tooltip.js +48 -23
- package/Tray.js +237 -13
- package/TrayMenu.js +62 -41
- package/VirtualizedList.js +208 -109
- package/VirtualizedMenu.js +359 -29
- package/VisuallyHidden.js +29 -6
- package/chunks/1250.js +98 -0
- package/chunks/1294.js +126 -0
- package/chunks/2956.js +18 -0
- package/chunks/4476.js +460 -0
- package/chunks/4491.js +10 -0
- package/chunks/4535.js +364 -0
- package/chunks/5047.js +3 -0
- package/chunks/6335.js +24 -0
- package/chunks/7279.js +10 -0
- package/chunks/8011.js +8 -0
- package/chunks/8307.js +56 -0
- package/chunks/8467.js +8 -0
- package/chunks/8809.js +8 -0
- package/chunks/{RadioGroup.context.js → 9551.js} +12 -6
- package/chunks/987.js +8 -0
- package/index.css +2624 -2416
- package/index.js +245 -193
- package/internal/utils/index.d.ts +1 -0
- package/internal/utils/setRef.d.ts +2 -0
- package/package.json +8 -8
- package/src/Alert/Alert.type.d.ts +2 -1
- package/src/Animation/components/Fade/Fade.d.ts +4 -2
- package/src/Animation/components/Grow/Grow.d.ts +4 -2
- package/src/Animation/components/ShowHideEye/ShowHideEye.d.ts +1 -1
- package/src/Animation/components/SlideIn/SlideIn.d.ts +4 -2
- package/src/Animation/components/SlideIn/getSlideIn.d.ts +1 -1
- package/src/Animation/hooks/useMotionSafeTransition/useMotionSafeTransition.d.ts +2 -0
- package/src/Autocomplete/SuggestionList/SuggestionList.d.ts +1 -1
- package/src/Autocomplete/useAutocomplete.d.ts +18 -18
- package/src/Autocomplete/useAutocompleteTag.d.ts +18 -18
- package/src/Badge/Badge.d.ts +2 -1
- package/src/Button/Button.classes.d.ts +1 -1
- package/src/ComponentsProps.d.ts +111 -110
- package/src/DatePicker/DatePickerDataAttributes.d.ts +11 -0
- package/src/DatePicker/utils/DatePickerAriaLabelUtils.d.ts +2 -1
- package/src/DatePicker/utils/DatePickerUtils.d.ts +1 -1
- package/src/Dialer/DialDelete/DialDelete.d.ts +2 -2
- package/src/Dialer/DialPad/DialPad.d.ts +2 -2
- package/src/Dialer/Dialer.d.ts +4 -2
- package/src/Dropdown/Dropdown.type.d.ts +2 -2
- package/src/InlineEditable/InlineEditable.type.d.ts +2 -1
- package/src/ListNavigation/useListNavigation.d.ts +3 -3
- package/src/MenuActions/MenuActions.d.ts +2 -2
- package/src/MenuItem/MenuItem.type.d.ts +1 -0
- package/src/MenuItem/useMenuItem.d.ts +1 -1
- package/src/MenuItem/useVirtualizedMenuItem.d.ts +1 -1
- package/src/MenuList/MenuList.type.d.ts +1 -1
- package/src/MenuList/MenuListContext.d.ts +2 -3
- package/src/Modal/Modal.type.d.ts +1 -0
- package/src/NestedMenuContext/MenuOverlayGroupContext.d.ts +2 -2
- package/src/Popover/Popover.classes.d.ts +1 -1
- package/src/Popover/Popover.internal.d.ts +8 -0
- package/src/Popover/Popover.type.d.ts +1 -0
- package/src/Popper/Popper.type.d.ts +10 -7
- package/src/Rating/utils.d.ts +3 -2
- package/src/Select/Select.type.d.ts +7 -5
- package/src/Slider/Slider.d.ts +2 -2
- package/src/Slider/SliderThumb.d.ts +2 -1
- package/src/Squircle/Squircle.d.ts +1 -1
- package/src/StatusIndicator/StatusIndicator.d.ts +2 -1
- package/src/SubMenu/PopperMenu.type.d.ts +4 -1
- package/src/Table/Table.type.d.ts +3 -0
- package/src/Table/TableContext.d.ts +3 -0
- package/src/Table/TableRowContext.d.ts +7 -0
- package/src/Table/index.d.ts +1 -0
- package/src/TableCell/TableCell.classes.d.ts +1 -1
- package/src/TableFooter/TableFooter.classes.d.ts +1 -1
- package/src/TableFooter/TableFooter.type.d.ts +1 -0
- package/src/TableHead/TableHead.classes.d.ts +1 -1
- package/src/TableHead/TableHead.type.d.ts +1 -0
- package/src/TableRow/TableRow.type.d.ts +2 -0
- package/chunks/AccordionContext.js +0 -6
- package/chunks/Alert.js +0 -48
- package/chunks/AvatarGroup.js +0 -22
- package/chunks/Backdrop.js +0 -18
- package/chunks/Badge.js +0 -32
- package/chunks/BottomNavigationItem.js +0 -36
- package/chunks/Button.js +0 -88
- package/chunks/Chip.js +0 -73
- package/chunks/CircularProgressIndicator.js +0 -36
- package/chunks/Divider.js +0 -19
- package/chunks/DragHandle.js +0 -11
- package/chunks/Drawer.js +0 -32
- package/chunks/ExpandCollapseCaret.js +0 -24
- package/chunks/FormLabel.js +0 -27
- package/chunks/Icon.js +0 -25
- package/chunks/IconButtonLabel.js +0 -68
- package/chunks/List.js +0 -22
- package/chunks/ListItem.js +0 -83
- package/chunks/Menu.js +0 -61
- package/chunks/MenuDivider.js +0 -14
- package/chunks/MenuItemText.js +0 -17
- package/chunks/MenuList.js +0 -46
- package/chunks/Modal.js +0 -212
- package/chunks/Overlap.js +0 -25
- package/chunks/PickerTextField.js +0 -85
- package/chunks/Popover.js +0 -53
- package/chunks/PopperPaper.js +0 -15
- package/chunks/Select.js +0 -220
- package/chunks/ShowHideEye.js +0 -56
- package/chunks/SlideIn.js +0 -19
- package/chunks/SortableArrow.js +0 -73
- package/chunks/Squircle.js +0 -31
- package/chunks/StatusIndicator.js +0 -20
- package/chunks/StepConnector.js +0 -21
- package/chunks/StepIcon.js +0 -43
- package/chunks/StepLabel.js +0 -29
- package/chunks/StepperContext.js +0 -9
- package/chunks/TableContext.js +0 -6
- package/chunks/Tablelvl2Context.js +0 -6
- package/chunks/TabsContext.js +0 -6
- package/chunks/TextField.js +0 -110
- package/chunks/Tooltip.js +0 -217
- package/chunks/VirtualizedMenu.js +0 -164
- package/chunks/VisuallyHidden.js +0 -12
- package/chunks/getFade.js +0 -27
- package/chunks/getGrow.js +0 -70
- package/chunks/getSlideIn.js +0 -30
- package/chunks/hasContent.js +0 -3
- package/chunks/useAnimationFrame.js +0 -15
- package/chunks/useFocusTrapStack.js +0 -36
- package/chunks/useHelperTextId.js +0 -22
- package/chunks/useListNavigation.js +0 -199
- package/chunks/useMenuItemSelect.js +0 -273
- package/chunks/useMotionSafeTransition.js +0 -9
- package/chunks/useNestedMenuItem.js +0 -27
- package/chunks/useNestedParentMenu.js +0 -113
- package/chunks/usePrefersReducedMotion.js +0 -36
- package/chunks/useTooltipForceHide.js +0 -27
- package/chunks/useTrayNavigate.js +0 -150
- package/chunks/withTooltip.js +0 -15
package/chunks/ShowHideEye.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { useClasses } from '@ringcentral/spring-base';
|
|
3
|
-
import { motionTransition } from '@ringcentral/spring-theme';
|
|
4
|
-
import { motion } from 'framer-motion';
|
|
5
|
-
import { I as Icon } from './Icon.js';
|
|
6
|
-
import 'react';
|
|
7
|
-
import { u as useMotionSafeTransition } from './useMotionSafeTransition.js';
|
|
8
|
-
|
|
9
|
-
const topEyelidVariants = {
|
|
10
|
-
show: {
|
|
11
|
-
d: 'M 17.5 12.25 C 16.75 10.25 13.8 7 10 7 C 6.2 7 3.25 10.25 2.5 12.25',
|
|
12
|
-
},
|
|
13
|
-
hide: {
|
|
14
|
-
d: 'M 17.5 6.75 C 16.75 8.75 14 12.2 10 12.2 C 6 12.2 3.25 8.75 2.5 6.75',
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
const bottomEyelidVariants = {
|
|
18
|
-
show: {
|
|
19
|
-
d: 'M 17.5 11.75 C 16.75 13.75 13.8 17 10 17 C 6.2 17 3.25 13.75 2.5 11.75',
|
|
20
|
-
},
|
|
21
|
-
hide: {
|
|
22
|
-
d: 'M 17.5 6.75 C 16.75 8.75 14 12.2 10 12.2 C 6 12.2 3.25 8.75 2.5 6.75',
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
-
const eyelashVariants = {
|
|
26
|
-
show: {
|
|
27
|
-
d: 'M 10 4.5 L 10 1.5 M 4 6.35 L 2.5 3.7 M 16 6.35 L 17.5 3.7',
|
|
28
|
-
},
|
|
29
|
-
hide: {
|
|
30
|
-
d: 'M 10 15.5 L 10 18.5 M 16 13.75 L 17.5 16.4 M 4 13.75 L 2.5 16.4',
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
const ShowHideEye = (props) => {
|
|
34
|
-
const { classes, size = 'medium', hide = false, className, ...rest } = props;
|
|
35
|
-
const cls = useClasses('show-hide-eye', classes, className);
|
|
36
|
-
const transition = useMotionSafeTransition(motionTransition['spring-01-fast']);
|
|
37
|
-
const pupilShowTransition = useMotionSafeTransition({
|
|
38
|
-
delay: 0.05,
|
|
39
|
-
});
|
|
40
|
-
const pupilHideTransition = useMotionSafeTransition({
|
|
41
|
-
duration: 0.1,
|
|
42
|
-
});
|
|
43
|
-
const pupilVariants = {
|
|
44
|
-
show: {
|
|
45
|
-
ry: 3.75,
|
|
46
|
-
transition: pupilShowTransition,
|
|
47
|
-
},
|
|
48
|
-
hide: {
|
|
49
|
-
ry: 0,
|
|
50
|
-
transition: pupilHideTransition,
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
return (jsx(Icon, { ...rest, size: size, className: cls('root'), children: jsxs(motion.svg, { xmlns: "http://www.w3.org/2000/svg", viewBox: '0 0 20 20', animate: hide ? 'hide' : 'show', transition: transition, children: [jsx(motion.path, { initial: false, stroke: "currentColor", strokeWidth: 1.5, strokeMiterlimit: 1.5, strokeLinejoin: 'miter', strokeLinecap: 'butt', variants: topEyelidVariants, transition: transition, fill: "transparent" }), jsx(motion.path, { initial: false, stroke: "currentColor", strokeWidth: 1.5, strokeMiterlimit: 1.5, strokeLinejoin: 'miter', strokeLinecap: 'butt', variants: bottomEyelidVariants, transition: transition, fill: "transparent" }), jsx(motion.ellipse, { initial: false, cx: 10, cy: 10.5, rx: 3.75, fill: "currentColor", variants: pupilVariants }), jsx(motion.path, { initial: false, stroke: "currentColor", strokeWidth: 1.5, strokeMiterlimit: 1.5, strokeLinejoin: 'miter', strokeLinecap: 'butt', variants: eyelashVariants, transition: transition, fill: "transparent" })] }) }));
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
export { ShowHideEye as S };
|
package/chunks/SlideIn.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { motion } from 'framer-motion';
|
|
3
|
-
import { u as usePrefersReducedMotion } from './usePrefersReducedMotion.js';
|
|
4
|
-
import '@ringcentral/spring-theme';
|
|
5
|
-
import { g as getSlideIn } from './getSlideIn.js';
|
|
6
|
-
|
|
7
|
-
const SlideIn = (props) => {
|
|
8
|
-
const { toggle, toggleOnTransition, toggleOffTransition, children, from = 'right', ...rest } = props;
|
|
9
|
-
const prefersReducedMotion = usePrefersReducedMotion();
|
|
10
|
-
return (jsx(motion.div, { ...getSlideIn({
|
|
11
|
-
toggle,
|
|
12
|
-
from,
|
|
13
|
-
prefersReducedMotion,
|
|
14
|
-
toggleOnTransition,
|
|
15
|
-
toggleOffTransition,
|
|
16
|
-
}), ...rest, children: children }));
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export { SlideIn as S };
|
package/chunks/SortableArrow.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { useClasses } from '@ringcentral/spring-base';
|
|
3
|
-
import { motion } from 'framer-motion';
|
|
4
|
-
import { motionTransition } from '@ringcentral/spring-theme';
|
|
5
|
-
import { I as Icon } from './Icon.js';
|
|
6
|
-
import 'react';
|
|
7
|
-
import { u as useMotionSafeTransition } from './useMotionSafeTransition.js';
|
|
8
|
-
|
|
9
|
-
const topCaretVariants = {
|
|
10
|
-
initial: {
|
|
11
|
-
d: 'M 5 7.5 L 10 2.5 L 15 7.5',
|
|
12
|
-
opacity: 1,
|
|
13
|
-
},
|
|
14
|
-
asc: {
|
|
15
|
-
d: 'M 4.75 9.5 L 10 4 L 15.25 9.5',
|
|
16
|
-
opacity: 1,
|
|
17
|
-
},
|
|
18
|
-
desc: {
|
|
19
|
-
d: 'M 10 9.5 L 10 4.5 L 10 9.5',
|
|
20
|
-
opacity: 0,
|
|
21
|
-
transition: {
|
|
22
|
-
ease: 'easeOut',
|
|
23
|
-
duration: 0.15,
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
const topLineVariants = {
|
|
28
|
-
initial: {
|
|
29
|
-
d: 'M 10 2.5 L 10 2.5',
|
|
30
|
-
opacity: 0,
|
|
31
|
-
},
|
|
32
|
-
asc: {
|
|
33
|
-
d: 'M 10 4.5 L 10 15.5',
|
|
34
|
-
opacity: 1,
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
const bottomLineVariants = {
|
|
38
|
-
initial: {
|
|
39
|
-
d: 'M 10 17.5 L 10 17.5',
|
|
40
|
-
opacity: 0,
|
|
41
|
-
},
|
|
42
|
-
desc: {
|
|
43
|
-
d: 'M 10 15.5 L 10 4.5',
|
|
44
|
-
opacity: 1,
|
|
45
|
-
},
|
|
46
|
-
};
|
|
47
|
-
const bottomCaretVariants = {
|
|
48
|
-
initial: {
|
|
49
|
-
d: 'M 5 12.5 L 10 17.5 L 15 12.5',
|
|
50
|
-
opacity: 1,
|
|
51
|
-
},
|
|
52
|
-
asc: {
|
|
53
|
-
d: 'M 10 10.5 L 10 15.5 L 10 10.5',
|
|
54
|
-
opacity: 0,
|
|
55
|
-
transition: {
|
|
56
|
-
ease: 'easeOut',
|
|
57
|
-
duration: 0.15,
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
desc: {
|
|
61
|
-
d: 'M 4.75 10.5 L 10 16 L 15.25 10.5',
|
|
62
|
-
opacity: 1,
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
const SortableArrow = (props) => {
|
|
66
|
-
const { classes, size = 'medium', direction = false, className, ...rest } = props;
|
|
67
|
-
const cls = useClasses('sortable-arrow', classes, className);
|
|
68
|
-
const caretTransition = useMotionSafeTransition(motionTransition['spring-01-fast']);
|
|
69
|
-
const lineTransition = useMotionSafeTransition(motionTransition['neutral-01-fast']);
|
|
70
|
-
return (jsx(Icon, { ...rest, size: size, className: cls('root'), children: jsxs(motion.svg, { xmlns: "http://www.w3.org/2000/svg", viewBox: '0 0 20 20', animate: direction || 'initial', children: [jsx(motion.path, { initial: false, stroke: "currentColor", strokeWidth: 1.5, strokeMiterlimit: 1.5, strokeLinejoin: 'miter', variants: topCaretVariants, transition: caretTransition, fill: "transparent" }), direction !== 'desc' && (jsx(motion.path, { initial: false, stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: 'square', variants: topLineVariants, transition: lineTransition, fill: "transparent" })), direction !== 'asc' && (jsx(motion.path, { initial: false, stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: 'square', variants: bottomLineVariants, transition: lineTransition, fill: "transparent" })), jsx(motion.path, { initial: false, stroke: "currentColor", strokeWidth: 1.5, strokeMiterlimit: 1.5, strokeLinejoin: 'miter', variants: bottomCaretVariants, transition: caretTransition, fill: "transparent" })] }) }));
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export { SortableArrow as S };
|
package/chunks/Squircle.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import React, { forwardRef, isValidElement, cloneElement } from 'react';
|
|
3
|
-
import { useClasses, useId } from '@ringcentral/spring-base';
|
|
4
|
-
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
5
|
-
|
|
6
|
-
const SQUIRCLE_PATH = 'M 0.5 0 C 0.879 0 1 0.121 1 0.5 C 1 0.879 0.879 1 0.5 1 C 0.121 1 0 0.879 0 0.5 C 0 0.121 0.121 0 0.5 0 Z';
|
|
7
|
-
const Squircle = forwardRef((inProps, ref) => {
|
|
8
|
-
const props = useThemeProps({ props: inProps, name: 'Squircle' });
|
|
9
|
-
const { component = 'div', focusVisible, active, children: childrenProp, className, classes, interactive = true, fillShape: fillShapeProp = false, ...rest } = props;
|
|
10
|
-
const children = React.Children.toArray(childrenProp);
|
|
11
|
-
const firstChild = children[0];
|
|
12
|
-
const fillShape = fillShapeProp &&
|
|
13
|
-
firstChild &&
|
|
14
|
-
isValidElement(firstChild);
|
|
15
|
-
const cls = useClasses('squircle', classes, className);
|
|
16
|
-
const clipId = useId('sui-squircle-clip', true);
|
|
17
|
-
const showFocusRing = interactive && focusVisible;
|
|
18
|
-
const Root = component;
|
|
19
|
-
return (jsxs(Root, { className: cls('root', { active, interactive }), ...rest, ref: ref, children: [jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "0", height: "0", viewBox: "0 0 1 1", children: jsx("defs", { children: jsx("clipPath", { id: clipId, clipPathUnits: "objectBoundingBox", children: jsx("path", { d: SQUIRCLE_PATH }) }) }) }), !fillShape && (jsx("svg", { className: cls('content'), xmlns: "http://www.w3.org/2000/svg", viewBox: '0 0 1 1', children: jsx("path", { clipPath: `url(#${clipId})`, d: SQUIRCLE_PATH, vectorEffect: "non-scaling-stroke" }) })), showFocusRing && (jsx("svg", { className: cls('ring'), xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 1 1", overflow: "visible", children: jsx("path", { d: SQUIRCLE_PATH, fillOpacity: 0, vectorEffect: "non-scaling-stroke" }) })), fillShape
|
|
20
|
-
? cloneElement(firstChild, {
|
|
21
|
-
style: {
|
|
22
|
-
...firstChild.props.style,
|
|
23
|
-
with: '100%',
|
|
24
|
-
height: '100%',
|
|
25
|
-
clipPath: `url(#${clipId})`,
|
|
26
|
-
},
|
|
27
|
-
})
|
|
28
|
-
: children] }));
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
export { Squircle as S };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useClasses } from '@ringcentral/spring-base';
|
|
3
|
-
import { MinusBoldMd, CheckBoldSm } from '@ringcentral/spring-icon';
|
|
4
|
-
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
5
|
-
import { I as Icon } from './Icon.js';
|
|
6
|
-
|
|
7
|
-
const IconSizeMap = {
|
|
8
|
-
large: 'small',
|
|
9
|
-
medium: 'xsmall',
|
|
10
|
-
small: 'xsmall',
|
|
11
|
-
};
|
|
12
|
-
const StatusIndicator = (inProps) => {
|
|
13
|
-
const props = useThemeProps({ props: inProps, name: 'StatusIndicator' });
|
|
14
|
-
const { classes, className, size = 'medium', variant = 'available', ...rest } = props;
|
|
15
|
-
const cls = useClasses('status-indicator', classes, className);
|
|
16
|
-
return (jsxs("div", { className: cls('root', size, variant), ...rest, children: [variant === 'dnd' && (jsx(Icon, { symbol: MinusBoldMd, size: IconSizeMap[size] })), variant === 'available' && (jsx(Icon, { symbol: CheckBoldSm, size: IconSizeMap[size] }))] }));
|
|
17
|
-
};
|
|
18
|
-
StatusIndicator.displayName = 'SuiStatusIndicator';
|
|
19
|
-
|
|
20
|
-
export { StatusIndicator as S };
|
package/chunks/StepConnector.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
|
-
import { useClasses } from '@ringcentral/spring-base';
|
|
4
|
-
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
5
|
-
import { b as useStepperContext, u as useStepContext } from './StepperContext.js';
|
|
6
|
-
|
|
7
|
-
const StepConnector = forwardRef((inProps, ref) => {
|
|
8
|
-
const props = useThemeProps({ props: inProps, name: 'StepConnector' });
|
|
9
|
-
const { classes, className, children, ...rest } = props;
|
|
10
|
-
const cls = useClasses('step-connector', classes, className);
|
|
11
|
-
const { orientation = 'horizontal' } = useStepperContext();
|
|
12
|
-
const { active, disabled, completed } = useStepContext();
|
|
13
|
-
return (jsx("div", { "aria-hidden": true, className: cls('root', orientation, {
|
|
14
|
-
active,
|
|
15
|
-
completed,
|
|
16
|
-
disabled,
|
|
17
|
-
}), ...rest, ref: ref, children: jsx("span", { className: cls('line', `line-${orientation}`) }) }));
|
|
18
|
-
});
|
|
19
|
-
StepConnector.displayName = 'SuiStepConnector';
|
|
20
|
-
|
|
21
|
-
export { StepConnector as S };
|
package/chunks/StepIcon.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
|
-
import { useClasses } from '@ringcentral/spring-base';
|
|
4
|
-
import { AlertFilledMd, AlertMd, CheckBoldMd, CheckMd } from '@ringcentral/spring-icon';
|
|
5
|
-
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
6
|
-
import { I as Icon } from './Icon.js';
|
|
7
|
-
|
|
8
|
-
const StepIcon = forwardRef((inProps, ref) => {
|
|
9
|
-
const props = useThemeProps({ props: inProps, name: 'StepIcon' });
|
|
10
|
-
const { classes, className, children, active = false, completed = false, error = false, disabled = false, variant = 'contained', icon, symbol, ...rest } = props;
|
|
11
|
-
const cls = useClasses('step-icon', classes, className);
|
|
12
|
-
if (symbol) {
|
|
13
|
-
return (jsx("span", { className: cls('root', variant, error && `${variant}-error`, active && `${variant}-current`, {
|
|
14
|
-
current: active,
|
|
15
|
-
completed,
|
|
16
|
-
error,
|
|
17
|
-
disabled,
|
|
18
|
-
}), ...rest, ref: ref, children: jsx(Icon, { className: cls('icon'), size: "xsmall", symbol: symbol }) }));
|
|
19
|
-
}
|
|
20
|
-
if (typeof icon === 'number' || typeof icon === 'string') {
|
|
21
|
-
let content;
|
|
22
|
-
if (error) {
|
|
23
|
-
content = (jsx(Icon, { className: cls('icon'), size: "large", symbol: variant === 'contained' ? AlertFilledMd : AlertMd }));
|
|
24
|
-
}
|
|
25
|
-
else if (completed) {
|
|
26
|
-
content =
|
|
27
|
-
variant === 'contained' ? (jsx(Icon, { className: cls('icon'), size: "xsmall", symbol: CheckBoldMd })) : (jsx(Icon, { className: cls('icon'), size: "large", symbol: CheckMd }));
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
content = (jsx("span", { className: cls('text', active && 'text-current'), children: icon }));
|
|
31
|
-
}
|
|
32
|
-
return (jsx("span", { className: cls('root', variant, error && `${variant}-error`, active && `${variant}-current`, {
|
|
33
|
-
current: active,
|
|
34
|
-
completed,
|
|
35
|
-
error,
|
|
36
|
-
disabled,
|
|
37
|
-
}), ...rest, ref: ref, children: content }));
|
|
38
|
-
}
|
|
39
|
-
return icon;
|
|
40
|
-
});
|
|
41
|
-
StepIcon.displayName = 'SuiStepIcon';
|
|
42
|
-
|
|
43
|
-
export { StepIcon as S };
|
package/chunks/StepLabel.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef } from 'react';
|
|
3
|
-
import { useClasses } from '@ringcentral/spring-base';
|
|
4
|
-
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
5
|
-
import clsx from 'clsx';
|
|
6
|
-
import { b as useStepperContext, u as useStepContext } from './StepperContext.js';
|
|
7
|
-
import { S as StepIcon } from './StepIcon.js';
|
|
8
|
-
|
|
9
|
-
const StepLabel = forwardRef((inProps, ref) => {
|
|
10
|
-
const props = useThemeProps({ props: inProps, name: 'StepLabel' });
|
|
11
|
-
const { classes, className, children, error = false, icon: iconProp, optional, labelProps = {}, StepIconComponent: StepIconComponentProp, StepIconProps, ...rest } = props;
|
|
12
|
-
const cls = useClasses('step-label', classes, className);
|
|
13
|
-
const { orientation = 'horizontal' } = useStepperContext();
|
|
14
|
-
const { active, disabled, completed, icon: iconContext, id, connector, index, last, variant, } = useStepContext();
|
|
15
|
-
const icon = iconProp || iconContext;
|
|
16
|
-
let StepIconComponent = StepIconComponentProp;
|
|
17
|
-
if (icon && !StepIconComponent) {
|
|
18
|
-
StepIconComponent = StepIcon;
|
|
19
|
-
}
|
|
20
|
-
return (jsxs("span", { id: id, className: cls('root', orientation, {
|
|
21
|
-
current: active,
|
|
22
|
-
completed,
|
|
23
|
-
disabled,
|
|
24
|
-
error,
|
|
25
|
-
}), ...rest, ref: ref, children: [index !== 0 ? connector : null, StepIconComponent ? (jsx("span", { className: cls('icon-container', `${orientation}-icon-container`), children: jsx(StepIconComponent, { completed: completed, active: active, error: error, disabled: disabled, icon: icon, variant: variant, ...StepIconProps }) })) : null, jsxs("span", { className: cls('label-container', `${orientation}-label-container`, error && 'error-label-container', { disabled }), children: [children ? (jsx("span", { ...labelProps, className: clsx(cls('label', `${orientation}-label`, active && 'current-label', error && 'error-label', { disabled, completed }), labelProps?.className), children: children })) : null, optional] }), !last ? connector : null] }));
|
|
26
|
-
});
|
|
27
|
-
StepLabel.displayName = 'SuiStepLabel';
|
|
28
|
-
|
|
29
|
-
export { StepLabel as S };
|
package/chunks/StepperContext.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext } from 'react';
|
|
2
|
-
|
|
3
|
-
const StepContext = createContext({});
|
|
4
|
-
const useStepContext = () => useContext(StepContext);
|
|
5
|
-
|
|
6
|
-
const StepperContext = createContext({});
|
|
7
|
-
const useStepperContext = () => useContext(StepperContext);
|
|
8
|
-
|
|
9
|
-
export { StepContext as S, StepperContext as a, useStepperContext as b, useStepContext as u };
|
package/chunks/TableContext.js
DELETED
package/chunks/TabsContext.js
DELETED
package/chunks/TextField.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef, useRef } from 'react';
|
|
3
|
-
import { useInput } from '@mui/base';
|
|
4
|
-
import { useId, useClasses, useControlled, useEventCallback, combineProps, useForkRef } from '@ringcentral/spring-base';
|
|
5
|
-
import { Xmd } from '@ringcentral/spring-icon';
|
|
6
|
-
import { useThemeProps } from '@ringcentral/spring-theme';
|
|
7
|
-
import 'framer-motion';
|
|
8
|
-
import './Icon.js';
|
|
9
|
-
import { S as ShowHideEye } from './ShowHideEye.js';
|
|
10
|
-
import { u as useHelperTextId, F as FormField } from './useHelperTextId.js';
|
|
11
|
-
import { I as IconButton } from './IconButtonLabel.js';
|
|
12
|
-
|
|
13
|
-
const TextFieldComponent = (inProps, ref) => {
|
|
14
|
-
const props = useThemeProps({ props: inProps, name: 'TextField' });
|
|
15
|
-
const { classes, className, clearBtn = true, clearText = 'clear', showCharacterCount = false, useNativeClearBtn = false, size, endAdornment, fullWidth, helperText: helperTextProp, inputProps, label, onClear, placeholder: placeholderProp, RootProps, startAdornment, type, variant = 'outlined', inputComponent: InputComponent = 'input', autoFocus, ClearButtonProps, id: idProp, onKeyDown, onKeyUp, readOnly, onClick, focused, FormHelperTextProps, showMaskValueToggleButton = type === 'password', maskValue: maskValueProps, MaskValueButtonProps, ShowHideEyeIconProps, } = props;
|
|
16
|
-
const placeholder = placeholderProp || ' ';
|
|
17
|
-
const defaultId = useId();
|
|
18
|
-
const id = idProp ?? inputProps?.id ?? defaultId;
|
|
19
|
-
const cls = useClasses('text-field', classes, className);
|
|
20
|
-
const { disabled, required, error, getInputProps } = useInput(props);
|
|
21
|
-
const states = { disabled, required, error, focused };
|
|
22
|
-
const idForHelperText = useHelperTextId({
|
|
23
|
-
helperText: helperTextProp,
|
|
24
|
-
id,
|
|
25
|
-
FormHelperTextProps,
|
|
26
|
-
});
|
|
27
|
-
const widgetProps = getInputProps({
|
|
28
|
-
'aria-describedby': idForHelperText,
|
|
29
|
-
...inputProps,
|
|
30
|
-
placeholder,
|
|
31
|
-
id,
|
|
32
|
-
type,
|
|
33
|
-
});
|
|
34
|
-
const inputRef = useRef();
|
|
35
|
-
const handlerClear = (e) => {
|
|
36
|
-
if (disabled)
|
|
37
|
-
return;
|
|
38
|
-
const el = inputRef.current;
|
|
39
|
-
if (el) {
|
|
40
|
-
onClear?.(e);
|
|
41
|
-
const host = Object.getPrototypeOf(el);
|
|
42
|
-
Object.getOwnPropertyDescriptor(host, 'value')?.set?.call(el, '');
|
|
43
|
-
el.focus();
|
|
44
|
-
el.dispatchEvent(new InputEvent('input', { bubbles: true }));
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
let helperText = helperTextProp;
|
|
48
|
-
if (showCharacterCount &&
|
|
49
|
-
inputProps?.maxLength !== undefined &&
|
|
50
|
-
props.value !== undefined) {
|
|
51
|
-
helperText = (jsxs("div", { className: cls('helper-text'), children: [jsx("span", { children: helperText }), jsxs("span", { children: [props.value?.length ?? 0, "/", inputProps.maxLength] })] }));
|
|
52
|
-
}
|
|
53
|
-
const [maskValue, setMaskValue] = useControlled({
|
|
54
|
-
controlled: maskValueProps,
|
|
55
|
-
default: false,
|
|
56
|
-
name: 'TextField',
|
|
57
|
-
state: 'showPassword',
|
|
58
|
-
});
|
|
59
|
-
let inputType = type;
|
|
60
|
-
const shouldShowMaskToggleButton = showMaskValueToggleButton && type === 'password';
|
|
61
|
-
const isSearchInput = type === 'search';
|
|
62
|
-
const shouldHideNativeClear = isSearchInput && !useNativeClearBtn;
|
|
63
|
-
if (shouldShowMaskToggleButton) {
|
|
64
|
-
if (maskValue) {
|
|
65
|
-
inputType = 'text';
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
inputType = 'password';
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
const handleMaskValueChange = useEventCallback(() => {
|
|
72
|
-
setMaskValue(!maskValue);
|
|
73
|
-
if (props.onMaskValueChange) {
|
|
74
|
-
props.onMaskValueChange(!maskValue);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
return (jsxs(FormField, { ...combineProps({
|
|
78
|
-
classes: {
|
|
79
|
-
root: cls('root', {
|
|
80
|
-
'full-width': fullWidth,
|
|
81
|
-
'hide-native-clear': shouldHideNativeClear,
|
|
82
|
-
}),
|
|
83
|
-
content: cls('form-field-content'),
|
|
84
|
-
outlined: cls('outlined'),
|
|
85
|
-
standard: cls('standard'),
|
|
86
|
-
quiet: cls('quiet'),
|
|
87
|
-
},
|
|
88
|
-
contentProps: {
|
|
89
|
-
onClick: (e) => {
|
|
90
|
-
onClick?.(e);
|
|
91
|
-
if (e.target === e.currentTarget && !disabled) {
|
|
92
|
-
inputRef.current?.focus();
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
}, RootProps), ...states, htmlFor: id, label: label, ref: ref, helperText: helperText, variant: variant, size: size, FormHelperTextProps: { id: idForHelperText, ...FormHelperTextProps }, children: [startAdornment && (jsx("div", { className: cls('start-adornment'), children: startAdornment })), jsx(InputComponent, { readOnly: readOnly, autoComplete: "off", autoFocus: autoFocus, onKeyDown: onKeyDown, onKeyUp: onKeyUp, ...widgetProps, className: cls('input'), ref: useForkRef(widgetProps.ref, inputRef), type: inputType }), clearBtn && (jsx(IconButton, { symbol: Xmd, shape: 'squircle', background: false, color: 'secondary', variant: "contained", size: "small", title: clearText, "aria-label": clearText, disabled: disabled, ...combineProps({
|
|
97
|
-
className: cls('clear'),
|
|
98
|
-
onClick: handlerClear,
|
|
99
|
-
}, ClearButtonProps) })), shouldShowMaskToggleButton && (jsx(IconButton, { disabled: disabled, shape: 'squircle', background: false, color: 'neutral', variant: "icon", size: "small", ...combineProps({
|
|
100
|
-
className: cls('mask-value-button'),
|
|
101
|
-
onClick: handleMaskValueChange,
|
|
102
|
-
'aria-label': maskValue ? 'eye-visible' : 'eye',
|
|
103
|
-
}, MaskValueButtonProps), children: jsx(ShowHideEye, { hide: !maskValue, size: ShowHideEyeIconProps?.size ??
|
|
104
|
-
MaskValueButtonProps?.iconSize ??
|
|
105
|
-
'small', ...ShowHideEyeIconProps }) })), endAdornment && (jsx("div", { className: cls('end-adornment'), children: endAdornment }))] }));
|
|
106
|
-
};
|
|
107
|
-
const TextField = forwardRef(TextFieldComponent);
|
|
108
|
-
TextField.displayName = 'SuiTextField';
|
|
109
|
-
|
|
110
|
-
export { TextField as T };
|
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 };
|