@allternit/ix 0.1.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/README.md +320 -0
- package/dist/adapters/json-render.d.ts +211 -0
- package/dist/adapters/json-render.d.ts.bak +211 -0
- package/dist/adapters/json-render.d.ts.map +1 -0
- package/dist/adapters/json-render.js +576 -0
- package/dist/adapters/json-render.js.bak +576 -0
- package/dist/adapters/json-render.js.map +1 -0
- package/dist/catalog/registry.d.ts +65 -0
- package/dist/catalog/registry.d.ts.bak +65 -0
- package/dist/catalog/registry.d.ts.map +1 -0
- package/dist/catalog/registry.js +388 -0
- package/dist/catalog/registry.js.bak +388 -0
- package/dist/catalog/registry.js.map +1 -0
- package/dist/collab/capsule-registry.d.ts +114 -0
- package/dist/collab/capsule-registry.d.ts.bak +114 -0
- package/dist/collab/capsule-registry.d.ts.map +1 -0
- package/dist/collab/capsule-registry.js +271 -0
- package/dist/collab/capsule-registry.js.bak +271 -0
- package/dist/collab/capsule-registry.js.map +1 -0
- package/dist/collab/index.d.ts +21 -0
- package/dist/collab/index.d.ts.bak +21 -0
- package/dist/collab/index.d.ts.map +1 -0
- package/dist/collab/index.js +32 -0
- package/dist/collab/index.js.bak +32 -0
- package/dist/collab/index.js.map +1 -0
- package/dist/collab/visual-editor.d.ts +199 -0
- package/dist/collab/visual-editor.d.ts.bak +199 -0
- package/dist/collab/visual-editor.d.ts.map +1 -0
- package/dist/collab/visual-editor.js +259 -0
- package/dist/collab/visual-editor.js.bak +259 -0
- package/dist/collab/visual-editor.js.map +1 -0
- package/dist/collab/yjs-adapter.d.ts +95 -0
- package/dist/collab/yjs-adapter.d.ts.bak +95 -0
- package/dist/collab/yjs-adapter.d.ts.map +1 -0
- package/dist/collab/yjs-adapter.js +282 -0
- package/dist/collab/yjs-adapter.js.bak +282 -0
- package/dist/collab/yjs-adapter.js.map +1 -0
- package/dist/collab/yjs-client.d.ts +101 -0
- package/dist/collab/yjs-client.d.ts.bak +101 -0
- package/dist/collab/yjs-client.d.ts.map +1 -0
- package/dist/collab/yjs-client.js +193 -0
- package/dist/collab/yjs-client.js.bak +193 -0
- package/dist/collab/yjs-client.js.map +1 -0
- package/dist/collab/yjs-protocols.d.ts +128 -0
- package/dist/collab/yjs-protocols.d.ts.bak +128 -0
- package/dist/collab/yjs-protocols.d.ts.map +1 -0
- package/dist/collab/yjs-protocols.js +245 -0
- package/dist/collab/yjs-protocols.js.bak +245 -0
- package/dist/collab/yjs-protocols.js.map +1 -0
- package/dist/collab/yjs-types.d.ts +201 -0
- package/dist/collab/yjs-types.d.ts.bak +201 -0
- package/dist/collab/yjs-types.d.ts.map +1 -0
- package/dist/collab/yjs-types.js +45 -0
- package/dist/collab/yjs-types.js.bak +45 -0
- package/dist/collab/yjs-types.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.bak +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +48 -0
- package/dist/index.js.bak +48 -0
- package/dist/index.js.map +1 -0
- package/dist/pipeline/llm-to-ix.d.ts +249 -0
- package/dist/pipeline/llm-to-ix.d.ts.bak +249 -0
- package/dist/pipeline/llm-to-ix.d.ts.map +1 -0
- package/dist/pipeline/llm-to-ix.js +992 -0
- package/dist/pipeline/llm-to-ix.js.bak +992 -0
- package/dist/pipeline/llm-to-ix.js.map +1 -0
- package/dist/react/index.d.ts +18 -0
- package/dist/react/index.d.ts.bak +18 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +18 -0
- package/dist/react/index.js.bak +18 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/renderer.d.ts +47 -0
- package/dist/react/renderer.d.ts.bak +47 -0
- package/dist/react/renderer.d.ts.map +1 -0
- package/dist/react/renderer.js +420 -0
- package/dist/react/renderer.js.bak +420 -0
- package/dist/react/renderer.js.map +1 -0
- package/dist/renderer/renderer.d.ts +55 -0
- package/dist/renderer/renderer.d.ts.bak +55 -0
- package/dist/renderer/renderer.d.ts.map +1 -0
- package/dist/renderer/renderer.js +232 -0
- package/dist/renderer/renderer.js.bak +232 -0
- package/dist/renderer/renderer.js.map +1 -0
- package/dist/runtime/capsule-runtime.d.ts +227 -0
- package/dist/runtime/capsule-runtime.d.ts.bak +227 -0
- package/dist/runtime/capsule-runtime.d.ts.map +1 -0
- package/dist/runtime/capsule-runtime.js +563 -0
- package/dist/runtime/capsule-runtime.js.bak +563 -0
- package/dist/runtime/capsule-runtime.js.map +1 -0
- package/dist/runtime/policy-gates.d.ts +116 -0
- package/dist/runtime/policy-gates.d.ts.bak +116 -0
- package/dist/runtime/policy-gates.d.ts.map +1 -0
- package/dist/runtime/policy-gates.js +317 -0
- package/dist/runtime/policy-gates.js.bak +317 -0
- package/dist/runtime/policy-gates.js.map +1 -0
- package/dist/schema/ui-ir.d.ts +26 -0
- package/dist/schema/ui-ir.d.ts.bak +26 -0
- package/dist/schema/ui-ir.d.ts.map +1 -0
- package/dist/schema/ui-ir.js +51 -0
- package/dist/schema/ui-ir.js.bak +51 -0
- package/dist/schema/ui-ir.js.map +1 -0
- package/dist/sdk/api.d.ts +101 -0
- package/dist/sdk/api.d.ts.bak +101 -0
- package/dist/sdk/api.d.ts.map +1 -0
- package/dist/sdk/api.js +177 -0
- package/dist/sdk/api.js.bak +177 -0
- package/dist/sdk/api.js.map +1 -0
- package/dist/sdk/index.d.ts +9 -0
- package/dist/sdk/index.d.ts.bak +9 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/index.js +10 -0
- package/dist/sdk/index.js.bak +10 -0
- package/dist/sdk/index.js.map +1 -0
- package/dist/sdk/react.d.ts +63 -0
- package/dist/sdk/react.d.ts.bak +63 -0
- package/dist/sdk/react.d.ts.map +1 -0
- package/dist/sdk/react.js +161 -0
- package/dist/sdk/react.js.bak +161 -0
- package/dist/sdk/react.js.map +1 -0
- package/dist/state/index.d.ts +8 -0
- package/dist/state/index.d.ts.bak +8 -0
- package/dist/state/index.d.ts.map +1 -0
- package/dist/state/index.js +8 -0
- package/dist/state/index.js.bak +8 -0
- package/dist/state/index.js.map +1 -0
- package/dist/state/patch.d.ts +73 -0
- package/dist/state/patch.d.ts.bak +73 -0
- package/dist/state/patch.d.ts.map +1 -0
- package/dist/state/patch.js +437 -0
- package/dist/state/patch.js.bak +437 -0
- package/dist/state/patch.js.map +1 -0
- package/dist/state/store.d.ts +50 -0
- package/dist/state/store.d.ts.bak +50 -0
- package/dist/state/store.d.ts.map +1 -0
- package/dist/state/store.js +246 -0
- package/dist/state/store.js.bak +246 -0
- package/dist/state/store.js.map +1 -0
- package/dist/svelte/index.d.ts +15 -0
- package/dist/svelte/index.d.ts.bak +15 -0
- package/dist/svelte/index.d.ts.map +1 -0
- package/dist/svelte/index.js +15 -0
- package/dist/svelte/index.js.bak +15 -0
- package/dist/svelte/index.js.map +1 -0
- package/dist/svelte/renderer.d.ts +35 -0
- package/dist/svelte/renderer.d.ts.bak +35 -0
- package/dist/svelte/renderer.d.ts.map +1 -0
- package/dist/svelte/renderer.js +317 -0
- package/dist/svelte/renderer.js.bak +317 -0
- package/dist/svelte/renderer.js.map +1 -0
- package/dist/types/index.d.ts +349 -0
- package/dist/types/index.d.ts.bak +349 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +152 -0
- package/dist/types/index.js.bak +152 -0
- package/dist/types/index.js.map +1 -0
- package/dist/vue/index.d.ts +18 -0
- package/dist/vue/index.d.ts.bak +18 -0
- package/dist/vue/index.d.ts.map +1 -0
- package/dist/vue/index.js +18 -0
- package/dist/vue/index.js.bak +18 -0
- package/dist/vue/index.js.map +1 -0
- package/dist/vue/renderer.d.ts +46 -0
- package/dist/vue/renderer.d.ts.bak +46 -0
- package/dist/vue/renderer.d.ts.map +1 -0
- package/dist/vue/renderer.js +302 -0
- package/dist/vue/renderer.js.bak +302 -0
- package/dist/vue/renderer.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visual Editor for A2R-IX
|
|
3
|
+
*
|
|
4
|
+
* Declarative API for building UI IR visually.
|
|
5
|
+
*/
|
|
6
|
+
import type { UIRoot, UIComponent, UIAction, StateVariable } from '../types';
|
|
7
|
+
export interface VisualEditor {
|
|
8
|
+
/** Create new UI document */
|
|
9
|
+
create(version?: string): UIRootBuilder;
|
|
10
|
+
/** Load existing UI */
|
|
11
|
+
load(root: UIRoot): UIRootBuilder;
|
|
12
|
+
}
|
|
13
|
+
export interface UIRootBuilder {
|
|
14
|
+
/** Set document metadata */
|
|
15
|
+
metadata(meta: {
|
|
16
|
+
title?: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
author?: string;
|
|
19
|
+
}): UIRootBuilder;
|
|
20
|
+
/** Add component to root */
|
|
21
|
+
add(component: UIComponentBuilder | UIComponent): UIRootBuilder;
|
|
22
|
+
/** Add state variable */
|
|
23
|
+
state(path: string, type: StateVariable['type'], defaultValue?: unknown): UIRootBuilder;
|
|
24
|
+
/** Add computed value */
|
|
25
|
+
computed(name: string, deps: string[], compute: string): UIRootBuilder;
|
|
26
|
+
/** Add action */
|
|
27
|
+
action(id: string, type: UIAction['type'], handler: UIAction['handler']): UIRootBuilder;
|
|
28
|
+
/** Add custom CSS */
|
|
29
|
+
css(styles: string): UIRootBuilder;
|
|
30
|
+
/** Build final UIRoot */
|
|
31
|
+
build(): UIRoot;
|
|
32
|
+
}
|
|
33
|
+
export interface UIComponentBuilder {
|
|
34
|
+
/** Set component ID */
|
|
35
|
+
id(id: string): UIComponentBuilder;
|
|
36
|
+
/** Set component props */
|
|
37
|
+
props(props: Record<string, unknown>): UIComponentBuilder;
|
|
38
|
+
/** Add prop */
|
|
39
|
+
prop(key: string, value: unknown): UIComponentBuilder;
|
|
40
|
+
/** Add binding */
|
|
41
|
+
bind(prop: string, statePath: string, direction?: 'one-way' | 'two-way'): UIComponentBuilder;
|
|
42
|
+
/** Add event handler */
|
|
43
|
+
on(event: string, action: string, params?: Record<string, unknown>): UIComponentBuilder;
|
|
44
|
+
/** Add child component */
|
|
45
|
+
child(component: UIComponentBuilder | UIComponent): UIComponentBuilder;
|
|
46
|
+
/** Set conditional render */
|
|
47
|
+
when(condition: string): UIComponentBuilder;
|
|
48
|
+
/** Set repeat/for loop */
|
|
49
|
+
repeat(items: string, as: string, options?: {
|
|
50
|
+
indexAs?: string;
|
|
51
|
+
filter?: string;
|
|
52
|
+
sort?: string;
|
|
53
|
+
}): UIComponentBuilder;
|
|
54
|
+
/** Set style */
|
|
55
|
+
style(styles: Record<string, string | number>): UIComponentBuilder;
|
|
56
|
+
/** Set CSS class */
|
|
57
|
+
className(className: string): UIComponentBuilder;
|
|
58
|
+
/** Build final component */
|
|
59
|
+
build(): UIComponent;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create visual editor
|
|
63
|
+
*/
|
|
64
|
+
export declare function createVisualEditor(): VisualEditor;
|
|
65
|
+
/**
|
|
66
|
+
* Component type builders
|
|
67
|
+
*/
|
|
68
|
+
export declare const components: {
|
|
69
|
+
/** Layout components */
|
|
70
|
+
layout: {
|
|
71
|
+
Box: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
72
|
+
Stack: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
73
|
+
Grid: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
74
|
+
Flex: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
75
|
+
Container: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
76
|
+
};
|
|
77
|
+
/** Typography components */
|
|
78
|
+
typography: {
|
|
79
|
+
Text: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
80
|
+
Heading: (text: string, level?: number, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
81
|
+
Paragraph: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
82
|
+
Label: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
83
|
+
};
|
|
84
|
+
/** Input components */
|
|
85
|
+
input: {
|
|
86
|
+
Button: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
87
|
+
Input: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
88
|
+
TextArea: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
89
|
+
Select: (options: Array<{
|
|
90
|
+
value: string;
|
|
91
|
+
label: string;
|
|
92
|
+
}>, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
93
|
+
Checkbox: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
94
|
+
Radio: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
95
|
+
Switch: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
96
|
+
};
|
|
97
|
+
/** Display components */
|
|
98
|
+
display: {
|
|
99
|
+
Image: (src: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
100
|
+
Icon: (name: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
101
|
+
Badge: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
102
|
+
Card: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
103
|
+
List: (items: unknown[], renderItem: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
104
|
+
Table: (data: unknown[], columns: unknown[], props?: Record<string, unknown>) => UIComponentBuilder;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Fluent API for common patterns
|
|
109
|
+
*/
|
|
110
|
+
export declare const patterns: {
|
|
111
|
+
/** Create a form with inputs */
|
|
112
|
+
form: (fields: Array<{
|
|
113
|
+
name: string;
|
|
114
|
+
label: string;
|
|
115
|
+
type: string;
|
|
116
|
+
}>, submitAction: string) => UIRootBuilder;
|
|
117
|
+
/** Create a data table */
|
|
118
|
+
dataTable: (dataPath: string, columns: Array<{
|
|
119
|
+
key: string;
|
|
120
|
+
title: string;
|
|
121
|
+
}>) => UIComponentBuilder;
|
|
122
|
+
/** Create a modal/dialog */
|
|
123
|
+
modal: (title: string, content: UIComponentBuilder, onClose: string) => UIComponentBuilder;
|
|
124
|
+
/** Create a navigation menu */
|
|
125
|
+
navMenu: (items: Array<{
|
|
126
|
+
label: string;
|
|
127
|
+
action: string;
|
|
128
|
+
icon?: string;
|
|
129
|
+
}>) => UIComponentBuilder;
|
|
130
|
+
};
|
|
131
|
+
export declare const ui: {
|
|
132
|
+
/** Create new UI */
|
|
133
|
+
create: (version?: string) => UIRootBuilder;
|
|
134
|
+
/** Load existing UI */
|
|
135
|
+
load: (root: UIRoot) => UIRootBuilder;
|
|
136
|
+
/** Component builders */
|
|
137
|
+
components: {
|
|
138
|
+
/** Layout components */
|
|
139
|
+
layout: {
|
|
140
|
+
Box: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
141
|
+
Stack: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
142
|
+
Grid: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
143
|
+
Flex: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
144
|
+
Container: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
145
|
+
};
|
|
146
|
+
/** Typography components */
|
|
147
|
+
typography: {
|
|
148
|
+
Text: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
149
|
+
Heading: (text: string, level?: number, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
150
|
+
Paragraph: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
151
|
+
Label: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
152
|
+
};
|
|
153
|
+
/** Input components */
|
|
154
|
+
input: {
|
|
155
|
+
Button: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
156
|
+
Input: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
157
|
+
TextArea: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
158
|
+
Select: (options: Array<{
|
|
159
|
+
value: string;
|
|
160
|
+
label: string;
|
|
161
|
+
}>, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
162
|
+
Checkbox: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
163
|
+
Radio: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
164
|
+
Switch: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
165
|
+
};
|
|
166
|
+
/** Display components */
|
|
167
|
+
display: {
|
|
168
|
+
Image: (src: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
169
|
+
Icon: (name: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
170
|
+
Badge: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
171
|
+
Card: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
172
|
+
List: (items: unknown[], renderItem: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
173
|
+
Table: (data: unknown[], columns: unknown[], props?: Record<string, unknown>) => UIComponentBuilder;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
/** Pattern builders */
|
|
177
|
+
patterns: {
|
|
178
|
+
/** Create a form with inputs */
|
|
179
|
+
form: (fields: Array<{
|
|
180
|
+
name: string;
|
|
181
|
+
label: string;
|
|
182
|
+
type: string;
|
|
183
|
+
}>, submitAction: string) => UIRootBuilder;
|
|
184
|
+
/** Create a data table */
|
|
185
|
+
dataTable: (dataPath: string, columns: Array<{
|
|
186
|
+
key: string;
|
|
187
|
+
title: string;
|
|
188
|
+
}>) => UIComponentBuilder;
|
|
189
|
+
/** Create a modal/dialog */
|
|
190
|
+
modal: (title: string, content: UIComponentBuilder, onClose: string) => UIComponentBuilder;
|
|
191
|
+
/** Create a navigation menu */
|
|
192
|
+
navMenu: (items: Array<{
|
|
193
|
+
label: string;
|
|
194
|
+
action: string;
|
|
195
|
+
icon?: string;
|
|
196
|
+
}>) => UIComponentBuilder;
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
//# sourceMappingURL=visual-editor.d.ts.map
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visual Editor for A2R-IX
|
|
3
|
+
*
|
|
4
|
+
* Declarative API for building UI IR visually.
|
|
5
|
+
*/
|
|
6
|
+
import type { UIRoot, UIComponent, UIAction, StateVariable } from '../types';
|
|
7
|
+
export interface VisualEditor {
|
|
8
|
+
/** Create new UI document */
|
|
9
|
+
create(version?: string): UIRootBuilder;
|
|
10
|
+
/** Load existing UI */
|
|
11
|
+
load(root: UIRoot): UIRootBuilder;
|
|
12
|
+
}
|
|
13
|
+
export interface UIRootBuilder {
|
|
14
|
+
/** Set document metadata */
|
|
15
|
+
metadata(meta: {
|
|
16
|
+
title?: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
author?: string;
|
|
19
|
+
}): UIRootBuilder;
|
|
20
|
+
/** Add component to root */
|
|
21
|
+
add(component: UIComponentBuilder | UIComponent): UIRootBuilder;
|
|
22
|
+
/** Add state variable */
|
|
23
|
+
state(path: string, type: StateVariable['type'], defaultValue?: unknown): UIRootBuilder;
|
|
24
|
+
/** Add computed value */
|
|
25
|
+
computed(name: string, deps: string[], compute: string): UIRootBuilder;
|
|
26
|
+
/** Add action */
|
|
27
|
+
action(id: string, type: UIAction['type'], handler: UIAction['handler']): UIRootBuilder;
|
|
28
|
+
/** Add custom CSS */
|
|
29
|
+
css(styles: string): UIRootBuilder;
|
|
30
|
+
/** Build final UIRoot */
|
|
31
|
+
build(): UIRoot;
|
|
32
|
+
}
|
|
33
|
+
export interface UIComponentBuilder {
|
|
34
|
+
/** Set component ID */
|
|
35
|
+
id(id: string): UIComponentBuilder;
|
|
36
|
+
/** Set component props */
|
|
37
|
+
props(props: Record<string, unknown>): UIComponentBuilder;
|
|
38
|
+
/** Add prop */
|
|
39
|
+
prop(key: string, value: unknown): UIComponentBuilder;
|
|
40
|
+
/** Add binding */
|
|
41
|
+
bind(prop: string, statePath: string, direction?: 'one-way' | 'two-way'): UIComponentBuilder;
|
|
42
|
+
/** Add event handler */
|
|
43
|
+
on(event: string, action: string, params?: Record<string, unknown>): UIComponentBuilder;
|
|
44
|
+
/** Add child component */
|
|
45
|
+
child(component: UIComponentBuilder | UIComponent): UIComponentBuilder;
|
|
46
|
+
/** Set conditional render */
|
|
47
|
+
when(condition: string): UIComponentBuilder;
|
|
48
|
+
/** Set repeat/for loop */
|
|
49
|
+
repeat(items: string, as: string, options?: {
|
|
50
|
+
indexAs?: string;
|
|
51
|
+
filter?: string;
|
|
52
|
+
sort?: string;
|
|
53
|
+
}): UIComponentBuilder;
|
|
54
|
+
/** Set style */
|
|
55
|
+
style(styles: Record<string, string | number>): UIComponentBuilder;
|
|
56
|
+
/** Set CSS class */
|
|
57
|
+
className(className: string): UIComponentBuilder;
|
|
58
|
+
/** Build final component */
|
|
59
|
+
build(): UIComponent;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create visual editor
|
|
63
|
+
*/
|
|
64
|
+
export declare function createVisualEditor(): VisualEditor;
|
|
65
|
+
/**
|
|
66
|
+
* Component type builders
|
|
67
|
+
*/
|
|
68
|
+
export declare const components: {
|
|
69
|
+
/** Layout components */
|
|
70
|
+
layout: {
|
|
71
|
+
Box: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
72
|
+
Stack: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
73
|
+
Grid: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
74
|
+
Flex: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
75
|
+
Container: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
76
|
+
};
|
|
77
|
+
/** Typography components */
|
|
78
|
+
typography: {
|
|
79
|
+
Text: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
80
|
+
Heading: (text: string, level?: number, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
81
|
+
Paragraph: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
82
|
+
Label: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
83
|
+
};
|
|
84
|
+
/** Input components */
|
|
85
|
+
input: {
|
|
86
|
+
Button: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
87
|
+
Input: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
88
|
+
TextArea: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
89
|
+
Select: (options: Array<{
|
|
90
|
+
value: string;
|
|
91
|
+
label: string;
|
|
92
|
+
}>, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
93
|
+
Checkbox: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
94
|
+
Radio: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
95
|
+
Switch: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
96
|
+
};
|
|
97
|
+
/** Display components */
|
|
98
|
+
display: {
|
|
99
|
+
Image: (src: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
100
|
+
Icon: (name: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
101
|
+
Badge: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
102
|
+
Card: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
103
|
+
List: (items: unknown[], renderItem: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
104
|
+
Table: (data: unknown[], columns: unknown[], props?: Record<string, unknown>) => UIComponentBuilder;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Fluent API for common patterns
|
|
109
|
+
*/
|
|
110
|
+
export declare const patterns: {
|
|
111
|
+
/** Create a form with inputs */
|
|
112
|
+
form: (fields: Array<{
|
|
113
|
+
name: string;
|
|
114
|
+
label: string;
|
|
115
|
+
type: string;
|
|
116
|
+
}>, submitAction: string) => UIRootBuilder;
|
|
117
|
+
/** Create a data table */
|
|
118
|
+
dataTable: (dataPath: string, columns: Array<{
|
|
119
|
+
key: string;
|
|
120
|
+
title: string;
|
|
121
|
+
}>) => UIComponentBuilder;
|
|
122
|
+
/** Create a modal/dialog */
|
|
123
|
+
modal: (title: string, content: UIComponentBuilder, onClose: string) => UIComponentBuilder;
|
|
124
|
+
/** Create a navigation menu */
|
|
125
|
+
navMenu: (items: Array<{
|
|
126
|
+
label: string;
|
|
127
|
+
action: string;
|
|
128
|
+
icon?: string;
|
|
129
|
+
}>) => UIComponentBuilder;
|
|
130
|
+
};
|
|
131
|
+
export declare const ui: {
|
|
132
|
+
/** Create new UI */
|
|
133
|
+
create: (version?: string) => UIRootBuilder;
|
|
134
|
+
/** Load existing UI */
|
|
135
|
+
load: (root: UIRoot) => UIRootBuilder;
|
|
136
|
+
/** Component builders */
|
|
137
|
+
components: {
|
|
138
|
+
/** Layout components */
|
|
139
|
+
layout: {
|
|
140
|
+
Box: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
141
|
+
Stack: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
142
|
+
Grid: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
143
|
+
Flex: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
144
|
+
Container: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
145
|
+
};
|
|
146
|
+
/** Typography components */
|
|
147
|
+
typography: {
|
|
148
|
+
Text: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
149
|
+
Heading: (text: string, level?: number, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
150
|
+
Paragraph: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
151
|
+
Label: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
152
|
+
};
|
|
153
|
+
/** Input components */
|
|
154
|
+
input: {
|
|
155
|
+
Button: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
156
|
+
Input: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
157
|
+
TextArea: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
158
|
+
Select: (options: Array<{
|
|
159
|
+
value: string;
|
|
160
|
+
label: string;
|
|
161
|
+
}>, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
162
|
+
Checkbox: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
163
|
+
Radio: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
164
|
+
Switch: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
165
|
+
};
|
|
166
|
+
/** Display components */
|
|
167
|
+
display: {
|
|
168
|
+
Image: (src: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
169
|
+
Icon: (name: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
170
|
+
Badge: (text: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
171
|
+
Card: (props?: Record<string, unknown>) => UIComponentBuilder;
|
|
172
|
+
List: (items: unknown[], renderItem: string, props?: Record<string, unknown>) => UIComponentBuilder;
|
|
173
|
+
Table: (data: unknown[], columns: unknown[], props?: Record<string, unknown>) => UIComponentBuilder;
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
/** Pattern builders */
|
|
177
|
+
patterns: {
|
|
178
|
+
/** Create a form with inputs */
|
|
179
|
+
form: (fields: Array<{
|
|
180
|
+
name: string;
|
|
181
|
+
label: string;
|
|
182
|
+
type: string;
|
|
183
|
+
}>, submitAction: string) => UIRootBuilder;
|
|
184
|
+
/** Create a data table */
|
|
185
|
+
dataTable: (dataPath: string, columns: Array<{
|
|
186
|
+
key: string;
|
|
187
|
+
title: string;
|
|
188
|
+
}>) => UIComponentBuilder;
|
|
189
|
+
/** Create a modal/dialog */
|
|
190
|
+
modal: (title: string, content: UIComponentBuilder, onClose: string) => UIComponentBuilder;
|
|
191
|
+
/** Create a navigation menu */
|
|
192
|
+
navMenu: (items: Array<{
|
|
193
|
+
label: string;
|
|
194
|
+
action: string;
|
|
195
|
+
icon?: string;
|
|
196
|
+
}>) => UIComponentBuilder;
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
//# sourceMappingURL=visual-editor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visual-editor.d.ts","sourceRoot":"","sources":["../../src/collab/visual-editor.ts"],"names":[],"mappings":"AAAA;;;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
/**
|
|
2
|
+
* Visual Editor for A2R-IX
|
|
3
|
+
*
|
|
4
|
+
* Declarative API for building UI IR visually.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Create visual editor
|
|
8
|
+
*/
|
|
9
|
+
export function createVisualEditor() {
|
|
10
|
+
return {
|
|
11
|
+
create(version = '1.0.0') {
|
|
12
|
+
return createUIRootBuilder(version);
|
|
13
|
+
},
|
|
14
|
+
load(root) {
|
|
15
|
+
return createUIRootBuilder(root.version, root);
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Create UI root builder
|
|
21
|
+
*/
|
|
22
|
+
function createUIRootBuilder(version, existing) {
|
|
23
|
+
const root = existing || {
|
|
24
|
+
version,
|
|
25
|
+
components: [],
|
|
26
|
+
state: { variables: [], computed: [], initial: {} },
|
|
27
|
+
actions: [],
|
|
28
|
+
};
|
|
29
|
+
let metadata = {};
|
|
30
|
+
return {
|
|
31
|
+
metadata(meta) {
|
|
32
|
+
metadata = { ...metadata, ...meta };
|
|
33
|
+
return this;
|
|
34
|
+
},
|
|
35
|
+
add(component) {
|
|
36
|
+
const comp = 'build' in component ? component.build() : component;
|
|
37
|
+
root.components.push(comp);
|
|
38
|
+
return this;
|
|
39
|
+
},
|
|
40
|
+
state(path, type, defaultValue) {
|
|
41
|
+
root.state.variables.push({ path, type, default: defaultValue });
|
|
42
|
+
if (defaultValue !== undefined) {
|
|
43
|
+
root.state.initial[path] = defaultValue;
|
|
44
|
+
}
|
|
45
|
+
return this;
|
|
46
|
+
},
|
|
47
|
+
computed(name, deps, compute) {
|
|
48
|
+
if (!root.state.computed) {
|
|
49
|
+
root.state.computed = [];
|
|
50
|
+
}
|
|
51
|
+
root.state.computed.push({
|
|
52
|
+
name,
|
|
53
|
+
deps,
|
|
54
|
+
compute: { $expr: compute },
|
|
55
|
+
});
|
|
56
|
+
return this;
|
|
57
|
+
},
|
|
58
|
+
action(id, type, handler) {
|
|
59
|
+
root.actions.push({ id, type, handler });
|
|
60
|
+
return this;
|
|
61
|
+
},
|
|
62
|
+
css(styles) {
|
|
63
|
+
root.css = styles;
|
|
64
|
+
return this;
|
|
65
|
+
},
|
|
66
|
+
build() {
|
|
67
|
+
if (Object.keys(metadata).length > 0) {
|
|
68
|
+
root.metadata = { ...root.metadata, ...metadata };
|
|
69
|
+
}
|
|
70
|
+
return root;
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Component type builders
|
|
76
|
+
*/
|
|
77
|
+
export const components = {
|
|
78
|
+
/** Layout components */
|
|
79
|
+
layout: {
|
|
80
|
+
Box: (props) => createComponentBuilder('Box', props),
|
|
81
|
+
Stack: (props) => createComponentBuilder('Stack', props),
|
|
82
|
+
Grid: (props) => createComponentBuilder('Grid', props),
|
|
83
|
+
Flex: (props) => createComponentBuilder('Flex', props),
|
|
84
|
+
Container: (props) => createComponentBuilder('Container', props),
|
|
85
|
+
},
|
|
86
|
+
/** Typography components */
|
|
87
|
+
typography: {
|
|
88
|
+
Text: (text, props) => createComponentBuilder('Text', { children: text, ...props }),
|
|
89
|
+
Heading: (text, level = 1, props) => createComponentBuilder('Heading', { children: text, level, ...props }),
|
|
90
|
+
Paragraph: (text, props) => createComponentBuilder('Paragraph', { children: text, ...props }),
|
|
91
|
+
Label: (text, props) => createComponentBuilder('Label', { children: text, ...props }),
|
|
92
|
+
},
|
|
93
|
+
/** Input components */
|
|
94
|
+
input: {
|
|
95
|
+
Button: (text, props) => createComponentBuilder('Button', { children: text, ...props }),
|
|
96
|
+
Input: (props) => createComponentBuilder('Input', props),
|
|
97
|
+
TextArea: (props) => createComponentBuilder('TextArea', props),
|
|
98
|
+
Select: (options, props) => createComponentBuilder('Select', { options, ...props }),
|
|
99
|
+
Checkbox: (props) => createComponentBuilder('Checkbox', props),
|
|
100
|
+
Radio: (props) => createComponentBuilder('Radio', props),
|
|
101
|
+
Switch: (props) => createComponentBuilder('Switch', props),
|
|
102
|
+
},
|
|
103
|
+
/** Display components */
|
|
104
|
+
display: {
|
|
105
|
+
Image: (src, props) => createComponentBuilder('Image', { src, ...props }),
|
|
106
|
+
Icon: (name, props) => createComponentBuilder('Icon', { name, ...props }),
|
|
107
|
+
Badge: (text, props) => createComponentBuilder('Badge', { children: text, ...props }),
|
|
108
|
+
Card: (props) => createComponentBuilder('Card', props),
|
|
109
|
+
List: (items, renderItem, props) => createComponentBuilder('List', { items, renderItem, ...props }),
|
|
110
|
+
Table: (data, columns, props) => createComponentBuilder('Table', { data, columns, ...props }),
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Create component builder
|
|
115
|
+
*/
|
|
116
|
+
function createComponentBuilder(type, initialProps = {}) {
|
|
117
|
+
const component = {
|
|
118
|
+
id: generateId(),
|
|
119
|
+
type,
|
|
120
|
+
props: { ...initialProps },
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
id(id) {
|
|
124
|
+
component.id = id;
|
|
125
|
+
return this;
|
|
126
|
+
},
|
|
127
|
+
props(props) {
|
|
128
|
+
Object.assign(component.props, props);
|
|
129
|
+
return this;
|
|
130
|
+
},
|
|
131
|
+
prop(key, value) {
|
|
132
|
+
component.props[key] = value;
|
|
133
|
+
return this;
|
|
134
|
+
},
|
|
135
|
+
bind(prop, statePath, direction = 'one-way') {
|
|
136
|
+
if (!component.bindings) {
|
|
137
|
+
component.bindings = [];
|
|
138
|
+
}
|
|
139
|
+
component.bindings.push({ prop, statePath, direction });
|
|
140
|
+
return this;
|
|
141
|
+
},
|
|
142
|
+
on(event, action, params) {
|
|
143
|
+
if (!component.events) {
|
|
144
|
+
component.events = [];
|
|
145
|
+
}
|
|
146
|
+
component.events.push({ event, action, params });
|
|
147
|
+
return this;
|
|
148
|
+
},
|
|
149
|
+
child(childComponent) {
|
|
150
|
+
if (!component.children) {
|
|
151
|
+
component.children = [];
|
|
152
|
+
}
|
|
153
|
+
const child = 'build' in childComponent ? childComponent.build() : childComponent;
|
|
154
|
+
component.children.push(child);
|
|
155
|
+
return this;
|
|
156
|
+
},
|
|
157
|
+
when(condition) {
|
|
158
|
+
component.condition = { $expr: condition };
|
|
159
|
+
return this;
|
|
160
|
+
},
|
|
161
|
+
repeat(items, as, options) {
|
|
162
|
+
component.repeat = {
|
|
163
|
+
items,
|
|
164
|
+
as,
|
|
165
|
+
indexAs: options?.indexAs,
|
|
166
|
+
filter: options?.filter ? { $expr: options.filter } : undefined,
|
|
167
|
+
sort: options?.sort ? { $expr: options.sort } : undefined,
|
|
168
|
+
};
|
|
169
|
+
return this;
|
|
170
|
+
},
|
|
171
|
+
style(styles) {
|
|
172
|
+
component.style = styles;
|
|
173
|
+
return this;
|
|
174
|
+
},
|
|
175
|
+
className(className) {
|
|
176
|
+
component.className = className;
|
|
177
|
+
return this;
|
|
178
|
+
},
|
|
179
|
+
build() {
|
|
180
|
+
return component;
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Generate unique ID
|
|
186
|
+
*/
|
|
187
|
+
function generateId() {
|
|
188
|
+
return `comp_${Math.random().toString(36).substr(2, 9)}`;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Fluent API for common patterns
|
|
192
|
+
*/
|
|
193
|
+
export const patterns = {
|
|
194
|
+
/** Create a form with inputs */
|
|
195
|
+
form: (fields, submitAction) => {
|
|
196
|
+
const editor = createVisualEditor();
|
|
197
|
+
const builder = editor.create();
|
|
198
|
+
// Add state for each field
|
|
199
|
+
fields.forEach((field) => {
|
|
200
|
+
builder.state(`form.${field.name}`, field.type === 'number' ? 'number' : 'string', '');
|
|
201
|
+
});
|
|
202
|
+
// Build form components
|
|
203
|
+
const formContainer = components.layout.Stack({ spacing: 4 })
|
|
204
|
+
.className('a2r-form');
|
|
205
|
+
fields.forEach((field) => {
|
|
206
|
+
formContainer.child(components.layout.Stack({ direction: 'vertical', spacing: 1 })
|
|
207
|
+
.child(components.typography.Label(field.label))
|
|
208
|
+
.child(components.input.Input({ type: field.type })
|
|
209
|
+
.bind('value', `form.${field.name}`, 'two-way')));
|
|
210
|
+
});
|
|
211
|
+
formContainer.child(components.input.Button('Submit', { variant: 'primary' })
|
|
212
|
+
.on('onClick', submitAction));
|
|
213
|
+
builder.add(formContainer);
|
|
214
|
+
return builder;
|
|
215
|
+
},
|
|
216
|
+
/** Create a data table */
|
|
217
|
+
dataTable: (dataPath, columns) => {
|
|
218
|
+
return components.display.Table([], [])
|
|
219
|
+
.bind('data', dataPath)
|
|
220
|
+
.prop('columns', columns);
|
|
221
|
+
},
|
|
222
|
+
/** Create a modal/dialog */
|
|
223
|
+
modal: (title, content, onClose) => {
|
|
224
|
+
return components.layout.Box({ padding: 4 })
|
|
225
|
+
.className('a2r-modal')
|
|
226
|
+
.child(components.layout.Stack({ direction: 'vertical', spacing: 2 })
|
|
227
|
+
.child(components.layout.Stack({ direction: 'horizontal', justify: 'between' })
|
|
228
|
+
.child(components.typography.Heading(title, 3))
|
|
229
|
+
.child(components.input.Button('×', { variant: 'ghost', size: 'sm' })
|
|
230
|
+
.on('onClick', onClose)))
|
|
231
|
+
.child(content));
|
|
232
|
+
},
|
|
233
|
+
/** Create a navigation menu */
|
|
234
|
+
navMenu: (items) => {
|
|
235
|
+
const list = components.layout.Stack({ direction: 'vertical', spacing: 1 })
|
|
236
|
+
.className('a2r-nav-menu');
|
|
237
|
+
items.forEach((item) => {
|
|
238
|
+
const btn = components.input.Button(item.label, { variant: 'ghost' })
|
|
239
|
+
.on('onClick', item.action);
|
|
240
|
+
if (item.icon) {
|
|
241
|
+
btn.prop('icon', item.icon);
|
|
242
|
+
}
|
|
243
|
+
list.child(btn);
|
|
244
|
+
});
|
|
245
|
+
return list;
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
// Export fluent API
|
|
249
|
+
export const ui = {
|
|
250
|
+
/** Create new UI */
|
|
251
|
+
create: (version) => createVisualEditor().create(version),
|
|
252
|
+
/** Load existing UI */
|
|
253
|
+
load: (root) => createVisualEditor().load(root),
|
|
254
|
+
/** Component builders */
|
|
255
|
+
components,
|
|
256
|
+
/** Pattern builders */
|
|
257
|
+
patterns,
|
|
258
|
+
};
|
|
259
|
+
//# sourceMappingURL=visual-editor.js.map
|