wcz-test 3.2.0 → 3.4.0
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 +172 -88
- package/dist/index.js +1698 -900
- package/dist/index.js.map +1 -1
- package/package.json +7 -5
package/dist/index.js
CHANGED
|
@@ -206,7 +206,7 @@ var require_react_is_development = __commonJS({
|
|
|
206
206
|
var ContextProvider = REACT_PROVIDER_TYPE;
|
|
207
207
|
var Element = REACT_ELEMENT_TYPE;
|
|
208
208
|
var ForwardRef = REACT_FORWARD_REF_TYPE;
|
|
209
|
-
var
|
|
209
|
+
var Fragment7 = REACT_FRAGMENT_TYPE;
|
|
210
210
|
var Lazy = REACT_LAZY_TYPE;
|
|
211
211
|
var Memo = REACT_MEMO_TYPE;
|
|
212
212
|
var Portal = REACT_PORTAL_TYPE;
|
|
@@ -265,7 +265,7 @@ var require_react_is_development = __commonJS({
|
|
|
265
265
|
exports.ContextProvider = ContextProvider;
|
|
266
266
|
exports.Element = Element;
|
|
267
267
|
exports.ForwardRef = ForwardRef;
|
|
268
|
-
exports.Fragment =
|
|
268
|
+
exports.Fragment = Fragment7;
|
|
269
269
|
exports.Lazy = Lazy;
|
|
270
270
|
exports.Memo = Memo;
|
|
271
271
|
exports.Portal = Portal;
|
|
@@ -1040,35 +1040,86 @@ var TypographyWithIcon = ({ startIcon, endIcon, children, sx, gutterBottom, ...p
|
|
|
1040
1040
|
] });
|
|
1041
1041
|
};
|
|
1042
1042
|
|
|
1043
|
-
// src/
|
|
1044
|
-
import {
|
|
1045
|
-
|
|
1046
|
-
// src/components/core/PageContainer.tsx
|
|
1047
|
-
import { Container } from "@mui/material";
|
|
1043
|
+
// src/components/core/PageHeader.tsx
|
|
1044
|
+
import { CardHeader, Typography as Typography2 } from "@mui/material";
|
|
1048
1045
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
1049
|
-
var
|
|
1050
|
-
return /* @__PURE__ */ jsx2(
|
|
1051
|
-
|
|
1046
|
+
var PageHeader = ({ title, action, sx }) => {
|
|
1047
|
+
return /* @__PURE__ */ jsx2(CardHeader, { title: /* @__PURE__ */ jsx2(Typography2, { variant: "h4", fontWeight: 600, children: title }), action, sx: { px: 0, ...sx } });
|
|
1048
|
+
};
|
|
1049
|
+
|
|
1050
|
+
// src/components/core/TableContainer.tsx
|
|
1051
|
+
import { Box } from "@mui/material";
|
|
1052
|
+
import { useEffect, useRef, useState } from "react";
|
|
1053
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
1054
|
+
var TableContainer = ({ children, sx, ...props }) => {
|
|
1055
|
+
const reference = useRef(null);
|
|
1056
|
+
const [height, setHeight] = useState();
|
|
1057
|
+
useEffect(() => {
|
|
1058
|
+
const element = reference.current;
|
|
1059
|
+
if (!element) return;
|
|
1060
|
+
const recompute = () => {
|
|
1061
|
+
if (!reference.current) return;
|
|
1062
|
+
const top = Math.ceil(reference.current.getBoundingClientRect().top);
|
|
1063
|
+
const avail = Math.max(0, window.innerHeight - top);
|
|
1064
|
+
setHeight(avail);
|
|
1065
|
+
};
|
|
1066
|
+
recompute();
|
|
1067
|
+
window.addEventListener("resize", recompute);
|
|
1068
|
+
const ro = new ResizeObserver(recompute);
|
|
1069
|
+
ro.observe(document.documentElement);
|
|
1070
|
+
ro.observe(document.body);
|
|
1071
|
+
ro.observe(element);
|
|
1072
|
+
return () => {
|
|
1073
|
+
window.removeEventListener("resize", recompute);
|
|
1074
|
+
ro.disconnect();
|
|
1075
|
+
};
|
|
1076
|
+
}, []);
|
|
1077
|
+
return /* @__PURE__ */ jsx3(
|
|
1078
|
+
Box,
|
|
1052
1079
|
{
|
|
1080
|
+
ref: reference,
|
|
1053
1081
|
sx: {
|
|
1054
1082
|
display: "flex",
|
|
1055
1083
|
flexDirection: "column",
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
...
|
|
1084
|
+
minHeight: 0,
|
|
1085
|
+
width: "100%",
|
|
1086
|
+
...sx
|
|
1059
1087
|
},
|
|
1088
|
+
height,
|
|
1060
1089
|
...props,
|
|
1061
|
-
children:
|
|
1090
|
+
children: /* @__PURE__ */ jsx3(Box, { sx: (theme) => ({
|
|
1091
|
+
flex: 1,
|
|
1092
|
+
minHeight: 0,
|
|
1093
|
+
height: "100%",
|
|
1094
|
+
"& .MuiDataGrid-cell--editing": {
|
|
1095
|
+
"& .MuiInputBase-root": {
|
|
1096
|
+
height: "100%"
|
|
1097
|
+
}
|
|
1098
|
+
},
|
|
1099
|
+
"& .MuiDataGrid-columnHeaderTitle": {
|
|
1100
|
+
fontWeight: 600
|
|
1101
|
+
},
|
|
1102
|
+
"& .Mui-error": {
|
|
1103
|
+
backgroundColor: theme.palette.error.main,
|
|
1104
|
+
color: theme.palette.error.contrastText
|
|
1105
|
+
},
|
|
1106
|
+
"& .MuiDataGrid-booleanCell[data-value='true']": {
|
|
1107
|
+
color: `${theme.palette.success.main} !important`
|
|
1108
|
+
},
|
|
1109
|
+
"& .MuiDataGrid-booleanCell[data-value='false']": {
|
|
1110
|
+
color: `${theme.palette.error.main} !important`
|
|
1111
|
+
}
|
|
1112
|
+
}), children })
|
|
1062
1113
|
}
|
|
1063
1114
|
);
|
|
1064
1115
|
};
|
|
1065
1116
|
|
|
1066
1117
|
// src/components/file/Dropzone.tsx
|
|
1067
1118
|
import CloudUpload from "@mui/icons-material/CloudUpload";
|
|
1068
|
-
import { Paper, Typography as
|
|
1119
|
+
import { Paper, Typography as Typography3, useTheme } from "@mui/material";
|
|
1069
1120
|
import { useDropzone } from "react-dropzone";
|
|
1070
1121
|
import { useTranslation } from "react-i18next";
|
|
1071
|
-
import { jsx as
|
|
1122
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1072
1123
|
var baseStyle = {
|
|
1073
1124
|
flex: 1,
|
|
1074
1125
|
display: "flex",
|
|
@@ -1093,15 +1144,589 @@ var Dropzone = ({ sx, ...props }) => {
|
|
|
1093
1144
|
...isDragReject ? { borderColor: theme.palette.error.main } : {}
|
|
1094
1145
|
};
|
|
1095
1146
|
return /* @__PURE__ */ jsxs2(Paper, { variant: "outlined", ...getRootProps({ style }), sx, children: [
|
|
1096
|
-
/* @__PURE__ */
|
|
1097
|
-
/* @__PURE__ */
|
|
1098
|
-
/* @__PURE__ */
|
|
1147
|
+
/* @__PURE__ */ jsx4("input", { ...getInputProps(), style: { display: "none" } }),
|
|
1148
|
+
/* @__PURE__ */ jsx4(CloudUpload, {}),
|
|
1149
|
+
/* @__PURE__ */ jsx4(Typography3, { children: t2("Layout.File.DragSomeFilesHereOrClickToSelectThem") })
|
|
1150
|
+
] });
|
|
1151
|
+
};
|
|
1152
|
+
|
|
1153
|
+
// src/components/file/FileViewer.tsx
|
|
1154
|
+
import { useState as useState5 } from "react";
|
|
1155
|
+
|
|
1156
|
+
// src/contexts/FileContext.ts
|
|
1157
|
+
import { createContext, useContext } from "react";
|
|
1158
|
+
var FileContext = createContext(null);
|
|
1159
|
+
var useFile = () => {
|
|
1160
|
+
const context = useContext(FileContext);
|
|
1161
|
+
if (!context) {
|
|
1162
|
+
throw new Error("FileViewer components must be used within FileViewer");
|
|
1163
|
+
}
|
|
1164
|
+
return context;
|
|
1165
|
+
};
|
|
1166
|
+
|
|
1167
|
+
// src/hooks/FileHooks.ts
|
|
1168
|
+
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
1169
|
+
import saveAs from "file-saver";
|
|
1170
|
+
import { useState as useState2 } from "react";
|
|
1171
|
+
import { Upload as TusUpload } from "tus-js-client";
|
|
1172
|
+
import { uuidv7 } from "uuidv7";
|
|
1173
|
+
|
|
1174
|
+
// src/components/core/AppTitle.tsx
|
|
1175
|
+
import { Chip, Stack as Stack2, Typography as Typography4 } from "@mui/material";
|
|
1176
|
+
import { useRouterState } from "@tanstack/react-router";
|
|
1177
|
+
import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1178
|
+
var AppTitle = () => {
|
|
1179
|
+
const title = useAppTitle();
|
|
1180
|
+
return /* @__PURE__ */ jsxs3(Stack2, { direction: "row", alignItems: "center", spacing: 2, flexGrow: 1, children: [
|
|
1181
|
+
/* @__PURE__ */ jsx5("img", { src: "/favicon-32x32.png", alt: "app-logo", loading: "lazy" }),
|
|
1182
|
+
/* @__PURE__ */ jsx5(Typography4, { variant: "h6", children: title }),
|
|
1183
|
+
import.meta.env.DEV && /* @__PURE__ */ jsx5(Chip, { size: "small", label: "TEST", color: "info" })
|
|
1184
|
+
] });
|
|
1185
|
+
};
|
|
1186
|
+
var useAppTitle = () => {
|
|
1187
|
+
const rootRouterState = useRouterState({ select: (s) => s.matches[0] });
|
|
1188
|
+
return rootRouterState.meta?.find((meta) => meta?.title)?.title;
|
|
1189
|
+
};
|
|
1190
|
+
|
|
1191
|
+
// src/utils/ClientUtils.ts
|
|
1192
|
+
import axios from "axios";
|
|
1193
|
+
var Platform = class {
|
|
1194
|
+
static get isAndroid() {
|
|
1195
|
+
return /android/i.test(this.userAgent);
|
|
1196
|
+
}
|
|
1197
|
+
static get isIOS() {
|
|
1198
|
+
return /iPad|iPhone|iPod/.test(this.userAgent);
|
|
1199
|
+
}
|
|
1200
|
+
static get isWindows() {
|
|
1201
|
+
return /windows/i.test(this.userAgent);
|
|
1202
|
+
}
|
|
1203
|
+
static get isMacOS() {
|
|
1204
|
+
return /Macintosh|MacIntel|MacPPC|Mac68K/.test(this.userAgent);
|
|
1205
|
+
}
|
|
1206
|
+
static get userAgent() {
|
|
1207
|
+
return typeof navigator === "undefined" ? "" : navigator.userAgent;
|
|
1208
|
+
}
|
|
1209
|
+
};
|
|
1210
|
+
var rootRouteHead = ({ title }) => () => ({
|
|
1211
|
+
meta: [
|
|
1212
|
+
{ charSet: "utf-8" },
|
|
1213
|
+
{ name: "viewport", content: "width=device-width, initial-scale=1" },
|
|
1214
|
+
{ title },
|
|
1215
|
+
{ name: "og:type", content: "website" },
|
|
1216
|
+
{ name: "og:title", content: title },
|
|
1217
|
+
{ name: "og:image", content: "/favicon-32x32.png" }
|
|
1218
|
+
],
|
|
1219
|
+
links: [
|
|
1220
|
+
{ rel: "apple-touch-icon", sizes: "180x180", href: "/apple-touch-icon.png" },
|
|
1221
|
+
{ rel: "icon", type: "image/png", sizes: "32x32", href: "/favicon-32x32.png" },
|
|
1222
|
+
{ rel: "icon", type: "image/png", sizes: "16x16", href: "/favicon-16x16.png" },
|
|
1223
|
+
{ rel: "manifest", href: "/site.webmanifest" },
|
|
1224
|
+
{ rel: "icon", href: "/favicon.ico" }
|
|
1225
|
+
]
|
|
1226
|
+
});
|
|
1227
|
+
var wczApiClient = axios.create();
|
|
1228
|
+
|
|
1229
|
+
// src/hooks/FileHooks.ts
|
|
1230
|
+
var BASE_URL = import.meta.env.VITE_FILE_API_BASE_URL;
|
|
1231
|
+
var QUERY_KEY = "Files";
|
|
1232
|
+
var HOUR = 1e3 * 60 * 60;
|
|
1233
|
+
var useGetFileMetas = (subId, options) => {
|
|
1234
|
+
const appTitle = useAppTitle();
|
|
1235
|
+
return useQuery({
|
|
1236
|
+
...options,
|
|
1237
|
+
queryKey: [QUERY_KEY, "meta", subId, appTitle],
|
|
1238
|
+
queryFn: ({ signal }) => wczApiClient.request({
|
|
1239
|
+
url: `${BASE_URL}/v1/meta?appName=${appTitle}&subId=${subId}`,
|
|
1240
|
+
method: "GET",
|
|
1241
|
+
signal
|
|
1242
|
+
}),
|
|
1243
|
+
staleTime: HOUR,
|
|
1244
|
+
gcTime: HOUR,
|
|
1245
|
+
refetchOnWindowFocus: false
|
|
1246
|
+
});
|
|
1247
|
+
};
|
|
1248
|
+
var useGetFileThumbnail = (meta, options) => {
|
|
1249
|
+
const appTitle = useAppTitle();
|
|
1250
|
+
return useQuery({
|
|
1251
|
+
...options,
|
|
1252
|
+
queryKey: [QUERY_KEY, "thumbnail", meta?.id, appTitle],
|
|
1253
|
+
queryFn: ({ signal }) => wczApiClient.request({
|
|
1254
|
+
url: `${BASE_URL}/v1/thumbnail?appName=${appTitle}&id=${meta?.id}`,
|
|
1255
|
+
method: "GET",
|
|
1256
|
+
signal,
|
|
1257
|
+
responseType: "blob"
|
|
1258
|
+
}),
|
|
1259
|
+
select: (data) => URL.createObjectURL(data),
|
|
1260
|
+
staleTime: HOUR,
|
|
1261
|
+
gcTime: HOUR,
|
|
1262
|
+
refetchOnWindowFocus: false,
|
|
1263
|
+
enabled: !!meta?.id && options?.enabled
|
|
1264
|
+
});
|
|
1265
|
+
};
|
|
1266
|
+
var useGetFile = (meta, options) => {
|
|
1267
|
+
const appTitle = useAppTitle();
|
|
1268
|
+
return useQuery({
|
|
1269
|
+
...options,
|
|
1270
|
+
queryKey: [QUERY_KEY, meta?.id, appTitle],
|
|
1271
|
+
queryFn: ({ signal }) => wczApiClient.request({
|
|
1272
|
+
url: `${BASE_URL}/v1?appName=${appTitle}&id=${meta?.id}`,
|
|
1273
|
+
method: "GET",
|
|
1274
|
+
signal,
|
|
1275
|
+
responseType: "blob"
|
|
1276
|
+
}),
|
|
1277
|
+
select: (data) => URL.createObjectURL(data),
|
|
1278
|
+
staleTime: HOUR,
|
|
1279
|
+
gcTime: HOUR,
|
|
1280
|
+
refetchOnWindowFocus: false,
|
|
1281
|
+
enabled: !!meta?.id && options?.enabled
|
|
1282
|
+
});
|
|
1283
|
+
};
|
|
1284
|
+
var useDownloadFile = (options) => {
|
|
1285
|
+
const appTitle = useAppTitle();
|
|
1286
|
+
return useMutation({
|
|
1287
|
+
...options,
|
|
1288
|
+
mutationFn: (meta) => wczApiClient.request({
|
|
1289
|
+
url: `${BASE_URL}/v1/download?appName=${appTitle}&id=${meta.id}`,
|
|
1290
|
+
method: "GET",
|
|
1291
|
+
responseType: "blob"
|
|
1292
|
+
}),
|
|
1293
|
+
onSuccess: (data, variables) => saveAs(data, `${variables.fileName}.${variables.fileExtension}`)
|
|
1294
|
+
});
|
|
1295
|
+
};
|
|
1296
|
+
var useOpenFile = (options) => {
|
|
1297
|
+
const appTitle = useAppTitle();
|
|
1298
|
+
return useMutation({
|
|
1299
|
+
...options,
|
|
1300
|
+
mutationFn: (meta) => wczApiClient.request({
|
|
1301
|
+
url: `${BASE_URL}/v1?appName=${appTitle}&id=${meta.id}`,
|
|
1302
|
+
method: "GET",
|
|
1303
|
+
responseType: "blob"
|
|
1304
|
+
}),
|
|
1305
|
+
onSuccess: (data) => {
|
|
1306
|
+
window.open(URL.createObjectURL(data));
|
|
1307
|
+
}
|
|
1308
|
+
});
|
|
1309
|
+
};
|
|
1310
|
+
var useUpdateFileMeta = (options) => {
|
|
1311
|
+
const appTitle = useAppTitle();
|
|
1312
|
+
const queryClient = useQueryClient();
|
|
1313
|
+
return useMutation({
|
|
1314
|
+
...options,
|
|
1315
|
+
mutationFn: (meta) => wczApiClient.request({
|
|
1316
|
+
url: `${BASE_URL}/v1/meta?appName=${appTitle}&id=${meta.id}`,
|
|
1317
|
+
method: "PUT",
|
|
1318
|
+
data: meta
|
|
1319
|
+
}),
|
|
1320
|
+
onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY, "meta"], exact: false })
|
|
1321
|
+
});
|
|
1322
|
+
};
|
|
1323
|
+
var useDeleteFile = (options) => {
|
|
1324
|
+
const appTitle = useAppTitle();
|
|
1325
|
+
const queryClient = useQueryClient();
|
|
1326
|
+
return useMutation({
|
|
1327
|
+
...options,
|
|
1328
|
+
mutationFn: (meta) => wczApiClient.request({
|
|
1329
|
+
url: `${BASE_URL}/v1?appName=${appTitle}&id=${meta.id}`,
|
|
1330
|
+
method: "DELETE"
|
|
1331
|
+
}),
|
|
1332
|
+
onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY, "meta"], exact: false })
|
|
1333
|
+
});
|
|
1334
|
+
};
|
|
1335
|
+
var useDeleteFiles = (options) => {
|
|
1336
|
+
const appTitle = useAppTitle();
|
|
1337
|
+
const queryClient = useQueryClient();
|
|
1338
|
+
return useMutation({
|
|
1339
|
+
...options,
|
|
1340
|
+
mutationFn: (subId) => wczApiClient.request({
|
|
1341
|
+
url: `${BASE_URL}/v1?appName=${appTitle}&subId=${subId}`,
|
|
1342
|
+
method: "DELETE"
|
|
1343
|
+
}),
|
|
1344
|
+
onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY, "meta"], exact: false })
|
|
1345
|
+
});
|
|
1346
|
+
};
|
|
1347
|
+
var useUploadFile = ({ subId, onSuccess, onError }) => {
|
|
1348
|
+
const appTitle = useAppTitle();
|
|
1349
|
+
const [progress, setProgress] = useState2(0);
|
|
1350
|
+
const queryClient = useQueryClient();
|
|
1351
|
+
const mutate = async (file) => {
|
|
1352
|
+
if (!subId) throw new Error("subId is required for file upload");
|
|
1353
|
+
if (!appTitle) throw new Error("appTitle is required for file upload");
|
|
1354
|
+
const metadata = {
|
|
1355
|
+
id: uuidv7(),
|
|
1356
|
+
appName: appTitle,
|
|
1357
|
+
subId,
|
|
1358
|
+
fileName: file.name
|
|
1359
|
+
};
|
|
1360
|
+
const upload = new TusUpload(file, {
|
|
1361
|
+
endpoint: `${BASE_URL}/v1/upload`,
|
|
1362
|
+
chunkSize: 1048576,
|
|
1363
|
+
// 1 MB
|
|
1364
|
+
metadata: {
|
|
1365
|
+
id: metadata.id,
|
|
1366
|
+
appName: metadata.appName,
|
|
1367
|
+
subId: metadata.subId,
|
|
1368
|
+
fileName: metadata.fileName,
|
|
1369
|
+
fileExtension: file.type
|
|
1370
|
+
},
|
|
1371
|
+
//headers: { "Authorization": `Bearer ${await getToken()}` }, //TODO: implement token retrieval
|
|
1372
|
+
onError: (error) => {
|
|
1373
|
+
setProgress(0);
|
|
1374
|
+
onError?.(error);
|
|
1375
|
+
},
|
|
1376
|
+
onProgress: (bytesUploaded, bytesTotal) => {
|
|
1377
|
+
setProgress(bytesUploaded / bytesTotal * 100);
|
|
1378
|
+
},
|
|
1379
|
+
onSuccess: () => {
|
|
1380
|
+
setProgress(0);
|
|
1381
|
+
queryClient.invalidateQueries({ queryKey: [QUERY_KEY, "meta", subId, appTitle], exact: false });
|
|
1382
|
+
onSuccess?.(metadata);
|
|
1383
|
+
}
|
|
1384
|
+
});
|
|
1385
|
+
const previousUploads = await upload.findPreviousUploads();
|
|
1386
|
+
if (previousUploads.length > 0) {
|
|
1387
|
+
upload.resumeFromPreviousUpload(previousUploads[0]);
|
|
1388
|
+
}
|
|
1389
|
+
upload.start();
|
|
1390
|
+
};
|
|
1391
|
+
return { mutate, progress };
|
|
1392
|
+
};
|
|
1393
|
+
|
|
1394
|
+
// src/components/file/fileViewer/FileViewerGrid.tsx
|
|
1395
|
+
import MoreVert from "@mui/icons-material/MoreVert";
|
|
1396
|
+
import { Box as Box2, IconButton, ImageListItem, ImageListItemBar, Stack as Stack3, Tooltip } from "@mui/material";
|
|
1397
|
+
import { grey } from "@mui/material/colors";
|
|
1398
|
+
import { Fragment, useEffect as useEffect3, useState as useState3 } from "react";
|
|
1399
|
+
|
|
1400
|
+
// src/components/file/fileViewer/common/ActionsMenu.tsx
|
|
1401
|
+
import Delete from "@mui/icons-material/Delete";
|
|
1402
|
+
import FileDownload from "@mui/icons-material/FileDownload";
|
|
1403
|
+
import { List, ListItemButton, ListItemIcon, ListItemText, Menu } from "@mui/material";
|
|
1404
|
+
import { useTranslation as useTranslation3 } from "react-i18next";
|
|
1405
|
+
|
|
1406
|
+
// src/hooks/DialogsHooks.tsx
|
|
1407
|
+
import Button from "@mui/material/Button";
|
|
1408
|
+
import Dialog from "@mui/material/Dialog";
|
|
1409
|
+
import DialogActions from "@mui/material/DialogActions";
|
|
1410
|
+
import DialogContent from "@mui/material/DialogContent";
|
|
1411
|
+
import DialogTitle from "@mui/material/DialogTitle";
|
|
1412
|
+
|
|
1413
|
+
// node_modules/@mui/utils/esm/useEventCallback/useEventCallback.js
|
|
1414
|
+
import * as React2 from "react";
|
|
1415
|
+
|
|
1416
|
+
// node_modules/@mui/utils/esm/useEnhancedEffect/useEnhancedEffect.js
|
|
1417
|
+
import * as React from "react";
|
|
1418
|
+
var useEnhancedEffect = typeof window !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
1419
|
+
var useEnhancedEffect_default = useEnhancedEffect;
|
|
1420
|
+
|
|
1421
|
+
// node_modules/@mui/utils/esm/useEventCallback/useEventCallback.js
|
|
1422
|
+
function useEventCallback(fn) {
|
|
1423
|
+
const ref = React2.useRef(fn);
|
|
1424
|
+
useEnhancedEffect_default(() => {
|
|
1425
|
+
ref.current = fn;
|
|
1426
|
+
});
|
|
1427
|
+
return React2.useRef((...args) => (
|
|
1428
|
+
// @ts-expect-error hide `this`
|
|
1429
|
+
(0, ref.current)(...args)
|
|
1430
|
+
)).current;
|
|
1431
|
+
}
|
|
1432
|
+
var useEventCallback_default = useEventCallback;
|
|
1433
|
+
|
|
1434
|
+
// src/hooks/DialogsHooks.tsx
|
|
1435
|
+
import { useContext as useContext2, useMemo } from "react";
|
|
1436
|
+
import { useTranslation as useTranslation2 } from "react-i18next";
|
|
1437
|
+
|
|
1438
|
+
// src/contexts/DialogsContext.ts
|
|
1439
|
+
import { createContext as createContext2 } from "react";
|
|
1440
|
+
var DialogsContext = createContext2({});
|
|
1441
|
+
|
|
1442
|
+
// src/hooks/DialogsHooks.tsx
|
|
1443
|
+
import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1444
|
+
function AlertDialog({ open, payload, onClose }) {
|
|
1445
|
+
const { t: t2 } = useTranslation2();
|
|
1446
|
+
return /* @__PURE__ */ jsxs4(Dialog, { maxWidth: "xs", fullWidth: true, open, onClose: () => onClose(), children: [
|
|
1447
|
+
/* @__PURE__ */ jsx6(DialogTitle, { children: payload.title ?? t2("Layout.Dialog.Alert") }),
|
|
1448
|
+
/* @__PURE__ */ jsx6(DialogContent, { children: payload.message }),
|
|
1449
|
+
/* @__PURE__ */ jsx6(DialogActions, { children: /* @__PURE__ */ jsx6(Button, { disabled: !open, onClick: () => onClose(), children: t2("Layout.Dialog.Confirm") }) })
|
|
1450
|
+
] });
|
|
1451
|
+
}
|
|
1452
|
+
function ConfirmDialog({ open, payload, onClose }) {
|
|
1453
|
+
const { t: t2 } = useTranslation2();
|
|
1454
|
+
return /* @__PURE__ */ jsxs4(Dialog, { maxWidth: "xs", fullWidth: true, open, onClose: () => onClose(false), children: [
|
|
1455
|
+
/* @__PURE__ */ jsx6(DialogTitle, { children: payload.title ?? t2("Layout.Dialog.Confirm") }),
|
|
1456
|
+
/* @__PURE__ */ jsx6(DialogContent, { children: payload.message }),
|
|
1457
|
+
/* @__PURE__ */ jsxs4(DialogActions, { children: [
|
|
1458
|
+
/* @__PURE__ */ jsx6(Button, { autoFocus: true, disabled: !open, onClick: () => onClose(false), children: payload.cancelText ?? t2("Layout.Dialog.Cancel") }),
|
|
1459
|
+
/* @__PURE__ */ jsx6(Button, { disabled: !open, onClick: () => onClose(true), children: t2("Layout.Dialog.Confirm") })
|
|
1460
|
+
] })
|
|
1461
|
+
] });
|
|
1462
|
+
}
|
|
1463
|
+
function useDialogs() {
|
|
1464
|
+
const { open, close } = useContext2(DialogsContext);
|
|
1465
|
+
const alert = useEventCallback_default(
|
|
1466
|
+
(message, { ...options } = {}) => open(AlertDialog, { ...options, message })
|
|
1467
|
+
);
|
|
1468
|
+
const confirm = useEventCallback_default(
|
|
1469
|
+
(message, { ...options } = {}) => open(ConfirmDialog, { ...options, message })
|
|
1470
|
+
);
|
|
1471
|
+
return useMemo(() => ({ alert, confirm, open, close }), [alert, close, confirm, open]);
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
// src/components/file/fileViewer/common/ActionsMenu.tsx
|
|
1475
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1476
|
+
var ActionsMenu = ({ meta, menu, setMenu }) => {
|
|
1477
|
+
const { t: t2 } = useTranslation3();
|
|
1478
|
+
const { fileMetas, onDelete, actions } = useFile();
|
|
1479
|
+
const { confirm } = useDialogs();
|
|
1480
|
+
const handleMenuClose = () => {
|
|
1481
|
+
setMenu(null);
|
|
1482
|
+
};
|
|
1483
|
+
const { mutate: download, isPending: isDownloading } = useDownloadFile();
|
|
1484
|
+
const { mutate: deleteFile, isPending: isDeleting } = useDeleteFile();
|
|
1485
|
+
const handleOnDownload = () => {
|
|
1486
|
+
handleMenuClose();
|
|
1487
|
+
download(meta);
|
|
1488
|
+
};
|
|
1489
|
+
const handleOnDelete = async () => {
|
|
1490
|
+
if (!await confirm(t2("Layout.File.AreYouSureYouWantToDelete", { fileName: meta.fileName })))
|
|
1491
|
+
return;
|
|
1492
|
+
deleteFile(meta);
|
|
1493
|
+
handleMenuClose();
|
|
1494
|
+
if (onDelete) {
|
|
1495
|
+
const remainingFileMetas = fileMetas.filter((m) => m.id !== meta.id);
|
|
1496
|
+
onDelete({ remainingFileMetas, deletedFileMeta: meta });
|
|
1497
|
+
}
|
|
1498
|
+
};
|
|
1499
|
+
return /* @__PURE__ */ jsx7(
|
|
1500
|
+
Menu,
|
|
1501
|
+
{
|
|
1502
|
+
open: menu !== null,
|
|
1503
|
+
onClose: handleMenuClose,
|
|
1504
|
+
anchorReference: "anchorPosition",
|
|
1505
|
+
variant: "menu",
|
|
1506
|
+
anchorPosition: menu === null ? void 0 : { top: menu.mouseY, left: menu.mouseX },
|
|
1507
|
+
children: /* @__PURE__ */ jsxs5(List, { disablePadding: true, children: [
|
|
1508
|
+
actions?.download !== false && /* @__PURE__ */ jsxs5(ListItemButton, { onClick: handleOnDownload, disabled: isDownloading, children: [
|
|
1509
|
+
/* @__PURE__ */ jsx7(ListItemIcon, { children: /* @__PURE__ */ jsx7(FileDownload, {}) }),
|
|
1510
|
+
/* @__PURE__ */ jsx7(ListItemText, { children: t2("Layout.File.Download") })
|
|
1511
|
+
] }),
|
|
1512
|
+
actions?.delete !== false && /* @__PURE__ */ jsxs5(ListItemButton, { onClick: handleOnDelete, disabled: isDeleting, children: [
|
|
1513
|
+
/* @__PURE__ */ jsx7(ListItemIcon, { children: /* @__PURE__ */ jsx7(Delete, {}) }),
|
|
1514
|
+
/* @__PURE__ */ jsx7(ListItemText, { children: t2("Layout.File.Delete") })
|
|
1515
|
+
] })
|
|
1516
|
+
] })
|
|
1517
|
+
}
|
|
1518
|
+
);
|
|
1519
|
+
};
|
|
1520
|
+
|
|
1521
|
+
// src/components/file/fileViewer/FileViewerGrid.tsx
|
|
1522
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1523
|
+
var IMAGE_SIZE = 150;
|
|
1524
|
+
var FileViewerGrid = ({ sx, size, itemBar }) => {
|
|
1525
|
+
const { fileMetas } = useFile();
|
|
1526
|
+
return /* @__PURE__ */ jsx8(Stack3, { direction: "row", spacing: 1, sx: { overflow: "auto", ...sx }, children: fileMetas.map((fileMeta) => /* @__PURE__ */ jsx8(
|
|
1527
|
+
GridFileViewerItem,
|
|
1528
|
+
{
|
|
1529
|
+
meta: fileMeta,
|
|
1530
|
+
size,
|
|
1531
|
+
itemBar
|
|
1532
|
+
},
|
|
1533
|
+
fileMeta.id
|
|
1534
|
+
)) });
|
|
1535
|
+
};
|
|
1536
|
+
var GridFileViewerItem = ({ meta, size, itemBar }) => {
|
|
1537
|
+
const { setImageId, actions } = useFile();
|
|
1538
|
+
const [showItemBar, setShowItemBar] = useState3(itemBar === "always");
|
|
1539
|
+
const [menu, setMenu] = useState3(null);
|
|
1540
|
+
useEffect3(() => {
|
|
1541
|
+
setShowItemBar(itemBar === "always");
|
|
1542
|
+
}, [itemBar]);
|
|
1543
|
+
const { data: source } = useGetFileThumbnail(meta);
|
|
1544
|
+
const handleOnMouseEnter = () => setShowItemBar(true);
|
|
1545
|
+
const handleOnMouseLeave = () => itemBar !== "always" && setShowItemBar(false);
|
|
1546
|
+
const openMenu = (event) => {
|
|
1547
|
+
setMenu(menu === null ? { mouseX: event.clientX, mouseY: event.clientY } : null);
|
|
1548
|
+
setTimeout(() => setShowItemBar(true));
|
|
1549
|
+
};
|
|
1550
|
+
const { mutate: openFile } = useOpenFile();
|
|
1551
|
+
const { mutate: download } = useDownloadFile();
|
|
1552
|
+
const onClick = () => {
|
|
1553
|
+
switch (meta.mediaType) {
|
|
1554
|
+
case "image": {
|
|
1555
|
+
return setImageId(meta.id);
|
|
1556
|
+
}
|
|
1557
|
+
case "application": {
|
|
1558
|
+
return openFile(meta);
|
|
1559
|
+
}
|
|
1560
|
+
case "video": {
|
|
1561
|
+
return openFile(meta);
|
|
1562
|
+
}
|
|
1563
|
+
default: {
|
|
1564
|
+
return download(meta);
|
|
1565
|
+
}
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
return /* @__PURE__ */ jsxs6(Fragment, { children: [
|
|
1569
|
+
/* @__PURE__ */ jsxs6(ImageListItem, { sx: { width: size ?? IMAGE_SIZE, height: size ?? IMAGE_SIZE }, onMouseEnter: handleOnMouseEnter, onMouseLeave: handleOnMouseLeave, children: [
|
|
1570
|
+
/* @__PURE__ */ jsx8(
|
|
1571
|
+
Box2,
|
|
1572
|
+
{
|
|
1573
|
+
component: "img",
|
|
1574
|
+
src: source,
|
|
1575
|
+
loading: "lazy",
|
|
1576
|
+
alt: "thumbnail-" + meta.id,
|
|
1577
|
+
onClick,
|
|
1578
|
+
sx: { cursor: "pointer", objectFit: "contain", width: size ?? IMAGE_SIZE, height: size ?? IMAGE_SIZE }
|
|
1579
|
+
}
|
|
1580
|
+
),
|
|
1581
|
+
itemBar !== "hidden" && showItemBar && /* @__PURE__ */ jsx8(
|
|
1582
|
+
ImageListItemBar,
|
|
1583
|
+
{
|
|
1584
|
+
title: /* @__PURE__ */ jsx8(Tooltip, { title: meta.fileName, children: /* @__PURE__ */ jsx8(Box2, { children: meta.fileName }) }),
|
|
1585
|
+
actionIcon: (actions?.download !== false || actions?.delete !== false) && /* @__PURE__ */ jsx8(IconButton, { sx: { color: grey[100] }, onClick: openMenu, children: /* @__PURE__ */ jsx8(MoreVert, {}) })
|
|
1586
|
+
}
|
|
1587
|
+
)
|
|
1588
|
+
] }),
|
|
1589
|
+
(actions?.download !== false || actions?.delete !== false) && /* @__PURE__ */ jsx8(ActionsMenu, { meta, menu, setMenu })
|
|
1590
|
+
] });
|
|
1591
|
+
};
|
|
1592
|
+
|
|
1593
|
+
// src/components/file/fileViewer/FileViewerList.tsx
|
|
1594
|
+
import AttachFile from "@mui/icons-material/AttachFile";
|
|
1595
|
+
import Image from "@mui/icons-material/Image";
|
|
1596
|
+
import MoreVert2 from "@mui/icons-material/MoreVert";
|
|
1597
|
+
import SmartDisplay from "@mui/icons-material/SmartDisplay";
|
|
1598
|
+
import { IconButton as IconButton2, List as List2, ListItemButton as ListItemButton2, ListItemIcon as ListItemIcon2, ListItemText as ListItemText2 } from "@mui/material";
|
|
1599
|
+
import { Fragment as Fragment2, useState as useState4 } from "react";
|
|
1600
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1601
|
+
var FileViewerList = ({ sx }) => {
|
|
1602
|
+
const { fileMetas } = useFile();
|
|
1603
|
+
return /* @__PURE__ */ jsx9(List2, { dense: true, sx, children: fileMetas.map(
|
|
1604
|
+
(fileMeta) => /* @__PURE__ */ jsx9(
|
|
1605
|
+
ListFileViewerItem,
|
|
1606
|
+
{
|
|
1607
|
+
meta: fileMeta
|
|
1608
|
+
},
|
|
1609
|
+
fileMeta.id
|
|
1610
|
+
)
|
|
1611
|
+
) });
|
|
1612
|
+
};
|
|
1613
|
+
var ListFileViewerItem = ({ meta }) => {
|
|
1614
|
+
const { setImageId, actions } = useFile();
|
|
1615
|
+
const [menu, setMenu] = useState4(null);
|
|
1616
|
+
const openMenu = (event) => {
|
|
1617
|
+
event.stopPropagation();
|
|
1618
|
+
setMenu(menu === null ? { mouseX: event.clientX, mouseY: event.clientY } : null);
|
|
1619
|
+
};
|
|
1620
|
+
const { mutate: openFile } = useOpenFile();
|
|
1621
|
+
const { mutate: download } = useDownloadFile();
|
|
1622
|
+
const onClick = () => {
|
|
1623
|
+
switch (meta.mediaType) {
|
|
1624
|
+
case "image": {
|
|
1625
|
+
return setImageId(meta.id);
|
|
1626
|
+
}
|
|
1627
|
+
case "application": {
|
|
1628
|
+
return openFile(meta);
|
|
1629
|
+
}
|
|
1630
|
+
case "video": {
|
|
1631
|
+
return openFile(meta);
|
|
1632
|
+
}
|
|
1633
|
+
default: {
|
|
1634
|
+
return download(meta);
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
};
|
|
1638
|
+
const icon = () => {
|
|
1639
|
+
switch (meta.mediaType) {
|
|
1640
|
+
case "image": {
|
|
1641
|
+
return /* @__PURE__ */ jsx9(Image, {});
|
|
1642
|
+
}
|
|
1643
|
+
case "video": {
|
|
1644
|
+
return /* @__PURE__ */ jsx9(SmartDisplay, {});
|
|
1645
|
+
}
|
|
1646
|
+
default: {
|
|
1647
|
+
return /* @__PURE__ */ jsx9(AttachFile, {});
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
};
|
|
1651
|
+
return /* @__PURE__ */ jsxs7(Fragment2, { children: [
|
|
1652
|
+
/* @__PURE__ */ jsxs7(ListItemButton2, { onClick, children: [
|
|
1653
|
+
/* @__PURE__ */ jsx9(ListItemIcon2, { children: icon() }),
|
|
1654
|
+
/* @__PURE__ */ jsx9(ListItemText2, { primary: `${meta.fileName}.${meta.fileExtension}` }),
|
|
1655
|
+
(actions?.download !== false || actions?.delete !== false) && /* @__PURE__ */ jsx9(IconButton2, { edge: "end", onClick: openMenu, children: /* @__PURE__ */ jsx9(MoreVert2, {}) })
|
|
1656
|
+
] }, meta.id),
|
|
1657
|
+
(actions?.download !== false || actions?.delete !== false) && /* @__PURE__ */ jsx9(ActionsMenu, { meta, menu, setMenu })
|
|
1658
|
+
] });
|
|
1659
|
+
};
|
|
1660
|
+
|
|
1661
|
+
// src/components/file/fileViewer/ImageViewer.tsx
|
|
1662
|
+
import Close from "@mui/icons-material/Close";
|
|
1663
|
+
import { Box as Box3, Dialog as Dialog2, Fab } from "@mui/material";
|
|
1664
|
+
import { useEffect as useEffect4 } from "react";
|
|
1665
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1666
|
+
var ImageViewer = ({ metaId }) => {
|
|
1667
|
+
const { fileMetas, setImageId } = useFile();
|
|
1668
|
+
const meta = fileMetas.find((m) => m.id === metaId);
|
|
1669
|
+
const { data: source } = useGetFile(meta);
|
|
1670
|
+
useEffect4(() => {
|
|
1671
|
+
if (globalThis.window !== void 0 && metaId)
|
|
1672
|
+
globalThis.addEventListener("keydown", handleOnKeydown);
|
|
1673
|
+
return () => {
|
|
1674
|
+
globalThis.removeEventListener("keydown", handleOnKeydown);
|
|
1675
|
+
};
|
|
1676
|
+
}, [metaId]);
|
|
1677
|
+
const handleOnKeydown = (event) => {
|
|
1678
|
+
const images = fileMetas.filter((m) => m.mediaType === "image");
|
|
1679
|
+
const imageIndex = images.findIndex((m) => m.id === metaId);
|
|
1680
|
+
switch (event.key) {
|
|
1681
|
+
case "ArrowLeft": {
|
|
1682
|
+
return handleOnArrowLeft(images, imageIndex);
|
|
1683
|
+
}
|
|
1684
|
+
case "ArrowRight": {
|
|
1685
|
+
return handleOnArrowRight(images, imageIndex);
|
|
1686
|
+
}
|
|
1687
|
+
case "Backspace":
|
|
1688
|
+
case "Escape": {
|
|
1689
|
+
event.preventDefault();
|
|
1690
|
+
return onClose();
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
};
|
|
1694
|
+
const handleOnArrowLeft = (images, index) => {
|
|
1695
|
+
if (index > 0) {
|
|
1696
|
+
const previousFile = images[index - 1];
|
|
1697
|
+
setImageId(previousFile.id);
|
|
1698
|
+
}
|
|
1699
|
+
};
|
|
1700
|
+
const handleOnArrowRight = (images, index) => {
|
|
1701
|
+
if (index < images.length - 1) {
|
|
1702
|
+
const nextFile = images[index + 1];
|
|
1703
|
+
setImageId(nextFile.id);
|
|
1704
|
+
}
|
|
1705
|
+
};
|
|
1706
|
+
const onClose = () => setImageId("");
|
|
1707
|
+
if (!metaId) return null;
|
|
1708
|
+
return /* @__PURE__ */ jsxs8(Dialog2, { open: true, onClose, maxWidth: "xl", children: [
|
|
1709
|
+
/* @__PURE__ */ jsx10(Box3, { component: "img", src: source, alt: metaId, sx: { maxWidth: "100vw", maxHeight: { xs: "calc(100vh - 56px)", sm: "calc(100vh - 64px)" } } }),
|
|
1710
|
+
/* @__PURE__ */ jsx10(Fab, { size: "medium", onClick: onClose, sx: { position: "fixed", top: 8, right: 8 }, children: /* @__PURE__ */ jsx10(Close, {}) })
|
|
1711
|
+
] });
|
|
1712
|
+
};
|
|
1713
|
+
|
|
1714
|
+
// src/components/file/FileViewer.tsx
|
|
1715
|
+
import { jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1716
|
+
var FileViewer = ({ subId, onDelete, actions, children }) => {
|
|
1717
|
+
const { data: fileMetas = [] } = useGetFileMetas(subId, { enabled: !!subId });
|
|
1718
|
+
const [imageId, setImageId] = useState5("");
|
|
1719
|
+
const components = { Grid: FileViewerGrid, List: FileViewerList };
|
|
1720
|
+
if (fileMetas.length === 0) return null;
|
|
1721
|
+
return /* @__PURE__ */ jsxs9(FileContext.Provider, { value: { fileMetas, onDelete, actions, setImageId }, children: [
|
|
1722
|
+
children(components),
|
|
1723
|
+
/* @__PURE__ */ jsx11(ImageViewer, { metaId: imageId })
|
|
1099
1724
|
] });
|
|
1100
1725
|
};
|
|
1101
1726
|
|
|
1102
1727
|
// src/components/data-grid/ChipInputCell.tsx
|
|
1103
|
-
import { Chip, Stack as
|
|
1104
|
-
import { jsx as
|
|
1728
|
+
import { Chip as Chip2, Stack as Stack4 } from "@mui/material";
|
|
1729
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
1105
1730
|
var isArray = (value) => Array.isArray(value);
|
|
1106
1731
|
var ChipInputCell = ({ params, slotProps, getLabel }) => {
|
|
1107
1732
|
if (!params.value) return null;
|
|
@@ -1110,113 +1735,123 @@ var ChipInputCell = ({ params, slotProps, getLabel }) => {
|
|
|
1110
1735
|
return value;
|
|
1111
1736
|
};
|
|
1112
1737
|
if (isArray(params.value))
|
|
1113
|
-
return /* @__PURE__ */
|
|
1114
|
-
(value, index) => /* @__PURE__ */
|
|
1738
|
+
return /* @__PURE__ */ jsx12(Stack4, { direction: "row", alignItems: "center", gap: 1, sx: { overflowX: "auto", height: "100%", width: params.colDef.computedWidth }, children: params.value.map(
|
|
1739
|
+
(value, index) => /* @__PURE__ */ jsx12(Chip2, { label: getLabelValue(value), ...slotProps }, `${index + 1}-chip-input-cell`)
|
|
1115
1740
|
) });
|
|
1116
|
-
return /* @__PURE__ */
|
|
1741
|
+
return /* @__PURE__ */ jsx12(Chip2, { label: getLabelValue(params.value), ...slotProps });
|
|
1117
1742
|
};
|
|
1118
1743
|
|
|
1119
1744
|
// src/components/data-grid/EditableColumnHeader.tsx
|
|
1120
1745
|
import Edit from "@mui/icons-material/Edit";
|
|
1121
|
-
import { jsx as
|
|
1746
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
1122
1747
|
var EditableColumnHeader = ({ colDef }) => {
|
|
1123
|
-
return /* @__PURE__ */
|
|
1748
|
+
return /* @__PURE__ */ jsx13(TypographyWithIcon, { endIcon: /* @__PURE__ */ jsx13(Edit, { color: "disabled", fontSize: "small" }), variant: "body2", className: "MuiDataGrid-columnHeaderTitle", children: colDef.headerName });
|
|
1124
1749
|
};
|
|
1125
1750
|
|
|
1126
1751
|
// src/components/router/RouterButton.tsx
|
|
1127
|
-
import { Button } from "@mui/material";
|
|
1752
|
+
import { Button as Button2 } from "@mui/material";
|
|
1128
1753
|
import { createLink } from "@tanstack/react-router";
|
|
1129
|
-
import
|
|
1130
|
-
import { jsx as
|
|
1131
|
-
var Component =
|
|
1132
|
-
return /* @__PURE__ */
|
|
1754
|
+
import React5 from "react";
|
|
1755
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1756
|
+
var Component = React5.forwardRef(function ButtonComponent(props, reference) {
|
|
1757
|
+
return /* @__PURE__ */ jsx14(Button2, { ref: reference, component: "a", ...props });
|
|
1133
1758
|
});
|
|
1134
1759
|
var CreatedComponent = createLink(Component);
|
|
1135
1760
|
var RouterButton = (props) => {
|
|
1136
|
-
return /* @__PURE__ */
|
|
1761
|
+
return /* @__PURE__ */ jsx14(CreatedComponent, { ...props });
|
|
1137
1762
|
};
|
|
1138
1763
|
|
|
1139
1764
|
// src/components/router/RouterGridActionsCellItem.tsx
|
|
1140
1765
|
import { GridActionsCellItem } from "@mui/x-data-grid-premium";
|
|
1141
1766
|
import { createLink as createLink2 } from "@tanstack/react-router";
|
|
1142
|
-
import
|
|
1143
|
-
import { jsx as
|
|
1144
|
-
var Component2 =
|
|
1767
|
+
import React6 from "react";
|
|
1768
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
1769
|
+
var Component2 = React6.forwardRef(
|
|
1145
1770
|
function GridActionsCellItemComponent(props, reference) {
|
|
1146
|
-
return /* @__PURE__ */
|
|
1771
|
+
return /* @__PURE__ */ jsx15(GridActionsCellItem, { ref: reference, component: "a", ...props });
|
|
1147
1772
|
}
|
|
1148
1773
|
);
|
|
1149
1774
|
var CreatedComponent2 = createLink2(Component2);
|
|
1150
1775
|
var RouterGridActionsCellItem = (props) => {
|
|
1151
|
-
return /* @__PURE__ */
|
|
1776
|
+
return /* @__PURE__ */ jsx15(CreatedComponent2, { ...props });
|
|
1152
1777
|
};
|
|
1153
1778
|
|
|
1154
1779
|
// src/components/router/RouterIconButton.tsx
|
|
1155
|
-
import { IconButton } from "@mui/material";
|
|
1780
|
+
import { IconButton as IconButton3 } from "@mui/material";
|
|
1156
1781
|
import { createLink as createLink3 } from "@tanstack/react-router";
|
|
1157
|
-
import
|
|
1158
|
-
import { jsx as
|
|
1159
|
-
var Component3 =
|
|
1160
|
-
return /* @__PURE__ */
|
|
1782
|
+
import React7 from "react";
|
|
1783
|
+
import { jsx as jsx16 } from "react/jsx-runtime";
|
|
1784
|
+
var Component3 = React7.forwardRef(function IconButtonComponent(props, reference) {
|
|
1785
|
+
return /* @__PURE__ */ jsx16(IconButton3, { ref: reference, component: "a", ...props });
|
|
1161
1786
|
});
|
|
1162
1787
|
var CreatedComponent3 = createLink3(Component3);
|
|
1163
1788
|
var RouterIconButton = (props) => {
|
|
1164
|
-
return /* @__PURE__ */
|
|
1789
|
+
return /* @__PURE__ */ jsx16(CreatedComponent3, { ...props });
|
|
1165
1790
|
};
|
|
1166
1791
|
|
|
1167
1792
|
// src/components/router/RouterLink.tsx
|
|
1168
1793
|
import { Link } from "@mui/material";
|
|
1169
1794
|
import { createLink as createLink4 } from "@tanstack/react-router";
|
|
1170
|
-
import
|
|
1171
|
-
import { jsx as
|
|
1172
|
-
var Component4 =
|
|
1173
|
-
return /* @__PURE__ */
|
|
1795
|
+
import React8 from "react";
|
|
1796
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
1797
|
+
var Component4 = React8.forwardRef(function LinkComponent(props, reference) {
|
|
1798
|
+
return /* @__PURE__ */ jsx17(Link, { ref: reference, ...props });
|
|
1174
1799
|
});
|
|
1175
1800
|
var CreatedComponent4 = createLink4(Component4);
|
|
1176
1801
|
var RouterLink = (props) => {
|
|
1177
|
-
return /* @__PURE__ */
|
|
1802
|
+
return /* @__PURE__ */ jsx17(CreatedComponent4, { ...props });
|
|
1178
1803
|
};
|
|
1179
1804
|
|
|
1180
1805
|
// src/components/router/RouterTab.tsx
|
|
1181
1806
|
import { Tab } from "@mui/material";
|
|
1182
1807
|
import { createLink as createLink5 } from "@tanstack/react-router";
|
|
1183
|
-
import
|
|
1184
|
-
import { jsx as
|
|
1185
|
-
var Component5 =
|
|
1186
|
-
return /* @__PURE__ */
|
|
1808
|
+
import React9 from "react";
|
|
1809
|
+
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
1810
|
+
var Component5 = React9.forwardRef(function TabComponent(props, reference) {
|
|
1811
|
+
return /* @__PURE__ */ jsx18(Tab, { ref: reference, component: "a", ...props });
|
|
1187
1812
|
});
|
|
1188
1813
|
var CreatedComponent5 = createLink5(Component5);
|
|
1189
1814
|
var RouterTab = (props) => {
|
|
1190
|
-
return /* @__PURE__ */
|
|
1815
|
+
return /* @__PURE__ */ jsx18(CreatedComponent5, { ...props });
|
|
1816
|
+
};
|
|
1817
|
+
|
|
1818
|
+
// src/components/router/RouterListItemButton.tsx
|
|
1819
|
+
import { ListItemButton as ListItemButton3 } from "@mui/material";
|
|
1820
|
+
import { createLink as createLink6 } from "@tanstack/react-router";
|
|
1821
|
+
import React10 from "react";
|
|
1822
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
1823
|
+
var Component6 = React10.forwardRef(function ButtonComponent2(props, reference) {
|
|
1824
|
+
return /* @__PURE__ */ jsx19(ListItemButton3, { ref: reference, component: "a", ...props });
|
|
1825
|
+
});
|
|
1826
|
+
var CreatedComponent6 = createLink6(Component6);
|
|
1827
|
+
var RouterListItemButton = (props) => {
|
|
1828
|
+
return /* @__PURE__ */ jsx19(CreatedComponent6, { ...props });
|
|
1191
1829
|
};
|
|
1192
1830
|
|
|
1193
1831
|
// src/components/router/RouterNotFound.tsx
|
|
1194
|
-
import { Box, Divider, Typography as
|
|
1195
|
-
import { useTranslation as
|
|
1196
|
-
import { jsx as
|
|
1832
|
+
import { Box as Box4, Divider, Typography as Typography5 } from "@mui/material";
|
|
1833
|
+
import { useTranslation as useTranslation4 } from "react-i18next";
|
|
1834
|
+
import { jsx as jsx20, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1197
1835
|
function RouterNotFound() {
|
|
1198
|
-
const { t: t2 } =
|
|
1199
|
-
return /* @__PURE__ */
|
|
1200
|
-
/* @__PURE__ */
|
|
1201
|
-
/* @__PURE__ */
|
|
1202
|
-
/* @__PURE__ */
|
|
1836
|
+
const { t: t2 } = useTranslation4();
|
|
1837
|
+
return /* @__PURE__ */ jsx20(Box4, { height: "100vh", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", textAlign: "center", px: 2, children: /* @__PURE__ */ jsxs10(Box4, { display: "flex", alignItems: "center", mb: 4, children: [
|
|
1838
|
+
/* @__PURE__ */ jsx20(Typography5, { variant: "h3", component: "span", fontWeight: 500, sx: { lineHeight: 1 }, children: "404" }),
|
|
1839
|
+
/* @__PURE__ */ jsx20(Divider, { orientation: "vertical", flexItem: true, sx: { mx: 3 } }),
|
|
1840
|
+
/* @__PURE__ */ jsx20(Typography5, { variant: "h5", component: "span", children: t2("Layout.ThisPageCouldNotBeFound") })
|
|
1203
1841
|
] }) });
|
|
1204
1842
|
}
|
|
1205
1843
|
|
|
1206
1844
|
// src/components/router/RouterError.tsx
|
|
1207
|
-
import { Box as
|
|
1208
|
-
import { jsx as
|
|
1845
|
+
import { Box as Box5, Divider as Divider2, Typography as Typography6 } from "@mui/material";
|
|
1846
|
+
import { jsx as jsx21, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1209
1847
|
var RouterError = ({ error }) => {
|
|
1210
|
-
return /* @__PURE__ */
|
|
1211
|
-
/* @__PURE__ */
|
|
1212
|
-
/* @__PURE__ */
|
|
1213
|
-
/* @__PURE__ */
|
|
1848
|
+
return /* @__PURE__ */ jsx21(Box5, { height: "100vh", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", textAlign: "center", px: 2, children: /* @__PURE__ */ jsxs11(Box5, { display: "flex", alignItems: "center", mb: 4, children: [
|
|
1849
|
+
/* @__PURE__ */ jsx21(Typography6, { variant: "h3", component: "span", fontWeight: 500, sx: { lineHeight: 1 }, children: error.name || "500" }),
|
|
1850
|
+
/* @__PURE__ */ jsx21(Divider2, { orientation: "vertical", flexItem: true, sx: { mx: 3 } }),
|
|
1851
|
+
/* @__PURE__ */ jsx21(Typography6, { variant: "h5", component: "span", children: error.message })
|
|
1214
1852
|
] }) });
|
|
1215
1853
|
};
|
|
1216
1854
|
|
|
1217
|
-
// src/providers/LayoutProvider.tsx
|
|
1218
|
-
import { LinearProgress, useMediaQuery } from "@mui/material";
|
|
1219
|
-
|
|
1220
1855
|
// node_modules/@babel/runtime/helpers/esm/extends.js
|
|
1221
1856
|
function _extends() {
|
|
1222
1857
|
return _extends = Object.assign ? Object.assign.bind() : function(n) {
|
|
@@ -1241,11 +1876,11 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
1241
1876
|
|
|
1242
1877
|
// node_modules/@mui/x-date-pickers/esm/LocalizationProvider/LocalizationProvider.js
|
|
1243
1878
|
var import_prop_types = __toESM(require_prop_types(), 1);
|
|
1244
|
-
import * as
|
|
1879
|
+
import * as React11 from "react";
|
|
1245
1880
|
import { useThemeProps } from "@mui/material/styles";
|
|
1246
1881
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1247
1882
|
var _excluded = ["localeText"];
|
|
1248
|
-
var PickerAdapterContext = /* @__PURE__ */
|
|
1883
|
+
var PickerAdapterContext = /* @__PURE__ */ React11.createContext(null);
|
|
1249
1884
|
if (process.env.NODE_ENV !== "production") PickerAdapterContext.displayName = "PickerAdapterContext";
|
|
1250
1885
|
var LocalizationProvider = function LocalizationProvider2(inProps) {
|
|
1251
1886
|
const {
|
|
@@ -1254,7 +1889,7 @@ var LocalizationProvider = function LocalizationProvider2(inProps) {
|
|
|
1254
1889
|
const {
|
|
1255
1890
|
adapter: parentAdapter,
|
|
1256
1891
|
localeText: parentLocaleText
|
|
1257
|
-
} =
|
|
1892
|
+
} = React11.useContext(PickerAdapterContext) ?? {
|
|
1258
1893
|
utils: void 0,
|
|
1259
1894
|
adapter: void 0,
|
|
1260
1895
|
localeText: void 0
|
|
@@ -1273,8 +1908,8 @@ var LocalizationProvider = function LocalizationProvider2(inProps) {
|
|
|
1273
1908
|
adapterLocale,
|
|
1274
1909
|
localeText: themeLocaleText
|
|
1275
1910
|
} = props;
|
|
1276
|
-
const localeText =
|
|
1277
|
-
const adapter =
|
|
1911
|
+
const localeText = React11.useMemo(() => _extends({}, themeLocaleText, parentLocaleText, inLocaleText), [themeLocaleText, parentLocaleText, inLocaleText]);
|
|
1912
|
+
const adapter = React11.useMemo(() => {
|
|
1278
1913
|
if (!DateAdapter) {
|
|
1279
1914
|
if (parentAdapter) {
|
|
1280
1915
|
return parentAdapter;
|
|
@@ -1292,7 +1927,7 @@ var LocalizationProvider = function LocalizationProvider2(inProps) {
|
|
|
1292
1927
|
}
|
|
1293
1928
|
return dateAdapter;
|
|
1294
1929
|
}, [DateAdapter, adapterLocale, dateFormats, dateLibInstance, parentAdapter]);
|
|
1295
|
-
const defaultDates =
|
|
1930
|
+
const defaultDates = React11.useMemo(() => {
|
|
1296
1931
|
if (!adapter) {
|
|
1297
1932
|
return null;
|
|
1298
1933
|
}
|
|
@@ -1301,7 +1936,7 @@ var LocalizationProvider = function LocalizationProvider2(inProps) {
|
|
|
1301
1936
|
maxDate: adapter.date("2099-12-31T00:00:00.000")
|
|
1302
1937
|
};
|
|
1303
1938
|
}, [adapter]);
|
|
1304
|
-
const contextValue =
|
|
1939
|
+
const contextValue = React11.useMemo(() => {
|
|
1305
1940
|
return {
|
|
1306
1941
|
utils: adapter,
|
|
1307
1942
|
adapter,
|
|
@@ -1506,396 +2141,796 @@ var defaultFormats = {
|
|
|
1506
2141
|
var MISSING_UTC_PLUGIN = ["Missing UTC plugin", "To be able to use UTC or timezones, you have to enable the `utc` plugin", "Find more information on https://mui.com/x/react-date-pickers/timezone/#day-js-and-utc"].join("\n");
|
|
1507
2142
|
var MISSING_TIMEZONE_PLUGIN = ["Missing timezone plugin", "To be able to use timezones, you have to enable both the `utc` and the `timezone` plugin", "Find more information on https://mui.com/x/react-date-pickers/timezone/#day-js-and-timezone"].join("\n");
|
|
1508
2143
|
var AdapterDayjs = class {
|
|
2144
|
+
isMUIAdapter = true;
|
|
2145
|
+
isTimezoneCompatible = true;
|
|
2146
|
+
lib = "dayjs";
|
|
2147
|
+
escapedCharacters = {
|
|
2148
|
+
start: "[",
|
|
2149
|
+
end: "]"
|
|
2150
|
+
};
|
|
2151
|
+
formatTokenMap = /* @__PURE__ */ (() => formatTokenMap)();
|
|
1509
2152
|
constructor({
|
|
1510
|
-
locale
|
|
2153
|
+
locale,
|
|
1511
2154
|
formats
|
|
1512
2155
|
} = {}) {
|
|
1513
|
-
this.
|
|
1514
|
-
this.
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
end: "]"
|
|
1521
|
-
};
|
|
1522
|
-
this.formatTokenMap = formatTokenMap;
|
|
1523
|
-
this.setLocaleToValue = (value) => {
|
|
1524
|
-
const expectedLocale = this.getCurrentLocaleCode();
|
|
1525
|
-
if (expectedLocale === value.locale()) {
|
|
1526
|
-
return value;
|
|
1527
|
-
}
|
|
1528
|
-
return value.locale(expectedLocale);
|
|
1529
|
-
};
|
|
1530
|
-
this.hasUTCPlugin = () => typeof dayjs.utc !== "undefined";
|
|
1531
|
-
this.hasTimezonePlugin = () => typeof dayjs.tz !== "undefined";
|
|
1532
|
-
this.isSame = (value, comparing, comparisonTemplate) => {
|
|
1533
|
-
const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
|
|
1534
|
-
return value.format(comparisonTemplate) === comparingInValueTimezone.format(comparisonTemplate);
|
|
1535
|
-
};
|
|
1536
|
-
this.cleanTimezone = (timezone) => {
|
|
1537
|
-
switch (timezone) {
|
|
1538
|
-
case "default": {
|
|
1539
|
-
return void 0;
|
|
1540
|
-
}
|
|
1541
|
-
case "system": {
|
|
1542
|
-
return dayjs.tz.guess();
|
|
1543
|
-
}
|
|
1544
|
-
default: {
|
|
1545
|
-
return timezone;
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1548
|
-
};
|
|
1549
|
-
this.createSystemDate = (value) => {
|
|
1550
|
-
let date;
|
|
1551
|
-
if (this.hasUTCPlugin() && this.hasTimezonePlugin()) {
|
|
1552
|
-
const timezone = dayjs.tz.guess();
|
|
1553
|
-
if (timezone === "UTC") {
|
|
1554
|
-
date = dayjs(value);
|
|
1555
|
-
} else {
|
|
1556
|
-
date = dayjs.tz(value, timezone);
|
|
1557
|
-
}
|
|
1558
|
-
} else {
|
|
1559
|
-
date = dayjs(value);
|
|
1560
|
-
}
|
|
1561
|
-
return this.setLocaleToValue(date);
|
|
1562
|
-
};
|
|
1563
|
-
this.createUTCDate = (value) => {
|
|
1564
|
-
if (!this.hasUTCPlugin()) {
|
|
1565
|
-
throw new Error(MISSING_UTC_PLUGIN);
|
|
1566
|
-
}
|
|
1567
|
-
return this.setLocaleToValue(dayjs.utc(value));
|
|
1568
|
-
};
|
|
1569
|
-
this.createTZDate = (value, timezone) => {
|
|
1570
|
-
if (!this.hasUTCPlugin()) {
|
|
1571
|
-
throw new Error(MISSING_UTC_PLUGIN);
|
|
1572
|
-
}
|
|
1573
|
-
if (!this.hasTimezonePlugin()) {
|
|
1574
|
-
throw new Error(MISSING_TIMEZONE_PLUGIN);
|
|
1575
|
-
}
|
|
1576
|
-
const keepLocalTime = value !== void 0 && !value.endsWith("Z");
|
|
1577
|
-
return this.setLocaleToValue(dayjs(value).tz(this.cleanTimezone(timezone), keepLocalTime));
|
|
1578
|
-
};
|
|
1579
|
-
this.getLocaleFormats = () => {
|
|
1580
|
-
const locales = dayjs.Ls;
|
|
1581
|
-
const locale = this.locale || "en";
|
|
1582
|
-
let localeObject = locales[locale];
|
|
1583
|
-
if (localeObject === void 0) {
|
|
1584
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1585
|
-
warnOnce(["MUI X: Your locale has not been found.", "Either the locale key is not a supported one. Locales supported by dayjs are available here: https://github.com/iamkun/dayjs/tree/dev/src/locale.", "Or you forget to import the locale from 'dayjs/locale/{localeUsed}'", "fallback on English locale."]);
|
|
1586
|
-
}
|
|
1587
|
-
localeObject = locales.en;
|
|
1588
|
-
}
|
|
1589
|
-
return localeObject.formats;
|
|
1590
|
-
};
|
|
1591
|
-
this.adjustOffset = (value) => {
|
|
1592
|
-
if (!this.hasTimezonePlugin()) {
|
|
1593
|
-
return value;
|
|
1594
|
-
}
|
|
1595
|
-
const timezone = this.getTimezone(value);
|
|
1596
|
-
if (timezone !== "UTC") {
|
|
1597
|
-
const fixedValue = value.tz(this.cleanTimezone(timezone), true);
|
|
1598
|
-
if (fixedValue.$offset === (value.$offset ?? 0)) {
|
|
1599
|
-
return value;
|
|
1600
|
-
}
|
|
1601
|
-
value.$offset = fixedValue.$offset;
|
|
1602
|
-
}
|
|
2156
|
+
this.locale = locale;
|
|
2157
|
+
this.formats = _extends({}, defaultFormats, formats);
|
|
2158
|
+
dayjs.extend(customParseFormatPlugin);
|
|
2159
|
+
}
|
|
2160
|
+
setLocaleToValue = (value) => {
|
|
2161
|
+
const expectedLocale = this.getCurrentLocaleCode();
|
|
2162
|
+
if (expectedLocale === value.locale()) {
|
|
1603
2163
|
return value;
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
const zone = value.$x?.$timezone;
|
|
1621
|
-
if (zone) {
|
|
1622
|
-
return zone;
|
|
1623
|
-
}
|
|
2164
|
+
}
|
|
2165
|
+
return value.locale(expectedLocale);
|
|
2166
|
+
};
|
|
2167
|
+
hasUTCPlugin = () => typeof dayjs.utc !== "undefined";
|
|
2168
|
+
hasTimezonePlugin = () => typeof dayjs.tz !== "undefined";
|
|
2169
|
+
isSame = (value, comparing, comparisonTemplate) => {
|
|
2170
|
+
const comparingInValueTimezone = this.setTimezone(comparing, this.getTimezone(value));
|
|
2171
|
+
return value.format(comparisonTemplate) === comparingInValueTimezone.format(comparisonTemplate);
|
|
2172
|
+
};
|
|
2173
|
+
/**
|
|
2174
|
+
* Replaces "default" by undefined and "system" by the system timezone before passing it to `dayjs`.
|
|
2175
|
+
*/
|
|
2176
|
+
cleanTimezone = (timezone) => {
|
|
2177
|
+
switch (timezone) {
|
|
2178
|
+
case "default": {
|
|
2179
|
+
return void 0;
|
|
1624
2180
|
}
|
|
1625
|
-
|
|
1626
|
-
return
|
|
2181
|
+
case "system": {
|
|
2182
|
+
return dayjs.tz.guess();
|
|
1627
2183
|
}
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
this.setTimezone = (value, timezone) => {
|
|
1631
|
-
if (this.getTimezone(value) === timezone) {
|
|
1632
|
-
return value;
|
|
2184
|
+
default: {
|
|
2185
|
+
return timezone;
|
|
1633
2186
|
}
|
|
2187
|
+
}
|
|
2188
|
+
};
|
|
2189
|
+
createSystemDate = (value) => {
|
|
2190
|
+
let date;
|
|
2191
|
+
if (this.hasUTCPlugin() && this.hasTimezonePlugin()) {
|
|
2192
|
+
const timezone = dayjs.tz.guess();
|
|
1634
2193
|
if (timezone === "UTC") {
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
return value.utc();
|
|
1639
|
-
}
|
|
1640
|
-
if (timezone === "system") {
|
|
1641
|
-
return value.local();
|
|
1642
|
-
}
|
|
1643
|
-
if (!this.hasTimezonePlugin()) {
|
|
1644
|
-
if (timezone === "default") {
|
|
1645
|
-
return value;
|
|
1646
|
-
}
|
|
1647
|
-
throw new Error(MISSING_TIMEZONE_PLUGIN);
|
|
1648
|
-
}
|
|
1649
|
-
return this.setLocaleToValue(dayjs.tz(value, this.cleanTimezone(timezone)));
|
|
1650
|
-
};
|
|
1651
|
-
this.toJsDate = (value) => {
|
|
1652
|
-
return value.toDate();
|
|
1653
|
-
};
|
|
1654
|
-
this.parse = (value, format) => {
|
|
1655
|
-
if (value === "") {
|
|
1656
|
-
return null;
|
|
1657
|
-
}
|
|
1658
|
-
return dayjs(value, format, this.locale, true);
|
|
1659
|
-
};
|
|
1660
|
-
this.getCurrentLocaleCode = () => {
|
|
1661
|
-
return this.locale || "en";
|
|
1662
|
-
};
|
|
1663
|
-
this.is12HourCycleInCurrentLocale = () => {
|
|
1664
|
-
return /A|a/.test(this.getLocaleFormats().LT || "");
|
|
1665
|
-
};
|
|
1666
|
-
this.expandFormat = (format) => {
|
|
1667
|
-
const localeFormats = this.getLocaleFormats();
|
|
1668
|
-
const t2 = (formatBis) => formatBis.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, (_, a, b) => a || b.slice(1));
|
|
1669
|
-
return format.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, (_, a, b) => {
|
|
1670
|
-
const B = b && b.toUpperCase();
|
|
1671
|
-
return a || localeFormats[b] || t2(localeFormats[B]);
|
|
1672
|
-
});
|
|
1673
|
-
};
|
|
1674
|
-
this.isValid = (value) => {
|
|
1675
|
-
if (value == null) {
|
|
1676
|
-
return false;
|
|
1677
|
-
}
|
|
1678
|
-
return value.isValid();
|
|
1679
|
-
};
|
|
1680
|
-
this.format = (value, formatKey) => {
|
|
1681
|
-
return this.formatByString(value, this.formats[formatKey]);
|
|
1682
|
-
};
|
|
1683
|
-
this.formatByString = (value, formatString) => {
|
|
1684
|
-
return this.setLocaleToValue(value).format(formatString);
|
|
1685
|
-
};
|
|
1686
|
-
this.formatNumber = (numberToFormat) => {
|
|
1687
|
-
return numberToFormat;
|
|
1688
|
-
};
|
|
1689
|
-
this.isEqual = (value, comparing) => {
|
|
1690
|
-
if (value === null && comparing === null) {
|
|
1691
|
-
return true;
|
|
2194
|
+
date = dayjs(value);
|
|
2195
|
+
} else {
|
|
2196
|
+
date = dayjs.tz(value, timezone);
|
|
1692
2197
|
}
|
|
1693
|
-
|
|
1694
|
-
|
|
2198
|
+
} else {
|
|
2199
|
+
date = dayjs(value);
|
|
2200
|
+
}
|
|
2201
|
+
return this.setLocaleToValue(date);
|
|
2202
|
+
};
|
|
2203
|
+
createUTCDate = (value) => {
|
|
2204
|
+
if (!this.hasUTCPlugin()) {
|
|
2205
|
+
throw new Error(MISSING_UTC_PLUGIN);
|
|
2206
|
+
}
|
|
2207
|
+
return this.setLocaleToValue(dayjs.utc(value));
|
|
2208
|
+
};
|
|
2209
|
+
createTZDate = (value, timezone) => {
|
|
2210
|
+
if (!this.hasUTCPlugin()) {
|
|
2211
|
+
throw new Error(MISSING_UTC_PLUGIN);
|
|
2212
|
+
}
|
|
2213
|
+
if (!this.hasTimezonePlugin()) {
|
|
2214
|
+
throw new Error(MISSING_TIMEZONE_PLUGIN);
|
|
2215
|
+
}
|
|
2216
|
+
const keepLocalTime = value !== void 0 && !value.endsWith("Z");
|
|
2217
|
+
return this.setLocaleToValue(dayjs(value).tz(this.cleanTimezone(timezone), keepLocalTime));
|
|
2218
|
+
};
|
|
2219
|
+
getLocaleFormats = () => {
|
|
2220
|
+
const locales = dayjs.Ls;
|
|
2221
|
+
const locale = this.locale || "en";
|
|
2222
|
+
let localeObject = locales[locale];
|
|
2223
|
+
if (localeObject === void 0) {
|
|
2224
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2225
|
+
warnOnce(["MUI X: Your locale has not been found.", "Either the locale key is not a supported one. Locales supported by dayjs are available here: https://github.com/iamkun/dayjs/tree/dev/src/locale.", "Or you forget to import the locale from 'dayjs/locale/{localeUsed}'", "fallback on English locale."]);
|
|
1695
2226
|
}
|
|
1696
|
-
|
|
1697
|
-
}
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
this.
|
|
1708
|
-
return value
|
|
1709
|
-
}
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
return value.isAfter(comparing, "year");
|
|
2227
|
+
localeObject = locales.en;
|
|
2228
|
+
}
|
|
2229
|
+
return localeObject.formats;
|
|
2230
|
+
};
|
|
2231
|
+
/**
|
|
2232
|
+
* If the new day does not have the same offset as the old one (when switching to summer day time for example),
|
|
2233
|
+
* Then dayjs will not automatically adjust the offset (moment does).
|
|
2234
|
+
* We have to parse again the value to make sure the `fixOffset` method is applied.
|
|
2235
|
+
* See https://github.com/iamkun/dayjs/blob/b3624de619d6e734cd0ffdbbd3502185041c1b60/src/plugin/timezone/index.js#L72
|
|
2236
|
+
*/
|
|
2237
|
+
adjustOffset = (value) => {
|
|
2238
|
+
if (!this.hasTimezonePlugin()) {
|
|
2239
|
+
return value;
|
|
2240
|
+
}
|
|
2241
|
+
const timezone = this.getTimezone(value);
|
|
2242
|
+
if (timezone !== "UTC") {
|
|
2243
|
+
const fixedValue = value.tz(this.cleanTimezone(timezone), true);
|
|
2244
|
+
if (fixedValue.$offset === (value.$offset ?? 0)) {
|
|
2245
|
+
return value;
|
|
1716
2246
|
}
|
|
1717
|
-
|
|
1718
|
-
}
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
2247
|
+
value.$offset = fixedValue.$offset;
|
|
2248
|
+
}
|
|
2249
|
+
return value;
|
|
2250
|
+
};
|
|
2251
|
+
date = (value, timezone = "default") => {
|
|
2252
|
+
if (value === null) {
|
|
2253
|
+
return null;
|
|
2254
|
+
}
|
|
2255
|
+
if (timezone === "UTC") {
|
|
2256
|
+
return this.createUTCDate(value);
|
|
2257
|
+
}
|
|
2258
|
+
if (timezone === "system" || timezone === "default" && !this.hasTimezonePlugin()) {
|
|
2259
|
+
return this.createSystemDate(value);
|
|
2260
|
+
}
|
|
2261
|
+
return this.createTZDate(value, timezone);
|
|
2262
|
+
};
|
|
2263
|
+
getInvalidDate = () => dayjs(/* @__PURE__ */ new Date("Invalid date"));
|
|
2264
|
+
getTimezone = (value) => {
|
|
2265
|
+
if (this.hasTimezonePlugin()) {
|
|
2266
|
+
const zone = value.$x?.$timezone;
|
|
2267
|
+
if (zone) {
|
|
2268
|
+
return zone;
|
|
1722
2269
|
}
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
2270
|
+
}
|
|
2271
|
+
if (this.hasUTCPlugin() && value.isUTC()) {
|
|
2272
|
+
return "UTC";
|
|
2273
|
+
}
|
|
2274
|
+
return "system";
|
|
2275
|
+
};
|
|
2276
|
+
setTimezone = (value, timezone) => {
|
|
2277
|
+
if (this.getTimezone(value) === timezone) {
|
|
2278
|
+
return value;
|
|
2279
|
+
}
|
|
2280
|
+
if (timezone === "UTC") {
|
|
1729
2281
|
if (!this.hasUTCPlugin()) {
|
|
1730
|
-
|
|
2282
|
+
throw new Error(MISSING_UTC_PLUGIN);
|
|
1731
2283
|
}
|
|
1732
|
-
return
|
|
1733
|
-
}
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
2284
|
+
return value.utc();
|
|
2285
|
+
}
|
|
2286
|
+
if (timezone === "system") {
|
|
2287
|
+
return value.local();
|
|
2288
|
+
}
|
|
2289
|
+
if (!this.hasTimezonePlugin()) {
|
|
2290
|
+
if (timezone === "default") {
|
|
2291
|
+
return value;
|
|
1737
2292
|
}
|
|
1738
|
-
|
|
1739
|
-
}
|
|
1740
|
-
this.
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
return
|
|
1748
|
-
}
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
this.
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
this.
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
}
|
|
1761
|
-
|
|
1762
|
-
return
|
|
1763
|
-
};
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
this.
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
2293
|
+
throw new Error(MISSING_TIMEZONE_PLUGIN);
|
|
2294
|
+
}
|
|
2295
|
+
return this.setLocaleToValue(dayjs.tz(value, this.cleanTimezone(timezone)));
|
|
2296
|
+
};
|
|
2297
|
+
toJsDate = (value) => {
|
|
2298
|
+
return value.toDate();
|
|
2299
|
+
};
|
|
2300
|
+
parse = (value, format) => {
|
|
2301
|
+
if (value === "") {
|
|
2302
|
+
return null;
|
|
2303
|
+
}
|
|
2304
|
+
return dayjs(value, format, this.locale, true);
|
|
2305
|
+
};
|
|
2306
|
+
getCurrentLocaleCode = () => {
|
|
2307
|
+
return this.locale || "en";
|
|
2308
|
+
};
|
|
2309
|
+
is12HourCycleInCurrentLocale = () => {
|
|
2310
|
+
return /A|a/.test(this.getLocaleFormats().LT || "");
|
|
2311
|
+
};
|
|
2312
|
+
expandFormat = (format) => {
|
|
2313
|
+
const localeFormats = this.getLocaleFormats();
|
|
2314
|
+
const t2 = (formatBis) => formatBis.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, (_, a, b) => a || b.slice(1));
|
|
2315
|
+
return format.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, (_, a, b) => {
|
|
2316
|
+
const B = b && b.toUpperCase();
|
|
2317
|
+
return a || localeFormats[b] || t2(localeFormats[B]);
|
|
2318
|
+
});
|
|
2319
|
+
};
|
|
2320
|
+
isValid = (value) => {
|
|
2321
|
+
if (value == null) {
|
|
2322
|
+
return false;
|
|
2323
|
+
}
|
|
2324
|
+
return value.isValid();
|
|
2325
|
+
};
|
|
2326
|
+
format = (value, formatKey) => {
|
|
2327
|
+
return this.formatByString(value, this.formats[formatKey]);
|
|
2328
|
+
};
|
|
2329
|
+
formatByString = (value, formatString) => {
|
|
2330
|
+
return this.setLocaleToValue(value).format(formatString);
|
|
2331
|
+
};
|
|
2332
|
+
formatNumber = (numberToFormat) => {
|
|
2333
|
+
return numberToFormat;
|
|
2334
|
+
};
|
|
2335
|
+
isEqual = (value, comparing) => {
|
|
2336
|
+
if (value === null && comparing === null) {
|
|
2337
|
+
return true;
|
|
2338
|
+
}
|
|
2339
|
+
if (value === null || comparing === null) {
|
|
2340
|
+
return false;
|
|
2341
|
+
}
|
|
2342
|
+
return value.toDate().getTime() === comparing.toDate().getTime();
|
|
2343
|
+
};
|
|
2344
|
+
isSameYear = (value, comparing) => {
|
|
2345
|
+
return this.isSame(value, comparing, "YYYY");
|
|
2346
|
+
};
|
|
2347
|
+
isSameMonth = (value, comparing) => {
|
|
2348
|
+
return this.isSame(value, comparing, "YYYY-MM");
|
|
2349
|
+
};
|
|
2350
|
+
isSameDay = (value, comparing) => {
|
|
2351
|
+
return this.isSame(value, comparing, "YYYY-MM-DD");
|
|
2352
|
+
};
|
|
2353
|
+
isSameHour = (value, comparing) => {
|
|
2354
|
+
return value.isSame(comparing, "hour");
|
|
2355
|
+
};
|
|
2356
|
+
isAfter = (value, comparing) => {
|
|
2357
|
+
return value > comparing;
|
|
2358
|
+
};
|
|
2359
|
+
isAfterYear = (value, comparing) => {
|
|
2360
|
+
if (!this.hasUTCPlugin()) {
|
|
2361
|
+
return value.isAfter(comparing, "year");
|
|
2362
|
+
}
|
|
2363
|
+
return !this.isSameYear(value, comparing) && value.utc() > comparing.utc();
|
|
2364
|
+
};
|
|
2365
|
+
isAfterDay = (value, comparing) => {
|
|
2366
|
+
if (!this.hasUTCPlugin()) {
|
|
2367
|
+
return value.isAfter(comparing, "day");
|
|
2368
|
+
}
|
|
2369
|
+
return !this.isSameDay(value, comparing) && value.utc() > comparing.utc();
|
|
2370
|
+
};
|
|
2371
|
+
isBefore = (value, comparing) => {
|
|
2372
|
+
return value < comparing;
|
|
2373
|
+
};
|
|
2374
|
+
isBeforeYear = (value, comparing) => {
|
|
2375
|
+
if (!this.hasUTCPlugin()) {
|
|
2376
|
+
return value.isBefore(comparing, "year");
|
|
2377
|
+
}
|
|
2378
|
+
return !this.isSameYear(value, comparing) && value.utc() < comparing.utc();
|
|
2379
|
+
};
|
|
2380
|
+
isBeforeDay = (value, comparing) => {
|
|
2381
|
+
if (!this.hasUTCPlugin()) {
|
|
2382
|
+
return value.isBefore(comparing, "day");
|
|
2383
|
+
}
|
|
2384
|
+
return !this.isSameDay(value, comparing) && value.utc() < comparing.utc();
|
|
2385
|
+
};
|
|
2386
|
+
isWithinRange = (value, [start, end]) => {
|
|
2387
|
+
return value >= start && value <= end;
|
|
2388
|
+
};
|
|
2389
|
+
startOfYear = (value) => {
|
|
2390
|
+
return this.adjustOffset(value.startOf("year"));
|
|
2391
|
+
};
|
|
2392
|
+
startOfMonth = (value) => {
|
|
2393
|
+
return this.adjustOffset(value.startOf("month"));
|
|
2394
|
+
};
|
|
2395
|
+
startOfWeek = (value) => {
|
|
2396
|
+
return this.adjustOffset(this.setLocaleToValue(value).startOf("week"));
|
|
2397
|
+
};
|
|
2398
|
+
startOfDay = (value) => {
|
|
2399
|
+
return this.adjustOffset(value.startOf("day"));
|
|
2400
|
+
};
|
|
2401
|
+
endOfYear = (value) => {
|
|
2402
|
+
return this.adjustOffset(value.endOf("year"));
|
|
2403
|
+
};
|
|
2404
|
+
endOfMonth = (value) => {
|
|
2405
|
+
return this.adjustOffset(value.endOf("month"));
|
|
2406
|
+
};
|
|
2407
|
+
endOfWeek = (value) => {
|
|
2408
|
+
return this.adjustOffset(this.setLocaleToValue(value).endOf("week"));
|
|
2409
|
+
};
|
|
2410
|
+
endOfDay = (value) => {
|
|
2411
|
+
return this.adjustOffset(value.endOf("day"));
|
|
2412
|
+
};
|
|
2413
|
+
addYears = (value, amount) => {
|
|
2414
|
+
return this.adjustOffset(value.add(amount, "year"));
|
|
2415
|
+
};
|
|
2416
|
+
addMonths = (value, amount) => {
|
|
2417
|
+
return this.adjustOffset(value.add(amount, "month"));
|
|
2418
|
+
};
|
|
2419
|
+
addWeeks = (value, amount) => {
|
|
2420
|
+
return this.adjustOffset(value.add(amount, "week"));
|
|
2421
|
+
};
|
|
2422
|
+
addDays = (value, amount) => {
|
|
2423
|
+
return this.adjustOffset(value.add(amount, "day"));
|
|
2424
|
+
};
|
|
2425
|
+
addHours = (value, amount) => {
|
|
2426
|
+
return this.adjustOffset(value.add(amount, "hour"));
|
|
2427
|
+
};
|
|
2428
|
+
addMinutes = (value, amount) => {
|
|
2429
|
+
return this.adjustOffset(value.add(amount, "minute"));
|
|
2430
|
+
};
|
|
2431
|
+
addSeconds = (value, amount) => {
|
|
2432
|
+
return this.adjustOffset(value.add(amount, "second"));
|
|
2433
|
+
};
|
|
2434
|
+
getYear = (value) => {
|
|
2435
|
+
return value.year();
|
|
2436
|
+
};
|
|
2437
|
+
getMonth = (value) => {
|
|
2438
|
+
return value.month();
|
|
2439
|
+
};
|
|
2440
|
+
getDate = (value) => {
|
|
2441
|
+
return value.date();
|
|
2442
|
+
};
|
|
2443
|
+
getHours = (value) => {
|
|
2444
|
+
return value.hour();
|
|
2445
|
+
};
|
|
2446
|
+
getMinutes = (value) => {
|
|
2447
|
+
return value.minute();
|
|
2448
|
+
};
|
|
2449
|
+
getSeconds = (value) => {
|
|
2450
|
+
return value.second();
|
|
2451
|
+
};
|
|
2452
|
+
getMilliseconds = (value) => {
|
|
2453
|
+
return value.millisecond();
|
|
2454
|
+
};
|
|
2455
|
+
setYear = (value, year) => {
|
|
2456
|
+
return this.adjustOffset(value.set("year", year));
|
|
2457
|
+
};
|
|
2458
|
+
setMonth = (value, month) => {
|
|
2459
|
+
return this.adjustOffset(value.set("month", month));
|
|
2460
|
+
};
|
|
2461
|
+
setDate = (value, date) => {
|
|
2462
|
+
return this.adjustOffset(value.set("date", date));
|
|
2463
|
+
};
|
|
2464
|
+
setHours = (value, hours) => {
|
|
2465
|
+
return this.adjustOffset(value.set("hour", hours));
|
|
2466
|
+
};
|
|
2467
|
+
setMinutes = (value, minutes) => {
|
|
2468
|
+
return this.adjustOffset(value.set("minute", minutes));
|
|
2469
|
+
};
|
|
2470
|
+
setSeconds = (value, seconds) => {
|
|
2471
|
+
return this.adjustOffset(value.set("second", seconds));
|
|
2472
|
+
};
|
|
2473
|
+
setMilliseconds = (value, milliseconds) => {
|
|
2474
|
+
return this.adjustOffset(value.set("millisecond", milliseconds));
|
|
2475
|
+
};
|
|
2476
|
+
getDaysInMonth = (value) => {
|
|
2477
|
+
return value.daysInMonth();
|
|
2478
|
+
};
|
|
2479
|
+
getWeekArray = (value) => {
|
|
2480
|
+
const start = this.startOfWeek(this.startOfMonth(value));
|
|
2481
|
+
const end = this.endOfWeek(this.endOfMonth(value));
|
|
2482
|
+
let count = 0;
|
|
2483
|
+
let current = start;
|
|
2484
|
+
const nestedWeeks = [];
|
|
2485
|
+
while (current < end) {
|
|
2486
|
+
const weekNumber = Math.floor(count / 7);
|
|
2487
|
+
nestedWeeks[weekNumber] = nestedWeeks[weekNumber] || [];
|
|
2488
|
+
nestedWeeks[weekNumber].push(current);
|
|
2489
|
+
current = this.addDays(current, 1);
|
|
2490
|
+
count += 1;
|
|
2491
|
+
}
|
|
2492
|
+
return nestedWeeks;
|
|
2493
|
+
};
|
|
2494
|
+
getWeekNumber = (value) => {
|
|
2495
|
+
return value.week();
|
|
2496
|
+
};
|
|
1866
2497
|
getDayOfWeek(value) {
|
|
1867
2498
|
return value.day() + 1;
|
|
1868
2499
|
}
|
|
2500
|
+
getYearRange = ([start, end]) => {
|
|
2501
|
+
const startDate = this.startOfYear(start);
|
|
2502
|
+
const endDate = this.endOfYear(end);
|
|
2503
|
+
const years = [];
|
|
2504
|
+
let current = startDate;
|
|
2505
|
+
while (this.isBefore(current, endDate)) {
|
|
2506
|
+
years.push(current);
|
|
2507
|
+
current = this.addYears(current, 1);
|
|
2508
|
+
}
|
|
2509
|
+
return years;
|
|
2510
|
+
};
|
|
1869
2511
|
};
|
|
1870
2512
|
|
|
1871
2513
|
// src/providers/LayoutProvider.tsx
|
|
1872
|
-
import {
|
|
1873
|
-
import {
|
|
1874
|
-
import { DashboardLayout } from "@toolpad/core/DashboardLayout";
|
|
1875
|
-
import { TanStackRouterAppProvider } from "@toolpad/core/tanstack-router";
|
|
1876
|
-
import { NotificationsProvider } from "@toolpad/core/useNotifications";
|
|
1877
|
-
import { useEffect, useState as useState2 } from "react";
|
|
1878
|
-
import { I18nextProvider, useTranslation as useTranslation5 } from "react-i18next";
|
|
2514
|
+
import { useEffect as useEffect6, useState as useState10 } from "react";
|
|
2515
|
+
import { I18nextProvider, useTranslation as useTranslation7 } from "react-i18next";
|
|
1879
2516
|
import * as z from "zod";
|
|
1880
2517
|
import { cs, en } from "zod/locales";
|
|
1881
2518
|
|
|
1882
|
-
// src/components/core/
|
|
1883
|
-
import
|
|
2519
|
+
// src/components/core/Layout.tsx
|
|
2520
|
+
import Menu3 from "@mui/icons-material/Menu";
|
|
2521
|
+
import MenuOpen from "@mui/icons-material/MenuOpen";
|
|
2522
|
+
import { AppBar, Box as Box9, CssBaseline, IconButton as IconButton5, InitColorSchemeScript, LinearProgress, Toolbar } from "@mui/material";
|
|
2523
|
+
import { ThemeProvider, styled as styled2 } from "@mui/material/styles";
|
|
2524
|
+
import { useIsFetching, useIsMutating } from "@tanstack/react-query";
|
|
2525
|
+
import useLocalStorageState from "use-local-storage-state";
|
|
1884
2526
|
|
|
1885
|
-
// src/
|
|
1886
|
-
import {
|
|
1887
|
-
|
|
1888
|
-
|
|
2527
|
+
// src/hooks/ThemeHook.ts
|
|
2528
|
+
import { createTheme, darken, lighten } from "@mui/material";
|
|
2529
|
+
import { grey as grey2 } from "@mui/material/colors";
|
|
2530
|
+
import { csCZ, enUS } from "@mui/material/locale";
|
|
2531
|
+
import { csCZ as dataGridCsCz, enUS as dataGridEnUs } from "@mui/x-data-grid-premium/locales";
|
|
2532
|
+
import { csCZ as datePickersCsCz, enUS as datePickersEnUs } from "@mui/x-date-pickers-pro/locales";
|
|
2533
|
+
import { useTranslation as useTranslation5 } from "react-i18next";
|
|
2534
|
+
var WISTRON_PRIMARY_COLOR = "#00506E";
|
|
2535
|
+
var WISTRON_SECONDARY_COLOR = "#64DC00";
|
|
2536
|
+
var useGetTheme = (theme) => {
|
|
2537
|
+
const { i18n: i18n2 } = useTranslation5();
|
|
2538
|
+
return createTheme(
|
|
2539
|
+
{
|
|
2540
|
+
cssVariables: {
|
|
2541
|
+
colorSchemeSelector: "data-mui-color-scheme"
|
|
2542
|
+
},
|
|
2543
|
+
colorSchemes: {
|
|
2544
|
+
light: {
|
|
2545
|
+
palette: {
|
|
2546
|
+
primary: { main: WISTRON_PRIMARY_COLOR },
|
|
2547
|
+
secondary: { main: WISTRON_SECONDARY_COLOR }
|
|
2548
|
+
}
|
|
2549
|
+
},
|
|
2550
|
+
dark: {
|
|
2551
|
+
palette: {
|
|
2552
|
+
primary: { main: lighten(WISTRON_PRIMARY_COLOR, 0.5) },
|
|
2553
|
+
secondary: { main: darken(WISTRON_SECONDARY_COLOR, 0.5) }
|
|
2554
|
+
}
|
|
2555
|
+
},
|
|
2556
|
+
...theme?.colorSchemes
|
|
2557
|
+
},
|
|
2558
|
+
components: {
|
|
2559
|
+
MuiCssBaseline: {
|
|
2560
|
+
styleOverrides: (theme2) => {
|
|
2561
|
+
return {
|
|
2562
|
+
body: {
|
|
2563
|
+
"&::-webkit-scrollbar, & *::-webkit-scrollbar": {
|
|
2564
|
+
width: "0.7em",
|
|
2565
|
+
height: "0.7em"
|
|
2566
|
+
},
|
|
2567
|
+
"&::-webkit-scrollbar-track, & *::-webkit-scrollbar-track": {
|
|
2568
|
+
backgroundColor: theme2.palette.mode === "dark" ? grey2[900] : grey2[200],
|
|
2569
|
+
borderRadius: "5px"
|
|
2570
|
+
},
|
|
2571
|
+
"&::-webkit-scrollbar-thumb, & *::-webkit-scrollbar-thumb": {
|
|
2572
|
+
backgroundColor: theme2.palette.mode === "dark" ? grey2[800] : grey2[400],
|
|
2573
|
+
borderRadius: "10px"
|
|
2574
|
+
},
|
|
2575
|
+
"&::-webkit-scrollbar-thumb:hover, & *::-webkit-scrollbar-thumb:hover": {
|
|
2576
|
+
backgroundColor: theme2.palette.mode === "dark" ? grey2[700] : grey2[500]
|
|
2577
|
+
},
|
|
2578
|
+
"&::-webkit-scrollbar-corner, & *::-webkit-scrollbar-corner": {
|
|
2579
|
+
backgroundColor: "transparent"
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
};
|
|
2583
|
+
}
|
|
2584
|
+
},
|
|
2585
|
+
...theme?.components
|
|
2586
|
+
}
|
|
2587
|
+
},
|
|
2588
|
+
i18n2.resolvedLanguage === "cs" ? datePickersCsCz : datePickersEnUs,
|
|
2589
|
+
i18n2.resolvedLanguage === "cs" ? dataGridCsCz : dataGridEnUs,
|
|
2590
|
+
i18n2.resolvedLanguage === "cs" ? csCZ : enUS
|
|
2591
|
+
);
|
|
2592
|
+
};
|
|
1889
2593
|
|
|
1890
|
-
// src/components/core/
|
|
1891
|
-
import {
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
2594
|
+
// src/components/core/navigation/NavigationRail.tsx
|
|
2595
|
+
import { useMediaQuery } from "@mui/material";
|
|
2596
|
+
import Box7 from "@mui/material/Box";
|
|
2597
|
+
import Drawer from "@mui/material/Drawer";
|
|
2598
|
+
import { useTheme as useTheme2 } from "@mui/material/styles";
|
|
2599
|
+
import { useNavigate, useRouterState as useRouterState2 } from "@tanstack/react-router";
|
|
2600
|
+
|
|
2601
|
+
// src/components/core/navigation/NavigationList.tsx
|
|
2602
|
+
import Divider3 from "@mui/material/Divider";
|
|
2603
|
+
import List3 from "@mui/material/List";
|
|
2604
|
+
import ListSubheader from "@mui/material/ListSubheader";
|
|
2605
|
+
import { Fragment as Fragment5, useEffect as useEffect5, useState as useState7 } from "react";
|
|
2606
|
+
|
|
2607
|
+
// src/components/core/navigation/NavigationListItem.tsx
|
|
2608
|
+
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
|
|
2609
|
+
import Avatar from "@mui/material/Avatar";
|
|
2610
|
+
import Box6 from "@mui/material/Box";
|
|
2611
|
+
import Popper from "@mui/material/Popper";
|
|
2612
|
+
import ListItem from "@mui/material/ListItem";
|
|
2613
|
+
import ListItemButton4 from "@mui/material/ListItemButton";
|
|
2614
|
+
import ListItemIcon3 from "@mui/material/ListItemIcon";
|
|
2615
|
+
import ListItemText3 from "@mui/material/ListItemText";
|
|
2616
|
+
import Paper2 from "@mui/material/Paper";
|
|
2617
|
+
import { styled } from "@mui/material/styles";
|
|
2618
|
+
import Typography7 from "@mui/material/Typography";
|
|
2619
|
+
import { Fragment as Fragment3, useMemo as useMemo3, useState as useState6 } from "react";
|
|
2620
|
+
import { Collapse } from "@mui/material";
|
|
2621
|
+
import { Fragment as Fragment4, jsx as jsx22, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
2622
|
+
var ICON_SIZE = 34;
|
|
2623
|
+
var StyledNavButton = styled(ListItemButton4)(({ theme }) => ({
|
|
2624
|
+
borderRadius: 8,
|
|
2625
|
+
"&.Mui-selected": {
|
|
2626
|
+
"& .MuiListItemIcon-root, & .MuiTypography-root, & .MuiSvgIcon-root": {
|
|
2627
|
+
color: (theme.vars ?? theme).palette.primary.dark
|
|
2628
|
+
},
|
|
2629
|
+
"& .MuiAvatar-root": {
|
|
2630
|
+
backgroundColor: (theme.vars ?? theme).palette.primary.dark
|
|
2631
|
+
},
|
|
2632
|
+
"& .MuiTouchRipple-child": {
|
|
2633
|
+
backgroundColor: (theme.vars ?? theme).palette.primary.dark
|
|
2634
|
+
}
|
|
2635
|
+
},
|
|
2636
|
+
"& .MuiSvgIcon-root": {
|
|
2637
|
+
color: (theme.vars ?? theme).palette.action.active
|
|
2638
|
+
},
|
|
2639
|
+
"& .MuiAvatar-root": {
|
|
2640
|
+
backgroundColor: (theme.vars ?? theme).palette.action.active
|
|
2641
|
+
}
|
|
2642
|
+
}));
|
|
2643
|
+
var StyledRouterButton = styled(RouterListItemButton)(({ theme }) => ({
|
|
2644
|
+
borderRadius: 8,
|
|
2645
|
+
"&.Mui-selected": {
|
|
2646
|
+
"& .MuiListItemIcon-root, & .MuiTypography-root, & .MuiSvgIcon-root": {
|
|
2647
|
+
color: (theme.vars ?? theme).palette.primary.dark
|
|
2648
|
+
},
|
|
2649
|
+
"& .MuiAvatar-root": {
|
|
2650
|
+
backgroundColor: (theme.vars ?? theme).palette.primary.dark
|
|
2651
|
+
},
|
|
2652
|
+
"& .MuiTouchRipple-child": {
|
|
2653
|
+
backgroundColor: (theme.vars ?? theme).palette.primary.dark
|
|
2654
|
+
}
|
|
2655
|
+
},
|
|
2656
|
+
"& .MuiSvgIcon-root": {
|
|
2657
|
+
color: (theme.vars ?? theme).palette.action.active
|
|
2658
|
+
},
|
|
2659
|
+
"& .MuiAvatar-root": {
|
|
2660
|
+
backgroundColor: (theme.vars ?? theme).palette.action.active
|
|
2661
|
+
}
|
|
2662
|
+
}));
|
|
2663
|
+
var IconOrAvatar = ({ item, collapsed }) => {
|
|
2664
|
+
if (item.icon || collapsed) {
|
|
2665
|
+
return /* @__PURE__ */ jsxs12(Box6, { sx: collapsed ? { position: "absolute", left: "50%", top: "calc(50% - 6px)", transform: "translate(-50%, -50%)" } : {}, children: [
|
|
2666
|
+
/* @__PURE__ */ jsxs12(ListItemIcon3, { sx: { display: "flex", alignItems: "center", justifyContent: "center", minWidth: ICON_SIZE }, children: [
|
|
2667
|
+
item.icon ?? null,
|
|
2668
|
+
!item.icon && collapsed ? /* @__PURE__ */ jsx22(Avatar, { sx: { width: ICON_SIZE - 7, height: ICON_SIZE - 7, fontSize: 12 }, children: item.title }) : null
|
|
2669
|
+
] }),
|
|
2670
|
+
collapsed ? /* @__PURE__ */ jsx22(
|
|
2671
|
+
Typography7,
|
|
2672
|
+
{
|
|
2673
|
+
variant: "caption",
|
|
2674
|
+
sx: {
|
|
2675
|
+
position: "absolute",
|
|
2676
|
+
bottom: -18,
|
|
2677
|
+
left: "50%",
|
|
2678
|
+
transform: "translateX(-50%)",
|
|
2679
|
+
fontSize: 10,
|
|
2680
|
+
fontWeight: 500,
|
|
2681
|
+
textAlign: "center",
|
|
2682
|
+
whiteSpace: "nowrap",
|
|
2683
|
+
overflow: "hidden",
|
|
2684
|
+
textOverflow: "ellipsis",
|
|
2685
|
+
maxWidth: MINI_WIDTH - 28
|
|
2686
|
+
},
|
|
2687
|
+
children: item.title
|
|
2688
|
+
}
|
|
2689
|
+
) : null
|
|
2690
|
+
] });
|
|
2691
|
+
}
|
|
2692
|
+
return null;
|
|
2693
|
+
};
|
|
2694
|
+
var MiniPopover = ({ open, anchorEl, children }) => /* @__PURE__ */ jsx22(
|
|
2695
|
+
Popper,
|
|
2696
|
+
{
|
|
2697
|
+
open,
|
|
2698
|
+
anchorEl,
|
|
2699
|
+
placement: "right-start",
|
|
2700
|
+
modifiers: [
|
|
2701
|
+
{ name: "offset", options: { offset: [6, 0] } },
|
|
2702
|
+
{ name: "preventOverflow", options: { padding: 8 } },
|
|
2703
|
+
{ name: "flip", options: { fallbackPlacements: ["right-end", "left-start"] } }
|
|
2704
|
+
],
|
|
2705
|
+
children: /* @__PURE__ */ jsx22(
|
|
2706
|
+
Paper2,
|
|
2707
|
+
{
|
|
2708
|
+
sx: {
|
|
2709
|
+
pt: 0.5,
|
|
2710
|
+
pb: 0.5,
|
|
2711
|
+
maxHeight: "min(calc(100vh - 100px), 560px)",
|
|
2712
|
+
overflowY: "auto",
|
|
2713
|
+
overscrollBehavior: "contain"
|
|
2714
|
+
},
|
|
2715
|
+
children
|
|
2716
|
+
}
|
|
2717
|
+
)
|
|
2718
|
+
}
|
|
2719
|
+
);
|
|
2720
|
+
var NavigationListItem = ({ item, isOpen, selected, disabled, collapsed, isSidebarFullyExpanded = true, isSidebarFullyCollapsed, onClick, renderNested }) => {
|
|
2721
|
+
const [hoveredPopoverItem, setHoveredPopoverItem] = useState6(null);
|
|
2722
|
+
const [anchorElement, setAnchorElement] = useState6(null);
|
|
2723
|
+
const chevronSx = useMemo3(() => {
|
|
2724
|
+
if (collapsed && isSidebarFullyCollapsed && item.children) {
|
|
2725
|
+
return {
|
|
2726
|
+
fontSize: 18,
|
|
2727
|
+
position: "absolute",
|
|
2728
|
+
top: "41.5%",
|
|
2729
|
+
right: "2px",
|
|
2730
|
+
transform: "translateY(-50%) rotate(-90deg)"
|
|
2731
|
+
};
|
|
2732
|
+
}
|
|
2733
|
+
if (!collapsed && isSidebarFullyExpanded && item.children) {
|
|
2734
|
+
return {
|
|
2735
|
+
ml: 0.5,
|
|
2736
|
+
transform: `rotate(${isOpen ? 0 : -90}deg)`
|
|
2737
|
+
};
|
|
2738
|
+
}
|
|
2739
|
+
return { display: "none" };
|
|
2740
|
+
}, [collapsed, isSidebarFullyExpanded, isSidebarFullyCollapsed, isOpen, item.children]);
|
|
2741
|
+
const shouldJustExpand = item.children && !collapsed;
|
|
2742
|
+
const buttonProps = {
|
|
2743
|
+
selected,
|
|
2744
|
+
disabled,
|
|
2745
|
+
sx: { px: 1.4, height: collapsed ? 60 : 48 }
|
|
2746
|
+
};
|
|
2747
|
+
const buttonContent = /* @__PURE__ */ jsxs12(Fragment4, { children: [
|
|
2748
|
+
/* @__PURE__ */ jsx22(IconOrAvatar, { item, collapsed }),
|
|
2749
|
+
!collapsed && /* @__PURE__ */ jsx22(
|
|
2750
|
+
ListItemText3,
|
|
2751
|
+
{
|
|
2752
|
+
primary: item.title,
|
|
2753
|
+
slotProps: { primary: { noWrap: true, title: item.title } },
|
|
2754
|
+
sx: { ml: 1.2, flex: 1, minWidth: 0, "& .MuiTypography-root": { whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }
|
|
2755
|
+
}
|
|
2756
|
+
),
|
|
2757
|
+
item.children ? /* @__PURE__ */ jsx22(ExpandMoreIcon, { sx: chevronSx }) : null
|
|
1898
2758
|
] });
|
|
2759
|
+
const listItem = /* @__PURE__ */ jsxs12(
|
|
2760
|
+
ListItem,
|
|
2761
|
+
{
|
|
2762
|
+
...item.children && collapsed ? {
|
|
2763
|
+
onMouseEnter: (event) => {
|
|
2764
|
+
setAnchorElement(event.currentTarget);
|
|
2765
|
+
setHoveredPopoverItem(item.title);
|
|
2766
|
+
},
|
|
2767
|
+
onMouseLeave: () => {
|
|
2768
|
+
setHoveredPopoverItem(null);
|
|
2769
|
+
}
|
|
2770
|
+
} : {},
|
|
2771
|
+
sx: { py: 0, px: 1, overflowX: "hidden" },
|
|
2772
|
+
children: [
|
|
2773
|
+
shouldJustExpand ? /* @__PURE__ */ jsx22(StyledNavButton, { ...buttonProps, onClick: () => onClick?.(item), children: buttonContent }) : /* @__PURE__ */ jsx22(
|
|
2774
|
+
StyledRouterButton,
|
|
2775
|
+
{
|
|
2776
|
+
...buttonProps,
|
|
2777
|
+
to: item.to,
|
|
2778
|
+
href: item.href,
|
|
2779
|
+
params: item.params,
|
|
2780
|
+
search: item.search,
|
|
2781
|
+
children: buttonContent
|
|
2782
|
+
}
|
|
2783
|
+
),
|
|
2784
|
+
item.children && collapsed ? /* @__PURE__ */ jsx22(MiniPopover, { open: item.title === hoveredPopoverItem, anchorEl: anchorElement, children: renderNested?.(item.children) }) : null
|
|
2785
|
+
]
|
|
2786
|
+
}
|
|
2787
|
+
);
|
|
2788
|
+
return /* @__PURE__ */ jsxs12(Fragment3, { children: [
|
|
2789
|
+
listItem,
|
|
2790
|
+
item.children && !collapsed ? /* @__PURE__ */ jsx22(Collapse, { in: isOpen, timeout: "auto", unmountOnExit: true, children: renderNested?.(item.children) }) : null
|
|
2791
|
+
] }, item.to);
|
|
2792
|
+
};
|
|
2793
|
+
|
|
2794
|
+
// src/components/core/navigation/NavigationList.tsx
|
|
2795
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
2796
|
+
var isPageItem = (item) => !("kind" in item);
|
|
2797
|
+
var isDivider = (item) => "kind" in item && item.kind === "divider";
|
|
2798
|
+
var isHeader = (item) => "kind" in item && item.kind === "header";
|
|
2799
|
+
var NavigationList = ({ subNavigation, depth = 0, collapsed, isPopover, isSidebarFullyExpanded = true, isSidebarFullyCollapsed, expandedWidth, renderItem, activePath, onNavigate }) => {
|
|
2800
|
+
const [openKeys, setOpenKeys] = useState7([]);
|
|
2801
|
+
useEffect5(() => {
|
|
2802
|
+
if (collapsed) setOpenKeys([]);
|
|
2803
|
+
}, [collapsed]);
|
|
2804
|
+
const toggleKey = (key) => setOpenKeys((previous) => previous.includes(key) ? previous.filter((k) => k !== key) : [...previous, key]);
|
|
2805
|
+
const renderNested = (children) => /* @__PURE__ */ jsx23(
|
|
2806
|
+
NavigationList,
|
|
2807
|
+
{
|
|
2808
|
+
subNavigation: children,
|
|
2809
|
+
depth: depth + 1,
|
|
2810
|
+
isPopover: collapsed,
|
|
2811
|
+
expandedWidth,
|
|
2812
|
+
activePath,
|
|
2813
|
+
onNavigate
|
|
2814
|
+
}
|
|
2815
|
+
);
|
|
2816
|
+
const filteredNavigation = subNavigation.filter((nav) => !nav.hidden);
|
|
2817
|
+
return /* @__PURE__ */ jsx23(
|
|
2818
|
+
List3,
|
|
2819
|
+
{
|
|
2820
|
+
sx: {
|
|
2821
|
+
padding: 0,
|
|
2822
|
+
mt: isPopover && depth === 1 ? 0.5 : 0,
|
|
2823
|
+
mb: depth === 0 && !isPopover ? 4 : 0.5,
|
|
2824
|
+
pl: (isPopover ? 1 : 2) * (isPopover ? depth - 1 : depth),
|
|
2825
|
+
minWidth: isPopover && depth === 1 ? EXPANDED_WIDTH : "auto",
|
|
2826
|
+
width: collapsed ? MINI_WIDTH : "auto"
|
|
2827
|
+
},
|
|
2828
|
+
children: filteredNavigation.map((navItem, index) => {
|
|
2829
|
+
if (isHeader(navItem)) {
|
|
2830
|
+
return /* @__PURE__ */ jsx23(
|
|
2831
|
+
ListSubheader,
|
|
2832
|
+
{
|
|
2833
|
+
sx: {
|
|
2834
|
+
fontSize: 12,
|
|
2835
|
+
fontWeight: "700",
|
|
2836
|
+
height: collapsed ? 0 : 40,
|
|
2837
|
+
px: 2,
|
|
2838
|
+
minWidth: expandedWidth,
|
|
2839
|
+
overflow: "hidden",
|
|
2840
|
+
textOverflow: "ellipsis",
|
|
2841
|
+
whiteSpace: "nowrap",
|
|
2842
|
+
zIndex: 2,
|
|
2843
|
+
bgcolor: "transparent",
|
|
2844
|
+
position: "static"
|
|
2845
|
+
},
|
|
2846
|
+
children: navItem.title
|
|
2847
|
+
},
|
|
2848
|
+
`subheader-${depth}-${index}`
|
|
2849
|
+
);
|
|
2850
|
+
}
|
|
2851
|
+
if (isDivider(navItem)) {
|
|
2852
|
+
const nextItem = filteredNavigation[index + 1];
|
|
2853
|
+
return /* @__PURE__ */ jsx23("li", { children: /* @__PURE__ */ jsx23(Divider3, { sx: { mx: 1, mt: 1, mb: nextItem && isHeader(nextItem) && !collapsed ? 0 : 1 } }) }, `divider-${depth}-${index}`);
|
|
2854
|
+
}
|
|
2855
|
+
if (!isPageItem(navItem)) return null;
|
|
2856
|
+
const key = `item-${depth}-${index}`;
|
|
2857
|
+
const uniqueItemKey = `${depth}-${index}-${navItem.title}`;
|
|
2858
|
+
if (renderItem) return /* @__PURE__ */ jsx23(Fragment5, { children: renderItem(navItem, { collapsed: !!collapsed }) }, key);
|
|
2859
|
+
return /* @__PURE__ */ jsx23(
|
|
2860
|
+
NavigationListItem,
|
|
2861
|
+
{
|
|
2862
|
+
item: navItem,
|
|
2863
|
+
isOpen: openKeys.includes(uniqueItemKey),
|
|
2864
|
+
selected: activePath === navItem.to,
|
|
2865
|
+
collapsed,
|
|
2866
|
+
isSidebarFullyExpanded,
|
|
2867
|
+
isSidebarFullyCollapsed,
|
|
2868
|
+
onClick: navItem.children && !collapsed ? () => toggleKey(uniqueItemKey) : void 0,
|
|
2869
|
+
renderNested
|
|
2870
|
+
},
|
|
2871
|
+
key
|
|
2872
|
+
);
|
|
2873
|
+
})
|
|
2874
|
+
}
|
|
2875
|
+
);
|
|
2876
|
+
};
|
|
2877
|
+
|
|
2878
|
+
// src/components/core/navigation/NavigationRail.tsx
|
|
2879
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
2880
|
+
var MINI_WIDTH = 84;
|
|
2881
|
+
var EXPANDED_WIDTH = 320;
|
|
2882
|
+
var TOOLBAR_HEIGHT = 65;
|
|
2883
|
+
var NavigationRail = ({ navigation, expanded, setExpanded }) => {
|
|
2884
|
+
const navigate = useNavigate();
|
|
2885
|
+
const routerState = useRouterState2();
|
|
2886
|
+
const theme = useTheme2();
|
|
2887
|
+
const showPermanent = useMediaQuery(theme.breakpoints.up("sm"));
|
|
2888
|
+
const drawerContent = (collapsed) => /* @__PURE__ */ jsx24(
|
|
2889
|
+
Box7,
|
|
2890
|
+
{
|
|
2891
|
+
component: "nav",
|
|
2892
|
+
sx: {
|
|
2893
|
+
height: "100%",
|
|
2894
|
+
display: "flex",
|
|
2895
|
+
flexDirection: "column",
|
|
2896
|
+
justifyContent: "space-between",
|
|
2897
|
+
overflow: "auto",
|
|
2898
|
+
scrollbarGutter: collapsed ? "stable" : "auto",
|
|
2899
|
+
overflowX: "hidden",
|
|
2900
|
+
pt: navigation[0] && isHeader(navigation[0]) && !collapsed ? 0 : 2
|
|
2901
|
+
},
|
|
2902
|
+
children: /* @__PURE__ */ jsx24(
|
|
2903
|
+
NavigationList,
|
|
2904
|
+
{
|
|
2905
|
+
subNavigation: navigation,
|
|
2906
|
+
collapsed,
|
|
2907
|
+
isSidebarFullyExpanded: expanded,
|
|
2908
|
+
isSidebarFullyCollapsed: !expanded,
|
|
2909
|
+
expandedWidth: EXPANDED_WIDTH,
|
|
2910
|
+
activePath: routerState.location.pathname,
|
|
2911
|
+
onNavigate: navigate
|
|
2912
|
+
}
|
|
2913
|
+
)
|
|
2914
|
+
}
|
|
2915
|
+
);
|
|
2916
|
+
if (showPermanent)
|
|
2917
|
+
return /* @__PURE__ */ jsx24(
|
|
2918
|
+
Drawer,
|
|
2919
|
+
{
|
|
2920
|
+
variant: "permanent",
|
|
2921
|
+
sx: {
|
|
2922
|
+
width: expanded ? EXPANDED_WIDTH : MINI_WIDTH,
|
|
2923
|
+
["& .MuiDrawer-paper"]: {
|
|
2924
|
+
position: "absolute",
|
|
2925
|
+
top: `${TOOLBAR_HEIGHT}px`,
|
|
2926
|
+
height: `calc(100% - ${TOOLBAR_HEIGHT}px)`,
|
|
2927
|
+
width: expanded ? EXPANDED_WIDTH : MINI_WIDTH
|
|
2928
|
+
}
|
|
2929
|
+
},
|
|
2930
|
+
children: drawerContent(!expanded)
|
|
2931
|
+
}
|
|
2932
|
+
);
|
|
2933
|
+
return /* @__PURE__ */ jsx24(Drawer, { open: expanded, onClose: () => setExpanded(false), children: drawerContent(!expanded) });
|
|
1899
2934
|
};
|
|
1900
2935
|
|
|
1901
2936
|
// src/components/core/ToolbarAccount.tsx
|
|
@@ -1909,9 +2944,9 @@ import Login from "@mui/icons-material/Login";
|
|
|
1909
2944
|
import Logout from "@mui/icons-material/Logout";
|
|
1910
2945
|
import SettingsBrightness from "@mui/icons-material/SettingsBrightness";
|
|
1911
2946
|
import Translate from "@mui/icons-material/Translate";
|
|
1912
|
-
import { Avatar, Box as
|
|
1913
|
-
import { Fragment, useState } from "react";
|
|
1914
|
-
import { useTranslation as
|
|
2947
|
+
import { Avatar as Avatar2, Box as Box8, IconButton as IconButton4, List as List4, ListItem as ListItem2, ListItemButton as ListItemButton5, ListItemIcon as ListItemIcon4, ListItemText as ListItemText4, ListSubheader as ListSubheader2, Menu as Menu2, Typography as Typography8, useColorScheme } from "@mui/material";
|
|
2948
|
+
import { Fragment as Fragment6, useState as useState8 } from "react";
|
|
2949
|
+
import { useTranslation as useTranslation6 } from "react-i18next";
|
|
1915
2950
|
|
|
1916
2951
|
// src/auth-test/keycloak.ts
|
|
1917
2952
|
import { useRouter } from "@tanstack/react-router";
|
|
@@ -1931,12 +2966,12 @@ function useKeycloak() {
|
|
|
1931
2966
|
}
|
|
1932
2967
|
|
|
1933
2968
|
// src/components/core/ToolbarAccount.tsx
|
|
1934
|
-
import { jsx as
|
|
2969
|
+
import { jsx as jsx25, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1935
2970
|
var ToolbarAccount = () => {
|
|
1936
|
-
const [anchorElement, setAnchorElement] =
|
|
1937
|
-
const [tab, setTab] =
|
|
2971
|
+
const [anchorElement, setAnchorElement] = useState8();
|
|
2972
|
+
const [tab, setTab] = useState8("settings");
|
|
1938
2973
|
const open = Boolean(anchorElement);
|
|
1939
|
-
const { t: t2, i18n: i18n2 } =
|
|
2974
|
+
const { t: t2, i18n: i18n2 } = useTranslation6();
|
|
1940
2975
|
const { mode, setMode } = useColorScheme();
|
|
1941
2976
|
const changeLanguage = (newLanguage) => () => {
|
|
1942
2977
|
i18n2.changeLanguage(newLanguage).finally(() => closeMenu());
|
|
@@ -1971,160 +3006,124 @@ var ToolbarAccount = () => {
|
|
|
1971
3006
|
setTimeout(() => setTab("settings"), 300);
|
|
1972
3007
|
};
|
|
1973
3008
|
const changeTab = (newTab) => () => setTab(newTab);
|
|
1974
|
-
const settings = /* @__PURE__ */
|
|
1975
|
-
/* @__PURE__ */
|
|
1976
|
-
/* @__PURE__ */
|
|
1977
|
-
/* @__PURE__ */
|
|
1978
|
-
/* @__PURE__ */
|
|
3009
|
+
const settings = /* @__PURE__ */ jsxs13(List4, { component: "nav", subheader: /* @__PURE__ */ jsx25(ListSubheader2, { sx: { backgroundColor: "transparent" }, children: t2("Layout.Settings") }), children: [
|
|
3010
|
+
/* @__PURE__ */ jsxs13(ListItemButton5, { onClick: changeTab("theme"), sx: { py: 0.3 }, children: [
|
|
3011
|
+
/* @__PURE__ */ jsx25(ListItemIcon4, { children: /* @__PURE__ */ jsx25(Brightness4, {}) }),
|
|
3012
|
+
/* @__PURE__ */ jsx25(ListItemText4, { primary: t2("Layout.Appearance"), secondary: getModeText() }),
|
|
3013
|
+
/* @__PURE__ */ jsx25(ChevronRight, {})
|
|
1979
3014
|
] }),
|
|
1980
|
-
/* @__PURE__ */
|
|
1981
|
-
/* @__PURE__ */
|
|
1982
|
-
/* @__PURE__ */
|
|
1983
|
-
/* @__PURE__ */
|
|
3015
|
+
/* @__PURE__ */ jsxs13(ListItemButton5, { onClick: changeTab("language"), sx: { py: 0.3 }, children: [
|
|
3016
|
+
/* @__PURE__ */ jsx25(ListItemIcon4, { children: /* @__PURE__ */ jsx25(Translate, {}) }),
|
|
3017
|
+
/* @__PURE__ */ jsx25(ListItemText4, { primary: t2("Layout.Language"), secondary: i18n2.resolvedLanguage === "en" ? "English" : "\u010Ce\u0161tina" }),
|
|
3018
|
+
/* @__PURE__ */ jsx25(ChevronRight, {})
|
|
1984
3019
|
] })
|
|
1985
3020
|
] });
|
|
1986
|
-
const theme = /* @__PURE__ */
|
|
1987
|
-
/* @__PURE__ */
|
|
3021
|
+
const theme = /* @__PURE__ */ jsxs13(List4, { subheader: /* @__PURE__ */ jsxs13(ListSubheader2, { onClick: changeTab("settings"), sx: { backgroundColor: "transparent", display: "flex", alignItems: "center", px: 1, cursor: "pointer" }, children: [
|
|
3022
|
+
/* @__PURE__ */ jsx25(IconButton4, { size: "small", sx: { mr: 0.5 }, children: /* @__PURE__ */ jsx25(ArrowBack, { fontSize: "small" }) }),
|
|
1988
3023
|
" ",
|
|
1989
3024
|
t2("Layout.Appearance")
|
|
1990
3025
|
] }), children: [
|
|
1991
|
-
/* @__PURE__ */
|
|
1992
|
-
/* @__PURE__ */
|
|
1993
|
-
/* @__PURE__ */
|
|
3026
|
+
/* @__PURE__ */ jsxs13(ListItemButton5, { onClick: changeMode("light"), disabled: mode === "light", children: [
|
|
3027
|
+
/* @__PURE__ */ jsx25(ListItemIcon4, { children: /* @__PURE__ */ jsx25(LightMode, {}) }),
|
|
3028
|
+
/* @__PURE__ */ jsx25(ListItemText4, { primary: t2("Layout.Light") })
|
|
1994
3029
|
] }),
|
|
1995
|
-
/* @__PURE__ */
|
|
1996
|
-
/* @__PURE__ */
|
|
1997
|
-
/* @__PURE__ */
|
|
3030
|
+
/* @__PURE__ */ jsxs13(ListItemButton5, { onClick: changeMode("dark"), disabled: mode === "dark", children: [
|
|
3031
|
+
/* @__PURE__ */ jsx25(ListItemIcon4, { children: /* @__PURE__ */ jsx25(DarkMode, {}) }),
|
|
3032
|
+
/* @__PURE__ */ jsx25(ListItemText4, { primary: t2("Layout.Dark") })
|
|
1998
3033
|
] }),
|
|
1999
|
-
/* @__PURE__ */
|
|
2000
|
-
/* @__PURE__ */
|
|
2001
|
-
/* @__PURE__ */
|
|
3034
|
+
/* @__PURE__ */ jsxs13(ListItemButton5, { onClick: changeMode("system"), disabled: mode === "system", children: [
|
|
3035
|
+
/* @__PURE__ */ jsx25(ListItemIcon4, { children: /* @__PURE__ */ jsx25(SettingsBrightness, {}) }),
|
|
3036
|
+
/* @__PURE__ */ jsx25(ListItemText4, { primary: t2("Layout.System") })
|
|
2002
3037
|
] })
|
|
2003
3038
|
] });
|
|
2004
|
-
const language = /* @__PURE__ */
|
|
2005
|
-
/* @__PURE__ */
|
|
3039
|
+
const language = /* @__PURE__ */ jsxs13(List4, { subheader: /* @__PURE__ */ jsxs13(ListSubheader2, { onClick: changeTab("settings"), sx: { backgroundColor: "transparent", display: "flex", alignItems: "center", px: 1, cursor: "pointer" }, children: [
|
|
3040
|
+
/* @__PURE__ */ jsx25(IconButton4, { size: "small", sx: { mr: 0.5 }, children: /* @__PURE__ */ jsx25(ArrowBack, { fontSize: "small" }) }),
|
|
2006
3041
|
" ",
|
|
2007
3042
|
t2("Layout.Language")
|
|
2008
3043
|
] }), children: [
|
|
2009
|
-
/* @__PURE__ */
|
|
2010
|
-
/* @__PURE__ */
|
|
3044
|
+
/* @__PURE__ */ jsx25(ListItemButton5, { onClick: changeLanguage("en"), disabled: i18n2.resolvedLanguage === "en", children: /* @__PURE__ */ jsx25(ListItemText4, { primary: "English" }) }),
|
|
3045
|
+
/* @__PURE__ */ jsx25(ListItemButton5, { onClick: changeLanguage("cs"), disabled: i18n2.resolvedLanguage === "cs", children: /* @__PURE__ */ jsx25(ListItemText4, { primary: "\u010Ce\u0161tina" }) })
|
|
2011
3046
|
] });
|
|
2012
|
-
return /* @__PURE__ */
|
|
2013
|
-
/* @__PURE__ */
|
|
2014
|
-
/* @__PURE__ */
|
|
2015
|
-
/* @__PURE__ */
|
|
2016
|
-
/* @__PURE__ */
|
|
2017
|
-
/* @__PURE__ */
|
|
2018
|
-
/* @__PURE__ */
|
|
2019
|
-
/* @__PURE__ */
|
|
3047
|
+
return /* @__PURE__ */ jsxs13(Fragment6, { children: [
|
|
3048
|
+
/* @__PURE__ */ jsx25(IconButton4, { size: "small", edge: "end", onClick: openMenu, children: user?.name ? /* @__PURE__ */ jsx25(Avatar2, { sx: { width: { xs: 32, sm: 40 }, height: { xs: 32, sm: 40 }, bgcolor: "primary.main" }, children: /* @__PURE__ */ jsx25(Typography8, { variant: "subtitle2", sx: { fontWeight: "bold", lineHeight: 0 }, children: usernameInitials() }) }) : /* @__PURE__ */ jsx25(AccountCircle, { fontSize: "large" }) }),
|
|
3049
|
+
/* @__PURE__ */ jsx25(Menu2, { anchorEl: anchorElement, open, onClose: closeMenu, children: /* @__PURE__ */ jsxs13(Box8, { sx: { width: 240 }, children: [
|
|
3050
|
+
/* @__PURE__ */ jsx25(List4, { children: user?.name ? /* @__PURE__ */ jsxs13(Fragment6, { children: [
|
|
3051
|
+
/* @__PURE__ */ jsx25(ListItem2, { children: /* @__PURE__ */ jsx25(ListItemText4, { primary: user.name, secondary: /* @__PURE__ */ jsxs13("span", { children: [
|
|
3052
|
+
/* @__PURE__ */ jsx25("span", { children: user.employeeId }),
|
|
3053
|
+
/* @__PURE__ */ jsx25("br", {}),
|
|
3054
|
+
/* @__PURE__ */ jsx25("span", { children: user.department })
|
|
2020
3055
|
] }) }) }),
|
|
2021
|
-
/* @__PURE__ */
|
|
2022
|
-
/* @__PURE__ */
|
|
2023
|
-
/* @__PURE__ */
|
|
3056
|
+
/* @__PURE__ */ jsxs13(ListItemButton5, { onClick: () => keycloak.logout(), children: [
|
|
3057
|
+
/* @__PURE__ */ jsx25(ListItemIcon4, { children: /* @__PURE__ */ jsx25(Logout, { color: "error" }) }),
|
|
3058
|
+
/* @__PURE__ */ jsx25(ListItemText4, { primary: t2("Layout.Logout") })
|
|
2024
3059
|
] })
|
|
2025
|
-
] }) : /* @__PURE__ */
|
|
2026
|
-
/* @__PURE__ */
|
|
2027
|
-
/* @__PURE__ */
|
|
3060
|
+
] }) : /* @__PURE__ */ jsxs13(ListItemButton5, { onClick: () => keycloak.login(), children: [
|
|
3061
|
+
/* @__PURE__ */ jsx25(ListItemIcon4, { children: /* @__PURE__ */ jsx25(Login, { color: "success" }) }),
|
|
3062
|
+
/* @__PURE__ */ jsx25(ListItemText4, { primary: t2("Layout.LogIn") })
|
|
2028
3063
|
] }) }),
|
|
2029
3064
|
tab === "settings" && settings,
|
|
2030
3065
|
tab === "theme" && theme,
|
|
2031
3066
|
tab === "language" && language
|
|
2032
3067
|
] }) })
|
|
2033
|
-
] });
|
|
2034
|
-
};
|
|
2035
|
-
|
|
2036
|
-
// src/
|
|
2037
|
-
import {
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
var
|
|
2046
|
-
const
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
}
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
body: {
|
|
2072
|
-
"&::-webkit-scrollbar, & *::-webkit-scrollbar": {
|
|
2073
|
-
width: "0.7em",
|
|
2074
|
-
height: "0.7em"
|
|
2075
|
-
},
|
|
2076
|
-
"&::-webkit-scrollbar-track, & *::-webkit-scrollbar-track": {
|
|
2077
|
-
backgroundColor: theme2.palette.mode === "dark" ? grey[900] : grey[200],
|
|
2078
|
-
borderRadius: "5px"
|
|
2079
|
-
},
|
|
2080
|
-
"&::-webkit-scrollbar-thumb, & *::-webkit-scrollbar-thumb": {
|
|
2081
|
-
backgroundColor: theme2.palette.mode === "dark" ? grey[800] : grey[400],
|
|
2082
|
-
borderRadius: "10px"
|
|
2083
|
-
},
|
|
2084
|
-
"&::-webkit-scrollbar-thumb:hover, & *::-webkit-scrollbar-thumb:hover": {
|
|
2085
|
-
backgroundColor: theme2.palette.mode === "dark" ? grey[700] : grey[500]
|
|
2086
|
-
},
|
|
2087
|
-
"&::-webkit-scrollbar-corner, & *::-webkit-scrollbar-corner": {
|
|
2088
|
-
backgroundColor: "transparent"
|
|
2089
|
-
}
|
|
2090
|
-
}
|
|
2091
|
-
};
|
|
2092
|
-
}
|
|
2093
|
-
},
|
|
2094
|
-
MuiTableContainer: {
|
|
2095
|
-
styleOverrides: {
|
|
2096
|
-
root: ({ theme: theme2 }) => ({
|
|
2097
|
-
flexGrow: 1,
|
|
2098
|
-
"& .MuiDataGrid-cell--editing": {
|
|
2099
|
-
"& .MuiInputBase-root": {
|
|
2100
|
-
height: "100%"
|
|
2101
|
-
}
|
|
2102
|
-
},
|
|
2103
|
-
"& .MuiDataGrid-columnHeaderTitle": {
|
|
2104
|
-
fontWeight: 600
|
|
2105
|
-
},
|
|
2106
|
-
"& .Mui-error": {
|
|
2107
|
-
backgroundColor: theme2.palette.error.main,
|
|
2108
|
-
color: theme2.palette.error.contrastText
|
|
2109
|
-
},
|
|
2110
|
-
"& .MuiDataGrid-booleanCell[data-value='true']": {
|
|
2111
|
-
color: `${theme2.palette.success.main} !important`
|
|
2112
|
-
},
|
|
2113
|
-
"& .MuiDataGrid-booleanCell[data-value='false']": {
|
|
2114
|
-
color: `${theme2.palette.error.main} !important`
|
|
3068
|
+
] });
|
|
3069
|
+
};
|
|
3070
|
+
|
|
3071
|
+
// src/components/core/Layout.tsx
|
|
3072
|
+
import { jsx as jsx26, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3073
|
+
var DrawerHeader = styled2("div")(({ theme }) => ({
|
|
3074
|
+
display: "flex",
|
|
3075
|
+
alignItems: "center",
|
|
3076
|
+
justifyContent: "flex-end",
|
|
3077
|
+
padding: theme.spacing(0, 1),
|
|
3078
|
+
...theme.mixins.toolbar
|
|
3079
|
+
}));
|
|
3080
|
+
var Layout = (props) => {
|
|
3081
|
+
const theme = useGetTheme(props.theme);
|
|
3082
|
+
const [navigationOpen, setNavigationOpen] = useLocalStorageState("navigationOpen", { defaultServerValue: false });
|
|
3083
|
+
const isFetching = !!useIsFetching();
|
|
3084
|
+
const isMutating = !!useIsMutating();
|
|
3085
|
+
return /* @__PURE__ */ jsxs14(ThemeProvider, { theme, children: [
|
|
3086
|
+
/* @__PURE__ */ jsx26(InitColorSchemeScript, {}),
|
|
3087
|
+
/* @__PURE__ */ jsx26(CssBaseline, {}),
|
|
3088
|
+
/* @__PURE__ */ jsxs14(Box9, { sx: { display: "flex", height: "100dvh", maxHeight: "100dvh", overflow: "hidden", width: "100%" }, children: [
|
|
3089
|
+
/* @__PURE__ */ jsx26(
|
|
3090
|
+
AppBar,
|
|
3091
|
+
{
|
|
3092
|
+
color: "transparent",
|
|
3093
|
+
position: "fixed",
|
|
3094
|
+
sx: {
|
|
3095
|
+
borderBottom: "1px solid",
|
|
3096
|
+
borderColor: theme.vars?.palette.divider,
|
|
3097
|
+
boxShadow: "none"
|
|
3098
|
+
},
|
|
3099
|
+
children: /* @__PURE__ */ jsxs14(Toolbar, { children: [
|
|
3100
|
+
props.navigation && /* @__PURE__ */ jsx26(
|
|
3101
|
+
IconButton5,
|
|
3102
|
+
{
|
|
3103
|
+
onClick: () => setNavigationOpen((previous) => !previous),
|
|
3104
|
+
sx: { marginRight: 2 },
|
|
3105
|
+
children: navigationOpen ? /* @__PURE__ */ jsx26(MenuOpen, {}) : /* @__PURE__ */ jsx26(Menu3, {})
|
|
2115
3106
|
}
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
3107
|
+
),
|
|
3108
|
+
/* @__PURE__ */ jsx26(AppTitle, {}),
|
|
3109
|
+
/* @__PURE__ */ jsx26(ToolbarAccount, {})
|
|
3110
|
+
] })
|
|
3111
|
+
}
|
|
3112
|
+
),
|
|
3113
|
+
props.navigation && /* @__PURE__ */ jsx26(NavigationRail, { navigation: props.navigation, expanded: navigationOpen ?? false, setExpanded: setNavigationOpen }),
|
|
3114
|
+
/* @__PURE__ */ jsxs14(Box9, { component: "main", sx: { flexGrow: 1, display: "flex", flexDirection: "column", minWidth: 0, height: "100%", overflow: "hidden" }, children: [
|
|
3115
|
+
/* @__PURE__ */ jsx26(DrawerHeader, {}),
|
|
3116
|
+
/* @__PURE__ */ jsx26(Box9, { sx: { flex: 1, overflow: "auto", position: "relative" }, children: props.children })
|
|
3117
|
+
] })
|
|
3118
|
+
] }),
|
|
3119
|
+
(isFetching || isMutating) && /* @__PURE__ */ jsx26(LinearProgress, { sx: { position: "fixed", top: { xs: 56, sm: 64 }, left: 0, right: 0 } })
|
|
3120
|
+
] });
|
|
2126
3121
|
};
|
|
2127
3122
|
|
|
3123
|
+
// src/contexts/LayoutContext.ts
|
|
3124
|
+
import { createContext as createContext4, useContext as useContext4 } from "react";
|
|
3125
|
+
var LayoutContext = createContext4(null);
|
|
3126
|
+
|
|
2128
3127
|
// src/utils/i18n.ts
|
|
2129
3128
|
import i18n from "i18next";
|
|
2130
3129
|
import LanguageDetector from "i18next-browser-languagedetector";
|
|
@@ -2141,88 +3140,94 @@ i18n.use(HttpBackend).use(LanguageDetector).use(initReactI18next).init({
|
|
|
2141
3140
|
}
|
|
2142
3141
|
});
|
|
2143
3142
|
|
|
3143
|
+
// src/providers/DialogsProvider.tsx
|
|
3144
|
+
import { useCallback, useId, useMemo as useMemo4, useRef as useRef3, useState as useState9 } from "react";
|
|
3145
|
+
import { jsx as jsx27, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3146
|
+
function DialogsProvider({ children, unmountAfter = 1e3 }) {
|
|
3147
|
+
const [stack, setStack] = useState9([]);
|
|
3148
|
+
const keyPrefix = useId();
|
|
3149
|
+
const nextId = useRef3(0);
|
|
3150
|
+
const dialogMetadata = useRef3(/* @__PURE__ */ new WeakMap());
|
|
3151
|
+
const requestDialog = useEventCallback_default(function open(Component7, payload, options = {}) {
|
|
3152
|
+
const { onClose = async () => {
|
|
3153
|
+
} } = options;
|
|
3154
|
+
let resolve;
|
|
3155
|
+
const promise = new Promise((resolveImpl) => {
|
|
3156
|
+
resolve = resolveImpl;
|
|
3157
|
+
});
|
|
3158
|
+
const key = `${keyPrefix}-${nextId.current}`;
|
|
3159
|
+
nextId.current += 1;
|
|
3160
|
+
const newEntry = {
|
|
3161
|
+
key,
|
|
3162
|
+
open: true,
|
|
3163
|
+
promise,
|
|
3164
|
+
Component: Component7,
|
|
3165
|
+
payload,
|
|
3166
|
+
onClose,
|
|
3167
|
+
resolve
|
|
3168
|
+
};
|
|
3169
|
+
dialogMetadata.current.set(promise, newEntry);
|
|
3170
|
+
setStack((previousStack) => [...previousStack, newEntry]);
|
|
3171
|
+
return promise;
|
|
3172
|
+
});
|
|
3173
|
+
const removeDialogFromStack = useCallback((dialog) => {
|
|
3174
|
+
setStack((previousStack) => previousStack.filter((entry) => entry.promise !== dialog));
|
|
3175
|
+
dialogMetadata.current.delete(dialog);
|
|
3176
|
+
}, []);
|
|
3177
|
+
const closeDialogUi = useEventCallback_default(function closeDialogUi2(dialog) {
|
|
3178
|
+
setStack(
|
|
3179
|
+
(previousStack) => previousStack.map((entry) => entry.promise === dialog ? { ...entry, open: false } : entry)
|
|
3180
|
+
);
|
|
3181
|
+
setTimeout(() => removeDialogFromStack(dialog), unmountAfter);
|
|
3182
|
+
});
|
|
3183
|
+
const closeDialog = useEventCallback_default(async function closeDialog2(dialog, result) {
|
|
3184
|
+
const entryToClose = dialogMetadata.current.get(dialog);
|
|
3185
|
+
if (!entryToClose) {
|
|
3186
|
+
throw new Error("Dialog not found in stack");
|
|
3187
|
+
}
|
|
3188
|
+
try {
|
|
3189
|
+
await entryToClose.onClose(result);
|
|
3190
|
+
} finally {
|
|
3191
|
+
entryToClose.resolve(result);
|
|
3192
|
+
closeDialogUi(dialog);
|
|
3193
|
+
}
|
|
3194
|
+
return dialog;
|
|
3195
|
+
});
|
|
3196
|
+
const contextValue = useMemo4(() => ({ open: requestDialog, close: closeDialog }), [requestDialog, closeDialog]);
|
|
3197
|
+
return /* @__PURE__ */ jsxs15(DialogsContext.Provider, { value: contextValue, children: [
|
|
3198
|
+
children,
|
|
3199
|
+
stack.map(({ key, open, Component: Component7, payload, promise }) => /* @__PURE__ */ jsx27(
|
|
3200
|
+
Component7,
|
|
3201
|
+
{
|
|
3202
|
+
payload,
|
|
3203
|
+
open,
|
|
3204
|
+
onClose: async (result) => {
|
|
3205
|
+
await closeDialog(promise, result);
|
|
3206
|
+
}
|
|
3207
|
+
},
|
|
3208
|
+
key
|
|
3209
|
+
))
|
|
3210
|
+
] });
|
|
3211
|
+
}
|
|
3212
|
+
|
|
2144
3213
|
// src/providers/LayoutProvider.tsx
|
|
2145
|
-
import { jsx as
|
|
3214
|
+
import { jsx as jsx28, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2146
3215
|
var LayoutProvider = (props) => {
|
|
2147
|
-
const
|
|
2148
|
-
const
|
|
2149
|
-
const { t: t2 } = useTranslation5();
|
|
2150
|
-
const isFetching = !!useIsFetching();
|
|
2151
|
-
const isMutating = !!useIsMutating();
|
|
2152
|
-
const isLargeScreen = useMediaQuery(theme.breakpoints.up("sm"));
|
|
2153
|
-
const [user, setUser] = useState2({ employeeId: "", name: "Unknown", department: "", company: "", category: "" });
|
|
3216
|
+
const [user, setUser] = useState10({ employeeId: "", name: "Unknown", department: "", company: "", category: "" });
|
|
3217
|
+
const { t: t2 } = useTranslation7();
|
|
2154
3218
|
const navigation = props.getNavigation?.({ user, t: t2 });
|
|
2155
|
-
|
|
2156
|
-
useEffect(() => {
|
|
3219
|
+
useEffect6(() => {
|
|
2157
3220
|
z.config(default2.resolvedLanguage === "cs" ? cs() : en());
|
|
2158
3221
|
}, []);
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
cancel: t2("Layout.Dialog.Cancel"),
|
|
2164
|
-
alert: t2("Layout.Dialog.Alert")
|
|
2165
|
-
}, children: /* @__PURE__ */ jsx15(NotificationsProvider, { slotProps: { snackbar: { anchorOrigin: { vertical: isLargeScreen ? "top" : "bottom", horizontal: "center" } } }, children: /* @__PURE__ */ jsx15(LayoutContext.Provider, { value: { appTitle, user: { get: user, set: setUser } }, children: /* @__PURE__ */ jsxs7(
|
|
2166
|
-
DashboardLayout,
|
|
2167
|
-
{
|
|
2168
|
-
defaultSidebarCollapsed: props.defaultSidebarCollapsed ?? true,
|
|
2169
|
-
disableCollapsibleSidebar: props.disableCollapsibleSidebar,
|
|
2170
|
-
sidebarExpandedWidth: props.sidebarExpandedWidth,
|
|
2171
|
-
hideNavigation: navigation?.length === 0,
|
|
2172
|
-
slots: {
|
|
2173
|
-
toolbarActions: () => null,
|
|
2174
|
-
toolbarAccount: ToolbarAccount,
|
|
2175
|
-
appTitle: AppTitle
|
|
2176
|
-
},
|
|
2177
|
-
children: [
|
|
2178
|
-
props.children,
|
|
2179
|
-
(isFetching || isMutating) && /* @__PURE__ */ jsx15(LinearProgress, { sx: { position: "fixed", top: { xs: 56, sm: 64 }, left: 0, right: 0 } })
|
|
2180
|
-
]
|
|
2181
|
-
}
|
|
2182
|
-
) }) }) }) }) });
|
|
3222
|
+
return /* @__PURE__ */ jsx28(I18nextProvider, { i18n: default2, children: /* @__PURE__ */ jsx28(LocalizationProvider, { dateAdapter: AdapterDayjs, adapterLocale: default2.resolvedLanguage, children: /* @__PURE__ */ jsx28(LayoutContext.Provider, { value: { user: { get: user, set: setUser } }, children: /* @__PURE__ */ jsxs16(Layout, { navigation, theme: props.theme, children: [
|
|
3223
|
+
"\xA8",
|
|
3224
|
+
/* @__PURE__ */ jsx28(DialogsProvider, { children: props.children })
|
|
3225
|
+
] }) }) }) });
|
|
2183
3226
|
};
|
|
2184
3227
|
|
|
2185
3228
|
// src/index.ts
|
|
2186
3229
|
import { uuidv7 as uuidv72 } from "uuidv7";
|
|
2187
3230
|
|
|
2188
|
-
// src/utils/ClientUtils.ts
|
|
2189
|
-
import axios from "axios";
|
|
2190
|
-
var Platform = class {
|
|
2191
|
-
static get isAndroid() {
|
|
2192
|
-
return /android/i.test(this.userAgent);
|
|
2193
|
-
}
|
|
2194
|
-
static get isIOS() {
|
|
2195
|
-
return /iPad|iPhone|iPod/.test(this.userAgent);
|
|
2196
|
-
}
|
|
2197
|
-
static get isWindows() {
|
|
2198
|
-
return /windows/i.test(this.userAgent);
|
|
2199
|
-
}
|
|
2200
|
-
static get isMacOS() {
|
|
2201
|
-
return /Macintosh|MacIntel|MacPPC|Mac68K/.test(this.userAgent);
|
|
2202
|
-
}
|
|
2203
|
-
static get userAgent() {
|
|
2204
|
-
return typeof navigator === "undefined" ? "" : navigator.userAgent;
|
|
2205
|
-
}
|
|
2206
|
-
};
|
|
2207
|
-
var rootRouteHead = ({ title }) => () => ({
|
|
2208
|
-
meta: [
|
|
2209
|
-
{ charSet: "utf-8" },
|
|
2210
|
-
{ name: "viewport", content: "width=device-width, initial-scale=1" },
|
|
2211
|
-
{ title },
|
|
2212
|
-
{ name: "og:type", content: "website" },
|
|
2213
|
-
{ name: "og:title", content: title },
|
|
2214
|
-
{ name: "og:image", content: "/favicon-32x32.png" }
|
|
2215
|
-
],
|
|
2216
|
-
links: [
|
|
2217
|
-
{ rel: "apple-touch-icon", sizes: "180x180", href: "/apple-touch-icon.png" },
|
|
2218
|
-
{ rel: "icon", type: "image/png", sizes: "32x32", href: "/favicon-32x32.png" },
|
|
2219
|
-
{ rel: "icon", type: "image/png", sizes: "16x16", href: "/favicon-16x16.png" },
|
|
2220
|
-
{ rel: "manifest", href: "/site.webmanifest" },
|
|
2221
|
-
{ rel: "icon", href: "/favicon.ico" }
|
|
2222
|
-
]
|
|
2223
|
-
});
|
|
2224
|
-
var wczApiClient = axios.create();
|
|
2225
|
-
|
|
2226
3231
|
// src/hooks/FormHooks.ts
|
|
2227
3232
|
import { createFormHook, createFormHookContexts } from "@tanstack/react-form";
|
|
2228
3233
|
|
|
@@ -2239,11 +3244,11 @@ var getFieldStatus = (field) => {
|
|
|
2239
3244
|
};
|
|
2240
3245
|
|
|
2241
3246
|
// src/components/form/FormAutocomplete.tsx
|
|
2242
|
-
import { jsx as
|
|
3247
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
2243
3248
|
var FormAutocomplete = ({ textFieldProps, ...autocompleteProps }) => {
|
|
2244
3249
|
const field = useFieldContext();
|
|
2245
3250
|
const { isTouched, hasError, helperText } = getFieldStatus(field);
|
|
2246
|
-
return /* @__PURE__ */
|
|
3251
|
+
return /* @__PURE__ */ jsx29(
|
|
2247
3252
|
Autocomplete,
|
|
2248
3253
|
{
|
|
2249
3254
|
value: field.state.value,
|
|
@@ -2252,7 +3257,7 @@ var FormAutocomplete = ({ textFieldProps, ...autocompleteProps }) => {
|
|
|
2252
3257
|
onBlur: field.handleBlur,
|
|
2253
3258
|
"aria-label": field.name,
|
|
2254
3259
|
...autocompleteProps,
|
|
2255
|
-
renderInput: (parameters) => /* @__PURE__ */
|
|
3260
|
+
renderInput: (parameters) => /* @__PURE__ */ jsx29(
|
|
2256
3261
|
TextField,
|
|
2257
3262
|
{
|
|
2258
3263
|
...parameters,
|
|
@@ -2268,15 +3273,15 @@ var FormAutocomplete = ({ textFieldProps, ...autocompleteProps }) => {
|
|
|
2268
3273
|
|
|
2269
3274
|
// src/components/form/FormCheckbox.tsx
|
|
2270
3275
|
import { Checkbox, FormControl, FormControlLabel, FormHelperText } from "@mui/material";
|
|
2271
|
-
import { jsx as
|
|
3276
|
+
import { jsx as jsx30, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2272
3277
|
var FormCheckbox = (props) => {
|
|
2273
3278
|
const field = useFieldContext();
|
|
2274
3279
|
const { isTouched, hasError, helperText } = getFieldStatus(field);
|
|
2275
|
-
return /* @__PURE__ */
|
|
2276
|
-
/* @__PURE__ */
|
|
3280
|
+
return /* @__PURE__ */ jsxs17(FormControl, { component: "fieldset", children: [
|
|
3281
|
+
/* @__PURE__ */ jsx30(
|
|
2277
3282
|
FormControlLabel,
|
|
2278
3283
|
{
|
|
2279
|
-
control: /* @__PURE__ */
|
|
3284
|
+
control: /* @__PURE__ */ jsx30(
|
|
2280
3285
|
Checkbox,
|
|
2281
3286
|
{
|
|
2282
3287
|
name: field.name,
|
|
@@ -2290,18 +3295,18 @@ var FormCheckbox = (props) => {
|
|
|
2290
3295
|
label: props.label ?? ""
|
|
2291
3296
|
}
|
|
2292
3297
|
),
|
|
2293
|
-
isTouched && hasError && /* @__PURE__ */
|
|
3298
|
+
isTouched && hasError && /* @__PURE__ */ jsx30(FormHelperText, { error: hasError, children: helperText })
|
|
2294
3299
|
] });
|
|
2295
3300
|
};
|
|
2296
3301
|
|
|
2297
3302
|
// src/components/form/FormDatePicker.tsx
|
|
2298
3303
|
import { DatePicker } from "@mui/x-date-pickers-pro";
|
|
2299
3304
|
import dayjs2 from "dayjs";
|
|
2300
|
-
import { jsx as
|
|
3305
|
+
import { jsx as jsx31 } from "react/jsx-runtime";
|
|
2301
3306
|
var FormDatePicker = (props) => {
|
|
2302
3307
|
const field = useFieldContext();
|
|
2303
3308
|
const { isTouched, hasError, helperText } = getFieldStatus(field);
|
|
2304
|
-
return /* @__PURE__ */
|
|
3309
|
+
return /* @__PURE__ */ jsx31(
|
|
2305
3310
|
DatePicker,
|
|
2306
3311
|
{
|
|
2307
3312
|
name: field.name,
|
|
@@ -2325,11 +3330,11 @@ var FormDatePicker = (props) => {
|
|
|
2325
3330
|
// src/components/form/FormDateTimePicker.tsx
|
|
2326
3331
|
import { DateTimePicker } from "@mui/x-date-pickers-pro";
|
|
2327
3332
|
import dayjs3 from "dayjs";
|
|
2328
|
-
import { jsx as
|
|
3333
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
2329
3334
|
var FormDateTimePicker = (props) => {
|
|
2330
3335
|
const field = useFieldContext();
|
|
2331
3336
|
const { isTouched, hasError, helperText } = getFieldStatus(field);
|
|
2332
|
-
return /* @__PURE__ */
|
|
3337
|
+
return /* @__PURE__ */ jsx32(
|
|
2333
3338
|
DateTimePicker,
|
|
2334
3339
|
{
|
|
2335
3340
|
name: field.name,
|
|
@@ -2353,11 +3358,11 @@ var FormDateTimePicker = (props) => {
|
|
|
2353
3358
|
// src/components/form/FormNumberField.tsx
|
|
2354
3359
|
import { TextField as TextField2 } from "@mui/material";
|
|
2355
3360
|
import { NumericFormat } from "react-number-format";
|
|
2356
|
-
import { jsx as
|
|
3361
|
+
import { jsx as jsx33 } from "react/jsx-runtime";
|
|
2357
3362
|
var FormNumberField = ({ options, ...props }) => {
|
|
2358
3363
|
const field = useFieldContext();
|
|
2359
3364
|
const { isTouched, hasError, helperText } = getFieldStatus(field);
|
|
2360
|
-
return /* @__PURE__ */
|
|
3365
|
+
return /* @__PURE__ */ jsx33(
|
|
2361
3366
|
NumericFormat,
|
|
2362
3367
|
{
|
|
2363
3368
|
customInput: TextField2,
|
|
@@ -2376,13 +3381,13 @@ var FormNumberField = ({ options, ...props }) => {
|
|
|
2376
3381
|
|
|
2377
3382
|
// src/components/form/FormRadioGroup.tsx
|
|
2378
3383
|
import { FormControl as FormControl2, FormControlLabel as FormControlLabel2, FormHelperText as FormHelperText2, FormLabel, Radio, RadioGroup } from "@mui/material";
|
|
2379
|
-
import { jsx as
|
|
3384
|
+
import { jsx as jsx34, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
2380
3385
|
var FormRadioGroup = ({ label, options, ...props }) => {
|
|
2381
3386
|
const field = useFieldContext();
|
|
2382
3387
|
const { isTouched, hasError, helperText } = getFieldStatus(field);
|
|
2383
|
-
return /* @__PURE__ */
|
|
2384
|
-
label && /* @__PURE__ */
|
|
2385
|
-
/* @__PURE__ */
|
|
3388
|
+
return /* @__PURE__ */ jsxs18(FormControl2, { component: "fieldset", children: [
|
|
3389
|
+
label && /* @__PURE__ */ jsx34(FormLabel, { component: "legend", children: label }),
|
|
3390
|
+
/* @__PURE__ */ jsx34(
|
|
2386
3391
|
RadioGroup,
|
|
2387
3392
|
{
|
|
2388
3393
|
name: field.name,
|
|
@@ -2391,30 +3396,30 @@ var FormRadioGroup = ({ label, options, ...props }) => {
|
|
|
2391
3396
|
onBlur: field.handleBlur,
|
|
2392
3397
|
"aria-label": field.name,
|
|
2393
3398
|
...props,
|
|
2394
|
-
children: options.map((option) => /* @__PURE__ */
|
|
3399
|
+
children: options.map((option) => /* @__PURE__ */ jsx34(
|
|
2395
3400
|
FormControlLabel2,
|
|
2396
3401
|
{
|
|
2397
3402
|
value: option.value,
|
|
2398
|
-
control: /* @__PURE__ */
|
|
3403
|
+
control: /* @__PURE__ */ jsx34(Radio, {}),
|
|
2399
3404
|
label: option.label
|
|
2400
3405
|
},
|
|
2401
3406
|
option.value
|
|
2402
3407
|
))
|
|
2403
3408
|
}
|
|
2404
3409
|
),
|
|
2405
|
-
isTouched && hasError && /* @__PURE__ */
|
|
3410
|
+
isTouched && hasError && /* @__PURE__ */ jsx34(FormHelperText2, { error: hasError, children: helperText })
|
|
2406
3411
|
] });
|
|
2407
3412
|
};
|
|
2408
3413
|
|
|
2409
3414
|
// src/components/form/FormSlider.tsx
|
|
2410
3415
|
import { FormControl as FormControl3, FormHelperText as FormHelperText3, FormLabel as FormLabel2, Slider } from "@mui/material";
|
|
2411
|
-
import { jsx as
|
|
3416
|
+
import { jsx as jsx35, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
2412
3417
|
var FormSlider = ({ label, ...props }) => {
|
|
2413
3418
|
const field = useFieldContext();
|
|
2414
3419
|
const { isTouched, hasError, helperText } = getFieldStatus(field);
|
|
2415
|
-
return /* @__PURE__ */
|
|
2416
|
-
label && /* @__PURE__ */
|
|
2417
|
-
/* @__PURE__ */
|
|
3420
|
+
return /* @__PURE__ */ jsxs19(FormControl3, { component: "fieldset", children: [
|
|
3421
|
+
label && /* @__PURE__ */ jsx35(FormLabel2, { children: label }),
|
|
3422
|
+
/* @__PURE__ */ jsx35(
|
|
2418
3423
|
Slider,
|
|
2419
3424
|
{
|
|
2420
3425
|
name: field.name,
|
|
@@ -2425,13 +3430,13 @@ var FormSlider = ({ label, ...props }) => {
|
|
|
2425
3430
|
...props
|
|
2426
3431
|
}
|
|
2427
3432
|
),
|
|
2428
|
-
isTouched && hasError && /* @__PURE__ */
|
|
3433
|
+
isTouched && hasError && /* @__PURE__ */ jsx35(FormHelperText3, { error: hasError, children: helperText })
|
|
2429
3434
|
] });
|
|
2430
3435
|
};
|
|
2431
3436
|
|
|
2432
3437
|
// src/components/form/FormSubmitButton.tsx
|
|
2433
|
-
import { Button as
|
|
2434
|
-
import { jsx as
|
|
3438
|
+
import { Button as Button3 } from "@mui/material";
|
|
3439
|
+
import { jsx as jsx36 } from "react/jsx-runtime";
|
|
2435
3440
|
var FormSubmitButton = (props) => {
|
|
2436
3441
|
const form = useFormContext();
|
|
2437
3442
|
const handleClick = (event) => {
|
|
@@ -2439,8 +3444,8 @@ var FormSubmitButton = (props) => {
|
|
|
2439
3444
|
event.stopPropagation();
|
|
2440
3445
|
form.handleSubmit();
|
|
2441
3446
|
};
|
|
2442
|
-
return /* @__PURE__ */
|
|
2443
|
-
|
|
3447
|
+
return /* @__PURE__ */ jsx36(form.Subscribe, { selector: (state) => [state.canSubmit, state.isSubmitting], children: ([canSubmit, isSubmitting]) => /* @__PURE__ */ jsx36(
|
|
3448
|
+
Button3,
|
|
2444
3449
|
{
|
|
2445
3450
|
loading: isSubmitting,
|
|
2446
3451
|
disabled: !canSubmit,
|
|
@@ -2454,15 +3459,15 @@ var FormSubmitButton = (props) => {
|
|
|
2454
3459
|
|
|
2455
3460
|
// src/components/form/FormSwitch.tsx
|
|
2456
3461
|
import { FormControl as FormControl4, FormControlLabel as FormControlLabel3, FormHelperText as FormHelperText4, Switch } from "@mui/material";
|
|
2457
|
-
import { jsx as
|
|
3462
|
+
import { jsx as jsx37, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
2458
3463
|
var FormSwitch = (props) => {
|
|
2459
3464
|
const field = useFieldContext();
|
|
2460
3465
|
const { isTouched, hasError, helperText } = getFieldStatus(field);
|
|
2461
|
-
return /* @__PURE__ */
|
|
2462
|
-
/* @__PURE__ */
|
|
3466
|
+
return /* @__PURE__ */ jsxs20(FormControl4, { component: "fieldset", children: [
|
|
3467
|
+
/* @__PURE__ */ jsx37(
|
|
2463
3468
|
FormControlLabel3,
|
|
2464
3469
|
{
|
|
2465
|
-
control: /* @__PURE__ */
|
|
3470
|
+
control: /* @__PURE__ */ jsx37(
|
|
2466
3471
|
Switch,
|
|
2467
3472
|
{
|
|
2468
3473
|
name: field.name,
|
|
@@ -2476,17 +3481,17 @@ var FormSwitch = (props) => {
|
|
|
2476
3481
|
label: props.label ?? ""
|
|
2477
3482
|
}
|
|
2478
3483
|
),
|
|
2479
|
-
isTouched && hasError && /* @__PURE__ */
|
|
3484
|
+
isTouched && hasError && /* @__PURE__ */ jsx37(FormHelperText4, { error: hasError, children: helperText })
|
|
2480
3485
|
] });
|
|
2481
3486
|
};
|
|
2482
3487
|
|
|
2483
3488
|
// src/components/form/FormTextField.tsx
|
|
2484
3489
|
import { TextField as TextField3 } from "@mui/material";
|
|
2485
|
-
import { jsx as
|
|
3490
|
+
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
2486
3491
|
var FormTextField = (props) => {
|
|
2487
3492
|
const field = useFieldContext();
|
|
2488
3493
|
const { isTouched, hasError, helperText } = getFieldStatus(field);
|
|
2489
|
-
return /* @__PURE__ */
|
|
3494
|
+
return /* @__PURE__ */ jsx38(
|
|
2490
3495
|
TextField3,
|
|
2491
3496
|
{
|
|
2492
3497
|
name: field.name,
|
|
@@ -2523,222 +3528,15 @@ var { useAppForm: useLayoutForm, withForm: withLayoutForm } = createFormHook({
|
|
|
2523
3528
|
});
|
|
2524
3529
|
|
|
2525
3530
|
// src/index.ts
|
|
2526
|
-
import {
|
|
2527
|
-
import {
|
|
2528
|
-
import { useLocalStorageState } from "@toolpad/core/useLocalStorageState";
|
|
2529
|
-
import { useTranslation as useTranslation6 } from "react-i18next";
|
|
3531
|
+
import { default as default3 } from "use-local-storage-state";
|
|
3532
|
+
import { useTranslation as useTranslation8 } from "react-i18next";
|
|
2530
3533
|
import { t } from "i18next";
|
|
2531
|
-
|
|
2532
|
-
// src/hooks/FileHooks.ts
|
|
2533
|
-
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
2534
|
-
import saveAs from "file-saver";
|
|
2535
|
-
import { useState as useState3 } from "react";
|
|
2536
|
-
import { Upload as TusUpload } from "tus-js-client";
|
|
2537
|
-
import { uuidv7 } from "uuidv7";
|
|
2538
|
-
var BASE_URL = import.meta.env.VITE_FILE_API_BASE_URL;
|
|
2539
|
-
var QUERY_KEY = "Files";
|
|
2540
|
-
var HOUR = 1e3 * 60 * 60;
|
|
2541
|
-
var useGetFileMetas = (subId, options) => {
|
|
2542
|
-
const { appTitle } = useLayout();
|
|
2543
|
-
return useQuery({
|
|
2544
|
-
...options,
|
|
2545
|
-
queryKey: [QUERY_KEY, "meta", subId, appTitle],
|
|
2546
|
-
queryFn: ({ signal }) => wczApiClient.request({
|
|
2547
|
-
url: `${BASE_URL}/v1/meta?appName=${appTitle}&subId=${subId}`,
|
|
2548
|
-
method: "GET",
|
|
2549
|
-
signal
|
|
2550
|
-
}),
|
|
2551
|
-
initialData: [],
|
|
2552
|
-
refetchOnWindowFocus: false
|
|
2553
|
-
});
|
|
2554
|
-
};
|
|
2555
|
-
var useGetFileThumbnail = (meta, options) => {
|
|
2556
|
-
const { appTitle } = useLayout();
|
|
2557
|
-
return useQuery({
|
|
2558
|
-
...options,
|
|
2559
|
-
queryKey: [QUERY_KEY, "thumbnail", meta?.id, appTitle],
|
|
2560
|
-
queryFn: ({ signal }) => wczApiClient.request({
|
|
2561
|
-
url: `${BASE_URL}/v1/thumbnail?appName=${appTitle}&id=${meta?.id}`,
|
|
2562
|
-
method: "GET",
|
|
2563
|
-
signal,
|
|
2564
|
-
responseType: "blob"
|
|
2565
|
-
}),
|
|
2566
|
-
select: (data) => URL.createObjectURL(data),
|
|
2567
|
-
staleTime: HOUR,
|
|
2568
|
-
gcTime: HOUR,
|
|
2569
|
-
refetchOnWindowFocus: false,
|
|
2570
|
-
enabled: !!meta?.id && options?.enabled
|
|
2571
|
-
});
|
|
2572
|
-
};
|
|
2573
|
-
var useGetFile = (meta, options) => {
|
|
2574
|
-
const { appTitle } = useLayout();
|
|
2575
|
-
return useQuery({
|
|
2576
|
-
...options,
|
|
2577
|
-
queryKey: [QUERY_KEY, meta?.id, appTitle],
|
|
2578
|
-
queryFn: ({ signal }) => wczApiClient.request({
|
|
2579
|
-
url: `${BASE_URL}/v1?appName=${appTitle}&id=${meta?.id}`,
|
|
2580
|
-
method: "GET",
|
|
2581
|
-
signal,
|
|
2582
|
-
responseType: "blob"
|
|
2583
|
-
}),
|
|
2584
|
-
select: (data) => URL.createObjectURL(data),
|
|
2585
|
-
staleTime: HOUR,
|
|
2586
|
-
gcTime: HOUR,
|
|
2587
|
-
refetchOnWindowFocus: false,
|
|
2588
|
-
enabled: !!meta?.id && options?.enabled
|
|
2589
|
-
});
|
|
2590
|
-
};
|
|
2591
|
-
var useDownloadFile = (options) => {
|
|
2592
|
-
const { appTitle } = useLayout();
|
|
2593
|
-
return useMutation({
|
|
2594
|
-
...options,
|
|
2595
|
-
mutationFn: (meta) => wczApiClient.request({
|
|
2596
|
-
url: `${BASE_URL}/v1/download?appName=${appTitle}&id=${meta.id}`,
|
|
2597
|
-
method: "GET",
|
|
2598
|
-
responseType: "blob"
|
|
2599
|
-
}),
|
|
2600
|
-
onSuccess: (data, variables) => saveAs(data, `${variables.fileName}.${variables.fileExtension}`)
|
|
2601
|
-
});
|
|
2602
|
-
};
|
|
2603
|
-
var useOpenFile = (options) => {
|
|
2604
|
-
const { appTitle } = useLayout();
|
|
2605
|
-
return useMutation({
|
|
2606
|
-
...options,
|
|
2607
|
-
mutationFn: (meta) => wczApiClient.request({
|
|
2608
|
-
url: `${BASE_URL}/v1?appName=${appTitle}&id=${meta.id}`,
|
|
2609
|
-
method: "GET",
|
|
2610
|
-
responseType: "blob"
|
|
2611
|
-
}),
|
|
2612
|
-
onSuccess: (data) => {
|
|
2613
|
-
window.open(URL.createObjectURL(data));
|
|
2614
|
-
}
|
|
2615
|
-
});
|
|
2616
|
-
};
|
|
2617
|
-
var useUpdateFileMeta = (options) => {
|
|
2618
|
-
const { appTitle } = useLayout();
|
|
2619
|
-
const queryClient = useQueryClient();
|
|
2620
|
-
return useMutation({
|
|
2621
|
-
...options,
|
|
2622
|
-
mutationFn: (meta) => wczApiClient.request({
|
|
2623
|
-
url: `${BASE_URL}/v1/meta?appName=${appTitle}&id=${meta.id}`,
|
|
2624
|
-
method: "PUT",
|
|
2625
|
-
data: meta
|
|
2626
|
-
}),
|
|
2627
|
-
onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY, "meta"], exact: false })
|
|
2628
|
-
});
|
|
2629
|
-
};
|
|
2630
|
-
var useDeleteFile = (options) => {
|
|
2631
|
-
const { appTitle } = useLayout();
|
|
2632
|
-
const queryClient = useQueryClient();
|
|
2633
|
-
return useMutation({
|
|
2634
|
-
...options,
|
|
2635
|
-
mutationFn: (meta) => wczApiClient.request({
|
|
2636
|
-
url: `${BASE_URL}/v1?appName=${appTitle}&id=${meta.id}`,
|
|
2637
|
-
method: "DELETE"
|
|
2638
|
-
}),
|
|
2639
|
-
onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY, "meta"], exact: false })
|
|
2640
|
-
});
|
|
2641
|
-
};
|
|
2642
|
-
var useDeleteFiles = (options) => {
|
|
2643
|
-
const { appTitle } = useLayout();
|
|
2644
|
-
const queryClient = useQueryClient();
|
|
2645
|
-
return useMutation({
|
|
2646
|
-
...options,
|
|
2647
|
-
mutationFn: (subId) => wczApiClient.request({
|
|
2648
|
-
url: `${BASE_URL}/v1?appName=${appTitle}&subId=${subId}`,
|
|
2649
|
-
method: "DELETE"
|
|
2650
|
-
}),
|
|
2651
|
-
onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY, "meta"], exact: false })
|
|
2652
|
-
});
|
|
2653
|
-
};
|
|
2654
|
-
var useUploadFile = ({ subId, onSuccess, onError }) => {
|
|
2655
|
-
const { appTitle } = useLayout();
|
|
2656
|
-
const [progress, setProgress] = useState3(0);
|
|
2657
|
-
const queryClient = useQueryClient();
|
|
2658
|
-
const mutate = async (file) => {
|
|
2659
|
-
if (!subId) throw new Error("subId is required for file upload");
|
|
2660
|
-
const metadata = {
|
|
2661
|
-
id: uuidv7(),
|
|
2662
|
-
appName: appTitle,
|
|
2663
|
-
subId,
|
|
2664
|
-
fileName: file.name
|
|
2665
|
-
};
|
|
2666
|
-
const upload = new TusUpload(file, {
|
|
2667
|
-
endpoint: `${BASE_URL}/v1/upload`,
|
|
2668
|
-
chunkSize: 1048576,
|
|
2669
|
-
// 1 MB
|
|
2670
|
-
metadata: {
|
|
2671
|
-
id: metadata.id,
|
|
2672
|
-
appName: metadata.appName,
|
|
2673
|
-
subId: metadata.subId,
|
|
2674
|
-
fileName: metadata.fileName,
|
|
2675
|
-
fileExtension: file.type
|
|
2676
|
-
},
|
|
2677
|
-
//headers: { "Authorization": `Bearer ${await getToken()}` }, //TODO: implement token retrieval
|
|
2678
|
-
onError: (error) => {
|
|
2679
|
-
setProgress(0);
|
|
2680
|
-
onError?.(error);
|
|
2681
|
-
},
|
|
2682
|
-
onProgress: (bytesUploaded, bytesTotal) => {
|
|
2683
|
-
setProgress(bytesUploaded / bytesTotal * 100);
|
|
2684
|
-
},
|
|
2685
|
-
onSuccess: () => {
|
|
2686
|
-
setProgress(0);
|
|
2687
|
-
queryClient.invalidateQueries({ queryKey: [QUERY_KEY, "meta"], exact: false });
|
|
2688
|
-
onSuccess?.(metadata);
|
|
2689
|
-
}
|
|
2690
|
-
});
|
|
2691
|
-
const previousUploads = await upload.findPreviousUploads();
|
|
2692
|
-
if (previousUploads.length > 0) {
|
|
2693
|
-
upload.resumeFromPreviousUpload(previousUploads[0]);
|
|
2694
|
-
}
|
|
2695
|
-
upload.start();
|
|
2696
|
-
};
|
|
2697
|
-
return { mutate, progress };
|
|
2698
|
-
};
|
|
2699
|
-
function useOptimisticFileMutation(subId, options) {
|
|
2700
|
-
const [uploadedFileIds, setUploadedFileIds] = useState3([]);
|
|
2701
|
-
const [deletedFileIds, setDeletedFileIds] = useState3([]);
|
|
2702
|
-
const { data } = useGetFileMetas(subId, options);
|
|
2703
|
-
const { mutate: deleteAttachment } = useDeleteFile();
|
|
2704
|
-
function addFile(meta) {
|
|
2705
|
-
setUploadedFileIds((previous) => [...previous, meta.id]);
|
|
2706
|
-
}
|
|
2707
|
-
function removeFile(meta) {
|
|
2708
|
-
const added = uploadedFileIds.includes(meta.id);
|
|
2709
|
-
if (added) {
|
|
2710
|
-
setUploadedFileIds((previous) => previous.filter((file) => file !== meta.id));
|
|
2711
|
-
} else {
|
|
2712
|
-
setDeletedFileIds((previous) => [...previous, meta.id]);
|
|
2713
|
-
}
|
|
2714
|
-
}
|
|
2715
|
-
function save() {
|
|
2716
|
-
for (const id of deletedFileIds) {
|
|
2717
|
-
const meta = data.find((meta2) => meta2.id === id);
|
|
2718
|
-
if (!meta) continue;
|
|
2719
|
-
deleteAttachment(meta);
|
|
2720
|
-
}
|
|
2721
|
-
}
|
|
2722
|
-
function undo() {
|
|
2723
|
-
for (const id of uploadedFileIds) {
|
|
2724
|
-
const meta = data.find((meta2) => meta2.id === id);
|
|
2725
|
-
if (!meta) continue;
|
|
2726
|
-
deleteAttachment(meta);
|
|
2727
|
-
}
|
|
2728
|
-
}
|
|
2729
|
-
return {
|
|
2730
|
-
addFile,
|
|
2731
|
-
removeFile,
|
|
2732
|
-
save,
|
|
2733
|
-
undo
|
|
2734
|
-
};
|
|
2735
|
-
}
|
|
2736
3534
|
export {
|
|
2737
3535
|
ChipInputCell,
|
|
2738
3536
|
Dropzone,
|
|
2739
3537
|
EditableColumnHeader,
|
|
3538
|
+
FileViewer,
|
|
2740
3539
|
LayoutProvider,
|
|
2741
|
-
PageContainer,
|
|
2742
3540
|
PageHeader,
|
|
2743
3541
|
Platform,
|
|
2744
3542
|
RouterButton,
|
|
@@ -2746,8 +3544,10 @@ export {
|
|
|
2746
3544
|
RouterGridActionsCellItem,
|
|
2747
3545
|
RouterIconButton,
|
|
2748
3546
|
RouterLink,
|
|
3547
|
+
RouterListItemButton,
|
|
2749
3548
|
RouterNotFound,
|
|
2750
3549
|
RouterTab,
|
|
3550
|
+
TableContainer,
|
|
2751
3551
|
TypographyWithIcon,
|
|
2752
3552
|
rootRouteHead,
|
|
2753
3553
|
t,
|
|
@@ -2761,11 +3561,9 @@ export {
|
|
|
2761
3561
|
useGetFileMetas,
|
|
2762
3562
|
useGetFileThumbnail,
|
|
2763
3563
|
useLayoutForm,
|
|
2764
|
-
useLocalStorageState,
|
|
2765
|
-
useNotifications,
|
|
3564
|
+
default3 as useLocalStorageState,
|
|
2766
3565
|
useOpenFile,
|
|
2767
|
-
|
|
2768
|
-
useTranslation6 as useTranslation,
|
|
3566
|
+
useTranslation8 as useTranslation,
|
|
2769
3567
|
useUpdateFileMeta,
|
|
2770
3568
|
useUploadFile,
|
|
2771
3569
|
uuidv72 as uuidv7,
|