You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.5 KiB

import React from 'react';
import RcTreeSelect, { TreeNode, SHOW_ALL, SHOW_PARENT, SHOW_CHILD } from 'rc-tree-select';
9 years ago
import classNames from 'classnames';
import { TreeSelectProps, TreeSelectContext } from './interface';
9 years ago
export { TreeSelectProps };
export default class TreeSelect extends React.Component<TreeSelectProps, any> {
static TreeNode = TreeNode;
static SHOW_ALL = SHOW_ALL;
static SHOW_PARENT = SHOW_PARENT;
static SHOW_CHILD = SHOW_CHILD;
static defaultProps = {
prefixCls: 'ant-select',
transitionName: 'slide-up',
choiceTransitionName: 'zoom',
showSearch: false,
dropdownClassName: 'ant-select-tree-dropdown',
};
static contextTypes = {
antLocale: React.PropTypes.object,
};
context: TreeSelectContext;
9 years ago
render() {
const props = this.props;
let {
size, className = '', notFoundContent, prefixCls,
9 years ago
} = this.props;
const cls = classNames({
[`${prefixCls}-lg`]: size === 'large',
[`${prefixCls}-sm`]: size === 'small',
9 years ago
[className]: !!className,
});
const { antLocale } = this.context;
if (antLocale && antLocale.Select) {
notFoundContent = notFoundContent || antLocale.Select.notFoundContent;
}
9 years ago
let checkable = props.treeCheckable;
9 years ago
if (checkable) {
checkable = <span className={`${prefixCls}-tree-checkbox-inner`} />;
9 years ago
}
return (
<RcTreeSelect
{...this.props}
9 years ago
treeCheckable={checkable}
9 years ago
className={cls}
notFoundContent={notFoundContent}
/>
9 years ago
);
}
}