@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
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type ReactComponentImplementation } from "@a2ui/react";
|
|
2
|
+
import type { ComponentApi } from "@a2ui/web_core";
|
|
3
|
+
import { type ReactNode } from "react";
|
|
4
|
+
import type { CoreComponent, PointerComponent, ResolvedProps } from "./generated/catalogs.ts";
|
|
5
|
+
type BuildChild = (id: string, basePath?: string) => ReactNode;
|
|
6
|
+
type View<Name extends keyof ResolvedProps> = (args: {
|
|
7
|
+
props: ResolvedProps[Name];
|
|
8
|
+
buildChild: BuildChild;
|
|
9
|
+
}) => ReactNode;
|
|
10
|
+
/** The views of a catalog's components, one for each: a missing one does not compile. */
|
|
11
|
+
export type Views<Name extends keyof ResolvedProps> = {
|
|
12
|
+
[Key in Name]: View<Key>;
|
|
13
|
+
};
|
|
14
|
+
export declare const CORE_VIEWS: Views<CoreComponent>;
|
|
15
|
+
export declare const POINTER_VIEWS: Views<PointerComponent>;
|
|
16
|
+
/**
|
|
17
|
+
* The components of a catalog as A2UI's React renderer takes them: each view under the API the
|
|
18
|
+
* catalog document gives it, so the schema an agent's message is checked against is the one
|
|
19
|
+
* the document publishes, not a copy of it.
|
|
20
|
+
*/
|
|
21
|
+
export declare function implementations<Name extends keyof ResolvedProps>(apis: ReadonlyMap<string, ComponentApi>, views: Views<Name>): ReactComponentImplementation[];
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createComponentImplementation } from "@a2ui/react";
|
|
3
|
+
import { Accordion, Avatar, AvatarStack, Badge, Banner, Button, Card, Checkbox, Chip, ChipBar, CountBadge, DatePicker, DateRangePicker, Dialog, Divider, EmptyState, Icon, IconButton, ListRow, MediaCard, Menu, ProgressBar, RadioGroup, SearchField, SectionHeader, SegmentedControl, Select, Slider, Spinner, Switch, Tabs, Text, TextField, Thumbnail, Tooltip, } from "@xds/react";
|
|
4
|
+
import { Fragment } from "react";
|
|
5
|
+
const child = (buildChild, id) => id === undefined ? undefined : buildChild(id);
|
|
6
|
+
function children(buildChild, list) {
|
|
7
|
+
if (!list || list.length === 0)
|
|
8
|
+
return undefined;
|
|
9
|
+
return list.map((entry) => typeof entry === "string" ? (_jsx(Fragment, { children: buildChild(entry) }, entry)) : (_jsx(Fragment, { children: buildChild(entry.id, entry.basePath) }, `${entry.id} ${entry.basePath}`)));
|
|
10
|
+
}
|
|
11
|
+
const send = (action) => action === undefined ? undefined : () => void action();
|
|
12
|
+
const day = (value) => value !== undefined && /^\d{4}-\d{2}-\d{2}$/.test(value) ? value : undefined;
|
|
13
|
+
const fieldError = (props) => props.validationErrors?.[0] ?? props.error;
|
|
14
|
+
const blocked = (props) => props.disabled === true || props.isValid === false;
|
|
15
|
+
const toggle = (props) => () => {
|
|
16
|
+
if (props.selected !== undefined)
|
|
17
|
+
props.setSelected(!props.selected);
|
|
18
|
+
void props.onPress?.();
|
|
19
|
+
};
|
|
20
|
+
export const CORE_VIEWS = {
|
|
21
|
+
Button: ({ props }) => (_jsx(Button, { variant: props.variant, size: props.size, iconStart: props.iconStart, iconEnd: props.iconEnd, disabled: blocked(props), loading: props.loading, fullWidth: props.fullWidth, selected: props.selected, onPress: toggle(props), children: props.label })),
|
|
22
|
+
TextField: ({ props, buildChild }) => (_jsx(TextField, { label: props.label ?? "", value: props.value ?? "", onChange: props.setValue, description: props.description, error: fieldError(props), placeholder: props.placeholder, leading: child(buildChild, props.leading), trailing: child(buildChild, props.trailing), rows: props.rows, maxLength: props.maxLength, disabled: props.disabled, multiline: props.multiline })),
|
|
23
|
+
Text: ({ props }) => (_jsx(Text, { variant: props.variant, tone: props.tone, children: props.text })),
|
|
24
|
+
Badge: ({ props }) => (_jsx(Badge, { tone: props.tone, dot: props.dot, icon: props.icon, children: props.label })),
|
|
25
|
+
CountBadge: ({ props, buildChild }) => (_jsx(CountBadge, { count: props.count ?? 0, max: props.max, label: props.label, children: child(buildChild, props.children) })),
|
|
26
|
+
Banner: ({ props }) => (_jsx(Banner, { tone: props.tone, title: props.title, action: props.action && {
|
|
27
|
+
label: props.action.label ?? "",
|
|
28
|
+
onPress: () => void props.action?.onPress?.(),
|
|
29
|
+
}, onDismiss: send(props.onDismiss), dismissLabel: props.dismissLabel, children: props.message })),
|
|
30
|
+
Card: ({ props, buildChild }) => (_jsx(Card, { title: props.title, description: props.description, actions: children(buildChild, props.actions), media: child(buildChild, props.media), onPress: send(props.onPress), flush: props.flush, selected: props.selected, children: children(buildChild, props.children) })),
|
|
31
|
+
Divider: () => _jsx(Divider, {}),
|
|
32
|
+
Spinner: ({ props }) => _jsx(Spinner, { size: props.size, label: props.label }),
|
|
33
|
+
Switch: ({ props }) => (_jsx(Switch, { label: props.label, checked: props.checked ?? false, onChange: props.setChecked, disabled: props.disabled })),
|
|
34
|
+
Checkbox: ({ props }) => (_jsx(Checkbox, { label: props.label, checked: props.checked ?? false, onChange: props.setChecked, disabled: props.disabled })),
|
|
35
|
+
SegmentedControl: ({ props }) => (_jsx(SegmentedControl, { options: (props.options ?? []).map((option) => ({
|
|
36
|
+
value: option.value ?? "",
|
|
37
|
+
label: option.label ?? "",
|
|
38
|
+
})), value: props.value ?? "", onChange: props.setValue, "aria-label": props.label ?? "", fullWidth: props.fullWidth })),
|
|
39
|
+
Avatar: ({ props }) => _jsx(Avatar, { name: props.name ?? "", src: props.src, size: props.size }),
|
|
40
|
+
AvatarStack: ({ props }) => (_jsx(AvatarStack, { people: (props.people ?? []).map((person) => ({ name: person.name ?? "", src: person.src })), max: props.max, label: props.label, size: props.size })),
|
|
41
|
+
ProgressBar: ({ props }) => _jsx(ProgressBar, { value: props.value ?? 0, label: props.label ?? "" }),
|
|
42
|
+
Icon: ({ props }) => props.name === undefined ? null : (_jsx(Icon, { name: props.name, label: props.label, size: props.size, filled: props.filled })),
|
|
43
|
+
ListRow: ({ props, buildChild }) => (_jsx(ListRow, { title: props.title ?? "", description: props.description, leading: child(buildChild, props.leading), trailing: child(buildChild, props.trailing), onPress: send(props.onPress), chevron: props.chevron, disabled: props.disabled, selected: props.selected, compact: props.compact })),
|
|
44
|
+
IconButton: ({ props }) => props.icon === undefined ? null : (_jsx(IconButton, { icon: props.icon, label: props.label ?? "", variant: props.variant, size: props.size, selected: props.selected, disabled: blocked(props), loading: props.loading, onPress: toggle(props) })),
|
|
45
|
+
Chip: ({ props }) => (_jsx(Chip, { label: props.label ?? "", iconStart: props.iconStart, selected: props.selected, disabled: props.disabled, onPress: toggle(props) })),
|
|
46
|
+
ChipBar: ({ props, buildChild }) => (_jsx(ChipBar, { label: props.label ?? "", children: children(buildChild, props.children) })),
|
|
47
|
+
Tabs: ({ props }) => (_jsx(Tabs, { items: (props.items ?? []).map((item) => ({
|
|
48
|
+
value: item.value ?? "",
|
|
49
|
+
label: item.label ?? "",
|
|
50
|
+
icon: item.icon,
|
|
51
|
+
})), value: props.value ?? "", onChange: props.setValue, label: props.label ?? "", fullWidth: props.fullWidth })),
|
|
52
|
+
Menu: ({ props, buildChild }) => (_jsx(Menu, { trigger: child(buildChild, props.trigger), label: props.label ?? "", align: props.align, items: (props.items ?? []).map((item) => item.separator
|
|
53
|
+
? "separator"
|
|
54
|
+
: {
|
|
55
|
+
label: item.label ?? "",
|
|
56
|
+
icon: item.icon,
|
|
57
|
+
onSelect: () => void item.onSelect?.(),
|
|
58
|
+
danger: item.danger,
|
|
59
|
+
disabled: item.disabled,
|
|
60
|
+
selected: item.selected,
|
|
61
|
+
}) })),
|
|
62
|
+
Dialog: ({ props, buildChild }) => (_jsx(Dialog, { open: props.open ?? false, title: props.title ?? "", description: props.description, dismissible: props.dismissible, actions: children(buildChild, props.actions), onClose: () => {
|
|
63
|
+
props.setOpen(false);
|
|
64
|
+
void props.onClose?.();
|
|
65
|
+
}, children: children(buildChild, props.children) })),
|
|
66
|
+
SearchField: ({ props }) => (_jsx(SearchField, { label: props.label ?? "", value: props.value ?? "", onChange: props.setValue, onSubmit: send(props.onSubmit), placeholder: props.placeholder, clearLabel: props.clearLabel, disabled: props.disabled })),
|
|
67
|
+
RadioGroup: ({ props }) => (_jsx(RadioGroup, { label: props.label ?? "", options: (props.options ?? []).map((option) => ({
|
|
68
|
+
value: option.value ?? "",
|
|
69
|
+
label: option.label ?? "",
|
|
70
|
+
description: option.description,
|
|
71
|
+
})), value: props.value, onChange: props.setValue, error: fieldError(props), disabled: props.disabled })),
|
|
72
|
+
Select: ({ props }) => (_jsx(Select, { label: props.label ?? "", options: (props.options ?? []).map((option) => ({
|
|
73
|
+
value: option.value ?? "",
|
|
74
|
+
label: option.label ?? "",
|
|
75
|
+
description: option.description,
|
|
76
|
+
})), value: props.value, onChange: props.setValue, placeholder: props.placeholder, description: props.description, error: fieldError(props), disabled: props.disabled })),
|
|
77
|
+
DatePicker: ({ props }) => (_jsx(DatePicker, { label: props.label ?? "", value: day(props.value), onChange: props.setValue, min: day(props.min), max: day(props.max), placeholder: props.placeholder, description: props.description, error: fieldError(props), previousLabel: props.previousLabel, nextLabel: props.nextLabel, disabled: props.disabled })),
|
|
78
|
+
DateRangePicker: ({ props }) => {
|
|
79
|
+
const start = day(props.value?.start);
|
|
80
|
+
const end = day(props.value?.end);
|
|
81
|
+
return (_jsx(DateRangePicker, { label: props.label ?? "", value: start && end ? { start, end } : undefined, onChange: props.setValue, min: day(props.min), max: day(props.max), minLength: props.minLength, maxLength: props.maxLength, placeholder: props.placeholder, description: props.description, error: fieldError(props), startLabel: props.startLabel, endLabel: props.endLabel, previousLabel: props.previousLabel, nextLabel: props.nextLabel, disabled: props.disabled }));
|
|
82
|
+
},
|
|
83
|
+
Slider: ({ props }) => (_jsx(Slider, { label: props.label ?? "", value: props.value ?? props.min ?? 0, onChange: props.setValue, min: props.min, max: props.max, step: props.step, disabled: props.disabled, showValue: props.showValue })),
|
|
84
|
+
Thumbnail: ({ props }) => (_jsx(Thumbnail, { src: props.src, alt: props.alt ?? "", ratio: props.ratio, badge: props.badge, progress: props.progress })),
|
|
85
|
+
MediaCard: ({ props, buildChild }) => (_jsx(MediaCard, { layout: props.layout, src: props.src, alt: props.alt, ratio: props.ratio, badge: props.badge, progress: props.progress, title: props.title ?? "", meta: props.meta, leading: child(buildChild, props.leading), action: child(buildChild, props.action), onPress: send(props.onPress) })),
|
|
86
|
+
SectionHeader: ({ props }) => (_jsx(SectionHeader, { title: props.title ?? "", description: props.description, icon: props.icon, level: props.level, action: props.action && {
|
|
87
|
+
label: props.action.label ?? "",
|
|
88
|
+
onPress: () => void props.action?.onPress?.(),
|
|
89
|
+
} })),
|
|
90
|
+
EmptyState: ({ props, buildChild }) => props.icon === undefined ? null : (_jsx(EmptyState, { icon: props.icon, title: props.title ?? "", description: props.description, action: child(buildChild, props.action) })),
|
|
91
|
+
Accordion: ({ props, buildChild }) => (_jsx(Accordion, { items: (props.items ?? []).map((item) => ({
|
|
92
|
+
value: item.value ?? "",
|
|
93
|
+
title: item.title ?? "",
|
|
94
|
+
description: item.description,
|
|
95
|
+
content: child(buildChild, item.content),
|
|
96
|
+
})), expanded: props.expanded ?? [], onChange: props.setExpanded, multiple: props.multiple })),
|
|
97
|
+
};
|
|
98
|
+
export const POINTER_VIEWS = {
|
|
99
|
+
Tooltip: ({ props, buildChild }) => (_jsx(Tooltip, { label: props.label ?? "", shortcut: props.shortcut, placement: props.placement, children: child(buildChild, props.children) })),
|
|
100
|
+
};
|
|
101
|
+
export function implementations(apis, views) {
|
|
102
|
+
return Object.entries(views).map(([name, view]) => {
|
|
103
|
+
const api = apis.get(name);
|
|
104
|
+
if (!api)
|
|
105
|
+
throw new Error(`The catalog has no ${name}`);
|
|
106
|
+
return createComponentImplementation(api, ({ props, buildChild }) => view({ props: props, buildChild }));
|
|
107
|
+
});
|
|
108
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Catalog } from "@a2ui/web_core";
|
|
2
|
+
import { type CatalogDocument } from "./generated/catalogs.ts";
|
|
3
|
+
/** The components every xds client has. */
|
|
4
|
+
export declare const xdsCatalog: Catalog<import("@a2ui/react").ReactComponentImplementation<import("zod").ZodTypeAny>, never>;
|
|
5
|
+
/** The components only clients with a pointer have, which the web libraries are. */
|
|
6
|
+
export declare const xdsPointerCatalog: Catalog<import("@a2ui/react").ReactComponentImplementation<import("zod").ZodTypeAny>, never>;
|
|
7
|
+
/** The catalogs' IDs, which an agent names in `createSurface` and `@catalogId`. */
|
|
8
|
+
export declare const XDS_CATALOG_ID: string;
|
|
9
|
+
export declare const XDS_POINTER_CATALOG_ID: string;
|
|
10
|
+
export declare const XDS_TOUCH_CATALOG_ID: string;
|
|
11
|
+
/**
|
|
12
|
+
* The catalog documents, to put in an agent's prompt or to serve to it. The touch catalog has no
|
|
13
|
+
* implementation on the web: its document is here for an agent that also draws on a phone.
|
|
14
|
+
*/
|
|
15
|
+
export declare const CATALOG_DOCUMENTS: {
|
|
16
|
+
readonly core: CatalogDocument;
|
|
17
|
+
readonly pointer: CatalogDocument;
|
|
18
|
+
readonly touch: CatalogDocument;
|
|
19
|
+
};
|
|
20
|
+
export { BASIC_DRAWN, BASIC_ICONS, BASIC_KEPT, xdsBasicCatalog } from "./basic.tsx";
|
|
21
|
+
export type { CatalogDocument, ResolvedProps } from "./generated/catalogs.ts";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Catalog } from "@a2ui/web_core";
|
|
2
|
+
import { CORE_CATALOG, POINTER_CATALOG, TOUCH_CATALOG, } from "./generated/catalogs.js";
|
|
3
|
+
import { CORE_VIEWS, implementations, POINTER_VIEWS } from "./implementations.js";
|
|
4
|
+
function catalog(document, views) {
|
|
5
|
+
const loaded = Catalog.fromJson(document);
|
|
6
|
+
return loaded.withEntries(implementations(loaded.components, views), []);
|
|
7
|
+
}
|
|
8
|
+
export const xdsCatalog = catalog(CORE_CATALOG, CORE_VIEWS);
|
|
9
|
+
export const xdsPointerCatalog = catalog(POINTER_CATALOG, POINTER_VIEWS);
|
|
10
|
+
export const XDS_CATALOG_ID = CORE_CATALOG.catalogId;
|
|
11
|
+
export const XDS_POINTER_CATALOG_ID = POINTER_CATALOG.catalogId;
|
|
12
|
+
export const XDS_TOUCH_CATALOG_ID = TOUCH_CATALOG.catalogId;
|
|
13
|
+
export const CATALOG_DOCUMENTS = {
|
|
14
|
+
core: CORE_CATALOG,
|
|
15
|
+
pointer: POINTER_CATALOG,
|
|
16
|
+
touch: TOUCH_CATALOG,
|
|
17
|
+
};
|
|
18
|
+
export { BASIC_DRAWN, BASIC_ICONS, BASIC_KEPT, xdsBasicCatalog } from "./basic.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ReactCatalogComponent } from "@a2ui/react";
|
|
2
|
+
import { type ActionListener, MessageProcessor } from "@a2ui/web_core";
|
|
3
|
+
import { type Case } from "./cases.ts";
|
|
4
|
+
export { type Case, CASES, type Expected, type Step, type Target } from "./cases.ts";
|
|
5
|
+
/**
|
|
6
|
+
* A processor that has taken every message of the case, with the catalogs an app on the web
|
|
7
|
+
* registers: the basic catalog for layout and functions, and both xds catalogs. A case of an
|
|
8
|
+
* agent that knows only the basic catalog has it drawn with xds.
|
|
9
|
+
*/
|
|
10
|
+
export declare function replay(entry: Case, onAction?: ActionListener): Processor;
|
|
11
|
+
export type Processor = MessageProcessor<ReactCatalogComponent>;
|
|
12
|
+
/** Draws every surface of a processor. */
|
|
13
|
+
export declare function Surfaces({ processor }: {
|
|
14
|
+
processor: Processor;
|
|
15
|
+
}): import("react").JSX.Element[];
|
|
16
|
+
/**
|
|
17
|
+
* One case, or every case one after the other. `onAction` receives the actions the surfaces
|
|
18
|
+
* send, as an app would forward them to its agent.
|
|
19
|
+
*/
|
|
20
|
+
export declare function Preview({ name, onAction }: {
|
|
21
|
+
name?: string;
|
|
22
|
+
onAction?: ActionListener;
|
|
23
|
+
}): import("react").JSX.Element[];
|
package/dist/preview.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { A2uiSurface } from "@a2ui/react";
|
|
3
|
+
import { MessageProcessor } from "@a2ui/web_core";
|
|
4
|
+
import { basicCatalog } from "@a2ui/web_core/catalogs/basic/v1";
|
|
5
|
+
import { useEffect, useState } from "react";
|
|
6
|
+
import { CASES } from "./cases.js";
|
|
7
|
+
import { xdsBasicCatalog, xdsCatalog, xdsPointerCatalog } from "./index.js";
|
|
8
|
+
export { CASES } from "./cases.js";
|
|
9
|
+
export function replay(entry, onAction) {
|
|
10
|
+
const processor = new MessageProcessor([entry.xdsBasic ? xdsBasicCatalog : basicCatalog, xdsCatalog, xdsPointerCatalog], onAction);
|
|
11
|
+
processor.processMessages(entry.messages);
|
|
12
|
+
return processor;
|
|
13
|
+
}
|
|
14
|
+
function useSurfaces(processor) {
|
|
15
|
+
const [surfaces, setSurfaces] = useState(() => [
|
|
16
|
+
...processor.model.surfacesMap.values(),
|
|
17
|
+
]);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const sync = () => setSurfaces([...processor.model.surfacesMap.values()]);
|
|
20
|
+
const created = processor.onSurfaceCreated(sync);
|
|
21
|
+
const deleted = processor.onSurfaceDeleted(sync);
|
|
22
|
+
return () => {
|
|
23
|
+
created.unsubscribe();
|
|
24
|
+
deleted.unsubscribe();
|
|
25
|
+
};
|
|
26
|
+
}, [processor]);
|
|
27
|
+
return surfaces;
|
|
28
|
+
}
|
|
29
|
+
export function Surfaces({ processor }) {
|
|
30
|
+
return useSurfaces(processor).map((surface) => (_jsx(A2uiSurface, { surface: surface }, surface.id)));
|
|
31
|
+
}
|
|
32
|
+
function Replay({ entry, onAction }) {
|
|
33
|
+
const [processor] = useState(() => replay(entry, onAction));
|
|
34
|
+
return _jsx(Surfaces, { processor: processor });
|
|
35
|
+
}
|
|
36
|
+
export function Preview({ name, onAction }) {
|
|
37
|
+
const entries = name === undefined ? CASES : CASES.filter((entry) => entry.name === name);
|
|
38
|
+
if (entries.length === 0)
|
|
39
|
+
throw new Error(`There is no case named ${name}`);
|
|
40
|
+
return entries.map((entry) => (_jsx("section", { "data-case": entry.name, children: _jsx(Replay, { entry: entry, onAction: onAction }) }, entry.name)));
|
|
41
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xds/a2ui-react",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0-rc.1",
|
|
4
|
+
"description": "The xds design system as an A2UI catalog: an agent's surfaces drawn with @xds/react.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"design-system",
|
|
7
|
+
"design-tokens",
|
|
8
|
+
"components",
|
|
9
|
+
"a2ui",
|
|
10
|
+
"react",
|
|
11
|
+
"agent"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"homepage": "https://github.com/kjmin-dev/xds/blob/main/docs/a2ui-react.md",
|
|
15
|
+
"bugs": "https://github.com/kjmin-dev/xds/issues",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/kjmin-dev/xds.git",
|
|
19
|
+
"directory": "packages/a2ui-react"
|
|
20
|
+
},
|
|
21
|
+
"type": "module",
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"*.css"
|
|
24
|
+
],
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./preview": {
|
|
31
|
+
"types": "./dist/preview.d.ts",
|
|
32
|
+
"default": "./dist/preview.js"
|
|
33
|
+
},
|
|
34
|
+
"./styles.css": "./styles.css",
|
|
35
|
+
"./package.json": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"dist",
|
|
39
|
+
"styles.css"
|
|
40
|
+
],
|
|
41
|
+
"peerDependencies": {
|
|
42
|
+
"@a2ui/react": "^0.17.0",
|
|
43
|
+
"@a2ui/web_core": "^0.17.0",
|
|
44
|
+
"@xds/react": "^1.0.0-rc.1",
|
|
45
|
+
"react": "^19.3.0",
|
|
46
|
+
"react-dom": "^19.3.0",
|
|
47
|
+
"zod": "^3.25.76"
|
|
48
|
+
}
|
|
49
|
+
}
|
package/styles.css
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/* A2UI's basic catalog in the app's theme. Its components (Row, Column, List, and the others an
|
|
2
|
+
agent may draw beside the xds ones) take their look from `--a2ui-*` custom properties, which
|
|
3
|
+
this sets from the design tokens, so a surface of basic components follows the app's colors,
|
|
4
|
+
type and spacing, in light and dark mode and under a theme applied to part of the page.
|
|
5
|
+
|
|
6
|
+
A2UI's defaults sit in an unlayered stylesheet the renderer adopts at the end of the page, with
|
|
7
|
+
no specificity (`:where(:root)`). These rules are unlayered too, with a selector's
|
|
8
|
+
specificity, so they win over the defaults whatever their order; an app that sets one of the
|
|
9
|
+
properties itself does it after importing this stylesheet. They are set again on every element
|
|
10
|
+
that applies a theme, so the tokens they read are that theme's. */
|
|
11
|
+
|
|
12
|
+
:root,
|
|
13
|
+
[data-xds-theme] {
|
|
14
|
+
--a2ui-color-background: var(--xds-color-background-base);
|
|
15
|
+
--a2ui-color-on-background: var(--xds-color-text-primary);
|
|
16
|
+
--a2ui-color-surface: var(--xds-color-background-surface);
|
|
17
|
+
--a2ui-color-on-surface: var(--xds-color-text-primary);
|
|
18
|
+
|
|
19
|
+
--a2ui-color-primary: var(--xds-color-accent-default);
|
|
20
|
+
--a2ui-color-primary-hover: var(--xds-color-accent-hover);
|
|
21
|
+
--a2ui-color-primary-dark: var(--xds-color-accent-pressed);
|
|
22
|
+
--a2ui-color-primary-light: var(--xds-color-accent-subtle);
|
|
23
|
+
--a2ui-color-on-primary: var(--xds-color-text-on-accent);
|
|
24
|
+
|
|
25
|
+
--a2ui-color-secondary: var(--xds-color-button-secondary-background);
|
|
26
|
+
--a2ui-color-secondary-hover: var(--xds-color-button-secondary-background-hover);
|
|
27
|
+
--a2ui-color-secondary-dark: var(--xds-color-button-secondary-background-pressed);
|
|
28
|
+
--a2ui-color-secondary-light: var(--xds-color-button-secondary-background);
|
|
29
|
+
--a2ui-color-on-secondary: var(--xds-color-button-secondary-text);
|
|
30
|
+
|
|
31
|
+
--a2ui-color-border: var(--xds-color-border-default);
|
|
32
|
+
--a2ui-border-width: var(--xds-border-width-thin);
|
|
33
|
+
--a2ui-border: var(--xds-border-width-thin) solid var(--xds-color-border-default);
|
|
34
|
+
--a2ui-border-radius: var(--xds-radius-md);
|
|
35
|
+
|
|
36
|
+
--a2ui-color-input: var(--xds-color-field-background);
|
|
37
|
+
--a2ui-color-on-input: var(--xds-color-field-text);
|
|
38
|
+
--a2ui-textfield-border: var(--xds-border-width-thin) solid var(--xds-color-field-border);
|
|
39
|
+
--a2ui-textfield-color-border-focus: var(--xds-color-field-border-focus);
|
|
40
|
+
--a2ui-textfield-color-error: var(--xds-color-field-border-invalid);
|
|
41
|
+
|
|
42
|
+
--a2ui-font-family-title: var(--xds-font-family-sans);
|
|
43
|
+
--a2ui-font-size: var(--xds-typography-body-size);
|
|
44
|
+
--a2ui-font-size-xs: var(--xds-font-size-xs);
|
|
45
|
+
--a2ui-font-size-s: var(--xds-font-size-sm);
|
|
46
|
+
--a2ui-font-size-m: var(--xds-font-size-md);
|
|
47
|
+
--a2ui-font-size-l: var(--xds-font-size-lg);
|
|
48
|
+
--a2ui-font-size-xl: var(--xds-font-size-xl);
|
|
49
|
+
--a2ui-font-size-2xl: var(--xds-font-size-2xl);
|
|
50
|
+
--a2ui-line-height-headings: var(--xds-font-line-height-tight);
|
|
51
|
+
--a2ui-line-height-body: var(--xds-typography-body-line-height);
|
|
52
|
+
--a2ui-label-font-size: var(--xds-typography-label-size);
|
|
53
|
+
--a2ui-label-font-weight: var(--xds-typography-label-weight);
|
|
54
|
+
--a2ui-text-caption-color: var(--xds-color-text-secondary);
|
|
55
|
+
--a2ui-text-a-color: var(--xds-color-text-accent);
|
|
56
|
+
|
|
57
|
+
/* Row, Column and List hold the xds components, so their gaps are the spacing the
|
|
58
|
+
components keep between each other in the app. */
|
|
59
|
+
--a2ui-grid-base: var(--xds-space-2);
|
|
60
|
+
--a2ui-spacing-xs: var(--xds-space-1);
|
|
61
|
+
--a2ui-spacing-s: var(--xds-space-2);
|
|
62
|
+
--a2ui-spacing-m: var(--xds-space-3);
|
|
63
|
+
--a2ui-spacing-l: var(--xds-space-4);
|
|
64
|
+
--a2ui-spacing-xl: var(--xds-space-6);
|
|
65
|
+
--a2ui-row-gap: var(--xds-space-3);
|
|
66
|
+
--a2ui-column-gap: var(--xds-space-4);
|
|
67
|
+
--a2ui-list-gap: var(--xds-space-3);
|
|
68
|
+
|
|
69
|
+
--a2ui-card-background: var(--xds-color-background-surface);
|
|
70
|
+
--a2ui-card-border: var(--xds-border-width-thin) solid var(--xds-color-border-default);
|
|
71
|
+
--a2ui-card-border-radius: var(--xds-radius-lg);
|
|
72
|
+
--a2ui-modal-background: var(--xds-color-dialog-background);
|
|
73
|
+
--a2ui-modal-border-radius: var(--xds-radius-xl);
|
|
74
|
+
--a2ui-modal-box-shadow: var(--xds-shadow-overlay);
|
|
75
|
+
--a2ui-modal-backdrop-bg: var(--xds-color-scrim);
|
|
76
|
+
--a2ui-divider-border: var(--xds-border-width-thin) solid var(--xds-color-border-default);
|
|
77
|
+
--a2ui-icon-color: var(--xds-color-text-secondary);
|
|
78
|
+
--a2ui-image-icon-size: var(--xds-size-icon-lg);
|
|
79
|
+
--a2ui-image-avatar-size: var(--xds-size-avatar-lg);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* A2UI's defaults also set the color scheme, unlayered: `:where(:root) { color-scheme: light
|
|
83
|
+
dark }`. An unlayered rule wins over any rule in a cascade layer, and the published library
|
|
84
|
+
keeps its own, which follow `data-theme`, in its `xds` layer, so the page would keep to the
|
|
85
|
+
system's mode. The library's rules are set again here, unlayered, as the tokens set them. */
|
|
86
|
+
:root {
|
|
87
|
+
color-scheme: light dark;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
[data-theme="light"] {
|
|
91
|
+
color-scheme: light;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
[data-theme="dark"] {
|
|
95
|
+
color-scheme: dark;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* The basic catalog's controls are the browser's buttons and inputs, which keep the browser's
|
|
99
|
+
font unless the page resets them. The library resets only its own elements, so these take the
|
|
100
|
+
page's font here, as the xds components do. With no specificity, A2UI's own rules for them
|
|
101
|
+
win. */
|
|
102
|
+
:where(
|
|
103
|
+
a2ui-basic-button,
|
|
104
|
+
a2ui-basic-textfield,
|
|
105
|
+
a2ui-checkbox,
|
|
106
|
+
a2ui-choicepicker,
|
|
107
|
+
a2ui-datetimeinput,
|
|
108
|
+
a2ui-modal,
|
|
109
|
+
a2ui-slider,
|
|
110
|
+
a2ui-tabs
|
|
111
|
+
)
|
|
112
|
+
:where(button, input, textarea) {
|
|
113
|
+
font: inherit;
|
|
114
|
+
letter-spacing: inherit;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* What xds draws in place of the basic catalog's components (basic.tsx) around the xds ones: a
|
|
118
|
+
control with the message of a failing check under it, a group of checkboxes, the panel under
|
|
119
|
+
a row of tabs, a modal's trigger and a vertical divider. In a cascade layer of their own, as
|
|
120
|
+
the library's styles are, so that an app's styles win. */
|
|
121
|
+
@layer xds-a2ui {
|
|
122
|
+
.xds-a2ui-field,
|
|
123
|
+
.xds-a2ui-tabs {
|
|
124
|
+
display: flex;
|
|
125
|
+
flex-direction: column;
|
|
126
|
+
gap: var(--xds-space-2);
|
|
127
|
+
min-width: 0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.xds-a2ui-tabs {
|
|
131
|
+
gap: var(--xds-space-4);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* The message's live region stays in the page, so that a message is announced when it
|
|
135
|
+
appears, and takes back the gap before it while it is empty. */
|
|
136
|
+
.xds-a2ui-check-error:empty {
|
|
137
|
+
margin-top: calc(var(--xds-space-2) * -1);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/* The trigger is laid out where the basic Modal stands; the wrapper only hears its presses. */
|
|
141
|
+
.xds-a2ui-trigger {
|
|
142
|
+
display: contents;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.xds-a2ui-divider--vertical {
|
|
146
|
+
width: var(--xds-border-width-thin);
|
|
147
|
+
height: auto;
|
|
148
|
+
align-self: stretch;
|
|
149
|
+
}
|
|
150
|
+
}
|