glchat-a2ui-react-renderer 0.3.4 → 0.3.6
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/dist/src/components/a2ui/v0_8/UnknownComponent/UnknownComponent.d.ts.map +1 -1
- package/dist/src/components/a2ui/v0_8/UnknownComponent/UnknownComponent.js +1 -1
- package/dist/src/components/a2ui/v0_9/Button/Button.d.ts +2 -2
- package/dist/src/components/a2ui/v0_9/Timeout/Timeout.d.ts +2 -2
- package/dist/src/components/a2ui/v0_9/UnknownComponent/UnknownComponent.d.ts.map +1 -1
- package/dist/src/components/a2ui/v0_9/UnknownComponent/UnknownComponent.js +1 -1
- package/dist/src/components/ui/InlineAlert/InlineAlert.d.ts +60 -9
- package/dist/src/components/ui/InlineAlert/InlineAlert.d.ts.map +1 -1
- package/dist/src/components/ui/InlineAlert/InlineAlert.js +4 -3
- package/dist/src/v0_8/Provider.d.ts.map +1 -1
- package/dist/src/v0_8/Provider.js +2 -2
- package/dist/src/v0_9/Provider.d.ts.map +1 -1
- package/dist/src/v0_9/Provider.js +2 -2
- package/dist/src/v0_9/SurfaceErrorBoundary.d.ts +18 -0
- package/dist/src/v0_9/SurfaceErrorBoundary.d.ts.map +1 -0
- package/dist/src/v0_9/SurfaceErrorBoundary.js +24 -0
- package/dist/src/v0_9/SurfaceRenderer.d.ts.map +1 -1
- package/dist/src/v0_9/SurfaceRenderer.js +4 -3
- package/package.json +1 -1
- package/styles/globals.css +44 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnknownComponent.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/v0_8/UnknownComponent/UnknownComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAI3D;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,IAAI,EAAE,EAAE,QAAQ,CAAC,kBAAkB,CAAC,+
|
|
1
|
+
{"version":3,"file":"UnknownComponent.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/v0_8/UnknownComponent/UnknownComponent.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAI3D;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EAAE,IAAI,EAAE,EAAE,QAAQ,CAAC,kBAAkB,CAAC,+BAW5E"}
|
|
@@ -9,5 +9,5 @@ export function CustomUnknownComponent({ node }) {
|
|
|
9
9
|
const type = node && typeof node === 'object' && 'type' in node && node.type != null
|
|
10
10
|
? String(node.type)
|
|
11
11
|
: 'unknown';
|
|
12
|
-
return (_jsx(InlineAlert, { role: "status", variant: "warning",
|
|
12
|
+
return (_jsx(InlineAlert, { role: "status", variant: "warning", children: `Unknown A2UI component: ${type}` }));
|
|
13
13
|
}
|
|
@@ -229,8 +229,8 @@ export declare const GlchatButtonApi: {
|
|
|
229
229
|
returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
|
|
230
230
|
};
|
|
231
231
|
};
|
|
232
|
-
variant?: "primary" | "destructive" | "borderless" | "default" | undefined;
|
|
233
232
|
weight?: number | undefined;
|
|
233
|
+
variant?: "primary" | "destructive" | "borderless" | "default" | undefined;
|
|
234
234
|
accessibility?: {
|
|
235
235
|
description?: string | {
|
|
236
236
|
path: string;
|
|
@@ -277,8 +277,8 @@ export declare const GlchatButtonApi: {
|
|
|
277
277
|
returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
|
|
278
278
|
};
|
|
279
279
|
};
|
|
280
|
-
variant?: "primary" | "destructive" | "borderless" | "default" | undefined;
|
|
281
280
|
weight?: number | undefined;
|
|
281
|
+
variant?: "primary" | "destructive" | "borderless" | "default" | undefined;
|
|
282
282
|
accessibility?: {
|
|
283
283
|
description?: string | {
|
|
284
284
|
path: string;
|
|
@@ -105,8 +105,8 @@ export declare const TimeoutApi: {
|
|
|
105
105
|
args: Record<string, any>;
|
|
106
106
|
returnType: "string" | "number" | "boolean" | "object" | "array" | "void" | "any";
|
|
107
107
|
};
|
|
108
|
-
variant?: "caption" | "h3" | "body" | "h4" | "h5" | undefined;
|
|
109
108
|
weight?: number | undefined;
|
|
109
|
+
variant?: "caption" | "h3" | "body" | "h4" | "h5" | undefined;
|
|
110
110
|
accessibility?: {
|
|
111
111
|
description?: string | {
|
|
112
112
|
path: string;
|
|
@@ -131,8 +131,8 @@ export declare const TimeoutApi: {
|
|
|
131
131
|
args: Record<string, any>;
|
|
132
132
|
returnType?: "string" | "number" | "boolean" | "object" | "array" | "void" | "any" | undefined;
|
|
133
133
|
};
|
|
134
|
-
variant?: "caption" | "h3" | "body" | "h4" | "h5" | undefined;
|
|
135
134
|
weight?: number | undefined;
|
|
135
|
+
variant?: "caption" | "h3" | "body" | "h4" | "h5" | undefined;
|
|
136
136
|
accessibility?: {
|
|
137
137
|
description?: string | {
|
|
138
138
|
path: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnknownComponent.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/v0_9/UnknownComponent/UnknownComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"UnknownComponent.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/v0_9/UnknownComponent/UnknownComponent.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;GAGG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;0BAsBqqZ,CAAC;;;;;;;;;;;;;;;;;;;0BAAivB,CAAC;;;;;;;;;;;;;;;;;;;;;;;0BAA2sB,CAAC;;;;;;;0BAA0O,CAAC;;;;;;;;;;;;;;;;;;;;;;;0BAA1qD,CAAC;;;;;;;;;;;;;;;;;;;0BAAivB,CAAC;;;;;;;;;;;;;;;;;;;;;;;0BAA2sB,CAAC;;;;;;;0BAA0O,CAAC;;;;;;;;;;;;;;;;;;;;;;;0BAA1qD,CAAC;;;;;;;;;;;;;;;;;;;0BAAivB,CAAC;;;;;;;;;;;;;;;;;;;;;;;0BAA2sB,CAAC;;;;;;;0BAA0O,CAAC;;;;;CAd92c,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,yDAOpC,CAAC"}
|
|
@@ -21,4 +21,4 @@ export const UnknownComponentApi = {
|
|
|
21
21
|
* Renders a warning alert for unknown component types.
|
|
22
22
|
* Wired into catalogs via `installUnknownComponentFallback`.
|
|
23
23
|
*/
|
|
24
|
-
export const UnknownComponentFallback = createBinderlessComponentImplementation(UnknownComponentApi, ({ context }) => (_jsx(InlineAlert, { role: "status", variant: "warning",
|
|
24
|
+
export const UnknownComponentFallback = createBinderlessComponentImplementation(UnknownComponentApi, ({ context }) => (_jsx(InlineAlert, { role: "status", variant: "warning", children: `Unknown A2UI component: ${context.componentModel.type}` })));
|
|
@@ -1,14 +1,65 @@
|
|
|
1
|
-
import { type HTMLAttributes } from 'react';
|
|
1
|
+
import { type HTMLAttributes, type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
export type InlineAlertVariant = 'neutral' | 'warning' | 'error' | 'success';
|
|
2
3
|
export type InlineAlertProps = HTMLAttributes<HTMLDivElement> & {
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Visual tone. Defaults to `warning` for A2UI status surfaces.
|
|
6
|
+
*/
|
|
7
|
+
variant?: InlineAlertVariant;
|
|
8
|
+
/**
|
|
9
|
+
* Alert message content.
|
|
10
|
+
*/
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
/**
|
|
13
|
+
* Called when the action button is clicked.
|
|
14
|
+
* Shown only when both `actionClick` and `actionLabel` are set.
|
|
15
|
+
*/
|
|
16
|
+
actionClick?: () => void;
|
|
17
|
+
/**
|
|
18
|
+
* Label for the optional action button.
|
|
19
|
+
*/
|
|
20
|
+
actionLabel?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Extra class name for the action button.
|
|
23
|
+
*/
|
|
24
|
+
actionClassName?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Optional custom icon. Defaults to a circle alert mark.
|
|
27
|
+
*/
|
|
28
|
+
icon?: ReactElement;
|
|
29
|
+
/**
|
|
30
|
+
* Extra class name for the message element.
|
|
31
|
+
*/
|
|
32
|
+
messageClassName?: string;
|
|
7
33
|
};
|
|
8
34
|
export declare const InlineAlert: import("react").ForwardRefExoticComponent<HTMLAttributes<HTMLDivElement> & {
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Visual tone. Defaults to `warning` for A2UI status surfaces.
|
|
37
|
+
*/
|
|
38
|
+
variant?: InlineAlertVariant;
|
|
39
|
+
/**
|
|
40
|
+
* Alert message content.
|
|
41
|
+
*/
|
|
42
|
+
children?: ReactNode;
|
|
43
|
+
/**
|
|
44
|
+
* Called when the action button is clicked.
|
|
45
|
+
* Shown only when both `actionClick` and `actionLabel` are set.
|
|
46
|
+
*/
|
|
47
|
+
actionClick?: () => void;
|
|
48
|
+
/**
|
|
49
|
+
* Label for the optional action button.
|
|
50
|
+
*/
|
|
51
|
+
actionLabel?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Extra class name for the action button.
|
|
54
|
+
*/
|
|
55
|
+
actionClassName?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Optional custom icon. Defaults to a circle alert mark.
|
|
58
|
+
*/
|
|
59
|
+
icon?: ReactElement;
|
|
60
|
+
/**
|
|
61
|
+
* Extra class name for the message element.
|
|
62
|
+
*/
|
|
63
|
+
messageClassName?: string;
|
|
13
64
|
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
14
65
|
//# sourceMappingURL=InlineAlert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InlineAlert.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/InlineAlert/InlineAlert.tsx"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"InlineAlert.d.ts","sourceRoot":"","sources":["../../../../../src/components/ui/InlineAlert/InlineAlert.tsx"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAKf,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAE7E,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IAC9D;;OAEG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB;;OAEG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B,CAAC;AAEF,eAAO,MAAM,WAAW;IA/BtB;;OAEG;cACO,kBAAkB;IAC5B;;OAEG;eACQ,SAAS;IACpB;;;OAGG;kBACW,MAAM,IAAI;IACxB;;OAEG;kBACW,MAAM;IACpB;;OAEG;sBACe,MAAM;IACxB;;OAEG;WACI,YAAY;IACnB;;OAEG;uBACgB,MAAM;kDAkD1B,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { CircleAlert } from 'lucide-react';
|
|
4
|
-
import { forwardRef } from 'react';
|
|
4
|
+
import { forwardRef, } from 'react';
|
|
5
|
+
import { Button } from '../../../components/ui/Button/Button.js';
|
|
5
6
|
import { cn } from '../../../utils/css.js';
|
|
6
|
-
export const InlineAlert = forwardRef(function InlineAlert({
|
|
7
|
-
return (_jsxs("div", { className: cn('glchat-a2ui-inline-alert', `glchat-a2ui-inline-alert--${variant}`, className), ref: ref, ...props, children: [_jsx("div", { className: "glchat-a2ui-inline-alert__icon", children: _jsx(CircleAlert, { className: "glchat-a2ui-inline-alert__svg", strokeWidth: 1.5 }) }),
|
|
7
|
+
export const InlineAlert = forwardRef(function InlineAlert({ actionClick, actionLabel, actionClassName, className, icon, messageClassName, variant = 'warning', children, ...props }, ref) {
|
|
8
|
+
return (_jsxs("div", { className: cn('glchat-a2ui-inline-alert', `glchat-a2ui-inline-alert--${variant}`, className), ref: ref, ...props, children: [_jsx("div", { className: "glchat-a2ui-inline-alert__icon", children: icon ?? (_jsx(CircleAlert, { className: "glchat-a2ui-inline-alert__svg", strokeWidth: 1.5 })) }), _jsxs("div", { className: "glchat-a2ui-inline-alert__body", children: [_jsx("div", { className: cn('glchat-a2ui-inline-alert__message', messageClassName), children: children }), !!actionClick && !!actionLabel && (_jsx(Button, { className: cn('glchat-a2ui-inline-alert__action', actionClassName), onClick: actionClick, variant: "borderless", children: actionLabel }))] })] }));
|
|
8
9
|
});
|
|
9
10
|
InlineAlert.displayName = 'InlineAlert';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/v0_8/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAW/C,OAAO,EAEL,iBAAiB,EAEjB,KAAK,sBAAsB,EAC5B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAyB,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAGxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAA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E,KAAK,CAAC;IACd,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,OAAO,CAAC,EAAE,sBAAsB,CAAC;IACjC,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B,CAAC;AAuDF,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,OAAO,EACP,QAAQ,EAAE,YAAY,EACtB,QAAQ,GACT,EAAE,QAAQ,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,+BAgC/C;AAED,wBAAgB,eAAe,IAAI,iBAAiB,CAInD"}
|
|
@@ -6,7 +6,7 @@ import { InlineAlert } from '../components/ui/InlineAlert/InlineAlert.js';
|
|
|
6
6
|
import { ensureGlchatComponentsRegistered } from './registry.js';
|
|
7
7
|
import { mergeGlchatTheme } from './theme.js';
|
|
8
8
|
const A2UIRegistryContext = createContext(null);
|
|
9
|
-
const PROCESS_ERROR_MESSAGE = '
|
|
9
|
+
const PROCESS_ERROR_MESSAGE = 'Failed to process A2UI messages (v0.8)';
|
|
10
10
|
function MessagesProcessor({ messages, onError, }) {
|
|
11
11
|
const { processMessages } = useA2UI();
|
|
12
12
|
const processedCountRef = useRef(0);
|
|
@@ -39,7 +39,7 @@ function MessagesProcessor({ messages, onError, }) {
|
|
|
39
39
|
}, [messages, onError, processMessages]);
|
|
40
40
|
if (!processError)
|
|
41
41
|
return null;
|
|
42
|
-
return (_jsx("div", { className: "a2ui-surface", children: _jsx(InlineAlert, { role: "alert", variant: "warning",
|
|
42
|
+
return (_jsx("div", { className: "a2ui-surface", children: _jsx(InlineAlert, { role: "alert", variant: "warning", children: processError }) }));
|
|
43
43
|
}
|
|
44
44
|
export function V08Provider({ messages, theme, onAction, onError, registry: registryProp, children, }) {
|
|
45
45
|
const registry = useMemo(() => registryProp ?? ComponentRegistry.getInstance(), [registryProp]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/v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C;AACtF,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAK7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAQ5D,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;AAEF,KAAK,wBAAwB,GAAG;IAC9B,KAAK,EAAE,iBAAiB,CAAC,4BAA4B,CAAC,CAAC;IACvD,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAMF,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,OAAO,EACP,QAAQ,GACT,EAAE,QAAQ,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC,+BAoF/C;AAED,wBAAgB,eAAe,IAAI,wBAAwB,CAI1D"}
|
|
@@ -8,7 +8,7 @@ import { renderMarkdown } from '@a2ui/markdown-it';
|
|
|
8
8
|
import { InlineAlert } from '../components/ui/InlineAlert/InlineAlert.js';
|
|
9
9
|
import { createGlchatCatalog, GLCHAT_CATALOG_ID, installUnknownComponentFallback, withFallbackCatalogId, } from './catalog.js';
|
|
10
10
|
const SurfaceGroupContext = createContext(null);
|
|
11
|
-
const PROCESS_ERROR_MESSAGE = '
|
|
11
|
+
const PROCESS_ERROR_MESSAGE = 'Failed to process A2UI messages (v0.9)';
|
|
12
12
|
export function V09Provider({ messages, onAction, onError, catalog, children, }) {
|
|
13
13
|
const onActionRef = useRef(onAction);
|
|
14
14
|
const onErrorRef = useRef(onError);
|
|
@@ -64,7 +64,7 @@ export function V09Provider({ messages, onAction, onError, catalog, children, })
|
|
|
64
64
|
}
|
|
65
65
|
}, [messages, processor, catalog?.id]);
|
|
66
66
|
const contextValue = useMemo(() => ({ model: processor.model, hasMessages }), [processor.model, hasMessages]);
|
|
67
|
-
return (_jsx(SurfaceGroupContext.Provider, { value: contextValue, children: _jsxs(MarkdownContext.Provider, { value: renderMarkdown, children: [processError ? (_jsx("div", { className: "a2ui-surface", children: _jsx(InlineAlert, { role: "alert", variant: "warning",
|
|
67
|
+
return (_jsx(SurfaceGroupContext.Provider, { value: contextValue, children: _jsxs(MarkdownContext.Provider, { value: renderMarkdown, children: [processError ? (_jsx("div", { className: "a2ui-surface", children: _jsx(InlineAlert, { role: "alert", variant: "warning", children: processError }) })) : null, children] }) }));
|
|
68
68
|
}
|
|
69
69
|
export function useSurfaceGroup() {
|
|
70
70
|
const ctx = useContext(SurfaceGroupContext);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Component, type ErrorInfo, type ReactNode } from 'react';
|
|
2
|
+
type SurfaceErrorBoundaryProps = Readonly<{
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
}>;
|
|
5
|
+
type SurfaceErrorBoundaryState = {
|
|
6
|
+
hasError: boolean;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Catches render errors from `@a2ui/react` catalog components.
|
|
10
|
+
*/
|
|
11
|
+
export declare class SurfaceErrorBoundary extends Component<SurfaceErrorBoundaryProps, SurfaceErrorBoundaryState> {
|
|
12
|
+
state: SurfaceErrorBoundaryState;
|
|
13
|
+
static getDerivedStateFromError(): SurfaceErrorBoundaryState;
|
|
14
|
+
componentDidCatch(error: Error, info: ErrorInfo): void;
|
|
15
|
+
render(): ReactNode;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=SurfaceErrorBoundary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SurfaceErrorBoundary.d.ts","sourceRoot":"","sources":["../../../src/v0_9/SurfaceErrorBoundary.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAMlE,KAAK,yBAAyB,GAAG,QAAQ,CAAC;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,CAAC,CAAC;AACnE,KAAK,yBAAyB,GAAG;IAAE,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC;AAEvD;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,SAAS,CACjD,yBAAyB,EACzB,yBAAyB,CAC1B;IACC,KAAK,EAAE,yBAAyB,CAAuB;IAEvD,MAAM,CAAC,wBAAwB,IAAI,yBAAyB;IAI5D,iBAAiB,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI;IAKtD,MAAM,IAAI,SAAS;CAUpB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Component } from 'react';
|
|
4
|
+
import { InlineAlert } from '../components/ui/InlineAlert/InlineAlert.js';
|
|
5
|
+
const RENDER_ERROR_MESSAGE = 'Failed to render A2UI surface';
|
|
6
|
+
/**
|
|
7
|
+
* Catches render errors from `@a2ui/react` catalog components.
|
|
8
|
+
*/
|
|
9
|
+
export class SurfaceErrorBoundary extends Component {
|
|
10
|
+
state = { hasError: false };
|
|
11
|
+
static getDerivedStateFromError() {
|
|
12
|
+
return { hasError: true };
|
|
13
|
+
}
|
|
14
|
+
componentDidCatch(error, info) {
|
|
15
|
+
// eslint-disable-next-line no-console -- match Provider message-process logging
|
|
16
|
+
console.error('[glchat-a2ui] Failed to render v0.9 surface:', error, info.componentStack);
|
|
17
|
+
}
|
|
18
|
+
render() {
|
|
19
|
+
if (this.state.hasError) {
|
|
20
|
+
return (_jsx(InlineAlert, { role: "alert", variant: "warning", children: RENDER_ERROR_MESSAGE }));
|
|
21
|
+
}
|
|
22
|
+
return this.props.children;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SurfaceRenderer.d.ts","sourceRoot":"","sources":["../../../src/v0_9/SurfaceRenderer.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"SurfaceRenderer.d.ts","sourceRoot":"","sources":["../../../src/v0_9/SurfaceRenderer.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AA6DlE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,+BAkCvE"}
|
|
@@ -4,9 +4,10 @@ import { useCallback, useSyncExternalStore } from 'react';
|
|
|
4
4
|
import { A2uiSurface } from '@a2ui/react/v0_9';
|
|
5
5
|
import { InlineAlert } from '../components/ui/InlineAlert/InlineAlert.js';
|
|
6
6
|
import { useSurfaceGroup } from './Provider.js';
|
|
7
|
+
import { SurfaceErrorBoundary } from './SurfaceErrorBoundary.js';
|
|
7
8
|
import { useSurfaces } from './useSurfaces.js';
|
|
8
9
|
const DEFAULT_FALLBACK = _jsx(_Fragment, {});
|
|
9
|
-
const ROOT_MISSING_MESSAGE = '
|
|
10
|
+
const ROOT_MISSING_MESSAGE = 'This A2UI interface could not be loaded because no root component was found.';
|
|
10
11
|
/** True when the surface has a `root` component (replace `@a2ui` "[Loading root...]"). */
|
|
11
12
|
function useHasRootComponent(surface) {
|
|
12
13
|
const subscribe = useCallback((onStoreChange) => {
|
|
@@ -25,9 +26,9 @@ function SurfaceView({ surface, className, fallback, hasMessages, }) {
|
|
|
25
26
|
if (!hasRoot) {
|
|
26
27
|
if (!hasMessages)
|
|
27
28
|
return _jsx(_Fragment, { children: fallback });
|
|
28
|
-
return (_jsx("div", { className: className, children: _jsx(InlineAlert, { role: "alert", variant: "warning",
|
|
29
|
+
return (_jsx("div", { className: className, children: _jsx(InlineAlert, { role: "alert", variant: "warning", children: ROOT_MISSING_MESSAGE }) }));
|
|
29
30
|
}
|
|
30
|
-
return (_jsx("div", { className: className, children: _jsx(A2uiSurface, { surface: surface }) }));
|
|
31
|
+
return (_jsx("div", { className: className, children: _jsx(SurfaceErrorBoundary, { children: _jsx(A2uiSurface, { surface: surface }) }) }));
|
|
31
32
|
}
|
|
32
33
|
export function V09SurfaceRenderer(props) {
|
|
33
34
|
const { model, hasMessages } = useSurfaceGroup();
|
package/package.json
CHANGED
package/styles/globals.css
CHANGED
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
--positive-alternate: 152 81% 96%;
|
|
44
44
|
--positive-alternate-foreground: 161 100% 22%;
|
|
45
45
|
|
|
46
|
-
--warning:
|
|
46
|
+
--warning: 28 100% 53%;
|
|
47
47
|
--warning-foreground: 0 0% 100%;
|
|
48
|
-
--warning-alternate:
|
|
49
|
-
--warning-alternate-foreground:
|
|
48
|
+
--warning-alternate: 36 100% 94%;
|
|
49
|
+
--warning-alternate-foreground: 28 100% 53%;
|
|
50
50
|
|
|
51
51
|
--ring: 198 100% 31%;
|
|
52
52
|
|
|
@@ -104,10 +104,10 @@
|
|
|
104
104
|
--positive-alternate: 161 100% 22%;
|
|
105
105
|
--positive-alternate-foreground: 152 81% 96%;
|
|
106
106
|
|
|
107
|
-
--warning:
|
|
108
|
-
--warning-
|
|
109
|
-
--warning-alternate:
|
|
110
|
-
--warning-
|
|
107
|
+
--warning: 30 100% 62%;
|
|
108
|
+
--warning-alternate: 22 100% 27%;
|
|
109
|
+
--warning-alternate-foreground: 30 100% 62%;
|
|
110
|
+
--warning-foreground: 0 0% 100%;
|
|
111
111
|
|
|
112
112
|
--ring: 196 71% 39%;
|
|
113
113
|
|
|
@@ -601,7 +601,7 @@
|
|
|
601
601
|
opacity: 0.5 !important;
|
|
602
602
|
}
|
|
603
603
|
|
|
604
|
-
/* Inline alert —
|
|
604
|
+
/* Inline alert — matches glchat-ui InlineAlert (border + icon tone) */
|
|
605
605
|
.a2ui-surface .glchat-a2ui-inline-alert {
|
|
606
606
|
position: relative;
|
|
607
607
|
display: flex;
|
|
@@ -610,17 +610,25 @@
|
|
|
610
610
|
max-width: 100%;
|
|
611
611
|
box-sizing: border-box;
|
|
612
612
|
border-radius: var(--radius-md);
|
|
613
|
+
border: 1px solid hsl(var(--border));
|
|
613
614
|
padding: 1rem;
|
|
615
|
+
background-color: hsl(var(--background));
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
.a2ui-surface .glchat-a2ui-inline-alert--neutral {
|
|
619
|
+
border-color: hsl(var(--border));
|
|
614
620
|
}
|
|
615
621
|
|
|
616
622
|
.a2ui-surface .glchat-a2ui-inline-alert--warning {
|
|
617
|
-
border:
|
|
618
|
-
background-color: hsl(var(--warning-alternate));
|
|
623
|
+
border-color: hsl(var(--warning-alternate-foreground));
|
|
619
624
|
}
|
|
620
625
|
|
|
621
626
|
.a2ui-surface .glchat-a2ui-inline-alert--error {
|
|
622
|
-
border:
|
|
623
|
-
|
|
627
|
+
border-color: hsl(var(--destructive));
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
.a2ui-surface .glchat-a2ui-inline-alert--success {
|
|
631
|
+
border-color: hsl(var(--positive));
|
|
624
632
|
}
|
|
625
633
|
|
|
626
634
|
.a2ui-surface .glchat-a2ui-inline-alert__icon {
|
|
@@ -631,16 +639,21 @@
|
|
|
631
639
|
width: 1.25rem;
|
|
632
640
|
height: 1.25rem;
|
|
633
641
|
flex-shrink: 0;
|
|
642
|
+
color: hsl(var(--border));
|
|
634
643
|
}
|
|
635
644
|
|
|
636
645
|
.a2ui-surface .glchat-a2ui-inline-alert--warning .glchat-a2ui-inline-alert__svg {
|
|
637
|
-
color: hsl(var(--warning));
|
|
646
|
+
color: hsl(var(--warning-alternate-foreground));
|
|
638
647
|
}
|
|
639
648
|
|
|
640
649
|
.a2ui-surface .glchat-a2ui-inline-alert--error .glchat-a2ui-inline-alert__svg {
|
|
641
650
|
color: hsl(var(--destructive));
|
|
642
651
|
}
|
|
643
652
|
|
|
653
|
+
.a2ui-surface .glchat-a2ui-inline-alert--success .glchat-a2ui-inline-alert__svg {
|
|
654
|
+
color: hsl(var(--positive));
|
|
655
|
+
}
|
|
656
|
+
|
|
644
657
|
.a2ui-surface .glchat-a2ui-inline-alert__body {
|
|
645
658
|
margin-left: 0.75rem;
|
|
646
659
|
display: flex;
|
|
@@ -650,18 +663,30 @@
|
|
|
650
663
|
overflow: hidden;
|
|
651
664
|
}
|
|
652
665
|
|
|
666
|
+
@media (min-width: 1024px) {
|
|
667
|
+
.a2ui-surface .glchat-a2ui-inline-alert__body {
|
|
668
|
+
flex-direction: row;
|
|
669
|
+
gap: 2.5rem;
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
653
673
|
.a2ui-surface .glchat-a2ui-inline-alert__message {
|
|
654
674
|
margin: 0;
|
|
655
675
|
flex: 1;
|
|
656
676
|
overflow: auto;
|
|
657
677
|
font-size: 0.875rem;
|
|
658
678
|
line-height: 1.5rem;
|
|
679
|
+
color: hsl(var(--foreground));
|
|
659
680
|
}
|
|
660
681
|
|
|
661
|
-
.a2ui-surface .glchat-a2ui-inline-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
682
|
+
.a2ui-surface .glchat-a2ui-inline-alert__action {
|
|
683
|
+
width: fit-content;
|
|
684
|
+
height: fit-content;
|
|
685
|
+
padding: 0;
|
|
686
|
+
color: hsl(var(--primary));
|
|
687
|
+
font-size: 0.875rem;
|
|
688
|
+
font-weight: 600;
|
|
689
|
+
line-height: 1.5rem;
|
|
690
|
+
text-decoration: underline;
|
|
691
|
+
text-underline-offset: 2px;
|
|
667
692
|
}
|