@dooherceg/material-react-table 3.2.6 → 3.2.8
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 +109 -7
- package/dist/index.esm.js +2120 -1685
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2119 -1681
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,24 +4,39 @@ var matchSorterUtils = require('@tanstack/match-sorter-utils');
|
|
|
4
4
|
var reactTable = require('@tanstack/react-table');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var CancelIcon = require('@mui/icons-material/Cancel');
|
|
8
|
+
var Button = require('@mui/material/Button');
|
|
9
|
+
var Dialog = require('@mui/material/Dialog');
|
|
10
|
+
var DialogActions = require('@mui/material/DialogActions');
|
|
11
|
+
var DialogContent = require('@mui/material/DialogContent');
|
|
12
|
+
var DialogTitle = require('@mui/material/DialogTitle');
|
|
7
13
|
var IconButton = require('@mui/material/IconButton');
|
|
8
|
-
var
|
|
14
|
+
var Stack = require('@mui/material/Stack');
|
|
15
|
+
var DeleteOutlineIcon = require('@mui/icons-material/DeleteOutline');
|
|
16
|
+
var EditNoteIcon = require('@mui/icons-material/EditNote');
|
|
17
|
+
var FileDownloadIcon = require('@mui/icons-material/FileDownload');
|
|
18
|
+
var PrintIcon = require('@mui/icons-material/Print');
|
|
19
|
+
var Checkbox = require('@mui/material/Checkbox');
|
|
20
|
+
var CircularProgress = require('@mui/material/CircularProgress');
|
|
21
|
+
var Divider = require('@mui/material/Divider');
|
|
22
|
+
var FormControl = require('@mui/material/FormControl');
|
|
23
|
+
var FormControlLabel = require('@mui/material/FormControlLabel');
|
|
9
24
|
var Menu = require('@mui/material/Menu');
|
|
10
|
-
var Box = require('@mui/material/Box');
|
|
11
|
-
var ListItemIcon = require('@mui/material/ListItemIcon');
|
|
12
25
|
var MenuItem = require('@mui/material/MenuItem');
|
|
13
|
-
var
|
|
14
|
-
var
|
|
26
|
+
var Radio = require('@mui/material/Radio');
|
|
27
|
+
var RadioGroup = require('@mui/material/RadioGroup');
|
|
15
28
|
var styles = require('@mui/material/styles');
|
|
16
|
-
var
|
|
29
|
+
var Tooltip = require('@mui/material/Tooltip');
|
|
30
|
+
var Typography = require('@mui/material/Typography');
|
|
31
|
+
var printJS = require('print-js');
|
|
32
|
+
var notistack = require('notistack');
|
|
33
|
+
var Box = require('@mui/material/Box');
|
|
34
|
+
var ListItemIcon = require('@mui/material/ListItemIcon');
|
|
17
35
|
var SubdirectoryArrowLeftIcon = require('@mui/icons-material/SubdirectoryArrowLeft');
|
|
18
36
|
var VerticalAlignTopIcon = require('@mui/icons-material/VerticalAlignTop');
|
|
19
|
-
var Checkbox = require('@mui/material/Checkbox');
|
|
20
|
-
var Radio = require('@mui/material/Radio');
|
|
21
37
|
var AddIcon = require('@mui/icons-material/Add');
|
|
22
38
|
var ArrowDownwardIcon = require('@mui/icons-material/ArrowDownward');
|
|
23
39
|
var ArrowRightIcon = require('@mui/icons-material/ArrowRight');
|
|
24
|
-
var CancelIcon = require('@mui/icons-material/Cancel');
|
|
25
40
|
var ChevronLeftIcon = require('@mui/icons-material/ChevronLeft');
|
|
26
41
|
var ChevronRightIcon = require('@mui/icons-material/ChevronRight');
|
|
27
42
|
var ClearAllIcon = require('@mui/icons-material/ClearAll');
|
|
@@ -53,15 +68,6 @@ var SortIcon = require('@mui/icons-material/Sort');
|
|
|
53
68
|
var SyncAltIcon = require('@mui/icons-material/SyncAlt');
|
|
54
69
|
var ViewColumnIcon = require('@mui/icons-material/ViewColumn');
|
|
55
70
|
var VisibilityOffIcon = require('@mui/icons-material/VisibilityOff');
|
|
56
|
-
var FileDownloadIcon = require('@mui/icons-material/FileDownload');
|
|
57
|
-
var PrintIcon = require('@mui/icons-material/Print');
|
|
58
|
-
var Divider = require('@mui/material/Divider');
|
|
59
|
-
var FormControl = require('@mui/material/FormControl');
|
|
60
|
-
var FormControlLabel = require('@mui/material/FormControlLabel');
|
|
61
|
-
var RadioGroup = require('@mui/material/RadioGroup');
|
|
62
|
-
var Typography = require('@mui/material/Typography');
|
|
63
|
-
var printJS = require('print-js');
|
|
64
|
-
var notistack = require('notistack');
|
|
65
71
|
var reactVirtual = require('@tanstack/react-virtual');
|
|
66
72
|
var Drawer = require('@mui/material/Drawer');
|
|
67
73
|
var TextField = require('@mui/material/TextField');
|
|
@@ -106,10 +112,6 @@ var DeleteForeverIcon = require('@mui/icons-material/DeleteForever');
|
|
|
106
112
|
var Switch = require('@mui/material/Switch');
|
|
107
113
|
var Badge = require('@mui/material/Badge');
|
|
108
114
|
var TableContainer = require('@mui/material/TableContainer');
|
|
109
|
-
var Dialog = require('@mui/material/Dialog');
|
|
110
|
-
var DialogActions = require('@mui/material/DialogActions');
|
|
111
|
-
var DialogContent = require('@mui/material/DialogContent');
|
|
112
|
-
var DialogTitle = require('@mui/material/DialogTitle');
|
|
113
115
|
var Modal = require('@mui/material/Modal');
|
|
114
116
|
var Accordion = require('@mui/material/Accordion');
|
|
115
117
|
var AccordionDetails = require('@mui/material/AccordionDetails');
|
|
@@ -723,99 +725,6 @@ const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parent
|
|
|
723
725
|
[getColumnId(col)]: '',
|
|
724
726
|
}))), rowIndex, depth, subRows, parentId);
|
|
725
727
|
|
|
726
|
-
const MRT_AggregationFns = Object.assign({}, reactTable.aggregationFns);
|
|
727
|
-
|
|
728
|
-
const fuzzy = (row, columnId, filterValue, addMeta) => {
|
|
729
|
-
const itemRank = matchSorterUtils.rankItem(row.getValue(columnId), filterValue, {
|
|
730
|
-
threshold: matchSorterUtils.rankings.MATCHES,
|
|
731
|
-
});
|
|
732
|
-
addMeta(itemRank);
|
|
733
|
-
return itemRank.passed;
|
|
734
|
-
};
|
|
735
|
-
fuzzy.autoRemove = (val) => !val;
|
|
736
|
-
const contains = (row, id, filterValue) => {
|
|
737
|
-
var _a;
|
|
738
|
-
return !!((_a = row
|
|
739
|
-
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().includes(filterValue.toString().toLowerCase().trim()));
|
|
740
|
-
};
|
|
741
|
-
contains.autoRemove = (val) => !val;
|
|
742
|
-
const startsWith = (row, id, filterValue) => {
|
|
743
|
-
var _a;
|
|
744
|
-
return !!((_a = row
|
|
745
|
-
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().startsWith(filterValue.toString().toLowerCase().trim()));
|
|
746
|
-
};
|
|
747
|
-
startsWith.autoRemove = (val) => !val;
|
|
748
|
-
const endsWith = (row, id, filterValue) => {
|
|
749
|
-
var _a;
|
|
750
|
-
return !!((_a = row
|
|
751
|
-
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().endsWith(filterValue.toString().toLowerCase().trim()));
|
|
752
|
-
};
|
|
753
|
-
endsWith.autoRemove = (val) => !val;
|
|
754
|
-
const equals = (row, id, filterValue) => {
|
|
755
|
-
var _a;
|
|
756
|
-
return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) ===
|
|
757
|
-
filterValue.toString().toLowerCase().trim();
|
|
758
|
-
};
|
|
759
|
-
equals.autoRemove = (val) => !val;
|
|
760
|
-
const notEquals = (row, id, filterValue) => {
|
|
761
|
-
var _a;
|
|
762
|
-
return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) !==
|
|
763
|
-
filterValue.toString().toLowerCase().trim();
|
|
764
|
-
};
|
|
765
|
-
notEquals.autoRemove = (val) => !val;
|
|
766
|
-
const greaterThan = (row, id, filterValue) => {
|
|
767
|
-
var _a, _b, _c;
|
|
768
|
-
return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
|
769
|
-
? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) > +filterValue
|
|
770
|
-
: ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) > filterValue.toString().toLowerCase().trim();
|
|
771
|
-
};
|
|
772
|
-
greaterThan.autoRemove = (val) => !val;
|
|
773
|
-
const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
|
|
774
|
-
greaterThanOrEqualTo.autoRemove = (val) => !val;
|
|
775
|
-
const lessThan = (row, id, filterValue) => {
|
|
776
|
-
var _a, _b, _c;
|
|
777
|
-
return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
|
778
|
-
? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) < +filterValue
|
|
779
|
-
: ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) < filterValue.toString().toLowerCase().trim();
|
|
780
|
-
};
|
|
781
|
-
lessThan.autoRemove = (val) => !val;
|
|
782
|
-
const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
|
|
783
|
-
lessThanOrEqualTo.autoRemove = (val) => !val;
|
|
784
|
-
const between = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
|
|
785
|
-
greaterThan(row, id, filterValues[0])) &&
|
|
786
|
-
((!isNaN(+filterValues[0]) &&
|
|
787
|
-
!isNaN(+filterValues[1]) &&
|
|
788
|
-
+filterValues[0] > +filterValues[1]) ||
|
|
789
|
-
['', undefined].includes(filterValues[1]) ||
|
|
790
|
-
lessThan(row, id, filterValues[1]));
|
|
791
|
-
between.autoRemove = (val) => !val;
|
|
792
|
-
const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
|
|
793
|
-
greaterThanOrEqualTo(row, id, filterValues[0])) &&
|
|
794
|
-
((!isNaN(+filterValues[0]) &&
|
|
795
|
-
!isNaN(+filterValues[1]) &&
|
|
796
|
-
+filterValues[0] > +filterValues[1]) ||
|
|
797
|
-
['', undefined].includes(filterValues[1]) ||
|
|
798
|
-
lessThanOrEqualTo(row, id, filterValues[1]));
|
|
799
|
-
betweenInclusive.autoRemove = (val) => !val;
|
|
800
|
-
const empty = (row, id, _filterValue) => { var _a; return !((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
|
|
801
|
-
empty.autoRemove = (val) => !val;
|
|
802
|
-
const notEmpty = (row, id, _filterValue) => { var _a; return !!((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
|
|
803
|
-
notEmpty.autoRemove = (val) => !val;
|
|
804
|
-
const MRT_FilterFns = Object.assign(Object.assign({}, reactTable.filterFns), { between,
|
|
805
|
-
betweenInclusive,
|
|
806
|
-
contains,
|
|
807
|
-
empty,
|
|
808
|
-
endsWith,
|
|
809
|
-
equals,
|
|
810
|
-
fuzzy,
|
|
811
|
-
greaterThan,
|
|
812
|
-
greaterThanOrEqualTo,
|
|
813
|
-
lessThan,
|
|
814
|
-
lessThanOrEqualTo,
|
|
815
|
-
notEmpty,
|
|
816
|
-
notEquals,
|
|
817
|
-
startsWith });
|
|
818
|
-
|
|
819
728
|
/******************************************************************************
|
|
820
729
|
Copyright (c) Microsoft Corporation.
|
|
821
730
|
|
|
@@ -860,1408 +769,1659 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
860
769
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
861
770
|
};
|
|
862
771
|
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
minWidth: '120px',
|
|
870
|
-
my: 0,
|
|
871
|
-
py: '6px',
|
|
872
|
-
}, tabIndex: 0 }, rest, { children: [jsxRuntime.jsxs(Box, { sx: {
|
|
873
|
-
alignItems: 'center',
|
|
874
|
-
display: 'flex',
|
|
875
|
-
}, children: [jsxRuntime.jsx(ListItemIcon, { children: icon }), label] }), onOpenSubMenu && (jsxRuntime.jsx(IconButton, { onClick: (e) => onOpenSubMenu(e), onMouseEnter: (e) => onOpenSubMenu(e), size: "small", sx: { p: 0 }, children: jsxRuntime.jsx(ArrowRightIcon, {}) }))] })));
|
|
876
|
-
};
|
|
877
|
-
|
|
878
|
-
const MRT_RowActionMenu = (_a) => {
|
|
879
|
-
var { anchorEl, handleEdit, row, setAnchorEl, staticRowIndex, table } = _a, rest = __rest(_a, ["anchorEl", "handleEdit", "row", "setAnchorEl", "staticRowIndex", "table"]);
|
|
880
|
-
const { getState, options: { editDisplayMode, enableEditing, icons: { EditIcon }, localization, mrtTheme: { menuBackgroundColor }, renderRowActionMenuItems, }, } = table;
|
|
881
|
-
const { density } = getState();
|
|
882
|
-
const menuItems = react.useMemo(() => {
|
|
883
|
-
const items = [];
|
|
884
|
-
const editItem = parseFromValuesOrFunc(enableEditing, row) &&
|
|
885
|
-
['modal', 'row'].includes(editDisplayMode) && (jsxRuntime.jsx(MRT_ActionMenuItem, { icon: jsxRuntime.jsx(EditIcon, {}), label: localization.edit, onClick: handleEdit, table: table }, 'edit'));
|
|
886
|
-
if (editItem)
|
|
887
|
-
items.push(editItem);
|
|
888
|
-
const rowActionMenuItems = renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
|
889
|
-
closeMenu: () => setAnchorEl(null),
|
|
890
|
-
row,
|
|
891
|
-
staticRowIndex,
|
|
892
|
-
table,
|
|
893
|
-
});
|
|
894
|
-
if (rowActionMenuItems === null || rowActionMenuItems === void 0 ? void 0 : rowActionMenuItems.length)
|
|
895
|
-
items.push(...rowActionMenuItems);
|
|
896
|
-
return items;
|
|
897
|
-
}, [renderRowActionMenuItems, row, staticRowIndex, table]);
|
|
898
|
-
if (!menuItems.length)
|
|
899
|
-
return null;
|
|
900
|
-
return (jsxRuntime.jsx(Menu, Object.assign({ MenuListProps: {
|
|
901
|
-
dense: density === 'compact',
|
|
902
|
-
sx: {
|
|
903
|
-
backgroundColor: menuBackgroundColor,
|
|
904
|
-
},
|
|
905
|
-
}, anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: menuItems })));
|
|
906
|
-
};
|
|
772
|
+
function MRT_DeleteRowButton({ onClick, }) {
|
|
773
|
+
const iconButtonStyle = {
|
|
774
|
+
p: 0,
|
|
775
|
+
};
|
|
776
|
+
return (jsxRuntime.jsx(IconButton, { disableRipple: true, color: "error", sx: iconButtonStyle, onClick: onClick, children: jsxRuntime.jsx(DeleteOutlineIcon, {}) }));
|
|
777
|
+
}
|
|
907
778
|
|
|
908
|
-
const
|
|
909
|
-
|
|
910
|
-
const
|
|
911
|
-
const
|
|
912
|
-
|
|
913
|
-
const
|
|
914
|
-
const
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
779
|
+
const DeleteRowAction = ({ onDeleteConfirm, table, deleteConfirmation, }) => {
|
|
780
|
+
// Toolbar context — no specific row is targeted
|
|
781
|
+
const [open, setOpen] = react.useState(false);
|
|
782
|
+
const [deleting, setDeleting] = react.useState(false);
|
|
783
|
+
// Resolve deleteConfirmation — plain object, defaults to empty object.
|
|
784
|
+
const resolvedDeleteConfirmation = deleteConfirmation !== null && deleteConfirmation !== void 0 ? deleteConfirmation : {};
|
|
785
|
+
const { title: titleOverride, message: messageOverride, confirmButtonText: confirmButtonTextOverride, cancelButtonText: cancelButtonTextOverride, dialogSx, contentContainerSx, headerSx, titleSx, bodySx, footerSx, closeButtonProps, cancelButtonProps, confirmButtonProps, } = resolvedDeleteConfirmation;
|
|
786
|
+
// Consumer override takes priority over localization fallback.
|
|
787
|
+
const deleteConfirmationTitle = titleOverride !== null && titleOverride !== void 0 ? titleOverride : table.options.localization.deleteConfirmationTitle;
|
|
788
|
+
const deleteConfirmationMessage = messageOverride !== null && messageOverride !== void 0 ? messageOverride : table.options.localization.deleteConfirmationMessage;
|
|
789
|
+
const confirmButtonLabel = confirmButtonTextOverride !== null && confirmButtonTextOverride !== void 0 ? confirmButtonTextOverride : table.options.localization.deleteConfirmYes;
|
|
790
|
+
const cancelButtonLabel = cancelButtonTextOverride !== null && cancelButtonTextOverride !== void 0 ? cancelButtonTextOverride : table.options.localization.deleteConfirmNo;
|
|
791
|
+
const deletingLabel = table.options.localization.deleteConfirmDeleting;
|
|
792
|
+
const handleDeleteRowButtonClick = () => {
|
|
793
|
+
setOpen(true);
|
|
794
|
+
};
|
|
795
|
+
const handleConfirmDelete = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
796
|
+
setDeleting(true);
|
|
797
|
+
yield onDeleteConfirm();
|
|
798
|
+
setDeleting(false);
|
|
799
|
+
setOpen(false);
|
|
800
|
+
});
|
|
801
|
+
const handleClose = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
802
|
+
setOpen(false);
|
|
803
|
+
});
|
|
804
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Dialog, { open: open, onClose: () => setOpen(false), keepMounted: true, "aria-describedby": "alert-dialog-slide-description", role: "alertdialog", sx: dialogSx, children: jsxRuntime.jsxs(Stack, { flexDirection: "column", height: "min-content", sx: contentContainerSx, children: [jsxRuntime.jsxs(Stack, { flexDirection: "row", alignItems: "center", justifyContent: "space-between", sx: Object.assign({ width: '100%' }, headerSx), children: [jsxRuntime.jsx(DialogTitle, { sx: Object.assign({ p: '0.7rem' }, titleSx), children: deleteConfirmationTitle }), jsxRuntime.jsx(DialogActions, { sx: {
|
|
805
|
+
p: '0.7rem',
|
|
806
|
+
}, children: jsxRuntime.jsx(IconButton, Object.assign({ color: "error", "aria-label": "close", onClick: handleClose }, closeButtonProps, { children: jsxRuntime.jsx(CancelIcon, {}) })) })] }), jsxRuntime.jsxs(Stack, { children: [jsxRuntime.jsx(DialogContent, { sx: Object.assign({ pr: '6rem' }, bodySx), children: deleteConfirmationMessage }), jsxRuntime.jsxs(DialogActions, { sx: footerSx, children: [jsxRuntime.jsx(Button, Object.assign({ onClick: () => setOpen(false), disabled: deleting, autoFocus: true, variant: "soft" }, cancelButtonProps, { children: cancelButtonLabel })), jsxRuntime.jsx(Button, Object.assign({ onClick: handleConfirmDelete, disabled: deleting, variant: "contained", color: "error" }, confirmButtonProps, { children: deleting ? deletingLabel : confirmButtonLabel }))] })] })] }) }), jsxRuntime.jsx(MRT_DeleteRowButton, { onClick: handleDeleteRowButtonClick })] }));
|
|
807
|
+
};
|
|
808
|
+
|
|
809
|
+
const createDeleteAction = (_a = {}) => {
|
|
810
|
+
var { onDelete, renderRow: customRenderRow, renderToolbar: customRenderToolbar, deleteConfirmation } = _a, rest = __rest(_a, ["onDelete", "renderRow", "renderToolbar", "deleteConfirmation"]);
|
|
811
|
+
// Default delete behavior used when the consumer does not provide a custom onDelete.
|
|
812
|
+
// Also exposed to custom onDelete through context.defaultOnDelete for composition.
|
|
813
|
+
const defaultOnDelete = (_a) => __awaiter(void 0, [_a], void 0, function* ({ rowsToDelete, table, }) {
|
|
814
|
+
var _b, _c;
|
|
815
|
+
// Nothing to delete, so exit early.
|
|
816
|
+
if (!rowsToDelete.length) {
|
|
817
|
+
return;
|
|
918
818
|
}
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
819
|
+
yield ((_c = (_b = table.options).deleteRowsFn) === null || _c === void 0 ? void 0 : _c.call(_b, { rowsToDelete, table }));
|
|
820
|
+
});
|
|
821
|
+
// Single execution pipeline for every delete flow (row or toolbar).
|
|
822
|
+
// If a custom handler exists, it receives defaultOnDelete and decides when to call it.
|
|
823
|
+
const executeDelete = (context) => {
|
|
824
|
+
const executeDefaultDelete = () => defaultOnDelete(context);
|
|
825
|
+
if (onDelete) {
|
|
826
|
+
return onDelete(Object.assign(Object.assign({}, context), { defaultOnDelete: executeDefaultDelete }));
|
|
922
827
|
}
|
|
923
|
-
|
|
828
|
+
return executeDefaultDelete();
|
|
924
829
|
};
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
830
|
+
// Resolves selected rows from table state for toolbar-triggered delete.
|
|
831
|
+
const handleMultipleRowDelete = ({ table, }) => {
|
|
832
|
+
const rowsToDelete = table.getSelectedRowModel().rows;
|
|
833
|
+
return executeDelete({ table, rowsToDelete });
|
|
834
|
+
};
|
|
835
|
+
// Resolves only the active row for row-triggered delete.
|
|
836
|
+
const handleSingleRowDelete = ({ table, row, }) => {
|
|
837
|
+
return executeDelete({ table, rowsToDelete: [row] });
|
|
838
|
+
};
|
|
839
|
+
// Wraps row context into a zero-argument callback expected by row action UI.
|
|
840
|
+
const createRowDeleteExecutor = (context) => {
|
|
841
|
+
return () => {
|
|
842
|
+
void handleSingleRowDelete(context);
|
|
843
|
+
};
|
|
844
|
+
};
|
|
845
|
+
// Wraps toolbar context into a zero-argument callback expected by toolbar action UI.
|
|
846
|
+
const createToolbarDeleteExecutor = (context) => {
|
|
847
|
+
return () => {
|
|
848
|
+
void handleMultipleRowDelete(context);
|
|
849
|
+
};
|
|
850
|
+
};
|
|
851
|
+
// Uses custom row renderer when provided; otherwise renders default delete action UI.
|
|
852
|
+
const renderRowAction = (context) => {
|
|
853
|
+
const onRowDelete = createRowDeleteExecutor(context);
|
|
854
|
+
if (customRenderRow) {
|
|
855
|
+
return customRenderRow(Object.assign(Object.assign({}, context), { onDelete: onRowDelete }));
|
|
950
856
|
}
|
|
857
|
+
return (jsxRuntime.jsx(DeleteRowAction, { onDeleteConfirm: onRowDelete, table: context.table, deleteConfirmation: deleteConfirmation }));
|
|
951
858
|
};
|
|
952
|
-
|
|
953
|
-
|
|
859
|
+
// Uses custom toolbar renderer when provided; otherwise renders default delete action UI.
|
|
860
|
+
const renderToolbarAction = (context) => {
|
|
861
|
+
const onToolbarDelete = createToolbarDeleteExecutor(context);
|
|
862
|
+
if (customRenderToolbar) {
|
|
863
|
+
return customRenderToolbar(Object.assign(Object.assign({}, context), { onDelete: onToolbarDelete }));
|
|
864
|
+
}
|
|
865
|
+
return (jsxRuntime.jsx(DeleteRowAction, { onDeleteConfirm: onToolbarDelete, table: context.table }));
|
|
866
|
+
};
|
|
867
|
+
return Object.assign({ name: 'delete', renderRow: renderRowAction, renderToolbar: renderToolbarAction }, rest);
|
|
954
868
|
};
|
|
955
869
|
|
|
956
|
-
const
|
|
957
|
-
|
|
958
|
-
const mrtThemeOverrides = parseFromValuesOrFunc(mrtTheme, muiTheme);
|
|
959
|
-
const baseBackgroundColor = muiTheme.palette.background.default;
|
|
960
|
-
return Object.assign({ baseBackgroundColor, cellNavigationOutlineColor: muiTheme.palette.primary.main, draggingBorderColor: muiTheme.palette.primary.main, matchHighlightColor: muiTheme.palette.mode === 'dark'
|
|
961
|
-
? styles.darken(muiTheme.palette.warning.dark, 0.25)
|
|
962
|
-
: styles.lighten(muiTheme.palette.warning.light, 0.5), menuBackgroundColor: styles.lighten(baseBackgroundColor, 0.07), pinnedRowBackgroundColor: styles.alpha(muiTheme.palette.primary.main, 0.1), selectedRowBackgroundColor: styles.alpha(muiTheme.palette.primary.main, 0.2) }, mrtThemeOverrides);
|
|
870
|
+
const MRT_EditRowButton = ({ onClick }) => {
|
|
871
|
+
return (jsxRuntime.jsx(IconButton, { sx: { p: 0 }, disableRipple: true, color: "primary", onClick: onClick, children: jsxRuntime.jsx(EditNoteIcon, {}) }));
|
|
963
872
|
};
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
left: 0,
|
|
968
|
-
position: 'absolute',
|
|
969
|
-
top: 0,
|
|
970
|
-
width: '100%',
|
|
971
|
-
zIndex: -1,
|
|
873
|
+
|
|
874
|
+
const EditRowAction = ({ onEditButtonClick, }) => {
|
|
875
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(MRT_EditRowButton, { onClick: onEditButtonClick }) }));
|
|
972
876
|
};
|
|
973
|
-
const getCommonPinnedCellStyles = ({ table, theme, }) => {
|
|
974
|
-
const { baseBackgroundColor } = table.options.mrtTheme;
|
|
975
|
-
return {
|
|
976
|
-
'&[data-pinned="true"]': {
|
|
977
|
-
'&:before': Object.assign({ backgroundColor: styles.alpha(styles.darken(baseBackgroundColor, theme.palette.mode === 'dark' ? 0.05 : 0.01), 0.97) }, commonCellBeforeAfterStyles),
|
|
978
|
-
},
|
|
979
|
-
};
|
|
980
|
-
};
|
|
981
|
-
const getCommonMRTCellStyles = ({ column, header, table, tableCellProps, theme, }) => {
|
|
982
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
983
|
-
const { getState, options: { enableColumnVirtualization, layoutMode }, } = table;
|
|
984
|
-
const { draggingColumn } = getState();
|
|
985
|
-
const { columnDef } = column;
|
|
986
|
-
const { columnDefType } = columnDef;
|
|
987
|
-
const isColumnPinned = columnDef.columnDefType !== 'group' && column.getIsPinned();
|
|
988
|
-
const widthStyles = {
|
|
989
|
-
minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId((_a = header === null || header === void 0 ? void 0 : header.id) !== null && _a !== void 0 ? _a : column.id)}-size) * 1px), ${(_b = columnDef.minSize) !== null && _b !== void 0 ? _b : 30}px)`,
|
|
990
|
-
width: `calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId((_c = header === null || header === void 0 ? void 0 : header.id) !== null && _c !== void 0 ? _c : column.id)}-size) * 1px)`,
|
|
991
|
-
};
|
|
992
|
-
if (layoutMode === 'grid') {
|
|
993
|
-
widthStyles.flex = `${[0, false].includes(columnDef.grow)
|
|
994
|
-
? 0
|
|
995
|
-
: `var(--${header ? 'header' : 'col'}-${parseCSSVarId((_d = header === null || header === void 0 ? void 0 : header.id) !== null && _d !== void 0 ? _d : column.id)}-size)`} 0 auto`;
|
|
996
|
-
}
|
|
997
|
-
else if (layoutMode === 'grid-no-grow') {
|
|
998
|
-
widthStyles.flex = `${+(columnDef.grow || 0)} 0 auto`;
|
|
999
|
-
}
|
|
1000
|
-
// The checkbox column is technically pinned (for sticky positioning) but
|
|
1001
|
-
// should look like a regular center column — no background overlay or shadow.
|
|
1002
|
-
const isCheckboxColumn = column.id === CHECKBOX_DISPLAY_COLUMN_ID;
|
|
1003
|
-
// Count all currently pinned column IDs across both sides.
|
|
1004
|
-
// Checkbox is always pinned (counts as 1), so > 1 means the user has
|
|
1005
|
-
// explicitly pinned at least one additional column.
|
|
1006
|
-
const totalPinnedColumnCount = [
|
|
1007
|
-
...((_e = table.getState().columnPinning.left) !== null && _e !== void 0 ? _e : []),
|
|
1008
|
-
...((_f = table.getState().columnPinning.right) !== null && _f !== void 0 ? _f : []),
|
|
1009
|
-
].length;
|
|
1010
|
-
const hasNoPinnedColumns = totalPinnedColumnCount === 0;
|
|
1011
|
-
const pinnedStyles = isColumnPinned
|
|
1012
|
-
? Object.assign(Object.assign({}, (isCheckboxColumn
|
|
1013
|
-
? hasNoPinnedColumns
|
|
1014
|
-
? {
|
|
1015
|
-
// Use doubled class selector (&&) to beat the row-level
|
|
1016
|
-
// td[data-pinned="true"]:before specificity from MRT_TableBodyRow.
|
|
1017
|
-
'&&[data-pinned="true"]': {
|
|
1018
|
-
'&:before': {
|
|
1019
|
-
backgroundColor: 'transparent',
|
|
1020
|
-
boxShadow: 'none',
|
|
1021
|
-
},
|
|
1022
|
-
},
|
|
1023
|
-
}
|
|
1024
|
-
: // Other columns are also pinned — apply standard pinned background
|
|
1025
|
-
// so the checkbox header matches the pinned row cells below it.
|
|
1026
|
-
getCommonPinnedCellStyles({ column, table, theme })
|
|
1027
|
-
: getCommonPinnedCellStyles({ column, table, theme }))), { left: isColumnPinned === 'left'
|
|
1028
|
-
? `${column.getStart('left')}px`
|
|
1029
|
-
: undefined,
|
|
1030
|
-
// Skip opacity reduction for checkbox — keep it fully opaque like center columns
|
|
1031
|
-
opacity: isCheckboxColumn ? undefined : 0.97, position: 'sticky', right: isColumnPinned === 'right'
|
|
1032
|
-
? `${column.getAfter('right')}px`
|
|
1033
|
-
: undefined }) : {};
|
|
1034
|
-
return Object.assign(Object.assign(Object.assign({ backgroundColor: 'inherit', backgroundImage: 'inherit', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, justifyContent: columnDefType === 'group'
|
|
1035
|
-
? 'center'
|
|
1036
|
-
: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid'))
|
|
1037
|
-
? tableCellProps.align
|
|
1038
|
-
: undefined, opacity: ((_g = table.getState().draggingColumn) === null || _g === void 0 ? void 0 : _g.id) === column.id ||
|
|
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
|
-
? 'none'
|
|
1043
|
-
: `padding 150ms ease-in-out`, zIndex: column.getIsResizing() || (draggingColumn === null || draggingColumn === void 0 ? void 0 : draggingColumn.id) === column.id
|
|
1044
|
-
? 2
|
|
1045
|
-
: columnDefType !== 'group' && isColumnPinned
|
|
1046
|
-
? 1
|
|
1047
|
-
: 0, '&:focus-visible': {
|
|
1048
|
-
outline: `2px solid ${table.options.mrtTheme.cellNavigationOutlineColor}`,
|
|
1049
|
-
outlineOffset: '-2px',
|
|
1050
|
-
} }, pinnedStyles), widthStyles), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme));
|
|
1051
|
-
};
|
|
1052
|
-
const getCommonToolbarStyles = ({ table, }) => ({
|
|
1053
|
-
alignItems: 'flex-start',
|
|
1054
|
-
backgroundColor: table.options.mrtTheme.baseBackgroundColor,
|
|
1055
|
-
display: 'grid',
|
|
1056
|
-
flexWrap: 'wrap-reverse',
|
|
1057
|
-
position: 'relative',
|
|
1058
|
-
transition: 'all 150ms ease-in-out',
|
|
1059
|
-
zIndex: 1,
|
|
1060
|
-
});
|
|
1061
|
-
const flipIconStyles = (theme) => theme.direction === 'rtl'
|
|
1062
|
-
? { style: { transform: 'scaleX(-1)' } }
|
|
1063
|
-
: undefined;
|
|
1064
|
-
const getCommonTooltipProps = (placement) => ({
|
|
1065
|
-
disableInteractive: true,
|
|
1066
|
-
enterDelay: 1000,
|
|
1067
|
-
enterNextDelay: 1000,
|
|
1068
|
-
placement,
|
|
1069
|
-
});
|
|
1070
877
|
|
|
1071
|
-
const
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
const
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
878
|
+
const createEditAction = ({ onEdit, renderRow: customRenderRow, } = {}) => {
|
|
879
|
+
const defaultOnEdit = (_a) => __awaiter(void 0, [_a], void 0, function* ({ rowToEdit, table, }) {
|
|
880
|
+
// Nothing to edit, so exit early.
|
|
881
|
+
if (!rowToEdit) {
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
884
|
+
const { setNewEntryModal } = table;
|
|
885
|
+
const handleOpenEditModal = () => {
|
|
886
|
+
setNewEntryModal({
|
|
887
|
+
open: true,
|
|
888
|
+
mode: 'edit',
|
|
889
|
+
});
|
|
890
|
+
};
|
|
891
|
+
if (table.options.editRowFn) {
|
|
892
|
+
yield table.options.editRowFn({ rowToEdit, table });
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
handleOpenEditModal();
|
|
896
|
+
});
|
|
897
|
+
const executeEdit = (context) => {
|
|
898
|
+
const executeDefaultEdit = () => defaultOnEdit(context);
|
|
899
|
+
if (onEdit) {
|
|
900
|
+
return onEdit(Object.assign(Object.assign({}, context), { defaultOnEdit: executeDefaultEdit }));
|
|
901
|
+
}
|
|
902
|
+
return executeDefaultEdit();
|
|
1095
903
|
};
|
|
1096
|
-
const
|
|
1097
|
-
|
|
1098
|
-
setEditingRow(Object.assign({}, row));
|
|
1099
|
-
setAnchorEl(null);
|
|
904
|
+
const handleEditRow = ({ table, row }) => {
|
|
905
|
+
return executeEdit({ table, rowToEdit: row });
|
|
1100
906
|
};
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
};
|
|
1110
|
-
|
|
1111
|
-
const getMRT_RowActionsColumnDef = (tableOptions) => {
|
|
1112
|
-
return Object.assign({ Cell: ({ cell, row, staticRowIndex, table }) => (jsxRuntime.jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, staticRowIndex: staticRowIndex, table: table })) }, defaultDisplayColumnProps({
|
|
1113
|
-
header: 'actions',
|
|
1114
|
-
id: 'mrt-row-actions',
|
|
1115
|
-
size: 70,
|
|
1116
|
-
tableOptions,
|
|
1117
|
-
}));
|
|
1118
|
-
};
|
|
1119
|
-
|
|
1120
|
-
const MRT_GrabHandleButton = (_a) => {
|
|
1121
|
-
var _b, _c;
|
|
1122
|
-
var { location, table } = _a, rest = __rest(_a, ["location", "table"]);
|
|
1123
|
-
const { options: { icons: { DragHandleIcon }, localization, }, } = table;
|
|
1124
|
-
return (jsxRuntime.jsx(Tooltip, Object.assign({}, getCommonTooltipProps('top'), { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.move, children: jsxRuntime.jsx(IconButton, Object.assign({ "aria-label": (_c = rest.title) !== null && _c !== void 0 ? _c : localization.move, disableRipple: true, draggable: "true", size: "small" }, rest, { onClick: (e) => {
|
|
1125
|
-
var _a;
|
|
1126
|
-
e.stopPropagation();
|
|
1127
|
-
(_a = rest === null || rest === void 0 ? void 0 : rest.onClick) === null || _a === void 0 ? void 0 : _a.call(rest, e);
|
|
1128
|
-
}, sx: (theme) => (Object.assign({ '&:active': {
|
|
1129
|
-
cursor: 'grabbing',
|
|
1130
|
-
}, '&:hover': {
|
|
1131
|
-
backgroundColor: 'transparent',
|
|
1132
|
-
opacity: 1,
|
|
1133
|
-
}, cursor: 'grab', m: '0 -0.1rem', opacity: location === 'row' ? 1 : 0.5, p: '2px', transition: 'all 150ms ease-in-out' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), title: undefined, children: jsxRuntime.jsx(DragHandleIcon, {}) })) })));
|
|
1134
|
-
};
|
|
1135
|
-
|
|
1136
|
-
const MRT_TableBodyRowGrabHandle = (_a) => {
|
|
1137
|
-
var { row, rowRef, table } = _a, rest = __rest(_a, ["row", "rowRef", "table"]);
|
|
1138
|
-
const { options: { muiRowDragHandleProps }, } = table;
|
|
1139
|
-
const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiRowDragHandleProps, {
|
|
1140
|
-
row,
|
|
1141
|
-
table,
|
|
1142
|
-
})), rest);
|
|
1143
|
-
const handleDragStart = (event) => {
|
|
1144
|
-
var _a;
|
|
1145
|
-
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
1146
|
-
try {
|
|
1147
|
-
event.dataTransfer.setDragImage(rowRef.current, 0, 0);
|
|
1148
|
-
}
|
|
1149
|
-
catch (e) {
|
|
1150
|
-
console.error(e);
|
|
907
|
+
const createEditRowExecutor = (context) => {
|
|
908
|
+
return () => {
|
|
909
|
+
void handleEditRow(context);
|
|
910
|
+
};
|
|
911
|
+
};
|
|
912
|
+
const renderRowAction = (context) => {
|
|
913
|
+
const onRowEdit = createEditRowExecutor(context);
|
|
914
|
+
if (customRenderRow) {
|
|
915
|
+
return customRenderRow(Object.assign(Object.assign({}, context), { onEdit: onRowEdit }));
|
|
1151
916
|
}
|
|
1152
|
-
|
|
917
|
+
return jsxRuntime.jsx(EditRowAction, { onEditButtonClick: onRowEdit });
|
|
1153
918
|
};
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
table.setDraggingRow(null);
|
|
1158
|
-
table.setHoveredRow(null);
|
|
919
|
+
return {
|
|
920
|
+
name: 'edit',
|
|
921
|
+
renderRow: renderRowAction,
|
|
1159
922
|
};
|
|
1160
|
-
return (jsxRuntime.jsx(MRT_GrabHandleButton, Object.assign({}, iconButtonProps, { location: "row", onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })));
|
|
1161
923
|
};
|
|
1162
924
|
|
|
1163
|
-
const
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
925
|
+
const downloadExportFiles = (files) => {
|
|
926
|
+
files.forEach((file) => {
|
|
927
|
+
const binaryString = atob(file.content);
|
|
928
|
+
const len = binaryString.length;
|
|
929
|
+
const bytes = new Uint8Array(len);
|
|
930
|
+
for (let i = 0; i < len; i++) {
|
|
931
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
932
|
+
}
|
|
933
|
+
const blob = new Blob([bytes], { type: 'application/octet-stream' });
|
|
934
|
+
const element = document.createElement('a');
|
|
935
|
+
element.href = URL.createObjectURL(blob);
|
|
936
|
+
element.download = file.filename;
|
|
937
|
+
document.body.appendChild(element);
|
|
938
|
+
element.click();
|
|
939
|
+
document.body.removeChild(element);
|
|
940
|
+
URL.revokeObjectURL(element.href);
|
|
941
|
+
});
|
|
1170
942
|
};
|
|
1171
943
|
|
|
1172
|
-
const
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
944
|
+
const printExportFiles = (files) => {
|
|
945
|
+
files.forEach((file) => {
|
|
946
|
+
const binaryString = atob(file.content);
|
|
947
|
+
const len = binaryString.length;
|
|
948
|
+
const bytes = new Uint8Array(len);
|
|
949
|
+
for (let i = 0; i < len; i++) {
|
|
950
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
951
|
+
}
|
|
952
|
+
const blob = new Blob([bytes], { type: 'application/pdf' });
|
|
953
|
+
const url = URL.createObjectURL(blob);
|
|
954
|
+
printJS({
|
|
955
|
+
printable: url,
|
|
956
|
+
type: 'pdf',
|
|
957
|
+
onLoadingEnd: () => URL.revokeObjectURL(url),
|
|
958
|
+
});
|
|
959
|
+
});
|
|
1185
960
|
};
|
|
1186
961
|
|
|
1187
|
-
const
|
|
1188
|
-
var _a, _b;
|
|
962
|
+
const MRT_ExportsToolbar = ({ table, availableExports, exportState, onExportStateChange, loadExport, }) => {
|
|
1189
963
|
const theme = styles.useTheme();
|
|
1190
|
-
const {
|
|
1191
|
-
const {
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
const
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
964
|
+
const { localization } = table.options;
|
|
965
|
+
const { selectedExports, selectedFormat, grouped } = exportState;
|
|
966
|
+
const [anchorEl, setAnchorEl] = react.useState(null);
|
|
967
|
+
const [loadingExportType, setLoadingExportType] = react.useState(null);
|
|
968
|
+
const { rowSelection } = table.getState();
|
|
969
|
+
const selectedRowIds = Object.keys(rowSelection).filter((id) => rowSelection[id]);
|
|
970
|
+
const isNoRowsSelected = selectedRowIds.length === 0;
|
|
971
|
+
const availableFormats = react.useMemo(() => {
|
|
972
|
+
const allFormats = Object.values(availableExports).flatMap((exp) => exp.formats);
|
|
973
|
+
return Array.from(new Set(allFormats));
|
|
974
|
+
}, [availableExports]);
|
|
975
|
+
const hasPdfFormat = availableFormats.includes('pdf');
|
|
976
|
+
const exportTypesForSelectedFormat = react.useMemo(() => {
|
|
977
|
+
if (!selectedFormat)
|
|
978
|
+
return [];
|
|
979
|
+
return Object.values(availableExports).filter((exp) => exp.formats.includes(selectedFormat));
|
|
980
|
+
}, [availableExports, selectedFormat]);
|
|
981
|
+
const isPrintDisabled = selectedFormat !== 'pdf' ||
|
|
982
|
+
!selectedFormat ||
|
|
983
|
+
selectedExports.length < 1 ||
|
|
984
|
+
(!grouped && selectedExports.length > 1);
|
|
985
|
+
const isDownloadDisabled = !selectedFormat || selectedExports.length < 1;
|
|
986
|
+
const handleOpenMenu = (event) => {
|
|
987
|
+
setAnchorEl(event.currentTarget);
|
|
988
|
+
};
|
|
989
|
+
const handleCloseMenu = () => {
|
|
990
|
+
setAnchorEl(null);
|
|
991
|
+
};
|
|
992
|
+
const handleSelectFormat = (format) => {
|
|
993
|
+
const newFormat = selectedFormat === format ? null : format;
|
|
994
|
+
onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { grouped: false })), { selectedExports: [], selectedFormat: newFormat })));
|
|
995
|
+
};
|
|
996
|
+
const handleToggleExportType = (exportName) => {
|
|
997
|
+
const isAlreadySelected = selectedExports.includes(exportName);
|
|
998
|
+
const newSelectedExports = isAlreadySelected
|
|
999
|
+
? selectedExports.filter((name) => name !== exportName)
|
|
1000
|
+
: [...selectedExports, exportName];
|
|
1001
|
+
onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { selectedFormat: null, grouped: false })), { selectedExports: newSelectedExports })));
|
|
1002
|
+
};
|
|
1003
|
+
const handleToggleGrouped = () => {
|
|
1004
|
+
onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { selectedFormat: null, selectedExports: [] })), { grouped: !grouped })));
|
|
1005
|
+
};
|
|
1006
|
+
const handleExportAction = (type) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1007
|
+
setLoadingExportType(type);
|
|
1008
|
+
try {
|
|
1009
|
+
const response = yield loadExport({
|
|
1010
|
+
format: selectedFormat,
|
|
1011
|
+
exports: selectedExports,
|
|
1012
|
+
separated_files: !grouped,
|
|
1013
|
+
download: false,
|
|
1014
|
+
ids: JSON.stringify(selectedRowIds),
|
|
1015
|
+
type,
|
|
1016
|
+
});
|
|
1017
|
+
handleCloseMenu();
|
|
1018
|
+
if (type === 'download') {
|
|
1019
|
+
downloadExportFiles(response);
|
|
1020
|
+
}
|
|
1021
|
+
else {
|
|
1022
|
+
printExportFiles(response);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
finally {
|
|
1026
|
+
setLoadingExportType(null);
|
|
1027
|
+
}
|
|
1028
|
+
});
|
|
1029
|
+
const renderFormatSelector = () => (jsxRuntime.jsx(Stack, { justifyContent: "flex-start", minWidth: "200px", sx: {
|
|
1030
|
+
borderRight: selectedFormat
|
|
1031
|
+
? `1px dashed ${theme.palette.divider}`
|
|
1032
|
+
: 'none',
|
|
1033
|
+
}, children: jsxRuntime.jsx(FormControl, { children: jsxRuntime.jsx(RadioGroup, { value: selectedFormat !== null && selectedFormat !== void 0 ? selectedFormat : '', children: availableFormats.map((format) => (jsxRuntime.jsx(FormControlLabel, { sx: { m: 0 }, value: format, control: jsxRuntime.jsx(Radio, { size: "small", onClick: () => handleSelectFormat(format) }), label: jsxRuntime.jsx(Typography, { variant: "subtitle2", sx: { fontWeight: 800 }, children: format }) }, format))) }) }) }));
|
|
1034
|
+
const renderExportTypeSelector = () => {
|
|
1035
|
+
if (!selectedFormat || exportTypesForSelectedFormat.length === 0)
|
|
1036
|
+
return null;
|
|
1037
|
+
return (jsxRuntime.jsx(Stack, { minWidth: "250px", maxHeight: "500px", sx: { overflowY: 'auto' }, children: exportTypesForSelectedFormat.map((exportType) => (jsxRuntime.jsxs(MenuItem, { onClick: () => handleToggleExportType(exportType.name), value: exportType.name, children: [jsxRuntime.jsx(Checkbox, { checked: selectedExports.includes(exportType.name), size: "small" }), jsxRuntime.jsx(Typography, { variant: "body2", children: exportType.label })] }, exportType.name))) }));
|
|
1038
|
+
};
|
|
1039
|
+
const renderActionButtons = () => {
|
|
1040
|
+
const isAnyLoading = loadingExportType !== null;
|
|
1041
|
+
return (jsxRuntime.jsxs(Stack, { direction: "row", gap: 0.5, mt: 1, mr: 2, children: [hasPdfFormat && (jsxRuntime.jsx(Button, { sx: { display: 'flex', gap: 0.5 }, disabled: isPrintDisabled || isAnyLoading, onClick: () => handleExportAction('print'), startIcon: loadingExportType === 'print' ? (jsxRuntime.jsx(CircularProgress, { size: 16, color: "inherit" })) : (jsxRuntime.jsx(PrintIcon, { fontSize: "small" })), children: localization.exportPrintPdf })), jsxRuntime.jsx(Button, { sx: { display: 'flex', gap: 0.5 }, disabled: isDownloadDisabled || isAnyLoading, onClick: () => handleExportAction('download'), startIcon: loadingExportType === 'download' ? (jsxRuntime.jsx(CircularProgress, { size: 16, color: "inherit" })) : (jsxRuntime.jsx(FileDownloadIcon, { fontSize: "small" })), children: localization.exportDownload })] }));
|
|
1042
|
+
};
|
|
1043
|
+
const renderGroupedCheckbox = () => (jsxRuntime.jsx(Stack, { mt: "auto", children: jsxRuntime.jsx(FormControlLabel, { onChange: handleToggleGrouped, sx: { m: 0 }, control: jsxRuntime.jsx(Checkbox, { checked: grouped, size: "small" }), label: jsxRuntime.jsx(Typography, { variant: "body2", children: localization.exportGrouped }) }) }));
|
|
1044
|
+
return (jsxRuntime.jsxs(Stack, { direction: "row", gap: 0.5, alignItems: "center", children: [jsxRuntime.jsx(Tooltip, { title: isNoRowsSelected
|
|
1045
|
+
? localization.exportSelectRowsTooltip
|
|
1046
|
+
: localization.exportButton, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(Button, { "aria-label": localization.exportButton, disabled: isNoRowsSelected, onClick: handleOpenMenu, size: "small", startIcon: jsxRuntime.jsx(FileDownloadIcon, { fontSize: "small" }), variant: "text", children: localization.exportButton }) }) }), jsxRuntime.jsxs(Menu, { anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleCloseMenu, anchorOrigin: { vertical: 'bottom', horizontal: 'left' }, transformOrigin: { vertical: 'top', horizontal: 'left' }, children: [jsxRuntime.jsxs(Stack, { direction: "row", sx: { px: 1, pt: 1, maxHeight: '320px', overflow: 'auto' }, children: [renderFormatSelector(), selectedFormat &&
|
|
1047
|
+
exportTypesForSelectedFormat.length > 0 &&
|
|
1048
|
+
renderExportTypeSelector()] }), jsxRuntime.jsx(Divider, { sx: { mt: 1 } }), jsxRuntime.jsxs(Stack, { direction: "row", alignItems: "center", sx: { px: 1, pb: 1 }, children: [renderActionButtons(), renderGroupedCheckbox()] })] })] }));
|
|
1219
1049
|
};
|
|
1220
1050
|
|
|
1221
|
-
const
|
|
1222
|
-
|
|
1223
|
-
const MRT_InsertHereAction = ({ onClick, }) => {
|
|
1224
|
-
return (jsxRuntime.jsx(Tooltip, { title: INSERT_HERE_TOOLTIP, disableInteractive: true, children: jsxRuntime.jsx(IconButton, { onClick: onClick, size: ACTION_ICON_SIZE$1, children: jsxRuntime.jsx(SubdirectoryArrowLeftIcon, { color: "warning" }) }) }));
|
|
1051
|
+
const MRT_ExportRowButton = ({ onClick }) => {
|
|
1052
|
+
return (jsxRuntime.jsx(IconButton, { sx: { p: 0 }, disableRipple: true, onClick: onClick, children: jsxRuntime.jsx(FileDownloadIcon, { fontSize: "small" }) }));
|
|
1225
1053
|
};
|
|
1226
1054
|
|
|
1227
|
-
const
|
|
1228
|
-
|
|
1229
|
-
const ACTION_BUTTON_HEIGHT = '1.75rem';
|
|
1230
|
-
const MRT_MoveToTopAction = ({ onClick }) => {
|
|
1231
|
-
return (jsxRuntime.jsx(Tooltip, { title: MOVE_TO_TOP_TOOLTIP, disableInteractive: true, children: jsxRuntime.jsx(IconButton, { onClick: onClick, size: ACTION_ICON_SIZE, sx: { height: ACTION_BUTTON_HEIGHT }, children: jsxRuntime.jsx(VerticalAlignTopIcon, { fontSize: "small" }) }) }));
|
|
1055
|
+
const MRT_PrintRowButton = ({ onClick }) => {
|
|
1056
|
+
return (jsxRuntime.jsx(IconButton, { sx: { p: 0 }, disableRipple: true, onClick: onClick, children: jsxRuntime.jsx(PrintIcon, { fontSize: "small" }) }));
|
|
1232
1057
|
};
|
|
1233
1058
|
|
|
1234
|
-
const
|
|
1235
|
-
return (jsxRuntime.
|
|
1236
|
-
color: (theme) => theme.palette.warning.main,
|
|
1237
|
-
'&.Mui-checked': {
|
|
1238
|
-
color: (theme) => theme.palette.warning.main,
|
|
1239
|
-
},
|
|
1240
|
-
} }));
|
|
1059
|
+
const ExportRowAction = ({ onExport, onPrint }) => {
|
|
1060
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MRT_ExportRowButton, { onClick: onExport }), onPrint && jsxRuntime.jsx(MRT_PrintRowButton, { onClick: onPrint })] }));
|
|
1241
1061
|
};
|
|
1242
1062
|
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
* Example: Row at depth 1 with a child at depth 3 → returns 3
|
|
1247
|
-
*/
|
|
1248
|
-
const getDeepestSubRowDepth = (row) => {
|
|
1249
|
-
var _a;
|
|
1250
|
-
if (!((_a = row.subRows) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
1251
|
-
return row.depth;
|
|
1252
|
-
}
|
|
1253
|
-
return row.subRows.reduce((maxDepth, subRow) => Math.max(maxDepth, getDeepestSubRowDepth(subRow)), row.depth);
|
|
1254
|
-
};
|
|
1255
|
-
/**
|
|
1256
|
-
* Extracts an array of IDs of only the selected rows from the selection object.
|
|
1257
|
-
* Filters the record where the value is true and maps only the keys (IDs).
|
|
1258
|
-
* Example: { row1: true, row2: false, row3: true } → ['row1', 'row3']
|
|
1259
|
-
*/
|
|
1260
|
-
const getSelectedReorderRowIds = (rowReorderingSelection) => {
|
|
1261
|
-
return Object.entries(rowReorderingSelection !== null && rowReorderingSelection !== void 0 ? rowReorderingSelection : {})
|
|
1262
|
-
.filter(([, isSelected]) => isSelected)
|
|
1263
|
-
.map(([rowId]) => rowId);
|
|
1264
|
-
};
|
|
1265
|
-
/**
|
|
1266
|
-
* Checks WHETHER we can move selected rows as children of target row
|
|
1267
|
-
* without exceeding the maximum allowed depth.
|
|
1268
|
-
* Directly calculates the final maximum depth after the move.
|
|
1269
|
-
* Example: selectedRows at depth 1-2 with descendants to depth 4, target depth 1, maxDepth 5
|
|
1270
|
-
* → new max depth = 1 + 1 + (4 - 1) = 5, which equals maxDepth, so returns false
|
|
1271
|
-
*/
|
|
1272
|
-
const canInsertSelectedRowsWithoutExceedingMaxDepth = ({ maxDepth, selectedRows, targetRowDepth, }) => {
|
|
1273
|
-
// Cannot insert if there are no selected rows to move
|
|
1274
|
-
if (selectedRows.length === 0) {
|
|
1275
|
-
return false;
|
|
1276
|
-
}
|
|
1277
|
-
// No depth restriction - can insert anywhere
|
|
1278
|
-
if (maxDepth === undefined) {
|
|
1279
|
-
return true;
|
|
1280
|
-
}
|
|
1281
|
-
// Find the deepest descendant among all selected rows
|
|
1282
|
-
const maxDeepestDescendantDepth = selectedRows.reduce((max, row) => {
|
|
1283
|
-
return Math.max(max, getDeepestSubRowDepth(row));
|
|
1284
|
-
}, 0);
|
|
1285
|
-
// Find the minimum depth of selected rows (to calculate relative depth)
|
|
1286
|
-
const minSelectedRowDepth = Math.min(...selectedRows.map((r) => r.depth));
|
|
1287
|
-
// Calculate the maximum depth after moving rows as children of target
|
|
1288
|
-
// newMaxDepth = target.depth + 1 (as children) + relative depth of selected rows
|
|
1289
|
-
const newMaxDepth = targetRowDepth + 1 + (maxDeepestDescendantDepth - minSelectedRowDepth);
|
|
1290
|
-
return newMaxDepth < maxDepth;
|
|
1291
|
-
};
|
|
1292
|
-
/**
|
|
1293
|
-
* Finds the depth of the FIRST selected row in the selection object.
|
|
1294
|
-
* Used to enforce constraint: can only select rows at the SAME depth.
|
|
1295
|
-
* Example: If I select a row at depth 2, I cannot select a row at depth 3
|
|
1296
|
-
*/
|
|
1297
|
-
const getFirstSelectedReorderRowDepth = ({ rowReorderingSelection, table, }) => {
|
|
1298
|
-
var _a, _b;
|
|
1299
|
-
const firstSelectedRowId = (_a = Object.entries(rowReorderingSelection !== null && rowReorderingSelection !== void 0 ? rowReorderingSelection : {}).find(([, isSelected]) => isSelected)) === null || _a === void 0 ? void 0 : _a[0];
|
|
1300
|
-
if (!firstSelectedRowId) {
|
|
1301
|
-
return undefined;
|
|
1302
|
-
}
|
|
1303
|
-
return (_b = table.getRow(firstSelectedRowId, true)) === null || _b === void 0 ? void 0 : _b.depth;
|
|
1304
|
-
};
|
|
1305
|
-
/**
|
|
1306
|
-
* Checks WHETHER we can select a specific row.
|
|
1307
|
-
* Rule: If a selection already exists, new row MUST be at the SAME depth as the first selected.
|
|
1308
|
-
* Without this, you could move rows from different levels which would break the hierarchy.
|
|
1309
|
-
*/
|
|
1310
|
-
const canSelectRowForReorder = ({ rowId, rowDepth, rowReorderingSelection, firstSelectedReorderRowDepth, }) => {
|
|
1311
|
-
const isCurrentRowSelected = !!(rowReorderingSelection === null || rowReorderingSelection === void 0 ? void 0 : rowReorderingSelection[rowId]);
|
|
1312
|
-
if (isCurrentRowSelected) {
|
|
1313
|
-
return true;
|
|
1314
|
-
}
|
|
1315
|
-
const hasAnySelection = Object.values(rowReorderingSelection !== null && rowReorderingSelection !== void 0 ? rowReorderingSelection : {}).some(Boolean);
|
|
1316
|
-
if (!hasAnySelection) {
|
|
1317
|
-
return true;
|
|
1318
|
-
}
|
|
1319
|
-
return rowDepth === firstSelectedReorderRowDepth;
|
|
1320
|
-
};
|
|
1321
|
-
/**
|
|
1322
|
-
* Creates an array of MRT_Row objects from an array of IDs.
|
|
1323
|
-
* Finds each row from the table and collects it in the result.
|
|
1324
|
-
* Used to prepare data for the onTreeRowReorder callback.
|
|
1325
|
-
*/
|
|
1326
|
-
const buildSelectedRowsArray = (selectedRowIds, table) => {
|
|
1327
|
-
return selectedRowIds.reduce((selectedRows, selectedRowId) => {
|
|
1328
|
-
const selectedRow = table.getRow(selectedRowId, true);
|
|
1329
|
-
if (selectedRow) {
|
|
1330
|
-
selectedRows.push(selectedRow);
|
|
1331
|
-
}
|
|
1332
|
-
return selectedRows;
|
|
1333
|
-
}, []);
|
|
1063
|
+
const hasActiveExports = (table) => {
|
|
1064
|
+
const { activeExports } = table.getState();
|
|
1065
|
+
return !!((activeExports === null || activeExports === void 0 ? void 0 : activeExports.selectedFormat) && activeExports.selectedExports.length > 0);
|
|
1334
1066
|
};
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
* Used to prevent circular references (parent cannot become child of its own child).
|
|
1339
|
-
*/
|
|
1340
|
-
const isRowInSubtreeOf = (targetRowId, parentRow) => {
|
|
1067
|
+
// Same conditions as MRT_ExportsToolbar: pdf format selected, at least one export type,
|
|
1068
|
+
// and either grouped or exactly one export type selected.
|
|
1069
|
+
const isPrintAvailable = (table) => {
|
|
1341
1070
|
var _a;
|
|
1342
|
-
|
|
1071
|
+
const allFormats = Object.values((_a = table.options.availableExports) !== null && _a !== void 0 ? _a : {}).flatMap((e) => e.formats);
|
|
1072
|
+
if (!allFormats.includes('pdf'))
|
|
1343
1073
|
return false;
|
|
1344
|
-
}
|
|
1345
|
-
|
|
1346
|
-
if (subRow.id === targetRowId) {
|
|
1347
|
-
return true;
|
|
1348
|
-
}
|
|
1349
|
-
if (isRowInSubtreeOf(targetRowId, subRow)) {
|
|
1350
|
-
return true;
|
|
1351
|
-
}
|
|
1352
|
-
}
|
|
1353
|
-
return false;
|
|
1354
|
-
};
|
|
1355
|
-
/**
|
|
1356
|
-
* Checks if a row can be used as a valid insert target for selected rows.
|
|
1357
|
-
* Rules: Target row must NOT be already selected AND must NOT be a descendant of any selected row.
|
|
1358
|
-
* This prevents circular references where a parent becomes a child of its own descendants.
|
|
1359
|
-
* Example: If you select "Department", you cannot insert it under "Project" (which is its descendant)
|
|
1360
|
-
*/
|
|
1361
|
-
const isValidInsertTarget = ({ targetRowId, selectedRowIds, table, }) => {
|
|
1362
|
-
// Rule 1: Target row cannot be already selected
|
|
1363
|
-
if (selectedRowIds.includes(targetRowId) || selectedRowIds.length === 0) {
|
|
1074
|
+
const { activeExports } = table.getState();
|
|
1075
|
+
if (!activeExports)
|
|
1364
1076
|
return false;
|
|
1365
|
-
}
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
const selectedRow = table.getRow(selectedRowId, true);
|
|
1370
|
-
if (selectedRow &&
|
|
1371
|
-
isRowInSubtreeOf(targetRowId, selectedRow)) {
|
|
1372
|
-
return false;
|
|
1373
|
-
}
|
|
1374
|
-
}
|
|
1375
|
-
return true;
|
|
1077
|
+
const { selectedFormat, selectedExports, grouped } = activeExports;
|
|
1078
|
+
return (selectedFormat === 'pdf' &&
|
|
1079
|
+
selectedExports.length >= 1 &&
|
|
1080
|
+
(grouped || selectedExports.length === 1));
|
|
1376
1081
|
};
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
const
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1082
|
+
const createExportAction = (_a = {}) => {
|
|
1083
|
+
var { onExport, renderRow: customRenderRow, renderToolbar: customRenderToolbar } = _a, rest = __rest(_a, ["onExport", "renderRow", "renderToolbar"]);
|
|
1084
|
+
// Pure download logic — no notifications. Throws on failure so callers can handle it.
|
|
1085
|
+
const defaultOnExport = (_a) => __awaiter(void 0, [_a], void 0, function* ({ rowsToExport, table, }) {
|
|
1086
|
+
if (!rowsToExport.length)
|
|
1087
|
+
return;
|
|
1088
|
+
const { loadExport } = table.options;
|
|
1089
|
+
const { activeExports } = table.getState();
|
|
1090
|
+
if (!loadExport || !activeExports)
|
|
1091
|
+
return;
|
|
1092
|
+
const response = yield loadExport({
|
|
1093
|
+
format: activeExports.selectedFormat,
|
|
1094
|
+
exports: activeExports.selectedExports,
|
|
1095
|
+
separated_files: !activeExports.grouped,
|
|
1096
|
+
download: false,
|
|
1097
|
+
ids: JSON.stringify(rowsToExport.map((r) => r.id)),
|
|
1098
|
+
type: 'download',
|
|
1099
|
+
});
|
|
1100
|
+
downloadExportFiles(response);
|
|
1389
1101
|
});
|
|
1390
|
-
|
|
1391
|
-
const
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1102
|
+
// Pure print logic — no notifications. Throws on failure so callers can handle it.
|
|
1103
|
+
const defaultOnPrint = (_a) => __awaiter(void 0, [_a], void 0, function* ({ rowsToExport, table, }) {
|
|
1104
|
+
if (!rowsToExport.length)
|
|
1105
|
+
return;
|
|
1106
|
+
const { loadExport } = table.options;
|
|
1107
|
+
const { activeExports } = table.getState();
|
|
1108
|
+
if (!loadExport || !activeExports)
|
|
1109
|
+
return;
|
|
1110
|
+
const response = yield loadExport({
|
|
1111
|
+
format: activeExports.selectedFormat,
|
|
1112
|
+
exports: activeExports.selectedExports,
|
|
1113
|
+
separated_files: !activeExports.grouped,
|
|
1114
|
+
download: false,
|
|
1115
|
+
ids: JSON.stringify(rowsToExport.map((r) => r.id)),
|
|
1116
|
+
type: 'print',
|
|
1404
1117
|
});
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
const
|
|
1410
|
-
|
|
1411
|
-
|
|
1118
|
+
printExportFiles(response);
|
|
1119
|
+
});
|
|
1120
|
+
// Single execution pipeline for every export flow (row or toolbar).
|
|
1121
|
+
// If a custom handler exists, it receives defaultOnExport and decides when to call it.
|
|
1122
|
+
const executeExport = (context) => {
|
|
1123
|
+
const executeDefaultExport = () => defaultOnExport(context);
|
|
1124
|
+
if (onExport) {
|
|
1125
|
+
return onExport(Object.assign(Object.assign({}, context), { defaultOnExport: executeDefaultExport }));
|
|
1126
|
+
}
|
|
1127
|
+
return executeDefaultExport();
|
|
1128
|
+
};
|
|
1129
|
+
// Row download: checks for active exports, then wraps with loading/success/error notifications.
|
|
1130
|
+
const handleSingleRowExport = (_a) => __awaiter(void 0, [_a], void 0, function* ({ table, row, }) {
|
|
1131
|
+
const { localization } = table.options;
|
|
1132
|
+
if (!hasActiveExports(table)) {
|
|
1133
|
+
notistack.enqueueSnackbar(localization.exportNoExportsSelected, {
|
|
1134
|
+
variant: 'warning',
|
|
1135
|
+
});
|
|
1412
1136
|
return;
|
|
1413
1137
|
}
|
|
1138
|
+
const loadingKey = notistack.enqueueSnackbar(localization.exportInProgress, {
|
|
1139
|
+
variant: 'info',
|
|
1140
|
+
persist: true,
|
|
1141
|
+
});
|
|
1414
1142
|
try {
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
table,
|
|
1419
|
-
targetRow: row,
|
|
1420
|
-
};
|
|
1421
|
-
onTreeRowReorder(treeRowReorderEvent);
|
|
1143
|
+
yield executeExport({ table, rowsToExport: [row] });
|
|
1144
|
+
notistack.closeSnackbar(loadingKey);
|
|
1145
|
+
notistack.enqueueSnackbar(localization.exportSuccess, { variant: 'success' });
|
|
1422
1146
|
}
|
|
1423
|
-
catch (
|
|
1424
|
-
|
|
1147
|
+
catch (_b) {
|
|
1148
|
+
notistack.closeSnackbar(loadingKey);
|
|
1149
|
+
notistack.enqueueSnackbar(localization.exportError, { variant: 'error' });
|
|
1425
1150
|
}
|
|
1426
|
-
}
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
table
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
isRowHovered,
|
|
1435
|
-
shouldShowReorderCheckbox,
|
|
1436
|
-
shouldShowInsertHereAction,
|
|
1437
|
-
handleRowHoverEnter: () => setIsRowHovered(true),
|
|
1438
|
-
handleRowHoverLeave: () => setIsRowHovered(false),
|
|
1439
|
-
handleReorderCheckboxChange,
|
|
1440
|
-
handleInsertHereActionClick,
|
|
1441
|
-
isReorderCheckboxSelected: !!(rowReorderingSelection === null || rowReorderingSelection === void 0 ? void 0 : rowReorderingSelection[row.id]),
|
|
1442
|
-
};
|
|
1443
|
-
};
|
|
1444
|
-
|
|
1445
|
-
const useTreeRowReorderingHeader = ({ table, enableRowReordering, onTreeRowReorder, }) => {
|
|
1446
|
-
const selectedReorderRowIds = getSelectedReorderRowIds(table.getState().rowReorderingSelection);
|
|
1447
|
-
const selectedRowsForReorder = buildSelectedRowsArray(selectedReorderRowIds, table);
|
|
1448
|
-
const shouldShowMoveToTopLevelAction = !!enableRowReordering &&
|
|
1449
|
-
selectedRowsForReorder.length > 0 &&
|
|
1450
|
-
selectedRowsForReorder.some((selectedRow) => selectedRow.depth > 0);
|
|
1451
|
-
const handleMoveToTopLevelActionClick = react.useCallback(() => {
|
|
1452
|
-
if (!onTreeRowReorder) {
|
|
1453
|
-
console.warn('[MRT] onTreeRowReorder callback is not defined');
|
|
1151
|
+
});
|
|
1152
|
+
// Row print: same guard + notification pattern as download, but calls defaultOnPrint.
|
|
1153
|
+
const handleSingleRowPrint = (_a) => __awaiter(void 0, [_a], void 0, function* ({ table, row, }) {
|
|
1154
|
+
const { localization } = table.options;
|
|
1155
|
+
if (!hasActiveExports(table)) {
|
|
1156
|
+
notistack.enqueueSnackbar(localization.exportNoExportsSelected, {
|
|
1157
|
+
variant: 'warning',
|
|
1158
|
+
});
|
|
1454
1159
|
return;
|
|
1455
1160
|
}
|
|
1161
|
+
const loadingKey = notistack.enqueueSnackbar(localization.exportInProgress, {
|
|
1162
|
+
variant: 'info',
|
|
1163
|
+
persist: true,
|
|
1164
|
+
});
|
|
1456
1165
|
try {
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
table,
|
|
1461
|
-
targetRow: null,
|
|
1462
|
-
};
|
|
1463
|
-
onTreeRowReorder(treeRowReorderEvent);
|
|
1166
|
+
yield defaultOnPrint({ table, rowsToExport: [row] });
|
|
1167
|
+
notistack.closeSnackbar(loadingKey);
|
|
1168
|
+
notistack.enqueueSnackbar(localization.exportSuccess, { variant: 'success' });
|
|
1464
1169
|
}
|
|
1465
|
-
catch (
|
|
1466
|
-
|
|
1170
|
+
catch (_b) {
|
|
1171
|
+
notistack.closeSnackbar(loadingKey);
|
|
1172
|
+
notistack.enqueueSnackbar(localization.exportError, { variant: 'error' });
|
|
1467
1173
|
}
|
|
1468
|
-
}
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1174
|
+
});
|
|
1175
|
+
// Resolves selected rows from table state for toolbar-triggered export (custom renderToolbar only).
|
|
1176
|
+
const handleMultipleRowExport = ({ table, }) => {
|
|
1177
|
+
const rowsToExport = table.getSelectedRowModel().rows;
|
|
1178
|
+
return executeExport({ table, rowsToExport });
|
|
1179
|
+
};
|
|
1180
|
+
const createRowExportExecutor = (context) => () => {
|
|
1181
|
+
void handleSingleRowExport(context);
|
|
1182
|
+
};
|
|
1183
|
+
const createRowPrintExecutor = (context) => () => {
|
|
1184
|
+
void handleSingleRowPrint(context);
|
|
1185
|
+
};
|
|
1186
|
+
const createToolbarExportExecutor = (context) => () => {
|
|
1187
|
+
void handleMultipleRowExport(context);
|
|
1188
|
+
};
|
|
1189
|
+
// Renders download + optional print button. Print is shown under the same conditions
|
|
1190
|
+
// as in MRT_ExportsToolbar: pdf format selected, active exports, grouped or single type.
|
|
1191
|
+
const renderRowAction = (context) => {
|
|
1192
|
+
const onRowExport = createRowExportExecutor(context);
|
|
1193
|
+
const onRowPrint = isPrintAvailable(context.table)
|
|
1194
|
+
? createRowPrintExecutor(context)
|
|
1195
|
+
: undefined;
|
|
1196
|
+
if (customRenderRow) {
|
|
1197
|
+
return customRenderRow(Object.assign(Object.assign({}, context), { onExport: onRowExport }));
|
|
1198
|
+
}
|
|
1199
|
+
return jsxRuntime.jsx(ExportRowAction, { onExport: onRowExport, onPrint: onRowPrint });
|
|
1200
|
+
};
|
|
1201
|
+
// Uses custom toolbar renderer when provided; otherwise renders MRT_ExportsToolbar.
|
|
1202
|
+
// loadExport is always wrapped with notifications so that loading/success/error are shown
|
|
1203
|
+
// regardless of whether a custom onExport handler was provided.
|
|
1204
|
+
// When onExport is provided, it intercepts the call and returns [] so MRT_ExportsToolbar
|
|
1205
|
+
// does not attempt a second download from an empty response.
|
|
1206
|
+
const renderToolbarAction = (context) => {
|
|
1207
|
+
const { table } = context;
|
|
1208
|
+
const { availableExports, loadExport, onActiveExportsChange, localization, } = table.options;
|
|
1209
|
+
const { activeExports } = table.getState();
|
|
1210
|
+
if (customRenderToolbar) {
|
|
1211
|
+
return customRenderToolbar(Object.assign(Object.assign({}, context), { onExport: createToolbarExportExecutor(context) }));
|
|
1212
|
+
}
|
|
1213
|
+
if (!availableExports ||
|
|
1214
|
+
!loadExport ||
|
|
1215
|
+
!onActiveExportsChange ||
|
|
1216
|
+
!activeExports) {
|
|
1217
|
+
return null;
|
|
1218
|
+
}
|
|
1219
|
+
const notifiedLoadExport = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1220
|
+
const loadingKey = notistack.enqueueSnackbar(localization.exportInProgress, {
|
|
1221
|
+
variant: 'info',
|
|
1222
|
+
persist: true,
|
|
1223
|
+
});
|
|
1224
|
+
try {
|
|
1225
|
+
let response;
|
|
1226
|
+
if (onExport) {
|
|
1227
|
+
const rowsToExport = table.getSelectedRowModel().rows;
|
|
1228
|
+
yield executeExport({ table, rowsToExport });
|
|
1229
|
+
response = [];
|
|
1230
|
+
}
|
|
1231
|
+
else {
|
|
1232
|
+
response = yield loadExport(params);
|
|
1233
|
+
}
|
|
1234
|
+
notistack.closeSnackbar(loadingKey);
|
|
1235
|
+
notistack.enqueueSnackbar(localization.exportSuccess, { variant: 'success' });
|
|
1236
|
+
return response;
|
|
1237
|
+
}
|
|
1238
|
+
catch (_a) {
|
|
1239
|
+
notistack.closeSnackbar(loadingKey);
|
|
1240
|
+
notistack.enqueueSnackbar(localization.exportError, { variant: 'error' });
|
|
1241
|
+
return [];
|
|
1242
|
+
}
|
|
1243
|
+
});
|
|
1244
|
+
return (jsxRuntime.jsx(MRT_ExportsToolbar, { table: table, availableExports: availableExports, exportState: activeExports, onExportStateChange: onActiveExportsChange, loadExport: notifiedLoadExport }));
|
|
1472
1245
|
};
|
|
1246
|
+
return Object.assign({ name: 'export', renderRow: renderRowAction, renderToolbar: renderToolbarAction }, rest);
|
|
1473
1247
|
};
|
|
1474
1248
|
|
|
1475
|
-
const
|
|
1476
|
-
|
|
1249
|
+
const MRT_AggregationFns = Object.assign({}, reactTable.aggregationFns);
|
|
1250
|
+
|
|
1251
|
+
const fuzzy = (row, columnId, filterValue, addMeta) => {
|
|
1252
|
+
const itemRank = matchSorterUtils.rankItem(row.getValue(columnId), filterValue, {
|
|
1253
|
+
threshold: matchSorterUtils.rankings.MATCHES,
|
|
1254
|
+
});
|
|
1255
|
+
addMeta(itemRank);
|
|
1256
|
+
return itemRank.passed;
|
|
1257
|
+
};
|
|
1258
|
+
fuzzy.autoRemove = (val) => !val;
|
|
1259
|
+
const contains = (row, id, filterValue) => {
|
|
1477
1260
|
var _a;
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
? {
|
|
1481
|
-
align: 'right',
|
|
1482
|
-
}
|
|
1483
|
-
: undefined;
|
|
1484
|
-
return Object.assign(Object.assign({ Cell: ({ cell, column, row, staticRowIndex, table }) => {
|
|
1485
|
-
var _a, _b, _c;
|
|
1486
|
-
const cellLogic = useTreeRowReorderingCell({
|
|
1487
|
-
row,
|
|
1488
|
-
table,
|
|
1489
|
-
rowReorderingSelection,
|
|
1490
|
-
maxDepth,
|
|
1491
|
-
onTreeRowReorder,
|
|
1492
|
-
});
|
|
1493
|
-
const expandButtonProps = { row, staticRowIndex, table };
|
|
1494
|
-
const subRowsLength = (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.length;
|
|
1495
|
-
const customGroupedCell = (_c = (_b = column.columnDef).GroupedCell) === null || _c === void 0 ? void 0 : _c.call(_b, {
|
|
1496
|
-
cell,
|
|
1497
|
-
column,
|
|
1498
|
-
row,
|
|
1499
|
-
table,
|
|
1500
|
-
staticRowIndex,
|
|
1501
|
-
});
|
|
1502
|
-
if (groupedColumnMode === 'remove' && row.groupingColumnId) {
|
|
1503
|
-
const defaultGroupedCell = (jsxRuntime.jsx(Tooltip, Object.assign({}, getCommonTooltipProps('right'), { title: table.getColumn(row.groupingColumnId).columnDef.header, children: jsxRuntime.jsx("span", { children: row.groupingValue }) })));
|
|
1504
|
-
return (jsxRuntime.jsxs(Stack, { alignItems: "center", flexDirection: "row", gap: TREE_REORDER_ICON_SPACING, onMouseEnter: cellLogic.handleRowHoverEnter, onMouseLeave: cellLogic.handleRowHoverLeave, width: "100%", children: [jsxRuntime.jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), column.columnDef.GroupedCell
|
|
1505
|
-
? customGroupedCell
|
|
1506
|
-
: defaultGroupedCell, cellLogic.shouldShowReorderCheckbox && (jsxRuntime.jsx(MRT_ReorderRowCheckbox, { isSelected: cellLogic.isReorderCheckboxSelected, onChange: cellLogic.handleReorderCheckboxChange })), cellLogic.shouldShowInsertHereAction && (jsxRuntime.jsx(MRT_InsertHereAction, { onClick: cellLogic.handleInsertHereActionClick })), !!subRowsLength && jsxRuntime.jsxs("span", { children: ["(", subRowsLength, ")"] })] }));
|
|
1507
|
-
}
|
|
1508
|
-
return (jsxRuntime.jsxs(Stack, { alignItems: "center", flexDirection: "row", gap: TREE_REORDER_ICON_SPACING, onMouseEnter: cellLogic.handleRowHoverEnter, onMouseLeave: cellLogic.handleRowHoverLeave, width: "100%", children: [jsxRuntime.jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), customGroupedCell, cellLogic.shouldShowReorderCheckbox && (jsxRuntime.jsx(MRT_ReorderRowCheckbox, { isSelected: cellLogic.isReorderCheckboxSelected, onChange: cellLogic.handleReorderCheckboxChange })), cellLogic.shouldShowInsertHereAction && (jsxRuntime.jsx(MRT_InsertHereAction, { onClick: cellLogic.handleInsertHereActionClick }))] }));
|
|
1509
|
-
}, Header: enableExpandAll
|
|
1510
|
-
? ({ table }) => {
|
|
1511
|
-
var _a;
|
|
1512
|
-
const headerLogic = useTreeRowReorderingHeader({
|
|
1513
|
-
table,
|
|
1514
|
-
enableRowReordering,
|
|
1515
|
-
onTreeRowReorder,
|
|
1516
|
-
});
|
|
1517
|
-
return (jsxRuntime.jsxs(Stack, { alignItems: "center", flexDirection: "row", gap: TREE_REORDER_ICON_SPACING, children: [jsxRuntime.jsx(MRT_ExpandAllButton, { table: table }), headerLogic.shouldShowMoveToTopLevelAction && (jsxRuntime.jsx(MRT_MoveToTopAction, { onClick: headerLogic.handleMoveToTopLevelActionClick })), groupedColumnMode === 'remove' &&
|
|
1518
|
-
((_a = grouping === null || grouping === void 0 ? void 0 : grouping.map((groupedColumnId) => table.getColumn(groupedColumnId).columnDef.header)) === null || _a === void 0 ? void 0 : _a.join(', '))] }));
|
|
1519
|
-
}
|
|
1520
|
-
: undefined, muiTableBodyCellProps: alignProps, muiTableHeadCellProps: alignProps }, defaultDisplayColumnProps({
|
|
1521
|
-
header: 'expand',
|
|
1522
|
-
id: 'mrt-row-expand',
|
|
1523
|
-
size: groupedColumnMode === 'remove'
|
|
1524
|
-
? ((_a = defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.size) !== null && _a !== void 0 ? _a : 180)
|
|
1525
|
-
: renderDetailPanel
|
|
1526
|
-
? enableExpandAll
|
|
1527
|
-
? 60
|
|
1528
|
-
: 70
|
|
1529
|
-
: 100,
|
|
1530
|
-
tableOptions,
|
|
1531
|
-
})), { enableResizing: true });
|
|
1261
|
+
return !!((_a = row
|
|
1262
|
+
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().includes(filterValue.toString().toLowerCase().trim()));
|
|
1532
1263
|
};
|
|
1533
|
-
|
|
1534
|
-
const
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1264
|
+
contains.autoRemove = (val) => !val;
|
|
1265
|
+
const startsWith = (row, id, filterValue) => {
|
|
1266
|
+
var _a;
|
|
1267
|
+
return !!((_a = row
|
|
1268
|
+
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().startsWith(filterValue.toString().toLowerCase().trim()));
|
|
1269
|
+
};
|
|
1270
|
+
startsWith.autoRemove = (val) => !val;
|
|
1271
|
+
const endsWith = (row, id, filterValue) => {
|
|
1272
|
+
var _a;
|
|
1273
|
+
return !!((_a = row
|
|
1274
|
+
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().endsWith(filterValue.toString().toLowerCase().trim()));
|
|
1275
|
+
};
|
|
1276
|
+
endsWith.autoRemove = (val) => !val;
|
|
1277
|
+
const equals = (row, id, filterValue) => {
|
|
1278
|
+
var _a;
|
|
1279
|
+
return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) ===
|
|
1280
|
+
filterValue.toString().toLowerCase().trim();
|
|
1281
|
+
};
|
|
1282
|
+
equals.autoRemove = (val) => !val;
|
|
1283
|
+
const notEquals = (row, id, filterValue) => {
|
|
1284
|
+
var _a;
|
|
1285
|
+
return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) !==
|
|
1286
|
+
filterValue.toString().toLowerCase().trim();
|
|
1287
|
+
};
|
|
1288
|
+
notEquals.autoRemove = (val) => !val;
|
|
1289
|
+
const greaterThan = (row, id, filterValue) => {
|
|
1290
|
+
var _a, _b, _c;
|
|
1291
|
+
return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
|
1292
|
+
? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) > +filterValue
|
|
1293
|
+
: ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) > filterValue.toString().toLowerCase().trim();
|
|
1548
1294
|
};
|
|
1295
|
+
greaterThan.autoRemove = (val) => !val;
|
|
1296
|
+
const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
|
|
1297
|
+
greaterThanOrEqualTo.autoRemove = (val) => !val;
|
|
1298
|
+
const lessThan = (row, id, filterValue) => {
|
|
1299
|
+
var _a, _b, _c;
|
|
1300
|
+
return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
|
1301
|
+
? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) < +filterValue
|
|
1302
|
+
: ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) < filterValue.toString().toLowerCase().trim();
|
|
1303
|
+
};
|
|
1304
|
+
lessThan.autoRemove = (val) => !val;
|
|
1305
|
+
const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
|
|
1306
|
+
lessThanOrEqualTo.autoRemove = (val) => !val;
|
|
1307
|
+
const between = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
|
|
1308
|
+
greaterThan(row, id, filterValues[0])) &&
|
|
1309
|
+
((!isNaN(+filterValues[0]) &&
|
|
1310
|
+
!isNaN(+filterValues[1]) &&
|
|
1311
|
+
+filterValues[0] > +filterValues[1]) ||
|
|
1312
|
+
['', undefined].includes(filterValues[1]) ||
|
|
1313
|
+
lessThan(row, id, filterValues[1]));
|
|
1314
|
+
between.autoRemove = (val) => !val;
|
|
1315
|
+
const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
|
|
1316
|
+
greaterThanOrEqualTo(row, id, filterValues[0])) &&
|
|
1317
|
+
((!isNaN(+filterValues[0]) &&
|
|
1318
|
+
!isNaN(+filterValues[1]) &&
|
|
1319
|
+
+filterValues[0] > +filterValues[1]) ||
|
|
1320
|
+
['', undefined].includes(filterValues[1]) ||
|
|
1321
|
+
lessThanOrEqualTo(row, id, filterValues[1]));
|
|
1322
|
+
betweenInclusive.autoRemove = (val) => !val;
|
|
1323
|
+
const empty = (row, id, _filterValue) => { var _a; return !((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
|
|
1324
|
+
empty.autoRemove = (val) => !val;
|
|
1325
|
+
const notEmpty = (row, id, _filterValue) => { var _a; return !!((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
|
|
1326
|
+
notEmpty.autoRemove = (val) => !val;
|
|
1327
|
+
const MRT_FilterFns = Object.assign(Object.assign({}, reactTable.filterFns), { between,
|
|
1328
|
+
betweenInclusive,
|
|
1329
|
+
contains,
|
|
1330
|
+
empty,
|
|
1331
|
+
endsWith,
|
|
1332
|
+
equals,
|
|
1333
|
+
fuzzy,
|
|
1334
|
+
greaterThan,
|
|
1335
|
+
greaterThanOrEqualTo,
|
|
1336
|
+
lessThan,
|
|
1337
|
+
lessThanOrEqualTo,
|
|
1338
|
+
notEmpty,
|
|
1339
|
+
notEquals,
|
|
1340
|
+
startsWith });
|
|
1549
1341
|
|
|
1550
|
-
const
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
const isPinned = row.getIsPinned();
|
|
1554
|
-
const [tooltipOpened, setTooltipOpened] = react.useState(false);
|
|
1555
|
-
const handleTogglePin = (event) => {
|
|
1556
|
-
setTooltipOpened(false);
|
|
1557
|
-
event.stopPropagation();
|
|
1558
|
-
row.pin(isPinned ? false : pinningPosition);
|
|
1559
|
-
};
|
|
1560
|
-
return (jsxRuntime.jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { open: tooltipOpened, title: isPinned ? localization.unpin : localization.pin, children: jsxRuntime.jsx(IconButton, Object.assign({ "aria-label": localization.pin, onBlur: () => setTooltipOpened(false), onClick: handleTogglePin, onFocus: () => setTooltipOpened(true), onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false), size: "small" }, rest, { sx: (theme) => (Object.assign({ height: '24px', width: '24px' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: isPinned ? (jsxRuntime.jsx(CloseIcon, {})) : (jsxRuntime.jsx(PushPinIcon, { fontSize: "small", style: {
|
|
1561
|
-
transform: `rotate(${rowPinningDisplayMode === 'sticky'
|
|
1562
|
-
? 135
|
|
1563
|
-
: pinningPosition === 'top'
|
|
1564
|
-
? 180
|
|
1565
|
-
: 0}deg)`,
|
|
1566
|
-
} })) })) })));
|
|
1342
|
+
const useMRT_SliceValue = (store, selector) => {
|
|
1343
|
+
const getSnapshot = () => selector(store.get());
|
|
1344
|
+
return react.useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
|
|
1567
1345
|
};
|
|
1568
1346
|
|
|
1569
|
-
const
|
|
1570
|
-
var {
|
|
1571
|
-
const {
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
}, children: [jsxRuntime.jsx(MRT_RowPinButton, Object.assign({ pinningPosition: "top" }, rowPinButtonProps)), jsxRuntime.jsx(MRT_RowPinButton, Object.assign({ pinningPosition: "bottom" }, rowPinButtonProps))] }));
|
|
1583
|
-
}
|
|
1584
|
-
return (jsxRuntime.jsx(MRT_RowPinButton, Object.assign({ pinningPosition: rowPinningDisplayMode === 'bottom' ? 'bottom' : 'top' }, rowPinButtonProps)));
|
|
1347
|
+
const MRT_ActionMenuItem = (_a) => {
|
|
1348
|
+
var { icon, label, onOpenSubMenu, table } = _a, rest = __rest(_a, ["icon", "label", "onOpenSubMenu", "table"]);
|
|
1349
|
+
const { options: { icons: { ArrowRightIcon }, }, } = table;
|
|
1350
|
+
return (jsxRuntime.jsxs(MenuItem, Object.assign({ sx: {
|
|
1351
|
+
alignItems: 'center',
|
|
1352
|
+
justifyContent: 'space-between',
|
|
1353
|
+
minWidth: '120px',
|
|
1354
|
+
my: 0,
|
|
1355
|
+
py: '6px',
|
|
1356
|
+
}, tabIndex: 0 }, rest, { children: [jsxRuntime.jsxs(Box, { sx: {
|
|
1357
|
+
alignItems: 'center',
|
|
1358
|
+
display: 'flex',
|
|
1359
|
+
}, children: [jsxRuntime.jsx(ListItemIcon, { children: icon }), label] }), onOpenSubMenu && (jsxRuntime.jsx(IconButton, { onClick: (e) => onOpenSubMenu(e), onMouseEnter: (e) => onOpenSubMenu(e), size: "small", sx: { p: 0 }, children: jsxRuntime.jsx(ArrowRightIcon, {}) }))] })));
|
|
1585
1360
|
};
|
|
1586
1361
|
|
|
1587
|
-
const
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1362
|
+
const MRT_RowActionMenu = (_a) => {
|
|
1363
|
+
var { anchorEl, handleEdit, row, setAnchorEl, staticRowIndex, table } = _a, rest = __rest(_a, ["anchorEl", "handleEdit", "row", "setAnchorEl", "staticRowIndex", "table"]);
|
|
1364
|
+
const { options: { editDisplayMode, enableEditing, icons: { EditIcon }, localization, mrtTheme: { menuBackgroundColor }, renderRowActionMenuItems, }, } = table;
|
|
1365
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
1366
|
+
const menuItems = react.useMemo(() => {
|
|
1367
|
+
const items = [];
|
|
1368
|
+
const editItem = parseFromValuesOrFunc(enableEditing, row) &&
|
|
1369
|
+
['modal', 'row'].includes(editDisplayMode) && (jsxRuntime.jsx(MRT_ActionMenuItem, { icon: jsxRuntime.jsx(EditIcon, {}), label: localization.edit, onClick: handleEdit, table: table }, 'edit'));
|
|
1370
|
+
if (editItem)
|
|
1371
|
+
items.push(editItem);
|
|
1372
|
+
const rowActionMenuItems = renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
|
1373
|
+
closeMenu: () => setAnchorEl(null),
|
|
1374
|
+
row,
|
|
1375
|
+
staticRowIndex,
|
|
1376
|
+
table,
|
|
1377
|
+
});
|
|
1378
|
+
if (rowActionMenuItems === null || rowActionMenuItems === void 0 ? void 0 : rowActionMenuItems.length)
|
|
1379
|
+
items.push(...rowActionMenuItems);
|
|
1380
|
+
return items;
|
|
1381
|
+
}, [renderRowActionMenuItems, row, staticRowIndex, table]);
|
|
1382
|
+
if (!menuItems.length)
|
|
1383
|
+
return null;
|
|
1384
|
+
return (jsxRuntime.jsx(Menu, Object.assign({ MenuListProps: {
|
|
1385
|
+
dense: density === 'compact',
|
|
1386
|
+
sx: {
|
|
1387
|
+
backgroundColor: menuBackgroundColor,
|
|
1388
|
+
},
|
|
1389
|
+
}, anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: menuItems })));
|
|
1594
1390
|
};
|
|
1595
1391
|
|
|
1596
|
-
const
|
|
1597
|
-
|
|
1598
|
-
const
|
|
1599
|
-
const {
|
|
1600
|
-
|
|
1601
|
-
const
|
|
1602
|
-
const
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
};
|
|
1607
|
-
const handleClose = () => {
|
|
1608
|
-
setAnchorEl(null);
|
|
1609
|
-
};
|
|
1610
|
-
// Clears row pinning on every bulk selection/deselection
|
|
1611
|
-
const clearPinning = () => {
|
|
1612
|
-
if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
|
|
1613
|
-
table.setRowPinning({ bottom: [], top: [] });
|
|
1392
|
+
const MRT_EditActionButtons = (_a) => {
|
|
1393
|
+
var { row, table, variant = 'icon' } = _a, rest = __rest(_a, ["row", "table", "variant"]);
|
|
1394
|
+
const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onCreatingRowCancel, onCreatingRowSave, onEditingRowCancel, onEditingRowSave, }, refs: { editInputRefs }, setCreatingRow, setEditingRow, } = table;
|
|
1395
|
+
const { creatingRow, isSaving } = getState();
|
|
1396
|
+
const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
|
|
1397
|
+
const isEditing = useMRT_SliceValue(table._uiStore, (s) => { var _a; return ((_a = s.editingRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
|
|
1398
|
+
const handleCancel = () => {
|
|
1399
|
+
if (isCreating) {
|
|
1400
|
+
onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
|
|
1401
|
+
setCreatingRow(null);
|
|
1614
1402
|
}
|
|
1403
|
+
else if (isEditing) {
|
|
1404
|
+
onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
|
|
1405
|
+
setEditingRow(null);
|
|
1406
|
+
}
|
|
1407
|
+
row._valuesCache = {}; //reset values cache
|
|
1615
1408
|
};
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
table.setRowSelection({});
|
|
1626
|
-
allSelectableRowIdsRef.current = [];
|
|
1627
|
-
}
|
|
1628
|
-
else {
|
|
1629
|
-
table.toggleAllPageRowsSelected(false);
|
|
1630
|
-
}
|
|
1631
|
-
clearPinning();
|
|
1632
|
-
handleClose();
|
|
1633
|
-
};
|
|
1634
|
-
// ── All-pages actions ───────────────────────────────────────────────────────
|
|
1635
|
-
const handleSelectAllPages = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1636
|
-
handleClose();
|
|
1637
|
-
if (getAllSelectableRowIds) {
|
|
1638
|
-
// Server-side: IDs are not available locally, fetch them from the API
|
|
1639
|
-
setIsSelectingAllPages(true);
|
|
1640
|
-
table.setShowProgressBars(true);
|
|
1641
|
-
try {
|
|
1642
|
-
const ids = yield getAllSelectableRowIds({ table });
|
|
1643
|
-
allSelectableRowIdsRef.current = ids;
|
|
1644
|
-
const newSelection = {};
|
|
1645
|
-
ids.forEach((id) => {
|
|
1646
|
-
newSelection[id] = true;
|
|
1647
|
-
});
|
|
1648
|
-
table.setRowSelection(newSelection);
|
|
1649
|
-
clearPinning();
|
|
1650
|
-
}
|
|
1651
|
-
finally {
|
|
1652
|
-
setIsSelectingAllPages(false);
|
|
1653
|
-
table.setShowProgressBars(false);
|
|
1409
|
+
const handleSubmitRow = () => {
|
|
1410
|
+
var _a, _b;
|
|
1411
|
+
//look for auto-filled input values
|
|
1412
|
+
(_b = Object.values((_a = editInputRefs.current) !== null && _a !== void 0 ? _a : {})
|
|
1413
|
+
.filter((inputRef) => { var _a, _b; return row.id === ((_b = (_a = inputRef === null || inputRef === void 0 ? void 0 : inputRef.name) === null || _a === void 0 ? void 0 : _a.split('_')) === null || _b === void 0 ? void 0 : _b[0]); })) === null || _b === void 0 ? void 0 : _b.forEach((input) => {
|
|
1414
|
+
if (input.value !== undefined &&
|
|
1415
|
+
Object.hasOwn(row === null || row === void 0 ? void 0 : row._valuesCache, input.name)) {
|
|
1416
|
+
// @ts-expect-error
|
|
1417
|
+
row._valuesCache[input.name] = input.value;
|
|
1654
1418
|
}
|
|
1419
|
+
});
|
|
1420
|
+
if (isCreating)
|
|
1421
|
+
onCreatingRowSave === null || onCreatingRowSave === void 0 ? void 0 : onCreatingRowSave({
|
|
1422
|
+
exitCreatingMode: () => setCreatingRow(null),
|
|
1423
|
+
row,
|
|
1424
|
+
table,
|
|
1425
|
+
values: row._valuesCache,
|
|
1426
|
+
});
|
|
1427
|
+
else if (isEditing) {
|
|
1428
|
+
onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
|
|
1429
|
+
exitEditingMode: () => setEditingRow(null),
|
|
1430
|
+
row,
|
|
1431
|
+
table,
|
|
1432
|
+
values: row === null || row === void 0 ? void 0 : row._valuesCache,
|
|
1433
|
+
});
|
|
1655
1434
|
}
|
|
1656
|
-
else {
|
|
1657
|
-
// Client-side: all data is available locally
|
|
1658
|
-
table.toggleAllRowsSelected(true);
|
|
1659
|
-
clearPinning();
|
|
1660
|
-
}
|
|
1661
|
-
});
|
|
1662
|
-
const handleDeselectAllPages = () => {
|
|
1663
|
-
if (getAllSelectableRowIds) {
|
|
1664
|
-
table.setRowSelection({});
|
|
1665
|
-
}
|
|
1666
|
-
else {
|
|
1667
|
-
table.toggleAllRowsSelected(false);
|
|
1668
|
-
}
|
|
1669
|
-
allSelectableRowIdsRef.current = [];
|
|
1670
|
-
clearPinning();
|
|
1671
|
-
handleClose();
|
|
1672
1435
|
};
|
|
1673
|
-
|
|
1674
|
-
|
|
1436
|
+
return (jsxRuntime.jsx(Box, { onClick: (e) => e.stopPropagation(), sx: (theme) => (Object.assign({ display: 'flex', gap: '0.75rem' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: variant === 'icon' ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip, { title: localization.cancel, children: jsxRuntime.jsx(IconButton, { "aria-label": localization.cancel, onClick: handleCancel, children: jsxRuntime.jsx(CancelIcon, {}) }) }), ((isCreating && onCreatingRowSave) ||
|
|
1437
|
+
(isEditing && onEditingRowSave)) && (jsxRuntime.jsx(Tooltip, { title: localization.save, children: jsxRuntime.jsx(IconButton, { "aria-label": localization.save, color: "info", disabled: isSaving, onClick: handleSubmitRow, children: isSaving ? jsxRuntime.jsx(CircularProgress, { size: 18 }) : jsxRuntime.jsx(SaveIcon, {}) }) }))] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Button, { onClick: handleCancel, sx: { minWidth: '100px' }, children: localization.cancel }), jsxRuntime.jsxs(Button, { disabled: isSaving, onClick: handleSubmitRow, sx: { minWidth: '100px' }, variant: "contained", children: [isSaving && jsxRuntime.jsx(CircularProgress, { color: "inherit", size: 18 }), localization.save] })] })) }));
|
|
1675
1438
|
};
|
|
1676
1439
|
|
|
1677
|
-
const
|
|
1440
|
+
const parseCSSVarId = (id) => id.replace(/[^a-zA-Z0-9]/g, '_');
|
|
1441
|
+
const getMRTTheme = (mrtTheme, muiTheme) => {
|
|
1442
|
+
const mrtThemeOverrides = parseFromValuesOrFunc(mrtTheme, muiTheme);
|
|
1443
|
+
const baseBackgroundColor = muiTheme.palette.background.default;
|
|
1444
|
+
return Object.assign({ baseBackgroundColor, cellNavigationOutlineColor: muiTheme.palette.primary.main, draggingBorderColor: muiTheme.palette.primary.main, matchHighlightColor: muiTheme.palette.mode === 'dark'
|
|
1445
|
+
? styles.darken(muiTheme.palette.warning.dark, 0.25)
|
|
1446
|
+
: styles.lighten(muiTheme.palette.warning.light, 0.5), menuBackgroundColor: styles.lighten(baseBackgroundColor, 0.07), pinnedRowBackgroundColor: styles.alpha(muiTheme.palette.primary.main, 0.1), selectedRowBackgroundColor: styles.alpha(muiTheme.palette.primary.main, 0.2) }, mrtThemeOverrides);
|
|
1447
|
+
};
|
|
1448
|
+
const commonCellBeforeAfterStyles = {
|
|
1449
|
+
content: '""',
|
|
1450
|
+
height: '100%',
|
|
1451
|
+
left: 0,
|
|
1452
|
+
position: 'absolute',
|
|
1453
|
+
top: 0,
|
|
1454
|
+
width: '100%',
|
|
1455
|
+
zIndex: -1,
|
|
1456
|
+
};
|
|
1457
|
+
const getCommonPinnedCellStyles = ({ table, theme, }) => {
|
|
1458
|
+
const { baseBackgroundColor } = table.options.mrtTheme;
|
|
1459
|
+
return {
|
|
1460
|
+
'&[data-pinned="true"]': {
|
|
1461
|
+
'&:before': Object.assign({ backgroundColor: styles.alpha(styles.darken(baseBackgroundColor, theme.palette.mode === 'dark' ? 0.05 : 0.01), 0.97) }, commonCellBeforeAfterStyles),
|
|
1462
|
+
},
|
|
1463
|
+
};
|
|
1464
|
+
};
|
|
1465
|
+
const getCommonMRTCellStyles = ({ column, header, isDraggingColumn, isHoveredColumn, table, tableCellProps, theme, }) => {
|
|
1466
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1467
|
+
const { options: { enableColumnVirtualization, layoutMode }, } = table;
|
|
1468
|
+
const { columnDef } = column;
|
|
1469
|
+
const { columnDefType } = columnDef;
|
|
1470
|
+
const isColumnPinned = columnDef.columnDefType !== 'group' && column.getIsPinned();
|
|
1471
|
+
const widthStyles = {
|
|
1472
|
+
minWidth: `max(calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId((_a = header === null || header === void 0 ? void 0 : header.id) !== null && _a !== void 0 ? _a : column.id)}-size) * 1px), ${(_b = columnDef.minSize) !== null && _b !== void 0 ? _b : 30}px)`,
|
|
1473
|
+
width: `calc(var(--${header ? 'header' : 'col'}-${parseCSSVarId((_c = header === null || header === void 0 ? void 0 : header.id) !== null && _c !== void 0 ? _c : column.id)}-size) * 1px)`,
|
|
1474
|
+
};
|
|
1475
|
+
if (layoutMode === 'grid') {
|
|
1476
|
+
widthStyles.flex = `${[0, false].includes(columnDef.grow)
|
|
1477
|
+
? 0
|
|
1478
|
+
: `var(--${header ? 'header' : 'col'}-${parseCSSVarId((_d = header === null || header === void 0 ? void 0 : header.id) !== null && _d !== void 0 ? _d : column.id)}-size)`} 0 auto`;
|
|
1479
|
+
}
|
|
1480
|
+
else if (layoutMode === 'grid-no-grow') {
|
|
1481
|
+
widthStyles.flex = `${+(columnDef.grow || 0)} 0 auto`;
|
|
1482
|
+
}
|
|
1483
|
+
// The checkbox column is technically pinned (for sticky positioning) but
|
|
1484
|
+
// should look like a regular center column — no background overlay or shadow.
|
|
1485
|
+
const isCheckboxColumn = column.id === CHECKBOX_DISPLAY_COLUMN_ID;
|
|
1486
|
+
// Count all currently pinned column IDs across both sides.
|
|
1487
|
+
// Checkbox is always pinned (counts as 1), so > 1 means the user has
|
|
1488
|
+
// explicitly pinned at least one additional column.
|
|
1489
|
+
const totalPinnedColumnCount = [
|
|
1490
|
+
...((_e = table.getState().columnPinning.left) !== null && _e !== void 0 ? _e : []),
|
|
1491
|
+
...((_f = table.getState().columnPinning.right) !== null && _f !== void 0 ? _f : []),
|
|
1492
|
+
].length;
|
|
1493
|
+
const hasNoPinnedColumns = totalPinnedColumnCount === 0;
|
|
1494
|
+
const pinnedStyles = isColumnPinned
|
|
1495
|
+
? Object.assign(Object.assign({}, (isCheckboxColumn
|
|
1496
|
+
? hasNoPinnedColumns
|
|
1497
|
+
? {
|
|
1498
|
+
// Use doubled class selector (&&) to beat the row-level
|
|
1499
|
+
// td[data-pinned="true"]:before specificity from MRT_TableBodyRow.
|
|
1500
|
+
'&&[data-pinned="true"]': {
|
|
1501
|
+
'&:before': {
|
|
1502
|
+
backgroundColor: 'transparent',
|
|
1503
|
+
boxShadow: 'none',
|
|
1504
|
+
},
|
|
1505
|
+
},
|
|
1506
|
+
}
|
|
1507
|
+
: // Other columns are also pinned — apply standard pinned background
|
|
1508
|
+
// so the checkbox header matches the pinned row cells below it.
|
|
1509
|
+
getCommonPinnedCellStyles({ column, table, theme })
|
|
1510
|
+
: getCommonPinnedCellStyles({ column, table, theme }))), { left: isColumnPinned === 'left'
|
|
1511
|
+
? `${column.getStart('left')}px`
|
|
1512
|
+
: undefined,
|
|
1513
|
+
// Skip opacity reduction for checkbox — keep it fully opaque like center columns
|
|
1514
|
+
opacity: isCheckboxColumn ? undefined : 0.97, position: 'sticky', right: isColumnPinned === 'right'
|
|
1515
|
+
? `${column.getAfter('right')}px`
|
|
1516
|
+
: undefined }) : {};
|
|
1517
|
+
return Object.assign(Object.assign(Object.assign({ backgroundColor: 'inherit', backgroundImage: 'inherit', display: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid')) ? 'flex' : undefined, justifyContent: columnDefType === 'group'
|
|
1518
|
+
? 'center'
|
|
1519
|
+
: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid'))
|
|
1520
|
+
? tableCellProps.align
|
|
1521
|
+
: undefined, opacity: isDraggingColumn || isHoveredColumn ? 0.5 : 1, position: 'relative', transition: enableColumnVirtualization
|
|
1522
|
+
? 'none'
|
|
1523
|
+
: `padding 150ms ease-in-out`, zIndex: column.getIsResizing() || isDraggingColumn
|
|
1524
|
+
? 2
|
|
1525
|
+
: columnDefType !== 'group' && isColumnPinned
|
|
1526
|
+
? 1
|
|
1527
|
+
: 0, '&:focus-visible': {
|
|
1528
|
+
outline: `2px solid ${table.options.mrtTheme.cellNavigationOutlineColor}`,
|
|
1529
|
+
outlineOffset: '-2px',
|
|
1530
|
+
} }, pinnedStyles), widthStyles), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme));
|
|
1531
|
+
};
|
|
1532
|
+
const getCommonToolbarStyles = ({ table, }) => ({
|
|
1533
|
+
alignItems: 'flex-start',
|
|
1534
|
+
backgroundColor: table.options.mrtTheme.baseBackgroundColor,
|
|
1535
|
+
display: 'grid',
|
|
1536
|
+
flexWrap: 'wrap-reverse',
|
|
1537
|
+
position: 'relative',
|
|
1538
|
+
transition: 'all 150ms ease-in-out',
|
|
1539
|
+
zIndex: 1,
|
|
1540
|
+
});
|
|
1541
|
+
const flipIconStyles = (theme) => theme.direction === 'rtl'
|
|
1542
|
+
? { style: { transform: 'scaleX(-1)' } }
|
|
1543
|
+
: undefined;
|
|
1544
|
+
const getCommonTooltipProps = (placement) => ({
|
|
1545
|
+
disableInteractive: true,
|
|
1546
|
+
enterDelay: 1000,
|
|
1547
|
+
enterNextDelay: 1000,
|
|
1548
|
+
placement,
|
|
1549
|
+
});
|
|
1550
|
+
|
|
1551
|
+
const commonIconButtonStyles = {
|
|
1552
|
+
'&:hover': {
|
|
1553
|
+
opacity: 1,
|
|
1554
|
+
},
|
|
1555
|
+
height: '2rem',
|
|
1556
|
+
ml: '10px',
|
|
1557
|
+
opacity: 0.5,
|
|
1558
|
+
transition: 'opacity 150ms',
|
|
1559
|
+
width: '2rem',
|
|
1560
|
+
};
|
|
1561
|
+
const MRT_ToggleRowActionMenuButton = (_a) => {
|
|
1678
1562
|
var _b;
|
|
1679
|
-
var { row, staticRowIndex, table } = _a, rest = __rest(_a, ["row", "staticRowIndex", "table"]);
|
|
1680
|
-
const { getState, options: {
|
|
1681
|
-
const {
|
|
1682
|
-
const
|
|
1683
|
-
const
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1563
|
+
var { cell, row, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "row", "staticRowIndex", "table"]);
|
|
1564
|
+
const { getState, options: { createDisplayMode, editDisplayMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
|
|
1565
|
+
const { creatingRow } = getState();
|
|
1566
|
+
const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
|
|
1567
|
+
const isEditing = useMRT_SliceValue(table._uiStore, (s) => { var _a; return ((_a = s.editingRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
|
|
1568
|
+
const showEditActionButtons = (isCreating && createDisplayMode === 'row') ||
|
|
1569
|
+
(isEditing && editDisplayMode === 'row');
|
|
1570
|
+
const [anchorEl, setAnchorEl] = react.useState(null);
|
|
1571
|
+
const handleOpenRowActionMenu = (event) => {
|
|
1572
|
+
event.stopPropagation();
|
|
1573
|
+
event.preventDefault();
|
|
1574
|
+
setAnchorEl(event.currentTarget);
|
|
1575
|
+
};
|
|
1576
|
+
const handleStartEditMode = (event) => {
|
|
1577
|
+
event.stopPropagation();
|
|
1578
|
+
setEditingRow(Object.assign({}, row));
|
|
1579
|
+
setAnchorEl(null);
|
|
1580
|
+
};
|
|
1581
|
+
return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderRowActions && !showEditActionButtons ? (renderRowActions({ cell, row, staticRowIndex, table })) : showEditActionButtons ? (jsxRuntime.jsx(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems &&
|
|
1582
|
+
parseFromValuesOrFunc(enableEditing, row) &&
|
|
1583
|
+
['modal', 'row'].includes(editDisplayMode) ? (jsxRuntime.jsx(Tooltip, { placement: "right", title: localization.edit, children: jsxRuntime.jsx(IconButton, Object.assign({ "aria-label": localization.edit, onClick: handleStartEditMode, sx: commonIconButtonStyles }, rest, { children: jsxRuntime.jsx(EditIcon, {}) })) })) : ((_b = renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
|
1584
|
+
closeMenu: () => { },
|
|
1700
1585
|
row,
|
|
1701
1586
|
staticRowIndex,
|
|
1702
1587
|
table,
|
|
1703
|
-
})
|
|
1704
|
-
: undefined;
|
|
1705
|
-
const onSelectAllChange = getMRT_SelectAllHandler({ table });
|
|
1706
|
-
const commonProps = Object.assign(Object.assign({ 'aria-label': selectAll
|
|
1707
|
-
? localization.toggleSelectAll
|
|
1708
|
-
: localization.toggleSelectRow, checked: isChecked, disabled: isLoading || (row && !row.getCanSelect()) || (row === null || row === void 0 ? void 0 : row.id) === 'mrt-row-create', inputProps: {
|
|
1709
|
-
'aria-label': selectAll
|
|
1710
|
-
? localization.toggleSelectAll
|
|
1711
|
-
: localization.toggleSelectRow,
|
|
1712
|
-
}, onChange: (event) => {
|
|
1713
|
-
event.stopPropagation();
|
|
1714
|
-
selectAll ? onSelectAllChange(event) : onSelectionChange(event);
|
|
1715
|
-
}, size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
|
|
1716
|
-
var _a;
|
|
1717
|
-
e.stopPropagation();
|
|
1718
|
-
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
|
|
1719
|
-
}, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.5rem', m: density !== 'compact' ? '-0.4rem' : undefined, width: density === 'compact' ? '1.75rem' : '2.5rem', zIndex: 0 }, parseFromValuesOrFunc(checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx, theme))), title: undefined });
|
|
1720
|
-
return (jsxRuntime.jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: (_b = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _b !== void 0 ? _b : (selectAll
|
|
1721
|
-
? localization.toggleSelectAll
|
|
1722
|
-
: localization.toggleSelectRow), children: enableMultiRowSelection === false ? (jsxRuntime.jsx(Radio, Object.assign({}, commonProps))) : (jsxRuntime.jsx(Checkbox, Object.assign({ disableRipple: true, indeterminate: !isChecked && selectAll
|
|
1723
|
-
? table.getIsSomeRowsSelected()
|
|
1724
|
-
: (row === null || row === void 0 ? void 0 : row.getIsSomeSelected()) && row.getCanSelectSubRows() }, commonProps))) })));
|
|
1588
|
+
})) === null || _b === void 0 ? void 0 : _b.length) ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.rowActions, children: jsxRuntime.jsx(IconButton, Object.assign({ "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles }, rest, { children: jsxRuntime.jsx(MoreHorizIcon, {}) })) })), jsxRuntime.jsx(MRT_RowActionMenu, { anchorEl: anchorEl, handleEdit: handleStartEditMode, row: row, setAnchorEl: setAnchorEl, staticRowIndex: staticRowIndex, table: table })] })) : null }));
|
|
1725
1589
|
};
|
|
1726
1590
|
|
|
1727
|
-
const
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
header: 'select',
|
|
1733
|
-
id: '__check__',
|
|
1734
|
-
size: enableSelectAll ? 90 : 70, // widened from 60 to accommodate both the checkbox and the menu button
|
|
1591
|
+
const getMRT_RowActionsColumnDef = (tableOptions) => {
|
|
1592
|
+
return Object.assign({ Cell: ({ cell, row, staticRowIndex, table }) => (jsxRuntime.jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, staticRowIndex: staticRowIndex, table: table })) }, defaultDisplayColumnProps({
|
|
1593
|
+
header: 'actions',
|
|
1594
|
+
id: 'mrt-row-actions',
|
|
1595
|
+
size: 70,
|
|
1735
1596
|
tableOptions,
|
|
1736
1597
|
}));
|
|
1737
1598
|
};
|
|
1738
1599
|
|
|
1739
|
-
const
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
DynamicFeedIcon,
|
|
1754
|
-
EditIcon,
|
|
1755
|
-
ExpandMoreIcon,
|
|
1756
|
-
FilterAltIcon,
|
|
1757
|
-
FilterListIcon,
|
|
1758
|
-
FilterListOffIcon,
|
|
1759
|
-
FirstPageIcon,
|
|
1760
|
-
FullscreenExitIcon,
|
|
1761
|
-
FullscreenIcon,
|
|
1762
|
-
KeyboardDoubleArrowDownIcon,
|
|
1763
|
-
LastPageIcon,
|
|
1764
|
-
MoreHorizIcon,
|
|
1765
|
-
MoreVertIcon,
|
|
1766
|
-
PushPinIcon,
|
|
1767
|
-
RestartAltIcon,
|
|
1768
|
-
SaveIcon,
|
|
1769
|
-
SearchIcon,
|
|
1770
|
-
SearchOffIcon,
|
|
1771
|
-
SortIcon,
|
|
1772
|
-
SyncAltIcon,
|
|
1773
|
-
ViewColumnIcon,
|
|
1774
|
-
VisibilityOffIcon,
|
|
1600
|
+
const MRT_GrabHandleButton = (_a) => {
|
|
1601
|
+
var _b, _c;
|
|
1602
|
+
var { location, table } = _a, rest = __rest(_a, ["location", "table"]);
|
|
1603
|
+
const { options: { icons: { DragHandleIcon }, localization, }, } = table;
|
|
1604
|
+
return (jsxRuntime.jsx(Tooltip, Object.assign({}, getCommonTooltipProps('top'), { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.move, children: jsxRuntime.jsx(IconButton, Object.assign({ "aria-label": (_c = rest.title) !== null && _c !== void 0 ? _c : localization.move, disableRipple: true, draggable: "true", size: "small" }, rest, { onClick: (e) => {
|
|
1605
|
+
var _a;
|
|
1606
|
+
e.stopPropagation();
|
|
1607
|
+
(_a = rest === null || rest === void 0 ? void 0 : rest.onClick) === null || _a === void 0 ? void 0 : _a.call(rest, e);
|
|
1608
|
+
}, sx: (theme) => (Object.assign({ '&:active': {
|
|
1609
|
+
cursor: 'grabbing',
|
|
1610
|
+
}, '&:hover': {
|
|
1611
|
+
backgroundColor: 'transparent',
|
|
1612
|
+
opacity: 1,
|
|
1613
|
+
}, cursor: 'grab', m: '0 -0.1rem', opacity: location === 'row' ? 1 : 0.5, p: '2px', transition: 'all 150ms ease-in-out' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), title: undefined, children: jsxRuntime.jsx(DragHandleIcon, {}) })) })));
|
|
1775
1614
|
};
|
|
1776
1615
|
|
|
1777
|
-
const
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
expand: 'Expand',
|
|
1803
|
-
expandAll: 'Expand all',
|
|
1804
|
-
filterArrIncludes: 'Includes',
|
|
1805
|
-
filterArrIncludesAll: 'Includes all',
|
|
1806
|
-
filterArrIncludesSome: 'Includes',
|
|
1807
|
-
filterBetween: 'Between',
|
|
1808
|
-
filterBetweenInclusive: 'Between Inclusive',
|
|
1809
|
-
filterByColumn: 'Filter by {column}',
|
|
1810
|
-
filterFrom: 'From',
|
|
1811
|
-
filterTo: 'To',
|
|
1812
|
-
filterContains: 'Contains',
|
|
1813
|
-
filterEmpty: 'Empty',
|
|
1814
|
-
filterEndsWith: 'Ends With',
|
|
1815
|
-
filterEquals: 'Equals',
|
|
1816
|
-
filterEqualsString: 'Equals',
|
|
1817
|
-
filterFuzzy: 'Fuzzy',
|
|
1818
|
-
filterGreaterThan: 'Greater Than',
|
|
1819
|
-
filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
|
|
1820
|
-
filterInArray: 'Is any of',
|
|
1821
|
-
filterIsAnyOf: 'Is any of',
|
|
1822
|
-
filterInNumberRange: 'Between',
|
|
1823
|
-
filterIncludesString: 'Contains',
|
|
1824
|
-
filterIncludesStringSensitive: 'Contains',
|
|
1825
|
-
filterLessThan: 'Less Than',
|
|
1826
|
-
filterLessThanOrEqualTo: 'Less Than Or Equal To',
|
|
1827
|
-
filterMode: 'Filter Mode: {filterType}',
|
|
1828
|
-
filterNoOptions: 'No filter options available',
|
|
1829
|
-
filterNotEmpty: 'Not Empty',
|
|
1830
|
-
filterNotEquals: 'Not Equals',
|
|
1831
|
-
filterNotContains: 'Does Not Contain',
|
|
1832
|
-
filterLogic: 'Logic',
|
|
1833
|
-
filterOperator: 'Operator',
|
|
1834
|
-
filterStartsWith: 'Starts With',
|
|
1835
|
-
filterWeakEquals: 'Equals',
|
|
1836
|
-
filterCurrentWeek: 'Current Week',
|
|
1837
|
-
filterCurrentMonth: 'Current Month',
|
|
1838
|
-
filterLast7Days: 'Last 7 Days',
|
|
1839
|
-
filterLastWeek: 'Last Week',
|
|
1840
|
-
filterLastMonth: 'Last Month',
|
|
1841
|
-
filterFromToday: 'From Today',
|
|
1842
|
-
filterToToday: 'To Today',
|
|
1843
|
-
filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
|
|
1844
|
-
goToFirstPage: 'Go to first page',
|
|
1845
|
-
goToLastPage: 'Go to last page',
|
|
1846
|
-
goToNextPage: 'Go to next page',
|
|
1847
|
-
goToPreviousPage: 'Go to previous page',
|
|
1848
|
-
grab: 'Grab',
|
|
1849
|
-
groupByColumn: 'Group by {column}',
|
|
1850
|
-
groupedBy: 'Grouped by ',
|
|
1851
|
-
hideAll: 'Hide all',
|
|
1852
|
-
hideColumn: 'Hide {column} column',
|
|
1853
|
-
max: 'Max',
|
|
1854
|
-
min: 'Min',
|
|
1855
|
-
move: 'Move',
|
|
1856
|
-
noRecordsToDisplay: 'No records to display',
|
|
1857
|
-
noResultsFound: 'No results found',
|
|
1858
|
-
moreThan: 'more than',
|
|
1859
|
-
of: 'of',
|
|
1860
|
-
or: 'or',
|
|
1861
|
-
pin: 'Pin',
|
|
1862
|
-
pinToLeft: 'Pin to left',
|
|
1863
|
-
pinToRight: 'Pin to right',
|
|
1864
|
-
resetColumnSize: 'Reset column size',
|
|
1865
|
-
resetOrder: 'Reset order',
|
|
1866
|
-
rowActions: 'Row Actions',
|
|
1867
|
-
rowNumber: '#',
|
|
1868
|
-
rowNumbers: 'Row Numbers',
|
|
1869
|
-
rowsPerPage: 'Rows per page',
|
|
1870
|
-
countRows: 'Count Rows',
|
|
1871
|
-
countRowsTooltip: 'Count total rows for current filters',
|
|
1872
|
-
rowCount: 'Row Count',
|
|
1873
|
-
rowsSelected: '{count} row(s) selected',
|
|
1874
|
-
save: 'Save',
|
|
1875
|
-
search: 'Search',
|
|
1876
|
-
selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
|
|
1877
|
-
select: 'Select',
|
|
1878
|
-
selectAllOnAllPages: 'Select all on all pages',
|
|
1879
|
-
selectAllOnCurrentPage: 'Select all on current page',
|
|
1880
|
-
showAll: 'Show all',
|
|
1881
|
-
showAllColumns: 'Show all columns',
|
|
1882
|
-
showHideColumns: 'Columns',
|
|
1883
|
-
showHideFilters: 'Show/Hide filters',
|
|
1884
|
-
showHideSearch: 'Show/Hide search',
|
|
1885
|
-
showAdvancedFilters: 'Show advanced filters',
|
|
1886
|
-
advancedFilters: 'Advanced Filters',
|
|
1887
|
-
filters: 'Filters',
|
|
1888
|
-
add: 'Add',
|
|
1889
|
-
newEntry: 'New Entry',
|
|
1890
|
-
clear: 'Clear',
|
|
1891
|
-
discardChanges: 'Discard changes',
|
|
1892
|
-
saveFilters: 'Save filters',
|
|
1893
|
-
savedFilters: 'Saved filters',
|
|
1894
|
-
noSavedFilters: 'No saved filters',
|
|
1895
|
-
filterName: 'Filter name',
|
|
1896
|
-
apply: 'Apply',
|
|
1897
|
-
sortByColumnAsc: 'Sort by {column} ascending',
|
|
1898
|
-
sortByColumnDesc: 'Sort by {column} descending',
|
|
1899
|
-
sortedByColumnAsc: 'Sorted by {column} ascending',
|
|
1900
|
-
sortedByColumnDesc: 'Sorted by {column} descending',
|
|
1901
|
-
thenBy: ', then by ',
|
|
1902
|
-
toggleDensity: 'Density',
|
|
1903
|
-
densityCompact: 'Compact',
|
|
1904
|
-
densityStandard: 'Standard',
|
|
1905
|
-
densityComfortable: 'Comfortable',
|
|
1906
|
-
toggleFullScreen: 'Toggle full screen',
|
|
1907
|
-
toggleSelectAll: 'Toggle select all',
|
|
1908
|
-
toggleSelectRow: 'Toggle select row',
|
|
1909
|
-
toggleVisibility: 'Toggle visibility',
|
|
1910
|
-
ungroupByColumn: 'Ungroup by {column}',
|
|
1911
|
-
unpin: 'Unpin',
|
|
1912
|
-
unpinAll: 'Unpin all',
|
|
1913
|
-
dimensionRotationEnabled: 'Rotation enabled',
|
|
1914
|
-
dimensionRotationDisabled: 'Rotation disabled',
|
|
1915
|
-
length: 'Length',
|
|
1916
|
-
width: 'Width',
|
|
1917
|
-
height: 'Height',
|
|
1918
|
-
depth: 'Depth',
|
|
1919
|
-
tolerance: 'Tolerance',
|
|
1920
|
-
exportButton: 'Export',
|
|
1921
|
-
exportSelectRowsTooltip: 'Select rows to export',
|
|
1922
|
-
exportPrintPdf: 'Print PDF',
|
|
1923
|
-
exportDownload: 'Download',
|
|
1924
|
-
exportGrouped: 'Group files',
|
|
1925
|
-
exportInProgress: 'Export in progress...',
|
|
1926
|
-
exportSuccess: 'Export completed successfully.',
|
|
1927
|
-
exportError: 'Export failed. Please try again.',
|
|
1928
|
-
exportNoExportsSelected: 'No export type selected. Please configure the export first.',
|
|
1929
|
-
deleteConfirmationTitle: 'Delete Row',
|
|
1930
|
-
deleteConfirmationMessage: 'Are you sure you want to delete the selected row(s)?',
|
|
1931
|
-
deleteConfirmYes: 'Delete',
|
|
1932
|
-
deleteConfirmNo: 'Cancel',
|
|
1933
|
-
deleteConfirmDeleting: 'Deleting...',
|
|
1934
|
-
errorTitle: 'Unexpected error',
|
|
1935
|
-
errorMessage: 'An unexpected error occurred. Please try again.',
|
|
1936
|
-
serverTableErrorTitle: 'Unable to load table',
|
|
1937
|
-
serverTableErrorMessage: 'Something went wrong while loading the table configuration. Please try again.',
|
|
1938
|
-
serverTableErrorRetry: 'Try again',
|
|
1939
|
-
resetState: 'Reset State',
|
|
1940
|
-
tableOptions: 'Options',
|
|
1616
|
+
const MRT_TableBodyRowGrabHandle = (_a) => {
|
|
1617
|
+
var { row, rowRef, table } = _a, rest = __rest(_a, ["row", "rowRef", "table"]);
|
|
1618
|
+
const { options: { muiRowDragHandleProps }, } = table;
|
|
1619
|
+
const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiRowDragHandleProps, {
|
|
1620
|
+
row,
|
|
1621
|
+
table,
|
|
1622
|
+
})), rest);
|
|
1623
|
+
const handleDragStart = (event) => {
|
|
1624
|
+
var _a;
|
|
1625
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
1626
|
+
try {
|
|
1627
|
+
event.dataTransfer.setDragImage(rowRef.current, 0, 0);
|
|
1628
|
+
}
|
|
1629
|
+
catch (e) {
|
|
1630
|
+
console.error(e);
|
|
1631
|
+
}
|
|
1632
|
+
table.setDraggingRow(row);
|
|
1633
|
+
};
|
|
1634
|
+
const handleDragEnd = (event) => {
|
|
1635
|
+
var _a;
|
|
1636
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
1637
|
+
table.setDraggingRow(null);
|
|
1638
|
+
table.setHoveredRow(null);
|
|
1639
|
+
};
|
|
1640
|
+
return (jsxRuntime.jsx(MRT_GrabHandleButton, Object.assign({}, iconButtonProps, { location: "row", onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })));
|
|
1941
1641
|
};
|
|
1942
1642
|
|
|
1943
|
-
const
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
}
|
|
1951
|
-
const blob = new Blob([bytes], { type: 'application/octet-stream' });
|
|
1952
|
-
const element = document.createElement('a');
|
|
1953
|
-
element.href = URL.createObjectURL(blob);
|
|
1954
|
-
element.download = file.filename;
|
|
1955
|
-
document.body.appendChild(element);
|
|
1956
|
-
element.click();
|
|
1957
|
-
document.body.removeChild(element);
|
|
1958
|
-
URL.revokeObjectURL(element.href);
|
|
1959
|
-
});
|
|
1643
|
+
const getMRT_RowDragColumnDef = (tableOptions) => {
|
|
1644
|
+
return Object.assign({ Cell: ({ row, rowRef, table }) => (jsxRuntime.jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })), grow: false }, defaultDisplayColumnProps({
|
|
1645
|
+
header: 'move',
|
|
1646
|
+
id: 'mrt-row-drag',
|
|
1647
|
+
size: 60,
|
|
1648
|
+
tableOptions,
|
|
1649
|
+
}));
|
|
1960
1650
|
};
|
|
1961
1651
|
|
|
1962
|
-
const
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
});
|
|
1977
|
-
});
|
|
1652
|
+
const MRT_ExpandAllButton = (_a) => {
|
|
1653
|
+
var _b, _c;
|
|
1654
|
+
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
1655
|
+
const { getCanSomeRowsExpand, getIsAllRowsExpanded, getIsSomeRowsExpanded, getState, options: { icons: { KeyboardDoubleArrowDownIcon }, localization, muiExpandAllButtonProps, renderDetailPanel, }, toggleAllRowsExpanded, } = table;
|
|
1656
|
+
const { isLoading } = getState();
|
|
1657
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
1658
|
+
const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiExpandAllButtonProps, {
|
|
1659
|
+
table,
|
|
1660
|
+
})), rest);
|
|
1661
|
+
const isAllRowsExpanded = getIsAllRowsExpanded();
|
|
1662
|
+
return (jsxRuntime.jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _b !== void 0 ? _b : (isAllRowsExpanded ? localization.collapseAll : localization.expandAll), children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton, Object.assign({ "aria-label": localization.expandAll, disabled: isLoading || (!renderDetailPanel && !getCanSomeRowsExpand()), onClick: () => toggleAllRowsExpanded(!isAllRowsExpanded) }, iconButtonProps, { sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.25rem', mt: density !== 'compact' ? '-0.25rem' : undefined, width: density === 'compact' ? '1.75rem' : '2.25rem' }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), title: undefined, children: (_c = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _c !== void 0 ? _c : (jsxRuntime.jsx(KeyboardDoubleArrowDownIcon, { style: {
|
|
1663
|
+
transform: `rotate(${isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0}deg)`,
|
|
1664
|
+
transition: 'transform 150ms',
|
|
1665
|
+
} })) })) }) })));
|
|
1978
1666
|
};
|
|
1979
1667
|
|
|
1980
|
-
const
|
|
1668
|
+
const MRT_ExpandButton = ({ row, staticRowIndex, table, }) => {
|
|
1669
|
+
var _a, _b;
|
|
1981
1670
|
const theme = styles.useTheme();
|
|
1982
|
-
const { localization } = table
|
|
1983
|
-
const
|
|
1984
|
-
const
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
const isNoRowsSelected = selectedRowIds.length === 0;
|
|
1989
|
-
const availableFormats = react.useMemo(() => {
|
|
1990
|
-
const allFormats = Object.values(availableExports).flatMap((exp) => exp.formats);
|
|
1991
|
-
return Array.from(new Set(allFormats));
|
|
1992
|
-
}, [availableExports]);
|
|
1993
|
-
const hasPdfFormat = availableFormats.includes('pdf');
|
|
1994
|
-
const exportTypesForSelectedFormat = react.useMemo(() => {
|
|
1995
|
-
if (!selectedFormat)
|
|
1996
|
-
return [];
|
|
1997
|
-
return Object.values(availableExports).filter((exp) => exp.formats.includes(selectedFormat));
|
|
1998
|
-
}, [availableExports, selectedFormat]);
|
|
1999
|
-
const isPrintDisabled = selectedFormat !== 'pdf' ||
|
|
2000
|
-
!selectedFormat ||
|
|
2001
|
-
selectedExports.length < 1 ||
|
|
2002
|
-
(!grouped && selectedExports.length > 1);
|
|
2003
|
-
const isDownloadDisabled = !selectedFormat || selectedExports.length < 1;
|
|
2004
|
-
const handleOpenMenu = (event) => {
|
|
2005
|
-
setAnchorEl(event.currentTarget);
|
|
2006
|
-
};
|
|
2007
|
-
const handleCloseMenu = () => {
|
|
2008
|
-
setAnchorEl(null);
|
|
2009
|
-
};
|
|
2010
|
-
const handleSelectFormat = (format) => {
|
|
2011
|
-
const newFormat = selectedFormat === format ? null : format;
|
|
2012
|
-
onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { grouped: false })), { selectedExports: [], selectedFormat: newFormat })));
|
|
2013
|
-
};
|
|
2014
|
-
const handleToggleExportType = (exportName) => {
|
|
2015
|
-
const isAlreadySelected = selectedExports.includes(exportName);
|
|
2016
|
-
const newSelectedExports = isAlreadySelected
|
|
2017
|
-
? selectedExports.filter((name) => name !== exportName)
|
|
2018
|
-
: [...selectedExports, exportName];
|
|
2019
|
-
onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { selectedFormat: null, grouped: false })), { selectedExports: newSelectedExports })));
|
|
2020
|
-
};
|
|
2021
|
-
const handleToggleGrouped = () => {
|
|
2022
|
-
onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { selectedFormat: null, selectedExports: [] })), { grouped: !grouped })));
|
|
2023
|
-
};
|
|
2024
|
-
const handleExportAction = (type) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2025
|
-
setLoadingExportType(type);
|
|
2026
|
-
try {
|
|
2027
|
-
const response = yield loadExport({
|
|
2028
|
-
format: selectedFormat,
|
|
2029
|
-
exports: selectedExports,
|
|
2030
|
-
separated_files: !grouped,
|
|
2031
|
-
download: false,
|
|
2032
|
-
ids: JSON.stringify(selectedRowIds),
|
|
2033
|
-
type,
|
|
2034
|
-
});
|
|
2035
|
-
handleCloseMenu();
|
|
2036
|
-
if (type === 'download') {
|
|
2037
|
-
downloadExportFiles(response);
|
|
2038
|
-
}
|
|
2039
|
-
else {
|
|
2040
|
-
printExportFiles(response);
|
|
2041
|
-
}
|
|
2042
|
-
}
|
|
2043
|
-
finally {
|
|
2044
|
-
setLoadingExportType(null);
|
|
2045
|
-
}
|
|
1671
|
+
const { options: { icons: { ExpandMoreIcon }, localization, maxDepth, muiExpandButtonProps, positionExpandColumn, renderDetailPanel, }, } = table;
|
|
1672
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
1673
|
+
const iconButtonProps = parseFromValuesOrFunc(muiExpandButtonProps, {
|
|
1674
|
+
row,
|
|
1675
|
+
staticRowIndex,
|
|
1676
|
+
table,
|
|
2046
1677
|
});
|
|
2047
|
-
const
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
return null;
|
|
2055
|
-
return (jsxRuntime.jsx(Stack, { minWidth: "250px", maxHeight: "500px", sx: { overflowY: 'auto' }, children: exportTypesForSelectedFormat.map((exportType) => (jsxRuntime.jsxs(MenuItem, { onClick: () => handleToggleExportType(exportType.name), value: exportType.name, children: [jsxRuntime.jsx(Checkbox, { checked: selectedExports.includes(exportType.name), size: "small" }), jsxRuntime.jsx(Typography, { variant: "body2", children: exportType.label })] }, exportType.name))) }));
|
|
2056
|
-
};
|
|
2057
|
-
const renderActionButtons = () => {
|
|
2058
|
-
const isAnyLoading = loadingExportType !== null;
|
|
2059
|
-
return (jsxRuntime.jsxs(Stack, { direction: "row", gap: 0.5, mt: 1, mr: 2, children: [hasPdfFormat && (jsxRuntime.jsx(Button, { sx: { display: 'flex', gap: 0.5 }, disabled: isPrintDisabled || isAnyLoading, onClick: () => handleExportAction('print'), startIcon: loadingExportType === 'print' ? (jsxRuntime.jsx(CircularProgress, { size: 16, color: "inherit" })) : (jsxRuntime.jsx(PrintIcon, { fontSize: "small" })), children: localization.exportPrintPdf })), jsxRuntime.jsx(Button, { sx: { display: 'flex', gap: 0.5 }, disabled: isDownloadDisabled || isAnyLoading, onClick: () => handleExportAction('download'), startIcon: loadingExportType === 'download' ? (jsxRuntime.jsx(CircularProgress, { size: 16, color: "inherit" })) : (jsxRuntime.jsx(FileDownloadIcon, { fontSize: "small" })), children: localization.exportDownload })] }));
|
|
1678
|
+
const canExpand = row.getCanExpand() && (maxDepth === undefined || row.depth < maxDepth - 1);
|
|
1679
|
+
const isExpanded = row.getIsExpanded();
|
|
1680
|
+
const handleToggleExpand = (event) => {
|
|
1681
|
+
var _a;
|
|
1682
|
+
event.stopPropagation();
|
|
1683
|
+
row.toggleExpanded();
|
|
1684
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
2060
1685
|
};
|
|
2061
|
-
const
|
|
2062
|
-
return (jsxRuntime.
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
1686
|
+
const detailPanel = !!(renderDetailPanel === null || renderDetailPanel === void 0 ? void 0 : renderDetailPanel({ row, table }));
|
|
1687
|
+
return (jsxRuntime.jsx(Tooltip, Object.assign({ disableHoverListener: !canExpand && !detailPanel }, getCommonTooltipProps(), { title: (_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.title) !== null && _a !== void 0 ? _a : (isExpanded ? localization.collapse : localization.expand), children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton, Object.assign({ "aria-label": localization.expand, disabled: !canExpand && !detailPanel }, iconButtonProps, { onClick: handleToggleExpand, sx: (theme) => (Object.assign({ opacity: !canExpand && !detailPanel ? 0.3 : 1, [theme.direction === 'rtl' || positionExpandColumn === 'last'
|
|
1688
|
+
? 'mr'
|
|
1689
|
+
: 'ml']: `${row.depth * 16}px`, width: density === 'compact' ? '1.75rem' : '2.25rem' }, parseFromValuesOrFunc(iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.sx, theme))), size: "small", title: undefined, children: (_b = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.children) !== null && _b !== void 0 ? _b : (jsxRuntime.jsx(ExpandMoreIcon, { style: {
|
|
1690
|
+
transform: `rotate(${!canExpand && !renderDetailPanel
|
|
1691
|
+
? positionExpandColumn === 'last' ||
|
|
1692
|
+
theme.direction === 'rtl'
|
|
1693
|
+
? 90
|
|
1694
|
+
: -90
|
|
1695
|
+
: isExpanded
|
|
1696
|
+
? -180
|
|
1697
|
+
: 0}deg)`,
|
|
1698
|
+
transition: 'transform 150ms',
|
|
1699
|
+
} })) })) }) })));
|
|
2067
1700
|
};
|
|
2068
1701
|
|
|
2069
|
-
const
|
|
2070
|
-
|
|
1702
|
+
const INSERT_HERE_TOOLTIP = 'Insert here';
|
|
1703
|
+
const ACTION_ICON_SIZE$1 = 'small';
|
|
1704
|
+
const MRT_InsertHereAction = ({ onClick, }) => {
|
|
1705
|
+
return (jsxRuntime.jsx(Tooltip, { title: INSERT_HERE_TOOLTIP, disableInteractive: true, children: jsxRuntime.jsx(IconButton, { onClick: onClick, size: ACTION_ICON_SIZE$1, children: jsxRuntime.jsx(SubdirectoryArrowLeftIcon, { color: "warning" }) }) }));
|
|
2071
1706
|
};
|
|
2072
1707
|
|
|
2073
|
-
const
|
|
2074
|
-
|
|
1708
|
+
const MOVE_TO_TOP_TOOLTIP = 'Move to top level';
|
|
1709
|
+
const ACTION_ICON_SIZE = 'small';
|
|
1710
|
+
const ACTION_BUTTON_HEIGHT = '1.75rem';
|
|
1711
|
+
const MRT_MoveToTopAction = ({ onClick }) => {
|
|
1712
|
+
return (jsxRuntime.jsx(Tooltip, { title: MOVE_TO_TOP_TOOLTIP, disableInteractive: true, children: jsxRuntime.jsx(IconButton, { onClick: onClick, size: ACTION_ICON_SIZE, sx: { height: ACTION_BUTTON_HEIGHT }, children: jsxRuntime.jsx(VerticalAlignTopIcon, { fontSize: "small" }) }) }));
|
|
2075
1713
|
};
|
|
2076
1714
|
|
|
2077
|
-
const
|
|
2078
|
-
return (jsxRuntime.
|
|
1715
|
+
const MRT_ReorderRowCheckbox = ({ onChange, isSelected, }) => {
|
|
1716
|
+
return (jsxRuntime.jsx(Checkbox, { checked: isSelected, color: "warning", disableRipple: true, onChange: onChange, sx: {
|
|
1717
|
+
color: (theme) => theme.palette.warning.main,
|
|
1718
|
+
'&.Mui-checked': {
|
|
1719
|
+
color: (theme) => theme.palette.warning.main,
|
|
1720
|
+
},
|
|
1721
|
+
} }));
|
|
2079
1722
|
};
|
|
2080
1723
|
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
const isPrintAvailable = (table) => {
|
|
1724
|
+
/**
|
|
1725
|
+
* Finds the maximum depth in the hierarchy of a given row (recursively searches all descendants).
|
|
1726
|
+
* Used to determine the "size" of the tree being moved.
|
|
1727
|
+
* Example: Row at depth 1 with a child at depth 3 → returns 3
|
|
1728
|
+
*/
|
|
1729
|
+
const getDeepestSubRowDepth = (row) => {
|
|
2088
1730
|
var _a;
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
1731
|
+
if (!((_a = row.subRows) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
1732
|
+
return row.depth;
|
|
1733
|
+
}
|
|
1734
|
+
return row.subRows.reduce((maxDepth, subRow) => Math.max(maxDepth, getDeepestSubRowDepth(subRow)), row.depth);
|
|
1735
|
+
};
|
|
1736
|
+
/**
|
|
1737
|
+
* Extracts an array of IDs of only the selected rows from the selection object.
|
|
1738
|
+
* Filters the record where the value is true and maps only the keys (IDs).
|
|
1739
|
+
* Example: { row1: true, row2: false, row3: true } → ['row1', 'row3']
|
|
1740
|
+
*/
|
|
1741
|
+
const getSelectedReorderRowIds = (rowReorderingSelection) => {
|
|
1742
|
+
return Object.entries(rowReorderingSelection !== null && rowReorderingSelection !== void 0 ? rowReorderingSelection : {})
|
|
1743
|
+
.filter(([, isSelected]) => isSelected)
|
|
1744
|
+
.map(([rowId]) => rowId);
|
|
1745
|
+
};
|
|
1746
|
+
/**
|
|
1747
|
+
* Checks WHETHER we can move selected rows as children of target row
|
|
1748
|
+
* without exceeding the maximum allowed depth.
|
|
1749
|
+
* Directly calculates the final maximum depth after the move.
|
|
1750
|
+
* Example: selectedRows at depth 1-2 with descendants to depth 4, target depth 1, maxDepth 5
|
|
1751
|
+
* → new max depth = 1 + 1 + (4 - 1) = 5, which equals maxDepth, so returns false
|
|
1752
|
+
*/
|
|
1753
|
+
const canInsertSelectedRowsWithoutExceedingMaxDepth = ({ maxDepth, selectedRows, targetRowDepth, }) => {
|
|
1754
|
+
// Cannot insert if there are no selected rows to move
|
|
1755
|
+
if (selectedRows.length === 0) {
|
|
2094
1756
|
return false;
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
1757
|
+
}
|
|
1758
|
+
// No depth restriction - can insert anywhere
|
|
1759
|
+
if (maxDepth === undefined) {
|
|
1760
|
+
return true;
|
|
1761
|
+
}
|
|
1762
|
+
// Find the deepest descendant among all selected rows
|
|
1763
|
+
const maxDeepestDescendantDepth = selectedRows.reduce((max, row) => {
|
|
1764
|
+
return Math.max(max, getDeepestSubRowDepth(row));
|
|
1765
|
+
}, 0);
|
|
1766
|
+
// Find the minimum depth of selected rows (to calculate relative depth)
|
|
1767
|
+
const minSelectedRowDepth = Math.min(...selectedRows.map((r) => r.depth));
|
|
1768
|
+
// Calculate the maximum depth after moving rows as children of target
|
|
1769
|
+
// newMaxDepth = target.depth + 1 (as children) + relative depth of selected rows
|
|
1770
|
+
const newMaxDepth = targetRowDepth + 1 + (maxDeepestDescendantDepth - minSelectedRowDepth);
|
|
1771
|
+
return newMaxDepth < maxDepth;
|
|
2099
1772
|
};
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
1773
|
+
/**
|
|
1774
|
+
* Finds the depth of the FIRST selected row in the selection object.
|
|
1775
|
+
* Used to enforce constraint: can only select rows at the SAME depth.
|
|
1776
|
+
* Example: If I select a row at depth 2, I cannot select a row at depth 3
|
|
1777
|
+
*/
|
|
1778
|
+
const getFirstSelectedReorderRowDepth = ({ rowReorderingSelection, table, }) => {
|
|
1779
|
+
var _a, _b;
|
|
1780
|
+
const firstSelectedRowId = (_a = Object.entries(rowReorderingSelection !== null && rowReorderingSelection !== void 0 ? rowReorderingSelection : {}).find(([, isSelected]) => isSelected)) === null || _a === void 0 ? void 0 : _a[0];
|
|
1781
|
+
if (!firstSelectedRowId) {
|
|
1782
|
+
return undefined;
|
|
1783
|
+
}
|
|
1784
|
+
return (_b = table.getRow(firstSelectedRowId, true)) === null || _b === void 0 ? void 0 : _b.depth;
|
|
1785
|
+
};
|
|
1786
|
+
/**
|
|
1787
|
+
* Checks WHETHER we can select a specific row.
|
|
1788
|
+
* Rule: If a selection already exists, new row MUST be at the SAME depth as the first selected.
|
|
1789
|
+
* Without this, you could move rows from different levels which would break the hierarchy.
|
|
1790
|
+
*/
|
|
1791
|
+
const canSelectRowForReorder = ({ rowId, rowDepth, rowReorderingSelection, firstSelectedReorderRowDepth, }) => {
|
|
1792
|
+
const isCurrentRowSelected = !!(rowReorderingSelection === null || rowReorderingSelection === void 0 ? void 0 : rowReorderingSelection[rowId]);
|
|
1793
|
+
if (isCurrentRowSelected) {
|
|
1794
|
+
return true;
|
|
1795
|
+
}
|
|
1796
|
+
const hasAnySelection = Object.values(rowReorderingSelection !== null && rowReorderingSelection !== void 0 ? rowReorderingSelection : {}).some(Boolean);
|
|
1797
|
+
if (!hasAnySelection) {
|
|
1798
|
+
return true;
|
|
1799
|
+
}
|
|
1800
|
+
return rowDepth === firstSelectedReorderRowDepth;
|
|
1801
|
+
};
|
|
1802
|
+
/**
|
|
1803
|
+
* Creates an array of MRT_Row objects from an array of IDs.
|
|
1804
|
+
* Finds each row from the table and collects it in the result.
|
|
1805
|
+
* Used to prepare data for the onTreeRowReorder callback.
|
|
1806
|
+
*/
|
|
1807
|
+
const buildSelectedRowsArray = (selectedRowIds, table) => {
|
|
1808
|
+
return selectedRowIds.reduce((selectedRows, selectedRowId) => {
|
|
1809
|
+
const selectedRow = table.getRow(selectedRowId, true);
|
|
1810
|
+
if (selectedRow) {
|
|
1811
|
+
selectedRows.push(selectedRow);
|
|
1812
|
+
}
|
|
1813
|
+
return selectedRows;
|
|
1814
|
+
}, []);
|
|
1815
|
+
};
|
|
1816
|
+
/**
|
|
1817
|
+
* Helper function to check if a row is a descendant of another row.
|
|
1818
|
+
* Recursively searches through all subRows to find if targetRowId exists.
|
|
1819
|
+
* Used to prevent circular references (parent cannot become child of its own child).
|
|
1820
|
+
*/
|
|
1821
|
+
const isRowInSubtreeOf = (targetRowId, parentRow) => {
|
|
1822
|
+
var _a;
|
|
1823
|
+
if (!((_a = parentRow.subRows) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
1824
|
+
return false;
|
|
1825
|
+
}
|
|
1826
|
+
for (const subRow of parentRow.subRows) {
|
|
1827
|
+
if (subRow.id === targetRowId) {
|
|
1828
|
+
return true;
|
|
1829
|
+
}
|
|
1830
|
+
if (isRowInSubtreeOf(targetRowId, subRow)) {
|
|
1831
|
+
return true;
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
return false;
|
|
1835
|
+
};
|
|
1836
|
+
/**
|
|
1837
|
+
* Checks if a row can be used as a valid insert target for selected rows.
|
|
1838
|
+
* Rules: Target row must NOT be already selected AND must NOT be a descendant of any selected row.
|
|
1839
|
+
* This prevents circular references where a parent becomes a child of its own descendants.
|
|
1840
|
+
* Example: If you select "Department", you cannot insert it under "Project" (which is its descendant)
|
|
1841
|
+
*/
|
|
1842
|
+
const isValidInsertTarget = ({ targetRowId, selectedRowIds, table, }) => {
|
|
1843
|
+
// Rule 1: Target row cannot be already selected
|
|
1844
|
+
if (selectedRowIds.includes(targetRowId) || selectedRowIds.length === 0) {
|
|
1845
|
+
return false;
|
|
1846
|
+
}
|
|
1847
|
+
// Rule 2: Target row cannot be a descendant of any selected row
|
|
1848
|
+
// (prevents parent from becoming child of its own descendants)
|
|
1849
|
+
for (const selectedRowId of selectedRowIds) {
|
|
1850
|
+
const selectedRow = table.getRow(selectedRowId, true);
|
|
1851
|
+
if (selectedRow &&
|
|
1852
|
+
isRowInSubtreeOf(targetRowId, selectedRow)) {
|
|
1853
|
+
return false;
|
|
1854
|
+
}
|
|
1855
|
+
}
|
|
1856
|
+
return true;
|
|
1857
|
+
};
|
|
1858
|
+
|
|
1859
|
+
const useTreeRowReorderingCell = ({ row, table, rowReorderingSelection, maxDepth, onTreeRowReorder, }) => {
|
|
1860
|
+
const [isRowHovered, setIsRowHovered] = react.useState(false);
|
|
1861
|
+
const firstSelectedReorderRowDepth = getFirstSelectedReorderRowDepth({
|
|
1862
|
+
rowReorderingSelection,
|
|
1863
|
+
table,
|
|
2119
1864
|
});
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
const { activeExports } = table.getState();
|
|
2126
|
-
if (!loadExport || !activeExports)
|
|
2127
|
-
return;
|
|
2128
|
-
const response = yield loadExport({
|
|
2129
|
-
format: activeExports.selectedFormat,
|
|
2130
|
-
exports: activeExports.selectedExports,
|
|
2131
|
-
separated_files: !activeExports.grouped,
|
|
2132
|
-
download: false,
|
|
2133
|
-
ids: JSON.stringify(rowsToExport.map((r) => r.id)),
|
|
2134
|
-
type: 'print',
|
|
2135
|
-
});
|
|
2136
|
-
printExportFiles(response);
|
|
1865
|
+
const canSelectForReorder = canSelectRowForReorder({
|
|
1866
|
+
rowId: row.id,
|
|
1867
|
+
rowDepth: row.depth,
|
|
1868
|
+
rowReorderingSelection,
|
|
1869
|
+
firstSelectedReorderRowDepth,
|
|
2137
1870
|
});
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
const
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
1871
|
+
const hasAnyReorderSelection = Object.values(rowReorderingSelection !== null && rowReorderingSelection !== void 0 ? rowReorderingSelection : {}).some(Boolean);
|
|
1872
|
+
const selectedReorderRowIds = getSelectedReorderRowIds(rowReorderingSelection);
|
|
1873
|
+
const selectedRowsForReorder = buildSelectedRowsArray(selectedReorderRowIds, table);
|
|
1874
|
+
const shouldShowReorderCheckbox = canSelectForReorder && (isRowHovered || hasAnyReorderSelection);
|
|
1875
|
+
const shouldShowInsertHereAction = selectedReorderRowIds.length > 0 &&
|
|
1876
|
+
isValidInsertTarget({
|
|
1877
|
+
targetRowId: row.id,
|
|
1878
|
+
selectedRowIds: selectedReorderRowIds,
|
|
1879
|
+
table,
|
|
1880
|
+
}) &&
|
|
1881
|
+
canInsertSelectedRowsWithoutExceedingMaxDepth({
|
|
1882
|
+
maxDepth,
|
|
1883
|
+
selectedRows: selectedRowsForReorder,
|
|
1884
|
+
targetRowDepth: row.depth,
|
|
1885
|
+
});
|
|
1886
|
+
const handleReorderCheckboxChange = react.useCallback((event) => {
|
|
1887
|
+
const checked = event.target.checked;
|
|
1888
|
+
table.setRowReorderingSelection((prev) => (Object.assign(Object.assign({}, prev), { [row.id]: checked })));
|
|
1889
|
+
}, [row.id, table]);
|
|
1890
|
+
const handleInsertHereActionClick = react.useCallback(() => {
|
|
1891
|
+
if (!onTreeRowReorder) {
|
|
1892
|
+
console.warn('[MRT] onTreeRowReorder callback is not defined');
|
|
2154
1893
|
return;
|
|
2155
1894
|
}
|
|
2156
|
-
const loadingKey = notistack.enqueueSnackbar(localization.exportInProgress, {
|
|
2157
|
-
variant: 'info',
|
|
2158
|
-
persist: true,
|
|
2159
|
-
});
|
|
2160
1895
|
try {
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
1896
|
+
const treeRowReorderEvent = {
|
|
1897
|
+
selectedRowIds: selectedReorderRowIds,
|
|
1898
|
+
selectedRows: selectedRowsForReorder,
|
|
1899
|
+
table,
|
|
1900
|
+
targetRow: row,
|
|
1901
|
+
};
|
|
1902
|
+
onTreeRowReorder(treeRowReorderEvent);
|
|
2164
1903
|
}
|
|
2165
|
-
catch (
|
|
2166
|
-
|
|
2167
|
-
notistack.enqueueSnackbar(localization.exportError, { variant: 'error' });
|
|
1904
|
+
catch (error) {
|
|
1905
|
+
console.error('[MRT] Error during tree row reorder:', error);
|
|
2168
1906
|
}
|
|
2169
|
-
}
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
1907
|
+
}, [
|
|
1908
|
+
onTreeRowReorder,
|
|
1909
|
+
selectedReorderRowIds,
|
|
1910
|
+
selectedRowsForReorder,
|
|
1911
|
+
table,
|
|
1912
|
+
row,
|
|
1913
|
+
]);
|
|
1914
|
+
return {
|
|
1915
|
+
isRowHovered,
|
|
1916
|
+
shouldShowReorderCheckbox,
|
|
1917
|
+
shouldShowInsertHereAction,
|
|
1918
|
+
handleRowHoverEnter: () => setIsRowHovered(true),
|
|
1919
|
+
handleRowHoverLeave: () => setIsRowHovered(false),
|
|
1920
|
+
handleReorderCheckboxChange,
|
|
1921
|
+
handleInsertHereActionClick,
|
|
1922
|
+
isReorderCheckboxSelected: !!(rowReorderingSelection === null || rowReorderingSelection === void 0 ? void 0 : rowReorderingSelection[row.id]),
|
|
1923
|
+
};
|
|
1924
|
+
};
|
|
1925
|
+
|
|
1926
|
+
const useTreeRowReorderingHeader = ({ table, enableRowReordering, onTreeRowReorder, }) => {
|
|
1927
|
+
const rowReorderingSelection = useMRT_SliceValue(table._uiStore, (s) => s.rowReorderingSelection);
|
|
1928
|
+
const selectedReorderRowIds = getSelectedReorderRowIds(rowReorderingSelection);
|
|
1929
|
+
const selectedRowsForReorder = buildSelectedRowsArray(selectedReorderRowIds, table);
|
|
1930
|
+
const shouldShowMoveToTopLevelAction = !!enableRowReordering &&
|
|
1931
|
+
selectedRowsForReorder.length > 0 &&
|
|
1932
|
+
selectedRowsForReorder.some((selectedRow) => selectedRow.depth > 0);
|
|
1933
|
+
const handleMoveToTopLevelActionClick = react.useCallback(() => {
|
|
1934
|
+
if (!onTreeRowReorder) {
|
|
1935
|
+
console.warn('[MRT] onTreeRowReorder callback is not defined');
|
|
2177
1936
|
return;
|
|
2178
1937
|
}
|
|
2179
|
-
const loadingKey = notistack.enqueueSnackbar(localization.exportInProgress, {
|
|
2180
|
-
variant: 'info',
|
|
2181
|
-
persist: true,
|
|
2182
|
-
});
|
|
2183
1938
|
try {
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
1939
|
+
const treeRowReorderEvent = {
|
|
1940
|
+
selectedRowIds: selectedReorderRowIds,
|
|
1941
|
+
selectedRows: selectedRowsForReorder,
|
|
1942
|
+
table,
|
|
1943
|
+
targetRow: null,
|
|
1944
|
+
};
|
|
1945
|
+
onTreeRowReorder(treeRowReorderEvent);
|
|
2187
1946
|
}
|
|
2188
|
-
catch (
|
|
2189
|
-
|
|
2190
|
-
notistack.enqueueSnackbar(localization.exportError, { variant: 'error' });
|
|
1947
|
+
catch (error) {
|
|
1948
|
+
console.error('[MRT] Error during tree row reorder to top level:', error);
|
|
2191
1949
|
}
|
|
2192
|
-
});
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
return executeExport({ table, rowsToExport });
|
|
2197
|
-
};
|
|
2198
|
-
const createRowExportExecutor = (context) => () => {
|
|
2199
|
-
void handleSingleRowExport(context);
|
|
2200
|
-
};
|
|
2201
|
-
const createRowPrintExecutor = (context) => () => {
|
|
2202
|
-
void handleSingleRowPrint(context);
|
|
2203
|
-
};
|
|
2204
|
-
const createToolbarExportExecutor = (context) => () => {
|
|
2205
|
-
void handleMultipleRowExport(context);
|
|
1950
|
+
}, [onTreeRowReorder, selectedReorderRowIds, selectedRowsForReorder, table]);
|
|
1951
|
+
return {
|
|
1952
|
+
shouldShowMoveToTopLevelAction,
|
|
1953
|
+
handleMoveToTopLevelActionClick,
|
|
2206
1954
|
};
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
1955
|
+
};
|
|
1956
|
+
|
|
1957
|
+
const TREE_REORDER_ICON_SPACING = '0.25rem';
|
|
1958
|
+
const getMRT_RowExpandColumnDef = (tableOptions) => {
|
|
1959
|
+
var _a;
|
|
1960
|
+
const { defaultColumn, enableRowReordering, enableExpandAll, groupedColumnMode, maxDepth, onTreeRowReorder, positionExpandColumn, renderDetailPanel, state: { grouping }, } = tableOptions;
|
|
1961
|
+
const alignProps = positionExpandColumn === 'last'
|
|
1962
|
+
? {
|
|
1963
|
+
align: 'right',
|
|
2216
1964
|
}
|
|
2217
|
-
|
|
1965
|
+
: undefined;
|
|
1966
|
+
return Object.assign(Object.assign({ Cell: ({ cell, column, row, staticRowIndex, table }) => {
|
|
1967
|
+
var _a, _b, _c;
|
|
1968
|
+
const rowReorderingSelection = useMRT_SliceValue(table._uiStore, (s) => s.rowReorderingSelection);
|
|
1969
|
+
const cellLogic = useTreeRowReorderingCell({
|
|
1970
|
+
row,
|
|
1971
|
+
table,
|
|
1972
|
+
rowReorderingSelection,
|
|
1973
|
+
maxDepth,
|
|
1974
|
+
onTreeRowReorder,
|
|
1975
|
+
});
|
|
1976
|
+
const expandButtonProps = { row, staticRowIndex, table };
|
|
1977
|
+
const subRowsLength = (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.length;
|
|
1978
|
+
const customGroupedCell = (_c = (_b = column.columnDef).GroupedCell) === null || _c === void 0 ? void 0 : _c.call(_b, {
|
|
1979
|
+
cell,
|
|
1980
|
+
column,
|
|
1981
|
+
row,
|
|
1982
|
+
table,
|
|
1983
|
+
staticRowIndex,
|
|
1984
|
+
});
|
|
1985
|
+
if (groupedColumnMode === 'remove' && row.groupingColumnId) {
|
|
1986
|
+
const defaultGroupedCell = (jsxRuntime.jsx(Tooltip, Object.assign({}, getCommonTooltipProps('right'), { title: table.getColumn(row.groupingColumnId).columnDef.header, children: jsxRuntime.jsx("span", { children: row.groupingValue }) })));
|
|
1987
|
+
return (jsxRuntime.jsxs(Stack, { alignItems: "center", flexDirection: "row", gap: TREE_REORDER_ICON_SPACING, onMouseEnter: cellLogic.handleRowHoverEnter, onMouseLeave: cellLogic.handleRowHoverLeave, width: "100%", children: [jsxRuntime.jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), column.columnDef.GroupedCell
|
|
1988
|
+
? customGroupedCell
|
|
1989
|
+
: defaultGroupedCell, cellLogic.shouldShowReorderCheckbox && (jsxRuntime.jsx(MRT_ReorderRowCheckbox, { isSelected: cellLogic.isReorderCheckboxSelected, onChange: cellLogic.handleReorderCheckboxChange })), cellLogic.shouldShowInsertHereAction && (jsxRuntime.jsx(MRT_InsertHereAction, { onClick: cellLogic.handleInsertHereActionClick })), !!subRowsLength && jsxRuntime.jsxs("span", { children: ["(", subRowsLength, ")"] })] }));
|
|
1990
|
+
}
|
|
1991
|
+
return (jsxRuntime.jsxs(Stack, { alignItems: "center", flexDirection: "row", gap: TREE_REORDER_ICON_SPACING, onMouseEnter: cellLogic.handleRowHoverEnter, onMouseLeave: cellLogic.handleRowHoverLeave, width: "100%", children: [jsxRuntime.jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), customGroupedCell, cellLogic.shouldShowReorderCheckbox && (jsxRuntime.jsx(MRT_ReorderRowCheckbox, { isSelected: cellLogic.isReorderCheckboxSelected, onChange: cellLogic.handleReorderCheckboxChange })), cellLogic.shouldShowInsertHereAction && (jsxRuntime.jsx(MRT_InsertHereAction, { onClick: cellLogic.handleInsertHereActionClick }))] }));
|
|
1992
|
+
}, Header: enableExpandAll
|
|
1993
|
+
? ({ table }) => {
|
|
1994
|
+
var _a;
|
|
1995
|
+
const headerLogic = useTreeRowReorderingHeader({
|
|
1996
|
+
table,
|
|
1997
|
+
enableRowReordering,
|
|
1998
|
+
onTreeRowReorder,
|
|
1999
|
+
});
|
|
2000
|
+
return (jsxRuntime.jsxs(Stack, { alignItems: "center", flexDirection: "row", gap: TREE_REORDER_ICON_SPACING, children: [jsxRuntime.jsx(MRT_ExpandAllButton, { table: table }), headerLogic.shouldShowMoveToTopLevelAction && (jsxRuntime.jsx(MRT_MoveToTopAction, { onClick: headerLogic.handleMoveToTopLevelActionClick })), groupedColumnMode === 'remove' &&
|
|
2001
|
+
((_a = grouping === null || grouping === void 0 ? void 0 : grouping.map((groupedColumnId) => table.getColumn(groupedColumnId).columnDef.header)) === null || _a === void 0 ? void 0 : _a.join(', '))] }));
|
|
2002
|
+
}
|
|
2003
|
+
: undefined, muiTableBodyCellProps: alignProps, muiTableHeadCellProps: alignProps }, defaultDisplayColumnProps({
|
|
2004
|
+
header: 'expand',
|
|
2005
|
+
id: 'mrt-row-expand',
|
|
2006
|
+
size: groupedColumnMode === 'remove'
|
|
2007
|
+
? ((_a = defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.size) !== null && _a !== void 0 ? _a : 180)
|
|
2008
|
+
: renderDetailPanel
|
|
2009
|
+
? enableExpandAll
|
|
2010
|
+
? 60
|
|
2011
|
+
: 70
|
|
2012
|
+
: 100,
|
|
2013
|
+
tableOptions,
|
|
2014
|
+
})), { enableResizing: true });
|
|
2015
|
+
};
|
|
2016
|
+
|
|
2017
|
+
const getMRT_RowNumbersColumnDef = (tableOptions) => {
|
|
2018
|
+
const { localization, rowNumberDisplayMode } = tableOptions;
|
|
2019
|
+
const { pagination: { pageIndex, pageSize }, } = tableOptions.state;
|
|
2020
|
+
return Object.assign({ Cell: ({ row, staticRowIndex }) => {
|
|
2021
|
+
var _a;
|
|
2022
|
+
return ((_a = (rowNumberDisplayMode === 'static'
|
|
2023
|
+
? (staticRowIndex || 0) + (pageSize || 0) * (pageIndex || 0)
|
|
2024
|
+
: row.index)) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
2025
|
+
}, Header: () => localization.rowNumber, grow: false }, defaultDisplayColumnProps({
|
|
2026
|
+
header: 'rowNumbers',
|
|
2027
|
+
id: 'mrt-row-numbers',
|
|
2028
|
+
size: 50,
|
|
2029
|
+
tableOptions,
|
|
2030
|
+
}));
|
|
2031
|
+
};
|
|
2032
|
+
|
|
2033
|
+
const MRT_RowPinButton = (_a) => {
|
|
2034
|
+
var { pinningPosition, row, table } = _a, rest = __rest(_a, ["pinningPosition", "row", "table"]);
|
|
2035
|
+
const { options: { icons: { CloseIcon, PushPinIcon }, localization, rowPinningDisplayMode, }, } = table;
|
|
2036
|
+
const isPinned = row.getIsPinned();
|
|
2037
|
+
const [tooltipOpened, setTooltipOpened] = react.useState(false);
|
|
2038
|
+
const handleTogglePin = (event) => {
|
|
2039
|
+
setTooltipOpened(false);
|
|
2040
|
+
event.stopPropagation();
|
|
2041
|
+
row.pin(isPinned ? false : pinningPosition);
|
|
2218
2042
|
};
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2043
|
+
return (jsxRuntime.jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { open: tooltipOpened, title: isPinned ? localization.unpin : localization.pin, children: jsxRuntime.jsx(IconButton, Object.assign({ "aria-label": localization.pin, onBlur: () => setTooltipOpened(false), onClick: handleTogglePin, onFocus: () => setTooltipOpened(true), onMouseEnter: () => setTooltipOpened(true), onMouseLeave: () => setTooltipOpened(false), size: "small" }, rest, { sx: (theme) => (Object.assign({ height: '24px', width: '24px' }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: isPinned ? (jsxRuntime.jsx(CloseIcon, {})) : (jsxRuntime.jsx(PushPinIcon, { fontSize: "small", style: {
|
|
2044
|
+
transform: `rotate(${rowPinningDisplayMode === 'sticky'
|
|
2045
|
+
? 135
|
|
2046
|
+
: pinningPosition === 'top'
|
|
2047
|
+
? 180
|
|
2048
|
+
: 0}deg)`,
|
|
2049
|
+
} })) })) })));
|
|
2050
|
+
};
|
|
2051
|
+
|
|
2052
|
+
const MRT_TableBodyRowPinButton = (_a) => {
|
|
2053
|
+
var { row, table } = _a, rest = __rest(_a, ["row", "table"]);
|
|
2054
|
+
const { options: { enableRowPinning, rowPinningDisplayMode }, } = table;
|
|
2055
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
2056
|
+
const canPin = parseFromValuesOrFunc(enableRowPinning, row);
|
|
2057
|
+
if (!canPin)
|
|
2058
|
+
return null;
|
|
2059
|
+
const rowPinButtonProps = Object.assign({ row,
|
|
2060
|
+
table }, rest);
|
|
2061
|
+
if (rowPinningDisplayMode === 'top-and-bottom' && !row.getIsPinned()) {
|
|
2062
|
+
return (jsxRuntime.jsxs(Box, { sx: {
|
|
2063
|
+
display: 'flex',
|
|
2064
|
+
flexDirection: density === 'compact' ? 'row' : 'column',
|
|
2065
|
+
}, children: [jsxRuntime.jsx(MRT_RowPinButton, Object.assign({ pinningPosition: "top" }, rowPinButtonProps)), jsxRuntime.jsx(MRT_RowPinButton, Object.assign({ pinningPosition: "bottom" }, rowPinButtonProps))] }));
|
|
2066
|
+
}
|
|
2067
|
+
return (jsxRuntime.jsx(MRT_RowPinButton, Object.assign({ pinningPosition: rowPinningDisplayMode === 'bottom' ? 'bottom' : 'top' }, rowPinButtonProps)));
|
|
2068
|
+
};
|
|
2069
|
+
|
|
2070
|
+
const getMRT_RowPinningColumnDef = (tableOptions) => {
|
|
2071
|
+
return Object.assign({ Cell: ({ row, table }) => (jsxRuntime.jsx(MRT_TableBodyRowPinButton, { row: row, table: table })), grow: false }, defaultDisplayColumnProps({
|
|
2072
|
+
header: 'pin',
|
|
2073
|
+
id: 'mrt-row-pin',
|
|
2074
|
+
size: 60,
|
|
2075
|
+
tableOptions,
|
|
2076
|
+
}));
|
|
2077
|
+
};
|
|
2078
|
+
|
|
2079
|
+
const MRT_SelectAllMenu = ({ table, }) => {
|
|
2080
|
+
const [anchorEl, setAnchorEl] = react.useState(null);
|
|
2081
|
+
const [isSelectingAllPages, setIsSelectingAllPages] = react.useState(false);
|
|
2082
|
+
const { getState, options: { enableRowPinning, getAllSelectableRowIds, localization, rowPinningDisplayMode, }, refs: { allSelectableRowIdsRef }, } = table;
|
|
2083
|
+
// rowSelection is read here so that any change to selection will trigger a re-render and update the menu options accordingly
|
|
2084
|
+
const { isLoading, rowSelection } = getState();
|
|
2085
|
+
const isAllCurrentPageSelected = table.getIsAllPageRowsSelected();
|
|
2086
|
+
const isAllPagesActive = getIsAllPagesSelectionActive(table, rowSelection);
|
|
2087
|
+
const handleOpen = (event) => {
|
|
2088
|
+
setAnchorEl(event.currentTarget);
|
|
2089
|
+
};
|
|
2090
|
+
const handleClose = () => {
|
|
2091
|
+
setAnchorEl(null);
|
|
2092
|
+
};
|
|
2093
|
+
// Clears row pinning on every bulk selection/deselection
|
|
2094
|
+
const clearPinning = () => {
|
|
2095
|
+
if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
|
|
2096
|
+
table.setRowPinning({ bottom: [], top: [] });
|
|
2230
2097
|
}
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2098
|
+
};
|
|
2099
|
+
// ── Current-page actions ────────────────────────────────────────────────────
|
|
2100
|
+
const handleSelectCurrentPage = () => {
|
|
2101
|
+
table.toggleAllPageRowsSelected(true);
|
|
2102
|
+
clearPinning();
|
|
2103
|
+
handleClose();
|
|
2104
|
+
};
|
|
2105
|
+
const handleDeselectCurrentPage = () => {
|
|
2106
|
+
if (allSelectableRowIdsRef.current.length > 0) {
|
|
2107
|
+
// When all pages are selected, deselecting the current page must clear the entire selection — otherwise rows on other pages remain "ghost-selected" but the user can't see them.
|
|
2108
|
+
table.setRowSelection({});
|
|
2109
|
+
allSelectableRowIdsRef.current = [];
|
|
2236
2110
|
}
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2111
|
+
else {
|
|
2112
|
+
table.toggleAllPageRowsSelected(false);
|
|
2113
|
+
}
|
|
2114
|
+
clearPinning();
|
|
2115
|
+
handleClose();
|
|
2116
|
+
};
|
|
2117
|
+
// ── All-pages actions ───────────────────────────────────────────────────────
|
|
2118
|
+
const handleSelectAllPages = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2119
|
+
handleClose();
|
|
2120
|
+
if (getAllSelectableRowIds) {
|
|
2121
|
+
// Server-side: IDs are not available locally, fetch them from the API
|
|
2122
|
+
setIsSelectingAllPages(true);
|
|
2123
|
+
table.setShowProgressBars(true);
|
|
2242
2124
|
try {
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
}
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
}
|
|
2252
|
-
notistack.closeSnackbar(loadingKey);
|
|
2253
|
-
notistack.enqueueSnackbar(localization.exportSuccess, { variant: 'success' });
|
|
2254
|
-
return response;
|
|
2125
|
+
const ids = yield getAllSelectableRowIds({ table });
|
|
2126
|
+
allSelectableRowIdsRef.current = ids;
|
|
2127
|
+
const newSelection = {};
|
|
2128
|
+
ids.forEach((id) => {
|
|
2129
|
+
newSelection[id] = true;
|
|
2130
|
+
});
|
|
2131
|
+
table.setRowSelection(newSelection);
|
|
2132
|
+
clearPinning();
|
|
2255
2133
|
}
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
return [];
|
|
2134
|
+
finally {
|
|
2135
|
+
setIsSelectingAllPages(false);
|
|
2136
|
+
table.setShowProgressBars(false);
|
|
2260
2137
|
}
|
|
2261
|
-
}
|
|
2262
|
-
|
|
2138
|
+
}
|
|
2139
|
+
else {
|
|
2140
|
+
// Client-side: all data is available locally
|
|
2141
|
+
table.toggleAllRowsSelected(true);
|
|
2142
|
+
clearPinning();
|
|
2143
|
+
}
|
|
2144
|
+
});
|
|
2145
|
+
const handleDeselectAllPages = () => {
|
|
2146
|
+
if (getAllSelectableRowIds) {
|
|
2147
|
+
table.setRowSelection({});
|
|
2148
|
+
}
|
|
2149
|
+
else {
|
|
2150
|
+
table.toggleAllRowsSelected(false);
|
|
2151
|
+
}
|
|
2152
|
+
allSelectableRowIdsRef.current = [];
|
|
2153
|
+
clearPinning();
|
|
2154
|
+
handleClose();
|
|
2263
2155
|
};
|
|
2264
|
-
|
|
2156
|
+
const isDisabled = isLoading || isSelectingAllPages;
|
|
2157
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.toggleSelectAll, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton, { "aria-label": localization.toggleSelectAll, disabled: isDisabled, onClick: handleOpen, size: "small", sx: { height: '1.5rem', width: '1.5rem' }, children: jsxRuntime.jsx(table.options.icons.MoreVertIcon, { style: { transform: 'scale(0.85)' } }) }) }) })), jsxRuntime.jsxs(Menu, { anchorEl: anchorEl, onClose: handleClose, open: Boolean(anchorEl), children: [isAllCurrentPageSelected ? (jsxRuntime.jsx(MenuItem, { onClick: handleDeselectCurrentPage, children: localization.deselectAllOnCurrentPage })) : (jsxRuntime.jsx(MenuItem, { onClick: handleSelectCurrentPage, children: localization.selectAllOnCurrentPage })), isAllPagesActive ? (jsxRuntime.jsx(MenuItem, { onClick: handleDeselectAllPages, children: localization.deselectAllOnAllPages })) : (jsxRuntime.jsxs(MenuItem, { disabled: isSelectingAllPages, onClick: handleSelectAllPages, children: [isSelectingAllPages && (jsxRuntime.jsx(CircularProgress, { "aria-label": "Loading", size: 14, sx: { mr: 1 } })), localization.selectAllOnAllPages] }))] })] }));
|
|
2158
|
+
};
|
|
2159
|
+
|
|
2160
|
+
const MRT_SelectCheckbox = (_a) => {
|
|
2161
|
+
var _b;
|
|
2162
|
+
var { row, staticRowIndex, table } = _a, rest = __rest(_a, ["row", "staticRowIndex", "table"]);
|
|
2163
|
+
const { getState, options: { enableMultiRowSelection, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, selectAllMode, }, } = table;
|
|
2164
|
+
const { isLoading } = getState();
|
|
2165
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
2166
|
+
const selectAll = !row;
|
|
2167
|
+
const allRowsSelected = selectAll
|
|
2168
|
+
? selectAllMode === 'page'
|
|
2169
|
+
? table.getIsAllPageRowsSelected()
|
|
2170
|
+
: table.getIsAllRowsSelected()
|
|
2171
|
+
: undefined;
|
|
2172
|
+
const isChecked = selectAll
|
|
2173
|
+
? allRowsSelected
|
|
2174
|
+
: getIsRowSelected({ row, table });
|
|
2175
|
+
const checkboxProps = Object.assign(Object.assign({}, (selectAll
|
|
2176
|
+
? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
|
|
2177
|
+
: parseFromValuesOrFunc(muiSelectCheckboxProps, {
|
|
2178
|
+
row,
|
|
2179
|
+
staticRowIndex,
|
|
2180
|
+
table,
|
|
2181
|
+
}))), rest);
|
|
2182
|
+
const onSelectionChange = row
|
|
2183
|
+
? getMRT_RowSelectionHandler({
|
|
2184
|
+
row,
|
|
2185
|
+
staticRowIndex,
|
|
2186
|
+
table,
|
|
2187
|
+
})
|
|
2188
|
+
: undefined;
|
|
2189
|
+
const onSelectAllChange = getMRT_SelectAllHandler({ table });
|
|
2190
|
+
const commonProps = Object.assign(Object.assign({ 'aria-label': selectAll
|
|
2191
|
+
? localization.toggleSelectAll
|
|
2192
|
+
: localization.toggleSelectRow, checked: isChecked, disabled: isLoading || (row && !row.getCanSelect()) || (row === null || row === void 0 ? void 0 : row.id) === 'mrt-row-create', inputProps: {
|
|
2193
|
+
'aria-label': selectAll
|
|
2194
|
+
? localization.toggleSelectAll
|
|
2195
|
+
: localization.toggleSelectRow,
|
|
2196
|
+
}, onChange: (event) => {
|
|
2197
|
+
event.stopPropagation();
|
|
2198
|
+
selectAll ? onSelectAllChange(event) : onSelectionChange(event);
|
|
2199
|
+
}, size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
|
|
2200
|
+
var _a;
|
|
2201
|
+
e.stopPropagation();
|
|
2202
|
+
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
|
|
2203
|
+
}, sx: (theme) => (Object.assign({ height: density === 'compact' ? '1.75rem' : '2.5rem', m: density !== 'compact' ? '-0.4rem' : undefined, width: density === 'compact' ? '1.75rem' : '2.5rem', zIndex: 0 }, parseFromValuesOrFunc(checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.sx, theme))), title: undefined });
|
|
2204
|
+
return (jsxRuntime.jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: (_b = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _b !== void 0 ? _b : (selectAll
|
|
2205
|
+
? localization.toggleSelectAll
|
|
2206
|
+
: localization.toggleSelectRow), children: enableMultiRowSelection === false ? (jsxRuntime.jsx(Radio, Object.assign({}, commonProps))) : (jsxRuntime.jsx(Checkbox, Object.assign({ disableRipple: true, indeterminate: !isChecked && selectAll
|
|
2207
|
+
? table.getIsSomeRowsSelected()
|
|
2208
|
+
: (row === null || row === void 0 ? void 0 : row.getIsSomeSelected()) && row.getCanSelectSubRows() }, commonProps))) })));
|
|
2209
|
+
};
|
|
2210
|
+
|
|
2211
|
+
const getMRT_RowSelectColumnDef = (tableOptions) => {
|
|
2212
|
+
const { enableMultiRowSelection, enableSelectAll } = tableOptions;
|
|
2213
|
+
return Object.assign({ Cell: ({ row, staticRowIndex, table }) => (jsxRuntime.jsx(MRT_SelectCheckbox, { row: row, staticRowIndex: staticRowIndex, table: table })), Header: enableSelectAll && enableMultiRowSelection
|
|
2214
|
+
? ({ table }) => (jsxRuntime.jsxs(Box, { sx: { alignItems: 'center', display: 'flex' }, children: [jsxRuntime.jsx(MRT_SelectCheckbox, { table: table }), jsxRuntime.jsx(MRT_SelectAllMenu, { table: table })] }))
|
|
2215
|
+
: undefined, grow: false }, defaultDisplayColumnProps({
|
|
2216
|
+
header: 'select',
|
|
2217
|
+
id: '__check__',
|
|
2218
|
+
size: enableSelectAll ? 90 : 70, // widened from 60 to accommodate both the checkbox and the menu button
|
|
2219
|
+
tableOptions,
|
|
2220
|
+
}));
|
|
2221
|
+
};
|
|
2222
|
+
|
|
2223
|
+
const MRT_Default_Icons = {
|
|
2224
|
+
AddIcon,
|
|
2225
|
+
ArrowDownwardIcon,
|
|
2226
|
+
ArrowRightIcon,
|
|
2227
|
+
CancelIcon,
|
|
2228
|
+
ChevronLeftIcon,
|
|
2229
|
+
ChevronRightIcon,
|
|
2230
|
+
ClearAllIcon,
|
|
2231
|
+
CloseIcon,
|
|
2232
|
+
ContentCopy,
|
|
2233
|
+
DensityLargeIcon,
|
|
2234
|
+
DensityMediumIcon,
|
|
2235
|
+
DensitySmallIcon,
|
|
2236
|
+
DragHandleIcon,
|
|
2237
|
+
DynamicFeedIcon,
|
|
2238
|
+
EditIcon,
|
|
2239
|
+
ExpandMoreIcon,
|
|
2240
|
+
FilterAltIcon,
|
|
2241
|
+
FilterListIcon,
|
|
2242
|
+
FilterListOffIcon,
|
|
2243
|
+
FirstPageIcon,
|
|
2244
|
+
FullscreenExitIcon,
|
|
2245
|
+
FullscreenIcon,
|
|
2246
|
+
KeyboardDoubleArrowDownIcon,
|
|
2247
|
+
LastPageIcon,
|
|
2248
|
+
MoreHorizIcon,
|
|
2249
|
+
MoreVertIcon,
|
|
2250
|
+
PushPinIcon,
|
|
2251
|
+
RestartAltIcon,
|
|
2252
|
+
SaveIcon,
|
|
2253
|
+
SearchIcon,
|
|
2254
|
+
SearchOffIcon,
|
|
2255
|
+
SortIcon,
|
|
2256
|
+
SyncAltIcon,
|
|
2257
|
+
ViewColumnIcon,
|
|
2258
|
+
VisibilityOffIcon,
|
|
2259
|
+
};
|
|
2260
|
+
|
|
2261
|
+
const MRT_Localization_EN = {
|
|
2262
|
+
language: 'en',
|
|
2263
|
+
actions: 'Actions',
|
|
2264
|
+
and: 'and',
|
|
2265
|
+
booleanFalse: 'False',
|
|
2266
|
+
booleanTrue: 'True',
|
|
2267
|
+
cancel: 'Cancel',
|
|
2268
|
+
close: 'Close',
|
|
2269
|
+
changeFilterMode: 'Change filter mode',
|
|
2270
|
+
changeSearchMode: 'Change search mode',
|
|
2271
|
+
clearFilter: 'Clear filter',
|
|
2272
|
+
clearSearch: 'Clear search',
|
|
2273
|
+
clearSelection: 'Clear selection',
|
|
2274
|
+
clearSort: 'Clear sort',
|
|
2275
|
+
deselectAllOnAllPages: 'Deselect all on all pages',
|
|
2276
|
+
deselectAllOnCurrentPage: 'Deselect all on current page',
|
|
2277
|
+
clickToCopy: 'Click to copy',
|
|
2278
|
+
copy: 'Copy',
|
|
2279
|
+
collapse: 'Collapse',
|
|
2280
|
+
collapseAll: 'Collapse all',
|
|
2281
|
+
columnActions: 'Column Actions',
|
|
2282
|
+
columns: 'Columns',
|
|
2283
|
+
copiedToClipboard: 'Copied to clipboard',
|
|
2284
|
+
dropToGroupBy: 'Drop to group by {column}',
|
|
2285
|
+
edit: 'Edit',
|
|
2286
|
+
expand: 'Expand',
|
|
2287
|
+
expandAll: 'Expand all',
|
|
2288
|
+
filterArrIncludes: 'Includes',
|
|
2289
|
+
filterArrIncludesAll: 'Includes all',
|
|
2290
|
+
filterArrIncludesSome: 'Includes',
|
|
2291
|
+
filterBetween: 'Between',
|
|
2292
|
+
filterBetweenInclusive: 'Between Inclusive',
|
|
2293
|
+
filterByColumn: 'Filter by {column}',
|
|
2294
|
+
filterFrom: 'From',
|
|
2295
|
+
filterTo: 'To',
|
|
2296
|
+
filterContains: 'Contains',
|
|
2297
|
+
filterEmpty: 'Empty',
|
|
2298
|
+
filterEndsWith: 'Ends With',
|
|
2299
|
+
filterEquals: 'Equals',
|
|
2300
|
+
filterEqualsString: 'Equals',
|
|
2301
|
+
filterFuzzy: 'Fuzzy',
|
|
2302
|
+
filterGreaterThan: 'Greater Than',
|
|
2303
|
+
filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
|
|
2304
|
+
filterInArray: 'Is any of',
|
|
2305
|
+
filterIsAnyOf: 'Is any of',
|
|
2306
|
+
filterInNumberRange: 'Between',
|
|
2307
|
+
filterIncludesString: 'Contains',
|
|
2308
|
+
filterIncludesStringSensitive: 'Contains',
|
|
2309
|
+
filterLessThan: 'Less Than',
|
|
2310
|
+
filterLessThanOrEqualTo: 'Less Than Or Equal To',
|
|
2311
|
+
filterMode: 'Filter Mode: {filterType}',
|
|
2312
|
+
filterNoOptions: 'No filter options available',
|
|
2313
|
+
filterNotEmpty: 'Not Empty',
|
|
2314
|
+
filterNotEquals: 'Not Equals',
|
|
2315
|
+
filterNotContains: 'Does Not Contain',
|
|
2316
|
+
filterLogic: 'Logic',
|
|
2317
|
+
filterOperator: 'Operator',
|
|
2318
|
+
filterStartsWith: 'Starts With',
|
|
2319
|
+
filterWeakEquals: 'Equals',
|
|
2320
|
+
filterCurrentWeek: 'Current Week',
|
|
2321
|
+
filterCurrentMonth: 'Current Month',
|
|
2322
|
+
filterLast7Days: 'Last 7 Days',
|
|
2323
|
+
filterLastWeek: 'Last Week',
|
|
2324
|
+
filterLastMonth: 'Last Month',
|
|
2325
|
+
filterFromToday: 'From Today',
|
|
2326
|
+
filterToToday: 'To Today',
|
|
2327
|
+
filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
|
|
2328
|
+
goToFirstPage: 'Go to first page',
|
|
2329
|
+
goToLastPage: 'Go to last page',
|
|
2330
|
+
goToNextPage: 'Go to next page',
|
|
2331
|
+
goToPreviousPage: 'Go to previous page',
|
|
2332
|
+
grab: 'Grab',
|
|
2333
|
+
groupByColumn: 'Group by {column}',
|
|
2334
|
+
groupedBy: 'Grouped by ',
|
|
2335
|
+
hideAll: 'Hide all',
|
|
2336
|
+
hideColumn: 'Hide {column} column',
|
|
2337
|
+
max: 'Max',
|
|
2338
|
+
min: 'Min',
|
|
2339
|
+
move: 'Move',
|
|
2340
|
+
noRecordsToDisplay: 'No records to display',
|
|
2341
|
+
noResultsFound: 'No results found',
|
|
2342
|
+
moreThan: 'more than',
|
|
2343
|
+
of: 'of',
|
|
2344
|
+
or: 'or',
|
|
2345
|
+
pin: 'Pin',
|
|
2346
|
+
pinToLeft: 'Pin to left',
|
|
2347
|
+
pinToRight: 'Pin to right',
|
|
2348
|
+
resetColumnSize: 'Reset column size',
|
|
2349
|
+
resetOrder: 'Reset order',
|
|
2350
|
+
rowActions: 'Row Actions',
|
|
2351
|
+
rowNumber: '#',
|
|
2352
|
+
rowNumbers: 'Row Numbers',
|
|
2353
|
+
rowsPerPage: 'Rows per page',
|
|
2354
|
+
countRows: 'Count Rows',
|
|
2355
|
+
countRowsTooltip: 'Count total rows for current filters',
|
|
2356
|
+
rowCount: 'Row Count',
|
|
2357
|
+
rowsSelected: '{count} row(s) selected',
|
|
2358
|
+
save: 'Save',
|
|
2359
|
+
search: 'Search',
|
|
2360
|
+
selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
|
|
2361
|
+
select: 'Select',
|
|
2362
|
+
selectAllOnAllPages: 'Select all on all pages',
|
|
2363
|
+
selectAllOnCurrentPage: 'Select all on current page',
|
|
2364
|
+
showAll: 'Show all',
|
|
2365
|
+
showAllColumns: 'Show all columns',
|
|
2366
|
+
showHideColumns: 'Columns',
|
|
2367
|
+
showHideFilters: 'Show/Hide filters',
|
|
2368
|
+
showHideSearch: 'Show/Hide search',
|
|
2369
|
+
showAdvancedFilters: 'Show advanced filters',
|
|
2370
|
+
advancedFilters: 'Advanced Filters',
|
|
2371
|
+
filters: 'Filters',
|
|
2372
|
+
add: 'Add',
|
|
2373
|
+
newEntry: 'New Entry',
|
|
2374
|
+
clear: 'Clear',
|
|
2375
|
+
discardChanges: 'Discard changes',
|
|
2376
|
+
saveFilters: 'Save filters',
|
|
2377
|
+
savedFilters: 'Saved filters',
|
|
2378
|
+
noSavedFilters: 'No saved filters',
|
|
2379
|
+
filterName: 'Filter name',
|
|
2380
|
+
apply: 'Apply',
|
|
2381
|
+
sortByColumnAsc: 'Sort by {column} ascending',
|
|
2382
|
+
sortByColumnDesc: 'Sort by {column} descending',
|
|
2383
|
+
sortedByColumnAsc: 'Sorted by {column} ascending',
|
|
2384
|
+
sortedByColumnDesc: 'Sorted by {column} descending',
|
|
2385
|
+
thenBy: ', then by ',
|
|
2386
|
+
toggleDensity: 'Density',
|
|
2387
|
+
densityCompact: 'Compact',
|
|
2388
|
+
densityStandard: 'Standard',
|
|
2389
|
+
densityComfortable: 'Comfortable',
|
|
2390
|
+
toggleFullScreen: 'Toggle full screen',
|
|
2391
|
+
toggleSelectAll: 'Toggle select all',
|
|
2392
|
+
toggleSelectRow: 'Toggle select row',
|
|
2393
|
+
toggleVisibility: 'Toggle visibility',
|
|
2394
|
+
ungroupByColumn: 'Ungroup by {column}',
|
|
2395
|
+
unpin: 'Unpin',
|
|
2396
|
+
unpinAll: 'Unpin all',
|
|
2397
|
+
dimensionRotationEnabled: 'Rotation enabled',
|
|
2398
|
+
dimensionRotationDisabled: 'Rotation disabled',
|
|
2399
|
+
length: 'Length',
|
|
2400
|
+
width: 'Width',
|
|
2401
|
+
height: 'Height',
|
|
2402
|
+
depth: 'Depth',
|
|
2403
|
+
tolerance: 'Tolerance',
|
|
2404
|
+
exportButton: 'Export',
|
|
2405
|
+
exportSelectRowsTooltip: 'Select rows to export',
|
|
2406
|
+
exportPrintPdf: 'Print PDF',
|
|
2407
|
+
exportDownload: 'Download',
|
|
2408
|
+
exportGrouped: 'Group files',
|
|
2409
|
+
exportInProgress: 'Export in progress...',
|
|
2410
|
+
exportSuccess: 'Export completed successfully.',
|
|
2411
|
+
exportError: 'Export failed. Please try again.',
|
|
2412
|
+
exportNoExportsSelected: 'No export type selected. Please configure the export first.',
|
|
2413
|
+
deleteConfirmationTitle: 'Delete Row',
|
|
2414
|
+
deleteConfirmationMessage: 'Are you sure you want to delete the selected row(s)?',
|
|
2415
|
+
deleteConfirmYes: 'Delete',
|
|
2416
|
+
deleteConfirmNo: 'Cancel',
|
|
2417
|
+
deleteConfirmDeleting: 'Deleting...',
|
|
2418
|
+
errorTitle: 'Unexpected error',
|
|
2419
|
+
errorMessage: 'An unexpected error occurred. Please try again.',
|
|
2420
|
+
serverTableErrorTitle: 'Unable to load table',
|
|
2421
|
+
serverTableErrorMessage: 'Something went wrong while loading the table configuration. Please try again.',
|
|
2422
|
+
serverTableErrorRetry: 'Try again',
|
|
2423
|
+
resetState: 'Reset State',
|
|
2424
|
+
tableOptions: 'Options',
|
|
2265
2425
|
};
|
|
2266
2426
|
|
|
2267
2427
|
const MRT_DefaultColumn = {
|
|
@@ -2422,7 +2582,8 @@ const getMRT_RowSpacerColumnDef = (tableOptions) => {
|
|
|
2422
2582
|
|
|
2423
2583
|
const useMRT_Effects = (table) => {
|
|
2424
2584
|
const { getIsSomeRowsPinned, getPrePaginationRowModel, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
|
|
2425
|
-
const {
|
|
2585
|
+
const { globalFilter, isLoading, pagination, showSkeletons, sorting } = getState();
|
|
2586
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
2426
2587
|
const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
|
|
2427
2588
|
const rerender = react.useReducer(() => ({}), {})[1];
|
|
2428
2589
|
const initialBodyHeight = react.useRef(null);
|
|
@@ -2569,13 +2730,29 @@ const handleRemoveRow = ({ getRowId, setRowsState, }) => {
|
|
|
2569
2730
|
};
|
|
2570
2731
|
};
|
|
2571
2732
|
|
|
2733
|
+
const createSliceStore = (initial) => {
|
|
2734
|
+
let value = initial;
|
|
2735
|
+
const listeners = new Set();
|
|
2736
|
+
return {
|
|
2737
|
+
get: () => value,
|
|
2738
|
+
set: (next) => {
|
|
2739
|
+
value = next instanceof Function ? next(value) : next;
|
|
2740
|
+
listeners.forEach((listener) => listener());
|
|
2741
|
+
},
|
|
2742
|
+
subscribe: (listener) => {
|
|
2743
|
+
listeners.add(listener);
|
|
2744
|
+
return () => listeners.delete(listener);
|
|
2745
|
+
},
|
|
2746
|
+
};
|
|
2747
|
+
};
|
|
2748
|
+
|
|
2572
2749
|
/**
|
|
2573
2750
|
* The MRT hook that wraps the TanStack useReactTable hook and adds additional functionality
|
|
2574
2751
|
* @param definedTableOptions - table options with proper defaults set
|
|
2575
2752
|
* @returns the MRT table instance
|
|
2576
2753
|
*/
|
|
2577
2754
|
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
|
|
2755
|
+
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
2756
|
const lastSelectedRowId = react.useRef(null);
|
|
2580
2757
|
const allSelectableRowIdsRef = react.useRef([]);
|
|
2581
2758
|
const actionCellRef = react.useRef(null);
|
|
@@ -2589,6 +2766,9 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
|
2589
2766
|
const topToolbarRef = react.useRef(null);
|
|
2590
2767
|
const tableHeadRef = react.useRef(null);
|
|
2591
2768
|
const tableFooterRef = react.useRef(null);
|
|
2769
|
+
const tableRef = react.useRef(null);
|
|
2770
|
+
const isResizingRef = react.useRef(false);
|
|
2771
|
+
const resizeIndicatorRef = react.useRef(null);
|
|
2592
2772
|
//transform initial state with proper column order
|
|
2593
2773
|
const initialState = react.useMemo(() => {
|
|
2594
2774
|
var _a, _b, _c, _d, _e;
|
|
@@ -2607,8 +2787,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
|
2607
2787
|
return initState;
|
|
2608
2788
|
}, []);
|
|
2609
2789
|
definedTableOptions.initialState = initialState;
|
|
2610
|
-
const [
|
|
2611
|
-
const [creatingRow, _setCreatingRow] = react.useState((_b = initialState.creatingRow) !== null && _b !== void 0 ? _b : null);
|
|
2790
|
+
const [creatingRow, _setCreatingRow] = react.useState((_a = initialState.creatingRow) !== null && _a !== void 0 ? _a : null);
|
|
2612
2791
|
const [columnFilterFns, setColumnFilterFns] = react.useState(() => Object.assign({}, ...getAllLeafColumnDefs(definedTableOptions.columns).map((col) => {
|
|
2613
2792
|
var _a, _b, _c, _d;
|
|
2614
2793
|
return ({
|
|
@@ -2617,60 +2796,176 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
|
2617
2796
|
: ((_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
2797
|
});
|
|
2619
2798
|
})));
|
|
2620
|
-
const [columnOrder, onColumnOrderChange] = react.useState((
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
const [
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2799
|
+
const [columnOrder, onColumnOrderChange] = react.useState((_b = initialState.columnOrder) !== null && _b !== void 0 ? _b : []);
|
|
2800
|
+
// Hover/drag are UI-feedback-only and change at very high frequency during a drag
|
|
2801
|
+
// gesture (every cell crossed) — kept in slice stores instead of useState so
|
|
2802
|
+
// subscribers can select just the boolean they need instead of re-rendering the tree.
|
|
2803
|
+
const [dragStore] = react.useState(() => {
|
|
2804
|
+
var _a, _b;
|
|
2805
|
+
return createSliceStore({
|
|
2806
|
+
draggingColumn: ((_a = initialState.draggingColumn) !== null && _a !== void 0 ? _a : null),
|
|
2807
|
+
draggingRow: ((_b = initialState.draggingRow) !== null && _b !== void 0 ? _b : null),
|
|
2808
|
+
});
|
|
2809
|
+
});
|
|
2810
|
+
const [filters, setFilters] = react.useState((_c = initialState.filters) !== null && _c !== void 0 ? _c : {
|
|
2628
2811
|
logicOperator: 'and',
|
|
2629
2812
|
rules: [],
|
|
2630
2813
|
pinnedFilters: [],
|
|
2631
2814
|
});
|
|
2632
|
-
const [globalFilterFn, setGlobalFilterFn] = react.useState((
|
|
2633
|
-
const [grouping, onGroupingChange] = react.useState((
|
|
2634
|
-
const [
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2815
|
+
const [globalFilterFn, setGlobalFilterFn] = react.useState((_d = initialState.globalFilterFn) !== null && _d !== void 0 ? _d : 'fuzzy');
|
|
2816
|
+
const [grouping, onGroupingChange] = react.useState((_e = initialState.grouping) !== null && _e !== void 0 ? _e : []);
|
|
2817
|
+
const [hoverStore] = react.useState(() => {
|
|
2818
|
+
var _a, _b;
|
|
2819
|
+
return createSliceStore({
|
|
2820
|
+
hoveredColumn: ((_a = initialState.hoveredColumn) !== null && _a !== void 0 ? _a : null),
|
|
2821
|
+
hoveredRow: ((_b = initialState.hoveredRow) !== null && _b !== void 0 ? _b : null),
|
|
2822
|
+
});
|
|
2823
|
+
});
|
|
2824
|
+
// Everything below is UI-only feedback state that never influences the TanStack row/
|
|
2825
|
+
// column model (unlike filters/pagination/grouping/columnOrder/creatingRow/rows) —
|
|
2826
|
+
// kept in one combined store instead of 13 separate useState hooks so none of it
|
|
2827
|
+
// triggers a root re-render; consumers select just the field(s) they need via
|
|
2828
|
+
// useMRT_SliceValue.
|
|
2829
|
+
const [uiStore] = react.useState(() => {
|
|
2830
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
2831
|
+
return createSliceStore({
|
|
2832
|
+
actionCell: ((_a = initialState.actionCell) !== null && _a !== void 0 ? _a : null),
|
|
2833
|
+
columnSizingInfo: ((_b = initialState.columnSizingInfo) !== null && _b !== void 0 ? _b : {}),
|
|
2834
|
+
density: ((_c = initialState === null || initialState === void 0 ? void 0 : initialState.density) !== null && _c !== void 0 ? _c : 'compact'),
|
|
2835
|
+
editingCell: ((_d = initialState.editingCell) !== null && _d !== void 0 ? _d : null),
|
|
2836
|
+
editingRow: ((_e = initialState.editingRow) !== null && _e !== void 0 ? _e : null),
|
|
2837
|
+
newEntryModal: ((_f = initialState === null || initialState === void 0 ? void 0 : initialState.newEntryModal) !== null && _f !== void 0 ? _f : {
|
|
2838
|
+
open: false,
|
|
2839
|
+
}),
|
|
2840
|
+
rowReorderingSelection: ((_g = initialState === null || initialState === void 0 ? void 0 : initialState.rowReorderingSelection) !== null && _g !== void 0 ? _g : {}),
|
|
2841
|
+
// Saved filter presets — initialised from the dedicated option so the consumer
|
|
2842
|
+
// can hydrate them from the server response before rendering.
|
|
2843
|
+
savedFilters: ((_h = definedTableOptions.initialSavedFilters) !== null && _h !== void 0 ? _h : {}),
|
|
2844
|
+
showAlertBanner: ((_j = initialState === null || initialState === void 0 ? void 0 : initialState.showAlertBanner) !== null && _j !== void 0 ? _j : false),
|
|
2845
|
+
showColumnFilters: ((_k = initialState === null || initialState === void 0 ? void 0 : initialState.showColumnFilters) !== null && _k !== void 0 ? _k : false),
|
|
2846
|
+
showGlobalFilter: ((_l = initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) !== null && _l !== void 0 ? _l : false),
|
|
2847
|
+
showProgressBars: ((_m = initialState === null || initialState === void 0 ? void 0 : initialState.showProgressBars) !== null && _m !== void 0 ? _m : false),
|
|
2848
|
+
showToolbarDropZone: ((_o = initialState === null || initialState === void 0 ? void 0 : initialState.showToolbarDropZone) !== null && _o !== void 0 ? _o : false),
|
|
2849
|
+
});
|
|
2850
|
+
});
|
|
2851
|
+
// columnSizingInfo isn't an MRT-level `table.setX` wrapper — TanStack auto-generates
|
|
2852
|
+
// `table.setColumnSizingInfo` bound to whatever `onColumnSizingInfoChange` we pass into
|
|
2853
|
+
// useReactTable below, so redirecting it here is enough for every internal call
|
|
2854
|
+
// (column.resetSize(), the resize-handle double-click reset, etc.) to land in the store.
|
|
2855
|
+
const onColumnSizingInfoChange = (updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { columnSizingInfo: updater instanceof Function ? updater(prev.columnSizingInfo) : updater })));
|
|
2856
|
+
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
2857
|
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,
|
|
2858
|
+
const [rows, setRowsState] = react.useState((_g = definedTableOptions.data) !== null && _g !== void 0 ? _g : []);
|
|
2859
|
+
definedTableOptions.state = Object.assign({ columnFilterFns,
|
|
2652
2860
|
columnOrder,
|
|
2653
|
-
columnSizingInfo,
|
|
2654
2861
|
creatingRow,
|
|
2655
|
-
density,
|
|
2656
|
-
draggingColumn,
|
|
2657
|
-
draggingRow,
|
|
2658
|
-
editingCell,
|
|
2659
|
-
editingRow,
|
|
2660
2862
|
filters,
|
|
2661
2863
|
globalFilterFn,
|
|
2662
2864
|
grouping,
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2865
|
+
pagination }, definedTableOptions.state);
|
|
2866
|
+
// Sync a controlled consumer's state.draggingColumn/draggingRow/hoveredColumn/
|
|
2867
|
+
// hoveredRow into the slice stores — rare (these are usually left uncontrolled), but
|
|
2868
|
+
// since they no longer flow through definedTableOptions.state -> useReactTable, an
|
|
2869
|
+
// externally-controlled value needs an explicit bridge into the store.
|
|
2870
|
+
react.useEffect(() => {
|
|
2871
|
+
var _a;
|
|
2872
|
+
if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.draggingColumn) !== undefined) {
|
|
2873
|
+
dragStore.set((prev) => (Object.assign(Object.assign({}, prev), { draggingColumn: definedTableOptions.state.draggingColumn })));
|
|
2874
|
+
}
|
|
2875
|
+
}, [(_h = definedTableOptions.state) === null || _h === void 0 ? void 0 : _h.draggingColumn]);
|
|
2876
|
+
react.useEffect(() => {
|
|
2877
|
+
var _a;
|
|
2878
|
+
if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.draggingRow) !== undefined) {
|
|
2879
|
+
dragStore.set((prev) => (Object.assign(Object.assign({}, prev), { draggingRow: definedTableOptions.state.draggingRow })));
|
|
2880
|
+
}
|
|
2881
|
+
}, [(_j = definedTableOptions.state) === null || _j === void 0 ? void 0 : _j.draggingRow]);
|
|
2882
|
+
react.useEffect(() => {
|
|
2883
|
+
var _a;
|
|
2884
|
+
if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.hoveredColumn) !== undefined) {
|
|
2885
|
+
hoverStore.set((prev) => (Object.assign(Object.assign({}, prev), { hoveredColumn: definedTableOptions.state.hoveredColumn })));
|
|
2886
|
+
}
|
|
2887
|
+
}, [(_k = definedTableOptions.state) === null || _k === void 0 ? void 0 : _k.hoveredColumn]);
|
|
2888
|
+
react.useEffect(() => {
|
|
2889
|
+
var _a;
|
|
2890
|
+
if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.hoveredRow) !== undefined) {
|
|
2891
|
+
hoverStore.set((prev) => (Object.assign(Object.assign({}, prev), { hoveredRow: definedTableOptions.state.hoveredRow })));
|
|
2892
|
+
}
|
|
2893
|
+
}, [(_l = definedTableOptions.state) === null || _l === void 0 ? void 0 : _l.hoveredRow]);
|
|
2894
|
+
// Same bridge as above, for the 12 UI-only fields in uiStore (columnSizingInfo is
|
|
2895
|
+
// deliberately excluded — it isn't part of the table.setX = onXChange ?? ... pattern,
|
|
2896
|
+
// see onColumnSizingInfoChange above).
|
|
2897
|
+
react.useEffect(() => {
|
|
2898
|
+
var _a;
|
|
2899
|
+
if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.actionCell) !== undefined) {
|
|
2900
|
+
uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { actionCell: definedTableOptions.state.actionCell })));
|
|
2901
|
+
}
|
|
2902
|
+
}, [(_m = definedTableOptions.state) === null || _m === void 0 ? void 0 : _m.actionCell]);
|
|
2903
|
+
react.useEffect(() => {
|
|
2904
|
+
var _a;
|
|
2905
|
+
if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.density) !== undefined) {
|
|
2906
|
+
uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { density: definedTableOptions.state.density })));
|
|
2907
|
+
}
|
|
2908
|
+
}, [(_o = definedTableOptions.state) === null || _o === void 0 ? void 0 : _o.density]);
|
|
2909
|
+
react.useEffect(() => {
|
|
2910
|
+
var _a;
|
|
2911
|
+
if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.editingCell) !== undefined) {
|
|
2912
|
+
uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { editingCell: definedTableOptions.state.editingCell })));
|
|
2913
|
+
}
|
|
2914
|
+
}, [(_p = definedTableOptions.state) === null || _p === void 0 ? void 0 : _p.editingCell]);
|
|
2915
|
+
react.useEffect(() => {
|
|
2916
|
+
var _a;
|
|
2917
|
+
if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.editingRow) !== undefined) {
|
|
2918
|
+
uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { editingRow: definedTableOptions.state.editingRow })));
|
|
2919
|
+
}
|
|
2920
|
+
}, [(_q = definedTableOptions.state) === null || _q === void 0 ? void 0 : _q.editingRow]);
|
|
2921
|
+
react.useEffect(() => {
|
|
2922
|
+
var _a;
|
|
2923
|
+
if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.newEntryModal) !== undefined) {
|
|
2924
|
+
uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { newEntryModal: definedTableOptions.state.newEntryModal })));
|
|
2925
|
+
}
|
|
2926
|
+
}, [(_r = definedTableOptions.state) === null || _r === void 0 ? void 0 : _r.newEntryModal]);
|
|
2927
|
+
react.useEffect(() => {
|
|
2928
|
+
var _a;
|
|
2929
|
+
if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.rowReorderingSelection) !== undefined) {
|
|
2930
|
+
uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { rowReorderingSelection: definedTableOptions.state.rowReorderingSelection })));
|
|
2931
|
+
}
|
|
2932
|
+
}, [(_s = definedTableOptions.state) === null || _s === void 0 ? void 0 : _s.rowReorderingSelection]);
|
|
2933
|
+
react.useEffect(() => {
|
|
2934
|
+
var _a;
|
|
2935
|
+
if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.savedFilters) !== undefined) {
|
|
2936
|
+
uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { savedFilters: definedTableOptions.state.savedFilters })));
|
|
2937
|
+
}
|
|
2938
|
+
}, [(_t = definedTableOptions.state) === null || _t === void 0 ? void 0 : _t.savedFilters]);
|
|
2939
|
+
react.useEffect(() => {
|
|
2940
|
+
var _a;
|
|
2941
|
+
if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.showAlertBanner) !== undefined) {
|
|
2942
|
+
uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { showAlertBanner: definedTableOptions.state.showAlertBanner })));
|
|
2943
|
+
}
|
|
2944
|
+
}, [(_u = definedTableOptions.state) === null || _u === void 0 ? void 0 : _u.showAlertBanner]);
|
|
2945
|
+
react.useEffect(() => {
|
|
2946
|
+
var _a;
|
|
2947
|
+
if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.showColumnFilters) !== undefined) {
|
|
2948
|
+
uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { showColumnFilters: definedTableOptions.state.showColumnFilters })));
|
|
2949
|
+
}
|
|
2950
|
+
}, [(_v = definedTableOptions.state) === null || _v === void 0 ? void 0 : _v.showColumnFilters]);
|
|
2951
|
+
react.useEffect(() => {
|
|
2952
|
+
var _a;
|
|
2953
|
+
if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.showGlobalFilter) !== undefined) {
|
|
2954
|
+
uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { showGlobalFilter: definedTableOptions.state.showGlobalFilter })));
|
|
2955
|
+
}
|
|
2956
|
+
}, [(_w = definedTableOptions.state) === null || _w === void 0 ? void 0 : _w.showGlobalFilter]);
|
|
2957
|
+
react.useEffect(() => {
|
|
2958
|
+
var _a;
|
|
2959
|
+
if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.showProgressBars) !== undefined) {
|
|
2960
|
+
uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { showProgressBars: definedTableOptions.state.showProgressBars })));
|
|
2961
|
+
}
|
|
2962
|
+
}, [(_x = definedTableOptions.state) === null || _x === void 0 ? void 0 : _x.showProgressBars]);
|
|
2963
|
+
react.useEffect(() => {
|
|
2964
|
+
var _a;
|
|
2965
|
+
if (((_a = definedTableOptions.state) === null || _a === void 0 ? void 0 : _a.showToolbarDropZone) !== undefined) {
|
|
2966
|
+
uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { showToolbarDropZone: definedTableOptions.state.showToolbarDropZone })));
|
|
2967
|
+
}
|
|
2968
|
+
}, [(_y = definedTableOptions.state) === null || _y === void 0 ? void 0 : _y.showToolbarDropZone]);
|
|
2674
2969
|
// Normalize controlled columnPinning state: if the user passes state.columnPinning
|
|
2675
2970
|
// directly (controlled mode), we still need to ensure that the checkbox column
|
|
2676
2971
|
// is always at the front of the left-pinned group, just like we do for initialState.
|
|
@@ -2680,7 +2975,7 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
|
2680
2975
|
}
|
|
2681
2976
|
//The table options now include all state needed to help determine column visibility and order logic
|
|
2682
2977
|
const statefulTableOptions = definedTableOptions;
|
|
2683
|
-
const resolveRowId = (
|
|
2978
|
+
const resolveRowId = (_z = statefulTableOptions.getRowId) !== null && _z !== void 0 ? _z : ((_originalRow, index, _parentRow) => String(index));
|
|
2684
2979
|
//keep the prepared column tree referentially stable so TanStack's
|
|
2685
2980
|
//getAllColumns/getAllLeafColumns/row.getAllCells memo chain doesn't
|
|
2686
2981
|
//recompute (and recreate every cell of every row) on unrelated renders
|
|
@@ -2759,24 +3054,34 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
|
2759
3054
|
const table = reactTable.useReactTable(Object.assign(Object.assign({ onColumnOrderChange,
|
|
2760
3055
|
onColumnSizingInfoChange,
|
|
2761
3056
|
onGroupingChange,
|
|
2762
|
-
onPaginationChange }, statefulTableOptions), { globalFilterFn: (
|
|
3057
|
+
onPaginationChange }, statefulTableOptions), { globalFilterFn: (_0 = statefulTableOptions.filterFns) === null || _0 === void 0 ? void 0 : _0[globalFilterFn !== null && globalFilterFn !== void 0 ? globalFilterFn : 'fuzzy'] }));
|
|
2763
3058
|
table.refs = {
|
|
2764
3059
|
actionCellRef,
|
|
2765
3060
|
allSelectableRowIdsRef,
|
|
2766
3061
|
bottomToolbarRef,
|
|
2767
3062
|
editInputRefs,
|
|
2768
3063
|
filterInputRefs,
|
|
3064
|
+
isResizingRef,
|
|
2769
3065
|
lastSelectedRowId,
|
|
3066
|
+
resizeIndicatorRef,
|
|
2770
3067
|
searchInputRef,
|
|
2771
3068
|
tableContainerRef,
|
|
2772
3069
|
tableFooterRef,
|
|
2773
3070
|
tableHeadCellRefs,
|
|
2774
3071
|
tableHeadRef,
|
|
2775
3072
|
tablePaperRef,
|
|
3073
|
+
tableRef,
|
|
2776
3074
|
topToolbarRef,
|
|
2777
3075
|
};
|
|
3076
|
+
table._dragStore = dragStore;
|
|
3077
|
+
table._hoverStore = hoverStore;
|
|
3078
|
+
table._uiStore = uiStore;
|
|
3079
|
+
// Merge the slice stores back into getState() so every existing/external
|
|
3080
|
+
// `table.getState().hoveredColumn`-style read keeps working unchanged.
|
|
3081
|
+
const originalGetState = table.getState;
|
|
3082
|
+
table.getState = () => (Object.assign(Object.assign(Object.assign(Object.assign({}, originalGetState()), dragStore.get()), hoverStore.get()), uiStore.get()));
|
|
2778
3083
|
table.setActionCell =
|
|
2779
|
-
(
|
|
3084
|
+
(_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
3085
|
table.setCreatingRow = (row) => {
|
|
2781
3086
|
var _a, _b;
|
|
2782
3087
|
let _row = row;
|
|
@@ -2786,39 +3091,48 @@ const useMRT_TableInstance = (definedTableOptions) => {
|
|
|
2786
3091
|
(_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
3092
|
};
|
|
2788
3093
|
table.setColumnFilterFns =
|
|
2789
|
-
(
|
|
2790
|
-
table.setDensity =
|
|
3094
|
+
(_2 = statefulTableOptions.onColumnFilterFnsChange) !== null && _2 !== void 0 ? _2 : setColumnFilterFns;
|
|
3095
|
+
table.setDensity =
|
|
3096
|
+
(_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
3097
|
table.setDraggingColumn =
|
|
2792
|
-
(
|
|
3098
|
+
(_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
3099
|
table.setDraggingRow =
|
|
2794
|
-
(
|
|
3100
|
+
(_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
3101
|
table.setEditingCell =
|
|
2796
|
-
(
|
|
3102
|
+
(_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
3103
|
table.setEditingRow =
|
|
2798
|
-
(
|
|
2799
|
-
table.setFilters = (
|
|
3104
|
+
(_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 }))));
|
|
3105
|
+
table.setFilters = (_8 = statefulTableOptions.onFiltersChange) !== null && _8 !== void 0 ? _8 : setFilters;
|
|
2800
3106
|
table.setGlobalFilterFn =
|
|
2801
|
-
(
|
|
3107
|
+
(_9 = statefulTableOptions.onGlobalFilterFnChange) !== null && _9 !== void 0 ? _9 : setGlobalFilterFn;
|
|
2802
3108
|
table.setHoveredColumn =
|
|
2803
|
-
(
|
|
3109
|
+
(_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
3110
|
table.setHoveredRow =
|
|
2805
|
-
(
|
|
2806
|
-
table.setSavedFilters =
|
|
3111
|
+
(_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 }))));
|
|
3112
|
+
table.setSavedFilters = (updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { savedFilters: updater instanceof Function ? updater(prev.savedFilters) : updater })));
|
|
2807
3113
|
table.setShowAlertBanner =
|
|
2808
|
-
(
|
|
3114
|
+
(_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
3115
|
table._showAdvancedFiltersSetterRef = showAdvancedFiltersSetterRef;
|
|
2810
3116
|
table.setShowAdvancedFilters =
|
|
2811
|
-
(
|
|
3117
|
+
(_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
3118
|
table.setShowColumnFilters =
|
|
2813
|
-
(
|
|
3119
|
+
(_14 = statefulTableOptions.onShowColumnFiltersChange) !== null && _14 !== void 0 ? _14 : ((updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { showColumnFilters: updater instanceof Function
|
|
3120
|
+
? updater(prev.showColumnFilters)
|
|
3121
|
+
: updater }))));
|
|
2814
3122
|
table.setShowGlobalFilter =
|
|
2815
|
-
(
|
|
2816
|
-
|
|
3123
|
+
(_15 = statefulTableOptions.onShowGlobalFilterChange) !== null && _15 !== void 0 ? _15 : ((updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { showGlobalFilter: updater instanceof Function
|
|
3124
|
+
? updater(prev.showGlobalFilter)
|
|
3125
|
+
: updater }))));
|
|
3126
|
+
table.setShowProgressBars = (updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { showProgressBars: updater instanceof Function ? updater(prev.showProgressBars) : updater })));
|
|
2817
3127
|
table.setShowToolbarDropZone =
|
|
2818
|
-
(
|
|
2819
|
-
|
|
3128
|
+
(_16 = statefulTableOptions.onShowToolbarDropZoneChange) !== null && _16 !== void 0 ? _16 : ((updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { showToolbarDropZone: updater instanceof Function
|
|
3129
|
+
? updater(prev.showToolbarDropZone)
|
|
3130
|
+
: updater }))));
|
|
3131
|
+
table.setNewEntryModal = (updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { newEntryModal: updater instanceof Function ? updater(prev.newEntryModal) : updater })));
|
|
2820
3132
|
table.setRowReorderingSelection =
|
|
2821
|
-
(
|
|
3133
|
+
(_17 = statefulTableOptions.onRowReorderingSelectionChange) !== null && _17 !== void 0 ? _17 : ((updater) => uiStore.set((prev) => (Object.assign(Object.assign({}, prev), { rowReorderingSelection: updater instanceof Function
|
|
3134
|
+
? updater(prev.rowReorderingSelection)
|
|
3135
|
+
: updater }))));
|
|
2822
3136
|
table.addRow = handleAddRow({
|
|
2823
3137
|
setRowsState,
|
|
2824
3138
|
getRowId: resolveRowId,
|
|
@@ -2867,7 +3181,8 @@ const extraIndexRangeExtractor = (range, draggingIndex) => {
|
|
|
2867
3181
|
const useMRT_ColumnVirtualizer = (table) => {
|
|
2868
3182
|
var _a, _b, _c, _d;
|
|
2869
3183
|
const { getState, options: { columnVirtualizerInstanceRef, columnVirtualizerOptions, enableColumnPinning, enableColumnVirtualization, }, refs: { tableContainerRef }, } = table;
|
|
2870
|
-
const { columnPinning, columnVisibility
|
|
3184
|
+
const { columnPinning, columnVisibility } = getState();
|
|
3185
|
+
const draggingColumnId = useMRT_SliceValue(table._dragStore, (s) => { var _a; return (_a = s.draggingColumn) === null || _a === void 0 ? void 0 : _a.id; });
|
|
2871
3186
|
if (!enableColumnVirtualization)
|
|
2872
3187
|
return undefined;
|
|
2873
3188
|
const columnVirtualizerProps = parseFromValuesOrFunc(columnVirtualizerOptions, {
|
|
@@ -2885,9 +3200,9 @@ const useMRT_ColumnVirtualizer = (table) => {
|
|
|
2885
3200
|
: [[], []], [columnPinning, columnVisibility, enableColumnPinning]);
|
|
2886
3201
|
const numPinnedLeft = leftPinnedIndexes.length;
|
|
2887
3202
|
const numPinnedRight = rightPinnedIndexes.length;
|
|
2888
|
-
const draggingColumnIndex = react.useMemo(() =>
|
|
2889
|
-
? visibleColumns.findIndex((c) => c.id ===
|
|
2890
|
-
: undefined, [
|
|
3203
|
+
const draggingColumnIndex = react.useMemo(() => draggingColumnId
|
|
3204
|
+
? visibleColumns.findIndex((c) => c.id === draggingColumnId)
|
|
3205
|
+
: undefined, [draggingColumnId]);
|
|
2891
3206
|
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
3207
|
const newIndexes = extraIndexRangeExtractor(range, draggingColumnIndex);
|
|
2893
3208
|
if (!numPinnedLeft && !numPinnedRight) {
|
|
@@ -2945,7 +3260,9 @@ const useMRT_Rows = (table) => {
|
|
|
2945
3260
|
|
|
2946
3261
|
const useMRT_RowVirtualizer = (table, rows) => {
|
|
2947
3262
|
const { getRowModel, getState, options: { enableRowVirtualization, renderDetailPanel, rowVirtualizerInstanceRef, rowVirtualizerOptions, }, refs: { tableContainerRef }, } = table;
|
|
2948
|
-
const {
|
|
3263
|
+
const { expanded } = getState();
|
|
3264
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
3265
|
+
const draggingRowId = useMRT_SliceValue(table._dragStore, (s) => { var _a; return (_a = s.draggingRow) === null || _a === void 0 ? void 0 : _a.id; });
|
|
2949
3266
|
if (!enableRowVirtualization)
|
|
2950
3267
|
return undefined;
|
|
2951
3268
|
const rowVirtualizerProps = parseFromValuesOrFunc(rowVirtualizerOptions, {
|
|
@@ -2955,9 +3272,9 @@ const useMRT_RowVirtualizer = (table, rows) => {
|
|
|
2955
3272
|
/**
|
|
2956
3273
|
* when filtering, should find the correct index in filtered rows
|
|
2957
3274
|
*/
|
|
2958
|
-
const draggingRowIndex = react.useMemo(() =>
|
|
2959
|
-
? realRows.findIndex((r) => r.id ===
|
|
2960
|
-
: undefined, [realRows,
|
|
3275
|
+
const draggingRowIndex = react.useMemo(() => draggingRowId
|
|
3276
|
+
? realRows.findIndex((r) => r.id === draggingRowId)
|
|
3277
|
+
: undefined, [realRows, draggingRowId]);
|
|
2961
3278
|
const rowCount = realRows.length;
|
|
2962
3279
|
//matches the defaultRowHeight assumption in MRT_TableBodyRow so the
|
|
2963
3280
|
//initial estimate (before measureElement corrects it for dynamic content)
|
|
@@ -3953,26 +4270,6 @@ const DimensionColumnResolver = {
|
|
|
3953
4270
|
activeFilterRenderer: DimensionActiveFilterItem,
|
|
3954
4271
|
};
|
|
3955
4272
|
|
|
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
4273
|
const DEFAULT_FIELD_SIZE$4 = 'small';
|
|
3977
4274
|
const MRT_FormEnumInput = ({ name, columnDef, fieldConfig, }) => {
|
|
3978
4275
|
var _a, _b, _c;
|
|
@@ -4005,6 +4302,26 @@ const MRT_FormEnumInput = ({ name, columnDef, fieldConfig, }) => {
|
|
|
4005
4302
|
} }));
|
|
4006
4303
|
};
|
|
4007
4304
|
|
|
4305
|
+
const getEnumLabelByValue = (value, enumOptions) => {
|
|
4306
|
+
var _a;
|
|
4307
|
+
const normalizedValue = String(value !== null && value !== void 0 ? value : '');
|
|
4308
|
+
const matchingOption = enumOptions.find((option) => option.value === normalizedValue);
|
|
4309
|
+
return (_a = matchingOption === null || matchingOption === void 0 ? void 0 : matchingOption.label) !== null && _a !== void 0 ? _a : normalizedValue;
|
|
4310
|
+
};
|
|
4311
|
+
const EnumActiveFilterItem = (table, rule) => {
|
|
4312
|
+
var _a, _b;
|
|
4313
|
+
if (typeof rule.value !== 'string' && !Array.isArray(rule.value))
|
|
4314
|
+
return null;
|
|
4315
|
+
const column = getFilterColumn(table, rule.columnId);
|
|
4316
|
+
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 : [];
|
|
4317
|
+
if (rule.operator === 'isAnyOf' && Array.isArray(rule.value)) {
|
|
4318
|
+
return (jsxRuntime.jsx(MRT_ActiveFilterItemContainer, { table: table, rule: rule, children: jsxRuntime.jsx(Typography, { variant: "body2", children: rule.value
|
|
4319
|
+
.map((value) => getEnumLabelByValue(value, enumOptions))
|
|
4320
|
+
.join(', ') }) }));
|
|
4321
|
+
}
|
|
4322
|
+
return (jsxRuntime.jsx(MRT_ActiveFilterItemContainer, { table: table, rule: rule, children: jsxRuntime.jsx(Typography, { variant: "body2", children: getEnumLabelByValue(rule.value, enumOptions) }) }));
|
|
4323
|
+
};
|
|
4324
|
+
|
|
4008
4325
|
// Resolver for enum column type.
|
|
4009
4326
|
// Renders only the human-readable label and provides select/multi-select filters.
|
|
4010
4327
|
const EnumColumnResolver = {
|
|
@@ -5291,7 +5608,8 @@ const MRT_ActiveFilters = ({ table, }) => {
|
|
|
5291
5608
|
const MRT_LinearProgressBar = (_a) => {
|
|
5292
5609
|
var { isTopToolbar, table } = _a, rest = __rest(_a, ["isTopToolbar", "table"]);
|
|
5293
5610
|
const { getState, options: { muiLinearProgressProps }, } = table;
|
|
5294
|
-
const { isSaving
|
|
5611
|
+
const { isSaving } = getState();
|
|
5612
|
+
const showProgressBars = useMRT_SliceValue(table._uiStore, (s) => s.showProgressBars);
|
|
5295
5613
|
const linearProgressProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiLinearProgressProps, {
|
|
5296
5614
|
isTopToolbar,
|
|
5297
5615
|
table,
|
|
@@ -5392,7 +5710,10 @@ const MRT_ToolbarDropZone = (_a) => {
|
|
|
5392
5710
|
var _b, _c;
|
|
5393
5711
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
5394
5712
|
const { getState, options: { enableGrouping, localization }, setHoveredColumn, setShowToolbarDropZone, } = table;
|
|
5395
|
-
const {
|
|
5713
|
+
const { grouping } = getState();
|
|
5714
|
+
const showToolbarDropZone = useMRT_SliceValue(table._uiStore, (s) => s.showToolbarDropZone);
|
|
5715
|
+
const draggingColumn = useMRT_SliceValue(table._dragStore, (s) => s.draggingColumn);
|
|
5716
|
+
const hoveredColumn = useMRT_SliceValue(table._hoverStore, (s) => s.hoveredColumn);
|
|
5396
5717
|
const handleDragEnter = (_event) => {
|
|
5397
5718
|
setHoveredColumn({ id: 'drop-zone' });
|
|
5398
5719
|
};
|
|
@@ -5703,7 +6024,8 @@ const MRT_FilterOptionMenu = (_a) => {
|
|
|
5703
6024
|
var _b, _c, _d, _e;
|
|
5704
6025
|
var { anchorEl, header, onSelect, setAnchorEl, setFilterValue, table } = _a, rest = __rest(_a, ["anchorEl", "header", "onSelect", "setAnchorEl", "setFilterValue", "table"]);
|
|
5705
6026
|
const { getState, options: { columnFilterModeOptions, globalFilterModeOptions, localization, mrtTheme: { menuBackgroundColor }, renderColumnFilterModeMenuItems, renderGlobalFilterModeMenuItems, }, setColumnFilterFns, setGlobalFilterFn, } = table;
|
|
5706
|
-
const {
|
|
6027
|
+
const { globalFilterFn } = getState();
|
|
6028
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
5707
6029
|
const { column } = header !== null && header !== void 0 ? header : {};
|
|
5708
6030
|
const { columnDef } = column !== null && column !== void 0 ? column : {};
|
|
5709
6031
|
const currentFilterValue = column === null || column === void 0 ? void 0 : column.getFilterValue();
|
|
@@ -5813,7 +6135,8 @@ const MRT_GlobalFilterTextField = (_a) => {
|
|
|
5813
6135
|
var _b;
|
|
5814
6136
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
5815
6137
|
const { getState, options: { enableGlobalFilterModes, icons: { CloseIcon, SearchIcon }, localization, manualFiltering, muiSearchTextFieldProps, }, refs: { searchInputRef }, setGlobalFilter, } = table;
|
|
5816
|
-
const { globalFilter
|
|
6138
|
+
const { globalFilter } = getState();
|
|
6139
|
+
const showGlobalFilter = useMRT_SliceValue(table._uiStore, (s) => s.showGlobalFilter);
|
|
5817
6140
|
const textFieldProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiSearchTextFieldProps, {
|
|
5818
6141
|
table,
|
|
5819
6142
|
})), rest);
|
|
@@ -5929,8 +6252,8 @@ function MRT_TableOptions(_a) {
|
|
|
5929
6252
|
}
|
|
5930
6253
|
|
|
5931
6254
|
const MRT_SavedFiltersButton = ({ onSelectFilter, table, }) => {
|
|
5932
|
-
const {
|
|
5933
|
-
const
|
|
6255
|
+
const { options: { localization, onDeleteSavedFilter, onSaveFilters }, setFilters, setSavedFilters, } = table;
|
|
6256
|
+
const savedFilters = useMRT_SliceValue(table._uiStore, (s) => s.savedFilters);
|
|
5934
6257
|
const savedFiltersList = Object.values(savedFilters);
|
|
5935
6258
|
const buttonRef = react.useRef(null);
|
|
5936
6259
|
const [menuOpen, setMenuOpen] = react.useState(false);
|
|
@@ -5982,24 +6305,10 @@ const MRT_NewEntryButton = (_a) => {
|
|
|
5982
6305
|
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
6306
|
};
|
|
5984
6307
|
|
|
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
6308
|
const MRT_ShowHideColumnsMenuItems = (_a) => {
|
|
5999
6309
|
var _b;
|
|
6000
6310
|
var { allColumns, column, hoveredColumn, isNestedColumns, setHoveredColumn, table } = _a, rest = __rest(_a, ["allColumns", "column", "hoveredColumn", "isNestedColumns", "setHoveredColumn", "table"]);
|
|
6001
|
-
const {
|
|
6002
|
-
const { columnOrder } = getState();
|
|
6311
|
+
const { options: { enableHiding, localization, mrtTheme: { draggingBorderColor }, }, } = table;
|
|
6003
6312
|
const { columnDef } = column;
|
|
6004
6313
|
const { columnDefType } = columnDef;
|
|
6005
6314
|
const switchChecked = column.getIsVisible();
|
|
@@ -6014,63 +6323,30 @@ const MRT_ShowHideColumnsMenuItems = (_a) => {
|
|
|
6014
6323
|
column.toggleVisibility();
|
|
6015
6324
|
}
|
|
6016
6325
|
};
|
|
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
6326
|
if (!columnDef.header || columnDef.visibleInShowHideMenu === false) {
|
|
6046
6327
|
return null;
|
|
6047
6328
|
}
|
|
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: {
|
|
6329
|
+
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
|
|
6330
|
+
? `2px dashed ${draggingBorderColor}`
|
|
6331
|
+
: '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
6332
|
display: 'flex',
|
|
6054
6333
|
flexWrap: 'nowrap',
|
|
6055
6334
|
gap: '8px',
|
|
6056
|
-
}, children:
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
typography: {
|
|
6062
|
-
sx: {
|
|
6063
|
-
mb: 0,
|
|
6064
|
-
opacity: columnDefType !== 'display' ? 1 : 0.5,
|
|
6065
|
-
},
|
|
6335
|
+
}, children: enableHiding ? (jsxRuntime.jsx(FormControlLabel, { checked: switchChecked, componentsProps: {
|
|
6336
|
+
typography: {
|
|
6337
|
+
sx: {
|
|
6338
|
+
mb: 0,
|
|
6339
|
+
opacity: columnDefType !== 'display' ? 1 : 0.5,
|
|
6066
6340
|
},
|
|
6067
|
-
},
|
|
6341
|
+
},
|
|
6342
|
+
}, 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
6343
|
};
|
|
6069
6344
|
|
|
6070
6345
|
const MRT_ShowHideColumnsMenu = (_a) => {
|
|
6071
6346
|
var { anchorEl, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "setAnchorEl", "table"]);
|
|
6072
|
-
const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible,
|
|
6073
|
-
const { columnOrder, columnPinning
|
|
6347
|
+
const { getAllColumns, getAllLeafColumns, getCenterLeafColumns, getIsAllColumnsVisible, getIsSomeColumnsVisible, getLeftLeafColumns, getRightLeafColumns, getState, options: { enableHiding, localization, mrtTheme: { menuBackgroundColor }, }, } = table;
|
|
6348
|
+
const { columnOrder, columnPinning } = getState();
|
|
6349
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
6074
6350
|
const handleToggleAllColumns = (value) => {
|
|
6075
6351
|
const updates = getAllLeafColumns()
|
|
6076
6352
|
.filter((column) => column.columnDef.enableHiding !== false)
|
|
@@ -6100,8 +6376,6 @@ const MRT_ShowHideColumnsMenu = (_a) => {
|
|
|
6100
6376
|
getRightLeafColumns(),
|
|
6101
6377
|
]);
|
|
6102
6378
|
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
6379
|
const [hoveredColumn, setHoveredColumn] = react.useState(null);
|
|
6106
6380
|
return (jsxRuntime.jsxs(Menu, Object.assign({ MenuListProps: {
|
|
6107
6381
|
dense: density === 'compact',
|
|
@@ -6113,7 +6387,7 @@ const MRT_ShowHideColumnsMenu = (_a) => {
|
|
|
6113
6387
|
justifyContent: 'space-between',
|
|
6114
6388
|
p: '0.5rem',
|
|
6115
6389
|
pt: 0,
|
|
6116
|
-
}, children: [enableHiding && (jsxRuntime.jsx(Button, { disabled: !getIsSomeColumnsVisible(), onClick: () => handleToggleAllColumns(false), children: localization.hideAll })),
|
|
6390
|
+
}, 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
6391
|
};
|
|
6118
6392
|
|
|
6119
6393
|
const MRT_ShowHideColumnsButton = (_a) => {
|
|
@@ -6167,8 +6441,8 @@ const getDensityOptions = ({ icons: { DensityLargeIcon, DensityMediumIcon, Densi
|
|
|
6167
6441
|
|
|
6168
6442
|
const MRT_ToggleDensePaddingMenu = (_a) => {
|
|
6169
6443
|
var { anchorEl, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "setAnchorEl", "table"]);
|
|
6170
|
-
const {
|
|
6171
|
-
const
|
|
6444
|
+
const { options: { icons, localization }, setDensity, } = table;
|
|
6445
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
6172
6446
|
const handleCloseMenu = () => {
|
|
6173
6447
|
setAnchorEl(null);
|
|
6174
6448
|
};
|
|
@@ -6196,8 +6470,8 @@ const MRT_ToggleDensePaddingMenu = (_a) => {
|
|
|
6196
6470
|
const MRT_ToggleDensePaddingButton = (_a) => {
|
|
6197
6471
|
var _b;
|
|
6198
6472
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
6199
|
-
const {
|
|
6200
|
-
const
|
|
6473
|
+
const { options: { icons: { DensityLargeIcon, DensityMediumIcon, DensitySmallIcon }, localization, }, } = table;
|
|
6474
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
6201
6475
|
const [anchorEl, setAnchorEl] = react.useState(null);
|
|
6202
6476
|
const handleOpenMenu = (event) => {
|
|
6203
6477
|
setAnchorEl(event.currentTarget);
|
|
@@ -6213,8 +6487,8 @@ const MRT_ToggleDensePaddingButton = (_a) => {
|
|
|
6213
6487
|
const MRT_ToggleFiltersButton = (_a) => {
|
|
6214
6488
|
var _b;
|
|
6215
6489
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
6216
|
-
const {
|
|
6217
|
-
const
|
|
6490
|
+
const { options: { icons: { FilterListIcon, FilterListOffIcon }, localization, }, setShowColumnFilters, } = table;
|
|
6491
|
+
const showColumnFilters = useMRT_SliceValue(table._uiStore, (s) => s.showColumnFilters);
|
|
6218
6492
|
const handleToggleShowFilters = () => {
|
|
6219
6493
|
setShowColumnFilters(!showColumnFilters);
|
|
6220
6494
|
};
|
|
@@ -6225,7 +6499,8 @@ const MRT_ToggleGlobalFilterButton = (_a) => {
|
|
|
6225
6499
|
var _b, _c;
|
|
6226
6500
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
6227
6501
|
const { getState, options: { icons: { SearchIcon, SearchOffIcon }, localization, }, refs: { searchInputRef }, setShowGlobalFilter, } = table;
|
|
6228
|
-
const { globalFilter
|
|
6502
|
+
const { globalFilter } = getState();
|
|
6503
|
+
const showGlobalFilter = useMRT_SliceValue(table._uiStore, (s) => s.showGlobalFilter);
|
|
6229
6504
|
const handleToggleSearch = () => {
|
|
6230
6505
|
setShowGlobalFilter(!showGlobalFilter);
|
|
6231
6506
|
queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
|
|
@@ -6280,7 +6555,7 @@ const MRT_TopToolbar = ({ table, }) => {
|
|
|
6280
6555
|
: undefined,
|
|
6281
6556
|
table,
|
|
6282
6557
|
};
|
|
6283
|
-
return (jsxRuntime.jsxs(Box, Object.assign({}, toolbarProps, { ref: (ref) => {
|
|
6558
|
+
return (jsxRuntime.jsxs(Box, Object.assign({ "data-testid": "top-toolbar" }, toolbarProps, { ref: (ref) => {
|
|
6284
6559
|
topToolbarRef.current = ref;
|
|
6285
6560
|
if (toolbarProps === null || toolbarProps === void 0 ? void 0 : toolbarProps.ref) {
|
|
6286
6561
|
// @ts-expect-error
|
|
@@ -6296,23 +6571,30 @@ const MRT_TopToolbar = ({ table, }) => {
|
|
|
6296
6571
|
px: '0.5rem',
|
|
6297
6572
|
width: '100%',
|
|
6298
6573
|
position: 'relative',
|
|
6299
|
-
}, children: [
|
|
6574
|
+
}, children: [jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [enableGlobalFilter && positionGlobalFilter === 'left' && (jsxRuntime.jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), enableToolbarInternalActions ? (jsxRuntime.jsxs(Box, { sx: {
|
|
6300
6575
|
alignItems: 'center',
|
|
6301
6576
|
display: 'flex',
|
|
6302
6577
|
flexWrap: 'wrap-reverse',
|
|
6303
6578
|
gap: '0.5rem',
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
|
|
6579
|
+
}, children: [enableGlobalFilter && positionGlobalFilter === 'right' && (jsxRuntime.jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))), jsxRuntime.jsx(MRT_ToolbarInternalButtons, { table: table })] })) : (enableGlobalFilter &&
|
|
6580
|
+
positionGlobalFilter === 'right' && (jsxRuntime.jsx(MRT_GlobalFilterTextField, Object.assign({}, globalFilterProps))))] }), jsxRuntime.jsx(ToolbarActions, { table: table }), jsxRuntime.jsxs(Box, { sx: {
|
|
6581
|
+
alignItems: 'center',
|
|
6582
|
+
display: 'flex',
|
|
6583
|
+
gap: '0.5rem',
|
|
6584
|
+
marginLeft: 'auto',
|
|
6585
|
+
}, children: [(_a = (enableToolbarInternalActions &&
|
|
6586
|
+
(renderTopToolbarCustomActions === null || renderTopToolbarCustomActions === void 0 ? void 0 : renderTopToolbarCustomActions({
|
|
6587
|
+
table,
|
|
6588
|
+
})))) !== 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
6589
|
['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
6590
|
};
|
|
6310
6591
|
|
|
6311
6592
|
const MRT_CellActionMenu = (_a) => {
|
|
6312
6593
|
var _b, _c;
|
|
6313
6594
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
6314
|
-
const {
|
|
6315
|
-
const
|
|
6595
|
+
const { options: { editDisplayMode, enableClickToCopy, enableEditing, icons: { ContentCopy, EditIcon }, localization, mrtTheme: { menuBackgroundColor }, renderCellActionMenuItems, }, refs: { actionCellRef }, } = table;
|
|
6596
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
6597
|
+
const actionCell = useMRT_SliceValue(table._uiStore, (s) => s.actionCell);
|
|
6316
6598
|
const cell = actionCell;
|
|
6317
6599
|
const { row } = cell;
|
|
6318
6600
|
const { column } = cell;
|
|
@@ -6359,10 +6641,10 @@ const MRT_EditCellTextField = (_a) => {
|
|
|
6359
6641
|
const { getState, options: { createDisplayMode, editDisplayMode, muiEditTextFieldProps }, refs: { editInputRefs }, setCreatingRow, setEditingCell, setEditingRow, } = table;
|
|
6360
6642
|
const { column, row } = cell;
|
|
6361
6643
|
const { columnDef } = column;
|
|
6362
|
-
const { creatingRow
|
|
6644
|
+
const { creatingRow } = getState();
|
|
6363
6645
|
const { editSelectOptions, editVariant } = columnDef;
|
|
6364
6646
|
const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
|
|
6365
|
-
const isEditing = (editingRow === null ||
|
|
6647
|
+
const isEditing = useMRT_SliceValue(table._uiStore, (s) => { var _a; return ((_a = s.editingRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
|
|
6366
6648
|
const [value, setValue] = react.useState(() => cell.getValue());
|
|
6367
6649
|
const [completesComposition, setCompletesComposition] = react.useState(true);
|
|
6368
6650
|
const textFieldProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditTextFieldProps, {
|
|
@@ -6455,7 +6737,8 @@ const MRT_EditRowModal = (_a) => {
|
|
|
6455
6737
|
var _b;
|
|
6456
6738
|
var { open, table } = _a, rest = __rest(_a, ["open", "table"]);
|
|
6457
6739
|
const { getState, options: { localization, muiCreateRowModalProps, muiEditRowDialogProps, onCreatingRowCancel, onEditingRowCancel, renderCreateRowDialogContent, renderEditRowDialogContent, }, setCreatingRow, setEditingRow, } = table;
|
|
6458
|
-
const { creatingRow
|
|
6740
|
+
const { creatingRow } = getState();
|
|
6741
|
+
const editingRow = useMRT_SliceValue(table._uiStore, (s) => s.editingRow);
|
|
6459
6742
|
const row = (creatingRow !== null && creatingRow !== void 0 ? creatingRow : editingRow);
|
|
6460
6743
|
const dialogProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiEditRowDialogProps, { row, table })), (creatingRow &&
|
|
6461
6744
|
parseFromValuesOrFunc(muiCreateRowModalProps, { row, table }))), rest);
|
|
@@ -6668,8 +6951,8 @@ const FormFieldControl = ({ columnId, columnDef, fieldConfig, table, }) => {
|
|
|
6668
6951
|
const MRT_NewEntryForm = ({ table, }) => {
|
|
6669
6952
|
var _a, _b, _c;
|
|
6670
6953
|
const methods = reactHookForm.useFormContext();
|
|
6671
|
-
const {
|
|
6672
|
-
const
|
|
6954
|
+
const { options: { formConfig, icons: { ExpandMoreIcon }, }, } = table;
|
|
6955
|
+
const newEntryModal = useMRT_SliceValue(table._uiStore, (s) => s.newEntryModal);
|
|
6673
6956
|
const mode = (_a = newEntryModal.mode) !== null && _a !== void 0 ? _a : 'create';
|
|
6674
6957
|
// Consumer controls the entire form body — skip all field calculations.
|
|
6675
6958
|
if (formConfig === null || formConfig === void 0 ? void 0 : formConfig.renderForm) {
|
|
@@ -6718,8 +7001,8 @@ const MRT_NewEntryFormActions = ({ table, }) => {
|
|
|
6718
7001
|
var _a, _b;
|
|
6719
7002
|
const methods = reactHookForm.useFormContext();
|
|
6720
7003
|
const { handleCancel, handleSave } = useMRT_NewEntryFormActions();
|
|
6721
|
-
const {
|
|
6722
|
-
const
|
|
7004
|
+
const { options: { formConfig, localization, muiNewEntryModalProps }, } = table;
|
|
7005
|
+
const newEntryModal = useMRT_SliceValue(table._uiStore, (s) => s.newEntryModal);
|
|
6723
7006
|
const mode = (_a = newEntryModal.mode) !== null && _a !== void 0 ? _a : 'create';
|
|
6724
7007
|
const resolvedModalProps = muiNewEntryModalProps !== null && muiNewEntryModalProps !== void 0 ? muiNewEntryModalProps : {};
|
|
6725
7008
|
const { footerProps, footerSx } = resolvedModalProps;
|
|
@@ -6740,8 +7023,8 @@ const RHF_FormProvider = (_a) => {
|
|
|
6740
7023
|
// Place this above any component that needs form state (fields body or actions footer).
|
|
6741
7024
|
const MRT_NewEntryFormProvider = ({ table, children, }) => {
|
|
6742
7025
|
var _a;
|
|
6743
|
-
const {
|
|
6744
|
-
const
|
|
7026
|
+
const { options: { formConfig }, setNewEntryModal, } = table;
|
|
7027
|
+
const newEntryModal = useMRT_SliceValue(table._uiStore, (s) => s.newEntryModal);
|
|
6745
7028
|
// Default to 'create' when mode is not explicitly provided.
|
|
6746
7029
|
const mode = (_a = newEntryModal.mode) !== null && _a !== void 0 ? _a : 'create';
|
|
6747
7030
|
const defaultValues = buildDefaultValues(table, newEntryModal.initialValues, mode);
|
|
@@ -6791,11 +7074,11 @@ const clampOffset = (value, fallback) => {
|
|
|
6791
7074
|
};
|
|
6792
7075
|
const MRT_NewEntryModal = ({ table, }) => {
|
|
6793
7076
|
const theme = styles.useTheme();
|
|
6794
|
-
const {
|
|
7077
|
+
const { options: { formConfig, icons: { CancelIcon }, localization, muiNewEntryModalProps, }, setNewEntryModal, } = table;
|
|
6795
7078
|
// Resolve muiNewEntryModalProps — plain object, defaults to empty object.
|
|
6796
7079
|
const resolvedModalProps = muiNewEntryModalProps !== null && muiNewEntryModalProps !== void 0 ? muiNewEntryModalProps : {};
|
|
6797
7080
|
const { title: titleOverride, contentContainerSx, headerSx, headerProps, bodySx, bodyProps, modalSx, modalProps, closeButtonProps, disableHeader, position, headerComponents, } = resolvedModalProps;
|
|
6798
|
-
const
|
|
7081
|
+
const newEntryModal = useMRT_SliceValue(table._uiStore, (s) => s.newEntryModal);
|
|
6799
7082
|
// Whether the modal was opened in edit mode — determines the title.
|
|
6800
7083
|
const isEditMode = newEntryModal.mode === 'edit';
|
|
6801
7084
|
const handleClose = () => {
|
|
@@ -6945,10 +7228,19 @@ const MRT_TableBodyCell = (_a) => {
|
|
|
6945
7228
|
var _b, _c, _d, _e;
|
|
6946
7229
|
var { cell, numRows, rowRef, staticColumnIndex, staticRowIndex, table, theme } = _a, rest = __rest(_a, ["cell", "numRows", "rowRef", "staticColumnIndex", "staticRowIndex", "table", "theme"]);
|
|
6947
7230
|
const { getState, options: { columnResizeDirection, columnResizeMode, createDisplayMode, editDisplayMode, enableCellActions, enableClickToCopy, enableColumnOrdering, enableColumnPinning, enableGrouping, enableKeyboardShortcuts, layoutMode, mrtTheme: { draggingBorderColor }, muiSkeletonProps, muiTableBodyCellProps, }, setHoveredColumn, } = table;
|
|
6948
|
-
const {
|
|
7231
|
+
const { creatingRow, isLoading, showSkeletons } = getState();
|
|
7232
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
6949
7233
|
const { column, row } = cell;
|
|
6950
7234
|
const { columnDef } = column;
|
|
6951
7235
|
const { columnDefType } = columnDef;
|
|
7236
|
+
const isResizingThisColumn = useMRT_SliceValue(table._uiStore, (s) => s.columnSizingInfo.isResizingColumn === column.id);
|
|
7237
|
+
const isEditingRow = useMRT_SliceValue(table._uiStore, (s) => { var _a; return ((_a = s.editingRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
|
|
7238
|
+
const isActionCell = useMRT_SliceValue(table._uiStore, (s) => { var _a; return ((_a = s.actionCell) === null || _a === void 0 ? void 0 : _a.id) === cell.id; });
|
|
7239
|
+
const isEditingCell = useMRT_SliceValue(table._uiStore, (s) => { var _a; return ((_a = s.editingCell) === null || _a === void 0 ? void 0 : _a.id) === cell.id; });
|
|
7240
|
+
const isDraggingColumn = useMRT_SliceValue(table._dragStore, (s) => { var _a; return ((_a = s.draggingColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id; });
|
|
7241
|
+
const isDraggingRow = useMRT_SliceValue(table._dragStore, (s) => { var _a; return ((_a = s.draggingRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
|
|
7242
|
+
const isHoveredColumn = useMRT_SliceValue(table._hoverStore, (s) => { var _a; return ((_a = s.hoveredColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id; });
|
|
7243
|
+
const isHoveredRow = useMRT_SliceValue(table._hoverStore, (s) => { var _a; return ((_a = s.hoveredRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
|
|
6952
7244
|
const args = { cell, column, row, table };
|
|
6953
7245
|
const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyCellProps, args)), parseFromValuesOrFunc(columnDef.muiTableBodyCellProps, args)), rest);
|
|
6954
7246
|
const skeletonProps = parseFromValuesOrFunc(muiSkeletonProps, {
|
|
@@ -6967,14 +7259,10 @@ const MRT_TableBodyCell = (_a) => {
|
|
|
6967
7259
|
: Math.round(Math.random() * (size - size / 3) + size / 3));
|
|
6968
7260
|
}, [isLoading, showSkeletons]);
|
|
6969
7261
|
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
7262
|
const isFirstColumn = column.getIsFirstColumn();
|
|
6975
7263
|
const isLastColumn = column.getIsLastColumn();
|
|
6976
7264
|
const isLastRow = numRows && staticRowIndex === numRows - 1;
|
|
6977
|
-
const isResizingColumn =
|
|
7265
|
+
const isResizingColumn = isResizingThisColumn;
|
|
6978
7266
|
const showResizeBorder = isResizingColumn && columnResizeMode === 'onChange';
|
|
6979
7267
|
const borderStyle = showResizeBorder
|
|
6980
7268
|
? `2px solid ${draggingBorderColor} !important`
|
|
@@ -7007,11 +7295,11 @@ const MRT_TableBodyCell = (_a) => {
|
|
|
7007
7295
|
}
|
|
7008
7296
|
: undefined;
|
|
7009
7297
|
}, [
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
|
|
7298
|
+
isResizingThisColumn,
|
|
7299
|
+
isDraggingColumn,
|
|
7300
|
+
isDraggingRow,
|
|
7301
|
+
isHoveredColumn,
|
|
7302
|
+
isHoveredRow,
|
|
7015
7303
|
staticRowIndex,
|
|
7016
7304
|
]);
|
|
7017
7305
|
const isColumnPinned = enableColumnPinning &&
|
|
@@ -7020,9 +7308,7 @@ const MRT_TableBodyCell = (_a) => {
|
|
|
7020
7308
|
const isEditable = isCellEditable({ cell, table });
|
|
7021
7309
|
const isEditing = isEditable &&
|
|
7022
7310
|
!['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) &&
|
|
7311
|
+
(editDisplayMode === 'table' || isEditingRow || isEditingCell) &&
|
|
7026
7312
|
!row.getIsGrouped();
|
|
7027
7313
|
const isCreating = isEditable && createDisplayMode === 'row' && (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
|
|
7028
7314
|
const showClickToCopyButton = (parseFromValuesOrFunc(enableClickToCopy, cell) === true ||
|
|
@@ -7043,12 +7329,13 @@ const MRT_TableBodyCell = (_a) => {
|
|
|
7043
7329
|
openEditingCell({ cell, table });
|
|
7044
7330
|
};
|
|
7045
7331
|
const handleDragEnter = (e) => {
|
|
7046
|
-
var _a;
|
|
7332
|
+
var _a, _b;
|
|
7047
7333
|
(_a = tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.onDragEnter) === null || _a === void 0 ? void 0 : _a.call(tableCellProps, e);
|
|
7048
|
-
if (enableGrouping &&
|
|
7334
|
+
if (enableGrouping &&
|
|
7335
|
+
((_b = table._hoverStore.get().hoveredColumn) === null || _b === void 0 ? void 0 : _b.id) === 'drop-zone') {
|
|
7049
7336
|
setHoveredColumn(null);
|
|
7050
7337
|
}
|
|
7051
|
-
if (enableColumnOrdering && draggingColumn) {
|
|
7338
|
+
if (enableColumnOrdering && table._dragStore.get().draggingColumn) {
|
|
7052
7339
|
setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
|
|
7053
7340
|
}
|
|
7054
7341
|
};
|
|
@@ -7077,7 +7364,7 @@ const MRT_TableBodyCell = (_a) => {
|
|
|
7077
7364
|
});
|
|
7078
7365
|
};
|
|
7079
7366
|
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:
|
|
7367
|
+
outline: isActionCell ||
|
|
7081
7368
|
(editDisplayMode === 'cell' && isEditable) ||
|
|
7082
7369
|
(editDisplayMode === 'table' && (isCreating || isEditing))
|
|
7083
7370
|
? `1px solid ${theme.palette.grey[500]}`
|
|
@@ -7087,20 +7374,14 @@ const MRT_TableBodyCell = (_a) => {
|
|
|
7087
7374
|
? 'context-menu'
|
|
7088
7375
|
: isEditable && editDisplayMode === 'cell'
|
|
7089
7376
|
? 'pointer'
|
|
7090
|
-
: 'inherit', outline:
|
|
7377
|
+
: 'inherit', outline: isActionCell
|
|
7091
7378
|
? `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({
|
|
7379
|
+
: undefined, outlineOffset: '-1px', overflow: 'hidden', p: columnDefType === 'display'
|
|
7380
|
+
? 'var(--mrt-display-cell-p)'
|
|
7381
|
+
: 'var(--mrt-cell-p)', textOverflow: columnDefType !== 'display' ? 'ellipsis' : undefined, whiteSpace: row.getIsPinned() || density === 'compact' ? 'nowrap' : 'normal' }, getCommonMRTCellStyles({
|
|
7103
7382
|
column,
|
|
7383
|
+
isDraggingColumn,
|
|
7384
|
+
isHoveredColumn,
|
|
7104
7385
|
table,
|
|
7105
7386
|
tableCellProps,
|
|
7106
7387
|
theme,
|
|
@@ -7144,13 +7425,17 @@ const MRT_TableBodyRow = (_a) => {
|
|
|
7144
7425
|
var _b, _c, _d, _f;
|
|
7145
7426
|
var { columnVirtualizer, numRows, pinnedRowIds, row, rowVirtualizer, staticRowIndex, table, theme, virtualRow } = _a, rest = __rest(_a, ["columnVirtualizer", "numRows", "pinnedRowIds", "row", "rowVirtualizer", "staticRowIndex", "table", "theme", "virtualRow"]);
|
|
7146
7427
|
const { getState, options: { enableRowOrdering, enableRowPinning, enableStickyFooter, enableStickyHeader, layoutMode, memoMode, mrtTheme: { baseBackgroundColor, pinnedRowBackgroundColor, selectedRowBackgroundColor, }, muiTableBodyRowProps, renderDetailPanel, rowPinningDisplayMode, }, refs: { tableFooterRef, tableHeadRef }, setHoveredRow, } = table;
|
|
7147
|
-
const {
|
|
7428
|
+
const { rowPinning } = getState();
|
|
7429
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
7430
|
+
const editingCell = useMRT_SliceValue(table._uiStore, (s) => s.editingCell);
|
|
7431
|
+
const isEditingRow = useMRT_SliceValue(table._uiStore, (s) => { var _a; return ((_a = s.editingRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
|
|
7432
|
+
const isDraggingRow = useMRT_SliceValue(table._dragStore, (s) => { var _a; return ((_a = s.draggingRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
|
|
7433
|
+
const isHoveredRow = useMRT_SliceValue(table._hoverStore, (s) => { var _a; return ((_a = s.hoveredRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
|
|
7434
|
+
const isAnyDragging = useMRT_SliceValue(table._dragStore, (s) => !!s.draggingColumn || !!s.draggingRow);
|
|
7148
7435
|
const visibleCells = row.getVisibleCells();
|
|
7149
7436
|
const { virtualColumns, virtualPaddingLeft, virtualPaddingRight } = columnVirtualizer !== null && columnVirtualizer !== void 0 ? columnVirtualizer : {};
|
|
7150
7437
|
const isRowSelected = getIsRowSelected({ row, table });
|
|
7151
7438
|
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
7439
|
const tableRowProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableBodyRowProps, {
|
|
7155
7440
|
row,
|
|
7156
7441
|
staticRowIndex,
|
|
@@ -7176,7 +7461,7 @@ const MRT_TableBodyRow = (_a) => {
|
|
|
7176
7461
|
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
7462
|
const rowHeight = customRowHeight || defaultRowHeight;
|
|
7178
7463
|
const handleDragEnter = (_e) => {
|
|
7179
|
-
if (enableRowOrdering && draggingRow) {
|
|
7464
|
+
if (enableRowOrdering && table._dragStore.get().draggingRow) {
|
|
7180
7465
|
setHoveredRow(row);
|
|
7181
7466
|
}
|
|
7182
7467
|
};
|
|
@@ -7236,13 +7521,12 @@ const MRT_TableBodyRow = (_a) => {
|
|
|
7236
7521
|
table,
|
|
7237
7522
|
theme,
|
|
7238
7523
|
};
|
|
7239
|
-
const key =
|
|
7524
|
+
const key = cell.id;
|
|
7240
7525
|
return cell ? (memoMode === 'cells' &&
|
|
7241
7526
|
cell.column.columnDef.columnDefType === 'data' &&
|
|
7242
|
-
!
|
|
7243
|
-
!draggingRow &&
|
|
7527
|
+
!isAnyDragging &&
|
|
7244
7528
|
(editingCell === null || editingCell === void 0 ? void 0 : editingCell.id) !== cell.id &&
|
|
7245
|
-
|
|
7529
|
+
!isEditingRow ? (jsxRuntime.jsx(Memo_MRT_TableBodyCell, Object.assign({}, props), key)) : (jsxRuntime.jsx(MRT_TableBodyCell, Object.assign({}, props), key))) : null;
|
|
7246
7530
|
}), 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
7531
|
};
|
|
7248
7532
|
const Memo_MRT_TableBodyRow = react.memo(MRT_TableBodyRow, (prev, next) => prev.row === next.row && prev.staticRowIndex === next.staticRowIndex);
|
|
@@ -7320,7 +7604,7 @@ const MRT_TableBody = (_a) => {
|
|
|
7320
7604
|
staticRowIndex, virtualRow: rowVirtualizer
|
|
7321
7605
|
? rowOrVirtualRow
|
|
7322
7606
|
: undefined });
|
|
7323
|
-
const key =
|
|
7607
|
+
const key = row.id;
|
|
7324
7608
|
return memoMode === 'rows' ? (jsxRuntime.jsx(Memo_MRT_TableBodyRow, Object.assign({}, props), key)) : (jsxRuntime.jsx(MRT_TableBodyRow, Object.assign({}, props), key));
|
|
7325
7609
|
}) }))) })), !(rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('sticky')) &&
|
|
7326
7610
|
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 +7619,12 @@ const MRT_TableFooterCell = (_a) => {
|
|
|
7335
7619
|
var _b, _c, _d;
|
|
7336
7620
|
var { footer, staticColumnIndex, table } = _a, rest = __rest(_a, ["footer", "staticColumnIndex", "table"]);
|
|
7337
7621
|
const theme = styles.useTheme();
|
|
7338
|
-
const {
|
|
7339
|
-
const { density } = getState();
|
|
7622
|
+
const { options: { enableColumnPinning, muiTableFooterCellProps, enableKeyboardShortcuts, }, } = table;
|
|
7340
7623
|
const { column } = footer;
|
|
7341
7624
|
const { columnDef } = column;
|
|
7342
7625
|
const { columnDefType } = columnDef;
|
|
7626
|
+
const isDraggingColumn = useMRT_SliceValue(table._dragStore, (s) => { var _a; return ((_a = s.draggingColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id; });
|
|
7627
|
+
const isHoveredColumn = useMRT_SliceValue(table._hoverStore, (s) => { var _a; return ((_a = s.hoveredColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id; });
|
|
7343
7628
|
const isColumnPinned = enableColumnPinning &&
|
|
7344
7629
|
columnDef.columnDefType !== 'group' &&
|
|
7345
7630
|
column.getIsPinned();
|
|
@@ -7358,13 +7643,11 @@ const MRT_TableFooterCell = (_a) => {
|
|
|
7358
7643
|
? 'center'
|
|
7359
7644
|
: theme.direction === 'rtl'
|
|
7360
7645
|
? '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({
|
|
7646
|
+
: '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
7647
|
column,
|
|
7367
7648
|
header: footer,
|
|
7649
|
+
isDraggingColumn,
|
|
7650
|
+
isHoveredColumn,
|
|
7368
7651
|
table,
|
|
7369
7652
|
tableCellProps,
|
|
7370
7653
|
theme,
|
|
@@ -7439,7 +7722,9 @@ const MRT_ColumnActionMenu = (_a) => {
|
|
|
7439
7722
|
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
7723
|
const { column } = header;
|
|
7441
7724
|
const { columnDef } = column;
|
|
7442
|
-
const { columnSizing, columnVisibility
|
|
7725
|
+
const { columnSizing, columnVisibility } = getState();
|
|
7726
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
7727
|
+
const showColumnFilters = useMRT_SliceValue(table._uiStore, (s) => s.showColumnFilters);
|
|
7443
7728
|
const columnFilterValue = column.getFilterValue();
|
|
7444
7729
|
const [filterMenuAnchorEl, setFilterMenuAnchorEl] = react.useState(null);
|
|
7445
7730
|
const handleClearSort = () => {
|
|
@@ -7636,7 +7921,7 @@ const MRT_TableHeadCellGrabHandle = (_a) => {
|
|
|
7636
7921
|
var { column, table, tableHeadCellRef } = _a, rest = __rest(_a, ["column", "table", "tableHeadCellRef"]);
|
|
7637
7922
|
const { getState, options: { enableColumnOrdering, muiColumnDragHandleProps }, setColumnOrder, setColumnPinning, setDraggingColumn, setHoveredColumn, } = table;
|
|
7638
7923
|
const { columnDef } = column;
|
|
7639
|
-
const { columnOrder
|
|
7924
|
+
const { columnOrder } = getState();
|
|
7640
7925
|
const iconButtonProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiColumnDragHandleProps, { column, table })), parseFromValuesOrFunc(columnDef.muiColumnDragHandleProps, {
|
|
7641
7926
|
column,
|
|
7642
7927
|
table,
|
|
@@ -7655,6 +7940,8 @@ const MRT_TableHeadCellGrabHandle = (_a) => {
|
|
|
7655
7940
|
const handleDragEnd = (event) => {
|
|
7656
7941
|
var _a;
|
|
7657
7942
|
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
7943
|
+
const { hoveredColumn } = table._hoverStore.get();
|
|
7944
|
+
const { draggingColumn } = table._dragStore.get();
|
|
7658
7945
|
if ((hoveredColumn === null || hoveredColumn === void 0 ? void 0 : hoveredColumn.id) === 'drop-zone') {
|
|
7659
7946
|
column.toggleGrouping();
|
|
7660
7947
|
}
|
|
@@ -7675,30 +7962,110 @@ const MRT_TableHeadCellGrabHandle = (_a) => {
|
|
|
7675
7962
|
};
|
|
7676
7963
|
|
|
7677
7964
|
const MRT_TableHeadCellResizeHandle = (_a) => {
|
|
7678
|
-
var _b;
|
|
7679
7965
|
var { header, table } = _a, rest = __rest(_a, ["header", "table"]);
|
|
7680
|
-
const {
|
|
7681
|
-
const
|
|
7966
|
+
const { options: { columnResizeDirection }, refs: { isResizingRef, resizeIndicatorRef, tableContainerRef, tableHeadCellRefs, tableRef, }, setColumnSizing, setColumnSizingInfo, } = table;
|
|
7967
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
7682
7968
|
const { column } = header;
|
|
7683
|
-
const handler = header.getResizeHandler();
|
|
7684
7969
|
const mx = density === 'compact'
|
|
7685
7970
|
? '-8px'
|
|
7686
7971
|
: density === 'comfortable'
|
|
7687
7972
|
? '-16px'
|
|
7688
7973
|
: '-24px';
|
|
7689
7974
|
const lr = column.columnDef.columnDefType === 'display' ? '4px' : '0';
|
|
7975
|
+
// Drives the resize purely through refs/DOM writes (CSS vars + the indicator line) so
|
|
7976
|
+
// dragging causes zero React renders; the only state write is the commit on release.
|
|
7977
|
+
const startResize = react.useCallback((startX) => {
|
|
7978
|
+
var _a, _b;
|
|
7979
|
+
const tableEl = tableRef.current;
|
|
7980
|
+
const containerEl = tableContainerRef.current;
|
|
7981
|
+
const indicatorEl = resizeIndicatorRef.current;
|
|
7982
|
+
const startSize = column.getSize();
|
|
7983
|
+
const dir = columnResizeDirection === 'rtl' ? -1 : 1;
|
|
7984
|
+
const minSize = (_a = column.columnDef.minSize) !== null && _a !== void 0 ? _a : 40;
|
|
7985
|
+
const maxSize = (_b = column.columnDef.maxSize) !== null && _b !== void 0 ? _b : 1000;
|
|
7986
|
+
let size = startSize;
|
|
7987
|
+
// Read the header cell's own rendered edge (rather than deriving a position from
|
|
7988
|
+
// clientX/scrollLeft) so the indicator always matches the real column border, even
|
|
7989
|
+
// if the browser clamps scrollLeft mid-drag because the table's scrollWidth shrank.
|
|
7990
|
+
const updateIndicator = () => {
|
|
7991
|
+
var _a;
|
|
7992
|
+
const cellEl = (_a = tableHeadCellRefs.current) === null || _a === void 0 ? void 0 : _a[column.id];
|
|
7993
|
+
if (!indicatorEl || !containerEl || !cellEl)
|
|
7994
|
+
return;
|
|
7995
|
+
const containerRect = containerEl.getBoundingClientRect();
|
|
7996
|
+
const cellRect = cellEl.getBoundingClientRect();
|
|
7997
|
+
const edge = columnResizeDirection === 'rtl' ? cellRect.left : cellRect.right;
|
|
7998
|
+
const x = edge - containerRect.left + containerEl.scrollLeft;
|
|
7999
|
+
indicatorEl.style.display = 'block';
|
|
8000
|
+
indicatorEl.style.transform = `translateX(${x}px)`;
|
|
8001
|
+
};
|
|
8002
|
+
isResizingRef.current = column.id;
|
|
8003
|
+
containerEl === null || containerEl === void 0 ? void 0 : containerEl.setAttribute('data-mrt-resizing', 'true');
|
|
8004
|
+
document.body.style.cursor = 'col-resize';
|
|
8005
|
+
document.body.style.userSelect = 'none';
|
|
8006
|
+
updateIndicator();
|
|
8007
|
+
const handleMove = (clientX) => {
|
|
8008
|
+
size = Math.min(Math.max(startSize + dir * (clientX - startX), minSize), maxSize);
|
|
8009
|
+
if (tableEl) {
|
|
8010
|
+
tableEl.style.setProperty(`--header-${parseCSSVarId(header.id)}-size`, `${size}`);
|
|
8011
|
+
tableEl.style.setProperty(`--col-${parseCSSVarId(column.id)}-size`, `${size}`);
|
|
8012
|
+
}
|
|
8013
|
+
updateIndicator();
|
|
8014
|
+
};
|
|
8015
|
+
const handleMouseMove = (e) => handleMove(e.clientX);
|
|
8016
|
+
const handleTouchMove = (e) => {
|
|
8017
|
+
var _a;
|
|
8018
|
+
const touchX = (_a = e.touches[0]) === null || _a === void 0 ? void 0 : _a.clientX;
|
|
8019
|
+
if (touchX == null)
|
|
8020
|
+
return;
|
|
8021
|
+
e.preventDefault();
|
|
8022
|
+
handleMove(touchX);
|
|
8023
|
+
};
|
|
8024
|
+
const handleEnd = () => {
|
|
8025
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
|
8026
|
+
document.removeEventListener('mouseup', handleEnd);
|
|
8027
|
+
document.removeEventListener('touchmove', handleTouchMove);
|
|
8028
|
+
document.removeEventListener('touchend', handleEnd);
|
|
8029
|
+
isResizingRef.current = false;
|
|
8030
|
+
containerEl === null || containerEl === void 0 ? void 0 : containerEl.removeAttribute('data-mrt-resizing');
|
|
8031
|
+
document.body.style.cursor = '';
|
|
8032
|
+
document.body.style.userSelect = '';
|
|
8033
|
+
if (indicatorEl)
|
|
8034
|
+
indicatorEl.style.display = 'none';
|
|
8035
|
+
setColumnSizing((old) => (Object.assign(Object.assign({}, old), { [column.id]: size })));
|
|
8036
|
+
};
|
|
8037
|
+
document.addEventListener('mousemove', handleMouseMove);
|
|
8038
|
+
document.addEventListener('mouseup', handleEnd);
|
|
8039
|
+
document.addEventListener('touchmove', handleTouchMove, {
|
|
8040
|
+
passive: false,
|
|
8041
|
+
});
|
|
8042
|
+
document.addEventListener('touchend', handleEnd);
|
|
8043
|
+
}, [
|
|
8044
|
+
column,
|
|
8045
|
+
columnResizeDirection,
|
|
8046
|
+
header.id,
|
|
8047
|
+
isResizingRef,
|
|
8048
|
+
resizeIndicatorRef,
|
|
8049
|
+
setColumnSizing,
|
|
8050
|
+
tableContainerRef,
|
|
8051
|
+
tableHeadCellRefs,
|
|
8052
|
+
tableRef,
|
|
8053
|
+
]);
|
|
7690
8054
|
return (jsxRuntime.jsx(Box, { className: "Mui-TableHeadCell-ResizeHandle-Wrapper", onDoubleClick: () => {
|
|
7691
8055
|
setColumnSizingInfo((old) => (Object.assign(Object.assign({}, old), { isResizingColumn: false })));
|
|
7692
8056
|
column.resetSize();
|
|
7693
|
-
}, onMouseDown:
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
|
|
8057
|
+
}, onMouseDown: (e) => {
|
|
8058
|
+
e.preventDefault();
|
|
8059
|
+
startResize(e.clientX);
|
|
8060
|
+
}, onTouchStart: (e) => {
|
|
8061
|
+
var _a;
|
|
8062
|
+
const touchX = (_a = e.touches[0]) === null || _a === void 0 ? void 0 : _a.clientX;
|
|
8063
|
+
if (touchX != null)
|
|
8064
|
+
startResize(touchX);
|
|
7698
8065
|
}, sx: (theme) => ({
|
|
7699
8066
|
'&:active > hr': {
|
|
7700
8067
|
backgroundColor: theme.palette.info.main,
|
|
7701
|
-
opacity:
|
|
8068
|
+
opacity: 1,
|
|
7702
8069
|
},
|
|
7703
8070
|
cursor: 'col-resize',
|
|
7704
8071
|
left: columnResizeDirection === 'rtl' ? lr : undefined,
|
|
@@ -7750,12 +8117,16 @@ const MRT_TableHeadCell = (_a) => {
|
|
|
7750
8117
|
var _b, _c, _d;
|
|
7751
8118
|
var { columnVirtualizer, header, staticColumnIndex, table } = _a, rest = __rest(_a, ["columnVirtualizer", "header", "staticColumnIndex", "table"]);
|
|
7752
8119
|
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;
|
|
8120
|
+
const { getState, options: { columnResizeDirection, columnResizeMode, enableKeyboardShortcuts, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { isResizingRef, tableHeadCellRefs }, setHoveredColumn, } = table;
|
|
7754
8121
|
const [isColumnCellHovered, setIsColumnCellHovered] = react.useState(false);
|
|
7755
|
-
const {
|
|
8122
|
+
const { grouping } = getState();
|
|
8123
|
+
const showColumnFilters = useMRT_SliceValue(table._uiStore, (s) => s.showColumnFilters);
|
|
7756
8124
|
const { column } = header;
|
|
7757
8125
|
const { columnDef } = column;
|
|
7758
8126
|
const { columnDefType } = columnDef;
|
|
8127
|
+
const isResizingThisColumn = useMRT_SliceValue(table._uiStore, (s) => s.columnSizingInfo.isResizingColumn === column.id);
|
|
8128
|
+
const isDraggingColumn = useMRT_SliceValue(table._dragStore, (s) => { var _a; return ((_a = s.draggingColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id; });
|
|
8129
|
+
const isHoveredColumn = useMRT_SliceValue(table._hoverStore, (s) => { var _a; return ((_a = s.hoveredColumn) === null || _a === void 0 ? void 0 : _a.id) === column.id; });
|
|
7759
8130
|
const tableCellProps = Object.assign(Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableHeadCellProps, { column, table })), parseFromValuesOrFunc(columnDef.muiTableHeadCellProps, {
|
|
7760
8131
|
column,
|
|
7761
8132
|
table,
|
|
@@ -7783,14 +8154,14 @@ const MRT_TableHeadCell = (_a) => {
|
|
|
7783
8154
|
return pl;
|
|
7784
8155
|
}, [showColumnActions, showDragHandle]);
|
|
7785
8156
|
const draggingBorders = react.useMemo(() => {
|
|
7786
|
-
const showResizeBorder =
|
|
8157
|
+
const showResizeBorder = isResizingThisColumn &&
|
|
7787
8158
|
columnResizeMode === 'onChange' &&
|
|
7788
8159
|
!header.subHeaders.length;
|
|
7789
8160
|
const borderStyle = showResizeBorder
|
|
7790
8161
|
? `2px solid ${draggingBorderColor} !important`
|
|
7791
|
-
:
|
|
8162
|
+
: isDraggingColumn
|
|
7792
8163
|
? `1px dashed ${theme.palette.grey[500]}`
|
|
7793
|
-
:
|
|
8164
|
+
: isHoveredColumn
|
|
7794
8165
|
? `2px dashed ${draggingBorderColor}`
|
|
7795
8166
|
: undefined;
|
|
7796
8167
|
if (showResizeBorder) {
|
|
@@ -7805,12 +8176,16 @@ const MRT_TableHeadCell = (_a) => {
|
|
|
7805
8176
|
borderTop: borderStyle,
|
|
7806
8177
|
}
|
|
7807
8178
|
: undefined;
|
|
7808
|
-
}, [
|
|
8179
|
+
}, [isDraggingColumn, isHoveredColumn, isResizingThisColumn]);
|
|
7809
8180
|
const handleDragEnter = (_e) => {
|
|
7810
|
-
|
|
8181
|
+
var _a;
|
|
8182
|
+
if (enableGrouping &&
|
|
8183
|
+
((_a = table._hoverStore.get().hoveredColumn) === null || _a === void 0 ? void 0 : _a.id) === 'drop-zone') {
|
|
7811
8184
|
setHoveredColumn(null);
|
|
7812
8185
|
}
|
|
7813
|
-
if (enableColumnOrdering &&
|
|
8186
|
+
if (enableColumnOrdering &&
|
|
8187
|
+
table._dragStore.get().draggingColumn &&
|
|
8188
|
+
columnDefType !== 'group') {
|
|
7814
8189
|
setHoveredColumn(columnDef.enableColumnOrdering !== false ? column : null);
|
|
7815
8190
|
}
|
|
7816
8191
|
};
|
|
@@ -7831,7 +8206,7 @@ const MRT_TableHeadCell = (_a) => {
|
|
|
7831
8206
|
};
|
|
7832
8207
|
// Toggle the column cell hover state, but only when not actively resizing a column
|
|
7833
8208
|
const handleColumnCellHoverToggle = (isHovered) => {
|
|
7834
|
-
if (!
|
|
8209
|
+
if (!isResizingRef.current) {
|
|
7835
8210
|
setIsColumnCellHovered(isHovered);
|
|
7836
8211
|
}
|
|
7837
8212
|
};
|
|
@@ -7859,25 +8234,17 @@ const MRT_TableHeadCell = (_a) => {
|
|
|
7859
8234
|
? column.getIsSorted() === 'asc'
|
|
7860
8235
|
? 'ascending'
|
|
7861
8236
|
: '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'
|
|
8237
|
+
: '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'
|
|
8238
|
+
? 'var(--mrt-head-display-cell-p)'
|
|
8239
|
+
: 'var(--mrt-cell-p)', pb: columnDefType === 'display'
|
|
7871
8240
|
? 0
|
|
7872
|
-
: showColumnFilters
|
|
8241
|
+
: showColumnFilters
|
|
7873
8242
|
? '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({
|
|
8243
|
+
: '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
8244
|
column,
|
|
7880
8245
|
header,
|
|
8246
|
+
isDraggingColumn,
|
|
8247
|
+
isHoveredColumn,
|
|
7881
8248
|
table,
|
|
7882
8249
|
tableCellProps,
|
|
7883
8250
|
theme,
|
|
@@ -7971,8 +8338,8 @@ const MRT_TableHead = (_a) => {
|
|
|
7971
8338
|
|
|
7972
8339
|
const MRT_Table = (_a) => {
|
|
7973
8340
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
7974
|
-
const { getFlatHeaders, getState, options: { columns, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, renderCaption, }, } = table;
|
|
7975
|
-
const { columnSizing,
|
|
8341
|
+
const { getFlatHeaders, getState, options: { columns, enableStickyHeader, enableTableFooter, enableTableHead, layoutMode, memoMode, muiTableProps, renderCaption, }, refs: { tableRef }, } = table;
|
|
8342
|
+
const { columnSizing, columnVisibility, density } = getState();
|
|
7976
8343
|
const tableProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableProps, { table })), rest);
|
|
7977
8344
|
const Caption = parseFromValuesOrFunc(renderCaption, { table });
|
|
7978
8345
|
const columnSizeVars = react.useMemo(() => {
|
|
@@ -7985,13 +8352,49 @@ const MRT_Table = (_a) => {
|
|
|
7985
8352
|
colSizes[`--col-${parseCSSVarId(header.column.id)}-size`] = colSize;
|
|
7986
8353
|
}
|
|
7987
8354
|
return colSizes;
|
|
7988
|
-
}, [columns, columnSizing,
|
|
8355
|
+
}, [columns, columnSizing, columnVisibility]);
|
|
8356
|
+
// Padding values keyed off density, read by cell/header/footer sx so density toggles
|
|
8357
|
+
// reuse existing emotion classes instead of generating new ones per cell.
|
|
8358
|
+
const densityVars = react.useMemo(() => ({
|
|
8359
|
+
'--mrt-cell-p': density === 'compact'
|
|
8360
|
+
? '0.5rem'
|
|
8361
|
+
: density === 'comfortable'
|
|
8362
|
+
? '1rem'
|
|
8363
|
+
: '1.5rem',
|
|
8364
|
+
'--mrt-display-cell-p': density === 'compact'
|
|
8365
|
+
? '0 0.5rem'
|
|
8366
|
+
: density === 'comfortable'
|
|
8367
|
+
? '0.5rem 0.75rem'
|
|
8368
|
+
: '1rem 1.25rem',
|
|
8369
|
+
'--mrt-head-display-cell-p': density === 'compact'
|
|
8370
|
+
? '0.5rem'
|
|
8371
|
+
: density === 'comfortable'
|
|
8372
|
+
? '0.75rem'
|
|
8373
|
+
: '1rem 1.25rem',
|
|
8374
|
+
'--mrt-head-cell-pb': density === 'compact' ? '0.4rem' : '0.6rem',
|
|
8375
|
+
'--mrt-head-cell-pt': density === 'compact'
|
|
8376
|
+
? '0.25rem'
|
|
8377
|
+
: density === 'comfortable'
|
|
8378
|
+
? '.75rem'
|
|
8379
|
+
: '1.25rem',
|
|
8380
|
+
}), [density]);
|
|
7989
8381
|
const columnVirtualizer = useMRT_ColumnVirtualizer(table);
|
|
7990
8382
|
const commonTableGroupProps = {
|
|
7991
8383
|
columnVirtualizer,
|
|
7992
8384
|
table,
|
|
7993
8385
|
};
|
|
7994
|
-
return (jsxRuntime.jsxs(Table, Object.assign({ stickyHeader: enableStickyHeader }, tableProps, {
|
|
8386
|
+
return (jsxRuntime.jsxs(Table, Object.assign({ stickyHeader: enableStickyHeader }, tableProps, { ref: (node) => {
|
|
8387
|
+
if (node) {
|
|
8388
|
+
tableRef.current = node;
|
|
8389
|
+
const userRef = tableProps === null || tableProps === void 0 ? void 0 : tableProps.ref;
|
|
8390
|
+
if (typeof userRef === 'function') {
|
|
8391
|
+
userRef(node);
|
|
8392
|
+
}
|
|
8393
|
+
else if (userRef) {
|
|
8394
|
+
userRef.current = node;
|
|
8395
|
+
}
|
|
8396
|
+
}
|
|
8397
|
+
}, 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
8398
|
};
|
|
7996
8399
|
|
|
7997
8400
|
const MRT_TableLoadingOverlay = (_a) => {
|
|
@@ -8017,8 +8420,11 @@ const MRT_TableLoadingOverlay = (_a) => {
|
|
|
8017
8420
|
|
|
8018
8421
|
const MRT_TableContainer = (_a) => {
|
|
8019
8422
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
8020
|
-
const { getState, options: { createDisplayMode, editDisplayMode, enableCellActions, enableRowVirtualization, muiTableContainerProps, }, refs: { tableContainerRef }, } = table;
|
|
8021
|
-
const {
|
|
8423
|
+
const { getState, options: { createDisplayMode, editDisplayMode, enableCellActions, enableRowVirtualization, muiTableContainerProps, }, refs: { resizeIndicatorRef, tableContainerRef }, } = table;
|
|
8424
|
+
const { creatingRow, isLoading, showLoadingOverlay } = getState();
|
|
8425
|
+
const actionCell = useMRT_SliceValue(table._uiStore, (s) => s.actionCell);
|
|
8426
|
+
const editingRow = useMRT_SliceValue(table._uiStore, (s) => s.editingRow);
|
|
8427
|
+
const newEntryModal = useMRT_SliceValue(table._uiStore, (s) => s.newEntryModal);
|
|
8022
8428
|
const loading = showLoadingOverlay !== false && (isLoading || showLoadingOverlay);
|
|
8023
8429
|
const tableContainerProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiTableContainerProps, {
|
|
8024
8430
|
table,
|
|
@@ -8033,9 +8439,23 @@ const MRT_TableContainer = (_a) => {
|
|
|
8033
8439
|
tableContainerProps.ref.current = node;
|
|
8034
8440
|
}
|
|
8035
8441
|
}
|
|
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
|
|
8442
|
+
}, 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
8443
|
? { contain: 'paint', willChange: 'transform' }
|
|
8038
|
-
: null)),
|
|
8444
|
+
: null)), { '&[data-mrt-resizing]': {
|
|
8445
|
+
userSelect: 'none',
|
|
8446
|
+
}, '&[data-mrt-resizing] .Mui-TableHeadCell-Content-Actions': {
|
|
8447
|
+
visibility: 'hidden',
|
|
8448
|
+
} }), 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: {
|
|
8449
|
+
bgcolor: 'primary.main',
|
|
8450
|
+
bottom: 0,
|
|
8451
|
+
display: 'none',
|
|
8452
|
+
left: 0,
|
|
8453
|
+
pointerEvents: 'none',
|
|
8454
|
+
position: 'absolute',
|
|
8455
|
+
top: 0,
|
|
8456
|
+
width: '2px',
|
|
8457
|
+
zIndex: 3,
|
|
8458
|
+
} }), 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
8459
|
};
|
|
8040
8460
|
|
|
8041
8461
|
const MRT_TablePaper = (_a) => {
|
|
@@ -8351,11 +8771,26 @@ const MaterialReactServerTable = (_a) => {
|
|
|
8351
8771
|
return (jsxRuntime.jsx(MaterialReactServerTableInstance, Object.assign({ config: config, saveState: saveState }, instanceProps)));
|
|
8352
8772
|
};
|
|
8353
8773
|
|
|
8774
|
+
const MRT_ColumnPinningButtons = (_a) => {
|
|
8775
|
+
var { column, table } = _a, rest = __rest(_a, ["column", "table"]);
|
|
8776
|
+
const { options: { icons: { PushPinIcon }, localization, }, } = table;
|
|
8777
|
+
const handlePinColumn = (pinDirection) => {
|
|
8778
|
+
column.pin(pinDirection);
|
|
8779
|
+
};
|
|
8780
|
+
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: {
|
|
8781
|
+
transform: 'rotate(90deg)',
|
|
8782
|
+
} }) }) }), jsxRuntime.jsx(Tooltip, { title: localization.pinToRight, children: jsxRuntime.jsx(IconButton, { onClick: () => handlePinColumn('right'), size: "small", children: jsxRuntime.jsx(PushPinIcon, { style: {
|
|
8783
|
+
transform: 'rotate(-90deg)',
|
|
8784
|
+
} }) }) })] })) })));
|
|
8785
|
+
};
|
|
8786
|
+
|
|
8354
8787
|
const MRT_ToolbarAlertBanner = (_a) => {
|
|
8355
8788
|
var _b, _c, _d;
|
|
8356
8789
|
var { stackAlertBanner, table } = _a, rest = __rest(_a, ["stackAlertBanner", "table"]);
|
|
8357
8790
|
const { getFilteredSelectedRowModel, getCoreRowModel, getState, options: { enableRowSelection, enableSelectAll, localization, manualPagination, muiToolbarAlertBannerChipProps, muiToolbarAlertBannerProps, positionToolbarAlertBanner, renderToolbarAlertBannerContent, rowCount, }, refs: { tablePaperRef }, } = table;
|
|
8358
|
-
const {
|
|
8791
|
+
const { grouping, rowSelection } = getState();
|
|
8792
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
8793
|
+
const showAlertBanner = useMRT_SliceValue(table._uiStore, (s) => s.showAlertBanner);
|
|
8359
8794
|
const alertProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiToolbarAlertBannerProps, {
|
|
8360
8795
|
table,
|
|
8361
8796
|
})), rest);
|
|
@@ -8469,6 +8904,9 @@ exports.Memo_MRT_TableBodyRow = Memo_MRT_TableBodyRow;
|
|
|
8469
8904
|
exports.RHF_FormProvider = RHF_FormProvider;
|
|
8470
8905
|
exports.buildDefaultValues = buildDefaultValues;
|
|
8471
8906
|
exports.cellKeyboardShortcuts = cellKeyboardShortcuts;
|
|
8907
|
+
exports.createDeleteAction = createDeleteAction;
|
|
8908
|
+
exports.createEditAction = createEditAction;
|
|
8909
|
+
exports.createExportAction = createExportAction;
|
|
8472
8910
|
exports.createMRTColumnHelper = createMRTColumnHelper;
|
|
8473
8911
|
exports.createRow = createRow;
|
|
8474
8912
|
exports.defaultDisplayColumnProps = defaultDisplayColumnProps;
|