import { Checkbox as OldCheckbox, CheckboxProps, ConfigProvider } from 'antd';
import React, { useContext } from 'react';
import './index.less';
import classNames from 'classnames';
import { CheckboxGroupProps } from 'antd/lib/checkbox/Group';

interface CheckboxExtraProps {}

const Checkbox = (props: CheckboxProps & CheckboxExtraProps) => {
  const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
  const prefixCls = getPrefixCls('btri-checkbox');

  return (
    <OldCheckbox
      {...props}
      className={classNames(`${prefixCls}-box`, props.className)}
    >
      {props.children}
    </OldCheckbox>
  );
};

interface CheckGroupExtraProps {}

const Group = (props: CheckboxGroupProps & CheckGroupExtraProps) => {
  const { getPrefixCls } = useContext(ConfigProvider.ConfigContext);
  const prefixCls = getPrefixCls('btri-checkbox-group');

  return (
    <OldCheckbox.Group
      {...props}
      className={classNames(`${prefixCls}-box`, props.className)}
    >
      {props.children}
    </OldCheckbox.Group>
  );
};

Checkbox.Group = Group;

export { Checkbox };
