material-react-table 1.11.2 → 1.11.4

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.
@@ -45,6 +45,7 @@ export const MRT_ColumnActionMenu = ({
45
45
  enableHiding,
46
46
  enablePinning,
47
47
  enableSorting,
48
+ enableSortingRemoval,
48
49
  icons: {
49
50
  ArrowRightIcon,
50
51
  ClearAllIcon,
@@ -162,20 +163,23 @@ export const MRT_ColumnActionMenu = ({
162
163
  table,
163
164
  }) ??
164
165
  (enableSorting &&
165
- column.getCanSort() && [
166
- <MenuItem
167
- disabled={!column.getIsSorted()}
168
- key={0}
169
- onClick={handleClearSort}
170
- sx={commonMenuItemStyles}
171
- >
172
- <Box sx={commonListItemStyles}>
173
- <ListItemIcon>
174
- <ClearAllIcon />
175
- </ListItemIcon>
176
- {localization.clearSort}
177
- </Box>
178
- </MenuItem>,
166
+ column.getCanSort() &&
167
+ [
168
+ enableSortingRemoval !== false && (
169
+ <MenuItem
170
+ disabled={!column.getIsSorted()}
171
+ key={0}
172
+ onClick={handleClearSort}
173
+ sx={commonMenuItemStyles}
174
+ >
175
+ <Box sx={commonListItemStyles}>
176
+ <ListItemIcon>
177
+ <ClearAllIcon />
178
+ </ListItemIcon>
179
+ {localization.clearSort}
180
+ </Box>
181
+ </MenuItem>
182
+ ),
179
183
  <MenuItem
180
184
  disabled={column.getIsSorted() === 'asc'}
181
185
  key={1}
@@ -211,7 +215,7 @@ export const MRT_ColumnActionMenu = ({
211
215
  )}
212
216
  </Box>
213
217
  </MenuItem>,
214
- ])}
218
+ ].filter(Boolean))}
215
219
  {enableColumnFilters &&
216
220
  column.getCanFilter() &&
217
221
  [
@@ -39,6 +39,7 @@ import type {
39
39
  MRT_DensityState,
40
40
  MRT_ColumnOrderState,
41
41
  MRT_GroupingState,
42
+ MRT_FilterFnsState,
42
43
  } from '..';
43
44
 
44
45
  export const MRT_TableRoot: any = <TData extends Record<string, any> = {}>(
@@ -61,22 +62,21 @@ export const MRT_TableRoot: any = <TData extends Record<string, any> = {}>(
61
62
  return initState;
62
63
  }, []);
63
64
 
64
- const [columnFilterFns, setColumnFilterFns] = useState<{
65
- [key: string]: MRT_FilterOption;
66
- }>(() =>
67
- Object.assign(
68
- {},
69
- ...getAllLeafColumnDefs(props.columns as MRT_ColumnDef<TData>[]).map(
70
- (col) => ({
71
- [getColumnId(col)]:
72
- col.filterFn instanceof Function
73
- ? col.filterFn.name ?? 'custom'
74
- : col.filterFn ??
75
- initialState?.columnFilterFns?.[getColumnId(col)] ??
76
- getDefaultColumnFilterFn(col),
77
- }),
65
+ const [columnFilterFns, setColumnFilterFns] = useState<MRT_FilterFnsState>(
66
+ () =>
67
+ Object.assign(
68
+ {},
69
+ ...getAllLeafColumnDefs(props.columns as MRT_ColumnDef<TData>[]).map(
70
+ (col) => ({
71
+ [getColumnId(col)]:
72
+ col.filterFn instanceof Function
73
+ ? col.filterFn.name ?? 'custom'
74
+ : col.filterFn ??
75
+ initialState?.columnFilterFns?.[getColumnId(col)] ??
76
+ getDefaultColumnFilterFn(col),
77
+ }),
78
+ ),
78
79
  ),
79
- ),
80
80
  );
81
81
  const [columnOrder, setColumnOrder] = useState<MRT_ColumnOrderState>(
82
82
  initialState.columnOrder ?? [],