@@ -23,33 +23,36 @@ const TableCell = memo(function <T>({
2323 prevWidth,
2424 onExpanderClick
2525} : TableCellProps < T > ) {
26- // cell style
26+ // instance
27+ const { frozen, contentClassname, contentStyle } = column ;
2728 const style : React . CSSProperties = {
2829 width : width || undefined ,
2930 minWidth : width || undefined ,
30- left : column . frozen ? prevWidth : undefined
31+ left : frozen ? prevWidth : undefined
3132 } ;
3233
33- // cell classname
34- const cellClass = column . contentCellClassname
35- ? typeof column . contentCellClassname === "string"
36- ? column . contentCellClassname
37- : column . contentCellClassname ( { row, index } )
38- : null ;
39-
4034 // expander
4135 if ( column . expander ) {
36+ // cell classname
37+ const cellClass =
38+ typeof contentClassname === "function" ? contentClassname ( { row, index } ) : contentClassname ;
39+
4240 if ( typeof column . expander === "boolean" ) {
4341 const Logo = isExpanded ? Minus : Plus ;
42+ const cellStyle =
43+ ( typeof contentStyle === "function" ? contentStyle ( { row, index } ) : contentStyle ) || { } ;
4444
4545 return (
46- < div className = { cx ( "rft-cell" , column . frozen && "frozen" , cellClass ) } style = { style } >
46+ < div
47+ className = { cx ( "rft-cell" , frozen && "frozen" , cellClass ) }
48+ style = { { ...cellStyle , ...style } }
49+ >
4750 < Logo className = "rft-expander" onClick = { onExpanderClick } />
4851 </ div >
4952 ) ;
5053 }
5154
52- const frozenStyle : React . CSSProperties = column . frozen ? { position : "sticky" , zIndex : 2 } : { } ;
55+ const frozenStyle : React . CSSProperties = frozen ? { position : "sticky" , zIndex : 2 } : { } ;
5356 return (
5457 < column . expander
5558 row = { row }
@@ -63,6 +66,11 @@ const TableCell = memo(function <T>({
6366
6467 // basic styling
6568 if ( ! column . cell ) {
69+ // cell classname/style
70+ const cellClass =
71+ typeof contentClassname === "function" ? contentClassname ( { row, index } ) : contentClassname ;
72+ const cellStyle =
73+ ( typeof contentStyle === "function" ? contentStyle ( { row, index } ) : contentStyle ) || { } ;
6674 let content = ( row [ column . key as keyof T ] || null ) as React . ReactNode ;
6775 if ( column . content ) {
6876 if ( typeof column . content === "string" || typeof column . content === "number" ) {
@@ -73,7 +81,10 @@ const TableCell = memo(function <T>({
7381 }
7482
7583 return (
76- < div className = { cx ( "rft-cell" , column . frozen && "frozen" , cellClass ) } style = { style } >
84+ < div
85+ className = { cx ( "rft-cell" , frozen && "frozen" , cellClass ) }
86+ style = { { ...cellStyle , ...style } }
87+ >
7788 { content }
7889 </ div >
7990 ) ;
0 commit comments