rsuite 5.55.1 → 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 (65) hide show
  1. package/AutoComplete/styles/index.css +3 -3
  2. package/CHANGELOG.md +17 -0
  3. package/Cascader/styles/index.css +3 -3
  4. package/CheckPicker/styles/index.css +142 -40
  5. package/CheckPicker/styles/index.less +1 -1
  6. package/CheckTree/styles/index.css +143 -41
  7. package/CheckTreePicker/styles/index.css +143 -41
  8. package/CheckTreePicker/styles/index.less +2 -2
  9. package/Checkbox/styles/index.css +159 -36
  10. package/Checkbox/styles/index.less +32 -13
  11. package/DatePicker/styles/index.css +3 -3
  12. package/DateRangePicker/styles/index.css +3 -3
  13. package/InputPicker/styles/index.css +3 -3
  14. package/MultiCascader/styles/index.css +141 -39
  15. package/Pagination/styles/index.css +3 -3
  16. package/Radio/styles/index.css +133 -19
  17. package/Radio/styles/index.less +28 -12
  18. package/RadioGroup/styles/index.css +1 -1
  19. package/RadioGroup/styles/index.less +1 -1
  20. package/SelectPicker/styles/index.css +3 -3
  21. package/TagGroup/styles/index.css +1 -1
  22. package/TagGroup/styles/index.less +1 -1
  23. package/TagInput/styles/index.css +141 -39
  24. package/TagPicker/styles/index.css +141 -39
  25. package/cjs/Checkbox/Checkbox.d.ts +67 -25
  26. package/cjs/Checkbox/Checkbox.js +36 -26
  27. package/cjs/InputPicker/InputPicker.js +2 -2
  28. package/cjs/InputPicker/InputPickerContext.d.ts +1 -1
  29. package/cjs/MultiCascader/TreeView.js +2 -1
  30. package/cjs/Radio/Radio.d.ts +42 -16
  31. package/cjs/Radio/Radio.js +42 -37
  32. package/cjs/RadioGroup/RadioGroup.d.ts +1 -1
  33. package/cjs/RadioGroup/RadioGroup.js +3 -3
  34. package/cjs/TagPicker/index.js +1 -1
  35. package/cjs/internals/Picker/ListCheckItem.d.ts +2 -11
  36. package/cjs/internals/Picker/ListCheckItem.js +8 -6
  37. package/dist/rsuite-no-reset-rtl.css +258 -63
  38. package/dist/rsuite-no-reset-rtl.min.css +1 -1
  39. package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
  40. package/dist/rsuite-no-reset.css +258 -63
  41. package/dist/rsuite-no-reset.min.css +1 -1
  42. package/dist/rsuite-no-reset.min.css.map +1 -1
  43. package/dist/rsuite-rtl.css +258 -63
  44. package/dist/rsuite-rtl.min.css +1 -1
  45. package/dist/rsuite-rtl.min.css.map +1 -1
  46. package/dist/rsuite.css +258 -63
  47. package/dist/rsuite.js +7 -7
  48. package/dist/rsuite.min.css +1 -1
  49. package/dist/rsuite.min.css.map +1 -1
  50. package/dist/rsuite.min.js +1 -1
  51. package/dist/rsuite.min.js.map +1 -1
  52. package/esm/Checkbox/Checkbox.d.ts +67 -25
  53. package/esm/Checkbox/Checkbox.js +38 -28
  54. package/esm/InputPicker/InputPicker.js +2 -2
  55. package/esm/InputPicker/InputPickerContext.d.ts +1 -1
  56. package/esm/MultiCascader/TreeView.js +2 -1
  57. package/esm/Radio/Radio.d.ts +42 -16
  58. package/esm/Radio/Radio.js +43 -38
  59. package/esm/RadioGroup/RadioGroup.d.ts +1 -1
  60. package/esm/RadioGroup/RadioGroup.js +5 -5
  61. package/esm/TagPicker/index.js +1 -1
  62. package/esm/internals/Picker/ListCheckItem.d.ts +2 -11
  63. package/esm/internals/Picker/ListCheckItem.js +8 -6
  64. package/internals/Picker/styles/index.less +1 -1
  65. package/package.json +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.
@@ -13,7 +13,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
  var _utils = require("../utils");
14
14
  var _CheckboxGroup = require("../CheckboxGroup");
15
15
  var _propTypes2 = require("../internals/propTypes");
16
- var _templateObject, _templateObject2, _templateObject3;
16
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
17
17
  /**
18
18
  * The Checkbox component is used for selecting multiple options from a set.
19
19
  * @see https://rsuitejs.com/components/checkbox
@@ -36,12 +36,15 @@ var Checkbox = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
36
36
  classPrefix = _props$classPrefix === void 0 ? 'checkbox' : _props$classPrefix,
37
37
  _props$checkable = props.checkable,
38
38
  checkable = _props$checkable === void 0 ? true : _props$checkable,
39
+ color = props.color,
39
40
  _props$defaultChecked = props.defaultChecked,
40
41
  defaultChecked = _props$defaultChecked === void 0 ? false : _props$defaultChecked,
41
42
  title = props.title,
42
43
  inputRef = props.inputRef,
43
44
  inputProps = props.inputProps,
44
45
  indeterminate = props.indeterminate,
46
+ _props$labelClickable = props.labelClickable,
47
+ labelClickable = _props$labelClickable === void 0 ? true : _props$labelClickable,
45
48
  _props$tabIndex = props.tabIndex,
46
49
  tabIndex = _props$tabIndex === void 0 ? 0 : _props$tabIndex,
47
50
  _props$disabled = props.disabled,
@@ -58,7 +61,7 @@ var Checkbox = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
58
61
  onClick = props.onClick,
59
62
  onCheckboxClick = props.onCheckboxClick,
60
63
  onChange = props.onChange,
61
- rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["as", "checked", "className", "children", "classPrefix", "checkable", "defaultChecked", "title", "inputRef", "inputProps", "indeterminate", "tabIndex", "disabled", "readOnly", "plaintext", "inline", "name", "value", "onClick", "onCheckboxClick", "onChange"]);
64
+ rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["as", "checked", "className", "children", "classPrefix", "checkable", "color", "defaultChecked", "title", "inputRef", "inputProps", "indeterminate", "labelClickable", "tabIndex", "disabled", "readOnly", "plaintext", "inline", "name", "value", "onClick", "onCheckboxClick", "onChange"]);
62
65
  var _useControlled = (0, _utils.useControlled)(controlledChecked, defaultChecked),
63
66
  selfChecked = _useControlled[0],
64
67
  setSelfChecked = _useControlled[1],
@@ -78,7 +81,7 @@ var Checkbox = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
78
81
  merge = _useClassNames.merge,
79
82
  prefix = _useClassNames.prefix,
80
83
  withClassPrefix = _useClassNames.withClassPrefix;
81
- var classes = merge(className, withClassPrefix({
84
+ var classes = merge(className, withClassPrefix(color, {
82
85
  inline: inline,
83
86
  indeterminate: indeterminate,
84
87
  disabled: disabled,
@@ -93,7 +96,8 @@ var Checkbox = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
93
96
  // In uncontrolled situations, use defaultChecked instead of checked
94
97
  htmlInputProps[controlled ? 'checked' : 'defaultChecked'] = checked;
95
98
  }
96
- var handleChange = (0, _react.useCallback)(function (event) {
99
+ var checkboxRef = (0, _react.useRef)(null);
100
+ var handleChange = (0, _utils.useEventCallback)(function (event) {
97
101
  var nextChecked = event.target.checked;
98
102
  if (disabled || readOnly) {
99
103
  return;
@@ -101,30 +105,34 @@ var Checkbox = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
101
105
  setSelfChecked(nextChecked);
102
106
  onChange === null || onChange === void 0 ? void 0 : onChange(value, nextChecked, event);
103
107
  onGroupChange === null || onGroupChange === void 0 ? void 0 : onGroupChange(value, nextChecked, event);
104
- }, [disabled, readOnly, setSelfChecked, onChange, value, onGroupChange]);
108
+ });
109
+ var handleLabelClick = (0, _utils.useEventCallback)(function (event) {
110
+ // Prevent check when label is not clickable
111
+ if (!labelClickable && event.target !== checkboxRef.current) {
112
+ event.preventDefault();
113
+ }
114
+ });
115
+ var labelId = (0, _utils.useUniqueId)('label-');
105
116
  if (plaintext) {
106
117
  return checked ? /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, restProps, {
107
118
  ref: ref,
108
119
  className: classes
109
120
  }), children) : null;
110
121
  }
111
- var input = /*#__PURE__*/_react.default.createElement("span", {
112
- className: prefix(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2.default)(["wrapper"]))),
113
- onClick: onCheckboxClick,
114
- "aria-disabled": disabled
122
+ var control = /*#__PURE__*/_react.default.createElement("span", {
123
+ className: prefix(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2.default)(["control"])))
115
124
  }, /*#__PURE__*/_react.default.createElement("input", (0, _extends2.default)({}, htmlInputProps, inputProps, {
125
+ "aria-disabled": disabled,
126
+ "aria-checked": indeterminate ? 'mixed' : checked,
127
+ "aria-labelledby": labelId,
116
128
  name: name,
117
129
  value: value,
118
130
  type: "checkbox",
119
- ref: inputRef,
131
+ ref: (0, _utils.mergeRefs)(checkboxRef, inputRef),
120
132
  tabIndex: tabIndex,
121
133
  readOnly: readOnly,
122
134
  disabled: disabled,
123
- "aria-disabled": disabled,
124
- "aria-checked": indeterminate ? 'mixed' : checked,
125
- onClick: function onClick(event) {
126
- return event.stopPropagation();
127
- },
135
+ onClick: onCheckboxClick,
128
136
  onChange: handleChange
129
137
  })), /*#__PURE__*/_react.default.createElement("span", {
130
138
  className: prefix(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteralLoose2.default)(["inner"]))),
@@ -138,28 +146,30 @@ var Checkbox = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
138
146
  }), /*#__PURE__*/_react.default.createElement("div", {
139
147
  className: prefix(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteralLoose2.default)(["checker"])))
140
148
  }, /*#__PURE__*/_react.default.createElement("label", {
141
- title: title
142
- }, checkable ? input : null, children)));
149
+ title: title,
150
+ onClick: handleLabelClick
151
+ }, checkable ? control : null, /*#__PURE__*/_react.default.createElement("span", {
152
+ className: prefix(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteralLoose2.default)(["label"]))),
153
+ id: labelId
154
+ }, children))));
143
155
  });
144
156
  Checkbox.displayName = 'Checkbox';
145
157
  Checkbox.propTypes = {
146
158
  as: _propTypes.default.elementType,
147
- title: _propTypes.default.string,
159
+ checked: _propTypes.default.bool,
160
+ checkable: _propTypes.default.bool,
148
161
  className: _propTypes.default.string,
149
- inline: _propTypes.default.bool,
162
+ children: _propTypes.default.node,
163
+ classPrefix: _propTypes.default.string,
150
164
  disabled: _propTypes.default.bool,
151
- checked: _propTypes.default.bool,
152
165
  defaultChecked: _propTypes.default.bool,
166
+ inline: _propTypes.default.bool,
153
167
  indeterminate: _propTypes.default.bool,
154
- onChange: _propTypes.default.func,
155
- onClick: _propTypes.default.func,
156
168
  inputProps: _propTypes.default.any,
157
169
  inputRef: _propTypes2.refType,
158
170
  value: _propTypes.default.any,
159
- children: _propTypes.default.node,
160
- classPrefix: _propTypes.default.string,
161
- tabIndex: _propTypes.default.number,
162
- checkable: _propTypes.default.bool,
171
+ onChange: _propTypes.default.func,
172
+ onClick: _propTypes.default.func,
163
173
  onCheckboxClick: _propTypes.default.func
164
174
  };
165
175
  var _default = Checkbox;
@@ -124,7 +124,7 @@ var InputPicker = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
124
124
  trigger = _useContext.trigger,
125
125
  disabledOptions = _useContext.disabledOptions,
126
126
  onTagRemove = _useContext.onTagRemove,
127
- renderMenuItemCheckbox = _useContext.renderMenuItemCheckbox;
127
+ renderCheckbox = _useContext.renderCheckbox;
128
128
  if (groupBy === valueKey || groupBy === labelKey) {
129
129
  throw Error('`groupBy` can not be equal to `valueKey` and `labelKey`');
130
130
  }
@@ -579,7 +579,7 @@ var InputPicker = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
579
579
  listItemClassPrefix: multi ? undefined : menuClassPrefix + "-item",
580
580
  listItemAs: multi ? _Picker.ListCheckItem : _Picker.ListItem,
581
581
  listItemProps: {
582
- renderMenuItemCheckbox: renderMenuItemCheckbox
582
+ renderCheckbox: renderCheckbox
583
583
  },
584
584
  activeItemValues: multi ? value : [value],
585
585
  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;
@@ -125,7 +125,8 @@ var TreeView = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
125
125
  onCheck: function onCheck(_value, event, checked) {
126
126
  return _onCheck === null || _onCheck === void 0 ? void 0 : _onCheck(node, event, checked);
127
127
  },
128
- checkable: !uncheckable
128
+ checkable: !uncheckable,
129
+ labelClickable: false
129
130
  }, renderMenuItem ? renderMenuItem(label, node) : label, children ? /*#__PURE__*/_react.default.createElement(Icon, {
130
131
  className: prefix('caret'),
131
132
  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,10 +1,11 @@
1
1
  'use client';
2
2
  "use strict";
3
3
 
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
5
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
6
6
  exports.__esModule = true;
7
7
  exports.default = void 0;
8
+ var _taggedTemplateLiteralLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteralLoose"));
8
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
10
  var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
10
11
  var _react = _interopRequireWildcard(require("react"));
@@ -12,26 +13,28 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
12
13
  var _RadioGroup = require("../RadioGroup/RadioGroup");
13
14
  var _utils = require("../utils");
14
15
  var _propTypes2 = require("../internals/propTypes");
16
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
15
17
  /**
16
18
  * The `Radio` component is a simple radio button.
17
19
  * @see https://rsuitejs.com/components/radio
18
20
  */
19
21
  var Radio = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
20
- var _useContext = (0, _react.useContext)(_RadioGroup.RadioContext),
21
- groupValue = _useContext.value,
22
- controlled = _useContext.controlled,
23
- inlineContext = _useContext.inline,
24
- nameContext = _useContext.name,
25
- disabledContext = _useContext.disabled,
26
- readOnlyContext = _useContext.readOnly,
27
- plaintextContext = _useContext.plaintext,
28
- onGroupChange = _useContext.onChange;
22
+ var radioContext = (0, _react.useContext)(_RadioGroup.RadioContext);
23
+ var _ref = radioContext !== null && radioContext !== void 0 ? radioContext : {},
24
+ groupValue = _ref.value,
25
+ inlineContext = _ref.inline,
26
+ nameContext = _ref.name,
27
+ disabledContext = _ref.disabled,
28
+ readOnlyContext = _ref.readOnly,
29
+ plaintextContext = _ref.plaintext,
30
+ onGroupChange = _ref.onChange;
29
31
  var _props$as = props.as,
30
32
  Component = _props$as === void 0 ? 'div' : _props$as,
31
33
  title = props.title,
32
34
  className = props.className,
33
35
  children = props.children,
34
36
  checkedProp = props.checked,
37
+ color = props.color,
35
38
  defaultChecked = props.defaultChecked,
36
39
  _props$classPrefix = props.classPrefix,
37
40
  classPrefix = _props$classPrefix === void 0 ? 'radio' : _props$classPrefix,
@@ -52,15 +55,16 @@ var Radio = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
52
55
  value = props.value,
53
56
  onChange = props.onChange,
54
57
  onClick = props.onClick,
55
- rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["as", "title", "className", "children", "checked", "defaultChecked", "classPrefix", "tabIndex", "inputRef", "inputProps", "disabled", "readOnly", "plaintext", "inline", "name", "value", "onChange", "onClick"]);
58
+ rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["as", "title", "className", "children", "checked", "color", "defaultChecked", "classPrefix", "tabIndex", "inputRef", "inputProps", "disabled", "readOnly", "plaintext", "inline", "name", "value", "onChange", "onClick"]);
56
59
  var _useControlled = (0, _utils.useControlled)(typeof groupValue !== 'undefined' ? groupValue === value : checkedProp, defaultChecked || false),
57
60
  checked = _useControlled[0],
58
- setChecked = _useControlled[1];
61
+ setChecked = _useControlled[1],
62
+ selfControlled = _useControlled[2];
59
63
  var _useClassNames = (0, _utils.useClassNames)(classPrefix),
60
64
  merge = _useClassNames.merge,
61
65
  withClassPrefix = _useClassNames.withClassPrefix,
62
66
  prefix = _useClassNames.prefix;
63
- var classes = merge(className, withClassPrefix({
67
+ var classes = merge(className, withClassPrefix(color, {
64
68
  inline: inline,
65
69
  disabled: disabled,
66
70
  checked: checked
@@ -68,59 +72,62 @@ var Radio = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
68
72
  var _partitionHTMLProps = (0, _utils.partitionHTMLProps)(rest),
69
73
  htmlInputProps = _partitionHTMLProps[0],
70
74
  restProps = _partitionHTMLProps[1];
71
- var handleChange = (0, _react.useCallback)(function (event) {
75
+ var handleChange = (0, _utils.useEventCallback)(function (event) {
72
76
  if (disabled || readOnly) {
73
77
  return;
74
78
  }
75
79
  setChecked(true);
76
80
  onGroupChange === null || onGroupChange === void 0 ? void 0 : onGroupChange(value, event);
77
81
  onChange === null || onChange === void 0 ? void 0 : onChange(value, true, event);
78
- }, [disabled, onChange, onGroupChange, readOnly, setChecked, value]);
82
+ });
83
+ var controlled = radioContext ? true : selfControlled;
79
84
  if (typeof controlled !== 'undefined') {
80
85
  // In uncontrolled situations, use defaultChecked instead of checked
81
86
  htmlInputProps[controlled ? 'checked' : 'defaultChecked'] = checked;
82
87
  }
83
- var input = /*#__PURE__*/_react.default.createElement("span", {
84
- className: prefix('wrapper')
88
+ var labelId = (0, _utils.useUniqueId)('label-');
89
+ if (plaintext) {
90
+ return checked ? /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, restProps, {
91
+ ref: ref,
92
+ className: classes
93
+ }), children) : null;
94
+ }
95
+ var control = /*#__PURE__*/_react.default.createElement("span", {
96
+ className: prefix(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2.default)(["control"])))
85
97
  }, /*#__PURE__*/_react.default.createElement("input", (0, _extends2.default)({}, htmlInputProps, inputProps, {
98
+ "aria-labelledby": labelId,
99
+ "aria-checked": checked,
100
+ "aria-disabled": disabled,
86
101
  ref: inputRef,
87
102
  type: "radio",
88
103
  name: name,
89
104
  value: value,
90
105
  tabIndex: tabIndex,
106
+ readOnly: readOnly,
91
107
  disabled: disabled,
92
- onChange: handleChange,
93
- onClick: (0, _react.useCallback)(function (event) {
94
- return event.stopPropagation();
95
- }, [])
108
+ onChange: handleChange
96
109
  })), /*#__PURE__*/_react.default.createElement("span", {
97
- className: prefix('inner'),
110
+ className: prefix(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteralLoose2.default)(["inner"]))),
98
111
  "aria-hidden": true
99
112
  }));
100
- if (plaintext) {
101
- return checked ? /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, restProps, {
102
- ref: ref,
103
- className: classes
104
- }), children) : null;
105
- }
106
113
  return /*#__PURE__*/_react.default.createElement(Component, (0, _extends2.default)({}, restProps, {
107
114
  ref: ref,
108
115
  onClick: onClick,
109
- className: classes,
110
- "aria-checked": checked,
111
- "aria-disabled": disabled
116
+ className: classes
112
117
  }), /*#__PURE__*/_react.default.createElement("div", {
113
- className: prefix('checker')
118
+ className: prefix(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteralLoose2.default)(["checker"])))
114
119
  }, children ? /*#__PURE__*/_react.default.createElement("label", {
115
120
  title: title
116
- }, input, children) : input));
121
+ }, control, /*#__PURE__*/_react.default.createElement("span", {
122
+ className: prefix(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteralLoose2.default)(["label"]))),
123
+ id: labelId
124
+ }, children)) : control));
117
125
  });
118
126
  Radio.displayName = 'Radio';
119
127
  Radio.propTypes = {
120
128
  id: _propTypes.default.string,
121
129
  name: _propTypes.default.string,
122
130
  inline: _propTypes.default.bool,
123
- title: _propTypes.default.string,
124
131
  disabled: _propTypes.default.bool,
125
132
  checked: _propTypes.default.bool,
126
133
  defaultChecked: _propTypes.default.bool,
@@ -130,9 +137,7 @@ Radio.propTypes = {
130
137
  classPrefix: _propTypes.default.string,
131
138
  value: _propTypes.default.any,
132
139
  inputRef: _propTypes2.refType,
133
- onChange: _propTypes.default.func,
134
- onClick: _propTypes.default.func,
135
- tabIndex: _propTypes.default.number
140
+ onChange: _propTypes.default.func
136
141
  };
137
142
  var _default = Radio;
138
143
  exports.default = _default;
@@ -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
@@ -12,7 +12,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
12
12
  var _utils = require("../utils");
13
13
  var _propTypes2 = require("../internals/propTypes");
14
14
  var _Plaintext = _interopRequireDefault(require("../internals/Plaintext"));
15
- var RadioContext = /*#__PURE__*/_react.default.createContext({});
15
+ var RadioContext = /*#__PURE__*/_react.default.createContext(void 0);
16
16
 
17
17
  /**
18
18
  * The `RadioGroup` component is used to group a collection of `Radio` components.
@@ -47,10 +47,10 @@ var RadioGroup = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
47
47
  value = _useControlled[0],
48
48
  setValue = _useControlled[1],
49
49
  isControlled = _useControlled[2];
50
- var handleChange = (0, _react.useCallback)(function (nextValue, event) {
50
+ var handleChange = (0, _utils.useEventCallback)(function (nextValue, event) {
51
51
  setValue(nextValue);
52
52
  onChange === null || onChange === void 0 ? void 0 : onChange(nextValue !== null && nextValue !== void 0 ? nextValue : '', event);
53
- }, [onChange, setValue]);
53
+ });
54
54
  var contextValue = (0, _react.useMemo)(function () {
55
55
  return {
56
56
  inline: inline,
@@ -29,7 +29,7 @@ var TagPicker = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
29
29
  trigger: trigger,
30
30
  tagProps: tagProps,
31
31
  onTagRemove: onTagRemove,
32
- renderMenuItemCheckbox: renderMenuItemCheckbox
32
+ renderCheckbox: renderMenuItemCheckbox
33
33
  };
34
34
  }, [onTagRemove, renderMenuItemCheckbox, tagProps, trigger]);
35
35
  return /*#__PURE__*/_react.default.createElement(_InputPickerContext.default.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;
@@ -29,12 +29,13 @@ var ListCheckItem = /*#__PURE__*/_react.default.forwardRef(function (props, ref)
29
29
  children = props.children,
30
30
  className = props.className,
31
31
  indeterminate = props.indeterminate,
32
+ labelClickable = props.labelClickable,
32
33
  onKeyDown = props.onKeyDown,
33
34
  onSelect = props.onSelect,
34
35
  onCheck = props.onCheck,
35
36
  onSelectItem = props.onSelectItem,
36
- renderMenuItemCheckbox = props.renderMenuItemCheckbox,
37
- rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["active", "as", "checkboxAs", "classPrefix", "checkable", "disabled", "value", "focus", "children", "className", "indeterminate", "onKeyDown", "onSelect", "onCheck", "onSelectItem", "renderMenuItemCheckbox"]);
37
+ renderCheckbox = props.renderCheckbox,
38
+ rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["active", "as", "checkboxAs", "classPrefix", "checkable", "disabled", "value", "focus", "children", "className", "indeterminate", "labelClickable", "onKeyDown", "onSelect", "onCheck", "onSelectItem", "renderCheckbox"]);
38
39
  var handleChange = (0, _utils.useEventCallback)(function (value, checked, event) {
39
40
  onSelect === null || onSelect === void 0 ? void 0 : onSelect(value, event, checked);
40
41
  });
@@ -58,13 +59,14 @@ var ListCheckItem = /*#__PURE__*/_react.default.forwardRef(function (props, ref)
58
59
  focus: focus
59
60
  });
60
61
  var checkboxProps = {
61
- value: value,
62
- disabled: disabled,
63
- indeterminate: indeterminate,
64
62
  checkable: checkable,
65
63
  children: children,
66
64
  checked: active,
67
65
  className: checkboxItemClasses,
66
+ disabled: disabled,
67
+ value: value,
68
+ indeterminate: indeterminate,
69
+ labelClickable: labelClickable,
68
70
  onKeyDown: disabled ? undefined : onKeyDown,
69
71
  onChange: handleChange,
70
72
  onClick: handleSelectItem,
@@ -80,7 +82,7 @@ var ListCheckItem = /*#__PURE__*/_react.default.forwardRef(function (props, ref)
80
82
  ref: ref,
81
83
  className: merge(className, rootPrefix(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2.default)(["picker-list-item"])))),
82
84
  tabIndex: -1
83
- }), renderMenuItemCheckbox ? renderMenuItemCheckbox(checkboxProps) : /*#__PURE__*/_react.default.createElement(CheckboxItem, (0, _extends2.default)({
85
+ }), renderCheckbox ? renderCheckbox(checkboxProps) : /*#__PURE__*/_react.default.createElement(CheckboxItem, (0, _extends2.default)({
84
86
  role: "checkbox"
85
87
  }, checkboxProps)));
86
88
  });