Common props ref: Common Props
Box component serves as a container to manage Card instances and command dispatching.
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| children | Child elements | React.ReactNode | - | - |
| components | Custom component mapping, component names must start with uppercase letters | Record<string, React.ComponentType<any>> | - | - |
| commands | A2UI command object | A2UICommand_v0_9 | XAgentCommand_v0_8 | - | - |
| onAction | Callback function when action is triggered inside Card | (payload: ActionPayload) => void | - | - |
Card component is used to render a single Surface.
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| id | Surface ID, corresponding to surfaceId in commands | string | - | - |
Data structure for action events.
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| name | Event name | string | - | - |
| surfaceId | The surfaceId that triggered the action | string | - | - |
| context | Context passed by component, with path references resolved | Record<string, any> | - | - |
When a component triggers an action, X-Card automatically resolves path references in the context to actual values.
Use { path: string } format to bind values from dataModel in action configuration:
{"id": "submit-btn","component": "Button","action": {"event": {"name": "agent:send_context_text","context": {"username": { "path": "/form/username", "label": "Username" },"email": { "path": "/form/email", "label": "Email" }}}}}
When user clicks the button to trigger action, the context received by onAction callback is automatically resolved:
{"username": { "value": "John", "label": "Username" },"email": { "value": "john@example.com", "label": "Email" }}
Note:
{ path: "xxx" } format in the context are converted{ value: "actual_value" }) are not incorrectly convertedCommand type for v0.9 version, supporting the following commands:
Create a new Surface.
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| version | Version number | 'v0.9' | - | - |
| createSurface.surfaceId | Surface ID | string | - | - |
| createSurface.catalogId | Component catalog URL or local identifier | string | - | - |
Update components on a Surface.
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| version | Version number | 'v0.9' | - | - |
| updateComponents.surfaceId | Surface ID | string | - | - |
| updateComponents.components | Component list | BaseComponent_v0_9[] | - | - |
interface BaseComponent_v0_9 {id: string;component: string;child?: string;children?: string[];[key: string]: any | PathValue;}
Update data model.
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| version | Version number | 'v0.9' | - | - |
| updateDataModel.surfaceId | Surface ID | string | - | - |
| updateDataModel.path | Data path | string | - | - |
| updateDataModel.value | Data value | any | - | - |
Delete a Surface.
| Property | Description | Type | Default | Version |
|---|---|---|---|---|
| version | Version number | 'v0.9' | - | - |
| deleteSurface.surfaceId | Surface ID | string | - | - |
Data binding path object.
interface PathValue {path: string;}
Component catalog definition.
interface Catalog {$schema?: string;$id?: string;title?: string;description?: string;catalogId?: string;components?: Record<string, CatalogComponent>;functions?: Record<string, any>;$defs?: Record<string, any>;}
Component definition in Catalog.
interface CatalogComponent {type: 'object';allOf?: any[];properties?: Record<string, any>;required?: string[];[key: string]: any;}
Register a local catalog.
registerCatalog(catalog: Catalog): void
Load a catalog (supports remote URL or locally registered schema).
loadCatalog(catalogId: string): Promise<Catalog>
Validate whether a component conforms to catalog definition.
validateComponent(catalog: Catalog, componentName: string, componentProps: Record<string, any>): boolean
Clear catalog cache.
clearCatalogCache(): void