@syntrologie/adapt-nav 0.0.0-semantically-released
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/NavWidget.d.ts +31 -0
- package/dist/NavWidget.d.ts.map +1 -0
- package/dist/NavWidget.js +193 -0
- package/dist/cdn.d.ts +38 -0
- package/dist/cdn.d.ts.map +1 -0
- package/dist/cdn.js +36 -0
- package/dist/editor.d.ts +17 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/editor.js +252 -0
- package/dist/runtime.d.ts +43 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +43 -0
- package/dist/schema.d.ts +647 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +101 -0
- package/dist/types.d.ts +121 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/package.json +49 -0
package/dist/schema.js
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adaptive Nav - Config Schema
|
|
3
|
+
*
|
|
4
|
+
* Zod schema for validating navigation link list configuration.
|
|
5
|
+
* Demonstrates compositional action pattern with per-item showWhen.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Decision Strategy Schema (simplified for this package)
|
|
10
|
+
// ============================================================================
|
|
11
|
+
const ConditionZ = z
|
|
12
|
+
.object({
|
|
13
|
+
type: z.string(),
|
|
14
|
+
})
|
|
15
|
+
.passthrough();
|
|
16
|
+
const RuleZ = z.object({
|
|
17
|
+
conditions: z.array(ConditionZ),
|
|
18
|
+
value: z.unknown(),
|
|
19
|
+
});
|
|
20
|
+
const RuleStrategyZ = z.object({
|
|
21
|
+
type: z.literal('rules'),
|
|
22
|
+
rules: z.array(RuleZ),
|
|
23
|
+
default: z.unknown(),
|
|
24
|
+
});
|
|
25
|
+
const ScoreStrategyZ = z.object({
|
|
26
|
+
type: z.literal('score'),
|
|
27
|
+
field: z.string(),
|
|
28
|
+
threshold: z.number(),
|
|
29
|
+
above: z.unknown(),
|
|
30
|
+
below: z.unknown(),
|
|
31
|
+
});
|
|
32
|
+
const ModelStrategyZ = z.object({
|
|
33
|
+
type: z.literal('model'),
|
|
34
|
+
modelId: z.string(),
|
|
35
|
+
inputs: z.array(z.string()),
|
|
36
|
+
outputMapping: z.record(z.unknown()),
|
|
37
|
+
default: z.unknown(),
|
|
38
|
+
});
|
|
39
|
+
const ExternalStrategyZ = z.object({
|
|
40
|
+
type: z.literal('external'),
|
|
41
|
+
endpoint: z.string(),
|
|
42
|
+
method: z.enum(['GET', 'POST']).optional(),
|
|
43
|
+
default: z.unknown(),
|
|
44
|
+
timeoutMs: z.number().optional(),
|
|
45
|
+
});
|
|
46
|
+
const DecisionStrategyZ = z.discriminatedUnion('type', [
|
|
47
|
+
RuleStrategyZ,
|
|
48
|
+
ScoreStrategyZ,
|
|
49
|
+
ModelStrategyZ,
|
|
50
|
+
ExternalStrategyZ,
|
|
51
|
+
]);
|
|
52
|
+
// ============================================================================
|
|
53
|
+
// Nav Link Schema
|
|
54
|
+
// ============================================================================
|
|
55
|
+
/**
|
|
56
|
+
* Schema for a single navigation link (compositional action).
|
|
57
|
+
*/
|
|
58
|
+
export const NavLinkSchema = z.object({
|
|
59
|
+
kind: z.literal('nav:link'),
|
|
60
|
+
config: z.object({
|
|
61
|
+
/** Display label for the link */
|
|
62
|
+
label: z.string().min(1, 'Label is required'),
|
|
63
|
+
/** Target URL */
|
|
64
|
+
href: z.string().min(1, 'URL is required'),
|
|
65
|
+
/** Optional icon (emoji or icon key) */
|
|
66
|
+
icon: z.string().optional(),
|
|
67
|
+
/** Whether to open in new tab */
|
|
68
|
+
external: z.boolean().default(false),
|
|
69
|
+
}),
|
|
70
|
+
/** Per-item activation strategy (null = always show) */
|
|
71
|
+
showWhen: DecisionStrategyZ.nullable().optional(),
|
|
72
|
+
});
|
|
73
|
+
// ============================================================================
|
|
74
|
+
// Nav Config Schema
|
|
75
|
+
// ============================================================================
|
|
76
|
+
/**
|
|
77
|
+
* Full configuration schema for adaptive-nav.
|
|
78
|
+
*/
|
|
79
|
+
export const configSchema = z.object({
|
|
80
|
+
/** Layout orientation */
|
|
81
|
+
layout: z.enum(['horizontal', 'vertical']).default('horizontal'),
|
|
82
|
+
/** Color theme */
|
|
83
|
+
theme: z.enum(['light', 'dark', 'auto']).default('auto'),
|
|
84
|
+
/** Navigation links (compositional actions) */
|
|
85
|
+
actions: z.array(NavLinkSchema).default([]),
|
|
86
|
+
});
|
|
87
|
+
// ============================================================================
|
|
88
|
+
// Validation Helpers
|
|
89
|
+
// ============================================================================
|
|
90
|
+
/**
|
|
91
|
+
* Validate a nav link action.
|
|
92
|
+
*/
|
|
93
|
+
export function validateNavLink(data) {
|
|
94
|
+
return NavLinkSchema.safeParse(data);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Validate the full nav config.
|
|
98
|
+
*/
|
|
99
|
+
export function validateNavConfig(data) {
|
|
100
|
+
return configSchema.safeParse(data);
|
|
101
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adaptive Nav - Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for the navigation link list adaptive.
|
|
5
|
+
* Demonstrates compositional action pattern with per-item showWhen.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Simplified DecisionStrategy type for this package.
|
|
9
|
+
* Full definition is in @syntrologie/runtime-sdk.
|
|
10
|
+
*/
|
|
11
|
+
export type DecisionStrategy<T = unknown> = RuleStrategy<T> | ScoreStrategy<T> | ModelStrategy<T> | ExternalStrategy<T>;
|
|
12
|
+
export interface RuleStrategy<T = unknown> {
|
|
13
|
+
type: 'rules';
|
|
14
|
+
rules: Array<{
|
|
15
|
+
conditions: Array<Record<string, unknown>>;
|
|
16
|
+
value: T;
|
|
17
|
+
}>;
|
|
18
|
+
default: T;
|
|
19
|
+
}
|
|
20
|
+
export interface ScoreStrategy<T = unknown> {
|
|
21
|
+
type: 'score';
|
|
22
|
+
field: string;
|
|
23
|
+
threshold: number;
|
|
24
|
+
above: T;
|
|
25
|
+
below: T;
|
|
26
|
+
}
|
|
27
|
+
export interface ModelStrategy<T = unknown> {
|
|
28
|
+
type: 'model';
|
|
29
|
+
modelId: string;
|
|
30
|
+
inputs: string[];
|
|
31
|
+
outputMapping: Record<string, T>;
|
|
32
|
+
default: T;
|
|
33
|
+
}
|
|
34
|
+
export interface ExternalStrategy<T = unknown> {
|
|
35
|
+
type: 'external';
|
|
36
|
+
endpoint: string;
|
|
37
|
+
method?: 'GET' | 'POST';
|
|
38
|
+
default: T;
|
|
39
|
+
timeoutMs?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Single navigation link configuration.
|
|
43
|
+
* This is a "compositional action" - it's not executed, but rendered by the parent.
|
|
44
|
+
*/
|
|
45
|
+
export interface NavLinkAction {
|
|
46
|
+
/** Action kind identifier */
|
|
47
|
+
kind: 'nav:link';
|
|
48
|
+
/** Link configuration */
|
|
49
|
+
config: {
|
|
50
|
+
/** Display label for the link */
|
|
51
|
+
label: string;
|
|
52
|
+
/** Target URL */
|
|
53
|
+
href: string;
|
|
54
|
+
/** Optional icon (emoji or icon key) */
|
|
55
|
+
icon?: string;
|
|
56
|
+
/** Whether to open in new tab */
|
|
57
|
+
external?: boolean;
|
|
58
|
+
};
|
|
59
|
+
/** Optional per-item activation strategy */
|
|
60
|
+
showWhen?: DecisionStrategy<boolean> | null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Layout orientation for the navigation links.
|
|
64
|
+
*/
|
|
65
|
+
export type NavLayout = 'horizontal' | 'vertical';
|
|
66
|
+
/**
|
|
67
|
+
* Theme for the navigation widget.
|
|
68
|
+
*/
|
|
69
|
+
export type NavTheme = 'light' | 'dark' | 'auto';
|
|
70
|
+
/**
|
|
71
|
+
* Full configuration for the adaptive-nav widget.
|
|
72
|
+
*/
|
|
73
|
+
export interface NavConfig {
|
|
74
|
+
/** Layout orientation */
|
|
75
|
+
layout: NavLayout;
|
|
76
|
+
/** Color theme */
|
|
77
|
+
theme: NavTheme;
|
|
78
|
+
/** Navigation links (compositional actions) */
|
|
79
|
+
actions: NavLinkAction[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Runtime services passed to the widget.
|
|
83
|
+
*/
|
|
84
|
+
export interface NavWidgetRuntime {
|
|
85
|
+
/** Synchronously evaluate a decision strategy */
|
|
86
|
+
evaluateSync: <T>(strategy: DecisionStrategy<T>) => {
|
|
87
|
+
value: T;
|
|
88
|
+
isFallback: boolean;
|
|
89
|
+
};
|
|
90
|
+
/** Context manager for subscribing to changes */
|
|
91
|
+
context: {
|
|
92
|
+
subscribe: (callback: () => void) => () => void;
|
|
93
|
+
};
|
|
94
|
+
/** Event bus for publishing interactions */
|
|
95
|
+
events: {
|
|
96
|
+
publish: (name: string, props?: Record<string, unknown>) => void;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Props passed to the NavWidget component.
|
|
101
|
+
*/
|
|
102
|
+
export interface NavWidgetProps {
|
|
103
|
+
/** Widget configuration */
|
|
104
|
+
config: NavConfig;
|
|
105
|
+
/** Runtime services */
|
|
106
|
+
runtime: NavWidgetRuntime;
|
|
107
|
+
/** Instance ID for telemetry */
|
|
108
|
+
instanceId: string;
|
|
109
|
+
}
|
|
110
|
+
export interface EditorPanelProps {
|
|
111
|
+
config: Record<string, unknown>;
|
|
112
|
+
onChange: (config: Record<string, unknown>) => void;
|
|
113
|
+
editor: {
|
|
114
|
+
setDirty: (dirty: boolean) => void;
|
|
115
|
+
navigateHome: () => Promise<boolean>;
|
|
116
|
+
save: () => Promise<void>;
|
|
117
|
+
publish: (captureScreenshot?: boolean) => Promise<void>;
|
|
118
|
+
};
|
|
119
|
+
platformClient?: unknown;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMapp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CAAC;KAClE,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,2BAA2B;IAC3B,MAAM,EAAE,SAAS,CAAC;IAClB,uBAAuB;IACvB,OAAO,EAAE,gBAAgB,CAAC;IAC1B,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC;CACpB;AAMD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACpD,MAAM,EAAE;QACN,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;QACnC,YAAY,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;QACrC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1B,OAAO,EAAE,CAAC,iBAAiB,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;KACzD,CAAC;IACF,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B"}
|
package/dist/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@syntrologie/adapt-nav",
|
|
3
|
+
"version": "0.0.0-semantically-released",
|
|
4
|
+
"description": "Adaptive Navigation Links - Widget-based nav list with per-item conditional visibility",
|
|
5
|
+
"license": "Proprietary",
|
|
6
|
+
"private": false,
|
|
7
|
+
"author": "Syntrologie <eng@syntrologie.com>",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/SyntropyForge/amazing-demos.git",
|
|
11
|
+
"directory": "tech-core/sdks/adaptives/adaptive-nav"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"exports": {
|
|
18
|
+
"./runtime": {
|
|
19
|
+
"types": "./dist/runtime.d.ts",
|
|
20
|
+
"import": "./dist/runtime.js"
|
|
21
|
+
},
|
|
22
|
+
"./schema": {
|
|
23
|
+
"types": "./dist/schema.d.ts",
|
|
24
|
+
"import": "./dist/schema.js"
|
|
25
|
+
},
|
|
26
|
+
"./editor": {
|
|
27
|
+
"types": "./dist/editor.d.ts",
|
|
28
|
+
"import": "./dist/editor.js"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc",
|
|
36
|
+
"clean": "rm -rf dist"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"@syntrologie/runtime-sdk": "^2.0.0",
|
|
40
|
+
"react": ">=18.0.0",
|
|
41
|
+
"react-dom": ">=18.0.0",
|
|
42
|
+
"zod": "^3.0.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/react": "^18.0.0",
|
|
46
|
+
"typescript": "^5.0.0",
|
|
47
|
+
"zod": "^3.25.0"
|
|
48
|
+
}
|
|
49
|
+
}
|