@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/Dropdown.js CHANGED
@@ -1,129 +1,206 @@
1
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import { forwardRef, useState, useRef, useEffect } from 'react';
3
- import { useControlled, useClasses, useEventCallback, combineProps, useFocusVisible, useForkRef } from '@ringcentral/spring-base';
4
- import { useThemeProps } from '@ringcentral/spring-theme';
5
- import { E as ExpandCollapseCaret } from './chunks/ExpandCollapseCaret.js';
6
- import 'framer-motion';
7
- import './chunks/Icon.js';
8
- import { M as Menu } from './chunks/Menu.js';
9
- import { c as useMenuItemSelect, a as MenuItemSelectContext } from './chunks/useMenuItemSelect.js';
10
- import '@mui/utils';
11
- import 'tabbable';
12
- import './chunks/useListNavigation.js';
13
- import './VirtualizedList.js';
14
- import { M as MenuList } from './chunks/MenuList.js';
15
- import { S as Squircle } from './chunks/Squircle.js';
16
- import { a as VirtualizedMenu } from './chunks/VirtualizedMenu.js';
17
- import './chunks/useMotionSafeTransition.js';
18
- import './chunks/usePrefersReducedMotion.js';
19
- import './chunks/useNestedParentMenu.js';
20
- import './chunks/Popover.js';
21
- import '@floating-ui/react-dom';
22
- import './chunks/getGrow.js';
23
- import './chunks/Modal.js';
24
- import '@mui/base';
25
- import './chunks/getFade.js';
26
- import './chunks/useFocusTrapStack.js';
27
- import './chunks/Backdrop.js';
28
- import './Popper.js';
29
- import './chunks/PopperPaper.js';
30
- import '@ringcentral/spring-icon';
31
- import './chunks/useAnimationFrame.js';
32
- import './chunks/useNestedMenuItem.js';
33
- import './chunks/composeEventHandlers.js';
34
- import './ListNavigation.js';
35
- import 'react-virtuoso';
36
- import './chunks/List.js';
37
- import 'clsx';
38
-
39
- var Dropdown$1 = {"sui-dropdown-value":"sui-dropdown-value","sui-dropdown-chevron":"sui-dropdown-chevron","sui-dropdown-button":"sui-dropdown-button","sui-focus-visible":"sui-focus-visible","sui-dropdown-label":"sui-dropdown-label","sui-dropdown-colon":"sui-dropdown-colon","sui-dropdown-activated":"sui-dropdown-activated","sui-dropdown-root":"sui-dropdown-root","sui-disabled":"sui-disabled"};
40
-
41
- const Dropdown = forwardRef((inProps, ref) => {
42
- const props = useThemeProps({ props: inProps, name: 'Dropdown' });
43
- const { classes, className, children, defaultOpen, open: openProp, onOpenChange, autoFocus = false, disabled, virtualize = true, MenuProps, rootProps, buttonProps: buttonPropsProp = {}, value: valueProp, defaultValue = null, onChange: onChangeProp, renderValue = String, placeholder, label, buttonRef, getSelectedIndex = (value) => {
44
- return data.findIndex((v) => v === value);
45
- }, data, } = props;
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { forwardRef, useEffect, useMemo, useRef, useState } from "react";
3
+ import { combineProps, useClasses, useControlled, useEventCallback, useFocusVisible, useForkRef } from "@ringcentral/spring-base";
4
+ import { useThemeProps } from "@ringcentral/spring-theme";
5
+ import "./chunks/4476.js";
6
+ import { Menu as Menu_Menu } from "./Menu.js";
7
+ import { MenuItemSelectContext, useMenuItemSelect, MenuListContext } from "./MenuItem.js";
8
+ import { MenuList as MenuList_MenuList } from "./MenuList.js";
9
+ import "./Squircle.js";
10
+ import { VirtualizedMenu as VirtualizedMenu_VirtualizedMenu } from "./VirtualizedMenu.js";
11
+ import { Squircle as Squircle_Squircle } from "./chunks/1250.js";
12
+ import { ExpandCollapseCaret as ExpandCollapseCaret_ExpandCollapseCaret } from "./chunks/1294.js";
13
+
14
+
15
+
16
+
17
+
18
+ // extracted by css-extract-rspack-plugin
19
+ /* export default */ var Dropdown = ({"sui-dropdown-value":"sui-dropdown-value","sui-dropdown-chevron":"sui-dropdown-chevron","sui-dropdown-button":"sui-dropdown-button","sui-focus-visible":"sui-focus-visible","sui-dropdown-label":"sui-dropdown-label","sui-dropdown-colon":"sui-dropdown-colon","sui-dropdown-activated":"sui-dropdown-activated","sui-dropdown-root":"sui-dropdown-root","sui-disabled":"sui-disabled"});
20
+
21
+
22
+
23
+
24
+
25
+
26
+
27
+
28
+
29
+
30
+
31
+ const Dropdown_Dropdown = /*#__PURE__*/ forwardRef((inProps, ref)=>{
32
+ const props = useThemeProps({
33
+ props: inProps,
34
+ name: 'Dropdown'
35
+ });
36
+ const { classes, className, children, defaultOpen, open: openProp, onOpenChange, autoFocus = false, disabled, virtualize = true, MenuProps, rootProps, buttonProps: buttonPropsProp = {}, value: valueProp, defaultValue = null, onChange: onChangeProp, renderValue = String, placeholder, label, buttonRef, getSelectedIndex = (value)=>{
37
+ return data.findIndex((v)=>v === value);
38
+ }, data } = props;
46
39
  const [anchorEl, setAnchorEl] = useState(null);
47
40
  const [open, setOpen] = useControlled({
48
41
  controlled: openProp,
49
42
  default: defaultOpen,
50
43
  name: 'SuiSelect',
51
- state: 'open',
44
+ state: 'open'
52
45
  });
53
46
  const chevronRef = useRef(null);
54
- useEffect(() => {
47
+ useEffect(()=>{
55
48
  setAnchorEl(chevronRef.current);
56
49
  }, []);
57
50
  const cls = useClasses('dropdown', classes, className);
58
- const handleOpen = useEventCallback((isOpen) => {
51
+ const handleOpen = useEventCallback((isOpen)=>{
52
+ // prevent trigger onOpenChange when open state is not change
59
53
  if (open !== isOpen) {
54
+ // for uncontrolled mode
60
55
  setOpen(isOpen);
56
+ // for controlled mode
61
57
  onOpenChange?.(isOpen);
62
58
  }
63
59
  });
64
- const handleClose = useEventCallback(() => {
60
+ const handleClose = useEventCallback(()=>{
65
61
  handleOpen(false);
66
62
  });
67
63
  const [value, setValue] = useControlled({
68
64
  controlled: valueProp,
69
65
  default: defaultValue,
70
66
  name: 'SuiDropdown',
71
- state: 'value',
67
+ state: 'value'
72
68
  });
73
- const handleMenuListChange = useEventCallback((newValue) => {
69
+ const handleMenuListChange = useEventCallback((newValue)=>{
70
+ // for uncontrolled mode
74
71
  setValue(newValue);
72
+ // for controlled mode
75
73
  onChangeProp?.(newValue);
76
74
  handleOpen(false);
77
75
  });
78
76
  const { contextValue: virtualizedMenuContextValue } = useMenuItemSelect({
79
77
  value,
80
78
  onChange: handleMenuListChange,
81
- onClose: handleClose,
79
+ onClose: handleClose
82
80
  });
81
+ const menuListContextValue = useMemo(()=>({
82
+ nowrap: true
83
+ }), []);
83
84
  const buttonProps = combineProps({
84
- onClick: () => {
85
- if (!disabled && !open)
86
- handleOpen(true);
85
+ onClick: ()=>{
86
+ if (!disabled && !open) handleOpen(true);
87
87
  },
88
- onKeyDown: (e) => {
88
+ onKeyDown: (e)=>{
89
89
  if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
90
+ // prevent scroll
90
91
  e.preventDefault();
91
- if (!disabled)
92
- handleOpen(true);
92
+ if (!disabled) handleOpen(true);
93
93
  }
94
- },
94
+ }
95
95
  }, buttonPropsProp);
96
96
  const { focusVisible, focusVisibleRef, focusVisibleHandlers } = useFocusVisible(buttonProps);
97
97
  const handleButtonRef = useForkRef(buttonRef, focusVisibleRef);
98
- useEffect(() => {
98
+ useEffect(()=>{
99
+ // close menu when disabled
99
100
  if (disabled) {
100
101
  handleOpen(false);
101
102
  }
102
- }, [disabled, handleOpen]);
103
+ }, [
104
+ disabled,
105
+ handleOpen
106
+ ]);
103
107
  const baseMenuProps = {
104
- placement: 'top',
108
+ placement: 'bottom',
105
109
  open,
106
110
  anchorEl,
107
- onClose: handleClose,
111
+ onClose: handleClose
108
112
  };
109
113
  let menu = null;
110
114
  if (!virtualize) {
111
- menu = (jsx(Menu, { ...baseMenuProps, ...MenuProps, children: jsx(MenuList, { value: value, onChange: handleMenuListChange, nowrap: false, widget: "menu", children: children }) }));
112
- }
113
- else {
114
- menu = (jsx(MenuItemSelectContext.Provider, { value: virtualizedMenuContextValue, children: jsx(VirtualizedMenu, { ...baseMenuProps, ...MenuProps, initialFocus: () => {
115
- if (value !== null)
116
- return getSelectedIndex(value);
115
+ menu = /*#__PURE__*/ jsx(Menu_Menu, {
116
+ ...baseMenuProps,
117
+ ...MenuProps,
118
+ children: /*#__PURE__*/ jsx(MenuList_MenuList, {
119
+ value: value,
120
+ onChange: handleMenuListChange,
121
+ nowrap: menuListContextValue.nowrap,
122
+ widget: "menu",
123
+ children: children
124
+ })
125
+ });
126
+ } else {
127
+ menu = /*#__PURE__*/ jsx(MenuItemSelectContext.Provider, {
128
+ value: virtualizedMenuContextValue,
129
+ children: /*#__PURE__*/ jsx(VirtualizedMenu_VirtualizedMenu, {
130
+ ...baseMenuProps,
131
+ ...MenuProps,
132
+ initialFocus: ()=>{
133
+ if (value !== null) return getSelectedIndex(value);
117
134
  return true;
118
- }, data: data, children: children }) }));
135
+ },
136
+ data: data,
137
+ children: children
138
+ })
139
+ });
119
140
  }
120
- return (jsxs(Fragment, { children: [jsxs("div", { "aria-disabled": disabled, ...rootProps, className: cls('root', {
121
- disabled,
122
- }), ref: ref, children: [label && (jsxs(Fragment, { children: [jsx("span", { className: cls('label'), children: label }), jsx("span", { className: cls('colon'), children: ":" })] })), jsxs("button", { className: cls('button', {
141
+ return /*#__PURE__*/ jsxs(Fragment, {
142
+ children: [
143
+ /*#__PURE__*/ jsxs("div", {
144
+ "aria-disabled": disabled,
145
+ ...rootProps,
146
+ className: cls('root', {
147
+ disabled
148
+ }),
149
+ ref: ref,
150
+ children: [
151
+ label && /*#__PURE__*/ jsxs(Fragment, {
152
+ children: [
153
+ /*#__PURE__*/ jsx("span", {
154
+ className: cls('label'),
155
+ children: label
156
+ }),
157
+ /*#__PURE__*/ jsx("span", {
158
+ className: cls('colon'),
159
+ children: ":"
160
+ })
161
+ ]
162
+ }),
163
+ /*#__PURE__*/ jsxs("button", {
164
+ className: cls('button', {
123
165
  activated: open,
124
- focusVisible,
125
- }), ...buttonProps, ...focusVisibleHandlers, type: "button", autoFocus: autoFocus && !disabled, disabled: disabled, ref: handleButtonRef, children: [jsx("span", { className: cls('value'), children: value === null ? placeholder : renderValue(value) }), jsx(Squircle, { className: cls('chevron'), interactive: false, ref: chevronRef, children: jsx(ExpandCollapseCaret, { size: 'small', expanded: open }) })] })] }), anchorEl && menu] }));
166
+ focusVisible
167
+ }),
168
+ ...buttonProps,
169
+ ...focusVisibleHandlers,
170
+ type: "button",
171
+ autoFocus: autoFocus && !disabled,
172
+ disabled: disabled,
173
+ ref: handleButtonRef,
174
+ children: [
175
+ /*#__PURE__*/ jsx("span", {
176
+ className: cls('value'),
177
+ children: value === null ? placeholder : renderValue(value)
178
+ }),
179
+ /*#__PURE__*/ jsx(Squircle_Squircle, {
180
+ className: cls('chevron'),
181
+ interactive: false,
182
+ ref: chevronRef,
183
+ children: /*#__PURE__*/ jsx(ExpandCollapseCaret_ExpandCollapseCaret, {
184
+ size: 'small',
185
+ expanded: open
186
+ })
187
+ })
188
+ ]
189
+ })
190
+ ]
191
+ }),
192
+ /*#__PURE__*/ jsx(MenuListContext.Provider, {
193
+ value: menuListContextValue,
194
+ children: anchorEl && menu
195
+ })
196
+ ]
197
+ });
126
198
  });
127
- Dropdown.displayName = 'SuiDropdown';
199
+ Dropdown_Dropdown.displayName = 'SuiDropdown';
200
+
201
+
202
+
203
+
204
+
128
205
 
129
- export { Dropdown, Dropdown$1 as dropdownStyle };
206
+ export { Dropdown as dropdownStyle, Dropdown_Dropdown as Dropdown };
package/EmptyState.js CHANGED
@@ -1,19 +1,69 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { forwardRef } from 'react';
3
- import { useClasses, getTitle } from '@ringcentral/spring-base';
4
- import { useThemeProps } from '@ringcentral/spring-theme';
5
- import { h as hasContent } from './chunks/hasContent.js';
6
- import '@mui/utils';
7
- import { I as Icon } from './chunks/Icon.js';
8
-
9
- var EmptyState$1 = {"sui-empty-state-root":"sui-empty-state-root","sui-empty-state-icon":"sui-empty-state-icon","sui-empty-state-text-container":"sui-empty-state-text-container","sui-empty-state-title":"sui-empty-state-title","sui-empty-state-description":"sui-empty-state-description","sui-empty-state-actions":"sui-empty-state-actions"};
10
-
11
- const EmptyState = forwardRef((inProps, ref) => {
12
- const props = useThemeProps({ props: inProps, name: 'EmptyState' });
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { getTitle, useClasses } from "@ringcentral/spring-base";
4
+ import { useThemeProps } from "@ringcentral/spring-theme";
5
+ import { Icon as Icon_Icon } from "./chunks/8307.js";
6
+ import { hasContent } from "./chunks/5047.js";
7
+
8
+
9
+
10
+
11
+
12
+ // extracted by css-extract-rspack-plugin
13
+ /* export default */ var EmptyState = ({"sui-empty-state-root":"sui-empty-state-root","sui-empty-state-icon":"sui-empty-state-icon","sui-empty-state-text-container":"sui-empty-state-text-container","sui-empty-state-title":"sui-empty-state-title","sui-empty-state-description":"sui-empty-state-description","sui-empty-state-actions":"sui-empty-state-actions"});
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+ const EmptyState_EmptyState = /*#__PURE__*/ forwardRef((inProps, ref)=>{
22
+ const props = useThemeProps({
23
+ props: inProps,
24
+ name: 'EmptyState'
25
+ });
13
26
  const { classes, className, title, description, icon, actions, ...rest } = props;
14
27
  const cls = useClasses('empty-state', classes, className);
15
- return (jsxs("div", { ...rest, ref: ref, className: cls('root'), children: [icon && (jsx("div", { className: cls('icon'), children: jsx(Icon, { size: "xxxlarge", symbol: icon }) })), (hasContent(title) || hasContent(description)) && (jsxs("div", { className: cls('text-container'), children: [hasContent(title) && (jsx("span", { className: cls('title'), title: getTitle(title), children: title })), hasContent(description) && (jsx("span", { className: cls('description'), title: getTitle(description), children: description }))] })), actions && actions.length > 0 && (jsx("div", { className: cls('actions'), children: actions }))] }));
28
+ return /*#__PURE__*/ jsxs("div", {
29
+ ...rest,
30
+ ref: ref,
31
+ className: cls('root'),
32
+ children: [
33
+ icon && /*#__PURE__*/ jsx("div", {
34
+ className: cls('icon'),
35
+ children: /*#__PURE__*/ jsx(Icon_Icon, {
36
+ size: "xxxlarge",
37
+ symbol: icon
38
+ })
39
+ }),
40
+ (hasContent(title) || hasContent(description)) && /*#__PURE__*/ jsxs("div", {
41
+ className: cls('text-container'),
42
+ children: [
43
+ hasContent(title) && /*#__PURE__*/ jsx("span", {
44
+ className: cls('title'),
45
+ title: getTitle(title),
46
+ children: title
47
+ }),
48
+ hasContent(description) && /*#__PURE__*/ jsx("span", {
49
+ className: cls('description'),
50
+ title: getTitle(description),
51
+ children: description
52
+ })
53
+ ]
54
+ }),
55
+ actions && actions.length > 0 && /*#__PURE__*/ jsx("div", {
56
+ className: cls('actions'),
57
+ children: actions
58
+ })
59
+ ]
60
+ });
16
61
  });
17
- EmptyState.displayName = 'SuiEmptyState';
62
+ EmptyState_EmptyState.displayName = 'SuiEmptyState';
63
+
64
+
65
+
66
+
67
+
18
68
 
19
- export { EmptyState, EmptyState$1 as emptyStateStyle };
69
+ export { EmptyState as emptyStateStyle, EmptyState_EmptyState as EmptyState };
package/FabButton.js CHANGED
@@ -1,32 +1,66 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { forwardRef, useState } from 'react';
3
- import { useButton } from '@mui/base';
4
- import { useClasses } from '@ringcentral/spring-base';
5
- import { useThemeProps } from '@ringcentral/spring-theme';
6
- import { I as Icon } from './chunks/Icon.js';
7
- import { S as Squircle } from './chunks/Squircle.js';
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useState } from "react";
3
+ import { useButton } from "@mui/base";
4
+ import { useClasses } from "@ringcentral/spring-base";
5
+ import { useThemeProps } from "@ringcentral/spring-theme";
6
+ import { Icon as Icon_Icon } from "./chunks/8307.js";
7
+ import { Squircle as Squircle_Squircle } from "./chunks/1250.js";
8
+
9
+
10
+
11
+
12
+
13
+
14
+ // extracted by css-extract-rspack-plugin
15
+ /* export default */ var FabButton = ({"sui-fab-button-root":"sui-fab-button-root","sui-fab-button-large":"sui-fab-button-large","sui-fab-button-small":"sui-fab-button-small","sui-fab-button-activated":"sui-fab-button-activated","sui-active":"sui-active"});
16
+
17
+
18
+
19
+
20
+
21
+
8
22
 
9
- var FabButton$1 = {"sui-fab-button-root":"sui-fab-button-root","sui-fab-button-large":"sui-fab-button-large","sui-fab-button-small":"sui-fab-button-small","sui-fab-button-activated":"sui-fab-button-activated","sui-active":"sui-active"};
10
23
 
11
24
  const IconSizeMap = {
12
25
  large: 'medium',
13
- small: 'small',
26
+ small: 'small'
14
27
  };
15
- const FabButton = forwardRef((inProps, ref) => {
16
- const props = useThemeProps({ props: inProps, name: 'FabButton' });
28
+ const FabButton_FabButton = /*#__PURE__*/ forwardRef((inProps, ref)=>{
29
+ const props = useThemeProps({
30
+ props: inProps,
31
+ name: 'FabButton'
32
+ });
17
33
  const { classes, className, symbol, size = 'large', onClick, ...rest } = props;
18
34
  const [activated, setActivated] = useState(false);
19
35
  const cls = useClasses('fab-button', classes, className);
20
- const clickHandler = (e) => {
21
- setActivated((pre) => !pre);
36
+ const clickHandler = (e)=>{
37
+ setActivated((pre)=>!pre);
22
38
  onClick && onClick(e);
23
39
  };
24
40
  const { getRootProps, focusVisible } = useButton({
25
41
  ...props,
26
- rootRef: ref,
42
+ rootRef: ref
43
+ });
44
+ return /*#__PURE__*/ jsx(Squircle_Squircle, {
45
+ component: "button",
46
+ className: cls('root', size, {
47
+ activated
48
+ }),
49
+ focusVisible: focusVisible,
50
+ ...rest,
51
+ ...getRootProps(),
52
+ onClick: clickHandler,
53
+ children: /*#__PURE__*/ jsx(Icon_Icon, {
54
+ size: IconSizeMap[size],
55
+ symbol: symbol
56
+ })
27
57
  });
28
- return (jsx(Squircle, { component: "button", className: cls('root', size, { activated }), focusVisible: focusVisible, ...rest, ...getRootProps(), onClick: clickHandler, children: jsx(Icon, { size: IconSizeMap[size], symbol: symbol }) }));
29
58
  });
30
- FabButton.displayName = 'SuiFabButton';
59
+ FabButton_FabButton.displayName = 'SuiFabButton';
60
+
61
+
62
+
63
+
64
+
31
65
 
32
- export { FabButton, FabButton$1 as fabButtonStyle };
66
+ export { FabButton as fabButtonStyle, FabButton_FabButton as FabButton };
package/FocusTrap.js CHANGED
@@ -1,16 +1,113 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { FocusTrap as FocusTrap$1 } from '@mui/base';
3
- import { useImperativeHandle } from 'react';
4
- import { u as useFocusTrapStack } from './chunks/useFocusTrapStack.js';
5
- import '@ringcentral/spring-base';
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { FocusTrap } from "@mui/base";
3
+ import { useEffect, useImperativeHandle } from "react";
4
+ import { useEventCallback, useId, useWindowContext } from "@ringcentral/spring-base";
6
5
 
7
- const FocusTrap = (props) => {
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+ const FOCUS_TRAP_STACK = '__SUI_FOCUS_TRAP_STACK__';
14
+ // use global to ensure the work in the same window
15
+ const getFocusTrapStack = (global)=>{
16
+ // @ts-ignore
17
+ if (!global[FOCUS_TRAP_STACK]) {
18
+ // @ts-ignore
19
+ global[FOCUS_TRAP_STACK] = [];
20
+ }
21
+ // @ts-ignore
22
+ return global[FOCUS_TRAP_STACK];
23
+ };
24
+ /**
25
+ * Hook to manage focus trap stack for proper layering and focus management
26
+ */ const useFocusTrapStack = ({ open })=>{
27
+ const { globalThis } = useWindowContext();
28
+ const id = useId();
29
+ useEffect(()=>{
30
+ if (open) {
31
+ const stack = getFocusTrapStack(globalThis);
32
+ if (stack.indexOf(id) < 0) {
33
+ stack.push(id);
34
+ }
35
+ }
36
+ return ()=>{
37
+ const stack = getFocusTrapStack(globalThis);
38
+ const index = stack.indexOf(id);
39
+ if (index >= 0) {
40
+ stack.splice(index, 1);
41
+ }
42
+ };
43
+ // oxlint-disable-next-line react-hooks/exhaustive-deps
44
+ }, [
45
+ open
46
+ ]);
47
+ const isEnabled = useEventCallback(()=>{
48
+ const stack = getFocusTrapStack(globalThis);
49
+ return stack.at(-1) === id;
50
+ });
51
+ return {
52
+ isEnabled
53
+ };
54
+ };
55
+
56
+
57
+
58
+
59
+
60
+ /**
61
+ * Utility component that locks focus inside the component.
62
+ *
63
+ * @deprecated This component is deprecated. Use `useFocusTrapStack` hook directly with MUI's FocusTrap instead.
64
+ *
65
+ * @example
66
+ * ```tsx
67
+ * import { FocusTrap } from '@mui/base';
68
+ * import { useFocusTrapStack } from '@ringcentral/spring-ui';
69
+ *
70
+ * function MyModal({ open, children }) {
71
+ * // Call useFocusTrapStack where the `open` prop changes first (typically in Modal/Dialog)
72
+ * // This prevents race conditions between stack registration and autofocus behavior
73
+ * const { isEnabled } = useFocusTrapStack({ open });
74
+ *
75
+ * return open ? (
76
+ * <Portal>
77
+ * <div className="modal-backdrop">
78
+ * <FocusTrap
79
+ * open={open}
80
+ * isEnabled={isEnabled}
81
+ * >
82
+ * <div className="modal-content" tabIndex={-1}>
83
+ * {children}
84
+ * </div>
85
+ * </FocusTrap>
86
+ * </div>
87
+ * </Portal>
88
+ * ) : null;
89
+ * }
90
+ * ```
91
+ */ const FocusTrap_FocusTrap = (props)=>{
8
92
  const { open, children, action, ...rest } = props;
9
- const { isEnabled } = useFocusTrapStack({ open });
10
- useImperativeHandle(action, () => ({
11
- isEnabled,
12
- }), [isEnabled]);
13
- return (jsx(FocusTrap$1, { ...rest, open: open, isEnabled: isEnabled, children: children }));
93
+ const { isEnabled } = useFocusTrapStack({
94
+ open
95
+ });
96
+ useImperativeHandle(action, ()=>({
97
+ isEnabled
98
+ }), [
99
+ isEnabled
100
+ ]);
101
+ return /*#__PURE__*/ jsx(FocusTrap, {
102
+ ...rest,
103
+ open: open,
104
+ isEnabled: isEnabled,
105
+ children: children
106
+ });
14
107
  };
15
108
 
16
- export { FocusTrap, useFocusTrapStack };
109
+
110
+
111
+
112
+
113
+ export { FocusTrap_FocusTrap as FocusTrap, useFocusTrapStack };