@adia-ai/web-components 0.0.2 → 0.0.3

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.
Files changed (113) hide show
  1. package/a2ui/index.js +23 -17
  2. package/components/accordion/accordion.js +1 -1
  3. package/components/action-list/action-list.js +1 -1
  4. package/components/agent-artifact/agent-artifact.js +1 -1
  5. package/components/agent-feedback-bar/agent-feedback-bar.js +1 -1
  6. package/components/agent-questions/agent-questions.js +1 -1
  7. package/components/agent-reasoning/agent-reasoning.js +1 -1
  8. package/components/agent-suggestions/agent-suggestions.js +1 -1
  9. package/components/agent-trace/agent-trace.js +1 -1
  10. package/components/alert/alert.js +1 -1
  11. package/components/avatar/avatar.js +1 -1
  12. package/components/badge/badge.js +1 -1
  13. package/components/block/block.js +1 -1
  14. package/components/breadcrumb/breadcrumb.js +1 -1
  15. package/components/button/button.js +2 -2
  16. package/components/calendar-picker/calendar-picker.js +2 -2
  17. package/components/canvas/canvas.js +2 -2
  18. package/components/card/card.js +2 -2
  19. package/components/chart/chart.js +1 -1
  20. package/components/chat/chat-input.js +1 -1
  21. package/components/chat/chat.js +2 -2
  22. package/components/check/check.js +2 -2
  23. package/components/code/code.js +1 -1
  24. package/components/col/col.js +1 -1
  25. package/components/color-picker/color-picker.js +1 -1
  26. package/components/command/command.js +1 -1
  27. package/components/description-list/description-list.js +1 -1
  28. package/components/divider/divider.js +1 -1
  29. package/components/drawer/drawer.js +1 -1
  30. package/components/embed/embed.js +1 -1
  31. package/components/empty-state/empty-state.js +1 -1
  32. package/components/grid/grid.js +1 -1
  33. package/components/heatmap/heatmap.js +1 -1
  34. package/components/icon/icon.js +2 -2
  35. package/components/image/image.js +1 -1
  36. package/components/input/input.js +2 -2
  37. package/components/inspector/inspector.js +2 -2
  38. package/components/kbd/kbd.js +1 -1
  39. package/components/list/list.js +1 -1
  40. package/components/menu/menu.js +2 -2
  41. package/components/modal/modal.js +1 -1
  42. package/components/noodles/noodles.js +1 -1
  43. package/components/otp-input/otp-input.js +1 -1
  44. package/components/pagination/pagination.js +1 -1
  45. package/components/pane/pane.js +1 -1
  46. package/components/pipeline-status/pipeline-status.js +1 -1
  47. package/components/popover/popover.js +2 -2
  48. package/components/progress/progress.js +1 -1
  49. package/components/progress-row/progress-row.js +1 -1
  50. package/components/radio/radio.js +2 -2
  51. package/components/range/range.js +1 -1
  52. package/components/rating/rating.js +1 -1
  53. package/components/richtext/richtext.js +2 -2
  54. package/components/row/row.js +2 -2
  55. package/components/search/search.js +1 -1
  56. package/components/segment/segment.js +1 -1
  57. package/components/segmented/segmented.js +1 -1
  58. package/components/select/select.js +2 -2
  59. package/components/skeleton/skeleton.js +1 -1
  60. package/components/slider/slider.js +1 -1
  61. package/components/stack/stack.js +1 -1
  62. package/components/stat/stat.js +1 -1
  63. package/components/stepper/stepper.js +1 -1
  64. package/components/stream/stream.js +1 -1
  65. package/components/swiper/swiper.js +1 -1
  66. package/components/switch/switch.js +2 -2
  67. package/components/table/table.js +1 -1
  68. package/components/tabs/tab.js +1 -1
  69. package/components/tabs/tabs.js +1 -1
  70. package/components/tag/tag.js +1 -1
  71. package/components/text/text.js +1 -1
  72. package/components/textarea/textarea.js +1 -1
  73. package/components/timeline/timeline.js +1 -1
  74. package/components/toast/toast.js +1 -1
  75. package/components/toggle-group/toggle-group.js +1 -1
  76. package/components/toolbar/toolbar.js +2 -2
  77. package/components/tooltip/tooltip.js +2 -2
  78. package/components/tree/tree.js +1 -1
  79. package/components/upload/upload.js +1 -1
  80. package/core/markdown.js +1 -1
  81. package/core/provider.js +2 -2
  82. package/package.json +7 -3
  83. package/patterns/a2ui-root/a2ui-root.a2ui.json +118 -0
  84. package/{a2ui/root.js → patterns/a2ui-root/a2ui-root.js} +9 -4
  85. package/patterns/a2ui-root/a2ui-root.yaml +76 -0
  86. package/patterns/adia-chat/adia-chat.js +3 -3
  87. package/patterns/adia-editor/adia-editor.js +1 -1
  88. package/patterns/app-nav/app-nav.js +1 -1
  89. package/patterns/app-nav-group/app-nav-group.js +2 -2
  90. package/patterns/app-nav-item/app-nav-item.js +1 -1
  91. package/patterns/app-shell/app-shell.js +1 -1
  92. package/patterns/gen-ui/gen-ui.js +1 -1
  93. package/patterns/index.js +1 -0
  94. package/patterns/section-nav/section-nav.js +1 -1
  95. package/patterns/section-nav-group/section-nav-group.js +1 -1
  96. package/patterns/section-nav-item/section-nav-item.js +1 -1
  97. package/traits/define.js +1 -1
  98. package/a2ui/dockables/action.js +0 -152
  99. package/a2ui/dockables/base.js +0 -30
  100. package/a2ui/dockables/controller.js +0 -97
  101. package/a2ui/dockables/data-source.js +0 -103
  102. package/a2ui/dockables/index.js +0 -6
  103. package/a2ui/dockables/lifecycle.js +0 -84
  104. package/a2ui/dockables/provider.js +0 -59
  105. package/a2ui/manifest-runtime.js +0 -226
  106. package/a2ui/registry.js +0 -200
  107. package/a2ui/renderer.js +0 -361
  108. package/a2ui/stream.js +0 -243
  109. package/a2ui/surface-manifest.js +0 -294
  110. package/a2ui/surface.js +0 -222
  111. package/a2ui/wire-factory.js +0 -134
  112. package/a2ui/wiring-engine.js +0 -209
  113. package/a2ui/wiring-registry.js +0 -342
@@ -1,226 +0,0 @@
1
- /**
2
- * Manifest Runtime — Loads a surface manifest and manages cross-surface
3
- * navigation, data flow, context sharing, and lifecycle dependencies.
4
- *
5
- * Bridges A008 (design-time manifest) to A007 (per-surface wiring engine).
6
- * Consumes a SurfaceManifest and orchestrates the live application.
7
- */
8
-
9
- import { sharedContextStore } from './context-store.js';
10
- import { resolveData } from './wiring-registry.js';
11
-
12
- export class ManifestRuntime {
13
- /** @type {import('./surface-manifest.js').SurfaceManifest} */
14
- #manifest;
15
-
16
- /** @type {Map<string, { mounted: boolean, completed: boolean }>} */
17
- #surfaceState = new Map();
18
-
19
- /** @type {Map<string, Function[]>} */
20
- #triggerListeners = new Map();
21
-
22
- /**
23
- * @param {import('./surface-manifest.js').SurfaceManifest} manifest
24
- */
25
- constructor(manifest) {
26
- this.#manifest = manifest;
27
- this.#initSharedContexts();
28
- }
29
-
30
- /**
31
- * Initialize shared contexts from the manifest.
32
- */
33
- #initSharedContexts() {
34
- const json = this.#manifest.toJSON();
35
- if (json.sharedContexts) {
36
- for (const [name, config] of Object.entries(json.sharedContexts)) {
37
- sharedContextStore.define(name, config);
38
- }
39
- }
40
- }
41
-
42
- /**
43
- * Signal that a surface has mounted (rendered and wired).
44
- * Joins shared contexts and checks lifecycle dependencies.
45
- *
46
- * @param {string} surfaceId
47
- * @param {Record<string, string>} [params] — Resolved route params
48
- */
49
- async onSurfaceMount(surfaceId, params = {}) {
50
- this.#surfaceState.set(surfaceId, { mounted: true, completed: false });
51
-
52
- // Join shared contexts
53
- const descriptor = this.#manifest.getSurface(surfaceId);
54
- if (descriptor?.consumes) {
55
- for (const contextName of Object.keys(descriptor.consumes)) {
56
- await sharedContextStore.join(contextName, surfaceId, resolveData, params);
57
- }
58
- }
59
-
60
- // Check depends-on: if this surface depends on another, verify it's ready
61
- const deps = this.#manifest.getAssociationsTo(surfaceId, 'depends-on');
62
- for (const dep of deps) {
63
- const depState = this.#surfaceState.get(dep.from);
64
- const condition = dep.condition || 'mounted';
65
-
66
- let satisfied = false;
67
- if (condition === 'mounted') satisfied = depState?.mounted === true;
68
- if (condition === 'completed') satisfied = depState?.completed === true;
69
- if (condition === 'has-data') satisfied = this.#hasContextData(surfaceId);
70
-
71
- if (!satisfied && dep.fallback) {
72
- this.#executeFallback(dep.fallback, params);
73
- return false; // Surface should not proceed
74
- }
75
- }
76
-
77
- return true;
78
- }
79
-
80
- /**
81
- * Signal that a surface has unmounted.
82
- *
83
- * @param {string} surfaceId
84
- */
85
- onSurfaceUnmount(surfaceId) {
86
- this.#surfaceState.set(surfaceId, { mounted: false, completed: false });
87
-
88
- // Leave shared contexts
89
- const descriptor = this.#manifest.getSurface(surfaceId);
90
- if (descriptor?.consumes) {
91
- for (const contextName of Object.keys(descriptor.consumes)) {
92
- sharedContextStore.leave(contextName, surfaceId);
93
- }
94
- }
95
- }
96
-
97
- /**
98
- * Signal that a surface's primary action completed (e.g., form submitted).
99
- * Fires cross-surface triggers.
100
- *
101
- * @param {string} surfaceId
102
- * @param {string} actionName — The action that completed (e.g., "submit-checkin")
103
- * @param {unknown} [result] — The action's return value
104
- */
105
- async onActionComplete(surfaceId, actionName, result) {
106
- const state = this.#surfaceState.get(surfaceId);
107
- if (state) state.completed = true;
108
-
109
- const trigger = `action:${actionName}`;
110
-
111
- // Process routes-to associations
112
- const routes = this.#manifest.getAssociationsFrom(surfaceId, 'routes-to')
113
- .filter(a => a.trigger === trigger);
114
- for (const route of routes) {
115
- const target = this.#manifest.getSurface(route.to);
116
- if (target?.route) {
117
- let path = target.route;
118
- const params = this.#resolveAssocParams(route.params, result);
119
- for (const [key, value] of Object.entries(params)) {
120
- path = path.replace(`:${key}`, encodeURIComponent(value));
121
- }
122
- location.hash = path;
123
- }
124
- }
125
-
126
- // Process feeds associations
127
- const feeds = this.#manifest.getAssociationsFrom(surfaceId, 'feeds')
128
- .filter(a => a.trigger === trigger);
129
- for (const feed of feeds) {
130
- if (feed.mapping) {
131
- for (const [targetPath, source] of Object.entries(feed.mapping)) {
132
- let value;
133
- if (source.from === 'action-result') value = result;
134
- else if (source.from === 'context') value = sharedContextStore.read(source.context, source.key);
135
- else if (source.from === 'literal') value = source.value;
136
-
137
- // Store for the target surface to consume when it mounts
138
- sharedContextStore.update(`__feed_${feed.to}`, { [targetPath]: value });
139
- }
140
- }
141
- }
142
-
143
- // Process triggers associations
144
- const triggers = this.#manifest.getAssociationsFrom(surfaceId, 'triggers')
145
- .filter(a => a.trigger === trigger);
146
- for (const trig of triggers) {
147
- this.#executeTriggerEffect(trig.to, trig.effect, result);
148
- }
149
- }
150
-
151
- /**
152
- * Get navigation targets from a surface.
153
- * @param {string} surfaceId
154
- * @returns {{ surfaceId: string, route: string, trigger: string }[]}
155
- */
156
- getNavigationTargets(surfaceId) {
157
- return this.#manifest.getAssociationsFrom(surfaceId, 'routes-to')
158
- .map(a => ({
159
- surfaceId: a.to,
160
- route: this.#manifest.getSurface(a.to)?.route || '',
161
- trigger: a.trigger || '',
162
- }));
163
- }
164
-
165
- /**
166
- * Get the manifest.
167
- */
168
- get manifest() { return this.#manifest; }
169
-
170
- // ── Internal ──
171
-
172
- #hasContextData(surfaceId) {
173
- const descriptor = this.#manifest.getSurface(surfaceId);
174
- if (!descriptor?.consumes) return true;
175
- for (const contextName of Object.keys(descriptor.consumes)) {
176
- if (!sharedContextStore.isPopulated(contextName)) return false;
177
- }
178
- return true;
179
- }
180
-
181
- #executeFallback(fallback, params) {
182
- if (fallback.startsWith('redirect:')) {
183
- const targetId = fallback.slice('redirect:'.length);
184
- const target = this.#manifest.getSurface(targetId);
185
- if (target?.route) {
186
- let path = target.route;
187
- for (const [key, value] of Object.entries(params)) {
188
- path = path.replace(`:${key}`, encodeURIComponent(value));
189
- }
190
- location.hash = path;
191
- }
192
- }
193
- // Other fallbacks: show-error, wait (future)
194
- }
195
-
196
- #resolveAssocParams(paramSpec, actionResult) {
197
- const params = {};
198
- if (!paramSpec) return params;
199
- for (const [name, spec] of Object.entries(paramSpec)) {
200
- if (spec.from === 'event-detail' || spec.from === 'action-result') {
201
- params[name] = spec.key ? actionResult?.[spec.key] : actionResult;
202
- } else if (spec.from === 'param') {
203
- // Read from current route
204
- const hash = location.hash.slice(1);
205
- const match = hash.match(new RegExp(`${spec.key}/([^/]+)`));
206
- if (match) params[name] = match[1];
207
- } else if (spec.from === 'literal') {
208
- params[name] = spec.value;
209
- }
210
- }
211
- return params;
212
- }
213
-
214
- #executeTriggerEffect(targetSurfaceId, effect, data) {
215
- if (!effect) return;
216
-
217
- // Dispatch as a custom event that the target surface can listen for
218
- document.dispatchEvent(new CustomEvent('a2ui-trigger', {
219
- detail: {
220
- targetSurface: targetSurfaceId,
221
- effect,
222
- data,
223
- },
224
- }));
225
- }
226
- }
package/a2ui/registry.js DELETED
@@ -1,200 +0,0 @@
1
- /**
2
- * A2UI Registry — maps A2UI type names to AdiaUI custom element tag names.
3
- *
4
- * Usage:
5
- * import { registry, resolveTag } from './registry.js';
6
- * resolveTag('Button') // → 'button-ui'
7
- * resolveTag('ChoicePicker') // → 'select-ui'
8
- * resolveTag('Toggle') // → 'switch-ui'
9
- */
10
-
11
- export const registry = new Map([
12
-
13
- // ══════════════════════════════════════════════════════
14
- // A2UI Protocol Types (standard catalog)
15
- // ══════════════════════════════════════════════════════
16
-
17
- // Layout
18
- ['Row', 'row-ui'],
19
- ['Column', 'col-ui'],
20
- ['List', 'list-ui'],
21
- ['Grid', 'grid-ui'],
22
- ['Stack', 'stack-ui'],
23
- ['Block', 'block-ui'],
24
-
25
- // Display
26
- ['Text', 'text-ui'],
27
- ['Image', 'image-ui'],
28
- ['Icon', 'icon-ui'],
29
- ['Divider', 'divider-ui'],
30
- ['Badge', 'badge-ui'],
31
- ['Avatar', 'avatar-ui'],
32
- ['AvatarGroup', 'avatar-group-ui'],
33
- ['Progress', 'progress-ui'],
34
- ['Skeleton', 'skeleton-ui'],
35
- ['Code', 'code-ui'],
36
- ['Stat', 'stat-ui'],
37
- ['EmptyState', 'empty-state-ui'],
38
-
39
- // Input
40
- ['Input', 'input-ui'],
41
- ['TextField', 'input-ui'],
42
- ['TextArea', 'textarea-ui'],
43
- ['CheckBox', 'check-ui'],
44
- ['Toggle', 'switch-ui'],
45
- ['Switch', 'switch-ui'],
46
- ['Slider', 'slider-ui'],
47
- ['Range', 'range-ui'],
48
- ['ChoicePicker', 'select-ui'],
49
- ['Select', 'select-ui'],
50
- ['Radio', 'radio-ui'],
51
- ['DateTimeInput', 'calendar-picker-ui'],
52
- ['CalendarPicker', 'calendar-picker-ui'],
53
- ['ColorPicker', 'color-picker-ui'],
54
- // Search deprecated — use Input type="search" prefix="magnifying-glass"
55
- ['Upload', 'upload-ui'],
56
- ['OtpInput', 'otp-input-ui'],
57
-
58
- // Action
59
- ['Button', 'button-ui'],
60
-
61
- // System State
62
- ['LoadingIndicator', 'progress-ui'],
63
- ['ErrorContainer', 'card-ui'],
64
-
65
- // Container
66
- ['Card', 'card-ui'],
67
- ['Tabs', 'tabs-ui'],
68
- ['Tab', 'tab-ui'],
69
- ['Panel', 'pane-ui'],
70
- ['Pane', 'pane-ui'],
71
- ['Modal', 'modal-ui'],
72
- ['Dialog', 'modal-ui'],
73
- ['Drawer', 'drawer-ui'],
74
- ['Toast', 'toast-ui'],
75
- ['Popover', 'popover-ui'],
76
- ['Accordion', 'accordion-ui'],
77
- ['AccordionItem', 'accordion-item-ui'],
78
- ['Alert', 'alert-ui'],
79
- ['Tooltip', 'tooltip-ui'],
80
- ['Menu', 'menu-ui'],
81
-
82
- // Card children (native HTML elements styled by card.css)
83
- ['Section', 'section'],
84
- ['Header', 'header'],
85
- ['Footer', 'footer'],
86
-
87
- // Agent / Specialized
88
- ['Stream', 'stream-ui'],
89
- ['Table', 'table-ui'],
90
- ['Chart', 'chart-ui'],
91
- ['Embed', 'embed-ui'],
92
- ['Swiper', 'swiper-ui'],
93
- ['Slideshow', 'swiper-ui'],
94
- ['Carousel', 'swiper-ui'],
95
-
96
- // Navigation
97
- ['Breadcrumb', 'breadcrumb-ui'],
98
- ['Nav', 'nav-n'],
99
- ['Noodles', 'noodles-ui'],
100
- ['Pagination', 'pagination-ui'],
101
- ['SegmentedControl', 'segmented-ui'],
102
- ['Segment', 'segment-ui'],
103
- ['ToggleGroup', 'toggle-group-ui'],
104
-
105
- // Utility
106
- ['Command', 'command-ui'],
107
- ['Kbd', 'kbd-ui'],
108
- ['Toolbar', 'toolbar-ui'],
109
- ['Tag', 'tag-ui'],
110
- ['Timeline', 'timeline-ui'],
111
- ['TimelineItem', 'timeline-item-ui'],
112
-
113
- // ══════════════════════════════════════════════════════
114
- // AgentUI Aliases (backwards compat with -ui tags)
115
- // ══════════════════════════════════════════════════════
116
- ['button-ui', 'button-ui'],
117
- ['card-ui', 'card-ui'],
118
- ['text-ui', 'text-ui'],
119
- ['input-ui', 'input-ui'],
120
- ['text-field-ui', 'input-ui'],
121
- ['select-ui', 'select-ui'],
122
- ['toggle-ui', 'switch-ui'],
123
- ['check-ui', 'check-ui'],
124
- ['slider-ui', 'slider-ui'],
125
- ['badge-ui', 'badge-ui'],
126
- ['avatar-ui', 'avatar-ui'],
127
- ['icon-ui', 'icon-ui'],
128
- ['image-ui', 'image-ui'],
129
- ['divider-ui', 'divider-ui'],
130
- ['progress-ui', 'progress-ui'],
131
- ['skeleton-ui', 'skeleton-ui'],
132
- ['tabs-ui', 'tabs-ui'],
133
- ['tab-ui', 'tab-ui'],
134
- ['modal-ui', 'modal-ui'],
135
- ['dialog-ui', 'modal-ui'],
136
- ['drawer-ui', 'drawer-ui'],
137
- ['toast-ui', 'toast-ui'],
138
- ['popover-ui', 'popover-ui'],
139
- ['panel-ui', 'pane-ui'],
140
- ['accordion-ui', 'accordion-ui'],
141
- ['alert-ui', 'alert-ui'],
142
- ['tooltip-ui', 'tooltip-ui'],
143
- ['menu-ui', 'menu-ui'],
144
- ['table-ui', 'table-ui'],
145
- ['chart-ui', 'chart-ui'],
146
- ['code-ui', 'code-ui'],
147
- ['textarea-ui', 'textarea-ui'],
148
- ['radio-ui', 'radio-ui'],
149
- ['tag-ui', 'tag-ui'],
150
- ['search-ui', 'search-ui'],
151
- ['upload-ui', 'upload-ui'],
152
- ['breadcrumb-ui', 'breadcrumb-ui'],
153
- ['nav-ui', 'nav-n'],
154
- ['noodles-ui', 'noodles-ui'],
155
- ['pagination-ui', 'pagination-ui'],
156
- ['segmented-control-ui', 'segmented-ui'],
157
- ['segment-ui', 'segment-ui'],
158
- ['command-ui', 'command-ui'],
159
- ['calendar-picker-ui', 'calendar-picker-ui'],
160
- ['color-picker-ui', 'color-picker-ui'],
161
- ['kbd-ui', 'kbd-ui'],
162
- ['toolbar-ui', 'toolbar-ui'],
163
- ['otp-input-ui', 'otp-input-ui'],
164
- ['embed-ui', 'embed-ui'],
165
- ['stream-ui', 'stream-ui'],
166
- ['row-ui', 'row-ui'],
167
- ['col-ui', 'col-ui'],
168
- ['grid-ui', 'grid-ui'],
169
- ['stack-ui', 'stack-ui'],
170
- ['block-ui', 'block-ui'],
171
- ['list-ui', 'list-ui'],
172
- ['range-ui', 'range-ui'],
173
- ['datetime-ui', 'calendar-picker-ui'],
174
- ['timeline-ui', 'timeline-ui'],
175
- ['timeline-item-ui', 'timeline-item-ui'],
176
- ['avatar-group-ui', 'avatar-group-ui'],
177
-
178
- // Aliases (alternate names)
179
- ['Keyboard', 'kbd-ui'],
180
- ['DatePicker', 'calendar-picker-ui'],
181
- ['CommandPalette', 'command-ui'],
182
- ['Segmented', 'segmented-ui'],
183
- ['OTP', 'otp-input-ui'],
184
- ]);
185
-
186
- /**
187
- * Resolve an A2UI component type to a AdiaUI tag name.
188
- * @param {string} type — A2UI type name or AgentUI tag
189
- * @returns {string|null} — AdiaUI tag name or null
190
- */
191
- export function resolveTag(type) {
192
- return registry.get(type) || null;
193
- }
194
-
195
- /**
196
- * Register a custom component type.
197
- */
198
- export function registerType(type, tagName) {
199
- registry.set(type, tagName);
200
- }