material-react-table 0.16.0 → 0.16.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.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.16.0",
2
+ "version": "0.16.1",
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.",
@@ -36,7 +36,6 @@ export const MRT_TableHeadCellResizeHandle: FC<Props> = ({
36
36
  touchAction: 'none',
37
37
  transition: column.getIsResizing() ? undefined : 'all 0.2s ease-in-out',
38
38
  userSelect: 'none',
39
- zIndex: 2000,
40
39
  '&:active': {
41
40
  backgroundColor: theme.palette.info.main,
42
41
  opacity: 1,
@@ -9,22 +9,9 @@ interface Props {
9
9
  }
10
10
 
11
11
  export const MRT_FilterRangeFields: FC<Props> = ({ header, instance }) => {
12
- const {
13
- options: { localization },
14
- } = instance;
15
-
16
12
  return (
17
- <Box sx={{ display: 'grid', gridTemplateColumns: '6fr auto 5fr' }}>
13
+ <Box sx={{ display: 'grid', gridTemplateColumns: '6fr 6fr', gap: '1rem' }}>
18
14
  <MRT_FilterTextField header={header} inputIndex={0} instance={instance} />
19
- <Box
20
- sx={{
21
- width: '100%',
22
- minWidth: '5ch',
23
- textAlign: 'center',
24
- }}
25
- >
26
- {localization.to}
27
- </Box>
28
15
  <MRT_FilterTextField header={header} inputIndex={1} instance={instance} />
29
16
  </Box>
30
17
  );
@@ -55,11 +55,11 @@ export interface MRT_Localization {
55
55
  sortedByColumnAsc: string;
56
56
  sortedByColumnDesc: string;
57
57
  thenBy: string;
58
- to: string;
59
58
  toggleDensity: string;
60
59
  toggleFullScreen: string;
61
60
  toggleSelectAll: string;
62
61
  toggleSelectRow: string;
62
+ toggleVisibility: string;
63
63
  ungroupByColumn: string;
64
64
  unpin: string;
65
65
  unpinAll: string;
@@ -124,11 +124,11 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
124
124
  sortedByColumnAsc: 'Sorted by {column} ascending',
125
125
  sortedByColumnDesc: 'Sorted by {column} descending',
126
126
  thenBy: ', then by ',
127
- to: 'to',
128
127
  toggleDensity: 'Toggle density',
129
128
  toggleFullScreen: 'Toggle full screen',
130
129
  toggleSelectAll: 'Toggle select all',
131
130
  toggleSelectRow: 'Toggle select row',
131
+ toggleVisibility: 'Toggle visibility',
132
132
  ungroupByColumn: 'Ungroup by {column}',
133
133
  unpin: 'Unpin',
134
134
  unpinAll: 'Unpin all',
@@ -1,6 +1,13 @@
1
1
  import React, { FC, Ref } from 'react';
2
2
  import { useDrag, useDrop } from 'react-dnd';
3
- import { Box, FormControlLabel, MenuItem, Switch } from '@mui/material';
3
+ import {
4
+ Box,
5
+ FormControlLabel,
6
+ MenuItem,
7
+ Switch,
8
+ Tooltip,
9
+ Typography,
10
+ } from '@mui/material';
4
11
  import { MRT_ColumnPinningButtons } from '../buttons/MRT_ColumnPinningButtons';
5
12
  import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton';
6
13
  import { reorderColumn } from '../utils';
@@ -21,7 +28,13 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
21
28
  }) => {
22
29
  const {
23
30
  getState,
24
- options: { enableColumnOrdering, onColumnVisibilityChanged },
31
+ options: {
32
+ enableColumnOrdering,
33
+ enableHiding,
34
+ enablePinning,
35
+ localization,
36
+ onColumnVisibilityChanged,
37
+ },
25
38
  setColumnOrder,
26
39
  } = instance;
27
40
 
@@ -85,35 +98,56 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
85
98
  >
86
99
  {columnDefType !== 'group' &&
87
100
  enableColumnOrdering &&
88
- columnDef.enableColumnOrdering !== false &&
89
- !allColumns.some((col) => col.columnDefType === 'group') && (
101
+ !allColumns.some((col) => col.columnDefType === 'group') &&
102
+ (columnDef.enableColumnOrdering !== false ? (
90
103
  <MRT_GrabHandleButton
91
104
  ref={dragRef as Ref<HTMLButtonElement>}
92
105
  instance={instance}
93
106
  />
94
- )}
95
- {!isSubMenu && column.getCanPin() && (
96
- <MRT_ColumnPinningButtons column={column} instance={instance} />
97
- )}
98
- <FormControlLabel
99
- componentsProps={{
100
- typography: {
101
- sx: {
102
- mb: 0,
103
- opacity: columnDefType !== 'display' ? 1 : 0.5,
107
+ ) : (
108
+ <Box sx={{ width: '28px' }} />
109
+ ))}
110
+ {enablePinning &&
111
+ !isSubMenu &&
112
+ (column.getCanPin() ? (
113
+ <MRT_ColumnPinningButtons column={column} instance={instance} />
114
+ ) : (
115
+ <Box sx={{ width: '70px' }} />
116
+ ))}
117
+ {enableHiding ? (
118
+ <FormControlLabel
119
+ componentsProps={{
120
+ typography: {
121
+ sx: {
122
+ mb: 0,
123
+ opacity: columnDefType !== 'display' ? 1 : 0.5,
124
+ },
104
125
  },
105
- },
106
- }}
107
- checked={switchChecked}
108
- control={<Switch />}
109
- disabled={
110
- (isSubMenu && switchChecked) ||
111
- !column.getCanHide() ||
112
- column.getIsGrouped()
113
- }
114
- label={columnDef.header}
115
- onChange={() => handleToggleColumnHidden(column)}
116
- />
126
+ }}
127
+ checked={switchChecked}
128
+ control={
129
+ <Tooltip
130
+ arrow
131
+ enterDelay={1000}
132
+ enterNextDelay={1000}
133
+ title={localization.toggleVisibility}
134
+ >
135
+ <Switch />
136
+ </Tooltip>
137
+ }
138
+ disabled={
139
+ (isSubMenu && switchChecked) ||
140
+ !column.getCanHide() ||
141
+ column.getIsGrouped()
142
+ }
143
+ label={columnDef.header}
144
+ onChange={() => handleToggleColumnHidden(column)}
145
+ />
146
+ ) : (
147
+ <Typography sx={{ alignSelf: 'center' }}>
148
+ {columnDef.header}
149
+ </Typography>
150
+ )}
117
151
  </Box>
118
152
  </MenuItem>
119
153
  {column.columns?.map((c: MRT_Column, i) => (
@@ -42,6 +42,9 @@ export const MRT_TablePaper: FC<Props> = ({ instance }) => {
42
42
  sx={{
43
43
  transition: 'all 0.2s ease-in-out',
44
44
  ...tablePaperProps?.sx,
45
+ }}
46
+ style={{
47
+ ...tablePaperProps?.style,
45
48
  height: isFullScreen ? '100vh' : undefined,
46
49
  margin: isFullScreen ? '0' : undefined,
47
50
  maxHeight: isFullScreen ? '100vh' : undefined,
@@ -168,7 +168,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
168
168
  id: 'mrt-expand',
169
169
  muiTableBodyCellProps: props.muiTableBodyCellProps,
170
170
  muiTableHeadCellProps: props.muiTableHeadCellProps,
171
- size: 50,
171
+ size: 60,
172
172
  }),
173
173
  columnOrder.includes('mrt-select') &&
174
174
  createDisplayColumn(table, {
@@ -183,7 +183,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
183
183
  id: 'mrt-select',
184
184
  muiTableBodyCellProps: props.muiTableBodyCellProps,
185
185
  muiTableHeadCellProps: props.muiTableHeadCellProps,
186
- size: 50,
186
+ size: 60,
187
187
  }),
188
188
  columnOrder.includes('mrt-row-numbers') &&
189
189
  createDisplayColumn(table, {
@@ -193,7 +193,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
193
193
  id: 'mrt-row-numbers',
194
194
  muiTableBodyCellProps: props.muiTableBodyCellProps,
195
195
  muiTableHeadCellProps: props.muiTableHeadCellProps,
196
- size: 50,
196
+ size: 60,
197
197
  }),
198
198
  ].filter(Boolean) as MRT_ColumnDef<D>[];
199
199
  }, [
@@ -16,11 +16,13 @@ export const MRT_ToolbarInternalButtons: FC<Props> = ({ instance }) => {
16
16
  const {
17
17
  options: {
18
18
  enableColumnFilters,
19
+ enableColumnOrdering,
19
20
  enableDensityToggle,
20
21
  enableFilters,
21
22
  enableFullScreenToggle,
22
23
  enableGlobalFilter,
23
24
  enableHiding,
25
+ enablePinning,
24
26
  positionGlobalFilter,
25
27
  renderToolbarInternalActions,
26
28
  },
@@ -52,7 +54,9 @@ export const MRT_ToolbarInternalButtons: FC<Props> = ({ instance }) => {
52
54
  {enableFilters && enableColumnFilters && (
53
55
  <MRT_ToggleFiltersButton instance={instance} />
54
56
  )}
55
- {enableHiding && <MRT_ShowHideColumnsButton instance={instance} />}
57
+ {(enableHiding || enableColumnOrdering || enablePinning) && (
58
+ <MRT_ShowHideColumnsButton instance={instance} />
59
+ )}
56
60
  {enableDensityToggle && (
57
61
  <MRT_ToggleDensePaddingButton instance={instance} />
58
62
  )}