"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _typeof = require("@babel/runtime/helpers/typeof"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = SummaryCell; 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 _SummaryContext = _interopRequireDefault(require("./SummaryContext")); function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } function SummaryCell(_ref) { var className = _ref.className, index = _ref.index, children = _ref.children, _ref$colSpan = _ref.colSpan, colSpan = _ref$colSpan === void 0 ? 1 : _ref$colSpan, rowSpan = _ref.rowSpan, align = _ref.align; var _useContext = (0, _context.useContext)(_TableContext.default, ['prefixCls', 'direction']), prefixCls = _useContext.prefixCls, direction = _useContext.direction; var _React$useContext = React.useContext(_SummaryContext.default), scrollColumnIndex = _React$useContext.scrollColumnIndex, stickyOffsets = _React$useContext.stickyOffsets, flattenColumns = _React$useContext.flattenColumns, columns = _React$useContext.columns; var lastIndex = index + colSpan - 1; var mergedColSpan = lastIndex + 1 === scrollColumnIndex ? colSpan + 1 : colSpan; var fixedInfo = (0, _fixUtil.getCellFixedInfo)(index, index + mergedColSpan - 1, flattenColumns, stickyOffsets, direction, columns === null || columns === void 0 ? void 0 : columns[index]); return /*#__PURE__*/React.createElement(_Cell.default, (0, _extends2.default)({ className: className, index: index, component: "td", prefixCls: prefixCls, record: null, dataIndex: null, align: align, colSpan: mergedColSpan, rowSpan: rowSpan, render: function render() { return children; } }, fixedInfo)); }