material-react-table-narender 2.13.27 → 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 +3 -0
- package/dist/index.esm.js +54 -37
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +53 -36
- package/dist/index.js.map +1 -1
- package/package.json +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 -11
- package/src/components/menus/MRT_ColumnActionMenu.tsx +14 -1
- package/src/hooks/useMRT_TableInstance.ts +8 -0
- package/src/types.ts +3 -0
package/dist/index.js
CHANGED
@@ -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
|
};
|
@@ -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',
|
@@ -3219,19 +3228,7 @@ const MRT_FilterTextField = (_a) => {
|
|
3219
3228
|
});
|
3220
3229
|
}
|
3221
3230
|
else {
|
3222
|
-
|
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
|
-
}
|
3231
|
+
column.setFilterValue(newValue !== null && newValue !== void 0 ? newValue : undefined);
|
3235
3232
|
}
|
3236
3233
|
}, isTextboxFilter ? (manualFiltering ? 400 : 200) : 1), []);
|
3237
3234
|
const handleChange = (newValue) => {
|
@@ -3269,6 +3266,8 @@ const MRT_FilterTextField = (_a) => {
|
|
3269
3266
|
setFilterValue('');
|
3270
3267
|
column.setFilterValue(undefined);
|
3271
3268
|
}
|
3269
|
+
// focus on the input after clearing the filter
|
3270
|
+
// filterInputRefs.current[`${column.id}-${rangeFilterIndex ?? 0}`]?.focus();
|
3272
3271
|
};
|
3273
3272
|
const handleClearEmptyFilterChip = () => {
|
3274
3273
|
setFilterValue('');
|
@@ -3640,6 +3639,24 @@ const MRT_TableHeadCellSortLabel = (_a) => {
|
|
3640
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))) })) }) }));
|
3641
3640
|
};
|
3642
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
|
+
|
3643
3660
|
const MRT_TableHeadCell = (_a) => {
|
3644
3661
|
var _b, _c, _d, _f, _g, _h;
|
3645
3662
|
var { columnVirtualizer, header, staticColumnIndex, table } = _a, rest = __rest(_a, ["columnVirtualizer", "header", "staticColumnIndex", "table"]);
|
@@ -3647,7 +3664,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3647
3664
|
const { getState, options: { columnFilterDisplayMode, columnResizeDirection, columnResizeMode, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning,
|
3648
3665
|
// enableKeyboardShortcuts,
|
3649
3666
|
enableGrouping, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
|
3650
|
-
const { enableKeyboardShortcuts, columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
|
3667
|
+
const { enableKeyboardShortcuts, columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, showToolBar, } = getState();
|
3651
3668
|
const { column } = header;
|
3652
3669
|
const { columnDef } = column;
|
3653
3670
|
const { columnDefType } = columnDef;
|
@@ -3807,7 +3824,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
3807
3824
|
whiteSpace: ((_h = (_g = columnDef.header) === null || _g === void 0 ? void 0 : _g.length) !== null && _h !== void 0 ? _h : 0) < 20
|
3808
3825
|
? 'nowrap'
|
3809
3826
|
: 'normal',
|
3810
|
-
}, 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: {
|
3811
3828
|
whiteSpace: 'nowrap',
|
3812
3829
|
}, children: [showDragHandle && (jsxRuntime.jsx(MRT_TableHeadCellGrabHandle, { column: column, table: table, tableHeadCellRef: {
|
3813
3830
|
current: tableHeadCellRefs.current[column.id],
|