Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 30 additions & 11 deletions docs/catalogs.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,24 +195,22 @@ This catalog imports all elements from the Basic Catalog and adds a new `Suggest

#### Example: Cherry-picking Components

This catalog imports only `Text` and `Icon` from the Basic Catalog to build a simple Popup surface.
This catalog imports only `Text` from the Basic Catalog to build a simple Popup surface.

```json
{
"$id": "https://github.com/.../hello_world_with_some_basic/v1/catalog.json",
"components": {
"allOf": [
{ "$ref": "basic_catalog_definition.json#/components/Text" },
{ "$ref": "basic_catalog_definition.json#/components/Icon" },
{ "$ref": "basic_catalog.json#/components/Text" },
{
"Popup": {
"type": "object",
"description": "A modal overlay that displays an icon and text.",
"properties": {
"text": { "$ref": "common_types.json#/$defs/ComponentId" },
"icon": { "$ref": "common_types.json#/$defs/ComponentId" }
"text": { "$ref": "common_types.json#/$defs/ComponentId" }
},
"required": [ "text", "icon" ]
"required": [ "text" ]
}
}
]
Expand All @@ -226,7 +224,7 @@ This catalog imports only `Text` and `Icon` from the Basic Catalog to build a si

Client renderers implement the catalog by mapping the schema definition to actual code.

[Example Rizzcharts typescript renderer for the hello world catalog](../samples/client/angular/projects/rizzcharts/src/a2ui-catalog/catalog.ts).
Example typescript renderer for the hello world catalog

```typescript
import { Catalog, DEFAULT_CATALOG } from '@a2ui/angular';
Expand All @@ -237,13 +235,35 @@ export const RIZZ_CHARTS_CATALOG = {
HelloWorldBanner: {
type: () => import('./hello_world_banner').then((r) => r.HelloWorldBanner),
bindings: ({ properties }) => [
inputBinding('message', () => ('message' in properties && properties['message']) || undefined),
inputBinding('backgroundColor', () => ('backgroundColor' in properties && properties['backgroundColor']) || undefined),
inputBinding('message', () => ('message' in properties && properties['message']) || undefined)
Comment on lines 237 to +238
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This change removes the backgroundColor binding, which aligns with the new HelloWorldBanner component implementation. However, the catalog definition for HelloWorldBanner shown earlier in this document (lines 101-118) still defines a backgroundColor property. To ensure the documentation is consistent, the backgroundColor property should also be removed from the JSON schema example for HelloWorldBanner.

],
},
} as Catalog;
```

and the hello_world_banner implementation

```typescript
import { DynamicComponent } from '@a2ui/angular';
import { Component, Input } from '@angular/core';

@Component({
selector: 'hello-world-banner',
imports: [],
template: `
<div>
<h2>Hello World Banner</h2>
<p>{{ message }}</p>
</div>
`,
})
Comment on lines +250 to +259
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The Angular component example is missing standalone: true in the @Component decorator. The imports property is used for standalone components, so standalone: true should be added for this to be a valid standalone component example. The empty imports: [] can also be removed for brevity.

Suggested change
@Component({
selector: 'hello-world-banner',
imports: [],
template: `
<div>
<h2>Hello World Banner</h2>
<p>{{ message }}</p>
</div>
`,
})
@Component({
standalone: true,
selector: 'hello-world-banner',
template: `
<div>
<h2>Hello World Banner</h2>
<p>{{ message }}</p>
</div>
`,
})

export class HelloWorldBanner extends DynamicComponent {
@Input() message?: string;
}
```

You can see a working example of a client renderer in the [Rizzcharts demo](../samples/client/angular/projects/rizzcharts/src/a2ui-catalog/catalog.ts).

## A2UI Catalog Negotiation

Because clients and agents can support multiple catalogs, they must agree on which catalog to use through a catalog negotiation handshake.
Expand Down Expand Up @@ -404,5 +424,4 @@ Example of client reporting a missing required field

## Inline Catalogs

Inline catalogs sent by the client at runtime are supported but not recommended in production. More details about them can be found [here](../specification/v0_9/docs/a2ui_protocol.md#client-capabilities--metadata).

Inline catalogs sent by the client at runtime are supported but not recommended in production. More details about them can be found [here](../specification/v0_9/docs/a2ui_protocol.md#client-capabilities--metadata).
Loading