material-react-table 1.0.0-beta.9 → 1.0.0-rc.0
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 +1 -1
- package/dist/cjs/MaterialReactTable.d.ts +110 -11
- 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 +188 -63
- 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 +1 -2
- 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 +110 -11
- 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 +188 -65
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/menus/MRT_FilterOptionMenu.d.ts +1 -2
- 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 +59 -32
- 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 -77
- 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_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 +21 -11
- package/src/inputs/MRT_GlobalFilterTextField.tsx +17 -5
- package/src/inputs/MRT_SelectCheckbox.tsx +16 -7
- package/src/menus/MRT_FilterOptionMenu.tsx +1 -1
- package/src/table/MRT_TablePaper.tsx +9 -7
- 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,
|
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
|
+
};
|
|
@@ -3,6 +3,7 @@ import React, {
|
|
|
3
3
|
FC,
|
|
4
4
|
MouseEvent,
|
|
5
5
|
useCallback,
|
|
6
|
+
useEffect,
|
|
6
7
|
useState,
|
|
7
8
|
} from 'react';
|
|
8
9
|
import {
|
|
@@ -117,10 +118,12 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
117
118
|
(event: ChangeEvent<HTMLInputElement>) => {
|
|
118
119
|
let value =
|
|
119
120
|
textFieldProps.type === 'date'
|
|
120
|
-
?
|
|
121
|
+
? event.target.valueAsDate
|
|
122
|
+
: textFieldProps.type === 'number'
|
|
123
|
+
? event.target.valueAsNumber
|
|
121
124
|
: event.target.value;
|
|
122
125
|
if (isRangeFilter) {
|
|
123
|
-
column.setFilterValue((old:
|
|
126
|
+
column.setFilterValue((old: Array<string | Date | number | null>) => {
|
|
124
127
|
const newFilterValues = old ?? ['', ''];
|
|
125
128
|
newFilterValues[rangeFilterIndex as number] = value;
|
|
126
129
|
return newFilterValues;
|
|
@@ -169,8 +172,16 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
169
172
|
setAnchorEl(event.currentTarget);
|
|
170
173
|
};
|
|
171
174
|
|
|
175
|
+
useEffect(() => {
|
|
176
|
+
if (column.getFilterValue() === undefined) {
|
|
177
|
+
handleClear();
|
|
178
|
+
}
|
|
179
|
+
}, [column.getFilterValue()]);
|
|
180
|
+
|
|
172
181
|
if (columnDef.Filter) {
|
|
173
|
-
return
|
|
182
|
+
return (
|
|
183
|
+
<>{columnDef.Filter?.({ column, header, rangeFilterIndex, table })}</>
|
|
184
|
+
);
|
|
174
185
|
}
|
|
175
186
|
|
|
176
187
|
return (
|
|
@@ -203,7 +214,7 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
203
214
|
}
|
|
204
215
|
FormHelperTextProps={{
|
|
205
216
|
sx: {
|
|
206
|
-
fontSize: '0.
|
|
217
|
+
fontSize: '0.75rem',
|
|
207
218
|
lineHeight: '0.8rem',
|
|
208
219
|
whiteSpace: 'nowrap',
|
|
209
220
|
},
|
|
@@ -308,14 +319,13 @@ export const MRT_FilterTextField: FC<Props> = ({
|
|
|
308
319
|
}}
|
|
309
320
|
sx={(theme) => ({
|
|
310
321
|
p: 0,
|
|
311
|
-
minWidth:
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
: 'auto',
|
|
322
|
+
minWidth: isRangeFilter
|
|
323
|
+
? '100px'
|
|
324
|
+
: !filterChipLabel
|
|
325
|
+
? '120px'
|
|
326
|
+
: 'auto',
|
|
317
327
|
width: '100%',
|
|
318
|
-
'&
|
|
328
|
+
'& .MuiSelect-icon': {
|
|
319
329
|
mr: '1.5rem',
|
|
320
330
|
},
|
|
321
331
|
...(textFieldProps?.sx instanceof Function
|
|
@@ -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
|
|
@@ -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}
|
|
@@ -40,7 +40,7 @@ export const MRT_TablePaper: FC<Props> = ({ table }) => {
|
|
|
40
40
|
}
|
|
41
41
|
}}
|
|
42
42
|
sx={(theme) => ({
|
|
43
|
-
transition: 'all 0.
|
|
43
|
+
transition: 'all 0.1s ease-in-out',
|
|
44
44
|
...(tablePaperProps?.sx instanceof Function
|
|
45
45
|
? tablePaperProps?.sx(theme)
|
|
46
46
|
: (tablePaperProps?.sx as any)),
|
|
@@ -59,13 +59,15 @@ export const MRT_TablePaper: FC<Props> = ({ table }) => {
|
|
|
59
59
|
: {}),
|
|
60
60
|
}}
|
|
61
61
|
>
|
|
62
|
-
{
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
{enableTopToolbar &&
|
|
63
|
+
(renderTopToolbar instanceof Function
|
|
64
|
+
? renderTopToolbar({ table })
|
|
65
|
+
: renderTopToolbar ?? <MRT_TopToolbar table={table} />)}
|
|
65
66
|
<MRT_TableContainer table={table} />
|
|
66
|
-
{
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
{enableBottomToolbar &&
|
|
68
|
+
(renderBottomToolbar instanceof Function
|
|
69
|
+
? renderBottomToolbar({ table })
|
|
70
|
+
: renderBottomToolbar ?? <MRT_BottomToolbar table={table} />)}
|
|
69
71
|
</Paper>
|
|
70
72
|
);
|
|
71
73
|
};
|
|
@@ -34,11 +34,12 @@ import type {
|
|
|
34
34
|
MRT_TableInstance,
|
|
35
35
|
MRT_TableState,
|
|
36
36
|
MaterialReactTableProps,
|
|
37
|
+
MRT_Localization,
|
|
37
38
|
} from '..';
|
|
38
39
|
import { MRT_EditRowModal } from '../body/MRT_EditRowModal';
|
|
39
40
|
|
|
40
41
|
export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
41
|
-
props: MaterialReactTableProps<TData
|
|
42
|
+
props: MaterialReactTableProps<TData> & { localization: MRT_Localization },
|
|
42
43
|
) => {
|
|
43
44
|
const bottomToolbarRef = useRef<HTMLDivElement>(null);
|
|
44
45
|
const editInputRefs = useRef<Record<string, HTMLInputElement>>({});
|
|
@@ -123,7 +124,7 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
123
124
|
(
|
|
124
125
|
[
|
|
125
126
|
columnOrder.includes('mrt-row-drag') && {
|
|
126
|
-
header: props.localization
|
|
127
|
+
header: props.localization.move,
|
|
127
128
|
size: 60,
|
|
128
129
|
...props.defaultDisplayColumn,
|
|
129
130
|
...props.displayColumnDefOptions?.['mrt-row-drag'],
|
|
@@ -137,7 +138,7 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
137
138
|
table={table as any}
|
|
138
139
|
/>
|
|
139
140
|
),
|
|
140
|
-
header: props.localization
|
|
141
|
+
header: props.localization.actions,
|
|
141
142
|
size: 70,
|
|
142
143
|
...props.defaultDisplayColumn,
|
|
143
144
|
...props.displayColumnDefOptions?.['mrt-row-actions'],
|
|
@@ -152,7 +153,7 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
152
153
|
props.enableExpandAll ? (
|
|
153
154
|
<MRT_ExpandAllButton table={table as any} />
|
|
154
155
|
) : null,
|
|
155
|
-
header: props.localization
|
|
156
|
+
header: props.localization.expand,
|
|
156
157
|
size: 60,
|
|
157
158
|
...props.defaultDisplayColumn,
|
|
158
159
|
...props.displayColumnDefOptions?.['mrt-row-expand'],
|
|
@@ -166,7 +167,7 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
166
167
|
props.enableSelectAll ? (
|
|
167
168
|
<MRT_SelectCheckbox selectAll table={table as any} />
|
|
168
169
|
) : null,
|
|
169
|
-
header: props.localization
|
|
170
|
+
header: props.localization.select,
|
|
170
171
|
size: 60,
|
|
171
172
|
...props.defaultDisplayColumn,
|
|
172
173
|
...props.displayColumnDefOptions?.['mrt-row-select'],
|
|
@@ -174,8 +175,8 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
174
175
|
},
|
|
175
176
|
columnOrder.includes('mrt-row-numbers') && {
|
|
176
177
|
Cell: ({ row }) => row.index + 1,
|
|
177
|
-
Header: () => props.localization
|
|
178
|
-
header: props.localization
|
|
178
|
+
Header: () => props.localization.rowNumber,
|
|
179
|
+
header: props.localization.rowNumbers,
|
|
179
180
|
size: 60,
|
|
180
181
|
...props.defaultDisplayColumn,
|
|
181
182
|
...props.displayColumnDefOptions?.['mrt-row-numbers'],
|
|
@@ -50,7 +50,10 @@ export const MRT_BottomToolbar: FC<Props> = ({ table }) => {
|
|
|
50
50
|
({
|
|
51
51
|
...commonToolbarStyles({ theme }),
|
|
52
52
|
bottom: isFullScreen ? '0' : undefined,
|
|
53
|
-
boxShadow:
|
|
53
|
+
boxShadow: `0 1px 2px -1px ${alpha(
|
|
54
|
+
theme.palette.common.black,
|
|
55
|
+
0.1,
|
|
56
|
+
)} inset`,
|
|
54
57
|
left: 0,
|
|
55
58
|
position: isFullScreen ? 'fixed' : 'relative',
|
|
56
59
|
right: 0,
|