@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.
- package/Accordion.js +90 -34
- package/AccordionHeader.js +72 -20
- package/Alert.js +120 -28
- package/Animation.js +2 -45
- package/Announcement.js +46 -35
- package/Autocomplete.js +1011 -580
- package/Avatar.js +134 -73
- package/AvatarGroup.js +50 -7
- package/Backdrop.js +45 -7
- package/Badge.js +77 -15
- package/Block.js +34 -12
- package/BlockHeader.js +55 -11
- package/BottomNavigation.js +181 -65
- package/BottomNavigationItem.js +93 -30
- package/Button.js +160 -24
- package/CallButton.js +53 -31
- package/Checkbox.js +88 -26
- package/Chip.js +126 -26
- package/CircularProgressIndicator.js +80 -8
- package/ClickAwayListener.js +4 -1
- package/ComponentsProps.js +1 -0
- package/DatePicker.js +611 -190
- package/DateUtilsContext.js +43 -25
- package/Dialer.js +576 -250
- package/Dialog.js +100 -45
- package/Divider.js +43 -7
- package/DragHandle.js +32 -6
- package/Drawer.js +117 -19
- package/Dropdown.js +154 -74
- package/EmptyState.js +63 -11
- package/FabButton.js +51 -17
- package/FocusTrap.js +109 -12
- package/FormField.js +106 -8
- package/FormLabel.js +81 -7
- package/Icon.js +1 -8
- package/IconButton.js +142 -26
- package/IconButtonGroup.js +35 -12
- package/InlineEditable.js +98 -44
- package/LinearProgressIndicator.js +73 -24
- package/Link.js +40 -11
- package/List.js +54 -9
- package/ListItem.js +152 -23
- package/ListItemText.js +44 -16
- package/ListNavigation.js +272 -20
- package/Menu.js +139 -23
- package/MenuActions.js +37 -12
- package/MenuDivider.js +34 -8
- package/MenuFooter.js +36 -12
- package/MenuHeader.js +54 -15
- package/MenuItem.js +402 -33
- package/MenuItemText.js +51 -8
- package/MenuList.js +87 -34
- package/Modal.js +345 -16
- package/NestedMenuContext.js +183 -11
- package/Option.js +32 -34
- package/Overlap.js +54 -7
- package/PageHeader.js +62 -24
- package/PickerTextField.js +156 -33
- package/Popover.js +262 -21
- package/Popper.js +130 -77
- package/PopperPaper.js +54 -8
- package/Portal.js +6 -1
- package/Radio.js +65 -21
- package/RadioGroup.js +56 -17
- package/Rating.js +223 -87
- package/Select.js +387 -41
- package/SingleFilter.js +148 -77
- package/Skeleton.js +68 -17
- package/Slider.js +168 -69
- package/Snackbar.js +122 -59
- package/SortableList.js +32 -12
- package/SortableListDndContext.js +69 -22
- package/SortableListItem.js +92 -47
- package/SortableVirtualizedList.js +52 -28
- package/SplitButton.js +124 -86
- package/Squircle.js +4 -7
- package/StatusIndicator.js +51 -9
- package/Step.js +63 -38
- package/StepButton.js +51 -23
- package/StepConnector.js +48 -8
- package/StepContent.js +68 -25
- package/StepIcon.js +90 -9
- package/StepLabel.js +90 -14
- package/Stepper.js +65 -23
- package/SubMenu.js +203 -99
- package/SwipeableDrawer.js +439 -194
- package/Switch.js +70 -23
- package/Tab.js +120 -57
- package/TabContext.js +59 -15
- package/TabPanel.js +40 -13
- package/Table.js +60 -17
- package/TableBody.js +42 -12
- package/TableCell.js +84 -50
- package/TableContainer.js +32 -10
- package/TableFooter.js +38 -10
- package/TableHead.js +49 -15
- package/TablePagination.js +153 -77
- package/TableRow.js +60 -21
- package/Tabs.js +593 -268
- package/Tag.js +51 -16
- package/Text.js +68 -37
- package/TextField.js +209 -29
- package/Textarea.js +51 -40
- package/TimePicker.js +490 -230
- package/Tooltip.js +48 -23
- package/Tray.js +237 -13
- package/TrayMenu.js +62 -41
- package/VirtualizedList.js +208 -109
- package/VirtualizedMenu.js +359 -29
- package/VisuallyHidden.js +29 -6
- package/chunks/1250.js +98 -0
- package/chunks/1294.js +126 -0
- package/chunks/2956.js +18 -0
- package/chunks/4476.js +460 -0
- package/chunks/4491.js +10 -0
- package/chunks/4535.js +364 -0
- package/chunks/5047.js +3 -0
- package/chunks/6335.js +24 -0
- package/chunks/7279.js +10 -0
- package/chunks/8011.js +8 -0
- package/chunks/8307.js +56 -0
- package/chunks/8467.js +8 -0
- package/chunks/8809.js +8 -0
- package/chunks/{RadioGroup.context.js → 9551.js} +12 -6
- package/chunks/987.js +8 -0
- package/index.css +2624 -2416
- package/index.js +245 -193
- package/internal/utils/index.d.ts +1 -0
- package/internal/utils/setRef.d.ts +2 -0
- package/package.json +8 -8
- package/src/Alert/Alert.type.d.ts +2 -1
- package/src/Animation/components/Fade/Fade.d.ts +4 -2
- package/src/Animation/components/Grow/Grow.d.ts +4 -2
- package/src/Animation/components/ShowHideEye/ShowHideEye.d.ts +1 -1
- package/src/Animation/components/SlideIn/SlideIn.d.ts +4 -2
- package/src/Animation/components/SlideIn/getSlideIn.d.ts +1 -1
- package/src/Animation/hooks/useMotionSafeTransition/useMotionSafeTransition.d.ts +2 -0
- package/src/Autocomplete/SuggestionList/SuggestionList.d.ts +1 -1
- package/src/Autocomplete/useAutocomplete.d.ts +18 -18
- package/src/Autocomplete/useAutocompleteTag.d.ts +18 -18
- package/src/Badge/Badge.d.ts +2 -1
- package/src/Button/Button.classes.d.ts +1 -1
- package/src/ComponentsProps.d.ts +111 -110
- package/src/DatePicker/DatePickerDataAttributes.d.ts +11 -0
- package/src/DatePicker/utils/DatePickerAriaLabelUtils.d.ts +2 -1
- package/src/DatePicker/utils/DatePickerUtils.d.ts +1 -1
- package/src/Dialer/DialDelete/DialDelete.d.ts +2 -2
- package/src/Dialer/DialPad/DialPad.d.ts +2 -2
- package/src/Dialer/Dialer.d.ts +4 -2
- package/src/Dropdown/Dropdown.type.d.ts +2 -2
- package/src/InlineEditable/InlineEditable.type.d.ts +2 -1
- package/src/ListNavigation/useListNavigation.d.ts +3 -3
- package/src/MenuActions/MenuActions.d.ts +2 -2
- package/src/MenuItem/MenuItem.type.d.ts +1 -0
- package/src/MenuItem/useMenuItem.d.ts +1 -1
- package/src/MenuItem/useVirtualizedMenuItem.d.ts +1 -1
- package/src/MenuList/MenuList.type.d.ts +1 -1
- package/src/MenuList/MenuListContext.d.ts +2 -3
- package/src/Modal/Modal.type.d.ts +1 -0
- package/src/NestedMenuContext/MenuOverlayGroupContext.d.ts +2 -2
- package/src/Popover/Popover.classes.d.ts +1 -1
- package/src/Popover/Popover.internal.d.ts +8 -0
- package/src/Popover/Popover.type.d.ts +1 -0
- package/src/Popper/Popper.type.d.ts +10 -7
- package/src/Rating/utils.d.ts +3 -2
- package/src/Select/Select.type.d.ts +7 -5
- package/src/Slider/Slider.d.ts +2 -2
- package/src/Slider/SliderThumb.d.ts +2 -1
- package/src/Squircle/Squircle.d.ts +1 -1
- package/src/StatusIndicator/StatusIndicator.d.ts +2 -1
- package/src/SubMenu/PopperMenu.type.d.ts +4 -1
- package/src/Table/Table.type.d.ts +3 -0
- package/src/Table/TableContext.d.ts +3 -0
- package/src/Table/TableRowContext.d.ts +7 -0
- package/src/Table/index.d.ts +1 -0
- package/src/TableCell/TableCell.classes.d.ts +1 -1
- package/src/TableFooter/TableFooter.classes.d.ts +1 -1
- package/src/TableFooter/TableFooter.type.d.ts +1 -0
- package/src/TableHead/TableHead.classes.d.ts +1 -1
- package/src/TableHead/TableHead.type.d.ts +1 -0
- package/src/TableRow/TableRow.type.d.ts +2 -0
- package/chunks/AccordionContext.js +0 -6
- package/chunks/Alert.js +0 -48
- package/chunks/AvatarGroup.js +0 -22
- package/chunks/Backdrop.js +0 -18
- package/chunks/Badge.js +0 -32
- package/chunks/BottomNavigationItem.js +0 -36
- package/chunks/Button.js +0 -88
- package/chunks/Chip.js +0 -73
- package/chunks/CircularProgressIndicator.js +0 -36
- package/chunks/Divider.js +0 -19
- package/chunks/DragHandle.js +0 -11
- package/chunks/Drawer.js +0 -32
- package/chunks/ExpandCollapseCaret.js +0 -24
- package/chunks/FormLabel.js +0 -27
- package/chunks/Icon.js +0 -25
- package/chunks/IconButtonLabel.js +0 -68
- package/chunks/List.js +0 -22
- package/chunks/ListItem.js +0 -83
- package/chunks/Menu.js +0 -61
- package/chunks/MenuDivider.js +0 -14
- package/chunks/MenuItemText.js +0 -17
- package/chunks/MenuList.js +0 -46
- package/chunks/Modal.js +0 -212
- package/chunks/Overlap.js +0 -25
- package/chunks/PickerTextField.js +0 -85
- package/chunks/Popover.js +0 -53
- package/chunks/PopperPaper.js +0 -15
- package/chunks/Select.js +0 -220
- package/chunks/ShowHideEye.js +0 -56
- package/chunks/SlideIn.js +0 -19
- package/chunks/SortableArrow.js +0 -73
- package/chunks/Squircle.js +0 -31
- package/chunks/StatusIndicator.js +0 -20
- package/chunks/StepConnector.js +0 -21
- package/chunks/StepIcon.js +0 -43
- package/chunks/StepLabel.js +0 -29
- package/chunks/StepperContext.js +0 -9
- package/chunks/TableContext.js +0 -6
- package/chunks/Tablelvl2Context.js +0 -6
- package/chunks/TabsContext.js +0 -6
- package/chunks/TextField.js +0 -110
- package/chunks/Tooltip.js +0 -217
- package/chunks/VirtualizedMenu.js +0 -164
- package/chunks/VisuallyHidden.js +0 -12
- package/chunks/getFade.js +0 -27
- package/chunks/getGrow.js +0 -70
- package/chunks/getSlideIn.js +0 -30
- package/chunks/hasContent.js +0 -3
- package/chunks/useAnimationFrame.js +0 -15
- package/chunks/useFocusTrapStack.js +0 -36
- package/chunks/useHelperTextId.js +0 -22
- package/chunks/useListNavigation.js +0 -199
- package/chunks/useMenuItemSelect.js +0 -273
- package/chunks/useMotionSafeTransition.js +0 -9
- package/chunks/useNestedMenuItem.js +0 -27
- package/chunks/useNestedParentMenu.js +0 -113
- package/chunks/usePrefersReducedMotion.js +0 -36
- package/chunks/useTooltipForceHide.js +0 -27
- package/chunks/useTrayNavigate.js +0 -150
- package/chunks/withTooltip.js +0 -15
package/Radio.js
CHANGED
|
@@ -1,37 +1,81 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { forwardRef } from
|
|
3
|
-
import { useSwitch } from
|
|
4
|
-
import { useClasses } from
|
|
5
|
-
import { useThemeProps } from
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
29
|
-
|
|
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
|
-
}),
|
|
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
|
-
|
|
74
|
+
Radio_Radio.displayName = 'SuiRadio';
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
36
80
|
|
|
37
|
-
export { Radio,
|
|
81
|
+
export { Radio as radioStyle, Radio_Radio as Radio };
|
package/RadioGroup.js
CHANGED
|
@@ -1,29 +1,68 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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
|
-
|
|
11
|
-
|
|
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 {
|
|
23
|
-
|
|
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
|
|
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
|
-
|
|
59
|
+
RadioGroup_RadioGroup.displayName = 'SuiRadioGroup';
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
28
66
|
|
|
29
|
-
export { RadioGroup
|
|
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
|
|
2
|
-
import {
|
|
3
|
-
import clamp from
|
|
4
|
-
import {
|
|
5
|
-
import { useThemeProps } from
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
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(
|
|
22
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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 =
|
|
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
|
-
}),
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
65
|
+
'icon-active': isActive
|
|
66
|
+
}),
|
|
67
|
+
children: size ? /*#__PURE__*/ cloneElement(renderedIcon, {
|
|
68
|
+
size
|
|
69
|
+
}) : renderedIcon
|
|
70
|
+
});
|
|
47
71
|
if (readOnly) {
|
|
48
|
-
return
|
|
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
|
|
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
|
-
}),
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
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
|
-
|
|
64
|
-
|
|
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
|
|
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
|
|
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)
|
|
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
|
-
|
|
156
|
-
|
|
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
|
-
|
|
170
|
-
|
|
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(()
|
|
176
|
-
|
|
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
|
-
}),
|
|
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
|
|
305
|
+
return /*#__PURE__*/ jsx("div", {
|
|
306
|
+
className: cls('decimal', {
|
|
207
307
|
'icon-active': isActive,
|
|
208
|
-
focusVisible
|
|
209
|
-
}),
|
|
308
|
+
focusVisible
|
|
309
|
+
}),
|
|
310
|
+
children: items.map(($, indexDecimal)=>{
|
|
210
311
|
const itemDecimalValue = roundValueToPrecision(itemValue - 1 + (indexDecimal + 1) * precision, precision);
|
|
211
|
-
return
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
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
|
-
|
|
357
|
+
Rating_Rating.displayName = 'SuiRating';
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
|
|
229
365
|
|
|
230
|
-
export { Rating, RatingItem, defaultEmptyIcon, defaultIcon, defaultLabelText,
|
|
366
|
+
export { Rating as ratingStyle, RatingItem, Rating_Rating as Rating, defaultEmptyIcon, defaultIcon, defaultLabelText, roundValueToPrecision };
|