@ringcentral/spring-ui 1.7.0 → 1.8.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 (233) hide show
  1. package/Alert.js +3 -3
  2. package/Announcement.js +1 -1
  3. package/Autocomplete.js +174 -236
  4. package/Avatar.js +27 -13
  5. package/BottomNavigation.js +0 -3
  6. package/Checkbox.js +0 -2
  7. package/DatePicker.js +5 -13
  8. package/DateUtilsContext.js +0 -1
  9. package/Dialer.js +2 -50
  10. package/Dialog.js +4 -4
  11. package/Dropdown.js +0 -7
  12. package/FocusTrap.js +0 -32
  13. package/InlineEditable.js +0 -4
  14. package/Link.js +1 -1
  15. package/ListItem.js +1 -1
  16. package/ListNavigation.js +0 -6
  17. package/Menu.js +1 -1
  18. package/MenuDivider.js +2 -2
  19. package/MenuFooter.js +4 -4
  20. package/MenuHeader.js +4 -4
  21. package/MenuItem.js +1 -1
  22. package/MenuItemText.js +1 -1
  23. package/PageHeader.js +6 -4
  24. package/Popper.js +0 -1
  25. package/Rating.js +0 -5
  26. package/SingleFilter.js +0 -1
  27. package/Slider.js +1 -4
  28. package/Snackbar.js +0 -14
  29. package/SortableListItem.js +0 -1
  30. package/SplitButton.js +1 -3
  31. package/StatusIndicator.js +1 -1
  32. package/SubMenu.js +0 -4
  33. package/SwipeableDrawer.js +8 -146
  34. package/Switch.js +1 -4
  35. package/Tab.js +7 -8
  36. package/TabContext.js +0 -5
  37. package/TableBody.js +1 -1
  38. package/TableCell.js +0 -6
  39. package/TableRow.js +0 -1
  40. package/Tabs.js +20 -118
  41. package/Text.js +2 -4
  42. package/TimePicker.js +7 -46
  43. package/VirtualizedList.js +2 -30
  44. package/chunks/Alert.js +8 -7
  45. package/chunks/BottomNavigationItem.js +0 -1
  46. package/chunks/Button.js +0 -1
  47. package/chunks/Chip.js +0 -5
  48. package/chunks/Drawer.js +1 -30
  49. package/chunks/ListItem.js +3 -6
  50. package/chunks/Menu.js +3 -3
  51. package/chunks/MenuDivider.js +2 -3
  52. package/chunks/MenuItemText.js +3 -3
  53. package/chunks/MenuList.js +0 -3
  54. package/chunks/PickerTextField.js +0 -1
  55. package/chunks/Popover.js +0 -5
  56. package/chunks/Select.js +2 -39
  57. package/chunks/Squircle.js +0 -7
  58. package/chunks/StatusIndicator.js +1 -0
  59. package/chunks/StepIcon.js +1 -3
  60. package/chunks/StepperContext.js +0 -7
  61. package/chunks/Tooltip.js +0 -36
  62. package/chunks/VirtualizedMenu.js +2 -78
  63. package/chunks/getFade.js +2 -0
  64. package/chunks/useFocusTrapStack.js +0 -8
  65. package/chunks/useHelperTextId.js +0 -24
  66. package/chunks/useListNavigation.js +2 -17
  67. package/chunks/useMenuItemSelect.js +6 -19
  68. package/chunks/useMotionSafeTransition.js +0 -4
  69. package/chunks/useNestedParentMenu.js +0 -2
  70. package/chunks/usePrefersReducedMotion.js +0 -10
  71. package/chunks/useTooltipForceHide.js +0 -4
  72. package/chunks/useTrayNavigate.js +0 -1
  73. package/index.css +392 -120
  74. package/index.js +1 -1
  75. package/package.json +4 -4
  76. package/src/Accordion/Accordion.type.d.ts +0 -21
  77. package/src/AccordionHeader/AccordionHeader.type.d.ts +0 -14
  78. package/src/Alert/Alert.type.d.ts +0 -32
  79. package/src/Animation/components/ExpandCollapseCaret/ExpandCollapseCaret.d.ts +0 -4
  80. package/src/Animation/components/ShowHideEye/ShowHideEye.d.ts +0 -4
  81. package/src/Animation/hooks/useMotionSafeTransition/useMotionSafeTransition.d.ts +0 -4
  82. package/src/Autocomplete/Autocomplete.d.ts +0 -5
  83. package/src/Autocomplete/Autocomplete.type.d.ts +0 -84
  84. package/src/Autocomplete/SuggestionList/SuggestionList.d.ts +5 -89
  85. package/src/Autocomplete/SuggestionList/SuggestionListItem.d.ts +0 -2
  86. package/src/Autocomplete/SuggestionList/utils/SuggestionListItem.d.ts +1 -13
  87. package/src/Autocomplete/SuggestionList/utils/useDynamicHeight.d.ts +0 -6
  88. package/src/Autocomplete/SuggestionList/utils/useHighlightScroll.d.ts +0 -20
  89. package/src/Autocomplete/SuggestionList/utils/useSuggestionList.d.ts +3 -41
  90. package/src/Autocomplete/SuggestionList/utils/useSuggestionListGroup.d.ts +0 -49
  91. package/src/Autocomplete/useAutocomplete.d.ts +1 -62
  92. package/src/Autocomplete/useAutocompleteTag.d.ts +0 -33
  93. package/src/Avatar/Avatar.type.d.ts +0 -58
  94. package/src/AvatarGroup/AvatarGroup.type.d.ts +0 -3
  95. package/src/Backdrop/Backdrop.type.d.ts +0 -4
  96. package/src/Badge/Badge.type.d.ts +0 -33
  97. package/src/Block/Block.type.d.ts +0 -24
  98. package/src/BlockHeader/BlockHeader.type.d.ts +0 -5
  99. package/src/BottomNavigation/BottomNavigation.type.d.ts +0 -34
  100. package/src/BottomNavigationItem/BottomNavigationItem.type.d.ts +0 -39
  101. package/src/Button/Button.type.d.ts +0 -30
  102. package/src/CallButton/CallButton.type.d.ts +0 -4
  103. package/src/Checkbox/Checkbox.type.d.ts +0 -17
  104. package/src/Chip/Chip.type.d.ts +0 -41
  105. package/src/CircularProgressIndicator/CircularProgressIndicator.type.d.ts +0 -19
  106. package/src/DatePicker/Calendar.d.ts +1 -20
  107. package/src/DatePicker/DatePicker.type.d.ts +0 -18
  108. package/src/DatePicker/DatePickerHeader.d.ts +1 -12
  109. package/src/DatePicker/Day.d.ts +0 -7
  110. package/src/DatePicker/Year.d.ts +0 -6
  111. package/src/DatePicker/Years.d.ts +0 -7
  112. package/src/Dialer/DialDelete/DialDelete.d.ts +0 -3
  113. package/src/Dialer/DialPad/DialPad.d.ts +0 -106
  114. package/src/Dialer/DialPad/utils/types.d.ts +0 -5
  115. package/src/Dialer/DialPad/utils/useDialKeyboard.d.ts +0 -5
  116. package/src/Dialer/DialPad/utils/useKeyAudio.d.ts +0 -9
  117. package/src/Dialer/DialPadButton/DialPadButton.d.ts +0 -14
  118. package/src/Dialer/DialTextField/DialTextField.d.ts +0 -23
  119. package/src/Dialer/DialTextField/utils/getDialPadValueOnlyRegex.d.ts +0 -3
  120. package/src/Dialer/DialTextField/utils/useFixedEndSelection.d.ts +0 -3
  121. package/src/Dialog/Dialog.type.d.ts +0 -11
  122. package/src/Divider/Divider.type.d.ts +0 -17
  123. package/src/DragHandle/DragHandle.type.d.ts +0 -4
  124. package/src/Drawer/Drawer.d.ts +0 -28
  125. package/src/Drawer/Drawer.type.d.ts +0 -84
  126. package/src/Dropdown/Dropdown.type.d.ts +0 -64
  127. package/src/EmptyState/EmptyState.type.d.ts +0 -12
  128. package/src/FabButton/FabButton.type.d.ts +0 -5
  129. package/src/FocusTrap/FocusTrap.d.ts +0 -38
  130. package/src/FocusTrap/useFocusTrapStack.d.ts +0 -9
  131. package/src/FormField/FormField.type.d.ts +0 -26
  132. package/src/FormField/useHelperTextId.d.ts +0 -25
  133. package/src/FormLabel/FormLabel.type.d.ts +0 -14
  134. package/src/Icon/Icon.type.d.ts +0 -15
  135. package/src/IconButton/IconButton.type.d.ts +0 -30
  136. package/src/IconButton/IconButtonLabel.type.d.ts +0 -3
  137. package/src/IconButtonGroup/IconButtonGroup.type.d.ts +0 -8
  138. package/src/InlineEditable/InlineEditable.type.d.ts +0 -75
  139. package/src/LinearProgressIndicator/LinearProgressIndicator.type.d.ts +0 -31
  140. package/src/Link/Link.classes.d.ts +1 -1
  141. package/src/Link/Link.type.d.ts +1 -10
  142. package/src/ListItem/ListItem.type.d.ts +0 -41
  143. package/src/ListItemText/ListItemText.type.d.ts +0 -21
  144. package/src/ListNavigation/useListNavigation.d.ts +0 -16
  145. package/src/Menu/Menu.type.d.ts +0 -10
  146. package/src/MenuFooter/MenuFooter.type.d.ts +0 -4
  147. package/src/MenuHeader/MenuHeader.type.d.ts +0 -10
  148. package/src/MenuItem/MenuItem.type.d.ts +0 -19
  149. package/src/MenuItem/MenuItemSelectContext.d.ts +0 -3
  150. package/src/MenuItem/useMenuItemSelect.d.ts +0 -21
  151. package/src/MenuItemText/MenuItemText.type.d.ts +0 -17
  152. package/src/MenuList/MenuList.type.d.ts +0 -4
  153. package/src/MenuList/MenuListContext.d.ts +0 -6
  154. package/src/Modal/InnerModal.type.d.ts +0 -5
  155. package/src/Modal/Modal.type.d.ts +0 -11
  156. package/src/Modal/ModalContext.d.ts +0 -4
  157. package/src/Option/Option.type.d.ts +0 -3
  158. package/src/Overlap/Overlap.type.d.ts +0 -11
  159. package/src/PageHeader/PageHeader.type.d.ts +0 -4
  160. package/src/PickerTextField/PickerTextField.type.d.ts +0 -10
  161. package/src/Popover/Popover.type.d.ts +0 -29
  162. package/src/Popper/Popper.type.d.ts +0 -61
  163. package/src/Radio/Radio.type.d.ts +0 -5
  164. package/src/RadioGroup/RadioGroup.type.d.ts +0 -4
  165. package/src/Rating/Rating.type.d.ts +0 -74
  166. package/src/Select/Select.type.d.ts +0 -84
  167. package/src/SingleFilter/FilterButton/FilterButton.type.d.ts +0 -16
  168. package/src/SingleFilter/SingleFilter.type.d.ts +0 -26
  169. package/src/Skeleton/Skeleton.type.d.ts +0 -1
  170. package/src/Skeleton/SkeletonContainer/SkeletonContainer.classes.d.ts +1 -1
  171. package/src/Slider/Slider.classes.d.ts +1 -5
  172. package/src/Slider/Slider.type.d.ts +0 -104
  173. package/src/Snackbar/Snackbar.type.d.ts +0 -18
  174. package/src/SplitButton/SplitButton.type.d.ts +0 -21
  175. package/src/Squircle/Squircle.type.d.ts +0 -3
  176. package/src/StatusIndicator/StatusIndicator.classes.d.ts +1 -1
  177. package/src/StatusIndicator/StatusIndicator.type.d.ts +1 -9
  178. package/src/Step/Step.type.d.ts +0 -29
  179. package/src/Step/StepContext.d.ts +0 -7
  180. package/src/StepButton/StepButton.type.d.ts +0 -15
  181. package/src/StepContent/StepContent.type.d.ts +0 -7
  182. package/src/StepIcon/StepIcon.type.d.ts +0 -26
  183. package/src/StepLabel/StepLabel.type.d.ts +0 -23
  184. package/src/Stepper/Stepper.type.d.ts +0 -27
  185. package/src/SwipeableDrawer/SwipeableDrawer.d.ts +0 -26
  186. package/src/SwipeableDrawer/SwipeableDrawer.types.d.ts +0 -67
  187. package/src/SwipeableDrawer/hooks/useDrawerGestures.d.ts +0 -110
  188. package/src/SwipeableDrawer/hooks/useElementSizeObserver.d.ts +0 -5
  189. package/src/SwipeableDrawer/hooks/useSnapPoints.d.ts +0 -60
  190. package/src/Switch/Switch.type.d.ts +0 -9
  191. package/src/Tab/Tab.classes.d.ts +3 -2
  192. package/src/Tab/Tab.type.d.ts +0 -29
  193. package/src/TabContext/TabContext.d.ts +0 -4
  194. package/src/TabContext/TabContext.type.d.ts +0 -7
  195. package/src/TabPanel/TabPanel.type.d.ts +0 -10
  196. package/src/Table/Table.type.d.ts +0 -19
  197. package/src/TableBody/TableBody.type.d.ts +0 -3
  198. package/src/TableCell/TableCell.d.ts +0 -4
  199. package/src/TableCell/TableCell.type.d.ts +0 -35
  200. package/src/TableContainer/TableContainer.type.d.ts +0 -7
  201. package/src/TableFooter/TableFooter.type.d.ts +0 -3
  202. package/src/TableHead/TableHead.type.d.ts +0 -6
  203. package/src/TablePagination/TablePagination.type.d.ts +0 -47
  204. package/src/TableRow/TableRow.type.d.ts +0 -17
  205. package/src/Tabs/TabMoreMenu.d.ts +0 -16
  206. package/src/Tabs/TabScrollButton.d.ts +0 -10
  207. package/src/Tabs/Tabs.classes.d.ts +1 -1
  208. package/src/Tabs/Tabs.d.ts +1 -1
  209. package/src/Tabs/Tabs.type.d.ts +2 -36
  210. package/src/Tabs/TabsContext.d.ts +2 -0
  211. package/src/Tabs/hooks/useTabsScroller.d.ts +0 -30
  212. package/src/Tag/Tag.type.d.ts +0 -12
  213. package/src/Text/Text.type.d.ts +0 -13
  214. package/src/TextField/TextField.type.d.ts +0 -64
  215. package/src/Textarea/Textarea.type.d.ts +0 -13
  216. package/src/TimePicker/NumberPicker.type.d.ts +0 -12
  217. package/src/TimePicker/SelectionView.d.ts +0 -6
  218. package/src/TimePicker/TimeButton.d.ts +0 -3
  219. package/src/TimePicker/TimePicker.type.d.ts +0 -11
  220. package/src/TimePicker/ToggleText.type.d.ts +0 -3
  221. package/src/TimePicker/utils/TimeBoundary.d.ts +0 -3
  222. package/src/TimePicker/utils/TimePickerHelper.d.ts +0 -19
  223. package/src/TimePicker/utils/getNumberPickerBoundary.d.ts +0 -3
  224. package/src/Tooltip/TooltipTrigger.a11y.d.ts +0 -9
  225. package/src/Tooltip/TooltipTrigger.type.d.ts +0 -44
  226. package/src/Tooltip/TooltipView.type.d.ts +0 -25
  227. package/src/Tooltip/useTooltipForceHide.d.ts +0 -4
  228. package/src/Tray/Tray.type.d.ts +0 -13
  229. package/src/Tray/TrayContext.d.ts +0 -4
  230. package/src/Tray/hooks/useTray.d.ts +0 -16
  231. package/src/Tray/hooks/useTrayPanel.d.ts +0 -3
  232. package/src/VirtualizedList/VirtualizedList.type.d.ts +0 -27
  233. package/src/VirtualizedMenu/VirtualizedMenu.type.d.ts +0 -17
package/index.js CHANGED
@@ -120,7 +120,7 @@ export { Dialog, DialogActions, DialogContent, DialogTitle, dialogStyle } from '
120
120
  export { D as Drawer } from './chunks/Drawer.js';
121
121
  export { D as DragHandle } from './chunks/DragHandle.js';
122
122
  export { SwipeableDrawer, swipeableDrawerStyles } from './SwipeableDrawer.js';
123
- export { Autocomplete, DEFAULT_GET_OPTION_LABEL, DEFAULT_KEY_TO_CHIPS, RcAutocompleteDefaultFilterOptions, SuggestionList, SuggestionListItem, autocompleteStyles, stringArrToRegExp, suggestionListStyles, useAutocomplete, useAutocompleteGroup, useAutocompleteTag, useDynamicHeight, useHighlightScroll, useSuggestionList } from './Autocomplete.js';
123
+ export { Autocomplete, DEFAULT_GET_OPTION_LABEL, DEFAULT_KEY_TO_CHIPS, DEFAULT_PADDING, RcAutocompleteDefaultFilterOptions, SuggestionList, SuggestionListItem, autocompleteStyles, getPaddingValue, isFirstInGroup, stringArrToRegExp, suggestionListStyles, useAutocomplete, useAutocompleteGroup, useAutocompleteTag, useDynamicHeight, useHighlightScroll, useSuggestionList } from './Autocomplete.js';
124
124
  export { EmptyState, emptyStateStyle } from './EmptyState.js';
125
125
  export { TabContext, generateTabStableIds, useInternalTabsContext, useTabStableIds } from './TabContext.js';
126
126
  export { TabPanel, tabPanelStyle } from './TabPanel.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ringcentral/spring-ui",
3
- "version": "1.7.0",
3
+ "version": "1.8.0",
4
4
  "author": "RingCentral",
5
5
  "description": "A comprehensive React component library built with Tailwind CSS, featuring production-ready components",
6
6
  "main": "./index.js",
@@ -14,9 +14,9 @@
14
14
  "@floating-ui/react-dom": "2.1.1",
15
15
  "@juggle/resize-observer": "3.4.0",
16
16
  "@mui/base": "5.0.0-beta.40",
17
- "@ringcentral/spring-base": "^1.7.0",
18
- "@ringcentral/spring-icon": "^1.7.0",
19
- "@ringcentral/spring-theme": "^1.7.0",
17
+ "@ringcentral/spring-base": "^1.8.0",
18
+ "@ringcentral/spring-icon": "^1.8.0",
19
+ "@ringcentral/spring-theme": "^1.8.0",
20
20
  "@types/lodash": "^4.14.182",
21
21
  "@use-gesture/react": "10.3.1",
22
22
  "clsx": "^1.2.1",
@@ -2,30 +2,9 @@ import { ReactNode, SyntheticEvent } from 'react';
2
2
  import { StandardProps } from '@ringcentral/spring-base';
3
3
  import { AccordionClassesKey } from './Accordion.classes';
4
4
  export declare type AccordionProps = StandardProps<{
5
- /**
6
- * Slot for header of Accordion.
7
- */
8
5
  header: ReactNode;
9
- /**
10
- * If `true`, expands the accordion by default.
11
- * @default false
12
- */
13
6
  defaultExpanded?: boolean;
14
- /**
15
- * If `true`, expands the accordion, otherwise collapse it.
16
- * Setting this prop enables control over the accordion.
17
- */
18
7
  expanded?: boolean;
19
- /**
20
- * Callback fired when the expand/collapse state is changed.
21
- *
22
- * @param {React.SyntheticEvent} event The event source of the callback. **Warning**: This is a generic event not a change event.
23
- * @param {boolean} expanded The `expanded` state of the accordion.
24
- */
25
8
  onChange?: (event: SyntheticEvent, expanded: boolean) => void;
26
- /**
27
- * false: will unmount content whenever collapsed
28
- * true: keep displayed children mounted when collapsed
29
- */
30
9
  keepMounted?: boolean;
31
10
  }, AccordionClassesKey, 'div'>;
@@ -3,23 +3,9 @@ import { StandardProps, UseFocusVisibleOptions } from '@ringcentral/spring-base'
3
3
  import { ExpandCollapseCaretProps } from '../Animation/components/ExpandCollapseCaret';
4
4
  import { AccordionHeaderClassesKey } from './AccordionHeader.classes';
5
5
  export declare type AccordionHeaderProps = StandardProps<{
6
- /** If children is not string,
7
- * **should** handle truncation tooltip by adding title attribute on the actual component containing the string */
8
6
  children: ReactNode;
9
- /** secondary content slot of the header. */
10
7
  secondarySlot?: ReactNode;
11
- /**
12
- * If `true`, the component will be disabled.
13
- * @default false
14
- */
15
8
  disabled?: boolean;
16
- /**
17
- * If `true`, the component will show an ExpandCollapseCaret icon.
18
- * @default true
19
- */
20
9
  expandIcon?: boolean;
21
- /**
22
- * Props passed to the ExpandCollapseCaret component
23
- */
24
10
  ExpandCollapseCaretProps?: Partial<ExpandCollapseCaretProps>;
25
11
  } & Pick<UseFocusVisibleOptions, 'onFocusVisible'>, AccordionHeaderClassesKey, 'button'>;
@@ -7,44 +7,12 @@ declare type DefaultElementType = 'div';
7
7
  declare type ExtendElementType = ElementType;
8
8
  export declare type AlertSeverity = 'info' | 'error' | 'success' | 'warning' | 'neutral';
9
9
  declare type BaseAlertProps = WithClassesProps<{
10
- /**
11
- * The action to display. It renders after the message, at the end of the alert.
12
- */
13
10
  action?: React.ReactNode;
14
- /**
15
- * @deprecated Use startSlot instead. Will be removed in the next major version.
16
- * Override the icon displayed before the children.
17
- * Unless provided, the icon is mapped to the value of the `severity` prop.
18
- *
19
- * @default false
20
- */
21
11
  icon?: React.ComponentType | boolean;
22
- /**
23
- * The content to display at the start of the alert, before the message.
24
- * If not provided and severity is set, a default icon will be shown.
25
- */
26
12
  startSlot?: React.ComponentType | React.ReactElement | null;
27
- /**
28
- * Callback fired when the component requests to be closed.
29
- *
30
- * When this callback is set, a close icon button is displayed that triggers the callback when clicked.
31
- */
32
13
  onClose?: () => void;
33
- /**
34
- * Override the default label for the *close popup* icon button.
35
- *
36
- * For localization purposes, you can use the provided [translations](/guides/localization/).
37
- */
38
14
  closeText?: string;
39
- /**
40
- * The severity of the alert. This defines the color and icon used.
41
- *
42
- * @default "info"
43
- */
44
15
  severity?: AlertSeverity;
45
- /**
46
- * Props applied to the IconButton component used for the close button.
47
- */
48
16
  CloseButtonProps?: IconButtonProps;
49
17
  }, AlertClassesKey>;
50
18
  export declare type AlertProps<T extends ExtendElementType = DefaultElementType> = OverridableProps<BaseAlertProps, T>;
@@ -5,10 +5,6 @@ import { ExpandCollapseCaretClassesKey } from './ExpandCollapseCaret.classes';
5
5
  import expandCollapseCaretStyles from './styles/ExpandCollapseCaret.css';
6
6
  declare type Orientation = 'vertical' | 'horizontal';
7
7
  export declare type ExpandCollapseCaretProps = WithClassesProps<{
8
- /**
9
- * The orientation of the caret.
10
- * @default 'vertical'
11
- */
12
8
  orientation?: Orientation;
13
9
  expanded: boolean;
14
10
  size?: IconProps['size'];
@@ -4,10 +4,6 @@ import { MotionComponent } from '../types';
4
4
  import { ShowHideEyeClassesKey } from './ShowHideEye.classes';
5
5
  import showHideEyeStyles from './styles/ShowHideEye.css';
6
6
  export declare type ShowHideEyeProps = WithClassesProps<{
7
- /**
8
- * If `true`, the eye is closed.
9
- * @default false
10
- */
11
7
  hide: boolean;
12
8
  } & Omit<IconProps, 'symbol' | 'classes'>, ShowHideEyeClassesKey>;
13
9
  export declare const ShowHideEye: MotionComponent<ShowHideEyeProps>;
@@ -1,8 +1,4 @@
1
1
  import { Transition } from 'framer-motion';
2
- /**
3
- * A hook that returns an instant transition if the user has reduced motion enabled.
4
- * If reduced motion is not enabled, returns the given motion transition.
5
- */
6
2
  export declare const useMotionSafeTransition: (transition: Transition) => (import("framer-motion").Orchestration & import("framer-motion").Repeat & {
7
3
  [key: string]: any;
8
4
  }) | {
@@ -3,9 +3,4 @@ import autocompleteStyles from './styles/Autocomplete.css';
3
3
  import { SuggestionListItemData } from './SuggestionList';
4
4
  declare const Autocomplete: AutocompleteComponent<SuggestionListItemData>;
5
5
  export { Autocomplete, autocompleteStyles };
6
- /**
7
- * default Autocomplete filter options method, use with `variant="tags"`
8
- *
9
- * - filter options by input value and selected items
10
- */
11
6
  export declare const RcAutocompleteDefaultFilterOptions: AutocompleteProps['filterOptions'];
@@ -9,123 +9,39 @@ import { UseAutocompleteParams } from './useAutocomplete';
9
9
  import { GetTagProps } from './useAutocompleteTag';
10
10
  export declare type AutocompleteSuggestionListProps<T> = BaseSuggestionListProps<T> & Pick<SuggestionListProps, 'maxContainerHeight' | 'padding' | 'virtualize'>;
11
11
  export declare type AutocompleteRef<T extends SuggestionListItemData = SuggestionListItemData> = {
12
- /** get current active index */
13
12
  getActiveIndex: () => number;
14
- /** set current active index */
15
13
  setActiveIndex: (index: number) => void;
16
- /** get current filter result option items; */
17
14
  getFilterResultItems: () => T[];
18
- /** get current highlight index */
19
15
  getHighlightedIndex: () => number;
20
- /** set current highlight index */
21
16
  setHighlightedIndex: (index: number) => void;
22
- /**
23
- * keep highlightedIndex for next render when options change,
24
- * can use when lazy load more options
25
- */
26
17
  keepHighlightedIndex: () => void;
27
- /** open the listbox menu */
28
18
  openMenu: () => void;
29
- /** close the listbox menu */
30
19
  closeMenu: () => void;
31
- /** focus on text field input */
32
20
  focus: () => void;
33
- /** reset whole downshift, isFocus default is `false` */
34
21
  reset: (isFocus?: boolean) => void;
35
- /** method to clean input value */
36
22
  clearInput: () => void;
37
23
  };
38
24
  export declare type AutocompleteProps<T extends SuggestionListItemData = SuggestionListItemData> = StandardProps<{
39
- /** Determines the variant of the Autocomplete component. */
40
25
  variant?: 'autocomplete' | 'tags';
41
- /** If true, the component will take up the full width of its container.
42
- * @default `true`
43
- */
44
26
  fullWidth?: boolean;
45
- /** Specifies the variant of the input field. */
46
27
  inputVariant?: AutoCompleteTextFieldInputProps['variant'];
47
- /** Enables the toggle button for the dropdown menu. */
48
28
  toggleButton?: boolean;
49
- /** Props applied to the toggle button. */
50
29
  ToggleButtonProps?: Partial<IconButtonProps> & HTMLDataAttribute;
51
- /**
52
- * Props applied to the underlying IconButton component used for the clear button.
53
- * Allows customization of appearance and behavior.
54
- *
55
- * @example
56
- * ```tsx
57
- * ClearButtonProps={{
58
- * size: 'xsmall',
59
- * 'aria-label': 'Clear input',
60
- * }}
61
- * ```
62
- */
63
30
  ClearButtonProps?: Partial<IconButtonProps> & HTMLDataAttribute;
64
- /**
65
- * Function to get custom props for the toggle button based on the menu's open state.
66
- * Useful for customizing the toggle button icon.
67
- */
68
31
  getToggleButtonProps?: (isOpen: boolean) => AutocompleteProps<T>['ToggleButtonProps'];
69
- /**
70
- * A ref for imperative actions.
71
- *
72
- * - `getActiveIndex`: get current active index
73
- * - `setActiveIndex`: set current active index;
74
- * - `getFilterResultItems`: get current filter result option items;
75
- * - `getHighlightedIndex`: get current highlight index;
76
- * - `setHighlightedIndex`: set current highlight index;
77
- * - `openMenu`: open the listbox menu
78
- * - `closeMenu`: close the listbox menu
79
- * - `focus`: focus on text field input
80
- * - `reset(isFocus)`: reset whole downshift, `isFocus` default is `false`
81
- */
82
32
  action?: React.Ref<AutocompleteRef<T>>;
83
- /**
84
- * Custom rendering function for options Uses `getOptionLabel` by default.
85
- * @param option The option to render.
86
- * @param state The state of the component.
87
- * @returns A ReactNode representing the rendered option.
88
- */
89
33
  renderOption?: (option: T, state: AutocompleteRenderOptionState) => React.ReactNode;
90
- /** Custom component for rendering the popper. Defaults to Popper.
91
- * @default Popper
92
- */
93
34
  PopperComponent?: ComponentType<PopperProps>;
94
- /** Configuration props for the Popper component. */
95
35
  PopperProps?: Omit<Partial<PopperProps>, 'open' | 'keepMounted' | 'anchorEl' | 'classes'> & {
96
- /**
97
- * Determines the anchor element type for the popper.
98
- *
99
- * - `root`: on that whole TextField
100
- * - `input`: on that inside input
101
- * @default 'root'
102
- */
103
36
  anchorElType?: 'root' | 'input';
104
37
  } & ClassesProp<AutocompletePopperClassesKey>;
105
- /** Props for the suggestion list, supporting virtualized lists. */
106
38
  SuggestionListProps?: AutocompleteSuggestionListProps<T>;
107
- /**
108
- * Custom rendering function for the input field, default is `RcTextField`
109
- */
110
39
  renderInput?: (params: Partial<AutoCompleteTextFieldInputProps>) => React.ReactElement;
111
- /** If true, allows free solo input not bound to provided options. */
112
40
  freeSolo?: boolean;
113
- /**
114
- * If `true`, the placeholder will be displayed when multiple value is allowed and tags are present.
115
- * @default false
116
- */
117
41
  showPlaceholderWithTags?: boolean;
118
- /**
119
- * Custom rendering function for selected tags.
120
- *
121
- * @param selectedItems The selected items.
122
- * @param getTagProps Function to get props for each tag.
123
- * @returns A ReactNode representing the rendered tags.
124
- */
125
42
  renderTags?: (selectedItems: T[], getTagProps: (selectedItem: T, index: number) => Omit<GetTagProps<T>, 'children' | 'index' | 'selectedItem'> & {
126
43
  onDelete?: React.EventHandler<any>;
127
44
  }) => React.ReactNode;
128
- /** If true, the popup will ignore blur events. Useful for customization. */
129
45
  debug?: boolean;
130
46
  } & Omit<UseAutocompleteParams<T>, 'inputRef'> & Partial<Pick<UseAutocompleteParams<T>, 'inputRef'>> & Omit<AutoCompleteTextFieldInputProps, 'value' | 'variant' | 'onChange'> & Pick<SuggestionListProps, 'renderGroup'>, AutocompleteClassesKey, 'div'>;
131
47
  export interface AutocompleteComponent<T extends SuggestionListItemData = SuggestionListItemData> {
@@ -6,139 +6,55 @@ import suggestionListStyles from './styles/SuggestionList.css';
6
6
  import { SuggestionListClassesKey } from './SuggestionList.classes';
7
7
  import { SuggestionListItemProps } from './SuggestionListItem';
8
8
  import { SuggestionListGroupedOption, SuggestionListHighlightChangeReason, SuggestionListItemData, UseSuggestionListParams } from './utils';
9
+ export declare const DEFAULT_PADDING = 8;
9
10
  export interface AutocompleteRenderOptionState {
10
- /** current input value */
11
11
  inputValue?: string;
12
- /** is that item be show highlighted style */
13
12
  highlighted: boolean;
14
- /** that item index */
15
13
  index: number;
16
- /** sort index in option own group */
17
14
  indexInOwnGroup?: number;
18
- /** if that item is group title, that have that `expanded` state */
19
15
  expanded?: boolean;
20
- /** if that item is group title, that will have that `expandIconProps` */
21
16
  expandIconProps?: Partial<IconButtonProps>;
22
17
  }
23
- export declare type BaseSuggestionListProps<T, K = any> = Omit<Partial<VirtuosoProps<T, K>>, 'totalCount' | 'itemContent' | 'data' | 'color'> & ClassesProp<SuggestionListClassesKey> & HTMLDataAttribute;
18
+ export declare type BaseSuggestionListProps<T, K = Record<string, never>> = Omit<Partial<VirtuosoProps<T, K>>, 'totalCount' | 'itemContent' | 'data' | 'color'> & ClassesProp<SuggestionListClassesKey> & HTMLDataAttribute;
24
19
  export declare type SuggestionListProps<T extends SuggestionListItemData = SuggestionListItemData, K = any> = {
25
- /**
26
- * that virtual list container height,
27
- *
28
- * @default 100%
29
- */
30
20
  maxContainerHeight?: number | '100%';
31
- /**
32
- * vertical padding of the list
33
- *
34
- * @default 8
35
- */
36
21
  padding?: boolean | number;
37
- /** is that menu virtualize */
38
22
  virtualize?: boolean;
39
- /** current highlightedIndex */
40
23
  highlightedIndex: number;
41
- /** select options */
24
+ prevHighlightedIndex?: number;
42
25
  options: SuggestionListItemData[];
43
- /**
44
- * Used to determine the selected state for a given option.
45
- *
46
- * @param {T} option The option to test.
47
- * @returns {boolean}
48
- */
49
26
  getOptionSelected?: (option: T) => boolean;
50
- /** each item props getter */
51
27
  getItemProps: (options: {
52
28
  index?: number;
53
29
  item: T;
54
30
  }) => SuggestionListItemProps;
55
- /** list wrapper props getter */
56
31
  getSuggestionListProps: (restProps?: HTMLAttributes<HTMLDivElement> | undefined) => HTMLAttributes<HTMLDivElement>;
57
- /** that reason that change highlighted */
58
32
  changeHighlightedIndexReason?: SuggestionListHighlightChangeReason | undefined;
59
- /** is that need keep highlighted index, that will be helpful when you need load more options when scroll */
60
33
  isKeepHighlightedIndex?: boolean;
61
- /** trigger when need update outside popper position */
62
34
  onContainerHeightChange?: () => void;
63
- /** options group list, use for calculate `aria-setsize` */
64
35
  optionsGroupList?: SuggestionListGroupedOption<SuggestionListItemData>[];
65
- /**
66
- * Render the option, use `getOptionLabel` by default.
67
- *
68
- * @param {T} option The option to render.
69
- * @param {object} state The state of the component.
70
- * @returns {ReactNode}
71
- */
72
36
  renderOption?: (option: T, state: AutocompleteRenderOptionState) => React.ReactNode;
73
- /**
74
- * Render the group title item, also with for toggle button props.
75
- *
76
- * > when you have set custom `renderOption`, the `renderGroup` must be set.
77
- *
78
- * @param {T} option The option to render.
79
- * @param {object} state The state of the component.
80
- * @returns {ReactNode}
81
- */
82
37
  renderGroup?: (option: T, state: AutocompleteRenderOptionState) => React.ReactNode;
83
38
  } & Pick<UseSuggestionListParams, 'groupVariant' | 'groupExpanded' | 'inputValue' | 'getOptionDisabled' | 'getOptionLabel'> & BaseSuggestionListProps<T, K>;
39
+ export declare const getPaddingValue: (padding: boolean | number, itemCount: number) => number;
84
40
  export declare const SuggestionList: React.ForwardRefExoticComponent<{
85
- /**
86
- * that virtual list container height,
87
- *
88
- * @default 100%
89
- */
90
41
  maxContainerHeight?: number | "100%" | undefined;
91
- /**
92
- * vertical padding of the list
93
- *
94
- * @default 8
95
- */
96
42
  padding?: number | boolean | undefined;
97
- /** is that menu virtualize */
98
43
  virtualize?: boolean | undefined;
99
- /** current highlightedIndex */
100
44
  highlightedIndex: number;
101
- /** select options */
45
+ prevHighlightedIndex?: number | undefined;
102
46
  options: SuggestionListItemData[];
103
- /**
104
- * Used to determine the selected state for a given option.
105
- *
106
- * @param {T} option The option to test.
107
- * @returns {boolean}
108
- */
109
47
  getOptionSelected?: ((option: SuggestionListItemData) => boolean) | undefined;
110
- /** each item props getter */
111
48
  getItemProps: (options: {
112
49
  index?: number | undefined;
113
50
  item: SuggestionListItemData;
114
51
  }) => SuggestionListItemProps;
115
- /** list wrapper props getter */
116
52
  getSuggestionListProps: (restProps?: HTMLAttributes<HTMLDivElement> | undefined) => HTMLAttributes<HTMLDivElement>;
117
- /** that reason that change highlighted */
118
53
  changeHighlightedIndexReason?: SuggestionListHighlightChangeReason | undefined;
119
- /** is that need keep highlighted index, that will be helpful when you need load more options when scroll */
120
54
  isKeepHighlightedIndex?: boolean | undefined;
121
- /** trigger when need update outside popper position */
122
55
  onContainerHeightChange?: (() => void) | undefined;
123
- /** options group list, use for calculate `aria-setsize` */
124
56
  optionsGroupList?: SuggestionListGroupedOption<SuggestionListItemData>[] | undefined;
125
- /**
126
- * Render the option, use `getOptionLabel` by default.
127
- *
128
- * @param {T} option The option to render.
129
- * @param {object} state The state of the component.
130
- * @returns {ReactNode}
131
- */
132
57
  renderOption?: ((option: SuggestionListItemData, state: AutocompleteRenderOptionState) => React.ReactNode) | undefined;
133
- /**
134
- * Render the group title item, also with for toggle button props.
135
- *
136
- * > when you have set custom `renderOption`, the `renderGroup` must be set.
137
- *
138
- * @param {T} option The option to render.
139
- * @param {object} state The state of the component.
140
- * @returns {ReactNode}
141
- */
142
58
  renderGroup?: ((option: SuggestionListItemData, state: AutocompleteRenderOptionState) => React.ReactNode) | undefined;
143
59
  } & Pick<UseSuggestionListParams<SuggestionListItemData>, "getOptionDisabled" | "groupExpanded" | "groupVariant" | "inputValue" | "getOptionLabel"> & Omit<Partial<VirtuosoProps<SuggestionListItemData, any>>, "data" | "color" | "itemContent" | "totalCount"> & ClassesProp<SuggestionListClassesKey> & HTMLDataAttribute & React.RefAttributes<VirtuosoHandle>>;
144
60
  export { suggestionListStyles };
@@ -6,7 +6,6 @@ export declare type SuggestionListItemProps = {
6
6
  id?: string;
7
7
  label?: React.ReactNode;
8
8
  expanded?: boolean;
9
- expandable?: boolean;
10
9
  isGroupTitle?: boolean;
11
10
  isTitleMode?: boolean;
12
11
  selected?: boolean;
@@ -18,7 +17,6 @@ export declare const SuggestionListItem: import("react").ForwardRefExoticCompone
18
17
  id?: string | undefined;
19
18
  label?: React.ReactNode;
20
19
  expanded?: boolean | undefined;
21
- expandable?: boolean | undefined;
22
20
  isGroupTitle?: boolean | undefined;
23
21
  isTitleMode?: boolean | undefined;
24
22
  selected?: boolean | undefined;
@@ -2,32 +2,20 @@ import { ButtonHTMLAttributes, DetailedHTMLProps, PropsWithoutRef } from 'react'
2
2
  import { IconButtonProps } from '../../../IconButton';
3
3
  export interface SuggestionListGroupedOption<T = SuggestionListItemData> {
4
4
  options: T[];
5
- /** group key */
6
5
  key: number;
7
- /** group index in all options */
8
6
  index: number;
9
- /** group order in all group */
10
7
  order: number;
11
- /** group title */
12
8
  group: string;
13
- /** expanded state */
14
9
  expanded: boolean;
15
- /** The props apply to apply to the underlying `IconButton` */
16
10
  getExpandIconProps?: (additionalProps?: Omit<PropsWithoutRef<DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>>, 'color'> & Partial<IconButtonProps>) => Omit<PropsWithoutRef<DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>>, 'color'> | undefined | Partial<IconButtonProps>;
17
11
  }
18
12
  export declare type SuggestionListItemData = {
19
- /** children item id */
20
13
  id?: number | string;
21
- /** display label */
22
14
  label?: string;
23
- /** is that item disabled */
24
15
  disabled?: boolean;
25
- /** is that item error */
26
16
  error?: boolean;
27
- /** is that come from freeSolo item */
28
17
  freeSolo?: boolean;
29
- /** that item belongs group */
30
18
  group?: SuggestionListGroupedOption;
31
- /** default styles */
32
19
  className?: string;
33
20
  };
21
+ export declare const isFirstInGroup: (option: SuggestionListItemData) => boolean;
@@ -1,15 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  declare type UseDynamicHeightParams = {
3
- /** total items count */
4
3
  itemCount: number;
5
- /** max-height of container */
6
4
  maxContainerHeight?: number | '100%';
7
- /** trigger when container height need change */
8
5
  onContainerHeightChange?: (number: number) => void;
9
6
  };
10
- /**
11
- * auto calculate container height
12
- */
13
7
  export declare const useDynamicHeight: ({ itemCount, maxContainerHeight, onContainerHeightChange, }: UseDynamicHeightParams) => {
14
8
  containerHeighRef: import("react").MutableRefObject<number>;
15
9
  totalListHeightChanged: (height: number) => void;
@@ -1,33 +1,13 @@
1
1
  import React from 'react';
2
2
  import { FlatIndexLocationWithAlign, ListItem } from 'react-virtuoso';
3
3
  declare type UseHighlightScrollParams = {
4
- /** function to call to scroll to target index */
5
4
  scrollToIndex: (location: FlatIndexLocationWithAlign) => void;
6
- /** that scroll container height ref */
7
5
  containerHeighRef: React.MutableRefObject<number>;
8
6
  };
9
- /**
10
- * scroll into current highlight index
11
- */
12
7
  export declare function useHighlightScroll({ containerHeighRef, scrollToIndex, }: UseHighlightScrollParams): {
13
- /**
14
- * scroller reference
15
- */
16
8
  scrollerRef: React.MutableRefObject<HTMLElement | undefined>;
17
- /**
18
- * Scroll to target highlighted index
19
- * @param prevHighlightedIndex previous highlightedIndex
20
- * @param currHighlightedIndex current highlightedIndex
21
- * @param topHighlightIndex top highlighIndex for check should scroll when init
22
- */
23
9
  scrollToHighlightedIndex: (prevHighlightedIndex: number, currHighlightedIndex: number, topHighlightIndex?: number) => void;
24
- /**
25
- * set to virtuoso `scrollerRef` prop, auto bind inner `scrollerRef`
26
- */
27
10
  scrollerRefFn: (elm: HTMLElement) => HTMLElement;
28
- /**
29
- * set to virtuoso `itemsRendered` prop, auto bind inner `renderedItemsRef`
30
- */
31
11
  itemsRendered: (e: ListItem<unknown>[]) => ListItem<unknown>[];
32
12
  };
33
13
  export {};
@@ -11,64 +11,27 @@ export declare type SuggestionListGetItemPropsOptions<T> = {
11
11
  };
12
12
  export declare type SuggestionListHighlightChangeReason = 'keyboard' | 'mouse' | 'auto' | undefined;
13
13
  export declare type SuggestionListFilterOptions<T> = (options: T[], state: {
14
- /** current input value */
15
14
  inputValue?: string;
16
- /** is that input value have been changed or not */
17
15
  inputChanged?: boolean;
18
- /** get option label */
19
16
  getOptionLabel: (option: T) => string;
20
- /** current be selected item array */
21
17
  selectedItems: T[];
18
+ isOptionEqualToValue: (option: T, value: T) => boolean;
22
19
  }) => T[];
23
20
  export declare type UseSuggestionListParams<T extends SuggestionListItemData = SuggestionListItemData> = {
24
- /** current suggestion list unique id */
25
21
  id?: string;
26
- /** current text field input value */
27
22
  inputValue?: string;
28
- /** emit current input value */
29
23
  onInputChange?: (value: string) => void;
30
- /** that input ref you binding event */
31
24
  inputRef: React.RefObject<HTMLInputElement>;
32
- /**
33
- * If `true`, will allow disabled items highlightable.
34
- */
35
25
  disabledItemsHighlightable?: boolean;
36
- /**
37
- * process filtered options result, let you can handle result after filter
38
- */
39
26
  processFilteredResult?: (options: T[], inputValue: string) => T[];
40
- /**
41
- * A filter function that determines the options that are eligible.
42
- *
43
- * @param {T[]} options The options to render.
44
- * @param {object} state The state of the component.
45
- * @returns {T[]}
46
- */
47
27
  filterOptions?: SuggestionListFilterOptions<T>;
48
- /** emit when item be select */
49
28
  onSelect?: (event: React.ChangeEvent<{}>, selectedItems: T) => void;
50
- /**
51
- * @param event keydown event
52
- * @param highlightedIndex current menu highlightedIndex
53
- */
54
29
  onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>, highlightedIndex?: number | null) => void;
55
- /**
56
- * Trigger when click clear button.
57
- */
58
30
  onClear?: React.MouseEventHandler<HTMLButtonElement>;
59
- /**
60
- * Used to determine the string value for a given option.
61
- * It's used to fill the input (and the list box options if `renderOption` is not provided).
62
- *
63
- * @param {T} option
64
- * @returns {string}
65
- */
66
31
  getOptionLabel?: (option: T) => string;
32
+ isOptionEqualToValue?: (option: T, value: T) => boolean;
67
33
  } & Omit<UseAutocompleteGroupParams<T>, 'filteredResult' | 'id'>;
68
- /**
69
- * provide suggestion list with search function and expandable group with virtualized list
70
- */
71
- export declare const useSuggestionList: <T extends SuggestionListItemData = SuggestionListItemData>({ id, inputValue: inputValueProp, getOptionLabel, filterOptions, disabledItemsHighlightable, options, onInputChange: onInputChangeProp, inputRef, onKeyDown: onKeyDownProp, onSelect, onClear, getOptionDisabled, groupBy, onGroupExpanded, groupVariant, groupExpanded, groupDefaultExpanded, getExpandIconProps, processFilteredResult, }: UseSuggestionListParams<T>) => {
34
+ export declare const useSuggestionList: <T extends SuggestionListItemData = SuggestionListItemData>({ id, inputValue: inputValueProp, getOptionLabel, filterOptions, disabledItemsHighlightable, options, onInputChange: onInputChangeProp, inputRef, onKeyDown: onKeyDownProp, onSelect, onClear, getOptionDisabled, groupBy, onGroupExpanded, groupVariant, groupExpanded, groupDefaultExpanded, getExpandIconProps, processFilteredResult, isOptionEqualToValue, }: UseSuggestionListParams<T>) => {
72
35
  reset: (isFocus?: boolean | undefined) => void;
73
36
  clearInput: () => void;
74
37
  forceUpdate: () => void;
@@ -94,7 +57,6 @@ export declare const useSuggestionList: <T extends SuggestionListItemData = Sugg
94
57
  changeHighlightedIndexReasonRef: import("react").MutableRefObject<SuggestionListHighlightChangeReason>;
95
58
  changeHighlightedIndexReason: SuggestionListHighlightChangeReason;
96
59
  optionsGroupList: import("./SuggestionListItem").SuggestionListGroupedOption<T>[];
97
- /** current unique id */
98
60
  id: string;
99
61
  getNextFocusableOption: (index?: number, isInfinite?: any) => number;
100
62
  handleF10KeyDown: (e: React.KeyboardEvent<HTMLInputElement | HTMLTextAreaElement>) => void;