@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.
Files changed (241) hide show
  1. package/Accordion.js +90 -34
  2. package/AccordionHeader.js +72 -20
  3. package/Alert.js +120 -28
  4. package/Animation.js +2 -45
  5. package/Announcement.js +46 -35
  6. package/Autocomplete.js +1011 -580
  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 +55 -11
  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 -190
  23. package/DateUtilsContext.js +43 -25
  24. package/Dialer.js +576 -250
  25. package/Dialog.js +100 -45
  26. package/Divider.js +43 -7
  27. package/DragHandle.js +32 -6
  28. package/Drawer.js +117 -19
  29. package/Dropdown.js +154 -74
  30. package/EmptyState.js +63 -11
  31. package/FabButton.js +51 -17
  32. package/FocusTrap.js +109 -12
  33. package/FormField.js +106 -8
  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 -16
  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 -15
  50. package/MenuItem.js +402 -33
  51. package/MenuItemText.js +51 -8
  52. package/MenuList.js +87 -34
  53. package/Modal.js +345 -16
  54. package/NestedMenuContext.js +183 -11
  55. package/Option.js +32 -34
  56. package/Overlap.js +54 -7
  57. package/PageHeader.js +62 -24
  58. package/PickerTextField.js +156 -33
  59. package/Popover.js +262 -21
  60. package/Popper.js +130 -77
  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 -41
  67. package/SingleFilter.js +148 -77
  68. package/Skeleton.js +68 -17
  69. package/Slider.js +168 -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 +52 -28
  75. package/SplitButton.js +124 -86
  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 +68 -25
  82. package/StepIcon.js +90 -9
  83. package/StepLabel.js +90 -14
  84. package/Stepper.js +65 -23
  85. package/SubMenu.js +203 -99
  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 -77
  98. package/TableRow.js +60 -21
  99. package/Tabs.js +593 -268
  100. package/Tag.js +51 -16
  101. package/Text.js +68 -37
  102. package/TextField.js +209 -29
  103. package/Textarea.js +51 -40
  104. package/TimePicker.js +490 -230
  105. package/Tooltip.js +48 -23
  106. package/Tray.js +237 -13
  107. package/TrayMenu.js +62 -41
  108. package/VirtualizedList.js +208 -109
  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 +2624 -2416
  127. package/index.js +245 -193
  128. package/internal/utils/index.d.ts +1 -0
  129. package/internal/utils/setRef.d.ts +2 -0
  130. package/package.json +8 -8
  131. package/src/Alert/Alert.type.d.ts +2 -1
  132. package/src/Animation/components/Fade/Fade.d.ts +4 -2
  133. package/src/Animation/components/Grow/Grow.d.ts +4 -2
  134. package/src/Animation/components/ShowHideEye/ShowHideEye.d.ts +1 -1
  135. package/src/Animation/components/SlideIn/SlideIn.d.ts +4 -2
  136. package/src/Animation/components/SlideIn/getSlideIn.d.ts +1 -1
  137. package/src/Animation/hooks/useMotionSafeTransition/useMotionSafeTransition.d.ts +2 -0
  138. package/src/Autocomplete/SuggestionList/SuggestionList.d.ts +1 -1
  139. package/src/Autocomplete/useAutocomplete.d.ts +18 -18
  140. package/src/Autocomplete/useAutocompleteTag.d.ts +18 -18
  141. package/src/Badge/Badge.d.ts +2 -1
  142. package/src/Button/Button.classes.d.ts +1 -1
  143. package/src/ComponentsProps.d.ts +111 -110
  144. package/src/DatePicker/DatePickerDataAttributes.d.ts +11 -0
  145. package/src/DatePicker/utils/DatePickerAriaLabelUtils.d.ts +2 -1
  146. package/src/DatePicker/utils/DatePickerUtils.d.ts +1 -1
  147. package/src/Dialer/DialDelete/DialDelete.d.ts +2 -2
  148. package/src/Dialer/DialPad/DialPad.d.ts +2 -2
  149. package/src/Dialer/Dialer.d.ts +4 -2
  150. package/src/Dropdown/Dropdown.type.d.ts +2 -2
  151. package/src/InlineEditable/InlineEditable.type.d.ts +2 -1
  152. package/src/ListNavigation/useListNavigation.d.ts +3 -3
  153. package/src/MenuActions/MenuActions.d.ts +2 -2
  154. package/src/MenuItem/MenuItem.type.d.ts +1 -0
  155. package/src/MenuItem/useMenuItem.d.ts +1 -1
  156. package/src/MenuItem/useVirtualizedMenuItem.d.ts +1 -1
  157. package/src/MenuList/MenuList.type.d.ts +1 -1
  158. package/src/MenuList/MenuListContext.d.ts +2 -3
  159. package/src/Modal/Modal.type.d.ts +1 -0
  160. package/src/NestedMenuContext/MenuOverlayGroupContext.d.ts +2 -2
  161. package/src/Popover/Popover.classes.d.ts +1 -1
  162. package/src/Popover/Popover.internal.d.ts +8 -0
  163. package/src/Popover/Popover.type.d.ts +1 -0
  164. package/src/Popper/Popper.type.d.ts +10 -7
  165. package/src/Rating/utils.d.ts +3 -2
  166. package/src/Select/Select.type.d.ts +7 -5
  167. package/src/Slider/Slider.d.ts +2 -2
  168. package/src/Slider/SliderThumb.d.ts +2 -1
  169. package/src/Squircle/Squircle.d.ts +1 -1
  170. package/src/StatusIndicator/StatusIndicator.d.ts +2 -1
  171. package/src/SubMenu/PopperMenu.type.d.ts +4 -1
  172. package/src/Table/Table.type.d.ts +3 -0
  173. package/src/Table/TableContext.d.ts +3 -0
  174. package/src/Table/TableRowContext.d.ts +7 -0
  175. package/src/Table/index.d.ts +1 -0
  176. package/src/TableCell/TableCell.classes.d.ts +1 -1
  177. package/src/TableFooter/TableFooter.classes.d.ts +1 -1
  178. package/src/TableFooter/TableFooter.type.d.ts +1 -0
  179. package/src/TableHead/TableHead.classes.d.ts +1 -1
  180. package/src/TableHead/TableHead.type.d.ts +1 -0
  181. package/src/TableRow/TableRow.type.d.ts +2 -0
  182. package/chunks/AccordionContext.js +0 -6
  183. package/chunks/Alert.js +0 -48
  184. package/chunks/AvatarGroup.js +0 -22
  185. package/chunks/Backdrop.js +0 -18
  186. package/chunks/Badge.js +0 -32
  187. package/chunks/BottomNavigationItem.js +0 -36
  188. package/chunks/Button.js +0 -88
  189. package/chunks/Chip.js +0 -73
  190. package/chunks/CircularProgressIndicator.js +0 -36
  191. package/chunks/Divider.js +0 -19
  192. package/chunks/DragHandle.js +0 -11
  193. package/chunks/Drawer.js +0 -32
  194. package/chunks/ExpandCollapseCaret.js +0 -24
  195. package/chunks/FormLabel.js +0 -27
  196. package/chunks/Icon.js +0 -25
  197. package/chunks/IconButtonLabel.js +0 -68
  198. package/chunks/List.js +0 -22
  199. package/chunks/ListItem.js +0 -83
  200. package/chunks/Menu.js +0 -61
  201. package/chunks/MenuDivider.js +0 -14
  202. package/chunks/MenuItemText.js +0 -17
  203. package/chunks/MenuList.js +0 -46
  204. package/chunks/Modal.js +0 -212
  205. package/chunks/Overlap.js +0 -25
  206. package/chunks/PickerTextField.js +0 -85
  207. package/chunks/Popover.js +0 -53
  208. package/chunks/PopperPaper.js +0 -15
  209. package/chunks/Select.js +0 -220
  210. package/chunks/ShowHideEye.js +0 -56
  211. package/chunks/SlideIn.js +0 -19
  212. package/chunks/SortableArrow.js +0 -73
  213. package/chunks/Squircle.js +0 -31
  214. package/chunks/StatusIndicator.js +0 -20
  215. package/chunks/StepConnector.js +0 -21
  216. package/chunks/StepIcon.js +0 -43
  217. package/chunks/StepLabel.js +0 -29
  218. package/chunks/StepperContext.js +0 -9
  219. package/chunks/TableContext.js +0 -6
  220. package/chunks/Tablelvl2Context.js +0 -6
  221. package/chunks/TabsContext.js +0 -6
  222. package/chunks/TextField.js +0 -110
  223. package/chunks/Tooltip.js +0 -217
  224. package/chunks/VirtualizedMenu.js +0 -164
  225. package/chunks/VisuallyHidden.js +0 -12
  226. package/chunks/getFade.js +0 -27
  227. package/chunks/getGrow.js +0 -70
  228. package/chunks/getSlideIn.js +0 -30
  229. package/chunks/hasContent.js +0 -3
  230. package/chunks/useAnimationFrame.js +0 -15
  231. package/chunks/useFocusTrapStack.js +0 -36
  232. package/chunks/useHelperTextId.js +0 -22
  233. package/chunks/useListNavigation.js +0 -199
  234. package/chunks/useMenuItemSelect.js +0 -273
  235. package/chunks/useMotionSafeTransition.js +0 -9
  236. package/chunks/useNestedMenuItem.js +0 -27
  237. package/chunks/useNestedParentMenu.js +0 -113
  238. package/chunks/usePrefersReducedMotion.js +0 -36
  239. package/chunks/useTooltipForceHide.js +0 -27
  240. package/chunks/useTrayNavigate.js +0 -150
  241. package/chunks/withTooltip.js +0 -15
@@ -1,46 +0,0 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { forwardRef, useMemo, useRef, useLayoutEffect } from 'react';
3
- import { useClasses, useForkRef, useWindowContext } from '@ringcentral/spring-base';
4
- import { useThemeProps } from '@ringcentral/spring-theme';
5
- import { L as List } from './List.js';
6
- import { u as useMenuContext } from './Menu.js';
7
- import { c as useMenuItemSelect, e as MenuListContext, a as MenuItemSelectContext } from './useMenuItemSelect.js';
8
- import 'tabbable';
9
- import './useListNavigation.js';
10
- import '../VirtualizedList.js';
11
-
12
- const MenuList = forwardRef((inProps, ref) => {
13
- const props = useThemeProps({ props: inProps, name: 'MenuList' });
14
- const { classes, className, children, widget, selectMode = 'single', nowrap, value: valueProp, onChange, autoFocus: autoFocusProp, ...rest } = props;
15
- const menuContext = useMenuContext();
16
- const autoFocus = Boolean(autoFocusProp || menuContext?.autoFocus);
17
- const cls = useClasses('menu-list', classes, className);
18
- const menuListContextValue = useMemo(() => ({
19
- nowrap,
20
- }), [nowrap]);
21
- const { contextValue } = useMenuItemSelect({
22
- widget,
23
- selectMode,
24
- value: valueProp,
25
- onChange,
26
- autoFocus,
27
- });
28
- const actions = useRef(null);
29
- const listRef = useRef(null);
30
- const handleListRef = useForkRef(listRef, ref);
31
- const { document } = useWindowContext();
32
- useLayoutEffect(() => {
33
- if (autoFocus &&
34
- !listRef.current?.contains(document?.activeElement ?? null)) {
35
- actions.current?.focus();
36
- }
37
- }, [autoFocus]);
38
- const listRole = widget === 'select' ? 'listbox' : 'menu';
39
- const listboxProps = widget === 'select'
40
- ? { 'aria-multiselectable': selectMode === 'multiple' }
41
- : {};
42
- return (jsx(List, { className: cls('root'), role: listRole, ...listboxProps, ...rest, ref: handleListRef, actions: actions, children: jsx(MenuListContext.Provider, { value: menuListContextValue, children: jsx(MenuItemSelectContext.Provider, { value: contextValue, children: children }) }) }));
43
- });
44
- MenuList.displayName = 'SuiMenuList';
45
-
46
- export { MenuList as M };
package/chunks/Modal.js DELETED
@@ -1,212 +0,0 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { createContext, useContext, useRef, useCallback, useLayoutEffect, forwardRef, useState, useEffect } from 'react';
3
- import { useAriaHideOutside, useForkRef, useClasses, useEventCallback, useBodyScrollLock, useWindowContext } from '@ringcentral/spring-base';
4
- import { useThemeProps, useTheme } from '@ringcentral/spring-theme';
5
- import { FocusTrap, Portal } from '@mui/base';
6
- import { motion } from 'framer-motion';
7
- import './Icon.js';
8
- import { u as usePrefersReducedMotion } from './usePrefersReducedMotion.js';
9
- import { g as getFade } from './getFade.js';
10
- import { u as useFocusTrapStack } from './useFocusTrapStack.js';
11
- import { B as Backdrop } from './Backdrop.js';
12
-
13
- const ModalContext = createContext(null);
14
- const useModalContext = () => useContext(ModalContext);
15
-
16
- const createOverlayBranchRegistry = () => {
17
- const branchRefCounts = new Map();
18
- const listeners = new Set();
19
- const notify = (node, isRegistered) => {
20
- for (const listener of [...listeners]) {
21
- listener(node, isRegistered);
22
- }
23
- };
24
- return {
25
- getBranches: () => new Set(branchRefCounts.keys()),
26
- register: (node) => {
27
- const currentCount = branchRefCounts.get(node) ?? 0;
28
- branchRefCounts.set(node, currentCount + 1);
29
- if (currentCount === 0) {
30
- notify(node, true);
31
- }
32
- let isCleanedUp = false;
33
- return () => {
34
- if (isCleanedUp) {
35
- return;
36
- }
37
- isCleanedUp = true;
38
- const currentCount = branchRefCounts.get(node);
39
- if (!currentCount) {
40
- return;
41
- }
42
- if (currentCount > 1) {
43
- branchRefCounts.set(node, currentCount - 1);
44
- return;
45
- }
46
- branchRefCounts.delete(node);
47
- notify(node, false);
48
- };
49
- },
50
- subscribe: (listener) => {
51
- listeners.add(listener);
52
- return () => {
53
- listeners.delete(listener);
54
- };
55
- },
56
- };
57
- };
58
- const useOverlayBranchRegistry = () => {
59
- const registryRef = useRef();
60
- if (!registryRef.current) {
61
- registryRef.current = createOverlayBranchRegistry();
62
- }
63
- return registryRef.current;
64
- };
65
-
66
- const useOverlayBranch = ({ active, registry, }) => {
67
- const nodeRef = useRef(null);
68
- const registrationRef = useRef(null);
69
- const syncRegistration = useCallback((node) => {
70
- const registration = registrationRef.current;
71
- const shouldKeepRegistration = registration &&
72
- active &&
73
- registration.node === node &&
74
- registration.registry === registry;
75
- if (shouldKeepRegistration) {
76
- return;
77
- }
78
- registration?.unregister();
79
- registrationRef.current = null;
80
- if (active && node && registry) {
81
- registrationRef.current = {
82
- node,
83
- registry,
84
- unregister: registry.register(node),
85
- };
86
- }
87
- }, [active, registry]);
88
- const setBranchRef = useCallback((node) => {
89
- nodeRef.current = node;
90
- syncRegistration(node);
91
- }, [syncRegistration]);
92
- useLayoutEffect(() => {
93
- syncRegistration(nodeRef.current);
94
- }, [syncRegistration]);
95
- useLayoutEffect(() => () => {
96
- registrationRef.current?.unregister();
97
- registrationRef.current = null;
98
- }, []);
99
- return setBranchRef;
100
- };
101
- const useOverlayBranchConsumer = (registry, listener) => {
102
- useLayoutEffect(() => {
103
- const unsubscribe = registry.subscribe(listener);
104
- for (const node of registry.getBranches()) {
105
- listener(node, true);
106
- }
107
- return () => {
108
- unsubscribe();
109
- for (const node of registry.getBranches()) {
110
- listener(node, false);
111
- }
112
- };
113
- }, [listener, registry]);
114
- };
115
-
116
- const InnerModal = forwardRef((props, ref) => {
117
- const { hideBackdrop: hideBackdropProp, children, motionProps, disableBackdropClick: disableBackdropClickProp, onBackdropClick, disableEscapeKeyDown: disableEscapeKeyDownProp, onEscapeKeyDown, onClose, onKeyDown, disableAutoFocus, disableEnforceFocus, disableRestoreFocus, classes, className, backdropProps, open, isEnabled, blocking = true, shouldUseInert: shouldUseInertProp, ...rest } = props;
118
- const parentModalContext = useModalContext();
119
- const ownOverlayBranchRegistry = useOverlayBranchRegistry();
120
- const shouldUseInert = shouldUseInertProp ?? parentModalContext?.shouldUseInert ?? false;
121
- const hideBackdrop = hideBackdropProp ?? !blocking;
122
- const disableBackdropClick = disableBackdropClickProp ?? !blocking;
123
- const disableEscapeKeyDown = disableEscapeKeyDownProp ?? !blocking;
124
- const { ariaHideOutsideRef, ariaHideEnabled, setAriaHideOutsideTarget } = useAriaHideOutside({
125
- enable: blocking && open,
126
- shouldUseInert,
127
- });
128
- useOverlayBranchConsumer(ownOverlayBranchRegistry, setAriaHideOutsideTarget);
129
- const parentOverlayBranchRegistry = parentModalContext?.overlayBranchRegistry;
130
- const overlayBranchRegistry = ariaHideEnabled
131
- ? ownOverlayBranchRegistry
132
- : parentOverlayBranchRegistry;
133
- const isOverlayBranch = !blocking && open && parentOverlayBranchRegistry != null;
134
- const ariaHideEnabledForChildren = ariaHideEnabled || parentModalContext?.ariaHideEnabled === true;
135
- const overlayBranchRef = useOverlayBranch({
136
- active: isOverlayBranch,
137
- registry: parentOverlayBranchRegistry,
138
- });
139
- const handleRef = useForkRef(ref, ariaHideOutsideRef, overlayBranchRef);
140
- const cls = useClasses('modal', classes, className);
141
- const { onClick: externalOnClick, ...restBackdropProps } = backdropProps || {};
142
- const handleBackdropClick = useEventCallback((event) => {
143
- if (disableBackdropClick)
144
- return;
145
- if (event.target !== event.currentTarget) {
146
- return;
147
- }
148
- externalOnClick?.(event);
149
- onBackdropClick?.(event);
150
- onClose?.(event, 'backdropClick');
151
- });
152
- return (jsx(ModalContext.Provider, { value: {
153
- ariaHideEnabled: ariaHideEnabledForChildren,
154
- overlayBranchRegistry,
155
- shouldUseInert,
156
- }, children: jsxs(motion.div, { ...rest, ...motionProps, role: "presentation", className: cls('root', { 'non-blocking': !blocking }), onKeyDown: (e) => {
157
- onKeyDown?.(e);
158
- if (!disableEscapeKeyDown &&
159
- e.key === 'Escape' &&
160
- (isEnabled?.() ?? true)) {
161
- onEscapeKeyDown?.(e);
162
- onClose?.(e, 'escapeKeyDown');
163
- }
164
- }, ref: handleRef, children: [jsx(Backdrop, { ...restBackdropProps, isTransparent: hideBackdrop, onClick: handleBackdropClick }), jsx(FocusTrap, { open: open, isEnabled: isEnabled, disableAutoFocus: disableAutoFocus || !blocking, disableEnforceFocus: disableEnforceFocus || !blocking, disableRestoreFocus: disableRestoreFocus || !blocking, children: children })] }) }));
165
- });
166
- InnerModal.displayName = 'SuiInnerModal';
167
-
168
- const Modal = forwardRef((inProps, ref) => {
169
- const props = useThemeProps({ props: inProps, name: 'Modal' });
170
- const { children, open, container: containerProp, disablePortal, onExitComplete, disableBackdropAnimation, motionProps, disableScrollLock: disableScrollLockProp, blocking = true, shouldUseInert: themeFallbackShouldUseInert, ...rest } = props;
171
- const parentModalContext = useModalContext();
172
- const shouldUseInert = inProps.shouldUseInert ??
173
- parentModalContext?.shouldUseInert ??
174
- themeFallbackShouldUseInert ??
175
- false;
176
- const disableScrollLock = disableScrollLockProp ?? !blocking;
177
- const [shouldRender, setShouldRender] = useState(open);
178
- const [modalElement, setModalElement] = useState(null);
179
- const handleRef = useForkRef(setModalElement, ref);
180
- const prefersReducedMotion = usePrefersReducedMotion();
181
- const { isEnabled } = useFocusTrapStack({ open });
182
- useBodyScrollLock(open, modalElement, {
183
- disabled: disableScrollLock,
184
- });
185
- useEffect(() => {
186
- if (open) {
187
- setShouldRender(true);
188
- }
189
- else {
190
- if (disableBackdropAnimation) {
191
- setShouldRender(false);
192
- }
193
- }
194
- }, [open, disableBackdropAnimation]);
195
- const { document } = useWindowContext();
196
- const container = containerProp ?? document?.body;
197
- const { scopeProps } = useTheme();
198
- const onAnimationComplete = (e) => {
199
- motionProps?.onAnimationComplete?.(e);
200
- if (!open) {
201
- onExitComplete?.();
202
- setShouldRender(false);
203
- }
204
- };
205
- return shouldRender ? (jsx(Portal, { disablePortal: disablePortal, container: container, children: jsx("div", { ...scopeProps, children: jsx(InnerModal, { ...rest, ref: handleRef, open: open, blocking: blocking, shouldUseInert: shouldUseInert, isEnabled: isEnabled, motionProps: {
206
- ...(motionProps ?? getFade({ prefersReducedMotion, toggle: open })),
207
- onAnimationComplete,
208
- }, children: children }) }) })) : null;
209
- });
210
- Modal.displayName = 'SuiModal';
211
-
212
- export { InnerModal as I, Modal as M, ModalContext as a, useModalContext as u };
package/chunks/Overlap.js DELETED
@@ -1,25 +0,0 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { forwardRef } from 'react';
3
- import { useClasses } from '@ringcentral/spring-base';
4
- import { useThemeProps } from '@ringcentral/spring-theme';
5
-
6
- function isKeyPosition(position) {
7
- return typeof position === 'string';
8
- }
9
- const Overlap = forwardRef((inProps, ref) => {
10
- const props = useThemeProps({ props: inProps, name: 'Overlap' });
11
- const { classes, floater, position, children, className, showFloaterOnHoverOnly = false, component: OverlapRoot = 'div', ...rest } = props;
12
- const cls = useClasses('overlap', classes, className);
13
- let widget = null;
14
- if (floater) {
15
- const style = !isKeyPosition(position) ? position : undefined;
16
- const classes = cls('floater', isKeyPosition(position) && position);
17
- widget = jsx("div", { style: style, className: classes, children: floater });
18
- }
19
- return (jsxs(OverlapRoot, { ...rest, ref: ref, className: cls('root', {
20
- 'show-floater-on-hover-only': showFloaterOnHoverOnly,
21
- }), children: [children, widget] }));
22
- });
23
- Overlap.displayName = 'SuiOverlap';
24
-
25
- export { Overlap as O };
@@ -1,85 +0,0 @@
1
- import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
- import { forwardRef, useState, useRef, useImperativeHandle, useMemo } from 'react';
3
- import { useId, useClasses, useForkRef, useA11yKeyEvent, useEventCallback, combineClasses } from '@ringcentral/spring-base';
4
- import { I as Icon } from './Icon.js';
5
- import { P as Popover } from './Popover.js';
6
- import { u as useHelperTextId } from './useHelperTextId.js';
7
- import { T as TextField } from './TextField.js';
8
- import { V as VisuallyHidden } from './VisuallyHidden.js';
9
-
10
- const PICKER_DISPLAY_NAME = 'SuiPickerTextField';
11
- const PickerTextField = forwardRef((props, ref) => {
12
- const { disabled, value, defaultValue, onClear, action, inputProps = {}, announcementText, PopoverProps, children, endIconSymbol, clearText, clearBtn, ClearButtonProps, onKeyDown, onClick, onClose, classes, textInputClasses, className, id: idProp, ...rest } = props;
13
- const generatedId = useId(PICKER_DISPLAY_NAME, true);
14
- const idForInput = idProp ?? inputProps.id ?? generatedId;
15
- const [open, setOpen] = useState(false);
16
- const [isPopoverExited, setIsPopoverExited] = useState(!open);
17
- const cls = useClasses('picker-text-field', classes, className);
18
- const anchorRef = useRef(null);
19
- const handleRef = useForkRef(ref, anchorRef);
20
- const idForHelperText = useHelperTextId({
21
- helperText: rest.helperText,
22
- id: idForInput,
23
- FormHelperTextProps: rest.FormHelperTextProps,
24
- });
25
- const idForInstruction = announcementText
26
- ? `${idForInput}-instruction`
27
- : undefined;
28
- const ariaDescribedBy = Array.from(new Set([inputProps['aria-describedby'], idForHelperText, idForInstruction]
29
- .filter(Boolean)
30
- .flatMap((value) => `${value}`.split(/\s+/).filter(Boolean)))).join(' ');
31
- const handleA11yKeydown = useA11yKeyEvent(() => {
32
- handleOpen(true);
33
- });
34
- const handleOpen = useEventCallback((open) => {
35
- if (disabled && open) {
36
- return;
37
- }
38
- if (open) {
39
- setIsPopoverExited(false);
40
- }
41
- setOpen(open);
42
- });
43
- useImperativeHandle(action, () => ({
44
- close: () => {
45
- handleOpen(false);
46
- },
47
- }), [handleOpen]);
48
- const toClasses = useMemo(() => combineClasses(textInputClasses, {
49
- formFieldContent: cls('form-field-content', {
50
- 'has-value': Boolean(value),
51
- }),
52
- root: cls('root', {
53
- 'has-value': Boolean(value),
54
- }),
55
- input: cls('input'),
56
- }), [cls, textInputClasses, value]);
57
- return (jsxs(Fragment, { children: [jsx(TextField, { classes: toClasses, value: value, defaultValue: defaultValue, endAdornment: endIconSymbol && (jsx(Icon, { className: cls('end-icon'), symbol: endIconSymbol })), id: idForInput, ref: handleRef, focused: open || (!open && !isPopoverExited), disabled: disabled, clearBtn: clearBtn, clearText: clearText, ClearButtonProps: ClearButtonProps, onClick: (e) => {
58
- handleOpen(true);
59
- onClick?.(e);
60
- }, onKeyDown: (e) => {
61
- if (disabled)
62
- return;
63
- handleA11yKeydown(e);
64
- onKeyDown?.(e);
65
- }, inputProps: {
66
- 'aria-haspopup': true,
67
- ...inputProps,
68
- 'aria-describedby': ariaDescribedBy || undefined,
69
- }, ...rest, readOnly: true, onClear: (e) => {
70
- onClear?.(e);
71
- e.stopPropagation();
72
- } }), jsx(Popover, { bordered: true, open: open, anchorEl: anchorRef.current, onClose: (...args) => {
73
- handleOpen(false);
74
- onClose?.(...args);
75
- }, placement: "bottom-start", transformOrigin: {
76
- vertical: 'top',
77
- horizontal: 'left',
78
- }, ...PopoverProps, onExitComplete: () => {
79
- PopoverProps?.onExitComplete?.();
80
- setIsPopoverExited(true);
81
- }, children: children }), idForInstruction && (jsx(VisuallyHidden, { id: idForInstruction, children: announcementText }))] }));
82
- });
83
- PickerTextField.displayName = PICKER_DISPLAY_NAME;
84
-
85
- export { PickerTextField as P };
package/chunks/Popover.js DELETED
@@ -1,53 +0,0 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { forwardRef, useRef } from 'react';
3
- import { size } from '@floating-ui/react-dom';
4
- import { useClasses, useForkRef, combineProps } from '@ringcentral/spring-base';
5
- import { useThemeProps } from '@ringcentral/spring-theme';
6
- import 'framer-motion';
7
- import './Icon.js';
8
- import { u as usePrefersReducedMotion } from './usePrefersReducedMotion.js';
9
- import { g as getGrow, a as getTransformOriginStringForPlacement } from './getGrow.js';
10
- import { M as Modal } from './Modal.js';
11
- import { Popper } from '../Popper.js';
12
- import { P as PopperPaper } from './PopperPaper.js';
13
-
14
- const Popover = forwardRef((inProps, ref) => {
15
- const props = useThemeProps({ props: inProps, name: 'Popover' });
16
- const { classes, className, children, PopperProps, variant = 'standard', bordered = false, shadow = true, transformOrigin, motionProps: motionPropsProp, popperRef, placement, anchorEl, actions, onAvailableHeightChange, PopperPaperProps: popperPaperPropsProp, ...rest } = props;
17
- const cls = useClasses('popover', classes, className);
18
- const paperContentRef = useRef(null);
19
- const handlePaperContentRef = useForkRef(popperPaperPropsProp?.contentRef, paperContentRef);
20
- const prefersReducedMotion = usePrefersReducedMotion();
21
- return (jsx(Modal, { ...rest, className: cls('root', 'popper'), ref: ref, motionProps: null, hideBackdrop: true, children: jsx(Popper, { arrowHeight: variant === 'standard' ? 0 : 10, arrowPadding: 12, offset: variant === 'standard' ? 2 : 4, ...combineProps({
22
- middlewares: [
23
- size({
24
- padding: PopperProps?.padding,
25
- apply({ availableHeight, availableWidth, }) {
26
- onAvailableHeightChange?.(availableHeight);
27
- if (paperContentRef.current) {
28
- paperContentRef.current.style.maxHeight = `${availableHeight}px`;
29
- paperContentRef.current.style.maxWidth = `${availableWidth}px`;
30
- }
31
- },
32
- }),
33
- ],
34
- }, PopperProps), className: cls('popper'), disablePortal: true, tabIndex: -1, ref: popperRef, placement: placement, anchorEl: anchorEl, actions: actions, children: ({ arrowStyle, arrowRef, placement: computedPlacement }) => {
35
- const motionProps = motionPropsProp ??
36
- getGrow({ transformOrigin, prefersReducedMotion });
37
- const popperPaperProps = {
38
- className: cls('paper', { bordered, shadow }),
39
- };
40
- if (!transformOrigin) {
41
- popperPaperProps.style = {
42
- ...popperPaperProps.style,
43
- transformOrigin: getTransformOriginStringForPlacement({
44
- placement: computedPlacement,
45
- }),
46
- };
47
- }
48
- return (jsx(PopperPaper, { contentRef: handlePaperContentRef, arrowRef: arrowRef, arrowStyle: arrowStyle, ...combineProps(combineProps(motionProps, popperPaperProps), popperPaperPropsProp), children: children }));
49
- } }) }));
50
- });
51
- Popover.displayName = 'SuiPopover';
52
-
53
- export { Popover as P };
@@ -1,15 +0,0 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { forwardRef } from 'react';
3
- import { motion } from 'framer-motion';
4
- import { useClasses } from '@ringcentral/spring-base';
5
- import { useThemeProps } from '@ringcentral/spring-theme';
6
-
7
- const PopperPaper = forwardRef((inProps, ref) => {
8
- const props = useThemeProps({ props: inProps, name: 'PopperPaper' });
9
- const { classes, className, children, arrowRef, arrowStyle, contentRef, ...rest } = props;
10
- const cls = useClasses('popper-paper', classes, className);
11
- return (jsxs(motion.div, { className: cls('root'), ...rest, ref: ref, children: [jsx("div", { ref: contentRef, className: cls('content'), children: children }), jsx("div", { className: cls('arrow'), ref: arrowRef, style: arrowStyle })] }));
12
- });
13
- PopperPaper.displayName = 'SuiPopperPaper';
14
-
15
- export { PopperPaper as P };
package/chunks/Select.js DELETED
@@ -1,220 +0,0 @@
1
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import { forwardRef, useState, useRef, useEffect, useMemo } from 'react';
3
- import { combineProps, useControlled, useClasses, useId, useEventCallback, combineClasses, getTitle } from '@ringcentral/spring-base';
4
- import { useThemeProps } from '@ringcentral/spring-theme';
5
- import { E as ExpandCollapseCaret } from './ExpandCollapseCaret.js';
6
- import 'framer-motion';
7
- import { u as usePrefersReducedMotion } from './usePrefersReducedMotion.js';
8
- import { g as getGrow } from './getGrow.js';
9
- import './Icon.js';
10
- import { u as useHelperTextId, F as FormField } from './useHelperTextId.js';
11
- import { M as Menu, a as MenuContext } from './Menu.js';
12
- import { c as useMenuItemSelect, a as MenuItemSelectContext } from './useMenuItemSelect.js';
13
- import 'tabbable';
14
- import './useListNavigation.js';
15
- import '../VirtualizedList.js';
16
- import { M as MenuList } from './MenuList.js';
17
- import { S as Squircle } from './Squircle.js';
18
- import { a as VirtualizedMenu } from './VirtualizedMenu.js';
19
-
20
- const useSelect = (props) => {
21
- const { open, handleOpen } = props;
22
- const getButtonProps = (otherHandlers = {}) => {
23
- const eventHandlers = combineProps({
24
- onClick: () => {
25
- handleOpen(!open);
26
- },
27
- onKeyDown: (e) => {
28
- if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
29
- e.preventDefault();
30
- handleOpen(true);
31
- }
32
- },
33
- }, otherHandlers);
34
- return {
35
- 'aria-expanded': open,
36
- 'aria-haspopup': 'listbox',
37
- ...eventHandlers,
38
- };
39
- };
40
- const getListboxProps = () => ({
41
- role: 'listbox',
42
- });
43
- return {
44
- getButtonProps,
45
- getListboxProps,
46
- };
47
- };
48
-
49
- const DEFAULT_PLACEMENT = 'bottom';
50
- const Select = forwardRef((inProps, ref) => {
51
- const props = useThemeProps({ props: inProps, name: 'Select' });
52
- const { classes, className, children, name, id: idProp, value: valueProp, selectMode = 'single', defaultValue = selectMode === 'multiple' ? [] : null, onChange: onChangeProp, renderValue = (value) => Array.isArray(value) ? value.join(', ') : String(value), label, helperText, disabled, required, error, displayEmpty, placeholder, open: openProp, defaultOpen, onOpen, onClose, selectorProps: selectorPropsProp, MenuProps, variant = 'standard', inputProps, size = 'xlarge', virtualize = false, VirtualizedMenuProps: virtualizedMenuPropsProp, data, getSelectedIndex, FormHelperTextProps, ...rest } = props;
53
- const [anchorEl, setAnchorEl] = useState(null);
54
- const [open, setOpen] = useControlled({
55
- controlled: openProp,
56
- default: defaultOpen,
57
- name: 'SuiSelect',
58
- state: 'open',
59
- });
60
- const [didMenuExit, setDidMenuExit] = useState(!open);
61
- const inputRef = useRef(null);
62
- const prefersReducedMotion = usePrefersReducedMotion();
63
- const cls = useClasses('select', classes, className);
64
- const id = useId(idProp);
65
- const helperTextId = useHelperTextId({
66
- helperText,
67
- id,
68
- FormHelperTextProps,
69
- });
70
- const formFieldContentRef = useRef(null);
71
- useEffect(() => {
72
- setAnchorEl(formFieldContentRef.current);
73
- }, []);
74
- const handleOpen = useEventCallback((newOpen) => {
75
- if (disabled && newOpen)
76
- return;
77
- if (newOpen)
78
- setDidMenuExit(false);
79
- setOpen(newOpen);
80
- if (newOpen) {
81
- onOpen?.();
82
- }
83
- else {
84
- onClose?.();
85
- }
86
- });
87
- useEffect(() => {
88
- if (disabled) {
89
- handleOpen(false);
90
- }
91
- }, [disabled, handleOpen]);
92
- const [value, setValue] = useControlled({
93
- controlled: valueProp,
94
- default: defaultValue,
95
- name: 'SuiSelect',
96
- state: 'value',
97
- });
98
- const handleInputChange = useEventCallback((e) => {
99
- onChangeProp?.(e, inputRef.current);
100
- });
101
- const handleClose = useEventCallback(() => {
102
- handleOpen(false);
103
- });
104
- const handleInitialFocus = useEventCallback(() => {
105
- if (data && value !== null) {
106
- if (getSelectedIndex)
107
- return getSelectedIndex(value);
108
- if (Array.isArray(value)) {
109
- const lastSelectedItem = value.at(-1);
110
- return lastSelectedItem ? data.indexOf(lastSelectedItem) : -1;
111
- }
112
- return data.findIndex((v) => v === value);
113
- }
114
- return true;
115
- });
116
- const handleMenuListChange = useEventCallback((newValue) => {
117
- setValue(newValue);
118
- if (inputRef.current) {
119
- Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, 'value')?.set?.call(inputRef.current, newValue);
120
- const event = new Event('input', { bubbles: true });
121
- Object.defineProperty(event, 'target', {
122
- configurable: true,
123
- get: () => {
124
- return new Proxy(inputRef.current, {
125
- get(obj, prop) {
126
- if (prop === 'value') {
127
- return newValue;
128
- }
129
- return obj[prop];
130
- },
131
- });
132
- },
133
- });
134
- inputRef.current?.dispatchEvent(event);
135
- }
136
- });
137
- const { getButtonProps, getListboxProps } = useSelect({
138
- open,
139
- handleOpen,
140
- });
141
- const { contextValue: virtualizedContextValue } = useMenuItemSelect({
142
- value,
143
- onChange: handleMenuListChange,
144
- onClose: handleClose,
145
- selectMode,
146
- });
147
- const virtualizedMenuContextValue = useMemo(() => ({
148
- close: handleClose,
149
- autoFocus: true,
150
- }), [handleClose]);
151
- const selectorProps = getButtonProps(selectorPropsProp);
152
- const selectedValue = value !== null || displayEmpty ? renderValue(value) : null;
153
- const valueId = `${id}-value`;
154
- const labelId = `${id}-label`;
155
- let menu = null;
156
- const baseMenuProps = {
157
- onExitComplete: () => {
158
- setDidMenuExit(true);
159
- },
160
- placement: DEFAULT_PLACEMENT,
161
- open,
162
- anchorEl,
163
- PopperProps: {
164
- offset: 4,
165
- matchAnchorWidth: true,
166
- },
167
- classes: {
168
- paper: cls('menu'),
169
- },
170
- onClose: handleClose,
171
- };
172
- const popperProps = combineProps(baseMenuProps.PopperProps, !virtualize
173
- ? MenuProps?.PopperProps
174
- : virtualizedMenuPropsProp?.PopperProps);
175
- if (popperProps.matchAnchorWidth) {
176
- baseMenuProps.classes = combineClasses(baseMenuProps.classes, {
177
- paper: 'min-w-0',
178
- });
179
- }
180
- if (!virtualize) {
181
- menu = (jsx(Menu, { ...baseMenuProps, ...MenuProps, PopperProps: popperProps, classes: combineClasses(baseMenuProps.classes, MenuProps?.classes), motionProps: getYAxisGrowMotion({
182
- placement: MenuProps?.placement,
183
- prefersReducedMotion: prefersReducedMotion,
184
- }), children: jsx(MenuList, { value: value, onChange: handleMenuListChange, nowrap: false, widget: "select", selectMode: selectMode, ...getListboxProps(), children: children }) }));
185
- }
186
- else {
187
- menu = (jsx(MenuContext.Provider, { value: virtualizedMenuContextValue, children: jsx(MenuItemSelectContext.Provider, { value: virtualizedContextValue, children: jsx(VirtualizedMenu, { ...baseMenuProps, ...virtualizedMenuPropsProp, PopperProps: popperProps, classes: combineClasses(baseMenuProps.classes, virtualizedMenuPropsProp?.classes), initialFocus: handleInitialFocus, data: data, motionProps: getYAxisGrowMotion({
188
- placement: virtualizedMenuPropsProp?.placement,
189
- prefersReducedMotion: prefersReducedMotion,
190
- }), children: children }) }) }));
191
- }
192
- return (jsxs(Fragment, { children: [jsxs(FormField, { disabled: disabled, required: required, variant: variant, error: error, focused: open || (!open && !didMenuExit), htmlFor: id, label: label, labelProps: {
193
- id: labelId,
194
- }, ref: ref, contentRef: formFieldContentRef, helperText: helperText, FormHelperTextProps: { id: helperTextId, ...FormHelperTextProps }, className: cls('root', { error }), classes: {
195
- outlined: cls('outlined'),
196
- standard: cls('standard'),
197
- contained: cls('contained'),
198
- content: cls('content'),
199
- }, size: size, ...rest, children: [jsxs("button", { className: cls('selector', `${variant}-selector`, `${variant}-selector-${size}`, {
200
- expanded: open,
201
- }), type: 'button', disabled: disabled, "aria-labelledby": label ? `${labelId} ${valueId}` : valueId, "aria-describedby": helperTextId, ...selectorProps, id: id, children: [selectedValue ? (jsx("span", { id: valueId, "aria-live": "polite", className: cls('value'), title: getTitle(selectedValue), children: selectedValue })) : (jsx("span", { id: valueId, className: cls('placeholder'), title: getTitle(placeholder), children: placeholder })), jsx(Squircle, { className: cls('chevron'), interactive: false, children: jsx(ExpandCollapseCaret, { size: 'small', expanded: open }) })] }), jsx("input", { ref: inputRef, name: name, value: `${value}`, disabled: disabled, className: cls('native-input'), tabIndex: -1, "aria-hidden": true, "aria-invalid": error, onChange: handleInputChange, ...inputProps })] }), anchorEl && menu] }));
202
- });
203
- Select.displayName = 'SuiSelect';
204
- function getYAxisGrowMotion(params) {
205
- const { placement = DEFAULT_PLACEMENT, ...rest } = params;
206
- let verticalTransformOrigin = 'top';
207
- if (placement === 'top') {
208
- verticalTransformOrigin = 'bottom';
209
- }
210
- return getGrow({
211
- ...rest,
212
- direction: 'y',
213
- transformOrigin: {
214
- vertical: verticalTransformOrigin,
215
- horizontal: 'center',
216
- },
217
- });
218
- }
219
-
220
- export { Select as S, useSelect as u };