material-react-table 1.4.0-beta.0 → 1.4.0-beta.2

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.
Files changed (33) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/index.js +654 -85
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/types/MaterialReactTable.d.ts +6 -13
  5. package/dist/cjs/types/body/MRT_TableBodyCell.d.ts +1 -1
  6. package/dist/cjs/types/body/MRT_TableBodyRow.d.ts +3 -1
  7. package/dist/cjs/types/body/MRT_TableBodyRowGrabHandle.d.ts +1 -1
  8. package/dist/cjs/types/table/MRT_TableRoot.d.ts +4 -4
  9. package/dist/esm/material-react-table.esm.js +927 -376
  10. package/dist/esm/material-react-table.esm.js.map +1 -1
  11. package/dist/esm/types/MaterialReactTable.d.ts +6 -13
  12. package/dist/esm/types/body/MRT_TableBodyCell.d.ts +1 -1
  13. package/dist/esm/types/body/MRT_TableBodyRow.d.ts +3 -1
  14. package/dist/esm/types/body/MRT_TableBodyRowGrabHandle.d.ts +1 -1
  15. package/dist/esm/types/table/MRT_TableRoot.d.ts +4 -4
  16. package/dist/index.d.ts +7 -14
  17. package/package.json +4 -3
  18. package/src/MaterialReactTable.tsx +15 -22
  19. package/src/body/MRT_TableBody.tsx +53 -77
  20. package/src/body/MRT_TableBodyCell.tsx +1 -3
  21. package/src/body/MRT_TableBodyRow.tsx +16 -9
  22. package/src/body/MRT_TableBodyRowGrabHandle.tsx +1 -1
  23. package/src/body/MRT_TableDetailPanel.tsx +7 -1
  24. package/src/column.utils.ts +0 -1
  25. package/src/footer/MRT_TableFooter.tsx +2 -1
  26. package/src/footer/MRT_TableFooterCell.tsx +3 -1
  27. package/src/footer/MRT_TableFooterRow.tsx +10 -2
  28. package/src/head/MRT_TableHead.tsx +3 -3
  29. package/src/head/MRT_TableHeadCell.tsx +0 -2
  30. package/src/head/MRT_TableHeadCellFilterLabel.tsx +7 -0
  31. package/src/head/MRT_TableHeadRow.tsx +2 -3
  32. package/src/table/MRT_Table.tsx +1 -2
  33. package/src/table/MRT_TableContainer.tsx +7 -5
package/dist/cjs/index.js CHANGED
@@ -71,7 +71,6 @@ var TableHead = require('@mui/material/TableHead');
71
71
  var TableRow = require('@mui/material/TableRow');
72
72
  var TableCell = require('@mui/material/TableCell');
73
73
  var TableSortLabel = require('@mui/material/TableSortLabel');
74
- var reactVirtual = require('react-virtual');
75
74
  var TableBody = require('@mui/material/TableBody');
76
75
  var Skeleton = require('@mui/material/Skeleton');
77
76
  var TableFooter = require('@mui/material/TableFooter');
@@ -82,7 +81,26 @@ var Stack = require('@mui/material/Stack');
82
81
 
83
82
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
84
83
 
84
+ function _interopNamespace(e) {
85
+ if (e && e.__esModule) return e;
86
+ var n = Object.create(null);
87
+ if (e) {
88
+ Object.keys(e).forEach(function (k) {
89
+ if (k !== 'default') {
90
+ var d = Object.getOwnPropertyDescriptor(e, k);
91
+ Object.defineProperty(n, k, d.get ? d : {
92
+ enumerable: true,
93
+ get: function () { return e[k]; }
94
+ });
95
+ }
96
+ });
97
+ }
98
+ n["default"] = e;
99
+ return Object.freeze(n);
100
+ }
101
+
85
102
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
103
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
86
104
  var ArrowDownwardIcon__default = /*#__PURE__*/_interopDefaultLegacy(ArrowDownwardIcon);
87
105
  var ArrowRightIcon__default = /*#__PURE__*/_interopDefaultLegacy(ArrowRightIcon);
88
106
  var CancelIcon__default = /*#__PURE__*/_interopDefaultLegacy(CancelIcon);
@@ -329,7 +347,7 @@ const getCommonCellStyles = ({ column, header, table, tableCellProps, theme, })
329
347
  ? tableCellProps.sx(theme)
330
348
  : tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx)), { flex: table.options.layoutMode === 'grid'
331
349
  ? `${column.getSize()} 0 auto`
332
- : undefined, maxWidth: `min(${column.getSize()}px, fit-content)`, minWidth: `max(${column.getSize()}px, ${(_c = column.columnDef.minSize) !== null && _c !== void 0 ? _c : 30}px)`, width: (_d = header === null || header === void 0 ? void 0 : header.getSize()) !== null && _d !== void 0 ? _d : column.getSize() }));
350
+ : undefined, minWidth: `max(${column.getSize()}px, ${(_c = column.columnDef.minSize) !== null && _c !== void 0 ? _c : 30}px)`, width: (_d = header === null || header === void 0 ? void 0 : header.getSize()) !== null && _d !== void 0 ? _d : column.getSize() }));
333
351
  };
334
352
  const MRT_DefaultColumn = {
335
353
  minSize: 40,
@@ -1779,7 +1797,7 @@ const MRT_TableHeadCellFilterContainer = ({ header, table, }) => {
1779
1797
 
1780
1798
  const MRT_TableHeadCellFilterLabel = ({ header, table }) => {
1781
1799
  var _a, _b, _c;
1782
- const { options: { icons: { FilterAltIcon }, localization, }, } = table;
1800
+ const { options: { icons: { FilterAltIcon }, localization, }, refs: { filterInputRefs }, setShowFilters, } = table;
1783
1801
  const { column } = header;
1784
1802
  const { columnDef } = column;
1785
1803
  const isRangeFilter = columnDef.filterVariant === 'range' ||
@@ -1801,6 +1819,12 @@ const MRT_TableHeadCellFilterLabel = ({ header, table }) => {
1801
1819
  React__default["default"].createElement(Box__default["default"], { component: "span", sx: { flex: '0 0' } },
1802
1820
  React__default["default"].createElement(Tooltip__default["default"], { arrow: true, placement: "top", title: filterTooltip },
1803
1821
  React__default["default"].createElement(IconButton__default["default"], { disableRipple: true, onClick: (event) => {
1822
+ setShowFilters(true);
1823
+ queueMicrotask(() => {
1824
+ var _a, _b;
1825
+ (_a = filterInputRefs.current[`${column.id}-0`]) === null || _a === void 0 ? void 0 : _a.focus();
1826
+ (_b = filterInputRefs.current[`${column.id}-0`]) === null || _b === void 0 ? void 0 : _b.select();
1827
+ });
1804
1828
  event.stopPropagation();
1805
1829
  }, size: "small", sx: {
1806
1830
  height: '12px',
@@ -1965,11 +1989,11 @@ const MRT_TableHeadCell = ({ header, table }) => {
1965
1989
  table,
1966
1990
  })
1967
1991
  : (_b = columnDef === null || columnDef === void 0 ? void 0 : columnDef.Header) !== null && _b !== void 0 ? _b : columnDef.header;
1968
- return (React__default["default"].createElement(TableCell__default["default"], Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', component: layoutMode === 'grid' ? 'div' : 'td', colSpan: header.colSpan, onDragEnter: handleDragEnter, ref: (node) => {
1992
+ return (React__default["default"].createElement(TableCell__default["default"], Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: header.colSpan, onDragEnter: handleDragEnter, ref: (node) => {
1969
1993
  if (node) {
1970
1994
  tableHeadCellRefs.current[column.id] = node;
1971
1995
  }
1972
- }, role: "columnheader" }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ flexDirection: layoutMode === 'grid' ? 'column' : undefined, fontWeight: 'bold', overflow: 'visible', p: density === 'compact'
1996
+ } }, tableCellProps, { sx: (theme) => (Object.assign(Object.assign({ flexDirection: layoutMode === 'grid' ? 'column' : undefined, fontWeight: 'bold', overflow: 'visible', p: density === 'compact'
1973
1997
  ? '0.5rem'
1974
1998
  : density === 'comfortable'
1975
1999
  ? columnDefType === 'display'
@@ -2041,7 +2065,7 @@ const MRT_TableHeadRow = ({ headerGroup, table }) => {
2041
2065
  const tableRowProps = muiTableHeadRowProps instanceof Function
2042
2066
  ? muiTableHeadRowProps({ headerGroup, table })
2043
2067
  : muiTableHeadRowProps;
2044
- return (React__default["default"].createElement(TableRow__default["default"], Object.assign({ component: layoutMode === 'grid' ? 'div' : 'tr', role: "row" }, tableRowProps, { sx: (theme) => (Object.assign({ boxShadow: `4px 0 8px ${styles.alpha(theme.palette.common.black, 0.1)}`, display: layoutMode === 'grid' ? 'flex' : 'table-row', backgroundColor: styles.lighten(theme.palette.background.default, 0.04) }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
2068
+ return (React__default["default"].createElement(TableRow__default["default"], Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ backgroundColor: styles.lighten(theme.palette.background.default, 0.04), boxShadow: `4px 0 8px ${styles.alpha(theme.palette.common.black, 0.1)}`, display: layoutMode === 'grid' ? 'flex' : 'table-row', top: 0 }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
2045
2069
  ? tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx(theme)
2046
2070
  : tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx))) }), headerGroup.headers.map((header) => (React__default["default"].createElement(MRT_TableHeadCell, { header: header, key: header.id, table: table })))));
2047
2071
  };
@@ -2053,11 +2077,574 @@ const MRT_TableHead = ({ table }) => {
2053
2077
  ? muiTableHeadProps({ table })
2054
2078
  : muiTableHeadProps;
2055
2079
  const stickyHeader = enableStickyHeader || enableRowVirtualization || isFullScreen;
2056
- return (React__default["default"].createElement(TableHead__default["default"], Object.assign({ component: layoutMode === 'grid' ? 'div' : 'thead', role: "rowgroup" }, tableHeadProps, { sx: (theme) => (Object.assign({ opacity: 0.97, position: stickyHeader ? 'sticky' : undefined, zIndex: stickyHeader ? 2 : undefined }, ((tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx) instanceof Function
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
2057
2081
  ? tableHeadProps === null || tableHeadProps === void 0 ? void 0 : tableHeadProps.sx(theme)
2058
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 })))));
2059
2083
  };
2060
2084
 
2085
+ /**
2086
+ * virtual-core
2087
+ *
2088
+ * Copyright (c) TanStack
2089
+ *
2090
+ * This source code is licensed under the MIT license found in the
2091
+ * LICENSE.md file in the root directory of this source tree.
2092
+ *
2093
+ * @license MIT
2094
+ */
2095
+ function memo(getDeps, fn, opts) {
2096
+ let deps = [];
2097
+ let result;
2098
+ return () => {
2099
+ let depTime;
2100
+ if (opts.key && opts.debug != null && opts.debug()) depTime = Date.now();
2101
+ const newDeps = getDeps();
2102
+ const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
2103
+ if (!depsChanged) {
2104
+ return result;
2105
+ }
2106
+ deps = newDeps;
2107
+ let resultTime;
2108
+ if (opts.key && opts.debug != null && opts.debug()) resultTime = Date.now();
2109
+ result = fn(...newDeps);
2110
+ opts == null ? void 0 : opts.onChange == null ? void 0 : opts.onChange(result);
2111
+ if (opts.key && opts.debug != null && opts.debug()) {
2112
+ const depEndTime = Math.round((Date.now() - depTime) * 100) / 100;
2113
+ const resultEndTime = Math.round((Date.now() - resultTime) * 100) / 100;
2114
+ const resultFpsPercentage = resultEndTime / 16;
2115
+ const pad = (str, num) => {
2116
+ str = String(str);
2117
+ while (str.length < num) {
2118
+ str = ' ' + str;
2119
+ }
2120
+ return str;
2121
+ };
2122
+ console.info(`%c⏱ ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`, `
2123
+ font-size: .6rem;
2124
+ font-weight: bold;
2125
+ color: hsl(${Math.max(0, Math.min(120 - 120 * resultFpsPercentage, 120))}deg 100% 31%);`, opts == null ? void 0 : opts.key);
2126
+ }
2127
+ return result;
2128
+ };
2129
+ }
2130
+
2131
+ /**
2132
+ * virtual-core
2133
+ *
2134
+ * Copyright (c) TanStack
2135
+ *
2136
+ * This source code is licensed under the MIT license found in the
2137
+ * LICENSE.md file in the root directory of this source tree.
2138
+ *
2139
+ * @license MIT
2140
+ */
2141
+
2142
+ //
2143
+
2144
+ //
2145
+
2146
+ const defaultKeyExtractor = index => index;
2147
+ const defaultRangeExtractor = range => {
2148
+ const start = Math.max(range.startIndex - range.overscan, 0);
2149
+ const end = Math.min(range.endIndex + range.overscan, range.count - 1);
2150
+ const arr = [];
2151
+ for (let i = start; i <= end; i++) {
2152
+ arr.push(i);
2153
+ }
2154
+ return arr;
2155
+ };
2156
+ const observeElementRect = (instance, cb) => {
2157
+ const observer = new ResizeObserver(entries => {
2158
+ var _entries$, _entries$2;
2159
+ cb({
2160
+ width: (_entries$ = entries[0]) == null ? void 0 : _entries$.contentRect.width,
2161
+ height: (_entries$2 = entries[0]) == null ? void 0 : _entries$2.contentRect.height
2162
+ });
2163
+ });
2164
+ if (!instance.scrollElement) {
2165
+ return;
2166
+ }
2167
+ cb(instance.scrollElement.getBoundingClientRect());
2168
+ observer.observe(instance.scrollElement);
2169
+ return () => {
2170
+ observer.unobserve(instance.scrollElement);
2171
+ };
2172
+ };
2173
+ const scrollProps = {
2174
+ element: ['scrollLeft', 'scrollTop'],
2175
+ window: ['scrollX', 'scrollY']
2176
+ };
2177
+ const createOffsetObserver = mode => {
2178
+ return (instance, cb) => {
2179
+ if (!instance.scrollElement) {
2180
+ return;
2181
+ }
2182
+ const propX = scrollProps[mode][0];
2183
+ const propY = scrollProps[mode][1];
2184
+ let prevX = instance.scrollElement[propX];
2185
+ let prevY = instance.scrollElement[propY];
2186
+ const scroll = () => {
2187
+ const offset = instance.scrollElement[instance.options.horizontal ? propX : propY];
2188
+ cb(Math.max(0, offset - instance.options.scrollMargin));
2189
+ };
2190
+ scroll();
2191
+ const onScroll = e => {
2192
+ const target = e.currentTarget;
2193
+ const scrollX = target[propX];
2194
+ const scrollY = target[propY];
2195
+ if (instance.options.horizontal ? prevX - scrollX : prevY - scrollY) {
2196
+ scroll();
2197
+ }
2198
+ prevX = scrollX;
2199
+ prevY = scrollY;
2200
+ };
2201
+ instance.scrollElement.addEventListener('scroll', onScroll, {
2202
+ capture: false,
2203
+ passive: true
2204
+ });
2205
+ return () => {
2206
+ instance.scrollElement.removeEventListener('scroll', onScroll);
2207
+ };
2208
+ };
2209
+ };
2210
+ const observeElementOffset = createOffsetObserver('element');
2211
+ const measureElement = (element, instance) => {
2212
+ return Math.round(element.getBoundingClientRect()[instance.options.horizontal ? 'width' : 'height']);
2213
+ };
2214
+ const elementScroll = (offset, _ref2, instance) => {
2215
+ var _instance$scrollEleme2;
2216
+ let {
2217
+ adjustments,
2218
+ behavior,
2219
+ sync
2220
+ } = _ref2;
2221
+ const toOffset = (sync ? offset : offset + instance.options.scrollMargin) + (adjustments ?? 0);
2222
+ (_instance$scrollEleme2 = instance.scrollElement) == null ? void 0 : _instance$scrollEleme2.scrollTo == null ? void 0 : _instance$scrollEleme2.scrollTo({
2223
+ [instance.options.horizontal ? 'left' : 'top']: toOffset,
2224
+ behavior
2225
+ });
2226
+ };
2227
+ class Virtualizer {
2228
+ constructor(_opts) {
2229
+ var _this = this;
2230
+ this.unsubs = [];
2231
+ this.scrollElement = null;
2232
+ this.isScrolling = false;
2233
+ this.isScrollingTimeoutId = null;
2234
+ this.measurementsCache = [];
2235
+ this.itemMeasurementsCache = {};
2236
+ this.pendingMeasuredCacheIndexes = [];
2237
+ this.scrollAdjustments = 0;
2238
+ this.measureElementCache = {};
2239
+ this.pendingScrollToIndexCallback = null;
2240
+ this.getResizeObserver = (() => {
2241
+ let _ro = null;
2242
+ return () => {
2243
+ if (_ro) {
2244
+ return _ro;
2245
+ } else if (typeof ResizeObserver !== 'undefined') {
2246
+ return _ro = new ResizeObserver(entries => {
2247
+ entries.forEach(entry => {
2248
+ this._measureElement(entry.target, false);
2249
+ });
2250
+ });
2251
+ } else {
2252
+ return null;
2253
+ }
2254
+ };
2255
+ })();
2256
+ this.range = {
2257
+ startIndex: 0,
2258
+ endIndex: 0
2259
+ };
2260
+ this.setOptions = opts => {
2261
+ Object.entries(opts).forEach(_ref3 => {
2262
+ let [key, value] = _ref3;
2263
+ if (typeof value === 'undefined') delete opts[key];
2264
+ });
2265
+ this.options = {
2266
+ debug: false,
2267
+ initialOffset: 0,
2268
+ overscan: 1,
2269
+ paddingStart: 0,
2270
+ paddingEnd: 0,
2271
+ scrollPaddingStart: 0,
2272
+ scrollPaddingEnd: 0,
2273
+ horizontal: false,
2274
+ getItemKey: defaultKeyExtractor,
2275
+ rangeExtractor: defaultRangeExtractor,
2276
+ onChange: () => {},
2277
+ measureElement,
2278
+ initialRect: {
2279
+ width: 0,
2280
+ height: 0
2281
+ },
2282
+ scrollMargin: 0,
2283
+ scrollingDelay: 150,
2284
+ indexAttribute: 'data-index',
2285
+ ...opts
2286
+ };
2287
+ };
2288
+ this.notify = () => {
2289
+ var _this$options$onChang, _this$options;
2290
+ (_this$options$onChang = (_this$options = this.options).onChange) == null ? void 0 : _this$options$onChang.call(_this$options, this);
2291
+ };
2292
+ this.cleanup = () => {
2293
+ this.unsubs.filter(Boolean).forEach(d => d());
2294
+ this.unsubs = [];
2295
+ this.scrollElement = null;
2296
+ };
2297
+ this._didMount = () => {
2298
+ const ro = this.getResizeObserver();
2299
+ Object.values(this.measureElementCache).forEach(node => ro == null ? void 0 : ro.observe(node));
2300
+ return () => {
2301
+ ro == null ? void 0 : ro.disconnect();
2302
+ this.cleanup();
2303
+ };
2304
+ };
2305
+ this._willUpdate = () => {
2306
+ var _this$pendingScrollTo;
2307
+ (_this$pendingScrollTo = this.pendingScrollToIndexCallback) == null ? void 0 : _this$pendingScrollTo.call(this);
2308
+ const scrollElement = this.options.getScrollElement();
2309
+ if (this.scrollElement !== scrollElement) {
2310
+ this.cleanup();
2311
+ this.scrollElement = scrollElement;
2312
+ this._scrollToOffset(this.scrollOffset, {
2313
+ adjustments: undefined,
2314
+ behavior: undefined,
2315
+ sync: true
2316
+ });
2317
+ this.unsubs.push(this.options.observeElementRect(this, rect => {
2318
+ this.scrollRect = rect;
2319
+ this.calculateRange();
2320
+ }));
2321
+ this.unsubs.push(this.options.observeElementOffset(this, offset => {
2322
+ if (this.isScrollingTimeoutId !== null) {
2323
+ clearTimeout(this.isScrollingTimeoutId);
2324
+ this.isScrollingTimeoutId = null;
2325
+ }
2326
+ if (this.scrollOffset !== offset) {
2327
+ 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;
2338
+ }
2339
+ this.calculateRange();
2340
+ }));
2341
+ } else if (!this.isScrolling) {
2342
+ this.calculateRange();
2343
+ }
2344
+ };
2345
+ this.getSize = () => {
2346
+ return this.scrollRect[this.options.horizontal ? 'width' : 'height'];
2347
+ };
2348
+ this.getMeasurements = memo(() => [this.options.count, this.options.paddingStart, this.options.getItemKey, this.itemMeasurementsCache], (count, paddingStart, getItemKey, measurementsCache) => {
2349
+ const min = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
2350
+ this.pendingMeasuredCacheIndexes = [];
2351
+ const measurements = this.measurementsCache.slice(0, min);
2352
+ for (let i = min; i < count; i++) {
2353
+ const key = getItemKey(i);
2354
+ const measuredSize = measurementsCache[key];
2355
+ const start = measurements[i - 1] ? measurements[i - 1].end : paddingStart;
2356
+ const size = typeof measuredSize === 'number' ? measuredSize : this.options.estimateSize(i);
2357
+ const end = start + size;
2358
+ measurements[i] = {
2359
+ index: i,
2360
+ start,
2361
+ size,
2362
+ end,
2363
+ key
2364
+ };
2365
+ }
2366
+ this.measurementsCache = measurements;
2367
+ return measurements;
2368
+ }, {
2369
+ key: process.env.NODE_ENV !== 'production' && 'getMeasurements',
2370
+ debug: () => this.options.debug
2371
+ });
2372
+ this.calculateRange = memo(() => [this.getMeasurements(), this.getSize(), this.scrollOffset], (measurements, outerSize, scrollOffset) => {
2373
+ const range = calculateRange({
2374
+ measurements,
2375
+ outerSize,
2376
+ scrollOffset
2377
+ });
2378
+ if (range.startIndex !== this.range.startIndex || range.endIndex !== this.range.endIndex) {
2379
+ this.range = range;
2380
+ this.notify();
2381
+ }
2382
+ return this.range;
2383
+ }, {
2384
+ key: process.env.NODE_ENV !== 'production' && 'calculateRange',
2385
+ debug: () => this.options.debug
2386
+ });
2387
+ this.getIndexes = memo(() => [this.options.rangeExtractor, this.range, this.options.overscan, this.options.count], (rangeExtractor, range, overscan, count) => {
2388
+ return rangeExtractor({
2389
+ ...range,
2390
+ overscan,
2391
+ count: count
2392
+ });
2393
+ }, {
2394
+ key: process.env.NODE_ENV !== 'production' && 'getIndexes',
2395
+ debug: () => this.options.debug
2396
+ });
2397
+ this.indexFromElement = node => {
2398
+ const attributeName = this.options.indexAttribute;
2399
+ const indexStr = node.getAttribute(attributeName);
2400
+ if (!indexStr) {
2401
+ console.warn(`Missing attribute name '${attributeName}={index}' on measured element.`);
2402
+ return -1;
2403
+ }
2404
+ return parseInt(indexStr, 10);
2405
+ };
2406
+ this._measureElement = (node, _sync) => {
2407
+ const index = this.indexFromElement(node);
2408
+ const item = this.measurementsCache[index];
2409
+ if (!item) {
2410
+ return;
2411
+ }
2412
+ const prevNode = this.measureElementCache[item.key];
2413
+ const ro = this.getResizeObserver();
2414
+ if (!node.isConnected) {
2415
+ if (prevNode) {
2416
+ ro == null ? void 0 : ro.unobserve(prevNode);
2417
+ delete this.measureElementCache[item.key];
2418
+ }
2419
+ return;
2420
+ }
2421
+ if (!prevNode || prevNode !== node) {
2422
+ if (prevNode) {
2423
+ ro == null ? void 0 : ro.unobserve(prevNode);
2424
+ }
2425
+ this.measureElementCache[item.key] = node;
2426
+ ro == null ? void 0 : ro.observe(node);
2427
+ }
2428
+ const measuredItemSize = this.options.measureElement(node, this);
2429
+ const itemSize = this.itemMeasurementsCache[item.key] ?? item.size;
2430
+ const delta = measuredItemSize - itemSize;
2431
+ if (delta !== 0) {
2432
+ if (item.start < this.scrollOffset && this.isScrolling) {
2433
+ if (process.env.NODE_ENV !== 'production' && this.options.debug) {
2434
+ console.info('correction', delta);
2435
+ }
2436
+ this._scrollToOffset(this.scrollOffset, {
2437
+ adjustments: this.scrollAdjustments += delta,
2438
+ behavior: undefined,
2439
+ sync: false
2440
+ });
2441
+ }
2442
+ this.pendingMeasuredCacheIndexes.push(index);
2443
+ this.itemMeasurementsCache = {
2444
+ ...this.itemMeasurementsCache,
2445
+ [item.key]: measuredItemSize
2446
+ };
2447
+ this.notify();
2448
+ }
2449
+ };
2450
+ this.measureElement = node => {
2451
+ if (!node) {
2452
+ return;
2453
+ }
2454
+ this._measureElement(node, true);
2455
+ };
2456
+ this.getVirtualItems = memo(() => [this.getIndexes(), this.getMeasurements()], (indexes, measurements) => {
2457
+ const virtualItems = [];
2458
+ for (let k = 0, len = indexes.length; k < len; k++) {
2459
+ const i = indexes[k];
2460
+ const measurement = measurements[i];
2461
+ virtualItems.push(measurement);
2462
+ }
2463
+ return virtualItems;
2464
+ }, {
2465
+ key: process.env.NODE_ENV !== 'production' && 'getIndexes',
2466
+ debug: () => this.options.debug
2467
+ });
2468
+ this.scrollToOffset = function (toOffset, _temp) {
2469
+ let {
2470
+ align = 'start',
2471
+ behavior
2472
+ } = _temp === void 0 ? {} : _temp;
2473
+ const offset = _this.scrollOffset;
2474
+ const size = _this.getSize();
2475
+ if (align === 'auto') {
2476
+ if (toOffset <= offset) {
2477
+ align = 'start';
2478
+ } else if (toOffset >= offset + size) {
2479
+ align = 'end';
2480
+ } else {
2481
+ align = 'start';
2482
+ }
2483
+ }
2484
+ const options = {
2485
+ adjustments: undefined,
2486
+ behavior,
2487
+ sync: false
2488
+ };
2489
+ if (align === 'start') {
2490
+ _this._scrollToOffset(toOffset, options);
2491
+ } else if (align === 'end') {
2492
+ _this._scrollToOffset(toOffset - size, options);
2493
+ } else if (align === 'center') {
2494
+ _this._scrollToOffset(toOffset - size / 2, options);
2495
+ }
2496
+ };
2497
+ this.scrollToIndex = function (index, _temp2) {
2498
+ let {
2499
+ align = 'auto',
2500
+ ...rest
2501
+ } = _temp2 === void 0 ? {} : _temp2;
2502
+ _this.pendingScrollToIndexCallback = null;
2503
+ const measurements = _this.getMeasurements();
2504
+ const offset = _this.scrollOffset;
2505
+ const size = _this.getSize();
2506
+ const {
2507
+ count
2508
+ } = _this.options;
2509
+ const measurement = measurements[Math.max(0, Math.min(index, count - 1))];
2510
+ if (!measurement) {
2511
+ return;
2512
+ }
2513
+ if (align === 'auto') {
2514
+ if (measurement.end >= offset + size - _this.options.scrollPaddingEnd) {
2515
+ align = 'end';
2516
+ } else if (measurement.start <= offset + _this.options.scrollPaddingStart) {
2517
+ align = 'start';
2518
+ } else {
2519
+ return;
2520
+ }
2521
+ }
2522
+ const toOffset = align === 'end' ? measurement.end + _this.options.scrollPaddingEnd : measurement.start - _this.options.scrollPaddingStart;
2523
+ _this.scrollToOffset(toOffset, {
2524
+ align,
2525
+ ...rest
2526
+ });
2527
+ const isDynamic = Object.keys(_this.measureElementCache).length > 0;
2528
+ if (isDynamic) {
2529
+ const didSeen = () => typeof _this.itemMeasurementsCache[_this.options.getItemKey(index)] === 'number';
2530
+ if (!didSeen()) {
2531
+ _this.pendingScrollToIndexCallback = () => {
2532
+ if (didSeen()) {
2533
+ _this.pendingScrollToIndexCallback = null;
2534
+ _this.scrollToIndex(index, {
2535
+ align,
2536
+ ...rest
2537
+ });
2538
+ }
2539
+ };
2540
+ }
2541
+ }
2542
+ };
2543
+ this.getTotalSize = () => {
2544
+ var _this$getMeasurements;
2545
+ return (((_this$getMeasurements = this.getMeasurements()[this.options.count - 1]) == null ? void 0 : _this$getMeasurements.end) || this.options.paddingStart) + this.options.paddingEnd;
2546
+ };
2547
+ this._scrollToOffset = (offset, _ref4) => {
2548
+ let {
2549
+ adjustments,
2550
+ behavior,
2551
+ sync
2552
+ } = _ref4;
2553
+ this.options.scrollToFn(offset, {
2554
+ behavior,
2555
+ sync,
2556
+ adjustments
2557
+ }, this);
2558
+ };
2559
+ this.measure = () => {
2560
+ this.itemMeasurementsCache = {};
2561
+ this.notify();
2562
+ };
2563
+ this.setOptions(_opts);
2564
+ this.scrollRect = this.options.initialRect;
2565
+ this.scrollOffset = this.options.initialOffset;
2566
+ this.calculateRange();
2567
+ }
2568
+ }
2569
+ const findNearestBinarySearch = (low, high, getCurrentValue, value) => {
2570
+ while (low <= high) {
2571
+ const middle = (low + high) / 2 | 0;
2572
+ const currentValue = getCurrentValue(middle);
2573
+ if (currentValue < value) {
2574
+ low = middle + 1;
2575
+ } else if (currentValue > value) {
2576
+ high = middle - 1;
2577
+ } else {
2578
+ return middle;
2579
+ }
2580
+ }
2581
+ if (low > 0) {
2582
+ return low - 1;
2583
+ } else {
2584
+ return 0;
2585
+ }
2586
+ };
2587
+ function calculateRange(_ref5) {
2588
+ let {
2589
+ measurements,
2590
+ outerSize,
2591
+ scrollOffset
2592
+ } = _ref5;
2593
+ const count = measurements.length - 1;
2594
+ const getOffset = index => measurements[index].start;
2595
+ const startIndex = findNearestBinarySearch(0, count, getOffset, scrollOffset);
2596
+ let endIndex = startIndex;
2597
+ while (endIndex < count && measurements[endIndex].end < scrollOffset + outerSize) {
2598
+ endIndex++;
2599
+ }
2600
+ return {
2601
+ startIndex,
2602
+ endIndex
2603
+ };
2604
+ }
2605
+
2606
+ /**
2607
+ * react-virtual
2608
+ *
2609
+ * Copyright (c) TanStack
2610
+ *
2611
+ * This source code is licensed under the MIT license found in the
2612
+ * LICENSE.md file in the root directory of this source tree.
2613
+ *
2614
+ * @license MIT
2615
+ */
2616
+
2617
+ //
2618
+
2619
+ const useIsomorphicLayoutEffect$1 = typeof window !== 'undefined' ? React__namespace.useLayoutEffect : React__namespace.useEffect;
2620
+ function useVirtualizerBase(options) {
2621
+ const rerender = React__namespace.useReducer(() => ({}), {})[1];
2622
+ const resolvedOptions = {
2623
+ ...options,
2624
+ onChange: instance => {
2625
+ rerender();
2626
+ options.onChange == null ? void 0 : options.onChange(instance);
2627
+ }
2628
+ };
2629
+ const [instance] = React__namespace.useState(() => new Virtualizer(resolvedOptions));
2630
+ instance.setOptions(resolvedOptions);
2631
+ React__namespace.useEffect(() => {
2632
+ return instance._didMount();
2633
+ }, []);
2634
+ useIsomorphicLayoutEffect$1(() => {
2635
+ return instance._willUpdate();
2636
+ });
2637
+ return instance;
2638
+ }
2639
+ function useVirtualizer(options) {
2640
+ return useVirtualizerBase({
2641
+ observeElementRect: observeElementRect,
2642
+ observeElementOffset: observeElementOffset,
2643
+ scrollToFn: elementScroll,
2644
+ ...options
2645
+ });
2646
+ }
2647
+
2061
2648
  const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
2062
2649
  var _a;
2063
2650
  const { getState, options: { muiTableBodyCellEditTextFieldProps }, refs: { editInputRefs }, setEditingCell, setEditingRow, } = table;
@@ -2266,7 +2853,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, numRows, rowIndex, rowRef, table
2266
2853
  setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
2267
2854
  }
2268
2855
  };
2269
- return (React__default["default"].createElement(TableCell__default["default"], Object.assign({ component: layoutMode === 'grid' ? 'div' : 'td', role: "gridcell" }, tableCellProps, { onDragEnter: handleDragEnter, onDoubleClick: handleDoubleClick, sx: (theme) => (Object.assign(Object.assign({ alignItems: layoutMode === 'grid' ? 'center' : undefined, cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'inherit', overflow: 'hidden', p: density === 'compact'
2856
+ return (React__default["default"].createElement(TableCell__default["default"], Object.assign({}, tableCellProps, { onDragEnter: handleDragEnter, onDoubleClick: handleDoubleClick, sx: (theme) => (Object.assign(Object.assign({ alignItems: layoutMode === 'grid' ? 'center' : undefined, cursor: isEditable && editingMode === 'cell' ? 'pointer' : 'inherit', overflow: 'hidden', p: density === 'compact'
2270
2857
  ? columnDefType === 'display'
2271
2858
  ? '0 0.5rem'
2272
2859
  : '0.5rem'
@@ -2309,7 +2896,7 @@ const MRT_TableBodyCell = ({ cell, enableHover, numRows, rowIndex, rowRef, table
2309
2896
  const Memo_MRT_TableBodyCell = React.memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
2310
2897
 
2311
2898
  const MRT_TableDetailPanel = ({ row, table }) => {
2312
- const { getVisibleLeafColumns, getState, options: { muiTableBodyRowProps, muiTableDetailPanelProps, renderDetailPanel, }, } = table;
2899
+ const { getVisibleLeafColumns, getState, options: { layoutMode, muiTableBodyRowProps, muiTableDetailPanelProps, renderDetailPanel, }, } = table;
2313
2900
  const { isLoading } = getState();
2314
2901
  const tableRowProps = muiTableBodyRowProps instanceof Function
2315
2902
  ? muiTableBodyRowProps({ row, table })
@@ -2317,13 +2904,15 @@ const MRT_TableDetailPanel = ({ row, table }) => {
2317
2904
  const tableCellProps = muiTableDetailPanelProps instanceof Function
2318
2905
  ? muiTableDetailPanelProps({ row, table })
2319
2906
  : muiTableDetailPanelProps;
2320
- return (React__default["default"].createElement(TableRow__default["default"], Object.assign({}, tableRowProps),
2907
+ return (React__default["default"].createElement(TableRow__default["default"], Object.assign({ sx: {
2908
+ display: layoutMode === 'grid' ? 'flex' : 'table-row',
2909
+ } }, tableRowProps),
2321
2910
  React__default["default"].createElement(TableCell__default["default"], Object.assign({ colSpan: getVisibleLeafColumns().length }, tableCellProps, { sx: (theme) => (Object.assign({ borderBottom: !row.getIsExpanded() ? 'none' : undefined, pb: row.getIsExpanded() ? '1rem' : 0, pt: row.getIsExpanded() ? '1rem' : 0, transition: 'all 150ms ease-in-out', width: `${table.getTotalSize()}px` }, ((tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx) instanceof Function
2322
2911
  ? tableCellProps.sx(theme)
2323
2912
  : tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx))) }), renderDetailPanel && (React__default["default"].createElement(Collapse__default["default"], { in: row.getIsExpanded(), mountOnEnter: true, unmountOnExit: true }, !isLoading && renderDetailPanel({ row, table }))))));
2324
2913
  };
2325
2914
 
2326
- const MRT_TableBodyRow = ({ numRows, row, rowIndex, table, virtualRow, }) => {
2915
+ const MRT_TableBodyRow = ({ measureElement, numRows, row, rowIndex, table, virtualRow, }) => {
2327
2916
  const theme = styles.useTheme();
2328
2917
  const { getIsSomeColumnsPinned, getState, options: { enableRowOrdering, layoutMode, memoMode, muiTableBodyRowProps, renderDetailPanel, }, setHoveredRow, } = table;
2329
2918
  const { draggingColumn, draggingRow, editingCell, editingRow, hoveredRow } = getState();
@@ -2347,12 +2936,14 @@ const MRT_TableBodyRow = ({ numRows, row, rowIndex, table, virtualRow, }) => {
2347
2936
  }
2348
2937
  : undefined;
2349
2938
  return (React__default["default"].createElement(React__default["default"].Fragment, null,
2350
- React__default["default"].createElement(TableRow__default["default"], Object.assign({ component: layoutMode === 'grid' ? 'div' : 'tr', hover: true, onDragEnter: handleDragEnter, selected: row.getIsSelected(), ref: (node) => {
2351
- rowRef.current = node;
2352
- if (virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.measureRef) {
2353
- virtualRow.measureRef = node;
2939
+ React__default["default"].createElement(TableRow__default["default"], Object.assign({ "data-index": virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.index, hover: true, onDragEnter: handleDragEnter, selected: row.getIsSelected(), ref: (node) => {
2940
+ if (node) {
2941
+ rowRef.current = node;
2942
+ measureElement === null || measureElement === void 0 ? void 0 : measureElement(node);
2354
2943
  }
2355
- }, role: "row" }, 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, transition: 'all 150ms ease-in-out', '&:hover td': {
2944
+ } }, 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
+ ? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
2946
+ : undefined, transition: virtualRow ? 'none' : 'all 150ms ease-in-out', '&:hover td': {
2356
2947
  backgroundColor: (tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.hover) !== false && getIsSomeColumnsPinned()
2357
2948
  ? theme.palette.mode === 'dark'
2358
2949
  ? `${styles.lighten(theme.palette.background.default, 0.12)}`
@@ -2382,9 +2973,9 @@ const MRT_TableBodyRow = ({ numRows, row, rowIndex, table, virtualRow, }) => {
2382
2973
  const Memo_MRT_TableBodyRow = React.memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row);
2383
2974
 
2384
2975
  const MRT_TableBody = ({ table }) => {
2385
- var _a, _b;
2976
+ var _a, _b, _c;
2386
2977
  const { getRowModel, getPrePaginationRowModel, getState, options: { enableGlobalFilterRankedResults, enablePagination, enableRowVirtualization, layoutMode, localization, manualFiltering, manualSorting, memoMode, muiTableBodyProps, virtualizerInstanceRef, virtualizerProps, }, refs: { tableContainerRef, tablePaperRef }, } = table;
2387
- const { columnFilters, globalFilter, pagination, sorting } = getState();
2978
+ const { columnFilters, density, globalFilter, pagination, sorting } = getState();
2388
2979
  const tableBodyProps = muiTableBodyProps instanceof Function
2389
2980
  ? muiTableBodyProps({ table })
2390
2981
  : muiTableBodyProps;
@@ -2417,78 +3008,50 @@ const MRT_TableBody = ({ table }) => {
2417
3008
  pagination.pageSize,
2418
3009
  ]);
2419
3010
  const virtualizer = enableRowVirtualization
2420
- ? reactVirtual.useVirtual(Object.assign({ size: rows.length, parentRef: tableContainerRef, overscan: 15 }, vProps))
2421
- : {};
2422
- if (virtualizerInstanceRef) {
3011
+ ? useVirtualizer(Object.assign({ count: rows.length, estimateSize: () => density === 'compact' ? 37 : density === 'comfortable' ? 58 : 73, getScrollElement: () => tableContainerRef.current, measureElement: (element) => element === null || element === void 0 ? void 0 : element.getBoundingClientRect().height, overscan: 10 }, vProps))
3012
+ : undefined;
3013
+ if (virtualizerInstanceRef && virtualizer) {
2423
3014
  virtualizerInstanceRef.current = virtualizer;
2424
3015
  }
2425
- // const virtualizer: Virtualizer = enableRowVirtualization
2426
- // ? useVirtualizer({
2427
- // count: rows.length,
2428
- // estimateSize: () => (density === 'compact' ? 25 : 50),
2429
- // getScrollElement: () => tableContainerRef.current as HTMLDivElement,
2430
- // overscan: 15,
2431
- // ...vProps,
2432
- // })
2433
- // : ({} as any);
2434
- const virtualRows = enableRowVirtualization ? virtualizer.virtualItems : [];
2435
- // const virtualRows = enableRowVirtualization
2436
- // ? virtualizer.getVirtualItems()
2437
- // : [];
2438
- let paddingTop = 0;
2439
- let paddingBottom = 0;
2440
- if (enableRowVirtualization) {
2441
- paddingTop = virtualRows.length ? virtualRows[0].start : 0;
2442
- paddingBottom = virtualRows.length
2443
- ? virtualizer.totalSize - virtualRows[virtualRows.length - 1].end
2444
- : 0;
2445
- }
2446
- // if (enableRowVirtualization) {
2447
- // paddingTop = !!virtualRows.length ? virtualRows[0].start : 0;
2448
- // paddingBottom = !!virtualRows.length
2449
- // ? virtualizer.getTotalSize() - virtualRows[virtualRows.length - 1].end
2450
- // : 0;
2451
- // }
2452
- return (React__default["default"].createElement(TableBody__default["default"], Object.assign({ component: layoutMode === 'grid' ? 'div' : 'tbody', role: "rowgroup" }, tableBodyProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-row-group' }, ((tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx) instanceof Function
3016
+ const virtualRows = virtualizer ? virtualizer.getVirtualItems() : undefined;
3017
+ return (React__default["default"].createElement(TableBody__default["default"], Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-row-group', height: virtualizer ? `${virtualizer.getTotalSize()}px` : 'inherit', position: 'relative' }, ((tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx) instanceof Function
2453
3018
  ? tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx(theme)
2454
- : tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx))) }), ((_a = tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.children) !== null && _a !== void 0 ? _a : !rows.length) ? (React__default["default"].createElement("tr", null,
2455
- React__default["default"].createElement("td", { colSpan: table.getVisibleLeafColumns().length },
3019
+ : tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx))) }), ((_a = tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.children) !== null && _a !== void 0 ? _a : !rows.length) ? (React__default["default"].createElement("tr", { style: { display: layoutMode === 'grid' ? 'grid' : 'table-row' } },
3020
+ React__default["default"].createElement("td", { colSpan: table.getVisibleLeafColumns().length, style: { display: layoutMode === 'grid' ? 'grid' : 'table-cell' } },
2456
3021
  React__default["default"].createElement(Typography__default["default"], { sx: {
2457
3022
  color: 'text.secondary',
2458
3023
  fontStyle: 'italic',
2459
- maxWidth: `min(100vw, ${(_b = tablePaperRef.current) === null || _b === void 0 ? void 0 : _b.clientWidth}px)`,
3024
+ maxWidth: `min(100vw, ${(_c = (_b = tablePaperRef.current) === null || _b === void 0 ? void 0 : _b.clientWidth) !== null && _c !== void 0 ? _c : 360}px)`,
2460
3025
  py: '2rem',
2461
3026
  textAlign: 'center',
2462
3027
  width: '100%',
2463
3028
  } }, globalFilter || columnFilters.length
2464
3029
  ? localization.noResultsFound
2465
- : localization.noRecordsToDisplay)))) : (React__default["default"].createElement(React__default["default"].Fragment, null,
2466
- enableRowVirtualization && paddingTop > 0 && (React__default["default"].createElement("tr", null,
2467
- React__default["default"].createElement("td", { style: { height: `${paddingTop}px` } }))),
2468
- (enableRowVirtualization ? virtualRows : rows).map((rowOrVirtualRow, rowIndex) => {
2469
- const row = enableRowVirtualization
2470
- ? rows[rowOrVirtualRow.index]
2471
- : rowOrVirtualRow;
2472
- const props = {
2473
- key: row.id,
2474
- numRows: rows.length,
2475
- row,
2476
- rowIndex: enableRowVirtualization
2477
- ? rowOrVirtualRow.index
2478
- : rowIndex,
2479
- table,
2480
- virtualRow: enableRowVirtualization ? rowOrVirtualRow : null,
2481
- };
2482
- return memoMode === 'rows' ? (React__default["default"].createElement(Memo_MRT_TableBodyRow, Object.assign({}, props))) : (React__default["default"].createElement(MRT_TableBodyRow, Object.assign({}, props)));
2483
- }),
2484
- enableRowVirtualization && paddingBottom > 0 && (React__default["default"].createElement("tr", null,
2485
- React__default["default"].createElement("td", { style: { height: `${paddingBottom}px` } })))))));
3030
+ : localization.noRecordsToDisplay)))) : (React__default["default"].createElement(React__default["default"].Fragment, null, (virtualRows !== null && virtualRows !== void 0 ? virtualRows : rows).map((rowOrVirtualRow, rowIndex) => {
3031
+ const row = virtualizer
3032
+ ? rows[rowOrVirtualRow.index]
3033
+ : rowOrVirtualRow;
3034
+ const props = {
3035
+ key: row.id,
3036
+ measureElement: virtualizer
3037
+ ? virtualizer.measureElement
3038
+ : undefined,
3039
+ numRows: rows.length,
3040
+ row,
3041
+ rowIndex: virtualizer ? rowOrVirtualRow.index : rowIndex,
3042
+ table,
3043
+ virtualRow: virtualizer
3044
+ ? rowOrVirtualRow
3045
+ : undefined,
3046
+ };
3047
+ return memoMode === 'rows' ? (React__default["default"].createElement(Memo_MRT_TableBodyRow, Object.assign({}, props))) : (React__default["default"].createElement(MRT_TableBodyRow, Object.assign({}, props)));
3048
+ })))));
2486
3049
  };
2487
3050
  const Memo_MRT_TableBody = React.memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
2488
3051
 
2489
3052
  const MRT_TableFooterCell = ({ footer, table }) => {
2490
3053
  var _a, _b, _c;
2491
- const { getState, options: { muiTableFooterCellProps }, } = table;
3054
+ const { getState, options: { layoutMode, muiTableFooterCellProps }, } = table;
2492
3055
  const { density } = getState();
2493
3056
  const { column } = footer;
2494
3057
  const { columnDef } = column;
@@ -2500,7 +3063,7 @@ const MRT_TableFooterCell = ({ footer, table }) => {
2500
3063
  ? columnDef.muiTableFooterCellProps({ column, table })
2501
3064
  : columnDef.muiTableFooterCellProps;
2502
3065
  const tableCellProps = Object.assign(Object.assign({}, mTableFooterCellProps), mcTableFooterCellProps);
2503
- return (React__default["default"].createElement(TableCell__default["default"], Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: footer.colSpan, variant: "head" }, tableCellProps, { sx: (theme) => (Object.assign({ fontWeight: 'bold', p: density === 'compact'
3066
+ return (React__default["default"].createElement(TableCell__default["default"], Object.assign({ align: columnDefType === 'group' ? 'center' : 'left', colSpan: footer.colSpan, variant: "head" }, tableCellProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'grid' : 'table-cell', fontWeight: 'bold', justifyContent: columnDefType === 'group' ? 'center' : undefined, p: density === 'compact'
2504
3067
  ? '0.5rem'
2505
3068
  : density === 'comfortable'
2506
3069
  ? '1rem'
@@ -2518,7 +3081,7 @@ const MRT_TableFooterCell = ({ footer, table }) => {
2518
3081
 
2519
3082
  const MRT_TableFooterRow = ({ footerGroup, table }) => {
2520
3083
  var _a;
2521
- const { options: { muiTableFooterRowProps }, } = table;
3084
+ const { options: { layoutMode, muiTableFooterRowProps }, } = table;
2522
3085
  // if no content in row, skip row
2523
3086
  if (!((_a = footerGroup.headers) === null || _a === void 0 ? void 0 : _a.some((header) => (typeof header.column.columnDef.footer === 'string' &&
2524
3087
  !!header.column.columnDef.footer) ||
@@ -2527,17 +3090,19 @@ const MRT_TableFooterRow = ({ footerGroup, table }) => {
2527
3090
  const tableRowProps = muiTableFooterRowProps instanceof Function
2528
3091
  ? muiTableFooterRowProps({ footerGroup, table })
2529
3092
  : muiTableFooterRowProps;
2530
- return (React__default["default"].createElement(TableRow__default["default"], Object.assign({}, tableRowProps), footerGroup.headers.map((footer) => (React__default["default"].createElement(MRT_TableFooterCell, { footer: footer, key: footer.id, table: table })))));
3093
+ return (React__default["default"].createElement(TableRow__default["default"], Object.assign({}, tableRowProps, { sx: (theme) => (Object.assign({ display: layoutMode === 'grid' ? 'flex' : 'table-row' }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
3094
+ ? tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx(theme)
3095
+ : tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx))) }), footerGroup.headers.map((footer) => (React__default["default"].createElement(MRT_TableFooterCell, { footer: footer, key: footer.id, table: table })))));
2531
3096
  };
2532
3097
 
2533
3098
  const MRT_TableFooter = ({ table }) => {
2534
- const { getFooterGroups, getState, options: { enableStickyFooter, muiTableFooterProps }, } = table;
3099
+ const { getFooterGroups, getState, options: { enableStickyFooter, layoutMode, muiTableFooterProps }, } = table;
2535
3100
  const { isFullScreen } = getState();
2536
3101
  const tableFooterProps = muiTableFooterProps instanceof Function
2537
3102
  ? muiTableFooterProps({ table })
2538
3103
  : muiTableFooterProps;
2539
3104
  const stickFooter = (isFullScreen || enableStickyFooter) && enableStickyFooter !== false;
2540
- return (React__default["default"].createElement(TableFooter__default["default"], Object.assign({}, tableFooterProps, { sx: (theme) => (Object.assign({ backgroundColor: styles.lighten(theme.palette.background.default, 0.06), bottom: stickFooter ? 0 : undefined, opacity: stickFooter ? 0.97 : undefined, outline: stickFooter
3105
+ return (React__default["default"].createElement(TableFooter__default["default"], Object.assign({}, tableFooterProps, { sx: (theme) => (Object.assign({ backgroundColor: styles.lighten(theme.palette.background.default, 0.06), bottom: stickFooter ? 0 : undefined, display: layoutMode === 'grid' ? 'grid' : 'table-row-group', opacity: stickFooter ? 0.97 : undefined, outline: stickFooter
2541
3106
  ? theme.palette.mode === 'light'
2542
3107
  ? `1px solid ${theme.palette.grey[300]}`
2543
3108
  : `1px solid ${theme.palette.grey[700]}`
@@ -2552,7 +3117,7 @@ const MRT_Table = ({ table }) => {
2552
3117
  const tableProps = muiTableProps instanceof Function
2553
3118
  ? muiTableProps({ table })
2554
3119
  : muiTableProps;
2555
- return (React__default["default"].createElement(Table__default["default"], Object.assign({ component: layoutMode === 'grid' ? 'div' : 'table', role: "grid", stickyHeader: enableStickyHeader || enableRowVirtualization || isFullScreen }, tableProps, { sx: (theme) => (Object.assign({ tableLayout: enableColumnResizing || enableRowVirtualization ? 'fixed' : 'auto' }, ((tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx) instanceof Function
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
2556
3121
  ? tableProps.sx(theme)
2557
3122
  : tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx))) }),
2558
3123
  enableTableHead && React__default["default"].createElement(MRT_TableHead, { table: table }),
@@ -2578,11 +3143,13 @@ const MRT_TableContainer = ({ table }) => {
2578
3143
  : 0;
2579
3144
  setTotalToolbarHeight(topToolbarHeight + bottomToolbarHeight);
2580
3145
  });
2581
- return (React__default["default"].createElement(TableContainer__default["default"], Object.assign({}, tableContainerProps, { ref: (ref) => {
2582
- tableContainerRef.current = ref;
2583
- if (tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) {
2584
- //@ts-ignore
2585
- tableContainerProps.ref.current = ref;
3146
+ return (React__default["default"].createElement(TableContainer__default["default"], Object.assign({}, tableContainerProps, { ref: (node) => {
3147
+ if (node) {
3148
+ tableContainerRef.current = node;
3149
+ if (tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.ref) {
3150
+ //@ts-ignore
3151
+ tableContainerProps.ref.current = node;
3152
+ }
2586
3153
  }
2587
3154
  }, sx: (theme) => (Object.assign({ maxWidth: '100%', maxHeight: enableStickyHeader || enableRowVirtualization
2588
3155
  ? `clamp(350px, calc(100vh - ${totalToolbarHeight}px), 9999px)`
@@ -2910,6 +3477,8 @@ const MaterialReactTable = (_a) => {
2910
3477
  const _sortingFns = React.useMemo(() => (Object.assign(Object.assign({}, MRT_SortingFns), sortingFns)), []);
2911
3478
  const _defaultColumn = React.useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultColumn), defaultColumn)), []);
2912
3479
  const _defaultDisplayColumn = React.useMemo(() => (Object.assign(Object.assign({}, MRT_DefaultDisplayColumn), defaultDisplayColumn)), []);
3480
+ if (rest.enableRowVirtualization)
3481
+ layoutMode = 'grid';
2913
3482
  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)));
2914
3483
  };
2915
3484