material-react-table 3.0.0-beta.2 → 3.0.0
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 +4 -0
- package/dist/index.esm.js +38 -39
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +38 -38
- package/dist/index.js.map +1 -1
- package/locales/no/index.esm.js +1 -1
- package/locales/no/index.js +1 -1
- package/package.json +3 -3
- package/src/components/buttons/MRT_RowPinButton.tsx +2 -0
- package/src/components/buttons/MRT_ToggleFullScreenButton.tsx +2 -0
- package/src/components/table/MRT_TableLoadingOverlay.tsx +2 -1
- package/src/components/table/MRT_TablePaper.tsx +52 -48
- package/src/components/toolbar/MRT_TablePagination.tsx +4 -6
- package/src/hooks/useMRT_TableOptions.ts +3 -1
- package/src/locales/no.ts +2 -1
- package/src/types.ts +4 -0
package/dist/index.d.ts
CHANGED
@@ -818,6 +818,7 @@ interface MRT_TableOptions<TData extends MRT_RowData> extends Omit<Partial<Table
|
|
818
818
|
globalFilterFn?: MRT_FilterOption;
|
819
819
|
globalFilterModeOptions?: MRT_FilterOption[] | null;
|
820
820
|
icons?: Partial<MRT_Icons>;
|
821
|
+
id?: string;
|
821
822
|
initialState?: Partial<MRT_TableState<TData>>;
|
822
823
|
/**
|
823
824
|
* Changes which kind of CSS layout is used to render the table. `semantic` uses default semantic HTML elements, while `grid` adds CSS grid and flexbox styles
|
@@ -1018,6 +1019,9 @@ interface MRT_TableOptions<TData extends MRT_RowData> extends Omit<Partial<Table
|
|
1018
1019
|
muiTableContainerProps?: ((props: {
|
1019
1020
|
table: MRT_TableInstance<TData>;
|
1020
1021
|
}) => TableContainerProps) | TableContainerProps;
|
1022
|
+
/**
|
1023
|
+
* @deprecated Specify this in the `defaultColumn` table option instead if you want to apply to all columns.
|
1024
|
+
*/
|
1021
1025
|
muiTableFooterCellProps?: ((props: {
|
1022
1026
|
column: MRT_Column<TData>;
|
1023
1027
|
table: MRT_TableInstance<TData>;
|
package/dist/index.esm.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { flexRender as flexRender$1, createRow as createRow$1, sortingFns, aggregationFns, filterFns, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from '@tanstack/react-table';
|
2
|
-
import { useMemo, useState, useReducer, useRef, useEffect, useCallback, memo, Fragment as Fragment$1, useLayoutEffect } from 'react';
|
2
|
+
import { useMemo, useState, useId, useReducer, useRef, useEffect, useCallback, memo, Fragment as Fragment$1, useLayoutEffect } from 'react';
|
3
3
|
import { compareItems, rankItem, rankings } from '@tanstack/match-sorter-utils';
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
5
5
|
import IconButton from '@mui/material/IconButton';
|
@@ -50,7 +50,7 @@ import ViewColumnIcon from '@mui/icons-material/ViewColumn';
|
|
50
50
|
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
|
51
51
|
import { defaultRangeExtractor, useVirtualizer } from '@tanstack/react-virtual';
|
52
52
|
import Paper from '@mui/material/Paper';
|
53
|
-
import
|
53
|
+
import FocusTrap from '@mui/material/Unstable_TrapFocus/FocusTrap';
|
54
54
|
import TableContainer from '@mui/material/TableContainer';
|
55
55
|
import Table from '@mui/material/Table';
|
56
56
|
import TableBody from '@mui/material/TableBody';
|
@@ -1161,7 +1161,7 @@ const MRT_RowPinButton = (_a) => {
|
|
1161
1161
|
event.stopPropagation();
|
1162
1162
|
row.pin(isPinned ? false : pinningPosition);
|
1163
1163
|
};
|
1164
|
-
return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { open: tooltipOpened, title: isPinned ? localization.unpin : localization.pin, children: jsx(IconButton, Object.assign({ "aria-label": localization.pin, onClick: handleTogglePin, onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false), size: "small" }, rest, { sx: (theme) => (Object.assign({ height: '24px', width: '24px' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: isPinned ? (jsx(CloseIcon, {})) : (jsx(PushPinIcon, { fontSize: "small", style: {
|
1164
|
+
return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { open: tooltipOpened, title: isPinned ? localization.unpin : localization.pin, children: jsx(IconButton, Object.assign({ "aria-label": localization.pin, onBlur: () => setTooltipOpened(false), onClick: handleTogglePin, onFocus: () => setTooltipOpened(true), onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false), size: "small" }, rest, { sx: (theme) => (Object.assign({ height: '24px', width: '24px' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: isPinned ? (jsx(CloseIcon, {})) : (jsx(PushPinIcon, { fontSize: "small", style: {
|
1165
1165
|
transform: `rotate(${rowPinningDisplayMode === 'sticky'
|
1166
1166
|
? 135
|
1167
1167
|
: pinningPosition === 'top'
|
@@ -1412,7 +1412,7 @@ const MRT_DefaultDisplayColumn = {
|
|
1412
1412
|
};
|
1413
1413
|
const useMRT_TableOptions = (_a) => {
|
1414
1414
|
var _b;
|
1415
|
-
var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBatchRowSelection = true, enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, enableColumnVirtualization, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFacetedValues = false, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableKeyboardShortcuts = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = false, enableRowSelection = false, enableRowVirtualization, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, mrtTheme, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionCreatingRow = 'top', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeDirection", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBatchRowSelection", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableColumnVirtualization", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFacetedValues", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableKeyboardShortcuts", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableRowVirtualization", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "mrtTheme", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
|
1415
|
+
var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBatchRowSelection = true, enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = false, enableColumnPinning = false, enableColumnResizing = false, enableColumnVirtualization, enableDensityToggle = true, enableExpandAll = true, enableExpanding, enableFacetedValues = false, enableFilterMatchHighlighting = true, enableFilters = true, enableFullScreenToggle = true, enableGlobalFilter = true, enableGlobalFilterRankedResults = true, enableGrouping = false, enableHiding = true, enableKeyboardShortcuts = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = false, enableRowSelection = false, enableRowVirtualization, enableSelectAll = true, enableSorting = true, enableStickyHeader = false, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, id = useId(), layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, mrtTheme, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionCreatingRow = 'top', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeDirection", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBatchRowSelection", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableColumnVirtualization", "enableDensityToggle", "enableExpandAll", "enableExpanding", "enableFacetedValues", "enableFilterMatchHighlighting", "enableFilters", "enableFullScreenToggle", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableKeyboardShortcuts", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableRowVirtualization", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "id", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "mrtTheme", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
|
1416
1416
|
const theme = useTheme();
|
1417
1417
|
icons = useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
|
1418
1418
|
localization = useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
|
@@ -1497,6 +1497,7 @@ const useMRT_TableOptions = (_a) => {
|
|
1497
1497
|
: undefined, getGroupedRowModel: enableGrouping && !manualGrouping ? getGroupedRowModel() : undefined, getPaginationRowModel: enablePagination && !manualPagination
|
1498
1498
|
? getPaginationRowModel()
|
1499
1499
|
: undefined, getSortedRowModel: enableSorting && !manualSorting ? getSortedRowModel() : undefined, getSubRows: (row) => row === null || row === void 0 ? void 0 : row.subRows, icons,
|
1500
|
+
id,
|
1500
1501
|
layoutMode,
|
1501
1502
|
localization,
|
1502
1503
|
manualFiltering,
|
@@ -3750,7 +3751,7 @@ const MRT_Table = (_a) => {
|
|
3750
3751
|
const MRT_TableLoadingOverlay = (_a) => {
|
3751
3752
|
var _b;
|
3752
3753
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
3753
|
-
const { options: { localization, mrtTheme: { baseBackgroundColor }, muiCircularProgressProps, }, } = table;
|
3754
|
+
const { options: { id, localization, mrtTheme: { baseBackgroundColor }, muiCircularProgressProps, }, } = table;
|
3754
3755
|
const circularProgressProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiCircularProgressProps, { table })), rest);
|
3755
3756
|
return (jsx(Box, { sx: {
|
3756
3757
|
alignItems: 'center',
|
@@ -3765,7 +3766,7 @@ const MRT_TableLoadingOverlay = (_a) => {
|
|
3765
3766
|
top: 0,
|
3766
3767
|
width: '100%',
|
3767
3768
|
zIndex: 3,
|
3768
|
-
}, children: (_b = circularProgressProps === null || circularProgressProps === void 0 ? void 0 : circularProgressProps.Component) !== null && _b !== void 0 ? _b : (jsx(CircularProgress, Object.assign({ "aria-label": localization.noRecordsToDisplay, id:
|
3769
|
+
}, children: (_b = circularProgressProps === null || circularProgressProps === void 0 ? void 0 : circularProgressProps.Component) !== null && _b !== void 0 ? _b : (jsx(CircularProgress, Object.assign({ "aria-label": localization.noRecordsToDisplay, id: `mrt-progress-${id}` }, circularProgressProps))) }));
|
3769
3770
|
};
|
3770
3771
|
|
3771
3772
|
const MRT_CellActionMenu = (_a) => {
|
@@ -3911,8 +3912,8 @@ const MRT_TablePagination = (_a) => {
|
|
3911
3912
|
var { position = 'bottom', table } = _a, rest = __rest(_a, ["position", "table"]);
|
3912
3913
|
const theme = useTheme();
|
3913
3914
|
const isMobile = useMediaQuery('(max-width: 720px)');
|
3914
|
-
const { getState, options: { enableToolbarInternalActions, icons: { ChevronLeftIcon, ChevronRightIcon, FirstPageIcon, LastPageIcon }, localization, muiPaginationProps, paginationDisplayMode, }, } = table;
|
3915
|
-
const { pagination: { pageIndex = 0, pageSize = 10 },
|
3915
|
+
const { getState, options: { enableToolbarInternalActions, icons: { ChevronLeftIcon, ChevronRightIcon, FirstPageIcon, LastPageIcon }, id, localization, muiPaginationProps, paginationDisplayMode, }, } = table;
|
3916
|
+
const { pagination: { pageIndex = 0, pageSize = 10 }, } = getState();
|
3916
3917
|
const paginationProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiPaginationProps, {
|
3917
3918
|
table,
|
3918
3919
|
})), rest);
|
@@ -3935,18 +3936,16 @@ const MRT_TablePagination = (_a) => {
|
|
3935
3936
|
gap: '8px',
|
3936
3937
|
justifyContent: { md: 'space-between', sm: 'center' },
|
3937
3938
|
justifySelf: 'flex-end',
|
3938
|
-
mt: position === 'top' &&
|
3939
|
-
enableToolbarInternalActions &&
|
3940
|
-
!showGlobalFilter
|
3939
|
+
mt: position === 'top' && enableToolbarInternalActions
|
3941
3940
|
? '3rem'
|
3942
3941
|
: undefined,
|
3943
3942
|
position: 'relative',
|
3944
3943
|
px: '8px',
|
3945
3944
|
py: '12px',
|
3946
3945
|
zIndex: 2,
|
3947
|
-
}, children: [showRowsPerPage && (jsxs(Box, { sx: { alignItems: 'center', display: 'flex', gap: '8px' }, children: [jsx(InputLabel, { htmlFor:
|
3946
|
+
}, children: [showRowsPerPage && (jsxs(Box, { sx: { alignItems: 'center', display: 'flex', gap: '8px' }, children: [jsx(InputLabel, { htmlFor: `mrt-rows-per-page-${id}`, sx: { mb: 0 }, children: localization.rowsPerPage }), jsx(Select, Object.assign({ MenuProps: { disableScrollLock: true }, disableUnderline: true, disabled: disabled, inputProps: {
|
3948
3947
|
'aria-label': localization.rowsPerPage,
|
3949
|
-
id:
|
3948
|
+
id: `mrt-rows-per-page-${id}`,
|
3950
3949
|
}, label: localization.rowsPerPage, onChange: (event) => table.setPageSize(+event.target.value), sx: { mb: 0 }, value: pageSize, variant: "standard" }, SelectProps, { children: rowsPerPageOptions.map((option) => {
|
3951
3950
|
var _a;
|
3952
3951
|
const value = typeof option !== 'number' ? option.value : option;
|
@@ -4186,7 +4185,7 @@ const MRT_ToggleFullScreenButton = (_a) => {
|
|
4186
4185
|
setTooltipOpened(false);
|
4187
4186
|
setIsFullScreen(!isFullScreen);
|
4188
4187
|
};
|
4189
|
-
return (jsx(Tooltip, { open: tooltipOpened, title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.toggleFullScreen, children: jsx(IconButton, Object.assign({ "aria-label": localization.toggleFullScreen, onClick: handleToggleFullScreen, onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false) }, rest, { title: undefined, children: isFullScreen ? jsx(FullscreenExitIcon, {}) : jsx(FullscreenIcon, {}) })) }));
|
4188
|
+
return (jsx(Tooltip, { open: tooltipOpened, title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.toggleFullScreen, children: jsx(IconButton, Object.assign({ "aria-label": localization.toggleFullScreen, onBlur: () => setTooltipOpened(false), onClick: handleToggleFullScreen, onFocus: () => setTooltipOpened(true), onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false) }, rest, { title: undefined, children: isFullScreen ? jsx(FullscreenExitIcon, {}) : jsx(FullscreenIcon, {}) })) }));
|
4190
4189
|
};
|
4191
4190
|
|
4192
4191
|
const MRT_ToggleGlobalFilterButton = (_a) => {
|
@@ -4314,31 +4313,31 @@ const MRT_TablePaper = (_a) => {
|
|
4314
4313
|
const { getState, options: { enableBottomToolbar, enableTopToolbar, mrtTheme: { baseBackgroundColor }, muiTablePaperProps, renderBottomToolbar, renderTopToolbar, }, refs: { tablePaperRef }, } = table;
|
4315
4314
|
const { isFullScreen } = getState();
|
4316
4315
|
const paperProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTablePaperProps, { table })), rest);
|
4317
|
-
const theme = useTheme
|
4318
|
-
return (jsxs(Paper, Object.assign({ elevation: 2 }, paperProps, { ref: (ref) => {
|
4319
|
-
|
4320
|
-
|
4321
|
-
|
4322
|
-
|
4323
|
-
|
4324
|
-
|
4325
|
-
|
4326
|
-
|
4327
|
-
|
4328
|
-
|
4329
|
-
|
4330
|
-
|
4331
|
-
|
4332
|
-
|
4333
|
-
|
4334
|
-
|
4335
|
-
|
4336
|
-
|
4337
|
-
|
4338
|
-
|
4339
|
-
|
4340
|
-
|
4341
|
-
|
4316
|
+
const theme = useTheme();
|
4317
|
+
return (jsx(FocusTrap, { disableEnforceFocus: true, open: isFullScreen, children: jsxs(Paper, Object.assign({ elevation: 2, onKeyDown: (e) => e.key === 'Escape' && table.setIsFullScreen(false) }, paperProps, { ref: (ref) => {
|
4318
|
+
tablePaperRef.current = ref;
|
4319
|
+
if (paperProps === null || paperProps === void 0 ? void 0 : paperProps.ref) {
|
4320
|
+
//@ts-ignore
|
4321
|
+
paperProps.ref.current = ref;
|
4322
|
+
}
|
4323
|
+
}, style: Object.assign(Object.assign({}, (isFullScreen
|
4324
|
+
? {
|
4325
|
+
bottom: 0,
|
4326
|
+
height: '100dvh',
|
4327
|
+
left: 0,
|
4328
|
+
margin: 0,
|
4329
|
+
maxHeight: '100dvh',
|
4330
|
+
maxWidth: '100dvw',
|
4331
|
+
padding: 0,
|
4332
|
+
position: 'fixed',
|
4333
|
+
right: 0,
|
4334
|
+
top: 0,
|
4335
|
+
width: '100dvw',
|
4336
|
+
zIndex: theme.zIndex.modal,
|
4337
|
+
}
|
4338
|
+
: {})), paperProps === null || paperProps === void 0 ? void 0 : paperProps.style), sx: (theme) => (Object.assign({ backgroundColor: baseBackgroundColor, backgroundImage: 'unset', overflow: 'hidden', transition: 'all 100ms ease-in-out' }, parseFromValuesOrFunc(paperProps === null || paperProps === void 0 ? void 0 : paperProps.sx, theme))), children: [enableTopToolbar &&
|
4339
|
+
((_b = parseFromValuesOrFunc(renderTopToolbar, { table })) !== null && _b !== void 0 ? _b : (jsx(MRT_TopToolbar, { table: table }))), jsx(MRT_TableContainer, { table: table }), enableBottomToolbar &&
|
4340
|
+
((_c = parseFromValuesOrFunc(renderBottomToolbar, { table })) !== null && _c !== void 0 ? _c : (jsx(MRT_BottomToolbar, { table: table })))] })) }));
|
4342
4341
|
};
|
4343
4342
|
|
4344
4343
|
const isTableInstanceProp = (props) => props.table !== undefined;
|