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