@syntrologie/adapt-nav 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/NavWidgetLit.d.ts +56 -0
- package/dist/NavWidgetLit.d.ts.map +1 -0
- package/dist/NavWidgetLit.js +495 -0
- package/dist/NavWidgetLit.test.d.ts +8 -0
- package/dist/NavWidgetLit.test.d.ts.map +1 -0
- package/dist/NavWidgetLit.test.js +199 -0
- package/dist/editor-lit.d.ts +49 -0
- package/dist/editor-lit.d.ts.map +1 -0
- package/dist/editor-lit.js +319 -0
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +3 -3
- package/dist/runtime-lit.d.ts +108 -0
- package/dist/runtime-lit.d.ts.map +1 -0
- package/dist/runtime-lit.js +241 -0
- package/dist/runtime.d.ts +15 -3
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +29 -0
- package/dist/schema.d.ts +216 -216
- 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/sdk-contracts/dist/index.d.ts +1 -1
- package/node_modules/@syntrologie/sdk-contracts/dist/index.js +5 -3
- package/node_modules/@syntrologie/sdk-contracts/dist/schemas.d.ts +150 -79
- package/node_modules/@syntrologie/sdk-contracts/dist/schemas.js +266 -67
- 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 +12 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adaptive Nav - Runtime Module (Lit)
|
|
3
|
+
*
|
|
4
|
+
* Runtime manifest for the navigation tips accordion adaptive.
|
|
5
|
+
* Uses the Lit web component mountable instead of the React one.
|
|
6
|
+
* Includes widget-based nav tips and navigation action executors
|
|
7
|
+
* (scrollTo, navigate) previously in adaptive-navigation.
|
|
8
|
+
*/
|
|
9
|
+
import type { ActionExecutor, NavConfig, NavigateAction, NavWidgetRuntime, ScrollToAction } from './types';
|
|
10
|
+
/**
|
|
11
|
+
* Execute a scrollTo action
|
|
12
|
+
*/
|
|
13
|
+
export declare const executeScrollTo: ActionExecutor<ScrollToAction>;
|
|
14
|
+
/**
|
|
15
|
+
* Try to navigate using the host framework's native router.
|
|
16
|
+
* Returns true if a framework router handled the navigation,
|
|
17
|
+
* false if no framework was detected (caller should use pushState or location.href).
|
|
18
|
+
*
|
|
19
|
+
* Using the native router preserves SPA behavior (no full reload),
|
|
20
|
+
* layout state, scroll position, and framework-specific features
|
|
21
|
+
* (RSC streaming, view transitions, etc.).
|
|
22
|
+
*/
|
|
23
|
+
export declare function navigateWithFrameworkRouter(url: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Execute a navigate action
|
|
26
|
+
*/
|
|
27
|
+
export declare const executeNavigate: ActionExecutor<NavigateAction>;
|
|
28
|
+
/**
|
|
29
|
+
* NavWidgetLitMountable — Mounts the `<syntro-nav-tips>` Lit web component.
|
|
30
|
+
*
|
|
31
|
+
* Drop-in companion to NavMountableWidget that avoids React/ReactDOM entirely.
|
|
32
|
+
* Self-registers the custom element on first use.
|
|
33
|
+
*/
|
|
34
|
+
export declare const NavWidgetLitMountable: {
|
|
35
|
+
mount(container: HTMLElement, config?: NavConfig & {
|
|
36
|
+
runtime?: NavWidgetRuntime;
|
|
37
|
+
instanceId?: string;
|
|
38
|
+
}): () => void;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* All executors provided by this app.
|
|
42
|
+
* These are registered with the runtime's ExecutorRegistry.
|
|
43
|
+
*/
|
|
44
|
+
export declare const executors: readonly [{
|
|
45
|
+
readonly kind: "navigation:scrollTo";
|
|
46
|
+
readonly executor: ActionExecutor<ScrollToAction>;
|
|
47
|
+
}, {
|
|
48
|
+
readonly kind: "navigation:navigate";
|
|
49
|
+
readonly executor: ActionExecutor<NavigateAction>;
|
|
50
|
+
}];
|
|
51
|
+
/**
|
|
52
|
+
* Runtime manifest for adaptive-nav (Lit variant).
|
|
53
|
+
*
|
|
54
|
+
* Provides:
|
|
55
|
+
* - Navigation action executors (scrollTo, navigate)
|
|
56
|
+
* - Widget-based nav tips accordion using the Lit web component
|
|
57
|
+
*/
|
|
58
|
+
export declare const runtime: {
|
|
59
|
+
id: string;
|
|
60
|
+
version: string;
|
|
61
|
+
name: string;
|
|
62
|
+
description: string;
|
|
63
|
+
/**
|
|
64
|
+
* Navigation action executors (scrollTo, navigate).
|
|
65
|
+
*/
|
|
66
|
+
executors: readonly [{
|
|
67
|
+
readonly kind: "navigation:scrollTo";
|
|
68
|
+
readonly executor: ActionExecutor<ScrollToAction>;
|
|
69
|
+
}, {
|
|
70
|
+
readonly kind: "navigation:navigate";
|
|
71
|
+
readonly executor: ActionExecutor<NavigateAction>;
|
|
72
|
+
}];
|
|
73
|
+
/**
|
|
74
|
+
* Widget definitions for the runtime's WidgetRegistry.
|
|
75
|
+
*/
|
|
76
|
+
widgets: {
|
|
77
|
+
id: string;
|
|
78
|
+
component: {
|
|
79
|
+
mount(container: HTMLElement, config?: NavConfig & {
|
|
80
|
+
runtime?: NavWidgetRuntime;
|
|
81
|
+
instanceId?: string;
|
|
82
|
+
}): () => void;
|
|
83
|
+
};
|
|
84
|
+
metadata: {
|
|
85
|
+
name: string;
|
|
86
|
+
description: string;
|
|
87
|
+
icon: string;
|
|
88
|
+
};
|
|
89
|
+
}[];
|
|
90
|
+
/**
|
|
91
|
+
* Extract notify watcher entries from tile config props.
|
|
92
|
+
* The runtime evaluates these continuously (even with drawer closed)
|
|
93
|
+
* and publishes nav:tip_revealed when triggerWhen transitions false → true.
|
|
94
|
+
*/
|
|
95
|
+
notifyWatchers(props: Record<string, unknown>): {
|
|
96
|
+
id: string;
|
|
97
|
+
strategy: import("./types").DecisionStrategy<boolean>;
|
|
98
|
+
eventName: string;
|
|
99
|
+
eventProps: {
|
|
100
|
+
tipId: string;
|
|
101
|
+
title: string | undefined;
|
|
102
|
+
body: string | undefined;
|
|
103
|
+
icon: string | undefined;
|
|
104
|
+
};
|
|
105
|
+
}[];
|
|
106
|
+
};
|
|
107
|
+
export default runtime;
|
|
108
|
+
//# 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;;;;;;;GAOG;AAGH,OAAO,KAAK,EACV,cAAc,EAEd,SAAS,EACT,cAAc,EAEd,gBAAgB,EAChB,cAAc,EACf,MAAM,SAAS,CAAC;AAMjB;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,cAAc,CA+B1D,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAgDhE;AAgBD;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,cAAc,CAuC1D,CAAC;AAMF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;qBAEnB,WAAW,WACb,SAAS,GAAG;QAAE,OAAO,CAAC,EAAE,gBAAgB,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;CA2B3E,CAAC;AAMF;;;GAGG;AACH,eAAO,MAAM,SAAS;;;;;;EAGZ,CAAC;AAMX;;;;;;GAMG;AACH,eAAO,MAAM,OAAO;;;;;IAMlB;;OAEG;;;;;;;;IAGH;;OAEG;;;;6BAnEU,WAAW,WACb,SAAS,GAAG;gBAAE,OAAO,CAAC,EAAE,gBAAgB,CAAC;gBAAC,UAAU,CAAC,EAAE,MAAM,CAAA;aAAE;;;;;;;;IA+E1E;;;;OAIG;0BACmB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;CAgB9C,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adaptive Nav - Runtime Module (Lit)
|
|
3
|
+
*
|
|
4
|
+
* Runtime manifest for the navigation tips accordion adaptive.
|
|
5
|
+
* Uses the Lit web component mountable instead of the React one.
|
|
6
|
+
* Includes widget-based nav tips and navigation action executors
|
|
7
|
+
* (scrollTo, navigate) previously in adaptive-navigation.
|
|
8
|
+
*/
|
|
9
|
+
import { registerNavWidgetLit } from './NavWidgetLit';
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Navigation Action Executors (merged from adaptive-navigation)
|
|
12
|
+
// ============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Execute a scrollTo action
|
|
15
|
+
*/
|
|
16
|
+
export const executeScrollTo = async (action, context) => {
|
|
17
|
+
const anchorEl = context.resolveAnchor(action.anchorId);
|
|
18
|
+
if (!anchorEl) {
|
|
19
|
+
console.error(`[adaptive-nav] Anchor not found for scrollTo, skipping: ${action.anchorId.selector}`);
|
|
20
|
+
return { cleanup: () => { } };
|
|
21
|
+
}
|
|
22
|
+
// Scroll to element
|
|
23
|
+
anchorEl.scrollIntoView({
|
|
24
|
+
behavior: action.behavior ?? 'smooth',
|
|
25
|
+
block: action.block ?? 'center',
|
|
26
|
+
inline: action.inline ?? 'nearest',
|
|
27
|
+
});
|
|
28
|
+
context.publishEvent('action.applied', {
|
|
29
|
+
id: context.generateId(),
|
|
30
|
+
kind: 'navigation:scrollTo',
|
|
31
|
+
anchorId: action.anchorId,
|
|
32
|
+
behavior: action.behavior ?? 'smooth',
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
cleanup: () => {
|
|
36
|
+
// Optionally restore scroll position on revert
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Try to navigate using the host framework's native router.
|
|
42
|
+
* Returns true if a framework router handled the navigation,
|
|
43
|
+
* false if no framework was detected (caller should use pushState or location.href).
|
|
44
|
+
*
|
|
45
|
+
* Using the native router preserves SPA behavior (no full reload),
|
|
46
|
+
* layout state, scroll position, and framework-specific features
|
|
47
|
+
* (RSC streaming, view transitions, etc.).
|
|
48
|
+
*/
|
|
49
|
+
export function navigateWithFrameworkRouter(url) {
|
|
50
|
+
if (typeof window === 'undefined')
|
|
51
|
+
return false;
|
|
52
|
+
const w = window;
|
|
53
|
+
// Next.js — window.next.router.push() triggers App Router navigation
|
|
54
|
+
// with RSC fetch, layout preservation, and loading states
|
|
55
|
+
try {
|
|
56
|
+
const nextRouter = w.next?.router;
|
|
57
|
+
if (nextRouter?.push) {
|
|
58
|
+
nextRouter.push(url);
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
/* fall through */
|
|
64
|
+
}
|
|
65
|
+
// Nuxt 3 — useRouter() isn't accessible from outside Vue, but
|
|
66
|
+
// $nuxt.$router (Nuxt 2) or window.__NUXT__?.hooks (Nuxt 3) + navigateTo
|
|
67
|
+
// aren't reliably exposed. Nuxt 2 exposes $nuxt.$router.push().
|
|
68
|
+
try {
|
|
69
|
+
if (w.$nuxt?.$router?.push) {
|
|
70
|
+
w.$nuxt.$router.push(url);
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
/* fall through */
|
|
76
|
+
}
|
|
77
|
+
// Angular — Angular Router isn't exposed on window by default.
|
|
78
|
+
// The most reliable approach is to detect Angular and use location.href.
|
|
79
|
+
if (w.ng || w.getAllAngularRootElements || document.querySelector('[ng-version]')) {
|
|
80
|
+
window.location.href = url;
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
// SvelteKit — goto() isn't on window, but __SVELTEKIT_DATA__ confirms the framework.
|
|
84
|
+
if (w.__SVELTEKIT_DATA__ || document.body?.hasAttribute('data-sveltekit')) {
|
|
85
|
+
window.location.href = url;
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
// Astro (View Transitions) — no client-side router API exposed
|
|
89
|
+
if (document.querySelector('[data-astro-transition-fallback]')) {
|
|
90
|
+
window.location.href = url;
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Check if a URL is same-origin as the current page.
|
|
97
|
+
* Relative URLs (e.g. "/dashboard") are always same-origin.
|
|
98
|
+
*/
|
|
99
|
+
function isSameOrigin(url) {
|
|
100
|
+
try {
|
|
101
|
+
const parsed = new URL(url, window.location.origin);
|
|
102
|
+
return parsed.origin === window.location.origin;
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
// If URL parsing fails, fall back to full navigation
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Execute a navigate action
|
|
111
|
+
*/
|
|
112
|
+
export const executeNavigate = async (action, context) => {
|
|
113
|
+
// Validate URL to prevent javascript: URLs
|
|
114
|
+
const url = action.url.trim();
|
|
115
|
+
if (url.toLowerCase().startsWith('javascript:')) {
|
|
116
|
+
throw new Error('javascript: URLs are not allowed');
|
|
117
|
+
}
|
|
118
|
+
const target = action.target ?? '_self';
|
|
119
|
+
context.publishEvent('action.applied', {
|
|
120
|
+
id: context.generateId(),
|
|
121
|
+
kind: 'navigation:navigate',
|
|
122
|
+
url: action.url,
|
|
123
|
+
target,
|
|
124
|
+
});
|
|
125
|
+
if (target === '_blank') {
|
|
126
|
+
// Open in new tab
|
|
127
|
+
window.open(url, '_blank', 'noopener,noreferrer');
|
|
128
|
+
}
|
|
129
|
+
else if (!action.forceFullNavigation && isSameOrigin(url)) {
|
|
130
|
+
// Try the host framework's native router first (Next.js, Nuxt, Angular, etc.)
|
|
131
|
+
// Falls back to pushState for vanilla SPAs, or location.href as last resort.
|
|
132
|
+
if (!navigateWithFrameworkRouter(url)) {
|
|
133
|
+
window.history.pushState(null, '', url);
|
|
134
|
+
window.dispatchEvent(new PopStateEvent('popstate'));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
// Full navigation for cross-origin URLs or when explicitly requested
|
|
139
|
+
window.location.href = url;
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
cleanup: () => {
|
|
143
|
+
// Navigation cannot be reverted
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
// ============================================================================
|
|
148
|
+
// Lit Mountable Widget
|
|
149
|
+
// ============================================================================
|
|
150
|
+
/**
|
|
151
|
+
* NavWidgetLitMountable — Mounts the `<syntro-nav-tips>` Lit web component.
|
|
152
|
+
*
|
|
153
|
+
* Drop-in companion to NavMountableWidget that avoids React/ReactDOM entirely.
|
|
154
|
+
* Self-registers the custom element on first use.
|
|
155
|
+
*/
|
|
156
|
+
export const NavWidgetLitMountable = {
|
|
157
|
+
mount(container, config) {
|
|
158
|
+
registerNavWidgetLit();
|
|
159
|
+
const el = document.createElement('syntro-nav-tips');
|
|
160
|
+
const { runtime, instanceId = 'nav-widget', ...navConfig } = config ?? {
|
|
161
|
+
expandBehavior: 'single',
|
|
162
|
+
theme: 'auto',
|
|
163
|
+
actions: [],
|
|
164
|
+
};
|
|
165
|
+
// Assign structured props as JS properties (not HTML attributes)
|
|
166
|
+
Object.assign(el, {
|
|
167
|
+
config: navConfig,
|
|
168
|
+
runtime,
|
|
169
|
+
instanceId,
|
|
170
|
+
});
|
|
171
|
+
container.appendChild(el);
|
|
172
|
+
return () => el.remove();
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
// ============================================================================
|
|
176
|
+
// Executor Definitions for Registration
|
|
177
|
+
// ============================================================================
|
|
178
|
+
/**
|
|
179
|
+
* All executors provided by this app.
|
|
180
|
+
* These are registered with the runtime's ExecutorRegistry.
|
|
181
|
+
*/
|
|
182
|
+
export const executors = [
|
|
183
|
+
{ kind: 'navigation:scrollTo', executor: executeScrollTo },
|
|
184
|
+
{ kind: 'navigation:navigate', executor: executeNavigate },
|
|
185
|
+
];
|
|
186
|
+
// ============================================================================
|
|
187
|
+
// App Runtime Manifest
|
|
188
|
+
// ============================================================================
|
|
189
|
+
/**
|
|
190
|
+
* Runtime manifest for adaptive-nav (Lit variant).
|
|
191
|
+
*
|
|
192
|
+
* Provides:
|
|
193
|
+
* - Navigation action executors (scrollTo, navigate)
|
|
194
|
+
* - Widget-based nav tips accordion using the Lit web component
|
|
195
|
+
*/
|
|
196
|
+
export const runtime = {
|
|
197
|
+
id: 'adaptive-nav',
|
|
198
|
+
version: '2.0.0',
|
|
199
|
+
name: 'Navigation Tips',
|
|
200
|
+
description: 'Navigation actions and accordion-based tips with per-item conditional visibility',
|
|
201
|
+
/**
|
|
202
|
+
* Navigation action executors (scrollTo, navigate).
|
|
203
|
+
*/
|
|
204
|
+
executors,
|
|
205
|
+
/**
|
|
206
|
+
* Widget definitions for the runtime's WidgetRegistry.
|
|
207
|
+
*/
|
|
208
|
+
widgets: [
|
|
209
|
+
{
|
|
210
|
+
id: 'adaptive-nav:tips',
|
|
211
|
+
component: NavWidgetLitMountable,
|
|
212
|
+
metadata: {
|
|
213
|
+
name: 'Navigation Tips',
|
|
214
|
+
description: 'Accordion of contextual navigation tips with per-item visibility',
|
|
215
|
+
icon: '\u{1F9ED}',
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
],
|
|
219
|
+
/**
|
|
220
|
+
* Extract notify watcher entries from tile config props.
|
|
221
|
+
* The runtime evaluates these continuously (even with drawer closed)
|
|
222
|
+
* and publishes nav:tip_revealed when triggerWhen transitions false → true.
|
|
223
|
+
*/
|
|
224
|
+
notifyWatchers(props) {
|
|
225
|
+
const actions = (props.actions ?? []);
|
|
226
|
+
return actions
|
|
227
|
+
.filter((a) => a.notify && a.triggerWhen)
|
|
228
|
+
.map((a) => ({
|
|
229
|
+
id: `nav:${a.config.id}`,
|
|
230
|
+
strategy: a.triggerWhen,
|
|
231
|
+
eventName: 'nav:tip_revealed',
|
|
232
|
+
eventProps: {
|
|
233
|
+
tipId: a.config.id,
|
|
234
|
+
title: a.notify.title,
|
|
235
|
+
body: a.notify.body,
|
|
236
|
+
icon: a.notify.icon,
|
|
237
|
+
},
|
|
238
|
+
}));
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
export default runtime;
|
package/dist/runtime.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Includes widget-based nav tips and navigation action executors
|
|
6
6
|
* (scrollTo, navigate) previously in adaptive-navigation.
|
|
7
7
|
*/
|
|
8
|
-
import type { ActionExecutor, NavigateAction, ScrollToAction } from './types';
|
|
8
|
+
import type { ActionExecutor, NavConfig, NavigateAction, NavWidgetRuntime, ScrollToAction } from './types';
|
|
9
9
|
/**
|
|
10
10
|
* Execute a scrollTo action
|
|
11
11
|
*/
|
|
@@ -24,6 +24,18 @@ export declare function navigateWithFrameworkRouter(url: string): boolean;
|
|
|
24
24
|
* Execute a navigate action
|
|
25
25
|
*/
|
|
26
26
|
export declare const executeNavigate: ActionExecutor<NavigateAction>;
|
|
27
|
+
/**
|
|
28
|
+
* NavWidgetLitMountable — Mounts the `<syntro-nav-tips>` Lit web component.
|
|
29
|
+
*
|
|
30
|
+
* Drop-in companion to NavMountableWidget that avoids React/ReactDOM entirely.
|
|
31
|
+
* Self-registers the custom element on first use.
|
|
32
|
+
*/
|
|
33
|
+
export declare const NavWidgetLitMountable: {
|
|
34
|
+
mount(container: HTMLElement, config?: NavConfig & {
|
|
35
|
+
runtime?: NavWidgetRuntime;
|
|
36
|
+
instanceId?: string;
|
|
37
|
+
}): () => void;
|
|
38
|
+
};
|
|
27
39
|
/**
|
|
28
40
|
* All executors provided by this app.
|
|
29
41
|
* These are registered with the runtime's ExecutorRegistry.
|
|
@@ -63,8 +75,8 @@ export declare const runtime: {
|
|
|
63
75
|
widgets: {
|
|
64
76
|
id: string;
|
|
65
77
|
component: {
|
|
66
|
-
mount(container: HTMLElement, config?:
|
|
67
|
-
runtime?:
|
|
78
|
+
mount(container: HTMLElement, config?: NavConfig & {
|
|
79
|
+
runtime?: NavWidgetRuntime;
|
|
68
80
|
instanceId?: string;
|
|
69
81
|
}): (() => void) | undefined;
|
|
70
82
|
};
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EACV,cAAc,EAEd,SAAS,EACT,cAAc,EAEd,gBAAgB,EAChB,cAAc,EACf,MAAM,SAAS,CAAC;AAMjB;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,cAAc,CA+B1D,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,2BAA2B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAgDhE;AAgBD;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,cAAc,CAuC1D,CAAC;AAMF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB;qBAEnB,WAAW,WACb,SAAS,GAAG;QAAE,OAAO,CAAC,EAAE,gBAAgB,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;CA2B3E,CAAC;AAMF;;;GAGG;AACH,eAAO,MAAM,SAAS;;;;;;EAGZ,CAAC;AAMX;;;;;;GAMG;AACH,eAAO,MAAM,OAAO;;;;;IAMlB;;OAEG;;;;;;;;IAGH;;OAEG;;;;;uBAqC68Y,CAAC;0BAA8B,CAAC;;;;;;;;;IAxBh/Y;;;;OAIG;0BACmB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;;;;;CAgB9C,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
package/dist/runtime.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* (scrollTo, navigate) previously in adaptive-navigation.
|
|
7
7
|
*/
|
|
8
8
|
import { NavMountableWidget } from './NavWidget';
|
|
9
|
+
import { registerNavWidgetLit } from './NavWidgetLit';
|
|
9
10
|
// ============================================================================
|
|
10
11
|
// Navigation Action Executors (merged from adaptive-navigation)
|
|
11
12
|
// ============================================================================
|
|
@@ -144,6 +145,34 @@ export const executeNavigate = async (action, context) => {
|
|
|
144
145
|
};
|
|
145
146
|
};
|
|
146
147
|
// ============================================================================
|
|
148
|
+
// Lit Mountable Widget
|
|
149
|
+
// ============================================================================
|
|
150
|
+
/**
|
|
151
|
+
* NavWidgetLitMountable — Mounts the `<syntro-nav-tips>` Lit web component.
|
|
152
|
+
*
|
|
153
|
+
* Drop-in companion to NavMountableWidget that avoids React/ReactDOM entirely.
|
|
154
|
+
* Self-registers the custom element on first use.
|
|
155
|
+
*/
|
|
156
|
+
export const NavWidgetLitMountable = {
|
|
157
|
+
mount(container, config) {
|
|
158
|
+
registerNavWidgetLit();
|
|
159
|
+
const el = document.createElement('syntro-nav-tips');
|
|
160
|
+
const { runtime, instanceId = 'nav-widget', ...navConfig } = config ?? {
|
|
161
|
+
expandBehavior: 'single',
|
|
162
|
+
theme: 'auto',
|
|
163
|
+
actions: [],
|
|
164
|
+
};
|
|
165
|
+
// Assign structured props as JS properties (not HTML attributes)
|
|
166
|
+
Object.assign(el, {
|
|
167
|
+
config: navConfig,
|
|
168
|
+
runtime,
|
|
169
|
+
instanceId,
|
|
170
|
+
});
|
|
171
|
+
container.appendChild(el);
|
|
172
|
+
return () => el.remove();
|
|
173
|
+
},
|
|
174
|
+
};
|
|
175
|
+
// ============================================================================
|
|
147
176
|
// Executor Definitions for Registration
|
|
148
177
|
// ============================================================================
|
|
149
178
|
/**
|