material-react-table 0.12.1 → 0.12.2
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/material-react-table.cjs.development.js +18 -5
- 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 +18 -5
- package/dist/material-react-table.esm.js.map +1 -1
- package/dist/table/MRT_TableRoot.d.ts +0 -1
- package/package.json +1 -1
- package/src/table/MRT_TableRoot.tsx +90 -73
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.12.
|
|
2
|
+
"version": "0.12.2",
|
|
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.",
|
|
@@ -153,87 +153,104 @@ export const MRT_TableRoot = <D extends Record<string, any> = {}>(
|
|
|
153
153
|
[],
|
|
154
154
|
);
|
|
155
155
|
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
[
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
156
|
+
const [leadingDisplayColumns, trailingDisplayColumns] = useMemo(() => {
|
|
157
|
+
const leadingDisplayColumns = [
|
|
158
|
+
showActionColumn &&
|
|
159
|
+
createDisplayColumn(table, {
|
|
160
|
+
Cell: ({ cell }) => (
|
|
161
|
+
<MRT_ToggleRowActionMenuButton
|
|
162
|
+
row={cell.row as any}
|
|
163
|
+
instance={instance}
|
|
164
|
+
/>
|
|
165
|
+
),
|
|
166
|
+
header: props.localization?.actions,
|
|
167
|
+
id: 'mrt-row-actions',
|
|
168
|
+
muiTableBodyCellProps: props.muiTableBodyCellProps,
|
|
169
|
+
muiTableHeadCellProps: props.muiTableHeadCellProps,
|
|
170
|
+
size: 70,
|
|
171
|
+
}),
|
|
172
|
+
showExpandColumn &&
|
|
173
|
+
createDisplayColumn(table, {
|
|
174
|
+
Cell: ({ cell }) => (
|
|
175
|
+
<MRT_ExpandButton row={cell.row as any} instance={instance} />
|
|
176
|
+
),
|
|
177
|
+
Header: () =>
|
|
178
|
+
props.enableExpandAll ? (
|
|
179
|
+
<MRT_ExpandAllButton instance={instance} />
|
|
180
|
+
) : null,
|
|
181
|
+
header: props.localization?.expand,
|
|
182
|
+
id: 'mrt-expand',
|
|
183
|
+
muiTableBodyCellProps: props.muiTableBodyCellProps,
|
|
184
|
+
muiTableHeadCellProps: props.muiTableHeadCellProps,
|
|
185
|
+
size: 50,
|
|
186
|
+
}),
|
|
187
|
+
props.enableRowSelection &&
|
|
188
|
+
createDisplayColumn(table, {
|
|
189
|
+
Cell: ({ cell }) => (
|
|
190
|
+
<MRT_SelectCheckbox row={cell.row as any} instance={instance} />
|
|
191
|
+
),
|
|
192
|
+
Header: () =>
|
|
193
|
+
props.enableSelectAll ? (
|
|
194
|
+
<MRT_SelectCheckbox selectAll instance={instance} />
|
|
195
|
+
) : null,
|
|
196
|
+
header: props.localization?.select,
|
|
197
|
+
id: 'mrt-select',
|
|
198
|
+
muiTableBodyCellProps: props.muiTableBodyCellProps,
|
|
199
|
+
muiTableHeadCellProps: props.muiTableHeadCellProps,
|
|
200
|
+
size: 50,
|
|
201
|
+
}),
|
|
202
|
+
props.enableRowNumbers &&
|
|
203
|
+
createDisplayColumn(table, {
|
|
204
|
+
Cell: ({ cell }) => cell.row.index + 1,
|
|
205
|
+
Header: () => props.localization?.rowNumber,
|
|
206
|
+
header: props.localization?.rowNumbers,
|
|
207
|
+
id: 'mrt-row-numbers',
|
|
208
|
+
muiTableBodyCellProps: props.muiTableBodyCellProps,
|
|
209
|
+
muiTableHeadCellProps: props.muiTableHeadCellProps,
|
|
210
|
+
size: 50,
|
|
211
|
+
}),
|
|
212
|
+
].filter(Boolean) as MRT_ColumnDef<D>[];
|
|
213
|
+
|
|
214
|
+
const trailingDisplayColumns = [] as MRT_ColumnDef<D>[];
|
|
215
|
+
|
|
216
|
+
if (props.enableRowActions && props.positionActionsColumn === 'last') {
|
|
217
|
+
trailingDisplayColumns.push(
|
|
218
|
+
...leadingDisplayColumns.splice(
|
|
219
|
+
leadingDisplayColumns.findIndex(
|
|
220
|
+
(col) => col.id === 'mrt-row-actions',
|
|
221
|
+
),
|
|
222
|
+
1,
|
|
223
|
+
),
|
|
224
|
+
);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return [leadingDisplayColumns, trailingDisplayColumns];
|
|
228
|
+
}, [
|
|
229
|
+
props.editingMode,
|
|
230
|
+
props.enableEditing,
|
|
231
|
+
props.enableExpandAll,
|
|
232
|
+
props.enableExpanding,
|
|
233
|
+
props.enableGrouping,
|
|
234
|
+
props.enableRowActions,
|
|
235
|
+
props.enableRowNumbers,
|
|
236
|
+
props.enableRowSelection,
|
|
237
|
+
props.enableSelectAll,
|
|
238
|
+
props.localization,
|
|
239
|
+
props.muiTableBodyCellProps,
|
|
240
|
+
props.muiTableHeadCellProps,
|
|
241
|
+
props.positionActionsColumn,
|
|
242
|
+
table,
|
|
243
|
+
]);
|
|
228
244
|
|
|
229
245
|
const columns = useMemo(
|
|
230
246
|
() => [
|
|
231
|
-
...
|
|
247
|
+
...leadingDisplayColumns,
|
|
232
248
|
...props.columns.map((column) =>
|
|
233
249
|
column.columns
|
|
234
250
|
? createGroup(table, column as any, currentFilterFns)
|
|
235
251
|
: createDataColumn(table, column as any, currentFilterFns),
|
|
236
252
|
),
|
|
253
|
+
...trailingDisplayColumns,
|
|
237
254
|
],
|
|
238
255
|
[table, props.columns, currentFilterFns],
|
|
239
256
|
);
|