import React, { Component } from 'react';
import cls from 'classnames';
import hoistNonReactStatics from 'hoist-non-react-statics';
import { CommonThemeProps } from '../types';
import { Collapse as NextCollapse } from '@alifd/next';
import { CollapseProps as NextCollapseProps } from '@alifd/next/types/collapse';

interface CollapseProps extends NextCollapseProps, CommonThemeProps {
  align?: 'l' | 'r';
}

class Collapse extends Component<CollapseProps> {
  static Panel = NextCollapse.Panel;

  render() {
    const { align, theme } = this.props;
    const { prefix = 'next-', className, ...otherProps } = this.props;
    // right 模式
    return (
      <NextCollapse
        {...otherProps}
        prefix={prefix}
        className={cls(className, {
          [`${prefix}r`]: align === 'r',
          [`${prefix}grey`]: theme === 'grey',
        })}
      />
    );
  }
}

hoistNonReactStatics(Collapse, NextCollapse);

export default Collapse;
