@easyops-cn/a2ui-react 0.0.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/.claude/commands/speckit.analyze.md +184 -0
- package/.claude/commands/speckit.checklist.md +294 -0
- package/.claude/commands/speckit.clarify.md +181 -0
- package/.claude/commands/speckit.constitution.md +82 -0
- package/.claude/commands/speckit.implement.md +135 -0
- package/.claude/commands/speckit.plan.md +89 -0
- package/.claude/commands/speckit.specify.md +256 -0
- package/.claude/commands/speckit.tasks.md +137 -0
- package/.claude/commands/speckit.taskstoissues.md +30 -0
- package/.github/workflows/deploy.yml +69 -0
- package/.husky/pre-commit +1 -0
- package/.prettierignore +4 -0
- package/.prettierrc +7 -0
- package/.specify/memory/constitution.md +73 -0
- package/.specify/scripts/bash/check-prerequisites.sh +166 -0
- package/.specify/scripts/bash/common.sh +156 -0
- package/.specify/scripts/bash/create-new-feature.sh +297 -0
- package/.specify/scripts/bash/setup-plan.sh +61 -0
- package/.specify/scripts/bash/update-agent-context.sh +799 -0
- package/.specify/templates/agent-file-template.md +28 -0
- package/.specify/templates/checklist-template.md +40 -0
- package/.specify/templates/plan-template.md +105 -0
- package/.specify/templates/spec-template.md +115 -0
- package/.specify/templates/tasks-template.md +250 -0
- package/CLAUDE.md +105 -0
- package/CONTRIBUTING.md +97 -0
- package/README.md +126 -0
- package/components.json +21 -0
- package/eslint.config.js +25 -0
- package/netlify.toml +50 -0
- package/package.json +94 -0
- package/playground/README.md +75 -0
- package/playground/index.html +22 -0
- package/playground/package.json +32 -0
- package/playground/public/favicon.svg +8 -0
- package/playground/src/App.css +256 -0
- package/playground/src/App.tsx +115 -0
- package/playground/src/assets/react.svg +1 -0
- package/playground/src/components/ErrorDisplay.tsx +13 -0
- package/playground/src/components/ExampleSelector.tsx +64 -0
- package/playground/src/components/Header.tsx +47 -0
- package/playground/src/components/JsonEditor.tsx +32 -0
- package/playground/src/components/Preview.tsx +78 -0
- package/playground/src/components/ThemeToggle.tsx +19 -0
- package/playground/src/data/examples.ts +1571 -0
- package/playground/src/hooks/useTheme.ts +55 -0
- package/playground/src/index.css +220 -0
- package/playground/src/main.tsx +10 -0
- package/playground/tsconfig.app.json +34 -0
- package/playground/tsconfig.json +13 -0
- package/playground/tsconfig.node.json +26 -0
- package/playground/vite.config.ts +31 -0
- package/specs/001-a2ui-renderer/checklists/requirements.md +41 -0
- package/specs/001-a2ui-renderer/data-model.md +140 -0
- package/specs/001-a2ui-renderer/plan.md +123 -0
- package/specs/001-a2ui-renderer/quickstart.md +141 -0
- package/specs/001-a2ui-renderer/research.md +140 -0
- package/specs/001-a2ui-renderer/spec.md +165 -0
- package/specs/001-a2ui-renderer/tasks.md +310 -0
- package/specs/002-playground/checklists/requirements.md +37 -0
- package/specs/002-playground/contracts/components.md +120 -0
- package/specs/002-playground/data-model.md +149 -0
- package/specs/002-playground/plan.md +73 -0
- package/specs/002-playground/quickstart.md +158 -0
- package/specs/002-playground/research.md +117 -0
- package/specs/002-playground/spec.md +109 -0
- package/specs/002-playground/tasks.md +224 -0
- package/src/0.8/A2UIRender.test.tsx +793 -0
- package/src/0.8/A2UIRender.tsx +142 -0
- package/src/0.8/components/ComponentRenderer.test.tsx +373 -0
- package/src/0.8/components/ComponentRenderer.tsx +163 -0
- package/src/0.8/components/UnknownComponent.tsx +49 -0
- package/src/0.8/components/display/AudioPlayerComponent.tsx +37 -0
- package/src/0.8/components/display/DividerComponent.tsx +23 -0
- package/src/0.8/components/display/IconComponent.tsx +137 -0
- package/src/0.8/components/display/ImageComponent.tsx +57 -0
- package/src/0.8/components/display/TextComponent.tsx +56 -0
- package/src/0.8/components/display/VideoComponent.tsx +31 -0
- package/src/0.8/components/display/display.test.tsx +660 -0
- package/src/0.8/components/display/index.ts +10 -0
- package/src/0.8/components/index.ts +14 -0
- package/src/0.8/components/interactive/ButtonComponent.tsx +44 -0
- package/src/0.8/components/interactive/CheckBoxComponent.tsx +45 -0
- package/src/0.8/components/interactive/DateTimeInputComponent.tsx +176 -0
- package/src/0.8/components/interactive/MultipleChoiceComponent.tsx +157 -0
- package/src/0.8/components/interactive/SliderComponent.tsx +53 -0
- package/src/0.8/components/interactive/TextFieldComponent.tsx +65 -0
- package/src/0.8/components/interactive/index.ts +10 -0
- package/src/0.8/components/interactive/interactive.test.tsx +618 -0
- package/src/0.8/components/layout/CardComponent.tsx +30 -0
- package/src/0.8/components/layout/ColumnComponent.tsx +93 -0
- package/src/0.8/components/layout/ListComponent.tsx +81 -0
- package/src/0.8/components/layout/ModalComponent.tsx +41 -0
- package/src/0.8/components/layout/RowComponent.tsx +94 -0
- package/src/0.8/components/layout/TabsComponent.tsx +59 -0
- package/src/0.8/components/layout/index.ts +10 -0
- package/src/0.8/components/layout/layout.test.tsx +558 -0
- package/src/0.8/contexts/A2UIProvider.test.tsx +226 -0
- package/src/0.8/contexts/A2UIProvider.tsx +54 -0
- package/src/0.8/contexts/ActionContext.test.tsx +242 -0
- package/src/0.8/contexts/ActionContext.tsx +105 -0
- package/src/0.8/contexts/ComponentsMapContext.tsx +125 -0
- package/src/0.8/contexts/DataModelContext.test.tsx +335 -0
- package/src/0.8/contexts/DataModelContext.tsx +184 -0
- package/src/0.8/contexts/SurfaceContext.test.tsx +339 -0
- package/src/0.8/contexts/SurfaceContext.tsx +197 -0
- package/src/0.8/hooks/useA2UIMessageHandler.test.tsx +399 -0
- package/src/0.8/hooks/useA2UIMessageHandler.ts +123 -0
- package/src/0.8/hooks/useComponent.test.tsx +148 -0
- package/src/0.8/hooks/useComponent.ts +39 -0
- package/src/0.8/hooks/useDataBinding.test.tsx +334 -0
- package/src/0.8/hooks/useDataBinding.ts +99 -0
- package/src/0.8/hooks/useDispatchAction.test.tsx +83 -0
- package/src/0.8/hooks/useDispatchAction.ts +35 -0
- package/src/0.8/hooks/useSurface.test.tsx +114 -0
- package/src/0.8/hooks/useSurface.ts +34 -0
- package/src/0.8/index.ts +38 -0
- package/src/0.8/schemas/client_to_server.json +50 -0
- package/src/0.8/schemas/server_to_client.json +148 -0
- package/src/0.8/schemas/standard_catalog_definition.json +661 -0
- package/src/0.8/types/index.ts +448 -0
- package/src/0.8/utils/dataBinding.test.ts +443 -0
- package/src/0.8/utils/dataBinding.ts +212 -0
- package/src/0.8/utils/pathUtils.test.ts +353 -0
- package/src/0.8/utils/pathUtils.ts +200 -0
- package/src/components/ui/button.tsx +62 -0
- package/src/components/ui/calendar.tsx +220 -0
- package/src/components/ui/card.tsx +92 -0
- package/src/components/ui/checkbox.tsx +30 -0
- package/src/components/ui/dialog.tsx +141 -0
- package/src/components/ui/input.tsx +21 -0
- package/src/components/ui/label.tsx +22 -0
- package/src/components/ui/native-select.tsx +53 -0
- package/src/components/ui/popover.tsx +46 -0
- package/src/components/ui/select.tsx +188 -0
- package/src/components/ui/separator.tsx +26 -0
- package/src/components/ui/slider.tsx +61 -0
- package/src/components/ui/tabs.tsx +64 -0
- package/src/components/ui/textarea.tsx +18 -0
- package/src/index.ts +1 -0
- package/src/lib/utils.ts +6 -0
- package/tsconfig.json +28 -0
- package/vite.config.ts +29 -0
- package/vitest.config.ts +22 -0
- package/vitest.setup.ts +8 -0
- package/website/README.md +4 -0
- package/website/assets/favicon.svg +8 -0
- package/website/content/.gitkeep +0 -0
- package/website/content/index.md +122 -0
- package/website/global.d.ts +9 -0
- package/website/package.json +17 -0
- package/website/plain.config.js +28 -0
- package/website/serve.json +6 -0
- package/website/src/client/color-mode-switch.css +47 -0
- package/website/src/client/index.js +61 -0
- package/website/src/client/moon.svg +1 -0
- package/website/src/client/sun.svg +1 -0
- package/website/src/components/Footer.jsx +9 -0
- package/website/src/components/Header.jsx +44 -0
- package/website/src/components/Page.jsx +28 -0
- package/website/src/global.css +423 -0
package/src/0.8/index.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A2UI React Renderer - Public API
|
|
3
|
+
*
|
|
4
|
+
* This is the main entry point for the A2UI React renderer library.
|
|
5
|
+
* Import from '@easyops-cn/a2ui-react/0.8'
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* import { A2UIRender, A2UIMessage, A2UIAction } from '@easyops-cn/a2ui-react/0.8'
|
|
10
|
+
*
|
|
11
|
+
* function App() {
|
|
12
|
+
* const messages: A2UIMessage[] = [...]
|
|
13
|
+
* const handleAction = (action: A2UIAction) => {
|
|
14
|
+
* console.log('Action:', action)
|
|
15
|
+
* }
|
|
16
|
+
* return <A2UIRender messages={messages} onAction={handleAction} />
|
|
17
|
+
* }
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
// ============ Types ============
|
|
22
|
+
|
|
23
|
+
export type {
|
|
24
|
+
A2UIMessage,
|
|
25
|
+
ActionPayload as A2UIAction,
|
|
26
|
+
Action,
|
|
27
|
+
ValueSource,
|
|
28
|
+
} from './types'
|
|
29
|
+
|
|
30
|
+
// ============ Components ============
|
|
31
|
+
|
|
32
|
+
export { A2UIRender } from './A2UIRender'
|
|
33
|
+
export { ComponentRenderer } from './components/ComponentRenderer'
|
|
34
|
+
|
|
35
|
+
// ============ Hooks ============
|
|
36
|
+
|
|
37
|
+
export { useDispatchAction } from './hooks/useDispatchAction'
|
|
38
|
+
export { useDataBinding, useFormBinding } from './hooks/useDataBinding'
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "A2UI (Agent to UI) Client-to-Server Event Schema",
|
|
3
|
+
"description": "Describes a JSON payload for a client-to-server event message.",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"minProperties": 1,
|
|
6
|
+
"maxProperties": 1,
|
|
7
|
+
"properties": {
|
|
8
|
+
"userAction": {
|
|
9
|
+
"type": "object",
|
|
10
|
+
"description": "Reports a user-initiated action from a component.",
|
|
11
|
+
"properties": {
|
|
12
|
+
"name": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "The name of the action, taken from the component's action.name property."
|
|
15
|
+
},
|
|
16
|
+
"surfaceId": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "The id of the surface where the event originated."
|
|
19
|
+
},
|
|
20
|
+
"sourceComponentId": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "The id of the component that triggered the event."
|
|
23
|
+
},
|
|
24
|
+
"timestamp": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"format": "date-time",
|
|
27
|
+
"description": "An ISO 8601 timestamp of when the event occurred."
|
|
28
|
+
},
|
|
29
|
+
"context": {
|
|
30
|
+
"type": "object",
|
|
31
|
+
"description": "A JSON object containing the key-value pairs from the component's action.context, after resolving all data bindings.",
|
|
32
|
+
"additionalProperties": true
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"required": [
|
|
36
|
+
"name",
|
|
37
|
+
"surfaceId",
|
|
38
|
+
"sourceComponentId",
|
|
39
|
+
"timestamp",
|
|
40
|
+
"context"
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
"error": {
|
|
44
|
+
"type": "object",
|
|
45
|
+
"description": "Reports a client-side error. The content is flexible.",
|
|
46
|
+
"additionalProperties": true
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"oneOf": [{ "required": ["userAction"] }, { "required": ["error"] }]
|
|
50
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
{
|
|
2
|
+
"title": "A2UI Message Schema",
|
|
3
|
+
"description": "Describes a JSON payload for an A2UI (Agent to UI) message, which is used to dynamically construct and update user interfaces. A message MUST contain exactly ONE of the action properties: 'beginRendering', 'surfaceUpdate', 'dataModelUpdate', or 'deleteSurface'.",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"additionalProperties": false,
|
|
6
|
+
"properties": {
|
|
7
|
+
"beginRendering": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"description": "Signals the client to begin rendering a surface with a root component and specific styles.",
|
|
10
|
+
"additionalProperties": false,
|
|
11
|
+
"properties": {
|
|
12
|
+
"surfaceId": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "The unique identifier for the UI surface to be rendered."
|
|
15
|
+
},
|
|
16
|
+
"catalogId": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "The identifier of the component catalog to use for this surface. If omitted, the client MUST default to the standard catalog for this A2UI version (a2ui.org:standard_catalog_0_8_0)."
|
|
19
|
+
},
|
|
20
|
+
"root": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "The ID of the root component to render."
|
|
23
|
+
},
|
|
24
|
+
"styles": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"description": "Styling information for the UI.",
|
|
27
|
+
"additionalProperties": true
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"required": ["root", "surfaceId"]
|
|
31
|
+
},
|
|
32
|
+
"surfaceUpdate": {
|
|
33
|
+
"type": "object",
|
|
34
|
+
"description": "Updates a surface with a new set of components.",
|
|
35
|
+
"additionalProperties": false,
|
|
36
|
+
"properties": {
|
|
37
|
+
"surfaceId": {
|
|
38
|
+
"type": "string",
|
|
39
|
+
"description": "The unique identifier for the UI surface to be updated. If you are adding a new surface this *must* be a new, unique identified that has never been used for any existing surfaces shown."
|
|
40
|
+
},
|
|
41
|
+
"components": {
|
|
42
|
+
"type": "array",
|
|
43
|
+
"description": "A list containing all UI components for the surface.",
|
|
44
|
+
"minItems": 1,
|
|
45
|
+
"items": {
|
|
46
|
+
"type": "object",
|
|
47
|
+
"description": "Represents a *single* component in a UI widget tree. This component could be one of many supported types.",
|
|
48
|
+
"additionalProperties": false,
|
|
49
|
+
"properties": {
|
|
50
|
+
"id": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"description": "The unique identifier for this component."
|
|
53
|
+
},
|
|
54
|
+
"weight": {
|
|
55
|
+
"type": "number",
|
|
56
|
+
"description": "The relative weight of this component within a Row or Column. This corresponds to the CSS 'flex-grow' property. Note: this may ONLY be set when the component is a direct descendant of a Row or Column."
|
|
57
|
+
},
|
|
58
|
+
"component": {
|
|
59
|
+
"type": "object",
|
|
60
|
+
"description": "A wrapper object that MUST contain exactly one key, which is the name of the component type. The value is an object containing the properties for that specific component.",
|
|
61
|
+
"additionalProperties": true
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
"required": ["id", "component"]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"required": ["surfaceId", "components"]
|
|
69
|
+
},
|
|
70
|
+
"dataModelUpdate": {
|
|
71
|
+
"type": "object",
|
|
72
|
+
"description": "Updates the data model for a surface.",
|
|
73
|
+
"additionalProperties": false,
|
|
74
|
+
"properties": {
|
|
75
|
+
"surfaceId": {
|
|
76
|
+
"type": "string",
|
|
77
|
+
"description": "The unique identifier for the UI surface this data model update applies to."
|
|
78
|
+
},
|
|
79
|
+
"path": {
|
|
80
|
+
"type": "string",
|
|
81
|
+
"description": "An optional path to a location within the data model (e.g., '/user/name'). If omitted, or set to '/', the entire data model will be replaced."
|
|
82
|
+
},
|
|
83
|
+
"contents": {
|
|
84
|
+
"type": "array",
|
|
85
|
+
"description": "An array of data entries. Each entry must contain a 'key' and exactly one corresponding typed 'value*' property.",
|
|
86
|
+
"items": {
|
|
87
|
+
"type": "object",
|
|
88
|
+
"description": "A single data entry. Exactly one 'value*' property should be provided alongside the key.",
|
|
89
|
+
"additionalProperties": false,
|
|
90
|
+
"properties": {
|
|
91
|
+
"key": {
|
|
92
|
+
"type": "string",
|
|
93
|
+
"description": "The key for this data entry."
|
|
94
|
+
},
|
|
95
|
+
"valueString": {
|
|
96
|
+
"type": "string"
|
|
97
|
+
},
|
|
98
|
+
"valueNumber": {
|
|
99
|
+
"type": "number"
|
|
100
|
+
},
|
|
101
|
+
"valueBoolean": {
|
|
102
|
+
"type": "boolean"
|
|
103
|
+
},
|
|
104
|
+
"valueMap": {
|
|
105
|
+
"description": "Represents a map as an adjacency list.",
|
|
106
|
+
"type": "array",
|
|
107
|
+
"items": {
|
|
108
|
+
"type": "object",
|
|
109
|
+
"description": "One entry in the map. Exactly one 'value*' property should be provided alongside the key.",
|
|
110
|
+
"additionalProperties": false,
|
|
111
|
+
"properties": {
|
|
112
|
+
"key": {
|
|
113
|
+
"type": "string"
|
|
114
|
+
},
|
|
115
|
+
"valueString": {
|
|
116
|
+
"type": "string"
|
|
117
|
+
},
|
|
118
|
+
"valueNumber": {
|
|
119
|
+
"type": "number"
|
|
120
|
+
},
|
|
121
|
+
"valueBoolean": {
|
|
122
|
+
"type": "boolean"
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
"required": ["key"]
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"required": ["key"]
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"required": ["contents", "surfaceId"]
|
|
134
|
+
},
|
|
135
|
+
"deleteSurface": {
|
|
136
|
+
"type": "object",
|
|
137
|
+
"description": "Signals the client to delete the surface identified by 'surfaceId'.",
|
|
138
|
+
"additionalProperties": false,
|
|
139
|
+
"properties": {
|
|
140
|
+
"surfaceId": {
|
|
141
|
+
"type": "string",
|
|
142
|
+
"description": "The unique identifier for the UI surface to be deleted."
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
"required": ["surfaceId"]
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|