@@ -2,23 +2,25 @@ import * as React from 'react';
2
2
import ResizeObserver from 'rc-resize-observer' ;
3
3
import MeasureCell from './MeasureCell' ;
4
4
import isVisible from 'rc-util/lib/Dom/isVisible' ;
5
+ import type { ColumnType } from '../interface' ;
5
6
6
- export interface MeasureCellProps {
7
+ export interface MeasureRowProps {
7
8
prefixCls : string ;
8
9
onColumnResize : ( key : React . Key , width : number ) => void ;
9
10
columnsKey : React . Key [ ] ;
11
+ columns : readonly ColumnType < any > [ ] ;
10
12
}
11
13
12
- export default function MeasureRow ( { prefixCls, columnsKey, onColumnResize } : MeasureCellProps ) {
14
+ export default function MeasureRow ( {
15
+ prefixCls,
16
+ columnsKey,
17
+ onColumnResize,
18
+ columns,
19
+ } : MeasureRowProps ) {
13
20
const ref = React . useRef < HTMLTableRowElement > ( null ) ;
14
21
15
22
return (
16
- < tr
17
- aria-hidden = "true"
18
- className = { `${ prefixCls } -measure-row` }
19
- style = { { height : 0 , fontSize : 0 } }
20
- ref = { ref }
21
- >
23
+ < tr aria-hidden = "true" className = { `${ prefixCls } -measure-row` } style = { { height : 0 } } ref = { ref } >
22
24
< ResizeObserver . Collection
23
25
onBatchResize = { infoList => {
24
26
if ( isVisible ( ref . current ) ) {
@@ -28,9 +30,17 @@ export default function MeasureRow({ prefixCls, columnsKey, onColumnResize }: Me
28
30
}
29
31
} }
30
32
>
31
- { columnsKey . map ( columnKey => (
32
- < MeasureCell key = { columnKey } columnKey = { columnKey } onColumnResize = { onColumnResize } />
33
- ) ) }
33
+ { columnsKey . map ( columnKey => {
34
+ const column = columns . find ( col => col . key === columnKey ) ;
35
+ return (
36
+ < MeasureCell
37
+ key = { columnKey }
38
+ columnKey = { columnKey }
39
+ onColumnResize = { onColumnResize }
40
+ column = { column }
41
+ />
42
+ ) ;
43
+ } ) }
34
44
</ ResizeObserver . Collection >
35
45
</ tr >
36
46
) ;
0 commit comments