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

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 (43) hide show
  1. package/README.md +6 -2
  2. package/dist/catalog/catalogTransition.css +12 -0
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.js +2 -0
  5. package/dist/spatial-element/BrandStageShell.svelte +9 -59
  6. package/dist/spatial-element/BrandStageShell.svelte.d.ts +2 -0
  7. package/dist/spatial-element/CarouselSection.svelte +339 -323
  8. package/dist/spatial-element/CarouselSection.svelte.d.ts +2 -7
  9. package/dist/spatial-element/CarouselSpatialElement.svelte +142 -127
  10. package/dist/spatial-element/CarouselSpatialElement.svelte.d.ts +5 -1
  11. package/dist/spatial-element/ContentPage.svelte +2 -1
  12. package/dist/spatial-element/PointerHint.svelte +78 -0
  13. package/dist/spatial-element/PointerHint.svelte.d.ts +3 -0
  14. package/dist/spatial-element/SpatialElementCard.svelte +68 -2
  15. package/dist/spatial-element/SpatialElementHelp.svelte +23 -14
  16. package/dist/spatial-element/SpatialElementMediaRail.svelte +22 -3
  17. package/dist/spatial-element/SpatialElementPage.svelte +2 -4
  18. package/dist/spatial-element/SpatialElementSummaryContent.svelte +182 -0
  19. package/dist/spatial-element/SpatialElementSummaryContent.svelte.d.ts +18 -0
  20. package/dist/spatial-element/SpatialElementSummaryPanel.svelte +29 -375
  21. package/dist/spatial-element/SpatialElementTabs.svelte +2 -1
  22. package/dist/spatial-element/SpatialElementViewToggle.svelte +53 -0
  23. package/dist/spatial-element/SpatialElementViewToggle.svelte.d.ts +8 -0
  24. package/dist/spatial-element/SpatialIconButton.svelte +2 -1
  25. package/dist/spatial-element/brandContext.d.ts +1 -1
  26. package/dist/spatial-element/brandContext.js +1 -1
  27. package/dist/spatial-element/carouselTextHit.d.ts +2 -0
  28. package/dist/spatial-element/carouselTextHit.js +17 -0
  29. package/dist/spatial-element/spatialThemeStyle.d.ts +3 -0
  30. package/dist/spatial-element/spatialThemeStyle.js +48 -0
  31. package/dist/spatial-element/truncatedTitle.d.ts +5 -0
  32. package/dist/spatial-element/truncatedTitle.js +28 -0
  33. package/dist/stage/ButtonGroup.svelte +163 -0
  34. package/dist/stage/ButtonGroup.svelte.d.ts +24 -0
  35. package/dist/stage/Panel.svelte +24 -9
  36. package/dist/stage/Stage.svelte +91 -5
  37. package/dist/stage/Stage.svelte.d.ts +2 -0
  38. package/dist/stage/StageViewport.svelte +7 -1
  39. package/dist/stage/authoredStyle.d.ts +4 -0
  40. package/dist/stage/authoredStyle.js +17 -0
  41. package/dist/stage/buttonGroup.d.ts +9 -0
  42. package/dist/stage/buttonGroup.js +1 -0
  43. package/package.json +2 -2
@@ -1,18 +1,31 @@
1
1
  <script lang="ts">
2
- import { catalogActionSemantic } from '@spatial-elements/core/catalog/catalogAction';
3
- import { mouseHover } from '@spatial-elements/core/stage/mouseHover';
4
- import { ShoppingCart } from 'lucide-svelte';
2
+ import { onMount } from 'svelte';
3
+ import SpatialElementSummaryContent from './SpatialElementSummaryContent.svelte';
5
4
  import Panel from '../stage/Panel.svelte';
6
5
  import { useSpatialTheme } from './brandContext.js';
7
6
  import type { ResolvedSpatialElementData as SpatialElementData } from '@spatial-elements/core/spatial-element/spatialElement';
8
- import { createCatalogEndpointAction } from '../catalog/catalogEndpointAction.js';
9
7
 
10
8
  let { spatialElement }: { spatialElement: SpatialElementData } = $props();
11
- const theme = useSpatialTheme();
12
- const catalogEndpoint = createCatalogEndpointAction();
9
+ const readTheme = useSpatialTheme();
10
+ const theme = $derived(readTheme());
11
+ const contentInset = $derived(theme.panelShape.contentInset ?? Math.max(16, Math.round(theme.panelShape.radius * 0.7)));
12
+ let presentation = $state<HTMLDivElement>(null!);
13
+ let panelHeight = $state<number>();
14
+
15
+ onMount(() => {
16
+ // The stage reparents the rendered content. Keep its layout placeholder in
17
+ // sync using untransformed content size, including wrapping and font loads.
18
+ panelHeight = Math.max(504, presentation.offsetHeight + contentInset * 2);
19
+ const observer = new ResizeObserver(([entry]) => {
20
+ const height = entry.borderBoxSize?.[0]?.blockSize ?? presentation.offsetHeight;
21
+ panelHeight = Math.max(504, Math.ceil(height + contentInset * 2));
22
+ });
23
+ observer.observe(presentation);
24
+ return () => observer.disconnect();
25
+ });
13
26
  </script>
14
27
 
15
- <div class="spatial-element-aside">
28
+ <div class="spatial-element-aside" style:--summary-panel-height={panelHeight === undefined ? undefined : `${panelHeight}px`}>
16
29
  <Panel
17
30
  catalogEndpoint={{
18
31
  brandId: theme.id,
@@ -20,6 +33,7 @@
20
33
  slot: 'detail.summary',
21
34
  role: 'summary-surface'
22
35
  }}
36
+ pointerReactive={false}
23
37
  transitionGroup="shared"
24
38
  class="spatial-element-panel"
25
39
  shape={theme.panelShape}
@@ -30,137 +44,22 @@
30
44
  data-shared-role="summary-surface"
31
45
  data-spatial-element-id={spatialElement.id}
32
46
  >
33
- <div class="summary-presentation" use:mouseHover>
34
- <div class="panel-copy">
35
- <p
36
- class="panel-kicker"
37
- data-shared-role="eyebrow"
38
- data-spatial-element-id={spatialElement.id}
39
- use:catalogEndpoint={{
40
- brandId: theme.id,
41
- spatialElementId: spatialElement.id,
42
- slot: 'detail.summary',
43
- role: 'eyebrow'
44
- }}
45
- >
46
- {spatialElement.eyebrow}
47
- </p>
48
- <h1
49
- id="spatial-element-title"
50
- tabindex="-1"
51
- data-shared-role="title"
52
- data-spatial-element-id={spatialElement.id}
53
- use:catalogEndpoint={{
54
- brandId: theme.id,
55
- spatialElementId: spatialElement.id,
56
- slot: 'detail.summary',
57
- role: 'title'
58
- }}
59
- >
60
- {spatialElement.title}
61
- </h1>
62
- </div>
63
-
64
- <ul
65
- class="feature-list"
66
- aria-label="SpatialElement highlights"
67
- use:catalogEndpoint={{
68
- brandId: theme.id,
69
- spatialElementId: spatialElement.id,
70
- slot: 'detail.summary',
71
- role: 'features'
72
- }}
73
- data-catalog-rich-shared="features"
74
- data-catalog-semantic={JSON.stringify(spatialElement.features)}
75
- >
76
- {#each spatialElement.features as feature (feature.label)}
77
- <li>
78
- <span class="feature-content" data-catalog-secondary>
79
- <span class="feature-marker" aria-hidden="true">{feature.marker ?? 'Link'}</span>
80
- <span>{feature.label}</span>
81
- </span>
82
- </li>
83
- {/each}
84
- </ul>
85
-
86
- {#if spatialElement.action}
87
- {#if spatialElement.action.href}
88
- <a
89
- use:catalogEndpoint={{
90
- brandId: theme.id,
91
- spatialElementId: spatialElement.id,
92
- slot: 'detail.summary',
93
- role: 'primary-action'
94
- }}
95
- data-catalog-rich-shared="primary-action"
96
- data-catalog-semantic={catalogActionSemantic(spatialElement.action)}
97
- class="spatial-element-action spatial-element-action-expanded"
98
- href={spatialElement.action.href}
99
- rel="external"
100
- aria-label={spatialElement.action.ariaLabel}
101
- >
102
- <span class="spatial-element-action-surface" data-catalog-secondary>
103
- <ShoppingCart
104
- class="spatial-element-action-icon"
105
- size={27}
106
- strokeWidth={2}
107
- aria-hidden="true"
108
- />
109
- <span class="spatial-element-action-label">{spatialElement.action.label}</span>
110
- </span>
111
- </a>
112
- {:else}
113
- <button
114
- use:catalogEndpoint={{
115
- brandId: theme.id,
116
- spatialElementId: spatialElement.id,
117
- slot: 'detail.summary',
118
- role: 'primary-action'
119
- }}
120
- data-catalog-rich-shared="primary-action"
121
- data-catalog-semantic={catalogActionSemantic(spatialElement.action)}
122
- class="spatial-element-action spatial-element-action-expanded"
123
- type="button"
124
- aria-label={spatialElement.action.ariaLabel}
125
- >
126
- <span class="spatial-element-action-surface" data-catalog-secondary>
127
- <ShoppingCart
128
- class="spatial-element-action-icon"
129
- size={27}
130
- strokeWidth={2}
131
- aria-hidden="true"
132
- />
133
- <span class="spatial-element-action-label">{spatialElement.action.label}</span>
134
- </span>
135
- </button>
136
- {/if}
137
- {/if}
138
- </div>
47
+ <SpatialElementSummaryContent {spatialElement} {contentInset} heading="h1" bind:element={presentation}
48
+ address={(role) => ({ brandId: theme.id, spatialElementId: spatialElement.id, slot: 'detail.summary', role })} />
139
49
  </Panel>
140
50
  </div>
141
51
 
142
52
  <style>
143
- @property --summary-feature-hover-progress {
144
- syntax: '<number>';
145
- inherits: false;
146
- initial-value: 0;
147
- }
148
-
149
- @property --summary-action-hover-progress {
150
- syntax: '<number>';
151
- inherits: false;
152
- initial-value: 0;
153
- }
154
-
155
53
  .spatial-element-aside {
54
+ position: relative;
156
55
  min-height: inherit;
157
56
  }
158
57
 
159
58
  :global(.spatial-element-panel) {
160
- position: relative;
161
- top: 0;
59
+ position: sticky;
60
+ top: var(--spatial-element-summary-sticky-top, 104px);
162
61
  width: min(494px, 100%);
163
- height: 504px;
62
+ height: var(--summary-panel-height, auto);
164
63
  min-height: 504px;
165
64
  pointer-events: auto;
166
65
  }
@@ -170,258 +69,13 @@
170
69
  display: block;
171
70
  overflow: visible;
172
71
  color: color-mix(in srgb, var(--spatial-element-ink) 92%, transparent);
173
- transform-style: preserve-3d;
174
- }
175
-
176
- .summary-presentation {
177
- --summary-depth-progress: var(--stage-panel-pointer-proximity, 0);
178
- --summary-shadow-strength: var(--stage-panel-shadow-strength, 0.18);
179
- --summary-feature-depth: 40;
180
- --summary-feature-hover-depth: 48;
181
- --summary-eyebrow-depth: 60;
182
- --summary-title-depth: 96;
183
- --summary-action-depth: 76;
184
- --summary-action-hover-depth: 24;
185
-
186
- position: absolute;
187
- inset: 0;
188
- box-sizing: border-box;
189
- display: flex;
190
- flex-direction: column;
191
- justify-content: space-between;
192
- gap: 24px;
193
- pointer-events: auto;
194
- transform-style: preserve-3d;
195
- }
196
-
197
- .panel-copy {
198
- transform-style: preserve-3d;
199
- }
200
-
201
- .summary-presentation h1 {
202
- max-width: 390px;
203
- margin: 10px 0 0;
204
- font-size: clamp(30px, 3vw, 40px);
205
- font-weight: 780;
206
- line-height: 1.16;
207
- transform-origin: left center;
208
- will-change: transform;
209
- }
210
-
211
- .panel-kicker {
212
- margin: 0;
213
- font-size: 14px;
214
- font-weight: 720;
215
- letter-spacing: 0.05em;
216
- text-transform: uppercase;
217
- transform-origin: left center;
218
- will-change: transform;
219
- }
220
-
221
- .feature-list {
222
- display: grid;
223
- gap: 20px;
224
- margin: 0;
225
- padding: 0;
226
- color: var(--spatial-element-body);
227
- font-size: 18px;
228
- list-style: none;
229
- transform-style: preserve-3d;
230
- }
231
-
232
- .feature-list li {
233
- transform-style: preserve-3d;
234
- }
235
-
236
- .feature-content {
237
- --summary-feature-hover-progress: 0;
238
- --summary-feature-effective-depth: calc(
239
- var(--summary-feature-depth) * var(--summary-depth-progress) +
240
- var(--summary-feature-hover-depth) * var(--summary-feature-hover-progress)
241
- );
242
- --summary-feature-shadow-depth: calc(
243
- var(--summary-feature-depth) * var(--summary-depth-progress)
244
- );
245
-
246
- display: flex;
247
- align-items: baseline;
248
- gap: 14px;
249
- text-shadow:
250
- 0 calc(0.055px * var(--summary-feature-shadow-depth))
251
- calc(0.055px * var(--summary-feature-shadow-depth))
252
- rgb(
253
- 0 0 0 /
254
- calc(0.0168 * var(--summary-shadow-strength) * var(--summary-feature-shadow-depth))
255
- ),
256
- 0 calc(0.194px * var(--summary-feature-shadow-depth))
257
- calc(0.278px * var(--summary-feature-shadow-depth))
258
- rgb(
259
- 0 0 0 /
260
- calc(0.00936 * var(--summary-shadow-strength) * var(--summary-feature-shadow-depth))
261
- );
262
- transform: translateZ(calc(1px * var(--summary-feature-effective-depth)));
263
- transform-origin: left center;
264
- transition: --summary-feature-hover-progress 260ms cubic-bezier(0.22, 0.75, 0.25, 1);
265
- will-change: transform;
266
- }
267
-
268
- .summary-presentation:global([data-mouse-hover]) .feature-list li:hover .feature-content {
269
- --summary-feature-hover-progress: 1;
270
- }
271
-
272
- .feature-marker {
273
- color: var(--spatial-element-accent);
274
- font-weight: 800;
275
72
  }
276
73
 
277
- .spatial-element-action {
278
- display: block;
279
- box-sizing: border-box;
280
- width: 100%;
281
- min-height: 62px;
282
- border: 0;
283
- padding: 0;
284
- color: inherit;
285
- background: transparent;
286
- text-decoration: none;
287
- cursor: pointer;
288
- transform-style: preserve-3d;
289
- }
290
-
291
- .summary-presentation:global([data-mouse-hover]) .spatial-element-action:hover .spatial-element-action-surface,
292
- .spatial-element-action:focus-visible .spatial-element-action-surface {
293
- --summary-action-hover-progress: 1;
294
- }
295
-
296
- .spatial-element-action-surface {
297
- --summary-action-hover-progress: 0;
298
-
299
- display: flex;
300
- align-items: center;
301
- justify-content: center;
302
- gap: 10px;
303
- box-sizing: border-box;
304
- width: 100%;
305
- min-height: 62px;
306
- border-radius: 7px;
307
- color: var(--spatial-element-on-accent);
308
- background: var(--spatial-element-accent);
309
- font:
310
- 760 22px/1 system-ui,
311
- sans-serif;
312
- transform-origin: center;
313
- transition: --summary-action-hover-progress 260ms cubic-bezier(0.22, 0.75, 0.25, 1);
314
- will-change: transform;
315
- }
316
-
317
- .panel-kicker {
318
- --summary-eyebrow-effective-depth: calc(
319
- var(--summary-eyebrow-depth) * var(--summary-depth-progress)
320
- );
321
-
322
- text-shadow:
323
- 0 calc(0.055px * var(--summary-eyebrow-effective-depth))
324
- calc(0.04px * var(--summary-eyebrow-effective-depth))
325
- rgb(
326
- 0 0 0 /
327
- calc(0.0134 * var(--summary-shadow-strength) * var(--summary-eyebrow-effective-depth))
328
- ),
329
- 0 calc(0.117px * var(--summary-eyebrow-effective-depth))
330
- calc(0.167px * var(--summary-eyebrow-effective-depth))
331
- rgb(
332
- 0 0 0 /
333
- calc(0.0074 * var(--summary-shadow-strength) * var(--summary-eyebrow-effective-depth))
334
- );
335
- transform: translateZ(calc(1px * var(--summary-eyebrow-effective-depth)));
336
- }
337
-
338
- .summary-presentation h1 {
339
- --summary-title-effective-depth: calc(
340
- var(--summary-title-depth) * var(--summary-depth-progress)
341
- );
342
-
343
- text-shadow:
344
- 0 calc(0.055px * var(--summary-title-effective-depth))
345
- calc(0.04px * var(--summary-title-effective-depth))
346
- rgb(
347
- 0 0 0 /
348
- calc(0.007 * var(--summary-shadow-strength) * var(--summary-title-effective-depth))
349
- ),
350
- 0 calc(0.156px * var(--summary-title-effective-depth))
351
- calc(0.203px * var(--summary-title-effective-depth))
352
- rgb(
353
- 0 0 0 /
354
- calc(0.0039 * var(--summary-shadow-strength) * var(--summary-title-effective-depth))
355
- );
356
- transform: translateZ(calc(1px * var(--summary-title-effective-depth)));
357
- }
358
-
359
- .spatial-element-action-surface {
360
- --summary-action-effective-depth: calc(
361
- var(--summary-action-depth) * var(--summary-depth-progress) +
362
- var(--summary-action-hover-depth) * var(--summary-action-hover-progress)
363
- );
364
-
365
- box-shadow:
366
- 0 calc(0.078px * var(--summary-action-effective-depth))
367
- calc(0.094px * var(--summary-action-effective-depth))
368
- rgb(
369
- 0 0 0 /
370
- calc(0.0105 * var(--summary-shadow-strength) * var(--summary-action-effective-depth))
371
- ),
372
- 0 calc(0.237px * var(--summary-action-effective-depth))
373
- calc(0.316px * var(--summary-action-effective-depth))
374
- rgb(
375
- 0 0 0 /
376
- calc(0.0068 * var(--summary-shadow-strength) * var(--summary-action-effective-depth))
377
- );
378
- transform: translateZ(calc(1px * var(--summary-action-effective-depth)));
379
- }
380
-
381
- :global(.spatial-element-action-icon) {
382
- flex: none;
383
- }
384
-
385
- .spatial-element-action-label {
386
- white-space: nowrap;
387
- }
388
-
389
- /* Zero-depth transforms still promote text to composited layers in Chromium.
390
- * Remove those layers while the complete panel is in its native DOM rest mode. */
391
- :global([data-stage-panel-render-mode='native']) .summary-presentation,
392
- :global([data-stage-panel-render-mode='native']) .panel-copy,
393
- :global([data-stage-panel-render-mode='native']) .feature-list,
394
- :global([data-stage-panel-render-mode='native']) .feature-list li,
395
- :global([data-stage-panel-render-mode='native']) .spatial-element-action {
396
- transform-style: flat;
397
- }
398
-
399
- :global([data-stage-panel-render-mode='native']) .panel-kicker,
400
- :global([data-stage-panel-render-mode='native']) .summary-presentation h1,
401
- :global([data-stage-panel-render-mode='native']) .feature-content,
402
- :global([data-stage-panel-render-mode='native']) .spatial-element-action-surface {
403
- transform: none;
404
- will-change: auto;
405
- }
406
-
407
- @media (prefers-reduced-motion: reduce) {
408
- .summary-presentation {
409
- --summary-depth-progress: 0;
410
- }
411
-
412
- .feature-content,
413
- .summary-presentation:global([data-mouse-hover]) .feature-list li:hover .feature-content,
414
- .spatial-element-action-surface,
415
- .summary-presentation:global([data-mouse-hover]) .spatial-element-action:hover .spatial-element-action-surface,
416
- .spatial-element-action:focus-visible .spatial-element-action-surface {
417
- --summary-feature-hover-progress: 0;
418
- --summary-action-hover-progress: 0;
419
- transition: none;
420
- }
421
- }
422
74
 
423
75
  @media (max-width: 1100px) {
76
+ .spatial-element-aside { min-height: 0; }
424
77
  :global(.spatial-element-panel) {
78
+ position: relative;
425
79
  top: auto;
426
80
  }
427
81
  }
@@ -14,7 +14,8 @@
14
14
  sections: SpatialElementSectionNavigationItem[];
15
15
  } = $props();
16
16
  let anchorElement: HTMLDivElement;
17
- const theme = useSpatialTheme();
17
+ const readTheme = useSpatialTheme();
18
+ const theme = $derived(readTheme());
18
19
 
19
20
  onMount(() => {
20
21
  let resizeObserver: ResizeObserver | undefined;
@@ -0,0 +1,53 @@
1
+ <script lang="ts">
2
+ import { getContext } from 'svelte';
3
+ import { PanelsTopLeft, Maximize } from 'lucide-svelte';
4
+ import { STAGE_CONTEXT_KEY, type StageContext } from '@spatial-elements/core/stage/panelContext';
5
+ import ButtonGroup from '../stage/ButtonGroup.svelte';
6
+ import { useSpatialTheme } from './brandContext.js';
7
+ import { useSpatialMessages } from './messagesContext.js';
8
+ let {
9
+ enabled,
10
+ focusAnchor,
11
+ onchange
12
+ }: { enabled: boolean; focusAnchor?: HTMLElement; onchange: () => void } = $props();
13
+ const stage = getContext<StageContext>(STAGE_CONTEXT_KEY);
14
+ const readTheme = useSpatialTheme();
15
+ const theme = $derived(readTheme());
16
+ const readMessages = useSpatialMessages();
17
+ const messages = $derived(readMessages());
18
+ const fullscreen = $derived(stage.isFullscreen?.() ?? false);
19
+ const zoomFocus = $derived(stage.getZoomFocus?.() ?? 0);
20
+ function select(value: string) {
21
+ onchange();
22
+ stage.setFullscreen?.(value === 'fullscreen');
23
+ if (value === 'detail') stage.resetView();
24
+ }
25
+ </script>
26
+
27
+ <ButtonGroup
28
+ data-spatial-element-view-toggle
29
+ label={messages.controls.detailView}
30
+ iconOnly
31
+ items={[
32
+ {
33
+ value: 'detail',
34
+ label: messages.controls.detailView,
35
+ selection: fullscreen ? 0 : 1 - zoomFocus
36
+ },
37
+ { value: 'fullscreen', label: messages.controls.fullscreen }
38
+ ]}
39
+ value={fullscreen ? 'fullscreen' : zoomFocus < 0.001 ? 'detail' : undefined}
40
+ onchange={select}
41
+ disabled={!enabled}
42
+ visible={enabled}
43
+ shape={theme.panelShape}
44
+ theme={theme.panelTheme}
45
+ focusReactive="top-right"
46
+ {focusAnchor}
47
+ transitionGroup="enter"
48
+ >
49
+ {#snippet content(item)}
50
+ {#if item.value === 'detail'}<PanelsTopLeft size={21} strokeWidth={1.8} aria-hidden="true" />
51
+ {:else}<Maximize size={21} strokeWidth={1.8} aria-hidden="true" />{/if}
52
+ {/snippet}
53
+ </ButtonGroup>
@@ -0,0 +1,8 @@
1
+ type $$ComponentProps = {
2
+ enabled: boolean;
3
+ focusAnchor?: HTMLElement;
4
+ onchange: () => void;
5
+ };
6
+ declare const SpatialElementViewToggle: import("svelte").Component<$$ComponentProps, {}, "">;
7
+ type SpatialElementViewToggle = ReturnType<typeof SpatialElementViewToggle>;
8
+ export default SpatialElementViewToggle;
@@ -14,7 +14,8 @@
14
14
  enabled?: boolean;
15
15
  element?: HTMLButtonElement;
16
16
  } = $props();
17
- const theme = useSpatialTheme();
17
+ const readTheme = useSpatialTheme();
18
+ const theme = $derived(readTheme());
18
19
  </script>
19
20
 
20
21
  <div class="icon-frame">
@@ -2,4 +2,4 @@ import type { SpatialTheme } from '@spatial-elements/core/spatial-element/types'
2
2
  /** Makes the current brand theme available to all spatial-element descendants. */
3
3
  export declare function provideSpatialTheme(getTheme: () => SpatialTheme): void;
4
4
  /** Returns the nearest brand theme or throws when the element shell is incomplete. */
5
- export declare function useSpatialTheme(): SpatialTheme;
5
+ export declare function useSpatialTheme(): () => SpatialTheme;
@@ -10,5 +10,5 @@ export function useSpatialTheme() {
10
10
  if (!getTheme) {
11
11
  throw new Error('SpatialElement detail components must be rendered inside a brand layout');
12
12
  }
13
- return getTheme();
13
+ return getTheme;
14
14
  }
@@ -0,0 +1,2 @@
1
+ /** Test rendered text fragments, not the full width of their block container. */
2
+ export declare function carouselTextHit(target: EventTarget | null, x: number, y: number): HTMLElement | undefined;
@@ -0,0 +1,17 @@
1
+ /** Test rendered text fragments, not the full width of their block container. */
2
+ export function carouselTextHit(target, x, y) {
3
+ if (!(target instanceof HTMLElement) || !target.closest('.summary') ||
4
+ target.closest('a, button, input, textarea, select, [contenteditable]'))
5
+ return;
6
+ const walker = document.createTreeWalker(target, NodeFilter.SHOW_TEXT);
7
+ const range = document.createRange();
8
+ for (let node = walker.nextNode(); node; node = walker.nextNode()) {
9
+ if (!node.textContent?.trim())
10
+ continue;
11
+ range.selectNodeContents(node);
12
+ for (const rect of range.getClientRects()) {
13
+ if (x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom)
14
+ return target;
15
+ }
16
+ }
17
+ }
@@ -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,5 @@
1
+ /** Native tooltips only for clipped text; measurements never run on pointer movement. */
2
+ export declare function truncatedTitle(node: HTMLElement, text: string): {
3
+ update(value: string): void;
4
+ destroy(): void;
5
+ };
@@ -0,0 +1,28 @@
1
+ /** Native tooltips only for clipped text; measurements never run on pointer movement. */
2
+ export function truncatedTitle(node, text) {
3
+ const target = node.closest('[data-catalog-card]') ?? node;
4
+ let frame = 0;
5
+ const measure = () => {
6
+ frame = 0;
7
+ if (node.scrollHeight > node.clientHeight + 1 || node.scrollWidth > node.clientWidth + 1)
8
+ target.title = node.textContent?.trim() || text;
9
+ else
10
+ target.removeAttribute('title');
11
+ };
12
+ const schedule = () => {
13
+ if (!frame)
14
+ frame = requestAnimationFrame(measure);
15
+ };
16
+ const observer = new ResizeObserver(schedule);
17
+ observer.observe(node);
18
+ document.fonts?.addEventListener('loadingdone', schedule);
19
+ schedule();
20
+ return {
21
+ update(value) { text = value; schedule(); },
22
+ destroy() {
23
+ cancelAnimationFrame(frame);
24
+ observer.disconnect();
25
+ document.fonts?.removeEventListener('loadingdone', schedule);
26
+ }
27
+ };
28
+ }