waiting for upgrade rc-tree-select

This commit is contained in:
HeskeyBaozi 2018-08-24 14:08:06 +08:00
parent 9893fec5f1
commit d375070da5
2 changed files with 37 additions and 1 deletions

View File

@ -5,6 +5,8 @@ import { TreeSelectProps } from './interface';
import { SelectLocale } from '../select';
import LocaleReceiver from '../locale-provider/LocaleReceiver';
import warning from '../_util/warning';
import Icon from '../icon';
import { AntTreeNodeProps } from '../tree';
export { TreeNode, TreeSelectProps } from './interface';
@ -44,6 +46,28 @@ export default class TreeSelect extends React.Component<TreeSelectProps, any> {
this.rcTreeSelect = node;
}
renderSwitcherIcon = ({ isLeaf, loading }: AntTreeNodeProps) => {
const {
prefixCls,
} = this.props;
if (loading) {
return (
<Icon
type="reload"
spin
className={`${prefixCls}-switcher-loading-icon`}
svgClassName={`${prefixCls}-switcher-loading-icon-svg`}
/>
);
}
if (isLeaf) {
return null;
}
return (
<Icon type="down" className={`${prefixCls}-switcher-icon`} />
);
}
renderTreeSelect = (locale: SelectLocale) => {
const {
prefixCls,
@ -64,6 +88,15 @@ export default class TreeSelect extends React.Component<TreeSelectProps, any> {
if (checkable) {
checkable = <span className={`${prefixCls}-tree-checkbox-inner`} />;
}
const inputIcon = (
<Icon type="down" className={`${prefixCls}-arrow-icon`} />
);
const removeIcon = (
<Icon type="close" className={`${prefixCls}-remove-icon`} />
);
return (
<RcTreeSelect
{...restProps}
@ -74,6 +107,9 @@ export default class TreeSelect extends React.Component<TreeSelectProps, any> {
treeCheckable={checkable}
notFoundContent={notFoundContent || locale.notFoundContent}
ref={this.saveTreeSelect}
switcherIcon={this.renderSwitcherIcon}
inputIcon={inputIcon}
removeIcon={removeIcon}
/>
);
}

View File

@ -80,7 +80,7 @@
"rc-time-picker": "~3.4.0",
"rc-tooltip": "~3.7.0",
"rc-tree": "~1.14.3",
"rc-tree-select": "~2.1.0",
"rc-tree-select": "~2.1.1",
"rc-trigger": "^2.5.4",
"rc-upload": "~2.5.0",
"rc-util": "^4.0.4",