import ConfigProvider from '../config-provider';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import cls from 'classnames';
import { CommonThemeProps } from '../types';
import { Cascader as NextCascader } from '@alifd/next';
import { CascaderProps as NextCascaderProps } from '@alifd/next/types/cascader';
import { getTheme } from '../utils/getTheme';


interface CascaderProps extends NextCascaderProps, CommonThemeProps {
}

class Cascader extends Component<CascaderProps> {

  // contextTypes
  static contextTypes = {
    theme: PropTypes.string,
  };

  render() {
    const { prefix = 'next-', className, ...otherProps } = this.props;

    const theme = getTheme(this.context, this.props);

    return (
      <NextCascader
        {...otherProps}
        prefix={prefix}
        className={cls(className, {
          [`${prefix}grey`]: theme === 'grey',
          [`${prefix}white`]: theme === 'white',

        })}
      />
    );
  }
}


export default ConfigProvider.config(Cascader);
