glchat-a2ui-react-renderer 0.2.8 → 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
package/README.md
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# glchat-a2ui-react-renderer
|
|
2
2
|
|
|
3
|
-
GLChat styling and component extensions for [`@a2ui/react`](https://www.npmjs.com/package/@a2ui/react) (**A2UI v0.9**). This package wraps the standard A2UI renderer pipeline with
|
|
3
|
+
GLChat styling and component extensions for [`@a2ui/react`](https://www.npmjs.com/package/@a2ui/react) (**A2UI v0.8 and v0.9**). This package wraps the standard A2UI renderer pipeline with registered catalogs, design tokens, and GLChat-specific UI components.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
7
|
| Export | Description |
|
|
8
8
|
|---|---|
|
|
9
|
-
| `Provider` | Owns
|
|
9
|
+
| `Provider` | Owns message processing, surface state, and the GLChat catalog |
|
|
10
10
|
| `SurfaceRenderer` | Renders one or all active surfaces (requires `Provider`) |
|
|
11
|
+
| `useA2UIVersion` | Returns the active protocol version (`v0.8` or `v0.9`) |
|
|
11
12
|
| Design tokens | `styles/globals.css`, `styles/theme-v4.css`, `tailwind-config.cjs` |
|
|
12
13
|
|
|
13
14
|
## Requirements
|
|
@@ -22,14 +23,27 @@ GLChat styling and component extensions for [`@a2ui/react`](https://www.npmjs.co
|
|
|
22
23
|
npm install glchat-a2ui-react-renderer
|
|
23
24
|
```
|
|
24
25
|
|
|
25
|
-
##
|
|
26
|
+
## Version selection
|
|
27
|
+
|
|
28
|
+
`Provider` supports both A2UI v0.8 and v0.9 through a single API.
|
|
29
|
+
|
|
30
|
+
| Mode | Behavior |
|
|
31
|
+
|---|---|
|
|
32
|
+
| Default | Uses **v0.9** when no messages are present |
|
|
33
|
+
| Auto-detect | When `version` is omitted and `messages` arrive, detects from the first message (`version: "v0.9"` or v0.8 keys like `beginRendering`) |
|
|
34
|
+
| Explicit | Pass `version="v0.8"` or `version="v0.9"` to lock the protocol |
|
|
35
|
+
|
|
36
|
+
## Quick start (v0.9)
|
|
26
37
|
|
|
27
38
|
```tsx
|
|
28
39
|
import { Provider, SurfaceRenderer } from 'glchat-a2ui-react-renderer';
|
|
29
40
|
import type { A2UIMessage, ActionPayload } from 'glchat-a2ui-react-renderer';
|
|
30
41
|
|
|
31
42
|
function App() {
|
|
32
|
-
const messages: A2UIMessage[] = [
|
|
43
|
+
const messages: A2UIMessage[] = [
|
|
44
|
+
{ version: 'v0.9', createSurface: { surfaceId: 'main', catalogId: '/* ... */' } },
|
|
45
|
+
{ version: 'v0.9', updateComponents: { surfaceId: 'main', components: [/* ... */] } },
|
|
46
|
+
];
|
|
33
47
|
|
|
34
48
|
const handleAction = (action: ActionPayload) => {
|
|
35
49
|
// { name, surfaceId, sourceComponentId, timestamp, context }
|
|
@@ -44,12 +58,34 @@ function App() {
|
|
|
44
58
|
}
|
|
45
59
|
```
|
|
46
60
|
|
|
47
|
-
|
|
61
|
+
Sample payloads: [`json/v0_9/a2ui-sample-messages.json`](json/v0_9/a2ui-sample-messages.json).
|
|
62
|
+
|
|
63
|
+
## Quick start (v0.8)
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
import { Provider, SurfaceRenderer } from 'glchat-a2ui-react-renderer';
|
|
67
|
+
import type { A2UIMessage, ActionPayload } from 'glchat-a2ui-react-renderer';
|
|
68
|
+
|
|
69
|
+
function App() {
|
|
70
|
+
const messages: A2UIMessage[] = [
|
|
71
|
+
{ beginRendering: { surfaceId: 'main', root: 'root' } },
|
|
72
|
+
{ surfaceUpdate: { surfaceId: 'main', components: [/* ... */] } },
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
const handleAction = (action: ActionPayload) => {
|
|
76
|
+
// { name, surfaceId, sourceComponentId, timestamp, context }
|
|
77
|
+
console.log('Action:', action);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Provider messages={messages} onAction={handleAction}>
|
|
82
|
+
<SurfaceRenderer surfaceId="main" />
|
|
83
|
+
</Provider>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
48
87
|
|
|
49
|
-
|
|
50
|
-
- The `fallback` prop controls the loading UI (default: `"Waiting for agent..."`).
|
|
51
|
-
- `Provider` configures markdown rendering for `Text` via `@a2ui/markdown-it`.
|
|
52
|
-
- `onAction` receives v0.9 `A2uiClientAction` payloads from interactive components.
|
|
88
|
+
Sample payloads: [`json/v0_8/a2ui-sample-messages.json`](json/v0_8/a2ui-sample-messages.json).
|
|
53
89
|
|
|
54
90
|
## Icons
|
|
55
91
|
|
|
@@ -89,7 +125,7 @@ To adopt Inter explicitly:
|
|
|
89
125
|
|
|
90
126
|
## GLChat catalog
|
|
91
127
|
|
|
92
|
-
|
|
128
|
+
### v0.9 catalog
|
|
93
129
|
|
|
94
130
|
| Component | Role |
|
|
95
131
|
|---|---|
|
|
@@ -98,6 +134,19 @@ To adopt Inter explicitly:
|
|
|
98
134
|
| `TagInput` | Extension |
|
|
99
135
|
| `Timeout` | Extension |
|
|
100
136
|
|
|
137
|
+
### v0.8 catalog
|
|
138
|
+
|
|
139
|
+
| Component | Role |
|
|
140
|
+
|---|---|
|
|
141
|
+
| `Button` | Override — GLChat styling with `primary` prop |
|
|
142
|
+
| `ButtonAsLink` | Extension — borderless link-style button |
|
|
143
|
+
| `DestructiveButton` | Extension — destructive action button |
|
|
144
|
+
| `MultipleChoice` | Override — chips and checkbox variants |
|
|
145
|
+
| `TagInput` | Extension |
|
|
146
|
+
| `Timeout` | Extension |
|
|
147
|
+
|
|
148
|
+
Component implementations live under `src/components/a2ui/v0_9/` and `src/components/a2ui/v0_8/`.
|
|
149
|
+
|
|
101
150
|
See [Custom components](#custom-components) to register additional components on top of this catalog. Component schemas are documented in [`json/README.md`](json/README.md).
|
|
102
151
|
|
|
103
152
|
## Custom components (Optional)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
export { Provider, useSurfaceGroup, type ProviderProps, type A2UIMessage, type ActionPayload, type ActionHandler, type MessageErrorHandler, } from './src/Provider.js';
|
|
1
|
+
export { Provider, useSurfaceGroup, useA2UIRegistry, useA2UIVersion, type ProviderProps, type A2UIMessage, type ActionPayload, type ActionHandler, type MessageErrorHandler, } from './src/Provider.js';
|
|
2
2
|
export { SurfaceRenderer, type SurfaceRendererProps } from './src/SurfaceRenderer.js';
|
|
3
|
-
export { useSurfaces } from './src/
|
|
4
|
-
export { createGlchatCatalog, GLCHAT_CATALOG_ID } from './src/
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
3
|
+
export { useSurfaces } from './src/v0_9/useSurfaces.js';
|
|
4
|
+
export { createGlchatCatalog, GLCHAT_CATALOG_ID } from './src/v0_9/catalog.js';
|
|
5
|
+
export { createGlchatRegistry, GLCHAT_CATALOG_ID_V08, ensureGlchatComponentsRegistered } from './src/v0_8/registry.js';
|
|
6
|
+
export { GlchatButtonComponent, GlchatButtonApi } from './src/components/a2ui/v0_9/Button/Button.js';
|
|
7
|
+
export { GlchatChoicePickerComponent } from './src/components/a2ui/v0_9/ChoicePicker/ChoicePicker.js';
|
|
8
|
+
export { GlchatTagInputComponent, TagInputApi } from './src/components/a2ui/v0_9/TagInput/TagInput.js';
|
|
9
|
+
export { GlchatTimeoutComponent, TimeoutApi } from './src/components/a2ui/v0_9/Timeout/Timeout.js';
|
|
9
10
|
export { A2uiSurface, createComponentImplementation, createBinderlessComponentImplementation, MarkdownContext, useMarkdownRenderer, type ReactComponentImplementation, type ReactA2uiComponentProps, } from '@a2ui/react/v0_9';
|
|
10
11
|
export { Catalog, MessageProcessor, SurfaceModel, SurfaceGroupModel, ComponentIdSchema, ChildListSchema, ActionSchema, DynamicStringSchema, DynamicNumberSchema, DynamicBooleanSchema, DynamicStringListSchema, DynamicValueSchema, CheckableSchema, AccessibilityAttributesSchema, type ComponentApi, type A2uiMessage, type A2uiClientAction, } from '@a2ui/web_core/v0_9';
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,eAAe,EACf,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,mBAAmB,GACzB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEtF,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,eAAe,EACf,eAAe,EACf,cAAc,EACd,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,mBAAmB,GACzB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEtF,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,gCAAgC,EAAE,MAAM,wBAAwB,CAAC;AAGvH,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,6CAA6C,CAAC;AACrG,OAAO,EAAE,2BAA2B,EAAE,MAAM,yDAAyD,CAAC;AACtG,OAAO,EAAE,uBAAuB,EAAE,WAAW,EAAE,MAAM,iDAAiD,CAAC;AACvG,OAAO,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,+CAA+C,CAAC;AAGnG,OAAO,EACL,WAAW,EACX,6BAA6B,EAC7B,uCAAuC,EACvC,eAAe,EACf,mBAAmB,EACnB,KAAK,4BAA4B,EACjC,KAAK,uBAAuB,GAC7B,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,OAAO,EACP,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,EACf,6BAA6B,EAC7B,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
export { Provider, useSurfaceGroup, } from './src/Provider.js';
|
|
1
|
+
export { Provider, useSurfaceGroup, useA2UIRegistry, useA2UIVersion, } from './src/Provider.js';
|
|
2
2
|
export { SurfaceRenderer } from './src/SurfaceRenderer.js';
|
|
3
|
-
export { useSurfaces } from './src/
|
|
4
|
-
export { createGlchatCatalog, GLCHAT_CATALOG_ID } from './src/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
3
|
+
export { useSurfaces } from './src/v0_9/useSurfaces.js';
|
|
4
|
+
export { createGlchatCatalog, GLCHAT_CATALOG_ID } from './src/v0_9/catalog.js';
|
|
5
|
+
export { createGlchatRegistry, GLCHAT_CATALOG_ID_V08, ensureGlchatComponentsRegistered } from './src/v0_8/registry.js';
|
|
6
|
+
// GLChat custom component implementations and their schemas (v0.9)
|
|
7
|
+
export { GlchatButtonComponent, GlchatButtonApi } from './src/components/a2ui/v0_9/Button/Button.js';
|
|
8
|
+
export { GlchatChoicePickerComponent } from './src/components/a2ui/v0_9/ChoicePicker/ChoicePicker.js';
|
|
9
|
+
export { GlchatTagInputComponent, TagInputApi } from './src/components/a2ui/v0_9/TagInput/TagInput.js';
|
|
10
|
+
export { GlchatTimeoutComponent, TimeoutApi } from './src/components/a2ui/v0_9/Timeout/Timeout.js';
|
|
10
11
|
// Re-exports from the official `@a2ui/react` (v0.9), for authoring components.
|
|
11
12
|
export { A2uiSurface, createComponentImplementation, createBinderlessComponentImplementation, MarkdownContext, useMarkdownRenderer, } from '@a2ui/react/v0_9';
|
|
12
13
|
// Re-exports from `@a2ui/web_core` (v0.9)
|
package/dist/src/Provider.d.ts
CHANGED
|
@@ -1,30 +1,37 @@
|
|
|
1
1
|
import type { PropsWithChildren } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import type { ComponentRegistry } from '@a2ui/react/v0_8';
|
|
3
|
+
import type { ReactComponentImplementation } from '@a2ui/react/v0_9';
|
|
4
|
+
import type { Theme } from '@a2ui/web_core/v0_8';
|
|
5
|
+
import type { A2uiClientAction, Catalog } from '@a2ui/web_core/v0_9';
|
|
6
|
+
import { type A2UIMessage, type A2UIVersion } from './utils/detectVersion.js';
|
|
7
|
+
import type { V08ActionPayload } from './v0_8/Provider.js';
|
|
8
|
+
export type { A2UIMessage } from './utils/detectVersion.js';
|
|
9
|
+
export type ActionPayload = A2uiClientAction | V08ActionPayload;
|
|
10
|
+
export type ActionHandler = (action: ActionPayload) => void | Promise<void>;
|
|
7
11
|
export type MessageErrorHandler = (error: unknown) => void;
|
|
8
12
|
export type ProviderProps = {
|
|
9
13
|
/**
|
|
10
14
|
* A2UI messages to process. Only **new** messages appended since the last
|
|
11
15
|
* render are fed to the processor (append-only). To replace the full batch,
|
|
12
|
-
* remount `Provider` (e.g. change `key`)
|
|
13
|
-
* `createSurface`.
|
|
16
|
+
* remount `Provider` (e.g. change `key`).
|
|
14
17
|
*/
|
|
15
18
|
messages?: A2UIMessage[];
|
|
16
|
-
onAction?: ActionHandler;
|
|
17
|
-
onError?: MessageErrorHandler;
|
|
18
19
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
20
|
+
* A2UI protocol version. When omitted, defaults to `v0.9` until messages
|
|
21
|
+
* arrive, then auto-detects from the first message.
|
|
21
22
|
*/
|
|
23
|
+
version?: A2UIVersion;
|
|
24
|
+
onAction?: ActionHandler;
|
|
25
|
+
onError?: MessageErrorHandler;
|
|
26
|
+
/** v0.9 only — optional catalog override. */
|
|
22
27
|
catalog?: Catalog<ReactComponentImplementation>;
|
|
28
|
+
/** v0.8 only — theme override merged into the GLChat default theme. */
|
|
29
|
+
theme?: Theme;
|
|
30
|
+
/** v0.8 only — optional component registry override. */
|
|
31
|
+
registry?: ComponentRegistry;
|
|
23
32
|
};
|
|
24
|
-
export declare function Provider({ messages, onAction, onError, catalog, children, }: Readonly<PropsWithChildren<ProviderProps>>): import("react").JSX.Element;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
*/
|
|
29
|
-
export declare function useSurfaceGroup(): SurfaceGroupModel<ReactComponentImplementation>;
|
|
33
|
+
export declare function Provider({ messages, version: versionProp, onAction, onError, theme, catalog, registry, children, }: Readonly<PropsWithChildren<ProviderProps>>): import("react").JSX.Element;
|
|
34
|
+
export declare function useA2UIVersion(): A2UIVersion;
|
|
35
|
+
export { useSurfaceGroup } from './v0_9/Provider.js';
|
|
36
|
+
export { useA2UIRegistry } from './v0_8/Provider.js';
|
|
30
37
|
//# sourceMappingURL=Provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../src/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,OAAO,
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../src/Provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAErE,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,WAAW,EAGjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAI3D,YAAY,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D,MAAM,MAAM,aAAa,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAChE,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,aAAa,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAC5E,MAAM,MAAM,mBAAmB,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG;IAC1B;;;;OAIG;IACH,QAAQ,CAAC,EAAE,WAAW,EAAE,CAAC;IACzB;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,QAAQ,CAAC,EAAE,aAAa,CAAC;IACzB,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,6CAA6C;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAChD,uEAAuE;IACvE,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,wDAAwD;IACxD,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B,CAAC;AAgBF,wBAAgB,QAAQ,CAAC,EACvB,QAAQ,EACR,OAAO,EAAE,WAAW,EACpB,QAAQ,EACR,OAAO,EACP,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,GACT,EAAE,QAAQ,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC,+BAkE5C;AAED,wBAAgB,cAAc,IAAI,WAAW,CAE5C;AAED,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/src/Provider.js
CHANGED
|
@@ -1,70 +1,54 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useContext, useEffect, useRef, useState } from 'react';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
import { createContext, useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
+
import { detectMessagesVersion, } from './utils/detectVersion.js';
|
|
5
|
+
import { V08Provider } from './v0_8/Provider.js';
|
|
6
|
+
import { V09Provider } from './v0_9/Provider.js';
|
|
7
|
+
const A2UIVersionContext = createContext('v0.9');
|
|
8
|
+
function resolveVersion(versionProp, messages) {
|
|
9
|
+
if (versionProp)
|
|
10
|
+
return versionProp;
|
|
11
|
+
if (messages?.length) {
|
|
12
|
+
const detected = detectMessagesVersion(messages);
|
|
13
|
+
if (detected)
|
|
14
|
+
return detected;
|
|
15
|
+
}
|
|
16
|
+
return 'v0.9';
|
|
17
|
+
}
|
|
18
|
+
export function Provider({ messages, version: versionProp, onAction, onError, theme, catalog, registry, children, }) {
|
|
12
19
|
const onErrorRef = useRef(onError);
|
|
13
|
-
|
|
14
|
-
onActionRef.current = onAction;
|
|
15
|
-
}, [onAction]);
|
|
20
|
+
const lockedVersionRef = useRef(null);
|
|
16
21
|
useEffect(() => {
|
|
17
22
|
onErrorRef.current = onError;
|
|
18
23
|
}, [onError]);
|
|
19
|
-
const
|
|
20
|
-
|
|
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
|
-
}, []);
|
|
24
|
+
const resolvedVersion = useMemo(() => resolveVersion(versionProp, messages), [versionProp, messages]);
|
|
25
|
+
const [activeVersion, setActiveVersion] = useState(resolvedVersion);
|
|
35
26
|
useEffect(() => {
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if (messages.length < processedCountRef.current) {
|
|
40
|
-
processedCountRef.current = 0;
|
|
41
|
-
}
|
|
42
|
-
if (processedCountRef.current >= messages.length)
|
|
27
|
+
if (lockedVersionRef.current === null) {
|
|
28
|
+
lockedVersionRef.current = resolvedVersion;
|
|
29
|
+
setActiveVersion(resolvedVersion);
|
|
43
30
|
return;
|
|
44
|
-
const pending = messages.slice(processedCountRef.current);
|
|
45
|
-
processedCountRef.current = messages.length;
|
|
46
|
-
try {
|
|
47
|
-
processor.processMessages(pending);
|
|
48
31
|
}
|
|
49
|
-
|
|
32
|
+
if (resolvedVersion !== lockedVersionRef.current) {
|
|
33
|
+
const error = new Error(`A2UI version mismatch: Provider is locked to ${lockedVersionRef.current}, but messages indicate ${resolvedVersion}.`);
|
|
50
34
|
if (onErrorRef.current) {
|
|
51
35
|
onErrorRef.current(error);
|
|
52
36
|
}
|
|
53
37
|
else {
|
|
54
38
|
// eslint-disable-next-line no-console
|
|
55
|
-
console.error('[glchat-a2ui]
|
|
39
|
+
console.error('[glchat-a2ui]', error);
|
|
56
40
|
}
|
|
41
|
+
return;
|
|
57
42
|
}
|
|
58
|
-
|
|
59
|
-
|
|
43
|
+
setActiveVersion(resolvedVersion);
|
|
44
|
+
}, [resolvedVersion]);
|
|
45
|
+
if (activeVersion === 'v0.8') {
|
|
46
|
+
return (_jsx(A2UIVersionContext.Provider, { value: "v0.8", children: _jsx(V08Provider, { messages: messages, theme: theme, onAction: onAction, onError: onError, registry: registry, children: children }) }));
|
|
47
|
+
}
|
|
48
|
+
return (_jsx(A2UIVersionContext.Provider, { value: "v0.9", children: _jsx(V09Provider, { messages: messages, onAction: onAction, onError: onError, catalog: catalog, children: children }) }));
|
|
60
49
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
* Used by the surface renderers to read and subscribe to active surfaces.
|
|
64
|
-
*/
|
|
65
|
-
export function useSurfaceGroup() {
|
|
66
|
-
const model = useContext(SurfaceGroupContext);
|
|
67
|
-
if (!model)
|
|
68
|
-
throw new Error('useSurfaceGroup must be used inside Provider');
|
|
69
|
-
return model;
|
|
50
|
+
export function useA2UIVersion() {
|
|
51
|
+
return useContext(A2UIVersionContext);
|
|
70
52
|
}
|
|
53
|
+
export { useSurfaceGroup } from './v0_9/Provider.js';
|
|
54
|
+
export { useA2UIRegistry } from './v0_8/Provider.js';
|
|
@@ -5,13 +5,11 @@ export type SurfaceRendererProps = {
|
|
|
5
5
|
className?: string;
|
|
6
6
|
/** Shown while no surface(s) are available to render. */
|
|
7
7
|
fallback?: ReactNode;
|
|
8
|
+
/** v0.8 only — loading fallback for lazy-loaded components. */
|
|
9
|
+
loadingFallback?: ReactNode;
|
|
8
10
|
};
|
|
9
11
|
/**
|
|
10
12
|
* Renders one or all active A2UI surfaces from the nearest `Provider`.
|
|
11
|
-
*
|
|
12
|
-
* - Omit `surfaceId` to render every active surface.
|
|
13
|
-
* - Set `surfaceId` to render a single surface.
|
|
14
|
-
* - Shows `fallback` (default: empty) until surface(s) exist.
|
|
15
13
|
*/
|
|
16
14
|
export declare function SurfaceRenderer(props: Readonly<SurfaceRendererProps>): import("react").JSX.Element;
|
|
17
15
|
//# sourceMappingURL=SurfaceRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SurfaceRenderer.d.ts","sourceRoot":"","sources":["../../src/SurfaceRenderer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SurfaceRenderer.d.ts","sourceRoot":"","sources":["../../src/SurfaceRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAMvC,MAAM,MAAM,oBAAoB,GAAG;IACjC,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,+DAA+D;IAC/D,eAAe,CAAC,EAAE,SAAS,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,CAAC,oBAAoB,CAAC,+BAQpE"}
|
|
@@ -1,28 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
const DEFAULT_FALLBACK = _jsx(_Fragment, {});
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useA2UIVersion } from './Provider.js';
|
|
4
|
+
import { V08SurfaceRenderer } from './v0_8/SurfaceRenderer.js';
|
|
5
|
+
import { V09SurfaceRenderer } from './v0_9/SurfaceRenderer.js';
|
|
7
6
|
/**
|
|
8
7
|
* Renders one or all active A2UI surfaces from the nearest `Provider`.
|
|
9
|
-
*
|
|
10
|
-
* - Omit `surfaceId` to render every active surface.
|
|
11
|
-
* - Set `surfaceId` to render a single surface.
|
|
12
|
-
* - Shows `fallback` (default: empty) until surface(s) exist.
|
|
13
8
|
*/
|
|
14
9
|
export function SurfaceRenderer(props) {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const surfaceClassName = props.className ? `a2ui-surface ${props.className}` : 'a2ui-surface';
|
|
19
|
-
if (props.surfaceId !== undefined) {
|
|
20
|
-
const surface = model.getSurface(props.surfaceId);
|
|
21
|
-
if (!surface)
|
|
22
|
-
return _jsx(_Fragment, { children: fallback });
|
|
23
|
-
return (_jsx("div", { className: surfaceClassName, children: _jsx(A2uiSurface, { surface: surface }) }));
|
|
10
|
+
const version = useA2UIVersion();
|
|
11
|
+
if (version === 'v0.8') {
|
|
12
|
+
return _jsx(V08SurfaceRenderer, { ...props });
|
|
24
13
|
}
|
|
25
|
-
|
|
26
|
-
return _jsx(_Fragment, { children: fallback });
|
|
27
|
-
return (_jsx(_Fragment, { children: surfaces.map((surface) => (_jsx("div", { className: surfaceClassName, children: _jsx(A2uiSurface, { surface: surface }) }, surface.id))) }));
|
|
14
|
+
return _jsx(V09SurfaceRenderer, { ...props });
|
|
28
15
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type A2UIComponentProps } from '@a2ui/react/v0_8';
|
|
2
|
+
import type { ButtonNode } from '@a2ui/web_core/v0_8';
|
|
3
|
+
export declare function CustomButtonComponent({ node, surfaceId, }: Readonly<A2UIComponentProps<ButtonNode>>): import("react").JSX.Element;
|
|
4
|
+
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/v0_8/Button/Button.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAOtD,wBAAgB,qBAAqB,CAAC,EACpC,IAAI,EACJ,SAAS,GACV,EAAE,QAAQ,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,+BAiC1C"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { ComponentNode, classMapToString, stylesToObject, useA2UIComponent, } from '@a2ui/react/v0_8';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { Button } from '../../../../components/ui/Button/Button.js';
|
|
6
|
+
export function CustomButtonComponent({ node, surfaceId, }) {
|
|
7
|
+
const { sendAction, theme } = useA2UIComponent(node, surfaceId);
|
|
8
|
+
const { child, action, primary } = node.properties;
|
|
9
|
+
const variant = useMemo(() => (primary ? 'primary' : 'outline'), [primary]);
|
|
10
|
+
const buttonStyle = useMemo(() => stylesToObject(theme.additionalStyles?.Button), [theme.additionalStyles?.Button]);
|
|
11
|
+
const handleClick = () => {
|
|
12
|
+
if (action) {
|
|
13
|
+
sendAction(action);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const hostStyle = node.weight === void 0 ? undefined : { '--weight': node.weight };
|
|
17
|
+
return (_jsx("div", { className: "a2ui-button", style: hostStyle, children: _jsx(Button, { variant: variant, className: classMapToString(theme.components.Button), style: buttonStyle, onClick: handleClick, children: child ? _jsx(ComponentNode, { node: child, surfaceId: surfaceId }) : null }) }));
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/v0_8/Button/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEjD,yEAAyE;AACzE,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,QAAQ,CAE1D,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type A2UIComponentProps } from '@a2ui/react/v0_8';
|
|
2
|
+
import type { CustomNode } from '@a2ui/web_core/v0_8';
|
|
3
|
+
export declare function CustomButtonAsLinkComponent({ node, surfaceId, }: Readonly<A2UIComponentProps<CustomNode>>): import("react").JSX.Element;
|
|
4
|
+
//# sourceMappingURL=ButtonAsLink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ButtonAsLink.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/v0_8/ButtonAsLink/ButtonAsLink.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,kBAAkB,EAExB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAoB,UAAU,EAAE,MAAM,qBAAqB,CAAC;AA2CxE,wBAAgB,2BAA2B,CAAC,EAC1C,IAAI,EACJ,SAAS,GACV,EAAE,QAAQ,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,+BAiD1C"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { ComponentNode, classMapToString, stylesToObject, useA2UIComponent, } from '@a2ui/react/v0_8';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { ButtonAsLink } from '../../../../components/ui/Button/ButtonAsLink.js';
|
|
6
|
+
import { cn } from '../../../../utils/css.js';
|
|
7
|
+
import { sanitizeHref, sanitizeTarget } from '../../../../utils/href.js';
|
|
8
|
+
import { buttonAsLinkComponents } from './theme.js';
|
|
9
|
+
function resolveStringValue(value, resolveString, getValue) {
|
|
10
|
+
if (!value)
|
|
11
|
+
return undefined;
|
|
12
|
+
if (value.path) {
|
|
13
|
+
const raw = getValue(value.path);
|
|
14
|
+
if (raw == null)
|
|
15
|
+
return undefined;
|
|
16
|
+
if (typeof raw === 'string')
|
|
17
|
+
return raw;
|
|
18
|
+
if (typeof raw === 'number' || typeof raw === 'boolean')
|
|
19
|
+
return String(raw);
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
return resolveString(value) ?? undefined;
|
|
23
|
+
}
|
|
24
|
+
function resolveHref(href, resolveString, getValue) {
|
|
25
|
+
const resolved = resolveStringValue(href, resolveString, getValue);
|
|
26
|
+
return sanitizeHref(resolved ?? '#');
|
|
27
|
+
}
|
|
28
|
+
export function CustomButtonAsLinkComponent({ node, surfaceId, }) {
|
|
29
|
+
const { theme, resolveString, getValue } = useA2UIComponent(node, surfaceId);
|
|
30
|
+
const { child, href, target } = node.properties;
|
|
31
|
+
const buttonAsLinkTheme = useMemo(() => {
|
|
32
|
+
const components = theme.components;
|
|
33
|
+
return components.ButtonAsLink ?? buttonAsLinkComponents;
|
|
34
|
+
}, [theme.components]);
|
|
35
|
+
const linkStyle = useMemo(() => stylesToObject(theme.additionalStyles?.ButtonAsLink), [theme.additionalStyles]);
|
|
36
|
+
const resolvedHref = useMemo(() => resolveHref(href, resolveString, getValue), [getValue, href, resolveString]);
|
|
37
|
+
const resolvedTarget = useMemo(() => {
|
|
38
|
+
const raw = resolveStringValue(target, resolveString, getValue);
|
|
39
|
+
return raw ? sanitizeTarget(raw) : undefined;
|
|
40
|
+
}, [getValue, resolveString, target]);
|
|
41
|
+
const hostStyle = node.weight === void 0 ? undefined : { '--weight': node.weight };
|
|
42
|
+
return (_jsx("div", { className: cn('a2ui-button a2ui-button-as-link', classMapToString(buttonAsLinkTheme.container)), style: hostStyle, children: _jsx(ButtonAsLink, { href: resolvedHref, target: resolvedTarget, className: classMapToString(buttonAsLinkTheme.element), style: linkStyle, children: child ? _jsx(ComponentNode, { node: child, surfaceId: surfaceId }) : null }) }));
|
|
43
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type ButtonAsLinkTheme = {
|
|
2
|
+
container: Record<string, boolean>;
|
|
3
|
+
element: Record<string, boolean>;
|
|
4
|
+
};
|
|
5
|
+
/** Marks the link button with our CSS hook (`.glchat-a2ui-button`). */
|
|
6
|
+
export declare const buttonAsLinkComponents: ButtonAsLinkTheme;
|
|
7
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/v0_8/ButtonAsLink/theme.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,sBAAsB,EAAE,iBAKpC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/v0_8/Card/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEjD,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,MAAM,CAEtD,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC,MAAM,CAW/E,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const cardComponents = {
|
|
2
|
+
'layout-p-4': true,
|
|
3
|
+
};
|
|
4
|
+
export const cardAdditionalStyles = {
|
|
5
|
+
backgroundColor: 'hsl(var(--card))',
|
|
6
|
+
color: 'hsl(var(--card-foreground))',
|
|
7
|
+
borderColor: 'hsl(var(--border))',
|
|
8
|
+
borderWidth: '1px',
|
|
9
|
+
borderStyle: 'solid',
|
|
10
|
+
borderRadius: 'var(--radius)',
|
|
11
|
+
boxShadow: '0 1px 2px 0 rgb(0 0 0 / 0.05)',
|
|
12
|
+
transitionProperty: 'color, background-color, border-color, box-shadow',
|
|
13
|
+
transitionTimingFunction: 'cubic-bezier(0.4, 0, 0.2, 1)',
|
|
14
|
+
transitionDuration: '300ms',
|
|
15
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Theme } from '@a2ui/web_core/v0_8';
|
|
2
|
+
/**
|
|
3
|
+
* Empty maps clear litTheme utility classes (e.g. horizontal flex).
|
|
4
|
+
* Visual styles live in styles/globals.css under `.a2ui-datetime-input`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const dateTimeInputComponents: Theme['components']['DateTimeInput'];
|
|
7
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/v0_8/DateTimeInput/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,eAAe,CAIxE,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type A2UIComponentProps } from '@a2ui/react/v0_8';
|
|
2
|
+
import type { CustomNode } from '@a2ui/web_core/v0_8';
|
|
3
|
+
export declare function CustomDestructiveButtonComponent({ node, surfaceId, }: Readonly<A2UIComponentProps<CustomNode>>): import("react").JSX.Element;
|
|
4
|
+
//# sourceMappingURL=DestructiveButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DestructiveButton.d.ts","sourceRoot":"","sources":["../../../../../../src/components/a2ui/v0_8/DestructiveButton/DestructiveButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAWlE,wBAAgB,gCAAgC,CAAC,EAC/C,IAAI,EACJ,SAAS,GACV,EAAE,QAAQ,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,+BA6C1C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { ComponentNode, classMapToString, stylesToObject, useA2UIComponent, } from '@a2ui/react/v0_8';
|
|
4
|
+
import { useMemo } from 'react';
|
|
5
|
+
import { Button } from '../../../../components/ui/Button/Button.js';
|
|
6
|
+
import { cn } from '../../../../utils/css.js';
|
|
7
|
+
import { destructiveButtonComponents } from './theme.js';
|
|
8
|
+
export function CustomDestructiveButtonComponent({ node, surfaceId, }) {
|
|
9
|
+
const { sendAction, theme } = useA2UIComponent(node, surfaceId);
|
|
10
|
+
const { child, action } = node.properties;
|
|
11
|
+
const destructiveButtonTheme = useMemo(() => {
|
|
12
|
+
const components = theme.components;
|
|
13
|
+
return components.DestructiveButton ?? destructiveButtonComponents;
|
|
14
|
+
}, [theme.components]);
|
|
15
|
+
const buttonStyle = useMemo(() => stylesToObject(theme.additionalStyles?.DestructiveButton), [theme.additionalStyles]);
|
|
16
|
+
const handleClick = () => {
|
|
17
|
+
if (action) {
|
|
18
|
+
sendAction(action);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const hostStyle = node.weight === void 0 ? undefined : { '--weight': node.weight };
|
|
22
|
+
return (_jsx("div", { className: cn('a2ui-button a2ui-destructive-button', classMapToString(destructiveButtonTheme.container)), style: hostStyle, children: _jsx(Button, { variant: "destructive", className: classMapToString(destructiveButtonTheme.element), style: buttonStyle, onClick: handleClick, children: child ? _jsx(ComponentNode, { node: child, surfaceId: surfaceId }) : null }) }));
|
|
23
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type DestructiveButtonTheme = {
|
|
2
|
+
container: Record<string, boolean>;
|
|
3
|
+
element: Record<string, boolean>;
|
|
4
|
+
};
|
|
5
|
+
/** Marks the destructive button with our CSS hook (`.glchat-a2ui-button`). */
|
|
6
|
+
export declare const destructiveButtonComponents: DestructiveButtonTheme;
|
|
7
|
+
//# sourceMappingURL=theme.d.ts.map
|