glchat-a2ui-react-renderer 0.3.0 → 0.3.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/README.md +59 -10
- package/dist/index.d.ts +8 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -8
- package/dist/src/Provider.d.ts +24 -17
- package/dist/src/Provider.d.ts.map +1 -1
- package/dist/src/Provider.js +36 -52
- package/dist/src/SurfaceRenderer.d.ts +2 -4
- package/dist/src/SurfaceRenderer.d.ts.map +1 -1
- package/dist/src/SurfaceRenderer.js +8 -21
- package/dist/src/components/a2ui/v0_8/Button/Button.d.ts +4 -0
- package/dist/src/components/a2ui/v0_8/Button/Button.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_8/Button/Button.js +18 -0
- package/dist/src/components/a2ui/v0_8/Button/theme.d.ts +4 -0
- package/dist/src/components/a2ui/v0_8/Button/theme.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_8/Button/theme.js +4 -0
- package/dist/src/components/a2ui/v0_8/ButtonAsLink/ButtonAsLink.d.ts +4 -0
- package/dist/src/components/a2ui/v0_8/ButtonAsLink/ButtonAsLink.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_8/ButtonAsLink/ButtonAsLink.js +43 -0
- package/dist/src/components/a2ui/v0_8/ButtonAsLink/theme.d.ts +7 -0
- package/dist/src/components/a2ui/v0_8/ButtonAsLink/theme.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_8/ButtonAsLink/theme.js +7 -0
- package/dist/src/components/a2ui/v0_8/Card/theme.d.ts +4 -0
- package/dist/src/components/a2ui/v0_8/Card/theme.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_8/Card/theme.js +15 -0
- package/dist/src/components/a2ui/v0_8/DateTimeInput/theme.d.ts +7 -0
- package/dist/src/components/a2ui/v0_8/DateTimeInput/theme.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_8/DateTimeInput/theme.js +9 -0
- package/dist/src/components/a2ui/v0_8/DestructiveButton/DestructiveButton.d.ts +4 -0
- package/dist/src/components/a2ui/v0_8/DestructiveButton/DestructiveButton.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_8/DestructiveButton/DestructiveButton.js +23 -0
- package/dist/src/components/a2ui/v0_8/DestructiveButton/theme.d.ts +7 -0
- package/dist/src/components/a2ui/v0_8/DestructiveButton/theme.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_8/DestructiveButton/theme.js +7 -0
- package/dist/src/components/a2ui/v0_8/MultipleChoice/MultipleChoice.d.ts +4 -0
- package/dist/src/components/a2ui/v0_8/MultipleChoice/MultipleChoice.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_8/MultipleChoice/MultipleChoice.js +72 -0
- package/dist/src/components/a2ui/v0_8/TagInput/TagInput.d.ts +4 -0
- package/dist/src/components/a2ui/v0_8/TagInput/TagInput.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_8/TagInput/TagInput.js +49 -0
- package/dist/src/components/a2ui/v0_8/TagInput/theme.d.ts +11 -0
- package/dist/src/components/a2ui/v0_8/TagInput/theme.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_8/TagInput/theme.js +9 -0
- package/dist/src/components/a2ui/v0_8/TextField/theme.d.ts +7 -0
- package/dist/src/components/a2ui/v0_8/TextField/theme.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_8/TextField/theme.js +9 -0
- package/dist/src/components/a2ui/v0_8/Timeout/Timeout.d.ts +4 -0
- package/dist/src/components/a2ui/v0_8/Timeout/Timeout.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_8/Timeout/Timeout.js +29 -0
- package/dist/src/components/a2ui/v0_8/Timeout/theme.d.ts +8 -0
- package/dist/src/components/a2ui/v0_8/Timeout/theme.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_8/Timeout/theme.js +12 -0
- package/dist/src/components/a2ui/v0_8/types.d.ts +12 -0
- package/dist/src/components/a2ui/v0_8/types.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_8/types.js +1 -0
- package/dist/src/components/a2ui/v0_9/Button/Button.d.ts.map +1 -0
- package/dist/src/components/a2ui/{Button → v0_9/Button}/Button.js +1 -1
- package/dist/src/components/a2ui/v0_9/ChoicePicker/ChoicePicker.d.ts.map +1 -0
- package/dist/src/components/a2ui/{ChoicePicker → v0_9/ChoicePicker}/ChoicePicker.js +4 -4
- package/dist/src/components/a2ui/v0_9/ChoicePicker/theme.d.ts +4 -0
- package/dist/src/components/a2ui/v0_9/ChoicePicker/theme.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_9/ChoicePicker/theme.js +11 -0
- package/dist/src/components/a2ui/{TagInput → v0_9/TagInput}/TagInput.d.ts +32 -32
- package/dist/src/components/a2ui/v0_9/TagInput/TagInput.d.ts.map +1 -0
- package/dist/src/components/a2ui/v0_9/TagInput/TagInput.js +40 -0
- package/dist/src/components/a2ui/v0_9/Timeout/Timeout.d.ts.map +1 -0
- package/dist/src/components/a2ui/{Timeout → v0_9/Timeout}/Timeout.js +1 -1
- package/dist/src/components/a2ui/v0_9/common.d.ts.map +1 -0
- package/dist/src/components/ui/Button/Button.d.ts.map +1 -1
- package/dist/src/components/ui/Button/Button.js +2 -2
- package/dist/src/components/ui/Button/ButtonAsLink.d.ts +15 -0
- package/dist/src/components/ui/Button/ButtonAsLink.d.ts.map +1 -0
- package/dist/src/components/ui/Button/ButtonAsLink.js +17 -0
- package/dist/src/components/ui/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/src/components/ui/Checkbox/Checkbox.js +2 -2
- package/dist/src/components/{a2ui/ChoicePicker → ui/CheckboxList}/CheckboxList.d.ts +3 -2
- package/dist/src/components/ui/CheckboxList/CheckboxList.d.ts.map +1 -0
- package/dist/src/components/{a2ui/ChoicePicker → ui/CheckboxList}/CheckboxList.js +16 -5
- package/dist/src/components/{a2ui/ChoicePicker → ui/CheckboxList}/theme.d.ts +0 -5
- package/dist/src/components/ui/CheckboxList/theme.d.ts.map +1 -0
- package/dist/src/components/{a2ui/ChoicePicker → ui/CheckboxList}/theme.js +0 -14
- package/dist/src/components/ui/MultiSelect/MultiSelect.d.ts.map +1 -1
- package/dist/src/components/ui/MultiSelect/MultiSelect.js +2 -3
- package/dist/src/components/ui/Select/Select.d.ts.map +1 -1
- package/dist/src/components/ui/Select/Select.js +2 -1
- package/dist/src/components/ui/TagInput/TagInput.d.ts +18 -0
- package/dist/src/components/ui/TagInput/TagInput.d.ts.map +1 -0
- package/dist/src/components/{a2ui → ui}/TagInput/TagInput.js +16 -48
- package/dist/src/components/ui/TagInput/theme.d.ts.map +1 -0
- package/dist/src/components/{a2ui → ui}/TagInput/theme.js +1 -1
- package/dist/src/utils/css.d.ts +4 -0
- package/dist/src/utils/css.d.ts.map +1 -0
- package/dist/src/utils/css.js +5 -0
- package/dist/src/utils/detectVersion.d.ts +9 -0
- package/dist/src/utils/detectVersion.d.ts.map +1 -0
- package/dist/src/utils/detectVersion.js +29 -0
- package/dist/src/utils/href.d.ts +11 -0
- package/dist/src/utils/href.d.ts.map +1 -0
- package/dist/src/utils/href.js +34 -0
- package/dist/src/v0_8/Provider.d.ts +17 -0
- package/dist/src/v0_8/Provider.d.ts.map +1 -0
- package/dist/src/v0_8/Provider.js +59 -0
- package/dist/src/v0_8/SurfaceRenderer.d.ts +3 -0
- package/dist/src/v0_8/SurfaceRenderer.d.ts.map +1 -0
- package/dist/src/v0_8/SurfaceRenderer.js +21 -0
- package/dist/src/v0_8/registry.d.ts +12 -0
- package/dist/src/v0_8/registry.d.ts.map +1 -0
- package/dist/src/v0_8/registry.js +35 -0
- package/dist/src/v0_8/theme.d.ts +11 -0
- package/dist/src/v0_8/theme.d.ts.map +1 -0
- package/dist/src/v0_8/theme.js +77 -0
- package/dist/src/v0_9/Provider.d.ts +16 -0
- package/dist/src/v0_9/Provider.d.ts.map +1 -0
- package/dist/src/v0_9/Provider.js +65 -0
- package/dist/src/v0_9/SurfaceRenderer.d.ts +3 -0
- package/dist/src/v0_9/SurfaceRenderer.d.ts.map +1 -0
- package/dist/src/v0_9/SurfaceRenderer.js +21 -0
- package/dist/src/{utils → v0_9}/catalog.d.ts +1 -2
- package/dist/src/v0_9/catalog.d.ts.map +1 -0
- package/dist/src/{utils → v0_9}/catalog.js +5 -6
- package/dist/src/v0_9/useSurfaces.d.ts.map +1 -0
- package/json/README.md +24 -42
- package/json/v0_8/a2ui-sample-messages.json +2024 -0
- package/json/v0_8/glchat_standard_catalog_definition.json +870 -0
- package/json/{a2ui-sample-messages.json → v0_9/a2ui-sample-messages.json} +12 -2
- package/json/{glchat_standard_catalog_definition.json → v0_9/glchat_standard_catalog_definition.json} +286 -68
- package/package.json +4 -5
- package/styles/globals.css +157 -68
- package/dist/src/components/a2ui/Button/Button.d.ts.map +0 -1
- package/dist/src/components/a2ui/ChoicePicker/CheckboxList.d.ts.map +0 -1
- package/dist/src/components/a2ui/ChoicePicker/ChoicePicker.d.ts.map +0 -1
- package/dist/src/components/a2ui/ChoicePicker/theme.d.ts.map +0 -1
- package/dist/src/components/a2ui/TagInput/TagInput.d.ts.map +0 -1
- package/dist/src/components/a2ui/TagInput/theme.d.ts.map +0 -1
- package/dist/src/components/a2ui/Timeout/Timeout.d.ts.map +0 -1
- package/dist/src/components/a2ui/common.d.ts.map +0 -1
- package/dist/src/components/ui/Checkbox/theme.d.ts +0 -5
- package/dist/src/components/ui/Checkbox/theme.d.ts.map +0 -1
- package/dist/src/components/ui/Checkbox/theme.js +0 -26
- package/dist/src/utils/catalog.d.ts.map +0 -1
- package/dist/src/utils/useSurfaces.d.ts.map +0 -1
- /package/dist/src/components/a2ui/{Button → v0_9/Button}/Button.d.ts +0 -0
- /package/dist/src/components/a2ui/{ChoicePicker → v0_9/ChoicePicker}/ChoicePicker.d.ts +0 -0
- /package/dist/src/components/a2ui/{Timeout → v0_9/Timeout}/Timeout.d.ts +0 -0
- /package/dist/src/components/a2ui/{common.d.ts → v0_9/common.d.ts} +0 -0
- /package/dist/src/components/a2ui/{common.js → v0_9/common.js} +0 -0
- /package/dist/src/components/{a2ui → ui}/TagInput/theme.d.ts +0 -0
- /package/dist/src/{utils → v0_9}/useSurfaces.d.ts +0 -0
- /package/dist/src/{utils → v0_9}/useSurfaces.js +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { litTheme } from '@a2ui/react/v0_8';
|
|
2
|
+
import { buttonComponents } from '../components/a2ui/v0_8/Button/theme.js';
|
|
3
|
+
import { buttonAsLinkComponents } from '../components/a2ui/v0_8/ButtonAsLink/theme.js';
|
|
4
|
+
import { cardAdditionalStyles, cardComponents } from '../components/a2ui/v0_8/Card/theme.js';
|
|
5
|
+
import { dateTimeInputComponents } from '../components/a2ui/v0_8/DateTimeInput/theme.js';
|
|
6
|
+
import { destructiveButtonComponents } from '../components/a2ui/v0_8/DestructiveButton/theme.js';
|
|
7
|
+
import { textFieldComponents } from '../components/a2ui/v0_8/TextField/theme.js';
|
|
8
|
+
/** GLChat-owned component class maps merged into the default A2UI theme. */
|
|
9
|
+
const components = {
|
|
10
|
+
...litTheme.components,
|
|
11
|
+
Card: cardComponents,
|
|
12
|
+
Button: buttonComponents,
|
|
13
|
+
TextField: textFieldComponents,
|
|
14
|
+
DateTimeInput: dateTimeInputComponents,
|
|
15
|
+
DestructiveButton: destructiveButtonComponents,
|
|
16
|
+
ButtonAsLink: buttonAsLinkComponents,
|
|
17
|
+
};
|
|
18
|
+
/** GLChat-owned inline style overrides merged into the default A2UI theme. */
|
|
19
|
+
const additionalStyles = {
|
|
20
|
+
...litTheme.additionalStyles,
|
|
21
|
+
Card: { ...cardAdditionalStyles },
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Default theme passed to Provider. Starts from upstream litTheme and layers
|
|
25
|
+
* GLChat component class maps and inline styles from each a2ui component theme file.
|
|
26
|
+
*/
|
|
27
|
+
export const glchatDefaultTheme = {
|
|
28
|
+
...litTheme,
|
|
29
|
+
components,
|
|
30
|
+
additionalStyles,
|
|
31
|
+
};
|
|
32
|
+
const DEEP_MERGE_COMPONENT_KEYS = [
|
|
33
|
+
'Card',
|
|
34
|
+
'Button',
|
|
35
|
+
'TextField',
|
|
36
|
+
'DateTimeInput',
|
|
37
|
+
'DestructiveButton',
|
|
38
|
+
'ButtonAsLink',
|
|
39
|
+
];
|
|
40
|
+
function mergeSection(base, patch, deepMergeKeys) {
|
|
41
|
+
if (!patch)
|
|
42
|
+
return base;
|
|
43
|
+
const merged = { ...base, ...patch };
|
|
44
|
+
for (const key of deepMergeKeys) {
|
|
45
|
+
if (patch[key] === undefined)
|
|
46
|
+
continue;
|
|
47
|
+
if (!(key in base))
|
|
48
|
+
continue;
|
|
49
|
+
merged[key] = {
|
|
50
|
+
...base[key],
|
|
51
|
+
...patch[key],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return merged;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Merges consumer overrides into glchatDefaultTheme.
|
|
58
|
+
*/
|
|
59
|
+
export function mergeGlchatTheme(override) {
|
|
60
|
+
if (!override) {
|
|
61
|
+
return glchatDefaultTheme;
|
|
62
|
+
}
|
|
63
|
+
const mergedComponents = mergeSection(components, override.components, DEEP_MERGE_COMPONENT_KEYS);
|
|
64
|
+
const mergedAdditionalStyles = mergeSection(additionalStyles, override.additionalStyles, DEEP_MERGE_COMPONENT_KEYS);
|
|
65
|
+
return {
|
|
66
|
+
...glchatDefaultTheme,
|
|
67
|
+
...override,
|
|
68
|
+
components: mergedComponents,
|
|
69
|
+
elements: override.elements
|
|
70
|
+
? { ...glchatDefaultTheme.elements, ...override.elements }
|
|
71
|
+
: glchatDefaultTheme.elements,
|
|
72
|
+
markdown: override.markdown
|
|
73
|
+
? { ...glchatDefaultTheme.markdown, ...override.markdown }
|
|
74
|
+
: glchatDefaultTheme.markdown,
|
|
75
|
+
additionalStyles: mergedAdditionalStyles,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PropsWithChildren } from 'react';
|
|
2
|
+
import { type ReactComponentImplementation } from '@a2ui/react/v0_9';
|
|
3
|
+
import { type Catalog, type A2uiClientAction, type SurfaceGroupModel } from '@a2ui/web_core/v0_9';
|
|
4
|
+
import type { V09Message } from '../utils/detectVersion.js';
|
|
5
|
+
export type V09ActionPayload = A2uiClientAction;
|
|
6
|
+
export type V09ActionHandler = (action: A2uiClientAction) => void | Promise<void>;
|
|
7
|
+
export type V09MessageErrorHandler = (error: unknown) => void;
|
|
8
|
+
export type V09ProviderProps = {
|
|
9
|
+
messages?: V09Message[];
|
|
10
|
+
onAction?: V09ActionHandler;
|
|
11
|
+
onError?: V09MessageErrorHandler;
|
|
12
|
+
catalog?: Catalog<ReactComponentImplementation>;
|
|
13
|
+
};
|
|
14
|
+
export declare function V09Provider({ messages, onAction, onError, catalog, children, }: Readonly<PropsWithChildren<V09ProviderProps>>): import("react").JSX.Element;
|
|
15
|
+
export declare function useSurfaceGroup(): SurfaceGroupModel<ReactComponentImplementation>;
|
|
16
|
+
//# sourceMappingURL=Provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/v0_9/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,OAAO,EAAmB,KAAK,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAG5D,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,CAAC;AAChD,MAAM,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAClF,MAAM,MAAM,sBAAsB,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,UAAU,EAAE,CAAC;IACxB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC,4BAA4B,CAAC,CAAC;CACjD,CAAC;AAMF,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,OAAO,EACP,QAAQ,GACT,EAAE,QAAQ,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,+BA6D/C;AAED,wBAAgB,eAAe,IAAI,iBAAiB,CAAC,4BAA4B,CAAC,CAIjF"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { MarkdownContext } from '@a2ui/react/v0_9';
|
|
5
|
+
import { MessageProcessor, } from '@a2ui/web_core/v0_9';
|
|
6
|
+
import { injectBasicCatalogStyles } from '@a2ui/web_core/v0_9/basic_catalog';
|
|
7
|
+
import { renderMarkdown } from '@a2ui/markdown-it';
|
|
8
|
+
import { createGlchatCatalog } from './catalog.js';
|
|
9
|
+
const SurfaceGroupContext = createContext(null);
|
|
10
|
+
export function V09Provider({ messages, onAction, onError, catalog, children, }) {
|
|
11
|
+
const onActionRef = useRef(onAction);
|
|
12
|
+
const onErrorRef = useRef(onError);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
onActionRef.current = onAction;
|
|
15
|
+
}, [onAction]);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
onErrorRef.current = onError;
|
|
18
|
+
}, [onError]);
|
|
19
|
+
const [processor] = useState(() => {
|
|
20
|
+
const resolvedCatalog = catalog ?? createGlchatCatalog();
|
|
21
|
+
return new MessageProcessor([resolvedCatalog]);
|
|
22
|
+
});
|
|
23
|
+
const processedCountRef = useRef(0);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const subscription = processor.model.onAction.subscribe((action) => {
|
|
26
|
+
onActionRef.current?.(action);
|
|
27
|
+
});
|
|
28
|
+
return () => subscription.unsubscribe();
|
|
29
|
+
}, [processor]);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (typeof document !== 'undefined' && document.adoptedStyleSheets) {
|
|
32
|
+
injectBasicCatalogStyles();
|
|
33
|
+
}
|
|
34
|
+
}, []);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!messages?.length)
|
|
37
|
+
return;
|
|
38
|
+
if (messages.length < processedCountRef.current) {
|
|
39
|
+
processedCountRef.current = 0;
|
|
40
|
+
}
|
|
41
|
+
if (processedCountRef.current >= messages.length)
|
|
42
|
+
return;
|
|
43
|
+
const pending = messages.slice(processedCountRef.current);
|
|
44
|
+
processedCountRef.current = messages.length;
|
|
45
|
+
try {
|
|
46
|
+
processor.processMessages(pending);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
if (onErrorRef.current) {
|
|
50
|
+
onErrorRef.current(error);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
// eslint-disable-next-line no-console
|
|
54
|
+
console.error('[glchat-a2ui] Failed to process v0.9 messages:', error);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}, [messages, processor]);
|
|
58
|
+
return (_jsx(SurfaceGroupContext.Provider, { value: processor.model, children: _jsx(MarkdownContext.Provider, { value: renderMarkdown, children: children }) }));
|
|
59
|
+
}
|
|
60
|
+
export function useSurfaceGroup() {
|
|
61
|
+
const model = useContext(SurfaceGroupContext);
|
|
62
|
+
if (!model)
|
|
63
|
+
throw new Error('useSurfaceGroup must be used inside Provider (v0.9)');
|
|
64
|
+
return model;
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SurfaceRenderer.d.ts","sourceRoot":"","sources":["../../../src/v0_9/SurfaceRenderer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAMlE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,+BA4BvE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { A2uiSurface } from '@a2ui/react/v0_9';
|
|
4
|
+
import { useSurfaceGroup } from './Provider.js';
|
|
5
|
+
import { useSurfaces } from './useSurfaces.js';
|
|
6
|
+
const DEFAULT_FALLBACK = _jsx(_Fragment, {});
|
|
7
|
+
export function V09SurfaceRenderer(props) {
|
|
8
|
+
const model = useSurfaceGroup();
|
|
9
|
+
const surfaces = useSurfaces(model);
|
|
10
|
+
const fallback = props.fallback ?? DEFAULT_FALLBACK;
|
|
11
|
+
const surfaceClassName = props.className ? `a2ui-surface ${props.className}` : 'a2ui-surface';
|
|
12
|
+
if (props.surfaceId !== undefined) {
|
|
13
|
+
const surface = model.getSurface(props.surfaceId);
|
|
14
|
+
if (!surface)
|
|
15
|
+
return _jsx(_Fragment, { children: fallback });
|
|
16
|
+
return (_jsx("div", { className: surfaceClassName, children: _jsx(A2uiSurface, { surface: surface }) }));
|
|
17
|
+
}
|
|
18
|
+
if (surfaces.length === 0)
|
|
19
|
+
return _jsx(_Fragment, { children: fallback });
|
|
20
|
+
return (_jsx(_Fragment, { children: surfaces.map((surface) => (_jsx("div", { className: surfaceClassName, children: _jsx(A2uiSurface, { surface: surface }) }, surface.id))) }));
|
|
21
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { type ReactComponentImplementation } from '@a2ui/react/v0_9';
|
|
2
2
|
import { Catalog } from '@a2ui/web_core/v0_9';
|
|
3
3
|
/**
|
|
4
|
-
* Catalog identifier for the GLChat extended A2UI v0.9 catalog.
|
|
5
|
-
* `catalogId` in `createSurface` messages targeting the GLChat renderer.
|
|
4
|
+
* Catalog identifier for the GLChat extended A2UI v0.9 catalog.
|
|
6
5
|
*/
|
|
7
6
|
export declare const GLCHAT_CATALOG_ID = "https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/glchat_standard_catalog_definition.json";
|
|
8
7
|
/** Basic catalog components whose JSON Schema is regenerated from Zod. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/v0_9/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAO9C;;GAEG;AACH,eAAO,MAAM,iBAAiB,iIACkG,CAAC;AAKjI,0EAA0E;AAC1E,eAAO,MAAM,wBAAwB,qBAAsB,CAAC;AAE5D,+DAA+D;AAC/D,eAAO,MAAM,yBAAyB,kCAAmC,CAAC;AAE1E;;;;;GAKG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,4BAA4B,CAAC,CAgB3E"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { basicCatalog } from '@a2ui/react/v0_9';
|
|
2
2
|
import { Catalog } from '@a2ui/web_core/v0_9';
|
|
3
|
-
import { GlchatButtonComponent } from '../components/a2ui/Button/Button.js';
|
|
4
|
-
import { GlchatChoicePickerComponent } from '../components/a2ui/ChoicePicker/ChoicePicker.js';
|
|
5
|
-
import { GlchatTagInputComponent } from '../components/a2ui/TagInput/TagInput.js';
|
|
6
|
-
import { GlchatTimeoutComponent } from '../components/a2ui/Timeout/Timeout.js';
|
|
3
|
+
import { GlchatButtonComponent } from '../components/a2ui/v0_9/Button/Button.js';
|
|
4
|
+
import { GlchatChoicePickerComponent } from '../components/a2ui/v0_9/ChoicePicker/ChoicePicker.js';
|
|
5
|
+
import { GlchatTagInputComponent } from '../components/a2ui/v0_9/TagInput/TagInput.js';
|
|
6
|
+
import { GlchatTimeoutComponent } from '../components/a2ui/v0_9/Timeout/Timeout.js';
|
|
7
7
|
/**
|
|
8
|
-
* Catalog identifier for the GLChat extended A2UI v0.9 catalog.
|
|
9
|
-
* `catalogId` in `createSurface` messages targeting the GLChat renderer.
|
|
8
|
+
* Catalog identifier for the GLChat extended A2UI v0.9 catalog.
|
|
10
9
|
*/
|
|
11
10
|
export const GLCHAT_CATALOG_ID = 'https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/glchat_standard_catalog_definition.json';
|
|
12
11
|
/** Basic catalog components overridden at runtime by GLChat implementations. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSurfaces.d.ts","sourceRoot":"","sources":["../../../src/v0_9/useSurfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAG3E;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,iBAAiB,CAAC,4BAA4B,CAAC,GACrD,YAAY,CAAC,4BAA4B,CAAC,EAAE,CA6B9C"}
|
package/json/README.md
CHANGED
|
@@ -1,61 +1,43 @@
|
|
|
1
1
|
# JSON reference files
|
|
2
2
|
|
|
3
|
-
This folder contains JSON schema and sample payload files for the GLChat A2UI React renderer
|
|
4
|
-
|
|
5
|
-
These files are generated from the official A2UI v0.9 basic catalog plus GLChat
|
|
6
|
-
extensions. To regenerate the catalog JSON after changing a component schema, run:
|
|
7
|
-
|
|
8
|
-
```bash
|
|
9
|
-
npm run generate:json
|
|
10
|
-
```
|
|
3
|
+
This folder contains JSON schema and sample payload files for the GLChat A2UI React renderer, split by schema version under `v0_8/` and `v0_9/`.
|
|
11
4
|
|
|
12
5
|
---
|
|
13
6
|
|
|
14
|
-
##
|
|
7
|
+
## v0.9 files (`v0_9/`)
|
|
15
8
|
|
|
16
|
-
|
|
17
|
-
It **extends** the official basic catalog JSON Schema (same structure as the
|
|
18
|
-
[rizzcharts custom catalog example](https://github.com/a2ui-project/a2ui/blob/main/samples/community/agent/adk/rizzcharts/catalog_schemas/0.9/rizzcharts_catalog_definition.json)):
|
|
19
|
-
clone [basic/catalog.json](https://github.com/a2ui-project/a2ui/blob/main/specification/v0_9/catalogs/basic/catalog.json),
|
|
20
|
-
normalize `common_types.json` refs, then merge GLChat overrides and extensions
|
|
21
|
-
generated from the live Zod component APIs.
|
|
9
|
+
### `v0_9/glchat_standard_catalog_definition.json`
|
|
22
10
|
|
|
23
|
-
|
|
11
|
+
The GLChat extended A2UI **v0.9** unified catalog.
|
|
24
12
|
|
|
25
13
|
**Catalog ID:** `https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/glchat_standard_catalog_definition.json`
|
|
26
14
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
1. **`Button`** (override) — GLChat-styled button. Extends the basic catalog schema
|
|
30
|
-
with a `destructive` variant.
|
|
15
|
+
**Base specification:** [A2UI v0.9 basic catalog](https://github.com/a2ui-project/a2ui/blob/main/specification/v0_9/catalogs/basic/catalog.json)
|
|
31
16
|
|
|
32
|
-
|
|
33
|
-
basic catalog.
|
|
17
|
+
GLChat overrides/extensions: `Button`, `ChoicePicker`, `TagInput`, `Timeout`.
|
|
34
18
|
|
|
35
|
-
|
|
36
|
-
`placeholder`, `disabled`, `disableTextInput`, `validationRegexp`,
|
|
37
|
-
`validationErrorMessage`.
|
|
19
|
+
To regenerate the v0.9 catalog JSON after changing a component schema, run:
|
|
38
20
|
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
```bash
|
|
22
|
+
npm run generate:json
|
|
23
|
+
```
|
|
41
24
|
|
|
42
|
-
###
|
|
25
|
+
### `v0_9/a2ui-sample-messages.json`
|
|
43
26
|
|
|
44
|
-
|
|
45
|
-
|---|---|
|
|
46
|
-
| Text, Image, Icon, Video, AudioPlayer | v0.9 basic catalog |
|
|
47
|
-
| Row, Column, List, Card, Tabs, Divider, Modal | v0.9 basic catalog |
|
|
48
|
-
| TextField, CheckBox, Slider, DateTimeInput | v0.9 basic catalog |
|
|
49
|
-
| Button | GLChat override |
|
|
50
|
-
| ChoicePicker | GLChat override |
|
|
51
|
-
| TagInput | GLChat extension |
|
|
52
|
-
| Timeout | GLChat extension |
|
|
27
|
+
A2UI **v0.9** sample messages (`createSurface`, `updateDataModel`, `updateComponents`) for surface `"main"`.
|
|
53
28
|
|
|
54
29
|
---
|
|
55
30
|
|
|
56
|
-
##
|
|
31
|
+
## v0.8 files (`v0_8/`)
|
|
32
|
+
|
|
33
|
+
### `v0_8/glchat_standard_catalog_definition.json`
|
|
34
|
+
|
|
35
|
+
The GLChat extended A2UI **v0.8** catalog. Extends the [v0.8 standard catalog](https://a2ui.org/specification/v0_8/standard_catalog_definition.json) with `ButtonAsLink`, `DestructiveButton`, `TagInput`, and `Timeout`.
|
|
36
|
+
|
|
37
|
+
**Catalog ID:** `https://github.com/GDP-ADMIN/glchat-sdk/blob/main/js/glchat-a2ui-react-renderer/json/v0_8/glchat_standard_catalog_definition.json`
|
|
38
|
+
|
|
39
|
+
When `beginRendering` omits `catalogId`, `Provider` injects this catalog ID automatically.
|
|
40
|
+
|
|
41
|
+
### `v0_8/a2ui-sample-messages.json`
|
|
57
42
|
|
|
58
|
-
|
|
59
|
-
`updateComponents`) describing a surface that includes **every component** from the
|
|
60
|
-
catalog. Validated against the catalog during generation. Use for reference and
|
|
61
|
-
testing.
|
|
43
|
+
A2UI **v0.8** sample messages (`beginRendering`, `surfaceUpdate`) for surface `"all-components-demo"`. Demonstrates standard catalog components plus GLChat-styled `Button` and `MultipleChoice` variants.
|