-
-
Notifications
You must be signed in to change notification settings - Fork 619
Expand file tree
/
Copy pathVirtualRow.tsx
More file actions
44 lines (40 loc) · 1.29 KB
/
VirtualRow.tsx
File metadata and controls
44 lines (40 loc) · 1.29 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
import * as React from 'react';
import { useContext } from '@rc-component/context';
import TableContext from '../context/TableContext';
import useHorizontalVirtual from './useHorizontalVirtual';
import type { getCellProps } from '../Body/BodyRow';
import VirtualCell from './VirtualCell';
import type useRowInfo from '../hooks/useRowInfo';
import type { CustomizeComponent } from '../interface';
export interface VirtualRowProps {
cellPropsCollections: ReturnType<typeof getCellProps>[];
offsetX: number;
index: number;
renderIndex: number;
inverse: boolean;
record: any;
rowInfo: ReturnType<typeof useRowInfo>;
component: CustomizeComponent;
getHeight: (rowSpan: number) => number;
}
export default function VirtualRow({
cellPropsCollections,
offsetX,
...restProps
}: VirtualRowProps) {
const { flattenColumns } = useContext(TableContext, ['flattenColumns']);
const [startIndex, virtualOffset, showColumnIndexes] = useHorizontalVirtual(
cellPropsCollections,
offsetX,
);
return showColumnIndexes.map(colIndex => (
<VirtualCell
key={colIndex}
column={flattenColumns[colIndex]}
colIndex={colIndex}
style={startIndex === colIndex ? { marginLeft: virtualOffset } : {}}
cellProps={cellPropsCollections[colIndex]}
{...restProps}
/>
));
}