material-react-table 0.38.0 → 0.38.3
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 +2 -1
- package/dist/cjs/MaterialReactTable.d.ts +3 -2
- package/dist/cjs/index.js +42 -13
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/MaterialReactTable.d.ts +3 -2
- package/dist/esm/material-react-table.esm.js +42 -13
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +3 -2
- package/src/buttons/MRT_ExpandAllButton.tsx +5 -3
- package/src/buttons/MRT_GrabHandleButton.tsx +5 -3
- package/src/footer/MRT_TableFooter.tsx +22 -2
- package/src/head/MRT_TableHeadRow.tsx +3 -1
- package/src/inputs/MRT_EditCellTextField.tsx +36 -15
- package/src/inputs/MRT_FilterTextField.tsx +1 -1
- package/src/table/MRT_TablePaper.tsx +5 -3
package/README.md
CHANGED
|
@@ -43,6 +43,7 @@ See all [Props and Options](https://www.material-react-table.com/docs/api)
|
|
|
43
43
|
- [Basic Table](https://www.material-react-table.com/docs/examples/basic/) (See Default Features)
|
|
44
44
|
- [Minimal Table](https://www.material-react-table.com/docs/examples/minimal/) (Turn off Features)
|
|
45
45
|
- [Advanced Table](https://www.material-react-table.com/docs/examples/advanced/) (See some of the Advanced Features)
|
|
46
|
+
- [Aggregation/Grouping](https://www.material-react-table.com/docs/examples/aggregation-and-grouping/) (Aggregation features such as Sum, Average, Count, etc.)
|
|
46
47
|
- [Data Export Table](https://www.material-react-table.com/docs/examples/data-export/) (Export to CSV, Excel, etc.)
|
|
47
48
|
- [Editing CRUD Table](https://www.material-react-table.com/docs/examples/editing-crud/) (Create, Edit, and Delete Rows)
|
|
48
49
|
- [Remote Data](https://www.material-react-table.com/docs/examples/remote/) (Server-side Pagination, Sorting, and Filtering)
|
|
@@ -60,9 +61,9 @@ _All features can easily be enabled/disabled_
|
|
|
60
61
|
|
|
61
62
|
- [x] < 37kb gzipped - [Bundlephobia](https://bundlephobia.com/package/material-react-table)
|
|
62
63
|
- [x] Advanced TypeScript Generics Support (TypeScript Optional)
|
|
64
|
+
- [x] Aggregation and Grouping (Sum, Average, Count, etc.)
|
|
63
65
|
- [x] Click To Copy Cell Values
|
|
64
66
|
- [x] Column Action Dropdown Menu
|
|
65
|
-
- [x] Column/Row Grouping (Group By and Aggregates)
|
|
66
67
|
- [x] Column Hiding
|
|
67
68
|
- [x] Column Ordering via Drag'n'Drop
|
|
68
69
|
- [x] Column Pinning (Freeze Columns)
|
|
@@ -48,8 +48,8 @@ export declare type MRT_TableInstance<TData extends Record<string, any> = {}> =
|
|
|
48
48
|
setDensity: Dispatch<SetStateAction<'comfortable' | 'compact' | 'spacious'>>;
|
|
49
49
|
setDraggingColumn: Dispatch<SetStateAction<MRT_Column<TData> | null>>;
|
|
50
50
|
setDraggingRow: Dispatch<SetStateAction<MRT_Row<TData> | null>>;
|
|
51
|
-
setEditingCell: Dispatch<SetStateAction<MRT_Cell | null>>;
|
|
52
|
-
setEditingRow: Dispatch<SetStateAction<MRT_Row | null>>;
|
|
51
|
+
setEditingCell: Dispatch<SetStateAction<MRT_Cell<TData> | null>>;
|
|
52
|
+
setEditingRow: Dispatch<SetStateAction<MRT_Row<TData> | null>>;
|
|
53
53
|
setGlobalFilterFn: Dispatch<SetStateAction<MRT_FilterOption>>;
|
|
54
54
|
setHoveredColumn: Dispatch<SetStateAction<MRT_Column<TData> | {
|
|
55
55
|
id: string;
|
|
@@ -288,6 +288,7 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
288
288
|
enableRowSelection?: boolean | ((row: MRT_Row<TData>) => boolean);
|
|
289
289
|
enableRowVirtualization?: boolean;
|
|
290
290
|
enableSelectAll?: boolean;
|
|
291
|
+
enableStickyFooter?: boolean;
|
|
291
292
|
enableStickyHeader?: boolean;
|
|
292
293
|
enableTableFooter?: boolean;
|
|
293
294
|
enableTableHead?: boolean;
|
package/dist/cjs/index.js
CHANGED
|
@@ -263,7 +263,9 @@ const MRT_ExpandAllButton = ({ table }) => {
|
|
|
263
263
|
: muiExpandAllButtonProps;
|
|
264
264
|
return (React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.expandAll },
|
|
265
265
|
React__default["default"].createElement("span", null,
|
|
266
|
-
React__default["default"].createElement(material.IconButton, Object.assign({ "aria-label": localization.expandAll, disabled: !getCanSomeRowsExpand() && !renderDetailPanel, onClick: () => toggleAllRowsExpanded(!getIsAllRowsExpanded()) }, iconButtonProps, { sx: Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', width: density === 'compact' ? '1.75rem' : '2.25rem', mt: density !== 'compact' ? '-0.25rem' : undefined }, iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx)
|
|
266
|
+
React__default["default"].createElement(material.IconButton, Object.assign({ "aria-label": localization.expandAll, disabled: !getCanSomeRowsExpand() && !renderDetailPanel, onClick: () => toggleAllRowsExpanded(!getIsAllRowsExpanded()) }, iconButtonProps, { sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', width: density === 'compact' ? '1.75rem' : '2.25rem', mt: density !== 'compact' ? '-0.25rem' : undefined }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
|
|
267
|
+
? iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx(theme)
|
|
268
|
+
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))) }),
|
|
267
269
|
React__default["default"].createElement(KeyboardDoubleArrowDownIcon, { style: {
|
|
268
270
|
transform: `rotate(${getIsAllRowsExpanded()
|
|
269
271
|
? -180
|
|
@@ -453,12 +455,14 @@ const MRT_ColumnPinningButtons = ({ column, table, }) => {
|
|
|
453
455
|
const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table, }) => {
|
|
454
456
|
const { options: { icons: { DragHandleIcon }, localization, }, } = table;
|
|
455
457
|
return (React__default["default"].createElement(material.Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: localization.move },
|
|
456
|
-
React__default["default"].createElement(material.IconButton, Object.assign({ disableRipple: true, draggable: "true", onDragStart: onDragStart, onDragEnd: onDragEnd, size: "small" }, iconButtonProps, { sx: Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all 0.2s ease-in-out', '&:hover': {
|
|
458
|
+
React__default["default"].createElement(material.IconButton, Object.assign({ disableRipple: true, draggable: "true", onDragStart: onDragStart, onDragEnd: onDragEnd, size: "small" }, iconButtonProps, { sx: (theme) => (Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all 0.2s ease-in-out', '&:hover': {
|
|
457
459
|
backgroundColor: 'transparent',
|
|
458
460
|
opacity: 1,
|
|
459
461
|
}, '&:active': {
|
|
460
462
|
cursor: 'grabbing',
|
|
461
|
-
} }, iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx)
|
|
463
|
+
} }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
|
|
464
|
+
? iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx(theme)
|
|
465
|
+
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))) }),
|
|
462
466
|
React__default["default"].createElement(DragHandleIcon, null))));
|
|
463
467
|
};
|
|
464
468
|
|
|
@@ -1452,7 +1456,7 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1452
1456
|
if (textFieldProps.inputRef) {
|
|
1453
1457
|
textFieldProps.inputRef = inputRef;
|
|
1454
1458
|
}
|
|
1455
|
-
}, sx: (theme) => (Object.assign({ p: 0, minWidth: !filterChipLabel ? '
|
|
1459
|
+
}, sx: (theme) => (Object.assign({ p: 0, minWidth: !filterChipLabel ? '150px' : 'auto', width: '100%', '& .MuiSelect-icon': {
|
|
1456
1460
|
mr: '1.5rem',
|
|
1457
1461
|
} }, ((textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.sx) instanceof Function
|
|
1458
1462
|
? textFieldProps.sx(theme)
|
|
@@ -1751,7 +1755,9 @@ const MRT_TableHeadRow = ({ headerGroup, table }) => {
|
|
|
1751
1755
|
const tableRowProps = muiTableHeadRowProps instanceof Function
|
|
1752
1756
|
? muiTableHeadRowProps({ headerGroup, table })
|
|
1753
1757
|
: muiTableHeadRowProps;
|
|
1754
|
-
return (React__default["default"].createElement(material.TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ boxShadow: `4px 0 8px ${material.alpha(theme.palette.common.black, 0.1)}`, backgroundColor: material.lighten(theme.palette.background.default, 0.04) }, tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx)
|
|
1758
|
+
return (React__default["default"].createElement(material.TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ boxShadow: `4px 0 8px ${material.alpha(theme.palette.common.black, 0.1)}`, backgroundColor: material.lighten(theme.palette.background.default, 0.04) }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
|
|
1759
|
+
? tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx(theme)
|
|
1760
|
+
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx))) }), headerGroup.headers.map((header, index) => (React__default["default"].createElement(MRT_TableHeadCell, { header: header, key: header.id || index, table: table })))));
|
|
1755
1761
|
};
|
|
1756
1762
|
|
|
1757
1763
|
const MRT_TableHead = ({ table }) => {
|
|
@@ -1781,30 +1787,43 @@ const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
|
|
1781
1787
|
})
|
|
1782
1788
|
: columnDef.muiTableBodyCellEditTextFieldProps;
|
|
1783
1789
|
const textFieldProps = Object.assign(Object.assign({}, mTableBodyCellEditTextFieldProps), mcTableBodyCellEditTextFieldProps);
|
|
1790
|
+
const saveRow = (newValue) => {
|
|
1791
|
+
if (editingRow) {
|
|
1792
|
+
setEditingRow(Object.assign(Object.assign({}, editingRow), { _valuesCache: Object.assign(Object.assign({}, editingRow._valuesCache), { [column.id]: newValue }) }));
|
|
1793
|
+
}
|
|
1794
|
+
};
|
|
1784
1795
|
const handleChange = (event) => {
|
|
1785
1796
|
var _a;
|
|
1786
1797
|
(_a = textFieldProps.onChange) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
|
1787
1798
|
setValue(event.target.value);
|
|
1799
|
+
if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.select) {
|
|
1800
|
+
saveRow(event.target.value);
|
|
1801
|
+
}
|
|
1788
1802
|
};
|
|
1789
1803
|
const handleBlur = (event) => {
|
|
1790
1804
|
var _a;
|
|
1791
1805
|
(_a = textFieldProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
|
1792
|
-
|
|
1793
|
-
setEditingRow(Object.assign(Object.assign({}, editingRow), { _valuesCache: Object.assign(Object.assign({}, editingRow._valuesCache), { [column.id]: value }) }));
|
|
1794
|
-
}
|
|
1806
|
+
saveRow(value);
|
|
1795
1807
|
setEditingCell(null);
|
|
1796
1808
|
};
|
|
1809
|
+
const handleEnterKeyDown = (event) => {
|
|
1810
|
+
var _a, _b;
|
|
1811
|
+
(_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
|
1812
|
+
if (event.key === 'Enter') {
|
|
1813
|
+
(_b = editInputRefs.current[column.id]) === null || _b === void 0 ? void 0 : _b.blur();
|
|
1814
|
+
}
|
|
1815
|
+
};
|
|
1797
1816
|
if (columnDef.Edit) {
|
|
1798
1817
|
return React__default["default"].createElement(React__default["default"].Fragment, null, (_a = columnDef.Edit) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table }));
|
|
1799
1818
|
}
|
|
1800
|
-
return (React__default["default"].createElement(material.TextField, Object.assign({ disabled: columnDef.enableEditing === false, fullWidth: true,
|
|
1819
|
+
return (React__default["default"].createElement(material.TextField, Object.assign({ disabled: columnDef.enableEditing === false, fullWidth: true, inputRef: (inputRef) => {
|
|
1801
1820
|
if (inputRef) {
|
|
1802
1821
|
editInputRefs.current[column.id] = inputRef;
|
|
1803
1822
|
if (textFieldProps.inputRef) {
|
|
1804
1823
|
textFieldProps.inputRef = inputRef;
|
|
1805
1824
|
}
|
|
1806
1825
|
}
|
|
1807
|
-
}, onBlur: handleBlur, onChange: handleChange })));
|
|
1826
|
+
}, label: showLabel ? column.columnDef.header : undefined, margin: "none", name: column.id, onClick: (e) => e.stopPropagation(), placeholder: columnDef.header, value: value, variant: "standard" }, textFieldProps, { onBlur: handleBlur, onChange: handleChange, onKeyDown: handleEnterKeyDown })));
|
|
1808
1827
|
};
|
|
1809
1828
|
|
|
1810
1829
|
const MRT_CopyButton = ({ cell, children, table, }) => {
|
|
@@ -2189,11 +2208,19 @@ const MRT_TableFooterRow = ({ footerGroup, table }) => {
|
|
|
2189
2208
|
};
|
|
2190
2209
|
|
|
2191
2210
|
const MRT_TableFooter = ({ table }) => {
|
|
2192
|
-
const { getFooterGroups, options: { muiTableFooterProps }, } = table;
|
|
2211
|
+
const { getFooterGroups, getState, options: { enableStickyFooter, muiTableFooterProps }, } = table;
|
|
2212
|
+
const { isFullScreen } = getState();
|
|
2193
2213
|
const tableFooterProps = muiTableFooterProps instanceof Function
|
|
2194
2214
|
? muiTableFooterProps({ table })
|
|
2195
2215
|
: muiTableFooterProps;
|
|
2196
|
-
|
|
2216
|
+
const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
|
|
2217
|
+
return (React__default["default"].createElement(material.TableFooter, Object.assign({}, tableFooterProps, { sx: (theme) => (Object.assign({ position: stickFooter ? 'sticky' : undefined, bottom: stickFooter ? 0 : undefined, opacity: stickFooter ? 0.95 : undefined, outline: stickFooter
|
|
2218
|
+
? theme.palette.mode === 'light'
|
|
2219
|
+
? `1px solid ${theme.palette.grey[300]}`
|
|
2220
|
+
: `1px solid ${theme.palette.grey[700]}`
|
|
2221
|
+
: undefined }, ((tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx) instanceof Function
|
|
2222
|
+
? tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx(theme)
|
|
2223
|
+
: tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx))) }), getFooterGroups().map((footerGroup) => (React__default["default"].createElement(MRT_TableFooterRow, { footerGroup: footerGroup, key: footerGroup.id, table: table })))));
|
|
2197
2224
|
};
|
|
2198
2225
|
|
|
2199
2226
|
const MRT_Table = ({ tableContainerRef, table }) => {
|
|
@@ -2260,7 +2287,9 @@ const MRT_TablePaper = ({ table }) => {
|
|
|
2260
2287
|
const tablePaperProps = muiTablePaperProps instanceof Function
|
|
2261
2288
|
? muiTablePaperProps({ table })
|
|
2262
2289
|
: muiTablePaperProps;
|
|
2263
|
-
return (React__default["default"].createElement(material.Paper, Object.assign({ elevation: 2 }, tablePaperProps, { sx: Object.assign({ transition: 'all 0.2s ease-in-out' },
|
|
2290
|
+
return (React__default["default"].createElement(material.Paper, Object.assign({ elevation: 2 }, tablePaperProps, { sx: (theme) => (Object.assign({ transition: 'all 0.2s ease-in-out' }, ((tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx) instanceof Function
|
|
2291
|
+
? tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx(theme)
|
|
2292
|
+
: tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx))), style: Object.assign(Object.assign({}, tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.style), { height: isFullScreen ? '100vh' : undefined, margin: isFullScreen ? '0' : undefined, maxHeight: isFullScreen ? '100vh' : undefined, maxWidth: isFullScreen ? '100vw' : undefined, padding: isFullScreen ? '0' : undefined, width: isFullScreen ? '100vw' : undefined }) }),
|
|
2264
2293
|
enableTopToolbar && React__default["default"].createElement(MRT_TopToolbar, { table: table }),
|
|
2265
2294
|
React__default["default"].createElement(MRT_TableContainer, { table: table }),
|
|
2266
2295
|
enableBottomToolbar && React__default["default"].createElement(MRT_BottomToolbar, { table: table })));
|