-
-
Notifications
You must be signed in to change notification settings - Fork 619
Expand file tree
/
Copy pathCell.tsx
More file actions
54 lines (50 loc) · 1.33 KB
/
Cell.tsx
File metadata and controls
54 lines (50 loc) · 1.33 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
import * as React from 'react';
import Cell from '../Cell';
import TableContext from '../context/TableContext';
import { useContext } from '@rc-component/context';
import type { AlignType } from '../interface';
import { getCellFixedInfo } from '../utils/fixUtil';
import SummaryContext from './SummaryContext';
export interface SummaryCellProps {
className?: string;
children?: React.ReactNode;
index: number;
colSpan?: number;
rowSpan?: number;
align?: AlignType;
}
export default function SummaryCell({
className,
index,
children,
colSpan = 1,
rowSpan,
align,
}: SummaryCellProps) {
const { prefixCls, direction } = useContext(TableContext, ['prefixCls', 'direction']);
const { scrollColumnIndex, stickyOffsets, flattenColumns } = React.useContext(SummaryContext);
const lastIndex = index + colSpan - 1;
const mergedColSpan = lastIndex + 1 === scrollColumnIndex ? colSpan + 1 : colSpan;
const fixedInfo = getCellFixedInfo(
index,
index + mergedColSpan - 1,
flattenColumns,
stickyOffsets,
direction,
);
return (
<Cell
className={className}
rowIndex={index}
component="td"
prefixCls={prefixCls}
record={null}
dataIndex={null}
align={align}
colSpan={mergedColSpan}
rowSpan={rowSpan}
render={() => children}
{...fixedInfo}
/>
);
}