"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = exports.ROW_GROUP_HEIGHT = void 0;

var _react = _interopRequireWildcard(require("react"));

var _mobxReactLite = require("mobx-react-lite");

var _UnitConvertor = require("../../../lib/_util/UnitConvertor");

var _enum = require("./enum");

var _TableContext = _interopRequireDefault(require("./TableContext"));

var _utils = require("./utils");

var ROW_GROUP_HEIGHT = 25;
exports.ROW_GROUP_HEIGHT = ROW_GROUP_HEIGHT;

var TableRowGroup = function TableRowGroup(props) {
  var _useContext = (0, _react.useContext)(_TableContext["default"]),
      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 _enum.ColumnLock.left:
        return columnGroups.leftLeafs.length;

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

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

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

TableRowGroup.displayName = 'TableRowGroup';

var _default = (0, _mobxReactLite.observer)(TableRowGroup);

exports["default"] = _default;
//# sourceMappingURL=TableRowGroup.js.map
