material-react-table 0.8.11 → 0.8.12

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
  anchorEl: HTMLElement | null;
5
5
  isSubMenu?: boolean;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.8.11",
2
+ "version": "0.8.12",
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.",
@@ -48,11 +48,11 @@
48
48
  "size-limit": [
49
49
  {
50
50
  "path": "dist/material-react-table.cjs.production.min.js",
51
- "limit": "60 KB"
51
+ "limit": "50 KB"
52
52
  },
53
53
  {
54
54
  "path": "dist/material-react-table.esm.js",
55
- "limit": "60 KB"
55
+ "limit": "50 KB"
56
56
  }
57
57
  ],
58
58
  "devDependencies": {
@@ -63,17 +63,17 @@
63
63
  "@mui/icons-material": "^5.8.2",
64
64
  "@mui/material": "^5.8.2",
65
65
  "@size-limit/preset-small-lib": "^7.0.8",
66
- "@storybook/addon-a11y": "^6.5.5",
67
- "@storybook/addon-actions": "^6.5.5",
68
- "@storybook/addon-essentials": "^6.5.5",
66
+ "@storybook/addon-a11y": "^6.5.6",
67
+ "@storybook/addon-actions": "^6.5.6",
68
+ "@storybook/addon-essentials": "^6.5.6",
69
69
  "@storybook/addon-info": "^5.3.21",
70
- "@storybook/addon-links": "^6.5.5",
71
- "@storybook/addons": "^6.5.5",
72
- "@storybook/react": "^6.5.5",
73
- "@types/react": "^18.0.10",
70
+ "@storybook/addon-links": "^6.5.6",
71
+ "@storybook/addons": "^6.5.6",
72
+ "@storybook/react": "^6.5.6",
73
+ "@types/react": "^18.0.11",
74
74
  "@types/react-dom": "^18.0.5",
75
75
  "babel-loader": "^8.2.5",
76
- "eslint": "^8.16.0",
76
+ "eslint": "^8.17.0",
77
77
  "eslint-plugin-react-hooks": "^4.5.0",
78
78
  "husky": "^8.0.1",
79
79
  "prettier": "^2.6.2",
@@ -87,7 +87,7 @@
87
87
  "storybook-dark-mode": "^1.1.0",
88
88
  "tsdx": "^0.14.1",
89
89
  "tslib": "^2.4.0",
90
- "typescript": "^4.7.2"
90
+ "typescript": "^4.7.3"
91
91
  },
92
92
  "peerDependencies": {
93
93
  "@emotion/react": ">=11",
@@ -35,7 +35,6 @@ import {
35
35
  Header,
36
36
  HeaderGroup,
37
37
  Overwrite,
38
- PaginationState,
39
38
  ReactTableGenerics,
40
39
  Row,
41
40
  TableGenerics,
@@ -79,9 +78,11 @@ export type MRT_TableInstance<D extends Record<string, any> = {}> = Omit<
79
78
  >
80
79
  >,
81
80
  | 'getAllColumns'
81
+ | 'getAllFlatColumns'
82
82
  | 'getAllLeafColumns'
83
83
  | 'getColumn'
84
84
  | 'getExpandedRowModel'
85
+ | 'getFlatHeaders'
85
86
  | 'getPaginationRowModel'
86
87
  | 'getPrePaginationRowModel'
87
88
  | 'getRowModel'
@@ -90,9 +91,11 @@ export type MRT_TableInstance<D extends Record<string, any> = {}> = Omit<
90
91
  | 'options'
91
92
  > & {
92
93
  getAllColumns: () => MRT_Column<D>[];
94
+ getAllFlatColumns: () => MRT_Column<D>[];
93
95
  getAllLeafColumns: () => MRT_Column<D>[];
94
96
  getColumn: (columnId: string) => MRT_Column<D>;
95
97
  getExpandedRowModel: () => MRT_RowModel<D>;
98
+ getFlatHeaders: () => MRT_Header<D>[];
96
99
  getPaginationRowModel: () => MRT_RowModel<D>;
97
100
  getPrePaginationRowModel: () => MRT_RowModel<D>;
98
101
  getRowModel: () => MRT_RowModel<D>;
@@ -117,10 +120,7 @@ export type MRT_TableInstance<D extends Record<string, any> = {}> = Omit<
117
120
  setShowGlobalFilter: Dispatch<SetStateAction<boolean>>;
118
121
  };
119
122
 
120
- export type MRT_TableState<D extends Record<string, any> = {}> = Omit<
121
- TableState,
122
- 'pagination'
123
- > & {
123
+ export type MRT_TableState<D extends Record<string, any> = {}> = TableState & {
124
124
  currentEditingCell: MRT_Cell<D> | null;
125
125
  currentEditingRow: MRT_Row<D> | null;
126
126
  currentFilterFns: Record<string, string | Function>;
@@ -128,7 +128,6 @@ export type MRT_TableState<D extends Record<string, any> = {}> = Omit<
128
128
  isDensePadding: boolean;
129
129
  isLoading: boolean;
130
130
  isFullScreen: boolean;
131
- pagination: Partial<PaginationState>;
132
131
  showFilters: boolean;
133
132
  showGlobalFilter: boolean;
134
133
  showProgressBars: boolean;
@@ -39,7 +39,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
39
39
 
40
40
  const { column, row } = cell;
41
41
 
42
- const { columnDef } = column;
42
+ const { columnDef, columnDefType } = column;
43
43
 
44
44
  const mTableCellBodyProps =
45
45
  muiTableBodyCellProps instanceof Function
@@ -58,11 +58,11 @@ export const MRT_TableBodyCell: FC<Props> = ({
58
58
 
59
59
  const skeletonWidth = useMemo(
60
60
  () =>
61
- column.columnDefType === 'display'
61
+ columnDefType === 'display'
62
62
  ? column.getSize() / 2
63
63
  : Math.random() * (column.getSize() - column.getSize() / 3) +
64
64
  column.getSize() / 3,
65
- [column.columnDefType, column.getSize()],
65
+ [columnDefType, column.getSize()],
66
66
  );
67
67
 
68
68
  const isEditable =
@@ -136,10 +136,10 @@ export const MRT_TableBodyCell: FC<Props> = ({
136
136
  ? `${column.getStart('left')}px`
137
137
  : undefined,
138
138
  p: isDensePadding
139
- ? column.columnDefType === 'display'
139
+ ? columnDefType === 'display'
140
140
  ? '0 0.5rem'
141
141
  : '0.5rem'
142
- : column.columnDefType === 'display'
142
+ : columnDefType === 'display'
143
143
  ? '0.5rem 0.75rem'
144
144
  : '1rem',
145
145
  pl:
@@ -175,7 +175,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
175
175
  width={skeletonWidth}
176
176
  {...muiTableBodyCellSkeletonProps}
177
177
  />
178
- ) : column.columnDefType === 'display' ? (
178
+ ) : columnDefType === 'display' ? (
179
179
  columnDef.Cell?.({ cell, tableInstance })
180
180
  ) : cell.getIsPlaceholder() ||
181
181
  (row.getIsGrouped() &&
@@ -189,7 +189,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
189
189
  <>
190
190
  <MRT_CopyButton cell={cell} tableInstance={tableInstance}>
191
191
  <>
192
- {cell.column.columnDef?.Cell?.({ cell, tableInstance }) ??
192
+ {columnDef?.Cell?.({ cell, tableInstance }) ??
193
193
  cell.renderCell()}
194
194
  </>
195
195
  </MRT_CopyButton>
@@ -197,8 +197,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
197
197
  </>
198
198
  ) : (
199
199
  <>
200
- {cell.column.columnDef?.Cell?.({ cell, tableInstance }) ??
201
- cell.renderCell()}
200
+ {columnDef?.Cell?.({ cell, tableInstance }) ?? cell.renderCell()}
202
201
  {row.getIsGrouped() && <> ({row.subRows?.length ?? ''})</>}
203
202
  </>
204
203
  )}
@@ -17,6 +17,10 @@ export const MRT_CopyButton: FC<Props> = ({
17
17
  options: { localization, muiTableBodyCellCopyButtonProps },
18
18
  } = tableInstance;
19
19
 
20
+ const { column } = cell;
21
+
22
+ const { columnDef } = column;
23
+
20
24
  const [copied, setCopied] = useState(false);
21
25
 
22
26
  const handleCopy = (text: unknown) => {
@@ -31,12 +35,12 @@ export const MRT_CopyButton: FC<Props> = ({
31
35
  : muiTableBodyCellCopyButtonProps;
32
36
 
33
37
  const mcTableBodyCellCopyButtonProps =
34
- cell.column.columnDef.muiTableBodyCellCopyButtonProps instanceof Function
35
- ? cell.column.columnDef.muiTableBodyCellCopyButtonProps({
38
+ columnDef.muiTableBodyCellCopyButtonProps instanceof Function
39
+ ? columnDef.muiTableBodyCellCopyButtonProps({
36
40
  cell,
37
41
  tableInstance,
38
42
  })
39
- : cell.column.columnDef.muiTableBodyCellCopyButtonProps;
43
+ : columnDef.muiTableBodyCellCopyButtonProps;
40
44
 
41
45
  const buttonProps = {
42
46
  ...mTableBodyCellCopyButtonProps,
@@ -22,6 +22,8 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({
22
22
 
23
23
  const { column } = header;
24
24
 
25
+ const { columnDef } = column;
26
+
25
27
  const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
26
28
 
27
29
  const handleClick = (event: MouseEvent<HTMLElement>) => {
@@ -36,13 +38,12 @@ export const MRT_ToggleColumnActionMenuButton: FC<Props> = ({
36
38
  : muiTableHeadCellColumnActionsButtonProps;
37
39
 
38
40
  const mcTableHeadCellColumnActionsButtonProps =
39
- column.columnDef.muiTableHeadCellColumnActionsButtonProps instanceof
40
- Function
41
- ? column.columnDef.muiTableHeadCellColumnActionsButtonProps({
41
+ columnDef.muiTableHeadCellColumnActionsButtonProps instanceof Function
42
+ ? columnDef.muiTableHeadCellColumnActionsButtonProps({
42
43
  column,
43
44
  tableInstance,
44
45
  })
45
- : column.columnDef.muiTableHeadCellColumnActionsButtonProps;
46
+ : columnDef.muiTableHeadCellColumnActionsButtonProps;
46
47
 
47
48
  const iconButtonProps = {
48
49
  ...mTableHeadCellColumnActionsButtonProps,
@@ -17,7 +17,7 @@ export const MRT_TableFooterCell: FC<Props> = ({ footer, tableInstance }) => {
17
17
 
18
18
  const { column } = footer;
19
19
 
20
- const { columnDef } = column;
20
+ const { columnDef, columnDefType } = column;
21
21
 
22
22
  const mTableFooterCellProps =
23
23
  muiTableFooterCellProps instanceof Function
@@ -36,7 +36,7 @@ export const MRT_TableFooterCell: FC<Props> = ({ footer, tableInstance }) => {
36
36
 
37
37
  return (
38
38
  <TableCell
39
- align={column.columnDefType === 'group' ? 'center' : 'left'}
39
+ align={columnDefType === 'group' ? 'center' : 'left'}
40
40
  colSpan={footer.colSpan}
41
41
  variant="head"
42
42
  {...tableCellProps}
@@ -19,10 +19,10 @@ export const MRT_TableFooterRow: FC<Props> = ({
19
19
  // if no content in row, skip row
20
20
  if (
21
21
  !footerGroup.headers?.some(
22
- (h) =>
23
- (typeof h.column.columnDef.footer === 'string' &&
24
- !!h.column.columnDef.footer) ||
25
- h.column.columnDef.Footer,
22
+ (header) =>
23
+ (typeof header.column.columnDef.footer === 'string' &&
24
+ !!header.column.columnDef.footer) ||
25
+ header.column.columnDef.Footer,
26
26
  )
27
27
  )
28
28
  return null;
@@ -20,18 +20,25 @@ export const MRT_DraggableTableHeadCell: FC<Props> = ({
20
20
 
21
21
  const { columnOrder } = getState();
22
22
 
23
- const reorder = (item: MRT_Header, newIndex: number) => {
24
- const { index: currentIndex } = item;
25
- columnOrder.splice(newIndex, 0, columnOrder.splice(currentIndex, 1)[0]);
23
+ const reorder = (movingHeader: MRT_Header, receivingHeader: MRT_Header) => {
24
+ if (movingHeader.column.getCanPin()) {
25
+ movingHeader.column.pin(receivingHeader.column.getIsPinned());
26
+ }
27
+ const { index: currentIndex } = movingHeader;
28
+ columnOrder.splice(
29
+ receivingHeader.index,
30
+ 0,
31
+ columnOrder.splice(currentIndex, 1)[0],
32
+ );
26
33
  setColumnOrder([...columnOrder]);
27
34
  };
28
35
 
29
- const [, drop] = useDrop({
36
+ const [, dropRef] = useDrop({
30
37
  accept: 'header',
31
- drop: (item: MRT_Header) => reorder(item, header.index),
38
+ drop: (movingHeader: MRT_Header) => reorder(movingHeader, header),
32
39
  });
33
40
 
34
- const [{ isDragging }, drag, preview] = useDrag({
41
+ const [{ isDragging }, dragRef, previewRef] = useDrag({
35
42
  collect: (monitor) => ({
36
43
  isDragging: monitor.isDragging(),
37
44
  }),
@@ -41,11 +48,11 @@ export const MRT_DraggableTableHeadCell: FC<Props> = ({
41
48
 
42
49
  return (
43
50
  <MRT_TableHeadCell
44
- dragRef={drag}
45
- dropRef={drop}
51
+ dragRef={dragRef}
52
+ dropRef={dropRef}
46
53
  header={header}
47
54
  isDragging={isDragging}
48
- previewRef={preview}
55
+ previewRef={previewRef}
49
56
  tableInstance={tableInstance}
50
57
  />
51
58
  );
@@ -59,12 +59,12 @@ export const MRT_TableHeadCell: FC<Props> = ({
59
59
  };
60
60
 
61
61
  const headerElement = (
62
- column.columnDef?.Header instanceof Function
63
- ? column.columnDef?.Header?.({
62
+ columnDef?.Header instanceof Function
63
+ ? columnDef?.Header?.({
64
64
  header,
65
65
  tableInstance,
66
66
  })
67
- : column.columnDef?.Header ?? header.renderHeader()
67
+ : columnDef?.Header ?? header.renderHeader()
68
68
  ) as ReactNode;
69
69
 
70
70
  const getIsLastLeftPinnedColumn = () => {
@@ -123,12 +123,7 @@ export const MRT_TableHeadCell: FC<Props> = ({
123
123
  column.getIsPinned() && columnDefType !== 'group'
124
124
  ? 'sticky'
125
125
  : undefined,
126
- pt:
127
- columnDefType === 'display'
128
- ? 0
129
- : isDensePadding
130
- ? '0.75rem'
131
- : '1.25rem',
126
+ pt: columnDefType !== 'data' ? 0 : isDensePadding ? '0.25' : '.5rem',
132
127
  right:
133
128
  column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined,
134
129
  transition: `all ${enableColumnResizing ? 0 : '0.2s'} ease-in-out`,
@@ -24,11 +24,13 @@ export const MRT_TableHeadCellFilterLabel: FC<Props> = ({
24
24
 
25
25
  const { column } = header;
26
26
 
27
+ const { columnDef } = column;
28
+
27
29
  const filterFn = getState()?.currentFilterFns?.[header.id];
28
30
 
29
31
  const filterTooltip = !!column.getFilterValue()
30
32
  ? localization.filteringByColumn
31
- .replace('{column}', String(column.columnDef.header))
33
+ .replace('{column}', String(columnDef.header))
32
34
  .replace(
33
35
  '{filterType}',
34
36
  filterFn instanceof Function
@@ -17,6 +17,8 @@ export const MRT_TableHeadCellResizeHandle: FC<Props> = ({
17
17
 
18
18
  const { column } = header;
19
19
 
20
+ const { columnDefType } = column;
21
+
20
22
  return (
21
23
  <Divider
22
24
  flexItem
@@ -26,8 +28,7 @@ export const MRT_TableHeadCellResizeHandle: FC<Props> = ({
26
28
  borderRadius: '2px',
27
29
  borderRightWidth: '2px',
28
30
  cursor: 'col-resize',
29
- height:
30
- showFilters && column.columnDefType === 'data' ? '4rem' : '2rem',
31
+ height: showFilters && columnDefType === 'data' ? '4rem' : '2rem',
31
32
  opacity: 0.8,
32
33
  position: 'absolute',
33
34
  right: '1px',
@@ -17,16 +17,12 @@ export const MRT_TableHeadCellSortLabel: FC<Props> = ({
17
17
 
18
18
  const { column } = header;
19
19
 
20
+ const { columnDef } = column;
21
+
20
22
  const sortTooltip = !!column.getIsSorted()
21
23
  ? column.getIsSorted() === 'desc'
22
- ? localization.sortedByColumnDesc.replace(
23
- '{column}',
24
- column.columnDef.header,
25
- )
26
- : localization.sortedByColumnAsc.replace(
27
- '{column}',
28
- column.columnDef.header,
29
- )
24
+ ? localization.sortedByColumnDesc.replace('{column}', columnDef.header)
25
+ : localization.sortedByColumnAsc.replace('{column}', columnDef.header)
30
26
  : localization.unsorted;
31
27
 
32
28
  return (
@@ -144,7 +144,7 @@ export const MRT_FilterTextField: FC<Props> = ({
144
144
  : inputIndex === 1
145
145
  ? localization.max
146
146
  : '';
147
- console.log({ textFieldProps });
147
+
148
148
  return (
149
149
  <>
150
150
  <TextField
@@ -37,6 +37,7 @@ export interface MRT_Localization {
37
37
  pinToLeft: string;
38
38
  pinToRight: string;
39
39
  resetColumnSize: string;
40
+ resetOrder: string;
40
41
  rowActions: string;
41
42
  rowNumber: string;
42
43
  rowNumbers: string;
@@ -104,6 +105,7 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
104
105
  pinToLeft: 'Pin to left',
105
106
  pinToRight: 'Pin to right',
106
107
  resetColumnSize: 'Reset column size',
108
+ resetOrder: 'Reset order',
107
109
  rowActions: 'Row Actions',
108
110
  rowNumber: '#',
109
111
  rowNumbers: 'Row Numbers',
@@ -1,7 +1,7 @@
1
1
  import React, { FC, useMemo } from 'react';
2
2
  import { Button, Menu, Divider, Box } from '@mui/material';
3
3
  import { MRT_ShowHideColumnsMenuItems } from './MRT_ShowHideColumnsMenuItems';
4
- import { MRT_Column, MRT_TableInstance } from '..';
4
+ import type { MRT_Column, MRT_TableInstance } from '..';
5
5
 
6
6
  interface Props {
7
7
  anchorEl: HTMLElement | null;
@@ -18,16 +18,16 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
18
18
  }) => {
19
19
  const {
20
20
  getAllColumns,
21
+ getAllLeafColumns,
21
22
  getIsAllColumnsVisible,
22
- getIsSomeColumnsVisible,
23
23
  getIsSomeColumnsPinned,
24
+ getIsSomeColumnsVisible,
24
25
  getState,
25
26
  toggleAllColumnsVisible,
26
- getAllLeafColumns,
27
- options: { localization, enablePinning },
27
+ options: { localization, enablePinning, enableColumnOrdering },
28
28
  } = tableInstance;
29
29
 
30
- const { isDensePadding } = getState();
30
+ const { isDensePadding, columnOrder, columnPinning } = getState();
31
31
 
32
32
  const hideAllColumns = () => {
33
33
  getAllLeafColumns()
@@ -35,25 +35,19 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
35
35
  .forEach((col) => col.toggleVisibility(false));
36
36
  };
37
37
 
38
- const allDisplayColumns = useMemo(
39
- () => getAllColumns().filter((col) => col.columnDefType === 'display'),
40
- [getAllColumns()],
41
- );
42
-
43
- const allDataColumns: (MRT_Column | null)[] = useMemo(() => {
44
- const dataColumns = getAllColumns().filter(
45
- (col) => col.columnDefType !== 'display',
46
- );
47
- return getIsSomeColumnsPinned()
48
- ? [
49
- ...dataColumns.filter((c) => c.getIsPinned() === 'left'),
50
- null,
51
- ...dataColumns.filter((c) => c.getIsPinned() === false),
52
- null,
53
- ...dataColumns.filter((c) => c.getIsPinned() === 'right'),
54
- ]
55
- : dataColumns;
56
- }, [getAllColumns(), getState().columnPinning, getIsSomeColumnsPinned()]);
38
+ const allColumns = useMemo(() => {
39
+ const columns = getAllColumns();
40
+ if (
41
+ columnOrder.length > 0 &&
42
+ !columns.some((col) => col.columnDefType === 'group')
43
+ ) {
44
+ return (
45
+ columnOrder.map((colId) => columns.find((col) => col.id === colId)) ??
46
+ columns
47
+ );
48
+ }
49
+ return columns;
50
+ }, [getAllColumns(), columnOrder, columnPinning]) as MRT_Column[];
57
51
 
58
52
  return (
59
53
  <Menu
@@ -80,6 +74,11 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
80
74
  {localization.hideAll}
81
75
  </Button>
82
76
  )}
77
+ {!isSubMenu && enableColumnOrdering && (
78
+ <Button onClick={() => tableInstance.resetColumnOrder()}>
79
+ {localization.resetOrder}
80
+ </Button>
81
+ )}
83
82
  {!isSubMenu && enablePinning && (
84
83
  <Button
85
84
  disabled={!getIsSomeColumnsPinned()}
@@ -96,7 +95,7 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
96
95
  </Button>
97
96
  </Box>
98
97
  <Divider />
99
- {allDisplayColumns.map((column, index) => (
98
+ {allColumns.map((column, index) => (
100
99
  <MRT_ShowHideColumnsMenuItems
101
100
  column={column}
102
101
  isSubMenu={isSubMenu}
@@ -104,19 +103,6 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
104
103
  tableInstance={tableInstance}
105
104
  />
106
105
  ))}
107
- <Divider />
108
- {allDataColumns.map((column, index) =>
109
- column ? (
110
- <MRT_ShowHideColumnsMenuItems
111
- column={column}
112
- isSubMenu={isSubMenu}
113
- key={`${index}-${column.id}`}
114
- tableInstance={tableInstance}
115
- />
116
- ) : (
117
- <Divider key={`${index}-divider`} />
118
- ),
119
- )}
120
106
  </Menu>
121
107
  );
122
108
  };
@@ -1,7 +1,7 @@
1
1
  import React, { FC } from 'react';
2
2
  import { FormControlLabel, MenuItem, Switch } from '@mui/material';
3
- import type { MRT_Column, MRT_TableInstance } from '..';
4
3
  import { MRT_ColumnPinningButtons } from '../buttons/MRT_ColumnPinningButtons';
4
+ import type { MRT_Column, MRT_TableInstance } from '..';
5
5
 
6
6
  interface Props {
7
7
  column: MRT_Column;
@@ -21,13 +21,15 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
21
21
 
22
22
  const { columnVisibility } = getState();
23
23
 
24
+ const { columnDef, columnDefType } = column;
25
+
24
26
  const switchChecked =
25
- (column.columnDefType !== 'group' && column.getIsVisible()) ||
26
- (column.columnDefType === 'group' &&
27
+ (columnDefType !== 'group' && column.getIsVisible()) ||
28
+ (columnDefType === 'group' &&
27
29
  column.getLeafColumns().some((col) => col.getIsVisible()));
28
30
 
29
31
  const handleToggleColumnHidden = (column: MRT_Column) => {
30
- if (column.columnDefType === 'group') {
32
+ if (columnDefType === 'group') {
31
33
  column?.columns?.forEach?.((childColumn: MRT_Column) => {
32
34
  childColumn.toggleVisibility(!switchChecked);
33
35
  });
@@ -59,11 +61,18 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
59
61
  />
60
62
  )}
61
63
  <FormControlLabel
62
- componentsProps={{ typography: { sx: { marginBottom: 0 } } }}
64
+ componentsProps={{
65
+ typography: {
66
+ sx: {
67
+ marginBottom: 0,
68
+ opacity: columnDefType !== 'display' ? 1 : 0.5,
69
+ },
70
+ },
71
+ }}
63
72
  checked={switchChecked}
64
73
  control={<Switch />}
65
74
  disabled={(isSubMenu && switchChecked) || !column.getCanHide()}
66
- label={column.columnDef.header}
75
+ label={columnDef.header}
67
76
  onChange={() => handleToggleColumnHidden(column)}
68
77
  />
69
78
  </MenuItem>