wcz-layout 10.2.1 → 11.0.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.
Files changed (122) hide show
  1. package/dist/ChatLayout-B0MBrI-Y.mjs +2394 -0
  2. package/dist/ChatLayout-B0MBrI-Y.mjs.map +1 -0
  3. package/dist/{Employee-C8xIlBxY.d.mts → ExtractFile-BQUXpuBS.d.mts} +44 -3
  4. package/dist/FileMeta-B5VU-eCi.d.mts +55 -0
  5. package/dist/FileMeta-BexXC_45.mjs +35 -0
  6. package/dist/FileMeta-BexXC_45.mjs.map +1 -0
  7. package/dist/QueryClientParam-BG9Q_9XU.d.mts +6 -0
  8. package/dist/Translate-Ad784Dps.d.mts +24 -0
  9. package/dist/{Approval-D1TfISUL.mjs → Translate-C43AmXYW.mjs} +44 -36
  10. package/dist/Translate-C43AmXYW.mjs.map +1 -0
  11. package/dist/User-CvLutatT.d.mts +10 -0
  12. package/dist/ai.d.mts +31 -4
  13. package/dist/ai.mjs +154 -10
  14. package/dist/ai.mjs.map +1 -1
  15. package/dist/auth.d.mts +7 -14
  16. package/dist/auth.mjs +15 -38
  17. package/dist/auth.mjs.map +1 -1
  18. package/dist/authMiddleware-ANa9Tlmp.mjs +45 -0
  19. package/dist/authMiddleware-ANa9Tlmp.mjs.map +1 -0
  20. package/dist/{ChatLayout-BmLySLXy.d.mts → components-2HKj8GpC.d.mts} +219 -255
  21. package/dist/components.d.mts +2 -126
  22. package/dist/components.mjs +876 -916
  23. package/dist/components.mjs.map +1 -1
  24. package/dist/data/client.d.mts +313 -55
  25. package/dist/data/client.mjs +10 -5
  26. package/dist/data/client.mjs.map +1 -1
  27. package/dist/data/server.d.mts +19 -3
  28. package/dist/data/server.mjs +3 -5
  29. package/dist/data/server.mjs.map +1 -1
  30. package/dist/env-C4WLVJMm.mjs +32 -0
  31. package/dist/env-C4WLVJMm.mjs.map +1 -0
  32. package/dist/file-DBqTibcr.mjs +176 -0
  33. package/dist/file-DBqTibcr.mjs.map +1 -0
  34. package/dist/file-hecCQszp.mjs +114 -0
  35. package/dist/file-hecCQszp.mjs.map +1 -0
  36. package/dist/generatedChart-k7NEdi5Z.mjs.map +1 -1
  37. package/dist/hooks.d.mts +13 -93
  38. package/dist/hooks.mjs +353 -1059
  39. package/dist/hooks.mjs.map +1 -1
  40. package/dist/i18n-ZRiIIdpb.mjs +563 -0
  41. package/dist/i18n-ZRiIIdpb.mjs.map +1 -0
  42. package/dist/index.d.mts +3 -35
  43. package/dist/index.mjs +630 -680
  44. package/dist/index.mjs.map +1 -1
  45. package/dist/layout-DeTB6Ai1.mjs +224 -0
  46. package/dist/layout-DeTB6Ai1.mjs.map +1 -0
  47. package/dist/middleware.d.mts +1 -1
  48. package/dist/middleware.mjs +2 -46
  49. package/dist/middleware.mjs.map +1 -1
  50. package/dist/models.d.mts +35 -43
  51. package/dist/models.mjs +4 -6
  52. package/dist/models.mjs.map +1 -1
  53. package/dist/oidc--D2ox365.mjs +97 -0
  54. package/dist/oidc--D2ox365.mjs.map +1 -0
  55. package/dist/peoplesoft-DhwB8jrM.d.mts +204 -0
  56. package/dist/tokens-C4djIAhl.mjs +97 -0
  57. package/dist/tokens-C4djIAhl.mjs.map +1 -0
  58. package/dist/useDialogs-QER-2rVG.mjs +297 -0
  59. package/dist/useDialogs-QER-2rVG.mjs.map +1 -0
  60. package/dist/user-DQx1BanQ.mjs +120 -0
  61. package/dist/user-DQx1BanQ.mjs.map +1 -0
  62. package/dist/{utils-CNYCSgip.d.mts → utils-BnyAEKW7.d.mts} +7 -9
  63. package/dist/utils-H4BskGF8.mjs +132 -0
  64. package/dist/utils-H4BskGF8.mjs.map +1 -0
  65. package/dist/utils.d.mts +21 -4
  66. package/dist/utils.mjs +5 -4
  67. package/dist/vite.mjs +98 -32
  68. package/dist/vite.mjs.map +1 -1
  69. package/package.json +23 -29
  70. package/skills/ai/SKILL.md +105 -75
  71. package/skills/general/SKILL.md +15 -8
  72. package/skills/general/references/auth.md +15 -17
  73. package/skills/general/references/languages.md +56 -0
  74. package/skills/migrations/versions/migrate-v10-to-v11.md +98 -22
  75. package/skills/migrations/versions/migrate-v9-to-v10.md +22 -22
  76. package/skills/services/SKILL.md +41 -7
  77. package/skills/services/docs/email.md +2 -2
  78. package/skills/services/docs/file.md +100 -85
  79. package/skills/services/docs/layout.md +129 -0
  80. package/skills/start/steps/02-project-name-setup.md +1 -1
  81. package/skills/start/steps/03-apm-setup.md +8 -1
  82. package/skills/start/steps/06-entra-setup.md +1 -1
  83. package/skills/start/steps/08-generate-favicon.md +1 -1
  84. package/skills/table/SKILL.md +18 -5
  85. package/src/lib/locales/cs.json +120 -0
  86. package/src/lib/locales/en.json +119 -0
  87. package/src/lib/locales/uk.json +121 -0
  88. package/src/lib/locales/zh-TW.json +118 -0
  89. package/dist/Approval-D1TfISUL.mjs.map +0 -1
  90. package/dist/ChatLayout-BpRj5rlH.mjs +0 -1639
  91. package/dist/ChatLayout-BpRj5rlH.mjs.map +0 -1
  92. package/dist/DialogsContext-D23fJjYR.mjs +0 -6
  93. package/dist/DialogsContext-D23fJjYR.mjs.map +0 -1
  94. package/dist/Email-Dz5k0UWE.d.mts +0 -15
  95. package/dist/FileMeta-B39e2FLC.d.mts +0 -17
  96. package/dist/FileMeta-CPBWI_jA.mjs +0 -18
  97. package/dist/FileMeta-CPBWI_jA.mjs.map +0 -1
  98. package/dist/QueryClientParam-CTV1vj76.d.mts +0 -8
  99. package/dist/RouterListItemButton-CF-8w-08.mjs +0 -62
  100. package/dist/RouterListItemButton-CF-8w-08.mjs.map +0 -1
  101. package/dist/User-aJksXItw.d.mts +0 -12
  102. package/dist/approval-B3ZQn9aH.mjs +0 -83
  103. package/dist/approval-B3ZQn9aH.mjs.map +0 -1
  104. package/dist/createApi-BXjkj4fM.mjs +0 -25
  105. package/dist/createApi-BXjkj4fM.mjs.map +0 -1
  106. package/dist/env-BwFl7nWc.mjs +0 -48
  107. package/dist/env-BwFl7nWc.mjs.map +0 -1
  108. package/dist/file-BQ-Bu2g8.mjs +0 -150
  109. package/dist/file-BQ-Bu2g8.mjs.map +0 -1
  110. package/dist/file-DZ0KYhoB.mjs +0 -151
  111. package/dist/file-DZ0KYhoB.mjs.map +0 -1
  112. package/dist/peoplesoft-C-zPdRVj.d.mts +0 -161
  113. package/dist/peoplesoft-CvwdApCK.mjs +0 -125
  114. package/dist/peoplesoft-CvwdApCK.mjs.map +0 -1
  115. package/dist/providers-BfFg_3eo.mjs +0 -56
  116. package/dist/providers-BfFg_3eo.mjs.map +0 -1
  117. package/dist/session-B_jK90RC.mjs +0 -23
  118. package/dist/session-B_jK90RC.mjs.map +0 -1
  119. package/dist/tokens-CkWpu7Qp.mjs +0 -150
  120. package/dist/tokens-CkWpu7Qp.mjs.map +0 -1
  121. package/dist/utils-DJx-7b4M.mjs +0 -244
  122. package/dist/utils-DJx-7b4M.mjs.map +0 -1
@@ -1,262 +1,29 @@
1
- import { d as sanitizeReturnTo, m as loginProvidersQueryOptions } from "./utils-DJx-7b4M.mjs";
2
- import { a as fileQueryOptions, i as fileMetasQueryOptions, n as deleteFileMutationOptions, o as fileThumbnailQueryOptions, r as downloadFileMutationOptions, s as openFileMutationOptions } from "./file-BQ-Bu2g8.mjs";
3
- import { D as RouterLink, O as useDialogs, _ as toClipboardText, a as cellSelectionSx, c as columnFlex, d as layoutTableClasses, f as lookaheadRange, h as pinnedSx, m as pinnedClass, o as classNames, r as AggregatedCell, s as columnAlign, t as ChatLayout, u as hasColumnLabel, v as DEFAULT_PAGE_SIZE_OPTIONS } from "./ChatLayout-BpRj5rlH.mjs";
4
- import { n as RouterIconButton, t as RouterListItemButton } from "./RouterListItemButton-CF-8w-08.mjs";
1
+ import { i as fileMetasQueryOptions, n as deleteFileMutationOptions } from "./file-hecCQszp.mjs";
2
+ import { a as RouterFab, c as RouterListItemButton, i as RouterButton, l as RouterTab, n as useDialogs, o as RouterIconButton, s as RouterLink } from "./useDialogs-QER-2rVG.mjs";
3
+ import { D as useLayoutForm, S as pinnedSx, _ as hasColumnLabel, f as cellSelectionSx, h as columnFlex, m as columnAlign, p as classNames, r as AggregatedCell, t as ChatLayout, v as layoutTableClasses, w as toClipboardText, x as pinnedClass, y as lookaheadRange } from "./ChatLayout-B0MBrI-Y.mjs";
4
+ import { o as getFieldStatus } from "./utils-H4BskGF8.mjs";
5
5
  import { c } from "react/compiler-runtime";
6
- import { Box, Button, ButtonBase, Card, CardContent, CircularProgress, Dialog, Divider, Fab, IconButton, ImageListItem, ImageListItemBar, List, ListItem, ListItemButton, ListItemIcon, ListItemText, Menu, MenuItem, Paper, Skeleton, Stack, Tab, Table, TableBody, TableCell, TableContainer, TableFooter, TableHead, TableRow, Tooltip, Typography, alpha, useTheme } from "@mui/material";
7
- import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
8
- import React, { Fragment, createContext, useContext, useEffect, useEffectEvent, useLayoutEffect, useMemo, useRef, useState } from "react";
6
+ import { Box, ButtonBase, ClickAwayListener, Dialog, Divider, Fab, IconButton, ImageListItem, ImageListItemBar, LinearProgress, List, ListItem, ListItemButton, ListItemIcon, ListItemText, Menu, MenuItem, Paper, Skeleton, Stack, Table, TableBody, TableCell, TableContainer, TableFooter, TableHead, TableRow, Tooltip, Typography, useTheme } from "@mui/material";
7
+ import { useMutation, useQuery } from "@tanstack/react-query";
8
+ import { Fragment, createContext, useCallback, useContext, useEffect, useEffectEvent, useLayoutEffect, useMemo, useRef, useState } from "react";
9
9
  import { useTranslation } from "react-i18next";
10
- import { manifest } from "virtual:wcz-layout";
11
- import { createLink, rootRouteId, useLocation, useMatch } from "@tanstack/react-router";
10
+ import { rootRouteId, useMatch } from "@tanstack/react-router";
12
11
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
13
12
  import ChevronRight from "@mui/icons-material/ChevronRight";
14
13
  import Close from "@mui/icons-material/Close";
15
- import CloudQueue from "@mui/icons-material/CloudQueue";
16
- import Microsoft from "@mui/icons-material/Microsoft";
17
14
  import CloudUpload from "@mui/icons-material/CloudUpload";
18
15
  import { useDropzone } from "react-dropzone";
19
16
  import MoreVert from "@mui/icons-material/MoreVert";
20
17
  import { grey } from "@mui/material/colors";
21
- import { useInView } from "react-intersection-observer";
22
18
  import Delete from "@mui/icons-material/Delete";
23
19
  import FileDownload from "@mui/icons-material/FileDownload";
24
20
  import AttachFile from "@mui/icons-material/AttachFile";
25
- import Image from "@mui/icons-material/Image";
21
+ import Image$1 from "@mui/icons-material/Image";
26
22
  import SmartDisplay from "@mui/icons-material/SmartDisplay";
27
23
  import ChevronLeft from "@mui/icons-material/ChevronLeft";
24
+ import EditOutlined from "@mui/icons-material/EditOutlined";
28
25
  import { useHotkeys } from "@tanstack/react-hotkeys";
29
26
  import { useVirtualizer } from "@tanstack/react-virtual";
30
- // src/components/core/account/LoginForm.tsx
31
- const LAST_PROVIDER_KEY = "auth-provider";
32
- const PROVIDER_ICON = {
33
- entra: /* @__PURE__ */ jsx(Microsoft, {}),
34
- aws: /* @__PURE__ */ jsx(CloudQueue, {})
35
- };
36
- /**
37
- * The provider chooser card. Mount it at `/login` — `requireAuth` redirects there,
38
- * and it reads `?returnTo` from the URL itself, so it takes no props.
39
- */
40
- const LoginForm = () => {
41
- const $ = c(35);
42
- const { data: t0 } = useQuery(loginProvidersQueryOptions);
43
- let t1;
44
- if ($[0] !== t0) {
45
- t1 = t0 === void 0 ? [] : t0;
46
- $[0] = t0;
47
- $[1] = t1;
48
- } else t1 = $[1];
49
- const providers = t1;
50
- let t2;
51
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
52
- t2 = { select: _temp$2 };
53
- $[2] = t2;
54
- } else t2 = $[2];
55
- const search = useLocation(t2);
56
- let t3;
57
- if ($[3] !== search.returnTo) {
58
- t3 = sanitizeReturnTo(search.returnTo);
59
- $[3] = search.returnTo;
60
- $[4] = t3;
61
- } else t3 = $[4];
62
- const returnTo = t3;
63
- const { t } = useTranslation();
64
- const [lastProvider, setLastProvider] = useState(null);
65
- let t4;
66
- let t5;
67
- if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
68
- t4 = () => setLastProvider(localStorage.getItem(LAST_PROVIDER_KEY));
69
- t5 = [];
70
- $[5] = t4;
71
- $[6] = t5;
72
- } else {
73
- t4 = $[5];
74
- t5 = $[6];
75
- }
76
- useEffect(t4, t5);
77
- const preferred = lastProvider ?? (providers.length === 1 ? providers[0].id : null);
78
- let t6;
79
- if ($[7] !== returnTo) {
80
- t6 = (provider) => () => {
81
- localStorage.setItem(LAST_PROVIDER_KEY, provider);
82
- location.href = `/auth/login?provider=${provider}&returnTo=${encodeURIComponent(returnTo)}`;
83
- };
84
- $[7] = returnTo;
85
- $[8] = t6;
86
- } else t6 = $[8];
87
- const signIn = t6;
88
- let t7;
89
- if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
90
- t7 = {
91
- minHeight: "100%",
92
- display: "flex",
93
- alignItems: "center",
94
- justifyContent: "center",
95
- px: 2,
96
- py: 6
97
- };
98
- $[9] = t7;
99
- } else t7 = $[9];
100
- let t8;
101
- if ($[10] === Symbol.for("react.memo_cache_sentinel")) {
102
- t8 = [_temp2, _temp3];
103
- $[10] = t8;
104
- } else t8 = $[10];
105
- let t9;
106
- if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
107
- t9 = { p: {
108
- xs: 3,
109
- sm: 4
110
- } };
111
- $[11] = t9;
112
- } else t9 = $[11];
113
- let t10;
114
- let t11;
115
- if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
116
- t10 = { alignItems: "center" };
117
- t11 = /* @__PURE__ */ jsx(Box, {
118
- component: "img",
119
- src: "/android-chrome-192x192.png",
120
- alt: "",
121
- width: 48,
122
- height: 48
123
- });
124
- $[12] = t10;
125
- $[13] = t11;
126
- } else {
127
- t10 = $[12];
128
- t11 = $[13];
129
- }
130
- let t12;
131
- if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
132
- t12 = /* @__PURE__ */ jsx(Typography, {
133
- variant: "body2",
134
- color: "text.secondary",
135
- sx: { fontWeight: 600 },
136
- children: manifest.name
137
- });
138
- $[14] = t12;
139
- } else t12 = $[14];
140
- let t13;
141
- if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
142
- t13 = { fontWeight: 700 };
143
- $[15] = t13;
144
- } else t13 = $[15];
145
- let t14;
146
- if ($[16] !== t) {
147
- t14 = t("Layout.LogIn");
148
- $[16] = t;
149
- $[17] = t14;
150
- } else t14 = $[17];
151
- let t15;
152
- if ($[18] !== t14) {
153
- t15 = /* @__PURE__ */ jsxs(Stack, {
154
- direction: "row",
155
- spacing: 2,
156
- sx: t10,
157
- children: [t11, /* @__PURE__ */ jsxs(Stack, {
158
- spacing: .25,
159
- children: [t12, /* @__PURE__ */ jsx(Typography, {
160
- variant: "h5",
161
- component: "h1",
162
- sx: t13,
163
- children: t14
164
- })]
165
- })]
166
- });
167
- $[18] = t14;
168
- $[19] = t15;
169
- } else t15 = $[19];
170
- let t16;
171
- if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
172
- t16 = /* @__PURE__ */ jsx(Divider, { sx: { my: 3 } });
173
- $[20] = t16;
174
- } else t16 = $[20];
175
- let t17;
176
- if ($[21] !== preferred || $[22] !== providers || $[23] !== signIn || $[24] !== t) {
177
- let t18;
178
- if ($[26] !== preferred || $[27] !== signIn || $[28] !== t) {
179
- t18 = (t19) => {
180
- const { id, label } = t19;
181
- return /* @__PURE__ */ jsx(Button, {
182
- fullWidth: true,
183
- size: "large",
184
- startIcon: PROVIDER_ICON[id],
185
- variant: id === preferred ? "contained" : "outlined",
186
- onClick: signIn(id),
187
- sx: {
188
- minHeight: 52,
189
- px: 2,
190
- borderRadius: 1,
191
- fontWeight: 600,
192
- textTransform: "none",
193
- boxShadow: "none"
194
- },
195
- children: t("Layout.ContinueWith", { provider: label })
196
- }, id);
197
- };
198
- $[26] = preferred;
199
- $[27] = signIn;
200
- $[28] = t;
201
- $[29] = t18;
202
- } else t18 = $[29];
203
- t17 = providers.map(t18);
204
- $[21] = preferred;
205
- $[22] = providers;
206
- $[23] = signIn;
207
- $[24] = t;
208
- $[25] = t17;
209
- } else t17 = $[25];
210
- let t18;
211
- if ($[30] !== t17) {
212
- t18 = /* @__PURE__ */ jsx(Stack, {
213
- spacing: 1.5,
214
- children: t17
215
- });
216
- $[30] = t17;
217
- $[31] = t18;
218
- } else t18 = $[31];
219
- let t19;
220
- if ($[32] !== t15 || $[33] !== t18) {
221
- t19 = /* @__PURE__ */ jsx(Box, {
222
- sx: t7,
223
- children: /* @__PURE__ */ jsx(Card, {
224
- variant: "outlined",
225
- sx: t8,
226
- children: /* @__PURE__ */ jsxs(CardContent, {
227
- sx: t9,
228
- children: [
229
- t15,
230
- t16,
231
- t18
232
- ]
233
- })
234
- })
235
- });
236
- $[32] = t15;
237
- $[33] = t18;
238
- $[34] = t19;
239
- } else t19 = $[34];
240
- return t19;
241
- };
242
- function _temp$2(location) {
243
- return location.search;
244
- }
245
- function _temp2(theme) {
246
- return {
247
- width: "100%",
248
- maxWidth: 440,
249
- borderColor: alpha(theme.palette.primary.main, .2),
250
- borderRadius: 1,
251
- boxShadow: `0 20px 50px ${alpha(theme.palette.common.black, .08)}`
252
- };
253
- }
254
- function _temp3(theme_0) {
255
- return theme_0.applyStyles("dark", {
256
- borderColor: alpha(theme_0.palette.primary.main, .28),
257
- boxShadow: `0 20px 50px ${alpha(theme_0.palette.common.black, .28)}`
258
- });
259
- }
260
27
  // src/components/core/Fullscreen.tsx
261
28
  const isScrollContainer = (element) => /auto|scroll|overlay/.test(getComputedStyle(element).overflowY);
262
29
  /** Ancestors up to and including the nearest scroll container (or the root element). */
@@ -384,7 +151,7 @@ const baseStyle = {
384
151
  cursor: "pointer"
385
152
  };
386
153
  const Dropzone = (t0) => {
387
- const $ = c(32);
154
+ const $ = c(36);
388
155
  let progress;
389
156
  let props;
390
157
  let sx;
@@ -456,48 +223,75 @@ const Dropzone = (t0) => {
456
223
  $[18] = t6;
457
224
  } else t6 = $[18];
458
225
  let t7;
459
- if ($[19] !== progress) {
460
- t7 = progress ? /* @__PURE__ */ jsx(CircularProgress, {
461
- size: 24,
462
- variant: "determinate",
463
- value: progress,
464
- "aria-label": "Uploading"
465
- }) : /* @__PURE__ */ jsx(CloudUpload, {});
466
- $[19] = progress;
467
- $[20] = t7;
468
- } else t7 = $[20];
226
+ if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
227
+ t7 = {
228
+ display: "flex",
229
+ flexDirection: "column",
230
+ alignItems: "center"
231
+ };
232
+ $[19] = t7;
233
+ } else t7 = $[19];
469
234
  let t8;
470
- if ($[21] !== t) {
471
- t8 = t("Layout.File.DragSomeFilesHereOrClickToSelectThem");
472
- $[21] = t;
473
- $[22] = t8;
474
- } else t8 = $[22];
235
+ if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
236
+ t8 = {
237
+ display: "flex",
238
+ alignItems: "center",
239
+ width: "100%",
240
+ height: "1.5rem"
241
+ };
242
+ $[20] = t8;
243
+ } else t8 = $[20];
475
244
  let t9;
476
- if ($[23] !== t8) {
477
- t9 = /* @__PURE__ */ jsx(Typography, { children: t8 });
478
- $[23] = t8;
479
- $[24] = t9;
480
- } else t9 = $[24];
245
+ if ($[21] !== progress) {
246
+ t9 = /* @__PURE__ */ jsx(Box, {
247
+ sx: t8,
248
+ children: progress ? /* @__PURE__ */ jsx(LinearProgress, {
249
+ variant: "determinate",
250
+ value: progress,
251
+ "aria-label": "Uploading",
252
+ sx: { width: "100%" }
253
+ }) : /* @__PURE__ */ jsx(CloudUpload, { sx: { mx: "auto" } })
254
+ });
255
+ $[21] = progress;
256
+ $[22] = t9;
257
+ } else t9 = $[22];
481
258
  let t10;
482
- if ($[25] !== T0 || $[26] !== sx || $[27] !== t3 || $[28] !== t6 || $[29] !== t7 || $[30] !== t9) {
483
- t10 = /* @__PURE__ */ jsxs(T0, {
259
+ if ($[23] !== t) {
260
+ t10 = t("Layout.File.DragSomeFilesHereOrClickToSelectThem");
261
+ $[23] = t;
262
+ $[24] = t10;
263
+ } else t10 = $[24];
264
+ let t11;
265
+ if ($[25] !== t10) {
266
+ t11 = /* @__PURE__ */ jsx(Typography, { children: t10 });
267
+ $[25] = t10;
268
+ $[26] = t11;
269
+ } else t11 = $[26];
270
+ let t12;
271
+ if ($[27] !== t11 || $[28] !== t9) {
272
+ t12 = /* @__PURE__ */ jsxs(Box, {
273
+ sx: t7,
274
+ children: [t9, t11]
275
+ });
276
+ $[27] = t11;
277
+ $[28] = t9;
278
+ $[29] = t12;
279
+ } else t12 = $[29];
280
+ let t13;
281
+ if ($[30] !== T0 || $[31] !== sx || $[32] !== t12 || $[33] !== t3 || $[34] !== t6) {
282
+ t13 = /* @__PURE__ */ jsxs(T0, {
484
283
  ...t3,
485
284
  sx,
486
- children: [
487
- t6,
488
- t7,
489
- t9
490
- ]
285
+ children: [t6, t12]
491
286
  });
492
- $[25] = T0;
493
- $[26] = sx;
494
- $[27] = t3;
495
- $[28] = t6;
496
- $[29] = t7;
497
- $[30] = t9;
498
- $[31] = t10;
499
- } else t10 = $[31];
500
- return t10;
287
+ $[30] = T0;
288
+ $[31] = sx;
289
+ $[32] = t12;
290
+ $[33] = t3;
291
+ $[34] = t6;
292
+ $[35] = t13;
293
+ } else t13 = $[35];
294
+ return t13;
501
295
  };
502
296
  // src/contexts/FileContext.ts
503
297
  const FileContext = createContext(null);
@@ -506,12 +300,61 @@ const useFile = () => {
506
300
  if (!context) throw new Error("FileViewer components must be used within FileViewer");
507
301
  return context;
508
302
  };
303
+ /**
304
+ * Opening a file: an image in the viewer, anything else in a new tab. The file service shows
305
+ * what the browser can (Office files as PDF) and downloads the rest.
306
+ */
307
+ const useOpenFile = (meta) => {
308
+ const $ = c(13);
309
+ const { setImageId, actions } = useFile();
310
+ let t0;
311
+ if ($[0] !== meta.id || $[1] !== meta.mediaType || $[2] !== meta.urls || $[3] !== setImageId) {
312
+ t0 = () => {
313
+ if (meta.mediaType === "image") return setImageId(meta.id);
314
+ window.open(meta.urls.view, "_blank", "noopener");
315
+ };
316
+ $[0] = meta.id;
317
+ $[1] = meta.mediaType;
318
+ $[2] = meta.urls;
319
+ $[3] = setImageId;
320
+ $[4] = t0;
321
+ } else t0 = $[4];
322
+ const open = t0;
323
+ let t1;
324
+ if ($[5] !== meta.fileSize || $[6] !== meta.urls) {
325
+ t1 = () => {
326
+ if (meta.fileSize <= 20971520) fetch(meta.urls.view, { mode: "no-cors" }).catch(_temp$2);
327
+ };
328
+ $[5] = meta.fileSize;
329
+ $[6] = meta.urls;
330
+ $[7] = t1;
331
+ } else t1 = $[7];
332
+ const prefetch = t1;
333
+ const t2 = `${meta.fileName}.${meta.fileExtension}`;
334
+ const t3 = actions?.download !== false || actions.delete !== false && meta.canWrite;
335
+ let t4;
336
+ if ($[8] !== open || $[9] !== prefetch || $[10] !== t2 || $[11] !== t3) {
337
+ t4 = {
338
+ open,
339
+ prefetch,
340
+ fileName: t2,
341
+ hasActions: t3
342
+ };
343
+ $[8] = open;
344
+ $[9] = prefetch;
345
+ $[10] = t2;
346
+ $[11] = t3;
347
+ $[12] = t4;
348
+ } else t4 = $[12];
349
+ return t4;
350
+ };
351
+ function _temp$2() {}
509
352
  // src/components/file/fileViewer/common/ActionsMenu.tsx
510
353
  const ActionsMenu = (t0) => {
511
- const $ = c(37);
354
+ const $ = c(29);
512
355
  const { meta, anchorEl, onClose } = t0;
513
356
  const { t } = useTranslation();
514
- const { fileMetas, onDelete, actions, appName } = useFile();
357
+ const { fileMetas, onDelete, actions } = useFile();
515
358
  const { alert, confirm } = useDialogs();
516
359
  let t1;
517
360
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -520,53 +363,24 @@ const ActionsMenu = (t0) => {
520
363
  } else t1 = $[0];
521
364
  const queryClient = useMatch(t1).context.queryClient;
522
365
  let t2;
523
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
524
- t2 = downloadFileMutationOptions();
525
- $[1] = t2;
526
- } else t2 = $[1];
527
- const { mutate: download, isPending: isDownloading } = useMutation(t2);
366
+ if ($[1] !== queryClient) {
367
+ t2 = deleteFileMutationOptions({ queryClient });
368
+ $[1] = queryClient;
369
+ $[2] = t2;
370
+ } else t2 = $[2];
371
+ const { mutateAsync: deleteFile, isPending: isDeleting } = useMutation(t2);
528
372
  let t3;
529
- if ($[2] !== queryClient) {
530
- t3 = deleteFileMutationOptions({ queryClient });
531
- $[2] = queryClient;
532
- $[3] = t3;
533
- } else t3 = $[3];
534
- const { mutateAsync: deleteFile, isPending: isDeleting } = useMutation(t3);
535
- let t4;
536
- if ($[4] !== appName || $[5] !== download || $[6] !== meta.fileExtension || $[7] !== meta.fileName || $[8] !== meta.id || $[9] !== onClose) {
537
- t4 = () => {
538
- onClose();
539
- download({
540
- id: meta.id,
541
- appName,
542
- fileName: meta.fileName,
543
- fileExtension: meta.fileExtension
544
- });
545
- };
546
- $[4] = appName;
547
- $[5] = download;
548
- $[6] = meta.fileExtension;
549
- $[7] = meta.fileName;
550
- $[8] = meta.id;
551
- $[9] = onClose;
552
- $[10] = t4;
553
- } else t4 = $[10];
554
- const handleOnDownload = t4;
555
- let t5;
556
- if ($[11] !== alert || $[12] !== appName || $[13] !== confirm || $[14] !== deleteFile || $[15] !== fileMetas || $[16] !== meta || $[17] !== onClose || $[18] !== onDelete || $[19] !== t) {
557
- t5 = async () => {
373
+ if ($[3] !== alert || $[4] !== confirm || $[5] !== deleteFile || $[6] !== fileMetas || $[7] !== meta || $[8] !== onClose || $[9] !== onDelete || $[10] !== t) {
374
+ t3 = async () => {
558
375
  onClose();
559
376
  if (!await confirm(t("Layout.File.AreYouSureYouWantToDelete", { name: meta.fileName }), {
560
377
  title: t("Layout.File.Delete"),
561
378
  confirmText: t("Layout.File.Delete")
562
379
  })) return;
563
380
  try {
564
- await deleteFile({
565
- id: meta.id,
566
- appName
567
- });
568
- } catch (t6) {
569
- const error = t6;
381
+ await deleteFile({ id: meta.id });
382
+ } catch (t4) {
383
+ const error = t4;
570
384
  await alert(error instanceof Error ? error.message : String(error));
571
385
  return;
572
386
  }
@@ -575,61 +389,62 @@ const ActionsMenu = (t0) => {
575
389
  deletedFileMeta: meta
576
390
  });
577
391
  };
578
- $[11] = alert;
579
- $[12] = appName;
580
- $[13] = confirm;
581
- $[14] = deleteFile;
582
- $[15] = fileMetas;
583
- $[16] = meta;
584
- $[17] = onClose;
585
- $[18] = onDelete;
586
- $[19] = t;
587
- $[20] = t5;
588
- } else t5 = $[20];
589
- const handleOnDelete = t5;
590
- const t6 = !!anchorEl;
591
- let t7;
592
- if ($[21] !== actions?.download || $[22] !== handleOnDownload || $[23] !== isDownloading || $[24] !== t) {
593
- t7 = actions?.download !== false && /* @__PURE__ */ jsxs(MenuItem, {
594
- onClick: handleOnDownload,
595
- disabled: isDownloading,
392
+ $[3] = alert;
393
+ $[4] = confirm;
394
+ $[5] = deleteFile;
395
+ $[6] = fileMetas;
396
+ $[7] = meta;
397
+ $[8] = onClose;
398
+ $[9] = onDelete;
399
+ $[10] = t;
400
+ $[11] = t3;
401
+ } else t3 = $[11];
402
+ const handleOnDelete = t3;
403
+ const t4 = !!anchorEl;
404
+ let t5;
405
+ if ($[12] !== actions?.download || $[13] !== meta.urls || $[14] !== onClose || $[15] !== t) {
406
+ t5 = actions?.download !== false && /* @__PURE__ */ jsxs(MenuItem, {
407
+ component: "a",
408
+ href: meta.urls.download,
409
+ onClick: onClose,
596
410
  children: [/* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(FileDownload, {}) }), /* @__PURE__ */ jsx(ListItemText, { children: t("Layout.File.Download") })]
597
411
  });
598
- $[21] = actions?.download;
599
- $[22] = handleOnDownload;
600
- $[23] = isDownloading;
601
- $[24] = t;
602
- $[25] = t7;
603
- } else t7 = $[25];
604
- let t8;
605
- if ($[26] !== actions?.delete || $[27] !== handleOnDelete || $[28] !== isDeleting || $[29] !== t) {
606
- t8 = actions?.delete !== false && /* @__PURE__ */ jsxs(MenuItem, {
412
+ $[12] = actions?.download;
413
+ $[13] = meta.urls;
414
+ $[14] = onClose;
415
+ $[15] = t;
416
+ $[16] = t5;
417
+ } else t5 = $[16];
418
+ let t6;
419
+ if ($[17] !== actions?.delete || $[18] !== handleOnDelete || $[19] !== isDeleting || $[20] !== meta.canWrite || $[21] !== t) {
420
+ t6 = actions?.delete !== false && meta.canWrite && /* @__PURE__ */ jsxs(MenuItem, {
607
421
  onClick: handleOnDelete,
608
422
  disabled: isDeleting,
609
423
  children: [/* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(Delete, {}) }), /* @__PURE__ */ jsx(ListItemText, { children: t("Layout.File.Delete") })]
610
424
  });
611
- $[26] = actions?.delete;
612
- $[27] = handleOnDelete;
613
- $[28] = isDeleting;
614
- $[29] = t;
615
- $[30] = t8;
616
- } else t8 = $[30];
617
- let t9;
618
- if ($[31] !== anchorEl || $[32] !== onClose || $[33] !== t6 || $[34] !== t7 || $[35] !== t8) {
619
- t9 = /* @__PURE__ */ jsxs(Menu, {
425
+ $[17] = actions?.delete;
426
+ $[18] = handleOnDelete;
427
+ $[19] = isDeleting;
428
+ $[20] = meta.canWrite;
429
+ $[21] = t;
430
+ $[22] = t6;
431
+ } else t6 = $[22];
432
+ let t7;
433
+ if ($[23] !== anchorEl || $[24] !== onClose || $[25] !== t4 || $[26] !== t5 || $[27] !== t6) {
434
+ t7 = /* @__PURE__ */ jsxs(Menu, {
620
435
  anchorEl,
621
- open: t6,
436
+ open: t4,
622
437
  onClose,
623
- children: [t7, t8]
438
+ children: [t5, t6]
624
439
  });
625
- $[31] = anchorEl;
626
- $[32] = onClose;
627
- $[33] = t6;
628
- $[34] = t7;
629
- $[35] = t8;
630
- $[36] = t9;
631
- } else t9 = $[36];
632
- return t9;
440
+ $[23] = anchorEl;
441
+ $[24] = onClose;
442
+ $[25] = t4;
443
+ $[26] = t5;
444
+ $[27] = t6;
445
+ $[28] = t7;
446
+ } else t7 = $[28];
447
+ return t7;
633
448
  };
634
449
  // src/components/file/fileViewer/FileViewerGrid.tsx
635
450
  const IMAGE_SIZE = 150;
@@ -679,108 +494,161 @@ const FileViewerGrid = (t0) => {
679
494
  } else t3 = $[11];
680
495
  return t3;
681
496
  };
682
- const GridFileViewerItem = ({ meta, size, itemBar }) => {
683
- const { setImageId, actions, appName } = useFile();
497
+ const GridFileViewerItem = (t0) => {
498
+ const $ = c(36);
499
+ const { meta, size, itemBar } = t0;
500
+ const { open, prefetch, fileName, hasActions } = useOpenFile(meta);
684
501
  const [hovered, setHovered] = useState(false);
685
502
  const [focused, setFocused] = useState(false);
686
503
  const [menuAnchor, setMenuAnchor] = useState(null);
687
- const { ref, inView } = useInView({ triggerOnce: true });
688
- const queryClient = useQueryClient();
689
- const target = useRef(null);
690
504
  const side = size ?? IMAGE_SIZE;
691
- const fileName = `${meta.fileName}.${meta.fileExtension}`;
692
- const hasActions = actions?.download !== false || actions.delete !== false;
693
505
  const showItemBar = itemBar === "always" || itemBar !== "hidden" && (hovered || focused || !!menuAnchor);
694
- const { data: source, isPending } = useQuery({
695
- ...fileThumbnailQueryOptions({
696
- id: meta.id,
697
- appName
698
- }),
699
- enabled: inView
700
- });
701
- const { mutate: openFile } = useMutation(openFileMutationOptions({ target }));
702
- const { mutate: download } = useMutation(downloadFileMutationOptions());
703
- const prefetch = () => queryClient.prefetchQuery(fileQueryOptions({
704
- id: meta.id,
705
- appName
706
- }));
707
- const onClick = () => {
708
- switch (meta.mediaType) {
709
- case "image": return setImageId(meta.id);
710
- case "application":
711
- case "video":
712
- target.current = window.open("about:blank", "_blank");
713
- return openFile({
714
- id: meta.id,
715
- appName
716
- });
717
- default: return download({
718
- id: meta.id,
719
- appName,
720
- fileName: meta.fileName,
721
- fileExtension: meta.fileExtension
722
- });
723
- }
724
- };
725
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs(ImageListItem, {
726
- sx: {
506
+ let t1;
507
+ if ($[0] !== side) {
508
+ t1 = {
727
509
  width: side,
728
510
  height: side
729
- },
730
- onMouseEnter: () => setHovered(true),
731
- onMouseLeave: () => setHovered(false),
732
- onFocus: () => setFocused(true),
733
- onBlur: (event) => {
511
+ };
512
+ $[0] = side;
513
+ $[1] = t1;
514
+ } else t1 = $[1];
515
+ let t2;
516
+ let t3;
517
+ let t4;
518
+ let t5;
519
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
520
+ t2 = () => setHovered(true);
521
+ t3 = () => setHovered(false);
522
+ t4 = () => setFocused(true);
523
+ t5 = (event) => {
734
524
  if (!event.currentTarget.contains(event.relatedTarget)) setFocused(false);
735
- },
736
- ref,
737
- children: [isPending ? /* @__PURE__ */ jsx(Skeleton, {
738
- variant: "rectangular",
525
+ };
526
+ $[2] = t2;
527
+ $[3] = t3;
528
+ $[4] = t4;
529
+ $[5] = t5;
530
+ } else {
531
+ t2 = $[2];
532
+ t3 = $[3];
533
+ t4 = $[4];
534
+ t5 = $[5];
535
+ }
536
+ const t6 = `Open ${fileName}`;
537
+ let t7;
538
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
539
+ t7 = {
540
+ outline: "2px solid",
541
+ outlineColor: "primary.main",
542
+ outlineOffset: -2
543
+ };
544
+ $[6] = t7;
545
+ } else t7 = $[6];
546
+ let t8;
547
+ if ($[7] !== side) {
548
+ t8 = {
549
+ width: side,
550
+ height: side,
551
+ "&.Mui-focusVisible": t7
552
+ };
553
+ $[7] = side;
554
+ $[8] = t8;
555
+ } else t8 = $[8];
556
+ let t9;
557
+ if ($[9] !== side) {
558
+ t9 = {
559
+ objectFit: "contain",
739
560
  width: side,
740
561
  height: side
741
- }) : /* @__PURE__ */ jsx(ButtonBase, {
742
- onClick,
562
+ };
563
+ $[9] = side;
564
+ $[10] = t9;
565
+ } else t9 = $[10];
566
+ let t10;
567
+ if ($[11] !== meta.urls.thumbnail || $[12] !== t9) {
568
+ t10 = /* @__PURE__ */ jsx(Box, {
569
+ component: "img",
570
+ src: meta.urls.thumbnail,
571
+ loading: "lazy",
572
+ alt: "",
573
+ sx: t9
574
+ });
575
+ $[11] = meta.urls.thumbnail;
576
+ $[12] = t9;
577
+ $[13] = t10;
578
+ } else t10 = $[13];
579
+ let t11;
580
+ if ($[14] !== open || $[15] !== prefetch || $[16] !== t10 || $[17] !== t6 || $[18] !== t8) {
581
+ t11 = /* @__PURE__ */ jsx(ButtonBase, {
582
+ onClick: open,
743
583
  onMouseEnter: prefetch,
744
584
  onFocus: prefetch,
745
- "aria-label": `Open ${fileName}`,
746
- sx: {
747
- width: side,
748
- height: side,
749
- "&.Mui-focusVisible": {
750
- outline: "2px solid",
751
- outlineColor: "primary.main",
752
- outlineOffset: -2
753
- }
754
- },
755
- children: /* @__PURE__ */ jsx(Box, {
756
- component: "img",
757
- src: source,
758
- loading: "lazy",
759
- alt: "",
760
- sx: {
761
- objectFit: "contain",
762
- width: side,
763
- height: side
764
- }
765
- })
766
- }), showItemBar && /* @__PURE__ */ jsx(ImageListItemBar, {
585
+ "aria-label": t6,
586
+ sx: t8,
587
+ children: t10
588
+ });
589
+ $[14] = open;
590
+ $[15] = prefetch;
591
+ $[16] = t10;
592
+ $[17] = t6;
593
+ $[18] = t8;
594
+ $[19] = t11;
595
+ } else t11 = $[19];
596
+ let t12;
597
+ if ($[20] !== fileName || $[21] !== hasActions || $[22] !== meta.fileName || $[23] !== showItemBar) {
598
+ t12 = showItemBar && /* @__PURE__ */ jsx(ImageListItemBar, {
767
599
  title: /* @__PURE__ */ jsx(Tooltip, {
768
600
  title: fileName,
769
601
  children: /* @__PURE__ */ jsx(Box, { children: meta.fileName })
770
602
  }),
771
603
  actionIcon: hasActions && /* @__PURE__ */ jsx(IconButton, {
772
604
  sx: { color: grey[100] },
773
- onClick: (event) => setMenuAnchor(event.currentTarget),
605
+ onClick: (event_0) => setMenuAnchor(event_0.currentTarget),
774
606
  "aria-label": `Actions for ${fileName}`,
775
607
  "aria-haspopup": "menu",
776
608
  children: /* @__PURE__ */ jsx(MoreVert, {})
777
609
  })
778
- })]
779
- }), hasActions && /* @__PURE__ */ jsx(ActionsMenu, {
780
- meta,
781
- anchorEl: menuAnchor,
782
- onClose: () => setMenuAnchor(null)
783
- })] });
610
+ });
611
+ $[20] = fileName;
612
+ $[21] = hasActions;
613
+ $[22] = meta.fileName;
614
+ $[23] = showItemBar;
615
+ $[24] = t12;
616
+ } else t12 = $[24];
617
+ let t13;
618
+ if ($[25] !== t1 || $[26] !== t11 || $[27] !== t12) {
619
+ t13 = /* @__PURE__ */ jsxs(ImageListItem, {
620
+ sx: t1,
621
+ onMouseEnter: t2,
622
+ onMouseLeave: t3,
623
+ onFocus: t4,
624
+ onBlur: t5,
625
+ children: [t11, t12]
626
+ });
627
+ $[25] = t1;
628
+ $[26] = t11;
629
+ $[27] = t12;
630
+ $[28] = t13;
631
+ } else t13 = $[28];
632
+ let t14;
633
+ if ($[29] !== hasActions || $[30] !== menuAnchor || $[31] !== meta) {
634
+ t14 = hasActions && /* @__PURE__ */ jsx(ActionsMenu, {
635
+ meta,
636
+ anchorEl: menuAnchor,
637
+ onClose: () => setMenuAnchor(null)
638
+ });
639
+ $[29] = hasActions;
640
+ $[30] = menuAnchor;
641
+ $[31] = meta;
642
+ $[32] = t14;
643
+ } else t14 = $[32];
644
+ let t15;
645
+ if ($[33] !== t13 || $[34] !== t14) {
646
+ t15 = /* @__PURE__ */ jsxs(Fragment, { children: [t13, t14] });
647
+ $[33] = t13;
648
+ $[34] = t14;
649
+ $[35] = t15;
650
+ } else t15 = $[35];
651
+ return t15;
784
652
  };
785
653
  // src/components/file/fileViewer/FileViewerList.tsx
786
654
  const FileViewerList = (t0) => {
@@ -806,149 +674,166 @@ const FileViewerList = (t0) => {
806
674
  } else t2 = $[4];
807
675
  return t2;
808
676
  };
809
- const ListFileViewerItem = ({ meta }) => {
810
- const { setImageId, actions, appName } = useFile();
677
+ const ListFileViewerItem = (t0) => {
678
+ const $ = c(24);
679
+ const { meta } = t0;
680
+ const { open, prefetch, fileName, hasActions } = useOpenFile(meta);
811
681
  const [menuAnchor, setMenuAnchor] = useState(null);
812
- const queryClient = useQueryClient();
813
- const target = useRef(null);
814
- const fileName = `${meta.fileName}.${meta.fileExtension}`;
815
- const hasActions = actions?.download !== false || actions.delete !== false;
816
- const { mutate: openFile } = useMutation(openFileMutationOptions({ target }));
817
- const { mutate: download } = useMutation(downloadFileMutationOptions());
818
- const onClick = () => {
819
- switch (meta.mediaType) {
820
- case "image": return setImageId(meta.id);
821
- case "application":
822
- case "video":
823
- target.current = window.open("about:blank", "_blank");
824
- return openFile({
825
- id: meta.id,
826
- appName
827
- });
828
- default: return download({
829
- id: meta.id,
830
- appName,
831
- fileName: meta.fileName,
832
- fileExtension: meta.fileExtension
833
- });
834
- }
835
- };
836
- const icon = () => {
837
- switch (meta.mediaType) {
838
- case "image": return /* @__PURE__ */ jsx(Image, {});
839
- case "video": return /* @__PURE__ */ jsx(SmartDisplay, {});
840
- default: return /* @__PURE__ */ jsx(AttachFile, {});
841
- }
842
- };
843
- return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ListItem, {
844
- disablePadding: true,
845
- secondaryAction: hasActions && /* @__PURE__ */ jsx(IconButton, {
682
+ let t1;
683
+ if ($[0] !== meta.mediaType) {
684
+ t1 = () => {
685
+ switch (meta.mediaType) {
686
+ case "image": return /* @__PURE__ */ jsx(Image$1, {});
687
+ case "video": return /* @__PURE__ */ jsx(SmartDisplay, {});
688
+ default: return /* @__PURE__ */ jsx(AttachFile, {});
689
+ }
690
+ };
691
+ $[0] = meta.mediaType;
692
+ $[1] = t1;
693
+ } else t1 = $[1];
694
+ const icon = t1;
695
+ let t2;
696
+ if ($[2] !== fileName || $[3] !== hasActions) {
697
+ t2 = hasActions && /* @__PURE__ */ jsx(IconButton, {
846
698
  edge: "end",
847
699
  onClick: (event) => setMenuAnchor(event.currentTarget),
848
700
  "aria-label": `Actions for ${fileName}`,
849
701
  "aria-haspopup": "menu",
850
702
  children: /* @__PURE__ */ jsx(MoreVert, {})
851
- }),
852
- children: /* @__PURE__ */ jsxs(ListItemButton, {
853
- onClick,
854
- onMouseEnter: () => queryClient.prefetchQuery(fileQueryOptions({
855
- id: meta.id,
856
- appName
857
- })),
858
- children: [/* @__PURE__ */ jsx(ListItemIcon, { children: icon() }), /* @__PURE__ */ jsx(ListItemText, { primary: fileName })]
859
- })
860
- }), hasActions && /* @__PURE__ */ jsx(ActionsMenu, {
861
- meta,
862
- anchorEl: menuAnchor,
863
- onClose: () => setMenuAnchor(null)
864
- })] });
703
+ });
704
+ $[2] = fileName;
705
+ $[3] = hasActions;
706
+ $[4] = t2;
707
+ } else t2 = $[4];
708
+ let t3;
709
+ if ($[5] !== icon) {
710
+ t3 = /* @__PURE__ */ jsx(ListItemIcon, { children: icon() });
711
+ $[5] = icon;
712
+ $[6] = t3;
713
+ } else t3 = $[6];
714
+ let t4;
715
+ if ($[7] !== fileName) {
716
+ t4 = /* @__PURE__ */ jsx(ListItemText, { primary: fileName });
717
+ $[7] = fileName;
718
+ $[8] = t4;
719
+ } else t4 = $[8];
720
+ let t5;
721
+ if ($[9] !== open || $[10] !== prefetch || $[11] !== t3 || $[12] !== t4) {
722
+ t5 = /* @__PURE__ */ jsxs(ListItemButton, {
723
+ onClick: open,
724
+ onMouseEnter: prefetch,
725
+ onFocus: prefetch,
726
+ children: [t3, t4]
727
+ });
728
+ $[9] = open;
729
+ $[10] = prefetch;
730
+ $[11] = t3;
731
+ $[12] = t4;
732
+ $[13] = t5;
733
+ } else t5 = $[13];
734
+ let t6;
735
+ if ($[14] !== t2 || $[15] !== t5) {
736
+ t6 = /* @__PURE__ */ jsx(ListItem, {
737
+ disablePadding: true,
738
+ secondaryAction: t2,
739
+ children: t5
740
+ });
741
+ $[14] = t2;
742
+ $[15] = t5;
743
+ $[16] = t6;
744
+ } else t6 = $[16];
745
+ let t7;
746
+ if ($[17] !== hasActions || $[18] !== menuAnchor || $[19] !== meta) {
747
+ t7 = hasActions && /* @__PURE__ */ jsx(ActionsMenu, {
748
+ meta,
749
+ anchorEl: menuAnchor,
750
+ onClose: () => setMenuAnchor(null)
751
+ });
752
+ $[17] = hasActions;
753
+ $[18] = menuAnchor;
754
+ $[19] = meta;
755
+ $[20] = t7;
756
+ } else t7 = $[20];
757
+ let t8;
758
+ if ($[21] !== t6 || $[22] !== t7) {
759
+ t8 = /* @__PURE__ */ jsxs(Fragment, { children: [t6, t7] });
760
+ $[21] = t6;
761
+ $[22] = t7;
762
+ $[23] = t8;
763
+ } else t8 = $[23];
764
+ return t8;
865
765
  };
866
766
  function _temp$1(fileMeta) {
867
767
  return /* @__PURE__ */ jsx(ListFileViewerItem, { meta: fileMeta }, fileMeta.id);
868
768
  }
869
769
  // src/components/file/fileViewer/ImageViewer.tsx
870
770
  const ImageViewer = (t0) => {
871
- const $ = c(55);
771
+ const $ = c(58);
872
772
  const { metaId } = t0;
873
- const { fileMetas, setImageId, appName } = useFile();
874
- let meta;
875
- let next;
876
- let previous;
773
+ const { fileMetas, setImageId } = useFile();
774
+ const [loaded, setLoaded] = useState(false);
877
775
  let t1;
776
+ if ($[0] !== fileMetas || $[1] !== metaId) {
777
+ let t2;
778
+ if ($[3] !== metaId) {
779
+ t2 = (m) => m.id === metaId;
780
+ $[3] = metaId;
781
+ $[4] = t2;
782
+ } else t2 = $[4];
783
+ t1 = fileMetas.find(t2);
784
+ $[0] = fileMetas;
785
+ $[1] = metaId;
786
+ $[2] = t1;
787
+ } else t1 = $[2];
788
+ const meta = t1;
789
+ let images;
878
790
  let t2;
879
- if ($[0] !== appName || $[1] !== fileMetas || $[2] !== metaId) {
791
+ if ($[5] !== fileMetas || $[6] !== metaId) {
792
+ images = fileMetas.filter(_temp);
880
793
  let t3;
881
- if ($[8] !== metaId) {
882
- t3 = (m) => m.id === metaId;
883
- $[8] = metaId;
884
- $[9] = t3;
885
- } else t3 = $[9];
886
- meta = fileMetas.find(t3);
887
- let images;
888
- let t4;
889
- if ($[10] !== fileMetas || $[11] !== metaId) {
890
- images = fileMetas.filter(_temp);
891
- let t5;
892
- if ($[14] !== metaId) {
893
- t5 = (m_1) => m_1.id === metaId;
894
- $[14] = metaId;
895
- $[15] = t5;
896
- } else t5 = $[15];
897
- t4 = images.findIndex(t5);
898
- $[10] = fileMetas;
899
- $[11] = metaId;
900
- $[12] = images;
901
- $[13] = t4;
902
- } else {
903
- images = $[12];
904
- t4 = $[13];
905
- }
906
- const index = t4;
907
- previous = index > 0 ? images[index - 1] : void 0;
908
- next = index >= 0 && index < images.length - 1 ? images[index + 1] : void 0;
909
- t2 = useQuery;
910
- t1 = fileQueryOptions({
911
- id: meta?.id ?? "",
912
- appName
913
- });
914
- $[0] = appName;
915
- $[1] = fileMetas;
916
- $[2] = metaId;
917
- $[3] = meta;
918
- $[4] = next;
919
- $[5] = previous;
920
- $[6] = t1;
921
- $[7] = t2;
794
+ if ($[9] !== metaId) {
795
+ t3 = (m_1) => m_1.id === metaId;
796
+ $[9] = metaId;
797
+ $[10] = t3;
798
+ } else t3 = $[10];
799
+ t2 = images.findIndex(t3);
800
+ $[5] = fileMetas;
801
+ $[6] = metaId;
802
+ $[7] = images;
803
+ $[8] = t2;
922
804
  } else {
923
- meta = $[3];
924
- next = $[4];
925
- previous = $[5];
926
- t1 = $[6];
927
- t2 = $[7];
805
+ images = $[7];
806
+ t2 = $[8];
928
807
  }
929
- const t3 = !!meta;
808
+ const index = t2;
809
+ const previous = index > 0 ? images[index - 1] : void 0;
810
+ const next = index >= 0 && index < images.length - 1 ? images[index + 1] : void 0;
811
+ let t3;
812
+ if ($[11] !== setImageId) {
813
+ t3 = () => setImageId("");
814
+ $[11] = setImageId;
815
+ $[12] = t3;
816
+ } else t3 = $[12];
817
+ const onClose = t3;
930
818
  let t4;
931
- if ($[16] !== t1 || $[17] !== t3) {
932
- t4 = {
933
- ...t1,
934
- enabled: t3
935
- };
936
- $[16] = t1;
937
- $[17] = t3;
938
- $[18] = t4;
939
- } else t4 = $[18];
940
- const { data: source, isPending } = t2(t4);
941
819
  let t5;
942
- if ($[19] !== setImageId) {
943
- t5 = () => setImageId("");
944
- $[19] = setImageId;
945
- $[20] = t5;
946
- } else t5 = $[20];
947
- const onClose = t5;
820
+ if ($[13] !== next || $[14] !== previous) {
821
+ t4 = () => {
822
+ for (const neighbor of [previous, next]) if (neighbor && neighbor.fileSize <= 20971520) new Image().src = neighbor.urls.view;
823
+ };
824
+ t5 = [previous, next];
825
+ $[13] = next;
826
+ $[14] = previous;
827
+ $[15] = t4;
828
+ $[16] = t5;
829
+ } else {
830
+ t4 = $[15];
831
+ t5 = $[16];
832
+ }
833
+ useEffect(t4, t5);
948
834
  let t6;
949
- if ($[21] !== metaId || $[22] !== next || $[23] !== onClose || $[24] !== previous || $[25] !== setImageId) {
835
+ if ($[17] !== next || $[18] !== onClose || $[19] !== previous || $[20] !== setImageId) {
950
836
  t6 = () => {
951
- if (!metaId) return;
952
837
  const handleOnKeydown = (event) => {
953
838
  switch (event.key) {
954
839
  case "ArrowLeft": return previous && setImageId(previous.id);
@@ -962,46 +847,45 @@ const ImageViewer = (t0) => {
962
847
  globalThis.addEventListener("keydown", handleOnKeydown);
963
848
  return () => globalThis.removeEventListener("keydown", handleOnKeydown);
964
849
  };
965
- $[21] = metaId;
966
- $[22] = next;
967
- $[23] = onClose;
968
- $[24] = previous;
969
- $[25] = setImageId;
970
- $[26] = t6;
971
- } else t6 = $[26];
850
+ $[17] = next;
851
+ $[18] = onClose;
852
+ $[19] = previous;
853
+ $[20] = setImageId;
854
+ $[21] = t6;
855
+ } else t6 = $[21];
972
856
  let t7;
973
- if ($[27] !== metaId || $[28] !== next || $[29] !== previous) {
857
+ if ($[22] !== metaId || $[23] !== next || $[24] !== previous) {
974
858
  t7 = [
975
859
  metaId,
976
860
  previous,
977
861
  next
978
862
  ];
979
- $[27] = metaId;
980
- $[28] = next;
981
- $[29] = previous;
982
- $[30] = t7;
983
- } else t7 = $[30];
863
+ $[22] = metaId;
864
+ $[23] = next;
865
+ $[24] = previous;
866
+ $[25] = t7;
867
+ } else t7 = $[25];
984
868
  useEffect(t6, t7);
985
869
  if (!meta) return null;
986
870
  let t8;
987
- if ($[31] === Symbol.for("react.memo_cache_sentinel")) {
871
+ if ($[26] === Symbol.for("react.memo_cache_sentinel")) {
988
872
  t8 = {
989
873
  position: "fixed",
990
874
  top: "50%",
991
875
  transform: "translateY(-50%)"
992
876
  };
993
- $[31] = t8;
994
- } else t8 = $[31];
877
+ $[26] = t8;
878
+ } else t8 = $[26];
995
879
  const navSx = t8;
996
880
  let t9;
997
- if ($[32] !== meta.fileName) {
881
+ if ($[27] !== meta.fileName) {
998
882
  t9 = { paper: { "aria-label": meta.fileName } };
999
- $[32] = meta.fileName;
1000
- $[33] = t9;
1001
- } else t9 = $[33];
883
+ $[27] = meta.fileName;
884
+ $[28] = t9;
885
+ } else t9 = $[28];
1002
886
  let t10;
1003
- if ($[34] !== isPending || $[35] !== meta.fileName || $[36] !== source) {
1004
- t10 = isPending ? /* @__PURE__ */ jsx(Skeleton, {
887
+ if ($[29] !== loaded) {
888
+ t10 = !loaded && /* @__PURE__ */ jsx(Skeleton, {
1005
889
  variant: "rectangular",
1006
890
  sx: {
1007
891
  width: {
@@ -1013,26 +897,58 @@ const ImageViewer = (t0) => {
1013
897
  sm: "calc(100vh - 64px)"
1014
898
  }
1015
899
  }
1016
- }) : /* @__PURE__ */ jsx(Box, {
900
+ });
901
+ $[29] = loaded;
902
+ $[30] = t10;
903
+ } else t10 = $[30];
904
+ let t11;
905
+ let t12;
906
+ if ($[31] === Symbol.for("react.memo_cache_sentinel")) {
907
+ t11 = () => setLoaded(true);
908
+ t12 = () => setLoaded(true);
909
+ $[31] = t11;
910
+ $[32] = t12;
911
+ } else {
912
+ t11 = $[31];
913
+ t12 = $[32];
914
+ }
915
+ const t13 = loaded ? "block" : "none";
916
+ let t14;
917
+ if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
918
+ t14 = {
919
+ xs: "calc(100vh - 56px)",
920
+ sm: "calc(100vh - 64px)"
921
+ };
922
+ $[33] = t14;
923
+ } else t14 = $[33];
924
+ let t15;
925
+ if ($[34] !== t13) {
926
+ t15 = {
927
+ display: t13,
928
+ maxWidth: "100vw",
929
+ maxHeight: t14
930
+ };
931
+ $[34] = t13;
932
+ $[35] = t15;
933
+ } else t15 = $[35];
934
+ let t16;
935
+ if ($[36] !== meta.fileName || $[37] !== meta.urls.view || $[38] !== t15) {
936
+ t16 = /* @__PURE__ */ jsx(Box, {
1017
937
  component: "img",
1018
- src: source,
938
+ src: meta.urls.view,
1019
939
  alt: meta.fileName,
1020
- sx: {
1021
- maxWidth: "100vw",
1022
- maxHeight: {
1023
- xs: "calc(100vh - 56px)",
1024
- sm: "calc(100vh - 64px)"
1025
- }
1026
- }
940
+ onLoad: t11,
941
+ onError: t12,
942
+ sx: t15
1027
943
  });
1028
- $[34] = isPending;
1029
- $[35] = meta.fileName;
1030
- $[36] = source;
1031
- $[37] = t10;
1032
- } else t10 = $[37];
1033
- let t11;
1034
- if ($[38] !== previous || $[39] !== setImageId) {
1035
- t11 = previous && /* @__PURE__ */ jsx(Fab, {
944
+ $[36] = meta.fileName;
945
+ $[37] = meta.urls.view;
946
+ $[38] = t15;
947
+ $[39] = t16;
948
+ } else t16 = $[39];
949
+ let t17;
950
+ if ($[40] !== previous || $[41] !== setImageId) {
951
+ t17 = previous && /* @__PURE__ */ jsx(Fab, {
1036
952
  size: "medium",
1037
953
  onClick: () => setImageId(previous.id),
1038
954
  "aria-label": "Previous",
@@ -1042,13 +958,13 @@ const ImageViewer = (t0) => {
1042
958
  },
1043
959
  children: /* @__PURE__ */ jsx(ChevronLeft, {})
1044
960
  });
1045
- $[38] = previous;
1046
- $[39] = setImageId;
1047
- $[40] = t11;
1048
- } else t11 = $[40];
1049
- let t12;
1050
- if ($[41] !== next || $[42] !== setImageId) {
1051
- t12 = next && /* @__PURE__ */ jsx(Fab, {
961
+ $[40] = previous;
962
+ $[41] = setImageId;
963
+ $[42] = t17;
964
+ } else t17 = $[42];
965
+ let t18;
966
+ if ($[43] !== next || $[44] !== setImageId) {
967
+ t18 = next && /* @__PURE__ */ jsx(Fab, {
1052
968
  size: "medium",
1053
969
  onClick: () => setImageId(next.id),
1054
970
  "aria-label": "Next",
@@ -1058,73 +974,75 @@ const ImageViewer = (t0) => {
1058
974
  },
1059
975
  children: /* @__PURE__ */ jsx(ChevronRight, {})
1060
976
  });
1061
- $[41] = next;
1062
- $[42] = setImageId;
1063
- $[43] = t12;
1064
- } else t12 = $[43];
1065
- let t13;
1066
- let t14;
1067
- if ($[44] === Symbol.for("react.memo_cache_sentinel")) {
1068
- t13 = {
977
+ $[43] = next;
978
+ $[44] = setImageId;
979
+ $[45] = t18;
980
+ } else t18 = $[45];
981
+ let t19;
982
+ let t20;
983
+ if ($[46] === Symbol.for("react.memo_cache_sentinel")) {
984
+ t19 = {
1069
985
  position: "fixed",
1070
986
  top: 8,
1071
987
  right: 8
1072
988
  };
1073
- t14 = /* @__PURE__ */ jsx(Close, {});
1074
- $[44] = t13;
1075
- $[45] = t14;
989
+ t20 = /* @__PURE__ */ jsx(Close, {});
990
+ $[46] = t19;
991
+ $[47] = t20;
1076
992
  } else {
1077
- t13 = $[44];
1078
- t14 = $[45];
993
+ t19 = $[46];
994
+ t20 = $[47];
1079
995
  }
1080
- let t15;
1081
- if ($[46] !== onClose) {
1082
- t15 = /* @__PURE__ */ jsx(Fab, {
996
+ let t21;
997
+ if ($[48] !== onClose) {
998
+ t21 = /* @__PURE__ */ jsx(Fab, {
1083
999
  size: "medium",
1084
1000
  onClick: onClose,
1085
1001
  "aria-label": "Close",
1086
- sx: t13,
1087
- children: t14
1002
+ sx: t19,
1003
+ children: t20
1088
1004
  });
1089
- $[46] = onClose;
1090
- $[47] = t15;
1091
- } else t15 = $[47];
1092
- let t16;
1093
- if ($[48] !== onClose || $[49] !== t10 || $[50] !== t11 || $[51] !== t12 || $[52] !== t15 || $[53] !== t9) {
1094
- t16 = /* @__PURE__ */ jsxs(Dialog, {
1005
+ $[48] = onClose;
1006
+ $[49] = t21;
1007
+ } else t21 = $[49];
1008
+ let t22;
1009
+ if ($[50] !== onClose || $[51] !== t10 || $[52] !== t16 || $[53] !== t17 || $[54] !== t18 || $[55] !== t21 || $[56] !== t9) {
1010
+ t22 = /* @__PURE__ */ jsxs(Dialog, {
1095
1011
  open: true,
1096
1012
  onClose,
1097
1013
  maxWidth: "xl",
1098
1014
  slotProps: t9,
1099
1015
  children: [
1100
1016
  t10,
1101
- t11,
1102
- t12,
1103
- t15
1017
+ t16,
1018
+ t17,
1019
+ t18,
1020
+ t21
1104
1021
  ]
1105
1022
  });
1106
- $[48] = onClose;
1107
- $[49] = t10;
1108
- $[50] = t11;
1109
- $[51] = t12;
1110
- $[52] = t15;
1111
- $[53] = t9;
1112
- $[54] = t16;
1113
- } else t16 = $[54];
1114
- return t16;
1023
+ $[50] = onClose;
1024
+ $[51] = t10;
1025
+ $[52] = t16;
1026
+ $[53] = t17;
1027
+ $[54] = t18;
1028
+ $[55] = t21;
1029
+ $[56] = t9;
1030
+ $[57] = t22;
1031
+ } else t22 = $[57];
1032
+ return t22;
1115
1033
  };
1116
1034
  function _temp(m_0) {
1117
1035
  return m_0.mediaType === "image";
1118
1036
  }
1119
1037
  // src/components/file/FileViewer.tsx
1120
1038
  const FileViewer = (t0) => {
1121
- const $ = c(21);
1122
- const { appName, subId, onDelete, actions, children } = t0;
1039
+ const $ = c(20);
1040
+ const { subId, appName, onDelete, actions, children } = t0;
1123
1041
  let t1;
1124
1042
  if ($[0] !== appName || $[1] !== subId) {
1125
1043
  t1 = fileMetasQueryOptions({
1126
- appName,
1127
- subId
1044
+ subId,
1045
+ appName
1128
1046
  });
1129
1047
  $[0] = appName;
1130
1048
  $[1] = subId;
@@ -1152,210 +1070,51 @@ const FileViewer = (t0) => {
1152
1070
  const [imageId, setImageId] = useState("");
1153
1071
  if (fileMetas.length === 0) return null;
1154
1072
  let t6;
1155
- if ($[8] !== actions || $[9] !== appName || $[10] !== fileMetas || $[11] !== onDelete) {
1073
+ if ($[8] !== actions || $[9] !== fileMetas || $[10] !== onDelete) {
1156
1074
  t6 = {
1157
- appName,
1158
1075
  fileMetas,
1159
1076
  onDelete,
1160
1077
  actions,
1161
1078
  setImageId
1162
1079
  };
1163
1080
  $[8] = actions;
1164
- $[9] = appName;
1165
- $[10] = fileMetas;
1166
- $[11] = onDelete;
1167
- $[12] = t6;
1168
- } else t6 = $[12];
1081
+ $[9] = fileMetas;
1082
+ $[10] = onDelete;
1083
+ $[11] = t6;
1084
+ } else t6 = $[11];
1169
1085
  let t7;
1170
- if ($[13] !== children) {
1086
+ if ($[12] !== children) {
1171
1087
  t7 = children({
1172
1088
  Grid: FileViewerGrid,
1173
1089
  List: FileViewerList
1174
1090
  });
1175
- $[13] = children;
1176
- $[14] = t7;
1177
- } else t7 = $[14];
1091
+ $[12] = children;
1092
+ $[13] = t7;
1093
+ } else t7 = $[13];
1178
1094
  let t8;
1179
- if ($[15] !== imageId) {
1180
- t8 = /* @__PURE__ */ jsx(ImageViewer, { metaId: imageId });
1181
- $[15] = imageId;
1182
- $[16] = t8;
1183
- } else t8 = $[16];
1095
+ if ($[14] !== imageId) {
1096
+ t8 = imageId && /* @__PURE__ */ jsx(ImageViewer, { metaId: imageId });
1097
+ $[14] = imageId;
1098
+ $[15] = t8;
1099
+ } else t8 = $[15];
1184
1100
  let t9;
1185
- if ($[17] !== t6 || $[18] !== t7 || $[19] !== t8) {
1101
+ if ($[16] !== t6 || $[17] !== t7 || $[18] !== t8) {
1186
1102
  t9 = /* @__PURE__ */ jsxs(FileContext.Provider, {
1187
1103
  value: t6,
1188
1104
  children: [t7, t8]
1189
1105
  });
1190
- $[17] = t6;
1191
- $[18] = t7;
1192
- $[19] = t8;
1193
- $[20] = t9;
1194
- } else t9 = $[20];
1106
+ $[16] = t6;
1107
+ $[17] = t7;
1108
+ $[18] = t8;
1109
+ $[19] = t9;
1110
+ } else t9 = $[19];
1195
1111
  return t9;
1196
1112
  };
1197
- // src/components/router/RouterButton.tsx
1198
- const Component$2 = React.forwardRef(function ButtonComponent(props, reference) {
1199
- const $ = c(3);
1200
- let t0;
1201
- if ($[0] !== props || $[1] !== reference) {
1202
- t0 = /* @__PURE__ */ jsx(Button, {
1203
- ref: reference,
1204
- component: "a",
1205
- ...props
1206
- });
1207
- $[0] = props;
1208
- $[1] = reference;
1209
- $[2] = t0;
1210
- } else t0 = $[2];
1211
- return t0;
1212
- });
1213
- const CreatedComponent$2 = createLink(Component$2);
1214
- const RouterButton = (props) => {
1215
- const $ = c(2);
1216
- let t0;
1217
- if ($[0] !== props) {
1218
- t0 = /* @__PURE__ */ jsx(CreatedComponent$2, { ...props });
1219
- $[0] = props;
1220
- $[1] = t0;
1221
- } else t0 = $[1];
1222
- return t0;
1223
- };
1224
- // src/components/router/RouterFab.tsx
1225
- const Component$1 = React.forwardRef(function FabComponent(props, reference) {
1226
- const $ = c(3);
1227
- let t0;
1228
- if ($[0] !== props || $[1] !== reference) {
1229
- t0 = /* @__PURE__ */ jsx(Fab, {
1230
- ref: reference,
1231
- component: "a",
1232
- ...props
1233
- });
1234
- $[0] = props;
1235
- $[1] = reference;
1236
- $[2] = t0;
1237
- } else t0 = $[2];
1238
- return t0;
1239
- });
1240
- const CreatedComponent$1 = createLink(Component$1);
1241
- const RouterFab = (props) => {
1242
- const $ = c(2);
1243
- let t0;
1244
- if ($[0] !== props) {
1245
- t0 = /* @__PURE__ */ jsx(CreatedComponent$1, { ...props });
1246
- $[0] = props;
1247
- $[1] = t0;
1248
- } else t0 = $[1];
1249
- return t0;
1250
- };
1251
- // src/components/router/RouterTab.tsx
1252
- const Component = React.forwardRef(function TabComponent(props, reference) {
1253
- const $ = c(3);
1254
- let t0;
1255
- if ($[0] !== props || $[1] !== reference) {
1256
- t0 = /* @__PURE__ */ jsx(Tab, {
1257
- ref: reference,
1258
- component: "a",
1259
- ...props
1260
- });
1261
- $[0] = props;
1262
- $[1] = reference;
1263
- $[2] = t0;
1264
- } else t0 = $[2];
1265
- return t0;
1266
- });
1267
- const CreatedComponent = createLink(Component);
1268
- const RouterTab = (props) => {
1269
- const $ = c(2);
1270
- let t0;
1271
- if ($[0] !== props) {
1272
- t0 = /* @__PURE__ */ jsx(CreatedComponent, { ...props });
1273
- $[0] = props;
1274
- $[1] = t0;
1275
- } else t0 = $[1];
1276
- return t0;
1277
- };
1278
- // src/components/router/RouterNotFound.tsx
1279
- function RouterNotFound() {
1280
- const $ = c(8);
1281
- const { t } = useTranslation();
1282
- let t0;
1283
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1284
- t0 = {
1285
- alignItems: "center",
1286
- justifyContent: "center",
1287
- px: 2
1288
- };
1289
- $[0] = t0;
1290
- } else t0 = $[0];
1291
- let t1;
1292
- if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
1293
- t1 = {
1294
- display: "flex",
1295
- alignItems: "center",
1296
- m: 0,
1297
- mb: 4
1298
- };
1299
- $[1] = t1;
1300
- } else t1 = $[1];
1301
- let t2;
1302
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
1303
- t2 = /* @__PURE__ */ jsx(Typography, {
1304
- variant: "h3",
1305
- component: "span",
1306
- sx: {
1307
- fontWeight: 500,
1308
- lineHeight: 1
1309
- },
1310
- children: "404"
1311
- });
1312
- $[2] = t2;
1313
- } else t2 = $[2];
1314
- let t3;
1315
- if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
1316
- t3 = /* @__PURE__ */ jsx(Divider, {
1317
- component: "span",
1318
- role: "presentation",
1319
- orientation: "vertical",
1320
- flexItem: true,
1321
- sx: { mx: 3 }
1322
- });
1323
- $[3] = t3;
1324
- } else t3 = $[3];
1325
- let t4;
1326
- if ($[4] !== t) {
1327
- t4 = t("Layout.ThisPageCouldNotBeFound");
1328
- $[4] = t;
1329
- $[5] = t4;
1330
- } else t4 = $[5];
1331
- let t5;
1332
- if ($[6] !== t4) {
1333
- t5 = /* @__PURE__ */ jsx(Fullscreen, {
1334
- sx: t0,
1335
- children: /* @__PURE__ */ jsxs(Box, {
1336
- component: "h1",
1337
- sx: t1,
1338
- children: [
1339
- t2,
1340
- t3,
1341
- /* @__PURE__ */ jsx(Typography, {
1342
- variant: "h5",
1343
- component: "span",
1344
- children: t4
1345
- })
1346
- ]
1347
- })
1348
- });
1349
- $[6] = t4;
1350
- $[7] = t5;
1351
- } else t5 = $[7];
1352
- return t5;
1353
- }
1354
1113
  // src/components/router/RouterError.tsx
1355
- const RouterError = (t0) => {
1114
+ /** A full-page error: its code, a rule and the message. */
1115
+ const ErrorPage = (t0) => {
1356
1116
  const $ = c(11);
1357
- const { error } = t0;
1358
- const isError = error instanceof Error;
1117
+ const { code, message } = t0;
1359
1118
  let t1;
1360
1119
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1361
1120
  t1 = {
@@ -1383,60 +1142,96 @@ const RouterError = (t0) => {
1383
1142
  };
1384
1143
  $[2] = t3;
1385
1144
  } else t3 = $[2];
1386
- const t4 = isError && error.name || "500";
1387
- let t5;
1388
- if ($[3] !== t4) {
1389
- t5 = /* @__PURE__ */ jsx(Typography, {
1145
+ let t4;
1146
+ if ($[3] !== code) {
1147
+ t4 = /* @__PURE__ */ jsx(Typography, {
1390
1148
  variant: "h3",
1391
1149
  component: "span",
1392
1150
  sx: t3,
1393
- children: t4
1151
+ children: code
1394
1152
  });
1395
- $[3] = t4;
1396
- $[4] = t5;
1397
- } else t5 = $[4];
1398
- let t6;
1153
+ $[3] = code;
1154
+ $[4] = t4;
1155
+ } else t4 = $[4];
1156
+ let t5;
1399
1157
  if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
1400
- t6 = /* @__PURE__ */ jsx(Divider, {
1158
+ t5 = /* @__PURE__ */ jsx(Divider, {
1401
1159
  component: "span",
1402
1160
  role: "presentation",
1403
1161
  orientation: "vertical",
1404
1162
  flexItem: true,
1405
1163
  sx: { mx: 3 }
1406
1164
  });
1407
- $[5] = t6;
1408
- } else t6 = $[5];
1409
- const t7 = isError ? error.message : String(error);
1410
- let t8;
1411
- if ($[6] !== t7) {
1412
- t8 = /* @__PURE__ */ jsx(Typography, {
1165
+ $[5] = t5;
1166
+ } else t5 = $[5];
1167
+ let t6;
1168
+ if ($[6] !== message) {
1169
+ t6 = /* @__PURE__ */ jsx(Typography, {
1413
1170
  variant: "h5",
1414
1171
  component: "span",
1415
- children: t7
1172
+ children: message
1416
1173
  });
1417
- $[6] = t7;
1418
- $[7] = t8;
1419
- } else t8 = $[7];
1420
- let t9;
1421
- if ($[8] !== t5 || $[9] !== t8) {
1422
- t9 = /* @__PURE__ */ jsx(Fullscreen, {
1174
+ $[6] = message;
1175
+ $[7] = t6;
1176
+ } else t6 = $[7];
1177
+ let t7;
1178
+ if ($[8] !== t4 || $[9] !== t6) {
1179
+ t7 = /* @__PURE__ */ jsx(Fullscreen, {
1423
1180
  sx: t1,
1424
1181
  children: /* @__PURE__ */ jsxs(Box, {
1425
1182
  component: "h1",
1426
1183
  sx: t2,
1427
1184
  children: [
1185
+ t4,
1428
1186
  t5,
1429
- t6,
1430
- t8
1187
+ t6
1431
1188
  ]
1432
1189
  })
1433
1190
  });
1434
- $[8] = t5;
1435
- $[9] = t8;
1436
- $[10] = t9;
1437
- } else t9 = $[10];
1438
- return t9;
1191
+ $[8] = t4;
1192
+ $[9] = t6;
1193
+ $[10] = t7;
1194
+ } else t7 = $[10];
1195
+ return t7;
1439
1196
  };
1197
+ const RouterError = (t0) => {
1198
+ const $ = c(3);
1199
+ const { error } = t0;
1200
+ const t1 = error instanceof Error && error.name || "500";
1201
+ const t2 = error instanceof Error ? error.message : String(error);
1202
+ let t3;
1203
+ if ($[0] !== t1 || $[1] !== t2) {
1204
+ t3 = /* @__PURE__ */ jsx(ErrorPage, {
1205
+ code: t1,
1206
+ message: t2
1207
+ });
1208
+ $[0] = t1;
1209
+ $[1] = t2;
1210
+ $[2] = t3;
1211
+ } else t3 = $[2];
1212
+ return t3;
1213
+ };
1214
+ // src/components/router/RouterNotFound.tsx
1215
+ function RouterNotFound() {
1216
+ const $ = c(4);
1217
+ const { t } = useTranslation();
1218
+ let t0;
1219
+ if ($[0] !== t) {
1220
+ t0 = t("Layout.ThisPageCouldNotBeFound");
1221
+ $[0] = t;
1222
+ $[1] = t0;
1223
+ } else t0 = $[1];
1224
+ let t1;
1225
+ if ($[2] !== t0) {
1226
+ t1 = /* @__PURE__ */ jsx(ErrorPage, {
1227
+ code: "404",
1228
+ message: t0
1229
+ });
1230
+ $[2] = t0;
1231
+ $[3] = t1;
1232
+ } else t1 = $[3];
1233
+ return t1;
1234
+ }
1440
1235
  // src/components/table/LayoutTable.tsx
1441
1236
  const ROW_HEIGHT = 52;
1442
1237
  const COLUMN_HEADER_HEIGHT = 56;
@@ -1444,6 +1239,7 @@ const COLUMN_HEADER_HEIGHT = 56;
1444
1239
  const ROW_OVERSCAN = 6;
1445
1240
  const ROW_LOOKAHEAD = 15;
1446
1241
  const COLUMN_OVERSCAN = 3;
1242
+ const PAGE_SIZE = 25;
1447
1243
  const JUSTIFY = {
1448
1244
  left: "flex-start",
1449
1245
  center: "center",
@@ -1467,6 +1263,76 @@ const FOOTER_SX = {
1467
1263
  borderTopStyle: "solid",
1468
1264
  borderColor: "divider"
1469
1265
  };
1266
+ /**
1267
+ * The editor covers its cell and the cell is the field: one ring and no outline of the input's
1268
+ * own, its inset the cell's padding, so the text stays exactly where the value was drawn.
1269
+ */
1270
+ const EDITOR_SX = {
1271
+ position: "absolute",
1272
+ inset: 0,
1273
+ display: "flex",
1274
+ alignItems: "center",
1275
+ bgcolor: "background.paper",
1276
+ "& .MuiAutocomplete-root, & .MuiTextField-root": {
1277
+ width: 1,
1278
+ height: 1
1279
+ },
1280
+ "& .MuiInputBase-root": {
1281
+ height: 1,
1282
+ pl: "0 !important",
1283
+ font: "inherit",
1284
+ letterSpacing: "inherit"
1285
+ },
1286
+ "& .MuiInputBase-input": {
1287
+ px: `${CELL_SX.px} !important`,
1288
+ textAlign: "inherit"
1289
+ },
1290
+ "& .MuiOutlinedInput-notchedOutline": { display: "none" },
1291
+ "& .MuiFormControlLabel-root": { m: 0 },
1292
+ "& .MuiFormHelperText-root": { display: "none" }
1293
+ };
1294
+ const editorRing = (color) => (theme) => `inset 0 0 0 2px ${(theme.vars ?? theme).palette[color].main}`;
1295
+ /** The error sits right under the edited cell. */
1296
+ const EDITOR_ERROR_SLOT_PROPS = {
1297
+ popper: { modifiers: [{
1298
+ name: "offset",
1299
+ options: { offset: [0, -10] }
1300
+ }] },
1301
+ tooltip: { sx: {
1302
+ bgcolor: "error.main",
1303
+ color: "error.contrastText"
1304
+ } }
1305
+ };
1306
+ /** A hovered row outlines its editable cells like inputs, the one under the pointer firmer. */
1307
+ const EDITABLE_SX = { "@media (hover: hover) and (pointer: fine)": {
1308
+ ".MuiTableRow-root:hover > &": { boxShadow: (theme) => `inset 0 0 0 1px ${(theme.vars ?? theme).palette.divider}` },
1309
+ ".MuiTableRow-root:hover > &:hover": { boxShadow: (theme) => `inset 0 0 0 1px ${(theme.vars ?? theme).palette.text.disabled}` }
1310
+ } };
1311
+ /**
1312
+ * The pencil a hovered editable cell shows; one click edits. Opaque, so it covers the end of a
1313
+ * long value cleanly. A hidden one takes no clicks, so on a touch screen the first tap selects
1314
+ * the cell and shows it.
1315
+ */
1316
+ const EDIT_BUTTON_SX = {
1317
+ position: "absolute",
1318
+ top: "50%",
1319
+ transform: "translateY(-50%)",
1320
+ p: .5,
1321
+ color: "text.secondary",
1322
+ bgcolor: "background.paper",
1323
+ opacity: 0,
1324
+ pointerEvents: "none",
1325
+ ".MuiTableCell-root:hover > &": {
1326
+ opacity: 1,
1327
+ pointerEvents: "auto"
1328
+ },
1329
+ "&:hover": {
1330
+ color: "text.primary",
1331
+ bgcolor: "background.paper"
1332
+ }
1333
+ };
1334
+ /** A module-level ref, so it runs once when the editor mounts rather than on every render. */
1335
+ const focusEditor = (element) => element?.querySelector("input:not([aria-hidden]), textarea, [tabindex='0']")?.focus();
1470
1336
  const pinnedWidth = (columns) => columns.reduce((total, column) => total + column.getSize(), 0);
1471
1337
  /**
1472
1338
  * Gives an ellipsized value (the cell itself or a noWrap Typography in it) a native
@@ -1477,7 +1343,7 @@ const titleIfTruncated = (event) => {
1477
1343
  if (getComputedStyle(element).textOverflow !== "ellipsis") return;
1478
1344
  element.title = element.scrollWidth > element.clientWidth ? element.textContent ?? "" : "";
1479
1345
  };
1480
- function LayoutTable({ table, loading = false, pagination = false, pageSizeOptions = DEFAULT_PAGE_SIZE_OPTIONS, showToolbar = false, disableColumnMenu = false, onRowClick, onRowDoubleClick, sx, ...toolbar }) {
1346
+ function LayoutTable({ table, loading = false, pagination = false, showToolbar = false, disableColumnMenu = false, onRowClick, onRowDoubleClick, onRowUpdate, editSchema, sx, ...toolbar }) {
1481
1347
  "use no memo";
1482
1348
  const { t } = useTranslation();
1483
1349
  const containerRef = useRef(null);
@@ -1495,25 +1361,15 @@ function LayoutTable({ table, loading = false, pagination = false, pageSizeOptio
1495
1361
  ];
1496
1362
  const isEmpty = !loading && !rows.length;
1497
1363
  const pageSize = table.state.pagination.pageSize;
1498
- const pageSizeOffered = pageSizeOptions.includes(pageSize);
1499
- const pagerStarted = useRef(false);
1364
+ const targetPageSize = pagination ? PAGE_SIZE : Math.max(rows.length, 1);
1500
1365
  useLayoutEffect(() => {
1501
- if (!pagination) {
1502
- if (pageSize !== rows.length) table.setPageSize(Math.max(rows.length, 1));
1503
- return;
1504
- }
1505
- const appSetSize = pagerStarted.current || !!(table.options.state?.pagination ?? table.options.initialState?.pagination);
1506
- pagerStarted.current = true;
1507
- if (!appSetSize || !pageSizeOffered) table.setPagination({
1366
+ if (pageSize !== targetPageSize) table.setPagination({
1508
1367
  pageIndex: 0,
1509
- pageSize: Math.min(...pageSizeOptions)
1368
+ pageSize: targetPageSize
1510
1369
  });
1511
1370
  }, [
1512
- pagination,
1513
1371
  pageSize,
1514
- pageSizeOffered,
1515
- pageSizeOptions,
1516
- rows.length,
1372
+ targetPageSize,
1517
1373
  table
1518
1374
  ]);
1519
1375
  const startColumns = table.getStartVisibleLeafColumns();
@@ -1522,13 +1378,16 @@ function LayoutTable({ table, loading = false, pagination = false, pageSizeOptio
1522
1378
  const startPinnedWidth = pinnedWidth(startColumns);
1523
1379
  const endPinnedWidth = pinnedWidth(endColumns);
1524
1380
  const [containerWidth, setContainerWidth] = useState(0);
1525
- useLayoutEffect(() => {
1526
- const container = containerRef.current;
1381
+ const observeContainer = useCallback((container) => {
1382
+ containerRef.current = container;
1527
1383
  if (!container) return;
1528
1384
  setContainerWidth(container.clientWidth - 1);
1529
1385
  const observer = new ResizeObserver(([entry]) => setContainerWidth(Math.floor(entry.contentRect.width)));
1530
1386
  observer.observe(container);
1531
- return () => observer.disconnect();
1387
+ return () => {
1388
+ observer.disconnect();
1389
+ containerRef.current = null;
1390
+ };
1532
1391
  }, []);
1533
1392
  const flexColumns = table.getVisibleLeafColumns().filter((column) => columnFlex(column) > 0);
1534
1393
  const totalFlex = flexColumns.reduce((total, column) => total + columnFlex(column), 0);
@@ -1572,9 +1431,13 @@ function LayoutTable({ table, loading = false, pagination = false, pageSizeOptio
1572
1431
  const focusedCell = table.getFocusedCell();
1573
1432
  const focusedRowId = focusedCell?.row.id;
1574
1433
  const focusedColumnId = focusedCell?.column.id;
1434
+ const entryCellId = rows.some((row) => row.id === focusedRowId) ? void 0 : rows[0]?.getVisibleCells().find((cell) => cell.getCanSelect())?.id;
1575
1435
  useEffect(() => {
1576
- const cell = containerRef.current?.querySelector("tbody td[tabindex='0']");
1436
+ if (!focusedRowId) return;
1437
+ const container = containerRef.current;
1438
+ const cell = container?.querySelector("tbody td[tabindex='0']");
1577
1439
  if (cell) {
1440
+ if (container?.contains(document.activeElement) && document.activeElement?.matches("td")) cell.focus({ preventScroll: true });
1578
1441
  cell.scrollIntoView({
1579
1442
  block: "nearest",
1580
1443
  inline: "nearest"
@@ -1587,6 +1450,34 @@ function LayoutTable({ table, loading = false, pagination = false, pageSizeOptio
1587
1450
  if (columnIndex >= 0) columnVirtualizer.scrollToIndex(columnIndex);
1588
1451
  }, [focusedRowId, focusedColumnId]);
1589
1452
  const hasCellSelection = table.state.cellSelection.length > 0;
1453
+ const [editing, setEditing] = useState();
1454
+ const form = useLayoutForm({
1455
+ defaultValues: void 0,
1456
+ validators: { onChange: editSchema },
1457
+ onSubmit: async ({ value }) => {
1458
+ await onRowUpdate?.(value);
1459
+ setEditing(void 0);
1460
+ }
1461
+ });
1462
+ const cellEditor = (cell) => onRowUpdate && !cell.row.getIsGrouped() ? cell.column.columnDef.meta?.edit : void 0;
1463
+ const startEditing = async (cell) => {
1464
+ if (form.state.isSubmitting || editing && !await commitEdit()) return;
1465
+ form.reset(cell.row.original);
1466
+ setEditing({
1467
+ rowId: cell.row.id,
1468
+ columnId: cell.column.id
1469
+ });
1470
+ };
1471
+ /** Resolves true once the editor has closed: saved, or nothing changed. */
1472
+ const commitEdit = async () => {
1473
+ if (form.state.isSubmitting) return false;
1474
+ if (!form.state.isDirty) {
1475
+ setEditing(void 0);
1476
+ return true;
1477
+ }
1478
+ await form.handleSubmit();
1479
+ return form.state.isSubmitSuccessful;
1480
+ };
1590
1481
  const copySelection = () => {
1591
1482
  const text = toClipboardText(table.getSelectedCellRangesData());
1592
1483
  if (text) navigator.clipboard.writeText(text);
@@ -1635,11 +1526,11 @@ function LayoutTable({ table, loading = false, pagination = false, pageSizeOptio
1635
1526
  {
1636
1527
  hotkey: "Mod+A",
1637
1528
  callback: () => table.selectAllCells(),
1638
- options: { enabled: true }
1529
+ options: { enabled: !editing }
1639
1530
  }
1640
1531
  ], {
1641
1532
  target: containerRef,
1642
- enabled: hasCellSelection
1533
+ enabled: hasCellSelection && !editing
1643
1534
  });
1644
1535
  const virtualRows = rowVirtualizer.getVirtualItems();
1645
1536
  const paddingTop = virtualRows.length ? virtualRows[0].start - headerHeight : 0;
@@ -1722,26 +1613,95 @@ function LayoutTable({ table, loading = false, pagination = false, pageSizeOptio
1722
1613
  const cellClassName = (cell) => classNames(layoutTableClasses.cell, cell.getIsSelected() && layoutTableClasses["cell--selected"], cell.getIsGrouped() && layoutTableClasses["cell--grouped"], cell.getIsAggregated() && layoutTableClasses["cell--aggregated"], pinnedClass(cell.column, "cell"));
1723
1614
  const renderCell = (c) => /* @__PURE__ */ jsx(table.AppCell, {
1724
1615
  cell: c,
1725
- children: (cell) => cell.getIsCovered() ? null : /* @__PURE__ */ jsx(TableCell, {
1726
- className: cellClassName(cell),
1727
- align: columnAlign(cell.column),
1728
- rowSpan: cell.getRowSpan(),
1729
- colSpan: cell.getColSpan(),
1730
- tabIndex: cell.getCanSelect() ? cell.getTabIndex() : void 0,
1731
- onMouseDown: cell.getSelectionStartHandler(),
1732
- onMouseEnter: cell.getSelectionExtendHandler(),
1733
- onMouseOver: titleIfTruncated,
1734
- sx: {
1735
- overflow: "hidden",
1736
- textOverflow: "ellipsis",
1737
- whiteSpace: "nowrap",
1738
- userSelect: cell.getCanSelect() ? "none" : void 0,
1739
- ...hasColumnLabel(cell.column) ? CELL_SX : UTILITY_SX,
1740
- ...pinnedSx(cell.column),
1741
- ...cellSelectionSx(cell)
1742
- },
1743
- children: cell.getIsGrouped() ? /* @__PURE__ */ jsx(cell.GroupCell, {}) : cell.row.getIsGrouped() && !cell.getIsAggregated() ? null : /* @__PURE__ */ jsx(cell.FlexRender, {})
1744
- })
1616
+ children: (cell) => {
1617
+ if (cell.getIsCovered()) return null;
1618
+ const edit = cellEditor(cell);
1619
+ const isEditing = editing?.rowId === cell.row.id && editing.columnId === cell.column.id;
1620
+ const canStartEditing = edit && !isEditing;
1621
+ return /* @__PURE__ */ jsxs(TableCell, {
1622
+ className: cellClassName(cell),
1623
+ align: columnAlign(cell.column),
1624
+ rowSpan: cell.getRowSpan(),
1625
+ colSpan: cell.getColSpan(),
1626
+ tabIndex: cell.getCanSelect() ? cell.id === entryCellId ? 0 : cell.getTabIndex() : void 0,
1627
+ onFocus: (event) => {
1628
+ if (event.target === event.currentTarget && !table.getFocusedCell()) table.setFocusedCell(cell.row.id, cell.column.id);
1629
+ },
1630
+ onDoubleClick: canStartEditing ? (event) => {
1631
+ event.stopPropagation();
1632
+ startEditing(cell);
1633
+ } : void 0,
1634
+ onKeyDown: canStartEditing ? (event) => {
1635
+ if (event.target !== event.currentTarget) return;
1636
+ if (event.key !== "Enter" && event.key !== "F2") return;
1637
+ event.stopPropagation();
1638
+ startEditing(cell);
1639
+ } : void 0,
1640
+ onMouseDown: cell.getSelectionStartHandler(),
1641
+ onMouseEnter: cell.getSelectionExtendHandler(),
1642
+ onMouseOver: titleIfTruncated,
1643
+ sx: {
1644
+ overflow: "hidden",
1645
+ textOverflow: "ellipsis",
1646
+ whiteSpace: "nowrap",
1647
+ userSelect: cell.getCanSelect() ? "none" : void 0,
1648
+ ...hasColumnLabel(cell.column) ? CELL_SX : UTILITY_SX,
1649
+ ...edit && { position: "relative" },
1650
+ ...pinnedSx(cell.column),
1651
+ ...cellSelectionSx(cell),
1652
+ ...canStartEditing && !cell.getIsSelected() && EDITABLE_SX
1653
+ },
1654
+ children: [isEditing && edit ? /* @__PURE__ */ jsx(form.AppField, {
1655
+ name: cell.column.id,
1656
+ children: (field) => {
1657
+ const { error, helperText } = getFieldStatus(field);
1658
+ return /* @__PURE__ */ jsx(ClickAwayListener, {
1659
+ onClickAway: () => void commitEdit(),
1660
+ children: /* @__PURE__ */ jsx(Tooltip, {
1661
+ open: error,
1662
+ title: helperText ?? "",
1663
+ placement: "bottom-start",
1664
+ slotProps: EDITOR_ERROR_SLOT_PROPS,
1665
+ children: /* @__PURE__ */ jsx(Box, {
1666
+ ref: focusEditor,
1667
+ className: layoutTableClasses.cellEditor,
1668
+ sx: [EDITOR_SX, {
1669
+ justifyContent: JUSTIFY[columnAlign(cell.column)],
1670
+ boxShadow: editorRing(error ? "error" : "primary")
1671
+ }],
1672
+ onMouseDown: (event) => {
1673
+ if (event.target === event.currentTarget) event.preventDefault();
1674
+ },
1675
+ onDoubleClick: (event) => event.stopPropagation(),
1676
+ onKeyDown: async (event) => {
1677
+ if (event.defaultPrevented || event.nativeEvent.isComposing) return;
1678
+ if (event.key !== "Enter" && event.key !== "Escape") return;
1679
+ event.preventDefault();
1680
+ event.stopPropagation();
1681
+ const cellElement = event.currentTarget.closest("td");
1682
+ if (event.key === "Escape") setEditing(void 0);
1683
+ else if (!await commitEdit()) return;
1684
+ cellElement?.focus();
1685
+ },
1686
+ children: edit(field)
1687
+ })
1688
+ })
1689
+ });
1690
+ }
1691
+ }) : cell.getIsGrouped() ? /* @__PURE__ */ jsx(cell.GroupCell, {}) : cell.row.getIsGrouped() && !cell.getIsAggregated() ? null : /* @__PURE__ */ jsx(cell.FlexRender, {}), canStartEditing && /* @__PURE__ */ jsx(IconButton, {
1692
+ className: layoutTableClasses.editButton,
1693
+ size: "small",
1694
+ tabIndex: -1,
1695
+ "aria-label": t("Layout.Table.EditCell"),
1696
+ onClick: (event) => {
1697
+ event.stopPropagation();
1698
+ startEditing(cell);
1699
+ },
1700
+ sx: [EDIT_BUTTON_SX, columnAlign(cell.column) === "right" ? { left: 4 } : { right: 4 }],
1701
+ children: /* @__PURE__ */ jsx(EditOutlined, { sx: { fontSize: 16 } })
1702
+ })]
1703
+ });
1704
+ }
1745
1705
  }, c.id);
1746
1706
  const renderFooter = (f) => /* @__PURE__ */ jsx(table.AppFooter, {
1747
1707
  header: f,
@@ -1768,7 +1728,9 @@ function LayoutTable({ table, loading = false, pagination = false, pageSizeOptio
1768
1728
  hover: true,
1769
1729
  selected: row.getIsSelected(),
1770
1730
  tabIndex: rowAction && !focusableCells ? 0 : void 0,
1771
- onClick: onRowClick && (() => onRowClick(row)),
1731
+ onClick: onRowClick && (() => {
1732
+ if (editing?.rowId !== row.id) onRowClick(row);
1733
+ }),
1772
1734
  onDoubleClick: onRowDoubleClick && (() => onRowDoubleClick(row)),
1773
1735
  onKeyDown: rowAction && ((event) => {
1774
1736
  const target = event.target;
@@ -1797,7 +1759,8 @@ function LayoutTable({ table, loading = false, pagination = false, pageSizeOptio
1797
1759
  firstColumn?.index,
1798
1760
  lastColumn?.index,
1799
1761
  paddingStart,
1800
- paddingEnd
1762
+ paddingEnd,
1763
+ editing
1801
1764
  ]);
1802
1765
  const cacheKey = (index) => `${index}:${rows[index].id}`;
1803
1766
  const bodyRows = virtualRows.map(({ index }) => rowCache.current.get(cacheKey(index)) ?? renderRow(rows[index], index));
@@ -1828,7 +1791,7 @@ function LayoutTable({ table, loading = false, pagination = false, pageSizeOptio
1828
1791
  children: [
1829
1792
  showToolbar && /* @__PURE__ */ jsx(table.Toolbar, { ...toolbar }),
1830
1793
  /* @__PURE__ */ jsx(TableContainer, {
1831
- ref: containerRef,
1794
+ ref: observeContainer,
1832
1795
  className: layoutTableClasses.main,
1833
1796
  sx: {
1834
1797
  flex: 1,
@@ -1977,13 +1940,10 @@ function LayoutTable({ table, loading = false, pagination = false, pageSizeOptio
1977
1940
  ]
1978
1941
  })
1979
1942
  }),
1980
- pagination && pageSizeOffered && /* @__PURE__ */ jsx(table.Pagination, {
1981
- className: layoutTableClasses.pagination,
1982
- pageSizeOptions
1983
- })
1943
+ pagination && pageSize === PAGE_SIZE && /* @__PURE__ */ jsx(table.Pagination, { className: layoutTableClasses.pagination })
1984
1944
  ]
1985
1945
  }) });
1986
1946
  }
1987
- export { AggregatedCell, ChatLayout, Dropzone, FileViewer, Fullscreen, LayoutTable, LoginForm, RouterButton, RouterError, RouterFab, RouterIconButton, RouterLink, RouterListItemButton, RouterNotFound, RouterTab, layoutTableClasses };
1947
+ export { AggregatedCell, ChatLayout, Dropzone, FileViewer, Fullscreen, LayoutTable, RouterButton, RouterError, RouterFab, RouterIconButton, RouterLink, RouterListItemButton, RouterNotFound, RouterTab, layoutTableClasses };
1988
1948
 
1989
1949
  //# sourceMappingURL=components.mjs.map