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 = () => {
421421 return < div > Custom Pagination </ div > ;
422422 } ;
423423
424+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
425+ const renderCustomExpandButton = ( ) => {
426+ return < div > ➡</ div > ;
427+ } ;
428+
424429 return (
425430 < div className = "app" style = { { backgroundColor : theme . colors ?. background } } >
426431 < header
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ interface MultiLevelTableProps {
4242 sortable ?: boolean ;
4343 ascendingIcon ?: React . ReactNode ;
4444 descendingIcon ?: React . ReactNode ;
45+ expandIcon ?: React . ReactNode ;
4546}
4647
4748/**
@@ -59,6 +60,7 @@ export const MultiLevelTable: React.FC<MultiLevelTableProps> = ({
5960 sortable = false ,
6061 ascendingIcon,
6162 descendingIcon,
63+ expandIcon,
6264} ) => {
6365 const mergedTheme = mergeThemeProps ( defaultThemeProps , theme ) ;
6466 const [ filterInput , setFilterInput ] = useState ( "" ) ;
@@ -184,6 +186,7 @@ export const MultiLevelTable: React.FC<MultiLevelTableProps> = ({
184186 onToggle = { ( ) => hasChildren && toggleRow ( child . id ) }
185187 level = { level }
186188 theme = { mergedTheme }
189+ expandIcon = { expandIcon }
187190 />
188191 { renderNestedRows ( child . id , level + 1 ) }
189192 </ React . Fragment >
@@ -216,6 +219,7 @@ export const MultiLevelTable: React.FC<MultiLevelTableProps> = ({
216219 isExpanded = { expandedRows . has ( parentId ) }
217220 onToggle = { ( ) => hasChildren && toggleRow ( parentId ) }
218221 theme = { mergedTheme }
222+ expandIcon = { expandIcon }
219223 />
220224 { renderNestedRows ( parentId ) }
221225 </ React . Fragment >
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ import '../styles/TableCell.css';
1818 * @property {() => void } onToggle - Function to toggle row expansion
1919 * @property {number } [paddingLeft=0] - Left padding for nested cells
2020 * @property {ThemeProps } theme - Theme properties
21+ * @property {React.ReactNode } [expandIcon] - Custom expand icon
2122 */
2223interface TableCellProps {
2324 cell : Cell < DataItem > ;
@@ -26,6 +27,7 @@ interface TableCellProps {
2627 onToggle : ( ) => void ;
2728 paddingLeft ?: number ;
2829 theme : ThemeProps ;
30+ expandIcon ?: React . ReactNode ;
2931}
3032
3133/**
@@ -40,7 +42,8 @@ export const TableCell: React.FC<TableCellProps> = ({
4042 isExpanded,
4143 onToggle,
4244 paddingLeft = 0 ,
43- theme
45+ theme,
46+ expandIcon,
4447} ) => {
4548 const { key, ...cellProps } = cell . getCellProps ( ) ;
4649
@@ -76,7 +79,7 @@ export const TableCell: React.FC<TableCellProps> = ({
7679 alignItems : 'center' ,
7780 } }
7881 >
79- < ExpandIcon isExpanded = { isExpanded } theme = { theme } />
82+ { expandIcon || < ExpandIcon isExpanded = { isExpanded } theme = { theme } /> }
8083 </ button >
8184 ) }
8285 { cell . render ( 'Cell' ) }
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import '../styles/TableRow.css';
1919 * @property {() => void } onToggle - Function to toggle row expansion
2020 * @property {number } [level=0] - Nesting level of the row
2121 * @property {ThemeProps } theme - Theme properties
22+ * @property {React.ReactNode } [expandIcon] - Custom expand icon
2223 */
2324interface TableRowProps {
2425 row : Row < DataItem > | DataItem ;
@@ -28,6 +29,7 @@ interface TableRowProps {
2829 onToggle : ( ) => void ;
2930 level ?: number ;
3031 theme : ThemeProps ;
32+ expandIcon ?: React . ReactNode ;
3133}
3234
3335/**
@@ -43,7 +45,8 @@ export const TableRow: React.FC<TableRowProps> = ({
4345 isExpanded,
4446 onToggle,
4547 level = 0 ,
46- theme
48+ theme,
49+ expandIcon,
4750} ) => {
4851 const getRowClassName = ( ) => {
4952 const classes = [ 'table-row' ] ;
@@ -91,7 +94,7 @@ export const TableRow: React.FC<TableRowProps> = ({
9194 } }
9295 style = { { cursor : 'pointer' , marginRight : '8px' } }
9396 >
94- < ExpandIcon isExpanded = { isExpanded } theme = { theme } />
97+ { expandIcon || < ExpandIcon isExpanded = { isExpanded } theme = { theme } /> }
9598 </ span >
9699 ) }
97100 { column . render
@@ -125,6 +128,7 @@ export const TableRow: React.FC<TableRowProps> = ({
125128 onToggle = { onToggle }
126129 paddingLeft = { level > 0 ? 32 + ( level * 16 ) : 0 }
127130 theme = { theme }
131+ expandIcon = { expandIcon }
128132 />
129133 ) ) }
130134 </ tr >
You can’t perform that action at this time.
0 commit comments