@spatial-elements/sveltekit 1.0.0-beta.4 → 1.0.0-beta.5

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 (31) hide show
  1. package/README.md +6 -2
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.js +2 -0
  4. package/dist/spatial-element/BrandStageShell.svelte +7 -59
  5. package/dist/spatial-element/BrandStageShell.svelte.d.ts +2 -0
  6. package/dist/spatial-element/CarouselSection.svelte +14 -12
  7. package/dist/spatial-element/CarouselSpatialElement.svelte +2 -1
  8. package/dist/spatial-element/ContentPage.svelte +2 -1
  9. package/dist/spatial-element/SpatialElementCard.svelte +2 -1
  10. package/dist/spatial-element/SpatialElementHelp.svelte +23 -14
  11. package/dist/spatial-element/SpatialElementMediaRail.svelte +2 -1
  12. package/dist/spatial-element/SpatialElementPage.svelte +2 -1
  13. package/dist/spatial-element/SpatialElementSummaryPanel.svelte +27 -8
  14. package/dist/spatial-element/SpatialElementTabs.svelte +2 -1
  15. package/dist/spatial-element/SpatialElementViewToggle.svelte +53 -0
  16. package/dist/spatial-element/SpatialElementViewToggle.svelte.d.ts +8 -0
  17. package/dist/spatial-element/SpatialIconButton.svelte +2 -1
  18. package/dist/spatial-element/brandContext.d.ts +1 -1
  19. package/dist/spatial-element/brandContext.js +1 -1
  20. package/dist/spatial-element/spatialThemeStyle.d.ts +3 -0
  21. package/dist/spatial-element/spatialThemeStyle.js +48 -0
  22. package/dist/stage/ButtonGroup.svelte +163 -0
  23. package/dist/stage/ButtonGroup.svelte.d.ts +24 -0
  24. package/dist/stage/Panel.svelte +24 -9
  25. package/dist/stage/Stage.svelte +52 -3
  26. package/dist/stage/Stage.svelte.d.ts +2 -0
  27. package/dist/stage/authoredStyle.d.ts +4 -0
  28. package/dist/stage/authoredStyle.js +17 -0
  29. package/dist/stage/buttonGroup.d.ts +9 -0
  30. package/dist/stage/buttonGroup.js +1 -0
  31. package/package.json +2 -2
package/README.md CHANGED
@@ -2,7 +2,11 @@
2
2
 
3
3
  SvelteKit components and navigation for Spatial Elements.
4
4
 
5
- Detail pages include a compact 3D help button. Pass optional `messages` to `BrandStageShell` to translate its labels, tooltips and instructions; missing strings use English defaults. See [interface texts and help](https://github.com/LauridBergjohann/spatial-elements/blob/main/docs/interface-texts.md) for the complete typed dictionary and examples.
5
+ Pass a reactive `theme` and optional resolved `colorScheme` (`light` or `dark`) to `BrandStageShell` for live appearance changes. The host owns system preference and persistence. The public `ButtonGroup` component can implement a theme switch, language selector or other choices. See [runtime themes and ButtonGroup](https://github.com/LauridBergjohann/spatial-elements/blob/main/docs/theming.md).
6
+
7
+ Detail pages include 3D help and a detail/fullscreen view switch, with a viewport fallback when native fullscreen is unavailable. Pass optional `messages` to `BrandStageShell` to translate labels, tooltips and instructions, including `controls.detailView` and `controls.fullscreen`; missing strings use English defaults. See [interface texts and help](https://github.com/LauridBergjohann/spatial-elements/blob/main/docs/interface-texts.md) for the complete typed dictionary and examples.
8
+
9
+ The detail button always restores the fitted camera view, including when already on the detail page. Its selected background fades with camera zoom; the fullscreen button remains selected throughout fullscreen navigation.
6
10
 
7
11
  See the [authoring guide](https://github.com/LauridBergjohann/spatial-elements/blob/main/docs/authoring.md) and [development guide](https://github.com/LauridBergjohann/spatial-elements/blob/main/docs/development.md).
8
12
 
@@ -10,7 +14,7 @@ Beta API; MPL-2.0; see LICENSE.
10
14
 
11
15
  Read the [getting-started tutorial](https://github.com/LauridBergjohann/spatial-elements/blob/main/docs/getting-started.md), [API reference](https://github.com/LauridBergjohann/spatial-elements/blob/main/docs/api.md) and [configuration migration](https://github.com/LauridBergjohann/spatial-elements/blob/main/docs/configuration-migration.md).
12
16
 
13
- Element content and required `geometry: { low, high }` belong in `SpatialElementData`; shared appearance belongs in `SpatialTheme`. Use `createSpatialTheme({ id, name })` for defaults. The SvelteKit shell needs only the theme; pages register their own data. These docs target version `1.0.0-beta.3` and newer.
17
+ Element content and required `geometry: { low, high }` belong in `SpatialElementData`; shared appearance belongs in `SpatialTheme`. Use `createSpatialTheme({ id, name })` for defaults. The SvelteKit shell needs only the theme; pages register their own data. These docs target version `1.0.0-beta.5` and newer.
14
18
 
15
19
  Installation:
16
20
 
package/dist/index.d.ts CHANGED
@@ -4,3 +4,6 @@ export { default as Stage } from './stage/Stage.svelte';
4
4
  export { default as StageViewport } from './stage/StageViewport.svelte';
5
5
  export { catalogViewLink } from '@spatial-elements/core';
6
6
  export { default as ScrollNavigationBridge } from './catalog/ScrollNavigationBridge.svelte';
7
+ export { default as ButtonGroup } from './stage/ButtonGroup.svelte';
8
+ export type { ButtonGroupItem } from './stage/buttonGroup.js';
9
+ export { getSpatialThemeStyle } from './spatial-element/spatialThemeStyle.js';
package/dist/index.js CHANGED
@@ -4,3 +4,5 @@ export { default as Stage } from './stage/Stage.svelte';
4
4
  export { default as StageViewport } from './stage/StageViewport.svelte';
5
5
  export { catalogViewLink } from '@spatial-elements/core';
6
6
  export { default as ScrollNavigationBridge } from './catalog/ScrollNavigationBridge.svelte';
7
+ export { default as ButtonGroup } from './stage/ButtonGroup.svelte';
8
+ export { getSpatialThemeStyle } from './spatial-element/spatialThemeStyle.js';
@@ -2,7 +2,7 @@
2
2
  import type { Snippet } from 'svelte';
3
3
  import Stage from '../stage/Stage.svelte';
4
4
  import type { StageRenderSettings } from '@spatial-elements/core';
5
- import { getCssPanelBoxShadow, resolvePanelShadowStrength } from '@spatial-elements/core/stage/panelShadow';
5
+ import { getSpatialThemeStyle } from './spatialThemeStyle.js';
6
6
  import { provideSpatialTheme } from './brandContext.js';
7
7
  import { provideSpatialMessages } from './messagesContext.js';
8
8
  import type { SpatialMessagesInput } from '@spatial-elements/core/spatial-element/messages';
@@ -11,6 +11,8 @@
11
11
  interface Props {
12
12
  /** Shared appearance and namespace. Use createSpatialTheme for defaults. */
13
13
  theme: SpatialTheme;
14
+ /** Resolved by the host. System preference and persistence belong to the shell. */
15
+ colorScheme?: 'light' | 'dark';
14
16
  /** Localized interface copy. Missing groups/strings fall back to English; updates are reactive. */
15
17
  messages?: SpatialMessagesInput;
16
18
  /** Optional GPU resolution budget; defaults to DPR 1 and 2,073,600 pixels. */
@@ -21,75 +23,21 @@
21
23
  children?: Snippet;
22
24
  }
23
25
 
24
- let { theme, messages, renderSettings, dracoDecoderPath, children }: Props = $props();
26
+ let { theme, colorScheme, messages, renderSettings, dracoDecoderPath, children }: Props = $props();
25
27
 
26
28
  provideSpatialTheme(() => theme);
27
29
  provideSpatialMessages(() => messages);
28
30
 
29
- const brandStyle = $derived(
30
- [
31
- `--spatial-element-background: ${theme.background}`,
32
- `--spatial-element-ink: ${theme.colors.ink}`,
33
- `--spatial-element-body: ${theme.colors.body}`,
34
- `--spatial-element-accent: ${theme.colors.accent}`,
35
- `--spatial-element-on-accent: ${theme.colors.onAccent}`,
36
- `--spatial-element-section-tint: ${theme.sectionTheme.tint}`,
37
- `--spatial-element-section-tint-opacity: ${toPercentage(theme.sectionTheme.tintOpacity)}`,
38
- `--spatial-element-section-backdrop-blur: ${Math.max(theme.sectionTheme.backdropBlur, 0)}px`,
39
- `--spatial-element-tab-background: ${theme.colors.tabBackground}`,
40
- `--spatial-element-panel-radius: ${theme.panelShape.radius}px`,
41
- `--spatial-element-docked-panel-tint-rgb: ${getDockedPanelTintRgb(theme.dockedPanelTheme.tint)}`,
42
- `--spatial-element-docked-panel-tint-opacity: ${clamp(theme.dockedPanelTheme.tintOpacity, 0, 1)}`,
43
- `--spatial-element-docked-panel-shadow-intensity: ${clamp(theme.dockedPanelTheme.shadowIntensity, 0, 1)}`,
44
- `--spatial-element-docked-panel-shadow-strength: ${resolvePanelShadowStrength(theme.dockedPanelTheme.shadowIntensity)}`,
45
- `--spatial-element-docked-panel-box-shadow: ${getCssPanelBoxShadow(theme.dockedPanelTheme.shadowIntensity)}`,
46
- `--spatial-element-docked-panel-backdrop-blur: ${Math.min(
47
- Math.max(theme.dockedPanelTheme.backdropBlur, 0),
48
- 100
49
- )}px`
50
- ].join('; ')
51
- );
52
-
53
- function toPercentage(value: number) {
54
- return `${clamp(value, 0, 1) * 100}%`;
55
- }
56
-
57
- function getDockedPanelTintRgb(tint: SpatialTheme['dockedPanelTheme']['tint']) {
58
- const value = tint;
59
-
60
- if (typeof value === 'number') {
61
- return hexToRgb(value.toString(16).padStart(6, '0'));
62
- }
63
-
64
- if (typeof value === 'string') {
65
- const hex = value.trim().replace(/^#/, '');
66
- if (/^[0-9a-f]{3}$/i.test(hex)) {
67
- return hexToRgb(hex.replace(/(.)/g, '$1$1'));
68
- }
69
- if (/^[0-9a-f]{6}$/i.test(hex)) {
70
- return hexToRgb(hex);
71
- }
72
- }
73
-
74
- return '255 255 255';
75
- }
76
-
77
- function hexToRgb(hex: string) {
78
- const value = Number.parseInt(hex, 16);
79
- return `${(value >> 16) & 255} ${(value >> 8) & 255} ${value & 255}`;
80
- }
81
-
82
- function clamp(value: number, min: number, max: number) {
83
- return Math.min(Math.max(value, min), max);
84
- }
31
+ const brandStyle = $derived(getSpatialThemeStyle(theme));
85
32
  </script>
86
33
 
87
- <div class="brand-stage-shell" style={brandStyle}>
34
+ <div class="brand-stage-shell" style={brandStyle} style:color-scheme={colorScheme} data-color-scheme={colorScheme}>
88
35
  <Stage
89
36
  brandId={theme.id}
90
37
  {renderSettings}
91
38
  {dracoDecoderPath}
92
39
  pageBackground={theme.background}
40
+ sceneBackground={theme.sceneBackground}
93
41
  interactionTheme={theme.interactionTheme}
94
42
  ariaLabel={`${theme.name} spatialElement stage`}
95
43
  >
@@ -5,6 +5,8 @@ import type { SpatialTheme } from '@spatial-elements/core/spatial-element/types'
5
5
  interface Props {
6
6
  /** Shared appearance and namespace. Use createSpatialTheme for defaults. */
7
7
  theme: SpatialTheme;
8
+ /** Resolved by the host. System preference and persistence belong to the shell. */
9
+ colorScheme?: 'light' | 'dark';
8
10
  /** Localized interface copy. Missing groups/strings fall back to English; updates are reactive. */
9
11
  messages?: SpatialMessagesInput;
10
12
  /** Optional GPU resolution budget; defaults to DPR 1 and 2,073,600 pixels. */
@@ -296,9 +296,11 @@
296
296
  event.preventDefault();
297
297
  }
298
298
  onMount(() => {
299
+ // Section's child snippet can clear bind:this before this mount cleanup runs.
300
+ const carouselRing = ring;
299
301
  interactive = true;
300
302
  // The model owns both single-finger axes; passive events still allow native pinch zoom.
301
- ring.addEventListener('touchstart', touchstart, { passive: true });
303
+ carouselRing.addEventListener('touchstart', touchstart, { passive: true });
302
304
  const release = sections?.register(section.id, {
303
305
  read: () => selected,
304
306
  restore: (key) => {
@@ -319,19 +321,19 @@
319
321
  settle();
320
322
  }
321
323
  });
322
- observer.observe(ring);
324
+ observer.observe(carouselRing);
323
325
  let sizingFrame = 0;
324
326
  const measure = () => {
325
327
  sizingFrame = 0;
326
- const heights = [...ring.querySelectorAll<HTMLElement>('.summary')].map(
328
+ const heights = [...carouselRing.querySelectorAll<HTMLElement>('.summary')].map(
327
329
  (panel) => panel.offsetHeight
328
330
  );
329
331
  const contentHeight = Math.max(0, ...heights);
330
332
  const height =
331
- ring.clientWidth < 700 ? 408 + contentHeight : Math.max(560, contentHeight + 64);
333
+ carouselRing.clientWidth < 700 ? 408 + contentHeight : Math.max(560, contentHeight + 64);
332
334
  const value = height + 'px';
333
- if (ring.style.getPropertyValue('--carousel-height') !== value)
334
- ring.style.setProperty('--carousel-height', value);
335
+ if (carouselRing.style.getPropertyValue('--carousel-height') !== value)
336
+ carouselRing.style.setProperty('--carousel-height', value);
335
337
  };
336
338
  const scheduleSize = () => {
337
339
  if (!sizingFrame) sizingFrame = requestAnimationFrame(measure);
@@ -339,13 +341,13 @@
339
341
  const sizing = new ResizeObserver(scheduleSize);
340
342
  const contentChanges = new MutationObserver(() => {
341
343
  sizing.disconnect();
342
- sizing.observe(ring);
343
- for (const panel of ring.querySelectorAll('.summary')) sizing.observe(panel);
344
+ sizing.observe(carouselRing);
345
+ for (const panel of carouselRing.querySelectorAll('.summary')) sizing.observe(panel);
344
346
  scheduleSize();
345
347
  });
346
- contentChanges.observe(ring, { childList: true, subtree: true });
347
- sizing.observe(ring);
348
- for (const panel of ring.querySelectorAll('.summary')) sizing.observe(panel);
348
+ contentChanges.observe(carouselRing, { childList: true, subtree: true });
349
+ sizing.observe(carouselRing);
350
+ for (const panel of carouselRing.querySelectorAll('.summary')) sizing.observe(panel);
349
351
  const stop = () => pointercancel();
350
352
  let viewportWidth = window.innerWidth;
351
353
  const resize = () => {
@@ -371,7 +373,7 @@
371
373
  stopScrollMomentum();
372
374
  clearTimeout(clickTimer);
373
375
  releaseDrag();
374
- ring.removeEventListener('touchstart', touchstart);
376
+ carouselRing.removeEventListener('touchstart', touchstart);
375
377
  observer.disconnect();
376
378
  sizing.disconnect();
377
379
  contentChanges.disconnect();
@@ -42,7 +42,8 @@
42
42
  const items = getContext<CatalogItems | undefined>(CATALOG_ITEMS);
43
43
  const endpoints = getContext<CatalogEndpointRegistry | undefined>(CATALOG_ENDPOINTS);
44
44
  const sections = getContext<CatalogSections | undefined>(CATALOG_SECTIONS);
45
- const brand = useSpatialTheme();
45
+ const readTheme = useSpatialTheme();
46
+ const brand = $derived(readTheme());
46
47
  const catalogEndpoint = createCatalogEndpointAction();
47
48
  function address(role: CatalogEndpointRole) {
48
49
  return interactive &&
@@ -19,7 +19,8 @@
19
19
  children?: Snippet;
20
20
  }
21
21
  let { page, hdr, children }: Props = $props();
22
- const brand = useSpatialTheme();
22
+ const readTheme = useSpatialTheme();
23
+ const brand = $derived(readTheme());
23
24
  registerSpatialPage(() => ({ kind: 'content', hdr }));
24
25
  setContext(SPATIAL_ELEMENT_SECTION_REGISTRY_KEY, new SpatialElementSectionRegistry());
25
26
  setContext(SECTION_PAGE_KIND, 'content');
@@ -15,7 +15,8 @@
15
15
  occurrence,
16
16
  order = 0
17
17
  }: { spatialElement: SpatialListItem; occurrence: string; order?: number } = $props();
18
- const brand = useSpatialTheme();
18
+ const readTheme = useSpatialTheme();
19
+ const brand = $derived(readTheme());
19
20
  const catalogEndpoint = createCatalogEndpointAction();
20
21
  const endpoints = getContext<CatalogEndpointRegistry | undefined>(CATALOG_ENDPOINTS);
21
22
  const items = getContext<CatalogItems | undefined>(CATALOG_ITEMS);
@@ -1,17 +1,21 @@
1
1
  <script lang="ts">
2
- import { onMount, tick } from 'svelte';
2
+ import { getContext, onMount, tick } from 'svelte';
3
3
  import { CircleHelp, X } from 'lucide-svelte';
4
4
  import InteractionGesture from './InteractionGesture.svelte';
5
5
  import { getCssPanelBoxShadow } from '@spatial-elements/core/stage/panelShadow';
6
6
  import { getInteractionGuidance, MODEL_INPUT_EVENT, type ModelInputState, type InteractionGuidance } from '@spatial-elements/core/stage/interactionGuidance';
7
7
  import { STAGE_SCROLL_PRIORITY, subscribeStageScrollFrame } from '@spatial-elements/core/stage/scrollFrame';
8
- import { STAGE_PANEL_LAYOUT_EVENT } from '@spatial-elements/core/stage/panelContext';
8
+ import { STAGE_CONTEXT_KEY, STAGE_PANEL_LAYOUT_EVENT, type StageContext } from '@spatial-elements/core/stage/panelContext';
9
+ import SpatialElementViewToggle from './SpatialElementViewToggle.svelte';
9
10
  import Panel from '../stage/Panel.svelte';
10
11
  import SpatialIconButton from './SpatialIconButton.svelte';
11
12
  import { useSpatialTheme } from './brandContext.js';
12
13
  import { useSpatialMessages } from './messagesContext.js';
13
14
 
14
- const theme = useSpatialTheme();
15
+ const readTheme = useSpatialTheme();
16
+ const theme = $derived(readTheme());
17
+ const stageContext = getContext<StageContext>(STAGE_CONTEXT_KEY);
18
+ const fullscreen = $derived(stageContext.isFullscreen?.() ?? false);
15
19
  const readMessages = useSpatialMessages();
16
20
  const messages = $derived(readMessages());
17
21
  const help = $derived(messages.interactionHelp);
@@ -78,11 +82,12 @@
78
82
  if (open) window.dispatchEvent(new Event(STAGE_PANEL_LAYOUT_EVENT));
79
83
  }
80
84
  async function show(keyboard = false) {
81
- if (!enhanced || !visible) return;
85
+ if (!enhanced || (!visible && !fullscreen)) return;
82
86
  clearDelay(); clearHideDelay();
83
87
  popover.showPopover();
84
88
  open = true;
85
89
  await tick();
90
+ if (!open || !enhanced) return;
86
91
  requestPosition();
87
92
  if (keyboard) closeButton.focus({ preventScroll: true });
88
93
  }
@@ -104,6 +109,9 @@
104
109
  }
105
110
 
106
111
  onMount(() => {
112
+ // The child component can clear bind:element before this mount cleanup runs.
113
+ // Remove listeners from the same node they were registered on.
114
+ const helpButton = button;
107
115
  guidance = getInteractionGuidance();
108
116
  touchInput = window.matchMedia('(pointer: coarse)').matches;
109
117
  const stopGuidance = guidance.subscribe((state) => {
@@ -120,7 +128,7 @@
120
128
  .filter((node) => { const rect = node.getBoundingClientRect(); return rect.width > innerWidth * 0.4 && rect.bottom <= top && rect.height > 0; })
121
129
  .sort((a, b) => b.getBoundingClientRect().bottom - a.getBoundingClientRect().bottom)[0];
122
130
  const measureSpacing = () => {
123
- if (header) {
131
+ if (header && !fullscreen) {
124
132
  const gap = Math.max(16, root.getBoundingClientRect().top - header.getBoundingClientRect().bottom - 12);
125
133
  root.style.setProperty('--model-tools-gap', `${gap}px`);
126
134
  }
@@ -160,13 +168,13 @@
160
168
  };
161
169
  const stopScroll = subscribeStageScrollFrame(() => {
162
170
  if (!open) return;
163
- const rect = button.getBoundingClientRect();
171
+ const rect = helpButton.getBoundingClientRect();
164
172
  if (rect.bottom < 0 || rect.top > innerHeight) close();
165
173
  else requestPosition();
166
174
  }, STAGE_SCROLL_PRIORITY.stage + 1);
167
175
  stage.addEventListener(MODEL_INPUT_EVENT, modelChanged);
168
- button.addEventListener('pointerenter', buttonEnter);
169
- button.addEventListener('pointerleave', buttonLeave);
176
+ helpButton.addEventListener('pointerenter', buttonEnter);
177
+ helpButton.addEventListener('pointerleave', buttonLeave);
170
178
  window.addEventListener('pointerdown', inputChanged, { capture: true, passive: true });
171
179
  window.addEventListener('pointermove', inputChanged, { capture: true, passive: true });
172
180
  window.addEventListener('keydown', keydown);
@@ -179,8 +187,8 @@
179
187
  close(); stopGuidance(); stopScroll(); mutation.disconnect(); observer.disconnect(); size.disconnect(); headerSize.disconnect();
180
188
  root.appendChild(popover);
181
189
  stage.removeEventListener(MODEL_INPUT_EVENT, modelChanged);
182
- button.removeEventListener('pointerenter', buttonEnter);
183
- button.removeEventListener('pointerleave', buttonLeave);
190
+ helpButton.removeEventListener('pointerenter', buttonEnter);
191
+ helpButton.removeEventListener('pointerleave', buttonLeave);
184
192
  window.removeEventListener('pointerdown', inputChanged, true);
185
193
  window.removeEventListener('pointermove', inputChanged, true);
186
194
  window.removeEventListener('keydown', keydown);
@@ -196,8 +204,9 @@
196
204
  <SpatialIconButton bind:element={button} {focusAnchor} label={messages.controls.help} onclick={toggleHelp} expanded={open} controls={id} enabled={enhanced}>
197
205
  <CircleHelp size={21} strokeWidth={1.8} aria-hidden="true" />
198
206
  </SpatialIconButton>
207
+ <SpatialElementViewToggle enabled={enhanced} {focusAnchor} onchange={() => close()} />
199
208
  </div>
200
- {#if enhanced && touchInput && !interacted && !open}
209
+ {#if enhanced && touchInput && !interacted && !open && !fullscreen}
201
210
  <p class="touch-hint" data-spatial-element-touch-hint>{help.touchHint}</p>
202
211
  {/if}
203
212
  <div bind:this={popover} {id} popover="auto" role="dialog" tabindex="-1" aria-modal="false" aria-labelledby={`${id}-title`}
@@ -207,7 +216,7 @@
207
216
  onpointerleave={() => { helpHovered = false; schedule(); }}
208
217
  onfocusin={clearHideDelay} onfocusout={() => { queueMicrotask(schedule); }}
209
218
  ontoggle={(event) => { open = event.newState === 'open'; if (!open) { manual = false; clearHideDelay(); } }}>
210
- <Panel class="interaction-help-panel" nativeContent nativeLayout={position} visible={open} pointerReactive={false} focusReactive={false}
219
+ <Panel class="interaction-help-panel" data-stage-fullscreen-visible nativeContent nativeLayout={position} visible={open} pointerReactive={false} focusReactive={false}
211
220
  shape={{ ...theme.panelShape, contentInset: 0 }} theme={theme.panelTheme}>
212
221
  <div class="help-copy">
213
222
  <div class="help-heading">
@@ -224,7 +233,7 @@
224
233
  </dl>
225
234
  <p class="navigation-hint">
226
235
  {#if touchInput}
227
- {help.touchScrollHint}
236
+ {#if !fullscreen}{help.touchScrollHint}{/if}
228
237
  {:else}
229
238
  {#each help.mouseNavigationHint.split('{spacemouse}') as part, index}{#if index > 0}<a href="https://3dconnexion.com/" target="_blank" rel="noopener noreferrer">SpaceMouse</a>{/if}{part}{/each}
230
239
  {/if}
@@ -238,7 +247,7 @@
238
247
  .model-tools {
239
248
  grid-column: 1; grid-row: 1; align-self: start; justify-self: end; position: relative;
240
249
  margin-top: 6px; margin-inline-end: calc(var(--model-tools-gap, 32px) - var(--spatial-element-hero-column-gap));
241
- width: 40px; height: 40px; z-index: 6; visibility: hidden; pointer-events: none;
250
+ width: 128px; height: 40px; z-index: 6; visibility: hidden; pointer-events: none;
242
251
  }
243
252
  .model-tools.enhanced { visibility: visible; pointer-events: auto; }
244
253
  .model-tools-buttons { display: flex; gap: 8px; justify-content: flex-end; }
@@ -4,7 +4,8 @@
4
4
  import type { ResolvedSpatialElementData as SpatialElementData } from '@spatial-elements/core/spatial-element/spatialElement';
5
5
 
6
6
  let { spatialElement }: { spatialElement: SpatialElementData } = $props();
7
- const theme = useSpatialTheme();
7
+ const readTheme = useSpatialTheme();
8
+ const theme = $derived(readTheme());
8
9
  const minimap = $derived({
9
10
  ...spatialElement.minimap,
10
11
  ...theme.minimapTheme,
@@ -39,7 +39,8 @@
39
39
  children?: Snippet;
40
40
  }
41
41
  let { spatialElement: element, children }: Props = $props();
42
- const brand = useSpatialTheme();
42
+ const readTheme = useSpatialTheme();
43
+ const brand = $derived(readTheme());
43
44
  const spatialElement = $derived(resolveSpatialElementData(element, brand.id));
44
45
  // During route teardown Kit can clear the outgoing page's data before unmount.
45
46
  // Read raw assets here, so the parent stage never evaluates outgoing DOM-derived content.
@@ -1,4 +1,5 @@
1
1
  <script lang="ts">
2
+ import { onMount } from 'svelte';
2
3
  import { catalogActionSemantic } from '@spatial-elements/core/catalog/catalogAction';
3
4
  import { mouseHover } from '@spatial-elements/core/stage/mouseHover';
4
5
  import { ShoppingCart } from 'lucide-svelte';
@@ -8,11 +9,27 @@
8
9
  import { createCatalogEndpointAction } from '../catalog/catalogEndpointAction.js';
9
10
 
10
11
  let { spatialElement }: { spatialElement: SpatialElementData } = $props();
11
- const theme = useSpatialTheme();
12
+ const readTheme = useSpatialTheme();
13
+ const theme = $derived(readTheme());
12
14
  const catalogEndpoint = createCatalogEndpointAction();
15
+ const contentInset = $derived(theme.panelShape.contentInset ?? Math.max(16, Math.round(theme.panelShape.radius * 0.7)));
16
+ let presentation: HTMLDivElement;
17
+ let panelHeight = $state<number>();
18
+
19
+ onMount(() => {
20
+ // The stage reparents the rendered content. Keep its layout placeholder in
21
+ // sync using untransformed content size, including wrapping and font loads.
22
+ panelHeight = Math.max(504, presentation.offsetHeight + contentInset * 2);
23
+ const observer = new ResizeObserver(([entry]) => {
24
+ const height = entry.borderBoxSize?.[0]?.blockSize ?? presentation.offsetHeight;
25
+ panelHeight = Math.max(504, Math.ceil(height + contentInset * 2));
26
+ });
27
+ observer.observe(presentation);
28
+ return () => observer.disconnect();
29
+ });
13
30
  </script>
14
31
 
15
- <div class="spatial-element-aside">
32
+ <div class="spatial-element-aside" style:--summary-panel-height={panelHeight === undefined ? undefined : `${panelHeight}px`}>
16
33
  <Panel
17
34
  catalogEndpoint={{
18
35
  brandId: theme.id,
@@ -30,7 +47,7 @@
30
47
  data-shared-role="summary-surface"
31
48
  data-spatial-element-id={spatialElement.id}
32
49
  >
33
- <div class="summary-presentation" use:mouseHover>
50
+ <div bind:this={presentation} class="summary-presentation" style:min-height={`${Math.max(504 - contentInset * 2, 0)}px`} use:mouseHover>
34
51
  <div class="panel-copy">
35
52
  <p
36
53
  class="panel-kicker"
@@ -153,14 +170,15 @@
153
170
  }
154
171
 
155
172
  .spatial-element-aside {
173
+ position: relative;
156
174
  min-height: inherit;
157
175
  }
158
176
 
159
177
  :global(.spatial-element-panel) {
160
- position: relative;
161
- top: 0;
178
+ position: sticky;
179
+ top: var(--spatial-element-summary-sticky-top, 104px);
162
180
  width: min(494px, 100%);
163
- height: 504px;
181
+ height: var(--summary-panel-height, auto);
164
182
  min-height: 504px;
165
183
  pointer-events: auto;
166
184
  }
@@ -183,8 +201,7 @@
183
201
  --summary-action-depth: 76;
184
202
  --summary-action-hover-depth: 24;
185
203
 
186
- position: absolute;
187
- inset: 0;
204
+ position: relative;
188
205
  box-sizing: border-box;
189
206
  display: flex;
190
207
  flex-direction: column;
@@ -421,7 +438,9 @@
421
438
  }
422
439
 
423
440
  @media (max-width: 1100px) {
441
+ .spatial-element-aside { min-height: 0; }
424
442
  :global(.spatial-element-panel) {
443
+ position: relative;
425
444
  top: auto;
426
445
  }
427
446
  }
@@ -14,7 +14,8 @@
14
14
  sections: SpatialElementSectionNavigationItem[];
15
15
  } = $props();
16
16
  let anchorElement: HTMLDivElement;
17
- const theme = useSpatialTheme();
17
+ const readTheme = useSpatialTheme();
18
+ const theme = $derived(readTheme());
18
19
 
19
20
  onMount(() => {
20
21
  let resizeObserver: ResizeObserver | undefined;
@@ -0,0 +1,53 @@
1
+ <script lang="ts">
2
+ import { getContext } from 'svelte';
3
+ import { PanelsTopLeft, Maximize } from 'lucide-svelte';
4
+ import { STAGE_CONTEXT_KEY, type StageContext } from '@spatial-elements/core/stage/panelContext';
5
+ import ButtonGroup from '../stage/ButtonGroup.svelte';
6
+ import { useSpatialTheme } from './brandContext.js';
7
+ import { useSpatialMessages } from './messagesContext.js';
8
+ let {
9
+ enabled,
10
+ focusAnchor,
11
+ onchange
12
+ }: { enabled: boolean; focusAnchor?: HTMLElement; onchange: () => void } = $props();
13
+ const stage = getContext<StageContext>(STAGE_CONTEXT_KEY);
14
+ const readTheme = useSpatialTheme();
15
+ const theme = $derived(readTheme());
16
+ const readMessages = useSpatialMessages();
17
+ const messages = $derived(readMessages());
18
+ const fullscreen = $derived(stage.isFullscreen?.() ?? false);
19
+ const zoomFocus = $derived(stage.getZoomFocus?.() ?? 0);
20
+ function select(value: string) {
21
+ onchange();
22
+ stage.setFullscreen?.(value === 'fullscreen');
23
+ if (value === 'detail') stage.resetView();
24
+ }
25
+ </script>
26
+
27
+ <ButtonGroup
28
+ data-spatial-element-view-toggle
29
+ label={messages.controls.detailView}
30
+ iconOnly
31
+ items={[
32
+ {
33
+ value: 'detail',
34
+ label: messages.controls.detailView,
35
+ selection: fullscreen ? 0 : 1 - zoomFocus
36
+ },
37
+ { value: 'fullscreen', label: messages.controls.fullscreen }
38
+ ]}
39
+ value={fullscreen ? 'fullscreen' : zoomFocus < 0.001 ? 'detail' : undefined}
40
+ onchange={select}
41
+ disabled={!enabled}
42
+ visible={enabled}
43
+ shape={theme.panelShape}
44
+ theme={theme.panelTheme}
45
+ focusReactive="top-right"
46
+ {focusAnchor}
47
+ transitionGroup="enter"
48
+ >
49
+ {#snippet content(item)}
50
+ {#if item.value === 'detail'}<PanelsTopLeft size={21} strokeWidth={1.8} aria-hidden="true" />
51
+ {:else}<Maximize size={21} strokeWidth={1.8} aria-hidden="true" />{/if}
52
+ {/snippet}
53
+ </ButtonGroup>
@@ -0,0 +1,8 @@
1
+ type $$ComponentProps = {
2
+ enabled: boolean;
3
+ focusAnchor?: HTMLElement;
4
+ onchange: () => void;
5
+ };
6
+ declare const SpatialElementViewToggle: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type SpatialElementViewToggle = ReturnType<typeof SpatialElementViewToggle>;
8
+ export default SpatialElementViewToggle;
@@ -14,7 +14,8 @@
14
14
  enabled?: boolean;
15
15
  element?: HTMLButtonElement;
16
16
  } = $props();
17
- const theme = useSpatialTheme();
17
+ const readTheme = useSpatialTheme();
18
+ const theme = $derived(readTheme());
18
19
  </script>
19
20
 
20
21
  <div class="icon-frame">
@@ -2,4 +2,4 @@ import type { SpatialTheme } from '@spatial-elements/core/spatial-element/types'
2
2
  /** Makes the current brand theme available to all spatial-element descendants. */
3
3
  export declare function provideSpatialTheme(getTheme: () => SpatialTheme): void;
4
4
  /** Returns the nearest brand theme or throws when the element shell is incomplete. */
5
- export declare function useSpatialTheme(): SpatialTheme;
5
+ export declare function useSpatialTheme(): () => SpatialTheme;
@@ -10,5 +10,5 @@ export function useSpatialTheme() {
10
10
  if (!getTheme) {
11
11
  throw new Error('SpatialElement detail components must be rendered inside a brand layout');
12
12
  }
13
- return getTheme();
13
+ return getTheme;
14
14
  }
@@ -0,0 +1,3 @@
1
+ import type { SpatialTheme } from '@spatial-elements/core/spatial-element/types';
2
+ /** CSS declarations shared by the shell and optional server-rendered theme previews. */
3
+ export declare function getSpatialThemeStyle(theme: SpatialTheme): string;
@@ -0,0 +1,48 @@
1
+ import { getCssPanelBoxShadow, resolvePanelShadowStrength } from '@spatial-elements/core/stage/panelShadow';
2
+ /** CSS declarations shared by the shell and optional server-rendered theme previews. */
3
+ export function getSpatialThemeStyle(theme) {
4
+ return [
5
+ `--spatial-element-background: ${theme.background}`,
6
+ `--spatial-element-ink: ${theme.colors.ink}`,
7
+ `--spatial-element-body: ${theme.colors.body}`,
8
+ `--spatial-element-accent: ${theme.colors.accent}`,
9
+ `--spatial-element-on-accent: ${theme.colors.onAccent}`,
10
+ `--spatial-element-section-tint: ${theme.sectionTheme.tint}`,
11
+ `--spatial-element-section-tint-opacity: ${toPercentage(theme.sectionTheme.tintOpacity)}`,
12
+ `--spatial-element-section-backdrop-blur: ${Math.max(theme.sectionTheme.backdropBlur, 0)}px`,
13
+ `--spatial-element-tab-background: ${theme.colors.tabBackground}`,
14
+ `--spatial-element-panel-radius: ${theme.panelShape.radius}px`,
15
+ `--spatial-element-docked-panel-tint-rgb: ${getDockedPanelTintRgb(theme.dockedPanelTheme.tint)}`,
16
+ `--spatial-element-docked-panel-tint-opacity: ${clamp(theme.dockedPanelTheme.tintOpacity, 0, 1)}`,
17
+ `--spatial-element-docked-panel-shadow-intensity: ${clamp(theme.dockedPanelTheme.shadowIntensity, 0, 1)}`,
18
+ `--spatial-element-docked-panel-shadow-strength: ${resolvePanelShadowStrength(theme.dockedPanelTheme.shadowIntensity)}`,
19
+ `--spatial-element-docked-panel-box-shadow: ${getCssPanelBoxShadow(theme.dockedPanelTheme.shadowIntensity)}`,
20
+ `--spatial-element-docked-panel-backdrop-blur: ${Math.min(Math.max(theme.dockedPanelTheme.backdropBlur, 0), 100)}px`
21
+ ].join('; ');
22
+ }
23
+ function toPercentage(value) {
24
+ return `${clamp(value, 0, 1) * 100}%`;
25
+ }
26
+ function getDockedPanelTintRgb(tint) {
27
+ const value = tint;
28
+ if (typeof value === 'number') {
29
+ return hexToRgb(value.toString(16).padStart(6, '0'));
30
+ }
31
+ if (typeof value === 'string') {
32
+ const hex = value.trim().replace(/^#/, '');
33
+ if (/^[0-9a-f]{3}$/i.test(hex)) {
34
+ return hexToRgb(hex.replace(/(.)/g, '$1$1'));
35
+ }
36
+ if (/^[0-9a-f]{6}$/i.test(hex)) {
37
+ return hexToRgb(hex);
38
+ }
39
+ }
40
+ return '255 255 255';
41
+ }
42
+ function hexToRgb(hex) {
43
+ const value = Number.parseInt(hex, 16);
44
+ return `${(value >> 16) & 255} ${(value >> 8) & 255} ${value & 255}`;
45
+ }
46
+ function clamp(value, min, max) {
47
+ return Math.min(Math.max(value, min), max);
48
+ }
@@ -0,0 +1,163 @@
1
+ <script lang="ts">
2
+ import { onMount, type Snippet } from 'svelte';
3
+ import type { HTMLAttributes } from 'svelte/elements';
4
+ import type { StagePanelShape, StagePanelTheme } from '@spatial-elements/core/stage/panelContext';
5
+ import type { CatalogTransitionGroup } from '@spatial-elements/core/catalog/catalogPresentation';
6
+ import { mouseHover } from '@spatial-elements/core/stage/mouseHover';
7
+ import Panel from './Panel.svelte';
8
+ import type { ButtonGroupItem } from './buttonGroup.js';
9
+ type Props = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onchange'> & {
10
+ items: readonly ButtonGroupItem[];
11
+ /** Controlled selection. Omit when no button is selected. */
12
+ value?: string;
13
+ onchange?: (value: string) => void;
14
+ label: string;
15
+ content?: Snippet<[ButtonGroupItem]>;
16
+ iconOnly?: boolean;
17
+ disabled?: boolean;
18
+ visible?: boolean;
19
+ shape: StagePanelShape;
20
+ theme?: StagePanelTheme;
21
+ focusReactive?: boolean | 'top-right';
22
+ focusAnchor?: HTMLElement;
23
+ transitionGroup?: CatalogTransitionGroup;
24
+ };
25
+ let {
26
+ items,
27
+ value,
28
+ onchange,
29
+ label,
30
+ content,
31
+ iconOnly = false,
32
+ disabled = false,
33
+ visible = true,
34
+ shape,
35
+ theme,
36
+ focusReactive = false,
37
+ focusAnchor,
38
+ transitionGroup,
39
+ class: className = '',
40
+ ...rest
41
+ }: Props = $props();
42
+ let group: HTMLDivElement;
43
+ let measuredWidth = $state<number>();
44
+ const radius = $derived(Math.min(12, Math.max(0, shape.radius)));
45
+ const width = $derived(
46
+ iconOnly ? `${items.length * 40}px` : measuredWidth ? `${measuredWidth}px` : 'max-content'
47
+ );
48
+ onMount(() => {
49
+ const observer = new ResizeObserver(() => {
50
+ measuredWidth = group.offsetWidth;
51
+ });
52
+ observer.observe(group);
53
+ return () => observer.disconnect();
54
+ });
55
+ </script>
56
+
57
+ <div class="button-group-frame" style:width>
58
+ <Panel
59
+ class="button-group-panel"
60
+ shape={{ ...shape, radius, contentInset: 0 }}
61
+ {theme}
62
+ pointerReactive={false}
63
+ {focusReactive}
64
+ {focusAnchor}
65
+ {transitionGroup}
66
+ >
67
+ <div
68
+ {...rest}
69
+ bind:this={group}
70
+ role="group"
71
+ aria-label={label}
72
+ class={['button-group', className]}
73
+ use:mouseHover
74
+ style:--control-radius={`${radius}px`}
75
+ style:visibility={visible ? 'visible' : 'hidden'}
76
+ >
77
+ {#each items as item (item.value)}
78
+ <button
79
+ type="button"
80
+ class:icon-only={iconOnly}
81
+ disabled={disabled || item.disabled}
82
+ aria-label={item.label}
83
+ title={item.tooltip ?? item.label}
84
+ aria-pressed={item.value === value}
85
+ style:--selection={`${Math.min(1, Math.max(0, item.selection ?? (item.value === value ? 1 : 0))) * 8}%`}
86
+ onclick={() => onchange?.(item.value)}
87
+ >
88
+ {#if content}{@render content(item)}{:else}{item.label}{/if}
89
+ </button>
90
+ {/each}
91
+ </div>
92
+ </Panel>
93
+ </div>
94
+
95
+ <style>
96
+ .button-group-frame {
97
+ height: 40px;
98
+ flex: none;
99
+ }
100
+ .button-group-frame :global(.button-group-panel) {
101
+ width: 100%;
102
+ height: 40px;
103
+ }
104
+ .button-group {
105
+ display: flex;
106
+ width: max-content;
107
+ height: 40px;
108
+ border-radius: var(--control-radius);
109
+ }
110
+ button {
111
+ box-sizing: border-box;
112
+ display: grid;
113
+ place-items: center;
114
+ min-width: 40px;
115
+ height: 40px;
116
+ padding: 0 12px;
117
+ border: 0;
118
+ font: inherit;
119
+ white-space: nowrap;
120
+ background: color-mix(
121
+ in srgb,
122
+ var(--spatial-element-body, currentColor) var(--selection),
123
+ transparent
124
+ );
125
+ color: var(--spatial-element-ink, inherit);
126
+ cursor: pointer;
127
+ touch-action: manipulation;
128
+ transition: background-color 180ms ease;
129
+ }
130
+ button.icon-only {
131
+ width: 40px;
132
+ padding: 0;
133
+ }
134
+ button:first-child {
135
+ border-radius: var(--control-radius) 0 0 var(--control-radius);
136
+ }
137
+ button:last-child {
138
+ border-radius: 0 var(--control-radius) var(--control-radius) 0;
139
+ }
140
+ button:only-child {
141
+ border-radius: var(--control-radius);
142
+ }
143
+ button + button {
144
+ border-left: 1px solid
145
+ color-mix(in srgb, var(--spatial-element-body, currentColor) 12%, transparent);
146
+ }
147
+ .button-group:global([data-mouse-hover]) button:enabled:hover {
148
+ background: color-mix(in srgb, var(--spatial-element-body, currentColor) 8%, transparent);
149
+ }
150
+ button:focus-visible {
151
+ outline: 2px solid var(--spatial-element-accent, currentColor);
152
+ outline-offset: -2px;
153
+ }
154
+ button:disabled {
155
+ cursor: default;
156
+ opacity: 0.45;
157
+ }
158
+ @media (prefers-reduced-motion: reduce) {
159
+ button {
160
+ transition: none;
161
+ }
162
+ }
163
+ </style>
@@ -0,0 +1,24 @@
1
+ import { type Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import type { StagePanelShape, StagePanelTheme } from '@spatial-elements/core/stage/panelContext';
4
+ import type { CatalogTransitionGroup } from '@spatial-elements/core/catalog/catalogPresentation';
5
+ import type { ButtonGroupItem } from './buttonGroup.js';
6
+ type Props = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onchange'> & {
7
+ items: readonly ButtonGroupItem[];
8
+ /** Controlled selection. Omit when no button is selected. */
9
+ value?: string;
10
+ onchange?: (value: string) => void;
11
+ label: string;
12
+ content?: Snippet<[ButtonGroupItem]>;
13
+ iconOnly?: boolean;
14
+ disabled?: boolean;
15
+ visible?: boolean;
16
+ shape: StagePanelShape;
17
+ theme?: StagePanelTheme;
18
+ focusReactive?: boolean | 'top-right';
19
+ focusAnchor?: HTMLElement;
20
+ transitionGroup?: CatalogTransitionGroup;
21
+ };
22
+ declare const ButtonGroup: import("svelte").Component<Props, {}, "">;
23
+ type ButtonGroup = ReturnType<typeof ButtonGroup>;
24
+ export default ButtonGroup;
@@ -1,7 +1,8 @@
1
1
  <script lang="ts">
2
2
  import type { HTMLAttributes } from "svelte/elements";
3
3
  type StagePanelAttributes = HTMLAttributes<HTMLDivElement>;
4
- import { getContext, onDestroy, onMount } from 'svelte';
4
+ import { getContext, onDestroy, onMount, untrack } from 'svelte';
5
+ import { authoredStyle } from './authoredStyle.js';
5
6
  import type { Snippet } from 'svelte';
6
7
  import {
7
8
  STAGE_CONTEXT_KEY,
@@ -97,6 +98,13 @@
97
98
  });
98
99
 
99
100
  onDestroy(unregister);
101
+ $effect(() => {
102
+ getPanelOptions();
103
+ getContentInset();
104
+ Object.values(getMinimapOptions() ?? {});
105
+ void resolvedSurface;
106
+ stage.updatePanelAppearance?.();
107
+ });
100
108
  $effect(() => {
101
109
  if (nativeContent) {
102
110
  void visible;
@@ -106,14 +114,15 @@
106
114
 
107
115
  onMount(() => {
108
116
  if (!getMinimapOptions()) return;
117
+ const minimapContent = contentElement;
109
118
 
110
119
  const resetView = (event: MouseEvent) => {
111
120
  if (event.defaultPrevented || event.button !== 0) return;
112
121
  stage.resetView();
113
122
  };
114
123
 
115
- contentElement.addEventListener('click', resetView);
116
- return () => contentElement.removeEventListener('click', resetView);
124
+ minimapContent.addEventListener('click', resetView);
125
+ return () => minimapContent.removeEventListener('click', resetView);
117
126
  });
118
127
 
119
128
  function getContentInset() {
@@ -180,9 +189,6 @@
180
189
  `--stage-panel-thickness: ${thickness}`,
181
190
  `--stage-panel-bezel: ${bezel}px`,
182
191
  `--stage-panel-opacity: ${clamp(theme.opacity ?? 1, 0, 1)}`,
183
- '--stage-panel-surface-opacity: 1',
184
- '--stage-panel-focus-opacity: 1',
185
- '--stage-panel-content-opacity: 1',
186
192
  `--stage-panel-css-blur: ${Math.min(backdropBlur, 100)}px`
187
193
  ];
188
194
 
@@ -242,6 +248,9 @@
242
248
  function clamp(value: number, min: number, max: number) {
243
249
  return Math.min(Math.max(value, min), max);
244
250
  }
251
+ // SSR styles are static; the action patches only authored properties after hydration.
252
+ const initialFallbackStyle = untrack(getFallbackStyle);
253
+ const initialContentStyle = untrack(getContentThemeStyle);
245
254
  </script>
246
255
 
247
256
  <div
@@ -255,7 +264,8 @@
255
264
  class={[frameClass, 'stage-panel-fallback', pose ? 'stage-panel-posed' : '']
256
265
  .filter(Boolean)
257
266
  .join(' ')}
258
- style={getFallbackStyle()}
267
+ style={initialFallbackStyle}
268
+ use:authoredStyle={getFallbackStyle()}
259
269
  >
260
270
  <div
261
271
  bind:this={surfaceElement}
@@ -264,16 +274,21 @@
264
274
  data-stage-panel-minimap={minimap ? '' : undefined}
265
275
  data-stage-panel-surface={resolvedSurface}
266
276
  class="stage-panel-surface"
267
- style={getFallbackStyle()}
277
+ style={initialFallbackStyle}
278
+ data-stage-panel-authored-style={getFallbackStyle()}
279
+ use:authoredStyle={getFallbackStyle()}
268
280
  >
269
281
  <div
270
282
  {...rest}
271
283
  bind:this={contentElement}
272
284
  use:registerEndpoint={catalogEndpoint}
273
285
  data-stage-panel-content
286
+ data-stage-corner-control={focusReactive === 'top-right' ? '' : undefined}
274
287
  data-catalog-transition-group={transitionGroup}
275
288
  class={contentClass}
276
- style={getContentThemeStyle()}
289
+ style={initialContentStyle}
290
+ data-stage-panel-authored-style={getContentThemeStyle()}
291
+ use:authoredStyle={getContentThemeStyle()}
277
292
  >
278
293
  {@render children?.()}
279
294
  </div>
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  import type { SpatialElementLodPair } from '@spatial-elements/core/catalog/spatialElementLodPair';
3
+ import { DEFAULT_BACKGROUND } from '@spatial-elements/core/stage/stageConstants';
3
4
  import { onMount, setContext, tick } from 'svelte';
4
5
  import type { Snippet } from 'svelte';
5
6
  import type {
@@ -20,6 +21,7 @@
20
21
  } from '@spatial-elements/core/stage/stageVisualTest';
21
22
  import { resolveStageRenderSettings } from '@spatial-elements/core/stage/renderSettings';
22
23
  import { VirtualScrollController } from '@spatial-elements/core/stage/VirtualScrollController';
24
+ import { StageFullscreenController } from '@spatial-elements/core/stage/StageFullscreenController';
23
25
  import ScrollNavigationBridge from '../catalog/ScrollNavigationBridge.svelte';
24
26
  import { CatalogTransition } from '@spatial-elements/core/catalog/CatalogTransition';
25
27
  import {
@@ -59,6 +61,8 @@
59
61
  dracoDecoderPath?: string;
60
62
  ariaLabel?: string;
61
63
  background?: BackgroundSettings;
64
+ /** Theme overrides applied after each element's HDR background settings. */
65
+ sceneBackground?: Partial<BackgroundSettings>;
62
66
  pageBackground?: string;
63
67
  hdr?: string;
64
68
  glb?: string;
@@ -78,6 +82,7 @@
78
82
  dracoDecoderPath,
79
83
  pageBackground = '#ffffff',
80
84
  background: standaloneBackground,
85
+ sceneBackground,
81
86
  hdr: standaloneHdr,
82
87
  glb: standaloneGlb,
83
88
  lodPair: standaloneLodPair,
@@ -115,7 +120,7 @@
115
120
  const catalogSpatialElements = $derived(
116
121
  displayedSpatialElements.length ? displayedSpatialElements : (catalog?.spatialElements ?? [])
117
122
  );
118
- const background = $derived(brandId ? activeElement?.background : standaloneBackground);
123
+ const background = $derived({ ...DEFAULT_BACKGROUND, ...(brandId ? activeElement?.background : standaloneBackground), ...sceneBackground });
119
124
  const hdr = $derived(brandId
120
125
  ? (activePage?.kind === 'content' ? activePage.hdr : activeScene?.hdr ?? '')
121
126
  : standaloneHdr);
@@ -134,6 +139,8 @@
134
139
  let status = $state('Loading stage');
135
140
  let showStatus = $state(true);
136
141
  let isEnhanced = $state(false);
142
+ let fullscreen = $state(false);
143
+ let fullscreenController: StageFullscreenController | undefined;
137
144
  let isFallback = $state(true);
138
145
  let domLayerHidden = $state(false);
139
146
  let domLayerOpacity = $state(1);
@@ -176,6 +183,7 @@
176
183
  };
177
184
 
178
185
  setContext<StageContext>(STAGE_CONTEXT_KEY, {
186
+ updatePanelAppearance: scheduleAppearanceUpdate,
179
187
  prefetchSpatialElement: (config) => experience?.prefetchSpatialElement(config),
180
188
  registerPanel(panel) {
181
189
  registeredPanels.push(panel);
@@ -194,10 +202,17 @@
194
202
  },
195
203
  resetView() {
196
204
  experience?.resetView();
197
- }
205
+ },
206
+ isFullscreen: () => fullscreen,
207
+ getZoomFocus: () => zoomFocusState.focus,
208
+ setFullscreen: (active) => fullscreenController?.setFullscreen(active)
198
209
  });
199
210
 
200
211
  onMount(() => {
212
+ fullscreenController = new StageFullscreenController(stage, (active) => {
213
+ fullscreen = active;
214
+ experience?.setFullscreen(active);
215
+ });
201
216
  document.documentElement.classList.add('stage-route');
202
217
  document.body.classList.add('stage-route');
203
218
  virtualScroll = new VirtualScrollController(stage, domLayer, virtualScrollSpacer);
@@ -269,6 +284,7 @@
269
284
  enableSpaceMouse: !isStageVisualTestMode(),
270
285
  onDeviceLost: () => {
271
286
  if (disposed || experience !== instance) return;
287
+ fullscreenController?.setFullscreen(false);
272
288
  navigationGeneration += 1;
273
289
  transition?.cancel();
274
290
  experience = null;
@@ -322,6 +338,8 @@
322
338
  });
323
339
 
324
340
  return () => {
341
+ fullscreenController?.dispose();
342
+ fullscreenController = undefined;
325
343
  virtualScroll?.destroy();
326
344
  virtualScroll = undefined;
327
345
  destroyed = true;
@@ -340,6 +358,22 @@
340
358
  };
341
359
  });
342
360
 
361
+ $effect(() => {
362
+ void pageBackground; void background; void isEnhanced;
363
+ Object.values(interactionTheme ?? {});
364
+ scheduleAppearanceUpdate();
365
+ });
366
+ let appearanceUpdatePending = false;
367
+ function scheduleAppearanceUpdate() {
368
+ if (appearanceUpdatePending) return;
369
+ appearanceUpdatePending = true;
370
+ void tick().then(() => {
371
+ appearanceUpdatePending = false;
372
+ if (!destroyed && isEnhanced) experience?.updateAppearance({
373
+ pageBackground, background, interactionTheme, panels: getPanelTargets()
374
+ });
375
+ });
376
+ }
343
377
  $effect(() => {
344
378
  const spatialElements = catalogSpatialElements;
345
379
  if (experience && catalog && isEnhanced) {
@@ -385,6 +419,7 @@
385
419
 
386
420
  let navigationTimings = { dataReady: 0, captured: 0, restoring: 0, bound: 0 };
387
421
  function captureNavigation(navigation: OnNavigate) {
422
+ fullscreenController?.setFullscreen(false);
388
423
  navigationTimings = { dataReady: performance.now(), captured: 0, restoring: 0, bound: 0 };
389
424
  navigationGeneration += 1;
390
425
  reuseCatalogPage = Boolean(
@@ -557,6 +592,7 @@
557
592
  getPanelRect: (frame) => experience?.getVisualTestPanelRect(frame) ?? null,
558
593
  getModelRect: () => experience?.getVisualTestModelRect() ?? null,
559
594
  getMinimapModelRect: () => experience?.getVisualTestMinimapModelRect() ?? null,
595
+ getMinimapViewportRect: () => experience?.getVisualTestMinimapViewportRect() ?? null,
560
596
  getMinimapOrientation: () => experience?.getVisualTestMinimapOrientation() ?? null,
561
597
  getMinimapRenderStats: () =>
562
598
  experience?.getVisualTestMinimapRenderStats() ?? {
@@ -661,7 +697,7 @@
661
697
  >
662
698
  <div bind:this={virtualScrollSpacer} class="stage-virtual-scroll-spacer" aria-hidden="true"></div>
663
699
 
664
- <div class="stage-virtual-viewport">
700
+ <div class="stage-virtual-viewport" inert={fullscreen}>
665
701
  <div
666
702
  bind:this={domLayer}
667
703
  class="stage-dom-layer"
@@ -698,6 +734,19 @@
698
734
  background: var(--stage-page-background, #ffffff);
699
735
  }
700
736
 
737
+ .stage:global([data-stage-fullscreen]) {
738
+ z-index: 2147483000;
739
+ isolation: isolate;
740
+ }
741
+ .stage:global([data-stage-fullscreen]) .stage-virtual-viewport {
742
+ visibility: hidden;
743
+ pointer-events: none;
744
+ }
745
+ .stage:global([data-stage-fullscreen]) .stage-virtual-viewport :global(*) {
746
+ visibility: hidden !important;
747
+ pointer-events: none !important;
748
+ }
749
+
701
750
  .stage-virtual-scroll-spacer {
702
751
  display: none;
703
752
  width: 1px;
@@ -10,6 +10,8 @@ interface Props {
10
10
  dracoDecoderPath?: string;
11
11
  ariaLabel?: string;
12
12
  background?: BackgroundSettings;
13
+ /** Theme overrides applied after each element's HDR background settings. */
14
+ sceneBackground?: Partial<BackgroundSettings>;
13
15
  pageBackground?: string;
14
16
  hdr?: string;
15
17
  glb?: string;
@@ -0,0 +1,4 @@
1
+ /** Patch authored declarations without erasing the renderer's position, transform or visibility. */
2
+ export declare function authoredStyle(node: HTMLElement, value: string): {
3
+ update: (next: string) => void;
4
+ };
@@ -0,0 +1,17 @@
1
+ /** Patch authored declarations without erasing the renderer's position, transform or visibility. */
2
+ export function authoredStyle(node, value) {
3
+ let previous = new Set();
4
+ function update(next) {
5
+ const parsed = document.createElement('div').style;
6
+ parsed.cssText = next;
7
+ const properties = new Set(Array.from(parsed));
8
+ for (const name of previous)
9
+ if (!properties.has(name))
10
+ node.style.removeProperty(name);
11
+ for (const name of properties)
12
+ node.style.setProperty(name, parsed.getPropertyValue(name), parsed.getPropertyPriority(name));
13
+ previous = properties;
14
+ }
15
+ update(value);
16
+ return { update };
17
+ }
@@ -0,0 +1,9 @@
1
+ export interface ButtonGroupItem {
2
+ value: string;
3
+ /** Accessible name and default tooltip. */
4
+ label: string;
5
+ tooltip?: string;
6
+ disabled?: boolean;
7
+ /** Visual selection strength (0–1), independent of aria-pressed. */
8
+ selection?: number;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spatial-elements/sveltekit",
3
- "version": "1.0.0-beta.4",
3
+ "version": "1.0.0-beta.5",
4
4
  "description": "SvelteKit components and navigation for Spatial Elements.",
5
5
  "license": "MPL-2.0",
6
6
  "type": "module",
@@ -39,7 +39,7 @@
39
39
  "prepack": "npm run build"
40
40
  },
41
41
  "dependencies": {
42
- "@spatial-elements/core": "1.0.0-beta.4",
42
+ "@spatial-elements/core": "1.0.0-beta.5",
43
43
  "lucide-svelte": "^1.0.1"
44
44
  },
45
45
  "peerDependencies": {