HeaderRow.js
2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _Cell = _interopRequireDefault(require("../Cell"));
var _TableContext = _interopRequireDefault(require("../context/TableContext"));
var _fixUtil = require("../utils/fixUtil");
var _valueUtil = require("../utils/valueUtil");
function HeaderRow(_ref) {
var cells = _ref.cells,
stickyOffsets = _ref.stickyOffsets,
flattenColumns = _ref.flattenColumns,
RowComponent = _ref.rowComponent,
CellComponent = _ref.cellComponent,
onHeaderRow = _ref.onHeaderRow,
index = _ref.index;
var _React$useContext = React.useContext(_TableContext.default),
prefixCls = _React$useContext.prefixCls,
direction = _React$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 React.createElement(RowComponent, Object.assign({}, 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 React.createElement(_Cell.default, Object.assign({}, cell, {
ellipsis: column.ellipsis,
align: column.align,
component: CellComponent,
prefixCls: prefixCls,
key: columnsKey[cellIndex]
}, fixedInfo, {
additionalProps: additionalProps,
rowType: "header"
}));
}));
}
HeaderRow.displayName = 'HeaderRow';
var _default = HeaderRow;
exports.default = _default;