material-react-table 0.40.4 → 0.40.5
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/cjs/MaterialReactTable.d.ts +12 -2
- package/dist/cjs/index.js +45 -40
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/MaterialReactTable.d.ts +12 -2
- package/dist/esm/material-react-table.esm.js +45 -40
- package/dist/esm/material-react-table.esm.js.map +1 -1
- package/dist/index.d.ts +12 -2
- package/package.json +1 -1
- package/src/MaterialReactTable.tsx +20 -2
- package/src/body/MRT_TableBody.tsx +9 -7
- package/src/menus/MRT_ColumnActionMenu.tsx +63 -50
- package/src/table/MRT_TableRoot.tsx +4 -6
|
@@ -216,12 +216,17 @@ export declare type MRT_ColumnDef<TData extends Record<string, any> = {}> = Omit
|
|
|
216
216
|
table: MRT_TableInstance<TData>;
|
|
217
217
|
column: MRT_Column<TData>;
|
|
218
218
|
}) => TableCellProps);
|
|
219
|
+
renderColumnActionsMenuItems?: ({ closeMenu, column, table, }: {
|
|
220
|
+
closeMenu: () => void;
|
|
221
|
+
column: MRT_Column<TData>;
|
|
222
|
+
table: MRT_TableInstance<TData>;
|
|
223
|
+
}) => ReactNode[];
|
|
219
224
|
renderColumnFilterModeMenuItems?: ({ column, internalFilterOptions, onSelectFilterMode, table, }: {
|
|
220
225
|
column: MRT_Column<TData>;
|
|
221
226
|
internalFilterOptions: MRT_InternalFilterOption[];
|
|
222
227
|
onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
|
|
223
228
|
table: MRT_TableInstance<TData>;
|
|
224
|
-
}) => ReactNode;
|
|
229
|
+
}) => ReactNode[];
|
|
225
230
|
sortingFn?: MRT_SortingFn;
|
|
226
231
|
};
|
|
227
232
|
export declare type MRT_DefinedColumnDef<TData extends Record<string, any> = {}> = Omit<MRT_ColumnDef<TData>, 'id'> & {
|
|
@@ -472,12 +477,17 @@ export declare type MaterialReactTableProps<TData extends Record<string, any> =
|
|
|
472
477
|
renderBottomToolbarCustomActions?: ({ table, }: {
|
|
473
478
|
table: MRT_TableInstance<TData>;
|
|
474
479
|
}) => ReactNode;
|
|
480
|
+
renderColumnActionsMenuItems?: ({ column, closeMenu, table, }: {
|
|
481
|
+
column: MRT_Column<TData>;
|
|
482
|
+
closeMenu: () => void;
|
|
483
|
+
table: MRT_TableInstance<TData>;
|
|
484
|
+
}) => ReactNode[];
|
|
475
485
|
renderColumnFilterModeMenuItems?: ({ column, internalFilterOptions, onSelectFilterMode, table, }: {
|
|
476
486
|
column: MRT_Column<TData>;
|
|
477
487
|
internalFilterOptions: MRT_InternalFilterOption[];
|
|
478
488
|
onSelectFilterMode: (filterMode: MRT_FilterOption) => void;
|
|
479
489
|
table: MRT_TableInstance<TData>;
|
|
480
|
-
}) => ReactNode;
|
|
490
|
+
}) => ReactNode[];
|
|
481
491
|
renderDetailPanel?: ({ row, table, }: {
|
|
482
492
|
row: MRT_Row<TData>;
|
|
483
493
|
table: MRT_TableInstance<TData>;
|
|
@@ -728,8 +728,8 @@ const commonListItemStyles = {
|
|
|
728
728
|
alignItems: 'center',
|
|
729
729
|
};
|
|
730
730
|
const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
731
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
732
|
-
const { getState, toggleAllColumnsVisible, setColumnOrder, options: { enableColumnFilterModes, enableColumnFilters, enableColumnResizing, enableGrouping, enableHiding, enablePinning, enableSorting,
|
|
731
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
732
|
+
const { getState, toggleAllColumnsVisible, setColumnOrder, options: { columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnResizing, enableGrouping, enableHiding, enablePinning, enableSorting, icons: { ArrowRightIcon, ClearAllIcon, ViewColumnIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, SortIcon, RestartAltIcon, VisibilityOffIcon, }, localization, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setShowFilters, } = table;
|
|
733
733
|
const { column } = header;
|
|
734
734
|
const { columnDef } = column;
|
|
735
735
|
const { columnSizing, columnVisibility, density } = getState();
|
|
@@ -794,25 +794,32 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
|
794
794
|
!!(allowedColumnFilterOptions === null || allowedColumnFilterOptions === void 0 ? void 0 : allowedColumnFilterOptions.length));
|
|
795
795
|
return (React.createElement(Menu, { anchorEl: anchorEl, open: !!anchorEl, onClose: () => setAnchorEl(null), MenuListProps: {
|
|
796
796
|
dense: density === 'compact',
|
|
797
|
-
} },
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
797
|
+
} }, (_d = (_c = (_b = columnDef.renderColumnActionsMenuItems) === null || _b === void 0 ? void 0 : _b.call(columnDef, {
|
|
798
|
+
closeMenu: () => setAnchorEl(null),
|
|
799
|
+
column,
|
|
800
|
+
table,
|
|
801
|
+
})) !== null && _c !== void 0 ? _c : renderColumnActionsMenuItems === null || renderColumnActionsMenuItems === void 0 ? void 0 : renderColumnActionsMenuItems({
|
|
802
|
+
closeMenu: () => setAnchorEl(null),
|
|
803
|
+
column,
|
|
804
|
+
table,
|
|
805
|
+
})) !== null && _d !== void 0 ? _d : (enableSorting &&
|
|
806
|
+
column.getCanSort() && [
|
|
807
|
+
React.createElement(MenuItem, { disabled: !column.getIsSorted(), key: 0, onClick: handleClearSort, sx: commonMenuItemStyles },
|
|
808
|
+
React.createElement(Box, { sx: commonListItemStyles },
|
|
809
|
+
React.createElement(ListItemIcon, null,
|
|
810
|
+
React.createElement(ClearAllIcon, null)),
|
|
811
|
+
localization.clearSort)),
|
|
812
|
+
React.createElement(MenuItem, { disabled: column.getIsSorted() === 'asc', key: 1, onClick: handleSortAsc, sx: commonMenuItemStyles },
|
|
813
|
+
React.createElement(Box, { sx: commonListItemStyles },
|
|
814
|
+
React.createElement(ListItemIcon, null,
|
|
815
|
+
React.createElement(SortIcon, { style: { transform: 'rotate(180deg) scaleX(-1)' } })), (_e = localization.sortByColumnAsc) === null || _e === void 0 ? void 0 :
|
|
816
|
+
_e.replace('{column}', String(columnDef.header)))),
|
|
817
|
+
React.createElement(MenuItem, { divider: enableColumnFilters || enableGrouping || enableHiding, key: 2, disabled: column.getIsSorted() === 'desc', onClick: handleSortDesc, sx: commonMenuItemStyles },
|
|
818
|
+
React.createElement(Box, { sx: commonListItemStyles },
|
|
819
|
+
React.createElement(ListItemIcon, null,
|
|
820
|
+
React.createElement(SortIcon, null)), (_f = localization.sortByColumnDesc) === null || _f === void 0 ? void 0 :
|
|
821
|
+
_f.replace('{column}', String(columnDef.header)))),
|
|
822
|
+
]),
|
|
816
823
|
enableColumnFilters &&
|
|
817
824
|
column.getCanFilter() &&
|
|
818
825
|
[
|
|
@@ -824,8 +831,8 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
|
824
831
|
React.createElement(MenuItem, { divider: enableGrouping || enableHiding, key: 1, onClick: handleFilterByColumn, sx: commonMenuItemStyles },
|
|
825
832
|
React.createElement(Box, { sx: commonListItemStyles },
|
|
826
833
|
React.createElement(ListItemIcon, null,
|
|
827
|
-
React.createElement(FilterListIcon, null)), (
|
|
828
|
-
|
|
834
|
+
React.createElement(FilterListIcon, null)), (_g = localization.filterByColumn) === null || _g === void 0 ? void 0 :
|
|
835
|
+
_g.replace('{column}', String(columnDef.header))),
|
|
829
836
|
showFilterModeSubMenu && (React.createElement(IconButton, { onClick: handleOpenFilterModeMenu, onMouseEnter: handleOpenFilterModeMenu, size: "small", sx: { p: 0 } },
|
|
830
837
|
React.createElement(ArrowRightIcon, null)))),
|
|
831
838
|
showFilterModeSubMenu && (React.createElement(MRT_FilterOptionMenu, { anchorEl: filterMenuAnchorEl, header: header, key: 2, onSelect: handleFilterByColumn, setAnchorEl: setFilterMenuAnchorEl, table: table })),
|
|
@@ -835,8 +842,8 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
|
835
842
|
React.createElement(MenuItem, { divider: enablePinning, key: 0, onClick: handleGroupByColumn, sx: commonMenuItemStyles },
|
|
836
843
|
React.createElement(Box, { sx: commonListItemStyles },
|
|
837
844
|
React.createElement(ListItemIcon, null,
|
|
838
|
-
React.createElement(DynamicFeedIcon, null)), (
|
|
839
|
-
|
|
845
|
+
React.createElement(DynamicFeedIcon, null)), (_h = localization[column.getIsGrouped() ? 'ungroupByColumn' : 'groupByColumn']) === null || _h === void 0 ? void 0 :
|
|
846
|
+
_h.replace('{column}', String(columnDef.header)))),
|
|
840
847
|
],
|
|
841
848
|
enablePinning &&
|
|
842
849
|
column.getCanPin() && [
|
|
@@ -868,14 +875,14 @@ const MRT_ColumnActionMenu = ({ anchorEl, header, setAnchorEl, table, }) => {
|
|
|
868
875
|
React.createElement(MenuItem, { disabled: columnDef.enableHiding === false, key: 0, onClick: handleHideColumn, sx: commonMenuItemStyles },
|
|
869
876
|
React.createElement(Box, { sx: commonListItemStyles },
|
|
870
877
|
React.createElement(ListItemIcon, null,
|
|
871
|
-
React.createElement(VisibilityOffIcon, null)), (
|
|
872
|
-
|
|
878
|
+
React.createElement(VisibilityOffIcon, null)), (_j = localization.hideColumn) === null || _j === void 0 ? void 0 :
|
|
879
|
+
_j.replace('{column}', String(columnDef.header)))),
|
|
873
880
|
React.createElement(MenuItem, { disabled: !Object.values(columnVisibility).filter((visible) => !visible)
|
|
874
881
|
.length, key: 1, onClick: handleShowAllColumns, sx: commonMenuItemStyles },
|
|
875
882
|
React.createElement(Box, { sx: commonListItemStyles },
|
|
876
883
|
React.createElement(ListItemIcon, null,
|
|
877
|
-
React.createElement(ViewColumnIcon, null)), (
|
|
878
|
-
|
|
884
|
+
React.createElement(ViewColumnIcon, null)), (_k = localization.showAllColumns) === null || _k === void 0 ? void 0 :
|
|
885
|
+
_k.replace('{column}', String(columnDef.header))),
|
|
879
886
|
React.createElement(IconButton, { onClick: handleOpenShowHideColumnsMenu, onMouseEnter: handleOpenShowHideColumnsMenu, size: "small", sx: { p: 0 } },
|
|
880
887
|
React.createElement(ArrowRightIcon, null))),
|
|
881
888
|
React.createElement(MRT_ShowHideColumnsMenu, { anchorEl: showHideColumnsMenuAnchorEl, isSubMenu: true, key: 2, setAnchorEl: setShowHideColumnsMenuAnchorEl, table: table }),
|
|
@@ -2127,7 +2134,7 @@ const MRT_TableBodyRow = ({ row, rowIndex, table, virtualRow, }) => {
|
|
|
2127
2134
|
};
|
|
2128
2135
|
|
|
2129
2136
|
const MRT_TableBody = ({ table, tableContainerRef }) => {
|
|
2130
|
-
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization,
|
|
2137
|
+
const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, manualFiltering, manualSorting, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, } = table;
|
|
2131
2138
|
const { globalFilter, pagination, sorting } = getState();
|
|
2132
2139
|
const tableBodyProps = muiTableBodyProps instanceof Function
|
|
2133
2140
|
? muiTableBodyProps({ table })
|
|
@@ -2138,6 +2145,8 @@ const MRT_TableBody = ({ table, tableContainerRef }) => {
|
|
|
2138
2145
|
const rows = useMemo(() => {
|
|
2139
2146
|
if (enableGlobalFilterRankedResults &&
|
|
2140
2147
|
globalFilter &&
|
|
2148
|
+
!manualFiltering &&
|
|
2149
|
+
!manualSorting &&
|
|
2141
2150
|
!Object.values(sorting).some(Boolean)) {
|
|
2142
2151
|
const rankedRows = getPrePaginationRowModel().rows.sort((a, b) => rankGlobalFuzzy(a, b));
|
|
2143
2152
|
if (enablePagination) {
|
|
@@ -2158,11 +2167,9 @@ const MRT_TableBody = ({ table, tableContainerRef }) => {
|
|
|
2158
2167
|
const virtualizer = enableRowVirtualization
|
|
2159
2168
|
? useVirtual(Object.assign({ size: rows.length, parentRef: tableContainerRef, overscan: 15 }, vProps))
|
|
2160
2169
|
: {};
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
}
|
|
2165
|
-
}, [virtualizer]);
|
|
2170
|
+
if (virtualizerInstanceRef) {
|
|
2171
|
+
virtualizerInstanceRef.current = virtualizer;
|
|
2172
|
+
}
|
|
2166
2173
|
// const virtualizer: Virtualizer = enableRowVirtualization
|
|
2167
2174
|
// ? useVirtualizer({
|
|
2168
2175
|
// count: rows.length,
|
|
@@ -2469,11 +2476,9 @@ const MRT_TableRoot = (props) => {
|
|
|
2469
2476
|
tableContainerRef,
|
|
2470
2477
|
topToolbarRef,
|
|
2471
2478
|
}, setColumnFilterFns: (_w = props.onFilterFnsChange) !== null && _w !== void 0 ? _w : setColumnFilterFns, setDensity: (_x = props.onDensityChange) !== null && _x !== void 0 ? _x : setDensity, setDraggingColumn: (_y = props.onDraggingColumnChange) !== null && _y !== void 0 ? _y : setDraggingColumn, setDraggingRow: (_z = props.onDraggingRowChange) !== null && _z !== void 0 ? _z : setDraggingRow, setEditingCell: (_0 = props.onEditingCellChange) !== null && _0 !== void 0 ? _0 : setEditingCell, setEditingRow: (_1 = props.onEditingRowChange) !== null && _1 !== void 0 ? _1 : setEditingRow, setGlobalFilterFn: (_2 = props.onGlobalFilterFnChange) !== null && _2 !== void 0 ? _2 : setGlobalFilterFn, setHoveredColumn: (_3 = props.onHoveredColumnChange) !== null && _3 !== void 0 ? _3 : setHoveredColumn, setHoveredRow: (_4 = props.onHoveredRowChange) !== null && _4 !== void 0 ? _4 : setHoveredRow, setIsFullScreen: (_5 = props.onIsFullScreenChange) !== null && _5 !== void 0 ? _5 : setIsFullScreen, setShowAlertBanner: (_6 = props.onShowAlertBannerChange) !== null && _6 !== void 0 ? _6 : setShowAlertBanner, setShowFilters: (_7 = props.onShowFiltersChange) !== null && _7 !== void 0 ? _7 : setShowFilters, setShowGlobalFilter: (_8 = props.onShowGlobalFilterChange) !== null && _8 !== void 0 ? _8 : setShowGlobalFilter });
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
}
|
|
2476
|
-
}, [table]);
|
|
2479
|
+
if (props.tableInstanceRef) {
|
|
2480
|
+
props.tableInstanceRef.current = table;
|
|
2481
|
+
}
|
|
2477
2482
|
return (React.createElement(React.Fragment, null,
|
|
2478
2483
|
React.createElement(Dialog, { PaperComponent: Box, TransitionComponent: Grow, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => setIsFullScreen(false), open: isFullScreen, transitionDuration: 400 },
|
|
2479
2484
|
React.createElement(MRT_TablePaper, { table: table })),
|