material-react-table-narender 2.13.27 → 2.13.29
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/index.d.ts +3 -0
- package/dist/index.esm.js +54 -37
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +53 -36
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/head/MRT_TableHeadCell.tsx +3 -0
- package/src/components/head/MRT_TableHeadCellToolBar.tsx +68 -0
- package/src/components/inputs/MRT_FilterTextField.tsx +2 -11
- package/src/components/menus/MRT_ColumnActionMenu.tsx +14 -1
- package/src/hooks/useMRT_TableInstance.ts +8 -0
- package/src/types.ts +3 -0
package/dist/index.d.ts
CHANGED
@@ -448,6 +448,7 @@ type MRT_TableInstance<TData extends MRT_RowData> = Omit<Table<TData>, 'getAllCo
|
|
448
448
|
setIsFullScreen: Dispatch<SetStateAction<boolean>>;
|
449
449
|
setShowAlertBanner: Dispatch<SetStateAction<boolean>>;
|
450
450
|
setShowColumnFilters: Dispatch<SetStateAction<boolean>>;
|
451
|
+
setShowToolBar: Dispatch<SetStateAction<boolean>>;
|
451
452
|
setShowGlobalFilter: Dispatch<SetStateAction<boolean>>;
|
452
453
|
setShowToolbarDropZone: Dispatch<SetStateAction<boolean>>;
|
453
454
|
setEnableKeyboardShortcuts: Dispatch<SetStateAction<boolean>>;
|
@@ -478,6 +479,7 @@ interface MRT_TableState<TData extends MRT_RowData> extends TableState {
|
|
478
479
|
isSaving: boolean;
|
479
480
|
showAlertBanner: boolean;
|
480
481
|
showColumnFilters: boolean;
|
482
|
+
showToolBar: boolean;
|
481
483
|
showGlobalFilter: boolean;
|
482
484
|
showLoadingOverlay: boolean;
|
483
485
|
showProgressBars: boolean;
|
@@ -1067,6 +1069,7 @@ interface MRT_TableOptions<TData extends MRT_RowData> extends Omit<Partial<Table
|
|
1067
1069
|
onEnableKeyboardShortcutsChange?: OnChangeFn<boolean>;
|
1068
1070
|
onShowAlertBannerChange?: OnChangeFn<boolean>;
|
1069
1071
|
onShowColumnFiltersChange?: OnChangeFn<boolean>;
|
1072
|
+
onShowToolBarChange?: OnChangeFn<boolean>;
|
1070
1073
|
onShowGlobalFilterChange?: OnChangeFn<boolean>;
|
1071
1074
|
onShowToolbarDropZoneChange?: OnChangeFn<boolean>;
|
1072
1075
|
paginationDisplayMode?: 'custom' | 'default' | 'pages';
|
package/dist/index.esm.js
CHANGED
@@ -51,7 +51,7 @@ import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
|
|
51
51
|
import SettingsBackupRestoreIcon from '@mui/icons-material/SettingsBackupRestore';
|
52
52
|
import { defaultRangeExtractor, useVirtualizer } from '@tanstack/react-virtual';
|
53
53
|
import Paper from '@mui/material/Paper';
|
54
|
-
import { Button as Button$1, useTheme as useTheme$1 } from '@mui/material';
|
54
|
+
import { IconButton as IconButton$1, Button as Button$1, useTheme as useTheme$1 } from '@mui/material';
|
55
55
|
import TableContainer from '@mui/material/TableContainer';
|
56
56
|
import Table from '@mui/material/Table';
|
57
57
|
import TableBody from '@mui/material/TableBody';
|
@@ -1693,7 +1693,7 @@ const useMRT_Effects = (table) => {
|
|
1693
1693
|
* @returns the MRT table instance
|
1694
1694
|
*/
|
1695
1695
|
const useMRT_TableInstance = (definedTableOptions) => {
|
1696
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12;
|
1696
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14;
|
1697
1697
|
const lastSelectedRowId = useRef(null);
|
1698
1698
|
const actionCellRef = useRef(null);
|
1699
1699
|
const bottomToolbarRef = useRef(null);
|
@@ -1745,8 +1745,9 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1745
1745
|
const [pagination, onPaginationChange] = useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) !== null && _r !== void 0 ? _r : { pageIndex: 0, pageSize: 10 });
|
1746
1746
|
const [showAlertBanner, setShowAlertBanner] = useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _s !== void 0 ? _s : false);
|
1747
1747
|
const [showColumnFilters, setShowColumnFilters] = useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _t !== void 0 ? _t : false);
|
1748
|
-
const [
|
1749
|
-
const [
|
1748
|
+
const [showToolBar, setShowToolBar] = useState((_u = initialState === null || initialState === void 0 ? void 0 : initialState.showToolBar) !== null && _u !== void 0 ? _u : false);
|
1749
|
+
const [showGlobalFilter, setShowGlobalFilter] = useState((_v = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _v !== void 0 ? _v : false);
|
1750
|
+
const [showToolbarDropZone, setShowToolbarDropZone] = useState((_w = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _w !== void 0 ? _w : false);
|
1750
1751
|
definedTableOptions.state = Object.assign({ actionCell,
|
1751
1752
|
columnFilterFns,
|
1752
1753
|
columnOrder,
|
@@ -1766,6 +1767,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1766
1767
|
pagination,
|
1767
1768
|
showAlertBanner,
|
1768
1769
|
showColumnFilters,
|
1770
|
+
showToolBar,
|
1769
1771
|
showGlobalFilter,
|
1770
1772
|
showToolbarDropZone }, definedTableOptions.state);
|
1771
1773
|
//The table options now include all state needed to help determine column visibility and order logic
|
@@ -1820,7 +1822,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1820
1822
|
const table = useReactTable(Object.assign(Object.assign({ onColumnOrderChange,
|
1821
1823
|
onColumnSizingInfoChange,
|
1822
1824
|
onGroupingChange,
|
1823
|
-
onPaginationChange }, statefulTableOptions), { globalFilterFn: (
|
1825
|
+
onPaginationChange }, statefulTableOptions), { globalFilterFn: (_x = statefulTableOptions.filterFns) === null || _x === void 0 ? void 0 : _x[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
|
1824
1826
|
table.refs = {
|
1825
1827
|
actionCellRef,
|
1826
1828
|
bottomToolbarRef,
|
@@ -1836,7 +1838,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1836
1838
|
topToolbarRef,
|
1837
1839
|
};
|
1838
1840
|
table.setActionCell =
|
1839
|
-
(
|
1841
|
+
(_y = statefulTableOptions.onActionCellChange) !== null && _y !== void 0 ? _y : setActionCell;
|
1840
1842
|
table.setCreatingRow = (row) => {
|
1841
1843
|
var _a, _b;
|
1842
1844
|
let _row = row;
|
@@ -1846,34 +1848,36 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1846
1848
|
(_b = (_a = statefulTableOptions === null || statefulTableOptions === void 0 ? void 0 : statefulTableOptions.onCreatingRowChange) === null || _a === void 0 ? void 0 : _a.call(statefulTableOptions, _row)) !== null && _b !== void 0 ? _b : _setCreatingRow(_row);
|
1847
1849
|
};
|
1848
1850
|
table.setColumnFilterFns =
|
1849
|
-
(
|
1850
|
-
table.setDensity = (
|
1851
|
+
(_z = statefulTableOptions.onColumnFilterFnsChange) !== null && _z !== void 0 ? _z : setColumnFilterFns;
|
1852
|
+
table.setDensity = (_0 = statefulTableOptions.onDensityChange) !== null && _0 !== void 0 ? _0 : setDensity;
|
1851
1853
|
table.setDraggingColumn =
|
1852
|
-
(
|
1854
|
+
(_1 = statefulTableOptions.onDraggingColumnChange) !== null && _1 !== void 0 ? _1 : setDraggingColumn;
|
1853
1855
|
table.setDraggingRow =
|
1854
|
-
(
|
1856
|
+
(_2 = statefulTableOptions.onDraggingRowChange) !== null && _2 !== void 0 ? _2 : setDraggingRow;
|
1855
1857
|
table.setEditingCell =
|
1856
|
-
(
|
1858
|
+
(_3 = statefulTableOptions.onEditingCellChange) !== null && _3 !== void 0 ? _3 : setEditingCell;
|
1857
1859
|
table.setEditingRow =
|
1858
|
-
(
|
1860
|
+
(_4 = statefulTableOptions.onEditingRowChange) !== null && _4 !== void 0 ? _4 : setEditingRow;
|
1859
1861
|
table.setGlobalFilterFn =
|
1860
|
-
(
|
1862
|
+
(_5 = statefulTableOptions.onGlobalFilterFnChange) !== null && _5 !== void 0 ? _5 : setGlobalFilterFn;
|
1861
1863
|
table.setHoveredColumn =
|
1862
|
-
(
|
1864
|
+
(_6 = statefulTableOptions.onHoveredColumnChange) !== null && _6 !== void 0 ? _6 : setHoveredColumn;
|
1863
1865
|
table.setHoveredRow =
|
1864
|
-
(
|
1866
|
+
(_7 = statefulTableOptions.onHoveredRowChange) !== null && _7 !== void 0 ? _7 : setHoveredRow;
|
1865
1867
|
table.setIsFullScreen =
|
1866
|
-
(
|
1868
|
+
(_8 = statefulTableOptions.onIsFullScreenChange) !== null && _8 !== void 0 ? _8 : setIsFullScreen;
|
1867
1869
|
table.setEnableKeyboardShortcuts =
|
1868
|
-
(
|
1870
|
+
(_9 = statefulTableOptions.onEnableKeyboardShortcutsChange) !== null && _9 !== void 0 ? _9 : setEnableKeyboardShortcuts;
|
1869
1871
|
table.setShowAlertBanner =
|
1870
|
-
(
|
1872
|
+
(_10 = statefulTableOptions.onShowAlertBannerChange) !== null && _10 !== void 0 ? _10 : setShowAlertBanner;
|
1871
1873
|
table.setShowColumnFilters =
|
1872
|
-
(
|
1874
|
+
(_11 = statefulTableOptions.onShowColumnFiltersChange) !== null && _11 !== void 0 ? _11 : setShowColumnFilters;
|
1875
|
+
table.setShowToolBar =
|
1876
|
+
(_12 = statefulTableOptions.onShowToolBarChange) !== null && _12 !== void 0 ? _12 : setShowToolBar;
|
1873
1877
|
table.setShowGlobalFilter =
|
1874
|
-
(
|
1878
|
+
(_13 = statefulTableOptions.onShowGlobalFilterChange) !== null && _13 !== void 0 ? _13 : setShowGlobalFilter;
|
1875
1879
|
table.setShowToolbarDropZone =
|
1876
|
-
(
|
1880
|
+
(_14 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _14 !== void 0 ? _14 : setShowToolbarDropZone;
|
1877
1881
|
useMRT_Effects(table);
|
1878
1882
|
return table;
|
1879
1883
|
};
|
@@ -2897,7 +2901,7 @@ const MRT_ColumnActionMenu = (_a) => {
|
|
2897
2901
|
const { getAllLeafColumns, getState, options: { columnFilterDisplayMode, columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnPinning, enableColumnResizing, enableGrouping, enableHiding, enableSorting, enableSortingRemoval, icons: { ClearAllIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, RestartAltIcon, SortIcon, ViewColumnIcon, VisibilityOffIcon, }, localization, mrtTheme: { menuBackgroundColor }, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnFilterFns, setColumnOrder, setColumnSizingInfo, setShowColumnFilters, } = table;
|
2898
2902
|
const { column } = header;
|
2899
2903
|
const { columnDef } = column;
|
2900
|
-
const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
|
2904
|
+
const { columnSizing, columnVisibility, density, showColumnFilters, showToolBar } = getState();
|
2901
2905
|
const columnFilterValue = column.getFilterValue();
|
2902
2906
|
const [filterMenuAnchorEl, setFilterMenuAnchorEl] = useState(null);
|
2903
2907
|
const handleClearSort = () => {
|
@@ -3005,6 +3009,11 @@ const MRT_ColumnActionMenu = (_a) => {
|
|
3005
3009
|
.length, icon: jsx(ViewColumnIcon, {}), label: (_h = localization.showAllColumns) === null || _h === void 0 ? void 0 : _h.replace('{column}', String(columnDef.header)), onClick: handleShowAllColumns, table: table }, 12),
|
3006
3010
|
]
|
3007
3011
|
: []),
|
3012
|
+
// **Newly Added Menu Item for Toolbar Visibility**
|
3013
|
+
jsx(MRT_ActionMenuItem, { icon: jsx(ViewColumnIcon, {}), label: showToolBar ? "Hide ToolBar" : "Show ToolBar", onClick: (e) => {
|
3014
|
+
e.stopPropagation();
|
3015
|
+
table.setShowToolBar(!showToolBar);
|
3016
|
+
}, table: table }, 13),
|
3008
3017
|
].filter(Boolean);
|
3009
3018
|
return (jsx(Menu, Object.assign({ MenuListProps: {
|
3010
3019
|
dense: density === 'compact',
|
@@ -3128,19 +3137,7 @@ const MRT_FilterTextField = (_a) => {
|
|
3128
3137
|
});
|
3129
3138
|
}
|
3130
3139
|
else {
|
3131
|
-
|
3132
|
-
// column.setFilterValue(newValue === '' ? undefined : newValue);
|
3133
|
-
debugger;
|
3134
|
-
if (newValue === 0) {
|
3135
|
-
column.setFilterValue("0");
|
3136
|
-
}
|
3137
|
-
else {
|
3138
|
-
column.setFilterValue(newValue);
|
3139
|
-
}
|
3140
|
-
}
|
3141
|
-
else {
|
3142
|
-
column.setFilterValue(newValue !== null && newValue !== void 0 ? newValue : undefined);
|
3143
|
-
}
|
3140
|
+
column.setFilterValue(newValue !== null && newValue !== void 0 ? newValue : undefined);
|
3144
3141
|
}
|
3145
3142
|
}, isTextboxFilter ? (manualFiltering ? 400 : 200) : 1), []);
|
3146
3143
|
const handleChange = (newValue) => {
|
@@ -3178,6 +3175,8 @@ const MRT_FilterTextField = (_a) => {
|
|
3178
3175
|
setFilterValue('');
|
3179
3176
|
column.setFilterValue(undefined);
|
3180
3177
|
}
|
3178
|
+
// focus on the input after clearing the filter
|
3179
|
+
// filterInputRefs.current[`${column.id}-${rangeFilterIndex ?? 0}`]?.focus();
|
3181
3180
|
};
|
3182
3181
|
const handleClearEmptyFilterChip = () => {
|
3183
3182
|
setFilterValue('');
|
@@ -3549,6 +3548,24 @@ const MRT_TableHeadCellSortLabel = (_a) => {
|
|
3549
3548
|
}, flex: '0 0', opacity: isSorted ? 1 : 0.3, transition: 'all 150ms ease-in-out', width: '3ch' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))) })) }) }));
|
3550
3549
|
};
|
3551
3550
|
|
3551
|
+
const MRT_TableHeadCellToolBar = (_a) => {
|
3552
|
+
var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
|
3553
|
+
const { getState, options: { icons: { ArrowDownwardIcon, SyncAltIcon }, localization, }, } = table;
|
3554
|
+
const { isLoading, showSkeletons, showToolBar } = getState();
|
3555
|
+
const showToolBarTooltip = isLoading || showSkeletons
|
3556
|
+
? ''
|
3557
|
+
: showToolBar
|
3558
|
+
? "Hide ToolBar"
|
3559
|
+
: "Show ToolBar";
|
3560
|
+
return (jsx(Tooltip, { placement: "top", title: showToolBarTooltip, children: jsx(IconButton$1, { "aria-label": showToolBarTooltip, size: "small", sx: (theme) => (Object.assign({ '&:hover': {
|
3561
|
+
backgroundColor: 'transparent',
|
3562
|
+
opacity: 1,
|
3563
|
+
}, cursor: 'pointer', opacity: 1, p: '2px', transition: 'all 150ms ease-in-out' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), onClick: (e) => {
|
3564
|
+
e.stopPropagation();
|
3565
|
+
table.setShowToolBar(!showToolBar);
|
3566
|
+
}, children: jsx(SyncAltIcon, {}) }) }));
|
3567
|
+
};
|
3568
|
+
|
3552
3569
|
const MRT_TableHeadCell = (_a) => {
|
3553
3570
|
var _b, _c, _d, _f, _g, _h;
|
3554
3571
|
var { columnVirtualizer, header, staticColumnIndex, table } = _a, rest = __rest(_a, ["columnVirtualizer", "header", "staticColumnIndex", "table"]);
|
@@ -3556,7 +3573,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3556
3573
|
const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning,
|
3557
3574
|
// enableKeyboardShortcuts,
|
3558
3575
|
enableGrouping, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
|
3559
|
-
const { enableKeyboardShortcuts, columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
|
3576
|
+
const { enableKeyboardShortcuts, columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, showToolBar, } = getState();
|
3560
3577
|
const { column } = header;
|
3561
3578
|
const { columnDef } = column;
|
3562
3579
|
const { columnDefType } = columnDef;
|
@@ -3716,7 +3733,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3716
3733
|
whiteSpace: ((_h = (_g = columnDef.header) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0) < 20
|
3717
3734
|
? 'nowrap'
|
3718
3735
|
: 'normal',
|
3719
|
-
}, children: HeaderElement }), column.getCanFilter() && (jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table })), column.getCanSort() && (jsx(MRT_TableHeadCellSortLabel, { header: header, table: table }))] }), columnDefType !== 'group' && (jsxs(Box, { className: "Mui-TableHeadCell-Content-Actions", sx: {
|
3736
|
+
}, children: HeaderElement }), column.getCanFilter() && (jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table })), column.getCanSort() && (jsx(MRT_TableHeadCellSortLabel, { header: header, table: table })), jsx(MRT_TableHeadCellToolBar, { header: header, table: table })] }), columnDefType !== 'group' && (jsxs(Box, { className: "Mui-TableHeadCell-Content-Actions", sx: {
|
3720
3737
|
whiteSpace: 'nowrap',
|
3721
3738
|
}, children: [showDragHandle && (jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
|
3722
3739
|
current: tableHeadCellRefs.current[column.id],
|