@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,49 +1,96 @@
1
- import { useDndContext, KeyboardCode, useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, closestCenter } from '@dnd-kit/core';
2
- import { ownerDocument } from '@ringcentral/spring-base';
3
- import { useEffect } from 'react';
4
- import { jsxs, jsx } from 'react/jsx-runtime';
5
- import { sortableKeyboardCoordinates } from '@dnd-kit/sortable';
6
- export { arrayMove } from '@dnd-kit/sortable';
7
- import { useThemeProps } from '@ringcentral/spring-theme';
8
-
9
- const DndKeyboardBlocker = () => {
1
+ import { DndContext, KeyboardCode, KeyboardSensor, PointerSensor, closestCenter, useDndContext, useSensor, useSensors } from "@dnd-kit/core";
2
+ import { ownerDocument } from "@ringcentral/spring-base";
3
+ import { useEffect } from "react";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { arrayMove, sortableKeyboardCoordinates } from "@dnd-kit/sortable";
6
+ import { useThemeProps } from "@ringcentral/spring-theme";
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+ const DndKeyboardBlocker = ()=>{
10
15
  const { activeNode } = useDndContext();
11
- useEffect(() => {
16
+ useEffect(()=>{
12
17
  if (activeNode) {
13
18
  const externalDocument = ownerDocument(activeNode);
14
- const listener = (e) => {
19
+ const listener = (e)=>{
15
20
  if (e.key === 'Tab') {
16
21
  e.preventDefault();
17
22
  }
18
23
  };
19
24
  externalDocument.addEventListener('keydown', listener);
20
- return () => externalDocument.removeEventListener('keydown', listener);
25
+ return ()=>externalDocument.removeEventListener('keydown', listener);
21
26
  }
22
27
  return undefined;
23
- }, [activeNode]);
28
+ }, [
29
+ activeNode
30
+ ]);
24
31
  return null;
25
32
  };
26
33
 
27
- const pointerSensorOpts = { activationConstraint: { distance: 10 } };
34
+
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+ const pointerSensorOpts = {
44
+ activationConstraint: {
45
+ distance: 10
46
+ }
47
+ };
28
48
  const keyboardSensorOpts = {
29
49
  coordinateGetter: sortableKeyboardCoordinates,
30
50
  keyboardCodes: {
31
- start: [KeyboardCode.Space],
32
- cancel: [KeyboardCode.Esc],
33
- end: [KeyboardCode.Space, KeyboardCode.Enter],
34
- },
51
+ start: [
52
+ KeyboardCode.Space
53
+ ],
54
+ cancel: [
55
+ KeyboardCode.Esc
56
+ ],
57
+ end: [
58
+ KeyboardCode.Space,
59
+ KeyboardCode.Enter
60
+ ]
61
+ }
35
62
  };
36
- const SortableListDndContext = (inProps) => {
63
+ const SortableListDndContext = (inProps)=>{
37
64
  const props = useThemeProps({
38
65
  props: inProps,
39
- name: 'SortableListDndContext',
66
+ name: 'SortableListDndContext'
40
67
  });
41
68
  const { children, collisionDetection = closestCenter, ...rest } = props;
42
69
  const sensors = useSensors(useSensor(PointerSensor, pointerSensorOpts), useSensor(KeyboardSensor, keyboardSensorOpts));
43
- return (jsxs(DndContext, { sensors: sensors, collisionDetection: collisionDetection, ...rest, children: [jsx(DndKeyboardBlocker, {}), children] }));
70
+ return /*#__PURE__*/ jsxs(DndContext, {
71
+ sensors: sensors,
72
+ collisionDetection: collisionDetection,
73
+ ...rest,
74
+ children: [
75
+ /*#__PURE__*/ jsx(DndKeyboardBlocker, {}),
76
+ children
77
+ ]
78
+ });
44
79
  };
45
80
  SortableListDndContext.displayName = 'SortableListDndContext';
46
81
 
82
+
83
+
84
+
47
85
  const useSortableListDndContext = useDndContext;
48
86
 
49
- export { DndKeyboardBlocker, SortableListDndContext, useSortableListDndContext };
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+ export { DndKeyboardBlocker, SortableListDndContext, arrayMove, useSortableListDndContext };
@@ -1,81 +1,126 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { useSortable } from '@dnd-kit/sortable';
3
- import { CSS } from '@dnd-kit/utilities';
4
- import { useForkRef, combineProps, useWindowContext } from '@ringcentral/spring-base';
5
- import { forwardRef } from 'react';
6
- import { useTheme } from '@ringcentral/spring-theme';
7
- import 'framer-motion';
8
- import './chunks/Icon.js';
9
- import { L as ListItem } from './chunks/ListItem.js';
10
- import { useDndContext, DragOverlay } from '@dnd-kit/core';
11
- import { Portal } from '@mui/base';
12
- import './chunks/Divider.js';
13
- import './ListNavigation.js';
14
- import './chunks/useListNavigation.js';
15
- import 'tabbable';
16
- import './VirtualizedList.js';
17
- import 'react-virtuoso';
18
- import './chunks/useAnimationFrame.js';
19
- import './chunks/List.js';
20
- import './chunks/useMotionSafeTransition.js';
21
- import './chunks/usePrefersReducedMotion.js';
22
- import './chunks/SlideIn.js';
23
- import './chunks/getSlideIn.js';
24
-
25
- const SortableListItem = forwardRef((props, ref) => {
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useSortable } from "@dnd-kit/sortable";
3
+ import { CSS } from "@dnd-kit/utilities";
4
+ import { combineProps, useForkRef, useWindowContext } from "@ringcentral/spring-base";
5
+ import { forwardRef } from "react";
6
+ import { DragOverlay, useDndContext } from "@dnd-kit/core";
7
+ import { useTheme } from "@ringcentral/spring-theme";
8
+ import { ListItem as ListItem_ListItem } from "./ListItem.js";
9
+ import { Portal } from "./Portal.js";
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+ const SortableListItem = /*#__PURE__*/ forwardRef((props, ref)=>{
26
23
  const { style, children, dragId, role = 'listitem', ...rest } = props;
27
- const { setNodeRef, setActivatorNodeRef, listeners, attributes, transform, transition, isDragging, isSorting, } = useSortable({
24
+ const { setNodeRef, setActivatorNodeRef, listeners, attributes, transform, transition, isDragging, isSorting } = useSortable({
28
25
  id: dragId,
29
26
  attributes: {
30
27
  tabIndex: -1,
31
- role,
32
- },
28
+ role
29
+ }
33
30
  });
34
31
  const handleRef = useForkRef(ref, setNodeRef, setActivatorNodeRef);
35
- return (jsx(ListItem, { ...combineProps(combineProps(rest, {
36
- onKeyDown: (e) => {
37
- if (isSorting &&
38
- ['End', 'Home', 'ArrowUp', 'ArrowDown'].includes(e.key)) {
32
+ return /*#__PURE__*/ jsx(ListItem_ListItem, {
33
+ ...combineProps(combineProps(rest, {
34
+ onKeyDown: (e)=>{
35
+ // prevent trigger keyboard navigation
36
+ if (isSorting && [
37
+ 'End',
38
+ 'Home',
39
+ 'ArrowUp',
40
+ 'ArrowDown'
41
+ ].includes(e.key)) {
39
42
  e.preventDefault();
40
43
  }
41
44
  },
42
- onKeyUp: (e) => {
45
+ onKeyUp: (e)=>{
43
46
  if (e.target === e.currentTarget && e.key === ' ') {
44
47
  e.preventDefault();
45
48
  }
46
- },
47
- }), listeners), ...attributes, style: {
49
+ }
50
+ }), listeners),
51
+ ...attributes,
52
+ style: {
48
53
  ...style,
49
54
  transform: CSS.Transform.toString(transform),
50
55
  opacity: isDragging ? 0 : 1,
51
56
  touchAction: 'none',
52
- transition,
53
- }, ref: handleRef, hoverable: !isSorting, children: children }));
57
+ transition
58
+ },
59
+ ref: handleRef,
60
+ hoverable: !isSorting,
61
+ children: children
62
+ });
54
63
  });
55
64
  SortableListItem.displayName = 'SuiSortableListItem';
56
65
 
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
57
79
  const overlayVisualOnlyProps = {
58
80
  'aria-hidden': true,
59
- inert: '',
81
+ inert: ''
60
82
  };
61
83
  const SORTABLE_LIST_ITEM_OVERLAY_Z_INDEX = 1500;
62
- const SortableListItemOverlay = forwardRef((props, ref) => {
84
+ const SortableListItemOverlay = /*#__PURE__*/ forwardRef((props, ref)=>{
63
85
  const { children, OverlayProps, ...rest } = props;
64
86
  const { style: overlayStyle, zIndex: overlayZIndex, ...overlayProps } = OverlayProps ?? {};
65
87
  const { active, activatorEvent } = useDndContext();
66
88
  const { document } = useWindowContext();
67
89
  const { scopeProps } = useTheme();
68
- const isMousePointerActivator = activatorEvent != null &&
69
- 'pointerType' in activatorEvent &&
70
- activatorEvent.pointerType === 'mouse';
71
- return (jsx(Portal, { container: document?.body, children: jsx("div", { ...scopeProps, style: { display: 'contents' }, children: jsx(DragOverlay, { ...overlayProps, zIndex: overlayZIndex ?? SORTABLE_LIST_ITEM_OVERLAY_Z_INDEX, style: {
90
+ const isMousePointerActivator = activatorEvent != null && 'pointerType' in activatorEvent && activatorEvent.pointerType === 'mouse';
91
+ return /*#__PURE__*/ jsx(Portal, {
92
+ container: document?.body,
93
+ children: /*#__PURE__*/ jsx("div", {
94
+ ...scopeProps,
95
+ style: {
96
+ display: 'contents'
97
+ },
98
+ children: /*#__PURE__*/ jsx(DragOverlay, {
99
+ ...overlayProps,
100
+ zIndex: overlayZIndex ?? SORTABLE_LIST_ITEM_OVERLAY_Z_INDEX,
101
+ style: {
72
102
  ...overlayStyle,
73
103
  pointerEvents: isMousePointerActivator ? 'none' : 'auto',
74
- touchAction: 'none',
75
- }, children: active && (jsx(ListItem, { ...rest, ref: ref, dragged: true, ...overlayVisualOnlyProps, tabIndex: undefined, children: typeof children === 'function'
76
- ? children(active.id)
77
- : children })) }) }) }));
104
+ touchAction: 'none'
105
+ },
106
+ children: active && /*#__PURE__*/ jsx(ListItem_ListItem, {
107
+ ...rest,
108
+ ref: ref,
109
+ dragged: true,
110
+ ...overlayVisualOnlyProps,
111
+ tabIndex: undefined,
112
+ children: typeof children === 'function' ? children(active.id) : children
113
+ })
114
+ })
115
+ })
116
+ });
78
117
  });
79
118
  SortableListItemOverlay.displayName = 'SortableListItemOverlay';
80
119
 
120
+
121
+
122
+
123
+
124
+
125
+
81
126
  export { SortableListItem, SortableListItemOverlay };
@@ -1,37 +1,61 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { useDndContext } from '@dnd-kit/core';
3
- import { SortableContext } from '@dnd-kit/sortable';
4
- import { useThemeProps } from '@ringcentral/spring-theme';
5
- import { forwardRef, useMemo } from 'react';
6
- import { VirtualizedList } from './VirtualizedList.js';
7
- import '@ringcentral/spring-base';
8
- import 'react-virtuoso';
9
- import './chunks/useAnimationFrame.js';
10
- import './chunks/List.js';
11
- import './chunks/useListNavigation.js';
12
- import 'tabbable';
13
-
14
- const SortableVirtualizedList = forwardRef((inProps, ref) => {
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useDndContext } from "@dnd-kit/core";
3
+ import { SortableContext } from "@dnd-kit/sortable";
4
+ import { useThemeProps } from "@ringcentral/spring-theme";
5
+ import { forwardRef, useMemo } from "react";
6
+ import { VirtualizedList } from "./VirtualizedList.js";
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+ const SortableVirtualizedList = /*#__PURE__*/ forwardRef((inProps, ref)=>{
15
20
  const props = useThemeProps({
16
21
  props: inProps,
17
- name: 'SortableVirtualizedList',
22
+ name: 'SortableVirtualizedList'
18
23
  });
19
24
  const { children, data, ...rest } = props;
20
25
  const { active } = useDndContext();
21
- const keepInvisibleItems = useMemo(() => {
22
- return active
23
- ? [
24
- data.findIndex((value) => {
25
- if (typeof value === 'object') {
26
- return value.id === active.id;
27
- }
28
- return value === active.id;
29
- }),
30
- ]
31
- : undefined;
32
- }, [active, data]);
33
- return (jsx(SortableContext, { items: data, children: jsx(VirtualizedList, { ...rest, data: data, keepInvisibleItems: keepInvisibleItems, computeItemKey: (_, item) => typeof item === 'object' ? item.id : item, ref: ref, children: (index, data) => children(data, index) }) }));
26
+ const keepInvisibleItems = useMemo(()=>{
27
+ if (!active) {
28
+ return undefined;
29
+ }
30
+ const activeIndex = data.findIndex((value)=>{
31
+ if (typeof value === 'object') {
32
+ return value.id === active.id;
33
+ }
34
+ return value === active.id;
35
+ });
36
+ return activeIndex === -1 ? undefined : [
37
+ activeIndex
38
+ ];
39
+ }, [
40
+ active,
41
+ data
42
+ ]);
43
+ return /*#__PURE__*/ jsx(SortableContext, {
44
+ items: data,
45
+ children: /*#__PURE__*/ jsx(VirtualizedList, {
46
+ ...rest,
47
+ data: data,
48
+ keepInvisibleItems: keepInvisibleItems,
49
+ computeItemKey: (_, item)=>typeof item === 'object' ? item.id : item,
50
+ ref: ref,
51
+ children: (index, data)=>children(data, index)
52
+ })
53
+ });
34
54
  });
35
55
  SortableVirtualizedList.displayName = 'SuiSortableVirtualizedList';
36
56
 
57
+
58
+
59
+
60
+
37
61
  export { SortableVirtualizedList };