@@ -7,31 +7,42 @@ 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 ;
17
20
18
21
/** Render cell only when it has `rowSpan > 1` */
19
22
extra ?: boolean ;
20
23
getHeight ?: ( rowSpan : number ) => number ;
21
24
}
22
25
23
26
const BodyLine = React . forwardRef < HTMLDivElement , BodyLineProps > ( ( props , ref ) => {
24
- const { data, index, className, rowKey, style, extra, getHeight, ...restProps } = props ;
27
+ const { data, index, className, rowKey, style, extra, getHeight, scrollLeft, ...restProps } =
28
+ props ;
25
29
const { record, indent, index : renderIndex } = data ;
26
30
27
31
const { scrollX, flattenColumns, prefixCls, fixColumn, componentWidth } = useContext (
28
32
TableContext ,
29
33
[ 'prefixCls' , 'flattenColumns' , 'fixColumn' , 'componentWidth' , 'scrollX' ] ,
30
34
) ;
31
- const { getComponent } = useContext ( StaticContext , [ 'getComponent' ] ) ;
35
+ const { getComponent, horizontalVirtual } = useContext ( StaticContext , [
36
+ 'getComponent' ,
37
+ 'horizontalVirtual' ,
38
+ ] ) ;
32
39
33
40
const rowInfo = useRowInfo ( record , rowKey , index , indent ) ;
34
41
42
+ const cellPropsCollections = flattenColumns . map ( ( column , colIndex ) =>
43
+ getCellProps ( rowInfo , column , colIndex , indent , index ) ,
44
+ ) ;
45
+
35
46
const RowComponent = getComponent ( [ 'body' , 'row' ] , 'div' ) ;
36
47
const cellComponent = getComponent ( [ 'body' , 'cell' ] , 'div' ) ;
37
48
@@ -87,6 +98,16 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
87
98
rowStyle . pointerEvents = 'none' ;
88
99
}
89
100
101
+ const shareCellProps = {
102
+ index,
103
+ renderIndex,
104
+ inverse : extra ,
105
+ record,
106
+ rowInfo,
107
+ component : cellComponent ,
108
+ getHeight,
109
+ } ;
110
+
90
111
const rowNode = (
91
112
< RowComponent
92
113
{ ...rowProps }
@@ -98,23 +119,23 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
98
119
} ) }
99
120
style = { { ...rowStyle , ...rowProps ?. style } }
100
121
>
101
- { flattenColumns . map ( ( column , colIndex ) => {
102
- return (
122
+ { horizontalVirtual ? (
123
+ < VirtualRow
124
+ cellPropsCollections = { cellPropsCollections }
125
+ scrollLeft = { scrollLeft }
126
+ { ...shareCellProps }
127
+ />
128
+ ) : (
129
+ flattenColumns . map ( ( column , colIndex ) => (
103
130
< VirtualCell
104
131
key = { colIndex }
105
- component = { cellComponent }
106
- rowInfo = { rowInfo }
107
132
column = { column }
108
133
colIndex = { colIndex }
109
- indent = { indent }
110
- index = { index }
111
- renderIndex = { renderIndex }
112
- record = { record }
113
- inverse = { extra }
114
- getHeight = { getHeight }
134
+ cellProps = { cellPropsCollections [ colIndex ] }
135
+ { ...shareCellProps }
115
136
/>
116
- ) ;
117
- } ) }
137
+ ) )
138
+ ) }
118
139
</ RowComponent >
119
140
) ;
120
141
0 commit comments