Skip to content

Commit c5ed201

Browse files
committed
docs: Align documentation with v0.9 specification
- Add 'fit' and 'variant' properties to Image component documentation. - Clarify 'updateDataModel' value optionality (omission implies deletion). - Add new 'Client-Side Functions' reference page and link it. - Mention client-side formatting in best practices.
1 parent 9d8a3ef commit c5ed201

File tree

5 files changed

+133
-2
lines changed

5 files changed

+133
-2
lines changed

docs/concepts/data-binding.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,3 +128,9 @@ Interactive components update the data model bidirectionally:
128128
```json
129129
{"price": "$19.99"} // Not: {"price": 19.99}
130130
```
131+
132+
**4. Use Client-Side Formatting** - For dynamic localization or complex updates, use client-side functions:
133+
```json
134+
{"text": {"call": "formatCurrency", "args": {"value": 19.99, "currency": "USD"}}}
135+
```
136+
See the **[Functions Reference](../reference/functions.md)** for a complete list of available functions.

docs/reference/components.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,18 @@ Display images from URLs.
6666
{
6767
"id": "logo",
6868
"component": "Image",
69-
"url": "https://example.com/logo.png"
69+
"url": "https://example.com/logo.png",
70+
"fit": "contain",
71+
"variant": "mediumFeature"
7072
}
7173
```
7274

75+
**Properties:**
76+
77+
- `url`: The URL of the image.
78+
- `fit`: CSS-like object-fit (`contain`, `cover`, `fill`, `none`, `scale-down`).
79+
- `variant`: Image style nuance (`icon`, `avatar`, `smallFeature`, `mediumFeature`, `largeFeature`, `header`).
80+
7381
### Icon
7482

7583
Display icons using Material Icons or custom icon sets.
@@ -308,5 +316,6 @@ This launches a live gallery with all components, their variations, and interact
308316
## Further Reading
309317

310318
- **[Standard Catalog Definition](../../specification/v0_9/json/standard_catalog_definition.json)**: Complete technical specification
319+
- **[Client-Side Functions](functions.md)**: Standard catalog functions for validation and formatting
311320
- **[Custom Components Guide](../guides/custom-components.md)**: Build your own components
312321
- **[Theming Guide](../guides/theming.md)**: Style components to match your brand

docs/reference/functions.md

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
# Client-Side Functions
2+
3+
This page documents the standard client-side functions available in the A2UI catalog. These functions can be used for data validation, string formatting, and logical operations within your UI definitions.
4+
5+
## Usage
6+
7+
Functions are invoked using the `FunctionCall` object structure:
8+
9+
```json
10+
{
11+
"call": "functionName",
12+
"args": {
13+
"arg1": "value1",
14+
"arg2": {"path": "/data/path"}
15+
}
16+
}
17+
```
18+
19+
## Validation Functions
20+
21+
These functions return a boolean and are primarily used in the `checks` property of input components.
22+
23+
### required
24+
Checks that the value is not null, undefined, or empty.
25+
- **args**:
26+
- `value`: The value to check.
27+
28+
### regex
29+
Checks that the value matches a regular expression string.
30+
- **args**:
31+
- `value`: The string to check.
32+
- `pattern`: The regex pattern to match against.
33+
34+
### length
35+
Checks string length constraints.
36+
- **args**:
37+
- `value`: The string to check.
38+
- `min` (optional): Minimum length.
39+
- `max` (optional): Maximum length.
40+
41+
### numeric
42+
Checks numeric range constraints.
43+
- **args**:
44+
- `value`: The number to check.
45+
- `min` (optional): Minimum value.
46+
- `max` (optional): Maximum value.
47+
48+
### email
49+
Checks that the value is a valid email address.
50+
- **args**:
51+
- `value`: The string to check.
52+
53+
## Formatting Functions
54+
55+
These functions return a formatted string and are often used in `Text` components or `formatString` calls.
56+
57+
### formatString
58+
Performs string interpolation.
59+
- **args**:
60+
- `value`: The format string containing `${expression}` placeholders.
61+
- **Usage**: `${formatString(value:'Hello ${/name}')}` or simply as a direct function call.
62+
63+
### formatNumber
64+
Formats a number with grouping and precision.
65+
- **args**:
66+
- `value`: The number to format.
67+
- `decimals` (optional): Number of decimal places.
68+
- `grouping` (optional): Whether to use grouping separators (default: true).
69+
70+
### formatCurrency
71+
Formats a number as a currency string.
72+
- **args**:
73+
- `value`: The amount.
74+
- `currency`: ISO 4217 currency code (e.g., 'USD').
75+
- `decimals` (optional): Number of decimal places.
76+
- `grouping` (optional): Whether to use grouping separators.
77+
78+
### formatDate
79+
Formats a timestamp using a pattern.
80+
- **args**:
81+
- `value`: The date/time to format.
82+
- `format`: Unicode TR35 date pattern (e.g., 'MMM dd, yyyy').
83+
84+
### pluralize
85+
Selects a localized string based on a count.
86+
- **args**:
87+
- `value`: The count.
88+
- `other`: Fallback string.
89+
- `zero`, `one`, `two`, `few`, `many` (optional): Category-specific strings.
90+
91+
## Logical Functions
92+
93+
Used to combine multiple boolean conditions.
94+
95+
### and
96+
Logical AND.
97+
- **args**:
98+
- `values`: Array of boolean values.
99+
100+
### or
101+
Logical OR.
102+
- **args**:
103+
- `values`: Array of boolean values.
104+
105+
### not
106+
Logical NOT.
107+
- **args**:
108+
- `value`: Boolean value to negate.
109+
110+
## Utility Functions
111+
112+
### openUrl
113+
Opens a URL in a browser or handler.
114+
- **args**:
115+
- `url`: The URL to open.

docs/reference/messages.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ Update the data model that components bind to.
182182
updateDataModel: {
183183
surfaceId: string; // Required: Target surface
184184
path?: string; // Optional: Path to update (defaults to root)
185-
value: any; // Required: Data to upsert (if not removing)
185+
value?: any; // Optional: Data to upsert (omission implies removal)
186186
}
187187
}
188188
```

mkdocs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ nav:
6666
- Reference:
6767
- Component Reference: reference/components.md
6868
- Message Reference: reference/messages.md
69+
- Client-Side Functions: reference/functions.md
6970

7071
exclude_docs: |
7172
scripts/**

0 commit comments

Comments
 (0)