material-react-table 0.9.6 → 0.9.7

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.
@@ -1,5 +1,5 @@
1
1
  import { FC } from 'react';
2
- import { MRT_TableInstance } from '..';
2
+ import type { MRT_TableInstance } from '..';
3
3
  interface Props {
4
4
  tableInstance: MRT_TableInstance;
5
5
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.9.6",
2
+ "version": "0.9.7",
3
3
  "license": "MIT",
4
4
  "name": "material-react-table",
5
5
  "description": "A fully featured Material UI implementation of TanStack React Table, inspired by material-table and the MUI X DataGrid, written from the ground up in TypeScript.",
@@ -34,6 +34,7 @@ import {
34
34
  FilterFnOption,
35
35
  Header,
36
36
  HeaderGroup,
37
+ OnChangeFn,
37
38
  Overwrite,
38
39
  ReactTableGenerics,
39
40
  Row,
@@ -568,6 +569,12 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
568
569
  }: {
569
570
  tableInstance: MRT_TableInstance;
570
571
  }) => ToolbarProps);
572
+ onCurrentEditingCellChange?: OnChangeFn<MRT_Cell>;
573
+ onCurrentEditingRowChange?: OnChangeFn<MRT_Row>;
574
+ onCurrentFilterFnsChange?: OnChangeFn<{ [key: string]: MRT_FilterFn<D> }>;
575
+ onCurrentGlobalFilterFnChange?: OnChangeFn<MRT_FilterFn<D>>;
576
+ onIsDensePaddingChange?: OnChangeFn<boolean>;
577
+ onIsFullScreenChange?: OnChangeFn<boolean>;
571
578
  onMrtCellClick?: ({
572
579
  cell,
573
580
  event,
@@ -709,6 +716,8 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
709
716
  showGlobalFilter: boolean;
710
717
  tableInstance: MRT_TableInstance<D>;
711
718
  }) => void;
719
+ onShowFiltersChange?: OnChangeFn<boolean>;
720
+ onShowGlobalFilterChange?: OnChangeFn<boolean>;
712
721
  persistentStateMode?: 'localStorage' | 'sessionStorage';
713
722
  positionActionsColumn?: 'first' | 'last';
714
723
  positionPagination?: 'bottom' | 'top' | 'both';
@@ -795,7 +804,7 @@ export default <D extends Record<string, any> = {}>({
795
804
  enablePinning = false,
796
805
  enableSelectAll = true,
797
806
  enableSorting = true,
798
- enableStickyHeader = true,
807
+ enableStickyHeader = false,
799
808
  enableTableFooter = true,
800
809
  enableTableHead = true,
801
810
  enableToolbarBottom = true,
@@ -10,7 +10,11 @@ interface Props {
10
10
  tableInstance: MRT_TableInstance;
11
11
  }
12
12
 
13
- export const MRT_TableBodyRow: FC<Props> = ({ row, rowIndex, tableInstance }) => {
13
+ export const MRT_TableBodyRow: FC<Props> = ({
14
+ row,
15
+ rowIndex,
16
+ tableInstance,
17
+ }) => {
14
18
  const {
15
19
  getIsSomeColumnsPinned,
16
20
  options: { muiTableBodyRowProps, onMrtRowClick, renderDetailPanel },
@@ -12,6 +12,7 @@ interface Props {
12
12
 
13
13
  export const MRT_Table: FC<Props> = ({ tableContainerRef, tableInstance }) => {
14
14
  const {
15
+ getState,
15
16
  options: {
16
17
  enableColumnResizing,
17
18
  enableRowVirtualization,
@@ -22,6 +23,8 @@ export const MRT_Table: FC<Props> = ({ tableContainerRef, tableInstance }) => {
22
23
  },
23
24
  } = tableInstance;
24
25
 
26
+ const { isFullScreen } = getState();
27
+
25
28
  const tableProps =
26
29
  muiTableProps instanceof Function
27
30
  ? muiTableProps({ tableInstance })
@@ -29,7 +32,9 @@ export const MRT_Table: FC<Props> = ({ tableContainerRef, tableInstance }) => {
29
32
 
30
33
  return (
31
34
  <Table
32
- stickyHeader={enableStickyHeader}
35
+ stickyHeader={
36
+ enableStickyHeader || enableRowVirtualization || isFullScreen
37
+ }
33
38
  {...tableProps}
34
39
  sx={{
35
40
  tableLayout:
@@ -13,7 +13,12 @@ interface Props {
13
13
  export const MRT_TableContainer: FC<Props> = ({ tableInstance }) => {
14
14
  const {
15
15
  getState,
16
- options: { enableStickyHeader, muiTableContainerProps, tableId },
16
+ options: {
17
+ enableStickyHeader,
18
+ enableRowVirtualization,
19
+ muiTableContainerProps,
20
+ tableId,
21
+ },
17
22
  } = tableInstance;
18
23
 
19
24
  const { isFullScreen } = getState();
@@ -49,9 +54,10 @@ export const MRT_TableContainer: FC<Props> = ({ tableInstance }) => {
49
54
  ref={tableContainerRef}
50
55
  sx={{
51
56
  maxWidth: '100%',
52
- maxHeight: enableStickyHeader
53
- ? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 2000px)`
54
- : undefined,
57
+ maxHeight:
58
+ enableStickyHeader || enableRowVirtualization
59
+ ? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
60
+ : undefined,
55
61
  overflow: 'auto',
56
62
  ...tableContainerProps?.sx,
57
63
  }}
@@ -59,6 +65,7 @@ export const MRT_TableContainer: FC<Props> = ({ tableInstance }) => {
59
65
  maxHeight: isFullScreen
60
66
  ? `calc(100vh - ${totalToolbarHeight}px)`
61
67
  : undefined,
68
+ ...tableContainerProps?.style,
62
69
  }}
63
70
  >
64
71
  <MRT_Table
@@ -5,7 +5,7 @@ import { HTML5Backend } from 'react-dnd-html5-backend';
5
5
  import { MRT_ToolbarTop } from '../toolbar/MRT_ToolbarTop';
6
6
  import { MRT_ToolbarBottom } from '../toolbar/MRT_ToolbarBottom';
7
7
  import { MRT_TableContainer } from './MRT_TableContainer';
8
- import { MRT_TableInstance } from '..';
8
+ import type { MRT_TableInstance } from '..';
9
9
 
10
10
  interface Props {
11
11
  tableInstance: MRT_TableInstance;
@@ -22,10 +22,8 @@ export const MRT_TablePaper: FC<Props> = ({ tableInstance }) => {
22
22
  useEffect(() => {
23
23
  if (typeof window !== 'undefined') {
24
24
  if (isFullScreen) {
25
- document.body.style.overflow = 'hidden';
26
25
  document.body.style.height = '100vh';
27
26
  } else {
28
- document.body.style.overflow = 'auto';
29
27
  document.body.style.height = 'auto';
30
28
  }
31
29
  }
@@ -44,8 +42,6 @@ export const MRT_TablePaper: FC<Props> = ({ tableInstance }) => {
44
42
  sx={{
45
43
  transition: 'all 0.2s ease-in-out',
46
44
  ...tablePaperProps?.sx,
47
- }}
48
- style={{
49
45
  height: isFullScreen ? '100vh' : undefined,
50
46
  margin: isFullScreen ? '0' : undefined,
51
47
  maxHeight: isFullScreen ? '100vh' : undefined,
@@ -170,7 +170,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
170
170
  id: 'mrt-row-actions',
171
171
  muiTableBodyCellProps: props.muiTableBodyCellProps,
172
172
  muiTableHeadCellProps: props.muiTableHeadCellProps,
173
- size: 60,
173
+ size: 70,
174
174
  }),
175
175
  showExpandColumn &&
176
176
  createDisplayColumn(table, {
@@ -286,14 +286,17 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
286
286
  ...props.state,
287
287
  } as TableState,
288
288
  }),
289
- setCurrentEditingCell,
290
- setCurrentEditingRow,
291
- setCurrentFilterFns,
292
- setCurrentGlobalFilterFn,
293
- setIsDensePadding,
294
- setIsFullScreen,
295
- setShowFilters,
296
- setShowGlobalFilter,
289
+ setCurrentEditingCell:
290
+ props.onCurrentEditingCellChange ?? setCurrentEditingCell,
291
+ setCurrentEditingRow:
292
+ props.onCurrentEditingRowChange ?? setCurrentEditingRow,
293
+ setCurrentFilterFns: props.onCurrentFilterFnsChange ?? setCurrentFilterFns,
294
+ setCurrentGlobalFilterFn:
295
+ props.onCurrentGlobalFilterFnChange ?? setCurrentGlobalFilterFn,
296
+ setIsDensePadding: props.onIsDensePaddingChange ?? setIsDensePadding,
297
+ setIsFullScreen: props.onIsFullScreenChange ?? setIsFullScreen,
298
+ setShowFilters: props.onShowFiltersChange ?? setShowFilters,
299
+ setShowGlobalFilter: props.onShowGlobalFilterChange ?? setShowGlobalFilter,
297
300
  } as MRT_TableInstance;
298
301
 
299
302
  useEffect(() => {
@@ -76,6 +76,7 @@ export const MRT_ToolbarTop: FC<Props> = ({ tableInstance }) => {
76
76
  )}
77
77
  <Box
78
78
  sx={{
79
+ alignItems: 'flex-start',
79
80
  display: 'flex',
80
81
  justifyContent: 'space-between',
81
82
  p: '0.5rem',