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

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 (87) hide show
  1. package/dist/catalog/ScrollNavigationBridge.svelte +170 -45
  2. package/dist/catalog/ScrollNavigationBridge.svelte.d.ts +9 -2
  3. package/dist/catalog/catalogSummaryTransfer.d.ts +16 -0
  4. package/dist/catalog/catalogSummaryTransfer.js +79 -0
  5. package/dist/catalog/catalogTransition.css +46 -3
  6. package/dist/catalog/interruptedPresentation.d.ts +10 -0
  7. package/dist/catalog/interruptedPresentation.js +29 -0
  8. package/dist/catalog/presentationCleanup.d.ts +4 -0
  9. package/dist/catalog/presentationCleanup.js +20 -0
  10. package/dist/catalog/stagedCatalogNavigation.d.ts +44 -0
  11. package/dist/catalog/stagedCatalogNavigation.js +403 -0
  12. package/dist/catalog/stagedDomReveal.d.ts +8 -0
  13. package/dist/catalog/stagedDomReveal.js +76 -0
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.js +1 -0
  16. package/dist/spatial-element/BrandStageShell.svelte +20 -2
  17. package/dist/spatial-element/BrandStageShell.svelte.d.ts +10 -0
  18. package/dist/spatial-element/CarouselSection.svelte +40 -21
  19. package/dist/spatial-element/CarouselSpatialElement.svelte +49 -115
  20. package/dist/spatial-element/ContentBlock.svelte +53 -0
  21. package/dist/spatial-element/ContentBlock.svelte.d.ts +11 -0
  22. package/dist/spatial-element/ContentGrid.svelte +28 -0
  23. package/dist/spatial-element/ContentGrid.svelte.d.ts +10 -0
  24. package/dist/spatial-element/ContentPage.svelte +28 -20
  25. package/dist/spatial-element/ContentPage.svelte.d.ts +3 -0
  26. package/dist/spatial-element/ListSection.svelte +17 -5
  27. package/dist/spatial-element/ListSection.svelte.d.ts +5 -0
  28. package/dist/spatial-element/PointerHint.svelte +3 -1
  29. package/dist/spatial-element/Section.svelte +51 -40
  30. package/dist/spatial-element/Section.svelte.d.ts +1 -0
  31. package/dist/spatial-element/SectionSurfaceGroup.svelte +34 -0
  32. package/dist/spatial-element/SectionSurfaceGroup.svelte.d.ts +7 -0
  33. package/dist/spatial-element/SpatialCardPresentation.svelte +378 -0
  34. package/dist/spatial-element/SpatialCardPresentation.svelte.d.ts +13 -0
  35. package/dist/spatial-element/SpatialCardSlot.svelte +33 -0
  36. package/dist/spatial-element/SpatialCardSlot.svelte.d.ts +8 -0
  37. package/dist/spatial-element/SpatialElementBreadcrumbs.svelte +20 -12
  38. package/dist/spatial-element/SpatialElementBreadcrumbs.svelte.d.ts +1 -0
  39. package/dist/spatial-element/SpatialElementCard.svelte +19 -318
  40. package/dist/spatial-element/SpatialElementCard.svelte.d.ts +3 -0
  41. package/dist/spatial-element/SpatialElementHelp.svelte +21 -15
  42. package/dist/spatial-element/SpatialElementHelp.svelte.d.ts +4 -1
  43. package/dist/spatial-element/SpatialElementMediaRail.svelte +75 -21
  44. package/dist/spatial-element/SpatialElementMediaRail.svelte.d.ts +3 -0
  45. package/dist/spatial-element/SpatialElementNativeMedia.svelte +36 -0
  46. package/dist/spatial-element/SpatialElementNativeMedia.svelte.d.ts +9 -0
  47. package/dist/spatial-element/SpatialElementPage.svelte +127 -68
  48. package/dist/spatial-element/SpatialElementPage.svelte.d.ts +1 -0
  49. package/dist/spatial-element/SpatialElementStickyHeader.svelte +36 -69
  50. package/dist/spatial-element/SpatialElementStickyHeader.svelte.d.ts +1 -0
  51. package/dist/spatial-element/SpatialElementSummaryContent.svelte +14 -11
  52. package/dist/spatial-element/SpatialElementSummaryPanel.svelte +29 -20
  53. package/dist/spatial-element/SpatialElementSummaryPanel.svelte.d.ts +1 -0
  54. package/dist/spatial-element/SpatialElementTabList.svelte +19 -3
  55. package/dist/spatial-element/SpatialElementTabs.svelte +56 -16
  56. package/dist/spatial-element/SpatialElementTabs.svelte.d.ts +1 -0
  57. package/dist/spatial-element/SpatialElementViewToggle.svelte +5 -4
  58. package/dist/spatial-element/SpatialIconButton.svelte +4 -2
  59. package/dist/spatial-element/SpatialNavigationShell.svelte +129 -0
  60. package/dist/spatial-element/SpatialNavigationShell.svelte.d.ts +10 -0
  61. package/dist/spatial-element/SpatialSummaryHost.svelte +19 -0
  62. package/dist/spatial-element/SpatialSummaryHost.svelte.d.ts +9 -0
  63. package/dist/spatial-element/SpatialSummaryRoot.svelte +78 -0
  64. package/dist/spatial-element/SpatialSummaryRoot.svelte.d.ts +8 -0
  65. package/dist/spatial-element/SpatialSummarySlot.svelte +39 -0
  66. package/dist/spatial-element/SpatialSummarySlot.svelte.d.ts +9 -0
  67. package/dist/spatial-element/SpatialViewIcon.svelte +29 -0
  68. package/dist/spatial-element/SpatialViewIcon.svelte.d.ts +6 -0
  69. package/dist/spatial-element/cardAppearanceFreeze.d.ts +5 -0
  70. package/dist/spatial-element/cardAppearanceFreeze.js +72 -0
  71. package/dist/spatial-element/index.d.ts +6 -2
  72. package/dist/spatial-element/index.js +3 -1
  73. package/dist/spatial-element/layout.generated.css +455 -0
  74. package/dist/spatial-element/presentationBoxFreeze.d.ts +8 -0
  75. package/dist/spatial-element/presentationBoxFreeze.js +35 -0
  76. package/dist/spatial-element/spatialPresentationOwner.d.ts +6 -0
  77. package/dist/spatial-element/spatialPresentationOwner.js +2 -0
  78. package/dist/spatial-element/spatialSummary.d.ts +37 -0
  79. package/dist/spatial-element/spatialSummary.js +1 -0
  80. package/dist/spatial-element/spatialSummaryHost.svelte.d.ts +60 -0
  81. package/dist/spatial-element/spatialSummaryHost.svelte.js +233 -0
  82. package/dist/spatial-element/spatialThemeStyle.js +10 -4
  83. package/dist/stage/ButtonGroup.svelte +1 -1
  84. package/dist/stage/Panel.svelte +16 -4
  85. package/dist/stage/Stage.svelte +183 -26
  86. package/dist/stage/Stage.svelte.d.ts +1 -0
  87. package/package.json +2 -2
@@ -0,0 +1,233 @@
1
+ import { hydrate, mount, unmount, untrack } from 'svelte';
2
+ import { PresentationLease } from '@spatial-elements/core/catalog/PresentationLease';
3
+ import SpatialSummaryRoot from './SpatialSummaryRoot.svelte';
4
+ import { freezePresentationBox } from './presentationBoxFreeze.js';
5
+ import { releasePresentationResources } from '../catalog/presentationCleanup.js';
6
+ export const SPATIAL_SUMMARY_HOST = Symbol('spatial-summary-host');
7
+ /** Real Svelte instance ownership is independent of a route's placement node. */
8
+ export class SpatialSummaryHostController {
9
+ content;
10
+ contexts;
11
+ records = new Map();
12
+ roots = new Set();
13
+ placements = new WeakMap();
14
+ pendingModels = new Map();
15
+ disposed = false;
16
+ constructor(content, contexts) {
17
+ this.content = content;
18
+ this.contexts = contexts;
19
+ }
20
+ attach(slot, key, context) {
21
+ return this.attachModel(slot, key, { kind: 'summary', current: context, active: true });
22
+ }
23
+ attachCard(slot, key, context) {
24
+ return this.attachModel(slot, key, { kind: 'card', current: context, active: true });
25
+ }
26
+ attachModel(slot, key, initial) {
27
+ let active = true;
28
+ const placement = {};
29
+ // A slot's reactive context can change before its deferred Svelte root mounts
30
+ // (for example the carousel's SSR width is replaced by the mobile viewport).
31
+ // Keep those updates with the incoming placement, not an older held record.
32
+ const pending = { model: initial };
33
+ this.pendingModels.set(key, pending);
34
+ const forgetPending = () => { if (this.pendingModels.get(key) === pending)
35
+ this.pendingModels.delete(key); };
36
+ this.placements.set(slot, placement);
37
+ queueMicrotask(() => {
38
+ if (!active || this.disposed) {
39
+ forgetPending();
40
+ return;
41
+ }
42
+ try {
43
+ const previous = this.records.get(key);
44
+ if (previous && !previous.held)
45
+ throw new Error(`Duplicate presentation occurrence: ${key}`);
46
+ let root = slot.querySelector('[data-spatial-presentation-root]');
47
+ const serverRoot = Boolean(root);
48
+ if (!root) {
49
+ root = document.createElement('div');
50
+ root.dataset.spatialPresentationRoot = '';
51
+ root.className = initial.kind === 'card' ? 'spatial-card-root' : 'spatial-summary-island';
52
+ slot.append(root);
53
+ }
54
+ root.dataset.spatialPresentationKey = key;
55
+ const model = $state(pending.model);
56
+ pending.model = model;
57
+ if (model.kind === 'summary') {
58
+ root.style.setProperty('--spatial-summary-content-inset', `${model.current.contentInset}px`);
59
+ root.dataset.presentationMode = model.current.mode;
60
+ }
61
+ const options = { target: root, props: { content: this.content(), model }, context: this.contexts };
62
+ const component = serverRoot ? hydrate(SpatialSummaryRoot, { ...options, recover: false }) : mount(SpatialSummaryRoot, options);
63
+ const lease = new PresentationLease(root, () => {
64
+ releasePresentationResources('Unable to unmount spatial presentation', [
65
+ () => unmount(component),
66
+ () => root.remove(),
67
+ () => {
68
+ if (this.records.get(record.key) === record)
69
+ this.records.delete(record.key);
70
+ this.roots.delete(record);
71
+ }
72
+ ]);
73
+ });
74
+ const owner = lease.claim();
75
+ const record = { key, kind: model.kind, root, slot, model, component, lease, owner, held: false };
76
+ placement.release = owner.release;
77
+ this.records.set(key, record);
78
+ this.roots.add(record);
79
+ }
80
+ finally {
81
+ forgetPending();
82
+ }
83
+ });
84
+ return () => { active = false; forgetPending(); placement.release?.(); this.placements.delete(slot); };
85
+ }
86
+ update(key, context) { untrack(() => this.updateModel(key, 'summary', context)); }
87
+ updateCard(key, context) { untrack(() => this.updateModel(key, 'card', context)); }
88
+ updateModel(key, kind, context) {
89
+ const pending = this.pendingModels.get(key);
90
+ if (pending?.model.kind === kind) {
91
+ if (pending.model.kind === 'summary')
92
+ pending.model.current = context;
93
+ else
94
+ pending.model.current = context;
95
+ return;
96
+ }
97
+ const record = this.records.get(key);
98
+ if (!record || record.kind !== kind)
99
+ return;
100
+ if (record.frozen) {
101
+ record.frozen.pending = context;
102
+ return;
103
+ }
104
+ this.applyContext(record, context);
105
+ }
106
+ applyContext(record, context) {
107
+ if (record.model.kind === 'summary') {
108
+ record.model.current = context;
109
+ record.root.dataset.presentationMode = context.mode;
110
+ record.root.style.setProperty('--spatial-summary-content-inset', `${context.contentInset}px`);
111
+ }
112
+ else
113
+ record.model.current = context;
114
+ }
115
+ retainByElement(element) {
116
+ const matches = [...this.roots].filter(entry => entry.root === element || entry.root.contains(element) || element.contains(entry.root));
117
+ const record = matches.length === 1 ? matches[0] : undefined;
118
+ return record && this.retainRecord(record);
119
+ }
120
+ retain(key) {
121
+ const record = this.records.get(key);
122
+ return record && this.retainRecord(record);
123
+ }
124
+ retainRecord(record) {
125
+ if (this.disposed)
126
+ return;
127
+ const owner = record.owner = record.lease.claim();
128
+ const originalSlot = record.slot, originalKey = record.key;
129
+ const unfreeze = () => {
130
+ const frozen = record.frozen;
131
+ if (!frozen)
132
+ return;
133
+ record.root.style.cssText = frozen.css;
134
+ record.root.inert = frozen.inert;
135
+ delete record.root.dataset.spatialPresentationFrozen;
136
+ delete record.root.dataset.spatialPresentationGlass;
137
+ delete record.root.dataset.spatialPresentationModelReady;
138
+ record.frozen = undefined;
139
+ if (frozen.pending)
140
+ this.applyContext(record, frozen.pending);
141
+ if (!record.held)
142
+ record.model.active = true;
143
+ };
144
+ const freeze = () => {
145
+ if (record.frozen)
146
+ return record.frozen.box;
147
+ const root = record.root;
148
+ record.frozen = freezePresentationBox(root);
149
+ root.dataset.spatialPresentationFrozen = '';
150
+ if (root.closest('[data-carousel-glass-ready]'))
151
+ root.dataset.spatialPresentationGlass = '';
152
+ // Catalog disposal clears the original card's ready marker. Its captured GPU
153
+ // geometry still owns the image while this complete source island is held.
154
+ if (root.querySelector('[data-catalog-card][data-catalog-model-ready]'))
155
+ root.dataset.spatialPresentationModelReady = '';
156
+ return record.frozen.box;
157
+ };
158
+ return {
159
+ record, freeze,
160
+ hold: targetHost => {
161
+ const box = freeze();
162
+ record.held = true;
163
+ record.model.active = false;
164
+ record.root.inert = true;
165
+ Object.assign(record.root.style, { position: 'absolute', left: '0px', top: '0px', margin: '0px', pointerEvents: 'none' });
166
+ targetHost.append(record.root);
167
+ return box;
168
+ },
169
+ adopt: (slot, key, context) => {
170
+ if (this.disposed || !owner.isCurrent() || record.kind !== 'summary')
171
+ return false;
172
+ const destination = [...this.roots].find(entry => entry.slot === slot && entry !== record);
173
+ const placement = this.placements.get(slot);
174
+ if (!destination || destination.kind !== 'summary' || !placement)
175
+ return false;
176
+ const nextContext = context ?? destination.model.current;
177
+ const nextKey = key ?? destination.key;
178
+ destination.owner.release();
179
+ if (this.records.get(record.key) === record)
180
+ this.records.delete(record.key);
181
+ record.key = nextKey;
182
+ record.slot = slot;
183
+ record.root.dataset.spatialPresentationKey = nextKey;
184
+ record.owner = record.lease.claim();
185
+ placement.release = record.owner.release;
186
+ this.records.set(nextKey, record);
187
+ slot.append(record.root);
188
+ record.held = false;
189
+ // Do not register the outgoing address again between adoption and destination-model commit.
190
+ record.model.active = false;
191
+ if (record.frozen)
192
+ record.frozen.pending = nextContext;
193
+ else {
194
+ this.applyContext(record, nextContext);
195
+ record.model.active = true;
196
+ }
197
+ return true;
198
+ },
199
+ restore: () => {
200
+ const placement = this.placements.get(originalSlot);
201
+ const current = this.records.get(originalKey);
202
+ if (this.disposed || !owner.isCurrent() || !originalSlot.isConnected || !placement || current && current !== record)
203
+ return false;
204
+ if (record.root.parentElement !== originalSlot)
205
+ originalSlot.append(record.root);
206
+ if (this.records.get(record.key) === record)
207
+ this.records.delete(record.key);
208
+ record.key = originalKey;
209
+ record.slot = originalSlot;
210
+ record.root.dataset.spatialPresentationKey = originalKey;
211
+ record.owner = record.lease.claim();
212
+ placement.release = record.owner.release;
213
+ this.records.set(originalKey, record);
214
+ record.held = false;
215
+ unfreeze();
216
+ record.model.active = true;
217
+ return true;
218
+ },
219
+ unfreeze,
220
+ release: owner.release
221
+ };
222
+ }
223
+ destroy() {
224
+ if (this.disposed)
225
+ return;
226
+ this.disposed = true;
227
+ for (const record of this.roots)
228
+ record.owner.release();
229
+ this.records.clear();
230
+ this.pendingModels.clear();
231
+ this.roots.clear();
232
+ }
233
+ }
@@ -1,6 +1,9 @@
1
+ import { resolveSpatialSectionBackgrounds, resolveSpatialThemeRadii } from '@spatial-elements/core/spatial-element/spatialTheme';
1
2
  import { getCssPanelBoxShadow, resolvePanelShadowStrength } from '@spatial-elements/core/stage/panelShadow';
2
3
  /** CSS declarations shared by the shell and optional server-rendered theme previews. */
3
4
  export function getSpatialThemeStyle(theme) {
5
+ const radii = resolveSpatialThemeRadii(theme);
6
+ const sectionBackgrounds = resolveSpatialSectionBackgrounds(theme);
4
7
  return [
5
8
  `--spatial-element-background: ${theme.background}`,
6
9
  `--spatial-element-ink: ${theme.colors.ink}`,
@@ -8,16 +11,19 @@ export function getSpatialThemeStyle(theme) {
8
11
  `--spatial-element-accent: ${theme.colors.accent}`,
9
12
  `--spatial-element-on-accent: ${theme.colors.onAccent}`,
10
13
  `--spatial-element-section-tint: ${theme.sectionTheme.tint}`,
14
+ `--spatial-element-section-standard: ${sectionBackgrounds.standard}`,
15
+ `--spatial-element-section-muted: ${sectionBackgrounds.muted}`,
11
16
  `--spatial-element-section-tint-opacity: ${toPercentage(theme.sectionTheme.tintOpacity)}`,
12
- `--spatial-element-section-backdrop-blur: ${Math.max(theme.sectionTheme.backdropBlur, 0)}px`,
17
+ `--spatial-element-section-backdrop-blur: ${clamp(theme.sectionTheme.backdropBlur, 0, 100)}px`,
13
18
  `--spatial-element-tab-background: ${theme.colors.tabBackground}`,
14
- `--spatial-element-panel-radius: ${theme.panelShape.radius}px`,
19
+ `--spatial-element-control-radius: ${radii.control}px`,
20
+ `--spatial-element-panel-radius: ${radii.panel}px`,
15
21
  `--spatial-element-docked-panel-tint-rgb: ${getDockedPanelTintRgb(theme.dockedPanelTheme.tint)}`,
16
22
  `--spatial-element-docked-panel-tint-opacity: ${clamp(theme.dockedPanelTheme.tintOpacity, 0, 1)}`,
17
23
  `--spatial-element-docked-panel-shadow-intensity: ${clamp(theme.dockedPanelTheme.shadowIntensity, 0, 1)}`,
18
24
  `--spatial-element-docked-panel-shadow-strength: ${resolvePanelShadowStrength(theme.dockedPanelTheme.shadowIntensity)}`,
19
25
  `--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`
26
+ `--spatial-element-docked-panel-backdrop-blur: ${clamp(theme.dockedPanelTheme.backdropBlur, 0, 100)}px`
21
27
  ].join('; ');
22
28
  }
23
29
  function toPercentage(value) {
@@ -44,5 +50,5 @@ function hexToRgb(hex) {
44
50
  return `${(value >> 16) & 255} ${(value >> 8) & 255} ${value & 255}`;
45
51
  }
46
52
  function clamp(value, min, max) {
47
- return Math.min(Math.max(value, min), max);
53
+ return Number.isFinite(value) ? Math.min(Math.max(value, min), max) : min;
48
54
  }
@@ -41,7 +41,7 @@
41
41
  }: Props = $props();
42
42
  let group: HTMLDivElement;
43
43
  let measuredWidth = $state<number>();
44
- const radius = $derived(Math.min(12, Math.max(0, shape.radius)));
44
+ const radius = $derived(Number.isFinite(shape.radius) ? Math.max(0, shape.radius) : 12);
45
45
  const width = $derived(
46
46
  iconOnly ? `${items.length * 40}px` : measuredWidth ? `${measuredWidth}px` : 'max-content'
47
47
  );
@@ -86,12 +86,15 @@
86
86
  getFocusReactive: () => focusReactive,
87
87
  getFocusAnchor: () => focusAnchor,
88
88
  getNativeContent: () => nativeContent,
89
- updateNativeLayout: () => nativeLayout?.(),
89
+ // Absence matters: only an actively positioned popover needs a fresh
90
+ // native measurement on every render; ordinary panels use the layout cache.
91
+ get updateNativeLayout() { return nativeLayout; },
90
92
  getVisible: () => visible,
91
93
  getMinimapOptions: () => getMinimapOptions(),
92
94
  getMinimapDockProgress,
93
95
  getMinimapModelScale,
94
96
  getMinimapModelTop,
97
+ getMinimapModelLeft,
95
98
  getSurface: () => resolvedSurface,
96
99
  getSurfaceOpacity,
97
100
  getOptions: getPanelOptions
@@ -103,6 +106,7 @@
103
106
  getContentInset();
104
107
  Object.values(getMinimapOptions() ?? {});
105
108
  void resolvedSurface;
109
+ void nativeContent;
106
110
  stage.updatePanelAppearance?.();
107
111
  });
108
112
  $effect(() => {
@@ -170,6 +174,11 @@
170
174
  return Number.isFinite(value) ? value : undefined;
171
175
  }
172
176
 
177
+ function getMinimapModelLeft() {
178
+ const value = Number.parseFloat(frameElement?.dataset.stageMinimapModelLeft ?? '');
179
+ return Number.isFinite(value) ? value : undefined;
180
+ }
181
+
173
182
  function getFallbackStyle() {
174
183
  const tintOpacity = clamp(theme.tintOpacity ?? 0.28, 0, 1);
175
184
  const shadowIntensity = getShadowIntensity();
@@ -330,7 +339,7 @@
330
339
  /* Content can leave its CSS surface when glass uses the DOM projection layer. */
331
340
  opacity: calc(
332
341
  var(--stage-panel-opacity, 1) * var(--stage-panel-content-opacity, 1) *
333
- var(--stage-transition-opacity, 1)
342
+ var(--catalog-reveal-opacity, var(--stage-transition-opacity, 1))
334
343
  );
335
344
  }
336
345
 
@@ -344,6 +353,9 @@
344
353
 
345
354
  .stage-panel-surface::before,
346
355
  .stage-panel-surface::after {
356
+ /* These two paint owners share their surface's local reveal value. Ordinary
357
+ * descendants do not inherit it; the content has its own existing factor. */
358
+ --catalog-reveal-opacity: inherit;
347
359
  position: absolute;
348
360
  inset: 0;
349
361
  border-radius: inherit;
@@ -351,7 +363,7 @@
351
363
  content: '';
352
364
  opacity: calc(
353
365
  var(--stage-panel-opacity) * var(--stage-panel-surface-opacity, 1) *
354
- var(--stage-panel-focus-opacity, 1) * var(--stage-transition-opacity, 1)
366
+ var(--stage-panel-focus-opacity, 1) * var(--catalog-reveal-opacity, var(--stage-transition-opacity, 1))
355
367
  );
356
368
  }
357
369
 
@@ -379,7 +391,7 @@
379
391
  opacity: calc(
380
392
  var(--stage-panel-opacity) * var(--stage-panel-surface-opacity, 1) *
381
393
  var(--stage-panel-focus-opacity, 1) * var(--stage-panel-specular-opacity) *
382
- var(--stage-transition-opacity, 1)
394
+ var(--catalog-reveal-opacity, var(--stage-transition-opacity, 1))
383
395
  );
384
396
  }
385
397