1- import classNames from 'classnames' ;
1+ import cls from 'classnames' ;
22import * as React from 'react' ;
33import Cell from '../Cell' ;
4- import { responseImmutable } from '../context/TableContext' ;
4+ import { useContext } from '@rc-component/context' ;
5+ import TableContext , { responseImmutable } from '../context/TableContext' ;
56import devRenderTimes from '../hooks/useRenderTimes' ;
67import useRowInfo from '../hooks/useRowInfo' ;
78import type { ColumnType , CustomizeComponent } from '../interface' ;
@@ -19,6 +20,7 @@ export interface BodyRowProps<RecordType> {
1920 scopeCellComponent : CustomizeComponent ;
2021 indent ?: number ;
2122 rowKey : React . Key ;
23+ rowType ?: 'header' | 'body' | 'footer' ;
2224}
2325
2426// ==================================================================================
@@ -90,7 +92,6 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
9092 if ( process . env . NODE_ENV !== 'production' ) {
9193 devRenderTimes ( props ) ;
9294 }
93-
9495 const {
9596 className,
9697 style,
@@ -102,7 +103,11 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
102103 rowComponent : RowComponent ,
103104 cellComponent,
104105 scopeCellComponent,
106+ rowType,
105107 } = props ;
108+ const { classNames, styles } = useContext ( TableContext , [ 'classNames' , 'styles' ] ) ;
109+ const { body : bodyCls , header : headerCls } = classNames || { } ;
110+ const { body : bodyStyles , header : headerStyles } = styles || { } ;
106111 const rowInfo = useRowInfo ( record , rowKey , index , indent ) ;
107112 const {
108113 prefixCls,
@@ -133,16 +138,23 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
133138 < RowComponent
134139 { ...rowProps }
135140 data-row-key = { rowKey }
136- className = { classNames (
141+ className = { cls (
137142 className ,
138143 `${ prefixCls } -row` ,
139144 `${ prefixCls } -row-level-${ indent } ` ,
140145 rowProps ?. className ,
141146 {
147+ [ headerCls ?. row ] : headerCls ?. row && rowType === 'header' ,
148+ [ bodyCls ?. row ] : bodyCls ?. row && rowType === 'body' ,
142149 [ expandedClsName ] : indent >= 1 ,
143150 } ,
144151 ) }
145- style = { { ...style , ...rowProps ?. style } }
152+ style = { {
153+ ...style ,
154+ ...rowProps ?. style ,
155+ ...( rowType === 'header' && headerStyles ?. row ) ,
156+ ...( rowType === 'body' && bodyStyles ?. row ) ,
157+ } }
146158 >
147159 { flattenColumns . map ( ( column : ColumnType < RecordType > , colIndex ) => {
148160 const { render, dataIndex, className : columnClassName } = column ;
@@ -157,6 +169,7 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
157169
158170 return (
159171 < Cell < RecordType >
172+ rowType = "body"
160173 className = { columnClassName }
161174 ellipsis = { column . ellipsis }
162175 align = { column . align }
@@ -187,7 +200,7 @@ function BodyRow<RecordType extends { children?: readonly RecordType[] }>(
187200 expandRowNode = (
188201 < ExpandedRow
189202 expanded = { expanded }
190- className = { classNames (
203+ className = { cls (
191204 `${ prefixCls } -expanded-row` ,
192205 `${ prefixCls } -expanded-row-level-${ indent + 1 } ` ,
193206 expandedClsName ,
0 commit comments