1
- import { Theme , ThemeProvider , createTheme , styled } from '@mui/material/styles' ;
1
+ import { Theme , styled } from '@mui/material/styles' ;
2
2
import MUIDataTable , { MUIDataTableColumn } from 'mui-datatables' ;
3
3
import React , { useCallback } from 'react' ;
4
4
import { Checkbox , Collapse , ListItemIcon , ListItemText , Menu , MenuItem } from '../base' ;
@@ -104,7 +104,6 @@ export const DataTableEllipsisMenu: React.FC<{
104
104
< MenuItem
105
105
sx = { {
106
106
width : '-webkit-fill-available'
107
- // background: theme.palette.background.surfaces
108
107
} }
109
108
onClick = { ( ) => handleActionClick ( action ) }
110
109
disabled = { action . disabled }
@@ -123,142 +122,6 @@ export const DataTableEllipsisMenu: React.FC<{
123
122
) ;
124
123
} ;
125
124
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
-
262
125
export interface Column {
263
126
name : string ;
264
127
label : string ;
@@ -287,10 +150,8 @@ export interface ResponsiveDataTableProps {
287
150
tableCols ?: MUIDataTableColumn [ ] ;
288
151
updateCols ?: ( ( columns : MUIDataTableColumn [ ] ) => void ) | undefined ;
289
152
columnVisibility : Record < string , boolean > | undefined ;
290
- theme ?: object ;
291
153
colViews ?: ColView [ ] ;
292
154
rowsPerPageOptions ?: number [ ] | undefined ;
293
- backgroundColor ?: string ;
294
155
}
295
156
const ResponsiveDataTable = ( {
296
157
data,
@@ -300,8 +161,6 @@ const ResponsiveDataTable = ({
300
161
updateCols,
301
162
columnVisibility,
302
163
rowsPerPageOptions = [ 10 , 25 , 50 , 100 ] ,
303
- theme : customTheme ,
304
- backgroundColor,
305
164
...props
306
165
} : ResponsiveDataTableProps ) : JSX . Element => {
307
166
const formatDate = ( date : Date ) : string => {
@@ -320,7 +179,7 @@ const ResponsiveDataTable = ({
320
179
print : false ,
321
180
download : false ,
322
181
search : false ,
323
- filter : true ,
182
+ filter : false ,
324
183
viewColumns : false ,
325
184
rowsPerPageOptions : rowsPerPageOptions ,
326
185
onViewColumnsChange : ( column : string , action : string ) => {
@@ -402,32 +261,19 @@ const ResponsiveDataTable = ({
402
261
Checkbox : Checkbox
403
262
} ;
404
263
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
-
416
264
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
+ />
431
277
) ;
432
278
} ;
433
279
0 commit comments