69 lines
2.3 KiB
JavaScript
69 lines
2.3 KiB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
import * as React from 'react';
|
|
import classNames from 'classnames';
|
|
import PropTypes from 'prop-types';
|
|
import { defaultClassPrefix, prefix } from './utils/prefix';
|
|
var ColumnGroup = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
var header = props.header,
|
|
className = props.className,
|
|
children = props.children,
|
|
classPrefix = props.classPrefix,
|
|
headerHeight = props.headerHeight,
|
|
verticalAlign = props.verticalAlign,
|
|
width = props.width,
|
|
rest = _objectWithoutPropertiesLoose(props, ["header", "className", "children", "classPrefix", "headerHeight", "verticalAlign", "width"]);
|
|
|
|
var height = headerHeight / 2;
|
|
var styles = {
|
|
height: height,
|
|
width: width
|
|
};
|
|
|
|
var contentStyles = _extends({}, styles, {
|
|
verticalAlign: verticalAlign
|
|
});
|
|
|
|
var addPrefix = React.useCallback(function (name) {
|
|
return prefix(classPrefix)(name);
|
|
}, []);
|
|
return /*#__PURE__*/React.createElement("div", _extends({
|
|
ref: ref,
|
|
className: classNames(classPrefix, className)
|
|
}, rest), /*#__PURE__*/React.createElement("div", {
|
|
className: addPrefix('header'),
|
|
style: styles
|
|
}, /*#__PURE__*/React.createElement("div", {
|
|
className: addPrefix('header-content'),
|
|
style: contentStyles
|
|
}, header)), React.Children.map(children, function (node) {
|
|
var _node$props;
|
|
|
|
var nodeStyles = _extends({
|
|
height: height
|
|
}, (_node$props = node.props) === null || _node$props === void 0 ? void 0 : _node$props.style, {
|
|
top: styles.height
|
|
});
|
|
|
|
return /*#__PURE__*/React.cloneElement(node, {
|
|
className: addPrefix('cell'),
|
|
style: nodeStyles,
|
|
headerHeight: height,
|
|
verticalAlign: verticalAlign,
|
|
children: /*#__PURE__*/React.createElement("span", {
|
|
className: addPrefix('cell-content')
|
|
}, node.props.children)
|
|
});
|
|
}));
|
|
});
|
|
ColumnGroup.displayName = 'ColumnGroup';
|
|
ColumnGroup.defaultProps = {
|
|
headerHeight: 80,
|
|
classPrefix: defaultClassPrefix('table-column-group')
|
|
};
|
|
ColumnGroup.propTypes = {
|
|
header: PropTypes.node,
|
|
classPrefix: PropTypes.string,
|
|
verticalAlign: PropTypes.oneOf(['top', 'middle', 'bottom'])
|
|
};
|
|
export default ColumnGroup; |