material-react-table 2.2.0 → 2.3.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.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.2.0",
2
+ "version": "2.3.0",
3
3
  "license": "MIT",
4
4
  "name": "material-react-table",
5
5
  "description": "A fully featured Material UI V5 implementation of TanStack React Table V8, written from the ground up in TypeScript.",
@@ -87,6 +87,10 @@ export const MRT_TableBody = <TData extends MRT_RowData>({
87
87
  virtualPaddingRight,
88
88
  };
89
89
 
90
+ const CreatingRow = creatingRow && createDisplayMode === 'row' && (
91
+ <MRT_TableBodyRow {...commonRowProps} row={creatingRow} rowIndex={-1} />
92
+ );
93
+
90
94
  return (
91
95
  <>
92
96
  {!rowPinningDisplayMode?.includes('sticky') &&
@@ -115,24 +119,32 @@ export const MRT_TableBody = <TData extends MRT_RowData>({
115
119
  })}
116
120
  </TableBody>
117
121
  )}
122
+ {rowVirtualizer && CreatingRow && (
123
+ <TableBody
124
+ {...tableBodyProps}
125
+ sx={(theme) => ({
126
+ display: layoutMode?.startsWith('grid') ? 'grid' : undefined,
127
+ ...(parseFromValuesOrFunc(tableBodyProps?.sx, theme) as any),
128
+ })}
129
+ >
130
+ {CreatingRow}
131
+ </TableBody>
132
+ )}
118
133
  <TableBody
119
134
  {...tableBodyProps}
120
135
  sx={(theme) => ({
121
136
  display: layoutMode?.startsWith('grid') ? 'grid' : undefined,
122
- height:
123
- rowVirtualizer
124
- ? `${rowVirtualizer.getTotalSize()}px`
125
- : undefined,
137
+ height: rowVirtualizer
138
+ ? `${rowVirtualizer.getTotalSize()}px`
139
+ : undefined,
126
140
  minHeight: !rows.length ? '100px' : undefined,
127
141
  position: 'relative',
128
142
  ...(parseFromValuesOrFunc(tableBodyProps?.sx, theme) as any),
129
143
  })}
130
144
  >
131
- {creatingRow && createDisplayMode === 'row' && (
132
- <MRT_TableBodyRow row={creatingRow} rowIndex={-1} table={table} />
133
- )}
145
+ {!rowVirtualizer && CreatingRow}
134
146
  {tableBodyProps?.children ??
135
- (!rows.length ? (
147
+ (!rows.length && !CreatingRow ? (
136
148
  <tr
137
149
  style={{
138
150
  display: layoutMode?.startsWith('grid') ? 'grid' : undefined,
@@ -40,14 +40,13 @@ export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
40
40
  enableHiding,
41
41
  localization,
42
42
  },
43
- toggleAllColumnsVisible,
44
43
  } = table;
45
44
  const { columnOrder, columnPinning, density } = getState();
46
45
 
47
- const hideAllColumns = () => {
46
+ const handleToggleAllColumns = (value?: boolean) => {
48
47
  getAllLeafColumns()
49
48
  .filter((col) => col.columnDef.enableHiding !== false)
50
- .forEach((col) => col.toggleVisibility(false));
49
+ .forEach((col) => col.toggleVisibility(value));
51
50
  };
52
51
 
53
52
  const allColumns = useMemo(() => {
@@ -99,7 +98,7 @@ export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
99
98
  {enableHiding && (
100
99
  <Button
101
100
  disabled={!getIsSomeColumnsVisible()}
102
- onClick={hideAllColumns}
101
+ onClick={() => handleToggleAllColumns(false)}
103
102
  >
104
103
  {localization.hideAll}
105
104
  </Button>
@@ -126,7 +125,7 @@ export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
126
125
  {enableHiding && (
127
126
  <Button
128
127
  disabled={getIsAllColumnsVisible()}
129
- onClick={() => toggleAllColumnsVisible(true)}
128
+ onClick={() => handleToggleAllColumns(true)}
130
129
  >
131
130
  {localization.showAll}
132
131
  </Button>
@@ -89,7 +89,8 @@ export const MRT_ShowHideColumnsMenuItems = <TData extends MRT_RowData>({
89
89
  }
90
90
  };
91
91
 
92
- if (!columnDef.header) return null;
92
+ if (!columnDef.header || columnDef.visibleInShowHideMenu === false)
93
+ return null;
93
94
 
94
95
  return (
95
96
  <>
package/src/types.ts CHANGED
@@ -579,6 +579,7 @@ export type MRT_ColumnDef<TData extends MRT_RowData, TValue = unknown> = Omit<
579
579
  table: MRT_TableInstance<TData>;
580
580
  }) => ReactNode[];
581
581
  sortingFn?: MRT_SortingFn<TData>;
582
+ visibleInShowHideMenu?: boolean;
582
583
  };
583
584
 
584
585
  export type MRT_DisplayColumnDef<