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