@@ -7,31 +7,53 @@ 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 ;
20+ columnsWidth : [ key : React . Key , width : number , total : number ] [ ] ;
1721
1822 /** Render cell only when it has `rowSpan > 1` */
1923 extra ?: boolean ;
2024 getHeight ?: ( rowSpan : number ) => number ;
2125}
2226
2327const 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 ;
2540 const { record, indent, index : renderIndex } = data ;
2641
2742 const { scrollX, flattenColumns, prefixCls, fixColumn, componentWidth } = useContext (
2843 TableContext ,
2944 [ 'prefixCls' , 'flattenColumns' , 'fixColumn' , 'componentWidth' , 'scrollX' ] ,
3045 ) ;
31- const { getComponent } = useContext ( StaticContext , [ 'getComponent' ] ) ;
46+ const { getComponent, horizontalVirtual } = useContext ( StaticContext , [
47+ 'getComponent' ,
48+ 'horizontalVirtual' ,
49+ ] ) ;
3250
3351 const rowInfo = useRowInfo ( record , rowKey , index , indent ) ;
3452
53+ const cellPropsCollections = flattenColumns . map ( ( column , colIndex ) =>
54+ getCellProps ( rowInfo , column , colIndex , indent , index ) ,
55+ ) ;
56+
3557 const RowComponent = getComponent ( [ 'body' , 'row' ] , 'div' ) ;
3658 const cellComponent = getComponent ( [ 'body' , 'cell' ] , 'div' ) ;
3759
@@ -87,6 +109,16 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
87109 rowStyle . pointerEvents = 'none' ;
88110 }
89111
112+ const shareCellProps = {
113+ index,
114+ renderIndex,
115+ inverse : extra ,
116+ record,
117+ rowInfo,
118+ component : cellComponent ,
119+ getHeight,
120+ } ;
121+
90122 const rowNode = (
91123 < RowComponent
92124 { ...rowProps }
@@ -98,23 +130,23 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
98130 } ) }
99131 style = { { ...rowStyle , ...rowProps ?. style } }
100132 >
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 ) => (
103141 < VirtualCell
104142 key = { colIndex }
105- component = { cellComponent }
106- rowInfo = { rowInfo }
107143 column = { column }
108144 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 }
115147 />
116- ) ;
117- } ) }
148+ ) )
149+ ) }
118150 </ RowComponent >
119151 ) ;
120152
0 commit comments