UNPKG

choerodon-ui

Version:

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

72 lines (59 loc) 1.9 kB
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; import _objectSpread from "@babel/runtime/helpers/objectSpread2"; 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 React.createElement(HeaderRow, _extends({}, rowProps, { style: style }), row.map(function (cell, i) { var column = cell.column, cellProps = _objectWithoutProperties(cell, ["column"]); var customProps = column.onHeaderCell ? column.onHeaderCell(column) : {}; if (column.align) { cellProps.style = { textAlign: column.align }; } return 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