material-react-table 1.0.0-beta.8 → 1.0.1
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 +2 -2
- package/dist/cjs/MaterialReactTable.d.ts +112 -7
- package/dist/cjs/_locales/en.d.ts +2 -0
- package/dist/cjs/_locales/pt-BR.d.ts +2 -0
- package/dist/cjs/column.utils.d.ts +6 -0
- package/dist/cjs/head/MRT_TableHeadCellSortLabel.d.ts +2 -0
- package/dist/cjs/index.d.ts +4 -3
- package/dist/cjs/index.js +200 -71
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/inputs/MRT_FilterCheckbox.d.ts +8 -0
- package/dist/cjs/menus/MRT_FilterOptionMenu.d.ts +3 -3
- package/dist/cjs/table/MRT_TableRoot.d.ts +254 -2
- package/dist/cjs/toolbar/MRT_TablePagination.d.ts +3 -4
- package/dist/cjs/toolbar/MRT_ToolbarInternalButtons.d.ts +3 -4
- package/dist/cjs/toolbar/MRT_TopToolbar.d.ts +1 -0
- package/dist/esm/MaterialReactTable.d.ts +112 -7
- package/dist/esm/_locales/en.d.ts +2 -0
- package/dist/esm/_locales/pt-BR.d.ts +2 -0
- package/dist/esm/column.utils.d.ts +6 -0
- package/dist/esm/head/MRT_TableHeadCellSortLabel.d.ts +2 -0
- package/dist/esm/index.d.ts +4 -3
- package/dist/esm/inputs/MRT_FilterCheckbox.d.ts +8 -0
- package/dist/esm/material-react-table.esm.js +200 -73
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/menus/MRT_FilterOptionMenu.d.ts +3 -3
- package/dist/esm/table/MRT_TableRoot.d.ts +254 -2
- package/dist/esm/toolbar/MRT_TablePagination.d.ts +3 -4
- package/dist/esm/toolbar/MRT_ToolbarInternalButtons.d.ts +3 -4
- package/dist/esm/toolbar/MRT_TopToolbar.d.ts +1 -0
- package/dist/index.d.ts +61 -28
- package/locales/en.d.ts +2 -0
- package/locales/en.esm.d.ts +2 -0
- package/locales/en.esm.js +92 -0
- package/locales/en.esm.js.map +1 -0
- package/locales/en.js +96 -0
- package/locales/en.js.map +1 -0
- package/locales/pt-BR.d.ts +2 -0
- package/locales/pt-BR.esm.d.ts +2 -0
- package/locales/pt-BR.esm.js +92 -0
- package/locales/pt-BR.esm.js.map +1 -0
- package/locales/pt-BR.js +96 -0
- package/locales/pt-BR.js.map +1 -0
- package/package.json +13 -11
- package/src/MaterialReactTable.tsx +205 -67
- package/src/_locales/de.ts +1 -0
- package/src/{localization.ts → _locales/en.ts} +8 -84
- package/src/_locales/es.ts +1 -0
- package/src/_locales/fr.ts +1 -0
- package/src/_locales/hi.ts +1 -0
- package/src/_locales/id.ts +1 -0
- package/src/_locales/ja.ts +1 -0
- package/src/_locales/nl.ts +1 -0
- package/src/_locales/pt-BR.ts +92 -0
- package/src/_locales/pt.ts +1 -0
- package/src/_locales/ru.ts +1 -0
- package/src/_locales/uk.ts +1 -0
- package/src/_locales/vi.ts +1 -0
- package/src/_locales/zh.ts +1 -0
- package/src/body/MRT_EditRowModal.tsx +3 -2
- package/src/body/MRT_TableBodyCell.tsx +1 -1
- package/src/body/MRT_TableBodyRow.tsx +1 -1
- package/src/body/MRT_TableDetailPanel.tsx +1 -1
- package/src/buttons/MRT_ExpandAllButton.tsx +1 -1
- package/src/buttons/MRT_ExpandButton.tsx +1 -1
- package/src/buttons/MRT_GrabHandleButton.tsx +1 -1
- package/src/buttons/MRT_ToggleGlobalFilterButton.tsx +7 -2
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +1 -1
- package/src/column.utils.ts +28 -3
- package/src/footer/MRT_TableFooter.tsx +1 -1
- package/src/head/MRT_TableHead.tsx +10 -2
- package/src/head/MRT_TableHeadCell.tsx +10 -2
- package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +1 -1
- package/src/head/MRT_TableHeadCellFilterContainer.tsx +7 -3
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +5 -1
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +1 -1
- package/src/head/MRT_TableHeadCellSortLabel.tsx +11 -3
- package/src/index.tsx +6 -3
- package/src/inputs/MRT_FilterCheckbox.tsx +96 -0
- package/src/inputs/MRT_FilterTextField.tsx +19 -13
- package/src/inputs/MRT_GlobalFilterTextField.tsx +18 -5
- package/src/inputs/MRT_SelectCheckbox.tsx +16 -7
- package/src/menus/MRT_FilterOptionMenu.tsx +19 -2
- package/src/table/MRT_TablePaper.tsx +16 -4
- package/src/table/MRT_TableRoot.tsx +8 -7
- package/src/toolbar/MRT_BottomToolbar.tsx +4 -1
- package/src/toolbar/MRT_TablePagination.tsx +45 -8
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +2 -1
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +8 -4
- package/src/toolbar/MRT_TopToolbar.tsx +2 -1
- package/dist/cjs/localization.d.ts +0 -84
- package/dist/esm/localization.d.ts +0 -84
|
@@ -46,7 +46,7 @@ export const MRT_GrabHandleButton = <TData extends Record<string, any> = {}>({
|
|
|
46
46
|
m: 0,
|
|
47
47
|
opacity: 0.5,
|
|
48
48
|
p: '2px',
|
|
49
|
-
transition: 'all 0.
|
|
49
|
+
transition: 'all 0.1s ease-in-out',
|
|
50
50
|
'&:hover': {
|
|
51
51
|
backgroundColor: 'transparent',
|
|
52
52
|
opacity: 1,
|
|
@@ -23,7 +23,7 @@ export const MRT_ToggleGlobalFilterButton = <
|
|
|
23
23
|
refs: { searchInputRef },
|
|
24
24
|
setShowGlobalFilter,
|
|
25
25
|
} = table;
|
|
26
|
-
const { showGlobalFilter } = getState();
|
|
26
|
+
const { globalFilter, showGlobalFilter } = getState();
|
|
27
27
|
|
|
28
28
|
const handleToggleSearch = () => {
|
|
29
29
|
setShowGlobalFilter(!showGlobalFilter);
|
|
@@ -32,7 +32,12 @@ export const MRT_ToggleGlobalFilterButton = <
|
|
|
32
32
|
|
|
33
33
|
return (
|
|
34
34
|
<Tooltip arrow title={rest?.title ?? localization.showHideSearch}>
|
|
35
|
-
<IconButton
|
|
35
|
+
<IconButton
|
|
36
|
+
disabled={!!globalFilter}
|
|
37
|
+
onClick={handleToggleSearch}
|
|
38
|
+
{...rest}
|
|
39
|
+
title={undefined}
|
|
40
|
+
>
|
|
36
41
|
{showGlobalFilter ? <SearchOffIcon /> : <SearchIcon />}
|
|
37
42
|
</IconButton>
|
|
38
43
|
</Tooltip>
|
package/src/column.utils.ts
CHANGED
|
@@ -164,8 +164,12 @@ export const getDefaultColumnFilterFn = <
|
|
|
164
164
|
columnDef: MRT_ColumnDef<TData>,
|
|
165
165
|
): MRT_FilterOption => {
|
|
166
166
|
if (columnDef.filterVariant === 'multi-select') return 'arrIncludesSome';
|
|
167
|
-
if (columnDef.filterVariant === 'select') return 'equals';
|
|
168
167
|
if (columnDef.filterVariant === 'range') return 'betweenInclusive';
|
|
168
|
+
if (
|
|
169
|
+
columnDef.filterVariant === 'select' ||
|
|
170
|
+
columnDef.filterVariant === 'checkbox'
|
|
171
|
+
)
|
|
172
|
+
return 'equals';
|
|
169
173
|
return 'fuzzy';
|
|
170
174
|
};
|
|
171
175
|
|
|
@@ -204,7 +208,7 @@ export const getCommonCellStyles = ({
|
|
|
204
208
|
}) => ({
|
|
205
209
|
backgroundColor:
|
|
206
210
|
column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
|
207
|
-
? alpha(lighten(theme.palette.background.default, 0.04), 0.
|
|
211
|
+
? alpha(lighten(theme.palette.background.default, 0.04), 0.97)
|
|
208
212
|
: 'inherit',
|
|
209
213
|
backgroundImage: 'inherit',
|
|
210
214
|
boxShadow: getIsLastLeftPinnedColumn(table, column)
|
|
@@ -229,7 +233,7 @@ export const getCommonCellStyles = ({
|
|
|
229
233
|
column.getIsPinned() === 'right'
|
|
230
234
|
? `${getTotalRight(table, column)}px`
|
|
231
235
|
: undefined,
|
|
232
|
-
transition: `all ${column.getIsResizing() ? 0 : '0.
|
|
236
|
+
transition: `all ${column.getIsResizing() ? 0 : '0.1s'} ease-in-out`,
|
|
233
237
|
...(tableCellProps?.sx instanceof Function
|
|
234
238
|
? tableCellProps.sx(theme)
|
|
235
239
|
: (tableCellProps?.sx as any)),
|
|
@@ -237,3 +241,24 @@ export const getCommonCellStyles = ({
|
|
|
237
241
|
minWidth: `max(${column.getSize()}px, ${column.columnDef.minSize ?? 30}px)`,
|
|
238
242
|
width: header?.getSize() ?? column.getSize(),
|
|
239
243
|
});
|
|
244
|
+
|
|
245
|
+
export const MRT_DefaultColumn = {
|
|
246
|
+
minSize: 40,
|
|
247
|
+
maxSize: 1000,
|
|
248
|
+
size: 180,
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export const MRT_DefaultDisplayColumn: Partial<MRT_ColumnDef> = {
|
|
252
|
+
columnDefType: 'display',
|
|
253
|
+
enableClickToCopy: false,
|
|
254
|
+
enableColumnActions: false,
|
|
255
|
+
enableColumnDragging: false,
|
|
256
|
+
enableColumnFilter: false,
|
|
257
|
+
enableColumnOrdering: false,
|
|
258
|
+
enableEditing: false,
|
|
259
|
+
enableGlobalFilter: false,
|
|
260
|
+
enableGrouping: false,
|
|
261
|
+
enableHiding: false,
|
|
262
|
+
enableResizing: false,
|
|
263
|
+
enableSorting: false,
|
|
264
|
+
};
|
|
@@ -29,7 +29,7 @@ export const MRT_TableFooter: FC<Props> = ({ table }) => {
|
|
|
29
29
|
sx={(theme) => ({
|
|
30
30
|
backgroundColor: lighten(theme.palette.background.default, 0.06),
|
|
31
31
|
bottom: stickFooter ? 0 : undefined,
|
|
32
|
-
opacity: stickFooter ? 0.
|
|
32
|
+
opacity: stickFooter ? 0.97 : undefined,
|
|
33
33
|
outline: stickFooter
|
|
34
34
|
? theme.palette.mode === 'light'
|
|
35
35
|
? `1px solid ${theme.palette.grey[300]}`
|
|
@@ -10,7 +10,7 @@ interface Props {
|
|
|
10
10
|
export const MRT_TableHead: FC<Props> = ({ table }) => {
|
|
11
11
|
const {
|
|
12
12
|
getHeaderGroups,
|
|
13
|
-
options: { muiTableHeadProps },
|
|
13
|
+
options: { enableStickyHeader, muiTableHeadProps },
|
|
14
14
|
} = table;
|
|
15
15
|
|
|
16
16
|
const tableHeadProps =
|
|
@@ -19,7 +19,15 @@ export const MRT_TableHead: FC<Props> = ({ table }) => {
|
|
|
19
19
|
: muiTableHeadProps;
|
|
20
20
|
|
|
21
21
|
return (
|
|
22
|
-
<TableHead
|
|
22
|
+
<TableHead
|
|
23
|
+
{...tableHeadProps}
|
|
24
|
+
sx={(theme) => ({
|
|
25
|
+
opacity: enableStickyHeader ? 0.97 : undefined,
|
|
26
|
+
...(tableHeadProps?.sx instanceof Function
|
|
27
|
+
? tableHeadProps?.sx(theme)
|
|
28
|
+
: (tableHeadProps?.sx as any)),
|
|
29
|
+
})}
|
|
30
|
+
>
|
|
23
31
|
{getHeaderGroups().map((headerGroup) => (
|
|
24
32
|
<MRT_TableHeadRow
|
|
25
33
|
headerGroup={headerGroup as any}
|
|
@@ -145,9 +145,11 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
|
|
|
145
145
|
sx={{
|
|
146
146
|
alignItems: 'flex-start',
|
|
147
147
|
display: 'flex',
|
|
148
|
+
flexDirection:
|
|
149
|
+
tableCellProps?.align === 'right' ? 'row-reverse' : 'row',
|
|
148
150
|
justifyContent:
|
|
149
151
|
tableCellProps?.align === 'right'
|
|
150
|
-
? 'flex-
|
|
152
|
+
? 'flex-start'
|
|
151
153
|
: columnDefType === 'group' ||
|
|
152
154
|
tableCellProps?.align === 'center'
|
|
153
155
|
? 'center'
|
|
@@ -165,6 +167,8 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
|
|
|
165
167
|
? 'pointer'
|
|
166
168
|
: undefined,
|
|
167
169
|
display: 'flex',
|
|
170
|
+
flexDirection:
|
|
171
|
+
tableCellProps?.align === 'right' ? 'row-reverse' : 'row',
|
|
168
172
|
flexWrap: 'nowrap',
|
|
169
173
|
m: tableCellProps?.align === 'center' ? 'auto' : undefined,
|
|
170
174
|
pl:
|
|
@@ -177,7 +181,11 @@ export const MRT_TableHeadCell: FC<Props> = ({ header, table }) => {
|
|
|
177
181
|
>
|
|
178
182
|
{headerElement}
|
|
179
183
|
{column.getCanSort() && (
|
|
180
|
-
<MRT_TableHeadCellSortLabel
|
|
184
|
+
<MRT_TableHeadCellSortLabel
|
|
185
|
+
header={header}
|
|
186
|
+
table={table}
|
|
187
|
+
tableCellProps={tableCellProps}
|
|
188
|
+
/>
|
|
181
189
|
)}
|
|
182
190
|
{column.getCanFilter() && (
|
|
183
191
|
<MRT_TableHeadCellFilterLabel header={header} table={table} />
|
|
@@ -3,6 +3,7 @@ import { Collapse } from '@mui/material';
|
|
|
3
3
|
import { MRT_FilterRangeFields } from '../inputs/MRT_FilterRangeFields';
|
|
4
4
|
import { MRT_FilterTextField } from '../inputs/MRT_FilterTextField';
|
|
5
5
|
import { MRT_Header, MRT_TableInstance } from '..';
|
|
6
|
+
import { MRT_FilterCheckbox } from '../inputs/MRT_FilterCheckbox';
|
|
6
7
|
|
|
7
8
|
interface Props {
|
|
8
9
|
header: MRT_Header;
|
|
@@ -20,9 +21,12 @@ export const MRT_TableHeadCellFilterContainer: FC<Props> = ({
|
|
|
20
21
|
|
|
21
22
|
return (
|
|
22
23
|
<Collapse in={showColumnFilters} mountOnEnter unmountOnExit>
|
|
23
|
-
{
|
|
24
|
-
|
|
25
|
-
)
|
|
24
|
+
{columnDef.filterVariant === 'checkbox' ? (
|
|
25
|
+
<MRT_FilterCheckbox column={column} table={table} />
|
|
26
|
+
) : columnDef.filterVariant === 'range' ||
|
|
27
|
+
['between', 'betweenInclusive', 'inNumberRange'].includes(
|
|
28
|
+
columnDef._filterFn,
|
|
29
|
+
) ? (
|
|
26
30
|
<MRT_FilterRangeFields header={header} table={table} />
|
|
27
31
|
) : (
|
|
28
32
|
<MRT_FilterTextField header={header} table={table} />
|
|
@@ -42,7 +42,11 @@ export const MRT_TableHeadCellGrabHandle: FC<Props> = ({
|
|
|
42
42
|
const handleDragStart = (event: DragEvent<HTMLButtonElement>) => {
|
|
43
43
|
iconButtonProps?.onDragStart?.(event);
|
|
44
44
|
setDraggingColumn(column);
|
|
45
|
-
event.dataTransfer.setDragImage(
|
|
45
|
+
event.dataTransfer.setDragImage(
|
|
46
|
+
tableHeadCellRef.current as HTMLElement,
|
|
47
|
+
0,
|
|
48
|
+
0,
|
|
49
|
+
);
|
|
46
50
|
};
|
|
47
51
|
|
|
48
52
|
const handleDragEnd = (event: DragEvent<HTMLButtonElement>) => {
|
|
@@ -32,7 +32,7 @@ export const MRT_TableHeadCellResizeHandle: FC<Props> = ({ header, table }) => {
|
|
|
32
32
|
position: 'absolute',
|
|
33
33
|
right: '1px',
|
|
34
34
|
touchAction: 'none',
|
|
35
|
-
transition: column.getIsResizing() ? undefined : 'all 0.
|
|
35
|
+
transition: column.getIsResizing() ? undefined : 'all 0.1s ease-in-out',
|
|
36
36
|
userSelect: 'none',
|
|
37
37
|
zIndex: 4,
|
|
38
38
|
'&:active': {
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import React, { FC } from 'react';
|
|
2
|
-
import { TableSortLabel, Tooltip } from '@mui/material';
|
|
2
|
+
import { TableCellProps, TableSortLabel, Tooltip } from '@mui/material';
|
|
3
3
|
import { MRT_Header, MRT_TableInstance } from '..';
|
|
4
4
|
|
|
5
5
|
interface Props {
|
|
6
6
|
header: MRT_Header;
|
|
7
7
|
table: MRT_TableInstance;
|
|
8
|
+
tableCellProps?: TableCellProps;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
export const MRT_TableHeadCellSortLabel: FC<Props> = ({
|
|
11
|
+
export const MRT_TableHeadCellSortLabel: FC<Props> = ({
|
|
12
|
+
header,
|
|
13
|
+
table,
|
|
14
|
+
tableCellProps,
|
|
15
|
+
}) => {
|
|
11
16
|
const {
|
|
12
17
|
options: { localization },
|
|
13
18
|
} = table;
|
|
@@ -32,7 +37,10 @@ export const MRT_TableHeadCellSortLabel: FC<Props> = ({ header, table }) => {
|
|
|
32
37
|
}
|
|
33
38
|
sx={{
|
|
34
39
|
width: '2ch',
|
|
35
|
-
transform:
|
|
40
|
+
transform:
|
|
41
|
+
tableCellProps?.align !== 'right'
|
|
42
|
+
? 'translateX(-0.5ch)'
|
|
43
|
+
: undefined,
|
|
36
44
|
}}
|
|
37
45
|
/>
|
|
38
46
|
</Tooltip>
|
package/src/index.tsx
CHANGED
|
@@ -3,23 +3,26 @@ export default MaterialReactTable;
|
|
|
3
3
|
export * from './MaterialReactTable';
|
|
4
4
|
|
|
5
5
|
import type { MRT_Icons } from './icons';
|
|
6
|
-
|
|
7
|
-
export type { MRT_Localization, MRT_Icons };
|
|
6
|
+
export type { MRT_Icons };
|
|
8
7
|
|
|
9
8
|
import { MRT_CopyButton } from './buttons/MRT_CopyButton';
|
|
10
9
|
import { MRT_FullScreenToggleButton } from './buttons/MRT_FullScreenToggleButton';
|
|
11
10
|
import { MRT_GlobalFilterTextField } from './inputs/MRT_GlobalFilterTextField';
|
|
12
11
|
import { MRT_ShowHideColumnsButton } from './buttons/MRT_ShowHideColumnsButton';
|
|
12
|
+
import { MRT_TablePagination } from './toolbar/MRT_TablePagination';
|
|
13
13
|
import { MRT_ToggleDensePaddingButton } from './buttons/MRT_ToggleDensePaddingButton';
|
|
14
14
|
import { MRT_ToggleFiltersButton } from './buttons/MRT_ToggleFiltersButton';
|
|
15
15
|
import { MRT_ToggleGlobalFilterButton } from './buttons/MRT_ToggleGlobalFilterButton';
|
|
16
|
+
import { MRT_ToolbarInternalButtons } from './toolbar/MRT_ToolbarInternalButtons';
|
|
16
17
|
|
|
17
18
|
export {
|
|
19
|
+
MRT_CopyButton,
|
|
18
20
|
MRT_FullScreenToggleButton,
|
|
19
21
|
MRT_GlobalFilterTextField,
|
|
20
22
|
MRT_ShowHideColumnsButton,
|
|
23
|
+
MRT_TablePagination,
|
|
21
24
|
MRT_ToggleDensePaddingButton,
|
|
22
25
|
MRT_ToggleFiltersButton,
|
|
23
26
|
MRT_ToggleGlobalFilterButton,
|
|
24
|
-
|
|
27
|
+
MRT_ToolbarInternalButtons,
|
|
25
28
|
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Checkbox,
|
|
4
|
+
CheckboxProps,
|
|
5
|
+
FormControlLabel,
|
|
6
|
+
Tooltip,
|
|
7
|
+
} from '@mui/material';
|
|
8
|
+
import type { MRT_Column, MRT_TableInstance } from '..';
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
column: MRT_Column;
|
|
12
|
+
table: MRT_TableInstance;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const MRT_FilterCheckbox: FC<Props> = ({ column, table }) => {
|
|
16
|
+
const {
|
|
17
|
+
getState,
|
|
18
|
+
options: { localization, muiTableHeadCellFilterCheckboxProps },
|
|
19
|
+
} = table;
|
|
20
|
+
const { density } = getState();
|
|
21
|
+
const { columnDef } = column;
|
|
22
|
+
|
|
23
|
+
const mTableHeadCellFilterCheckboxProps =
|
|
24
|
+
muiTableHeadCellFilterCheckboxProps instanceof Function
|
|
25
|
+
? muiTableHeadCellFilterCheckboxProps({
|
|
26
|
+
column,
|
|
27
|
+
table,
|
|
28
|
+
})
|
|
29
|
+
: muiTableHeadCellFilterCheckboxProps;
|
|
30
|
+
|
|
31
|
+
const mcTableHeadCellFilterCheckboxProps =
|
|
32
|
+
columnDef.muiTableHeadCellFilterCheckboxProps instanceof Function
|
|
33
|
+
? columnDef.muiTableHeadCellFilterCheckboxProps({
|
|
34
|
+
column,
|
|
35
|
+
table,
|
|
36
|
+
})
|
|
37
|
+
: columnDef.muiTableHeadCellFilterCheckboxProps;
|
|
38
|
+
|
|
39
|
+
const checkboxProps = {
|
|
40
|
+
...mTableHeadCellFilterCheckboxProps,
|
|
41
|
+
...mcTableHeadCellFilterCheckboxProps,
|
|
42
|
+
} as CheckboxProps;
|
|
43
|
+
|
|
44
|
+
const filterLabel = localization.filterByColumn?.replace(
|
|
45
|
+
'{column}',
|
|
46
|
+
columnDef.header,
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<Tooltip
|
|
51
|
+
arrow
|
|
52
|
+
enterDelay={1000}
|
|
53
|
+
enterNextDelay={1000}
|
|
54
|
+
title={checkboxProps?.title ?? filterLabel}
|
|
55
|
+
>
|
|
56
|
+
<FormControlLabel
|
|
57
|
+
control={
|
|
58
|
+
<Checkbox
|
|
59
|
+
checked={column.getFilterValue() === 'true'}
|
|
60
|
+
indeterminate={column.getFilterValue() === undefined}
|
|
61
|
+
color={
|
|
62
|
+
column.getFilterValue() === undefined ? 'default' : 'primary'
|
|
63
|
+
}
|
|
64
|
+
size={density === 'compact' ? 'small' : 'medium'}
|
|
65
|
+
{...checkboxProps}
|
|
66
|
+
onClick={(e) => {
|
|
67
|
+
e.stopPropagation();
|
|
68
|
+
checkboxProps?.onClick?.(e);
|
|
69
|
+
}}
|
|
70
|
+
onChange={(e, checked) => {
|
|
71
|
+
column.setFilterValue(
|
|
72
|
+
column.getFilterValue() === undefined
|
|
73
|
+
? 'true'
|
|
74
|
+
: column.getFilterValue() === 'true'
|
|
75
|
+
? 'false'
|
|
76
|
+
: undefined,
|
|
77
|
+
);
|
|
78
|
+
checkboxProps?.onChange?.(e, checked);
|
|
79
|
+
}}
|
|
80
|
+
sx={(theme) => ({
|
|
81
|
+
height: '2.5rem',
|
|
82
|
+
width: '2.5rem',
|
|
83
|
+
...(checkboxProps?.sx instanceof Function
|
|
84
|
+
? checkboxProps.sx(theme)
|
|
85
|
+
: (checkboxProps?.sx as any)),
|
|
86
|
+
})}
|
|
87
|
+
/>
|
|
88
|
+
}
|
|
89
|
+
disableTypography
|
|
90
|
+
label={checkboxProps.title ?? filterLabel}
|
|
91
|
+
sx={{ color: 'text.secondary', mt: '-4px', fontWeight: 'normal' }}
|
|
92
|
+
title={undefined}
|
|
93
|
+
/>
|
|
94
|
+
</Tooltip>
|
|
95
|
+
);
|
|
96
|
+
};
|
|
@@ -118,10 +118,12 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
118
118
|
(event: ChangeEvent<HTMLInputElement>) => {
|
|
119
119
|
let value =
|
|
120
120
|
textFieldProps.type === 'date'
|
|
121
|
-
?
|
|
121
|
+
? event.target.valueAsDate
|
|
122
|
+
: textFieldProps.type === 'number'
|
|
123
|
+
? event.target.valueAsNumber
|
|
122
124
|
: event.target.value;
|
|
123
125
|
if (isRangeFilter) {
|
|
124
|
-
column.setFilterValue((old:
|
|
126
|
+
column.setFilterValue((old: Array<string | Date | number | null>) => {
|
|
125
127
|
const newFilterValues = old ?? ['', ''];
|
|
126
128
|
newFilterValues[rangeFilterIndex as number] = value;
|
|
127
129
|
return newFilterValues;
|
|
@@ -171,11 +173,15 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
171
173
|
};
|
|
172
174
|
|
|
173
175
|
useEffect(() => {
|
|
174
|
-
|
|
175
|
-
|
|
176
|
+
if (column.getFilterValue() === undefined) {
|
|
177
|
+
handleClear();
|
|
178
|
+
}
|
|
179
|
+
}, [column.getFilterValue()]);
|
|
176
180
|
|
|
177
181
|
if (columnDef.Filter) {
|
|
178
|
-
return
|
|
182
|
+
return (
|
|
183
|
+
<>{columnDef.Filter?.({ column, header, rangeFilterIndex, table })}</>
|
|
184
|
+
);
|
|
179
185
|
}
|
|
180
186
|
|
|
181
187
|
return (
|
|
@@ -208,7 +214,7 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
208
214
|
}
|
|
209
215
|
FormHelperTextProps={{
|
|
210
216
|
sx: {
|
|
211
|
-
fontSize: '0.
|
|
217
|
+
fontSize: '0.75rem',
|
|
212
218
|
lineHeight: '0.8rem',
|
|
213
219
|
whiteSpace: 'nowrap',
|
|
214
220
|
},
|
|
@@ -313,14 +319,13 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
313
319
|
}}
|
|
314
320
|
sx={(theme) => ({
|
|
315
321
|
p: 0,
|
|
316
|
-
minWidth:
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
: 'auto',
|
|
322
|
+
minWidth: isRangeFilter
|
|
323
|
+
? '100px'
|
|
324
|
+
: !filterChipLabel
|
|
325
|
+
? '120px'
|
|
326
|
+
: 'auto',
|
|
322
327
|
width: '100%',
|
|
323
|
-
'&
|
|
328
|
+
'& .MuiSelect-icon': {
|
|
324
329
|
mr: '1.5rem',
|
|
325
330
|
},
|
|
326
331
|
...(textFieldProps?.sx instanceof Function
|
|
@@ -374,6 +379,7 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
374
379
|
header={header}
|
|
375
380
|
setAnchorEl={setAnchorEl}
|
|
376
381
|
table={table}
|
|
382
|
+
setFilterValue={setFilterValue}
|
|
377
383
|
/>
|
|
378
384
|
</>
|
|
379
385
|
);
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, {
|
|
2
|
+
ChangeEvent,
|
|
3
|
+
MouseEvent,
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react';
|
|
2
8
|
import {
|
|
3
9
|
Collapse,
|
|
4
10
|
debounce,
|
|
@@ -32,6 +38,11 @@ export const MRT_GlobalFilterTextField = <
|
|
|
32
38
|
} = table;
|
|
33
39
|
const { globalFilter, showGlobalFilter } = getState();
|
|
34
40
|
|
|
41
|
+
const textFieldProps =
|
|
42
|
+
muiSearchTextFieldProps instanceof Function
|
|
43
|
+
? muiSearchTextFieldProps({ table })
|
|
44
|
+
: muiSearchTextFieldProps;
|
|
45
|
+
|
|
35
46
|
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
|
|
36
47
|
const [searchValue, setSearchValue] = useState(globalFilter ?? '');
|
|
37
48
|
|
|
@@ -56,10 +67,11 @@ export const MRT_GlobalFilterTextField = <
|
|
|
56
67
|
setGlobalFilter(undefined);
|
|
57
68
|
};
|
|
58
69
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (globalFilter === undefined) {
|
|
72
|
+
handleClear();
|
|
73
|
+
}
|
|
74
|
+
}, [globalFilter]);
|
|
63
75
|
|
|
64
76
|
return (
|
|
65
77
|
<Collapse
|
|
@@ -119,6 +131,7 @@ export const MRT_GlobalFilterTextField = <
|
|
|
119
131
|
anchorEl={anchorEl}
|
|
120
132
|
setAnchorEl={setAnchorEl}
|
|
121
133
|
table={table}
|
|
134
|
+
onSelect={handleClear}
|
|
122
135
|
/>
|
|
123
136
|
</Collapse>
|
|
124
137
|
);
|
|
@@ -42,10 +42,19 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll, table }) => {
|
|
|
42
42
|
>
|
|
43
43
|
<Checkbox
|
|
44
44
|
checked={
|
|
45
|
-
selectAll
|
|
45
|
+
selectAll
|
|
46
|
+
? selectAllMode === 'page'
|
|
47
|
+
? table.getIsAllPageRowsSelected()
|
|
48
|
+
: table.getIsAllRowsSelected()
|
|
49
|
+
: row?.getIsSelected()
|
|
46
50
|
}
|
|
47
51
|
indeterminate={
|
|
48
|
-
selectAll
|
|
52
|
+
selectAll
|
|
53
|
+
? table.getIsSomeRowsSelected() &&
|
|
54
|
+
!(selectAllMode === 'page'
|
|
55
|
+
? table.getIsAllPageRowsSelected()
|
|
56
|
+
: table.getIsAllRowsSelected())
|
|
57
|
+
: row?.getIsSomeSelected()
|
|
49
58
|
}
|
|
50
59
|
inputProps={{
|
|
51
60
|
'aria-label': selectAll
|
|
@@ -53,11 +62,11 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll, table }) => {
|
|
|
53
62
|
: localization.toggleSelectRow,
|
|
54
63
|
}}
|
|
55
64
|
onChange={
|
|
56
|
-
|
|
57
|
-
?
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
:
|
|
65
|
+
row
|
|
66
|
+
? row.getToggleSelectedHandler()
|
|
67
|
+
: selectAllMode === 'all'
|
|
68
|
+
? table.getToggleAllRowsSelectedHandler()
|
|
69
|
+
: table.getToggleAllPageRowsSelectedHandler()
|
|
61
70
|
}
|
|
62
71
|
size={density === 'compact' ? 'small' : 'medium'}
|
|
63
72
|
{...checkboxProps}
|
|
@@ -4,9 +4,9 @@ import type {
|
|
|
4
4
|
MRT_FilterOption,
|
|
5
5
|
MRT_Header,
|
|
6
6
|
MRT_InternalFilterOption,
|
|
7
|
+
MRT_Localization,
|
|
7
8
|
MRT_TableInstance,
|
|
8
9
|
} from '..';
|
|
9
|
-
import { MRT_Localization } from '../localization';
|
|
10
10
|
|
|
11
11
|
export const mrtFilterOptions = (
|
|
12
12
|
localization: MRT_Localization,
|
|
@@ -102,6 +102,7 @@ interface Props<TData extends Record<string, any> = {}> {
|
|
|
102
102
|
header?: MRT_Header<TData>;
|
|
103
103
|
onSelect?: () => void;
|
|
104
104
|
setAnchorEl: (anchorEl: HTMLElement | null) => void;
|
|
105
|
+
setFilterValue?: (filterValue: any) => void;
|
|
105
106
|
table: MRT_TableInstance<TData>;
|
|
106
107
|
}
|
|
107
108
|
|
|
@@ -110,6 +111,7 @@ export const MRT_FilterOptionMenu = <TData extends Record<string, any> = {}>({
|
|
|
110
111
|
header,
|
|
111
112
|
onSelect,
|
|
112
113
|
setAnchorEl,
|
|
114
|
+
setFilterValue,
|
|
113
115
|
table,
|
|
114
116
|
}: Props<TData>) => {
|
|
115
117
|
const {
|
|
@@ -152,10 +154,25 @@ export const MRT_FilterOptionMenu = <TData extends Record<string, any> = {}>({
|
|
|
152
154
|
}));
|
|
153
155
|
if (['empty', 'notEmpty'].includes(option as string)) {
|
|
154
156
|
column.setFilterValue(' ');
|
|
155
|
-
} else if (
|
|
157
|
+
} else if (
|
|
158
|
+
columnDef?.filterVariant === 'multi-select' ||
|
|
159
|
+
['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'].includes(
|
|
160
|
+
option as string,
|
|
161
|
+
)
|
|
162
|
+
) {
|
|
163
|
+
column.setFilterValue([]);
|
|
164
|
+
setFilterValue?.([]);
|
|
165
|
+
} else if (
|
|
166
|
+
columnDef?.filterVariant === 'range' ||
|
|
167
|
+
['between', 'betweenInclusive', 'inNumberRange'].includes(
|
|
168
|
+
option as MRT_FilterOption,
|
|
169
|
+
)
|
|
170
|
+
) {
|
|
156
171
|
column.setFilterValue(['', '']);
|
|
172
|
+
setFilterValue?.('');
|
|
157
173
|
} else {
|
|
158
174
|
column.setFilterValue('');
|
|
175
|
+
setFilterValue?.('');
|
|
159
176
|
}
|
|
160
177
|
} else {
|
|
161
178
|
setGlobalFilterFn(option);
|
|
@@ -12,7 +12,13 @@ interface Props {
|
|
|
12
12
|
export const MRT_TablePaper: FC<Props> = ({ table }) => {
|
|
13
13
|
const {
|
|
14
14
|
getState,
|
|
15
|
-
options: {
|
|
15
|
+
options: {
|
|
16
|
+
enableBottomToolbar,
|
|
17
|
+
enableTopToolbar,
|
|
18
|
+
muiTablePaperProps,
|
|
19
|
+
renderBottomToolbar,
|
|
20
|
+
renderTopToolbar,
|
|
21
|
+
},
|
|
16
22
|
refs: { tablePaperRef },
|
|
17
23
|
} = table;
|
|
18
24
|
const { isFullScreen } = getState();
|
|
@@ -34,7 +40,7 @@ export const MRT_TablePaper: FC<Props> = ({ table }) => {
|
|
|
34
40
|
}
|
|
35
41
|
}}
|
|
36
42
|
sx={(theme) => ({
|
|
37
|
-
transition: 'all 0.
|
|
43
|
+
transition: 'all 0.1s ease-in-out',
|
|
38
44
|
...(tablePaperProps?.sx instanceof Function
|
|
39
45
|
? tablePaperProps?.sx(theme)
|
|
40
46
|
: (tablePaperProps?.sx as any)),
|
|
@@ -53,9 +59,15 @@ export const MRT_TablePaper: FC<Props> = ({ table }) => {
|
|
|
53
59
|
: {}),
|
|
54
60
|
}}
|
|
55
61
|
>
|
|
56
|
-
{enableTopToolbar &&
|
|
62
|
+
{enableTopToolbar &&
|
|
63
|
+
(renderTopToolbar instanceof Function
|
|
64
|
+
? renderTopToolbar({ table })
|
|
65
|
+
: renderTopToolbar ?? <MRT_TopToolbar table={table} />)}
|
|
57
66
|
<MRT_TableContainer table={table} />
|
|
58
|
-
{enableBottomToolbar &&
|
|
67
|
+
{enableBottomToolbar &&
|
|
68
|
+
(renderBottomToolbar instanceof Function
|
|
69
|
+
? renderBottomToolbar({ table })
|
|
70
|
+
: renderBottomToolbar ?? <MRT_BottomToolbar table={table} />)}
|
|
59
71
|
</Paper>
|
|
60
72
|
);
|
|
61
73
|
};
|