UNPKG

2.8 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 = SummaryCell;
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 _SummaryContext = _interopRequireDefault(require("./SummaryContext"));
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; }
18function SummaryCell(_ref) {
19 var className = _ref.className,
20 index = _ref.index,
21 children = _ref.children,
22 _ref$colSpan = _ref.colSpan,
23 colSpan = _ref$colSpan === void 0 ? 1 : _ref$colSpan,
24 rowSpan = _ref.rowSpan,
25 align = _ref.align;
26 var _useContext = (0, _context.useContext)(_TableContext.default, ['prefixCls', 'direction']),
27 prefixCls = _useContext.prefixCls,
28 direction = _useContext.direction;
29 var _React$useContext = React.useContext(_SummaryContext.default),
30 scrollColumnIndex = _React$useContext.scrollColumnIndex,
31 stickyOffsets = _React$useContext.stickyOffsets,
32 flattenColumns = _React$useContext.flattenColumns;
33 var lastIndex = index + colSpan - 1;
34 var mergedColSpan = lastIndex + 1 === scrollColumnIndex ? colSpan + 1 : colSpan;
35 var fixedInfo = (0, _fixUtil.getCellFixedInfo)(index, index + mergedColSpan - 1, flattenColumns, stickyOffsets, direction);
36 return /*#__PURE__*/React.createElement(_Cell.default, (0, _extends2.default)({
37 className: className,
38 index: index,
39 component: "td",
40 prefixCls: prefixCls,
41 record: null,
42 dataIndex: null,
43 align: align,
44 colSpan: mergedColSpan,
45 rowSpan: rowSpan,
46 render: function render() {
47 return children;
48 }
49 }, fixedInfo));
50}
\No newline at end of file