rsuite 5.55.0 → 5.56.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 (78) hide show
  1. package/AutoComplete/styles/index.css +3 -3
  2. package/CHANGELOG.md +29 -0
  3. package/Calendar/styles/index.css +3 -0
  4. package/Calendar/styles/index.less +3 -1
  5. package/Cascader/styles/index.css +3 -3
  6. package/CheckPicker/styles/index.css +142 -40
  7. package/CheckPicker/styles/index.less +1 -1
  8. package/CheckTree/styles/index.css +143 -41
  9. package/CheckTreePicker/styles/index.css +143 -41
  10. package/CheckTreePicker/styles/index.less +2 -2
  11. package/Checkbox/styles/index.css +159 -36
  12. package/Checkbox/styles/index.less +32 -13
  13. package/DatePicker/styles/index.css +10 -5
  14. package/DatePicker/styles/index.less +5 -2
  15. package/DateRangePicker/styles/index.css +22 -14
  16. package/DateRangePicker/styles/index.less +5 -1
  17. package/InputPicker/styles/index.css +3 -3
  18. package/Message/styles/index.css +1 -1
  19. package/MultiCascader/styles/index.css +141 -39
  20. package/Nav/styles/index.css +1 -2
  21. package/Nav/styles/index.less +1 -2
  22. package/Pagination/styles/index.css +3 -3
  23. package/Radio/styles/index.css +133 -19
  24. package/Radio/styles/index.less +28 -12
  25. package/RadioGroup/styles/index.css +1 -1
  26. package/RadioGroup/styles/index.less +1 -1
  27. package/SelectPicker/styles/index.css +3 -3
  28. package/Tabs/styles/index.css +1 -2
  29. package/TagGroup/styles/index.css +1 -1
  30. package/TagGroup/styles/index.less +1 -1
  31. package/TagInput/styles/index.css +141 -39
  32. package/TagPicker/styles/index.css +141 -39
  33. package/cjs/Checkbox/Checkbox.d.ts +67 -25
  34. package/cjs/Checkbox/Checkbox.js +36 -26
  35. package/cjs/DatePicker/DatePicker.js +1 -1
  36. package/cjs/DateRangePicker/DateRangePicker.js +1 -1
  37. package/cjs/InputPicker/InputPicker.js +2 -2
  38. package/cjs/InputPicker/InputPickerContext.d.ts +1 -1
  39. package/cjs/MultiCascader/TreeView.js +2 -1
  40. package/cjs/Radio/Radio.d.ts +42 -16
  41. package/cjs/Radio/Radio.js +42 -37
  42. package/cjs/RadioGroup/RadioGroup.d.ts +1 -1
  43. package/cjs/RadioGroup/RadioGroup.js +3 -3
  44. package/cjs/TagPicker/index.js +1 -1
  45. package/cjs/internals/Picker/ListCheckItem.d.ts +2 -11
  46. package/cjs/internals/Picker/ListCheckItem.js +8 -6
  47. package/dist/rsuite-no-reset-rtl.css +279 -77
  48. package/dist/rsuite-no-reset-rtl.min.css +1 -1
  49. package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
  50. package/dist/rsuite-no-reset.css +279 -77
  51. package/dist/rsuite-no-reset.min.css +1 -1
  52. package/dist/rsuite-no-reset.min.css.map +1 -1
  53. package/dist/rsuite-rtl.css +279 -77
  54. package/dist/rsuite-rtl.min.css +1 -1
  55. package/dist/rsuite-rtl.min.css.map +1 -1
  56. package/dist/rsuite.css +279 -77
  57. package/dist/rsuite.js +9 -9
  58. package/dist/rsuite.min.css +1 -1
  59. package/dist/rsuite.min.css.map +1 -1
  60. package/dist/rsuite.min.js +1 -1
  61. package/dist/rsuite.min.js.map +1 -1
  62. package/esm/Checkbox/Checkbox.d.ts +67 -25
  63. package/esm/Checkbox/Checkbox.js +38 -28
  64. package/esm/DatePicker/DatePicker.js +1 -1
  65. package/esm/DateRangePicker/DateRangePicker.js +1 -1
  66. package/esm/InputPicker/InputPicker.js +2 -2
  67. package/esm/InputPicker/InputPickerContext.d.ts +1 -1
  68. package/esm/MultiCascader/TreeView.js +2 -1
  69. package/esm/Radio/Radio.d.ts +42 -16
  70. package/esm/Radio/Radio.js +43 -38
  71. package/esm/RadioGroup/RadioGroup.d.ts +1 -1
  72. package/esm/RadioGroup/RadioGroup.js +5 -5
  73. package/esm/TagPicker/index.js +1 -1
  74. package/esm/internals/Picker/ListCheckItem.d.ts +2 -11
  75. package/esm/internals/Picker/ListCheckItem.js +8 -6
  76. package/internals/Picker/styles/index.less +1 -1
  77. package/package.json +1 -1
  78. package/styles/variables.less +1 -1
@@ -1,43 +1,85 @@
1
1
  import React from 'react';
2
- import { WithAsProps, RsRefForwardingComponent } from '../@types/common';
2
+ import { WithAsProps, RsRefForwardingComponent, TypeAttributes } from '../@types/common';
3
3
  export declare type ValueType = string | number;
4
- export interface CheckboxProps<V = ValueType> extends WithAsProps {
5
- /** HTML title */
6
- title?: string;
7
- /** Inline layout */
8
- inline?: boolean;
9
- /** A checkbox can appear disabled and be unable to change states */
4
+ export interface CheckboxProps<V = ValueType> extends WithAsProps, Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
5
+ /**
6
+ * The color of the checkbox when checked or indeterminate
7
+ *
8
+ * @version 5.56.0
9
+ */
10
+ color?: TypeAttributes.Color;
11
+ /**
12
+ * Whether to show checkbox
13
+ *
14
+ * @private Used in MultiCascader
15
+ */
16
+ checkable?: boolean;
17
+ /**
18
+ * A checkbox can appear disabled and be unable to change states
19
+ */
10
20
  disabled?: boolean;
11
- /** Make the control readonly */
21
+ /**
22
+ * Make the control readonly
23
+ */
12
24
  readOnly?: boolean;
13
- /** Render the control as plain text */
25
+ /**
26
+ * Render the control as plain text
27
+ */
14
28
  plaintext?: boolean;
15
- /** Whether or not checkbox is checked. */
29
+ /**
30
+ * Whether or not checkbox is checked.
31
+ */
16
32
  checked?: boolean;
17
- /** The initial value of checked. */
33
+ /**
34
+ * The initial value of checked.
35
+ */
18
36
  defaultChecked?: boolean;
19
- /** Whether or not checkbox is indeterminate. */
37
+ /**
38
+ * Whether or not checkbox is indeterminate.
39
+ */
20
40
  indeterminate?: boolean;
21
- /** Attributes applied to the input element. */
41
+ /**
42
+ * Attributes applied to the input element.
43
+ */
22
44
  inputProps?: React.HTMLAttributes<HTMLInputElement>;
23
- /** Pass a ref to the input element. */
45
+ /**
46
+ * Pass a ref to the input element.
47
+ */
24
48
  inputRef?: React.Ref<any>;
25
- /** The HTML input value. */
49
+ /**
50
+ * Inline layout
51
+ *
52
+ * @private Used in CheckboxGroup
53
+ */
54
+ inline?: boolean;
55
+ /**
56
+ * The HTML input value.
57
+ */
26
58
  value?: V;
27
- /** A checkbox can receive focus. */
28
- tabIndex?: number;
29
- /** Whether to show checkbox */
30
- checkable?: boolean;
31
- /** Used for the name of the form */
59
+ /**
60
+ * Used for the name of the form
61
+ */
32
62
  name?: string;
33
- /** Called when the user attempts to change the checked state. */
63
+ /**
64
+ * Whether the label is clickable
65
+ *
66
+ * @private Used in MultiCascader
67
+ */
68
+ labelClickable?: boolean;
69
+ /**
70
+ * Called when the user attempts to change the checked state.
71
+ */
34
72
  onChange?: (value: V | undefined, checked: boolean, event: React.ChangeEvent<HTMLInputElement>) => void;
35
- /** Called when the checkbox or label is clicked. */
73
+ /**
74
+ * Called when the checkbox or label is clicked.
75
+ */
36
76
  onClick?: (event: React.SyntheticEvent) => void;
37
- /** Called when the checkbox is clicked. */
77
+ /**
78
+ * Called when the checkbox is clicked.
79
+ *
80
+ * @private Used in MultiCascader
81
+ */
38
82
  onCheckboxClick?: (event: React.SyntheticEvent) => void;
39
- /** Called when the user presses down a key. */
40
- onKeyDown?: (event: React.KeyboardEvent) => void;
41
83
  }
42
84
  /**
43
85
  * The Checkbox component is used for selecting multiple options from a set.
@@ -2,10 +2,10 @@
2
2
  import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/esm/taggedTemplateLiteralLoose";
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
5
- var _templateObject, _templateObject2, _templateObject3;
6
- import React, { useContext, useCallback, useMemo } from 'react';
5
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
6
+ import React, { useContext, useMemo, useRef } from 'react';
7
7
  import PropTypes from 'prop-types';
8
- import { useControlled, partitionHTMLProps, useClassNames } from '../utils';
8
+ import { useControlled, partitionHTMLProps, useClassNames, useEventCallback, useUniqueId, mergeRefs } from '../utils';
9
9
  import { CheckboxGroupContext } from '../CheckboxGroup';
10
10
  import { refType } from '../internals/propTypes';
11
11
  /**
@@ -30,12 +30,15 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (props, ref) {
30
30
  classPrefix = _props$classPrefix === void 0 ? 'checkbox' : _props$classPrefix,
31
31
  _props$checkable = props.checkable,
32
32
  checkable = _props$checkable === void 0 ? true : _props$checkable,
33
+ color = props.color,
33
34
  _props$defaultChecked = props.defaultChecked,
34
35
  defaultChecked = _props$defaultChecked === void 0 ? false : _props$defaultChecked,
35
36
  title = props.title,
36
37
  inputRef = props.inputRef,
37
38
  inputProps = props.inputProps,
38
39
  indeterminate = props.indeterminate,
40
+ _props$labelClickable = props.labelClickable,
41
+ labelClickable = _props$labelClickable === void 0 ? true : _props$labelClickable,
39
42
  _props$tabIndex = props.tabIndex,
40
43
  tabIndex = _props$tabIndex === void 0 ? 0 : _props$tabIndex,
41
44
  _props$disabled = props.disabled,
@@ -52,7 +55,7 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (props, ref) {
52
55
  onClick = props.onClick,
53
56
  onCheckboxClick = props.onCheckboxClick,
54
57
  onChange = props.onChange,
55
- rest = _objectWithoutPropertiesLoose(props, ["as", "checked", "className", "children", "classPrefix", "checkable", "defaultChecked", "title", "inputRef", "inputProps", "indeterminate", "tabIndex", "disabled", "readOnly", "plaintext", "inline", "name", "value", "onClick", "onCheckboxClick", "onChange"]);
58
+ rest = _objectWithoutPropertiesLoose(props, ["as", "checked", "className", "children", "classPrefix", "checkable", "color", "defaultChecked", "title", "inputRef", "inputProps", "indeterminate", "labelClickable", "tabIndex", "disabled", "readOnly", "plaintext", "inline", "name", "value", "onClick", "onCheckboxClick", "onChange"]);
56
59
  var _useControlled = useControlled(controlledChecked, defaultChecked),
57
60
  selfChecked = _useControlled[0],
58
61
  setSelfChecked = _useControlled[1],
@@ -72,7 +75,7 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (props, ref) {
72
75
  merge = _useClassNames.merge,
73
76
  prefix = _useClassNames.prefix,
74
77
  withClassPrefix = _useClassNames.withClassPrefix;
75
- var classes = merge(className, withClassPrefix({
78
+ var classes = merge(className, withClassPrefix(color, {
76
79
  inline: inline,
77
80
  indeterminate: indeterminate,
78
81
  disabled: disabled,
@@ -87,7 +90,8 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (props, ref) {
87
90
  // In uncontrolled situations, use defaultChecked instead of checked
88
91
  htmlInputProps[controlled ? 'checked' : 'defaultChecked'] = checked;
89
92
  }
90
- var handleChange = useCallback(function (event) {
93
+ var checkboxRef = useRef(null);
94
+ var handleChange = useEventCallback(function (event) {
91
95
  var nextChecked = event.target.checked;
92
96
  if (disabled || readOnly) {
93
97
  return;
@@ -95,30 +99,34 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (props, ref) {
95
99
  setSelfChecked(nextChecked);
96
100
  onChange === null || onChange === void 0 ? void 0 : onChange(value, nextChecked, event);
97
101
  onGroupChange === null || onGroupChange === void 0 ? void 0 : onGroupChange(value, nextChecked, event);
98
- }, [disabled, readOnly, setSelfChecked, onChange, value, onGroupChange]);
102
+ });
103
+ var handleLabelClick = useEventCallback(function (event) {
104
+ // Prevent check when label is not clickable
105
+ if (!labelClickable && event.target !== checkboxRef.current) {
106
+ event.preventDefault();
107
+ }
108
+ });
109
+ var labelId = useUniqueId('label-');
99
110
  if (plaintext) {
100
111
  return checked ? /*#__PURE__*/React.createElement(Component, _extends({}, restProps, {
101
112
  ref: ref,
102
113
  className: classes
103
114
  }), children) : null;
104
115
  }
105
- var input = /*#__PURE__*/React.createElement("span", {
106
- className: prefix(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["wrapper"]))),
107
- onClick: onCheckboxClick,
108
- "aria-disabled": disabled
116
+ var control = /*#__PURE__*/React.createElement("span", {
117
+ className: prefix(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["control"])))
109
118
  }, /*#__PURE__*/React.createElement("input", _extends({}, htmlInputProps, inputProps, {
119
+ "aria-disabled": disabled,
120
+ "aria-checked": indeterminate ? 'mixed' : checked,
121
+ "aria-labelledby": labelId,
110
122
  name: name,
111
123
  value: value,
112
124
  type: "checkbox",
113
- ref: inputRef,
125
+ ref: mergeRefs(checkboxRef, inputRef),
114
126
  tabIndex: tabIndex,
115
127
  readOnly: readOnly,
116
128
  disabled: disabled,
117
- "aria-disabled": disabled,
118
- "aria-checked": indeterminate ? 'mixed' : checked,
119
- onClick: function onClick(event) {
120
- return event.stopPropagation();
121
- },
129
+ onClick: onCheckboxClick,
122
130
  onChange: handleChange
123
131
  })), /*#__PURE__*/React.createElement("span", {
124
132
  className: prefix(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["inner"]))),
@@ -132,28 +140,30 @@ var Checkbox = /*#__PURE__*/React.forwardRef(function (props, ref) {
132
140
  }), /*#__PURE__*/React.createElement("div", {
133
141
  className: prefix(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["checker"])))
134
142
  }, /*#__PURE__*/React.createElement("label", {
135
- title: title
136
- }, checkable ? input : null, children)));
143
+ title: title,
144
+ onClick: handleLabelClick
145
+ }, checkable ? control : null, /*#__PURE__*/React.createElement("span", {
146
+ className: prefix(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["label"]))),
147
+ id: labelId
148
+ }, children))));
137
149
  });
138
150
  Checkbox.displayName = 'Checkbox';
139
151
  Checkbox.propTypes = {
140
152
  as: PropTypes.elementType,
141
- title: PropTypes.string,
153
+ checked: PropTypes.bool,
154
+ checkable: PropTypes.bool,
142
155
  className: PropTypes.string,
143
- inline: PropTypes.bool,
156
+ children: PropTypes.node,
157
+ classPrefix: PropTypes.string,
144
158
  disabled: PropTypes.bool,
145
- checked: PropTypes.bool,
146
159
  defaultChecked: PropTypes.bool,
160
+ inline: PropTypes.bool,
147
161
  indeterminate: PropTypes.bool,
148
- onChange: PropTypes.func,
149
- onClick: PropTypes.func,
150
162
  inputProps: PropTypes.any,
151
163
  inputRef: refType,
152
164
  value: PropTypes.any,
153
- children: PropTypes.node,
154
- classPrefix: PropTypes.string,
155
- tabIndex: PropTypes.number,
156
- checkable: PropTypes.bool,
165
+ onChange: PropTypes.func,
166
+ onClick: PropTypes.func,
157
167
  onCheckboxClick: PropTypes.func
158
168
  };
159
169
  export default Checkbox;
@@ -413,7 +413,7 @@ var DatePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
413
413
  var left = positionProps.left,
414
414
  top = positionProps.top,
415
415
  className = positionProps.className;
416
- var classes = merge(menuClassName, className);
416
+ var classes = merge(menuClassName, className, prefix('popup-date'));
417
417
  var styles = _extends({}, menuStyle, {
418
418
  left: left,
419
419
  top: top
@@ -553,7 +553,7 @@ var DateRangePicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
553
553
  var left = positionProps.left,
554
554
  top = positionProps.top,
555
555
  className = positionProps.className;
556
- var classes = merge(className, menuClassName, prefix('daterange-menu'));
556
+ var classes = merge(className, menuClassName, prefix('popup-daterange'));
557
557
  var panelClasses = prefix('daterange-panel', {
558
558
  'daterange-panel-show-one-calendar': showOneCalendar
559
559
  });
@@ -118,7 +118,7 @@ var InputPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
118
118
  trigger = _useContext.trigger,
119
119
  disabledOptions = _useContext.disabledOptions,
120
120
  onTagRemove = _useContext.onTagRemove,
121
- renderMenuItemCheckbox = _useContext.renderMenuItemCheckbox;
121
+ renderCheckbox = _useContext.renderCheckbox;
122
122
  if (groupBy === valueKey || groupBy === labelKey) {
123
123
  throw Error('`groupBy` can not be equal to `valueKey` and `labelKey`');
124
124
  }
@@ -573,7 +573,7 @@ var InputPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
573
573
  listItemClassPrefix: multi ? undefined : menuClassPrefix + "-item",
574
574
  listItemAs: multi ? ListCheckItem : ListItem,
575
575
  listItemProps: {
576
- renderMenuItemCheckbox: renderMenuItemCheckbox
576
+ renderCheckbox: renderCheckbox
577
577
  },
578
578
  activeItemValues: multi ? value : [value],
579
579
  focusItemValue: focusItemValue,
@@ -20,7 +20,7 @@ export interface InputPickerContextProps extends TagOnlyProps {
20
20
  */
21
21
  disabledOptions?: boolean;
22
22
  /** Custom render checkbox on menu item */
23
- renderMenuItemCheckbox?: (checkboxProps: CheckboxProps) => React.ReactNode;
23
+ renderCheckbox?: (checkboxProps: CheckboxProps) => React.ReactNode;
24
24
  }
25
25
  declare const InputPickerContext: React.Context<InputPickerContextProps>;
26
26
  export default InputPickerContext;
@@ -120,7 +120,8 @@ var TreeView = /*#__PURE__*/React.forwardRef(function (props, ref) {
120
120
  onCheck: function onCheck(_value, event, checked) {
121
121
  return _onCheck === null || _onCheck === void 0 ? void 0 : _onCheck(node, event, checked);
122
122
  },
123
- checkable: !uncheckable
123
+ checkable: !uncheckable,
124
+ labelClickable: false
124
125
  }, renderMenuItem ? renderMenuItem(label, node) : label, children ? /*#__PURE__*/React.createElement(Icon, {
125
126
  className: prefix('caret'),
126
127
  spin: node.loading
@@ -1,32 +1,58 @@
1
1
  import React from 'react';
2
- import { WithAsProps } from '../@types/common';
2
+ import { WithAsProps, TypeAttributes } from '../@types/common';
3
3
  export declare type ValueType = string | number;
4
4
  export interface RadioProps<T = ValueType> extends WithAsProps, Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
5
- /** HTML title */
6
- title?: string;
7
- /** The disable of component */
5
+ /**
6
+ * The color of the radio when checked
7
+ *
8
+ * @version 5.56.0
9
+ */
10
+ color?: TypeAttributes.Color;
11
+ /**
12
+ * The disable of component
13
+ */
8
14
  disabled?: boolean;
9
- /** Make the control readonly */
15
+ /**
16
+ * Make the control readonly
17
+ */
10
18
  readOnly?: boolean;
11
- /** Render the control as plain text */
19
+ /**
20
+ * Render the control as plain text
21
+ */
12
22
  plaintext?: boolean;
13
- /** Specifies whether the radio is selected */
23
+ /**
24
+ * Specifies whether the radio is selected
25
+ */
14
26
  checked?: boolean;
15
- /** Specifies the initial state: whether or not the radio is selected */
27
+ /**
28
+ * Specifies the initial state: whether or not the radio is selected
29
+ */
16
30
  defaultChecked?: boolean;
17
- /** Attributes applied to the input element. */
31
+ /**
32
+ * Attributes applied to the input element
33
+ */
18
34
  inputProps?: React.HTMLAttributes<HTMLInputElement>;
19
- /** Pass a ref to the input element */
35
+ /**
36
+ * Pass a ref to the input element
37
+ */
20
38
  inputRef?: React.Ref<HTMLInputElement>;
21
- /** Value, corresponding to the value of the Radiogroup, to determine whether the */
39
+ /**
40
+ * Value, corresponding to the value of the Radiogroup, to determine whether the
41
+ */
22
42
  value?: T;
23
- /** Name to use for form */
43
+ /**
44
+ * Name to use for form
45
+ */
24
46
  name?: string;
25
- /** Inline layout */
47
+ /**
48
+ * Inline layout.
49
+ *
50
+ * @private Used in RadioGroup
51
+ */
26
52
  inline?: boolean;
27
- /** Primary content */
28
- children?: React.ReactNode;
29
- /** Callback function with value changed */
53
+ /**
54
+ * Callback function with value changed
55
+ */
30
56
  onChange?: (value: T | undefined, checked: boolean, event: React.ChangeEvent<HTMLInputElement>) => void;
31
57
  }
32
58
  /**
@@ -1,31 +1,34 @@
1
1
  'use client';
2
+ import _taggedTemplateLiteralLoose from "@babel/runtime/helpers/esm/taggedTemplateLiteralLoose";
2
3
  import _extends from "@babel/runtime/helpers/esm/extends";
3
4
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
- import React, { useCallback, useContext } from 'react';
5
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
6
+ import React, { useContext } from 'react';
5
7
  import PropTypes from 'prop-types';
6
8
  import { RadioContext } from '../RadioGroup/RadioGroup';
7
- import { useClassNames, useControlled, partitionHTMLProps } from '../utils';
9
+ import { useClassNames, useControlled, useEventCallback, useUniqueId, partitionHTMLProps } from '../utils';
8
10
  import { refType } from '../internals/propTypes';
9
11
  /**
10
12
  * The `Radio` component is a simple radio button.
11
13
  * @see https://rsuitejs.com/components/radio
12
14
  */
13
15
  var Radio = /*#__PURE__*/React.forwardRef(function (props, ref) {
14
- var _useContext = useContext(RadioContext),
15
- groupValue = _useContext.value,
16
- controlled = _useContext.controlled,
17
- inlineContext = _useContext.inline,
18
- nameContext = _useContext.name,
19
- disabledContext = _useContext.disabled,
20
- readOnlyContext = _useContext.readOnly,
21
- plaintextContext = _useContext.plaintext,
22
- onGroupChange = _useContext.onChange;
16
+ var radioContext = useContext(RadioContext);
17
+ var _ref = radioContext !== null && radioContext !== void 0 ? radioContext : {},
18
+ groupValue = _ref.value,
19
+ inlineContext = _ref.inline,
20
+ nameContext = _ref.name,
21
+ disabledContext = _ref.disabled,
22
+ readOnlyContext = _ref.readOnly,
23
+ plaintextContext = _ref.plaintext,
24
+ onGroupChange = _ref.onChange;
23
25
  var _props$as = props.as,
24
26
  Component = _props$as === void 0 ? 'div' : _props$as,
25
27
  title = props.title,
26
28
  className = props.className,
27
29
  children = props.children,
28
30
  checkedProp = props.checked,
31
+ color = props.color,
29
32
  defaultChecked = props.defaultChecked,
30
33
  _props$classPrefix = props.classPrefix,
31
34
  classPrefix = _props$classPrefix === void 0 ? 'radio' : _props$classPrefix,
@@ -46,15 +49,16 @@ var Radio = /*#__PURE__*/React.forwardRef(function (props, ref) {
46
49
  value = props.value,
47
50
  onChange = props.onChange,
48
51
  onClick = props.onClick,
49
- rest = _objectWithoutPropertiesLoose(props, ["as", "title", "className", "children", "checked", "defaultChecked", "classPrefix", "tabIndex", "inputRef", "inputProps", "disabled", "readOnly", "plaintext", "inline", "name", "value", "onChange", "onClick"]);
52
+ rest = _objectWithoutPropertiesLoose(props, ["as", "title", "className", "children", "checked", "color", "defaultChecked", "classPrefix", "tabIndex", "inputRef", "inputProps", "disabled", "readOnly", "plaintext", "inline", "name", "value", "onChange", "onClick"]);
50
53
  var _useControlled = useControlled(typeof groupValue !== 'undefined' ? groupValue === value : checkedProp, defaultChecked || false),
51
54
  checked = _useControlled[0],
52
- setChecked = _useControlled[1];
55
+ setChecked = _useControlled[1],
56
+ selfControlled = _useControlled[2];
53
57
  var _useClassNames = useClassNames(classPrefix),
54
58
  merge = _useClassNames.merge,
55
59
  withClassPrefix = _useClassNames.withClassPrefix,
56
60
  prefix = _useClassNames.prefix;
57
- var classes = merge(className, withClassPrefix({
61
+ var classes = merge(className, withClassPrefix(color, {
58
62
  inline: inline,
59
63
  disabled: disabled,
60
64
  checked: checked
@@ -62,59 +66,62 @@ var Radio = /*#__PURE__*/React.forwardRef(function (props, ref) {
62
66
  var _partitionHTMLProps = partitionHTMLProps(rest),
63
67
  htmlInputProps = _partitionHTMLProps[0],
64
68
  restProps = _partitionHTMLProps[1];
65
- var handleChange = useCallback(function (event) {
69
+ var handleChange = useEventCallback(function (event) {
66
70
  if (disabled || readOnly) {
67
71
  return;
68
72
  }
69
73
  setChecked(true);
70
74
  onGroupChange === null || onGroupChange === void 0 ? void 0 : onGroupChange(value, event);
71
75
  onChange === null || onChange === void 0 ? void 0 : onChange(value, true, event);
72
- }, [disabled, onChange, onGroupChange, readOnly, setChecked, value]);
76
+ });
77
+ var controlled = radioContext ? true : selfControlled;
73
78
  if (typeof controlled !== 'undefined') {
74
79
  // In uncontrolled situations, use defaultChecked instead of checked
75
80
  htmlInputProps[controlled ? 'checked' : 'defaultChecked'] = checked;
76
81
  }
77
- var input = /*#__PURE__*/React.createElement("span", {
78
- className: prefix('wrapper')
82
+ var labelId = useUniqueId('label-');
83
+ if (plaintext) {
84
+ return checked ? /*#__PURE__*/React.createElement(Component, _extends({}, restProps, {
85
+ ref: ref,
86
+ className: classes
87
+ }), children) : null;
88
+ }
89
+ var control = /*#__PURE__*/React.createElement("span", {
90
+ className: prefix(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["control"])))
79
91
  }, /*#__PURE__*/React.createElement("input", _extends({}, htmlInputProps, inputProps, {
92
+ "aria-labelledby": labelId,
93
+ "aria-checked": checked,
94
+ "aria-disabled": disabled,
80
95
  ref: inputRef,
81
96
  type: "radio",
82
97
  name: name,
83
98
  value: value,
84
99
  tabIndex: tabIndex,
100
+ readOnly: readOnly,
85
101
  disabled: disabled,
86
- onChange: handleChange,
87
- onClick: useCallback(function (event) {
88
- return event.stopPropagation();
89
- }, [])
102
+ onChange: handleChange
90
103
  })), /*#__PURE__*/React.createElement("span", {
91
- className: prefix('inner'),
104
+ className: prefix(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["inner"]))),
92
105
  "aria-hidden": true
93
106
  }));
94
- if (plaintext) {
95
- return checked ? /*#__PURE__*/React.createElement(Component, _extends({}, restProps, {
96
- ref: ref,
97
- className: classes
98
- }), children) : null;
99
- }
100
107
  return /*#__PURE__*/React.createElement(Component, _extends({}, restProps, {
101
108
  ref: ref,
102
109
  onClick: onClick,
103
- className: classes,
104
- "aria-checked": checked,
105
- "aria-disabled": disabled
110
+ className: classes
106
111
  }), /*#__PURE__*/React.createElement("div", {
107
- className: prefix('checker')
112
+ className: prefix(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["checker"])))
108
113
  }, children ? /*#__PURE__*/React.createElement("label", {
109
114
  title: title
110
- }, input, children) : input));
115
+ }, control, /*#__PURE__*/React.createElement("span", {
116
+ className: prefix(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["label"]))),
117
+ id: labelId
118
+ }, children)) : control));
111
119
  });
112
120
  Radio.displayName = 'Radio';
113
121
  Radio.propTypes = {
114
122
  id: PropTypes.string,
115
123
  name: PropTypes.string,
116
124
  inline: PropTypes.bool,
117
- title: PropTypes.string,
118
125
  disabled: PropTypes.bool,
119
126
  checked: PropTypes.bool,
120
127
  defaultChecked: PropTypes.bool,
@@ -124,8 +131,6 @@ Radio.propTypes = {
124
131
  classPrefix: PropTypes.string,
125
132
  value: PropTypes.any,
126
133
  inputRef: refType,
127
- onChange: PropTypes.func,
128
- onClick: PropTypes.func,
129
- tabIndex: PropTypes.number
134
+ onChange: PropTypes.func
130
135
  };
131
136
  export default Radio;
@@ -21,7 +21,7 @@ export interface RadioGroupProps<T = ValueType> extends WithAsProps, FormControl
21
21
  /** Primary content */
22
22
  children?: React.ReactNode;
23
23
  }
24
- export declare const RadioContext: React.Context<RadioContextProps>;
24
+ export declare const RadioContext: React.Context<RadioContextProps | undefined>;
25
25
  /**
26
26
  * The `RadioGroup` component is used to group a collection of `Radio` components.
27
27
  * @see https://rsuitejs.com/components/radio/#radio-group
@@ -1,12 +1,12 @@
1
1
  'use client';
2
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
3
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
4
- import React, { useCallback, useMemo } from 'react';
4
+ import React, { useMemo } from 'react';
5
5
  import PropTypes from 'prop-types';
6
- import { useClassNames, useControlled } from '../utils';
6
+ import { useClassNames, useControlled, useEventCallback } from '../utils';
7
7
  import { oneOf } from '../internals/propTypes';
8
8
  import Plaintext from '../internals/Plaintext';
9
- export var RadioContext = /*#__PURE__*/React.createContext({});
9
+ export var RadioContext = /*#__PURE__*/React.createContext(void 0);
10
10
 
11
11
  /**
12
12
  * The `RadioGroup` component is used to group a collection of `Radio` components.
@@ -40,10 +40,10 @@ var RadioGroup = /*#__PURE__*/React.forwardRef(function (props, ref) {
40
40
  value = _useControlled[0],
41
41
  setValue = _useControlled[1],
42
42
  isControlled = _useControlled[2];
43
- var handleChange = useCallback(function (nextValue, event) {
43
+ var handleChange = useEventCallback(function (nextValue, event) {
44
44
  setValue(nextValue);
45
45
  onChange === null || onChange === void 0 ? void 0 : onChange(nextValue !== null && nextValue !== void 0 ? nextValue : '', event);
46
- }, [onChange, setValue]);
46
+ });
47
47
  var contextValue = useMemo(function () {
48
48
  return {
49
49
  inline: inline,
@@ -23,7 +23,7 @@ var TagPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
23
23
  trigger: trigger,
24
24
  tagProps: tagProps,
25
25
  onTagRemove: onTagRemove,
26
- renderMenuItemCheckbox: renderMenuItemCheckbox
26
+ renderCheckbox: renderMenuItemCheckbox
27
27
  };
28
28
  }, [onTagRemove, renderMenuItemCheckbox, tagProps, trigger]);
29
29
  return /*#__PURE__*/React.createElement(InputPickerContext.Provider, {
@@ -1,23 +1,14 @@
1
1
  import React from 'react';
2
2
  import { CheckboxProps } from '../../Checkbox';
3
3
  import { WithAsProps, RsRefForwardingComponent } from '../../@types/common';
4
- export interface ListCheckItemProps extends WithAsProps {
4
+ export interface ListCheckItemProps extends WithAsProps, Omit<CheckboxProps, 'onSelect'> {
5
5
  active?: boolean;
6
6
  checkboxAs?: React.ElementType | string;
7
- classPrefix?: string;
8
- disabled?: boolean;
9
- checkable?: boolean;
10
- indeterminate?: boolean;
11
- value?: string | number;
12
7
  focus?: boolean;
13
- title?: string;
14
- className?: string;
15
- children?: React.ReactNode;
16
8
  onSelect?: (value: any, event: React.SyntheticEvent, checked: boolean) => void;
17
9
  onCheck?: (value: any, event: React.SyntheticEvent, checked: boolean) => void;
18
10
  onSelectItem?: (value: any, event: React.SyntheticEvent, checked: boolean) => void;
19
- onKeyDown?: (event: React.KeyboardEvent) => void;
20
- renderMenuItemCheckbox?: (checkboxProps: CheckboxProps) => React.ReactNode;
11
+ renderCheckbox?: (checkboxProps: CheckboxProps) => React.ReactNode;
21
12
  }
22
13
  declare const ListCheckItem: RsRefForwardingComponent<'div', ListCheckItemProps>;
23
14
  export default ListCheckItem;