rsuite 5.4.4 → 5.5.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 +18 -0
- package/CheckTreePicker/styles/index.less +48 -47
- package/Picker/styles/mixin.less +3 -2
- package/Sidenav/styles/index.less +52 -57
- package/TreePicker/styles/index.less +3 -3
- package/cjs/Dropdown/Dropdown.d.ts +5 -0
- package/cjs/Dropdown/test/Dropdown.test.d.ts +1 -0
- package/cjs/Dropdown/test/Dropdown.test.js +30 -0
- package/cjs/InputNumber/InputNumber.d.ts +1 -1
- package/cjs/InputNumber/InputNumber.js +36 -6
- package/cjs/InputNumber/test/InputNumber.test.d.ts +1 -0
- package/cjs/InputNumber/test/InputNumber.test.js +14 -0
- package/cjs/MultiCascader/MultiCascader.js +1 -0
- package/cjs/RangeSlider/RangeSlider.d.ts +12 -2
- package/cjs/RangeSlider/RangeSlider.js +35 -12
- package/cjs/utils/treeUtils.js +4 -3
- package/dist/rsuite-rtl.css +91 -107
- package/dist/rsuite-rtl.min.css +1 -1
- package/dist/rsuite-rtl.min.css.map +1 -1
- package/dist/rsuite.css +91 -107
- package/dist/rsuite.js +6 -6
- 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/Dropdown/Dropdown.d.ts +5 -0
- package/esm/Dropdown/test/Dropdown.test.d.ts +1 -0
- package/esm/Dropdown/test/Dropdown.test.js +22 -0
- package/esm/InputNumber/InputNumber.d.ts +1 -1
- package/esm/InputNumber/InputNumber.js +38 -7
- package/esm/InputNumber/test/InputNumber.test.d.ts +1 -0
- package/esm/InputNumber/test/InputNumber.test.js +7 -0
- package/esm/MultiCascader/MultiCascader.js +1 -0
- package/esm/RangeSlider/RangeSlider.d.ts +12 -2
- package/esm/RangeSlider/RangeSlider.js +35 -12
- package/esm/utils/treeUtils.js +6 -3
- package/package.json +2 -2
|
@@ -3,6 +3,7 @@ import DropdownMenu from './DropdownMenu';
|
|
|
3
3
|
import { TypeAttributes, WithAsProps, RsRefForwardingComponent } from '../@types/common';
|
|
4
4
|
import { IconProps } from '@rsuite/icons/lib/Icon';
|
|
5
5
|
import DropdownItem from './DropdownItem';
|
|
6
|
+
import Button from '../Button';
|
|
6
7
|
export declare type DropdownTrigger = 'click' | 'hover' | 'contextMenu';
|
|
7
8
|
export interface DropdownProps<T = any> extends WithAsProps, Omit<React.HTMLAttributes<HTMLElement>, 'onSelect' | 'title'> {
|
|
8
9
|
/** Define the title as a submenu */
|
|
@@ -48,6 +49,10 @@ export interface DropdownProps<T = any> extends WithAsProps, Omit<React.HTMLAttr
|
|
|
48
49
|
onSelect?: (eventKey: T | undefined, event: React.SyntheticEvent) => void;
|
|
49
50
|
}
|
|
50
51
|
export interface DropdownComponent extends RsRefForwardingComponent<'div', DropdownProps> {
|
|
52
|
+
<ToggleAs extends React.ElementType = typeof Button>(props: DropdownProps & {
|
|
53
|
+
ref?: React.Ref<any>;
|
|
54
|
+
toggleAs?: ToggleAs;
|
|
55
|
+
} & React.ComponentProps<ToggleAs>, context: any): JSX.Element | null;
|
|
51
56
|
Item: typeof DropdownItem;
|
|
52
57
|
Menu: typeof DropdownMenu;
|
|
53
58
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Dropdown from '../Dropdown';
|
|
3
|
+
var ref = /*#__PURE__*/React.createRef(); // Infer `toggleAs` props (defaults to Button)
|
|
4
|
+
|
|
5
|
+
/*#__PURE__*/
|
|
6
|
+
React.createElement(Dropdown, {
|
|
7
|
+
ref: ref,
|
|
8
|
+
appearance: "subtle",
|
|
9
|
+
size: "sm"
|
|
10
|
+
});
|
|
11
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
12
|
+
|
|
13
|
+
var CustomToggle = function CustomToggle(_props) {
|
|
14
|
+
return null;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/*#__PURE__*/
|
|
18
|
+
React.createElement(Dropdown, {
|
|
19
|
+
ref: ref,
|
|
20
|
+
toggleAs: CustomToggle,
|
|
21
|
+
myProp: "myValue"
|
|
22
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { WithAsProps, TypeAttributes, FormControlBaseProps } from '../@types/common';
|
|
3
|
-
export interface InputNumberProps<T = number | string> extends WithAsProps, FormControlBaseProps<T> {
|
|
3
|
+
export interface InputNumberProps<T = number | string> extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultValue' | 'onChange' | 'size' | 'prefix'>, WithAsProps, FormControlBaseProps<T> {
|
|
4
4
|
/** Button can have different appearances */
|
|
5
5
|
buttonAppearance?: TypeAttributes.Appearance;
|
|
6
6
|
/** An input can show that it is disabled */
|
|
@@ -10,7 +10,7 @@ import InputGroup from '../InputGroup/InputGroup';
|
|
|
10
10
|
import InputGroupAddon from '../InputGroup/InputGroupAddon';
|
|
11
11
|
import Input from '../Input';
|
|
12
12
|
import Button from '../Button';
|
|
13
|
-
import { partitionHTMLProps, createChainedFunction, useClassNames, useControlled } from '../utils';
|
|
13
|
+
import { partitionHTMLProps, createChainedFunction, useClassNames, useControlled, KEY_VALUES } from '../utils';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Check if the value is a number.
|
|
@@ -93,16 +93,17 @@ var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
93
93
|
step = _props$step === void 0 ? 1 : _props$step,
|
|
94
94
|
_props$buttonAppearan = props.buttonAppearance,
|
|
95
95
|
buttonAppearance = _props$buttonAppearan === void 0 ? 'subtle' : _props$buttonAppearan,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
_props$max = props.max,
|
|
99
|
-
max = _props$max === void 0 ? Infinity : _props$max,
|
|
96
|
+
minProp = props.min,
|
|
97
|
+
maxProp = props.max,
|
|
100
98
|
_props$scrollable = props.scrollable,
|
|
101
99
|
scrollable = _props$scrollable === void 0 ? true : _props$scrollable,
|
|
102
100
|
onChange = props.onChange,
|
|
103
101
|
onWheel = props.onWheel,
|
|
104
102
|
restProps = _objectWithoutPropertiesLoose(props, ["as", "className", "classPrefix", "disabled", "readOnly", "plaintext", "value", "defaultValue", "size", "prefix", "postfix", "step", "buttonAppearance", "min", "max", "scrollable", "onChange", "onWheel"]);
|
|
105
103
|
|
|
104
|
+
var min = minProp !== null && minProp !== void 0 ? minProp : -Infinity;
|
|
105
|
+
var max = maxProp !== null && maxProp !== void 0 ? maxProp : Infinity;
|
|
106
|
+
|
|
106
107
|
var _useControlled = useControlled(valueProp, defaultValue),
|
|
107
108
|
value = _useControlled[0],
|
|
108
109
|
setValue = _useControlled[1];
|
|
@@ -166,6 +167,35 @@ var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
166
167
|
var bit = decimals(val, step);
|
|
167
168
|
handleChangeValue(getSafeValue((val - step).toFixed(bit)), event);
|
|
168
169
|
}, [getSafeValue, handleChangeValue, step, value]);
|
|
170
|
+
var handleKeyDown = useCallback(function (event) {
|
|
171
|
+
switch (event.key) {
|
|
172
|
+
case KEY_VALUES.UP:
|
|
173
|
+
event.preventDefault();
|
|
174
|
+
handlePlus(event);
|
|
175
|
+
break;
|
|
176
|
+
|
|
177
|
+
case KEY_VALUES.DOWN:
|
|
178
|
+
event.preventDefault();
|
|
179
|
+
handleMinus(event);
|
|
180
|
+
break;
|
|
181
|
+
|
|
182
|
+
case KEY_VALUES.HOME:
|
|
183
|
+
if (typeof minProp !== 'undefined') {
|
|
184
|
+
event.preventDefault();
|
|
185
|
+
handleChangeValue(getSafeValue(minProp), event);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
break;
|
|
189
|
+
|
|
190
|
+
case KEY_VALUES.END:
|
|
191
|
+
if (typeof maxProp !== 'undefined') {
|
|
192
|
+
event.preventDefault();
|
|
193
|
+
handleChangeValue(getSafeValue(maxProp), event);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
}, [handlePlus, handleMinus, minProp, maxProp, handleChangeValue, getSafeValue]);
|
|
169
199
|
var handleWheel = useCallback(function (event) {
|
|
170
200
|
if (!disabled && !readOnly && event.target === document.activeElement) {
|
|
171
201
|
event.preventDefault();
|
|
@@ -211,7 +241,7 @@ var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
211
241
|
};
|
|
212
242
|
}, [handleWheel, scrollable]);
|
|
213
243
|
var input = /*#__PURE__*/React.createElement(Input, _extends({}, htmlInputProps, {
|
|
214
|
-
type: "
|
|
244
|
+
type: "number",
|
|
215
245
|
autoComplete: "off",
|
|
216
246
|
step: step,
|
|
217
247
|
inputRef: inputRef,
|
|
@@ -221,7 +251,8 @@ var InputNumber = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
221
251
|
disabled: disabled,
|
|
222
252
|
readOnly: readOnly,
|
|
223
253
|
plaintext: plaintext,
|
|
224
|
-
ref: plaintext ? ref : undefined
|
|
254
|
+
ref: plaintext ? ref : undefined,
|
|
255
|
+
onKeyDown: handleKeyDown
|
|
225
256
|
}));
|
|
226
257
|
|
|
227
258
|
if (plaintext) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -459,6 +459,7 @@ var MultiCascader = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
459
459
|
var _usePickerClassName = usePickerClassName(_extends({}, props, {
|
|
460
460
|
classPrefix: classPrefix,
|
|
461
461
|
hasValue: hasValue,
|
|
462
|
+
countable: countable,
|
|
462
463
|
name: 'cascader',
|
|
463
464
|
appearance: appearance,
|
|
464
465
|
cleanable: cleanable
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SliderProps } from '../Slider';
|
|
3
3
|
export declare type Range = [number, number];
|
|
4
|
-
export declare type RangeSliderProps = SliderProps<Range
|
|
5
|
-
|
|
4
|
+
export declare type RangeSliderProps = SliderProps<Range> & {
|
|
5
|
+
/**
|
|
6
|
+
* Add constraint to validate before onChange is dispatched
|
|
7
|
+
*/
|
|
8
|
+
constraint?: (range: Range) => boolean;
|
|
9
|
+
};
|
|
10
|
+
declare const RangeSlider: React.ForwardRefExoticComponent<SliderProps<Range> & {
|
|
11
|
+
/**
|
|
12
|
+
* Add constraint to validate before onChange is dispatched
|
|
13
|
+
*/
|
|
14
|
+
constraint?: ((range: Range) => boolean) | undefined;
|
|
15
|
+
} & React.RefAttributes<unknown>>;
|
|
6
16
|
export default RangeSlider;
|
|
@@ -21,6 +21,7 @@ var RangeSlider = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
21
21
|
Component = _props$as === void 0 ? 'div' : _props$as,
|
|
22
22
|
barClassName = props.barClassName,
|
|
23
23
|
className = props.className,
|
|
24
|
+
constraint = props.constraint,
|
|
24
25
|
_props$defaultValue = props.defaultValue,
|
|
25
26
|
defaultValue = _props$defaultValue === void 0 ? defaultDefaultValue : _props$defaultValue,
|
|
26
27
|
graduated = props.graduated,
|
|
@@ -47,7 +48,7 @@ var RangeSlider = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
47
48
|
renderMark = props.renderMark,
|
|
48
49
|
onChange = props.onChange,
|
|
49
50
|
onChangeCommitted = props.onChangeCommitted,
|
|
50
|
-
rest = _objectWithoutPropertiesLoose(props, ["aria-label", "aria-labelledby", "aria-valuetext", "as", "barClassName", "className", "defaultValue", "graduated", "progress", "vertical", "disabled", "classPrefix", "min", "max", "step", "value", "handleClassName", "handleStyle", "handleTitle", "tooltip", "getAriaValueText", "renderTooltip", "renderMark", "onChange", "onChangeCommitted"]);
|
|
51
|
+
rest = _objectWithoutPropertiesLoose(props, ["aria-label", "aria-labelledby", "aria-valuetext", "as", "barClassName", "className", "constraint", "defaultValue", "graduated", "progress", "vertical", "disabled", "classPrefix", "min", "max", "step", "value", "handleClassName", "handleStyle", "handleTitle", "tooltip", "getAriaValueText", "renderTooltip", "renderMark", "onChange", "onChangeCommitted"]);
|
|
51
52
|
|
|
52
53
|
var barRef = useRef(null); // Define the parameter position of the handle
|
|
53
54
|
|
|
@@ -157,14 +158,27 @@ var RangeSlider = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
157
158
|
|
|
158
159
|
return nextValue;
|
|
159
160
|
}, [getRangeValue, getValidValue]);
|
|
161
|
+
/**
|
|
162
|
+
* Whether a range is valid against given constraint (if any)
|
|
163
|
+
* Should check before every `setValue` calls
|
|
164
|
+
*/
|
|
165
|
+
|
|
166
|
+
var isRangeMatchingConstraint = useCallback(function (range) {
|
|
167
|
+
// If no constraint is defined, any range is valid
|
|
168
|
+
if (!constraint) return true;
|
|
169
|
+
return constraint(range);
|
|
170
|
+
}, [constraint]);
|
|
160
171
|
/**
|
|
161
172
|
* Callback function that is fired when the mousemove is triggered
|
|
162
173
|
*/
|
|
163
174
|
|
|
164
175
|
var handleDragMove = useEventCallback(function (event, dataset) {
|
|
165
176
|
var nextValue = getNextValue(event, dataset);
|
|
166
|
-
|
|
167
|
-
|
|
177
|
+
|
|
178
|
+
if (isRangeMatchingConstraint(nextValue)) {
|
|
179
|
+
setValue(nextValue);
|
|
180
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(nextValue, event);
|
|
181
|
+
}
|
|
168
182
|
});
|
|
169
183
|
/**
|
|
170
184
|
* Callback function that is fired when the mouseup is triggered
|
|
@@ -172,9 +186,12 @@ var RangeSlider = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
172
186
|
|
|
173
187
|
var handleChangeCommitted = useCallback(function (event, dataset) {
|
|
174
188
|
var nextValue = getNextValue(event, dataset);
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
189
|
+
|
|
190
|
+
if (isRangeMatchingConstraint(nextValue)) {
|
|
191
|
+
setValue(nextValue);
|
|
192
|
+
onChangeCommitted === null || onChangeCommitted === void 0 ? void 0 : onChangeCommitted(nextValue, event);
|
|
193
|
+
}
|
|
194
|
+
}, [getNextValue, onChangeCommitted, isRangeMatchingConstraint, setValue]);
|
|
178
195
|
var handleKeyDown = useCallback(function (event) {
|
|
179
196
|
var _event$target;
|
|
180
197
|
|
|
@@ -217,9 +234,12 @@ var RangeSlider = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
217
234
|
|
|
218
235
|
|
|
219
236
|
event.preventDefault();
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
237
|
+
|
|
238
|
+
if (isRangeMatchingConstraint(nextValue)) {
|
|
239
|
+
setValue(nextValue);
|
|
240
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(nextValue, event);
|
|
241
|
+
}
|
|
242
|
+
}, [max, min, onChange, rtl, isRangeMatchingConstraint, setValue, step, value]);
|
|
223
243
|
var handleClick = useCallback(function (event) {
|
|
224
244
|
if (disabled) {
|
|
225
245
|
return;
|
|
@@ -236,9 +256,12 @@ var RangeSlider = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
236
256
|
}
|
|
237
257
|
|
|
238
258
|
var nextValue = getValidValue([start, end].sort());
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
259
|
+
|
|
260
|
+
if (isRangeMatchingConstraint(nextValue)) {
|
|
261
|
+
setValue(nextValue);
|
|
262
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(nextValue, event);
|
|
263
|
+
}
|
|
264
|
+
}, [disabled, getValidValue, getValueByPosition, isRangeMatchingConstraint, onChange, setValue, value]);
|
|
242
265
|
var handleProps = useMemo(function () {
|
|
243
266
|
return [{
|
|
244
267
|
value: value[0],
|
package/esm/utils/treeUtils.js
CHANGED
|
@@ -258,6 +258,9 @@ export function createUpdateTreeDataFunction(params, _ref2) {
|
|
|
258
258
|
var dragNode = params.dragNode,
|
|
259
259
|
dropNode = params.dropNode,
|
|
260
260
|
dropNodePosition = params.dropNodePosition;
|
|
261
|
+
|
|
262
|
+
var cloneDragNode = _extends({}, dragNode);
|
|
263
|
+
|
|
261
264
|
removeDragNode(data, params, {
|
|
262
265
|
valueKey: valueKey,
|
|
263
266
|
childrenKey: childrenKey
|
|
@@ -272,16 +275,16 @@ export function createUpdateTreeDataFunction(params, _ref2) {
|
|
|
272
275
|
if (dropNodePosition === TREE_NODE_DROP_POSITION.DRAG_OVER) {
|
|
273
276
|
_item2[childrenKey] = _isNil(_item2[childrenKey]) ? [] : _item2[childrenKey];
|
|
274
277
|
|
|
275
|
-
_item2[childrenKey].push(
|
|
278
|
+
_item2[childrenKey].push(cloneDragNode);
|
|
276
279
|
|
|
277
280
|
break;
|
|
278
281
|
} else if (dropNodePosition === TREE_NODE_DROP_POSITION.DRAG_OVER_TOP) {
|
|
279
282
|
// drag to top of node
|
|
280
|
-
items.splice(_index2, 0,
|
|
283
|
+
items.splice(_index2, 0, cloneDragNode);
|
|
281
284
|
break;
|
|
282
285
|
} else if (dropNodePosition === TREE_NODE_DROP_POSITION.DRAG_OVER_BOTTOM) {
|
|
283
286
|
// drag to bottom of node
|
|
284
|
-
items.splice(_index2 + 1, 0,
|
|
287
|
+
items.splice(_index2 + 1, 0, cloneDragNode);
|
|
285
288
|
break;
|
|
286
289
|
}
|
|
287
290
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsuite",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.5.0",
|
|
4
4
|
"description": "A suite of react components",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"lodash": "^4.17.11",
|
|
38
38
|
"prop-types": "^15.7.2",
|
|
39
39
|
"react-virtualized": "^9.22.3",
|
|
40
|
-
"rsuite-table": "^5.3.
|
|
40
|
+
"rsuite-table": "^5.3.2",
|
|
41
41
|
"schema-typed": "^2.0.2"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|