@dooherceg/material-react-table 3.2.6 → 3.2.7

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.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, createContext, useContext, forwardRef, Fragment as Fragment$1, memo, useImperativeHandle } from 'react';
3
+ import { useMemo, useSyncExternalStore, 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';
@@ -858,6 +858,11 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
858
858
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
859
859
  };
860
860
 
861
+ const useMRT_SliceValue = (store, selector) => {
862
+ const getSnapshot = () => selector(store.get());
863
+ return useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
864
+ };
865
+
861
866
  const MRT_ActionMenuItem = (_a) => {
862
867
  var { icon, label, onOpenSubMenu, table } = _a, rest = __rest(_a, ["icon", "label", "onOpenSubMenu", "table"]);
863
868
  const { options: { icons: { ArrowRightIcon }, }, } = table;
@@ -875,8 +880,8 @@ const MRT_ActionMenuItem = (_a) => {
875
880
 
876
881
  const MRT_RowActionMenu = (_a) => {
877
882
  var { anchorEl, handleEdit, row, setAnchorEl, staticRowIndex, table } = _a, rest = __rest(_a, ["anchorEl", "handleEdit", "row", "setAnchorEl", "staticRowIndex", "table"]);
878
- const { getState, options: { editDisplayMode, enableEditing, icons: { EditIcon }, localization, mrtTheme: { menuBackgroundColor }, renderRowActionMenuItems, }, } = table;
879
- const { density } = getState();
883
+ const { options: { editDisplayMode, enableEditing, icons: { EditIcon }, localization, mrtTheme: { menuBackgroundColor }, renderRowActionMenuItems, }, } = table;
884
+ const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
880
885
  const menuItems = useMemo(() => {
881
886
  const items = [];
882
887
  const editItem = parseFromValuesOrFunc(enableEditing, row) &&
@@ -906,9 +911,9 @@ const MRT_RowActionMenu = (_a) => {
906
911
  const MRT_EditActionButtons = (_a) => {
907
912
  var { row, table, variant = 'icon' } = _a, rest = __rest(_a, ["row", "table", "variant"]);
908
913
  const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onCreatingRowCancel, onCreatingRowSave, onEditingRowCancel, onEditingRowSave, }, refs: { editInputRefs }, setCreatingRow, setEditingRow, } = table;
909
- const { creatingRow, editingRow, isSaving } = getState();
914
+ const { creatingRow, isSaving } = getState();
910
915
  const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
911
- const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
916
+ const isEditing = useMRT_SliceValue(table._uiStore, (s) => { var _a; return ((_a = s.editingRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
912
917
  const handleCancel = () => {
913
918
  if (isCreating) {
914
919
  onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
@@ -976,10 +981,9 @@ const getCommonPinnedCellStyles = ({ table, theme, }) => {
976
981
  },
977
982
  };
978
983
  };
979
- const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
980
- var _a, _b, _c, _d, _e, _f, _g, _h;
981
- const { getState, options: { enableColumnVirtualization, layoutMode }, } = table;
982
- const { draggingColumn } = getState();
984
+ const getCommonMRTCellStyles = ({ column, header, isDraggingColumn, isHoveredColumn, table, tableCellProps, theme, }) => {
985
+ var _a, _b, _c, _d, _e, _f;
986
+ const { options: { enableColumnVirtualization, layoutMode }, } = table;
983
987
  const { columnDef } = column;
984
988
  const { columnDefType } = columnDef;
985
989
  const isColumnPinned = columnDef.columnDefType !== 'group' && column.getIsPinned();
@@ -1033,12 +1037,9 @@ const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme,
1033
1037
  ? 'center'
1034
1038
  : (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid'))
1035
1039
  ? tableCellProps.align
1036
- : undefined, opacity: ((_g = table.getState().draggingColumn) === null || _g === void 0 ? void 0 : _g.id) === column.id ||
1037
- ((_h = table.getState().hoveredColumn) === null || _h === void 0 ? void 0 : _h.id) === column.id
1038
- ? 0.5
1039
- : 1, position: 'relative', transition: enableColumnVirtualization
1040
+ : undefined, opacity: isDraggingColumn || isHoveredColumn ? 0.5 : 1, position: 'relative', transition: enableColumnVirtualization
1040
1041
  ? 'none'
1041
- : `padding 150ms ease-in-out`, zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
1042
+ : `padding 150ms ease-in-out`, zIndex: column.getIsResizing() || isDraggingColumn
1042
1043
  ? 2
1043
1044
  : columnDefType !== 'group' && isColumnPinned
1044
1045
  ? 1
@@ -1080,9 +1081,9 @@ const MRT_ToggleRowActionMenuButton = (_a) => {
1080
1081
  var _b;
1081
1082
  var { cell, row, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "row", "staticRowIndex", "table"]);
1082
1083
  const { getState, options: { createDisplayMode, editDisplayMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
1083
- const { creatingRow, editingRow } = getState();
1084
+ const { creatingRow } = getState();
1084
1085
  const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
1085
- const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
1086
+ const isEditing = useMRT_SliceValue(table._uiStore, (s) => { var _a; return ((_a = s.editingRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
1086
1087
  const showEditActionButtons = (isCreating && createDisplayMode === 'row') ||
1087
1088
  (isEditing && editDisplayMode === 'row');
1088
1089
  const [anchorEl, setAnchorEl] = useState(null);
@@ -1171,7 +1172,8 @@ const MRT_ExpandAllButton = (_a) => {
1171
1172
  var _b, _c;
1172
1173
  var { table } = _a, rest = __rest(_a, ["table"]);
1173
1174
  const { getCanSomeRowsExpand, getIsAllRowsExpanded, getIsSomeRowsExpanded, getState, options: { icons: { KeyboardDoubleArrowDownIcon }, localization, muiExpandAllButtonProps, renderDetailPanel, }, toggleAllRowsExpanded, } = table;
1174
- const { density, isLoading } = getState();
1175
+ const { isLoading } = getState();
1176
+ const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
1175
1177
  const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiExpandAllButtonProps, {
1176
1178
  table,
1177
1179
  })), rest);
@@ -1185,8 +1187,8 @@ const MRT_ExpandAllButton = (_a) => {
1185
1187
  const MRT_ExpandButton = ({ row, staticRowIndex, table, }) => {
1186
1188
  var _a, _b;
1187
1189
  const theme = useTheme();
1188
- const { getState, options: { icons: { ExpandMoreIcon }, localization, maxDepth, muiExpandButtonProps, positionExpandColumn, renderDetailPanel, }, } = table;
1189
- const { density } = getState();
1190
+ const { options: { icons: { ExpandMoreIcon }, localization, maxDepth, muiExpandButtonProps, positionExpandColumn, renderDetailPanel, }, } = table;
1191
+ const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
1190
1192
  const iconButtonProps = parseFromValuesOrFunc(muiExpandButtonProps, {
1191
1193
  row,
1192
1194
  staticRowIndex,
@@ -1441,7 +1443,8 @@ const useTreeRowReorderingCell = ({ row, table, rowReorderingSelection, maxDepth
1441
1443
  };
1442
1444
 
1443
1445
  const useTreeRowReorderingHeader = ({ table, enableRowReordering, onTreeRowReorder, }) => {
1444
- const selectedReorderRowIds = getSelectedReorderRowIds(table.getState().rowReorderingSelection);
1446
+ const rowReorderingSelection = useMRT_SliceValue(table._uiStore, (s) => s.rowReorderingSelection);
1447
+ const selectedReorderRowIds = getSelectedReorderRowIds(rowReorderingSelection);
1445
1448
  const selectedRowsForReorder = buildSelectedRowsArray(selectedReorderRowIds, table);
1446
1449
  const shouldShowMoveToTopLevelAction = !!enableRowReordering &&
1447
1450
  selectedRowsForReorder.length > 0 &&
@@ -1473,7 +1476,7 @@ const useTreeRowReorderingHeader = ({ table, enableRowReordering, onTreeRowReord
1473
1476
  const TREE_REORDER_ICON_SPACING = '0.25rem';
1474
1477
  const getMRT_RowExpandColumnDef = (tableOptions) => {
1475
1478
  var _a;
1476
- const { defaultColumn, enableRowReordering, enableExpandAll, groupedColumnMode, maxDepth, onTreeRowReorder, positionExpandColumn, renderDetailPanel, state: { grouping, rowReorderingSelection }, } = tableOptions;
1479
+ const { defaultColumn, enableRowReordering, enableExpandAll, groupedColumnMode, maxDepth, onTreeRowReorder, positionExpandColumn, renderDetailPanel, state: { grouping }, } = tableOptions;
1477
1480
  const alignProps = positionExpandColumn === 'last'
1478
1481
  ? {
1479
1482
  align: 'right',
@@ -1481,6 +1484,7 @@ const getMRT_RowExpandColumnDef = (tableOptions) => {
1481
1484
  : undefined;
1482
1485
  return Object.assign(Object.assign({ Cell: ({ cell, column, row, staticRowIndex, table }) => {
1483
1486
  var _a, _b, _c;
1487
+ const rowReorderingSelection = useMRT_SliceValue(table._uiStore, (s) => s.rowReorderingSelection);
1484
1488
  const cellLogic = useTreeRowReorderingCell({
1485
1489
  row,
1486
1490
  table,
@@ -1566,8 +1570,8 @@ const MRT_RowPinButton = (_a) => {
1566
1570
 
1567
1571
  const MRT_TableBodyRowPinButton = (_a) => {
1568
1572
  var { row, table } = _a, rest = __rest(_a, ["row", "table"]);
1569
- const { getState, options: { enableRowPinning, rowPinningDisplayMode }, } = table;
1570
- const { density } = getState();
1573
+ const { options: { enableRowPinning, rowPinningDisplayMode }, } = table;
1574
+ const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
1571
1575
  const canPin = parseFromValuesOrFunc(enableRowPinning, row);
1572
1576
  if (!canPin)
1573
1577
  return null;
@@ -1676,7 +1680,8 @@ const MRT_SelectCheckbox = (_a) => {
1676
1680
  var _b;
1677
1681
  var { row, staticRowIndex, table } = _a, rest = __rest(_a, ["row", "staticRowIndex", "table"]);
1678
1682
  const { getState, options: { enableMultiRowSelection, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, selectAllMode, }, } = table;
1679
- const { density, isLoading } = getState();
1683
+ const { isLoading } = getState();
1684
+ const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
1680
1685
  const selectAll = !row;
1681
1686
  const allRowsSelected = selectAll
1682
1687
  ? selectAllMode === 'page'
@@ -2420,7 +2425,8 @@ const getMRT_RowSpacerColumnDef = (tableOptions) => {
2420
2425
 
2421
2426
  const useMRT_Effects = (table) => {
2422
2427
  const { getIsSomeRowsPinned, getPrePaginationRowModel, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
2423
- const { density, globalFilter, isLoading, pagination, showSkeletons, sorting, } = getState();
2428
+ const { globalFilter, isLoading, pagination, showSkeletons, sorting } = getState();
2429
+ const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
2424
2430
  const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
2425
2431
  const rerender = useReducer(() => ({}), {})[1];
2426
2432
  const initialBodyHeight = useRef(null);
@@ -2567,13 +2573,29 @@ const handleRemoveRow = ({ getRowId, setRowsState, }) => {
2567
2573
  };
2568
2574
  };
2569
2575
 
2576
+ const createSliceStore = (initial) => {
2577
+ let value = initial;
2578
+ const listeners = new Set();
2579
+ return {
2580
+ get: () => value,
2581
+ set: (next) => {
2582
+ value = next instanceof Function ? next(value) : next;
2583
+ listeners.forEach((listener) => listener());
2584
+ },
2585
+ subscribe: (listener) => {
2586
+ listeners.add(listener);
2587
+ return () => listeners.delete(listener);
2588
+ },
2589
+ };
2590
+ };
2591
+
2570
2592
  /**
2571
2593
  * The MRT hook that wraps the TanStack useReactTable hook and adds additional functionality
2572
2594
  * @param definedTableOptions - table options with proper defaults set
2573
2595
  * @returns the MRT table instance
2574
2596
  */
2575
2597
  const useMRT_TableInstance = (definedTableOptions) => {
2576
- 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;
2598
+ 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;
2577
2599
  const lastSelectedRowId = useRef(null);
2578
2600
  const allSelectableRowIdsRef = useRef([]);
2579
2601
  const actionCellRef = useRef(null);
@@ -2587,6 +2609,9 @@ const useMRT_TableInstance = (definedTableOptions) => {
2587
2609
  const topToolbarRef = useRef(null);
2588
2610
  const tableHeadRef = useRef(null);
2589
2611
  const tableFooterRef = useRef(null);
2612
+ const tableRef = useRef(null);
2613
+ const isResizingRef = useRef(false);
2614
+ const resizeIndicatorRef = useRef(null);
2590
2615
  //transform initial state with proper column order
2591
2616
  const initialState = useMemo(() => {
2592
2617
  var _a, _b, _c, _d, _e;
@@ -2605,8 +2630,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
2605
2630
  return initState;
2606
2631
  }, []);
2607
2632
  definedTableOptions.initialState = initialState;
2608
- const [actionCell, setActionCell] = useState((_a = initialState.actionCell) !== null && _a !== void 0 ? _a : null);
2609
- const [creatingRow, _setCreatingRow] = useState((_b = initialState.creatingRow) !== null && _b !== void 0 ? _b : null);
2633
+ const [creatingRow, _setCreatingRow] = useState((_a = initialState.creatingRow) !== null && _a !== void 0 ? _a : null);
2610
2634
  const [columnFilterFns, setColumnFilterFns] = useState(() => Object.assign({}, ...getAllLeafColumnDefs(definedTableOptions.columns).map((col) => {
2611
2635
  var _a, _b, _c, _d;
2612
2636
  return ({
@@ -2615,60 +2639,176 @@ const useMRT_TableInstance = (definedTableOptions) => {
2615
2639
  : ((_d = (_b = col.filterFn) !== null && _b !== void 0 ? _b : (_c = initialState === null || initialState === void 0 ? void 0 : initialState.columnFilterFns) === null || _c === void 0 ? void 0 : _c[getColumnId(col)]) !== null && _d !== void 0 ? _d : getDefaultColumnFilterFn(col)),
2616
2640
  });
2617
2641
  })));
2618
- const [columnOrder, onColumnOrderChange] = useState((_c = initialState.columnOrder) !== null && _c !== void 0 ? _c : []);
2619
- const [columnSizingInfo, onColumnSizingInfoChange] = useState((_d = initialState.columnSizingInfo) !== null && _d !== void 0 ? _d : {});
2620
- const [density, setDensity] = useState((_e = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _e !== void 0 ? _e : 'compact');
2621
- const [draggingColumn, setDraggingColumn] = useState((_f = initialState.draggingColumn) !== null && _f !== void 0 ? _f : null);
2622
- const [draggingRow, setDraggingRow] = useState((_g = initialState.draggingRow) !== null && _g !== void 0 ? _g : null);
2623
- const [editingCell, setEditingCell] = useState((_h = initialState.editingCell) !== null && _h !== void 0 ? _h : null);
2624
- const [editingRow, setEditingRow] = useState((_j = initialState.editingRow) !== null && _j !== void 0 ? _j : null);
2625
- const [filters, setFilters] = useState((_k = initialState.filters) !== null && _k !== void 0 ? _k : {
2642
+ const [columnOrder, onColumnOrderChange] = useState((_b = initialState.columnOrder) !== null && _b !== void 0 ? _b : []);
2643
+ // Hover/drag are UI-feedback-only and change at very high frequency during a drag
2644
+ // gesture (every cell crossed) — kept in slice stores instead of useState so
2645
+ // subscribers can select just the boolean they need instead of re-rendering the tree.
2646
+ const [dragStore] = useState(() => {
2647
+ var _a, _b;
2648
+ return createSliceStore({
2649
+ draggingColumn: ((_a = initialState.draggingColumn) !== null && _a !== void 0 ? _a : null),
2650
+ draggingRow: ((_b = initialState.draggingRow) !== null && _b !== void 0 ? _b : null),
2651
+ });
2652
+ });
2653
+ const [filters, setFilters] = useState((_c = initialState.filters) !== null && _c !== void 0 ? _c : {
2626
2654
  logicOperator: 'and',
2627
2655
  rules: [],
2628
2656
  pinnedFilters: [],
2629
2657
  });
2630
- const [globalFilterFn, setGlobalFilterFn] = useState((_l = initialState.globalFilterFn) !== null && _l !== void 0 ? _l : 'fuzzy');
2631
- const [grouping, onGroupingChange] = useState((_m = initialState.grouping) !== null && _m !== void 0 ? _m : []);
2632
- const [hoveredColumn, setHoveredColumn] = useState((_o = initialState.hoveredColumn) !== null && _o !== void 0 ? _o : null);
2633
- const [hoveredRow, setHoveredRow] = useState((_p = initialState.hoveredRow) !== null && _p !== void 0 ? _p : null);
2634
- const [pagination, onPaginationChange] = useState((_q = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) !== null && _q !== void 0 ? _q : { pageIndex: 0, pageSize: 10 });
2635
- const [showAlertBanner, setShowAlertBanner] = useState((_r = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _r !== void 0 ? _r : false);
2636
- const [showColumnFilters, setShowColumnFilters] = useState((_s = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _s !== void 0 ? _s : false);
2637
- const [showGlobalFilter, setShowGlobalFilter] = useState((_t = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _t !== void 0 ? _t : false);
2658
+ const [globalFilterFn, setGlobalFilterFn] = useState((_d = initialState.globalFilterFn) !== null && _d !== void 0 ? _d : 'fuzzy');
2659
+ const [grouping, onGroupingChange] = useState((_e = initialState.grouping) !== null && _e !== void 0 ? _e : []);
2660
+ const [hoverStore] = useState(() => {
2661
+ var _a, _b;
2662
+ return createSliceStore({
2663
+ hoveredColumn: ((_a = initialState.hoveredColumn) !== null && _a !== void 0 ? _a : null),
2664
+ hoveredRow: ((_b = initialState.hoveredRow) !== null && _b !== void 0 ? _b : null),
2665
+ });
2666
+ });
2667
+ // Everything below is UI-only feedback state that never influences the TanStack row/
2668
+ // column model (unlike filters/pagination/grouping/columnOrder/creatingRow/rows) —
2669
+ // kept in one combined store instead of 13 separate useState hooks so none of it
2670
+ // triggers a root re-render; consumers select just the field(s) they need via
2671
+ // useMRT_SliceValue.
2672
+ const [uiStore] = useState(() => {
2673
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
2674
+ return createSliceStore({
2675
+ actionCell: ((_a = initialState.actionCell) !== null && _a !== void 0 ? _a : null),
2676
+ columnSizingInfo: ((_b = initialState.columnSizingInfo) !== null && _b !== void 0 ? _b : {}),
2677
+ density: ((_c = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _c !== void 0 ? _c : 'compact'),
2678
+ editingCell: ((_d = initialState.editingCell) !== null && _d !== void 0 ? _d : null),
2679
+ editingRow: ((_e = initialState.editingRow) !== null && _e !== void 0 ? _e : null),
2680
+ newEntryModal: ((_f = initialState === null || initialState === void 0 ? void 0 : initialState.newEntryModal) !== null && _f !== void 0 ? _f : {
2681
+ open: false,
2682
+ }),
2683
+ rowReorderingSelection: ((_g = initialState === null || initialState === void 0 ? void 0 : initialState.rowReorderingSelection) !== null && _g !== void 0 ? _g : {}),
2684
+ // Saved filter presets — initialised from the dedicated option so the consumer
2685
+ // can hydrate them from the server response before rendering.
2686
+ savedFilters: ((_h = definedTableOptions.initialSavedFilters) !== null && _h !== void 0 ? _h : {}),
2687
+ showAlertBanner: ((_j = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _j !== void 0 ? _j : false),
2688
+ showColumnFilters: ((_k = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _k !== void 0 ? _k : false),
2689
+ showGlobalFilter: ((_l = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _l !== void 0 ? _l : false),
2690
+ showProgressBars: ((_m = initialState === null || initialState === void 0 ? void 0 : initialState.showProgressBars) !== null && _m !== void 0 ? _m : false),
2691
+ showToolbarDropZone: ((_o = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _o !== void 0 ? _o : false),
2692
+ });
2693
+ });
2694
+ // columnSizingInfo isn't an MRT-level `table.setX` wrapper — TanStack auto-generates
2695
+ // `table.setColumnSizingInfo` bound to whatever `onColumnSizingInfoChange` we pass into
2696
+ // useReactTable below, so redirecting it here is enough for every internal call
2697
+ // (column.resetSize(), the resize-handle double-click reset, etc.) to land in the store.
2698
+ const onColumnSizingInfoChange = (updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { columnSizingInfo: updater instanceof Function ? updater(prev.columnSizingInfo) : updater })));
2699
+ const [pagination, onPaginationChange] = useState((_f = initialState === null || initialState === void 0 ? void 0 : initialState.pagination) !== null && _f !== void 0 ? _f : { pageIndex: 0, pageSize: 10 });
2638
2700
  const showAdvancedFiltersSetterRef = useRef(null);
2639
- const [showToolbarDropZone, setShowToolbarDropZone] = useState((_u = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _u !== void 0 ? _u : false);
2640
- const [newEntryModal, setNewEntryModal] = useState((_v = initialState === null || initialState === void 0 ? void 0 : initialState.newEntryModal) !== null && _v !== void 0 ? _v : { open: false });
2641
- const [showProgressBars, setShowProgressBars] = useState((_w = initialState === null || initialState === void 0 ? void 0 : initialState.showProgressBars) !== null && _w !== void 0 ? _w : false);
2642
- // Saved filter presets — initialised from the dedicated option so the consumer
2643
- // can hydrate them from the server response before rendering.
2644
- const [savedFilters, setSavedFilters] = useState((_x = definedTableOptions.initialSavedFilters) !== null && _x !== void 0 ? _x : {});
2645
- // Row reordering selection state
2646
- const [rowReorderingSelection, setRowReorderingSelection] = useState((_y = initialState === null || initialState === void 0 ? void 0 : initialState.rowReorderingSelection) !== null && _y !== void 0 ? _y : {});
2647
- const [rows, setRowsState] = useState((_z = definedTableOptions.data) !== null && _z !== void 0 ? _z : []);
2648
- definedTableOptions.state = Object.assign({ actionCell,
2649
- columnFilterFns,
2701
+ const [rows, setRowsState] = useState((_g = definedTableOptions.data) !== null && _g !== void 0 ? _g : []);
2702
+ definedTableOptions.state = Object.assign({ columnFilterFns,
2650
2703
  columnOrder,
2651
- columnSizingInfo,
2652
2704
  creatingRow,
2653
- density,
2654
- draggingColumn,
2655
- draggingRow,
2656
- editingCell,
2657
- editingRow,
2658
2705
  filters,
2659
2706
  globalFilterFn,
2660
2707
  grouping,
2661
- hoveredColumn,
2662
- hoveredRow,
2663
- pagination,
2664
- rowReorderingSelection,
2665
- savedFilters,
2666
- showAlertBanner,
2667
- showColumnFilters,
2668
- showGlobalFilter,
2669
- showProgressBars,
2670
- showToolbarDropZone,
2671
- newEntryModal }, definedTableOptions.state);
2708
+ pagination }, definedTableOptions.state);
2709
+ // Sync a controlled consumer's state.draggingColumn/draggingRow/hoveredColumn/
2710
+ // hoveredRow into the slice stores — rare (these are usually left uncontrolled), but
2711
+ // since they no longer flow through definedTableOptions.state -> useReactTable, an
2712
+ // externally-controlled value needs an explicit bridge into the store.
2713
+ useEffect(() => {
2714
+ var _a;
2715
+ if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.draggingColumn) !== undefined) {
2716
+ dragStore.set((prev) => (Object.assign(Object.assign({}, prev), { draggingColumn: definedTableOptions.state.draggingColumn })));
2717
+ }
2718
+ }, [(_h = definedTableOptions.state) === null || _h === void 0 ? void 0 : _h.draggingColumn]);
2719
+ useEffect(() => {
2720
+ var _a;
2721
+ if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.draggingRow) !== undefined) {
2722
+ dragStore.set((prev) => (Object.assign(Object.assign({}, prev), { draggingRow: definedTableOptions.state.draggingRow })));
2723
+ }
2724
+ }, [(_j = definedTableOptions.state) === null || _j === void 0 ? void 0 : _j.draggingRow]);
2725
+ useEffect(() => {
2726
+ var _a;
2727
+ if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.hoveredColumn) !== undefined) {
2728
+ hoverStore.set((prev) => (Object.assign(Object.assign({}, prev), { hoveredColumn: definedTableOptions.state.hoveredColumn })));
2729
+ }
2730
+ }, [(_k = definedTableOptions.state) === null || _k === void 0 ? void 0 : _k.hoveredColumn]);
2731
+ useEffect(() => {
2732
+ var _a;
2733
+ if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.hoveredRow) !== undefined) {
2734
+ hoverStore.set((prev) => (Object.assign(Object.assign({}, prev), { hoveredRow: definedTableOptions.state.hoveredRow })));
2735
+ }
2736
+ }, [(_l = definedTableOptions.state) === null || _l === void 0 ? void 0 : _l.hoveredRow]);
2737
+ // Same bridge as above, for the 12 UI-only fields in uiStore (columnSizingInfo is
2738
+ // deliberately excluded — it isn't part of the table.setX = onXChange ?? ... pattern,
2739
+ // see onColumnSizingInfoChange above).
2740
+ useEffect(() => {
2741
+ var _a;
2742
+ if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.actionCell) !== undefined) {
2743
+ uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { actionCell: definedTableOptions.state.actionCell })));
2744
+ }
2745
+ }, [(_m = definedTableOptions.state) === null || _m === void 0 ? void 0 : _m.actionCell]);
2746
+ useEffect(() => {
2747
+ var _a;
2748
+ if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.density) !== undefined) {
2749
+ uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { density: definedTableOptions.state.density })));
2750
+ }
2751
+ }, [(_o = definedTableOptions.state) === null || _o === void 0 ? void 0 : _o.density]);
2752
+ useEffect(() => {
2753
+ var _a;
2754
+ if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.editingCell) !== undefined) {
2755
+ uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { editingCell: definedTableOptions.state.editingCell })));
2756
+ }
2757
+ }, [(_p = definedTableOptions.state) === null || _p === void 0 ? void 0 : _p.editingCell]);
2758
+ useEffect(() => {
2759
+ var _a;
2760
+ if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.editingRow) !== undefined) {
2761
+ uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { editingRow: definedTableOptions.state.editingRow })));
2762
+ }
2763
+ }, [(_q = definedTableOptions.state) === null || _q === void 0 ? void 0 : _q.editingRow]);
2764
+ useEffect(() => {
2765
+ var _a;
2766
+ if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.newEntryModal) !== undefined) {
2767
+ uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { newEntryModal: definedTableOptions.state.newEntryModal })));
2768
+ }
2769
+ }, [(_r = definedTableOptions.state) === null || _r === void 0 ? void 0 : _r.newEntryModal]);
2770
+ useEffect(() => {
2771
+ var _a;
2772
+ if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.rowReorderingSelection) !== undefined) {
2773
+ uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { rowReorderingSelection: definedTableOptions.state.rowReorderingSelection })));
2774
+ }
2775
+ }, [(_s = definedTableOptions.state) === null || _s === void 0 ? void 0 : _s.rowReorderingSelection]);
2776
+ useEffect(() => {
2777
+ var _a;
2778
+ if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.savedFilters) !== undefined) {
2779
+ uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { savedFilters: definedTableOptions.state.savedFilters })));
2780
+ }
2781
+ }, [(_t = definedTableOptions.state) === null || _t === void 0 ? void 0 : _t.savedFilters]);
2782
+ useEffect(() => {
2783
+ var _a;
2784
+ if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.showAlertBanner) !== undefined) {
2785
+ uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { showAlertBanner: definedTableOptions.state.showAlertBanner })));
2786
+ }
2787
+ }, [(_u = definedTableOptions.state) === null || _u === void 0 ? void 0 : _u.showAlertBanner]);
2788
+ useEffect(() => {
2789
+ var _a;
2790
+ if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.showColumnFilters) !== undefined) {
2791
+ uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { showColumnFilters: definedTableOptions.state.showColumnFilters })));
2792
+ }
2793
+ }, [(_v = definedTableOptions.state) === null || _v === void 0 ? void 0 : _v.showColumnFilters]);
2794
+ useEffect(() => {
2795
+ var _a;
2796
+ if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.showGlobalFilter) !== undefined) {
2797
+ uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { showGlobalFilter: definedTableOptions.state.showGlobalFilter })));
2798
+ }
2799
+ }, [(_w = definedTableOptions.state) === null || _w === void 0 ? void 0 : _w.showGlobalFilter]);
2800
+ useEffect(() => {
2801
+ var _a;
2802
+ if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.showProgressBars) !== undefined) {
2803
+ uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { showProgressBars: definedTableOptions.state.showProgressBars })));
2804
+ }
2805
+ }, [(_x = definedTableOptions.state) === null || _x === void 0 ? void 0 : _x.showProgressBars]);
2806
+ useEffect(() => {
2807
+ var _a;
2808
+ if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.showToolbarDropZone) !== undefined) {
2809
+ uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { showToolbarDropZone: definedTableOptions.state.showToolbarDropZone })));
2810
+ }
2811
+ }, [(_y = definedTableOptions.state) === null || _y === void 0 ? void 0 : _y.showToolbarDropZone]);
2672
2812
  // Normalize controlled columnPinning state: if the user passes state.columnPinning
2673
2813
  // directly (controlled mode), we still need to ensure that the checkbox column
2674
2814
  // is always at the front of the left-pinned group, just like we do for initialState.
@@ -2678,7 +2818,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
2678
2818
  }
2679
2819
  //The table options now include all state needed to help determine column visibility and order logic
2680
2820
  const statefulTableOptions = definedTableOptions;
2681
- const resolveRowId = (_0 = statefulTableOptions.getRowId) !== null && _0 !== void 0 ? _0 : ((_originalRow, index, _parentRow) => String(index));
2821
+ const resolveRowId = (_z = statefulTableOptions.getRowId) !== null && _z !== void 0 ? _z : ((_originalRow, index, _parentRow) => String(index));
2682
2822
  //keep the prepared column tree referentially stable so TanStack's
2683
2823
  //getAllColumns/getAllLeafColumns/row.getAllCells memo chain doesn't
2684
2824
  //recompute (and recreate every cell of every row) on unrelated renders
@@ -2757,24 +2897,34 @@ const useMRT_TableInstance = (definedTableOptions) => {
2757
2897
  const table = useReactTable(Object.assign(Object.assign({ onColumnOrderChange,
2758
2898
  onColumnSizingInfoChange,
2759
2899
  onGroupingChange,
2760
- onPaginationChange }, statefulTableOptions), { globalFilterFn: (_1 = statefulTableOptions.filterFns) === null || _1 === void 0 ? void 0 : _1[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
2900
+ onPaginationChange }, statefulTableOptions), { globalFilterFn: (_0 = statefulTableOptions.filterFns) === null || _0 === void 0 ? void 0 : _0[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
2761
2901
  table.refs = {
2762
2902
  actionCellRef,
2763
2903
  allSelectableRowIdsRef,
2764
2904
  bottomToolbarRef,
2765
2905
  editInputRefs,
2766
2906
  filterInputRefs,
2907
+ isResizingRef,
2767
2908
  lastSelectedRowId,
2909
+ resizeIndicatorRef,
2768
2910
  searchInputRef,
2769
2911
  tableContainerRef,
2770
2912
  tableFooterRef,
2771
2913
  tableHeadCellRefs,
2772
2914
  tableHeadRef,
2773
2915
  tablePaperRef,
2916
+ tableRef,
2774
2917
  topToolbarRef,
2775
2918
  };
2919
+ table._dragStore = dragStore;
2920
+ table._hoverStore = hoverStore;
2921
+ table._uiStore = uiStore;
2922
+ // Merge the slice stores back into getState() so every existing/external
2923
+ // `table.getState().hoveredColumn`-style read keeps working unchanged.
2924
+ const originalGetState = table.getState;
2925
+ table.getState = () => (Object.assign(Object.assign(Object.assign(Object.assign({}, originalGetState()), dragStore.get()), hoverStore.get()), uiStore.get()));
2776
2926
  table.setActionCell =
2777
- (_2 = statefulTableOptions.onActionCellChange) !== null && _2 !== void 0 ? _2 : setActionCell;
2927
+ (_1 = statefulTableOptions.onActionCellChange) !== null && _1 !== void 0 ? _1 : ((updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { actionCell: updater instanceof Function ? updater(prev.actionCell) : updater }))));
2778
2928
  table.setCreatingRow = (row) => {
2779
2929
  var _a, _b;
2780
2930
  let _row = row;
@@ -2784,39 +2934,48 @@ const useMRT_TableInstance = (definedTableOptions) => {
2784
2934
  (_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);
2785
2935
  };
2786
2936
  table.setColumnFilterFns =
2787
- (_3 = statefulTableOptions.onColumnFilterFnsChange) !== null && _3 !== void 0 ? _3 : setColumnFilterFns;
2788
- table.setDensity = (_4 = statefulTableOptions.onDensityChange) !== null && _4 !== void 0 ? _4 : setDensity;
2937
+ (_2 = statefulTableOptions.onColumnFilterFnsChange) !== null && _2 !== void 0 ? _2 : setColumnFilterFns;
2938
+ table.setDensity =
2939
+ (_3 = statefulTableOptions.onDensityChange) !== null && _3 !== void 0 ? _3 : ((updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { density: updater instanceof Function ? updater(prev.density) : updater }))));
2789
2940
  table.setDraggingColumn =
2790
- (_5 = statefulTableOptions.onDraggingColumnChange) !== null && _5 !== void 0 ? _5 : setDraggingColumn;
2941
+ (_4 = statefulTableOptions.onDraggingColumnChange) !== null && _4 !== void 0 ? _4 : ((updater) => dragStore.set((prev) => (Object.assign(Object.assign({}, prev), { draggingColumn: updater instanceof Function ? updater(prev.draggingColumn) : updater }))));
2791
2942
  table.setDraggingRow =
2792
- (_6 = statefulTableOptions.onDraggingRowChange) !== null && _6 !== void 0 ? _6 : setDraggingRow;
2943
+ (_5 = statefulTableOptions.onDraggingRowChange) !== null && _5 !== void 0 ? _5 : ((updater) => dragStore.set((prev) => (Object.assign(Object.assign({}, prev), { draggingRow: updater instanceof Function ? updater(prev.draggingRow) : updater }))));
2793
2944
  table.setEditingCell =
2794
- (_7 = statefulTableOptions.onEditingCellChange) !== null && _7 !== void 0 ? _7 : setEditingCell;
2945
+ (_6 = statefulTableOptions.onEditingCellChange) !== null && _6 !== void 0 ? _6 : ((updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { editingCell: updater instanceof Function ? updater(prev.editingCell) : updater }))));
2795
2946
  table.setEditingRow =
2796
- (_8 = statefulTableOptions.onEditingRowChange) !== null && _8 !== void 0 ? _8 : setEditingRow;
2797
- table.setFilters = (_9 = statefulTableOptions.onFiltersChange) !== null && _9 !== void 0 ? _9 : setFilters;
2947
+ (_7 = statefulTableOptions.onEditingRowChange) !== null && _7 !== void 0 ? _7 : ((updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { editingRow: updater instanceof Function ? updater(prev.editingRow) : updater }))));
2948
+ table.setFilters = (_8 = statefulTableOptions.onFiltersChange) !== null && _8 !== void 0 ? _8 : setFilters;
2798
2949
  table.setGlobalFilterFn =
2799
- (_10 = statefulTableOptions.onGlobalFilterFnChange) !== null && _10 !== void 0 ? _10 : setGlobalFilterFn;
2950
+ (_9 = statefulTableOptions.onGlobalFilterFnChange) !== null && _9 !== void 0 ? _9 : setGlobalFilterFn;
2800
2951
  table.setHoveredColumn =
2801
- (_11 = statefulTableOptions.onHoveredColumnChange) !== null && _11 !== void 0 ? _11 : setHoveredColumn;
2952
+ (_10 = statefulTableOptions.onHoveredColumnChange) !== null && _10 !== void 0 ? _10 : ((updater) => hoverStore.set((prev) => (Object.assign(Object.assign({}, prev), { hoveredColumn: updater instanceof Function ? updater(prev.hoveredColumn) : updater }))));
2802
2953
  table.setHoveredRow =
2803
- (_12 = statefulTableOptions.onHoveredRowChange) !== null && _12 !== void 0 ? _12 : setHoveredRow;
2804
- table.setSavedFilters = setSavedFilters;
2954
+ (_11 = statefulTableOptions.onHoveredRowChange) !== null && _11 !== void 0 ? _11 : ((updater) => hoverStore.set((prev) => (Object.assign(Object.assign({}, prev), { hoveredRow: updater instanceof Function ? updater(prev.hoveredRow) : updater }))));
2955
+ table.setSavedFilters = (updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { savedFilters: updater instanceof Function ? updater(prev.savedFilters) : updater })));
2805
2956
  table.setShowAlertBanner =
2806
- (_13 = statefulTableOptions.onShowAlertBannerChange) !== null && _13 !== void 0 ? _13 : setShowAlertBanner;
2957
+ (_12 = statefulTableOptions.onShowAlertBannerChange) !== null && _12 !== void 0 ? _12 : ((updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { showAlertBanner: updater instanceof Function ? updater(prev.showAlertBanner) : updater }))));
2807
2958
  table._showAdvancedFiltersSetterRef = showAdvancedFiltersSetterRef;
2808
2959
  table.setShowAdvancedFilters =
2809
- (_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); });
2960
+ (_13 = statefulTableOptions.onShowAdvancedFiltersChange) !== null && _13 !== void 0 ? _13 : ((updater) => { var _a; return (_a = showAdvancedFiltersSetterRef.current) === null || _a === void 0 ? void 0 : _a.call(showAdvancedFiltersSetterRef, updater); });
2810
2961
  table.setShowColumnFilters =
2811
- (_15 = statefulTableOptions.onShowColumnFiltersChange) !== null && _15 !== void 0 ? _15 : setShowColumnFilters;
2962
+ (_14 = statefulTableOptions.onShowColumnFiltersChange) !== null && _14 !== void 0 ? _14 : ((updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { showColumnFilters: updater instanceof Function
2963
+ ? updater(prev.showColumnFilters)
2964
+ : updater }))));
2812
2965
  table.setShowGlobalFilter =
2813
- (_16 = statefulTableOptions.onShowGlobalFilterChange) !== null && _16 !== void 0 ? _16 : setShowGlobalFilter;
2814
- table.setShowProgressBars = setShowProgressBars;
2966
+ (_15 = statefulTableOptions.onShowGlobalFilterChange) !== null && _15 !== void 0 ? _15 : ((updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { showGlobalFilter: updater instanceof Function
2967
+ ? updater(prev.showGlobalFilter)
2968
+ : updater }))));
2969
+ table.setShowProgressBars = (updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { showProgressBars: updater instanceof Function ? updater(prev.showProgressBars) : updater })));
2815
2970
  table.setShowToolbarDropZone =
2816
- (_17 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _17 !== void 0 ? _17 : setShowToolbarDropZone;
2817
- table.setNewEntryModal = setNewEntryModal;
2971
+ (_16 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _16 !== void 0 ? _16 : ((updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { showToolbarDropZone: updater instanceof Function
2972
+ ? updater(prev.showToolbarDropZone)
2973
+ : updater }))));
2974
+ table.setNewEntryModal = (updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { newEntryModal: updater instanceof Function ? updater(prev.newEntryModal) : updater })));
2818
2975
  table.setRowReorderingSelection =
2819
- (_18 = statefulTableOptions.onRowReorderingSelectionChange) !== null && _18 !== void 0 ? _18 : setRowReorderingSelection;
2976
+ (_17 = statefulTableOptions.onRowReorderingSelectionChange) !== null && _17 !== void 0 ? _17 : ((updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { rowReorderingSelection: updater instanceof Function
2977
+ ? updater(prev.rowReorderingSelection)
2978
+ : updater }))));
2820
2979
  table.addRow = handleAddRow({
2821
2980
  setRowsState,
2822
2981
  getRowId: resolveRowId,
@@ -2865,7 +3024,8 @@ const extraIndexRangeExtractor = (range, draggingIndex) => {
2865
3024
  const useMRT_ColumnVirtualizer = (table) => {
2866
3025
  var _a, _b, _c, _d;
2867
3026
  const { getState, options: { columnVirtualizerInstanceRef, columnVirtualizerOptions, enableColumnPinning, enableColumnVirtualization, }, refs: { tableContainerRef }, } = table;
2868
- const { columnPinning, columnVisibility, draggingColumn } = getState();
3027
+ const { columnPinning, columnVisibility } = getState();
3028
+ const draggingColumnId = useMRT_SliceValue(table._dragStore, (s) => { var _a; return (_a = s.draggingColumn) === null || _a === void 0 ? void 0 : _a.id; });
2869
3029
  if (!enableColumnVirtualization)
2870
3030
  return undefined;
2871
3031
  const columnVirtualizerProps = parseFromValuesOrFunc(columnVirtualizerOptions, {
@@ -2883,9 +3043,9 @@ const useMRT_ColumnVirtualizer = (table) => {
2883
3043
  : [[], []], [columnPinning, columnVisibility, enableColumnPinning]);
2884
3044
  const numPinnedLeft = leftPinnedIndexes.length;
2885
3045
  const numPinnedRight = rightPinnedIndexes.length;
2886
- const draggingColumnIndex = useMemo(() => (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id)
2887
- ? visibleColumns.findIndex((c) => c.id === (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id))
2888
- : undefined, [draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id]);
3046
+ const draggingColumnIndex = useMemo(() => draggingColumnId
3047
+ ? visibleColumns.findIndex((c) => c.id === draggingColumnId)
3048
+ : undefined, [draggingColumnId]);
2889
3049
  const columnVirtualizer = useVirtualizer(Object.assign({ count: visibleColumns.length, estimateSize: (index) => visibleColumns[index].getSize(), getScrollElement: () => tableContainerRef.current, horizontal: true, overscan: 3, rangeExtractor: useCallback((range) => {
2890
3050
  const newIndexes = extraIndexRangeExtractor(range, draggingColumnIndex);
2891
3051
  if (!numPinnedLeft && !numPinnedRight) {
@@ -2943,7 +3103,9 @@ const useMRT_Rows = (table) => {
2943
3103
 
2944
3104
  const useMRT_RowVirtualizer = (table, rows) => {
2945
3105
  const { getRowModel, getState, options: { enableRowVirtualization, renderDetailPanel, rowVirtualizerInstanceRef, rowVirtualizerOptions, }, refs: { tableContainerRef }, } = table;
2946
- const { density, draggingRow, expanded } = getState();
3106
+ const { expanded } = getState();
3107
+ const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
3108
+ const draggingRowId = useMRT_SliceValue(table._dragStore, (s) => { var _a; return (_a = s.draggingRow) === null || _a === void 0 ? void 0 : _a.id; });
2947
3109
  if (!enableRowVirtualization)
2948
3110
  return undefined;
2949
3111
  const rowVirtualizerProps = parseFromValuesOrFunc(rowVirtualizerOptions, {
@@ -2953,9 +3115,9 @@ const useMRT_RowVirtualizer = (table, rows) => {
2953
3115
  /**
2954
3116
  * when filtering, should find the correct index in filtered rows
2955
3117
  */
2956
- const draggingRowIndex = useMemo(() => (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id)
2957
- ? realRows.findIndex((r) => r.id === (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id))
2958
- : undefined, [realRows, draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id]);
3118
+ const draggingRowIndex = useMemo(() => draggingRowId
3119
+ ? realRows.findIndex((r) => r.id === draggingRowId)
3120
+ : undefined, [realRows, draggingRowId]);
2959
3121
  const rowCount = realRows.length;
2960
3122
  //matches the defaultRowHeight assumption in MRT_TableBodyRow so the
2961
3123
  //initial estimate (before measureElement corrects it for dynamic content)
@@ -3951,26 +4113,6 @@ const DimensionColumnResolver = {
3951
4113
  activeFilterRenderer: DimensionActiveFilterItem,
3952
4114
  };
3953
4115
 
3954
- const getEnumLabelByValue = (value, enumOptions) => {
3955
- var _a;
3956
- const normalizedValue = String(value !== null && value !== void 0 ? value : '');
3957
- const matchingOption = enumOptions.find((option) => option.value === normalizedValue);
3958
- return (_a = matchingOption === null || matchingOption === void 0 ? void 0 : matchingOption.label) !== null && _a !== void 0 ? _a : normalizedValue;
3959
- };
3960
- const EnumActiveFilterItem = (table, rule) => {
3961
- var _a, _b;
3962
- if (typeof rule.value !== 'string' && !Array.isArray(rule.value))
3963
- return null;
3964
- const column = getFilterColumn(table, rule.columnId);
3965
- const enumOptions = (_b = (_a = column === null || column === void 0 ? void 0 : column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.enumValues) !== null && _b !== void 0 ? _b : [];
3966
- if (rule.operator === 'isAnyOf' && Array.isArray(rule.value)) {
3967
- return (jsx(MRT_ActiveFilterItemContainer, { table: table, rule: rule, children: jsx(Typography, { variant: "body2", children: rule.value
3968
- .map((value) => getEnumLabelByValue(value, enumOptions))
3969
- .join(', ') }) }));
3970
- }
3971
- return (jsx(MRT_ActiveFilterItemContainer, { table: table, rule: rule, children: jsx(Typography, { variant: "body2", children: getEnumLabelByValue(rule.value, enumOptions) }) }));
3972
- };
3973
-
3974
4116
  const DEFAULT_FIELD_SIZE$4 = 'small';
3975
4117
  const MRT_FormEnumInput = ({ name, columnDef, fieldConfig, }) => {
3976
4118
  var _a, _b, _c;
@@ -4003,6 +4145,26 @@ const MRT_FormEnumInput = ({ name, columnDef, fieldConfig, }) => {
4003
4145
  } }));
4004
4146
  };
4005
4147
 
4148
+ const getEnumLabelByValue = (value, enumOptions) => {
4149
+ var _a;
4150
+ const normalizedValue = String(value !== null && value !== void 0 ? value : '');
4151
+ const matchingOption = enumOptions.find((option) => option.value === normalizedValue);
4152
+ return (_a = matchingOption === null || matchingOption === void 0 ? void 0 : matchingOption.label) !== null && _a !== void 0 ? _a : normalizedValue;
4153
+ };
4154
+ const EnumActiveFilterItem = (table, rule) => {
4155
+ var _a, _b;
4156
+ if (typeof rule.value !== 'string' && !Array.isArray(rule.value))
4157
+ return null;
4158
+ const column = getFilterColumn(table, rule.columnId);
4159
+ const enumOptions = (_b = (_a = column === null || column === void 0 ? void 0 : column.columnDef.meta) === null || _a === void 0 ? void 0 : _a.enumValues) !== null && _b !== void 0 ? _b : [];
4160
+ if (rule.operator === 'isAnyOf' && Array.isArray(rule.value)) {
4161
+ return (jsx(MRT_ActiveFilterItemContainer, { table: table, rule: rule, children: jsx(Typography, { variant: "body2", children: rule.value
4162
+ .map((value) => getEnumLabelByValue(value, enumOptions))
4163
+ .join(', ') }) }));
4164
+ }
4165
+ return (jsx(MRT_ActiveFilterItemContainer, { table: table, rule: rule, children: jsx(Typography, { variant: "body2", children: getEnumLabelByValue(rule.value, enumOptions) }) }));
4166
+ };
4167
+
4006
4168
  // Resolver for enum column type.
4007
4169
  // Renders only the human-readable label and provides select/multi-select filters.
4008
4170
  const EnumColumnResolver = {
@@ -5289,7 +5451,8 @@ const MRT_ActiveFilters = ({ table, }) => {
5289
5451
  const MRT_LinearProgressBar = (_a) => {
5290
5452
  var { isTopToolbar, table } = _a, rest = __rest(_a, ["isTopToolbar", "table"]);
5291
5453
  const { getState, options: { muiLinearProgressProps }, } = table;
5292
- const { isSaving, showProgressBars } = getState();
5454
+ const { isSaving } = getState();
5455
+ const showProgressBars = useMRT_SliceValue(table._uiStore, (s) => s.showProgressBars);
5293
5456
  const linearProgressProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiLinearProgressProps, {
5294
5457
  isTopToolbar,
5295
5458
  table,
@@ -5390,7 +5553,10 @@ const MRT_ToolbarDropZone = (_a) => {
5390
5553
  var _b, _c;
5391
5554
  var { table } = _a, rest = __rest(_a, ["table"]);
5392
5555
  const { getState, options: { enableGrouping, localization }, setHoveredColumn, setShowToolbarDropZone, } = table;
5393
- const { draggingColumn, grouping, hoveredColumn, showToolbarDropZone } = getState();
5556
+ const { grouping } = getState();
5557
+ const showToolbarDropZone = useMRT_SliceValue(table._uiStore, (s) => s.showToolbarDropZone);
5558
+ const draggingColumn = useMRT_SliceValue(table._dragStore, (s) => s.draggingColumn);
5559
+ const hoveredColumn = useMRT_SliceValue(table._hoverStore, (s) => s.hoveredColumn);
5394
5560
  const handleDragEnter = (_event) => {
5395
5561
  setHoveredColumn({ id: 'drop-zone' });
5396
5562
  };
@@ -5701,7 +5867,8 @@ const MRT_FilterOptionMenu = (_a) => {
5701
5867
  var _b, _c, _d, _e;
5702
5868
  var { anchorEl, header, onSelect, setAnchorEl, setFilterValue, table } = _a, rest = __rest(_a, ["anchorEl", "header", "onSelect", "setAnchorEl", "setFilterValue", "table"]);
5703
5869
  const { getState, options: { columnFilterModeOptions, globalFilterModeOptions, localization, mrtTheme: { menuBackgroundColor }, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
5704
- const { density, globalFilterFn } = getState();
5870
+ const { globalFilterFn } = getState();
5871
+ const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
5705
5872
  const { column } = header !== null && header !== void 0 ? header : {};
5706
5873
  const { columnDef } = column !== null && column !== void 0 ? column : {};
5707
5874
  const currentFilterValue = column === null || column === void 0 ? void 0 : column.getFilterValue();
@@ -5811,7 +5978,8 @@ const MRT_GlobalFilterTextField = (_a) => {
5811
5978
  var _b;
5812
5979
  var { table } = _a, rest = __rest(_a, ["table"]);
5813
5980
  const { getState, options: { enableGlobalFilterModes, icons: { CloseIcon, SearchIcon }, localization, manualFiltering, muiSearchTextFieldProps, }, refs: { searchInputRef }, setGlobalFilter, } = table;
5814
- const { globalFilter, showGlobalFilter } = getState();
5981
+ const { globalFilter } = getState();
5982
+ const showGlobalFilter = useMRT_SliceValue(table._uiStore, (s) => s.showGlobalFilter);
5815
5983
  const textFieldProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiSearchTextFieldProps, {
5816
5984
  table,
5817
5985
  })), rest);
@@ -5927,8 +6095,8 @@ function MRT_TableOptions(_a) {
5927
6095
  }
5928
6096
 
5929
6097
  const MRT_SavedFiltersButton = ({ onSelectFilter, table, }) => {
5930
- const { getState, options: { localization, onDeleteSavedFilter, onSaveFilters }, setFilters, setSavedFilters, } = table;
5931
- const { savedFilters } = getState();
6098
+ const { options: { localization, onDeleteSavedFilter, onSaveFilters }, setFilters, setSavedFilters, } = table;
6099
+ const savedFilters = useMRT_SliceValue(table._uiStore, (s) => s.savedFilters);
5932
6100
  const savedFiltersList = Object.values(savedFilters);
5933
6101
  const buttonRef = useRef(null);
5934
6102
  const [menuOpen, setMenuOpen] = useState(false);
@@ -5980,24 +6148,10 @@ const MRT_NewEntryButton = (_a) => {
5980
6148
  return (jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.newEntry, children: jsx(Button, Object.assign({ "aria-label": localization.newEntry, onClick: handleOpenNewEntryModal, size: "small", startIcon: jsx(AddIcon, { fontSize: "small" }), variant: "text" }, rest, { title: undefined, children: localization.newEntry })) }));
5981
6149
  };
5982
6150
 
5983
- const MRT_ColumnPinningButtons = (_a) => {
5984
- var { column, table } = _a, rest = __rest(_a, ["column", "table"]);
5985
- const { options: { icons: { PushPinIcon }, localization, }, } = table;
5986
- const handlePinColumn = (pinDirection) => {
5987
- column.pin(pinDirection);
5988
- };
5989
- return (jsx(Box, Object.assign({}, rest, { sx: (theme) => (Object.assign({ minWidth: '70px', textAlign: 'center' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: column.getIsPinned() ? (jsx(Tooltip, { title: localization.unpin, children: jsx(IconButton, { onClick: () => handlePinColumn(false), size: "small", children: jsx(PushPinIcon, {}) }) })) : (jsxs(Fragment, { children: [jsx(Tooltip, { title: localization.pinToLeft, children: jsx(IconButton, { onClick: () => handlePinColumn('left'), size: "small", children: jsx(PushPinIcon, { style: {
5990
- transform: 'rotate(90deg)',
5991
- } }) }) }), jsx(Tooltip, { title: localization.pinToRight, children: jsx(IconButton, { onClick: () => handlePinColumn('right'), size: "small", children: jsx(PushPinIcon, { style: {
5992
- transform: 'rotate(-90deg)',
5993
- } }) }) })] })) })));
5994
- };
5995
-
5996
6151
  const MRT_ShowHideColumnsMenuItems = (_a) => {
5997
6152
  var _b;
5998
6153
  var { allColumns, column, hoveredColumn, isNestedColumns, setHoveredColumn, table } = _a, rest = __rest(_a, ["allColumns", "column", "hoveredColumn", "isNestedColumns", "setHoveredColumn", "table"]);
5999
- const { getState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { draggingBorderColor }, }, setColumnOrder, setColumnPinning, } = table;
6000
- const { columnOrder } = getState();
6154
+ const { options: { enableHiding, localization, mrtTheme: { draggingBorderColor }, }, } = table;
6001
6155
  const { columnDef } = column;
6002
6156
  const { columnDefType } = columnDef;
6003
6157
  const switchChecked = column.getIsVisible();
@@ -6012,63 +6166,30 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
6012
6166
  column.toggleVisibility();
6013
6167
  }
6014
6168
  };
6015
- const menuItemRef = useRef(null);
6016
- const [isDragging, setIsDragging] = useState(false);
6017
- const handleDragStart = (e) => {
6018
- setIsDragging(true);
6019
- try {
6020
- e.dataTransfer.setDragImage(menuItemRef.current, 0, 0);
6021
- }
6022
- catch (e) {
6023
- console.error(e);
6024
- }
6025
- };
6026
- const handleDragEnd = (_e) => {
6027
- setIsDragging(false);
6028
- setHoveredColumn(null);
6029
- if (hoveredColumn) {
6030
- const reorderedColumns = reorderColumn(column, hoveredColumn, columnOrder);
6031
- setColumnOrder(reorderedColumns);
6032
- setColumnPinning(({ left = [], right = [] }) => ({
6033
- left: reorderedColumns.filter((header) => left.includes(header)),
6034
- right: reorderedColumns.filter((header) => right.includes(header)),
6035
- }));
6036
- }
6037
- };
6038
- const handleDragEnter = (_e) => {
6039
- if (!isDragging && columnDef.enableColumnOrdering !== false) {
6040
- setHoveredColumn(column);
6041
- }
6042
- };
6043
6169
  if (!columnDef.header || columnDef.visibleInShowHideMenu === false) {
6044
6170
  return null;
6045
6171
  }
6046
- return (jsxs(Fragment, { children: [jsx(MenuItem, Object.assign({ disableRipple: true, onDragEnter: handleDragEnter, ref: menuItemRef }, rest, { sx: (theme) => (Object.assign({ alignItems: 'center', justifyContent: 'flex-start', my: 0, opacity: isDragging ? 0.5 : 1, outline: isDragging
6047
- ? `2px dashed ${theme.palette.grey[500]}`
6048
- : (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
6049
- ? `2px dashed ${draggingBorderColor}`
6050
- : 'none', outlineOffset: '-2px', pl: `${(column.depth + 0.5) * 2}rem`, py: '6px' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: jsxs(Box, { "data-testid": `column-show-hide-row-${column.id}`, sx: {
6172
+ return (jsxs(Fragment, { children: [jsx(MenuItem, Object.assign({ disableRipple: true }, rest, { sx: (theme) => (Object.assign({ alignItems: 'center', justifyContent: 'flex-start', my: 0, outline: (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
6173
+ ? `2px dashed ${draggingBorderColor}`
6174
+ : 'none', outlineOffset: '-2px', pl: `${(column.depth + 0.5) * 2}rem`, py: '6px' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: jsx(Box, { "data-testid": `column-show-hide-row-${column.id}`, sx: {
6051
6175
  display: 'flex',
6052
6176
  flexWrap: 'nowrap',
6053
6177
  gap: '8px',
6054
- }, children: [columnDefType !== 'group' &&
6055
- enableColumnOrdering &&
6056
- !isNestedColumns &&
6057
- (columnDef.enableColumnOrdering !== false ? (jsx(MRT_GrabHandleButton, { onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })) : (jsx(Box, { sx: { width: '28px' } }))), enableColumnPinning &&
6058
- (column.getCanPin() ? (jsx(MRT_ColumnPinningButtons, { column: column, table: table })) : (jsx(Box, { sx: { width: '70px' } }))), enableHiding ? (jsx(FormControlLabel, { checked: switchChecked, componentsProps: {
6059
- typography: {
6060
- sx: {
6061
- mb: 0,
6062
- opacity: columnDefType !== 'display' ? 1 : 0.5,
6063
- },
6178
+ }, children: enableHiding ? (jsx(FormControlLabel, { checked: switchChecked, componentsProps: {
6179
+ typography: {
6180
+ sx: {
6181
+ mb: 0,
6182
+ opacity: columnDefType !== 'display' ? 1 : 0.5,
6064
6183
  },
6065
- }, control: jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.toggleVisibility, children: jsx(Switch, { size: "small" }) })), disabled: !column.getCanHide(), label: columnDef.header, onChange: () => handleToggleColumnHidden(column) })) : (jsx(Typography, { sx: { alignSelf: 'center' }, children: columnDef.header }))] }) })), (_b = column.columns) === null || _b === void 0 ? void 0 : _b.map((c, i) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${i}-${c.id}`)))] }));
6184
+ },
6185
+ }, control: jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.toggleVisibility, children: jsx(Switch, { size: "small" }) })), disabled: !column.getCanHide(), label: columnDef.header, onChange: () => handleToggleColumnHidden(column) })) : (jsx(Typography, { sx: { alignSelf: 'center' }, children: columnDef.header })) }) })), (_b = column.columns) === null || _b === void 0 ? void 0 : _b.map((c, i) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: c, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${i}-${c.id}`)))] }));
6066
6186
  };
6067
6187
 
6068
6188
  const MRT_ShowHideColumnsMenu = (_a) => {
6069
6189
  var { anchorEl, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "setAnchorEl", "table"]);
6070
- const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsPinned, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, getState, initialState, options: { enableColumnOrdering, enableColumnPinning, enableHiding, localization, mrtTheme: { menuBackgroundColor }, }, } = table;
6071
- const { columnOrder, columnPinning, density } = getState();
6190
+ const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, getState, options: { enableHiding, localization, mrtTheme: { menuBackgroundColor }, }, } = table;
6191
+ const { columnOrder, columnPinning } = getState();
6192
+ const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
6072
6193
  const handleToggleAllColumns = (value) => {
6073
6194
  const updates = getAllLeafColumns()
6074
6195
  .filter((column) => column.columnDef.enableHiding !== false)
@@ -6098,8 +6219,6 @@ const MRT_ShowHideColumnsMenu = (_a) => {
6098
6219
  getRightLeafColumns(),
6099
6220
  ]);
6100
6221
  const isNestedColumns = allColumns.some((col) => col.columnDef.columnDefType === 'group');
6101
- const hasColumnOrderChanged = useMemo(() => columnOrder.length !== initialState.columnOrder.length ||
6102
- !columnOrder.every((column, index) => column === initialState.columnOrder[index]), [columnOrder, initialState.columnOrder]);
6103
6222
  const [hoveredColumn, setHoveredColumn] = useState(null);
6104
6223
  return (jsxs(Menu, Object.assign({ MenuListProps: {
6105
6224
  dense: density === 'compact',
@@ -6111,7 +6230,7 @@ const MRT_ShowHideColumnsMenu = (_a) => {
6111
6230
  justifyContent: 'space-between',
6112
6231
  p: '0.5rem',
6113
6232
  pt: 0,
6114
- }, children: [enableHiding && (jsx(Button, { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), children: localization.hideAll })), enableColumnOrdering && (jsx(Button, { onClick: () => table.setColumnOrder(getDefaultColumnOrderIds(table.options, true)), disabled: !hasColumnOrderChanged, children: localization.resetOrder })), enableColumnPinning && (jsx(Button, { disabled: !getIsSomeColumnsPinned(), onClick: () => table.resetColumnPinning(true), children: localization.unpinAll })), enableHiding && (jsx(Button, { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), children: localization.showAll }))] }), jsx(Divider, {}), allColumns.map((column, index) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] })));
6233
+ }, children: [enableHiding && (jsx(Button, { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), children: localization.hideAll })), enableHiding && (jsx(Button, { disabled: getIsAllColumnsVisible(), onClick: () => handleToggleAllColumns(true), children: localization.showAll }))] }), jsx(Divider, {}), allColumns.map((column, index) => (jsx(MRT_ShowHideColumnsMenuItems, { allColumns: allColumns, column: column, hoveredColumn: hoveredColumn, isNestedColumns: isNestedColumns, setHoveredColumn: setHoveredColumn, table: table }, `${index}-${column.id}`)))] })));
6115
6234
  };
6116
6235
 
6117
6236
  const MRT_ShowHideColumnsButton = (_a) => {
@@ -6165,8 +6284,8 @@ const getDensityOptions = ({ icons: { DensityLargeIcon, DensityMediumIcon, Densi
6165
6284
 
6166
6285
  const MRT_ToggleDensePaddingMenu = (_a) => {
6167
6286
  var { anchorEl, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "setAnchorEl", "table"]);
6168
- const { getState, options: { icons, localization }, setDensity, } = table;
6169
- const { density } = getState();
6287
+ const { options: { icons, localization }, setDensity, } = table;
6288
+ const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
6170
6289
  const handleCloseMenu = () => {
6171
6290
  setAnchorEl(null);
6172
6291
  };
@@ -6194,8 +6313,8 @@ const MRT_ToggleDensePaddingMenu = (_a) => {
6194
6313
  const MRT_ToggleDensePaddingButton = (_a) => {
6195
6314
  var _b;
6196
6315
  var { table } = _a, rest = __rest(_a, ["table"]);
6197
- const { getState, options: { icons: { DensityLargeIcon, DensityMediumIcon, DensitySmallIcon }, localization, }, } = table;
6198
- const { density } = getState();
6316
+ const { options: { icons: { DensityLargeIcon, DensityMediumIcon, DensitySmallIcon }, localization, }, } = table;
6317
+ const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
6199
6318
  const [anchorEl, setAnchorEl] = useState(null);
6200
6319
  const handleOpenMenu = (event) => {
6201
6320
  setAnchorEl(event.currentTarget);
@@ -6211,8 +6330,8 @@ const MRT_ToggleDensePaddingButton = (_a) => {
6211
6330
  const MRT_ToggleFiltersButton = (_a) => {
6212
6331
  var _b;
6213
6332
  var { table } = _a, rest = __rest(_a, ["table"]);
6214
- const { getState, options: { icons: { FilterListIcon, FilterListOffIcon }, localization, }, setShowColumnFilters, } = table;
6215
- const { showColumnFilters } = getState();
6333
+ const { options: { icons: { FilterListIcon, FilterListOffIcon }, localization, }, setShowColumnFilters, } = table;
6334
+ const showColumnFilters = useMRT_SliceValue(table._uiStore, (s) => s.showColumnFilters);
6216
6335
  const handleToggleShowFilters = () => {
6217
6336
  setShowColumnFilters(!showColumnFilters);
6218
6337
  };
@@ -6223,7 +6342,8 @@ const MRT_ToggleGlobalFilterButton = (_a) => {
6223
6342
  var _b, _c;
6224
6343
  var { table } = _a, rest = __rest(_a, ["table"]);
6225
6344
  const { getState, options: { icons: { SearchIcon, SearchOffIcon }, localization, }, refs: { searchInputRef }, setShowGlobalFilter, } = table;
6226
- const { globalFilter, showGlobalFilter } = getState();
6345
+ const { globalFilter } = getState();
6346
+ const showGlobalFilter = useMRT_SliceValue(table._uiStore, (s) => s.showGlobalFilter);
6227
6347
  const handleToggleSearch = () => {
6228
6348
  setShowGlobalFilter(!showGlobalFilter);
6229
6349
  queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
@@ -6278,7 +6398,7 @@ const MRT_TopToolbar = ({ table, }) => {
6278
6398
  : undefined,
6279
6399
  table,
6280
6400
  };
6281
- return (jsxs(Box, Object.assign({}, toolbarProps, { ref: (ref) => {
6401
+ return (jsxs(Box, Object.assign({ "data-testid": "top-toolbar" }, toolbarProps, { ref: (ref) => {
6282
6402
  topToolbarRef.current = ref;
6283
6403
  if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
6284
6404
  // @ts-expect-error
@@ -6294,23 +6414,30 @@ const MRT_TopToolbar = ({ table, }) => {
6294
6414
  px: '0.5rem',
6295
6415
  width: '100%',
6296
6416
  position: 'relative',
6297
- }, children: [enableGlobalFilter && positionGlobalFilter === 'left' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), jsxs(Fragment, { children: [enableGlobalFilter && positionGlobalFilter === 'left' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), enableToolbarInternalActions ? (jsxs(Box, { sx: {
6417
+ }, children: [jsxs(Fragment, { children: [enableGlobalFilter && positionGlobalFilter === 'left' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), enableToolbarInternalActions ? (jsxs(Box, { sx: {
6298
6418
  alignItems: 'center',
6299
6419
  display: 'flex',
6300
6420
  flexWrap: 'wrap-reverse',
6301
6421
  gap: '0.5rem',
6302
- justifyContent: 'flex-start',
6303
- width: '100%',
6304
- }, children: [enableGlobalFilter && positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), (_a = renderTopToolbarCustomActions === null || renderTopToolbarCustomActions === void 0 ? void 0 : renderTopToolbarCustomActions({ table })) !== null && _a !== void 0 ? _a : jsx("span", {}), jsx(MRT_ToolbarInternalButtons, { table: table })] })) : (enableGlobalFilter &&
6305
- positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))))] }), jsx(ToolbarActions, { table: table }), jsx(MRT_TableOptions, { table: table })] }), ['both', 'top'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (jsx(MRT_ToolbarDropZone, { table: table })), enablePagination &&
6422
+ }, children: [enableGlobalFilter && positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), jsx(MRT_ToolbarInternalButtons, { table: table })] })) : (enableGlobalFilter &&
6423
+ positionGlobalFilter === 'right' && (jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))))] }), jsx(ToolbarActions, { table: table }), jsxs(Box, { sx: {
6424
+ alignItems: 'center',
6425
+ display: 'flex',
6426
+ gap: '0.5rem',
6427
+ marginLeft: 'auto',
6428
+ }, children: [(_a = (enableToolbarInternalActions &&
6429
+ (renderTopToolbarCustomActions === null || renderTopToolbarCustomActions === void 0 ? void 0 : renderTopToolbarCustomActions({
6430
+ table,
6431
+ })))) !== null && _a !== void 0 ? _a : jsx("span", {}), jsx(MRT_TableOptions, { table: table })] })] }), ['both', 'top'].includes(positionToolbarDropZone !== null && positionToolbarDropZone !== void 0 ? positionToolbarDropZone : '') && (jsx(MRT_ToolbarDropZone, { table: table })), enablePagination &&
6306
6432
  ['both', 'top'].includes(positionPagination !== null && positionPagination !== void 0 ? positionPagination : '') && (jsx(MRT_TablePagination, { position: "top", table: table })), jsx(MRT_LinearProgressBar, { isTopToolbar: true, table: table })] })));
6307
6433
  };
6308
6434
 
6309
6435
  const MRT_CellActionMenu = (_a) => {
6310
6436
  var _b, _c;
6311
6437
  var { table } = _a, rest = __rest(_a, ["table"]);
6312
- const { getState, options: { editDisplayMode, enableClickToCopy, enableEditing, icons: { ContentCopy, EditIcon }, localization, mrtTheme: { menuBackgroundColor }, renderCellActionMenuItems, }, refs: { actionCellRef }, } = table;
6313
- const { actionCell, density } = getState();
6438
+ const { options: { editDisplayMode, enableClickToCopy, enableEditing, icons: { ContentCopy, EditIcon }, localization, mrtTheme: { menuBackgroundColor }, renderCellActionMenuItems, }, refs: { actionCellRef }, } = table;
6439
+ const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
6440
+ const actionCell = useMRT_SliceValue(table._uiStore, (s) => s.actionCell);
6314
6441
  const cell = actionCell;
6315
6442
  const { row } = cell;
6316
6443
  const { column } = cell;
@@ -6357,10 +6484,10 @@ const MRT_EditCellTextField = (_a) => {
6357
6484
  const { getState, options: { createDisplayMode, editDisplayMode, muiEditTextFieldProps }, refs: { editInputRefs }, setCreatingRow, setEditingCell, setEditingRow, } = table;
6358
6485
  const { column, row } = cell;
6359
6486
  const { columnDef } = column;
6360
- const { creatingRow, editingRow } = getState();
6487
+ const { creatingRow } = getState();
6361
6488
  const { editSelectOptions, editVariant } = columnDef;
6362
6489
  const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
6363
- const isEditing = (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id;
6490
+ const isEditing = useMRT_SliceValue(table._uiStore, (s) => { var _a; return ((_a = s.editingRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
6364
6491
  const [value, setValue] = useState(() => cell.getValue());
6365
6492
  const [completesComposition, setCompletesComposition] = useState(true);
6366
6493
  const textFieldProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditTextFieldProps, {
@@ -6453,7 +6580,8 @@ const MRT_EditRowModal = (_a) => {
6453
6580
  var _b;
6454
6581
  var { open, table } = _a, rest = __rest(_a, ["open", "table"]);
6455
6582
  const { getState, options: { localization, muiCreateRowModalProps, muiEditRowDialogProps, onCreatingRowCancel, onEditingRowCancel, renderCreateRowDialogContent, renderEditRowDialogContent, }, setCreatingRow, setEditingRow, } = table;
6456
- const { creatingRow, editingRow } = getState();
6583
+ const { creatingRow } = getState();
6584
+ const editingRow = useMRT_SliceValue(table._uiStore, (s) => s.editingRow);
6457
6585
  const row = (creatingRow !== null && creatingRow !== void 0 ? creatingRow : editingRow);
6458
6586
  const dialogProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditRowDialogProps, { row, table })), (creatingRow &&
6459
6587
  parseFromValuesOrFunc(muiCreateRowModalProps, { row, table }))), rest);
@@ -6666,8 +6794,8 @@ const FormFieldControl = ({ columnId, columnDef, fieldConfig, table, }) => {
6666
6794
  const MRT_NewEntryForm = ({ table, }) => {
6667
6795
  var _a, _b, _c;
6668
6796
  const methods = useFormContext();
6669
- const { getState, options: { formConfig, icons: { ExpandMoreIcon }, }, } = table;
6670
- const { newEntryModal } = getState();
6797
+ const { options: { formConfig, icons: { ExpandMoreIcon }, }, } = table;
6798
+ const newEntryModal = useMRT_SliceValue(table._uiStore, (s) => s.newEntryModal);
6671
6799
  const mode = (_a = newEntryModal.mode) !== null && _a !== void 0 ? _a : 'create';
6672
6800
  // Consumer controls the entire form body — skip all field calculations.
6673
6801
  if (formConfig === null || formConfig === void 0 ? void 0 : formConfig.renderForm) {
@@ -6716,8 +6844,8 @@ const MRT_NewEntryFormActions = ({ table, }) => {
6716
6844
  var _a, _b;
6717
6845
  const methods = useFormContext();
6718
6846
  const { handleCancel, handleSave } = useMRT_NewEntryFormActions();
6719
- const { getState, options: { formConfig, localization, muiNewEntryModalProps }, } = table;
6720
- const { newEntryModal } = getState();
6847
+ const { options: { formConfig, localization, muiNewEntryModalProps }, } = table;
6848
+ const newEntryModal = useMRT_SliceValue(table._uiStore, (s) => s.newEntryModal);
6721
6849
  const mode = (_a = newEntryModal.mode) !== null && _a !== void 0 ? _a : 'create';
6722
6850
  const resolvedModalProps = muiNewEntryModalProps !== null && muiNewEntryModalProps !== void 0 ? muiNewEntryModalProps : {};
6723
6851
  const { footerProps, footerSx } = resolvedModalProps;
@@ -6738,8 +6866,8 @@ const RHF_FormProvider = (_a) => {
6738
6866
  // Place this above any component that needs form state (fields body or actions footer).
6739
6867
  const MRT_NewEntryFormProvider = ({ table, children, }) => {
6740
6868
  var _a;
6741
- const { getState, options: { formConfig }, setNewEntryModal, } = table;
6742
- const { newEntryModal } = getState();
6869
+ const { options: { formConfig }, setNewEntryModal, } = table;
6870
+ const newEntryModal = useMRT_SliceValue(table._uiStore, (s) => s.newEntryModal);
6743
6871
  // Default to 'create' when mode is not explicitly provided.
6744
6872
  const mode = (_a = newEntryModal.mode) !== null && _a !== void 0 ? _a : 'create';
6745
6873
  const defaultValues = buildDefaultValues(table, newEntryModal.initialValues, mode);
@@ -6789,11 +6917,11 @@ const clampOffset = (value, fallback) => {
6789
6917
  };
6790
6918
  const MRT_NewEntryModal = ({ table, }) => {
6791
6919
  const theme = useTheme();
6792
- const { getState, options: { formConfig, icons: { CancelIcon }, localization, muiNewEntryModalProps, }, setNewEntryModal, } = table;
6920
+ const { options: { formConfig, icons: { CancelIcon }, localization, muiNewEntryModalProps, }, setNewEntryModal, } = table;
6793
6921
  // Resolve muiNewEntryModalProps — plain object, defaults to empty object.
6794
6922
  const resolvedModalProps = muiNewEntryModalProps !== null && muiNewEntryModalProps !== void 0 ? muiNewEntryModalProps : {};
6795
6923
  const { title: titleOverride, contentContainerSx, headerSx, headerProps, bodySx, bodyProps, modalSx, modalProps, closeButtonProps, disableHeader, position, headerComponents, } = resolvedModalProps;
6796
- const { newEntryModal } = getState();
6924
+ const newEntryModal = useMRT_SliceValue(table._uiStore, (s) => s.newEntryModal);
6797
6925
  // Whether the modal was opened in edit mode — determines the title.
6798
6926
  const isEditMode = newEntryModal.mode === 'edit';
6799
6927
  const handleClose = () => {
@@ -6943,10 +7071,19 @@ const MRT_TableBodyCell = (_a) => {
6943
7071
  var _b, _c, _d, _e;
6944
7072
  var { cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table, theme } = _a, rest = __rest(_a, ["cell", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table", "theme"]);
6945
7073
  const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableCellActions, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableGrouping, enableKeyboardShortcuts, layoutMode, mrtTheme: { draggingBorderColor }, muiSkeletonProps, muiTableBodyCellProps, }, setHoveredColumn, } = table;
6946
- const { actionCell, columnSizingInfo, creatingRow, density, draggingColumn, draggingRow, editingCell, editingRow, hoveredColumn, hoveredRow, isLoading, showSkeletons, } = getState();
7074
+ const { creatingRow, isLoading, showSkeletons } = getState();
7075
+ const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
6947
7076
  const { column, row } = cell;
6948
7077
  const { columnDef } = column;
6949
7078
  const { columnDefType } = columnDef;
7079
+ const isResizingThisColumn = useMRT_SliceValue(table._uiStore, (s) => s.columnSizingInfo.isResizingColumn === column.id);
7080
+ const isEditingRow = useMRT_SliceValue(table._uiStore, (s) => { var _a; return ((_a = s.editingRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
7081
+ const isActionCell = useMRT_SliceValue(table._uiStore, (s) => { var _a; return ((_a = s.actionCell) === null || _a === void 0 ? void 0 : _a.id) === cell.id; });
7082
+ const isEditingCell = useMRT_SliceValue(table._uiStore, (s) => { var _a; return ((_a = s.editingCell) === null || _a === void 0 ? void 0 : _a.id) === cell.id; });
7083
+ const isDraggingColumn = useMRT_SliceValue(table._dragStore, (s) => { var _a; return ((_a = s.draggingColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id; });
7084
+ const isDraggingRow = useMRT_SliceValue(table._dragStore, (s) => { var _a; return ((_a = s.draggingRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
7085
+ const isHoveredColumn = useMRT_SliceValue(table._hoverStore, (s) => { var _a; return ((_a = s.hoveredColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id; });
7086
+ const isHoveredRow = useMRT_SliceValue(table._hoverStore, (s) => { var _a; return ((_a = s.hoveredRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
6950
7087
  const args = { cell, column, row, table };
6951
7088
  const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableBodyCellProps, args)), rest);
6952
7089
  const skeletonProps = parseFromValuesOrFunc(muiSkeletonProps, {
@@ -6965,14 +7102,10 @@ const MRT_TableBodyCell = (_a) => {
6965
7102
  : Math.round(Math.random() * (size - size / 3) + size / 3));
6966
7103
  }, [isLoading, showSkeletons]);
6967
7104
  const draggingBorders = useMemo(() => {
6968
- const isDraggingColumn = (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id;
6969
- const isHoveredColumn = (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id;
6970
- const isDraggingRow = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id;
6971
- const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
6972
7105
  const isFirstColumn = column.getIsFirstColumn();
6973
7106
  const isLastColumn = column.getIsLastColumn();
6974
7107
  const isLastRow = numRows && staticRowIndex === numRows - 1;
6975
- const isResizingColumn = columnSizingInfo.isResizingColumn === column.id;
7108
+ const isResizingColumn = isResizingThisColumn;
6976
7109
  const showResizeBorder = isResizingColumn && columnResizeMode === 'onChange';
6977
7110
  const borderStyle = showResizeBorder
6978
7111
  ? `2px solid ${draggingBorderColor} !important`
@@ -7005,11 +7138,11 @@ const MRT_TableBodyCell = (_a) => {
7005
7138
  }
7006
7139
  : undefined;
7007
7140
  }, [
7008
- columnSizingInfo.isResizingColumn,
7009
- draggingColumn,
7010
- draggingRow,
7011
- hoveredColumn,
7012
- hoveredRow,
7141
+ isResizingThisColumn,
7142
+ isDraggingColumn,
7143
+ isDraggingRow,
7144
+ isHoveredColumn,
7145
+ isHoveredRow,
7013
7146
  staticRowIndex,
7014
7147
  ]);
7015
7148
  const isColumnPinned = enableColumnPinning &&
@@ -7018,9 +7151,7 @@ const MRT_TableBodyCell = (_a) => {
7018
7151
  const isEditable = isCellEditable({ cell, table });
7019
7152
  const isEditing = isEditable &&
7020
7153
  !['custom', 'modal'].includes(editDisplayMode) &&
7021
- (editDisplayMode === 'table' ||
7022
- (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) === row.id ||
7023
- (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) === cell.id) &&
7154
+ (editDisplayMode === 'table' || isEditingRow || isEditingCell) &&
7024
7155
  !row.getIsGrouped();
7025
7156
  const isCreating = isEditable && createDisplayMode === 'row' && (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
7026
7157
  const showClickToCopyButton = (parseFromValuesOrFunc(enableClickToCopy, cell) === true ||
@@ -7041,12 +7172,13 @@ const MRT_TableBodyCell = (_a) => {
7041
7172
  openEditingCell({ cell, table });
7042
7173
  };
7043
7174
  const handleDragEnter = (e) => {
7044
- var _a;
7175
+ var _a, _b;
7045
7176
  (_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDragEnter) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
7046
- if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
7177
+ if (enableGrouping &&
7178
+ ((_b = table._hoverStore.get().hoveredColumn) === null || _b === void 0 ? void 0 : _b.id) === 'drop-zone') {
7047
7179
  setHoveredColumn(null);
7048
7180
  }
7049
- if (enableColumnOrdering && draggingColumn) {
7181
+ if (enableColumnOrdering && table._dragStore.get().draggingColumn) {
7050
7182
  setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
7051
7183
  }
7052
7184
  };
@@ -7075,7 +7207,7 @@ const MRT_TableBodyCell = (_a) => {
7075
7207
  });
7076
7208
  };
7077
7209
  return (jsx(TableCell, Object.assign({ align: theme.direction === 'rtl' ? 'right' : 'left', "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, tabIndex: enableKeyboardShortcuts ? 0 : undefined }, tableCellProps, { onKeyDown: handleKeyDown, onContextMenu: handleContextMenu, onDoubleClick: handleDoubleClick, onDragEnter: handleDragEnter, onDragOver: handleDragOver, sx: (theme) => (Object.assign(Object.assign({ '&:hover': {
7078
- outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id ||
7210
+ outline: isActionCell ||
7079
7211
  (editDisplayMode === 'cell' && isEditable) ||
7080
7212
  (editDisplayMode === 'table' && (isCreating || isEditing))
7081
7213
  ? `1px solid ${theme.palette.grey[500]}`
@@ -7085,20 +7217,14 @@ const MRT_TableBodyCell = (_a) => {
7085
7217
  ? 'context-menu'
7086
7218
  : isEditable && editDisplayMode === 'cell'
7087
7219
  ? 'pointer'
7088
- : 'inherit', outline: (actionCell === null || actionCell === void 0 ? void 0 : actionCell.id) === cell.id
7220
+ : 'inherit', outline: isActionCell
7089
7221
  ? `1px solid ${theme.palette.grey[500]}`
7090
- : undefined, outlineOffset: '-1px', overflow: 'hidden', p: density === 'compact'
7091
- ? columnDefType === 'display'
7092
- ? '0 0.5rem'
7093
- : '0.5rem'
7094
- : density === 'comfortable'
7095
- ? columnDefType === 'display'
7096
- ? '0.5rem 0.75rem'
7097
- : '1rem'
7098
- : columnDefType === 'display'
7099
- ? '1rem 1.25rem'
7100
- : '1.5rem', textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, whiteSpace: row.getIsPinned() || density === 'compact' ? 'nowrap' : 'normal' }, getCommonMRTCellStyles({
7222
+ : undefined, outlineOffset: '-1px', overflow: 'hidden', p: columnDefType === 'display'
7223
+ ? 'var(--mrt-display-cell-p)'
7224
+ : 'var(--mrt-cell-p)', textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, whiteSpace: row.getIsPinned() || density === 'compact' ? 'nowrap' : 'normal' }, getCommonMRTCellStyles({
7101
7225
  column,
7226
+ isDraggingColumn,
7227
+ isHoveredColumn,
7102
7228
  table,
7103
7229
  tableCellProps,
7104
7230
  theme,
@@ -7142,13 +7268,17 @@ const MRT_TableBodyRow = (_a) => {
7142
7268
  var _b, _c, _d, _f;
7143
7269
  var { columnVirtualizer, numRows, pinnedRowIds, row, rowVirtualizer, staticRowIndex, table, theme, virtualRow } = _a, rest = __rest(_a, ["columnVirtualizer", "numRows", "pinnedRowIds", "row", "rowVirtualizer", "staticRowIndex", "table", "theme", "virtualRow"]);
7144
7270
  const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, memoMode, mrtTheme: { baseBackgroundColor, pinnedRowBackgroundColor, selectedRowBackgroundColor, }, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
7145
- const { density, draggingColumn, draggingRow, editingCell, editingRow, hoveredRow, rowPinning, } = getState();
7271
+ const { rowPinning } = getState();
7272
+ const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
7273
+ const editingCell = useMRT_SliceValue(table._uiStore, (s) => s.editingCell);
7274
+ const isEditingRow = useMRT_SliceValue(table._uiStore, (s) => { var _a; return ((_a = s.editingRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
7275
+ const isDraggingRow = useMRT_SliceValue(table._dragStore, (s) => { var _a; return ((_a = s.draggingRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
7276
+ const isHoveredRow = useMRT_SliceValue(table._hoverStore, (s) => { var _a; return ((_a = s.hoveredRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
7277
+ const isAnyDragging = useMRT_SliceValue(table._dragStore, (s) => !!s.draggingColumn || !!s.draggingRow);
7146
7278
  const visibleCells = row.getVisibleCells();
7147
7279
  const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
7148
7280
  const isRowSelected = getIsRowSelected({ row, table });
7149
7281
  const isRowPinned = enableRowPinning && row.getIsPinned();
7150
- const isDraggingRow = (draggingRow === null || draggingRow === void 0 ? void 0 : draggingRow.id) === row.id;
7151
- const isHoveredRow = (hoveredRow === null || hoveredRow === void 0 ? void 0 : hoveredRow.id) === row.id;
7152
7282
  const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyRowProps, {
7153
7283
  row,
7154
7284
  staticRowIndex,
@@ -7174,7 +7304,7 @@ const MRT_TableBodyRow = (_a) => {
7174
7304
  parseInt((_f = (_d = tableRowProps === null || tableRowProps === void 0 ? void 0 : tableRowProps.style) === null || _d === void 0 ? void 0 : _d.height) !== null && _f !== void 0 ? _f : sx === null || sx === void 0 ? void 0 : sx.height, 10) || undefined;
7175
7305
  const rowHeight = customRowHeight || defaultRowHeight;
7176
7306
  const handleDragEnter = (_e) => {
7177
- if (enableRowOrdering && draggingRow) {
7307
+ if (enableRowOrdering && table._dragStore.get().draggingRow) {
7178
7308
  setHoveredRow(row);
7179
7309
  }
7180
7310
  };
@@ -7234,13 +7364,12 @@ const MRT_TableBodyRow = (_a) => {
7234
7364
  table,
7235
7365
  theme,
7236
7366
  };
7237
- const key = `${cell.id}-${staticRowIndex}`;
7367
+ const key = cell.id;
7238
7368
  return cell ? (memoMode === 'cells' &&
7239
7369
  cell.column.columnDef.columnDefType === 'data' &&
7240
- !draggingColumn &&
7241
- !draggingRow &&
7370
+ !isAnyDragging &&
7242
7371
  (editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) !== cell.id &&
7243
- (editingRow === null || editingRow === void 0 ? void 0 : editingRow.id) !== row.id ? (jsx(Memo_MRT_TableBodyCell, Object.assign({}, props), key)) : (jsx(MRT_TableBodyCell, Object.assign({}, props), key))) : null;
7372
+ !isEditingRow ? (jsx(Memo_MRT_TableBodyCell, Object.assign({}, props), key)) : (jsx(MRT_TableBodyCell, Object.assign({}, props), key))) : null;
7244
7373
  }), virtualPaddingRight ? (jsx("td", { style: { display: 'flex', width: virtualPaddingRight } })) : null] })), renderDetailPanel && !row.getIsGrouped() && (jsx(MRT_TableDetailPanel, { parentRowRef: rowRef, row: row, rowVirtualizer: rowVirtualizer, staticRowIndex: staticRowIndex, table: table, virtualRow: virtualRow }))] }));
7245
7374
  };
7246
7375
  const Memo_MRT_TableBodyRow = memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.staticRowIndex === next.staticRowIndex);
@@ -7318,7 +7447,7 @@ const MRT_TableBody = (_a) => {
7318
7447
  staticRowIndex, virtualRow: rowVirtualizer
7319
7448
  ? rowOrVirtualRow
7320
7449
  : undefined });
7321
- const key = `${row.id}-${row.index}`;
7450
+ const key = row.id;
7322
7451
  return memoMode === 'rows' ? (jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), key)) : (jsx(MRT_TableBodyRow, Object.assign({}, props), key));
7323
7452
  }) }))) })), !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
7324
7453
  getIsSomeRowsPinned('bottom') && (jsx(TableBody, Object.assign({}, tableBodyProps, { sx: (theme) => (Object.assign({ bottom: tableFooterHeight - 1, display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'grid' : undefined, position: 'sticky', zIndex: 1 }, parseFromValuesOrFunc(tableBodyProps === null || tableBodyProps === void 0 ? void 0 : tableBodyProps.sx, theme))), children: getBottomRows().map((row, staticRowIndex) => {
@@ -7333,11 +7462,13 @@ const MRT_TableFooterCell = (_a) => {
7333
7462
  var _b, _c, _d;
7334
7463
  var { footer, staticColumnIndex, table } = _a, rest = __rest(_a, ["footer", "staticColumnIndex", "table"]);
7335
7464
  const theme = useTheme();
7336
- const { getState, options: { enableColumnPinning, muiTableFooterCellProps, enableKeyboardShortcuts, }, } = table;
7337
- const { density } = getState();
7465
+ const { options: { enableColumnPinning, muiTableFooterCellProps, enableKeyboardShortcuts, }, } = table;
7466
+ useMRT_SliceValue(table._uiStore, (s) => s.density);
7338
7467
  const { column } = footer;
7339
7468
  const { columnDef } = column;
7340
7469
  const { columnDefType } = columnDef;
7470
+ const isDraggingColumn = useMRT_SliceValue(table._dragStore, (s) => { var _a; return ((_a = s.draggingColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id; });
7471
+ const isHoveredColumn = useMRT_SliceValue(table._hoverStore, (s) => { var _a; return ((_a = s.hoveredColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id; });
7341
7472
  const isColumnPinned = enableColumnPinning &&
7342
7473
  columnDef.columnDefType !== 'group' &&
7343
7474
  column.getIsPinned();
@@ -7356,13 +7487,11 @@ const MRT_TableFooterCell = (_a) => {
7356
7487
  ? 'center'
7357
7488
  : theme.direction === 'rtl'
7358
7489
  ? 'right'
7359
- : 'left', colSpan: footer.colSpan, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, tabIndex: enableKeyboardShortcuts ? 0 : undefined, variant: "footer" }, tableCellProps, { onKeyDown: handleKeyDown, sx: (theme) => (Object.assign(Object.assign({ fontWeight: 'bold', p: density === 'compact'
7360
- ? '0.5rem'
7361
- : density === 'comfortable'
7362
- ? '1rem'
7363
- : '1.5rem', verticalAlign: 'top' }, getCommonMRTCellStyles({
7490
+ : 'left', colSpan: footer.colSpan, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, tabIndex: enableKeyboardShortcuts ? 0 : undefined, variant: "footer" }, tableCellProps, { onKeyDown: handleKeyDown, sx: (theme) => (Object.assign(Object.assign({ fontWeight: 'bold', p: 'var(--mrt-cell-p)', verticalAlign: 'top' }, getCommonMRTCellStyles({
7364
7491
  column,
7365
7492
  header: footer,
7493
+ isDraggingColumn,
7494
+ isHoveredColumn,
7366
7495
  table,
7367
7496
  tableCellProps,
7368
7497
  theme,
@@ -7437,7 +7566,9 @@ const MRT_ColumnActionMenu = (_a) => {
7437
7566
  const { getAllLeafColumns, getState, options: { columnFilterDisplayMode, columnFilterModeOptions, enableColumnFilterModes, enableColumnFilters, enableColumnPinning, enableColumnResizing, enableGrouping, enableHiding, enableSorting, enableSortingRemoval, icons: { ClearAllIcon, DynamicFeedIcon, FilterListIcon, FilterListOffIcon, PushPinIcon, RestartAltIcon, SortIcon, ViewColumnIcon, VisibilityOffIcon, }, localization, mrtTheme: { menuBackgroundColor }, renderColumnActionsMenuItems, }, refs: { filterInputRefs }, setColumnFilterFns, setColumnOrder, setColumnSizingInfo, setShowColumnFilters, } = table;
7438
7567
  const { column } = header;
7439
7568
  const { columnDef } = column;
7440
- const { columnSizing, columnVisibility, density, showColumnFilters } = getState();
7569
+ const { columnSizing, columnVisibility } = getState();
7570
+ const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
7571
+ const showColumnFilters = useMRT_SliceValue(table._uiStore, (s) => s.showColumnFilters);
7441
7572
  const columnFilterValue = column.getFilterValue();
7442
7573
  const [filterMenuAnchorEl, setFilterMenuAnchorEl] = useState(null);
7443
7574
  const handleClearSort = () => {
@@ -7634,7 +7765,7 @@ const MRT_TableHeadCellGrabHandle = (_a) => {
7634
7765
  var { column, table, tableHeadCellRef } = _a, rest = __rest(_a, ["column", "table", "tableHeadCellRef"]);
7635
7766
  const { getState, options: { enableColumnOrdering, muiColumnDragHandleProps }, setColumnOrder, setColumnPinning, setDraggingColumn, setHoveredColumn, } = table;
7636
7767
  const { columnDef } = column;
7637
- const { columnOrder, draggingColumn, hoveredColumn } = getState();
7768
+ const { columnOrder } = getState();
7638
7769
  const iconButtonProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiColumnDragHandleProps, { column, table })), parseFromValuesOrFunc(columnDef.muiColumnDragHandleProps, {
7639
7770
  column,
7640
7771
  table,
@@ -7653,6 +7784,8 @@ const MRT_TableHeadCellGrabHandle = (_a) => {
7653
7784
  const handleDragEnd = (event) => {
7654
7785
  var _a;
7655
7786
  (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
7787
+ const { hoveredColumn } = table._hoverStore.get();
7788
+ const { draggingColumn } = table._dragStore.get();
7656
7789
  if ((hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
7657
7790
  column.toggleGrouping();
7658
7791
  }
@@ -7673,30 +7806,110 @@ const MRT_TableHeadCellGrabHandle = (_a) => {
7673
7806
  };
7674
7807
 
7675
7808
  const MRT_TableHeadCellResizeHandle = (_a) => {
7676
- var _b;
7677
7809
  var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
7678
- const { getState, options: { columnResizeDirection, columnResizeMode }, setColumnSizingInfo, } = table;
7679
- const { density } = getState();
7810
+ const { options: { columnResizeDirection }, refs: { isResizingRef, resizeIndicatorRef, tableContainerRef, tableHeadCellRefs, tableRef, }, setColumnSizing, setColumnSizingInfo, } = table;
7811
+ const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
7680
7812
  const { column } = header;
7681
- const handler = header.getResizeHandler();
7682
7813
  const mx = density === 'compact'
7683
7814
  ? '-8px'
7684
7815
  : density === 'comfortable'
7685
7816
  ? '-16px'
7686
7817
  : '-24px';
7687
7818
  const lr = column.columnDef.columnDefType === 'display' ? '4px' : '0';
7819
+ // Drives the resize purely through refs/DOM writes (CSS vars + the indicator line) so
7820
+ // dragging causes zero React renders; the only state write is the commit on release.
7821
+ const startResize = useCallback((startX) => {
7822
+ var _a, _b;
7823
+ const tableEl = tableRef.current;
7824
+ const containerEl = tableContainerRef.current;
7825
+ const indicatorEl = resizeIndicatorRef.current;
7826
+ const startSize = column.getSize();
7827
+ const dir = columnResizeDirection === 'rtl' ? -1 : 1;
7828
+ const minSize = (_a = column.columnDef.minSize) !== null && _a !== void 0 ? _a : 40;
7829
+ const maxSize = (_b = column.columnDef.maxSize) !== null && _b !== void 0 ? _b : 1000;
7830
+ let size = startSize;
7831
+ // Read the header cell's own rendered edge (rather than deriving a position from
7832
+ // clientX/scrollLeft) so the indicator always matches the real column border, even
7833
+ // if the browser clamps scrollLeft mid-drag because the table's scrollWidth shrank.
7834
+ const updateIndicator = () => {
7835
+ var _a;
7836
+ const cellEl = (_a = tableHeadCellRefs.current) === null || _a === void 0 ? void 0 : _a[column.id];
7837
+ if (!indicatorEl || !containerEl || !cellEl)
7838
+ return;
7839
+ const containerRect = containerEl.getBoundingClientRect();
7840
+ const cellRect = cellEl.getBoundingClientRect();
7841
+ const edge = columnResizeDirection === 'rtl' ? cellRect.left : cellRect.right;
7842
+ const x = edge - containerRect.left + containerEl.scrollLeft;
7843
+ indicatorEl.style.display = 'block';
7844
+ indicatorEl.style.transform = `translateX(${x}px)`;
7845
+ };
7846
+ isResizingRef.current = column.id;
7847
+ containerEl === null || containerEl === void 0 ? void 0 : containerEl.setAttribute('data-mrt-resizing', 'true');
7848
+ document.body.style.cursor = 'col-resize';
7849
+ document.body.style.userSelect = 'none';
7850
+ updateIndicator();
7851
+ const handleMove = (clientX) => {
7852
+ size = Math.min(Math.max(startSize + dir * (clientX - startX), minSize), maxSize);
7853
+ if (tableEl) {
7854
+ tableEl.style.setProperty(`--header-${parseCSSVarId(header.id)}-size`, `${size}`);
7855
+ tableEl.style.setProperty(`--col-${parseCSSVarId(column.id)}-size`, `${size}`);
7856
+ }
7857
+ updateIndicator();
7858
+ };
7859
+ const handleMouseMove = (e) => handleMove(e.clientX);
7860
+ const handleTouchMove = (e) => {
7861
+ var _a;
7862
+ const touchX = (_a = e.touches[0]) === null || _a === void 0 ? void 0 : _a.clientX;
7863
+ if (touchX == null)
7864
+ return;
7865
+ e.preventDefault();
7866
+ handleMove(touchX);
7867
+ };
7868
+ const handleEnd = () => {
7869
+ document.removeEventListener('mousemove', handleMouseMove);
7870
+ document.removeEventListener('mouseup', handleEnd);
7871
+ document.removeEventListener('touchmove', handleTouchMove);
7872
+ document.removeEventListener('touchend', handleEnd);
7873
+ isResizingRef.current = false;
7874
+ containerEl === null || containerEl === void 0 ? void 0 : containerEl.removeAttribute('data-mrt-resizing');
7875
+ document.body.style.cursor = '';
7876
+ document.body.style.userSelect = '';
7877
+ if (indicatorEl)
7878
+ indicatorEl.style.display = 'none';
7879
+ setColumnSizing((old) => (Object.assign(Object.assign({}, old), { [column.id]: size })));
7880
+ };
7881
+ document.addEventListener('mousemove', handleMouseMove);
7882
+ document.addEventListener('mouseup', handleEnd);
7883
+ document.addEventListener('touchmove', handleTouchMove, {
7884
+ passive: false,
7885
+ });
7886
+ document.addEventListener('touchend', handleEnd);
7887
+ }, [
7888
+ column,
7889
+ columnResizeDirection,
7890
+ header.id,
7891
+ isResizingRef,
7892
+ resizeIndicatorRef,
7893
+ setColumnSizing,
7894
+ tableContainerRef,
7895
+ tableHeadCellRefs,
7896
+ tableRef,
7897
+ ]);
7688
7898
  return (jsx(Box, { className: "Mui-TableHeadCell-ResizeHandle-Wrapper", onDoubleClick: () => {
7689
7899
  setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
7690
7900
  column.resetSize();
7691
- }, onMouseDown: handler, onTouchStart: handler, style: {
7692
- transform: column.getIsResizing() && columnResizeMode === 'onEnd'
7693
- ? `translateX(${(columnResizeDirection === 'rtl' ? -1 : 1) *
7694
- ((_b = getState().columnSizingInfo.deltaOffset) !== null && _b !== void 0 ? _b : 0)}px)`
7695
- : undefined,
7901
+ }, onMouseDown: (e) => {
7902
+ e.preventDefault();
7903
+ startResize(e.clientX);
7904
+ }, onTouchStart: (e) => {
7905
+ var _a;
7906
+ const touchX = (_a = e.touches[0]) === null || _a === void 0 ? void 0 : _a.clientX;
7907
+ if (touchX != null)
7908
+ startResize(touchX);
7696
7909
  }, sx: (theme) => ({
7697
7910
  '&:active > hr': {
7698
7911
  backgroundColor: theme.palette.info.main,
7699
- opacity: header.subHeaders.length || columnResizeMode === 'onEnd' ? 1 : 0,
7912
+ opacity: 1,
7700
7913
  },
7701
7914
  cursor: 'col-resize',
7702
7915
  left: columnResizeDirection === 'rtl' ? lr : undefined,
@@ -7748,12 +7961,17 @@ const MRT_TableHeadCell = (_a) => {
7748
7961
  var _b, _c, _d;
7749
7962
  var { columnVirtualizer, header, staticColumnIndex, table } = _a, rest = __rest(_a, ["columnVirtualizer", "header", "staticColumnIndex", "table"]);
7750
7963
  const theme = useTheme();
7751
- const { getState, options: { columnResizeDirection, columnResizeMode, enableKeyboardShortcuts, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { tableHeadCellRefs }, setHoveredColumn, } = table;
7964
+ const { getState, options: { columnResizeDirection, columnResizeMode, enableKeyboardShortcuts, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { isResizingRef, tableHeadCellRefs }, setHoveredColumn, } = table;
7752
7965
  const [isColumnCellHovered, setIsColumnCellHovered] = useState(false);
7753
- const { columnSizingInfo, density, draggingColumn, grouping, hoveredColumn, showColumnFilters, } = getState();
7966
+ const { grouping } = getState();
7967
+ useMRT_SliceValue(table._uiStore, (s) => s.density);
7968
+ const showColumnFilters = useMRT_SliceValue(table._uiStore, (s) => s.showColumnFilters);
7754
7969
  const { column } = header;
7755
7970
  const { columnDef } = column;
7756
7971
  const { columnDefType } = columnDef;
7972
+ const isResizingThisColumn = useMRT_SliceValue(table._uiStore, (s) => s.columnSizingInfo.isResizingColumn === column.id);
7973
+ const isDraggingColumn = useMRT_SliceValue(table._dragStore, (s) => { var _a; return ((_a = s.draggingColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id; });
7974
+ const isHoveredColumn = useMRT_SliceValue(table._hoverStore, (s) => { var _a; return ((_a = s.hoveredColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id; });
7757
7975
  const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadCellProps, { column, table })), parseFromValuesOrFunc(columnDef.muiTableHeadCellProps, {
7758
7976
  column,
7759
7977
  table,
@@ -7781,14 +7999,14 @@ const MRT_TableHeadCell = (_a) => {
7781
7999
  return pl;
7782
8000
  }, [showColumnActions, showDragHandle]);
7783
8001
  const draggingBorders = useMemo(() => {
7784
- const showResizeBorder = columnSizingInfo.isResizingColumn === column.id &&
8002
+ const showResizeBorder = isResizingThisColumn &&
7785
8003
  columnResizeMode === 'onChange' &&
7786
8004
  !header.subHeaders.length;
7787
8005
  const borderStyle = showResizeBorder
7788
8006
  ? `2px solid ${draggingBorderColor} !important`
7789
- : (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
8007
+ : isDraggingColumn
7790
8008
  ? `1px dashed ${theme.palette.grey[500]}`
7791
- : (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === column.id
8009
+ : isHoveredColumn
7792
8010
  ? `2px dashed ${draggingBorderColor}`
7793
8011
  : undefined;
7794
8012
  if (showResizeBorder) {
@@ -7803,12 +8021,16 @@ const MRT_TableHeadCell = (_a) => {
7803
8021
  borderTop: borderStyle,
7804
8022
  }
7805
8023
  : undefined;
7806
- }, [draggingColumn, hoveredColumn, columnSizingInfo.isResizingColumn]);
8024
+ }, [isDraggingColumn, isHoveredColumn, isResizingThisColumn]);
7807
8025
  const handleDragEnter = (_e) => {
7808
- if (enableGrouping && (hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
8026
+ var _a;
8027
+ if (enableGrouping &&
8028
+ ((_a = table._hoverStore.get().hoveredColumn) === null || _a === void 0 ? void 0 : _a.id) === 'drop-zone') {
7809
8029
  setHoveredColumn(null);
7810
8030
  }
7811
- if (enableColumnOrdering && draggingColumn && columnDefType !== 'group') {
8031
+ if (enableColumnOrdering &&
8032
+ table._dragStore.get().draggingColumn &&
8033
+ columnDefType !== 'group') {
7812
8034
  setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
7813
8035
  }
7814
8036
  };
@@ -7829,7 +8051,7 @@ const MRT_TableHeadCell = (_a) => {
7829
8051
  };
7830
8052
  // Toggle the column cell hover state, but only when not actively resizing a column
7831
8053
  const handleColumnCellHoverToggle = (isHovered) => {
7832
- if (!columnSizingInfo.isResizingColumn) {
8054
+ if (!isResizingRef.current) {
7833
8055
  setIsColumnCellHovered(isHovered);
7834
8056
  }
7835
8057
  };
@@ -7857,25 +8079,17 @@ const MRT_TableHeadCell = (_a) => {
7857
8079
  ? column.getIsSorted() === 'asc'
7858
8080
  ? 'ascending'
7859
8081
  : 'descending'
7860
- : 'none', colSpan: header.colSpan, "data-can-sort": column.getCanSort() || undefined, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, "data-testid": `header-cell-${column.id}`, "data-sort": column.getIsSorted() || undefined, onDragEnter: handleDragEnter, onDragOver: handleDragOver, onMouseEnter: () => handleColumnCellHoverToggle(true), onMouseLeave: () => handleColumnCellHoverToggle(false), ref: handleRef, tabIndex: enableKeyboardShortcuts ? 0 : undefined }, tableCellProps, { onKeyDown: handleKeyDown, sx: (theme) => (Object.assign(Object.assign({ flexDirection: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'column' : undefined, fontWeight: 'bold', overflow: 'hidden', color: theme.palette.text.primary, p: density === 'compact'
7861
- ? '0.5rem'
7862
- : density === 'comfortable'
7863
- ? columnDefType === 'display'
7864
- ? '0.75rem'
7865
- : '1rem'
7866
- : columnDefType === 'display'
7867
- ? '1rem 1.25rem'
7868
- : '1.5rem', pb: columnDefType === 'display'
8082
+ : 'none', colSpan: header.colSpan, "data-can-sort": column.getCanSort() || undefined, "data-index": staticColumnIndex, "data-pinned": !!isColumnPinned || undefined, "data-testid": `header-cell-${column.id}`, "data-sort": column.getIsSorted() || undefined, onDragEnter: handleDragEnter, onDragOver: handleDragOver, onMouseEnter: () => handleColumnCellHoverToggle(true), onMouseLeave: () => handleColumnCellHoverToggle(false), ref: handleRef, tabIndex: enableKeyboardShortcuts ? 0 : undefined }, tableCellProps, { onKeyDown: handleKeyDown, sx: (theme) => (Object.assign(Object.assign({ flexDirection: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'column' : undefined, fontWeight: 'bold', overflow: 'hidden', color: theme.palette.text.primary, p: columnDefType === 'display'
8083
+ ? 'var(--mrt-head-display-cell-p)'
8084
+ : 'var(--mrt-cell-p)', pb: columnDefType === 'display'
7869
8085
  ? 0
7870
- : showColumnFilters || density === 'compact'
8086
+ : showColumnFilters
7871
8087
  ? '0.4rem'
7872
- : '0.6rem', pt: columnDefType === 'group' || density === 'compact'
7873
- ? '0.25rem'
7874
- : density === 'comfortable'
7875
- ? '.75rem'
7876
- : '1.25rem', userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', borderBottom: 'none', paddingBottom: 'none' }, getCommonMRTCellStyles({
8088
+ : 'var(--mrt-head-cell-pb)', pt: columnDefType === 'group' ? '0.25rem' : 'var(--mrt-head-cell-pt)', userSelect: enableMultiSort && column.getCanSort() ? 'none' : undefined, verticalAlign: 'top', borderBottom: 'none', paddingBottom: 'none' }, getCommonMRTCellStyles({
7877
8089
  column,
7878
8090
  header,
8091
+ isDraggingColumn,
8092
+ isHoveredColumn,
7879
8093
  table,
7880
8094
  tableCellProps,
7881
8095
  theme,
@@ -7969,8 +8183,8 @@ const MRT_TableHead = (_a) => {
7969
8183
 
7970
8184
  const MRT_Table = (_a) => {
7971
8185
  var { table } = _a, rest = __rest(_a, ["table"]);
7972
- const { getFlatHeaders, getState, options: { columns, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, renderCaption, }, } = table;
7973
- const { columnSizing, columnSizingInfo, columnVisibility } = getState();
8186
+ const { getFlatHeaders, getState, options: { columns, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, renderCaption, }, refs: { tableRef }, } = table;
8187
+ const { columnSizing, columnVisibility, density } = getState();
7974
8188
  const tableProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableProps, { table })), rest);
7975
8189
  const Caption = parseFromValuesOrFunc(renderCaption, { table });
7976
8190
  const columnSizeVars = useMemo(() => {
@@ -7983,13 +8197,49 @@ const MRT_Table = (_a) => {
7983
8197
  colSizes[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
7984
8198
  }
7985
8199
  return colSizes;
7986
- }, [columns, columnSizing, columnSizingInfo, columnVisibility]);
8200
+ }, [columns, columnSizing, columnVisibility]);
8201
+ // Padding values keyed off density, read by cell/header/footer sx so density toggles
8202
+ // reuse existing emotion classes instead of generating new ones per cell.
8203
+ const densityVars = useMemo(() => ({
8204
+ '--mrt-cell-p': density === 'compact'
8205
+ ? '0.5rem'
8206
+ : density === 'comfortable'
8207
+ ? '1rem'
8208
+ : '1.5rem',
8209
+ '--mrt-display-cell-p': density === 'compact'
8210
+ ? '0 0.5rem'
8211
+ : density === 'comfortable'
8212
+ ? '0.5rem 0.75rem'
8213
+ : '1rem 1.25rem',
8214
+ '--mrt-head-display-cell-p': density === 'compact'
8215
+ ? '0.5rem'
8216
+ : density === 'comfortable'
8217
+ ? '0.75rem'
8218
+ : '1rem 1.25rem',
8219
+ '--mrt-head-cell-pb': density === 'compact' ? '0.4rem' : '0.6rem',
8220
+ '--mrt-head-cell-pt': density === 'compact'
8221
+ ? '0.25rem'
8222
+ : density === 'comfortable'
8223
+ ? '.75rem'
8224
+ : '1.25rem',
8225
+ }), [density]);
7987
8226
  const columnVirtualizer = useMRT_ColumnVirtualizer(table);
7988
8227
  const commonTableGroupProps = {
7989
8228
  columnVirtualizer,
7990
8229
  table,
7991
8230
  };
7992
- 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))] })));
8231
+ return (jsxs(Table, Object.assign({ stickyHeader: enableStickyHeader }, tableProps, { ref: (node) => {
8232
+ if (node) {
8233
+ tableRef.current = node;
8234
+ const userRef = tableProps === null || tableProps === void 0 ? void 0 : tableProps.ref;
8235
+ if (typeof userRef === 'function') {
8236
+ userRef(node);
8237
+ }
8238
+ else if (userRef) {
8239
+ userRef.current = node;
8240
+ }
8241
+ }
8242
+ }, style: Object.assign(Object.assign(Object.assign({}, columnSizeVars), densityVars), 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: 'visible', 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' ? (jsx(Memo_MRT_TableBody, Object.assign({}, commonTableGroupProps))) : (jsx(MRT_TableBody, Object.assign({}, commonTableGroupProps))), enableTableFooter && jsx(MRT_TableFooter, Object.assign({}, commonTableGroupProps))] })));
7993
8243
  };
7994
8244
 
7995
8245
  const MRT_TableLoadingOverlay = (_a) => {
@@ -8015,8 +8265,11 @@ const MRT_TableLoadingOverlay = (_a) => {
8015
8265
 
8016
8266
  const MRT_TableContainer = (_a) => {
8017
8267
  var { table } = _a, rest = __rest(_a, ["table"]);
8018
- const { getState, options: { createDisplayMode, editDisplayMode, enableCellActions, enableRowVirtualization, muiTableContainerProps, }, refs: { tableContainerRef }, } = table;
8019
- const { actionCell, creatingRow, editingRow, isLoading, showLoadingOverlay, newEntryModal, } = getState();
8268
+ const { getState, options: { createDisplayMode, editDisplayMode, enableCellActions, enableRowVirtualization, muiTableContainerProps, }, refs: { resizeIndicatorRef, tableContainerRef }, } = table;
8269
+ const { creatingRow, isLoading, showLoadingOverlay } = getState();
8270
+ const actionCell = useMRT_SliceValue(table._uiStore, (s) => s.actionCell);
8271
+ const editingRow = useMRT_SliceValue(table._uiStore, (s) => s.editingRow);
8272
+ const newEntryModal = useMRT_SliceValue(table._uiStore, (s) => s.newEntryModal);
8020
8273
  const loading = showLoadingOverlay !== false && (isLoading || showLoadingOverlay);
8021
8274
  const tableContainerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableContainerProps, {
8022
8275
  table,
@@ -8031,9 +8284,23 @@ const MRT_TableContainer = (_a) => {
8031
8284
  tableContainerProps.ref.current = node;
8032
8285
  }
8033
8286
  }
8034
- }, 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
8287
+ }, style: Object.assign({}, tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.style), sx: (theme) => (Object.assign(Object.assign(Object.assign({ flex: '1 1 auto', height: '100%', display: 'flex', flexDirection: 'column', maxWidth: '100%', overflow: 'auto', position: 'relative' }, (enableRowVirtualization
8035
8288
  ? { contain: 'paint', willChange: 'transform' }
8036
- : 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 })] })));
8289
+ : null)), { '&[data-mrt-resizing]': {
8290
+ userSelect: 'none',
8291
+ }, '&[data-mrt-resizing] .Mui-TableHeadCell-Content-Actions': {
8292
+ visibility: 'hidden',
8293
+ } }), parseFromValuesOrFunc(tableContainerProps === null || tableContainerProps === void 0 ? void 0 : tableContainerProps.sx, theme))), children: [loading ? jsx(MRT_TableLoadingOverlay, { table: table }) : null, jsx(Box, { ref: resizeIndicatorRef, sx: {
8294
+ bgcolor: 'primary.main',
8295
+ bottom: 0,
8296
+ display: 'none',
8297
+ left: 0,
8298
+ pointerEvents: 'none',
8299
+ position: 'absolute',
8300
+ top: 0,
8301
+ width: '2px',
8302
+ zIndex: 3,
8303
+ } }), 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 })] })));
8037
8304
  };
8038
8305
 
8039
8306
  const MRT_TablePaper = (_a) => {
@@ -8349,11 +8616,26 @@ const MaterialReactServerTable = (_a) => {
8349
8616
  return (jsx(MaterialReactServerTableInstance, Object.assign({ config: config, saveState: saveState }, instanceProps)));
8350
8617
  };
8351
8618
 
8619
+ const MRT_ColumnPinningButtons = (_a) => {
8620
+ var { column, table } = _a, rest = __rest(_a, ["column", "table"]);
8621
+ const { options: { icons: { PushPinIcon }, localization, }, } = table;
8622
+ const handlePinColumn = (pinDirection) => {
8623
+ column.pin(pinDirection);
8624
+ };
8625
+ return (jsx(Box, Object.assign({}, rest, { sx: (theme) => (Object.assign({ minWidth: '70px', textAlign: 'center' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: column.getIsPinned() ? (jsx(Tooltip, { title: localization.unpin, children: jsx(IconButton, { onClick: () => handlePinColumn(false), size: "small", children: jsx(PushPinIcon, {}) }) })) : (jsxs(Fragment, { children: [jsx(Tooltip, { title: localization.pinToLeft, children: jsx(IconButton, { onClick: () => handlePinColumn('left'), size: "small", children: jsx(PushPinIcon, { style: {
8626
+ transform: 'rotate(90deg)',
8627
+ } }) }) }), jsx(Tooltip, { title: localization.pinToRight, children: jsx(IconButton, { onClick: () => handlePinColumn('right'), size: "small", children: jsx(PushPinIcon, { style: {
8628
+ transform: 'rotate(-90deg)',
8629
+ } }) }) })] })) })));
8630
+ };
8631
+
8352
8632
  const MRT_ToolbarAlertBanner = (_a) => {
8353
8633
  var _b, _c, _d;
8354
8634
  var { stackAlertBanner, table } = _a, rest = __rest(_a, ["stackAlertBanner", "table"]);
8355
8635
  const { getFilteredSelectedRowModel, getCoreRowModel, getState, options: { enableRowSelection, enableSelectAll, localization, manualPagination, muiToolbarAlertBannerChipProps, muiToolbarAlertBannerProps, positionToolbarAlertBanner, renderToolbarAlertBannerContent, rowCount, }, refs: { tablePaperRef }, } = table;
8356
- const { density, grouping, rowSelection, showAlertBanner } = getState();
8636
+ const { grouping, rowSelection } = getState();
8637
+ const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
8638
+ const showAlertBanner = useMRT_SliceValue(table._uiStore, (s) => s.showAlertBanner);
8357
8639
  const alertProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiToolbarAlertBannerProps, {
8358
8640
  table,
8359
8641
  })), rest);