import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { createRows } from './TableRow';

class TableFooter extends PureComponent {
  static componentName = 'TableFooter';

  static propTypes = {
    /**
     * Children passed to table footer.
     */
    children: PropTypes.node,
    /**
     * Controls the display of the row to adjust checkbox.
     */
    adjustForCheckbox: PropTypes.bool,
    className: PropTypes.string
  };

  static defaultProps = {
    children: null,
    adjustForCheckbox: false,
    className: undefined
  };

  render() {
    const {
      children,
      adjustForCheckbox,
      className,
      ...rest
    } = this.props;

    return (
      <tfoot className={className} {...rest}>{createRows({ children, props: { adjustForCheckbox } })}</tfoot>
    );
  }
}

export default TableFooter;

