@@ -7,31 +7,53 @@ import type { FlattenData } from '../hooks/useFlattenRecords';
7
7
import useRowInfo from '../hooks/useRowInfo' ;
8
8
import VirtualCell from './VirtualCell' ;
9
9
import { StaticContext } from './context' ;
10
+ import { getCellProps } from '../Body/BodyRow' ;
11
+ import VirtualRow from './VirtualRow' ;
10
12
11
13
export interface BodyLineProps < RecordType = any > {
12
14
data : FlattenData < RecordType > ;
13
15
index : number ;
14
16
className ?: string ;
15
17
style ?: React . CSSProperties ;
16
18
rowKey : React . Key ;
19
+ scrollLeft : number ;
20
+ columnsWidth : [ key : React . Key , width : number , total : number ] [ ] ;
17
21
18
22
/** Render cell only when it has `rowSpan > 1` */
19
23
extra ?: boolean ;
20
24
getHeight ?: ( rowSpan : number ) => number ;
21
25
}
22
26
23
27
const BodyLine = React . forwardRef < HTMLDivElement , BodyLineProps > ( ( props , ref ) => {
24
- const { data, index, className, rowKey, style, extra, getHeight, ...restProps } = props ;
28
+ const {
29
+ data,
30
+ index,
31
+ className,
32
+ rowKey,
33
+ style,
34
+ extra,
35
+ getHeight,
36
+ scrollLeft,
37
+ columnsWidth,
38
+ ...restProps
39
+ } = props ;
25
40
const { record, indent, index : renderIndex } = data ;
26
41
27
42
const { scrollX, flattenColumns, prefixCls, fixColumn, componentWidth } = useContext (
28
43
TableContext ,
29
44
[ 'prefixCls' , 'flattenColumns' , 'fixColumn' , 'componentWidth' , 'scrollX' ] ,
30
45
) ;
31
- const { getComponent } = useContext ( StaticContext , [ 'getComponent' ] ) ;
46
+ const { getComponent, horizontalVirtual } = useContext ( StaticContext , [
47
+ 'getComponent' ,
48
+ 'horizontalVirtual' ,
49
+ ] ) ;
32
50
33
51
const rowInfo = useRowInfo ( record , rowKey , index , indent ) ;
34
52
53
+ const cellPropsCollections = flattenColumns . map ( ( column , colIndex ) =>
54
+ getCellProps ( rowInfo , column , colIndex , indent , index ) ,
55
+ ) ;
56
+
35
57
const RowComponent = getComponent ( [ 'body' , 'row' ] , 'div' ) ;
36
58
const cellComponent = getComponent ( [ 'body' , 'cell' ] , 'div' ) ;
37
59
@@ -87,6 +109,16 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
87
109
rowStyle . pointerEvents = 'none' ;
88
110
}
89
111
112
+ const shareCellProps = {
113
+ index,
114
+ renderIndex,
115
+ inverse : extra ,
116
+ record,
117
+ rowInfo,
118
+ component : cellComponent ,
119
+ getHeight,
120
+ } ;
121
+
90
122
const rowNode = (
91
123
< RowComponent
92
124
{ ...rowProps }
@@ -98,23 +130,23 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
98
130
} ) }
99
131
style = { { ...rowStyle , ...rowProps ?. style } }
100
132
>
101
- { flattenColumns . map ( ( column , colIndex ) => {
102
- return (
133
+ { horizontalVirtual ? (
134
+ < VirtualRow
135
+ cellPropsCollections = { cellPropsCollections }
136
+ scrollLeft = { scrollLeft }
137
+ { ...shareCellProps }
138
+ />
139
+ ) : (
140
+ flattenColumns . map ( ( column , colIndex ) => (
103
141
< VirtualCell
104
142
key = { colIndex }
105
- component = { cellComponent }
106
- rowInfo = { rowInfo }
107
143
column = { column }
108
144
colIndex = { colIndex }
109
- indent = { indent }
110
- index = { index }
111
- renderIndex = { renderIndex }
112
- record = { record }
113
- inverse = { extra }
114
- getHeight = { getHeight }
145
+ cellProps = { cellPropsCollections [ colIndex ] }
146
+ { ...shareCellProps }
115
147
/>
116
- ) ;
117
- } ) }
148
+ ) )
149
+ ) }
118
150
</ RowComponent >
119
151
) ;
120
152
0 commit comments