@syntrologie/runtime-sdk 0.2.21 → 1.0.0
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.
- package/CAPABILITIES.md +944 -440
- package/README.md +395 -66
- package/dist/RuntimeProvider.d.ts +51 -0
- package/dist/RuntimeProvider.js +113 -0
- package/dist/RuntimeProvider.js.map +1 -0
- package/dist/SmartCanvasApp.d.ts +16 -10
- package/dist/SmartCanvasApp.js +47 -51
- package/dist/SmartCanvasApp.js.map +1 -1
- package/dist/SmartCanvasElement.d.ts +5 -5
- package/dist/SmartCanvasElement.js +24 -14
- package/dist/SmartCanvasElement.js.map +1 -1
- package/dist/SmartCanvasPortal.d.ts +2 -2
- package/dist/SmartCanvasPortal.js +2 -2
- package/dist/SmartCanvasPortal.js.map +1 -1
- package/dist/actions/ActionEngine.d.ts +11 -0
- package/dist/actions/ActionEngine.js +272 -0
- package/dist/actions/ActionEngine.js.map +1 -0
- package/dist/actions/executors/index.d.ts +116 -0
- package/dist/actions/executors/index.js +240 -0
- package/dist/actions/executors/index.js.map +1 -0
- package/dist/actions/executors/tour.d.ts +18 -0
- package/dist/actions/executors/tour.js +332 -0
- package/dist/actions/executors/tour.js.map +1 -0
- package/dist/actions/index.d.ts +10 -0
- package/dist/actions/index.js +12 -0
- package/dist/actions/index.js.map +1 -0
- package/dist/actions/types.d.ts +399 -0
- package/dist/actions/types.js +8 -0
- package/dist/actions/types.js.map +1 -0
- package/dist/actions/validation.d.ts +14 -0
- package/dist/actions/validation.js +577 -0
- package/dist/actions/validation.js.map +1 -0
- package/dist/adaptives/adaptive-chatbot/index.js +9 -0
- package/dist/adaptives/adaptive-chatbot/index.js.map +7 -0
- package/dist/adaptives/adaptive-content/index.js +2 -0
- package/dist/adaptives/adaptive-content/index.js.map +7 -0
- package/dist/adaptives/adaptive-faq/index.js +11 -0
- package/dist/adaptives/adaptive-faq/index.js.map +7 -0
- package/dist/adaptives/adaptive-gamification/index.js +2 -0
- package/dist/adaptives/adaptive-gamification/index.js.map +7 -0
- package/dist/adaptives/adaptive-nav/index.js +11 -0
- package/dist/adaptives/adaptive-nav/index.js.map +7 -0
- package/dist/adaptives/adaptive-overlays/index.js +91 -0
- package/dist/adaptives/adaptive-overlays/index.js.map +7 -0
- package/dist/antiFlicker.js +1 -1
- package/dist/api.d.ts +40 -26
- package/dist/api.js +87 -60
- package/dist/api.js.map +1 -1
- package/dist/apps/AppContext.d.ts +31 -0
- package/dist/apps/AppContext.js +91 -0
- package/dist/apps/AppContext.js.map +1 -0
- package/dist/apps/AppLoader.d.ts +85 -0
- package/dist/apps/AppLoader.js +282 -0
- package/dist/apps/AppLoader.js.map +1 -0
- package/dist/apps/AppRegistry.d.ts +102 -0
- package/dist/apps/AppRegistry.js +317 -0
- package/dist/apps/AppRegistry.js.map +1 -0
- package/dist/apps/examples/gamification-app.example.d.ts +305 -0
- package/dist/apps/examples/gamification-app.example.js +329 -0
- package/dist/apps/examples/gamification-app.example.js.map +1 -0
- package/dist/apps/index.d.ts +14 -0
- package/dist/apps/index.js +16 -0
- package/dist/apps/index.js.map +1 -0
- package/dist/apps/types.d.ts +231 -0
- package/dist/apps/types.js +8 -0
- package/dist/apps/types.js.map +1 -0
- package/dist/blocks/data/ComparisonBlock.d.ts +1 -1
- package/dist/blocks/data/ComparisonBlock.js +40 -40
- package/dist/blocks/data/ComparisonBlock.js.map +1 -1
- package/dist/blocks/data/StatsBlock.d.ts +1 -1
- package/dist/blocks/data/StatsBlock.js +42 -44
- package/dist/blocks/data/StatsBlock.js.map +1 -1
- package/dist/blocks/data/index.d.ts +2 -2
- package/dist/blocks/data/index.js +2 -2
- package/dist/blocks/index.d.ts +5 -5
- package/dist/blocks/index.js +29 -30
- package/dist/blocks/index.js.map +1 -1
- package/dist/blocks/interactive/ChecklistBlock.d.ts +1 -1
- package/dist/blocks/interactive/ChecklistBlock.js +60 -60
- package/dist/blocks/interactive/ChecklistBlock.js.map +1 -1
- package/dist/blocks/interactive/RatingBlock.d.ts +1 -1
- package/dist/blocks/interactive/RatingBlock.js +73 -65
- package/dist/blocks/interactive/RatingBlock.js.map +1 -1
- package/dist/blocks/interactive/index.d.ts +2 -2
- package/dist/blocks/interactive/index.js +2 -2
- package/dist/blocks/notification/NotificationBlock.d.ts +2 -2
- package/dist/blocks/notification/NotificationBlock.js +68 -64
- package/dist/blocks/notification/NotificationBlock.js.map +1 -1
- package/dist/blocks/notification/index.d.ts +1 -1
- package/dist/blocks/notification/index.js +1 -1
- package/dist/bootstrap.d.ts +32 -8
- package/dist/bootstrap.js +218 -102
- package/dist/bootstrap.js.map +1 -1
- package/dist/components/ShadowCanvasOverlay.d.ts +6 -6
- package/dist/components/ShadowCanvasOverlay.js +156 -118
- package/dist/components/ShadowCanvasOverlay.js.map +1 -1
- package/dist/components/TileCard.d.ts +5 -5
- package/dist/components/TileCard.js +205 -154
- package/dist/components/TileCard.js.map +1 -1
- package/dist/components/TileWheel.d.ts +3 -3
- package/dist/components/TileWheel.js +29 -7
- package/dist/components/TileWheel.js.map +1 -1
- package/dist/config-validator.d.ts +49 -0
- package/dist/config-validator.js +173 -0
- package/dist/config-validator.js.map +1 -0
- package/dist/configFetcher.d.ts +7 -3
- package/dist/configFetcher.js +70 -29
- package/dist/configFetcher.js.map +1 -1
- package/dist/context/ContextManager.d.ts +3 -3
- package/dist/context/ContextManager.js +19 -18
- package/dist/context/ContextManager.js.map +1 -1
- package/dist/context/index.d.ts +4 -4
- package/dist/context/index.js +3 -3
- package/dist/context/schema.d.ts +9 -9
- package/dist/context/schema.js +2 -2
- package/dist/context/schema.js.map +1 -1
- package/dist/decisions/engine.d.ts +5 -5
- package/dist/decisions/engine.js +13 -13
- package/dist/decisions/engine.js.map +1 -1
- package/dist/decisions/index.d.ts +6 -6
- package/dist/decisions/index.js +5 -5
- package/dist/decisions/schema.d.ts +131 -131
- package/dist/decisions/schema.js +21 -21
- package/dist/decisions/schema.js.map +1 -1
- package/dist/decisions/strategies/rules.d.ts +1 -1
- package/dist/decisions/strategies/rules.js +24 -24
- package/dist/decisions/strategies/rules.js.map +1 -1
- package/dist/decisions/strategies/score.d.ts +1 -1
- package/dist/decisions/strategies/score.js +3 -3
- package/dist/decisions/types.d.ts +19 -19
- package/dist/earlyPatcher.d.ts +8 -20
- package/dist/earlyPatcher.js +13 -62
- package/dist/earlyPatcher.js.map +1 -1
- package/dist/editorLoader.d.ts +19 -7
- package/dist/editorLoader.js +154 -97
- package/dist/editorLoader.js.map +1 -1
- package/dist/events/EventBus.d.ts +3 -3
- package/dist/events/EventBus.js +5 -7
- package/dist/events/EventBus.js.map +1 -1
- package/dist/events/index.d.ts +6 -6
- package/dist/events/index.js +5 -5
- package/dist/events/normalizers/canvas.d.ts +2 -2
- package/dist/events/normalizers/canvas.js +3 -3
- package/dist/events/normalizers/canvas.js.map +1 -1
- package/dist/events/normalizers/posthog.d.ts +25 -1
- package/dist/events/normalizers/posthog.js +35 -27
- package/dist/events/normalizers/posthog.js.map +1 -1
- package/dist/events/schema.d.ts +13 -13
- package/dist/events/schema.js +3 -3
- package/dist/events/schema.js.map +1 -1
- package/dist/events/types.d.ts +7 -1
- package/dist/events/types.js +29 -21
- package/dist/events/types.js.map +1 -1
- package/dist/experiments/adapters/growthbook.d.ts +5 -4
- package/dist/experiments/adapters/growthbook.js +14 -6
- package/dist/experiments/adapters/growthbook.js.map +1 -1
- package/dist/experiments/index.d.ts +3 -3
- package/dist/experiments/index.js +1 -1
- package/dist/experiments/registry.d.ts +2 -2
- package/dist/experiments/registry.js +2 -2
- package/dist/experiments/types.d.ts +10 -1
- package/dist/fetchers/cdnFetcher.d.ts +1 -1
- package/dist/fetchers/cdnFetcher.js +4 -8
- package/dist/fetchers/cdnFetcher.js.map +1 -1
- package/dist/fetchers/experimentsFetcher.d.ts +25 -3
- package/dist/fetchers/experimentsFetcher.js +55 -8
- package/dist/fetchers/experimentsFetcher.js.map +1 -1
- package/dist/fetchers/index.d.ts +3 -3
- package/dist/fetchers/index.js +2 -2
- package/dist/fetchers/index.js.map +1 -1
- package/dist/fetchers/mergeConfigs.d.ts +29 -0
- package/dist/fetchers/mergeConfigs.js +38 -0
- package/dist/fetchers/mergeConfigs.js.map +1 -0
- package/dist/fetchers/registry.d.ts +1 -1
- package/dist/fetchers/registry.js +4 -4
- package/dist/fetchers/types.d.ts +1 -1
- package/dist/hooks/useCanvasOverlays.d.ts +8 -5
- package/dist/hooks/useCanvasOverlays.js +66 -17
- package/dist/hooks/useCanvasOverlays.js.map +1 -1
- package/dist/hooks/useHostPatches.d.ts +2 -2
- package/dist/hooks/useHostPatches.js +8 -8
- package/dist/hooks/useHostPatches.js.map +1 -1
- package/dist/hooks/useShadowCanvasConfig.d.ts +5 -9
- package/dist/hooks/useShadowCanvasConfig.js +7 -5
- package/dist/hooks/useShadowCanvasConfig.js.map +1 -1
- package/dist/hostPatcher/core/patcher.d.ts +1 -1
- package/dist/hostPatcher/core/patcher.js +18 -9
- package/dist/hostPatcher/core/patcher.js.map +1 -1
- package/dist/hostPatcher/core/sanitizer.js +24 -3
- package/dist/hostPatcher/core/sanitizer.js.map +1 -1
- package/dist/hostPatcher/policy/defaultPolicy.js +15 -5
- package/dist/hostPatcher/policy/defaultPolicy.js.map +1 -1
- package/dist/hostPatcher/utils/anchors.js +4 -6
- package/dist/hostPatcher/utils/anchors.js.map +1 -1
- package/dist/index.d.ts +34 -27
- package/dist/index.js +51 -24
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +29 -0
- package/dist/logger.js +81 -0
- package/dist/logger.js.map +1 -0
- package/dist/metrics/index.d.ts +1 -1
- package/dist/metrics/index.js +1 -1
- package/dist/metrics/sessionMetrics.d.ts +1 -1
- package/dist/metrics/sessionMetrics.js +6 -6
- package/dist/overlays/fetcher.d.ts +2 -2
- package/dist/overlays/fetcher.js +13 -15
- package/dist/overlays/fetcher.js.map +1 -1
- package/dist/overlays/recipeRegistry.js +2 -2
- package/dist/overlays/recipeRegistry.js.map +1 -1
- package/dist/overlays/runtime/anchor/resolve.js +1 -1
- package/dist/overlays/runtime/anchor/resolve.js.map +1 -1
- package/dist/overlays/runtime/index.d.ts +7 -7
- package/dist/overlays/runtime/index.js +7 -7
- package/dist/overlays/runtime/overlay/highlight.js +39 -39
- package/dist/overlays/runtime/overlay/highlight.js.map +1 -1
- package/dist/overlays/runtime/overlay/modal.js +5 -5
- package/dist/overlays/runtime/overlay/modal.js.map +1 -1
- package/dist/overlays/runtime/overlay/root.js +1 -1
- package/dist/overlays/runtime/overlay/runner.js +88 -28
- package/dist/overlays/runtime/overlay/runner.js.map +1 -1
- package/dist/overlays/runtime/overlay/tooltip.d.ts +1 -1
- package/dist/overlays/runtime/overlay/tooltip.js +13 -15
- package/dist/overlays/runtime/overlay/tooltip.js.map +1 -1
- package/dist/overlays/runtime/utils/dom.js +4 -1
- package/dist/overlays/runtime/utils/dom.js.map +1 -1
- package/dist/overlays/schema.d.ts +146 -146
- package/dist/overlays/schema.js +12 -8
- package/dist/overlays/schema.js.map +1 -1
- package/dist/react.d.ts +7 -7
- package/dist/react.js +4 -4
- package/dist/react.js.map +1 -1
- package/dist/render/RenderContext.d.ts +2 -2
- package/dist/render/RenderContext.js +5 -5
- package/dist/render/RenderContext.js.map +1 -1
- package/dist/render/index.d.ts +3 -3
- package/dist/render/index.js +1 -1
- package/dist/render/types.d.ts +4 -4
- package/dist/runtime.d.ts +32 -8
- package/dist/runtime.js +109 -13
- package/dist/runtime.js.map +1 -1
- package/dist/smart-canvas.esm.js +144 -55
- package/dist/smart-canvas.esm.js.map +4 -4
- package/dist/smart-canvas.js +14688 -11455
- package/dist/smart-canvas.js.map +4 -4
- package/dist/smart-canvas.min.js +145 -55
- package/dist/smart-canvas.min.js.map +4 -4
- package/dist/state/StateStore.d.ts +1 -7
- package/dist/state/StateStore.js +15 -9
- package/dist/state/StateStore.js.map +1 -1
- package/dist/state/helpers/cooldowns.d.ts +1 -1
- package/dist/state/helpers/cooldowns.js +1 -1
- package/dist/state/helpers/dismissals.d.ts +1 -1
- package/dist/state/helpers/dismissals.js +1 -1
- package/dist/state/helpers/frequency.d.ts +1 -1
- package/dist/state/helpers/frequency.js +1 -1
- package/dist/state/index.d.ts +4 -4
- package/dist/state/index.js +3 -3
- package/dist/state/schema.d.ts +1 -1
- package/dist/state/schema.js +1 -1
- package/dist/store/example.d.ts +1 -0
- package/dist/store/example.js +43 -0
- package/dist/store/example.js.map +1 -0
- package/dist/store/mini-effector.d.ts +46 -0
- package/dist/store/mini-effector.js +88 -0
- package/dist/store/mini-effector.js.map +1 -0
- package/dist/surfaces/Surfaces.d.ts +11 -0
- package/dist/surfaces/Surfaces.js +361 -0
- package/dist/surfaces/Surfaces.js.map +1 -0
- package/dist/surfaces/index.d.ts +9 -0
- package/dist/surfaces/index.js +12 -0
- package/dist/surfaces/index.js.map +1 -0
- package/dist/surfaces/positioning.d.ts +50 -0
- package/dist/surfaces/positioning.js +228 -0
- package/dist/surfaces/positioning.js.map +1 -0
- package/dist/surfaces/types.d.ts +167 -0
- package/dist/surfaces/types.js +23 -0
- package/dist/surfaces/types.js.map +1 -0
- package/dist/telemetry/adapters/noop.d.ts +12 -0
- package/dist/telemetry/adapters/noop.js +42 -0
- package/dist/telemetry/adapters/noop.js.map +1 -0
- package/dist/telemetry/adapters/posthog.d.ts +8 -2
- package/dist/telemetry/adapters/posthog.js +36 -14
- package/dist/telemetry/adapters/posthog.js.map +1 -1
- package/dist/telemetry/index.d.ts +4 -3
- package/dist/telemetry/index.js +3 -2
- package/dist/telemetry/index.js.map +1 -1
- package/dist/telemetry/registry.d.ts +2 -9
- package/dist/telemetry/registry.js +4 -2
- package/dist/telemetry/registry.js.map +1 -1
- package/dist/telemetry/types.d.ts +1 -1
- package/dist/theme/ThemeProvider.d.ts +2 -2
- package/dist/theme/ThemeProvider.js +21 -21
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/theme/defaultTheme.d.ts +4 -5
- package/dist/theme/defaultTheme.js +127 -118
- package/dist/theme/defaultTheme.js.map +1 -1
- package/dist/theme/extractHostTheme.d.ts +1 -1
- package/dist/theme/extractHostTheme.js +43 -45
- package/dist/theme/extractHostTheme.js.map +1 -1
- package/dist/theme/index.d.ts +5 -5
- package/dist/theme/index.js +3 -3
- package/dist/theme/index.js.map +1 -1
- package/dist/theme/types.d.ts +2 -2
- package/dist/token.d.ts +2 -0
- package/dist/token.js +3 -6
- package/dist/token.js.map +1 -1
- package/dist/types-only.d.ts +32 -0
- package/dist/types-only.js +11 -0
- package/dist/types-only.js.map +1 -0
- package/dist/types.d.ts +89 -56
- package/dist/types.js +14 -2
- package/dist/types.js.map +1 -1
- package/dist/version.d.ts +13 -0
- package/dist/version.js +14 -0
- package/dist/version.js.map +1 -0
- package/dist/widgets/WidgetRegistry.d.ts +145 -0
- package/dist/widgets/WidgetRegistry.js +191 -0
- package/dist/widgets/WidgetRegistry.js.map +1 -0
- package/dist/widgets/index.d.ts +7 -0
- package/dist/widgets/index.js +7 -0
- package/dist/widgets/index.js.map +1 -0
- package/package.json +35 -15
- package/schema/canvas-config.schema.json +488 -254
- package/schema/runtime-context.schema.json +1 -5
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surfaces
|
|
3
|
+
*
|
|
4
|
+
* Managed surface system for rendering UI into named slots.
|
|
5
|
+
* Handles layout, stacking, animations, and priority-based arbitration.
|
|
6
|
+
*/
|
|
7
|
+
import { sanitizeWithFallback } from '../hostPatcher/core/sanitizer';
|
|
8
|
+
import { applyStaticSlotStyles, setupAdjacentPositioning, setupInlinePositioning, playEnterAnimation, playExitAnimation, createSurfaceContainer, getSlotZIndex, } from './positioning';
|
|
9
|
+
import { getSlotType, getSlotAnchorId } from './types';
|
|
10
|
+
/** Counter for generating unique mount IDs */
|
|
11
|
+
let mountIdCounter = 0;
|
|
12
|
+
/**
|
|
13
|
+
* Create a Surfaces instance.
|
|
14
|
+
*/
|
|
15
|
+
export function createSurfaces(options) {
|
|
16
|
+
const { overlayRoot, eventBus, anchorResolver, defaultAnimation = 'fade', widgetRegistry, } = options;
|
|
17
|
+
/** Map of current mounts by slot */
|
|
18
|
+
const mounts = new Map();
|
|
19
|
+
/** Map of mount counts by slot (for stats) */
|
|
20
|
+
const mountCounts = new Map();
|
|
21
|
+
/** Map of state change callbacks by slot */
|
|
22
|
+
const stateCallbacks = new Map();
|
|
23
|
+
/**
|
|
24
|
+
* Generate a unique mount ID.
|
|
25
|
+
*/
|
|
26
|
+
function generateMountId() {
|
|
27
|
+
return `mount-${++mountIdCounter}`;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Publish an event to the EventBus if available.
|
|
31
|
+
*/
|
|
32
|
+
function publishEvent(name, props) {
|
|
33
|
+
if (eventBus) {
|
|
34
|
+
eventBus.publish(name, props);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Notify state change callbacks for a slot.
|
|
39
|
+
*/
|
|
40
|
+
function notifyStateChange(slot) {
|
|
41
|
+
const callbacks = stateCallbacks.get(slot);
|
|
42
|
+
if (callbacks) {
|
|
43
|
+
const state = getState(slot);
|
|
44
|
+
for (const callback of callbacks) {
|
|
45
|
+
try {
|
|
46
|
+
callback(state);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error('[Surfaces] State callback error:', error);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** Track mounted widget handles for cleanup */
|
|
55
|
+
const widgetHandles = new Map();
|
|
56
|
+
/**
|
|
57
|
+
* Render content into a container.
|
|
58
|
+
*/
|
|
59
|
+
function renderContent(container, content, mountId) {
|
|
60
|
+
switch (content.type) {
|
|
61
|
+
case 'html':
|
|
62
|
+
container.innerHTML = sanitizeWithFallback(content.content);
|
|
63
|
+
return undefined;
|
|
64
|
+
case 'widget': {
|
|
65
|
+
// Use widget registry if available
|
|
66
|
+
if (widgetRegistry && widgetRegistry.has(content.widgetId)) {
|
|
67
|
+
const handle = widgetRegistry.mount(content.widgetId, container, content.config);
|
|
68
|
+
if (mountId) {
|
|
69
|
+
widgetHandles.set(mountId, handle);
|
|
70
|
+
}
|
|
71
|
+
return () => {
|
|
72
|
+
handle.unmount();
|
|
73
|
+
if (mountId) {
|
|
74
|
+
widgetHandles.delete(mountId);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
// Fallback: create a placeholder if widget not found
|
|
79
|
+
console.warn(`[Surfaces] Widget not found: ${content.widgetId}`);
|
|
80
|
+
container.innerHTML = `<div data-widget-id="${content.widgetId}" data-widget-missing="true">Widget: ${content.widgetId}</div>`;
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
case 'custom':
|
|
84
|
+
return content.mount(container);
|
|
85
|
+
case 'react':
|
|
86
|
+
// React rendering would require ReactDOM
|
|
87
|
+
// For now, create a placeholder
|
|
88
|
+
container.innerHTML = `<div data-react-component>React Component</div>`;
|
|
89
|
+
return undefined;
|
|
90
|
+
default:
|
|
91
|
+
console.warn('[Surfaces] Unknown content type');
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Mount content to a surface slot.
|
|
97
|
+
*/
|
|
98
|
+
function mount(slot, content, opts) {
|
|
99
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
100
|
+
const id = generateMountId();
|
|
101
|
+
const slotType = getSlotType(slot);
|
|
102
|
+
const priority = (_a = opts === null || opts === void 0 ? void 0 : opts.priority) !== null && _a !== void 0 ? _a : 0;
|
|
103
|
+
const animation = (_b = opts === null || opts === void 0 ? void 0 : opts.animation) !== null && _b !== void 0 ? _b : defaultAnimation;
|
|
104
|
+
const exclusive = (_c = opts === null || opts === void 0 ? void 0 : opts.exclusive) !== null && _c !== void 0 ? _c : true;
|
|
105
|
+
// Check for existing mount
|
|
106
|
+
const existingMount = mounts.get(slot);
|
|
107
|
+
if (existingMount) {
|
|
108
|
+
if (exclusive) {
|
|
109
|
+
// Priority-based arbitration
|
|
110
|
+
if (existingMount.options.priority > priority) {
|
|
111
|
+
throw new Error(`Slot ${slot} is occupied by higher priority content (${existingMount.options.priority} > ${priority})`);
|
|
112
|
+
}
|
|
113
|
+
// Unmount existing content
|
|
114
|
+
unmountEntry(existingMount);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Create container
|
|
118
|
+
const container = createSurfaceContainer(slot, id);
|
|
119
|
+
container.style.zIndex = String(getSlotZIndex(slot));
|
|
120
|
+
// Set up positioning based on slot type
|
|
121
|
+
let positionCleanup;
|
|
122
|
+
if (slotType === 'static') {
|
|
123
|
+
applyStaticSlotStyles(container, slot, opts === null || opts === void 0 ? void 0 : opts.constraints);
|
|
124
|
+
overlayRoot.appendChild(container);
|
|
125
|
+
}
|
|
126
|
+
else if (slotType === 'inline') {
|
|
127
|
+
const anchorId = getSlotAnchorId(slot);
|
|
128
|
+
if (!anchorId) {
|
|
129
|
+
throw new Error(`Invalid inline slot: ${slot}`);
|
|
130
|
+
}
|
|
131
|
+
if (!anchorResolver) {
|
|
132
|
+
throw new Error('Anchor resolver required for inline slots');
|
|
133
|
+
}
|
|
134
|
+
const anchorEl = anchorResolver(anchorId);
|
|
135
|
+
if (!anchorEl) {
|
|
136
|
+
throw new Error(`Anchor not found for inline slot: ${anchorId}`);
|
|
137
|
+
}
|
|
138
|
+
positionCleanup = setupInlinePositioning(container, anchorEl);
|
|
139
|
+
}
|
|
140
|
+
else if (slotType === 'adjacent') {
|
|
141
|
+
const anchorId = getSlotAnchorId(slot);
|
|
142
|
+
if (!anchorId) {
|
|
143
|
+
throw new Error(`Invalid adjacent slot: ${slot}`);
|
|
144
|
+
}
|
|
145
|
+
if (!anchorResolver) {
|
|
146
|
+
throw new Error('Anchor resolver required for adjacent slots');
|
|
147
|
+
}
|
|
148
|
+
const anchorEl = anchorResolver(anchorId);
|
|
149
|
+
if (!anchorEl) {
|
|
150
|
+
throw new Error(`Anchor not found for adjacent slot: ${anchorId}`);
|
|
151
|
+
}
|
|
152
|
+
overlayRoot.appendChild(container);
|
|
153
|
+
positionCleanup = setupAdjacentPositioning(container, anchorEl, (_d = opts === null || opts === void 0 ? void 0 : opts.position) !== null && _d !== void 0 ? _d : { placement: 'bottom' });
|
|
154
|
+
}
|
|
155
|
+
// Render content
|
|
156
|
+
const contentCleanup = renderContent(container, content, id);
|
|
157
|
+
// Play enter animation
|
|
158
|
+
playEnterAnimation(container, animation);
|
|
159
|
+
// Create internal entry
|
|
160
|
+
const entry = {
|
|
161
|
+
id,
|
|
162
|
+
slot,
|
|
163
|
+
content,
|
|
164
|
+
options: {
|
|
165
|
+
priority,
|
|
166
|
+
exclusive,
|
|
167
|
+
animation,
|
|
168
|
+
position: (_e = opts === null || opts === void 0 ? void 0 : opts.position) !== null && _e !== void 0 ? _e : { placement: 'auto' },
|
|
169
|
+
constraints: (_f = opts === null || opts === void 0 ? void 0 : opts.constraints) !== null && _f !== void 0 ? _f : {},
|
|
170
|
+
adaptiveId: opts === null || opts === void 0 ? void 0 : opts.adaptiveId,
|
|
171
|
+
autoUnmountOnRouteChange: (_g = opts === null || opts === void 0 ? void 0 : opts.autoUnmountOnRouteChange) !== null && _g !== void 0 ? _g : true,
|
|
172
|
+
},
|
|
173
|
+
container,
|
|
174
|
+
cleanup: () => {
|
|
175
|
+
positionCleanup === null || positionCleanup === void 0 ? void 0 : positionCleanup();
|
|
176
|
+
contentCleanup === null || contentCleanup === void 0 ? void 0 : contentCleanup();
|
|
177
|
+
},
|
|
178
|
+
mountedAt: Date.now(),
|
|
179
|
+
};
|
|
180
|
+
// Store mount
|
|
181
|
+
mounts.set(slot, entry);
|
|
182
|
+
// Update mount count
|
|
183
|
+
mountCounts.set(slot, ((_h = mountCounts.get(slot)) !== null && _h !== void 0 ? _h : 0) + 1);
|
|
184
|
+
// Publish event
|
|
185
|
+
publishEvent('surface.mounted', {
|
|
186
|
+
slot,
|
|
187
|
+
id,
|
|
188
|
+
adaptiveId: opts === null || opts === void 0 ? void 0 : opts.adaptiveId,
|
|
189
|
+
});
|
|
190
|
+
// Notify state change
|
|
191
|
+
notifyStateChange(slot);
|
|
192
|
+
// Create and return handle
|
|
193
|
+
const handle = {
|
|
194
|
+
id,
|
|
195
|
+
update(newContent) {
|
|
196
|
+
const entry = mounts.get(slot);
|
|
197
|
+
if (!entry || entry.id !== id) {
|
|
198
|
+
throw new Error('Mount no longer active');
|
|
199
|
+
}
|
|
200
|
+
// Clean up existing widget handle if present
|
|
201
|
+
const existingWidgetHandle = widgetHandles.get(id);
|
|
202
|
+
if (existingWidgetHandle) {
|
|
203
|
+
// If content is a widget and we have an update method, use it
|
|
204
|
+
if (newContent.type === 'widget') {
|
|
205
|
+
existingWidgetHandle.update(newContent.config);
|
|
206
|
+
entry.content = newContent;
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
// Otherwise, unmount the old widget
|
|
210
|
+
existingWidgetHandle.unmount();
|
|
211
|
+
widgetHandles.delete(id);
|
|
212
|
+
}
|
|
213
|
+
// Clear existing content
|
|
214
|
+
entry.container.innerHTML = '';
|
|
215
|
+
// Render new content
|
|
216
|
+
const newCleanup = renderContent(entry.container, newContent, id);
|
|
217
|
+
entry.content = newContent;
|
|
218
|
+
// Update cleanup if needed
|
|
219
|
+
if (newCleanup) {
|
|
220
|
+
const oldCleanup = entry.cleanup;
|
|
221
|
+
entry.cleanup = () => {
|
|
222
|
+
oldCleanup === null || oldCleanup === void 0 ? void 0 : oldCleanup();
|
|
223
|
+
newCleanup();
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
setOptions(newOpts) {
|
|
228
|
+
const entry = mounts.get(slot);
|
|
229
|
+
if (!entry || entry.id !== id) {
|
|
230
|
+
throw new Error('Mount no longer active');
|
|
231
|
+
}
|
|
232
|
+
// Update options
|
|
233
|
+
if (newOpts.priority !== undefined) {
|
|
234
|
+
entry.options.priority = newOpts.priority;
|
|
235
|
+
}
|
|
236
|
+
if (newOpts.animation !== undefined) {
|
|
237
|
+
entry.options.animation = newOpts.animation;
|
|
238
|
+
}
|
|
239
|
+
// Re-apply constraints if changed
|
|
240
|
+
if (newOpts.constraints && slotType === 'static') {
|
|
241
|
+
if (newOpts.constraints.maxWidth)
|
|
242
|
+
entry.container.style.maxWidth = newOpts.constraints.maxWidth;
|
|
243
|
+
if (newOpts.constraints.maxHeight)
|
|
244
|
+
entry.container.style.maxHeight = newOpts.constraints.maxHeight;
|
|
245
|
+
if (newOpts.constraints.minWidth)
|
|
246
|
+
entry.container.style.minWidth = newOpts.constraints.minWidth;
|
|
247
|
+
if (newOpts.constraints.minHeight)
|
|
248
|
+
entry.container.style.minHeight = newOpts.constraints.minHeight;
|
|
249
|
+
}
|
|
250
|
+
notifyStateChange(slot);
|
|
251
|
+
},
|
|
252
|
+
async unmount() {
|
|
253
|
+
const entry = mounts.get(slot);
|
|
254
|
+
if (!entry || entry.id !== id)
|
|
255
|
+
return;
|
|
256
|
+
await unmountEntry(entry);
|
|
257
|
+
},
|
|
258
|
+
isMounted() {
|
|
259
|
+
const entry = mounts.get(slot);
|
|
260
|
+
return (entry === null || entry === void 0 ? void 0 : entry.id) === id;
|
|
261
|
+
},
|
|
262
|
+
getContainer() {
|
|
263
|
+
const entry = mounts.get(slot);
|
|
264
|
+
return (entry === null || entry === void 0 ? void 0 : entry.id) === id ? entry.container : null;
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
return handle;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Unmount an entry with animation.
|
|
271
|
+
*/
|
|
272
|
+
async function unmountEntry(entry) {
|
|
273
|
+
var _a;
|
|
274
|
+
// Play exit animation
|
|
275
|
+
await playExitAnimation(entry.container, entry.options.animation);
|
|
276
|
+
// Run cleanup
|
|
277
|
+
(_a = entry.cleanup) === null || _a === void 0 ? void 0 : _a.call(entry);
|
|
278
|
+
// Remove container
|
|
279
|
+
entry.container.remove();
|
|
280
|
+
// Remove from mounts
|
|
281
|
+
mounts.delete(entry.slot);
|
|
282
|
+
// Publish event
|
|
283
|
+
publishEvent('surface.unmounted', {
|
|
284
|
+
slot: entry.slot,
|
|
285
|
+
id: entry.id,
|
|
286
|
+
});
|
|
287
|
+
// Notify state change
|
|
288
|
+
notifyStateChange(entry.slot);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Get the current state of a slot.
|
|
292
|
+
*/
|
|
293
|
+
function getState(slot) {
|
|
294
|
+
var _a;
|
|
295
|
+
const entry = mounts.get(slot);
|
|
296
|
+
return {
|
|
297
|
+
slot,
|
|
298
|
+
occupied: !!entry,
|
|
299
|
+
currentPriority: entry === null || entry === void 0 ? void 0 : entry.options.priority,
|
|
300
|
+
currentAdaptiveId: entry === null || entry === void 0 ? void 0 : entry.options.adaptiveId,
|
|
301
|
+
mountCount: (_a = mountCounts.get(slot)) !== null && _a !== void 0 ? _a : 0,
|
|
302
|
+
currentMountId: entry === null || entry === void 0 ? void 0 : entry.id,
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Subscribe to state changes for a slot.
|
|
307
|
+
*/
|
|
308
|
+
function onStateChange(slot, fn) {
|
|
309
|
+
let callbacks = stateCallbacks.get(slot);
|
|
310
|
+
if (!callbacks) {
|
|
311
|
+
callbacks = new Set();
|
|
312
|
+
stateCallbacks.set(slot, callbacks);
|
|
313
|
+
}
|
|
314
|
+
callbacks.add(fn);
|
|
315
|
+
return () => {
|
|
316
|
+
callbacks === null || callbacks === void 0 ? void 0 : callbacks.delete(fn);
|
|
317
|
+
if ((callbacks === null || callbacks === void 0 ? void 0 : callbacks.size) === 0) {
|
|
318
|
+
stateCallbacks.delete(slot);
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
/**
|
|
323
|
+
* Check if content can be mounted to a slot.
|
|
324
|
+
*/
|
|
325
|
+
function canMount(slot, priority) {
|
|
326
|
+
const existingMount = mounts.get(slot);
|
|
327
|
+
if (!existingMount)
|
|
328
|
+
return true;
|
|
329
|
+
// Check priority if provided
|
|
330
|
+
if (priority !== undefined) {
|
|
331
|
+
return priority >= existingMount.options.priority;
|
|
332
|
+
}
|
|
333
|
+
return false;
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Clean up all mounted surfaces.
|
|
337
|
+
*/
|
|
338
|
+
function destroy() {
|
|
339
|
+
var _a;
|
|
340
|
+
// Unmount all surfaces
|
|
341
|
+
for (const entry of mounts.values()) {
|
|
342
|
+
try {
|
|
343
|
+
(_a = entry.cleanup) === null || _a === void 0 ? void 0 : _a.call(entry);
|
|
344
|
+
entry.container.remove();
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
console.error('[Surfaces] Error during cleanup:', error);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
mounts.clear();
|
|
351
|
+
stateCallbacks.clear();
|
|
352
|
+
}
|
|
353
|
+
return {
|
|
354
|
+
mount,
|
|
355
|
+
getState,
|
|
356
|
+
onStateChange,
|
|
357
|
+
canMount,
|
|
358
|
+
destroy,
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
//# sourceMappingURL=Surfaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Surfaces.js","sourceRoot":"","sources":["../../src/surfaces/Surfaces.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,GACd,MAAM,eAAe,CAAC;AAavB,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEvD,8CAA8C;AAC9C,IAAI,cAAc,GAAG,CAAC,CAAC;AAEvB;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,OAAwB;IACrD,MAAM,EACJ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AAC;QACvC,IAAI,CAAC,aAAa;YAAE,OAAO,IAAI,CAAC;QAEhC,6BAA6B;QAC7B,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,OAAO,QAAQ,IAAI,aAAa,CAAC,OAAO,CAAC,QAAQ,CAAC;QACpD,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACH,SAAS,OAAO;;QACd,uBAAuB;QACvB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;YACpC,IAAI,CAAC;gBACH,MAAA,KAAK,CAAC,OAAO,qDAAI,CAAC;gBAClB,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;YAC3B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;QAED,MAAM,CAAC,KAAK,EAAE,CAAC;QACf,cAAc,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,OAAO;QACL,KAAK;QACL,QAAQ;QACR,aAAa;QACb,QAAQ;QACR,OAAO;KACR,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surfaces Module
|
|
3
|
+
*
|
|
4
|
+
* Managed surface system for rendering UI into named slots.
|
|
5
|
+
*/
|
|
6
|
+
export { createSurfaces } from './Surfaces';
|
|
7
|
+
export type { Surfaces, SurfacesOptions, SurfacesWidgetRegistry, MountHandle, SurfaceState, SurfaceChangeCallback, SurfaceSlot, StaticSurfaceSlot, InlineSurfaceSlot, AdjacentSurfaceSlot, RenderableContent, ReactContent, HtmlContent, WidgetContent, CustomContent, MountOptions, PositionConfig, MountConstraints, AnimationType, } from './types';
|
|
8
|
+
export { getSlotType, getSlotAnchorId } from './types';
|
|
9
|
+
export { STATIC_SLOT_STYLES, ANIMATION_KEYFRAMES, applyStaticSlotStyles, setupAdjacentPositioning, setupInlinePositioning, playEnterAnimation, playExitAnimation, createSurfaceContainer, getSlotZIndex, } from './positioning';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surfaces Module
|
|
3
|
+
*
|
|
4
|
+
* Managed surface system for rendering UI into named slots.
|
|
5
|
+
*/
|
|
6
|
+
// Main factory
|
|
7
|
+
export { createSurfaces } from './Surfaces';
|
|
8
|
+
// Utilities
|
|
9
|
+
export { getSlotType, getSlotAnchorId } from './types';
|
|
10
|
+
// Positioning (for advanced usage)
|
|
11
|
+
export { STATIC_SLOT_STYLES, ANIMATION_KEYFRAMES, applyStaticSlotStyles, setupAdjacentPositioning, setupInlinePositioning, playEnterAnimation, playExitAnimation, createSurfaceContainer, getSlotZIndex, } from './positioning';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/surfaces/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAe;AACf,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAgC5C,YAAY;AACZ,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEvD,mCAAmC;AACnC,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,EACxB,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,aAAa,GACd,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surfaces Positioning
|
|
3
|
+
*
|
|
4
|
+
* Handles positioning for different slot types using CSS for static slots
|
|
5
|
+
* and Floating UI for adjacent slots.
|
|
6
|
+
*/
|
|
7
|
+
import type { SurfaceSlot, StaticSurfaceSlot, PositionConfig, MountConstraints, AnimationType } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* CSS styles for static surface slots.
|
|
10
|
+
*/
|
|
11
|
+
export declare const STATIC_SLOT_STYLES: Record<StaticSurfaceSlot, Record<string, string>>;
|
|
12
|
+
/**
|
|
13
|
+
* Animation keyframes for different animation types.
|
|
14
|
+
*/
|
|
15
|
+
export declare const ANIMATION_KEYFRAMES: Record<AnimationType, Keyframe[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Animation options.
|
|
18
|
+
*/
|
|
19
|
+
export declare const ANIMATION_OPTIONS: KeyframeAnimationOptions;
|
|
20
|
+
/**
|
|
21
|
+
* Apply static slot positioning to an element.
|
|
22
|
+
*/
|
|
23
|
+
export declare function applyStaticSlotStyles(element: HTMLElement, slot: StaticSurfaceSlot, constraints?: MountConstraints): void;
|
|
24
|
+
/**
|
|
25
|
+
* Set up adjacent slot positioning using Floating UI.
|
|
26
|
+
* Returns a cleanup function.
|
|
27
|
+
*/
|
|
28
|
+
export declare function setupAdjacentPositioning(container: HTMLElement, anchorEl: HTMLElement, config: PositionConfig): () => void;
|
|
29
|
+
/**
|
|
30
|
+
* Set up inline slot positioning.
|
|
31
|
+
* Inline slots render content inside the anchor element.
|
|
32
|
+
*/
|
|
33
|
+
export declare function setupInlinePositioning(container: HTMLElement, anchorEl: HTMLElement, position?: 'prepend' | 'append'): () => void;
|
|
34
|
+
/**
|
|
35
|
+
* Play enter animation on an element.
|
|
36
|
+
*/
|
|
37
|
+
export declare function playEnterAnimation(element: HTMLElement, animationType: AnimationType): Animation | null;
|
|
38
|
+
/**
|
|
39
|
+
* Play exit animation on an element.
|
|
40
|
+
* Returns a promise that resolves when the animation completes.
|
|
41
|
+
*/
|
|
42
|
+
export declare function playExitAnimation(element: HTMLElement, animationType: AnimationType): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Create and style a surface container element.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createSurfaceContainer(slot: SurfaceSlot, id: string): HTMLElement;
|
|
47
|
+
/**
|
|
48
|
+
* Get the z-index for a slot type.
|
|
49
|
+
*/
|
|
50
|
+
export declare function getSlotZIndex(slot: SurfaceSlot): number;
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Surfaces Positioning
|
|
3
|
+
*
|
|
4
|
+
* Handles positioning for different slot types using CSS for static slots
|
|
5
|
+
* and Floating UI for adjacent slots.
|
|
6
|
+
*/
|
|
7
|
+
import { computePosition, autoUpdate, offset, flip, shift } from '@floating-ui/dom';
|
|
8
|
+
import { getSlotType } from './types';
|
|
9
|
+
/**
|
|
10
|
+
* CSS styles for static surface slots.
|
|
11
|
+
*/
|
|
12
|
+
export const STATIC_SLOT_STYLES = {
|
|
13
|
+
drawer_right: {
|
|
14
|
+
position: 'fixed',
|
|
15
|
+
top: '0',
|
|
16
|
+
right: '0',
|
|
17
|
+
bottom: '0',
|
|
18
|
+
width: '360px',
|
|
19
|
+
maxWidth: '90vw',
|
|
20
|
+
},
|
|
21
|
+
drawer_left: {
|
|
22
|
+
position: 'fixed',
|
|
23
|
+
top: '0',
|
|
24
|
+
left: '0',
|
|
25
|
+
bottom: '0',
|
|
26
|
+
width: '360px',
|
|
27
|
+
maxWidth: '90vw',
|
|
28
|
+
},
|
|
29
|
+
drawer_bottom: {
|
|
30
|
+
position: 'fixed',
|
|
31
|
+
left: '0',
|
|
32
|
+
right: '0',
|
|
33
|
+
bottom: '0',
|
|
34
|
+
maxHeight: '50vh',
|
|
35
|
+
},
|
|
36
|
+
overlay_center: {
|
|
37
|
+
position: 'fixed',
|
|
38
|
+
top: '50%',
|
|
39
|
+
left: '50%',
|
|
40
|
+
transform: 'translate(-50%, -50%)',
|
|
41
|
+
maxWidth: '90vw',
|
|
42
|
+
maxHeight: '90vh',
|
|
43
|
+
},
|
|
44
|
+
overlay_corner_br: {
|
|
45
|
+
position: 'fixed',
|
|
46
|
+
bottom: '16px',
|
|
47
|
+
right: '16px',
|
|
48
|
+
maxWidth: '400px',
|
|
49
|
+
maxHeight: '80vh',
|
|
50
|
+
},
|
|
51
|
+
overlay_corner_bl: {
|
|
52
|
+
position: 'fixed',
|
|
53
|
+
bottom: '16px',
|
|
54
|
+
left: '16px',
|
|
55
|
+
maxWidth: '400px',
|
|
56
|
+
maxHeight: '80vh',
|
|
57
|
+
},
|
|
58
|
+
toast_top: {
|
|
59
|
+
position: 'fixed',
|
|
60
|
+
top: '16px',
|
|
61
|
+
left: '50%',
|
|
62
|
+
transform: 'translateX(-50%)',
|
|
63
|
+
maxWidth: '90vw',
|
|
64
|
+
},
|
|
65
|
+
toast_bottom: {
|
|
66
|
+
position: 'fixed',
|
|
67
|
+
bottom: '16px',
|
|
68
|
+
left: '50%',
|
|
69
|
+
transform: 'translateX(-50%)',
|
|
70
|
+
maxWidth: '90vw',
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Animation keyframes for different animation types.
|
|
75
|
+
*/
|
|
76
|
+
export const ANIMATION_KEYFRAMES = {
|
|
77
|
+
fade: [{ opacity: 0 }, { opacity: 1 }],
|
|
78
|
+
slide: [
|
|
79
|
+
{ opacity: 0, transform: 'translateY(10px)' },
|
|
80
|
+
{ opacity: 1, transform: 'translateY(0)' },
|
|
81
|
+
],
|
|
82
|
+
scale: [
|
|
83
|
+
{ opacity: 0, transform: 'scale(0.95)' },
|
|
84
|
+
{ opacity: 1, transform: 'scale(1)' },
|
|
85
|
+
],
|
|
86
|
+
none: [],
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Animation options.
|
|
90
|
+
*/
|
|
91
|
+
export const ANIMATION_OPTIONS = {
|
|
92
|
+
duration: 200,
|
|
93
|
+
easing: 'cubic-bezier(0.16, 1, 0.3, 1)',
|
|
94
|
+
fill: 'forwards',
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Apply static slot positioning to an element.
|
|
98
|
+
*/
|
|
99
|
+
export function applyStaticSlotStyles(element, slot, constraints) {
|
|
100
|
+
const styles = STATIC_SLOT_STYLES[slot];
|
|
101
|
+
Object.assign(element.style, styles);
|
|
102
|
+
// Apply constraints
|
|
103
|
+
if (constraints) {
|
|
104
|
+
if (constraints.maxWidth)
|
|
105
|
+
element.style.maxWidth = constraints.maxWidth;
|
|
106
|
+
if (constraints.maxHeight)
|
|
107
|
+
element.style.maxHeight = constraints.maxHeight;
|
|
108
|
+
if (constraints.minWidth)
|
|
109
|
+
element.style.minWidth = constraints.minWidth;
|
|
110
|
+
if (constraints.minHeight)
|
|
111
|
+
element.style.minHeight = constraints.minHeight;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Set up adjacent slot positioning using Floating UI.
|
|
116
|
+
* Returns a cleanup function.
|
|
117
|
+
*/
|
|
118
|
+
export function setupAdjacentPositioning(container, anchorEl, config) {
|
|
119
|
+
const placement = config.placement === 'auto' ? 'bottom' : config.placement;
|
|
120
|
+
const middleware = [
|
|
121
|
+
offset(config.offset ? { mainAxis: config.offset.y, crossAxis: config.offset.x } : 8),
|
|
122
|
+
];
|
|
123
|
+
if (config.flip !== false) {
|
|
124
|
+
middleware.push(flip());
|
|
125
|
+
}
|
|
126
|
+
if (config.shift !== false) {
|
|
127
|
+
middleware.push(shift({ padding: 8 }));
|
|
128
|
+
}
|
|
129
|
+
// Set initial position style
|
|
130
|
+
container.style.position = 'absolute';
|
|
131
|
+
container.style.zIndex = '2147483646';
|
|
132
|
+
const cleanup = autoUpdate(anchorEl, container, async () => {
|
|
133
|
+
const { x, y, strategy } = await computePosition(anchorEl, container, {
|
|
134
|
+
placement,
|
|
135
|
+
middleware,
|
|
136
|
+
});
|
|
137
|
+
Object.assign(container.style, {
|
|
138
|
+
position: strategy,
|
|
139
|
+
left: `${x}px`,
|
|
140
|
+
top: `${y}px`,
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
return cleanup;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Set up inline slot positioning.
|
|
147
|
+
* Inline slots render content inside the anchor element.
|
|
148
|
+
*/
|
|
149
|
+
export function setupInlinePositioning(container, anchorEl, position = 'append') {
|
|
150
|
+
// Reset container positioning (inline is flow-based)
|
|
151
|
+
container.style.position = 'relative';
|
|
152
|
+
container.style.display = 'inline-block';
|
|
153
|
+
if (position === 'prepend') {
|
|
154
|
+
anchorEl.insertBefore(container, anchorEl.firstChild);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
anchorEl.appendChild(container);
|
|
158
|
+
}
|
|
159
|
+
return () => {
|
|
160
|
+
container.remove();
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Play enter animation on an element.
|
|
165
|
+
*/
|
|
166
|
+
export function playEnterAnimation(element, animationType) {
|
|
167
|
+
if (animationType === 'none' || ANIMATION_KEYFRAMES[animationType].length === 0) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
return element.animate(ANIMATION_KEYFRAMES[animationType], ANIMATION_OPTIONS);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Play exit animation on an element.
|
|
174
|
+
* Returns a promise that resolves when the animation completes.
|
|
175
|
+
*/
|
|
176
|
+
export function playExitAnimation(element, animationType) {
|
|
177
|
+
if (animationType === 'none' || ANIMATION_KEYFRAMES[animationType].length === 0) {
|
|
178
|
+
return Promise.resolve();
|
|
179
|
+
}
|
|
180
|
+
const keyframes = [...ANIMATION_KEYFRAMES[animationType]].reverse();
|
|
181
|
+
const animation = element.animate(keyframes, ANIMATION_OPTIONS);
|
|
182
|
+
return new Promise((resolve) => {
|
|
183
|
+
animation.onfinish = () => resolve();
|
|
184
|
+
animation.oncancel = () => resolve();
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Create and style a surface container element.
|
|
189
|
+
*/
|
|
190
|
+
export function createSurfaceContainer(slot, id) {
|
|
191
|
+
const container = document.createElement('div');
|
|
192
|
+
container.setAttribute('data-syntro-surface', slot);
|
|
193
|
+
container.setAttribute('data-syntro-mount-id', id);
|
|
194
|
+
container.className = 'syntro-surface';
|
|
195
|
+
// Base styles for all surfaces
|
|
196
|
+
Object.assign(container.style, {
|
|
197
|
+
pointerEvents: 'auto',
|
|
198
|
+
boxSizing: 'border-box',
|
|
199
|
+
overflow: 'auto',
|
|
200
|
+
});
|
|
201
|
+
return container;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Get the z-index for a slot type.
|
|
205
|
+
*/
|
|
206
|
+
export function getSlotZIndex(slot) {
|
|
207
|
+
const type = getSlotType(slot);
|
|
208
|
+
switch (type) {
|
|
209
|
+
case 'static':
|
|
210
|
+
// Drawers and overlays
|
|
211
|
+
if (slot.startsWith('drawer'))
|
|
212
|
+
return 2147483640;
|
|
213
|
+
if (slot.startsWith('overlay'))
|
|
214
|
+
return 2147483642;
|
|
215
|
+
if (slot.startsWith('toast'))
|
|
216
|
+
return 2147483644;
|
|
217
|
+
return 2147483640;
|
|
218
|
+
case 'inline':
|
|
219
|
+
// Inline content doesn't need high z-index
|
|
220
|
+
return 1;
|
|
221
|
+
case 'adjacent':
|
|
222
|
+
// Adjacent content needs to be above page content
|
|
223
|
+
return 2147483638;
|
|
224
|
+
default:
|
|
225
|
+
return 2147483640;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
//# sourceMappingURL=positioning.js.map
|