material-react-table-narender 2.13.27 → 2.13.30

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.js CHANGED
@@ -53,6 +53,7 @@ var SyncAltIcon = require('@mui/icons-material/SyncAlt');
53
53
  var ViewColumnIcon = require('@mui/icons-material/ViewColumn');
54
54
  var VisibilityOffIcon = require('@mui/icons-material/VisibilityOff');
55
55
  var SettingsBackupRestoreIcon = require('@mui/icons-material/SettingsBackupRestore');
56
+ var SettingsOutlinedIcon = require('@mui/icons-material/SettingsOutlined');
56
57
  var reactVirtual = require('@tanstack/react-virtual');
57
58
  var Paper = require('@mui/material/Paper');
58
59
  var material = require('@mui/material');
@@ -146,6 +147,7 @@ var SyncAltIcon__default = /*#__PURE__*/_interopDefaultLegacy(SyncAltIcon);
146
147
  var ViewColumnIcon__default = /*#__PURE__*/_interopDefaultLegacy(ViewColumnIcon);
147
148
  var VisibilityOffIcon__default = /*#__PURE__*/_interopDefaultLegacy(VisibilityOffIcon);
148
149
  var SettingsBackupRestoreIcon__default = /*#__PURE__*/_interopDefaultLegacy(SettingsBackupRestoreIcon);
150
+ var SettingsOutlinedIcon__default = /*#__PURE__*/_interopDefaultLegacy(SettingsOutlinedIcon);
149
151
  var Paper__default = /*#__PURE__*/_interopDefaultLegacy(Paper);
150
152
  var TableContainer__default = /*#__PURE__*/_interopDefaultLegacy(TableContainer);
151
153
  var Table__default = /*#__PURE__*/_interopDefaultLegacy(Table);
@@ -1462,7 +1464,8 @@ const MRT_Default_Icons = {
1462
1464
  SyncAltIcon: SyncAltIcon__default["default"],
1463
1465
  ViewColumnIcon: ViewColumnIcon__default["default"],
1464
1466
  VisibilityOffIcon: VisibilityOffIcon__default["default"],
1465
- SettingsBackupRestoreIcon: SettingsBackupRestoreIcon__default["default"]
1467
+ SettingsBackupRestoreIcon: SettingsBackupRestoreIcon__default["default"],
1468
+ SettingsOutlinedIcon: SettingsOutlinedIcon__default["default"]
1466
1469
  };
1467
1470
 
1468
1471
  const MRT_Localization_EN = {
@@ -1784,7 +1787,7 @@ const useMRT_Effects = (table) => {
1784
1787
  * @returns the MRT table instance
1785
1788
  */
1786
1789
  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;
1790
+ 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
1791
  const lastSelectedRowId = react.useRef(null);
1789
1792
  const actionCellRef = react.useRef(null);
1790
1793
  const bottomToolbarRef = react.useRef(null);
@@ -1836,8 +1839,9 @@ const useMRT_TableInstance = (definedTableOptions) => {
1836
1839
  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
1840
  const [showAlertBanner, setShowAlertBanner] = react.useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _s !== void 0 ? _s : false);
1838
1841
  const [showColumnFilters, setShowColumnFilters] = react.useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _t !== void 0 ? _t : false);
1839
- const [showGlobalFilter, setShowGlobalFilter] = react.useState((_u = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _u !== void 0 ? _u : false);
1840
- const [showToolbarDropZone, setShowToolbarDropZone] = react.useState((_v = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _v !== void 0 ? _v : false);
1842
+ const [showToolBar, setShowToolBar] = react.useState((_u = initialState === null || initialState === void 0 ? void 0 : initialState.showToolBar) !== null && _u !== void 0 ? _u : false);
1843
+ const [showGlobalFilter, setShowGlobalFilter] = react.useState((_v = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _v !== void 0 ? _v : false);
1844
+ const [showToolbarDropZone, setShowToolbarDropZone] = react.useState((_w = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _w !== void 0 ? _w : false);
1841
1845
  definedTableOptions.state = Object.assign({ actionCell,
1842
1846
  columnFilterFns,
1843
1847
  columnOrder,
@@ -1857,6 +1861,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
1857
1861
  pagination,
1858
1862
  showAlertBanner,
1859
1863
  showColumnFilters,
1864
+ showToolBar,
1860
1865
  showGlobalFilter,
1861
1866
  showToolbarDropZone }, definedTableOptions.state);
1862
1867
  //The table options now include all state needed to help determine column visibility and order logic
@@ -1911,7 +1916,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
1911
1916
  const table = reactTable.useReactTable(Object.assign(Object.assign({ onColumnOrderChange,
1912
1917
  onColumnSizingInfoChange,
1913
1918
  onGroupingChange,
1914
- onPaginationChange }, statefulTableOptions), { globalFilterFn: (_w = statefulTableOptions.filterFns) === null || _w === void 0 ? void 0 : _w[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
1919
+ onPaginationChange }, statefulTableOptions), { globalFilterFn: (_x = statefulTableOptions.filterFns) === null || _x === void 0 ? void 0 : _x[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
1915
1920
  table.refs = {
1916
1921
  actionCellRef,
1917
1922
  bottomToolbarRef,
@@ -1927,7 +1932,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
1927
1932
  topToolbarRef,
1928
1933
  };
1929
1934
  table.setActionCell =
1930
- (_x = statefulTableOptions.onActionCellChange) !== null && _x !== void 0 ? _x : setActionCell;
1935
+ (_y = statefulTableOptions.onActionCellChange) !== null && _y !== void 0 ? _y : setActionCell;
1931
1936
  table.setCreatingRow = (row) => {
1932
1937
  var _a, _b;
1933
1938
  let _row = row;
@@ -1937,34 +1942,36 @@ const useMRT_TableInstance = (definedTableOptions) => {
1937
1942
  (_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
1943
  };
1939
1944
  table.setColumnFilterFns =
1940
- (_y = statefulTableOptions.onColumnFilterFnsChange) !== null && _y !== void 0 ? _y : setColumnFilterFns;
1941
- table.setDensity = (_z = statefulTableOptions.onDensityChange) !== null && _z !== void 0 ? _z : setDensity;
1945
+ (_z = statefulTableOptions.onColumnFilterFnsChange) !== null && _z !== void 0 ? _z : setColumnFilterFns;
1946
+ table.setDensity = (_0 = statefulTableOptions.onDensityChange) !== null && _0 !== void 0 ? _0 : setDensity;
1942
1947
  table.setDraggingColumn =
1943
- (_0 = statefulTableOptions.onDraggingColumnChange) !== null && _0 !== void 0 ? _0 : setDraggingColumn;
1948
+ (_1 = statefulTableOptions.onDraggingColumnChange) !== null && _1 !== void 0 ? _1 : setDraggingColumn;
1944
1949
  table.setDraggingRow =
1945
- (_1 = statefulTableOptions.onDraggingRowChange) !== null && _1 !== void 0 ? _1 : setDraggingRow;
1950
+ (_2 = statefulTableOptions.onDraggingRowChange) !== null && _2 !== void 0 ? _2 : setDraggingRow;
1946
1951
  table.setEditingCell =
1947
- (_2 = statefulTableOptions.onEditingCellChange) !== null && _2 !== void 0 ? _2 : setEditingCell;
1952
+ (_3 = statefulTableOptions.onEditingCellChange) !== null && _3 !== void 0 ? _3 : setEditingCell;
1948
1953
  table.setEditingRow =
1949
- (_3 = statefulTableOptions.onEditingRowChange) !== null && _3 !== void 0 ? _3 : setEditingRow;
1954
+ (_4 = statefulTableOptions.onEditingRowChange) !== null && _4 !== void 0 ? _4 : setEditingRow;
1950
1955
  table.setGlobalFilterFn =
1951
- (_4 = statefulTableOptions.onGlobalFilterFnChange) !== null && _4 !== void 0 ? _4 : setGlobalFilterFn;
1956
+ (_5 = statefulTableOptions.onGlobalFilterFnChange) !== null && _5 !== void 0 ? _5 : setGlobalFilterFn;
1952
1957
  table.setHoveredColumn =
1953
- (_5 = statefulTableOptions.onHoveredColumnChange) !== null && _5 !== void 0 ? _5 : setHoveredColumn;
1958
+ (_6 = statefulTableOptions.onHoveredColumnChange) !== null && _6 !== void 0 ? _6 : setHoveredColumn;
1954
1959
  table.setHoveredRow =
1955
- (_6 = statefulTableOptions.onHoveredRowChange) !== null && _6 !== void 0 ? _6 : setHoveredRow;
1960
+ (_7 = statefulTableOptions.onHoveredRowChange) !== null && _7 !== void 0 ? _7 : setHoveredRow;
1956
1961
  table.setIsFullScreen =
1957
- (_7 = statefulTableOptions.onIsFullScreenChange) !== null && _7 !== void 0 ? _7 : setIsFullScreen;
1962
+ (_8 = statefulTableOptions.onIsFullScreenChange) !== null && _8 !== void 0 ? _8 : setIsFullScreen;
1958
1963
  table.setEnableKeyboardShortcuts =
1959
- (_8 = statefulTableOptions.onEnableKeyboardShortcutsChange) !== null && _8 !== void 0 ? _8 : setEnableKeyboardShortcuts;
1964
+ (_9 = statefulTableOptions.onEnableKeyboardShortcutsChange) !== null && _9 !== void 0 ? _9 : setEnableKeyboardShortcuts;
1960
1965
  table.setShowAlertBanner =
1961
- (_9 = statefulTableOptions.onShowAlertBannerChange) !== null && _9 !== void 0 ? _9 : setShowAlertBanner;
1966
+ (_10 = statefulTableOptions.onShowAlertBannerChange) !== null && _10 !== void 0 ? _10 : setShowAlertBanner;
1962
1967
  table.setShowColumnFilters =
1963
- (_10 = statefulTableOptions.onShowColumnFiltersChange) !== null && _10 !== void 0 ? _10 : setShowColumnFilters;
1968
+ (_11 = statefulTableOptions.onShowColumnFiltersChange) !== null && _11 !== void 0 ? _11 : setShowColumnFilters;
1969
+ table.setShowToolBar =
1970
+ (_12 = statefulTableOptions.onShowToolBarChange) !== null && _12 !== void 0 ? _12 : setShowToolBar;
1964
1971
  table.setShowGlobalFilter =
1965
- (_11 = statefulTableOptions.onShowGlobalFilterChange) !== null && _11 !== void 0 ? _11 : setShowGlobalFilter;
1972
+ (_13 = statefulTableOptions.onShowGlobalFilterChange) !== null && _13 !== void 0 ? _13 : setShowGlobalFilter;
1966
1973
  table.setShowToolbarDropZone =
1967
- (_12 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _12 !== void 0 ? _12 : setShowToolbarDropZone;
1974
+ (_14 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _14 !== void 0 ? _14 : setShowToolbarDropZone;
1968
1975
  useMRT_Effects(table);
1969
1976
  return table;
1970
1977
  };
@@ -2985,10 +2992,10 @@ const MRT_FilterOptionMenu = (_a) => {
2985
2992
  const MRT_ColumnActionMenu = (_a) => {
2986
2993
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
2987
2994
  var { anchorEl, header, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "header", "setAnchorEl", "table"]);
2988
- 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;
2995
+ const { getAllLeafColumns, getState, options: { columnFilterDisplayMode, columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnPinning, enableColumnResizing, enableGrouping, enableHiding, enableSorting, enableSortingRemoval, icons: { ClearAllIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, RestartAltIcon, SortIcon, ViewColumnIcon, VisibilityOffIcon, SettingsOutlinedIcon }, localization, mrtTheme: { menuBackgroundColor }, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnFilterFns, setColumnOrder, setColumnSizingInfo, setShowColumnFilters, } = table;
2989
2996
  const { column } = header;
2990
2997
  const { columnDef } = column;
2991
- const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
2998
+ const { columnSizing, columnVisibility, density, showColumnFilters, showToolBar } = getState();
2992
2999
  const columnFilterValue = column.getFilterValue();
2993
3000
  const [filterMenuAnchorEl, setFilterMenuAnchorEl] = react.useState(null);
2994
3001
  const handleClearSort = () => {
@@ -3096,6 +3103,11 @@ const MRT_ColumnActionMenu = (_a) => {
3096
3103
  .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
3104
  ]
3098
3105
  : []),
3106
+ // **Newly Added Menu Item for Toolbar Visibility**
3107
+ jsxRuntime.jsx(MRT_ActionMenuItem, { icon: jsxRuntime.jsx(SettingsOutlinedIcon, {}), label: showToolBar ? "Hide ToolBar" : "Show ToolBar", onClick: (e) => {
3108
+ e.stopPropagation();
3109
+ table.setShowToolBar(!showToolBar);
3110
+ }, table: table }, 13),
3099
3111
  ].filter(Boolean);
3100
3112
  return (jsxRuntime.jsx(Menu__default["default"], Object.assign({ MenuListProps: {
3101
3113
  dense: density === 'compact',
@@ -3219,19 +3231,7 @@ const MRT_FilterTextField = (_a) => {
3219
3231
  });
3220
3232
  }
3221
3233
  else {
3222
- if (textFieldProps.type === "number") {
3223
- // column.setFilterValue(newValue === '' ? undefined : newValue);
3224
- debugger;
3225
- if (newValue === 0) {
3226
- column.setFilterValue("0");
3227
- }
3228
- else {
3229
- column.setFilterValue(newValue);
3230
- }
3231
- }
3232
- else {
3233
- column.setFilterValue(newValue !== null && newValue !== void 0 ? newValue : undefined);
3234
- }
3234
+ column.setFilterValue(newValue !== null && newValue !== void 0 ? newValue : undefined);
3235
3235
  }
3236
3236
  }, isTextboxFilter ? (manualFiltering ? 400 : 200) : 1), []);
3237
3237
  const handleChange = (newValue) => {
@@ -3269,6 +3269,8 @@ const MRT_FilterTextField = (_a) => {
3269
3269
  setFilterValue('');
3270
3270
  column.setFilterValue(undefined);
3271
3271
  }
3272
+ // focus on the input after clearing the filter
3273
+ // filterInputRefs.current[`${column.id}-${rangeFilterIndex ?? 0}`]?.focus();
3272
3274
  };
3273
3275
  const handleClearEmptyFilterChip = () => {
3274
3276
  setFilterValue('');
@@ -3647,7 +3649,7 @@ const MRT_TableHeadCell = (_a) => {
3647
3649
  const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning,
3648
3650
  // enableKeyboardShortcuts,
3649
3651
  enableGrouping, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
3650
- const { enableKeyboardShortcuts, columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
3652
+ const { enableKeyboardShortcuts, columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, showToolBar, } = getState();
3651
3653
  const { column } = header;
3652
3654
  const { columnDef } = column;
3653
3655
  const { columnDefType } = columnDef;