choerodon-ui
Version:
An enterprise-class UI design language and React-based implementation
51 lines (39 loc) • 2.27 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import React, { useContext } from 'react';
import { observer } from 'mobx-react-lite';
import classNames from 'classnames';
import { pxToRem } from '../../../es/_util/UnitConvertor';
import measureScrollbar from '../../../es/_util/measureScrollbar';
import TableContext from './TableContext';
import { onlyCustomizedColumn } from './utils';
var StickyShadow = function StickyShadow(props) {
var _classNames;
var position = props.position,
children = props.children;
var _useContext = useContext(TableContext),
tableStore = _useContext.tableStore,
prefixCls = _useContext.prefixCls;
var columnGroups = tableStore.columnGroups;
var disabled = !children && (position === 'left' && columnGroups.leftLeafs.length === 0 || position === 'right' && onlyCustomizedColumn(tableStore));
if (disabled) {
return null;
}
var classString = classNames((_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-sticky-shadow"), !children), _defineProperty(_classNames, "".concat(prefixCls, "-sticky-shadow-no-transition"), !tableStore.tableColumnResizeTransition), _defineProperty(_classNames, "".concat(prefixCls, "-fixed-left"), children && position === 'left'), _defineProperty(_classNames, "".concat(prefixCls, "-fixed-right"), children && position === 'right'), _defineProperty(_classNames, "".concat(prefixCls, "-sticky-left"), position === 'left' && tableStore.stickyLeft), _defineProperty(_classNames, "".concat(prefixCls, "-sticky-right"), position === 'right' && tableStore.stickyRight), _classNames));
var style = {};
if (!children) {
var scrollBarWidth = measureScrollbar();
if (position === 'left') {
style.left = pxToRem(columnGroups.leftLeafColumnsWidth - 1, true);
} else if (position === 'right') {
style.right = pxToRem(columnGroups.rightLeafColumnsWidth + (tableStore.overflowY ? scrollBarWidth : 0), true);
}
style.bottom = pxToRem(scrollBarWidth, true);
}
return /*#__PURE__*/React.createElement("div", {
className: classString,
style: style
}, children);
};
StickyShadow.displayName = 'StickyShadow';
export default observer(StickyShadow);
//# sourceMappingURL=StickyShadow.js.map