@shellui/core 0.7.0-alpha.1 → 0.7.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/schemas/shellui.config.schema.json +37 -4
- package/src/components/ContentView.tsx +19 -8
- package/src/components/ui/sidebar.tsx +11 -5
- package/src/features/admin/AdminView.tsx +9 -6
- package/src/features/auth/AuthProvider.tsx +25 -4
- package/src/features/auth/appBackend/appBackendSessions.spec.ts +134 -0
- package/src/features/auth/appBackend/appBackendSessions.ts +168 -17
- package/src/features/auth/appBackend/childFrames.spec.ts +328 -0
- package/src/features/auth/appBackend/childFrames.ts +180 -0
- package/src/features/auth/appBackend/frameAuth.ts +47 -10
- package/src/features/auth/appBackend/silentSignIn.spec.ts +18 -0
- package/src/features/auth/appBackend/silentSignIn.ts +15 -1
- package/src/features/auth/appBackend/tokenExchange.spec.ts +98 -0
- package/src/features/auth/appBackend/tokenExchange.ts +76 -0
- package/src/features/auth/components/OAuthCallbackView.tsx +7 -5
- package/src/features/auth/utils/buildOAuthSessionRedirectTo.spec.ts +42 -1
- package/src/features/auth/utils/buildOAuthSessionRedirectTo.ts +23 -0
- package/src/features/auth/utils/canRestoreStoredSession.spec.ts +29 -0
- package/src/features/auth/utils/canRestoreStoredSession.ts +12 -0
- package/src/features/auth/utils/index.ts +7 -1
- package/src/features/auth/utils/resolveSdkLoginRedirectPath.spec.ts +41 -0
- package/src/features/auth/utils/resolveSdkLoginRedirectPath.ts +31 -0
- package/src/features/auth/utils/webPkce.spec.ts +23 -0
- package/src/features/auth/utils/webPkce.ts +23 -6
- package/src/features/chromeActions/computeActionInsets.ts +7 -4
- package/src/features/config/types.ts +30 -4
- package/src/features/layouts/appbar/AppBarLayout.tsx +63 -30
- package/src/features/layouts/chrome/CollapsedDesktopTitlebar.tsx +12 -23
- package/src/features/layouts/chrome/ContentDragOverlay.tsx +5 -6
- package/src/features/layouts/chrome/DesktopChrome.tsx +37 -0
- package/src/features/layouts/chrome/DesktopHistoryButtons.tsx +15 -4
- package/src/features/layouts/chrome/MacStrip.tsx +33 -0
- package/src/features/layouts/chrome/constants.ts +33 -8
- package/src/features/layouts/chrome/index.ts +8 -0
- package/src/features/layouts/chrome/stripDragMap.ts +35 -0
- package/src/features/layouts/chrome/stripNoDrag.spec.tsx +103 -0
- package/src/features/layouts/chrome/useScrollHideChrome.ts +3 -8
- package/src/features/layouts/filterNavigationForAuthState.spec.ts +5 -3
- package/src/features/layouts/floating/FloatingBottomDock.tsx +199 -20
- package/src/features/layouts/floating/FloatingLayout.tsx +13 -8
- package/src/features/layouts/floating/FloatingSidebar.tsx +144 -70
- package/src/features/layouts/floating/computeFloatingInsets.ts +22 -4
- package/src/features/layouts/floating/useFloatingChrome.ts +3 -1
- package/src/features/layouts/floating/useSoftKeyboard.spec.ts +39 -0
- package/src/features/layouts/floating/useSoftKeyboard.ts +82 -0
- package/src/features/layouts/fullscreen/FullscreenLayout.tsx +38 -10
- package/src/features/layouts/sidebar/NavigationContent.tsx +14 -6
- package/src/features/layouts/sidebar/SidebarIcons.tsx +3 -9
- package/src/features/layouts/sidebar/SidebarInner.tsx +50 -39
- package/src/features/layouts/sidebar/SidebarLayout.tsx +8 -11
- package/src/features/layouts/utils.ts +4 -3
- package/src/features/layouts/windows/DesktopDots.tsx +76 -0
- package/src/features/layouts/windows/WindowsLayout.tsx +184 -125
- package/src/features/layouts/windows/deskDots.spec.ts +52 -0
- package/src/features/layouts/windows/deskDots.ts +314 -0
- package/src/features/settings/SettingsProvider.tsx +158 -2
- package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +8 -7
- package/src/features/settings/utils/buildSettingsForPropagation.ts +4 -6
- package/src/features/theme/applyTheme.ts +8 -0
- package/src/features/theme/navContrast.spec.ts +49 -0
- package/src/features/theme/navContrast.ts +108 -0
- package/src/features/transfers/transferQueue.spec.ts +6 -2
- package/src/i18n/translations/en/common.json +25 -0
- package/src/i18n/translations/fr/common.json +25 -0
- package/src/index.css +935 -46
- package/src/index.ts +1 -0
- package/src/routes/hooks/useNavigationItems.ts +14 -3
- package/src/routes/hooks/withShellSearch.spec.ts +13 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Active nav contrast guard.
|
|
3
|
+
*
|
|
4
|
+
* The solid active pill paints `--sidebar-primary-foreground` on `--sidebar-primary`.
|
|
5
|
+
* Some themes pair those two below WCAG AA (4.5:1). For those, `applyTheme` sets
|
|
6
|
+
* `html[data-shellui-nav-contrast="low"]` and the chrome switches to a tinted pill.
|
|
7
|
+
*
|
|
8
|
+
* Parses the colour formats themes use: oklch(), #rrggbb, hsl() and legacy
|
|
9
|
+
* `H S% L%` channels. Anything else returns null (guard stays off).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const NAV_CONTRAST_MIN = 4.5;
|
|
13
|
+
export const NAV_CONTRAST_ATTR = 'data-shellui-nav-contrast';
|
|
14
|
+
|
|
15
|
+
type Rgb = [number, number, number];
|
|
16
|
+
|
|
17
|
+
const clamp01 = (n: number) => Math.min(1, Math.max(0, n));
|
|
18
|
+
|
|
19
|
+
function parseNumber(token: string, percentScale: number): number | null {
|
|
20
|
+
const t = token.trim();
|
|
21
|
+
if (t === 'none') return 0;
|
|
22
|
+
const n = parseFloat(t);
|
|
23
|
+
if (Number.isNaN(n)) return null;
|
|
24
|
+
return t.endsWith('%') ? (n / 100) * percentScale : n;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** OKLCH to linear sRGB (Björn Ottosson's matrices), clamped to the gamut. */
|
|
28
|
+
function oklchToLinearRgb(L: number, C: number, H: number): Rgb {
|
|
29
|
+
const hr = (H * Math.PI) / 180;
|
|
30
|
+
const a = C * Math.cos(hr);
|
|
31
|
+
const b = C * Math.sin(hr);
|
|
32
|
+
const l_ = L + 0.3963377774 * a + 0.2158037573 * b;
|
|
33
|
+
const m_ = L - 0.1055613458 * a - 0.0638541728 * b;
|
|
34
|
+
const s_ = L - 0.0894841775 * a - 1.291485548 * b;
|
|
35
|
+
const l = l_ ** 3;
|
|
36
|
+
const m = m_ ** 3;
|
|
37
|
+
const s = s_ ** 3;
|
|
38
|
+
return [
|
|
39
|
+
clamp01(4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s),
|
|
40
|
+
clamp01(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s),
|
|
41
|
+
clamp01(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s),
|
|
42
|
+
];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const srgbToLinear = (c: number) => (c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4);
|
|
46
|
+
|
|
47
|
+
function hslToLinearRgb(h: number, s: number, l: number): Rgb {
|
|
48
|
+
const k = (n: number) => (n + h / 30) % 12;
|
|
49
|
+
const a = s * Math.min(l, 1 - l);
|
|
50
|
+
const f = (n: number) => l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
|
|
51
|
+
return [srgbToLinear(f(0)), srgbToLinear(f(8)), srgbToLinear(f(4))];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Linear sRGB for a theme colour value, or null when the format is unknown. */
|
|
55
|
+
export function parseThemeColor(value: string | undefined | null): Rgb | null {
|
|
56
|
+
if (!value || typeof value !== 'string') return null;
|
|
57
|
+
const v = value.trim().toLowerCase();
|
|
58
|
+
|
|
59
|
+
const hex = v.match(/^#?([0-9a-f]{6})$/);
|
|
60
|
+
if (hex) {
|
|
61
|
+
const n = parseInt(hex[1], 16);
|
|
62
|
+
return [
|
|
63
|
+
srgbToLinear(((n >> 16) & 255) / 255),
|
|
64
|
+
srgbToLinear(((n >> 8) & 255) / 255),
|
|
65
|
+
srgbToLinear((n & 255) / 255),
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const ok = v.match(/^oklch\(\s*([^\s/]+)\s+([^\s/]+)\s+([^\s/)]+)/);
|
|
70
|
+
if (ok) {
|
|
71
|
+
const L = parseNumber(ok[1], 1);
|
|
72
|
+
const C = parseNumber(ok[2], 0.4);
|
|
73
|
+
const H = parseNumber(ok[3], 360);
|
|
74
|
+
if (L === null || C === null || H === null) return null;
|
|
75
|
+
return oklchToLinearRgb(L, C, H);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const hsl = v.match(/^(?:hsla?\()?\s*([\d.]+)(?:deg)?[\s,]+([\d.]+)%[\s,]+([\d.]+)%/);
|
|
79
|
+
if (hsl) {
|
|
80
|
+
return hslToLinearRgb(parseFloat(hsl[1]), parseFloat(hsl[2]) / 100, parseFloat(hsl[3]) / 100);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const luminance = ([r, g, b]: Rgb) => 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
87
|
+
|
|
88
|
+
/** WCAG 2 contrast ratio between two theme colours, or null when either is unparsable. */
|
|
89
|
+
export function contrastRatio(
|
|
90
|
+
a: string | undefined | null,
|
|
91
|
+
b: string | undefined | null,
|
|
92
|
+
): number | null {
|
|
93
|
+
const ca = parseThemeColor(a);
|
|
94
|
+
const cb = parseThemeColor(b);
|
|
95
|
+
if (!ca || !cb) return null;
|
|
96
|
+
const la = luminance(ca);
|
|
97
|
+
const lb = luminance(cb);
|
|
98
|
+
return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** True when the solid active pill would fall under 4.5:1 for this mode. */
|
|
102
|
+
export function isLowNavContrast(
|
|
103
|
+
sidebarPrimary?: string | null,
|
|
104
|
+
sidebarPrimaryForeground?: string | null,
|
|
105
|
+
): boolean {
|
|
106
|
+
const ratio = contrastRatio(sidebarPrimary, sidebarPrimaryForeground);
|
|
107
|
+
return ratio !== null && ratio < NAV_CONTRAST_MIN;
|
|
108
|
+
}
|
|
@@ -47,14 +47,18 @@ describe('transferQueue', () => {
|
|
|
47
47
|
expect(summary.active).toBe(2);
|
|
48
48
|
expect(summary.activeUploads).toBe(1);
|
|
49
49
|
expect(summary.activeDownloads).toBe(1);
|
|
50
|
-
|
|
50
|
+
const download = getTransferQueue().find((i) => i.id === 'dl');
|
|
51
|
+
expect(download).toBeDefined();
|
|
52
|
+
expect(getItemPercent(download as NonNullable<typeof download>)).toBe(25);
|
|
51
53
|
expect(getTransferQueue().find((i) => i.id === 'dl')?.bytesTransferred).toBe(175_000_000);
|
|
52
54
|
});
|
|
53
55
|
|
|
54
56
|
it('supports ratio-only progress when size is unknown', () => {
|
|
55
57
|
addTransfer({ id: 'dl', kind: 'download', name: 'Model', size: 0 });
|
|
56
58
|
setTransferProgress('dl', { ratio: 0.4 });
|
|
57
|
-
|
|
59
|
+
const [item] = getTransferQueue();
|
|
60
|
+
expect(item).toBeDefined();
|
|
61
|
+
expect(getItemPercent(item as NonNullable<typeof item>)).toBe(40);
|
|
58
62
|
expect(getTransferSummary().percent).toBe(40);
|
|
59
63
|
});
|
|
60
64
|
|
|
@@ -155,5 +155,30 @@
|
|
|
155
155
|
"navigation": "Navigation",
|
|
156
156
|
"openNavigation": "Open navigation",
|
|
157
157
|
"more": "More"
|
|
158
|
+
},
|
|
159
|
+
"shellChrome": {
|
|
160
|
+
"externalLink": "Opens in a new tab",
|
|
161
|
+
"mainNav": "Main",
|
|
162
|
+
"accountNav": "Account",
|
|
163
|
+
"toggleSidebar": "Toggle sidebar",
|
|
164
|
+
"resizeSidebar": "Resize sidebar",
|
|
165
|
+
"dragToResize": "Drag to resize",
|
|
166
|
+
"collapseSidebar": "Collapse sidebar",
|
|
167
|
+
"expandSidebar": "Expand sidebar",
|
|
168
|
+
"closeMenu": "Close menu",
|
|
169
|
+
"unreadCount": "{{count}} unread",
|
|
170
|
+
"sheetDescription": "Main navigation and account links"
|
|
171
|
+
},
|
|
172
|
+
"windows": {
|
|
173
|
+
"applications": "Applications",
|
|
174
|
+
"chooseApp": "Choose an app to open in a window",
|
|
175
|
+
"noApps": "No applications available",
|
|
176
|
+
"maximize": "Maximize",
|
|
177
|
+
"restore": "Restore",
|
|
178
|
+
"close": "Close",
|
|
179
|
+
"taskbar": "Taskbar",
|
|
180
|
+
"openApps": "Open windows",
|
|
181
|
+
"start": "Start",
|
|
182
|
+
"open": "Open"
|
|
158
183
|
}
|
|
159
184
|
}
|
|
@@ -155,5 +155,30 @@
|
|
|
155
155
|
"navigation": "Navigation",
|
|
156
156
|
"openNavigation": "Ouvrir la navigation",
|
|
157
157
|
"more": "Plus"
|
|
158
|
+
},
|
|
159
|
+
"shellChrome": {
|
|
160
|
+
"externalLink": "S'ouvre dans un nouvel onglet",
|
|
161
|
+
"mainNav": "Principal",
|
|
162
|
+
"accountNav": "Compte",
|
|
163
|
+
"toggleSidebar": "Afficher ou masquer la barre latérale",
|
|
164
|
+
"resizeSidebar": "Redimensionner la barre latérale",
|
|
165
|
+
"dragToResize": "Faire glisser pour redimensionner",
|
|
166
|
+
"collapseSidebar": "Réduire la barre latérale",
|
|
167
|
+
"expandSidebar": "Développer la barre latérale",
|
|
168
|
+
"closeMenu": "Fermer le menu",
|
|
169
|
+
"unreadCount": "{{count}} non lus",
|
|
170
|
+
"sheetDescription": "Navigation principale et liens du compte"
|
|
171
|
+
},
|
|
172
|
+
"windows": {
|
|
173
|
+
"applications": "Applications",
|
|
174
|
+
"chooseApp": "Choisissez une application à ouvrir dans une fenêtre",
|
|
175
|
+
"noApps": "Aucune application disponible",
|
|
176
|
+
"maximize": "Agrandir",
|
|
177
|
+
"restore": "Restaurer",
|
|
178
|
+
"close": "Fermer",
|
|
179
|
+
"taskbar": "Barre des tâches",
|
|
180
|
+
"openApps": "Fenêtres ouvertes",
|
|
181
|
+
"start": "Démarrer",
|
|
182
|
+
"open": "Ouverte"
|
|
158
183
|
}
|
|
159
184
|
}
|