material-react-table 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.2",
2
+ "version": "0.5.3",
3
3
  "license": "MIT",
4
4
  "name": "material-react-table",
5
5
  "description": "A fully featured Material-UI implementation of react-table, inspired by material-table and the mui DataGrid, written from the ground up in TypeScript.",
@@ -239,18 +239,22 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
239
239
  muiTableBodyCellProps?:
240
240
  | TableCellProps
241
241
  | ((cell?: MRT_Cell<D>) => TableCellProps);
242
- muiTableBodyProps?: TableBodyProps;
242
+ muiTableBodyProps?:
243
+ | TableBodyProps
244
+ | ((tableInstance: MRT_TableInstance<D>) => TableBodyProps);
243
245
  muiTableBodyRowProps?: TableRowProps | ((row: Row<D>) => TableRowProps);
244
246
  muiTableContainerProps?:
245
247
  | TableContainerProps
246
- | ((table: MRT_TableInstance<D>) => TableContainerProps);
248
+ | ((tableInstance: MRT_TableInstance<D>) => TableContainerProps);
247
249
  muiTableDetailPanelProps?:
248
250
  | TableCellProps
249
251
  | ((row: Row<D>) => TableCellProps);
250
252
  muiTableFooterCellProps?:
251
253
  | TableCellProps
252
254
  | ((column: Column<D>) => TableCellProps);
253
- muiTableFooterProps?: TableFooterProps;
255
+ muiTableFooterProps?:
256
+ | TableFooterProps
257
+ | ((tableInstance: MRT_TableInstance<D>) => TableFooterProps);
254
258
  muiTableFooterRowProps?:
255
259
  | TableRowProps
256
260
  | ((footerGroup: MRT_HeaderGroup<D>) => TableRowProps);
@@ -260,7 +264,9 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
260
264
  muiTableHeadCellProps?:
261
265
  | TableCellProps
262
266
  | ((column: Column<D>) => TableCellProps);
263
- muiTableHeadProps?: TableHeadProps;
267
+ muiTableHeadProps?:
268
+ | TableHeadProps
269
+ | ((tableInstance: MRT_TableInstance<D>) => TableHeadProps);
264
270
  muiTableHeadRowProps?:
265
271
  | TableRowProps
266
272
  | ((row: MRT_HeaderGroup<D>) => TableRowProps);
@@ -269,7 +275,7 @@ export type MaterialReactTableProps<D extends {} = {}> = UseTableOptions<D> &
269
275
  | ((
270
276
  tableInstance: MRT_TableInstance<D>,
271
277
  ) => Partial<TablePaginationProps>);
272
- muiTableProps?: TableProps;
278
+ muiTableProps?: TableProps | ((tableInstance: MRT_TableInstance<D>) => TableProps);
273
279
  muiTableToolbarAlertBannerProps?:
274
280
  | AlertProps
275
281
  | ((tableInstance: MRT_TableInstance<D>) => AlertProps);
@@ -11,12 +11,17 @@ export const MRT_TableBody: FC<Props> = () => {
11
11
 
12
12
  const rows = manualPagination ? tableInstance.rows : tableInstance.page;
13
13
 
14
+ const mTableBodyProps =
15
+ muiTableBodyProps instanceof Function
16
+ ? muiTableBodyProps(tableInstance)
17
+ : muiTableBodyProps;
18
+
14
19
  const tableBodyProps = {
15
- ...muiTableBodyProps,
20
+ ...mTableBodyProps,
16
21
  ...tableInstance.getTableBodyProps(),
17
22
  style: {
18
23
  ...tableInstance.getTableBodyProps().style,
19
- ...muiTableBodyProps?.style,
24
+ ...mTableBodyProps?.style,
20
25
  },
21
26
  };
22
27
 
@@ -9,8 +9,13 @@ interface Props {}
9
9
  export const MRT_TableFooter: FC<Props> = () => {
10
10
  const { muiTableFooterProps, tableInstance } = useMRT();
11
11
 
12
+ const tableFooterProps =
13
+ muiTableFooterProps instanceof Function
14
+ ? muiTableFooterProps(tableInstance)
15
+ : muiTableFooterProps;
16
+
12
17
  return (
13
- <TableFooter {...muiTableFooterProps}>
18
+ <TableFooter {...tableFooterProps}>
14
19
  {tableInstance.footerGroups.map((footerGroup: MRT_HeaderGroup) => (
15
20
  <MRT_TableFooterRow
16
21
  key={footerGroup.getFooterGroupProps().key}
@@ -11,12 +11,17 @@ export const MRT_Table: FC<Props> = () => {
11
11
  const { tableInstance, muiTableProps, hideTableHead, hideTableFooter } =
12
12
  useMRT();
13
13
 
14
+ const mTableProps =
15
+ muiTableProps instanceof Function
16
+ ? muiTableProps(tableInstance)
17
+ : muiTableProps;
18
+
14
19
  const tableProps = {
15
- ...muiTableProps,
20
+ ...mTableProps,
16
21
  ...tableInstance.getTableProps(),
17
22
  style: {
18
23
  ...tableInstance.getTableProps().style,
19
- ...muiTableProps?.style,
24
+ ...mTableProps?.style,
20
25
  },
21
26
  };
22
27
 
@@ -1,5 +1,11 @@
1
1
  import React, { FC, useEffect, useRef } from 'react';
2
- import { LinearProgress, Paper, TableContainer, Collapse } from '@mui/material';
2
+ import {
3
+ LinearProgress,
4
+ Paper,
5
+ TableContainer,
6
+ Collapse,
7
+ Box,
8
+ } from '@mui/material';
3
9
  import { useMRT } from '../useMRT';
4
10
  import { MRT_Table } from './MRT_Table';
5
11
  import { MRT_ToolbarTop } from '../toolbar/MRT_ToolbarTop';
@@ -63,7 +69,14 @@ export const MRT_TableContainer: FC<Props> = () => {
63
69
  <Collapse in={isFetching || isLoading} unmountOnExit>
64
70
  <LinearProgress />
65
71
  </Collapse>
66
- <MRT_Table />
72
+ <Box
73
+ sx={{
74
+ maxWidth: '100%',
75
+ overflowX: 'auto',
76
+ }}
77
+ >
78
+ <MRT_Table />
79
+ </Box>
67
80
  {!hideToolbarBottom && <MRT_ToolbarBottom />}
68
81
  </TableContainer>
69
82
  );