1- import { Theme , ThemeProvider , createTheme , styled } from '@mui/material/styles' ;
1+ import { Theme , styled } from '@mui/material/styles' ;
22import MUIDataTable , { MUIDataTableColumn } from 'mui-datatables' ;
33import React , { useCallback } from 'react' ;
44import { Checkbox , Collapse , ListItemIcon , ListItemText , Menu , MenuItem } from '../base' ;
@@ -104,7 +104,6 @@ export const DataTableEllipsisMenu: React.FC<{
104104 < MenuItem
105105 sx = { {
106106 width : '-webkit-fill-available'
107- // background: theme.palette.background.surfaces
108107 } }
109108 onClick = { ( ) => handleActionClick ( action ) }
110109 disabled = { action . disabled }
@@ -123,142 +122,6 @@ export const DataTableEllipsisMenu: React.FC<{
123122 ) ;
124123} ;
125124
126- const dataTableTheme = ( theme : Theme , backgroundColor ?: string ) =>
127- createTheme ( {
128- typography : {
129- fontFamily : theme . typography . fontFamily
130- } ,
131- palette : {
132- mode : theme . palette . mode ,
133- text : {
134- primary : theme . palette . text . default ,
135- secondary : theme . palette . text . secondary
136- } ,
137- background : {
138- default : backgroundColor || theme . palette . background ?. constant ?. table ,
139- paper : backgroundColor || theme . palette . background ?. constant ?. table
140- } ,
141- border : { ...theme . palette . border } ,
142- icon : { ...theme . palette . icon }
143- } ,
144- components : {
145- MuiTableCell : {
146- styleOverrides : {
147- root : {
148- borderBottom : `1px solid ${ theme . palette . border . default } `
149- }
150- }
151- } ,
152- MuiPaper : {
153- styleOverrides : {
154- root : {
155- maxWidth : '100%'
156- }
157- }
158- } ,
159- MuiTable : {
160- styleOverrides : {
161- root : {
162- width : '-webkit-fill-available' ,
163- '@media (max-width: 500px)' : {
164- wordWrap : 'break-word'
165- }
166- }
167- }
168- } ,
169- MuiTableSortLabel : {
170- styleOverrides : {
171- root : {
172- '&.Mui-active .MuiTableSortLabel-icon' : {
173- color : theme . palette . icon . default
174- }
175- }
176- }
177- } ,
178- MUIDataTableHeadCell : {
179- styleOverrides : {
180- data : {
181- fontWeight : 'bold' ,
182- textTransform : 'uppercase'
183- } ,
184- root : {
185- fontWeight : 'bold' ,
186- textTransform : 'uppercase'
187- }
188- }
189- } ,
190- MUIDataTableSearch : {
191- styleOverrides : {
192- main : {
193- '@media (max-width: 600px)' : {
194- justifyContent : 'center'
195- }
196- }
197- }
198- } ,
199- MuiCheckbox : {
200- styleOverrides : {
201- root : {
202- intermediate : false ,
203- color : 'transparent' ,
204- '&.Mui-checked' : {
205- color : theme . palette . primary . main ,
206- '& .MuiSvgIcon-root' : {
207- width : '1.25rem' ,
208- height : '1.25rem' ,
209- borderColor : theme . palette . border . brand ,
210- marginLeft : '0px' ,
211- padding : '0px'
212- }
213- } ,
214- '&.MuiCheckbox-indeterminate' : {
215- color : theme . palette . background . brand ?. default
216- } ,
217- '& .MuiSvgIcon-root' : {
218- width : '1.25rem' ,
219- height : '1.25rem' ,
220- border : `.75px solid ${ theme . palette . border . strong } ` ,
221- borderRadius : '2px' ,
222- padding : '0px'
223- } ,
224- '&:hover' : {
225- backgroundColor : 'transparent'
226- } ,
227- '&.Mui-disabled' : {
228- '&:hover' : {
229- cursor : 'not-allowed'
230- }
231- }
232- }
233- }
234- } ,
235- MuiInput : {
236- styleOverrides : {
237- root : {
238- '&:before' : {
239- borderBottom : `2px solid ${ theme . palette . border . brand } `
240- } ,
241- '&.Mui-focused:after' : {
242- borderBottom : `2px solid ${ theme . palette . border . brand } `
243- } ,
244- '&:hover:not(.Mui-disabled):before' : {
245- borderBottom : `2px solid ${ theme . palette . border . brand } `
246- }
247- }
248- }
249- } ,
250- MuiTableRow : {
251- styleOverrides : {
252- root : {
253- '&.Mui-disabled' : {
254- cursor : 'not-allowed'
255- }
256- }
257- }
258- }
259- }
260- } ) ;
261-
262125export interface Column {
263126 name : string ;
264127 label : string ;
@@ -287,10 +150,8 @@ export interface ResponsiveDataTableProps {
287150 tableCols ?: MUIDataTableColumn [ ] ;
288151 updateCols ?: ( ( columns : MUIDataTableColumn [ ] ) => void ) | undefined ;
289152 columnVisibility : Record < string , boolean > | undefined ;
290- theme ?: object ;
291153 colViews ?: ColView [ ] ;
292154 rowsPerPageOptions ?: number [ ] | undefined ;
293- backgroundColor ?: string ;
294155}
295156const ResponsiveDataTable = ( {
296157 data,
@@ -300,8 +161,6 @@ const ResponsiveDataTable = ({
300161 updateCols,
301162 columnVisibility,
302163 rowsPerPageOptions = [ 10 , 25 , 50 , 100 ] ,
303- theme : customTheme ,
304- backgroundColor,
305164 ...props
306165} : ResponsiveDataTableProps ) : JSX . Element => {
307166 const formatDate = ( date : Date ) : string => {
@@ -320,7 +179,7 @@ const ResponsiveDataTable = ({
320179 print : false ,
321180 download : false ,
322181 search : false ,
323- filter : true ,
182+ filter : false ,
324183 viewColumns : false ,
325184 rowsPerPageOptions : rowsPerPageOptions ,
326185 onViewColumnsChange : ( column : string , action : string ) => {
@@ -402,32 +261,19 @@ const ResponsiveDataTable = ({
402261 Checkbox : Checkbox
403262 } ;
404263
405- const finalTheme = ( baseTheme : Theme ) => {
406- const defaultTheme = dataTableTheme ( baseTheme , backgroundColor ) ;
407- if ( customTheme ) {
408- return createTheme (
409- defaultTheme ,
410- typeof customTheme === 'function' ? customTheme ( baseTheme ) : customTheme
411- ) ;
412- }
413- return defaultTheme ;
414- } ;
415-
416264 return (
417- < ThemeProvider theme = { finalTheme } >
418- < MUIDataTable
419- columns = { tableCols ?? [ ] }
420- data = { data || [ ] }
421- title = { undefined }
422- components = { components }
423- options = { {
424- ...updatedOptions ,
425- elevation : 0 ,
426- enableNestedDataAccess : '.'
427- } }
428- { ...props }
429- />
430- </ ThemeProvider >
265+ < MUIDataTable
266+ columns = { tableCols ?? [ ] }
267+ data = { data || [ ] }
268+ title = { undefined }
269+ components = { components }
270+ options = { {
271+ ...updatedOptions ,
272+ elevation : 0 ,
273+ enableNestedDataAccess : '.'
274+ } }
275+ { ...props }
276+ />
431277 ) ;
432278} ;
433279
0 commit comments