"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _classnames = _interopRequireDefault(require("classnames"));
var _react = _interopRequireDefault(require("react"));
var _web = require("@react-spring/web");
require("./index.css");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var preCls = 'titaui-super-table-box';
var Box = function Box(_ref) {
  var className = _ref.className,
    style = _ref.style,
    record = _ref.record,
    rowIdx = _ref.rowIdx,
    columnOption = _ref.columnOption,
    active = _ref.active,
    width = _ref.width;
  var dataIndex = columnOption.dataIndex,
    onCell = columnOption.onCell,
    render = columnOption.render,
    renderFill = columnOption.renderFill,
    hidden = columnOption.hidden;
  var spanOption = onCell ? onCell(record, rowIdx) || {} : {};
  if (spanOption.rowSpan === 0 || spanOption.colSpan === 0) return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null);
  var content = /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null);
  if (render) {
    var Render = render;
    content = /*#__PURE__*/_react["default"].createElement(Render, {
      value: dataIndex ? record[dataIndex] : undefined,
      data: record,
      rowIdx: rowIdx
    });
  }
  if (dataIndex) content = record[dataIndex];
  return /*#__PURE__*/_react["default"].createElement("td", _extends({
    className: (0, _classnames["default"])(preCls, className, _defineProperty({}, "".concat(preCls, "--active"), active)),
    style: style
  }, spanOption), /*#__PURE__*/_react["default"].createElement("div", {
    className: (0, _classnames["default"])("".concat(preCls, "__box-container"), _defineProperty({}, "".concat(preCls, "__box-container--hidden"), hidden))
  }, /*#__PURE__*/_react["default"].createElement(_web.animated.div, {
    style: {
      width: width
    }
  }, renderFill ? content : /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(preCls, "__content")
  }, content))));
};
var _default = /*#__PURE__*/_react["default"].memo(Box);
exports["default"] = _default;