material-react-table 0.5.7 → 0.5.8

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.
@@ -2,6 +2,7 @@ import React, { FC } from 'react';
2
2
  import { FormControlLabel, MenuItem, Switch } from '@mui/material';
3
3
  import { ColumnInstance } from 'react-table';
4
4
  import { MRT_ColumnInstance } from '..';
5
+ import { commonMenuItemStyles } from './MRT_ColumnActionMenu';
5
6
 
6
7
  interface Props {
7
8
  column: MRT_ColumnInstance;
@@ -28,8 +29,11 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({ column }) => {
28
29
 
29
30
  return (
30
31
  <>
31
- <MenuItem sx={{ pl: `${(column.depth + 0.5) * 2}rem` }}>
32
+ <MenuItem
33
+ sx={{ ...commonMenuItemStyles, pl: `${(column.depth + 0.5) * 2}rem` }}
34
+ >
32
35
  <FormControlLabel
36
+ componentsProps={{ typography: { sx: { marginBottom: 0 } } }}
33
37
  checked={switchChecked}
34
38
  control={<Switch />}
35
39
  label={column.Header as string}
package/src/useMRT.tsx CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  useSortBy,
22
22
  useTable,
23
23
  } from 'react-table';
24
- import { MRT_FilterType, MRT_Row, MRT_TableInstance } from '.';
24
+ import { MRT_FilterType, MRT_FILTER_TYPE, MRT_Row, MRT_TableInstance } from '.';
25
25
  import { defaultFilterFNs } from './filtersFNs';
26
26
  import { MRT_Icons } from './icons';
27
27
  import { MRT_Localization } from './localization';
@@ -81,7 +81,9 @@ export const MaterialReactTableProvider = <D extends {} = {}>(
81
81
  props.initialState?.showSearch ?? false,
82
82
  );
83
83
 
84
- const filterTypes = useMemo<Partial<{ [key in MRT_FilterType]: any }>>(
84
+ const filterTypes = useMemo<{
85
+ [key in MRT_FILTER_TYPE]: any;
86
+ }>(
85
87
  () => ({
86
88
  ...defaultFilterFNs,
87
89
  ...props.filterTypes,
@@ -94,12 +96,12 @@ export const MaterialReactTableProvider = <D extends {} = {}>(
94
96
  }>(() =>
95
97
  Object.assign(
96
98
  {},
97
- ...props.columns
98
- .map((c) => c.accessor?.toString() as string)
99
- .map((accessor) => ({
100
- [accessor]:
101
- props?.initialState?.filters?.[accessor as any] ?? 'fuzzy',
102
- })),
99
+ ...props.columns.map((c) => ({
100
+ [c.accessor as string]:
101
+ c.filter ??
102
+ props?.initialState?.filters?.[c.accessor as any] ??
103
+ (!!c.filterSelectOptions ? 'equals' : 'fuzzy'),
104
+ })),
103
105
  ),
104
106
  );
105
107
 
@@ -107,7 +109,9 @@ export const MaterialReactTableProvider = <D extends {} = {}>(
107
109
  () =>
108
110
  props.columns.map((column) => {
109
111
  column.filter =
110
- filterTypes[currentFilterTypes[column.accessor as string]];
112
+ filterTypes[
113
+ currentFilterTypes[column.accessor as string] as MRT_FILTER_TYPE
114
+ ];
111
115
  return column;
112
116
  }),
113
117
  [props.columns, filterTypes, currentFilterTypes],
@@ -119,6 +123,7 @@ export const MaterialReactTableProvider = <D extends {} = {}>(
119
123
  columns,
120
124
  // @ts-ignore
121
125
  filterTypes,
126
+ globalFilterValue: 'fuzzy',
122
127
  useControlledState: (state) =>
123
128
  useMemo(
124
129
  () => ({