material-react-table 1.4.0-beta.3 → 1.4.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.
@@ -468,6 +468,9 @@ export type MaterialReactTableProps<TData extends Record<string, any> = {}> = Om
468
468
  globalFilterModeOptions?: MRT_FilterOption[] | null;
469
469
  icons?: Partial<MRT_Icons>;
470
470
  initialState?: Partial<MRT_TableState<TData>>;
471
+ /**
472
+ * 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
473
+ */
471
474
  layoutMode?: 'semantic' | 'grid';
472
475
  /**
473
476
  * Pass in either a locale imported from `material-react-table/locales/*` or a custom locale object.
@@ -1973,12 +1973,12 @@ const MRT_TableHeadRow = ({ headerGroup, table }) => {
1973
1973
  };
1974
1974
 
1975
1975
  const MRT_TableHead = ({ table }) => {
1976
- const { getHeaderGroups, getState, options: { enableRowVirtualization, enableStickyHeader, layoutMode, muiTableHeadProps, }, } = table;
1976
+ const { getHeaderGroups, getState, options: { enableStickyHeader, layoutMode, muiTableHeadProps }, } = table;
1977
1977
  const { isFullScreen } = getState();
1978
1978
  const tableHeadProps = muiTableHeadProps instanceof Function
1979
1979
  ? muiTableHeadProps({ table })
1980
1980
  : muiTableHeadProps;
1981
- const stickyHeader = enableStickyHeader || enableRowVirtualization || isFullScreen;
1981
+ const stickyHeader = enableStickyHeader || isFullScreen;
1982
1982
  return (React__default.createElement(TableHead, Object.assign({}, tableHeadProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-row-group', opacity: 0.97, position: stickyHeader ? 'sticky' : 'relative', top: stickyHeader && layoutMode === 'grid' ? 0 : undefined, zIndex: stickyHeader ? 2 : undefined }, ((tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx) instanceof Function
1983
1983
  ? tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx(theme)
1984
1984
  : tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx))) }), getHeaderGroups().map((headerGroup) => (React__default.createElement(MRT_TableHeadRow, { headerGroup: headerGroup, key: headerGroup.id, table: table })))));
@@ -2225,20 +2225,22 @@ class Virtualizer {
2225
2225
  clearTimeout(this.isScrollingTimeoutId);
2226
2226
  this.isScrollingTimeoutId = null;
2227
2227
  }
2228
+ const onIsScrollingChange = isScrolling => {
2229
+ if (this.isScrolling !== isScrolling) {
2230
+ this.isScrolling = isScrolling;
2231
+ this.notify();
2232
+ }
2233
+ };
2234
+ this.scrollAdjustments = 0;
2228
2235
  if (this.scrollOffset !== offset) {
2229
2236
  this.scrollOffset = offset;
2230
- this.isScrolling = true;
2231
- this.scrollAdjustments = 0;
2232
- this.isScrollingTimeoutId = setTimeout(() => {
2233
- this.isScrollingTimeoutId = null;
2234
- this.isScrolling = false;
2235
- this.notify();
2236
- }, this.options.scrollingDelay);
2237
- } else {
2238
- this.isScrolling = false;
2239
- this.scrollAdjustments = 0;
2237
+ onIsScrollingChange(true);
2240
2238
  }
2241
2239
  this.calculateRange();
2240
+ this.isScrollingTimeoutId = setTimeout(() => {
2241
+ this.isScrollingTimeoutId = null;
2242
+ onIsScrollingChange(false);
2243
+ }, this.options.scrollingDelay);
2242
2244
  }));
2243
2245
  } else if (!this.isScrolling) {
2244
2246
  this.calculateRange();
@@ -2845,7 +2847,7 @@ const MRT_TableBodyRow = ({ measureElement, numRows, row, rowIndex, table, virtu
2845
2847
  }
2846
2848
  } }, tableRowProps, { sx: (theme) => (Object.assign(Object.assign({ backgroundColor: lighten(theme.palette.background.default, 0.06), display: layoutMode === 'grid' ? 'flex' : 'table-row', opacity: (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id || (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id ? 0.5 : 1, position: virtualRow ? 'absolute' : undefined, top: virtualRow ? 0 : undefined, transform: virtualRow
2847
2849
  ? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
2848
- : undefined, transition: virtualRow ? 'none' : 'all 150ms ease-in-out', '&:hover td': {
2850
+ : undefined, transition: virtualRow ? 'none' : 'all 150ms ease-in-out', width: '100%', '&:hover td': {
2849
2851
  backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false && getIsSomeColumnsPinned()
2850
2852
  ? theme.palette.mode === 'dark'
2851
2853
  ? `${lighten(theme.palette.background.default, 0.12)}`
@@ -3014,12 +3016,12 @@ const MRT_TableFooter = ({ table }) => {
3014
3016
  };
3015
3017
 
3016
3018
  const MRT_Table = ({ table }) => {
3017
- const { getState, options: { enableColumnResizing, enableRowVirtualization, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, }, } = table;
3019
+ const { getState, options: { enableColumnResizing, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, }, } = table;
3018
3020
  const { isFullScreen } = getState();
3019
3021
  const tableProps = muiTableProps instanceof Function
3020
3022
  ? muiTableProps({ table })
3021
3023
  : muiTableProps;
3022
- return (React__default.createElement(Table, Object.assign({ stickyHeader: enableStickyHeader || enableRowVirtualization || isFullScreen }, tableProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table', tableLayout: enableColumnResizing || enableRowVirtualization ? 'fixed' : 'auto' }, ((tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx) instanceof Function
3024
+ return (React__default.createElement(Table, Object.assign({ stickyHeader: enableStickyHeader || isFullScreen }, tableProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table', tableLayout: enableColumnResizing ? 'fixed' : 'auto' }, ((tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx) instanceof Function
3023
3025
  ? tableProps.sx(theme)
3024
3026
  : tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx))) }),
3025
3027
  enableTableHead && React__default.createElement(MRT_TableHead, { table: table }),
@@ -3029,7 +3031,7 @@ const MRT_Table = ({ table }) => {
3029
3031
 
3030
3032
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
3031
3033
  const MRT_TableContainer = ({ table }) => {
3032
- const { getState, options: { enableStickyHeader, enableRowVirtualization, muiTableContainerProps, }, refs: { tableContainerRef, bottomToolbarRef, topToolbarRef }, } = table;
3034
+ const { getState, options: { enableStickyHeader, muiTableContainerProps }, refs: { tableContainerRef, bottomToolbarRef, topToolbarRef }, } = table;
3033
3035
  const { isFullScreen } = getState();
3034
3036
  const [totalToolbarHeight, setTotalToolbarHeight] = useState(0);
3035
3037
  const tableContainerProps = muiTableContainerProps instanceof Function
@@ -3053,7 +3055,7 @@ const MRT_TableContainer = ({ table }) => {
3053
3055
  tableContainerProps.ref.current = node;
3054
3056
  }
3055
3057
  }
3056
- }, sx: (theme) => (Object.assign({ maxWidth: '100%', maxHeight: enableStickyHeader || enableRowVirtualization
3058
+ }, sx: (theme) => (Object.assign({ maxWidth: '100%', maxHeight: enableStickyHeader
3057
3059
  ? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
3058
3060
  : undefined, overflow: 'auto' }, ((tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx) instanceof Function
3059
3061
  ? tableContainerProps.sx(theme)
@@ -3272,7 +3274,7 @@ const MRT_TableRoot = (props) => {
3272
3274
  }
3273
3275
  }, [table.getState().isFullScreen]);
3274
3276
  return (React__default.createElement(React__default.Fragment, null,
3275
- React__default.createElement(Dialog, { PaperComponent: Box, TransitionComponent: Grow, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => table.setIsFullScreen(false), open: table.getState().isFullScreen, transitionDuration: 400 },
3277
+ React__default.createElement(Dialog, { PaperComponent: Box, TransitionComponent: !props.enableRowVirtualization ? Grow : undefined, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => table.setIsFullScreen(false), open: table.getState().isFullScreen, transitionDuration: 400 },
3276
3278
  React__default.createElement(MRT_TablePaper, { table: table })),
3277
3279
  !table.getState().isFullScreen && (React__default.createElement(MRT_TablePaper, { table: table })),
3278
3280
  editingRow && props.editingMode === 'modal' && (React__default.createElement(MRT_EditRowModal, { row: editingRow, table: table, open: true }))));
@@ -3379,8 +3381,10 @@ const MaterialReactTable = (_a) => {
3379
3381
  const _sortingFns = useMemo(() => (Object.assign(Object.assign({}, MRT_SortingFns), sortingFns)), []);
3380
3382
  const _defaultColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultColumn), defaultColumn)), []);
3381
3383
  const _defaultDisplayColumn = useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultDisplayColumn), defaultDisplayColumn)), []);
3382
- if (rest.enableRowVirtualization)
3384
+ if (rest.enableRowVirtualization) {
3383
3385
  layoutMode = 'grid';
3386
+ enableStickyHeader = true;
3387
+ }
3384
3388
  return (React__default.createElement(MRT_TableRoot, Object.assign({ aggregationFns: _aggregationFns, autoResetExpanded: autoResetExpanded, columnResizeMode: columnResizeMode, defaultColumn: _defaultColumn, defaultDisplayColumn: _defaultDisplayColumn, editingMode: editingMode, enableBottomToolbar: enableBottomToolbar, enableColumnActions: enableColumnActions, enableColumnFilters: enableColumnFilters, enableColumnOrdering: enableColumnOrdering, enableColumnResizing: enableColumnResizing, enableDensityToggle: enableDensityToggle, enableExpandAll: enableExpandAll, enableFilters: enableFilters, enableFullScreenToggle: enableFullScreenToggle, enableGlobalFilter: enableGlobalFilter, enableGlobalFilterRankedResults: enableGlobalFilterRankedResults, enableGrouping: enableGrouping, enableHiding: enableHiding, enableMultiRowSelection: enableMultiRowSelection, enableMultiSort: enableMultiSort, enablePagination: enablePagination, enablePinning: enablePinning, enableRowSelection: enableRowSelection, enableSelectAll: enableSelectAll, enableSorting: enableSorting, enableStickyHeader: enableStickyHeader, enableTableFooter: enableTableFooter, enableTableHead: enableTableHead, enableToolbarInternalActions: enableToolbarInternalActions, enableTopToolbar: enableTopToolbar, filterFns: _filterFns, icons: _icons, layoutMode: layoutMode, localization: _localization, positionActionsColumn: positionActionsColumn, positionExpandColumn: positionExpandColumn, positionGlobalFilter: positionGlobalFilter, positionPagination: positionPagination, positionToolbarAlertBanner: positionToolbarAlertBanner, positionToolbarDropZone: positionToolbarDropZone, rowNumberMode: rowNumberMode, selectAllMode: selectAllMode, sortingFns: _sortingFns }, rest)));
3385
3389
  };
3386
3390