@dooherceg/material-react-table 3.2.2-alpha.9 → 3.2.3

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;
@@ -579,13 +580,6 @@ interface MRT_TableState<TData extends MRT_RowData> extends TableState {
579
580
  rowReorderingSelection: MRT_RowReorderingSelectionState;
580
581
  }
581
582
  interface MRT_ColumnDefBase<TData extends MRT_RowData, TValue = unknown> extends Omit<ColumnDef<TData, TValue>, 'accessorKey' | 'aggregatedCell' | 'aggregationFn' | 'cell' | 'columns' | 'filterFn' | 'footer' | 'header' | 'id' | 'sortingFn'> {
582
- /**
583
- * Either an `accessorKey` or a combination of an `accessorFn` and `id` are required for a data column definition.
584
- * Specify a function here to point to the correct property in the data object.
585
- *
586
- * @example accessorFn: (row) => row.username
587
- */
588
- accessorFn?: (originalRow: TData) => TValue;
589
583
  /**
590
584
  * Either an `accessorKey` or a combination of an `accessorFn` and `id` are required for a data column definition.
591
585
  * Specify which key in the row this column should use to access the correct data.
@@ -594,7 +588,7 @@ interface MRT_ColumnDefBase<TData extends MRT_RowData, TValue = unknown> extends
594
588
  * @example accessorKey: 'username' //simple
595
589
  * @example accessorKey: 'name.firstName' //deep key dot notation
596
590
  */
597
- accessorKey?: DeepKeys<TData> | (string & {});
591
+ accessorKey: DeepKeys<TData> | (string & {});
598
592
  AggregatedCell?: (props: {
599
593
  cell: MRT_Cell<TData, TValue>;
600
594
  column: MRT_Column<TData, TValue>;
@@ -1555,7 +1549,7 @@ interface MRT_FormSectionConfig {
1555
1549
  interface IIconColTypeValue {
1556
1550
  color: string;
1557
1551
  description: string;
1558
- iconCode: string;
1552
+ iconCode: number;
1559
1553
  additional?: Record<string, Omit<IIconColTypeValue, 'additional'>>;
1560
1554
  }
1561
1555
  type MRT_AvailableIconOption = {
@@ -1571,7 +1565,7 @@ interface MRT_DimensionsDef {
1571
1565
  };
1572
1566
  fieldsPerRow?: number;
1573
1567
  }
1574
- type MRT_ColumnMetaExtraFieldFilters<TData extends RowData> = TData extends MRT_RowData ? MRT_ColumnDef<TData>[] : never;
1568
+ type ExtraFieldFilterOption<TData extends RowData> = Pick<MRT_ColumnDef<TData & MRT_RowData>, 'type' | 'accessorKey' | 'header' | 'meta'>;
1575
1569
  declare module '@tanstack/react-table' {
1576
1570
  interface ColumnMeta<TData extends RowData, TValue> {
1577
1571
  enumValues?: Array<{
@@ -1580,7 +1574,7 @@ declare module '@tanstack/react-table' {
1580
1574
  }>;
1581
1575
  availableIcons?: MRT_AvailableIconOption[];
1582
1576
  dimensions?: MRT_DimensionsDef;
1583
- extraFieldFilters?: MRT_ColumnMetaExtraFieldFilters<TData>;
1577
+ extraFieldFilters?: ExtraFieldFilterOption<TData>[];
1584
1578
  }
1585
1579
  }
1586
1580
 
@@ -1750,6 +1744,7 @@ type MaterialReactServerTableInstanceProps<TData extends MRT_RowData> = Partial<
1750
1744
  editRowFn?: ({ rowToEdit, table, }: OnEditActionContext<TData>) => Promise<void> | void;
1751
1745
  enableResetState?: boolean;
1752
1746
  resetState?: (table: MRT_TableInstance<TData>) => Promise<void> | void;
1747
+ extendColumns?: Partial<MRT_ColumnDef<TData>>[];
1753
1748
  };
1754
1749
 
1755
1750
  type MaterialReactServerTableProps<TData extends MRT_RowData> = Omit<MaterialReactServerTableInstanceProps<TData>, 'config'> & {
@@ -1781,8 +1776,9 @@ interface MRT_TableBodyCellProps<TData extends MRT_RowData> extends TableCellPro
1781
1776
  staticColumnIndex?: number;
1782
1777
  staticRowIndex: number;
1783
1778
  table: MRT_TableInstance<TData>;
1779
+ theme: Theme;
1784
1780
  }
1785
- declare const MRT_TableBodyCell: <TData extends MRT_RowData>({ cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table, ...rest }: MRT_TableBodyCellProps<TData>) => react_jsx_runtime.JSX.Element;
1781
+ declare const MRT_TableBodyCell: <TData extends MRT_RowData>({ cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table, theme, ...rest }: MRT_TableBodyCellProps<TData>) => react_jsx_runtime.JSX.Element;
1786
1782
  declare const Memo_MRT_TableBodyCell: typeof MRT_TableBodyCell;
1787
1783
 
1788
1784
  interface MRT_TableBodyCellValueProps<TData extends MRT_RowData> {
@@ -1802,9 +1798,10 @@ interface MRT_TableBodyRowProps<TData extends MRT_RowData> extends TableRowProps
1802
1798
  rowVirtualizer?: MRT_RowVirtualizer;
1803
1799
  staticRowIndex: number;
1804
1800
  table: MRT_TableInstance<TData>;
1801
+ theme: Theme;
1805
1802
  virtualRow?: VirtualItem;
1806
1803
  }
1807
- 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;
1804
+ 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;
1808
1805
  declare const Memo_MRT_TableBodyRow: typeof MRT_TableBodyRow;
1809
1806
 
1810
1807
  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';
@@ -710,10 +710,7 @@ const getDefaultColumnOrderIds = (tableOptions, reset = false) => {
710
710
  const flexRender = flexRender$1;
711
711
  function createMRTColumnHelper() {
712
712
  return {
713
- accessor: (accessor, column) => {
714
- return typeof accessor === 'function'
715
- ? Object.assign(Object.assign({}, column), { accessorFn: accessor }) : Object.assign(Object.assign({}, column), { accessorKey: accessor });
716
- },
713
+ accessor: (accessor, column) => (Object.assign(Object.assign({}, column), { accessorKey: accessor })),
717
714
  display: (column) => column,
718
715
  group: (column) => column,
719
716
  };
@@ -1949,7 +1946,7 @@ const MRT_DefaultDisplayColumn = {
1949
1946
  };
1950
1947
  const useMRT_TableOptions = (_a) => {
1951
1948
  var _b;
1952
- 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"]);
1953
1950
  const theme = useTheme();
1954
1951
  icons = useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
1955
1952
  localization = useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
@@ -2235,7 +2232,7 @@ const handleRemoveRow = ({ getRowId, setRowsState, }) => {
2235
2232
  * @returns the MRT table instance
2236
2233
  */
2237
2234
  const useMRT_TableInstance = (definedTableOptions) => {
2238
- 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;
2239
2236
  const lastSelectedRowId = useRef(null);
2240
2237
  const allSelectableRowIdsRef = useRef([]);
2241
2238
  const actionCellRef = useRef(null);
@@ -2297,17 +2294,16 @@ const useMRT_TableInstance = (definedTableOptions) => {
2297
2294
  const [showAlertBanner, setShowAlertBanner] = useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _r !== void 0 ? _r : false);
2298
2295
  const [showColumnFilters, setShowColumnFilters] = useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _s !== void 0 ? _s : false);
2299
2296
  const [showGlobalFilter, setShowGlobalFilter] = useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _t !== void 0 ? _t : false);
2300
- const [showAdvancedFilters, setShowAdvancedFilters] = useState((_u = initialState === null || initialState === void 0 ? void 0 : initialState.showAdvancedFilters) !== null && _u !== void 0 ? _u : Boolean(definedTableOptions.enableAdvancedFilters &&
2301
- definedTableOptions.manualFiltering));
2302
- const [showToolbarDropZone, setShowToolbarDropZone] = useState((_v = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _v !== void 0 ? _v : false);
2303
- const [newEntryModal, setNewEntryModal] = useState((_w = initialState === null || initialState === void 0 ? void 0 : initialState.newEntryModal) !== null && _w !== void 0 ? _w : { open: false });
2304
- 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);
2305
2301
  // Saved filter presets — initialised from the dedicated option so the consumer
2306
2302
  // can hydrate them from the server response before rendering.
2307
- 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 : {});
2308
2304
  // Row reordering selection state
2309
- const [rowReorderingSelection, setRowReorderingSelection] = useState((_z = initialState === null || initialState === void 0 ? void 0 : initialState.rowReorderingSelection) !== null && _z !== void 0 ? _z : {});
2310
- 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 : []);
2311
2307
  definedTableOptions.state = Object.assign({ actionCell,
2312
2308
  columnFilterFns,
2313
2309
  columnOrder,
@@ -2329,7 +2325,6 @@ const useMRT_TableInstance = (definedTableOptions) => {
2329
2325
  showAlertBanner,
2330
2326
  showColumnFilters,
2331
2327
  showGlobalFilter,
2332
- showAdvancedFilters,
2333
2328
  showProgressBars,
2334
2329
  showToolbarDropZone,
2335
2330
  newEntryModal }, definedTableOptions.state);
@@ -2342,39 +2337,67 @@ const useMRT_TableInstance = (definedTableOptions) => {
2342
2337
  }
2343
2338
  //The table options now include all state needed to help determine column visibility and order logic
2344
2339
  const statefulTableOptions = definedTableOptions;
2345
- const resolveRowId = (_1 = statefulTableOptions.getRowId) !== null && _1 !== void 0 ? _1 : ((_originalRow, index, _parentRow) => String(index));
2346
- //don't recompute columnDefs while resizing column or dragging column/row
2347
- const columnDefsRef = useRef([]);
2348
- statefulTableOptions.columns =
2349
- statefulTableOptions.state.columnSizingInfo.isResizingColumn ||
2350
- statefulTableOptions.state.draggingColumn ||
2351
- statefulTableOptions.state.draggingRow
2352
- ? columnDefsRef.current
2353
- : prepareColumns({
2354
- columnDefs: [
2355
- ...[
2356
- showRowPinningColumn(statefulTableOptions) &&
2357
- getMRT_RowPinningColumnDef(statefulTableOptions),
2358
- showRowDragColumn(statefulTableOptions) &&
2359
- getMRT_RowDragColumnDef(statefulTableOptions),
2360
- showRowActionsColumn(statefulTableOptions) &&
2361
- getMRT_RowActionsColumnDef(statefulTableOptions),
2362
- showRowExpandColumn(statefulTableOptions) &&
2363
- getMRT_RowExpandColumnDef(statefulTableOptions),
2364
- showRowSelectionColumn(statefulTableOptions) &&
2365
- getMRT_RowSelectColumnDef(statefulTableOptions),
2366
- showRowNumbersColumn(statefulTableOptions) &&
2367
- getMRT_RowNumbersColumnDef(statefulTableOptions),
2368
- ].filter(Boolean),
2369
- ...statefulTableOptions.columns,
2370
- ...[
2371
- showRowSpacerColumn(statefulTableOptions) &&
2372
- getMRT_RowSpacerColumnDef(statefulTableOptions),
2373
- ].filter(Boolean),
2374
- ],
2375
- tableOptions: statefulTableOptions,
2376
- });
2377
- 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
+ ]);
2378
2401
  //if loading, generate blank rows to show skeleton loaders
2379
2402
  statefulTableOptions.data = useMemo(() => (statefulTableOptions.state.isLoading ||
2380
2403
  statefulTableOptions.state.showSkeletons) &&
@@ -2393,7 +2416,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
2393
2416
  const table = useReactTable(Object.assign(Object.assign({ onColumnOrderChange,
2394
2417
  onColumnSizingInfoChange,
2395
2418
  onGroupingChange,
2396
- 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'] }));
2397
2420
  table.refs = {
2398
2421
  actionCellRef,
2399
2422
  allSelectableRowIdsRef,
@@ -2410,7 +2433,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
2410
2433
  topToolbarRef,
2411
2434
  };
2412
2435
  table.setActionCell =
2413
- (_3 = statefulTableOptions.onActionCellChange) !== null && _3 !== void 0 ? _3 : setActionCell;
2436
+ (_2 = statefulTableOptions.onActionCellChange) !== null && _2 !== void 0 ? _2 : setActionCell;
2414
2437
  table.setCreatingRow = (row) => {
2415
2438
  var _a, _b;
2416
2439
  let _row = row;
@@ -2420,38 +2443,39 @@ const useMRT_TableInstance = (definedTableOptions) => {
2420
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);
2421
2444
  };
2422
2445
  table.setColumnFilterFns =
2423
- (_4 = statefulTableOptions.onColumnFilterFnsChange) !== null && _4 !== void 0 ? _4 : setColumnFilterFns;
2424
- 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;
2425
2448
  table.setDraggingColumn =
2426
- (_6 = statefulTableOptions.onDraggingColumnChange) !== null && _6 !== void 0 ? _6 : setDraggingColumn;
2449
+ (_5 = statefulTableOptions.onDraggingColumnChange) !== null && _5 !== void 0 ? _5 : setDraggingColumn;
2427
2450
  table.setDraggingRow =
2428
- (_7 = statefulTableOptions.onDraggingRowChange) !== null && _7 !== void 0 ? _7 : setDraggingRow;
2451
+ (_6 = statefulTableOptions.onDraggingRowChange) !== null && _6 !== void 0 ? _6 : setDraggingRow;
2429
2452
  table.setEditingCell =
2430
- (_8 = statefulTableOptions.onEditingCellChange) !== null && _8 !== void 0 ? _8 : setEditingCell;
2453
+ (_7 = statefulTableOptions.onEditingCellChange) !== null && _7 !== void 0 ? _7 : setEditingCell;
2431
2454
  table.setEditingRow =
2432
- (_9 = statefulTableOptions.onEditingRowChange) !== null && _9 !== void 0 ? _9 : setEditingRow;
2433
- 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;
2434
2457
  table.setGlobalFilterFn =
2435
- (_11 = statefulTableOptions.onGlobalFilterFnChange) !== null && _11 !== void 0 ? _11 : setGlobalFilterFn;
2458
+ (_10 = statefulTableOptions.onGlobalFilterFnChange) !== null && _10 !== void 0 ? _10 : setGlobalFilterFn;
2436
2459
  table.setHoveredColumn =
2437
- (_12 = statefulTableOptions.onHoveredColumnChange) !== null && _12 !== void 0 ? _12 : setHoveredColumn;
2460
+ (_11 = statefulTableOptions.onHoveredColumnChange) !== null && _11 !== void 0 ? _11 : setHoveredColumn;
2438
2461
  table.setHoveredRow =
2439
- (_13 = statefulTableOptions.onHoveredRowChange) !== null && _13 !== void 0 ? _13 : setHoveredRow;
2462
+ (_12 = statefulTableOptions.onHoveredRowChange) !== null && _12 !== void 0 ? _12 : setHoveredRow;
2440
2463
  table.setSavedFilters = setSavedFilters;
2441
2464
  table.setShowAlertBanner =
2442
- (_14 = statefulTableOptions.onShowAlertBannerChange) !== null && _14 !== void 0 ? _14 : setShowAlertBanner;
2465
+ (_13 = statefulTableOptions.onShowAlertBannerChange) !== null && _13 !== void 0 ? _13 : setShowAlertBanner;
2466
+ table._showAdvancedFiltersSetterRef = showAdvancedFiltersSetterRef;
2443
2467
  table.setShowAdvancedFilters =
2444
- (_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); });
2445
2469
  table.setShowColumnFilters =
2446
- (_16 = statefulTableOptions.onShowColumnFiltersChange) !== null && _16 !== void 0 ? _16 : setShowColumnFilters;
2470
+ (_15 = statefulTableOptions.onShowColumnFiltersChange) !== null && _15 !== void 0 ? _15 : setShowColumnFilters;
2447
2471
  table.setShowGlobalFilter =
2448
- (_17 = statefulTableOptions.onShowGlobalFilterChange) !== null && _17 !== void 0 ? _17 : setShowGlobalFilter;
2472
+ (_16 = statefulTableOptions.onShowGlobalFilterChange) !== null && _16 !== void 0 ? _16 : setShowGlobalFilter;
2449
2473
  table.setShowProgressBars = setShowProgressBars;
2450
2474
  table.setShowToolbarDropZone =
2451
- (_18 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _18 !== void 0 ? _18 : setShowToolbarDropZone;
2475
+ (_17 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _17 !== void 0 ? _17 : setShowToolbarDropZone;
2452
2476
  table.setNewEntryModal = setNewEntryModal;
2453
2477
  table.setRowReorderingSelection =
2454
- (_19 = statefulTableOptions.onRowReorderingSelectionChange) !== null && _19 !== void 0 ? _19 : setRowReorderingSelection;
2478
+ (_18 = statefulTableOptions.onRowReorderingSelectionChange) !== null && _18 !== void 0 ? _18 : setRowReorderingSelection;
2455
2479
  table.addRow = handleAddRow({
2456
2480
  setRowsState,
2457
2481
  getRowId: resolveRowId,
@@ -2592,7 +2616,10 @@ const useMRT_RowVirtualizer = (table, rows) => {
2592
2616
  ? realRows.findIndex((r) => r.id === (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id))
2593
2617
  : undefined, [realRows, draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id]);
2594
2618
  const rowCount = realRows.length;
2595
- 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;
2596
2623
  const rowVirtualizer = useVirtualizer(Object.assign({ count: renderDetailPanel ? rowCount * 2 : rowCount, estimateSize: (index) => renderDetailPanel && index % 2 === 1
2597
2624
  ? expanded === true
2598
2625
  ? 100
@@ -2612,6 +2639,20 @@ const useMRT_RowVirtualizer = (table, rows) => {
2612
2639
  return rowVirtualizer;
2613
2640
  };
2614
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
+
2615
2656
  // Internal Select option value strings — converted to/from actual boolean in RHF state.
2616
2657
  const BOOLEAN_OPTION_TRUE = 'true';
2617
2658
  const BOOLEAN_OPTION_FALSE = 'false';
@@ -4373,7 +4414,7 @@ const MRT_AdvancedFiltersRuleRow = ({ filterableColumns, isFirst, isPinned, logi
4373
4414
  xs: 'auto minmax(0, 1fr) minmax(0, 0.7fr) minmax(0, 1.5fr) auto auto',
4374
4415
  },
4375
4416
  width: '100%',
4376
- }, 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) => {
4377
4418
  const shouldApplyOnEnter = selectedOperator.valueShape !== 'multi';
4378
4419
  if (event.key === 'Enter' && onApply && shouldApplyOnEnter) {
4379
4420
  // Prevent the Enter from bubbling to MUI Drawer/Modal infrastructure
@@ -4599,8 +4640,8 @@ const useMRT_AdvancedFiltersDraft = (table) => {
4599
4640
  * Extracted so that hooks are never called conditionally in the parent guard.
4600
4641
  */
4601
4642
  const MRT_AdvancedFiltersContent = ({ table, }) => {
4602
- const { getState, options: { icons: { CloseIcon }, localization, }, setFilters, setShowAdvancedFilters, } = table;
4603
- const { showAdvancedFilters } = getState();
4643
+ const { options: { icons: { CloseIcon }, localization, }, setFilters, } = table;
4644
+ const { showAdvancedFilters, setShowAdvancedFilters } = useMRT_AdvancedFiltersContext();
4604
4645
  // All draft editing logic lives in this hook
4605
4646
  const { addRule, clearRules, discardChanges, draftFilters, filterableColumns, hasInvalidRules, hasUnappliedChanges, markApplied, pinRule, removeRule, unpinRule, updateLogicOperator, updateRule, } = useMRT_AdvancedFiltersDraft(table);
4606
4647
  // Close the drawer without applying changes
@@ -5376,7 +5417,7 @@ const MRT_SavedFiltersButton = ({ onSelectFilter, table, }) => {
5376
5417
  justifyContent: 'space-between',
5377
5418
  gap: 1,
5378
5419
  minWidth: 180,
5379
- }, 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) => {
5380
5421
  event.stopPropagation();
5381
5422
  handleDeleteFilter(savedFilter.name);
5382
5423
  }, sx: { cursor: 'pointer', flexShrink: 0 } })] }))] }, savedFilter.name)))] })] }));
@@ -5537,21 +5578,24 @@ const MRT_ShowHideColumnsButton = (_a) => {
5537
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 }))] }));
5538
5579
  };
5539
5580
 
5540
- const MRT_ToggleAdvancedFiltersButton = (_a) => {
5581
+ const MRT_ToggleAdvancedFiltersButtonInner = (_a) => {
5541
5582
  var _b;
5542
5583
  var { table } = _a, rest = __rest(_a, ["table"]);
5543
- const { getState, options: { icons: { FilterListIcon, FilterListOffIcon }, localization, manualFiltering, }, setShowAdvancedFilters, } = table;
5544
- const { filters, showAdvancedFilters } = getState();
5584
+ const { getState, options: { icons: { FilterListIcon, FilterListOffIcon }, localization, manualFiltering, }, } = table;
5585
+ const { filters } = getState();
5586
+ const { showAdvancedFilters, setShowAdvancedFilters } = useMRT_AdvancedFiltersContext();
5545
5587
  if (!manualFiltering) {
5546
5588
  return null;
5547
5589
  }
5548
- // Count applied filter rules to display on the badge
5549
5590
  const activeFilterCount = filters.rules.length;
5550
- const handleToggleShowAdvancedFilters = () => {
5551
- setShowAdvancedFilters((prev) => !prev);
5552
- };
5553
5591
  const FilterIcon = showAdvancedFilters ? FilterListOffIcon : FilterListIcon;
5554
- 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)) }));
5555
5599
  };
5556
5600
 
5557
5601
  const MRT_ToggleDensePaddingButton = (_a) => {
@@ -6438,8 +6482,7 @@ const MRT_TableBodyCellValue = ({ cell, rowRef, staticColumnIndex, staticRowInde
6438
6482
 
6439
6483
  const MRT_TableBodyCell = (_a) => {
6440
6484
  var _b, _c, _d, _e;
6441
- var { cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table"]);
6442
- const theme = useTheme();
6485
+ var { cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table, theme } = _a, rest = __rest(_a, ["cell", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table", "theme"]);
6443
6486
  const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableCellActions, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableGrouping, enableKeyboardShortcuts, layoutMode, mrtTheme: { draggingBorderColor }, muiSkeletonProps, muiTableBodyCellProps, }, setHoveredColumn, } = table;
6444
6487
  const { actionCell, columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
6445
6488
  const { column, row } = cell;
@@ -6638,8 +6681,7 @@ const MRT_TableDetailPanel = (_a) => {
6638
6681
 
6639
6682
  const MRT_TableBodyRow = (_a) => {
6640
6683
  var _b, _c, _d, _f;
6641
- var { columnVirtualizer, numRows, pinnedRowIds, row, rowVirtualizer, staticRowIndex, table, virtualRow } = _a, rest = __rest(_a, ["columnVirtualizer", "numRows", "pinnedRowIds", "row", "rowVirtualizer", "staticRowIndex", "table", "virtualRow"]);
6642
- 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"]);
6643
6685
  const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, memoMode, mrtTheme: { baseBackgroundColor, pinnedRowBackgroundColor, selectedRowBackgroundColor, }, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
6644
6686
  const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, rowPinning, } = getState();
6645
6687
  const visibleCells = row.getVisibleCells();
@@ -6704,7 +6746,11 @@ const MRT_TableBodyRow = (_a) => {
6704
6746
  ? Object.assign({ backgroundColor: alpha(cellHighlightColorHover, 0.3) }, commonCellBeforeAfterStyles) : undefined, backgroundColor: `${baseBackgroundColor} !important`, bottom: !virtualRow && bottomPinnedIndex !== undefined && isRowPinned
6705
6747
  ? `${bottomPinnedIndex * rowHeight +
6706
6748
  (enableStickyFooter ? tableFooterHeight - 1 : 0)}px`
6707
- : 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
6708
6754
  ? 'absolute'
6709
6755
  : (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) && isRowPinned
6710
6756
  ? 'sticky'
@@ -6727,6 +6773,7 @@ const MRT_TableBodyRow = (_a) => {
6727
6773
  staticColumnIndex,
6728
6774
  staticRowIndex,
6729
6775
  table,
6776
+ theme,
6730
6777
  };
6731
6778
  const key = `${cell.id}-${staticRowIndex}`;
6732
6779
  return cell ? (memoMode === 'cells' &&
@@ -6744,6 +6791,10 @@ const MRT_TableBody = (_a) => {
6744
6791
  var { columnVirtualizer, table } = _a, rest = __rest(_a, ["columnVirtualizer", "table"]);
6745
6792
  const { getBottomRows, getIsSomeRowsPinned, getRowModel, getState, getTopRows, options: { enableStickyFooter, enableStickyHeader, layoutMode, localization, memoMode, muiTableBodyProps, renderDetailPanel, renderEmptyRowsFallback, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef, tablePaperRef }, } = table;
6746
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();
6747
6798
  const tableBodyProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyProps, { table })), rest);
6748
6799
  const tableHeadHeight = (enableStickyHeader && ((_b = tableHeadRef.current) === null || _b === void 0 ? void 0 : _b.clientHeight)) || 0;
6749
6800
  const tableFooterHeight = (enableStickyFooter && ((_c = tableFooterRef.current) === null || _c === void 0 ? void 0 : _c.clientHeight)) || 0;
@@ -6762,6 +6813,7 @@ const MRT_TableBody = (_a) => {
6762
6813
  columnVirtualizer,
6763
6814
  numRows: rows.length,
6764
6815
  table,
6816
+ theme,
6765
6817
  };
6766
6818
  return (jsxs(Fragment, { children: [!(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
6767
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) => {
@@ -7478,7 +7530,7 @@ const MRT_Table = (_a) => {
7478
7530
  columnVirtualizer,
7479
7531
  table,
7480
7532
  };
7481
- 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))] })));
7482
7534
  };
7483
7535
 
7484
7536
  const MRT_TableLoadingOverlay = (_a) => {
@@ -7504,7 +7556,7 @@ const MRT_TableLoadingOverlay = (_a) => {
7504
7556
 
7505
7557
  const MRT_TableContainer = (_a) => {
7506
7558
  var { table } = _a, rest = __rest(_a, ["table"]);
7507
- const { getState, options: { createDisplayMode, editDisplayMode, enableCellActions, muiTableContainerProps, }, refs: { tableContainerRef }, } = table;
7559
+ const { getState, options: { createDisplayMode, editDisplayMode, enableCellActions, enableRowVirtualization, muiTableContainerProps, }, refs: { tableContainerRef }, } = table;
7508
7560
  const { actionCell, creatingRow, editingRow, isLoading, showLoadingOverlay, newEntryModal, } = getState();
7509
7561
  const loading = showLoadingOverlay !== false && (isLoading || showLoadingOverlay);
7510
7562
  const tableContainerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableContainerProps, {
@@ -7520,7 +7572,9 @@ const MRT_TableContainer = (_a) => {
7520
7572
  tableContainerProps.ref.current = node;
7521
7573
  }
7522
7574
  }
7523
- }, 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 })] })));
7524
7578
  };
7525
7579
 
7526
7580
  const MRT_TablePaper = (_a) => {
@@ -7821,8 +7875,14 @@ function createColumnDef(column) {
7821
7875
  }
7822
7876
  return resolver.createColumnDef(column);
7823
7877
  }
7824
- function createColumnDefs(columns) {
7825
- return columns.map((column) => createColumnDef(column));
7878
+ function createColumnDefs(columns, extendColumns) {
7879
+ return columns.map((column) => {
7880
+ const resolved = createColumnDef(column);
7881
+ const extension = extendColumns === null || extendColumns === void 0 ? void 0 : extendColumns.find((ext) => ext.accessorKey === column.accessorKey);
7882
+ if (extension)
7883
+ return Object.assign(Object.assign({}, resolved), extension);
7884
+ return resolved;
7885
+ });
7826
7886
  }
7827
7887
 
7828
7888
  /** Builds the initial MRT_ActiveExportsState from availableExports.
@@ -7846,10 +7906,10 @@ const buildInitialExportState = (availableExports, savedActiveExports) => {
7846
7906
  });
7847
7907
  };
7848
7908
  const MaterialReactServerTableInstance = (_a) => {
7849
- var _b;
7850
- var { config, loadData, saveState, getAllSelectableRowIds, getTotalRows, onSaveFilters, onDeleteSavedFilter, initialSavedFilters, loadExport, exportPermissions, enableNewEntryButton, actions, deleteRowsFn, editRowFn, enableResetState, resetState } = _a,
7909
+ var _b, _c;
7910
+ var { config, loadData, saveState, getAllSelectableRowIds, getTotalRows, onSaveFilters, onDeleteSavedFilter, initialSavedFilters, loadExport, exportPermissions, enableNewEntryButton, actions, deleteRowsFn, editRowFn, enableResetState, resetState, extendColumns } = _a,
7851
7911
  // Extra MRT_TableOptions props (e.g. formConfig) passed directly through to useMaterialReactTable
7852
- tableOptionsOverrides = __rest(_a, ["config", "loadData", "saveState", "getAllSelectableRowIds", "getTotalRows", "onSaveFilters", "onDeleteSavedFilter", "initialSavedFilters", "loadExport", "exportPermissions", "enableNewEntryButton", "actions", "deleteRowsFn", "editRowFn", "enableResetState", "resetState"]);
7912
+ tableOptionsOverrides = __rest(_a, ["config", "loadData", "saveState", "getAllSelectableRowIds", "getTotalRows", "onSaveFilters", "onDeleteSavedFilter", "initialSavedFilters", "loadExport", "exportPermissions", "enableNewEntryButton", "actions", "deleteRowsFn", "editRowFn", "enableResetState", "resetState", "extendColumns"]);
7853
7913
  const [pageCount, setPageCount] = useState(undefined);
7854
7914
  const [rowCount, setRowCount] = useState(0);
7855
7915
  const [isLoading, setIsLoading] = useState(false);
@@ -7877,7 +7937,7 @@ const MaterialReactServerTableInstance = (_a) => {
7877
7937
  initialState: Object.assign(Object.assign({}, config.initialState), { activeExports: buildInitialExportState(allowedExports, (_b = config.initialState) === null || _b === void 0 ? void 0 : _b.activeExports) }),
7878
7938
  saveState,
7879
7939
  });
7880
- const columns = useMemo(() => createColumnDefs(config.columns), [config.columns]);
7940
+ const columns = useMemo(() => createColumnDefs(config.columns, extendColumns), [config.columns, extendColumns]);
7881
7941
  const wrappedGetTotalRows = useMemo(() => getTotalRows
7882
7942
  ? (props) => __awaiter(void 0, void 0, void 0, function* () {
7883
7943
  const count = yield getTotalRows(props);
@@ -7892,8 +7952,7 @@ const MaterialReactServerTableInstance = (_a) => {
7892
7952
  resetState, enableRowActions: true, renderRowActions: RowActionsCell, positionActionsColumn: 'last', actions: actions, getAllSelectableRowIds, getTotalRows: wrappedGetTotalRows, deleteRowsFn,
7893
7953
  editRowFn,
7894
7954
  onSaveFilters,
7895
- onDeleteSavedFilter,
7896
- initialSavedFilters, availableExports: hasAvailableExports ? allowedExports : undefined, loadExport: hasAvailableExports ? loadExport : undefined, enableNewEntryButton }, tableOptionsOverrides), handlers));
7955
+ 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));
7897
7956
  const fetchData = useCallback((tableInstance) => __awaiter(void 0, void 0, void 0, function* () {
7898
7957
  setIsLoading(true);
7899
7958
  try {