@@ -7,31 +7,42 @@ import type { FlattenData } from '../hooks/useFlattenRecords';
77import useRowInfo from '../hooks/useRowInfo' ;
88import VirtualCell from './VirtualCell' ;
99import { StaticContext } from './context' ;
10+ import { getCellProps } from '../Body/BodyRow' ;
11+ import VirtualRow from './VirtualRow' ;
1012
1113export interface BodyLineProps < RecordType = any > {
1214 data : FlattenData < RecordType > ;
1315 index : number ;
1416 className ?: string ;
1517 style ?: React . CSSProperties ;
1618 rowKey : React . Key ;
19+ scrollLeft : number ;
1720
1821 /** Render cell only when it has `rowSpan > 1` */
1922 extra ?: boolean ;
2023 getHeight ?: ( rowSpan : number ) => number ;
2124}
2225
2326const 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 ;
2529 const { record, indent, index : renderIndex } = data ;
2630
2731 const { scrollX, flattenColumns, prefixCls, fixColumn, componentWidth } = useContext (
2832 TableContext ,
2933 [ 'prefixCls' , 'flattenColumns' , 'fixColumn' , 'componentWidth' , 'scrollX' ] ,
3034 ) ;
31- const { getComponent } = useContext ( StaticContext , [ 'getComponent' ] ) ;
35+ const { getComponent, horizontalVirtual } = useContext ( StaticContext , [
36+ 'getComponent' ,
37+ 'horizontalVirtual' ,
38+ ] ) ;
3239
3340 const rowInfo = useRowInfo ( record , rowKey , index , indent ) ;
3441
42+ const cellPropsCollections = flattenColumns . map ( ( column , colIndex ) =>
43+ getCellProps ( rowInfo , column , colIndex , indent , index ) ,
44+ ) ;
45+
3546 const RowComponent = getComponent ( [ 'body' , 'row' ] , 'div' ) ;
3647 const cellComponent = getComponent ( [ 'body' , 'cell' ] , 'div' ) ;
3748
@@ -87,6 +98,16 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
8798 rowStyle . pointerEvents = 'none' ;
8899 }
89100
101+ const shareCellProps = {
102+ index,
103+ renderIndex,
104+ inverse : extra ,
105+ record,
106+ rowInfo,
107+ component : cellComponent ,
108+ getHeight,
109+ } ;
110+
90111 const rowNode = (
91112 < RowComponent
92113 { ...rowProps }
@@ -98,23 +119,23 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
98119 } ) }
99120 style = { { ...rowStyle , ...rowProps ?. style } }
100121 >
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 ) => (
103130 < VirtualCell
104131 key = { colIndex }
105- component = { cellComponent }
106- rowInfo = { rowInfo }
107132 column = { column }
108133 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 }
115136 />
116- ) ;
117- } ) }
137+ ) )
138+ ) }
118139 </ RowComponent >
119140 ) ;
120141
0 commit comments