material-react-table 1.4.0 → 1.4.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.
package/dist/cjs/index.js CHANGED
@@ -71,6 +71,7 @@ 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('@tanstack/react-virtual');
74
75
  var TableBody = require('@mui/material/TableBody');
75
76
  var Skeleton = require('@mui/material/Skeleton');
76
77
  var TableFooter = require('@mui/material/TableFooter');
@@ -81,26 +82,7 @@ var Stack = require('@mui/material/Stack');
81
82
 
82
83
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
83
84
 
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
-
102
85
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
103
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
104
86
  var ArrowDownwardIcon__default = /*#__PURE__*/_interopDefaultLegacy(ArrowDownwardIcon);
105
87
  var ArrowRightIcon__default = /*#__PURE__*/_interopDefaultLegacy(ArrowRightIcon);
106
88
  var CancelIcon__default = /*#__PURE__*/_interopDefaultLegacy(CancelIcon);
@@ -1392,7 +1374,7 @@ const MRT_ToolbarInternalButtons = ({ table, }) => {
1392
1374
  enableFullScreenToggle && (React__default["default"].createElement(MRT_FullScreenToggleButton, { table: table }))))));
1393
1375
  };
1394
1376
 
1395
- const MRT_ToolbarDropZone = ({ table }) => {
1377
+ const MRT_ToolbarDropZone = ({ table, }) => {
1396
1378
  var _a, _b;
1397
1379
  const { getState, options: { enableGrouping, localization }, setHoveredColumn, } = table;
1398
1380
  const { draggingColumn, hoveredColumn, grouping } = getState();
@@ -2082,571 +2064,6 @@ const MRT_TableHead = ({ table }) => {
2082
2064
  : 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 })))));
2083
2065
  };
2084
2066
 
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
- const onIsScrollingChange = isScrolling => {
2327
- if (this.isScrolling !== isScrolling) {
2328
- this.isScrolling = isScrolling;
2329
- this.notify();
2330
- }
2331
- };
2332
- this.scrollAdjustments = 0;
2333
- if (this.scrollOffset !== offset) {
2334
- this.scrollOffset = offset;
2335
- onIsScrollingChange(true);
2336
- }
2337
- this.calculateRange();
2338
- this.isScrollingTimeoutId = setTimeout(() => {
2339
- this.isScrollingTimeoutId = null;
2340
- onIsScrollingChange(false);
2341
- }, this.options.scrollingDelay);
2342
- }));
2343
- } else if (!this.isScrolling) {
2344
- this.calculateRange();
2345
- }
2346
- };
2347
- this.getSize = () => {
2348
- return this.scrollRect[this.options.horizontal ? 'width' : 'height'];
2349
- };
2350
- this.getMeasurements = memo(() => [this.options.count, this.options.paddingStart, this.options.getItemKey, this.itemMeasurementsCache], (count, paddingStart, getItemKey, measurementsCache) => {
2351
- const min = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
2352
- this.pendingMeasuredCacheIndexes = [];
2353
- const measurements = this.measurementsCache.slice(0, min);
2354
- for (let i = min; i < count; i++) {
2355
- const key = getItemKey(i);
2356
- const measuredSize = measurementsCache[key];
2357
- const start = measurements[i - 1] ? measurements[i - 1].end : paddingStart;
2358
- const size = typeof measuredSize === 'number' ? measuredSize : this.options.estimateSize(i);
2359
- const end = start + size;
2360
- measurements[i] = {
2361
- index: i,
2362
- start,
2363
- size,
2364
- end,
2365
- key
2366
- };
2367
- }
2368
- this.measurementsCache = measurements;
2369
- return measurements;
2370
- }, {
2371
- key: process.env.NODE_ENV !== 'production' && 'getMeasurements',
2372
- debug: () => this.options.debug
2373
- });
2374
- this.calculateRange = memo(() => [this.getMeasurements(), this.getSize(), this.scrollOffset], (measurements, outerSize, scrollOffset) => {
2375
- const range = calculateRange({
2376
- measurements,
2377
- outerSize,
2378
- scrollOffset
2379
- });
2380
- if (range.startIndex !== this.range.startIndex || range.endIndex !== this.range.endIndex) {
2381
- this.range = range;
2382
- this.notify();
2383
- }
2384
- return this.range;
2385
- }, {
2386
- key: process.env.NODE_ENV !== 'production' && 'calculateRange',
2387
- debug: () => this.options.debug
2388
- });
2389
- this.getIndexes = memo(() => [this.options.rangeExtractor, this.range, this.options.overscan, this.options.count], (rangeExtractor, range, overscan, count) => {
2390
- return rangeExtractor({
2391
- ...range,
2392
- overscan,
2393
- count: count
2394
- });
2395
- }, {
2396
- key: process.env.NODE_ENV !== 'production' && 'getIndexes',
2397
- debug: () => this.options.debug
2398
- });
2399
- this.indexFromElement = node => {
2400
- const attributeName = this.options.indexAttribute;
2401
- const indexStr = node.getAttribute(attributeName);
2402
- if (!indexStr) {
2403
- console.warn(`Missing attribute name '${attributeName}={index}' on measured element.`);
2404
- return -1;
2405
- }
2406
- return parseInt(indexStr, 10);
2407
- };
2408
- this._measureElement = (node, _sync) => {
2409
- const index = this.indexFromElement(node);
2410
- const item = this.measurementsCache[index];
2411
- if (!item) {
2412
- return;
2413
- }
2414
- const prevNode = this.measureElementCache[item.key];
2415
- const ro = this.getResizeObserver();
2416
- if (!node.isConnected) {
2417
- if (prevNode) {
2418
- ro == null ? void 0 : ro.unobserve(prevNode);
2419
- delete this.measureElementCache[item.key];
2420
- }
2421
- return;
2422
- }
2423
- if (!prevNode || prevNode !== node) {
2424
- if (prevNode) {
2425
- ro == null ? void 0 : ro.unobserve(prevNode);
2426
- }
2427
- this.measureElementCache[item.key] = node;
2428
- ro == null ? void 0 : ro.observe(node);
2429
- }
2430
- const measuredItemSize = this.options.measureElement(node, this);
2431
- const itemSize = this.itemMeasurementsCache[item.key] ?? item.size;
2432
- const delta = measuredItemSize - itemSize;
2433
- if (delta !== 0) {
2434
- if (item.start < this.scrollOffset && this.isScrolling) {
2435
- if (process.env.NODE_ENV !== 'production' && this.options.debug) {
2436
- console.info('correction', delta);
2437
- }
2438
- this._scrollToOffset(this.scrollOffset, {
2439
- adjustments: this.scrollAdjustments += delta,
2440
- behavior: undefined,
2441
- sync: false
2442
- });
2443
- }
2444
- this.pendingMeasuredCacheIndexes.push(index);
2445
- this.itemMeasurementsCache = {
2446
- ...this.itemMeasurementsCache,
2447
- [item.key]: measuredItemSize
2448
- };
2449
- this.notify();
2450
- }
2451
- };
2452
- this.measureElement = node => {
2453
- if (!node) {
2454
- return;
2455
- }
2456
- this._measureElement(node, true);
2457
- };
2458
- this.getVirtualItems = memo(() => [this.getIndexes(), this.getMeasurements()], (indexes, measurements) => {
2459
- const virtualItems = [];
2460
- for (let k = 0, len = indexes.length; k < len; k++) {
2461
- const i = indexes[k];
2462
- const measurement = measurements[i];
2463
- virtualItems.push(measurement);
2464
- }
2465
- return virtualItems;
2466
- }, {
2467
- key: process.env.NODE_ENV !== 'production' && 'getIndexes',
2468
- debug: () => this.options.debug
2469
- });
2470
- this.scrollToOffset = function (toOffset, _temp) {
2471
- let {
2472
- align = 'start',
2473
- behavior
2474
- } = _temp === void 0 ? {} : _temp;
2475
- const offset = _this.scrollOffset;
2476
- const size = _this.getSize();
2477
- if (align === 'auto') {
2478
- if (toOffset <= offset) {
2479
- align = 'start';
2480
- } else if (toOffset >= offset + size) {
2481
- align = 'end';
2482
- } else {
2483
- align = 'start';
2484
- }
2485
- }
2486
- const options = {
2487
- adjustments: undefined,
2488
- behavior,
2489
- sync: false
2490
- };
2491
- if (align === 'start') {
2492
- _this._scrollToOffset(toOffset, options);
2493
- } else if (align === 'end') {
2494
- _this._scrollToOffset(toOffset - size, options);
2495
- } else if (align === 'center') {
2496
- _this._scrollToOffset(toOffset - size / 2, options);
2497
- }
2498
- };
2499
- this.scrollToIndex = function (index, _temp2) {
2500
- let {
2501
- align = 'auto',
2502
- ...rest
2503
- } = _temp2 === void 0 ? {} : _temp2;
2504
- _this.pendingScrollToIndexCallback = null;
2505
- const measurements = _this.getMeasurements();
2506
- const offset = _this.scrollOffset;
2507
- const size = _this.getSize();
2508
- const {
2509
- count
2510
- } = _this.options;
2511
- const measurement = measurements[Math.max(0, Math.min(index, count - 1))];
2512
- if (!measurement) {
2513
- return;
2514
- }
2515
- if (align === 'auto') {
2516
- if (measurement.end >= offset + size - _this.options.scrollPaddingEnd) {
2517
- align = 'end';
2518
- } else if (measurement.start <= offset + _this.options.scrollPaddingStart) {
2519
- align = 'start';
2520
- } else {
2521
- return;
2522
- }
2523
- }
2524
- const toOffset = align === 'end' ? measurement.end + _this.options.scrollPaddingEnd : measurement.start - _this.options.scrollPaddingStart;
2525
- _this.scrollToOffset(toOffset, {
2526
- align,
2527
- ...rest
2528
- });
2529
- const isDynamic = Object.keys(_this.measureElementCache).length > 0;
2530
- if (isDynamic) {
2531
- const didSeen = () => typeof _this.itemMeasurementsCache[_this.options.getItemKey(index)] === 'number';
2532
- if (!didSeen()) {
2533
- _this.pendingScrollToIndexCallback = () => {
2534
- if (didSeen()) {
2535
- _this.pendingScrollToIndexCallback = null;
2536
- _this.scrollToIndex(index, {
2537
- align,
2538
- ...rest
2539
- });
2540
- }
2541
- };
2542
- }
2543
- }
2544
- };
2545
- this.getTotalSize = () => {
2546
- var _this$getMeasurements;
2547
- return (((_this$getMeasurements = this.getMeasurements()[this.options.count - 1]) == null ? void 0 : _this$getMeasurements.end) || this.options.paddingStart) + this.options.paddingEnd;
2548
- };
2549
- this._scrollToOffset = (offset, _ref4) => {
2550
- let {
2551
- adjustments,
2552
- behavior,
2553
- sync
2554
- } = _ref4;
2555
- this.options.scrollToFn(offset, {
2556
- behavior,
2557
- sync,
2558
- adjustments
2559
- }, this);
2560
- };
2561
- this.measure = () => {
2562
- this.itemMeasurementsCache = {};
2563
- this.notify();
2564
- };
2565
- this.setOptions(_opts);
2566
- this.scrollRect = this.options.initialRect;
2567
- this.scrollOffset = this.options.initialOffset;
2568
- this.calculateRange();
2569
- }
2570
- }
2571
- const findNearestBinarySearch = (low, high, getCurrentValue, value) => {
2572
- while (low <= high) {
2573
- const middle = (low + high) / 2 | 0;
2574
- const currentValue = getCurrentValue(middle);
2575
- if (currentValue < value) {
2576
- low = middle + 1;
2577
- } else if (currentValue > value) {
2578
- high = middle - 1;
2579
- } else {
2580
- return middle;
2581
- }
2582
- }
2583
- if (low > 0) {
2584
- return low - 1;
2585
- } else {
2586
- return 0;
2587
- }
2588
- };
2589
- function calculateRange(_ref5) {
2590
- let {
2591
- measurements,
2592
- outerSize,
2593
- scrollOffset
2594
- } = _ref5;
2595
- const count = measurements.length - 1;
2596
- const getOffset = index => measurements[index].start;
2597
- const startIndex = findNearestBinarySearch(0, count, getOffset, scrollOffset);
2598
- let endIndex = startIndex;
2599
- while (endIndex < count && measurements[endIndex].end < scrollOffset + outerSize) {
2600
- endIndex++;
2601
- }
2602
- return {
2603
- startIndex,
2604
- endIndex
2605
- };
2606
- }
2607
-
2608
- /**
2609
- * react-virtual
2610
- *
2611
- * Copyright (c) TanStack
2612
- *
2613
- * This source code is licensed under the MIT license found in the
2614
- * LICENSE.md file in the root directory of this source tree.
2615
- *
2616
- * @license MIT
2617
- */
2618
-
2619
- //
2620
-
2621
- const useIsomorphicLayoutEffect$1 = typeof window !== 'undefined' ? React__namespace.useLayoutEffect : React__namespace.useEffect;
2622
- function useVirtualizerBase(options) {
2623
- const rerender = React__namespace.useReducer(() => ({}), {})[1];
2624
- const resolvedOptions = {
2625
- ...options,
2626
- onChange: instance => {
2627
- rerender();
2628
- options.onChange == null ? void 0 : options.onChange(instance);
2629
- }
2630
- };
2631
- const [instance] = React__namespace.useState(() => new Virtualizer(resolvedOptions));
2632
- instance.setOptions(resolvedOptions);
2633
- React__namespace.useEffect(() => {
2634
- return instance._didMount();
2635
- }, []);
2636
- useIsomorphicLayoutEffect$1(() => {
2637
- return instance._willUpdate();
2638
- });
2639
- return instance;
2640
- }
2641
- function useVirtualizer(options) {
2642
- return useVirtualizerBase({
2643
- observeElementRect: observeElementRect,
2644
- observeElementOffset: observeElementOffset,
2645
- scrollToFn: elementScroll,
2646
- ...options
2647
- });
2648
- }
2649
-
2650
2067
  const MRT_EditCellTextField = ({ cell, showLabel, table, }) => {
2651
2068
  var _a;
2652
2069
  const { getState, options: { muiTableBodyCellEditTextFieldProps }, refs: { editInputRefs }, setEditingCell, setEditingRow, } = table;
@@ -2897,19 +2314,28 @@ const MRT_TableBodyCell = ({ cell, enableHover, numRows, rowIndex, rowRef, table
2897
2314
  };
2898
2315
  const Memo_MRT_TableBodyCell = React.memo(MRT_TableBodyCell, (prev, next) => next.cell === prev.cell);
2899
2316
 
2900
- const MRT_TableDetailPanel = ({ row, table }) => {
2317
+ const MRT_TableDetailPanel = ({ parentRowRef, row, table, virtualRow, }) => {
2901
2318
  const { getVisibleLeafColumns, getState, options: { layoutMode, muiTableBodyRowProps, muiTableDetailPanelProps, renderDetailPanel, }, } = table;
2902
2319
  const { isLoading } = getState();
2903
2320
  const tableRowProps = muiTableBodyRowProps instanceof Function
2904
- ? muiTableBodyRowProps({ row, table })
2321
+ ? muiTableBodyRowProps({ isDetailPanel: true, row, table })
2905
2322
  : muiTableBodyRowProps;
2906
2323
  const tableCellProps = muiTableDetailPanelProps instanceof Function
2907
2324
  ? muiTableDetailPanelProps({ row, table })
2908
2325
  : muiTableDetailPanelProps;
2909
- return (React__default["default"].createElement(TableRow__default["default"], Object.assign({ sx: {
2910
- display: layoutMode === 'grid' ? 'flex' : 'table-row',
2911
- } }, tableRowProps),
2912
- 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
2326
+ return (React__default["default"].createElement(TableRow__default["default"], Object.assign({ className: "Mui-TableBodyCell-DetailPanel" }, tableRowProps, { sx: (theme) => {
2327
+ var _a, _b;
2328
+ return (Object.assign({ display: layoutMode === 'grid' ? 'flex' : 'table-row', position: virtualRow ? 'absolute' : undefined, top: virtualRow
2329
+ ? `${(_b = (_a = parentRowRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) === null || _b === void 0 ? void 0 : _b.height}px`
2330
+ : undefined, transform: virtualRow
2331
+ ? `translateY(${virtualRow === null || virtualRow === void 0 ? void 0 : virtualRow.start}px)`
2332
+ : undefined, width: '100%', zIndex: virtualRow ? 2 : undefined }, ((tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx) instanceof Function
2333
+ ? tableRowProps.sx(theme)
2334
+ : tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.sx)));
2335
+ } }),
2336
+ React__default["default"].createElement(TableCell__default["default"], Object.assign({ className: "Mui-TableBodyCell-DetailPanel", colSpan: getVisibleLeafColumns().length }, tableCellProps, { sx: (theme) => (Object.assign({ backgroundColor: virtualRow
2337
+ ? styles.lighten(theme.palette.background.default, 0.06)
2338
+ : undefined, borderBottom: !row.getIsExpanded() ? 'none' : undefined, display: layoutMode === 'grid' ? 'flex' : 'table-cell', 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
2913
2339
  ? tableCellProps.sx(theme)
2914
2340
  : 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 }))))));
2915
2341
  };
@@ -2970,7 +2396,7 @@ const MRT_TableBodyRow = ({ measureElement, numRows, row, rowIndex, table, virtu
2970
2396
  (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) !== cell.id &&
2971
2397
  (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (React__default["default"].createElement(Memo_MRT_TableBodyCell, Object.assign({}, props))) : (React__default["default"].createElement(MRT_TableBodyCell, Object.assign({}, props)));
2972
2398
  })),
2973
- renderDetailPanel && !row.getIsGrouped() && (React__default["default"].createElement(MRT_TableDetailPanel, { row: row, table: table }))));
2399
+ renderDetailPanel && !row.getIsGrouped() && (React__default["default"].createElement(MRT_TableDetailPanel, { parentRowRef: rowRef, row: row, table: table, virtualRow: virtualRow }))));
2974
2400
  };
2975
2401
  const Memo_MRT_TableBodyRow = React.memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row);
2976
2402
 
@@ -3010,15 +2436,15 @@ const MRT_TableBody = ({ table }) => {
3010
2436
  pagination.pageSize,
3011
2437
  ]);
3012
2438
  const virtualizer = enableRowVirtualization
3013
- ? 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))
2439
+ ? reactVirtual.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: 4 }, vProps))
3014
2440
  : undefined;
3015
2441
  if (virtualizerInstanceRef && virtualizer) {
3016
2442
  virtualizerInstanceRef.current = virtualizer;
3017
2443
  }
3018
2444
  const virtualRows = virtualizer ? virtualizer.getVirtualItems() : undefined;
3019
- 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
2445
+ 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', minHeight: !rows.length ? '100px' : undefined, position: 'relative' }, ((tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx) instanceof Function
3020
2446
  ? tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx(theme)
3021
- : 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' } },
2447
+ : 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' } },
3022
2448
  React__default["default"].createElement("td", { colSpan: table.getVisibleLeafColumns().length, style: { display: layoutMode === 'grid' ? 'grid' : 'table-cell' } },
3023
2449
  React__default["default"].createElement(Typography__default["default"], { sx: {
3024
2450
  color: 'text.secondary',
@@ -3047,7 +2473,7 @@ const MRT_TableBody = ({ table }) => {
3047
2473
  : undefined,
3048
2474
  };
3049
2475
  return memoMode === 'rows' ? (React__default["default"].createElement(Memo_MRT_TableBodyRow, Object.assign({}, props))) : (React__default["default"].createElement(MRT_TableBodyRow, Object.assign({}, props)));
3050
- })))));
2476
+ }))))));
3051
2477
  };
3052
2478
  const Memo_MRT_TableBody = React.memo(MRT_TableBody, (prev, next) => prev.table.options.data === next.table.options.data);
3053
2479
 
@@ -3495,6 +2921,8 @@ exports.MRT_TablePagination = MRT_TablePagination;
3495
2921
  exports.MRT_ToggleDensePaddingButton = MRT_ToggleDensePaddingButton;
3496
2922
  exports.MRT_ToggleFiltersButton = MRT_ToggleFiltersButton;
3497
2923
  exports.MRT_ToggleGlobalFilterButton = MRT_ToggleGlobalFilterButton;
2924
+ exports.MRT_ToolbarAlertBanner = MRT_ToolbarAlertBanner;
2925
+ exports.MRT_ToolbarDropZone = MRT_ToolbarDropZone;
3498
2926
  exports.MRT_ToolbarInternalButtons = MRT_ToolbarInternalButtons;
3499
2927
  exports["default"] = MaterialReactTable;
3500
2928
  //# sourceMappingURL=index.js.map