"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 _react = _interopRequireWildcard(require("react"));

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

var _mobx = require("mobx");

var _isEqual = _interopRequireDefault(require("lodash/isEqual"));

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

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

var _Column = require("./Column");

var TableCol = function TableCol(props) {
  var column = props.column,
      last = props.last;

  var _useContext = (0, _react.useContext)(_TableContext["default"]),
      tableStore = _useContext.tableStore,
      prefixCls = _useContext.prefixCls;

  var lastEmptyWidthColumn = tableStore.getLastEmptyWidthColumn;
  var width = last && !tableStore.hasEmptyWidthColumn ? undefined : tableStore.overflowX ? (0, _Column.columnWidth)(column, tableStore) : (0, _mobx.get)(column, 'width');
  var innerClassName = [];

  if (tableStore.isBuiltInColumn(column)) {
    innerClassName.push((0, _mobx.get)(column, 'headerClassName'));
  }

  if (tableStore.tableColumnResizeTransition) {
    innerClassName.push("".concat(prefixCls, "-col"));
  }

  var minWidth = (0, _Column.minColumnWidth)(column, tableStore);

  if (lastEmptyWidthColumn && (0, _isEqual["default"])(column, lastEmptyWidthColumn)) {
    width = undefined;
  } else {
    width = (0, _UnitConvertor.pxToRem)(width, true);
  }

  var style = (0, _react.useMemo)(function () {
    return {
      width: width,
      minWidth: (0, _UnitConvertor.pxToRem)(minWidth, true)
    };
  }, [width, minWidth]);
  return /*#__PURE__*/_react["default"].createElement("col", {
    className: innerClassName.join(' '),
    style: style
  });
};

TableCol.displayName = 'TableCol';

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

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