@shellui/core 0.5.0-beta.3 → 0.5.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 (62) hide show
  1. package/README.md +5 -5
  2. package/package.json +3 -2
  3. package/src/app.tsx +8 -4
  4. package/src/components/ui/dialog.tsx +5 -1
  5. package/src/components/ui/dropdown-menu.tsx +39 -4
  6. package/src/components/ui/sheet.tsx +1 -1
  7. package/src/components/ui/sidebar.tsx +3 -2
  8. package/src/components/ui/tabs.tsx +52 -0
  9. package/src/constants/urls.ts +1 -0
  10. package/src/features/auth/AuthProvider.tsx +17 -6
  11. package/src/features/chromeActions/ChromeActionIcons.tsx +261 -0
  12. package/src/features/chromeActions/ChromeActionsDemoView.tsx +149 -0
  13. package/src/features/chromeActions/ChromeActionsHost.tsx +1511 -0
  14. package/src/features/chromeActions/ChromeActionsProvider.tsx +141 -0
  15. package/src/features/chromeActions/chromeActionsStore.spec.ts +61 -0
  16. package/src/features/chromeActions/chromeActionsStore.ts +77 -0
  17. package/src/features/chromeActions/computeActionInsets.spec.ts +360 -0
  18. package/src/features/chromeActions/computeActionInsets.ts +326 -0
  19. package/src/features/chromeActions/index.ts +26 -0
  20. package/src/features/chromeActions/resolveUuidForRemoveIframe.spec.ts +49 -0
  21. package/src/features/layouts/AppLayout.tsx +4 -4
  22. package/src/features/layouts/OverlayShell.tsx +60 -12
  23. package/src/features/layouts/app-bar-inset/AppBarInsetLayout.tsx +1 -1
  24. package/src/features/layouts/appbar/AppBarLayout.tsx +194 -89
  25. package/src/features/layouts/chrome/DesktopChrome.tsx +17 -3
  26. package/src/features/layouts/chrome/InsetMobileRadiusOverlay.tsx +18 -0
  27. package/src/features/layouts/chrome/index.ts +8 -0
  28. package/src/features/layouts/chrome/runtime.ts +73 -0
  29. package/src/features/layouts/chrome/useScrollHideChrome.ts +210 -0
  30. package/src/features/layouts/floating/FloatingBottomDock.tsx +410 -0
  31. package/src/features/layouts/floating/FloatingLayout.tsx +31 -21
  32. package/src/features/layouts/floating/FloatingStatusScrim.tsx +36 -0
  33. package/src/features/layouts/floating/computeFloatingInsets.spec.ts +5 -5
  34. package/src/features/layouts/floating/computeFloatingInsets.ts +64 -12
  35. package/src/features/layouts/floating/isShellOwnedPath.spec.ts +2 -0
  36. package/src/features/layouts/floating/isShellOwnedPath.ts +1 -0
  37. package/src/features/layouts/floating/layoutChromeStore.spec.ts +138 -0
  38. package/src/features/layouts/floating/layoutChromeStore.ts +169 -6
  39. package/src/features/layouts/floating/useFloatingChrome.ts +20 -30
  40. package/src/features/layouts/sidebar/SidebarLayout.tsx +87 -31
  41. package/src/features/layouts/sidebar-inset/SidebarInsetLayout.tsx +1 -1
  42. package/src/features/layouts/windows/WindowsLayout.tsx +240 -110
  43. package/src/features/overlays/ResponsiveModal.tsx +201 -21
  44. package/src/features/overlays/overlaySize.spec.ts +18 -0
  45. package/src/features/overlays/overlaySize.ts +89 -0
  46. package/src/features/settings/SettingsProvider.tsx +29 -9
  47. package/src/features/settings/components/Develop.tsx +2 -0
  48. package/src/features/settings/components/develop/ChromeActionsTestButtons.tsx +63 -0
  49. package/src/features/storage/uploads/uploadQueue.spec.ts +56 -1
  50. package/src/features/storage/uploads/uploadQueue.ts +42 -1
  51. package/src/features/theme/applyTheme.ts +23 -5
  52. package/src/hooks/use-mobile.tsx +21 -7
  53. package/src/i18n/translations/en/settings.json +9 -0
  54. package/src/i18n/translations/fr/settings.json +9 -0
  55. package/src/index.css +264 -124
  56. package/src/index.html +6 -4
  57. package/src/index.ts +8 -0
  58. package/src/routes/components/RouteFallback.tsx +15 -0
  59. package/src/routes/routes.tsx +14 -0
  60. package/src/features/layouts/floating/FloatingFadeMask.tsx +0 -22
  61. package/src/features/layouts/floating/FloatingTabBar.tsx +0 -437
  62. package/src/features/layouts/floating/FloatingTabIndicator.tsx +0 -216
@@ -1,4 +1,4 @@
1
- import { afterEach, describe, expect, it } from 'vitest';
1
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
2
2
  import {
3
3
  addUpload,
4
4
  closeUploadToaster,
@@ -15,11 +15,17 @@ import {
15
15
  setUploadProgress,
16
16
  setUploadToastExpanded,
17
17
  isUploadToastExpanded,
18
+ UPLOAD_TOAST_AUTO_DISMISS_MS,
18
19
  } from './uploadQueue';
19
20
 
20
21
  describe('uploadQueue', () => {
22
+ beforeEach(() => {
23
+ vi.useFakeTimers();
24
+ });
25
+
21
26
  afterEach(() => {
22
27
  resetUploadQueue();
28
+ vi.useRealTimers();
23
29
  });
24
30
 
25
31
  it('tracks progress and overall percent across files', () => {
@@ -115,4 +121,53 @@ describe('uploadQueue', () => {
115
121
  expect(getUploadQueue()).toEqual([]);
116
122
  expect(isUploadToastExpanded()).toBe(false);
117
123
  });
124
+
125
+ it('auto-dismisses the toaster a few seconds after all uploads succeed', () => {
126
+ addUpload({ id: 'a', name: 'a.pdf', path: 'a.pdf', bucket: 'company', size: 10 });
127
+ addUpload({ id: 'b', name: 'b.pdf', path: 'b.pdf', bucket: 'company', size: 10 });
128
+ completeUpload('a');
129
+ expect(getUploadQueue()).toHaveLength(2);
130
+ completeUpload('b');
131
+ expect(getUploadQueue()).toHaveLength(2);
132
+
133
+ vi.advanceTimersByTime(UPLOAD_TOAST_AUTO_DISMISS_MS - 1);
134
+ expect(getUploadQueue()).toHaveLength(2);
135
+
136
+ vi.advanceTimersByTime(1);
137
+ expect(getUploadQueue()).toEqual([]);
138
+ });
139
+
140
+ it('does not auto-dismiss when any upload fails', () => {
141
+ addUpload({ id: 'ok', name: 'ok.pdf', path: 'ok.pdf', bucket: 'company', size: 10 });
142
+ addUpload({ id: 'bad', name: 'bad.pdf', path: 'bad.pdf', bucket: 'company', size: 10 });
143
+ completeUpload('ok');
144
+ failUpload('bad', 'Denied');
145
+
146
+ vi.advanceTimersByTime(UPLOAD_TOAST_AUTO_DISMISS_MS * 2);
147
+ expect(getUploadQueue()).toHaveLength(2);
148
+ expect(getUploadQueue().map((item) => item.status)).toEqual(['success', 'error']);
149
+ });
150
+
151
+ it('cancels a pending auto-dismiss when a new upload starts', () => {
152
+ addUpload({ id: 'ok', name: 'ok.pdf', path: 'ok.pdf', bucket: 'company', size: 10 });
153
+ completeUpload('ok');
154
+
155
+ vi.advanceTimersByTime(UPLOAD_TOAST_AUTO_DISMISS_MS - 100);
156
+ addUpload({ id: 'next', name: 'next.pdf', path: 'next.pdf', bucket: 'company', size: 10 });
157
+
158
+ vi.advanceTimersByTime(UPLOAD_TOAST_AUTO_DISMISS_MS);
159
+ expect(getUploadQueue().map((item) => item.id)).toEqual(['ok', 'next']);
160
+ });
161
+
162
+ it('cancels a pending auto-dismiss when the toaster is closed manually', () => {
163
+ addUpload({ id: 'ok', name: 'ok.pdf', path: 'ok.pdf', bucket: 'company', size: 10 });
164
+ completeUpload('ok');
165
+ closeUploadToaster();
166
+ expect(getUploadQueue()).toEqual([]);
167
+
168
+ addUpload({ id: 'again', name: 'again.pdf', path: 'again.pdf', bucket: 'company', size: 10 });
169
+ vi.advanceTimersByTime(UPLOAD_TOAST_AUTO_DISMISS_MS);
170
+ expect(getUploadQueue()).toHaveLength(1);
171
+ expect(getUploadQueue()[0]?.status).toBe('uploading');
172
+ });
118
173
  });
@@ -2,6 +2,8 @@ import type { UploadItem, UploadItemStatus, UploadQueueSummary } from './types';
2
2
 
3
3
  export const UPLOAD_TOAST_ID = 'shellui-upload-progress';
4
4
  export const UPLOAD_TOAST_DEMO_MESSAGE = 'SHELLUI_UPLOAD_TOAST_DEMO';
5
+ /** Brief pause so the success state is visible before the toaster hides. */
6
+ export const UPLOAD_TOAST_AUTO_DISMISS_MS = 2500;
5
7
 
6
8
  type UploadListener = () => void;
7
9
 
@@ -21,6 +23,33 @@ const demoStartTimeouts: ReturnType<typeof setTimeout>[] = [];
21
23
 
22
24
  let items: UploadItem[] = [];
23
25
  let expanded = false;
26
+ let autoDismissTimeout: ReturnType<typeof setTimeout> | null = null;
27
+
28
+ function clearAutoDismissTimeout(): void {
29
+ if (autoDismissTimeout === null) return;
30
+ clearTimeout(autoDismissTimeout);
31
+ autoDismissTimeout = null;
32
+ }
33
+
34
+ /**
35
+ * Hide the toaster a few seconds after every upload finishes successfully.
36
+ * Errors and in-progress uploads keep the panel open; cancelled-only queues stay too.
37
+ */
38
+ function scheduleAutoDismissIfNeeded(): void {
39
+ clearAutoDismissTimeout();
40
+ const summary = getUploadSummary();
41
+ if (summary.uploading > 0 || summary.error > 0 || summary.success === 0) {
42
+ return;
43
+ }
44
+ autoDismissTimeout = setTimeout(() => {
45
+ autoDismissTimeout = null;
46
+ const current = getUploadSummary();
47
+ if (current.uploading > 0 || current.error > 0 || current.success === 0) {
48
+ return;
49
+ }
50
+ resetUploadQueue();
51
+ }, UPLOAD_TOAST_AUTO_DISMISS_MS);
52
+ }
24
53
 
25
54
  function emit(): void {
26
55
  listeners.forEach((listener) => listener());
@@ -115,6 +144,7 @@ export function getItemPercent(item: UploadItem): number {
115
144
  }
116
145
 
117
146
  export function addUpload(input: AddUploadInput): { id: string; signal: AbortSignal } {
147
+ clearAutoDismissTimeout();
118
148
  const id = input.id ?? createId();
119
149
  const existing = abortControllers.get(id);
120
150
  existing?.abort();
@@ -159,6 +189,7 @@ export function completeUpload(id: string): void {
159
189
  bytesUploaded: item.size || item.bytesUploaded,
160
190
  error: undefined,
161
191
  });
192
+ scheduleAutoDismissIfNeeded();
162
193
  }
163
194
 
164
195
  export function failUpload(id: string, message: string): void {
@@ -167,6 +198,7 @@ export function failUpload(id: string, message: string): void {
167
198
  abortControllers.delete(id);
168
199
  clearDemoTimer(id);
169
200
  patchItem(id, { status: 'error', error: message });
201
+ clearAutoDismissTimeout();
170
202
  }
171
203
 
172
204
  export function markUploadCancelled(id: string): void {
@@ -174,6 +206,7 @@ export function markUploadCancelled(id: string): void {
174
206
  abortControllers.delete(id);
175
207
  clearDemoTimer(id);
176
208
  patchItem(id, { status: 'cancelled' });
209
+ scheduleAutoDismissIfNeeded();
177
210
  }
178
211
 
179
212
  /** Abort an in-progress upload and keep it visible as cancelled. */
@@ -196,11 +229,18 @@ export function removeUpload(id: string): void {
196
229
  const next = items.filter((entry) => entry.id !== id);
197
230
  if (next.length === items.length) return;
198
231
  items = next;
199
- if (items.length === 0) expanded = false;
232
+ if (items.length === 0) {
233
+ expanded = false;
234
+ clearAutoDismissTimeout();
235
+ }
200
236
  emit();
237
+ if (items.length > 0) {
238
+ scheduleAutoDismissIfNeeded();
239
+ }
201
240
  }
202
241
 
203
242
  export function dismissFinishedUploads(): void {
243
+ clearAutoDismissTimeout();
204
244
  const keep = items.filter((item) => item.status === 'uploading');
205
245
  items.forEach((item) => {
206
246
  if (item.status === 'uploading') return;
@@ -228,6 +268,7 @@ export function closeUploadToaster(): void {
228
268
  }
229
269
 
230
270
  export function resetUploadQueue(): void {
271
+ clearAutoDismissTimeout();
231
272
  abortControllers.forEach((controller) => controller.abort());
232
273
  abortControllers.clear();
233
274
  demoTimers.forEach((timer) => clearInterval(timer));
@@ -1,5 +1,7 @@
1
1
  import { toCssVarValue } from './color';
2
2
  import type { ThemeColorsMode, ThemeDefinition } from './types';
3
+ import { isHomeScreenPwa, isTauriRuntime } from '../layouts/chrome/runtime';
4
+
3
5
  const COLOR_VAR_MAP: Array<[keyof ThemeColorsMode, string]> = [
4
6
  ['background', '--background'],
5
7
  ['foreground', '--foreground'],
@@ -35,13 +37,30 @@ const COLOR_VAR_MAP: Array<[keyof ThemeColorsMode, string]> = [
35
37
  ['chart5', '--chart-5'],
36
38
  ];
37
39
 
38
- /** Update <meta name="theme-color"> so PWA / browser chrome matches the active surface. */
40
+ /**
41
+ * Update <meta name="theme-color"> so browser chrome matches the active surface.
42
+ *
43
+ * Skipped for:
44
+ * - Home Screen PWAs (iOS 26/27 Liquid Glass ignores it; on older iOS it can
45
+ * override `black-translucent` and paint an uncoverable slab)
46
+ * - Tauri runtime (native window / status bar owns chrome; meta is meaningless)
47
+ */
39
48
  function syncThemeColorMeta(cssColor: string): void {
40
- if (typeof document === 'undefined' || !cssColor) return;
49
+ if (typeof document === 'undefined') return;
41
50
  const head = document.head || document.getElementsByTagName('head')[0];
42
51
  if (!head) return;
43
52
 
44
- // Prefer a single unconditional theme-color (iOS reads this; media variants are flaky standalone)
53
+ const skip = isTauriRuntime() || isHomeScreenPwa();
54
+ const existing = head.querySelectorAll<HTMLMetaElement>('meta[name="theme-color"]');
55
+
56
+ if (skip) {
57
+ existing.forEach((meta) => meta.remove());
58
+ return;
59
+ }
60
+
61
+ if (!cssColor) return;
62
+
63
+ // Prefer a single unconditional theme-color (media variants are flaky)
45
64
  let meta = head.querySelector<HTMLMetaElement>('meta[name="theme-color"]:not([media])');
46
65
  if (!meta) {
47
66
  meta = document.createElement('meta');
@@ -76,8 +95,7 @@ export function applyTheme(theme: ThemeDefinition, isDark: boolean): void {
76
95
 
77
96
  root.style.setProperty('--radius', colors.radius);
78
97
 
79
- // Keep browser chrome in sync. theme-color coexists with black-translucent — it
80
- // does not paint the iOS status-bar slab, sizing the shell with dvh does.
98
+ // Browser-tab chrome only — see syncThemeColorMeta (skipped for PWA / Tauri).
81
99
  syncThemeColorMeta(toCssVarValue(colors.background) || (isDark ? '#000000' : '#ffffff'));
82
100
 
83
101
  const head = document.head || document.getElementsByTagName('head')[0];
@@ -2,18 +2,32 @@ import * as React from 'react';
2
2
 
3
3
  const MOBILE_BREAKPOINT = 768;
4
4
 
5
+ function readIsMobile(): boolean {
6
+ if (typeof window === 'undefined') return false;
7
+ return window.innerWidth < MOBILE_BREAKPOINT;
8
+ }
9
+
10
+ /**
11
+ * True below the `md` breakpoint (width &lt; 768).
12
+ * Listens to matchMedia **and** resize/orientationchange — iOS often updates
13
+ * `innerWidth` on resize before (or without) a reliable matchMedia `change`.
14
+ */
5
15
  export function useIsMobile() {
6
- const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined);
16
+ const [isMobile, setIsMobile] = React.useState<boolean>(readIsMobile);
7
17
 
8
18
  React.useEffect(() => {
19
+ const sync = () => setIsMobile(readIsMobile());
9
20
  const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
10
- const onChange = () => {
11
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
21
+ mql.addEventListener('change', sync);
22
+ window.addEventListener('resize', sync);
23
+ window.addEventListener('orientationchange', sync);
24
+ sync();
25
+ return () => {
26
+ mql.removeEventListener('change', sync);
27
+ window.removeEventListener('resize', sync);
28
+ window.removeEventListener('orientationchange', sync);
12
29
  };
13
- mql.addEventListener('change', onChange);
14
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
15
- return () => mql.removeEventListener('change', onChange);
16
30
  }, []);
17
31
 
18
- return !!isMobile;
32
+ return isMobile;
19
33
  }
@@ -462,6 +462,15 @@
462
462
  "files": "Select files",
463
463
  "filesAndFolders": "Select files and folders"
464
464
  }
465
+ },
466
+ "chromeActions": {
467
+ "title": "Chrome actions",
468
+ "description": "Opens a shell-owned demo page inside a modal or drawer iframe. That iframe calls shellui.actions.set/clear so chrome and click round-trips use the real postMessage path. Use Set / Update / Clear inside the demo; narrow the viewport for ··· overflow.",
469
+ "buttons": {
470
+ "openModal": "Open demo (modal iframe)",
471
+ "openDrawer": "Open demo (drawer iframe)",
472
+ "close": "Close demo"
473
+ }
465
474
  }
466
475
  }
467
476
  }
@@ -462,6 +462,15 @@
462
462
  "files": "Sélectionner des fichiers",
463
463
  "filesAndFolders": "Sélectionner fichiers et dossiers"
464
464
  }
465
+ },
466
+ "chromeActions": {
467
+ "title": "Actions chrome",
468
+ "description": "Ouvre une page démo Shellui dans un modal ou un tiroir (iframe). Cette iframe appelle shellui.actions.set/clear pour exercer le chrome et le round-trip postMessage. Utilisez Set / Update / Clear dans la démo ; réduisez la fenêtre pour le menu ···.",
469
+ "buttons": {
470
+ "openModal": "Ouvrir la démo (modal iframe)",
471
+ "openDrawer": "Ouvrir la démo (tiroir iframe)",
472
+ "close": "Fermer la démo"
473
+ }
465
474
  }
466
475
  }
467
476
  }