File tree Expand file tree Collapse file tree 6 files changed +31
-2
lines changed Expand file tree Collapse file tree 6 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 1
1
# Change Log
2
2
3
+ ## 3.5.0
4
+ > Date: 2021-12-26
5
+ ### Added
6
+ - New prop ` rowClassName `
7
+
3
8
## 3.4.0
4
9
> Date: 2021-12-23
5
10
### Added
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " react-datasheet-grid" ,
3
- "version" : " 3.4 .0" ,
3
+ "version" : " 3.5 .0" ,
4
4
"description" : " An Excel-like React component to create beautiful spreadsheets." ,
5
5
"main" : " dist/index.js" ,
6
6
"types" : " dist/index.d.ts" ,
Original file line number Diff line number Diff line change @@ -85,6 +85,7 @@ export const DataSheetGrid = React.memo(
85
85
onBlur = DEFAULT_EMPTY_CALLBACK ,
86
86
onActiveCellChange = DEFAULT_EMPTY_CALLBACK ,
87
87
onSelectionChange = DEFAULT_EMPTY_CALLBACK ,
88
+ rowClassName,
88
89
} : DataSheetGridProps < T > ,
89
90
ref : React . ForwardedRef < DataSheetGridRef >
90
91
) : JSX . Element => {
@@ -1553,6 +1554,7 @@ export const DataSheetGrid = React.memo(
1553
1554
insertRowAfter,
1554
1555
stopEditing,
1555
1556
getContextMenuItems,
1557
+ rowClassName,
1556
1558
} )
1557
1559
1558
1560
const itemSize = useCallback (
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ const RowComponent = React.memo(
24
24
duplicateRows,
25
25
stopEditing,
26
26
getContextMenuItems,
27
+ rowClassName,
27
28
} : RowProps < any > ) => {
28
29
const firstRender = useFirstRender ( )
29
30
@@ -50,7 +51,16 @@ const RowComponent = React.memo(
50
51
} , [ insertRowAfter , index ] )
51
52
52
53
return (
53
- < div className = "dsg-row" style = { style } >
54
+ < div
55
+ className = { cx (
56
+ 'dsg-row' ,
57
+ typeof rowClassName === 'string' ? rowClassName : null ,
58
+ typeof rowClassName === 'function'
59
+ ? rowClassName ( { rowData : data , rowIndex : index } )
60
+ : null
61
+ ) }
62
+ style = { style }
63
+ >
54
64
{ columns . map ( ( column , i ) => {
55
65
const Component = column . component
56
66
@@ -153,6 +163,7 @@ export const Row = <T extends any>({
153
163
: undefined
154
164
}
155
165
getContextMenuItems = { data . getContextMenuItems }
166
+ rowClassName = { data . rowClassName }
156
167
/>
157
168
)
158
169
}
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export const StaticDataSheetGrid = React.forwardRef<
20
20
onBlur,
21
21
onActiveCellChange,
22
22
onSelectionChange,
23
+ rowClassName,
23
24
...rest
24
25
} : DataSheetGridProps < T > ,
25
26
ref : React . ForwardedRef < DataSheetGridRef >
@@ -36,6 +37,7 @@ export const StaticDataSheetGrid = React.forwardRef<
36
37
onBlur,
37
38
onActiveCellChange,
38
39
onSelectionChange,
40
+ rowClassName,
39
41
} )
40
42
41
43
return < DataSheetGrid { ...staticProps } { ...rest } ref = { ref } />
Original file line number Diff line number Diff line change @@ -64,6 +64,9 @@ export type ListItemData<T> = {
64
64
insertRowAfter : ( row : number , count ?: number ) => void
65
65
stopEditing : ( opts ?: { nextRow ?: boolean } ) => void
66
66
getContextMenuItems : ( ) => ContextMenuItem [ ]
67
+ rowClassName ?:
68
+ | string
69
+ | ( ( opt : { rowData : T ; rowIndex : number } ) => string | undefined )
67
70
}
68
71
69
72
export type HeaderContextType < T > = {
@@ -109,6 +112,9 @@ export type RowProps<T> = {
109
112
insertRowAfter : ( row : number , count ?: number ) => void
110
113
stopEditing ?: ( opts ?: { nextRow ?: boolean } ) => void
111
114
getContextMenuItems : ( ) => ContextMenuItem [ ]
115
+ rowClassName ?:
116
+ | string
117
+ | ( ( opt : { rowData : T ; rowIndex : number } ) => string | undefined )
112
118
}
113
119
114
120
export type SimpleColumn < T , C > = Partial <
@@ -151,6 +157,9 @@ export type DataSheetGridProps<T> = {
151
157
value ?: T [ ]
152
158
style ?: React . CSSProperties
153
159
className ?: string
160
+ rowClassName ?:
161
+ | string
162
+ | ( ( opt : { rowData : T ; rowIndex : number } ) => string | undefined )
154
163
onChange ?: ( value : T [ ] , operations : Operation [ ] ) => void
155
164
columns ?: Partial < Column < T , any > > [ ]
156
165
gutterColumn ?: SimpleColumn < T , any > | false
You can’t perform that action at this time.
0 commit comments