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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Kevin Vandy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -87,7 +87,7 @@ _**Fully Fleshed out [Docs](https://www.material-react-table.com/docs/guides#gui
87
87
  - [x] Theming (Respects your Material UI Theme)
88
88
  - [x] Toolbars (Add your own action buttons)
89
89
  - [x] Tree Data / Expanding Sub-rows
90
- - [x] Virtualization (react-virtual)
90
+ - [x] Virtualization (@tanstack/react-virtual)
91
91
 
92
92
  ## Getting Started
93
93
 
@@ -189,4 +189,6 @@ _Open in [Code Sandbox](https://codesandbox.io/s/simple-material-react-table-exa
189
189
 
190
190
  PRs are Welcome, but please discuss in [GitHub Discussions](https://github.com/KevinVandy/material-react-table/discussions) or the [Discord Server](https://discord.gg/5wqyRx6fnm) first if it is a large change!
191
191
 
192
- Read the [Contributing Guide](https://github.com/KevinVandy/material-react-table/blob/main/CONTRIBUTING.md) to learn how to run this project locally.
192
+ Read the [Contributing Guide](https://github.com/KevinVandy/material-react-table/blob/main/CONTRIBUTING.md) to learn how to run this project locally.
193
+
194
+ <!-- Use the FORCE, Luke! -->
package/dist/cjs/index.js CHANGED
@@ -2071,12 +2071,12 @@ const MRT_TableHeadRow = ({ headerGroup, table }) => {
2071
2071
  };
2072
2072
 
2073
2073
  const MRT_TableHead = ({ table }) => {
2074
- const { getHeaderGroups, getState, options: { enableRowVirtualization, enableStickyHeader, layoutMode, muiTableHeadProps, }, } = table;
2074
+ const { getHeaderGroups, getState, options: { enableStickyHeader, layoutMode, muiTableHeadProps }, } = table;
2075
2075
  const { isFullScreen } = getState();
2076
2076
  const tableHeadProps = muiTableHeadProps instanceof Function
2077
2077
  ? muiTableHeadProps({ table })
2078
2078
  : muiTableHeadProps;
2079
- const stickyHeader = enableStickyHeader || enableRowVirtualization || isFullScreen;
2079
+ const stickyHeader = enableStickyHeader || isFullScreen;
2080
2080
  return (React__default["default"].createElement(TableHead__default["default"], 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
2081
2081
  ? tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx(theme)
2082
2082
  : tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx))) }), getHeaderGroups().map((headerGroup) => (React__default["default"].createElement(MRT_TableHeadRow, { headerGroup: headerGroup, key: headerGroup.id, table: table })))));
@@ -2323,20 +2323,22 @@ class Virtualizer {
2323
2323
  clearTimeout(this.isScrollingTimeoutId);
2324
2324
  this.isScrollingTimeoutId = null;
2325
2325
  }
2326
+ const onIsScrollingChange = isScrolling => {
2327
+ if (this.isScrolling !== isScrolling) {
2328
+ this.isScrolling = isScrolling;
2329
+ this.notify();
2330
+ }
2331
+ };
2332
+ this.scrollAdjustments = 0;
2326
2333
  if (this.scrollOffset !== offset) {
2327
2334
  this.scrollOffset = offset;
2328
- this.isScrolling = true;
2329
- this.scrollAdjustments = 0;
2330
- this.isScrollingTimeoutId = setTimeout(() => {
2331
- this.isScrollingTimeoutId = null;
2332
- this.isScrolling = false;
2333
- this.notify();
2334
- }, this.options.scrollingDelay);
2335
- } else {
2336
- this.isScrolling = false;
2337
- this.scrollAdjustments = 0;
2335
+ onIsScrollingChange(true);
2338
2336
  }
2339
2337
  this.calculateRange();
2338
+ this.isScrollingTimeoutId = setTimeout(() => {
2339
+ this.isScrollingTimeoutId = null;
2340
+ onIsScrollingChange(false);
2341
+ }, this.options.scrollingDelay);
2340
2342
  }));
2341
2343
  } else if (!this.isScrolling) {
2342
2344
  this.calculateRange();
@@ -2943,7 +2945,7 @@ const MRT_TableBodyRow = ({ measureElement, numRows, row, rowIndex, table, virtu
2943
2945
  }
2944
2946
  } }, tableRowProps, { sx: (theme) => (Object.assign(Object.assign({ backgroundColor: styles.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
2945
2947
  ? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
2946
- : undefined, transition: virtualRow ? 'none' : 'all 150ms ease-in-out', '&:hover td': {
2948
+ : undefined, transition: virtualRow ? 'none' : 'all 150ms ease-in-out', width: '100%', '&:hover td': {
2947
2949
  backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false && getIsSomeColumnsPinned()
2948
2950
  ? theme.palette.mode === 'dark'
2949
2951
  ? `${styles.lighten(theme.palette.background.default, 0.12)}`
@@ -3112,12 +3114,12 @@ const MRT_TableFooter = ({ table }) => {
3112
3114
  };
3113
3115
 
3114
3116
  const MRT_Table = ({ table }) => {
3115
- const { getState, options: { enableColumnResizing, enableRowVirtualization, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, }, } = table;
3117
+ const { getState, options: { enableColumnResizing, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, }, } = table;
3116
3118
  const { isFullScreen } = getState();
3117
3119
  const tableProps = muiTableProps instanceof Function
3118
3120
  ? muiTableProps({ table })
3119
3121
  : muiTableProps;
3120
- return (React__default["default"].createElement(Table__default["default"], 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
3122
+ return (React__default["default"].createElement(Table__default["default"], 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
3121
3123
  ? tableProps.sx(theme)
3122
3124
  : tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx))) }),
3123
3125
  enableTableHead && React__default["default"].createElement(MRT_TableHead, { table: table }),
@@ -3127,7 +3129,7 @@ const MRT_Table = ({ table }) => {
3127
3129
 
3128
3130
  const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect;
3129
3131
  const MRT_TableContainer = ({ table }) => {
3130
- const { getState, options: { enableStickyHeader, enableRowVirtualization, muiTableContainerProps, }, refs: { tableContainerRef, bottomToolbarRef, topToolbarRef }, } = table;
3132
+ const { getState, options: { enableStickyHeader, muiTableContainerProps }, refs: { tableContainerRef, bottomToolbarRef, topToolbarRef }, } = table;
3131
3133
  const { isFullScreen } = getState();
3132
3134
  const [totalToolbarHeight, setTotalToolbarHeight] = React.useState(0);
3133
3135
  const tableContainerProps = muiTableContainerProps instanceof Function
@@ -3151,7 +3153,7 @@ const MRT_TableContainer = ({ table }) => {
3151
3153
  tableContainerProps.ref.current = node;
3152
3154
  }
3153
3155
  }
3154
- }, sx: (theme) => (Object.assign({ maxWidth: '100%', maxHeight: enableStickyHeader || enableRowVirtualization
3156
+ }, sx: (theme) => (Object.assign({ maxWidth: '100%', maxHeight: enableStickyHeader
3155
3157
  ? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
3156
3158
  : undefined, overflow: 'auto' }, ((tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx) instanceof Function
3157
3159
  ? tableContainerProps.sx(theme)
@@ -3370,7 +3372,7 @@ const MRT_TableRoot = (props) => {
3370
3372
  }
3371
3373
  }, [table.getState().isFullScreen]);
3372
3374
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
3373
- React__default["default"].createElement(Dialog__default["default"], { PaperComponent: Box__default["default"], TransitionComponent: Grow__default["default"], disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => table.setIsFullScreen(false), open: table.getState().isFullScreen, transitionDuration: 400 },
3375
+ React__default["default"].createElement(Dialog__default["default"], { PaperComponent: Box__default["default"], TransitionComponent: !props.enableRowVirtualization ? Grow__default["default"] : undefined, disablePortal: true, fullScreen: true, keepMounted: false, onClose: () => table.setIsFullScreen(false), open: table.getState().isFullScreen, transitionDuration: 400 },
3374
3376
  React__default["default"].createElement(MRT_TablePaper, { table: table })),
3375
3377
  !table.getState().isFullScreen && (React__default["default"].createElement(MRT_TablePaper, { table: table })),
3376
3378
  editingRow && props.editingMode === 'modal' && (React__default["default"].createElement(MRT_EditRowModal, { row: editingRow, table: table, open: true }))));
@@ -3477,8 +3479,10 @@ const MaterialReactTable = (_a) => {
3477
3479
  const _sortingFns = React.useMemo(() => (Object.assign(Object.assign({}, MRT_SortingFns), sortingFns)), []);
3478
3480
  const _defaultColumn = React.useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultColumn), defaultColumn)), []);
3479
3481
  const _defaultDisplayColumn = React.useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultDisplayColumn), defaultDisplayColumn)), []);
3480
- if (rest.enableRowVirtualization)
3482
+ if (rest.enableRowVirtualization) {
3481
3483
  layoutMode = 'grid';
3484
+ enableStickyHeader = true;
3485
+ }
3482
3486
  return (React__default["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)));
3483
3487
  };
3484
3488