1- import { Theme , ThemeProvider , createTheme } from '@mui/material' ;
1+ import { Theme , ThemeProvider , createTheme , styled } from '@mui/material' ;
22import MUIDataTable from 'mui-datatables' ;
33import React , { useCallback } from 'react' ;
44import { IconButton , Menu , MenuItem } from '../base' ;
55import { DropDownIcon } from '../icons' ;
66
7- const DataTableEllipsisMenu : React . FC < {
7+ export const IconWrapper = styled ( 'div' ) < { disabled ?: boolean } > ( ( { disabled = false } ) => ( {
8+ cursor : disabled ? 'not-allowed' : 'pointer' ,
9+ opacity : disabled ? '0.5' : '1' ,
10+ display : 'flex' ,
11+ '& svg' : {
12+ cursor : disabled ? 'not-allowed' : 'pointer'
13+ }
14+ } ) ) ;
15+
16+ const CustomMenuItem = styled ( MenuItem ) ( ( ) => ( {
17+ paddingLeft : '0px' ,
18+ padding : '10px'
19+ } ) ) ;
20+
21+ export const DataTableEllipsisMenu : React . FC < {
822 actionsList : NonNullable < Column [ 'options' ] > [ 'actionsList' ] ;
923} > = ( { actionsList } ) => {
1024 const [ anchorEl , setAnchorEl ] = React . useState < null | HTMLElement > ( null ) ;
@@ -14,6 +28,7 @@ const DataTableEllipsisMenu: React.FC<{
1428 const handleClose = ( ) => {
1529 setAnchorEl ( null ) ;
1630 } ;
31+
1732 return (
1833 < >
1934 < IconButton onClick = { handleClick } >
@@ -25,17 +40,18 @@ const DataTableEllipsisMenu: React.FC<{
2540 onClose = { handleClose }
2641 PaperProps = { {
2742 style : {
28- maxHeight : 48 * 4.5 ,
29- width : '20ch'
43+ maxHeight : 48 * 4.5
3044 }
3145 } }
3246 >
3347 { actionsList &&
3448 actionsList . map ( ( action , index ) => (
35- < MenuItem key = { index } onClick = { action . onClick } disabled = { action . disabled } >
36- { action . icon }
37- { action . title }
38- </ MenuItem >
49+ < IconWrapper key = { index } disabled = { action . disabled } >
50+ < CustomMenuItem key = { index } onClick = { action . onClick } disabled = { action . disabled } >
51+ { action . icon }
52+ { action . title }
53+ </ CustomMenuItem >
54+ </ IconWrapper >
3955 ) ) }
4056 </ Menu >
4157 </ >
@@ -211,16 +227,6 @@ const ResponsiveDataTable = ({
211227 return new Intl . DateTimeFormat ( 'un-US' , dateOptions ) . format ( date ) ;
212228 } ;
213229
214- columns . forEach ( ( col ) => {
215- console . log ( 'col' , col ) ;
216- if ( col . options ?. actionsList ) {
217- console . log ( 'col.options.actionsList' , col . options . actionsList ) ;
218- col . options . customBodyRender = function CustomBody ( ) {
219- return < DataTableEllipsisMenu actionsList = { col . options ?. actionsList } /> ;
220- } ;
221- }
222- } ) ;
223-
224230 const updatedOptions = {
225231 ...options ,
226232 print : false ,
0 commit comments