@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,164 +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, 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 (!popperPaperContentRef.current)
78
- return;
79
- popperPaperContentRef.current.style.maxHeight = `${availableHeight.current}px`;
80
- if (paperContentContainerRef.current) {
81
- paperContentContainerRef.current.style.height = `auto`;
82
- }
83
- });
84
- const handleTotalListHeightChanged = useEventCallback((listHeight) => {
85
- if (!hasItemsRenderedRef.current) {
86
- return;
87
- }
88
- const adjustedHeight = listHeight + MENU_VERTICAL_PADDING * 2
89
- ;
90
- computedListHeight.current = adjustedHeight;
91
- if (paperContentContainerRef.current) {
92
- paperContentContainerRef.current.style.height = `${adjustedHeight}px`;
93
- }
94
- updateMenuHeight();
95
- popperActions.current?.update();
96
- if (waitForHeightCompute) {
97
- requestAnimationFrame(() => {
98
- setDeferPendingVirtualizedListActions(false);
99
- requestAnimationFrame(() => {
100
- setWaitForHeightCompute(false);
101
- });
102
- });
103
- }
104
- });
105
- const handleAvailableHeightChange = useEventCallback((value) => {
106
- if (computedListHeight.current === -1 || !hasItemsRenderedRef.current) {
107
- return;
108
- }
109
- availableHeight.current = value;
110
- updateMenuHeight();
111
- updatePopoverHeight();
112
- });
113
- useEffect(() => {
114
- if (!open) {
115
- hasItemsRenderedRef.current = false;
116
- }
117
- if (open) {
118
- if (computedListHeight.current !== -1) {
119
- updateMenuHeight();
120
- setWaitForHeightCompute(false);
121
- setDeferPendingVirtualizedListActions(false);
122
- popperActions.current?.update();
123
- }
124
- else {
125
- setMenuHeight(MENU_VERTICAL_PADDING * 2);
126
- setWaitForHeightCompute(true);
127
- setDeferPendingVirtualizedListActions(true);
128
- }
129
- if (popperPaperContentRef.current) {
130
- popperPaperContentRef.current.style.maxHeight = 'none';
131
- }
132
- }
133
- }, [open]);
134
- return (jsx(Popover, { bordered: true, PopperProps: { ...PopperProps, padding: popperPadding }, ...rest, open: open, className: clsx(cls('root'), waitForHeightCompute && 'opacity-0'), PopperPaperProps: {
135
- contentRef: popperPaperContentRef,
136
- }, 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, style: { height: menuHeight }, ...combineProps(VirtualizedListProps, {
137
- ListProps: combineProps(VirtualizedListProps?.ListProps, {
138
- className: cls('list'),
139
- style: {
140
- ['--sui-virtualized-menu-vertical-padding']: `${MENU_VERTICAL_PADDING}px`,
141
- },
142
- }),
143
- totalListHeightChanged: handleTotalListHeightChanged,
144
- itemsRendered: (items) => {
145
- if (totalCount === 0 ||
146
- (totalCount === undefined &&
147
- data !== undefined &&
148
- data.length === 0) ||
149
- (items && items.length > 0)) {
150
- hasItemsRenderedRef.current = true;
151
- }
152
- VirtualizedListProps?.itemsRendered?.(items);
153
- },
154
- onKeyDown: (e) => {
155
- if (e.key === 'Tab') {
156
- e.preventDefault();
157
- onClose?.();
158
- }
159
- },
160
- }), children: children }) }) }) }) }));
161
- });
162
- VirtualizedMenu.displayName = 'SuiVirtualizedMenu';
163
-
164
- 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 };
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, } = {}) => {
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
- : 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,36 +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
- stack.push(id);
18
- }
19
- return () => {
20
- const stack = getFocusTrapStack(globalThis);
21
- const index = stack.indexOf(id);
22
- if (index >= 0) {
23
- stack.splice(index, 1);
24
- }
25
- };
26
- }, [open]);
27
- const isEnabled = useEventCallback(() => {
28
- const stack = getFocusTrapStack(globalThis);
29
- return stack.at(-1) === id;
30
- });
31
- return {
32
- isEnabled,
33
- };
34
- };
35
-
36
- export { useFocusTrapStack as u };
@@ -1,22 +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
-
7
- const FormField = forwardRef((inProps, ref) => {
8
- const props = useThemeProps({ props: inProps, name: 'FormField' });
9
- const { classes, className, children, htmlFor, label, labelProps, helperText, required, disabled, error, variant = 'standard', size = 'xlarge', contentRef, contentProps, focused, FormHelperTextProps, ...rest } = props;
10
- const cls = useClasses('form-field', classes, className);
11
- return (jsxs("div", { ...rest, ref: ref, className: cls('root', variant, { disabled, error, focused }), "aria-disabled": disabled, children: [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') })] }), helperText && (jsx("div", { ...FormHelperTextProps, className: clsx(cls('helper-text', error && 'error-helper-text'), FormHelperTextProps?.className), children: helperText }))] }));
12
- });
13
- FormField.displayName = 'SuiFormField';
14
-
15
- const useHelperTextId = ({ helperText, id, FormHelperTextProps, }) => {
16
- if (!helperText) {
17
- return undefined;
18
- }
19
- return FormHelperTextProps?.id || `${id}-helper-text`;
20
- };
21
-
22
- export { FormField as F, useHelperTextId as u };
@@ -1,199 +0,0 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { useEventCallback } from '@ringcentral/spring-base';
3
- import { createContext, useContext, useRef, useMemo, useImperativeHandle } from 'react';
4
-
5
- const ListNavigationContext = createContext(null);
6
- const useListNavigationContext = () => useContext(ListNavigationContext);
7
-
8
- const useListNavigation = (props) => {
9
- const { preventContainerScroll = true, searchAndFocusItemHandler: searchAndFocusItemHandlerProp = defaultSearchAndFocusItem, actions, } = props;
10
- const currentFocusedItemRef = useRef(null);
11
- const listRef = useRef(null);
12
- const sentinelArrowNavRef = useRef(null);
13
- const sentinelTabBoundaryRef = useRef(null);
14
- const skipEnforceFocusRef = useRef(false);
15
- const focusList = () => {
16
- skipEnforceFocusRef.current = true;
17
- listRef.current.focus();
18
- };
19
- const focusTabBoundary = () => {
20
- skipEnforceFocusRef.current = true;
21
- sentinelTabBoundaryRef.current.focus();
22
- };
23
- const itemActions = useMemo(() => ({
24
- onTab: () => {
25
- skipEnforceFocusRef.current = true;
26
- sentinelTabBoundaryRef.current.focus();
27
- },
28
- onShiftTab: () => {
29
- skipEnforceFocusRef.current = true;
30
- listRef.current.focus();
31
- },
32
- updateFocusedItem: (el) => {
33
- currentFocusedItemRef.current = el;
34
- },
35
- }), []);
36
- const focusFirstItem = useEventCallback(() => {
37
- const { focused } = searchAndFocusItemHandler('first');
38
- if (!focused) {
39
- focusList();
40
- }
41
- });
42
- useImperativeHandle(actions, () => ({
43
- focus: focusFirstItem,
44
- }), []);
45
- const sentinelFocusHandler = (e) => {
46
- if (e.target === e.currentTarget) {
47
- const skipEnforceFocus = skipEnforceFocusRef.current;
48
- if (skipEnforceFocus) {
49
- skipEnforceFocusRef.current = false;
50
- return;
51
- }
52
- focusFirstItem();
53
- }
54
- };
55
- const searchAndFocusItemHandler = (searchElementOption) => {
56
- return searchAndFocusItemHandlerProp(searchElementOption, {
57
- sentinelEnd: sentinelArrowNavRef.current,
58
- list: listRef.current,
59
- });
60
- };
61
- const listKeyDownHandler = (e) => {
62
- const focusedItem = currentFocusedItemRef.current;
63
- const key = e.key;
64
- if (focusedItem) {
65
- const searchElementOption = {
66
- ArrowDown: {
67
- baseElement: focusedItem,
68
- direction: 'down',
69
- },
70
- ArrowUp: {
71
- baseElement: focusedItem,
72
- direction: 'up',
73
- },
74
- Home: 'first',
75
- End: 'last',
76
- }[key];
77
- if (searchElementOption) {
78
- const { focused, isAfterBaseElement } = searchAndFocusItemHandler(searchElementOption);
79
- if (!focused) {
80
- focusList();
81
- }
82
- if (!isAfterBaseElement || preventContainerScroll) {
83
- e.preventDefault();
84
- }
85
- }
86
- }
87
- else {
88
- if (e.target === e.currentTarget && key === 'Tab' && !e.shiftKey) {
89
- focusTabBoundary();
90
- }
91
- }
92
- };
93
- const getListProps = (otherHandler) => {
94
- const { onKeyDown, onFocus } = otherHandler;
95
- const handleKeyDown = (e) => {
96
- onKeyDown?.(e);
97
- if (e.defaultPrevented) {
98
- return;
99
- }
100
- listKeyDownHandler(e);
101
- };
102
- const handleFocus = (e) => {
103
- sentinelFocusHandler(e);
104
- onFocus?.(e);
105
- };
106
- return {
107
- tabIndex: 0,
108
- onKeyDown: handleKeyDown,
109
- onFocus: handleFocus,
110
- };
111
- };
112
- const renderItems = (items) => {
113
- return (jsxs(ListNavigationContext.Provider, { value: itemActions, children: [items, jsx("div", { "aria-hidden": "true", ref: sentinelArrowNavRef })] }));
114
- };
115
- const renderTabBoundary = () => {
116
- return (jsx("div", { style: { position: 'fixed', bottom: '50%' }, ref: sentinelTabBoundaryRef, tabIndex: 0, onFocus: sentinelFocusHandler }));
117
- };
118
- return { renderItems, renderTabBoundary, getListProps, listRef };
119
- };
120
- const isUnfocusable = (el) => el.matches('.sui-disabled, :disabled, hr, [role="separator"], [disabled]');
121
- const defaultSearchAndFocusItem = (searchElementOption, helperElements) => {
122
- const { list, sentinelEnd } = helperElements;
123
- if (list.firstElementChild === sentinelEnd) {
124
- return { focused: false };
125
- }
126
- const getFirstItem = () => {
127
- const firstItem = list.firstElementChild;
128
- if (firstItem === sentinelEnd) {
129
- throw Error('SPRING [useListNavigation]: must have child element');
130
- }
131
- return firstItem;
132
- };
133
- const getLastItem = () => {
134
- const lastItem = sentinelEnd.previousElementSibling;
135
- if (!lastItem) {
136
- throw Error('SPRING [useListNavigation]: must have child element');
137
- }
138
- return lastItem;
139
- };
140
- let direction;
141
- let startElement;
142
- if (typeof searchElementOption === 'string') {
143
- if (searchElementOption === 'first') {
144
- startElement = getFirstItem();
145
- direction = 'down';
146
- }
147
- else {
148
- startElement = getLastItem();
149
- direction = 'up';
150
- }
151
- if (!isUnfocusable(startElement)) {
152
- startElement.focus();
153
- return { focused: true };
154
- }
155
- }
156
- else {
157
- startElement = searchElementOption.baseElement;
158
- direction = searchElementOption.direction;
159
- }
160
- let pointer = startElement;
161
- let isAfterBaseElement = true;
162
- if (direction === 'up') {
163
- do {
164
- if (!pointer.previousElementSibling) {
165
- pointer = getLastItem();
166
- isAfterBaseElement = false;
167
- }
168
- else {
169
- pointer = pointer.previousElementSibling;
170
- }
171
- if (!isUnfocusable(pointer)) {
172
- break;
173
- }
174
- } while (pointer !== startElement);
175
- }
176
- else {
177
- do {
178
- if (pointer.nextElementSibling === sentinelEnd) {
179
- pointer = getFirstItem();
180
- isAfterBaseElement = false;
181
- }
182
- else {
183
- pointer = pointer.nextElementSibling;
184
- }
185
- if (!isUnfocusable(pointer)) {
186
- break;
187
- }
188
- } while (pointer !== startElement);
189
- }
190
- if (isUnfocusable(pointer)) {
191
- return { focused: false };
192
- }
193
- pointer.focus();
194
- return typeof searchElementOption === 'string'
195
- ? { focused: true }
196
- : { focused: true, isAfterBaseElement };
197
- };
198
-
199
- export { ListNavigationContext as L, useListNavigation as a, useListNavigationContext as u };