import React, { Component } from 'react';
import cls from 'classnames';
import hoistNonReactStatics from 'hoist-non-react-statics';
import { Radio as NextRadio } from '@alifd/next';
import { RadioProps as NextRadioProps } from '@alifd/next/types/radio';

interface RadioProps extends NextRadioProps {
  size?: 'xl' | 'large' | 'medium' | 'small';
}
class Radio extends Component<RadioProps> {
  static Group = NextRadio.Group;

  render() {
    const { size = 'medium' } = this.props;
    const { prefix = 'next-', className, ...otherProps } = this.props;
    return (
      <NextRadio
        {...otherProps}
        prefix={prefix}
        className={cls(className, {
          [`${prefix}xl`]: size === 'xl',
          [`${prefix}large`]: size === 'large',
          [`${prefix}medium`]: size === 'medium',
          [`${prefix}small`]: size === 'small',
        })}
      />
    );
  }
}

hoistNonReactStatics(Radio, NextRadio);

export default Radio;
