@dooherceg/material-react-table 3.2.3 → 3.2.5
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 +4 -0
- package/dist/index.esm.js +375 -144
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +375 -144
- package/dist/index.js.map +1 -1
- package/locales/de/index.esm.js +4 -0
- package/locales/de/index.js +4 -0
- package/locales/en/index.esm.js +4 -0
- package/locales/en/index.js +4 -0
- package/locales/fr/index.esm.js +4 -0
- package/locales/fr/index.js +4 -0
- package/locales/hr/index.esm.js +4 -0
- package/locales/hr/index.js +4 -0
- package/locales/nl/index.esm.js +4 -0
- package/locales/nl/index.js +4 -0
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -53,12 +53,19 @@ var SortIcon = require('@mui/icons-material/Sort');
|
|
|
53
53
|
var SyncAltIcon = require('@mui/icons-material/SyncAlt');
|
|
54
54
|
var ViewColumnIcon = require('@mui/icons-material/ViewColumn');
|
|
55
55
|
var VisibilityOffIcon = require('@mui/icons-material/VisibilityOff');
|
|
56
|
+
var FileDownloadIcon = require('@mui/icons-material/FileDownload');
|
|
57
|
+
var PrintIcon = require('@mui/icons-material/Print');
|
|
58
|
+
var Divider = require('@mui/material/Divider');
|
|
59
|
+
var FormControl = require('@mui/material/FormControl');
|
|
60
|
+
var FormControlLabel = require('@mui/material/FormControlLabel');
|
|
61
|
+
var RadioGroup = require('@mui/material/RadioGroup');
|
|
62
|
+
var Typography = require('@mui/material/Typography');
|
|
63
|
+
var printJS = require('print-js');
|
|
64
|
+
var notistack = require('notistack');
|
|
56
65
|
var reactVirtual = require('@tanstack/react-virtual');
|
|
57
66
|
var Drawer = require('@mui/material/Drawer');
|
|
58
|
-
var Typography = require('@mui/material/Typography');
|
|
59
67
|
var TextField = require('@mui/material/TextField');
|
|
60
68
|
var reactHookForm = require('react-hook-form');
|
|
61
|
-
var FormControl = require('@mui/material/FormControl');
|
|
62
69
|
var FormHelperText = require('@mui/material/FormHelperText');
|
|
63
70
|
var InputLabel = require('@mui/material/InputLabel');
|
|
64
71
|
var Select = require('@mui/material/Select');
|
|
@@ -95,14 +102,8 @@ var MenuList = require('@mui/material/MenuList');
|
|
|
95
102
|
var ListItemText = require('@mui/material/ListItemText');
|
|
96
103
|
var BookmarkIcon = require('@mui/icons-material/Bookmark');
|
|
97
104
|
var DeleteForeverIcon = require('@mui/icons-material/DeleteForever');
|
|
98
|
-
var Divider = require('@mui/material/Divider');
|
|
99
|
-
var FormControlLabel = require('@mui/material/FormControlLabel');
|
|
100
105
|
var Switch = require('@mui/material/Switch');
|
|
101
106
|
var Badge = require('@mui/material/Badge');
|
|
102
|
-
var FileDownloadIcon = require('@mui/icons-material/FileDownload');
|
|
103
|
-
var PrintIcon = require('@mui/icons-material/Print');
|
|
104
|
-
var RadioGroup = require('@mui/material/RadioGroup');
|
|
105
|
-
var printJS = require('print-js');
|
|
106
107
|
var TableContainer = require('@mui/material/TableContainer');
|
|
107
108
|
var Dialog = require('@mui/material/Dialog');
|
|
108
109
|
var DialogActions = require('@mui/material/DialogActions');
|
|
@@ -1917,6 +1918,10 @@ const MRT_Localization_EN = {
|
|
|
1917
1918
|
exportPrintPdf: 'Print PDF',
|
|
1918
1919
|
exportDownload: 'Download',
|
|
1919
1920
|
exportGrouped: 'Group files',
|
|
1921
|
+
exportInProgress: 'Export in progress...',
|
|
1922
|
+
exportSuccess: 'Export completed successfully.',
|
|
1923
|
+
exportError: 'Export failed. Please try again.',
|
|
1924
|
+
exportNoExportsSelected: 'No export type selected. Please configure the export first.',
|
|
1920
1925
|
deleteConfirmationTitle: 'Delete Row',
|
|
1921
1926
|
deleteConfirmationMessage: 'Are you sure you want to delete the selected row(s)?',
|
|
1922
1927
|
deleteConfirmYes: 'Delete',
|
|
@@ -1926,6 +1931,330 @@ const MRT_Localization_EN = {
|
|
|
1926
1931
|
tableOptions: 'Options',
|
|
1927
1932
|
};
|
|
1928
1933
|
|
|
1934
|
+
const downloadExportFiles = (files) => {
|
|
1935
|
+
files.forEach((file) => {
|
|
1936
|
+
const binaryString = atob(file.content);
|
|
1937
|
+
const len = binaryString.length;
|
|
1938
|
+
const bytes = new Uint8Array(len);
|
|
1939
|
+
for (let i = 0; i < len; i++) {
|
|
1940
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
1941
|
+
}
|
|
1942
|
+
const blob = new Blob([bytes], { type: 'application/octet-stream' });
|
|
1943
|
+
const element = document.createElement('a');
|
|
1944
|
+
element.href = URL.createObjectURL(blob);
|
|
1945
|
+
element.download = file.filename;
|
|
1946
|
+
document.body.appendChild(element);
|
|
1947
|
+
element.click();
|
|
1948
|
+
document.body.removeChild(element);
|
|
1949
|
+
URL.revokeObjectURL(element.href);
|
|
1950
|
+
});
|
|
1951
|
+
};
|
|
1952
|
+
|
|
1953
|
+
const printExportFiles = (files) => {
|
|
1954
|
+
files.forEach((file) => {
|
|
1955
|
+
const binaryString = atob(file.content);
|
|
1956
|
+
const len = binaryString.length;
|
|
1957
|
+
const bytes = new Uint8Array(len);
|
|
1958
|
+
for (let i = 0; i < len; i++) {
|
|
1959
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
1960
|
+
}
|
|
1961
|
+
const blob = new Blob([bytes], { type: 'application/pdf' });
|
|
1962
|
+
const url = URL.createObjectURL(blob);
|
|
1963
|
+
printJS({
|
|
1964
|
+
printable: url,
|
|
1965
|
+
type: 'pdf',
|
|
1966
|
+
onLoadingEnd: () => URL.revokeObjectURL(url),
|
|
1967
|
+
});
|
|
1968
|
+
});
|
|
1969
|
+
};
|
|
1970
|
+
|
|
1971
|
+
const MRT_ExportsToolbar = ({ table, availableExports, exportState, onExportStateChange, loadExport, }) => {
|
|
1972
|
+
const theme = styles.useTheme();
|
|
1973
|
+
const { localization } = table.options;
|
|
1974
|
+
const { selectedExports, selectedFormat, grouped } = exportState;
|
|
1975
|
+
const [anchorEl, setAnchorEl] = react.useState(null);
|
|
1976
|
+
const [loadingExportType, setLoadingExportType] = react.useState(null);
|
|
1977
|
+
const { rowSelection } = table.getState();
|
|
1978
|
+
const selectedRowIds = Object.keys(rowSelection).filter((id) => rowSelection[id]);
|
|
1979
|
+
const isNoRowsSelected = selectedRowIds.length === 0;
|
|
1980
|
+
const availableFormats = react.useMemo(() => {
|
|
1981
|
+
const allFormats = Object.values(availableExports).flatMap((exp) => exp.formats);
|
|
1982
|
+
return Array.from(new Set(allFormats));
|
|
1983
|
+
}, [availableExports]);
|
|
1984
|
+
const hasPdfFormat = availableFormats.includes('pdf');
|
|
1985
|
+
const exportTypesForSelectedFormat = react.useMemo(() => {
|
|
1986
|
+
if (!selectedFormat)
|
|
1987
|
+
return [];
|
|
1988
|
+
return Object.values(availableExports).filter((exp) => exp.formats.includes(selectedFormat));
|
|
1989
|
+
}, [availableExports, selectedFormat]);
|
|
1990
|
+
const isPrintDisabled = selectedFormat !== 'pdf' ||
|
|
1991
|
+
!selectedFormat ||
|
|
1992
|
+
selectedExports.length < 1 ||
|
|
1993
|
+
(!grouped && selectedExports.length > 1);
|
|
1994
|
+
const isDownloadDisabled = !selectedFormat || selectedExports.length < 1;
|
|
1995
|
+
const handleOpenMenu = (event) => {
|
|
1996
|
+
setAnchorEl(event.currentTarget);
|
|
1997
|
+
};
|
|
1998
|
+
const handleCloseMenu = () => {
|
|
1999
|
+
setAnchorEl(null);
|
|
2000
|
+
};
|
|
2001
|
+
const handleSelectFormat = (format) => {
|
|
2002
|
+
const newFormat = selectedFormat === format ? null : format;
|
|
2003
|
+
onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { grouped: false })), { selectedExports: [], selectedFormat: newFormat })));
|
|
2004
|
+
};
|
|
2005
|
+
const handleToggleExportType = (exportName) => {
|
|
2006
|
+
const isAlreadySelected = selectedExports.includes(exportName);
|
|
2007
|
+
const newSelectedExports = isAlreadySelected
|
|
2008
|
+
? selectedExports.filter((name) => name !== exportName)
|
|
2009
|
+
: [...selectedExports, exportName];
|
|
2010
|
+
onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { selectedFormat: null, grouped: false })), { selectedExports: newSelectedExports })));
|
|
2011
|
+
};
|
|
2012
|
+
const handleToggleGrouped = () => {
|
|
2013
|
+
onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { selectedFormat: null, selectedExports: [] })), { grouped: !grouped })));
|
|
2014
|
+
};
|
|
2015
|
+
const handleExportAction = (type) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2016
|
+
setLoadingExportType(type);
|
|
2017
|
+
try {
|
|
2018
|
+
const response = yield loadExport({
|
|
2019
|
+
format: selectedFormat,
|
|
2020
|
+
exports: selectedExports,
|
|
2021
|
+
separated_files: !grouped,
|
|
2022
|
+
download: false,
|
|
2023
|
+
ids: JSON.stringify(selectedRowIds),
|
|
2024
|
+
type,
|
|
2025
|
+
});
|
|
2026
|
+
handleCloseMenu();
|
|
2027
|
+
if (type === 'download') {
|
|
2028
|
+
downloadExportFiles(response);
|
|
2029
|
+
}
|
|
2030
|
+
else {
|
|
2031
|
+
printExportFiles(response);
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
finally {
|
|
2035
|
+
setLoadingExportType(null);
|
|
2036
|
+
}
|
|
2037
|
+
});
|
|
2038
|
+
const renderFormatSelector = () => (jsxRuntime.jsx(Stack, { justifyContent: "flex-start", minWidth: "200px", sx: {
|
|
2039
|
+
borderRight: selectedFormat
|
|
2040
|
+
? `1px dashed ${theme.palette.divider}`
|
|
2041
|
+
: 'none',
|
|
2042
|
+
}, children: jsxRuntime.jsx(FormControl, { children: jsxRuntime.jsx(RadioGroup, { value: selectedFormat !== null && selectedFormat !== void 0 ? selectedFormat : '', children: availableFormats.map((format) => (jsxRuntime.jsx(FormControlLabel, { sx: { m: 0 }, value: format, control: jsxRuntime.jsx(Radio, { size: "small", onClick: () => handleSelectFormat(format) }), label: jsxRuntime.jsx(Typography, { variant: "subtitle2", sx: { fontWeight: 800 }, children: format }) }, format))) }) }) }));
|
|
2043
|
+
const renderExportTypeSelector = () => {
|
|
2044
|
+
if (!selectedFormat || exportTypesForSelectedFormat.length === 0)
|
|
2045
|
+
return null;
|
|
2046
|
+
return (jsxRuntime.jsx(Stack, { minWidth: "250px", maxHeight: "500px", sx: { overflowY: 'auto' }, children: exportTypesForSelectedFormat.map((exportType) => (jsxRuntime.jsxs(MenuItem, { onClick: () => handleToggleExportType(exportType.name), value: exportType.name, children: [jsxRuntime.jsx(Checkbox, { checked: selectedExports.includes(exportType.name), size: "small" }), jsxRuntime.jsx(Typography, { variant: "body2", children: exportType.label })] }, exportType.name))) }));
|
|
2047
|
+
};
|
|
2048
|
+
const renderActionButtons = () => {
|
|
2049
|
+
const isAnyLoading = loadingExportType !== null;
|
|
2050
|
+
return (jsxRuntime.jsxs(Stack, { direction: "row", gap: 0.5, mt: 1, mr: 2, children: [hasPdfFormat && (jsxRuntime.jsx(Button, { sx: { display: 'flex', gap: 0.5 }, disabled: isPrintDisabled || isAnyLoading, onClick: () => handleExportAction('print'), startIcon: loadingExportType === 'print' ? (jsxRuntime.jsx(CircularProgress, { size: 16, color: "inherit" })) : (jsxRuntime.jsx(PrintIcon, { fontSize: "small" })), children: localization.exportPrintPdf })), jsxRuntime.jsx(Button, { sx: { display: 'flex', gap: 0.5 }, disabled: isDownloadDisabled || isAnyLoading, onClick: () => handleExportAction('download'), startIcon: loadingExportType === 'download' ? (jsxRuntime.jsx(CircularProgress, { size: 16, color: "inherit" })) : (jsxRuntime.jsx(FileDownloadIcon, { fontSize: "small" })), children: localization.exportDownload })] }));
|
|
2051
|
+
};
|
|
2052
|
+
const renderGroupedCheckbox = () => (jsxRuntime.jsx(Stack, { mt: "auto", children: jsxRuntime.jsx(FormControlLabel, { onChange: handleToggleGrouped, sx: { m: 0 }, control: jsxRuntime.jsx(Checkbox, { checked: grouped, size: "small" }), label: jsxRuntime.jsx(Typography, { variant: "body2", children: localization.exportGrouped }) }) }));
|
|
2053
|
+
return (jsxRuntime.jsxs(Stack, { direction: "row", gap: 0.5, alignItems: "center", children: [jsxRuntime.jsx(Tooltip, { title: isNoRowsSelected
|
|
2054
|
+
? localization.exportSelectRowsTooltip
|
|
2055
|
+
: localization.exportButton, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(Button, { "aria-label": localization.exportButton, disabled: isNoRowsSelected, onClick: handleOpenMenu, size: "small", startIcon: jsxRuntime.jsx(FileDownloadIcon, { fontSize: "small" }), variant: "text", children: localization.exportButton }) }) }), jsxRuntime.jsxs(Menu, { anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleCloseMenu, anchorOrigin: { vertical: 'bottom', horizontal: 'left' }, transformOrigin: { vertical: 'top', horizontal: 'left' }, children: [jsxRuntime.jsxs(Stack, { direction: "row", sx: { px: 1, pt: 1, maxHeight: '320px', overflow: 'auto' }, children: [renderFormatSelector(), selectedFormat &&
|
|
2056
|
+
exportTypesForSelectedFormat.length > 0 &&
|
|
2057
|
+
renderExportTypeSelector()] }), jsxRuntime.jsx(Divider, { sx: { mt: 1 } }), jsxRuntime.jsxs(Stack, { direction: "row", alignItems: "center", sx: { px: 1, pb: 1 }, children: [renderActionButtons(), renderGroupedCheckbox()] })] })] }));
|
|
2058
|
+
};
|
|
2059
|
+
|
|
2060
|
+
const MRT_ExportRowButton = ({ onClick }) => {
|
|
2061
|
+
return (jsxRuntime.jsx(IconButton, { sx: { p: 0 }, disableRipple: true, onClick: onClick, children: jsxRuntime.jsx(FileDownloadIcon, { fontSize: "small" }) }));
|
|
2062
|
+
};
|
|
2063
|
+
|
|
2064
|
+
const MRT_PrintRowButton = ({ onClick }) => {
|
|
2065
|
+
return (jsxRuntime.jsx(IconButton, { sx: { p: 0 }, disableRipple: true, onClick: onClick, children: jsxRuntime.jsx(PrintIcon, { fontSize: "small" }) }));
|
|
2066
|
+
};
|
|
2067
|
+
|
|
2068
|
+
const ExportRowAction = ({ onExport, onPrint }) => {
|
|
2069
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(MRT_ExportRowButton, { onClick: onExport }), onPrint && jsxRuntime.jsx(MRT_PrintRowButton, { onClick: onPrint })] }));
|
|
2070
|
+
};
|
|
2071
|
+
|
|
2072
|
+
const hasActiveExports = (table) => {
|
|
2073
|
+
const { activeExports } = table.getState();
|
|
2074
|
+
return !!((activeExports === null || activeExports === void 0 ? void 0 : activeExports.selectedFormat) && activeExports.selectedExports.length > 0);
|
|
2075
|
+
};
|
|
2076
|
+
// Same conditions as MRT_ExportsToolbar: pdf format selected, at least one export type,
|
|
2077
|
+
// and either grouped or exactly one export type selected.
|
|
2078
|
+
const isPrintAvailable = (table) => {
|
|
2079
|
+
var _a;
|
|
2080
|
+
const allFormats = Object.values((_a = table.options.availableExports) !== null && _a !== void 0 ? _a : {}).flatMap((e) => e.formats);
|
|
2081
|
+
if (!allFormats.includes('pdf'))
|
|
2082
|
+
return false;
|
|
2083
|
+
const { activeExports } = table.getState();
|
|
2084
|
+
if (!activeExports)
|
|
2085
|
+
return false;
|
|
2086
|
+
const { selectedFormat, selectedExports, grouped } = activeExports;
|
|
2087
|
+
return (selectedFormat === 'pdf' &&
|
|
2088
|
+
selectedExports.length >= 1 &&
|
|
2089
|
+
(grouped || selectedExports.length === 1));
|
|
2090
|
+
};
|
|
2091
|
+
const createExportAction = (_a = {}) => {
|
|
2092
|
+
var { onExport, renderRow: customRenderRow, renderToolbar: customRenderToolbar } = _a, rest = __rest(_a, ["onExport", "renderRow", "renderToolbar"]);
|
|
2093
|
+
// Pure download logic — no notifications. Throws on failure so callers can handle it.
|
|
2094
|
+
const defaultOnExport = (_a) => __awaiter(void 0, [_a], void 0, function* ({ rowsToExport, table, }) {
|
|
2095
|
+
if (!rowsToExport.length)
|
|
2096
|
+
return;
|
|
2097
|
+
const { loadExport } = table.options;
|
|
2098
|
+
const { activeExports } = table.getState();
|
|
2099
|
+
if (!loadExport || !activeExports)
|
|
2100
|
+
return;
|
|
2101
|
+
const response = yield loadExport({
|
|
2102
|
+
format: activeExports.selectedFormat,
|
|
2103
|
+
exports: activeExports.selectedExports,
|
|
2104
|
+
separated_files: !activeExports.grouped,
|
|
2105
|
+
download: false,
|
|
2106
|
+
ids: JSON.stringify(rowsToExport.map((r) => r.id)),
|
|
2107
|
+
type: 'download',
|
|
2108
|
+
});
|
|
2109
|
+
downloadExportFiles(response);
|
|
2110
|
+
});
|
|
2111
|
+
// Pure print logic — no notifications. Throws on failure so callers can handle it.
|
|
2112
|
+
const defaultOnPrint = (_a) => __awaiter(void 0, [_a], void 0, function* ({ rowsToExport, table, }) {
|
|
2113
|
+
if (!rowsToExport.length)
|
|
2114
|
+
return;
|
|
2115
|
+
const { loadExport } = table.options;
|
|
2116
|
+
const { activeExports } = table.getState();
|
|
2117
|
+
if (!loadExport || !activeExports)
|
|
2118
|
+
return;
|
|
2119
|
+
const response = yield loadExport({
|
|
2120
|
+
format: activeExports.selectedFormat,
|
|
2121
|
+
exports: activeExports.selectedExports,
|
|
2122
|
+
separated_files: !activeExports.grouped,
|
|
2123
|
+
download: false,
|
|
2124
|
+
ids: JSON.stringify(rowsToExport.map((r) => r.id)),
|
|
2125
|
+
type: 'print',
|
|
2126
|
+
});
|
|
2127
|
+
printExportFiles(response);
|
|
2128
|
+
});
|
|
2129
|
+
// Single execution pipeline for every export flow (row or toolbar).
|
|
2130
|
+
// If a custom handler exists, it receives defaultOnExport and decides when to call it.
|
|
2131
|
+
const executeExport = (context) => {
|
|
2132
|
+
const executeDefaultExport = () => defaultOnExport(context);
|
|
2133
|
+
if (onExport) {
|
|
2134
|
+
return onExport(Object.assign(Object.assign({}, context), { defaultOnExport: executeDefaultExport }));
|
|
2135
|
+
}
|
|
2136
|
+
return executeDefaultExport();
|
|
2137
|
+
};
|
|
2138
|
+
// Row download: checks for active exports, then wraps with loading/success/error notifications.
|
|
2139
|
+
const handleSingleRowExport = (_a) => __awaiter(void 0, [_a], void 0, function* ({ table, row, }) {
|
|
2140
|
+
const { localization } = table.options;
|
|
2141
|
+
if (!hasActiveExports(table)) {
|
|
2142
|
+
notistack.enqueueSnackbar(localization.exportNoExportsSelected, {
|
|
2143
|
+
variant: 'warning',
|
|
2144
|
+
});
|
|
2145
|
+
return;
|
|
2146
|
+
}
|
|
2147
|
+
const loadingKey = notistack.enqueueSnackbar(localization.exportInProgress, {
|
|
2148
|
+
variant: 'info',
|
|
2149
|
+
persist: true,
|
|
2150
|
+
});
|
|
2151
|
+
try {
|
|
2152
|
+
yield executeExport({ table, rowsToExport: [row] });
|
|
2153
|
+
notistack.closeSnackbar(loadingKey);
|
|
2154
|
+
notistack.enqueueSnackbar(localization.exportSuccess, { variant: 'success' });
|
|
2155
|
+
}
|
|
2156
|
+
catch (_b) {
|
|
2157
|
+
notistack.closeSnackbar(loadingKey);
|
|
2158
|
+
notistack.enqueueSnackbar(localization.exportError, { variant: 'error' });
|
|
2159
|
+
}
|
|
2160
|
+
});
|
|
2161
|
+
// Row print: same guard + notification pattern as download, but calls defaultOnPrint.
|
|
2162
|
+
const handleSingleRowPrint = (_a) => __awaiter(void 0, [_a], void 0, function* ({ table, row, }) {
|
|
2163
|
+
const { localization } = table.options;
|
|
2164
|
+
if (!hasActiveExports(table)) {
|
|
2165
|
+
notistack.enqueueSnackbar(localization.exportNoExportsSelected, {
|
|
2166
|
+
variant: 'warning',
|
|
2167
|
+
});
|
|
2168
|
+
return;
|
|
2169
|
+
}
|
|
2170
|
+
const loadingKey = notistack.enqueueSnackbar(localization.exportInProgress, {
|
|
2171
|
+
variant: 'info',
|
|
2172
|
+
persist: true,
|
|
2173
|
+
});
|
|
2174
|
+
try {
|
|
2175
|
+
yield defaultOnPrint({ table, rowsToExport: [row] });
|
|
2176
|
+
notistack.closeSnackbar(loadingKey);
|
|
2177
|
+
notistack.enqueueSnackbar(localization.exportSuccess, { variant: 'success' });
|
|
2178
|
+
}
|
|
2179
|
+
catch (_b) {
|
|
2180
|
+
notistack.closeSnackbar(loadingKey);
|
|
2181
|
+
notistack.enqueueSnackbar(localization.exportError, { variant: 'error' });
|
|
2182
|
+
}
|
|
2183
|
+
});
|
|
2184
|
+
// Resolves selected rows from table state for toolbar-triggered export (custom renderToolbar only).
|
|
2185
|
+
const handleMultipleRowExport = ({ table, }) => {
|
|
2186
|
+
const rowsToExport = table.getSelectedRowModel().rows;
|
|
2187
|
+
return executeExport({ table, rowsToExport });
|
|
2188
|
+
};
|
|
2189
|
+
const createRowExportExecutor = (context) => () => {
|
|
2190
|
+
void handleSingleRowExport(context);
|
|
2191
|
+
};
|
|
2192
|
+
const createRowPrintExecutor = (context) => () => {
|
|
2193
|
+
void handleSingleRowPrint(context);
|
|
2194
|
+
};
|
|
2195
|
+
const createToolbarExportExecutor = (context) => () => {
|
|
2196
|
+
void handleMultipleRowExport(context);
|
|
2197
|
+
};
|
|
2198
|
+
// Renders download + optional print button. Print is shown under the same conditions
|
|
2199
|
+
// as in MRT_ExportsToolbar: pdf format selected, active exports, grouped or single type.
|
|
2200
|
+
const renderRowAction = (context) => {
|
|
2201
|
+
const onRowExport = createRowExportExecutor(context);
|
|
2202
|
+
const onRowPrint = isPrintAvailable(context.table)
|
|
2203
|
+
? createRowPrintExecutor(context)
|
|
2204
|
+
: undefined;
|
|
2205
|
+
if (customRenderRow) {
|
|
2206
|
+
return customRenderRow(Object.assign(Object.assign({}, context), { onExport: onRowExport }));
|
|
2207
|
+
}
|
|
2208
|
+
return jsxRuntime.jsx(ExportRowAction, { onExport: onRowExport, onPrint: onRowPrint });
|
|
2209
|
+
};
|
|
2210
|
+
// Uses custom toolbar renderer when provided; otherwise renders MRT_ExportsToolbar.
|
|
2211
|
+
// loadExport is always wrapped with notifications so that loading/success/error are shown
|
|
2212
|
+
// regardless of whether a custom onExport handler was provided.
|
|
2213
|
+
// When onExport is provided, it intercepts the call and returns [] so MRT_ExportsToolbar
|
|
2214
|
+
// does not attempt a second download from an empty response.
|
|
2215
|
+
const renderToolbarAction = (context) => {
|
|
2216
|
+
const { table } = context;
|
|
2217
|
+
const { availableExports, loadExport, onActiveExportsChange, localization, } = table.options;
|
|
2218
|
+
const { activeExports } = table.getState();
|
|
2219
|
+
if (customRenderToolbar) {
|
|
2220
|
+
return customRenderToolbar(Object.assign(Object.assign({}, context), { onExport: createToolbarExportExecutor(context) }));
|
|
2221
|
+
}
|
|
2222
|
+
if (!availableExports ||
|
|
2223
|
+
!loadExport ||
|
|
2224
|
+
!onActiveExportsChange ||
|
|
2225
|
+
!activeExports) {
|
|
2226
|
+
return null;
|
|
2227
|
+
}
|
|
2228
|
+
const notifiedLoadExport = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2229
|
+
const loadingKey = notistack.enqueueSnackbar(localization.exportInProgress, {
|
|
2230
|
+
variant: 'info',
|
|
2231
|
+
persist: true,
|
|
2232
|
+
});
|
|
2233
|
+
try {
|
|
2234
|
+
let response;
|
|
2235
|
+
if (onExport) {
|
|
2236
|
+
const rowsToExport = table.getSelectedRowModel().rows;
|
|
2237
|
+
yield executeExport({ table, rowsToExport });
|
|
2238
|
+
response = [];
|
|
2239
|
+
}
|
|
2240
|
+
else {
|
|
2241
|
+
response = yield loadExport(params);
|
|
2242
|
+
}
|
|
2243
|
+
notistack.closeSnackbar(loadingKey);
|
|
2244
|
+
notistack.enqueueSnackbar(localization.exportSuccess, { variant: 'success' });
|
|
2245
|
+
return response;
|
|
2246
|
+
}
|
|
2247
|
+
catch (_a) {
|
|
2248
|
+
notistack.closeSnackbar(loadingKey);
|
|
2249
|
+
notistack.enqueueSnackbar(localization.exportError, { variant: 'error' });
|
|
2250
|
+
return [];
|
|
2251
|
+
}
|
|
2252
|
+
});
|
|
2253
|
+
return (jsxRuntime.jsx(MRT_ExportsToolbar, { table: table, availableExports: availableExports, exportState: activeExports, onExportStateChange: onActiveExportsChange, loadExport: notifiedLoadExport }));
|
|
2254
|
+
};
|
|
2255
|
+
return Object.assign({ name: 'export', renderRow: renderRowAction, renderToolbar: renderToolbarAction }, rest);
|
|
2256
|
+
};
|
|
2257
|
+
|
|
1929
2258
|
const MRT_DefaultColumn = {
|
|
1930
2259
|
filterVariant: 'text',
|
|
1931
2260
|
maxSize: 1000,
|
|
@@ -1948,8 +2277,18 @@ const MRT_DefaultDisplayColumn = {
|
|
|
1948
2277
|
};
|
|
1949
2278
|
const useMRT_TableOptions = (_a) => {
|
|
1950
2279
|
var _b;
|
|
1951
|
-
var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBatchRowSelection = true, enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = true, enableColumnPinning = true, enableColumnResizing = true, enableColumnVirtualization, enableDensityToggle = true, enableExpandAll = true, maxDepth, enableExpanding, enableRowReordering, enableFacetedValues = false, enableFilterMatchHighlighting = true, enableFilters = false, enableAdvancedFilters = true, enableGlobalFilter = false, enableGlobalFilterRankedResults = true, enableGrouping = true, enableHiding = true, enableKeyboardShortcuts = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = true, enableRowSelection = true, enableRowVirtualization = false, enableSelectAll = true, enableSorting = true, enableStickyHeader = true, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, id = react.useId(), layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, mrtTheme, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionCreatingRow = 'top', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeDirection", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBatchRowSelection", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableColumnVirtualization", "enableDensityToggle", "enableExpandAll", "maxDepth", "enableExpanding", "enableRowReordering", "enableFacetedValues", "enableFilterMatchHighlighting", "enableFilters", "enableAdvancedFilters", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableKeyboardShortcuts", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableRowVirtualization", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "id", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "mrtTheme", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns"]);
|
|
2280
|
+
var { aggregationFns, autoResetExpanded = false, columnFilterDisplayMode = 'subheader', columnResizeDirection, columnResizeMode = 'onChange', createDisplayMode = 'modal', defaultColumn, defaultDisplayColumn, editDisplayMode = 'modal', enableBatchRowSelection = true, enableBottomToolbar = true, enableColumnActions = true, enableColumnFilters = true, enableColumnOrdering = true, enableColumnPinning = true, enableColumnResizing = true, enableColumnVirtualization, enableDensityToggle = true, enableExpandAll = true, maxDepth, enableExpanding, enableRowReordering, enableFacetedValues = false, enableFilterMatchHighlighting = true, enableFilters = false, enableAdvancedFilters = true, enableGlobalFilter = false, enableGlobalFilterRankedResults = true, enableGrouping = true, enableHiding = true, enableKeyboardShortcuts = true, enableMultiRowSelection = true, enableMultiSort = true, enablePagination = true, enableRowPinning = true, enableRowSelection = true, enableRowVirtualization = false, enableSelectAll = true, enableSorting = true, enableStickyHeader = true, enableTableFooter = true, enableTableHead = true, enableToolbarInternalActions = true, enableTopToolbar = true, filterFns, icons, id = react.useId(), layoutMode, localization, manualFiltering, manualGrouping, manualPagination, manualSorting, mrtTheme, paginationDisplayMode = 'default', positionActionsColumn = 'first', positionCreatingRow = 'top', positionExpandColumn = 'first', positionGlobalFilter = 'right', positionPagination = 'bottom', positionToolbarAlertBanner = 'top', positionToolbarDropZone = 'top', rowNumberDisplayMode = 'static', rowPinningDisplayMode = 'sticky', selectAllMode = 'page', sortingFns, actions, availableExports } = _a, rest = __rest(_a, ["aggregationFns", "autoResetExpanded", "columnFilterDisplayMode", "columnResizeDirection", "columnResizeMode", "createDisplayMode", "defaultColumn", "defaultDisplayColumn", "editDisplayMode", "enableBatchRowSelection", "enableBottomToolbar", "enableColumnActions", "enableColumnFilters", "enableColumnOrdering", "enableColumnPinning", "enableColumnResizing", "enableColumnVirtualization", "enableDensityToggle", "enableExpandAll", "maxDepth", "enableExpanding", "enableRowReordering", "enableFacetedValues", "enableFilterMatchHighlighting", "enableFilters", "enableAdvancedFilters", "enableGlobalFilter", "enableGlobalFilterRankedResults", "enableGrouping", "enableHiding", "enableKeyboardShortcuts", "enableMultiRowSelection", "enableMultiSort", "enablePagination", "enableRowPinning", "enableRowSelection", "enableRowVirtualization", "enableSelectAll", "enableSorting", "enableStickyHeader", "enableTableFooter", "enableTableHead", "enableToolbarInternalActions", "enableTopToolbar", "filterFns", "icons", "id", "layoutMode", "localization", "manualFiltering", "manualGrouping", "manualPagination", "manualSorting", "mrtTheme", "paginationDisplayMode", "positionActionsColumn", "positionCreatingRow", "positionExpandColumn", "positionGlobalFilter", "positionPagination", "positionToolbarAlertBanner", "positionToolbarDropZone", "rowNumberDisplayMode", "rowPinningDisplayMode", "selectAllMode", "sortingFns", "actions", "availableExports"]);
|
|
1952
2281
|
const theme = styles.useTheme();
|
|
2282
|
+
// When availableExports is configured and the user has not supplied their own
|
|
2283
|
+
// 'export' action, inject the default export action automatically.
|
|
2284
|
+
const effectiveActions = react.useMemo(() => {
|
|
2285
|
+
if (!availableExports)
|
|
2286
|
+
return actions;
|
|
2287
|
+
const hasUserExportAction = actions === null || actions === void 0 ? void 0 : actions.some((a) => a.name === 'export');
|
|
2288
|
+
if (hasUserExportAction)
|
|
2289
|
+
return actions;
|
|
2290
|
+
return [createExportAction(), ...(actions !== null && actions !== void 0 ? actions : [])];
|
|
2291
|
+
}, [actions, availableExports]);
|
|
1953
2292
|
icons = react.useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
|
|
1954
2293
|
localization = react.useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
|
|
1955
2294
|
mrtTheme = react.useMemo(() => getMRTTheme(mrtTheme, theme), [mrtTheme, theme]);
|
|
@@ -2053,7 +2392,7 @@ const useMRT_TableOptions = (_a) => {
|
|
|
2053
2392
|
rowPinningDisplayMode,
|
|
2054
2393
|
selectAllMode,
|
|
2055
2394
|
sortingFns,
|
|
2056
|
-
enableAdvancedFilters }, rest);
|
|
2395
|
+
enableAdvancedFilters, actions: effectiveActions, availableExports }, rest);
|
|
2057
2396
|
};
|
|
2058
2397
|
|
|
2059
2398
|
const blankColProps = {
|
|
@@ -4714,6 +5053,24 @@ function RowActionsCell({ row, table, }) {
|
|
|
4714
5053
|
}) }));
|
|
4715
5054
|
}
|
|
4716
5055
|
|
|
5056
|
+
// Detects whether a real SnackbarProvider exists in the tree.
|
|
5057
|
+
// In notistack's default context both enqueueSnackbar and closeSnackbar point to
|
|
5058
|
+
// the same no-op reference. A real provider binds them to different functions.
|
|
5059
|
+
const useHasSnackbarProvider = () => {
|
|
5060
|
+
const { enqueueSnackbar, closeSnackbar } = notistack.useSnackbar();
|
|
5061
|
+
return enqueueSnackbar !== closeSnackbar;
|
|
5062
|
+
};
|
|
5063
|
+
const Inner = ({ children }) => {
|
|
5064
|
+
const hasProvider = useHasSnackbarProvider();
|
|
5065
|
+
if (hasProvider)
|
|
5066
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: children });
|
|
5067
|
+
return (jsxRuntime.jsx(notistack.SnackbarProvider, { maxSnack: 5, anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, children: children }));
|
|
5068
|
+
};
|
|
5069
|
+
// Wraps children with SnackbarProvider only when no provider exists in the tree.
|
|
5070
|
+
// When the user's app already has a SnackbarProvider, notifications from MRT
|
|
5071
|
+
// will appear there — inheriting its position and styling.
|
|
5072
|
+
const MaybeSnackbarProvider = ({ children, }) => jsxRuntime.jsx(Inner, { children: children });
|
|
5073
|
+
|
|
4717
5074
|
const MRT_ActiveFilterItem = ({ table, rule, }) => {
|
|
4718
5075
|
var _a;
|
|
4719
5076
|
const column = getFilterColumn(table, rule.columnId);
|
|
@@ -5644,147 +6001,17 @@ const MRT_ToggleGlobalFilterButton = (_a) => {
|
|
|
5644
6001
|
return (jsxRuntime.jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideSearch, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(IconButton, Object.assign({ "aria-label": (_c = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _c !== void 0 ? _c : localization.showHideSearch, disabled: !!globalFilter && showGlobalFilter, onClick: handleToggleSearch }, rest, { title: undefined, children: showGlobalFilter ? jsxRuntime.jsx(SearchOffIcon, {}) : jsxRuntime.jsx(SearchIcon, {}) })) }) }));
|
|
5645
6002
|
};
|
|
5646
6003
|
|
|
5647
|
-
const downloadExportFiles = (files) => {
|
|
5648
|
-
files.forEach((file) => {
|
|
5649
|
-
const binaryString = atob(file.content);
|
|
5650
|
-
const len = binaryString.length;
|
|
5651
|
-
const bytes = new Uint8Array(len);
|
|
5652
|
-
for (let i = 0; i < len; i++) {
|
|
5653
|
-
bytes[i] = binaryString.charCodeAt(i);
|
|
5654
|
-
}
|
|
5655
|
-
const blob = new Blob([bytes], { type: 'application/octet-stream' });
|
|
5656
|
-
const element = document.createElement('a');
|
|
5657
|
-
element.href = URL.createObjectURL(blob);
|
|
5658
|
-
element.download = file.filename;
|
|
5659
|
-
document.body.appendChild(element);
|
|
5660
|
-
element.click();
|
|
5661
|
-
document.body.removeChild(element);
|
|
5662
|
-
URL.revokeObjectURL(element.href);
|
|
5663
|
-
});
|
|
5664
|
-
};
|
|
5665
|
-
|
|
5666
|
-
const printExportFiles = (files) => {
|
|
5667
|
-
files.forEach((file) => {
|
|
5668
|
-
const binaryString = atob(file.content);
|
|
5669
|
-
const len = binaryString.length;
|
|
5670
|
-
const bytes = new Uint8Array(len);
|
|
5671
|
-
for (let i = 0; i < len; i++) {
|
|
5672
|
-
bytes[i] = binaryString.charCodeAt(i);
|
|
5673
|
-
}
|
|
5674
|
-
const blob = new Blob([bytes], { type: 'application/pdf' });
|
|
5675
|
-
const url = URL.createObjectURL(blob);
|
|
5676
|
-
printJS({
|
|
5677
|
-
printable: url,
|
|
5678
|
-
type: 'pdf',
|
|
5679
|
-
onLoadingEnd: () => URL.revokeObjectURL(url),
|
|
5680
|
-
});
|
|
5681
|
-
});
|
|
5682
|
-
};
|
|
5683
|
-
|
|
5684
|
-
const MRT_ExportsToolbar = ({ table, availableExports, exportState, onExportStateChange, loadExport, }) => {
|
|
5685
|
-
const theme = styles.useTheme();
|
|
5686
|
-
const { localization } = table.options;
|
|
5687
|
-
const { selectedExports, selectedFormat, grouped } = exportState;
|
|
5688
|
-
const [anchorEl, setAnchorEl] = react.useState(null);
|
|
5689
|
-
const [loadingExportType, setLoadingExportType] = react.useState(null);
|
|
5690
|
-
const { rowSelection } = table.getState();
|
|
5691
|
-
const selectedRowIds = Object.keys(rowSelection).filter((id) => rowSelection[id]);
|
|
5692
|
-
const isNoRowsSelected = selectedRowIds.length === 0;
|
|
5693
|
-
const availableFormats = react.useMemo(() => {
|
|
5694
|
-
const allFormats = Object.values(availableExports).flatMap((exp) => exp.formats);
|
|
5695
|
-
return Array.from(new Set(allFormats));
|
|
5696
|
-
}, [availableExports]);
|
|
5697
|
-
const hasPdfFormat = availableFormats.includes('pdf');
|
|
5698
|
-
const exportTypesForSelectedFormat = react.useMemo(() => {
|
|
5699
|
-
if (!selectedFormat)
|
|
5700
|
-
return [];
|
|
5701
|
-
return Object.values(availableExports).filter((exp) => exp.formats.includes(selectedFormat));
|
|
5702
|
-
}, [availableExports, selectedFormat]);
|
|
5703
|
-
const isPrintDisabled = selectedFormat !== 'pdf' ||
|
|
5704
|
-
!selectedFormat ||
|
|
5705
|
-
selectedExports.length < 1 ||
|
|
5706
|
-
(!grouped && selectedExports.length > 1);
|
|
5707
|
-
const isDownloadDisabled = !selectedFormat || selectedExports.length < 1;
|
|
5708
|
-
const handleOpenMenu = (event) => {
|
|
5709
|
-
setAnchorEl(event.currentTarget);
|
|
5710
|
-
};
|
|
5711
|
-
const handleCloseMenu = () => {
|
|
5712
|
-
setAnchorEl(null);
|
|
5713
|
-
};
|
|
5714
|
-
const handleSelectFormat = (format) => {
|
|
5715
|
-
const newFormat = selectedFormat === format ? null : format;
|
|
5716
|
-
onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { grouped: false })), { selectedExports: [], selectedFormat: newFormat })));
|
|
5717
|
-
};
|
|
5718
|
-
const handleToggleExportType = (exportName) => {
|
|
5719
|
-
const isAlreadySelected = selectedExports.includes(exportName);
|
|
5720
|
-
const newSelectedExports = isAlreadySelected
|
|
5721
|
-
? selectedExports.filter((name) => name !== exportName)
|
|
5722
|
-
: [...selectedExports, exportName];
|
|
5723
|
-
onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { selectedFormat: null, grouped: false })), { selectedExports: newSelectedExports })));
|
|
5724
|
-
};
|
|
5725
|
-
const handleToggleGrouped = () => {
|
|
5726
|
-
onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { selectedFormat: null, selectedExports: [] })), { grouped: !grouped })));
|
|
5727
|
-
};
|
|
5728
|
-
const handleExportAction = (type) => __awaiter(void 0, void 0, void 0, function* () {
|
|
5729
|
-
setLoadingExportType(type);
|
|
5730
|
-
try {
|
|
5731
|
-
const response = yield loadExport({
|
|
5732
|
-
format: selectedFormat,
|
|
5733
|
-
exports: selectedExports,
|
|
5734
|
-
separated_files: !grouped,
|
|
5735
|
-
download: false,
|
|
5736
|
-
ids: JSON.stringify(selectedRowIds),
|
|
5737
|
-
type,
|
|
5738
|
-
});
|
|
5739
|
-
handleCloseMenu();
|
|
5740
|
-
if (type === 'download') {
|
|
5741
|
-
downloadExportFiles(response);
|
|
5742
|
-
}
|
|
5743
|
-
else {
|
|
5744
|
-
printExportFiles(response);
|
|
5745
|
-
}
|
|
5746
|
-
}
|
|
5747
|
-
finally {
|
|
5748
|
-
setLoadingExportType(null);
|
|
5749
|
-
}
|
|
5750
|
-
});
|
|
5751
|
-
const renderFormatSelector = () => (jsxRuntime.jsx(Stack, { justifyContent: "flex-start", minWidth: "200px", sx: {
|
|
5752
|
-
borderRight: selectedFormat
|
|
5753
|
-
? `1px dashed ${theme.palette.divider}`
|
|
5754
|
-
: 'none',
|
|
5755
|
-
}, children: jsxRuntime.jsx(FormControl, { children: jsxRuntime.jsx(RadioGroup, { value: selectedFormat !== null && selectedFormat !== void 0 ? selectedFormat : '', children: availableFormats.map((format) => (jsxRuntime.jsx(FormControlLabel, { sx: { m: 0 }, value: format, control: jsxRuntime.jsx(Radio, { size: "small", onClick: () => handleSelectFormat(format) }), label: jsxRuntime.jsx(Typography, { variant: "subtitle2", sx: { fontWeight: 800 }, children: format }) }, format))) }) }) }));
|
|
5756
|
-
const renderExportTypeSelector = () => {
|
|
5757
|
-
if (!selectedFormat || exportTypesForSelectedFormat.length === 0)
|
|
5758
|
-
return null;
|
|
5759
|
-
return (jsxRuntime.jsx(Stack, { minWidth: "250px", maxHeight: "500px", sx: { overflowY: 'auto' }, children: exportTypesForSelectedFormat.map((exportType) => (jsxRuntime.jsxs(MenuItem, { onClick: () => handleToggleExportType(exportType.name), value: exportType.name, children: [jsxRuntime.jsx(Checkbox, { checked: selectedExports.includes(exportType.name), size: "small" }), jsxRuntime.jsx(Typography, { variant: "body2", children: exportType.label })] }, exportType.name))) }));
|
|
5760
|
-
};
|
|
5761
|
-
const renderActionButtons = () => {
|
|
5762
|
-
const isAnyLoading = loadingExportType !== null;
|
|
5763
|
-
return (jsxRuntime.jsxs(Stack, { direction: "row", gap: 0.5, mt: 1, mr: 2, children: [hasPdfFormat && (jsxRuntime.jsx(Button, { sx: { display: 'flex', gap: 0.5 }, disabled: isPrintDisabled || isAnyLoading, onClick: () => handleExportAction('print'), startIcon: loadingExportType === 'print' ? (jsxRuntime.jsx(CircularProgress, { size: 16, color: "inherit" })) : (jsxRuntime.jsx(PrintIcon, { fontSize: "small" })), children: localization.exportPrintPdf })), jsxRuntime.jsx(Button, { sx: { display: 'flex', gap: 0.5 }, disabled: isDownloadDisabled || isAnyLoading, onClick: () => handleExportAction('download'), startIcon: loadingExportType === 'download' ? (jsxRuntime.jsx(CircularProgress, { size: 16, color: "inherit" })) : (jsxRuntime.jsx(FileDownloadIcon, { fontSize: "small" })), children: localization.exportDownload })] }));
|
|
5764
|
-
};
|
|
5765
|
-
const renderGroupedCheckbox = () => (jsxRuntime.jsx(Stack, { mt: "auto", children: jsxRuntime.jsx(FormControlLabel, { onChange: handleToggleGrouped, sx: { m: 0 }, control: jsxRuntime.jsx(Checkbox, { checked: grouped, size: "small" }), label: jsxRuntime.jsx(Typography, { variant: "body2", children: localization.exportGrouped }) }) }));
|
|
5766
|
-
return (jsxRuntime.jsxs(Stack, { direction: "row", gap: 0.5, alignItems: "center", children: [jsxRuntime.jsx(Tooltip, { title: isNoRowsSelected
|
|
5767
|
-
? localization.exportSelectRowsTooltip
|
|
5768
|
-
: localization.exportButton, children: jsxRuntime.jsx("span", { children: jsxRuntime.jsx(Button, { "aria-label": localization.exportButton, disabled: isNoRowsSelected, onClick: handleOpenMenu, size: "small", startIcon: jsxRuntime.jsx(FileDownloadIcon, { fontSize: "small" }), variant: "text", children: localization.exportButton }) }) }), jsxRuntime.jsxs(Menu, { anchorEl: anchorEl, open: Boolean(anchorEl), onClose: handleCloseMenu, anchorOrigin: { vertical: 'bottom', horizontal: 'left' }, transformOrigin: { vertical: 'top', horizontal: 'left' }, children: [jsxRuntime.jsxs(Stack, { direction: "row", sx: { px: 1, pt: 1, maxHeight: '320px', overflow: 'auto' }, children: [renderFormatSelector(), selectedFormat &&
|
|
5769
|
-
exportTypesForSelectedFormat.length > 0 &&
|
|
5770
|
-
renderExportTypeSelector()] }), jsxRuntime.jsx(Divider, { sx: { mt: 1 } }), jsxRuntime.jsxs(Stack, { direction: "row", alignItems: "center", sx: { px: 1, pb: 1 }, children: [renderActionButtons(), renderGroupedCheckbox()] })] })] }));
|
|
5771
|
-
};
|
|
5772
|
-
|
|
5773
6004
|
const MRT_ToolbarInternalButtons = (_a) => {
|
|
5774
6005
|
var _b;
|
|
5775
6006
|
var { table } = _a, rest = __rest(_a, ["table"]);
|
|
5776
|
-
const { options: {
|
|
5777
|
-
const { activeExports } = table.getState();
|
|
6007
|
+
const { options: { columnFilterDisplayMode, enableColumnFilters, enableColumnOrdering, enableColumnPinning, enableDensityToggle, enableFilters, enableGlobalFilter, enableHiding, initialState, enableAdvancedFilters, renderToolbarInternalActions, enableNewEntryButton, }, } = table;
|
|
5778
6008
|
return (jsxRuntime.jsx(Box, Object.assign({}, rest, { sx: (theme) => (Object.assign({ alignItems: 'center', display: 'flex', zIndex: 3, gap: 1 }, parseFromValuesOrFunc(rest === null || rest === void 0 ? void 0 : rest.sx, theme))), children: (_b = renderToolbarInternalActions === null || renderToolbarInternalActions === void 0 ? void 0 : renderToolbarInternalActions({
|
|
5779
6009
|
table,
|
|
5780
6010
|
})) !== null && _b !== void 0 ? _b : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [enableFilters &&
|
|
5781
6011
|
enableGlobalFilter &&
|
|
5782
6012
|
!(initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) && (jsxRuntime.jsx(MRT_ToggleGlobalFilterButton, { table: table })), enableFilters &&
|
|
5783
6013
|
enableColumnFilters &&
|
|
5784
|
-
columnFilterDisplayMode !== 'popover' && (jsxRuntime.jsx(MRT_ToggleFiltersButton, { table: table })), (enableHiding || enableColumnOrdering || enableColumnPinning) && (jsxRuntime.jsx(MRT_ShowHideColumnsButton, { table: table })), enableDensityToggle && (jsxRuntime.jsx(MRT_ToggleDensePaddingButton, { table: table })), enableAdvancedFilters && (jsxRuntime.jsx(MRT_ToggleAdvancedFiltersButton, { table: table })), enableAdvancedFilters && jsxRuntime.jsx(MRT_SavedFiltersButton, { table: table }),
|
|
5785
|
-
loadExport &&
|
|
5786
|
-
onActiveExportsChange &&
|
|
5787
|
-
activeExports && (jsxRuntime.jsx(MRT_ExportsToolbar, { table: table, availableExports: availableExports, exportState: activeExports, onExportStateChange: onActiveExportsChange, loadExport: loadExport })), enableNewEntryButton && jsxRuntime.jsx(MRT_NewEntryButton, { table: table })] })) })));
|
|
6014
|
+
columnFilterDisplayMode !== 'popover' && (jsxRuntime.jsx(MRT_ToggleFiltersButton, { table: table })), (enableHiding || enableColumnOrdering || enableColumnPinning) && (jsxRuntime.jsx(MRT_ShowHideColumnsButton, { table: table })), enableDensityToggle && (jsxRuntime.jsx(MRT_ToggleDensePaddingButton, { table: table })), enableAdvancedFilters && (jsxRuntime.jsx(MRT_ToggleAdvancedFiltersButton, { table: table })), enableAdvancedFilters && jsxRuntime.jsx(MRT_SavedFiltersButton, { table: table }), enableNewEntryButton && jsxRuntime.jsx(MRT_NewEntryButton, { table: table })] })) })));
|
|
5788
6015
|
};
|
|
5789
6016
|
|
|
5790
6017
|
function ToolbarActions({ table, }) {
|
|
@@ -7601,7 +7828,7 @@ const MaterialReactTableComponent = (props, ref) => {
|
|
|
7601
7828
|
? props.table
|
|
7602
7829
|
: useMaterialReactTable(props);
|
|
7603
7830
|
react.useImperativeHandle(ref, () => table, [table]);
|
|
7604
|
-
return jsxRuntime.jsx(MRT_TablePaper, { table: table });
|
|
7831
|
+
return (jsxRuntime.jsx(MaybeSnackbarProvider, { children: jsxRuntime.jsx(MRT_TablePaper, { table: table }) }));
|
|
7605
7832
|
};
|
|
7606
7833
|
const MaterialReactTable = react.forwardRef(MaterialReactTableComponent);
|
|
7607
7834
|
|
|
@@ -7858,6 +8085,10 @@ const MRT_Localization_HR = {
|
|
|
7858
8085
|
exportPrintPdf: 'Ispis PDF',
|
|
7859
8086
|
exportDownload: 'Preuzmi',
|
|
7860
8087
|
exportGrouped: 'Grupirati datoteke',
|
|
8088
|
+
exportInProgress: 'Izvoz u toku...',
|
|
8089
|
+
exportSuccess: 'Izvoz je uspješno završen.',
|
|
8090
|
+
exportError: 'Izvoz nije uspio. Pokušajte ponovo.',
|
|
8091
|
+
exportNoExportsSelected: 'Nije odabran tip izvoza. Molimo odaberite izvoz iz gornje trake.',
|
|
7861
8092
|
deleteConfirmationTitle: 'Brisanje reda',
|
|
7862
8093
|
deleteConfirmationMessage: 'Da li ste sigurni da želite izbrisati ovaj red?',
|
|
7863
8094
|
deleteConfirmYes: 'Izbriši',
|
|
@@ -7898,7 +8129,7 @@ const buildInitialExportState = (availableExports, savedActiveExports) => {
|
|
|
7898
8129
|
return {
|
|
7899
8130
|
selectedFormat: uniqueFormats[0],
|
|
7900
8131
|
selectedExports: exportEntries.length > 0 ? [exportEntries[0].name] : [],
|
|
7901
|
-
grouped: false,
|
|
8132
|
+
grouped: savedActiveExports ? savedActiveExports.grouped : false,
|
|
7902
8133
|
};
|
|
7903
8134
|
}
|
|
7904
8135
|
return (savedActiveExports !== null && savedActiveExports !== void 0 ? savedActiveExports : {
|