@selvajs/ui 6.6.0-beta.5 → 6.6.0-beta.7

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 (44) hide show
  1. package/dist/components/ErrorScreen.svelte +1 -1
  2. package/dist/components/compute/AppLayout.svelte +69 -29
  3. package/dist/components/compute/AppLayout.svelte.d.ts +5 -0
  4. package/dist/components/compute/ComputeApp.svelte +1 -0
  5. package/dist/components/layout/AppShell.svelte +10 -6
  6. package/dist/components/layout/PageHeader.svelte +11 -7
  7. package/dist/components/layout/SectionHeader.svelte +4 -2
  8. package/dist/components/layout/SideNav.svelte +19 -11
  9. package/dist/components/preview/ChartOutput.svelte +7 -3
  10. package/dist/components/preview/ImageOutput.svelte +1 -1
  11. package/dist/components/preview/OutputDisplay.svelte +1 -1
  12. package/dist/components/primitives/DataTable.svelte +38 -4
  13. package/dist/components/primitives/DataTable.svelte.d.ts +2 -0
  14. package/dist/components/primitives/alert-dialog/alert-dialog-content.svelte +1 -1
  15. package/dist/components/primitives/dialog/dialog-content.svelte +1 -1
  16. package/dist/components/primitives/drawer/Drawer.svelte +1 -1
  17. package/dist/components/viewer/MeshMetadataPanel.svelte +119 -0
  18. package/dist/components/viewer/MeshMetadataPanel.svelte.d.ts +9 -0
  19. package/dist/components/viewer/Viewer.svelte +59 -24
  20. package/dist/styles/base.css +21 -1
  21. package/dist/utils/loadScript.d.ts +2 -0
  22. package/dist/utils/loadScript.js +2 -0
  23. package/package.json +9 -9
  24. package/src/lib/components/ErrorScreen.svelte +1 -1
  25. package/src/lib/components/compute/AppLayout.svelte +69 -29
  26. package/src/lib/components/compute/ComputeApp.svelte +1 -0
  27. package/src/lib/components/layout/AppShell.svelte +10 -6
  28. package/src/lib/components/layout/PageHeader.svelte +11 -7
  29. package/src/lib/components/layout/SectionHeader.svelte +4 -2
  30. package/src/lib/components/layout/SideNav.svelte +19 -11
  31. package/src/lib/components/preview/ChartOutput.svelte +7 -3
  32. package/src/lib/components/preview/ImageOutput.svelte +1 -1
  33. package/src/lib/components/preview/OutputDisplay.svelte +1 -1
  34. package/src/lib/components/primitives/DataTable.svelte +38 -4
  35. package/src/lib/components/primitives/alert-dialog/alert-dialog-content.svelte +1 -1
  36. package/src/lib/components/primitives/dialog/dialog-content.svelte +1 -1
  37. package/src/lib/components/primitives/drawer/Drawer.svelte +1 -1
  38. package/src/lib/components/viewer/MeshMetadataPanel.svelte +119 -0
  39. package/src/lib/components/viewer/Viewer.svelte +59 -24
  40. package/src/lib/styles/base.css +21 -1
  41. package/src/lib/utils/loadScript.ts +3 -0
  42. package/dist/components/viewer/MeshMetadataDialog.svelte +0 -126
  43. package/dist/components/viewer/MeshMetadataDialog.svelte.d.ts +0 -10
  44. package/src/lib/components/viewer/MeshMetadataDialog.svelte +0 -126
@@ -18,7 +18,9 @@
18
18
  }: SectionHeaderProps = $props();
19
19
  </script>
20
20
 
21
- <div class={`mb-6 gap-5 flex items-start justify-between ${className}`}>
21
+ <div
22
+ class={`mb-6 gap-3 sm:gap-5 sm:flex-row sm:items-start sm:justify-between flex flex-col ${className}`}
23
+ >
22
24
  <div class="min-w-0">
23
25
  {#if eyebrow}
24
26
  <div class="mb-1.5 text-xs font-medium tracking-wider text-muted-foreground uppercase">
@@ -31,7 +33,7 @@
31
33
  {/if}
32
34
  </div>
33
35
  {#if actions}
34
- <div class="gap-2 flex shrink-0 items-center">
36
+ <div class="gap-2 flex shrink-0 flex-wrap items-center">
35
37
  {@render actions()}
36
38
  </div>
37
39
  {/if}
@@ -43,13 +43,15 @@
43
43
  }
44
44
  </script>
45
45
 
46
+ <!-- On a phone a 240px column would leave the page ~150px, so the nav becomes a scrolling strip
47
+ above the content and the eyebrow, header and footer drop out. -->
46
48
  <aside
47
- class={`w-60 flex h-full shrink-0 flex-col overflow-y-auto bg-background ${
48
- border ? 'border-r border-border' : ''
49
+ class={`sm:h-full sm:w-60 sm:overflow-y-auto sm:border-b-0 flex w-full shrink-0 flex-col border-b border-border bg-background ${
50
+ border ? 'sm:border-r' : ''
49
51
  } ${className}`}
50
52
  >
51
53
  {#if eyebrow}
52
- <div class="px-4 pt-5 pb-3">
54
+ <div class="px-4 pt-5 pb-3 sm:block hidden">
53
55
  <span class="text-xs font-medium tracking-wider text-muted-foreground uppercase">
54
56
  {eyebrow}
55
57
  </span>
@@ -57,30 +59,36 @@
57
59
  {/if}
58
60
 
59
61
  {#if header}
60
- <div class="px-3 pb-3">
62
+ <div class="px-3 pb-3 sm:block hidden">
61
63
  {@render header()}
62
64
  </div>
63
65
  {/if}
64
66
 
65
- <nav class="pb-4 pr-2 flex-1 space-y-px">
67
+ <nav
68
+ class="gap-1 py-2 sm:gap-0 sm:pt-0 sm:pb-4 sm:pr-2 sm:flex-1 sm:space-y-px sm:block sm:px-0 flex overflow-x-auto px-(--page-px)"
69
+ >
66
70
  {#each items as item (item.href)}
67
71
  {@const active = isActive(item)}
68
72
  {@const Icon = item.icon}
69
73
  <a
70
74
  href={item.href}
71
- class={`group gap-2 py-1.5 pr-2.5 relative flex w-full items-center text-left transition-colors ${
75
+ class={`group gap-2 py-2 pr-2.5 sm:py-1.5 sm:w-full relative flex shrink-0 items-center text-left transition-colors ${
72
76
  active
73
- ? 'pl-4 rounded-r-md bg-accent text-accent-foreground'
74
- : 'mx-2 pl-2.5 rounded-md text-muted-foreground hover:bg-muted/60 hover:text-foreground'
77
+ ? 'pl-2.5 sm:pl-4 sm:rounded-l-none sm:rounded-r-md rounded-md bg-accent text-accent-foreground'
78
+ : 'sm:mx-2 pl-2.5 rounded-md text-muted-foreground hover:bg-muted/60 hover:text-foreground'
75
79
  }`}
76
80
  >
77
81
  {#if active}
78
- <span class="left-0 top-0 bottom-0 w-0.75 absolute bg-primary" aria-hidden="true"></span>
82
+ <span
83
+ class="left-0 top-0 bottom-0 w-0.75 sm:block absolute hidden bg-primary"
84
+ aria-hidden="true"
85
+ ></span>
79
86
  {/if}
80
87
  {#if Icon}
81
88
  <Icon class="h-3.5 w-3.5 shrink-0 opacity-70" />
82
89
  {/if}
83
- <span class="text-sm font-medium flex-1 truncate">{item.label}</span>
90
+ <span class="text-sm font-medium sm:flex-1 sm:truncate whitespace-nowrap">{item.label}</span
91
+ >
84
92
  {#if item.badge !== undefined}
85
93
  <span class="font-mono shrink-0 text-2xs tabular-nums opacity-60">{item.badge}</span>
86
94
  {/if}
@@ -89,7 +97,7 @@
89
97
  </nav>
90
98
 
91
99
  {#if footer}
92
- <div class="px-3 py-3 border-t border-border/60">
100
+ <div class="px-3 py-3 sm:block hidden border-t border-border/60">
93
101
  {@render footer()}
94
102
  </div>
95
103
  {/if}
@@ -45,7 +45,11 @@
45
45
  // @ts-expect-error — Plotly is loaded dynamically onto window
46
46
  if (window.Plotly) return window.Plotly;
47
47
 
48
- await loadScript('https://cdn.plot.ly/plotly-3.4.0.min.js', { crossOrigin: 'anonymous' });
48
+ // Pinned by hash: the plugin's web UI runs this on the origin that holds its bridge secret.
49
+ await loadScript('https://cdn.plot.ly/plotly-3.4.0.min.js', {
50
+ crossOrigin: 'anonymous',
51
+ integrity: 'sha384-pFOQ7loGBChmUyS4Tszy+he8OWeYkwTFjc2xii4aJUWWiGwf2u2OEc04T5iDRpMp'
52
+ });
49
53
  // @ts-expect-error — Plotly is loaded dynamically onto window
50
54
  return window.Plotly;
51
55
  }
@@ -192,10 +196,10 @@
192
196
  <!-- The layout hides this output while it has no data, so this is data that doesn't parse yet. -->
193
197
  <div class="px-4 py-8 text-sm text-center text-muted-foreground">{t.chartReceiving}</div>
194
198
  {:else}
195
- <div bind:this={containerEl} class="w-full {isFullscreen ? 'h-screen' : 'h-95'}"></div>
199
+ <div bind:this={containerEl} class="w-full {isFullscreen ? 'h-dvh' : 'h-95'}"></div>
196
200
 
197
201
  <div
198
- class="gap-1 left-2 top-2 absolute z-10 flex items-center opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100 {isFullscreen
202
+ class="gap-1 left-2 top-2 absolute z-10 flex items-center opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100 pointer-coarse:opacity-100 {isFullscreen
199
203
  ? 'opacity-100'
200
204
  : ''}"
201
205
  >
@@ -302,7 +302,7 @@
302
302
  <div
303
303
  bind:this={wrapperEl}
304
304
  class="rounded flex flex-col overflow-hidden border border-border bg-background {isFullscreen
305
- ? 'h-screen'
305
+ ? 'h-dvh'
306
306
  : ''}"
307
307
  >
308
308
  {#if error}
@@ -318,7 +318,7 @@
318
318
  <div
319
319
  class="right-2 top-2 absolute transition-opacity {copied
320
320
  ? 'opacity-100'
321
- : 'opacity-0 group-hover:opacity-100 focus-within:opacity-100'}"
321
+ : 'opacity-0 group-hover:opacity-100 focus-within:opacity-100 pointer-coarse:opacity-100'}"
322
322
  >
323
323
  <Button onclick={copyToClipboard} size="sm">
324
324
  {copied ? t.copied : t.copy}
@@ -3,6 +3,8 @@
3
3
  label: string;
4
4
  width?: string;
5
5
  align?: 'left' | 'right';
6
+ /** Drop the column below 640px, where fixed widths would crush the flexible one. */
7
+ hideOnMobile?: boolean;
6
8
  }
7
9
  </script>
8
10
 
@@ -19,20 +21,52 @@
19
21
 
20
22
  let { rows, columns, getKey, row, class: className = '' }: Props = $props();
21
23
 
22
- const gridTemplate = $derived(columns.map((c) => c.width ?? '1fr').join(' '));
24
+ // `minmax(0, …)` so a long name truncates rather than widening its row past the others.
25
+ const toTemplate = (cols: DataTableColumn[]) =>
26
+ cols.map((c) => c.width ?? 'minmax(0, 1fr)').join(' ');
27
+ const gridTemplate = $derived(toTemplate(columns));
28
+ const mobileTemplate = $derived(toTemplate(columns.filter((c) => !c.hideOnMobile)));
29
+ // Cells come from the caller's snippet, so they're hidden by position.
30
+ const hiddenCols = $derived(
31
+ columns
32
+ .map((c, i) => (c.hideOnMobile ? `hide-col-${i + 1}` : ''))
33
+ .filter(Boolean)
34
+ .join(' ')
35
+ );
23
36
  </script>
24
37
 
25
- <div class={`divide-y rounded-lg border ${className}`} style:--table-cols={gridTemplate}>
38
+ <div
39
+ class={`divide-y rounded-lg border ${className}`}
40
+ style:--table-cols={gridTemplate}
41
+ style:--table-cols-sm={mobileTemplate}
42
+ >
26
43
  <div
27
- class="gap-4 px-4 py-2 text-xs font-medium tracking-wide grid grid-cols-(--table-cols) bg-muted/40 text-muted-foreground uppercase"
44
+ class="data-table-row gap-4 px-4 py-2 text-xs font-medium tracking-wide sm:grid-cols-(--table-cols) grid grid-cols-(--table-cols-sm) bg-muted/40 text-muted-foreground uppercase {hiddenCols}"
28
45
  >
29
46
  {#each columns as col (col.label)}
30
47
  <span class={col.align === 'right' ? 'text-right' : ''}>{col.label}</span>
31
48
  {/each}
32
49
  </div>
33
50
  {#each rows as item (getKey(item))}
34
- <div class="gap-4 px-4 py-3 grid grid-cols-(--table-cols) items-center">
51
+ <div
52
+ class="data-table-row gap-4 px-4 py-3 sm:grid-cols-(--table-cols) grid grid-cols-(--table-cols-sm) items-center {hiddenCols}"
53
+ >
35
54
  {@render row(item)}
36
55
  </div>
37
56
  {/each}
38
57
  </div>
58
+
59
+ <style>
60
+ @media (max-width: 639px) {
61
+ :global(.data-table-row.hide-col-1 > :nth-child(1)),
62
+ :global(.data-table-row.hide-col-2 > :nth-child(2)),
63
+ :global(.data-table-row.hide-col-3 > :nth-child(3)),
64
+ :global(.data-table-row.hide-col-4 > :nth-child(4)),
65
+ :global(.data-table-row.hide-col-5 > :nth-child(5)),
66
+ :global(.data-table-row.hide-col-6 > :nth-child(6)),
67
+ :global(.data-table-row.hide-col-7 > :nth-child(7)),
68
+ :global(.data-table-row.hide-col-8 > :nth-child(8)) {
69
+ display: none;
70
+ }
71
+ }
72
+ </style>
@@ -19,7 +19,7 @@
19
19
  bind:ref
20
20
  data-slot="alert-dialog-content"
21
21
  class={cn(
22
- 'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 gap-4 p-6 shadow-lg sm:max-w-lg fixed start-1/2 top-1/2 z-50 grid w-full max-w-screen-inset -translate-x-1/2 -translate-y-1/2 rounded-lg border bg-background duration-200',
22
+ 'data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 gap-4 p-6 shadow-lg sm:max-w-lg fixed start-1/2 top-1/2 z-50 grid max-h-dialog w-screen-inset -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-lg border bg-background duration-200',
23
23
  className
24
24
  )}
25
25
  {...restProps}
@@ -32,7 +32,7 @@
32
32
  data-slot="dialog-content"
33
33
  class={cn(
34
34
  variant === 'flush' ? 'gap-0' : 'gap-4 p-6',
35
- 'shadow-lg data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg fixed top-1/2 left-1/2 z-50 grid max-h-dialog w-full max-w-screen-inset -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-lg border bg-background duration-200',
35
+ 'shadow-lg data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg fixed top-1/2 left-1/2 z-50 grid max-h-dialog w-screen-inset -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-lg border bg-background duration-200',
36
36
  className
37
37
  )}
38
38
  {...restProps}
@@ -26,7 +26,7 @@
26
26
  onkeydown={handleKey}
27
27
  ></div>
28
28
  <div
29
- class="animate-in slide-in-from-right-4 top-0 right-0 fixed z-50 flex h-full border-border bg-background {width} flex-col overflow-y-auto border-l duration-150"
29
+ class="animate-in slide-in-from-right-4 top-0 right-0 fixed z-50 flex h-full max-w-full border-border bg-background {width} flex-col overflow-y-auto border-l duration-150"
30
30
  >
31
31
  {@render children()}
32
32
  </div>
@@ -0,0 +1,119 @@
1
+ <script lang="ts">
2
+ import { X } from '@lucide/svelte';
3
+ import { Button } from '../primitives/button/index.js';
4
+ import { getLocaleContext } from '$lib/i18n/localeContext.svelte';
5
+
6
+ const locale = getLocaleContext();
7
+ const t = $derived(locale.messages);
8
+
9
+ interface Props {
10
+ metadata: Record<string, any>;
11
+ meshName: string | null;
12
+ onClose: () => void;
13
+ class?: string;
14
+ }
15
+
16
+ const EXCLUDED_KEYS = new Set(['name', 'layer', 'id']);
17
+
18
+ let { metadata, meshName, onClose, class: className = '' }: Props = $props();
19
+
20
+ const filteredMetadata = $derived.by(() => {
21
+ const result: Record<string, unknown> = {};
22
+ for (const [key, value] of Object.entries(metadata)) {
23
+ if (EXCLUDED_KEYS.has(key)) continue;
24
+ if (
25
+ key === 'metadata' &&
26
+ typeof value === 'object' &&
27
+ value !== null &&
28
+ !Array.isArray(value)
29
+ ) {
30
+ Object.assign(result, value);
31
+ } else {
32
+ result[key] = value;
33
+ }
34
+ }
35
+ return result;
36
+ });
37
+ </script>
38
+
39
+ <!-- Not a modal: a modal locks the page, and on touch the tap that should dismiss it can race the
40
+ dialog's own dismiss handler, leaving the viewer frozen. A card lets the canvas keep orbiting. -->
41
+ <section
42
+ aria-label={meshName ?? t.objectFallbackName}
43
+ class="min-h-0 shadow-lg backdrop-blur-sm flex flex-col overflow-hidden rounded-lg border bg-background/95 {className}"
44
+ >
45
+ <header class="gap-2 py-1 pr-1 pl-4 flex items-center border-b">
46
+ <h2 class="text-sm font-semibold min-w-0 flex-1 truncate">
47
+ {meshName ?? t.objectFallbackName}
48
+ </h2>
49
+ <Button
50
+ variant="ghost"
51
+ size="icon-sm"
52
+ class="pointer-coarse:size-10 shrink-0"
53
+ aria-label={t.close}
54
+ title={t.close}
55
+ onclick={onClose}
56
+ >
57
+ <X />
58
+ </Button>
59
+ </header>
60
+
61
+ <div class="min-h-0 overflow-y-auto overscroll-contain">
62
+ {#if Object.keys(filteredMetadata).length === 0}
63
+ <p class="px-4 py-3 text-xs text-muted-foreground">{t.noMetadata}</p>
64
+ {:else}
65
+ <table class="text-xs w-full border-collapse">
66
+ <tbody>
67
+ {#each Object.entries(filteredMetadata) as [key, value] (key)}
68
+ <tr class="border-b border-border/60 last:border-b-0">
69
+ <th
70
+ scope="row"
71
+ class="px-4 py-2 font-normal text-left align-top whitespace-nowrap text-muted-foreground"
72
+ >{key}</th
73
+ >
74
+ <td class="px-4 py-2 text-right align-top text-foreground">
75
+ {#if typeof value === 'object' && value !== null}
76
+ {#if Array.isArray(value)}
77
+ <div class="space-y-1 text-left">
78
+ {#each value as item, index (index)}
79
+ {#if typeof item === 'object'}
80
+ <div class="space-y-0.5">
81
+ {#each Object.entries(item) as [k, v] (k)}
82
+ <div class="gap-2 flex">
83
+ <span class="shrink-0 text-muted-foreground">{k}:</span>
84
+ <span>{v}</span>
85
+ </div>
86
+ {/each}
87
+ </div>
88
+ {:else}
89
+ <div>{item}</div>
90
+ {/if}
91
+ {/each}
92
+ </div>
93
+ {:else}
94
+ <div class="space-y-0.5 text-left">
95
+ {#each Object.entries(value) as [k, v] (k)}
96
+ <div class="gap-2 flex">
97
+ <span class="shrink-0 text-muted-foreground">{k}:</span>
98
+ <span>{v}</span>
99
+ </div>
100
+ {/each}
101
+ </div>
102
+ {/if}
103
+ {:else if typeof value === 'number'}
104
+ <span class="font-mono">{value}</span>
105
+ {:else if typeof value === 'boolean'}
106
+ <span class={value ? 'text-success' : 'text-muted-foreground'}
107
+ >{value ? 'true' : 'false'}</span
108
+ >
109
+ {:else}
110
+ <span class="break-all">{value}</span>
111
+ {/if}
112
+ </td>
113
+ </tr>
114
+ {/each}
115
+ </tbody>
116
+ </table>
117
+ {/if}
118
+ </div>
119
+ </section>
@@ -34,7 +34,7 @@
34
34
  import type { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js';
35
35
  import { createSceneOutliner, type SceneOutliner } from '@selvajs/visualization/scene';
36
36
  import SceneManager from './SceneManager.svelte';
37
- import MeshMetadataDialog from './MeshMetadataDialog.svelte';
37
+ import MeshMetadataPanel from './MeshMetadataPanel.svelte';
38
38
  import * as Resizable from '$lib/components/primitives/resizable/index.js';
39
39
  import * as DropdownMenu from '$lib/components/primitives/dropdown-menu/index.js';
40
40
  import { Button } from '$lib/components/primitives/button/index.js';
@@ -122,6 +122,7 @@
122
122
  let updateGridScale: (() => void) | null = null;
123
123
  let updateShadowBounds: (() => void) | null = null;
124
124
  let fitToView: (() => void) | null = null;
125
+ let clearSelection: (() => void) | null = null;
125
126
  let viewerInitialized = false;
126
127
  let sceneVersion = $state(0);
127
128
  let hideButton = $state(false);
@@ -194,6 +195,10 @@
194
195
  grid: { enabled: config.showToolsMenu && config.showGridToggle },
195
196
  measure: { enabled: config.showToolsMenu },
196
197
  events: {
198
+ // Fires before onMeshMetadataClicked, so picking an object without metadata closes the
199
+ // previous object's panel instead of leaving it describing the wrong thing.
200
+ onObjectSelected: closeMetadata,
201
+ onBackgroundClicked: closeMetadata,
197
202
  onMeshMetadataClicked: config.enableMeshClick
198
203
  ? (metadata: Record<string, unknown>) => {
199
204
  if (hasUsefulMetadata(metadata)) {
@@ -224,6 +229,7 @@
224
229
  updateGridScale = init.updateGridScale;
225
230
  updateShadowBounds = init.updateShadowBounds;
226
231
  fitToView = init.fitToView;
232
+ clearSelection = init.clearSelection;
227
233
  projection = init.cameraController.getProjection();
228
234
 
229
235
  const renderer = init.renderer;
@@ -375,6 +381,29 @@
375
381
  }
376
382
  });
377
383
 
384
+ function closeMetadata() {
385
+ selectedMeshMetadata = null;
386
+ selectedMeshName = null;
387
+ }
388
+
389
+ function dismissMetadata() {
390
+ closeMetadata();
391
+ clearSelection?.();
392
+ invalidate?.();
393
+ }
394
+
395
+ // The panel describes an object from the previous solve once new meshes arrive.
396
+ $effect(() => {
397
+ void meshes;
398
+ untrack(closeMetadata);
399
+ });
400
+
401
+ // Dialogs portal to <body>, so one opened over the fullscreen viewer needs lifting above it.
402
+ $effect(() => {
403
+ document.body.toggleAttribute('data-viewer-fullscreen', isFullscreen);
404
+ return () => document.body.removeAttribute('data-viewer-fullscreen');
405
+ });
406
+
378
407
  function toggleFullscreen() {
379
408
  isFullscreen = !isFullscreen;
380
409
  }
@@ -450,12 +479,9 @@
450
479
  {/if}
451
480
 
452
481
  {#if logoUrl}
453
- <!-- Bottom offset matches the tools menu so it clears the mobile drawer handle.
454
- Always pointer-events:none so it never intercepts canvas drags. -->
482
+ <!-- pointer-events:none so it never intercepts canvas drags. -->
455
483
  <div
456
- class="right-4 {isFullscreen
457
- ? 'bottom-4'
458
- : 'bottom-16 sm:bottom-4'} pointer-events-none absolute z-20 {hideButton
484
+ class="right-4 bottom-4 pointer-events-none absolute z-20 {hideButton
459
485
  ? 'opacity-0'
460
486
  : ''}"
461
487
  >
@@ -467,11 +493,18 @@
467
493
  </div>
468
494
  {/if}
469
495
 
496
+ {#if selectedMeshMetadata}
497
+ <MeshMetadataPanel
498
+ metadata={selectedMeshMetadata}
499
+ meshName={selectedMeshName}
500
+ onClose={dismissMetadata}
501
+ class="top-3 right-3 left-3 sm:right-auto sm:max-h-2/3 sm:w-72 absolute z-30 max-h-1/2"
502
+ />
503
+ {/if}
504
+
470
505
  {#if config.showToolsMenu}
471
506
  <div
472
- class="left-4 {isFullscreen
473
- ? 'bottom-4'
474
- : 'bottom-16 sm:bottom-4'} shadow-lg absolute z-50 flex items-center rounded-lg {hideButton
507
+ class="left-4 bottom-4 gap-2 *:shadow-lg absolute z-50 flex items-center *:rounded-md {hideButton
475
508
  ? 'pointer-events-none opacity-0'
476
509
  : ''}"
477
510
  >
@@ -594,6 +627,18 @@
594
627
  {/if}
595
628
  </DropdownMenu.Content>
596
629
  </DropdownMenu.Root>
630
+ <!-- Touch has no F key, and fit-to-view is the way back from a framed part. -->
631
+ <div class="hidden pointer-coarse:block">
632
+ <Button
633
+ variant="outline"
634
+ size="icon-lg"
635
+ title={t.fitToView}
636
+ aria-label={t.fitToView}
637
+ onclick={() => fitToView?.()}
638
+ >
639
+ <Frame />
640
+ </Button>
641
+ </div>
597
642
  </div>
598
643
  {/if}
599
644
  </div>
@@ -608,22 +653,12 @@
608
653
  </Resizable.PaneGroup>
609
654
  </div>
610
655
 
611
- <MeshMetadataDialog
612
- open={selectedMeshMetadata !== null}
613
- metadata={selectedMeshMetadata}
614
- meshName={selectedMeshName}
615
- {isFullscreen}
616
- onOpenChange={(open: boolean) => {
617
- if (!open) {
618
- setTimeout(() => {
619
- selectedMeshMetadata = null;
620
- selectedMeshName = null;
621
- }, 200);
622
- }
623
- }}
624
- />
625
-
626
656
  <style>
657
+ :global([data-viewer-fullscreen] [data-slot='dialog-content']),
658
+ :global([data-viewer-fullscreen] [data-slot='dialog-overlay']) {
659
+ z-index: 10001;
660
+ }
661
+
627
662
  .fullscreen-viewer {
628
663
  position: fixed;
629
664
  inset: 0;
@@ -3,7 +3,7 @@
3
3
  :root {
4
4
  --radius: 0.625rem;
5
5
  --header-h: 3.5rem;
6
- --page-px: 1.5rem;
6
+ --page-px: 1rem;
7
7
  --page-py: 1.75rem;
8
8
  --background: oklch(0.99 0 0);
9
9
  --foreground: oklch(0.22 0 0);
@@ -180,6 +180,26 @@
180
180
  border-radius: inherit;
181
181
  }
182
182
 
183
+ /* Phones keep a narrower gutter: at 390px every 8px of side padding is 2% of the width. */
184
+ @media (min-width: 40rem) {
185
+ :root {
186
+ --page-px: 1.5rem;
187
+ }
188
+ }
189
+
190
+ /* A native select draws its arrow inside the right padding, so with the `px-2`/`px-3` every
191
+ caller uses it sits on the border. A drawn chevron with its own gutter fixes them all. Unlayered
192
+ on purpose: the gutter has to beat the callers' `px-*` utilities. Mid-grey reads on both themes,
193
+ since a data URI can't take `currentColor`. */
194
+ select:not([multiple]):not([size]) {
195
+ appearance: none;
196
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
197
+ background-repeat: no-repeat;
198
+ background-position: right 0.625rem center;
199
+ background-size: 1.1em;
200
+ padding-inline-end: calc(1.1em + 1rem);
201
+ }
202
+
183
203
  @layer base {
184
204
  * {
185
205
  @apply border-border outline-ring;
@@ -8,6 +8,8 @@ export function loadScript(
8
8
  src: string,
9
9
  options?: {
10
10
  crossOrigin?: string;
11
+ /** Subresource Integrity hash. A cross-origin script also needs `crossOrigin`. */
12
+ integrity?: string;
11
13
  async?: boolean;
12
14
  defer?: boolean;
13
15
  }
@@ -26,6 +28,7 @@ export function loadScript(
26
28
  const script = document.createElement('script');
27
29
  script.src = src;
28
30
  if (options?.crossOrigin) script.crossOrigin = options.crossOrigin;
31
+ if (options?.integrity) script.integrity = options.integrity;
29
32
  if (options?.async !== undefined) script.async = options.async;
30
33
  if (options?.defer !== undefined) script.defer = options.defer;
31
34