material-react-table 3.0.0-beta.2 → 3.0.0

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.
@@ -89,7 +89,7 @@ const MRT_Localization_NO = {
89
89
  unpin: 'Løsne',
90
90
  unpinAll: 'Løsne alle',
91
91
  ungroupByColumn: 'Oppgrupper etter {column}',
92
- selectedCountOfRowCountRowsSelected: '{selected} av {count} rader valgt',
92
+ selectedCountOfRowCountRowsSelected: '{selectedCount} av {rowCount} rader valgt',
93
93
  };
94
94
 
95
95
  export { MRT_Localization_NO };
@@ -93,7 +93,7 @@ const MRT_Localization_NO = {
93
93
  unpin: 'Løsne',
94
94
  unpinAll: 'Løsne alle',
95
95
  ungroupByColumn: 'Oppgrupper etter {column}',
96
- selectedCountOfRowCountRowsSelected: '{selected} av {count} rader valgt',
96
+ selectedCountOfRowCountRowsSelected: '{selectedCount} av {rowCount} rader valgt',
97
97
  };
98
98
 
99
99
  exports.MRT_Localization_NO = MRT_Localization_NO;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "3.0.0-beta.2",
2
+ "version": "3.0.0",
3
3
  "license": "MIT",
4
4
  "name": "material-react-table",
5
5
  "description": "A fully featured Material UI V6 implementation of TanStack React Table V8, written from the ground up in TypeScript.",
@@ -110,8 +110,8 @@
110
110
  "@mui/icons-material": ">=6",
111
111
  "@mui/material": ">=6",
112
112
  "@mui/x-date-pickers": ">=7.15",
113
- "react": ">=17.0",
114
- "react-dom": ">=17.0"
113
+ "react": ">=18.0",
114
+ "react-dom": ">=18.0"
115
115
  },
116
116
  "dependencies": {
117
117
  "@tanstack/match-sorter-utils": "8.19.4",
@@ -49,7 +49,9 @@ export const MRT_RowPinButton = <TData extends MRT_RowData>({
49
49
  >
50
50
  <IconButton
51
51
  aria-label={localization.pin}
52
+ onBlur={() => setTooltipOpened(false)}
52
53
  onClick={handleTogglePin}
54
+ onFocus={() => setTooltipOpened(true)}
53
55
  onMouseEnter={() => setTooltipOpened(true)}
54
56
  onMouseLeave={() => setTooltipOpened(false)}
55
57
  size="small"
@@ -36,7 +36,9 @@ export const MRT_ToggleFullScreenButton = <TData extends MRT_RowData>({
36
36
  >
37
37
  <IconButton
38
38
  aria-label={localization.toggleFullScreen}
39
+ onBlur={() => setTooltipOpened(false)}
39
40
  onClick={handleToggleFullScreen}
41
+ onFocus={() => setTooltipOpened(true)}
40
42
  onMouseEnter={() => setTooltipOpened(true)}
41
43
  onMouseLeave={() => setTooltipOpened(false)}
42
44
  {...rest}
@@ -17,6 +17,7 @@ export const MRT_TableLoadingOverlay = <TData extends MRT_RowData>({
17
17
  }: MRT_TableLoadingOverlayProps<TData>) => {
18
18
  const {
19
19
  options: {
20
+ id,
20
21
  localization,
21
22
  mrtTheme: { baseBackgroundColor },
22
23
  muiCircularProgressProps,
@@ -48,7 +49,7 @@ export const MRT_TableLoadingOverlay = <TData extends MRT_RowData>({
48
49
  {circularProgressProps?.Component ?? (
49
50
  <CircularProgress
50
51
  aria-label={localization.noRecordsToDisplay}
51
- id="mrt-progress"
52
+ id={`mrt-progress-${id}`}
52
53
  {...circularProgressProps}
53
54
  />
54
55
  )}
@@ -1,5 +1,6 @@
1
1
  import Paper, { type PaperProps } from '@mui/material/Paper';
2
- import { useTheme } from '@mui/material';
2
+ import FocusTrap from '@mui/material/Unstable_TrapFocus/FocusTrap';
3
+ import { useTheme } from '@mui/material/styles';
3
4
  import { MRT_TableContainer } from './MRT_TableContainer';
4
5
  import { type MRT_RowData, type MRT_TableInstance } from '../../types';
5
6
  import { parseFromValuesOrFunc } from '../../utils/utils';
@@ -37,52 +38,55 @@ export const MRT_TablePaper = <TData extends MRT_RowData>({
37
38
  const theme = useTheme();
38
39
 
39
40
  return (
40
- <Paper
41
- elevation={2}
42
- {...paperProps}
43
- ref={(ref: HTMLDivElement) => {
44
- tablePaperRef.current = ref;
45
- if (paperProps?.ref) {
46
- //@ts-ignore
47
- paperProps.ref.current = ref;
48
- }
49
- }}
50
- style={{
51
- ...(isFullScreen
52
- ? {
53
- bottom: 0,
54
- height: '100dvh',
55
- left: 0,
56
- margin: 0,
57
- maxHeight: '100dvh',
58
- maxWidth: '100dvw',
59
- padding: 0,
60
- position: 'fixed',
61
- right: 0,
62
- top: 0,
63
- width: '100dvw',
64
- zIndex: theme.zIndex.modal,
65
- }
66
- : {}),
67
- ...paperProps?.style,
68
- }}
69
- sx={(theme) => ({
70
- backgroundColor: baseBackgroundColor,
71
- backgroundImage: 'unset',
72
- overflow: 'hidden',
73
- transition: 'all 100ms ease-in-out',
74
- ...(parseFromValuesOrFunc(paperProps?.sx, theme) as any),
75
- })}
76
- >
77
- {enableTopToolbar &&
78
- (parseFromValuesOrFunc(renderTopToolbar, { table }) ?? (
79
- <MRT_TopToolbar table={table} />
80
- ))}
81
- <MRT_TableContainer table={table} />
82
- {enableBottomToolbar &&
83
- (parseFromValuesOrFunc(renderBottomToolbar, { table }) ?? (
84
- <MRT_BottomToolbar table={table} />
85
- ))}
86
- </Paper>
41
+ <FocusTrap disableEnforceFocus open={isFullScreen}>
42
+ <Paper
43
+ elevation={2}
44
+ onKeyDown={(e) => e.key === 'Escape' && table.setIsFullScreen(false)}
45
+ {...paperProps}
46
+ ref={(ref: HTMLDivElement) => {
47
+ tablePaperRef.current = ref;
48
+ if (paperProps?.ref) {
49
+ //@ts-ignore
50
+ paperProps.ref.current = ref;
51
+ }
52
+ }}
53
+ style={{
54
+ ...(isFullScreen
55
+ ? {
56
+ bottom: 0,
57
+ height: '100dvh',
58
+ left: 0,
59
+ margin: 0,
60
+ maxHeight: '100dvh',
61
+ maxWidth: '100dvw',
62
+ padding: 0,
63
+ position: 'fixed',
64
+ right: 0,
65
+ top: 0,
66
+ width: '100dvw',
67
+ zIndex: theme.zIndex.modal,
68
+ }
69
+ : {}),
70
+ ...paperProps?.style,
71
+ }}
72
+ sx={(theme) => ({
73
+ backgroundColor: baseBackgroundColor,
74
+ backgroundImage: 'unset',
75
+ overflow: 'hidden',
76
+ transition: 'all 100ms ease-in-out',
77
+ ...(parseFromValuesOrFunc(paperProps?.sx, theme) as any),
78
+ })}
79
+ >
80
+ {enableTopToolbar &&
81
+ (parseFromValuesOrFunc(renderTopToolbar, { table }) ?? (
82
+ <MRT_TopToolbar table={table} />
83
+ ))}
84
+ <MRT_TableContainer table={table} />
85
+ {enableBottomToolbar &&
86
+ (parseFromValuesOrFunc(renderBottomToolbar, { table }) ?? (
87
+ <MRT_BottomToolbar table={table} />
88
+ ))}
89
+ </Paper>
90
+ </FocusTrap>
87
91
  );
88
92
  };
@@ -41,6 +41,7 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
41
41
  options: {
42
42
  enableToolbarInternalActions,
43
43
  icons: { ChevronLeftIcon, ChevronRightIcon, FirstPageIcon, LastPageIcon },
44
+ id,
44
45
  localization,
45
46
  muiPaginationProps,
46
47
  paginationDisplayMode,
@@ -48,7 +49,6 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
48
49
  } = table;
49
50
  const {
50
51
  pagination: { pageIndex = 0, pageSize = 10 },
51
- showGlobalFilter,
52
52
  } = getState();
53
53
 
54
54
  const paginationProps = {
@@ -94,9 +94,7 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
94
94
  justifyContent: { md: 'space-between', sm: 'center' },
95
95
  justifySelf: 'flex-end',
96
96
  mt:
97
- position === 'top' &&
98
- enableToolbarInternalActions &&
99
- !showGlobalFilter
97
+ position === 'top' && enableToolbarInternalActions
100
98
  ? '3rem'
101
99
  : undefined,
102
100
  position: 'relative',
@@ -107,7 +105,7 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
107
105
  >
108
106
  {showRowsPerPage && (
109
107
  <Box sx={{ alignItems: 'center', display: 'flex', gap: '8px' }}>
110
- <InputLabel htmlFor="mrt-rows-per-page" sx={{ mb: 0 }}>
108
+ <InputLabel htmlFor={`mrt-rows-per-page-${id}`} sx={{ mb: 0 }}>
111
109
  {localization.rowsPerPage}
112
110
  </InputLabel>
113
111
  <Select
@@ -116,7 +114,7 @@ export const MRT_TablePagination = <TData extends MRT_RowData>({
116
114
  disabled={disabled}
117
115
  inputProps={{
118
116
  'aria-label': localization.rowsPerPage,
119
- id: 'mrt-rows-per-page',
117
+ id: `mrt-rows-per-page-${id}`,
120
118
  }}
121
119
  label={localization.rowsPerPage}
122
120
  onChange={(event) =>
@@ -1,4 +1,4 @@
1
- import { useMemo } from 'react';
1
+ import { useId, useMemo } from 'react';
2
2
  import {
3
3
  getCoreRowModel,
4
4
  getExpandedRowModel,
@@ -92,6 +92,7 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
92
92
  enableTopToolbar = true,
93
93
  filterFns,
94
94
  icons,
95
+ id = useId(),
95
96
  layoutMode,
96
97
  localization,
97
98
  manualFiltering,
@@ -244,6 +245,7 @@ export const useMRT_TableOptions: <TData extends MRT_RowData>(
244
245
  enableSorting && !manualSorting ? getSortedRowModel() : undefined,
245
246
  getSubRows: (row) => row?.subRows,
246
247
  icons,
248
+ id,
247
249
  layoutMode,
248
250
  localization,
249
251
  manualFiltering,
package/src/locales/no.ts CHANGED
@@ -93,5 +93,6 @@ export const MRT_Localization_NO: MRT_Localization = {
93
93
  unpinAll: 'Løsne alle',
94
94
 
95
95
  ungroupByColumn: 'Oppgrupper etter {column}',
96
- selectedCountOfRowCountRowsSelected: '{selected} av {count} rader valgt',
96
+ selectedCountOfRowCountRowsSelected:
97
+ '{selectedCount} av {rowCount} rader valgt',
97
98
  };
package/src/types.ts CHANGED
@@ -894,6 +894,7 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
894
894
  globalFilterFn?: MRT_FilterOption;
895
895
  globalFilterModeOptions?: MRT_FilterOption[] | null;
896
896
  icons?: Partial<MRT_Icons>;
897
+ id?: string;
897
898
  initialState?: Partial<MRT_TableState<TData>>;
898
899
  /**
899
900
  * Changes which kind of CSS layout is used to render the table. `semantic` uses default semantic HTML elements, while `grid` adds CSS grid and flexbox styles
@@ -1132,6 +1133,9 @@ export interface MRT_TableOptions<TData extends MRT_RowData>
1132
1133
  muiTableContainerProps?:
1133
1134
  | ((props: { table: MRT_TableInstance<TData> }) => TableContainerProps)
1134
1135
  | TableContainerProps;
1136
+ /**
1137
+ * @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
1138
+ */
1135
1139
  muiTableFooterCellProps?:
1136
1140
  | ((props: {
1137
1141
  column: MRT_Column<TData>;