@dooherceg/material-react-table 3.2.2-alpha.11 → 3.2.2-alpha.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -534,6 +534,7 @@ type MRT_TableInstance<TData extends MRT_RowData> = Omit<Table<TData>, 'getAllCo
534
534
  setShowProgressBars: Dispatch<SetStateAction<boolean>>;
535
535
  setShowToolbarDropZone: Dispatch<SetStateAction<boolean>>;
536
536
  setShowAdvancedFilters: Dispatch<SetStateAction<boolean>>;
537
+ _showAdvancedFiltersSetterRef: RefObject<Dispatch<SetStateAction<boolean>> | null>;
537
538
  setNewEntryModal: Dispatch<SetStateAction<MRT_NewEntryModalState>>;
538
539
  setRowReorderingSelection: Dispatch<SetStateAction<MRT_RowReorderingSelectionState>>;
539
540
  addRow: (rows: MRT_RowManipulationInput<TData>) => void;
@@ -1564,7 +1565,7 @@ interface MRT_DimensionsDef {
1564
1565
  };
1565
1566
  fieldsPerRow?: number;
1566
1567
  }
1567
- type ExtraFieldFilterOption<TData extends MRT_RowData> = Pick<MRT_ColumnDef<TData>, 'type' | 'accessorKey' | 'header' | 'meta'>;
1568
+ type ExtraFieldFilterOption<TData extends RowData> = Pick<MRT_ColumnDef<TData & MRT_RowData>, 'type' | 'accessorKey' | 'header' | 'meta'>;
1568
1569
  declare module '@tanstack/react-table' {
1569
1570
  interface ColumnMeta<TData extends RowData, TValue> {
1570
1571
  enumValues?: Array<{
@@ -1573,7 +1574,7 @@ declare module '@tanstack/react-table' {
1573
1574
  }>;
1574
1575
  availableIcons?: MRT_AvailableIconOption[];
1575
1576
  dimensions?: MRT_DimensionsDef;
1576
- extraFieldFilters?: TData extends MRT_RowData ? ExtraFieldFilterOption<TData>[] : ExtraFieldFilterOption<MRT_RowData>[];
1577
+ extraFieldFilters?: ExtraFieldFilterOption<TData>[];
1577
1578
  }
1578
1579
  }
1579
1580
 
@@ -1774,8 +1775,9 @@ interface MRT_TableBodyCellProps<TData extends MRT_RowData> extends TableCellPro
1774
1775
  staticColumnIndex?: number;
1775
1776
  staticRowIndex: number;
1776
1777
  table: MRT_TableInstance<TData>;
1778
+ theme: Theme;
1777
1779
  }
1778
- declare const MRT_TableBodyCell: <TData extends MRT_RowData>({ cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table, ...rest }: MRT_TableBodyCellProps<TData>) => react_jsx_runtime.JSX.Element;
1780
+ declare const MRT_TableBodyCell: <TData extends MRT_RowData>({ cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table, theme, ...rest }: MRT_TableBodyCellProps<TData>) => react_jsx_runtime.JSX.Element;
1779
1781
  declare const Memo_MRT_TableBodyCell: typeof MRT_TableBodyCell;
1780
1782
 
1781
1783
  interface MRT_TableBodyCellValueProps<TData extends MRT_RowData> {
@@ -1795,9 +1797,10 @@ interface MRT_TableBodyRowProps<TData extends MRT_RowData> extends TableRowProps
1795
1797
  rowVirtualizer?: MRT_RowVirtualizer;
1796
1798
  staticRowIndex: number;
1797
1799
  table: MRT_TableInstance<TData>;
1800
+ theme: Theme;
1798
1801
  virtualRow?: VirtualItem;
1799
1802
  }
1800
- declare const MRT_TableBodyRow: <TData extends MRT_RowData>({ columnVirtualizer, numRows, pinnedRowIds, row, rowVirtualizer, staticRowIndex, table, virtualRow, ...rest }: MRT_TableBodyRowProps<TData>) => react_jsx_runtime.JSX.Element;
1803
+ declare const MRT_TableBodyRow: <TData extends MRT_RowData>({ columnVirtualizer, numRows, pinnedRowIds, row, rowVirtualizer, staticRowIndex, table, theme, virtualRow, ...rest }: MRT_TableBodyRowProps<TData>) => react_jsx_runtime.JSX.Element;
1801
1804
  declare const Memo_MRT_TableBodyRow: typeof MRT_TableBodyRow;
1802
1805
 
1803
1806
  interface MRT_TableBodyRowGrabHandleProps<TData extends MRT_RowData> extends IconButtonProps {
package/dist/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { compareItems, rankItem, rankings } from '@tanstack/match-sorter-utils';
2
2
  import { sortingFns, flexRender as flexRender$1, createRow as createRow$1, aggregationFns, filterFns, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, useReactTable, functionalUpdate } from '@tanstack/react-table';
3
- import { useMemo, useState, useCallback, useId, useReducer, useRef, useEffect, forwardRef, Fragment as Fragment$1, createContext, useContext, memo, useImperativeHandle } from 'react';
3
+ import { useMemo, useState, useCallback, useId, useReducer, useRef, useEffect, createContext, useContext, forwardRef, Fragment as Fragment$1, memo, useImperativeHandle } from 'react';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
5
  import IconButton from '@mui/material/IconButton';
6
6
  import Tooltip from '@mui/material/Tooltip';
@@ -1946,7 +1946,7 @@ const MRT_DefaultDisplayColumn = {
1946
1946
  };
1947
1947
  const useMRT_TableOptions = (_a) => {
1948
1948
  var _b;
1949
- var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBatchRowSelection = true, enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = true, enableColumnPinning = true, enableColumnResizing = true, enableColumnVirtualization, enableDensityToggle = true, enableExpandAll = true, maxDepth, enableExpanding, enableRowReordering, enableFacetedValues = false, enableFilterMatchHighlighting = true, enableFilters = false, enableAdvancedFilters = true, enableGlobalFilter = false, enableGlobalFilterRankedResults = true, enableGrouping = true, enableHiding = true, enableKeyboardShortcuts = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = true, enableRowSelection = true, enableRowVirtualization, enableSelectAll = true, enableSorting = true, enableStickyHeader = true, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, id = useId(), layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, mrtTheme, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionCreatingRow = 'top', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeDirection", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBatchRowSelection", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableColumnVirtualization", "enableDensityToggle", "enableExpandAll", "maxDepth", "enableExpanding", "enableRowReordering", "enableFacetedValues", "enableFilterMatchHighlighting", "enableFilters", "enableAdvancedFilters", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableKeyboardShortcuts", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableRowVirtualization", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "id", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "mrtTheme", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
1949
+ var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBatchRowSelection = true, enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = true, enableColumnPinning = true, enableColumnResizing = true, enableColumnVirtualization, enableDensityToggle = true, enableExpandAll = true, maxDepth, enableExpanding, enableRowReordering, enableFacetedValues = false, enableFilterMatchHighlighting = true, enableFilters = false, enableAdvancedFilters = true, enableGlobalFilter = false, enableGlobalFilterRankedResults = true, enableGrouping = true, enableHiding = true, enableKeyboardShortcuts = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = true, enableRowSelection = true, enableRowVirtualization = false, enableSelectAll = true, enableSorting = true, enableStickyHeader = true, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, id = useId(), layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, mrtTheme, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionCreatingRow = 'top', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeDirection", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBatchRowSelection", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableColumnVirtualization", "enableDensityToggle", "enableExpandAll", "maxDepth", "enableExpanding", "enableRowReordering", "enableFacetedValues", "enableFilterMatchHighlighting", "enableFilters", "enableAdvancedFilters", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableKeyboardShortcuts", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableRowVirtualization", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "id", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "mrtTheme", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
1950
1950
  const theme = useTheme();
1951
1951
  icons = useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
1952
1952
  localization = useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
@@ -2232,7 +2232,7 @@ const handleRemoveRow = ({ getRowId, setRowsState, }) => {
2232
2232
  * @returns the MRT table instance
2233
2233
  */
2234
2234
  const useMRT_TableInstance = (definedTableOptions) => {
2235
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19;
2235
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
2236
2236
  const lastSelectedRowId = useRef(null);
2237
2237
  const allSelectableRowIdsRef = useRef([]);
2238
2238
  const actionCellRef = useRef(null);
@@ -2294,17 +2294,16 @@ const useMRT_TableInstance = (definedTableOptions) => {
2294
2294
  const [showAlertBanner, setShowAlertBanner] = useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _r !== void 0 ? _r : false);
2295
2295
  const [showColumnFilters, setShowColumnFilters] = useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _s !== void 0 ? _s : false);
2296
2296
  const [showGlobalFilter, setShowGlobalFilter] = useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _t !== void 0 ? _t : false);
2297
- const [showAdvancedFilters, setShowAdvancedFilters] = useState((_u = initialState === null || initialState === void 0 ? void 0 : initialState.showAdvancedFilters) !== null && _u !== void 0 ? _u : Boolean(definedTableOptions.enableAdvancedFilters &&
2298
- definedTableOptions.manualFiltering));
2299
- const [showToolbarDropZone, setShowToolbarDropZone] = useState((_v = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _v !== void 0 ? _v : false);
2300
- const [newEntryModal, setNewEntryModal] = useState((_w = initialState === null || initialState === void 0 ? void 0 : initialState.newEntryModal) !== null && _w !== void 0 ? _w : { open: false });
2301
- const [showProgressBars, setShowProgressBars] = useState((_x = initialState === null || initialState === void 0 ? void 0 : initialState.showProgressBars) !== null && _x !== void 0 ? _x : false);
2297
+ const showAdvancedFiltersSetterRef = useRef(null);
2298
+ const [showToolbarDropZone, setShowToolbarDropZone] = useState((_u = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _u !== void 0 ? _u : false);
2299
+ const [newEntryModal, setNewEntryModal] = useState((_v = initialState === null || initialState === void 0 ? void 0 : initialState.newEntryModal) !== null && _v !== void 0 ? _v : { open: false });
2300
+ const [showProgressBars, setShowProgressBars] = useState((_w = initialState === null || initialState === void 0 ? void 0 : initialState.showProgressBars) !== null && _w !== void 0 ? _w : false);
2302
2301
  // Saved filter presets — initialised from the dedicated option so the consumer
2303
2302
  // can hydrate them from the server response before rendering.
2304
- const [savedFilters, setSavedFilters] = useState((_y = definedTableOptions.initialSavedFilters) !== null && _y !== void 0 ? _y : {});
2303
+ const [savedFilters, setSavedFilters] = useState((_x = definedTableOptions.initialSavedFilters) !== null && _x !== void 0 ? _x : {});
2305
2304
  // Row reordering selection state
2306
- const [rowReorderingSelection, setRowReorderingSelection] = useState((_z = initialState === null || initialState === void 0 ? void 0 : initialState.rowReorderingSelection) !== null && _z !== void 0 ? _z : {});
2307
- const [rows, setRowsState] = useState((_0 = definedTableOptions.data) !== null && _0 !== void 0 ? _0 : []);
2305
+ const [rowReorderingSelection, setRowReorderingSelection] = useState((_y = initialState === null || initialState === void 0 ? void 0 : initialState.rowReorderingSelection) !== null && _y !== void 0 ? _y : {});
2306
+ const [rows, setRowsState] = useState((_z = definedTableOptions.data) !== null && _z !== void 0 ? _z : []);
2308
2307
  definedTableOptions.state = Object.assign({ actionCell,
2309
2308
  columnFilterFns,
2310
2309
  columnOrder,
@@ -2326,7 +2325,6 @@ const useMRT_TableInstance = (definedTableOptions) => {
2326
2325
  showAlertBanner,
2327
2326
  showColumnFilters,
2328
2327
  showGlobalFilter,
2329
- showAdvancedFilters,
2330
2328
  showProgressBars,
2331
2329
  showToolbarDropZone,
2332
2330
  newEntryModal }, definedTableOptions.state);
@@ -2339,39 +2337,67 @@ const useMRT_TableInstance = (definedTableOptions) => {
2339
2337
  }
2340
2338
  //The table options now include all state needed to help determine column visibility and order logic
2341
2339
  const statefulTableOptions = definedTableOptions;
2342
- const resolveRowId = (_1 = statefulTableOptions.getRowId) !== null && _1 !== void 0 ? _1 : ((_originalRow, index, _parentRow) => String(index));
2343
- //don't recompute columnDefs while resizing column or dragging column/row
2344
- const columnDefsRef = useRef([]);
2345
- statefulTableOptions.columns =
2346
- statefulTableOptions.state.columnSizingInfo.isResizingColumn ||
2347
- statefulTableOptions.state.draggingColumn ||
2348
- statefulTableOptions.state.draggingRow
2349
- ? columnDefsRef.current
2350
- : prepareColumns({
2351
- columnDefs: [
2352
- ...[
2353
- showRowPinningColumn(statefulTableOptions) &&
2354
- getMRT_RowPinningColumnDef(statefulTableOptions),
2355
- showRowDragColumn(statefulTableOptions) &&
2356
- getMRT_RowDragColumnDef(statefulTableOptions),
2357
- showRowActionsColumn(statefulTableOptions) &&
2358
- getMRT_RowActionsColumnDef(statefulTableOptions),
2359
- showRowExpandColumn(statefulTableOptions) &&
2360
- getMRT_RowExpandColumnDef(statefulTableOptions),
2361
- showRowSelectionColumn(statefulTableOptions) &&
2362
- getMRT_RowSelectColumnDef(statefulTableOptions),
2363
- showRowNumbersColumn(statefulTableOptions) &&
2364
- getMRT_RowNumbersColumnDef(statefulTableOptions),
2365
- ].filter(Boolean),
2366
- ...statefulTableOptions.columns,
2367
- ...[
2368
- showRowSpacerColumn(statefulTableOptions) &&
2369
- getMRT_RowSpacerColumnDef(statefulTableOptions),
2370
- ].filter(Boolean),
2371
- ],
2372
- tableOptions: statefulTableOptions,
2373
- });
2374
- columnDefsRef.current = statefulTableOptions.columns;
2340
+ const resolveRowId = (_0 = statefulTableOptions.getRowId) !== null && _0 !== void 0 ? _0 : ((_originalRow, index, _parentRow) => String(index));
2341
+ //keep the prepared column tree referentially stable so TanStack's
2342
+ //getAllColumns/getAllLeafColumns/row.getAllCells memo chain doesn't
2343
+ //recompute (and recreate every cell of every row) on unrelated renders
2344
+ //like hover, menu open/close, or density toggle
2345
+ const rawColumns = statefulTableOptions.columns;
2346
+ const { aggregationFns, createDisplayMode, defaultDisplayColumn, displayColumnDefOptions, editDisplayMode, enableEditing, enableExpanding, enableGrouping, enableRowActions, enableRowDragging, enableRowNumbers, enableRowOrdering, enableRowPinning, enableRowSelection, filterFns, layoutMode, localization, renderDetailPanel, rowNumberDisplayMode, rowPinningDisplayMode, sortingFns, } = statefulTableOptions;
2347
+ //read from the final merged state (consumers/MaterialReactServerTableInstance
2348
+ //may control these via the `state` option, which overrides the internal
2349
+ //useState values above)
2350
+ const { columnFilterFns: stateColumnFilterFns, creatingRow: stateCreatingRow, grouping: stateGrouping, } = statefulTableOptions.state;
2351
+ statefulTableOptions.columns = useMemo(() => prepareColumns({
2352
+ columnDefs: [
2353
+ ...[
2354
+ showRowPinningColumn(statefulTableOptions) &&
2355
+ getMRT_RowPinningColumnDef(statefulTableOptions),
2356
+ showRowDragColumn(statefulTableOptions) &&
2357
+ getMRT_RowDragColumnDef(statefulTableOptions),
2358
+ showRowActionsColumn(statefulTableOptions) &&
2359
+ getMRT_RowActionsColumnDef(statefulTableOptions),
2360
+ showRowExpandColumn(statefulTableOptions) &&
2361
+ getMRT_RowExpandColumnDef(statefulTableOptions),
2362
+ showRowSelectionColumn(statefulTableOptions) &&
2363
+ getMRT_RowSelectColumnDef(statefulTableOptions),
2364
+ showRowNumbersColumn(statefulTableOptions) &&
2365
+ getMRT_RowNumbersColumnDef(statefulTableOptions),
2366
+ ].filter(Boolean),
2367
+ ...rawColumns,
2368
+ ...[
2369
+ showRowSpacerColumn(statefulTableOptions) &&
2370
+ getMRT_RowSpacerColumnDef(statefulTableOptions),
2371
+ ].filter(Boolean),
2372
+ ],
2373
+ tableOptions: statefulTableOptions,
2374
+ }), [
2375
+ rawColumns,
2376
+ aggregationFns,
2377
+ createDisplayMode,
2378
+ defaultDisplayColumn,
2379
+ displayColumnDefOptions,
2380
+ editDisplayMode,
2381
+ enableEditing,
2382
+ enableExpanding,
2383
+ enableGrouping,
2384
+ enableRowActions,
2385
+ enableRowDragging,
2386
+ enableRowNumbers,
2387
+ enableRowOrdering,
2388
+ enableRowPinning,
2389
+ enableRowSelection,
2390
+ filterFns,
2391
+ layoutMode,
2392
+ localization,
2393
+ renderDetailPanel,
2394
+ rowNumberDisplayMode,
2395
+ rowPinningDisplayMode,
2396
+ sortingFns,
2397
+ stateColumnFilterFns,
2398
+ stateCreatingRow,
2399
+ stateGrouping,
2400
+ ]);
2375
2401
  //if loading, generate blank rows to show skeleton loaders
2376
2402
  statefulTableOptions.data = useMemo(() => (statefulTableOptions.state.isLoading ||
2377
2403
  statefulTableOptions.state.showSkeletons) &&
@@ -2390,7 +2416,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
2390
2416
  const table = useReactTable(Object.assign(Object.assign({ onColumnOrderChange,
2391
2417
  onColumnSizingInfoChange,
2392
2418
  onGroupingChange,
2393
- onPaginationChange }, statefulTableOptions), { globalFilterFn: (_2 = statefulTableOptions.filterFns) === null || _2 === void 0 ? void 0 : _2[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
2419
+ onPaginationChange }, statefulTableOptions), { globalFilterFn: (_1 = statefulTableOptions.filterFns) === null || _1 === void 0 ? void 0 : _1[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
2394
2420
  table.refs = {
2395
2421
  actionCellRef,
2396
2422
  allSelectableRowIdsRef,
@@ -2407,7 +2433,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
2407
2433
  topToolbarRef,
2408
2434
  };
2409
2435
  table.setActionCell =
2410
- (_3 = statefulTableOptions.onActionCellChange) !== null && _3 !== void 0 ? _3 : setActionCell;
2436
+ (_2 = statefulTableOptions.onActionCellChange) !== null && _2 !== void 0 ? _2 : setActionCell;
2411
2437
  table.setCreatingRow = (row) => {
2412
2438
  var _a, _b;
2413
2439
  let _row = row;
@@ -2417,38 +2443,39 @@ const useMRT_TableInstance = (definedTableOptions) => {
2417
2443
  (_b = (_a = statefulTableOptions === null || statefulTableOptions === void 0 ? void 0 : statefulTableOptions.onCreatingRowChange) === null || _a === void 0 ? void 0 : _a.call(statefulTableOptions, _row)) !== null && _b !== void 0 ? _b : _setCreatingRow(_row);
2418
2444
  };
2419
2445
  table.setColumnFilterFns =
2420
- (_4 = statefulTableOptions.onColumnFilterFnsChange) !== null && _4 !== void 0 ? _4 : setColumnFilterFns;
2421
- table.setDensity = (_5 = statefulTableOptions.onDensityChange) !== null && _5 !== void 0 ? _5 : setDensity;
2446
+ (_3 = statefulTableOptions.onColumnFilterFnsChange) !== null && _3 !== void 0 ? _3 : setColumnFilterFns;
2447
+ table.setDensity = (_4 = statefulTableOptions.onDensityChange) !== null && _4 !== void 0 ? _4 : setDensity;
2422
2448
  table.setDraggingColumn =
2423
- (_6 = statefulTableOptions.onDraggingColumnChange) !== null && _6 !== void 0 ? _6 : setDraggingColumn;
2449
+ (_5 = statefulTableOptions.onDraggingColumnChange) !== null && _5 !== void 0 ? _5 : setDraggingColumn;
2424
2450
  table.setDraggingRow =
2425
- (_7 = statefulTableOptions.onDraggingRowChange) !== null && _7 !== void 0 ? _7 : setDraggingRow;
2451
+ (_6 = statefulTableOptions.onDraggingRowChange) !== null && _6 !== void 0 ? _6 : setDraggingRow;
2426
2452
  table.setEditingCell =
2427
- (_8 = statefulTableOptions.onEditingCellChange) !== null && _8 !== void 0 ? _8 : setEditingCell;
2453
+ (_7 = statefulTableOptions.onEditingCellChange) !== null && _7 !== void 0 ? _7 : setEditingCell;
2428
2454
  table.setEditingRow =
2429
- (_9 = statefulTableOptions.onEditingRowChange) !== null && _9 !== void 0 ? _9 : setEditingRow;
2430
- table.setFilters = (_10 = statefulTableOptions.onFiltersChange) !== null && _10 !== void 0 ? _10 : setFilters;
2455
+ (_8 = statefulTableOptions.onEditingRowChange) !== null && _8 !== void 0 ? _8 : setEditingRow;
2456
+ table.setFilters = (_9 = statefulTableOptions.onFiltersChange) !== null && _9 !== void 0 ? _9 : setFilters;
2431
2457
  table.setGlobalFilterFn =
2432
- (_11 = statefulTableOptions.onGlobalFilterFnChange) !== null && _11 !== void 0 ? _11 : setGlobalFilterFn;
2458
+ (_10 = statefulTableOptions.onGlobalFilterFnChange) !== null && _10 !== void 0 ? _10 : setGlobalFilterFn;
2433
2459
  table.setHoveredColumn =
2434
- (_12 = statefulTableOptions.onHoveredColumnChange) !== null && _12 !== void 0 ? _12 : setHoveredColumn;
2460
+ (_11 = statefulTableOptions.onHoveredColumnChange) !== null && _11 !== void 0 ? _11 : setHoveredColumn;
2435
2461
  table.setHoveredRow =
2436
- (_13 = statefulTableOptions.onHoveredRowChange) !== null && _13 !== void 0 ? _13 : setHoveredRow;
2462
+ (_12 = statefulTableOptions.onHoveredRowChange) !== null && _12 !== void 0 ? _12 : setHoveredRow;
2437
2463
  table.setSavedFilters = setSavedFilters;
2438
2464
  table.setShowAlertBanner =
2439
- (_14 = statefulTableOptions.onShowAlertBannerChange) !== null && _14 !== void 0 ? _14 : setShowAlertBanner;
2465
+ (_13 = statefulTableOptions.onShowAlertBannerChange) !== null && _13 !== void 0 ? _13 : setShowAlertBanner;
2466
+ table._showAdvancedFiltersSetterRef = showAdvancedFiltersSetterRef;
2440
2467
  table.setShowAdvancedFilters =
2441
- (_15 = statefulTableOptions.onShowAdvancedFiltersChange) !== null && _15 !== void 0 ? _15 : setShowAdvancedFilters;
2468
+ (_14 = statefulTableOptions.onShowAdvancedFiltersChange) !== null && _14 !== void 0 ? _14 : ((updater) => { var _a; return (_a = showAdvancedFiltersSetterRef.current) === null || _a === void 0 ? void 0 : _a.call(showAdvancedFiltersSetterRef, updater); });
2442
2469
  table.setShowColumnFilters =
2443
- (_16 = statefulTableOptions.onShowColumnFiltersChange) !== null && _16 !== void 0 ? _16 : setShowColumnFilters;
2470
+ (_15 = statefulTableOptions.onShowColumnFiltersChange) !== null && _15 !== void 0 ? _15 : setShowColumnFilters;
2444
2471
  table.setShowGlobalFilter =
2445
- (_17 = statefulTableOptions.onShowGlobalFilterChange) !== null && _17 !== void 0 ? _17 : setShowGlobalFilter;
2472
+ (_16 = statefulTableOptions.onShowGlobalFilterChange) !== null && _16 !== void 0 ? _16 : setShowGlobalFilter;
2446
2473
  table.setShowProgressBars = setShowProgressBars;
2447
2474
  table.setShowToolbarDropZone =
2448
- (_18 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _18 !== void 0 ? _18 : setShowToolbarDropZone;
2475
+ (_17 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _17 !== void 0 ? _17 : setShowToolbarDropZone;
2449
2476
  table.setNewEntryModal = setNewEntryModal;
2450
2477
  table.setRowReorderingSelection =
2451
- (_19 = statefulTableOptions.onRowReorderingSelectionChange) !== null && _19 !== void 0 ? _19 : setRowReorderingSelection;
2478
+ (_18 = statefulTableOptions.onRowReorderingSelectionChange) !== null && _18 !== void 0 ? _18 : setRowReorderingSelection;
2452
2479
  table.addRow = handleAddRow({
2453
2480
  setRowsState,
2454
2481
  getRowId: resolveRowId,
@@ -2589,7 +2616,10 @@ const useMRT_RowVirtualizer = (table, rows) => {
2589
2616
  ? realRows.findIndex((r) => r.id === (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id))
2590
2617
  : undefined, [realRows, draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id]);
2591
2618
  const rowCount = realRows.length;
2592
- const normalRowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 58 : 73;
2619
+ //matches the defaultRowHeight assumption in MRT_TableBodyRow so the
2620
+ //initial estimate (before measureElement corrects it for dynamic content)
2621
+ //doesn't cause scroll-position drift
2622
+ const normalRowHeight = density === 'compact' ? 37 : density === 'comfortable' ? 53 : 69;
2593
2623
  const rowVirtualizer = useVirtualizer(Object.assign({ count: renderDetailPanel ? rowCount * 2 : rowCount, estimateSize: (index) => renderDetailPanel && index % 2 === 1
2594
2624
  ? expanded === true
2595
2625
  ? 100
@@ -2609,6 +2639,20 @@ const useMRT_RowVirtualizer = (table, rows) => {
2609
2639
  return rowVirtualizer;
2610
2640
  };
2611
2641
 
2642
+ const MRT_AdvancedFiltersContext = createContext(null);
2643
+ const useMRT_AdvancedFiltersContext = () => {
2644
+ const ctx = useContext(MRT_AdvancedFiltersContext);
2645
+ if (!ctx)
2646
+ throw new Error('useMRT_AdvancedFiltersContext must be used within MRT_AdvancedFiltersProvider');
2647
+ return ctx;
2648
+ };
2649
+ const MRT_AdvancedFiltersProvider = ({ children, initialOpen = false, setterRef, }) => {
2650
+ const [showAdvancedFilters, setShowAdvancedFilters] = useState(initialOpen);
2651
+ // Always keep ref in sync so table.setShowAdvancedFilters works externally
2652
+ setterRef.current = setShowAdvancedFilters;
2653
+ return (jsx(MRT_AdvancedFiltersContext.Provider, { value: { showAdvancedFilters, setShowAdvancedFilters }, children: children }));
2654
+ };
2655
+
2612
2656
  // Internal Select option value strings — converted to/from actual boolean in RHF state.
2613
2657
  const BOOLEAN_OPTION_TRUE = 'true';
2614
2658
  const BOOLEAN_OPTION_FALSE = 'false';
@@ -4370,7 +4414,7 @@ const MRT_AdvancedFiltersRuleRow = ({ filterableColumns, isFirst, isPinned, logi
4370
4414
  xs: 'auto minmax(0, 1fr) minmax(0, 0.7fr) minmax(0, 1.5fr) auto auto',
4371
4415
  },
4372
4416
  width: '100%',
4373
- }, children: [jsxs(TextField, { disabled: !isFirst, fullWidth: true, onChange: (event) => onUpdateLogicOperator(event.target.value), select: true, size: "small", value: logicOperator, variant: "outlined", children: [jsx(MenuItem, { value: "and", children: localization.and }), jsx(MenuItem, { value: "or", children: localization.or })] }), jsx(TextField, { fullWidth: true, label: localization.columns, onChange: (event) => handleColumnChange(event.target.value), select: true, size: "small", value: selectedColumn.id, variant: "outlined", children: filterableColumns.map((column) => (jsx(MenuItem, { value: column.id, children: column.columnDef.header || localization[column.id] || column.id }, column.id))) }), jsx(TextField, { fullWidth: true, label: localization.filterOperator, onChange: (event) => handleOperatorChange(event.target.value), select: true, size: "small", value: selectedOperator.id, variant: "outlined", children: availableOperators.map((operator) => (jsx(MenuItem, { value: operator.id, children: getLocalizedFilterOperatorLabel(localization, operator.id, operator.label) }, operator.id))) }), jsx(Box, { "data-testid": FILTER_RULE_VALUE_TEST_ID, onKeyDown: (event) => {
4417
+ }, children: [jsxs(TextField, { disabled: !isFirst, fullWidth: true, onChange: (event) => onUpdateLogicOperator(event.target.value), select: true, size: "small", value: logicOperator, variant: "outlined", "data-testid": "logic-operator", children: [jsx(MenuItem, { value: "and", children: localization.and }), jsx(MenuItem, { value: "or", children: localization.or })] }), jsx(TextField, { fullWidth: true, label: localization.columns, onChange: (event) => handleColumnChange(event.target.value), select: true, size: "small", value: selectedColumn.id, variant: "outlined", children: filterableColumns.map((column) => (jsx(MenuItem, { value: column.id, children: column.columnDef.header || localization[column.id] || column.id }, column.id))) }), jsx(TextField, { fullWidth: true, label: localization.filterOperator, onChange: (event) => handleOperatorChange(event.target.value), select: true, size: "small", value: selectedOperator.id, variant: "outlined", children: availableOperators.map((operator) => (jsx(MenuItem, { value: operator.id, children: getLocalizedFilterOperatorLabel(localization, operator.id, operator.label) }, operator.id))) }), jsx(Box, { "data-testid": FILTER_RULE_VALUE_TEST_ID, onKeyDown: (event) => {
4374
4418
  const shouldApplyOnEnter = selectedOperator.valueShape !== 'multi';
4375
4419
  if (event.key === 'Enter' && onApply && shouldApplyOnEnter) {
4376
4420
  // Prevent the Enter from bubbling to MUI Drawer/Modal infrastructure
@@ -4596,8 +4640,8 @@ const useMRT_AdvancedFiltersDraft = (table) => {
4596
4640
  * Extracted so that hooks are never called conditionally in the parent guard.
4597
4641
  */
4598
4642
  const MRT_AdvancedFiltersContent = ({ table, }) => {
4599
- const { getState, options: { icons: { CloseIcon }, localization, }, setFilters, setShowAdvancedFilters, } = table;
4600
- const { showAdvancedFilters } = getState();
4643
+ const { options: { icons: { CloseIcon }, localization, }, setFilters, } = table;
4644
+ const { showAdvancedFilters, setShowAdvancedFilters } = useMRT_AdvancedFiltersContext();
4601
4645
  // All draft editing logic lives in this hook
4602
4646
  const { addRule, clearRules, discardChanges, draftFilters, filterableColumns, hasInvalidRules, hasUnappliedChanges, markApplied, pinRule, removeRule, unpinRule, updateLogicOperator, updateRule, } = useMRT_AdvancedFiltersDraft(table);
4603
4647
  // Close the drawer without applying changes
@@ -5373,7 +5417,7 @@ const MRT_SavedFiltersButton = ({ onSelectFilter, table, }) => {
5373
5417
  justifyContent: 'space-between',
5374
5418
  gap: 1,
5375
5419
  minWidth: 180,
5376
- }, children: [jsx(ListItemText, { onClick: () => handleSelectFilter(savedFilter), primary: savedFilter.name, sx: { cursor: 'pointer', flexGrow: 1 } }), onDeleteSavedFilter && (jsxs(Fragment, { children: [jsx(Divider, { flexItem: true, orientation: "vertical" }), jsx(DeleteForeverIcon, { color: "error", fontSize: "small", onClick: (event) => {
5420
+ }, children: [jsx(ListItemText, { onClick: () => handleSelectFilter(savedFilter), primary: savedFilter.name, sx: { cursor: 'pointer', flexGrow: 1 }, "data-testid": "saved-filter-item" }), onDeleteSavedFilter && (jsxs(Fragment, { children: [jsx(Divider, { flexItem: true, orientation: "vertical" }), jsx(DeleteForeverIcon, { color: "error", fontSize: "small", onClick: (event) => {
5377
5421
  event.stopPropagation();
5378
5422
  handleDeleteFilter(savedFilter.name);
5379
5423
  }, sx: { cursor: 'pointer', flexShrink: 0 } })] }))] }, savedFilter.name)))] })] }));
@@ -5534,21 +5578,24 @@ const MRT_ShowHideColumnsButton = (_a) => {
5534
5578
  return (jsxs(Fragment, { children: [jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideColumns, children: jsx(Button, Object.assign({ "aria-label": localization.showHideColumns, onClick: handleClick, size: "small", startIcon: jsx(ViewColumnIcon, { fontSize: "small" }), variant: "text" }, rest, { title: undefined, children: localization.showHideColumns })) }), anchorEl && (jsx(MRT_ShowHideColumnsMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table }))] }));
5535
5579
  };
5536
5580
 
5537
- const MRT_ToggleAdvancedFiltersButton = (_a) => {
5581
+ const MRT_ToggleAdvancedFiltersButtonInner = (_a) => {
5538
5582
  var _b;
5539
5583
  var { table } = _a, rest = __rest(_a, ["table"]);
5540
- const { getState, options: { icons: { FilterListIcon, FilterListOffIcon }, localization, manualFiltering, }, setShowAdvancedFilters, } = table;
5541
- const { filters, showAdvancedFilters } = getState();
5584
+ const { getState, options: { icons: { FilterListIcon, FilterListOffIcon }, localization, manualFiltering, }, } = table;
5585
+ const { filters } = getState();
5586
+ const { showAdvancedFilters, setShowAdvancedFilters } = useMRT_AdvancedFiltersContext();
5542
5587
  if (!manualFiltering) {
5543
5588
  return null;
5544
5589
  }
5545
- // Count applied filter rules to display on the badge
5546
5590
  const activeFilterCount = filters.rules.length;
5547
- const handleToggleShowAdvancedFilters = () => {
5548
- setShowAdvancedFilters((prev) => !prev);
5549
- };
5550
5591
  const FilterIcon = showAdvancedFilters ? FilterListOffIcon : FilterListIcon;
5551
- return (jsxs(Fragment, { children: [jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showAdvancedFilters, children: jsx(Badge, { badgeContent: activeFilterCount, color: "primary", invisible: activeFilterCount === 0, children: jsx(Button, Object.assign({ "aria-label": localization.showAdvancedFilters, onClick: handleToggleShowAdvancedFilters, size: "small", startIcon: jsx(FilterIcon, {}), variant: "text" }, rest, { title: undefined, children: localization.filters })) }) }), jsx(MRT_AdvancedFilters, { table: table })] }));
5592
+ return (jsxs(Fragment, { children: [jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showAdvancedFilters, children: jsx(Badge, { badgeContent: activeFilterCount, color: "primary", invisible: activeFilterCount === 0, children: jsx(Button, Object.assign({ "aria-label": localization.showAdvancedFilters, onClick: () => setShowAdvancedFilters((prev) => !prev), size: "small", startIcon: jsx(FilterIcon, {}), variant: "text" }, rest, { title: undefined, children: localization.filters })) }) }), jsx(MRT_AdvancedFilters, { table: table })] }));
5593
+ };
5594
+ const MRT_ToggleAdvancedFiltersButton = (_a) => {
5595
+ var _b, _c;
5596
+ var { table } = _a, rest = __rest(_a, ["table"]);
5597
+ const initialOpen = (_c = (_b = table.options.initialState) === null || _b === void 0 ? void 0 : _b.showAdvancedFilters) !== null && _c !== void 0 ? _c : Boolean(table.options.enableAdvancedFilters && table.options.manualFiltering);
5598
+ return (jsx(MRT_AdvancedFiltersProvider, { initialOpen: initialOpen, setterRef: table._showAdvancedFiltersSetterRef, children: jsx(MRT_ToggleAdvancedFiltersButtonInner, Object.assign({ table: table }, rest)) }));
5552
5599
  };
5553
5600
 
5554
5601
  const MRT_ToggleDensePaddingButton = (_a) => {
@@ -6435,8 +6482,7 @@ const MRT_TableBodyCellValue = ({ cell, rowRef, staticColumnIndex, staticRowInde
6435
6482
 
6436
6483
  const MRT_TableBodyCell = (_a) => {
6437
6484
  var _b, _c, _d, _e;
6438
- var { cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table"]);
6439
- const theme = useTheme();
6485
+ var { cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table, theme } = _a, rest = __rest(_a, ["cell", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table", "theme"]);
6440
6486
  const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableCellActions, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableGrouping, enableKeyboardShortcuts, layoutMode, mrtTheme: { draggingBorderColor }, muiSkeletonProps, muiTableBodyCellProps, }, setHoveredColumn, } = table;
6441
6487
  const { actionCell, columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
6442
6488
  const { column, row } = cell;
@@ -6635,8 +6681,7 @@ const MRT_TableDetailPanel = (_a) => {
6635
6681
 
6636
6682
  const MRT_TableBodyRow = (_a) => {
6637
6683
  var _b, _c, _d, _f;
6638
- var { columnVirtualizer, numRows, pinnedRowIds, row, rowVirtualizer, staticRowIndex, table, virtualRow } = _a, rest = __rest(_a, ["columnVirtualizer", "numRows", "pinnedRowIds", "row", "rowVirtualizer", "staticRowIndex", "table", "virtualRow"]);
6639
- const theme = useTheme();
6684
+ var { columnVirtualizer, numRows, pinnedRowIds, row, rowVirtualizer, staticRowIndex, table, theme, virtualRow } = _a, rest = __rest(_a, ["columnVirtualizer", "numRows", "pinnedRowIds", "row", "rowVirtualizer", "staticRowIndex", "table", "theme", "virtualRow"]);
6640
6685
  const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, memoMode, mrtTheme: { baseBackgroundColor, pinnedRowBackgroundColor, selectedRowBackgroundColor, }, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
6641
6686
  const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, rowPinning, } = getState();
6642
6687
  const visibleCells = row.getVisibleCells();
@@ -6701,7 +6746,11 @@ const MRT_TableBodyRow = (_a) => {
6701
6746
  ? Object.assign({ backgroundColor: alpha(cellHighlightColorHover, 0.3) }, commonCellBeforeAfterStyles) : undefined, backgroundColor: `${baseBackgroundColor} !important`, bottom: !virtualRow && bottomPinnedIndex !== undefined && isRowPinned
6702
6747
  ? `${bottomPinnedIndex * rowHeight +
6703
6748
  (enableStickyFooter ? tableFooterHeight - 1 : 0)}px`
6704
- : undefined, boxSizing: 'border-box', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, opacity: isRowPinned ? 0.97 : isDraggingRow || isHoveredRow ? 0.5 : 1, position: virtualRow
6749
+ : undefined, boxSizing: 'border-box', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, opacity: isRowPinned ? 0.97 : isDraggingRow || isHoveredRow ? 0.5 : 1,
6750
+ //prevents the browser from "anchoring" scroll position to this
6751
+ //row as virtualized rows are recycled in and out — see
6752
+ //tanstack/virtual#860
6753
+ overflowAnchor: virtualRow ? 'none' : undefined, position: virtualRow
6705
6754
  ? 'absolute'
6706
6755
  : (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isRowPinned
6707
6756
  ? 'sticky'
@@ -6724,6 +6773,7 @@ const MRT_TableBodyRow = (_a) => {
6724
6773
  staticColumnIndex,
6725
6774
  staticRowIndex,
6726
6775
  table,
6776
+ theme,
6727
6777
  };
6728
6778
  const key = `${cell.id}-${staticRowIndex}`;
6729
6779
  return cell ? (memoMode === 'cells' &&
@@ -6741,6 +6791,10 @@ const MRT_TableBody = (_a) => {
6741
6791
  var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
6742
6792
  const { getBottomRows, getIsSomeRowsPinned, getRowModel, getState, getTopRows, options: { enableStickyFooter, enableStickyHeader, layoutMode, localization, memoMode, muiTableBodyProps, renderDetailPanel, renderEmptyRowsFallback, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef, tablePaperRef }, } = table;
6743
6793
  const { columnFilters, globalFilter, rowPinning } = getState();
6794
+ //read once per body render instead of once per row/cell, since every
6795
+ //subscriber otherwise pays its own useContext lookup on every mount
6796
+ //(noticeable when a burst of new rows mounts on a fast scroll jump)
6797
+ const theme = useTheme();
6744
6798
  const tableBodyProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyProps, { table })), rest);
6745
6799
  const tableHeadHeight = (enableStickyHeader && ((_b = tableHeadRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) || 0;
6746
6800
  const tableFooterHeight = (enableStickyFooter && ((_c = tableFooterRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight)) || 0;
@@ -6759,6 +6813,7 @@ const MRT_TableBody = (_a) => {
6759
6813
  columnVirtualizer,
6760
6814
  numRows: rows.length,
6761
6815
  table,
6816
+ theme,
6762
6817
  };
6763
6818
  return (jsxs(Fragment, { children: [!(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
6764
6819
  getIsSomeRowsPinned('top') && (jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'sticky', top: tableHeadHeight - 1, zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getTopRows().map((row, staticRowIndex) => {
@@ -7475,7 +7530,7 @@ const MRT_Table = (_a) => {
7475
7530
  columnVirtualizer,
7476
7531
  table,
7477
7532
  };
7478
- return (jsxs(Table, Object.assign({ stickyHeader: enableStickyHeader }, tableProps, { style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, overflow: 'auto', position: 'relative' }, parseFromValuesOrFunc(tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx, theme))), children: [!!Caption && jsx("caption", { children: Caption }), enableTableHead && jsx(MRT_TableHead, Object.assign({}, commonTableGroupProps)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsx(Memo_MRT_TableBody, Object.assign({}, commonTableGroupProps))) : (jsx(MRT_TableBody, Object.assign({}, commonTableGroupProps))), enableTableFooter && jsx(MRT_TableFooter, Object.assign({}, commonTableGroupProps))] })));
7533
+ return (jsxs(Table, Object.assign({ stickyHeader: enableStickyHeader }, tableProps, { style: Object.assign(Object.assign({}, columnSizeVars), tableProps === null || tableProps === void 0 ? void 0 : tableProps.style), sx: (theme) => (Object.assign({ borderCollapse: 'separate', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'relative' }, parseFromValuesOrFunc(tableProps === null || tableProps === void 0 ? void 0 : tableProps.sx, theme))), children: [!!Caption && jsx("caption", { children: Caption }), enableTableHead && jsx(MRT_TableHead, Object.assign({}, commonTableGroupProps)), memoMode === 'table-body' || columnSizingInfo.isResizingColumn ? (jsx(Memo_MRT_TableBody, Object.assign({}, commonTableGroupProps))) : (jsx(MRT_TableBody, Object.assign({}, commonTableGroupProps))), enableTableFooter && jsx(MRT_TableFooter, Object.assign({}, commonTableGroupProps))] })));
7479
7534
  };
7480
7535
 
7481
7536
  const MRT_TableLoadingOverlay = (_a) => {
@@ -7501,7 +7556,7 @@ const MRT_TableLoadingOverlay = (_a) => {
7501
7556
 
7502
7557
  const MRT_TableContainer = (_a) => {
7503
7558
  var { table } = _a, rest = __rest(_a, ["table"]);
7504
- const { getState, options: { createDisplayMode, editDisplayMode, enableCellActions, muiTableContainerProps, }, refs: { tableContainerRef }, } = table;
7559
+ const { getState, options: { createDisplayMode, editDisplayMode, enableCellActions, enableRowVirtualization, muiTableContainerProps, }, refs: { tableContainerRef }, } = table;
7505
7560
  const { actionCell, creatingRow, editingRow, isLoading, showLoadingOverlay, newEntryModal, } = getState();
7506
7561
  const loading = showLoadingOverlay !== false && (isLoading || showLoadingOverlay);
7507
7562
  const tableContainerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableContainerProps, {
@@ -7517,7 +7572,9 @@ const MRT_TableContainer = (_a) => {
7517
7572
  tableContainerProps.ref.current = node;
7518
7573
  }
7519
7574
  }
7520
- }, style: Object.assign({}, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style), sx: (theme) => (Object.assign({ flex: '1 1 auto', height: '100%', display: 'flex', flexDirection: 'column', maxWidth: '100%', overflow: 'auto', position: 'relative' }, parseFromValuesOrFunc(tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx, theme))), children: [loading ? jsx(MRT_TableLoadingOverlay, { table: table }) : null, jsx(MRT_Table, { table: table }), (createModalOpen || editModalOpen) && (jsx(MRT_EditRowModal, { open: true, table: table })), newEntryModal.open && jsx(MRT_NewEntryModal, { table: table }), enableCellActions && actionCell && jsx(MRT_CellActionMenu, { table: table })] })));
7575
+ }, style: Object.assign({}, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style), sx: (theme) => (Object.assign(Object.assign({ flex: '1 1 auto', height: '100%', display: 'flex', flexDirection: 'column', maxWidth: '100%', overflow: 'auto', position: 'relative' }, (enableRowVirtualization
7576
+ ? { contain: 'paint', willChange: 'transform' }
7577
+ : null)), parseFromValuesOrFunc(tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx, theme))), children: [loading ? jsx(MRT_TableLoadingOverlay, { table: table }) : null, jsx(MRT_Table, { table: table }), (createModalOpen || editModalOpen) && (jsx(MRT_EditRowModal, { open: true, table: table })), newEntryModal.open && jsx(MRT_NewEntryModal, { table: table }), enableCellActions && actionCell && jsx(MRT_CellActionMenu, { table: table })] })));
7521
7578
  };
7522
7579
 
7523
7580
  const MRT_TablePaper = (_a) => {
@@ -7843,7 +7900,7 @@ const buildInitialExportState = (availableExports, savedActiveExports) => {
7843
7900
  });
7844
7901
  };
7845
7902
  const MaterialReactServerTableInstance = (_a) => {
7846
- var _b;
7903
+ var _b, _c;
7847
7904
  var { config, loadData, saveState, getAllSelectableRowIds, getTotalRows, onSaveFilters, onDeleteSavedFilter, initialSavedFilters, loadExport, exportPermissions, enableNewEntryButton, actions, deleteRowsFn, editRowFn, enableResetState, resetState } = _a,
7848
7905
  // Extra MRT_TableOptions props (e.g. formConfig) passed directly through to useMaterialReactTable
7849
7906
  tableOptionsOverrides = __rest(_a, ["config", "loadData", "saveState", "getAllSelectableRowIds", "getTotalRows", "onSaveFilters", "onDeleteSavedFilter", "initialSavedFilters", "loadExport", "exportPermissions", "enableNewEntryButton", "actions", "deleteRowsFn", "editRowFn", "enableResetState", "resetState"]);
@@ -7889,8 +7946,7 @@ const MaterialReactServerTableInstance = (_a) => {
7889
7946
  resetState, enableRowActions: true, renderRowActions: RowActionsCell, positionActionsColumn: 'last', actions: actions, getAllSelectableRowIds, getTotalRows: wrappedGetTotalRows, deleteRowsFn,
7890
7947
  editRowFn,
7891
7948
  onSaveFilters,
7892
- onDeleteSavedFilter,
7893
- initialSavedFilters, availableExports: hasAvailableExports ? allowedExports : undefined, loadExport: hasAvailableExports ? loadExport : undefined, enableNewEntryButton }, tableOptionsOverrides), handlers));
7949
+ onDeleteSavedFilter, initialSavedFilters: initialSavedFilters !== null && initialSavedFilters !== void 0 ? initialSavedFilters : (_c = config.initialState) === null || _c === void 0 ? void 0 : _c.savedFilters, availableExports: hasAvailableExports ? allowedExports : undefined, loadExport: hasAvailableExports ? loadExport : undefined, enableNewEntryButton }, tableOptionsOverrides), handlers));
7894
7950
  const fetchData = useCallback((tableInstance) => __awaiter(void 0, void 0, void 0, function* () {
7895
7951
  setIsLoading(true);
7896
7952
  try {