rsuite 4.9.0 → 4.9.4
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 +37 -11
- package/dist/rsuite.js +1563 -294
- package/dist/rsuite.min.js +2 -2
- package/dist/rsuite.min.js.map +1 -1
- package/es/InputPicker/InputPicker.js +1 -11
- package/es/Nav/Nav.js +5 -4
- package/es/Uploader/Uploader.js +2 -0
- package/lib/InputPicker/InputPicker.js +1 -11
- package/lib/Nav/Nav.js +4 -3
- package/lib/Uploader/Uploader.js +2 -0
- package/package.json +2 -2
- package/src/InputPicker/InputPicker.tsx +1 -6
- package/src/Nav/Nav.tsx +10 -4
- package/src/Nav/test/NavSpec.js +35 -0
- package/src/Uploader/Uploader.tsx +1 -0
- package/src/Whisper/test/WhisperSpec.js +15 -4
|
@@ -403,16 +403,6 @@ function (_React$Component) {
|
|
|
403
403
|
(_this$triggerRef$curr5 = _this.triggerRef.current) === null || _this$triggerRef$curr5 === void 0 ? void 0 : _this$triggerRef$curr5.show();
|
|
404
404
|
};
|
|
405
405
|
|
|
406
|
-
_this.handleInputBlur = function () {
|
|
407
|
-
var _this$triggerRef$curr6;
|
|
408
|
-
|
|
409
|
-
_this.setState({
|
|
410
|
-
open: false
|
|
411
|
-
});
|
|
412
|
-
|
|
413
|
-
(_this$triggerRef$curr6 = _this.triggerRef.current) === null || _this$triggerRef$curr6 === void 0 ? void 0 : _this$triggerRef$curr6.hide();
|
|
414
|
-
};
|
|
415
|
-
|
|
416
406
|
_this.removeLastItem = function (event) {
|
|
417
407
|
var tagName = _get(event, 'target.tagName');
|
|
418
408
|
|
|
@@ -794,7 +784,7 @@ function (_React$Component) {
|
|
|
794
784
|
tabIndex: tabIndex,
|
|
795
785
|
onChange: this.handleSearch,
|
|
796
786
|
value: this.state.open ? this.state.searchKeyword : '',
|
|
797
|
-
onBlur:
|
|
787
|
+
onBlur: onBlur,
|
|
798
788
|
onFocus: createChainedFunction(this.handleInputFocus, onFocus)
|
|
799
789
|
}));
|
|
800
790
|
};
|
package/es/Nav/Nav.js
CHANGED
|
@@ -7,7 +7,7 @@ import classNames from 'classnames';
|
|
|
7
7
|
import { setStatic } from 'recompose';
|
|
8
8
|
import shallowEqual from '../utils/shallowEqual';
|
|
9
9
|
import NavItem from './NavItem';
|
|
10
|
-
import { prefix, getUnhandledProps, defaultProps, ReactChildren } from '../utils';
|
|
10
|
+
import { prefix, getUnhandledProps, defaultProps, ReactChildren, createChainedFunction } from '../utils';
|
|
11
11
|
import { getClassNamePrefix } from '../utils/prefix';
|
|
12
12
|
import { NavbarContext } from '../Navbar/Navbar';
|
|
13
13
|
import { SidenavContext } from '../Sidenav/Sidenav';
|
|
@@ -54,20 +54,21 @@ function (_React$Component) {
|
|
|
54
54
|
var _item$props = item.props,
|
|
55
55
|
eventKey = _item$props.eventKey,
|
|
56
56
|
active = _item$props.active,
|
|
57
|
-
|
|
57
|
+
onSelectItem = _item$props.onSelect,
|
|
58
|
+
rest = _objectWithoutPropertiesLoose(_item$props, ["eventKey", "active", "onSelect"]);
|
|
58
59
|
|
|
59
60
|
var displayName = item === null || item === void 0 ? void 0 : (_item$type = item.type) === null || _item$type === void 0 ? void 0 : _item$type.displayName;
|
|
60
61
|
var hasTooltip = sidenav && !expanded;
|
|
61
62
|
|
|
62
63
|
if (~(displayName === null || displayName === void 0 ? void 0 : displayName.indexOf('(NavItem)'))) {
|
|
63
64
|
return _extends({}, rest, {
|
|
64
|
-
onSelect: onSelect,
|
|
65
|
+
onSelect: createChainedFunction(onSelect, onSelectItem),
|
|
65
66
|
hasTooltip: hasTooltip,
|
|
66
67
|
active: typeof activeKey === 'undefined' ? active : shallowEqual(activeKey, eventKey)
|
|
67
68
|
});
|
|
68
69
|
} else if (~(displayName === null || displayName === void 0 ? void 0 : displayName.indexOf('(Dropdown)'))) {
|
|
69
70
|
return _extends({}, rest, {
|
|
70
|
-
onSelect: onSelect,
|
|
71
|
+
onSelect: createChainedFunction(onSelect, onSelectItem),
|
|
71
72
|
activeKey: activeKey,
|
|
72
73
|
showHeader: hasTooltip,
|
|
73
74
|
componentClass: 'li'
|
package/es/Uploader/Uploader.js
CHANGED
|
@@ -48,6 +48,8 @@ function (_React$Component) {
|
|
|
48
48
|
|
|
49
49
|
(_this$props$onRemove = (_this$props = _this.props).onRemove) === null || _this$props$onRemove === void 0 ? void 0 : _this$props$onRemove.call(_this$props, file);
|
|
50
50
|
(_this$props$onChange = (_this$props2 = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props2, nextFileList);
|
|
51
|
+
|
|
52
|
+
_this.cleanInputValue();
|
|
51
53
|
};
|
|
52
54
|
|
|
53
55
|
_this.handleUploadTriggerChange = function (event) {
|
|
@@ -436,16 +436,6 @@ function (_React$Component) {
|
|
|
436
436
|
(_this$triggerRef$curr5 = _this.triggerRef.current) === null || _this$triggerRef$curr5 === void 0 ? void 0 : _this$triggerRef$curr5.show();
|
|
437
437
|
};
|
|
438
438
|
|
|
439
|
-
_this.handleInputBlur = function () {
|
|
440
|
-
var _this$triggerRef$curr6;
|
|
441
|
-
|
|
442
|
-
_this.setState({
|
|
443
|
-
open: false
|
|
444
|
-
});
|
|
445
|
-
|
|
446
|
-
(_this$triggerRef$curr6 = _this.triggerRef.current) === null || _this$triggerRef$curr6 === void 0 ? void 0 : _this$triggerRef$curr6.hide();
|
|
447
|
-
};
|
|
448
|
-
|
|
449
439
|
_this.removeLastItem = function (event) {
|
|
450
440
|
var tagName = (0, _get2.default)(event, 'target.tagName');
|
|
451
441
|
|
|
@@ -825,7 +815,7 @@ function (_React$Component) {
|
|
|
825
815
|
tabIndex: tabIndex,
|
|
826
816
|
onChange: this.handleSearch,
|
|
827
817
|
value: this.state.open ? this.state.searchKeyword : '',
|
|
828
|
-
onBlur:
|
|
818
|
+
onBlur: onBlur,
|
|
829
819
|
onFocus: (0, _utils.createChainedFunction)(this.handleInputFocus, onFocus)
|
|
830
820
|
}));
|
|
831
821
|
};
|
package/lib/Nav/Nav.js
CHANGED
|
@@ -76,19 +76,20 @@ function (_React$Component) {
|
|
|
76
76
|
var _item$props = item.props,
|
|
77
77
|
eventKey = _item$props.eventKey,
|
|
78
78
|
active = _item$props.active,
|
|
79
|
-
|
|
79
|
+
onSelectItem = _item$props.onSelect,
|
|
80
|
+
rest = (0, _objectWithoutPropertiesLoose2.default)(_item$props, ["eventKey", "active", "onSelect"]);
|
|
80
81
|
var displayName = item === null || item === void 0 ? void 0 : (_item$type = item.type) === null || _item$type === void 0 ? void 0 : _item$type.displayName;
|
|
81
82
|
var hasTooltip = sidenav && !expanded;
|
|
82
83
|
|
|
83
84
|
if (~(displayName === null || displayName === void 0 ? void 0 : displayName.indexOf('(NavItem)'))) {
|
|
84
85
|
return (0, _extends2.default)({}, rest, {
|
|
85
|
-
onSelect: onSelect,
|
|
86
|
+
onSelect: (0, _utils.createChainedFunction)(onSelect, onSelectItem),
|
|
86
87
|
hasTooltip: hasTooltip,
|
|
87
88
|
active: typeof activeKey === 'undefined' ? active : (0, _shallowEqual.default)(activeKey, eventKey)
|
|
88
89
|
});
|
|
89
90
|
} else if (~(displayName === null || displayName === void 0 ? void 0 : displayName.indexOf('(Dropdown)'))) {
|
|
90
91
|
return (0, _extends2.default)({}, rest, {
|
|
91
|
-
onSelect: onSelect,
|
|
92
|
+
onSelect: (0, _utils.createChainedFunction)(onSelect, onSelectItem),
|
|
92
93
|
activeKey: activeKey,
|
|
93
94
|
showHeader: hasTooltip,
|
|
94
95
|
componentClass: 'li'
|
package/lib/Uploader/Uploader.js
CHANGED
|
@@ -70,6 +70,8 @@ function (_React$Component) {
|
|
|
70
70
|
|
|
71
71
|
(_this$props$onRemove = (_this$props = _this.props).onRemove) === null || _this$props$onRemove === void 0 ? void 0 : _this$props$onRemove.call(_this$props, file);
|
|
72
72
|
(_this$props$onChange = (_this$props2 = _this.props).onChange) === null || _this$props$onChange === void 0 ? void 0 : _this$props$onChange.call(_this$props2, nextFileList);
|
|
73
|
+
|
|
74
|
+
_this.cleanInputValue();
|
|
73
75
|
};
|
|
74
76
|
|
|
75
77
|
_this.handleUploadTriggerChange = function (event) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsuite",
|
|
3
|
-
"version": "4.9.
|
|
3
|
+
"version": "4.9.4",
|
|
4
4
|
"description": "A suite of react components",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"react-lifecycles-compat": "^3.0.4",
|
|
64
64
|
"react-virtualized": "^9.21.0",
|
|
65
65
|
"recompose": "^0.30.0",
|
|
66
|
-
"rsuite-table": "^3.14.
|
|
66
|
+
"rsuite-table": "^3.14.6",
|
|
67
67
|
"schema-typed": "^1.5.1"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
@@ -502,11 +502,6 @@ class InputPicker extends React.Component<InputPickerProps, InputPickerState> {
|
|
|
502
502
|
this.triggerRef.current?.show();
|
|
503
503
|
};
|
|
504
504
|
|
|
505
|
-
handleInputBlur = () => {
|
|
506
|
-
this.setState({ open: false });
|
|
507
|
-
this.triggerRef.current?.hide();
|
|
508
|
-
};
|
|
509
|
-
|
|
510
505
|
removeLastItem = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
511
506
|
const tagName = _.get(event, 'target.tagName');
|
|
512
507
|
if (tagName !== 'INPUT') {
|
|
@@ -684,7 +679,7 @@ class InputPicker extends React.Component<InputPickerProps, InputPickerState> {
|
|
|
684
679
|
tabIndex={tabIndex}
|
|
685
680
|
onChange={this.handleSearch}
|
|
686
681
|
value={this.state.open ? this.state.searchKeyword : ''}
|
|
687
|
-
onBlur={
|
|
682
|
+
onBlur={onBlur}
|
|
688
683
|
onFocus={createChainedFunction(this.handleInputFocus, onFocus)}
|
|
689
684
|
/>
|
|
690
685
|
);
|
package/src/Nav/Nav.tsx
CHANGED
|
@@ -5,7 +5,13 @@ import { setStatic } from 'recompose';
|
|
|
5
5
|
import shallowEqual from '../utils/shallowEqual';
|
|
6
6
|
|
|
7
7
|
import NavItem from './NavItem';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
prefix,
|
|
10
|
+
getUnhandledProps,
|
|
11
|
+
defaultProps,
|
|
12
|
+
ReactChildren,
|
|
13
|
+
createChainedFunction
|
|
14
|
+
} from '../utils';
|
|
9
15
|
import { getClassNamePrefix } from '../utils/prefix';
|
|
10
16
|
import { NavbarContext } from '../Navbar/Navbar';
|
|
11
17
|
import { SidenavContext } from '../Sidenav/Sidenav';
|
|
@@ -56,21 +62,21 @@ class Nav extends React.Component<NavProps> {
|
|
|
56
62
|
const hasWaterline = appearance !== 'default';
|
|
57
63
|
|
|
58
64
|
const items = ReactChildren.mapCloneElement(children, item => {
|
|
59
|
-
const { eventKey, active, ...rest } = item.props;
|
|
65
|
+
const { eventKey, active, onSelect: onSelectItem, ...rest } = item.props;
|
|
60
66
|
const displayName = item?.type?.displayName;
|
|
61
67
|
const hasTooltip = sidenav && !expanded;
|
|
62
68
|
|
|
63
69
|
if (~displayName?.indexOf('(NavItem)')) {
|
|
64
70
|
return {
|
|
65
71
|
...rest,
|
|
66
|
-
onSelect,
|
|
72
|
+
onSelect: createChainedFunction(onSelect, onSelectItem),
|
|
67
73
|
hasTooltip,
|
|
68
74
|
active: typeof activeKey === 'undefined' ? active : shallowEqual(activeKey, eventKey)
|
|
69
75
|
};
|
|
70
76
|
} else if (~displayName?.indexOf('(Dropdown)')) {
|
|
71
77
|
return {
|
|
72
78
|
...rest,
|
|
73
|
-
onSelect,
|
|
79
|
+
onSelect: createChainedFunction(onSelect, onSelectItem),
|
|
74
80
|
activeKey,
|
|
75
81
|
showHeader: hasTooltip,
|
|
76
82
|
componentClass: 'li'
|
package/src/Nav/test/NavSpec.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import ReactTestUtils from 'react-dom/test-utils';
|
|
2
3
|
import { innerText, getDOMNode } from '@test/testUtils';
|
|
3
4
|
|
|
4
5
|
import Nav from '../Nav';
|
|
@@ -68,4 +69,38 @@ describe('Nav', () => {
|
|
|
68
69
|
const instance = getDOMNode(<Nav classPrefix="custom-prefix" />);
|
|
69
70
|
assert.ok(instance.className.match(/\bcustom-prefix\b/));
|
|
70
71
|
});
|
|
72
|
+
|
|
73
|
+
it('Should call onSelect callback', done => {
|
|
74
|
+
const doneOp = eventKey => {
|
|
75
|
+
if (eventKey === 2) {
|
|
76
|
+
done();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const instance = getDOMNode(
|
|
80
|
+
<Nav onSelect={doneOp}>
|
|
81
|
+
<Nav.Item eventKey={1}>1</Nav.Item>
|
|
82
|
+
<Nav.Item eventKey={2}>2</Nav.Item>
|
|
83
|
+
</Nav>
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
ReactTestUtils.Simulate.click(instance.querySelectorAll('.rs-nav-item a')[1]);
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('Should call onSelect callback on Nav.Item', done => {
|
|
90
|
+
const doneOp = eventKey => {
|
|
91
|
+
if (eventKey === 2) {
|
|
92
|
+
done();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const instance = getDOMNode(
|
|
96
|
+
<Nav>
|
|
97
|
+
<Nav.Item eventKey={1}>1</Nav.Item>
|
|
98
|
+
<Nav.Item eventKey={2} onSelect={doneOp}>
|
|
99
|
+
2
|
|
100
|
+
</Nav.Item>
|
|
101
|
+
</Nav>
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
ReactTestUtils.Simulate.click(instance.querySelectorAll('.rs-nav-item a')[1]);
|
|
105
|
+
});
|
|
71
106
|
});
|
|
@@ -132,6 +132,7 @@ class Uploader extends React.Component<UploaderProps, UploaderState> {
|
|
|
132
132
|
|
|
133
133
|
this.props.onRemove?.(file);
|
|
134
134
|
this.props.onChange?.(nextFileList);
|
|
135
|
+
this.cleanInputValue();
|
|
135
136
|
};
|
|
136
137
|
|
|
137
138
|
handleUploadTriggerChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
@@ -172,12 +172,14 @@ describe('Whisper', () => {
|
|
|
172
172
|
const doneOp = () => {
|
|
173
173
|
done();
|
|
174
174
|
};
|
|
175
|
-
const triggerRef = React.createRef();
|
|
176
175
|
const btnRef = React.createRef();
|
|
176
|
+
const closeBtnRef = React.createRef();
|
|
177
177
|
const Overlay = React.forwardRef(({ style, onClose, ...rest }, ref) => {
|
|
178
178
|
return (
|
|
179
179
|
<div {...rest} style={style} ref={ref}>
|
|
180
|
-
<button onClick={onClose}>
|
|
180
|
+
<button ref={closeBtnRef} onClick={onClose}>
|
|
181
|
+
close
|
|
182
|
+
</button>
|
|
181
183
|
</div>
|
|
182
184
|
);
|
|
183
185
|
});
|
|
@@ -186,7 +188,16 @@ describe('Whisper', () => {
|
|
|
186
188
|
|
|
187
189
|
ReactTestUtils.act(() => {
|
|
188
190
|
ReactDOM.render(
|
|
189
|
-
<Whisper
|
|
191
|
+
<Whisper
|
|
192
|
+
onExited={doneOp}
|
|
193
|
+
trigger="click"
|
|
194
|
+
speaker={(props, ref) => {
|
|
195
|
+
const { className, left, top, onClose } = props;
|
|
196
|
+
return (
|
|
197
|
+
<Overlay style={{ left, top }} onClose={onClose} className={className} ref={ref} />
|
|
198
|
+
);
|
|
199
|
+
}}
|
|
200
|
+
>
|
|
190
201
|
<button ref={btnRef}>button</button>
|
|
191
202
|
</Whisper>,
|
|
192
203
|
createTestContainer()
|
|
@@ -197,7 +208,7 @@ describe('Whisper', () => {
|
|
|
197
208
|
});
|
|
198
209
|
|
|
199
210
|
ReactTestUtils.act(() => {
|
|
200
|
-
ReactTestUtils.Simulate.click(
|
|
211
|
+
ReactTestUtils.Simulate.click(closeBtnRef.current);
|
|
201
212
|
});
|
|
202
213
|
});
|
|
203
214
|
});
|