Browse Source

waiting for upgrade rc-tree-select

pull/11322/head
HeskeyBaozi 6 years ago
parent
commit
d375070da5
  1. 36
      components/tree-select/index.tsx
  2. 2
      package.json

36
components/tree-select/index.tsx

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

2
package.json

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

Loading…
Cancel
Save