UNPKG

3.15 kBJavaScriptView Raw
1"use strict";
2
3var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4var _typeof = require("@babel/runtime/helpers/typeof");
5Object.defineProperty(exports, "__esModule", {
6 value: true
7});
8exports.default = void 0;
9var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10var React = _interopRequireWildcard(require("react"));
11var _Cell = _interopRequireDefault(require("../Cell"));
12var _TableContext = _interopRequireDefault(require("../context/TableContext"));
13var _context = require("@rc-component/context");
14var _fixUtil = require("../utils/fixUtil");
15var _valueUtil = require("../utils/valueUtil");
16function _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); }
17function _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; }
18var HeaderRow = function HeaderRow(props) {
19 var cells = props.cells,
20 stickyOffsets = props.stickyOffsets,
21 flattenColumns = props.flattenColumns,
22 RowComponent = props.rowComponent,
23 CellComponent = props.cellComponent,
24 onHeaderRow = props.onHeaderRow,
25 index = props.index;
26 var _useContext = (0, _context.useContext)(_TableContext.default, ['prefixCls', 'direction']),
27 prefixCls = _useContext.prefixCls,
28 direction = _useContext.direction;
29 var rowProps;
30 if (onHeaderRow) {
31 rowProps = onHeaderRow(cells.map(function (cell) {
32 return cell.column;
33 }), index);
34 }
35 var columnsKey = (0, _valueUtil.getColumnsKey)(cells.map(function (cell) {
36 return cell.column;
37 }));
38 return /*#__PURE__*/React.createElement(RowComponent, rowProps, cells.map(function (cell, cellIndex) {
39 var column = cell.column;
40 var fixedInfo = (0, _fixUtil.getCellFixedInfo)(cell.colStart, cell.colEnd, flattenColumns, stickyOffsets, direction);
41 var additionalProps;
42 if (column && column.onHeaderCell) {
43 additionalProps = cell.column.onHeaderCell(column);
44 }
45 return /*#__PURE__*/React.createElement(_Cell.default, (0, _extends2.default)({}, cell, {
46 scope: column.title ? cell.colSpan > 1 ? 'colgroup' : 'col' : null,
47 ellipsis: column.ellipsis,
48 align: column.align,
49 component: CellComponent,
50 prefixCls: prefixCls,
51 key: columnsKey[cellIndex]
52 }, fixedInfo, {
53 additionalProps: additionalProps,
54 rowType: "header"
55 }));
56 }));
57};
58if (process.env.NODE_ENV !== 'production') {
59 HeaderRow.displayName = 'HeaderRow';
60}
61var _default = exports.default = HeaderRow;
\No newline at end of file