material-react-table 0.6.3 → 0.6.6

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.
@@ -4,16 +4,16 @@ import { useMRT } from '../useMRT';
4
4
  import type { MRT_FilterType, MRT_HeaderGroup } from '..';
5
5
  import { MRT_FILTER_TYPE } from '../enums';
6
6
  import {
7
- containsFilterFN,
8
- emptyFilterFN,
9
- endsWithFilterFN,
10
- equalsFilterFN,
11
- fuzzyFilterFN,
12
- greaterThanFilterFN,
13
- lessThanFilterFN,
14
- notEmptyFilterFN,
15
- notEqualsFilterFN,
16
- startsWithFilterFN,
7
+ contains,
8
+ empty,
9
+ endsWith,
10
+ equals,
11
+ fuzzy,
12
+ greaterThan,
13
+ lessThan,
14
+ notEmpty,
15
+ notEquals,
16
+ startsWith,
17
17
  } from '../filtersFNs';
18
18
 
19
19
  const commonMenuItemStyles = {
@@ -43,68 +43,72 @@ export const MRT_FilterTypeMenu: FC<Props> = ({
43
43
  divider: boolean;
44
44
  fn: Function;
45
45
  }[] = useMemo(
46
- () => [
47
- {
48
- type: MRT_FILTER_TYPE.FUZZY,
49
- label: localization.filterFuzzy,
50
- divider: false,
51
- fn: fuzzyFilterFN,
52
- },
53
- {
54
- type: MRT_FILTER_TYPE.CONTAINS,
55
- label: localization.filterContains,
56
- divider: true,
57
- fn: containsFilterFN,
58
- },
59
- {
60
- type: MRT_FILTER_TYPE.STARTS_WITH,
61
- label: localization.filterStartsWith,
62
- divider: false,
63
- fn: startsWithFilterFN,
64
- },
65
- {
66
- type: MRT_FILTER_TYPE.ENDS_WITH,
67
- label: localization.filterEndsWith,
68
- divider: true,
69
- fn: endsWithFilterFN,
70
- },
71
- {
72
- type: MRT_FILTER_TYPE.EQUALS,
73
- label: localization.filterEquals,
74
- divider: false,
75
- fn: equalsFilterFN,
76
- },
77
- {
78
- type: MRT_FILTER_TYPE.NOT_EQUALS,
79
- label: localization.filterNotEquals,
80
- divider: true,
81
- fn: notEqualsFilterFN,
82
- },
83
- {
84
- type: MRT_FILTER_TYPE.GREATER_THAN,
85
- label: localization.filterGreaterThan,
86
- divider: false,
87
- fn: greaterThanFilterFN,
88
- },
89
- {
90
- type: MRT_FILTER_TYPE.LESS_THAN,
91
- label: localization.filterLessThan,
92
- divider: true,
93
- fn: lessThanFilterFN,
94
- },
95
- {
96
- type: MRT_FILTER_TYPE.EMPTY,
97
- label: localization.filterEmpty,
98
- divider: false,
99
- fn: emptyFilterFN,
100
- },
101
- {
102
- type: MRT_FILTER_TYPE.NOT_EMPTY,
103
- label: localization.filterNotEmpty,
104
- divider: false,
105
- fn: notEmptyFilterFN,
106
- },
107
- ],
46
+ () =>
47
+ [
48
+ {
49
+ type: MRT_FILTER_TYPE.FUZZY,
50
+ label: localization.filterFuzzy,
51
+ divider: false,
52
+ fn: fuzzy,
53
+ },
54
+ {
55
+ type: MRT_FILTER_TYPE.CONTAINS,
56
+ label: localization.filterContains,
57
+ divider: true,
58
+ fn: contains,
59
+ },
60
+ {
61
+ type: MRT_FILTER_TYPE.STARTS_WITH,
62
+ label: localization.filterStartsWith,
63
+ divider: false,
64
+ fn: startsWith,
65
+ },
66
+ {
67
+ type: MRT_FILTER_TYPE.ENDS_WITH,
68
+ label: localization.filterEndsWith,
69
+ divider: true,
70
+ fn: endsWith,
71
+ },
72
+ {
73
+ type: MRT_FILTER_TYPE.EQUALS,
74
+ label: localization.filterEquals,
75
+ divider: false,
76
+ fn: equals,
77
+ },
78
+ {
79
+ type: MRT_FILTER_TYPE.NOT_EQUALS,
80
+ label: localization.filterNotEquals,
81
+ divider: true,
82
+ fn: notEquals,
83
+ },
84
+ {
85
+ type: MRT_FILTER_TYPE.GREATER_THAN,
86
+ label: localization.filterGreaterThan,
87
+ divider: false,
88
+ fn: greaterThan,
89
+ },
90
+ {
91
+ type: MRT_FILTER_TYPE.LESS_THAN,
92
+ label: localization.filterLessThan,
93
+ divider: true,
94
+ fn: lessThan,
95
+ },
96
+ {
97
+ type: MRT_FILTER_TYPE.EMPTY,
98
+ label: localization.filterEmpty,
99
+ divider: false,
100
+ fn: empty,
101
+ },
102
+ {
103
+ type: MRT_FILTER_TYPE.NOT_EMPTY,
104
+ label: localization.filterNotEmpty,
105
+ divider: false,
106
+ fn: notEmpty,
107
+ },
108
+ ].filter(
109
+ (filterType) =>
110
+ !column.filterTypes || column.filterTypes.includes(filterType.type),
111
+ ),
108
112
  [],
109
113
  );
110
114
 
@@ -1,8 +1,11 @@
1
1
  import React, { FC } from 'react';
2
- import { Menu, MenuItem } from '@mui/material';
2
+ import { Box, ListItemIcon, Menu, MenuItem } from '@mui/material';
3
3
  import { useMRT } from '../useMRT';
4
4
  import type { MRT_Row } from '..';
5
- import { commonMenuItemStyles } from './MRT_ColumnActionMenu';
5
+ import {
6
+ commonListItemStyles,
7
+ commonMenuItemStyles,
8
+ } from './MRT_ColumnActionMenu';
6
9
 
7
10
  interface Props {
8
11
  anchorEl: HTMLElement | null;
@@ -36,8 +39,12 @@ export const MRT_RowActionMenu: FC<Props> = ({
36
39
  >
37
40
  {enableRowEditing && (
38
41
  <MenuItem onClick={handleEdit} sx={commonMenuItemStyles}>
39
- <EditIcon />
40
- {localization.edit}
42
+ <Box sx={commonListItemStyles}>
43
+ <ListItemIcon>
44
+ <EditIcon />
45
+ </ListItemIcon>
46
+ {localization.edit}
47
+ </Box>
41
48
  </MenuItem>
42
49
  )}
43
50
  {renderRowActionMenuItems?.(row, tableInstance, () =>
@@ -3,6 +3,7 @@ import { FormControlLabel, MenuItem, Switch } from '@mui/material';
3
3
  import { ColumnInstance } from 'react-table';
4
4
  import type { MRT_ColumnInstance } from '..';
5
5
  import { commonMenuItemStyles } from './MRT_ColumnActionMenu';
6
+ import { useMRT } from '../useMRT';
6
7
 
7
8
  interface Props {
8
9
  column: MRT_ColumnInstance;
@@ -13,6 +14,7 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
13
14
  column,
14
15
  isSubMenu,
15
16
  }) => {
17
+ const { onColumnHide, tableInstance } = useMRT();
16
18
  const isParentHeader = !!column?.columns?.length;
17
19
 
18
20
  const allChildColumnsVisible =
@@ -29,6 +31,7 @@ export const MRT_ShowHideColumnsMenuItems: FC<Props> = ({
29
31
  } else {
30
32
  column.toggleHidden();
31
33
  }
34
+ onColumnHide?.(column, tableInstance.state.hiddenColumns);
32
35
  };
33
36
 
34
37
  return (
@@ -40,7 +40,7 @@ export const MRT_TableContainer: FC<Props> = () => {
40
40
  height: fullScreen ? '100%' : undefined,
41
41
  left: fullScreen ? '0' : undefined,
42
42
  m: fullScreen ? '0' : undefined,
43
- overflowY: 'hidden',
43
+ overflowY: !fullScreen ? 'hidden' : undefined,
44
44
  position: fullScreen ? 'fixed' : undefined,
45
45
  right: fullScreen ? '0' : undefined,
46
46
  top: fullScreen ? '0' : undefined,
package/src/useMRT.tsx CHANGED
@@ -128,7 +128,7 @@ export const MaterialReactTableProvider = <D extends {} = {}>(
128
128
  () =>
129
129
  !props.isLoading || !!props.data.length
130
130
  ? props.data
131
- : [...Array(10)].map((_) =>
131
+ : [...Array(10).fill(null)].map((_) =>
132
132
  Object.assign(
133
133
  {},
134
134
  ...findLowestLevelCols(props.columns).map((c) => ({