material-react-table 0.37.2 → 0.38.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/dist/cjs/MaterialReactTable.d.ts +16 -7
- package/dist/cjs/index.js +27 -17
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/MaterialReactTable.d.ts +16 -7
- package/dist/esm/material-react-table.esm.js +27 -17
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/index.d.ts +16 -7
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +21 -6
- package/src/body/MRT_TableBodyCell.tsx +3 -1
- package/src/body/MRT_TableBodyCellValue.tsx +9 -1
- package/src/toolbar/MRT_BottomToolbar.tsx +4 -4
- package/src/toolbar/MRT_ToolbarAlertBanner.tsx +14 -5
- package/src/toolbar/MRT_TopToolbar.tsx +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dispatch, DragEvent, MutableRefObject, ReactNode, SetStateAction } from 'react';
|
|
2
|
-
import type { AlertProps, ButtonProps, CheckboxProps, IconButtonProps, LinearProgressProps, PaperProps, SkeletonProps, TableBodyProps, TableCellProps, TableContainerProps, TableFooterProps, TableHeadProps, TablePaginationProps, TableProps, TableRowProps, TextFieldProps, ToolbarProps } from '@mui/material';
|
|
2
|
+
import type { AlertProps, ButtonProps, CheckboxProps, ChipProps, IconButtonProps, LinearProgressProps, PaperProps, SkeletonProps, TableBodyProps, TableCellProps, TableContainerProps, TableFooterProps, TableHeadProps, TablePaginationProps, TableProps, TableRowProps, TextFieldProps, ToolbarProps } from '@mui/material';
|
|
3
3
|
import type { Cell, Column, ColumnDef, DeepKeys, FilterFn, Header, HeaderGroup, OnChangeFn, Row, SortingFn, Table, TableOptions, TableState } from '@tanstack/react-table';
|
|
4
4
|
import type { Options as VirtualizerOptions } from 'react-virtual';
|
|
5
5
|
import { MRT_Icons } from './icons';
|
|
@@ -113,6 +113,12 @@ export declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit
|
|
|
113
113
|
footer: MRT_Header<TData>;
|
|
114
114
|
table: MRT_TableInstance<TData>;
|
|
115
115
|
}) => ReactNode);
|
|
116
|
+
GroupedCell?: ({ cell, column, row, table, }: {
|
|
117
|
+
cell: MRT_Cell<TData>;
|
|
118
|
+
column: MRT_Column<TData>;
|
|
119
|
+
row: MRT_Row<TData>;
|
|
120
|
+
table: MRT_TableInstance<TData>;
|
|
121
|
+
}) => ReactNode;
|
|
116
122
|
Header?: ReactNode | (({ column, header, table, }: {
|
|
117
123
|
column: MRT_Column<TData>;
|
|
118
124
|
header: MRT_Header<TData>;
|
|
@@ -292,6 +298,9 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
292
298
|
icons?: Partial<MRT_Icons>;
|
|
293
299
|
initialState?: Partial<MRT_TableState<TData>>;
|
|
294
300
|
localization?: Partial<MRT_Localization>;
|
|
301
|
+
muiBottomToolbarProps?: ToolbarProps | (({ table }: {
|
|
302
|
+
table: MRT_TableInstance<TData>;
|
|
303
|
+
}) => ToolbarProps);
|
|
295
304
|
muiExpandAllButtonProps?: IconButtonProps | (({ table }: {
|
|
296
305
|
table: MRT_TableInstance<TData>;
|
|
297
306
|
}) => IconButtonProps);
|
|
@@ -346,9 +355,6 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
346
355
|
table: MRT_TableInstance<TData>;
|
|
347
356
|
row: MRT_Row<TData>;
|
|
348
357
|
}) => TableRowProps);
|
|
349
|
-
muiTableBottomToolbarProps?: ToolbarProps | (({ table }: {
|
|
350
|
-
table: MRT_TableInstance<TData>;
|
|
351
|
-
}) => ToolbarProps);
|
|
352
358
|
muiTableContainerProps?: TableContainerProps | (({ table, }: {
|
|
353
359
|
table: MRT_TableInstance<TData>;
|
|
354
360
|
}) => TableContainerProps);
|
|
@@ -400,10 +406,13 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
400
406
|
muiTableProps?: TableProps | (({ table }: {
|
|
401
407
|
table: MRT_TableInstance<TData>;
|
|
402
408
|
}) => TableProps);
|
|
403
|
-
|
|
409
|
+
muiToolbarAlertBannerChipProps?: ChipProps | (({ table }: {
|
|
410
|
+
table: MRT_TableInstance<TData>;
|
|
411
|
+
}) => ChipProps);
|
|
412
|
+
muiToolbarAlertBannerProps?: AlertProps | (({ table }: {
|
|
404
413
|
table: MRT_TableInstance<TData>;
|
|
405
414
|
}) => AlertProps);
|
|
406
|
-
|
|
415
|
+
muiTopToolbarProps?: ToolbarProps | (({ table }: {
|
|
407
416
|
table: MRT_TableInstance<TData>;
|
|
408
417
|
}) => ToolbarProps);
|
|
409
418
|
onColumnDrop?: ({ event, draggedColumn, targetColumn, }: {
|
|
@@ -416,13 +425,13 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
416
425
|
onDensityChange?: OnChangeFn<boolean>;
|
|
417
426
|
onDraggingColumnChange?: OnChangeFn<MRT_Column<TData> | null>;
|
|
418
427
|
onDraggingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
|
|
428
|
+
onEditingCellChange?: OnChangeFn<MRT_Cell<TData> | null>;
|
|
419
429
|
onEditingRowSave?: ({ exitEditingMode, row, table, values, }: {
|
|
420
430
|
exitEditingMode: () => void;
|
|
421
431
|
row: MRT_Row<TData>;
|
|
422
432
|
table: MRT_TableInstance<TData>;
|
|
423
433
|
values: Record<LiteralUnion<string & DeepKeys<TData>>, any>;
|
|
424
434
|
}) => Promise<void> | void;
|
|
425
|
-
onEditingCellChange?: OnChangeFn<MRT_Cell<TData> | null>;
|
|
426
435
|
onEditingRowChange?: OnChangeFn<MRT_Row<TData> | null>;
|
|
427
436
|
onFilterFnsChange?: OnChangeFn<{
|
|
428
437
|
[key: string]: MRT_FilterOption;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1053,11 +1053,14 @@ const MRT_TablePagination = ({ table, position }) => {
|
|
|
1053
1053
|
|
|
1054
1054
|
const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
|
|
1055
1055
|
var _a, _b;
|
|
1056
|
-
const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization,
|
|
1056
|
+
const { getPrePaginationRowModel, getSelectedRowModel, getState, options: { localization, muiToolbarAlertBannerProps, muiToolbarAlertBannerChipProps, }, } = table;
|
|
1057
1057
|
const { grouping, showAlertBanner } = getState();
|
|
1058
|
-
const alertProps =
|
|
1059
|
-
?
|
|
1060
|
-
:
|
|
1058
|
+
const alertProps = muiToolbarAlertBannerProps instanceof Function
|
|
1059
|
+
? muiToolbarAlertBannerProps({ table })
|
|
1060
|
+
: muiToolbarAlertBannerProps;
|
|
1061
|
+
const chipProps = muiToolbarAlertBannerChipProps instanceof Function
|
|
1062
|
+
? muiToolbarAlertBannerChipProps({ table })
|
|
1063
|
+
: muiToolbarAlertBannerChipProps;
|
|
1061
1064
|
const selectMessage = getSelectedRowModel().rows.length > 0
|
|
1062
1065
|
? (_b = (_a = localization.selectedCountOfRowCountRowsSelected) === null || _a === void 0 ? void 0 : _a.replace('{selectedCount}', getSelectedRowModel().rows.length.toString())) === null || _b === void 0 ? void 0 : _b.replace('{rowCount}', getPrePaginationRowModel().rows.length.toString())
|
|
1063
1066
|
: null;
|
|
@@ -1066,7 +1069,7 @@ const MRT_ToolbarAlertBanner = ({ stackAlertBanner, table, }) => {
|
|
|
1066
1069
|
' ',
|
|
1067
1070
|
grouping.map((columnId, index) => (React__default["default"].createElement(React.Fragment, { key: `${index}-${columnId}` },
|
|
1068
1071
|
index > 0 ? localization.thenBy : '',
|
|
1069
|
-
React__default["default"].createElement(material.Chip, {
|
|
1072
|
+
React__default["default"].createElement(material.Chip, Object.assign({ label: table.getColumn(columnId).columnDef.header, onDelete: () => table.getColumn(columnId).toggleGrouping() }, chipProps))))))) : null;
|
|
1070
1073
|
return (React__default["default"].createElement(material.Collapse, { in: showAlertBanner || !!selectMessage || !!groupedByMessage, timeout: stackAlertBanner ? 200 : 0 },
|
|
1071
1074
|
React__default["default"].createElement(material.Alert, Object.assign({ color: "info", icon: false }, alertProps, { sx: (theme) => (Object.assign({ borderRadius: 0, fontSize: '1rem', left: 0, p: 0, position: 'relative', right: 0, top: 0, width: '100%', zIndex: 2 }, ((alertProps === null || alertProps === void 0 ? void 0 : alertProps.sx) instanceof Function
|
|
1072
1075
|
? alertProps.sx(theme)
|
|
@@ -1197,12 +1200,12 @@ const commonToolbarStyles = ({ theme }) => ({
|
|
|
1197
1200
|
});
|
|
1198
1201
|
const MRT_TopToolbar = ({ table }) => {
|
|
1199
1202
|
var _a;
|
|
1200
|
-
const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions,
|
|
1203
|
+
const { getState, options: { enableGlobalFilter, enablePagination, enableToolbarInternalActions, muiTopToolbarProps, positionGlobalFilter, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderTopToolbarCustomActions, }, refs: { topToolbarRef }, } = table;
|
|
1201
1204
|
const { isFullScreen, showGlobalFilter } = getState();
|
|
1202
1205
|
const isMobile = material.useMediaQuery('(max-width:720px)');
|
|
1203
|
-
const toolbarProps =
|
|
1204
|
-
?
|
|
1205
|
-
:
|
|
1206
|
+
const toolbarProps = muiTopToolbarProps instanceof Function
|
|
1207
|
+
? muiTopToolbarProps({ table })
|
|
1208
|
+
: muiTopToolbarProps;
|
|
1206
1209
|
const stackAlertBanner = isMobile || !!renderTopToolbarCustomActions || showGlobalFilter;
|
|
1207
1210
|
return (React__default["default"].createElement(material.Toolbar, Object.assign({ variant: "dense" }, toolbarProps, { ref: (ref) => {
|
|
1208
1211
|
topToolbarRef.current = ref;
|
|
@@ -1235,12 +1238,12 @@ const MRT_TopToolbar = ({ table }) => {
|
|
|
1235
1238
|
};
|
|
1236
1239
|
|
|
1237
1240
|
const MRT_BottomToolbar = ({ table }) => {
|
|
1238
|
-
const { getState, options: { enablePagination,
|
|
1241
|
+
const { getState, options: { enablePagination, muiBottomToolbarProps, positionPagination, positionToolbarAlertBanner, positionToolbarDropZone, renderBottomToolbarCustomActions, }, refs: { bottomToolbarRef }, } = table;
|
|
1239
1242
|
const { isFullScreen } = getState();
|
|
1240
1243
|
const isMobile = material.useMediaQuery('(max-width:720px)');
|
|
1241
|
-
const toolbarProps =
|
|
1242
|
-
?
|
|
1243
|
-
:
|
|
1244
|
+
const toolbarProps = muiBottomToolbarProps instanceof Function
|
|
1245
|
+
? muiBottomToolbarProps({ table })
|
|
1246
|
+
: muiBottomToolbarProps;
|
|
1244
1247
|
const stackAlertBanner = isMobile || !!renderBottomToolbarCustomActions;
|
|
1245
1248
|
return (React__default["default"].createElement(material.Toolbar, Object.assign({ variant: "dense" }, toolbarProps, { ref: (ref) => {
|
|
1246
1249
|
bottomToolbarRef.current = ref;
|
|
@@ -1853,7 +1856,7 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
|
1853
1856
|
};
|
|
1854
1857
|
|
|
1855
1858
|
const MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
1856
|
-
var _a, _b, _c;
|
|
1859
|
+
var _a, _b, _c, _d;
|
|
1857
1860
|
const { column, row } = cell;
|
|
1858
1861
|
const { columnDef } = column;
|
|
1859
1862
|
return (React__default["default"].createElement(React__default["default"].Fragment, null, cell.getIsAggregated() && column.columnDef.aggregationFn
|
|
@@ -1865,7 +1868,14 @@ const MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
|
1865
1868
|
})
|
|
1866
1869
|
: row.getIsGrouped() && !cell.getIsGrouped()
|
|
1867
1870
|
? null
|
|
1868
|
-
: (
|
|
1871
|
+
: (cell.getIsGrouped() &&
|
|
1872
|
+
((_b = columnDef.GroupedCell) === null || _b === void 0 ? void 0 : _b.call(columnDef, {
|
|
1873
|
+
cell,
|
|
1874
|
+
column,
|
|
1875
|
+
row,
|
|
1876
|
+
table,
|
|
1877
|
+
}))) ||
|
|
1878
|
+
((_d = (_c = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Cell) === null || _c === void 0 ? void 0 : _c.call(columnDef, { cell, column, row, table })) !== null && _d !== void 0 ? _d : cell.renderValue())));
|
|
1869
1879
|
};
|
|
1870
1880
|
|
|
1871
1881
|
const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
@@ -2001,10 +2011,10 @@ const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
|
2001
2011
|
!row.getIsGrouped()) ? ((_a = columnDef.Cell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table })) : isEditing ? (React__default["default"].createElement(MRT_EditCellTextField, { cell: cell, table: table })) : (enableClickToCopy || columnDef.enableClickToCopy) &&
|
|
2002
2012
|
columnDef.enableClickToCopy !== false ? (React__default["default"].createElement(MRT_CopyButton, { cell: cell, table: table },
|
|
2003
2013
|
React__default["default"].createElement(MRT_TableBodyCellValue, { cell: cell, table: table }))) : (React__default["default"].createElement(MRT_TableBodyCellValue, { cell: cell, table: table }))),
|
|
2004
|
-
cell.getIsGrouped() && React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2014
|
+
cell.getIsGrouped() && !columnDef.GroupedCell && (React__default["default"].createElement(React__default["default"].Fragment, null,
|
|
2005
2015
|
" (", (_b = row.subRows) === null || _b === void 0 ? void 0 :
|
|
2006
2016
|
_b.length,
|
|
2007
|
-
")")));
|
|
2017
|
+
")"))));
|
|
2008
2018
|
};
|
|
2009
2019
|
|
|
2010
2020
|
const MRT_TableDetailPanel = ({ row, table }) => {
|