UNPKG

choerodon-ui

Version:

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

82 lines (68 loc) 2.25 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; import _objectSpread from "@babel/runtime/helpers/objectSpread2"; var _excluded = ["column"]; import React from 'react'; import { connect } from 'mini-store'; function TableHeaderRow(_ref) { var row = _ref.row, index = _ref.index, height = _ref.height, components = _ref.components, onHeaderRow = _ref.onHeaderRow; var HeaderRow = components.header.row; var HeaderCell = components.header.cell; var rowProps = onHeaderRow(row.map(function (cell) { return cell.column; }), index); var customStyle = rowProps ? rowProps.style : {}; var style = _objectSpread({ height: height }, customStyle); return /*#__PURE__*/React.createElement(HeaderRow, _extends({}, rowProps, { style: style }), row.map(function (cell, i) { var column = cell.column, cellProps = _objectWithoutProperties(cell, _excluded); var customProps = column.onHeaderCell ? column.onHeaderCell(column) : {}; if (column.width) { var addStyle = { minWidth: column.width, width: column.width, maxWidth: column.width }; customProps.style = _objectSpread(_objectSpread({}, customProps.style), addStyle); } if (column.align) { customProps.style = _objectSpread(_objectSpread({}, customProps.style), {}, { textAlign: column.align }); } return /*#__PURE__*/React.createElement(HeaderCell, _extends({}, cellProps, customProps, { key: column.key || column.dataIndex || i })); })); } function getRowHeight(state, props) { var fixedColumnsHeadRowsHeight = state.fixedColumnsHeadRowsHeight; var columns = props.columns, rows = props.rows, fixed = props.fixed; var headerHeight = fixedColumnsHeadRowsHeight[0]; if (!fixed) { return null; } if (headerHeight && columns) { if (headerHeight === 'auto') { return 'auto'; } return headerHeight / rows.length; } return null; } export default connect(function (state, props) { return { height: getRowHeight(state, props) }; })(TableHeaderRow); //# sourceMappingURL=TableHeaderRow.js.map