material-react-table 0.12.2 → 0.13.0
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 +4 -3
- package/dist/MaterialReactTable.d.ts +5 -5
- package/dist/icons.d.ts +1 -0
- package/dist/localization.d.ts +1 -1
- package/dist/material-react-table.cjs.development.js +49 -46
- package/dist/material-react-table.cjs.development.js.map +1 -1
- package/dist/material-react-table.cjs.production.min.js +1 -1
- package/dist/material-react-table.cjs.production.min.js.map +1 -1
- package/dist/material-react-table.esm.js +50 -47
- package/dist/material-react-table.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +6 -6
- package/src/body/MRT_TableBody.tsx +2 -2
- package/src/body/MRT_TableBodyCell.tsx +22 -10
- package/src/buttons/MRT_ExpandAllButton.tsx +3 -3
- package/src/buttons/MRT_ExpandButton.tsx +3 -3
- package/src/buttons/MRT_ToggleDensePaddingButton.tsx +22 -10
- package/src/footer/MRT_TableFooterCell.tsx +7 -2
- package/src/head/MRT_TableHeadCell.tsx +21 -9
- package/src/icons.ts +6 -3
- package/src/inputs/MRT_SelectCheckbox.tsx +4 -4
- package/src/localization.ts +2 -2
- package/src/menus/MRT_ColumnActionMenu.tsx +2 -2
- package/src/menus/MRT_FilterOptionMenu.tsx +2 -3
- package/src/menus/MRT_RowActionMenu.tsx +2 -2
- package/src/menus/MRT_ShowHideColumnsMenu.tsx +2 -2
- package/src/table/MRT_TableRoot.tsx +4 -4
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.13.0",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "material-react-table",
|
|
5
5
|
"description": "A fully featured Material UI implementation of TanStack React Table, inspired by material-table and the MUI X DataGrid, written from the ground up in TypeScript.",
|
|
@@ -121,7 +121,7 @@ export type MRT_TableInstance<D extends Record<string, any> = {}> = Omit<
|
|
|
121
121
|
}>
|
|
122
122
|
>;
|
|
123
123
|
setCurrentGlobalFilterFn: Dispatch<SetStateAction<MRT_FilterFn>>;
|
|
124
|
-
|
|
124
|
+
setDensity: Dispatch<SetStateAction<'comfortable' | 'compact' | 'spacious'>>;
|
|
125
125
|
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
|
126
126
|
setShowFilters: Dispatch<SetStateAction<boolean>>;
|
|
127
127
|
setShowGlobalFilter: Dispatch<SetStateAction<boolean>>;
|
|
@@ -132,7 +132,7 @@ export type MRT_TableState<D extends Record<string, any> = {}> = TableState & {
|
|
|
132
132
|
currentEditingRow: MRT_Row<D> | null;
|
|
133
133
|
currentFilterFns: Record<string, string | Function>;
|
|
134
134
|
currentGlobalFilterFn: Record<string, string | Function>;
|
|
135
|
-
|
|
135
|
+
density: 'comfortable' | 'compact' | 'spacious';
|
|
136
136
|
isLoading: boolean;
|
|
137
137
|
isFullScreen: boolean;
|
|
138
138
|
showFilters: boolean;
|
|
@@ -665,14 +665,14 @@ export type MaterialReactTableProps<D extends Record<string, any> = {}> =
|
|
|
665
665
|
event: ChangeEvent<HTMLInputElement>;
|
|
666
666
|
instance: MRT_TableInstance<D>;
|
|
667
667
|
}) => void;
|
|
668
|
-
|
|
669
|
-
|
|
668
|
+
onDensityChange?: OnChangeFn<boolean>;
|
|
669
|
+
onDensityChanged?: ({
|
|
670
670
|
event,
|
|
671
|
-
|
|
671
|
+
density,
|
|
672
672
|
instance,
|
|
673
673
|
}: {
|
|
674
674
|
event: MouseEvent<HTMLButtonElement>;
|
|
675
|
-
|
|
675
|
+
density: 'comfortable' | 'compact' | 'spacious';
|
|
676
676
|
instance: MRT_TableInstance<D>;
|
|
677
677
|
}) => void;
|
|
678
678
|
onIsFullScreenChange?: OnChangeFn<boolean>;
|
|
@@ -22,7 +22,7 @@ export const MRT_TableBody: FC<Props> = ({ instance, tableContainerRef }) => {
|
|
|
22
22
|
},
|
|
23
23
|
} = instance;
|
|
24
24
|
|
|
25
|
-
const {
|
|
25
|
+
const { density } = getState();
|
|
26
26
|
|
|
27
27
|
const tableBodyProps =
|
|
28
28
|
muiTableBodyProps instanceof Function
|
|
@@ -35,7 +35,7 @@ export const MRT_TableBody: FC<Props> = ({ instance, tableContainerRef }) => {
|
|
|
35
35
|
|
|
36
36
|
const rowVirtualizer = enableRowVirtualization
|
|
37
37
|
? useVirtual({
|
|
38
|
-
overscan:
|
|
38
|
+
overscan: density === 'compact' ? 15 : 5,
|
|
39
39
|
size: rows.length,
|
|
40
40
|
parentRef: tableContainerRef,
|
|
41
41
|
...virtualizerProps,
|
|
@@ -41,7 +41,7 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
41
41
|
columnOrder,
|
|
42
42
|
currentEditingCell,
|
|
43
43
|
currentEditingRow,
|
|
44
|
-
|
|
44
|
+
density,
|
|
45
45
|
isLoading,
|
|
46
46
|
showSkeletons,
|
|
47
47
|
} = getState();
|
|
@@ -152,23 +152,35 @@ export const MRT_TableBodyCell: FC<Props> = ({
|
|
|
152
152
|
? `${column.getStart('left')}px`
|
|
153
153
|
: undefined,
|
|
154
154
|
overflow: 'hidden',
|
|
155
|
-
p:
|
|
156
|
-
|
|
157
|
-
?
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
155
|
+
p:
|
|
156
|
+
density === 'compact'
|
|
157
|
+
? columnDefType === 'display'
|
|
158
|
+
? '0 0.5rem'
|
|
159
|
+
: '0.5rem'
|
|
160
|
+
: density === 'comfortable'
|
|
161
|
+
? columnDefType === 'display'
|
|
162
|
+
? '0.5rem 0.75rem'
|
|
163
|
+
: '1rem'
|
|
164
|
+
: columnDefType === 'display'
|
|
165
|
+
? '1rem 1.25rem'
|
|
166
|
+
: '1.5rem',
|
|
162
167
|
pl:
|
|
163
168
|
column.id === 'mrt-expand'
|
|
164
|
-
? `${
|
|
169
|
+
? `${
|
|
170
|
+
row.depth +
|
|
171
|
+
(density === 'compact'
|
|
172
|
+
? 0.5
|
|
173
|
+
: density === 'comfortable'
|
|
174
|
+
? 0.75
|
|
175
|
+
: 1.25)
|
|
176
|
+
}rem`
|
|
165
177
|
: undefined,
|
|
166
178
|
position: column.getIsPinned() ? 'sticky' : 'relative',
|
|
167
179
|
right:
|
|
168
180
|
column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined,
|
|
169
181
|
textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined,
|
|
170
182
|
transition: 'all 0.2s ease-in-out',
|
|
171
|
-
whiteSpace:
|
|
183
|
+
whiteSpace: density === 'compact' ? 'nowrap' : 'normal',
|
|
172
184
|
zIndex: column.getIsPinned() ? 1 : undefined,
|
|
173
185
|
'&:hover': {
|
|
174
186
|
backgroundColor:
|
|
@@ -20,7 +20,7 @@ export const MRT_ExpandAllButton: FC<Props> = ({ instance }) => {
|
|
|
20
20
|
toggleAllRowsExpanded,
|
|
21
21
|
} = instance;
|
|
22
22
|
|
|
23
|
-
const {
|
|
23
|
+
const { density } = getState();
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
26
|
<Tooltip
|
|
@@ -34,8 +34,8 @@ export const MRT_ExpandAllButton: FC<Props> = ({ instance }) => {
|
|
|
34
34
|
disabled={!getCanSomeRowsExpand() && !renderDetailPanel}
|
|
35
35
|
onClick={() => toggleAllRowsExpanded(!getIsAllRowsExpanded())}
|
|
36
36
|
sx={{
|
|
37
|
-
height:
|
|
38
|
-
width:
|
|
37
|
+
height: density === 'compact' ? '1.75rem' : '2.25rem',
|
|
38
|
+
width: density === 'compact' ? '1.75rem' : '2.25rem',
|
|
39
39
|
}}
|
|
40
40
|
>
|
|
41
41
|
<KeyboardDoubleArrowDownIcon
|
|
@@ -18,7 +18,7 @@ export const MRT_ExpandButton: FC<Props> = ({ row, instance }) => {
|
|
|
18
18
|
},
|
|
19
19
|
} = instance;
|
|
20
20
|
|
|
21
|
-
const {
|
|
21
|
+
const { density } = getState();
|
|
22
22
|
|
|
23
23
|
const handleToggleExpand = (event: MouseEvent<HTMLButtonElement>) => {
|
|
24
24
|
row.toggleExpanded();
|
|
@@ -37,8 +37,8 @@ export const MRT_ExpandButton: FC<Props> = ({ row, instance }) => {
|
|
|
37
37
|
disabled={!row.getCanExpand() && !renderDetailPanel}
|
|
38
38
|
onClick={handleToggleExpand}
|
|
39
39
|
sx={{
|
|
40
|
-
height:
|
|
41
|
-
width:
|
|
40
|
+
height: density === 'compact' ? '1.75rem' : '2.25rem',
|
|
41
|
+
width: density === 'compact' ? '1.75rem' : '2.25rem',
|
|
42
42
|
}}
|
|
43
43
|
>
|
|
44
44
|
<ExpandMoreIcon
|
|
@@ -13,32 +13,44 @@ export const MRT_ToggleDensePaddingButton: FC<Props> = ({
|
|
|
13
13
|
const {
|
|
14
14
|
getState,
|
|
15
15
|
options: {
|
|
16
|
-
icons: { DensityMediumIcon, DensitySmallIcon },
|
|
16
|
+
icons: { DensityLargeIcon, DensityMediumIcon, DensitySmallIcon },
|
|
17
17
|
localization,
|
|
18
|
-
|
|
18
|
+
onDensityChanged,
|
|
19
19
|
},
|
|
20
|
-
|
|
20
|
+
setDensity,
|
|
21
21
|
} = instance;
|
|
22
22
|
|
|
23
|
-
const {
|
|
23
|
+
const { density } = getState();
|
|
24
24
|
|
|
25
25
|
const handleToggleDensePadding = (event: MouseEvent<HTMLButtonElement>) => {
|
|
26
|
-
|
|
26
|
+
const nextDensity =
|
|
27
|
+
density === 'comfortable'
|
|
28
|
+
? 'compact'
|
|
29
|
+
: density === 'compact'
|
|
30
|
+
? 'spacious'
|
|
31
|
+
: 'comfortable';
|
|
32
|
+
onDensityChanged?.({
|
|
27
33
|
event,
|
|
28
|
-
|
|
34
|
+
density: nextDensity,
|
|
29
35
|
instance,
|
|
30
36
|
});
|
|
31
|
-
|
|
37
|
+
setDensity(nextDensity);
|
|
32
38
|
};
|
|
33
39
|
|
|
34
40
|
return (
|
|
35
|
-
<Tooltip arrow title={localization.
|
|
41
|
+
<Tooltip arrow title={localization.toggleDensity}>
|
|
36
42
|
<IconButton
|
|
37
|
-
aria-label={localization.
|
|
43
|
+
aria-label={localization.toggleDensity}
|
|
38
44
|
onClick={handleToggleDensePadding}
|
|
39
45
|
{...rest}
|
|
40
46
|
>
|
|
41
|
-
{
|
|
47
|
+
{density === 'compact' ? (
|
|
48
|
+
<DensitySmallIcon />
|
|
49
|
+
) : density === 'comfortable' ? (
|
|
50
|
+
<DensityMediumIcon />
|
|
51
|
+
) : (
|
|
52
|
+
<DensityLargeIcon />
|
|
53
|
+
)}
|
|
42
54
|
</IconButton>
|
|
43
55
|
</Tooltip>
|
|
44
56
|
);
|
|
@@ -13,7 +13,7 @@ export const MRT_TableFooterCell: FC<Props> = ({ footer, instance }) => {
|
|
|
13
13
|
options: { muiTableFooterCellProps, enableColumnResizing },
|
|
14
14
|
} = instance;
|
|
15
15
|
|
|
16
|
-
const {
|
|
16
|
+
const { density } = getState();
|
|
17
17
|
|
|
18
18
|
const { column } = footer;
|
|
19
19
|
|
|
@@ -49,7 +49,12 @@ export const MRT_TableFooterCell: FC<Props> = ({ footer, instance }) => {
|
|
|
49
49
|
fontWeight: 'bold',
|
|
50
50
|
maxWidth: `${column.getSize()}px`,
|
|
51
51
|
minWidth: `${column.getSize()}px`,
|
|
52
|
-
p:
|
|
52
|
+
p:
|
|
53
|
+
density === 'compact'
|
|
54
|
+
? '0.5rem'
|
|
55
|
+
: density === 'comfortable'
|
|
56
|
+
? '1rem'
|
|
57
|
+
: '1.5rem',
|
|
53
58
|
transition: `all ${enableColumnResizing ? '10ms' : '0.2s'} ease-in-out`,
|
|
54
59
|
width: column.getSize(),
|
|
55
60
|
verticalAlign: 'text-top',
|
|
@@ -37,7 +37,7 @@ export const MRT_TableHeadCell: FC<Props> = ({
|
|
|
37
37
|
},
|
|
38
38
|
} = instance;
|
|
39
39
|
|
|
40
|
-
const {
|
|
40
|
+
const { density } = getState();
|
|
41
41
|
|
|
42
42
|
const { column } = header;
|
|
43
43
|
|
|
@@ -111,19 +111,31 @@ export const MRT_TableHeadCell: FC<Props> = ({
|
|
|
111
111
|
? `${column.getStart('left')}px`
|
|
112
112
|
: undefined,
|
|
113
113
|
overflow: 'visible',
|
|
114
|
-
p:
|
|
115
|
-
|
|
116
|
-
?
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
114
|
+
p:
|
|
115
|
+
density === 'compact'
|
|
116
|
+
? columnDefType === 'display'
|
|
117
|
+
? '0 0.5rem'
|
|
118
|
+
: '0.5rem'
|
|
119
|
+
: density === 'comfortable'
|
|
120
|
+
? columnDefType === 'display'
|
|
121
|
+
? '0.5rem 0.75rem'
|
|
122
|
+
: '1rem'
|
|
123
|
+
: columnDefType === 'display'
|
|
124
|
+
? '1rem 1.25rem'
|
|
125
|
+
: '1.5rem',
|
|
121
126
|
pb: columnDefType === 'display' ? 0 : undefined,
|
|
122
127
|
position:
|
|
123
128
|
column.getIsPinned() && columnDefType !== 'group'
|
|
124
129
|
? 'sticky'
|
|
125
130
|
: undefined,
|
|
126
|
-
pt:
|
|
131
|
+
pt:
|
|
132
|
+
columnDefType !== 'data'
|
|
133
|
+
? 0
|
|
134
|
+
: density === 'compact'
|
|
135
|
+
? '0.25'
|
|
136
|
+
: density === 'comfortable'
|
|
137
|
+
? '.75rem'
|
|
138
|
+
: '1.25rem',
|
|
127
139
|
right:
|
|
128
140
|
column.getIsPinned() === 'right' ? `${getTotalRight()}px` : undefined,
|
|
129
141
|
transition: `all ${enableColumnResizing ? 0 : '0.2s'} ease-in-out`,
|
package/src/icons.ts
CHANGED
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
CheckBox,
|
|
5
5
|
ClearAll,
|
|
6
6
|
Close,
|
|
7
|
+
DensityLarge,
|
|
7
8
|
DensityMedium,
|
|
8
9
|
DensitySmall,
|
|
9
|
-
KeyboardDoubleArrowDown,
|
|
10
10
|
DragHandle,
|
|
11
11
|
DynamicFeed,
|
|
12
12
|
Edit,
|
|
@@ -16,8 +16,9 @@ import {
|
|
|
16
16
|
FilterAltOff,
|
|
17
17
|
FilterList,
|
|
18
18
|
FilterListOff,
|
|
19
|
-
FullscreenExit,
|
|
20
19
|
Fullscreen,
|
|
20
|
+
FullscreenExit,
|
|
21
|
+
KeyboardDoubleArrowDown,
|
|
21
22
|
MoreHoriz,
|
|
22
23
|
MoreVert,
|
|
23
24
|
PushPin,
|
|
@@ -36,6 +37,7 @@ export interface MRT_Icons {
|
|
|
36
37
|
CheckBoxIcon: any;
|
|
37
38
|
ClearAllIcon: any;
|
|
38
39
|
CloseIcon: any;
|
|
40
|
+
DensityLargeIcon: any;
|
|
39
41
|
DensityMediumIcon: any;
|
|
40
42
|
DensitySmallIcon: any;
|
|
41
43
|
KeyboardDoubleArrowDownIcon: any;
|
|
@@ -68,9 +70,9 @@ export const MRT_Default_Icons: MRT_Icons = {
|
|
|
68
70
|
CheckBoxIcon: CheckBox,
|
|
69
71
|
ClearAllIcon: ClearAll,
|
|
70
72
|
CloseIcon: Close,
|
|
73
|
+
DensityLargeIcon: DensityLarge,
|
|
71
74
|
DensityMediumIcon: DensityMedium,
|
|
72
75
|
DensitySmallIcon: DensitySmall,
|
|
73
|
-
KeyboardDoubleArrowDownIcon: KeyboardDoubleArrowDown,
|
|
74
76
|
DragHandleIcon: DragHandle,
|
|
75
77
|
DynamicFeedIcon: DynamicFeed,
|
|
76
78
|
EditIcon: Edit,
|
|
@@ -82,6 +84,7 @@ export const MRT_Default_Icons: MRT_Icons = {
|
|
|
82
84
|
FilterListOffIcon: FilterListOff,
|
|
83
85
|
FullscreenExitIcon: FullscreenExit,
|
|
84
86
|
FullscreenIcon: Fullscreen,
|
|
87
|
+
KeyboardDoubleArrowDownIcon: KeyboardDoubleArrowDown,
|
|
85
88
|
MoreHorizIcon: MoreHoriz,
|
|
86
89
|
MoreVertIcon: MoreVert,
|
|
87
90
|
PushPinIcon: PushPin,
|
|
@@ -22,7 +22,7 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll, instance }) => {
|
|
|
22
22
|
},
|
|
23
23
|
} = instance;
|
|
24
24
|
|
|
25
|
-
const {
|
|
25
|
+
const { density } = getState();
|
|
26
26
|
|
|
27
27
|
const handleSelectChange = (event: ChangeEvent<HTMLInputElement>) => {
|
|
28
28
|
if (selectAll) {
|
|
@@ -80,11 +80,11 @@ export const MRT_SelectCheckbox: FC<Props> = ({ row, selectAll, instance }) => {
|
|
|
80
80
|
: localization.toggleSelectRow,
|
|
81
81
|
}}
|
|
82
82
|
onChange={handleSelectChange}
|
|
83
|
-
size={
|
|
83
|
+
size={density === 'compact' ? 'small' : 'medium'}
|
|
84
84
|
{...checkboxProps}
|
|
85
85
|
sx={{
|
|
86
|
-
height:
|
|
87
|
-
width:
|
|
86
|
+
height: density === 'compact' ? '1.75rem' : '2.25rem',
|
|
87
|
+
width: density === 'compact' ? '1.75rem' : '2.25rem',
|
|
88
88
|
...checkboxProps?.sx,
|
|
89
89
|
}}
|
|
90
90
|
/>
|
package/src/localization.ts
CHANGED
|
@@ -56,7 +56,7 @@ export interface MRT_Localization {
|
|
|
56
56
|
sortedByColumnDesc: string;
|
|
57
57
|
thenBy: string;
|
|
58
58
|
to: string;
|
|
59
|
-
|
|
59
|
+
toggleDensity: string;
|
|
60
60
|
toggleFullScreen: string;
|
|
61
61
|
toggleSelectAll: string;
|
|
62
62
|
toggleSelectRow: string;
|
|
@@ -125,7 +125,7 @@ export const MRT_DefaultLocalization_EN: MRT_Localization = {
|
|
|
125
125
|
sortedByColumnDesc: 'Sorted by {column} descending',
|
|
126
126
|
thenBy: ', then by ',
|
|
127
127
|
to: 'to',
|
|
128
|
-
|
|
128
|
+
toggleDensity: 'Toggle density',
|
|
129
129
|
toggleFullScreen: 'Toggle full screen',
|
|
130
130
|
toggleSelectAll: 'Toggle select all',
|
|
131
131
|
toggleSelectRow: 'Toggle select row',
|
|
@@ -62,7 +62,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
62
62
|
|
|
63
63
|
const { columnDef } = column;
|
|
64
64
|
|
|
65
|
-
const { columnSizing, columnVisibility,
|
|
65
|
+
const { columnSizing, columnVisibility, density } = getState();
|
|
66
66
|
|
|
67
67
|
const [filterMenuAnchorEl, setFilterMenuAnchorEl] =
|
|
68
68
|
useState<null | HTMLElement>(null);
|
|
@@ -150,7 +150,7 @@ export const MRT_ColumnActionMenu: FC<Props> = ({
|
|
|
150
150
|
open={!!anchorEl}
|
|
151
151
|
onClose={() => setAnchorEl(null)}
|
|
152
152
|
MenuListProps={{
|
|
153
|
-
dense:
|
|
153
|
+
dense: density === 'compact',
|
|
154
154
|
}}
|
|
155
155
|
>
|
|
156
156
|
{enableSorting &&
|
|
@@ -52,8 +52,7 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
|
52
52
|
setCurrentGlobalFilterFn,
|
|
53
53
|
} = instance;
|
|
54
54
|
|
|
55
|
-
const {
|
|
56
|
-
getState();
|
|
55
|
+
const { density, currentFilterFns, currentGlobalFilterFn } = getState();
|
|
57
56
|
|
|
58
57
|
const { column } = header ?? {};
|
|
59
58
|
|
|
@@ -178,7 +177,7 @@ export const MRT_FilterOptionMenu: FC<Props> = ({
|
|
|
178
177
|
onClose={() => setAnchorEl(null)}
|
|
179
178
|
open={!!anchorEl}
|
|
180
179
|
MenuListProps={{
|
|
181
|
-
dense:
|
|
180
|
+
dense: density === 'compact',
|
|
182
181
|
}}
|
|
183
182
|
>
|
|
184
183
|
{filterOptions.map(({ option, label, divider, fn }, index) => (
|
|
@@ -31,7 +31,7 @@ export const MRT_RowActionMenu: FC<Props> = ({
|
|
|
31
31
|
},
|
|
32
32
|
} = instance;
|
|
33
33
|
|
|
34
|
-
const {
|
|
34
|
+
const { density } = getState();
|
|
35
35
|
|
|
36
36
|
return (
|
|
37
37
|
<Menu
|
|
@@ -39,7 +39,7 @@ export const MRT_RowActionMenu: FC<Props> = ({
|
|
|
39
39
|
open={!!anchorEl}
|
|
40
40
|
onClose={() => setAnchorEl(null)}
|
|
41
41
|
MenuListProps={{
|
|
42
|
-
dense:
|
|
42
|
+
dense: density === 'compact',
|
|
43
43
|
}}
|
|
44
44
|
>
|
|
45
45
|
{enableEditing && (
|
|
@@ -30,7 +30,7 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
|
|
|
30
30
|
options: { localization, enablePinning, enableColumnOrdering },
|
|
31
31
|
} = instance;
|
|
32
32
|
|
|
33
|
-
const {
|
|
33
|
+
const { density, columnOrder, columnPinning } = getState();
|
|
34
34
|
|
|
35
35
|
const hideAllColumns = () => {
|
|
36
36
|
getAllLeafColumns()
|
|
@@ -68,7 +68,7 @@ export const MRT_ShowHideColumnsMenu: FC<Props> = ({
|
|
|
68
68
|
open={!!anchorEl}
|
|
69
69
|
onClose={() => setAnchorEl(null)}
|
|
70
70
|
MenuListProps={{
|
|
71
|
-
dense:
|
|
71
|
+
dense: density === 'compact',
|
|
72
72
|
}}
|
|
73
73
|
>
|
|
74
74
|
<Box
|
|
@@ -102,8 +102,8 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
102
102
|
const [currentEditingRow, setCurrentEditingRow] = useState<MRT_Row<D> | null>(
|
|
103
103
|
initialState?.currentEditingRow ?? null,
|
|
104
104
|
);
|
|
105
|
-
const [
|
|
106
|
-
initialState?.
|
|
105
|
+
const [density, setDensity] = useState(
|
|
106
|
+
initialState?.density ?? 'comfortable',
|
|
107
107
|
);
|
|
108
108
|
const [isFullScreen, setIsFullScreen] = useState(
|
|
109
109
|
initialState?.isFullScreen ?? false,
|
|
@@ -288,7 +288,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
288
288
|
currentEditingRow,
|
|
289
289
|
currentFilterFns,
|
|
290
290
|
currentGlobalFilterFn,
|
|
291
|
-
|
|
291
|
+
density,
|
|
292
292
|
isFullScreen,
|
|
293
293
|
showFilters,
|
|
294
294
|
showGlobalFilter,
|
|
@@ -302,7 +302,7 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
302
302
|
setCurrentFilterFns: props.onCurrentFilterFnsChange ?? setCurrentFilterFns,
|
|
303
303
|
setCurrentGlobalFilterFn:
|
|
304
304
|
props.onCurrentGlobalFilterFnChange ?? setCurrentGlobalFilterFn,
|
|
305
|
-
|
|
305
|
+
setDensity: props.onDensityChange ?? setDensity,
|
|
306
306
|
setIsFullScreen: props.onIsFullScreenChange ?? setIsFullScreen,
|
|
307
307
|
setShowFilters: props.onShowFiltersChange ?? setShowFilters,
|
|
308
308
|
setShowGlobalFilter: props.onShowGlobalFilterChange ?? setShowGlobalFilter,
|