material-react-table-narender 2.13.11 → 2.13.13
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 +36 -22
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +36 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/hooks/useMRT_TableInstance.ts +11 -0
- package/src/types.ts +3 -0
- package/src/utils/cell.utils.ts +14 -0
package/dist/index.js
CHANGED
@@ -528,6 +528,13 @@ 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
|
+
const { getState, setEnableKeyboardShortcuts, } = table;
|
532
|
+
const { enableKeyboardShortcuts } = getState();
|
533
|
+
if (event.altKey && event.key.toLowerCase() === 'n') {
|
534
|
+
event.preventDefault();
|
535
|
+
setEnableKeyboardShortcuts(!enableKeyboardShortcuts);
|
536
|
+
return;
|
537
|
+
}
|
531
538
|
if (!table.options.enableKeyboardShortcuts)
|
532
539
|
return;
|
533
540
|
if (event.isPropagationStopped())
|
@@ -1741,7 +1748,7 @@ const useMRT_Effects = (table) => {
|
|
1741
1748
|
* @returns the MRT table instance
|
1742
1749
|
*/
|
1743
1750
|
const useMRT_TableInstance = (definedTableOptions) => {
|
1744
|
-
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;
|
1745
1752
|
const lastSelectedRowId = react.useRef(null);
|
1746
1753
|
const actionCellRef = react.useRef(null);
|
1747
1754
|
const bottomToolbarRef = react.useRef(null);
|
@@ -1786,11 +1793,15 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1786
1793
|
const [hoveredColumn, setHoveredColumn] = react.useState((_m = initialState.hoveredColumn) !== null && _m !== void 0 ? _m : null);
|
1787
1794
|
const [hoveredRow, setHoveredRow] = react.useState((_o = initialState.hoveredRow) !== null && _o !== void 0 ? _o : null);
|
1788
1795
|
const [isFullScreen, setIsFullScreen] = react.useState((_p = initialState === null || initialState === void 0 ? void 0 : initialState.isFullScreen) !== null && _p !== void 0 ? _p : false);
|
1789
|
-
const [
|
1790
|
-
const [
|
1791
|
-
|
1792
|
-
|
1793
|
-
const [
|
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);
|
1794
1805
|
definedTableOptions.state = Object.assign({ actionCell,
|
1795
1806
|
columnFilterFns,
|
1796
1807
|
columnOrder,
|
@@ -1806,6 +1817,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1806
1817
|
hoveredColumn,
|
1807
1818
|
hoveredRow,
|
1808
1819
|
isFullScreen,
|
1820
|
+
enableKeyboardShortcuts,
|
1809
1821
|
pagination,
|
1810
1822
|
showAlertBanner,
|
1811
1823
|
showColumnFilters,
|
@@ -1863,7 +1875,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1863
1875
|
const table = reactTable.useReactTable(Object.assign(Object.assign({ onColumnOrderChange,
|
1864
1876
|
onColumnSizingInfoChange,
|
1865
1877
|
onGroupingChange,
|
1866
|
-
onPaginationChange }, statefulTableOptions), { globalFilterFn: (
|
1878
|
+
onPaginationChange }, statefulTableOptions), { globalFilterFn: (_w = statefulTableOptions.filterFns) === null || _w === void 0 ? void 0 : _w[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
|
1867
1879
|
table.refs = {
|
1868
1880
|
actionCellRef,
|
1869
1881
|
bottomToolbarRef,
|
@@ -1879,7 +1891,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1879
1891
|
topToolbarRef,
|
1880
1892
|
};
|
1881
1893
|
table.setActionCell =
|
1882
|
-
(
|
1894
|
+
(_x = statefulTableOptions.onActionCellChange) !== null && _x !== void 0 ? _x : setActionCell;
|
1883
1895
|
table.setCreatingRow = (row) => {
|
1884
1896
|
var _a, _b;
|
1885
1897
|
let _row = row;
|
@@ -1889,32 +1901,34 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
1889
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);
|
1890
1902
|
};
|
1891
1903
|
table.setColumnFilterFns =
|
1892
|
-
(
|
1893
|
-
table.setDensity = (
|
1904
|
+
(_y = statefulTableOptions.onColumnFilterFnsChange) !== null && _y !== void 0 ? _y : setColumnFilterFns;
|
1905
|
+
table.setDensity = (_z = statefulTableOptions.onDensityChange) !== null && _z !== void 0 ? _z : setDensity;
|
1894
1906
|
table.setDraggingColumn =
|
1895
|
-
(
|
1907
|
+
(_0 = statefulTableOptions.onDraggingColumnChange) !== null && _0 !== void 0 ? _0 : setDraggingColumn;
|
1896
1908
|
table.setDraggingRow =
|
1897
|
-
(
|
1909
|
+
(_1 = statefulTableOptions.onDraggingRowChange) !== null && _1 !== void 0 ? _1 : setDraggingRow;
|
1898
1910
|
table.setEditingCell =
|
1899
|
-
(
|
1911
|
+
(_2 = statefulTableOptions.onEditingCellChange) !== null && _2 !== void 0 ? _2 : setEditingCell;
|
1900
1912
|
table.setEditingRow =
|
1901
|
-
(
|
1913
|
+
(_3 = statefulTableOptions.onEditingRowChange) !== null && _3 !== void 0 ? _3 : setEditingRow;
|
1902
1914
|
table.setGlobalFilterFn =
|
1903
|
-
(
|
1915
|
+
(_4 = statefulTableOptions.onGlobalFilterFnChange) !== null && _4 !== void 0 ? _4 : setGlobalFilterFn;
|
1904
1916
|
table.setHoveredColumn =
|
1905
|
-
(
|
1917
|
+
(_5 = statefulTableOptions.onHoveredColumnChange) !== null && _5 !== void 0 ? _5 : setHoveredColumn;
|
1906
1918
|
table.setHoveredRow =
|
1907
|
-
(
|
1919
|
+
(_6 = statefulTableOptions.onHoveredRowChange) !== null && _6 !== void 0 ? _6 : setHoveredRow;
|
1908
1920
|
table.setIsFullScreen =
|
1909
|
-
(
|
1921
|
+
(_7 = statefulTableOptions.onIsFullScreenChange) !== null && _7 !== void 0 ? _7 : setIsFullScreen;
|
1922
|
+
table.setEnableKeyboardShortcuts =
|
1923
|
+
(_8 = statefulTableOptions.onEnableKeyboardShortcutsChange) !== null && _8 !== void 0 ? _8 : setEnableKeyboardShortcuts;
|
1910
1924
|
table.setShowAlertBanner =
|
1911
|
-
(
|
1925
|
+
(_9 = statefulTableOptions.onShowAlertBannerChange) !== null && _9 !== void 0 ? _9 : setShowAlertBanner;
|
1912
1926
|
table.setShowColumnFilters =
|
1913
|
-
(
|
1927
|
+
(_10 = statefulTableOptions.onShowColumnFiltersChange) !== null && _10 !== void 0 ? _10 : setShowColumnFilters;
|
1914
1928
|
table.setShowGlobalFilter =
|
1915
|
-
(
|
1929
|
+
(_11 = statefulTableOptions.onShowGlobalFilterChange) !== null && _11 !== void 0 ? _11 : setShowGlobalFilter;
|
1916
1930
|
table.setShowToolbarDropZone =
|
1917
|
-
(
|
1931
|
+
(_12 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _12 !== void 0 ? _12 : setShowToolbarDropZone;
|
1918
1932
|
useMRT_Effects(table);
|
1919
1933
|
return table;
|
1920
1934
|
};
|