@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
@@ -1,86 +1,139 @@
1
- import { createContext, useContext, forwardRef, isValidElement, useRef, useState, useImperativeHandle, useEffect } from 'react';
2
- import { jsx } from 'react/jsx-runtime';
3
- import { useForkRef, useVirtuosoExternalWindow, useEventCallback, logInDev } from '@ringcentral/spring-base';
4
- import { useThemeProps } from '@ringcentral/spring-theme';
5
- import { Virtuoso } from 'react-virtuoso';
6
- import { u as useAnimationFrame } from './chunks/useAnimationFrame.js';
7
- import { L as List } from './chunks/List.js';
8
- import './chunks/useListNavigation.js';
9
- import 'tabbable';
1
+ import { createContext, forwardRef, isValidElement, useContext, useEffect, useImperativeHandle, useRef, useState } from "react";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { logInDev, useEventCallback, useForkRef, useVirtuosoExternalWindow } from "@ringcentral/spring-base";
4
+ import { useThemeProps } from "@ringcentral/spring-theme";
5
+ import { Virtuoso } from "react-virtuoso";
6
+ import { List as List_List } from "./List.js";
7
+ import { useAnimationFrame } from "./chunks/6335.js";
8
+
9
+
10
10
 
11
11
  const VirtualizedItemPropsContext = createContext(null);
12
- const useVirtualizedItemPropsContext = () => useContext(VirtualizedItemPropsContext);
12
+ const useVirtualizedItemPropsContext = ()=>useContext(VirtualizedItemPropsContext);
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+
13
26
 
14
27
  const DATA_ITEM_INDEX_ATTR = 'data-item-index';
15
- const VirtuosoList = forwardRef((props, ref) => {
28
+ const VirtuosoList = /*#__PURE__*/ forwardRef((props, ref)=>{
16
29
  const { children: childrenProp, context, style, ...rest } = props;
17
- const { searchAndFocusItemHandler, isScrolling, ListProps, listActions, listRef, itemContentRenderer, data, keepInvisibleItems, computeItemKey, } = context;
30
+ const { searchAndFocusItemHandler, isScrolling, ListProps, listActions, listRef, itemContentRenderer, data, keepInvisibleItems, computeItemKey } = context;
18
31
  const handleListRef = useForkRef(listRef, ref);
19
32
  let rangeStart = null;
20
33
  let rangeEnd = null;
21
34
  let children = childrenProp;
22
35
  if (keepInvisibleItems && computeItemKey && Array.isArray(childrenProp)) {
23
36
  const firstChild = childrenProp[0];
24
- if (firstChild && isValidElement(firstChild)) {
37
+ if (firstChild && /*#__PURE__*/ isValidElement(firstChild)) {
25
38
  const index = Number(firstChild.props[DATA_ITEM_INDEX_ATTR]);
26
39
  rangeStart = Number.isNaN(index) ? null : index;
27
40
  }
28
41
  const lastChild = childrenProp.at(-1);
29
- if (lastChild && isValidElement(lastChild)) {
42
+ if (lastChild && /*#__PURE__*/ isValidElement(lastChild)) {
30
43
  const index = Number(lastChild.props[DATA_ITEM_INDEX_ATTR]);
31
44
  rangeEnd = Number.isNaN(index) ? null : index;
32
45
  }
33
46
  children = [
34
- ...(rangeStart !== null
35
- ? keepInvisibleItems
36
- .filter((itemIndex) => itemIndex < rangeStart)
37
- .map((itemIndex) => {
38
- const itemData = data ? data[itemIndex] : itemIndex;
39
- return (jsx(InnerItem, { "data-sticky-index": itemIndex, style: {
40
- left: 0,
41
- top: 0,
42
- position: 'absolute',
43
- }, children: itemContentRenderer(itemIndex, itemData, context) }, computeItemKey(itemIndex, itemData, context)));
44
- })
45
- : []),
47
+ ...rangeStart !== null ? keepInvisibleItems// oxlint-disable-next-line @typescript-eslint/no-non-null-assertion
48
+ .filter((itemIndex)=>itemIndex < rangeStart).map((itemIndex)=>{
49
+ const itemData = data ? data[itemIndex] : itemIndex;
50
+ return /*#__PURE__*/ jsx(InnerItem, {
51
+ "data-sticky-index": itemIndex,
52
+ style: {
53
+ left: 0,
54
+ top: 0,
55
+ position: 'absolute'
56
+ },
57
+ children: itemContentRenderer(itemIndex, itemData, context)
58
+ }, computeItemKey(itemIndex, itemData, context));
59
+ }) : [],
46
60
  ...childrenProp,
47
- ...(rangeEnd !== null
48
- ? keepInvisibleItems
49
- .filter((itemIndex) => itemIndex > rangeEnd)
50
- .map((itemIndex) => {
51
- const itemData = data ? data[itemIndex] : itemIndex;
52
- return (jsx(InnerItem, { "data-sticky-index": itemIndex, style: {
53
- left: 0,
54
- bottom: 0,
55
- position: 'absolute',
56
- }, children: itemContentRenderer(itemIndex, itemData, context) }, computeItemKey(itemIndex, itemData, context)));
57
- })
58
- : []),
61
+ ...rangeEnd !== null ? keepInvisibleItems// oxlint-disable-next-line @typescript-eslint/no-non-null-assertion
62
+ .filter((itemIndex)=>itemIndex > rangeEnd).map((itemIndex)=>{
63
+ const itemData = data ? data[itemIndex] : itemIndex;
64
+ return /*#__PURE__*/ jsx(InnerItem, {
65
+ "data-sticky-index": itemIndex,
66
+ style: {
67
+ left: 0,
68
+ bottom: 0,
69
+ position: 'absolute'
70
+ },
71
+ children: itemContentRenderer(itemIndex, itemData, context)
72
+ }, computeItemKey(itemIndex, itemData, context));
73
+ }) : []
59
74
  ];
60
75
  }
61
- return (jsx(List, { ...ListProps, ...rest, actions: listActions, style: {
76
+ return /*#__PURE__*/ jsx(List_List, {
77
+ ...ListProps,
78
+ ...rest,
79
+ actions: listActions,
80
+ style: {
62
81
  ...ListProps?.style,
63
82
  ...style,
64
- ...(isScrolling ? { pointerEvents: 'none' } : undefined),
65
- position: 'relative',
66
- }, preventContainerScroll: false, ref: handleListRef, searchAndFocusItemHandler: searchAndFocusItemHandler, children: children }));
83
+ // optimize list scrolling
84
+ ...isScrolling ? {
85
+ pointerEvents: 'none'
86
+ } : undefined,
87
+ // for prop `keepInvisibleItems`
88
+ position: 'relative'
89
+ },
90
+ preventContainerScroll: false,
91
+ ref: handleListRef,
92
+ searchAndFocusItemHandler: searchAndFocusItemHandler,
93
+ children: children
94
+ });
67
95
  });
68
- const Scroller = forwardRef((props, ref) => {
96
+ const Scroller = /*#__PURE__*/ forwardRef((props, ref)=>{
69
97
  const { children, context, ...rest } = props;
70
98
  const handleRef = useForkRef(ref, context?.scrollerRef);
71
- return (jsx("div", { ...rest, ref: handleRef, tabIndex: undefined, children: children }));
99
+ return /*#__PURE__*/ jsx("div", {
100
+ ...rest,
101
+ ref: handleRef,
102
+ tabIndex: undefined,
103
+ children: children
104
+ });
72
105
  });
73
- const InnerItem = (props) => {
106
+ const InnerItem = (props)=>{
74
107
  const { children, ...rest } = props;
75
- return (jsx(VirtualizedItemPropsContext.Provider, { value: rest, children: children }));
108
+ return /*#__PURE__*/ jsx(VirtualizedItemPropsContext.Provider, {
109
+ value: rest,
110
+ children: children
111
+ });
76
112
  };
77
113
  const Item = InnerItem;
78
- const VirtuosoComponents = { Item, Scroller, List: VirtuosoList };
114
+ const VirtuosoComponents = {
115
+ Item: Item,
116
+ Scroller: Scroller,
117
+ List: VirtuosoList
118
+ };
119
+
79
120
 
80
- const VirtualizedList = forwardRef((inProps, ref) => {
81
- const props = useThemeProps({ props: inProps, name: 'VirtualizedList' });
121
+
122
+
123
+
124
+
125
+
126
+
127
+ const VirtualizedList = /*#__PURE__*/ forwardRef((inProps, ref)=>{
128
+ const props = useThemeProps({
129
+ props: inProps,
130
+ name: 'VirtualizedList'
131
+ });
82
132
  const { children, totalCount, data, isScrolling: handleScroll, rangeChanged: handleRangeChanged, virtuosoActions, actions, ListProps, isItemDisabled, infinite = false, isReady = true, context, components, keepInvisibleItems, computeItemKey, firstFocusIndex = 0, ...rest } = props;
83
- const listRangeRef = useRef({ startIndex: -1, endIndex: -1 });
133
+ const listRangeRef = useRef({
134
+ startIndex: -1,
135
+ endIndex: -1
136
+ });
84
137
  const [isScrolling, setIsScrolling] = useState(false);
85
138
  const listRef = useRef(null);
86
139
  const virtuosoRef = useRef(null);
@@ -89,51 +142,60 @@ const VirtualizedList = forwardRef((inProps, ref) => {
89
142
  const itemRenderedPromiseRef = useRef(null);
90
143
  const { requestAnimationFrame } = useAnimationFrame();
91
144
  const externalWindowProps = useVirtuosoExternalWindow();
92
- const isItemRendered = (index) => {
145
+ const isItemRendered = (index)=>{
93
146
  const { startIndex, endIndex } = listRangeRef.current;
94
147
  return index <= endIndex && index >= startIndex;
95
148
  };
96
- const focusItemByIndex = (index) => {
97
- if (!isReady) {
98
- new Promise((resolve) => {
149
+ const focusItemByIndex = (index)=>{
150
+ /**
151
+ * If the component isn't ready, we need to defer the focus action until the component is ready.
152
+ * This is necessary if a parent component is waiting for some height calculation of the list to
153
+ * be performed before it actually renders the list. If we didn't do this the component would not
154
+ * know where to scroll to/would scroll to an incorrect position as it has not yet fully rendered.
155
+ */ if (!isReady) {
156
+ new Promise((resolve)=>{
99
157
  initialFocusItemByIndexPromiseRef.current = resolve;
100
- }).then(() => {
101
- requestAnimationFrame(() => focusByIndexAction(index));
158
+ }).then(()=>{
159
+ // Wrap in rAF to ensure height has truly settled before focusing
160
+ requestAnimationFrame(()=>focusByIndexAction(index));
102
161
  });
103
- }
104
- else {
105
- const focusTarget = () => {
162
+ } else {
163
+ const focusTarget = ()=>{
106
164
  const targetItem = listRef.current?.querySelector(`[data-item-index="${index}"]`);
107
165
  if (process.env.NODE_ENV !== 'production' && !targetItem) {
108
166
  logInDev({
109
167
  scope: 'VirtualizedList',
110
168
  level: 'warn',
111
- message: `Can't find the target item with index \`${index}\`. Please ensure \`getSelectedIndex\` can find the index in your data array.`,
169
+ message: `Can't find the target item with index \`${index}\`. Please ensure \`getSelectedIndex\` can find the index in your data array.`
112
170
  });
113
171
  }
114
172
  targetItem?.focus();
115
173
  };
116
174
  if (!isItemRendered(index)) {
117
- new Promise((resolve) => {
118
- itemRenderedPromiseRef.current = { resolve, itemIndex: index };
119
- }).then(() => {
175
+ new Promise((resolve)=>{
176
+ itemRenderedPromiseRef.current = {
177
+ resolve,
178
+ itemIndex: index
179
+ };
180
+ }).then(()=>{
120
181
  focusTarget();
121
182
  });
122
- virtuosoRef.current?.scrollToIndex({ index, align: 'center' });
123
- }
124
- else {
183
+ virtuosoRef.current?.scrollToIndex({
184
+ index,
185
+ align: 'center'
186
+ });
187
+ } else {
125
188
  focusTarget();
126
189
  }
127
190
  }
128
191
  };
129
- const isDisabled = (index) => {
130
- if (!isItemDisabled)
131
- return false;
192
+ const isDisabled = (index)=>{
193
+ if (!isItemDisabled) return false;
132
194
  return isItemDisabled(index);
133
195
  };
134
- const searchAndFocusItemHandler = (searchElementOption) => {
196
+ const searchAndFocusItemHandler = (searchElementOption)=>{
135
197
  const firstItemIndex = 0;
136
- const lastItemIndex = (() => {
198
+ const lastItemIndex = (()=>{
137
199
  if (data) {
138
200
  return data.length - 1;
139
201
  }
@@ -145,17 +207,17 @@ const VirtualizedList = forwardRef((inProps, ref) => {
145
207
  if (searchElementOption === 'first') {
146
208
  startIndex = firstFocusIndex;
147
209
  direction = 'down';
148
- }
149
- else {
210
+ } else {
150
211
  startIndex = lastItemIndex;
151
212
  direction = 'up';
152
213
  }
153
214
  if (!isDisabled(startIndex)) {
154
215
  focusItemByIndex(startIndex);
155
- return { focused: true };
216
+ return {
217
+ focused: true
218
+ };
156
219
  }
157
- }
158
- else {
220
+ } else {
159
221
  startIndex = Number(searchElementOption.baseElement.dataset['itemIndex']);
160
222
  direction = searchElementOption.direction;
161
223
  }
@@ -164,69 +226,75 @@ const VirtualizedList = forwardRef((inProps, ref) => {
164
226
  if (direction === 'up') {
165
227
  do {
166
228
  if (pointer - 1 < firstItemIndex) {
229
+ // disabled focus loop when infinite is true
167
230
  if (infinite) {
168
231
  pointer = startIndex;
169
- }
170
- else {
232
+ } else {
171
233
  pointer = lastItemIndex;
172
234
  }
173
235
  isAfterBaseElement = false;
174
- }
175
- else {
236
+ } else {
176
237
  pointer--;
177
238
  }
178
239
  if (!isDisabled(pointer)) {
179
240
  break;
180
241
  }
181
- } while (pointer !== startIndex);
182
- }
183
- else {
242
+ }while (pointer !== startIndex);
243
+ } else {
184
244
  do {
185
245
  if (pointer + 1 > lastItemIndex) {
246
+ // disabled focus loop when infinite is true
186
247
  if (infinite) {
187
248
  pointer = startIndex;
188
- }
189
- else {
249
+ } else {
190
250
  pointer = firstItemIndex;
191
251
  }
192
252
  isAfterBaseElement = false;
193
- }
194
- else {
253
+ } else {
195
254
  pointer++;
196
255
  }
197
256
  if (!isDisabled(pointer)) {
198
257
  break;
199
258
  }
200
- } while (pointer !== startIndex);
259
+ }while (pointer !== startIndex);
201
260
  }
202
261
  if (isDisabled(pointer)) {
203
- return { focused: false };
262
+ return {
263
+ focused: false
264
+ };
204
265
  }
205
266
  focusItemByIndex(pointer);
206
- return typeof searchElementOption === 'string'
207
- ? { focused: true }
208
- : { focused: true, isAfterBaseElement };
267
+ return typeof searchElementOption === 'string' ? {
268
+ focused: true
269
+ } : {
270
+ focused: true,
271
+ isAfterBaseElement
272
+ };
209
273
  };
210
274
  const listActions = useRef(null);
211
- const focusByIndexAction = useEventCallback((i) => {
275
+ const focusByIndexAction = useEventCallback((i)=>{
212
276
  if (isDisabled(i)) {
213
277
  listActions.current?.focus();
214
- }
215
- else {
278
+ } else {
216
279
  focusItemByIndex(i);
217
280
  }
218
281
  });
219
- useImperativeHandle(actions, () => ({
220
- focus: () => {
221
- listActions.current?.focus();
222
- },
223
- focusByIndex: focusByIndexAction,
224
- }), [focusByIndexAction]);
225
- useEffect(() => {
282
+ useImperativeHandle(actions, ()=>({
283
+ focus: ()=>{
284
+ listActions.current?.focus();
285
+ },
286
+ focusByIndex: focusByIndexAction
287
+ }), [
288
+ focusByIndexAction
289
+ ]);
290
+ useEffect(()=>{
291
+ // Execute the initial focus item by index promise when the list is ready
226
292
  if (isReady) {
227
293
  initialFocusItemByIndexPromiseRef.current?.();
228
294
  }
229
- }, [isReady]);
295
+ }, [
296
+ isReady
297
+ ]);
230
298
  const virtuosoContext = {
231
299
  listRef,
232
300
  scrollerRef: ref,
@@ -237,9 +305,29 @@ const VirtualizedList = forwardRef((inProps, ref) => {
237
305
  data,
238
306
  keepInvisibleItems,
239
307
  itemContentRenderer: children,
240
- computeItemKey: computeItemKey,
308
+ computeItemKey: computeItemKey
241
309
  };
242
- return (jsx(Virtuoso, { className: "sui-virtualized-list", ...externalWindowProps, ref: handleVirtuosoRef, increaseViewportBy: 200, ...(computeItemKey ? { computeItemKey } : undefined), ...rest, context: { ...context, ...virtuosoContext }, components: { ...VirtuosoComponents, ...components }, totalCount: totalCount, data: data, rangeChanged: (range) => {
310
+ return /*#__PURE__*/ jsx(Virtuoso, {
311
+ className: "sui-virtualized-list",
312
+ ...externalWindowProps,
313
+ ref: handleVirtuosoRef,
314
+ // pre-render, make scroll smooth when move focus
315
+ increaseViewportBy: 200,
316
+ ...computeItemKey ? {
317
+ computeItemKey
318
+ } : undefined,
319
+ ...rest,
320
+ context: {
321
+ ...context,
322
+ ...virtuosoContext
323
+ },
324
+ components: {
325
+ ...VirtuosoComponents,
326
+ ...components
327
+ },
328
+ totalCount: totalCount,
329
+ data: data,
330
+ rangeChanged: (range)=>{
243
331
  listRangeRef.current = range;
244
332
  const itemRenderedPromise = itemRenderedPromiseRef.current;
245
333
  if (itemRenderedPromise) {
@@ -250,11 +338,21 @@ const VirtualizedList = forwardRef((inProps, ref) => {
250
338
  }
251
339
  }
252
340
  handleRangeChanged?.(range);
253
- }, isScrolling: (isScrolling) => {
341
+ },
342
+ isScrolling: (isScrolling)=>{
254
343
  setIsScrolling(isScrolling);
255
344
  handleScroll?.(isScrolling);
256
- }, itemContent: children }));
345
+ },
346
+ itemContent: children
347
+ });
257
348
  });
258
349
  VirtualizedList.displayName = 'SuiVirtualizedList';
259
350
 
351
+
352
+
353
+
354
+
355
+
356
+
357
+
260
358
  export { VirtualizedItemPropsContext, VirtualizedList, VirtuosoComponents, useVirtualizedItemPropsContext };