@shellui/core 0.5.0-beta.2 → 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.
- package/README.md +5 -5
- package/package.json +3 -2
- package/schemas/shellui.config.schema.json +10 -2
- package/src/app.tsx +8 -4
- package/src/components/ContentView.tsx +12 -5
- package/src/components/ui/alert-dialog.tsx +1 -1
- package/src/components/ui/dialog.tsx +5 -1
- package/src/components/ui/dropdown-menu.tsx +39 -4
- package/src/components/ui/sheet.tsx +1 -1
- package/src/components/ui/sidebar.tsx +60 -20
- package/src/components/ui/tabs.tsx +52 -0
- package/src/constants/urls.ts +1 -0
- package/src/features/auth/AuthProvider.tsx +17 -6
- package/src/features/chromeActions/ChromeActionIcons.tsx +261 -0
- package/src/features/chromeActions/ChromeActionsDemoView.tsx +149 -0
- package/src/features/chromeActions/ChromeActionsHost.tsx +1511 -0
- package/src/features/chromeActions/ChromeActionsProvider.tsx +141 -0
- package/src/features/chromeActions/chromeActionsStore.spec.ts +61 -0
- package/src/features/chromeActions/chromeActionsStore.ts +77 -0
- package/src/features/chromeActions/computeActionInsets.spec.ts +360 -0
- package/src/features/chromeActions/computeActionInsets.ts +326 -0
- package/src/features/chromeActions/index.ts +26 -0
- package/src/features/chromeActions/resolveUuidForRemoveIframe.spec.ts +49 -0
- package/src/features/config/types.ts +16 -2
- package/src/features/layouts/AppLayout.tsx +30 -3
- package/src/features/layouts/OverlayShell.tsx +63 -13
- package/src/features/layouts/app-bar-inset/AppBarInsetLayout.tsx +22 -0
- package/src/features/layouts/appbar/AppBarLayout.tsx +230 -86
- package/src/features/layouts/chrome/DesktopChrome.tsx +17 -3
- package/src/features/layouts/chrome/InsetMobileRadiusOverlay.tsx +18 -0
- package/src/features/layouts/chrome/index.ts +8 -0
- package/src/features/layouts/chrome/runtime.ts +73 -0
- package/src/features/layouts/chrome/useScrollHideChrome.ts +210 -0
- package/src/features/layouts/floating/FloatingBottomDock.tsx +410 -0
- package/src/features/layouts/floating/FloatingLayout.tsx +152 -0
- package/src/features/layouts/floating/FloatingSidebar.tsx +327 -0
- package/src/features/layouts/floating/FloatingStatusScrim.tsx +36 -0
- package/src/features/layouts/floating/computeFloatingInsets.spec.ts +83 -0
- package/src/features/layouts/floating/computeFloatingInsets.ts +155 -0
- package/src/features/layouts/floating/isShellOwnedPath.spec.ts +25 -0
- package/src/features/layouts/floating/isShellOwnedPath.ts +17 -0
- package/src/features/layouts/floating/layoutChromeStore.spec.ts +138 -0
- package/src/features/layouts/floating/layoutChromeStore.ts +209 -0
- package/src/features/layouts/floating/scrollChrome.spec.ts +49 -0
- package/src/features/layouts/floating/useFloatingChrome.ts +206 -0
- package/src/features/layouts/sidebar/SidebarLayout.tsx +119 -37
- package/src/features/layouts/sidebar/types.ts +4 -0
- package/src/features/layouts/sidebar-inset/SidebarInsetLayout.tsx +15 -0
- package/src/features/layouts/windows/WindowsLayout.tsx +240 -110
- package/src/features/overlays/ResponsiveModal.tsx +201 -21
- package/src/features/overlays/overlaySize.spec.ts +18 -0
- package/src/features/overlays/overlaySize.ts +89 -0
- package/src/features/settings/SettingsProvider.tsx +36 -9
- package/src/features/settings/SettingsView.tsx +6 -6
- package/src/features/settings/components/Develop.tsx +33 -13
- package/src/features/settings/components/develop/ChromeActionsTestButtons.tsx +63 -0
- package/src/features/settings/utils/buildSettingsForPropagation.ts +16 -0
- package/src/features/storage/StoragePickerContext.tsx +1 -0
- package/src/features/storage/uploads/uploadQueue.spec.ts +56 -1
- package/src/features/storage/uploads/uploadQueue.ts +42 -1
- package/src/features/theme/applyTheme.ts +23 -5
- package/src/hooks/use-mobile.tsx +21 -7
- package/src/hooks/use-viewport.ts +40 -0
- package/src/i18n/translations/en/settings.json +17 -2
- package/src/i18n/translations/fr/settings.json +17 -2
- package/src/index.css +473 -12
- package/src/index.html +6 -4
- package/src/index.ts +8 -0
- package/src/routes/components/RouteFallback.tsx +21 -2
- package/src/routes/routes.tsx +14 -0
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# @shellui/core
|
|
2
2
|
|
|
3
|
-
Shellui
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
3
|
+
React runtime for the Shellui host. `@shellui/cli` depends on this package. Install it yourself when you import config types or `useAuth` from host code.
|
|
6
4
|
|
|
7
5
|
```bash
|
|
8
6
|
npm install @shellui/core
|
|
9
7
|
```
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
```typescript
|
|
10
|
+
import type { ShellUIConfig } from '@shellui/core';
|
|
11
|
+
```
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Docs: [Core](https://docs.shellui.com/core), [CLI](https://docs.shellui.com/cli).
|
|
14
14
|
|
|
15
15
|
## License
|
|
16
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shellui/core",
|
|
3
|
-
"version": "0.5.0
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Shellui Core - Core React application runtime",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
|
51
51
|
"@radix-ui/react-separator": "^1.1.8",
|
|
52
52
|
"@radix-ui/react-slot": "^1.2.4",
|
|
53
|
+
"@radix-ui/react-tabs": "^1.1.21",
|
|
53
54
|
"@radix-ui/react-tooltip": "^1.2.8",
|
|
54
55
|
"@sentry/react": "^10.39.0",
|
|
55
56
|
"@supabase/supabase-js": "^2.99.3",
|
|
@@ -71,7 +72,7 @@
|
|
|
71
72
|
"workbox-routing": "^7.4.0",
|
|
72
73
|
"workbox-strategies": "^7.4.0",
|
|
73
74
|
"workbox-window": "^7.4.0",
|
|
74
|
-
"@shellui/sdk": "0.5.0
|
|
75
|
+
"@shellui/sdk": "0.5.0"
|
|
75
76
|
},
|
|
76
77
|
"peerDependencies": {
|
|
77
78
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -172,8 +172,16 @@
|
|
|
172
172
|
},
|
|
173
173
|
"LayoutType": {
|
|
174
174
|
"type": "string",
|
|
175
|
-
"enum": [
|
|
176
|
-
|
|
175
|
+
"enum": [
|
|
176
|
+
"sidebar",
|
|
177
|
+
"sidebar-inset",
|
|
178
|
+
"fullscreen",
|
|
179
|
+
"windows",
|
|
180
|
+
"app-bar",
|
|
181
|
+
"app-bar-inset",
|
|
182
|
+
"floating"
|
|
183
|
+
],
|
|
184
|
+
"description": "Layout mode: 'sidebar' (default) shows navigation sidebar; 'sidebar-inset' is sidebar with a padded, rounded main frame that reveals the chrome background; 'fullscreen' shows only content area; 'windows' shows a taskbar with start menu and multi-window desktop; 'app-bar' shows a compact top bar with a 9-square launcher for start links and icon-only end links; 'app-bar-inset' is app-bar with the same padded, rounded main frame as sidebar-inset; 'floating' is glass navigation over full-bleed content (bottom-centered tabs on phone and tablet, floating sidebar on desktop) with layout-chrome safe insets for iframe apps."
|
|
177
185
|
},
|
|
178
186
|
"NavigationItem": {
|
|
179
187
|
"type": "object",
|
package/src/app.tsx
CHANGED
|
@@ -12,6 +12,7 @@ import { CookieConsentModal } from './features/cookieConsent/CookieConsentModal'
|
|
|
12
12
|
import { AuthProvider } from './features/auth/AuthProvider';
|
|
13
13
|
import { StorageBridge } from './features/storage/StorageBridge';
|
|
14
14
|
import { SonnerProvider } from './features/sonner/SonnerContext';
|
|
15
|
+
import { ChromeActionsHost, ChromeActionsProvider } from './features/chromeActions';
|
|
15
16
|
import { Toaster } from './components/ui/sonner';
|
|
16
17
|
import { UploadToaster } from './features/storage/uploads/UploadToaster';
|
|
17
18
|
import './features/sentry/initSentry';
|
|
@@ -136,10 +137,13 @@ const App = () => {
|
|
|
136
137
|
<I18nProvider>
|
|
137
138
|
<DialogProvider>
|
|
138
139
|
<SonnerProvider>
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
<ChromeActionsProvider>
|
|
141
|
+
{/* Toaster + upload progress live at Shellui root so they survive navigation. */}
|
|
142
|
+
<Toaster />
|
|
143
|
+
<UploadToaster />
|
|
144
|
+
<ChromeActionsHost />
|
|
145
|
+
<AppContent />
|
|
146
|
+
</ChromeActionsProvider>
|
|
143
147
|
</SonnerProvider>
|
|
144
148
|
</DialogProvider>
|
|
145
149
|
</I18nProvider>
|
|
@@ -73,6 +73,11 @@ interface ContentViewProps {
|
|
|
73
73
|
pathPrefix: string;
|
|
74
74
|
ignoreMessages?: boolean;
|
|
75
75
|
navItem: NavigationItem;
|
|
76
|
+
/**
|
|
77
|
+
* When true (default), this iframe is a main layout content frame and receives
|
|
78
|
+
* floating layout-chrome insets. Modal / drawer / picker frames set false.
|
|
79
|
+
*/
|
|
80
|
+
layoutChrome?: boolean;
|
|
76
81
|
}
|
|
77
82
|
|
|
78
83
|
export const ContentView = ({
|
|
@@ -80,6 +85,7 @@ export const ContentView = ({
|
|
|
80
85
|
pathPrefix,
|
|
81
86
|
ignoreMessages = false,
|
|
82
87
|
navItem,
|
|
88
|
+
layoutChrome = true,
|
|
83
89
|
}: ContentViewProps) => {
|
|
84
90
|
const navigate = useNavigate();
|
|
85
91
|
const location = useLocation();
|
|
@@ -91,11 +97,9 @@ export const ContentView = ({
|
|
|
91
97
|
const skipInitialShellSyncRef = useRef(true);
|
|
92
98
|
const prevNavPathRef = useRef(navItem?.path ?? '');
|
|
93
99
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
return true;
|
|
98
|
-
});
|
|
100
|
+
// Always start covered: remounts (e.g. /layout → /) create a fresh iframe that would
|
|
101
|
+
// otherwise flash blank/white at opacity 1 before SHELLUI_INITIALIZED.
|
|
102
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
99
103
|
|
|
100
104
|
const [iframeUrl, setIframeUrl] = useState(url);
|
|
101
105
|
/** Bumped only when the iframe element must remount (nav item / app change). */
|
|
@@ -156,6 +160,8 @@ export const ContentView = ({
|
|
|
156
160
|
if (iframe && isSameOriginAsNavItem(url, navItem) && replaceIframeLocation(iframe, url)) {
|
|
157
161
|
// Do not update the src prop — React would re-navigate the iframe and can
|
|
158
162
|
// push a joint session-history entry, wiping intermediate shell routes.
|
|
163
|
+
// Loading stays as-is: same-document (e.g. hash) hops do not re-send
|
|
164
|
+
// SHELLUI_INITIALIZED, and blanking for the fallback timeout would feel stuck.
|
|
159
165
|
return;
|
|
160
166
|
}
|
|
161
167
|
|
|
@@ -354,6 +360,7 @@ export const ContentView = ({
|
|
|
354
360
|
src={iframeUrl}
|
|
355
361
|
key={`${navItem?.path ?? ''}:${frameGeneration}`}
|
|
356
362
|
loading="eager"
|
|
363
|
+
data-shellui-frame={layoutChrome ? 'main' : 'overlay'}
|
|
357
364
|
style={{
|
|
358
365
|
width: '100%',
|
|
359
366
|
height: '100%',
|
|
@@ -114,7 +114,7 @@ const AlertDialogFooter = ({ className, ...props }: HTMLAttributes<HTMLDivElemen
|
|
|
114
114
|
className={cn(
|
|
115
115
|
'flex w-full min-w-full flex-col-reverse max-sm:gap-2 sm:flex-row sm:justify-end sm:space-x-2',
|
|
116
116
|
'-mb-6 mt-2 border-t border-border bg-muted/50 px-6 py-3 rounded-b-xl sm:rounded-b-lg',
|
|
117
|
-
'[&_button]:h-8 [&_button]:text-xs [&_button]:px-3',
|
|
117
|
+
'[&_button]:h-8 [&_button]:min-w-[80px] [&_button]:text-xs [&_button]:px-3',
|
|
118
118
|
'group-data-[size=sm]:flex-row group-data-[size=sm]:gap-2',
|
|
119
119
|
'group-data-[size=sm]:[&>*:not(:only-child)]:min-w-0 group-data-[size=sm]:[&>*:not(:only-child)]:flex-1',
|
|
120
120
|
className,
|
|
@@ -74,7 +74,11 @@ const DialogContent = forwardRef<ElementRef<typeof DialogPrimitive.Content>, Dia
|
|
|
74
74
|
>[0],
|
|
75
75
|
) => {
|
|
76
76
|
const target = event?.target as Element | null;
|
|
77
|
-
if (
|
|
77
|
+
if (
|
|
78
|
+
target?.closest?.(
|
|
79
|
+
'[data-sonner-toaster], [data-upload-toast], [data-shellui-chrome-actions]',
|
|
80
|
+
)
|
|
81
|
+
) {
|
|
78
82
|
event.preventDefault();
|
|
79
83
|
}
|
|
80
84
|
onPointerDownOutside?.(event);
|
|
@@ -1,9 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
forwardRef,
|
|
3
|
+
type ComponentPropsWithoutRef,
|
|
4
|
+
type ElementRef,
|
|
5
|
+
type PointerEvent as ReactPointerEvent,
|
|
6
|
+
} from 'react';
|
|
2
7
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
3
8
|
import { cn } from '../../lib/utils';
|
|
4
9
|
import { Z_INDEX } from '../../lib/z-index';
|
|
5
10
|
|
|
6
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Default `modal={false}`: Radix modal menus set `pointer-events: none` on `body`,
|
|
13
|
+
* which breaks Apple Pencil (and sometimes fine touch) on iPad — items never get
|
|
14
|
+
* a `click` / `onSelect`. Non-modal matches LoginButton and Radix #1027.
|
|
15
|
+
*/
|
|
16
|
+
function DropdownMenu({
|
|
17
|
+
modal = false,
|
|
18
|
+
...props
|
|
19
|
+
}: ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Root>) {
|
|
20
|
+
return (
|
|
21
|
+
<DropdownMenuPrimitive.Root
|
|
22
|
+
modal={modal}
|
|
23
|
+
{...props}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
7
27
|
|
|
8
28
|
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
9
29
|
|
|
@@ -39,17 +59,32 @@ const DropdownMenuContent = forwardRef<
|
|
|
39
59
|
));
|
|
40
60
|
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
41
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Pencil taps often never synthesize a `click` under Radix layers (same class of
|
|
64
|
+
* bug as dialog close / toast actions). Fire click on pointerdown for pen only.
|
|
65
|
+
*/
|
|
66
|
+
function handlePenPointerDown(
|
|
67
|
+
e: ReactPointerEvent<HTMLDivElement>,
|
|
68
|
+
onPointerDown?: (event: ReactPointerEvent<HTMLDivElement>) => void,
|
|
69
|
+
) {
|
|
70
|
+
onPointerDown?.(e);
|
|
71
|
+
if (e.defaultPrevented) return;
|
|
72
|
+
if (e.pointerType !== 'pen') return;
|
|
73
|
+
e.currentTarget.click();
|
|
74
|
+
}
|
|
75
|
+
|
|
42
76
|
const DropdownMenuItem = forwardRef<
|
|
43
77
|
ElementRef<typeof DropdownMenuPrimitive.Item>,
|
|
44
78
|
ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item>
|
|
45
|
-
>(({ className, ...props }, ref) => (
|
|
79
|
+
>(({ className, onPointerDown, ...props }, ref) => (
|
|
46
80
|
<DropdownMenuPrimitive.Item
|
|
47
81
|
ref={ref}
|
|
48
82
|
className={cn(
|
|
49
|
-
'relative flex items-center gap-2 cursor-pointer select-none rounded-sm px-2 py-1.5 text-sm outline-none transition-colors',
|
|
83
|
+
'relative flex items-center gap-2 cursor-pointer select-none rounded-sm px-2 py-1.5 text-sm outline-none transition-colors [touch-action:manipulation]',
|
|
50
84
|
'focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50',
|
|
51
85
|
className,
|
|
52
86
|
)}
|
|
87
|
+
onPointerDown={(e) => handlePenPointerDown(e, onPointerDown)}
|
|
53
88
|
{...props}
|
|
54
89
|
/>
|
|
55
90
|
));
|
|
@@ -12,7 +12,7 @@ import { cn } from '../../lib/utils';
|
|
|
12
12
|
import { Z_INDEX } from '../../lib/z-index';
|
|
13
13
|
|
|
14
14
|
const PORTALED_OVERLAY_SELECTOR =
|
|
15
|
-
'[data-dropdown-menu-content], [data-auth-menu-content], [data-sonner-toaster], [data-upload-toast]';
|
|
15
|
+
'[data-dropdown-menu-content], [data-auth-menu-content], [data-sonner-toaster], [data-upload-toast], [data-shellui-chrome-actions]';
|
|
16
16
|
|
|
17
17
|
function isPortaledOverlayTarget(target: EventTarget | null): boolean {
|
|
18
18
|
const element = target instanceof Element ? target : (target as Node | null)?.parentElement;
|
|
@@ -236,7 +236,7 @@ function SidebarProvider({
|
|
|
236
236
|
className={cn(
|
|
237
237
|
// #root owns the screen height (see index.html); fill it rather than
|
|
238
238
|
// re-deriving it from a viewport unit.
|
|
239
|
-
'group/sidebar-wrapper flex h-full min-h-0 w-full has-data-[variant=inset]:bg-
|
|
239
|
+
'group/sidebar-wrapper flex h-full min-h-0 w-full has-data-[variant=inset]:bg-shellui-inset-chrome',
|
|
240
240
|
className,
|
|
241
241
|
)}
|
|
242
242
|
{...props}
|
|
@@ -332,9 +332,12 @@ function Sidebar({
|
|
|
332
332
|
'relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear group-data-[resizing]/sidebar-wrapper:transition-none',
|
|
333
333
|
'group-data-[collapsible=offcanvas]:w-0',
|
|
334
334
|
'group-data-[side=right]:rotate-180',
|
|
335
|
-
variant === 'floating'
|
|
335
|
+
variant === 'floating'
|
|
336
336
|
? 'group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]'
|
|
337
|
-
: '
|
|
337
|
+
: variant === 'inset'
|
|
338
|
+
? // Collapsed: only left chrome pad — inset ml provides the gap before the card (keeps L/R even).
|
|
339
|
+
'group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(3)))]'
|
|
340
|
+
: 'group-data-[collapsible=icon]:w-(--sidebar-width-icon)',
|
|
338
341
|
)}
|
|
339
342
|
/>
|
|
340
343
|
<div
|
|
@@ -345,9 +348,12 @@ function Sidebar({
|
|
|
345
348
|
? 'left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]'
|
|
346
349
|
: 'right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]',
|
|
347
350
|
// Adjust the padding for floating and inset variants.
|
|
348
|
-
variant === 'floating'
|
|
351
|
+
variant === 'floating'
|
|
349
352
|
? 'p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]'
|
|
350
|
-
:
|
|
353
|
+
: variant === 'inset'
|
|
354
|
+
? // Expanded: pad all sides. Collapsed: drop right pad so card ml-3 matches right gutter.
|
|
355
|
+
'p-3 group-data-[collapsible=icon]:pr-0 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(3)))]'
|
|
356
|
+
: 'group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l',
|
|
351
357
|
className,
|
|
352
358
|
)}
|
|
353
359
|
{...props}
|
|
@@ -355,7 +361,11 @@ function Sidebar({
|
|
|
355
361
|
<div
|
|
356
362
|
data-sidebar="sidebar"
|
|
357
363
|
data-slot="sidebar-inner"
|
|
358
|
-
className=
|
|
364
|
+
className={cn(
|
|
365
|
+
'flex h-full w-full flex-col bg-sidebar',
|
|
366
|
+
'group-data-[variant=inset]:bg-transparent',
|
|
367
|
+
'group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow-sm',
|
|
368
|
+
)}
|
|
359
369
|
>
|
|
360
370
|
{children}
|
|
361
371
|
</div>
|
|
@@ -391,7 +401,17 @@ function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<t
|
|
|
391
401
|
);
|
|
392
402
|
}
|
|
393
403
|
|
|
394
|
-
function SidebarRail({
|
|
404
|
+
function SidebarRail({
|
|
405
|
+
className,
|
|
406
|
+
placement = 'sidebar',
|
|
407
|
+
side: sideProp = 'left',
|
|
408
|
+
...props
|
|
409
|
+
}: React.ComponentProps<'button'> & {
|
|
410
|
+
/** Where the rail attaches. `inset` sits on the main frame edge (sidebar-inset layout). */
|
|
411
|
+
placement?: 'sidebar' | 'inset';
|
|
412
|
+
/** Used when `placement="inset"` (no `[data-side]` ancestor). */
|
|
413
|
+
side?: 'left' | 'right';
|
|
414
|
+
}) {
|
|
395
415
|
const { toggleSidebar, state, width, setWidth, setIsResizing } = useSidebar();
|
|
396
416
|
const dragRef = React.useRef<{
|
|
397
417
|
startX: number;
|
|
@@ -403,21 +423,24 @@ function SidebarRail({ className, ...props }: React.ComponentProps<'button'>) {
|
|
|
403
423
|
const widthRef = React.useRef(width);
|
|
404
424
|
widthRef.current = width;
|
|
405
425
|
|
|
426
|
+
const resolveSide = (event: React.PointerEvent<HTMLButtonElement>): 'left' | 'right' => {
|
|
427
|
+
if (placement === 'inset') return sideProp;
|
|
428
|
+
return (event.currentTarget.closest('[data-side]') as HTMLElement | null)?.dataset.side ===
|
|
429
|
+
'right'
|
|
430
|
+
? 'right'
|
|
431
|
+
: 'left';
|
|
432
|
+
};
|
|
433
|
+
|
|
406
434
|
const onPointerDown = (event: React.PointerEvent<HTMLButtonElement>) => {
|
|
407
435
|
if (event.button !== 0) return;
|
|
408
436
|
// Collapsed rail keeps click-to-expand; only resize when expanded.
|
|
409
437
|
if (state !== 'expanded') return;
|
|
410
438
|
|
|
411
|
-
const side =
|
|
412
|
-
(event.currentTarget.closest('[data-side]') as HTMLElement | null)?.dataset.side === 'right'
|
|
413
|
-
? 'right'
|
|
414
|
-
: 'left';
|
|
415
|
-
|
|
416
439
|
didDragRef.current = false;
|
|
417
440
|
dragRef.current = {
|
|
418
441
|
startX: event.clientX,
|
|
419
442
|
startWidth: width,
|
|
420
|
-
side,
|
|
443
|
+
side: resolveSide(event),
|
|
421
444
|
pointerId: event.pointerId,
|
|
422
445
|
};
|
|
423
446
|
setIsResizing(true);
|
|
@@ -462,6 +485,7 @@ function SidebarRail({ className, ...props }: React.ComponentProps<'button'>) {
|
|
|
462
485
|
data-sidebar="rail"
|
|
463
486
|
data-slot="sidebar-rail"
|
|
464
487
|
data-shellui-no-drag=""
|
|
488
|
+
data-placement={placement}
|
|
465
489
|
aria-label={state === 'expanded' ? 'Resize Sidebar' : 'Toggle Sidebar'}
|
|
466
490
|
tabIndex={-1}
|
|
467
491
|
title={state === 'expanded' ? 'Drag to resize' : 'Toggle Sidebar'}
|
|
@@ -478,12 +502,25 @@ function SidebarRail({ className, ...props }: React.ComponentProps<'button'>) {
|
|
|
478
502
|
onPointerUp={endDrag}
|
|
479
503
|
onPointerCancel={endDrag}
|
|
480
504
|
className={cn(
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
505
|
+
placement === 'inset'
|
|
506
|
+
? cn(
|
|
507
|
+
// Sit on the inset frame edge so the hover line follows the rounded card,
|
|
508
|
+
// instead of cutting through the chrome gap from the sidebar.
|
|
509
|
+
'absolute inset-y-0 z-20 hidden w-3 md:flex',
|
|
510
|
+
sideProp === 'left' ? 'left-0 cursor-col-resize' : 'right-0 cursor-col-resize',
|
|
511
|
+
'after:absolute after:inset-y-0 after:w-[2px] hover:after:bg-border',
|
|
512
|
+
sideProp === 'left' ? 'after:left-0' : 'after:right-0',
|
|
513
|
+
state === 'collapsed' &&
|
|
514
|
+
(sideProp === 'left' ? 'cursor-e-resize' : 'cursor-w-resize'),
|
|
515
|
+
)
|
|
516
|
+
: cn(
|
|
517
|
+
'absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex',
|
|
518
|
+
'in-data-[side=left]:cursor-col-resize in-data-[side=right]:cursor-col-resize',
|
|
519
|
+
'[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize',
|
|
520
|
+
'group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar',
|
|
521
|
+
'[[data-side=left][data-collapsible=offcanvas]_&]:-right-2',
|
|
522
|
+
'[[data-side=right][data-collapsible=offcanvas]_&]:-left-2',
|
|
523
|
+
),
|
|
487
524
|
className,
|
|
488
525
|
)}
|
|
489
526
|
{...props}
|
|
@@ -497,7 +534,10 @@ function SidebarInset({ className, ...props }: React.ComponentProps<'main'>) {
|
|
|
497
534
|
data-slot="sidebar-inset"
|
|
498
535
|
className={cn(
|
|
499
536
|
'relative flex w-full flex-1 flex-col bg-background',
|
|
500
|
-
|
|
537
|
+
// Inset layout: float the main frame on a darkened chrome tray (desktop).
|
|
538
|
+
// Mobile inset rounding lives on the content card in SidebarLayout so the
|
|
539
|
+
// header can sit on the chrome tray above a radiused iframe frame.
|
|
540
|
+
'md:peer-data-[variant=inset]:m-3 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-2xl md:peer-data-[variant=inset]:border md:peer-data-[variant=inset]:border-border md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-3',
|
|
501
541
|
className,
|
|
502
542
|
)}
|
|
503
543
|
{...props}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { forwardRef, type ComponentPropsWithoutRef, type ElementRef } from 'react';
|
|
2
|
+
import * as TabsPrimitive from '@radix-ui/react-tabs';
|
|
3
|
+
import { cn } from '../../lib/utils';
|
|
4
|
+
|
|
5
|
+
const Tabs = TabsPrimitive.Root;
|
|
6
|
+
|
|
7
|
+
const TabsList = forwardRef<
|
|
8
|
+
ElementRef<typeof TabsPrimitive.List>,
|
|
9
|
+
ComponentPropsWithoutRef<typeof TabsPrimitive.List>
|
|
10
|
+
>(({ className, ...props }, ref) => (
|
|
11
|
+
<TabsPrimitive.List
|
|
12
|
+
ref={ref}
|
|
13
|
+
className={cn(
|
|
14
|
+
'inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground',
|
|
15
|
+
className,
|
|
16
|
+
)}
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
19
|
+
));
|
|
20
|
+
TabsList.displayName = TabsPrimitive.List.displayName;
|
|
21
|
+
|
|
22
|
+
const TabsTrigger = forwardRef<
|
|
23
|
+
ElementRef<typeof TabsPrimitive.Trigger>,
|
|
24
|
+
ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
|
|
25
|
+
>(({ className, ...props }, ref) => (
|
|
26
|
+
<TabsPrimitive.Trigger
|
|
27
|
+
ref={ref}
|
|
28
|
+
className={cn(
|
|
29
|
+
'inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm',
|
|
30
|
+
className,
|
|
31
|
+
)}
|
|
32
|
+
{...props}
|
|
33
|
+
/>
|
|
34
|
+
));
|
|
35
|
+
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
|
36
|
+
|
|
37
|
+
const TabsContent = forwardRef<
|
|
38
|
+
ElementRef<typeof TabsPrimitive.Content>,
|
|
39
|
+
ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
|
|
40
|
+
>(({ className, ...props }, ref) => (
|
|
41
|
+
<TabsPrimitive.Content
|
|
42
|
+
ref={ref}
|
|
43
|
+
className={cn(
|
|
44
|
+
'mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
|
|
45
|
+
className,
|
|
46
|
+
)}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
));
|
|
50
|
+
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
|
51
|
+
|
|
52
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent };
|
package/src/constants/urls.ts
CHANGED
|
@@ -49,6 +49,8 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
|
|
|
49
49
|
const sessionRef = useRef<AuthSession | null>(null);
|
|
50
50
|
sessionRef.current = session;
|
|
51
51
|
const refreshInFlightRef = useRef(false);
|
|
52
|
+
/** Bumps on every preferences sync so a slower older PUT can’t overwrite a newer theme. */
|
|
53
|
+
const preferencesSyncGenRef = useRef(0);
|
|
52
54
|
|
|
53
55
|
useEffect(() => {
|
|
54
56
|
let cancelled = false;
|
|
@@ -356,24 +358,33 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
|
|
|
356
358
|
|
|
357
359
|
const syncUserPreferences = useCallback(
|
|
358
360
|
async (preferences: UserPreferences) => {
|
|
361
|
+
const gen = ++preferencesSyncGenRef.current;
|
|
362
|
+
const sessionAtStart = sessionRef.current;
|
|
359
363
|
try {
|
|
360
|
-
await backend.syncUserPreferences(
|
|
364
|
+
await backend.syncUserPreferences(sessionAtStart, preferences);
|
|
365
|
+
// A newer appearance change started another sync — drop this result.
|
|
366
|
+
if (gen !== preferencesSyncGenRef.current) return;
|
|
367
|
+
|
|
361
368
|
const now = Math.floor(Date.now() / 1000);
|
|
362
369
|
let nextSession: AuthSession | null = null;
|
|
363
370
|
try {
|
|
364
|
-
if (
|
|
371
|
+
if (sessionAtStart && isTokenAutoRefreshDisabled()) {
|
|
365
372
|
logger.info(
|
|
366
373
|
'Skipped token refresh after preferences sync because Develop → Disable token auto-refresh is on',
|
|
367
374
|
);
|
|
368
375
|
nextSession = null;
|
|
369
376
|
} else {
|
|
370
|
-
nextSession =
|
|
377
|
+
nextSession = sessionAtStart
|
|
378
|
+
? await backend.refreshAuthSession(sessionAtStart, now)
|
|
379
|
+
: null;
|
|
371
380
|
}
|
|
372
381
|
} catch (refreshErr) {
|
|
373
382
|
logger.error('Failed to refresh auth session after syncing preferences', { refreshErr });
|
|
374
383
|
}
|
|
375
|
-
if (
|
|
376
|
-
|
|
384
|
+
if (gen !== preferencesSyncGenRef.current) return;
|
|
385
|
+
|
|
386
|
+
if (!nextSession && sessionAtStart) {
|
|
387
|
+
nextSession = { ...sessionAtStart, userPreferences: preferences };
|
|
377
388
|
}
|
|
378
389
|
if (nextSession) {
|
|
379
390
|
// Keep stored snapshot aligned with what we synced (JWT claims can lag the PUT).
|
|
@@ -387,7 +398,7 @@ export const AuthProvider = ({ children }: { children: ReactNode }) => {
|
|
|
387
398
|
logger.error('Failed to sync user preferences to auth provider metadata', { err });
|
|
388
399
|
}
|
|
389
400
|
},
|
|
390
|
-
[backend
|
|
401
|
+
[backend],
|
|
391
402
|
);
|
|
392
403
|
|
|
393
404
|
const loadUserPreferences = useCallback(async () => {
|