import React, { useContext } from 'react';
import clsx from 'clsx';
import { BORDER_TOP_BOTTOM } from '../utils/constant';
import ConfigProviderContext from '../config-provider/ConfigProviderContext';

var CellGroup = function CellGroup(props) {
  var title = props.title,
      border = props.border,
      insetP = props.inset,
      card = props.card;
  var inset = card || insetP;

  var _useContext = useContext(ConfigProviderContext),
      prefixCls = _useContext.prefixCls,
      createNamespace = _useContext.createNamespace;

  var _createNamespace = createNamespace('cell-group', prefixCls),
      bem = _createNamespace[0];

  var renderGroup = function renderGroup() {
    var _clsx;

    return /*#__PURE__*/React.createElement("div", {
      className: clsx(bem({
        inset: inset
      }), (_clsx = {}, _clsx[BORDER_TOP_BOTTOM] = !inset && border, _clsx))
    }, props.children);
  };

  var renderTitle = function renderTitle() {
    if (title) return /*#__PURE__*/React.createElement("div", {
      className: clsx(bem('title'))
    }, title);
    return null;
  };

  return /*#__PURE__*/React.createElement("div", {
    className: props.className,
    style: props.style
  }, renderTitle(), renderGroup());
};

CellGroup.defaultProps = {
  border: true
};
export default CellGroup;