"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"] = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));

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

var _classnames = _interopRequireDefault(require("classnames"));

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

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

var _excluded = ["fixed", "width", "left", "height", "style", "classPrefix", "className", "children", "rowDraggable", "provided", "snapshot"];
var propTypeKeys = ['fixed', 'width', 'height', 'left', 'style', 'className', 'classPrefix', 'rowDraggable', 'snapshot', 'provided'];

var CellGroup = /*#__PURE__*/function (_React$PureComponent) {
  (0, _inherits2["default"])(CellGroup, _React$PureComponent);

  var _super = (0, _createSuper2["default"])(CellGroup);

  function CellGroup() {
    var _this;

    (0, _classCallCheck2["default"])(this, CellGroup);
    _this = _super.apply(this, arguments);

    _this.addPrefix = function (name) {
      return (0, _utils.prefix)(_this.props.classPrefix)(name);
    };

    return _this;
  }

  (0, _createClass2["default"])(CellGroup, [{
    key: "render",
    value: function render() {
      var _classNames;

      var _this$props = this.props,
          fixed = _this$props.fixed,
          width = _this$props.width,
          left = _this$props.left,
          height = _this$props.height,
          style = _this$props.style,
          classPrefix = _this$props.classPrefix,
          className = _this$props.className,
          children = _this$props.children,
          rowDraggable = _this$props.rowDraggable,
          provided = _this$props.provided,
          snapshot = _this$props.snapshot,
          rest = (0, _objectWithoutProperties2["default"])(_this$props, _excluded);
      var classes = (0, _classnames["default"])(classPrefix, className, (_classNames = {}, (0, _defineProperty2["default"])(_classNames, this.addPrefix("fixed-".concat(fixed || '')), fixed), (0, _defineProperty2["default"])(_classNames, this.addPrefix('scroll'), !fixed), _classNames));
      var styles = (0, _objectSpread2["default"])({
        width: width,
        height: height
      }, style);
      var unhandledProps = (0, _utils.getUnhandledProps)(propTypeKeys, rest);
      var childArr = [];

      if (rowDraggable) {
        React.Children.forEach(children, function (child) {
          childArr.push( /*#__PURE__*/React.cloneElement(child, {
            provided: provided,
            isDragging: snapshot ? snapshot.isDragging : false
          }));
        });
      }

      var cloneChildren = rowDraggable ? childArr : children;
      return /*#__PURE__*/React.createElement(_TableContext["default"].Consumer, null, function (_ref) {
        var translateDOMPositionXY = _ref.translateDOMPositionXY;

        if (translateDOMPositionXY) {
          translateDOMPositionXY(styles, left, 0);
        }

        return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({}, unhandledProps, {
          className: classes,
          style: styles
        }), cloneChildren);
      });
    }
  }]);
  return CellGroup;
}(React.PureComponent);

CellGroup.defaultProps = {
  classPrefix: (0, _utils.defaultClassPrefix)('performance-table-cell-group')
};
var _default = CellGroup;
exports["default"] = _default;
//# sourceMappingURL=CellGroup.js.map
