material-react-table 0.25.0 → 0.26.2
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/README.md +13 -11
- package/dist/{utils.d.ts → column.utils.d.ts} +1 -1
- package/dist/filtersFns.d.ts +22 -54
- package/dist/localization.d.ts +3 -0
- package/dist/material-react-table.cjs.development.js +188 -103
- package/dist/material-react-table.cjs.development.js.map +1 -1
- package/dist/material-react-table.cjs.production.min.js +1 -1
- package/dist/material-react-table.cjs.production.min.js.map +1 -1
- package/dist/material-react-table.esm.js +188 -103
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/table/MRT_TableRoot.d.ts +1 -1
- package/package.json +1 -1
- package/src/body/MRT_TableBodyCell.tsx +3 -1
- package/src/body/MRT_TableBodyRow.tsx +3 -1
- package/src/body/MRT_TableDetailPanel.tsx +5 -3
- package/src/buttons/MRT_CopyButton.tsx +5 -3
- package/src/buttons/MRT_ExpandButton.tsx +5 -3
- package/src/{utils.ts → column.utils.ts} +0 -0
- package/src/filtersFns.ts +47 -13
- package/src/footer/MRT_TableFooterCell.tsx +3 -1
- package/src/head/MRT_TableHeadCell.tsx +5 -1
- package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +5 -3
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +1 -1
- package/src/inputs/MRT_FilterTextField.tsx +9 -4
- package/src/inputs/MRT_SelectCheckbox.tsx +5 -3
- package/src/localization.ts +6 -0
- package/src/menus/MRT_FilterOptionMenu.tsx +105 -72
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +1 -1
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +1 -1
- package/src/table/MRT_Table.tsx +5 -3
- package/src/table/MRT_TableContainer.tsx +5 -3
- package/src/table/MRT_TableRoot.tsx +12 -12
- package/src/toolbar/MRT_TablePagination.tsx +5 -3
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +5 -3
- package/src/toolbar/MRT_ToolbarBottom.tsx +3 -1
- package/src/toolbar/MRT_ToolbarTop.tsx +3 -1
@@ -1,3 +1,3 @@
|
|
1
1
|
/// <reference types="react" />
|
2
|
-
import { MaterialReactTableProps } from '
|
2
|
+
import type { MaterialReactTableProps } from '..';
|
3
3
|
export declare const MRT_TableRoot: <TData extends Record<string, any> = {}>(props: MaterialReactTableProps<TData>) => JSX.Element;
|
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"version": "0.
|
2
|
+
"version": "0.26.2",
|
3
3
|
"license": "MIT",
|
4
4
|
"name": "material-react-table",
|
5
5
|
"description": "A fully featured Material UI implementation of TanStack React Table, inspired by material-table and the MUI X DataGrid, written from the ground up in TypeScript.",
|
@@ -224,7 +224,9 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
224
224
|
: `${darken(theme.palette.background.default, 0.07)} !important`
|
225
225
|
: undefined,
|
226
226
|
},
|
227
|
-
...(tableCellProps?.sx
|
227
|
+
...(tableCellProps?.sx instanceof Function
|
228
|
+
? tableCellProps.sx(theme)
|
229
|
+
: (tableCellProps?.sx as any)),
|
228
230
|
...draggingBorders,
|
229
231
|
maxWidth: `min(${column.getSize()}px, fit-content)`,
|
230
232
|
minWidth: `max(${column.getSize()}px, ${columnDef.minSize ?? 30}px)`,
|
@@ -70,7 +70,9 @@ export const MRT_TableBodyRow: FC<Props> = ({ row, rowIndex, table }) => {
|
|
70
70
|
: `${darken(theme.palette.background.default, 0.05)}`
|
71
71
|
: undefined,
|
72
72
|
},
|
73
|
-
...(tableRowProps?.sx
|
73
|
+
...(tableRowProps?.sx instanceof Function
|
74
|
+
? tableRowProps.sx(theme)
|
75
|
+
: (tableRowProps?.sx as any)),
|
74
76
|
...draggingBorders,
|
75
77
|
})}
|
76
78
|
>
|
@@ -32,14 +32,16 @@ export const MRT_TableDetailPanel: FC<Props> = ({ row, table }) => {
|
|
32
32
|
<TableCell
|
33
33
|
colSpan={getVisibleLeafColumns().length}
|
34
34
|
{...tableCellProps}
|
35
|
-
sx={{
|
35
|
+
sx={(theme) => ({
|
36
36
|
borderBottom: !row.getIsExpanded() ? 'none' : undefined,
|
37
37
|
pb: row.getIsExpanded() ? '1rem' : 0,
|
38
38
|
pt: row.getIsExpanded() ? '1rem' : 0,
|
39
39
|
transition: 'all 0.2s ease-in-out',
|
40
40
|
width: `${table.getTotalSize()}px`,
|
41
|
-
...tableCellProps?.sx
|
42
|
-
|
41
|
+
...(tableCellProps?.sx instanceof Function
|
42
|
+
? tableCellProps.sx(theme)
|
43
|
+
: (tableCellProps?.sx as any)),
|
44
|
+
})}
|
43
45
|
>
|
44
46
|
{renderDetailPanel && (
|
45
47
|
<Collapse in={row.getIsExpanded()}>
|
@@ -55,7 +55,7 @@ export const MRT_CopyButton: FC<Props> = ({ cell, children, table }) => {
|
|
55
55
|
type="button"
|
56
56
|
variant="text"
|
57
57
|
{...buttonProps}
|
58
|
-
sx={{
|
58
|
+
sx={(theme) => ({
|
59
59
|
backgroundColor: 'transparent',
|
60
60
|
border: 'none',
|
61
61
|
color: 'inherit',
|
@@ -67,8 +67,10 @@ export const MRT_CopyButton: FC<Props> = ({ cell, children, table }) => {
|
|
67
67
|
minWidth: 'unset',
|
68
68
|
textAlign: 'inherit',
|
69
69
|
textTransform: 'inherit',
|
70
|
-
...buttonProps?.sx
|
71
|
-
|
70
|
+
...(buttonProps?.sx instanceof Function
|
71
|
+
? buttonProps.sx(theme)
|
72
|
+
: (buttonProps?.sx as any)),
|
73
|
+
})}
|
72
74
|
>
|
73
75
|
{children}
|
74
76
|
</Button>
|
@@ -41,11 +41,13 @@ export const MRT_ExpandButton: FC<Props> = ({ row, table }) => {
|
|
41
41
|
disabled={!row.getCanExpand() && !renderDetailPanel}
|
42
42
|
onClick={handleToggleExpand}
|
43
43
|
{...iconButtonProps}
|
44
|
-
sx={{
|
44
|
+
sx={(theme) => ({
|
45
45
|
height: density === 'compact' ? '1.75rem' : '2.25rem',
|
46
46
|
width: density === 'compact' ? '1.75rem' : '2.25rem',
|
47
|
-
...iconButtonProps?.sx
|
48
|
-
|
47
|
+
...(iconButtonProps?.sx instanceof Function
|
48
|
+
? iconButtonProps.sx(theme)
|
49
|
+
: (iconButtonProps?.sx as any)),
|
50
|
+
})}
|
49
51
|
>
|
50
52
|
<ExpandMoreIcon
|
51
53
|
style={{
|
File without changes
|
package/src/filtersFns.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { rankItem, rankings, RankingInfo } from '@tanstack/match-sorter-utils';
|
2
2
|
import { filterFns, Row } from '@tanstack/react-table';
|
3
3
|
|
4
|
-
|
4
|
+
const fuzzy = <TData extends Record<string, any> = {}>(
|
5
5
|
row: Row<TData>,
|
6
6
|
columnId: string,
|
7
7
|
filterValue: string | number,
|
@@ -16,7 +16,7 @@ export const fuzzy = <TData extends Record<string, any> = {}>(
|
|
16
16
|
|
17
17
|
fuzzy.autoRemove = (val: any) => !val;
|
18
18
|
|
19
|
-
|
19
|
+
const contains = <TData extends Record<string, any> = {}>(
|
20
20
|
row: Row<TData>,
|
21
21
|
id: string,
|
22
22
|
filterValue: string | number,
|
@@ -30,7 +30,7 @@ export const contains = <TData extends Record<string, any> = {}>(
|
|
30
30
|
|
31
31
|
contains.autoRemove = (val: any) => !val;
|
32
32
|
|
33
|
-
|
33
|
+
const startsWith = <TData extends Record<string, any> = {}>(
|
34
34
|
row: Row<TData>,
|
35
35
|
id: string,
|
36
36
|
filterValue: string | number,
|
@@ -44,7 +44,7 @@ export const startsWith = <TData extends Record<string, any> = {}>(
|
|
44
44
|
|
45
45
|
startsWith.autoRemove = (val: any) => !val;
|
46
46
|
|
47
|
-
|
47
|
+
const endsWith = <TData extends Record<string, any> = {}>(
|
48
48
|
row: Row<TData>,
|
49
49
|
id: string,
|
50
50
|
filterValue: string | number,
|
@@ -58,7 +58,7 @@ export const endsWith = <TData extends Record<string, any> = {}>(
|
|
58
58
|
|
59
59
|
endsWith.autoRemove = (val: any) => !val;
|
60
60
|
|
61
|
-
|
61
|
+
const equals = <TData extends Record<string, any> = {}>(
|
62
62
|
row: Row<TData>,
|
63
63
|
id: string,
|
64
64
|
filterValue: string | number,
|
@@ -68,7 +68,7 @@ export const equals = <TData extends Record<string, any> = {}>(
|
|
68
68
|
|
69
69
|
equals.autoRemove = (val: any) => !val;
|
70
70
|
|
71
|
-
|
71
|
+
const notEquals = <TData extends Record<string, any> = {}>(
|
72
72
|
row: Row<TData>,
|
73
73
|
id: string,
|
74
74
|
filterValue: string | number,
|
@@ -78,31 +78,47 @@ export const notEquals = <TData extends Record<string, any> = {}>(
|
|
78
78
|
|
79
79
|
notEquals.autoRemove = (val: any) => !val;
|
80
80
|
|
81
|
-
|
81
|
+
const greaterThan = <TData extends Record<string, any> = {}>(
|
82
82
|
row: Row<TData>,
|
83
83
|
id: string,
|
84
84
|
filterValue: string | number,
|
85
85
|
) =>
|
86
86
|
!isNaN(+filterValue) && !isNaN(+row.getValue<string | number>(id))
|
87
|
-
? +row.getValue<string | number>(id)
|
87
|
+
? +row.getValue<string | number>(id) > +filterValue
|
88
88
|
: row.getValue<string | number>(id).toString().toLowerCase().trim() >
|
89
89
|
filterValue.toString().toLowerCase().trim();
|
90
90
|
|
91
91
|
greaterThan.autoRemove = (val: any) => !val;
|
92
92
|
|
93
|
-
|
93
|
+
const greaterThanOrEqualTo = <TData extends Record<string, any> = {}>(
|
94
|
+
row: Row<TData>,
|
95
|
+
id: string,
|
96
|
+
filterValue: string | number,
|
97
|
+
) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
|
98
|
+
|
99
|
+
greaterThanOrEqualTo.autoRemove = (val: any) => !val;
|
100
|
+
|
101
|
+
const lessThan = <TData extends Record<string, any> = {}>(
|
94
102
|
row: Row<TData>,
|
95
103
|
id: string,
|
96
104
|
filterValue: string | number,
|
97
105
|
) =>
|
98
106
|
!isNaN(+filterValue) && !isNaN(+row.getValue<string | number>(id))
|
99
|
-
? +row.getValue<string | number>(id)
|
107
|
+
? +row.getValue<string | number>(id) < +filterValue
|
100
108
|
: row.getValue<string | number>(id).toString().toLowerCase().trim() <
|
101
109
|
filterValue.toString().toLowerCase().trim();
|
102
110
|
|
103
111
|
lessThan.autoRemove = (val: any) => !val;
|
104
112
|
|
105
|
-
|
113
|
+
const lessThanOrEqualTo = <TData extends Record<string, any> = {}>(
|
114
|
+
row: Row<TData>,
|
115
|
+
id: string,
|
116
|
+
filterValue: string | number,
|
117
|
+
) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
|
118
|
+
|
119
|
+
lessThanOrEqualTo.autoRemove = (val: any) => !val;
|
120
|
+
|
121
|
+
const between = <TData extends Record<string, any> = {}>(
|
106
122
|
row: Row<TData>,
|
107
123
|
id: string,
|
108
124
|
filterValues: [string | number, string | number],
|
@@ -117,7 +133,22 @@ export const between = <TData extends Record<string, any> = {}>(
|
|
117
133
|
|
118
134
|
between.autoRemove = (val: any) => !val;
|
119
135
|
|
120
|
-
|
136
|
+
const betweenInclusive = <TData extends Record<string, any> = {}>(
|
137
|
+
row: Row<TData>,
|
138
|
+
id: string,
|
139
|
+
filterValues: [string | number, string | number],
|
140
|
+
) =>
|
141
|
+
((['', undefined] as any[]).includes(filterValues[0]) ||
|
142
|
+
greaterThanOrEqualTo(row, id, filterValues[0])) &&
|
143
|
+
((!isNaN(+filterValues[0]) &&
|
144
|
+
!isNaN(+filterValues[1]) &&
|
145
|
+
+filterValues[0] > +filterValues[1]) ||
|
146
|
+
(['', undefined] as any[]).includes(filterValues[1]) ||
|
147
|
+
lessThanOrEqualTo(row, id, filterValues[1]));
|
148
|
+
|
149
|
+
betweenInclusive.autoRemove = (val: any) => !val;
|
150
|
+
|
151
|
+
const empty = <TData extends Record<string, any> = {}>(
|
121
152
|
row: Row<TData>,
|
122
153
|
id: string,
|
123
154
|
_filterValue: string | number,
|
@@ -125,7 +156,7 @@ export const empty = <TData extends Record<string, any> = {}>(
|
|
125
156
|
|
126
157
|
empty.autoRemove = (val: any) => !val;
|
127
158
|
|
128
|
-
|
159
|
+
const notEmpty = <TData extends Record<string, any> = {}>(
|
129
160
|
row: Row<TData>,
|
130
161
|
id: string,
|
131
162
|
_filterValue: string | number,
|
@@ -136,13 +167,16 @@ notEmpty.autoRemove = (val: any) => !val;
|
|
136
167
|
export const MRT_FilterFns = {
|
137
168
|
...filterFns,
|
138
169
|
between,
|
170
|
+
betweenInclusive,
|
139
171
|
contains,
|
140
172
|
empty,
|
141
173
|
endsWith,
|
142
174
|
equals,
|
143
175
|
fuzzy,
|
144
176
|
greaterThan,
|
177
|
+
greaterThanOrEqualTo,
|
145
178
|
lessThan,
|
179
|
+
lessThanOrEqualTo,
|
146
180
|
notEmpty,
|
147
181
|
notEquals,
|
148
182
|
startsWith,
|
@@ -56,7 +56,9 @@ export const MRT_TableFooterCell: FC<Props> = ({ footer, table }) => {
|
|
56
56
|
transition: `all ${enableColumnResizing ? '10ms' : '0.2s'} ease-in-out`,
|
57
57
|
width: column.getSize(),
|
58
58
|
verticalAlign: 'text-top',
|
59
|
-
...(tableCellProps?.sx
|
59
|
+
...(tableCellProps?.sx instanceof Function
|
60
|
+
? tableCellProps.sx(theme)
|
61
|
+
: (tableCellProps?.sx as any)),
|
60
62
|
})}
|
61
63
|
>
|
62
64
|
<>
|
@@ -162,7 +162,9 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
|
|
162
162
|
: column.getIsPinned() && columnDefType !== 'group'
|
163
163
|
? 2
|
164
164
|
: 1,
|
165
|
-
...(tableCellProps?.sx
|
165
|
+
...(tableCellProps?.sx instanceof Function
|
166
|
+
? tableCellProps.sx(theme)
|
167
|
+
: (tableCellProps?.sx as any)),
|
166
168
|
...draggingBorders,
|
167
169
|
maxWidth: `min(${column.getSize()}px, fit-content)`,
|
168
170
|
minWidth: `max(${column.getSize()}px, ${columnDef.minSize ?? 30}px)`,
|
@@ -190,6 +192,8 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
|
|
190
192
|
: undefined,
|
191
193
|
display: 'flex',
|
192
194
|
flexWrap: 'nowrap',
|
195
|
+
m: tableCellProps?.align === 'center' ? 'auto' : undefined,
|
196
|
+
pl: tableCellProps?.align === 'center' ? '1rem' : undefined,
|
193
197
|
whiteSpace:
|
194
198
|
(columnDef.header?.length ?? 0) < 24 ? 'nowrap' : 'normal',
|
195
199
|
}}
|
@@ -62,7 +62,7 @@ export const MRT_TableHeadCellColumnActionsButton: FC<Props> = ({
|
|
62
62
|
onClick={handleClick}
|
63
63
|
size="small"
|
64
64
|
{...iconButtonProps}
|
65
|
-
sx={{
|
65
|
+
sx={(theme) => ({
|
66
66
|
height: '2rem',
|
67
67
|
mt: '-0.2rem',
|
68
68
|
opacity: 0.5,
|
@@ -71,8 +71,10 @@ export const MRT_TableHeadCellColumnActionsButton: FC<Props> = ({
|
|
71
71
|
'&:hover': {
|
72
72
|
opacity: 1,
|
73
73
|
},
|
74
|
-
...iconButtonProps
|
75
|
-
|
74
|
+
...(iconButtonProps?.sx instanceof Function
|
75
|
+
? iconButtonProps.sx(theme)
|
76
|
+
: (iconButtonProps?.sx as any)),
|
77
|
+
})}
|
76
78
|
>
|
77
79
|
<MoreVertIcon />
|
78
80
|
</IconButton>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React, { DragEvent, FC, RefObject } from 'react';
|
2
2
|
import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton';
|
3
|
-
import { reorderColumn } from '../utils';
|
3
|
+
import { reorderColumn } from '../column.utils';
|
4
4
|
import type { MRT_Column, MRT_TableInstance } from '..';
|
5
5
|
|
6
6
|
interface Props {
|
@@ -73,7 +73,10 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
73
73
|
|
74
74
|
const handleChangeDebounced = useCallback(
|
75
75
|
debounce((event: ChangeEvent<HTMLInputElement>) => {
|
76
|
-
let value =
|
76
|
+
let value =
|
77
|
+
textFieldProps.type === 'date'
|
78
|
+
? new Date(event.target.value)
|
79
|
+
: event.target.value;
|
77
80
|
if (inputIndex !== undefined) {
|
78
81
|
column.setFilterValue((old: [string, string | Date]) => {
|
79
82
|
const newFilterValues = old ?? ['', ''];
|
@@ -256,7 +259,7 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
256
259
|
),
|
257
260
|
}}
|
258
261
|
{...textFieldProps}
|
259
|
-
sx={{
|
262
|
+
sx={(theme) => ({
|
260
263
|
m: '-0.25rem',
|
261
264
|
p: 0,
|
262
265
|
minWidth: !filterChipLabel ? '8rem' : 'auto',
|
@@ -264,8 +267,10 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
264
267
|
'& .MuiSelect-icon': {
|
265
268
|
mr: '1.5rem',
|
266
269
|
},
|
267
|
-
...textFieldProps?.sx
|
268
|
-
|
270
|
+
...(textFieldProps?.sx instanceof Function
|
271
|
+
? textFieldProps.sx(theme)
|
272
|
+
: (textFieldProps?.sx as any)),
|
273
|
+
})}
|
269
274
|
>
|
270
275
|
{isSelectFilter && (
|
271
276
|
<MenuItem divider disabled={!filterValue} value="">
|
@@ -58,12 +58,14 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll, table }) => {
|
|
58
58
|
}
|
59
59
|
size={density === 'compact' ? 'small' : 'medium'}
|
60
60
|
{...checkboxProps}
|
61
|
-
sx={{
|
61
|
+
sx={(theme) => ({
|
62
62
|
height: density === 'compact' ? '1.5rem' : '2rem',
|
63
63
|
width: density === 'compact' ? '1.5rem' : '2rem',
|
64
64
|
m: '-1re.m',
|
65
|
-
...checkboxProps?.sx
|
66
|
-
|
65
|
+
...(checkboxProps?.sx instanceof Function
|
66
|
+
? checkboxProps.sx(theme)
|
67
|
+
: (checkboxProps?.sx as any)),
|
68
|
+
})}
|
67
69
|
/>
|
68
70
|
</Tooltip>
|
69
71
|
);
|
package/src/localization.ts
CHANGED
@@ -14,6 +14,7 @@ export interface MRT_Localization {
|
|
14
14
|
expand: string;
|
15
15
|
expandAll: string;
|
16
16
|
filterBetween: string;
|
17
|
+
filterBetweenInclusive: string;
|
17
18
|
filterByColumn: string;
|
18
19
|
filterContains: string;
|
19
20
|
filterEmpty: string;
|
@@ -21,7 +22,9 @@ export interface MRT_Localization {
|
|
21
22
|
filterEquals: string;
|
22
23
|
filterFuzzy: string;
|
23
24
|
filterGreaterThan: string;
|
25
|
+
filterGreaterThanOrEqualTo: string;
|
24
26
|
filterLessThan: string;
|
27
|
+
filterLessThanOrEqualTo: string;
|
25
28
|
filterMode: string;
|
26
29
|
filterNotEmpty: string;
|
27
30
|
filterNotEquals: string;
|
@@ -83,6 +86,7 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
83
86
|
expand: 'Expand',
|
84
87
|
expandAll: 'Expand all',
|
85
88
|
filterBetween: 'Between',
|
89
|
+
filterBetweenInclusive: 'Between Inclusive',
|
86
90
|
filterByColumn: 'Filter by {column}',
|
87
91
|
filterContains: 'Contains',
|
88
92
|
filterEmpty: 'Empty',
|
@@ -90,7 +94,9 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
90
94
|
filterEquals: 'Equals',
|
91
95
|
filterFuzzy: 'Fuzzy',
|
92
96
|
filterGreaterThan: 'Greater Than',
|
97
|
+
filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
|
93
98
|
filterLessThan: 'Less Than',
|
99
|
+
filterLessThanOrEqualTo: 'Less Than Or Equal To',
|
94
100
|
filterMode: 'Filter Mode: {filterType}',
|
95
101
|
filterNotEmpty: 'Not Empty',
|
96
102
|
filterNotEquals: 'Not Equals',
|
@@ -1,13 +1,7 @@
|
|
1
1
|
import React, { FC, useMemo } from 'react';
|
2
|
-
import { Menu, MenuItem } from '@mui/material';
|
2
|
+
import { Box, Menu, MenuItem } from '@mui/material';
|
3
3
|
import type { MRT_FilterOption, MRT_Header, MRT_TableInstance } from '..';
|
4
4
|
|
5
|
-
const commonMenuItemStyles = {
|
6
|
-
py: '6px',
|
7
|
-
my: 0,
|
8
|
-
alignItems: 'center',
|
9
|
-
};
|
10
|
-
|
11
5
|
interface Props {
|
12
6
|
anchorEl: HTMLElement | null;
|
13
7
|
header?: MRT_Header;
|
@@ -42,75 +36,107 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
42
36
|
|
43
37
|
const filterOptions = useMemo(
|
44
38
|
() =>
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
39
|
+
(
|
40
|
+
[
|
41
|
+
{
|
42
|
+
option: 'fuzzy',
|
43
|
+
symbol: '≈',
|
44
|
+
label: localization.filterFuzzy,
|
45
|
+
divider: false,
|
46
|
+
},
|
47
|
+
{
|
48
|
+
option: 'contains',
|
49
|
+
symbol: '*',
|
50
|
+
label: localization.filterContains,
|
51
|
+
divider: false,
|
52
|
+
},
|
53
|
+
{
|
54
|
+
option: 'startsWith',
|
55
|
+
symbol: 'a',
|
56
|
+
label: localization.filterStartsWith,
|
57
|
+
divider: false,
|
58
|
+
},
|
59
|
+
{
|
60
|
+
option: 'endsWith',
|
61
|
+
symbol: 'z',
|
62
|
+
label: localization.filterEndsWith,
|
63
|
+
divider: true,
|
64
|
+
},
|
65
|
+
{
|
66
|
+
option: 'equals',
|
67
|
+
symbol: '=',
|
68
|
+
label: localization.filterEquals,
|
69
|
+
divider: false,
|
70
|
+
},
|
71
|
+
{
|
72
|
+
option: 'notEquals',
|
73
|
+
symbol: '≠',
|
74
|
+
label: localization.filterNotEquals,
|
75
|
+
divider: true,
|
76
|
+
},
|
77
|
+
{
|
78
|
+
option: 'between',
|
79
|
+
symbol: '⇿',
|
80
|
+
label: localization.filterBetween,
|
81
|
+
divider: false,
|
82
|
+
},
|
83
|
+
{
|
84
|
+
option: 'betweenInclusive',
|
85
|
+
symbol: '⬌',
|
86
|
+
label: localization.filterBetweenInclusive,
|
87
|
+
divider: true,
|
88
|
+
},
|
89
|
+
{
|
90
|
+
option: 'greaterThan',
|
91
|
+
symbol: '>',
|
92
|
+
label: localization.filterGreaterThan,
|
93
|
+
divider: false,
|
94
|
+
},
|
95
|
+
{
|
96
|
+
option: 'greaterThanOrEqualTo',
|
97
|
+
symbol: '≥',
|
98
|
+
label: localization.filterGreaterThanOrEqualTo,
|
99
|
+
divider: false,
|
100
|
+
},
|
101
|
+
{
|
102
|
+
option: 'lessThan',
|
103
|
+
symbol: '<',
|
104
|
+
label: localization.filterLessThan,
|
105
|
+
divider: false,
|
106
|
+
},
|
107
|
+
{
|
108
|
+
option: 'lessThanOrEqualTo',
|
109
|
+
symbol: '≤',
|
110
|
+
label: localization.filterLessThanOrEqualTo,
|
111
|
+
divider: true,
|
112
|
+
},
|
113
|
+
{
|
114
|
+
option: 'empty',
|
115
|
+
symbol: '∅',
|
116
|
+
label: localization.filterEmpty,
|
117
|
+
divider: false,
|
118
|
+
},
|
119
|
+
{
|
120
|
+
option: 'notEmpty',
|
121
|
+
symbol: '!∅',
|
122
|
+
label: localization.filterNotEmpty,
|
123
|
+
divider: false,
|
124
|
+
},
|
125
|
+
] as Array<{
|
126
|
+
divider: boolean;
|
127
|
+
fn: Function;
|
128
|
+
label: string;
|
129
|
+
option: MRT_FilterOption;
|
130
|
+
symbol?: string;
|
131
|
+
}>
|
132
|
+
).filter((filterType) =>
|
102
133
|
columnDef
|
103
134
|
? allowedColumnFilterOptions === undefined ||
|
104
135
|
allowedColumnFilterOptions?.includes(filterType.option)
|
105
136
|
: (!enabledGlobalFilterOptions ||
|
106
137
|
enabledGlobalFilterOptions.includes(filterType.option)) &&
|
107
138
|
['fuzzy', 'contains'].includes(filterType.option),
|
108
|
-
)
|
109
|
-
option: MRT_FilterOption;
|
110
|
-
label: string;
|
111
|
-
divider: boolean;
|
112
|
-
fn: Function;
|
113
|
-
}>,
|
139
|
+
),
|
114
140
|
[],
|
115
141
|
);
|
116
142
|
|
@@ -148,15 +174,22 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
148
174
|
dense: density === 'compact',
|
149
175
|
}}
|
150
176
|
>
|
151
|
-
{filterOptions.map(({ option, label, divider }, index) => (
|
177
|
+
{filterOptions.map(({ option, label, divider, symbol }, index) => (
|
152
178
|
<MenuItem
|
153
179
|
divider={divider}
|
154
180
|
key={index}
|
155
181
|
onClick={() => handleSelectFilterType(option)}
|
156
182
|
selected={option === filterOption}
|
157
|
-
sx={
|
183
|
+
sx={{
|
184
|
+
py: '6px',
|
185
|
+
my: 0,
|
186
|
+
alignItems: 'center',
|
187
|
+
display: 'flex',
|
188
|
+
gap: '2ch',
|
189
|
+
}}
|
158
190
|
value={option}
|
159
191
|
>
|
192
|
+
<Box sx={{ fontSize: '1.25rem', width: '2ch' }}>{symbol}</Box>
|
160
193
|
{label}
|
161
194
|
</MenuItem>
|
162
195
|
))}
|
@@ -2,7 +2,7 @@ import React, { FC, useMemo, useState } from 'react';
|
|
2
2
|
import { Button, Menu, Divider, Box } from '@mui/material';
|
3
3
|
import { MRT_ShowHideColumnsMenuItems } from './MRT_ShowHideColumnsMenuItems';
|
4
4
|
import type { MRT_Column, MRT_TableInstance } from '..';
|
5
|
-
import { getDefaultColumnOrderIds } from '../utils';
|
5
|
+
import { getDefaultColumnOrderIds } from '../column.utils';
|
6
6
|
|
7
7
|
interface Props {
|
8
8
|
anchorEl: HTMLElement | null;
|
@@ -15,7 +15,7 @@ import {
|
|
15
15
|
} from '@mui/material';
|
16
16
|
import { MRT_ColumnPinningButtons } from '../buttons/MRT_ColumnPinningButtons';
|
17
17
|
import { MRT_GrabHandleButton } from '../buttons/MRT_GrabHandleButton';
|
18
|
-
import { reorderColumn } from '../utils';
|
18
|
+
import { reorderColumn } from '../column.utils';
|
19
19
|
import type { MRT_Column, MRT_TableInstance } from '..';
|
20
20
|
|
21
21
|
interface Props {
|
package/src/table/MRT_Table.tsx
CHANGED
@@ -35,11 +35,13 @@ export const MRT_Table: FC<Props> = ({ tableContainerRef, table }) => {
|
|
35
35
|
enableStickyHeader || enableRowVirtualization || isFullScreen
|
36
36
|
}
|
37
37
|
{...tableProps}
|
38
|
-
sx={{
|
38
|
+
sx={(theme) => ({
|
39
39
|
tableLayout:
|
40
40
|
enableColumnResizing || enableRowVirtualization ? 'fixed' : 'auto',
|
41
|
-
...tableProps?.sx
|
42
|
-
|
41
|
+
...(tableProps?.sx instanceof Function
|
42
|
+
? tableProps.sx(theme)
|
43
|
+
: (tableProps?.sx as any)),
|
44
|
+
})}
|
43
45
|
>
|
44
46
|
{enableTableHead && <MRT_TableHead table={table} />}
|
45
47
|
<MRT_TableBody tableContainerRef={tableContainerRef} table={table} />
|