rsuite 5.34.0 → 5.35.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/CHANGELOG.md +13 -0
- package/Checkbox/styles/mixin.less +1 -1
- package/CheckboxGroup/styles/index.less +4 -1
- package/RadioGroup/styles/index.less +4 -1
- package/RadioTile/package.json +7 -0
- package/RadioTile/styles/index.less +69 -0
- package/RadioTileGroup/package.json +7 -0
- package/RadioTileGroup/styles/index.less +1 -0
- package/cjs/InputPicker/InputPicker.js +1 -1
- package/cjs/RadioTile/RadioTile.d.ts +25 -0
- package/cjs/RadioTile/RadioTile.js +128 -0
- package/cjs/RadioTile/index.d.ts +3 -0
- package/cjs/RadioTile/index.js +11 -0
- package/cjs/RadioTileGroup/RadioTileGroup.d.ts +23 -0
- package/cjs/RadioTileGroup/RadioTileGroup.js +89 -0
- package/cjs/RadioTileGroup/index.d.ts +3 -0
- package/cjs/RadioTileGroup/index.js +11 -0
- package/cjs/index.d.ts +4 -0
- package/cjs/index.js +9 -1
- package/dist/rsuite-no-reset-rtl.css +92 -4
- 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 +92 -4
- package/dist/rsuite-no-reset.min.css +1 -1
- package/dist/rsuite-no-reset.min.css.map +1 -1
- package/dist/rsuite-rtl.css +92 -4
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +92 -4
- package/dist/rsuite.js +50 -6
- package/dist/rsuite.js.map +1 -1
- 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/InputPicker/InputPicker.js +1 -1
- package/esm/RadioTile/RadioTile.d.ts +25 -0
- package/esm/RadioTile/RadioTile.js +108 -0
- package/esm/RadioTile/index.d.ts +3 -0
- package/esm/RadioTile/index.js +2 -0
- package/esm/RadioTileGroup/RadioTileGroup.d.ts +23 -0
- package/esm/RadioTileGroup/RadioTileGroup.js +69 -0
- package/esm/RadioTileGroup/index.d.ts +3 -0
- package/esm/RadioTileGroup/index.js +2 -0
- package/esm/index.d.ts +4 -0
- package/esm/index.js +2 -0
- package/package.json +2 -2
- package/styles/color-modes/dark.less +7 -0
- package/styles/color-modes/high-contrast.less +7 -0
- package/styles/color-modes/light.less +8 -0
- package/styles/index.less +1 -0
|
@@ -583,7 +583,7 @@ var InputPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
583
583
|
top = positionProps.top,
|
|
584
584
|
className = positionProps.className;
|
|
585
585
|
var menuClassPrefix = multi ? 'picker-check-menu' : 'picker-select-menu';
|
|
586
|
-
var classes = merge(className, menuClassName, prefix(
|
|
586
|
+
var classes = merge(className, menuClassName, prefix(multi ? 'check-menu' : 'select-menu'));
|
|
587
587
|
|
|
588
588
|
var styles = _extends({}, menuStyle, {
|
|
589
589
|
left: left,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { WithAsProps } from '../@types/common';
|
|
3
|
+
export declare type ValueType = string | number;
|
|
4
|
+
export interface RadioTileProps<T = ValueType> extends WithAsProps, Omit<React.HTMLAttributes<HTMLDivElement>, 'onChange'> {
|
|
5
|
+
/** Additional description, if needed*/
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
/** Specifies whether the radio is selected */
|
|
8
|
+
checked?: boolean;
|
|
9
|
+
/** Specifies the initial state: whether or not the radio is selected */
|
|
10
|
+
defaultChecked?: boolean;
|
|
11
|
+
/** Whether the Radio is disabled */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
/** Label of the Radio tile */
|
|
14
|
+
label?: React.ReactNode;
|
|
15
|
+
/** Icon to be used */
|
|
16
|
+
icon?: React.ReactNode;
|
|
17
|
+
/** Name to use for form */
|
|
18
|
+
name?: string;
|
|
19
|
+
/** Value, corresponding to the value of the RadioTileGroup, to determine whether the */
|
|
20
|
+
value?: T;
|
|
21
|
+
/** Callback function with value changed */
|
|
22
|
+
onChange?: (value?: T, event?: React.ChangeEvent<HTMLInputElement>) => void;
|
|
23
|
+
}
|
|
24
|
+
declare const RadioTile: React.ForwardRefExoticComponent<RadioTileProps<ValueType> & React.RefAttributes<unknown>>;
|
|
25
|
+
export default RadioTile;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
import React, { useCallback, useContext } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import CheckIcon from '@rsuite/icons/Check';
|
|
6
|
+
import Stack from '../Stack';
|
|
7
|
+
import { RadioTileContext } from '../RadioTileGroup/RadioTileGroup';
|
|
8
|
+
import { useClassNames, useControlled, partitionHTMLProps } from '../utils';
|
|
9
|
+
import useUniqueId from '../utils/useUniqueId';
|
|
10
|
+
var RadioTile = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
11
|
+
var _useContext = useContext(RadioTileContext),
|
|
12
|
+
groupValue = _useContext.value,
|
|
13
|
+
nameContext = _useContext.name,
|
|
14
|
+
disabledContext = _useContext.disabled,
|
|
15
|
+
onGroupChange = _useContext.onChange;
|
|
16
|
+
|
|
17
|
+
var _props$as = props.as,
|
|
18
|
+
Component = _props$as === void 0 ? Stack : _props$as,
|
|
19
|
+
children = props.children,
|
|
20
|
+
_props$classPrefix = props.classPrefix,
|
|
21
|
+
classPrefix = _props$classPrefix === void 0 ? 'radio-tile' : _props$classPrefix,
|
|
22
|
+
checkedProp = props.checked,
|
|
23
|
+
className = props.className,
|
|
24
|
+
defaultChecked = props.defaultChecked,
|
|
25
|
+
_props$disabled = props.disabled,
|
|
26
|
+
disabled = _props$disabled === void 0 ? disabledContext : _props$disabled,
|
|
27
|
+
icon = props.icon,
|
|
28
|
+
value = props.value,
|
|
29
|
+
label = props.label,
|
|
30
|
+
_props$name = props.name,
|
|
31
|
+
name = _props$name === void 0 ? nameContext : _props$name,
|
|
32
|
+
_props$tabIndex = props.tabIndex,
|
|
33
|
+
tabIndex = _props$tabIndex === void 0 ? 0 : _props$tabIndex,
|
|
34
|
+
onChange = props.onChange,
|
|
35
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "children", "classPrefix", "checked", "className", "defaultChecked", "disabled", "icon", "value", "label", "name", "tabIndex", "onChange"]);
|
|
36
|
+
|
|
37
|
+
var _useControlled = useControlled(typeof groupValue !== 'undefined' ? groupValue === value : checkedProp, defaultChecked || false),
|
|
38
|
+
checked = _useControlled[0],
|
|
39
|
+
setChecked = _useControlled[1];
|
|
40
|
+
|
|
41
|
+
var _partitionHTMLProps = partitionHTMLProps(rest),
|
|
42
|
+
htmlInputProps = _partitionHTMLProps[0],
|
|
43
|
+
restProps = _partitionHTMLProps[1];
|
|
44
|
+
|
|
45
|
+
var _useClassNames = useClassNames(classPrefix),
|
|
46
|
+
merge = _useClassNames.merge,
|
|
47
|
+
withClassPrefix = _useClassNames.withClassPrefix,
|
|
48
|
+
prefix = _useClassNames.prefix;
|
|
49
|
+
|
|
50
|
+
var handleChange = useCallback(function (event) {
|
|
51
|
+
setChecked(true);
|
|
52
|
+
onGroupChange === null || onGroupChange === void 0 ? void 0 : onGroupChange(value, event);
|
|
53
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value, event);
|
|
54
|
+
}, [onChange, onGroupChange, setChecked, value]);
|
|
55
|
+
var classes = merge(className, withClassPrefix({
|
|
56
|
+
checked: checked,
|
|
57
|
+
disabled: disabled
|
|
58
|
+
}));
|
|
59
|
+
var radioId = useUniqueId('radio-');
|
|
60
|
+
return /*#__PURE__*/React.createElement(Component, _extends({
|
|
61
|
+
spacing: 6
|
|
62
|
+
}, restProps, {
|
|
63
|
+
childrenRenderMode: "clone",
|
|
64
|
+
ref: ref,
|
|
65
|
+
className: classes,
|
|
66
|
+
as: "label"
|
|
67
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
68
|
+
className: prefix('icon')
|
|
69
|
+
}, icon), /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
className: prefix('body')
|
|
71
|
+
}, /*#__PURE__*/React.createElement("input", _extends({}, htmlInputProps, {
|
|
72
|
+
type: "radio",
|
|
73
|
+
name: name,
|
|
74
|
+
value: value,
|
|
75
|
+
checked: checked,
|
|
76
|
+
tabIndex: tabIndex,
|
|
77
|
+
disabled: disabled,
|
|
78
|
+
onChange: handleChange,
|
|
79
|
+
"aria-checked": checked,
|
|
80
|
+
"aria-disabled": disabled,
|
|
81
|
+
"aria-labelledby": radioId + "-label",
|
|
82
|
+
"aria-describedby": radioId + "-desc"
|
|
83
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
84
|
+
className: prefix('label'),
|
|
85
|
+
id: radioId + "-label"
|
|
86
|
+
}, label), /*#__PURE__*/React.createElement("div", {
|
|
87
|
+
className: prefix('content'),
|
|
88
|
+
id: radioId + "-desc"
|
|
89
|
+
}, children), /*#__PURE__*/React.createElement("div", {
|
|
90
|
+
className: prefix('mark')
|
|
91
|
+
}, /*#__PURE__*/React.createElement(CheckIcon, {
|
|
92
|
+
className: prefix('mark-icon')
|
|
93
|
+
}))));
|
|
94
|
+
});
|
|
95
|
+
RadioTile.displayName = 'RadioTile';
|
|
96
|
+
RadioTile.propTypes = {
|
|
97
|
+
children: PropTypes.node,
|
|
98
|
+
classPrefix: PropTypes.string,
|
|
99
|
+
checked: PropTypes.bool,
|
|
100
|
+
defaultChecked: PropTypes.bool,
|
|
101
|
+
disabled: PropTypes.bool,
|
|
102
|
+
icon: PropTypes.node,
|
|
103
|
+
label: PropTypes.node,
|
|
104
|
+
name: PropTypes.string,
|
|
105
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
106
|
+
onChange: PropTypes.func
|
|
107
|
+
};
|
|
108
|
+
export default RadioTile;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { WithAsProps, FormControlBaseProps, RsRefForwardingComponent } from '../@types/common';
|
|
3
|
+
import { ValueType } from '../RadioTile';
|
|
4
|
+
export interface RadioTileContextProps {
|
|
5
|
+
name?: string;
|
|
6
|
+
value?: ValueType | null;
|
|
7
|
+
controlled?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
onChange?: (value: ValueType | undefined, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
10
|
+
}
|
|
11
|
+
export interface RadioTileGroupProps<T = ValueType> extends WithAsProps, FormControlBaseProps<T> {
|
|
12
|
+
/** Name to use for form */
|
|
13
|
+
name?: string;
|
|
14
|
+
/** Inline layout */
|
|
15
|
+
inline?: boolean;
|
|
16
|
+
/** Whether radio is disabled */
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
/** Primary content */
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
}
|
|
21
|
+
export declare const RadioTileContext: React.Context<RadioTileContextProps>;
|
|
22
|
+
declare const RadioTileGroup: RsRefForwardingComponent<'div', RadioTileGroupProps>;
|
|
23
|
+
export default RadioTileGroup;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
import React, { useCallback, useMemo } from 'react';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { useClassNames, useControlled } from '../utils';
|
|
6
|
+
import Stack from '../Stack';
|
|
7
|
+
export var RadioTileContext = /*#__PURE__*/React.createContext({});
|
|
8
|
+
var RadioTileGroup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
9
|
+
var _props$as = props.as,
|
|
10
|
+
Component = _props$as === void 0 ? Stack : _props$as,
|
|
11
|
+
className = props.className,
|
|
12
|
+
inline = props.inline,
|
|
13
|
+
children = props.children,
|
|
14
|
+
_props$classPrefix = props.classPrefix,
|
|
15
|
+
classPrefix = _props$classPrefix === void 0 ? 'radio-tile-group' : _props$classPrefix,
|
|
16
|
+
disabled = props.disabled,
|
|
17
|
+
valueProp = props.value,
|
|
18
|
+
defaultValue = props.defaultValue,
|
|
19
|
+
name = props.name,
|
|
20
|
+
onChange = props.onChange,
|
|
21
|
+
rest = _objectWithoutPropertiesLoose(props, ["as", "className", "inline", "children", "classPrefix", "disabled", "value", "defaultValue", "name", "onChange"]);
|
|
22
|
+
|
|
23
|
+
var _useClassNames = useClassNames(classPrefix),
|
|
24
|
+
merge = _useClassNames.merge,
|
|
25
|
+
withClassPrefix = _useClassNames.withClassPrefix;
|
|
26
|
+
|
|
27
|
+
var classes = merge(className, withClassPrefix());
|
|
28
|
+
|
|
29
|
+
var _useControlled = useControlled(valueProp, defaultValue),
|
|
30
|
+
value = _useControlled[0],
|
|
31
|
+
setValue = _useControlled[1];
|
|
32
|
+
|
|
33
|
+
var handleChange = useCallback(function (nextValue, event) {
|
|
34
|
+
setValue(nextValue);
|
|
35
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(nextValue, event);
|
|
36
|
+
}, [onChange, setValue]);
|
|
37
|
+
var contextValue = useMemo(function () {
|
|
38
|
+
return {
|
|
39
|
+
name: name,
|
|
40
|
+
disabled: disabled,
|
|
41
|
+
value: typeof value === 'undefined' ? null : value,
|
|
42
|
+
onChange: handleChange
|
|
43
|
+
};
|
|
44
|
+
}, [disabled, handleChange, name, value]);
|
|
45
|
+
return /*#__PURE__*/React.createElement(RadioTileContext.Provider, {
|
|
46
|
+
value: contextValue
|
|
47
|
+
}, /*#__PURE__*/React.createElement(Component, _extends({
|
|
48
|
+
alignItems: "stretch",
|
|
49
|
+
spacing: 10
|
|
50
|
+
}, rest, {
|
|
51
|
+
role: "radiogroup",
|
|
52
|
+
childrenRenderMode: "clone",
|
|
53
|
+
direction: inline ? 'row' : 'column',
|
|
54
|
+
ref: ref,
|
|
55
|
+
className: classes
|
|
56
|
+
}), children));
|
|
57
|
+
});
|
|
58
|
+
RadioTileGroup.displayName = 'RadioTileGroup';
|
|
59
|
+
RadioTileGroup.propTypes = {
|
|
60
|
+
name: PropTypes.string,
|
|
61
|
+
inline: PropTypes.bool,
|
|
62
|
+
value: PropTypes.any,
|
|
63
|
+
defaultValue: PropTypes.any,
|
|
64
|
+
className: PropTypes.string,
|
|
65
|
+
classPrefix: PropTypes.string,
|
|
66
|
+
children: PropTypes.node,
|
|
67
|
+
onChange: PropTypes.func
|
|
68
|
+
};
|
|
69
|
+
export default RadioTileGroup;
|
package/esm/index.d.ts
CHANGED
|
@@ -68,6 +68,10 @@ export { default as Radio } from './Radio';
|
|
|
68
68
|
export type { RadioProps } from './Radio';
|
|
69
69
|
export { default as RadioGroup } from './RadioGroup';
|
|
70
70
|
export type { RadioGroupProps } from './RadioGroup';
|
|
71
|
+
export { default as RadioTile } from './RadioTile';
|
|
72
|
+
export type { RadioTileProps } from './RadioTile';
|
|
73
|
+
export { default as RadioTileGroup } from './RadioTileGroup';
|
|
74
|
+
export type { RadioTileGroupProps } from './RadioTileGroup';
|
|
71
75
|
export { default as SelectPicker } from './SelectPicker';
|
|
72
76
|
export type { SelectPickerProps } from './SelectPicker';
|
|
73
77
|
export { default as CheckPicker } from './CheckPicker';
|
package/esm/index.js
CHANGED
|
@@ -36,6 +36,8 @@ export { default as Checkbox } from './Checkbox';
|
|
|
36
36
|
export { default as CheckboxGroup } from './CheckboxGroup';
|
|
37
37
|
export { default as Radio } from './Radio';
|
|
38
38
|
export { default as RadioGroup } from './RadioGroup';
|
|
39
|
+
export { default as RadioTile } from './RadioTile';
|
|
40
|
+
export { default as RadioTileGroup } from './RadioTileGroup';
|
|
39
41
|
export { default as SelectPicker } from './SelectPicker';
|
|
40
42
|
export { default as CheckPicker } from './CheckPicker';
|
|
41
43
|
export { default as InputPicker } from './InputPicker';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsuite",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.35.0",
|
|
4
4
|
"description": "A suite of react components",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"prop-types": "^15.8.1",
|
|
39
39
|
"react-use-set": "^1.0.0",
|
|
40
40
|
"react-window": "^1.8.8",
|
|
41
|
-
"rsuite-table": "^5.10.
|
|
41
|
+
"rsuite-table": "^5.10.6",
|
|
42
42
|
"schema-typed": "^2.1.3"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
@@ -247,6 +247,13 @@
|
|
|
247
247
|
--rs-radio-checked-bg: @H500-dark;
|
|
248
248
|
--rs-radio-disabled-bg: @B500-dark;
|
|
249
249
|
|
|
250
|
+
// RadioTile
|
|
251
|
+
--rs-radio-tile-border: @B300-dark;
|
|
252
|
+
--rs-radio-tile-bg: @B000-dark;
|
|
253
|
+
--rs-radio-tile-checked-color: @H500-dark;
|
|
254
|
+
--rs-radio-tile-checked-mark-color: @B800-dark;
|
|
255
|
+
--rs-radio-tile-checked-disabled-color: @H900-dark;
|
|
256
|
+
|
|
250
257
|
// Rate
|
|
251
258
|
--rs-rate-symbol: @B600-dark;
|
|
252
259
|
--rs-rate-symbol-checked: @yellow-500;
|
|
@@ -256,6 +256,13 @@
|
|
|
256
256
|
--rs-radio-checked-bg: @H500-high-contrast;
|
|
257
257
|
--rs-radio-disabled-bg: @B500-high-contrast;
|
|
258
258
|
|
|
259
|
+
// RadioTile
|
|
260
|
+
--rs-radio-tile-border: @B300-high-contrast;
|
|
261
|
+
--rs-radio-tile-bg: @B000-high-contrast;
|
|
262
|
+
--rs-radio-tile-checked-color: @H500-high-contrast;
|
|
263
|
+
--rs-radio-tile-checked-mark-color: @B800-high-contrast;
|
|
264
|
+
--rs-radio-tile-checked-disabled-color: @H900-high-contrast;
|
|
265
|
+
|
|
259
266
|
// Rate
|
|
260
267
|
--rs-rate-symbol: @B100-high-contrast;
|
|
261
268
|
--rs-rate-symbol-checked: @H500-high-contrast;
|
|
@@ -254,6 +254,14 @@
|
|
|
254
254
|
--rs-radio-checked-bg: @H500;
|
|
255
255
|
--rs-radio-disabled-bg: @B050;
|
|
256
256
|
|
|
257
|
+
// RadioTile
|
|
258
|
+
--rs-radio-tile-border: @B300;
|
|
259
|
+
--rs-radio-tile-bg: @B000;
|
|
260
|
+
--rs-radio-tile-checked-color: @H500;
|
|
261
|
+
--rs-radio-tile-checked-mark-color: #fff;
|
|
262
|
+
--rs-radio-tile-checked-disabled-color: @H100;
|
|
263
|
+
--rs-radio-tile-icon-size: 32px;
|
|
264
|
+
|
|
257
265
|
// Rate
|
|
258
266
|
--rs-rate-symbol: @B600;
|
|
259
267
|
--rs-rate-symbol-checked: @yellow-500;
|
package/styles/index.less
CHANGED
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
@import '../Progress/styles/index';
|
|
57
57
|
@import '../Radio/styles/index';
|
|
58
58
|
@import '../RadioGroup/styles/index';
|
|
59
|
+
@import '../RadioTile/styles/index';
|
|
59
60
|
@import '../Ripple/styles/index';
|
|
60
61
|
@import '../Row/styles/index';
|
|
61
62
|
@import '../SelectPicker/styles/index';
|