material-react-table 1.8.5 → 1.9.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/dist/cjs/index.js +96 -60
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/_locales/sr-Cyrl-RS.d.ts +2 -0
- package/dist/cjs/types/_locales/sr-Latn-RS.d.ts +2 -0
- package/dist/cjs/types/body/MRT_TableBody.d.ts +1 -1
- package/dist/cjs/types/body/MRT_TableBodyCell.d.ts +2 -3
- package/dist/cjs/types/column.utils.d.ts +1 -1
- package/dist/cjs/types/filterFns.d.ts +1 -1
- package/dist/cjs/types/footer/MRT_TableFooterRow.d.ts +1 -1
- package/dist/cjs/types/sortingFns.d.ts +2 -2
- package/dist/esm/material-react-table.esm.js +95 -60
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/types/_locales/sr-Cyrl-RS.d.ts +2 -0
- package/dist/esm/types/_locales/sr-Latn-RS.d.ts +2 -0
- package/dist/esm/types/body/MRT_TableBody.d.ts +1 -1
- package/dist/esm/types/body/MRT_TableBodyCell.d.ts +2 -3
- package/dist/esm/types/column.utils.d.ts +1 -1
- package/dist/esm/types/filterFns.d.ts +1 -1
- package/dist/esm/types/footer/MRT_TableFooterRow.d.ts +1 -1
- package/dist/esm/types/sortingFns.d.ts +2 -2
- package/locales/sr-Cyrl-RS.d.ts +2 -0
- package/locales/sr-Cyrl-RS.esm.d.ts +2 -0
- package/locales/sr-Cyrl-RS.esm.js +94 -0
- package/locales/sr-Cyrl-RS.esm.js.map +1 -0
- package/locales/sr-Cyrl-RS.js +98 -0
- package/locales/sr-Cyrl-RS.js.map +1 -0
- package/locales/sr-Latn-RS.d.ts +2 -0
- package/locales/sr-Latn-RS.esm.d.ts +2 -0
- package/locales/sr-Latn-RS.esm.js +94 -0
- package/locales/sr-Latn-RS.esm.js.map +1 -0
- package/locales/sr-Latn-RS.js +98 -0
- package/locales/sr-Latn-RS.js.map +1 -0
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +1 -1
- package/src/_locales/sr-Cyrl-RS.ts +94 -0
- package/src/_locales/sr-Latn-RS.ts +94 -0
- package/src/body/MRT_TableBody.tsx +2 -2
- package/src/body/MRT_TableBodyCell.tsx +9 -14
- package/src/body/MRT_TableBodyRow.tsx +5 -6
- package/src/column.utils.ts +1 -1
- package/src/filterFns.ts +1 -1
- package/src/footer/MRT_TableFooterRow.tsx +1 -1
- package/src/head/MRT_TableHeadCell.tsx +4 -0
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +1 -1
- package/src/head/MRT_TableHeadCellSortLabel.tsx +30 -22
- package/src/inputs/MRT_FilterTextField.tsx +1 -1
- package/src/menus/MRT_FilterOptionMenu.tsx +37 -15
- package/src/menus/MRT_RowActionMenu.tsx +1 -0
- package/src/menus/MRT_ShowHideColumnsMenuItems.tsx +2 -1
- package/src/sortingFns.ts +3 -3
- package/src/table/MRT_Table.tsx +2 -2
- package/src/table/MRT_TableRoot.tsx +1 -1
@@ -0,0 +1,94 @@
|
|
1
|
+
import type { MRT_Localization } from '../MaterialReactTable';
|
2
|
+
|
3
|
+
export const MRT_Localization_SR_LATN_RS: MRT_Localization = {
|
4
|
+
actions: 'Akcije',
|
5
|
+
and: 'i',
|
6
|
+
cancel: 'Otkaži',
|
7
|
+
changeFilterMode: 'Promeni režim filtriranja',
|
8
|
+
changeSearchMode: 'Promeni režim pretrage',
|
9
|
+
clearFilter: 'Poništi filter',
|
10
|
+
clearSearch: 'Poništi pretragu',
|
11
|
+
clearSort: 'Poništi sortiranje',
|
12
|
+
clickToCopy: 'Klikni da kopiraš',
|
13
|
+
collapse: 'Raširi',
|
14
|
+
collapseAll: 'Raširi sve',
|
15
|
+
columnActions: 'Akcije nad kolonama',
|
16
|
+
copiedToClipboard: 'Kopirani u clipboard',
|
17
|
+
dropToGroupBy: 'Ubaci u grupu po {column}',
|
18
|
+
edit: 'Izmeni',
|
19
|
+
expand: 'Proširi',
|
20
|
+
expandAll: 'Proširi sve',
|
21
|
+
filterArrIncludes: 'Uključuje',
|
22
|
+
filterArrIncludesAll: 'Uključuje sve',
|
23
|
+
filterArrIncludesSome: 'Uključuje',
|
24
|
+
filterBetween: 'Između',
|
25
|
+
filterBetweenInclusive: 'Inkluzivno između',
|
26
|
+
filterByColumn: 'Filtriraj po {column}',
|
27
|
+
filterContains: 'Sadrži',
|
28
|
+
filterEmpty: 'Prazno',
|
29
|
+
filterEndsWith: 'Završava se na',
|
30
|
+
filterEquals: 'Jednako',
|
31
|
+
filterEqualsString: 'Jednako',
|
32
|
+
filterFuzzy: 'Fazi',
|
33
|
+
filterGreaterThan: 'Veće',
|
34
|
+
filterGreaterThanOrEqualTo: 'Veće ili jednako',
|
35
|
+
filterInNumberRange: 'Između',
|
36
|
+
filterIncludesString: 'Sadrži',
|
37
|
+
filterIncludesStringSensitive: 'Sadrži',
|
38
|
+
filterLessThan: 'Manje',
|
39
|
+
filterLessThanOrEqualTo: 'Manje ili jednako',
|
40
|
+
filterMode: 'Režim filtriranja: {filterType}',
|
41
|
+
filterNotEmpty: 'Nije prazno',
|
42
|
+
filterNotEquals: 'Nije jednako',
|
43
|
+
filterStartsWith: 'Počinje sa',
|
44
|
+
filterWeakEquals: 'Jednako',
|
45
|
+
filteringByColumn: 'Filtriranje po {column} - {filterType} {filterValue}',
|
46
|
+
goToFirstPage: 'Idi na prvu stranicu',
|
47
|
+
goToLastPage: 'Idi na poslednju stranicu',
|
48
|
+
goToNextPage: 'Idi na sledeću stranicu',
|
49
|
+
goToPreviousPage: 'Idi na prošlu stranicu',
|
50
|
+
grab: 'Zgrabi',
|
51
|
+
groupByColumn: 'Grupiši po {column}',
|
52
|
+
groupedBy: 'Grupisano po ',
|
53
|
+
hideAll: 'Sakrij sve',
|
54
|
+
hideColumn: 'Sakrij {column} kolonu',
|
55
|
+
max: 'Max',
|
56
|
+
min: 'Min',
|
57
|
+
move: 'Pomeri',
|
58
|
+
noRecordsToDisplay: 'Nema redova za prikaz',
|
59
|
+
noResultsFound: 'Nema rezultata',
|
60
|
+
of: 'od',
|
61
|
+
or: 'ili',
|
62
|
+
pinToLeft: 'Zakači levo',
|
63
|
+
pinToRight: 'Zakači desno',
|
64
|
+
resetColumnSize: 'Resetuj širinu kolone',
|
65
|
+
resetOrder: 'Resetuj poredak',
|
66
|
+
rowActions: 'Akcije nad redovima',
|
67
|
+
rowNumber: '#',
|
68
|
+
rowNumbers: 'Broj redova',
|
69
|
+
rowsPerPage: 'Redova po stranici',
|
70
|
+
save: 'Snimi',
|
71
|
+
search: 'Pretraži',
|
72
|
+
selectedCountOfRowCountRowsSelected:
|
73
|
+
'{selectedCount} od {rowCount} redova označeno',
|
74
|
+
select: 'Označi',
|
75
|
+
showAll: 'Prikaži sve',
|
76
|
+
showAllColumns: 'Prikaži sve kolone',
|
77
|
+
showHideColumns: 'Prikaži/sakrij kolone',
|
78
|
+
showHideFilters: 'Prikaži/sakrij filtere',
|
79
|
+
showHideSearch: 'Prikaži/sakrij pretragu',
|
80
|
+
sortByColumnAsc: 'Sortiraj po {column} rastuće',
|
81
|
+
sortByColumnDesc: 'Sortiraj po {column} opadajuće',
|
82
|
+
sortedByColumnAsc: 'Sortirano po {column} rastuće',
|
83
|
+
sortedByColumnDesc: 'Sortirano po {column} opadajuće',
|
84
|
+
thenBy: ', onda po ',
|
85
|
+
toggleDensity: 'Podesi gustinu',
|
86
|
+
toggleFullScreen: 'Uključi/isključi preko celog ekrana',
|
87
|
+
toggleSelectAll: 'Označi/odznači sve redove',
|
88
|
+
toggleSelectRow: 'Označi/odznači red',
|
89
|
+
toggleVisibility: 'Uključi/isključi vidljivost',
|
90
|
+
ungroupByColumn: 'Odgrupiši po {column}',
|
91
|
+
unpin: 'Otkači',
|
92
|
+
unpinAll: 'Otkači sve',
|
93
|
+
unsorted: 'Nesortirano',
|
94
|
+
};
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import React, { memo, useMemo } from 'react';
|
2
2
|
import {
|
3
3
|
useVirtualizer,
|
4
|
-
VirtualItem,
|
5
|
-
Virtualizer,
|
4
|
+
type VirtualItem,
|
5
|
+
type Virtualizer,
|
6
6
|
} from '@tanstack/react-virtual';
|
7
7
|
import TableBody from '@mui/material/TableBody';
|
8
8
|
import Typography from '@mui/material/Typography';
|
@@ -9,7 +9,7 @@ import React, {
|
|
9
9
|
} from 'react';
|
10
10
|
import Skeleton from '@mui/material/Skeleton';
|
11
11
|
import TableCell from '@mui/material/TableCell';
|
12
|
-
import {
|
12
|
+
import { useTheme } from '@mui/material/styles';
|
13
13
|
import { MRT_EditCellTextField } from '../inputs/MRT_EditCellTextField';
|
14
14
|
import { MRT_CopyButton } from '../buttons/MRT_CopyButton';
|
15
15
|
import { MRT_TableBodyRowGrabHandle } from './MRT_TableBodyRowGrabHandle';
|
@@ -24,7 +24,6 @@ import type { MRT_Cell, MRT_TableInstance } from '..';
|
|
24
24
|
|
25
25
|
interface Props {
|
26
26
|
cell: MRT_Cell;
|
27
|
-
enableHover?: boolean;
|
28
27
|
measureElement?: (element: HTMLTableCellElement) => void;
|
29
28
|
numRows: number;
|
30
29
|
rowIndex: number;
|
@@ -35,7 +34,6 @@ interface Props {
|
|
35
34
|
|
36
35
|
export const MRT_TableBodyCell = ({
|
37
36
|
cell,
|
38
|
-
enableHover,
|
39
37
|
measureElement,
|
40
38
|
numRows,
|
41
39
|
rowIndex,
|
@@ -237,14 +235,11 @@ export const MRT_TableBodyCell = ({
|
|
237
235
|
zIndex:
|
238
236
|
draggingColumn?.id === column.id ? 2 : column.getIsPinned() ? 1 : 0,
|
239
237
|
'&:hover': {
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
? `${lighten(theme.palette.background.default, 0.2)} !important`
|
246
|
-
: `${darken(theme.palette.background.default, 0.1)} !important`
|
247
|
-
: undefined,
|
238
|
+
outline: ['table', 'cell'].includes(editingMode ?? '')
|
239
|
+
? `1px solid ${theme.palette.text.secondary}`
|
240
|
+
: undefined,
|
241
|
+
outlineOffset: '-1px',
|
242
|
+
textOverflow: 'clip',
|
248
243
|
},
|
249
244
|
...getCommonCellStyles({
|
250
245
|
column,
|
@@ -296,10 +291,10 @@ export const MRT_TableBodyCell = ({
|
|
296
291
|
) : (
|
297
292
|
<MRT_TableBodyCellValue cell={cell} table={table} />
|
298
293
|
)}
|
294
|
+
{cell.getIsGrouped() && !columnDef.GroupedCell && (
|
295
|
+
<> ({row.subRows?.length})</>
|
296
|
+
)}
|
299
297
|
</>
|
300
|
-
{cell.getIsGrouped() && !columnDef.GroupedCell && (
|
301
|
-
<> ({row.subRows?.length})</>
|
302
|
-
)}
|
303
298
|
</TableCell>
|
304
299
|
);
|
305
300
|
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React, { DragEvent, memo, useRef } from 'react';
|
2
2
|
import TableRow from '@mui/material/TableRow';
|
3
|
-
import { darken, lighten } from '@mui/material/styles';
|
3
|
+
import { alpha, darken, lighten } from '@mui/material/styles';
|
4
4
|
import { Memo_MRT_TableBodyCell, MRT_TableBodyCell } from './MRT_TableBodyCell';
|
5
5
|
import { MRT_TableDetailPanel } from './MRT_TableDetailPanel';
|
6
6
|
import type { VirtualItem, Virtualizer } from '@tanstack/react-virtual';
|
@@ -32,7 +32,6 @@ export const MRT_TableBodyRow = ({
|
|
32
32
|
virtualRow,
|
33
33
|
}: Props) => {
|
34
34
|
const {
|
35
|
-
getIsSomeColumnsPinned,
|
36
35
|
getState,
|
37
36
|
options: {
|
38
37
|
enableRowOrdering,
|
@@ -63,7 +62,6 @@ export const MRT_TableBodyRow = ({
|
|
63
62
|
<>
|
64
63
|
<TableRow
|
65
64
|
data-index={virtualRow?.index}
|
66
|
-
hover
|
67
65
|
onDragEnter={handleDragEnter}
|
68
66
|
selected={row.getIsSelected()}
|
69
67
|
ref={(node: HTMLTableRowElement) => {
|
@@ -87,8 +85,10 @@ export const MRT_TableBodyRow = ({
|
|
87
85
|
width: '100%',
|
88
86
|
'&:hover td': {
|
89
87
|
backgroundColor:
|
90
|
-
tableRowProps?.hover !== false
|
91
|
-
?
|
88
|
+
tableRowProps?.hover !== false
|
89
|
+
? row.getIsSelected()
|
90
|
+
? `${alpha(theme.palette.primary.main, 0.2)}`
|
91
|
+
: theme.palette.mode === 'dark'
|
92
92
|
? `${lighten(theme.palette.background.default, 0.12)}`
|
93
93
|
: `${darken(theme.palette.background.default, 0.05)}`
|
94
94
|
: undefined,
|
@@ -107,7 +107,6 @@ export const MRT_TableBodyRow = ({
|
|
107
107
|
: (cellOrVirtualCell as MRT_Cell);
|
108
108
|
const props = {
|
109
109
|
cell,
|
110
|
-
enableHover: tableRowProps?.hover !== false,
|
111
110
|
key: cell.id,
|
112
111
|
measureElement: columnVirtualizer?.measureElement,
|
113
112
|
numRows,
|
package/src/column.utils.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
import type { Row } from '@tanstack/react-table';
|
2
1
|
import { MRT_AggregationFns } from './aggregationFns';
|
3
2
|
import { MRT_FilterFns } from './filterFns';
|
4
3
|
import { MRT_SortingFns } from './sortingFns';
|
5
4
|
import { alpha, lighten } from '@mui/material/styles';
|
5
|
+
import type { Row } from '@tanstack/react-table';
|
6
6
|
import type { TableCellProps } from '@mui/material/TableCell';
|
7
7
|
import type { Theme } from '@mui/material/styles';
|
8
8
|
import type {
|
package/src/filterFns.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { rankItem, rankings, RankingInfo } from '@tanstack/match-sorter-utils';
|
2
|
-
import { filterFns, Row } from '@tanstack/react-table';
|
2
|
+
import { filterFns, type Row } from '@tanstack/react-table';
|
3
3
|
|
4
4
|
const fuzzy = <TData extends Record<string, any> = {}>(
|
5
5
|
row: Row<TData>,
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
2
2
|
import TableRow from '@mui/material/TableRow';
|
3
3
|
import { lighten } from '@mui/material/styles';
|
4
4
|
import { MRT_TableFooterCell } from './MRT_TableFooterCell';
|
5
|
-
import { VirtualItem } from '@tanstack/react-virtual';
|
5
|
+
import type { VirtualItem } from '@tanstack/react-virtual';
|
6
6
|
import type { MRT_Header, MRT_HeaderGroup, MRT_TableInstance } from '..';
|
7
7
|
|
8
8
|
interface Props {
|
@@ -213,10 +213,14 @@ export const MRT_TableHeadCell = ({ header, table }: Props) => {
|
|
213
213
|
<Box
|
214
214
|
className="Mui-TableHeadCell-Content-Wrapper"
|
215
215
|
sx={{
|
216
|
+
minWidth: '5ch',
|
216
217
|
overflow: columnDefType === 'data' ? 'hidden' : undefined,
|
217
218
|
textOverflow: 'ellipsis',
|
218
219
|
whiteSpace:
|
219
220
|
(columnDef.header?.length ?? 0) < 20 ? 'nowrap' : 'normal',
|
221
|
+
'&:hover': {
|
222
|
+
textOverflow: 'clip',
|
223
|
+
},
|
220
224
|
}}
|
221
225
|
title={columnDefType === 'data' ? columnDef.header : undefined}
|
222
226
|
>
|
@@ -31,7 +31,7 @@ export const MRT_TableHeadCellResizeHandle = ({ header, table }: Props) => {
|
|
31
31
|
onTouchStart={header.getResizeHandler()}
|
32
32
|
sx={(theme) => ({
|
33
33
|
cursor: 'col-resize',
|
34
|
-
mr: density === 'compact' ? '-0.
|
34
|
+
mr: density === 'compact' ? '-0.75rem' : '-1rem',
|
35
35
|
position: 'absolute',
|
36
36
|
right: '1px',
|
37
37
|
px: '4px',
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
+
import Badge from '@mui/material/Badge';
|
2
3
|
import TableSortLabel from '@mui/material/TableSortLabel';
|
3
4
|
import Tooltip from '@mui/material/Tooltip';
|
4
5
|
import { MRT_Header, MRT_TableInstance } from '..';
|
@@ -16,6 +17,7 @@ export const MRT_TableHeadCellSortLabel = ({
|
|
16
17
|
tableCellProps,
|
17
18
|
}: Props) => {
|
18
19
|
const {
|
20
|
+
getState,
|
19
21
|
options: {
|
20
22
|
icons: { ArrowDownwardIcon },
|
21
23
|
localization,
|
@@ -23,6 +25,7 @@ export const MRT_TableHeadCellSortLabel = ({
|
|
23
25
|
} = table;
|
24
26
|
const { column } = header;
|
25
27
|
const { columnDef } = column;
|
28
|
+
const { sorting } = getState();
|
26
29
|
|
27
30
|
const sortTooltip = column.getIsSorted()
|
28
31
|
? column.getIsSorted() === 'desc'
|
@@ -32,28 +35,33 @@ export const MRT_TableHeadCellSortLabel = ({
|
|
32
35
|
|
33
36
|
return (
|
34
37
|
<Tooltip arrow placement="top" title={sortTooltip}>
|
35
|
-
<
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
38
|
+
<Badge
|
39
|
+
badgeContent={sorting.length > 1 ? column.getSortIndex() + 1 : 0}
|
40
|
+
overlap="circular"
|
41
|
+
>
|
42
|
+
<TableSortLabel
|
43
|
+
aria-label={sortTooltip}
|
44
|
+
active={!!column.getIsSorted()}
|
45
|
+
direction={
|
46
|
+
column.getIsSorted()
|
47
|
+
? (column.getIsSorted() as 'asc' | 'desc')
|
48
|
+
: undefined
|
49
|
+
}
|
50
|
+
sx={{
|
51
|
+
flex: '0 0',
|
52
|
+
width: '2.4ch',
|
53
|
+
transform:
|
54
|
+
tableCellProps?.align !== 'right'
|
55
|
+
? 'translateX(-0.5ch)'
|
56
|
+
: undefined,
|
57
|
+
}}
|
58
|
+
IconComponent={ArrowDownwardIcon}
|
59
|
+
onClick={(e) => {
|
60
|
+
e.stopPropagation();
|
61
|
+
header.column.getToggleSortingHandler()?.(e);
|
62
|
+
}}
|
63
|
+
/>
|
64
|
+
</Badge>
|
57
65
|
</Tooltip>
|
58
66
|
);
|
59
67
|
};
|
@@ -149,7 +149,7 @@ export const MRT_FilterTextField = ({
|
|
149
149
|
} else if (isRangeFilter) {
|
150
150
|
setFilterValue('');
|
151
151
|
column.setFilterValue((old: [string | undefined, string | undefined]) => {
|
152
|
-
const newFilterValues = old
|
152
|
+
const newFilterValues = (Array.isArray(old) && old) || ['', ''];
|
153
153
|
newFilterValues[rangeFilterIndex as number] = undefined;
|
154
154
|
return newFilterValues;
|
155
155
|
});
|
@@ -99,6 +99,10 @@ export const mrtFilterOptions = (
|
|
99
99
|
},
|
100
100
|
];
|
101
101
|
|
102
|
+
const rangeModes = ['between', 'betweenInclusive', 'inNumberRange'];
|
103
|
+
const emptyModes = ['empty', 'notEmpty'];
|
104
|
+
const arrModes = ['arrIncludesSome', 'arrIncludesAll', 'arrIncludes'];
|
105
|
+
|
102
106
|
interface Props<TData extends Record<string, any> = {}> {
|
103
107
|
anchorEl: HTMLElement | null;
|
104
108
|
header?: MRT_Header<TData>;
|
@@ -150,48 +154,66 @@ export const MRT_FilterOptionMenu = <TData extends Record<string, any> = {}>({
|
|
150
154
|
);
|
151
155
|
|
152
156
|
const handleSelectFilterMode = (option: MRT_FilterOption) => {
|
153
|
-
|
157
|
+
const prevFilterMode = columnDef?._filterFn ?? '';
|
158
|
+
if (!header || !column) {
|
159
|
+
// global filter mode
|
160
|
+
setGlobalFilterFn(option);
|
161
|
+
} else if (option !== prevFilterMode) {
|
162
|
+
// column filter mode
|
154
163
|
setColumnFilterFns((prev: { [key: string]: any }) => ({
|
155
164
|
...prev,
|
156
165
|
[header.id]: option,
|
157
166
|
}));
|
158
|
-
|
159
|
-
|
167
|
+
|
168
|
+
// reset filter value and/or perform new filter render
|
169
|
+
if (emptyModes.includes(option)) {
|
170
|
+
// will now be empty/notEmpty filter mode
|
171
|
+
if (
|
172
|
+
currentFilterValue !== ' ' &&
|
173
|
+
!emptyModes.includes(prevFilterMode)
|
174
|
+
) {
|
160
175
|
column.setFilterValue(' ');
|
176
|
+
} else if (currentFilterValue) {
|
177
|
+
column.setFilterValue(currentFilterValue); // perform new filter render
|
161
178
|
}
|
162
179
|
} else if (
|
163
180
|
columnDef?.filterVariant === 'multi-select' ||
|
164
|
-
|
165
|
-
option as string,
|
166
|
-
)
|
181
|
+
arrModes.includes(option as string)
|
167
182
|
) {
|
183
|
+
// will now be array filter mode
|
168
184
|
if (
|
169
185
|
currentFilterValue instanceof String ||
|
170
186
|
(currentFilterValue as Array<any>)?.length
|
171
187
|
) {
|
172
188
|
column.setFilterValue([]);
|
173
189
|
setFilterValue?.([]);
|
190
|
+
} else if (currentFilterValue) {
|
191
|
+
column.setFilterValue(currentFilterValue); // perform new filter render
|
174
192
|
}
|
175
193
|
} else if (
|
176
194
|
columnDef?.filterVariant === 'range' ||
|
177
|
-
|
178
|
-
option as MRT_FilterOption,
|
179
|
-
)
|
195
|
+
rangeModes.includes(option as MRT_FilterOption)
|
180
196
|
) {
|
181
|
-
|
197
|
+
// will now be range filter mode
|
198
|
+
if (
|
199
|
+
!Array.isArray(currentFilterValue) ||
|
200
|
+
(!(currentFilterValue as Array<any>)?.every((v) => v === '') &&
|
201
|
+
!rangeModes.includes(prevFilterMode))
|
202
|
+
) {
|
182
203
|
column.setFilterValue(['', '']);
|
183
204
|
setFilterValue?.('');
|
205
|
+
} else {
|
206
|
+
column.setFilterValue(currentFilterValue); // perform new filter render
|
184
207
|
}
|
185
208
|
} else {
|
186
|
-
|
187
|
-
|
188
|
-
) {
|
209
|
+
// will now be single value filter mode
|
210
|
+
if (Array.isArray(currentFilterValue)) {
|
189
211
|
column.setFilterValue('');
|
190
212
|
setFilterValue?.('');
|
213
|
+
} else {
|
214
|
+
column.setFilterValue(currentFilterValue); // perform new filter render
|
191
215
|
}
|
192
216
|
}
|
193
|
-
} else {
|
194
|
-
setGlobalFilterFn(option);
|
195
217
|
}
|
196
218
|
setAnchorEl(null);
|
197
219
|
onSelect?.();
|
@@ -98,8 +98,9 @@ export const MRT_ShowHideColumnsMenuItems = <
|
|
98
98
|
justifyContent: 'flex-start',
|
99
99
|
my: 0,
|
100
100
|
opacity: isDragging ? 0.5 : 1,
|
101
|
+
outlineOffset: '-2px',
|
101
102
|
outline: isDragging
|
102
|
-
? `
|
103
|
+
? `2px dashed ${theme.palette.divider}`
|
103
104
|
: hoveredColumn?.id === column.id
|
104
105
|
? `2px dashed ${theme.palette.primary.main}`
|
105
106
|
: 'none',
|
package/src/sortingFns.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import { compareItems, RankingInfo } from '@tanstack/match-sorter-utils';
|
2
|
-
import { Row, sortingFns } from '@tanstack/react-table';
|
3
|
-
import { MRT_Row } from '.';
|
1
|
+
import { compareItems, type RankingInfo } from '@tanstack/match-sorter-utils';
|
2
|
+
import { type Row, sortingFns } from '@tanstack/react-table';
|
3
|
+
import type { MRT_Row } from '.';
|
4
4
|
|
5
5
|
const fuzzy = <TData extends Record<string, any> = {}>(
|
6
6
|
rowA: Row<TData>,
|
package/src/table/MRT_Table.tsx
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import React, { useCallback, useMemo } from 'react';
|
2
2
|
import {
|
3
3
|
defaultRangeExtractor,
|
4
|
-
Range,
|
5
4
|
useVirtualizer,
|
6
|
-
|
5
|
+
type Range,
|
6
|
+
type Virtualizer,
|
7
7
|
} from '@tanstack/react-virtual';
|
8
8
|
import Table from '@mui/material/Table';
|
9
9
|
import { MRT_TableHead } from '../head/MRT_TableHead';
|