@spatial-elements/sveltekit 1.0.0-beta.3 → 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 (42) hide show
  1. package/README.md +7 -1
  2. package/dist/index.d.ts +3 -0
  3. package/dist/index.js +2 -0
  4. package/dist/spatial-element/BrandStageShell.svelte +12 -59
  5. package/dist/spatial-element/BrandStageShell.svelte.d.ts +5 -0
  6. package/dist/spatial-element/CarouselSection.svelte +191 -48
  7. package/dist/spatial-element/CarouselSpatialElement.svelte +7 -2
  8. package/dist/spatial-element/ContentPage.svelte +2 -1
  9. package/dist/spatial-element/InteractionGesture.svelte +39 -0
  10. package/dist/spatial-element/InteractionGesture.svelte.d.ts +7 -0
  11. package/dist/spatial-element/SpatialElementBreadcrumbs.svelte +3 -1
  12. package/dist/spatial-element/SpatialElementCard.svelte +2 -1
  13. package/dist/spatial-element/SpatialElementHelp.svelte +286 -0
  14. package/dist/spatial-element/SpatialElementHelp.svelte.d.ts +3 -0
  15. package/dist/spatial-element/SpatialElementMediaRail.svelte +2 -1
  16. package/dist/spatial-element/SpatialElementPage.svelte +11 -2
  17. package/dist/spatial-element/SpatialElementSummaryPanel.svelte +34 -12
  18. package/dist/spatial-element/SpatialElementTabList.svelte +3 -1
  19. package/dist/spatial-element/SpatialElementTabs.svelte +2 -1
  20. package/dist/spatial-element/SpatialElementViewToggle.svelte +53 -0
  21. package/dist/spatial-element/SpatialElementViewToggle.svelte.d.ts +8 -0
  22. package/dist/spatial-element/SpatialIconButton.svelte +57 -0
  23. package/dist/spatial-element/SpatialIconButton.svelte.d.ts +14 -0
  24. package/dist/spatial-element/brandContext.d.ts +1 -1
  25. package/dist/spatial-element/brandContext.js +1 -1
  26. package/dist/spatial-element/index.d.ts +1 -0
  27. package/dist/spatial-element/index.js +1 -0
  28. package/dist/spatial-element/messagesContext.d.ts +3 -0
  29. package/dist/spatial-element/messagesContext.js +10 -0
  30. package/dist/spatial-element/spatialThemeStyle.d.ts +3 -0
  31. package/dist/spatial-element/spatialThemeStyle.js +48 -0
  32. package/dist/stage/ButtonGroup.svelte +163 -0
  33. package/dist/stage/ButtonGroup.svelte.d.ts +24 -0
  34. package/dist/stage/Panel.svelte +54 -11
  35. package/dist/stage/Panel.svelte.d.ts +12 -2
  36. package/dist/stage/Stage.svelte +67 -7
  37. package/dist/stage/Stage.svelte.d.ts +2 -0
  38. package/dist/stage/authoredStyle.d.ts +4 -0
  39. package/dist/stage/authoredStyle.js +17 -0
  40. package/dist/stage/buttonGroup.d.ts +9 -0
  41. package/dist/stage/buttonGroup.js +1 -0
  42. package/package.json +2 -2
@@ -1,4 +1,5 @@
1
1
  export { default as BrandStageShell } from './BrandStageShell.svelte';
2
+ export { defaultSpatialMessages, resolveSpatialMessages } from '@spatial-elements/core/spatial-element/messages';
2
3
  export { default as SpatialElementPage } from './SpatialElementPage.svelte';
3
4
  export { default as SpatialListPage } from './SpatialListPage.svelte';
4
5
  export { default as Section } from './Section.svelte';
@@ -0,0 +1,3 @@
1
+ import { type SpatialMessagesInput } from '@spatial-elements/core/spatial-element/messages';
2
+ export declare function provideSpatialMessages(read: () => SpatialMessagesInput | undefined): void;
3
+ export declare function useSpatialMessages(): () => import("@spatial-elements/core").SpatialMessages;
@@ -0,0 +1,10 @@
1
+ import { getContext, setContext } from 'svelte';
2
+ import { resolveSpatialMessages } from '@spatial-elements/core/spatial-element/messages';
3
+ const MESSAGES = Symbol('spatial-messages');
4
+ export function provideSpatialMessages(read) {
5
+ setContext(MESSAGES, read);
6
+ }
7
+ export function useSpatialMessages() {
8
+ const read = getContext(MESSAGES);
9
+ return () => resolveSpatialMessages(read?.());
10
+ }
@@ -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,10 +1,12 @@
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,
9
+ STAGE_PANEL_LAYOUT_EVENT,
8
10
  type StageContext,
9
11
 
10
12
  type StagePanelMinimapOptions,
@@ -23,8 +25,18 @@
23
25
  class?: string;
24
26
  contentClass?: string;
25
27
  minimap?: boolean | StagePanelMinimapOptions;
26
- /** Enables proximity lift and pointer-driven tilt. Defaults to true. */
27
- pointerReactive?: boolean;
28
+ /** true: proximity lift and tilt; 'lift': a 2px mouse-hover lift without tilt; false: still. */
29
+ pointerReactive?: boolean | 'lift';
30
+ /** false keeps the pose; 'top-right' reaches the corner as the surrounding UI clears. */
31
+ focusReactive?: boolean | 'top-right';
32
+ /** Optional neighbouring panel frame whose top-left corner moves with a 'top-right' control. */
33
+ focusAnchor?: HTMLElement;
34
+ /** Retain native DOM layout, including popover semantics, while rendering the glass surface. */
35
+ nativeContent?: boolean;
36
+ /** Position native content in the stage render frame, after projected anchors have moved. */
37
+ nativeLayout?: () => void;
38
+ /** Visibility of an optional native-content panel. */
39
+ visible?: boolean;
28
40
  pose?: StagePanelPose;
29
41
  shape: StagePanelShape;
30
42
  surface?: StagePanelSurface;
@@ -39,6 +51,11 @@
39
51
  contentClass = '',
40
52
  minimap = false,
41
53
  pointerReactive = true,
54
+ focusReactive = true,
55
+ focusAnchor,
56
+ nativeContent = false,
57
+ nativeLayout,
58
+ visible = true,
42
59
  pose,
43
60
  shape,
44
61
  style: contentStyle = '',
@@ -66,6 +83,11 @@
66
83
  getFrameElement: () => frameElement,
67
84
  getSurfaceElement: () => surfaceElement,
68
85
  getPointerReactive: () => pointerReactive,
86
+ getFocusReactive: () => focusReactive,
87
+ getFocusAnchor: () => focusAnchor,
88
+ getNativeContent: () => nativeContent,
89
+ updateNativeLayout: () => nativeLayout?.(),
90
+ getVisible: () => visible,
69
91
  getMinimapOptions: () => getMinimapOptions(),
70
92
  getMinimapDockProgress,
71
93
  getMinimapModelScale,
@@ -76,17 +98,31 @@
76
98
  });
77
99
 
78
100
  onDestroy(unregister);
101
+ $effect(() => {
102
+ getPanelOptions();
103
+ getContentInset();
104
+ Object.values(getMinimapOptions() ?? {});
105
+ void resolvedSurface;
106
+ stage.updatePanelAppearance?.();
107
+ });
108
+ $effect(() => {
109
+ if (nativeContent) {
110
+ void visible;
111
+ window.dispatchEvent(new Event(STAGE_PANEL_LAYOUT_EVENT));
112
+ }
113
+ });
79
114
 
80
115
  onMount(() => {
81
116
  if (!getMinimapOptions()) return;
117
+ const minimapContent = contentElement;
82
118
 
83
119
  const resetView = (event: MouseEvent) => {
84
120
  if (event.defaultPrevented || event.button !== 0) return;
85
121
  stage.resetView();
86
122
  };
87
123
 
88
- contentElement.addEventListener('click', resetView);
89
- return () => contentElement.removeEventListener('click', resetView);
124
+ minimapContent.addEventListener('click', resetView);
125
+ return () => minimapContent.removeEventListener('click', resetView);
90
126
  });
91
127
 
92
128
  function getContentInset() {
@@ -153,9 +189,6 @@
153
189
  `--stage-panel-thickness: ${thickness}`,
154
190
  `--stage-panel-bezel: ${bezel}px`,
155
191
  `--stage-panel-opacity: ${clamp(theme.opacity ?? 1, 0, 1)}`,
156
- '--stage-panel-surface-opacity: 1',
157
- '--stage-panel-focus-opacity: 1',
158
- '--stage-panel-content-opacity: 1',
159
192
  `--stage-panel-css-blur: ${Math.min(backdropBlur, 100)}px`
160
193
  ];
161
194
 
@@ -215,11 +248,15 @@
215
248
  function clamp(value: number, min: number, max: number) {
216
249
  return Math.min(Math.max(value, min), max);
217
250
  }
251
+ // SSR styles are static; the action patches only authored properties after hydration.
252
+ const initialFallbackStyle = untrack(getFallbackStyle);
253
+ const initialContentStyle = untrack(getContentThemeStyle);
218
254
  </script>
219
255
 
220
256
  <div
221
257
  bind:this={frameElement}
222
258
  data-stage-panel-fallback
259
+ data-stage-panel-native-content={nativeContent ? '' : undefined}
223
260
  data-catalog-transition-group={transitionGroup}
224
261
  data-stage-panel-minimap={minimap ? '' : undefined}
225
262
  data-stage-minimap-docked-view-scale={getMinimapOptions()?.dockedView?.scale}
@@ -227,7 +264,8 @@
227
264
  class={[frameClass, 'stage-panel-fallback', pose ? 'stage-panel-posed' : '']
228
265
  .filter(Boolean)
229
266
  .join(' ')}
230
- style={getFallbackStyle()}
267
+ style={initialFallbackStyle}
268
+ use:authoredStyle={getFallbackStyle()}
231
269
  >
232
270
  <div
233
271
  bind:this={surfaceElement}
@@ -236,16 +274,21 @@
236
274
  data-stage-panel-minimap={minimap ? '' : undefined}
237
275
  data-stage-panel-surface={resolvedSurface}
238
276
  class="stage-panel-surface"
239
- style={getFallbackStyle()}
277
+ style={initialFallbackStyle}
278
+ data-stage-panel-authored-style={getFallbackStyle()}
279
+ use:authoredStyle={getFallbackStyle()}
240
280
  >
241
281
  <div
242
282
  {...rest}
243
283
  bind:this={contentElement}
244
284
  use:registerEndpoint={catalogEndpoint}
245
285
  data-stage-panel-content
286
+ data-stage-corner-control={focusReactive === 'top-right' ? '' : undefined}
246
287
  data-catalog-transition-group={transitionGroup}
247
288
  class={contentClass}
248
- style={getContentThemeStyle()}
289
+ style={initialContentStyle}
290
+ data-stage-panel-authored-style={getContentThemeStyle()}
291
+ use:authoredStyle={getContentThemeStyle()}
249
292
  >
250
293
  {@render children?.()}
251
294
  </div>
@@ -10,8 +10,18 @@ type Props = Omit<StagePanelAttributes, 'class'> & {
10
10
  class?: string;
11
11
  contentClass?: string;
12
12
  minimap?: boolean | StagePanelMinimapOptions;
13
- /** Enables proximity lift and pointer-driven tilt. Defaults to true. */
14
- pointerReactive?: boolean;
13
+ /** true: proximity lift and tilt; 'lift': a 2px mouse-hover lift without tilt; false: still. */
14
+ pointerReactive?: boolean | 'lift';
15
+ /** false keeps the pose; 'top-right' reaches the corner as the surrounding UI clears. */
16
+ focusReactive?: boolean | 'top-right';
17
+ /** Optional neighbouring panel frame whose top-left corner moves with a 'top-right' control. */
18
+ focusAnchor?: HTMLElement;
19
+ /** Retain native DOM layout, including popover semantics, while rendering the glass surface. */
20
+ nativeContent?: boolean;
21
+ /** Position native content in the stage render frame, after projected anchors have moved. */
22
+ nativeLayout?: () => void;
23
+ /** Visibility of an optional native-content panel. */
24
+ visible?: boolean;
15
25
  pose?: StagePanelPose;
16
26
  shape: StagePanelShape;
17
27
  surface?: StagePanelSurface;
@@ -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(
@@ -507,9 +542,9 @@
507
542
  await Promise.resolve();
508
543
  };
509
544
 
510
- const setView = async (view: StageVisualTestView) => {
545
+ const setView = async (view: StageVisualTestView, frames = 18) => {
511
546
  experience?.setVisualTestView(view);
512
- await settle(18);
547
+ await settle(frames);
513
548
  };
514
549
  const setSpaceMouseZoom = async (zoom: number) => {
515
550
  experience?.setVisualTestSpaceMouseZoom(zoom);
@@ -554,8 +589,10 @@
554
589
  driveSpaceMouseZoom,
555
590
  stopSpaceMouse,
556
591
  getMinimapRect: () => experience?.getVisualTestMinimapRect() ?? null,
592
+ getPanelRect: (frame) => experience?.getVisualTestPanelRect(frame) ?? null,
557
593
  getModelRect: () => experience?.getVisualTestModelRect() ?? null,
558
594
  getMinimapModelRect: () => experience?.getVisualTestMinimapModelRect() ?? null,
595
+ getMinimapViewportRect: () => experience?.getVisualTestMinimapViewportRect() ?? null,
559
596
  getMinimapOrientation: () => experience?.getVisualTestMinimapOrientation() ?? null,
560
597
  getMinimapRenderStats: () =>
561
598
  experience?.getVisualTestMinimapRenderStats() ?? {
@@ -617,11 +654,16 @@
617
654
  getMinimapModelScale: panel.getMinimapModelScale,
618
655
  getMinimapModelTop: panel.getMinimapModelTop,
619
656
  getSurfaceOpacity: panel.getSurfaceOpacity,
657
+ getVisible: panel.getVisible,
658
+ getFocusAnchor: panel.getFocusAnchor,
659
+ updateNativeLayout: panel.updateNativeLayout,
660
+ nativeContent: panel.getNativeContent?.() ?? false,
620
661
  minimap: panel.getMinimapOptions(),
621
662
  options: panel.getOptions(),
622
663
  surface: panel.getSurface(),
623
664
  surfaceElement,
624
- pointerReactive: panel.getPointerReactive()
665
+ pointerReactive: panel.getPointerReactive(),
666
+ focusReactive: panel.getFocusReactive?.() ?? true
625
667
  });
626
668
  });
627
669
 
@@ -655,7 +697,7 @@
655
697
  >
656
698
  <div bind:this={virtualScrollSpacer} class="stage-virtual-scroll-spacer" aria-hidden="true"></div>
657
699
 
658
- <div class="stage-virtual-viewport">
700
+ <div class="stage-virtual-viewport" inert={fullscreen}>
659
701
  <div
660
702
  bind:this={domLayer}
661
703
  class="stage-dom-layer"
@@ -692,6 +734,19 @@
692
734
  background: var(--stage-page-background, #ffffff);
693
735
  }
694
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
+
695
750
  .stage-virtual-scroll-spacer {
696
751
  display: none;
697
752
  width: 1px;
@@ -784,12 +839,17 @@
784
839
  pointer-events: none !important;
785
840
  }
786
841
 
787
- :global(.stage.stage-enhanced [data-stage-panel-fallback][data-stage-panel-bound]) {
842
+ :global(.stage.stage-enhanced [data-stage-panel-fallback][data-stage-panel-bound]:not([data-stage-panel-native-content])) {
788
843
  visibility: hidden !important;
789
844
  opacity: 0 !important;
790
845
  pointer-events: none !important;
791
846
  }
792
847
 
848
+ :global(.stage.stage-enhanced [data-stage-panel-native-content][data-stage-panel-bound][data-stage-panel-surface='glass'] > .stage-panel-surface::before),
849
+ :global(.stage.stage-enhanced [data-stage-panel-native-content][data-stage-panel-bound][data-stage-panel-surface='glass'] > .stage-panel-surface::after) {
850
+ display: none;
851
+ }
852
+
793
853
  /* A failed binding may leave pixels in either canvas; the poster owns fallback paint. */
794
854
  .stage.stage-fallback :global(.stage-webgpu-background),
795
855
  .stage.stage-fallback :global(.stage-webgpu-carousel-rear),
@@ -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
+ }