@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,15 +1,10 @@
1
- import type { CarouselPresentation } from '@spatial-elements/core/catalog/catalogPose';
1
+ import { type CarouselPresentation } from '@spatial-elements/core/catalog/catalogPose';
2
2
  import type { SpatialListItem, SpatialElementSectionDefinition } from '@spatial-elements/core/spatial-element/types';
3
3
  type $$ComponentProps = {
4
- /** Unique page-local anchor, heading and optional CSS appearance overrides. */
5
4
  section: SpatialElementSectionDefinition;
6
- /** Project element documents with getSpatialListItems; assets register automatically. */
7
- list: SpatialListItem[];
8
- /** Arc radius (default 0.48 of width) and depth (default 700 CSS-world pixels). */
9
5
  presentation?: CarouselPresentation;
10
- /** Initially selected itemKey (or element ID); defaults to the first item. */
6
+ list: SpatialListItem[];
11
7
  initialItemKey?: string;
12
- /** Reports selection changes; URL and application state remain host-owned. */
13
8
  onselectionchange?: (selection: {
14
9
  itemKey: string;
15
10
  spatialElementId: string;
@@ -1,12 +1,13 @@
1
1
  <script lang="ts">
2
- import { catalogActionSemantic } from '@spatial-elements/core/catalog/catalogAction';
2
+ import SpatialElementSummaryContent from './SpatialElementSummaryContent.svelte';
3
3
  import { getContext } from 'svelte';
4
4
  import { getCssPanelBoxShadow } from '@spatial-elements/core/stage/panelShadow';
5
+ import { mouseHover } from '@spatial-elements/core/stage/mouseHover';
5
6
  import type { SpatialListItem } from '@spatial-elements/core/spatial-element/types';
6
7
  import { CATALOG_ITEMS, type CatalogItems } from '@spatial-elements/core/catalog/catalogItems';
7
8
  import { carouselKey } from '@spatial-elements/core/catalog/carouselSelection';
8
9
  import { carouselPose, carouselResident } from '@spatial-elements/core/catalog/catalogPose';
9
- import type { CarouselPresentation } from '@spatial-elements/core/catalog/catalogPose';
10
+ import type { CarouselLayout, CarouselPresentation, CarouselEmphasis } from '@spatial-elements/core/catalog/catalogPose';
10
11
  import { useCatalogNavigation } from '../catalog/catalogNavigation.js';
11
12
  import { createCatalogEndpointAction } from '../catalog/catalogEndpointAction.js';
12
13
  import {
@@ -20,29 +21,39 @@
20
21
  spatialElement,
21
22
  sectionId,
22
23
  presentation,
24
+ layout,
23
25
  index,
24
26
  count,
25
27
  phase,
28
+ emphasis,
29
+ focus,
26
30
  windowPhase,
27
31
  selected,
28
32
  interactive,
29
- onselect
33
+ onselect,
34
+ canActivate
30
35
  }: {
31
36
  spatialElement: SpatialListItem;
32
37
  sectionId: string;
33
38
  presentation?: CarouselPresentation;
39
+ layout: CarouselLayout;
34
40
  index: number;
35
41
  count: number;
36
42
  phase: number;
43
+ emphasis?: CarouselEmphasis;
44
+ focus: number;
37
45
  windowPhase: number;
38
46
  selected: boolean;
39
47
  interactive: boolean;
40
48
  onselect: () => void;
49
+ canActivate: () => boolean;
41
50
  } = $props();
42
51
  const items = getContext<CatalogItems | undefined>(CATALOG_ITEMS);
43
52
  const endpoints = getContext<CatalogEndpointRegistry | undefined>(CATALOG_ENDPOINTS);
44
53
  const sections = getContext<CatalogSections | undefined>(CATALOG_SECTIONS);
45
- const brand = useSpatialTheme();
54
+ const readTheme = useSpatialTheme();
55
+ const brand = $derived(readTheme());
56
+ const contentInset = $derived(brand.panelShape.contentInset ?? Math.max(16, Math.round(brand.panelShape.radius * 0.7)));
46
57
  const catalogEndpoint = createCatalogEndpointAction();
47
58
  function address(role: CatalogEndpointRole) {
48
59
  return interactive &&
@@ -69,8 +80,9 @@
69
80
  return () => clearTimeout(timer);
70
81
  });
71
82
  const occurrence = $derived(JSON.stringify([sectionId, carouselKey(spatialElement)]));
72
- const pose = $derived(carouselPose(index, phase, count, presentation));
73
- const resident = $derived(carouselResident(index, windowPhase, count));
83
+ const tooltip = $derived(spatialElement.title);
84
+ const pose = $derived(carouselPose(index, phase, count, presentation, layout, emphasis, focus));
85
+ const resident = $derived(carouselResident(index, windowPhase, count, presentation, layout));
74
86
  function activate(event: MouseEvent) {
75
87
  endpoints?.prefer(brand.id, spatialElement.id, occurrence, 'carousel.front');
76
88
  sections?.activate({
@@ -86,12 +98,13 @@
86
98
  return items?.register({
87
99
  ...spatialElement,
88
100
  occurrence,
89
- pose: { kind: 'carousel', read: () => carouselPose(index, phase, count, presentation) }
101
+ pose: { kind: 'carousel', read: () => carouselPose(index, phase, count, presentation, layout, emphasis, focus) }
90
102
  });
91
103
  });
92
104
  </script>
93
105
 
94
106
  <article
107
+ id={`carousel-${sectionId}-${index}`}
95
108
  use:catalogEndpoint={address('container')}
96
109
  class="carousel-spatial-element"
97
110
  class:selected
@@ -115,29 +128,54 @@
115
128
  data-catalog-geometry
116
129
  data-spatial-element-id={spatialElement.id}
117
130
  data-catalog-occurrence={occurrence}
131
+ style={interactive
132
+ ? `--carousel-poster-x:${(pose.x - 0.19) * 100}%;--carousel-poster-mobile-x:${pose.x * 100}%;--carousel-poster-y:${pose.y * 100}%;--carousel-poster-size:${pose.size};--carousel-poster-opacity:${pose.opacity}`
133
+ : undefined}
118
134
  >
119
- <button
135
+ <a
136
+ use:mouseHover
120
137
  draggable="false"
121
138
  class="spatial-element-target"
139
+ title={tooltip}
122
140
  hidden={interactive && !pose.visible}
123
- aria-label={`Select ${spatialElement.eyebrow}`}
124
- aria-pressed={selected}
125
- onclick={onselect}
126
- style={interactive
127
- ? `left:${(pose.x - 0.19 * Math.cos(pose.yaw)) * 100}%;top:${pose.y * 100}%;width:${pose.size * 100}%;max-width:${pose.size * 480}px;z-index:${Math.round(1300 + pose.depth)}`
128
- : undefined}
141
+ href={href(spatialElement.href)}
142
+ role={interactive && !selected ? 'button' : undefined}
143
+ aria-label={interactive && !selected ? `Select ${tooltip}` : `More information: ${tooltip}`}
144
+ aria-pressed={interactive && !selected ? false : undefined}
145
+ aria-busy={selected && busy || undefined}
146
+ data-catalog-focus-key={`catalog-geometry:${occurrence}`}
147
+ onpointerenter={() => { if (selected) prepare(spatialElement); }}
148
+ onfocus={() => { if (selected) prepare(spatialElement); }}
149
+ onpointerdown={() => { if (selected) prepare(spatialElement); }}
150
+ onkeydown={(event) => {
151
+ if (interactive && !selected && event.key === ' ') {
152
+ event.preventDefault();
153
+ event.currentTarget.click();
154
+ }
155
+ }}
156
+ onclick={(event) => {
157
+ if (!canActivate()) { event.preventDefault(); return; }
158
+ if (interactive && !selected) { event.preventDefault(); onselect(); return; }
159
+ activate(event);
160
+ }}
161
+ style:z-index={interactive ? Math.max(1, Math.round(1200 / (1 + Math.max(0, -pose.depth) / 1000))) : undefined}
129
162
  >
130
- {#if spatialElement.fallbackImage}<img
163
+ {#if !spatialElement.fallbackImage}<span>{spatialElement.eyebrow}</span>{/if}
164
+ </a>
165
+ {#if spatialElement.fallbackImage}<img
166
+ hidden={interactive && !pose.visible}
167
+ class="spatial-element-poster"
131
168
  draggable="false"
132
169
  src={spatialElement.fallbackImage}
133
170
  alt={`${brand.name} ${spatialElement.title}`}
171
+ style:--carousel-depth-blur={interactive && pose.blur ? `blur(${pose.blur}px)` : 'blur(0px)'}
134
172
  width="320"
135
173
  height="320"
136
- />{:else}<span>{spatialElement.eyebrow}</span>{/if}
137
- </button>
174
+ />{/if}
138
175
  </div>
139
176
  <div
140
177
  class="summary"
178
+ style:--summary-content-inset={`${contentInset}px`}
141
179
  hidden={interactive && pose.panelOpacity < 0.001}
142
180
  inert={interactive && !selected}
143
181
  aria-hidden={interactive && !selected}
@@ -153,55 +191,20 @@
153
191
  100 +
154
192
  '%'}
155
193
  style:--carousel-panel-blur={(brand.panelTheme.backdropBlur ?? 5) + 'px'}
194
+ style:--carousel-focus-blur={interactive && pose.panelOpacity < 1 ? `blur(${(1 - pose.panelOpacity) * 6}px)` : 'none'}
156
195
  style:--carousel-panel-radius={brand.panelShape.radius + 'px'}
157
196
  use:catalogEndpoint={address('summary-surface')}
158
197
  >
159
- <p class="eyebrow" use:catalogEndpoint={address('eyebrow')}>{spatialElement.eyebrow}</p>
160
- <h3 use:catalogEndpoint={address('title')}>{spatialElement.title}</h3>
161
- <ul
162
- use:catalogEndpoint={address('features')}
163
- data-catalog-rich-shared="features"
164
- data-catalog-semantic={JSON.stringify(
165
- spatialElement.summary?.features ?? spatialElement.features.map((label) => ({ label }))
166
- )}
167
- >
168
- {#each spatialElement.summary?.features ?? spatialElement.features.map( (label) => ({ label }) ) as feature, index (index)}<li
169
- >
170
- {feature.label}
171
- </li>{/each}
172
- </ul>
173
- {#if spatialElement.summary?.action}
174
- {@const action = spatialElement.summary.action}
175
- {#if action.href}<a
176
- use:catalogEndpoint={address('primary-action')}
177
- data-catalog-rich-shared="primary-action"
178
- data-catalog-semantic={catalogActionSemantic(action)}
179
- class="action"
180
- href={action.href}
181
- rel="external"
182
- aria-label={action.ariaLabel}>{action.label}</a
183
- >
184
- {:else}<button
185
- class="action"
186
- aria-label={action.ariaLabel}
187
- use:catalogEndpoint={address('primary-action')}
188
- data-catalog-rich-shared="primary-action"
189
- data-catalog-semantic={catalogActionSemantic(action)}>{action.label}</button
190
- >{/if}
191
- {/if}
198
+ <SpatialElementSummaryContent {address} {contentInset} spatialElement={{
199
+ id: spatialElement.id, eyebrow: spatialElement.eyebrow, title: spatialElement.title,
200
+ features: spatialElement.summary?.features ?? spatialElement.features.map((label) => ({ label })),
201
+ action: spatialElement.summary?.action
202
+ }} />
203
+ <div class="information-links">
192
204
  <a
193
205
  data-catalog-focus-key={`catalog:${JSON.stringify([brand.id, spatialElement.id, occurrence, 'carousel.front'])}`}
194
206
  aria-busy={busy || undefined}
195
- onclick={(event) => {
196
- endpoints?.prefer(brand.id, spatialElement.id, occurrence, 'carousel.front');
197
- sections?.activate({
198
- brandId: brand.id,
199
- spatialElementId: spatialElement.id,
200
- occurrence,
201
- slot: 'carousel.front'
202
- });
203
- event.currentTarget.focus({ preventScroll: true });
204
- }}
207
+ onclick={activate}
205
208
  class="information"
206
209
  href={href(spatialElement.href)}
207
210
  onpointerenter={() => prepare(spatialElement)}
@@ -218,53 +221,63 @@
218
221
  >{spatialElement.summary.sectionLink.label}</a
219
222
  >
220
223
  {/if}
224
+ </div>
221
225
  </div>
222
226
  </article>
223
227
 
224
228
  <style>
225
229
  .carousel-spatial-element {
226
230
  display: grid;
227
- grid-template-columns: minmax(0, 1fr) minmax(280px, 0.7fr);
228
- gap: 32px;
231
+ grid-template-columns: minmax(0, 1fr);
232
+ grid-template-rows: 1fr;
229
233
  align-items: center;
230
- margin-bottom: 24px;
234
+ position: relative;
235
+ min-width: 0;
236
+ min-height: 600px;
237
+ padding: 32px 0 64px;
238
+ box-sizing: border-box;
239
+ scroll-snap-align: start;
240
+ scroll-snap-stop: always;
241
+ scroll-margin-top: 100px;
231
242
  }
232
243
  .interactive {
233
- position: absolute;
234
- inset: 0;
244
+ grid-area: 1 / 1;
235
245
  pointer-events: none;
236
246
  }
237
247
  .spatial-element-visual {
238
- height: var(--carousel-height, 560px);
239
- position: relative;
248
+ position: absolute;
249
+ inset: 0;
240
250
  display: grid;
241
251
  place-items: center;
242
252
  touch-action: manipulation;
243
253
  }
244
- .interactive {
245
- display: block;
246
- margin: 0;
247
- }
248
254
  .interactive .spatial-element-visual {
249
- /* One owner for diagonal single-finger motion; two-finger page zoom stays native. */
250
- touch-action: pinch-zoom;
255
+ /* The native rail owns horizontal panning; vertical page scroll and zoom stay native. */
256
+ touch-action: manipulation;
251
257
  }
252
258
  .interactive[hidden] {
253
259
  /* Keep known summary dimensions measurable without painting or registering GPU actors. */
254
- display: block;
260
+ display: grid;
255
261
  visibility: hidden;
256
262
  }
257
263
  .interactive .summary {
258
- position: absolute;
259
- left: 0;
260
- top: 0;
261
- width: 40%;
262
- box-sizing: border-box;
263
264
  z-index: 1400;
264
265
  transform-origin: 0 0;
265
- transform: translate(150%, 24px);
266
+ }
267
+ .spatial-element-target,
268
+ .spatial-element-poster {
269
+ position: absolute;
270
+ left: var(--carousel-poster-x, 31%);
271
+ top: var(--carousel-poster-y, 50%);
272
+ width: calc(var(--carousel-poster-size, 0.82) * 100cqw);
273
+ max-width: calc(var(--carousel-poster-size, 0.82) * 560px);
274
+ transform: translate(-50%, -50%);
275
+ aspect-ratio: 1;
266
276
  }
267
277
  .spatial-element-target {
278
+ display: block;
279
+ color: inherit;
280
+ text-decoration: none;
268
281
  border: none;
269
282
  background: transparent;
270
283
  cursor: pointer;
@@ -272,10 +285,6 @@
272
285
  padding: 0;
273
286
  aspect-ratio: 1;
274
287
  }
275
- .interactive .spatial-element-target {
276
- position: absolute;
277
- transform: translate(-50%, -50%);
278
- }
279
288
  .spatial-element-target[hidden] {
280
289
  display: none;
281
290
  }
@@ -284,21 +293,41 @@
284
293
  outline-offset: 4px;
285
294
  border-radius: 12px;
286
295
  }
296
+ /* Enhanced geometry already has a silhouette focus outline in the renderer. */
297
+ .interactive:global([data-catalog-model-ready]) .spatial-element-target:focus-visible {
298
+ outline: none;
299
+ }
287
300
  img {
288
- width: 100%;
289
- height: 100%;
301
+ opacity: var(--carousel-poster-opacity, 1);
302
+ height: auto;
303
+ pointer-events: none;
290
304
  object-fit: contain;
305
+ filter: var(--carousel-hover-blur, var(--carousel-depth-blur, blur(0px))) var(--carousel-hover-shadow, drop-shadow(0 0 0 transparent));
306
+ transition: filter 180ms ease, opacity 240ms ease;
307
+ }
308
+ .spatial-element-target:global([data-mouse-hover]) + img,
309
+ .spatial-element-target:focus-visible + img {
310
+ --carousel-hover-blur: blur(0px);
311
+ --carousel-hover-shadow: drop-shadow(0 0 3px var(--spatial-element-accent));
291
312
  }
292
- .carousel-spatial-element:global([data-catalog-model-ready]) img {
313
+ .interactive:global([data-catalog-model-ready]) img {
293
314
  opacity: 0;
315
+ /* The GPU replaces the poster in this frame. Fading it would draw a second
316
+ product beneath the moving model when a return transition releases it. */
317
+ transition: filter 180ms ease;
294
318
  }
295
319
  .summary {
296
320
  position: relative;
321
+ width: min(494px, 100%);
322
+ min-height: 504px;
323
+ margin-left: 50%;
324
+ box-sizing: border-box;
325
+ filter: var(--carousel-focus-blur, none);
297
326
 
298
327
  border-radius: var(--carousel-panel-radius, 14px);
299
- padding: 28px;
328
+ padding: var(--summary-content-inset);
300
329
 
301
- color: var(--spatial-element-ink);
330
+ color: color-mix(in srgb, var(--spatial-element-ink) 92%, transparent);
302
331
  pointer-events: auto;
303
332
  }
304
333
  .summary::before {
@@ -328,37 +357,15 @@
328
357
  display: block;
329
358
  visibility: hidden;
330
359
  }
331
- .eyebrow {
332
- font-weight: 720;
333
- font-size: 13px;
334
- }
335
- h3 {
336
- font-size: clamp(24px, 2.5vw, 36px);
337
- line-height: 1.15;
338
- margin: 12px 0 28px;
339
- }
340
- ul {
341
- padding-left: 20px;
342
- line-height: 1.6;
343
- }
344
- li {
345
- margin: 12px 0;
346
- }
347
- .action {
348
- display: block;
349
- width: 100%;
350
- box-sizing: border-box;
351
- padding: 14px;
352
- margin-top: 24px;
353
- border: 0;
354
- border-radius: 8px;
355
- background: var(--spatial-element-accent);
356
- color: white;
357
- text-align: center;
358
- text-decoration: none;
359
- font: inherit;
360
- font-weight: 650;
361
- }
360
+ .summary > .information-links {
361
+ position: absolute;
362
+ top: 100%;
363
+ left: 0;
364
+ width: 100%;
365
+ display: flex;
366
+ flex-wrap: wrap;
367
+ gap: 0 16px;
368
+ }
362
369
  .information {
363
370
  display: inline-block;
364
371
  margin-top: 20px;
@@ -379,14 +386,22 @@
379
386
  white-space: nowrap;
380
387
  }
381
388
  @container (max-width: 700px) {
382
- .interactive .summary {
383
- width: 92%;
384
- }
385
- }
386
- @media (max-width: 850px) {
387
389
  .carousel-spatial-element {
388
- grid-template-columns: 1fr;
389
- gap: 12px;
390
+ min-height: 0;
391
+ padding: 360px 0 80px;
392
+ align-items: start;
390
393
  }
394
+ .summary {
395
+ margin-inline: auto;
396
+ }
397
+ .spatial-element-target,
398
+ .spatial-element-poster {
399
+ left: var(--carousel-poster-mobile-x, 50%);
400
+ top: 180px;
401
+ max-width: calc(var(--carousel-poster-size, 0.82) * 360px);
402
+ }
403
+ }
404
+ @media (prefers-reduced-motion: reduce) {
405
+ img { transition: none; }
391
406
  }
392
407
  </style>
@@ -1,16 +1,20 @@
1
1
  import type { SpatialListItem } from '@spatial-elements/core/spatial-element/types';
2
- import type { CarouselPresentation } from '@spatial-elements/core/catalog/catalogPose';
2
+ import type { CarouselLayout, CarouselPresentation, CarouselEmphasis } from '@spatial-elements/core/catalog/catalogPose';
3
3
  type $$ComponentProps = {
4
4
  spatialElement: SpatialListItem;
5
5
  sectionId: string;
6
6
  presentation?: CarouselPresentation;
7
+ layout: CarouselLayout;
7
8
  index: number;
8
9
  count: number;
9
10
  phase: number;
11
+ emphasis?: CarouselEmphasis;
12
+ focus: number;
10
13
  windowPhase: number;
11
14
  selected: boolean;
12
15
  interactive: boolean;
13
16
  onselect: () => void;
17
+ canActivate: () => boolean;
14
18
  };
15
19
  declare const CarouselSpatialElement: import("svelte").Component<$$ComponentProps, {}, "">;
16
20
  type CarouselSpatialElement = ReturnType<typeof CarouselSpatialElement>;
@@ -19,7 +19,8 @@
19
19
  children?: Snippet;
20
20
  }
21
21
  let { page, hdr, children }: Props = $props();
22
- const brand = useSpatialTheme();
22
+ const readTheme = useSpatialTheme();
23
+ const brand = $derived(readTheme());
23
24
  registerSpatialPage(() => ({ kind: 'content', hdr }));
24
25
  setContext(SPATIAL_ELEMENT_SECTION_REGISTRY_KEY, new SpatialElementSectionRegistry());
25
26
  setContext(SECTION_PAGE_KIND, 'content');
@@ -0,0 +1,78 @@
1
+ <script lang="ts">
2
+ import { onMount } from 'svelte';
3
+ import { MoveHorizontal, Search, Rotate3D } from 'lucide-svelte';
4
+ import { carouselTextHit } from './carouselTextHit.js';
5
+ let badge: HTMLDivElement;
6
+ let action = $state<'move' | 'details' | 'rotate' | undefined>();
7
+ onMount(() => {
8
+ let frame = 0, x = 0, y = 0, buttons = 0;
9
+ let text: HTMLElement | undefined;
10
+ const clearText = () => { text?.removeAttribute('data-carousel-text-hit'); text = undefined; };
11
+ const hide = () => { cancelAnimationFrame(frame); frame = 0; action = undefined; clearText(); };
12
+ const update = () => {
13
+ frame = 0;
14
+ clearText();
15
+ const target = document.elementFromPoint(x, y);
16
+ const shell = badge.closest('.brand-stage-shell');
17
+ if (!target || !shell?.contains(target) || target.closest('[data-catalog-transition]')) { action = undefined; return; }
18
+ const section = target.closest('.carousel-drag-section');
19
+ const dragging = section?.hasAttribute('data-carousel-dragging');
20
+ if (section?.querySelector('.carousel.interactive')) {
21
+ text = !dragging ? carouselTextHit(target, x, y) : undefined;
22
+ text?.setAttribute('data-carousel-text-hit', '');
23
+ const geometry = target.closest('.spatial-element-target');
24
+ action = dragging ? 'move' : text || (buttons & 1) || (!geometry && target.closest('a, button, input, textarea, select, [contenteditable]'))
25
+ ? undefined : geometry?.closest('.selected') ? 'details' : 'move';
26
+ } else {
27
+ const cursor = target instanceof HTMLCanvasElement ? target.style.cursor : '';
28
+ action = cursor === 'grab' || cursor === 'grabbing' ? 'rotate' : undefined;
29
+ }
30
+ };
31
+ const move = (event: PointerEvent) => {
32
+ if (event.pointerType !== 'mouse') { hide(); return; }
33
+ x = event.clientX; y = event.clientY; buttons = event.buttons;
34
+ // Position immediately, independently of the frame-batched hit testing.
35
+ // No reactive update or interpolation between the pointer and its hint.
36
+ badge.style.transform = `translate3d(${Math.max(0, Math.min(x + 10, innerWidth - 22))}px, ${Math.max(0, Math.min(y + 14, innerHeight - 22))}px, 0)`;
37
+ if (!frame) frame = requestAnimationFrame(update);
38
+ };
39
+ window.addEventListener('pointermove', move);
40
+ window.addEventListener('pointerdown', move);
41
+ window.addEventListener('pointerup', move);
42
+ window.addEventListener('blur', hide);
43
+ window.addEventListener('pointercancel', hide);
44
+ window.addEventListener('keydown', hide);
45
+ window.addEventListener('scroll', hide, true);
46
+ document.documentElement.addEventListener('pointerleave', hide);
47
+ const observer = new MutationObserver(hide);
48
+ observer.observe(badge.closest('.brand-stage-shell')!, {subtree:true, attributes:true, attributeFilter:['data-catalog-transition']});
49
+ return () => {
50
+ hide();
51
+ observer.disconnect();
52
+ window.removeEventListener('pointermove', move);
53
+ window.removeEventListener('pointerdown', move);
54
+ window.removeEventListener('pointerup', move);
55
+ window.removeEventListener('blur', hide);
56
+ window.removeEventListener('pointercancel', hide);
57
+ window.removeEventListener('keydown', hide);
58
+ window.removeEventListener('scroll', hide, true);
59
+ document.documentElement.removeEventListener('pointerleave', hide);
60
+ };
61
+ });
62
+ </script>
63
+
64
+ <div bind:this={badge} class="pointer-hint" data-pointer-hint={action} hidden={!action} aria-hidden="true">
65
+ {#if action === 'move'}<MoveHorizontal size={20} strokeWidth={1.8} />
66
+ {:else if action === 'details'}<Search size={20} strokeWidth={1.8} />
67
+ {:else if action === 'rotate'}<Rotate3D size={20} strokeWidth={1.8} />{/if}
68
+ </div>
69
+
70
+ <style>
71
+ .pointer-hint { position: fixed; left: 0; top: 0; z-index: 2147483647; pointer-events: none;
72
+ display: grid; place-items: center; width: 20px; height: 20px;
73
+ color: var(--spatial-element-ink); will-change: transform;
74
+ /* Contrast follows the strokes only, without a button-like surface. */
75
+ filter: drop-shadow(0 0 1px var(--spatial-element-background))
76
+ drop-shadow(0 0 1px var(--spatial-element-background)); }
77
+ .pointer-hint[hidden] { display: none; }
78
+ </style>
@@ -0,0 +1,3 @@
1
+ declare const PointerHint: import("svelte").Component<Record<string, never>, {}, "">;
2
+ type PointerHint = ReturnType<typeof PointerHint>;
3
+ export default PointerHint;