1
+ import { useContext } from '@rc-component/context' ;
2
+ import classNames from 'classnames' ;
1
3
import * as React from 'react' ;
2
4
import { getCellProps } from '../Body/BodyRow' ;
3
5
import Cell from '../Cell' ;
6
+ import type useRowInfo from '../hooks/useRowInfo' ;
4
7
import type { ColumnType } from '../interface' ;
5
- import classNames from 'classnames' ;
6
- import { useContext } from '@rc-component/context' ;
7
8
import { GridContext } from './context' ;
8
- import type useRowInfo from '../hooks/useRowInfo' ;
9
9
10
- export interface VirtualCellProps < RecordType extends { index : number } > {
10
+ export interface VirtualCellProps < RecordType > {
11
11
rowInfo : ReturnType < typeof useRowInfo > ;
12
12
column : ColumnType < RecordType > ;
13
13
colIndex : number ;
14
14
indent : number ;
15
15
index : number ;
16
+ /** Used for `column.render` */
17
+ renderIndex : number ;
16
18
record : RecordType ;
17
19
18
20
// Follow props is used for RowSpanVirtualCell only
@@ -33,11 +35,20 @@ export function getColumnWidth(colIndex: number, colSpan: number, columnsOffset:
33
35
return columnsOffset [ colIndex + mergedColSpan ] - ( columnsOffset [ colIndex ] || 0 ) ;
34
36
}
35
37
36
- function VirtualCell < RecordType extends { index : number } = any > (
37
- props : VirtualCellProps < RecordType > ,
38
- ) {
39
- const { rowInfo, column, colIndex, indent, index, record, style, className, inverse, getHeight } =
40
- props ;
38
+ function VirtualCell < RecordType = any > ( props : VirtualCellProps < RecordType > ) {
39
+ const {
40
+ rowInfo,
41
+ column,
42
+ colIndex,
43
+ indent,
44
+ index,
45
+ renderIndex,
46
+ record,
47
+ style,
48
+ className,
49
+ inverse,
50
+ getHeight,
51
+ } = props ;
41
52
42
53
const { render, dataIndex, className : columnClassName , width : colWidth } = column ;
43
54
@@ -108,7 +119,7 @@ function VirtualCell<RecordType extends { index: number } = any>(
108
119
key = { key }
109
120
record = { record }
110
121
index = { index }
111
- renderIndex = { record . index }
122
+ renderIndex = { renderIndex }
112
123
dataIndex = { dataIndex }
113
124
render = { mergedRender }
114
125
shouldCellUpdate = { column . shouldCellUpdate }
0 commit comments