choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
36 lines (29 loc) • 1.34 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
import React, { useCallback, useContext } from 'react';
import { action } from 'mobx';
import ReactResizeObserver from '../../../es/_util/resizeObserver';
import { TableBoxSizing } from './enum';
import TableContext from './TableContext';
var TableSibling = function TableSibling(props) {
var position = props.position,
boxSizing = props.boxSizing,
children = props.children;
var _useContext = useContext(TableContext),
tableStore = _useContext.tableStore;
var handleResize = useCallback(action(function (_, height) {
tableStore.siblingHeihgt = _objectSpread(_objectSpread({}, tableStore.siblingHeihgt), {}, _defineProperty({}, position, height));
}), [tableStore, position]);
if (boxSizing === TableBoxSizing.wrapper) {
return /*#__PURE__*/React.createElement(ReactResizeObserver, {
resizeProp: "height",
onResize: handleResize
}, /*#__PURE__*/React.createElement("div", {
className: "".concat(tableStore.prefixCls, "-sibling")
}, children));
}
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
};
TableSibling.displayName = 'TableSibling';
export default TableSibling;
//# sourceMappingURL=TableSibling.js.map