File tree Expand file tree Collapse file tree 4 files changed +20
-4
lines changed Expand file tree Collapse file tree 4 files changed +20
-4
lines changed Original file line number Diff line number Diff line change @@ -421,6 +421,11 @@ const App: React.FC = () => {
421
421
return < div > Custom Pagination </ div > ;
422
422
} ;
423
423
424
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
425
+ const renderCustomExpandButton = ( ) => {
426
+ return < div > ➡</ div > ;
427
+ } ;
428
+
424
429
return (
425
430
< div className = "app" style = { { backgroundColor : theme . colors ?. background } } >
426
431
< header
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ interface MultiLevelTableProps {
42
42
sortable ?: boolean ;
43
43
ascendingIcon ?: React . ReactNode ;
44
44
descendingIcon ?: React . ReactNode ;
45
+ expandIcon ?: React . ReactNode ;
45
46
}
46
47
47
48
/**
@@ -59,6 +60,7 @@ export const MultiLevelTable: React.FC<MultiLevelTableProps> = ({
59
60
sortable = false ,
60
61
ascendingIcon,
61
62
descendingIcon,
63
+ expandIcon,
62
64
} ) => {
63
65
const mergedTheme = mergeThemeProps ( defaultThemeProps , theme ) ;
64
66
const [ filterInput , setFilterInput ] = useState ( "" ) ;
@@ -184,6 +186,7 @@ export const MultiLevelTable: React.FC<MultiLevelTableProps> = ({
184
186
onToggle = { ( ) => hasChildren && toggleRow ( child . id ) }
185
187
level = { level }
186
188
theme = { mergedTheme }
189
+ expandIcon = { expandIcon }
187
190
/>
188
191
{ renderNestedRows ( child . id , level + 1 ) }
189
192
</ React . Fragment >
@@ -216,6 +219,7 @@ export const MultiLevelTable: React.FC<MultiLevelTableProps> = ({
216
219
isExpanded = { expandedRows . has ( parentId ) }
217
220
onToggle = { ( ) => hasChildren && toggleRow ( parentId ) }
218
221
theme = { mergedTheme }
222
+ expandIcon = { expandIcon }
219
223
/>
220
224
{ renderNestedRows ( parentId ) }
221
225
</ React . Fragment >
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import '../styles/TableCell.css';
18
18
* @property {() => void } onToggle - Function to toggle row expansion
19
19
* @property {number } [paddingLeft=0] - Left padding for nested cells
20
20
* @property {ThemeProps } theme - Theme properties
21
+ * @property {React.ReactNode } [expandIcon] - Custom expand icon
21
22
*/
22
23
interface TableCellProps {
23
24
cell : Cell < DataItem > ;
@@ -26,6 +27,7 @@ interface TableCellProps {
26
27
onToggle : ( ) => void ;
27
28
paddingLeft ?: number ;
28
29
theme : ThemeProps ;
30
+ expandIcon ?: React . ReactNode ;
29
31
}
30
32
31
33
/**
@@ -40,7 +42,8 @@ export const TableCell: React.FC<TableCellProps> = ({
40
42
isExpanded,
41
43
onToggle,
42
44
paddingLeft = 0 ,
43
- theme
45
+ theme,
46
+ expandIcon,
44
47
} ) => {
45
48
const { key, ...cellProps } = cell . getCellProps ( ) ;
46
49
@@ -76,7 +79,7 @@ export const TableCell: React.FC<TableCellProps> = ({
76
79
alignItems : 'center' ,
77
80
} }
78
81
>
79
- < ExpandIcon isExpanded = { isExpanded } theme = { theme } />
82
+ { expandIcon || < ExpandIcon isExpanded = { isExpanded } theme = { theme } /> }
80
83
</ button >
81
84
) }
82
85
{ cell . render ( 'Cell' ) }
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import '../styles/TableRow.css';
19
19
* @property {() => void } onToggle - Function to toggle row expansion
20
20
* @property {number } [level=0] - Nesting level of the row
21
21
* @property {ThemeProps } theme - Theme properties
22
+ * @property {React.ReactNode } [expandIcon] - Custom expand icon
22
23
*/
23
24
interface TableRowProps {
24
25
row : Row < DataItem > | DataItem ;
@@ -28,6 +29,7 @@ interface TableRowProps {
28
29
onToggle : ( ) => void ;
29
30
level ?: number ;
30
31
theme : ThemeProps ;
32
+ expandIcon ?: React . ReactNode ;
31
33
}
32
34
33
35
/**
@@ -43,7 +45,8 @@ export const TableRow: React.FC<TableRowProps> = ({
43
45
isExpanded,
44
46
onToggle,
45
47
level = 0 ,
46
- theme
48
+ theme,
49
+ expandIcon,
47
50
} ) => {
48
51
const getRowClassName = ( ) => {
49
52
const classes = [ 'table-row' ] ;
@@ -91,7 +94,7 @@ export const TableRow: React.FC<TableRowProps> = ({
91
94
} }
92
95
style = { { cursor : 'pointer' , marginRight : '8px' } }
93
96
>
94
- < ExpandIcon isExpanded = { isExpanded } theme = { theme } />
97
+ { expandIcon || < ExpandIcon isExpanded = { isExpanded } theme = { theme } /> }
95
98
</ span >
96
99
) }
97
100
{ column . render
@@ -125,6 +128,7 @@ export const TableRow: React.FC<TableRowProps> = ({
125
128
onToggle = { onToggle }
126
129
paddingLeft = { level > 0 ? 32 + ( level * 16 ) : 0 }
127
130
theme = { theme }
131
+ expandIcon = { expandIcon }
128
132
/>
129
133
) ) }
130
134
</ tr >
You can’t perform that action at this time.
0 commit comments