@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
package/Radio.js CHANGED
@@ -1,37 +1,81 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import { forwardRef } from 'react';
3
- import { useSwitch } from '@mui/base';
4
- import { useClasses } from '@ringcentral/spring-base';
5
- import { useThemeProps } from '@ringcentral/spring-theme';
6
- import { u as useFormLabel } from './chunks/FormLabel.js';
7
- import { u as useRadioGroup } from './chunks/RadioGroup.context.js';
8
-
9
- var Radio$1 = {"sui-radio-root":"sui-radio-root","sui-focus-visible":"sui-focus-visible","sui-disabled":"sui-disabled","sui-radio-input":"sui-radio-input","sui-radio-dot":"sui-radio-dot","sui-checked":"sui-checked"};
10
-
11
- const Radio = forwardRef((inProps, ref) => {
12
- const props = useThemeProps({ props: inProps, name: 'Radio' });
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { forwardRef } from "react";
3
+ import { useSwitch } from "@mui/base";
4
+ import { useClasses } from "@ringcentral/spring-base";
5
+ import { useThemeProps } from "@ringcentral/spring-theme";
6
+ import { useFormLabel } from "./FormLabel.js";
7
+ import { useRadioGroup } from "./chunks/9551.js";
8
+
9
+
10
+
11
+
12
+
13
+
14
+ // extracted by css-extract-rspack-plugin
15
+ /* export default */ var Radio = ({"sui-radio-root":"sui-radio-root","sui-focus-visible":"sui-focus-visible","sui-disabled":"sui-disabled","sui-radio-input":"sui-radio-input","sui-radio-dot":"sui-radio-dot","sui-checked":"sui-checked"});
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+ const Radio_Radio = /*#__PURE__*/ forwardRef((inProps, ref)=>{
25
+ const props = useThemeProps({
26
+ props: inProps,
27
+ name: 'Radio'
28
+ });
13
29
  const { name = '', classes, inputRef, rootProps, inputProps, disabled: disabledProp, className: rootClass, ...rest } = props;
14
30
  const cls = useClasses('radio', classes, rootClass);
15
31
  const { disabled, id, value } = useFormLabel({
16
32
  value: rest.value,
17
33
  id: inputProps?.id,
18
- disabled: disabledProp,
34
+ disabled: disabledProp
19
35
  });
20
36
  const { focusVisible, getInputProps, checked } = useSwitch({
21
37
  ...rest,
22
- disabled,
38
+ disabled
23
39
  });
24
40
  const { onChange, ...inputRest } = getInputProps({
25
41
  role: undefined,
26
- ...inputProps,
42
+ ...inputProps
43
+ });
44
+ const context = useRadioGroup({
45
+ name,
46
+ value,
47
+ checked,
48
+ onChange
27
49
  });
28
- const context = useRadioGroup({ name, value, checked, onChange });
29
- return (jsxs("div", { ...rootProps, ref: ref, className: cls('root', {
50
+ return /*#__PURE__*/ jsxs("div", {
51
+ ...rootProps,
52
+ ref: ref,
53
+ className: cls('root', {
30
54
  disabled,
31
55
  focusVisible,
32
- checked: context.checked,
33
- }), children: [jsx("span", { className: cls('dot') }), jsx("input", { ...inputRest, ...context, id: id, type: "radio", ref: inputRef, value: value, className: cls('input') })] }));
56
+ checked: context.checked
57
+ }),
58
+ children: [
59
+ /*#__PURE__*/ jsx("span", {
60
+ className: cls('dot')
61
+ }),
62
+ /*#__PURE__*/ jsx("input", {
63
+ ...inputRest,
64
+ ...context,
65
+ id: id,
66
+ type: "radio",
67
+ ref: inputRef,
68
+ value: value,
69
+ className: cls('input')
70
+ })
71
+ ]
72
+ });
34
73
  });
35
- Radio.displayName = 'SuiRadio';
74
+ Radio_Radio.displayName = 'SuiRadio';
75
+
76
+
77
+
78
+
79
+
36
80
 
37
- export { Radio, Radio$1 as radioStyle };
81
+ export { Radio as radioStyle, Radio_Radio as Radio };
package/RadioGroup.js CHANGED
@@ -1,29 +1,68 @@
1
- import { R as RadioGroupContext, c as callbacksInSeries } from './chunks/RadioGroup.context.js';
2
- export { u as useRadioGroup } from './chunks/RadioGroup.context.js';
3
- import { jsx } from 'react/jsx-runtime';
4
- import { forwardRef, useMemo } from 'react';
5
- import { useControlled, useClasses } from '@ringcentral/spring-base';
6
- import { useThemeProps } from '@ringcentral/spring-theme';
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { forwardRef, useMemo } from "react";
3
+ import { useClasses, useControlled } from "@ringcentral/spring-base";
4
+ import { useThemeProps } from "@ringcentral/spring-theme";
5
+ import { callbacksInSeries, RadioGroupContext } from "./chunks/9551.js";
7
6
 
8
- var RadioGroup$1 = {"sui-radio-group-root":"sui-radio-group-root","sui-radio-group-row":"sui-radio-group-row"};
9
7
 
10
- const RadioGroup = forwardRef((inProps, ref) => {
11
- const props = useThemeProps({ props: inProps, name: 'RadioGroup' });
8
+
9
+
10
+
11
+ // extracted by css-extract-rspack-plugin
12
+ /* export default */ var RadioGroup = ({"sui-radio-group-root":"sui-radio-group-root","sui-radio-group-row":"sui-radio-group-row"});
13
+
14
+
15
+
16
+
17
+
18
+
19
+ const RadioGroup_RadioGroup = /*#__PURE__*/ forwardRef((inProps, ref)=>{
20
+ const props = useThemeProps({
21
+ props: inProps,
22
+ name: 'RadioGroup'
23
+ });
12
24
  const { row, classes, className, children, value: controlled, name, defaultValue, onChange, ...rest } = props;
13
25
  const [value, setValue] = useControlled({
14
26
  name,
15
27
  controlled,
16
- default: defaultValue,
28
+ default: defaultValue
17
29
  });
18
- const radioGroupContext = useMemo(() => {
19
- const handleChange = callbacksInSeries(onChange, (e) => {
30
+ const radioGroupContext = useMemo(()=>{
31
+ const handleChange = callbacksInSeries(onChange, (e)=>{
20
32
  setValue(e.target.value);
21
33
  });
22
- return { name, value, onChange: handleChange };
23
- }, [name, value, setValue, onChange]);
34
+ return {
35
+ name,
36
+ value,
37
+ onChange: handleChange
38
+ };
39
+ }, [
40
+ name,
41
+ value,
42
+ setValue,
43
+ onChange
44
+ ]);
24
45
  const cls = useClasses('radio-group', classes, className);
25
- return (jsx("div", { ...rest, ref: ref, role: "radiogroup", className: cls('root', { row }), children: jsx(RadioGroupContext.Provider, { value: radioGroupContext, children: children }) }));
46
+ return /*#__PURE__*/ jsx("div", {
47
+ ...rest,
48
+ ref: ref,
49
+ role: "radiogroup",
50
+ className: cls('root', {
51
+ row
52
+ }),
53
+ children: /*#__PURE__*/ jsx(RadioGroupContext.Provider, {
54
+ value: radioGroupContext,
55
+ children: children
56
+ })
57
+ });
26
58
  });
27
- RadioGroup.displayName = 'SuiRadioGroup';
59
+ RadioGroup_RadioGroup.displayName = 'SuiRadioGroup';
60
+
61
+
62
+
63
+
64
+
65
+
28
66
 
29
- export { RadioGroup, RadioGroupContext, callbacksInSeries, RadioGroup$1 as radioGroupStyle };
67
+ export { RadioGroup as radioGroupStyle, RadioGroup_RadioGroup as RadioGroup };
68
+ export { RadioGroupContext, callbacksInSeries, useRadioGroup } from "./chunks/9551.js";
package/Rating.js CHANGED
@@ -1,11 +1,25 @@
1
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import { forwardRef, cloneElement, useState, useRef, useMemo } from 'react';
3
- import clamp from 'lodash/clamp';
4
- import { useId, useClasses, useControlled, useIsFocusVisible, useForkRef } from '@ringcentral/spring-base';
5
- import { useThemeProps } from '@ringcentral/spring-theme';
6
- import { S as Squircle } from './chunks/Squircle.js';
7
- import { StarFilledMd, StarMd } from '@ringcentral/spring-icon';
8
- import { I as Icon } from './chunks/Icon.js';
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { cloneElement, forwardRef, useMemo, useRef, useState } from "react";
3
+ import clamp from "lodash/clamp";
4
+ import { useClasses, useControlled, useForkRef, useId, useIsFocusVisible } from "@ringcentral/spring-base";
5
+ import { useThemeProps } from "@ringcentral/spring-theme";
6
+ import { StarFilledMd, StarMd } from "@ringcentral/spring-icon";
7
+ import { Icon as Icon_Icon } from "./chunks/8307.js";
8
+ import "./Squircle.js";
9
+ import { Squircle as Squircle_Squircle } from "./chunks/1250.js";
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
9
23
 
10
24
  function getDecimalPrecision(num) {
11
25
  const decimalPart = num.toString().split('.')[1];
@@ -18,61 +32,132 @@ function roundValueToPrecision(value, precision) {
18
32
  const nearest = Math.round(value / precision) * precision;
19
33
  return Number(nearest.toFixed(getDecimalPrecision(precision)));
20
34
  }
21
- const defaultIcon = jsx(Icon, { symbol: StarFilledMd, size: "large" });
22
- const defaultEmptyIcon = jsx(Icon, { symbol: StarMd, size: "large" });
35
+ const defaultIcon = /*#__PURE__*/ jsx(Icon_Icon, {
36
+ symbol: StarFilledMd,
37
+ size: "large"
38
+ });
39
+ const defaultEmptyIcon = /*#__PURE__*/ jsx(Icon_Icon, {
40
+ symbol: StarMd,
41
+ size: "large"
42
+ });
23
43
  function defaultLabelText(value) {
24
44
  return `${value || '0'} Star${value !== 1 ? 's' : ''}`;
25
45
  }
26
46
 
27
- const RatingItem = forwardRef((inProps, ref) => {
28
- const { classes, disabled, emptyIcon = defaultEmptyIcon, getLabelText = defaultLabelText, icon = defaultIcon, IconContainerComponent = 'div', size = 'large', focus, highlightSelectedOnly, hover, isActive, focusVisible, itemValue, name, onBlur, onChange, onClick, onFocus, readOnly, ratingValue, className, ratingValueRounded, style, } = inProps;
29
- const isFilled = highlightSelectedOnly
30
- ? itemValue === ratingValue
31
- : ratingValue && itemValue <= ratingValue;
47
+
48
+
49
+
50
+
51
+
52
+ const RatingItem = /*#__PURE__*/ forwardRef((inProps, ref)=>{
53
+ const { classes, disabled, emptyIcon = defaultEmptyIcon, getLabelText = defaultLabelText, icon = defaultIcon, IconContainerComponent = 'div', size = 'large', focus, highlightSelectedOnly, hover, isActive, focusVisible, itemValue, name, onBlur, onChange, onClick, onFocus, readOnly, ratingValue, className, ratingValueRounded, style } = inProps;
54
+ const isFilled = highlightSelectedOnly ? itemValue === ratingValue : ratingValue && itemValue <= ratingValue;
32
55
  const isFocused = itemValue <= focus;
33
56
  const isChecked = itemValue === ratingValueRounded;
34
57
  const id = useId();
35
58
  const cls = useClasses('rating', classes, className);
36
59
  const renderedIcon = emptyIcon && !isFilled ? emptyIcon : icon;
37
- const container = (jsx("div", { className: cls('icon', {
60
+ const container = /*#__PURE__*/ jsx("div", {
61
+ className: cls('icon', {
38
62
  'icon-empty': !isFilled,
39
63
  'icon-filled': !!isFilled,
40
64
  'icon-focus': isFocused,
41
- 'icon-active': isActive,
42
- }), children: size
43
- ? cloneElement(renderedIcon, {
44
- size,
45
- })
46
- : renderedIcon }));
65
+ 'icon-active': isActive
66
+ }),
67
+ children: size ? /*#__PURE__*/ cloneElement(renderedIcon, {
68
+ size
69
+ }) : renderedIcon
70
+ });
47
71
  if (readOnly) {
48
- return (jsx("span", { style: style, className: cls('read-only'), children: jsx(IconContainerComponent, { className: cls('label-container'), children: container }) }));
72
+ return /*#__PURE__*/ jsx("span", {
73
+ style: style,
74
+ className: cls('read-only'),
75
+ children: /*#__PURE__*/ jsx(IconContainerComponent, {
76
+ className: cls('label-container'),
77
+ children: container
78
+ })
79
+ });
49
80
  }
50
- return (jsxs(Fragment, { children: [jsxs("label", { ref: ref, htmlFor: id, className: cls('label', {
81
+ return /*#__PURE__*/ jsxs(Fragment, {
82
+ children: [
83
+ /*#__PURE__*/ jsxs("label", {
84
+ ref: ref,
85
+ htmlFor: id,
86
+ className: cls('label', {
51
87
  disabled,
52
- focusVisible,
53
- }), style: style, children: [jsxs(IconContainerComponent, { className: cls('label-container'), children: [jsx(Squircle, { classes: {
54
- content: cls('squircle-content'),
55
- }, interactive: true, focusVisible: isActive && focusVisible, className: cls('squircle', {
56
- 'icon-hover': Math.ceil(hover) === itemValue,
57
- }) }), container] }), jsx("span", { className: cls('visually-hidden'), children: getLabelText(itemValue) })] }), jsx("input", { className: cls('visually-hidden'), onFocus: onFocus, onBlur: onBlur, onChange: onChange, onClick: onClick, disabled: disabled, value: itemValue, id: id, type: "radio", name: name, checked: isChecked })] }));
88
+ focusVisible
89
+ }),
90
+ style: style,
91
+ children: [
92
+ /*#__PURE__*/ jsxs(IconContainerComponent, {
93
+ className: cls('label-container'),
94
+ children: [
95
+ /*#__PURE__*/ jsx(Squircle_Squircle, {
96
+ classes: {
97
+ content: cls('squircle-content')
98
+ },
99
+ interactive: true,
100
+ focusVisible: isActive && focusVisible,
101
+ className: cls('squircle', {
102
+ 'icon-hover': Math.ceil(hover) === itemValue
103
+ })
104
+ }),
105
+ container
106
+ ]
107
+ }),
108
+ /*#__PURE__*/ jsx("span", {
109
+ className: cls('visually-hidden'),
110
+ children: getLabelText(itemValue)
111
+ })
112
+ ]
113
+ }),
114
+ /*#__PURE__*/ jsx("input", {
115
+ className: cls('visually-hidden'),
116
+ onFocus: onFocus,
117
+ onBlur: onBlur,
118
+ onChange: onChange,
119
+ onClick: onClick,
120
+ disabled: disabled,
121
+ value: itemValue,
122
+ id: id,
123
+ type: "radio",
124
+ name: name,
125
+ checked: isChecked
126
+ })
127
+ ]
128
+ });
58
129
  });
59
130
  RatingItem.displayName = 'SuiRatingItem';
60
131
 
61
- var Rating$1 = {"sui-rating-root":"sui-rating-root","sui-disabled":"sui-disabled","sui-rating-icon-empty":"sui-rating-icon-empty","sui-rating-squircle":"sui-rating-squircle","sui-rating-squircle-content":"sui-rating-squircle-content","sui-rating-icon-hover":"sui-rating-icon-hover","sui-active":"sui-active","sui-rating-read-only":"sui-rating-read-only","sui-rating-decimal":"sui-rating-decimal","sui-rating-label":"sui-rating-label","sui-rating-label-container":"sui-rating-label-container","sui-rating-label-empty-value":"sui-rating-label-empty-value","sui-rating-empty-value-focused":"sui-rating-empty-value-focused","sui-rating-visually-hidden":"sui-rating-visually-hidden","sui-rating-icon":"sui-rating-icon","sui-rating-icon-filled":"sui-rating-icon-filled"};
132
+ // extracted by css-extract-rspack-plugin
133
+ /* export default */ var Rating = ({"sui-rating-root":"sui-rating-root","sui-disabled":"sui-disabled","sui-rating-icon-empty":"sui-rating-icon-empty","sui-rating-squircle":"sui-rating-squircle","sui-rating-squircle-content":"sui-rating-squircle-content","sui-rating-icon-hover":"sui-rating-icon-hover","sui-active":"sui-active","sui-rating-read-only":"sui-rating-read-only","sui-rating-decimal":"sui-rating-decimal","sui-rating-label":"sui-rating-label","sui-rating-label-container":"sui-rating-label-container","sui-rating-label-empty-value":"sui-rating-label-empty-value","sui-rating-empty-value-focused":"sui-rating-empty-value-focused","sui-rating-visually-hidden":"sui-rating-visually-hidden","sui-rating-icon":"sui-rating-icon","sui-rating-icon-filled":"sui-rating-icon-filled"});
134
+
135
+
136
+
137
+
138
+
139
+
62
140
 
63
- const Rating = forwardRef((inProps, ref) => {
64
- const props = useThemeProps({ name: 'Rating', props: inProps });
141
+
142
+ const Rating_Rating = /*#__PURE__*/ forwardRef((inProps, ref)=>{
143
+ const props = useThemeProps({
144
+ name: 'Rating',
145
+ props: inProps
146
+ });
65
147
  const { className, classes, defaultValue = null, disabled = false, emptyLabelText = 'Empty', highlightSelectedOnly = false, icon, max = 5, name: nameProp, onChange, onChangeActive, onMouseLeave, onMouseMove, precision = 1, readOnly = false, emptyIcon, getLabelText = defaultLabelText, IconContainerComponent, value: valueProp, size, ...rest } = props;
66
148
  const name = useId(nameProp);
67
149
  const [valueDerived, setValueState] = useControlled({
68
150
  controlled: valueProp,
69
151
  default: defaultValue,
70
- name: 'SuiRating',
152
+ name: 'SuiRating'
71
153
  });
72
154
  const valueRounded = roundValueToPrecision(valueDerived, precision);
155
+ // const isRtl = useRtl();
156
+ // * spring still not support rtl
157
+ const isRtl = false;
73
158
  const [{ hover, focus }, setState] = useState({
74
159
  hover: -1,
75
- focus: -1,
160
+ focus: -1
76
161
  });
77
162
  let value = valueRounded;
78
163
  if (hover !== -1) {
@@ -81,48 +166,51 @@ const Rating = forwardRef((inProps, ref) => {
81
166
  if (focus !== -1) {
82
167
  value = focus;
83
168
  }
84
- const { isFocusVisibleRef, onBlur: handleBlurVisible, onFocus: handleFocusVisible, ref: focusVisibleRef, } = useIsFocusVisible();
169
+ const { isFocusVisibleRef, onBlur: handleBlurVisible, onFocus: handleFocusVisible, ref: focusVisibleRef } = useIsFocusVisible();
85
170
  const [focusVisible, setFocusVisible] = useState(false);
86
171
  const rootRef = useRef();
87
172
  const handleRef = useForkRef(focusVisibleRef, rootRef, ref);
88
- const handleMouseMove = (event) => {
173
+ const handleMouseMove = (event)=>{
89
174
  if (onMouseMove) {
90
175
  onMouseMove(event);
91
176
  }
177
+ // oxlint-disable-next-line @typescript-eslint/no-non-null-assertion
92
178
  const rootNode = rootRef.current;
93
- const { right, left, width: containerWidth, } = rootNode.getBoundingClientRect();
179
+ const { right, left, width: containerWidth } = rootNode.getBoundingClientRect();
94
180
  let percent;
95
- {
181
+ if (isRtl) {
182
+ percent = (right - event.clientX) / containerWidth;
183
+ } else {
96
184
  percent = (event.clientX - left) / containerWidth;
97
185
  }
98
186
  let newHover = roundValueToPrecision(max * percent + precision / 2, precision);
99
187
  newHover = clamp(newHover, precision, max);
100
- setState((prev) => prev.hover === newHover && prev.focus === newHover
101
- ? prev
102
- : {
188
+ setState((prev)=>prev.hover === newHover && prev.focus === newHover ? prev : {
103
189
  hover: newHover,
104
- focus: newHover,
190
+ focus: newHover
105
191
  });
106
192
  setFocusVisible(false);
107
193
  if (onChangeActive && hover !== newHover) {
108
194
  onChangeActive(event, newHover);
109
195
  }
110
196
  };
111
- const handleMouseLeave = (event) => {
197
+ const handleMouseLeave = (event)=>{
112
198
  if (onMouseLeave) {
113
199
  onMouseLeave(event);
114
200
  }
115
201
  const newHover = -1;
116
202
  setState({
117
203
  hover: newHover,
118
- focus: newHover,
204
+ focus: newHover
119
205
  });
120
206
  if (onChangeActive && hover !== newHover) {
121
207
  onChangeActive(event, newHover);
122
208
  }
123
209
  };
124
- const handleChange = (event) => {
210
+ const handleChange = (event)=>{
125
211
  let newValue = event.target.value === '' ? null : parseFloat(event.target.value);
212
+ // Give mouse priority over keyboard
213
+ // Fix https://github.com/mui/material-ui/issues/22827
126
214
  if (hover !== -1) {
127
215
  newValue = hover;
128
216
  }
@@ -131,32 +219,33 @@ const Rating = forwardRef((inProps, ref) => {
131
219
  onChange(event, newValue);
132
220
  }
133
221
  };
134
- const handleClear = (event) => {
222
+ const handleClear = (event)=>{
223
+ // Ignore keyboard events
224
+ // https://github.com/facebook/react/issues/7407
135
225
  if (event.clientX === 0 && event.clientY === 0) {
136
226
  return;
137
227
  }
138
228
  setState({
139
229
  hover: -1,
140
- focus: -1,
230
+ focus: -1
141
231
  });
142
232
  setValueState(null);
143
- if (onChange &&
144
- parseFloat(event.target.value) === valueRounded) {
233
+ if (onChange && parseFloat(event.target.value) === valueRounded) {
145
234
  onChange(event, null);
146
235
  }
147
236
  };
148
- const handleFocus = (event) => {
237
+ const handleFocus = (event)=>{
149
238
  handleFocusVisible(event);
150
239
  if (isFocusVisibleRef.current === true) {
151
240
  setFocusVisible(true);
152
241
  }
153
242
  const newFocus = parseFloat(event.target.value);
154
- setState((prev) => ({
155
- hover: prev.hover,
156
- focus: newFocus,
157
- }));
243
+ setState((prev)=>({
244
+ hover: prev.hover,
245
+ focus: newFocus
246
+ }));
158
247
  };
159
- const handleBlur = (event) => {
248
+ const handleBlur = (event)=>{
160
249
  if (hover !== -1) {
161
250
  return;
162
251
  }
@@ -165,18 +254,29 @@ const Rating = forwardRef((inProps, ref) => {
165
254
  setFocusVisible(false);
166
255
  }
167
256
  const newFocus = -1;
168
- setState((prev) => ({
169
- hover: prev.hover,
170
- focus: newFocus,
171
- }));
257
+ setState((prev)=>({
258
+ hover: prev.hover,
259
+ focus: newFocus
260
+ }));
172
261
  };
173
262
  const [emptyValueFocused, setEmptyValueFocused] = useState(false);
174
263
  const cls = useClasses('rating', classes, className);
175
- const ratingValues = useMemo(() => Array.from(new Array(max)), [max]);
176
- return (jsxs("div", { ref: handleRef, onMouseMove: handleMouseMove, onMouseLeave: handleMouseLeave, className: cls('root', {
264
+ const ratingValues = useMemo(()=>Array.from(new Array(max)), [
265
+ max
266
+ ]);
267
+ return /*#__PURE__*/ jsxs("div", {
268
+ ref: handleRef,
269
+ onMouseMove: handleMouseMove,
270
+ onMouseLeave: handleMouseLeave,
271
+ className: cls('root', {
177
272
  'read-only': readOnly,
178
- disabled,
179
- }), role: readOnly ? 'img' : undefined, "aria-label": readOnly ? getLabelText(value) : undefined, ...rest, children: [ratingValues.map((_, index) => {
273
+ disabled
274
+ }),
275
+ role: readOnly ? 'img' : undefined,
276
+ "aria-label": readOnly ? getLabelText(value) : undefined,
277
+ ...rest,
278
+ children: [
279
+ ratingValues.map((_, index)=>{
180
280
  const itemValue = index + 1;
181
281
  const ratingItemProps = {
182
282
  classes,
@@ -197,34 +297,70 @@ const Rating = forwardRef((inProps, ref) => {
197
297
  onBlur: handleBlur,
198
298
  onChange: handleChange,
199
299
  onClick: handleClear,
200
- onFocus: handleFocus,
300
+ onFocus: handleFocus
201
301
  };
202
- const isActive = itemValue === Math.ceil(value) &&
203
- (hover !== -1 || focus !== -1);
302
+ const isActive = itemValue === Math.ceil(value) && (hover !== -1 || focus !== -1);
204
303
  if (precision < 1) {
205
304
  const items = Array.from(new Array(1 / precision));
206
- return (jsx("div", { className: cls('decimal', {
305
+ return /*#__PURE__*/ jsx("div", {
306
+ className: cls('decimal', {
207
307
  'icon-active': isActive,
208
- focusVisible,
209
- }), children: items.map(($, indexDecimal) => {
308
+ focusVisible
309
+ }),
310
+ children: items.map(($, indexDecimal)=>{
210
311
  const itemDecimalValue = roundValueToPrecision(itemValue - 1 + (indexDecimal + 1) * precision, precision);
211
- return (jsx(RatingItem, { ...ratingItemProps, isActive: isActive && Math.ceil(focus) === itemDecimalValue, itemValue: itemDecimalValue, style: items.length - 1 === indexDecimal
212
- ? undefined
213
- : {
214
- width: itemDecimalValue === value
215
- ? `${(indexDecimal + 1) * precision * 100}%`
216
- : '0%',
217
- overflow: 'hidden',
218
- position: 'absolute',
219
- zIndex: 1,
220
- } }, itemDecimalValue));
221
- }) }, itemValue));
312
+ return /*#__PURE__*/ jsx(RatingItem, {
313
+ ...ratingItemProps,
314
+ isActive: isActive && Math.ceil(focus) === itemDecimalValue,
315
+ itemValue: itemDecimalValue,
316
+ style: items.length - 1 === indexDecimal ? undefined : {
317
+ width: itemDecimalValue === value ? `${(indexDecimal + 1) * precision * 100}%` : '0%',
318
+ overflow: 'hidden',
319
+ position: 'absolute',
320
+ zIndex: 1
321
+ }
322
+ }, itemDecimalValue);
323
+ })
324
+ }, itemValue);
222
325
  }
223
- return (jsx(RatingItem, { ...ratingItemProps, isActive: isActive, itemValue: itemValue }, itemValue));
224
- }), !readOnly && !disabled && (jsxs("label", { className: cls('label', 'label-empty-value', {
225
- 'empty-value-focused': emptyValueFocused,
226
- }), children: [jsx("input", { className: cls('visually-hidden'), value: "", id: `${name}-empty`, type: "radio", name: name, checked: valueRounded == null, onFocus: () => setEmptyValueFocused(true), onBlur: () => setEmptyValueFocused(false), onChange: handleChange }), jsx("span", { className: cls('visually-hidden'), children: emptyLabelText })] }))] }));
326
+ return /*#__PURE__*/ jsx(RatingItem, {
327
+ ...ratingItemProps,
328
+ isActive: isActive,
329
+ itemValue: itemValue
330
+ }, itemValue);
331
+ }),
332
+ !readOnly && !disabled && /*#__PURE__*/ jsxs("label", {
333
+ className: cls('label', 'label-empty-value', {
334
+ 'empty-value-focused': emptyValueFocused
335
+ }),
336
+ children: [
337
+ /*#__PURE__*/ jsx("input", {
338
+ className: cls('visually-hidden'),
339
+ value: "",
340
+ id: `${name}-empty`,
341
+ type: "radio",
342
+ name: name,
343
+ checked: valueRounded == null,
344
+ onFocus: ()=>setEmptyValueFocused(true),
345
+ onBlur: ()=>setEmptyValueFocused(false),
346
+ onChange: handleChange
347
+ }),
348
+ /*#__PURE__*/ jsx("span", {
349
+ className: cls('visually-hidden'),
350
+ children: emptyLabelText
351
+ })
352
+ ]
353
+ })
354
+ ]
355
+ });
227
356
  });
228
- Rating.displayName = 'SuiRating';
357
+ Rating_Rating.displayName = 'SuiRating';
358
+
359
+
360
+
361
+
362
+
363
+
364
+
229
365
 
230
- export { Rating, RatingItem, defaultEmptyIcon, defaultIcon, defaultLabelText, Rating$1 as ratingStyle, roundValueToPrecision };
366
+ export { Rating as ratingStyle, RatingItem, Rating_Rating as Rating, defaultEmptyIcon, defaultIcon, defaultLabelText, roundValueToPrecision };