import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { useContext } from 'react';
import clsx from 'clsx';
import { BORDER_TOP_BOTTOM } from '../utils/constant';
import ConfigProviderContext from '../config-provider/ConfigProviderContext';

const CellGroup = props => {
  const {
    title,
    border,
    inset: insetP,
    card
  } = props;
  const inset = card || insetP;
  const {
    prefixCls,
    createNamespace
  } = useContext(ConfigProviderContext);
  const [bem] = createNamespace('cell-group', prefixCls);

  const renderGroup = () => _jsx("div", Object.assign({
    className: clsx(bem({
      inset
    }), {
      [BORDER_TOP_BOTTOM]: !inset && border
    })
  }, {
    children: props.children
  }));

  const renderTitle = () => {
    if (title) return _jsx("div", Object.assign({
      className: clsx(bem('title'))
    }, {
      children: title
    }));
    return null;
  };

  return _jsxs("div", Object.assign({
    className: props.className,
    style: props.style
  }, {
    children: [renderTitle(), renderGroup()]
  }));
};

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