@dooherceg/material-react-table 3.2.4 → 3.2.6

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.esm.js CHANGED
@@ -51,12 +51,19 @@ import SortIcon from '@mui/icons-material/Sort';
51
51
  import SyncAltIcon from '@mui/icons-material/SyncAlt';
52
52
  import ViewColumnIcon from '@mui/icons-material/ViewColumn';
53
53
  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';
54
63
  import { defaultRangeExtractor, useVirtualizer } from '@tanstack/react-virtual';
55
64
  import Drawer from '@mui/material/Drawer';
56
- import Typography from '@mui/material/Typography';
57
65
  import TextField from '@mui/material/TextField';
58
66
  import { useFormContext, Controller, FormProvider, useForm } from 'react-hook-form';
59
- import FormControl from '@mui/material/FormControl';
60
67
  import FormHelperText from '@mui/material/FormHelperText';
61
68
  import InputLabel from '@mui/material/InputLabel';
62
69
  import Select from '@mui/material/Select';
@@ -80,6 +87,7 @@ import { Icon } from '@iconify/react';
80
87
  import BookmarkAddIcon from '@mui/icons-material/BookmarkAdd';
81
88
  import CheckIcon from '@mui/icons-material/Check';
82
89
  import ClickAwayListener from '@mui/material/ClickAwayListener';
90
+ import ErrorOutlineRoundedIcon from '@mui/icons-material/ErrorOutlineRounded';
83
91
  import Paper from '@mui/material/Paper';
84
92
  import Collapse from '@mui/material/Collapse';
85
93
  import LinearProgress from '@mui/material/LinearProgress';
@@ -93,14 +101,8 @@ import MenuList from '@mui/material/MenuList';
93
101
  import ListItemText from '@mui/material/ListItemText';
94
102
  import BookmarkIcon from '@mui/icons-material/Bookmark';
95
103
  import DeleteForeverIcon from '@mui/icons-material/DeleteForever';
96
- import Divider from '@mui/material/Divider';
97
- import FormControlLabel from '@mui/material/FormControlLabel';
98
104
  import Switch from '@mui/material/Switch';
99
105
  import Badge from '@mui/material/Badge';
100
- import FileDownloadIcon from '@mui/icons-material/FileDownload';
101
- import PrintIcon from '@mui/icons-material/Print';
102
- import RadioGroup from '@mui/material/RadioGroup';
103
- import printJS from 'print-js';
104
106
  import TableContainer from '@mui/material/TableContainer';
105
107
  import Dialog from '@mui/material/Dialog';
106
108
  import DialogActions from '@mui/material/DialogActions';
@@ -1896,6 +1898,9 @@ const MRT_Localization_EN = {
1896
1898
  sortedByColumnDesc: 'Sorted by {column} descending',
1897
1899
  thenBy: ', then by ',
1898
1900
  toggleDensity: 'Density',
1901
+ densityCompact: 'Compact',
1902
+ densityStandard: 'Standard',
1903
+ densityComfortable: 'Comfortable',
1899
1904
  toggleFullScreen: 'Toggle full screen',
1900
1905
  toggleSelectAll: 'Toggle select all',
1901
1906
  toggleSelectRow: 'Toggle select row',
@@ -1915,15 +1920,348 @@ const MRT_Localization_EN = {
1915
1920
  exportPrintPdf: 'Print PDF',
1916
1921
  exportDownload: 'Download',
1917
1922
  exportGrouped: 'Group files',
1923
+ exportInProgress: 'Export in progress...',
1924
+ exportSuccess: 'Export completed successfully.',
1925
+ exportError: 'Export failed. Please try again.',
1926
+ exportNoExportsSelected: 'No export type selected. Please configure the export first.',
1918
1927
  deleteConfirmationTitle: 'Delete Row',
1919
1928
  deleteConfirmationMessage: 'Are you sure you want to delete the selected row(s)?',
1920
1929
  deleteConfirmYes: 'Delete',
1921
1930
  deleteConfirmNo: 'Cancel',
1922
1931
  deleteConfirmDeleting: 'Deleting...',
1932
+ errorTitle: 'Unexpected error',
1933
+ errorMessage: 'An unexpected error occurred. Please try again.',
1934
+ serverTableErrorTitle: 'Unable to load table',
1935
+ serverTableErrorMessage: 'Something went wrong while loading the table configuration. Please try again.',
1936
+ serverTableErrorRetry: 'Try again',
1923
1937
  resetState: 'Reset State',
1924
1938
  tableOptions: 'Options',
1925
1939
  };
1926
1940
 
1941
+ const downloadExportFiles = (files) => {
1942
+ files.forEach((file) => {
1943
+ const binaryString = atob(file.content);
1944
+ const len = binaryString.length;
1945
+ const bytes = new Uint8Array(len);
1946
+ for (let i = 0; i < len; i++) {
1947
+ bytes[i] = binaryString.charCodeAt(i);
1948
+ }
1949
+ const blob = new Blob([bytes], { type: 'application/octet-stream' });
1950
+ const element = document.createElement('a');
1951
+ element.href = URL.createObjectURL(blob);
1952
+ element.download = file.filename;
1953
+ document.body.appendChild(element);
1954
+ element.click();
1955
+ document.body.removeChild(element);
1956
+ URL.revokeObjectURL(element.href);
1957
+ });
1958
+ };
1959
+
1960
+ const printExportFiles = (files) => {
1961
+ files.forEach((file) => {
1962
+ const binaryString = atob(file.content);
1963
+ const len = binaryString.length;
1964
+ const bytes = new Uint8Array(len);
1965
+ for (let i = 0; i < len; i++) {
1966
+ bytes[i] = binaryString.charCodeAt(i);
1967
+ }
1968
+ const blob = new Blob([bytes], { type: 'application/pdf' });
1969
+ const url = URL.createObjectURL(blob);
1970
+ printJS({
1971
+ printable: url,
1972
+ type: 'pdf',
1973
+ onLoadingEnd: () => URL.revokeObjectURL(url),
1974
+ });
1975
+ });
1976
+ };
1977
+
1978
+ const MRT_ExportsToolbar = ({ table, availableExports, exportState, onExportStateChange, loadExport, }) => {
1979
+ const theme = useTheme();
1980
+ const { localization } = table.options;
1981
+ const { selectedExports, selectedFormat, grouped } = exportState;
1982
+ const [anchorEl, setAnchorEl] = useState(null);
1983
+ const [loadingExportType, setLoadingExportType] = useState(null);
1984
+ const { rowSelection } = table.getState();
1985
+ const selectedRowIds = Object.keys(rowSelection).filter((id) => rowSelection[id]);
1986
+ const isNoRowsSelected = selectedRowIds.length === 0;
1987
+ const availableFormats = useMemo(() => {
1988
+ const allFormats = Object.values(availableExports).flatMap((exp) => exp.formats);
1989
+ return Array.from(new Set(allFormats));
1990
+ }, [availableExports]);
1991
+ const hasPdfFormat = availableFormats.includes('pdf');
1992
+ const exportTypesForSelectedFormat = useMemo(() => {
1993
+ if (!selectedFormat)
1994
+ return [];
1995
+ return Object.values(availableExports).filter((exp) => exp.formats.includes(selectedFormat));
1996
+ }, [availableExports, selectedFormat]);
1997
+ const isPrintDisabled = selectedFormat !== 'pdf' ||
1998
+ !selectedFormat ||
1999
+ selectedExports.length < 1 ||
2000
+ (!grouped && selectedExports.length > 1);
2001
+ const isDownloadDisabled = !selectedFormat || selectedExports.length < 1;
2002
+ const handleOpenMenu = (event) => {
2003
+ setAnchorEl(event.currentTarget);
2004
+ };
2005
+ const handleCloseMenu = () => {
2006
+ setAnchorEl(null);
2007
+ };
2008
+ const handleSelectFormat = (format) => {
2009
+ const newFormat = selectedFormat === format ? null : format;
2010
+ onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { grouped: false })), { selectedExports: [], selectedFormat: newFormat })));
2011
+ };
2012
+ const handleToggleExportType = (exportName) => {
2013
+ const isAlreadySelected = selectedExports.includes(exportName);
2014
+ const newSelectedExports = isAlreadySelected
2015
+ ? selectedExports.filter((name) => name !== exportName)
2016
+ : [...selectedExports, exportName];
2017
+ onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { selectedFormat: null, grouped: false })), { selectedExports: newSelectedExports })));
2018
+ };
2019
+ const handleToggleGrouped = () => {
2020
+ onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { selectedFormat: null, selectedExports: [] })), { grouped: !grouped })));
2021
+ };
2022
+ const handleExportAction = (type) => __awaiter(void 0, void 0, void 0, function* () {
2023
+ setLoadingExportType(type);
2024
+ try {
2025
+ const response = yield loadExport({
2026
+ format: selectedFormat,
2027
+ exports: selectedExports,
2028
+ separated_files: !grouped,
2029
+ download: false,
2030
+ ids: JSON.stringify(selectedRowIds),
2031
+ type,
2032
+ });
2033
+ handleCloseMenu();
2034
+ if (type === 'download') {
2035
+ downloadExportFiles(response);
2036
+ }
2037
+ else {
2038
+ printExportFiles(response);
2039
+ }
2040
+ }
2041
+ finally {
2042
+ setLoadingExportType(null);
2043
+ }
2044
+ });
2045
+ const renderFormatSelector = () => (jsx(Stack, { justifyContent: "flex-start", minWidth: "200px", sx: {
2046
+ borderRight: selectedFormat
2047
+ ? `1px dashed ${theme.palette.divider}`
2048
+ : 'none',
2049
+ }, 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))) }) }) }));
2050
+ const renderExportTypeSelector = () => {
2051
+ if (!selectedFormat || exportTypesForSelectedFormat.length === 0)
2052
+ return null;
2053
+ 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))) }));
2054
+ };
2055
+ const renderActionButtons = () => {
2056
+ const isAnyLoading = loadingExportType !== null;
2057
+ 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 })] }));
2058
+ };
2059
+ 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 }) }) }));
2060
+ return (jsxs(Stack, { direction: "row", gap: 0.5, alignItems: "center", children: [jsx(Tooltip, { title: isNoRowsSelected
2061
+ ? localization.exportSelectRowsTooltip
2062
+ : 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 &&
2063
+ exportTypesForSelectedFormat.length > 0 &&
2064
+ renderExportTypeSelector()] }), jsx(Divider, { sx: { mt: 1 } }), jsxs(Stack, { direction: "row", alignItems: "center", sx: { px: 1, pb: 1 }, children: [renderActionButtons(), renderGroupedCheckbox()] })] })] }));
2065
+ };
2066
+
2067
+ const MRT_ExportRowButton = ({ onClick }) => {
2068
+ return (jsx(IconButton, { sx: { p: 0 }, disableRipple: true, onClick: onClick, children: jsx(FileDownloadIcon, { fontSize: "small" }) }));
2069
+ };
2070
+
2071
+ const MRT_PrintRowButton = ({ onClick }) => {
2072
+ return (jsx(IconButton, { sx: { p: 0 }, disableRipple: true, onClick: onClick, children: jsx(PrintIcon, { fontSize: "small" }) }));
2073
+ };
2074
+
2075
+ const ExportRowAction = ({ onExport, onPrint }) => {
2076
+ return (jsxs(Fragment, { children: [jsx(MRT_ExportRowButton, { onClick: onExport }), onPrint && jsx(MRT_PrintRowButton, { onClick: onPrint })] }));
2077
+ };
2078
+
2079
+ const hasActiveExports = (table) => {
2080
+ const { activeExports } = table.getState();
2081
+ return !!((activeExports === null || activeExports === void 0 ? void 0 : activeExports.selectedFormat) && activeExports.selectedExports.length > 0);
2082
+ };
2083
+ // Same conditions as MRT_ExportsToolbar: pdf format selected, at least one export type,
2084
+ // and either grouped or exactly one export type selected.
2085
+ const isPrintAvailable = (table) => {
2086
+ var _a;
2087
+ const allFormats = Object.values((_a = table.options.availableExports) !== null && _a !== void 0 ? _a : {}).flatMap((e) => e.formats);
2088
+ if (!allFormats.includes('pdf'))
2089
+ return false;
2090
+ const { activeExports } = table.getState();
2091
+ if (!activeExports)
2092
+ return false;
2093
+ const { selectedFormat, selectedExports, grouped } = activeExports;
2094
+ return (selectedFormat === 'pdf' &&
2095
+ selectedExports.length >= 1 &&
2096
+ (grouped || selectedExports.length === 1));
2097
+ };
2098
+ const createExportAction = (_a = {}) => {
2099
+ var { onExport, renderRow: customRenderRow, renderToolbar: customRenderToolbar } = _a, rest = __rest(_a, ["onExport", "renderRow", "renderToolbar"]);
2100
+ // Pure download logic — no notifications. Throws on failure so callers can handle it.
2101
+ const defaultOnExport = (_a) => __awaiter(void 0, [_a], void 0, function* ({ rowsToExport, table, }) {
2102
+ if (!rowsToExport.length)
2103
+ return;
2104
+ const { loadExport } = table.options;
2105
+ const { activeExports } = table.getState();
2106
+ if (!loadExport || !activeExports)
2107
+ return;
2108
+ const response = yield loadExport({
2109
+ format: activeExports.selectedFormat,
2110
+ exports: activeExports.selectedExports,
2111
+ separated_files: !activeExports.grouped,
2112
+ download: false,
2113
+ ids: JSON.stringify(rowsToExport.map((r) => r.id)),
2114
+ type: 'download',
2115
+ });
2116
+ downloadExportFiles(response);
2117
+ });
2118
+ // Pure print logic — no notifications. Throws on failure so callers can handle it.
2119
+ const defaultOnPrint = (_a) => __awaiter(void 0, [_a], void 0, function* ({ rowsToExport, table, }) {
2120
+ if (!rowsToExport.length)
2121
+ return;
2122
+ const { loadExport } = table.options;
2123
+ const { activeExports } = table.getState();
2124
+ if (!loadExport || !activeExports)
2125
+ return;
2126
+ const response = yield loadExport({
2127
+ format: activeExports.selectedFormat,
2128
+ exports: activeExports.selectedExports,
2129
+ separated_files: !activeExports.grouped,
2130
+ download: false,
2131
+ ids: JSON.stringify(rowsToExport.map((r) => r.id)),
2132
+ type: 'print',
2133
+ });
2134
+ printExportFiles(response);
2135
+ });
2136
+ // Single execution pipeline for every export flow (row or toolbar).
2137
+ // If a custom handler exists, it receives defaultOnExport and decides when to call it.
2138
+ const executeExport = (context) => {
2139
+ const executeDefaultExport = () => defaultOnExport(context);
2140
+ if (onExport) {
2141
+ return onExport(Object.assign(Object.assign({}, context), { defaultOnExport: executeDefaultExport }));
2142
+ }
2143
+ return executeDefaultExport();
2144
+ };
2145
+ // Row download: checks for active exports, then wraps with loading/success/error notifications.
2146
+ const handleSingleRowExport = (_a) => __awaiter(void 0, [_a], void 0, function* ({ table, row, }) {
2147
+ const { localization } = table.options;
2148
+ if (!hasActiveExports(table)) {
2149
+ enqueueSnackbar(localization.exportNoExportsSelected, {
2150
+ variant: 'warning',
2151
+ });
2152
+ return;
2153
+ }
2154
+ const loadingKey = enqueueSnackbar(localization.exportInProgress, {
2155
+ variant: 'info',
2156
+ persist: true,
2157
+ });
2158
+ try {
2159
+ yield executeExport({ table, rowsToExport: [row] });
2160
+ closeSnackbar(loadingKey);
2161
+ enqueueSnackbar(localization.exportSuccess, { variant: 'success' });
2162
+ }
2163
+ catch (_b) {
2164
+ closeSnackbar(loadingKey);
2165
+ enqueueSnackbar(localization.exportError, { variant: 'error' });
2166
+ }
2167
+ });
2168
+ // Row print: same guard + notification pattern as download, but calls defaultOnPrint.
2169
+ const handleSingleRowPrint = (_a) => __awaiter(void 0, [_a], void 0, function* ({ table, row, }) {
2170
+ const { localization } = table.options;
2171
+ if (!hasActiveExports(table)) {
2172
+ enqueueSnackbar(localization.exportNoExportsSelected, {
2173
+ variant: 'warning',
2174
+ });
2175
+ return;
2176
+ }
2177
+ const loadingKey = enqueueSnackbar(localization.exportInProgress, {
2178
+ variant: 'info',
2179
+ persist: true,
2180
+ });
2181
+ try {
2182
+ yield defaultOnPrint({ table, rowsToExport: [row] });
2183
+ closeSnackbar(loadingKey);
2184
+ enqueueSnackbar(localization.exportSuccess, { variant: 'success' });
2185
+ }
2186
+ catch (_b) {
2187
+ closeSnackbar(loadingKey);
2188
+ enqueueSnackbar(localization.exportError, { variant: 'error' });
2189
+ }
2190
+ });
2191
+ // Resolves selected rows from table state for toolbar-triggered export (custom renderToolbar only).
2192
+ const handleMultipleRowExport = ({ table, }) => {
2193
+ const rowsToExport = table.getSelectedRowModel().rows;
2194
+ return executeExport({ table, rowsToExport });
2195
+ };
2196
+ const createRowExportExecutor = (context) => () => {
2197
+ void handleSingleRowExport(context);
2198
+ };
2199
+ const createRowPrintExecutor = (context) => () => {
2200
+ void handleSingleRowPrint(context);
2201
+ };
2202
+ const createToolbarExportExecutor = (context) => () => {
2203
+ void handleMultipleRowExport(context);
2204
+ };
2205
+ // Renders download + optional print button. Print is shown under the same conditions
2206
+ // as in MRT_ExportsToolbar: pdf format selected, active exports, grouped or single type.
2207
+ const renderRowAction = (context) => {
2208
+ const onRowExport = createRowExportExecutor(context);
2209
+ const onRowPrint = isPrintAvailable(context.table)
2210
+ ? createRowPrintExecutor(context)
2211
+ : undefined;
2212
+ if (customRenderRow) {
2213
+ return customRenderRow(Object.assign(Object.assign({}, context), { onExport: onRowExport }));
2214
+ }
2215
+ return jsx(ExportRowAction, { onExport: onRowExport, onPrint: onRowPrint });
2216
+ };
2217
+ // Uses custom toolbar renderer when provided; otherwise renders MRT_ExportsToolbar.
2218
+ // loadExport is always wrapped with notifications so that loading/success/error are shown
2219
+ // regardless of whether a custom onExport handler was provided.
2220
+ // When onExport is provided, it intercepts the call and returns [] so MRT_ExportsToolbar
2221
+ // does not attempt a second download from an empty response.
2222
+ const renderToolbarAction = (context) => {
2223
+ const { table } = context;
2224
+ const { availableExports, loadExport, onActiveExportsChange, localization, } = table.options;
2225
+ const { activeExports } = table.getState();
2226
+ if (customRenderToolbar) {
2227
+ return customRenderToolbar(Object.assign(Object.assign({}, context), { onExport: createToolbarExportExecutor(context) }));
2228
+ }
2229
+ if (!availableExports ||
2230
+ !loadExport ||
2231
+ !onActiveExportsChange ||
2232
+ !activeExports) {
2233
+ return null;
2234
+ }
2235
+ const notifiedLoadExport = (params) => __awaiter(void 0, void 0, void 0, function* () {
2236
+ const loadingKey = enqueueSnackbar(localization.exportInProgress, {
2237
+ variant: 'info',
2238
+ persist: true,
2239
+ });
2240
+ try {
2241
+ let response;
2242
+ if (onExport) {
2243
+ const rowsToExport = table.getSelectedRowModel().rows;
2244
+ yield executeExport({ table, rowsToExport });
2245
+ response = [];
2246
+ }
2247
+ else {
2248
+ response = yield loadExport(params);
2249
+ }
2250
+ closeSnackbar(loadingKey);
2251
+ enqueueSnackbar(localization.exportSuccess, { variant: 'success' });
2252
+ return response;
2253
+ }
2254
+ catch (_a) {
2255
+ closeSnackbar(loadingKey);
2256
+ enqueueSnackbar(localization.exportError, { variant: 'error' });
2257
+ return [];
2258
+ }
2259
+ });
2260
+ return (jsx(MRT_ExportsToolbar, { table: table, availableExports: availableExports, exportState: activeExports, onExportStateChange: onActiveExportsChange, loadExport: notifiedLoadExport }));
2261
+ };
2262
+ return Object.assign({ name: 'export', renderRow: renderRowAction, renderToolbar: renderToolbarAction }, rest);
2263
+ };
2264
+
1927
2265
  const MRT_DefaultColumn = {
1928
2266
  filterVariant: 'text',
1929
2267
  maxSize: 1000,
@@ -1946,8 +2284,18 @@ const MRT_DefaultDisplayColumn = {
1946
2284
  };
1947
2285
  const useMRT_TableOptions = (_a) => {
1948
2286
  var _b;
1949
- 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 = 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"]);
2287
+ 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 = 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"]);
1950
2288
  const theme = useTheme();
2289
+ // When availableExports is configured and the user has not supplied their own
2290
+ // 'export' action, inject the default export action automatically.
2291
+ const effectiveActions = useMemo(() => {
2292
+ if (!availableExports)
2293
+ return actions;
2294
+ const hasUserExportAction = actions === null || actions === void 0 ? void 0 : actions.some((a) => a.name === 'export');
2295
+ if (hasUserExportAction)
2296
+ return actions;
2297
+ return [createExportAction(), ...(actions !== null && actions !== void 0 ? actions : [])];
2298
+ }, [actions, availableExports]);
1951
2299
  icons = useMemo(() => (Object.assign(Object.assign({}, MRT_Default_Icons), icons)), [icons]);
1952
2300
  localization = useMemo(() => (Object.assign(Object.assign({}, MRT_Localization_EN), localization)), [localization]);
1953
2301
  mrtTheme = useMemo(() => getMRTTheme(mrtTheme, theme), [mrtTheme, theme]);
@@ -2051,7 +2399,7 @@ const useMRT_TableOptions = (_a) => {
2051
2399
  rowPinningDisplayMode,
2052
2400
  selectAllMode,
2053
2401
  sortingFns,
2054
- enableAdvancedFilters }, rest);
2402
+ enableAdvancedFilters, actions: effectiveActions, availableExports }, rest);
2055
2403
  };
2056
2404
 
2057
2405
  const blankColProps = {
@@ -2072,8 +2420,7 @@ const getMRT_RowSpacerColumnDef = (tableOptions) => {
2072
2420
 
2073
2421
  const useMRT_Effects = (table) => {
2074
2422
  const { getIsSomeRowsPinned, getPrePaginationRowModel, getState, options: { enablePagination, enableRowPinning, rowCount }, } = table;
2075
- const { columnOrder, density, globalFilter, isLoading, pagination, showSkeletons, sorting, } = getState();
2076
- const totalColumnCount = table.options.columns.length;
2423
+ const { density, globalFilter, isLoading, pagination, showSkeletons, sorting, } = getState();
2077
2424
  const totalRowCount = rowCount !== null && rowCount !== void 0 ? rowCount : getPrePaginationRowModel().rows.length;
2078
2425
  const rerender = useReducer(() => ({}), {})[1];
2079
2426
  const initialBodyHeight = useRef(null);
@@ -2082,12 +2429,6 @@ const useMRT_Effects = (table) => {
2082
2429
  initialBodyHeight.current = document.body.style.height;
2083
2430
  }
2084
2431
  }, []);
2085
- //recalculate column order when columns change or features are toggled on/off
2086
- useEffect(() => {
2087
- if (totalColumnCount !== columnOrder.length) {
2088
- table.setColumnOrder(getDefaultColumnOrderIds(table.options));
2089
- }
2090
- }, [totalColumnCount]);
2091
2432
  //if page index is out of bounds, set it to the last page
2092
2433
  useEffect(() => {
2093
2434
  if (!enablePagination || isLoading || showSkeletons)
@@ -4704,61 +5045,267 @@ const MRT_AdvancedFilters = ({ table, }) => {
4704
5045
  return jsx(MRT_AdvancedFiltersContent, { table: table });
4705
5046
  };
4706
5047
 
4707
- function RowActionsCell({ row, table, }) {
4708
- const { actions } = table.options;
4709
- return (jsx(Box, { children: actions === null || actions === void 0 ? void 0 : actions.map((action) => {
4710
- var _a;
4711
- return (jsx(Fragment$1, { children: (_a = action.renderRow) === null || _a === void 0 ? void 0 : _a.call(action, { row, table }) }, action.name));
4712
- }) }));
4713
- }
4714
-
4715
- const MRT_ActiveFilterItem = ({ table, rule, }) => {
4716
- var _a;
4717
- const column = getFilterColumn(table, rule.columnId);
4718
- if (!column ||
4719
- column.columnDef.type === 'actions' ||
4720
- column.columnDef.type === 'object') {
4721
- return null;
4722
- }
4723
- const columnType = column.columnDef.type;
4724
- const resolver = columnType && columnTypeResolvers[columnType];
4725
- return (jsx(Box, { "data-testid": "active-filter-item", sx: {
4726
- display: 'flex',
4727
- gap: 1,
4728
- }, children: (_a = resolver === null || resolver === void 0 ? void 0 : resolver.activeFilterRenderer) === null || _a === void 0 ? void 0 : _a.call(resolver, table, rule) }));
4729
- };
4730
-
4731
- const MRT_ActiveFilters = ({ table, }) => {
4732
- const { getState } = table;
4733
- const { filters } = getState();
4734
- const hasFilters = filters.rules.length > 0;
4735
- if (!hasFilters)
4736
- return null;
4737
- return (jsx(Stack, { "data-testid": "active-filters-container", gap: 1, direction: "row", p: 1, sx: {
4738
- borderBottom: (theme) => `1px solid ${theme.palette.divider}`,
4739
- }, children: filters.rules.map((rule) => (jsx(MRT_ActiveFilterItem, { table: table, rule: rule }, rule.id))) }));
4740
- };
4741
-
4742
- const MRT_LinearProgressBar = (_a) => {
4743
- var { isTopToolbar, table } = _a, rest = __rest(_a, ["isTopToolbar", "table"]);
4744
- const { getState, options: { muiLinearProgressProps }, } = table;
4745
- const { isSaving, showProgressBars } = getState();
4746
- const linearProgressProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiLinearProgressProps, {
4747
- isTopToolbar,
4748
- table,
4749
- })), rest);
4750
- return (jsx(Collapse, { in: showProgressBars !== false && (showProgressBars || isSaving), mountOnEnter: true, sx: {
4751
- bottom: isTopToolbar ? 0 : undefined,
4752
- position: 'absolute',
4753
- top: !isTopToolbar ? 0 : undefined,
4754
- width: '100%',
4755
- }, unmountOnExit: true, children: jsx(LinearProgress, Object.assign({ "aria-busy": "true", "aria-label": "Loading", sx: { position: 'relative' } }, linearProgressProps)) }));
4756
- };
4757
-
4758
- /**
4759
- * Displays the number of currently selected rows.
4760
- *
4761
- * Responsibilities:
5048
+ const MRT_Localization_HR = {
5049
+ language: 'hr',
5050
+ actions: 'Radnje',
5051
+ and: 'i',
5052
+ booleanFalse: 'Ne',
5053
+ booleanTrue: 'Da',
5054
+ cancel: 'Odustani',
5055
+ close: 'Zatvori',
5056
+ changeFilterMode: 'Promijeni način filtriranja',
5057
+ changeSearchMode: 'Promijeni način pretraživanja',
5058
+ clearFilter: 'Očisti filtriranje',
5059
+ clearSearch: 'Očisti pretragu',
5060
+ clearSelection: 'Očisti odabir',
5061
+ clearSort: 'Očisti sortiranje',
5062
+ deselectAllOnAllPages: 'Poništi odabir na svim stranicama',
5063
+ deselectAllOnCurrentPage: 'Poništi odabir na trenutnoj stranici',
5064
+ clickToCopy: 'Klikni za kopiranje',
5065
+ copy: 'Kopiraj',
5066
+ collapse: 'Sažmi',
5067
+ collapseAll: 'Sažmi sve',
5068
+ columnActions: 'Radnje s stupcima',
5069
+ columns: 'Kolone',
5070
+ copiedToClipboard: 'Kopirano u međuspremnik',
5071
+ dropToGroupBy: 'Ispusti za grupiranje po {column}',
5072
+ edit: 'Uredi',
5073
+ expand: 'Proširi',
5074
+ expandAll: 'Proširi sve',
5075
+ filterArrIncludes: 'Uključuje',
5076
+ filterArrIncludesAll: 'Uključuje sve',
5077
+ filterArrIncludesSome: 'Uključuje',
5078
+ filterBetween: 'Između',
5079
+ filterBetweenInclusive: 'Između uključivo',
5080
+ filterByColumn: 'Filtriraj po {column}',
5081
+ filterFrom: 'Od',
5082
+ filterTo: 'Do',
5083
+ filterContains: 'Sadrži',
5084
+ filterEmpty: 'Prazno',
5085
+ filterEndsWith: 'Završava s',
5086
+ filterEquals: 'Jednako',
5087
+ filterEqualsString: 'Jednako',
5088
+ filterFuzzy: 'Maglovito',
5089
+ filterGreaterThan: 'Veće od',
5090
+ filterGreaterThanOrEqualTo: 'Veće od ili jednako',
5091
+ filterInArray: 'Je jedno od',
5092
+ filterIsAnyOf: 'Je jedno od',
5093
+ filterInNumberRange: 'Između',
5094
+ filterIncludesString: 'Sadrži',
5095
+ filterIncludesStringSensitive: 'Sadrži',
5096
+ filterLessThan: 'Manje od',
5097
+ filterLessThanOrEqualTo: 'Manje od ili jednako',
5098
+ filterMode: 'Način filtriranja: {filterType}',
5099
+ filterNoOptions: 'Nema dostupnih opcija za filtriranje',
5100
+ filterNotEmpty: 'Nije prazno',
5101
+ filterNotEquals: 'Nije jednako',
5102
+ filterNotContains: 'Ne sadrži',
5103
+ filterLogic: 'Logika',
5104
+ filterOperator: 'Operator',
5105
+ filterStartsWith: 'Počinje s',
5106
+ filterWeakEquals: 'Jednako',
5107
+ filterCurrentWeek: 'Trenutni tjedan',
5108
+ filterCurrentMonth: 'Trenutni mjesec',
5109
+ filterLast7Days: 'Zadnjih 7 dana',
5110
+ filterLastWeek: 'Prošli tjedan',
5111
+ filterLastMonth: 'Prošli mjesec',
5112
+ filterFromToday: 'Od danas',
5113
+ filterToToday: 'Do danas',
5114
+ filteringByColumn: 'Filtriranje po {column} - {filterType} {filterValue}',
5115
+ goToFirstPage: 'Idi na prvu stranicu',
5116
+ goToLastPage: 'Idi na zadnju stranicu',
5117
+ goToNextPage: 'Idi na sljedeću stranicu',
5118
+ goToPreviousPage: 'Idi na prethodnu stranicu',
5119
+ grab: 'Uhvati',
5120
+ groupByColumn: 'Grupiraj po {column}',
5121
+ groupedBy: 'Grupirano po ',
5122
+ hideAll: 'Sakrij sve',
5123
+ hideColumn: 'Sakrij stupac {column}',
5124
+ max: 'Maks.',
5125
+ min: 'Min.',
5126
+ move: 'Premjesti',
5127
+ noRecordsToDisplay: 'Nema zapisa za prikaz',
5128
+ noResultsFound: 'Nema pronađenih rezultata',
5129
+ moreThan: 'više od',
5130
+ of: 'od',
5131
+ or: 'ili',
5132
+ pin: 'Prikači',
5133
+ pinToLeft: 'Prikači na lijevo',
5134
+ pinToRight: 'Prikači na desno',
5135
+ resetColumnSize: 'Resetiraj veličinu stupca',
5136
+ resetOrder: 'Resetiraj redoslijed',
5137
+ rowActions: 'Radnje retka',
5138
+ rowNumber: '#',
5139
+ countRows: 'Izbroji redove',
5140
+ countRowsTooltip: 'Izbroji ukupan broj redova za trenutne filtere',
5141
+ rowCount: 'Broj redova',
5142
+ rowNumbers: 'Brojevi redaka',
5143
+ rowsPerPage: 'Redaka po stranici',
5144
+ rowsSelected: '{count} odabranih redova',
5145
+ save: 'Spremi',
5146
+ search: 'Pretraži',
5147
+ selectedCountOfRowCountRowsSelected: '{selectedCount} od {rowCount} odabranih redaka',
5148
+ select: 'Odaberi',
5149
+ selectAllOnAllPages: 'Odaberi sve na svim stranicama',
5150
+ selectAllOnCurrentPage: 'Odaberi sve na trenutnoj stranici',
5151
+ showAll: 'Prikaži sve',
5152
+ showAllColumns: 'Prikaži sve stupce',
5153
+ showHideColumns: 'Kolone',
5154
+ showHideFilters: 'Prikaži/sakrij filtere',
5155
+ showHideSearch: 'Prikaži/sakrij pretragu',
5156
+ showAdvancedFilters: 'Prikaži napredne filtere',
5157
+ advancedFilters: 'Napredni filteri',
5158
+ filters: 'Filteri',
5159
+ add: 'Dodaj',
5160
+ newEntry: 'Novi unos',
5161
+ clear: 'Očisti',
5162
+ discardChanges: 'Odbaci izmjene',
5163
+ saveFilters: 'Spremi filtere',
5164
+ savedFilters: 'Spremljeni filteri',
5165
+ noSavedFilters: 'Nema spremljenih filtera',
5166
+ filterName: 'Naziv filtera',
5167
+ apply: 'Primijeni',
5168
+ sortByColumnAsc: 'Sortiraj po {column} uzlazno',
5169
+ sortByColumnDesc: 'Sortiraj po {column} silazno',
5170
+ sortedByColumnAsc: 'Sortirano po {column} uzlazno',
5171
+ sortedByColumnDesc: 'Sortirano po {column} silazno',
5172
+ thenBy: ', zatim po ',
5173
+ toggleDensity: 'Gustoća',
5174
+ densityCompact: 'Kompaktan',
5175
+ densityStandard: 'Standard',
5176
+ densityComfortable: 'Udobno',
5177
+ toggleFullScreen: 'Prebaci u puni zaslon',
5178
+ toggleSelectAll: 'Prebaci odabir svih',
5179
+ toggleSelectRow: 'Prebaci odabir retka',
5180
+ toggleVisibility: 'Prebaci vidljivost',
5181
+ ungroupByColumn: 'Razgrupiraj po {column}',
5182
+ unpin: 'Odkači',
5183
+ unpinAll: 'Odkači sve',
5184
+ dimensionRotationEnabled: 'Rotacija ukljucena',
5185
+ dimensionRotationDisabled: 'Rotacija iskljucena',
5186
+ length: 'Dužina',
5187
+ width: 'Širina',
5188
+ height: 'Visina',
5189
+ depth: 'Dubina',
5190
+ tolerance: 'Tolerancija',
5191
+ exportButton: 'Izvoz',
5192
+ exportSelectRowsTooltip: 'Odaberite redove za izvoz',
5193
+ exportPrintPdf: 'Ispis PDF',
5194
+ exportDownload: 'Preuzmi',
5195
+ exportGrouped: 'Grupirati datoteke',
5196
+ exportInProgress: 'Izvoz u toku...',
5197
+ exportSuccess: 'Izvoz je uspješno završen.',
5198
+ exportError: 'Izvoz nije uspio. Pokušajte ponovo.',
5199
+ exportNoExportsSelected: 'Nije odabran tip izvoza. Molimo odaberite izvoz iz gornje trake.',
5200
+ deleteConfirmationTitle: 'Brisanje reda',
5201
+ deleteConfirmationMessage: 'Da li ste sigurni da želite izbrisati ovaj red?',
5202
+ deleteConfirmYes: 'Izbriši',
5203
+ deleteConfirmNo: 'Odustani',
5204
+ deleteConfirmDeleting: 'Brisanje...',
5205
+ errorTitle: 'Neočekivana greška',
5206
+ errorMessage: 'Došlo je do neočekivane pogreške. Pokušajte ponovno.',
5207
+ serverTableErrorTitle: 'Učitavanje tablice nije uspjelo',
5208
+ serverTableErrorMessage: 'Došlo je do pogreške prilikom učitavanja konfiguracije tablice. Pokušajte ponovno.',
5209
+ serverTableErrorRetry: 'Pokušaj ponovno',
5210
+ resetState: 'Resetuj stanje',
5211
+ tableOptions: 'Opcije',
5212
+ };
5213
+
5214
+ const MaterialReactServerTableError = ({ description, localization = MRT_Localization_HR, title, }) => (jsxs(Paper, { "data-testid": "server-table-error", sx: {
5215
+ alignItems: 'center',
5216
+ display: 'flex',
5217
+ flexDirection: 'column',
5218
+ gap: '1rem',
5219
+ height: '100%',
5220
+ justifyContent: 'center',
5221
+ minHeight: '12rem',
5222
+ px: '2rem',
5223
+ py: '3rem',
5224
+ textAlign: 'center',
5225
+ }, children: [jsx(Box, { sx: (theme) => ({
5226
+ alignItems: 'center',
5227
+ backgroundColor: theme.palette.error.main + '14',
5228
+ borderRadius: '50%',
5229
+ color: theme.palette.error.main,
5230
+ display: 'flex',
5231
+ height: '4rem',
5232
+ justifyContent: 'center',
5233
+ width: '4rem',
5234
+ }), children: jsx(ErrorOutlineRoundedIcon, { sx: { fontSize: '2.25rem' } }) }), jsxs(Box, { sx: { display: 'flex', flexDirection: 'column', gap: '0.35rem' }, children: [jsx(Typography, { fontWeight: 600, variant: "h6", children: title !== null && title !== void 0 ? title : localization.errorTitle }), jsx(Typography, { color: "text.secondary", sx: { maxWidth: '28rem' }, variant: "body2", children: description !== null && description !== void 0 ? description : localization.errorMessage })] })] }));
5235
+
5236
+ function RowActionsCell({ row, table, }) {
5237
+ const { actions } = table.options;
5238
+ return (jsx(Box, { children: actions === null || actions === void 0 ? void 0 : actions.map((action) => {
5239
+ var _a;
5240
+ return (jsx(Fragment$1, { children: (_a = action.renderRow) === null || _a === void 0 ? void 0 : _a.call(action, { row, table }) }, action.name));
5241
+ }) }));
5242
+ }
5243
+
5244
+ // Detects whether a real SnackbarProvider exists in the tree.
5245
+ // In notistack's default context both enqueueSnackbar and closeSnackbar point to
5246
+ // the same no-op reference. A real provider binds them to different functions.
5247
+ const useHasSnackbarProvider = () => {
5248
+ const { enqueueSnackbar, closeSnackbar } = useSnackbar();
5249
+ return enqueueSnackbar !== closeSnackbar;
5250
+ };
5251
+ const Inner = ({ children }) => {
5252
+ const hasProvider = useHasSnackbarProvider();
5253
+ if (hasProvider)
5254
+ return jsx(Fragment, { children: children });
5255
+ return (jsx(SnackbarProvider, { maxSnack: 5, anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, children: children }));
5256
+ };
5257
+ // Wraps children with SnackbarProvider only when no provider exists in the tree.
5258
+ // When the user's app already has a SnackbarProvider, notifications from MRT
5259
+ // will appear there — inheriting its position and styling.
5260
+ const MaybeSnackbarProvider = ({ children, }) => jsx(Inner, { children: children });
5261
+
5262
+ const MRT_ActiveFilterItem = ({ table, rule, }) => {
5263
+ var _a;
5264
+ const column = getFilterColumn(table, rule.columnId);
5265
+ if (!column ||
5266
+ column.columnDef.type === 'actions' ||
5267
+ column.columnDef.type === 'object') {
5268
+ return null;
5269
+ }
5270
+ const columnType = column.columnDef.type;
5271
+ const resolver = columnType && columnTypeResolvers[columnType];
5272
+ return (jsx(Box, { "data-testid": "active-filter-item", sx: {
5273
+ display: 'flex',
5274
+ gap: 1,
5275
+ }, children: (_a = resolver === null || resolver === void 0 ? void 0 : resolver.activeFilterRenderer) === null || _a === void 0 ? void 0 : _a.call(resolver, table, rule) }));
5276
+ };
5277
+
5278
+ const MRT_ActiveFilters = ({ table, }) => {
5279
+ const { getState } = table;
5280
+ const { filters } = getState();
5281
+ const hasFilters = filters.rules.length > 0;
5282
+ if (!hasFilters)
5283
+ return null;
5284
+ return (jsx(Stack, { "data-testid": "active-filters-container", gap: 1, direction: "row", p: 1, sx: {
5285
+ borderBottom: (theme) => `1px solid ${theme.palette.divider}`,
5286
+ }, children: filters.rules.map((rule) => (jsx(MRT_ActiveFilterItem, { table: table, rule: rule }, rule.id))) }));
5287
+ };
5288
+
5289
+ const MRT_LinearProgressBar = (_a) => {
5290
+ var { isTopToolbar, table } = _a, rest = __rest(_a, ["isTopToolbar", "table"]);
5291
+ const { getState, options: { muiLinearProgressProps }, } = table;
5292
+ const { isSaving, showProgressBars } = getState();
5293
+ const linearProgressProps = Object.assign(Object.assign({}, parseFromValuesOrFunc(muiLinearProgressProps, {
5294
+ isTopToolbar,
5295
+ table,
5296
+ })), rest);
5297
+ return (jsx(Collapse, { in: showProgressBars !== false && (showProgressBars || isSaving), mountOnEnter: true, sx: {
5298
+ bottom: isTopToolbar ? 0 : undefined,
5299
+ position: 'absolute',
5300
+ top: !isTopToolbar ? 0 : undefined,
5301
+ width: '100%',
5302
+ }, unmountOnExit: true, children: jsx(LinearProgress, Object.assign({ "aria-busy": "true", "aria-label": "Loading", sx: { position: 'relative' } }, linearProgressProps)) }));
5303
+ };
5304
+
5305
+ /**
5306
+ * Displays the number of currently selected rows.
5307
+ *
5308
+ * Responsibilities:
4762
5309
  * - Compute the selected row count from `rowSelection` state (server-side
4763
5310
  * compatible — counts truthy values in the map directly).
4764
5311
  * - Render an accessible label using the `rowsSelected` localization string.
@@ -5598,191 +6145,103 @@ const MRT_ToggleAdvancedFiltersButton = (_a) => {
5598
6145
  return (jsx(MRT_AdvancedFiltersProvider, { initialOpen: initialOpen, setterRef: table._showAdvancedFiltersSetterRef, children: jsx(MRT_ToggleAdvancedFiltersButtonInner, Object.assign({ table: table }, rest)) }));
5599
6146
  };
5600
6147
 
5601
- const MRT_ToggleDensePaddingButton = (_a) => {
5602
- var _b;
5603
- var { table } = _a, rest = __rest(_a, ["table"]);
5604
- const { getState, options: { icons: { DensityLargeIcon, DensityMediumIcon, DensitySmallIcon }, localization, }, setDensity, } = table;
5605
- const { density } = getState();
5606
- const handleToggleDensePadding = () => {
5607
- const nextDensity = density === 'comfortable'
5608
- ? 'compact'
5609
- : density === 'compact'
5610
- ? 'spacious'
5611
- : 'comfortable';
5612
- setDensity(nextDensity);
5613
- };
5614
- const DensityIcon = density === 'compact'
5615
- ? DensitySmallIcon
5616
- : density === 'comfortable'
5617
- ? DensityMediumIcon
5618
- : DensityLargeIcon;
5619
- return (jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.toggleDensity, children: jsx(Button, Object.assign({ "aria-label": localization.toggleDensity, onClick: handleToggleDensePadding, size: "small", startIcon: jsx(DensityIcon, { fontSize: "small" }), variant: "text" }, rest, { title: undefined, children: localization.toggleDensity })) }));
5620
- };
5621
-
5622
- const MRT_ToggleFiltersButton = (_a) => {
5623
- var _b;
5624
- var { table } = _a, rest = __rest(_a, ["table"]);
5625
- const { getState, options: { icons: { FilterListIcon, FilterListOffIcon }, localization, }, setShowColumnFilters, } = table;
5626
- const { showColumnFilters } = getState();
5627
- const handleToggleShowFilters = () => {
5628
- setShowColumnFilters(!showColumnFilters);
5629
- };
5630
- return (jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideFilters, children: jsx(IconButton, Object.assign({ "aria-label": localization.showHideFilters, onClick: handleToggleShowFilters }, rest, { title: undefined, children: showColumnFilters ? jsx(FilterListOffIcon, {}) : jsx(FilterListIcon, {}) })) }));
5631
- };
5632
-
5633
- const MRT_ToggleGlobalFilterButton = (_a) => {
5634
- var _b, _c;
5635
- var { table } = _a, rest = __rest(_a, ["table"]);
5636
- const { getState, options: { icons: { SearchIcon, SearchOffIcon }, localization, }, refs: { searchInputRef }, setShowGlobalFilter, } = table;
5637
- const { globalFilter, showGlobalFilter } = getState();
5638
- const handleToggleSearch = () => {
5639
- setShowGlobalFilter(!showGlobalFilter);
5640
- queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
5641
- };
5642
- return (jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideSearch, children: jsx("span", { children: 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 ? jsx(SearchOffIcon, {}) : jsx(SearchIcon, {}) })) }) }));
5643
- };
5644
-
5645
- const downloadExportFiles = (files) => {
5646
- files.forEach((file) => {
5647
- const binaryString = atob(file.content);
5648
- const len = binaryString.length;
5649
- const bytes = new Uint8Array(len);
5650
- for (let i = 0; i < len; i++) {
5651
- bytes[i] = binaryString.charCodeAt(i);
5652
- }
5653
- const blob = new Blob([bytes], { type: 'application/octet-stream' });
5654
- const element = document.createElement('a');
5655
- element.href = URL.createObjectURL(blob);
5656
- element.download = file.filename;
5657
- document.body.appendChild(element);
5658
- element.click();
5659
- document.body.removeChild(element);
5660
- URL.revokeObjectURL(element.href);
5661
- });
5662
- };
5663
-
5664
- const printExportFiles = (files) => {
5665
- files.forEach((file) => {
5666
- const binaryString = atob(file.content);
5667
- const len = binaryString.length;
5668
- const bytes = new Uint8Array(len);
5669
- for (let i = 0; i < len; i++) {
5670
- bytes[i] = binaryString.charCodeAt(i);
5671
- }
5672
- const blob = new Blob([bytes], { type: 'application/pdf' });
5673
- const url = URL.createObjectURL(blob);
5674
- printJS({
5675
- printable: url,
5676
- type: 'pdf',
5677
- onLoadingEnd: () => URL.revokeObjectURL(url),
5678
- });
5679
- });
5680
- };
5681
-
5682
- const MRT_ExportsToolbar = ({ table, availableExports, exportState, onExportStateChange, loadExport, }) => {
5683
- const theme = useTheme();
5684
- const { localization } = table.options;
5685
- const { selectedExports, selectedFormat, grouped } = exportState;
5686
- const [anchorEl, setAnchorEl] = useState(null);
5687
- const [loadingExportType, setLoadingExportType] = useState(null);
5688
- const { rowSelection } = table.getState();
5689
- const selectedRowIds = Object.keys(rowSelection).filter((id) => rowSelection[id]);
5690
- const isNoRowsSelected = selectedRowIds.length === 0;
5691
- const availableFormats = useMemo(() => {
5692
- const allFormats = Object.values(availableExports).flatMap((exp) => exp.formats);
5693
- return Array.from(new Set(allFormats));
5694
- }, [availableExports]);
5695
- const hasPdfFormat = availableFormats.includes('pdf');
5696
- const exportTypesForSelectedFormat = useMemo(() => {
5697
- if (!selectedFormat)
5698
- return [];
5699
- return Object.values(availableExports).filter((exp) => exp.formats.includes(selectedFormat));
5700
- }, [availableExports, selectedFormat]);
5701
- const isPrintDisabled = selectedFormat !== 'pdf' ||
5702
- !selectedFormat ||
5703
- selectedExports.length < 1 ||
5704
- (!grouped && selectedExports.length > 1);
5705
- const isDownloadDisabled = !selectedFormat || selectedExports.length < 1;
5706
- const handleOpenMenu = (event) => {
5707
- setAnchorEl(event.currentTarget);
5708
- };
6148
+ const getDensityOptions = ({ icons: { DensityLargeIcon, DensityMediumIcon, DensitySmallIcon }, localization, }) => [
6149
+ {
6150
+ Icon: DensitySmallIcon,
6151
+ label: localization.densityCompact,
6152
+ value: 'compact',
6153
+ },
6154
+ {
6155
+ Icon: DensityMediumIcon,
6156
+ label: localization.densityStandard,
6157
+ value: 'comfortable',
6158
+ },
6159
+ {
6160
+ Icon: DensityLargeIcon,
6161
+ label: localization.densityComfortable,
6162
+ value: 'spacious',
6163
+ },
6164
+ ];
6165
+
6166
+ const MRT_ToggleDensePaddingMenu = (_a) => {
6167
+ var { anchorEl, setAnchorEl, table } = _a, rest = __rest(_a, ["anchorEl", "setAnchorEl", "table"]);
6168
+ const { getState, options: { icons, localization }, setDensity, } = table;
6169
+ const { density } = getState();
5709
6170
  const handleCloseMenu = () => {
5710
6171
  setAnchorEl(null);
5711
6172
  };
5712
- const handleSelectFormat = (format) => {
5713
- const newFormat = selectedFormat === format ? null : format;
5714
- onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { grouped: false })), { selectedExports: [], selectedFormat: newFormat })));
5715
- };
5716
- const handleToggleExportType = (exportName) => {
5717
- const isAlreadySelected = selectedExports.includes(exportName);
5718
- const newSelectedExports = isAlreadySelected
5719
- ? selectedExports.filter((name) => name !== exportName)
5720
- : [...selectedExports, exportName];
5721
- onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { selectedFormat: null, grouped: false })), { selectedExports: newSelectedExports })));
6173
+ const handleSelectDensity = (nextDensity) => {
6174
+ setDensity(nextDensity);
6175
+ handleCloseMenu();
5722
6176
  };
5723
- const handleToggleGrouped = () => {
5724
- onExportStateChange((prev) => (Object.assign(Object.assign({}, (prev !== null && prev !== void 0 ? prev : { selectedFormat: null, selectedExports: [] })), { grouped: !grouped })));
6177
+ const densityOptions = getDensityOptions({ icons, localization });
6178
+ return (jsx(Menu, Object.assign({ id: "mrt-density-menu", anchorEl: anchorEl, open: !!anchorEl, onClose: handleCloseMenu, anchorOrigin: { vertical: 'bottom', horizontal: 'left' }, transformOrigin: { vertical: 'top', horizontal: 'left' } }, rest, { children: densityOptions.map(({ Icon, label, value }) => (jsxs(MenuItem, { onClick: () => handleSelectDensity(value), selected: density === value, sx: {
6179
+ borderRadius: '4px',
6180
+ '&.Mui-selected': {
6181
+ backgroundColor: 'action.selected',
6182
+ },
6183
+ '&.Mui-selected:hover': {
6184
+ backgroundColor: 'action.hover',
6185
+ },
6186
+ }, children: [jsx(ListItemIcon, { sx: { color: 'text.primary', marginRight: '0px' }, children: jsx(Icon, {}) }), jsx(ListItemText, { primary: label, slotProps: {
6187
+ primary: {
6188
+ fontSize: '0.875rem',
6189
+ fontWeight: 600,
6190
+ },
6191
+ } })] }, value))) })));
6192
+ };
6193
+
6194
+ const MRT_ToggleDensePaddingButton = (_a) => {
6195
+ var _b;
6196
+ var { table } = _a, rest = __rest(_a, ["table"]);
6197
+ const { getState, options: { icons: { DensityLargeIcon, DensityMediumIcon, DensitySmallIcon }, localization, }, } = table;
6198
+ const { density } = getState();
6199
+ const [anchorEl, setAnchorEl] = useState(null);
6200
+ const handleOpenMenu = (event) => {
6201
+ setAnchorEl(event.currentTarget);
5725
6202
  };
5726
- const handleExportAction = (type) => __awaiter(void 0, void 0, void 0, function* () {
5727
- setLoadingExportType(type);
5728
- try {
5729
- const response = yield loadExport({
5730
- format: selectedFormat,
5731
- exports: selectedExports,
5732
- separated_files: !grouped,
5733
- download: false,
5734
- ids: JSON.stringify(selectedRowIds),
5735
- type,
5736
- });
5737
- handleCloseMenu();
5738
- if (type === 'download') {
5739
- downloadExportFiles(response);
5740
- }
5741
- else {
5742
- printExportFiles(response);
5743
- }
5744
- }
5745
- finally {
5746
- setLoadingExportType(null);
5747
- }
5748
- });
5749
- const renderFormatSelector = () => (jsx(Stack, { justifyContent: "flex-start", minWidth: "200px", sx: {
5750
- borderRight: selectedFormat
5751
- ? `1px dashed ${theme.palette.divider}`
5752
- : 'none',
5753
- }, 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))) }) }) }));
5754
- const renderExportTypeSelector = () => {
5755
- if (!selectedFormat || exportTypesForSelectedFormat.length === 0)
5756
- return null;
5757
- 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))) }));
6203
+ const DensityIcon = density === 'compact'
6204
+ ? DensitySmallIcon
6205
+ : density === 'comfortable'
6206
+ ? DensityMediumIcon
6207
+ : DensityLargeIcon;
6208
+ return (jsxs(Fragment, { children: [jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.toggleDensity, children: jsx(Button, Object.assign({ "aria-label": localization.toggleDensity, onClick: handleOpenMenu, size: "small", startIcon: jsx(DensityIcon, { fontSize: "small" }), variant: "text" }, rest, { title: undefined, children: localization.toggleDensity })) }), anchorEl && (jsx(MRT_ToggleDensePaddingMenu, { anchorEl: anchorEl, setAnchorEl: setAnchorEl, table: table }))] }));
6209
+ };
6210
+
6211
+ const MRT_ToggleFiltersButton = (_a) => {
6212
+ var _b;
6213
+ var { table } = _a, rest = __rest(_a, ["table"]);
6214
+ const { getState, options: { icons: { FilterListIcon, FilterListOffIcon }, localization, }, setShowColumnFilters, } = table;
6215
+ const { showColumnFilters } = getState();
6216
+ const handleToggleShowFilters = () => {
6217
+ setShowColumnFilters(!showColumnFilters);
5758
6218
  };
5759
- const renderActionButtons = () => {
5760
- const isAnyLoading = loadingExportType !== null;
5761
- 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 })] }));
6219
+ return (jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideFilters, children: jsx(IconButton, Object.assign({ "aria-label": localization.showHideFilters, onClick: handleToggleShowFilters }, rest, { title: undefined, children: showColumnFilters ? jsx(FilterListOffIcon, {}) : jsx(FilterListIcon, {}) })) }));
6220
+ };
6221
+
6222
+ const MRT_ToggleGlobalFilterButton = (_a) => {
6223
+ var _b, _c;
6224
+ var { table } = _a, rest = __rest(_a, ["table"]);
6225
+ const { getState, options: { icons: { SearchIcon, SearchOffIcon }, localization, }, refs: { searchInputRef }, setShowGlobalFilter, } = table;
6226
+ const { globalFilter, showGlobalFilter } = getState();
6227
+ const handleToggleSearch = () => {
6228
+ setShowGlobalFilter(!showGlobalFilter);
6229
+ queueMicrotask(() => { var _a; return (_a = searchInputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); });
5762
6230
  };
5763
- 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 }) }) }));
5764
- return (jsxs(Stack, { direction: "row", gap: 0.5, alignItems: "center", children: [jsx(Tooltip, { title: isNoRowsSelected
5765
- ? localization.exportSelectRowsTooltip
5766
- : 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 &&
5767
- exportTypesForSelectedFormat.length > 0 &&
5768
- renderExportTypeSelector()] }), jsx(Divider, { sx: { mt: 1 } }), jsxs(Stack, { direction: "row", alignItems: "center", sx: { px: 1, pb: 1 }, children: [renderActionButtons(), renderGroupedCheckbox()] })] })] }));
6231
+ return (jsx(Tooltip, { title: (_b = rest === null || rest === void 0 ? void 0 : rest.title) !== null && _b !== void 0 ? _b : localization.showHideSearch, children: jsx("span", { children: 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 ? jsx(SearchOffIcon, {}) : jsx(SearchIcon, {}) })) }) }));
5769
6232
  };
5770
6233
 
5771
6234
  const MRT_ToolbarInternalButtons = (_a) => {
5772
6235
  var _b;
5773
6236
  var { table } = _a, rest = __rest(_a, ["table"]);
5774
- const { options: { availableExports, columnFilterDisplayMode, enableColumnFilters, enableColumnOrdering, enableColumnPinning, enableDensityToggle, enableFilters, enableGlobalFilter, enableHiding, initialState, enableAdvancedFilters, loadExport, onActiveExportsChange, renderToolbarInternalActions, enableNewEntryButton, }, } = table;
5775
- const { activeExports } = table.getState();
6237
+ const { options: { columnFilterDisplayMode, enableColumnFilters, enableColumnOrdering, enableColumnPinning, enableDensityToggle, enableFilters, enableGlobalFilter, enableHiding, initialState, enableAdvancedFilters, renderToolbarInternalActions, enableNewEntryButton, }, } = table;
5776
6238
  return (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({
5777
6239
  table,
5778
6240
  })) !== null && _b !== void 0 ? _b : (jsxs(Fragment, { children: [enableFilters &&
5779
6241
  enableGlobalFilter &&
5780
6242
  !(initialState === null || initialState === void 0 ? void 0 : initialState.showGlobalFilter) && (jsx(MRT_ToggleGlobalFilterButton, { table: table })), enableFilters &&
5781
6243
  enableColumnFilters &&
5782
- columnFilterDisplayMode !== 'popover' && (jsx(MRT_ToggleFiltersButton, { table: table })), (enableHiding || enableColumnOrdering || enableColumnPinning) && (jsx(MRT_ShowHideColumnsButton, { table: table })), enableDensityToggle && (jsx(MRT_ToggleDensePaddingButton, { table: table })), enableAdvancedFilters && (jsx(MRT_ToggleAdvancedFiltersButton, { table: table })), enableAdvancedFilters && jsx(MRT_SavedFiltersButton, { table: table }), availableExports &&
5783
- loadExport &&
5784
- onActiveExportsChange &&
5785
- activeExports && (jsx(MRT_ExportsToolbar, { table: table, availableExports: availableExports, exportState: activeExports, onExportStateChange: onActiveExportsChange, loadExport: loadExport })), enableNewEntryButton && jsx(MRT_NewEntryButton, { table: table })] })) })));
6244
+ columnFilterDisplayMode !== 'popover' && (jsx(MRT_ToggleFiltersButton, { table: table })), (enableHiding || enableColumnOrdering || enableColumnPinning) && (jsx(MRT_ShowHideColumnsButton, { table: table })), enableDensityToggle && (jsx(MRT_ToggleDensePaddingButton, { table: table })), enableAdvancedFilters && (jsx(MRT_ToggleAdvancedFiltersButton, { table: table })), enableAdvancedFilters && jsx(MRT_SavedFiltersButton, { table: table }), enableNewEntryButton && jsx(MRT_NewEntryButton, { table: table })] })) })));
5786
6245
  };
5787
6246
 
5788
6247
  function ToolbarActions({ table, }) {
@@ -7599,7 +8058,7 @@ const MaterialReactTableComponent = (props, ref) => {
7599
8058
  ? props.table
7600
8059
  : useMaterialReactTable(props);
7601
8060
  useImperativeHandle(ref, () => table, [table]);
7602
- return jsx(MRT_TablePaper, { table: table });
8061
+ return (jsx(MaybeSnackbarProvider, { children: jsx(MRT_TablePaper, { table: table }) }));
7603
8062
  };
7604
8063
  const MaterialReactTable = forwardRef(MaterialReactTableComponent);
7605
8064
 
@@ -7711,160 +8170,6 @@ const useServerTableState = ({ initialState, saveState, saveDebounceMs = 500, })
7711
8170
  };
7712
8171
  };
7713
8172
 
7714
- const MRT_Localization_HR = {
7715
- language: 'hr',
7716
- actions: 'Radnje',
7717
- and: 'i',
7718
- booleanFalse: 'Ne',
7719
- booleanTrue: 'Da',
7720
- cancel: 'Odustani',
7721
- close: 'Zatvori',
7722
- changeFilterMode: 'Promijeni način filtriranja',
7723
- changeSearchMode: 'Promijeni način pretraživanja',
7724
- clearFilter: 'Očisti filtriranje',
7725
- clearSearch: 'Očisti pretragu',
7726
- clearSelection: 'Očisti odabir',
7727
- clearSort: 'Očisti sortiranje',
7728
- deselectAllOnAllPages: 'Poništi odabir na svim stranicama',
7729
- deselectAllOnCurrentPage: 'Poništi odabir na trenutnoj stranici',
7730
- clickToCopy: 'Klikni za kopiranje',
7731
- copy: 'Kopiraj',
7732
- collapse: 'Sažmi',
7733
- collapseAll: 'Sažmi sve',
7734
- columnActions: 'Radnje s stupcima',
7735
- columns: 'Kolone',
7736
- copiedToClipboard: 'Kopirano u međuspremnik',
7737
- dropToGroupBy: 'Ispusti za grupiranje po {column}',
7738
- edit: 'Uredi',
7739
- expand: 'Proširi',
7740
- expandAll: 'Proširi sve',
7741
- filterArrIncludes: 'Uključuje',
7742
- filterArrIncludesAll: 'Uključuje sve',
7743
- filterArrIncludesSome: 'Uključuje',
7744
- filterBetween: 'Između',
7745
- filterBetweenInclusive: 'Između uključivo',
7746
- filterByColumn: 'Filtriraj po {column}',
7747
- filterFrom: 'Od',
7748
- filterTo: 'Do',
7749
- filterContains: 'Sadrži',
7750
- filterEmpty: 'Prazno',
7751
- filterEndsWith: 'Završava s',
7752
- filterEquals: 'Jednako',
7753
- filterEqualsString: 'Jednako',
7754
- filterFuzzy: 'Maglovito',
7755
- filterGreaterThan: 'Veće od',
7756
- filterGreaterThanOrEqualTo: 'Veće od ili jednako',
7757
- filterInArray: 'Je jedno od',
7758
- filterIsAnyOf: 'Je jedno od',
7759
- filterInNumberRange: 'Između',
7760
- filterIncludesString: 'Sadrži',
7761
- filterIncludesStringSensitive: 'Sadrži',
7762
- filterLessThan: 'Manje od',
7763
- filterLessThanOrEqualTo: 'Manje od ili jednako',
7764
- filterMode: 'Način filtriranja: {filterType}',
7765
- filterNoOptions: 'Nema dostupnih opcija za filtriranje',
7766
- filterNotEmpty: 'Nije prazno',
7767
- filterNotEquals: 'Nije jednako',
7768
- filterNotContains: 'Ne sadrži',
7769
- filterLogic: 'Logika',
7770
- filterOperator: 'Operator',
7771
- filterStartsWith: 'Počinje s',
7772
- filterWeakEquals: 'Jednako',
7773
- filterCurrentWeek: 'Trenutni tjedan',
7774
- filterCurrentMonth: 'Trenutni mjesec',
7775
- filterLast7Days: 'Zadnjih 7 dana',
7776
- filterLastWeek: 'Prošli tjedan',
7777
- filterLastMonth: 'Prošli mjesec',
7778
- filterFromToday: 'Od danas',
7779
- filterToToday: 'Do danas',
7780
- filteringByColumn: 'Filtriranje po {column} - {filterType} {filterValue}',
7781
- goToFirstPage: 'Idi na prvu stranicu',
7782
- goToLastPage: 'Idi na zadnju stranicu',
7783
- goToNextPage: 'Idi na sljedeću stranicu',
7784
- goToPreviousPage: 'Idi na prethodnu stranicu',
7785
- grab: 'Uhvati',
7786
- groupByColumn: 'Grupiraj po {column}',
7787
- groupedBy: 'Grupirano po ',
7788
- hideAll: 'Sakrij sve',
7789
- hideColumn: 'Sakrij stupac {column}',
7790
- max: 'Maks.',
7791
- min: 'Min.',
7792
- move: 'Premjesti',
7793
- noRecordsToDisplay: 'Nema zapisa za prikaz',
7794
- noResultsFound: 'Nema pronađenih rezultata',
7795
- moreThan: 'više od',
7796
- of: 'od',
7797
- or: 'ili',
7798
- pin: 'Prikači',
7799
- pinToLeft: 'Prikači na lijevo',
7800
- pinToRight: 'Prikači na desno',
7801
- resetColumnSize: 'Resetiraj veličinu stupca',
7802
- resetOrder: 'Resetiraj redoslijed',
7803
- rowActions: 'Radnje retka',
7804
- rowNumber: '#',
7805
- countRows: 'Izbroji redove',
7806
- countRowsTooltip: 'Izbroji ukupan broj redova za trenutne filtere',
7807
- rowCount: 'Broj redova',
7808
- rowNumbers: 'Brojevi redaka',
7809
- rowsPerPage: 'Redaka po stranici',
7810
- rowsSelected: '{count} odabranih redova',
7811
- save: 'Spremi',
7812
- search: 'Pretraži',
7813
- selectedCountOfRowCountRowsSelected: '{selectedCount} od {rowCount} odabranih redaka',
7814
- select: 'Odaberi',
7815
- selectAllOnAllPages: 'Odaberi sve na svim stranicama',
7816
- selectAllOnCurrentPage: 'Odaberi sve na trenutnoj stranici',
7817
- showAll: 'Prikaži sve',
7818
- showAllColumns: 'Prikaži sve stupce',
7819
- showHideColumns: 'Kolone',
7820
- showHideFilters: 'Prikaži/sakrij filtere',
7821
- showHideSearch: 'Prikaži/sakrij pretragu',
7822
- showAdvancedFilters: 'Prikaži napredne filtere',
7823
- advancedFilters: 'Napredni filteri',
7824
- filters: 'Filteri',
7825
- add: 'Dodaj',
7826
- newEntry: 'Novi unos',
7827
- clear: 'Očisti',
7828
- discardChanges: 'Odbaci izmjene',
7829
- saveFilters: 'Spremi filtere',
7830
- savedFilters: 'Spremljeni filteri',
7831
- noSavedFilters: 'Nema spremljenih filtera',
7832
- filterName: 'Naziv filtera',
7833
- apply: 'Primijeni',
7834
- sortByColumnAsc: 'Sortiraj po {column} uzlazno',
7835
- sortByColumnDesc: 'Sortiraj po {column} silazno',
7836
- sortedByColumnAsc: 'Sortirano po {column} uzlazno',
7837
- sortedByColumnDesc: 'Sortirano po {column} silazno',
7838
- thenBy: ', zatim po ',
7839
- toggleDensity: 'Gustoća',
7840
- toggleFullScreen: 'Prebaci u puni zaslon',
7841
- toggleSelectAll: 'Prebaci odabir svih',
7842
- toggleSelectRow: 'Prebaci odabir retka',
7843
- toggleVisibility: 'Prebaci vidljivost',
7844
- ungroupByColumn: 'Razgrupiraj po {column}',
7845
- unpin: 'Odkači',
7846
- unpinAll: 'Odkači sve',
7847
- dimensionRotationEnabled: 'Rotacija ukljucena',
7848
- dimensionRotationDisabled: 'Rotacija iskljucena',
7849
- length: 'Dužina',
7850
- width: 'Širina',
7851
- height: 'Visina',
7852
- depth: 'Dubina',
7853
- tolerance: 'Tolerancija',
7854
- exportButton: 'Izvoz',
7855
- exportSelectRowsTooltip: 'Odaberite redove za izvoz',
7856
- exportPrintPdf: 'Ispis PDF',
7857
- exportDownload: 'Preuzmi',
7858
- exportGrouped: 'Grupirati datoteke',
7859
- deleteConfirmationTitle: 'Brisanje reda',
7860
- deleteConfirmationMessage: 'Da li ste sigurni da želite izbrisati ovaj red?',
7861
- deleteConfirmYes: 'Izbriši',
7862
- deleteConfirmNo: 'Odustani',
7863
- deleteConfirmDeleting: 'Brisanje...',
7864
- resetState: 'Resetuj stanje',
7865
- tableOptions: 'Opcije',
7866
- };
7867
-
7868
8173
  function createColumnDef(column) {
7869
8174
  if (column.type === 'object' || column.type === 'actions') {
7870
8175
  return column;
@@ -7984,8 +8289,30 @@ const MaterialReactServerTableInstance = (_a) => {
7984
8289
  return jsx(MaterialReactTable, { table: table });
7985
8290
  };
7986
8291
 
8292
+ const MaterialReactServerTableSkeleton = () => (jsxs(Paper, { "data-testid": "server-table-skeleton", sx: {
8293
+ display: 'flex',
8294
+ flexDirection: 'column',
8295
+ height: '100%',
8296
+ }, children: [jsxs(Box, { sx: (theme) => ({
8297
+ alignItems: 'center',
8298
+ borderBottom: `1px solid ${theme.palette.divider}`,
8299
+ display: 'flex',
8300
+ height: '4rem',
8301
+ justifyContent: 'space-between',
8302
+ paddingLeft: '1.3rem',
8303
+ paddingRight: '0.3rem',
8304
+ }), children: [jsxs(Box, { sx: { alignItems: 'center', display: 'flex', gap: '0.5rem' }, children: [jsx(Skeleton, { animation: "wave", height: 30, variant: "rounded", width: 73 }), jsx(Skeleton, { animation: "wave", height: 30, variant: "rounded", width: 80 }), jsx(Skeleton, { animation: "wave", height: 30, variant: "rounded", width: 67 }), jsx(Skeleton, { animation: "wave", height: 30, variant: "rounded", width: 135 })] }), jsx(Box, { sx: { alignItems: 'center', display: 'flex', gap: '0.5rem' }, children: jsx(Skeleton, { animation: "wave", height: 24, variant: "circular", width: 24 }) })] }), jsx(Box, { sx: { display: 'flex', flex: 1, padding: '1.3rem' }, children: jsx(Skeleton, { animation: "wave", variant: "rounded", sx: { flex: 1, height: '100%' } }) }), jsx(Box, { sx: (theme) => ({
8305
+ alignItems: 'center',
8306
+ borderTop: `1px solid ${theme.palette.divider}`,
8307
+ display: 'flex',
8308
+ height: '3.30rem',
8309
+ justifyContent: 'flex-end',
8310
+ px: '1.3rem',
8311
+ }), children: jsxs(Box, { sx: { alignItems: 'center', display: 'flex', gap: '1rem' }, children: [jsx(Skeleton, { animation: "wave", height: 36, variant: "rounded", width: 136 }), jsx(Skeleton, { animation: "wave", height: 31, variant: "text", width: 176 }), jsx(Skeleton, { animation: "wave", height: 22, variant: "text", width: 70 }), jsx(Skeleton, { animation: "wave", height: 24, variant: "circular", width: 24 }), jsx(Skeleton, { animation: "wave", height: 24, variant: "circular", width: 24 })] }) })] }));
8312
+
7987
8313
  const MaterialReactServerTable = (_a) => {
7988
- var { loadConfig, saveState } = _a, instanceProps = __rest(_a, ["loadConfig", "saveState"]);
8314
+ var { loadConfig, saveState, localization } = _a, instanceProps = __rest(_a, ["loadConfig", "saveState", "localization"]);
8315
+ const mergedLocalization = Object.assign(Object.assign({}, MRT_Localization_HR), localization);
7989
8316
  const [configLoading, setConfigLoading] = useState(true);
7990
8317
  const [config, setConfig] = useState(null);
7991
8318
  useEffect(() => {
@@ -8014,10 +8341,10 @@ const MaterialReactServerTable = (_a) => {
8014
8341
  };
8015
8342
  }, [loadConfig]);
8016
8343
  if (configLoading) {
8017
- return jsx("div", { children: "Loading..." });
8344
+ return jsx(MaterialReactServerTableSkeleton, {});
8018
8345
  }
8019
8346
  if (!config) {
8020
- return jsx("div", { children: "Error loading table configuration." });
8347
+ return (jsx(MaterialReactServerTableError, { description: mergedLocalization.serverTableErrorMessage }));
8021
8348
  }
8022
8349
  return (jsx(MaterialReactServerTableInstance, Object.assign({ config: config, saveState: saveState }, instanceProps)));
8023
8350
  };