@xds/a2ui-react 0.0.0-stage → 1.0.0-rc.1
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/LICENSE +21 -0
- package/README.md +16 -2
- package/dist/basic.d.ts +75 -0
- package/dist/basic.js +203 -0
- package/dist/cases.d.ts +70 -0
- package/dist/cases.js +958 -0
- package/dist/generated/catalogs.d.ts +365 -0
- package/dist/generated/catalogs.js +1886 -0
- package/dist/implementations.d.ts +22 -0
- package/dist/implementations.js +108 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +18 -0
- package/dist/preview.d.ts +23 -0
- package/dist/preview.js +41 -0
- package/package.json +47 -4
- package/styles.css +150 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 kjmin-dev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @xds/a2ui-react
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The xds design system as an [A2UI](https://a2ui.org) catalog: the surfaces an agent sends are drawn with the components of `@xds/react`, in the app's theme.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @xds/a2ui-react@preview @xds/react@preview @a2ui/react @a2ui/web_core zod
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import "@xds/react/styles.css";
|
|
11
|
+
import "@xds/a2ui-react/styles.css";
|
|
12
|
+
import { xdsBasicCatalog, xdsCatalog, xdsPointerCatalog } from "@xds/a2ui-react";
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Register the catalogs with A2UI's `MessageProcessor`, beside its basic catalog, and draw each surface with `A2uiSurface`. The stylesheet gives the basic catalog's components the app's colors, type and spacing. `xdsBasicCatalog`, registered in place of `basicCatalog`, draws the basic catalog's components with the xds components, for an agent that knows only the basic catalog.
|
|
16
|
+
|
|
17
|
+
This package is a preview, as A2UI's renderers are. See [the guide](https://github.com/kjmin-dev/xds/blob/main/docs/a2ui-react.md).
|
package/dist/basic.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { type ReactCatalogComponent } from "@a2ui/react";
|
|
2
|
+
/**
|
|
3
|
+
* The basic catalog's icons as xds draws them. Every name of the basic catalog has one, so an
|
|
4
|
+
* icon an agent names is never left out; an icon given as `svgPath` is the agent's own drawing,
|
|
5
|
+
* which the xds icons do not take.
|
|
6
|
+
*/
|
|
7
|
+
export declare const BASIC_ICONS: {
|
|
8
|
+
readonly accountCircle: "circle-user";
|
|
9
|
+
readonly add: "plus";
|
|
10
|
+
readonly arrowBack: "arrow-left";
|
|
11
|
+
readonly arrowForward: "arrow-right";
|
|
12
|
+
readonly attachFile: "paperclip";
|
|
13
|
+
readonly calendarToday: "calendar";
|
|
14
|
+
readonly call: "phone";
|
|
15
|
+
readonly camera: "camera";
|
|
16
|
+
readonly check: "check";
|
|
17
|
+
readonly close: "x";
|
|
18
|
+
readonly delete: "trash";
|
|
19
|
+
readonly download: "download";
|
|
20
|
+
readonly edit: "pencil";
|
|
21
|
+
readonly event: "calendar";
|
|
22
|
+
readonly error: "circle-alert";
|
|
23
|
+
readonly fastForward: "fast-forward";
|
|
24
|
+
readonly favorite: "heart";
|
|
25
|
+
readonly favoriteOff: "heart-off";
|
|
26
|
+
readonly folder: "folder";
|
|
27
|
+
readonly help: "circle-help";
|
|
28
|
+
readonly home: "house";
|
|
29
|
+
readonly info: "info";
|
|
30
|
+
readonly locationOn: "map-pin";
|
|
31
|
+
readonly lock: "lock";
|
|
32
|
+
readonly lockOpen: "lock-open";
|
|
33
|
+
readonly mail: "mail";
|
|
34
|
+
readonly menu: "menu";
|
|
35
|
+
readonly moreHoriz: "ellipsis";
|
|
36
|
+
readonly moreVert: "ellipsis-vertical";
|
|
37
|
+
readonly notifications: "bell";
|
|
38
|
+
readonly notificationsOff: "bell-off";
|
|
39
|
+
readonly pause: "pause";
|
|
40
|
+
readonly payment: "credit-card";
|
|
41
|
+
readonly person: "user";
|
|
42
|
+
readonly phone: "smartphone";
|
|
43
|
+
readonly photo: "image";
|
|
44
|
+
readonly play: "play";
|
|
45
|
+
readonly print: "printer";
|
|
46
|
+
readonly refresh: "rotate-cw";
|
|
47
|
+
readonly rewind: "rewind";
|
|
48
|
+
readonly search: "search";
|
|
49
|
+
readonly send: "send";
|
|
50
|
+
readonly settings: "settings";
|
|
51
|
+
readonly share: "share-2";
|
|
52
|
+
readonly shoppingCart: "shopping-cart";
|
|
53
|
+
readonly skipNext: "skip-forward";
|
|
54
|
+
readonly skipPrevious: "skip-back";
|
|
55
|
+
readonly star: "star";
|
|
56
|
+
readonly starHalf: "star-half";
|
|
57
|
+
readonly starOff: "star-off";
|
|
58
|
+
readonly stop: "square";
|
|
59
|
+
readonly upload: "upload";
|
|
60
|
+
readonly visibility: "eye";
|
|
61
|
+
readonly visibilityOff: "eye-off";
|
|
62
|
+
readonly volumeDown: "volume-1";
|
|
63
|
+
readonly volumeMute: "volume";
|
|
64
|
+
readonly volumeOff: "volume-x";
|
|
65
|
+
readonly volumeUp: "volume-2";
|
|
66
|
+
readonly warning: "triangle-alert";
|
|
67
|
+
};
|
|
68
|
+
/** The names of the basic catalog's components that xds draws, and of those it leaves to A2UI. */
|
|
69
|
+
export declare const BASIC_DRAWN: string[];
|
|
70
|
+
export declare const BASIC_KEPT: string[];
|
|
71
|
+
/**
|
|
72
|
+
* A2UI's basic catalog, with xds drawing every component it has a counterpart for. Register it
|
|
73
|
+
* in place of `basicCatalog`, never beside it: both have the basic catalog's ID.
|
|
74
|
+
*/
|
|
75
|
+
export declare const xdsBasicCatalog: import("@a2ui/web_core").Catalog<ReactCatalogComponent, import("@a2ui/web_core").FunctionImplementation>;
|
package/dist/basic.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createComponentImplementation, MarkdownComponentContext, } from "@a2ui/react";
|
|
3
|
+
import { sanitizeMediaUrl } from "@a2ui/web_core";
|
|
4
|
+
import { basicCatalog, ButtonApi, CardApi, CheckBoxApi, ChoicePickerApi, DateTimeInputApi, DividerApi, IconApi, ImageApi, ModalApi, SliderApi, TabsApi, TextApi, TextFieldApi, } from "@a2ui/web_core/catalogs/basic/v1";
|
|
5
|
+
import { Avatar, Button, Card, Checkbox, Chip, ChipBar, DatePicker, Dialog, Divider, Icon, RadioGroup, SearchField, Slider, Tabs, Text, TextField, Thumbnail, } from "@xds/react";
|
|
6
|
+
import { createContext, useContext, useId, useState, } from "react";
|
|
7
|
+
export const BASIC_ICONS = {
|
|
8
|
+
accountCircle: "circle-user",
|
|
9
|
+
add: "plus",
|
|
10
|
+
arrowBack: "arrow-left",
|
|
11
|
+
arrowForward: "arrow-right",
|
|
12
|
+
attachFile: "paperclip",
|
|
13
|
+
calendarToday: "calendar",
|
|
14
|
+
call: "phone",
|
|
15
|
+
camera: "camera",
|
|
16
|
+
check: "check",
|
|
17
|
+
close: "x",
|
|
18
|
+
delete: "trash",
|
|
19
|
+
download: "download",
|
|
20
|
+
edit: "pencil",
|
|
21
|
+
event: "calendar",
|
|
22
|
+
error: "circle-alert",
|
|
23
|
+
fastForward: "fast-forward",
|
|
24
|
+
favorite: "heart",
|
|
25
|
+
favoriteOff: "heart-off",
|
|
26
|
+
folder: "folder",
|
|
27
|
+
help: "circle-help",
|
|
28
|
+
home: "house",
|
|
29
|
+
info: "info",
|
|
30
|
+
locationOn: "map-pin",
|
|
31
|
+
lock: "lock",
|
|
32
|
+
lockOpen: "lock-open",
|
|
33
|
+
mail: "mail",
|
|
34
|
+
menu: "menu",
|
|
35
|
+
moreHoriz: "ellipsis",
|
|
36
|
+
moreVert: "ellipsis-vertical",
|
|
37
|
+
notifications: "bell",
|
|
38
|
+
notificationsOff: "bell-off",
|
|
39
|
+
pause: "pause",
|
|
40
|
+
payment: "credit-card",
|
|
41
|
+
person: "user",
|
|
42
|
+
phone: "smartphone",
|
|
43
|
+
photo: "image",
|
|
44
|
+
play: "play",
|
|
45
|
+
print: "printer",
|
|
46
|
+
refresh: "rotate-cw",
|
|
47
|
+
rewind: "rewind",
|
|
48
|
+
search: "search",
|
|
49
|
+
send: "send",
|
|
50
|
+
settings: "settings",
|
|
51
|
+
share: "share-2",
|
|
52
|
+
shoppingCart: "shopping-cart",
|
|
53
|
+
skipNext: "skip-forward",
|
|
54
|
+
skipPrevious: "skip-back",
|
|
55
|
+
star: "star",
|
|
56
|
+
starHalf: "star-half",
|
|
57
|
+
starOff: "star-off",
|
|
58
|
+
stop: "square",
|
|
59
|
+
upload: "upload",
|
|
60
|
+
visibility: "eye",
|
|
61
|
+
visibilityOff: "eye-off",
|
|
62
|
+
volumeDown: "volume-1",
|
|
63
|
+
volumeMute: "volume",
|
|
64
|
+
volumeOff: "volume-x",
|
|
65
|
+
volumeUp: "volume-2",
|
|
66
|
+
warning: "triangle-alert",
|
|
67
|
+
};
|
|
68
|
+
const isBasicIcon = (name) => typeof name === "string" && Object.hasOwn(BASIC_ICONS, name);
|
|
69
|
+
const InButton = createContext(false);
|
|
70
|
+
const weighted = (weight) => weight === undefined ? undefined : { flex: weight };
|
|
71
|
+
const firstError = (props) => props.validationErrors?.[0];
|
|
72
|
+
const named = (props) => props.accessibility?.label;
|
|
73
|
+
function Markdown({ text }) {
|
|
74
|
+
const Renderer = useContext(MarkdownComponentContext);
|
|
75
|
+
return Renderer ? _jsx(Renderer, { markdown: text }) : text;
|
|
76
|
+
}
|
|
77
|
+
const text = createComponentImplementation(TextApi, ({ props }) => {
|
|
78
|
+
const inButton = useContext(InButton);
|
|
79
|
+
const rendersMarkdown = useContext(MarkdownComponentContext) !== undefined;
|
|
80
|
+
const value = props.text ?? "";
|
|
81
|
+
if (inButton)
|
|
82
|
+
return props.variant === "caption" ? value : _jsx(Markdown, { text: value });
|
|
83
|
+
return props.variant === "caption" ? (_jsx(Text, { variant: "footnote", tone: "secondary", style: weighted(props.weight), children: value })) : (_jsx(Text, { as: rendersMarkdown ? "div" : "p", variant: "body", tone: "primary", style: weighted(props.weight), children: _jsx(Markdown, { text: value }) }));
|
|
84
|
+
});
|
|
85
|
+
const BUTTON_VARIANT = { default: "secondary", primary: "primary", borderless: "ghost" };
|
|
86
|
+
const button = createComponentImplementation(ButtonApi, ({ props, buildChild }) => (_jsx(Button, { variant: BUTTON_VARIANT[props.variant ?? "default"], size: "md", disabled: props.isValid === false, "aria-label": named(props), onPress: () => void props.action?.(), style: weighted(props.weight), children: _jsx(InButton, { value: true, children: buildChild(props.child) }) })));
|
|
87
|
+
const FIELD_TYPE = {
|
|
88
|
+
shortText: { type: "text" },
|
|
89
|
+
longText: { type: "text", multiline: true },
|
|
90
|
+
number: { type: "number", inputMode: "decimal" },
|
|
91
|
+
obscured: { type: "password" },
|
|
92
|
+
};
|
|
93
|
+
const textField = createComponentImplementation(TextFieldApi, ({ props }) => {
|
|
94
|
+
const kind = FIELD_TYPE[props.variant ?? "shortText"];
|
|
95
|
+
return (_jsx(TextField, { label: props.label ?? "", value: props.value === undefined ? "" : String(props.value), onChange: props.setValue, placeholder: props.placeholder, error: firstError(props), type: kind.type, inputMode: "inputMode" in kind ? kind.inputMode : undefined, multiline: "multiline" in kind, style: weighted(props.weight) }));
|
|
96
|
+
});
|
|
97
|
+
function CheckError({ message, id }) {
|
|
98
|
+
return (_jsx("span", { id: id, className: "xds-a2ui-check-error", "aria-live": "polite", children: message === undefined ? null : (_jsx(Text, { as: "span", variant: "footnote", tone: "danger", children: message })) }));
|
|
99
|
+
}
|
|
100
|
+
const checkBox = createComponentImplementation(CheckBoxApi, ({ props }) => {
|
|
101
|
+
const errorId = useId();
|
|
102
|
+
const error = firstError(props);
|
|
103
|
+
return (_jsxs("div", { className: "xds-a2ui-field", style: weighted(props.weight), children: [_jsx(Checkbox, { label: props.label, checked: props.value ?? false, onChange: props.setValue }), _jsx(CheckError, { message: error, id: errorId })] }));
|
|
104
|
+
});
|
|
105
|
+
const choicePicker = createComponentImplementation(ChoicePickerApi, ({ props }) => {
|
|
106
|
+
const [filter, setFilter] = useState("");
|
|
107
|
+
const errorId = useId();
|
|
108
|
+
const labelId = useId();
|
|
109
|
+
const label = props.label ?? named(props) ?? "";
|
|
110
|
+
const multiple = props.variant === "multipleSelection";
|
|
111
|
+
const selected = props.value ?? [];
|
|
112
|
+
const error = firstError(props);
|
|
113
|
+
const query = filter.trim().toLowerCase();
|
|
114
|
+
const options = (props.options ?? []).filter((option) => !props.filterable || query === "" || (option.label ?? "").toLowerCase().includes(query));
|
|
115
|
+
const toggle = (value) => props.setValue(multiple
|
|
116
|
+
? selected.includes(value)
|
|
117
|
+
? selected.filter((each) => each !== value)
|
|
118
|
+
: [...selected, value]
|
|
119
|
+
: [value]);
|
|
120
|
+
const search = props.filterable ? (_jsx(SearchField, { label: label, value: filter, onChange: setFilter })) : null;
|
|
121
|
+
if (props.displayStyle === "chips") {
|
|
122
|
+
return (_jsxs("div", { className: "xds-a2ui-field", style: weighted(props.weight), children: [props.label === undefined ? null : (_jsx(Text, { as: "span", variant: "label", tone: "primary", children: props.label })), search, _jsx(ChipBar, { label: label, children: options.map((option) => (_jsx(Chip, { label: option.label ?? option.value, selected: selected.includes(option.value), onPress: () => toggle(option.value) }, option.value))) }), _jsx(CheckError, { message: error, id: errorId })] }));
|
|
123
|
+
}
|
|
124
|
+
if (!multiple) {
|
|
125
|
+
return (_jsxs("div", { className: "xds-a2ui-field", style: weighted(props.weight), children: [search, _jsx(RadioGroup, { label: label, options: options.map((option) => ({
|
|
126
|
+
value: option.value,
|
|
127
|
+
label: option.label ?? option.value,
|
|
128
|
+
})), value: selected[0], onChange: (value) => props.setValue([value]), error: error })] }));
|
|
129
|
+
}
|
|
130
|
+
return (_jsxs("div", { role: "group", className: "xds-a2ui-field", "aria-labelledby": labelId, "aria-describedby": error === undefined ? undefined : errorId, "aria-invalid": error === undefined ? undefined : true, style: weighted(props.weight), children: [_jsx("span", { id: labelId, children: _jsx(Text, { as: "span", variant: "label", tone: "primary", children: label }) }), search, options.map((option) => (_jsx(Checkbox, { label: option.label ?? option.value, checked: selected.includes(option.value), onChange: () => toggle(option.value) }, option.value))), _jsx(CheckError, { message: error, id: errorId })] }));
|
|
131
|
+
});
|
|
132
|
+
const slider = createComponentImplementation(SliderApi, ({ props }) => {
|
|
133
|
+
const min = props.min ?? 0;
|
|
134
|
+
const max = props.max;
|
|
135
|
+
const step = props.steps !== undefined && props.steps > 0 ? (max - min) / props.steps : undefined;
|
|
136
|
+
return (_jsx(Slider, { label: props.label ?? named(props) ?? "", value: props.value ?? min, onChange: props.setValue, min: min, max: max, step: step, showValue: true, style: weighted(props.weight) }));
|
|
137
|
+
});
|
|
138
|
+
const day = (value) => {
|
|
139
|
+
const match = value === undefined ? null : /^\d{4}-\d{2}-\d{2}/.exec(value);
|
|
140
|
+
return match ? match[0] : undefined;
|
|
141
|
+
};
|
|
142
|
+
const dateTimeInput = createComponentImplementation(DateTimeInputApi, ({ props }) => {
|
|
143
|
+
const enableTime = props.enableTime ?? false;
|
|
144
|
+
const enableDate = props.enableDate ?? !enableTime;
|
|
145
|
+
const label = props.label ?? named(props) ?? "";
|
|
146
|
+
const value = props.value ?? "";
|
|
147
|
+
if (enableDate && !enableTime) {
|
|
148
|
+
return (_jsx(DatePicker, { label: label, value: day(value), onChange: props.setValue, min: day(props.min), max: day(props.max), error: firstError(props), style: weighted(props.weight) }));
|
|
149
|
+
}
|
|
150
|
+
return (_jsx(TextField, { label: label, value: enableDate ? value.slice(0, 16) : value.slice(0, 5), onChange: (next) => props.setValue(enableDate && next !== "" ? `${next}:00` : next), type: enableDate ? "datetime-local" : "time", error: firstError(props), style: weighted(props.weight) }));
|
|
151
|
+
});
|
|
152
|
+
const card = createComponentImplementation(CardApi, ({ props, buildChild }) => (_jsx(Card, { style: weighted(props.weight), children: buildChild(props.child) })));
|
|
153
|
+
const divider = createComponentImplementation(DividerApi, ({ props }) => (_jsx(Divider, { className: props.axis === "vertical" ? "xds-a2ui-divider--vertical" : undefined, style: weighted(props.weight) })));
|
|
154
|
+
const icon = createComponentImplementation(IconApi, ({ props }) => isBasicIcon(props.name) ? (_jsx(Icon, { name: BASIC_ICONS[props.name], label: named(props), style: weighted(props.weight) })) : null);
|
|
155
|
+
const PICTURE = {
|
|
156
|
+
icon: { ratio: "1:1", style: { width: "var(--a2ui-image-icon-size)" } },
|
|
157
|
+
smallFeature: { ratio: "1:1", style: { maxWidth: "var(--a2ui-image-small-feature-size)" } },
|
|
158
|
+
mediumFeature: { ratio: "16:9" },
|
|
159
|
+
largeFeature: { ratio: "16:9" },
|
|
160
|
+
header: { ratio: "16:9" },
|
|
161
|
+
};
|
|
162
|
+
const image = createComponentImplementation(ImageApi, ({ props }) => {
|
|
163
|
+
const alt = named(props) ?? props.description ?? "";
|
|
164
|
+
const src = sanitizeMediaUrl(props.url);
|
|
165
|
+
if (props.variant === "avatar") {
|
|
166
|
+
return _jsx(Avatar, { name: alt, src: src, size: "lg", style: weighted(props.weight) });
|
|
167
|
+
}
|
|
168
|
+
const picture = PICTURE[props.variant ?? "mediumFeature"] ?? { ratio: "16:9" };
|
|
169
|
+
return (_jsx(Thumbnail, { src: src, alt: alt, ratio: picture.ratio, style: { ...picture.style, ...weighted(props.weight) } }));
|
|
170
|
+
});
|
|
171
|
+
const tabs = createComponentImplementation(TabsApi, ({ props, buildChild }) => {
|
|
172
|
+
const [active, setActive] = useState(0);
|
|
173
|
+
const list = props.tabs ?? [];
|
|
174
|
+
const index = active < list.length ? active : 0;
|
|
175
|
+
const shown = list[index];
|
|
176
|
+
return (_jsxs("div", { className: "xds-a2ui-tabs", style: weighted(props.weight), children: [_jsx(Tabs, { items: list.map((tab, at) => ({ value: String(at), label: tab.title ?? "" })), value: String(index), onChange: (value) => setActive(Number(value)), label: named(props) ?? "" }), shown ? buildChild(shown.child) : null] }));
|
|
177
|
+
});
|
|
178
|
+
function nameOf(event) {
|
|
179
|
+
const control = event.target.closest("button, [role='button'], a");
|
|
180
|
+
return control?.getAttribute("aria-label") ?? control?.textContent?.trim() ?? "";
|
|
181
|
+
}
|
|
182
|
+
const modal = createComponentImplementation(ModalApi, ({ props, buildChild }) => {
|
|
183
|
+
const [opened, setOpened] = useState(undefined);
|
|
184
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "xds-a2ui-trigger", onClick: (event) => setOpened(nameOf(event)), style: weighted(props.weight), children: buildChild(props.trigger) }), _jsx(Dialog, { open: opened !== undefined, title: named(props) ?? opened ?? "", onClose: () => setOpened(undefined), children: opened === undefined ? null : buildChild(props.content) })] }));
|
|
185
|
+
});
|
|
186
|
+
const REPLACED = {
|
|
187
|
+
Text: text,
|
|
188
|
+
Image: image,
|
|
189
|
+
Icon: icon,
|
|
190
|
+
Card: card,
|
|
191
|
+
Tabs: tabs,
|
|
192
|
+
Modal: modal,
|
|
193
|
+
Divider: divider,
|
|
194
|
+
Button: button,
|
|
195
|
+
TextField: textField,
|
|
196
|
+
CheckBox: checkBox,
|
|
197
|
+
ChoicePicker: choicePicker,
|
|
198
|
+
Slider: slider,
|
|
199
|
+
DateTimeInput: dateTimeInput,
|
|
200
|
+
};
|
|
201
|
+
export const BASIC_DRAWN = Object.keys(REPLACED);
|
|
202
|
+
export const BASIC_KEPT = [...basicCatalog.components.keys()].filter((name) => !(name in REPLACED));
|
|
203
|
+
export const xdsBasicCatalog = basicCatalog.withEntries([...basicCatalog.components.values()].map((entry) => REPLACED[entry.name] ?? entry), [...basicCatalog.functions.values()]);
|
package/dist/cases.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** An element a person finds by its role and accessible name. */
|
|
2
|
+
export type Target = {
|
|
3
|
+
role: string;
|
|
4
|
+
name: string;
|
|
5
|
+
exact?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type Step =
|
|
8
|
+
/** Presses an element. */
|
|
9
|
+
{
|
|
10
|
+
click: Target;
|
|
11
|
+
}
|
|
12
|
+
/** Presses the visible text of a label, as a person presses a switch or a radio button. */
|
|
13
|
+
| {
|
|
14
|
+
clickText: string;
|
|
15
|
+
}
|
|
16
|
+
/** Types into a field after clearing it. */
|
|
17
|
+
| {
|
|
18
|
+
fill: Target;
|
|
19
|
+
text: string;
|
|
20
|
+
}
|
|
21
|
+
/** Presses a key, such as `Enter` or `Escape`. */
|
|
22
|
+
| {
|
|
23
|
+
press: string;
|
|
24
|
+
}
|
|
25
|
+
/** Rests the pointer on an element. */
|
|
26
|
+
| {
|
|
27
|
+
hover: Target;
|
|
28
|
+
}
|
|
29
|
+
/** Checks what is on screen between two steps, such as a dialog that the next one closes. */
|
|
30
|
+
| {
|
|
31
|
+
see: Expected;
|
|
32
|
+
};
|
|
33
|
+
/** What a person should meet on screen, and in which state. */
|
|
34
|
+
export type Expected = Target & {
|
|
35
|
+
value?: string;
|
|
36
|
+
checked?: boolean;
|
|
37
|
+
pressed?: boolean;
|
|
38
|
+
expanded?: boolean;
|
|
39
|
+
selected?: boolean;
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
invalid?: boolean;
|
|
42
|
+
/** The element is not on screen at all. */
|
|
43
|
+
absent?: true;
|
|
44
|
+
};
|
|
45
|
+
export type Case = {
|
|
46
|
+
name: string;
|
|
47
|
+
title: string;
|
|
48
|
+
/** What the case shows, for the preview. */
|
|
49
|
+
description: string;
|
|
50
|
+
/** What the agent sends, in order. */
|
|
51
|
+
messages: readonly Record<string, unknown>[];
|
|
52
|
+
/** On screen once the stream is drawn. */
|
|
53
|
+
screen: readonly Expected[];
|
|
54
|
+
steps: readonly Step[];
|
|
55
|
+
/** On screen after the steps. */
|
|
56
|
+
after?: readonly Expected[];
|
|
57
|
+
/** The actions the agent receives, in order: their names and contexts. */
|
|
58
|
+
actions: readonly {
|
|
59
|
+
name: string;
|
|
60
|
+
context?: Record<string, unknown>;
|
|
61
|
+
}[];
|
|
62
|
+
/** Values the data model holds after the steps, by path. */
|
|
63
|
+
data?: Readonly<Record<string, unknown>>;
|
|
64
|
+
/**
|
|
65
|
+
* Draws the basic catalog with xds (`xdsBasicCatalog`) in place of A2UI's own components: the
|
|
66
|
+
* stream of an agent that knows only the basic catalog.
|
|
67
|
+
*/
|
|
68
|
+
xdsBasic?: true;
|
|
69
|
+
};
|
|
70
|
+
export declare const CASES: readonly Case[];
|