material-react-table-narender 2.13.25 → 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 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';
@@ -436,7 +436,7 @@ const openEditingCell = ({ cell, table, }) => {
436
436
  };
437
437
  const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement, event, header, parentElement, table, }) => {
438
438
  var _a, _b, _c, _d, _e, _f, _g, _h;
439
- debugger;
439
+ //debugger;
440
440
  const { getState, setEnableKeyboardShortcuts, } = table;
441
441
  const { enableKeyboardShortcuts } = getState();
442
442
  if (event.altKey && event.key.toLocaleLowerCase() === 'n') {
@@ -532,7 +532,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
532
532
  header.column.toggleSorting();
533
533
  }
534
534
  else if ("Enter" === event.key) {
535
- debugger;
535
+ //debugger;
536
536
  event.preventDefault();
537
537
  const input = currentCell.querySelector('input');
538
538
  const select = currentCell.querySelector('select');
@@ -573,7 +573,7 @@ const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement
573
573
  ].includes(event.key)) {
574
574
  event.preventDefault();
575
575
  // if (['ArrowDown'].includes(event.key)) {
576
- // debugger; // This will pause execution for debugging purposes
576
+ // //debugger; // This will pause execution for debugging purposes
577
577
  // // Select the input element within the MUI Autocomplete component
578
578
  // const autocomplete = currentCell.querySelector('.MuiAutocomplete-root input[type="text"]');
579
579
  // // Check if the current cell is an MUI Autocomplete
@@ -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 [showGlobalFilter, setShowGlobalFilter] = useState((_u = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _u !== void 0 ? _u : false);
1749
- const [showToolbarDropZone, setShowToolbarDropZone] = useState((_v = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _v !== void 0 ? _v : false);
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: (_w = statefulTableOptions.filterFns) === null || _w === void 0 ? void 0 : _w[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
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
- (_x = statefulTableOptions.onActionCellChange) !== null && _x !== void 0 ? _x : setActionCell;
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
- (_y = statefulTableOptions.onColumnFilterFnsChange) !== null && _y !== void 0 ? _y : setColumnFilterFns;
1850
- table.setDensity = (_z = statefulTableOptions.onDensityChange) !== null && _z !== void 0 ? _z : 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
- (_0 = statefulTableOptions.onDraggingColumnChange) !== null && _0 !== void 0 ? _0 : setDraggingColumn;
1854
+ (_1 = statefulTableOptions.onDraggingColumnChange) !== null && _1 !== void 0 ? _1 : setDraggingColumn;
1853
1855
  table.setDraggingRow =
1854
- (_1 = statefulTableOptions.onDraggingRowChange) !== null && _1 !== void 0 ? _1 : setDraggingRow;
1856
+ (_2 = statefulTableOptions.onDraggingRowChange) !== null && _2 !== void 0 ? _2 : setDraggingRow;
1855
1857
  table.setEditingCell =
1856
- (_2 = statefulTableOptions.onEditingCellChange) !== null && _2 !== void 0 ? _2 : setEditingCell;
1858
+ (_3 = statefulTableOptions.onEditingCellChange) !== null && _3 !== void 0 ? _3 : setEditingCell;
1857
1859
  table.setEditingRow =
1858
- (_3 = statefulTableOptions.onEditingRowChange) !== null && _3 !== void 0 ? _3 : setEditingRow;
1860
+ (_4 = statefulTableOptions.onEditingRowChange) !== null && _4 !== void 0 ? _4 : setEditingRow;
1859
1861
  table.setGlobalFilterFn =
1860
- (_4 = statefulTableOptions.onGlobalFilterFnChange) !== null && _4 !== void 0 ? _4 : setGlobalFilterFn;
1862
+ (_5 = statefulTableOptions.onGlobalFilterFnChange) !== null && _5 !== void 0 ? _5 : setGlobalFilterFn;
1861
1863
  table.setHoveredColumn =
1862
- (_5 = statefulTableOptions.onHoveredColumnChange) !== null && _5 !== void 0 ? _5 : setHoveredColumn;
1864
+ (_6 = statefulTableOptions.onHoveredColumnChange) !== null && _6 !== void 0 ? _6 : setHoveredColumn;
1863
1865
  table.setHoveredRow =
1864
- (_6 = statefulTableOptions.onHoveredRowChange) !== null && _6 !== void 0 ? _6 : setHoveredRow;
1866
+ (_7 = statefulTableOptions.onHoveredRowChange) !== null && _7 !== void 0 ? _7 : setHoveredRow;
1865
1867
  table.setIsFullScreen =
1866
- (_7 = statefulTableOptions.onIsFullScreenChange) !== null && _7 !== void 0 ? _7 : setIsFullScreen;
1868
+ (_8 = statefulTableOptions.onIsFullScreenChange) !== null && _8 !== void 0 ? _8 : setIsFullScreen;
1867
1869
  table.setEnableKeyboardShortcuts =
1868
- (_8 = statefulTableOptions.onEnableKeyboardShortcutsChange) !== null && _8 !== void 0 ? _8 : setEnableKeyboardShortcuts;
1870
+ (_9 = statefulTableOptions.onEnableKeyboardShortcutsChange) !== null && _9 !== void 0 ? _9 : setEnableKeyboardShortcuts;
1869
1871
  table.setShowAlertBanner =
1870
- (_9 = statefulTableOptions.onShowAlertBannerChange) !== null && _9 !== void 0 ? _9 : setShowAlertBanner;
1872
+ (_10 = statefulTableOptions.onShowAlertBannerChange) !== null && _10 !== void 0 ? _10 : setShowAlertBanner;
1871
1873
  table.setShowColumnFilters =
1872
- (_10 = statefulTableOptions.onShowColumnFiltersChange) !== null && _10 !== void 0 ? _10 : setShowColumnFilters;
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
- (_11 = statefulTableOptions.onShowGlobalFilterChange) !== null && _11 !== void 0 ? _11 : setShowGlobalFilter;
1878
+ (_13 = statefulTableOptions.onShowGlobalFilterChange) !== null && _13 !== void 0 ? _13 : setShowGlobalFilter;
1875
1879
  table.setShowToolbarDropZone =
1876
- (_12 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _12 !== void 0 ? _12 : setShowToolbarDropZone;
1880
+ (_14 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _14 !== void 0 ? _14 : setShowToolbarDropZone;
1877
1881
  useMRT_Effects(table);
1878
1882
  return table;
1879
1883
  };
@@ -2332,7 +2336,7 @@ const MRT_TableBodyCell = (_a) => {
2332
2336
  const handleKeyDown = (event) => {
2333
2337
  var _a;
2334
2338
  (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onKeyDown) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, event);
2335
- debugger;
2339
+ //debugger;
2336
2340
  cellKeyboardShortcuts({
2337
2341
  cell,
2338
2342
  cellValue: cell.getValue(),
@@ -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',
@@ -3166,6 +3175,8 @@ const MRT_FilterTextField = (_a) => {
3166
3175
  setFilterValue('');
3167
3176
  column.setFilterValue(undefined);
3168
3177
  }
3178
+ // focus on the input after clearing the filter
3179
+ // filterInputRefs.current[`${column.id}-${rangeFilterIndex ?? 0}`]?.focus();
3169
3180
  };
3170
3181
  const handleClearEmptyFilterChip = () => {
3171
3182
  setFilterValue('');
@@ -3537,6 +3548,24 @@ const MRT_TableHeadCellSortLabel = (_a) => {
3537
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))) })) }) }));
3538
3549
  };
3539
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
+
3540
3569
  const MRT_TableHeadCell = (_a) => {
3541
3570
  var _b, _c, _d, _f, _g, _h;
3542
3571
  var { columnVirtualizer, header, staticColumnIndex, table } = _a, rest = __rest(_a, ["columnVirtualizer", "header", "staticColumnIndex", "table"]);
@@ -3544,7 +3573,7 @@ const MRT_TableHeadCell = (_a) => {
3544
3573
  const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning,
3545
3574
  // enableKeyboardShortcuts,
3546
3575
  enableGrouping, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
3547
- const { enableKeyboardShortcuts, columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
3576
+ const { enableKeyboardShortcuts, columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, showToolBar, } = getState();
3548
3577
  const { column } = header;
3549
3578
  const { columnDef } = column;
3550
3579
  const { columnDefType } = columnDef;
@@ -3704,7 +3733,7 @@ const MRT_TableHeadCell = (_a) => {
3704
3733
  whiteSpace: ((_h = (_g = columnDef.header) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0) < 20
3705
3734
  ? 'nowrap'
3706
3735
  : 'normal',
3707
- }, 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: {
3708
3737
  whiteSpace: 'nowrap',
3709
3738
  }, children: [showDragHandle && (jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
3710
3739
  current: tableHeadCellRefs.current[column.id],
@@ -4439,7 +4468,7 @@ const MRT_TablePaper = (_a) => {
4439
4468
  const isTableInstanceProp = (props) => props.table !== undefined;
4440
4469
  const MaterialReactTable = (props) => {
4441
4470
  let table;
4442
- debugger;
4471
+ //debugger;
4443
4472
  if (isTableInstanceProp(props)) {
4444
4473
  table = props.table;
4445
4474
  }