@shellui/core 0.3.1 → 0.4.1

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 (59) hide show
  1. package/package.json +2 -2
  2. package/src/app.tsx +11 -1
  3. package/src/components/ui/dialog.tsx +26 -6
  4. package/src/components/ui/sonner.tsx +9 -5
  5. package/src/features/admin/AdminView.tsx +1 -20
  6. package/src/features/auth/AuthProvider.tsx +68 -13
  7. package/src/features/auth/backends/shellui.ts +8 -1
  8. package/src/features/auth/components/AccessPendingView.tsx +112 -0
  9. package/src/features/auth/components/LoginView.tsx +17 -0
  10. package/src/features/auth/components/OAuthCallbackView.tsx +211 -48
  11. package/src/features/auth/hooks/useAuth.tsx +8 -1
  12. package/src/features/auth/utils/authRequestError.spec.ts +52 -0
  13. package/src/features/auth/utils/authRequestError.ts +45 -0
  14. package/src/features/auth/utils/index.ts +7 -0
  15. package/src/features/auth/utils/isTokenAutoRefreshDisabled.spec.ts +71 -0
  16. package/src/features/auth/utils/isTokenAutoRefreshDisabled.ts +18 -0
  17. package/src/features/config/types.ts +46 -0
  18. package/src/features/layouts/AppLayout.tsx +3 -3
  19. package/src/features/layouts/OverlayShell.tsx +10 -6
  20. package/src/features/modal/ModalContext.spec.ts +77 -0
  21. package/src/features/modal/ModalContext.tsx +12 -50
  22. package/src/features/modal/validateAndNormalizeUrl.ts +96 -0
  23. package/src/features/settings/SettingsIcons.tsx +35 -0
  24. package/src/features/settings/SettingsProvider.tsx +69 -4
  25. package/src/features/settings/SettingsRoutes.tsx +14 -6
  26. package/src/features/settings/SettingsView.tsx +11 -5
  27. package/src/features/settings/components/Advanced.tsx +117 -44
  28. package/src/features/settings/components/Develop.tsx +38 -0
  29. package/src/features/settings/components/Storage.tsx +138 -0
  30. package/src/features/settings/components/develop/StoragePickerTestButtons.tsx +148 -0
  31. package/src/features/settings/components/develop/UploadToastTestButton.tsx +29 -0
  32. package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +54 -0
  33. package/src/features/settings/utils/buildSettingsForPropagation.ts +34 -0
  34. package/src/features/settings/utils/toSettingsUser.spec.ts +4 -0
  35. package/src/features/settings/utils/toSettingsUser.ts +2 -0
  36. package/src/features/storage/StorageBridge.tsx +50 -0
  37. package/src/features/storage/StoragePickerContext.tsx +214 -0
  38. package/src/features/storage/api.spec.ts +303 -0
  39. package/src/features/storage/api.ts +414 -0
  40. package/src/features/storage/handleRequest.spec.ts +88 -0
  41. package/src/features/storage/handleRequest.ts +53 -0
  42. package/src/features/storage/quota.spec.ts +151 -0
  43. package/src/features/storage/quota.ts +104 -0
  44. package/src/features/storage/uploads/UploadToastCard.tsx +442 -0
  45. package/src/features/storage/uploads/UploadToaster.tsx +41 -0
  46. package/src/features/storage/uploads/handleTrackedUpload.spec.ts +170 -0
  47. package/src/features/storage/uploads/handleTrackedUpload.ts +97 -0
  48. package/src/features/storage/uploads/types.ts +24 -0
  49. package/src/features/storage/uploads/uploadQueue.spec.ts +118 -0
  50. package/src/features/storage/uploads/uploadQueue.ts +349 -0
  51. package/src/features/storage/uploads/useUploadQueue.ts +30 -0
  52. package/src/i18n/translations/en/common.json +33 -0
  53. package/src/i18n/translations/en/settings.json +47 -4
  54. package/src/i18n/translations/fr/common.json +33 -0
  55. package/src/i18n/translations/fr/settings.json +47 -4
  56. package/src/index.css +2 -1
  57. package/src/index.ts +2 -0
  58. package/src/lib/z-index.ts +9 -3
  59. package/src/service-worker/register.ts +4 -12
@@ -0,0 +1,104 @@
1
+ import type { ShellUIConfig } from '../config/types';
2
+
3
+ const QUOTA_PATH = '/storage/v1/quota';
4
+ const BYTE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB'] as const;
5
+
6
+ export type StorageQuotaBucket = {
7
+ maxBytes: number | null;
8
+ usedBytes: number;
9
+ remainingBytes: number | null;
10
+ };
11
+
12
+ export type StorageQuotaSnapshot = {
13
+ companyId: number;
14
+ company: StorageQuotaBucket;
15
+ user: StorageQuotaBucket & { userId: number };
16
+ };
17
+
18
+ export const getStorageBaseUrl = (config: ShellUIConfig | undefined): string | null => {
19
+ const url = config?.storage?.url?.trim().replace(/\/+$/, '') || '';
20
+ return url || null;
21
+ };
22
+
23
+ /** Settings → Storage is shown only when storage.url is set and showInSettings is not false. */
24
+ export const isStorageSettingsEnabled = (config: ShellUIConfig | undefined): boolean => {
25
+ if (!getStorageBaseUrl(config)) return false;
26
+ return config?.storage?.showInSettings !== false;
27
+ };
28
+
29
+ export const formatBytes = (bytes: number, locale = 'en'): string => {
30
+ if (!Number.isFinite(bytes) || bytes <= 0) return `0 ${BYTE_UNITS[0]}`;
31
+ const exponent = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), BYTE_UNITS.length - 1);
32
+ const value = bytes / 1024 ** exponent;
33
+ const formatted = new Intl.NumberFormat(locale, {
34
+ maximumFractionDigits: exponent === 0 || value >= 10 ? 0 : 1,
35
+ }).format(value);
36
+ return `${formatted} ${BYTE_UNITS[exponent]}`;
37
+ };
38
+
39
+ export const getUsagePercent = (usedBytes: number, maxBytes: number | null): number | null => {
40
+ if (maxBytes === null || !Number.isFinite(maxBytes) || maxBytes <= 0) return null;
41
+ if (!Number.isFinite(usedBytes) || usedBytes <= 0) return 0;
42
+ return Math.min(100, Math.max(0, (usedBytes / maxBytes) * 100));
43
+ };
44
+
45
+ const asFiniteNumber = (value: unknown): number | null => {
46
+ if (typeof value === 'number' && Number.isFinite(value)) return value;
47
+ if (typeof value === 'string' && value.trim() !== '') {
48
+ const parsed = Number(value);
49
+ return Number.isFinite(parsed) ? parsed : null;
50
+ }
51
+ return null;
52
+ };
53
+
54
+ const parseBucket = (value: unknown): StorageQuotaBucket | null => {
55
+ if (!value || typeof value !== 'object') return null;
56
+ const record = value as Record<string, unknown>;
57
+ const usedBytes = asFiniteNumber(record.used_bytes);
58
+ if (usedBytes === null) return null;
59
+ const rawMax = asFiniteNumber(record.max_bytes);
60
+ const maxBytes = rawMax !== null && rawMax > 0 ? rawMax : null;
61
+ const remainingBytes = asFiniteNumber(record.remaining_bytes);
62
+ return {
63
+ usedBytes,
64
+ maxBytes,
65
+ remainingBytes,
66
+ };
67
+ };
68
+
69
+ export const parseStorageQuota = (payload: unknown): StorageQuotaSnapshot | null => {
70
+ if (!payload || typeof payload !== 'object') return null;
71
+ const record = payload as Record<string, unknown>;
72
+ const companyId = asFiniteNumber(record.company_id);
73
+ const company = parseBucket(record.company);
74
+ const userRaw = record.user;
75
+ if (companyId === null || !company || !userRaw || typeof userRaw !== 'object') return null;
76
+ const userBucket = parseBucket(userRaw);
77
+ const userId = asFiniteNumber((userRaw as Record<string, unknown>).user_id);
78
+ if (!userBucket || userId === null) return null;
79
+ return {
80
+ companyId,
81
+ company,
82
+ user: { ...userBucket, userId },
83
+ };
84
+ };
85
+
86
+ export const fetchStorageQuota = async (
87
+ storageBaseUrl: string,
88
+ accessToken: string,
89
+ ): Promise<StorageQuotaSnapshot> => {
90
+ const response = await fetch(`${storageBaseUrl.replace(/\/+$/, '')}${QUOTA_PATH}`, {
91
+ headers: {
92
+ Authorization: `Bearer ${accessToken}`,
93
+ Accept: 'application/json',
94
+ },
95
+ });
96
+ if (!response.ok) {
97
+ throw new Error(`HTTP ${response.status}`);
98
+ }
99
+ const snapshot = parseStorageQuota(await response.json());
100
+ if (!snapshot) {
101
+ throw new Error('Invalid quota response');
102
+ }
103
+ return snapshot;
104
+ };
@@ -0,0 +1,442 @@
1
+ import type { ReactNode } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { Button } from '../../../components/ui/button';
4
+ import {
5
+ Tooltip,
6
+ TooltipContent,
7
+ TooltipProvider,
8
+ TooltipTrigger,
9
+ } from '../../../components/ui/tooltip';
10
+ import { cn } from '../../../lib/utils';
11
+ import { formatBytes } from '../quota';
12
+ import type { UploadItem } from './types';
13
+ import {
14
+ closeUploadToaster,
15
+ getItemPercent,
16
+ interruptAllUploads,
17
+ interruptUpload,
18
+ removeUpload,
19
+ setUploadToastExpanded,
20
+ } from './uploadQueue';
21
+ import { useUploadQueue } from './useUploadQueue';
22
+
23
+ function ChevronIcon({ expanded }: { expanded: boolean }) {
24
+ return (
25
+ <svg
26
+ xmlns="http://www.w3.org/2000/svg"
27
+ width="16"
28
+ height="16"
29
+ viewBox="0 0 24 24"
30
+ fill="none"
31
+ stroke="currentColor"
32
+ strokeWidth="2"
33
+ strokeLinecap="round"
34
+ strokeLinejoin="round"
35
+ className={cn('transition-transform duration-200', expanded ? 'rotate-0' : 'rotate-180')}
36
+ >
37
+ <path d="m6 9 6 6 6-6" />
38
+ </svg>
39
+ );
40
+ }
41
+
42
+ function CloseIcon() {
43
+ return (
44
+ <svg
45
+ xmlns="http://www.w3.org/2000/svg"
46
+ width="16"
47
+ height="16"
48
+ viewBox="0 0 24 24"
49
+ fill="none"
50
+ stroke="currentColor"
51
+ strokeWidth="2"
52
+ strokeLinecap="round"
53
+ strokeLinejoin="round"
54
+ >
55
+ <path d="M18 6 6 18" />
56
+ <path d="m6 6 12 12" />
57
+ </svg>
58
+ );
59
+ }
60
+
61
+ function CheckIcon() {
62
+ return (
63
+ <svg
64
+ xmlns="http://www.w3.org/2000/svg"
65
+ width="14"
66
+ height="14"
67
+ viewBox="0 0 24 24"
68
+ fill="none"
69
+ stroke="currentColor"
70
+ strokeWidth="2.5"
71
+ strokeLinecap="round"
72
+ strokeLinejoin="round"
73
+ >
74
+ <path d="M20 6 9 17l-5-5" />
75
+ </svg>
76
+ );
77
+ }
78
+
79
+ function AlertIcon() {
80
+ return (
81
+ <svg
82
+ xmlns="http://www.w3.org/2000/svg"
83
+ width="14"
84
+ height="14"
85
+ viewBox="0 0 24 24"
86
+ fill="none"
87
+ stroke="currentColor"
88
+ strokeWidth="2"
89
+ strokeLinecap="round"
90
+ strokeLinejoin="round"
91
+ >
92
+ <circle
93
+ cx="12"
94
+ cy="12"
95
+ r="10"
96
+ />
97
+ <line
98
+ x1="12"
99
+ x2="12"
100
+ y1="8"
101
+ y2="12"
102
+ />
103
+ <line
104
+ x1="12"
105
+ x2="12.01"
106
+ y1="16"
107
+ y2="16"
108
+ />
109
+ </svg>
110
+ );
111
+ }
112
+
113
+ function CircularProgress({
114
+ percent,
115
+ tone,
116
+ }: {
117
+ percent: number;
118
+ tone: 'primary' | 'destructive' | 'muted';
119
+ }) {
120
+ const radius = 10;
121
+ const circumference = 2 * Math.PI * radius;
122
+ const offset = circumference - (percent / 100) * circumference;
123
+ const stroke =
124
+ tone === 'destructive'
125
+ ? 'stroke-destructive'
126
+ : tone === 'muted'
127
+ ? 'stroke-muted-foreground'
128
+ : 'stroke-primary';
129
+
130
+ return (
131
+ <svg
132
+ className="size-8 -rotate-90"
133
+ viewBox="0 0 24 24"
134
+ aria-hidden
135
+ >
136
+ <circle
137
+ cx="12"
138
+ cy="12"
139
+ r={radius}
140
+ fill="none"
141
+ className="stroke-muted"
142
+ strokeWidth="2.5"
143
+ />
144
+ <circle
145
+ cx="12"
146
+ cy="12"
147
+ r={radius}
148
+ fill="none"
149
+ className={stroke}
150
+ strokeWidth="2.5"
151
+ strokeLinecap="round"
152
+ strokeDasharray={circumference}
153
+ strokeDashoffset={offset}
154
+ style={{ transition: 'stroke-dashoffset 160ms ease-out' }}
155
+ />
156
+ </svg>
157
+ );
158
+ }
159
+
160
+ function StatusGlyph({
161
+ uploading,
162
+ error,
163
+ percent,
164
+ }: {
165
+ uploading: boolean;
166
+ error: boolean;
167
+ percent: number;
168
+ }) {
169
+ if (uploading) {
170
+ return (
171
+ <CircularProgress
172
+ percent={percent}
173
+ tone="primary"
174
+ />
175
+ );
176
+ }
177
+ if (error) {
178
+ return (
179
+ <div className="flex size-8 items-center justify-center rounded-full bg-destructive/10 text-destructive">
180
+ <AlertIcon />
181
+ </div>
182
+ );
183
+ }
184
+ return (
185
+ <div className="flex size-8 items-center justify-center rounded-full bg-primary/10 text-primary">
186
+ <CheckIcon />
187
+ </div>
188
+ );
189
+ }
190
+
191
+ function ProgressTrack({
192
+ percent,
193
+ tone = 'primary',
194
+ }: {
195
+ percent: number;
196
+ tone?: 'primary' | 'destructive';
197
+ }) {
198
+ return (
199
+ <div
200
+ className="h-1.5 w-full overflow-hidden rounded-full bg-muted"
201
+ role="progressbar"
202
+ aria-valuemin={0}
203
+ aria-valuemax={100}
204
+ aria-valuenow={percent}
205
+ >
206
+ <div
207
+ className={cn(
208
+ 'h-full rounded-full transition-[width] duration-200 ease-out',
209
+ tone === 'destructive' ? 'bg-destructive' : 'bg-primary',
210
+ )}
211
+ style={{ width: `${percent}%` }}
212
+ />
213
+ </div>
214
+ );
215
+ }
216
+
217
+ function IconButton({
218
+ label,
219
+ onClick,
220
+ children,
221
+ }: {
222
+ label: string;
223
+ onClick: () => void;
224
+ children: ReactNode;
225
+ }) {
226
+ return (
227
+ <Tooltip>
228
+ <TooltipTrigger asChild>
229
+ <Button
230
+ type="button"
231
+ variant="ghost"
232
+ size="icon"
233
+ data-upload-action=""
234
+ aria-label={label}
235
+ className="size-7 shrink-0 text-muted-foreground hover:text-foreground [touch-action:manipulation]"
236
+ onClick={(event) => {
237
+ event.stopPropagation();
238
+ onClick();
239
+ }}
240
+ >
241
+ {children}
242
+ </Button>
243
+ </TooltipTrigger>
244
+ <TooltipContent
245
+ side="top"
246
+ align="center"
247
+ collisionPadding={12}
248
+ >
249
+ {label}
250
+ </TooltipContent>
251
+ </Tooltip>
252
+ );
253
+ }
254
+
255
+ function titleForSummary(
256
+ t: (key: string, options?: Record<string, unknown>) => string,
257
+ summary: ReturnType<typeof useUploadQueue>['summary'],
258
+ ): string {
259
+ if (summary.uploading > 0) {
260
+ return t('uploads.titleUploading', { count: summary.uploading });
261
+ }
262
+ if (summary.error > 0 && summary.success > 0) {
263
+ return t('uploads.titleMixed', { success: summary.success, errors: summary.error });
264
+ }
265
+ if (summary.error > 0) {
266
+ return t('uploads.titleFailed', { count: summary.error });
267
+ }
268
+ if (summary.success > 0) {
269
+ return t('uploads.titleComplete', { count: summary.success });
270
+ }
271
+ if (summary.cancelled > 0) {
272
+ return t('uploads.titleCancelled', { count: summary.cancelled });
273
+ }
274
+ return t('uploads.titleCancelled', { count: summary.total });
275
+ }
276
+
277
+ function FileRow({ item, locale }: { item: UploadItem; locale: string }) {
278
+ const { t } = useTranslation('common');
279
+ const percent = getItemPercent(item);
280
+ const isUploading = item.status === 'uploading';
281
+ const sizeLabel = item.size > 0 ? formatBytes(item.size, locale) : null;
282
+
283
+ return (
284
+ <div className="flex flex-col gap-1.5 py-2">
285
+ <div className="flex items-start gap-2">
286
+ <div className="min-w-0 flex-1">
287
+ <p
288
+ className={cn(
289
+ 'truncate text-sm font-medium leading-tight',
290
+ item.status === 'cancelled' && 'text-muted-foreground',
291
+ )}
292
+ >
293
+ {item.name}
294
+ </p>
295
+ <p
296
+ className={cn(
297
+ 'mt-0.5 text-xs',
298
+ item.status === 'error' ? 'text-destructive' : 'text-muted-foreground',
299
+ )}
300
+ >
301
+ {item.status === 'error'
302
+ ? item.error || t('uploads.statusError')
303
+ : isUploading
304
+ ? [sizeLabel, t('uploads.progressPercent', { percent })].filter(Boolean).join(' · ')
305
+ : item.status === 'success'
306
+ ? [sizeLabel, t('uploads.statusComplete')].filter(Boolean).join(' · ')
307
+ : t('uploads.statusCancelled')}
308
+ </p>
309
+ </div>
310
+ <IconButton
311
+ label={isUploading ? t('uploads.cancelFile') : t('uploads.removeFile')}
312
+ onClick={() => (isUploading ? interruptUpload(item.id) : removeUpload(item.id))}
313
+ >
314
+ <CloseIcon />
315
+ </IconButton>
316
+ </div>
317
+ {isUploading ? <ProgressTrack percent={percent} /> : null}
318
+ </div>
319
+ );
320
+ }
321
+
322
+ export function UploadToastCard() {
323
+ const { t, i18n } = useTranslation('common');
324
+ const { items, summary, expanded } = useUploadQueue();
325
+ const locale = i18n.language || 'en';
326
+ const title = titleForSummary(t, summary);
327
+ const hasErrors = summary.error > 0;
328
+ const subtitleParts: string[] = [];
329
+
330
+ if (summary.uploading > 0 && summary.bytesTotal > 0) {
331
+ subtitleParts.push(
332
+ t('uploads.bytesProgress', {
333
+ uploaded: formatBytes(summary.bytesUploaded, locale),
334
+ total: formatBytes(summary.bytesTotal, locale),
335
+ }),
336
+ );
337
+ }
338
+ if (hasErrors) {
339
+ subtitleParts.push(t('uploads.errorCount', { count: summary.error }));
340
+ }
341
+ if (summary.cancelled > 0) {
342
+ subtitleParts.push(t('uploads.cancelledCount', { count: summary.cancelled }));
343
+ }
344
+ if (summary.uploading > 0 && summary.total > summary.uploading) {
345
+ subtitleParts.push(
346
+ t('uploads.filesProgress', { done: summary.success + summary.error, total: summary.total }),
347
+ );
348
+ }
349
+
350
+ return (
351
+ <TooltipProvider delayDuration={200}>
352
+ <div
353
+ className="w-[min(24rem,calc(100vw-1.5rem))] overflow-hidden rounded-xl border border-border bg-background text-foreground shadow-lg"
354
+ data-upload-toast=""
355
+ role="status"
356
+ aria-live="polite"
357
+ aria-busy={summary.uploading > 0}
358
+ >
359
+ <div className="flex items-start gap-3 p-3">
360
+ <StatusGlyph
361
+ uploading={summary.uploading > 0}
362
+ error={hasErrors && summary.uploading === 0}
363
+ percent={summary.percent}
364
+ />
365
+ <button
366
+ type="button"
367
+ className="min-w-0 flex-1 cursor-pointer text-left [touch-action:manipulation]"
368
+ aria-expanded={expanded}
369
+ aria-label={expanded ? t('uploads.collapse') : t('uploads.expand')}
370
+ onClick={() => setUploadToastExpanded(!expanded)}
371
+ >
372
+ <p
373
+ className="truncate text-sm font-medium leading-tight"
374
+ style={{ fontFamily: 'var(--heading-font-family, inherit)' }}
375
+ >
376
+ {title}
377
+ </p>
378
+ {subtitleParts.length > 0 ? (
379
+ <p className="mt-0.5 truncate text-xs text-muted-foreground">
380
+ {subtitleParts.join(' · ')}
381
+ </p>
382
+ ) : null}
383
+ </button>
384
+ <div className="flex items-center">
385
+ <IconButton
386
+ label={expanded ? t('uploads.collapse') : t('uploads.expand')}
387
+ onClick={() => setUploadToastExpanded(!expanded)}
388
+ >
389
+ <ChevronIcon expanded={expanded} />
390
+ </IconButton>
391
+ <IconButton
392
+ label={summary.uploading > 0 ? t('uploads.closeAndCancel') : t('uploads.dismiss')}
393
+ onClick={() => closeUploadToaster()}
394
+ >
395
+ <CloseIcon />
396
+ </IconButton>
397
+ </div>
398
+ </div>
399
+ <div className="px-3 pb-3">
400
+ <ProgressTrack
401
+ percent={summary.percent}
402
+ tone={hasErrors && summary.uploading === 0 ? 'destructive' : 'primary'}
403
+ />
404
+ </div>
405
+ <div
406
+ className={cn(
407
+ 'grid transition-[grid-template-rows] duration-300 ease-out',
408
+ expanded ? 'grid-rows-[1fr]' : 'grid-rows-[0fr]',
409
+ )}
410
+ >
411
+ <div className="overflow-hidden">
412
+ <div className="border-t border-border px-3">
413
+ <div className="max-h-[min(14rem,calc(100dvh-14rem))] overflow-y-auto overscroll-contain divide-y divide-border">
414
+ {items.map((item) => (
415
+ <FileRow
416
+ key={item.id}
417
+ item={item}
418
+ locale={locale}
419
+ />
420
+ ))}
421
+ </div>
422
+ {summary.uploading > 0 ? (
423
+ <div className="flex justify-end py-2">
424
+ <Button
425
+ type="button"
426
+ variant="ghost"
427
+ size="sm"
428
+ data-upload-action=""
429
+ className="h-8 text-xs text-muted-foreground [touch-action:manipulation]"
430
+ onClick={() => interruptAllUploads()}
431
+ >
432
+ {t('uploads.cancelAll')}
433
+ </Button>
434
+ </div>
435
+ ) : null}
436
+ </div>
437
+ </div>
438
+ </div>
439
+ </div>
440
+ </TooltipProvider>
441
+ );
442
+ }
@@ -0,0 +1,41 @@
1
+ import { useEffect } from 'react';
2
+ import { shellui } from '@shellui/sdk';
3
+ import { UploadToastCard } from './UploadToastCard';
4
+ import { startUploadToastDemo, UPLOAD_TOAST_DEMO_MESSAGE, UPLOAD_TOAST_ID } from './uploadQueue';
5
+ import { useUploadQueue } from './useUploadQueue';
6
+ import { Z_INDEX } from '../../../lib/z-index';
7
+
8
+ function isShellUiRoot(): boolean {
9
+ return typeof window !== 'undefined' && window.parent === window;
10
+ }
11
+
12
+ /**
13
+ * Custom upload toast at the outermost ShellUI window. Nested iframes never
14
+ * render it — they post uploads / demo requests up so the root can show this
15
+ * panel above modals and keep it while the user navigates.
16
+ */
17
+ export function UploadToaster() {
18
+ const isRoot = isShellUiRoot();
19
+ const { items } = useUploadQueue();
20
+
21
+ useEffect(() => {
22
+ if (!isRoot) return;
23
+ return shellui.addMessageListener(UPLOAD_TOAST_DEMO_MESSAGE, () => {
24
+ startUploadToastDemo();
25
+ });
26
+ }, [isRoot]);
27
+
28
+ if (!isRoot || items.length === 0) return null;
29
+
30
+ return (
31
+ <div
32
+ id={UPLOAD_TOAST_ID}
33
+ className="pointer-events-none fixed right-3 bottom-20 md:right-4 md:bottom-4"
34
+ style={{ zIndex: Z_INDEX.TOAST }}
35
+ >
36
+ <div className="pointer-events-auto origin-bottom animate-in fade-in-0 slide-in-from-bottom-2 duration-200">
37
+ <UploadToastCard />
38
+ </div>
39
+ </div>
40
+ );
41
+ }