61 lines
3.1 KiB
JavaScript
61 lines
3.1 KiB
JavaScript
"use strict";
|
|
|
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.default = void 0;
|
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
var React = _interopRequireWildcard(require("react"));
|
|
var _Cell = _interopRequireDefault(require("../Cell"));
|
|
var _TableContext = _interopRequireDefault(require("../context/TableContext"));
|
|
var _context = require("@rc-component/context");
|
|
var _fixUtil = require("../utils/fixUtil");
|
|
var _valueUtil = require("../utils/valueUtil");
|
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
var HeaderRow = function HeaderRow(props) {
|
|
var cells = props.cells,
|
|
stickyOffsets = props.stickyOffsets,
|
|
flattenColumns = props.flattenColumns,
|
|
RowComponent = props.rowComponent,
|
|
CellComponent = props.cellComponent,
|
|
onHeaderRow = props.onHeaderRow,
|
|
index = props.index;
|
|
var _useContext = (0, _context.useContext)(_TableContext.default, ['prefixCls', 'direction']),
|
|
prefixCls = _useContext.prefixCls,
|
|
direction = _useContext.direction;
|
|
var rowProps;
|
|
if (onHeaderRow) {
|
|
rowProps = onHeaderRow(cells.map(function (cell) {
|
|
return cell.column;
|
|
}), index);
|
|
}
|
|
var columnsKey = (0, _valueUtil.getColumnsKey)(cells.map(function (cell) {
|
|
return cell.column;
|
|
}));
|
|
return /*#__PURE__*/React.createElement(RowComponent, rowProps, cells.map(function (cell, cellIndex) {
|
|
var column = cell.column;
|
|
var fixedInfo = (0, _fixUtil.getCellFixedInfo)(cell.colStart, cell.colEnd, flattenColumns, stickyOffsets, direction);
|
|
var additionalProps;
|
|
if (column && column.onHeaderCell) {
|
|
additionalProps = cell.column.onHeaderCell(column);
|
|
}
|
|
return /*#__PURE__*/React.createElement(_Cell.default, (0, _extends2.default)({}, cell, {
|
|
scope: column.title ? cell.colSpan > 1 ? 'colgroup' : 'col' : null,
|
|
ellipsis: column.ellipsis,
|
|
align: column.align,
|
|
component: CellComponent,
|
|
prefixCls: prefixCls,
|
|
key: columnsKey[cellIndex]
|
|
}, fixedInfo, {
|
|
additionalProps: additionalProps,
|
|
rowType: "header"
|
|
}));
|
|
}));
|
|
};
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
HeaderRow.displayName = 'HeaderRow';
|
|
}
|
|
var _default = exports.default = HeaderRow; |