UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

74 lines (67 loc) 2.46 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectSpread from "@babel/runtime/helpers/objectSpread2"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; import React from 'react'; import classNames from 'classnames'; import PropTypes from 'prop-types'; import { defaultClassPrefix, prefix } from './utils'; var ColumnGroup = React.forwardRef(function (props, ref) { var header = props.header, className = props.className, children = props.children, classPrefix = props.classPrefix, _props$headerHeight = props.headerHeight, headerHeight = _props$headerHeight === void 0 ? 80 : _props$headerHeight, verticalAlign = props.verticalAlign, width = props.width, left = props.left, rest = _objectWithoutProperties(props, ["header", "className", "children", "classPrefix", "headerHeight", "verticalAlign", "width", "left"]); var height = headerHeight / 2; var styles = { height: height, width: width, left: left }; var contentStyles = _objectSpread({}, styles, { verticalAlign: verticalAlign }); var addPrefix = function addPrefix(name) { return prefix(classPrefix)(name); }; return React.createElement("div", _extends({ ref: ref, className: classNames(classPrefix, className) }, rest), React.createElement("div", { className: addPrefix('header'), style: styles }, React.createElement("div", { className: addPrefix('header-content'), style: contentStyles }, header)), React.Children.map(children, function (node) { var _node$props; var nodeStyles = _objectSpread({}, (_node$props = node.props) === null || _node$props === void 0 ? void 0 : _node$props.style, { top: styles.height, left: styles.left }); return React.cloneElement(node, { className: addPrefix('cell'), style: nodeStyles, children: React.createElement("span", { className: addPrefix('cell-content') }, node.props.children) }); })); }); ColumnGroup.displayName = 'ColumnGroup'; ColumnGroup.__PRO_TABLE_COLUMN_GROUP = true; ColumnGroup.defaultProps = { headerHeight: 80, classPrefix: defaultClassPrefix('performance-table-column-group') }; ColumnGroup.propTypes = { header: PropTypes.node, classPrefix: PropTypes.string, verticalAlign: PropTypes.oneOf(['top', 'middle', 'bottom']) }; export default ColumnGroup; //# sourceMappingURL=ColumnGroup.js.map