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
@@ -1,8 +1,8 @@
|
|
1
1
|
import Box from '@mui/material/Box';
|
2
2
|
import Button from '@mui/material/Button';
|
3
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
3
4
|
import IconButton from '@mui/material/IconButton';
|
4
5
|
import Tooltip from '@mui/material/Tooltip';
|
5
|
-
import CircularProgress from '@mui/material/CircularProgress';
|
6
6
|
import { type MRT_Row, type MRT_TableInstance } from '../types';
|
7
7
|
|
8
8
|
interface Props<TData extends Record<string, any>> {
|
@@ -23,8 +23,8 @@ export const MRT_EditActionButtons = <TData extends Record<string, any>>({
|
|
23
23
|
localization,
|
24
24
|
onCreatingRowCancel,
|
25
25
|
onCreatingRowSave,
|
26
|
-
onEditingRowSave,
|
27
26
|
onEditingRowCancel,
|
27
|
+
onEditingRowSave,
|
28
28
|
},
|
29
29
|
refs: { editInputRefs },
|
30
30
|
setCreatingRow,
|
@@ -100,12 +100,12 @@ export const MRT_EditActionButtons = <TData extends Record<string, any>>({
|
|
100
100
|
</>
|
101
101
|
) : (
|
102
102
|
<>
|
103
|
-
<Button sx={{ minWidth: '100px' }}
|
103
|
+
<Button onClick={handleCancel} sx={{ minWidth: '100px' }}>
|
104
104
|
{localization.cancel}
|
105
105
|
</Button>
|
106
106
|
<Button
|
107
|
-
sx={{ minWidth: '100px' }}
|
108
107
|
onClick={handleSubmitRow}
|
108
|
+
sx={{ minWidth: '100px' }}
|
109
109
|
variant="contained"
|
110
110
|
>
|
111
111
|
{isSaving && <CircularProgress color="inherit" size={18} />}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import IconButton from '@mui/material/IconButton';
|
2
2
|
import Tooltip from '@mui/material/Tooltip';
|
3
|
-
import { type MRT_TableInstance } from '../types';
|
4
3
|
import { parseFromValuesOrFunc } from '../column.utils';
|
4
|
+
import { type MRT_TableInstance } from '../types';
|
5
5
|
|
6
6
|
interface Props<TData extends Record<string, any>> {
|
7
7
|
table: MRT_TableInstance<TData>;
|
@@ -11,9 +11,9 @@ export const MRT_ExpandAllButton = <TData extends Record<string, any>>({
|
|
11
11
|
table,
|
12
12
|
}: Props<TData>) => {
|
13
13
|
const {
|
14
|
+
getCanSomeRowsExpand,
|
14
15
|
getIsAllRowsExpanded,
|
15
16
|
getIsSomeRowsExpanded,
|
16
|
-
getCanSomeRowsExpand,
|
17
17
|
getState,
|
18
18
|
options: {
|
19
19
|
icons: { KeyboardDoubleArrowDownIcon },
|
@@ -52,8 +52,8 @@ export const MRT_ExpandAllButton = <TData extends Record<string, any>>({
|
|
52
52
|
{...iconButtonProps}
|
53
53
|
sx={(theme) => ({
|
54
54
|
height: density === 'compact' ? '1.75rem' : '2.25rem',
|
55
|
-
width: density === 'compact' ? '1.75rem' : '2.25rem',
|
56
55
|
mt: density !== 'compact' ? '-0.25rem' : undefined,
|
56
|
+
width: density === 'compact' ? '1.75rem' : '2.25rem',
|
57
57
|
...(parseFromValuesOrFunc(iconButtonProps?.sx, theme) as any),
|
58
58
|
})}
|
59
59
|
title={undefined}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { type MouseEvent } from 'react';
|
2
2
|
import IconButton from '@mui/material/IconButton';
|
3
3
|
import Tooltip from '@mui/material/Tooltip';
|
4
|
-
import { type MRT_Row, type MRT_TableInstance } from '../types';
|
5
4
|
import { parseFromValuesOrFunc } from '../column.utils';
|
5
|
+
import { type MRT_Row, type MRT_TableInstance } from '../types';
|
6
6
|
|
7
7
|
interface Props<TData extends Record<string, any>> {
|
8
8
|
row: MRT_Row<TData>;
|
@@ -1,14 +1,14 @@
|
|
1
1
|
import { type DragEventHandler } from 'react';
|
2
2
|
import IconButton from '@mui/material/IconButton';
|
3
|
-
import Tooltip from '@mui/material/Tooltip';
|
4
3
|
import { type IconButtonProps } from '@mui/material/IconButton';
|
4
|
+
import Tooltip from '@mui/material/Tooltip';
|
5
5
|
import { parseFromValuesOrFunc } from '../column.utils';
|
6
6
|
import { type MRT_TableInstance } from '../types';
|
7
7
|
|
8
8
|
interface Props<TData extends Record<string, any>> {
|
9
9
|
iconButtonProps?: IconButtonProps;
|
10
|
-
onDragStart: DragEventHandler<HTMLButtonElement>;
|
11
10
|
onDragEnd: DragEventHandler<HTMLButtonElement>;
|
11
|
+
onDragStart: DragEventHandler<HTMLButtonElement>;
|
12
12
|
table: MRT_TableInstance<TData>;
|
13
13
|
}
|
14
14
|
|
@@ -42,21 +42,21 @@ export const MRT_GrabHandleButton = <TData extends Record<string, any>>({
|
|
42
42
|
e.stopPropagation();
|
43
43
|
iconButtonProps?.onClick?.(e);
|
44
44
|
}}
|
45
|
-
onDragStart={onDragStart}
|
46
45
|
onDragEnd={onDragEnd}
|
46
|
+
onDragStart={onDragStart}
|
47
47
|
sx={(theme) => ({
|
48
|
+
'&:active': {
|
49
|
+
cursor: 'grabbing',
|
50
|
+
},
|
51
|
+
'&:hover': {
|
52
|
+
backgroundColor: 'transparent',
|
53
|
+
opacity: 1,
|
54
|
+
},
|
48
55
|
cursor: 'grab',
|
49
56
|
m: '0 -0.1rem',
|
50
57
|
opacity: 0.5,
|
51
58
|
p: '2px',
|
52
59
|
transition: 'all 150ms ease-in-out',
|
53
|
-
'&:hover': {
|
54
|
-
backgroundColor: 'transparent',
|
55
|
-
opacity: 1,
|
56
|
-
},
|
57
|
-
'&:active': {
|
58
|
-
cursor: 'grabbing',
|
59
|
-
},
|
60
60
|
...(parseFromValuesOrFunc(iconButtonProps?.sx, theme) as any),
|
61
61
|
})}
|
62
62
|
title={undefined}
|
@@ -1,23 +1,23 @@
|
|
1
|
-
import {
|
1
|
+
import { type MouseEvent, useState } from 'react';
|
2
2
|
import { type RowPinningPosition } from '@tanstack/react-table';
|
3
3
|
import IconButton from '@mui/material/IconButton';
|
4
4
|
import Tooltip from '@mui/material/Tooltip';
|
5
5
|
import { type MRT_Row, type MRT_TableInstance } from '../types';
|
6
6
|
|
7
7
|
interface Props<TData extends Record<string, any>> {
|
8
|
+
pinningPosition: RowPinningPosition;
|
8
9
|
row: MRT_Row<TData>;
|
9
10
|
table: MRT_TableInstance<TData>;
|
10
|
-
pinningPosition: RowPinningPosition;
|
11
11
|
}
|
12
12
|
|
13
13
|
export const MRT_RowPinButton = <TData extends Record<string, any>>({
|
14
|
+
pinningPosition,
|
14
15
|
row,
|
15
16
|
table,
|
16
|
-
pinningPosition,
|
17
17
|
}: Props<TData>) => {
|
18
18
|
const {
|
19
19
|
options: {
|
20
|
-
icons: {
|
20
|
+
icons: { CloseIcon, PushPinIcon },
|
21
21
|
localization,
|
22
22
|
rowPinningDisplayMode,
|
23
23
|
},
|
@@ -36,9 +36,9 @@ export const MRT_RowPinButton = <TData extends Record<string, any>>({
|
|
36
36
|
return (
|
37
37
|
<Tooltip
|
38
38
|
arrow
|
39
|
-
open={tooltipOpened}
|
40
39
|
enterDelay={1000}
|
41
40
|
enterNextDelay={1000}
|
41
|
+
open={tooltipOpened}
|
42
42
|
title={isPinned ? localization.unpin : localization.pin}
|
43
43
|
>
|
44
44
|
<IconButton
|
@@ -20,7 +20,7 @@ export const MRT_ShowHideColumnsButton = <TData extends Record<string, any>>({
|
|
20
20
|
},
|
21
21
|
} = table;
|
22
22
|
|
23
|
-
const [anchorEl, setAnchorEl] = useState<
|
23
|
+
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
|
24
24
|
|
25
25
|
const handleClick = (event: MouseEvent<HTMLElement>) => {
|
26
26
|
setAnchorEl(event.currentTarget);
|
@@ -1,8 +1,8 @@
|
|
1
|
+
import { useState } from 'react';
|
1
2
|
import IconButton from '@mui/material/IconButton';
|
2
3
|
import { type IconButtonProps } from '@mui/material/IconButton';
|
3
4
|
import Tooltip from '@mui/material/Tooltip';
|
4
5
|
import { type MRT_TableInstance } from '../types';
|
5
|
-
import { useState } from 'react';
|
6
6
|
|
7
7
|
interface Props<TData extends Record<string, any>> extends IconButtonProps {
|
8
8
|
table: MRT_TableInstance<TData>;
|
@@ -31,8 +31,8 @@ export const MRT_ToggleFullScreenButton = <TData extends Record<string, any>>({
|
|
31
31
|
|
32
32
|
return (
|
33
33
|
<Tooltip
|
34
|
-
open={tooltipOpened}
|
35
34
|
arrow
|
35
|
+
open={tooltipOpened}
|
36
36
|
title={rest?.title ?? localization.toggleFullScreen}
|
37
37
|
>
|
38
38
|
<IconButton
|
@@ -1,20 +1,20 @@
|
|
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_RowActionMenu } from '../menus/MRT_RowActionMenu';
|
5
4
|
import { MRT_EditActionButtons } from './MRT_EditActionButtons';
|
6
|
-
import { type MRT_Cell, type MRT_Row, type MRT_TableInstance } from '../types';
|
7
5
|
import { parseFromValuesOrFunc } from '../column.utils';
|
6
|
+
import { MRT_RowActionMenu } from '../menus/MRT_RowActionMenu';
|
7
|
+
import { type MRT_Cell, type MRT_Row, type MRT_TableInstance } from '../types';
|
8
8
|
|
9
9
|
const commonIconButtonStyles = {
|
10
|
+
'&:hover': {
|
11
|
+
opacity: 1,
|
12
|
+
},
|
10
13
|
height: '2rem',
|
11
14
|
ml: '10px',
|
12
15
|
opacity: 0.5,
|
13
16
|
transition: 'opacity 150ms',
|
14
17
|
width: '2rem',
|
15
|
-
'&:hover': {
|
16
|
-
opacity: 1,
|
17
|
-
},
|
18
18
|
};
|
19
19
|
|
20
20
|
interface Props<TData extends Record<string, any>> {
|
@@ -53,7 +53,7 @@ export const MRT_ToggleRowActionMenuButton = <
|
|
53
53
|
(isCreating && createDisplayMode === 'row') ||
|
54
54
|
(isEditing && editDisplayMode === 'row');
|
55
55
|
|
56
|
-
const [anchorEl, setAnchorEl] = useState<
|
56
|
+
const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
|
57
57
|
|
58
58
|
const handleOpenRowActionMenu = (event: MouseEvent<HTMLElement>) => {
|
59
59
|
event.stopPropagation();
|
@@ -75,11 +75,11 @@ export const MRT_ToggleRowActionMenuButton = <
|
|
75
75
|
<MRT_EditActionButtons row={row} table={table} />
|
76
76
|
) : !renderRowActionMenuItems &&
|
77
77
|
parseFromValuesOrFunc(enableEditing, row) ? (
|
78
|
-
<Tooltip placement="right"
|
78
|
+
<Tooltip arrow placement="right" title={localization.edit}>
|
79
79
|
<IconButton
|
80
80
|
aria-label={localization.edit}
|
81
|
-
sx={commonIconButtonStyles}
|
82
81
|
onClick={handleStartEditMode}
|
82
|
+
sx={commonIconButtonStyles}
|
83
83
|
>
|
84
84
|
<EditIcon />
|
85
85
|
</IconButton>
|
package/src/column.utils.ts
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
import { type ReactNode } from 'react';
|
2
2
|
import {
|
3
|
-
type Row,
|
4
|
-
type Renderable,
|
5
|
-
flexRender as _flexRender,
|
6
3
|
createRow as _createRow,
|
4
|
+
flexRender as _flexRender,
|
5
|
+
type Renderable,
|
6
|
+
type Row,
|
7
7
|
} from '@tanstack/react-table';
|
8
|
+
import { type TableCellProps } from '@mui/material/TableCell';
|
8
9
|
import { alpha, lighten } from '@mui/material/styles';
|
10
|
+
import { type Theme } from '@mui/material/styles';
|
9
11
|
import { type MRT_AggregationFns } from './aggregationFns';
|
10
12
|
import { type MRT_FilterFns } from './filterFns';
|
11
13
|
import { type MRT_SortingFns } from './sortingFns';
|
12
|
-
import { type TableCellProps } from '@mui/material/TableCell';
|
13
|
-
import { type Theme } from '@mui/material/styles';
|
14
14
|
import {
|
15
|
-
type MRT_TableOptions,
|
16
15
|
type MRT_Column,
|
17
16
|
type MRT_ColumnDef,
|
18
17
|
type MRT_ColumnOrderState,
|
@@ -21,8 +20,9 @@ import {
|
|
21
20
|
type MRT_FilterOption,
|
22
21
|
type MRT_GroupingState,
|
23
22
|
type MRT_Header,
|
24
|
-
type MRT_TableInstance,
|
25
23
|
type MRT_Row,
|
24
|
+
type MRT_TableInstance,
|
25
|
+
type MRT_TableOptions,
|
26
26
|
} from './types';
|
27
27
|
|
28
28
|
export const getColumnId = <TData extends Record<string, any>>(
|
@@ -159,7 +159,7 @@ export const getLeadingDisplayColumnIds = <TData extends Record<string, any>>(
|
|
159
159
|
props.positionActionsColumn === 'first' &&
|
160
160
|
(props.enableRowActions ||
|
161
161
|
(props.enableEditing &&
|
162
|
-
['
|
162
|
+
['modal', 'row'].includes(props.editDisplayMode ?? ''))) &&
|
163
163
|
'mrt-row-actions',
|
164
164
|
props.positionExpandColumn === 'first' &&
|
165
165
|
showExpandColumn(props) &&
|
@@ -175,7 +175,7 @@ export const getTrailingDisplayColumnIds = <TData extends Record<string, any>>(
|
|
175
175
|
props.positionActionsColumn === 'last' &&
|
176
176
|
(props.enableRowActions ||
|
177
177
|
(props.enableEditing &&
|
178
|
-
['
|
178
|
+
['modal', 'row'].includes(props.editDisplayMode ?? ''))) &&
|
179
179
|
'mrt-row-actions',
|
180
180
|
props.positionExpandColumn === 'last' &&
|
181
181
|
showExpandColumn(props) &&
|
@@ -201,11 +201,7 @@ export const getDefaultColumnFilterFn = <TData extends Record<string, any>>(
|
|
201
201
|
columnDef: MRT_ColumnDef<TData>,
|
202
202
|
): MRT_FilterOption => {
|
203
203
|
if (columnDef.filterVariant === 'multi-select') return 'arrIncludesSome';
|
204
|
-
if (
|
205
|
-
columnDef.filterVariant === 'range' ||
|
206
|
-
columnDef.filterVariant === 'range-slider'
|
207
|
-
)
|
208
|
-
return 'betweenInclusive';
|
204
|
+
if (columnDef.filterVariant?.includes('range')) return 'betweenInclusive';
|
209
205
|
if (
|
210
206
|
columnDef.filterVariant === 'select' ||
|
211
207
|
columnDef.filterVariant === 'checkbox'
|
@@ -218,15 +214,21 @@ export const getIsFirstColumn = <TData extends Record<string, any>>(
|
|
218
214
|
column: MRT_Column<TData>,
|
219
215
|
table: MRT_TableInstance<TData>,
|
220
216
|
) => {
|
221
|
-
|
217
|
+
const leftColumns = table.getLeftVisibleLeafColumns();
|
218
|
+
return leftColumns.length
|
219
|
+
? leftColumns[0].id === column.id
|
220
|
+
: table.getVisibleLeafColumns()[0].id === column.id;
|
222
221
|
};
|
223
222
|
|
224
223
|
export const getIsLastColumn = <TData extends Record<string, any>>(
|
225
224
|
column: MRT_Column<TData>,
|
226
225
|
table: MRT_TableInstance<TData>,
|
227
226
|
) => {
|
227
|
+
const rightColumns = table.getRightVisibleLeafColumns();
|
228
228
|
const columns = table.getVisibleLeafColumns();
|
229
|
-
return
|
229
|
+
return rightColumns.length
|
230
|
+
? rightColumns[rightColumns.length - 1].id === column.id
|
231
|
+
: columns[columns.length - 1].id === column.id;
|
230
232
|
};
|
231
233
|
|
232
234
|
export const getIsLastLeftPinnedColumn = <TData extends Record<string, any>>(
|
@@ -258,15 +260,15 @@ export const getTotalRight = <TData extends Record<string, any>>(
|
|
258
260
|
export const getCanRankRows = <TData extends Record<string, any>>(
|
259
261
|
table: MRT_TableInstance<TData>,
|
260
262
|
) => {
|
261
|
-
const {
|
263
|
+
const { getState, options } = table;
|
262
264
|
const {
|
265
|
+
enableGlobalFilterRankedResults,
|
263
266
|
manualExpanding,
|
264
267
|
manualFiltering,
|
265
268
|
manualGrouping,
|
266
269
|
manualSorting,
|
267
|
-
enableGlobalFilterRankedResults,
|
268
270
|
} = options;
|
269
|
-
const {
|
271
|
+
const { expanded, globalFilterFn } = getState();
|
270
272
|
|
271
273
|
return (
|
272
274
|
!manualExpanding &&
|
@@ -366,8 +368,8 @@ export const getCommonCellStyles = <TData extends Record<string, any>>({
|
|
366
368
|
|
367
369
|
export const MRT_DefaultColumn = {
|
368
370
|
filterVariant: 'text',
|
369
|
-
minSize: 40,
|
370
371
|
maxSize: 1000,
|
372
|
+
minSize: 40,
|
371
373
|
size: 180,
|
372
374
|
} as const;
|
373
375
|
|
@@ -387,7 +389,7 @@ export const MRT_DefaultDisplayColumn = {
|
|
387
389
|
} as const;
|
388
390
|
|
389
391
|
export const parseFromValuesOrFunc = <T, U>(
|
390
|
-
fn:
|
392
|
+
fn: ((arg: U) => T) | T | undefined,
|
391
393
|
arg: U,
|
392
394
|
): T | undefined => (fn instanceof Function ? fn(arg) : fn);
|
393
395
|
|
@@ -396,7 +398,7 @@ export const parseCSSVarId = (id: string) => id.replace(/[^a-zA-Z0-9]/g, '_');
|
|
396
398
|
export const flexRender = _flexRender as (
|
397
399
|
Comp: Renderable<any>,
|
398
400
|
props: any,
|
399
|
-
) =>
|
401
|
+
) => JSX.Element | ReactNode;
|
400
402
|
|
401
403
|
export const createRow = <TData extends Record<string, any>>(
|
402
404
|
table: MRT_TableInstance<TData>,
|
package/src/filterFns.ts
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
import {
|
2
|
+
type RankingInfo,
|
2
3
|
rankItem,
|
3
4
|
rankings,
|
4
|
-
type RankingInfo,
|
5
5
|
} from '@tanstack/match-sorter-utils';
|
6
|
-
import {
|
6
|
+
import { type Row, filterFns } from '@tanstack/react-table';
|
7
7
|
|
8
8
|
const fuzzy = <TData extends Record<string, any>>(
|
9
9
|
row: Row<TData>,
|
10
10
|
columnId: string,
|
11
|
-
filterValue:
|
11
|
+
filterValue: number | string,
|
12
12
|
addMeta: (item: RankingInfo) => void,
|
13
13
|
) => {
|
14
14
|
const itemRank = rankItem(row.getValue(columnId), filterValue as string, {
|
@@ -23,10 +23,10 @@ fuzzy.autoRemove = (val: any) => !val;
|
|
23
23
|
const contains = <TData extends Record<string, any>>(
|
24
24
|
row: Row<TData>,
|
25
25
|
id: string,
|
26
|
-
filterValue:
|
26
|
+
filterValue: number | string,
|
27
27
|
) =>
|
28
28
|
row
|
29
|
-
.getValue<
|
29
|
+
.getValue<number | string>(id)
|
30
30
|
.toString()
|
31
31
|
.toLowerCase()
|
32
32
|
.trim()
|
@@ -37,10 +37,10 @@ contains.autoRemove = (val: any) => !val;
|
|
37
37
|
const startsWith = <TData extends Record<string, any>>(
|
38
38
|
row: Row<TData>,
|
39
39
|
id: string,
|
40
|
-
filterValue:
|
40
|
+
filterValue: number | string,
|
41
41
|
) =>
|
42
42
|
row
|
43
|
-
.getValue<
|
43
|
+
.getValue<number | string>(id)
|
44
44
|
.toString()
|
45
45
|
.toLowerCase()
|
46
46
|
.trim()
|
@@ -51,10 +51,10 @@ startsWith.autoRemove = (val: any) => !val;
|
|
51
51
|
const endsWith = <TData extends Record<string, any>>(
|
52
52
|
row: Row<TData>,
|
53
53
|
id: string,
|
54
|
-
filterValue:
|
54
|
+
filterValue: number | string,
|
55
55
|
) =>
|
56
56
|
row
|
57
|
-
.getValue<
|
57
|
+
.getValue<number | string>(id)
|
58
58
|
.toString()
|
59
59
|
.toLowerCase()
|
60
60
|
.trim()
|
@@ -65,9 +65,9 @@ endsWith.autoRemove = (val: any) => !val;
|
|
65
65
|
const equals = <TData extends Record<string, any>>(
|
66
66
|
row: Row<TData>,
|
67
67
|
id: string,
|
68
|
-
filterValue:
|
68
|
+
filterValue: number | string,
|
69
69
|
) =>
|
70
|
-
row.getValue<
|
70
|
+
row.getValue<number | string>(id).toString().toLowerCase().trim() ===
|
71
71
|
filterValue.toString().toLowerCase().trim();
|
72
72
|
|
73
73
|
equals.autoRemove = (val: any) => !val;
|
@@ -75,9 +75,9 @@ equals.autoRemove = (val: any) => !val;
|
|
75
75
|
const notEquals = <TData extends Record<string, any>>(
|
76
76
|
row: Row<TData>,
|
77
77
|
id: string,
|
78
|
-
filterValue:
|
78
|
+
filterValue: number | string,
|
79
79
|
) =>
|
80
|
-
row.getValue<
|
80
|
+
row.getValue<number | string>(id).toString().toLowerCase().trim() !==
|
81
81
|
filterValue.toString().toLowerCase().trim();
|
82
82
|
|
83
83
|
notEquals.autoRemove = (val: any) => !val;
|
@@ -85,11 +85,11 @@ notEquals.autoRemove = (val: any) => !val;
|
|
85
85
|
const greaterThan = <TData extends Record<string, any>>(
|
86
86
|
row: Row<TData>,
|
87
87
|
id: string,
|
88
|
-
filterValue:
|
88
|
+
filterValue: number | string,
|
89
89
|
) =>
|
90
|
-
!isNaN(+filterValue) && !isNaN(+row.getValue<
|
91
|
-
? +row.getValue<
|
92
|
-
: row.getValue<
|
90
|
+
!isNaN(+filterValue) && !isNaN(+row.getValue<number | string>(id))
|
91
|
+
? +row.getValue<number | string>(id) > +filterValue
|
92
|
+
: row.getValue<number | string>(id).toString().toLowerCase().trim() >
|
93
93
|
filterValue.toString().toLowerCase().trim();
|
94
94
|
|
95
95
|
greaterThan.autoRemove = (val: any) => !val;
|
@@ -97,7 +97,7 @@ greaterThan.autoRemove = (val: any) => !val;
|
|
97
97
|
const greaterThanOrEqualTo = <TData extends Record<string, any>>(
|
98
98
|
row: Row<TData>,
|
99
99
|
id: string,
|
100
|
-
filterValue:
|
100
|
+
filterValue: number | string,
|
101
101
|
) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
|
102
102
|
|
103
103
|
greaterThanOrEqualTo.autoRemove = (val: any) => !val;
|
@@ -105,11 +105,11 @@ greaterThanOrEqualTo.autoRemove = (val: any) => !val;
|
|
105
105
|
const lessThan = <TData extends Record<string, any>>(
|
106
106
|
row: Row<TData>,
|
107
107
|
id: string,
|
108
|
-
filterValue:
|
108
|
+
filterValue: number | string,
|
109
109
|
) =>
|
110
|
-
!isNaN(+filterValue) && !isNaN(+row.getValue<
|
111
|
-
? +row.getValue<
|
112
|
-
: row.getValue<
|
110
|
+
!isNaN(+filterValue) && !isNaN(+row.getValue<number | string>(id))
|
111
|
+
? +row.getValue<number | string>(id) < +filterValue
|
112
|
+
: row.getValue<number | string>(id).toString().toLowerCase().trim() <
|
113
113
|
filterValue.toString().toLowerCase().trim();
|
114
114
|
|
115
115
|
lessThan.autoRemove = (val: any) => !val;
|
@@ -117,7 +117,7 @@ lessThan.autoRemove = (val: any) => !val;
|
|
117
117
|
const lessThanOrEqualTo = <TData extends Record<string, any>>(
|
118
118
|
row: Row<TData>,
|
119
119
|
id: string,
|
120
|
-
filterValue:
|
120
|
+
filterValue: number | string,
|
121
121
|
) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
|
122
122
|
|
123
123
|
lessThanOrEqualTo.autoRemove = (val: any) => !val;
|
@@ -125,7 +125,7 @@ lessThanOrEqualTo.autoRemove = (val: any) => !val;
|
|
125
125
|
const between = <TData extends Record<string, any>>(
|
126
126
|
row: Row<TData>,
|
127
127
|
id: string,
|
128
|
-
filterValues: [
|
128
|
+
filterValues: [number | string, number | string],
|
129
129
|
) =>
|
130
130
|
((['', undefined] as any[]).includes(filterValues[0]) ||
|
131
131
|
greaterThan(row, id, filterValues[0])) &&
|
@@ -140,7 +140,7 @@ between.autoRemove = (val: any) => !val;
|
|
140
140
|
const betweenInclusive = <TData extends Record<string, any>>(
|
141
141
|
row: Row<TData>,
|
142
142
|
id: string,
|
143
|
-
filterValues: [
|
143
|
+
filterValues: [number | string, number | string],
|
144
144
|
) =>
|
145
145
|
((['', undefined] as any[]).includes(filterValues[0]) ||
|
146
146
|
greaterThanOrEqualTo(row, id, filterValues[0])) &&
|
@@ -155,16 +155,16 @@ betweenInclusive.autoRemove = (val: any) => !val;
|
|
155
155
|
const empty = <TData extends Record<string, any>>(
|
156
156
|
row: Row<TData>,
|
157
157
|
id: string,
|
158
|
-
_filterValue:
|
159
|
-
) => !row.getValue<
|
158
|
+
_filterValue: number | string,
|
159
|
+
) => !row.getValue<number | string>(id).toString().trim();
|
160
160
|
|
161
161
|
empty.autoRemove = (val: any) => !val;
|
162
162
|
|
163
163
|
const notEmpty = <TData extends Record<string, any>>(
|
164
164
|
row: Row<TData>,
|
165
165
|
id: string,
|
166
|
-
_filterValue:
|
167
|
-
) => !!row.getValue<
|
166
|
+
_filterValue: number | string,
|
167
|
+
) => !!row.getValue<number | string>(id).toString().trim();
|
168
168
|
|
169
169
|
notEmpty.autoRemove = (val: any) => !val;
|
170
170
|
|
@@ -1,8 +1,8 @@
|
|
1
|
+
import { type VirtualItem } from '@tanstack/react-virtual';
|
1
2
|
import TableFooter from '@mui/material/TableFooter';
|
2
3
|
import { MRT_TableFooterRow } from './MRT_TableFooterRow';
|
3
|
-
import { type VirtualItem } from '@tanstack/react-virtual';
|
4
|
-
import { type MRT_TableInstance } from '../types';
|
5
4
|
import { parseFromValuesOrFunc } from '../column.utils';
|
5
|
+
import { type MRT_TableInstance } from '../types';
|
6
6
|
|
7
7
|
interface Props<TData extends Record<string, any>> {
|
8
8
|
table: MRT_TableInstance<TData>;
|
@@ -35,6 +35,13 @@ export const MRT_TableFooter = <TData extends Record<string, any>>({
|
|
35
35
|
return (
|
36
36
|
<TableFooter
|
37
37
|
{...tableFooterProps}
|
38
|
+
ref={(ref: HTMLTableSectionElement) => {
|
39
|
+
tableFooterRef.current = ref;
|
40
|
+
if (tableFooterProps?.ref) {
|
41
|
+
// @ts-ignore
|
42
|
+
tableFooterProps.ref.current = ref;
|
43
|
+
}
|
44
|
+
}}
|
38
45
|
sx={(theme) => ({
|
39
46
|
bottom: stickFooter ? 0 : undefined,
|
40
47
|
display: layoutMode === 'grid' ? 'grid' : 'table-row-group',
|
@@ -48,13 +55,6 @@ export const MRT_TableFooter = <TData extends Record<string, any>>({
|
|
48
55
|
zIndex: stickFooter ? 1 : undefined,
|
49
56
|
...(parseFromValuesOrFunc(tableFooterProps?.sx, theme) as any),
|
50
57
|
})}
|
51
|
-
ref={(ref: HTMLTableSectionElement) => {
|
52
|
-
tableFooterRef.current = ref;
|
53
|
-
if (tableFooterProps?.ref) {
|
54
|
-
// @ts-ignore
|
55
|
-
tableFooterProps.ref.current = ref;
|
56
|
-
}
|
57
|
-
}}
|
58
58
|
>
|
59
59
|
{getFooterGroups().map((footerGroup) => (
|
60
60
|
<MRT_TableFooterRow
|
@@ -1,13 +1,13 @@
|
|
1
|
+
import { type VirtualItem } from '@tanstack/react-virtual';
|
1
2
|
import TableRow from '@mui/material/TableRow';
|
2
3
|
import { lighten } from '@mui/material/styles';
|
3
4
|
import { MRT_TableFooterCell } from './MRT_TableFooterCell';
|
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
|
footerGroup: MRT_HeaderGroup<TData>;
|
@@ -1,8 +1,8 @@
|
|
1
|
+
import { type VirtualItem } from '@tanstack/react-virtual';
|
1
2
|
import TableHead from '@mui/material/TableHead';
|
2
3
|
import { MRT_TableHeadRow } from './MRT_TableHeadRow';
|
3
|
-
import { type VirtualItem } from '@tanstack/react-virtual';
|
4
|
-
import { type MRT_TableInstance } from '../types';
|
5
4
|
import { parseFromValuesOrFunc } from '../column.utils';
|
5
|
+
import { type MRT_TableInstance } from '../types';
|
6
6
|
|
7
7
|
interface Props<TData extends Record<string, any>> {
|
8
8
|
table: MRT_TableInstance<TData>;
|
@@ -32,6 +32,13 @@ export const MRT_TableHead = <TData extends Record<string, any>>({
|
|
32
32
|
return (
|
33
33
|
<TableHead
|
34
34
|
{...tableHeadProps}
|
35
|
+
ref={(ref: HTMLTableSectionElement) => {
|
36
|
+
tableHeadRef.current = ref;
|
37
|
+
if (tableHeadProps?.ref) {
|
38
|
+
// @ts-ignore
|
39
|
+
tableHeadProps.ref.current = ref;
|
40
|
+
}
|
41
|
+
}}
|
35
42
|
sx={(theme) => ({
|
36
43
|
display: layoutMode === 'grid' ? 'grid' : 'table-row-group',
|
37
44
|
opacity: 0.97,
|
@@ -40,13 +47,6 @@ export const MRT_TableHead = <TData extends Record<string, any>>({
|
|
40
47
|
zIndex: stickyHeader ? 2 : undefined,
|
41
48
|
...(parseFromValuesOrFunc(tableHeadProps?.sx, theme) as any),
|
42
49
|
})}
|
43
|
-
ref={(ref: HTMLTableSectionElement) => {
|
44
|
-
tableHeadRef.current = ref;
|
45
|
-
if (tableHeadProps?.ref) {
|
46
|
-
// @ts-ignore
|
47
|
-
tableHeadProps.ref.current = ref;
|
48
|
-
}
|
49
|
-
}}
|
50
50
|
>
|
51
51
|
{getHeaderGroups().map((headerGroup) => (
|
52
52
|
<MRT_TableHeadRow
|