material-react-table 2.11.3 → 2.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -22
- package/dist/index.d.ts +19 -2
- package/dist/index.esm.js +136 -105
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +137 -104
- package/dist/index.js.map +1 -1
- package/locales/hr/index.d.ts +3 -0
- package/locales/hr/index.esm.d.ts +3 -0
- package/locales/hr/index.esm.js +95 -0
- package/locales/hr/index.js +99 -0
- package/locales/hr/package.json +6 -0
- package/package.json +25 -25
- package/src/components/body/MRT_TableBodyCell.tsx +7 -0
- package/src/components/body/MRT_TableBodyRow.tsx +5 -0
- package/src/components/body/MRT_TableDetailPanel.tsx +2 -5
- package/src/components/head/MRT_TableHead.tsx +11 -11
- package/src/components/head/MRT_TableHeadCell.tsx +7 -0
- package/src/components/head/MRT_TableHeadCellFilterContainer.tsx +3 -4
- package/src/components/head/MRT_TableHeadCellFilterLabel.tsx +61 -37
- package/src/components/inputs/MRT_FilterRangeFields.tsx +8 -2
- package/src/components/inputs/MRT_FilterTextField.tsx +41 -63
- package/src/components/menus/MRT_ShowHideColumnsMenuItems.tsx +1 -4
- package/src/components/table/MRT_TablePaper.tsx +4 -4
- package/src/components/toolbar/MRT_TablePagination.tsx +10 -12
- package/src/components/toolbar/MRT_ToolbarDropZone.tsx +5 -0
- package/src/hooks/display-columns/getMRT_RowActionsColumnDef.tsx +1 -1
- package/src/hooks/display-columns/getMRT_RowDragColumnDef.tsx +1 -1
- package/src/hooks/display-columns/getMRT_RowExpandColumnDef.tsx +1 -1
- package/src/hooks/display-columns/getMRT_RowNumbersColumnDef.tsx +1 -1
- package/src/hooks/display-columns/getMRT_RowPinningColumnDef.tsx +1 -1
- package/src/hooks/display-columns/getMRT_RowSelectColumnDef.tsx +1 -1
- package/src/hooks/display-columns/getMRT_RowSpacerColumnDef.tsx +1 -1
- package/src/hooks/useMRT_ColumnVirtualizer.ts +6 -8
- package/src/locales/hr.ts +96 -0
- package/src/types.ts +0 -1
- package/src/utils/column.utils.ts +86 -0
- package/src/utils/utils.ts +1 -1
@@ -0,0 +1,95 @@
|
|
1
|
+
const MRT_Localization_HR = {
|
2
|
+
actions: 'Radnje',
|
3
|
+
and: 'i',
|
4
|
+
cancel: 'Odustani',
|
5
|
+
changeFilterMode: 'Promijeni način filtriranja',
|
6
|
+
changeSearchMode: 'Promijeni način pretraživanja',
|
7
|
+
clearFilter: 'Očisti filtriranje',
|
8
|
+
clearSearch: 'Očisti pretragu',
|
9
|
+
clearSelection: 'Očisti odabir',
|
10
|
+
clearSort: 'Očisti sortiranje',
|
11
|
+
clickToCopy: 'Klikni za kopiranje',
|
12
|
+
copy: 'Kopiraj',
|
13
|
+
collapse: 'Sažmi',
|
14
|
+
collapseAll: 'Sažmi sve',
|
15
|
+
columnActions: 'Radnje s stupcima',
|
16
|
+
copiedToClipboard: 'Kopirano u međuspremnik',
|
17
|
+
dropToGroupBy: 'Ispusti za grupiranje po {column}',
|
18
|
+
edit: 'Uredi',
|
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: 'Između uključivo',
|
26
|
+
filterByColumn: 'Filtriraj po {column}',
|
27
|
+
filterContains: 'Sadrži',
|
28
|
+
filterEmpty: 'Prazno',
|
29
|
+
filterEndsWith: 'Završava s',
|
30
|
+
filterEquals: 'Jednako',
|
31
|
+
filterEqualsString: 'Jednako',
|
32
|
+
filterFuzzy: 'Maglovito',
|
33
|
+
filterGreaterThan: 'Veće od',
|
34
|
+
filterGreaterThanOrEqualTo: 'Veće od ili jednako',
|
35
|
+
filterInNumberRange: 'Između',
|
36
|
+
filterIncludesString: 'Sadrži',
|
37
|
+
filterIncludesStringSensitive: 'Sadrži',
|
38
|
+
filterLessThan: 'Manje od',
|
39
|
+
filterLessThanOrEqualTo: 'Manje od ili jednako',
|
40
|
+
filterMode: 'Način filtriranja: {filterType}',
|
41
|
+
filterNotEmpty: 'Nije prazno',
|
42
|
+
filterNotEquals: 'Nije jednako',
|
43
|
+
filterStartsWith: 'Počinje s',
|
44
|
+
filterWeakEquals: 'Jednako',
|
45
|
+
filteringByColumn: 'Filtriranje po {column} - {filterType} {filterValue}',
|
46
|
+
goToFirstPage: 'Idi na prvu stranicu',
|
47
|
+
goToLastPage: 'Idi na zadnju stranicu',
|
48
|
+
goToNextPage: 'Idi na sljedeću stranicu',
|
49
|
+
goToPreviousPage: 'Idi na prethodnu stranicu',
|
50
|
+
grab: 'Uhvati',
|
51
|
+
groupByColumn: 'Grupiraj po {column}',
|
52
|
+
groupedBy: 'Grupirano po ',
|
53
|
+
hideAll: 'Sakrij sve',
|
54
|
+
hideColumn: 'Sakrij stupac {column}',
|
55
|
+
max: 'Maks.',
|
56
|
+
min: 'Min.',
|
57
|
+
move: 'Premjesti',
|
58
|
+
noRecordsToDisplay: 'Nema zapisa za prikaz',
|
59
|
+
noResultsFound: 'Nema pronađenih rezultata',
|
60
|
+
of: 'od',
|
61
|
+
or: 'ili',
|
62
|
+
pin: 'Prikači',
|
63
|
+
pinToLeft: 'Prikači na lijevo',
|
64
|
+
pinToRight: 'Prikači na desno',
|
65
|
+
resetColumnSize: 'Resetiraj veličinu stupca',
|
66
|
+
resetOrder: 'Resetiraj redoslijed',
|
67
|
+
rowActions: 'Radnje retka',
|
68
|
+
rowNumber: '#',
|
69
|
+
rowNumbers: 'Brojevi redaka',
|
70
|
+
rowsPerPage: 'Redaka po stranici',
|
71
|
+
save: 'Spremi',
|
72
|
+
search: 'Pretraži',
|
73
|
+
selectedCountOfRowCountRowsSelected: '{selectedCount} od {rowCount} odabranih redaka',
|
74
|
+
select: 'Odaberi',
|
75
|
+
showAll: 'Prikaži sve',
|
76
|
+
showAllColumns: 'Prikaži sve stupce',
|
77
|
+
showHideColumns: 'Prikaži/sakrij stupce',
|
78
|
+
showHideFilters: 'Prikaži/sakrij filtere',
|
79
|
+
showHideSearch: 'Prikaži/sakrij pretragu',
|
80
|
+
sortByColumnAsc: 'Sortiraj po {column} uzlazno',
|
81
|
+
sortByColumnDesc: 'Sortiraj po {column} silazno',
|
82
|
+
sortedByColumnAsc: 'Sortirano po {column} uzlazno',
|
83
|
+
sortedByColumnDesc: 'Sortirano po {column} silazno',
|
84
|
+
thenBy: ', zatim po ',
|
85
|
+
toggleDensity: 'Promijeni gustoću',
|
86
|
+
toggleFullScreen: 'Prebaci u puni zaslon',
|
87
|
+
toggleSelectAll: 'Prebaci odabir svih',
|
88
|
+
toggleSelectRow: 'Prebaci odabir retka',
|
89
|
+
toggleVisibility: 'Prebaci vidljivost',
|
90
|
+
ungroupByColumn: 'Razgrupiraj po {column}',
|
91
|
+
unpin: 'Odkači',
|
92
|
+
unpinAll: 'Odkači sve',
|
93
|
+
};
|
94
|
+
|
95
|
+
export { MRT_Localization_HR };
|
@@ -0,0 +1,99 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
const MRT_Localization_HR = {
|
6
|
+
actions: 'Radnje',
|
7
|
+
and: 'i',
|
8
|
+
cancel: 'Odustani',
|
9
|
+
changeFilterMode: 'Promijeni način filtriranja',
|
10
|
+
changeSearchMode: 'Promijeni način pretraživanja',
|
11
|
+
clearFilter: 'Očisti filtriranje',
|
12
|
+
clearSearch: 'Očisti pretragu',
|
13
|
+
clearSelection: 'Očisti odabir',
|
14
|
+
clearSort: 'Očisti sortiranje',
|
15
|
+
clickToCopy: 'Klikni za kopiranje',
|
16
|
+
copy: 'Kopiraj',
|
17
|
+
collapse: 'Sažmi',
|
18
|
+
collapseAll: 'Sažmi sve',
|
19
|
+
columnActions: 'Radnje s stupcima',
|
20
|
+
copiedToClipboard: 'Kopirano u međuspremnik',
|
21
|
+
dropToGroupBy: 'Ispusti za grupiranje po {column}',
|
22
|
+
edit: 'Uredi',
|
23
|
+
expand: 'Proširi',
|
24
|
+
expandAll: 'Proširi sve',
|
25
|
+
filterArrIncludes: 'Uključuje',
|
26
|
+
filterArrIncludesAll: 'Uključuje sve',
|
27
|
+
filterArrIncludesSome: 'Uključuje',
|
28
|
+
filterBetween: 'Između',
|
29
|
+
filterBetweenInclusive: 'Između uključivo',
|
30
|
+
filterByColumn: 'Filtriraj po {column}',
|
31
|
+
filterContains: 'Sadrži',
|
32
|
+
filterEmpty: 'Prazno',
|
33
|
+
filterEndsWith: 'Završava s',
|
34
|
+
filterEquals: 'Jednako',
|
35
|
+
filterEqualsString: 'Jednako',
|
36
|
+
filterFuzzy: 'Maglovito',
|
37
|
+
filterGreaterThan: 'Veće od',
|
38
|
+
filterGreaterThanOrEqualTo: 'Veće od ili jednako',
|
39
|
+
filterInNumberRange: 'Između',
|
40
|
+
filterIncludesString: 'Sadrži',
|
41
|
+
filterIncludesStringSensitive: 'Sadrži',
|
42
|
+
filterLessThan: 'Manje od',
|
43
|
+
filterLessThanOrEqualTo: 'Manje od ili jednako',
|
44
|
+
filterMode: 'Način filtriranja: {filterType}',
|
45
|
+
filterNotEmpty: 'Nije prazno',
|
46
|
+
filterNotEquals: 'Nije jednako',
|
47
|
+
filterStartsWith: 'Počinje s',
|
48
|
+
filterWeakEquals: 'Jednako',
|
49
|
+
filteringByColumn: 'Filtriranje po {column} - {filterType} {filterValue}',
|
50
|
+
goToFirstPage: 'Idi na prvu stranicu',
|
51
|
+
goToLastPage: 'Idi na zadnju stranicu',
|
52
|
+
goToNextPage: 'Idi na sljedeću stranicu',
|
53
|
+
goToPreviousPage: 'Idi na prethodnu stranicu',
|
54
|
+
grab: 'Uhvati',
|
55
|
+
groupByColumn: 'Grupiraj po {column}',
|
56
|
+
groupedBy: 'Grupirano po ',
|
57
|
+
hideAll: 'Sakrij sve',
|
58
|
+
hideColumn: 'Sakrij stupac {column}',
|
59
|
+
max: 'Maks.',
|
60
|
+
min: 'Min.',
|
61
|
+
move: 'Premjesti',
|
62
|
+
noRecordsToDisplay: 'Nema zapisa za prikaz',
|
63
|
+
noResultsFound: 'Nema pronađenih rezultata',
|
64
|
+
of: 'od',
|
65
|
+
or: 'ili',
|
66
|
+
pin: 'Prikači',
|
67
|
+
pinToLeft: 'Prikači na lijevo',
|
68
|
+
pinToRight: 'Prikači na desno',
|
69
|
+
resetColumnSize: 'Resetiraj veličinu stupca',
|
70
|
+
resetOrder: 'Resetiraj redoslijed',
|
71
|
+
rowActions: 'Radnje retka',
|
72
|
+
rowNumber: '#',
|
73
|
+
rowNumbers: 'Brojevi redaka',
|
74
|
+
rowsPerPage: 'Redaka po stranici',
|
75
|
+
save: 'Spremi',
|
76
|
+
search: 'Pretraži',
|
77
|
+
selectedCountOfRowCountRowsSelected: '{selectedCount} od {rowCount} odabranih redaka',
|
78
|
+
select: 'Odaberi',
|
79
|
+
showAll: 'Prikaži sve',
|
80
|
+
showAllColumns: 'Prikaži sve stupce',
|
81
|
+
showHideColumns: 'Prikaži/sakrij stupce',
|
82
|
+
showHideFilters: 'Prikaži/sakrij filtere',
|
83
|
+
showHideSearch: 'Prikaži/sakrij pretragu',
|
84
|
+
sortByColumnAsc: 'Sortiraj po {column} uzlazno',
|
85
|
+
sortByColumnDesc: 'Sortiraj po {column} silazno',
|
86
|
+
sortedByColumnAsc: 'Sortirano po {column} uzlazno',
|
87
|
+
sortedByColumnDesc: 'Sortirano po {column} silazno',
|
88
|
+
thenBy: ', zatim po ',
|
89
|
+
toggleDensity: 'Promijeni gustoću',
|
90
|
+
toggleFullScreen: 'Prebaci u puni zaslon',
|
91
|
+
toggleSelectAll: 'Prebaci odabir svih',
|
92
|
+
toggleSelectRow: 'Prebaci odabir retka',
|
93
|
+
toggleVisibility: 'Prebaci vidljivost',
|
94
|
+
ungroupByColumn: 'Razgrupiraj po {column}',
|
95
|
+
unpin: 'Odkači',
|
96
|
+
unpinAll: 'Odkači sve',
|
97
|
+
};
|
98
|
+
|
99
|
+
exports.MRT_Localization_HR = MRT_Localization_HR;
|
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"version": "2.
|
2
|
+
"version": "2.12.1",
|
3
3
|
"license": "MIT",
|
4
4
|
"name": "material-react-table",
|
5
5
|
"description": "A fully featured Material UI V5 implementation of TanStack React Table V8, written from the ground up in TypeScript.",
|
@@ -61,32 +61,32 @@
|
|
61
61
|
"storybook:dev": "storybook dev -p 6006"
|
62
62
|
},
|
63
63
|
"devDependencies": {
|
64
|
-
"@babel/core": "^7.
|
64
|
+
"@babel/core": "^7.24.0",
|
65
65
|
"@babel/preset-react": "^7.23.3",
|
66
|
-
"@emotion/react": "^11.11.
|
66
|
+
"@emotion/react": "^11.11.4",
|
67
67
|
"@emotion/styled": "^11.11.0",
|
68
68
|
"@faker-js/faker": "^8.4.1",
|
69
|
-
"@mui/icons-material": "^5.15.
|
70
|
-
"@mui/material": "^5.15.
|
71
|
-
"@mui/x-date-pickers": "^6.19.
|
69
|
+
"@mui/icons-material": "^5.15.11",
|
70
|
+
"@mui/material": "^5.15.11",
|
71
|
+
"@mui/x-date-pickers": "^6.19.5",
|
72
72
|
"@rollup/plugin-typescript": "^11.1.6",
|
73
73
|
"@size-limit/preset-small-lib": "^11.0.2",
|
74
|
-
"@storybook/addon-a11y": "^7.6.
|
75
|
-
"@storybook/addon-essentials": "^7.6.
|
76
|
-
"@storybook/addon-interactions": "^7.6.
|
77
|
-
"@storybook/addon-links": "^7.6.
|
78
|
-
"@storybook/addon-storysource": "^7.6.
|
79
|
-
"@storybook/blocks": "^7.6.
|
80
|
-
"@storybook/react": "^7.6.
|
81
|
-
"@storybook/react-vite": "^7.6.
|
74
|
+
"@storybook/addon-a11y": "^7.6.17",
|
75
|
+
"@storybook/addon-essentials": "^7.6.17",
|
76
|
+
"@storybook/addon-interactions": "^7.6.17",
|
77
|
+
"@storybook/addon-links": "^7.6.17",
|
78
|
+
"@storybook/addon-storysource": "^7.6.17",
|
79
|
+
"@storybook/blocks": "^7.6.17",
|
80
|
+
"@storybook/react": "^7.6.17",
|
81
|
+
"@storybook/react-vite": "^7.6.17",
|
82
82
|
"@storybook/testing-library": "^0.2.2",
|
83
|
-
"@types/node": "^20.11.
|
84
|
-
"@types/react": "^18.2.
|
83
|
+
"@types/node": "^20.11.22",
|
84
|
+
"@types/react": "^18.2.60",
|
85
85
|
"@types/react-dom": "^18.2.19",
|
86
|
-
"@typescript-eslint/eslint-plugin": "^7.0
|
87
|
-
"@typescript-eslint/parser": "^7.0
|
86
|
+
"@typescript-eslint/eslint-plugin": "^7.1.0",
|
87
|
+
"@typescript-eslint/parser": "^7.1.0",
|
88
88
|
"@vitejs/plugin-react": "^4.2.1",
|
89
|
-
"eslint": "^8.
|
89
|
+
"eslint": "^8.57.0",
|
90
90
|
"eslint-plugin-mui-path-imports": "^0.0.15",
|
91
91
|
"eslint-plugin-perfectionist": "^2.5.0",
|
92
92
|
"prop-types": "^15.8.1",
|
@@ -99,11 +99,11 @@
|
|
99
99
|
"rollup-plugin-dts": "^6.1.0",
|
100
100
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
101
101
|
"size-limit": "^11.0.2",
|
102
|
-
"storybook": "^7.6.
|
102
|
+
"storybook": "^7.6.17",
|
103
103
|
"storybook-dark-mode": "^3.0.3",
|
104
104
|
"tslib": "^2.6.2",
|
105
105
|
"typescript": "^5.3.3",
|
106
|
-
"vite": "^5.1.
|
106
|
+
"vite": "^5.1.4"
|
107
107
|
},
|
108
108
|
"peerDependencies": {
|
109
109
|
"@emotion/react": ">=11.11",
|
@@ -111,13 +111,13 @@
|
|
111
111
|
"@mui/icons-material": ">=5.11",
|
112
112
|
"@mui/material": ">=5.13",
|
113
113
|
"@mui/x-date-pickers": ">=6.15.0",
|
114
|
-
"react": ">=
|
115
|
-
"react-dom": ">=
|
114
|
+
"react": ">=17.0",
|
115
|
+
"react-dom": ">=17.0"
|
116
116
|
},
|
117
117
|
"dependencies": {
|
118
118
|
"@tanstack/match-sorter-utils": "8.11.8",
|
119
|
-
"@tanstack/react-table": "8.
|
120
|
-
"@tanstack/react-virtual": "3.
|
119
|
+
"@tanstack/react-table": "8.13.2",
|
120
|
+
"@tanstack/react-virtual": "3.1.3",
|
121
121
|
"highlight-words": "1.2.2"
|
122
122
|
}
|
123
123
|
}
|
@@ -210,6 +210,12 @@ export const MRT_TableBodyCell = <TData extends MRT_RowData>({
|
|
210
210
|
}
|
211
211
|
};
|
212
212
|
|
213
|
+
const handleDragOver = (e: DragEvent) => {
|
214
|
+
if (columnDef.enableColumnOrdering !== false) {
|
215
|
+
e.preventDefault();
|
216
|
+
}
|
217
|
+
};
|
218
|
+
|
213
219
|
const handleContextMenu = (e: MouseEvent<HTMLTableCellElement>) => {
|
214
220
|
tableCellProps?.onContextMenu?.(e);
|
215
221
|
if (isRightClickable) {
|
@@ -228,6 +234,7 @@ export const MRT_TableBodyCell = <TData extends MRT_RowData>({
|
|
228
234
|
onContextMenu={handleContextMenu}
|
229
235
|
onDoubleClick={handleDoubleClick}
|
230
236
|
onDragEnter={handleDragEnter}
|
237
|
+
onDragOver={handleDragOver}
|
231
238
|
sx={(theme) => ({
|
232
239
|
'&:hover': {
|
233
240
|
outline:
|
@@ -140,6 +140,10 @@ export const MRT_TableBodyRow = <TData extends MRT_RowData>({
|
|
140
140
|
}
|
141
141
|
};
|
142
142
|
|
143
|
+
const handleDragOver = (e: DragEvent) => {
|
144
|
+
e.preventDefault();
|
145
|
+
};
|
146
|
+
|
143
147
|
const rowRef = useRef<HTMLTableRowElement | null>(null);
|
144
148
|
|
145
149
|
const cellHighlightColor = isRowSelected
|
@@ -164,6 +168,7 @@ export const MRT_TableBodyRow = <TData extends MRT_RowData>({
|
|
164
168
|
data-pinned={!!isRowPinned || undefined}
|
165
169
|
data-selected={isRowSelected || undefined}
|
166
170
|
onDragEnter={handleDragEnter}
|
171
|
+
onDragOver={handleDragOver}
|
167
172
|
ref={(node: HTMLTableRowElement) => {
|
168
173
|
if (node) {
|
169
174
|
rowRef.current = node;
|
@@ -34,7 +34,6 @@ export const MRT_TableDetailPanel = <TData extends MRT_RowData>({
|
|
34
34
|
getState,
|
35
35
|
getVisibleLeafColumns,
|
36
36
|
options: {
|
37
|
-
enableRowVirtualization,
|
38
37
|
layoutMode,
|
39
38
|
mrtTheme: { baseBackgroundColor },
|
40
39
|
muiDetailPanelProps,
|
@@ -93,14 +92,12 @@ export const MRT_TableDetailPanel = <TData extends MRT_RowData>({
|
|
93
92
|
borderBottom: !row.getIsExpanded() ? 'none' : undefined,
|
94
93
|
display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
|
95
94
|
py: !!DetailPanel && row.getIsExpanded() ? '1rem' : 0,
|
96
|
-
transition: !
|
97
|
-
? 'all 150ms ease-in-out'
|
98
|
-
: undefined,
|
95
|
+
transition: !virtualRow ? 'all 150ms ease-in-out' : undefined,
|
99
96
|
width: `100%`,
|
100
97
|
...(parseFromValuesOrFunc(tableCellProps?.sx, theme) as any),
|
101
98
|
})}
|
102
99
|
>
|
103
|
-
{
|
100
|
+
{virtualRow ? (
|
104
101
|
row.getIsExpanded() && DetailPanel
|
105
102
|
) : (
|
106
103
|
<Collapse in={row.getIsExpanded()} mountOnEnter unmountOnExit>
|
@@ -20,8 +20,6 @@ export const MRT_TableHead = <TData extends MRT_RowData>({
|
|
20
20
|
...rest
|
21
21
|
}: MRT_TableHeadProps<TData>) => {
|
22
22
|
const {
|
23
|
-
getHeaderGroups,
|
24
|
-
getSelectedRowModel,
|
25
23
|
getState,
|
26
24
|
options: {
|
27
25
|
enableStickyHeader,
|
@@ -60,7 +58,7 @@ export const MRT_TableHead = <TData extends MRT_RowData>({
|
|
60
58
|
})}
|
61
59
|
>
|
62
60
|
{positionToolbarAlertBanner === 'head-overlay' &&
|
63
|
-
(showAlertBanner || getSelectedRowModel().rows.length > 0) ? (
|
61
|
+
(showAlertBanner || table.getSelectedRowModel().rows.length > 0) ? (
|
64
62
|
<tr
|
65
63
|
style={{
|
66
64
|
display: layoutMode?.startsWith('grid') ? 'grid' : undefined,
|
@@ -77,14 +75,16 @@ export const MRT_TableHead = <TData extends MRT_RowData>({
|
|
77
75
|
</th>
|
78
76
|
</tr>
|
79
77
|
) : (
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
78
|
+
table
|
79
|
+
.getHeaderGroups()
|
80
|
+
.map((headerGroup) => (
|
81
|
+
<MRT_TableHeadRow
|
82
|
+
columnVirtualizer={columnVirtualizer}
|
83
|
+
headerGroup={headerGroup as any}
|
84
|
+
key={headerGroup.id}
|
85
|
+
table={table}
|
86
|
+
/>
|
87
|
+
))
|
88
88
|
)}
|
89
89
|
</TableHead>
|
90
90
|
);
|
@@ -141,6 +141,12 @@ export const MRT_TableHeadCell = <TData extends MRT_RowData>({
|
|
141
141
|
}
|
142
142
|
};
|
143
143
|
|
144
|
+
const handleDragOver = (e: DragEvent) => {
|
145
|
+
if (columnDef.enableColumnOrdering !== false) {
|
146
|
+
e.preventDefault();
|
147
|
+
}
|
148
|
+
};
|
149
|
+
|
144
150
|
const HeaderElement =
|
145
151
|
parseFromValuesOrFunc(columnDef.Header, {
|
146
152
|
column,
|
@@ -161,6 +167,7 @@ export const MRT_TableHeadCell = <TData extends MRT_RowData>({
|
|
161
167
|
data-index={staticColumnIndex}
|
162
168
|
data-pinned={!!isColumnPinned || undefined}
|
163
169
|
onDragEnter={handleDragEnter}
|
170
|
+
onDragOver={handleDragOver}
|
164
171
|
ref={(node: HTMLTableCellElement) => {
|
165
172
|
if (node) {
|
166
173
|
tableHeadCellRefs.current[column.id] = node;
|
@@ -4,6 +4,7 @@ import {
|
|
4
4
|
type MRT_RowData,
|
5
5
|
type MRT_TableInstance,
|
6
6
|
} from '../../types';
|
7
|
+
import { getColumnFilterInfo } from '../../utils/column.utils';
|
7
8
|
import { MRT_FilterCheckbox } from '../inputs/MRT_FilterCheckbox';
|
8
9
|
import { MRT_FilterRangeFields } from '../inputs/MRT_FilterRangeFields';
|
9
10
|
import { MRT_FilterRangeSlider } from '../inputs/MRT_FilterRangeSlider';
|
@@ -28,6 +29,7 @@ export const MRT_TableHeadCellFilterContainer = <TData extends MRT_RowData>({
|
|
28
29
|
const { showColumnFilters } = getState();
|
29
30
|
const { column } = header;
|
30
31
|
const { columnDef } = column;
|
32
|
+
const { isRangeFilter } = getColumnFilterInfo({ header, table });
|
31
33
|
|
32
34
|
return (
|
33
35
|
<Collapse
|
@@ -40,10 +42,7 @@ export const MRT_TableHeadCellFilterContainer = <TData extends MRT_RowData>({
|
|
40
42
|
<MRT_FilterCheckbox column={column} table={table} />
|
41
43
|
) : columnDef.filterVariant === 'range-slider' ? (
|
42
44
|
<MRT_FilterRangeSlider header={header} table={table} />
|
43
|
-
) :
|
44
|
-
['between', 'betweenInclusive', 'inNumberRange'].includes(
|
45
|
-
columnDef._filterFn,
|
46
|
-
) ? (
|
45
|
+
) : isRangeFilter ? (
|
47
46
|
<MRT_FilterRangeFields header={header} table={table} />
|
48
47
|
) : (
|
49
48
|
<MRT_FilterTextField header={header} table={table} />
|
@@ -10,7 +10,11 @@ import {
|
|
10
10
|
type MRT_RowData,
|
11
11
|
type MRT_TableInstance,
|
12
12
|
} from '../../types';
|
13
|
-
import {
|
13
|
+
import {
|
14
|
+
getColumnFilterInfo,
|
15
|
+
useDropdownOptions,
|
16
|
+
} from '../../utils/column.utils';
|
17
|
+
import { getValueAndLabel, parseFromValuesOrFunc } from '../../utils/utils';
|
14
18
|
|
15
19
|
export interface MRT_TableHeadCellFilterLabelProps<TData extends MRT_RowData>
|
16
20
|
extends IconButtonProps {
|
@@ -35,20 +39,32 @@ export const MRT_TableHeadCellFilterLabel = <TData extends MRT_RowData = {}>({
|
|
35
39
|
const { column } = header;
|
36
40
|
const { columnDef } = column;
|
37
41
|
|
38
|
-
const filterValue = column.getFilterValue();
|
42
|
+
const filterValue = column.getFilterValue() as [string, string] | string;
|
39
43
|
|
40
44
|
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
|
41
45
|
|
46
|
+
const {
|
47
|
+
currentFilterOption,
|
48
|
+
isMultiSelectFilter,
|
49
|
+
isRangeFilter,
|
50
|
+
isSelectFilter,
|
51
|
+
} = getColumnFilterInfo({ header, table });
|
52
|
+
|
53
|
+
const dropdownOptions = useDropdownOptions({ header, table });
|
54
|
+
|
55
|
+
const getSelectLabel = (index?: number) =>
|
56
|
+
getValueAndLabel(
|
57
|
+
dropdownOptions?.find(
|
58
|
+
(option) =>
|
59
|
+
getValueAndLabel(option).value ===
|
60
|
+
(index !== undefined ? filterValue[index] : filterValue),
|
61
|
+
),
|
62
|
+
).label;
|
63
|
+
|
42
64
|
const isFilterActive =
|
43
65
|
(Array.isArray(filterValue) && filterValue.some(Boolean)) ||
|
44
66
|
(!!filterValue && !Array.isArray(filterValue));
|
45
67
|
|
46
|
-
const isRangeFilter =
|
47
|
-
columnDef.filterVariant?.includes('range') ||
|
48
|
-
['between', 'betweenInclusive', 'inNumberRange'].includes(
|
49
|
-
columnDef._filterFn,
|
50
|
-
);
|
51
|
-
const currentFilterOption = columnDef._filterFn;
|
52
68
|
const filterTooltip =
|
53
69
|
columnFilterDisplayMode === 'popover' && !isFilterActive
|
54
70
|
? localization.filterByColumn?.replace(
|
@@ -73,10 +89,16 @@ export const MRT_TableHeadCellFilterLabel = <TData extends MRT_RowData = {}>({
|
|
73
89
|
'{filterValue}',
|
74
90
|
`"${
|
75
91
|
Array.isArray(filterValue)
|
76
|
-
? (filterValue as [string, string])
|
77
|
-
|
78
|
-
|
79
|
-
|
92
|
+
? (filterValue as [string, string])
|
93
|
+
.map((value, index) =>
|
94
|
+
isMultiSelectFilter ? getSelectLabel(index) : value,
|
95
|
+
)
|
96
|
+
.join(
|
97
|
+
`" ${isRangeFilter ? localization.and : localization.or} "`,
|
98
|
+
)
|
99
|
+
: isSelectFilter
|
100
|
+
? getSelectLabel()
|
101
|
+
: (filterValue as string)
|
80
102
|
}"`,
|
81
103
|
)
|
82
104
|
.replace('" "', '');
|
@@ -126,31 +148,33 @@ export const MRT_TableHeadCellFilterLabel = <TData extends MRT_RowData = {}>({
|
|
126
148
|
</Tooltip>
|
127
149
|
</Box>
|
128
150
|
</Grow>
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
<
|
152
|
-
|
153
|
-
|
151
|
+
{columnFilterDisplayMode === 'popover' && (
|
152
|
+
<Popover
|
153
|
+
anchorEl={anchorEl}
|
154
|
+
anchorOrigin={{
|
155
|
+
horizontal: 'center',
|
156
|
+
vertical: 'top',
|
157
|
+
}}
|
158
|
+
disableScrollLock
|
159
|
+
onClick={(event) => event.stopPropagation()}
|
160
|
+
onClose={(event) => {
|
161
|
+
//@ts-ignore
|
162
|
+
event.stopPropagation();
|
163
|
+
setAnchorEl(null);
|
164
|
+
}}
|
165
|
+
onKeyDown={(event) => event.key === 'Enter' && setAnchorEl(null)}
|
166
|
+
open={!!anchorEl}
|
167
|
+
slotProps={{ paper: { sx: { overflow: 'visible' } } }}
|
168
|
+
transformOrigin={{
|
169
|
+
horizontal: 'center',
|
170
|
+
vertical: 'bottom',
|
171
|
+
}}
|
172
|
+
>
|
173
|
+
<Box sx={{ p: '1rem' }}>
|
174
|
+
<MRT_TableHeadCellFilterContainer header={header} table={table} />
|
175
|
+
</Box>
|
176
|
+
</Popover>
|
177
|
+
)}
|
154
178
|
</>
|
155
179
|
);
|
156
180
|
};
|
@@ -28,8 +28,14 @@ export const MRT_FilterRangeFields = <TData extends MRT_RowData>({
|
|
28
28
|
...(parseFromValuesOrFunc(rest?.sx, theme) as any),
|
29
29
|
})}
|
30
30
|
>
|
31
|
-
|
32
|
-
|
31
|
+
{[0, 1].map((rangeFilterIndex) => (
|
32
|
+
<MRT_FilterTextField
|
33
|
+
header={header}
|
34
|
+
key={rangeFilterIndex}
|
35
|
+
rangeFilterIndex={rangeFilterIndex}
|
36
|
+
table={table}
|
37
|
+
/>
|
38
|
+
))}
|
33
39
|
</Box>
|
34
40
|
);
|
35
41
|
};
|