@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.
Files changed (213) hide show
  1. package/Accordion.js +90 -34
  2. package/AccordionHeader.js +71 -21
  3. package/Alert.js +120 -28
  4. package/Animation.js +2 -46
  5. package/Announcement.js +46 -35
  6. package/Autocomplete.js +1011 -583
  7. package/Avatar.js +134 -73
  8. package/AvatarGroup.js +50 -7
  9. package/Backdrop.js +45 -7
  10. package/Badge.js +77 -15
  11. package/Block.js +34 -12
  12. package/BlockHeader.js +57 -15
  13. package/BottomNavigation.js +181 -65
  14. package/BottomNavigationItem.js +93 -30
  15. package/Button.js +160 -24
  16. package/CallButton.js +53 -31
  17. package/Checkbox.js +88 -26
  18. package/Chip.js +126 -26
  19. package/CircularProgressIndicator.js +80 -8
  20. package/ClickAwayListener.js +4 -1
  21. package/ComponentsProps.js +1 -0
  22. package/DatePicker.js +611 -192
  23. package/DateUtilsContext.js +43 -25
  24. package/Dialer.js +564 -253
  25. package/Dialog.js +99 -45
  26. package/Divider.js +43 -7
  27. package/DragHandle.js +32 -6
  28. package/Drawer.js +117 -19
  29. package/Dropdown.js +154 -77
  30. package/EmptyState.js +65 -15
  31. package/FabButton.js +51 -17
  32. package/FocusTrap.js +109 -12
  33. package/FormField.js +108 -12
  34. package/FormLabel.js +81 -7
  35. package/Icon.js +1 -8
  36. package/IconButton.js +142 -26
  37. package/IconButtonGroup.js +35 -12
  38. package/InlineEditable.js +98 -44
  39. package/LinearProgressIndicator.js +73 -24
  40. package/Link.js +40 -11
  41. package/List.js +54 -9
  42. package/ListItem.js +152 -23
  43. package/ListItemText.js +44 -17
  44. package/ListNavigation.js +272 -20
  45. package/Menu.js +139 -23
  46. package/MenuActions.js +37 -12
  47. package/MenuDivider.js +34 -8
  48. package/MenuFooter.js +36 -12
  49. package/MenuHeader.js +54 -16
  50. package/MenuItem.js +402 -35
  51. package/MenuItemText.js +51 -9
  52. package/MenuList.js +87 -36
  53. package/Modal.js +345 -16
  54. package/NestedMenuContext.js +183 -11
  55. package/Option.js +32 -36
  56. package/Overlap.js +54 -7
  57. package/PageHeader.js +62 -24
  58. package/PickerTextField.js +156 -35
  59. package/Popover.js +262 -21
  60. package/Popper.js +112 -62
  61. package/PopperPaper.js +54 -8
  62. package/Portal.js +6 -1
  63. package/Radio.js +65 -21
  64. package/RadioGroup.js +56 -17
  65. package/Rating.js +223 -87
  66. package/Select.js +387 -44
  67. package/SingleFilter.js +148 -79
  68. package/Skeleton.js +68 -17
  69. package/Slider.js +167 -69
  70. package/Snackbar.js +122 -59
  71. package/SortableList.js +32 -12
  72. package/SortableListDndContext.js +69 -22
  73. package/SortableListItem.js +92 -47
  74. package/SortableVirtualizedList.js +44 -20
  75. package/SplitButton.js +124 -89
  76. package/Squircle.js +4 -7
  77. package/StatusIndicator.js +51 -9
  78. package/Step.js +63 -38
  79. package/StepButton.js +51 -23
  80. package/StepConnector.js +48 -8
  81. package/StepContent.js +67 -24
  82. package/StepIcon.js +90 -9
  83. package/StepLabel.js +90 -14
  84. package/Stepper.js +65 -23
  85. package/SubMenu.js +203 -101
  86. package/SwipeableDrawer.js +439 -194
  87. package/Switch.js +70 -23
  88. package/Tab.js +120 -57
  89. package/TabContext.js +59 -15
  90. package/TabPanel.js +40 -13
  91. package/Table.js +60 -17
  92. package/TableBody.js +42 -12
  93. package/TableCell.js +84 -50
  94. package/TableContainer.js +32 -10
  95. package/TableFooter.js +38 -10
  96. package/TableHead.js +49 -15
  97. package/TablePagination.js +153 -79
  98. package/TableRow.js +60 -21
  99. package/Tabs.js +592 -271
  100. package/Tag.js +51 -16
  101. package/Text.js +68 -37
  102. package/TextField.js +209 -31
  103. package/Textarea.js +51 -42
  104. package/TimePicker.js +490 -232
  105. package/Tooltip.js +48 -23
  106. package/Tray.js +237 -13
  107. package/TrayMenu.js +62 -43
  108. package/VirtualizedList.js +205 -107
  109. package/VirtualizedMenu.js +359 -29
  110. package/VisuallyHidden.js +29 -6
  111. package/chunks/1250.js +98 -0
  112. package/chunks/1294.js +126 -0
  113. package/chunks/2956.js +18 -0
  114. package/chunks/4476.js +460 -0
  115. package/chunks/4491.js +10 -0
  116. package/chunks/4535.js +364 -0
  117. package/chunks/5047.js +3 -0
  118. package/chunks/6335.js +24 -0
  119. package/chunks/7279.js +10 -0
  120. package/chunks/8011.js +8 -0
  121. package/chunks/8307.js +56 -0
  122. package/chunks/8467.js +8 -0
  123. package/chunks/8809.js +8 -0
  124. package/chunks/{RadioGroup.context.js → 9551.js} +12 -6
  125. package/chunks/987.js +8 -0
  126. package/index.css +2436 -2261
  127. package/index.js +245 -195
  128. package/internal/utils/setRef.d.ts +2 -1
  129. package/package.json +4 -4
  130. package/src/Animation/hooks/useMotionSafeTransition/useMotionSafeTransition.d.ts +2 -0
  131. package/src/Autocomplete/SuggestionList/SuggestionList.d.ts +1 -1
  132. package/src/Button/Button.classes.d.ts +1 -1
  133. package/src/ComponentsProps.d.ts +111 -110
  134. package/src/DatePicker/DatePickerDataAttributes.d.ts +11 -0
  135. package/src/DatePicker/utils/DatePickerUtils.d.ts +1 -1
  136. package/src/MenuItem/MenuItem.type.d.ts +1 -0
  137. package/src/MenuList/MenuListContext.d.ts +2 -3
  138. package/src/Modal/Modal.type.d.ts +1 -0
  139. package/src/Popover/Popover.classes.d.ts +1 -1
  140. package/src/Popover/Popover.internal.d.ts +8 -0
  141. package/src/Popover/Popover.type.d.ts +1 -0
  142. package/src/Select/Select.type.d.ts +6 -4
  143. package/src/Table/Table.type.d.ts +3 -0
  144. package/src/Table/TableContext.d.ts +3 -0
  145. package/src/Table/TableRowContext.d.ts +7 -0
  146. package/src/Table/index.d.ts +1 -0
  147. package/src/TableCell/TableCell.classes.d.ts +1 -1
  148. package/src/TableFooter/TableFooter.classes.d.ts +1 -1
  149. package/src/TableFooter/TableFooter.type.d.ts +1 -0
  150. package/src/TableHead/TableHead.classes.d.ts +1 -1
  151. package/src/TableHead/TableHead.type.d.ts +1 -0
  152. package/src/TableRow/TableRow.type.d.ts +2 -0
  153. package/chunks/AccordionContext.js +0 -6
  154. package/chunks/Alert.js +0 -48
  155. package/chunks/AvatarGroup.js +0 -22
  156. package/chunks/Backdrop.js +0 -18
  157. package/chunks/Badge.js +0 -32
  158. package/chunks/BottomNavigationItem.js +0 -36
  159. package/chunks/Button.js +0 -88
  160. package/chunks/Chip.js +0 -73
  161. package/chunks/CircularProgressIndicator.js +0 -36
  162. package/chunks/Divider.js +0 -19
  163. package/chunks/DragHandle.js +0 -11
  164. package/chunks/Drawer.js +0 -33
  165. package/chunks/ExpandCollapseCaret.js +0 -24
  166. package/chunks/FormLabel.js +0 -27
  167. package/chunks/Icon.js +0 -25
  168. package/chunks/IconButtonLabel.js +0 -68
  169. package/chunks/List.js +0 -22
  170. package/chunks/ListItem.js +0 -83
  171. package/chunks/Menu.js +0 -61
  172. package/chunks/MenuDivider.js +0 -14
  173. package/chunks/MenuItemText.js +0 -18
  174. package/chunks/MenuList.js +0 -47
  175. package/chunks/Modal.js +0 -211
  176. package/chunks/Overlap.js +0 -25
  177. package/chunks/PickerTextField.js +0 -85
  178. package/chunks/Popover.js +0 -61
  179. package/chunks/PopperPaper.js +0 -15
  180. package/chunks/Select.js +0 -225
  181. package/chunks/ShowHideEye.js +0 -56
  182. package/chunks/SlideIn.js +0 -20
  183. package/chunks/SortableArrow.js +0 -73
  184. package/chunks/Squircle.js +0 -31
  185. package/chunks/StatusIndicator.js +0 -20
  186. package/chunks/StepConnector.js +0 -21
  187. package/chunks/StepIcon.js +0 -43
  188. package/chunks/StepLabel.js +0 -29
  189. package/chunks/StepperContext.js +0 -9
  190. package/chunks/TableContext.js +0 -6
  191. package/chunks/Tablelvl2Context.js +0 -6
  192. package/chunks/TabsContext.js +0 -6
  193. package/chunks/TextField.js +0 -110
  194. package/chunks/Tooltip.js +0 -217
  195. package/chunks/VirtualizedMenu.js +0 -162
  196. package/chunks/VisuallyHidden.js +0 -12
  197. package/chunks/composeEventHandlers.js +0 -10
  198. package/chunks/getFade.js +0 -27
  199. package/chunks/getGrow.js +0 -70
  200. package/chunks/getSlideIn.js +0 -30
  201. package/chunks/hasContent.js +0 -3
  202. package/chunks/useAnimationFrame.js +0 -15
  203. package/chunks/useFocusTrapStack.js +0 -38
  204. package/chunks/useHelperTextId.js +0 -24
  205. package/chunks/useListNavigation.js +0 -199
  206. package/chunks/useMenuItemSelect.js +0 -282
  207. package/chunks/useMotionSafeTransition.js +0 -9
  208. package/chunks/useNestedMenuItem.js +0 -27
  209. package/chunks/useNestedParentMenu.js +0 -113
  210. package/chunks/usePrefersReducedMotion.js +0 -36
  211. package/chunks/useTooltipForceHide.js +0 -27
  212. package/chunks/useTrayNavigate.js +0 -150
  213. 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 };
@@ -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 };
@@ -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 };
@@ -1,3 +0,0 @@
1
- const hasContent = (content) => Boolean(content) || content === 0;
2
-
3
- export { hasContent as h };
@@ -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 };