material-react-table 0.8.7 → 0.8.10

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.
@@ -47,6 +47,10 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
47
47
  const { isDensePadding, currentFilterFns, currentGlobalFilterFn } =
48
48
  getState();
49
49
 
50
+ const { column } = header ?? {};
51
+
52
+ const { columnDef } = column ?? {};
53
+
50
54
  const filterOptions: {
51
55
  option: MRT_FILTER_OPTION;
52
56
  label: string;
@@ -122,9 +126,9 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
122
126
  fn: notEmpty,
123
127
  },
124
128
  ].filter((filterType) =>
125
- header
126
- ? !header.column.enabledColumnFilterOptions ||
127
- header.column.enabledColumnFilterOptions.includes(filterType.option)
129
+ columnDef
130
+ ? !columnDef.enabledColumnFilterOptions ||
131
+ columnDef.enabledColumnFilterOptions.includes(filterType.option)
128
132
  : (!enabledGlobalFilterOptions ||
129
133
  enabledGlobalFilterOptions.includes(filterType.option)) &&
130
134
  [MRT_FILTER_OPTION.FUZZY, MRT_FILTER_OPTION.CONTAINS].includes(
@@ -135,7 +139,7 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
135
139
  );
136
140
 
137
141
  const handleSelectFilterType = (value: MRT_FILTER_OPTION) => {
138
- if (header) {
142
+ if (header && column) {
139
143
  setCurrentFilterFns((prev: { [key: string]: MRT_FilterFn }) => ({
140
144
  ...prev,
141
145
  [header.id]: value,
@@ -143,11 +147,11 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
143
147
  if (
144
148
  [MRT_FILTER_OPTION.EMPTY, MRT_FILTER_OPTION.NOT_EMPTY].includes(value)
145
149
  ) {
146
- header.column.setFilterValue(' ');
150
+ column.setFilterValue(' ');
147
151
  } else if (value === MRT_FILTER_OPTION.BETWEEN) {
148
- header.column.setFilterValue(['', '']);
152
+ column.setFilterValue(['', '']);
149
153
  } else {
150
- header.column.setFilterValue('');
154
+ column.setFilterValue('');
151
155
  }
152
156
  } else {
153
157
  setCurrentGlobalFilterFn(value);
@@ -31,7 +31,7 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
31
31
 
32
32
  const hideAllColumns = () => {
33
33
  getAllLeafColumns()
34
- .filter((col) => col.enableHiding !== false)
34
+ .filter((col) => col.columnDef.enableHiding !== false)
35
35
  .forEach((col) => col.toggleVisibility(false));
36
36
  };
37
37