@@ -23,33 +23,36 @@ const TableCell = memo(function <T>({
23
23
prevWidth,
24
24
onExpanderClick
25
25
} : TableCellProps < T > ) {
26
- // cell style
26
+ // instance
27
+ const { frozen, contentClassname, contentStyle } = column ;
27
28
const style : React . CSSProperties = {
28
29
width : width || undefined ,
29
30
minWidth : width || undefined ,
30
- left : column . frozen ? prevWidth : undefined
31
+ left : frozen ? prevWidth : undefined
31
32
} ;
32
33
33
- // cell classname
34
- const cellClass = column . contentCellClassname
35
- ? typeof column . contentCellClassname === "string"
36
- ? column . contentCellClassname
37
- : column . contentCellClassname ( { row, index } )
38
- : null ;
39
-
40
34
// expander
41
35
if ( column . expander ) {
36
+ // cell classname
37
+ const cellClass =
38
+ typeof contentClassname === "function" ? contentClassname ( { row, index } ) : contentClassname ;
39
+
42
40
if ( typeof column . expander === "boolean" ) {
43
41
const Logo = isExpanded ? Minus : Plus ;
42
+ const cellStyle =
43
+ ( typeof contentStyle === "function" ? contentStyle ( { row, index } ) : contentStyle ) || { } ;
44
44
45
45
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
+ >
47
50
< Logo className = "rft-expander" onClick = { onExpanderClick } />
48
51
</ div >
49
52
) ;
50
53
}
51
54
52
- const frozenStyle : React . CSSProperties = column . frozen ? { position : "sticky" , zIndex : 2 } : { } ;
55
+ const frozenStyle : React . CSSProperties = frozen ? { position : "sticky" , zIndex : 2 } : { } ;
53
56
return (
54
57
< column . expander
55
58
row = { row }
@@ -63,6 +66,11 @@ const TableCell = memo(function <T>({
63
66
64
67
// basic styling
65
68
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 ) || { } ;
66
74
let content = ( row [ column . key as keyof T ] || null ) as React . ReactNode ;
67
75
if ( column . content ) {
68
76
if ( typeof column . content === "string" || typeof column . content === "number" ) {
@@ -73,7 +81,10 @@ const TableCell = memo(function <T>({
73
81
}
74
82
75
83
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
+ >
77
88
{ content }
78
89
</ div >
79
90
) ;
0 commit comments