material-react-table 1.1.1 → 1.2.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 +1 -0
- package/dist/cjs/index.js +57 -40
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/MaterialReactTable.d.ts +1 -0
- package/dist/esm/material-react-table.esm.js +57 -40
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +1 -0
- package/src/buttons/MRT_GrabHandleButton.tsx +1 -1
- package/src/head/MRT_TableHeadCell.tsx +75 -44
- package/src/head/MRT_TableHeadCellFilterLabel.tsx +3 -3
- package/src/head/MRT_TableHeadCellResizeHandle.tsx +1 -4
- package/src/head/MRT_TableHeadCellSortLabel.tsx +1 -0
- package/src/inputs/MRT_FilterTextField.tsx +2 -1
- package/src/inputs/MRT_GlobalFilterTextField.tsx +7 -3
- package/src/table/MRT_TableRoot.tsx +2 -0
|
@@ -132,6 +132,7 @@ export declare type MRT_TableInstance<TData extends Record<string, any> = {}> =
|
|
|
132
132
|
filterInputRefs: MutableRefObject<Record<string, HTMLInputElement>>;
|
|
133
133
|
searchInputRef: MutableRefObject<HTMLInputElement>;
|
|
134
134
|
tableContainerRef: MutableRefObject<HTMLDivElement>;
|
|
135
|
+
tableHeadCellRefs: MutableRefObject<Record<string, HTMLTableCellElement>>;
|
|
135
136
|
tablePaperRef: MutableRefObject<HTMLDivElement>;
|
|
136
137
|
topToolbarRef: MutableRefObject<HTMLDivElement>;
|
|
137
138
|
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -564,7 +564,7 @@ const MRT_GrabHandleButton = ({ iconButtonProps, onDragEnd, onDragStart, table,
|
|
|
564
564
|
var _a;
|
|
565
565
|
e.stopPropagation();
|
|
566
566
|
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, e);
|
|
567
|
-
}, onDragStart: onDragStart, onDragEnd: onDragEnd, sx: (theme) => (Object.assign({ cursor: 'grab', m: 0, opacity: 0.5, p: '2px', transition: 'all 150ms ease-in-out', '&:hover': {
|
|
567
|
+
}, onDragStart: onDragStart, onDragEnd: onDragEnd, sx: (theme) => (Object.assign({ cursor: 'grab', m: '0 -0.1rem', opacity: 0.5, p: '2px', transition: 'all 150ms ease-in-out', '&:hover': {
|
|
568
568
|
backgroundColor: 'transparent',
|
|
569
569
|
opacity: 1,
|
|
570
570
|
}, '&:active': {
|
|
@@ -996,7 +996,7 @@ const MRT_SelectCheckbox = ({ row, selectAll, table }) => {
|
|
|
996
996
|
|
|
997
997
|
const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
998
998
|
var _a;
|
|
999
|
-
const { getState, setGlobalFilter, options: { enableGlobalFilterModes, icons: { SearchIcon, CloseIcon }, localization, muiSearchTextFieldProps, }, refs: { searchInputRef }, } = table;
|
|
999
|
+
const { getState, setGlobalFilter, options: { enableGlobalFilterModes, icons: { SearchIcon, CloseIcon }, localization, manualFiltering, muiSearchTextFieldProps, }, refs: { searchInputRef }, } = table;
|
|
1000
1000
|
const { globalFilter, showGlobalFilter } = getState();
|
|
1001
1001
|
const textFieldProps = muiSearchTextFieldProps instanceof Function
|
|
1002
1002
|
? muiSearchTextFieldProps({ table })
|
|
@@ -1006,7 +1006,7 @@ const MRT_GlobalFilterTextField = ({ table, }) => {
|
|
|
1006
1006
|
const handleChangeDebounced = React.useCallback(material.debounce((event) => {
|
|
1007
1007
|
var _a;
|
|
1008
1008
|
setGlobalFilter((_a = event.target.value) !== null && _a !== void 0 ? _a : undefined);
|
|
1009
|
-
}, 250), []);
|
|
1009
|
+
}, manualFiltering ? 500 : 250), []);
|
|
1010
1010
|
const handleChange = (event) => {
|
|
1011
1011
|
setSearchValue(event.target.value);
|
|
1012
1012
|
handleChangeDebounced(event);
|
|
@@ -1375,7 +1375,7 @@ const MRT_TableHeadCellColumnActionsButton = ({ header, table, }) => {
|
|
|
1375
1375
|
|
|
1376
1376
|
const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
1377
1377
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1378
|
-
const { options: { enableColumnFilterModes, columnFilterModeOptions, icons: { FilterListIcon, CloseIcon }, localization, muiTableHeadCellFilterTextFieldProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
|
|
1378
|
+
const { options: { enableColumnFilterModes, columnFilterModeOptions, icons: { FilterListIcon, CloseIcon }, localization, manualFiltering, muiTableHeadCellFilterTextFieldProps, }, refs: { filterInputRefs }, setColumnFilterFns, } = table;
|
|
1379
1379
|
const { column } = header;
|
|
1380
1380
|
const { columnDef } = column;
|
|
1381
1381
|
const mTableHeadCellFilterTextFieldProps = muiTableHeadCellFilterTextFieldProps instanceof Function
|
|
@@ -1442,7 +1442,7 @@ const MRT_FilterTextField = ({ header, rangeFilterIndex, table, }) => {
|
|
|
1442
1442
|
else {
|
|
1443
1443
|
column.setFilterValue(value !== null && value !== void 0 ? value : undefined);
|
|
1444
1444
|
}
|
|
1445
|
-
}, isTextboxFilter ? 200 : 1), []);
|
|
1445
|
+
}, isTextboxFilter ? (manualFiltering ? 400 : 200) : 1), []);
|
|
1446
1446
|
const handleChange = (event) => {
|
|
1447
1447
|
setFilterValue(event.target.value);
|
|
1448
1448
|
handleChangeDebounced(event);
|
|
@@ -1643,7 +1643,7 @@ const MRT_TableHeadCellFilterLabel = ({ header, table }) => {
|
|
|
1643
1643
|
return (React__default["default"].createElement(material.Grow, { unmountOnExit: true, in: (!!column.getFilterValue() && !isRangeFilter) ||
|
|
1644
1644
|
(isRangeFilter && // @ts-ignore
|
|
1645
1645
|
(!!((_b = column.getFilterValue()) === null || _b === void 0 ? void 0 : _b[0]) || !!((_c = column.getFilterValue()) === null || _c === void 0 ? void 0 : _c[1]))) },
|
|
1646
|
-
React__default["default"].createElement("span",
|
|
1646
|
+
React__default["default"].createElement(material.Box, { component: "span", sx: { flex: '0 0' } },
|
|
1647
1647
|
React__default["default"].createElement(material.Tooltip, { arrow: true, placement: "top", title: filterTooltip },
|
|
1648
1648
|
React__default["default"].createElement(material.IconButton, { disableRipple: true, onClick: (event) => {
|
|
1649
1649
|
event.stopPropagation();
|
|
@@ -1717,10 +1717,7 @@ const MRT_TableHeadCellResizeHandle = ({ header, table }) => {
|
|
|
1717
1717
|
React__default["default"].createElement(material.Divider, { flexItem: true, orientation: "vertical", sx: {
|
|
1718
1718
|
borderRadius: '2px',
|
|
1719
1719
|
borderWidth: '2px',
|
|
1720
|
-
height: showColumnFilters && columnDefType === 'data'
|
|
1721
|
-
? '3.5rem'
|
|
1722
|
-
: '1.75rem',
|
|
1723
|
-
opacity: 0.8,
|
|
1720
|
+
height: showColumnFilters && columnDefType === 'data' ? '3.5rem' : '1.5rem',
|
|
1724
1721
|
touchAction: 'none',
|
|
1725
1722
|
transition: column.getIsResizing()
|
|
1726
1723
|
? undefined
|
|
@@ -1743,6 +1740,7 @@ const MRT_TableHeadCellSortLabel = ({ header, table, tableCellProps, }) => {
|
|
|
1743
1740
|
React__default["default"].createElement(material.TableSortLabel, { "aria-label": sortTooltip, active: !!column.getIsSorted(), direction: column.getIsSorted()
|
|
1744
1741
|
? column.getIsSorted()
|
|
1745
1742
|
: undefined, sx: {
|
|
1743
|
+
flex: '0 0',
|
|
1746
1744
|
width: '2ch',
|
|
1747
1745
|
transform: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) !== 'right'
|
|
1748
1746
|
? 'translateX(-0.5ch)'
|
|
@@ -1753,7 +1751,7 @@ const MRT_TableHeadCellSortLabel = ({ header, table, tableCellProps, }) => {
|
|
|
1753
1751
|
const MRT_TableHeadCell = ({ header, table }) => {
|
|
1754
1752
|
var _a, _b, _c, _d;
|
|
1755
1753
|
const theme = material.useTheme();
|
|
1756
|
-
const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableGrouping, enableMultiSort, muiTableHeadCellProps, }, setHoveredColumn, } = table;
|
|
1754
|
+
const { getState, options: { enableColumnActions, enableColumnDragging, enableColumnOrdering, enableGrouping, enableMultiSort, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
|
|
1757
1755
|
const { density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
|
|
1758
1756
|
const { column } = header;
|
|
1759
1757
|
const { columnDef } = column;
|
|
@@ -1765,6 +1763,25 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1765
1763
|
? columnDef.muiTableHeadCellProps({ column, table })
|
|
1766
1764
|
: columnDef.muiTableHeadCellProps;
|
|
1767
1765
|
const tableCellProps = Object.assign(Object.assign({}, mTableHeadCellProps), mcTableHeadCellProps);
|
|
1766
|
+
const showColumnActions = (enableColumnActions || columnDef.enableColumnActions) &&
|
|
1767
|
+
columnDef.enableColumnActions !== false;
|
|
1768
|
+
const showDragHandle = enableColumnDragging !== false &&
|
|
1769
|
+
columnDef.enableColumnDragging !== false &&
|
|
1770
|
+
(enableColumnDragging ||
|
|
1771
|
+
(enableColumnOrdering && columnDef.enableColumnOrdering !== false) ||
|
|
1772
|
+
(enableGrouping &&
|
|
1773
|
+
columnDef.enableGrouping !== false &&
|
|
1774
|
+
!grouping.includes(column.id)));
|
|
1775
|
+
const headerPL = React.useMemo(() => {
|
|
1776
|
+
let pl = 0;
|
|
1777
|
+
if (column.getCanSort())
|
|
1778
|
+
pl++;
|
|
1779
|
+
if (showColumnActions)
|
|
1780
|
+
pl += 1.75;
|
|
1781
|
+
if (showDragHandle)
|
|
1782
|
+
pl += 1.25;
|
|
1783
|
+
return pl;
|
|
1784
|
+
}, [showColumnActions, showDragHandle]);
|
|
1768
1785
|
const draggingBorder = React.useMemo(() => (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
|
|
1769
1786
|
? `1px dashed ${theme.palette.text.secondary}`
|
|
1770
1787
|
: (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
|
|
@@ -1785,15 +1802,18 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1785
1802
|
setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
|
|
1786
1803
|
}
|
|
1787
1804
|
};
|
|
1788
|
-
const headerElement = (
|
|
1805
|
+
const headerElement = (columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header) instanceof Function
|
|
1789
1806
|
? (_a = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header) === null || _a === void 0 ? void 0 : _a.call(columnDef, {
|
|
1790
1807
|
column,
|
|
1791
1808
|
header,
|
|
1792
1809
|
table,
|
|
1793
1810
|
})
|
|
1794
|
-
: columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header)
|
|
1795
|
-
|
|
1796
|
-
|
|
1811
|
+
: (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header) !== null && _b !== void 0 ? _b : columnDef.header;
|
|
1812
|
+
return (React__default["default"].createElement(material.TableCell, Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: header.colSpan, onDragEnter: handleDragEnter, ref: (node) => {
|
|
1813
|
+
if (node) {
|
|
1814
|
+
tableHeadCellRefs.current[column.id] = node;
|
|
1815
|
+
}
|
|
1816
|
+
} }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ fontWeight: 'bold', overflow: 'visible', p: density === 'compact'
|
|
1797
1817
|
? '0.5rem'
|
|
1798
1818
|
: density === 'comfortable'
|
|
1799
1819
|
? columnDefType === 'display'
|
|
@@ -1820,47 +1840,42 @@ const MRT_TableHeadCell = ({ header, table }) => {
|
|
|
1820
1840
|
tableCellProps,
|
|
1821
1841
|
theme,
|
|
1822
1842
|
})), draggingBorders)) }),
|
|
1823
|
-
header.isPlaceholder ? null : (React__default["default"].createElement(material.Box, { sx: {
|
|
1843
|
+
header.isPlaceholder ? null : (React__default["default"].createElement(material.Box, { className: "Mui-TableHeadCell-Content", sx: {
|
|
1824
1844
|
alignItems: 'flex-start',
|
|
1825
1845
|
display: 'flex',
|
|
1826
1846
|
flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
|
|
1827
|
-
justifyContent: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === '
|
|
1828
|
-
? '
|
|
1829
|
-
:
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
: 'space-between',
|
|
1847
|
+
justifyContent: columnDefType === 'group' || (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center'
|
|
1848
|
+
? 'center'
|
|
1849
|
+
: column.getCanResize()
|
|
1850
|
+
? 'space-between'
|
|
1851
|
+
: 'flex-start',
|
|
1833
1852
|
position: 'relative',
|
|
1834
1853
|
width: '100%',
|
|
1835
1854
|
} },
|
|
1836
|
-
React__default["default"].createElement(material.Box, { onClick: column.getToggleSortingHandler(), sx: {
|
|
1855
|
+
React__default["default"].createElement(material.Box, { className: "Mui-TableHeadCell-Content-Labels", onClick: column.getToggleSortingHandler(), sx: {
|
|
1837
1856
|
alignItems: 'center',
|
|
1838
1857
|
cursor: column.getCanSort() && columnDefType !== 'group'
|
|
1839
1858
|
? 'pointer'
|
|
1840
1859
|
: undefined,
|
|
1841
1860
|
display: 'flex',
|
|
1842
1861
|
flexDirection: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'right' ? 'row-reverse' : 'row',
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
? '1rem'
|
|
1862
|
+
overflow: 'hidden',
|
|
1863
|
+
pl: (tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.align) === 'center'
|
|
1864
|
+
? `${headerPL}rem`
|
|
1847
1865
|
: undefined,
|
|
1848
|
-
whiteSpace: ((_d = (_c = columnDef.header) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) < 24 ? 'nowrap' : 'normal',
|
|
1849
1866
|
} },
|
|
1850
|
-
|
|
1867
|
+
React__default["default"].createElement(material.Box, { className: "Mui-TableHeadCell-Content-Wrapper", sx: {
|
|
1868
|
+
overflow: 'hidden',
|
|
1869
|
+
textOverflow: 'ellipsis',
|
|
1870
|
+
whiteSpace: ((_d = (_c = columnDef.header) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) < 20 ? 'nowrap' : 'normal',
|
|
1871
|
+
}, title: columnDef.header }, headerElement),
|
|
1851
1872
|
column.getCanSort() && (React__default["default"].createElement(MRT_TableHeadCellSortLabel, { header: header, table: table, tableCellProps: tableCellProps })),
|
|
1852
1873
|
column.getCanFilter() && (React__default["default"].createElement(MRT_TableHeadCellFilterLabel, { header: header, table: table }))),
|
|
1853
|
-
columnDefType !== 'group' && (React__default["default"].createElement(material.Box, { sx: { whiteSpace: 'nowrap' } },
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
columnDef.enableColumnOrdering !== false) ||
|
|
1859
|
-
(enableGrouping &&
|
|
1860
|
-
columnDef.enableGrouping !== false &&
|
|
1861
|
-
!grouping.includes(column.id))) && (React__default["default"].createElement(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: tableHeadCellRef })),
|
|
1862
|
-
(enableColumnActions || columnDef.enableColumnActions) &&
|
|
1863
|
-
columnDef.enableColumnActions !== false && (React__default["default"].createElement(MRT_TableHeadCellColumnActionsButton, { header: header, table: table })))),
|
|
1874
|
+
columnDefType !== 'group' && (React__default["default"].createElement(material.Box, { className: "Mui-TableHeadCell-Content-Actions", sx: { whiteSpace: 'nowrap' } },
|
|
1875
|
+
showDragHandle && (React__default["default"].createElement(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
|
|
1876
|
+
current: tableHeadCellRefs.current[column.id],
|
|
1877
|
+
} })),
|
|
1878
|
+
showColumnActions && (React__default["default"].createElement(MRT_TableHeadCellColumnActionsButton, { header: header, table: table })))),
|
|
1864
1879
|
column.getCanResize() && (React__default["default"].createElement(MRT_TableHeadCellResizeHandle, { header: header, table: table })))),
|
|
1865
1880
|
column.getCanFilter() && (React__default["default"].createElement(MRT_TableHeadCellFilterContainer, { header: header, table: table }))));
|
|
1866
1881
|
};
|
|
@@ -2479,6 +2494,7 @@ const MRT_TableRoot = (props) => {
|
|
|
2479
2494
|
const filterInputRefs = React.useRef({});
|
|
2480
2495
|
const searchInputRef = React.useRef(null);
|
|
2481
2496
|
const tableContainerRef = React.useRef(null);
|
|
2497
|
+
const tableHeadCellRefs = React.useRef({});
|
|
2482
2498
|
const tablePaperRef = React.useRef(null);
|
|
2483
2499
|
const topToolbarRef = React.useRef(null);
|
|
2484
2500
|
const initialState = React.useMemo(() => {
|
|
@@ -2600,6 +2616,7 @@ const MRT_TableRoot = (props) => {
|
|
|
2600
2616
|
filterInputRefs,
|
|
2601
2617
|
searchInputRef,
|
|
2602
2618
|
tableContainerRef,
|
|
2619
|
+
tableHeadCellRefs,
|
|
2603
2620
|
tablePaperRef,
|
|
2604
2621
|
topToolbarRef,
|
|
2605
2622
|
}, setColumnFilterFns: (_x = props.onFilterFnsChange) !== null && _x !== void 0 ? _x : setColumnFilterFns, setDensity: (_y = props.onDensityChange) !== null && _y !== void 0 ? _y : setDensity, setDraggingColumn: (_z = props.onDraggingColumnChange) !== null && _z !== void 0 ? _z : setDraggingColumn, setDraggingRow: (_0 = props.onDraggingRowChange) !== null && _0 !== void 0 ? _0 : setDraggingRow, setEditingCell: (_1 = props.onEditingCellChange) !== null && _1 !== void 0 ? _1 : setEditingCell, setEditingRow: (_2 = props.onEditingRowChange) !== null && _2 !== void 0 ? _2 : setEditingRow, setGlobalFilterFn: (_3 = props.onGlobalFilterFnChange) !== null && _3 !== void 0 ? _3 : setGlobalFilterFn, setHoveredColumn: (_4 = props.onHoveredColumnChange) !== null && _4 !== void 0 ? _4 : setHoveredColumn, setHoveredRow: (_5 = props.onHoveredRowChange) !== null && _5 !== void 0 ? _5 : setHoveredRow, setIsFullScreen: (_6 = props.onIsFullScreenChange) !== null && _6 !== void 0 ? _6 : setIsFullScreen, setShowAlertBanner: (_7 = props.onShowAlertBannerChange) !== null && _7 !== void 0 ? _7 : setShowAlertBanner, setShowFilters: (_8 = props.onShowFiltersChange) !== null && _8 !== void 0 ? _8 : setShowFilters, setShowGlobalFilter: (_9 = props.onShowGlobalFilterChange) !== null && _9 !== void 0 ? _9 : setShowGlobalFilter });
|