material-react-table 2.0.0-alpha.4 → 2.0.0-alpha.5
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 +447 -418
- package/dist/cjs/index.js.map +1 -1
- 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 +16 -11
- package/dist/esm/material-react-table.esm.js +420 -391
- package/dist/esm/material-react-table.esm.js.map +1 -1
- 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 +16 -11
- package/dist/index.d.ts +18 -13
- 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 +13 -21
- 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 +15 -9
- 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_TableHeadRow.tsx +2 -2
- package/src/hooks/useMRT_TableOptions.ts +7 -2
- package/src/icons.ts +3 -3
- package/src/locales/hy.ts +93 -0
- package/src/table/MRT_Table.tsx +4 -2
- package/src/toolbar/MRT_TablePagination.tsx +24 -14
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +53 -15
- package/src/toolbar/MRT_TopToolbar.tsx +1 -1
- package/src/types.ts +20 -15
package/src/column.utils.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { type ReactNode } from 'react';
|
1
|
+
import { type CSSProperties, type ReactNode } from 'react';
|
2
2
|
import {
|
3
3
|
createRow as _createRow,
|
4
4
|
flexRender as _flexRender,
|
@@ -295,7 +295,10 @@ export const getCommonCellStyles = <TData extends Record<string, any>>({
|
|
295
295
|
tableCellProps: TableCellProps;
|
296
296
|
theme: Theme;
|
297
297
|
}) => {
|
298
|
-
const
|
298
|
+
const {
|
299
|
+
options: { layoutMode },
|
300
|
+
} = table;
|
301
|
+
const widthStyles: CSSProperties = {
|
299
302
|
minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId(
|
300
303
|
header?.id ?? column.id,
|
301
304
|
)}-size) * 1px), ${column.columnDef.minSize ?? 30}px)`,
|
@@ -303,6 +306,15 @@ export const getCommonCellStyles = <TData extends Record<string, any>>({
|
|
303
306
|
header?.id ?? column.id,
|
304
307
|
)}-size) * 1px)`,
|
305
308
|
};
|
309
|
+
|
310
|
+
if (layoutMode === 'grid') {
|
311
|
+
widthStyles.flex = `var(--${header ? 'header' : 'col'}-${parseCSSVarId(
|
312
|
+
header?.id ?? column.id,
|
313
|
+
)}-size) 0 auto`;
|
314
|
+
} else if (layoutMode === 'grid-no-grow') {
|
315
|
+
widthStyles.flex = '0 0 auto';
|
316
|
+
}
|
317
|
+
|
306
318
|
return {
|
307
319
|
backgroundColor:
|
308
320
|
column.getIsPinned() && column.columnDef.columnDefType !== 'group'
|
@@ -314,13 +326,7 @@ export const getCommonCellStyles = <TData extends Record<string, any>>({
|
|
314
326
|
: getIsFirstRightPinnedColumn(column)
|
315
327
|
? `4px 0 8px -6px ${alpha(theme.palette.common.black, 0.2)} inset`
|
316
328
|
: undefined,
|
317
|
-
display:
|
318
|
-
flex:
|
319
|
-
table.options.layoutMode === 'grid'
|
320
|
-
? `var(--${header ? 'header' : 'col'}-${parseCSSVarId(
|
321
|
-
header?.id ?? column.id,
|
322
|
-
)}-size) 0 auto`
|
323
|
-
: undefined,
|
329
|
+
display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
|
324
330
|
left:
|
325
331
|
column.getIsPinned() === 'left'
|
326
332
|
? `${column.getStart('left')}px`
|
@@ -44,7 +44,7 @@ export const MRT_TableFooter = <TData extends Record<string, any>>({
|
|
44
44
|
}}
|
45
45
|
sx={(theme) => ({
|
46
46
|
bottom: stickFooter ? 0 : undefined,
|
47
|
-
display: layoutMode
|
47
|
+
display: layoutMode?.startsWith('grid') ? 'grid' : undefined,
|
48
48
|
opacity: stickFooter ? 0.97 : undefined,
|
49
49
|
outline: stickFooter
|
50
50
|
? theme.palette.mode === 'light'
|
@@ -35,7 +35,7 @@ export const MRT_TableFooterCell = <TData extends Record<string, any>>({
|
|
35
35
|
variant="head"
|
36
36
|
{...tableCellProps}
|
37
37
|
sx={(theme) => ({
|
38
|
-
display: layoutMode
|
38
|
+
display: layoutMode?.startsWith('grid') ? 'grid' : 'table-cell',
|
39
39
|
fontWeight: 'bold',
|
40
40
|
justifyContent: columnDefType === 'group' ? 'center' : undefined,
|
41
41
|
p:
|
@@ -48,8 +48,8 @@ export const MRT_TableFooterRow = <TData extends Record<string, any>>({
|
|
48
48
|
<TableRow
|
49
49
|
{...tableRowProps}
|
50
50
|
sx={(theme) => ({
|
51
|
-
backgroundColor: lighten(theme.palette.background.default, 0.
|
52
|
-
display: layoutMode
|
51
|
+
backgroundColor: lighten(theme.palette.background.default, 0.05),
|
52
|
+
display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
|
53
53
|
width: '100%',
|
54
54
|
...(parseFromValuesOrFunc(tableRowProps?.sx, theme) as any),
|
55
55
|
})}
|
@@ -2,6 +2,7 @@ import { type VirtualItem } from '@tanstack/react-virtual';
|
|
2
2
|
import TableHead from '@mui/material/TableHead';
|
3
3
|
import { MRT_TableHeadRow } from './MRT_TableHeadRow';
|
4
4
|
import { parseFromValuesOrFunc } from '../column.utils';
|
5
|
+
import { MRT_ToolbarAlertBanner } from '../toolbar';
|
5
6
|
import { type MRT_TableInstance } from '../types';
|
6
7
|
|
7
8
|
interface Props<TData extends Record<string, any>> {
|
@@ -19,11 +20,17 @@ export const MRT_TableHead = <TData extends Record<string, any>>({
|
|
19
20
|
}: Props<TData>) => {
|
20
21
|
const {
|
21
22
|
getHeaderGroups,
|
23
|
+
getSelectedRowModel,
|
22
24
|
getState,
|
23
|
-
options: {
|
25
|
+
options: {
|
26
|
+
enableStickyHeader,
|
27
|
+
layoutMode,
|
28
|
+
muiTableHeadProps,
|
29
|
+
positionToolbarAlertBanner,
|
30
|
+
},
|
24
31
|
refs: { tableHeadRef },
|
25
32
|
} = table;
|
26
|
-
const { isFullScreen } = getState();
|
33
|
+
const { isFullScreen, showAlertBanner } = getState();
|
27
34
|
|
28
35
|
const tableHeadProps = parseFromValuesOrFunc(muiTableHeadProps, { table });
|
29
36
|
|
@@ -40,24 +47,39 @@ export const MRT_TableHead = <TData extends Record<string, any>>({
|
|
40
47
|
}
|
41
48
|
}}
|
42
49
|
sx={(theme) => ({
|
43
|
-
display: layoutMode
|
50
|
+
display: layoutMode?.startsWith('grid') ? 'grid' : undefined,
|
44
51
|
opacity: 0.97,
|
45
52
|
position: stickyHeader ? 'sticky' : 'relative',
|
46
|
-
top: stickyHeader && layoutMode
|
53
|
+
top: stickyHeader && layoutMode?.startsWith('grid') ? 0 : undefined,
|
47
54
|
zIndex: stickyHeader ? 2 : undefined,
|
48
55
|
...(parseFromValuesOrFunc(tableHeadProps?.sx, theme) as any),
|
49
56
|
})}
|
50
57
|
>
|
51
|
-
{
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
{positionToolbarAlertBanner === 'head-overlay' &&
|
59
|
+
(showAlertBanner || getSelectedRowModel().rows.length > 0) ? (
|
60
|
+
<tr style={{ display: layoutMode?.startsWith('grid') ? 'grid' : undefined }}>
|
61
|
+
<th
|
62
|
+
colSpan={table.getVisibleLeafColumns().length}
|
63
|
+
style={{
|
64
|
+
display: layoutMode?.startsWith('grid') ? 'grid' : 'table-cell',
|
65
|
+
padding: 0,
|
66
|
+
}}
|
67
|
+
>
|
68
|
+
<MRT_ToolbarAlertBanner table={table} />
|
69
|
+
</th>
|
70
|
+
</tr>
|
71
|
+
) : (
|
72
|
+
getHeaderGroups().map((headerGroup) => (
|
73
|
+
<MRT_TableHeadRow
|
74
|
+
headerGroup={headerGroup as any}
|
75
|
+
key={headerGroup.id}
|
76
|
+
table={table}
|
77
|
+
virtualColumns={virtualColumns}
|
78
|
+
virtualPaddingLeft={virtualPaddingLeft}
|
79
|
+
virtualPaddingRight={virtualPaddingRight}
|
80
|
+
/>
|
81
|
+
))
|
82
|
+
)}
|
61
83
|
</TableHead>
|
62
84
|
);
|
63
85
|
};
|
@@ -126,7 +126,7 @@ export const MRT_TableHeadCell = <TData extends Record<string, any>>({
|
|
126
126
|
}}
|
127
127
|
{...tableCellProps}
|
128
128
|
sx={(theme: Theme) => ({
|
129
|
-
flexDirection: layoutMode
|
129
|
+
flexDirection: layoutMode?.startsWith('grid') ? 'column' : undefined,
|
130
130
|
fontWeight: 'bold',
|
131
131
|
overflow: 'visible',
|
132
132
|
p:
|
@@ -37,9 +37,9 @@ export const MRT_TableHeadRow = <TData extends Record<string, any>>({
|
|
37
37
|
<TableRow
|
38
38
|
{...tableRowProps}
|
39
39
|
sx={(theme) => ({
|
40
|
-
backgroundColor: lighten(theme.palette.background.default, 0.
|
40
|
+
backgroundColor: lighten(theme.palette.background.default, 0.05),
|
41
41
|
boxShadow: `4px 0 8px ${alpha(theme.palette.common.black, 0.1)}`,
|
42
|
-
display: layoutMode
|
42
|
+
display: layoutMode?.startsWith('grid') ? 'flex' : undefined,
|
43
43
|
top: 0,
|
44
44
|
...(parseFromValuesOrFunc(tableRowProps?.sx, theme) as any),
|
45
45
|
})}
|
@@ -93,8 +93,13 @@ export const useMRT_TableOptions: <TData extends Record<string, any>>(
|
|
93
93
|
[defaultDisplayColumn],
|
94
94
|
);
|
95
95
|
|
96
|
-
if (
|
97
|
-
|
96
|
+
if (layoutMode === 'semantic') {
|
97
|
+
if (rest.enableRowVirtualization || rest.enableColumnVirtualization) {
|
98
|
+
layoutMode = 'grid';
|
99
|
+
}
|
100
|
+
if (enableColumnResizing) {
|
101
|
+
layoutMode = 'grid-no-grow';
|
102
|
+
}
|
98
103
|
}
|
99
104
|
|
100
105
|
if (rest.enableRowVirtualization) {
|
package/src/icons.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward';
|
2
2
|
import ArrowRightIcon from '@mui/icons-material/ArrowRight';
|
3
3
|
import CancelIcon from '@mui/icons-material/Cancel';
|
4
|
-
import
|
4
|
+
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
|
5
5
|
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
|
6
6
|
import ClearAllIcon from '@mui/icons-material/ClearAll';
|
7
7
|
import CloseIcon from '@mui/icons-material/Close';
|
@@ -35,7 +35,7 @@ export interface MRT_Icons {
|
|
35
35
|
ArrowDownwardIcon: any;
|
36
36
|
ArrowRightIcon: any;
|
37
37
|
CancelIcon: any;
|
38
|
-
|
38
|
+
ChevronLeftIcon: any;
|
39
39
|
ChevronRightIcon: any;
|
40
40
|
ClearAllIcon: any;
|
41
41
|
CloseIcon: any;
|
@@ -70,7 +70,7 @@ export const MRT_Default_Icons: MRT_Icons = {
|
|
70
70
|
ArrowDownwardIcon,
|
71
71
|
ArrowRightIcon,
|
72
72
|
CancelIcon,
|
73
|
-
|
73
|
+
ChevronLeftIcon,
|
74
74
|
ChevronRightIcon,
|
75
75
|
ClearAllIcon,
|
76
76
|
CloseIcon,
|
@@ -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
@@ -150,9 +150,11 @@ export const MRT_Table = <TData extends Record<string, any>>({
|
|
150
150
|
style={{ ...columnSizeVars, ...tableProps?.style }}
|
151
151
|
sx={(theme) => ({
|
152
152
|
borderCollapse: 'separate',
|
153
|
-
display: layoutMode
|
153
|
+
display: layoutMode?.startsWith('grid') ? 'grid' : undefined,
|
154
154
|
tableLayout:
|
155
|
-
layoutMode
|
155
|
+
layoutMode === 'semantic' && enableColumnResizing
|
156
|
+
? 'fixed'
|
157
|
+
: undefined,
|
156
158
|
...(parseFromValuesOrFunc(tableProps?.sx, theme) as any),
|
157
159
|
})}
|
158
160
|
>
|
@@ -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,25 @@ 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
|
+
showRowsPerPage = true,
|
54
|
+
rowsPerPageOptions = defaultRowsPerPage,
|
55
|
+
showFirstButton = showFirstLastPageButtons,
|
56
|
+
showLastButton = showFirstLastPageButtons,
|
57
|
+
|
58
|
+
...rest
|
59
|
+
} = paginationProps ?? {};
|
60
|
+
|
56
61
|
return (
|
57
62
|
<Box
|
58
63
|
sx={{
|
@@ -60,6 +65,7 @@ export const MRT_TablePagination = <TData extends Record<string, any> = {}>({
|
|
60
65
|
display: 'flex',
|
61
66
|
gap: '8px',
|
62
67
|
justifyContent: 'space-between',
|
68
|
+
justifySelf: 'flex-end',
|
63
69
|
mt:
|
64
70
|
position === 'top' &&
|
65
71
|
enableToolbarInternalActions &&
|
@@ -72,12 +78,13 @@ export const MRT_TablePagination = <TData extends Record<string, any> = {}>({
|
|
72
78
|
zIndex: 2,
|
73
79
|
}}
|
74
80
|
>
|
75
|
-
{
|
81
|
+
{showRowsPerPage && (
|
76
82
|
<Box sx={{ alignItems: 'center', display: 'flex', gap: '8px' }}>
|
77
83
|
<InputLabel htmlFor="mrt-rows-per-page" sx={{ mb: 0 }}>
|
78
84
|
{localization.rowsPerPage}
|
79
85
|
</InputLabel>
|
80
86
|
<Select
|
87
|
+
inputProps={{ 'aria-label': localization.rowsPerPage }}
|
81
88
|
id="mrt-rows-per-page"
|
82
89
|
label={localization.rowsPerPage}
|
83
90
|
onChange={(event) => setPageSize(+event.target.value)}
|
@@ -85,7 +92,7 @@ export const MRT_TablePagination = <TData extends Record<string, any> = {}>({
|
|
85
92
|
value={pageSize}
|
86
93
|
variant="standard"
|
87
94
|
>
|
88
|
-
{
|
95
|
+
{rowsPerPageOptions.map((value) => (
|
89
96
|
<MenuItem key={value} sx={{ m: 0 }} value={value}>
|
90
97
|
{value}
|
91
98
|
</MenuItem>
|
@@ -104,18 +111,21 @@ export const MRT_TablePagination = <TData extends Record<string, any> = {}>({
|
|
104
111
|
first: FirstPageIcon,
|
105
112
|
last: LastPageIcon,
|
106
113
|
next: ChevronRightIcon,
|
107
|
-
previous:
|
114
|
+
previous: ChevronLeftIcon,
|
108
115
|
}}
|
109
116
|
{...item}
|
110
117
|
/>
|
111
118
|
)}
|
112
119
|
showFirstButton={showFirstButton}
|
113
120
|
showLastButton={showLastButton}
|
114
|
-
{...(
|
121
|
+
{...(rest as PaginationProps)}
|
115
122
|
/>
|
116
123
|
) : paginationDisplayMode === 'default' ? (
|
117
124
|
<>
|
118
|
-
<Typography
|
125
|
+
<Typography
|
126
|
+
sx={{ mb: 0, mx: '4px', minWidth: '10ch' }}
|
127
|
+
variant="body2"
|
128
|
+
>{`${
|
119
129
|
lastRowIndex === 0 ? 0 : (firstRowIndex + 1).toLocaleString()
|
120
130
|
}-${lastRowIndex.toLocaleString()} ${
|
121
131
|
localization.of
|
@@ -137,7 +147,7 @@ export const MRT_TablePagination = <TData extends Record<string, any> = {}>({
|
|
137
147
|
onClick={() => setPageIndex(pageIndex - 1)}
|
138
148
|
size="small"
|
139
149
|
>
|
140
|
-
<
|
150
|
+
<ChevronLeftIcon />
|
141
151
|
</IconButton>
|
142
152
|
<IconButton
|
143
153
|
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
@@ -727,7 +727,7 @@ export type MRT_TableOptions<TData extends Record<string, any>> = Omit<
|
|
727
727
|
/**
|
728
728
|
* 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
729
|
*/
|
730
|
-
layoutMode?: 'grid' | 'semantic';
|
730
|
+
layoutMode?: 'grid' | 'grid-no-grow' | 'semantic';
|
731
731
|
/**
|
732
732
|
* Pass in either a locale imported from `material-react-table/locales/*` or a custom locale object.
|
733
733
|
*
|
@@ -838,6 +838,19 @@ export type MRT_TableOptions<TData extends Record<string, any>> = Omit<
|
|
838
838
|
table: MRT_TableInstance<TData>;
|
839
839
|
}) => LinearProgressProps)
|
840
840
|
| LinearProgressProps;
|
841
|
+
muiPaginationProps?:
|
842
|
+
| ((props: { table: MRT_TableInstance<TData> }) => Partial<
|
843
|
+
PaginationProps & {
|
844
|
+
rowsPerPageOptions?: number[];
|
845
|
+
showRowsPerPage?: boolean;
|
846
|
+
}
|
847
|
+
>)
|
848
|
+
| Partial<
|
849
|
+
PaginationProps & {
|
850
|
+
rowsPerPageOptions?: number[];
|
851
|
+
showRowsPerPage?: boolean;
|
852
|
+
}
|
853
|
+
>;
|
841
854
|
muiRowDragHandleProps?:
|
842
855
|
| ((props: {
|
843
856
|
row: MRT_Row<TData>;
|
@@ -916,19 +929,6 @@ export type MRT_TableOptions<TData extends Record<string, any>> = Omit<
|
|
916
929
|
table: MRT_TableInstance<TData>;
|
917
930
|
}) => TableRowProps)
|
918
931
|
| 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
932
|
muiTablePaperProps?:
|
933
933
|
| ((props: { table: MRT_TableInstance<TData> }) => PaperProps)
|
934
934
|
| PaperProps;
|
@@ -984,7 +984,7 @@ export type MRT_TableOptions<TData extends Record<string, any>> = Omit<
|
|
984
984
|
positionExpandColumn?: 'first' | 'last';
|
985
985
|
positionGlobalFilter?: 'left' | 'none' | 'right';
|
986
986
|
positionPagination?: 'both' | 'bottom' | 'none' | 'top';
|
987
|
-
positionToolbarAlertBanner?: 'bottom' | 'none' | 'top';
|
987
|
+
positionToolbarAlertBanner?: 'bottom' | 'head-overlay' | 'none' | 'top';
|
988
988
|
positionToolbarDropZone?: 'both' | 'bottom' | 'none' | 'top';
|
989
989
|
renderBottomToolbar?:
|
990
990
|
| ((props: { table: MRT_TableInstance<TData> }) => ReactNode)
|
@@ -1036,6 +1036,11 @@ export type MRT_TableOptions<TData extends Record<string, any>> = Omit<
|
|
1036
1036
|
row: MRT_Row<TData>;
|
1037
1037
|
table: MRT_TableInstance<TData>;
|
1038
1038
|
}) => ReactNode;
|
1039
|
+
renderToolbarAlertBannerContent?: (props: {
|
1040
|
+
groupedAlert: ReactNode | null;
|
1041
|
+
selectedAlert: ReactNode | null;
|
1042
|
+
table: MRT_TableInstance<TData>;
|
1043
|
+
}) => ReactNode;
|
1039
1044
|
renderToolbarInternalActions?: (props: {
|
1040
1045
|
table: MRT_TableInstance<TData>;
|
1041
1046
|
}) => ReactNode;
|