material-react-table 2.0.0-alpha.4 → 2.0.0-alpha.6
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 +458 -405
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/column.utils.d.ts +2 -0
- package/dist/cjs/types/icons.d.ts +1 -1
- package/dist/cjs/types/locales/hy.d.ts +2 -0
- package/dist/cjs/types/toolbar/MRT_ToolbarAlertBanner.d.ts +1 -1
- package/dist/cjs/types/types.d.ts +22 -29
- package/dist/esm/material-react-table.esm.js +459 -407
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/types/column.utils.d.ts +2 -0
- package/dist/esm/types/icons.d.ts +1 -1
- package/dist/esm/types/locales/hy.d.ts +2 -0
- package/dist/esm/types/toolbar/MRT_ToolbarAlertBanner.d.ts +1 -1
- package/dist/esm/types/types.d.ts +22 -29
- package/dist/index.d.ts +27 -33
- package/locales/hy.d.ts +2 -0
- package/locales/hy.esm.d.ts +2 -0
- package/locales/hy.esm.js +93 -0
- package/locales/hy.esm.js.map +1 -0
- package/locales/hy.js +97 -0
- package/locales/hy.js.map +1 -0
- package/package.json +7 -7
- package/src/body/MRT_TableBody.tsx +30 -22
- package/src/body/MRT_TableBodyCell.tsx +2 -2
- package/src/body/MRT_TableBodyRow.tsx +3 -3
- package/src/body/MRT_TableDetailPanel.tsx +3 -3
- package/src/buttons/MRT_GrabHandleButton.tsx +1 -2
- package/src/buttons/MRT_ShowHideColumnsButton.tsx +1 -2
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +1 -2
- package/src/buttons/MRT_ToggleFiltersButton.tsx +1 -2
- package/src/buttons/MRT_ToggleFullScreenButton.tsx +2 -3
- package/src/column.utils.ts +34 -9
- package/src/filterFns.ts +3 -3
- package/src/footer/MRT_TableFooter.tsx +1 -1
- package/src/footer/MRT_TableFooterCell.tsx +1 -1
- package/src/footer/MRT_TableFooterRow.tsx +2 -2
- package/src/head/MRT_TableHead.tsx +36 -14
- package/src/head/MRT_TableHeadCell.tsx +1 -1
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +2 -0
- package/src/head/MRT_TableHeadRow.tsx +2 -2
- package/src/hooks/useMRT_TableInstance.ts +6 -6
- package/src/hooks/useMRT_TableOptions.ts +7 -2
- package/src/icons.ts +3 -3
- package/src/inputs/MRT_FilterTextField.tsx +4 -3
- package/src/locales/hy.ts +93 -0
- package/src/table/MRT_Table.tsx +24 -12
- package/src/toolbar/MRT_TablePagination.tsx +23 -14
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +53 -15
- package/src/toolbar/MRT_TopToolbar.tsx +1 -1
- package/src/types.ts +26 -25
@@ -0,0 +1,93 @@
|
|
1
|
+
import { type MRT_Localization } from '..';
|
2
|
+
|
3
|
+
export const MRT_Localization_HY: MRT_Localization = {
|
4
|
+
actions: 'Գործողություններ',
|
5
|
+
and: 'և',
|
6
|
+
cancel: 'Չեղարկել',
|
7
|
+
changeFilterMode: 'Փոխել զտիչի ռեժիմը',
|
8
|
+
changeSearchMode: 'Փոխել որոնման ռեժիմը',
|
9
|
+
clearFilter: 'Մաքրել զտիչը',
|
10
|
+
clearSearch: 'Մաքրել որոնումը',
|
11
|
+
clearSort: 'Մաքրել տեսակավորումը',
|
12
|
+
clickToCopy: 'Սեղմել պատճենելու համար',
|
13
|
+
columnActions: 'Սյունակի գործողություն',
|
14
|
+
copiedToClipboard: 'Պատճենվել է փոխանակման բուֆերում',
|
15
|
+
collapse: 'Փոքրացնել',
|
16
|
+
collapseAll: 'Փոքրացնել բոլորը',
|
17
|
+
dropToGroupBy: 'Ավելացնել խմբին {column}',
|
18
|
+
edit: 'Խմբագրել',
|
19
|
+
expand: 'Բացել',
|
20
|
+
expandAll: 'Բացել բոլորը',
|
21
|
+
filterArrIncludes: 'Միացնել',
|
22
|
+
filterArrIncludesAll: 'Միացնել բոլորը',
|
23
|
+
filterArrIncludesSome: 'Միացնել',
|
24
|
+
filterBetween: 'Միջև',
|
25
|
+
filterBetweenInclusive: 'Միջև ներառյալ',
|
26
|
+
filterByColumn: 'Զտել ըստ {column}',
|
27
|
+
filterContains: 'Պարունակում է',
|
28
|
+
filterEmpty: 'Դատարկ է',
|
29
|
+
filterEndsWith: 'Ավարտվում է',
|
30
|
+
filterEquals: 'Հավասար են',
|
31
|
+
filterEqualsString: 'Հավասար են',
|
32
|
+
filterFuzzy: 'Ֆազզի',
|
33
|
+
filterGreaterThan: 'Ավել է քան',
|
34
|
+
filterGreaterThanOrEqualTo: 'Ավել է կամ հավասար է',
|
35
|
+
filterInNumberRange: 'Միջև',
|
36
|
+
filterIncludesString: 'Պարունակում է',
|
37
|
+
filterIncludesStringSensitive: 'Պարունակում է (գրանցումից կախված է)',
|
38
|
+
filterLessThan: 'Փոքր է քան',
|
39
|
+
filterLessThanOrEqualTo: 'Զտիչի ռեժիմ',
|
40
|
+
filterMode: 'Զտիչի ռեժիմ: {filterType}',
|
41
|
+
filterNotEmpty: 'Դատարկ չէ',
|
42
|
+
filterNotEquals: 'Հավասար չեն',
|
43
|
+
filterStartsWith: 'Սկսվում է ...-ից',
|
44
|
+
filterWeakEquals: 'Հավասար են',
|
45
|
+
filteringByColumn: 'Զտիչը ըստ {column} - {filterType} {filterValue}',
|
46
|
+
goToFirstPage: 'Անցնել առաջին էջ',
|
47
|
+
goToLastPage: 'Անցնել վերջին էջ',
|
48
|
+
goToNextPage: 'Անցնել հաջորդ էջ',
|
49
|
+
goToPreviousPage: 'Անցնել նախորդ էջ',
|
50
|
+
grab: 'Տեղաշարժել',
|
51
|
+
groupByColumn: 'Խմբավորել ըստ {column}',
|
52
|
+
groupedBy: 'Խմբավորել',
|
53
|
+
hideAll: 'Թաքցնել բոլորը',
|
54
|
+
hideColumn: 'Թաքցնել {column} սյունակը',
|
55
|
+
max: 'Առվ',
|
56
|
+
min: 'Նվզ',
|
57
|
+
move: 'Շարժել',
|
58
|
+
noRecordsToDisplay: 'Ցուցադրման համար գրառումներ չկան',
|
59
|
+
noResultsFound: 'Արդյունքներ չեն գտնվել',
|
60
|
+
of: '-ից',
|
61
|
+
or: 'կամ',
|
62
|
+
pinToLeft: 'Կցել ձախից',
|
63
|
+
pinToRight: 'Կցել աջից',
|
64
|
+
resetColumnSize: 'Չեղարկել սյունակի չափը',
|
65
|
+
resetOrder: 'Չեղարկել կարգը',
|
66
|
+
rowActions: 'Տողի գործողությունները',
|
67
|
+
rowNumber: '#',
|
68
|
+
rowNumbers: 'Տողերի քանակը',
|
69
|
+
rowsPerPage: 'Տողեր էջում',
|
70
|
+
save: 'Պահպանել',
|
71
|
+
search: 'Գտնել',
|
72
|
+
selectedCountOfRowCountRowsSelected:
|
73
|
+
'{rowCount} տողից ընտրված է {selectedCount}',
|
74
|
+
select: 'Ընտրել',
|
75
|
+
showAll: 'Ցույց տալ բոլորը',
|
76
|
+
showAllColumns: 'Ցույց տալ բոլոր սյունակները',
|
77
|
+
showHideColumns: 'Ցույց տալ/թաքցնել սյունակները',
|
78
|
+
showHideFilters: 'Ցույց տալ/թաքցնել զտիչները',
|
79
|
+
showHideSearch: 'Ցույց տալ/թաքցնել որոնումը',
|
80
|
+
sortByColumnAsc: 'Տեսակավորել {column} ըստ աճման',
|
81
|
+
sortByColumnDesc: 'Տեսակավորել {column} ըստ նվազման',
|
82
|
+
sortedByColumnAsc: 'Տեսակավորված է ըստ {column} աճման',
|
83
|
+
sortedByColumnDesc: 'Տեսակավորված է ըստ {column} նվազման',
|
84
|
+
thenBy: ', այնուհետ ',
|
85
|
+
toggleDensity: 'Փոխել խտությունը',
|
86
|
+
toggleFullScreen: 'Միացնել ամբողջ էկրանով ռեժիմը',
|
87
|
+
toggleSelectAll: 'Ընտրել բոլորը',
|
88
|
+
toggleSelectRow: 'Փոխել տողի ընտրությունը',
|
89
|
+
toggleVisibility: 'Փոխել տեսանելիությունը',
|
90
|
+
ungroupByColumn: 'Խմբավորել ըստ {column}',
|
91
|
+
unpin: 'Ապակցել',
|
92
|
+
unpinAll: 'Ապակցել բոլորը',
|
93
|
+
};
|
package/src/table/MRT_Table.tsx
CHANGED
@@ -2,12 +2,11 @@ import { useCallback, useMemo } from 'react';
|
|
2
2
|
import {
|
3
3
|
type Range,
|
4
4
|
type Virtualizer,
|
5
|
-
defaultRangeExtractor,
|
6
5
|
useVirtualizer,
|
7
6
|
} from '@tanstack/react-virtual';
|
8
7
|
import Table from '@mui/material/Table';
|
9
8
|
import { MRT_TableBody, Memo_MRT_TableBody } from '../body/MRT_TableBody';
|
10
|
-
import { parseCSSVarId, parseFromValuesOrFunc } from '../column.utils';
|
9
|
+
import { extraIndexRangeExtractor, parseCSSVarId, parseFromValuesOrFunc } from '../column.utils';
|
11
10
|
import { MRT_TableFooter } from '../footer/MRT_TableFooter';
|
12
11
|
import { MRT_TableHead } from '../head/MRT_TableHead';
|
13
12
|
import { type MRT_TableInstance } from '../types';
|
@@ -43,6 +42,7 @@ export const MRT_Table = <TData extends Record<string, any>>({
|
|
43
42
|
columnSizing,
|
44
43
|
columnSizingInfo,
|
45
44
|
columnVisibility,
|
45
|
+
draggingColumn,
|
46
46
|
isFullScreen,
|
47
47
|
} = getState();
|
48
48
|
|
@@ -93,6 +93,10 @@ export const MRT_Table = <TData extends Record<string, any>>({
|
|
93
93
|
[columnPinning, enableColumnVirtualization, enableColumnPinning],
|
94
94
|
);
|
95
95
|
|
96
|
+
const draggingColumnIndex = table
|
97
|
+
.getVisibleLeafColumns()
|
98
|
+
.findIndex((c) => c.id === draggingColumn?.id);
|
99
|
+
|
96
100
|
const columnVirtualizer:
|
97
101
|
| Virtualizer<HTMLDivElement, HTMLTableCellElement>
|
98
102
|
| undefined = enableColumnVirtualization
|
@@ -103,14 +107,20 @@ export const MRT_Table = <TData extends Record<string, any>>({
|
|
103
107
|
horizontal: true,
|
104
108
|
overscan: 3,
|
105
109
|
rangeExtractor: useCallback(
|
106
|
-
(range: Range) =>
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
110
|
+
(range: Range) => {
|
111
|
+
const newIndexs = extraIndexRangeExtractor(
|
112
|
+
range,
|
113
|
+
draggingColumnIndex,
|
114
|
+
);
|
115
|
+
return [
|
116
|
+
...new Set([
|
117
|
+
...leftPinnedIndexes,
|
118
|
+
...newIndexs,
|
119
|
+
...rightPinnedIndexes,
|
120
|
+
]),
|
121
|
+
];
|
122
|
+
},
|
123
|
+
[leftPinnedIndexes, rightPinnedIndexes, draggingColumnIndex],
|
114
124
|
),
|
115
125
|
...columnVirtualizerProps,
|
116
126
|
})
|
@@ -150,9 +160,11 @@ export const MRT_Table = <TData extends Record<string, any>>({
|
|
150
160
|
style={{ ...columnSizeVars, ...tableProps?.style }}
|
151
161
|
sx={(theme) => ({
|
152
162
|
borderCollapse: 'separate',
|
153
|
-
display: layoutMode
|
163
|
+
display: layoutMode?.startsWith('grid') ? 'grid' : undefined,
|
154
164
|
tableLayout:
|
155
|
-
layoutMode
|
165
|
+
layoutMode === 'semantic' && enableColumnResizing
|
166
|
+
? 'fixed'
|
167
|
+
: undefined,
|
156
168
|
...(parseFromValuesOrFunc(tableProps?.sx, theme) as any),
|
157
169
|
})}
|
158
170
|
>
|
@@ -9,7 +9,7 @@ import Typography from '@mui/material/Typography';
|
|
9
9
|
import { parseFromValuesOrFunc } from '../column.utils';
|
10
10
|
import { type MRT_TableInstance } from '../types';
|
11
11
|
|
12
|
-
const
|
12
|
+
const defaultRowsPerPage = [5, 10, 15, 20, 25, 30, 50, 100];
|
13
13
|
|
14
14
|
interface Props<TData extends Record<string, any> = {}> {
|
15
15
|
position?: 'bottom' | 'top';
|
@@ -25,9 +25,9 @@ export const MRT_TablePagination = <TData extends Record<string, any> = {}>({
|
|
25
25
|
getState,
|
26
26
|
options: {
|
27
27
|
enableToolbarInternalActions,
|
28
|
-
icons: {
|
28
|
+
icons: { ChevronLeftIcon, ChevronRightIcon, FirstPageIcon, LastPageIcon },
|
29
29
|
localization,
|
30
|
-
|
30
|
+
muiPaginationProps,
|
31
31
|
paginationDisplayMode,
|
32
32
|
rowCount,
|
33
33
|
},
|
@@ -39,20 +39,24 @@ export const MRT_TablePagination = <TData extends Record<string, any> = {}>({
|
|
39
39
|
showGlobalFilter,
|
40
40
|
} = getState();
|
41
41
|
|
42
|
-
const paginationProps = parseFromValuesOrFunc(
|
42
|
+
const paginationProps = parseFromValuesOrFunc(muiPaginationProps, {
|
43
43
|
table,
|
44
44
|
});
|
45
45
|
|
46
46
|
const totalRowCount = rowCount ?? getPrePaginationRowModel().rows.length;
|
47
47
|
const numberOfPages = Math.ceil(totalRowCount / pageSize);
|
48
48
|
const showFirstLastPageButtons = numberOfPages > 2;
|
49
|
-
const showFirstButton =
|
50
|
-
showFirstLastPageButtons && paginationProps?.showFirstButton !== false;
|
51
|
-
const showLastButton =
|
52
|
-
showFirstLastPageButtons && paginationProps?.showLastButton !== false;
|
53
49
|
const firstRowIndex = pageIndex * pageSize;
|
54
50
|
const lastRowIndex = Math.min(pageIndex * pageSize + pageSize, totalRowCount);
|
55
51
|
|
52
|
+
const {
|
53
|
+
rowsPerPageOptions = defaultRowsPerPage,
|
54
|
+
showFirstButton = showFirstLastPageButtons,
|
55
|
+
showLastButton = showFirstLastPageButtons,
|
56
|
+
showRowsPerPage = true,
|
57
|
+
...rest
|
58
|
+
} = paginationProps ?? {};
|
59
|
+
|
56
60
|
return (
|
57
61
|
<Box
|
58
62
|
sx={{
|
@@ -60,6 +64,7 @@ export const MRT_TablePagination = <TData extends Record<string, any> = {}>({
|
|
60
64
|
display: 'flex',
|
61
65
|
gap: '8px',
|
62
66
|
justifyContent: 'space-between',
|
67
|
+
justifySelf: 'flex-end',
|
63
68
|
mt:
|
64
69
|
position === 'top' &&
|
65
70
|
enableToolbarInternalActions &&
|
@@ -72,20 +77,21 @@ export const MRT_TablePagination = <TData extends Record<string, any> = {}>({
|
|
72
77
|
zIndex: 2,
|
73
78
|
}}
|
74
79
|
>
|
75
|
-
{
|
80
|
+
{showRowsPerPage && (
|
76
81
|
<Box sx={{ alignItems: 'center', display: 'flex', gap: '8px' }}>
|
77
82
|
<InputLabel htmlFor="mrt-rows-per-page" sx={{ mb: 0 }}>
|
78
83
|
{localization.rowsPerPage}
|
79
84
|
</InputLabel>
|
80
85
|
<Select
|
81
86
|
id="mrt-rows-per-page"
|
87
|
+
inputProps={{ 'aria-label': localization.rowsPerPage }}
|
82
88
|
label={localization.rowsPerPage}
|
83
89
|
onChange={(event) => setPageSize(+event.target.value)}
|
84
90
|
sx={{ '&::before': { border: 'none' }, mb: 0 }}
|
85
91
|
value={pageSize}
|
86
92
|
variant="standard"
|
87
93
|
>
|
88
|
-
{
|
94
|
+
{rowsPerPageOptions.map((value) => (
|
89
95
|
<MenuItem key={value} sx={{ m: 0 }} value={value}>
|
90
96
|
{value}
|
91
97
|
</MenuItem>
|
@@ -104,18 +110,21 @@ export const MRT_TablePagination = <TData extends Record<string, any> = {}>({
|
|
104
110
|
first: FirstPageIcon,
|
105
111
|
last: LastPageIcon,
|
106
112
|
next: ChevronRightIcon,
|
107
|
-
previous:
|
113
|
+
previous: ChevronLeftIcon,
|
108
114
|
}}
|
109
115
|
{...item}
|
110
116
|
/>
|
111
117
|
)}
|
112
118
|
showFirstButton={showFirstButton}
|
113
119
|
showLastButton={showLastButton}
|
114
|
-
{...(
|
120
|
+
{...(rest as PaginationProps)}
|
115
121
|
/>
|
116
122
|
) : paginationDisplayMode === 'default' ? (
|
117
123
|
<>
|
118
|
-
<Typography
|
124
|
+
<Typography
|
125
|
+
sx={{ mb: 0, minWidth: '10ch', mx: '4px' }}
|
126
|
+
variant="body2"
|
127
|
+
>{`${
|
119
128
|
lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()
|
120
129
|
}-${lastRowIndex.toLocaleString()} ${
|
121
130
|
localization.of
|
@@ -137,7 +146,7 @@ export const MRT_TablePagination = <TData extends Record<string, any> = {}>({
|
|
137
146
|
onClick={() => setPageIndex(pageIndex - 1)}
|
138
147
|
size="small"
|
139
148
|
>
|
140
|
-
<
|
149
|
+
<ChevronLeftIcon />
|
141
150
|
</IconButton>
|
142
151
|
<IconButton
|
143
152
|
aria-label={localization.goToNextPage}
|
@@ -4,11 +4,13 @@ import AlertTitle from '@mui/material/AlertTitle';
|
|
4
4
|
import Box from '@mui/material/Box';
|
5
5
|
import Chip from '@mui/material/Chip';
|
6
6
|
import Collapse from '@mui/material/Collapse';
|
7
|
+
import Stack from '@mui/material/Stack';
|
7
8
|
import { parseFromValuesOrFunc } from '../column.utils';
|
9
|
+
import { MRT_SelectCheckbox } from '../inputs';
|
8
10
|
import { type MRT_TableInstance } from '../types';
|
9
11
|
|
10
12
|
interface Props<TData extends Record<string, any>> {
|
11
|
-
stackAlertBanner
|
13
|
+
stackAlertBanner?: boolean;
|
12
14
|
table: MRT_TableInstance<TData>;
|
13
15
|
}
|
14
16
|
|
@@ -21,14 +23,18 @@ export const MRT_ToolbarAlertBanner = <TData extends Record<string, any>>({
|
|
21
23
|
getSelectedRowModel,
|
22
24
|
getState,
|
23
25
|
options: {
|
26
|
+
enableRowSelection,
|
27
|
+
enableSelectAll,
|
24
28
|
localization,
|
25
29
|
muiToolbarAlertBannerChipProps,
|
26
30
|
muiToolbarAlertBannerProps,
|
27
31
|
positionToolbarAlertBanner,
|
32
|
+
renderToolbarAlertBannerContent,
|
28
33
|
rowCount,
|
29
34
|
},
|
35
|
+
refs: { tablePaperRef },
|
30
36
|
} = table;
|
31
|
-
const { grouping, showAlertBanner } = getState();
|
37
|
+
const { density, grouping, showAlertBanner } = getState();
|
32
38
|
|
33
39
|
const alertProps = parseFromValuesOrFunc(muiToolbarAlertBannerProps, {
|
34
40
|
table,
|
@@ -38,7 +44,7 @@ export const MRT_ToolbarAlertBanner = <TData extends Record<string, any>>({
|
|
38
44
|
table,
|
39
45
|
});
|
40
46
|
|
41
|
-
const
|
47
|
+
const selectedAlert =
|
42
48
|
getSelectedRowModel().rows.length > 0
|
43
49
|
? localization.selectedCountOfRowCountRowsSelected
|
44
50
|
?.replace(
|
@@ -51,7 +57,7 @@ export const MRT_ToolbarAlertBanner = <TData extends Record<string, any>>({
|
|
51
57
|
)
|
52
58
|
: null;
|
53
59
|
|
54
|
-
const
|
60
|
+
const groupedAlert =
|
55
61
|
grouping.length > 0 ? (
|
56
62
|
<span>
|
57
63
|
{localization.groupedBy}{' '}
|
@@ -70,7 +76,7 @@ export const MRT_ToolbarAlertBanner = <TData extends Record<string, any>>({
|
|
70
76
|
|
71
77
|
return (
|
72
78
|
<Collapse
|
73
|
-
in={showAlertBanner || !!
|
79
|
+
in={showAlertBanner || !!selectedAlert || !!groupedAlert}
|
74
80
|
timeout={stackAlertBanner ? 200 : 0}
|
75
81
|
>
|
76
82
|
<Alert
|
@@ -78,6 +84,12 @@ export const MRT_ToolbarAlertBanner = <TData extends Record<string, any>>({
|
|
78
84
|
icon={false}
|
79
85
|
{...alertProps}
|
80
86
|
sx={(theme) => ({
|
87
|
+
'& .MuiAlert-message': {
|
88
|
+
maxWidth: `calc(${
|
89
|
+
tablePaperRef.current?.clientWidth ?? 360
|
90
|
+
}px - 1rem)`,
|
91
|
+
width: '100%',
|
92
|
+
},
|
81
93
|
borderRadius: 0,
|
82
94
|
fontSize: '1rem',
|
83
95
|
left: 0,
|
@@ -95,16 +107,42 @@ export const MRT_ToolbarAlertBanner = <TData extends Record<string, any>>({
|
|
95
107
|
...(parseFromValuesOrFunc(alertProps?.sx, theme) as any),
|
96
108
|
})}
|
97
109
|
>
|
98
|
-
{
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
110
|
+
{renderToolbarAlertBannerContent?.({
|
111
|
+
groupedAlert,
|
112
|
+
selectedAlert,
|
113
|
+
table,
|
114
|
+
}) ?? (
|
115
|
+
<>
|
116
|
+
{alertProps?.title && <AlertTitle>{alertProps.title}</AlertTitle>}
|
117
|
+
<Stack
|
118
|
+
sx={{
|
119
|
+
p:
|
120
|
+
positionToolbarAlertBanner !== 'head-overlay'
|
121
|
+
? '0.5rem 1rem'
|
122
|
+
: density === 'spacious'
|
123
|
+
? '0.75rem 1.25rem'
|
124
|
+
: density === 'comfortable'
|
125
|
+
? '0.5rem 0.75rem'
|
126
|
+
: '0.25rem 0.5rem',
|
127
|
+
}}
|
128
|
+
>
|
129
|
+
{alertProps?.children}
|
130
|
+
{alertProps?.children && (selectedAlert || groupedAlert) && (
|
131
|
+
<br />
|
132
|
+
)}
|
133
|
+
<Box sx={{ display: 'flex' }}>
|
134
|
+
{enableRowSelection &&
|
135
|
+
enableSelectAll &&
|
136
|
+
positionToolbarAlertBanner === 'head-overlay' && (
|
137
|
+
<MRT_SelectCheckbox selectAll table={table} />
|
138
|
+
)}{' '}
|
139
|
+
{selectedAlert}
|
140
|
+
</Box>
|
141
|
+
{selectedAlert && groupedAlert && <br />}
|
142
|
+
{groupedAlert}
|
143
|
+
</Stack>
|
144
|
+
</>
|
145
|
+
)}
|
108
146
|
</Alert>
|
109
147
|
</Collapse>
|
110
148
|
);
|
@@ -14,7 +14,7 @@ import { type MRT_TableInstance } from '../types';
|
|
14
14
|
|
15
15
|
export const commonToolbarStyles = ({ theme }: { theme: Theme }) => ({
|
16
16
|
alignItems: 'flex-start',
|
17
|
-
backgroundColor: lighten(theme.palette.background.default, 0.
|
17
|
+
backgroundColor: lighten(theme.palette.background.default, 0.05),
|
18
18
|
backgroundImage: 'none',
|
19
19
|
display: 'grid',
|
20
20
|
flexWrap: 'wrap-reverse',
|
package/src/types.ts
CHANGED
@@ -260,12 +260,8 @@ export type MRT_TableInstance<TData extends Record<string, any>> = Omit<
|
|
260
260
|
setEditingCell: Dispatch<SetStateAction<MRT_Cell<TData> | null>>;
|
261
261
|
setEditingRow: Dispatch<SetStateAction<MRT_Row<TData> | null>>;
|
262
262
|
setGlobalFilterFn: Dispatch<SetStateAction<MRT_FilterOption>>;
|
263
|
-
setHoveredColumn: Dispatch<
|
264
|
-
|
265
|
-
>;
|
266
|
-
setHoveredRow: Dispatch<
|
267
|
-
SetStateAction<{ id: string } | MRT_Row<TData> | null>
|
268
|
-
>;
|
263
|
+
setHoveredColumn: Dispatch<SetStateAction<Partial<MRT_Column<TData>> | null>>;
|
264
|
+
setHoveredRow: Dispatch<SetStateAction<Partial<MRT_Row<TData>> | null>>;
|
269
265
|
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
270
266
|
setShowAlertBanner: Dispatch<SetStateAction<boolean>>;
|
271
267
|
setShowColumnFilters: Dispatch<SetStateAction<boolean>>;
|
@@ -288,8 +284,8 @@ export type MRT_TableState<TData extends Record<string, any>> = TableState & {
|
|
288
284
|
editingCell: MRT_Cell<TData> | null;
|
289
285
|
editingRow: MRT_Row<TData> | null;
|
290
286
|
globalFilterFn: MRT_FilterOption;
|
291
|
-
hoveredColumn:
|
292
|
-
hoveredRow:
|
287
|
+
hoveredColumn: Partial<MRT_Column<TData>> | null;
|
288
|
+
hoveredRow: Partial<MRT_Row<TData>> | null;
|
293
289
|
isFullScreen: boolean;
|
294
290
|
isLoading: boolean;
|
295
291
|
isSaving: boolean;
|
@@ -727,7 +723,7 @@ export type MRT_TableOptions<TData extends Record<string, any>> = Omit<
|
|
727
723
|
/**
|
728
724
|
* Changes which kind of CSS layout is used to render the table. `semantic` uses default semantic HTML elements, while `grid` adds CSS grid and flexbox styles
|
729
725
|
*/
|
730
|
-
layoutMode?: 'grid' | 'semantic';
|
726
|
+
layoutMode?: 'grid' | 'grid-no-grow' | 'semantic';
|
731
727
|
/**
|
732
728
|
* Pass in either a locale imported from `material-react-table/locales/*` or a custom locale object.
|
733
729
|
*
|
@@ -838,6 +834,19 @@ export type MRT_TableOptions<TData extends Record<string, any>> = Omit<
|
|
838
834
|
table: MRT_TableInstance<TData>;
|
839
835
|
}) => LinearProgressProps)
|
840
836
|
| LinearProgressProps;
|
837
|
+
muiPaginationProps?:
|
838
|
+
| ((props: { table: MRT_TableInstance<TData> }) => Partial<
|
839
|
+
PaginationProps & {
|
840
|
+
rowsPerPageOptions?: number[];
|
841
|
+
showRowsPerPage?: boolean;
|
842
|
+
}
|
843
|
+
>)
|
844
|
+
| Partial<
|
845
|
+
PaginationProps & {
|
846
|
+
rowsPerPageOptions?: number[];
|
847
|
+
showRowsPerPage?: boolean;
|
848
|
+
}
|
849
|
+
>;
|
841
850
|
muiRowDragHandleProps?:
|
842
851
|
| ((props: {
|
843
852
|
row: MRT_Row<TData>;
|
@@ -916,19 +925,6 @@ export type MRT_TableOptions<TData extends Record<string, any>> = Omit<
|
|
916
925
|
table: MRT_TableInstance<TData>;
|
917
926
|
}) => TableRowProps)
|
918
927
|
| TableRowProps;
|
919
|
-
muiTablePaginationProps?:
|
920
|
-
| ((props: { table: MRT_TableInstance<TData> }) => Partial<
|
921
|
-
PaginationProps & {
|
922
|
-
rowsPerPageOptions?: number[];
|
923
|
-
showRowsPerPage?: boolean;
|
924
|
-
}
|
925
|
-
>)
|
926
|
-
| Partial<
|
927
|
-
PaginationProps & {
|
928
|
-
rowsPerPageOptions?: number[];
|
929
|
-
showRowsPerPage?: boolean;
|
930
|
-
}
|
931
|
-
>;
|
932
928
|
muiTablePaperProps?:
|
933
929
|
| ((props: { table: MRT_TableInstance<TData> }) => PaperProps)
|
934
930
|
| PaperProps;
|
@@ -972,8 +968,8 @@ export type MRT_TableOptions<TData extends Record<string, any>> = Omit<
|
|
972
968
|
values: Record<LiteralUnion<string & DeepKeys<TData>>, any>;
|
973
969
|
}) => Promise<void> | void;
|
974
970
|
onGlobalFilterFnChange?: OnChangeFn<MRT_FilterOption>;
|
975
|
-
onHoveredColumnChange?: OnChangeFn<
|
976
|
-
onHoveredRowChange?: OnChangeFn<
|
971
|
+
onHoveredColumnChange?: OnChangeFn<Partial<MRT_Column<TData>> | null>;
|
972
|
+
onHoveredRowChange?: OnChangeFn<Partial<MRT_Row<TData>> | null>;
|
977
973
|
onIsFullScreenChange?: OnChangeFn<boolean>;
|
978
974
|
onShowAlertBannerChange?: OnChangeFn<boolean>;
|
979
975
|
onShowColumnFiltersChange?: OnChangeFn<boolean>;
|
@@ -984,7 +980,7 @@ export type MRT_TableOptions<TData extends Record<string, any>> = Omit<
|
|
984
980
|
positionExpandColumn?: 'first' | 'last';
|
985
981
|
positionGlobalFilter?: 'left' | 'none' | 'right';
|
986
982
|
positionPagination?: 'both' | 'bottom' | 'none' | 'top';
|
987
|
-
positionToolbarAlertBanner?: 'bottom' | 'none' | 'top';
|
983
|
+
positionToolbarAlertBanner?: 'bottom' | 'head-overlay' | 'none' | 'top';
|
988
984
|
positionToolbarDropZone?: 'both' | 'bottom' | 'none' | 'top';
|
989
985
|
renderBottomToolbar?:
|
990
986
|
| ((props: { table: MRT_TableInstance<TData> }) => ReactNode)
|
@@ -1036,6 +1032,11 @@ export type MRT_TableOptions<TData extends Record<string, any>> = Omit<
|
|
1036
1032
|
row: MRT_Row<TData>;
|
1037
1033
|
table: MRT_TableInstance<TData>;
|
1038
1034
|
}) => ReactNode;
|
1035
|
+
renderToolbarAlertBannerContent?: (props: {
|
1036
|
+
groupedAlert: ReactNode | null;
|
1037
|
+
selectedAlert: ReactNode | null;
|
1038
|
+
table: MRT_TableInstance<TData>;
|
1039
|
+
}) => ReactNode;
|
1039
1040
|
renderToolbarInternalActions?: (props: {
|
1040
1041
|
table: MRT_TableInstance<TData>;
|
1041
1042
|
}) => ReactNode;
|