import React from 'react';
import AntdSelect from 'antd/es/select';

import { ConfigConsumer } from '../config-provider';
import Icons from '../icons';
import './index.less';

const { CaretDownIcon } = Icons;

const Select = props => (
  <ConfigConsumer>
    {({ getPrefixCls }) => {
      const { prefixCls: customizePrefixCls, ...restProps } = props;
      const prefixCls = getPrefixCls('select', customizePrefixCls);
      return (
        <AntdSelect
          prefixCls={prefixCls}
          suffixIcon={<CaretDownIcon />}
          {...restProps}
        />
      );
    }}
  </ConfigConsumer>
);

const Option = props => <AntdSelect.Option {...props} />;
const OptGroup = props => <AntdSelect.OptGroup {...props} />;

Select.Option = Option;
Select.OptGroup = OptGroup;

export default Select;
