wcz-test 3.4.4 → 3.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/index.d.ts +2 -34
  2. package/dist/src/components/core/AppTitle.d.ts +3 -0
  3. package/dist/src/components/core/Layout.d.ts +10 -0
  4. package/dist/src/components/core/Markdown.d.ts +6 -0
  5. package/dist/src/components/core/PageHeader.d.ts +9 -0
  6. package/dist/src/components/core/TableContainer.d.ts +3 -0
  7. package/dist/src/components/core/ToolbarAccount.d.ts +2 -0
  8. package/dist/src/components/core/TypographyWithIcon.d.ts +7 -0
  9. package/dist/src/components/core/navigation/NavigationList.d.ts +21 -0
  10. package/dist/src/components/core/navigation/NavigationListItem.d.ts +15 -0
  11. package/dist/src/components/core/navigation/NavigationRail.d.ts +12 -0
  12. package/dist/src/components/data-grid/ChipInputCell.d.ts +9 -0
  13. package/dist/src/components/data-grid/EditableColumnHeader.d.ts +2 -0
  14. package/dist/src/components/file/Dropzone.d.ts +8 -0
  15. package/dist/src/components/file/FileViewer.d.ts +21 -0
  16. package/dist/src/components/file/fileViewer/FileViewerGrid.d.ts +17 -0
  17. package/dist/src/components/file/fileViewer/FileViewerList.d.ts +12 -0
  18. package/dist/src/components/file/fileViewer/ImageViewer.d.ts +6 -0
  19. package/dist/src/components/file/fileViewer/common/ActionsMenu.d.ts +15 -0
  20. package/dist/src/components/form/FormAutocomplete.d.ts +7 -0
  21. package/dist/src/components/form/FormCheckbox.d.ts +7 -0
  22. package/dist/src/components/form/FormDatePicker.d.ts +8 -0
  23. package/dist/src/components/form/FormDateTimePicker.d.ts +8 -0
  24. package/dist/src/components/form/FormNumberField.d.ts +9 -0
  25. package/dist/src/components/form/FormRadioGroup.d.ts +13 -0
  26. package/dist/src/components/form/FormSlider.d.ts +7 -0
  27. package/dist/src/components/form/FormSubmitButton.d.ts +4 -0
  28. package/dist/src/components/form/FormSwitch.d.ts +7 -0
  29. package/dist/src/components/form/FormTextField.d.ts +7 -0
  30. package/dist/src/components/router/RouterButton.d.ts +6 -0
  31. package/dist/src/components/router/RouterError.d.ts +7 -0
  32. package/dist/src/components/router/RouterGridActionsCellItem.d.ts +6 -0
  33. package/dist/src/components/router/RouterIconButton.d.ts +6 -0
  34. package/dist/src/components/router/RouterLink.d.ts +6 -0
  35. package/dist/src/components/router/RouterListItemButton.d.ts +6 -0
  36. package/dist/src/components/router/RouterNotFound.d.ts +1 -0
  37. package/dist/src/components/router/RouterTab.d.ts +6 -0
  38. package/dist/src/contexts/DialogsContext.d.ts +6 -0
  39. package/dist/src/contexts/FileContext.d.ts +13 -0
  40. package/dist/src/contexts/LayoutContext.d.ts +11 -0
  41. package/dist/src/hooks/DialogsHooks.d.ts +42 -0
  42. package/dist/src/hooks/FileHooks.d.ts +27 -0
  43. package/dist/src/hooks/FormHooks.d.ts +40 -0
  44. package/dist/src/hooks/PeopleSoftHooks.d.ts +23 -0
  45. package/dist/src/hooks/ThemeHook.d.ts +2 -0
  46. package/dist/src/index.d.ts +35 -0
  47. package/dist/src/models/KeycloakSettings.d.ts +8 -0
  48. package/dist/src/models/Navigation.d.ts +18 -0
  49. package/dist/src/models/NavigationParams.d.ts +6 -0
  50. package/dist/src/models/User.d.ts +8 -0
  51. package/dist/src/models/email/Email.d.ts +9 -0
  52. package/dist/src/models/email/EmailAttachment.d.ts +4 -0
  53. package/dist/src/models/file/FileActions.d.ts +4 -0
  54. package/dist/src/models/file/FileMeta.d.ts +11 -0
  55. package/dist/src/models/peoplesoft/Department.d.ts +14 -0
  56. package/dist/src/models/peoplesoft/Employee.d.ts +38 -0
  57. package/dist/src/models/peoplesoft/EmployeeCategoryGroup.d.ts +5 -0
  58. package/dist/src/models/peoplesoft/EmployeeStatus.d.ts +5 -0
  59. package/dist/src/providers/DialogsProvider.d.ts +6 -0
  60. package/dist/src/providers/LayoutProvider.d.ts +11 -0
  61. package/dist/src/routes/__root.d.ts +6 -0
  62. package/dist/src/utils/ClientUtils.d.ts +46 -0
  63. package/dist/src/utils/FormUtils.d.ts +7 -0
  64. package/dist/src/utils/i18n.d.ts +1 -0
  65. package/dist/vite.config.d.ts +2 -0
  66. package/package.json +14 -12
  67. package/dist/index.js +0 -1015
  68. package/dist/index.js.map +0 -1
package/dist/index.js DELETED
@@ -1,1015 +0,0 @@
1
- // src/components/core/TypographyWithIcon.tsx
2
- import { Stack, Typography } from "@mui/material";
3
- import { jsx, jsxs } from "react/jsx-runtime";
4
- var stackSxProps = [
5
- "margin",
6
- "marginTop",
7
- "marginRight",
8
- "marginBottom",
9
- "marginLeft",
10
- "m",
11
- "mt",
12
- "mr",
13
- "mb",
14
- "ml",
15
- "mx",
16
- "my",
17
- "padding",
18
- "paddingTop",
19
- "paddingRight",
20
- "paddingBottom",
21
- "paddingLeft",
22
- "p",
23
- "pt",
24
- "pr",
25
- "pb",
26
- "pl",
27
- "px",
28
- "py",
29
- "flexGrow",
30
- "flexShrink",
31
- "flexBasis",
32
- "flexDirection",
33
- "alignItems",
34
- "justifyContent",
35
- "position",
36
- "zIndex",
37
- "top",
38
- "right",
39
- "bottom",
40
- "left",
41
- "gridGap",
42
- "gridColumnGap",
43
- "gridRowGap",
44
- "gridColumn",
45
- "gridRow",
46
- "gridAutoFlow",
47
- "gap",
48
- "columnGap",
49
- "rowGap"
50
- ];
51
- var TypographyWithIcon = ({ startIcon, endIcon, children, sx, gutterBottom, ...props }) => {
52
- const sxCopy = { ...sx };
53
- const stackStyles = {};
54
- if (sxCopy) {
55
- for (const current of stackSxProps) {
56
- if (sxCopy[current]) {
57
- stackStyles[current] = sxCopy[current];
58
- delete sxCopy[current];
59
- }
60
- }
61
- }
62
- return /* @__PURE__ */ jsxs(Stack, { direction: "row", alignItems: "center", gap: 1, sx: stackStyles, mb: gutterBottom ? 0.7 : void 0, children: [
63
- startIcon,
64
- /* @__PURE__ */ jsx(Typography, { ...props, sx: sxCopy, children }),
65
- endIcon
66
- ] });
67
- };
68
-
69
- // src/components/core/PageHeader.tsx
70
- import { CardHeader, Typography as Typography2 } from "@mui/material";
71
- import { jsx as jsx2 } from "react/jsx-runtime";
72
- var PageHeader = ({ title, action, sx }) => {
73
- return /* @__PURE__ */ jsx2(CardHeader, { title: /* @__PURE__ */ jsx2(Typography2, { variant: "h4", fontWeight: 600, children: title }), action, sx: { px: 0, ...sx } });
74
- };
75
-
76
- // src/components/core/TableContainer.tsx
77
- import { Box } from "@mui/material";
78
- import { useEffect, useRef, useState } from "react";
79
- import { jsx as jsx3 } from "react/jsx-runtime";
80
- var TableContainer = ({ children, sx, ...props }) => {
81
- const reference = useRef(null);
82
- const [height, setHeight] = useState();
83
- useEffect(() => {
84
- const element = reference.current;
85
- if (!element) return;
86
- const recompute = () => {
87
- if (!reference.current) return;
88
- const top = Math.ceil(reference.current.getBoundingClientRect().top);
89
- const avail = Math.max(0, window.innerHeight - top);
90
- setHeight(avail);
91
- };
92
- recompute();
93
- window.addEventListener("resize", recompute);
94
- const ro = new ResizeObserver(recompute);
95
- ro.observe(document.documentElement);
96
- ro.observe(document.body);
97
- ro.observe(element);
98
- return () => {
99
- window.removeEventListener("resize", recompute);
100
- ro.disconnect();
101
- };
102
- }, []);
103
- return /* @__PURE__ */ jsx3(
104
- Box,
105
- {
106
- ref: reference,
107
- sx: {
108
- display: "flex",
109
- flexDirection: "column",
110
- minHeight: 0,
111
- width: "100%",
112
- ...sx
113
- },
114
- height,
115
- ...props,
116
- children: /* @__PURE__ */ jsx3(Box, { sx: (theme) => ({
117
- flex: 1,
118
- minHeight: 0,
119
- height: "100%",
120
- "& .MuiDataGrid-cell--editing": {
121
- "& .MuiInputBase-root": {
122
- height: "100%"
123
- }
124
- },
125
- "& .MuiDataGrid-columnHeaderTitle": {
126
- fontWeight: 600
127
- },
128
- "& .Mui-error": {
129
- backgroundColor: theme.palette.error.main,
130
- color: theme.palette.error.contrastText
131
- },
132
- "& .MuiDataGrid-booleanCell[data-value='true']": {
133
- color: `${theme.palette.success.main} !important`
134
- },
135
- "& .MuiDataGrid-booleanCell[data-value='false']": {
136
- color: `${theme.palette.error.main} !important`
137
- }
138
- }), children })
139
- }
140
- );
141
- };
142
-
143
- // src/components/file/Dropzone.tsx
144
- import CloudUpload from "@mui/icons-material/CloudUpload";
145
- import { Paper, Typography as Typography3, useTheme } from "@mui/material";
146
- import { useDropzone } from "react-dropzone";
147
- import { useTranslation } from "react-i18next";
148
- import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
149
- var baseStyle = {
150
- flex: 1,
151
- display: "flex",
152
- flexDirection: "column",
153
- alignItems: "center",
154
- padding: "20px",
155
- borderWidth: 2,
156
- borderRadius: 2,
157
- borderStyle: "dashed",
158
- outline: "none",
159
- transition: "border .24s ease-in-out",
160
- cursor: "pointer"
161
- };
162
- var Dropzone = ({ sx, ...props }) => {
163
- const { getRootProps, getInputProps, isFocused, isDragAccept, isDragReject } = useDropzone(props);
164
- const { t: t2 } = useTranslation();
165
- const theme = useTheme();
166
- const style = {
167
- ...baseStyle,
168
- ...isFocused ? { borderColor: theme.palette.primary.main } : {},
169
- ...isDragAccept ? { borderColor: theme.palette.success.main } : {},
170
- ...isDragReject ? { borderColor: theme.palette.error.main } : {}
171
- };
172
- return /* @__PURE__ */ jsxs2(Paper, { variant: "outlined", ...getRootProps({ style }), sx, children: [
173
- /* @__PURE__ */ jsx4("input", { ...getInputProps(), style: { display: "none" } }),
174
- /* @__PURE__ */ jsx4(CloudUpload, {}),
175
- /* @__PURE__ */ jsx4(Typography3, { children: t2("Layout.File.DragSomeFilesHereOrClickToSelectThem") })
176
- ] });
177
- };
178
-
179
- // src/components/file/FileViewer.tsx
180
- import { useState as useState4 } from "react";
181
- import { FileContext } from "~/contexts/FileContext";
182
- import { useGetFileMetas } from "~/hooks/FileHooks";
183
-
184
- // src/components/file/fileViewer/FileViewerGrid.tsx
185
- import MoreVert from "@mui/icons-material/MoreVert";
186
- import { Box as Box2, IconButton, ImageListItem, ImageListItemBar, Stack as Stack2, Tooltip } from "@mui/material";
187
- import { grey } from "@mui/material/colors";
188
- import { Fragment, useEffect as useEffect2, useState as useState2 } from "react";
189
- import { useFile as useFile2 } from "~/contexts/FileContext";
190
- import { useDownloadFile as useDownloadFile2, useGetFileThumbnail, useOpenFile } from "~/hooks/FileHooks";
191
-
192
- // src/components/file/fileViewer/common/ActionsMenu.tsx
193
- import Delete from "@mui/icons-material/Delete";
194
- import FileDownload from "@mui/icons-material/FileDownload";
195
- import { List, ListItemButton, ListItemIcon, ListItemText, Menu } from "@mui/material";
196
- import { useTranslation as useTranslation2 } from "react-i18next";
197
- import { useFile } from "~/contexts/FileContext";
198
- import { useDialogs } from "~/hooks/DialogsHooks";
199
- import { useDeleteFile, useDownloadFile } from "~/hooks/FileHooks";
200
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
201
- var ActionsMenu = ({ meta, menu, setMenu }) => {
202
- const { t: t2 } = useTranslation2();
203
- const { fileMetas, onDelete, actions } = useFile();
204
- const { confirm } = useDialogs();
205
- const handleMenuClose = () => {
206
- setMenu(null);
207
- };
208
- const { mutate: download, isPending: isDownloading } = useDownloadFile();
209
- const { mutate: deleteFile, isPending: isDeleting } = useDeleteFile();
210
- const handleOnDownload = () => {
211
- handleMenuClose();
212
- download(meta);
213
- };
214
- const handleOnDelete = async () => {
215
- if (!await confirm(t2("Layout.File.AreYouSureYouWantToDelete", { fileName: meta.fileName })))
216
- return;
217
- deleteFile(meta);
218
- handleMenuClose();
219
- if (onDelete) {
220
- const remainingFileMetas = fileMetas.filter((m) => m.id !== meta.id);
221
- onDelete({ remainingFileMetas, deletedFileMeta: meta });
222
- }
223
- };
224
- return /* @__PURE__ */ jsx5(
225
- Menu,
226
- {
227
- open: menu !== null,
228
- onClose: handleMenuClose,
229
- anchorReference: "anchorPosition",
230
- variant: "menu",
231
- anchorPosition: menu === null ? void 0 : { top: menu.mouseY, left: menu.mouseX },
232
- children: /* @__PURE__ */ jsxs3(List, { disablePadding: true, children: [
233
- actions?.download !== false && /* @__PURE__ */ jsxs3(ListItemButton, { onClick: handleOnDownload, disabled: isDownloading, children: [
234
- /* @__PURE__ */ jsx5(ListItemIcon, { children: /* @__PURE__ */ jsx5(FileDownload, {}) }),
235
- /* @__PURE__ */ jsx5(ListItemText, { children: t2("Layout.File.Download") })
236
- ] }),
237
- actions?.delete !== false && /* @__PURE__ */ jsxs3(ListItemButton, { onClick: handleOnDelete, disabled: isDeleting, children: [
238
- /* @__PURE__ */ jsx5(ListItemIcon, { children: /* @__PURE__ */ jsx5(Delete, {}) }),
239
- /* @__PURE__ */ jsx5(ListItemText, { children: t2("Layout.File.Delete") })
240
- ] })
241
- ] })
242
- }
243
- );
244
- };
245
-
246
- // src/components/file/fileViewer/FileViewerGrid.tsx
247
- import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
248
- var IMAGE_SIZE = 150;
249
- var FileViewerGrid = ({ sx, size, itemBar }) => {
250
- const { fileMetas } = useFile2();
251
- return /* @__PURE__ */ jsx6(Stack2, { direction: "row", spacing: 1, sx: { overflow: "auto", ...sx }, children: fileMetas.map((fileMeta) => /* @__PURE__ */ jsx6(
252
- GridFileViewerItem,
253
- {
254
- meta: fileMeta,
255
- size,
256
- itemBar
257
- },
258
- fileMeta.id
259
- )) });
260
- };
261
- var GridFileViewerItem = ({ meta, size, itemBar }) => {
262
- const { setImageId, actions } = useFile2();
263
- const [showItemBar, setShowItemBar] = useState2(itemBar === "always");
264
- const [menu, setMenu] = useState2(null);
265
- useEffect2(() => {
266
- setShowItemBar(itemBar === "always");
267
- }, [itemBar]);
268
- const { data: source } = useGetFileThumbnail(meta);
269
- const handleOnMouseEnter = () => setShowItemBar(true);
270
- const handleOnMouseLeave = () => itemBar !== "always" && setShowItemBar(false);
271
- const openMenu = (event) => {
272
- setMenu(menu === null ? { mouseX: event.clientX, mouseY: event.clientY } : null);
273
- setTimeout(() => setShowItemBar(true));
274
- };
275
- const { mutate: openFile } = useOpenFile();
276
- const { mutate: download } = useDownloadFile2();
277
- const onClick = () => {
278
- switch (meta.mediaType) {
279
- case "image": {
280
- return setImageId(meta.id);
281
- }
282
- case "application": {
283
- return openFile(meta);
284
- }
285
- case "video": {
286
- return openFile(meta);
287
- }
288
- default: {
289
- return download(meta);
290
- }
291
- }
292
- };
293
- return /* @__PURE__ */ jsxs4(Fragment, { children: [
294
- /* @__PURE__ */ jsxs4(ImageListItem, { sx: { width: size ?? IMAGE_SIZE, height: size ?? IMAGE_SIZE }, onMouseEnter: handleOnMouseEnter, onMouseLeave: handleOnMouseLeave, children: [
295
- /* @__PURE__ */ jsx6(
296
- Box2,
297
- {
298
- component: "img",
299
- src: source,
300
- loading: "lazy",
301
- alt: "thumbnail-" + meta.id,
302
- onClick,
303
- sx: { cursor: "pointer", objectFit: "contain", width: size ?? IMAGE_SIZE, height: size ?? IMAGE_SIZE }
304
- }
305
- ),
306
- itemBar !== "hidden" && showItemBar && /* @__PURE__ */ jsx6(
307
- ImageListItemBar,
308
- {
309
- title: /* @__PURE__ */ jsx6(Tooltip, { title: meta.fileName, children: /* @__PURE__ */ jsx6(Box2, { children: meta.fileName }) }),
310
- actionIcon: (actions?.download !== false || actions?.delete !== false) && /* @__PURE__ */ jsx6(IconButton, { sx: { color: grey[100] }, onClick: openMenu, children: /* @__PURE__ */ jsx6(MoreVert, {}) })
311
- }
312
- )
313
- ] }),
314
- (actions?.download !== false || actions?.delete !== false) && /* @__PURE__ */ jsx6(ActionsMenu, { meta, menu, setMenu })
315
- ] });
316
- };
317
-
318
- // src/components/file/fileViewer/FileViewerList.tsx
319
- import AttachFile from "@mui/icons-material/AttachFile";
320
- import Image from "@mui/icons-material/Image";
321
- import MoreVert2 from "@mui/icons-material/MoreVert";
322
- import SmartDisplay from "@mui/icons-material/SmartDisplay";
323
- import { IconButton as IconButton2, List as List2, ListItemButton as ListItemButton2, ListItemIcon as ListItemIcon2, ListItemText as ListItemText2 } from "@mui/material";
324
- import { Fragment as Fragment2, useState as useState3 } from "react";
325
- import { useFile as useFile3 } from "~/contexts/FileContext";
326
- import { useDownloadFile as useDownloadFile3, useOpenFile as useOpenFile2 } from "~/hooks/FileHooks";
327
- import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
328
- var FileViewerList = ({ sx }) => {
329
- const { fileMetas } = useFile3();
330
- return /* @__PURE__ */ jsx7(List2, { dense: true, sx, children: fileMetas.map(
331
- (fileMeta) => /* @__PURE__ */ jsx7(
332
- ListFileViewerItem,
333
- {
334
- meta: fileMeta
335
- },
336
- fileMeta.id
337
- )
338
- ) });
339
- };
340
- var ListFileViewerItem = ({ meta }) => {
341
- const { setImageId, actions } = useFile3();
342
- const [menu, setMenu] = useState3(null);
343
- const openMenu = (event) => {
344
- event.stopPropagation();
345
- setMenu(menu === null ? { mouseX: event.clientX, mouseY: event.clientY } : null);
346
- };
347
- const { mutate: openFile } = useOpenFile2();
348
- const { mutate: download } = useDownloadFile3();
349
- const onClick = () => {
350
- switch (meta.mediaType) {
351
- case "image": {
352
- return setImageId(meta.id);
353
- }
354
- case "application": {
355
- return openFile(meta);
356
- }
357
- case "video": {
358
- return openFile(meta);
359
- }
360
- default: {
361
- return download(meta);
362
- }
363
- }
364
- };
365
- const icon = () => {
366
- switch (meta.mediaType) {
367
- case "image": {
368
- return /* @__PURE__ */ jsx7(Image, {});
369
- }
370
- case "video": {
371
- return /* @__PURE__ */ jsx7(SmartDisplay, {});
372
- }
373
- default: {
374
- return /* @__PURE__ */ jsx7(AttachFile, {});
375
- }
376
- }
377
- };
378
- return /* @__PURE__ */ jsxs5(Fragment2, { children: [
379
- /* @__PURE__ */ jsxs5(ListItemButton2, { onClick, children: [
380
- /* @__PURE__ */ jsx7(ListItemIcon2, { children: icon() }),
381
- /* @__PURE__ */ jsx7(ListItemText2, { primary: `${meta.fileName}.${meta.fileExtension}` }),
382
- (actions?.download !== false || actions?.delete !== false) && /* @__PURE__ */ jsx7(IconButton2, { edge: "end", onClick: openMenu, children: /* @__PURE__ */ jsx7(MoreVert2, {}) })
383
- ] }, meta.id),
384
- (actions?.download !== false || actions?.delete !== false) && /* @__PURE__ */ jsx7(ActionsMenu, { meta, menu, setMenu })
385
- ] });
386
- };
387
-
388
- // src/components/file/fileViewer/ImageViewer.tsx
389
- import Close from "@mui/icons-material/Close";
390
- import { Box as Box3, Dialog, Fab } from "@mui/material";
391
- import { useEffect as useEffect3 } from "react";
392
- import { useFile as useFile4 } from "~/contexts/FileContext";
393
- import { useGetFile } from "~/hooks/FileHooks";
394
- import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
395
- var ImageViewer = ({ metaId }) => {
396
- const { fileMetas, setImageId } = useFile4();
397
- const meta = fileMetas.find((m) => m.id === metaId);
398
- const { data: source } = useGetFile(meta);
399
- useEffect3(() => {
400
- if (globalThis.window !== void 0 && metaId)
401
- globalThis.addEventListener("keydown", handleOnKeydown);
402
- return () => {
403
- globalThis.removeEventListener("keydown", handleOnKeydown);
404
- };
405
- }, [metaId]);
406
- const handleOnKeydown = (event) => {
407
- const images = fileMetas.filter((m) => m.mediaType === "image");
408
- const imageIndex = images.findIndex((m) => m.id === metaId);
409
- switch (event.key) {
410
- case "ArrowLeft": {
411
- return handleOnArrowLeft(images, imageIndex);
412
- }
413
- case "ArrowRight": {
414
- return handleOnArrowRight(images, imageIndex);
415
- }
416
- case "Backspace":
417
- case "Escape": {
418
- event.preventDefault();
419
- return onClose();
420
- }
421
- }
422
- };
423
- const handleOnArrowLeft = (images, index) => {
424
- if (index > 0) {
425
- const previousFile = images[index - 1];
426
- setImageId(previousFile.id);
427
- }
428
- };
429
- const handleOnArrowRight = (images, index) => {
430
- if (index < images.length - 1) {
431
- const nextFile = images[index + 1];
432
- setImageId(nextFile.id);
433
- }
434
- };
435
- const onClose = () => setImageId("");
436
- if (!metaId) return null;
437
- return /* @__PURE__ */ jsxs6(Dialog, { open: true, onClose, maxWidth: "xl", children: [
438
- /* @__PURE__ */ jsx8(Box3, { component: "img", src: source, alt: metaId, sx: { maxWidth: "100vw", maxHeight: { xs: "calc(100vh - 56px)", sm: "calc(100vh - 64px)" } } }),
439
- /* @__PURE__ */ jsx8(Fab, { size: "medium", onClick: onClose, sx: { position: "fixed", top: 8, right: 8 }, children: /* @__PURE__ */ jsx8(Close, {}) })
440
- ] });
441
- };
442
-
443
- // src/components/file/FileViewer.tsx
444
- import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
445
- var FileViewer = ({ subId, onDelete, actions, children }) => {
446
- const { data: fileMetas = [] } = useGetFileMetas(subId, { enabled: !!subId });
447
- const [imageId, setImageId] = useState4("");
448
- const components = { Grid: FileViewerGrid, List: FileViewerList };
449
- if (fileMetas.length === 0) return null;
450
- return /* @__PURE__ */ jsxs7(FileContext.Provider, { value: { fileMetas, onDelete, actions, setImageId }, children: [
451
- children(components),
452
- /* @__PURE__ */ jsx9(ImageViewer, { metaId: imageId })
453
- ] });
454
- };
455
-
456
- // src/components/data-grid/ChipInputCell.tsx
457
- import { Chip, Stack as Stack3 } from "@mui/material";
458
- import { jsx as jsx10 } from "react/jsx-runtime";
459
- var isArray = (value) => Array.isArray(value);
460
- var ChipInputCell = ({ params, slotProps, getLabel }) => {
461
- if (!params.value) return null;
462
- const getLabelValue = (value) => {
463
- if (getLabel) return getLabel(value);
464
- return value;
465
- };
466
- if (isArray(params.value))
467
- return /* @__PURE__ */ jsx10(Stack3, { direction: "row", alignItems: "center", gap: 1, sx: { overflowX: "auto", height: "100%", width: params.colDef.computedWidth }, children: params.value.map(
468
- (value, index) => /* @__PURE__ */ jsx10(Chip, { label: getLabelValue(value), ...slotProps }, `${index + 1}-chip-input-cell`)
469
- ) });
470
- return /* @__PURE__ */ jsx10(Chip, { label: getLabelValue(params.value), ...slotProps });
471
- };
472
-
473
- // src/components/data-grid/EditableColumnHeader.tsx
474
- import Edit from "@mui/icons-material/Edit";
475
- import { jsx as jsx11 } from "react/jsx-runtime";
476
- var EditableColumnHeader = ({ colDef }) => {
477
- return /* @__PURE__ */ jsx11(TypographyWithIcon, { endIcon: /* @__PURE__ */ jsx11(Edit, { color: "disabled", fontSize: "small" }), variant: "body2", className: "MuiDataGrid-columnHeaderTitle", children: colDef.headerName });
478
- };
479
-
480
- // src/components/router/RouterButton.tsx
481
- import { Button } from "@mui/material";
482
- import { createLink } from "@tanstack/react-router";
483
- import React3 from "react";
484
- import { jsx as jsx12 } from "react/jsx-runtime";
485
- var Component = React3.forwardRef(function ButtonComponent(props, reference) {
486
- return /* @__PURE__ */ jsx12(Button, { ref: reference, component: "a", ...props });
487
- });
488
- var CreatedComponent = createLink(Component);
489
- var RouterButton = (props) => {
490
- return /* @__PURE__ */ jsx12(CreatedComponent, { ...props });
491
- };
492
-
493
- // src/components/router/RouterGridActionsCellItem.tsx
494
- import { GridActionsCellItem } from "@mui/x-data-grid-premium";
495
- import { createLink as createLink2 } from "@tanstack/react-router";
496
- import React4 from "react";
497
- import { jsx as jsx13 } from "react/jsx-runtime";
498
- var Component2 = React4.forwardRef(
499
- function GridActionsCellItemComponent(props, reference) {
500
- return /* @__PURE__ */ jsx13(GridActionsCellItem, { ref: reference, component: "a", ...props });
501
- }
502
- );
503
- var CreatedComponent2 = createLink2(Component2);
504
- var RouterGridActionsCellItem = (props) => {
505
- return /* @__PURE__ */ jsx13(CreatedComponent2, { ...props });
506
- };
507
-
508
- // src/components/router/RouterIconButton.tsx
509
- import { IconButton as IconButton3 } from "@mui/material";
510
- import { createLink as createLink3 } from "@tanstack/react-router";
511
- import React5 from "react";
512
- import { jsx as jsx14 } from "react/jsx-runtime";
513
- var Component3 = React5.forwardRef(function IconButtonComponent(props, reference) {
514
- return /* @__PURE__ */ jsx14(IconButton3, { ref: reference, component: "a", ...props });
515
- });
516
- var CreatedComponent3 = createLink3(Component3);
517
- var RouterIconButton = (props) => {
518
- return /* @__PURE__ */ jsx14(CreatedComponent3, { ...props });
519
- };
520
-
521
- // src/components/router/RouterLink.tsx
522
- import { Link } from "@mui/material";
523
- import { createLink as createLink4 } from "@tanstack/react-router";
524
- import React6 from "react";
525
- import { jsx as jsx15 } from "react/jsx-runtime";
526
- var Component4 = React6.forwardRef(function LinkComponent(props, reference) {
527
- return /* @__PURE__ */ jsx15(Link, { ref: reference, ...props });
528
- });
529
- var CreatedComponent4 = createLink4(Component4);
530
- var RouterLink = (props) => {
531
- return /* @__PURE__ */ jsx15(CreatedComponent4, { ...props });
532
- };
533
-
534
- // src/components/router/RouterTab.tsx
535
- import { Tab } from "@mui/material";
536
- import { createLink as createLink5 } from "@tanstack/react-router";
537
- import React7 from "react";
538
- import { jsx as jsx16 } from "react/jsx-runtime";
539
- var Component5 = React7.forwardRef(function TabComponent(props, reference) {
540
- return /* @__PURE__ */ jsx16(Tab, { ref: reference, component: "a", ...props });
541
- });
542
- var CreatedComponent5 = createLink5(Component5);
543
- var RouterTab = (props) => {
544
- return /* @__PURE__ */ jsx16(CreatedComponent5, { ...props });
545
- };
546
-
547
- // src/components/router/RouterListItemButton.tsx
548
- import { ListItemButton as ListItemButton3 } from "@mui/material";
549
- import { createLink as createLink6 } from "@tanstack/react-router";
550
- import React8 from "react";
551
- import { jsx as jsx17 } from "react/jsx-runtime";
552
- var Component6 = React8.forwardRef(function ButtonComponent2(props, reference) {
553
- return /* @__PURE__ */ jsx17(ListItemButton3, { ref: reference, component: "a", ...props });
554
- });
555
- var CreatedComponent6 = createLink6(Component6);
556
- var RouterListItemButton = (props) => {
557
- return /* @__PURE__ */ jsx17(CreatedComponent6, { ...props });
558
- };
559
-
560
- // src/components/router/RouterNotFound.tsx
561
- import { Box as Box4, Divider, Typography as Typography4 } from "@mui/material";
562
- import { useTranslation as useTranslation3 } from "react-i18next";
563
- import { jsx as jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
564
- function RouterNotFound() {
565
- const { t: t2 } = useTranslation3();
566
- return /* @__PURE__ */ jsx18(Box4, { height: "100vh", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", textAlign: "center", px: 2, children: /* @__PURE__ */ jsxs8(Box4, { display: "flex", alignItems: "center", mb: 4, children: [
567
- /* @__PURE__ */ jsx18(Typography4, { variant: "h3", component: "span", fontWeight: 500, sx: { lineHeight: 1 }, children: "404" }),
568
- /* @__PURE__ */ jsx18(Divider, { orientation: "vertical", flexItem: true, sx: { mx: 3 } }),
569
- /* @__PURE__ */ jsx18(Typography4, { variant: "h5", component: "span", children: t2("Layout.ThisPageCouldNotBeFound") })
570
- ] }) });
571
- }
572
-
573
- // src/components/router/RouterError.tsx
574
- import { Box as Box5, Divider as Divider2, Typography as Typography5 } from "@mui/material";
575
- import { jsx as jsx19, jsxs as jsxs9 } from "react/jsx-runtime";
576
- var RouterError = ({ error }) => {
577
- return /* @__PURE__ */ jsx19(Box5, { height: "100vh", display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", textAlign: "center", px: 2, children: /* @__PURE__ */ jsxs9(Box5, { display: "flex", alignItems: "center", mb: 4, children: [
578
- /* @__PURE__ */ jsx19(Typography5, { variant: "h3", component: "span", fontWeight: 500, sx: { lineHeight: 1 }, children: error.name || "500" }),
579
- /* @__PURE__ */ jsx19(Divider2, { orientation: "vertical", flexItem: true, sx: { mx: 3 } }),
580
- /* @__PURE__ */ jsx19(Typography5, { variant: "h5", component: "span", children: error.message })
581
- ] }) });
582
- };
583
-
584
- // src/providers/LayoutProvider.tsx
585
- import { LocalizationProvider } from "@mui/x-date-pickers";
586
- import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
587
- import { useEffect as useEffect4, useState as useState6 } from "react";
588
- import { I18nextProvider, useTranslation as useTranslation4 } from "react-i18next";
589
- import * as z from "zod";
590
- import { cs, en } from "zod/locales";
591
- import { Layout } from "~/components/core/Layout";
592
- import { LayoutContext } from "~/contexts/LayoutContext";
593
- import i18n from "~/utils/i18n";
594
-
595
- // src/providers/DialogsProvider.tsx
596
- import useEventCallback from "@mui/utils/useEventCallback";
597
- import { useCallback, useId, useMemo, useRef as useRef2, useState as useState5 } from "react";
598
-
599
- // src/contexts/DialogsContext.ts
600
- import { createContext } from "react";
601
- var DialogsContext = createContext({});
602
-
603
- // src/providers/DialogsProvider.tsx
604
- import { jsx as jsx20, jsxs as jsxs10 } from "react/jsx-runtime";
605
- function DialogsProvider({ children, unmountAfter = 1e3 }) {
606
- const [stack, setStack] = useState5([]);
607
- const keyPrefix = useId();
608
- const nextId = useRef2(0);
609
- const dialogMetadata = useRef2(/* @__PURE__ */ new WeakMap());
610
- const requestDialog = useEventCallback(function open(Component7, payload, options = {}) {
611
- const { onClose = async () => {
612
- } } = options;
613
- let resolve;
614
- const promise = new Promise((resolveImpl) => {
615
- resolve = resolveImpl;
616
- });
617
- const key = `${keyPrefix}-${nextId.current}`;
618
- nextId.current += 1;
619
- const newEntry = {
620
- key,
621
- open: true,
622
- promise,
623
- Component: Component7,
624
- payload,
625
- onClose,
626
- resolve
627
- };
628
- dialogMetadata.current.set(promise, newEntry);
629
- setStack((previousStack) => [...previousStack, newEntry]);
630
- return promise;
631
- });
632
- const removeDialogFromStack = useCallback((dialog) => {
633
- setStack((previousStack) => previousStack.filter((entry) => entry.promise !== dialog));
634
- dialogMetadata.current.delete(dialog);
635
- }, []);
636
- const closeDialogUi = useEventCallback(function closeDialogUi2(dialog) {
637
- setStack(
638
- (previousStack) => previousStack.map((entry) => entry.promise === dialog ? { ...entry, open: false } : entry)
639
- );
640
- setTimeout(() => removeDialogFromStack(dialog), unmountAfter);
641
- });
642
- const closeDialog = useEventCallback(async function closeDialog2(dialog, result) {
643
- const entryToClose = dialogMetadata.current.get(dialog);
644
- if (!entryToClose) {
645
- throw new Error("Dialog not found in stack");
646
- }
647
- try {
648
- await entryToClose.onClose(result);
649
- } finally {
650
- entryToClose.resolve(result);
651
- closeDialogUi(dialog);
652
- }
653
- return dialog;
654
- });
655
- const contextValue = useMemo(() => ({ open: requestDialog, close: closeDialog }), [requestDialog, closeDialog]);
656
- return /* @__PURE__ */ jsxs10(DialogsContext.Provider, { value: contextValue, children: [
657
- children,
658
- stack.map(({ key, open, Component: Component7, payload, promise }) => /* @__PURE__ */ jsx20(
659
- Component7,
660
- {
661
- payload,
662
- open,
663
- onClose: async (result) => {
664
- await closeDialog(promise, result);
665
- }
666
- },
667
- key
668
- ))
669
- ] });
670
- }
671
-
672
- // src/providers/LayoutProvider.tsx
673
- import { jsx as jsx21, jsxs as jsxs11 } from "react/jsx-runtime";
674
- var LayoutProvider = (props) => {
675
- const [user, setUser] = useState6({ employeeId: "", name: "Unknown", department: "", company: "", category: "" });
676
- const { t: t2 } = useTranslation4();
677
- const navigation = props.getNavigation?.({ user, t: t2 });
678
- useEffect4(() => {
679
- z.config(i18n.resolvedLanguage === "cs" ? cs() : en());
680
- }, []);
681
- return /* @__PURE__ */ jsx21(I18nextProvider, { i18n, children: /* @__PURE__ */ jsx21(LocalizationProvider, { dateAdapter: AdapterDayjs, adapterLocale: i18n.resolvedLanguage, children: /* @__PURE__ */ jsx21(LayoutContext.Provider, { value: { user: { get: user, set: setUser } }, children: /* @__PURE__ */ jsxs11(Layout, { navigation, theme: props.theme, children: [
682
- "\xA8",
683
- /* @__PURE__ */ jsx21(DialogsProvider, { children: props.children })
684
- ] }) }) }) });
685
- };
686
-
687
- // src/index.ts
688
- import { uuidv7 as uuidv72 } from "uuidv7";
689
-
690
- // src/utils/ClientUtils.ts
691
- import axios from "axios";
692
- var Platform = class {
693
- static get isAndroid() {
694
- return /android/i.test(this.userAgent);
695
- }
696
- static get isIOS() {
697
- return /iPad|iPhone|iPod/.test(this.userAgent);
698
- }
699
- static get isWindows() {
700
- return /windows/i.test(this.userAgent);
701
- }
702
- static get isMacOS() {
703
- return /Macintosh|MacIntel|MacPPC|Mac68K/.test(this.userAgent);
704
- }
705
- static get userAgent() {
706
- return typeof navigator === "undefined" ? "" : navigator.userAgent;
707
- }
708
- };
709
- var rootRouteHead = ({ title }) => () => ({
710
- meta: [
711
- { charSet: "utf-8" },
712
- { name: "viewport", content: "width=device-width, initial-scale=1" },
713
- { title },
714
- { name: "og:type", content: "website" },
715
- { name: "og:title", content: title },
716
- { name: "og:image", content: "/favicon-32x32.png" }
717
- ],
718
- links: [
719
- { rel: "apple-touch-icon", sizes: "180x180", href: "/apple-touch-icon.png" },
720
- { rel: "icon", type: "image/png", sizes: "32x32", href: "/favicon-32x32.png" },
721
- { rel: "icon", type: "image/png", sizes: "16x16", href: "/favicon-16x16.png" },
722
- { rel: "manifest", href: "/site.webmanifest" },
723
- { rel: "icon", href: "/favicon.ico" }
724
- ]
725
- });
726
- var wczApiClient = axios.create();
727
-
728
- // src/hooks/FormHooks.ts
729
- import { createFormHook, createFormHookContexts } from "@tanstack/react-form";
730
- import { FormAutocomplete as Autocomplete } from "~/components/form/FormAutocomplete";
731
- import { FormCheckbox as Checkbox } from "~/components/form/FormCheckbox";
732
- import { FormDatePicker as DatePicker } from "~/components/form/FormDatePicker";
733
- import { FormDateTimePicker as DateTimePicker } from "~/components/form/FormDateTimePicker";
734
- import { FormNumberField as NumberField } from "~/components/form/FormNumberField";
735
- import { FormRadioGroup as RadioGroup } from "~/components/form/FormRadioGroup";
736
- import { FormSlider as Slider } from "~/components/form/FormSlider";
737
- import { FormSubmitButton as SubmitButton } from "~/components/form/FormSubmitButton";
738
- import { FormSwitch as Switch } from "~/components/form/FormSwitch";
739
- import { FormTextField as TextField } from "~/components/form/FormTextField";
740
- var { fieldContext, useFieldContext, formContext, useFormContext } = createFormHookContexts();
741
- var { useAppForm: useLayoutForm, withForm: withLayoutForm } = createFormHook({
742
- fieldComponents: {
743
- TextField,
744
- NumberField,
745
- Autocomplete,
746
- Checkbox,
747
- Switch,
748
- RadioGroup,
749
- Slider,
750
- DatePicker,
751
- DateTimePicker
752
- },
753
- formComponents: {
754
- SubmitButton
755
- },
756
- fieldContext,
757
- formContext
758
- });
759
-
760
- // src/hooks/DialogsHooks.tsx
761
- import Button2 from "@mui/material/Button";
762
- import Dialog2 from "@mui/material/Dialog";
763
- import DialogActions from "@mui/material/DialogActions";
764
- import DialogContent from "@mui/material/DialogContent";
765
- import DialogTitle from "@mui/material/DialogTitle";
766
- import useEventCallback2 from "@mui/utils/useEventCallback";
767
- import { useContext, useMemo as useMemo2 } from "react";
768
- import { useTranslation as useTranslation5 } from "react-i18next";
769
- import { jsx as jsx22, jsxs as jsxs12 } from "react/jsx-runtime";
770
- function AlertDialog({ open, payload, onClose }) {
771
- const { t: t2 } = useTranslation5();
772
- return /* @__PURE__ */ jsxs12(Dialog2, { maxWidth: "xs", fullWidth: true, open, onClose: () => onClose(), children: [
773
- /* @__PURE__ */ jsx22(DialogTitle, { children: payload.title ?? t2("Layout.Dialog.Alert") }),
774
- /* @__PURE__ */ jsx22(DialogContent, { children: payload.message }),
775
- /* @__PURE__ */ jsx22(DialogActions, { children: /* @__PURE__ */ jsx22(Button2, { disabled: !open, onClick: () => onClose(), children: t2("Layout.Dialog.Confirm") }) })
776
- ] });
777
- }
778
- function ConfirmDialog({ open, payload, onClose }) {
779
- const { t: t2 } = useTranslation5();
780
- return /* @__PURE__ */ jsxs12(Dialog2, { maxWidth: "xs", fullWidth: true, open, onClose: () => onClose(false), children: [
781
- /* @__PURE__ */ jsx22(DialogTitle, { children: payload.title ?? t2("Layout.Dialog.Confirm") }),
782
- /* @__PURE__ */ jsx22(DialogContent, { children: payload.message }),
783
- /* @__PURE__ */ jsxs12(DialogActions, { children: [
784
- /* @__PURE__ */ jsx22(Button2, { autoFocus: true, disabled: !open, onClick: () => onClose(false), children: payload.cancelText ?? t2("Layout.Dialog.Cancel") }),
785
- /* @__PURE__ */ jsx22(Button2, { disabled: !open, onClick: () => onClose(true), children: t2("Layout.Dialog.Confirm") })
786
- ] })
787
- ] });
788
- }
789
- function useDialogs2() {
790
- const { open, close } = useContext(DialogsContext);
791
- const alert = useEventCallback2(
792
- (message, { ...options } = {}) => open(AlertDialog, { ...options, message })
793
- );
794
- const confirm = useEventCallback2(
795
- (message, { ...options } = {}) => open(ConfirmDialog, { ...options, message })
796
- );
797
- return useMemo2(() => ({ alert, confirm, open, close }), [alert, close, confirm, open]);
798
- }
799
-
800
- // src/index.ts
801
- import { default as default2 } from "use-local-storage-state";
802
- import { useTranslation as useTranslation6 } from "react-i18next";
803
- import { t } from "i18next";
804
-
805
- // src/hooks/FileHooks.ts
806
- import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
807
- import saveAs from "file-saver";
808
- import { useState as useState7 } from "react";
809
- import { Upload as TusUpload } from "tus-js-client";
810
- import { uuidv7 } from "uuidv7";
811
- import { useAppTitle } from "~/components/core/AppTitle";
812
- import { wczApiClient as wczApiClient2 } from "~/utils/ClientUtils";
813
- var BASE_URL = import.meta.env.VITE_FILE_API_BASE_URL;
814
- var QUERY_KEY = "Files";
815
- var HOUR = 1e3 * 60 * 60;
816
- var useGetFileMetas2 = (subId, options) => {
817
- const appTitle = useAppTitle();
818
- return useQuery({
819
- ...options,
820
- queryKey: [QUERY_KEY, "meta", subId, appTitle],
821
- queryFn: ({ signal }) => wczApiClient2.request({
822
- url: `${BASE_URL}/v1/meta?appName=${appTitle}&subId=${subId}`,
823
- method: "GET",
824
- signal
825
- }),
826
- staleTime: HOUR,
827
- gcTime: HOUR,
828
- refetchOnWindowFocus: false
829
- });
830
- };
831
- var useGetFileThumbnail2 = (meta, options) => {
832
- const appTitle = useAppTitle();
833
- return useQuery({
834
- ...options,
835
- queryKey: [QUERY_KEY, "thumbnail", meta?.id, appTitle],
836
- queryFn: ({ signal }) => wczApiClient2.request({
837
- url: `${BASE_URL}/v1/thumbnail?appName=${appTitle}&id=${meta?.id}`,
838
- method: "GET",
839
- signal,
840
- responseType: "blob"
841
- }),
842
- select: (data) => URL.createObjectURL(data),
843
- staleTime: HOUR,
844
- gcTime: HOUR,
845
- refetchOnWindowFocus: false,
846
- enabled: !!meta?.id && options?.enabled
847
- });
848
- };
849
- var useGetFile2 = (meta, options) => {
850
- const appTitle = useAppTitle();
851
- return useQuery({
852
- ...options,
853
- queryKey: [QUERY_KEY, meta?.id, appTitle],
854
- queryFn: ({ signal }) => wczApiClient2.request({
855
- url: `${BASE_URL}/v1?appName=${appTitle}&id=${meta?.id}`,
856
- method: "GET",
857
- signal,
858
- responseType: "blob"
859
- }),
860
- select: (data) => URL.createObjectURL(data),
861
- staleTime: HOUR,
862
- gcTime: HOUR,
863
- refetchOnWindowFocus: false,
864
- enabled: !!meta?.id && options?.enabled
865
- });
866
- };
867
- var useDownloadFile4 = (options) => {
868
- const appTitle = useAppTitle();
869
- return useMutation({
870
- ...options,
871
- mutationFn: (meta) => wczApiClient2.request({
872
- url: `${BASE_URL}/v1/download?appName=${appTitle}&id=${meta.id}`,
873
- method: "GET",
874
- responseType: "blob"
875
- }),
876
- onSuccess: (data, variables) => saveAs(data, `${variables.fileName}.${variables.fileExtension}`)
877
- });
878
- };
879
- var useOpenFile3 = (options) => {
880
- const appTitle = useAppTitle();
881
- return useMutation({
882
- ...options,
883
- mutationFn: (meta) => wczApiClient2.request({
884
- url: `${BASE_URL}/v1?appName=${appTitle}&id=${meta.id}`,
885
- method: "GET",
886
- responseType: "blob"
887
- }),
888
- onSuccess: (data) => {
889
- window.open(URL.createObjectURL(data));
890
- }
891
- });
892
- };
893
- var useUpdateFileMeta = (options) => {
894
- const appTitle = useAppTitle();
895
- const queryClient = useQueryClient();
896
- return useMutation({
897
- ...options,
898
- mutationFn: (meta) => wczApiClient2.request({
899
- url: `${BASE_URL}/v1/meta?appName=${appTitle}&id=${meta.id}`,
900
- method: "PUT",
901
- data: meta
902
- }),
903
- onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY, "meta"], exact: false })
904
- });
905
- };
906
- var useDeleteFile2 = (options) => {
907
- const appTitle = useAppTitle();
908
- const queryClient = useQueryClient();
909
- return useMutation({
910
- ...options,
911
- mutationFn: (meta) => wczApiClient2.request({
912
- url: `${BASE_URL}/v1?appName=${appTitle}&id=${meta.id}`,
913
- method: "DELETE"
914
- }),
915
- onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY, "meta"], exact: false })
916
- });
917
- };
918
- var useDeleteFiles = (options) => {
919
- const appTitle = useAppTitle();
920
- const queryClient = useQueryClient();
921
- return useMutation({
922
- ...options,
923
- mutationFn: (subId) => wczApiClient2.request({
924
- url: `${BASE_URL}/v1?appName=${appTitle}&subId=${subId}`,
925
- method: "DELETE"
926
- }),
927
- onSettled: () => queryClient.invalidateQueries({ queryKey: [QUERY_KEY, "meta"], exact: false })
928
- });
929
- };
930
- var useUploadFile = ({ subId, onSuccess, onError }) => {
931
- const appTitle = useAppTitle();
932
- const [progress, setProgress] = useState7(0);
933
- const queryClient = useQueryClient();
934
- const mutate = async (file) => {
935
- if (!subId) throw new Error("subId is required for file upload");
936
- if (!appTitle) throw new Error("appTitle is required for file upload");
937
- const metadata = {
938
- id: uuidv7(),
939
- appName: appTitle,
940
- subId,
941
- fileName: file.name
942
- };
943
- const upload = new TusUpload(file, {
944
- endpoint: `${BASE_URL}/v1/upload`,
945
- chunkSize: 1048576,
946
- // 1 MB
947
- metadata: {
948
- id: metadata.id,
949
- appName: metadata.appName,
950
- subId: metadata.subId,
951
- fileName: metadata.fileName,
952
- fileExtension: file.type
953
- },
954
- //headers: { "Authorization": `Bearer ${await getToken()}` }, //TODO: implement token retrieval
955
- onError: (error) => {
956
- setProgress(0);
957
- onError?.(error);
958
- },
959
- onProgress: (bytesUploaded, bytesTotal) => {
960
- setProgress(bytesUploaded / bytesTotal * 100);
961
- },
962
- onSuccess: () => {
963
- setProgress(0);
964
- queryClient.invalidateQueries({ queryKey: [QUERY_KEY, "meta", subId, appTitle], exact: false });
965
- onSuccess?.(metadata);
966
- }
967
- });
968
- const previousUploads = await upload.findPreviousUploads();
969
- if (previousUploads.length > 0) {
970
- upload.resumeFromPreviousUpload(previousUploads[0]);
971
- }
972
- upload.start();
973
- };
974
- return { mutate, progress };
975
- };
976
- export {
977
- ChipInputCell,
978
- Dropzone,
979
- EditableColumnHeader,
980
- FileViewer,
981
- LayoutProvider,
982
- PageHeader,
983
- Platform,
984
- RouterButton,
985
- RouterError,
986
- RouterGridActionsCellItem,
987
- RouterIconButton,
988
- RouterLink,
989
- RouterListItemButton,
990
- RouterNotFound,
991
- RouterTab,
992
- TableContainer,
993
- TypographyWithIcon,
994
- rootRouteHead,
995
- t,
996
- useDeleteFile2 as useDeleteFile,
997
- useDeleteFiles,
998
- useDialogs2 as useDialogs,
999
- useDownloadFile4 as useDownloadFile,
1000
- useFieldContext,
1001
- useFormContext,
1002
- useGetFile2 as useGetFile,
1003
- useGetFileMetas2 as useGetFileMetas,
1004
- useGetFileThumbnail2 as useGetFileThumbnail,
1005
- useLayoutForm,
1006
- default2 as useLocalStorageState,
1007
- useOpenFile3 as useOpenFile,
1008
- useTranslation6 as useTranslation,
1009
- useUpdateFileMeta,
1010
- useUploadFile,
1011
- uuidv72 as uuidv7,
1012
- wczApiClient,
1013
- withLayoutForm
1014
- };
1015
- //# sourceMappingURL=index.js.map