"use strict";

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

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 _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));

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

var _mobx = require("mobx");

var _resizeObserver = _interopRequireDefault(require("../../../lib/_util/resizeObserver"));

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

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

var TableSibling = function TableSibling(props) {
  var position = props.position,
      boxSizing = props.boxSizing,
      children = props.children;

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

  var handleResize = (0, _react.useCallback)((0, _mobx.action)(function (_, height) {
    tableStore.siblingHeihgt = (0, _objectSpread3["default"])((0, _objectSpread3["default"])({}, tableStore.siblingHeihgt), {}, (0, _defineProperty2["default"])({}, position, height));
  }), [tableStore, position]);

  if (boxSizing === _enum.TableBoxSizing.wrapper) {
    return /*#__PURE__*/_react["default"].createElement(_resizeObserver["default"], {
      resizeProp: "height",
      onResize: handleResize
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "".concat(tableStore.prefixCls, "-sibling")
    }, children));
  }

  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, children);
};

TableSibling.displayName = 'TableSibling';
var _default = TableSibling;
exports["default"] = _default;
//# sourceMappingURL=TableSibling.js.map
