material-react-table-narender 2.13.12 → 2.13.14

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -528,9 +528,11 @@ const openEditingCell = ({ cell, table, }) => {
528
528
  const cellKeyboardShortcuts = ({ cell, cellElements, cellValue, containerElement, event, header, parentElement, table, }) => {
529
529
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
530
530
  debugger;
531
- if (event.altKey && event.key.toLowerCase() === 'n') {
531
+ const { getState, setEnableKeyboardShortcuts, } = table;
532
+ const { enableKeyboardShortcuts } = getState();
533
+ if (event.altKey) {
532
534
  event.preventDefault();
533
- table.options.enableKeyboardShortcuts = !table.options.enableKeyboardShortcuts;
535
+ setEnableKeyboardShortcuts(!enableKeyboardShortcuts);
534
536
  return;
535
537
  }
536
538
  if (!table.options.enableKeyboardShortcuts)
@@ -1746,7 +1748,7 @@ const useMRT_Effects = (table) => {
1746
1748
  * @returns the MRT table instance
1747
1749
  */
1748
1750
  const useMRT_TableInstance = (definedTableOptions) => {
1749
- 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;
1751
+ 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;
1750
1752
  const lastSelectedRowId = react.useRef(null);
1751
1753
  const actionCellRef = react.useRef(null);
1752
1754
  const bottomToolbarRef = react.useRef(null);
@@ -1791,11 +1793,15 @@ const useMRT_TableInstance = (definedTableOptions) => {
1791
1793
  const [hoveredColumn, setHoveredColumn] = react.useState((_m = initialState.hoveredColumn) !== null && _m !== void 0 ? _m : null);
1792
1794
  const [hoveredRow, setHoveredRow] = react.useState((_o = initialState.hoveredRow) !== null && _o !== void 0 ? _o : null);
1793
1795
  const [isFullScreen, setIsFullScreen] = react.useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _p !== void 0 ? _p : false);
1794
- const [pagination, onPaginationChange] = react.useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) !== null && _q !== void 0 ? _q : { pageIndex: 0, pageSize: 10 });
1795
- const [showAlertBanner, setShowAlertBanner] = react.useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _r !== void 0 ? _r : false);
1796
- const [showColumnFilters, setShowColumnFilters] = react.useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _s !== void 0 ? _s : false);
1797
- const [showGlobalFilter, setShowGlobalFilter] = react.useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _t !== void 0 ? _t : false);
1798
- const [showToolbarDropZone, setShowToolbarDropZone] = react.useState((_u = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _u !== void 0 ? _u : false);
1796
+ const [enableKeyboardShortcuts, setEnableKeyboardShortcuts] = react.useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.enableKeyboardShortcuts) !== null && _q !== void 0 ? _q : false);
1797
+ // const [isFullScreen, setIsFullScreen] = useState<boolean>(
1798
+ // initialState?.isFullScreen ?? false,
1799
+ // );
1800
+ const [pagination, onPaginationChange] = react.useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) !== null && _r !== void 0 ? _r : { pageIndex: 0, pageSize: 10 });
1801
+ const [showAlertBanner, setShowAlertBanner] = react.useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _s !== void 0 ? _s : false);
1802
+ const [showColumnFilters, setShowColumnFilters] = react.useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _t !== void 0 ? _t : false);
1803
+ const [showGlobalFilter, setShowGlobalFilter] = react.useState((_u = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _u !== void 0 ? _u : false);
1804
+ const [showToolbarDropZone, setShowToolbarDropZone] = react.useState((_v = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _v !== void 0 ? _v : false);
1799
1805
  definedTableOptions.state = Object.assign({ actionCell,
1800
1806
  columnFilterFns,
1801
1807
  columnOrder,
@@ -1811,6 +1817,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
1811
1817
  hoveredColumn,
1812
1818
  hoveredRow,
1813
1819
  isFullScreen,
1820
+ enableKeyboardShortcuts,
1814
1821
  pagination,
1815
1822
  showAlertBanner,
1816
1823
  showColumnFilters,
@@ -1868,7 +1875,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
1868
1875
  const table = reactTable.useReactTable(Object.assign(Object.assign({ onColumnOrderChange,
1869
1876
  onColumnSizingInfoChange,
1870
1877
  onGroupingChange,
1871
- onPaginationChange }, statefulTableOptions), { globalFilterFn: (_v = statefulTableOptions.filterFns) === null || _v === void 0 ? void 0 : _v[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
1878
+ onPaginationChange }, statefulTableOptions), { globalFilterFn: (_w = statefulTableOptions.filterFns) === null || _w === void 0 ? void 0 : _w[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
1872
1879
  table.refs = {
1873
1880
  actionCellRef,
1874
1881
  bottomToolbarRef,
@@ -1884,7 +1891,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
1884
1891
  topToolbarRef,
1885
1892
  };
1886
1893
  table.setActionCell =
1887
- (_w = statefulTableOptions.onActionCellChange) !== null && _w !== void 0 ? _w : setActionCell;
1894
+ (_x = statefulTableOptions.onActionCellChange) !== null && _x !== void 0 ? _x : setActionCell;
1888
1895
  table.setCreatingRow = (row) => {
1889
1896
  var _a, _b;
1890
1897
  let _row = row;
@@ -1894,32 +1901,34 @@ const useMRT_TableInstance = (definedTableOptions) => {
1894
1901
  (_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);
1895
1902
  };
1896
1903
  table.setColumnFilterFns =
1897
- (_x = statefulTableOptions.onColumnFilterFnsChange) !== null && _x !== void 0 ? _x : setColumnFilterFns;
1898
- table.setDensity = (_y = statefulTableOptions.onDensityChange) !== null && _y !== void 0 ? _y : setDensity;
1904
+ (_y = statefulTableOptions.onColumnFilterFnsChange) !== null && _y !== void 0 ? _y : setColumnFilterFns;
1905
+ table.setDensity = (_z = statefulTableOptions.onDensityChange) !== null && _z !== void 0 ? _z : setDensity;
1899
1906
  table.setDraggingColumn =
1900
- (_z = statefulTableOptions.onDraggingColumnChange) !== null && _z !== void 0 ? _z : setDraggingColumn;
1907
+ (_0 = statefulTableOptions.onDraggingColumnChange) !== null && _0 !== void 0 ? _0 : setDraggingColumn;
1901
1908
  table.setDraggingRow =
1902
- (_0 = statefulTableOptions.onDraggingRowChange) !== null && _0 !== void 0 ? _0 : setDraggingRow;
1909
+ (_1 = statefulTableOptions.onDraggingRowChange) !== null && _1 !== void 0 ? _1 : setDraggingRow;
1903
1910
  table.setEditingCell =
1904
- (_1 = statefulTableOptions.onEditingCellChange) !== null && _1 !== void 0 ? _1 : setEditingCell;
1911
+ (_2 = statefulTableOptions.onEditingCellChange) !== null && _2 !== void 0 ? _2 : setEditingCell;
1905
1912
  table.setEditingRow =
1906
- (_2 = statefulTableOptions.onEditingRowChange) !== null && _2 !== void 0 ? _2 : setEditingRow;
1913
+ (_3 = statefulTableOptions.onEditingRowChange) !== null && _3 !== void 0 ? _3 : setEditingRow;
1907
1914
  table.setGlobalFilterFn =
1908
- (_3 = statefulTableOptions.onGlobalFilterFnChange) !== null && _3 !== void 0 ? _3 : setGlobalFilterFn;
1915
+ (_4 = statefulTableOptions.onGlobalFilterFnChange) !== null && _4 !== void 0 ? _4 : setGlobalFilterFn;
1909
1916
  table.setHoveredColumn =
1910
- (_4 = statefulTableOptions.onHoveredColumnChange) !== null && _4 !== void 0 ? _4 : setHoveredColumn;
1917
+ (_5 = statefulTableOptions.onHoveredColumnChange) !== null && _5 !== void 0 ? _5 : setHoveredColumn;
1911
1918
  table.setHoveredRow =
1912
- (_5 = statefulTableOptions.onHoveredRowChange) !== null && _5 !== void 0 ? _5 : setHoveredRow;
1919
+ (_6 = statefulTableOptions.onHoveredRowChange) !== null && _6 !== void 0 ? _6 : setHoveredRow;
1913
1920
  table.setIsFullScreen =
1914
- (_6 = statefulTableOptions.onIsFullScreenChange) !== null && _6 !== void 0 ? _6 : setIsFullScreen;
1921
+ (_7 = statefulTableOptions.onIsFullScreenChange) !== null && _7 !== void 0 ? _7 : setIsFullScreen;
1922
+ table.setEnableKeyboardShortcuts =
1923
+ (_8 = statefulTableOptions.onEnableKeyboardShortcutsChange) !== null && _8 !== void 0 ? _8 : setEnableKeyboardShortcuts;
1915
1924
  table.setShowAlertBanner =
1916
- (_7 = statefulTableOptions.onShowAlertBannerChange) !== null && _7 !== void 0 ? _7 : setShowAlertBanner;
1925
+ (_9 = statefulTableOptions.onShowAlertBannerChange) !== null && _9 !== void 0 ? _9 : setShowAlertBanner;
1917
1926
  table.setShowColumnFilters =
1918
- (_8 = statefulTableOptions.onShowColumnFiltersChange) !== null && _8 !== void 0 ? _8 : setShowColumnFilters;
1927
+ (_10 = statefulTableOptions.onShowColumnFiltersChange) !== null && _10 !== void 0 ? _10 : setShowColumnFilters;
1919
1928
  table.setShowGlobalFilter =
1920
- (_9 = statefulTableOptions.onShowGlobalFilterChange) !== null && _9 !== void 0 ? _9 : setShowGlobalFilter;
1929
+ (_11 = statefulTableOptions.onShowGlobalFilterChange) !== null && _11 !== void 0 ? _11 : setShowGlobalFilter;
1921
1930
  table.setShowToolbarDropZone =
1922
- (_10 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _10 !== void 0 ? _10 : setShowToolbarDropZone;
1931
+ (_12 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _12 !== void 0 ? _12 : setShowToolbarDropZone;
1923
1932
  useMRT_Effects(table);
1924
1933
  return table;
1925
1934
  };