material-react-table-narender 2.13.25 → 2.13.29
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +3 -0
- package/dist/index.esm.js +58 -29
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +57 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/MaterialReactTable.tsx +1 -1
- package/src/components/body/MRT_TableBodyCell.tsx +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 -0
- package/src/components/menus/MRT_ColumnActionMenu.tsx +14 -1
- package/src/hooks/useMRT_TableInstance.ts +8 -0
- package/src/types.ts +3 -0
- package/src/utils/cell.utils.ts +3 -3
package/dist/index.js
CHANGED
@@ -527,7 +527,7 @@ const openEditingCell = ({ cell, table, }) => {
|
|
527
527
|
};
|
528
528
|
const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement, event, header, parentElement, table, }) => {
|
529
529
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
530
|
-
debugger;
|
530
|
+
//debugger;
|
531
531
|
const { getState, setEnableKeyboardShortcuts, } = table;
|
532
532
|
const { enableKeyboardShortcuts } = getState();
|
533
533
|
if (event.altKey && event.key.toLocaleLowerCase() === 'n') {
|
@@ -623,7 +623,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
|
|
623
623
|
header.column.toggleSorting();
|
624
624
|
}
|
625
625
|
else if ("Enter" === event.key) {
|
626
|
-
debugger;
|
626
|
+
//debugger;
|
627
627
|
event.preventDefault();
|
628
628
|
const input = currentCell.querySelector('input');
|
629
629
|
const select = currentCell.querySelector('select');
|
@@ -664,7 +664,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
|
|
664
664
|
].includes(event.key)) {
|
665
665
|
event.preventDefault();
|
666
666
|
// if (['ArrowDown'].includes(event.key)) {
|
667
|
-
// debugger; // This will pause execution for debugging purposes
|
667
|
+
// //debugger; // This will pause execution for debugging purposes
|
668
668
|
// // Select the input element within the MUI Autocomplete component
|
669
669
|
// const autocomplete = currentCell.querySelector('.MuiAutocomplete-root input[type="text"]');
|
670
670
|
// // Check if the current cell is an MUI Autocomplete
|
@@ -1784,7 +1784,7 @@ const useMRT_Effects = (table) => {
|
|
1784
1784
|
* @returns the MRT table instance
|
1785
1785
|
*/
|
1786
1786
|
const useMRT_TableInstance = (definedTableOptions) => {
|
1787
|
-
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;
|
1787
|
+
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;
|
1788
1788
|
const lastSelectedRowId = react.useRef(null);
|
1789
1789
|
const actionCellRef = react.useRef(null);
|
1790
1790
|
const bottomToolbarRef = react.useRef(null);
|
@@ -1836,8 +1836,9 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1836
1836
|
const [pagination, onPaginationChange] = react.useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) !== null && _r !== void 0 ? _r : { pageIndex: 0, pageSize: 10 });
|
1837
1837
|
const [showAlertBanner, setShowAlertBanner] = react.useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _s !== void 0 ? _s : false);
|
1838
1838
|
const [showColumnFilters, setShowColumnFilters] = react.useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _t !== void 0 ? _t : false);
|
1839
|
-
const [
|
1840
|
-
const [
|
1839
|
+
const [showToolBar, setShowToolBar] = react.useState((_u = initialState === null || initialState === void 0 ? void 0 : initialState.showToolBar) !== null && _u !== void 0 ? _u : false);
|
1840
|
+
const [showGlobalFilter, setShowGlobalFilter] = react.useState((_v = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _v !== void 0 ? _v : false);
|
1841
|
+
const [showToolbarDropZone, setShowToolbarDropZone] = react.useState((_w = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _w !== void 0 ? _w : false);
|
1841
1842
|
definedTableOptions.state = Object.assign({ actionCell,
|
1842
1843
|
columnFilterFns,
|
1843
1844
|
columnOrder,
|
@@ -1857,6 +1858,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1857
1858
|
pagination,
|
1858
1859
|
showAlertBanner,
|
1859
1860
|
showColumnFilters,
|
1861
|
+
showToolBar,
|
1860
1862
|
showGlobalFilter,
|
1861
1863
|
showToolbarDropZone }, definedTableOptions.state);
|
1862
1864
|
//The table options now include all state needed to help determine column visibility and order logic
|
@@ -1911,7 +1913,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1911
1913
|
const table = reactTable.useReactTable(Object.assign(Object.assign({ onColumnOrderChange,
|
1912
1914
|
onColumnSizingInfoChange,
|
1913
1915
|
onGroupingChange,
|
1914
|
-
onPaginationChange }, statefulTableOptions), { globalFilterFn: (
|
1916
|
+
onPaginationChange }, statefulTableOptions), { globalFilterFn: (_x = statefulTableOptions.filterFns) === null || _x === void 0 ? void 0 : _x[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
|
1915
1917
|
table.refs = {
|
1916
1918
|
actionCellRef,
|
1917
1919
|
bottomToolbarRef,
|
@@ -1927,7 +1929,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1927
1929
|
topToolbarRef,
|
1928
1930
|
};
|
1929
1931
|
table.setActionCell =
|
1930
|
-
(
|
1932
|
+
(_y = statefulTableOptions.onActionCellChange) !== null && _y !== void 0 ? _y : setActionCell;
|
1931
1933
|
table.setCreatingRow = (row) => {
|
1932
1934
|
var _a, _b;
|
1933
1935
|
let _row = row;
|
@@ -1937,34 +1939,36 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1937
1939
|
(_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);
|
1938
1940
|
};
|
1939
1941
|
table.setColumnFilterFns =
|
1940
|
-
(
|
1941
|
-
table.setDensity = (
|
1942
|
+
(_z = statefulTableOptions.onColumnFilterFnsChange) !== null && _z !== void 0 ? _z : setColumnFilterFns;
|
1943
|
+
table.setDensity = (_0 = statefulTableOptions.onDensityChange) !== null && _0 !== void 0 ? _0 : setDensity;
|
1942
1944
|
table.setDraggingColumn =
|
1943
|
-
(
|
1945
|
+
(_1 = statefulTableOptions.onDraggingColumnChange) !== null && _1 !== void 0 ? _1 : setDraggingColumn;
|
1944
1946
|
table.setDraggingRow =
|
1945
|
-
(
|
1947
|
+
(_2 = statefulTableOptions.onDraggingRowChange) !== null && _2 !== void 0 ? _2 : setDraggingRow;
|
1946
1948
|
table.setEditingCell =
|
1947
|
-
(
|
1949
|
+
(_3 = statefulTableOptions.onEditingCellChange) !== null && _3 !== void 0 ? _3 : setEditingCell;
|
1948
1950
|
table.setEditingRow =
|
1949
|
-
(
|
1951
|
+
(_4 = statefulTableOptions.onEditingRowChange) !== null && _4 !== void 0 ? _4 : setEditingRow;
|
1950
1952
|
table.setGlobalFilterFn =
|
1951
|
-
(
|
1953
|
+
(_5 = statefulTableOptions.onGlobalFilterFnChange) !== null && _5 !== void 0 ? _5 : setGlobalFilterFn;
|
1952
1954
|
table.setHoveredColumn =
|
1953
|
-
(
|
1955
|
+
(_6 = statefulTableOptions.onHoveredColumnChange) !== null && _6 !== void 0 ? _6 : setHoveredColumn;
|
1954
1956
|
table.setHoveredRow =
|
1955
|
-
(
|
1957
|
+
(_7 = statefulTableOptions.onHoveredRowChange) !== null && _7 !== void 0 ? _7 : setHoveredRow;
|
1956
1958
|
table.setIsFullScreen =
|
1957
|
-
(
|
1959
|
+
(_8 = statefulTableOptions.onIsFullScreenChange) !== null && _8 !== void 0 ? _8 : setIsFullScreen;
|
1958
1960
|
table.setEnableKeyboardShortcuts =
|
1959
|
-
(
|
1961
|
+
(_9 = statefulTableOptions.onEnableKeyboardShortcutsChange) !== null && _9 !== void 0 ? _9 : setEnableKeyboardShortcuts;
|
1960
1962
|
table.setShowAlertBanner =
|
1961
|
-
(
|
1963
|
+
(_10 = statefulTableOptions.onShowAlertBannerChange) !== null && _10 !== void 0 ? _10 : setShowAlertBanner;
|
1962
1964
|
table.setShowColumnFilters =
|
1963
|
-
(
|
1965
|
+
(_11 = statefulTableOptions.onShowColumnFiltersChange) !== null && _11 !== void 0 ? _11 : setShowColumnFilters;
|
1966
|
+
table.setShowToolBar =
|
1967
|
+
(_12 = statefulTableOptions.onShowToolBarChange) !== null && _12 !== void 0 ? _12 : setShowToolBar;
|
1964
1968
|
table.setShowGlobalFilter =
|
1965
|
-
(
|
1969
|
+
(_13 = statefulTableOptions.onShowGlobalFilterChange) !== null && _13 !== void 0 ? _13 : setShowGlobalFilter;
|
1966
1970
|
table.setShowToolbarDropZone =
|
1967
|
-
(
|
1971
|
+
(_14 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _14 !== void 0 ? _14 : setShowToolbarDropZone;
|
1968
1972
|
useMRT_Effects(table);
|
1969
1973
|
return table;
|
1970
1974
|
};
|
@@ -2423,7 +2427,7 @@ const MRT_TableBodyCell = (_a) => {
|
|
2423
2427
|
const handleKeyDown = (event) => {
|
2424
2428
|
var _a;
|
2425
2429
|
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
|
2426
|
-
debugger;
|
2430
|
+
//debugger;
|
2427
2431
|
cellKeyboardShortcuts({
|
2428
2432
|
cell,
|
2429
2433
|
cellValue: cell.getValue(),
|
@@ -2988,7 +2992,7 @@ const MRT_ColumnActionMenu = (_a) => {
|
|
2988
2992
|
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;
|
2989
2993
|
const { column } = header;
|
2990
2994
|
const { columnDef } = column;
|
2991
|
-
const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
|
2995
|
+
const { columnSizing, columnVisibility, density, showColumnFilters, showToolBar } = getState();
|
2992
2996
|
const columnFilterValue = column.getFilterValue();
|
2993
2997
|
const [filterMenuAnchorEl, setFilterMenuAnchorEl] = react.useState(null);
|
2994
2998
|
const handleClearSort = () => {
|
@@ -3096,6 +3100,11 @@ const MRT_ColumnActionMenu = (_a) => {
|
|
3096
3100
|
.length, icon: jsxRuntime.jsx(ViewColumnIcon, {}), label: (_h = localization.showAllColumns) === null || _h === void 0 ? void 0 : _h.replace('{column}', String(columnDef.header)), onClick: handleShowAllColumns, table: table }, 12),
|
3097
3101
|
]
|
3098
3102
|
: []),
|
3103
|
+
// **Newly Added Menu Item for Toolbar Visibility**
|
3104
|
+
jsxRuntime.jsx(MRT_ActionMenuItem, { icon: jsxRuntime.jsx(ViewColumnIcon, {}), label: showToolBar ? "Hide ToolBar" : "Show ToolBar", onClick: (e) => {
|
3105
|
+
e.stopPropagation();
|
3106
|
+
table.setShowToolBar(!showToolBar);
|
3107
|
+
}, table: table }, 13),
|
3099
3108
|
].filter(Boolean);
|
3100
3109
|
return (jsxRuntime.jsx(Menu__default["default"], Object.assign({ MenuListProps: {
|
3101
3110
|
dense: density === 'compact',
|
@@ -3257,6 +3266,8 @@ const MRT_FilterTextField = (_a) => {
|
|
3257
3266
|
setFilterValue('');
|
3258
3267
|
column.setFilterValue(undefined);
|
3259
3268
|
}
|
3269
|
+
// focus on the input after clearing the filter
|
3270
|
+
// filterInputRefs.current[`${column.id}-${rangeFilterIndex ?? 0}`]?.focus();
|
3260
3271
|
};
|
3261
3272
|
const handleClearEmptyFilterChip = () => {
|
3262
3273
|
setFilterValue('');
|
@@ -3628,6 +3639,24 @@ const MRT_TableHeadCellSortLabel = (_a) => {
|
|
3628
3639
|
}, 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))) })) }) }));
|
3629
3640
|
};
|
3630
3641
|
|
3642
|
+
const MRT_TableHeadCellToolBar = (_a) => {
|
3643
|
+
var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
|
3644
|
+
const { getState, options: { icons: { ArrowDownwardIcon, SyncAltIcon }, localization, }, } = table;
|
3645
|
+
const { isLoading, showSkeletons, showToolBar } = getState();
|
3646
|
+
const showToolBarTooltip = isLoading || showSkeletons
|
3647
|
+
? ''
|
3648
|
+
: showToolBar
|
3649
|
+
? "Hide ToolBar"
|
3650
|
+
: "Show ToolBar";
|
3651
|
+
return (jsxRuntime.jsx(Tooltip__default["default"], { placement: "top", title: showToolBarTooltip, children: jsxRuntime.jsx(material.IconButton, { "aria-label": showToolBarTooltip, size: "small", sx: (theme) => (Object.assign({ '&:hover': {
|
3652
|
+
backgroundColor: 'transparent',
|
3653
|
+
opacity: 1,
|
3654
|
+
}, 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) => {
|
3655
|
+
e.stopPropagation();
|
3656
|
+
table.setShowToolBar(!showToolBar);
|
3657
|
+
}, children: jsxRuntime.jsx(SyncAltIcon, {}) }) }));
|
3658
|
+
};
|
3659
|
+
|
3631
3660
|
const MRT_TableHeadCell = (_a) => {
|
3632
3661
|
var _b, _c, _d, _f, _g, _h;
|
3633
3662
|
var { columnVirtualizer, header, staticColumnIndex, table } = _a, rest = __rest(_a, ["columnVirtualizer", "header", "staticColumnIndex", "table"]);
|
@@ -3635,7 +3664,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3635
3664
|
const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning,
|
3636
3665
|
// enableKeyboardShortcuts,
|
3637
3666
|
enableGrouping, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
|
3638
|
-
const { enableKeyboardShortcuts, columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
|
3667
|
+
const { enableKeyboardShortcuts, columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, showToolBar, } = getState();
|
3639
3668
|
const { column } = header;
|
3640
3669
|
const { columnDef } = column;
|
3641
3670
|
const { columnDefType } = columnDef;
|
@@ -3795,7 +3824,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3795
3824
|
whiteSpace: ((_h = (_g = columnDef.header) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0) < 20
|
3796
3825
|
? 'nowrap'
|
3797
3826
|
: 'normal',
|
3798
|
-
}, children: HeaderElement }), column.getCanFilter() && (jsxRuntime.jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table })), column.getCanSort() && (jsxRuntime.jsx(MRT_TableHeadCellSortLabel, { header: header, table: table }))] }), columnDefType !== 'group' && (jsxRuntime.jsxs(Box__default["default"], { className: "Mui-TableHeadCell-Content-Actions", sx: {
|
3827
|
+
}, children: HeaderElement }), column.getCanFilter() && (jsxRuntime.jsx(MRT_TableHeadCellFilterLabel, { header: header, table: table })), column.getCanSort() && (jsxRuntime.jsx(MRT_TableHeadCellSortLabel, { header: header, table: table })), jsxRuntime.jsx(MRT_TableHeadCellToolBar, { header: header, table: table })] }), columnDefType !== 'group' && (jsxRuntime.jsxs(Box__default["default"], { className: "Mui-TableHeadCell-Content-Actions", sx: {
|
3799
3828
|
whiteSpace: 'nowrap',
|
3800
3829
|
}, children: [showDragHandle && (jsxRuntime.jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
|
3801
3830
|
current: tableHeadCellRefs.current[column.id],
|
@@ -4530,7 +4559,7 @@ const MRT_TablePaper = (_a) => {
|
|
4530
4559
|
const isTableInstanceProp = (props) => props.table !== undefined;
|
4531
4560
|
const MaterialReactTable = (props) => {
|
4532
4561
|
let table;
|
4533
|
-
debugger;
|
4562
|
+
//debugger;
|
4534
4563
|
if (isTableInstanceProp(props)) {
|
4535
4564
|
table = props.table;
|
4536
4565
|
}
|