@syntrologie/adapt-overlays 2.13.0 → 2.15.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/dist/WorkflowWidgetLit.d.ts +123 -0
- package/dist/WorkflowWidgetLit.d.ts.map +1 -0
- package/dist/WorkflowWidgetLit.js +617 -0
- package/dist/overlay-editor-ui.d.ts.map +1 -1
- package/dist/overlay-editor-ui.js +3 -3
- package/dist/runtime-lit.d.ts +94 -0
- package/dist/runtime-lit.d.ts.map +1 -0
- package/dist/runtime-lit.js +402 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +10 -0
- package/dist/schema.d.ts +24 -24
- package/dist/schema.d.ts.map +1 -1
- package/node_modules/@syntro/design-system/dist/tokens/index.d.ts +2 -0
- package/node_modules/@syntro/design-system/dist/tokens/index.d.ts.map +1 -1
- package/node_modules/@syntro/design-system/dist/tokens/index.js +2 -0
- package/node_modules/@syntro/design-system/dist/tokens/panel-shell.d.ts +93 -0
- package/node_modules/@syntro/design-system/dist/tokens/panel-shell.d.ts.map +1 -0
- package/node_modules/@syntro/design-system/dist/tokens/panel-shell.js +72 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPicker.d.ts.map +1 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPicker.js +6 -3
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPickerLit.d.ts +84 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPickerLit.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPickerLit.js +323 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggleLit.d.ts +25 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggleLit.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggleLit.js +55 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLineLit.d.ts +33 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLineLit.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLineLit.js +118 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadgeLit.d.ts +32 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadgeLit.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadgeLit.js +68 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSectionLit.d.ts +34 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSectionLit.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSectionLit.js +57 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButtonLit.d.ts +13 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButtonLit.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButtonLit.js +31 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBodyLit.d.ts +7 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBodyLit.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBodyLit.js +15 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCardLit.d.ts +36 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCardLit.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCardLit.js +102 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooterLit.d.ts +20 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooterLit.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooterLit.js +48 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeaderLit.d.ts +16 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeaderLit.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeaderLit.js +25 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInputLit.d.ts +66 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInputLit.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInputLit.js +87 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayoutLit.d.ts +7 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayoutLit.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayoutLit.js +15 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShell.d.ts.map +1 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShell.js +28 -17
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShellLit.d.ts +66 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShellLit.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShellLit.js +528 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelectLit.d.ts +41 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelectLit.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelectLit.js +63 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextareaLit.d.ts +55 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextareaLit.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextareaLit.js +92 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlightLit.d.ts +90 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlightLit.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlightLit.js +242 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyStateLit.d.ts +12 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyStateLit.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyStateLit.js +21 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeaderLit.d.ts +21 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeaderLit.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeaderLit.js +33 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourneyLit.d.ts +28 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourneyLit.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourneyLit.js +121 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/controllers/PanelShellController.d.ts +110 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/controllers/PanelShellController.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/controllers/PanelShellController.js +476 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/index.d.ts +2 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/index.d.ts.map +1 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/index.js +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/lit-elements.d.ts +15 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/lit-elements.d.ts.map +1 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/lit-elements.js +14 -0
- package/node_modules/@syntrologie/shared-editor-ui/dist/utils/elementChainRecommender.d.ts +0 -4
- package/node_modules/@syntrologie/shared-editor-ui/dist/utils/elementChainRecommender.d.ts.map +1 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/utils/elementChainRecommender.js +17 -1
- package/node_modules/@syntrologie/shared-editor-ui/package.json +9 -1
- package/package.json +9 -2
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adaptive Overlays - Runtime Module (Lit)
|
|
3
|
+
*
|
|
4
|
+
* Visual overlay actions: highlight, pulse, badge, tooltip, celebrations.
|
|
5
|
+
* Uses the Lit web component mountable instead of the React one.
|
|
6
|
+
*/
|
|
7
|
+
import { executeTour } from './executors/tour';
|
|
8
|
+
import { executeModal } from './modal';
|
|
9
|
+
import type { ActionExecutor, BadgeAction, HighlightAction, PulseAction, TooltipAction } from './types';
|
|
10
|
+
export { executeModal, executeTour };
|
|
11
|
+
export type { TourAction, TourStep, WorkflowMeta } from './tour-types';
|
|
12
|
+
/**
|
|
13
|
+
* Execute a highlight action
|
|
14
|
+
*/
|
|
15
|
+
export declare const executeHighlight: ActionExecutor<HighlightAction>;
|
|
16
|
+
/**
|
|
17
|
+
* Execute a pulse action
|
|
18
|
+
*/
|
|
19
|
+
export declare const executePulse: ActionExecutor<PulseAction>;
|
|
20
|
+
/**
|
|
21
|
+
* Execute a badge action
|
|
22
|
+
*/
|
|
23
|
+
export declare const executeBadge: ActionExecutor<BadgeAction>;
|
|
24
|
+
/**
|
|
25
|
+
* Execute a tooltip action
|
|
26
|
+
*/
|
|
27
|
+
export declare const executeTooltip: ActionExecutor<TooltipAction>;
|
|
28
|
+
/**
|
|
29
|
+
* All executors provided by this app.
|
|
30
|
+
* These are registered with the runtime's ExecutorRegistry.
|
|
31
|
+
*/
|
|
32
|
+
export declare const executors: readonly [{
|
|
33
|
+
readonly kind: "overlays:highlight";
|
|
34
|
+
readonly executor: ActionExecutor<HighlightAction>;
|
|
35
|
+
}, {
|
|
36
|
+
readonly kind: "overlays:pulse";
|
|
37
|
+
readonly executor: ActionExecutor<PulseAction>;
|
|
38
|
+
}, {
|
|
39
|
+
readonly kind: "overlays:badge";
|
|
40
|
+
readonly executor: ActionExecutor<BadgeAction>;
|
|
41
|
+
}, {
|
|
42
|
+
readonly kind: "overlays:tooltip";
|
|
43
|
+
readonly executor: ActionExecutor<TooltipAction>;
|
|
44
|
+
}, {
|
|
45
|
+
readonly kind: "overlays:modal";
|
|
46
|
+
readonly executor: ActionExecutor<import("./types").ModalAction>;
|
|
47
|
+
}, {
|
|
48
|
+
readonly kind: "overlays:tour";
|
|
49
|
+
readonly executor: ActionExecutor<import("./tour-types").TourAction>;
|
|
50
|
+
}, {
|
|
51
|
+
readonly kind: "overlays:celebrate";
|
|
52
|
+
readonly executor: ActionExecutor<import("./types").CelebrateAction>;
|
|
53
|
+
}];
|
|
54
|
+
/**
|
|
55
|
+
* App runtime manifest (Lit variant).
|
|
56
|
+
*/
|
|
57
|
+
export declare const runtime: {
|
|
58
|
+
id: string;
|
|
59
|
+
version: string;
|
|
60
|
+
name: string;
|
|
61
|
+
description: string;
|
|
62
|
+
executors: readonly [{
|
|
63
|
+
readonly kind: "overlays:highlight";
|
|
64
|
+
readonly executor: ActionExecutor<HighlightAction>;
|
|
65
|
+
}, {
|
|
66
|
+
readonly kind: "overlays:pulse";
|
|
67
|
+
readonly executor: ActionExecutor<PulseAction>;
|
|
68
|
+
}, {
|
|
69
|
+
readonly kind: "overlays:badge";
|
|
70
|
+
readonly executor: ActionExecutor<BadgeAction>;
|
|
71
|
+
}, {
|
|
72
|
+
readonly kind: "overlays:tooltip";
|
|
73
|
+
readonly executor: ActionExecutor<TooltipAction>;
|
|
74
|
+
}, {
|
|
75
|
+
readonly kind: "overlays:modal";
|
|
76
|
+
readonly executor: ActionExecutor<import("./types").ModalAction>;
|
|
77
|
+
}, {
|
|
78
|
+
readonly kind: "overlays:tour";
|
|
79
|
+
readonly executor: ActionExecutor<import("./tour-types").TourAction>;
|
|
80
|
+
}, {
|
|
81
|
+
readonly kind: "overlays:celebrate";
|
|
82
|
+
readonly executor: ActionExecutor<import("./types").CelebrateAction>;
|
|
83
|
+
}];
|
|
84
|
+
widgets: {
|
|
85
|
+
id: string;
|
|
86
|
+
component: import("./WorkflowWidgetLit").MountableWidget;
|
|
87
|
+
metadata: {
|
|
88
|
+
name: string;
|
|
89
|
+
icon: string;
|
|
90
|
+
description: string;
|
|
91
|
+
};
|
|
92
|
+
}[];
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=runtime-lit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-lit.d.ts","sourceRoot":"","sources":["../src/runtime-lit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EAEX,eAAe,EACf,WAAW,EACX,aAAa,EACd,MAAM,SAAS,CAAC;AAIjB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC;AAGrC,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAMvE;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,cAAc,CAAC,eAAe,CAsE5D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,WAAW,CA0GpD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,WAAW,CAoGpD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,cAAc,CAAC,aAAa,CAwFxD,CAAC;AAMF;;;GAGG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;EAQZ,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkBnB,CAAC"}
|
|
@@ -0,0 +1,402 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adaptive Overlays - Runtime Module (Lit)
|
|
3
|
+
*
|
|
4
|
+
* Visual overlay actions: highlight, pulse, badge, tooltip, celebrations.
|
|
5
|
+
* Uses the Lit web component mountable instead of the React one.
|
|
6
|
+
*/
|
|
7
|
+
import { executeCelebrate } from './celebrations';
|
|
8
|
+
import { executeTour } from './executors/tour';
|
|
9
|
+
import { showHighlight } from './highlight';
|
|
10
|
+
import { executeModal } from './modal';
|
|
11
|
+
import { sanitizeHtml } from './sanitizer';
|
|
12
|
+
import { showTooltip } from './tooltip';
|
|
13
|
+
import { WorkflowWidgetLitMountable } from './WorkflowWidgetLit';
|
|
14
|
+
// Re-export executeModal and executeTour for use by other packages
|
|
15
|
+
export { executeModal, executeTour };
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// Executors
|
|
18
|
+
// ============================================================================
|
|
19
|
+
/**
|
|
20
|
+
* Execute a highlight action
|
|
21
|
+
*/
|
|
22
|
+
export const executeHighlight = async (action, context) => {
|
|
23
|
+
let anchorEl = context.resolveAnchor(action.anchorId);
|
|
24
|
+
if (!anchorEl && context.waitForAnchor) {
|
|
25
|
+
anchorEl = await context.waitForAnchor(action.anchorId, 3000);
|
|
26
|
+
}
|
|
27
|
+
if (!anchorEl) {
|
|
28
|
+
console.warn(`[adaptive-overlays] Anchor not found after waiting: ${action.anchorId.selector}`);
|
|
29
|
+
return { cleanup: () => { } };
|
|
30
|
+
}
|
|
31
|
+
// Skip re-application if the user previously dismissed this highlight.
|
|
32
|
+
// The dismissed attribute is set by onDismiss (user click-outside / Esc)
|
|
33
|
+
// and survives config-driven revert+reapply cycles.
|
|
34
|
+
if (anchorEl.getAttribute('data-syntro-highlight-dismissed')) {
|
|
35
|
+
return { cleanup: () => { } };
|
|
36
|
+
}
|
|
37
|
+
// Self-guard: destroy any existing highlight on this anchor to prevent duplicates
|
|
38
|
+
// (batch re-apply on navigation can call this executor multiple times for the same anchor)
|
|
39
|
+
const existing = anchorEl.getAttribute('data-syntro-highlight');
|
|
40
|
+
if (existing) {
|
|
41
|
+
const prev = context.overlayRoot.querySelectorAll('.syntro-spotlight-scrim, .syntro-spotlight-ring');
|
|
42
|
+
prev.forEach((el) => el.remove());
|
|
43
|
+
}
|
|
44
|
+
anchorEl.setAttribute('data-syntro-highlight', 'true');
|
|
45
|
+
// Resolve ring color: action override → theme primary → host page var → fallback
|
|
46
|
+
let ringColor = action.style?.color;
|
|
47
|
+
if (!ringColor) {
|
|
48
|
+
try {
|
|
49
|
+
const primary = getComputedStyle(context.overlayRoot)
|
|
50
|
+
.getPropertyValue('--sc-color-primary')
|
|
51
|
+
?.trim();
|
|
52
|
+
if (primary)
|
|
53
|
+
ringColor = primary;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
/* fallback to showHighlight default */
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const handle = showHighlight(anchorEl, context.overlayRoot, {
|
|
60
|
+
paddingPx: action.style?.paddingPx ?? 12,
|
|
61
|
+
radiusPx: action.style?.radiusPx ?? 12,
|
|
62
|
+
scrimOpacity: action.style?.scrimOpacity ?? 0.55,
|
|
63
|
+
ringColor,
|
|
64
|
+
blocking: action.blocking ?? false,
|
|
65
|
+
onClickOutside: action.onClickOutside ?? true,
|
|
66
|
+
onEsc: action.onEsc ?? true,
|
|
67
|
+
onDismiss: () => {
|
|
68
|
+
anchorEl.setAttribute('data-syntro-highlight-dismissed', 'true');
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
context.publishEvent('action.applied', {
|
|
72
|
+
id: context.generateId(),
|
|
73
|
+
kind: 'overlays:highlight',
|
|
74
|
+
anchorId: action.anchorId,
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
cleanup: () => {
|
|
78
|
+
handle.destroy();
|
|
79
|
+
anchorEl.removeAttribute('data-syntro-highlight');
|
|
80
|
+
anchorEl.removeAttribute('data-syntro-highlight-dismissed');
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Execute a pulse action
|
|
86
|
+
*/
|
|
87
|
+
export const executePulse = async (action, context) => {
|
|
88
|
+
let anchorEl = context.resolveAnchor(action.anchorId);
|
|
89
|
+
if (!anchorEl && context.waitForAnchor) {
|
|
90
|
+
anchorEl = await context.waitForAnchor(action.anchorId, 3000);
|
|
91
|
+
}
|
|
92
|
+
if (!anchorEl) {
|
|
93
|
+
console.warn(`[adaptive-overlays] Anchor not found after waiting: ${action.anchorId.selector}`);
|
|
94
|
+
return { cleanup: () => { } };
|
|
95
|
+
}
|
|
96
|
+
const duration = action.duration ?? 4000;
|
|
97
|
+
// Wait one frame so ThemeProvider's useEffect has injected CSS vars
|
|
98
|
+
await new Promise((resolve) => requestAnimationFrame(resolve));
|
|
99
|
+
// Read primary + secondary colors from theme (shadow DOM overlay root has --sc-* vars)
|
|
100
|
+
const parseHex = (hex) => ({
|
|
101
|
+
r: parseInt(hex.slice(1, 3), 16),
|
|
102
|
+
g: parseInt(hex.slice(3, 5), 16),
|
|
103
|
+
b: parseInt(hex.slice(5, 7), 16),
|
|
104
|
+
});
|
|
105
|
+
const fallback = { r: 79, g: 70, b: 229 }; // indigo-600
|
|
106
|
+
let primary = fallback;
|
|
107
|
+
let secondary = null;
|
|
108
|
+
try {
|
|
109
|
+
const styles = getComputedStyle(context.overlayRoot);
|
|
110
|
+
const pHex = styles.getPropertyValue('--sc-color-primary')?.trim();
|
|
111
|
+
const sHex = styles.getPropertyValue('--sc-color-primary-hover')?.trim();
|
|
112
|
+
if (pHex?.startsWith('#') && pHex.length >= 7) {
|
|
113
|
+
primary = parseHex(pHex);
|
|
114
|
+
}
|
|
115
|
+
if (sHex?.startsWith('#') && sHex.length >= 7) {
|
|
116
|
+
secondary = parseHex(sHex);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
/* fallback to default */
|
|
121
|
+
}
|
|
122
|
+
// Inject/update pulse animation with theme colors
|
|
123
|
+
// Two-tone pulse when both primary and secondary are available
|
|
124
|
+
const existing = document.querySelector('[data-syntro-pulse-styles]');
|
|
125
|
+
if (existing)
|
|
126
|
+
existing.remove();
|
|
127
|
+
const style = document.createElement('style');
|
|
128
|
+
style.setAttribute('data-syntro-pulse-styles', '');
|
|
129
|
+
const { r: pr, g: pg, b: pb } = primary;
|
|
130
|
+
if (secondary) {
|
|
131
|
+
const { r: sr, g: sg, b: sb } = secondary;
|
|
132
|
+
style.textContent = `
|
|
133
|
+
@keyframes syntro-pulse-anim {
|
|
134
|
+
0%, 100% {
|
|
135
|
+
box-shadow: 0 0 0 0 rgba(${pr}, ${pg}, ${pb}, 0.35);
|
|
136
|
+
}
|
|
137
|
+
25% {
|
|
138
|
+
box-shadow: 0 0 0 12px rgba(${pr}, ${pg}, ${pb}, 0);
|
|
139
|
+
}
|
|
140
|
+
50% {
|
|
141
|
+
box-shadow: 0 0 0 0 rgba(${sr}, ${sg}, ${sb}, 0.35);
|
|
142
|
+
}
|
|
143
|
+
75% {
|
|
144
|
+
box-shadow: 0 0 0 12px rgba(${sr}, ${sg}, ${sb}, 0);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
`;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
style.textContent = `
|
|
151
|
+
@keyframes syntro-pulse-anim {
|
|
152
|
+
0%, 100% {
|
|
153
|
+
box-shadow: 0 0 0 0 rgba(${pr}, ${pg}, ${pb}, 0.35);
|
|
154
|
+
}
|
|
155
|
+
50% {
|
|
156
|
+
box-shadow: 0 0 0 12px rgba(${pr}, ${pg}, ${pb}, 0);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
`;
|
|
160
|
+
}
|
|
161
|
+
document.head.appendChild(style);
|
|
162
|
+
// Apply pulse animation via inline style (scoped to this element)
|
|
163
|
+
const originalAnimation = anchorEl.style.animation;
|
|
164
|
+
anchorEl.style.animation = 'syntro-pulse-anim 2.5s cubic-bezier(0.4, 0, 0.6, 1) infinite';
|
|
165
|
+
anchorEl.setAttribute('data-syntro-pulse', 'true');
|
|
166
|
+
// Set up auto-remove timeout
|
|
167
|
+
const timeoutId = setTimeout(() => {
|
|
168
|
+
anchorEl.style.animation = originalAnimation;
|
|
169
|
+
anchorEl.removeAttribute('data-syntro-pulse');
|
|
170
|
+
}, duration);
|
|
171
|
+
context.publishEvent('action.applied', {
|
|
172
|
+
id: context.generateId(),
|
|
173
|
+
kind: 'overlays:pulse',
|
|
174
|
+
anchorId: action.anchorId,
|
|
175
|
+
duration,
|
|
176
|
+
});
|
|
177
|
+
return {
|
|
178
|
+
cleanup: () => {
|
|
179
|
+
clearTimeout(timeoutId);
|
|
180
|
+
if (!anchorEl.isConnected)
|
|
181
|
+
return;
|
|
182
|
+
anchorEl.style.animation = originalAnimation;
|
|
183
|
+
anchorEl.removeAttribute('data-syntro-pulse');
|
|
184
|
+
},
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Execute a badge action
|
|
189
|
+
*/
|
|
190
|
+
export const executeBadge = async (action, context) => {
|
|
191
|
+
let anchorEl = context.resolveAnchor(action.anchorId);
|
|
192
|
+
if (!anchorEl && context.waitForAnchor) {
|
|
193
|
+
anchorEl = await context.waitForAnchor(action.anchorId, 3000);
|
|
194
|
+
}
|
|
195
|
+
if (!anchorEl) {
|
|
196
|
+
console.warn(`[adaptive-overlays] Anchor not found after waiting: ${action.anchorId.selector}`);
|
|
197
|
+
return { cleanup: () => { } };
|
|
198
|
+
}
|
|
199
|
+
// Read primary color from theme (overlay root has --sc-* vars from shadow DOM)
|
|
200
|
+
let badgeColor = '#4f46e5';
|
|
201
|
+
try {
|
|
202
|
+
const primary = getComputedStyle(context.overlayRoot)
|
|
203
|
+
.getPropertyValue('--sc-color-primary')
|
|
204
|
+
?.trim();
|
|
205
|
+
if (primary?.startsWith('#') && primary.length >= 7) {
|
|
206
|
+
badgeColor = primary;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
/* fallback to default */
|
|
211
|
+
}
|
|
212
|
+
// Create badge element with inline styles (no global style injection)
|
|
213
|
+
const badge = document.createElement('div');
|
|
214
|
+
badge.textContent = action.content;
|
|
215
|
+
badge.setAttribute('data-syntro-badge', action.anchorId.selector);
|
|
216
|
+
// Apply styles directly to element
|
|
217
|
+
Object.assign(badge.style, {
|
|
218
|
+
position: 'absolute',
|
|
219
|
+
padding: '2px 6px',
|
|
220
|
+
fontSize: '12px',
|
|
221
|
+
fontWeight: '600',
|
|
222
|
+
lineHeight: '1',
|
|
223
|
+
color: 'white',
|
|
224
|
+
background: badgeColor,
|
|
225
|
+
borderRadius: '9999px',
|
|
226
|
+
pointerEvents: 'none',
|
|
227
|
+
zIndex: '2147483646',
|
|
228
|
+
whiteSpace: 'nowrap',
|
|
229
|
+
});
|
|
230
|
+
// Position badge relative to anchor
|
|
231
|
+
const position = action.position ?? 'top-right';
|
|
232
|
+
// Ensure anchor has relative positioning for badge
|
|
233
|
+
const originalPosition = anchorEl.style.position;
|
|
234
|
+
if (getComputedStyle(anchorEl).position === 'static') {
|
|
235
|
+
anchorEl.style.position = 'relative';
|
|
236
|
+
}
|
|
237
|
+
// Append to anchor for relative positioning
|
|
238
|
+
anchorEl.appendChild(badge);
|
|
239
|
+
// Position based on config
|
|
240
|
+
switch (position) {
|
|
241
|
+
case 'top-left':
|
|
242
|
+
Object.assign(badge.style, { top: '-8px', left: '-8px' });
|
|
243
|
+
break;
|
|
244
|
+
case 'top-right':
|
|
245
|
+
Object.assign(badge.style, { top: '-8px', right: '-8px' });
|
|
246
|
+
break;
|
|
247
|
+
case 'bottom-left':
|
|
248
|
+
Object.assign(badge.style, { bottom: '-8px', left: '-8px' });
|
|
249
|
+
break;
|
|
250
|
+
case 'bottom-right':
|
|
251
|
+
Object.assign(badge.style, { bottom: '-8px', right: '-8px' });
|
|
252
|
+
break;
|
|
253
|
+
}
|
|
254
|
+
context.publishEvent('action.applied', {
|
|
255
|
+
id: context.generateId(),
|
|
256
|
+
kind: 'overlays:badge',
|
|
257
|
+
anchorId: action.anchorId,
|
|
258
|
+
content: action.content,
|
|
259
|
+
position,
|
|
260
|
+
});
|
|
261
|
+
return {
|
|
262
|
+
cleanup: () => {
|
|
263
|
+
try {
|
|
264
|
+
badge.remove();
|
|
265
|
+
}
|
|
266
|
+
catch {
|
|
267
|
+
/* already detached */
|
|
268
|
+
}
|
|
269
|
+
if (!anchorEl.isConnected)
|
|
270
|
+
return;
|
|
271
|
+
if (originalPosition !== undefined) {
|
|
272
|
+
anchorEl.style.position = originalPosition;
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
updateFn: (changes) => {
|
|
276
|
+
if ('content' in changes && typeof changes.content === 'string') {
|
|
277
|
+
badge.textContent = changes.content;
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
};
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* Execute a tooltip action
|
|
284
|
+
*/
|
|
285
|
+
export const executeTooltip = async (action, context) => {
|
|
286
|
+
let anchorEl = context.resolveAnchor(action.anchorId);
|
|
287
|
+
if (!anchorEl && context.waitForAnchor) {
|
|
288
|
+
anchorEl = await context.waitForAnchor(action.anchorId, 3000);
|
|
289
|
+
}
|
|
290
|
+
if (!anchorEl) {
|
|
291
|
+
console.warn(`[adaptive-overlays] Anchor not found after waiting: ${action.anchorId.selector}`);
|
|
292
|
+
return { cleanup: () => { } };
|
|
293
|
+
}
|
|
294
|
+
// Build tooltip HTML
|
|
295
|
+
const { content } = action;
|
|
296
|
+
let html = '';
|
|
297
|
+
if (content.title) {
|
|
298
|
+
html += `<div class="syntro-tt-title">${sanitizeHtml(content.title)}</div>`;
|
|
299
|
+
}
|
|
300
|
+
html += `<div class="syntro-tt-body">${sanitizeHtml(content.body)}</div>`;
|
|
301
|
+
// Add CTA buttons if provided (new multi-button support)
|
|
302
|
+
if (content.ctaButtons && content.ctaButtons.length > 0) {
|
|
303
|
+
html += `<div class="syntro-tt-actions">`;
|
|
304
|
+
for (const btn of content.ctaButtons) {
|
|
305
|
+
const isPrimary = btn.primary ?? false;
|
|
306
|
+
html += `
|
|
307
|
+
<button
|
|
308
|
+
class="syntro-tt-btn ${isPrimary ? 'syntro-tt-btn-primary' : ''}"
|
|
309
|
+
data-syntro-action="${sanitizeHtml(btn.actionId)}"
|
|
310
|
+
>
|
|
311
|
+
${sanitizeHtml(btn.label)}
|
|
312
|
+
</button>
|
|
313
|
+
`;
|
|
314
|
+
}
|
|
315
|
+
html += `</div>`;
|
|
316
|
+
}
|
|
317
|
+
else if (content.cta) {
|
|
318
|
+
// Legacy single CTA support
|
|
319
|
+
html += `<div class="syntro-tt-actions">
|
|
320
|
+
<button class="syntro-tt-btn syntro-tt-btn-primary" data-syntro-action="cta">
|
|
321
|
+
${sanitizeHtml(content.cta.label)}
|
|
322
|
+
</button>
|
|
323
|
+
</div>`;
|
|
324
|
+
}
|
|
325
|
+
const handle = showTooltip(anchorEl, context.overlayRoot, {
|
|
326
|
+
html,
|
|
327
|
+
placement: action.placement ?? 'top',
|
|
328
|
+
trigger: action.trigger ?? 'immediate',
|
|
329
|
+
onAction: (actionId) => {
|
|
330
|
+
// Handle dismiss CTA — destroy the tooltip
|
|
331
|
+
if (actionId === 'dismiss') {
|
|
332
|
+
handle.destroy();
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
if (actionId === 'cta' && content.cta) {
|
|
336
|
+
context.publishEvent('action.cta_clicked', {
|
|
337
|
+
anchorId: action.anchorId,
|
|
338
|
+
ctaLabel: content.cta.label,
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
else if (content.ctaButtons) {
|
|
342
|
+
const clickedBtn = content.ctaButtons.find((b) => b.actionId === actionId);
|
|
343
|
+
if (clickedBtn) {
|
|
344
|
+
context.publishEvent('action.tooltip_cta_clicked', {
|
|
345
|
+
anchorId: action.anchorId,
|
|
346
|
+
actionId,
|
|
347
|
+
label: clickedBtn.label,
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
handle.destroy();
|
|
352
|
+
},
|
|
353
|
+
});
|
|
354
|
+
context.publishEvent('action.applied', {
|
|
355
|
+
id: context.generateId(),
|
|
356
|
+
kind: 'overlays:tooltip',
|
|
357
|
+
anchorId: action.anchorId,
|
|
358
|
+
trigger: action.trigger ?? 'immediate',
|
|
359
|
+
});
|
|
360
|
+
return {
|
|
361
|
+
cleanup: () => {
|
|
362
|
+
handle.destroy();
|
|
363
|
+
},
|
|
364
|
+
};
|
|
365
|
+
};
|
|
366
|
+
// ============================================================================
|
|
367
|
+
// Executor Definitions for Registration
|
|
368
|
+
// ============================================================================
|
|
369
|
+
/**
|
|
370
|
+
* All executors provided by this app.
|
|
371
|
+
* These are registered with the runtime's ExecutorRegistry.
|
|
372
|
+
*/
|
|
373
|
+
export const executors = [
|
|
374
|
+
{ kind: 'overlays:highlight', executor: executeHighlight },
|
|
375
|
+
{ kind: 'overlays:pulse', executor: executePulse },
|
|
376
|
+
{ kind: 'overlays:badge', executor: executeBadge },
|
|
377
|
+
{ kind: 'overlays:tooltip', executor: executeTooltip },
|
|
378
|
+
{ kind: 'overlays:modal', executor: executeModal },
|
|
379
|
+
{ kind: 'overlays:tour', executor: executeTour },
|
|
380
|
+
{ kind: 'overlays:celebrate', executor: executeCelebrate },
|
|
381
|
+
];
|
|
382
|
+
/**
|
|
383
|
+
* App runtime manifest (Lit variant).
|
|
384
|
+
*/
|
|
385
|
+
export const runtime = {
|
|
386
|
+
id: 'adaptive-overlays',
|
|
387
|
+
version: '1.0.0',
|
|
388
|
+
name: 'Overlays',
|
|
389
|
+
description: 'Tooltips, highlights, badges, modals, celebrations, visual overlays, and workflow tracking',
|
|
390
|
+
executors,
|
|
391
|
+
widgets: [
|
|
392
|
+
{
|
|
393
|
+
id: 'adaptive-overlays:workflow-tracker',
|
|
394
|
+
component: WorkflowWidgetLitMountable,
|
|
395
|
+
metadata: {
|
|
396
|
+
name: 'Workflow Tracker',
|
|
397
|
+
icon: '📋',
|
|
398
|
+
description: 'Tracks multi-step workflow progress across tours',
|
|
399
|
+
},
|
|
400
|
+
},
|
|
401
|
+
],
|
|
402
|
+
};
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EAEX,eAAe,EACf,WAAW,EACX,aAAa,EACd,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAGvC,OAAO,KAAK,EACV,cAAc,EACd,WAAW,EAEX,eAAe,EACf,WAAW,EACX,aAAa,EACd,MAAM,SAAS,CAAC;AAKjB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC;AAGrC,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAMvE;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,cAAc,CAAC,eAAe,CAsE5D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,WAAW,CA0GpD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,WAAW,CAoGpD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,cAAc,CAAC,aAAa,CAwFxD,CAAC;AAMF;;;GAGG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;EAQZ,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BnB,CAAC"}
|
package/dist/runtime.js
CHANGED
|
@@ -10,6 +10,7 @@ import { executeModal } from './modal';
|
|
|
10
10
|
import { sanitizeHtml } from './sanitizer';
|
|
11
11
|
import { showTooltip } from './tooltip';
|
|
12
12
|
import { WorkflowMountableWidget } from './WorkflowWidget';
|
|
13
|
+
import { WorkflowWidgetLitMountable } from './WorkflowWidgetLit';
|
|
13
14
|
// Re-export executeModal and executeTour for use by other packages
|
|
14
15
|
export { executeModal, executeTour };
|
|
15
16
|
// ============================================================================
|
|
@@ -397,5 +398,14 @@ export const runtime = {
|
|
|
397
398
|
description: 'Tracks multi-step workflow progress across tours',
|
|
398
399
|
},
|
|
399
400
|
},
|
|
401
|
+
{
|
|
402
|
+
id: 'adaptive-overlays:workflow-tracker-lit',
|
|
403
|
+
component: WorkflowWidgetLitMountable,
|
|
404
|
+
metadata: {
|
|
405
|
+
name: 'Workflow Tracker (Lit)',
|
|
406
|
+
icon: '📋',
|
|
407
|
+
description: 'Lit web component equivalent of the Workflow Tracker — decorator-free, light DOM',
|
|
408
|
+
},
|
|
409
|
+
},
|
|
400
410
|
],
|
|
401
411
|
};
|