rsuite 4.10.2 → 4.10.6
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 +45 -0
- package/dist/rsuite.js +75 -158
- package/dist/rsuite.min.js +10 -2
- package/dist/rsuite.min.js.map +1 -1
- package/es/AutoComplete/AutoComplete.js +1 -1
- package/es/Avatar/Avatar.js +1 -2
- package/es/Breadcrumb/Breadcrumb.js +1 -2
- package/es/Button/Button.js +1 -2
- package/es/ButtonGroup/ButtonGroup.js +1 -2
- package/es/Calendar/TimeDropdown.js +3 -3
- package/es/Cascader/Cascader.js +23 -6
- package/es/Drawer/index.js +1 -2
- package/es/Dropdown/Dropdown.js +1 -2
- package/es/FlexboxGrid/FlexboxGrid.js +1 -2
- package/es/FormGroup/FormGroup.js +1 -2
- package/es/Input/Input.js +1 -2
- package/es/InputGroup/InputGroup.js +1 -2
- package/es/IntlProvider/withLocale.js +1 -1
- package/es/List/List.js +1 -2
- package/es/List/ListItem.js +1 -2
- package/es/Loader/Loader.js +1 -2
- package/es/Modal/BaseModal.js +24 -4
- package/es/Modal/Modal.js +1 -2
- package/es/Modal/ModalDialog.js +2 -2
- package/es/MultiCascader/MultiCascader.js +14 -1
- package/es/Nav/Nav.js +1 -2
- package/es/Navbar/Navbar.js +1 -2
- package/es/Pagination/Pagination.js +1 -2
- package/es/Rate/Rate.js +1 -2
- package/es/Sidenav/Sidenav.js +1 -2
- package/es/Slider/Slider.d.ts +4 -11
- package/es/Steps/Steps.js +1 -2
- package/es/Table/Table.js +1 -2
- package/es/Table/TablePagination.js +1 -2
- package/es/Tag/Tag.js +1 -2
- package/es/TagPicker/index.js +1 -2
- package/es/Timeline/Timeline.js +1 -2
- package/es/Timeline/TimelineItem.js +1 -2
- package/es/Toggle/Toggle.js +1 -2
- package/es/Uploader/Uploader.js +2 -3
- package/es/utils/defaultProps.js +1 -1
- package/es/utils/index.js +1 -0
- package/es/utils/recompose.js +42 -0
- package/es/utils/withStyleProps.js +1 -1
- package/lib/AutoComplete/AutoComplete.js +2 -4
- package/lib/Avatar/Avatar.js +1 -3
- package/lib/Breadcrumb/Breadcrumb.js +1 -3
- package/lib/Button/Button.js +1 -3
- package/lib/ButtonGroup/ButtonGroup.js +1 -3
- package/lib/Calendar/TimeDropdown.js +3 -3
- package/lib/Cascader/Cascader.js +23 -6
- package/lib/Drawer/index.js +4 -6
- package/lib/Dropdown/Dropdown.js +2 -4
- package/lib/FlexboxGrid/FlexboxGrid.js +1 -3
- package/lib/FormGroup/FormGroup.js +1 -3
- package/lib/Input/Input.js +1 -3
- package/lib/InputGroup/InputGroup.js +3 -5
- package/lib/IntlProvider/withLocale.js +3 -3
- package/lib/List/List.js +1 -3
- package/lib/List/ListItem.js +1 -3
- package/lib/Loader/Loader.js +1 -3
- package/lib/Modal/BaseModal.js +24 -4
- package/lib/Modal/Modal.js +5 -7
- package/lib/Modal/ModalDialog.js +2 -3
- package/lib/MultiCascader/MultiCascader.js +14 -1
- package/lib/Nav/Nav.js +1 -3
- package/lib/Navbar/Navbar.js +2 -4
- package/lib/Pagination/Pagination.js +1 -3
- package/lib/Rate/Rate.js +1 -3
- package/lib/Sidenav/Sidenav.js +3 -5
- package/lib/Slider/Slider.d.ts +4 -11
- package/lib/Steps/Steps.js +1 -3
- package/lib/Table/Table.js +6 -8
- package/lib/Table/TablePagination.js +1 -3
- package/lib/Tag/Tag.js +1 -3
- package/lib/TagPicker/index.js +1 -3
- package/lib/Timeline/Timeline.js +1 -3
- package/lib/Timeline/TimelineItem.js +1 -3
- package/lib/Toggle/Toggle.js +1 -3
- package/lib/Uploader/Uploader.js +2 -4
- package/lib/utils/defaultProps.js +1 -1
- package/lib/utils/index.js +8 -0
- package/lib/utils/recompose.js +57 -0
- package/lib/utils/withStyleProps.js +1 -1
- package/package.json +5 -6
- package/src/AutoComplete/AutoComplete.tsx +1 -1
- package/src/Avatar/Avatar.tsx +1 -2
- package/src/Breadcrumb/Breadcrumb.tsx +1 -2
- package/src/Button/Button.tsx +8 -2
- package/src/ButtonGroup/ButtonGroup.tsx +1 -2
- package/src/Calendar/TimeDropdown.tsx +2 -3
- package/src/Cascader/Cascader.tsx +24 -5
- package/src/Cascader/test/CascaderSpec.js +56 -1
- package/src/DatePicker/test/DatePickerSpec.js +20 -0
- package/src/Drawer/index.tsx +1 -3
- package/src/Dropdown/Dropdown.tsx +1 -1
- package/src/FlexboxGrid/FlexboxGrid.tsx +1 -2
- package/src/FormGroup/FormGroup.tsx +1 -2
- package/src/Input/Input.tsx +1 -1
- package/src/InputGroup/InputGroup.tsx +1 -2
- package/src/IntlProvider/withLocale.tsx +1 -1
- package/src/List/List.tsx +1 -2
- package/src/List/ListItem.tsx +1 -2
- package/src/Loader/Loader.tsx +1 -2
- package/src/Modal/BaseModal.tsx +26 -4
- package/src/Modal/Modal.tsx +1 -2
- package/src/Modal/ModalDialog.tsx +2 -2
- package/src/Modal/test/ModalSpec.js +5 -0
- package/src/MultiCascader/MultiCascader.tsx +17 -1
- package/src/Nav/Nav.tsx +1 -1
- package/src/Navbar/Navbar.tsx +1 -2
- package/src/Pagination/Pagination.tsx +1 -2
- package/src/Rate/Rate.tsx +1 -2
- package/src/Sidenav/Sidenav.tsx +1 -2
- package/src/Slider/Slider.d.ts +4 -11
- package/src/Steps/Steps.tsx +1 -2
- package/src/Table/Table.tsx +1 -2
- package/src/Table/TablePagination.tsx +1 -2
- package/src/Tag/Tag.tsx +1 -2
- package/src/TagPicker/index.tsx +1 -3
- package/src/Timeline/Timeline.tsx +1 -2
- package/src/Timeline/TimelineItem.tsx +1 -2
- package/src/Toggle/Toggle.tsx +1 -2
- package/src/Uploader/Uploader.tsx +2 -3
- package/src/utils/defaultProps.ts +1 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/recompose.ts +52 -0
- package/src/utils/test/recomposeSpec.js +107 -0
- package/src/utils/withStyleProps.tsx +1 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import { compose } from 'recompose';
|
|
5
4
|
|
|
6
|
-
import { prefix, defaultProps, withStyleProps } from '../utils';
|
|
5
|
+
import { compose, prefix, defaultProps, withStyleProps } from '../utils';
|
|
7
6
|
import { TimelineItemProps } from './TimelineItem.d';
|
|
8
7
|
|
|
9
8
|
class TimelineItem extends React.Component<TimelineItemProps> {
|
package/src/Toggle/Toggle.tsx
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import { compose } from 'recompose';
|
|
5
4
|
|
|
6
|
-
import { prefix, withStyleProps, defaultProps, getUnhandledProps } from '../utils';
|
|
5
|
+
import { compose, prefix, withStyleProps, defaultProps, getUnhandledProps } from '../utils';
|
|
7
6
|
import { ToggleProps } from './Toggle.d';
|
|
8
7
|
|
|
9
8
|
interface ToggleState {
|
|
@@ -2,13 +2,12 @@ import * as React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import _ from 'lodash';
|
|
5
|
-
import { compose } from 'recompose';
|
|
6
5
|
|
|
7
6
|
import IntlContext from '../IntlProvider/IntlContext';
|
|
8
7
|
import withLocale from '../IntlProvider/withLocale';
|
|
9
8
|
import FileItem from './UploadFileItem';
|
|
10
9
|
import UploadTrigger from './UploadTrigger';
|
|
11
|
-
import { prefix, ajaxUpload, defaultProps, getUnhandledProps } from '../utils';
|
|
10
|
+
import { compose, prefix, ajaxUpload, defaultProps, getUnhandledProps } from '../utils';
|
|
12
11
|
import { getFiles, guid } from './utils';
|
|
13
12
|
import { UploaderProps, FileType } from './Uploader.d';
|
|
14
13
|
|
|
@@ -285,7 +284,7 @@ class Uploader extends React.Component<UploaderProps, UploaderState> {
|
|
|
285
284
|
fileList: nextFileList
|
|
286
285
|
};
|
|
287
286
|
|
|
288
|
-
if (nextFile.progress) {
|
|
287
|
+
if (nextFile.progress || nextFile.status === 'error') {
|
|
289
288
|
const { fileMap } = this.state;
|
|
290
289
|
|
|
291
290
|
fileMap[nextFile.fileKey] = {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { setDisplayName, wrapDisplayName } from 'recompose';
|
|
2
|
+
import { setDisplayName, wrapDisplayName } from './recompose';
|
|
3
3
|
import { getClassNamePrefix } from './prefix';
|
|
4
4
|
import { StandardProps } from '../@types/common';
|
|
5
5
|
import extendReactStatics from './extendReactStatics';
|
package/src/utils/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from './htmlPropsUtils';
|
|
|
3
3
|
|
|
4
4
|
export { default as withStyleProps } from './withStyleProps';
|
|
5
5
|
|
|
6
|
+
export * from './recompose';
|
|
6
7
|
export { default as prefix, defaultClassPrefix, getClassNamePrefix, globalKey } from './prefix';
|
|
7
8
|
export { default as createChainedFunction } from './createChainedFunction';
|
|
8
9
|
export { default as defaultProps } from './defaultProps';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface ComponentEnhancer<TInner, TOutter> {
|
|
4
|
+
(component: React.ComponentType<TInner>): React.ComponentClass<TOutter>;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function compose<TInner, TOutter>(...funcs: Function[]): ComponentEnhancer<TInner, TOutter> {
|
|
8
|
+
return funcs.reduce(
|
|
9
|
+
(a, b) => (...args) => a(b(...args)),
|
|
10
|
+
arg => arg
|
|
11
|
+
) as ComponentEnhancer<TInner, TOutter>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function setStatic(
|
|
15
|
+
key: string,
|
|
16
|
+
value: any
|
|
17
|
+
): <T extends React.ComponentType<any>>(component: T) => T {
|
|
18
|
+
return BaseComponent => {
|
|
19
|
+
/* eslint-disable no-param-reassign */
|
|
20
|
+
BaseComponent[key] = value;
|
|
21
|
+
/* eslint-enable no-param-reassign */
|
|
22
|
+
return BaseComponent;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function setDisplayName(
|
|
27
|
+
displayName: string
|
|
28
|
+
): <T extends React.ComponentType<any>>(component: T) => T {
|
|
29
|
+
return setStatic('displayName', displayName);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function getDisplayName(component: React.ComponentType<any>): string {
|
|
33
|
+
if (typeof component === 'string') {
|
|
34
|
+
return component;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (!component) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return component.displayName || component.name || 'Component';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function wrapDisplayName(component: React.ComponentType<any>, wrapperName: string): string {
|
|
45
|
+
return `${wrapperName}(${getDisplayName(component)})`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function setPropTypes<P>(
|
|
49
|
+
propTypes: React.ValidationMap<P>
|
|
50
|
+
): <T extends React.ComponentType<P>>(component: T) => T {
|
|
51
|
+
return setStatic('propTypes', propTypes);
|
|
52
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Ref: https://github.com/acdlite/recompose/tree/master/src/packages/recompose/__tests__
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import {
|
|
5
|
+
compose,
|
|
6
|
+
setStatic,
|
|
7
|
+
setDisplayName,
|
|
8
|
+
getDisplayName,
|
|
9
|
+
wrapDisplayName,
|
|
10
|
+
setPropTypes
|
|
11
|
+
} from '../recompose';
|
|
12
|
+
|
|
13
|
+
describe('compose', function() {
|
|
14
|
+
it('composes from right to left', () => {
|
|
15
|
+
const double = x => x * 2;
|
|
16
|
+
const square = x => x * x;
|
|
17
|
+
expect(compose(square)(5)).to.equal(25);
|
|
18
|
+
expect(compose(square, double)(5)).to.equal(100);
|
|
19
|
+
expect(compose(double, square, double)(5)).to.equal(200);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('can be seeded with multiple arguments', () => {
|
|
23
|
+
const square = x => x * x;
|
|
24
|
+
const add = (x, y) => x + y;
|
|
25
|
+
expect(compose(square, add)(1, 2)).to.equal(9);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('returns the identity function if given no arguments', () => {
|
|
29
|
+
expect(compose()(1, 2)).to.equal(1);
|
|
30
|
+
expect(compose()(3)).to.equal(3);
|
|
31
|
+
expect(compose()()).to.equal(undefined);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('the first function if given only one', () => {
|
|
35
|
+
const fn = x => x * x;
|
|
36
|
+
expect(compose(fn)(3)).to.equal(fn(3));
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('setStatic', () => {
|
|
41
|
+
it('sets a static property on the base component', () => {
|
|
42
|
+
const BaseComponent = () => <div />;
|
|
43
|
+
const NewComponent = setStatic('propTypes', { foo: PropTypes.object })(BaseComponent);
|
|
44
|
+
|
|
45
|
+
expect(NewComponent.propTypes).to.eql({
|
|
46
|
+
foo: PropTypes.object
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('setDisplayName', () => {
|
|
52
|
+
it('sets a static property on the base component', () => {
|
|
53
|
+
const BaseComponent = () => <div />;
|
|
54
|
+
const NewComponent = setDisplayName('Foo')(BaseComponent);
|
|
55
|
+
expect(NewComponent.displayName).to.equal('Foo');
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('getDisplayName', () => {
|
|
60
|
+
it('gets the display name of a React component', () => {
|
|
61
|
+
class SomeComponent extends React.Component {
|
|
62
|
+
render() {
|
|
63
|
+
return <div />;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
class SomeOtherComponent extends React.Component {
|
|
68
|
+
static displayName = 'CustomDisplayName';
|
|
69
|
+
render() {
|
|
70
|
+
return <div />;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function YetAnotherComponent() {
|
|
75
|
+
return <div />;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
expect(getDisplayName(SomeComponent)).to.equal('SomeComponent');
|
|
79
|
+
expect(getDisplayName(SomeOtherComponent)).to.equal('CustomDisplayName');
|
|
80
|
+
expect(getDisplayName(YetAnotherComponent)).to.equal('YetAnotherComponent');
|
|
81
|
+
expect(getDisplayName(() => <div />)).to.equal('Component');
|
|
82
|
+
expect(getDisplayName('div')).to.equal('div');
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe('wrapDisplayName', () => {
|
|
87
|
+
it('wraps the display name of a React component with the name of an HoC, Relay-style', () => {
|
|
88
|
+
class SomeComponent extends React.Component {
|
|
89
|
+
render() {
|
|
90
|
+
return <div />;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
expect(wrapDisplayName(SomeComponent, 'someHoC')).to.equal('someHoC(SomeComponent)');
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('setPropTypes', () => {
|
|
99
|
+
it(' sets a static property on the base component', () => {
|
|
100
|
+
const BaseComponent = () => <div />;
|
|
101
|
+
const NewComponent = setPropTypes({ foo: PropTypes.object })(BaseComponent);
|
|
102
|
+
|
|
103
|
+
expect(NewComponent.propTypes).to.eql({
|
|
104
|
+
foo: PropTypes.object
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import { setDisplayName, wrapDisplayName, setPropTypes } from 'recompose';
|
|
4
|
+
import { setDisplayName, wrapDisplayName, setPropTypes } from './recompose';
|
|
5
5
|
|
|
6
6
|
import { TypeAttributes } from '../@types/common';
|
|
7
7
|
import prefix from './prefix';
|