material-react-table 0.38.1 → 0.38.4
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 +1 -0
- package/dist/cjs/body/MRT_EditRowModal.d.ts +1 -0
- package/dist/cjs/body/MRT_TableBodyRow.d.ts +1 -0
- package/dist/cjs/buttons/MRT_ColumnPinningButtons.d.ts +1 -0
- package/dist/cjs/buttons/MRT_EditActionButtons.d.ts +1 -0
- package/dist/cjs/buttons/MRT_FullScreenToggleButton.d.ts +1 -0
- package/dist/cjs/buttons/MRT_ShowHideColumnsButton.d.ts +1 -0
- package/dist/cjs/buttons/MRT_ToggleDensePaddingButton.d.ts +1 -0
- package/dist/cjs/buttons/MRT_ToggleFiltersButton.d.ts +1 -0
- package/dist/cjs/buttons/MRT_ToggleGlobalFilterButton.d.ts +1 -0
- package/dist/cjs/index.js +55 -24
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/inputs/MRT_EditCellTextField.d.ts +1 -0
- package/dist/cjs/inputs/MRT_GlobalFilterTextField.d.ts +1 -0
- package/dist/cjs/menus/MRT_FilterOptionMenu.d.ts +1 -0
- package/dist/cjs/menus/MRT_ShowHideColumnsMenu.d.ts +1 -0
- package/dist/cjs/table/MRT_TableRoot.d.ts +1 -0
- package/dist/esm/MaterialReactTable.d.ts +1 -0
- package/dist/esm/body/MRT_EditRowModal.d.ts +1 -0
- package/dist/esm/body/MRT_TableBodyRow.d.ts +1 -0
- package/dist/esm/buttons/MRT_ColumnPinningButtons.d.ts +1 -0
- package/dist/esm/buttons/MRT_EditActionButtons.d.ts +1 -0
- package/dist/esm/buttons/MRT_FullScreenToggleButton.d.ts +1 -0
- package/dist/esm/buttons/MRT_ShowHideColumnsButton.d.ts +1 -0
- package/dist/esm/buttons/MRT_ToggleDensePaddingButton.d.ts +1 -0
- package/dist/esm/buttons/MRT_ToggleFiltersButton.d.ts +1 -0
- package/dist/esm/buttons/MRT_ToggleGlobalFilterButton.d.ts +1 -0
- package/dist/esm/inputs/MRT_EditCellTextField.d.ts +1 -0
- package/dist/esm/inputs/MRT_GlobalFilterTextField.d.ts +1 -0
- package/dist/esm/material-react-table.esm.js +55 -24
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/esm/menus/MRT_FilterOptionMenu.d.ts +1 -0
- package/dist/esm/menus/MRT_ShowHideColumnsMenu.d.ts +1 -0
- package/dist/esm/table/MRT_TableRoot.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/package.json +2 -2
- package/src/MaterialReactTable.tsx +1 -0
- package/src/body/MRT_TableBody.tsx +1 -0
- package/src/body/MRT_TableBodyCellValue.tsx +10 -11
- package/src/body/MRT_TableBodyRow.tsx +14 -3
- 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 +35 -23
- package/src/table/MRT_TablePaper.tsx +5 -3
|
@@ -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;
|
|
@@ -255,7 +255,9 @@ const MRT_ExpandAllButton = ({ table }) => {
|
|
|
255
255
|
: muiExpandAllButtonProps;
|
|
256
256
|
return (React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, title: localization.expandAll },
|
|
257
257
|
React.createElement("span", null,
|
|
258
|
-
React.createElement(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)
|
|
258
|
+
React.createElement(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
|
|
259
|
+
? iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx(theme)
|
|
260
|
+
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))) }),
|
|
259
261
|
React.createElement(KeyboardDoubleArrowDownIcon, { style: {
|
|
260
262
|
transform: `rotate(${getIsAllRowsExpanded()
|
|
261
263
|
? -180
|
|
@@ -445,12 +447,14 @@ const MRT_ColumnPinningButtons = ({ column, table, }) => {
|
|
|
445
447
|
const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table, }) => {
|
|
446
448
|
const { options: { icons: { DragHandleIcon }, localization, }, } = table;
|
|
447
449
|
return (React.createElement(Tooltip, { arrow: true, enterDelay: 1000, enterNextDelay: 1000, placement: "top", title: localization.move },
|
|
448
|
-
React.createElement(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': {
|
|
450
|
+
React.createElement(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': {
|
|
449
451
|
backgroundColor: 'transparent',
|
|
450
452
|
opacity: 1,
|
|
451
453
|
}, '&:active': {
|
|
452
454
|
cursor: 'grabbing',
|
|
453
|
-
} }, iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx)
|
|
455
|
+
} }, ((iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx) instanceof Function
|
|
456
|
+
? iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx(theme)
|
|
457
|
+
: iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx))) }),
|
|
454
458
|
React.createElement(DragHandleIcon, null))));
|
|
455
459
|
};
|
|
456
460
|
|
|
@@ -1743,7 +1747,9 @@ const MRT_TableHeadRow = ({ headerGroup, table }) => {
|
|
|
1743
1747
|
const tableRowProps = muiTableHeadRowProps instanceof Function
|
|
1744
1748
|
? muiTableHeadRowProps({ headerGroup, table })
|
|
1745
1749
|
: muiTableHeadRowProps;
|
|
1746
|
-
return (React.createElement(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ boxShadow: `4px 0 8px ${alpha(theme.palette.common.black, 0.1)}`, backgroundColor: lighten(theme.palette.background.default, 0.04) }, tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx)
|
|
1750
|
+
return (React.createElement(TableRow, Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ boxShadow: `4px 0 8px ${alpha(theme.palette.common.black, 0.1)}`, backgroundColor: lighten(theme.palette.background.default, 0.04) }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
|
|
1751
|
+
? tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx(theme)
|
|
1752
|
+
: tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx))) }), headerGroup.headers.map((header, index) => (React.createElement(MRT_TableHeadCell, { header: header, key: header.id || index, table: table })))));
|
|
1747
1753
|
};
|
|
1748
1754
|
|
|
1749
1755
|
const MRT_TableHead = ({ table }) => {
|
|
@@ -1773,33 +1779,43 @@ const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
|
|
|
1773
1779
|
})
|
|
1774
1780
|
: columnDef.muiTableBodyCellEditTextFieldProps;
|
|
1775
1781
|
const textFieldProps = Object.assign(Object.assign({}, mTableBodyCellEditTextFieldProps), mcTableBodyCellEditTextFieldProps);
|
|
1782
|
+
const saveRow = (newValue) => {
|
|
1783
|
+
if (editingRow) {
|
|
1784
|
+
setEditingRow(Object.assign(Object.assign({}, editingRow), { _valuesCache: Object.assign(Object.assign({}, editingRow._valuesCache), { [column.id]: newValue }) }));
|
|
1785
|
+
}
|
|
1786
|
+
};
|
|
1776
1787
|
const handleChange = (event) => {
|
|
1777
1788
|
var _a;
|
|
1778
1789
|
(_a = textFieldProps.onChange) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
|
1779
1790
|
setValue(event.target.value);
|
|
1780
|
-
if (
|
|
1781
|
-
|
|
1791
|
+
if (textFieldProps === null || textFieldProps === void 0 ? void 0 : textFieldProps.select) {
|
|
1792
|
+
saveRow(event.target.value);
|
|
1782
1793
|
}
|
|
1783
1794
|
};
|
|
1784
1795
|
const handleBlur = (event) => {
|
|
1785
1796
|
var _a;
|
|
1786
1797
|
(_a = textFieldProps.onBlur) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
|
1787
|
-
|
|
1788
|
-
setEditingRow(Object.assign(Object.assign({}, editingRow), { _valuesCache: Object.assign(Object.assign({}, editingRow._valuesCache), { [column.id]: value }) }));
|
|
1789
|
-
}
|
|
1798
|
+
saveRow(value);
|
|
1790
1799
|
setEditingCell(null);
|
|
1791
1800
|
};
|
|
1801
|
+
const handleEnterKeyDown = (event) => {
|
|
1802
|
+
var _a, _b;
|
|
1803
|
+
(_a = textFieldProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(textFieldProps, event);
|
|
1804
|
+
if (event.key === 'Enter') {
|
|
1805
|
+
(_b = editInputRefs.current[column.id]) === null || _b === void 0 ? void 0 : _b.blur();
|
|
1806
|
+
}
|
|
1807
|
+
};
|
|
1792
1808
|
if (columnDef.Edit) {
|
|
1793
1809
|
return React.createElement(React.Fragment, null, (_a = columnDef.Edit) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table }));
|
|
1794
1810
|
}
|
|
1795
|
-
return (React.createElement(TextField, Object.assign({ disabled: columnDef.enableEditing === false, fullWidth: true,
|
|
1811
|
+
return (React.createElement(TextField, Object.assign({ disabled: columnDef.enableEditing === false, fullWidth: true, inputRef: (inputRef) => {
|
|
1796
1812
|
if (inputRef) {
|
|
1797
1813
|
editInputRefs.current[column.id] = inputRef;
|
|
1798
1814
|
if (textFieldProps.inputRef) {
|
|
1799
1815
|
textFieldProps.inputRef = inputRef;
|
|
1800
1816
|
}
|
|
1801
1817
|
}
|
|
1802
|
-
}, onBlur: handleBlur, onChange: handleChange })));
|
|
1818
|
+
}, 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 })));
|
|
1803
1819
|
};
|
|
1804
1820
|
|
|
1805
1821
|
const MRT_CopyButton = ({ cell, children, table, }) => {
|
|
@@ -1851,11 +1867,11 @@ const MRT_TableBodyRowGrabHandle = ({ cell, rowRef, table, }) => {
|
|
|
1851
1867
|
};
|
|
1852
1868
|
|
|
1853
1869
|
const MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
1854
|
-
var _a, _b
|
|
1870
|
+
var _a, _b;
|
|
1855
1871
|
const { column, row } = cell;
|
|
1856
1872
|
const { columnDef } = column;
|
|
1857
|
-
return (React.createElement(React.Fragment, null, cell.getIsAggregated() &&
|
|
1858
|
-
?
|
|
1873
|
+
return (React.createElement(React.Fragment, null, cell.getIsAggregated() && columnDef.AggregatedCell
|
|
1874
|
+
? columnDef.AggregatedCell({
|
|
1859
1875
|
cell,
|
|
1860
1876
|
column,
|
|
1861
1877
|
row,
|
|
@@ -1863,14 +1879,14 @@ const MRT_TableBodyCellValue = ({ cell, table }) => {
|
|
|
1863
1879
|
})
|
|
1864
1880
|
: row.getIsGrouped() && !cell.getIsGrouped()
|
|
1865
1881
|
? null
|
|
1866
|
-
:
|
|
1867
|
-
|
|
1882
|
+
: cell.getIsGrouped() && columnDef.GroupedCell
|
|
1883
|
+
? columnDef.GroupedCell({
|
|
1868
1884
|
cell,
|
|
1869
1885
|
column,
|
|
1870
1886
|
row,
|
|
1871
1887
|
table,
|
|
1872
|
-
})
|
|
1873
|
-
(
|
|
1888
|
+
})
|
|
1889
|
+
: (_b = (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Cell) === null || _a === void 0 ? void 0 : _a.call(columnDef, { cell, column, row, table })) !== null && _b !== void 0 ? _b : cell.renderValue()));
|
|
1874
1890
|
};
|
|
1875
1891
|
|
|
1876
1892
|
const MRT_TableBodyCell = ({ cell, enableHover, rowIndex, rowRef, table, }) => {
|
|
@@ -2026,7 +2042,7 @@ const MRT_TableDetailPanel = ({ row, table }) => {
|
|
|
2026
2042
|
: tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))) }), renderDetailPanel && (React.createElement(Collapse, { in: row.getIsExpanded() }, renderDetailPanel({ row, table }))))));
|
|
2027
2043
|
};
|
|
2028
2044
|
|
|
2029
|
-
const MRT_TableBodyRow = ({ row, rowIndex, table }) => {
|
|
2045
|
+
const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
|
|
2030
2046
|
var _a, _b;
|
|
2031
2047
|
const theme = useTheme();
|
|
2032
2048
|
const { getIsSomeColumnsPinned, getState, options: { enableRowOrdering, muiTableBodyRowProps, renderDetailPanel }, setHoveredRow, } = table;
|
|
@@ -2051,7 +2067,12 @@ const MRT_TableBodyRow = ({ row, rowIndex, table }) => {
|
|
|
2051
2067
|
}
|
|
2052
2068
|
: undefined;
|
|
2053
2069
|
return (React.createElement(React.Fragment, null,
|
|
2054
|
-
React.createElement(TableRow, Object.assign({ onDragEnter: handleDragEnter, hover: true, selected: row.getIsSelected(), ref:
|
|
2070
|
+
React.createElement(TableRow, Object.assign({ onDragEnter: handleDragEnter, hover: true, selected: row.getIsSelected(), ref: (node) => {
|
|
2071
|
+
rowRef.current = node;
|
|
2072
|
+
if (virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.measureRef) {
|
|
2073
|
+
virtualRow.measureRef = node;
|
|
2074
|
+
}
|
|
2075
|
+
} }, tableRowProps, { sx: (theme) => (Object.assign(Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.06), opacity: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id ? 0.5 : 1, transition: 'all 0.2s ease-in-out', '&:hover td': {
|
|
2055
2076
|
backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false && getIsSomeColumnsPinned()
|
|
2056
2077
|
? theme.palette.mode === 'dark'
|
|
2057
2078
|
? `${lighten(theme.palette.background.default, 0.12)}`
|
|
@@ -2131,7 +2152,7 @@ const MRT_TableBody = ({ table, tableContainerRef }) => {
|
|
|
2131
2152
|
const row = enableRowVirtualization
|
|
2132
2153
|
? rows[rowOrVirtualRow.index]
|
|
2133
2154
|
: rowOrVirtualRow;
|
|
2134
|
-
return (React.createElement(MRT_TableBodyRow, { key: row.id, row: row, rowIndex: enableRowVirtualization ? rowOrVirtualRow.index : rowIndex, table: table }));
|
|
2155
|
+
return (React.createElement(MRT_TableBodyRow, { key: row.id, row: row, rowIndex: enableRowVirtualization ? rowOrVirtualRow.index : rowIndex, table: table, virtualRow: enableRowVirtualization ? rowOrVirtualRow : null }));
|
|
2135
2156
|
}),
|
|
2136
2157
|
enableRowVirtualization && paddingBottom > 0 && (React.createElement("tr", null,
|
|
2137
2158
|
React.createElement("td", { style: { height: `${paddingBottom}px` } })))));
|
|
@@ -2184,11 +2205,19 @@ const MRT_TableFooterRow = ({ footerGroup, table }) => {
|
|
|
2184
2205
|
};
|
|
2185
2206
|
|
|
2186
2207
|
const MRT_TableFooter = ({ table }) => {
|
|
2187
|
-
const { getFooterGroups, options: { muiTableFooterProps }, } = table;
|
|
2208
|
+
const { getFooterGroups, getState, options: { enableStickyFooter, muiTableFooterProps }, } = table;
|
|
2209
|
+
const { isFullScreen } = getState();
|
|
2188
2210
|
const tableFooterProps = muiTableFooterProps instanceof Function
|
|
2189
2211
|
? muiTableFooterProps({ table })
|
|
2190
2212
|
: muiTableFooterProps;
|
|
2191
|
-
|
|
2213
|
+
const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
|
|
2214
|
+
return (React.createElement(TableFooter, Object.assign({}, tableFooterProps, { sx: (theme) => (Object.assign({ position: stickFooter ? 'sticky' : undefined, bottom: stickFooter ? 0 : undefined, opacity: stickFooter ? 0.95 : undefined, outline: stickFooter
|
|
2215
|
+
? theme.palette.mode === 'light'
|
|
2216
|
+
? `1px solid ${theme.palette.grey[300]}`
|
|
2217
|
+
: `1px solid ${theme.palette.grey[700]}`
|
|
2218
|
+
: undefined }, ((tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx) instanceof Function
|
|
2219
|
+
? tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx(theme)
|
|
2220
|
+
: tableFooterProps === null || tableFooterProps === void 0 ? void 0 : tableFooterProps.sx))) }), getFooterGroups().map((footerGroup) => (React.createElement(MRT_TableFooterRow, { footerGroup: footerGroup, key: footerGroup.id, table: table })))));
|
|
2192
2221
|
};
|
|
2193
2222
|
|
|
2194
2223
|
const MRT_Table = ({ tableContainerRef, table }) => {
|
|
@@ -2255,7 +2284,9 @@ const MRT_TablePaper = ({ table }) => {
|
|
|
2255
2284
|
const tablePaperProps = muiTablePaperProps instanceof Function
|
|
2256
2285
|
? muiTablePaperProps({ table })
|
|
2257
2286
|
: muiTablePaperProps;
|
|
2258
|
-
return (React.createElement(Paper, Object.assign({ elevation: 2 }, tablePaperProps, { sx: Object.assign({ transition: 'all 0.2s ease-in-out' },
|
|
2287
|
+
return (React.createElement(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
|
|
2288
|
+
? tablePaperProps === null || tablePaperProps === void 0 ? void 0 : tablePaperProps.sx(theme)
|
|
2289
|
+
: 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 }) }),
|
|
2259
2290
|
enableTopToolbar && React.createElement(MRT_TopToolbar, { table: table }),
|
|
2260
2291
|
React.createElement(MRT_TableContainer, { table: table }),
|
|
2261
2292
|
enableBottomToolbar && React.createElement(MRT_BottomToolbar, { table: table })));
|