ant-design/components/select/index.jsx

43 lines
1.0 KiB
JavaScript

import React from 'react';
import RcSelect, { Option, OptGroup } from 'rc-select';
import classNames from 'classnames';
export default class Select extends React.Component {
static Option = Option;
static OptGroup = OptGroup;
static defaultProps = {
prefixCls: 'ant-select',
transitionName: 'slide-up',
optionLabelProp: 'children',
choiceTransitionName: 'zoom',
showSearch: false,
}
render() {
let {
size, className, combobox, notFoundContent, prefixCls, showSearch, optionLabelProp,
} = this.props;
const cls = classNames({
[`${prefixCls}-lg`]: size === 'large',
[`${prefixCls}-sm`]: size === 'small',
[className]: !!className,
[`${prefixCls}-show-search`]: showSearch,
});
if (combobox) {
notFoundContent = null;
// children 带 dom 结构时,无法填入输入框
optionLabelProp = 'value';
}
return (
<RcSelect {...this.props}
className={cls}
optionLabelProp={optionLabelProp}
notFoundContent={notFoundContent} />
);
}
}