@shellui/core 0.5.0-alpha.4 → 0.5.0-beta.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.
- package/package.json +2 -2
- package/schemas/shellui.config.schema.json +33 -0
- package/src/components/ContentView.tsx +1 -1
- package/src/components/ui/alert-dialog.tsx +51 -34
- package/src/components/ui/drawer.tsx +57 -40
- package/src/components/ui/sidebar.tsx +11 -4
- package/src/components/ui/sonner.tsx +20 -2
- package/src/features/alertDialog/DialogContext.tsx +11 -5
- package/src/features/auth/components/AccessPendingView.tsx +1 -1
- package/src/features/auth/components/LoginButton.tsx +3 -3
- package/src/features/auth/components/LoginView.tsx +5 -4
- package/src/features/config/types.ts +31 -0
- package/src/features/layouts/LayoutFallback.tsx +1 -1
- package/src/features/layouts/OverlayShell.tsx +76 -44
- package/src/features/layouts/appbar/AppBarLayout.tsx +473 -291
- package/src/features/layouts/chrome/viewport.ts +66 -0
- package/src/features/layouts/fullscreen/FullscreenLayout.tsx +1 -1
- package/src/features/layouts/sidebar/SidebarInner.tsx +1 -1
- package/src/features/layouts/sidebar/SidebarLayout.tsx +110 -38
- package/src/features/layouts/windows/WindowsLayout.tsx +138 -42
- package/src/features/overlays/ResponsiveModal.tsx +36 -17
- package/src/features/overlays/overlaySize.spec.ts +27 -1
- package/src/features/overlays/overlaySize.ts +73 -18
- package/src/features/overlays/useOverlayReportedSize.ts +5 -4
- package/src/features/settings/SettingsView.tsx +9 -2
- package/src/features/settings/utils/buildSettingsForPropagation.spec.ts +26 -0
- package/src/features/settings/utils/buildSettingsForPropagation.ts +15 -0
- package/src/features/storage/uploads/UploadToastCard.tsx +1 -1
- package/src/features/storage/uploads/UploadToaster.tsx +6 -3
- package/src/features/theme/applyTheme.ts +20 -1
- package/src/i18n/translations/en/common.json +2 -1
- package/src/i18n/translations/fr/common.json +2 -1
- package/src/index.css +168 -12
- package/src/index.html +32 -3
- package/src/index.ts +1 -0
- package/src/routes/components/RouteErrorBoundary.tsx +1 -1
- package/src/routes/components/RouteFallback.tsx +1 -1
|
@@ -303,12 +303,15 @@ export function ResponsiveModal({
|
|
|
303
303
|
}
|
|
304
304
|
}, []);
|
|
305
305
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
306
|
+
// Fresh open always starts at rest (clears any mid-dismiss translate)
|
|
307
|
+
useEffect(() => {
|
|
308
|
+
if (open) {
|
|
309
|
+
dragStartY.current = null;
|
|
310
|
+
dragCurrentY.current = 0;
|
|
311
|
+
setSheetDragOffset(0);
|
|
312
|
+
setIsSheetDragging(false);
|
|
313
|
+
}
|
|
314
|
+
}, [open]);
|
|
312
315
|
|
|
313
316
|
const handleSheetPointerDown = useCallback(
|
|
314
317
|
(e: ReactPointerEvent<HTMLDivElement>) => {
|
|
@@ -339,20 +342,29 @@ export function ResponsiveModal({
|
|
|
339
342
|
const delta = dragCurrentY.current;
|
|
340
343
|
const height = contentRef.current?.offsetHeight ?? window.innerHeight;
|
|
341
344
|
const shouldDismiss = delta >= SWIPE_DISMISS_PX || delta >= height * SWIPE_DISMISS_RATIO;
|
|
342
|
-
|
|
345
|
+
|
|
346
|
+
dragStartY.current = null;
|
|
347
|
+
dragCurrentY.current = 0;
|
|
348
|
+
setIsSheetDragging(false);
|
|
349
|
+
|
|
343
350
|
if (shouldDismiss && dismissible) {
|
|
351
|
+
// Keep the dragged translate and continue off-screen — no snap-back before close
|
|
352
|
+
setSheetDragOffset(Math.max(delta, height));
|
|
344
353
|
onOpenChange(false);
|
|
354
|
+
return;
|
|
345
355
|
}
|
|
356
|
+
|
|
357
|
+
// Not far enough — ease back to rest from the dragged position
|
|
358
|
+
setSheetDragOffset(0);
|
|
346
359
|
},
|
|
347
|
-
[dismissible, onOpenChange
|
|
360
|
+
[dismissible, onOpenChange],
|
|
348
361
|
);
|
|
349
362
|
|
|
350
363
|
const canMove = movable && !isSheet;
|
|
351
364
|
const canResize = resizable && !isSheet;
|
|
352
365
|
const hasCustomGeometry = !isSheet && geometry !== null;
|
|
353
366
|
|
|
354
|
-
const
|
|
355
|
-
isSheet && sheetDragOffset > 0 ? `translateY(${sheetDragOffset}px)` : undefined;
|
|
367
|
+
const sheetExitTransition = 'transform 0.28s cubic-bezier(0.32, 0.72, 0, 1)';
|
|
356
368
|
|
|
357
369
|
const geometryStyle: CSSProperties | undefined = hasCustomGeometry
|
|
358
370
|
? {
|
|
@@ -384,17 +396,17 @@ export function ResponsiveModal({
|
|
|
384
396
|
className={cn(
|
|
385
397
|
'gap-0 p-0 overflow-hidden flex flex-col',
|
|
386
398
|
isSheet
|
|
387
|
-
? 'left-0 right-0 top-auto bottom-0 max-w-none w-full translate-x-0 translate-y-0 rounded-t-xl rounded-b-none border-x-0 border-b-0'
|
|
399
|
+
? 'left-0 right-0 top-auto bottom-0 max-w-none w-full translate-x-0 translate-y-0 rounded-t-xl rounded-b-none border-x-0 border-b-0 pb-[var(--shellui-safe-area-bottom)]'
|
|
388
400
|
: cn('rounded-lg', hasCustomGeometry && 'translate-x-0 translate-y-0 max-w-none'),
|
|
389
401
|
className,
|
|
390
402
|
)}
|
|
391
403
|
style={{
|
|
392
404
|
...style,
|
|
393
405
|
...geometryStyle,
|
|
394
|
-
...(
|
|
406
|
+
...(isSheet
|
|
395
407
|
? {
|
|
396
|
-
transform:
|
|
397
|
-
transition: isSheetDragging ? 'none' :
|
|
408
|
+
transform: `translateY(${sheetDragOffset}px)`,
|
|
409
|
+
transition: isSheetDragging ? 'none' : sheetExitTransition,
|
|
398
410
|
}
|
|
399
411
|
: {}),
|
|
400
412
|
...((isSheetDragging || isWindowInteracting) && { transition: 'none' }),
|
|
@@ -451,15 +463,22 @@ export function ResponsiveModal({
|
|
|
451
463
|
{isSheet && showDragHandle && dismissible && (
|
|
452
464
|
<div
|
|
453
465
|
data-responsive-modal-handle
|
|
454
|
-
className="pointer-events-none absolute inset-x-0 top-0 z-20 flex touch-none items-
|
|
466
|
+
className="pointer-events-none absolute inset-x-0 top-0 z-20 flex touch-none items-start justify-center bg-transparent"
|
|
455
467
|
role="presentation"
|
|
456
468
|
>
|
|
469
|
+
{/* Centered tall hit target only — rest of the strip is click-through */}
|
|
457
470
|
<div
|
|
458
|
-
className="pointer-events-auto h-1.5 w-
|
|
471
|
+
className="pointer-events-auto relative h-11 w-28 shrink-0 cursor-grab touch-none active:cursor-grabbing after:absolute after:left-1/2 after:top-1.5 after:h-[3px] after:w-8 after:-translate-x-1/2 after:rounded-full after:bg-muted-foreground/70 after:content-['']"
|
|
459
472
|
onPointerDown={handleSheetPointerDown}
|
|
460
473
|
onPointerMove={handleSheetPointerMove}
|
|
461
474
|
onPointerUp={handleSheetPointerUp}
|
|
462
|
-
onPointerCancel={
|
|
475
|
+
onPointerCancel={() => {
|
|
476
|
+
// Cancel mid-drag — ease back to rest (not a dismiss)
|
|
477
|
+
dragStartY.current = null;
|
|
478
|
+
dragCurrentY.current = 0;
|
|
479
|
+
setIsSheetDragging(false);
|
|
480
|
+
setSheetDragOffset(0);
|
|
481
|
+
}}
|
|
463
482
|
/>
|
|
464
483
|
</div>
|
|
465
484
|
)}
|
|
@@ -6,6 +6,8 @@ import {
|
|
|
6
6
|
resolveDialogSize,
|
|
7
7
|
resolveDismissOptions,
|
|
8
8
|
resolveDrawerSize,
|
|
9
|
+
resolveDrawerSizeForViewport,
|
|
10
|
+
resolveEffectiveDrawerPosition,
|
|
9
11
|
toCssLength,
|
|
10
12
|
} from './overlaySize';
|
|
11
13
|
|
|
@@ -50,10 +52,34 @@ describe('overlaySize', () => {
|
|
|
50
52
|
});
|
|
51
53
|
|
|
52
54
|
it('resolves drawer presets by direction', () => {
|
|
53
|
-
expect(resolveDrawerSize({ size: 'sm' }, 'bottom').drawerSize).toBe(
|
|
55
|
+
expect(resolveDrawerSize({ size: 'sm' }, 'bottom').drawerSize).toBe(
|
|
56
|
+
'calc(var(--shellui-overlay-max-height) * 0.4)',
|
|
57
|
+
);
|
|
54
58
|
expect(resolveDrawerSize({ size: 'sm' }, 'left').drawerSize).toBe('20rem');
|
|
55
59
|
});
|
|
56
60
|
|
|
61
|
+
it('forces bottom position on mobile', () => {
|
|
62
|
+
expect(resolveEffectiveDrawerPosition('right', true)).toBe('bottom');
|
|
63
|
+
expect(resolveEffectiveDrawerPosition('left', true)).toBe('bottom');
|
|
64
|
+
expect(resolveEffectiveDrawerPosition('top', true)).toBe('bottom');
|
|
65
|
+
expect(resolveEffectiveDrawerPosition('bottom', true)).toBe('bottom');
|
|
66
|
+
expect(resolveEffectiveDrawerPosition('right', false)).toBe('right');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('remaps horizontal freeform size to default height on mobile', () => {
|
|
70
|
+
const desktop = resolveDrawerSizeForViewport({ size: '60vw' }, 'right', false);
|
|
71
|
+
expect(desktop.drawerSize).toBe('60vw');
|
|
72
|
+
|
|
73
|
+
const mobile = resolveDrawerSizeForViewport({ size: '60vw' }, 'right', true);
|
|
74
|
+
expect(mobile.drawerSize).toBe('calc(var(--shellui-overlay-max-height) * 0.8)');
|
|
75
|
+
|
|
76
|
+
const preset = resolveDrawerSizeForViewport({ size: 'md' }, 'right', true);
|
|
77
|
+
expect(preset.drawerSize).toBe('calc(var(--shellui-overlay-max-height) * 0.55)');
|
|
78
|
+
|
|
79
|
+
const fromTop = resolveDrawerSizeForViewport({ size: '60vh' }, 'top', true);
|
|
80
|
+
expect(fromTop.drawerSize).toBe('60vh');
|
|
81
|
+
});
|
|
82
|
+
|
|
57
83
|
it('defaults dismiss options', () => {
|
|
58
84
|
expect(resolveDismissOptions(null)).toEqual({
|
|
59
85
|
showCloseButton: true,
|
|
@@ -6,6 +6,14 @@ import type {
|
|
|
6
6
|
DrawerPosition,
|
|
7
7
|
} from '@shellui/sdk';
|
|
8
8
|
|
|
9
|
+
/** CSS max-height for overlays — matches --shellui-overlay-max-height in index.css. */
|
|
10
|
+
const OVERLAY_MAX_HEIGHT_CSS = 'var(--shellui-overlay-max-height)';
|
|
11
|
+
|
|
12
|
+
/** Fraction of overlay max height — avoids raw dvh which disagrees with iOS standalone measure. */
|
|
13
|
+
function overlayHeightFrac(fraction: number): string {
|
|
14
|
+
return `calc(${OVERLAY_MAX_HEIGHT_CSS} * ${fraction})`;
|
|
15
|
+
}
|
|
16
|
+
|
|
9
17
|
const PRESETS = new Set<string>(['sm', 'md', 'lg', 'xl', 'full', 'content']);
|
|
10
18
|
|
|
11
19
|
/**
|
|
@@ -38,48 +46,49 @@ export function toCssLength(value: string | number | undefined): string | undefi
|
|
|
38
46
|
|
|
39
47
|
/** Dialog (desktop/tablet modal) preset → class + inline style hints.
|
|
40
48
|
* Width uses `calc(100vw - …)` gutters so tablets never edge-to-edge;
|
|
41
|
-
* `max-w-*` still caps size on large desktops.
|
|
49
|
+
* `max-w-*` still caps size on large desktops.
|
|
50
|
+
* Heights derive from `--shellui-overlay-max-height` (not raw dvh). */
|
|
42
51
|
const DIALOG_PRESET: Record<
|
|
43
52
|
OverlaySizePreset,
|
|
44
53
|
{ className: string; style?: CSSProperties; contentSized?: boolean }
|
|
45
54
|
> = {
|
|
46
55
|
sm: {
|
|
47
56
|
className:
|
|
48
|
-
'max-w-sm w-[min(24rem,calc(100vw-3rem))] h-[min(
|
|
57
|
+
'max-w-sm w-[min(24rem,calc(100vw-3rem))] h-[min(calc(var(--shellui-overlay-max-height)*0.5),24rem)] max-h-[min(calc(var(--shellui-overlay-max-height)*0.7),28rem)] rounded-lg',
|
|
49
58
|
},
|
|
50
59
|
md: {
|
|
51
60
|
className:
|
|
52
|
-
'max-w-lg w-[min(32rem,calc(100vw-4rem))] h-[min(
|
|
61
|
+
'max-w-lg w-[min(32rem,calc(100vw-4rem))] h-[min(calc(var(--shellui-overlay-max-height)*0.6),32rem)] max-h-[min(calc(var(--shellui-overlay-max-height)*0.75),36rem)] rounded-lg',
|
|
53
62
|
},
|
|
54
63
|
lg: {
|
|
55
64
|
// Wider than the 768px mobile breakpoint so iframe apps keep desktop UI
|
|
56
65
|
className:
|
|
57
|
-
'max-w-4xl w-[min(56rem,calc(100vw-5rem))] h-[min(
|
|
66
|
+
'max-w-4xl w-[min(56rem,calc(100vw-5rem))] h-[min(calc(var(--shellui-overlay-max-height)*0.8),42.5rem)] max-h-[min(calc(var(--shellui-overlay-max-height)*0.8),42.5rem)] rounded-lg',
|
|
58
67
|
},
|
|
59
68
|
xl: {
|
|
60
69
|
className:
|
|
61
|
-
'max-w-6xl w-[min(72rem,calc(100vw-5rem))] h-[min(
|
|
70
|
+
'max-w-6xl w-[min(72rem,calc(100vw-5rem))] h-[min(calc(var(--shellui-overlay-max-height)*0.85),50rem)] max-h-[min(calc(var(--shellui-overlay-max-height)*0.85),50rem)] rounded-lg',
|
|
62
71
|
},
|
|
63
72
|
full: {
|
|
64
73
|
className:
|
|
65
|
-
'max-w-[calc(100vw-2.5rem)] w-[calc(100vw-2.5rem)] h-[
|
|
74
|
+
'max-w-[calc(100vw-2.5rem)] w-[calc(100vw-2.5rem)] h-[var(--shellui-overlay-max-height)] max-h-[var(--shellui-overlay-max-height)] rounded-lg',
|
|
66
75
|
},
|
|
67
76
|
content: {
|
|
68
77
|
// Width comes from SHELLUI_OVERLAY_SIZE; max-w only caps. Avoid forcing 56rem
|
|
69
78
|
// (that caused reflow: narrow measure → tall report → wide chrome → shorter report).
|
|
70
79
|
className: 'max-w-4xl w-max rounded-lg',
|
|
71
|
-
style: { height: 'auto', width: 'auto', maxHeight:
|
|
80
|
+
style: { height: 'auto', width: 'auto', maxHeight: OVERLAY_MAX_HEIGHT_CSS },
|
|
72
81
|
contentSized: true,
|
|
73
82
|
},
|
|
74
83
|
};
|
|
75
84
|
|
|
76
85
|
/** Drawer primary dimension presets (height for top/bottom, width for left/right). */
|
|
77
86
|
const DRAWER_PRESET_VERTICAL: Record<OverlaySizePreset, string> = {
|
|
78
|
-
sm:
|
|
79
|
-
md:
|
|
80
|
-
lg:
|
|
81
|
-
xl:
|
|
82
|
-
full:
|
|
87
|
+
sm: overlayHeightFrac(0.4),
|
|
88
|
+
md: overlayHeightFrac(0.55),
|
|
89
|
+
lg: overlayHeightFrac(0.75),
|
|
90
|
+
xl: overlayHeightFrac(0.9),
|
|
91
|
+
full: OVERLAY_MAX_HEIGHT_CSS,
|
|
83
92
|
content: 'auto',
|
|
84
93
|
};
|
|
85
94
|
|
|
@@ -92,6 +101,8 @@ const DRAWER_PRESET_HORIZONTAL: Record<OverlaySizePreset, string> = {
|
|
|
92
101
|
content: 'auto',
|
|
93
102
|
};
|
|
94
103
|
|
|
104
|
+
const DEFAULT_VERTICAL_DRAWER = overlayHeightFrac(0.8);
|
|
105
|
+
|
|
95
106
|
export interface ResolvedOverlaySize {
|
|
96
107
|
className: string;
|
|
97
108
|
style: CSSProperties;
|
|
@@ -113,7 +124,7 @@ function applyExplicitDimensions(
|
|
|
113
124
|
if (width) next.width = width;
|
|
114
125
|
if (height) next.height = height;
|
|
115
126
|
if (maxWidth) next.maxWidth = `min(${maxWidth}, 100vw)`;
|
|
116
|
-
if (maxHeight) next.maxHeight = `min(${maxHeight},
|
|
127
|
+
if (maxHeight) next.maxHeight = `min(${maxHeight}, ${OVERLAY_MAX_HEIGHT_CSS})`;
|
|
117
128
|
return next;
|
|
118
129
|
}
|
|
119
130
|
|
|
@@ -139,7 +150,7 @@ export function resolveDialogSize(options?: OverlayOpenOptions | null): Resolved
|
|
|
139
150
|
};
|
|
140
151
|
if (freeform) {
|
|
141
152
|
style.height = freeform;
|
|
142
|
-
style.maxHeight = `min(${freeform},
|
|
153
|
+
style.maxHeight = `min(${freeform}, ${OVERLAY_MAX_HEIGHT_CSS})`;
|
|
143
154
|
}
|
|
144
155
|
style = applyExplicitDimensions(style, options ?? {});
|
|
145
156
|
|
|
@@ -151,9 +162,20 @@ export function resolveDialogSize(options?: OverlayOpenOptions | null): Resolved
|
|
|
151
162
|
};
|
|
152
163
|
}
|
|
153
164
|
|
|
165
|
+
/**
|
|
166
|
+
* On viewports below the mobile breakpoint, every drawer edge presents as a
|
|
167
|
+
* bottom sheet (same chrome as mobile `openModal`).
|
|
168
|
+
*/
|
|
169
|
+
export function resolveEffectiveDrawerPosition(
|
|
170
|
+
position: DrawerPosition = 'right',
|
|
171
|
+
isMobile = false,
|
|
172
|
+
): DrawerPosition {
|
|
173
|
+
return isMobile ? 'bottom' : position;
|
|
174
|
+
}
|
|
175
|
+
|
|
154
176
|
/**
|
|
155
177
|
* Resolve drawer sizing from open options + direction.
|
|
156
|
-
* Default:
|
|
178
|
+
* Default: 80% of overlay max / 80vw (previous 80dvh / 80vw behavior).
|
|
157
179
|
*/
|
|
158
180
|
export function resolveDrawerSize(
|
|
159
181
|
options?: OverlayOpenOptions | null,
|
|
@@ -166,11 +188,11 @@ export function resolveDrawerSize(
|
|
|
166
188
|
|
|
167
189
|
let drawerSize: string;
|
|
168
190
|
if (!size) {
|
|
169
|
-
drawerSize = isVertical ?
|
|
191
|
+
drawerSize = isVertical ? DEFAULT_VERTICAL_DRAWER : '80vw';
|
|
170
192
|
} else if (isOverlaySizePreset(size)) {
|
|
171
193
|
drawerSize = isVertical ? DRAWER_PRESET_VERTICAL[size] : DRAWER_PRESET_HORIZONTAL[size];
|
|
172
194
|
} else {
|
|
173
|
-
drawerSize = toCssLength(size) ?? (isVertical ?
|
|
195
|
+
drawerSize = toCssLength(size) ?? (isVertical ? DEFAULT_VERTICAL_DRAWER : '80vw');
|
|
174
196
|
}
|
|
175
197
|
|
|
176
198
|
let style: CSSProperties = {
|
|
@@ -190,7 +212,7 @@ export function resolveDrawerSize(
|
|
|
190
212
|
if (contentSized) {
|
|
191
213
|
drawerSize = 'auto';
|
|
192
214
|
if (isVertical) {
|
|
193
|
-
style.maxHeight = style.maxHeight ??
|
|
215
|
+
style.maxHeight = style.maxHeight ?? OVERLAY_MAX_HEIGHT_CSS;
|
|
194
216
|
style.height = style.height ?? 'auto';
|
|
195
217
|
} else {
|
|
196
218
|
style.maxWidth = style.maxWidth ?? 'min(90vw, 100%)';
|
|
@@ -206,6 +228,39 @@ export function resolveDrawerSize(
|
|
|
206
228
|
};
|
|
207
229
|
}
|
|
208
230
|
|
|
231
|
+
/**
|
|
232
|
+
* Resolve drawer size for the active viewport.
|
|
233
|
+
* Mobile always uses bottom-sheet chrome; horizontal freeform widths (`60vw`,
|
|
234
|
+
* `400px`, explicit `width`) are dropped so they are not applied as height.
|
|
235
|
+
*/
|
|
236
|
+
export function resolveDrawerSizeForViewport(
|
|
237
|
+
options?: OverlayOpenOptions | null,
|
|
238
|
+
position: DrawerPosition = 'right',
|
|
239
|
+
isMobile = false,
|
|
240
|
+
): ResolvedOverlaySize {
|
|
241
|
+
const effective = resolveEffectiveDrawerPosition(position, isMobile);
|
|
242
|
+
if (!isMobile) {
|
|
243
|
+
return resolveDrawerSize(options, effective);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// left/right → bottom: width-oriented sizes must not become sheet height
|
|
247
|
+
if (position === 'left' || position === 'right') {
|
|
248
|
+
const dynamic = isDynamicSizing(options);
|
|
249
|
+
const size = options?.size;
|
|
250
|
+
const dropFreeformWidth =
|
|
251
|
+
!dynamic && size !== undefined && size !== null && !isOverlaySizePreset(size);
|
|
252
|
+
const nextOptions: OverlayOpenOptions | null | undefined = dropFreeformWidth
|
|
253
|
+
? { ...options, size: undefined, width: undefined }
|
|
254
|
+
: options?.width !== undefined
|
|
255
|
+
? { ...options, width: undefined }
|
|
256
|
+
: options;
|
|
257
|
+
return resolveDrawerSize(nextOptions, 'bottom');
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// top → bottom (or already bottom): keep height-oriented size
|
|
261
|
+
return resolveDrawerSize(options, 'bottom');
|
|
262
|
+
}
|
|
263
|
+
|
|
209
264
|
export type OverlayDismissOptions = {
|
|
210
265
|
showCloseButton: boolean;
|
|
211
266
|
dismissible: boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { shellui, type OverlaySizePayload, type ShellUIMessage } from '@shellui/sdk';
|
|
3
|
+
import { overlayMaxHeightPx, readAppHeightPx } from '../layouts/chrome/viewport';
|
|
3
4
|
|
|
4
5
|
const MIN_CONTENT_HEIGHT = 40;
|
|
5
6
|
const MAX_VIEWPORT_RATIO = 0.92;
|
|
@@ -66,7 +67,9 @@ export function useOverlayReportedSize(enabled: boolean, active: boolean) {
|
|
|
66
67
|
const height = Number(payload?.height);
|
|
67
68
|
if (!Number.isFinite(height) || height <= 0) return;
|
|
68
69
|
|
|
69
|
-
|
|
70
|
+
// Clamp against the shell height (not raw innerHeight / dvh), so standalone
|
|
71
|
+
// iOS overlays cannot outgrow the visible screen.
|
|
72
|
+
const maxH = overlayMaxHeightPx(MAX_VIEWPORT_RATIO);
|
|
70
73
|
const rawH = Math.ceil(height);
|
|
71
74
|
const clampedH = Math.min(Math.max(rawH, MIN_CONTENT_HEIGHT), maxH);
|
|
72
75
|
const wasClamped = rawH > maxH;
|
|
@@ -114,9 +117,7 @@ export function useOverlayReportedSize(enabled: boolean, active: boolean) {
|
|
|
114
117
|
reported ??
|
|
115
118
|
(fallback && enabled
|
|
116
119
|
? {
|
|
117
|
-
height: Math.floor(
|
|
118
|
-
(typeof window !== 'undefined' ? window.innerHeight : 600) * FALLBACK_HEIGHT_RATIO,
|
|
119
|
-
),
|
|
120
|
+
height: Math.floor(readAppHeightPx() * FALLBACK_HEIGHT_RATIO),
|
|
120
121
|
wasClamped: true,
|
|
121
122
|
}
|
|
122
123
|
: null);
|
|
@@ -279,7 +279,7 @@ export const SettingsView = () => {
|
|
|
279
279
|
<header className="flex h-16 shrink-0 items-center justify-center px-4 border-b">
|
|
280
280
|
<h1 className="text-lg font-semibold">{t('title')}</h1>
|
|
281
281
|
</header>
|
|
282
|
-
<div className="flex flex-1 flex-col p-4
|
|
282
|
+
<div className="flex flex-1 flex-col gap-6 p-4 pb-[max(1.5rem,calc(1rem+env(safe-area-inset-bottom,0px)))] pl-[max(1rem,env(safe-area-inset-left,0px))] pr-[max(1rem,env(safe-area-inset-right,0px))]">
|
|
283
283
|
{groupedRoutes.map((group) => (
|
|
284
284
|
<div
|
|
285
285
|
key={group.title}
|
|
@@ -344,7 +344,14 @@ export const SettingsView = () => {
|
|
|
344
344
|
</Button>
|
|
345
345
|
<h1 className="text-lg font-semibold">{selectedItem?.name}</h1>
|
|
346
346
|
</header>
|
|
347
|
-
<div
|
|
347
|
+
<div
|
|
348
|
+
className={cn(
|
|
349
|
+
'flex flex-1 flex-col overflow-hidden',
|
|
350
|
+
selectedItem?.path?.startsWith('app-')
|
|
351
|
+
? 'min-h-0'
|
|
352
|
+
: 'gap-4 overflow-y-auto p-4 pt-4 pb-[max(1.5rem,calc(1rem+env(safe-area-inset-bottom,0px)))] pl-[max(1rem,env(safe-area-inset-left,0px))] pr-[max(1rem,env(safe-area-inset-right,0px))]',
|
|
353
|
+
)}
|
|
354
|
+
>
|
|
348
355
|
<Routes>
|
|
349
356
|
<Route
|
|
350
357
|
index
|
|
@@ -218,4 +218,30 @@ describe('buildSettingsForPropagation', () => {
|
|
|
218
218
|
expect(result.administration).toBeNull();
|
|
219
219
|
expect(result.storage).toBeNull();
|
|
220
220
|
});
|
|
221
|
+
|
|
222
|
+
it('propagates showInAdmin false when hosting admin is disabled', () => {
|
|
223
|
+
const config = {
|
|
224
|
+
hosting: {
|
|
225
|
+
url: 'http://localhost:8002/',
|
|
226
|
+
showInAdmin: false,
|
|
227
|
+
},
|
|
228
|
+
} as ShellUIConfig;
|
|
229
|
+
|
|
230
|
+
const result = buildSettingsForPropagation(baseSettings, config, 'en');
|
|
231
|
+
expect(result.hosting).toEqual({
|
|
232
|
+
url: 'http://localhost:8002',
|
|
233
|
+
showInAdmin: false,
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it('omits showInAdmin from propagated hosting by default', () => {
|
|
238
|
+
const config = {
|
|
239
|
+
hosting: {
|
|
240
|
+
url: 'http://localhost:8002',
|
|
241
|
+
},
|
|
242
|
+
} as ShellUIConfig;
|
|
243
|
+
|
|
244
|
+
const result = buildSettingsForPropagation(baseSettings, config, 'en');
|
|
245
|
+
expect(result.hosting).toEqual({ url: 'http://localhost:8002' });
|
|
246
|
+
});
|
|
221
247
|
});
|
|
@@ -80,6 +80,21 @@ export const buildSettingsForPropagation = (
|
|
|
80
80
|
result = { ...result, storage: null };
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
+
const hostingUrl = config?.hosting?.url?.trim().replace(/\/+$/, '') || null;
|
|
84
|
+
if (hostingUrl) {
|
|
85
|
+
const app = config.hosting?.app?.trim() || null;
|
|
86
|
+
result = {
|
|
87
|
+
...result,
|
|
88
|
+
hosting: {
|
|
89
|
+
url: hostingUrl,
|
|
90
|
+
...(app ? { app } : {}),
|
|
91
|
+
...(config.hosting?.showInAdmin === false ? { showInAdmin: false } : {}),
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
} else {
|
|
95
|
+
result = { ...result, hosting: null };
|
|
96
|
+
}
|
|
97
|
+
|
|
83
98
|
const authBackendBaseUrl =
|
|
84
99
|
config?.backend?.type === 'shellui' && config.backend.url?.trim()
|
|
85
100
|
? config.backend.url.trim().replace(/\/+$/, '')
|
|
@@ -410,7 +410,7 @@ export function UploadToastCard() {
|
|
|
410
410
|
>
|
|
411
411
|
<div className="overflow-hidden">
|
|
412
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">
|
|
413
|
+
<div className="max-h-[min(14rem,calc(var(--shellui-app-height,100dvh)-14rem))] overflow-y-auto overscroll-contain divide-y divide-border">
|
|
414
414
|
{items.map((item) => (
|
|
415
415
|
<FileRow
|
|
416
416
|
key={item.id}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
2
3
|
import { shellui } from '@shellui/sdk';
|
|
3
4
|
import { UploadToastCard } from './UploadToastCard';
|
|
4
5
|
import { startUploadToastDemo, UPLOAD_TOAST_DEMO_MESSAGE, UPLOAD_TOAST_ID } from './uploadQueue';
|
|
@@ -27,15 +28,17 @@ export function UploadToaster() {
|
|
|
27
28
|
|
|
28
29
|
if (!isRoot || items.length === 0) return null;
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
// Portal to body so z-index sits above portaled modals/drawers (same as Sonner).
|
|
32
|
+
return createPortal(
|
|
31
33
|
<div
|
|
32
34
|
id={UPLOAD_TOAST_ID}
|
|
33
|
-
className="pointer-events-none fixed right-
|
|
35
|
+
className="pointer-events-none fixed right-[max(0.75rem,env(safe-area-inset-right,0px))] bottom-[max(5rem,calc(5rem+env(safe-area-inset-bottom,0px)))] md:right-[max(1rem,env(safe-area-inset-right,0px))] md:bottom-[max(1rem,env(safe-area-inset-bottom,0px))]"
|
|
34
36
|
style={{ zIndex: Z_INDEX.TOAST }}
|
|
35
37
|
>
|
|
36
38
|
<div className="pointer-events-auto origin-bottom animate-in fade-in-0 slide-in-from-bottom-2 duration-200">
|
|
37
39
|
<UploadToastCard />
|
|
38
40
|
</div>
|
|
39
|
-
</div
|
|
41
|
+
</div>,
|
|
42
|
+
document.body,
|
|
40
43
|
);
|
|
41
44
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { toCssVarValue } from './color';
|
|
2
2
|
import type { ThemeColorsMode, ThemeDefinition } from './types';
|
|
3
|
-
|
|
4
3
|
const COLOR_VAR_MAP: Array<[keyof ThemeColorsMode, string]> = [
|
|
5
4
|
['background', '--background'],
|
|
6
5
|
['foreground', '--foreground'],
|
|
@@ -36,6 +35,22 @@ const COLOR_VAR_MAP: Array<[keyof ThemeColorsMode, string]> = [
|
|
|
36
35
|
['chart5', '--chart-5'],
|
|
37
36
|
];
|
|
38
37
|
|
|
38
|
+
/** Update <meta name="theme-color"> so PWA / browser chrome matches the active surface. */
|
|
39
|
+
function syncThemeColorMeta(cssColor: string): void {
|
|
40
|
+
if (typeof document === 'undefined' || !cssColor) return;
|
|
41
|
+
const head = document.head || document.getElementsByTagName('head')[0];
|
|
42
|
+
if (!head) return;
|
|
43
|
+
|
|
44
|
+
// Prefer a single unconditional theme-color (iOS reads this; media variants are flaky standalone)
|
|
45
|
+
let meta = head.querySelector<HTMLMetaElement>('meta[name="theme-color"]:not([media])');
|
|
46
|
+
if (!meta) {
|
|
47
|
+
meta = document.createElement('meta');
|
|
48
|
+
meta.setAttribute('name', 'theme-color');
|
|
49
|
+
head.appendChild(meta);
|
|
50
|
+
}
|
|
51
|
+
meta.setAttribute('content', cssColor);
|
|
52
|
+
}
|
|
53
|
+
|
|
39
54
|
/**
|
|
40
55
|
* Apply theme colors to the document.
|
|
41
56
|
* Sets full CSS colors (OKLCH / hex / hsl()) on :root for Tailwind `var(--*)` consumption.
|
|
@@ -61,6 +76,10 @@ export function applyTheme(theme: ThemeDefinition, isDark: boolean): void {
|
|
|
61
76
|
|
|
62
77
|
root.style.setProperty('--radius', colors.radius);
|
|
63
78
|
|
|
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.
|
|
81
|
+
syncThemeColorMeta(toCssVarValue(colors.background) || (isDark ? '#000000' : '#ffffff'));
|
|
82
|
+
|
|
64
83
|
const head = document.head || document.getElementsByTagName('head')[0];
|
|
65
84
|
const existingFontLinks = head.querySelectorAll('link[data-theme-font], style[data-theme-font]');
|
|
66
85
|
existingFontLinks.forEach((link) => link.remove());
|