@spatial-elements/sveltekit 0.1.0-beta.1 → 1.0.0-beta.10

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 (129) hide show
  1. package/README.md +19 -9
  2. package/dist/catalog/ScrollNavigationBridge.svelte +172 -47
  3. package/dist/catalog/ScrollNavigationBridge.svelte.d.ts +9 -2
  4. package/dist/catalog/catalogNavigation.js +3 -2
  5. package/dist/catalog/catalogSummaryTransfer.d.ts +16 -0
  6. package/dist/catalog/catalogSummaryTransfer.js +79 -0
  7. package/dist/catalog/catalogTransition.css +58 -3
  8. package/dist/catalog/interruptedPresentation.d.ts +10 -0
  9. package/dist/catalog/interruptedPresentation.js +29 -0
  10. package/dist/catalog/presentationCleanup.d.ts +4 -0
  11. package/dist/catalog/presentationCleanup.js +20 -0
  12. package/dist/catalog/stagedCatalogNavigation.d.ts +44 -0
  13. package/dist/catalog/stagedCatalogNavigation.js +403 -0
  14. package/dist/catalog/stagedDomReveal.d.ts +8 -0
  15. package/dist/catalog/stagedDomReveal.js +76 -0
  16. package/dist/index.d.ts +4 -0
  17. package/dist/index.js +3 -0
  18. package/dist/spatial-element/BrandStageShell.svelte +52 -71
  19. package/dist/spatial-element/BrandStageShell.svelte.d.ts +31 -4
  20. package/dist/spatial-element/CarouselSpatialElement.svelte +150 -197
  21. package/dist/spatial-element/CarouselSpatialElement.svelte.d.ts +5 -1
  22. package/dist/spatial-element/ContentBlock.svelte +7 -0
  23. package/dist/spatial-element/ContentBlock.svelte.d.ts +9 -0
  24. package/dist/spatial-element/ContentGrid.svelte +7 -0
  25. package/dist/spatial-element/ContentGrid.svelte.d.ts +8 -0
  26. package/dist/spatial-element/ContentPage.svelte +51 -55
  27. package/dist/spatial-element/ContentPage.svelte.d.ts +14 -3
  28. package/dist/spatial-element/InteractionGesture.svelte +39 -0
  29. package/dist/spatial-element/InteractionGesture.svelte.d.ts +7 -0
  30. package/dist/spatial-element/OverflowControls.svelte +125 -0
  31. package/dist/spatial-element/OverflowControls.svelte.d.ts +9 -0
  32. package/dist/spatial-element/PointerHint.svelte +80 -0
  33. package/dist/spatial-element/PointerHint.svelte.d.ts +3 -0
  34. package/dist/spatial-element/Section.svelte +25 -106
  35. package/dist/spatial-element/Section.svelte.d.ts +1 -0
  36. package/dist/spatial-element/SectionSurfaceGroup.svelte +8 -0
  37. package/dist/spatial-element/SectionSurfaceGroup.svelte.d.ts +8 -0
  38. package/dist/spatial-element/SpatialCardGridSection.svelte +79 -0
  39. package/dist/spatial-element/SpatialCardGridSection.svelte.d.ts +11 -0
  40. package/dist/spatial-element/SpatialCardPresentation.svelte +311 -0
  41. package/dist/spatial-element/SpatialCardPresentation.svelte.d.ts +19 -0
  42. package/dist/spatial-element/SpatialCardSlot.svelte +33 -0
  43. package/dist/spatial-element/SpatialCardSlot.svelte.d.ts +8 -0
  44. package/dist/spatial-element/SpatialCarouselSection.svelte +752 -0
  45. package/dist/spatial-element/{CarouselSection.svelte.d.ts → SpatialCarouselSection.svelte.d.ts} +5 -5
  46. package/dist/spatial-element/SpatialElementBreadcrumbs.svelte +12 -65
  47. package/dist/spatial-element/SpatialElementCard.svelte +54 -238
  48. package/dist/spatial-element/SpatialElementCard.svelte.d.ts +9 -0
  49. package/dist/spatial-element/SpatialElementHelp.svelte +292 -0
  50. package/dist/spatial-element/SpatialElementHelp.svelte.d.ts +6 -0
  51. package/dist/spatial-element/SpatialElementMediaRail.svelte +321 -52
  52. package/dist/spatial-element/SpatialElementMediaRail.svelte.d.ts +4 -1
  53. package/dist/spatial-element/SpatialElementNativeMedia.svelte +101 -0
  54. package/dist/spatial-element/SpatialElementNativeMedia.svelte.d.ts +9 -0
  55. package/dist/spatial-element/SpatialElementPage.svelte +150 -70
  56. package/dist/spatial-element/SpatialElementPage.svelte.d.ts +6 -3
  57. package/dist/spatial-element/SpatialElementStickyHeader.svelte +76 -104
  58. package/dist/spatial-element/SpatialElementStickyHeader.svelte.d.ts +3 -1
  59. package/dist/spatial-element/SpatialElementSummaryContent.svelte +185 -0
  60. package/dist/spatial-element/SpatialElementSummaryContent.svelte.d.ts +18 -0
  61. package/dist/spatial-element/SpatialElementSummaryPanel.svelte +48 -380
  62. package/dist/spatial-element/SpatialElementSummaryPanel.svelte.d.ts +2 -1
  63. package/dist/spatial-element/SpatialElementTabList.svelte +40 -17
  64. package/dist/spatial-element/SpatialElementTabList.svelte.d.ts +2 -1
  65. package/dist/spatial-element/SpatialElementTabs.svelte +61 -18
  66. package/dist/spatial-element/SpatialElementTabs.svelte.d.ts +3 -1
  67. package/dist/spatial-element/SpatialElementViewToggle.svelte +54 -0
  68. package/dist/spatial-element/SpatialElementViewToggle.svelte.d.ts +8 -0
  69. package/dist/spatial-element/SpatialIconButton.svelte +59 -0
  70. package/dist/spatial-element/SpatialIconButton.svelte.d.ts +14 -0
  71. package/dist/spatial-element/SpatialListPage.svelte +37 -8
  72. package/dist/spatial-element/SpatialListPage.svelte.d.ts +4 -1
  73. package/dist/spatial-element/SpatialMediaIndicator.svelte +16 -0
  74. package/dist/spatial-element/SpatialMediaIndicator.svelte.d.ts +26 -0
  75. package/dist/spatial-element/SpatialNavigationShell.svelte +136 -0
  76. package/dist/spatial-element/SpatialNavigationShell.svelte.d.ts +15 -0
  77. package/dist/spatial-element/SpatialSummaryHost.svelte +19 -0
  78. package/dist/spatial-element/SpatialSummaryHost.svelte.d.ts +9 -0
  79. package/dist/spatial-element/SpatialSummaryRoot.svelte +78 -0
  80. package/dist/spatial-element/SpatialSummaryRoot.svelte.d.ts +8 -0
  81. package/dist/spatial-element/SpatialSummarySlot.svelte +39 -0
  82. package/dist/spatial-element/SpatialSummarySlot.svelte.d.ts +9 -0
  83. package/dist/spatial-element/SpatialViewIcon.svelte +29 -0
  84. package/dist/spatial-element/SpatialViewIcon.svelte.d.ts +6 -0
  85. package/dist/spatial-element/brandContext.d.ts +1 -1
  86. package/dist/spatial-element/brandContext.js +1 -1
  87. package/dist/spatial-element/cardAppearanceFreeze.d.ts +5 -0
  88. package/dist/spatial-element/cardAppearanceFreeze.js +72 -0
  89. package/dist/spatial-element/carouselTextHit.d.ts +2 -0
  90. package/dist/spatial-element/carouselTextHit.js +17 -0
  91. package/dist/spatial-element/contentSidebars.d.ts +3 -0
  92. package/dist/spatial-element/contentSidebars.js +56 -0
  93. package/dist/spatial-element/index.d.ts +18 -3
  94. package/dist/spatial-element/index.js +11 -2
  95. package/dist/spatial-element/layout.generated.css +363 -0
  96. package/dist/spatial-element/messagesContext.d.ts +3 -0
  97. package/dist/spatial-element/messagesContext.js +10 -0
  98. package/dist/spatial-element/presentationBoxFreeze.d.ts +8 -0
  99. package/dist/spatial-element/presentationBoxFreeze.js +35 -0
  100. package/dist/spatial-element/spatialCardGrid.d.ts +12 -0
  101. package/dist/spatial-element/spatialCardGrid.js +1 -0
  102. package/dist/spatial-element/spatialPageContext.d.ts +4 -0
  103. package/dist/spatial-element/spatialPageContext.js +9 -0
  104. package/dist/spatial-element/spatialPresentationOwner.d.ts +6 -0
  105. package/dist/spatial-element/spatialPresentationOwner.js +2 -0
  106. package/dist/spatial-element/spatialSummary.d.ts +43 -0
  107. package/dist/spatial-element/spatialSummary.js +1 -0
  108. package/dist/spatial-element/spatialSummaryHost.svelte.d.ts +60 -0
  109. package/dist/spatial-element/spatialSummaryHost.svelte.js +233 -0
  110. package/dist/spatial-element/spatialThemeStyle.d.ts +3 -0
  111. package/dist/spatial-element/spatialThemeStyle.js +69 -0
  112. package/dist/spatial-element/truncatedTitle.d.ts +5 -0
  113. package/dist/spatial-element/truncatedTitle.js +28 -0
  114. package/dist/stage/ButtonGroup.svelte +151 -0
  115. package/dist/stage/ButtonGroup.svelte.d.ts +24 -0
  116. package/dist/stage/Panel.svelte +72 -14
  117. package/dist/stage/Panel.svelte.d.ts +14 -2
  118. package/dist/stage/Stage.svelte +405 -48
  119. package/dist/stage/Stage.svelte.d.ts +8 -1
  120. package/dist/stage/StageViewport.svelte +15 -2
  121. package/dist/stage/authoredStyle.d.ts +4 -0
  122. package/dist/stage/authoredStyle.js +17 -0
  123. package/dist/stage/buttonGroup.d.ts +9 -0
  124. package/dist/stage/buttonGroup.js +1 -0
  125. package/logo.svg +188 -0
  126. package/package.json +9 -6
  127. package/dist/spatial-element/CarouselSection.svelte +0 -350
  128. package/dist/spatial-element/ListSection.svelte +0 -30
  129. package/dist/spatial-element/ListSection.svelte.d.ts +0 -8
@@ -0,0 +1,311 @@
1
+ <script lang="ts">
2
+ import { getContext } from 'svelte';
3
+ import { Card, type CardElements } from '@page-sections/svelte';
4
+ import type {
5
+ CardMediaAspect,
6
+ CardMediaFit,
7
+ CardVariant,
8
+ SurfaceTone
9
+ } from '@page-sections/core';
10
+ import { mouseHover } from '@spatial-elements/core/stage/mouseHover';
11
+ import { catalogViewLink } from '@spatial-elements/core/catalog/catalogViewLink';
12
+ import {
13
+ CATALOG_ENDPOINTS,
14
+ type CatalogEndpointRegistry,
15
+ type CatalogEndpointRole
16
+ } from '@spatial-elements/core/catalog/CatalogEndpointRegistry';
17
+ import {
18
+ CATALOG_SECTIONS,
19
+ type CatalogSections
20
+ } from '@spatial-elements/core/catalog/CatalogSections';
21
+ import type { SpatialListItem } from '@spatial-elements/core/spatial-element/types';
22
+ import type { SpatialCardSize } from '@spatial-elements/core/spatial-element/responsiveLayout';
23
+ import { useSpatialTheme } from './brandContext.js';
24
+ import { useCatalogNavigation } from '../catalog/catalogNavigation.js';
25
+ import { truncatedTitle } from './truncatedTitle.js';
26
+ let {
27
+ spatialElement,
28
+ occurrence,
29
+ order = 0,
30
+ cardSize = 'm',
31
+ textAlign = 'start',
32
+ active = true,
33
+ mediaAspect = '1/1',
34
+ mediaFit = 'contain',
35
+ reserveEyebrow = false,
36
+ cardTone = 'standard',
37
+ cardVariant = 'catalog'
38
+ }: {
39
+ spatialElement: SpatialListItem;
40
+ occurrence: string;
41
+ order?: number;
42
+ cardSize?: SpatialCardSize;
43
+ textAlign?: 'start' | 'center';
44
+ active?: boolean;
45
+ mediaAspect?: CardMediaAspect;
46
+ mediaFit?: CardMediaFit;
47
+ reserveEyebrow?: boolean;
48
+ cardTone?: SurfaceTone;
49
+ cardVariant?: CardVariant;
50
+ } = $props();
51
+ const readTheme = useSpatialTheme();
52
+ const brand = $derived(readTheme());
53
+ const endpoints = getContext<CatalogEndpointRegistry | undefined>(CATALOG_ENDPOINTS);
54
+ const sections = getContext<CatalogSections | undefined>(CATALOG_SECTIONS);
55
+ const { href, prepare, pending } = useCatalogNavigation();
56
+ const item = $derived({ ...spatialElement, href: href(spatialElement.href) });
57
+ let busy = $state(false);
58
+ $effect(() => {
59
+ const target = pending();
60
+ busy = false;
61
+ if (
62
+ !active ||
63
+ !target ||
64
+ new URL(href(spatialElement.href), target).pathname !== target.pathname
65
+ )
66
+ return;
67
+ const timer = setTimeout(() => {
68
+ busy = true;
69
+ }, 150);
70
+ return () => clearTimeout(timer);
71
+ });
72
+ // Resizing keeps the same endpoints: spatial measurement uses the actual media rectangle.
73
+ const ready = $derived.by(() => {
74
+ void reserveEyebrow;
75
+ void cardSize;
76
+ void cardVariant;
77
+ const enabled = active,
78
+ themeId = brand.id,
79
+ current = spatialElement,
80
+ key = occurrence;
81
+ return (parts: CardElements) => {
82
+ const cleanups: (() => void)[] = [];
83
+ const bind = (node: HTMLElement | null, role: CatalogEndpointRole, className?: string) => {
84
+ if (!node) return;
85
+ if (className) node.classList.add(className);
86
+ node.dataset.spatialElementId = current.id;
87
+ if (role !== 'container' && role !== 'geometry') node.dataset.sharedRole = role;
88
+ if (enabled) {
89
+ const stop = endpoints?.register(
90
+ {
91
+ brandId: themeId,
92
+ spatialElementId: current.id,
93
+ slot: 'catalog.card',
94
+ occurrence: key,
95
+ role
96
+ },
97
+ node
98
+ );
99
+ if (stop) cleanups.push(stop);
100
+ }
101
+ };
102
+ bind(parts.root, 'container');
103
+ bind(parts.surface, 'summary-surface', 'spatial-element-card-surface');
104
+ bind(parts.media, 'geometry', 'spatial-element-card-geometry');
105
+ bind(parts.title, 'title');
106
+ bind(
107
+ parts.copy.querySelector('[data-ps-card-part="eyebrow"]'),
108
+ 'eyebrow',
109
+ 'spatial-element-card-eyebrow'
110
+ );
111
+ parts.copy.classList.add('spatial-element-card-copy');
112
+ parts.media.dataset.catalogGeometry = '';
113
+ parts.media.dataset.catalogOccurrence = key;
114
+ parts.media.dataset.catalogSlot = 'catalog.card';
115
+ cleanups.push(mouseHover(parts.root).destroy);
116
+ const link = parts.root.matches('a')
117
+ ? (parts.root as HTMLAnchorElement)
118
+ : parts.title.querySelector('a');
119
+ if (link) {
120
+ link.dataset.catalogFocusKey = 'catalog:' + JSON.stringify([themeId, current.id, key]);
121
+ cleanups.push(
122
+ catalogViewLink(link, {
123
+ spatialElementId: current.id,
124
+ targetPresentation: current.targetPresentation
125
+ }).destroy
126
+ );
127
+ }
128
+ parts.title.removeAttribute('title');
129
+ cleanups.push(truncatedTitle(parts.title, current.title).destroy);
130
+ return () => cleanups.reverse().forEach((stop) => stop());
131
+ };
132
+ });
133
+ function activate(event: MouseEvent) {
134
+ if (!active) {
135
+ event.preventDefault();
136
+ return;
137
+ }
138
+ endpoints?.prefer(brand.id, spatialElement.id, occurrence);
139
+ sections?.activate({
140
+ brandId: brand.id,
141
+ spatialElementId: spatialElement.id,
142
+ occurrence,
143
+ slot: 'catalog.card'
144
+ });
145
+ const link = (event.target as HTMLElement).closest('a');
146
+ link?.focus({ preventScroll: true });
147
+ }
148
+ </script>
149
+
150
+ <Card
151
+ {item}
152
+ {cardSize}
153
+ {textAlign}
154
+ {mediaAspect}
155
+ {mediaFit}
156
+ {reserveEyebrow}
157
+ tone={cardTone}
158
+ variant={cardVariant}
159
+ headingLevel={3}
160
+ class="spatial-element-card"
161
+ onready={ready}
162
+ data-card-size={cardSize}
163
+ data-catalog-card
164
+ data-catalog-order={order}
165
+ data-catalog-occurrence={occurrence}
166
+ data-spatial-element-id={spatialElement.id}
167
+ data-catalog-focus-key={cardVariant === 'catalog'
168
+ ? `catalog:${JSON.stringify([brand.id, spatialElement.id, occurrence])}`
169
+ : undefined}
170
+ aria-busy={busy || undefined}
171
+ onclick={activate}
172
+ onpointerenter={() => {
173
+ if (active) prepare(spatialElement);
174
+ }}
175
+ onpointerdown={() => {
176
+ if (active) prepare(spatialElement);
177
+ }}
178
+ onfocus={(event) => {
179
+ if (
180
+ active &&
181
+ !(event.currentTarget as HTMLElement).hasAttribute('data-catalog-restoring-focus')
182
+ )
183
+ prepare(spatialElement);
184
+ }}
185
+ >
186
+ {#snippet media()}
187
+ {#if spatialElement.fallbackImage}<img
188
+ class="catalog-poster"
189
+ data-catalog-poster
190
+ loading="lazy"
191
+ decoding="async"
192
+ src={spatialElement.fallbackImage}
193
+ alt=""
194
+ />{/if}
195
+ {#if busy}<span class="catalog-loading" aria-hidden="true"></span>{/if}
196
+ {/snippet}
197
+ </Card>
198
+ <span class="catalog-status" role="status">{busy ? 'Opening spatial element…' : ''}</span>
199
+
200
+ <style>
201
+ :global(.ps-card.spatial-element-card[data-catalog-card]) {
202
+ isolation: auto;
203
+ --ps-radius: var(--spatial-element-control-radius);
204
+ pointer-events: auto;
205
+ transform-origin: center;
206
+ transform-style: preserve-3d;
207
+ transform: perspective(1000px) translate3d(0, var(--catalog-lift, 0px), 0)
208
+ rotateX(var(--catalog-rotate-x, 0deg)) rotateY(var(--catalog-rotate-y, 0deg));
209
+ }
210
+ :global(.ps-card.spatial-element-card[data-catalog-card] [data-ps-card-part='media-frame']) {
211
+ overflow: visible;
212
+ }
213
+ :global(.ps-card.spatial-element-card[data-catalog-card] [data-ps-card-part='media']),
214
+ :global(.ps-card.spatial-element-card[data-catalog-card] [data-ps-card-part='copy']) {
215
+ transform-style: preserve-3d;
216
+ }
217
+ :global(.ps-card.spatial-element-card[data-catalog-card] [data-ps-card-part='surface']) {
218
+ box-shadow: 0 12px 32px rgb(0 0 0 / 6%);
219
+ transition: border-color 180ms ease;
220
+ }
221
+ :global(
222
+ .ps-card.spatial-element-card[data-catalog-card]:is([data-mouse-hover], :focus-visible)
223
+ [data-ps-card-part='surface']
224
+ ) {
225
+ border-color: var(--ps-accent);
226
+ }
227
+ :global(.ps-card.spatial-element-card[data-catalog-card] [data-ps-card-part='surface']::after) {
228
+ content: '';
229
+ position: absolute;
230
+ inset: -1px;
231
+ border-radius: inherit;
232
+ box-shadow:
233
+ 0 0 0 1px color-mix(in srgb, var(--ps-accent) 25%, transparent),
234
+ 0 0 18px color-mix(in srgb, var(--ps-accent) 18%, transparent);
235
+ opacity: 0;
236
+ transition: opacity 180ms ease;
237
+ }
238
+ :global(
239
+ .ps-card.spatial-element-card[data-catalog-card]:is([data-mouse-hover], :focus-visible)
240
+ [data-ps-card-part='surface']::after
241
+ ) {
242
+ opacity: 1;
243
+ }
244
+ :global([data-spatial-card-appearance-frozen]::after) {
245
+ opacity: var(--spatial-card-frozen-after-opacity) !important;
246
+ transition-property: none !important;
247
+ }
248
+ :global(.ps-card.spatial-element-card[data-catalog-card] [data-ps-card-part='title']) {
249
+ transform: translateZ(var(--card-title-depth, 0px));
250
+ }
251
+ :global(.ps-card.spatial-element-card[data-catalog-card] [data-ps-card-part='eyebrow']) {
252
+ transform: translateZ(var(--card-eyebrow-depth, 0px));
253
+ }
254
+ :global(.ps-card.spatial-element-card[data-catalog-card] [data-shared-role='title']),
255
+ :global(.ps-card.spatial-element-card[data-catalog-card] [data-shared-role='eyebrow']) {
256
+ text-shadow: var(--card-text-shadow, 0 0 0 transparent);
257
+ transition:
258
+ transform 260ms ease,
259
+ text-shadow 260ms ease;
260
+ }
261
+ :global(.ps-card.spatial-element-card[data-catalog-card]:is([data-mouse-hover], :focus-visible)) {
262
+ --card-eyebrow-depth: 40px;
263
+ --card-title-depth: 64px;
264
+ --card-model-depth: 96px;
265
+ --card-model-scale: 1.12;
266
+ --card-text-shadow: 0 4px 10px rgb(0 0 0 / 16%);
267
+ }
268
+ .catalog-poster {
269
+ display: block;
270
+ transform: translateZ(var(--card-model-depth, 0px)) scale(var(--card-model-scale, 1));
271
+ transition:
272
+ transform 260ms ease,
273
+ opacity 240ms ease;
274
+ }
275
+ :global([data-catalog-model-ready]) .catalog-poster,
276
+ :global([data-spatial-presentation-model-ready]) .catalog-poster {
277
+ opacity: 0;
278
+ }
279
+ .catalog-loading {
280
+ position: absolute;
281
+ right: 14px;
282
+ top: 14px;
283
+ width: 18px;
284
+ height: 18px;
285
+ border: 2px solid var(--ps-border);
286
+ border-top-color: var(--ps-accent);
287
+ border-radius: 50%;
288
+ animation: spin 0.8s linear infinite;
289
+ }
290
+ .catalog-status {
291
+ position: absolute;
292
+ width: 1px;
293
+ height: 1px;
294
+ overflow: hidden;
295
+ clip-path: inset(50%);
296
+ }
297
+ @keyframes spin {
298
+ to {
299
+ transform: rotate(360deg);
300
+ }
301
+ }
302
+ @media (prefers-reduced-motion: reduce) {
303
+ :global(.ps-card.spatial-element-card[data-catalog-card]),
304
+ :global(.ps-card.spatial-element-card[data-catalog-card] [data-shared-role]),
305
+ .catalog-poster {
306
+ transform: none;
307
+ transition: none;
308
+ text-shadow: none;
309
+ }
310
+ }
311
+ </style>
@@ -0,0 +1,19 @@
1
+ import type { CardMediaAspect, CardMediaFit, CardVariant, SurfaceTone } from '@page-sections/core';
2
+ import type { SpatialListItem } from '@spatial-elements/core/spatial-element/types';
3
+ import type { SpatialCardSize } from '@spatial-elements/core/spatial-element/responsiveLayout';
4
+ type $$ComponentProps = {
5
+ spatialElement: SpatialListItem;
6
+ occurrence: string;
7
+ order?: number;
8
+ cardSize?: SpatialCardSize;
9
+ textAlign?: 'start' | 'center';
10
+ active?: boolean;
11
+ mediaAspect?: CardMediaAspect;
12
+ mediaFit?: CardMediaFit;
13
+ reserveEyebrow?: boolean;
14
+ cardTone?: SurfaceTone;
15
+ cardVariant?: CardVariant;
16
+ };
17
+ declare const SpatialCardPresentation: import("svelte").Component<$$ComponentProps, {}, "">;
18
+ type SpatialCardPresentation = ReturnType<typeof SpatialCardPresentation>;
19
+ export default SpatialCardPresentation;
@@ -0,0 +1,33 @@
1
+ <script lang="ts">
2
+ import { browser } from '$app/environment';
3
+ import { createRawSnippet, getContext, onMount, untrack } from 'svelte';
4
+ import { render } from 'svelte/server';
5
+ import { SpatialSummaryHostController, SPATIAL_SUMMARY_HOST } from './spatialSummaryHost.svelte.js';
6
+ import SpatialSummaryRoot from './SpatialSummaryRoot.svelte';
7
+ import type { SpatialCardContext } from './spatialSummary.js';
8
+ let { instanceKey, context }: { instanceKey: string; context: SpatialCardContext } = $props();
9
+ const host = getContext<SpatialSummaryHostController | undefined>(SPATIAL_SUMMARY_HOST);
10
+ if (!host) throw new Error('Spatial card slots require a BrandStageShell');
11
+ const key = untrack(() => instanceKey);
12
+ let mounted = $state(false);
13
+ const raw = createRawSnippet(() => ({
14
+ render: () => {
15
+ if (browser) return '<div data-spatial-card-slot></div>';
16
+ const output = render(SpatialSummaryRoot, {
17
+ props: { content: host.content(), model: { kind: 'card', current: context, active: true } },
18
+ context: host.contexts, idPrefix: `card-${encodeURIComponent(key).replaceAll('-', '%2D')}`
19
+ });
20
+ if (output.head) throw new Error('A persistent card must render synchronous content without svelte:head');
21
+ return `<div data-spatial-card-slot><div data-spatial-presentation-root class="spatial-card-root">${output.body}</div></div>`;
22
+ },
23
+ setup: (slot) => host.attachCard(slot as HTMLElement, key, context)
24
+ }));
25
+ onMount(() => { mounted = true; });
26
+ $effect(() => { if (mounted) host.updateCard(key, context); });
27
+ </script>
28
+ {@render raw()}
29
+ <style>
30
+ :global([data-spatial-card-slot]), :global(.spatial-card-root) {
31
+ width: 100%; height: 100%; min-width: 0; min-height: 0; transform-style: preserve-3d;
32
+ }
33
+ </style>
@@ -0,0 +1,8 @@
1
+ import type { SpatialCardContext } from './spatialSummary.js';
2
+ type $$ComponentProps = {
3
+ instanceKey: string;
4
+ context: SpatialCardContext;
5
+ };
6
+ declare const SpatialCardSlot: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type SpatialCardSlot = ReturnType<typeof SpatialCardSlot>;
8
+ export default SpatialCardSlot;