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.
- package/AutoComplete/styles/index.css +3 -3
- package/CHANGELOG.md +29 -0
- package/Calendar/styles/index.css +3 -0
- package/Calendar/styles/index.less +3 -1
- package/Cascader/styles/index.css +3 -3
- package/CheckPicker/styles/index.css +142 -40
- package/CheckPicker/styles/index.less +1 -1
- package/CheckTree/styles/index.css +143 -41
- package/CheckTreePicker/styles/index.css +143 -41
- package/CheckTreePicker/styles/index.less +2 -2
- package/Checkbox/styles/index.css +159 -36
- package/Checkbox/styles/index.less +32 -13
- package/DatePicker/styles/index.css +10 -5
- package/DatePicker/styles/index.less +5 -2
- package/DateRangePicker/styles/index.css +22 -14
- package/DateRangePicker/styles/index.less +5 -1
- package/InputPicker/styles/index.css +3 -3
- package/Message/styles/index.css +1 -1
- package/MultiCascader/styles/index.css +141 -39
- package/Nav/styles/index.css +1 -2
- package/Nav/styles/index.less +1 -2
- package/Pagination/styles/index.css +3 -3
- package/Radio/styles/index.css +133 -19
- package/Radio/styles/index.less +28 -12
- package/RadioGroup/styles/index.css +1 -1
- package/RadioGroup/styles/index.less +1 -1
- package/SelectPicker/styles/index.css +3 -3
- package/Tabs/styles/index.css +1 -2
- package/TagGroup/styles/index.css +1 -1
- package/TagGroup/styles/index.less +1 -1
- package/TagInput/styles/index.css +141 -39
- package/TagPicker/styles/index.css +141 -39
- package/cjs/Checkbox/Checkbox.d.ts +67 -25
- package/cjs/Checkbox/Checkbox.js +36 -26
- package/cjs/DatePicker/DatePicker.js +1 -1
- package/cjs/DateRangePicker/DateRangePicker.js +1 -1
- package/cjs/InputPicker/InputPicker.js +2 -2
- package/cjs/InputPicker/InputPickerContext.d.ts +1 -1
- package/cjs/MultiCascader/TreeView.js +2 -1
- package/cjs/Radio/Radio.d.ts +42 -16
- package/cjs/Radio/Radio.js +42 -37
- package/cjs/RadioGroup/RadioGroup.d.ts +1 -1
- package/cjs/RadioGroup/RadioGroup.js +3 -3
- package/cjs/TagPicker/index.js +1 -1
- package/cjs/internals/Picker/ListCheckItem.d.ts +2 -11
- package/cjs/internals/Picker/ListCheckItem.js +8 -6
- package/dist/rsuite-no-reset-rtl.css +279 -77
- package/dist/rsuite-no-reset-rtl.min.css +1 -1
- package/dist/rsuite-no-reset-rtl.min.css.map +1 -1
- package/dist/rsuite-no-reset.css +279 -77
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite-no-reset.min.css.map +1 -1
- package/dist/rsuite-rtl.css +279 -77
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +279 -77
- package/dist/rsuite.js +9 -9
- package/dist/rsuite.min.css +1 -1
- package/dist/rsuite.min.css.map +1 -1
- package/dist/rsuite.min.js +1 -1
- package/dist/rsuite.min.js.map +1 -1
- package/esm/Checkbox/Checkbox.d.ts +67 -25
- package/esm/Checkbox/Checkbox.js +38 -28
- package/esm/DatePicker/DatePicker.js +1 -1
- package/esm/DateRangePicker/DateRangePicker.js +1 -1
- package/esm/InputPicker/InputPicker.js +2 -2
- package/esm/InputPicker/InputPickerContext.d.ts +1 -1
- package/esm/MultiCascader/TreeView.js +2 -1
- package/esm/Radio/Radio.d.ts +42 -16
- package/esm/Radio/Radio.js +43 -38
- package/esm/RadioGroup/RadioGroup.d.ts +1 -1
- package/esm/RadioGroup/RadioGroup.js +5 -5
- package/esm/TagPicker/index.js +1 -1
- package/esm/internals/Picker/ListCheckItem.d.ts +2 -11
- package/esm/internals/Picker/ListCheckItem.js +8 -6
- package/internals/Picker/styles/index.less +1 -1
- package/package.json +1 -1
- package/styles/variables.less +1 -1
package/cjs/Checkbox/Checkbox.js
CHANGED
|
@@ -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
|
|
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
|
-
}
|
|
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
|
|
112
|
-
className: prefix(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2.default)(["
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
159
|
+
checked: _propTypes.default.bool,
|
|
160
|
+
checkable: _propTypes.default.bool,
|
|
148
161
|
className: _propTypes.default.string,
|
|
149
|
-
|
|
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
|
-
|
|
160
|
-
|
|
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;
|
|
@@ -419,7 +419,7 @@ var DatePicker = /*#__PURE__*/_react.default.forwardRef(function (props, ref) {
|
|
|
419
419
|
var left = positionProps.left,
|
|
420
420
|
top = positionProps.top,
|
|
421
421
|
className = positionProps.className;
|
|
422
|
-
var classes = merge(menuClassName, className);
|
|
422
|
+
var classes = merge(menuClassName, className, prefix('popup-date'));
|
|
423
423
|
var styles = (0, _extends2.default)({}, menuStyle, {
|
|
424
424
|
left: left,
|
|
425
425
|
top: top
|
|
@@ -559,7 +559,7 @@ var DateRangePicker = /*#__PURE__*/_react.default.forwardRef(function (props, re
|
|
|
559
559
|
var left = positionProps.left,
|
|
560
560
|
top = positionProps.top,
|
|
561
561
|
className = positionProps.className;
|
|
562
|
-
var classes = merge(className, menuClassName, prefix('daterange
|
|
562
|
+
var classes = merge(className, menuClassName, prefix('popup-daterange'));
|
|
563
563
|
var panelClasses = prefix('daterange-panel', {
|
|
564
564
|
'daterange-panel-show-one-calendar': showOneCalendar
|
|
565
565
|
});
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
package/cjs/Radio/Radio.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
/**
|
|
15
|
+
/**
|
|
16
|
+
* Make the control readonly
|
|
17
|
+
*/
|
|
10
18
|
readOnly?: boolean;
|
|
11
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Render the control as plain text
|
|
21
|
+
*/
|
|
12
22
|
plaintext?: boolean;
|
|
13
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* Specifies whether the radio is selected
|
|
25
|
+
*/
|
|
14
26
|
checked?: boolean;
|
|
15
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* Specifies the initial state: whether or not the radio is selected
|
|
29
|
+
*/
|
|
16
30
|
defaultChecked?: boolean;
|
|
17
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Attributes applied to the input element
|
|
33
|
+
*/
|
|
18
34
|
inputProps?: React.HTMLAttributes<HTMLInputElement>;
|
|
19
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Pass a ref to the input element
|
|
37
|
+
*/
|
|
20
38
|
inputRef?: React.Ref<HTMLInputElement>;
|
|
21
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* Value, corresponding to the value of the Radiogroup, to determine whether the
|
|
41
|
+
*/
|
|
22
42
|
value?: T;
|
|
23
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Name to use for form
|
|
45
|
+
*/
|
|
24
46
|
name?: string;
|
|
25
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Inline layout.
|
|
49
|
+
*
|
|
50
|
+
* @private Used in RadioGroup
|
|
51
|
+
*/
|
|
26
52
|
inline?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
|
|
29
|
-
|
|
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
|
/**
|
package/cjs/Radio/Radio.js
CHANGED
|
@@ -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
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
inlineContext =
|
|
24
|
-
nameContext =
|
|
25
|
-
disabledContext =
|
|
26
|
-
readOnlyContext =
|
|
27
|
-
plaintextContext =
|
|
28
|
-
onGroupChange =
|
|
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,
|
|
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
|
-
}
|
|
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
|
|
84
|
-
|
|
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(
|
|
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(
|
|
118
|
+
className: prefix(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteralLoose2.default)(["checker"])))
|
|
114
119
|
}, children ? /*#__PURE__*/_react.default.createElement("label", {
|
|
115
120
|
title: title
|
|
116
|
-
},
|
|
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,
|
|
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
|
-
}
|
|
53
|
+
});
|
|
54
54
|
var contextValue = (0, _react.useMemo)(function () {
|
|
55
55
|
return {
|
|
56
56
|
inline: inline,
|
package/cjs/TagPicker/index.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
37
|
-
rest = (0, _objectWithoutPropertiesLoose2.default)(props, ["active", "as", "checkboxAs", "classPrefix", "checkable", "disabled", "value", "focus", "children", "className", "indeterminate", "onKeyDown", "onSelect", "onCheck", "onSelectItem", "
|
|
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
|
-
}),
|
|
85
|
+
}), renderCheckbox ? renderCheckbox(checkboxProps) : /*#__PURE__*/_react.default.createElement(CheckboxItem, (0, _extends2.default)({
|
|
84
86
|
role: "checkbox"
|
|
85
87
|
}, checkboxProps)));
|
|
86
88
|
});
|