1 line
12 KiB
JSON
1 line
12 KiB
JSON
|
{"ast":null,"code":"import _extends from \"@babel/runtime/helpers/esm/extends\";\nimport _objectSpread from \"@babel/runtime/helpers/esm/objectSpread2\";\nimport { useContext } from '@rc-component/context';\nimport classNames from 'classnames';\nimport * as React from 'react';\nimport { getCellProps } from \"../Body/BodyRow\";\nimport Cell from \"../Cell\";\nimport { GridContext } from \"./context\";\n/**\n * Return the width of the column by `colSpan`.\n * When `colSpan` is `0` will be trade as `1`.\n */\nexport function getColumnWidth(colIndex, colSpan, columnsOffset) {\n var mergedColSpan = colSpan || 1;\n return columnsOffset[colIndex + mergedColSpan] - (columnsOffset[colIndex] || 0);\n}\nfunction VirtualCell(props) {\n var rowInfo = props.rowInfo,\n column = props.column,\n colIndex = props.colIndex,\n indent = props.indent,\n index = props.index,\n component = props.component,\n renderIndex = props.renderIndex,\n record = props.record,\n style = props.style,\n className = props.className,\n inverse = props.inverse,\n getHeight = props.getHeight;\n var render = column.render,\n dataIndex = column.dataIndex,\n columnClassName = column.className,\n colWidth = column.width;\n var _useContext = useContext(GridContext, ['columnsOffset']),\n columnsOffset = _useContext.columnsOffset;\n var _getCellProps = getCellProps(rowInfo, column, colIndex, indent, index),\n key = _getCellProps.key,\n fixedInfo = _getCellProps.fixedInfo,\n appendCellNode = _getCellProps.appendCellNode,\n additionalCellProps = _getCellProps.additionalCellProps;\n var cellStyle = additionalCellProps.style,\n _additionalCellProps$ = additionalCellProps.colSpan,\n colSpan = _additionalCellProps$ === void 0 ? 1 : _additionalCellProps$,\n _additionalCellProps$2 = additionalCellProps.rowSpan,\n rowSpan = _additionalCellProps$2 === void 0 ? 1 : _additionalCellProps$2;\n\n // ========================= ColWidth =========================\n // column width\n var startColIndex = colIndex - 1;\n var concatColWidth = getColumnWidth(startColIndex, colSpan, columnsOffset);\n\n // margin offset\n var marginOffset = colSpan > 1 ? colWidth - concatColWidth : 0;\n\n // ========================== Style ===========================\n var mergedStyle = _objectSpread(_objectSpread(_objectSpread({}, cellStyle), style), {}, {\n flex: \"0 0 \".concat(concatColWidth, \"px\"),\n width: \"\".concat(concatColWidth, \"px\"),\n marginRight: marginOffset,\n pointerEvents: 'auto'\n });\n\n // When `colSpan` or `rowSpan` is `0`, should skip render.\n var needHide = React.useMemo(function () {\n if (inverse) {\n return rowSpan <= 1;\n } else {\n return colSpan === 0 || rowSpan === 0 || rowSpan > 1;\n }\n }, [rowSpan, colSpan, inverse]);\n\n // 0 rowSpan or colSpan should not render\n if (needHide) {\n mergedStyle.visibility = 'hidden';\n } else if (inverse) {\n mergedStyle.height = getHeight === null || getHeight === void 0 ? void 0 : getHeight(rowSpan);\n }\n var mergedRender = needHide ? function () {\n return null;\n } : render;\n\n // ========================== Render ==========================\n var cellSpan = {};\n\n // Virtual should reset `colSpan` & `rowSpan`\n if (rowSpan === 0 || colSpan === 0) {\n cellSpan.rowSpan = 1;\n cellSpan.colSpan = 1;\n }\n return /*#__PURE__*/React.createElement(Cell, _extends({\n className: classNames(columnClassName, className),\n ellipsis: column.ellipsis,\n align: column.align,\n scope: column.rowScope,\n component: component,\n prefixCls: rowInfo.prefixCls,\n key: key,\n record: record,\n index: index,\n renderIndex: renderIndex,\n dataIndex: dataIndex,\n render: mergedRender,\n shouldCellUpdate: column.shouldCellUpdate\n }, fixedInfo, {\n appendNode: appendCellNode,\n additionalProps: _objectSpread(_objectSpread({}, additionalCellProps), {}, {\n style: mergedStyle\n }, cellSpan)\n }));\n}\nexport default VirtualCell;","map":{"version":3,"names":["_
|