glchat-a2ui-react-renderer 0.0.4 → 0.0.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/README.md +217 -95
- package/dist/index.d.ts +2 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -17
- package/dist/src/a2ui/adapter.d.ts +3 -0
- package/dist/src/a2ui/adapter.d.ts.map +1 -0
- package/dist/src/a2ui/adapter.js +11 -0
- package/dist/src/a2ui/glchatStandardCatalog.d.ts +10 -0
- package/dist/src/a2ui/glchatStandardCatalog.d.ts.map +1 -0
- package/dist/src/a2ui/glchatStandardCatalog.js +14 -0
- package/dist/src/components/custom/Button.d.ts +3 -0
- package/dist/src/components/custom/Button.d.ts.map +1 -0
- package/dist/src/components/custom/Button.js +14 -0
- package/dist/src/components/custom/Card.d.ts +3 -0
- package/dist/src/components/custom/Card.d.ts.map +1 -0
- package/dist/src/components/custom/Card.js +7 -0
- package/dist/src/components/custom/Timeout.d.ts +3 -0
- package/dist/src/components/custom/Timeout.d.ts.map +1 -0
- package/dist/src/components/custom/Timeout.js +6 -0
- package/dist/src/components/{Button.d.ts → ui/Button.d.ts} +4 -4
- package/dist/src/components/ui/Button.d.ts.map +1 -0
- package/dist/src/components/ui/Button.js +38 -0
- package/dist/src/components/{Card.d.ts → ui/Card.d.ts} +1 -1
- package/dist/src/components/ui/Card.d.ts.map +1 -0
- package/dist/src/components/ui/Card.js +16 -0
- package/dist/src/components/ui/Timeout.d.ts +6 -0
- package/dist/src/components/ui/Timeout.d.ts.map +1 -0
- package/dist/src/components/{Timeout.js → ui/Timeout.js} +3 -4
- package/package.json +9 -5
- package/styles/globals.css +103 -0
- package/styles/theme-v4.css +86 -0
- package/tailwind.config.cjs +111 -0
- package/dist/src/components/Button.d.ts.map +0 -1
- package/dist/src/components/Button.js +0 -43
- package/dist/src/components/Card.d.ts.map +0 -1
- package/dist/src/components/Card.js +0 -16
- package/dist/src/components/Checkbox.d.ts +0 -5
- package/dist/src/components/Checkbox.d.ts.map +0 -1
- package/dist/src/components/Checkbox.js +0 -9
- package/dist/src/components/Column.d.ts +0 -13
- package/dist/src/components/Column.d.ts.map +0 -1
- package/dist/src/components/Column.js +0 -20
- package/dist/src/components/Image.d.ts +0 -9
- package/dist/src/components/Image.d.ts.map +0 -1
- package/dist/src/components/Image.js +0 -21
- package/dist/src/components/Input.d.ts +0 -8
- package/dist/src/components/Input.d.ts.map +0 -1
- package/dist/src/components/Input.js +0 -9
- package/dist/src/components/Label.d.ts +0 -5
- package/dist/src/components/Label.d.ts.map +0 -1
- package/dist/src/components/Label.js +0 -8
- package/dist/src/components/Row.d.ts +0 -13
- package/dist/src/components/Row.d.ts.map +0 -1
- package/dist/src/components/Row.js +0 -20
- package/dist/src/components/Separator.d.ts +0 -5
- package/dist/src/components/Separator.d.ts.map +0 -1
- package/dist/src/components/Separator.js +0 -11
- package/dist/src/components/Text.d.ts +0 -8
- package/dist/src/components/Text.d.ts.map +0 -1
- package/dist/src/components/Text.js +0 -19
- package/dist/src/components/TextField.d.ts +0 -13
- package/dist/src/components/TextField.d.ts.map +0 -1
- package/dist/src/components/TextField.js +0 -31
- package/dist/src/components/Timeout.d.ts +0 -8
- package/dist/src/components/Timeout.d.ts.map +0 -1
- package/dist/src/helpers/messageParser.d.ts +0 -10
- package/dist/src/helpers/messageParser.d.ts.map +0 -1
- package/dist/src/helpers/messageParser.js +0 -40
- package/dist/src/hooks/useA2UIProcessor.d.ts +0 -17
- package/dist/src/hooks/useA2UIProcessor.d.ts.map +0 -1
- package/dist/src/hooks/useA2UIProcessor.js +0 -16
- package/dist/src/rendering/Surface.d.ts +0 -28
- package/dist/src/rendering/Surface.d.ts.map +0 -1
- package/dist/src/rendering/Surface.js +0 -51
- package/dist/src/rendering/catalog.d.ts +0 -42
- package/dist/src/rendering/catalog.d.ts.map +0 -1
- package/dist/src/rendering/catalog.js +0 -136
- package/dist/src/rendering/componentRegistry.d.ts +0 -9
- package/dist/src/rendering/componentRegistry.d.ts.map +0 -1
- package/dist/src/rendering/componentRegistry.js +0 -10
- package/dist/src/runtime/bindingResolver.d.ts +0 -29
- package/dist/src/runtime/bindingResolver.d.ts.map +0 -1
- package/dist/src/runtime/bindingResolver.js +0 -143
- package/dist/src/runtime/dispatcher.d.ts +0 -15
- package/dist/src/runtime/dispatcher.d.ts.map +0 -1
- package/dist/src/runtime/dispatcher.js +0 -29
- package/dist/src/runtime/messageProcessor.d.ts +0 -54
- package/dist/src/runtime/messageProcessor.d.ts.map +0 -1
- package/dist/src/runtime/messageProcessor.js +0 -85
- package/dist/src/runtime/surfaceManager.d.ts +0 -48
- package/dist/src/runtime/surfaceManager.d.ts.map +0 -1
- package/dist/src/runtime/surfaceManager.js +0 -90
- package/dist/src/types.d.ts +0 -285
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js +0 -4
- package/dist/styles.css +0 -395
package/README.md
CHANGED
|
@@ -1,138 +1,260 @@
|
|
|
1
1
|
# glchat-a2ui-react-renderer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[`@a2ui-sdk/react`](https://www.npmjs.com/package/@a2ui-sdk/react) with GLChat-specific catalog and styling.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This package provides:
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
* **`glchatStandardCatalog`** – the standard A2UI catalog with GLChat custom components (`Button`, `Card`, `Timeout`). Use it as `catalog={glchatStandardCatalog}` with `A2UIProvider`.
|
|
8
|
+
* **Tailwind theming** – `styles/globals.css`, `styles/theme-v4.css`, and `tailwind-config.cjs` for default tokens and utilities.
|
|
8
9
|
|
|
9
|
-
This
|
|
10
|
+
This library provides **GLChat-specific components and styling** while remaining fully compatible with the upstream
|
|
11
|
+
A2UI renderer.
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
- **[Angular](https://github.com/google/A2UI/tree/main/renderers/angular)** — [A2UI Renderers](https://a2ui.org/renderers/)
|
|
13
|
+
---
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
# Prerequisites
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
- **Data binding:** `BoundValue` resolution (literal and/or path against the surface data model); `setData(surfaceId, path, value)` for TextField/CheckBox so input changes update the model and refresh the UI.
|
|
19
|
-
- **Client–server:** User actions with resolved `action.context` sent as `userAction` payloads.
|
|
17
|
+
* **React 18+**
|
|
18
|
+
* **Tailwind CSS v3 or v4**
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
---
|
|
22
21
|
|
|
23
|
-
|
|
22
|
+
# Install
|
|
24
23
|
|
|
25
24
|
```bash
|
|
26
25
|
npm install glchat-a2ui-react-renderer
|
|
27
26
|
```
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
# Quick Start
|
|
31
|
+
|
|
32
|
+
Use `A2UIProvider` and `A2UIRenderer` from this package with the GLChat catalog:
|
|
30
33
|
|
|
31
34
|
```tsx
|
|
32
|
-
import { useEffect } from 'react';
|
|
33
35
|
import {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
A2UIProvider,
|
|
37
|
+
A2UIRenderer,
|
|
38
|
+
glchatStandardCatalog,
|
|
39
|
+
type A2UIMessage,
|
|
40
|
+
type A2UIAction,
|
|
38
41
|
} from 'glchat-a2ui-react-renderer';
|
|
39
|
-
import type { Theme, ComponentCatalog } from 'glchat-a2ui-react-renderer';
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
function App() {
|
|
44
|
+
const messages: A2UIMessage[] = [
|
|
45
|
+
// A2UI messages from your backend
|
|
46
|
+
];
|
|
43
47
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
Text: { body: 'a2ui-text-body', h1: 'a2ui-text-h1' },
|
|
48
|
-
Button: 'a2ui-button a2ui-button--primary',
|
|
49
|
-
},
|
|
50
|
-
};
|
|
48
|
+
const handleAction = (action: A2UIAction) => {
|
|
49
|
+
console.log('Action received:', action);
|
|
50
|
+
};
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
return (
|
|
53
|
+
<A2UIProvider messages={messages} catalog={glchatStandardCatalog}>
|
|
54
|
+
<A2UIRenderer onAction={handleAction} />
|
|
55
|
+
</A2UIProvider>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
# Custom Catalog
|
|
61
|
+
|
|
62
|
+
To extend catalog, you can use `glchatStandardCatalog` as the base standard.
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import {
|
|
66
|
+
A2UIProvider,
|
|
67
|
+
A2UIRenderer,
|
|
68
|
+
glchatStandardCatalog,
|
|
69
|
+
type A2UIMessage,
|
|
70
|
+
type A2UIAction,
|
|
71
|
+
} from 'glchat-a2ui-react-renderer';
|
|
72
|
+
|
|
73
|
+
function App() {
|
|
74
|
+
const messages: A2UIMessage[] = [
|
|
75
|
+
// A2UI messages from your backend
|
|
76
|
+
];
|
|
57
77
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// do something with the user action (e.g. send it back to the agent)
|
|
70
|
-
try {
|
|
71
|
-
await processYourUserAction(event.message);
|
|
72
|
-
} catch (err) {
|
|
73
|
-
// handle error
|
|
74
|
-
} finally {
|
|
75
|
-
event.completion([]);
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
return unsubscribe;
|
|
79
|
-
}, [processor]);
|
|
78
|
+
const customCatalog = {
|
|
79
|
+
...glchatStandardCatalog,
|
|
80
|
+
components: {
|
|
81
|
+
...glchatStandardCatalog.components,
|
|
82
|
+
Button: CustomButtonComponent,
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const handleAction = (action: A2UIAction) => {
|
|
87
|
+
console.log('Action received:', action);
|
|
88
|
+
};
|
|
80
89
|
|
|
81
90
|
return (
|
|
82
|
-
|
|
83
|
-
{
|
|
84
|
-
|
|
85
|
-
key={surfaceId}
|
|
86
|
-
surfaceId={surfaceId}
|
|
87
|
-
surface={surface}
|
|
88
|
-
processor={processor}
|
|
89
|
-
refreshSurfaces={refreshSurfaces}
|
|
90
|
-
theme={theme}
|
|
91
|
-
catalog={catalog}
|
|
92
|
-
/>
|
|
93
|
-
))}
|
|
94
|
-
</>
|
|
91
|
+
<A2UIProvider messages={messages} catalog={glchatStandardCatalog}>
|
|
92
|
+
<A2UIRenderer onAction={handleAction} />
|
|
93
|
+
</A2UIProvider>
|
|
95
94
|
);
|
|
96
95
|
}
|
|
97
96
|
```
|
|
98
97
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
98
|
+
```tsx
|
|
99
|
+
import {
|
|
100
|
+
ComponentRenderer,
|
|
101
|
+
type ButtonComponentProps,
|
|
102
|
+
type CatalogComponent,
|
|
103
|
+
useDispatchAction,
|
|
104
|
+
} from "glchat-a2ui-react-renderer";
|
|
105
|
+
|
|
106
|
+
export const CustomButtonComponent: CatalogComponent = ({
|
|
107
|
+
surfaceId,
|
|
108
|
+
componentId,
|
|
109
|
+
...props
|
|
110
|
+
}) => {
|
|
111
|
+
const { child, action, primary } = props as ButtonComponentProps
|
|
112
|
+
const dispatchAction = useDispatchAction()
|
|
113
|
+
|
|
114
|
+
const handleClick = () => {
|
|
115
|
+
if (action) {
|
|
116
|
+
dispatchAction(surfaceId, componentId, action)
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const variant = primary ? 'primary' : 'outline';
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<Button onClick={handleClick} variant={variant}>
|
|
124
|
+
<div>masuk custom button</div>
|
|
125
|
+
{child && <ComponentRenderer surfaceId={surfaceId} componentId={child} />}
|
|
126
|
+
</Button>
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
```
|
|
107
130
|
|
|
108
|
-
|
|
131
|
+
Refer to the upstream docs for full API details:
|
|
132
|
+
[https://a2ui.org/renderers/](https://a2ui.org/renderers/)
|
|
109
133
|
|
|
110
|
-
|
|
111
|
-
- **Catalog:** `DEFAULT_CATALOG`, `renderComponentFromCatalog`, `ComponentCatalog`, `ComponentRenderer`, `ComponentRenderProps`
|
|
112
|
-
- **Theme:** `defaultTheme`, type `Theme` (optional `components` with className strings per component/part)
|
|
113
|
-
- **Runtime:** `MessageDispatcher`, `SurfaceManager`, `resolveBoundValue`, `getPathFromBoundValue`, `resolveActionContext`, `setPathValue`, `updateDataModel`, `parseJSONLStream`, `isValidMessage`
|
|
114
|
-
- **Types:** `A2UIMessage`, `BoundValue`, `ClientToServerMessage`, `DispatchedEvent`, `UserAction`, `SurfaceState`, `Theme`, `ComponentDefinition`, and other protocol types (aligned with Lit/Angular)
|
|
134
|
+
---
|
|
115
135
|
|
|
116
|
-
|
|
136
|
+
# Tailwind Setup
|
|
117
137
|
|
|
118
|
-
|
|
138
|
+
## Tailwind v4
|
|
119
139
|
|
|
120
|
-
|
|
140
|
+
Add the following to your main CSS file (`globals.css`):
|
|
121
141
|
|
|
122
|
-
|
|
142
|
+
```css
|
|
143
|
+
@import "tailwindcss";
|
|
123
144
|
|
|
124
|
-
|
|
125
|
-
import
|
|
145
|
+
/* Load design tokens */
|
|
146
|
+
@import "glchat-a2ui-react-renderer/styles/globals.css";
|
|
147
|
+
|
|
148
|
+
/* Register tokens with Tailwind */
|
|
149
|
+
@import "glchat-a2ui-react-renderer/styles/theme-v4.css";
|
|
150
|
+
|
|
151
|
+
/* Optional: ensure Tailwind scans this package */
|
|
152
|
+
@source "../node_modules/glchat-a2ui-react-renderer";
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Tailwind v3
|
|
158
|
+
|
|
159
|
+
Use the provided preset and include the package in `content`.
|
|
160
|
+
|
|
161
|
+
```js
|
|
162
|
+
const glchatPreset = require('glchat-a2ui-react-renderer/tailwind-config.cjs');
|
|
163
|
+
|
|
164
|
+
module.exports = {
|
|
165
|
+
presets: [glchatPreset],
|
|
166
|
+
content: [
|
|
167
|
+
'./src/**/*.{js,ts,jsx,tsx}',
|
|
168
|
+
'./app/**/*.{js,ts,jsx,tsx}',
|
|
169
|
+
'./node_modules/glchat-a2ui-react-renderer/dist/**/*.{js,jsx,ts,tsx}',
|
|
170
|
+
],
|
|
171
|
+
};
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Import the tokens in your main CSS:
|
|
175
|
+
|
|
176
|
+
```css
|
|
177
|
+
@import "glchat-a2ui-react-renderer/styles/globals.css";
|
|
178
|
+
|
|
179
|
+
@tailwind base;
|
|
180
|
+
@tailwind components;
|
|
181
|
+
@tailwind utilities;
|
|
126
182
|
```
|
|
127
183
|
|
|
128
|
-
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
# Customizing Colors
|
|
187
|
+
|
|
188
|
+
Override CSS variables after importing `globals.css`:
|
|
189
|
+
|
|
190
|
+
```css
|
|
191
|
+
:root {
|
|
192
|
+
--primary: 220 90% 45%;
|
|
193
|
+
--background: 0 0% 99%;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.dark {
|
|
197
|
+
--primary: 220 70% 50%;
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
You may also extend the theme via:
|
|
202
|
+
|
|
203
|
+
* `tailwind.config.js` (v3)
|
|
204
|
+
* `@theme` (v4)
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
# Exports
|
|
209
|
+
|
|
210
|
+
## GLChat catalog
|
|
211
|
+
|
|
212
|
+
* `glchatStandardCatalog` – standard catalog with custom Button, Card, Timeout
|
|
213
|
+
|
|
214
|
+
## Re-exports from `@a2ui-sdk/react`
|
|
215
|
+
|
|
216
|
+
### Components
|
|
217
|
+
|
|
218
|
+
* `A2UIProvider`
|
|
219
|
+
* `A2UIRenderer`
|
|
220
|
+
* `ComponentRenderer`
|
|
221
|
+
* `standardCatalog`
|
|
222
|
+
|
|
223
|
+
### Hooks
|
|
224
|
+
|
|
225
|
+
* `useDispatchAction`
|
|
226
|
+
* `useDataBinding`
|
|
227
|
+
* `useFormBinding`
|
|
228
|
+
* `useSurfaceContext`
|
|
229
|
+
* `useDataModelContext`
|
|
230
|
+
* `useA2UIMessageHandler`
|
|
231
|
+
|
|
232
|
+
### Context
|
|
233
|
+
|
|
234
|
+
* `ActionProvider`
|
|
235
|
+
* `useActionContext`
|
|
236
|
+
|
|
237
|
+
### Types
|
|
238
|
+
|
|
239
|
+
* `A2UIMessage`
|
|
240
|
+
* `A2UIAction`
|
|
241
|
+
* `Action`
|
|
242
|
+
* `ValueSource`
|
|
243
|
+
* `A2UIProviderProps`
|
|
244
|
+
* `A2UIRendererProps`
|
|
245
|
+
* `A2UIMessageHandler`
|
|
246
|
+
|
|
247
|
+
### Styles
|
|
248
|
+
|
|
249
|
+
* `styles/globals.css`
|
|
250
|
+
* `styles/theme-v4.css`
|
|
251
|
+
* `tailwind-config.cjs`
|
|
129
252
|
|
|
130
|
-
|
|
253
|
+
Full documentation:
|
|
254
|
+
[https://a2ui.org/renderers/](https://a2ui.org/renderers/)
|
|
131
255
|
|
|
132
|
-
|
|
133
|
-
- [A2UI Renderers (Lit, Angular, Flutter, React roadmap)](https://a2ui.org/renderers/)
|
|
134
|
-
- `src/README.md` in this package for architecture and message flow details.
|
|
256
|
+
---
|
|
135
257
|
|
|
136
|
-
|
|
258
|
+
# License
|
|
137
259
|
|
|
138
260
|
MIT
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
* Structure aligned with official Lit/Angular renderers: processor + A2UISurface.
|
|
4
|
-
* @packageDocumentation
|
|
5
|
-
*/
|
|
6
|
-
export { MessageProcessor } from './src/runtime/messageProcessor.js';
|
|
7
|
-
export { A2UISurface } from './src/rendering/Surface.js';
|
|
8
|
-
export type { A2UISurfaceProps } from './src/rendering/Surface.js';
|
|
9
|
-
export { useA2UIProcessor } from './src/hooks/useA2UIProcessor.js';
|
|
10
|
-
export type { UseA2UIProcessorResult } from './src/hooks/useA2UIProcessor.js';
|
|
11
|
-
export { DEFAULT_CATALOG, renderComponentFromCatalog, } from './src/rendering/catalog.js';
|
|
12
|
-
export type { ComponentCatalog, ComponentRenderer, ComponentRenderProps, } from './src/rendering/catalog.js';
|
|
13
|
-
export { resolveBoundValue, updateDataModel, getPathFromBoundValue, resolveActionContext, setPathValue, } from './src/runtime/bindingResolver.js';
|
|
14
|
-
export { MessageDispatcher } from './src/runtime/dispatcher.js';
|
|
15
|
-
export { SurfaceManager } from './src/runtime/surfaceManager.js';
|
|
16
|
-
export { parseJSONLStream, isValidMessage } from './src/helpers/messageParser.js';
|
|
17
|
-
export type { A2UIMessage, BeginRenderingMessage, SurfaceUpdateMessage, DataModelUpdateMessage, DeleteSurfaceMessage, BoundValue, ComponentDefinition, ClientToServerMessage, ClientError, DispatchedEvent, UserAction, ActionDefinition, ActionContextInput, DataModelContent, ValueMapItem, SurfaceState, Component, Theme, } from './src/types.js';
|
|
18
|
-
export { defaultTheme } from './src/types.js';
|
|
1
|
+
export { glchatStandardCatalog } from './src/a2ui/glchatStandardCatalog.js';
|
|
2
|
+
export * from './src/a2ui/adapter.js';
|
|
19
3
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAG5E,cAAc,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,17 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
// Primary API (same structure as Lit/Angular)
|
|
7
|
-
export { MessageProcessor } from './src/runtime/messageProcessor.js';
|
|
8
|
-
export { A2UISurface } from './src/rendering/Surface.js';
|
|
9
|
-
export { useA2UIProcessor } from './src/hooks/useA2UIProcessor.js';
|
|
10
|
-
// Catalog (type → component map, same pattern as Lit componentRegistry / Angular Catalog)
|
|
11
|
-
export { DEFAULT_CATALOG, renderComponentFromCatalog, } from './src/rendering/catalog.js';
|
|
12
|
-
// Runtime helpers
|
|
13
|
-
export { resolveBoundValue, updateDataModel, getPathFromBoundValue, resolveActionContext, setPathValue, } from './src/runtime/bindingResolver.js';
|
|
14
|
-
export { MessageDispatcher } from './src/runtime/dispatcher.js';
|
|
15
|
-
export { SurfaceManager } from './src/runtime/surfaceManager.js';
|
|
16
|
-
export { parseJSONLStream, isValidMessage } from './src/helpers/messageParser.js';
|
|
17
|
-
export { defaultTheme } from './src/types.js';
|
|
1
|
+
// GLChat catalog (extended upstream standard with custom components)
|
|
2
|
+
export { glchatStandardCatalog } from './src/a2ui/glchatStandardCatalog.js';
|
|
3
|
+
// Re-exports from @a2ui-sdk/react/0.8
|
|
4
|
+
export * from './src/a2ui/adapter.js';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { A2UIProvider, A2UIRenderer, ComponentRenderer, standardCatalog, useDispatchAction, useDataBinding, useFormBinding, useSurfaceContext, useDataModelContext, useA2UIMessageHandler, ActionProvider, useActionContext, type A2UIMessage, type A2UIAction, type Action, type ValueSource, type A2UIProviderProps, type A2UIRendererProps, type A2UIMessageHandler, type CatalogComponent, } from '@a2ui-sdk/react/0.8';
|
|
2
|
+
export * from '@a2ui-sdk/types/0.8/standard-catalog';
|
|
3
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../src/a2ui/adapter.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,eAAe,EAEf,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EAErB,cAAc,EACd,gBAAgB,EAEhB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,GACtB,MAAM,qBAAqB,CAAC;AAE7B,cAAc,sCAAsC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Central adapter for the wrapper package.
|
|
3
|
+
*/
|
|
4
|
+
export {
|
|
5
|
+
// Core components
|
|
6
|
+
A2UIProvider, A2UIRenderer, ComponentRenderer, standardCatalog,
|
|
7
|
+
// Hooks
|
|
8
|
+
useDispatchAction, useDataBinding, useFormBinding, useSurfaceContext, useDataModelContext, useA2UIMessageHandler,
|
|
9
|
+
// Context providers
|
|
10
|
+
ActionProvider, useActionContext, } from '@a2ui-sdk/react/0.8';
|
|
11
|
+
export * from '@a2ui-sdk/types/0.8/standard-catalog';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** GLChat standard catalog: upstream standard catalog + custom Button, Card, Timeout. */
|
|
2
|
+
export declare const glchatStandardCatalog: {
|
|
3
|
+
components: {
|
|
4
|
+
Button: import("@a2ui-sdk/react/0.8").CatalogComponent;
|
|
5
|
+
Card: import("@a2ui-sdk/react/0.8").CatalogComponent;
|
|
6
|
+
Timeout: import("@a2ui-sdk/react/0.8").CatalogComponent;
|
|
7
|
+
};
|
|
8
|
+
functions?: import("@a2ui-sdk/react/0.8").CatalogFunctions;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=glchatStandardCatalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glchatStandardCatalog.d.ts","sourceRoot":"","sources":["../../../src/a2ui/glchatStandardCatalog.ts"],"names":[],"mappings":"AAKA,yFAAyF;AACzF,eAAO,MAAM,qBAAqB;;;;;;;CAQjC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { standardCatalog } from '@a2ui-sdk/react/0.8';
|
|
2
|
+
import { CustomButtonComponent } from '../components/custom/Button.js';
|
|
3
|
+
import { CustomCardComponent } from '../components/custom/Card.js';
|
|
4
|
+
import { CustomTimeoutComponent } from '../components/custom/Timeout.js';
|
|
5
|
+
/** GLChat standard catalog: upstream standard catalog + custom Button, Card, Timeout. */
|
|
6
|
+
export const glchatStandardCatalog = {
|
|
7
|
+
...standardCatalog,
|
|
8
|
+
components: {
|
|
9
|
+
...standardCatalog.components,
|
|
10
|
+
Button: CustomButtonComponent,
|
|
11
|
+
Card: CustomCardComponent,
|
|
12
|
+
Timeout: CustomTimeoutComponent,
|
|
13
|
+
},
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/components/custom/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAA;AAQ5B,eAAO,MAAM,qBAAqB,EAAE,gBAoBnC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useDispatchAction, ComponentRenderer, } from '@a2ui-sdk/react/0.8';
|
|
3
|
+
import { Button } from '../ui/Button';
|
|
4
|
+
export const CustomButtonComponent = ({ surfaceId, componentId, ...props }) => {
|
|
5
|
+
const { child, action, primary, destructive } = props;
|
|
6
|
+
const dispatchAction = useDispatchAction();
|
|
7
|
+
const handleClick = () => {
|
|
8
|
+
if (action) {
|
|
9
|
+
dispatchAction(surfaceId, componentId, action);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
const variant = destructive ? 'destructive' : primary ? 'primary' : 'outline';
|
|
13
|
+
return (_jsx(Button, { onClick: handleClick, variant: variant, children: child && _jsx(ComponentRenderer, { surfaceId: surfaceId, componentId: child }) }));
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../../../src/components/custom/Card.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAqB,MAAM,qBAAqB,CAAA;AAI9E,eAAO,MAAM,mBAAmB,EAAE,gBAWjC,CAAA"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ComponentRenderer } from '@a2ui-sdk/react/0.8';
|
|
3
|
+
import { Card } from '../ui/Card';
|
|
4
|
+
export const CustomCardComponent = ({ surfaceId, componentId, ...props }) => {
|
|
5
|
+
const { child } = props;
|
|
6
|
+
return (_jsx(Card, { children: child && _jsx(ComponentRenderer, { surfaceId: surfaceId, componentId: child }) }));
|
|
7
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Timeout.d.ts","sourceRoot":"","sources":["../../../../src/components/custom/Timeout.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAO3D,eAAO,MAAM,sBAAsB,EAAE,gBAOpC,CAAA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Timeout } from "../ui/Timeout";
|
|
3
|
+
export const CustomTimeoutComponent = ({ surfaceId, componentId, ...props }) => {
|
|
4
|
+
const { targetTimeUtc } = props;
|
|
5
|
+
return _jsx(Timeout, { targetTimeUtc: targetTimeUtc });
|
|
6
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { VariantProps } from 'class-variance-authority';
|
|
2
|
-
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
3
|
-
asChild?: boolean;
|
|
4
|
-
}
|
|
5
2
|
declare const buttonVariants: (props?: ({
|
|
6
3
|
variant?: "primary" | "secondary" | "destructive" | "destructive-subtle" | "outline" | "ghost-primary" | "ghost-neutral" | "ghost-destructive" | "link-primary" | "link-neutral" | null | undefined;
|
|
7
|
-
size?: "
|
|
4
|
+
size?: "tiny" | "small" | "medium" | "large" | "icon" | null | undefined;
|
|
8
5
|
shape?: "normal" | "pill" | null | undefined;
|
|
9
6
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
+
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
|
|
8
|
+
asChild?: boolean;
|
|
9
|
+
}
|
|
10
10
|
declare const Button: import("react").ForwardRefExoticComponent<ButtonProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
11
11
|
export { Button, buttonVariants };
|
|
12
12
|
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/Button.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAO,MAAM,0BAA0B,CAAC;AAE7D,QAAA,MAAM,cAAc;;;;8EAiFnB,CAAC;AAEF,MAAM,WAAW,WACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EACnD,YAAY,CAAC,OAAO,cAAc,CAAC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,QAAA,MAAM,MAAM,2GAsBX,CAAC;AAIF,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { cn } from '../../helpers/css.js';
|
|
5
|
+
import { cva } from 'class-variance-authority';
|
|
6
|
+
const buttonVariants = cva(cn('group inline-flex font-semibold border items-center justify-center whitespace-nowrap ring-offset-background transition-colors cursor-pointer', 'disabled:pointer-events-none disabled:opacity-secondary'), {
|
|
7
|
+
variants: {
|
|
8
|
+
variant: {
|
|
9
|
+
primary: cn('border-primary bg-primary text-primary-foreground', 'hover:border-primary-hover hover:bg-primary-hover', 'focus:bg-primary-hover focus:outline-none focus:ring-2 focus:ring-ring', 'focus-visible:bg-primary-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', 'active:bg-primary-hover active:outline-none active:ring-2 active:ring-ring'),
|
|
10
|
+
secondary: cn('border-primary-subtle bg-primary-subtle text-primary-subtle-foreground', 'hover:border-primary-subtle-hover hover:bg-primary-subtle-hover ', 'focus:border-primary-subtle-hover focus:bg-primary-subtle-hover focus:outline-none focus:ring-2 focus:ring-ring', 'focus-visible:border-primary-subtle-hover focus-visible:bg-primary-subtle-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', 'active:border-primary-subtle-hover active:bg-primary-subtle-hover active:outline-none active:ring-2 active:ring-ring'),
|
|
11
|
+
destructive: cn('border-destructive bg-destructive text-destructive-foreground', 'hover:border-destructive-hover hover:bg-destructive-hover', 'focus:bg-destructive-hover focus:border-destructive-hover focus:outline-none focus:ring-2 focus:ring-ring', 'focus-visible:bg-destructive-hover focus-visible:border-destructive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', 'active:bg-destructive-hover active:border-destructive-hover active:outline-none active:ring-2 active:ring-ring'),
|
|
12
|
+
'destructive-subtle': cn('border-destructive-alternate bg-destructive-alternate text-destructive', 'hover:border-destructive-alternate-hover hover:bg-destructive-alternate-hover', 'focus:bg-destructive-alternate-hover focus:border-destructive-alternate-hover focus:outline-none focus:ring-2 focus:ring-ring', 'focus-visible:bg-destructive-alternate-hover focus-visible:border-destructive-alternate-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring', 'active:bg-destructive-alternate-hover active:border-destructive-alternate-hover active:outline-none active:ring-2 active:ring-ring'),
|
|
13
|
+
outline: cn('bg-background text-foreground border-border', 'hover:bg-background-hover', 'focus:bg-background-hover', 'focus-visible:bg-background-hover', 'active:bg-background-hover'),
|
|
14
|
+
'ghost-primary': cn('group-hover:underline group-hover:decoration-primary group-active:underline group-active:decoration-primary', 'text-primary border-transparent', 'hover:bg-primary-hover hover:border-primary-hover', 'focus:bg-primary-hover focus:border-primary-hover', 'focus-visible:bg-primary-hover focus-visible:border-primary-hover', 'active:bg-primary-hover active:border-primary-hover'),
|
|
15
|
+
'ghost-neutral': cn('border-transparent text-foreground', 'hover:bg-background-hover hover:border-background-hover', 'focus:bg-background-hover focus:border-background-hover', 'focus-visible:bg-background-hover focus-visible:border-background-hover', 'active:bg-background-hover active:border-background-hover'),
|
|
16
|
+
'ghost-destructive': cn('border-transparent text-destructive', 'hover:bg-destructive-alternate hover:border-destructive-alternate', 'focus:bg-destructive-alternate focus:border-destructive-alternate', 'focus-visible:bg-destructive-alternate focus-visible:border-destructive-alternate', 'active:bg-destructive-alternate active:border-destructive-alternate'),
|
|
17
|
+
'link-primary': cn('border-transparent text-primary'),
|
|
18
|
+
'link-neutral': cn('border-transparent text-foreground'),
|
|
19
|
+
},
|
|
20
|
+
size: {
|
|
21
|
+
tiny: 'text-sm px-[12px] py-[6px] rounded-[6px]',
|
|
22
|
+
small: 'text-base px-[16px] py-[8px] rounded-[8px]',
|
|
23
|
+
medium: 'text-base px-[16px] py-[10px] rounded-[10px]',
|
|
24
|
+
large: 'text-lg px-[20px] py-[10px] rounded-[12px]',
|
|
25
|
+
icon: 'h-10 w-10 rounded-[8px]',
|
|
26
|
+
},
|
|
27
|
+
shape: {
|
|
28
|
+
normal: '',
|
|
29
|
+
pill: 'rounded-full',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
const Button = forwardRef(({ className, variant = 'primary', size = 'medium', shape = 'normal', asChild = false, ...props }, ref) => {
|
|
34
|
+
const Comp = asChild ? Slot : 'button';
|
|
35
|
+
return (_jsx(Comp, { className: cn(buttonVariants({ variant, size, shape }), className), ref: ref, ...props }));
|
|
36
|
+
});
|
|
37
|
+
Button.displayName = 'Button';
|
|
38
|
+
export { Button, buttonVariants };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
declare const Card: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
3
3
|
declare const CardHeader: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
-
declare const CardTitle: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLHeadingElement> & React.RefAttributes<
|
|
4
|
+
declare const CardTitle: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLHeadingElement> & React.RefAttributes<HTMLHeadingElement>>;
|
|
5
5
|
declare const CardDescription: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLParagraphElement> & React.RefAttributes<HTMLParagraphElement>>;
|
|
6
6
|
declare const CardContent: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
7
7
|
declare const CardFooter: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Card.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/Card.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,QAAA,MAAM,IAAI,6GAYR,CAAC;AAGH,QAAA,MAAM,UAAU,6GASd,CAAC;AAGH,QAAA,MAAM,SAAS,qHAWb,CAAC;AAGH,QAAA,MAAM,eAAe,yHAKnB,CAAC;AAGH,QAAA,MAAM,WAAW,6GAKf,CAAC;AAGH,QAAA,MAAM,UAAU,6GASd,CAAC;AAGH,OAAO,EACL,IAAI,EACJ,WAAW,EACX,eAAe,EACf,UAAU,EACV,UAAU,EACV,SAAS,GACV,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { cn } from '../../helpers/css.js';
|
|
4
|
+
const Card = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn('rounded-lg border border-border p-4 bg-card text-card-foreground shadow-sm transition-colors duration-300', className), ...props })));
|
|
5
|
+
Card.displayName = 'Card';
|
|
6
|
+
const CardHeader = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn('flex flex-col space-y-1.5 p-6', className), ...props })));
|
|
7
|
+
CardHeader.displayName = 'CardHeader';
|
|
8
|
+
const CardTitle = React.forwardRef(({ className, children, ...props }, ref) => (_jsx("h3", { ref: ref, className: cn('font-semibold leading-none tracking-tight', className), ...props, children: children })));
|
|
9
|
+
CardTitle.displayName = 'CardTitle';
|
|
10
|
+
const CardDescription = React.forwardRef(({ className, ...props }, ref) => (_jsx("p", { ref: ref, className: cn('text-sm', className), ...props })));
|
|
11
|
+
CardDescription.displayName = 'CardDescription';
|
|
12
|
+
const CardContent = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn('p-6 pt-0', className), ...props })));
|
|
13
|
+
CardContent.displayName = 'CardContent';
|
|
14
|
+
const CardFooter = React.forwardRef(({ className, ...props }, ref) => (_jsx("div", { ref: ref, className: cn('flex items-center p-6 pt-0', className), ...props })));
|
|
15
|
+
CardFooter.displayName = 'CardFooter';
|
|
16
|
+
export { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Timeout.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/Timeout.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,YAAY;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAiBD,wBAAgB,OAAO,CAAC,EACtB,aAAa,EACb,SAAS,GACV,EAAE,QAAQ,CAAC,YAAY,CAAC,2CAyBxB"}
|