"use strict";

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

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

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

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

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

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

var _measureScrollbar = _interopRequireDefault(require("../../_util/measureScrollbar"));

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

var StickyShadow = function StickyShadow(props) {
  var _classNames;

  var position = props.position,
      children = props.children,
      columns = props.columns,
      prefixCls = props.prefixCls,
      scroll = props.scroll;

  if (!children && columns.length === 0) {
    return null;
  }

  var classString = (0, _classnames["default"])((_classNames = {}, (0, _defineProperty2["default"])(_classNames, "".concat(prefixCls, "-sticky-shadow"), !children), (0, _defineProperty2["default"])(_classNames, "".concat(prefixCls, "-fixed-left"), children && position === 'left'), (0, _defineProperty2["default"])(_classNames, "".concat(prefixCls, "-fixed-right"), children && position === 'right'), (0, _defineProperty2["default"])(_classNames, "".concat(prefixCls, "-sticky-left"), position === 'left'), (0, _defineProperty2["default"])(_classNames, "".concat(prefixCls, "-sticky-right"), position === 'right'), _classNames));
  var style = {};

  if (!children) {
    var scrollBarWidth = (0, _measureScrollbar["default"])();

    if (position === 'left') {
      style.left = columns.reduce(function (sum, column) {
        return sum + (0, _utils.columnWidth)(column);
      }, 0);
    } else if (position === 'right') {
      style.right = columns.reduce(function (sum, column) {
        return sum + (0, _utils.columnWidth)(column);
      }, 0) + (scroll && scroll.y ? scrollBarWidth : 0);
    }

    style.bottom = scrollBarWidth;
  }

  return /*#__PURE__*/_react["default"].createElement("div", {
    className: classString,
    style: style
  }, children);
};

StickyShadow.displayName = 'StickyShadow';

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

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