import React, { useContext } from 'react';
import { observer } from 'mobx-react-lite';
import { pxToRem } from '../../../es/_util/UnitConvertor';
import { ColumnLock } from './enum';
import TableContext from './TableContext';
import { isStickySupport } from './utils';
export var ROW_GROUP_HEIGHT = 25;

var TableRowGroup = function TableRowGroup(props) {
  var _useContext = useContext(TableContext),
      prefixCls = _useContext.prefixCls,
      tableStore = _useContext.tableStore;

  var lock = props.lock,
      columnGroups = props.columnGroups,
      children = props.children,
      level = props.level;

  var colSpan = function () {
    switch (lock) {
      case ColumnLock.left:
        return columnGroups.leftLeafs.length;

      case ColumnLock.right:
        return columnGroups.rightLeafs.length;

      default:
        return columnGroups.leafs.length;
    }
  }();

  var Cmp = tableStore.parityRow ? 'div' : 'tr';
  return /*#__PURE__*/React.createElement(Cmp, {
    className: "".concat(prefixCls, "-row-group"),
    style: isStickySupport() ? undefined : {
      height: pxToRem(ROW_GROUP_HEIGHT)
    }
  }, /*#__PURE__*/React.createElement("th", {
    colSpan: colSpan,
    className: "".concat(prefixCls, "-row-group-title"),
    style: {
      top: level * ROW_GROUP_HEIGHT
    },
    scope: "colgroup"
  }, lock !== ColumnLock.right && /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefixCls, "-row-group-title-content")
  }, children)));
};

TableRowGroup.displayName = 'TableRowGroup';
export default observer(TableRowGroup);
//# sourceMappingURL=TableRowGroup.js.map
