通用属性参考:通用属性
Box 组件作为容器,用于管理 Card 实例和命令分发。
| 属性 | 说明 | 类型 | 默认值 | 版本 |
|---|---|---|---|---|
| children | 子元素 | React.ReactNode | - | - |
| components | 自定义组件映射,组件名称必须以大写字母开头 | Record<string, React.ComponentType<any>> | - | - |
| commands | A2UI 命令对象 | A2UICommand_v0_9 | XAgentCommand_v0_8 | - | - |
| onAction | Card 内部组件触发 action 时的回调函数 | (payload: ActionPayload) => void | - | - |
Card 组件用于渲染单个 Surface。
| 属性 | 说明 | 类型 | 默认值 | 版本 |
|---|---|---|---|---|
| id | Surface ID,对应命令中的 surfaceId | string | - | - |
action 事件的数据结构。
| 属性 | 说明 | 类型 | 默认值 | 版本 |
|---|---|---|---|---|
| name | 事件名称 | string | - | - |
| surfaceId | 触发该 action 的 surfaceId | string | - | - |
| context | 当前 surface 的完整 dataModel 快照 | Record<string, any> | - | - |
v0.9 版本的命令类型,支持以下命令:
创建新的 Surface。
| 属性 | 说明 | 类型 | 默认值 | 版本 |
|---|---|---|---|---|
| version | 版本号 | 'v0.9' | - | - |
| createSurface.surfaceId | Surface ID | string | - | - |
| createSurface.catalogId | 组件目录 URL 或本地标识 | string | - | - |
更新 Surface 上的组件。
| 属性 | 说明 | 类型 | 默认值 | 版本 |
|---|---|---|---|---|
| version | 版本号 | 'v0.9' | - | - |
| updateComponents.surfaceId | Surface ID | string | - | - |
| updateComponents.components | 组件列表 | BaseComponent_v0_9[] | - | - |
interface BaseComponent_v0_9 {id: string;component: string;child?: string;children?: string[];[key: string]: any | PathValue;}
更新数据模型。
| 属性 | 说明 | 类型 | 默认值 | 版本 |
|---|---|---|---|---|
| version | 版本号 | 'v0.9' | - | - |
| updateDataModel.surfaceId | Surface ID | string | - | - |
| updateDataModel.path | 数据路径 | string | - | - |
| updateDataModel.value | 数据值 | any | - | - |
删除 Surface。
| 属性 | 说明 | 类型 | 默认值 | 版本 |
|---|---|---|---|---|
| version | 版本号 | 'v0.9' | - | - |
| deleteSurface.surfaceId | Surface ID | string | - | - |
数据绑定路径对象。
interface PathValue {path: string;}
组件目录定义。
interface Catalog {$schema?: string;$id?: string;title?: string;description?: string;catalogId?: string;components?: Record<string, CatalogComponent>;functions?: Record<string, any>;$defs?: Record<string, any>;}
Catalog 中的组件定义。
interface CatalogComponent {type: 'object';allOf?: any[];properties?: Record<string, any>;required?: string[];[key: string]: any;}
注册本地 catalog。
registerCatalog(catalog: Catalog): void
加载 catalog(支持远程 URL 或本地注册的 schema)。
loadCatalog(catalogId: string): Promise<Catalog>
验证组件是否符合 catalog 定义。
validateComponent(catalog: Catalog, componentName: string, componentProps: Record<string, any>): boolean
清除 catalog 缓存。
clearCatalogCache(): void