@dooherceg/material-react-table 3.2.7 → 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 +77 -7
- package/dist/index.esm.js +1558 -1405
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1564 -1408
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,25 +1,40 @@
|
|
|
1
1
|
import { compareItems, rankItem, rankings } from '@tanstack/match-sorter-utils';
|
|
2
2
|
import { sortingFns, flexRender as flexRender$1, createRow as createRow$1, aggregationFns, filterFns, getCoreRowModel, getExpandedRowModel, getFacetedMinMaxValues, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getGroupedRowModel, getPaginationRowModel, getSortedRowModel, useReactTable, functionalUpdate } from '@tanstack/react-table';
|
|
3
|
-
import { useMemo,
|
|
4
|
-
import {
|
|
3
|
+
import { useMemo, useState, useSyncExternalStore, useCallback, useId, useReducer, useRef, useEffect, createContext, useContext, forwardRef, Fragment as Fragment$1, memo, useImperativeHandle } from 'react';
|
|
4
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
|
+
import CancelIcon from '@mui/icons-material/Cancel';
|
|
6
|
+
import Button from '@mui/material/Button';
|
|
7
|
+
import Dialog from '@mui/material/Dialog';
|
|
8
|
+
import DialogActions from '@mui/material/DialogActions';
|
|
9
|
+
import DialogContent from '@mui/material/DialogContent';
|
|
10
|
+
import DialogTitle from '@mui/material/DialogTitle';
|
|
5
11
|
import IconButton from '@mui/material/IconButton';
|
|
6
|
-
import
|
|
12
|
+
import Stack from '@mui/material/Stack';
|
|
13
|
+
import DeleteOutlineIcon from '@mui/icons-material/DeleteOutline';
|
|
14
|
+
import EditNoteIcon from '@mui/icons-material/EditNote';
|
|
15
|
+
import FileDownloadIcon from '@mui/icons-material/FileDownload';
|
|
16
|
+
import PrintIcon from '@mui/icons-material/Print';
|
|
17
|
+
import Checkbox from '@mui/material/Checkbox';
|
|
18
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
19
|
+
import Divider from '@mui/material/Divider';
|
|
20
|
+
import FormControl from '@mui/material/FormControl';
|
|
21
|
+
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
7
22
|
import Menu from '@mui/material/Menu';
|
|
23
|
+
import MenuItem from '@mui/material/MenuItem';
|
|
24
|
+
import Radio from '@mui/material/Radio';
|
|
25
|
+
import RadioGroup from '@mui/material/RadioGroup';
|
|
26
|
+
import { useTheme, darken, lighten, alpha } from '@mui/material/styles';
|
|
27
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
28
|
+
import Typography from '@mui/material/Typography';
|
|
29
|
+
import printJS from 'print-js';
|
|
30
|
+
import { enqueueSnackbar, closeSnackbar, SnackbarProvider, useSnackbar } from 'notistack';
|
|
8
31
|
import Box from '@mui/material/Box';
|
|
9
32
|
import ListItemIcon from '@mui/material/ListItemIcon';
|
|
10
|
-
import MenuItem from '@mui/material/MenuItem';
|
|
11
|
-
import Button from '@mui/material/Button';
|
|
12
|
-
import CircularProgress from '@mui/material/CircularProgress';
|
|
13
|
-
import { darken, lighten, alpha, useTheme } from '@mui/material/styles';
|
|
14
|
-
import Stack from '@mui/material/Stack';
|
|
15
33
|
import SubdirectoryArrowLeftIcon from '@mui/icons-material/SubdirectoryArrowLeft';
|
|
16
34
|
import VerticalAlignTopIcon from '@mui/icons-material/VerticalAlignTop';
|
|
17
|
-
import Checkbox from '@mui/material/Checkbox';
|
|
18
|
-
import Radio from '@mui/material/Radio';
|
|
19
35
|
import AddIcon from '@mui/icons-material/Add';
|
|
20
36
|
import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward';
|
|
21
37
|
import ArrowRightIcon from '@mui/icons-material/ArrowRight';
|
|
22
|
-
import CancelIcon from '@mui/icons-material/Cancel';
|
|
23
38
|
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
|
|
24
39
|
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
|
|
25
40
|
import ClearAllIcon from '@mui/icons-material/ClearAll';
|
|
@@ -51,15 +66,6 @@ import SortIcon from '@mui/icons-material/Sort';
|
|
|
51
66
|
import SyncAltIcon from '@mui/icons-material/SyncAlt';
|
|
52
67
|
import ViewColumnIcon from '@mui/icons-material/ViewColumn';
|
|
53
68
|
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
|
|
54
|
-
import FileDownloadIcon from '@mui/icons-material/FileDownload';
|
|
55
|
-
import PrintIcon from '@mui/icons-material/Print';
|
|
56
|
-
import Divider from '@mui/material/Divider';
|
|
57
|
-
import FormControl from '@mui/material/FormControl';
|
|
58
|
-
import FormControlLabel from '@mui/material/FormControlLabel';
|
|
59
|
-
import RadioGroup from '@mui/material/RadioGroup';
|
|
60
|
-
import Typography from '@mui/material/Typography';
|
|
61
|
-
import printJS from 'print-js';
|
|
62
|
-
import { enqueueSnackbar, closeSnackbar, SnackbarProvider, useSnackbar } from 'notistack';
|
|
63
69
|
import { defaultRangeExtractor, useVirtualizer } from '@tanstack/react-virtual';
|
|
64
70
|
import Drawer from '@mui/material/Drawer';
|
|
65
71
|
import TextField from '@mui/material/TextField';
|
|
@@ -104,10 +110,6 @@ import DeleteForeverIcon from '@mui/icons-material/DeleteForever';
|
|
|
104
110
|
import Switch from '@mui/material/Switch';
|
|
105
111
|
import Badge from '@mui/material/Badge';
|
|
106
112
|
import TableContainer from '@mui/material/TableContainer';
|
|
107
|
-
import Dialog from '@mui/material/Dialog';
|
|
108
|
-
import DialogActions from '@mui/material/DialogActions';
|
|
109
|
-
import DialogContent from '@mui/material/DialogContent';
|
|
110
|
-
import DialogTitle from '@mui/material/DialogTitle';
|
|
111
113
|
import Modal from '@mui/material/Modal';
|
|
112
114
|
import Accordion from '@mui/material/Accordion';
|
|
113
115
|
import AccordionDetails from '@mui/material/AccordionDetails';
|
|
@@ -721,99 +723,6 @@ const createRow = (table, originalRow, rowIndex = -1, depth = 0, subRows, parent
|
|
|
721
723
|
[getColumnId(col)]: '',
|
|
722
724
|
}))), rowIndex, depth, subRows, parentId);
|
|
723
725
|
|
|
724
|
-
const MRT_AggregationFns = Object.assign({}, aggregationFns);
|
|
725
|
-
|
|
726
|
-
const fuzzy = (row, columnId, filterValue, addMeta) => {
|
|
727
|
-
const itemRank = rankItem(row.getValue(columnId), filterValue, {
|
|
728
|
-
threshold: rankings.MATCHES,
|
|
729
|
-
});
|
|
730
|
-
addMeta(itemRank);
|
|
731
|
-
return itemRank.passed;
|
|
732
|
-
};
|
|
733
|
-
fuzzy.autoRemove = (val) => !val;
|
|
734
|
-
const contains = (row, id, filterValue) => {
|
|
735
|
-
var _a;
|
|
736
|
-
return !!((_a = row
|
|
737
|
-
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().includes(filterValue.toString().toLowerCase().trim()));
|
|
738
|
-
};
|
|
739
|
-
contains.autoRemove = (val) => !val;
|
|
740
|
-
const startsWith = (row, id, filterValue) => {
|
|
741
|
-
var _a;
|
|
742
|
-
return !!((_a = row
|
|
743
|
-
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().startsWith(filterValue.toString().toLowerCase().trim()));
|
|
744
|
-
};
|
|
745
|
-
startsWith.autoRemove = (val) => !val;
|
|
746
|
-
const endsWith = (row, id, filterValue) => {
|
|
747
|
-
var _a;
|
|
748
|
-
return !!((_a = row
|
|
749
|
-
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().endsWith(filterValue.toString().toLowerCase().trim()));
|
|
750
|
-
};
|
|
751
|
-
endsWith.autoRemove = (val) => !val;
|
|
752
|
-
const equals = (row, id, filterValue) => {
|
|
753
|
-
var _a;
|
|
754
|
-
return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) ===
|
|
755
|
-
filterValue.toString().toLowerCase().trim();
|
|
756
|
-
};
|
|
757
|
-
equals.autoRemove = (val) => !val;
|
|
758
|
-
const notEquals = (row, id, filterValue) => {
|
|
759
|
-
var _a;
|
|
760
|
-
return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) !==
|
|
761
|
-
filterValue.toString().toLowerCase().trim();
|
|
762
|
-
};
|
|
763
|
-
notEquals.autoRemove = (val) => !val;
|
|
764
|
-
const greaterThan = (row, id, filterValue) => {
|
|
765
|
-
var _a, _b, _c;
|
|
766
|
-
return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
|
767
|
-
? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) > +filterValue
|
|
768
|
-
: ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) > filterValue.toString().toLowerCase().trim();
|
|
769
|
-
};
|
|
770
|
-
greaterThan.autoRemove = (val) => !val;
|
|
771
|
-
const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
|
|
772
|
-
greaterThanOrEqualTo.autoRemove = (val) => !val;
|
|
773
|
-
const lessThan = (row, id, filterValue) => {
|
|
774
|
-
var _a, _b, _c;
|
|
775
|
-
return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
|
776
|
-
? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) < +filterValue
|
|
777
|
-
: ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) < filterValue.toString().toLowerCase().trim();
|
|
778
|
-
};
|
|
779
|
-
lessThan.autoRemove = (val) => !val;
|
|
780
|
-
const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
|
|
781
|
-
lessThanOrEqualTo.autoRemove = (val) => !val;
|
|
782
|
-
const between = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
|
|
783
|
-
greaterThan(row, id, filterValues[0])) &&
|
|
784
|
-
((!isNaN(+filterValues[0]) &&
|
|
785
|
-
!isNaN(+filterValues[1]) &&
|
|
786
|
-
+filterValues[0] > +filterValues[1]) ||
|
|
787
|
-
['', undefined].includes(filterValues[1]) ||
|
|
788
|
-
lessThan(row, id, filterValues[1]));
|
|
789
|
-
between.autoRemove = (val) => !val;
|
|
790
|
-
const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
|
|
791
|
-
greaterThanOrEqualTo(row, id, filterValues[0])) &&
|
|
792
|
-
((!isNaN(+filterValues[0]) &&
|
|
793
|
-
!isNaN(+filterValues[1]) &&
|
|
794
|
-
+filterValues[0] > +filterValues[1]) ||
|
|
795
|
-
['', undefined].includes(filterValues[1]) ||
|
|
796
|
-
lessThanOrEqualTo(row, id, filterValues[1]));
|
|
797
|
-
betweenInclusive.autoRemove = (val) => !val;
|
|
798
|
-
const empty = (row, id, _filterValue) => { var _a; return !((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
|
|
799
|
-
empty.autoRemove = (val) => !val;
|
|
800
|
-
const notEmpty = (row, id, _filterValue) => { var _a; return !!((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
|
|
801
|
-
notEmpty.autoRemove = (val) => !val;
|
|
802
|
-
const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
|
|
803
|
-
betweenInclusive,
|
|
804
|
-
contains,
|
|
805
|
-
empty,
|
|
806
|
-
endsWith,
|
|
807
|
-
equals,
|
|
808
|
-
fuzzy,
|
|
809
|
-
greaterThan,
|
|
810
|
-
greaterThanOrEqualTo,
|
|
811
|
-
lessThan,
|
|
812
|
-
lessThanOrEqualTo,
|
|
813
|
-
notEmpty,
|
|
814
|
-
notEquals,
|
|
815
|
-
startsWith });
|
|
816
|
-
|
|
817
726
|
/******************************************************************************
|
|
818
727
|
Copyright (c) Microsoft Corporation.
|
|
819
728
|
|
|
@@ -858,1413 +767,1659 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
858
767
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
859
768
|
};
|
|
860
769
|
|
|
861
|
-
|
|
862
|
-
const
|
|
863
|
-
|
|
770
|
+
function MRT_DeleteRowButton({ onClick, }) {
|
|
771
|
+
const iconButtonStyle = {
|
|
772
|
+
p: 0,
|
|
773
|
+
};
|
|
774
|
+
return (jsx(IconButton, { disableRipple: true, color: "error", sx: iconButtonStyle, onClick: onClick, children: jsx(DeleteOutlineIcon, {}) }));
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
const DeleteRowAction = ({ onDeleteConfirm, table, deleteConfirmation, }) => {
|
|
778
|
+
// Toolbar context — no specific row is targeted
|
|
779
|
+
const [open, setOpen] = useState(false);
|
|
780
|
+
const [deleting, setDeleting] = useState(false);
|
|
781
|
+
// Resolve deleteConfirmation — plain object, defaults to empty object.
|
|
782
|
+
const resolvedDeleteConfirmation = deleteConfirmation !== null && deleteConfirmation !== void 0 ? deleteConfirmation : {};
|
|
783
|
+
const { title: titleOverride, message: messageOverride, confirmButtonText: confirmButtonTextOverride, cancelButtonText: cancelButtonTextOverride, dialogSx, contentContainerSx, headerSx, titleSx, bodySx, footerSx, closeButtonProps, cancelButtonProps, confirmButtonProps, } = resolvedDeleteConfirmation;
|
|
784
|
+
// Consumer override takes priority over localization fallback.
|
|
785
|
+
const deleteConfirmationTitle = titleOverride !== null && titleOverride !== void 0 ? titleOverride : table.options.localization.deleteConfirmationTitle;
|
|
786
|
+
const deleteConfirmationMessage = messageOverride !== null && messageOverride !== void 0 ? messageOverride : table.options.localization.deleteConfirmationMessage;
|
|
787
|
+
const confirmButtonLabel = confirmButtonTextOverride !== null && confirmButtonTextOverride !== void 0 ? confirmButtonTextOverride : table.options.localization.deleteConfirmYes;
|
|
788
|
+
const cancelButtonLabel = cancelButtonTextOverride !== null && cancelButtonTextOverride !== void 0 ? cancelButtonTextOverride : table.options.localization.deleteConfirmNo;
|
|
789
|
+
const deletingLabel = table.options.localization.deleteConfirmDeleting;
|
|
790
|
+
const handleDeleteRowButtonClick = () => {
|
|
791
|
+
setOpen(true);
|
|
792
|
+
};
|
|
793
|
+
const handleConfirmDelete = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
794
|
+
setDeleting(true);
|
|
795
|
+
yield onDeleteConfirm();
|
|
796
|
+
setDeleting(false);
|
|
797
|
+
setOpen(false);
|
|
798
|
+
});
|
|
799
|
+
const handleClose = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
800
|
+
setOpen(false);
|
|
801
|
+
});
|
|
802
|
+
return (jsxs(Fragment, { children: [jsx(Dialog, { open: open, onClose: () => setOpen(false), keepMounted: true, "aria-describedby": "alert-dialog-slide-description", role: "alertdialog", sx: dialogSx, children: jsxs(Stack, { flexDirection: "column", height: "min-content", sx: contentContainerSx, children: [jsxs(Stack, { flexDirection: "row", alignItems: "center", justifyContent: "space-between", sx: Object.assign({ width: '100%' }, headerSx), children: [jsx(DialogTitle, { sx: Object.assign({ p: '0.7rem' }, titleSx), children: deleteConfirmationTitle }), jsx(DialogActions, { sx: {
|
|
803
|
+
p: '0.7rem',
|
|
804
|
+
}, children: jsx(IconButton, Object.assign({ color: "error", "aria-label": "close", onClick: handleClose }, closeButtonProps, { children: jsx(CancelIcon, {}) })) })] }), jsxs(Stack, { children: [jsx(DialogContent, { sx: Object.assign({ pr: '6rem' }, bodySx), children: deleteConfirmationMessage }), jsxs(DialogActions, { sx: footerSx, children: [jsx(Button, Object.assign({ onClick: () => setOpen(false), disabled: deleting, autoFocus: true, variant: "soft" }, cancelButtonProps, { children: cancelButtonLabel })), jsx(Button, Object.assign({ onClick: handleConfirmDelete, disabled: deleting, variant: "contained", color: "error" }, confirmButtonProps, { children: deleting ? deletingLabel : confirmButtonLabel }))] })] })] }) }), jsx(MRT_DeleteRowButton, { onClick: handleDeleteRowButtonClick })] }));
|
|
805
|
+
};
|
|
806
|
+
|
|
807
|
+
const createDeleteAction = (_a = {}) => {
|
|
808
|
+
var { onDelete, renderRow: customRenderRow, renderToolbar: customRenderToolbar, deleteConfirmation } = _a, rest = __rest(_a, ["onDelete", "renderRow", "renderToolbar", "deleteConfirmation"]);
|
|
809
|
+
// Default delete behavior used when the consumer does not provide a custom onDelete.
|
|
810
|
+
// Also exposed to custom onDelete through context.defaultOnDelete for composition.
|
|
811
|
+
const defaultOnDelete = (_a) => __awaiter(void 0, [_a], void 0, function* ({ rowsToDelete, table, }) {
|
|
812
|
+
var _b, _c;
|
|
813
|
+
// Nothing to delete, so exit early.
|
|
814
|
+
if (!rowsToDelete.length) {
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
yield ((_c = (_b = table.options).deleteRowsFn) === null || _c === void 0 ? void 0 : _c.call(_b, { rowsToDelete, table }));
|
|
818
|
+
});
|
|
819
|
+
// Single execution pipeline for every delete flow (row or toolbar).
|
|
820
|
+
// If a custom handler exists, it receives defaultOnDelete and decides when to call it.
|
|
821
|
+
const executeDelete = (context) => {
|
|
822
|
+
const executeDefaultDelete = () => defaultOnDelete(context);
|
|
823
|
+
if (onDelete) {
|
|
824
|
+
return onDelete(Object.assign(Object.assign({}, context), { defaultOnDelete: executeDefaultDelete }));
|
|
825
|
+
}
|
|
826
|
+
return executeDefaultDelete();
|
|
827
|
+
};
|
|
828
|
+
// Resolves selected rows from table state for toolbar-triggered delete.
|
|
829
|
+
const handleMultipleRowDelete = ({ table, }) => {
|
|
830
|
+
const rowsToDelete = table.getSelectedRowModel().rows;
|
|
831
|
+
return executeDelete({ table, rowsToDelete });
|
|
832
|
+
};
|
|
833
|
+
// Resolves only the active row for row-triggered delete.
|
|
834
|
+
const handleSingleRowDelete = ({ table, row, }) => {
|
|
835
|
+
return executeDelete({ table, rowsToDelete: [row] });
|
|
836
|
+
};
|
|
837
|
+
// Wraps row context into a zero-argument callback expected by row action UI.
|
|
838
|
+
const createRowDeleteExecutor = (context) => {
|
|
839
|
+
return () => {
|
|
840
|
+
void handleSingleRowDelete(context);
|
|
841
|
+
};
|
|
842
|
+
};
|
|
843
|
+
// Wraps toolbar context into a zero-argument callback expected by toolbar action UI.
|
|
844
|
+
const createToolbarDeleteExecutor = (context) => {
|
|
845
|
+
return () => {
|
|
846
|
+
void handleMultipleRowDelete(context);
|
|
847
|
+
};
|
|
848
|
+
};
|
|
849
|
+
// Uses custom row renderer when provided; otherwise renders default delete action UI.
|
|
850
|
+
const renderRowAction = (context) => {
|
|
851
|
+
const onRowDelete = createRowDeleteExecutor(context);
|
|
852
|
+
if (customRenderRow) {
|
|
853
|
+
return customRenderRow(Object.assign(Object.assign({}, context), { onDelete: onRowDelete }));
|
|
854
|
+
}
|
|
855
|
+
return (jsx(DeleteRowAction, { onDeleteConfirm: onRowDelete, table: context.table, deleteConfirmation: deleteConfirmation }));
|
|
856
|
+
};
|
|
857
|
+
// Uses custom toolbar renderer when provided; otherwise renders default delete action UI.
|
|
858
|
+
const renderToolbarAction = (context) => {
|
|
859
|
+
const onToolbarDelete = createToolbarDeleteExecutor(context);
|
|
860
|
+
if (customRenderToolbar) {
|
|
861
|
+
return customRenderToolbar(Object.assign(Object.assign({}, context), { onDelete: onToolbarDelete }));
|
|
862
|
+
}
|
|
863
|
+
return (jsx(DeleteRowAction, { onDeleteConfirm: onToolbarDelete, table: context.table }));
|
|
864
|
+
};
|
|
865
|
+
return Object.assign({ name: 'delete', renderRow: renderRowAction, renderToolbar: renderToolbarAction }, rest);
|
|
864
866
|
};
|
|
865
867
|
|
|
866
|
-
const
|
|
867
|
-
|
|
868
|
-
const { options: { icons: { ArrowRightIcon }, }, } = table;
|
|
869
|
-
return (jsxs(MenuItem, Object.assign({ sx: {
|
|
870
|
-
alignItems: 'center',
|
|
871
|
-
justifyContent: 'space-between',
|
|
872
|
-
minWidth: '120px',
|
|
873
|
-
my: 0,
|
|
874
|
-
py: '6px',
|
|
875
|
-
}, tabIndex: 0 }, rest, { children: [jsxs(Box, { sx: {
|
|
876
|
-
alignItems: 'center',
|
|
877
|
-
display: 'flex',
|
|
878
|
-
}, children: [jsx(ListItemIcon, { children: icon }), label] }), onOpenSubMenu && (jsx(IconButton, { onClick: (e) => onOpenSubMenu(e), onMouseEnter: (e) => onOpenSubMenu(e), size: "small", sx: { p: 0 }, children: jsx(ArrowRightIcon, {}) }))] })));
|
|
868
|
+
const MRT_EditRowButton = ({ onClick }) => {
|
|
869
|
+
return (jsx(IconButton, { sx: { p: 0 }, disableRipple: true, color: "primary", onClick: onClick, children: jsx(EditNoteIcon, {}) }));
|
|
879
870
|
};
|
|
880
871
|
|
|
881
|
-
const
|
|
882
|
-
|
|
883
|
-
const { options: { editDisplayMode, enableEditing, icons: { EditIcon }, localization, mrtTheme: { menuBackgroundColor }, renderRowActionMenuItems, }, } = table;
|
|
884
|
-
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
885
|
-
const menuItems = useMemo(() => {
|
|
886
|
-
const items = [];
|
|
887
|
-
const editItem = parseFromValuesOrFunc(enableEditing, row) &&
|
|
888
|
-
['modal', 'row'].includes(editDisplayMode) && (jsx(MRT_ActionMenuItem, { icon: jsx(EditIcon, {}), label: localization.edit, onClick: handleEdit, table: table }, 'edit'));
|
|
889
|
-
if (editItem)
|
|
890
|
-
items.push(editItem);
|
|
891
|
-
const rowActionMenuItems = renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
|
892
|
-
closeMenu: () => setAnchorEl(null),
|
|
893
|
-
row,
|
|
894
|
-
staticRowIndex,
|
|
895
|
-
table,
|
|
896
|
-
});
|
|
897
|
-
if (rowActionMenuItems === null || rowActionMenuItems === void 0 ? void 0 : rowActionMenuItems.length)
|
|
898
|
-
items.push(...rowActionMenuItems);
|
|
899
|
-
return items;
|
|
900
|
-
}, [renderRowActionMenuItems, row, staticRowIndex, table]);
|
|
901
|
-
if (!menuItems.length)
|
|
902
|
-
return null;
|
|
903
|
-
return (jsx(Menu, Object.assign({ MenuListProps: {
|
|
904
|
-
dense: density === 'compact',
|
|
905
|
-
sx: {
|
|
906
|
-
backgroundColor: menuBackgroundColor,
|
|
907
|
-
},
|
|
908
|
-
}, anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: menuItems })));
|
|
872
|
+
const EditRowAction = ({ onEditButtonClick, }) => {
|
|
873
|
+
return (jsx(Fragment, { children: jsx(MRT_EditRowButton, { onClick: onEditButtonClick }) }));
|
|
909
874
|
};
|
|
910
875
|
|
|
911
|
-
const
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
const isEditing = useMRT_SliceValue(table._uiStore, (s) => { var _a; return ((_a = s.editingRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
|
|
917
|
-
const handleCancel = () => {
|
|
918
|
-
if (isCreating) {
|
|
919
|
-
onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
|
|
920
|
-
setCreatingRow(null);
|
|
876
|
+
const createEditAction = ({ onEdit, renderRow: customRenderRow, } = {}) => {
|
|
877
|
+
const defaultOnEdit = (_a) => __awaiter(void 0, [_a], void 0, function* ({ rowToEdit, table, }) {
|
|
878
|
+
// Nothing to edit, so exit early.
|
|
879
|
+
if (!rowToEdit) {
|
|
880
|
+
return;
|
|
921
881
|
}
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
882
|
+
const { setNewEntryModal } = table;
|
|
883
|
+
const handleOpenEditModal = () => {
|
|
884
|
+
setNewEntryModal({
|
|
885
|
+
open: true,
|
|
886
|
+
mode: 'edit',
|
|
887
|
+
});
|
|
888
|
+
};
|
|
889
|
+
if (table.options.editRowFn) {
|
|
890
|
+
yield table.options.editRowFn({ rowToEdit, table });
|
|
891
|
+
return;
|
|
925
892
|
}
|
|
926
|
-
|
|
893
|
+
handleOpenEditModal();
|
|
894
|
+
});
|
|
895
|
+
const executeEdit = (context) => {
|
|
896
|
+
const executeDefaultEdit = () => defaultOnEdit(context);
|
|
897
|
+
if (onEdit) {
|
|
898
|
+
return onEdit(Object.assign(Object.assign({}, context), { defaultOnEdit: executeDefaultEdit }));
|
|
899
|
+
}
|
|
900
|
+
return executeDefaultEdit();
|
|
927
901
|
};
|
|
928
|
-
const
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
onCreatingRowSave === null || onCreatingRowSave === void 0 ? void 0 : onCreatingRowSave({
|
|
941
|
-
exitCreatingMode: () => setCreatingRow(null),
|
|
942
|
-
row,
|
|
943
|
-
table,
|
|
944
|
-
values: row._valuesCache,
|
|
945
|
-
});
|
|
946
|
-
else if (isEditing) {
|
|
947
|
-
onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
|
|
948
|
-
exitEditingMode: () => setEditingRow(null),
|
|
949
|
-
row,
|
|
950
|
-
table,
|
|
951
|
-
values: row === null || row === void 0 ? void 0 : row._valuesCache,
|
|
952
|
-
});
|
|
902
|
+
const handleEditRow = ({ table, row }) => {
|
|
903
|
+
return executeEdit({ table, rowToEdit: row });
|
|
904
|
+
};
|
|
905
|
+
const createEditRowExecutor = (context) => {
|
|
906
|
+
return () => {
|
|
907
|
+
void handleEditRow(context);
|
|
908
|
+
};
|
|
909
|
+
};
|
|
910
|
+
const renderRowAction = (context) => {
|
|
911
|
+
const onRowEdit = createEditRowExecutor(context);
|
|
912
|
+
if (customRenderRow) {
|
|
913
|
+
return customRenderRow(Object.assign(Object.assign({}, context), { onEdit: onRowEdit }));
|
|
953
914
|
}
|
|
915
|
+
return jsx(EditRowAction, { onEditButtonClick: onRowEdit });
|
|
954
916
|
};
|
|
955
|
-
return (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' ? (jsxs(Fragment, { children: [jsx(Tooltip, { title: localization.cancel, children: jsx(IconButton, { "aria-label": localization.cancel, onClick: handleCancel, children: jsx(CancelIcon, {}) }) }), ((isCreating && onCreatingRowSave) ||
|
|
956
|
-
(isEditing && onEditingRowSave)) && (jsx(Tooltip, { title: localization.save, children: jsx(IconButton, { "aria-label": localization.save, color: "info", disabled: isSaving, onClick: handleSubmitRow, children: isSaving ? jsx(CircularProgress, { size: 18 }) : jsx(SaveIcon, {}) }) }))] })) : (jsxs(Fragment, { children: [jsx(Button, { onClick: handleCancel, sx: { minWidth: '100px' }, children: localization.cancel }), jsxs(Button, { disabled: isSaving, onClick: handleSubmitRow, sx: { minWidth: '100px' }, variant: "contained", children: [isSaving && jsx(CircularProgress, { color: "inherit", size: 18 }), localization.save] })] })) }));
|
|
957
|
-
};
|
|
958
|
-
|
|
959
|
-
const parseCSSVarId = (id) => id.replace(/[^a-zA-Z0-9]/g, '_');
|
|
960
|
-
const getMRTTheme = (mrtTheme, muiTheme) => {
|
|
961
|
-
const mrtThemeOverrides = parseFromValuesOrFunc(mrtTheme, muiTheme);
|
|
962
|
-
const baseBackgroundColor = muiTheme.palette.background.default;
|
|
963
|
-
return Object.assign({ baseBackgroundColor, cellNavigationOutlineColor: muiTheme.palette.primary.main, draggingBorderColor: muiTheme.palette.primary.main, matchHighlightColor: muiTheme.palette.mode === 'dark'
|
|
964
|
-
? darken(muiTheme.palette.warning.dark, 0.25)
|
|
965
|
-
: lighten(muiTheme.palette.warning.light, 0.5), menuBackgroundColor: lighten(baseBackgroundColor, 0.07), pinnedRowBackgroundColor: alpha(muiTheme.palette.primary.main, 0.1), selectedRowBackgroundColor: alpha(muiTheme.palette.primary.main, 0.2) }, mrtThemeOverrides);
|
|
966
|
-
};
|
|
967
|
-
const commonCellBeforeAfterStyles = {
|
|
968
|
-
content: '""',
|
|
969
|
-
height: '100%',
|
|
970
|
-
left: 0,
|
|
971
|
-
position: 'absolute',
|
|
972
|
-
top: 0,
|
|
973
|
-
width: '100%',
|
|
974
|
-
zIndex: -1,
|
|
975
|
-
};
|
|
976
|
-
const getCommonPinnedCellStyles = ({ table, theme, }) => {
|
|
977
|
-
const { baseBackgroundColor } = table.options.mrtTheme;
|
|
978
917
|
return {
|
|
979
|
-
'
|
|
980
|
-
|
|
981
|
-
},
|
|
918
|
+
name: 'edit',
|
|
919
|
+
renderRow: renderRowAction,
|
|
982
920
|
};
|
|
983
921
|
};
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
}
|
|
1002
|
-
// The checkbox column is technically pinned (for sticky positioning) but
|
|
1003
|
-
// should look like a regular center column — no background overlay or shadow.
|
|
1004
|
-
const isCheckboxColumn = column.id === CHECKBOX_DISPLAY_COLUMN_ID;
|
|
1005
|
-
// Count all currently pinned column IDs across both sides.
|
|
1006
|
-
// Checkbox is always pinned (counts as 1), so > 1 means the user has
|
|
1007
|
-
// explicitly pinned at least one additional column.
|
|
1008
|
-
const totalPinnedColumnCount = [
|
|
1009
|
-
...((_e = table.getState().columnPinning.left) !== null && _e !== void 0 ? _e : []),
|
|
1010
|
-
...((_f = table.getState().columnPinning.right) !== null && _f !== void 0 ? _f : []),
|
|
1011
|
-
].length;
|
|
1012
|
-
const hasNoPinnedColumns = totalPinnedColumnCount === 0;
|
|
1013
|
-
const pinnedStyles = isColumnPinned
|
|
1014
|
-
? Object.assign(Object.assign({}, (isCheckboxColumn
|
|
1015
|
-
? hasNoPinnedColumns
|
|
1016
|
-
? {
|
|
1017
|
-
// Use doubled class selector (&&) to beat the row-level
|
|
1018
|
-
// td[data-pinned="true"]:before specificity from MRT_TableBodyRow.
|
|
1019
|
-
'&&[data-pinned="true"]': {
|
|
1020
|
-
'&:before': {
|
|
1021
|
-
backgroundColor: 'transparent',
|
|
1022
|
-
boxShadow: 'none',
|
|
1023
|
-
},
|
|
1024
|
-
},
|
|
1025
|
-
}
|
|
1026
|
-
: // Other columns are also pinned — apply standard pinned background
|
|
1027
|
-
// so the checkbox header matches the pinned row cells below it.
|
|
1028
|
-
getCommonPinnedCellStyles({ column, table, theme })
|
|
1029
|
-
: getCommonPinnedCellStyles({ column, table, theme }))), { left: isColumnPinned === 'left'
|
|
1030
|
-
? `${column.getStart('left')}px`
|
|
1031
|
-
: undefined,
|
|
1032
|
-
// Skip opacity reduction for checkbox — keep it fully opaque like center columns
|
|
1033
|
-
opacity: isCheckboxColumn ? undefined : 0.97, position: 'sticky', right: isColumnPinned === 'right'
|
|
1034
|
-
? `${column.getAfter('right')}px`
|
|
1035
|
-
: undefined }) : {};
|
|
1036
|
-
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'
|
|
1037
|
-
? 'center'
|
|
1038
|
-
: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid'))
|
|
1039
|
-
? tableCellProps.align
|
|
1040
|
-
: undefined, opacity: isDraggingColumn || isHoveredColumn ? 0.5 : 1, position: 'relative', transition: enableColumnVirtualization
|
|
1041
|
-
? 'none'
|
|
1042
|
-
: `padding 150ms ease-in-out`, zIndex: column.getIsResizing() || isDraggingColumn
|
|
1043
|
-
? 2
|
|
1044
|
-
: columnDefType !== 'group' && isColumnPinned
|
|
1045
|
-
? 1
|
|
1046
|
-
: 0, '&:focus-visible': {
|
|
1047
|
-
outline: `2px solid ${table.options.mrtTheme.cellNavigationOutlineColor}`,
|
|
1048
|
-
outlineOffset: '-2px',
|
|
1049
|
-
} }, pinnedStyles), widthStyles), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme));
|
|
922
|
+
|
|
923
|
+
const downloadExportFiles = (files) => {
|
|
924
|
+
files.forEach((file) => {
|
|
925
|
+
const binaryString = atob(file.content);
|
|
926
|
+
const len = binaryString.length;
|
|
927
|
+
const bytes = new Uint8Array(len);
|
|
928
|
+
for (let i = 0; i < len; i++) {
|
|
929
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
930
|
+
}
|
|
931
|
+
const blob = new Blob([bytes], { type: 'application/octet-stream' });
|
|
932
|
+
const element = document.createElement('a');
|
|
933
|
+
element.href = URL.createObjectURL(blob);
|
|
934
|
+
element.download = file.filename;
|
|
935
|
+
document.body.appendChild(element);
|
|
936
|
+
element.click();
|
|
937
|
+
document.body.removeChild(element);
|
|
938
|
+
URL.revokeObjectURL(element.href);
|
|
939
|
+
});
|
|
1050
940
|
};
|
|
1051
|
-
const getCommonToolbarStyles = ({ table, }) => ({
|
|
1052
|
-
alignItems: 'flex-start',
|
|
1053
|
-
backgroundColor: table.options.mrtTheme.baseBackgroundColor,
|
|
1054
|
-
display: 'grid',
|
|
1055
|
-
flexWrap: 'wrap-reverse',
|
|
1056
|
-
position: 'relative',
|
|
1057
|
-
transition: 'all 150ms ease-in-out',
|
|
1058
|
-
zIndex: 1,
|
|
1059
|
-
});
|
|
1060
|
-
const flipIconStyles = (theme) => theme.direction === 'rtl'
|
|
1061
|
-
? { style: { transform: 'scaleX(-1)' } }
|
|
1062
|
-
: undefined;
|
|
1063
|
-
const getCommonTooltipProps = (placement) => ({
|
|
1064
|
-
disableInteractive: true,
|
|
1065
|
-
enterDelay: 1000,
|
|
1066
|
-
enterNextDelay: 1000,
|
|
1067
|
-
placement,
|
|
1068
|
-
});
|
|
1069
941
|
|
|
1070
|
-
const
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
942
|
+
const printExportFiles = (files) => {
|
|
943
|
+
files.forEach((file) => {
|
|
944
|
+
const binaryString = atob(file.content);
|
|
945
|
+
const len = binaryString.length;
|
|
946
|
+
const bytes = new Uint8Array(len);
|
|
947
|
+
for (let i = 0; i < len; i++) {
|
|
948
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
949
|
+
}
|
|
950
|
+
const blob = new Blob([bytes], { type: 'application/pdf' });
|
|
951
|
+
const url = URL.createObjectURL(blob);
|
|
952
|
+
printJS({
|
|
953
|
+
printable: url,
|
|
954
|
+
type: 'pdf',
|
|
955
|
+
onLoadingEnd: () => URL.revokeObjectURL(url),
|
|
956
|
+
});
|
|
957
|
+
});
|
|
1079
958
|
};
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
const {
|
|
1084
|
-
const {
|
|
1085
|
-
const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
|
|
1086
|
-
const isEditing = useMRT_SliceValue(table._uiStore, (s) => { var _a; return ((_a = s.editingRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
|
|
1087
|
-
const showEditActionButtons = (isCreating && createDisplayMode === 'row') ||
|
|
1088
|
-
(isEditing && editDisplayMode === 'row');
|
|
959
|
+
|
|
960
|
+
const MRT_ExportsToolbar = ({ table, availableExports, exportState, onExportStateChange, loadExport, }) => {
|
|
961
|
+
const theme = useTheme();
|
|
962
|
+
const { localization } = table.options;
|
|
963
|
+
const { selectedExports, selectedFormat, grouped } = exportState;
|
|
1089
964
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
1090
|
-
const
|
|
1091
|
-
|
|
1092
|
-
|
|
965
|
+
const [loadingExportType, setLoadingExportType] = useState(null);
|
|
966
|
+
const { rowSelection } = table.getState();
|
|
967
|
+
const selectedRowIds = Object.keys(rowSelection).filter((id) => rowSelection[id]);
|
|
968
|
+
const isNoRowsSelected = selectedRowIds.length === 0;
|
|
969
|
+
const availableFormats = useMemo(() => {
|
|
970
|
+
const allFormats = Object.values(availableExports).flatMap((exp) => exp.formats);
|
|
971
|
+
return Array.from(new Set(allFormats));
|
|
972
|
+
}, [availableExports]);
|
|
973
|
+
const hasPdfFormat = availableFormats.includes('pdf');
|
|
974
|
+
const exportTypesForSelectedFormat = useMemo(() => {
|
|
975
|
+
if (!selectedFormat)
|
|
976
|
+
return [];
|
|
977
|
+
return Object.values(availableExports).filter((exp) => exp.formats.includes(selectedFormat));
|
|
978
|
+
}, [availableExports, selectedFormat]);
|
|
979
|
+
const isPrintDisabled = selectedFormat !== 'pdf' ||
|
|
980
|
+
!selectedFormat ||
|
|
981
|
+
selectedExports.length < 1 ||
|
|
982
|
+
(!grouped && selectedExports.length > 1);
|
|
983
|
+
const isDownloadDisabled = !selectedFormat || selectedExports.length < 1;
|
|
984
|
+
const handleOpenMenu = (event) => {
|
|
1093
985
|
setAnchorEl(event.currentTarget);
|
|
1094
986
|
};
|
|
1095
|
-
const
|
|
1096
|
-
event.stopPropagation();
|
|
1097
|
-
setEditingRow(Object.assign({}, row));
|
|
987
|
+
const handleCloseMenu = () => {
|
|
1098
988
|
setAnchorEl(null);
|
|
1099
989
|
};
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
990
|
+
const handleSelectFormat = (format) => {
|
|
991
|
+
const newFormat = selectedFormat === format ? null : format;
|
|
992
|
+
onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { grouped: false })), { selectedExports: [], selectedFormat: newFormat })));
|
|
993
|
+
};
|
|
994
|
+
const handleToggleExportType = (exportName) => {
|
|
995
|
+
const isAlreadySelected = selectedExports.includes(exportName);
|
|
996
|
+
const newSelectedExports = isAlreadySelected
|
|
997
|
+
? selectedExports.filter((name) => name !== exportName)
|
|
998
|
+
: [...selectedExports, exportName];
|
|
999
|
+
onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { selectedFormat: null, grouped: false })), { selectedExports: newSelectedExports })));
|
|
1000
|
+
};
|
|
1001
|
+
const handleToggleGrouped = () => {
|
|
1002
|
+
onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { selectedFormat: null, selectedExports: [] })), { grouped: !grouped })));
|
|
1003
|
+
};
|
|
1004
|
+
const handleExportAction = (type) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1005
|
+
setLoadingExportType(type);
|
|
1006
|
+
try {
|
|
1007
|
+
const response = yield loadExport({
|
|
1008
|
+
format: selectedFormat,
|
|
1009
|
+
exports: selectedExports,
|
|
1010
|
+
separated_files: !grouped,
|
|
1011
|
+
download: false,
|
|
1012
|
+
ids: JSON.stringify(selectedRowIds),
|
|
1013
|
+
type,
|
|
1014
|
+
});
|
|
1015
|
+
handleCloseMenu();
|
|
1016
|
+
if (type === 'download') {
|
|
1017
|
+
downloadExportFiles(response);
|
|
1018
|
+
}
|
|
1019
|
+
else {
|
|
1020
|
+
printExportFiles(response);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
finally {
|
|
1024
|
+
setLoadingExportType(null);
|
|
1025
|
+
}
|
|
1026
|
+
});
|
|
1027
|
+
const renderFormatSelector = () => (jsx(Stack, { justifyContent: "flex-start", minWidth: "200px", sx: {
|
|
1028
|
+
borderRight: selectedFormat
|
|
1029
|
+
? `1px dashed ${theme.palette.divider}`
|
|
1030
|
+
: 'none',
|
|
1031
|
+
}, children: jsx(FormControl, { children: jsx(RadioGroup, { value: selectedFormat !== null && selectedFormat !== void 0 ? selectedFormat : '', children: availableFormats.map((format) => (jsx(FormControlLabel, { sx: { m: 0 }, value: format, control: jsx(Radio, { size: "small", onClick: () => handleSelectFormat(format) }), label: jsx(Typography, { variant: "subtitle2", sx: { fontWeight: 800 }, children: format }) }, format))) }) }) }));
|
|
1032
|
+
const renderExportTypeSelector = () => {
|
|
1033
|
+
if (!selectedFormat || exportTypesForSelectedFormat.length === 0)
|
|
1034
|
+
return null;
|
|
1035
|
+
return (jsx(Stack, { minWidth: "250px", maxHeight: "500px", sx: { overflowY: 'auto' }, children: exportTypesForSelectedFormat.map((exportType) => (jsxs(MenuItem, { onClick: () => handleToggleExportType(exportType.name), value: exportType.name, children: [jsx(Checkbox, { checked: selectedExports.includes(exportType.name), size: "small" }), jsx(Typography, { variant: "body2", children: exportType.label })] }, exportType.name))) }));
|
|
1036
|
+
};
|
|
1037
|
+
const renderActionButtons = () => {
|
|
1038
|
+
const isAnyLoading = loadingExportType !== null;
|
|
1039
|
+
return (jsxs(Stack, { direction: "row", gap: 0.5, mt: 1, mr: 2, children: [hasPdfFormat && (jsx(Button, { sx: { display: 'flex', gap: 0.5 }, disabled: isPrintDisabled || isAnyLoading, onClick: () => handleExportAction('print'), startIcon: loadingExportType === 'print' ? (jsx(CircularProgress, { size: 16, color: "inherit" })) : (jsx(PrintIcon, { fontSize: "small" })), children: localization.exportPrintPdf })), jsx(Button, { sx: { display: 'flex', gap: 0.5 }, disabled: isDownloadDisabled || isAnyLoading, onClick: () => handleExportAction('download'), startIcon: loadingExportType === 'download' ? (jsx(CircularProgress, { size: 16, color: "inherit" })) : (jsx(FileDownloadIcon, { fontSize: "small" })), children: localization.exportDownload })] }));
|
|
1040
|
+
};
|
|
1041
|
+
const renderGroupedCheckbox = () => (jsx(Stack, { mt: "auto", children: jsx(FormControlLabel, { onChange: handleToggleGrouped, sx: { m: 0 }, control: jsx(Checkbox, { checked: grouped, size: "small" }), label: jsx(Typography, { variant: "body2", children: localization.exportGrouped }) }) }));
|
|
1042
|
+
return (jsxs(Stack, { direction: "row", gap: 0.5, alignItems: "center", children: [jsx(Tooltip, { title: isNoRowsSelected
|
|
1043
|
+
? localization.exportSelectRowsTooltip
|
|
1044
|
+
: localization.exportButton, children: jsx("span", { children: jsx(Button, { "aria-label": localization.exportButton, disabled: isNoRowsSelected, onClick: handleOpenMenu, size: "small", startIcon: jsx(FileDownloadIcon, { fontSize: "small" }), variant: "text", children: localization.exportButton }) }) }), jsxs(Menu, { anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleCloseMenu, anchorOrigin: { vertical: 'bottom', horizontal: 'left' }, transformOrigin: { vertical: 'top', horizontal: 'left' }, children: [jsxs(Stack, { direction: "row", sx: { px: 1, pt: 1, maxHeight: '320px', overflow: 'auto' }, children: [renderFormatSelector(), selectedFormat &&
|
|
1045
|
+
exportTypesForSelectedFormat.length > 0 &&
|
|
1046
|
+
renderExportTypeSelector()] }), jsx(Divider, { sx: { mt: 1 } }), jsxs(Stack, { direction: "row", alignItems: "center", sx: { px: 1, pb: 1 }, children: [renderActionButtons(), renderGroupedCheckbox()] })] })] }));
|
|
1108
1047
|
};
|
|
1109
1048
|
|
|
1110
|
-
const
|
|
1111
|
-
return
|
|
1112
|
-
header: 'actions',
|
|
1113
|
-
id: 'mrt-row-actions',
|
|
1114
|
-
size: 70,
|
|
1115
|
-
tableOptions,
|
|
1116
|
-
}));
|
|
1049
|
+
const MRT_ExportRowButton = ({ onClick }) => {
|
|
1050
|
+
return (jsx(IconButton, { sx: { p: 0 }, disableRipple: true, onClick: onClick, children: jsx(FileDownloadIcon, { fontSize: "small" }) }));
|
|
1117
1051
|
};
|
|
1118
1052
|
|
|
1119
|
-
const
|
|
1120
|
-
|
|
1121
|
-
var { location, table } = _a, rest = __rest(_a, ["location", "table"]);
|
|
1122
|
-
const { options: { icons: { DragHandleIcon }, localization, }, } = table;
|
|
1123
|
-
return (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: 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) => {
|
|
1124
|
-
var _a;
|
|
1125
|
-
e.stopPropagation();
|
|
1126
|
-
(_a = rest === null || rest === void 0 ? void 0 : rest.onClick) === null || _a === void 0 ? void 0 : _a.call(rest, e);
|
|
1127
|
-
}, sx: (theme) => (Object.assign({ '&:active': {
|
|
1128
|
-
cursor: 'grabbing',
|
|
1129
|
-
}, '&:hover': {
|
|
1130
|
-
backgroundColor: 'transparent',
|
|
1131
|
-
opacity: 1,
|
|
1132
|
-
}, 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: jsx(DragHandleIcon, {}) })) })));
|
|
1053
|
+
const MRT_PrintRowButton = ({ onClick }) => {
|
|
1054
|
+
return (jsx(IconButton, { sx: { p: 0 }, disableRipple: true, onClick: onClick, children: jsx(PrintIcon, { fontSize: "small" }) }));
|
|
1133
1055
|
};
|
|
1134
1056
|
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1057
|
+
const ExportRowAction = ({ onExport, onPrint }) => {
|
|
1058
|
+
return (jsxs(Fragment, { children: [jsx(MRT_ExportRowButton, { onClick: onExport }), onPrint && jsx(MRT_PrintRowButton, { onClick: onPrint })] }));
|
|
1059
|
+
};
|
|
1060
|
+
|
|
1061
|
+
const hasActiveExports = (table) => {
|
|
1062
|
+
const { activeExports } = table.getState();
|
|
1063
|
+
return !!((activeExports === null || activeExports === void 0 ? void 0 : activeExports.selectedFormat) && activeExports.selectedExports.length > 0);
|
|
1064
|
+
};
|
|
1065
|
+
// Same conditions as MRT_ExportsToolbar: pdf format selected, at least one export type,
|
|
1066
|
+
// and either grouped or exactly one export type selected.
|
|
1067
|
+
const isPrintAvailable = (table) => {
|
|
1068
|
+
var _a;
|
|
1069
|
+
const allFormats = Object.values((_a = table.options.availableExports) !== null && _a !== void 0 ? _a : {}).flatMap((e) => e.formats);
|
|
1070
|
+
if (!allFormats.includes('pdf'))
|
|
1071
|
+
return false;
|
|
1072
|
+
const { activeExports } = table.getState();
|
|
1073
|
+
if (!activeExports)
|
|
1074
|
+
return false;
|
|
1075
|
+
const { selectedFormat, selectedExports, grouped } = activeExports;
|
|
1076
|
+
return (selectedFormat === 'pdf' &&
|
|
1077
|
+
selectedExports.length >= 1 &&
|
|
1078
|
+
(grouped || selectedExports.length === 1));
|
|
1079
|
+
};
|
|
1080
|
+
const createExportAction = (_a = {}) => {
|
|
1081
|
+
var { onExport, renderRow: customRenderRow, renderToolbar: customRenderToolbar } = _a, rest = __rest(_a, ["onExport", "renderRow", "renderToolbar"]);
|
|
1082
|
+
// Pure download logic — no notifications. Throws on failure so callers can handle it.
|
|
1083
|
+
const defaultOnExport = (_a) => __awaiter(void 0, [_a], void 0, function* ({ rowsToExport, table, }) {
|
|
1084
|
+
if (!rowsToExport.length)
|
|
1085
|
+
return;
|
|
1086
|
+
const { loadExport } = table.options;
|
|
1087
|
+
const { activeExports } = table.getState();
|
|
1088
|
+
if (!loadExport || !activeExports)
|
|
1089
|
+
return;
|
|
1090
|
+
const response = yield loadExport({
|
|
1091
|
+
format: activeExports.selectedFormat,
|
|
1092
|
+
exports: activeExports.selectedExports,
|
|
1093
|
+
separated_files: !activeExports.grouped,
|
|
1094
|
+
download: false,
|
|
1095
|
+
ids: JSON.stringify(rowsToExport.map((r) => r.id)),
|
|
1096
|
+
type: 'download',
|
|
1097
|
+
});
|
|
1098
|
+
downloadExportFiles(response);
|
|
1099
|
+
});
|
|
1100
|
+
// Pure print logic — no notifications. Throws on failure so callers can handle it.
|
|
1101
|
+
const defaultOnPrint = (_a) => __awaiter(void 0, [_a], void 0, function* ({ rowsToExport, table, }) {
|
|
1102
|
+
if (!rowsToExport.length)
|
|
1103
|
+
return;
|
|
1104
|
+
const { loadExport } = table.options;
|
|
1105
|
+
const { activeExports } = table.getState();
|
|
1106
|
+
if (!loadExport || !activeExports)
|
|
1107
|
+
return;
|
|
1108
|
+
const response = yield loadExport({
|
|
1109
|
+
format: activeExports.selectedFormat,
|
|
1110
|
+
exports: activeExports.selectedExports,
|
|
1111
|
+
separated_files: !activeExports.grouped,
|
|
1112
|
+
download: false,
|
|
1113
|
+
ids: JSON.stringify(rowsToExport.map((r) => r.id)),
|
|
1114
|
+
type: 'print',
|
|
1115
|
+
});
|
|
1116
|
+
printExportFiles(response);
|
|
1117
|
+
});
|
|
1118
|
+
// Single execution pipeline for every export flow (row or toolbar).
|
|
1119
|
+
// If a custom handler exists, it receives defaultOnExport and decides when to call it.
|
|
1120
|
+
const executeExport = (context) => {
|
|
1121
|
+
const executeDefaultExport = () => defaultOnExport(context);
|
|
1122
|
+
if (onExport) {
|
|
1123
|
+
return onExport(Object.assign(Object.assign({}, context), { defaultOnExport: executeDefaultExport }));
|
|
1124
|
+
}
|
|
1125
|
+
return executeDefaultExport();
|
|
1126
|
+
};
|
|
1127
|
+
// Row download: checks for active exports, then wraps with loading/success/error notifications.
|
|
1128
|
+
const handleSingleRowExport = (_a) => __awaiter(void 0, [_a], void 0, function* ({ table, row, }) {
|
|
1129
|
+
const { localization } = table.options;
|
|
1130
|
+
if (!hasActiveExports(table)) {
|
|
1131
|
+
enqueueSnackbar(localization.exportNoExportsSelected, {
|
|
1132
|
+
variant: 'warning',
|
|
1133
|
+
});
|
|
1134
|
+
return;
|
|
1135
|
+
}
|
|
1136
|
+
const loadingKey = enqueueSnackbar(localization.exportInProgress, {
|
|
1137
|
+
variant: 'info',
|
|
1138
|
+
persist: true,
|
|
1139
|
+
});
|
|
1145
1140
|
try {
|
|
1146
|
-
|
|
1141
|
+
yield executeExport({ table, rowsToExport: [row] });
|
|
1142
|
+
closeSnackbar(loadingKey);
|
|
1143
|
+
enqueueSnackbar(localization.exportSuccess, { variant: 'success' });
|
|
1147
1144
|
}
|
|
1148
|
-
catch (
|
|
1149
|
-
|
|
1145
|
+
catch (_b) {
|
|
1146
|
+
closeSnackbar(loadingKey);
|
|
1147
|
+
enqueueSnackbar(localization.exportError, { variant: 'error' });
|
|
1150
1148
|
}
|
|
1151
|
-
|
|
1149
|
+
});
|
|
1150
|
+
// Row print: same guard + notification pattern as download, but calls defaultOnPrint.
|
|
1151
|
+
const handleSingleRowPrint = (_a) => __awaiter(void 0, [_a], void 0, function* ({ table, row, }) {
|
|
1152
|
+
const { localization } = table.options;
|
|
1153
|
+
if (!hasActiveExports(table)) {
|
|
1154
|
+
enqueueSnackbar(localization.exportNoExportsSelected, {
|
|
1155
|
+
variant: 'warning',
|
|
1156
|
+
});
|
|
1157
|
+
return;
|
|
1158
|
+
}
|
|
1159
|
+
const loadingKey = enqueueSnackbar(localization.exportInProgress, {
|
|
1160
|
+
variant: 'info',
|
|
1161
|
+
persist: true,
|
|
1162
|
+
});
|
|
1163
|
+
try {
|
|
1164
|
+
yield defaultOnPrint({ table, rowsToExport: [row] });
|
|
1165
|
+
closeSnackbar(loadingKey);
|
|
1166
|
+
enqueueSnackbar(localization.exportSuccess, { variant: 'success' });
|
|
1167
|
+
}
|
|
1168
|
+
catch (_b) {
|
|
1169
|
+
closeSnackbar(loadingKey);
|
|
1170
|
+
enqueueSnackbar(localization.exportError, { variant: 'error' });
|
|
1171
|
+
}
|
|
1172
|
+
});
|
|
1173
|
+
// Resolves selected rows from table state for toolbar-triggered export (custom renderToolbar only).
|
|
1174
|
+
const handleMultipleRowExport = ({ table, }) => {
|
|
1175
|
+
const rowsToExport = table.getSelectedRowModel().rows;
|
|
1176
|
+
return executeExport({ table, rowsToExport });
|
|
1152
1177
|
};
|
|
1153
|
-
const
|
|
1154
|
-
|
|
1155
|
-
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
1156
|
-
table.setDraggingRow(null);
|
|
1157
|
-
table.setHoveredRow(null);
|
|
1178
|
+
const createRowExportExecutor = (context) => () => {
|
|
1179
|
+
void handleSingleRowExport(context);
|
|
1158
1180
|
};
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1181
|
+
const createRowPrintExecutor = (context) => () => {
|
|
1182
|
+
void handleSingleRowPrint(context);
|
|
1183
|
+
};
|
|
1184
|
+
const createToolbarExportExecutor = (context) => () => {
|
|
1185
|
+
void handleMultipleRowExport(context);
|
|
1186
|
+
};
|
|
1187
|
+
// Renders download + optional print button. Print is shown under the same conditions
|
|
1188
|
+
// as in MRT_ExportsToolbar: pdf format selected, active exports, grouped or single type.
|
|
1189
|
+
const renderRowAction = (context) => {
|
|
1190
|
+
const onRowExport = createRowExportExecutor(context);
|
|
1191
|
+
const onRowPrint = isPrintAvailable(context.table)
|
|
1192
|
+
? createRowPrintExecutor(context)
|
|
1193
|
+
: undefined;
|
|
1194
|
+
if (customRenderRow) {
|
|
1195
|
+
return customRenderRow(Object.assign(Object.assign({}, context), { onExport: onRowExport }));
|
|
1196
|
+
}
|
|
1197
|
+
return jsx(ExportRowAction, { onExport: onRowExport, onPrint: onRowPrint });
|
|
1198
|
+
};
|
|
1199
|
+
// Uses custom toolbar renderer when provided; otherwise renders MRT_ExportsToolbar.
|
|
1200
|
+
// loadExport is always wrapped with notifications so that loading/success/error are shown
|
|
1201
|
+
// regardless of whether a custom onExport handler was provided.
|
|
1202
|
+
// When onExport is provided, it intercepts the call and returns [] so MRT_ExportsToolbar
|
|
1203
|
+
// does not attempt a second download from an empty response.
|
|
1204
|
+
const renderToolbarAction = (context) => {
|
|
1205
|
+
const { table } = context;
|
|
1206
|
+
const { availableExports, loadExport, onActiveExportsChange, localization, } = table.options;
|
|
1207
|
+
const { activeExports } = table.getState();
|
|
1208
|
+
if (customRenderToolbar) {
|
|
1209
|
+
return customRenderToolbar(Object.assign(Object.assign({}, context), { onExport: createToolbarExportExecutor(context) }));
|
|
1210
|
+
}
|
|
1211
|
+
if (!availableExports ||
|
|
1212
|
+
!loadExport ||
|
|
1213
|
+
!onActiveExportsChange ||
|
|
1214
|
+
!activeExports) {
|
|
1215
|
+
return null;
|
|
1216
|
+
}
|
|
1217
|
+
const notifiedLoadExport = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1218
|
+
const loadingKey = enqueueSnackbar(localization.exportInProgress, {
|
|
1219
|
+
variant: 'info',
|
|
1220
|
+
persist: true,
|
|
1221
|
+
});
|
|
1222
|
+
try {
|
|
1223
|
+
let response;
|
|
1224
|
+
if (onExport) {
|
|
1225
|
+
const rowsToExport = table.getSelectedRowModel().rows;
|
|
1226
|
+
yield executeExport({ table, rowsToExport });
|
|
1227
|
+
response = [];
|
|
1228
|
+
}
|
|
1229
|
+
else {
|
|
1230
|
+
response = yield loadExport(params);
|
|
1231
|
+
}
|
|
1232
|
+
closeSnackbar(loadingKey);
|
|
1233
|
+
enqueueSnackbar(localization.exportSuccess, { variant: 'success' });
|
|
1234
|
+
return response;
|
|
1235
|
+
}
|
|
1236
|
+
catch (_a) {
|
|
1237
|
+
closeSnackbar(loadingKey);
|
|
1238
|
+
enqueueSnackbar(localization.exportError, { variant: 'error' });
|
|
1239
|
+
return [];
|
|
1240
|
+
}
|
|
1241
|
+
});
|
|
1242
|
+
return (jsx(MRT_ExportsToolbar, { table: table, availableExports: availableExports, exportState: activeExports, onExportStateChange: onActiveExportsChange, loadExport: notifiedLoadExport }));
|
|
1243
|
+
};
|
|
1244
|
+
return Object.assign({ name: 'export', renderRow: renderRowAction, renderToolbar: renderToolbarAction }, rest);
|
|
1169
1245
|
};
|
|
1170
1246
|
|
|
1171
|
-
const
|
|
1172
|
-
var _b, _c;
|
|
1173
|
-
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
1174
|
-
const { getCanSomeRowsExpand, getIsAllRowsExpanded, getIsSomeRowsExpanded, getState, options: { icons: { KeyboardDoubleArrowDownIcon }, localization, muiExpandAllButtonProps, renderDetailPanel, }, toggleAllRowsExpanded, } = table;
|
|
1175
|
-
const { isLoading } = getState();
|
|
1176
|
-
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
1177
|
-
const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiExpandAllButtonProps, {
|
|
1178
|
-
table,
|
|
1179
|
-
})), rest);
|
|
1180
|
-
const isAllRowsExpanded = getIsAllRowsExpanded();
|
|
1181
|
-
return (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: jsx("span", { children: 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 : (jsx(KeyboardDoubleArrowDownIcon, { style: {
|
|
1182
|
-
transform: `rotate(${isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0}deg)`,
|
|
1183
|
-
transition: 'transform 150ms',
|
|
1184
|
-
} })) })) }) })));
|
|
1185
|
-
};
|
|
1247
|
+
const MRT_AggregationFns = Object.assign({}, aggregationFns);
|
|
1186
1248
|
|
|
1187
|
-
const
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
const { options: { icons: { ExpandMoreIcon }, localization, maxDepth, muiExpandButtonProps, positionExpandColumn, renderDetailPanel, }, } = table;
|
|
1191
|
-
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
1192
|
-
const iconButtonProps = parseFromValuesOrFunc(muiExpandButtonProps, {
|
|
1193
|
-
row,
|
|
1194
|
-
staticRowIndex,
|
|
1195
|
-
table,
|
|
1249
|
+
const fuzzy = (row, columnId, filterValue, addMeta) => {
|
|
1250
|
+
const itemRank = rankItem(row.getValue(columnId), filterValue, {
|
|
1251
|
+
threshold: rankings.MATCHES,
|
|
1196
1252
|
});
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
const handleToggleExpand = (event) => {
|
|
1200
|
-
var _a;
|
|
1201
|
-
event.stopPropagation();
|
|
1202
|
-
row.toggleExpanded();
|
|
1203
|
-
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
1204
|
-
};
|
|
1205
|
-
const detailPanel = !!(renderDetailPanel === null || renderDetailPanel === void 0 ? void 0 : renderDetailPanel({ row, table }));
|
|
1206
|
-
return (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: jsx("span", { children: 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'
|
|
1207
|
-
? 'mr'
|
|
1208
|
-
: '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 : (jsx(ExpandMoreIcon, { style: {
|
|
1209
|
-
transform: `rotate(${!canExpand && !renderDetailPanel
|
|
1210
|
-
? positionExpandColumn === 'last' ||
|
|
1211
|
-
theme.direction === 'rtl'
|
|
1212
|
-
? 90
|
|
1213
|
-
: -90
|
|
1214
|
-
: isExpanded
|
|
1215
|
-
? -180
|
|
1216
|
-
: 0}deg)`,
|
|
1217
|
-
transition: 'transform 150ms',
|
|
1218
|
-
} })) })) }) })));
|
|
1219
|
-
};
|
|
1220
|
-
|
|
1221
|
-
const INSERT_HERE_TOOLTIP = 'Insert here';
|
|
1222
|
-
const ACTION_ICON_SIZE$1 = 'small';
|
|
1223
|
-
const MRT_InsertHereAction = ({ onClick, }) => {
|
|
1224
|
-
return (jsx(Tooltip, { title: INSERT_HERE_TOOLTIP, disableInteractive: true, children: jsx(IconButton, { onClick: onClick, size: ACTION_ICON_SIZE$1, children: jsx(SubdirectoryArrowLeftIcon, { color: "warning" }) }) }));
|
|
1253
|
+
addMeta(itemRank);
|
|
1254
|
+
return itemRank.passed;
|
|
1225
1255
|
};
|
|
1226
|
-
|
|
1227
|
-
const
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
return (jsx(Tooltip, { title: MOVE_TO_TOP_TOOLTIP, disableInteractive: true, children: jsx(IconButton, { onClick: onClick, size: ACTION_ICON_SIZE, sx: { height: ACTION_BUTTON_HEIGHT }, children: jsx(VerticalAlignTopIcon, { fontSize: "small" }) }) }));
|
|
1256
|
+
fuzzy.autoRemove = (val) => !val;
|
|
1257
|
+
const contains = (row, id, filterValue) => {
|
|
1258
|
+
var _a;
|
|
1259
|
+
return !!((_a = row
|
|
1260
|
+
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().includes(filterValue.toString().toLowerCase().trim()));
|
|
1232
1261
|
};
|
|
1233
|
-
|
|
1234
|
-
const
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
color: (theme) => theme.palette.warning.main,
|
|
1239
|
-
},
|
|
1240
|
-
} }));
|
|
1262
|
+
contains.autoRemove = (val) => !val;
|
|
1263
|
+
const startsWith = (row, id, filterValue) => {
|
|
1264
|
+
var _a;
|
|
1265
|
+
return !!((_a = row
|
|
1266
|
+
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().startsWith(filterValue.toString().toLowerCase().trim()));
|
|
1241
1267
|
};
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
* Finds the maximum depth in the hierarchy of a given row (recursively searches all descendants).
|
|
1245
|
-
* Used to determine the "size" of the tree being moved.
|
|
1246
|
-
* Example: Row at depth 1 with a child at depth 3 → returns 3
|
|
1247
|
-
*/
|
|
1248
|
-
const getDeepestSubRowDepth = (row) => {
|
|
1268
|
+
startsWith.autoRemove = (val) => !val;
|
|
1269
|
+
const endsWith = (row, id, filterValue) => {
|
|
1249
1270
|
var _a;
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
}
|
|
1253
|
-
return row.subRows.reduce((maxDepth, subRow) => Math.max(maxDepth, getDeepestSubRowDepth(subRow)), row.depth);
|
|
1271
|
+
return !!((_a = row
|
|
1272
|
+
.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim().endsWith(filterValue.toString().toLowerCase().trim()));
|
|
1254
1273
|
};
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
const getSelectedReorderRowIds = (rowReorderingSelection) => {
|
|
1261
|
-
return Object.entries(rowReorderingSelection !== null && rowReorderingSelection !== void 0 ? rowReorderingSelection : {})
|
|
1262
|
-
.filter(([, isSelected]) => isSelected)
|
|
1263
|
-
.map(([rowId]) => rowId);
|
|
1274
|
+
endsWith.autoRemove = (val) => !val;
|
|
1275
|
+
const equals = (row, id, filterValue) => {
|
|
1276
|
+
var _a;
|
|
1277
|
+
return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) ===
|
|
1278
|
+
filterValue.toString().toLowerCase().trim();
|
|
1264
1279
|
};
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
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;
|
|
1280
|
+
equals.autoRemove = (val) => !val;
|
|
1281
|
+
const notEquals = (row, id, filterValue) => {
|
|
1282
|
+
var _a;
|
|
1283
|
+
return ((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().toLowerCase().trim()) !==
|
|
1284
|
+
filterValue.toString().toLowerCase().trim();
|
|
1291
1285
|
};
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
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;
|
|
1286
|
+
notEquals.autoRemove = (val) => !val;
|
|
1287
|
+
const greaterThan = (row, id, filterValue) => {
|
|
1288
|
+
var _a, _b, _c;
|
|
1289
|
+
return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
|
1290
|
+
? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) > +filterValue
|
|
1291
|
+
: ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) > filterValue.toString().toLowerCase().trim();
|
|
1304
1292
|
};
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
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;
|
|
1293
|
+
greaterThan.autoRemove = (val) => !val;
|
|
1294
|
+
const greaterThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || greaterThan(row, id, filterValue);
|
|
1295
|
+
greaterThanOrEqualTo.autoRemove = (val) => !val;
|
|
1296
|
+
const lessThan = (row, id, filterValue) => {
|
|
1297
|
+
var _a, _b, _c;
|
|
1298
|
+
return !isNaN(+filterValue) && !isNaN(+row.getValue(id))
|
|
1299
|
+
? +((_a = row.getValue(id)) !== null && _a !== void 0 ? _a : 0) < +filterValue
|
|
1300
|
+
: ((_c = ((_b = row.getValue(id)) !== null && _b !== void 0 ? _b : '')) === null || _c === void 0 ? void 0 : _c.toString().toLowerCase().trim()) < filterValue.toString().toLowerCase().trim();
|
|
1320
1301
|
};
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1302
|
+
lessThan.autoRemove = (val) => !val;
|
|
1303
|
+
const lessThanOrEqualTo = (row, id, filterValue) => equals(row, id, filterValue) || lessThan(row, id, filterValue);
|
|
1304
|
+
lessThanOrEqualTo.autoRemove = (val) => !val;
|
|
1305
|
+
const between = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
|
|
1306
|
+
greaterThan(row, id, filterValues[0])) &&
|
|
1307
|
+
((!isNaN(+filterValues[0]) &&
|
|
1308
|
+
!isNaN(+filterValues[1]) &&
|
|
1309
|
+
+filterValues[0] > +filterValues[1]) ||
|
|
1310
|
+
['', undefined].includes(filterValues[1]) ||
|
|
1311
|
+
lessThan(row, id, filterValues[1]));
|
|
1312
|
+
between.autoRemove = (val) => !val;
|
|
1313
|
+
const betweenInclusive = (row, id, filterValues) => (['', undefined].includes(filterValues[0]) ||
|
|
1314
|
+
greaterThanOrEqualTo(row, id, filterValues[0])) &&
|
|
1315
|
+
((!isNaN(+filterValues[0]) &&
|
|
1316
|
+
!isNaN(+filterValues[1]) &&
|
|
1317
|
+
+filterValues[0] > +filterValues[1]) ||
|
|
1318
|
+
['', undefined].includes(filterValues[1]) ||
|
|
1319
|
+
lessThanOrEqualTo(row, id, filterValues[1]));
|
|
1320
|
+
betweenInclusive.autoRemove = (val) => !val;
|
|
1321
|
+
const empty = (row, id, _filterValue) => { var _a; return !((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
|
|
1322
|
+
empty.autoRemove = (val) => !val;
|
|
1323
|
+
const notEmpty = (row, id, _filterValue) => { var _a; return !!((_a = row.getValue(id)) === null || _a === void 0 ? void 0 : _a.toString().trim()); };
|
|
1324
|
+
notEmpty.autoRemove = (val) => !val;
|
|
1325
|
+
const MRT_FilterFns = Object.assign(Object.assign({}, filterFns), { between,
|
|
1326
|
+
betweenInclusive,
|
|
1327
|
+
contains,
|
|
1328
|
+
empty,
|
|
1329
|
+
endsWith,
|
|
1330
|
+
equals,
|
|
1331
|
+
fuzzy,
|
|
1332
|
+
greaterThan,
|
|
1333
|
+
greaterThanOrEqualTo,
|
|
1334
|
+
lessThan,
|
|
1335
|
+
lessThanOrEqualTo,
|
|
1336
|
+
notEmpty,
|
|
1337
|
+
notEquals,
|
|
1338
|
+
startsWith });
|
|
1339
|
+
|
|
1340
|
+
const useMRT_SliceValue = (store, selector) => {
|
|
1341
|
+
const getSnapshot = () => selector(store.get());
|
|
1342
|
+
return useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
|
|
1334
1343
|
};
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
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) {
|
|
1364
|
-
return false;
|
|
1365
|
-
}
|
|
1366
|
-
// Rule 2: Target row cannot be a descendant of any selected row
|
|
1367
|
-
// (prevents parent from becoming child of its own descendants)
|
|
1368
|
-
for (const selectedRowId of selectedRowIds) {
|
|
1369
|
-
const selectedRow = table.getRow(selectedRowId, true);
|
|
1370
|
-
if (selectedRow &&
|
|
1371
|
-
isRowInSubtreeOf(targetRowId, selectedRow)) {
|
|
1372
|
-
return false;
|
|
1373
|
-
}
|
|
1374
|
-
}
|
|
1375
|
-
return true;
|
|
1344
|
+
|
|
1345
|
+
const MRT_ActionMenuItem = (_a) => {
|
|
1346
|
+
var { icon, label, onOpenSubMenu, table } = _a, rest = __rest(_a, ["icon", "label", "onOpenSubMenu", "table"]);
|
|
1347
|
+
const { options: { icons: { ArrowRightIcon }, }, } = table;
|
|
1348
|
+
return (jsxs(MenuItem, Object.assign({ sx: {
|
|
1349
|
+
alignItems: 'center',
|
|
1350
|
+
justifyContent: 'space-between',
|
|
1351
|
+
minWidth: '120px',
|
|
1352
|
+
my: 0,
|
|
1353
|
+
py: '6px',
|
|
1354
|
+
}, tabIndex: 0 }, rest, { children: [jsxs(Box, { sx: {
|
|
1355
|
+
alignItems: 'center',
|
|
1356
|
+
display: 'flex',
|
|
1357
|
+
}, children: [jsx(ListItemIcon, { children: icon }), label] }), onOpenSubMenu && (jsx(IconButton, { onClick: (e) => onOpenSubMenu(e), onMouseEnter: (e) => onOpenSubMenu(e), size: "small", sx: { p: 0 }, children: jsx(ArrowRightIcon, {}) }))] })));
|
|
1376
1358
|
};
|
|
1377
1359
|
|
|
1378
|
-
const
|
|
1379
|
-
|
|
1380
|
-
const
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
const selectedRowsForReorder = buildSelectedRowsArray(selectedReorderRowIds, table);
|
|
1393
|
-
const shouldShowReorderCheckbox = canSelectForReorder && (isRowHovered || hasAnyReorderSelection);
|
|
1394
|
-
const shouldShowInsertHereAction = selectedReorderRowIds.length > 0 &&
|
|
1395
|
-
isValidInsertTarget({
|
|
1396
|
-
targetRowId: row.id,
|
|
1397
|
-
selectedRowIds: selectedReorderRowIds,
|
|
1360
|
+
const MRT_RowActionMenu = (_a) => {
|
|
1361
|
+
var { anchorEl, handleEdit, row, setAnchorEl, staticRowIndex, table } = _a, rest = __rest(_a, ["anchorEl", "handleEdit", "row", "setAnchorEl", "staticRowIndex", "table"]);
|
|
1362
|
+
const { options: { editDisplayMode, enableEditing, icons: { EditIcon }, localization, mrtTheme: { menuBackgroundColor }, renderRowActionMenuItems, }, } = table;
|
|
1363
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
1364
|
+
const menuItems = useMemo(() => {
|
|
1365
|
+
const items = [];
|
|
1366
|
+
const editItem = parseFromValuesOrFunc(enableEditing, row) &&
|
|
1367
|
+
['modal', 'row'].includes(editDisplayMode) && (jsx(MRT_ActionMenuItem, { icon: jsx(EditIcon, {}), label: localization.edit, onClick: handleEdit, table: table }, 'edit'));
|
|
1368
|
+
if (editItem)
|
|
1369
|
+
items.push(editItem);
|
|
1370
|
+
const rowActionMenuItems = renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
|
1371
|
+
closeMenu: () => setAnchorEl(null),
|
|
1372
|
+
row,
|
|
1373
|
+
staticRowIndex,
|
|
1398
1374
|
table,
|
|
1399
|
-
}) &&
|
|
1400
|
-
canInsertSelectedRowsWithoutExceedingMaxDepth({
|
|
1401
|
-
maxDepth,
|
|
1402
|
-
selectedRows: selectedRowsForReorder,
|
|
1403
|
-
targetRowDepth: row.depth,
|
|
1404
1375
|
});
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
}, [row
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
selectedRows: selectedRowsForReorder,
|
|
1418
|
-
table,
|
|
1419
|
-
targetRow: row,
|
|
1420
|
-
};
|
|
1421
|
-
onTreeRowReorder(treeRowReorderEvent);
|
|
1422
|
-
}
|
|
1423
|
-
catch (error) {
|
|
1424
|
-
console.error('[MRT] Error during tree row reorder:', error);
|
|
1425
|
-
}
|
|
1426
|
-
}, [
|
|
1427
|
-
onTreeRowReorder,
|
|
1428
|
-
selectedReorderRowIds,
|
|
1429
|
-
selectedRowsForReorder,
|
|
1430
|
-
table,
|
|
1431
|
-
row,
|
|
1432
|
-
]);
|
|
1433
|
-
return {
|
|
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
|
-
};
|
|
1376
|
+
if (rowActionMenuItems === null || rowActionMenuItems === void 0 ? void 0 : rowActionMenuItems.length)
|
|
1377
|
+
items.push(...rowActionMenuItems);
|
|
1378
|
+
return items;
|
|
1379
|
+
}, [renderRowActionMenuItems, row, staticRowIndex, table]);
|
|
1380
|
+
if (!menuItems.length)
|
|
1381
|
+
return null;
|
|
1382
|
+
return (jsx(Menu, Object.assign({ MenuListProps: {
|
|
1383
|
+
dense: density === 'compact',
|
|
1384
|
+
sx: {
|
|
1385
|
+
backgroundColor: menuBackgroundColor,
|
|
1386
|
+
},
|
|
1387
|
+
}, anchorEl: anchorEl, disableScrollLock: true, onClick: (event) => event.stopPropagation(), onClose: () => setAnchorEl(null), open: !!anchorEl }, rest, { children: menuItems })));
|
|
1443
1388
|
};
|
|
1444
1389
|
|
|
1445
|
-
const
|
|
1446
|
-
|
|
1447
|
-
const
|
|
1448
|
-
const
|
|
1449
|
-
const
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
return;
|
|
1456
|
-
}
|
|
1457
|
-
try {
|
|
1458
|
-
const treeRowReorderEvent = {
|
|
1459
|
-
selectedRowIds: selectedReorderRowIds,
|
|
1460
|
-
selectedRows: selectedRowsForReorder,
|
|
1461
|
-
table,
|
|
1462
|
-
targetRow: null,
|
|
1463
|
-
};
|
|
1464
|
-
onTreeRowReorder(treeRowReorderEvent);
|
|
1390
|
+
const MRT_EditActionButtons = (_a) => {
|
|
1391
|
+
var { row, table, variant = 'icon' } = _a, rest = __rest(_a, ["row", "table", "variant"]);
|
|
1392
|
+
const { getState, options: { icons: { CancelIcon, SaveIcon }, localization, onCreatingRowCancel, onCreatingRowSave, onEditingRowCancel, onEditingRowSave, }, refs: { editInputRefs }, setCreatingRow, setEditingRow, } = table;
|
|
1393
|
+
const { creatingRow, isSaving } = getState();
|
|
1394
|
+
const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
|
|
1395
|
+
const isEditing = useMRT_SliceValue(table._uiStore, (s) => { var _a; return ((_a = s.editingRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
|
|
1396
|
+
const handleCancel = () => {
|
|
1397
|
+
if (isCreating) {
|
|
1398
|
+
onCreatingRowCancel === null || onCreatingRowCancel === void 0 ? void 0 : onCreatingRowCancel({ row, table });
|
|
1399
|
+
setCreatingRow(null);
|
|
1465
1400
|
}
|
|
1466
|
-
|
|
1467
|
-
|
|
1401
|
+
else if (isEditing) {
|
|
1402
|
+
onEditingRowCancel === null || onEditingRowCancel === void 0 ? void 0 : onEditingRowCancel({ row, table });
|
|
1403
|
+
setEditingRow(null);
|
|
1468
1404
|
}
|
|
1469
|
-
|
|
1470
|
-
return {
|
|
1471
|
-
shouldShowMoveToTopLevelAction,
|
|
1472
|
-
handleMoveToTopLevelActionClick,
|
|
1405
|
+
row._valuesCache = {}; //reset values cache
|
|
1473
1406
|
};
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
const cellLogic = useTreeRowReorderingCell({
|
|
1407
|
+
const handleSubmitRow = () => {
|
|
1408
|
+
var _a, _b;
|
|
1409
|
+
//look for auto-filled input values
|
|
1410
|
+
(_b = Object.values((_a = editInputRefs.current) !== null && _a !== void 0 ? _a : {})
|
|
1411
|
+
.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) => {
|
|
1412
|
+
if (input.value !== undefined &&
|
|
1413
|
+
Object.hasOwn(row === null || row === void 0 ? void 0 : row._valuesCache, input.name)) {
|
|
1414
|
+
// @ts-expect-error
|
|
1415
|
+
row._valuesCache[input.name] = input.value;
|
|
1416
|
+
}
|
|
1417
|
+
});
|
|
1418
|
+
if (isCreating)
|
|
1419
|
+
onCreatingRowSave === null || onCreatingRowSave === void 0 ? void 0 : onCreatingRowSave({
|
|
1420
|
+
exitCreatingMode: () => setCreatingRow(null),
|
|
1489
1421
|
row,
|
|
1490
1422
|
table,
|
|
1491
|
-
|
|
1492
|
-
maxDepth,
|
|
1493
|
-
onTreeRowReorder,
|
|
1423
|
+
values: row._valuesCache,
|
|
1494
1424
|
});
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
cell,
|
|
1499
|
-
column,
|
|
1425
|
+
else if (isEditing) {
|
|
1426
|
+
onEditingRowSave === null || onEditingRowSave === void 0 ? void 0 : onEditingRowSave({
|
|
1427
|
+
exitEditingMode: () => setEditingRow(null),
|
|
1500
1428
|
row,
|
|
1501
1429
|
table,
|
|
1502
|
-
|
|
1430
|
+
values: row === null || row === void 0 ? void 0 : row._valuesCache,
|
|
1503
1431
|
});
|
|
1504
|
-
|
|
1505
|
-
const defaultGroupedCell = (jsx(Tooltip, Object.assign({}, getCommonTooltipProps('right'), { title: table.getColumn(row.groupingColumnId).columnDef.header, children: jsx("span", { children: row.groupingValue }) })));
|
|
1506
|
-
return (jsxs(Stack, { alignItems: "center", flexDirection: "row", gap: TREE_REORDER_ICON_SPACING, onMouseEnter: cellLogic.handleRowHoverEnter, onMouseLeave: cellLogic.handleRowHoverLeave, width: "100%", children: [jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), column.columnDef.GroupedCell
|
|
1507
|
-
? customGroupedCell
|
|
1508
|
-
: defaultGroupedCell, cellLogic.shouldShowReorderCheckbox && (jsx(MRT_ReorderRowCheckbox, { isSelected: cellLogic.isReorderCheckboxSelected, onChange: cellLogic.handleReorderCheckboxChange })), cellLogic.shouldShowInsertHereAction && (jsx(MRT_InsertHereAction, { onClick: cellLogic.handleInsertHereActionClick })), !!subRowsLength && jsxs("span", { children: ["(", subRowsLength, ")"] })] }));
|
|
1509
|
-
}
|
|
1510
|
-
return (jsxs(Stack, { alignItems: "center", flexDirection: "row", gap: TREE_REORDER_ICON_SPACING, onMouseEnter: cellLogic.handleRowHoverEnter, onMouseLeave: cellLogic.handleRowHoverLeave, width: "100%", children: [jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), customGroupedCell, cellLogic.shouldShowReorderCheckbox && (jsx(MRT_ReorderRowCheckbox, { isSelected: cellLogic.isReorderCheckboxSelected, onChange: cellLogic.handleReorderCheckboxChange })), cellLogic.shouldShowInsertHereAction && (jsx(MRT_InsertHereAction, { onClick: cellLogic.handleInsertHereActionClick }))] }));
|
|
1511
|
-
}, Header: enableExpandAll
|
|
1512
|
-
? ({ table }) => {
|
|
1513
|
-
var _a;
|
|
1514
|
-
const headerLogic = useTreeRowReorderingHeader({
|
|
1515
|
-
table,
|
|
1516
|
-
enableRowReordering,
|
|
1517
|
-
onTreeRowReorder,
|
|
1518
|
-
});
|
|
1519
|
-
return (jsxs(Stack, { alignItems: "center", flexDirection: "row", gap: TREE_REORDER_ICON_SPACING, children: [jsx(MRT_ExpandAllButton, { table: table }), headerLogic.shouldShowMoveToTopLevelAction && (jsx(MRT_MoveToTopAction, { onClick: headerLogic.handleMoveToTopLevelActionClick })), groupedColumnMode === 'remove' &&
|
|
1520
|
-
((_a = grouping === null || grouping === void 0 ? void 0 : grouping.map((groupedColumnId) => table.getColumn(groupedColumnId).columnDef.header)) === null || _a === void 0 ? void 0 : _a.join(', '))] }));
|
|
1521
|
-
}
|
|
1522
|
-
: undefined, muiTableBodyCellProps: alignProps, muiTableHeadCellProps: alignProps }, defaultDisplayColumnProps({
|
|
1523
|
-
header: 'expand',
|
|
1524
|
-
id: 'mrt-row-expand',
|
|
1525
|
-
size: groupedColumnMode === 'remove'
|
|
1526
|
-
? ((_a = defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.size) !== null && _a !== void 0 ? _a : 180)
|
|
1527
|
-
: renderDetailPanel
|
|
1528
|
-
? enableExpandAll
|
|
1529
|
-
? 60
|
|
1530
|
-
: 70
|
|
1531
|
-
: 100,
|
|
1532
|
-
tableOptions,
|
|
1533
|
-
})), { enableResizing: true });
|
|
1534
|
-
};
|
|
1535
|
-
|
|
1536
|
-
const getMRT_RowNumbersColumnDef = (tableOptions) => {
|
|
1537
|
-
const { localization, rowNumberDisplayMode } = tableOptions;
|
|
1538
|
-
const { pagination: { pageIndex, pageSize }, } = tableOptions.state;
|
|
1539
|
-
return Object.assign({ Cell: ({ row, staticRowIndex }) => {
|
|
1540
|
-
var _a;
|
|
1541
|
-
return ((_a = (rowNumberDisplayMode === 'static'
|
|
1542
|
-
? (staticRowIndex || 0) + (pageSize || 0) * (pageIndex || 0)
|
|
1543
|
-
: row.index)) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
1544
|
-
}, Header: () => localization.rowNumber, grow: false }, defaultDisplayColumnProps({
|
|
1545
|
-
header: 'rowNumbers',
|
|
1546
|
-
id: 'mrt-row-numbers',
|
|
1547
|
-
size: 50,
|
|
1548
|
-
tableOptions,
|
|
1549
|
-
}));
|
|
1550
|
-
};
|
|
1551
|
-
|
|
1552
|
-
const MRT_RowPinButton = (_a) => {
|
|
1553
|
-
var { pinningPosition, row, table } = _a, rest = __rest(_a, ["pinningPosition", "row", "table"]);
|
|
1554
|
-
const { options: { icons: { CloseIcon, PushPinIcon }, localization, rowPinningDisplayMode, }, } = table;
|
|
1555
|
-
const isPinned = row.getIsPinned();
|
|
1556
|
-
const [tooltipOpened, setTooltipOpened] = useState(false);
|
|
1557
|
-
const handleTogglePin = (event) => {
|
|
1558
|
-
setTooltipOpened(false);
|
|
1559
|
-
event.stopPropagation();
|
|
1560
|
-
row.pin(isPinned ? false : pinningPosition);
|
|
1432
|
+
}
|
|
1561
1433
|
};
|
|
1562
|
-
return (jsx(
|
|
1563
|
-
|
|
1564
|
-
? 135
|
|
1565
|
-
: pinningPosition === 'top'
|
|
1566
|
-
? 180
|
|
1567
|
-
: 0}deg)`,
|
|
1568
|
-
} })) })) })));
|
|
1434
|
+
return (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' ? (jsxs(Fragment, { children: [jsx(Tooltip, { title: localization.cancel, children: jsx(IconButton, { "aria-label": localization.cancel, onClick: handleCancel, children: jsx(CancelIcon, {}) }) }), ((isCreating && onCreatingRowSave) ||
|
|
1435
|
+
(isEditing && onEditingRowSave)) && (jsx(Tooltip, { title: localization.save, children: jsx(IconButton, { "aria-label": localization.save, color: "info", disabled: isSaving, onClick: handleSubmitRow, children: isSaving ? jsx(CircularProgress, { size: 18 }) : jsx(SaveIcon, {}) }) }))] })) : (jsxs(Fragment, { children: [jsx(Button, { onClick: handleCancel, sx: { minWidth: '100px' }, children: localization.cancel }), jsxs(Button, { disabled: isSaving, onClick: handleSubmitRow, sx: { minWidth: '100px' }, variant: "contained", children: [isSaving && jsx(CircularProgress, { color: "inherit", size: 18 }), localization.save] })] })) }));
|
|
1569
1436
|
};
|
|
1570
1437
|
|
|
1571
|
-
const
|
|
1572
|
-
|
|
1573
|
-
const
|
|
1574
|
-
const
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1438
|
+
const parseCSSVarId = (id) => id.replace(/[^a-zA-Z0-9]/g, '_');
|
|
1439
|
+
const getMRTTheme = (mrtTheme, muiTheme) => {
|
|
1440
|
+
const mrtThemeOverrides = parseFromValuesOrFunc(mrtTheme, muiTheme);
|
|
1441
|
+
const baseBackgroundColor = muiTheme.palette.background.default;
|
|
1442
|
+
return Object.assign({ baseBackgroundColor, cellNavigationOutlineColor: muiTheme.palette.primary.main, draggingBorderColor: muiTheme.palette.primary.main, matchHighlightColor: muiTheme.palette.mode === 'dark'
|
|
1443
|
+
? darken(muiTheme.palette.warning.dark, 0.25)
|
|
1444
|
+
: lighten(muiTheme.palette.warning.light, 0.5), menuBackgroundColor: lighten(baseBackgroundColor, 0.07), pinnedRowBackgroundColor: alpha(muiTheme.palette.primary.main, 0.1), selectedRowBackgroundColor: alpha(muiTheme.palette.primary.main, 0.2) }, mrtThemeOverrides);
|
|
1445
|
+
};
|
|
1446
|
+
const commonCellBeforeAfterStyles = {
|
|
1447
|
+
content: '""',
|
|
1448
|
+
height: '100%',
|
|
1449
|
+
left: 0,
|
|
1450
|
+
position: 'absolute',
|
|
1451
|
+
top: 0,
|
|
1452
|
+
width: '100%',
|
|
1453
|
+
zIndex: -1,
|
|
1454
|
+
};
|
|
1455
|
+
const getCommonPinnedCellStyles = ({ table, theme, }) => {
|
|
1456
|
+
const { baseBackgroundColor } = table.options.mrtTheme;
|
|
1457
|
+
return {
|
|
1458
|
+
'&[data-pinned="true"]': {
|
|
1459
|
+
'&:before': Object.assign({ backgroundColor: alpha(darken(baseBackgroundColor, theme.palette.mode === 'dark' ? 0.05 : 0.01), 0.97) }, commonCellBeforeAfterStyles),
|
|
1460
|
+
},
|
|
1461
|
+
};
|
|
1462
|
+
};
|
|
1463
|
+
const getCommonMRTCellStyles = ({ column, header, isDraggingColumn, isHoveredColumn, table, tableCellProps, theme, }) => {
|
|
1464
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1465
|
+
const { options: { enableColumnVirtualization, layoutMode }, } = table;
|
|
1466
|
+
const { columnDef } = column;
|
|
1467
|
+
const { columnDefType } = columnDef;
|
|
1468
|
+
const isColumnPinned = columnDef.columnDefType !== 'group' && column.getIsPinned();
|
|
1469
|
+
const widthStyles = {
|
|
1470
|
+
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)`,
|
|
1471
|
+
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)`,
|
|
1472
|
+
};
|
|
1473
|
+
if (layoutMode === 'grid') {
|
|
1474
|
+
widthStyles.flex = `${[0, false].includes(columnDef.grow)
|
|
1475
|
+
? 0
|
|
1476
|
+
: `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`;
|
|
1585
1477
|
}
|
|
1586
|
-
|
|
1478
|
+
else if (layoutMode === 'grid-no-grow') {
|
|
1479
|
+
widthStyles.flex = `${+(columnDef.grow || 0)} 0 auto`;
|
|
1480
|
+
}
|
|
1481
|
+
// The checkbox column is technically pinned (for sticky positioning) but
|
|
1482
|
+
// should look like a regular center column — no background overlay or shadow.
|
|
1483
|
+
const isCheckboxColumn = column.id === CHECKBOX_DISPLAY_COLUMN_ID;
|
|
1484
|
+
// Count all currently pinned column IDs across both sides.
|
|
1485
|
+
// Checkbox is always pinned (counts as 1), so > 1 means the user has
|
|
1486
|
+
// explicitly pinned at least one additional column.
|
|
1487
|
+
const totalPinnedColumnCount = [
|
|
1488
|
+
...((_e = table.getState().columnPinning.left) !== null && _e !== void 0 ? _e : []),
|
|
1489
|
+
...((_f = table.getState().columnPinning.right) !== null && _f !== void 0 ? _f : []),
|
|
1490
|
+
].length;
|
|
1491
|
+
const hasNoPinnedColumns = totalPinnedColumnCount === 0;
|
|
1492
|
+
const pinnedStyles = isColumnPinned
|
|
1493
|
+
? Object.assign(Object.assign({}, (isCheckboxColumn
|
|
1494
|
+
? hasNoPinnedColumns
|
|
1495
|
+
? {
|
|
1496
|
+
// Use doubled class selector (&&) to beat the row-level
|
|
1497
|
+
// td[data-pinned="true"]:before specificity from MRT_TableBodyRow.
|
|
1498
|
+
'&&[data-pinned="true"]': {
|
|
1499
|
+
'&:before': {
|
|
1500
|
+
backgroundColor: 'transparent',
|
|
1501
|
+
boxShadow: 'none',
|
|
1502
|
+
},
|
|
1503
|
+
},
|
|
1504
|
+
}
|
|
1505
|
+
: // Other columns are also pinned — apply standard pinned background
|
|
1506
|
+
// so the checkbox header matches the pinned row cells below it.
|
|
1507
|
+
getCommonPinnedCellStyles({ column, table, theme })
|
|
1508
|
+
: getCommonPinnedCellStyles({ column, table, theme }))), { left: isColumnPinned === 'left'
|
|
1509
|
+
? `${column.getStart('left')}px`
|
|
1510
|
+
: undefined,
|
|
1511
|
+
// Skip opacity reduction for checkbox — keep it fully opaque like center columns
|
|
1512
|
+
opacity: isCheckboxColumn ? undefined : 0.97, position: 'sticky', right: isColumnPinned === 'right'
|
|
1513
|
+
? `${column.getAfter('right')}px`
|
|
1514
|
+
: undefined }) : {};
|
|
1515
|
+
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'
|
|
1516
|
+
? 'center'
|
|
1517
|
+
: (layoutMode === null || layoutMode === void 0 ? void 0 : layoutMode.startsWith('grid'))
|
|
1518
|
+
? tableCellProps.align
|
|
1519
|
+
: undefined, opacity: isDraggingColumn || isHoveredColumn ? 0.5 : 1, position: 'relative', transition: enableColumnVirtualization
|
|
1520
|
+
? 'none'
|
|
1521
|
+
: `padding 150ms ease-in-out`, zIndex: column.getIsResizing() || isDraggingColumn
|
|
1522
|
+
? 2
|
|
1523
|
+
: columnDefType !== 'group' && isColumnPinned
|
|
1524
|
+
? 1
|
|
1525
|
+
: 0, '&:focus-visible': {
|
|
1526
|
+
outline: `2px solid ${table.options.mrtTheme.cellNavigationOutlineColor}`,
|
|
1527
|
+
outlineOffset: '-2px',
|
|
1528
|
+
} }, pinnedStyles), widthStyles), parseFromValuesOrFunc(tableCellProps === null || tableCellProps === void 0 ? void 0 : tableCellProps.sx, theme));
|
|
1587
1529
|
};
|
|
1530
|
+
const getCommonToolbarStyles = ({ table, }) => ({
|
|
1531
|
+
alignItems: 'flex-start',
|
|
1532
|
+
backgroundColor: table.options.mrtTheme.baseBackgroundColor,
|
|
1533
|
+
display: 'grid',
|
|
1534
|
+
flexWrap: 'wrap-reverse',
|
|
1535
|
+
position: 'relative',
|
|
1536
|
+
transition: 'all 150ms ease-in-out',
|
|
1537
|
+
zIndex: 1,
|
|
1538
|
+
});
|
|
1539
|
+
const flipIconStyles = (theme) => theme.direction === 'rtl'
|
|
1540
|
+
? { style: { transform: 'scaleX(-1)' } }
|
|
1541
|
+
: undefined;
|
|
1542
|
+
const getCommonTooltipProps = (placement) => ({
|
|
1543
|
+
disableInteractive: true,
|
|
1544
|
+
enterDelay: 1000,
|
|
1545
|
+
enterNextDelay: 1000,
|
|
1546
|
+
placement,
|
|
1547
|
+
});
|
|
1588
1548
|
|
|
1589
|
-
const
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1549
|
+
const commonIconButtonStyles = {
|
|
1550
|
+
'&:hover': {
|
|
1551
|
+
opacity: 1,
|
|
1552
|
+
},
|
|
1553
|
+
height: '2rem',
|
|
1554
|
+
ml: '10px',
|
|
1555
|
+
opacity: 0.5,
|
|
1556
|
+
transition: 'opacity 150ms',
|
|
1557
|
+
width: '2rem',
|
|
1596
1558
|
};
|
|
1597
|
-
|
|
1598
|
-
|
|
1559
|
+
const MRT_ToggleRowActionMenuButton = (_a) => {
|
|
1560
|
+
var _b;
|
|
1561
|
+
var { cell, row, staticRowIndex, table } = _a, rest = __rest(_a, ["cell", "row", "staticRowIndex", "table"]);
|
|
1562
|
+
const { getState, options: { createDisplayMode, editDisplayMode, enableEditing, icons: { EditIcon, MoreHorizIcon }, localization, renderRowActionMenuItems, renderRowActions, }, setEditingRow, } = table;
|
|
1563
|
+
const { creatingRow } = getState();
|
|
1564
|
+
const isCreating = (creatingRow === null || creatingRow === void 0 ? void 0 : creatingRow.id) === row.id;
|
|
1565
|
+
const isEditing = useMRT_SliceValue(table._uiStore, (s) => { var _a; return ((_a = s.editingRow) === null || _a === void 0 ? void 0 : _a.id) === row.id; });
|
|
1566
|
+
const showEditActionButtons = (isCreating && createDisplayMode === 'row') ||
|
|
1567
|
+
(isEditing && editDisplayMode === 'row');
|
|
1599
1568
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
1600
|
-
const
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
const { isLoading, rowSelection } = getState();
|
|
1604
|
-
const isAllCurrentPageSelected = table.getIsAllPageRowsSelected();
|
|
1605
|
-
const isAllPagesActive = getIsAllPagesSelectionActive(table, rowSelection);
|
|
1606
|
-
const handleOpen = (event) => {
|
|
1569
|
+
const handleOpenRowActionMenu = (event) => {
|
|
1570
|
+
event.stopPropagation();
|
|
1571
|
+
event.preventDefault();
|
|
1607
1572
|
setAnchorEl(event.currentTarget);
|
|
1608
1573
|
};
|
|
1609
|
-
const
|
|
1574
|
+
const handleStartEditMode = (event) => {
|
|
1575
|
+
event.stopPropagation();
|
|
1576
|
+
setEditingRow(Object.assign({}, row));
|
|
1610
1577
|
setAnchorEl(null);
|
|
1611
1578
|
};
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
}
|
|
1617
|
-
};
|
|
1618
|
-
// ── Current-page actions ────────────────────────────────────────────────────
|
|
1619
|
-
const handleSelectCurrentPage = () => {
|
|
1620
|
-
table.toggleAllPageRowsSelected(true);
|
|
1621
|
-
clearPinning();
|
|
1622
|
-
handleClose();
|
|
1623
|
-
};
|
|
1624
|
-
const handleDeselectCurrentPage = () => {
|
|
1625
|
-
if (allSelectableRowIdsRef.current.length > 0) {
|
|
1626
|
-
// 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.
|
|
1627
|
-
table.setRowSelection({});
|
|
1628
|
-
allSelectableRowIdsRef.current = [];
|
|
1629
|
-
}
|
|
1630
|
-
else {
|
|
1631
|
-
table.toggleAllPageRowsSelected(false);
|
|
1632
|
-
}
|
|
1633
|
-
clearPinning();
|
|
1634
|
-
handleClose();
|
|
1635
|
-
};
|
|
1636
|
-
// ── All-pages actions ───────────────────────────────────────────────────────
|
|
1637
|
-
const handleSelectAllPages = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
1638
|
-
handleClose();
|
|
1639
|
-
if (getAllSelectableRowIds) {
|
|
1640
|
-
// Server-side: IDs are not available locally, fetch them from the API
|
|
1641
|
-
setIsSelectingAllPages(true);
|
|
1642
|
-
table.setShowProgressBars(true);
|
|
1643
|
-
try {
|
|
1644
|
-
const ids = yield getAllSelectableRowIds({ table });
|
|
1645
|
-
allSelectableRowIdsRef.current = ids;
|
|
1646
|
-
const newSelection = {};
|
|
1647
|
-
ids.forEach((id) => {
|
|
1648
|
-
newSelection[id] = true;
|
|
1649
|
-
});
|
|
1650
|
-
table.setRowSelection(newSelection);
|
|
1651
|
-
clearPinning();
|
|
1652
|
-
}
|
|
1653
|
-
finally {
|
|
1654
|
-
setIsSelectingAllPages(false);
|
|
1655
|
-
table.setShowProgressBars(false);
|
|
1656
|
-
}
|
|
1657
|
-
}
|
|
1658
|
-
else {
|
|
1659
|
-
// Client-side: all data is available locally
|
|
1660
|
-
table.toggleAllRowsSelected(true);
|
|
1661
|
-
clearPinning();
|
|
1662
|
-
}
|
|
1663
|
-
});
|
|
1664
|
-
const handleDeselectAllPages = () => {
|
|
1665
|
-
if (getAllSelectableRowIds) {
|
|
1666
|
-
table.setRowSelection({});
|
|
1667
|
-
}
|
|
1668
|
-
else {
|
|
1669
|
-
table.toggleAllRowsSelected(false);
|
|
1670
|
-
}
|
|
1671
|
-
allSelectableRowIdsRef.current = [];
|
|
1672
|
-
clearPinning();
|
|
1673
|
-
handleClose();
|
|
1674
|
-
};
|
|
1675
|
-
const isDisabled = isLoading || isSelectingAllPages;
|
|
1676
|
-
return (jsxs(Fragment, { children: [jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.toggleSelectAll, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.toggleSelectAll, disabled: isDisabled, onClick: handleOpen, size: "small", sx: { height: '1.5rem', width: '1.5rem' }, children: jsx(table.options.icons.MoreVertIcon, { style: { transform: 'scale(0.85)' } }) }) }) })), jsxs(Menu, { anchorEl: anchorEl, onClose: handleClose, open: Boolean(anchorEl), children: [isAllCurrentPageSelected ? (jsx(MenuItem, { onClick: handleDeselectCurrentPage, children: localization.deselectAllOnCurrentPage })) : (jsx(MenuItem, { onClick: handleSelectCurrentPage, children: localization.selectAllOnCurrentPage })), isAllPagesActive ? (jsx(MenuItem, { onClick: handleDeselectAllPages, children: localization.deselectAllOnAllPages })) : (jsxs(MenuItem, { disabled: isSelectingAllPages, onClick: handleSelectAllPages, children: [isSelectingAllPages && (jsx(CircularProgress, { "aria-label": "Loading", size: 14, sx: { mr: 1 } })), localization.selectAllOnAllPages] }))] })] }));
|
|
1677
|
-
};
|
|
1678
|
-
|
|
1679
|
-
const MRT_SelectCheckbox = (_a) => {
|
|
1680
|
-
var _b;
|
|
1681
|
-
var { row, staticRowIndex, table } = _a, rest = __rest(_a, ["row", "staticRowIndex", "table"]);
|
|
1682
|
-
const { getState, options: { enableMultiRowSelection, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, selectAllMode, }, } = table;
|
|
1683
|
-
const { isLoading } = getState();
|
|
1684
|
-
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
1685
|
-
const selectAll = !row;
|
|
1686
|
-
const allRowsSelected = selectAll
|
|
1687
|
-
? selectAllMode === 'page'
|
|
1688
|
-
? table.getIsAllPageRowsSelected()
|
|
1689
|
-
: table.getIsAllRowsSelected()
|
|
1690
|
-
: undefined;
|
|
1691
|
-
const isChecked = selectAll
|
|
1692
|
-
? allRowsSelected
|
|
1693
|
-
: getIsRowSelected({ row, table });
|
|
1694
|
-
const checkboxProps = Object.assign(Object.assign({}, (selectAll
|
|
1695
|
-
? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
|
|
1696
|
-
: parseFromValuesOrFunc(muiSelectCheckboxProps, {
|
|
1579
|
+
return (jsx(Fragment, { children: renderRowActions && !showEditActionButtons ? (renderRowActions({ cell, row, staticRowIndex, table })) : showEditActionButtons ? (jsx(MRT_EditActionButtons, { row: row, table: table })) : !renderRowActionMenuItems &&
|
|
1580
|
+
parseFromValuesOrFunc(enableEditing, row) &&
|
|
1581
|
+
['modal', 'row'].includes(editDisplayMode) ? (jsx(Tooltip, { placement: "right", title: localization.edit, children: jsx(IconButton, Object.assign({ "aria-label": localization.edit, onClick: handleStartEditMode, sx: commonIconButtonStyles }, rest, { children: jsx(EditIcon, {}) })) })) : ((_b = renderRowActionMenuItems === null || renderRowActionMenuItems === void 0 ? void 0 : renderRowActionMenuItems({
|
|
1582
|
+
closeMenu: () => { },
|
|
1697
1583
|
row,
|
|
1698
1584
|
staticRowIndex,
|
|
1699
1585
|
table,
|
|
1700
|
-
}))), rest);
|
|
1701
|
-
const onSelectionChange = row
|
|
1702
|
-
? getMRT_RowSelectionHandler({
|
|
1703
|
-
row,
|
|
1704
|
-
staticRowIndex,
|
|
1705
|
-
table,
|
|
1706
|
-
})
|
|
1707
|
-
: undefined;
|
|
1708
|
-
const onSelectAllChange = getMRT_SelectAllHandler({ table });
|
|
1709
|
-
const commonProps = Object.assign(Object.assign({ 'aria-label': selectAll
|
|
1710
|
-
? localization.toggleSelectAll
|
|
1711
|
-
: localization.toggleSelectRow, checked: isChecked, disabled: isLoading || (row && !row.getCanSelect()) || (row === null || row === void 0 ? void 0 : row.id) === 'mrt-row-create', inputProps: {
|
|
1712
|
-
'aria-label': selectAll
|
|
1713
|
-
? localization.toggleSelectAll
|
|
1714
|
-
: localization.toggleSelectRow,
|
|
1715
|
-
}, onChange: (event) => {
|
|
1716
|
-
event.stopPropagation();
|
|
1717
|
-
selectAll ? onSelectAllChange(event) : onSelectionChange(event);
|
|
1718
|
-
}, size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
|
|
1719
|
-
var _a;
|
|
1720
|
-
e.stopPropagation();
|
|
1721
|
-
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
|
|
1722
|
-
}, 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 });
|
|
1723
|
-
return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: (_b = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _b !== void 0 ? _b : (selectAll
|
|
1724
|
-
? localization.toggleSelectAll
|
|
1725
|
-
: localization.toggleSelectRow), children: enableMultiRowSelection === false ? (jsx(Radio, Object.assign({}, commonProps))) : (jsx(Checkbox, Object.assign({ disableRipple: true, indeterminate: !isChecked && selectAll
|
|
1726
|
-
? table.getIsSomeRowsSelected()
|
|
1727
|
-
: (row === null || row === void 0 ? void 0 : row.getIsSomeSelected()) && row.getCanSelectSubRows() }, commonProps))) })));
|
|
1586
|
+
})) === null || _b === void 0 ? void 0 : _b.length) ? (jsxs(Fragment, { children: [jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.rowActions, children: jsx(IconButton, Object.assign({ "aria-label": localization.rowActions, onClick: handleOpenRowActionMenu, size: "small", sx: commonIconButtonStyles }, rest, { children: jsx(MoreHorizIcon, {}) })) })), jsx(MRT_RowActionMenu, { anchorEl: anchorEl, handleEdit: handleStartEditMode, row: row, setAnchorEl: setAnchorEl, staticRowIndex: staticRowIndex, table: table })] })) : null }));
|
|
1728
1587
|
};
|
|
1729
1588
|
|
|
1730
|
-
const
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
header: 'select',
|
|
1736
|
-
id: '__check__',
|
|
1737
|
-
size: enableSelectAll ? 90 : 70, // widened from 60 to accommodate both the checkbox and the menu button
|
|
1589
|
+
const getMRT_RowActionsColumnDef = (tableOptions) => {
|
|
1590
|
+
return Object.assign({ Cell: ({ cell, row, staticRowIndex, table }) => (jsx(MRT_ToggleRowActionMenuButton, { cell: cell, row: row, staticRowIndex: staticRowIndex, table: table })) }, defaultDisplayColumnProps({
|
|
1591
|
+
header: 'actions',
|
|
1592
|
+
id: 'mrt-row-actions',
|
|
1593
|
+
size: 70,
|
|
1738
1594
|
tableOptions,
|
|
1739
1595
|
}));
|
|
1740
1596
|
};
|
|
1741
1597
|
|
|
1742
|
-
const
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
DynamicFeedIcon,
|
|
1757
|
-
EditIcon,
|
|
1758
|
-
ExpandMoreIcon,
|
|
1759
|
-
FilterAltIcon,
|
|
1760
|
-
FilterListIcon,
|
|
1761
|
-
FilterListOffIcon,
|
|
1762
|
-
FirstPageIcon,
|
|
1763
|
-
FullscreenExitIcon,
|
|
1764
|
-
FullscreenIcon,
|
|
1765
|
-
KeyboardDoubleArrowDownIcon,
|
|
1766
|
-
LastPageIcon,
|
|
1767
|
-
MoreHorizIcon,
|
|
1768
|
-
MoreVertIcon,
|
|
1769
|
-
PushPinIcon,
|
|
1770
|
-
RestartAltIcon,
|
|
1771
|
-
SaveIcon,
|
|
1772
|
-
SearchIcon,
|
|
1773
|
-
SearchOffIcon,
|
|
1774
|
-
SortIcon,
|
|
1775
|
-
SyncAltIcon,
|
|
1776
|
-
ViewColumnIcon,
|
|
1777
|
-
VisibilityOffIcon,
|
|
1778
|
-
};
|
|
1779
|
-
|
|
1780
|
-
const MRT_Localization_EN = {
|
|
1781
|
-
language: 'en',
|
|
1782
|
-
actions: 'Actions',
|
|
1783
|
-
and: 'and',
|
|
1784
|
-
booleanFalse: 'False',
|
|
1785
|
-
booleanTrue: 'True',
|
|
1786
|
-
cancel: 'Cancel',
|
|
1787
|
-
close: 'Close',
|
|
1788
|
-
changeFilterMode: 'Change filter mode',
|
|
1789
|
-
changeSearchMode: 'Change search mode',
|
|
1790
|
-
clearFilter: 'Clear filter',
|
|
1791
|
-
clearSearch: 'Clear search',
|
|
1792
|
-
clearSelection: 'Clear selection',
|
|
1793
|
-
clearSort: 'Clear sort',
|
|
1794
|
-
deselectAllOnAllPages: 'Deselect all on all pages',
|
|
1795
|
-
deselectAllOnCurrentPage: 'Deselect all on current page',
|
|
1796
|
-
clickToCopy: 'Click to copy',
|
|
1797
|
-
copy: 'Copy',
|
|
1798
|
-
collapse: 'Collapse',
|
|
1799
|
-
collapseAll: 'Collapse all',
|
|
1800
|
-
columnActions: 'Column Actions',
|
|
1801
|
-
columns: 'Columns',
|
|
1802
|
-
copiedToClipboard: 'Copied to clipboard',
|
|
1803
|
-
dropToGroupBy: 'Drop to group by {column}',
|
|
1804
|
-
edit: 'Edit',
|
|
1805
|
-
expand: 'Expand',
|
|
1806
|
-
expandAll: 'Expand all',
|
|
1807
|
-
filterArrIncludes: 'Includes',
|
|
1808
|
-
filterArrIncludesAll: 'Includes all',
|
|
1809
|
-
filterArrIncludesSome: 'Includes',
|
|
1810
|
-
filterBetween: 'Between',
|
|
1811
|
-
filterBetweenInclusive: 'Between Inclusive',
|
|
1812
|
-
filterByColumn: 'Filter by {column}',
|
|
1813
|
-
filterFrom: 'From',
|
|
1814
|
-
filterTo: 'To',
|
|
1815
|
-
filterContains: 'Contains',
|
|
1816
|
-
filterEmpty: 'Empty',
|
|
1817
|
-
filterEndsWith: 'Ends With',
|
|
1818
|
-
filterEquals: 'Equals',
|
|
1819
|
-
filterEqualsString: 'Equals',
|
|
1820
|
-
filterFuzzy: 'Fuzzy',
|
|
1821
|
-
filterGreaterThan: 'Greater Than',
|
|
1822
|
-
filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
|
|
1823
|
-
filterInArray: 'Is any of',
|
|
1824
|
-
filterIsAnyOf: 'Is any of',
|
|
1825
|
-
filterInNumberRange: 'Between',
|
|
1826
|
-
filterIncludesString: 'Contains',
|
|
1827
|
-
filterIncludesStringSensitive: 'Contains',
|
|
1828
|
-
filterLessThan: 'Less Than',
|
|
1829
|
-
filterLessThanOrEqualTo: 'Less Than Or Equal To',
|
|
1830
|
-
filterMode: 'Filter Mode: {filterType}',
|
|
1831
|
-
filterNoOptions: 'No filter options available',
|
|
1832
|
-
filterNotEmpty: 'Not Empty',
|
|
1833
|
-
filterNotEquals: 'Not Equals',
|
|
1834
|
-
filterNotContains: 'Does Not Contain',
|
|
1835
|
-
filterLogic: 'Logic',
|
|
1836
|
-
filterOperator: 'Operator',
|
|
1837
|
-
filterStartsWith: 'Starts With',
|
|
1838
|
-
filterWeakEquals: 'Equals',
|
|
1839
|
-
filterCurrentWeek: 'Current Week',
|
|
1840
|
-
filterCurrentMonth: 'Current Month',
|
|
1841
|
-
filterLast7Days: 'Last 7 Days',
|
|
1842
|
-
filterLastWeek: 'Last Week',
|
|
1843
|
-
filterLastMonth: 'Last Month',
|
|
1844
|
-
filterFromToday: 'From Today',
|
|
1845
|
-
filterToToday: 'To Today',
|
|
1846
|
-
filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
|
|
1847
|
-
goToFirstPage: 'Go to first page',
|
|
1848
|
-
goToLastPage: 'Go to last page',
|
|
1849
|
-
goToNextPage: 'Go to next page',
|
|
1850
|
-
goToPreviousPage: 'Go to previous page',
|
|
1851
|
-
grab: 'Grab',
|
|
1852
|
-
groupByColumn: 'Group by {column}',
|
|
1853
|
-
groupedBy: 'Grouped by ',
|
|
1854
|
-
hideAll: 'Hide all',
|
|
1855
|
-
hideColumn: 'Hide {column} column',
|
|
1856
|
-
max: 'Max',
|
|
1857
|
-
min: 'Min',
|
|
1858
|
-
move: 'Move',
|
|
1859
|
-
noRecordsToDisplay: 'No records to display',
|
|
1860
|
-
noResultsFound: 'No results found',
|
|
1861
|
-
moreThan: 'more than',
|
|
1862
|
-
of: 'of',
|
|
1863
|
-
or: 'or',
|
|
1864
|
-
pin: 'Pin',
|
|
1865
|
-
pinToLeft: 'Pin to left',
|
|
1866
|
-
pinToRight: 'Pin to right',
|
|
1867
|
-
resetColumnSize: 'Reset column size',
|
|
1868
|
-
resetOrder: 'Reset order',
|
|
1869
|
-
rowActions: 'Row Actions',
|
|
1870
|
-
rowNumber: '#',
|
|
1871
|
-
rowNumbers: 'Row Numbers',
|
|
1872
|
-
rowsPerPage: 'Rows per page',
|
|
1873
|
-
countRows: 'Count Rows',
|
|
1874
|
-
countRowsTooltip: 'Count total rows for current filters',
|
|
1875
|
-
rowCount: 'Row Count',
|
|
1876
|
-
rowsSelected: '{count} row(s) selected',
|
|
1877
|
-
save: 'Save',
|
|
1878
|
-
search: 'Search',
|
|
1879
|
-
selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
|
|
1880
|
-
select: 'Select',
|
|
1881
|
-
selectAllOnAllPages: 'Select all on all pages',
|
|
1882
|
-
selectAllOnCurrentPage: 'Select all on current page',
|
|
1883
|
-
showAll: 'Show all',
|
|
1884
|
-
showAllColumns: 'Show all columns',
|
|
1885
|
-
showHideColumns: 'Columns',
|
|
1886
|
-
showHideFilters: 'Show/Hide filters',
|
|
1887
|
-
showHideSearch: 'Show/Hide search',
|
|
1888
|
-
showAdvancedFilters: 'Show advanced filters',
|
|
1889
|
-
advancedFilters: 'Advanced Filters',
|
|
1890
|
-
filters: 'Filters',
|
|
1891
|
-
add: 'Add',
|
|
1892
|
-
newEntry: 'New Entry',
|
|
1893
|
-
clear: 'Clear',
|
|
1894
|
-
discardChanges: 'Discard changes',
|
|
1895
|
-
saveFilters: 'Save filters',
|
|
1896
|
-
savedFilters: 'Saved filters',
|
|
1897
|
-
noSavedFilters: 'No saved filters',
|
|
1898
|
-
filterName: 'Filter name',
|
|
1899
|
-
apply: 'Apply',
|
|
1900
|
-
sortByColumnAsc: 'Sort by {column} ascending',
|
|
1901
|
-
sortByColumnDesc: 'Sort by {column} descending',
|
|
1902
|
-
sortedByColumnAsc: 'Sorted by {column} ascending',
|
|
1903
|
-
sortedByColumnDesc: 'Sorted by {column} descending',
|
|
1904
|
-
thenBy: ', then by ',
|
|
1905
|
-
toggleDensity: 'Density',
|
|
1906
|
-
densityCompact: 'Compact',
|
|
1907
|
-
densityStandard: 'Standard',
|
|
1908
|
-
densityComfortable: 'Comfortable',
|
|
1909
|
-
toggleFullScreen: 'Toggle full screen',
|
|
1910
|
-
toggleSelectAll: 'Toggle select all',
|
|
1911
|
-
toggleSelectRow: 'Toggle select row',
|
|
1912
|
-
toggleVisibility: 'Toggle visibility',
|
|
1913
|
-
ungroupByColumn: 'Ungroup by {column}',
|
|
1914
|
-
unpin: 'Unpin',
|
|
1915
|
-
unpinAll: 'Unpin all',
|
|
1916
|
-
dimensionRotationEnabled: 'Rotation enabled',
|
|
1917
|
-
dimensionRotationDisabled: 'Rotation disabled',
|
|
1918
|
-
length: 'Length',
|
|
1919
|
-
width: 'Width',
|
|
1920
|
-
height: 'Height',
|
|
1921
|
-
depth: 'Depth',
|
|
1922
|
-
tolerance: 'Tolerance',
|
|
1923
|
-
exportButton: 'Export',
|
|
1924
|
-
exportSelectRowsTooltip: 'Select rows to export',
|
|
1925
|
-
exportPrintPdf: 'Print PDF',
|
|
1926
|
-
exportDownload: 'Download',
|
|
1927
|
-
exportGrouped: 'Group files',
|
|
1928
|
-
exportInProgress: 'Export in progress...',
|
|
1929
|
-
exportSuccess: 'Export completed successfully.',
|
|
1930
|
-
exportError: 'Export failed. Please try again.',
|
|
1931
|
-
exportNoExportsSelected: 'No export type selected. Please configure the export first.',
|
|
1932
|
-
deleteConfirmationTitle: 'Delete Row',
|
|
1933
|
-
deleteConfirmationMessage: 'Are you sure you want to delete the selected row(s)?',
|
|
1934
|
-
deleteConfirmYes: 'Delete',
|
|
1935
|
-
deleteConfirmNo: 'Cancel',
|
|
1936
|
-
deleteConfirmDeleting: 'Deleting...',
|
|
1937
|
-
errorTitle: 'Unexpected error',
|
|
1938
|
-
errorMessage: 'An unexpected error occurred. Please try again.',
|
|
1939
|
-
serverTableErrorTitle: 'Unable to load table',
|
|
1940
|
-
serverTableErrorMessage: 'Something went wrong while loading the table configuration. Please try again.',
|
|
1941
|
-
serverTableErrorRetry: 'Try again',
|
|
1942
|
-
resetState: 'Reset State',
|
|
1943
|
-
tableOptions: 'Options',
|
|
1598
|
+
const MRT_GrabHandleButton = (_a) => {
|
|
1599
|
+
var _b, _c;
|
|
1600
|
+
var { location, table } = _a, rest = __rest(_a, ["location", "table"]);
|
|
1601
|
+
const { options: { icons: { DragHandleIcon }, localization, }, } = table;
|
|
1602
|
+
return (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: 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) => {
|
|
1603
|
+
var _a;
|
|
1604
|
+
e.stopPropagation();
|
|
1605
|
+
(_a = rest === null || rest === void 0 ? void 0 : rest.onClick) === null || _a === void 0 ? void 0 : _a.call(rest, e);
|
|
1606
|
+
}, sx: (theme) => (Object.assign({ '&:active': {
|
|
1607
|
+
cursor: 'grabbing',
|
|
1608
|
+
}, '&:hover': {
|
|
1609
|
+
backgroundColor: 'transparent',
|
|
1610
|
+
opacity: 1,
|
|
1611
|
+
}, 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: jsx(DragHandleIcon, {}) })) })));
|
|
1944
1612
|
};
|
|
1945
1613
|
|
|
1946
|
-
const
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1614
|
+
const MRT_TableBodyRowGrabHandle = (_a) => {
|
|
1615
|
+
var { row, rowRef, table } = _a, rest = __rest(_a, ["row", "rowRef", "table"]);
|
|
1616
|
+
const { options: { muiRowDragHandleProps }, } = table;
|
|
1617
|
+
const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiRowDragHandleProps, {
|
|
1618
|
+
row,
|
|
1619
|
+
table,
|
|
1620
|
+
})), rest);
|
|
1621
|
+
const handleDragStart = (event) => {
|
|
1622
|
+
var _a;
|
|
1623
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragStart) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
1624
|
+
try {
|
|
1625
|
+
event.dataTransfer.setDragImage(rowRef.current, 0, 0);
|
|
1953
1626
|
}
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1627
|
+
catch (e) {
|
|
1628
|
+
console.error(e);
|
|
1629
|
+
}
|
|
1630
|
+
table.setDraggingRow(row);
|
|
1631
|
+
};
|
|
1632
|
+
const handleDragEnd = (event) => {
|
|
1633
|
+
var _a;
|
|
1634
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onDragEnd) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
1635
|
+
table.setDraggingRow(null);
|
|
1636
|
+
table.setHoveredRow(null);
|
|
1637
|
+
};
|
|
1638
|
+
return (jsx(MRT_GrabHandleButton, Object.assign({}, iconButtonProps, { location: "row", onDragEnd: handleDragEnd, onDragStart: handleDragStart, table: table })));
|
|
1963
1639
|
};
|
|
1964
1640
|
|
|
1965
|
-
const
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
}
|
|
1973
|
-
const blob = new Blob([bytes], { type: 'application/pdf' });
|
|
1974
|
-
const url = URL.createObjectURL(blob);
|
|
1975
|
-
printJS({
|
|
1976
|
-
printable: url,
|
|
1977
|
-
type: 'pdf',
|
|
1978
|
-
onLoadingEnd: () => URL.revokeObjectURL(url),
|
|
1979
|
-
});
|
|
1980
|
-
});
|
|
1641
|
+
const getMRT_RowDragColumnDef = (tableOptions) => {
|
|
1642
|
+
return Object.assign({ Cell: ({ row, rowRef, table }) => (jsx(MRT_TableBodyRowGrabHandle, { row: row, rowRef: rowRef, table: table })), grow: false }, defaultDisplayColumnProps({
|
|
1643
|
+
header: 'move',
|
|
1644
|
+
id: 'mrt-row-drag',
|
|
1645
|
+
size: 60,
|
|
1646
|
+
tableOptions,
|
|
1647
|
+
}));
|
|
1981
1648
|
};
|
|
1982
1649
|
|
|
1983
|
-
const
|
|
1650
|
+
const MRT_ExpandAllButton = (_a) => {
|
|
1651
|
+
var _b, _c;
|
|
1652
|
+
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
1653
|
+
const { getCanSomeRowsExpand, getIsAllRowsExpanded, getIsSomeRowsExpanded, getState, options: { icons: { KeyboardDoubleArrowDownIcon }, localization, muiExpandAllButtonProps, renderDetailPanel, }, toggleAllRowsExpanded, } = table;
|
|
1654
|
+
const { isLoading } = getState();
|
|
1655
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
1656
|
+
const iconButtonProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiExpandAllButtonProps, {
|
|
1657
|
+
table,
|
|
1658
|
+
})), rest);
|
|
1659
|
+
const isAllRowsExpanded = getIsAllRowsExpanded();
|
|
1660
|
+
return (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: jsx("span", { children: 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 : (jsx(KeyboardDoubleArrowDownIcon, { style: {
|
|
1661
|
+
transform: `rotate(${isAllRowsExpanded ? -180 : getIsSomeRowsExpanded() ? -90 : 0}deg)`,
|
|
1662
|
+
transition: 'transform 150ms',
|
|
1663
|
+
} })) })) }) })));
|
|
1664
|
+
};
|
|
1665
|
+
|
|
1666
|
+
const MRT_ExpandButton = ({ row, staticRowIndex, table, }) => {
|
|
1667
|
+
var _a, _b;
|
|
1984
1668
|
const theme = useTheme();
|
|
1985
|
-
const { localization } = table
|
|
1986
|
-
const
|
|
1987
|
-
const
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
const isNoRowsSelected = selectedRowIds.length === 0;
|
|
1992
|
-
const availableFormats = useMemo(() => {
|
|
1993
|
-
const allFormats = Object.values(availableExports).flatMap((exp) => exp.formats);
|
|
1994
|
-
return Array.from(new Set(allFormats));
|
|
1995
|
-
}, [availableExports]);
|
|
1996
|
-
const hasPdfFormat = availableFormats.includes('pdf');
|
|
1997
|
-
const exportTypesForSelectedFormat = useMemo(() => {
|
|
1998
|
-
if (!selectedFormat)
|
|
1999
|
-
return [];
|
|
2000
|
-
return Object.values(availableExports).filter((exp) => exp.formats.includes(selectedFormat));
|
|
2001
|
-
}, [availableExports, selectedFormat]);
|
|
2002
|
-
const isPrintDisabled = selectedFormat !== 'pdf' ||
|
|
2003
|
-
!selectedFormat ||
|
|
2004
|
-
selectedExports.length < 1 ||
|
|
2005
|
-
(!grouped && selectedExports.length > 1);
|
|
2006
|
-
const isDownloadDisabled = !selectedFormat || selectedExports.length < 1;
|
|
2007
|
-
const handleOpenMenu = (event) => {
|
|
2008
|
-
setAnchorEl(event.currentTarget);
|
|
2009
|
-
};
|
|
2010
|
-
const handleCloseMenu = () => {
|
|
2011
|
-
setAnchorEl(null);
|
|
2012
|
-
};
|
|
2013
|
-
const handleSelectFormat = (format) => {
|
|
2014
|
-
const newFormat = selectedFormat === format ? null : format;
|
|
2015
|
-
onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { grouped: false })), { selectedExports: [], selectedFormat: newFormat })));
|
|
2016
|
-
};
|
|
2017
|
-
const handleToggleExportType = (exportName) => {
|
|
2018
|
-
const isAlreadySelected = selectedExports.includes(exportName);
|
|
2019
|
-
const newSelectedExports = isAlreadySelected
|
|
2020
|
-
? selectedExports.filter((name) => name !== exportName)
|
|
2021
|
-
: [...selectedExports, exportName];
|
|
2022
|
-
onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { selectedFormat: null, grouped: false })), { selectedExports: newSelectedExports })));
|
|
2023
|
-
};
|
|
2024
|
-
const handleToggleGrouped = () => {
|
|
2025
|
-
onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { selectedFormat: null, selectedExports: [] })), { grouped: !grouped })));
|
|
2026
|
-
};
|
|
2027
|
-
const handleExportAction = (type) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2028
|
-
setLoadingExportType(type);
|
|
2029
|
-
try {
|
|
2030
|
-
const response = yield loadExport({
|
|
2031
|
-
format: selectedFormat,
|
|
2032
|
-
exports: selectedExports,
|
|
2033
|
-
separated_files: !grouped,
|
|
2034
|
-
download: false,
|
|
2035
|
-
ids: JSON.stringify(selectedRowIds),
|
|
2036
|
-
type,
|
|
2037
|
-
});
|
|
2038
|
-
handleCloseMenu();
|
|
2039
|
-
if (type === 'download') {
|
|
2040
|
-
downloadExportFiles(response);
|
|
2041
|
-
}
|
|
2042
|
-
else {
|
|
2043
|
-
printExportFiles(response);
|
|
2044
|
-
}
|
|
2045
|
-
}
|
|
2046
|
-
finally {
|
|
2047
|
-
setLoadingExportType(null);
|
|
2048
|
-
}
|
|
1669
|
+
const { options: { icons: { ExpandMoreIcon }, localization, maxDepth, muiExpandButtonProps, positionExpandColumn, renderDetailPanel, }, } = table;
|
|
1670
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
1671
|
+
const iconButtonProps = parseFromValuesOrFunc(muiExpandButtonProps, {
|
|
1672
|
+
row,
|
|
1673
|
+
staticRowIndex,
|
|
1674
|
+
table,
|
|
2049
1675
|
});
|
|
2050
|
-
const
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
return null;
|
|
2058
|
-
return (jsx(Stack, { minWidth: "250px", maxHeight: "500px", sx: { overflowY: 'auto' }, children: exportTypesForSelectedFormat.map((exportType) => (jsxs(MenuItem, { onClick: () => handleToggleExportType(exportType.name), value: exportType.name, children: [jsx(Checkbox, { checked: selectedExports.includes(exportType.name), size: "small" }), jsx(Typography, { variant: "body2", children: exportType.label })] }, exportType.name))) }));
|
|
2059
|
-
};
|
|
2060
|
-
const renderActionButtons = () => {
|
|
2061
|
-
const isAnyLoading = loadingExportType !== null;
|
|
2062
|
-
return (jsxs(Stack, { direction: "row", gap: 0.5, mt: 1, mr: 2, children: [hasPdfFormat && (jsx(Button, { sx: { display: 'flex', gap: 0.5 }, disabled: isPrintDisabled || isAnyLoading, onClick: () => handleExportAction('print'), startIcon: loadingExportType === 'print' ? (jsx(CircularProgress, { size: 16, color: "inherit" })) : (jsx(PrintIcon, { fontSize: "small" })), children: localization.exportPrintPdf })), jsx(Button, { sx: { display: 'flex', gap: 0.5 }, disabled: isDownloadDisabled || isAnyLoading, onClick: () => handleExportAction('download'), startIcon: loadingExportType === 'download' ? (jsx(CircularProgress, { size: 16, color: "inherit" })) : (jsx(FileDownloadIcon, { fontSize: "small" })), children: localization.exportDownload })] }));
|
|
1676
|
+
const canExpand = row.getCanExpand() && (maxDepth === undefined || row.depth < maxDepth - 1);
|
|
1677
|
+
const isExpanded = row.getIsExpanded();
|
|
1678
|
+
const handleToggleExpand = (event) => {
|
|
1679
|
+
var _a;
|
|
1680
|
+
event.stopPropagation();
|
|
1681
|
+
row.toggleExpanded();
|
|
1682
|
+
(_a = iconButtonProps === null || iconButtonProps === void 0 ? void 0 : iconButtonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(iconButtonProps, event);
|
|
2063
1683
|
};
|
|
2064
|
-
const
|
|
2065
|
-
return (
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
1684
|
+
const detailPanel = !!(renderDetailPanel === null || renderDetailPanel === void 0 ? void 0 : renderDetailPanel({ row, table }));
|
|
1685
|
+
return (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: jsx("span", { children: 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'
|
|
1686
|
+
? 'mr'
|
|
1687
|
+
: '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 : (jsx(ExpandMoreIcon, { style: {
|
|
1688
|
+
transform: `rotate(${!canExpand && !renderDetailPanel
|
|
1689
|
+
? positionExpandColumn === 'last' ||
|
|
1690
|
+
theme.direction === 'rtl'
|
|
1691
|
+
? 90
|
|
1692
|
+
: -90
|
|
1693
|
+
: isExpanded
|
|
1694
|
+
? -180
|
|
1695
|
+
: 0}deg)`,
|
|
1696
|
+
transition: 'transform 150ms',
|
|
1697
|
+
} })) })) }) })));
|
|
2070
1698
|
};
|
|
2071
1699
|
|
|
2072
|
-
const
|
|
2073
|
-
|
|
1700
|
+
const INSERT_HERE_TOOLTIP = 'Insert here';
|
|
1701
|
+
const ACTION_ICON_SIZE$1 = 'small';
|
|
1702
|
+
const MRT_InsertHereAction = ({ onClick, }) => {
|
|
1703
|
+
return (jsx(Tooltip, { title: INSERT_HERE_TOOLTIP, disableInteractive: true, children: jsx(IconButton, { onClick: onClick, size: ACTION_ICON_SIZE$1, children: jsx(SubdirectoryArrowLeftIcon, { color: "warning" }) }) }));
|
|
2074
1704
|
};
|
|
2075
1705
|
|
|
2076
|
-
const
|
|
2077
|
-
|
|
1706
|
+
const MOVE_TO_TOP_TOOLTIP = 'Move to top level';
|
|
1707
|
+
const ACTION_ICON_SIZE = 'small';
|
|
1708
|
+
const ACTION_BUTTON_HEIGHT = '1.75rem';
|
|
1709
|
+
const MRT_MoveToTopAction = ({ onClick }) => {
|
|
1710
|
+
return (jsx(Tooltip, { title: MOVE_TO_TOP_TOOLTIP, disableInteractive: true, children: jsx(IconButton, { onClick: onClick, size: ACTION_ICON_SIZE, sx: { height: ACTION_BUTTON_HEIGHT }, children: jsx(VerticalAlignTopIcon, { fontSize: "small" }) }) }));
|
|
2078
1711
|
};
|
|
2079
1712
|
|
|
2080
|
-
const
|
|
2081
|
-
return (
|
|
1713
|
+
const MRT_ReorderRowCheckbox = ({ onChange, isSelected, }) => {
|
|
1714
|
+
return (jsx(Checkbox, { checked: isSelected, color: "warning", disableRipple: true, onChange: onChange, sx: {
|
|
1715
|
+
color: (theme) => theme.palette.warning.main,
|
|
1716
|
+
'&.Mui-checked': {
|
|
1717
|
+
color: (theme) => theme.palette.warning.main,
|
|
1718
|
+
},
|
|
1719
|
+
} }));
|
|
2082
1720
|
};
|
|
2083
1721
|
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
const isPrintAvailable = (table) => {
|
|
1722
|
+
/**
|
|
1723
|
+
* Finds the maximum depth in the hierarchy of a given row (recursively searches all descendants).
|
|
1724
|
+
* Used to determine the "size" of the tree being moved.
|
|
1725
|
+
* Example: Row at depth 1 with a child at depth 3 → returns 3
|
|
1726
|
+
*/
|
|
1727
|
+
const getDeepestSubRowDepth = (row) => {
|
|
2091
1728
|
var _a;
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
if (!activeExports)
|
|
2097
|
-
return false;
|
|
2098
|
-
const { selectedFormat, selectedExports, grouped } = activeExports;
|
|
2099
|
-
return (selectedFormat === 'pdf' &&
|
|
2100
|
-
selectedExports.length >= 1 &&
|
|
2101
|
-
(grouped || selectedExports.length === 1));
|
|
1729
|
+
if (!((_a = row.subRows) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
1730
|
+
return row.depth;
|
|
1731
|
+
}
|
|
1732
|
+
return row.subRows.reduce((maxDepth, subRow) => Math.max(maxDepth, getDeepestSubRowDepth(subRow)), row.depth);
|
|
2102
1733
|
};
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
1734
|
+
/**
|
|
1735
|
+
* Extracts an array of IDs of only the selected rows from the selection object.
|
|
1736
|
+
* Filters the record where the value is true and maps only the keys (IDs).
|
|
1737
|
+
* Example: { row1: true, row2: false, row3: true } → ['row1', 'row3']
|
|
1738
|
+
*/
|
|
1739
|
+
const getSelectedReorderRowIds = (rowReorderingSelection) => {
|
|
1740
|
+
return Object.entries(rowReorderingSelection !== null && rowReorderingSelection !== void 0 ? rowReorderingSelection : {})
|
|
1741
|
+
.filter(([, isSelected]) => isSelected)
|
|
1742
|
+
.map(([rowId]) => rowId);
|
|
1743
|
+
};
|
|
1744
|
+
/**
|
|
1745
|
+
* Checks WHETHER we can move selected rows as children of target row
|
|
1746
|
+
* without exceeding the maximum allowed depth.
|
|
1747
|
+
* Directly calculates the final maximum depth after the move.
|
|
1748
|
+
* Example: selectedRows at depth 1-2 with descendants to depth 4, target depth 1, maxDepth 5
|
|
1749
|
+
* → new max depth = 1 + 1 + (4 - 1) = 5, which equals maxDepth, so returns false
|
|
1750
|
+
*/
|
|
1751
|
+
const canInsertSelectedRowsWithoutExceedingMaxDepth = ({ maxDepth, selectedRows, targetRowDepth, }) => {
|
|
1752
|
+
// Cannot insert if there are no selected rows to move
|
|
1753
|
+
if (selectedRows.length === 0) {
|
|
1754
|
+
return false;
|
|
1755
|
+
}
|
|
1756
|
+
// No depth restriction - can insert anywhere
|
|
1757
|
+
if (maxDepth === undefined) {
|
|
1758
|
+
return true;
|
|
1759
|
+
}
|
|
1760
|
+
// Find the deepest descendant among all selected rows
|
|
1761
|
+
const maxDeepestDescendantDepth = selectedRows.reduce((max, row) => {
|
|
1762
|
+
return Math.max(max, getDeepestSubRowDepth(row));
|
|
1763
|
+
}, 0);
|
|
1764
|
+
// Find the minimum depth of selected rows (to calculate relative depth)
|
|
1765
|
+
const minSelectedRowDepth = Math.min(...selectedRows.map((r) => r.depth));
|
|
1766
|
+
// Calculate the maximum depth after moving rows as children of target
|
|
1767
|
+
// newMaxDepth = target.depth + 1 (as children) + relative depth of selected rows
|
|
1768
|
+
const newMaxDepth = targetRowDepth + 1 + (maxDeepestDescendantDepth - minSelectedRowDepth);
|
|
1769
|
+
return newMaxDepth < maxDepth;
|
|
1770
|
+
};
|
|
1771
|
+
/**
|
|
1772
|
+
* Finds the depth of the FIRST selected row in the selection object.
|
|
1773
|
+
* Used to enforce constraint: can only select rows at the SAME depth.
|
|
1774
|
+
* Example: If I select a row at depth 2, I cannot select a row at depth 3
|
|
1775
|
+
*/
|
|
1776
|
+
const getFirstSelectedReorderRowDepth = ({ rowReorderingSelection, table, }) => {
|
|
1777
|
+
var _a, _b;
|
|
1778
|
+
const firstSelectedRowId = (_a = Object.entries(rowReorderingSelection !== null && rowReorderingSelection !== void 0 ? rowReorderingSelection : {}).find(([, isSelected]) => isSelected)) === null || _a === void 0 ? void 0 : _a[0];
|
|
1779
|
+
if (!firstSelectedRowId) {
|
|
1780
|
+
return undefined;
|
|
1781
|
+
}
|
|
1782
|
+
return (_b = table.getRow(firstSelectedRowId, true)) === null || _b === void 0 ? void 0 : _b.depth;
|
|
1783
|
+
};
|
|
1784
|
+
/**
|
|
1785
|
+
* Checks WHETHER we can select a specific row.
|
|
1786
|
+
* Rule: If a selection already exists, new row MUST be at the SAME depth as the first selected.
|
|
1787
|
+
* Without this, you could move rows from different levels which would break the hierarchy.
|
|
1788
|
+
*/
|
|
1789
|
+
const canSelectRowForReorder = ({ rowId, rowDepth, rowReorderingSelection, firstSelectedReorderRowDepth, }) => {
|
|
1790
|
+
const isCurrentRowSelected = !!(rowReorderingSelection === null || rowReorderingSelection === void 0 ? void 0 : rowReorderingSelection[rowId]);
|
|
1791
|
+
if (isCurrentRowSelected) {
|
|
1792
|
+
return true;
|
|
1793
|
+
}
|
|
1794
|
+
const hasAnySelection = Object.values(rowReorderingSelection !== null && rowReorderingSelection !== void 0 ? rowReorderingSelection : {}).some(Boolean);
|
|
1795
|
+
if (!hasAnySelection) {
|
|
1796
|
+
return true;
|
|
1797
|
+
}
|
|
1798
|
+
return rowDepth === firstSelectedReorderRowDepth;
|
|
1799
|
+
};
|
|
1800
|
+
/**
|
|
1801
|
+
* Creates an array of MRT_Row objects from an array of IDs.
|
|
1802
|
+
* Finds each row from the table and collects it in the result.
|
|
1803
|
+
* Used to prepare data for the onTreeRowReorder callback.
|
|
1804
|
+
*/
|
|
1805
|
+
const buildSelectedRowsArray = (selectedRowIds, table) => {
|
|
1806
|
+
return selectedRowIds.reduce((selectedRows, selectedRowId) => {
|
|
1807
|
+
const selectedRow = table.getRow(selectedRowId, true);
|
|
1808
|
+
if (selectedRow) {
|
|
1809
|
+
selectedRows.push(selectedRow);
|
|
2147
1810
|
}
|
|
2148
|
-
return
|
|
2149
|
-
};
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
1811
|
+
return selectedRows;
|
|
1812
|
+
}, []);
|
|
1813
|
+
};
|
|
1814
|
+
/**
|
|
1815
|
+
* Helper function to check if a row is a descendant of another row.
|
|
1816
|
+
* Recursively searches through all subRows to find if targetRowId exists.
|
|
1817
|
+
* Used to prevent circular references (parent cannot become child of its own child).
|
|
1818
|
+
*/
|
|
1819
|
+
const isRowInSubtreeOf = (targetRowId, parentRow) => {
|
|
1820
|
+
var _a;
|
|
1821
|
+
if (!((_a = parentRow.subRows) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
1822
|
+
return false;
|
|
1823
|
+
}
|
|
1824
|
+
for (const subRow of parentRow.subRows) {
|
|
1825
|
+
if (subRow.id === targetRowId) {
|
|
1826
|
+
return true;
|
|
2158
1827
|
}
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
persist: true,
|
|
2162
|
-
});
|
|
2163
|
-
try {
|
|
2164
|
-
yield executeExport({ table, rowsToExport: [row] });
|
|
2165
|
-
closeSnackbar(loadingKey);
|
|
2166
|
-
enqueueSnackbar(localization.exportSuccess, { variant: 'success' });
|
|
1828
|
+
if (isRowInSubtreeOf(targetRowId, subRow)) {
|
|
1829
|
+
return true;
|
|
2167
1830
|
}
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
1831
|
+
}
|
|
1832
|
+
return false;
|
|
1833
|
+
};
|
|
1834
|
+
/**
|
|
1835
|
+
* Checks if a row can be used as a valid insert target for selected rows.
|
|
1836
|
+
* Rules: Target row must NOT be already selected AND must NOT be a descendant of any selected row.
|
|
1837
|
+
* This prevents circular references where a parent becomes a child of its own descendants.
|
|
1838
|
+
* Example: If you select "Department", you cannot insert it under "Project" (which is its descendant)
|
|
1839
|
+
*/
|
|
1840
|
+
const isValidInsertTarget = ({ targetRowId, selectedRowIds, table, }) => {
|
|
1841
|
+
// Rule 1: Target row cannot be already selected
|
|
1842
|
+
if (selectedRowIds.includes(targetRowId) || selectedRowIds.length === 0) {
|
|
1843
|
+
return false;
|
|
1844
|
+
}
|
|
1845
|
+
// Rule 2: Target row cannot be a descendant of any selected row
|
|
1846
|
+
// (prevents parent from becoming child of its own descendants)
|
|
1847
|
+
for (const selectedRowId of selectedRowIds) {
|
|
1848
|
+
const selectedRow = table.getRow(selectedRowId, true);
|
|
1849
|
+
if (selectedRow &&
|
|
1850
|
+
isRowInSubtreeOf(targetRowId, selectedRow)) {
|
|
1851
|
+
return false;
|
|
2171
1852
|
}
|
|
1853
|
+
}
|
|
1854
|
+
return true;
|
|
1855
|
+
};
|
|
1856
|
+
|
|
1857
|
+
const useTreeRowReorderingCell = ({ row, table, rowReorderingSelection, maxDepth, onTreeRowReorder, }) => {
|
|
1858
|
+
const [isRowHovered, setIsRowHovered] = useState(false);
|
|
1859
|
+
const firstSelectedReorderRowDepth = getFirstSelectedReorderRowDepth({
|
|
1860
|
+
rowReorderingSelection,
|
|
1861
|
+
table,
|
|
2172
1862
|
});
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
1863
|
+
const canSelectForReorder = canSelectRowForReorder({
|
|
1864
|
+
rowId: row.id,
|
|
1865
|
+
rowDepth: row.depth,
|
|
1866
|
+
rowReorderingSelection,
|
|
1867
|
+
firstSelectedReorderRowDepth,
|
|
1868
|
+
});
|
|
1869
|
+
const hasAnyReorderSelection = Object.values(rowReorderingSelection !== null && rowReorderingSelection !== void 0 ? rowReorderingSelection : {}).some(Boolean);
|
|
1870
|
+
const selectedReorderRowIds = getSelectedReorderRowIds(rowReorderingSelection);
|
|
1871
|
+
const selectedRowsForReorder = buildSelectedRowsArray(selectedReorderRowIds, table);
|
|
1872
|
+
const shouldShowReorderCheckbox = canSelectForReorder && (isRowHovered || hasAnyReorderSelection);
|
|
1873
|
+
const shouldShowInsertHereAction = selectedReorderRowIds.length > 0 &&
|
|
1874
|
+
isValidInsertTarget({
|
|
1875
|
+
targetRowId: row.id,
|
|
1876
|
+
selectedRowIds: selectedReorderRowIds,
|
|
1877
|
+
table,
|
|
1878
|
+
}) &&
|
|
1879
|
+
canInsertSelectedRowsWithoutExceedingMaxDepth({
|
|
1880
|
+
maxDepth,
|
|
1881
|
+
selectedRows: selectedRowsForReorder,
|
|
1882
|
+
targetRowDepth: row.depth,
|
|
1883
|
+
});
|
|
1884
|
+
const handleReorderCheckboxChange = useCallback((event) => {
|
|
1885
|
+
const checked = event.target.checked;
|
|
1886
|
+
table.setRowReorderingSelection((prev) => (Object.assign(Object.assign({}, prev), { [row.id]: checked })));
|
|
1887
|
+
}, [row.id, table]);
|
|
1888
|
+
const handleInsertHereActionClick = useCallback(() => {
|
|
1889
|
+
if (!onTreeRowReorder) {
|
|
1890
|
+
console.warn('[MRT] onTreeRowReorder callback is not defined');
|
|
2180
1891
|
return;
|
|
2181
1892
|
}
|
|
2182
|
-
const loadingKey = enqueueSnackbar(localization.exportInProgress, {
|
|
2183
|
-
variant: 'info',
|
|
2184
|
-
persist: true,
|
|
2185
|
-
});
|
|
2186
1893
|
try {
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
1894
|
+
const treeRowReorderEvent = {
|
|
1895
|
+
selectedRowIds: selectedReorderRowIds,
|
|
1896
|
+
selectedRows: selectedRowsForReorder,
|
|
1897
|
+
table,
|
|
1898
|
+
targetRow: row,
|
|
1899
|
+
};
|
|
1900
|
+
onTreeRowReorder(treeRowReorderEvent);
|
|
2190
1901
|
}
|
|
2191
|
-
catch (
|
|
2192
|
-
|
|
2193
|
-
enqueueSnackbar(localization.exportError, { variant: 'error' });
|
|
1902
|
+
catch (error) {
|
|
1903
|
+
console.error('[MRT] Error during tree row reorder:', error);
|
|
2194
1904
|
}
|
|
2195
|
-
}
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2205
|
-
|
|
1905
|
+
}, [
|
|
1906
|
+
onTreeRowReorder,
|
|
1907
|
+
selectedReorderRowIds,
|
|
1908
|
+
selectedRowsForReorder,
|
|
1909
|
+
table,
|
|
1910
|
+
row,
|
|
1911
|
+
]);
|
|
1912
|
+
return {
|
|
1913
|
+
isRowHovered,
|
|
1914
|
+
shouldShowReorderCheckbox,
|
|
1915
|
+
shouldShowInsertHereAction,
|
|
1916
|
+
handleRowHoverEnter: () => setIsRowHovered(true),
|
|
1917
|
+
handleRowHoverLeave: () => setIsRowHovered(false),
|
|
1918
|
+
handleReorderCheckboxChange,
|
|
1919
|
+
handleInsertHereActionClick,
|
|
1920
|
+
isReorderCheckboxSelected: !!(rowReorderingSelection === null || rowReorderingSelection === void 0 ? void 0 : rowReorderingSelection[row.id]),
|
|
2206
1921
|
};
|
|
2207
|
-
|
|
2208
|
-
|
|
1922
|
+
};
|
|
1923
|
+
|
|
1924
|
+
const useTreeRowReorderingHeader = ({ table, enableRowReordering, onTreeRowReorder, }) => {
|
|
1925
|
+
const rowReorderingSelection = useMRT_SliceValue(table._uiStore, (s) => s.rowReorderingSelection);
|
|
1926
|
+
const selectedReorderRowIds = getSelectedReorderRowIds(rowReorderingSelection);
|
|
1927
|
+
const selectedRowsForReorder = buildSelectedRowsArray(selectedReorderRowIds, table);
|
|
1928
|
+
const shouldShowMoveToTopLevelAction = !!enableRowReordering &&
|
|
1929
|
+
selectedRowsForReorder.length > 0 &&
|
|
1930
|
+
selectedRowsForReorder.some((selectedRow) => selectedRow.depth > 0);
|
|
1931
|
+
const handleMoveToTopLevelActionClick = useCallback(() => {
|
|
1932
|
+
if (!onTreeRowReorder) {
|
|
1933
|
+
console.warn('[MRT] onTreeRowReorder callback is not defined');
|
|
1934
|
+
return;
|
|
1935
|
+
}
|
|
1936
|
+
try {
|
|
1937
|
+
const treeRowReorderEvent = {
|
|
1938
|
+
selectedRowIds: selectedReorderRowIds,
|
|
1939
|
+
selectedRows: selectedRowsForReorder,
|
|
1940
|
+
table,
|
|
1941
|
+
targetRow: null,
|
|
1942
|
+
};
|
|
1943
|
+
onTreeRowReorder(treeRowReorderEvent);
|
|
1944
|
+
}
|
|
1945
|
+
catch (error) {
|
|
1946
|
+
console.error('[MRT] Error during tree row reorder to top level:', error);
|
|
1947
|
+
}
|
|
1948
|
+
}, [onTreeRowReorder, selectedReorderRowIds, selectedRowsForReorder, table]);
|
|
1949
|
+
return {
|
|
1950
|
+
shouldShowMoveToTopLevelAction,
|
|
1951
|
+
handleMoveToTopLevelActionClick,
|
|
2209
1952
|
};
|
|
2210
|
-
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
1953
|
+
};
|
|
1954
|
+
|
|
1955
|
+
const TREE_REORDER_ICON_SPACING = '0.25rem';
|
|
1956
|
+
const getMRT_RowExpandColumnDef = (tableOptions) => {
|
|
1957
|
+
var _a;
|
|
1958
|
+
const { defaultColumn, enableRowReordering, enableExpandAll, groupedColumnMode, maxDepth, onTreeRowReorder, positionExpandColumn, renderDetailPanel, state: { grouping }, } = tableOptions;
|
|
1959
|
+
const alignProps = positionExpandColumn === 'last'
|
|
1960
|
+
? {
|
|
1961
|
+
align: 'right',
|
|
2219
1962
|
}
|
|
2220
|
-
|
|
1963
|
+
: undefined;
|
|
1964
|
+
return Object.assign(Object.assign({ Cell: ({ cell, column, row, staticRowIndex, table }) => {
|
|
1965
|
+
var _a, _b, _c;
|
|
1966
|
+
const rowReorderingSelection = useMRT_SliceValue(table._uiStore, (s) => s.rowReorderingSelection);
|
|
1967
|
+
const cellLogic = useTreeRowReorderingCell({
|
|
1968
|
+
row,
|
|
1969
|
+
table,
|
|
1970
|
+
rowReorderingSelection,
|
|
1971
|
+
maxDepth,
|
|
1972
|
+
onTreeRowReorder,
|
|
1973
|
+
});
|
|
1974
|
+
const expandButtonProps = { row, staticRowIndex, table };
|
|
1975
|
+
const subRowsLength = (_a = row.subRows) === null || _a === void 0 ? void 0 : _a.length;
|
|
1976
|
+
const customGroupedCell = (_c = (_b = column.columnDef).GroupedCell) === null || _c === void 0 ? void 0 : _c.call(_b, {
|
|
1977
|
+
cell,
|
|
1978
|
+
column,
|
|
1979
|
+
row,
|
|
1980
|
+
table,
|
|
1981
|
+
staticRowIndex,
|
|
1982
|
+
});
|
|
1983
|
+
if (groupedColumnMode === 'remove' && row.groupingColumnId) {
|
|
1984
|
+
const defaultGroupedCell = (jsx(Tooltip, Object.assign({}, getCommonTooltipProps('right'), { title: table.getColumn(row.groupingColumnId).columnDef.header, children: jsx("span", { children: row.groupingValue }) })));
|
|
1985
|
+
return (jsxs(Stack, { alignItems: "center", flexDirection: "row", gap: TREE_REORDER_ICON_SPACING, onMouseEnter: cellLogic.handleRowHoverEnter, onMouseLeave: cellLogic.handleRowHoverLeave, width: "100%", children: [jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), column.columnDef.GroupedCell
|
|
1986
|
+
? customGroupedCell
|
|
1987
|
+
: defaultGroupedCell, cellLogic.shouldShowReorderCheckbox && (jsx(MRT_ReorderRowCheckbox, { isSelected: cellLogic.isReorderCheckboxSelected, onChange: cellLogic.handleReorderCheckboxChange })), cellLogic.shouldShowInsertHereAction && (jsx(MRT_InsertHereAction, { onClick: cellLogic.handleInsertHereActionClick })), !!subRowsLength && jsxs("span", { children: ["(", subRowsLength, ")"] })] }));
|
|
1988
|
+
}
|
|
1989
|
+
return (jsxs(Stack, { alignItems: "center", flexDirection: "row", gap: TREE_REORDER_ICON_SPACING, onMouseEnter: cellLogic.handleRowHoverEnter, onMouseLeave: cellLogic.handleRowHoverLeave, width: "100%", children: [jsx(MRT_ExpandButton, Object.assign({}, expandButtonProps)), customGroupedCell, cellLogic.shouldShowReorderCheckbox && (jsx(MRT_ReorderRowCheckbox, { isSelected: cellLogic.isReorderCheckboxSelected, onChange: cellLogic.handleReorderCheckboxChange })), cellLogic.shouldShowInsertHereAction && (jsx(MRT_InsertHereAction, { onClick: cellLogic.handleInsertHereActionClick }))] }));
|
|
1990
|
+
}, Header: enableExpandAll
|
|
1991
|
+
? ({ table }) => {
|
|
1992
|
+
var _a;
|
|
1993
|
+
const headerLogic = useTreeRowReorderingHeader({
|
|
1994
|
+
table,
|
|
1995
|
+
enableRowReordering,
|
|
1996
|
+
onTreeRowReorder,
|
|
1997
|
+
});
|
|
1998
|
+
return (jsxs(Stack, { alignItems: "center", flexDirection: "row", gap: TREE_REORDER_ICON_SPACING, children: [jsx(MRT_ExpandAllButton, { table: table }), headerLogic.shouldShowMoveToTopLevelAction && (jsx(MRT_MoveToTopAction, { onClick: headerLogic.handleMoveToTopLevelActionClick })), groupedColumnMode === 'remove' &&
|
|
1999
|
+
((_a = grouping === null || grouping === void 0 ? void 0 : grouping.map((groupedColumnId) => table.getColumn(groupedColumnId).columnDef.header)) === null || _a === void 0 ? void 0 : _a.join(', '))] }));
|
|
2000
|
+
}
|
|
2001
|
+
: undefined, muiTableBodyCellProps: alignProps, muiTableHeadCellProps: alignProps }, defaultDisplayColumnProps({
|
|
2002
|
+
header: 'expand',
|
|
2003
|
+
id: 'mrt-row-expand',
|
|
2004
|
+
size: groupedColumnMode === 'remove'
|
|
2005
|
+
? ((_a = defaultColumn === null || defaultColumn === void 0 ? void 0 : defaultColumn.size) !== null && _a !== void 0 ? _a : 180)
|
|
2006
|
+
: renderDetailPanel
|
|
2007
|
+
? enableExpandAll
|
|
2008
|
+
? 60
|
|
2009
|
+
: 70
|
|
2010
|
+
: 100,
|
|
2011
|
+
tableOptions,
|
|
2012
|
+
})), { enableResizing: true });
|
|
2013
|
+
};
|
|
2014
|
+
|
|
2015
|
+
const getMRT_RowNumbersColumnDef = (tableOptions) => {
|
|
2016
|
+
const { localization, rowNumberDisplayMode } = tableOptions;
|
|
2017
|
+
const { pagination: { pageIndex, pageSize }, } = tableOptions.state;
|
|
2018
|
+
return Object.assign({ Cell: ({ row, staticRowIndex }) => {
|
|
2019
|
+
var _a;
|
|
2020
|
+
return ((_a = (rowNumberDisplayMode === 'static'
|
|
2021
|
+
? (staticRowIndex || 0) + (pageSize || 0) * (pageIndex || 0)
|
|
2022
|
+
: row.index)) !== null && _a !== void 0 ? _a : 0) + 1;
|
|
2023
|
+
}, Header: () => localization.rowNumber, grow: false }, defaultDisplayColumnProps({
|
|
2024
|
+
header: 'rowNumbers',
|
|
2025
|
+
id: 'mrt-row-numbers',
|
|
2026
|
+
size: 50,
|
|
2027
|
+
tableOptions,
|
|
2028
|
+
}));
|
|
2029
|
+
};
|
|
2030
|
+
|
|
2031
|
+
const MRT_RowPinButton = (_a) => {
|
|
2032
|
+
var { pinningPosition, row, table } = _a, rest = __rest(_a, ["pinningPosition", "row", "table"]);
|
|
2033
|
+
const { options: { icons: { CloseIcon, PushPinIcon }, localization, rowPinningDisplayMode, }, } = table;
|
|
2034
|
+
const isPinned = row.getIsPinned();
|
|
2035
|
+
const [tooltipOpened, setTooltipOpened] = useState(false);
|
|
2036
|
+
const handleTogglePin = (event) => {
|
|
2037
|
+
setTooltipOpened(false);
|
|
2038
|
+
event.stopPropagation();
|
|
2039
|
+
row.pin(isPinned ? false : pinningPosition);
|
|
2221
2040
|
};
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2041
|
+
return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { open: tooltipOpened, title: isPinned ? localization.unpin : localization.pin, children: 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 ? (jsx(CloseIcon, {})) : (jsx(PushPinIcon, { fontSize: "small", style: {
|
|
2042
|
+
transform: `rotate(${rowPinningDisplayMode === 'sticky'
|
|
2043
|
+
? 135
|
|
2044
|
+
: pinningPosition === 'top'
|
|
2045
|
+
? 180
|
|
2046
|
+
: 0}deg)`,
|
|
2047
|
+
} })) })) })));
|
|
2048
|
+
};
|
|
2049
|
+
|
|
2050
|
+
const MRT_TableBodyRowPinButton = (_a) => {
|
|
2051
|
+
var { row, table } = _a, rest = __rest(_a, ["row", "table"]);
|
|
2052
|
+
const { options: { enableRowPinning, rowPinningDisplayMode }, } = table;
|
|
2053
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
2054
|
+
const canPin = parseFromValuesOrFunc(enableRowPinning, row);
|
|
2055
|
+
if (!canPin)
|
|
2056
|
+
return null;
|
|
2057
|
+
const rowPinButtonProps = Object.assign({ row,
|
|
2058
|
+
table }, rest);
|
|
2059
|
+
if (rowPinningDisplayMode === 'top-and-bottom' && !row.getIsPinned()) {
|
|
2060
|
+
return (jsxs(Box, { sx: {
|
|
2061
|
+
display: 'flex',
|
|
2062
|
+
flexDirection: density === 'compact' ? 'row' : 'column',
|
|
2063
|
+
}, children: [jsx(MRT_RowPinButton, Object.assign({ pinningPosition: "top" }, rowPinButtonProps)), jsx(MRT_RowPinButton, Object.assign({ pinningPosition: "bottom" }, rowPinButtonProps))] }));
|
|
2064
|
+
}
|
|
2065
|
+
return (jsx(MRT_RowPinButton, Object.assign({ pinningPosition: rowPinningDisplayMode === 'bottom' ? 'bottom' : 'top' }, rowPinButtonProps)));
|
|
2066
|
+
};
|
|
2067
|
+
|
|
2068
|
+
const getMRT_RowPinningColumnDef = (tableOptions) => {
|
|
2069
|
+
return Object.assign({ Cell: ({ row, table }) => (jsx(MRT_TableBodyRowPinButton, { row: row, table: table })), grow: false }, defaultDisplayColumnProps({
|
|
2070
|
+
header: 'pin',
|
|
2071
|
+
id: 'mrt-row-pin',
|
|
2072
|
+
size: 60,
|
|
2073
|
+
tableOptions,
|
|
2074
|
+
}));
|
|
2075
|
+
};
|
|
2076
|
+
|
|
2077
|
+
const MRT_SelectAllMenu = ({ table, }) => {
|
|
2078
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
2079
|
+
const [isSelectingAllPages, setIsSelectingAllPages] = useState(false);
|
|
2080
|
+
const { getState, options: { enableRowPinning, getAllSelectableRowIds, localization, rowPinningDisplayMode, }, refs: { allSelectableRowIdsRef }, } = table;
|
|
2081
|
+
// rowSelection is read here so that any change to selection will trigger a re-render and update the menu options accordingly
|
|
2082
|
+
const { isLoading, rowSelection } = getState();
|
|
2083
|
+
const isAllCurrentPageSelected = table.getIsAllPageRowsSelected();
|
|
2084
|
+
const isAllPagesActive = getIsAllPagesSelectionActive(table, rowSelection);
|
|
2085
|
+
const handleOpen = (event) => {
|
|
2086
|
+
setAnchorEl(event.currentTarget);
|
|
2087
|
+
};
|
|
2088
|
+
const handleClose = () => {
|
|
2089
|
+
setAnchorEl(null);
|
|
2090
|
+
};
|
|
2091
|
+
// Clears row pinning on every bulk selection/deselection
|
|
2092
|
+
const clearPinning = () => {
|
|
2093
|
+
if (enableRowPinning && (rowPinningDisplayMode === null || rowPinningDisplayMode === void 0 ? void 0 : rowPinningDisplayMode.includes('select'))) {
|
|
2094
|
+
table.setRowPinning({ bottom: [], top: [] });
|
|
2233
2095
|
}
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2096
|
+
};
|
|
2097
|
+
// ── Current-page actions ────────────────────────────────────────────────────
|
|
2098
|
+
const handleSelectCurrentPage = () => {
|
|
2099
|
+
table.toggleAllPageRowsSelected(true);
|
|
2100
|
+
clearPinning();
|
|
2101
|
+
handleClose();
|
|
2102
|
+
};
|
|
2103
|
+
const handleDeselectCurrentPage = () => {
|
|
2104
|
+
if (allSelectableRowIdsRef.current.length > 0) {
|
|
2105
|
+
// 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.
|
|
2106
|
+
table.setRowSelection({});
|
|
2107
|
+
allSelectableRowIdsRef.current = [];
|
|
2239
2108
|
}
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2109
|
+
else {
|
|
2110
|
+
table.toggleAllPageRowsSelected(false);
|
|
2111
|
+
}
|
|
2112
|
+
clearPinning();
|
|
2113
|
+
handleClose();
|
|
2114
|
+
};
|
|
2115
|
+
// ── All-pages actions ───────────────────────────────────────────────────────
|
|
2116
|
+
const handleSelectAllPages = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2117
|
+
handleClose();
|
|
2118
|
+
if (getAllSelectableRowIds) {
|
|
2119
|
+
// Server-side: IDs are not available locally, fetch them from the API
|
|
2120
|
+
setIsSelectingAllPages(true);
|
|
2121
|
+
table.setShowProgressBars(true);
|
|
2245
2122
|
try {
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
}
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
}
|
|
2255
|
-
closeSnackbar(loadingKey);
|
|
2256
|
-
enqueueSnackbar(localization.exportSuccess, { variant: 'success' });
|
|
2257
|
-
return response;
|
|
2123
|
+
const ids = yield getAllSelectableRowIds({ table });
|
|
2124
|
+
allSelectableRowIdsRef.current = ids;
|
|
2125
|
+
const newSelection = {};
|
|
2126
|
+
ids.forEach((id) => {
|
|
2127
|
+
newSelection[id] = true;
|
|
2128
|
+
});
|
|
2129
|
+
table.setRowSelection(newSelection);
|
|
2130
|
+
clearPinning();
|
|
2258
2131
|
}
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
return [];
|
|
2132
|
+
finally {
|
|
2133
|
+
setIsSelectingAllPages(false);
|
|
2134
|
+
table.setShowProgressBars(false);
|
|
2263
2135
|
}
|
|
2264
|
-
}
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2136
|
+
}
|
|
2137
|
+
else {
|
|
2138
|
+
// Client-side: all data is available locally
|
|
2139
|
+
table.toggleAllRowsSelected(true);
|
|
2140
|
+
clearPinning();
|
|
2141
|
+
}
|
|
2142
|
+
});
|
|
2143
|
+
const handleDeselectAllPages = () => {
|
|
2144
|
+
if (getAllSelectableRowIds) {
|
|
2145
|
+
table.setRowSelection({});
|
|
2146
|
+
}
|
|
2147
|
+
else {
|
|
2148
|
+
table.toggleAllRowsSelected(false);
|
|
2149
|
+
}
|
|
2150
|
+
allSelectableRowIdsRef.current = [];
|
|
2151
|
+
clearPinning();
|
|
2152
|
+
handleClose();
|
|
2153
|
+
};
|
|
2154
|
+
const isDisabled = isLoading || isSelectingAllPages;
|
|
2155
|
+
return (jsxs(Fragment, { children: [jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: localization.toggleSelectAll, children: jsx("span", { children: jsx(IconButton, { "aria-label": localization.toggleSelectAll, disabled: isDisabled, onClick: handleOpen, size: "small", sx: { height: '1.5rem', width: '1.5rem' }, children: jsx(table.options.icons.MoreVertIcon, { style: { transform: 'scale(0.85)' } }) }) }) })), jsxs(Menu, { anchorEl: anchorEl, onClose: handleClose, open: Boolean(anchorEl), children: [isAllCurrentPageSelected ? (jsx(MenuItem, { onClick: handleDeselectCurrentPage, children: localization.deselectAllOnCurrentPage })) : (jsx(MenuItem, { onClick: handleSelectCurrentPage, children: localization.selectAllOnCurrentPage })), isAllPagesActive ? (jsx(MenuItem, { onClick: handleDeselectAllPages, children: localization.deselectAllOnAllPages })) : (jsxs(MenuItem, { disabled: isSelectingAllPages, onClick: handleSelectAllPages, children: [isSelectingAllPages && (jsx(CircularProgress, { "aria-label": "Loading", size: 14, sx: { mr: 1 } })), localization.selectAllOnAllPages] }))] })] }));
|
|
2156
|
+
};
|
|
2157
|
+
|
|
2158
|
+
const MRT_SelectCheckbox = (_a) => {
|
|
2159
|
+
var _b;
|
|
2160
|
+
var { row, staticRowIndex, table } = _a, rest = __rest(_a, ["row", "staticRowIndex", "table"]);
|
|
2161
|
+
const { getState, options: { enableMultiRowSelection, localization, muiSelectAllCheckboxProps, muiSelectCheckboxProps, selectAllMode, }, } = table;
|
|
2162
|
+
const { isLoading } = getState();
|
|
2163
|
+
const density = useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
2164
|
+
const selectAll = !row;
|
|
2165
|
+
const allRowsSelected = selectAll
|
|
2166
|
+
? selectAllMode === 'page'
|
|
2167
|
+
? table.getIsAllPageRowsSelected()
|
|
2168
|
+
: table.getIsAllRowsSelected()
|
|
2169
|
+
: undefined;
|
|
2170
|
+
const isChecked = selectAll
|
|
2171
|
+
? allRowsSelected
|
|
2172
|
+
: getIsRowSelected({ row, table });
|
|
2173
|
+
const checkboxProps = Object.assign(Object.assign({}, (selectAll
|
|
2174
|
+
? parseFromValuesOrFunc(muiSelectAllCheckboxProps, { table })
|
|
2175
|
+
: parseFromValuesOrFunc(muiSelectCheckboxProps, {
|
|
2176
|
+
row,
|
|
2177
|
+
staticRowIndex,
|
|
2178
|
+
table,
|
|
2179
|
+
}))), rest);
|
|
2180
|
+
const onSelectionChange = row
|
|
2181
|
+
? getMRT_RowSelectionHandler({
|
|
2182
|
+
row,
|
|
2183
|
+
staticRowIndex,
|
|
2184
|
+
table,
|
|
2185
|
+
})
|
|
2186
|
+
: undefined;
|
|
2187
|
+
const onSelectAllChange = getMRT_SelectAllHandler({ table });
|
|
2188
|
+
const commonProps = Object.assign(Object.assign({ 'aria-label': selectAll
|
|
2189
|
+
? localization.toggleSelectAll
|
|
2190
|
+
: localization.toggleSelectRow, checked: isChecked, disabled: isLoading || (row && !row.getCanSelect()) || (row === null || row === void 0 ? void 0 : row.id) === 'mrt-row-create', inputProps: {
|
|
2191
|
+
'aria-label': selectAll
|
|
2192
|
+
? localization.toggleSelectAll
|
|
2193
|
+
: localization.toggleSelectRow,
|
|
2194
|
+
}, onChange: (event) => {
|
|
2195
|
+
event.stopPropagation();
|
|
2196
|
+
selectAll ? onSelectAllChange(event) : onSelectionChange(event);
|
|
2197
|
+
}, size: (density === 'compact' ? 'small' : 'medium') }, checkboxProps), { onClick: (e) => {
|
|
2198
|
+
var _a;
|
|
2199
|
+
e.stopPropagation();
|
|
2200
|
+
(_a = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.onClick) === null || _a === void 0 ? void 0 : _a.call(checkboxProps, e);
|
|
2201
|
+
}, 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 });
|
|
2202
|
+
return (jsx(Tooltip, Object.assign({}, getCommonTooltipProps(), { title: (_b = checkboxProps === null || checkboxProps === void 0 ? void 0 : checkboxProps.title) !== null && _b !== void 0 ? _b : (selectAll
|
|
2203
|
+
? localization.toggleSelectAll
|
|
2204
|
+
: localization.toggleSelectRow), children: enableMultiRowSelection === false ? (jsx(Radio, Object.assign({}, commonProps))) : (jsx(Checkbox, Object.assign({ disableRipple: true, indeterminate: !isChecked && selectAll
|
|
2205
|
+
? table.getIsSomeRowsSelected()
|
|
2206
|
+
: (row === null || row === void 0 ? void 0 : row.getIsSomeSelected()) && row.getCanSelectSubRows() }, commonProps))) })));
|
|
2207
|
+
};
|
|
2208
|
+
|
|
2209
|
+
const getMRT_RowSelectColumnDef = (tableOptions) => {
|
|
2210
|
+
const { enableMultiRowSelection, enableSelectAll } = tableOptions;
|
|
2211
|
+
return Object.assign({ Cell: ({ row, staticRowIndex, table }) => (jsx(MRT_SelectCheckbox, { row: row, staticRowIndex: staticRowIndex, table: table })), Header: enableSelectAll && enableMultiRowSelection
|
|
2212
|
+
? ({ table }) => (jsxs(Box, { sx: { alignItems: 'center', display: 'flex' }, children: [jsx(MRT_SelectCheckbox, { table: table }), jsx(MRT_SelectAllMenu, { table: table })] }))
|
|
2213
|
+
: undefined, grow: false }, defaultDisplayColumnProps({
|
|
2214
|
+
header: 'select',
|
|
2215
|
+
id: '__check__',
|
|
2216
|
+
size: enableSelectAll ? 90 : 70, // widened from 60 to accommodate both the checkbox and the menu button
|
|
2217
|
+
tableOptions,
|
|
2218
|
+
}));
|
|
2219
|
+
};
|
|
2220
|
+
|
|
2221
|
+
const MRT_Default_Icons = {
|
|
2222
|
+
AddIcon,
|
|
2223
|
+
ArrowDownwardIcon,
|
|
2224
|
+
ArrowRightIcon,
|
|
2225
|
+
CancelIcon,
|
|
2226
|
+
ChevronLeftIcon,
|
|
2227
|
+
ChevronRightIcon,
|
|
2228
|
+
ClearAllIcon,
|
|
2229
|
+
CloseIcon,
|
|
2230
|
+
ContentCopy,
|
|
2231
|
+
DensityLargeIcon,
|
|
2232
|
+
DensityMediumIcon,
|
|
2233
|
+
DensitySmallIcon,
|
|
2234
|
+
DragHandleIcon,
|
|
2235
|
+
DynamicFeedIcon,
|
|
2236
|
+
EditIcon,
|
|
2237
|
+
ExpandMoreIcon,
|
|
2238
|
+
FilterAltIcon,
|
|
2239
|
+
FilterListIcon,
|
|
2240
|
+
FilterListOffIcon,
|
|
2241
|
+
FirstPageIcon,
|
|
2242
|
+
FullscreenExitIcon,
|
|
2243
|
+
FullscreenIcon,
|
|
2244
|
+
KeyboardDoubleArrowDownIcon,
|
|
2245
|
+
LastPageIcon,
|
|
2246
|
+
MoreHorizIcon,
|
|
2247
|
+
MoreVertIcon,
|
|
2248
|
+
PushPinIcon,
|
|
2249
|
+
RestartAltIcon,
|
|
2250
|
+
SaveIcon,
|
|
2251
|
+
SearchIcon,
|
|
2252
|
+
SearchOffIcon,
|
|
2253
|
+
SortIcon,
|
|
2254
|
+
SyncAltIcon,
|
|
2255
|
+
ViewColumnIcon,
|
|
2256
|
+
VisibilityOffIcon,
|
|
2257
|
+
};
|
|
2258
|
+
|
|
2259
|
+
const MRT_Localization_EN = {
|
|
2260
|
+
language: 'en',
|
|
2261
|
+
actions: 'Actions',
|
|
2262
|
+
and: 'and',
|
|
2263
|
+
booleanFalse: 'False',
|
|
2264
|
+
booleanTrue: 'True',
|
|
2265
|
+
cancel: 'Cancel',
|
|
2266
|
+
close: 'Close',
|
|
2267
|
+
changeFilterMode: 'Change filter mode',
|
|
2268
|
+
changeSearchMode: 'Change search mode',
|
|
2269
|
+
clearFilter: 'Clear filter',
|
|
2270
|
+
clearSearch: 'Clear search',
|
|
2271
|
+
clearSelection: 'Clear selection',
|
|
2272
|
+
clearSort: 'Clear sort',
|
|
2273
|
+
deselectAllOnAllPages: 'Deselect all on all pages',
|
|
2274
|
+
deselectAllOnCurrentPage: 'Deselect all on current page',
|
|
2275
|
+
clickToCopy: 'Click to copy',
|
|
2276
|
+
copy: 'Copy',
|
|
2277
|
+
collapse: 'Collapse',
|
|
2278
|
+
collapseAll: 'Collapse all',
|
|
2279
|
+
columnActions: 'Column Actions',
|
|
2280
|
+
columns: 'Columns',
|
|
2281
|
+
copiedToClipboard: 'Copied to clipboard',
|
|
2282
|
+
dropToGroupBy: 'Drop to group by {column}',
|
|
2283
|
+
edit: 'Edit',
|
|
2284
|
+
expand: 'Expand',
|
|
2285
|
+
expandAll: 'Expand all',
|
|
2286
|
+
filterArrIncludes: 'Includes',
|
|
2287
|
+
filterArrIncludesAll: 'Includes all',
|
|
2288
|
+
filterArrIncludesSome: 'Includes',
|
|
2289
|
+
filterBetween: 'Between',
|
|
2290
|
+
filterBetweenInclusive: 'Between Inclusive',
|
|
2291
|
+
filterByColumn: 'Filter by {column}',
|
|
2292
|
+
filterFrom: 'From',
|
|
2293
|
+
filterTo: 'To',
|
|
2294
|
+
filterContains: 'Contains',
|
|
2295
|
+
filterEmpty: 'Empty',
|
|
2296
|
+
filterEndsWith: 'Ends With',
|
|
2297
|
+
filterEquals: 'Equals',
|
|
2298
|
+
filterEqualsString: 'Equals',
|
|
2299
|
+
filterFuzzy: 'Fuzzy',
|
|
2300
|
+
filterGreaterThan: 'Greater Than',
|
|
2301
|
+
filterGreaterThanOrEqualTo: 'Greater Than Or Equal To',
|
|
2302
|
+
filterInArray: 'Is any of',
|
|
2303
|
+
filterIsAnyOf: 'Is any of',
|
|
2304
|
+
filterInNumberRange: 'Between',
|
|
2305
|
+
filterIncludesString: 'Contains',
|
|
2306
|
+
filterIncludesStringSensitive: 'Contains',
|
|
2307
|
+
filterLessThan: 'Less Than',
|
|
2308
|
+
filterLessThanOrEqualTo: 'Less Than Or Equal To',
|
|
2309
|
+
filterMode: 'Filter Mode: {filterType}',
|
|
2310
|
+
filterNoOptions: 'No filter options available',
|
|
2311
|
+
filterNotEmpty: 'Not Empty',
|
|
2312
|
+
filterNotEquals: 'Not Equals',
|
|
2313
|
+
filterNotContains: 'Does Not Contain',
|
|
2314
|
+
filterLogic: 'Logic',
|
|
2315
|
+
filterOperator: 'Operator',
|
|
2316
|
+
filterStartsWith: 'Starts With',
|
|
2317
|
+
filterWeakEquals: 'Equals',
|
|
2318
|
+
filterCurrentWeek: 'Current Week',
|
|
2319
|
+
filterCurrentMonth: 'Current Month',
|
|
2320
|
+
filterLast7Days: 'Last 7 Days',
|
|
2321
|
+
filterLastWeek: 'Last Week',
|
|
2322
|
+
filterLastMonth: 'Last Month',
|
|
2323
|
+
filterFromToday: 'From Today',
|
|
2324
|
+
filterToToday: 'To Today',
|
|
2325
|
+
filteringByColumn: 'Filtering by {column} - {filterType} {filterValue}',
|
|
2326
|
+
goToFirstPage: 'Go to first page',
|
|
2327
|
+
goToLastPage: 'Go to last page',
|
|
2328
|
+
goToNextPage: 'Go to next page',
|
|
2329
|
+
goToPreviousPage: 'Go to previous page',
|
|
2330
|
+
grab: 'Grab',
|
|
2331
|
+
groupByColumn: 'Group by {column}',
|
|
2332
|
+
groupedBy: 'Grouped by ',
|
|
2333
|
+
hideAll: 'Hide all',
|
|
2334
|
+
hideColumn: 'Hide {column} column',
|
|
2335
|
+
max: 'Max',
|
|
2336
|
+
min: 'Min',
|
|
2337
|
+
move: 'Move',
|
|
2338
|
+
noRecordsToDisplay: 'No records to display',
|
|
2339
|
+
noResultsFound: 'No results found',
|
|
2340
|
+
moreThan: 'more than',
|
|
2341
|
+
of: 'of',
|
|
2342
|
+
or: 'or',
|
|
2343
|
+
pin: 'Pin',
|
|
2344
|
+
pinToLeft: 'Pin to left',
|
|
2345
|
+
pinToRight: 'Pin to right',
|
|
2346
|
+
resetColumnSize: 'Reset column size',
|
|
2347
|
+
resetOrder: 'Reset order',
|
|
2348
|
+
rowActions: 'Row Actions',
|
|
2349
|
+
rowNumber: '#',
|
|
2350
|
+
rowNumbers: 'Row Numbers',
|
|
2351
|
+
rowsPerPage: 'Rows per page',
|
|
2352
|
+
countRows: 'Count Rows',
|
|
2353
|
+
countRowsTooltip: 'Count total rows for current filters',
|
|
2354
|
+
rowCount: 'Row Count',
|
|
2355
|
+
rowsSelected: '{count} row(s) selected',
|
|
2356
|
+
save: 'Save',
|
|
2357
|
+
search: 'Search',
|
|
2358
|
+
selectedCountOfRowCountRowsSelected: '{selectedCount} of {rowCount} row(s) selected',
|
|
2359
|
+
select: 'Select',
|
|
2360
|
+
selectAllOnAllPages: 'Select all on all pages',
|
|
2361
|
+
selectAllOnCurrentPage: 'Select all on current page',
|
|
2362
|
+
showAll: 'Show all',
|
|
2363
|
+
showAllColumns: 'Show all columns',
|
|
2364
|
+
showHideColumns: 'Columns',
|
|
2365
|
+
showHideFilters: 'Show/Hide filters',
|
|
2366
|
+
showHideSearch: 'Show/Hide search',
|
|
2367
|
+
showAdvancedFilters: 'Show advanced filters',
|
|
2368
|
+
advancedFilters: 'Advanced Filters',
|
|
2369
|
+
filters: 'Filters',
|
|
2370
|
+
add: 'Add',
|
|
2371
|
+
newEntry: 'New Entry',
|
|
2372
|
+
clear: 'Clear',
|
|
2373
|
+
discardChanges: 'Discard changes',
|
|
2374
|
+
saveFilters: 'Save filters',
|
|
2375
|
+
savedFilters: 'Saved filters',
|
|
2376
|
+
noSavedFilters: 'No saved filters',
|
|
2377
|
+
filterName: 'Filter name',
|
|
2378
|
+
apply: 'Apply',
|
|
2379
|
+
sortByColumnAsc: 'Sort by {column} ascending',
|
|
2380
|
+
sortByColumnDesc: 'Sort by {column} descending',
|
|
2381
|
+
sortedByColumnAsc: 'Sorted by {column} ascending',
|
|
2382
|
+
sortedByColumnDesc: 'Sorted by {column} descending',
|
|
2383
|
+
thenBy: ', then by ',
|
|
2384
|
+
toggleDensity: 'Density',
|
|
2385
|
+
densityCompact: 'Compact',
|
|
2386
|
+
densityStandard: 'Standard',
|
|
2387
|
+
densityComfortable: 'Comfortable',
|
|
2388
|
+
toggleFullScreen: 'Toggle full screen',
|
|
2389
|
+
toggleSelectAll: 'Toggle select all',
|
|
2390
|
+
toggleSelectRow: 'Toggle select row',
|
|
2391
|
+
toggleVisibility: 'Toggle visibility',
|
|
2392
|
+
ungroupByColumn: 'Ungroup by {column}',
|
|
2393
|
+
unpin: 'Unpin',
|
|
2394
|
+
unpinAll: 'Unpin all',
|
|
2395
|
+
dimensionRotationEnabled: 'Rotation enabled',
|
|
2396
|
+
dimensionRotationDisabled: 'Rotation disabled',
|
|
2397
|
+
length: 'Length',
|
|
2398
|
+
width: 'Width',
|
|
2399
|
+
height: 'Height',
|
|
2400
|
+
depth: 'Depth',
|
|
2401
|
+
tolerance: 'Tolerance',
|
|
2402
|
+
exportButton: 'Export',
|
|
2403
|
+
exportSelectRowsTooltip: 'Select rows to export',
|
|
2404
|
+
exportPrintPdf: 'Print PDF',
|
|
2405
|
+
exportDownload: 'Download',
|
|
2406
|
+
exportGrouped: 'Group files',
|
|
2407
|
+
exportInProgress: 'Export in progress...',
|
|
2408
|
+
exportSuccess: 'Export completed successfully.',
|
|
2409
|
+
exportError: 'Export failed. Please try again.',
|
|
2410
|
+
exportNoExportsSelected: 'No export type selected. Please configure the export first.',
|
|
2411
|
+
deleteConfirmationTitle: 'Delete Row',
|
|
2412
|
+
deleteConfirmationMessage: 'Are you sure you want to delete the selected row(s)?',
|
|
2413
|
+
deleteConfirmYes: 'Delete',
|
|
2414
|
+
deleteConfirmNo: 'Cancel',
|
|
2415
|
+
deleteConfirmDeleting: 'Deleting...',
|
|
2416
|
+
errorTitle: 'Unexpected error',
|
|
2417
|
+
errorMessage: 'An unexpected error occurred. Please try again.',
|
|
2418
|
+
serverTableErrorTitle: 'Unable to load table',
|
|
2419
|
+
serverTableErrorMessage: 'Something went wrong while loading the table configuration. Please try again.',
|
|
2420
|
+
serverTableErrorRetry: 'Try again',
|
|
2421
|
+
resetState: 'Reset State',
|
|
2422
|
+
tableOptions: 'Options',
|
|
2268
2423
|
};
|
|
2269
2424
|
|
|
2270
2425
|
const MRT_DefaultColumn = {
|
|
@@ -7463,7 +7618,6 @@ const MRT_TableFooterCell = (_a) => {
|
|
|
7463
7618
|
var { footer, staticColumnIndex, table } = _a, rest = __rest(_a, ["footer", "staticColumnIndex", "table"]);
|
|
7464
7619
|
const theme = useTheme();
|
|
7465
7620
|
const { options: { enableColumnPinning, muiTableFooterCellProps, enableKeyboardShortcuts, }, } = table;
|
|
7466
|
-
useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
7467
7621
|
const { column } = footer;
|
|
7468
7622
|
const { columnDef } = column;
|
|
7469
7623
|
const { columnDefType } = columnDef;
|
|
@@ -7964,7 +8118,6 @@ const MRT_TableHeadCell = (_a) => {
|
|
|
7964
8118
|
const { getState, options: { columnResizeDirection, columnResizeMode, enableKeyboardShortcuts, enableColumnActions, enableColumnDragging, enableColumnOrdering, enableColumnPinning, enableGrouping, enableMultiSort, layoutMode, mrtTheme: { draggingBorderColor }, muiTableHeadCellProps, }, refs: { isResizingRef, tableHeadCellRefs }, setHoveredColumn, } = table;
|
|
7965
8119
|
const [isColumnCellHovered, setIsColumnCellHovered] = useState(false);
|
|
7966
8120
|
const { grouping } = getState();
|
|
7967
|
-
useMRT_SliceValue(table._uiStore, (s) => s.density);
|
|
7968
8121
|
const showColumnFilters = useMRT_SliceValue(table._uiStore, (s) => s.showColumnFilters);
|
|
7969
8122
|
const { column } = header;
|
|
7970
8123
|
const { columnDef } = column;
|
|
@@ -8676,5 +8829,5 @@ const MRT_ToolbarAlertBanner = (_a) => {
|
|
|
8676
8829
|
positionToolbarAlertBanner === 'head-overlay' && (jsx(MRT_SelectCheckbox, { table: table })), ' ', selectedAlert] }), selectedAlert && groupedAlert && jsx("br", {}), groupedAlert] })] })) })) }));
|
|
8677
8830
|
};
|
|
8678
8831
|
|
|
8679
|
-
export { CHECKBOX_DISPLAY_COLUMN_ID, MRT_ActionMenuItem, MRT_AdvancedFilters, MRT_AggregationFns, MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_EditActionButtons, MRT_EditCellTextField, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, MRT_ExportsToolbar, MRT_FilterFns, MRT_FilterOptionMenu, MRT_GrabHandleButton, MRT_LinearProgressBar, MRT_NewEntryForm, MRT_NewEntryFormActions, MRT_NewEntryFormActionsContext, MRT_NewEntryFormProvider, MRT_NewEntryModal, MRT_RowActionMenu, MRT_RowPinButton, MRT_SelectAllMenu, MRT_SelectCheckbox, MRT_SelectionCountBadge, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TableLoadingOverlay, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactServerTable, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, RHF_FormProvider, buildDefaultValues, cellKeyboardShortcuts, createMRTColumnHelper, createRow, defaultDisplayColumnProps, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnFilterInfo, getColumnId, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getDefaultColumnPinningState, getIsAllPagesSelectionActive, getIsRankingRows, getIsRowSelected, getLeadingDisplayColumnIds, getMRT_RowSelectionHandler, getMRT_Rows, getMRT_SelectAllHandler, getTrailingDisplayColumnIds, groupFieldsBySection, isCellEditable, mrtFilterOptions, openEditingCell, prepareColumns, rankGlobalFuzzy, reorderColumn, resolveFormFields, showRowActionsColumn, showRowDragColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSelectionColumn, showRowSpacerColumn, sortByOrder, useDropdownOptions, useMRT_ColumnVirtualizer, useMRT_Effects, useMRT_NewEntryFormActions, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
|
|
8832
|
+
export { CHECKBOX_DISPLAY_COLUMN_ID, MRT_ActionMenuItem, MRT_AdvancedFilters, MRT_AggregationFns, MRT_BottomToolbar, MRT_ColumnActionMenu, MRT_ColumnPinningButtons, MRT_CopyButton, MRT_DefaultColumn, MRT_DefaultDisplayColumn, MRT_EditActionButtons, MRT_EditCellTextField, MRT_EditRowModal, MRT_ExpandAllButton, MRT_ExpandButton, MRT_ExportsToolbar, MRT_FilterFns, MRT_FilterOptionMenu, MRT_GrabHandleButton, MRT_LinearProgressBar, MRT_NewEntryForm, MRT_NewEntryFormActions, MRT_NewEntryFormActionsContext, MRT_NewEntryFormProvider, MRT_NewEntryModal, MRT_RowActionMenu, MRT_RowPinButton, MRT_SelectAllMenu, MRT_SelectCheckbox, MRT_SelectionCountBadge, MRT_ShowHideColumnsButton, MRT_ShowHideColumnsMenu, MRT_ShowHideColumnsMenuItems, MRT_SortingFns, MRT_Table, MRT_TableBody, MRT_TableBodyCell, MRT_TableBodyCellValue, MRT_TableBodyRow, MRT_TableBodyRowGrabHandle, MRT_TableBodyRowPinButton, MRT_TableContainer, MRT_TableDetailPanel, MRT_TableFooter, MRT_TableFooterCell, MRT_TableFooterRow, MRT_TableHead, MRT_TableHeadCell, MRT_TableHeadCellColumnActionsButton, MRT_TableHeadCellFilterLabel, MRT_TableHeadCellGrabHandle, MRT_TableHeadCellResizeHandle, MRT_TableHeadCellSortLabel, MRT_TableHeadRow, MRT_TableLoadingOverlay, MRT_TablePagination, MRT_TablePaper, MRT_ToggleDensePaddingButton, MRT_ToggleFiltersButton, MRT_ToggleGlobalFilterButton, MRT_ToggleRowActionMenuButton, MRT_ToolbarAlertBanner, MRT_ToolbarDropZone, MRT_ToolbarInternalButtons, MRT_TopToolbar, MaterialReactServerTable, MaterialReactTable, Memo_MRT_TableBody, Memo_MRT_TableBodyCell, Memo_MRT_TableBodyRow, RHF_FormProvider, buildDefaultValues, cellKeyboardShortcuts, createDeleteAction, createEditAction, createExportAction, createMRTColumnHelper, createRow, defaultDisplayColumnProps, flexRender, getAllLeafColumnDefs, getCanRankRows, getColumnFilterInfo, getColumnId, getDefaultColumnFilterFn, getDefaultColumnOrderIds, getDefaultColumnPinningState, getIsAllPagesSelectionActive, getIsRankingRows, getIsRowSelected, getLeadingDisplayColumnIds, getMRT_RowSelectionHandler, getMRT_Rows, getMRT_SelectAllHandler, getTrailingDisplayColumnIds, groupFieldsBySection, isCellEditable, mrtFilterOptions, openEditingCell, prepareColumns, rankGlobalFuzzy, reorderColumn, resolveFormFields, showRowActionsColumn, showRowDragColumn, showRowExpandColumn, showRowNumbersColumn, showRowPinningColumn, showRowSelectionColumn, showRowSpacerColumn, sortByOrder, useDropdownOptions, useMRT_ColumnVirtualizer, useMRT_Effects, useMRT_NewEntryFormActions, useMRT_RowVirtualizer, useMRT_Rows, useMRT_TableInstance, useMRT_TableOptions, useMaterialReactTable };
|
|
8680
8833
|
//# sourceMappingURL=index.esm.js.map
|