@spatial-elements/sveltekit 0.1.0-beta.2 → 1.0.0-beta.4

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 (41) hide show
  1. package/README.md +11 -3
  2. package/dist/catalog/catalogNavigation.js +3 -2
  3. package/dist/spatial-element/BrandStageShell.svelte +17 -12
  4. package/dist/spatial-element/BrandStageShell.svelte.d.ts +11 -4
  5. package/dist/spatial-element/CarouselSection.svelte +184 -38
  6. package/dist/spatial-element/CarouselSection.svelte.d.ts +5 -0
  7. package/dist/spatial-element/CarouselSpatialElement.svelte +7 -3
  8. package/dist/spatial-element/ContentPage.svelte +11 -1
  9. package/dist/spatial-element/ContentPage.svelte.d.ts +7 -3
  10. package/dist/spatial-element/InteractionGesture.svelte +39 -0
  11. package/dist/spatial-element/InteractionGesture.svelte.d.ts +7 -0
  12. package/dist/spatial-element/ListSection.svelte +11 -3
  13. package/dist/spatial-element/ListSection.svelte.d.ts +5 -3
  14. package/dist/spatial-element/SpatialElementBreadcrumbs.svelte +3 -1
  15. package/dist/spatial-element/SpatialElementCard.svelte +2 -2
  16. package/dist/spatial-element/SpatialElementHelp.svelte +277 -0
  17. package/dist/spatial-element/SpatialElementHelp.svelte.d.ts +3 -0
  18. package/dist/spatial-element/SpatialElementMediaRail.svelte +1 -1
  19. package/dist/spatial-element/SpatialElementMediaRail.svelte.d.ts +1 -1
  20. package/dist/spatial-element/SpatialElementPage.svelte +25 -8
  21. package/dist/spatial-element/SpatialElementPage.svelte.d.ts +5 -3
  22. package/dist/spatial-element/SpatialElementStickyHeader.svelte +42 -37
  23. package/dist/spatial-element/SpatialElementStickyHeader.svelte.d.ts +2 -1
  24. package/dist/spatial-element/SpatialElementSummaryPanel.svelte +60 -55
  25. package/dist/spatial-element/SpatialElementSummaryPanel.svelte.d.ts +1 -1
  26. package/dist/spatial-element/SpatialElementTabList.svelte +3 -1
  27. package/dist/spatial-element/SpatialIconButton.svelte +56 -0
  28. package/dist/spatial-element/SpatialIconButton.svelte.d.ts +14 -0
  29. package/dist/spatial-element/SpatialListPage.svelte +4 -1
  30. package/dist/spatial-element/SpatialListPage.svelte.d.ts +2 -0
  31. package/dist/spatial-element/index.d.ts +5 -1
  32. package/dist/spatial-element/index.js +3 -0
  33. package/dist/spatial-element/messagesContext.d.ts +3 -0
  34. package/dist/spatial-element/messagesContext.js +10 -0
  35. package/dist/spatial-element/spatialPageContext.d.ts +4 -0
  36. package/dist/spatial-element/spatialPageContext.js +9 -0
  37. package/dist/stage/Panel.svelte +30 -2
  38. package/dist/stage/Panel.svelte.d.ts +12 -2
  39. package/dist/stage/Stage.svelte +97 -17
  40. package/dist/stage/Stage.svelte.d.ts +5 -1
  41. package/package.json +4 -4
@@ -1,8 +1,10 @@
1
1
  import type { SpatialListItem, SpatialElementSectionDefinition } from '@spatial-elements/core/spatial-element/types';
2
- type $$ComponentProps = {
2
+ interface Props {
3
+ /** Unique page-local anchor, heading and optional CSS appearance overrides. */
3
4
  section: SpatialElementSectionDefinition;
5
+ /** Project element documents with getSpatialListItems; assets register automatically. */
4
6
  list: SpatialListItem[];
5
- };
6
- declare const ListSection: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ }
8
+ declare const ListSection: import("svelte").Component<Props, {}, "">;
7
9
  type ListSection = ReturnType<typeof ListSection>;
8
10
  export default ListSection;
@@ -1,5 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { resolve } from '$app/paths';
3
+ import { mouseHover } from '@spatial-elements/core/stage/mouseHover';
3
4
  import type { SpatialElementBreadcrumb } from '@spatial-elements/core/spatial-element/types';
4
5
 
5
6
  let {
@@ -9,6 +10,7 @@
9
10
  </script>
10
11
 
11
12
  <nav
13
+ use:mouseHover
12
14
  class="breadcrumbs"
13
15
  data-stage-dom-content
14
16
  aria-label="Breadcrumb"
@@ -56,7 +58,7 @@
56
58
  pointer-events: auto;
57
59
  }
58
60
 
59
- a:hover {
61
+ .breadcrumbs:global([data-mouse-hover]) a:hover {
60
62
  text-decoration: underline;
61
63
  }
62
64
 
@@ -108,13 +108,13 @@
108
108
  data-spatial-element-id={spatialElement.id}
109
109
  data-catalog-slot="catalog.card"
110
110
  >
111
- {#if spatialElement.stage?.fallbackImage}
111
+ {#if spatialElement.fallbackImage}
112
112
  <img
113
113
  class="catalog-poster"
114
114
  data-catalog-poster
115
115
  loading="lazy"
116
116
  decoding="async"
117
- src={spatialElement.stage.fallbackImage}
117
+ src={spatialElement.fallbackImage}
118
118
  alt={`${brand.name} ${spatialElement.title}`}
119
119
  />
120
120
  {/if}
@@ -0,0 +1,277 @@
1
+ <script lang="ts">
2
+ import { 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_PANEL_LAYOUT_EVENT } from '@spatial-elements/core/stage/panelContext';
9
+ import Panel from '../stage/Panel.svelte';
10
+ import SpatialIconButton from './SpatialIconButton.svelte';
11
+ import { useSpatialTheme } from './brandContext.js';
12
+ import { useSpatialMessages } from './messagesContext.js';
13
+
14
+ const theme = useSpatialTheme();
15
+ const readMessages = useSpatialMessages();
16
+ const messages = $derived(readMessages());
17
+ const help = $derived(messages.interactionHelp);
18
+ const id = $props.id();
19
+ let root: HTMLDivElement;
20
+ let focusAnchor = $state<HTMLElement>();
21
+ let button = $state<HTMLButtonElement>(null!);
22
+ let popover: HTMLDivElement;
23
+ let closeButton: HTMLButtonElement;
24
+ let open = $state(false);
25
+ let enhanced = $state(false);
26
+ let visible = false;
27
+ let interacted = $state(false);
28
+ let touchInput = $state(false);
29
+ let guidance: InteractionGuidance | undefined;
30
+ let delay: ReturnType<typeof setTimeout> | undefined;
31
+ let hideDelay: ReturnType<typeof setTimeout> | undefined;
32
+ let manual = false;
33
+ let helpHovered = false;
34
+ let buttonHovered = false;
35
+ let modelInput: ModelInputState = { hovered: false, active: false };
36
+ const surfaceStyle = $derived([
37
+ `--help-tint: ${typeof theme.panelTheme.tint === 'number' ? '#' + theme.panelTheme.tint.toString(16).padStart(6, '0') : theme.panelTheme.tint ?? '#ffffff'}`,
38
+ `--help-tint-opacity: ${(theme.panelTheme.tintOpacity ?? 0.65) * 100}%`,
39
+ `--help-blur: ${Math.min(100, Math.max(0, theme.panelTheme.backdropBlur ?? 8))}px`,
40
+ `--help-shadow: ${getCssPanelBoxShadow(theme.panelTheme.shadowIntensity ?? 0.2)}`,
41
+ `--help-radius: ${theme.panelShape.radius}px`
42
+ ].join(';'));
43
+
44
+ function clearDelay() { clearTimeout(delay); delay = undefined; }
45
+ function clearHideDelay() { clearTimeout(hideDelay); hideDelay = undefined; }
46
+ function close(returnFocus = false) {
47
+ clearDelay(); clearHideDelay();
48
+ if (!open) return;
49
+ const restoreFocus = returnFocus && popover.contains(document.activeElement);
50
+ popover.hidePopover();
51
+ open = false;
52
+ manual = false;
53
+ helpHovered = false;
54
+ if (restoreFocus) button.focus({ preventScroll: true });
55
+ }
56
+ function position() {
57
+ if (!open) return;
58
+ const rect = button.getBoundingClientRect();
59
+ const viewport = window.visualViewport;
60
+ const leftEdge = (viewport?.offsetLeft ?? 0) + 16;
61
+ const topEdge = (viewport?.offsetTop ?? 0) + 16;
62
+ const width = Math.min(viewport?.width ?? window.innerWidth, document.documentElement.clientWidth);
63
+ const height = Math.min(viewport?.height ?? window.innerHeight, document.documentElement.clientHeight);
64
+ popover.style.maxWidth = `${Math.max(0, width - 32)}px`;
65
+ popover.style.maxHeight = `${Math.max(0, height - 32)}px`;
66
+ popover.style.setProperty('--help-max-height', `${Math.max(0, height - 32)}px`);
67
+ const box = popover.getBoundingClientRect();
68
+ const left = Math.max(leftEdge, Math.min(rect.right - box.width, leftEdge + width - 32 - box.width));
69
+ const below = rect.bottom + 12;
70
+ const top = below + box.height <= topEdge + height - 32 ? below : Math.max(topEdge, rect.top - box.height - 12);
71
+ const nextLeft = `${left}px`, nextTop = `${top}px`;
72
+ if (popover.style.left !== nextLeft || popover.style.top !== nextTop) {
73
+ popover.style.left = nextLeft;
74
+ popover.style.top = nextTop;
75
+ }
76
+ }
77
+ function requestPosition() {
78
+ if (open) window.dispatchEvent(new Event(STAGE_PANEL_LAYOUT_EVENT));
79
+ }
80
+ async function show(keyboard = false) {
81
+ if (!enhanced || !visible) return;
82
+ clearDelay(); clearHideDelay();
83
+ popover.showPopover();
84
+ open = true;
85
+ await tick();
86
+ requestPosition();
87
+ if (keyboard) closeButton.focus({ preventScroll: true });
88
+ }
89
+ function toggleHelp(event: MouseEvent) {
90
+ if (open) close();
91
+ else {
92
+ manual = true;
93
+ void show(event.detail === 0);
94
+ }
95
+ }
96
+ function schedule() {
97
+ clearDelay(); clearHideDelay();
98
+ if (manual || !enhanced || !visible || modelInput.active || touchInput || guidance?.snapshot.interacted) return;
99
+ if (modelInput.hovered) {
100
+ if (!open) delay = setTimeout(() => { void show(); }, 600);
101
+ } else if (open && !helpHovered && !buttonHovered && !popover.contains(document.activeElement)) {
102
+ hideDelay = setTimeout(() => close(), 350);
103
+ }
104
+ }
105
+
106
+ onMount(() => {
107
+ guidance = getInteractionGuidance();
108
+ touchInput = window.matchMedia('(pointer: coarse)').matches;
109
+ const stopGuidance = guidance.subscribe((state) => {
110
+ interacted = state.interacted;
111
+ if (state.interacted) close();
112
+ });
113
+ const stage = root.closest<HTMLElement>('.stage')!;
114
+ focusAnchor = root.closest('.spatial-element-hero')?.querySelector<HTMLElement>('.spatial-element-panel') ?? undefined;
115
+ // Keep the non-modal help accessible when close-up hides the ordinary DOM layer.
116
+ stage.appendChild(popover);
117
+ // Measure the nearest wide panel above the hero, without relying on a host CSS class.
118
+ const top = root.getBoundingClientRect().top;
119
+ const header = Array.from(stage.querySelectorAll<HTMLElement>('[data-stage-panel-fallback]'))
120
+ .filter((node) => { const rect = node.getBoundingClientRect(); return rect.width > innerWidth * 0.4 && rect.bottom <= top && rect.height > 0; })
121
+ .sort((a, b) => b.getBoundingClientRect().bottom - a.getBoundingClientRect().bottom)[0];
122
+ const measureSpacing = () => {
123
+ if (header) {
124
+ const gap = Math.max(16, root.getBoundingClientRect().top - header.getBoundingClientRect().bottom - 12);
125
+ root.style.setProperty('--model-tools-gap', `${gap}px`);
126
+ }
127
+ requestPosition();
128
+ };
129
+ measureSpacing();
130
+ const headerSize = new ResizeObserver(measureSpacing);
131
+ if (header) headerSize.observe(header);
132
+ const stageChanged = () => {
133
+ enhanced = stage.dataset.stageState === 'enhanced' && !stage.hasAttribute('data-catalog-transition');
134
+ if (!enhanced) close();
135
+ };
136
+ stageChanged();
137
+ const mutation = new MutationObserver(stageChanged);
138
+ mutation.observe(stage, { attributes: true, attributeFilter: ['data-stage-state', 'data-catalog-transition'] });
139
+ const observer = new IntersectionObserver(([entry]) => {
140
+ visible = entry.isIntersecting;
141
+ if (!visible) close();
142
+ });
143
+ observer.observe(root);
144
+ const size = new ResizeObserver(requestPosition);
145
+ size.observe(popover);
146
+ const modelChanged = (event: Event) => {
147
+ modelInput = (event as CustomEvent<ModelInputState>).detail;
148
+ if (modelInput.active) close();
149
+ schedule();
150
+ };
151
+ const inputChanged = (event: PointerEvent) => {
152
+ if (!event.isTrusted) return;
153
+ const next = event.pointerType !== 'mouse';
154
+ if (next !== touchInput) { touchInput = next; if (next) { clearDelay(); clearHideDelay(); if (!manual) close(); } }
155
+ };
156
+ const buttonEnter = (event: PointerEvent) => { buttonHovered = event.pointerType === 'mouse'; schedule(); };
157
+ const buttonLeave = () => { buttonHovered = false; schedule(); };
158
+ const keydown = (event: KeyboardEvent) => {
159
+ if (event.key === 'Escape' && open) { event.preventDefault(); close(true); }
160
+ };
161
+ const stopScroll = subscribeStageScrollFrame(() => {
162
+ if (!open) return;
163
+ const rect = button.getBoundingClientRect();
164
+ if (rect.bottom < 0 || rect.top > innerHeight) close();
165
+ else requestPosition();
166
+ }, STAGE_SCROLL_PRIORITY.stage + 1);
167
+ stage.addEventListener(MODEL_INPUT_EVENT, modelChanged);
168
+ button.addEventListener('pointerenter', buttonEnter);
169
+ button.addEventListener('pointerleave', buttonLeave);
170
+ window.addEventListener('pointerdown', inputChanged, { capture: true, passive: true });
171
+ window.addEventListener('pointermove', inputChanged, { capture: true, passive: true });
172
+ window.addEventListener('keydown', keydown);
173
+ window.addEventListener('resize', measureSpacing, { passive: true });
174
+ window.visualViewport?.addEventListener('resize', requestPosition, { passive: true });
175
+ window.visualViewport?.addEventListener('scroll', requestPosition, { passive: true });
176
+ return () => {
177
+ // A queued focusout microtask must not restart the hover timer after teardown.
178
+ enhanced = false; visible = false;
179
+ close(); stopGuidance(); stopScroll(); mutation.disconnect(); observer.disconnect(); size.disconnect(); headerSize.disconnect();
180
+ root.appendChild(popover);
181
+ stage.removeEventListener(MODEL_INPUT_EVENT, modelChanged);
182
+ button.removeEventListener('pointerenter', buttonEnter);
183
+ button.removeEventListener('pointerleave', buttonLeave);
184
+ window.removeEventListener('pointerdown', inputChanged, true);
185
+ window.removeEventListener('pointermove', inputChanged, true);
186
+ window.removeEventListener('keydown', keydown);
187
+ window.removeEventListener('resize', measureSpacing);
188
+ window.visualViewport?.removeEventListener('resize', requestPosition);
189
+ window.visualViewport?.removeEventListener('scroll', requestPosition);
190
+ };
191
+ });
192
+ </script>
193
+
194
+ <div bind:this={root} class="model-tools" class:enhanced style={surfaceStyle} data-spatial-element-tools>
195
+ <div class="model-tools-buttons">
196
+ <SpatialIconButton bind:element={button} {focusAnchor} label={messages.controls.help} onclick={toggleHelp} expanded={open} controls={id} enabled={enhanced}>
197
+ <CircleHelp size={21} strokeWidth={1.8} aria-hidden="true" />
198
+ </SpatialIconButton>
199
+ </div>
200
+ {#if enhanced && touchInput && !interacted && !open}
201
+ <p class="touch-hint" data-spatial-element-touch-hint>{help.touchHint}</p>
202
+ {/if}
203
+ <div bind:this={popover} {id} popover="auto" role="dialog" tabindex="-1" aria-modal="false" aria-labelledby={`${id}-title`}
204
+ style={surfaceStyle}
205
+ class="interaction-help" data-spatial-element-help data-surface={theme.panelTheme.surface ?? 'glass'}
206
+ onpointerenter={(event) => { helpHovered = event.pointerType === 'mouse'; schedule(); }}
207
+ onpointerleave={() => { helpHovered = false; schedule(); }}
208
+ onfocusin={clearHideDelay} onfocusout={() => { queueMicrotask(schedule); }}
209
+ 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}
211
+ shape={{ ...theme.panelShape, contentInset: 0 }} theme={theme.panelTheme}>
212
+ <div class="help-copy">
213
+ <div class="help-heading">
214
+ <h2 id={`${id}-title`}>{help.title}</h2>
215
+ <button bind:this={closeButton} type="button" class="close-help" onclick={() => close(true)}
216
+ aria-label={messages.controls.closeHelp} title={messages.controls.closeHelp}>
217
+ <X size={19} aria-hidden="true" />
218
+ </button>
219
+ </div>
220
+ <dl>
221
+ <div><InteractionGesture action="rotate" touch={touchInput} /><dt>{help.rotate}</dt><dd>{touchInput ? help.touchRotate : help.mouseRotate}</dd></div>
222
+ <div><InteractionGesture action="zoom" touch={touchInput} /><dt>{help.zoom}</dt><dd>{touchInput ? help.touchZoom : help.mouseZoom}</dd></div>
223
+ <div><InteractionGesture action="pan" touch={touchInput} /><dt>{help.pan}</dt><dd>{touchInput ? help.touchPan : help.mousePan}</dd></div>
224
+ </dl>
225
+ <p class="navigation-hint">
226
+ {#if touchInput}
227
+ {help.touchScrollHint}
228
+ {:else}
229
+ {#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
+ {/if}
231
+ </p>
232
+ </div>
233
+ </Panel>
234
+ </div>
235
+ </div>
236
+
237
+ <style>
238
+ .model-tools {
239
+ grid-column: 1; grid-row: 1; align-self: start; justify-self: end; position: relative;
240
+ 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;
242
+ }
243
+ .model-tools.enhanced { visibility: visible; pointer-events: auto; }
244
+ .model-tools-buttons { display: flex; gap: 8px; justify-content: flex-end; }
245
+ .touch-hint {
246
+ position: absolute; right: 0; top: 48px; width: max-content; max-width: min(260px, calc(100vw - 48px));
247
+ margin: 0; padding: 8px 12px; border-radius: 10px; font-size: 12px; line-height: 1.45;
248
+ color: var(--spatial-element-ink); pointer-events: none;
249
+ background: color-mix(in srgb, var(--help-tint) var(--help-tint-opacity), transparent);
250
+ backdrop-filter: blur(var(--help-blur)); box-shadow: var(--help-shadow);
251
+ }
252
+ .interaction-help {
253
+ position: fixed; inset: auto; box-sizing: border-box; width: 248px;
254
+ margin: 0; padding: 0; overflow: visible;
255
+ border: 0; border-radius: var(--help-radius); color: var(--spatial-element-ink);
256
+ background: transparent;
257
+ font: inherit; font-size: 14px; line-height: 1.45; touch-action: manipulation;
258
+ }
259
+ .help-copy { box-sizing: border-box; padding: 12px 16px 16px; max-height: var(--help-max-height); overflow: auto; border-radius: var(--help-radius); }
260
+ .interaction-help::backdrop { background: transparent; pointer-events: none; }
261
+ .help-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
262
+ h2 { margin: 0; font-size: 15px; font-weight: 650; }
263
+ .close-help {
264
+ width: 40px; height: 40px; flex: 0 0 40px; display: grid; place-items: center;
265
+ padding: 0; border: 0; border-radius: 8px; color: inherit; background: transparent; cursor: pointer;
266
+ }
267
+ .close-help:focus-visible { outline: 2px solid var(--spatial-element-accent); }
268
+ dl { display: grid; gap: 8px; margin: 8px 0 0; }
269
+ dl > div { display: grid; grid-template-columns: 48px 1fr; column-gap: 14px; align-items: center; }
270
+ dt { font-weight: 650; }
271
+ /* Keep complete host-localized instructions available to assistive technology. */
272
+ dd { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
273
+ .navigation-hint { margin: 16px 0 0; padding-top: 12px; border-top: 1px solid currentColor; font-size: 12px; }
274
+ .navigation-hint a { color: var(--spatial-element-accent); text-decoration: underline; text-underline-offset: 2px; }
275
+ .navigation-hint a:focus-visible { outline: 2px solid var(--spatial-element-accent); outline-offset: 3px; border-radius: 2px; }
276
+ @media (max-width: 1100px) { .model-tools { margin-inline-end: 0; } }
277
+ </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;
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import Panel from '../stage/Panel.svelte';
3
3
  import { useSpatialTheme } from './brandContext.js';
4
- import type { SpatialElementData } from '@spatial-elements/core/spatial-element/types';
4
+ import type { ResolvedSpatialElementData as SpatialElementData } from '@spatial-elements/core/spatial-element/spatialElement';
5
5
 
6
6
  let { spatialElement }: { spatialElement: SpatialElementData } = $props();
7
7
  const theme = useSpatialTheme();
@@ -1,4 +1,4 @@
1
- import type { SpatialElementData } from '@spatial-elements/core/spatial-element/types';
1
+ import type { ResolvedSpatialElementData as SpatialElementData } from '@spatial-elements/core/spatial-element/spatialElement';
2
2
  type $$ComponentProps = {
3
3
  spatialElement: SpatialElementData;
4
4
  };
@@ -16,11 +16,14 @@
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';
22
23
  import { SPATIAL_ELEMENT_SECTION_REGISTRY_KEY, SpatialElementSectionRegistry } from '@spatial-elements/core/spatial-element/spatialElementSectionRegistry';
23
24
  import type { SpatialElementData, SpatialElementSectionNavigationItem } from '@spatial-elements/core/spatial-element/types';
25
+ import { resolveSpatialElementData } from '@spatial-elements/core/spatial-element/spatialElement';
26
+ import { registerSpatialPage } from './spatialPageContext.js';
24
27
 
25
28
  const SPATIAL_ELEMENT_OVERVIEW_SECTION = {
26
29
  id: 'overview',
@@ -29,8 +32,18 @@
29
32
  // Switch while the next panel enters the upper reading area, before it reaches the sticky tabs.
30
33
  const SPATIAL_ELEMENT_SECTION_ACTIVATION_VIEWPORT_RATIO = 0.25;
31
34
 
32
- let { spatialElement, children }: { spatialElement: SpatialElementData; children?: Snippet } = $props();
35
+ interface Props {
36
+ /** Complete element document from this page's load function. Registers assets with the enclosing shell. */
37
+ spatialElement: SpatialElementData;
38
+ /** Detail sections; Section components automatically populate the tab navigation. */
39
+ children?: Snippet;
40
+ }
41
+ let { spatialElement: element, children }: Props = $props();
33
42
  const brand = useSpatialTheme();
43
+ const spatialElement = $derived(resolveSpatialElementData(element, brand.id));
44
+ // During route teardown Kit can clear the outgoing page's data before unmount.
45
+ // Read raw assets here, so the parent stage never evaluates outgoing DOM-derived content.
46
+ registerSpatialPage(() => element ? { kind: 'detail', element } : { kind: 'content', hdr: '' });
34
47
  const endpoints = getContext<CatalogEndpointRegistry | undefined>(CATALOG_ENDPOINTS);
35
48
  let sections = $state<SpatialElementSectionNavigationItem[]>([]);
36
49
  let activeSectionId = $state<string | undefined>(SPATIAL_ELEMENT_OVERVIEW_SECTION.id);
@@ -137,10 +150,7 @@
137
150
  data-brand-id={spatialElement.brandId}
138
151
  >
139
152
  <SpatialElementBreadcrumbs
140
- items={spatialElement.breadcrumbs.map((item) => ({
141
- ...item,
142
- href: item.href ?? `/${brand.id}/categories/list`
143
- }))}
153
+ items={spatialElement.breadcrumbs}
144
154
  />
145
155
  <SpatialElementStickyHeader {activeSectionId} {spatialElement} sections={navigationSections} />
146
156
 
@@ -164,11 +174,12 @@
164
174
  data-catalog-geometry
165
175
  data-spatial-element-id={spatialElement.id}
166
176
  data-catalog-slot="detail.hero"
167
- fallbackSrc={spatialElement.stage.fallbackImage}
177
+ fallbackSrc={spatialElement.fallbackImage}
168
178
  fallbackAlt={`${brand.name} ${spatialElement.title}`}
169
- aria-hidden={spatialElement.stage.fallbackImage ? undefined : 'true'}
179
+ aria-hidden={spatialElement.fallbackImage ? undefined : 'true'}
170
180
  />
171
181
 
182
+ {#key spatialElement.id}<SpatialElementHelp />{/key}
172
183
  <SpatialElementSummaryPanel {spatialElement} />
173
184
  </section>
174
185
 
@@ -191,11 +202,12 @@
191
202
  }
192
203
 
193
204
  .spatial-element-hero {
205
+ --spatial-element-hero-column-gap: clamp(28px, 4vw, 70px);
194
206
  position: relative;
195
207
  box-sizing: border-box;
196
208
  display: grid;
197
209
  grid-template-columns: minmax(420px, 1fr) minmax(360px, 494px);
198
- gap: clamp(28px, 4vw, 70px);
210
+ gap: var(--spatial-element-hero-column-gap);
199
211
  align-items: start;
200
212
  width: calc(100vw - var(--spatial-element-hero-edge-gap) - var(--spatial-element-hero-edge-gap));
201
213
  min-height: clamp(610px, calc(100vh - 230px), 760px);
@@ -222,6 +234,11 @@
222
234
  margin-top: 8px;
223
235
  }
224
236
 
237
+ .spatial-element-hero :global(.spatial-element-visual) {
238
+ grid-column: 1;
239
+ grid-row: 1;
240
+ }
241
+
225
242
  :global(.spatial-element-visual) {
226
243
  min-height: clamp(540px, calc(100vh - 300px), 680px);
227
244
  border-radius: 28px;
@@ -1,9 +1,11 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { SpatialElementData } from '@spatial-elements/core/spatial-element/types';
3
- type $$ComponentProps = {
3
+ interface Props {
4
+ /** Complete element document from this page's load function. Registers assets with the enclosing shell. */
4
5
  spatialElement: SpatialElementData;
6
+ /** Detail sections; Section components automatically populate the tab navigation. */
5
7
  children?: Snippet;
6
- };
7
- declare const SpatialElementPage: import("svelte").Component<$$ComponentProps, {}, "">;
8
+ }
9
+ declare const SpatialElementPage: import("svelte").Component<Props, {}, "">;
8
10
  type SpatialElementPage = ReturnType<typeof SpatialElementPage>;
9
11
  export default SpatialElementPage;
@@ -1,10 +1,11 @@
1
1
  <script lang="ts">
2
+ import type { ResolvedSpatialElementData as SpatialElementData } from '@spatial-elements/core/spatial-element/spatialElement';
2
3
  import { catalogActionSemantic } from '@spatial-elements/core/catalog/catalogAction';
3
4
  import { ShoppingCart } from 'lucide-svelte';
4
5
  import SpatialElementTabList from './SpatialElementTabList.svelte';
5
6
  import { createCatalogEndpointAction } from '../catalog/catalogEndpointAction.js';
6
7
  const catalogEndpoint = createCatalogEndpointAction();
7
- import type { SpatialElementData, SpatialElementSectionNavigationItem } from '@spatial-elements/core/spatial-element/types';
8
+ import type { SpatialElementSectionNavigationItem } from '@spatial-elements/core/spatial-element/types';
8
9
 
9
10
  let {
10
11
  activeSectionId,
@@ -77,39 +78,41 @@
77
78
  </p>
78
79
  </div>
79
80
 
80
- {#if spatialElement.action.href}
81
- <a
82
- class="sticky-header-action"
83
- use:catalogEndpoint={{
84
- brandId: spatialElement.brandId,
85
- spatialElementId: spatialElement.id,
86
- slot: 'detail.dock',
87
- role: 'primary-action'
88
- }}
89
- data-catalog-rich-shared="primary-action"
90
- data-catalog-semantic={catalogActionSemantic(spatialElement.action)}
91
- href={spatialElement.action.href}
92
- rel="external"
93
- aria-label={spatialElement.action.ariaLabel}
94
- >
95
- <ShoppingCart size={29} strokeWidth={2} aria-hidden="true" />
96
- </a>
97
- {:else}
98
- <button
99
- use:catalogEndpoint={{
100
- brandId: spatialElement.brandId,
101
- spatialElementId: spatialElement.id,
102
- slot: 'detail.dock',
103
- role: 'primary-action'
104
- }}
105
- data-catalog-rich-shared="primary-action"
106
- data-catalog-semantic={catalogActionSemantic(spatialElement.action)}
107
- class="sticky-header-action"
108
- type="button"
109
- aria-label={spatialElement.action.ariaLabel}
110
- >
111
- <ShoppingCart size={29} strokeWidth={2} aria-hidden="true" />
112
- </button>
81
+ {#if spatialElement.action}
82
+ {#if spatialElement.action.href}
83
+ <a
84
+ class="sticky-header-action"
85
+ use:catalogEndpoint={{
86
+ brandId: spatialElement.brandId,
87
+ spatialElementId: spatialElement.id,
88
+ slot: 'detail.dock',
89
+ role: 'primary-action'
90
+ }}
91
+ data-catalog-rich-shared="primary-action"
92
+ data-catalog-semantic={catalogActionSemantic(spatialElement.action)}
93
+ href={spatialElement.action.href}
94
+ rel="external"
95
+ aria-label={spatialElement.action.ariaLabel}
96
+ >
97
+ <ShoppingCart size={29} strokeWidth={2} aria-hidden="true" />
98
+ </a>
99
+ {:else}
100
+ <button
101
+ use:catalogEndpoint={{
102
+ brandId: spatialElement.brandId,
103
+ spatialElementId: spatialElement.id,
104
+ slot: 'detail.dock',
105
+ role: 'primary-action'
106
+ }}
107
+ data-catalog-rich-shared="primary-action"
108
+ data-catalog-semantic={catalogActionSemantic(spatialElement.action)}
109
+ class="sticky-header-action"
110
+ type="button"
111
+ aria-label={spatialElement.action.ariaLabel}
112
+ >
113
+ <ShoppingCart size={29} strokeWidth={2} aria-hidden="true" />
114
+ </button>
115
+ {/if}
113
116
  {/if}
114
117
  </div>
115
118
 
@@ -185,8 +188,9 @@
185
188
  height: 52px;
186
189
  padding: 0;
187
190
  border: 0;
188
- border-radius: var(--spatial-element-tabs-dock-top-radius) var(--spatial-element-tabs-dock-top-radius)
189
- var(--spatial-element-tabs-dock-bottom-radius) var(--spatial-element-tabs-dock-bottom-radius);
191
+ border-radius: var(--spatial-element-tabs-dock-top-radius)
192
+ var(--spatial-element-tabs-dock-top-radius) var(--spatial-element-tabs-dock-bottom-radius)
193
+ var(--spatial-element-tabs-dock-bottom-radius);
190
194
  overflow: clip;
191
195
  opacity: 0;
192
196
  visibility: hidden;
@@ -209,7 +213,8 @@
209
213
  .spatial-element-sticky-header::before,
210
214
  .spatial-element-sticky-tabs::before {
211
215
  background: rgb(
212
- var(--spatial-element-docked-panel-tint-rgb) / var(--spatial-element-docked-panel-tint-opacity)
216
+ var(--spatial-element-docked-panel-tint-rgb) /
217
+ var(--spatial-element-docked-panel-tint-opacity)
213
218
  );
214
219
  box-shadow: inset 0 0 0 1px
215
220
  rgb(0 0 0 / calc(var(--spatial-element-docked-panel-shadow-strength) * 0.18));
@@ -1,4 +1,5 @@
1
- import type { SpatialElementData, SpatialElementSectionNavigationItem } from '@spatial-elements/core/spatial-element/types';
1
+ import type { ResolvedSpatialElementData as SpatialElementData } from '@spatial-elements/core/spatial-element/spatialElement';
2
+ import type { SpatialElementSectionNavigationItem } from '@spatial-elements/core/spatial-element/types';
2
3
  type $$ComponentProps = {
3
4
  activeSectionId?: string;
4
5
  spatialElement: SpatialElementData;