@syntrologie/adapt-overlays 2.16.0 → 2.18.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/chunk-VHAA22YE.js +14 -0
- package/dist/chunk-VHAA22YE.js.map +7 -0
- package/dist/runtime.d.ts +2 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +2596 -354
- package/dist/runtime.js.map +7 -0
- package/dist/schema.d.ts +90 -21
- package/dist/schema.d.ts.map +1 -1
- package/dist/schema.js +440 -151
- package/dist/schema.js.map +7 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -22
- package/dist/WorkflowTracker.d.ts +0 -10
- package/dist/WorkflowTracker.d.ts.map +0 -1
- package/dist/WorkflowTracker.js +0 -19
- package/dist/WorkflowWidget.d.ts +0 -70
- package/dist/WorkflowWidget.d.ts.map +0 -1
- package/dist/WorkflowWidget.js +0 -330
- package/dist/WorkflowWidgetLit.js +0 -617
- package/dist/cdn.d.ts +0 -35
- package/dist/cdn.d.ts.map +0 -1
- package/dist/cdn.js +0 -39
- package/dist/celebrations/__tests__/engine.test.js +0 -130
- package/dist/celebrations/__tests__/executor.test.js +0 -102
- package/dist/celebrations/__tests__/reduced-motion.test.js +0 -97
- package/dist/celebrations/effects/__tests__/confetti.test.js +0 -89
- package/dist/celebrations/effects/__tests__/emoji-rain.test.js +0 -88
- package/dist/celebrations/effects/__tests__/fireworks.test.js +0 -87
- package/dist/celebrations/effects/__tests__/sparkles.test.js +0 -79
- package/dist/celebrations/effects/confetti.js +0 -80
- package/dist/celebrations/effects/emoji-rain.js +0 -73
- package/dist/celebrations/effects/fireworks.js +0 -69
- package/dist/celebrations/effects/sparkles.js +0 -83
- package/dist/celebrations/engine.js +0 -93
- package/dist/celebrations/index.js +0 -73
- package/dist/celebrations/types.js +0 -1
- package/dist/editor.d.ts +0 -27
- package/dist/editor.d.ts.map +0 -1
- package/dist/editor.js +0 -22
- package/dist/executors/tour.js +0 -335
- package/dist/highlight.js +0 -180
- package/dist/modal.js +0 -218
- package/dist/overlay-editor-state.d.ts +0 -41
- package/dist/overlay-editor-state.d.ts.map +0 -1
- package/dist/overlay-editor-state.js +0 -131
- package/dist/overlay-editor-ui.d.ts +0 -9
- package/dist/overlay-editor-ui.d.ts.map +0 -1
- package/dist/overlay-editor-ui.js +0 -306
- package/dist/runtime-lit.d.ts +0 -94
- package/dist/runtime-lit.d.ts.map +0 -1
- package/dist/runtime-lit.js +0 -402
- package/dist/sanitizer.js +0 -84
- package/dist/summarize.js +0 -86
- package/dist/tooltip.js +0 -279
- package/dist/tour-types.js +0 -7
- package/dist/types.js +0 -7
- package/dist/workflow-types.js +0 -1
- package/node_modules/@syntro/design-system/README.md +0 -335
- package/node_modules/@syntro/design-system/dist/assets/syntrologie-logo.svg +0 -21
- package/node_modules/@syntro/design-system/dist/assets/syntrologie-logomark.svg +0 -10
- package/node_modules/@syntro/design-system/dist/index.d.ts +0 -8
- package/node_modules/@syntro/design-system/dist/index.d.ts.map +0 -1
- package/node_modules/@syntro/design-system/dist/index.js +0 -7
- package/node_modules/@syntro/design-system/dist/tailwind-preset.d.ts +0 -19
- package/node_modules/@syntro/design-system/dist/tailwind-preset.d.ts.map +0 -1
- package/node_modules/@syntro/design-system/dist/tailwind-preset.js +0 -455
- package/node_modules/@syntro/design-system/dist/tokens/colors.css +0 -464
- package/node_modules/@syntro/design-system/dist/tokens/colors.d.ts +0 -874
- package/node_modules/@syntro/design-system/dist/tokens/colors.d.ts.map +0 -1
- package/node_modules/@syntro/design-system/dist/tokens/colors.js +0 -564
- package/node_modules/@syntro/design-system/dist/tokens/effects.css +0 -43
- package/node_modules/@syntro/design-system/dist/tokens/effects.d.ts +0 -139
- package/node_modules/@syntro/design-system/dist/tokens/effects.d.ts.map +0 -1
- package/node_modules/@syntro/design-system/dist/tokens/effects.js +0 -121
- package/node_modules/@syntro/design-system/dist/tokens/index.d.ts +0 -12
- package/node_modules/@syntro/design-system/dist/tokens/index.d.ts.map +0 -1
- package/node_modules/@syntro/design-system/dist/tokens/index.js +0 -11
- package/node_modules/@syntro/design-system/dist/tokens/panel-shell.d.ts +0 -93
- package/node_modules/@syntro/design-system/dist/tokens/panel-shell.d.ts.map +0 -1
- package/node_modules/@syntro/design-system/dist/tokens/panel-shell.js +0 -72
- package/node_modules/@syntro/design-system/package.json +0 -55
- package/node_modules/@syntro/design-system/src/assets/syntrologie-logo.svg +0 -21
- package/node_modules/@syntro/design-system/src/assets/syntrologie-logomark.svg +0 -10
- package/node_modules/@syntrologie/shared-editor-ui/dist/cn.d.ts +0 -2
- package/node_modules/@syntrologie/shared-editor-ui/dist/cn.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/cn.js +0 -3
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPicker.d.ts +0 -34
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPicker.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPicker.js +0 -161
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPickerLit.d.ts +0 -84
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPickerLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/AnchorPickerLit.js +0 -323
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggle.d.ts +0 -7
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggle.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggle.js +0 -9
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggleLit.d.ts +0 -25
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggleLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/BeforeAfterToggleLit.js +0 -55
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLine.d.ts +0 -23
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLine.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLine.js +0 -40
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLineLit.d.ts +0 -33
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLineLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ConditionStatusLineLit.js +0 -118
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadge.d.ts +0 -7
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadge.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadge.js +0 -22
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadgeLit.d.ts +0 -32
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadgeLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DetectionBadgeLit.js +0 -68
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSection.d.ts +0 -8
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSection.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSection.js +0 -9
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSectionLit.d.ts +0 -34
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSectionLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/DismissedSectionLit.js +0 -57
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButton.d.ts +0 -7
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButton.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButton.js +0 -4
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButtonLit.d.ts +0 -13
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButtonLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditBackButtonLit.js +0 -31
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBody.d.ts +0 -7
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBody.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBody.js +0 -4
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBodyLit.d.ts +0 -7
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBodyLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorBodyLit.js +0 -15
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCard.d.ts +0 -13
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCard.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCard.js +0 -15
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCardLit.d.ts +0 -36
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCardLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorCardLit.js +0 -102
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooter.d.ts +0 -7
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooter.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooter.js +0 -4
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooterLit.d.ts +0 -20
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooterLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorFooterLit.js +0 -48
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeader.d.ts +0 -9
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeader.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeader.js +0 -4
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeaderLit.d.ts +0 -16
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeaderLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorHeaderLit.js +0 -25
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInput.d.ts +0 -8
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInput.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInput.js +0 -8
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInputLit.d.ts +0 -66
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInputLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorInputLit.js +0 -87
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayout.d.ts +0 -7
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayout.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayout.js +0 -4
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayoutLit.d.ts +0 -7
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayoutLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorLayoutLit.js +0 -15
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShell.d.ts +0 -25
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShell.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShell.js +0 -390
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShellLit.d.ts +0 -66
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShellLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorPanelShellLit.js +0 -528
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelect.d.ts +0 -8
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelect.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelect.js +0 -8
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelectLit.d.ts +0 -41
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelectLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorSelectLit.js +0 -63
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextarea.d.ts +0 -8
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextarea.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextarea.js +0 -17
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextareaLit.d.ts +0 -55
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextareaLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EditorTextareaLit.js +0 -92
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlight.d.ts +0 -32
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlight.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlight.js +0 -85
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlightLit.d.ts +0 -90
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlightLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/ElementHighlightLit.js +0 -242
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyState.d.ts +0 -6
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyState.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyState.js +0 -4
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyStateLit.d.ts +0 -12
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyStateLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/EmptyStateLit.js +0 -21
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeader.d.ts +0 -8
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeader.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeader.js +0 -5
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeaderLit.d.ts +0 -21
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeaderLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/GroupHeaderLit.js +0 -33
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourney.d.ts +0 -12
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourney.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourney.js +0 -40
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourneyLit.d.ts +0 -28
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourneyLit.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/components/TriggerJourneyLit.js +0 -121
- package/node_modules/@syntrologie/shared-editor-ui/dist/controllers/PanelShellController.d.ts +0 -110
- package/node_modules/@syntrologie/shared-editor-ui/dist/controllers/PanelShellController.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/controllers/PanelShellController.js +0 -481
- package/node_modules/@syntrologie/shared-editor-ui/dist/formatConditionLabel.d.ts +0 -26
- package/node_modules/@syntrologie/shared-editor-ui/dist/formatConditionLabel.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/formatConditionLabel.js +0 -202
- package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useElementRect.d.ts +0 -8
- package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useElementRect.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useElementRect.js +0 -46
- package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useTriggerWhenStatus.d.ts +0 -24
- package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useTriggerWhenStatus.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/hooks/useTriggerWhenStatus.js +0 -86
- package/node_modules/@syntrologie/shared-editor-ui/dist/index.d.ts +0 -36
- package/node_modules/@syntrologie/shared-editor-ui/dist/index.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/index.js +0 -26
- package/node_modules/@syntrologie/shared-editor-ui/dist/lit-elements.d.ts +0 -15
- package/node_modules/@syntrologie/shared-editor-ui/dist/lit-elements.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/lit-elements.js +0 -14
- package/node_modules/@syntrologie/shared-editor-ui/dist/utils/elementChainRecommender.d.ts +0 -33
- package/node_modules/@syntrologie/shared-editor-ui/dist/utils/elementChainRecommender.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/utils/elementChainRecommender.js +0 -68
- package/node_modules/@syntrologie/shared-editor-ui/dist/utils/selectorGenerator.d.ts +0 -22
- package/node_modules/@syntrologie/shared-editor-ui/dist/utils/selectorGenerator.d.ts.map +0 -1
- package/node_modules/@syntrologie/shared-editor-ui/dist/utils/selectorGenerator.js +0 -143
- package/node_modules/@syntrologie/shared-editor-ui/package.json +0 -55
package/dist/runtime-lit.js
DELETED
|
@@ -1,402 +0,0 @@
|
|
|
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/sanitizer.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* HTML Sanitizer
|
|
3
|
-
*
|
|
4
|
-
* Sanitizes HTML to prevent XSS attacks.
|
|
5
|
-
* Uses native Sanitizer API when available, falls back to whitelist approach.
|
|
6
|
-
*/
|
|
7
|
-
const ALLOWED_TAGS = new Set([
|
|
8
|
-
'b',
|
|
9
|
-
'strong',
|
|
10
|
-
'i',
|
|
11
|
-
'em',
|
|
12
|
-
'u',
|
|
13
|
-
'span',
|
|
14
|
-
'div',
|
|
15
|
-
'p',
|
|
16
|
-
'br',
|
|
17
|
-
'ul',
|
|
18
|
-
'ol',
|
|
19
|
-
'li',
|
|
20
|
-
'code',
|
|
21
|
-
'pre',
|
|
22
|
-
'small',
|
|
23
|
-
'sup',
|
|
24
|
-
'sub',
|
|
25
|
-
'a',
|
|
26
|
-
'button',
|
|
27
|
-
// SVG elements (for inline Lucide icons in config HTML)
|
|
28
|
-
'svg',
|
|
29
|
-
'path',
|
|
30
|
-
'circle',
|
|
31
|
-
'line',
|
|
32
|
-
'polyline',
|
|
33
|
-
'polygon',
|
|
34
|
-
'rect',
|
|
35
|
-
'g',
|
|
36
|
-
]);
|
|
37
|
-
export function sanitizeHtml(html) {
|
|
38
|
-
// Try native Sanitizer API first
|
|
39
|
-
const hasNative = typeof window.Sanitizer === 'function';
|
|
40
|
-
if (hasNative) {
|
|
41
|
-
try {
|
|
42
|
-
const s = new window.Sanitizer({});
|
|
43
|
-
const frag = s.sanitizeToFragment(html);
|
|
44
|
-
const div = document.createElement('div');
|
|
45
|
-
div.append(frag);
|
|
46
|
-
return div.innerHTML;
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
// Fall through to manual sanitizer
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
// Conservative fallback sanitizer
|
|
53
|
-
const tpl = document.createElement('template');
|
|
54
|
-
tpl.innerHTML = html;
|
|
55
|
-
const root = tpl.content;
|
|
56
|
-
const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT, null);
|
|
57
|
-
const toRemove = [];
|
|
58
|
-
while (walker.nextNode()) {
|
|
59
|
-
const el = walker.currentNode;
|
|
60
|
-
const tag = el.tagName.toLowerCase();
|
|
61
|
-
if (!ALLOWED_TAGS.has(tag)) {
|
|
62
|
-
toRemove.push(el);
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
// Remove dangerous attributes
|
|
66
|
-
for (const attr of Array.from(el.attributes)) {
|
|
67
|
-
const name = attr.name.toLowerCase();
|
|
68
|
-
const value = attr.value.trim().toLowerCase();
|
|
69
|
-
const isEvent = name.startsWith('on');
|
|
70
|
-
const isJsUrl = (name === 'href' || name === 'src') && value.startsWith('javascript:');
|
|
71
|
-
if (isEvent || isJsUrl) {
|
|
72
|
-
el.removeAttribute(attr.name);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
// Remove disallowed elements but keep their children
|
|
77
|
-
for (const el of toRemove) {
|
|
78
|
-
while (el.firstChild) {
|
|
79
|
-
el.parentNode?.insertBefore(el.firstChild, el);
|
|
80
|
-
}
|
|
81
|
-
el.remove();
|
|
82
|
-
}
|
|
83
|
-
return tpl.innerHTML;
|
|
84
|
-
}
|
package/dist/summarize.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Human-readable summary generation for overlay config items.
|
|
3
|
-
*
|
|
4
|
-
* Pure functions — no DOM access, just string formatting from config data.
|
|
5
|
-
*/
|
|
6
|
-
const MAX_TEXT_LEN = 40;
|
|
7
|
-
/** Extract the CSS selector string from an anchorId object. */
|
|
8
|
-
function resolveAnchorSelector(anchorId) {
|
|
9
|
-
if (!anchorId)
|
|
10
|
-
return '';
|
|
11
|
-
if (typeof anchorId === 'string')
|
|
12
|
-
return anchorId;
|
|
13
|
-
if (typeof anchorId === 'object')
|
|
14
|
-
return anchorId.selector ?? '';
|
|
15
|
-
return '';
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Convert a CSS selector into a human-friendly element description.
|
|
19
|
-
*/
|
|
20
|
-
export function describeSelector(selector) {
|
|
21
|
-
if (!selector)
|
|
22
|
-
return '(no target)';
|
|
23
|
-
// ID selector: strip #
|
|
24
|
-
if (selector.startsWith('#')) {
|
|
25
|
-
return truncate(selector.slice(1), 50);
|
|
26
|
-
}
|
|
27
|
-
// data-testid selector
|
|
28
|
-
const testIdMatch = selector.match(/\[data-testid="([^"]+)"\]/);
|
|
29
|
-
if (testIdMatch) {
|
|
30
|
-
return `${testIdMatch[1]} element`;
|
|
31
|
-
}
|
|
32
|
-
return truncate(selector, 50);
|
|
33
|
-
}
|
|
34
|
-
function truncate(text, max) {
|
|
35
|
-
if (text.length <= max)
|
|
36
|
-
return text;
|
|
37
|
-
return `${text.slice(0, max)}...`;
|
|
38
|
-
}
|
|
39
|
-
function truncateQuoted(text, max) {
|
|
40
|
-
if (text.length <= max)
|
|
41
|
-
return `"${text}"`;
|
|
42
|
-
return `"${text.slice(0, max)}..."`;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Generate a human-readable one-liner for an overlay config item.
|
|
46
|
-
*/
|
|
47
|
-
export function summarizeOverlayItem(type, item) {
|
|
48
|
-
switch (type) {
|
|
49
|
-
case 'tooltips': {
|
|
50
|
-
const anchorId = resolveAnchorSelector(item.anchorId);
|
|
51
|
-
const desc = describeSelector(anchorId);
|
|
52
|
-
const content = item.content;
|
|
53
|
-
const body = content?.body || '';
|
|
54
|
-
return `Tooltip on ${desc}: ${truncateQuoted(body, MAX_TEXT_LEN)}`;
|
|
55
|
-
}
|
|
56
|
-
case 'highlights': {
|
|
57
|
-
const anchorId = resolveAnchorSelector(item.anchorId);
|
|
58
|
-
const desc = describeSelector(anchorId);
|
|
59
|
-
return `Highlight ${desc}`;
|
|
60
|
-
}
|
|
61
|
-
case 'badges': {
|
|
62
|
-
const anchorId = resolveAnchorSelector(item.anchorId);
|
|
63
|
-
const desc = describeSelector(anchorId);
|
|
64
|
-
const content = item.content || '';
|
|
65
|
-
return `Badge "${content}" on ${desc}`;
|
|
66
|
-
}
|
|
67
|
-
case 'pulses': {
|
|
68
|
-
const anchorId = resolveAnchorSelector(item.anchorId);
|
|
69
|
-
const desc = describeSelector(anchorId);
|
|
70
|
-
return `Pulse on ${desc}`;
|
|
71
|
-
}
|
|
72
|
-
case 'modals': {
|
|
73
|
-
const content = item.content;
|
|
74
|
-
const label = content?.title || content?.body || '';
|
|
75
|
-
return `Modal: ${truncateQuoted(label, MAX_TEXT_LEN)}`;
|
|
76
|
-
}
|
|
77
|
-
case 'tours': {
|
|
78
|
-
const tourId = item.tourId || 'unknown';
|
|
79
|
-
const steps = item.steps || [];
|
|
80
|
-
const count = steps.length;
|
|
81
|
-
return `Tour: ${tourId} (${count} ${count === 1 ? 'step' : 'steps'})`;
|
|
82
|
-
}
|
|
83
|
-
default:
|
|
84
|
-
return `Unknown overlay`;
|
|
85
|
-
}
|
|
86
|
-
}
|