rsuite 4.9.2 → 4.9.3

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/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
- rest = _objectWithoutPropertiesLoose(_item$props, ["eventKey", "active"]);
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'
@@ -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) {
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
- rest = (0, _objectWithoutPropertiesLoose2.default)(_item$props, ["eventKey", "active"]);
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'
@@ -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.2",
3
+ "version": "4.9.3",
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.3",
66
+ "rsuite-table": "^3.14.4",
67
67
  "schema-typed": "^1.5.1"
68
68
  },
69
69
  "peerDependencies": {
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 { prefix, getUnhandledProps, defaultProps, ReactChildren } from '../utils';
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'
@@ -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>) => {