material-react-table 0.7.0 → 0.7.1

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,7 +1,7 @@
1
1
  import { FC } from 'react';
2
- import type { MRT_ColumnInstance, MRT_TableInstance } from '..';
2
+ import type { MRT_Column, MRT_TableInstance } from '..';
3
3
  interface Props {
4
- column: MRT_ColumnInstance;
4
+ column: MRT_Column;
5
5
  isSubMenu?: boolean;
6
6
  tableInstance: MRT_TableInstance;
7
7
  }
package/dist/utils.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { ColumnDef, Table } from '@tanstack/react-table';
2
- import { MRT_ColumnInterface, MRT_FilterType } from '.';
3
- export declare const getAllLeafColumnDefs: (columns: MRT_ColumnInterface[]) => MRT_ColumnInterface[];
4
- export declare const createGroup: <D extends Record<string, any> = {}>(table: Table<D>, column: MRT_ColumnInterface<D>, currentFilterTypes: {
2
+ import { MRT_ColumnDef, MRT_FilterType } from '.';
3
+ export declare const getAllLeafColumnDefs: (columns: MRT_ColumnDef[]) => MRT_ColumnDef[];
4
+ export declare const createGroup: <D extends Record<string, any> = {}>(table: Table<D>, column: MRT_ColumnDef<D>, currentFilterTypes: {
5
5
  [key: string]: MRT_FilterType;
6
6
  }) => ColumnDef<D>;
7
- export declare const createDataColumn: <D extends Record<string, any> = {}>(table: Table<D>, column: MRT_ColumnInterface<D>, currentFilterTypes: {
7
+ export declare const createDataColumn: <D extends Record<string, any> = {}>(table: Table<D>, column: MRT_ColumnDef<D>, currentFilterTypes: {
8
8
  [key: string]: MRT_FilterType;
9
9
  }) => ColumnDef<D>;
10
- export declare const createDisplayColumn: <D extends Record<string, any> = {}>(table: Table<D>, column: Pick<MRT_ColumnInterface<D>, "footer" | "columns" | "id" | "accessorKey" | "accessorFn" | "cell" | "meta" | "enableHiding" | "defaultCanHide" | "defaultIsVisible" | "enablePinning" | "defaultCanPin" | "filterType" | "enableAllFilters" | "enableColumnFilter" | "enableGlobalFilter" | "defaultCanFilter" | "defaultCanColumnFilter" | "defaultCanGlobalFilter" | "sortType" | "sortDescFirst" | "enableSorting" | "enableMultiSort" | "defaultCanSort" | "invertSorting" | "sortUndefined" | "aggregationType" | "aggregateValue" | "aggregatedCell" | "enableGrouping" | "defaultCanGroup" | "enableResizing" | "defaultCanResize" | "width" | "minWidth" | "maxWidth" | "Edit" | "Filter" | "Footer" | "Header" | "Cell" | "enableClickToCopy" | "enableColumnActions" | "enableEditing" | "enabledFilterTypes" | "filter" | "filterSelectOptions" | "muiTableBodyCellCopyButtonProps" | "muiTableBodyCellEditTextFieldProps" | "muiTableBodyCellProps" | "muiTableFooterCellProps" | "muiTableHeadCellColumnActionsButtonProps" | "muiTableHeadCellFilterTextFieldProps" | "muiTableHeadCellProps" | "onCellEditBlur" | "onCellEditChange" | "onColumnFilterValueChange"> & {
10
+ export declare const createDisplayColumn: <D extends Record<string, any> = {}>(table: Table<D>, column: Pick<MRT_ColumnDef<D>, "footer" | "columns" | "id" | "accessorKey" | "accessorFn" | "cell" | "meta" | "enableHiding" | "defaultCanHide" | "defaultIsVisible" | "enablePinning" | "defaultCanPin" | "filterType" | "enableAllFilters" | "enableColumnFilter" | "enableGlobalFilter" | "defaultCanFilter" | "defaultCanColumnFilter" | "defaultCanGlobalFilter" | "sortType" | "sortDescFirst" | "enableSorting" | "enableMultiSort" | "defaultCanSort" | "invertSorting" | "sortUndefined" | "aggregationType" | "aggregateValue" | "aggregatedCell" | "enableGrouping" | "defaultCanGroup" | "enableResizing" | "defaultCanResize" | "width" | "minWidth" | "maxWidth" | "Edit" | "Filter" | "Footer" | "Header" | "Cell" | "enableClickToCopy" | "enableColumnActions" | "enableEditing" | "enabledFilterTypes" | "filter" | "filterSelectOptions" | "muiTableBodyCellCopyButtonProps" | "muiTableBodyCellEditTextFieldProps" | "muiTableBodyCellProps" | "muiTableFooterCellProps" | "muiTableHeadCellColumnActionsButtonProps" | "muiTableHeadCellFilterTextFieldProps" | "muiTableHeadCellProps" | "onCellEditBlur" | "onCellEditChange" | "onColumnFilterValueChange"> & {
11
11
  header?: string | undefined;
12
12
  }) => ColumnDef<D>;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.7.0",
2
+ "version": "0.7.1",
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 X DataGrid, written from the ground up in TypeScript.",
@@ -97,7 +97,7 @@
97
97
  "react": ">=16.8"
98
98
  },
99
99
  "dependencies": {
100
- "@tanstack/react-table": "^8.0.0-alpha.43",
100
+ "@tanstack/react-table": "^8.0.0-alpha.44",
101
101
  "match-sorter": "^6.3.1"
102
102
  }
103
103
  }
@@ -53,7 +53,7 @@ export type MRT_TableOptions<D extends Record<string, any> = {}> = Partial<
53
53
  'columns' | 'data' | 'initialState' | 'state' | 'expandRowsFn'
54
54
  >
55
55
  > & {
56
- columns: MRT_ColumnInterface<D>[];
56
+ columns: MRT_ColumnDef<D>[];
57
57
  data: D[];
58
58
  initialState?: Partial<MRT_TableState<D>>;
59
59
  state?: Partial<MRT_TableState<D>>;
@@ -85,8 +85,8 @@ export type MRT_TableInstance<D extends Record<string, any> = {}> = Omit<
85
85
  | 'getState'
86
86
  | 'options'
87
87
  > & {
88
- getAllColumns: () => MRT_ColumnInstance<D>[];
89
- getAllLeafColumns: () => MRT_ColumnInstance<D>[];
88
+ getAllColumns: () => MRT_Column<D>[];
89
+ getAllLeafColumns: () => MRT_Column<D>[];
90
90
  getExpandedRowModel: () => MRT_RowModel<D>;
91
91
  getPaginationRowModel: () => MRT_RowModel<D>;
92
92
  getPrePaginationRowModel: () => MRT_RowModel<D>;
@@ -126,7 +126,7 @@ export type MRT_TableState<D extends Record<string, any> = {}> = Omit<
126
126
  pagination: Partial<PaginationState>;
127
127
  };
128
128
 
129
- export type MRT_ColumnInterface<D extends Record<string, any> = {}> = Omit<
129
+ export type MRT_ColumnDef<D extends Record<string, any> = {}> = Omit<
130
130
  ColumnDef<D>,
131
131
  'header' | 'footer' | 'columns'
132
132
  > & {
@@ -170,11 +170,11 @@ export type MRT_ColumnInterface<D extends Record<string, any> = {}> = Omit<
170
170
  tableInstance: MRT_TableInstance<D>;
171
171
  }) => ReactNode;
172
172
  id: keyof D | string;
173
- columns?: MRT_ColumnInterface<D>[];
173
+ columns?: MRT_ColumnDef<D>[];
174
174
  enableClickToCopy?: boolean;
175
175
  enableColumnActions?: boolean;
176
176
  enableEditing?: boolean;
177
- enabledFilterTypes?: (MRT_FILTER_TYPE | string)[];
177
+ enabledColumnFilterTypes?: (MRT_FILTER_TYPE | string)[];
178
178
  filter?: MRT_FilterType | string | FilterType<D>;
179
179
  filterSelectOptions?: (string | { text: string; value: string })[];
180
180
  footer?: string;
@@ -213,7 +213,7 @@ export type MRT_ColumnInterface<D extends Record<string, any> = {}> = Omit<
213
213
  column,
214
214
  }: {
215
215
  tableInstance: MRT_TableInstance;
216
- column: MRT_ColumnInstance<D>;
216
+ column: MRT_Column<D>;
217
217
  }) => TableCellProps);
218
218
  muiTableHeadCellColumnActionsButtonProps?:
219
219
  | IconButtonProps
@@ -222,7 +222,7 @@ export type MRT_ColumnInterface<D extends Record<string, any> = {}> = Omit<
222
222
  column,
223
223
  }: {
224
224
  tableInstance: MRT_TableInstance;
225
- column: MRT_ColumnInstance<D>;
225
+ column: MRT_Column<D>;
226
226
  }) => IconButtonProps);
227
227
  muiTableHeadCellFilterTextFieldProps?:
228
228
  | TextFieldProps
@@ -231,7 +231,7 @@ export type MRT_ColumnInterface<D extends Record<string, any> = {}> = Omit<
231
231
  column,
232
232
  }: {
233
233
  tableInstance: MRT_TableInstance;
234
- column: MRT_ColumnInstance<D>;
234
+ column: MRT_Column<D>;
235
235
  }) => TextFieldProps);
236
236
  muiTableHeadCellProps?:
237
237
  | TableCellProps
@@ -240,7 +240,7 @@ export type MRT_ColumnInterface<D extends Record<string, any> = {}> = Omit<
240
240
  column,
241
241
  }: {
242
242
  tableInstance: MRT_TableInstance;
243
- column: MRT_ColumnInstance<D>;
243
+ column: MRT_Column<D>;
244
244
  }) => TableCellProps);
245
245
  onCellEditBlur?: ({
246
246
  cell,
@@ -269,19 +269,19 @@ export type MRT_ColumnInterface<D extends Record<string, any> = {}> = Omit<
269
269
  }) => void;
270
270
  };
271
271
 
272
- export type MRT_ColumnInstance<D extends Record<string, any> = {}> = Omit<
272
+ export type MRT_Column<D extends Record<string, any> = {}> = Omit<
273
273
  Column<D>,
274
274
  'header' | 'footer' | 'columns'
275
275
  > &
276
- MRT_ColumnInterface<D> & {
277
- columns?: MRT_ColumnInstance<D>[];
276
+ MRT_ColumnDef<D> & {
277
+ columns?: MRT_Column<D>[];
278
278
  };
279
279
 
280
280
  export type MRT_Header<D extends Record<string, any> = {}> = Omit<
281
281
  Header<D>,
282
282
  'column'
283
283
  > & {
284
- column: MRT_ColumnInstance<D>;
284
+ column: MRT_Column<D>;
285
285
  };
286
286
 
287
287
  export type MRT_HeaderGroup<D extends Record<string, any> = {}> = Omit<
@@ -314,7 +314,7 @@ export type MRT_Cell<D extends Record<string, any> = {}> = Omit<
314
314
  Cell<D>,
315
315
  'column' | 'row'
316
316
  > & {
317
- column: MRT_ColumnInstance<D>;
317
+ column: MRT_Column<D>;
318
318
  row: MRT_Row<D>;
319
319
  };
320
320
 
@@ -333,13 +333,13 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
333
333
  enableRowNumbers?: boolean;
334
334
  enableSelectAll?: boolean;
335
335
  enableStickyHeader?: boolean;
336
+ enableTableFooter?: boolean;
337
+ enableTableHead?: boolean;
338
+ enableToolbarBottom?: boolean;
339
+ enableToolbarInternalActions?: boolean;
340
+ enableToolbarTop?: boolean;
336
341
  enabledGlobalFilterTypes?: (MRT_FILTER_TYPE | string)[];
337
342
  filterTypes?: { [key in MRT_FILTER_TYPE]: any };
338
- hideTableFooter?: boolean;
339
- hideTableHead?: boolean;
340
- hideToolbarBottom?: boolean;
341
- hideToolbarInternalActions?: boolean;
342
- hideToolbarTop?: boolean;
343
343
  icons?: Partial<MRT_Icons>;
344
344
  idPrefix?: string;
345
345
  isLoading?: boolean;
@@ -445,7 +445,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
445
445
  column,
446
446
  }: {
447
447
  tableInstance: MRT_TableInstance;
448
- column: MRT_ColumnInstance<D>;
448
+ column: MRT_Column<D>;
449
449
  }) => TableCellProps);
450
450
  muiTableFooterProps?:
451
451
  | TableFooterProps
@@ -470,7 +470,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
470
470
  column,
471
471
  }: {
472
472
  tableInstance: MRT_TableInstance;
473
- column: MRT_ColumnInstance<D>;
473
+ column: MRT_Column<D>;
474
474
  }) => IconButtonProps);
475
475
  muiTableHeadCellFilterTextFieldProps?:
476
476
  | TextFieldProps
@@ -479,7 +479,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
479
479
  column,
480
480
  }: {
481
481
  tableInstance: MRT_TableInstance;
482
- column: MRT_ColumnInstance<D>;
482
+ column: MRT_Column<D>;
483
483
  }) => TextFieldProps);
484
484
  muiTableHeadCellProps?:
485
485
  | TableCellProps
@@ -488,7 +488,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
488
488
  column,
489
489
  }: {
490
490
  tableInstance: MRT_TableInstance;
491
- column: MRT_ColumnInstance<D>;
491
+ column: MRT_Column<D>;
492
492
  }) => TableCellProps);
493
493
  muiTableHeadProps?:
494
494
  | TableHeadProps
@@ -622,7 +622,7 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
622
622
  columnVisibility,
623
623
  tableInstance,
624
624
  }: {
625
- column: MRT_ColumnInstance<D>;
625
+ column: MRT_Column<D>;
626
626
  columnVisibility: VisibilityState;
627
627
  tableInstance: MRT_TableInstance<D>;
628
628
  }) => void;
@@ -736,6 +736,11 @@ export default <D extends Record<string, any> = {}>({
736
736
  enableSelectAll = true,
737
737
  enableSorting = true,
738
738
  enableStickyHeader = true,
739
+ enableTableFooter = true,
740
+ enableTableHead = true,
741
+ enableToolbarBottom = true,
742
+ enableToolbarInternalActions = true,
743
+ enableToolbarTop = true,
739
744
  icons,
740
745
  localization,
741
746
  positionActionsColumn = 'first',
@@ -759,6 +764,11 @@ export default <D extends Record<string, any> = {}>({
759
764
  enableSelectAll={enableSelectAll}
760
765
  enableSorting={enableSorting}
761
766
  enableStickyHeader={enableStickyHeader}
767
+ enableTableFooter={enableTableFooter}
768
+ enableTableHead={enableTableHead}
769
+ enableToolbarBottom={enableToolbarBottom}
770
+ enableToolbarInternalActions={enableToolbarInternalActions}
771
+ enableToolbarTop={enableToolbarTop}
762
772
  icons={{ ...MRT_Default_Icons, ...icons }}
763
773
  localization={{ ...MRT_DefaultLocalization_EN, ...localization }}
764
774
  positionActionsColumn={positionActionsColumn}
@@ -144,7 +144,7 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, tableInstance }) => {
144
144
  : undefined,
145
145
  display: 'flex',
146
146
  flexWrap: 'nowrap',
147
- whiteSpace: column.header.length < 15 ? 'nowrap' : 'normal',
147
+ whiteSpace: column.header.length < 24 ? 'nowrap' : 'normal',
148
148
  }}
149
149
  >
150
150
  {headerElement}
@@ -123,8 +123,8 @@ export const MRT_FilterTypeMenu: FC<Props> = ({
123
123
  },
124
124
  ].filter((filterType) =>
125
125
  header
126
- ? !header.column.enabledFilterTypes ||
127
- header.column.enabledFilterTypes.includes(filterType.type)
126
+ ? !header.column.enabledColumnFilterTypes ||
127
+ header.column.enabledColumnFilterTypes.includes(filterType.type)
128
128
  : (!enabledGlobalFilterTypes ||
129
129
  enabledGlobalFilterTypes.includes(filterType.type)) &&
130
130
  [
@@ -1,10 +1,10 @@
1
1
  import React, { FC } from 'react';
2
2
  import { FormControlLabel, MenuItem, Switch } from '@mui/material';
3
- import type { MRT_ColumnInstance, MRT_TableInstance } from '..';
3
+ import type { MRT_Column, MRT_TableInstance } from '..';
4
4
  import { commonMenuItemStyles } from './MRT_ColumnActionMenu';
5
5
 
6
6
  interface Props {
7
- column: MRT_ColumnInstance;
7
+ column: MRT_Column;
8
8
  isSubMenu?: boolean;
9
9
  tableInstance: MRT_TableInstance;
10
10
  }
@@ -26,9 +26,9 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
26
26
  (column.columnDefType === 'group' &&
27
27
  column.getLeafColumns().some((col) => col.getIsVisible()));
28
28
 
29
- const handleToggleColumnHidden = (column: MRT_ColumnInstance) => {
29
+ const handleToggleColumnHidden = (column: MRT_Column) => {
30
30
  if (column.columnDefType === 'group') {
31
- column?.columns?.forEach?.((childColumn: MRT_ColumnInstance) => {
31
+ column?.columns?.forEach?.((childColumn: MRT_Column) => {
32
32
  childColumn.toggleVisibility(!switchChecked);
33
33
  });
34
34
  } else {
@@ -57,7 +57,7 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
57
57
  onChange={() => handleToggleColumnHidden(column)}
58
58
  />
59
59
  </MenuItem>
60
- {column.columns?.map((c: MRT_ColumnInstance, i) => (
60
+ {column.columns?.map((c: MRT_Column, i) => (
61
61
  <MRT_ShowHideColumnsMenuItems
62
62
  key={`${i}-${c.id}`}
63
63
  column={c}
@@ -14,10 +14,10 @@ export const MRT_Table: FC<Props> = ({ pinned, tableInstance }) => {
14
14
  const {
15
15
  getTableProps,
16
16
  options: {
17
- enableStickyHeader,
18
- hideTableFooter,
19
- hideTableHead,
20
17
  muiTableProps,
18
+ enableTableHead,
19
+ enableTableFooter,
20
+ enableStickyHeader,
21
21
  },
22
22
  } = tableInstance;
23
23
 
@@ -33,11 +33,11 @@ export const MRT_Table: FC<Props> = ({ pinned, tableInstance }) => {
33
33
 
34
34
  return (
35
35
  <Table stickyHeader={enableStickyHeader} {...tableProps}>
36
- {!hideTableHead && (
36
+ {enableTableHead && (
37
37
  <MRT_TableHead pinned={pinned} tableInstance={tableInstance} />
38
38
  )}
39
39
  <MRT_TableBody pinned={pinned} tableInstance={tableInstance} />
40
- {!hideTableFooter && (
40
+ {enableTableFooter && (
41
41
  <MRT_TableFooter pinned={pinned} tableInstance={tableInstance} />
42
42
  )}
43
43
  </Table>
@@ -12,7 +12,7 @@ interface Props {
12
12
  export const MRT_TablePaper: FC<Props> = ({ tableInstance }) => {
13
13
  const {
14
14
  getState,
15
- options: { hideToolbarBottom, hideToolbarTop, muiTablePaperProps },
15
+ options: { enableToolbarBottom, enableToolbarTop, muiTablePaperProps },
16
16
  } = tableInstance;
17
17
 
18
18
  const { isFullScreen } = getState();
@@ -21,8 +21,10 @@ export const MRT_TablePaper: FC<Props> = ({ tableInstance }) => {
21
21
  if (typeof window !== 'undefined') {
22
22
  if (isFullScreen) {
23
23
  document.body.style.overflow = 'hidden';
24
+ document.body.style.height = '100vh';
24
25
  } else {
25
26
  document.body.style.overflow = 'auto';
27
+ document.body.style.height = 'auto';
26
28
  }
27
29
  }
28
30
  }, [isFullScreen]);
@@ -41,23 +43,17 @@ export const MRT_TablePaper: FC<Props> = ({ tableInstance }) => {
41
43
  ...tablePaperProps?.sx,
42
44
  }}
43
45
  style={{
44
- height: isFullScreen ? '100%' : undefined,
45
- left: isFullScreen ? '0' : undefined,
46
+ height: isFullScreen ? '100vh' : undefined,
46
47
  margin: isFullScreen ? '0' : undefined,
47
- maxHeight: isFullScreen ? '100%' : undefined,
48
- maxWidth: isFullScreen ? '100%' : undefined,
49
- overflowY: !isFullScreen ? 'hidden' : undefined,
50
- position: isFullScreen ? 'fixed' : undefined,
51
- right: isFullScreen ? '0' : undefined,
52
- top: isFullScreen ? '0' : undefined,
48
+ maxHeight: isFullScreen ? '100vh' : undefined,
49
+ maxWidth: isFullScreen ? '100vw' : undefined,
50
+ padding: isFullScreen ? '0' : undefined,
53
51
  width: isFullScreen ? '100vw' : undefined,
54
- zIndex: isFullScreen ? 1200 : 1,
55
- bottom: isFullScreen ? '0' : undefined,
56
52
  }}
57
53
  >
58
- {!hideToolbarTop && <MRT_ToolbarTop tableInstance={tableInstance} />}
54
+ {enableToolbarTop && <MRT_ToolbarTop tableInstance={tableInstance} />}
59
55
  <MRT_TableContainer tableInstance={tableInstance} />
60
- {!hideToolbarBottom && (
56
+ {enableToolbarBottom && (
61
57
  <MRT_ToolbarBottom tableInstance={tableInstance} />
62
58
  )}
63
59
  </Paper>
@@ -1,4 +1,4 @@
1
- import React, { useMemo, useState } from 'react';
1
+ import React, { useEffect, useMemo, useState } from 'react';
2
2
  import {
3
3
  PaginationState,
4
4
  Table,
@@ -14,12 +14,7 @@ import {
14
14
  getCoreRowModelSync,
15
15
  ColumnDef,
16
16
  } from '@tanstack/react-table';
17
- import {
18
- MRT_ColumnInterface,
19
- MRT_FilterType,
20
- MRT_Row,
21
- MRT_TableInstance,
22
- } from '..';
17
+ import { MRT_ColumnDef, MRT_FilterType, MRT_Row, MRT_TableInstance } from '..';
23
18
  import { MRT_ExpandAllButton } from '../buttons/MRT_ExpandAllButton';
24
19
  import { MRT_ExpandButton } from '../buttons/MRT_ExpandButton';
25
20
  import { MRT_ToggleRowActionMenuButton } from '../buttons/MRT_ToggleRowActionMenuButton';
@@ -34,14 +29,18 @@ import {
34
29
  } from '../utils';
35
30
  import { defaultFilterFNs } from '../filtersFNs';
36
31
  import { MRT_FILTER_TYPE } from '../enums';
32
+ import { Box, Dialog, Grow } from '@mui/material';
37
33
 
38
34
  export const MRT_TableRoot = <D extends Record<string, any> = {}>(
39
35
  props: MaterialReactTableProps<D>,
40
36
  ) => {
41
- const idPrefix = useMemo(
42
- () => props.idPrefix ?? Math.random().toString(36).substring(2, 9),
37
+ const [idPrefix, setIdPrefix] = useState(props.idPrefix);
38
+ useEffect(
39
+ () =>
40
+ setIdPrefix(props.idPrefix ?? Math.random().toString(36).substring(2, 9)),
43
41
  [props.idPrefix],
44
42
  );
43
+
45
44
  const [currentEditingRow, setCurrentEditingRow] = useState<MRT_Row | null>(
46
45
  null,
47
46
  );
@@ -68,16 +67,14 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
68
67
  }>(() =>
69
68
  Object.assign(
70
69
  {},
71
- ...getAllLeafColumnDefs(props.columns as MRT_ColumnInterface[]).map(
72
- (c) => ({
73
- [c.id as string]:
74
- c.filter ??
75
- props?.initialState?.columnFilters?.find((cf) => cf.id === c.id) ??
76
- (!!c.filterSelectOptions?.length
77
- ? MRT_FILTER_TYPE.EQUALS
78
- : MRT_FILTER_TYPE.BEST_MATCH),
79
- }),
80
- ),
70
+ ...getAllLeafColumnDefs(props.columns as MRT_ColumnDef[]).map((c) => ({
71
+ [c.id as string]:
72
+ c.filter ??
73
+ props?.initialState?.columnFilters?.find((cf) => cf.id === c.id) ??
74
+ (!!c.filterSelectOptions?.length
75
+ ? MRT_FILTER_TYPE.EQUALS
76
+ : MRT_FILTER_TYPE.BEST_MATCH),
77
+ })),
81
78
  ),
82
79
  );
83
80
 
@@ -184,11 +181,11 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
184
181
  ? [...Array(10).fill(null)].map(() =>
185
182
  Object.assign(
186
183
  {},
187
- ...getAllLeafColumnDefs(
188
- props.columns as MRT_ColumnInterface[],
189
- ).map((c) => ({
190
- [c.id]: null,
191
- })),
184
+ ...getAllLeafColumnDefs(props.columns as MRT_ColumnDef[]).map(
185
+ (c) => ({
186
+ [c.id]: null,
187
+ }),
188
+ ),
192
189
  ),
193
190
  )
194
191
  : props.data,
@@ -198,9 +195,6 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
198
195
  //@ts-ignore
199
196
  const tableInstance: MRT_TableInstance<{}> = {
200
197
  ...useTableInstance(table, {
201
- ...props,
202
- columns,
203
- data,
204
198
  //@ts-ignore
205
199
  filterTypes: defaultFilterFNs,
206
200
  getColumnFilteredRowModel: getColumnFilteredRowModelSync(),
@@ -210,13 +204,14 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
210
204
  getGroupedRowModel: getGroupedRowModelSync(),
211
205
  getPaginationRowModel: getPaginationRowModel(),
212
206
  getSortedRowModel: getSortedRowModelSync(),
213
- getSubRows: props.getSubRows ?? ((originalRow: D) => originalRow.subRows),
207
+ getSubRows: (originalRow: D) => originalRow.subRows,
214
208
  globalFilterType: currentGlobalFilterType,
215
209
  idPrefix,
216
- //@ts-ignore
217
- initialState: props.initialState,
218
210
  onPaginationChange: (updater: any) =>
219
211
  setPagination((old) => functionalUpdate(updater, old)),
212
+ ...props,
213
+ columns,
214
+ data,
220
215
  state: {
221
216
  currentEditingRow,
222
217
  currentFilterTypes,
@@ -239,5 +234,23 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
239
234
  setShowGlobalFilter,
240
235
  };
241
236
 
242
- return <MRT_TablePaper tableInstance={tableInstance} />;
237
+ return (
238
+ <>
239
+ <Dialog
240
+ TransitionComponent={Grow}
241
+ PaperComponent={Box}
242
+ disablePortal
243
+ fullScreen
244
+ keepMounted={false}
245
+ onClose={() => tableInstance.setIsFullScreen(false)}
246
+ open={tableInstance.getState().isFullScreen}
247
+ transitionDuration={400}
248
+ >
249
+ <MRT_TablePaper tableInstance={tableInstance} />
250
+ </Dialog>
251
+ {!tableInstance.getState().isFullScreen && (
252
+ <MRT_TablePaper tableInstance={tableInstance} />
253
+ )}
254
+ </>
255
+ );
243
256
  };
@@ -15,7 +15,7 @@ export const MRT_ToolbarBottom: FC<Props> = ({ tableInstance }) => {
15
15
  const {
16
16
  getState,
17
17
  options: {
18
- hideToolbarInternalActions,
18
+ enableToolbarInternalActions,
19
19
  idPrefix,
20
20
  enablePagination,
21
21
  muiTableToolbarBottomProps,
@@ -51,7 +51,7 @@ export const MRT_ToolbarBottom: FC<Props> = ({ tableInstance }) => {
51
51
  <Box
52
52
  sx={{ display: 'flex', justifyContent: 'space-between', width: '100%' }}
53
53
  >
54
- {!hideToolbarInternalActions && positionToolbarActions === 'bottom' ? (
54
+ {enableToolbarInternalActions && positionToolbarActions === 'bottom' ? (
55
55
  <MRT_ToolbarInternalButtons tableInstance={tableInstance} />
56
56
  ) : (
57
57
  <span />
@@ -29,7 +29,7 @@ export const MRT_ToolbarTop: FC<Props> = ({ tableInstance }) => {
29
29
  options: {
30
30
  enableGlobalFilter,
31
31
  enablePagination,
32
- hideToolbarInternalActions,
32
+ enableToolbarInternalActions,
33
33
  idPrefix,
34
34
  muiTableToolbarTopProps,
35
35
  positionPagination,
@@ -82,7 +82,7 @@ export const MRT_ToolbarTop: FC<Props> = ({ tableInstance }) => {
82
82
  {enableGlobalFilter && (
83
83
  <MRT_SearchTextField tableInstance={tableInstance} />
84
84
  )}
85
- {!hideToolbarInternalActions && positionToolbarActions === 'top' && (
85
+ {enableToolbarInternalActions && positionToolbarActions === 'top' && (
86
86
  <MRT_ToolbarInternalButtons tableInstance={tableInstance} />
87
87
  )}
88
88
  </Box>
package/src/utils.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  import { ColumnDef, Table } from '@tanstack/react-table';
2
- import { MRT_ColumnInterface, MRT_FilterType } from '.';
2
+ import { MRT_ColumnDef, MRT_FilterType } from '.';
3
3
  import { MRT_FILTER_TYPE } from './enums';
4
4
 
5
5
  export const getAllLeafColumnDefs = (
6
- columns: MRT_ColumnInterface[],
7
- ): MRT_ColumnInterface[] => {
8
- let lowestLevelColumns: MRT_ColumnInterface[] = columns;
9
- let currentCols: MRT_ColumnInterface[] | undefined = columns;
6
+ columns: MRT_ColumnDef[],
7
+ ): MRT_ColumnDef[] => {
8
+ let lowestLevelColumns: MRT_ColumnDef[] = columns;
9
+ let currentCols: MRT_ColumnDef[] | undefined = columns;
10
10
  while (!!currentCols?.length && currentCols.some((col) => col.columns)) {
11
- const nextCols: MRT_ColumnInterface[] = currentCols
11
+ const nextCols: MRT_ColumnDef[] = currentCols
12
12
  .filter((col) => !!col.columns)
13
13
  .map((col) => col.columns)
14
- .flat() as MRT_ColumnInterface[];
14
+ .flat() as MRT_ColumnDef[];
15
15
  if (nextCols.every((col) => !col?.columns)) {
16
16
  lowestLevelColumns = [...lowestLevelColumns, ...nextCols];
17
17
  }
@@ -22,7 +22,7 @@ export const getAllLeafColumnDefs = (
22
22
 
23
23
  export const createGroup = <D extends Record<string, any> = {}>(
24
24
  table: Table<D>,
25
- column: MRT_ColumnInterface<D>,
25
+ column: MRT_ColumnDef<D>,
26
26
  currentFilterTypes: { [key: string]: MRT_FilterType },
27
27
  ): ColumnDef<D> =>
28
28
  table.createGroup({
@@ -36,7 +36,7 @@ export const createGroup = <D extends Record<string, any> = {}>(
36
36
 
37
37
  export const createDataColumn = <D extends Record<string, any> = {}>(
38
38
  table: Table<D>,
39
- column: MRT_ColumnInterface<D>,
39
+ column: MRT_ColumnDef<D>,
40
40
  currentFilterTypes: { [key: string]: MRT_FilterType },
41
41
  ): ColumnDef<D> => // @ts-ignore
42
42
  table.createDataColumn(column.id, {
@@ -46,5 +46,5 @@ export const createDataColumn = <D extends Record<string, any> = {}>(
46
46
 
47
47
  export const createDisplayColumn = <D extends Record<string, any> = {}>(
48
48
  table: Table<D>,
49
- column: Omit<MRT_ColumnInterface<D>, 'header'> & { header?: string },
49
+ column: Omit<MRT_ColumnDef<D>, 'header'> & { header?: string },
50
50
  ): ColumnDef<D> => table.createDisplayColumn(column);