@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
@@ -0,0 +1,286 @@
1
+ <script lang="ts">
2
+ import { getContext, onMount, tick } from 'svelte';
3
+ import { CircleHelp, X } from 'lucide-svelte';
4
+ import InteractionGesture from './InteractionGesture.svelte';
5
+ import { getCssPanelBoxShadow } from '@spatial-elements/core/stage/panelShadow';
6
+ import { getInteractionGuidance, MODEL_INPUT_EVENT, type ModelInputState, type InteractionGuidance } from '@spatial-elements/core/stage/interactionGuidance';
7
+ import { STAGE_SCROLL_PRIORITY, subscribeStageScrollFrame } from '@spatial-elements/core/stage/scrollFrame';
8
+ import { STAGE_CONTEXT_KEY, STAGE_PANEL_LAYOUT_EVENT, type StageContext } from '@spatial-elements/core/stage/panelContext';
9
+ import SpatialElementViewToggle from './SpatialElementViewToggle.svelte';
10
+ import Panel from '../stage/Panel.svelte';
11
+ import SpatialIconButton from './SpatialIconButton.svelte';
12
+ import { useSpatialTheme } from './brandContext.js';
13
+ import { useSpatialMessages } from './messagesContext.js';
14
+
15
+ const readTheme = useSpatialTheme();
16
+ const theme = $derived(readTheme());
17
+ const stageContext = getContext<StageContext>(STAGE_CONTEXT_KEY);
18
+ const fullscreen = $derived(stageContext.isFullscreen?.() ?? false);
19
+ const readMessages = useSpatialMessages();
20
+ const messages = $derived(readMessages());
21
+ const help = $derived(messages.interactionHelp);
22
+ const id = $props.id();
23
+ let root: HTMLDivElement;
24
+ let focusAnchor = $state<HTMLElement>();
25
+ let button = $state<HTMLButtonElement>(null!);
26
+ let popover: HTMLDivElement;
27
+ let closeButton: HTMLButtonElement;
28
+ let open = $state(false);
29
+ let enhanced = $state(false);
30
+ let visible = false;
31
+ let interacted = $state(false);
32
+ let touchInput = $state(false);
33
+ let guidance: InteractionGuidance | undefined;
34
+ let delay: ReturnType<typeof setTimeout> | undefined;
35
+ let hideDelay: ReturnType<typeof setTimeout> | undefined;
36
+ let manual = false;
37
+ let helpHovered = false;
38
+ let buttonHovered = false;
39
+ let modelInput: ModelInputState = { hovered: false, active: false };
40
+ const surfaceStyle = $derived([
41
+ `--help-tint: ${typeof theme.panelTheme.tint === 'number' ? '#' + theme.panelTheme.tint.toString(16).padStart(6, '0') : theme.panelTheme.tint ?? '#ffffff'}`,
42
+ `--help-tint-opacity: ${(theme.panelTheme.tintOpacity ?? 0.65) * 100}%`,
43
+ `--help-blur: ${Math.min(100, Math.max(0, theme.panelTheme.backdropBlur ?? 8))}px`,
44
+ `--help-shadow: ${getCssPanelBoxShadow(theme.panelTheme.shadowIntensity ?? 0.2)}`,
45
+ `--help-radius: ${theme.panelShape.radius}px`
46
+ ].join(';'));
47
+
48
+ function clearDelay() { clearTimeout(delay); delay = undefined; }
49
+ function clearHideDelay() { clearTimeout(hideDelay); hideDelay = undefined; }
50
+ function close(returnFocus = false) {
51
+ clearDelay(); clearHideDelay();
52
+ if (!open) return;
53
+ const restoreFocus = returnFocus && popover.contains(document.activeElement);
54
+ popover.hidePopover();
55
+ open = false;
56
+ manual = false;
57
+ helpHovered = false;
58
+ if (restoreFocus) button.focus({ preventScroll: true });
59
+ }
60
+ function position() {
61
+ if (!open) return;
62
+ const rect = button.getBoundingClientRect();
63
+ const viewport = window.visualViewport;
64
+ const leftEdge = (viewport?.offsetLeft ?? 0) + 16;
65
+ const topEdge = (viewport?.offsetTop ?? 0) + 16;
66
+ const width = Math.min(viewport?.width ?? window.innerWidth, document.documentElement.clientWidth);
67
+ const height = Math.min(viewport?.height ?? window.innerHeight, document.documentElement.clientHeight);
68
+ popover.style.maxWidth = `${Math.max(0, width - 32)}px`;
69
+ popover.style.maxHeight = `${Math.max(0, height - 32)}px`;
70
+ popover.style.setProperty('--help-max-height', `${Math.max(0, height - 32)}px`);
71
+ const box = popover.getBoundingClientRect();
72
+ const left = Math.max(leftEdge, Math.min(rect.right - box.width, leftEdge + width - 32 - box.width));
73
+ const below = rect.bottom + 12;
74
+ const top = below + box.height <= topEdge + height - 32 ? below : Math.max(topEdge, rect.top - box.height - 12);
75
+ const nextLeft = `${left}px`, nextTop = `${top}px`;
76
+ if (popover.style.left !== nextLeft || popover.style.top !== nextTop) {
77
+ popover.style.left = nextLeft;
78
+ popover.style.top = nextTop;
79
+ }
80
+ }
81
+ function requestPosition() {
82
+ if (open) window.dispatchEvent(new Event(STAGE_PANEL_LAYOUT_EVENT));
83
+ }
84
+ async function show(keyboard = false) {
85
+ if (!enhanced || (!visible && !fullscreen)) return;
86
+ clearDelay(); clearHideDelay();
87
+ popover.showPopover();
88
+ open = true;
89
+ await tick();
90
+ if (!open || !enhanced) return;
91
+ requestPosition();
92
+ if (keyboard) closeButton.focus({ preventScroll: true });
93
+ }
94
+ function toggleHelp(event: MouseEvent) {
95
+ if (open) close();
96
+ else {
97
+ manual = true;
98
+ void show(event.detail === 0);
99
+ }
100
+ }
101
+ function schedule() {
102
+ clearDelay(); clearHideDelay();
103
+ if (manual || !enhanced || !visible || modelInput.active || touchInput || guidance?.snapshot.interacted) return;
104
+ if (modelInput.hovered) {
105
+ if (!open) delay = setTimeout(() => { void show(); }, 600);
106
+ } else if (open && !helpHovered && !buttonHovered && !popover.contains(document.activeElement)) {
107
+ hideDelay = setTimeout(() => close(), 350);
108
+ }
109
+ }
110
+
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;
115
+ guidance = getInteractionGuidance();
116
+ touchInput = window.matchMedia('(pointer: coarse)').matches;
117
+ const stopGuidance = guidance.subscribe((state) => {
118
+ interacted = state.interacted;
119
+ if (state.interacted) close();
120
+ });
121
+ const stage = root.closest<HTMLElement>('.stage')!;
122
+ focusAnchor = root.closest('.spatial-element-hero')?.querySelector<HTMLElement>('.spatial-element-panel') ?? undefined;
123
+ // Keep the non-modal help accessible when close-up hides the ordinary DOM layer.
124
+ stage.appendChild(popover);
125
+ // Measure the nearest wide panel above the hero, without relying on a host CSS class.
126
+ const top = root.getBoundingClientRect().top;
127
+ const header = Array.from(stage.querySelectorAll<HTMLElement>('[data-stage-panel-fallback]'))
128
+ .filter((node) => { const rect = node.getBoundingClientRect(); return rect.width > innerWidth * 0.4 && rect.bottom <= top && rect.height > 0; })
129
+ .sort((a, b) => b.getBoundingClientRect().bottom - a.getBoundingClientRect().bottom)[0];
130
+ const measureSpacing = () => {
131
+ if (header && !fullscreen) {
132
+ const gap = Math.max(16, root.getBoundingClientRect().top - header.getBoundingClientRect().bottom - 12);
133
+ root.style.setProperty('--model-tools-gap', `${gap}px`);
134
+ }
135
+ requestPosition();
136
+ };
137
+ measureSpacing();
138
+ const headerSize = new ResizeObserver(measureSpacing);
139
+ if (header) headerSize.observe(header);
140
+ const stageChanged = () => {
141
+ enhanced = stage.dataset.stageState === 'enhanced' && !stage.hasAttribute('data-catalog-transition');
142
+ if (!enhanced) close();
143
+ };
144
+ stageChanged();
145
+ const mutation = new MutationObserver(stageChanged);
146
+ mutation.observe(stage, { attributes: true, attributeFilter: ['data-stage-state', 'data-catalog-transition'] });
147
+ const observer = new IntersectionObserver(([entry]) => {
148
+ visible = entry.isIntersecting;
149
+ if (!visible) close();
150
+ });
151
+ observer.observe(root);
152
+ const size = new ResizeObserver(requestPosition);
153
+ size.observe(popover);
154
+ const modelChanged = (event: Event) => {
155
+ modelInput = (event as CustomEvent<ModelInputState>).detail;
156
+ if (modelInput.active) close();
157
+ schedule();
158
+ };
159
+ const inputChanged = (event: PointerEvent) => {
160
+ if (!event.isTrusted) return;
161
+ const next = event.pointerType !== 'mouse';
162
+ if (next !== touchInput) { touchInput = next; if (next) { clearDelay(); clearHideDelay(); if (!manual) close(); } }
163
+ };
164
+ const buttonEnter = (event: PointerEvent) => { buttonHovered = event.pointerType === 'mouse'; schedule(); };
165
+ const buttonLeave = () => { buttonHovered = false; schedule(); };
166
+ const keydown = (event: KeyboardEvent) => {
167
+ if (event.key === 'Escape' && open) { event.preventDefault(); close(true); }
168
+ };
169
+ const stopScroll = subscribeStageScrollFrame(() => {
170
+ if (!open) return;
171
+ const rect = helpButton.getBoundingClientRect();
172
+ if (rect.bottom < 0 || rect.top > innerHeight) close();
173
+ else requestPosition();
174
+ }, STAGE_SCROLL_PRIORITY.stage + 1);
175
+ stage.addEventListener(MODEL_INPUT_EVENT, modelChanged);
176
+ helpButton.addEventListener('pointerenter', buttonEnter);
177
+ helpButton.addEventListener('pointerleave', buttonLeave);
178
+ window.addEventListener('pointerdown', inputChanged, { capture: true, passive: true });
179
+ window.addEventListener('pointermove', inputChanged, { capture: true, passive: true });
180
+ window.addEventListener('keydown', keydown);
181
+ window.addEventListener('resize', measureSpacing, { passive: true });
182
+ window.visualViewport?.addEventListener('resize', requestPosition, { passive: true });
183
+ window.visualViewport?.addEventListener('scroll', requestPosition, { passive: true });
184
+ return () => {
185
+ // A queued focusout microtask must not restart the hover timer after teardown.
186
+ enhanced = false; visible = false;
187
+ close(); stopGuidance(); stopScroll(); mutation.disconnect(); observer.disconnect(); size.disconnect(); headerSize.disconnect();
188
+ root.appendChild(popover);
189
+ stage.removeEventListener(MODEL_INPUT_EVENT, modelChanged);
190
+ helpButton.removeEventListener('pointerenter', buttonEnter);
191
+ helpButton.removeEventListener('pointerleave', buttonLeave);
192
+ window.removeEventListener('pointerdown', inputChanged, true);
193
+ window.removeEventListener('pointermove', inputChanged, true);
194
+ window.removeEventListener('keydown', keydown);
195
+ window.removeEventListener('resize', measureSpacing);
196
+ window.visualViewport?.removeEventListener('resize', requestPosition);
197
+ window.visualViewport?.removeEventListener('scroll', requestPosition);
198
+ };
199
+ });
200
+ </script>
201
+
202
+ <div bind:this={root} class="model-tools" class:enhanced style={surfaceStyle} data-spatial-element-tools>
203
+ <div class="model-tools-buttons">
204
+ <SpatialIconButton bind:element={button} {focusAnchor} label={messages.controls.help} onclick={toggleHelp} expanded={open} controls={id} enabled={enhanced}>
205
+ <CircleHelp size={21} strokeWidth={1.8} aria-hidden="true" />
206
+ </SpatialIconButton>
207
+ <SpatialElementViewToggle enabled={enhanced} {focusAnchor} onchange={() => close()} />
208
+ </div>
209
+ {#if enhanced && touchInput && !interacted && !open && !fullscreen}
210
+ <p class="touch-hint" data-spatial-element-touch-hint>{help.touchHint}</p>
211
+ {/if}
212
+ <div bind:this={popover} {id} popover="auto" role="dialog" tabindex="-1" aria-modal="false" aria-labelledby={`${id}-title`}
213
+ style={surfaceStyle}
214
+ class="interaction-help" data-spatial-element-help data-surface={theme.panelTheme.surface ?? 'glass'}
215
+ onpointerenter={(event) => { helpHovered = event.pointerType === 'mouse'; schedule(); }}
216
+ onpointerleave={() => { helpHovered = false; schedule(); }}
217
+ onfocusin={clearHideDelay} onfocusout={() => { queueMicrotask(schedule); }}
218
+ ontoggle={(event) => { open = event.newState === 'open'; if (!open) { manual = false; clearHideDelay(); } }}>
219
+ <Panel class="interaction-help-panel" data-stage-fullscreen-visible nativeContent nativeLayout={position} visible={open} pointerReactive={false} focusReactive={false}
220
+ shape={{ ...theme.panelShape, contentInset: 0 }} theme={theme.panelTheme}>
221
+ <div class="help-copy">
222
+ <div class="help-heading">
223
+ <h2 id={`${id}-title`}>{help.title}</h2>
224
+ <button bind:this={closeButton} type="button" class="close-help" onclick={() => close(true)}
225
+ aria-label={messages.controls.closeHelp} title={messages.controls.closeHelp}>
226
+ <X size={19} aria-hidden="true" />
227
+ </button>
228
+ </div>
229
+ <dl>
230
+ <div><InteractionGesture action="rotate" touch={touchInput} /><dt>{help.rotate}</dt><dd>{touchInput ? help.touchRotate : help.mouseRotate}</dd></div>
231
+ <div><InteractionGesture action="zoom" touch={touchInput} /><dt>{help.zoom}</dt><dd>{touchInput ? help.touchZoom : help.mouseZoom}</dd></div>
232
+ <div><InteractionGesture action="pan" touch={touchInput} /><dt>{help.pan}</dt><dd>{touchInput ? help.touchPan : help.mousePan}</dd></div>
233
+ </dl>
234
+ <p class="navigation-hint">
235
+ {#if touchInput}
236
+ {#if !fullscreen}{help.touchScrollHint}{/if}
237
+ {:else}
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}
239
+ {/if}
240
+ </p>
241
+ </div>
242
+ </Panel>
243
+ </div>
244
+ </div>
245
+
246
+ <style>
247
+ .model-tools {
248
+ grid-column: 1; grid-row: 1; align-self: start; justify-self: end; position: relative;
249
+ margin-top: 6px; margin-inline-end: calc(var(--model-tools-gap, 32px) - var(--spatial-element-hero-column-gap));
250
+ width: 128px; height: 40px; z-index: 6; visibility: hidden; pointer-events: none;
251
+ }
252
+ .model-tools.enhanced { visibility: visible; pointer-events: auto; }
253
+ .model-tools-buttons { display: flex; gap: 8px; justify-content: flex-end; }
254
+ .touch-hint {
255
+ position: absolute; right: 0; top: 48px; width: max-content; max-width: min(260px, calc(100vw - 48px));
256
+ margin: 0; padding: 8px 12px; border-radius: 10px; font-size: 12px; line-height: 1.45;
257
+ color: var(--spatial-element-ink); pointer-events: none;
258
+ background: color-mix(in srgb, var(--help-tint) var(--help-tint-opacity), transparent);
259
+ backdrop-filter: blur(var(--help-blur)); box-shadow: var(--help-shadow);
260
+ }
261
+ .interaction-help {
262
+ position: fixed; inset: auto; box-sizing: border-box; width: 248px;
263
+ margin: 0; padding: 0; overflow: visible;
264
+ border: 0; border-radius: var(--help-radius); color: var(--spatial-element-ink);
265
+ background: transparent;
266
+ font: inherit; font-size: 14px; line-height: 1.45; touch-action: manipulation;
267
+ }
268
+ .help-copy { box-sizing: border-box; padding: 12px 16px 16px; max-height: var(--help-max-height); overflow: auto; border-radius: var(--help-radius); }
269
+ .interaction-help::backdrop { background: transparent; pointer-events: none; }
270
+ .help-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
271
+ h2 { margin: 0; font-size: 15px; font-weight: 650; }
272
+ .close-help {
273
+ width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center;
274
+ padding: 0; border: 0; border-radius: 8px; color: inherit; background: transparent; cursor: pointer;
275
+ }
276
+ .close-help:focus-visible { outline: 2px solid var(--spatial-element-accent); }
277
+ dl { display: grid; gap: 8px; margin: 8px 0 0; }
278
+ dl > div { display: grid; grid-template-columns: 48px 1fr; column-gap: 14px; align-items: center; }
279
+ dt { font-weight: 650; }
280
+ /* Keep complete host-localized instructions available to assistive technology. */
281
+ dd { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
282
+ .navigation-hint { margin: 16px 0 0; padding-top: 12px; border-top: 1px solid currentColor; font-size: 12px; }
283
+ .navigation-hint a { color: var(--spatial-element-accent); text-decoration: underline; text-underline-offset: 2px; }
284
+ .navigation-hint a:focus-visible { outline: 2px solid var(--spatial-element-accent); outline-offset: 3px; border-radius: 2px; }
285
+ @media (max-width: 1100px) { .model-tools { margin-inline-end: 0; } }
286
+ </style>
@@ -0,0 +1,3 @@
1
+ declare const SpatialElementHelp: import("svelte").Component<Record<string, never>, {}, "">;
2
+ type SpatialElementHelp = ReturnType<typeof SpatialElementHelp>;
3
+ export default SpatialElementHelp;
@@ -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,
@@ -16,6 +16,7 @@
16
16
  import { useSpatialTheme } from './brandContext.js';
17
17
  import SpatialElementMediaRail from './SpatialElementMediaRail.svelte';
18
18
  import SpatialElementSummaryPanel from './SpatialElementSummaryPanel.svelte';
19
+ import SpatialElementHelp from './SpatialElementHelp.svelte';
19
20
  import SpatialElementStickyHeader from './SpatialElementStickyHeader.svelte';
20
21
  import SpatialElementTabs from './SpatialElementTabs.svelte';
21
22
  import { SpatialElementDockController } from '@spatial-elements/core/spatial-element/SpatialElementDockController';
@@ -38,7 +39,8 @@
38
39
  children?: Snippet;
39
40
  }
40
41
  let { spatialElement: element, children }: Props = $props();
41
- const brand = useSpatialTheme();
42
+ const readTheme = useSpatialTheme();
43
+ const brand = $derived(readTheme());
42
44
  const spatialElement = $derived(resolveSpatialElementData(element, brand.id));
43
45
  // During route teardown Kit can clear the outgoing page's data before unmount.
44
46
  // Read raw assets here, so the parent stage never evaluates outgoing DOM-derived content.
@@ -178,6 +180,7 @@
178
180
  aria-hidden={spatialElement.fallbackImage ? undefined : 'true'}
179
181
  />
180
182
 
183
+ {#key spatialElement.id}<SpatialElementHelp />{/key}
181
184
  <SpatialElementSummaryPanel {spatialElement} />
182
185
  </section>
183
186
 
@@ -200,11 +203,12 @@
200
203
  }
201
204
 
202
205
  .spatial-element-hero {
206
+ --spatial-element-hero-column-gap: clamp(28px, 4vw, 70px);
203
207
  position: relative;
204
208
  box-sizing: border-box;
205
209
  display: grid;
206
210
  grid-template-columns: minmax(420px, 1fr) minmax(360px, 494px);
207
- gap: clamp(28px, 4vw, 70px);
211
+ gap: var(--spatial-element-hero-column-gap);
208
212
  align-items: start;
209
213
  width: calc(100vw - var(--spatial-element-hero-edge-gap) - var(--spatial-element-hero-edge-gap));
210
214
  min-height: clamp(610px, calc(100vh - 230px), 760px);
@@ -231,6 +235,11 @@
231
235
  margin-top: 8px;
232
236
  }
233
237
 
238
+ .spatial-element-hero :global(.spatial-element-visual) {
239
+ grid-column: 1;
240
+ grid-row: 1;
241
+ }
242
+
234
243
  :global(.spatial-element-visual) {
235
244
  min-height: clamp(540px, calc(100vh - 300px), 680px);
236
245
  border-radius: 28px;
@@ -1,5 +1,7 @@
1
1
  <script lang="ts">
2
+ import { onMount } from 'svelte';
2
3
  import { catalogActionSemantic } from '@spatial-elements/core/catalog/catalogAction';
4
+ import { mouseHover } from '@spatial-elements/core/stage/mouseHover';
3
5
  import { ShoppingCart } from 'lucide-svelte';
4
6
  import Panel from '../stage/Panel.svelte';
5
7
  import { useSpatialTheme } from './brandContext.js';
@@ -7,11 +9,27 @@
7
9
  import { createCatalogEndpointAction } from '../catalog/catalogEndpointAction.js';
8
10
 
9
11
  let { spatialElement }: { spatialElement: SpatialElementData } = $props();
10
- const theme = useSpatialTheme();
12
+ const readTheme = useSpatialTheme();
13
+ const theme = $derived(readTheme());
11
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
+ });
12
30
  </script>
13
31
 
14
- <div class="spatial-element-aside">
32
+ <div class="spatial-element-aside" style:--summary-panel-height={panelHeight === undefined ? undefined : `${panelHeight}px`}>
15
33
  <Panel
16
34
  catalogEndpoint={{
17
35
  brandId: theme.id,
@@ -29,7 +47,7 @@
29
47
  data-shared-role="summary-surface"
30
48
  data-spatial-element-id={spatialElement.id}
31
49
  >
32
- <div class="summary-presentation">
50
+ <div bind:this={presentation} class="summary-presentation" style:min-height={`${Math.max(504 - contentInset * 2, 0)}px`} use:mouseHover>
33
51
  <div class="panel-copy">
34
52
  <p
35
53
  class="panel-kicker"
@@ -152,14 +170,15 @@
152
170
  }
153
171
 
154
172
  .spatial-element-aside {
173
+ position: relative;
155
174
  min-height: inherit;
156
175
  }
157
176
 
158
177
  :global(.spatial-element-panel) {
159
- position: relative;
160
- top: 0;
178
+ position: sticky;
179
+ top: var(--spatial-element-summary-sticky-top, 104px);
161
180
  width: min(494px, 100%);
162
- height: 504px;
181
+ height: var(--summary-panel-height, auto);
163
182
  min-height: 504px;
164
183
  pointer-events: auto;
165
184
  }
@@ -182,8 +201,7 @@
182
201
  --summary-action-depth: 76;
183
202
  --summary-action-hover-depth: 24;
184
203
 
185
- position: absolute;
186
- inset: 0;
204
+ position: relative;
187
205
  box-sizing: border-box;
188
206
  display: flex;
189
207
  flex-direction: column;
@@ -264,7 +282,7 @@
264
282
  will-change: transform;
265
283
  }
266
284
 
267
- .feature-list li:hover .feature-content {
285
+ .summary-presentation:global([data-mouse-hover]) .feature-list li:hover .feature-content {
268
286
  --summary-feature-hover-progress: 1;
269
287
  }
270
288
 
@@ -287,7 +305,8 @@
287
305
  transform-style: preserve-3d;
288
306
  }
289
307
 
290
- .spatial-element-action:is(:hover, :focus-visible) .spatial-element-action-surface {
308
+ .summary-presentation:global([data-mouse-hover]) .spatial-element-action:hover .spatial-element-action-surface,
309
+ .spatial-element-action:focus-visible .spatial-element-action-surface {
291
310
  --summary-action-hover-progress: 1;
292
311
  }
293
312
 
@@ -408,9 +427,10 @@
408
427
  }
409
428
 
410
429
  .feature-content,
411
- .feature-list li:hover .feature-content,
430
+ .summary-presentation:global([data-mouse-hover]) .feature-list li:hover .feature-content,
412
431
  .spatial-element-action-surface,
413
- .spatial-element-action:is(:hover, :focus-visible) .spatial-element-action-surface {
432
+ .summary-presentation:global([data-mouse-hover]) .spatial-element-action:hover .spatial-element-action-surface,
433
+ .spatial-element-action:focus-visible .spatial-element-action-surface {
414
434
  --summary-feature-hover-progress: 0;
415
435
  --summary-action-hover-progress: 0;
416
436
  transition: none;
@@ -418,7 +438,9 @@
418
438
  }
419
439
 
420
440
  @media (max-width: 1100px) {
441
+ .spatial-element-aside { min-height: 0; }
421
442
  :global(.spatial-element-panel) {
443
+ position: relative;
422
444
  top: auto;
423
445
  }
424
446
  }
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { onMount } from 'svelte';
3
+ import { mouseHover } from '@spatial-elements/core/stage/mouseHover';
3
4
  import {
4
5
  STAGE_ANCHOR_SCROLL_DURATION_MS,
5
6
  STAGE_ANCHOR_SCROLL_EASING
@@ -81,6 +82,7 @@
81
82
  </script>
82
83
 
83
84
  <nav
85
+ use:mouseHover
84
86
  class="spatial-element-tab-list"
85
87
  data-spatial-element-tab-list={variant}
86
88
  aria-label="Elementbereiche"
@@ -218,7 +220,7 @@
218
220
  visibility: hidden;
219
221
  }
220
222
 
221
- a:hover:not([aria-current='location']) {
223
+ .spatial-element-tab-list:global([data-mouse-hover]) a:hover:not([aria-current='location']) {
222
224
  background: color-mix(in srgb, var(--spatial-element-body) 8%, transparent);
223
225
  }
224
226
 
@@ -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;
@@ -0,0 +1,57 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import { mouseHover } from '@spatial-elements/core/stage/mouseHover';
4
+ import Panel from '../stage/Panel.svelte';
5
+ import { useSpatialTheme } from './brandContext.js';
6
+
7
+ let { label, children, onclick, expanded, controls, focusAnchor, enabled = true, element = $bindable() }: {
8
+ label: string;
9
+ children: Snippet;
10
+ onclick: (event: MouseEvent) => void;
11
+ expanded?: boolean;
12
+ controls?: string;
13
+ focusAnchor?: HTMLElement;
14
+ enabled?: boolean;
15
+ element?: HTMLButtonElement;
16
+ } = $props();
17
+ const readTheme = useSpatialTheme();
18
+ const theme = $derived(readTheme());
19
+ </script>
20
+
21
+ <div class="icon-frame">
22
+ <Panel
23
+ class="spatial-icon-panel"
24
+ shape={{ radius: Math.min(12, theme.panelShape.radius), contentInset: 0 }}
25
+ theme={theme.panelTheme}
26
+ pointerReactive={false}
27
+ focusReactive="top-right"
28
+ {focusAnchor}
29
+ transitionGroup="enter"
30
+ >
31
+ <!-- Keep visibility on the button: Panel's content style also holds renderer positioning. -->
32
+ <button bind:this={element} use:mouseHover type="button" {onclick} aria-label={label} title={label}
33
+ disabled={!enabled}
34
+ style:visibility={enabled ? 'visible' : 'hidden'}
35
+ aria-expanded={expanded} aria-controls={controls} aria-haspopup={controls ? 'dialog' : undefined}
36
+ class="spatial-icon-button">
37
+ {@render children()}
38
+ </button>
39
+ </Panel>
40
+ </div>
41
+
42
+ <style>
43
+ .icon-frame { width: 40px; height: 40px; flex: 0 0 40px; }
44
+ /* The renderer moves panel contents into its projection layer; retain the anchor size. */
45
+ .icon-frame :global(.spatial-icon-panel) { width: 40px; height: 40px; }
46
+ .spatial-icon-button {
47
+ box-sizing: border-box; display: grid; place-items: center; width: 40px; height: 40px;
48
+ padding: 0; border: 0; border-radius: min(12px, var(--spatial-element-panel-radius)); background: transparent;
49
+ color: var(--spatial-element-ink); cursor: pointer; touch-action: manipulation;
50
+ transition: background-color 180ms ease;
51
+ }
52
+ .spatial-icon-button:global([data-mouse-hover]):hover {
53
+ background: color-mix(in srgb, var(--spatial-element-body) 8%, transparent);
54
+ }
55
+ .spatial-icon-button:focus-visible { outline: 2px solid var(--spatial-element-accent); outline-offset: 3px; }
56
+ @media (prefers-reduced-motion: reduce) { .spatial-icon-button { transition: none; } }
57
+ </style>
@@ -0,0 +1,14 @@
1
+ import type { Snippet } from 'svelte';
2
+ type $$ComponentProps = {
3
+ label: string;
4
+ children: Snippet;
5
+ onclick: (event: MouseEvent) => void;
6
+ expanded?: boolean;
7
+ controls?: string;
8
+ focusAnchor?: HTMLElement;
9
+ enabled?: boolean;
10
+ element?: HTMLButtonElement;
11
+ };
12
+ declare const SpatialIconButton: import("svelte").Component<$$ComponentProps, {}, "element">;
13
+ type SpatialIconButton = ReturnType<typeof SpatialIconButton>;
14
+ export default SpatialIconButton;
@@ -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
  }
@@ -1,4 +1,5 @@
1
1
  export { default as BrandStageShell } from './BrandStageShell.svelte';
2
+ export { defaultSpatialMessages, resolveSpatialMessages, type SpatialMessages, type SpatialMessagesInput } 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';