material-react-table 0.37.0 → 0.37.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 +6 -3
- package/dist/cjs/column.utils.d.ts +2 -1
- package/dist/cjs/index.js +22 -18
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/column.utils.d.ts +2 -1
- package/dist/esm/material-react-table.esm.js +22 -18
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/package.json +4 -4
- package/src/column.utils.ts +13 -7
- package/src/table/MRT_TableRoot.tsx +24 -14
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.37.
|
|
2
|
+
"version": "0.37.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.",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@emotion/styled": "^11.10.0",
|
|
56
56
|
"@faker-js/faker": "^7.4.0",
|
|
57
57
|
"@mui/icons-material": "^5.8.4",
|
|
58
|
-
"@mui/material": "^5.10.
|
|
58
|
+
"@mui/material": "^5.10.1",
|
|
59
59
|
"@rollup/plugin-babel": "^5.3.1",
|
|
60
60
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
61
61
|
"@rollup/plugin-typescript": "^8.3.4",
|
|
@@ -71,14 +71,14 @@
|
|
|
71
71
|
"@types/react": "^18.0.17",
|
|
72
72
|
"@types/react-dom": "^18.0.6",
|
|
73
73
|
"babel-loader": "^8.2.5",
|
|
74
|
-
"eslint": "^8.
|
|
74
|
+
"eslint": "^8.22.0",
|
|
75
75
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
76
76
|
"husky": "^8.0.1",
|
|
77
77
|
"prettier": "^2.7.1",
|
|
78
78
|
"react": "^18.2.0",
|
|
79
79
|
"react-dom": "^18.2.0",
|
|
80
80
|
"react-is": "^18.2.0",
|
|
81
|
-
"rollup": "^2.
|
|
81
|
+
"rollup": "^2.78.0",
|
|
82
82
|
"rollup-plugin-dts": "^4.2.2",
|
|
83
83
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
84
84
|
"size-limit": "^8.0.1",
|
package/src/column.utils.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnOrderState } from '@tanstack/react-table';
|
|
1
|
+
import { ColumnOrderState, GroupingState } from '@tanstack/react-table';
|
|
2
2
|
import {
|
|
3
3
|
MaterialReactTableProps,
|
|
4
4
|
MRT_Column,
|
|
@@ -107,6 +107,16 @@ export const reorderColumn = <TData extends Record<string, any> = {}>(
|
|
|
107
107
|
return [...columnOrder];
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
+
export const showExpandColumn = <TData extends Record<string, any> = {}>(
|
|
111
|
+
props: MaterialReactTableProps<TData>,
|
|
112
|
+
grouping?: GroupingState,
|
|
113
|
+
) =>
|
|
114
|
+
!!(
|
|
115
|
+
props.enableExpanding ||
|
|
116
|
+
(props.enableGrouping && (grouping === undefined || grouping?.length)) ||
|
|
117
|
+
props.renderDetailPanel
|
|
118
|
+
);
|
|
119
|
+
|
|
110
120
|
export const getLeadingDisplayColumnIds = <
|
|
111
121
|
TData extends Record<string, any> = {},
|
|
112
122
|
>(
|
|
@@ -119,9 +129,7 @@ export const getLeadingDisplayColumnIds = <
|
|
|
119
129
|
['row', 'modal'].includes(props.editingMode ?? ''))) &&
|
|
120
130
|
'mrt-row-actions',
|
|
121
131
|
props.positionExpandColumn === 'first' &&
|
|
122
|
-
(props
|
|
123
|
-
props.enableGrouping ||
|
|
124
|
-
props.renderDetailPanel) &&
|
|
132
|
+
showExpandColumn(props) &&
|
|
125
133
|
'mrt-row-expand',
|
|
126
134
|
props.enableRowSelection && 'mrt-row-select',
|
|
127
135
|
props.enableRowNumbers && 'mrt-row-numbers',
|
|
@@ -137,9 +145,7 @@ export const getTrailingDisplayColumnIds = <
|
|
|
137
145
|
['row', 'modal'].includes(props.editingMode ?? ''))) &&
|
|
138
146
|
'mrt-row-actions',
|
|
139
147
|
props.positionExpandColumn === 'last' &&
|
|
140
|
-
(props
|
|
141
|
-
props.enableGrouping ||
|
|
142
|
-
props.renderDetailPanel) &&
|
|
148
|
+
showExpandColumn(props) &&
|
|
143
149
|
'mrt-row-expand',
|
|
144
150
|
];
|
|
145
151
|
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
getPaginationRowModel,
|
|
10
10
|
getSortedRowModel,
|
|
11
11
|
useReactTable,
|
|
12
|
+
GroupingState,
|
|
12
13
|
} from '@tanstack/react-table';
|
|
13
14
|
import { Box, Dialog, Grow } from '@mui/material';
|
|
14
15
|
import { MRT_ExpandAllButton } from '../buttons/MRT_ExpandAllButton';
|
|
@@ -22,6 +23,7 @@ import {
|
|
|
22
23
|
getDefaultColumnOrderIds,
|
|
23
24
|
getDefaultColumnFilterFn,
|
|
24
25
|
defaultDisplayColumnDefOptions,
|
|
26
|
+
showExpandColumn,
|
|
25
27
|
} from '../column.utils';
|
|
26
28
|
import type {
|
|
27
29
|
MRT_Cell,
|
|
@@ -95,6 +97,9 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
95
97
|
const [globalFilterFn, setGlobalFilterFn] = useState<MRT_FilterOption>(
|
|
96
98
|
initialState.globalFilterFn ?? 'fuzzy',
|
|
97
99
|
);
|
|
100
|
+
const [grouping, setGrouping] = useState<GroupingState>(
|
|
101
|
+
initialState.grouping ?? [],
|
|
102
|
+
);
|
|
98
103
|
const [hoveredColumn, setHoveredColumn] = useState<
|
|
99
104
|
MRT_Column<TData> | { id: string } | null
|
|
100
105
|
>(initialState.hoveredColumn ?? null);
|
|
@@ -135,20 +140,21 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
135
140
|
...props.displayColumnDefOptions?.['mrt-row-actions'],
|
|
136
141
|
id: 'mrt-row-actions',
|
|
137
142
|
},
|
|
138
|
-
columnOrder.includes('mrt-row-expand') &&
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
143
|
+
columnOrder.includes('mrt-row-expand') &&
|
|
144
|
+
showExpandColumn(props, grouping) && {
|
|
145
|
+
Cell: ({ row }) => (
|
|
146
|
+
<MRT_ExpandButton row={row as any} table={table} />
|
|
147
|
+
),
|
|
148
|
+
Header: () =>
|
|
149
|
+
props.enableExpandAll ? (
|
|
150
|
+
<MRT_ExpandAllButton table={table} />
|
|
151
|
+
) : null,
|
|
152
|
+
header: props.localization?.expand,
|
|
153
|
+
size: 60,
|
|
154
|
+
...defaultDisplayColumnDefOptions,
|
|
155
|
+
...props.displayColumnDefOptions?.['mrt-row-expand'],
|
|
156
|
+
id: 'mrt-row-expand',
|
|
157
|
+
},
|
|
152
158
|
columnOrder.includes('mrt-row-select') && {
|
|
153
159
|
Cell: ({ row }) => (
|
|
154
160
|
<MRT_SelectCheckbox row={row as any} table={table} />
|
|
@@ -176,6 +182,7 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
176
182
|
).filter(Boolean),
|
|
177
183
|
[
|
|
178
184
|
columnOrder,
|
|
185
|
+
grouping,
|
|
179
186
|
props.displayColumnDefOptions,
|
|
180
187
|
props.editingMode,
|
|
181
188
|
props.enableColumnDragging,
|
|
@@ -192,6 +199,7 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
192
199
|
props.enableSelectAll,
|
|
193
200
|
props.localization,
|
|
194
201
|
props.positionActionsColumn,
|
|
202
|
+
props.renderDetailPanel,
|
|
195
203
|
],
|
|
196
204
|
);
|
|
197
205
|
|
|
@@ -241,6 +249,7 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
241
249
|
getPaginationRowModel: getPaginationRowModel(),
|
|
242
250
|
getSortedRowModel: getSortedRowModel(),
|
|
243
251
|
onColumnOrderChange: setColumnOrder,
|
|
252
|
+
onGroupingChange: setGrouping,
|
|
244
253
|
getSubRows: (row) => row?.subRows,
|
|
245
254
|
...props,
|
|
246
255
|
//@ts-ignore
|
|
@@ -258,6 +267,7 @@ export const MRT_TableRoot = <TData extends Record<string, any> = {}>(
|
|
|
258
267
|
editingCell,
|
|
259
268
|
editingRow,
|
|
260
269
|
globalFilterFn,
|
|
270
|
+
grouping,
|
|
261
271
|
hoveredColumn,
|
|
262
272
|
hoveredRow,
|
|
263
273
|
isFullScreen,
|