index.js 1.27 KB
Newer Older
李纪文's avatar
李纪文 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
// eslint-disable-next-line no-unused-vars
import React, { useContext } from 'react';
import classNames from 'classnames';
import { Select, TreeSelect, ConfigProvider } from 'antd';
import './index.less';

const { Option, OptGroup } = Select;
const { SHOW_PARENT } = TreeSelect;
const SelectCustom = (props) => {
  const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
  const prefixCls = getPrefixCls('select-custom');

  return (
    <div className={classNames(`${prefixCls}`, props.prefixIcon ? `${prefixCls}-prefix` : '')}>
      {props.prefixIcon ? (
        <div className={classNames(`${prefixCls}-icon`)} style={props.prefixStyle}>
          {props.prefixIcon}
        </div>
      ) : null}
      <Select
        {...props}
        className={classNames(`${prefixCls}-base`, props.className || '')}
        popupClassName={classNames(`${prefixCls}-base-poup`, props.popupClassName || '')}
      ></Select>
    </div>
  );
};

const TreeSelectCustom = (props) => {
  const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
  const prefixCls = getPrefixCls('tree-select-custom');
李纪文's avatar
李纪文 committed
32

李纪文's avatar
李纪文 committed
33 34 35 36 37 38
  return (
    <TreeSelect {...props} className={classNames(`${prefixCls}-base`, props.className || '')} />
  );
};

export { SelectCustom, TreeSelectCustom, Option, OptGroup, SHOW_PARENT };