material-react-table 2.0.0-alpha.1 → 2.0.0-alpha.3
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/index.js +2408 -2334
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/MaterialReactTable.d.ts +1 -1
- package/dist/cjs/types/buttons/MRT_GrabHandleButton.d.ts +1 -1
- package/dist/cjs/types/buttons/MRT_RowPinButton.d.ts +2 -2
- package/dist/cjs/types/column.utils.d.ts +6 -6
- package/dist/cjs/types/filterFns.d.ts +14 -14
- package/dist/cjs/types/head/MRT_TableHeadCellFilterLabel.d.ts +1 -1
- package/dist/cjs/types/head/MRT_TableHeadCellSortLabel.d.ts +1 -1
- package/dist/cjs/types/hooks/useMRT_DisplayColumns.d.ts +3 -3
- package/dist/cjs/types/icons.d.ts +1 -1
- package/dist/cjs/types/inputs/MRT_FilterRangeSlider.d.ts +1 -1
- package/dist/cjs/types/locales/np.d.ts +2 -0
- package/dist/cjs/types/menus/MRT_ColumnActionMenu.d.ts +4 -4
- package/dist/cjs/types/menus/MRT_ShowHideColumnsMenuItems.d.ts +1 -1
- package/dist/cjs/types/toolbar/MRT_TablePagination.d.ts +2 -2
- package/dist/cjs/types/toolbar/MRT_TopToolbar.d.ts +1 -1
- package/dist/cjs/types/types.d.ts +217 -197
- package/dist/esm/material-react-table.esm.js +2311 -2239
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/types/MaterialReactTable.d.ts +1 -1
- package/dist/esm/types/buttons/MRT_GrabHandleButton.d.ts +1 -1
- package/dist/esm/types/buttons/MRT_RowPinButton.d.ts +2 -2
- package/dist/esm/types/column.utils.d.ts +6 -6
- package/dist/esm/types/filterFns.d.ts +14 -14
- package/dist/esm/types/head/MRT_TableHeadCellFilterLabel.d.ts +1 -1
- package/dist/esm/types/head/MRT_TableHeadCellSortLabel.d.ts +1 -1
- package/dist/esm/types/hooks/useMRT_DisplayColumns.d.ts +3 -3
- package/dist/esm/types/icons.d.ts +1 -1
- package/dist/esm/types/inputs/MRT_FilterRangeSlider.d.ts +1 -1
- package/dist/esm/types/locales/np.d.ts +2 -0
- package/dist/esm/types/menus/MRT_ColumnActionMenu.d.ts +4 -4
- package/dist/esm/types/menus/MRT_ShowHideColumnsMenuItems.d.ts +1 -1
- package/dist/esm/types/toolbar/MRT_TablePagination.d.ts +2 -2
- package/dist/esm/types/toolbar/MRT_TopToolbar.d.ts +1 -1
- package/dist/esm/types/types.d.ts +217 -197
- package/dist/index.d.ts +258 -238
- package/locales/fr.esm.js +1 -1
- package/locales/fr.esm.js.map +1 -1
- package/locales/fr.js +1 -1
- package/locales/fr.js.map +1 -1
- package/locales/np.d.ts +2 -0
- package/locales/np.esm.d.ts +2 -0
- package/locales/np.esm.js +94 -0
- package/locales/np.esm.js.map +1 -0
- package/locales/np.js +98 -0
- package/locales/np.js.map +1 -0
- package/locales/tr.d.ts +2 -0
- package/locales/tr.esm.d.ts +2 -0
- package/locales/tr.esm.js +93 -0
- package/locales/tr.esm.js.map +1 -0
- package/locales/tr.js +97 -0
- package/locales/tr.js.map +1 -0
- package/locales/uk.d.ts +2 -0
- package/locales/uk.esm.d.ts +2 -0
- package/locales/uk.esm.js +93 -0
- package/locales/uk.esm.js.map +1 -0
- package/locales/uk.js +97 -0
- package/locales/uk.js.map +1 -0
- package/locales/vi.d.ts +2 -0
- package/locales/vi.esm.d.ts +2 -0
- package/locales/vi.esm.js +93 -0
- package/locales/vi.esm.js.map +1 -0
- package/locales/vi.js +97 -0
- package/locales/vi.js.map +1 -0
- package/locales/zh-Hans.d.ts +2 -0
- package/locales/zh-Hans.esm.d.ts +2 -0
- package/locales/zh-Hans.esm.js +93 -0
- package/locales/zh-Hans.esm.js.map +1 -0
- package/locales/zh-Hans.js +97 -0
- package/locales/zh-Hans.js.map +1 -0
- package/locales/zh-Hant.d.ts +2 -0
- package/locales/zh-Hant.esm.d.ts +2 -0
- package/locales/zh-Hant.esm.js +93 -0
- package/locales/zh-Hant.esm.js.map +1 -0
- package/locales/zh-Hant.js +97 -0
- package/locales/zh-Hant.js.map +1 -0
- package/package.json +27 -26
- package/src/MaterialReactTable.tsx +2 -2
- package/src/body/MRT_TableBody.tsx +9 -9
- package/src/body/MRT_TableBodyCell.tsx +22 -22
- package/src/body/MRT_TableBodyCellValue.tsx +5 -5
- package/src/body/MRT_TableBodyRow.tsx +32 -32
- package/src/body/MRT_TableBodyRowGrabHandle.tsx +2 -2
- package/src/body/MRT_TableBodyRowPinButton.tsx +3 -3
- package/src/body/MRT_TableDetailPanel.tsx +3 -3
- package/src/buttons/MRT_CopyButton.tsx +1 -1
- package/src/buttons/MRT_EditActionButtons.tsx +4 -4
- package/src/buttons/MRT_ExpandAllButton.tsx +3 -3
- package/src/buttons/MRT_ExpandButton.tsx +1 -1
- package/src/buttons/MRT_GrabHandleButton.tsx +10 -10
- package/src/buttons/MRT_RowPinButton.tsx +5 -5
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +1 -1
- package/src/buttons/MRT_ToggleFullScreenButton.tsx +2 -2
- package/src/buttons/MRT_ToggleRowActionMenuButton.tsx +8 -8
- package/src/column.utils.ts +24 -22
- package/src/filterFns.ts +29 -29
- package/src/footer/MRT_TableFooter.tsx +9 -9
- package/src/footer/MRT_TableFooterCell.tsx +1 -1
- package/src/footer/MRT_TableFooterRow.tsx +2 -2
- package/src/head/MRT_TableHead.tsx +9 -9
- package/src/head/MRT_TableHeadCell.tsx +10 -6
- package/src/head/MRT_TableHeadCellColumnActionsButton.tsx +9 -6
- package/src/head/MRT_TableHeadCellFilterContainer.tsx +12 -5
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +106 -61
- package/src/head/MRT_TableHeadCellGrabHandle.tsx +2 -2
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +11 -11
- package/src/head/MRT_TableHeadCellSortLabel.tsx +8 -8
- package/src/head/MRT_TableHeadRow.tsx +2 -2
- package/src/hooks/useMRT_DisplayColumns.tsx +5 -5
- package/src/hooks/useMRT_Effects.ts +3 -3
- package/src/hooks/useMRT_TableInstance.ts +15 -14
- package/src/hooks/useMRT_TableOptions.ts +3 -3
- package/src/icons.ts +2 -2
- package/src/inputs/MRT_EditCellTextField.tsx +9 -9
- package/src/inputs/MRT_FilterCheckbox.tsx +7 -7
- package/src/inputs/MRT_FilterRangeFields.tsx +1 -1
- package/src/inputs/MRT_FilterRangeSlider.tsx +6 -6
- package/src/inputs/MRT_FilterTextField.tsx +309 -230
- package/src/inputs/MRT_GlobalFilterTextField.tsx +26 -26
- package/src/inputs/MRT_SelectCheckbox.tsx +7 -7
- package/src/locales/fr.ts +1 -1
- package/src/locales/np.ts +94 -0
- package/src/menus/MRT_ColumnActionMenu.tsx +48 -45
- package/src/menus/MRT_FilterOptionMenu.tsx +36 -36
- package/src/menus/MRT_RowActionMenu.tsx +7 -7
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +6 -6
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +5 -5
- package/src/modals/MRT_EditRowModal.tsx +8 -8
- package/src/sortingFns.ts +1 -1
- package/src/table/MRT_Table.tsx +7 -7
- package/src/table/MRT_TableContainer.tsx +10 -10
- package/src/table/MRT_TablePaper.tsx +9 -9
- package/src/toolbar/MRT_BottomToolbar.tsx +5 -5
- package/src/toolbar/MRT_LinearProgressBar.tsx +4 -4
- package/src/toolbar/MRT_TablePagination.tsx +19 -19
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +4 -4
- package/src/toolbar/MRT_ToolbarDropZone.tsx +6 -6
- package/src/toolbar/MRT_ToolbarInternalButtons.tsx +8 -5
- package/src/toolbar/MRT_TopToolbar.tsx +7 -7
- package/src/types.ts +288 -257
- package/src/useMaterialReactTable.ts +1 -1
@@ -2,6 +2,7 @@ import { type DragEvent, useMemo } from 'react';
|
|
2
2
|
import Box from '@mui/material/Box';
|
3
3
|
import TableCell from '@mui/material/TableCell';
|
4
4
|
import { useTheme } from '@mui/material/styles';
|
5
|
+
import { type Theme } from '@mui/material/styles';
|
5
6
|
import { MRT_TableHeadCellColumnActionsButton } from './MRT_TableHeadCellColumnActionsButton';
|
6
7
|
import { MRT_TableHeadCellFilterContainer } from './MRT_TableHeadCellFilterContainer';
|
7
8
|
import { MRT_TableHeadCellFilterLabel } from './MRT_TableHeadCellFilterLabel';
|
@@ -9,7 +10,6 @@ import { MRT_TableHeadCellGrabHandle } from './MRT_TableHeadCellGrabHandle';
|
|
9
10
|
import { MRT_TableHeadCellResizeHandle } from './MRT_TableHeadCellResizeHandle';
|
10
11
|
import { MRT_TableHeadCellSortLabel } from './MRT_TableHeadCellSortLabel';
|
11
12
|
import { getCommonCellStyles } from '../column.utils';
|
12
|
-
import { type Theme } from '@mui/material/styles';
|
13
13
|
import { parseFromValuesOrFunc } from '../column.utils';
|
14
14
|
import { type MRT_Header, type MRT_TableInstance } from '../types';
|
15
15
|
|
@@ -26,6 +26,7 @@ export const MRT_TableHeadCell = <TData extends Record<string, any>>({
|
|
26
26
|
const {
|
27
27
|
getState,
|
28
28
|
options: {
|
29
|
+
columnFilterDisplayMode,
|
29
30
|
enableColumnActions,
|
30
31
|
enableColumnDragging,
|
31
32
|
enableColumnOrdering,
|
@@ -50,7 +51,10 @@ export const MRT_TableHeadCell = <TData extends Record<string, any>>({
|
|
50
51
|
|
51
52
|
const tableCellProps = {
|
52
53
|
...parseFromValuesOrFunc(muiTableHeadCellProps, { column, table }),
|
53
|
-
...parseFromValuesOrFunc(columnDef.muiTableHeadCellProps, {
|
54
|
+
...parseFromValuesOrFunc(columnDef.muiTableHeadCellProps, {
|
55
|
+
column,
|
56
|
+
table,
|
57
|
+
}),
|
54
58
|
};
|
55
59
|
|
56
60
|
const showColumnActions =
|
@@ -205,14 +209,14 @@ export const MRT_TableHeadCell = <TData extends Record<string, any>>({
|
|
205
209
|
<Box
|
206
210
|
className="Mui-TableHeadCell-Content-Wrapper"
|
207
211
|
sx={{
|
212
|
+
'&:hover': {
|
213
|
+
textOverflow: 'clip',
|
214
|
+
},
|
208
215
|
minWidth: `${Math.min(columnDef.header?.length ?? 0, 5)}ch`,
|
209
216
|
overflow: columnDefType === 'data' ? 'hidden' : undefined,
|
210
217
|
textOverflow: 'ellipsis',
|
211
218
|
whiteSpace:
|
212
219
|
(columnDef.header?.length ?? 0) < 20 ? 'nowrap' : 'normal',
|
213
|
-
'&:hover': {
|
214
|
-
textOverflow: 'clip',
|
215
|
-
},
|
216
220
|
}}
|
217
221
|
title={columnDefType === 'data' ? columnDef.header : undefined}
|
218
222
|
>
|
@@ -256,7 +260,7 @@ export const MRT_TableHeadCell = <TData extends Record<string, any>>({
|
|
256
260
|
)}
|
257
261
|
</Box>
|
258
262
|
)}
|
259
|
-
{column.getCanFilter() && (
|
263
|
+
{columnFilterDisplayMode === 'subheader' && column.getCanFilter() && (
|
260
264
|
<MRT_TableHeadCellFilterContainer header={header} table={table} />
|
261
265
|
)}
|
262
266
|
</TableCell>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { type MouseEvent, useState } from 'react';
|
2
2
|
import IconButton from '@mui/material/IconButton';
|
3
3
|
import Tooltip from '@mui/material/Tooltip';
|
4
|
-
import { MRT_ColumnActionMenu } from '../menus/MRT_ColumnActionMenu';
|
5
4
|
import { parseFromValuesOrFunc } from '../column.utils';
|
5
|
+
import { MRT_ColumnActionMenu } from '../menus/MRT_ColumnActionMenu';
|
6
6
|
import { type MRT_Header, type MRT_TableInstance } from '../types';
|
7
7
|
|
8
8
|
interface Props<TData extends Record<string, any>> {
|
@@ -18,6 +18,7 @@ export const MRT_TableHeadCellColumnActionsButton = <
|
|
18
18
|
}: Props<TData>) => {
|
19
19
|
const {
|
20
20
|
options: {
|
21
|
+
columnFilterDisplayMode,
|
21
22
|
icons: { MoreVertIcon },
|
22
23
|
localization,
|
23
24
|
muiColumnActionsButtonProps,
|
@@ -26,7 +27,7 @@ export const MRT_TableHeadCellColumnActionsButton = <
|
|
26
27
|
const { column } = header;
|
27
28
|
const { columnDef } = column;
|
28
29
|
|
29
|
-
const [anchorEl, setAnchorEl] = useState<
|
30
|
+
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
|
30
31
|
|
31
32
|
const handleClick = (event: MouseEvent<HTMLElement>) => {
|
32
33
|
event.stopPropagation();
|
@@ -60,15 +61,17 @@ export const MRT_TableHeadCellColumnActionsButton = <
|
|
60
61
|
size="small"
|
61
62
|
{...iconButtonProps}
|
62
63
|
sx={(theme) => ({
|
64
|
+
'&:hover': {
|
65
|
+
opacity: 1,
|
66
|
+
},
|
63
67
|
height: '2rem',
|
64
68
|
m: '-8px -4px',
|
65
69
|
opacity: 0.5,
|
66
|
-
transform:
|
70
|
+
transform: `scale(0.85) ${
|
71
|
+
columnFilterDisplayMode !== 'popover' ? 'translateX(-4px)' : ''
|
72
|
+
}`,
|
67
73
|
transition: 'opacity 150ms',
|
68
74
|
width: '2rem',
|
69
|
-
'&:hover': {
|
70
|
-
opacity: 1,
|
71
|
-
},
|
72
75
|
...(parseFromValuesOrFunc(iconButtonProps?.sx, theme) as any),
|
73
76
|
})}
|
74
77
|
title={undefined}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import Collapse from '@mui/material/Collapse';
|
2
|
-
import { MRT_FilterRangeFields } from '../inputs/MRT_FilterRangeFields';
|
3
|
-
import { MRT_FilterTextField } from '../inputs/MRT_FilterTextField';
|
4
2
|
import { MRT_FilterCheckbox } from '../inputs/MRT_FilterCheckbox';
|
3
|
+
import { MRT_FilterRangeFields } from '../inputs/MRT_FilterRangeFields';
|
5
4
|
import { MRT_FilterRangeSlider } from '../inputs/MRT_FilterRangeSlider';
|
5
|
+
import { MRT_FilterTextField } from '../inputs/MRT_FilterTextField';
|
6
6
|
import { type MRT_Header, type MRT_TableInstance } from '../types';
|
7
7
|
|
8
8
|
interface Props<TData extends Record<string, any>> {
|
@@ -16,18 +16,25 @@ export const MRT_TableHeadCellFilterContainer = <
|
|
16
16
|
header,
|
17
17
|
table,
|
18
18
|
}: Props<TData>) => {
|
19
|
-
const {
|
19
|
+
const {
|
20
|
+
getState,
|
21
|
+
options: { columnFilterDisplayMode },
|
22
|
+
} = table;
|
20
23
|
const { showColumnFilters } = getState();
|
21
24
|
const { column } = header;
|
22
25
|
const { columnDef } = column;
|
23
26
|
|
24
27
|
return (
|
25
|
-
<Collapse
|
28
|
+
<Collapse
|
29
|
+
in={showColumnFilters || columnFilterDisplayMode === 'popover'}
|
30
|
+
mountOnEnter
|
31
|
+
unmountOnExit
|
32
|
+
>
|
26
33
|
{columnDef.filterVariant === 'checkbox' ? (
|
27
34
|
<MRT_FilterCheckbox column={column} table={table} />
|
28
35
|
) : columnDef.filterVariant === 'range-slider' ? (
|
29
36
|
<MRT_FilterRangeSlider header={header} table={table} />
|
30
|
-
) : columnDef.filterVariant
|
37
|
+
) : columnDef.filterVariant?.includes('range') ||
|
31
38
|
['between', 'betweenInclusive', 'inNumberRange'].includes(
|
32
39
|
columnDef._filterFn,
|
33
40
|
) ? (
|
@@ -1,8 +1,10 @@
|
|
1
|
-
import { type MouseEvent } from 'react';
|
1
|
+
import { type MouseEvent, useState } from 'react';
|
2
2
|
import Box from '@mui/material/Box';
|
3
3
|
import Grow from '@mui/material/Grow';
|
4
4
|
import IconButton from '@mui/material/IconButton';
|
5
|
+
import Popover from '@mui/material/Popover';
|
5
6
|
import Tooltip from '@mui/material/Tooltip';
|
7
|
+
import { MRT_TableHeadCellFilterContainer } from './MRT_TableHeadCellFilterContainer';
|
6
8
|
import { type MRT_Header, type MRT_TableInstance } from '../types';
|
7
9
|
|
8
10
|
interface Props<TData extends Record<string, any>> {
|
@@ -11,13 +13,14 @@ interface Props<TData extends Record<string, any>> {
|
|
11
13
|
}
|
12
14
|
|
13
15
|
export const MRT_TableHeadCellFilterLabel = <
|
14
|
-
TData extends Record<string, any
|
16
|
+
TData extends Record<string, any> = {},
|
15
17
|
>({
|
16
18
|
header,
|
17
19
|
table,
|
18
20
|
}: Props<TData>) => {
|
19
21
|
const {
|
20
22
|
options: {
|
23
|
+
columnFilterDisplayMode,
|
21
24
|
icons: { FilterAltIcon },
|
22
25
|
localization,
|
23
26
|
},
|
@@ -27,71 +30,113 @@ export const MRT_TableHeadCellFilterLabel = <
|
|
27
30
|
const { column } = header;
|
28
31
|
const { columnDef } = column;
|
29
32
|
|
33
|
+
const filterValue = column.getFilterValue();
|
34
|
+
|
35
|
+
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
|
36
|
+
|
37
|
+
const isFilterActive =
|
38
|
+
(Array.isArray(filterValue) && filterValue.some(Boolean)) ||
|
39
|
+
(!!filterValue && !Array.isArray(filterValue));
|
40
|
+
|
30
41
|
const isRangeFilter =
|
31
|
-
|
42
|
+
columnDef.filterVariant?.includes('range') ||
|
32
43
|
['between', 'betweenInclusive', 'inNumberRange'].includes(
|
33
44
|
columnDef._filterFn,
|
34
45
|
);
|
35
46
|
const currentFilterOption = columnDef._filterFn;
|
36
|
-
const filterTooltip =
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
47
|
+
const filterTooltip =
|
48
|
+
columnFilterDisplayMode === 'popover' && !isFilterActive
|
49
|
+
? localization.filterByColumn?.replace(
|
50
|
+
'{column}',
|
51
|
+
String(columnDef.header),
|
52
|
+
)
|
53
|
+
: localization.filteringByColumn
|
54
|
+
.replace('{column}', String(columnDef.header))
|
55
|
+
.replace(
|
56
|
+
'{filterType}',
|
57
|
+
currentFilterOption
|
58
|
+
? // @ts-ignore
|
59
|
+
localization[
|
60
|
+
`filter${
|
61
|
+
currentFilterOption?.charAt(0)?.toUpperCase() +
|
62
|
+
currentFilterOption?.slice(1)
|
63
|
+
}`
|
64
|
+
]
|
65
|
+
: '',
|
66
|
+
)
|
67
|
+
.replace(
|
68
|
+
'{filterValue}',
|
69
|
+
`"${
|
70
|
+
Array.isArray(filterValue)
|
71
|
+
? (filterValue as [string, string]).join(
|
72
|
+
`" ${isRangeFilter ? localization.and : localization.or} "`,
|
73
|
+
)
|
74
|
+
: (filterValue as string)
|
75
|
+
}"`,
|
76
|
+
)
|
77
|
+
.replace('" "', '');
|
59
78
|
|
60
79
|
return (
|
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
|
-
|
80
|
+
<>
|
81
|
+
<Grow
|
82
|
+
in={
|
83
|
+
columnFilterDisplayMode === 'popover' ||
|
84
|
+
(!!filterValue && !isRangeFilter) ||
|
85
|
+
(isRangeFilter && // @ts-ignore
|
86
|
+
(!!filterValue?.[0] || !!filterValue?.[1]))
|
87
|
+
}
|
88
|
+
unmountOnExit
|
89
|
+
>
|
90
|
+
<Box component="span" sx={{ flex: '0 0' }}>
|
91
|
+
<Tooltip arrow placement="top" title={filterTooltip}>
|
92
|
+
<IconButton
|
93
|
+
disableRipple
|
94
|
+
onClick={(event: MouseEvent<HTMLButtonElement>) => {
|
95
|
+
if (columnFilterDisplayMode === 'popover') {
|
96
|
+
setAnchorEl(event.currentTarget);
|
97
|
+
} else {
|
98
|
+
setShowColumnFilters(true);
|
99
|
+
}
|
100
|
+
queueMicrotask(() => {
|
101
|
+
filterInputRefs.current[`${column.id}-0`]?.focus();
|
102
|
+
filterInputRefs.current[`${column.id}-0`]?.select();
|
103
|
+
});
|
104
|
+
event.stopPropagation();
|
105
|
+
}}
|
106
|
+
sx={{
|
107
|
+
height: '16px',
|
108
|
+
opacity: 0.8,
|
109
|
+
p: '8px',
|
110
|
+
transform: 'scale(0.75)',
|
111
|
+
width: '16px',
|
112
|
+
}}
|
113
|
+
>
|
114
|
+
<FilterAltIcon />
|
115
|
+
</IconButton>
|
116
|
+
</Tooltip>
|
117
|
+
</Box>
|
118
|
+
</Grow>
|
119
|
+
<Popover
|
120
|
+
anchorEl={anchorEl}
|
121
|
+
anchorOrigin={{
|
122
|
+
horizontal: 'center',
|
123
|
+
vertical: 'top',
|
124
|
+
}}
|
125
|
+
onClose={(event) => {
|
126
|
+
//@ts-ignore
|
127
|
+
event.stopPropagation();
|
128
|
+
setAnchorEl(null);
|
129
|
+
}}
|
130
|
+
open={!!anchorEl}
|
131
|
+
transformOrigin={{
|
132
|
+
horizontal: 'center',
|
133
|
+
vertical: 'bottom',
|
134
|
+
}}
|
135
|
+
>
|
136
|
+
<Box sx={{ p: '1rem' }}>
|
137
|
+
<MRT_TableHeadCellFilterContainer header={header} table={table} />
|
138
|
+
</Box>
|
139
|
+
</Popover>
|
140
|
+
</>
|
96
141
|
);
|
97
142
|
};
|
@@ -22,7 +22,7 @@ export const MRT_TableHeadCellGrabHandle = <TData extends Record<string, any>>({
|
|
22
22
|
setHoveredColumn,
|
23
23
|
} = table;
|
24
24
|
const { columnDef } = column;
|
25
|
-
const {
|
25
|
+
const { columnOrder, draggingColumn, hoveredColumn } = getState();
|
26
26
|
|
27
27
|
const iconButtonProps = {
|
28
28
|
...parseFromValuesOrFunc(muiColumnDragHandleProps, { column, table }),
|
@@ -62,8 +62,8 @@ export const MRT_TableHeadCellGrabHandle = <TData extends Record<string, any>>({
|
|
62
62
|
return (
|
63
63
|
<MRT_GrabHandleButton
|
64
64
|
iconButtonProps={iconButtonProps}
|
65
|
-
onDragStart={handleDragStart}
|
66
65
|
onDragEnd={handleDragEnd}
|
66
|
+
onDragStart={handleDragStart}
|
67
67
|
table={table}
|
68
68
|
/>
|
69
69
|
);
|
@@ -33,23 +33,23 @@ export const MRT_TableHeadCellResizeHandle = <
|
|
33
33
|
}}
|
34
34
|
onMouseDown={header.getResizeHandler()}
|
35
35
|
onTouchStart={header.getResizeHandler()}
|
36
|
-
sx={(theme) => ({
|
37
|
-
cursor: 'col-resize',
|
38
|
-
mr: density === 'compact' ? '-0.75rem' : '-1rem',
|
39
|
-
position: 'absolute',
|
40
|
-
right: '4px',
|
41
|
-
px: '4px',
|
42
|
-
'&:active > hr': {
|
43
|
-
backgroundColor: theme.palette.info.main,
|
44
|
-
opacity: 1,
|
45
|
-
},
|
46
|
-
})}
|
47
36
|
style={{
|
48
37
|
transform:
|
49
38
|
column.getIsResizing() && columnResizeMode === 'onEnd'
|
50
39
|
? `translateX(${getState().columnSizingInfo.deltaOffset ?? 0}px)`
|
51
40
|
: undefined,
|
52
41
|
}}
|
42
|
+
sx={(theme) => ({
|
43
|
+
'&:active > hr': {
|
44
|
+
backgroundColor: theme.palette.info.main,
|
45
|
+
opacity: 1,
|
46
|
+
},
|
47
|
+
cursor: 'col-resize',
|
48
|
+
mr: density === 'compact' ? '-0.75rem' : '-1rem',
|
49
|
+
position: 'absolute',
|
50
|
+
px: '4px',
|
51
|
+
right: '4px',
|
52
|
+
})}
|
53
53
|
>
|
54
54
|
<Divider
|
55
55
|
className="Mui-TableHeadCell-ResizeHandle-Divider"
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import Badge from '@mui/material/Badge';
|
2
|
+
import { type TableCellProps } from '@mui/material/TableCell';
|
2
3
|
import TableSortLabel from '@mui/material/TableSortLabel';
|
3
4
|
import Tooltip from '@mui/material/Tooltip';
|
4
5
|
import { type MRT_Header, type MRT_TableInstance } from '../types';
|
5
|
-
import { type TableCellProps } from '@mui/material/TableCell';
|
6
6
|
|
7
7
|
interface Props<TData extends Record<string, any>> {
|
8
8
|
header: MRT_Header<TData>;
|
@@ -41,25 +41,25 @@ export const MRT_TableHeadCellSortLabel = <TData extends Record<string, any>>({
|
|
41
41
|
overlap="circular"
|
42
42
|
>
|
43
43
|
<TableSortLabel
|
44
|
-
|
44
|
+
IconComponent={ArrowDownwardIcon}
|
45
45
|
active={!!column.getIsSorted()}
|
46
|
+
aria-label={sortTooltip}
|
46
47
|
direction={
|
47
48
|
column.getIsSorted()
|
48
49
|
? (column.getIsSorted() as 'asc' | 'desc')
|
49
50
|
: undefined
|
50
51
|
}
|
52
|
+
onClick={(e) => {
|
53
|
+
e.stopPropagation();
|
54
|
+
header.column.getToggleSortingHandler()?.(e);
|
55
|
+
}}
|
51
56
|
sx={{
|
52
57
|
flex: '0 0',
|
53
|
-
width: '2.4ch',
|
54
58
|
transform:
|
55
59
|
tableCellProps?.align !== 'right'
|
56
60
|
? 'translateX(-0.5ch)'
|
57
61
|
: undefined,
|
58
|
-
|
59
|
-
IconComponent={ArrowDownwardIcon}
|
60
|
-
onClick={(e) => {
|
61
|
-
e.stopPropagation();
|
62
|
-
header.column.getToggleSortingHandler()?.(e);
|
62
|
+
width: '2.4ch',
|
63
63
|
}}
|
64
64
|
/>
|
65
65
|
</Badge>
|
@@ -1,13 +1,13 @@
|
|
1
|
+
import { type VirtualItem } from '@tanstack/react-virtual';
|
1
2
|
import TableRow from '@mui/material/TableRow';
|
2
3
|
import { alpha, lighten } from '@mui/material/styles';
|
3
4
|
import { MRT_TableHeadCell } from './MRT_TableHeadCell';
|
4
|
-
import {
|
5
|
+
import { parseFromValuesOrFunc } from '../column.utils';
|
5
6
|
import {
|
6
7
|
type MRT_Header,
|
7
8
|
type MRT_HeaderGroup,
|
8
9
|
type MRT_TableInstance,
|
9
10
|
} from '../types';
|
10
|
-
import { parseFromValuesOrFunc } from '../column.utils';
|
11
11
|
|
12
12
|
interface Props<TData extends Record<string, any>> {
|
13
13
|
headerGroup: MRT_HeaderGroup<TData>;
|
@@ -1,29 +1,29 @@
|
|
1
1
|
import { type RefObject, useMemo } from 'react';
|
2
|
-
import { showExpandColumn } from '../column.utils';
|
3
|
-
import { MRT_TableBodyRowPinButton } from '../body/MRT_TableBodyRowPinButton';
|
4
2
|
import { MRT_TableBodyRowGrabHandle } from '../body';
|
3
|
+
import { MRT_TableBodyRowPinButton } from '../body/MRT_TableBodyRowPinButton';
|
5
4
|
import { MRT_ExpandAllButton } from '../buttons/MRT_ExpandAllButton';
|
6
5
|
import { MRT_ExpandButton } from '../buttons/MRT_ExpandButton';
|
7
6
|
import { MRT_ToggleRowActionMenuButton } from '../buttons/MRT_ToggleRowActionMenuButton';
|
7
|
+
import { showExpandColumn } from '../column.utils';
|
8
8
|
import { MRT_SelectCheckbox } from '../inputs/MRT_SelectCheckbox';
|
9
9
|
import {
|
10
10
|
type MRT_ColumnDef,
|
11
11
|
type MRT_ColumnOrderState,
|
12
|
-
type MRT_GroupingState,
|
13
12
|
type MRT_DefinedTableOptions,
|
13
|
+
type MRT_GroupingState,
|
14
14
|
type MRT_Row,
|
15
15
|
} from '../types';
|
16
16
|
|
17
17
|
interface Params<TData extends Record<string, any>> {
|
18
|
-
creatingRow: MRT_Row<TData> | null;
|
19
18
|
columnOrder: MRT_ColumnOrderState;
|
19
|
+
creatingRow: MRT_Row<TData> | null;
|
20
20
|
grouping: MRT_GroupingState;
|
21
21
|
tableOptions: MRT_DefinedTableOptions<TData>;
|
22
22
|
}
|
23
23
|
|
24
24
|
export const useMRT_DisplayColumns = <TData extends Record<string, any>>({
|
25
|
-
creatingRow,
|
26
25
|
columnOrder,
|
26
|
+
creatingRow,
|
27
27
|
grouping,
|
28
28
|
tableOptions,
|
29
29
|
}: Params<TData>) => {
|
@@ -12,10 +12,10 @@ export const useMRT_Effects = <TData extends Record<string, any> = {}>(
|
|
12
12
|
const {
|
13
13
|
globalFilter,
|
14
14
|
isFullScreen,
|
15
|
-
pagination,
|
16
|
-
sorting,
|
17
15
|
isLoading,
|
16
|
+
pagination,
|
18
17
|
showSkeletons,
|
18
|
+
sorting,
|
19
19
|
} = getState();
|
20
20
|
|
21
21
|
const isMounted = useRef(false);
|
@@ -38,8 +38,8 @@ export const useMRT_Effects = <TData extends Record<string, any> = {}>(
|
|
38
38
|
if (!previousTop.current) return;
|
39
39
|
//restore scroll position
|
40
40
|
window.scrollTo({
|
41
|
-
top: -1 * (previousTop.current as number),
|
42
41
|
behavior: 'instant',
|
42
|
+
top: -1 * (previousTop.current as number),
|
43
43
|
});
|
44
44
|
}
|
45
45
|
}
|
@@ -19,16 +19,14 @@ import {
|
|
19
19
|
getDefaultColumnOrderIds,
|
20
20
|
prepareColumns,
|
21
21
|
} from '../column.utils';
|
22
|
-
import { useMRT_DisplayColumns } from './useMRT_DisplayColumns';
|
23
|
-
import { useMRT_Effects } from './useMRT_Effects';
|
24
22
|
import {
|
25
23
|
type MRT_Cell,
|
26
24
|
type MRT_Column,
|
27
25
|
type MRT_ColumnDef,
|
26
|
+
type MRT_ColumnFilterFnsState,
|
28
27
|
type MRT_ColumnOrderState,
|
29
28
|
type MRT_DefinedTableOptions,
|
30
29
|
type MRT_DensityState,
|
31
|
-
type MRT_ColumnFilterFnsState,
|
32
30
|
type MRT_FilterOption,
|
33
31
|
type MRT_GroupingState,
|
34
32
|
type MRT_Row,
|
@@ -36,6 +34,8 @@ import {
|
|
36
34
|
type MRT_TableState,
|
37
35
|
type MRT_Updater,
|
38
36
|
} from '../types';
|
37
|
+
import { useMRT_DisplayColumns } from './useMRT_DisplayColumns';
|
38
|
+
import { useMRT_Effects } from './useMRT_Effects';
|
39
39
|
|
40
40
|
export const useMRT_TableInstance: <TData extends Record<string, any>>(
|
41
41
|
tableOptions: MRT_DefinedTableOptions<TData>,
|
@@ -104,10 +104,10 @@ export const useMRT_TableInstance: <TData extends Record<string, any>>(
|
|
104
104
|
initialState.grouping ?? [],
|
105
105
|
);
|
106
106
|
const [hoveredColumn, setHoveredColumn] = useState<
|
107
|
-
|
107
|
+
{ id: string } | MRT_Column<TData> | null
|
108
108
|
>(initialState.hoveredColumn ?? null);
|
109
109
|
const [hoveredRow, setHoveredRow] = useState<
|
110
|
-
|
110
|
+
{ id: string } | MRT_Row<TData> | null
|
111
111
|
>(initialState.hoveredRow ?? null);
|
112
112
|
const [isFullScreen, setIsFullScreen] = useState<boolean>(
|
113
113
|
initialState?.isFullScreen ?? false,
|
@@ -207,9 +207,9 @@ export const useMRT_TableInstance: <TData extends Record<string, any>>(
|
|
207
207
|
getSortedRowModel: tableOptions.enableSorting
|
208
208
|
? getSortedRowModel()
|
209
209
|
: undefined,
|
210
|
+
getSubRows: (row) => row?.subRows,
|
210
211
|
onColumnOrderChange: setColumnOrder,
|
211
212
|
onGroupingChange: setGrouping,
|
212
|
-
getSubRows: (row) => row?.subRows,
|
213
213
|
...tableOptions,
|
214
214
|
//@ts-ignore
|
215
215
|
columns: columnDefs,
|
@@ -217,9 +217,9 @@ export const useMRT_TableInstance: <TData extends Record<string, any>>(
|
|
217
217
|
globalFilterFn: tableOptions.filterFns?.[globalFilterFn ?? 'fuzzy'],
|
218
218
|
initialState,
|
219
219
|
state: {
|
220
|
-
creatingRow,
|
221
220
|
columnFilterFns,
|
222
221
|
columnOrder,
|
222
|
+
creatingRow,
|
223
223
|
density,
|
224
224
|
draggingColumn,
|
225
225
|
draggingRow,
|
@@ -248,23 +248,24 @@ export const useMRT_TableInstance: <TData extends Record<string, any>>(
|
|
248
248
|
searchInputRef,
|
249
249
|
// @ts-ignore
|
250
250
|
tableContainerRef,
|
251
|
+
// @ts-ignore
|
252
|
+
tableFooterRef,
|
251
253
|
tableHeadCellRefs,
|
252
254
|
// @ts-ignore
|
255
|
+
tableHeadRef,
|
256
|
+
// @ts-ignore
|
253
257
|
tablePaperRef,
|
254
258
|
// @ts-ignore
|
255
259
|
topToolbarRef,
|
256
|
-
// @ts-ignore
|
257
|
-
tableFooterRef,
|
258
|
-
// @ts-ignore
|
259
|
-
tableHeadRef,
|
260
260
|
};
|
261
261
|
|
262
262
|
const setCreatingRow = (row: MRT_Updater<MRT_Row<TData> | null | true>) => {
|
263
|
+
let _row = row;
|
263
264
|
if (row === true) {
|
264
|
-
|
265
|
-
} else {
|
266
|
-
_setCreatingRow(row as MRT_Row<TData> | null);
|
265
|
+
_row = createRow(table);
|
267
266
|
}
|
267
|
+
tableOptions?.onCreatingRowChange?.(_row as MRT_Row<TData> | null) ??
|
268
|
+
_setCreatingRow(_row as MRT_Row<TData> | null);
|
268
269
|
};
|
269
270
|
|
270
271
|
table.setCreatingRow = setCreatingRow;
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { useMemo } from 'react';
|
2
2
|
import { MRT_AggregationFns } from '../aggregationFns';
|
3
|
-
import { MRT_FilterFns } from '../filterFns';
|
4
|
-
import { MRT_SortingFns } from '../sortingFns';
|
5
3
|
import { MRT_DefaultColumn, MRT_DefaultDisplayColumn } from '../column.utils';
|
6
|
-
import {
|
4
|
+
import { MRT_FilterFns } from '../filterFns';
|
7
5
|
import { MRT_Default_Icons } from '../icons';
|
6
|
+
import { MRT_Localization_EN } from '../locales/en';
|
7
|
+
import { MRT_SortingFns } from '../sortingFns';
|
8
8
|
import { type MRT_DefinedTableOptions, type MRT_TableOptions } from '../types';
|
9
9
|
|
10
10
|
export const useMRT_TableOptions: <TData extends Record<string, any>>(
|
package/src/icons.ts
CHANGED
@@ -13,8 +13,8 @@ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
13
13
|
import FilterAltIcon from '@mui/icons-material/FilterAlt';
|
14
14
|
import FilterListIcon from '@mui/icons-material/FilterList';
|
15
15
|
import FilterListOffIcon from '@mui/icons-material/FilterListOff';
|
16
|
-
import FullscreenExitIcon from '@mui/icons-material/FullscreenExit';
|
17
16
|
import FullscreenIcon from '@mui/icons-material/Fullscreen';
|
17
|
+
import FullscreenExitIcon from '@mui/icons-material/FullscreenExit';
|
18
18
|
import KeyboardDoubleArrowDownIcon from '@mui/icons-material/KeyboardDoubleArrowDown';
|
19
19
|
import MoreHorizIcon from '@mui/icons-material/MoreHoriz';
|
20
20
|
import MoreVertIcon from '@mui/icons-material/MoreVert';
|
@@ -36,7 +36,6 @@ export interface MRT_Icons {
|
|
36
36
|
DensityLargeIcon: any;
|
37
37
|
DensityMediumIcon: any;
|
38
38
|
DensitySmallIcon: any;
|
39
|
-
KeyboardDoubleArrowDownIcon: any;
|
40
39
|
DragHandleIcon: any;
|
41
40
|
DynamicFeedIcon: any;
|
42
41
|
EditIcon: any;
|
@@ -46,6 +45,7 @@ export interface MRT_Icons {
|
|
46
45
|
FilterListOffIcon: any;
|
47
46
|
FullscreenExitIcon: any;
|
48
47
|
FullscreenIcon: any;
|
48
|
+
KeyboardDoubleArrowDownIcon: any;
|
49
49
|
MoreHorizIcon: any;
|
50
50
|
MoreVertIcon: any;
|
51
51
|
PushPinIcon: any;
|